UNPKG

@luzmo/embed

Version:

A modern [Web Component](https://developer.mozilla.org/en-US/docs/Web/Web_Components) for [Luzmo](https://luzmo.com) dashboards in your web application.

1,328 lines (1,325 loc) 276 kB
(function(g,f){if(typeof define=="function"&&define.amd){define(f)}else if(typeof exports=="object" && typeof module<"u"){module.exports=f()}else{var m=f();for(var i in m) g[i]=m[i]}}(typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : this,function(){var exports={};var __exports=exports;var module={exports}; "use strict"; var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; var __hasOwnProp = Object.prototype.hasOwnProperty; var __commonJS = (cb2, mod) => function __require() { return mod || (0, cb2[__getOwnPropNames(cb2)[0]])((mod = { exports: {} }).exports, mod), mod.exports; }; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( // If the importer is in node compatibility mode or this is not an ESM // file that has been converted to a CommonJS file using a Babel- // compatible transform (i.e. "__esModule" has not been set), then set // "default" to the CommonJS "module.exports" for node compatibility. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod )); var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var __decorateClass = (decorators, target, key, kind) => { var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target; for (var i7 = decorators.length - 1, decorator; i7 >= 0; i7--) if (decorator = decorators[i7]) result = (kind ? decorator(target, key, result) : decorator(result)) || result; if (kind && result) __defProp(target, key, result); return result; }; // node_modules/@module-federation/sdk/dist/index.cjs.cjs var require_index_cjs = __commonJS({ "node_modules/@module-federation/sdk/dist/index.cjs.cjs"(exports, module) { "use strict"; var FederationModuleManifest = "federation-manifest.json"; var MANIFEST_EXT = ".json"; var BROWSER_LOG_KEY = "FEDERATION_DEBUG"; var NameTransformSymbol = { AT: "@", HYPHEN: "-", SLASH: "/" }; var NameTransformMap = { [NameTransformSymbol.AT]: "scope_", [NameTransformSymbol.HYPHEN]: "_", [NameTransformSymbol.SLASH]: "__" }; var EncodedNameTransformMap = { [NameTransformMap[NameTransformSymbol.AT]]: NameTransformSymbol.AT, [NameTransformMap[NameTransformSymbol.HYPHEN]]: NameTransformSymbol.HYPHEN, [NameTransformMap[NameTransformSymbol.SLASH]]: NameTransformSymbol.SLASH }; var SEPARATOR = ":"; var ManifestFileName = "mf-manifest.json"; var StatsFileName = "mf-stats.json"; var MFModuleType = { NPM: "npm", APP: "app" }; var MODULE_DEVTOOL_IDENTIFIER = "__MF_DEVTOOLS_MODULE_INFO__"; var ENCODE_NAME_PREFIX = "ENCODE_NAME_PREFIX"; var TEMP_DIR = ".federation"; var MFPrefetchCommon = { identifier: "MFDataPrefetch", globalKey: "__PREFETCH__", library: "mf-data-prefetch", exportsKey: "__PREFETCH_EXPORTS__", fileName: "bootstrap.js" }; var ContainerPlugin = /* @__PURE__ */ Object.freeze({ __proto__: null }); var ContainerReferencePlugin = /* @__PURE__ */ Object.freeze({ __proto__: null }); var ModuleFederationPlugin = /* @__PURE__ */ Object.freeze({ __proto__: null }); var SharePlugin = /* @__PURE__ */ Object.freeze({ __proto__: null }); function isBrowserEnv() { return typeof window !== "undefined" && typeof window.document !== "undefined"; } function isReactNativeEnv() { return typeof navigator !== "undefined" && navigator?.product === "ReactNative"; } function isBrowserDebug() { try { if (isBrowserEnv() && window.localStorage) { return Boolean(localStorage.getItem(BROWSER_LOG_KEY)); } } catch (error2) { return false; } return false; } function isDebugMode() { if (typeof process !== "undefined" && process.env && process.env["FEDERATION_DEBUG"]) { return Boolean(process.env["FEDERATION_DEBUG"]); } if (typeof FEDERATION_DEBUG !== "undefined" && Boolean(FEDERATION_DEBUG)) { return true; } return isBrowserDebug(); } var getProcessEnv = function() { return typeof process !== "undefined" && process.env ? process.env : {}; }; var LOG_CATEGORY = "[ Federation Runtime ]"; var parseEntry = (str, devVerOrUrl, separator = SEPARATOR) => { const strSplit = str.split(separator); const devVersionOrUrl = getProcessEnv()["NODE_ENV"] === "development" && devVerOrUrl; const defaultVersion = "*"; const isEntry = (s4) => s4.startsWith("http") || s4.includes(MANIFEST_EXT); if (strSplit.length >= 2) { let [name, ...versionOrEntryArr] = strSplit; if (str.startsWith(separator)) { name = strSplit.slice(0, 2).join(separator); versionOrEntryArr = [ devVersionOrUrl || strSplit.slice(2).join(separator) ]; } let versionOrEntry = devVersionOrUrl || versionOrEntryArr.join(separator); if (isEntry(versionOrEntry)) { return { name, entry: versionOrEntry }; } else { return { name, version: versionOrEntry || defaultVersion }; } } else if (strSplit.length === 1) { const [name] = strSplit; if (devVersionOrUrl && isEntry(devVersionOrUrl)) { return { name, entry: devVersionOrUrl }; } return { name, version: devVersionOrUrl || defaultVersion }; } else { throw `Invalid entry value: ${str}`; } }; var composeKeyWithSeparator = function(...args) { if (!args.length) { return ""; } return args.reduce((sum, cur) => { if (!cur) { return sum; } if (!sum) { return cur; } return `${sum}${SEPARATOR}${cur}`; }, ""); }; var encodeName = function(name, prefix = "", withExt = false) { try { const ext = withExt ? ".js" : ""; return `${prefix}${name.replace(new RegExp(`${NameTransformSymbol.AT}`, "g"), NameTransformMap[NameTransformSymbol.AT]).replace(new RegExp(`${NameTransformSymbol.HYPHEN}`, "g"), NameTransformMap[NameTransformSymbol.HYPHEN]).replace(new RegExp(`${NameTransformSymbol.SLASH}`, "g"), NameTransformMap[NameTransformSymbol.SLASH])}${ext}`; } catch (err) { throw err; } }; var decodeName = function(name, prefix, withExt) { try { let decodedName = name; if (prefix) { if (!decodedName.startsWith(prefix)) { return decodedName; } decodedName = decodedName.replace(new RegExp(prefix, "g"), ""); } decodedName = decodedName.replace(new RegExp(`${NameTransformMap[NameTransformSymbol.AT]}`, "g"), EncodedNameTransformMap[NameTransformMap[NameTransformSymbol.AT]]).replace(new RegExp(`${NameTransformMap[NameTransformSymbol.SLASH]}`, "g"), EncodedNameTransformMap[NameTransformMap[NameTransformSymbol.SLASH]]).replace(new RegExp(`${NameTransformMap[NameTransformSymbol.HYPHEN]}`, "g"), EncodedNameTransformMap[NameTransformMap[NameTransformSymbol.HYPHEN]]); if (withExt) { decodedName = decodedName.replace(".js", ""); } return decodedName; } catch (err) { throw err; } }; var generateExposeFilename = (exposeName, withExt) => { if (!exposeName) { return ""; } let expose = exposeName; if (expose === ".") { expose = "default_export"; } if (expose.startsWith("./")) { expose = expose.replace("./", ""); } return encodeName(expose, "__federation_expose_", withExt); }; var generateShareFilename = (pkgName, withExt) => { if (!pkgName) { return ""; } return encodeName(pkgName, "__federation_shared_", withExt); }; var getResourceUrl = (module2, sourceUrl) => { if ("getPublicPath" in module2) { let publicPath; if (!module2.getPublicPath.startsWith("function")) { publicPath = new Function(module2.getPublicPath)(); } else { publicPath = new Function("return " + module2.getPublicPath)()(); } return `${publicPath}${sourceUrl}`; } else if ("publicPath" in module2) { if (!isBrowserEnv() && !isReactNativeEnv() && "ssrPublicPath" in module2) { return `${module2.ssrPublicPath}${sourceUrl}`; } return `${module2.publicPath}${sourceUrl}`; } else { console.warn("Cannot get resource URL. If in debug mode, please ignore.", module2, sourceUrl); return ""; } }; var assert = (condition, msg) => { if (!condition) { error(msg); } }; var error = (msg) => { throw new Error(`${LOG_CATEGORY}: ${msg}`); }; var warn = (msg) => { console.warn(`${LOG_CATEGORY}: ${msg}`); }; function safeToString(info) { try { return JSON.stringify(info, null, 2); } catch (e7) { return ""; } } var VERSION_PATTERN_REGEXP = /^([\d^=v<>~]|[*xX]$)/; function isRequiredVersion(str) { return VERSION_PATTERN_REGEXP.test(str); } var simpleJoinRemoteEntry = (rPath, rName) => { if (!rPath) { return rName; } const transformPath = (str) => { if (str === ".") { return ""; } if (str.startsWith("./")) { return str.replace("./", ""); } if (str.startsWith("/")) { const strWithoutSlash = str.slice(1); if (strWithoutSlash.endsWith("/")) { return strWithoutSlash.slice(0, -1); } return strWithoutSlash; } return str; }; const transformedPath = transformPath(rPath); if (!transformedPath) { return rName; } if (transformedPath.endsWith("/")) { return `${transformedPath}${rName}`; } return `${transformedPath}/${rName}`; }; function inferAutoPublicPath(url2) { return url2.replace(/#.*$/, "").replace(/\?.*$/, "").replace(/\/[^\/]+$/, "/"); } function generateSnapshotFromManifest(manifest, options = {}) { const { remotes = {}, overrides = {}, version: version2 } = options; let remoteSnapshot; const getPublicPath = () => { if ("publicPath" in manifest.metaData) { if (manifest.metaData.publicPath === "auto" && version2) { return inferAutoPublicPath(version2); } return manifest.metaData.publicPath; } else { return manifest.metaData.getPublicPath; } }; const overridesKeys = Object.keys(overrides); let remotesInfo = {}; if (!Object.keys(remotes).length) { remotesInfo = manifest.remotes?.reduce((res2, next) => { let matchedVersion; const name = next.federationContainerName; if (overridesKeys.includes(name)) { matchedVersion = overrides[name]; } else { if ("version" in next) { matchedVersion = next.version; } else { matchedVersion = next.entry; } } res2[name] = { matchedVersion }; return res2; }, {}) || {}; } Object.keys(remotes).forEach((key) => remotesInfo[key] = { // overrides will override dependencies matchedVersion: overridesKeys.includes(key) ? overrides[key] : remotes[key] }); const { remoteEntry: { path: remoteEntryPath, name: remoteEntryName, type: remoteEntryType }, types: remoteTypes = { path: "", name: "", zip: "", api: "" }, buildInfo: { buildVersion }, globalName, ssrRemoteEntry } = manifest.metaData; const { exposes } = manifest; let basicRemoteSnapshot = { version: version2 ? version2 : "", buildVersion, globalName, remoteEntry: simpleJoinRemoteEntry(remoteEntryPath, remoteEntryName), remoteEntryType, remoteTypes: simpleJoinRemoteEntry(remoteTypes.path, remoteTypes.name), remoteTypesZip: remoteTypes.zip || "", remoteTypesAPI: remoteTypes.api || "", remotesInfo, shared: manifest?.shared.map((item) => ({ assets: item.assets, sharedName: item.name, version: item.version })), modules: exposes?.map((expose) => ({ moduleName: expose.name, modulePath: expose.path, assets: expose.assets })) }; if (manifest.metaData?.prefetchInterface) { const prefetchInterface = manifest.metaData.prefetchInterface; basicRemoteSnapshot = { ...basicRemoteSnapshot, prefetchInterface }; } if (manifest.metaData?.prefetchEntry) { const { path: path2, name, type } = manifest.metaData.prefetchEntry; basicRemoteSnapshot = { ...basicRemoteSnapshot, prefetchEntry: simpleJoinRemoteEntry(path2, name), prefetchEntryType: type }; } if ("publicPath" in manifest.metaData) { remoteSnapshot = { ...basicRemoteSnapshot, publicPath: getPublicPath(), ssrPublicPath: manifest.metaData.ssrPublicPath }; } else { remoteSnapshot = { ...basicRemoteSnapshot, getPublicPath: getPublicPath() }; } if (ssrRemoteEntry) { const fullSSRRemoteEntry = simpleJoinRemoteEntry(ssrRemoteEntry.path, ssrRemoteEntry.name); remoteSnapshot.ssrRemoteEntry = fullSSRRemoteEntry; remoteSnapshot.ssrRemoteEntryType = ssrRemoteEntry.type || "commonjs-module"; } return remoteSnapshot; } function isManifestProvider(moduleInfo) { if ("remoteEntry" in moduleInfo && moduleInfo.remoteEntry.includes(MANIFEST_EXT)) { return true; } else { return false; } } function getManifestFileName(manifestOptions) { if (!manifestOptions) { return { statsFileName: StatsFileName, manifestFileName: ManifestFileName }; } let filePath = typeof manifestOptions === "boolean" ? "" : manifestOptions.filePath || ""; let fileName = typeof manifestOptions === "boolean" ? "" : manifestOptions.fileName || ""; const JSON_EXT = ".json"; const addExt = (name) => { if (name.endsWith(JSON_EXT)) { return name; } return `${name}${JSON_EXT}`; }; const insertSuffix = (name, suffix) => { return name.replace(JSON_EXT, `${suffix}${JSON_EXT}`); }; const manifestFileName = fileName ? addExt(fileName) : ManifestFileName; const statsFileName = fileName ? insertSuffix(manifestFileName, "-stats") : StatsFileName; return { statsFileName: simpleJoinRemoteEntry(filePath, statsFileName), manifestFileName: simpleJoinRemoteEntry(filePath, manifestFileName) }; } var PREFIX = "[ Module Federation ]"; var DEFAULT_DELEGATE = console; var LOGGER_STACK_SKIP_TOKENS = [ "logger.ts", "logger.js", "captureStackTrace", "Logger.emit", "Logger.log", "Logger.info", "Logger.warn", "Logger.error", "Logger.debug" ]; function captureStackTrace() { try { const stack = new Error().stack; if (!stack) { return void 0; } const [, ...rawLines] = stack.split("\n"); const filtered = rawLines.filter((line) => !LOGGER_STACK_SKIP_TOKENS.some((token) => line.includes(token))); if (!filtered.length) { return void 0; } const stackPreview = filtered.slice(0, 5).join("\n"); return `Stack trace: ${stackPreview}`; } catch { return void 0; } } var Logger = class { constructor(prefix, delegate = DEFAULT_DELEGATE) { this.prefix = prefix; this.delegate = delegate ?? DEFAULT_DELEGATE; } setPrefix(prefix) { this.prefix = prefix; } setDelegate(delegate) { this.delegate = delegate ?? DEFAULT_DELEGATE; } emit(method, args) { const delegate = this.delegate; const debugMode = isDebugMode(); const stackTrace = debugMode ? captureStackTrace() : void 0; const enrichedArgs = stackTrace ? [...args, stackTrace] : args; const order = (() => { switch (method) { case "log": return ["log", "info"]; case "info": return ["info", "log"]; case "warn": return ["warn", "info", "log"]; case "error": return ["error", "warn", "log"]; case "debug": default: return ["debug", "log"]; } })(); for (const candidate of order) { const handler = delegate[candidate]; if (typeof handler === "function") { handler.call(delegate, this.prefix, ...enrichedArgs); return; } } for (const candidate of order) { const handler = DEFAULT_DELEGATE[candidate]; if (typeof handler === "function") { handler.call(DEFAULT_DELEGATE, this.prefix, ...enrichedArgs); return; } } } log(...args) { this.emit("log", args); } warn(...args) { this.emit("warn", args); } error(...args) { this.emit("error", args); } success(...args) { this.emit("info", args); } info(...args) { this.emit("info", args); } ready(...args) { this.emit("info", args); } debug(...args) { if (isDebugMode()) { this.emit("debug", args); } } }; function createLogger(prefix) { return new Logger(prefix); } function createInfrastructureLogger(prefix) { const infrastructureLogger2 = new Logger(prefix); Object.defineProperty(infrastructureLogger2, "__mf_infrastructure_logger__", { value: true, enumerable: false, configurable: false }); return infrastructureLogger2; } function bindLoggerToCompiler(loggerInstance, compiler, name) { if (!loggerInstance.__mf_infrastructure_logger__) { return; } if (!compiler?.getInfrastructureLogger) { return; } try { const infrastructureLogger2 = compiler.getInfrastructureLogger(name); if (infrastructureLogger2 && typeof infrastructureLogger2 === "object" && (typeof infrastructureLogger2.log === "function" || typeof infrastructureLogger2.info === "function" || typeof infrastructureLogger2.warn === "function" || typeof infrastructureLogger2.error === "function")) { loggerInstance.setDelegate(infrastructureLogger2); } } catch { loggerInstance.setDelegate(void 0); } } var logger = createLogger(PREFIX); var infrastructureLogger = createInfrastructureLogger(PREFIX); async function safeWrapper(callback, disableWarn) { try { const res2 = await callback(); return res2; } catch (e7) { !disableWarn && warn(e7); return; } } function isStaticResourcesEqual(url1, url2) { const REG_EXP = /^(https?:)?\/\//i; const relativeUrl1 = url1.replace(REG_EXP, "").replace(/\/$/, ""); const relativeUrl2 = url2.replace(REG_EXP, "").replace(/\/$/, ""); return relativeUrl1 === relativeUrl2; } function createScript(info) { let script2 = null; let needAttach = true; let timeout = 2e4; let timeoutId; const scripts = document.getElementsByTagName("script"); for (let i7 = 0; i7 < scripts.length; i7++) { const s4 = scripts[i7]; const scriptSrc = s4.getAttribute("src"); if (scriptSrc && isStaticResourcesEqual(scriptSrc, info.url)) { script2 = s4; needAttach = false; break; } } if (!script2) { const attrs2 = info.attrs; script2 = document.createElement("script"); script2.type = attrs2?.["type"] === "module" ? "module" : "text/javascript"; let createScriptRes = void 0; if (info.createScriptHook) { createScriptRes = info.createScriptHook(info.url, info.attrs); if (createScriptRes instanceof HTMLScriptElement) { script2 = createScriptRes; } else if (typeof createScriptRes === "object") { if ("script" in createScriptRes && createScriptRes.script) { script2 = createScriptRes.script; } if ("timeout" in createScriptRes && createScriptRes.timeout) { timeout = createScriptRes.timeout; } } } if (!script2.src) { script2.src = info.url; } if (attrs2 && !createScriptRes) { Object.keys(attrs2).forEach((name) => { if (script2) { if (name === "async" || name === "defer") { script2[name] = attrs2[name]; } else if (!script2.getAttribute(name)) { script2.setAttribute(name, attrs2[name]); } } }); } } const onScriptComplete = async (prev, event) => { clearTimeout(timeoutId); const onScriptCompleteCallback = () => { if (event?.type === "error") { info?.onErrorCallback && info?.onErrorCallback(event); } else { info?.cb && info?.cb(); } }; if (script2) { script2.onerror = null; script2.onload = null; safeWrapper(() => { const { needDeleteScript = true } = info; if (needDeleteScript) { script2?.parentNode && script2.parentNode.removeChild(script2); } }); if (prev && typeof prev === "function") { const result = prev(event); if (result instanceof Promise) { const res2 = await result; onScriptCompleteCallback(); return res2; } onScriptCompleteCallback(); return result; } } onScriptCompleteCallback(); }; script2.onerror = onScriptComplete.bind(null, script2.onerror); script2.onload = onScriptComplete.bind(null, script2.onload); timeoutId = setTimeout(() => { onScriptComplete(null, new Error(`Remote script "${info.url}" time-outed.`)); }, timeout); return { script: script2, needAttach }; } function createLink(info) { let link = null; let needAttach = true; const links = document.getElementsByTagName("link"); for (let i7 = 0; i7 < links.length; i7++) { const l3 = links[i7]; const linkHref = l3.getAttribute("href"); const linkRel = l3.getAttribute("rel"); if (linkHref && isStaticResourcesEqual(linkHref, info.url) && linkRel === info.attrs["rel"]) { link = l3; needAttach = false; break; } } if (!link) { link = document.createElement("link"); link.setAttribute("href", info.url); let createLinkRes = void 0; const attrs2 = info.attrs; if (info.createLinkHook) { createLinkRes = info.createLinkHook(info.url, attrs2); if (createLinkRes instanceof HTMLLinkElement) { link = createLinkRes; } } if (attrs2 && !createLinkRes) { Object.keys(attrs2).forEach((name) => { if (link && !link.getAttribute(name)) { link.setAttribute(name, attrs2[name]); } }); } } const onLinkComplete = (prev, event) => { const onLinkCompleteCallback = () => { if (event?.type === "error") { info?.onErrorCallback && info?.onErrorCallback(event); } else { info?.cb && info?.cb(); } }; if (link) { link.onerror = null; link.onload = null; safeWrapper(() => { const { needDeleteLink = true } = info; if (needDeleteLink) { link?.parentNode && link.parentNode.removeChild(link); } }); if (prev) { const res2 = prev(event); onLinkCompleteCallback(); return res2; } } onLinkCompleteCallback(); }; link.onerror = onLinkComplete.bind(null, link.onerror); link.onload = onLinkComplete.bind(null, link.onload); return { link, needAttach }; } function loadScript(url2, info) { const { attrs: attrs2 = {}, createScriptHook } = info; return new Promise((resolve, reject) => { const { script: script2, needAttach } = createScript({ url: url2, cb: resolve, onErrorCallback: reject, attrs: { fetchpriority: "high", ...attrs2 }, createScriptHook, needDeleteScript: true }); needAttach && document.head.appendChild(script2); }); } var sdkImportCache = /* @__PURE__ */ new Map(); function importNodeModule(name) { if (!name) { throw new Error("import specifier is required"); } if (sdkImportCache.has(name)) { return sdkImportCache.get(name); } const importModule = new Function("name", `return import(name)`); const promise = importModule(name).then((res2) => res2).catch((error2) => { console.error(`Error importing module ${name}:`, error2); sdkImportCache.delete(name); throw error2; }); sdkImportCache.set(name, promise); return promise; } var loadNodeFetch = async () => { const fetchModule = await importNodeModule("node-fetch"); return fetchModule.default || fetchModule; }; var lazyLoaderHookFetch = async (input, init, loaderHook2) => { const hook = (url2, init2) => { return loaderHook2.lifecycle.fetch.emit(url2, init2); }; const res2 = await hook(input, init || {}); if (!res2 || !(res2 instanceof Response)) { const fetchFunction = typeof fetch === "undefined" ? await loadNodeFetch() : fetch; return fetchFunction(input, init || {}); } return res2; }; var createScriptNode = typeof ENV_TARGET === "undefined" || ENV_TARGET !== "web" ? (url, cb, attrs, loaderHook) => { if (loaderHook?.createScriptHook) { const hookResult = loaderHook.createScriptHook(url); if (hookResult && typeof hookResult === "object" && "url" in hookResult) { url = hookResult.url; } } let urlObj; try { urlObj = new URL(url); } catch (e7) { console.error("Error constructing URL:", e7); cb(new Error(`Invalid URL: ${e7}`)); return; } const getFetch = async () => { if (loaderHook?.fetch) { return (input, init) => lazyLoaderHookFetch(input, init, loaderHook); } return typeof fetch === "undefined" ? loadNodeFetch() : fetch; }; const handleScriptFetch = async (f, urlObj) => { try { const res = await f(urlObj.href); const data = await res.text(); const [path, vm] = await Promise.all([ importNodeModule("path"), importNodeModule("vm") ]); const scriptContext = { exports: {}, module: { exports: {} } }; const urlDirname = urlObj.pathname.split("/").slice(0, -1).join("/"); const filename = path.basename(urlObj.pathname); const script = new vm.Script(`(function(exports, module, require, __dirname, __filename) {${data} })`, { filename, importModuleDynamically: ( //@ts-ignore vm.constants?.USE_MAIN_CONTEXT_DEFAULT_LOADER ?? importNodeModule ) }); script.runInThisContext()(scriptContext.exports, scriptContext.module, eval("require"), urlDirname, filename); const exportedInterface = scriptContext.module.exports || scriptContext.exports; if (attrs && exportedInterface && attrs["globalName"]) { const container = exportedInterface[attrs["globalName"]] || exportedInterface; cb(void 0, container); return; } cb(void 0, exportedInterface); } catch (e7) { cb(e7 instanceof Error ? e7 : new Error(`Script execution error: ${e7}`)); } }; getFetch().then(async (f4) => { if (attrs?.["type"] === "esm" || attrs?.["type"] === "module") { return loadModule(urlObj.href, { fetch: f4, vm: await importNodeModule("vm") }).then(async (module2) => { await module2.evaluate(); cb(void 0, module2.namespace); }).catch((e7) => { cb(e7 instanceof Error ? e7 : new Error(`Script execution error: ${e7}`)); }); } handleScriptFetch(f4, urlObj); }).catch((err) => { cb(err); }); } : (url2, cb2, attrs2, loaderHook2) => { cb2(new Error("createScriptNode is disabled in non-Node.js environment")); }; var loadScriptNode = typeof ENV_TARGET === "undefined" || ENV_TARGET !== "web" ? (url2, info) => { return new Promise((resolve, reject) => { createScriptNode(url2, (error2, scriptContext2) => { if (error2) { reject(error2); } else { const remoteEntryKey = info?.attrs?.["globalName"] || `__FEDERATION_${info?.attrs?.["name"]}:custom__`; const entryExports = globalThis[remoteEntryKey] = scriptContext2; resolve(entryExports); } }, info.attrs, info.loaderHook); }); } : (url2, info) => { throw new Error("loadScriptNode is disabled in non-Node.js environment"); }; var esmModuleCache = /* @__PURE__ */ new Map(); async function loadModule(url2, options) { if (esmModuleCache.has(url2)) { return esmModuleCache.get(url2); } const { fetch: fetch2, vm: vm2 } = options; const response = await fetch2(url2); const code = await response.text(); const module2 = new vm2.SourceTextModule(code, { // @ts-ignore importModuleDynamically: async (specifier, script2) => { const resolvedUrl = new URL(specifier, url2).href; return loadModule(resolvedUrl, options); } }); esmModuleCache.set(url2, module2); await module2.link(async (specifier) => { const resolvedUrl = new URL(specifier, url2).href; const module3 = await loadModule(resolvedUrl, options); return module3; }); return module2; } function normalizeOptions(enableDefault, defaultOptions, key) { return function(options) { if (options === false) { return false; } if (typeof options === "undefined") { if (enableDefault) { return defaultOptions; } else { return false; } } if (options === true) { return defaultOptions; } if (options && typeof options === "object") { return { ...defaultOptions, ...options }; } throw new Error(`Unexpected type for \`${key}\`, expect boolean/undefined/object, got: ${typeof options}`); }; } var createModuleFederationConfig = (options) => { return options; }; exports.BROWSER_LOG_KEY = BROWSER_LOG_KEY; exports.ENCODE_NAME_PREFIX = ENCODE_NAME_PREFIX; exports.EncodedNameTransformMap = EncodedNameTransformMap; exports.FederationModuleManifest = FederationModuleManifest; exports.MANIFEST_EXT = MANIFEST_EXT; exports.MFModuleType = MFModuleType; exports.MFPrefetchCommon = MFPrefetchCommon; exports.MODULE_DEVTOOL_IDENTIFIER = MODULE_DEVTOOL_IDENTIFIER; exports.ManifestFileName = ManifestFileName; exports.NameTransformMap = NameTransformMap; exports.NameTransformSymbol = NameTransformSymbol; exports.SEPARATOR = SEPARATOR; exports.StatsFileName = StatsFileName; exports.TEMP_DIR = TEMP_DIR; exports.assert = assert; exports.bindLoggerToCompiler = bindLoggerToCompiler; exports.composeKeyWithSeparator = composeKeyWithSeparator; exports.containerPlugin = ContainerPlugin; exports.containerReferencePlugin = ContainerReferencePlugin; exports.createInfrastructureLogger = createInfrastructureLogger; exports.createLink = createLink; exports.createLogger = createLogger; exports.createModuleFederationConfig = createModuleFederationConfig; exports.createScript = createScript; exports.createScriptNode = createScriptNode; exports.decodeName = decodeName; exports.encodeName = encodeName; exports.error = error; exports.generateExposeFilename = generateExposeFilename; exports.generateShareFilename = generateShareFilename; exports.generateSnapshotFromManifest = generateSnapshotFromManifest; exports.getManifestFileName = getManifestFileName; exports.getProcessEnv = getProcessEnv; exports.getResourceUrl = getResourceUrl; exports.inferAutoPublicPath = inferAutoPublicPath; exports.infrastructureLogger = infrastructureLogger; exports.isBrowserEnv = isBrowserEnv; exports.isDebugMode = isDebugMode; exports.isManifestProvider = isManifestProvider; exports.isReactNativeEnv = isReactNativeEnv; exports.isRequiredVersion = isRequiredVersion; exports.isStaticResourcesEqual = isStaticResourcesEqual; exports.loadScript = loadScript; exports.loadScriptNode = loadScriptNode; exports.logger = logger; exports.moduleFederationPlugin = ModuleFederationPlugin; exports.normalizeOptions = normalizeOptions; exports.parseEntry = parseEntry; exports.safeToString = safeToString; exports.safeWrapper = safeWrapper; exports.sharePlugin = SharePlugin; exports.simpleJoinRemoteEntry = simpleJoinRemoteEntry; exports.warn = warn; } }); // node_modules/@module-federation/error-codes/dist/index.cjs.js var require_index_cjs2 = __commonJS({ "node_modules/@module-federation/error-codes/dist/index.cjs.js"(exports2) { "use strict"; var RUNTIME_001 = "RUNTIME-001"; var RUNTIME_002 = "RUNTIME-002"; var RUNTIME_003 = "RUNTIME-003"; var RUNTIME_004 = "RUNTIME-004"; var RUNTIME_005 = "RUNTIME-005"; var RUNTIME_006 = "RUNTIME-006"; var RUNTIME_007 = "RUNTIME-007"; var RUNTIME_008 = "RUNTIME-008"; var RUNTIME_009 = "RUNTIME-009"; var TYPE_001 = "TYPE-001"; var BUILD_001 = "BUILD-001"; var BUILD_002 = "BUILD-002"; var getDocsUrl = (errorCode) => { const type = errorCode.split("-")[0].toLowerCase(); return `View the docs to see how to solve: https://module-federation.io/guide/troubleshooting/${type}/${errorCode}`; }; var getShortErrorMsg = (errorCode, errorDescMap2, args, originalErrorMsg) => { const msg = [`${[errorDescMap2[errorCode]]} #${errorCode}`]; args && msg.push(`args: ${JSON.stringify(args)}`); msg.push(getDocsUrl(errorCode)); originalErrorMsg && msg.push(`Original Error Message: ${originalErrorMsg}`); return msg.join("\n"); }; var runtimeDescMap = { [RUNTIME_001]: "Failed to get remoteEntry exports.", [RUNTIME_002]: 'The remote entry interface does not contain "init"', [RUNTIME_003]: "Failed to get manifest.", [RUNTIME_004]: "Failed to locate remote.", [RUNTIME_005]: "Invalid loadShareSync function call from bundler runtime", [RUNTIME_006]: "Invalid loadShareSync function call from runtime", [RUNTIME_007]: "Failed to get remote snapshot.", [RUNTIME_008]: "Failed to load script resources.", [RUNTIME_009]: "Please call createInstance first." }; var typeDescMap = { [TYPE_001]: "Failed to generate type declaration. Execute the below cmd to reproduce and fix the error." }; var buildDescMap = { [BUILD_001]: "Failed to find expose module.", [BUILD_002]: "PublicPath is required in prod mode." }; var errorDescMap = { ...runtimeDescMap, ...typeDescMap, ...buildDescMap }; exports2.BUILD_001 = BUILD_001; exports2.BUILD_002 = BUILD_002; exports2.RUNTIME_001 = RUNTIME_001; exports2.RUNTIME_002 = RUNTIME_002; exports2.RUNTIME_003 = RUNTIME_003; exports2.RUNTIME_004 = RUNTIME_004; exports2.RUNTIME_005 = RUNTIME_005; exports2.RUNTIME_006 = RUNTIME_006; exports2.RUNTIME_007 = RUNTIME_007; exports2.RUNTIME_008 = RUNTIME_008; exports2.RUNTIME_009 = RUNTIME_009; exports2.TYPE_001 = TYPE_001; exports2.buildDescMap = buildDescMap; exports2.errorDescMap = errorDescMap; exports2.getShortErrorMsg = getShortErrorMsg; exports2.runtimeDescMap = runtimeDescMap; exports2.typeDescMap = typeDescMap; } }); // node_modules/@module-federation/runtime-core/dist/index.cjs.cjs var require_index_cjs3 = __commonJS({ "node_modules/@module-federation/runtime-core/dist/index.cjs.cjs"(exports2) { "use strict"; var sdk = require_index_cjs(); var errorCodes = require_index_cjs2(); var LOG_CATEGORY2 = "[ Federation Runtime ]"; var logger2 = sdk.createLogger(LOG_CATEGORY2); function assert2(condition, msg) { if (!condition) { error2(msg); } } function error2(msg) { if (msg instanceof Error) { if (!msg.message.startsWith(LOG_CATEGORY2)) { msg.message = `${LOG_CATEGORY2}: ${msg.message}`; } throw msg; } throw new Error(`${LOG_CATEGORY2}: ${msg}`); } function warn2(msg) { if (msg instanceof Error) { if (!msg.message.startsWith(LOG_CATEGORY2)) { msg.message = `${LOG_CATEGORY2}: ${msg.message}`; } logger2.warn(msg); } else { logger2.warn(msg); } } function addUniqueItem(arr, item) { if (arr.findIndex((name) => name === item) === -1) { arr.push(item); } return arr; } function getFMId(remoteInfo) { if ("version" in remoteInfo && remoteInfo.version) { return `${remoteInfo.name}:${remoteInfo.version}`; } else if ("entry" in remoteInfo && remoteInfo.entry) { return `${remoteInfo.name}:${remoteInfo.entry}`; } else { return `${remoteInfo.name}`; } } function isRemoteInfoWithEntry(remote) { return typeof remote.entry !== "undefined"; } function isPureRemoteEntry(remote) { return !remote.entry.includes(".json"); } async function safeWrapper2(callback, disableWarn) { try { const res2 = await callback(); return res2; } catch (e7) { !disableWarn && warn2(e7); return; } } function isObject2(val) { return val && typeof val === "object"; } var objectToString = Object.prototype.toString; function isPlainObject(val) { return objectToString.call(val) === "[object Object]"; } function isStaticResourcesEqual2(url1, url2) { const REG_EXP = /^(https?:)?\/\//i; const relativeUrl1 = url1.replace(REG_EXP, "").replace(/\/$/, ""); const relativeUrl2 = url2.replace(REG_EXP, "").replace(/\/$/, ""); return relativeUrl1 === relativeUrl2; } function arrayOptions(options) { return Array.isArray(options) ? options : [options]; } function getRemoteEntryInfoFromSnapshot(snapshot) { const defaultRemoteEntryInfo = { url: "", type: "global", globalName: "" }; if (sdk.isBrowserEnv() || sdk.isReactNativeEnv()) { return "remoteEntry" in snapshot ? { url: snapshot.remoteEntry, type: snapshot.remoteEntryType, globalName: snapshot.globalName } : defaultRemoteEntryInfo; } if ("ssrRemoteEntry" in snapshot) { return { url: snapshot.ssrRemoteEntry || defaultRemoteEntryInfo.url, type: snapshot.ssrRemoteEntryType || defaultRemoteEntryInfo.type, globalName: snapshot.globalName }; } return defaultRemoteEntryInfo; } var processModuleAlias = (name, subPath) => { let moduleName; if (name.endsWith("/")) { moduleName = name.slice(0, -1); } else { moduleName = name; } if (subPath.startsWith(".")) { subPath = subPath.slice(1); } moduleName = moduleName + subPath; return moduleName; }; var CurrentGlobal = typeof globalThis === "object" ? globalThis : window; var nativeGlobal = (() => { try { return document.defaultView; } catch { return CurrentGlobal; } })(); var Global = nativeGlobal; function definePropertyGlobalVal(target, key, val) { Object.defineProperty(target, key, { value: val, configurable: false, writable: true }); } function includeOwnProperty(target, key) { return Object.hasOwnProperty.call(target, key); } if (!includeOwnProperty(CurrentGlobal, "__GLOBAL_LOADING_REMOTE_ENTRY__")) { definePropertyGlobalVal(CurrentGlobal, "__GLOBAL_LOADING_REMOTE_ENTRY__", {}); } var globalLoading = CurrentGlobal.__GLOBAL_LOADING_REMOTE_ENTRY__; function setGlobalDefaultVal(target) { if (includeOwnProperty(target, "__VMOK__") && !includeOwnProperty(target, "__FEDERATION__")) { definePropertyGlobalVal(target, "__FEDERATION__", target.__VMOK__); } if (!includeOwnProperty(target, "__FEDERATION__")) { definePropertyGlobalVal(target, "__FEDERATION__", { __GLOBAL_PLUGIN__: [], __INSTANCES__: [], moduleInfo: {}, __SHARE__: {}, __MANIFEST_LOADING__: {}, __PRELOADED_MAP__: /* @__PURE__ */ new Map() }); definePropertyGlobalVal(target, "__VMOK__", target.__FEDERATION__); } target.__FEDERATION__.__GLOBAL_PLUGIN__ ??= []; target.__FEDERATION__.__INSTANCES__ ??= []; target.__FEDERATION__.moduleInfo ??= {}; target.__FEDERATION__.__SHARE__ ??= {}; target.__FEDERATION__.__MANIFEST_LOADING__ ??= {}; target.__FEDERATION__.__PRELOADED_MAP__ ??= /* @__PURE__ */ new Map(); } setGlobalDefaultVal(CurrentGlobal); setGlobalDefaultVal(nativeGlobal); function resetFederationGlobalInfo() { CurrentGlobal.__FEDERATION__.__GLOBAL_PLUGIN__ = []; CurrentGlobal.__FEDERATION__.__INSTANCES__ = []; CurrentGlobal.__FEDERATION__.moduleInfo = {}; CurrentGlobal.__FEDERATION__.__SHARE__ = {}; CurrentGlobal.__FEDERATION__.__MANIFEST_LOADING__ = {}; Object.keys(globalLoading).forEach((key) => { delete globalLoading[key]; }); } function setGlobalFederationInstance(FederationInstance) { CurrentGlobal.__FEDERATION__.__INSTANCES__.push(FederationInstance); } function getGlobalFederationConstructor() { return CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR__; } function setGlobalFederationConstructor(FederationConstructor, isDebug = sdk.isDebugMode()) { if (isDebug) { CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = FederationConstructor; CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.21.6"; } } function getInfoWithoutType(target, key) { if (typeof key === "string") { const keyRes = target[key]; if (keyRes) { return { value: target[key], key }; } else { const targetKeys = Object.keys(target); for (const targetKey of targetKeys) { const [targetTypeOrName, _2] = targetKey.split(":"); const nKey = `${targetTypeOrName}:${key}`; const typeWithKeyRes = target[nKey]; if (typeWithKeyRes) { return { value: typeWithKeyRes, key: nKey }; } } return { value: void 0, key }; } } else { throw new Error("key must be string"); } } var getGlobalSnapshot = () => nativeGlobal.__FEDERATION__.moduleInfo; var getTargetSnapshotInfoByModuleInfo = (moduleInfo, snapshot) => { const moduleKey = getFMId(moduleInfo); const getModuleInfo = getInfoWithoutType(snapshot, moduleKey).value; if (getModuleInfo && !getModuleInfo.version && "version" in moduleInfo && moduleInfo["version"]) { getModuleInfo.version = moduleInfo["version"]; } if (getModuleInfo) { return getModuleInfo; } if ("version" in moduleInfo && moduleInfo["version"]) { const { version: version2, ...resModuleInfo } = moduleInfo; const moduleKeyWithoutVersion = getFMId(resModuleInfo); const getModuleInfoWithoutVersion = getInfoWithoutType(nativeGlobal.__FEDERATION__.moduleInfo, moduleKeyWithoutVersion).value; if (getModuleInfoWithoutVersion?.version === version2) { return getModuleInfoWithoutVersion; } } return; }; var getGlobalSnapshotInfoByModuleInfo = (moduleInfo) => getTargetSnapshotInfoByModuleInfo(moduleInfo, nativeGlobal.__FEDERATION__.moduleInfo); var setGlobalSnapshotInfoByModuleInfo = (remoteInfo, moduleDetailInfo) => { const moduleKey = getFMId(remoteInfo); nativeGlobal.__FEDERATION__.moduleInfo[moduleKey] = moduleDetailInfo; return nativeGlobal.__FEDERATION__.moduleInfo; }; var addGlobalSnapshot = (moduleInfos) => { nativeGlobal.__FEDERATION__.moduleInfo = { ...nativeGlobal.__FEDERATION__.moduleInfo, ...moduleInfos }; return () => { const keys = Object.keys(moduleInfos); for (const key of keys) { delete nativeGlobal.__FEDERATION__.moduleInfo[key]; } }; }; var getRemoteEntryExports = (name, globalName) => { const remoteEntryKey = globalName || `__FEDERATION_${name}:custom__`; const entryExports = CurrentGlobal[remoteEntryKey]; return { remoteEntryKey, entryExports }; }; var registerGlobalPlugins = (plugins) => { const { __GLOBAL_PLUGIN__ } = nativeGlobal.__FEDERATION__; plugins.forEach((plugin) => { if (__GLOBAL_PLUGIN__.findIndex((p3) => p3.name === plugin.name) === -1) { __GLOBAL_PLUGIN__.push(plugin); } else { warn2(`The plugin ${plugin.name} has been registered.`); } }); }; var getGlobalHostPlugins = () => nativeGlobal.__FEDERATION__.__GLOBAL_PLUGIN__; var getPreloaded = (id) => CurrentGlobal.__FEDERATION__.__PRELOADED_MAP__.get(id); var setPreloaded = (id) => CurrentGlobal.__FEDERATION__.__PRELOADED_MAP__.set(id, true); var DEFAULT_SCOPE = "default"; var DEFAULT_REMOTE_TYPE = "global"; var buildIdentifier = "[0-9A-Za-z-]+"; var build = `(?:\\+(${buildIdentifier}(?:\\.${buildIdentifier})*))`; var numericIdentifier = "0|[1-9]\\d*"; var numericIdentifierLoose = "[0-9]+"; var nonNumericIdentifier = "\\d*[a-zA-Z-][a-zA-Z0-9-]*"; var preReleaseIdentifierLoose = `(?:${numericIdentifierLoose}|${nonNumericIdentifier})`; var preReleaseLoose = `(?:-?(${preReleaseIdentifierLoose}(?:\\.${preReleaseIdentifierLoose})*))`; var preReleaseIdentifier = `(?:${numericIdentifier}|${nonNumericIdentifier})`; var preRelease = `(?:-(${preReleaseIdentifier}(?:\\.${preReleaseIdentifier})*))`; var xRangeIdentifier = `${numericIdentifier}|x|X|\\*`; var xRangePlain = `[v=\\s]*(${xRangeIdentifier})(?:\\.(${xRangeIdentifier})(?:\\.(${xRangeIdentifier})(?:${preRelease})?${build}?)?)?`; var hyphenRange = `^\\s*(${xRangePlain})\\s+-\\s+(${xRangePlain})\\s*$`; var mainVersionLoose = `(${numericIdentifierLoose})\\.(${numericIdentifierLoose})\\.(${numericIdentifierLoose})`; var loosePlain = `[v=\\s]*${mainVersionLoose}${preReleaseLoose}?${build}?`; var gtlt = "((?:<|>)?=?)"; var comparatorTrim = `(\\s*)${gtlt}\\s*(${loosePlain}|${xRangePlain})`; var loneTilde = "(?:~>?)"; var tildeTrim = `(\\s*)${loneTilde}\\s+`; var loneCaret = "(?:\\^)"; var caretTrim = `(\\s*)${loneCaret}\\s+`; var star = "(<|>)?=?\\s*\\*"; var caret = `^${loneCaret}${xRangePlain}$`; var mainVersion = `(${numericIdentifier})\\.(${numericIdentifier})\\.(${numericIdentifier})`; var fullPlain = `v?${mainVersion}${preRelease}?${build}?`; var tilde = `^${loneTilde}${xRangePlain}$`; var xRange = `^${gtlt}\\s*${xRangePlain}$`; var com