Skip to content

Commit cbc6449

Browse files
committed
fix preload
1 parent 9b8daac commit cbc6449

File tree

4 files changed

+37
-35
lines changed

4 files changed

+37
-35
lines changed

src/plugins/navigation/index.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import { render } from 'solid-js/web';
22

3-
import style from './style.css?inline';
3+
import { IconChevronLeft } from '@mdui/icons/chevron-left.js';
4+
import { IconChevronRight } from '@mdui/icons/chevron-right.js';
5+
46
import { createPlugin } from '@/utils';
57

68
import { t } from '@/i18n';
79

8-
import '@mdui/icons/chevron-left.js';
9-
import '@mdui/icons/chevron-right.js';
10-
1110
export default createPlugin({
1211
name: () => t('plugins.navigation.name'),
1312
description: () => t('plugins.navigation.description'),
@@ -18,6 +17,9 @@ export default createPlugin({
1817
renderer: {
1918
buttonContainer: document.createElement('div'),
2019
start() {
20+
const doNotTreeShake = [IconChevronLeft, IconChevronRight];
21+
((a) => {})(doNotTreeShake);
22+
2123
if (!this.buttonContainer) {
2224
this.buttonContainer = document.createElement('div');
2325
}

src/plugins/synced-lyrics/renderer/components/LyricsPicker.tsx

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@ import {
1515

1616
import * as z from 'zod';
1717

18+
import { IconChevronLeft } from '@mdui/icons/chevron-left.js';
19+
import { IconChevronRight } from '@mdui/icons/chevron-right.js';
20+
import { IconCheckCircle } from '@mdui/icons/check-circle.js';
21+
import { IconWarning } from '@mdui/icons/warning.js';
22+
import { IconError } from '@mdui/icons/error.js';
23+
import { IconStar } from '@mdui/icons/star.js';
24+
import { IconStarBorder } from '@mdui/icons/star-border.js';
25+
1826
import {
1927
type ProviderName,
2028
ProviderNames,
@@ -26,14 +34,6 @@ import { currentLyrics, lyricsStore, setLyricsStore } from '../store';
2634
import { _ytAPI } from '../index';
2735
import { config } from '../renderer';
2836

29-
import '@mdui/icons/chevron-left.js';
30-
import '@mdui/icons/chevron-right.js';
31-
import '@mdui/icons/check-circle.js';
32-
import '@mdui/icons/warning.js';
33-
import '@mdui/icons/error.js';
34-
import '@mdui/icons/star.js';
35-
import '@mdui/icons/star-border.js';
36-
3737
import type { PlayerAPIEvents } from '@/types/player-api-events';
3838

3939
const LocalStorageSchema = z.object({
@@ -82,6 +82,17 @@ const [hasManuallySwitchedProvider, setHasManuallySwitchedProvider] =
8282
export const LyricsPicker = (props: {
8383
setStickRef: Setter<HTMLElement | null>;
8484
}) => {
85+
const doNotTreeShake = [
86+
IconChevronLeft,
87+
IconChevronRight,
88+
IconCheckCircle,
89+
IconWarning,
90+
IconError,
91+
IconStar,
92+
IconStarBorder,
93+
];
94+
((a) => {})(doNotTreeShake);
95+
8596
const [videoId, setVideoId] = createSignal<string | null>(null);
8697
const [starredProvider, setStarredProvider] =
8798
createSignal<ProviderName | null>(null);

src/preload.ts

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@ import is from 'electron-is';
88

99
import * as config from './config';
1010

11-
import mduiStyleSheet from '@assets/mdui.css?inline';
11+
import {
12+
forceLoadPreloadPlugin,
13+
forceUnloadPreloadPlugin,
14+
loadAllPreloadPlugins,
15+
} from './loader/preload';
16+
import { loadI18n, setLanguage } from '@/i18n';
1217

13-
contextBridge.exposeInMainWorld(
14-
'litIssuedWarnings',
15-
new Set([
16-
'Lit is in dev mode. Not recommended for production! See https://lit.dev/msg/dev-mode for more information.',
17-
'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.',
18-
]),
19-
);
18+
// @ts-expect-error dummy
19+
globalThis.customElements = { define() {} };
2020

2121
new MutationObserver((mutations, observer) => {
22-
outer: for (const mutation of mutations) {
22+
for (const mutation of mutations) {
2323
for (const node of mutation.addedNodes) {
2424
const elem = node as HTMLElement;
2525
if (elem.tagName !== 'SCRIPT') continue;
@@ -32,23 +32,12 @@ new MutationObserver((mutations, observer) => {
3232

3333
script.remove();
3434

35-
const styleSheet = new CSSStyleSheet();
36-
styleSheet.replaceSync(mduiStyleSheet);
37-
document.adoptedStyleSheets.push(styleSheet);
38-
3935
observer.disconnect();
40-
break outer;
36+
return;
4137
}
4238
}
4339
}).observe(document, { subtree: true, childList: true });
4440

45-
import {
46-
forceLoadPreloadPlugin,
47-
forceUnloadPreloadPlugin,
48-
loadAllPreloadPlugins,
49-
} from './loader/preload';
50-
import { loadI18n, setLanguage } from '@/i18n';
51-
5241
loadI18n().then(async () => {
5342
await setLanguage(config.get('options.language') ?? 'en');
5443
await loadAllPreloadPlugins();

vite-plugins/plugin-loader.mts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import { fileURLToPath } from 'node:url';
55
import {
66
Project,
77
ts,
8-
ObjectLiteralExpression,
98
VariableDeclarationKind,
10-
Node,
9+
type ObjectLiteralExpression,
10+
type Node,
1111
type ObjectLiteralElementLike,
1212
} from 'ts-morph';
1313

0 commit comments

Comments
 (0)