From cbc6449621e773e4d6f7c33682601eb1aa967a32 Mon Sep 17 00:00:00 2001 From: ArjixWasTaken Date: Sat, 11 Oct 2025 18:18:36 +0300 Subject: [PATCH] fix preload --- src/plugins/navigation/index.tsx | 10 +++--- .../renderer/components/LyricsPicker.tsx | 27 +++++++++++----- src/preload.ts | 31 ++++++------------- vite-plugins/plugin-loader.mts | 4 +-- 4 files changed, 37 insertions(+), 35 deletions(-) diff --git a/src/plugins/navigation/index.tsx b/src/plugins/navigation/index.tsx index 54baccd9..410038c8 100644 --- a/src/plugins/navigation/index.tsx +++ b/src/plugins/navigation/index.tsx @@ -1,13 +1,12 @@ import { render } from 'solid-js/web'; -import style from './style.css?inline'; +import { IconChevronLeft } from '@mdui/icons/chevron-left.js'; +import { IconChevronRight } from '@mdui/icons/chevron-right.js'; + import { createPlugin } from '@/utils'; import { t } from '@/i18n'; -import '@mdui/icons/chevron-left.js'; -import '@mdui/icons/chevron-right.js'; - export default createPlugin({ name: () => t('plugins.navigation.name'), description: () => t('plugins.navigation.description'), @@ -18,6 +17,9 @@ export default createPlugin({ renderer: { buttonContainer: document.createElement('div'), start() { + const doNotTreeShake = [IconChevronLeft, IconChevronRight]; + ((a) => {})(doNotTreeShake); + if (!this.buttonContainer) { this.buttonContainer = document.createElement('div'); } diff --git a/src/plugins/synced-lyrics/renderer/components/LyricsPicker.tsx b/src/plugins/synced-lyrics/renderer/components/LyricsPicker.tsx index 5495f992..dd95f59d 100644 --- a/src/plugins/synced-lyrics/renderer/components/LyricsPicker.tsx +++ b/src/plugins/synced-lyrics/renderer/components/LyricsPicker.tsx @@ -15,6 +15,14 @@ import { import * as z from 'zod'; +import { IconChevronLeft } from '@mdui/icons/chevron-left.js'; +import { IconChevronRight } from '@mdui/icons/chevron-right.js'; +import { IconCheckCircle } from '@mdui/icons/check-circle.js'; +import { IconWarning } from '@mdui/icons/warning.js'; +import { IconError } from '@mdui/icons/error.js'; +import { IconStar } from '@mdui/icons/star.js'; +import { IconStarBorder } from '@mdui/icons/star-border.js'; + import { type ProviderName, ProviderNames, @@ -26,14 +34,6 @@ import { currentLyrics, lyricsStore, setLyricsStore } from '../store'; import { _ytAPI } from '../index'; import { config } from '../renderer'; -import '@mdui/icons/chevron-left.js'; -import '@mdui/icons/chevron-right.js'; -import '@mdui/icons/check-circle.js'; -import '@mdui/icons/warning.js'; -import '@mdui/icons/error.js'; -import '@mdui/icons/star.js'; -import '@mdui/icons/star-border.js'; - import type { PlayerAPIEvents } from '@/types/player-api-events'; const LocalStorageSchema = z.object({ @@ -82,6 +82,17 @@ const [hasManuallySwitchedProvider, setHasManuallySwitchedProvider] = export const LyricsPicker = (props: { setStickRef: Setter; }) => { + const doNotTreeShake = [ + IconChevronLeft, + IconChevronRight, + IconCheckCircle, + IconWarning, + IconError, + IconStar, + IconStarBorder, + ]; + ((a) => {})(doNotTreeShake); + const [videoId, setVideoId] = createSignal(null); const [starredProvider, setStarredProvider] = createSignal(null); diff --git a/src/preload.ts b/src/preload.ts index fb754d43..6b93bc21 100644 --- a/src/preload.ts +++ b/src/preload.ts @@ -8,18 +8,18 @@ import is from 'electron-is'; import * as config from './config'; -import mduiStyleSheet from '@assets/mdui.css?inline'; +import { + forceLoadPreloadPlugin, + forceUnloadPreloadPlugin, + loadAllPreloadPlugins, +} from './loader/preload'; +import { loadI18n, setLanguage } from '@/i18n'; -contextBridge.exposeInMainWorld( - 'litIssuedWarnings', - new Set([ - 'Lit is in dev mode. Not recommended for production! See https://lit.dev/msg/dev-mode for more information.', - 'Shadow DOM is being polyfilled via `ShadyDOM` but the `polyfill-support` module has not been loaded. See https://lit.dev/msg/polyfill-support-missing for more information.', - ]), -); +// @ts-expect-error dummy +globalThis.customElements = { define() {} }; new MutationObserver((mutations, observer) => { - outer: for (const mutation of mutations) { + for (const mutation of mutations) { for (const node of mutation.addedNodes) { const elem = node as HTMLElement; if (elem.tagName !== 'SCRIPT') continue; @@ -32,23 +32,12 @@ new MutationObserver((mutations, observer) => { script.remove(); - const styleSheet = new CSSStyleSheet(); - styleSheet.replaceSync(mduiStyleSheet); - document.adoptedStyleSheets.push(styleSheet); - observer.disconnect(); - break outer; + return; } } }).observe(document, { subtree: true, childList: true }); -import { - forceLoadPreloadPlugin, - forceUnloadPreloadPlugin, - loadAllPreloadPlugins, -} from './loader/preload'; -import { loadI18n, setLanguage } from '@/i18n'; - loadI18n().then(async () => { await setLanguage(config.get('options.language') ?? 'en'); await loadAllPreloadPlugins(); diff --git a/vite-plugins/plugin-loader.mts b/vite-plugins/plugin-loader.mts index 98e71906..e9c3f36e 100644 --- a/vite-plugins/plugin-loader.mts +++ b/vite-plugins/plugin-loader.mts @@ -5,9 +5,9 @@ import { fileURLToPath } from 'node:url'; import { Project, ts, - ObjectLiteralExpression, VariableDeclarationKind, - Node, + type ObjectLiteralExpression, + type Node, type ObjectLiteralElementLike, } from 'ts-morph';