mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-09 01:31:46 +00:00
fix preload
This commit is contained in:
@ -1,13 +1,12 @@
|
|||||||
import { render } from 'solid-js/web';
|
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 { createPlugin } from '@/utils';
|
||||||
|
|
||||||
import { t } from '@/i18n';
|
import { t } from '@/i18n';
|
||||||
|
|
||||||
import '@mdui/icons/chevron-left.js';
|
|
||||||
import '@mdui/icons/chevron-right.js';
|
|
||||||
|
|
||||||
export default createPlugin({
|
export default createPlugin({
|
||||||
name: () => t('plugins.navigation.name'),
|
name: () => t('plugins.navigation.name'),
|
||||||
description: () => t('plugins.navigation.description'),
|
description: () => t('plugins.navigation.description'),
|
||||||
@ -18,6 +17,9 @@ export default createPlugin({
|
|||||||
renderer: {
|
renderer: {
|
||||||
buttonContainer: document.createElement('div'),
|
buttonContainer: document.createElement('div'),
|
||||||
start() {
|
start() {
|
||||||
|
const doNotTreeShake = [IconChevronLeft, IconChevronRight];
|
||||||
|
((a) => {})(doNotTreeShake);
|
||||||
|
|
||||||
if (!this.buttonContainer) {
|
if (!this.buttonContainer) {
|
||||||
this.buttonContainer = document.createElement('div');
|
this.buttonContainer = document.createElement('div');
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,6 +15,14 @@ import {
|
|||||||
|
|
||||||
import * as z from 'zod';
|
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 {
|
import {
|
||||||
type ProviderName,
|
type ProviderName,
|
||||||
ProviderNames,
|
ProviderNames,
|
||||||
@ -26,14 +34,6 @@ import { currentLyrics, lyricsStore, setLyricsStore } from '../store';
|
|||||||
import { _ytAPI } from '../index';
|
import { _ytAPI } from '../index';
|
||||||
import { config } from '../renderer';
|
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';
|
import type { PlayerAPIEvents } from '@/types/player-api-events';
|
||||||
|
|
||||||
const LocalStorageSchema = z.object({
|
const LocalStorageSchema = z.object({
|
||||||
@ -82,6 +82,17 @@ const [hasManuallySwitchedProvider, setHasManuallySwitchedProvider] =
|
|||||||
export const LyricsPicker = (props: {
|
export const LyricsPicker = (props: {
|
||||||
setStickRef: Setter<HTMLElement | null>;
|
setStickRef: Setter<HTMLElement | null>;
|
||||||
}) => {
|
}) => {
|
||||||
|
const doNotTreeShake = [
|
||||||
|
IconChevronLeft,
|
||||||
|
IconChevronRight,
|
||||||
|
IconCheckCircle,
|
||||||
|
IconWarning,
|
||||||
|
IconError,
|
||||||
|
IconStar,
|
||||||
|
IconStarBorder,
|
||||||
|
];
|
||||||
|
((a) => {})(doNotTreeShake);
|
||||||
|
|
||||||
const [videoId, setVideoId] = createSignal<string | null>(null);
|
const [videoId, setVideoId] = createSignal<string | null>(null);
|
||||||
const [starredProvider, setStarredProvider] =
|
const [starredProvider, setStarredProvider] =
|
||||||
createSignal<ProviderName | null>(null);
|
createSignal<ProviderName | null>(null);
|
||||||
|
|||||||
@ -8,18 +8,18 @@ import is from 'electron-is';
|
|||||||
|
|
||||||
import * as config from './config';
|
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(
|
// @ts-expect-error dummy
|
||||||
'litIssuedWarnings',
|
globalThis.customElements = { define() {} };
|
||||||
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.',
|
|
||||||
]),
|
|
||||||
);
|
|
||||||
|
|
||||||
new MutationObserver((mutations, observer) => {
|
new MutationObserver((mutations, observer) => {
|
||||||
outer: for (const mutation of mutations) {
|
for (const mutation of mutations) {
|
||||||
for (const node of mutation.addedNodes) {
|
for (const node of mutation.addedNodes) {
|
||||||
const elem = node as HTMLElement;
|
const elem = node as HTMLElement;
|
||||||
if (elem.tagName !== 'SCRIPT') continue;
|
if (elem.tagName !== 'SCRIPT') continue;
|
||||||
@ -32,23 +32,12 @@ new MutationObserver((mutations, observer) => {
|
|||||||
|
|
||||||
script.remove();
|
script.remove();
|
||||||
|
|
||||||
const styleSheet = new CSSStyleSheet();
|
|
||||||
styleSheet.replaceSync(mduiStyleSheet);
|
|
||||||
document.adoptedStyleSheets.push(styleSheet);
|
|
||||||
|
|
||||||
observer.disconnect();
|
observer.disconnect();
|
||||||
break outer;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).observe(document, { subtree: true, childList: true });
|
}).observe(document, { subtree: true, childList: true });
|
||||||
|
|
||||||
import {
|
|
||||||
forceLoadPreloadPlugin,
|
|
||||||
forceUnloadPreloadPlugin,
|
|
||||||
loadAllPreloadPlugins,
|
|
||||||
} from './loader/preload';
|
|
||||||
import { loadI18n, setLanguage } from '@/i18n';
|
|
||||||
|
|
||||||
loadI18n().then(async () => {
|
loadI18n().then(async () => {
|
||||||
await setLanguage(config.get('options.language') ?? 'en');
|
await setLanguage(config.get('options.language') ?? 'en');
|
||||||
await loadAllPreloadPlugins();
|
await loadAllPreloadPlugins();
|
||||||
|
|||||||
@ -5,9 +5,9 @@ import { fileURLToPath } from 'node:url';
|
|||||||
import {
|
import {
|
||||||
Project,
|
Project,
|
||||||
ts,
|
ts,
|
||||||
ObjectLiteralExpression,
|
|
||||||
VariableDeclarationKind,
|
VariableDeclarationKind,
|
||||||
Node,
|
type ObjectLiteralExpression,
|
||||||
|
type Node,
|
||||||
type ObjectLiteralElementLike,
|
type ObjectLiteralElementLike,
|
||||||
} from 'ts-morph';
|
} from 'ts-morph';
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user