mirror of
https://github.com/d0zingcat/MoviePilot-Plugins.git
synced 2026-05-13 15:09:12 +00:00
88 lines
3.9 KiB
JavaScript
88 lines
3.9 KiB
JavaScript
const currentImports = {};
|
|
const exportSet = new Set(['Module', '__esModule', 'default', '_export_sfc']);
|
|
let moduleMap = {
|
|
"./Page":()=>{
|
|
dynamicLoadingCss(["__federation_expose_Page-BOym_1fV.css"], false, './Page');
|
|
return __federation_import('./__federation_expose_Page-D5l2MyNA.js').then(module =>Object.keys(module).every(item => exportSet.has(item)) ? () => module.default : () => module)},
|
|
"./Config":()=>{
|
|
dynamicLoadingCss(["__federation_expose_Config-BrXQaadr.css"], false, './Config');
|
|
return __federation_import('./__federation_expose_Config-NH09p1Am.js').then(module =>Object.keys(module).every(item => exportSet.has(item)) ? () => module.default : () => module)},
|
|
"./Dashboard":()=>{
|
|
dynamicLoadingCss(["__federation_expose_Dashboard-vS9Qm2ZB.css"], false, './Dashboard');
|
|
return __federation_import('./__federation_expose_Dashboard-BDSt5WaH.js').then(module =>Object.keys(module).every(item => exportSet.has(item)) ? () => module.default : () => module)},};
|
|
const seen = {};
|
|
const dynamicLoadingCss = (cssFilePaths, dontAppendStylesToHead, exposeItemName) => {
|
|
const metaUrl = import.meta.url;
|
|
if (typeof metaUrl === 'undefined') {
|
|
console.warn('The remote style takes effect only when the build.target option in the vite.config.ts file is higher than that of "es2020".');
|
|
return;
|
|
}
|
|
|
|
const curUrl = metaUrl.substring(0, metaUrl.lastIndexOf('remoteEntry.js'));
|
|
const base = '/';
|
|
'assets';
|
|
|
|
cssFilePaths.forEach(cssPath => {
|
|
let href = '';
|
|
const baseUrl = base || curUrl;
|
|
if (baseUrl) {
|
|
const trimmer = {
|
|
trailing: (path) => (path.endsWith('/') ? path.slice(0, -1) : path),
|
|
leading: (path) => (path.startsWith('/') ? path.slice(1) : path)
|
|
};
|
|
const isAbsoluteUrl = (url) => url.startsWith('http') || url.startsWith('//');
|
|
|
|
const cleanBaseUrl = trimmer.trailing(baseUrl);
|
|
const cleanCssPath = trimmer.leading(cssPath);
|
|
const cleanCurUrl = trimmer.trailing(curUrl);
|
|
|
|
if (isAbsoluteUrl(baseUrl)) {
|
|
href = [cleanBaseUrl, cleanCssPath].filter(Boolean).join('/');
|
|
} else {
|
|
if (cleanCurUrl.includes(cleanBaseUrl)) {
|
|
href = [cleanCurUrl, cleanCssPath].filter(Boolean).join('/');
|
|
} else {
|
|
href = [cleanCurUrl + cleanBaseUrl, cleanCssPath].filter(Boolean).join('/');
|
|
}
|
|
}
|
|
} else {
|
|
href = cssPath;
|
|
}
|
|
|
|
if (dontAppendStylesToHead) {
|
|
const key = 'css__ClashRuleProvider__' + exposeItemName;
|
|
window[key] = window[key] || [];
|
|
window[key].push(href);
|
|
return;
|
|
}
|
|
|
|
if (href in seen) return;
|
|
seen[href] = true;
|
|
|
|
const element = document.createElement('link');
|
|
element.rel = 'stylesheet';
|
|
element.href = href;
|
|
document.head.appendChild(element);
|
|
});
|
|
};
|
|
async function __federation_import(name) {
|
|
currentImports[name] ??= import(name);
|
|
return currentImports[name]
|
|
} const get =(module) => {
|
|
if(!moduleMap[module]) throw new Error('Can not find remote module ' + module)
|
|
return moduleMap[module]();
|
|
};
|
|
const init =(shareScope) => {
|
|
globalThis.__federation_shared__= globalThis.__federation_shared__|| {};
|
|
Object.entries(shareScope).forEach(([key, value]) => {
|
|
for (const [versionKey, versionValue] of Object.entries(value)) {
|
|
const scope = versionValue.scope || 'default';
|
|
globalThis.__federation_shared__[scope] = globalThis.__federation_shared__[scope] || {};
|
|
const shared= globalThis.__federation_shared__[scope];
|
|
(shared[key] = shared[key]||{})[versionKey] = versionValue;
|
|
}
|
|
});
|
|
};
|
|
|
|
export { dynamicLoadingCss, get, init };
|