@module-federation/playground 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -148,13 +148,13 @@ const App_module = {
148
148
  const BRIDGE_RUNTIME_FILES = {
149
149
  "bridge-base-BaKy6CY_.mjs": "var __defProp = Object.defineProperty;\nvar __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;\nvar __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== \"symbol\" ? key + \"\" : key, value);\nimport * as React from \"react\";\nimport { L as LoggerInstance, R as RouterContext } from \"./index-Bs2NxD2z.mjs\";\nimport { federationRuntime } from \"./plugin.es.js\";\nconst initialState = { didCatch: false, error: null };\nclass ErrorBoundary extends React.Component {\n constructor() {\n super(...arguments);\n __publicField(this, \"state\", initialState);\n __publicField(this, \"resetErrorBoundary\", (..._args) => {\n if (this.state.didCatch) {\n this.setState(initialState);\n }\n });\n }\n static getDerivedStateFromError(error) {\n return { didCatch: true, error };\n }\n render() {\n if (this.state.didCatch) {\n return /* @__PURE__ */ React.createElement(\n this.props.FallbackComponent,\n {\n error: this.state.error,\n resetErrorBoundary: this.resetErrorBoundary\n }\n );\n }\n return this.props.children;\n }\n}\nfunction createBaseBridgeComponent({\n createRoot,\n defaultRootOptions,\n ...bridgeInfo\n}) {\n return () => {\n const rootMap = /* @__PURE__ */ new Map();\n const instance = federationRuntime.instance;\n LoggerInstance.debug(\n `createBridgeComponent instance from props >>>`,\n instance\n );\n const RawComponent = (info) => {\n const { appInfo, propsInfo, ...restProps } = info;\n const { moduleName, memoryRoute, basename = \"/\" } = appInfo;\n return /* @__PURE__ */ React.createElement(RouterContext.Provider, { value: { moduleName, basename, memoryRoute } }, /* @__PURE__ */ React.createElement(\n bridgeInfo.rootComponent,\n {\n ...propsInfo,\n basename,\n ...restProps\n }\n ));\n };\n const DefaultFallback = ({ error }) => /* @__PURE__ */ React.createElement(\"div\", { role: \"alert\" }, /* @__PURE__ */ React.createElement(\"p\", null, \"Something went wrong:\"), /* @__PURE__ */ React.createElement(\"pre\", { style: { color: \"red\" } }, error instanceof Error ? error.message : String(error)));\n const omitHostFallback = (props) => {\n const nextProps = { ...props };\n delete nextProps.fallback;\n return nextProps;\n };\n const BridgeWrapper = ({\n basename,\n moduleName,\n memoryRoute,\n propsInfo\n }) => /* @__PURE__ */ React.createElement(ErrorBoundary, { FallbackComponent: DefaultFallback }, /* @__PURE__ */ React.createElement(\n RawComponent,\n {\n appInfo: {\n moduleName,\n basename,\n memoryRoute\n },\n propsInfo\n }\n ));\n return {\n async render(info) {\n var _a, _b, _c, _d, _e, _f;\n LoggerInstance.debug(`createBridgeComponent render Info`, info);\n const {\n moduleName,\n dom,\n basename,\n memoryRoute,\n rootOptions,\n ...propsInfo\n } = info;\n const mergedRootOptions = {\n ...defaultRootOptions,\n ...rootOptions\n };\n const beforeBridgeRenderRes = ((_c = (_b = (_a = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _a.lifecycle) == null ? void 0 : _b.beforeBridgeRender) == null ? void 0 : _c.emit(info)) || {};\n const rootComponentWithErrorBoundary = /* @__PURE__ */ React.createElement(\n BridgeWrapper,\n {\n basename,\n moduleName,\n memoryRoute,\n propsInfo: {\n ...omitHostFallback(propsInfo),\n basename,\n ...beforeBridgeRenderRes == null ? void 0 : beforeBridgeRenderRes.extraProps\n }\n }\n );\n if (bridgeInfo.render) {\n await Promise.resolve(\n bridgeInfo.render(rootComponentWithErrorBoundary, dom)\n ).then((root) => rootMap.set(dom, root));\n } else {\n let root = rootMap.get(dom);\n if (!root && createRoot) {\n root = createRoot(dom, mergedRootOptions);\n rootMap.set(dom, root);\n }\n if (root && \"render\" in root) {\n root.render(rootComponentWithErrorBoundary);\n }\n }\n ((_f = (_e = (_d = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _d.lifecycle) == null ? void 0 : _e.afterBridgeRender) == null ? void 0 : _f.emit(info)) || {};\n },\n destroy(info) {\n var _a, _b, _c;\n const { dom } = info;\n LoggerInstance.debug(`createBridgeComponent destroy Info`, info);\n const root = rootMap.get(dom);\n if (root) {\n if (\"unmount\" in root) {\n root.unmount();\n } else {\n LoggerInstance.warn(\"Root does not have unmount method\");\n }\n rootMap.delete(dom);\n }\n (_c = (_b = (_a = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _a.lifecycle) == null ? void 0 : _b.afterBridgeDestroy) == null ? void 0 : _c.emit(info);\n }\n };\n };\n}\nexport {\n ErrorBoundary as E,\n createBaseBridgeComponent as c\n};\n",
150
150
  "createHelpers-BSHeKyd-.mjs": "import { c as createBaseBridgeComponent, E as ErrorBoundary } from \"./bridge-base-BaKy6CY_.mjs\";\nimport ReactDOM from \"react-dom\";\nimport { L as LoggerInstance, g as getRootDomDefaultClassName } from \"./index-Bs2NxD2z.mjs\";\nimport React__default, { forwardRef, useRef, useState, useEffect } from \"react\";\nimport { federationRuntime } from \"./plugin.es.js\";\nfunction createReact16Or17Root(container) {\n return {\n render(children) {\n const reactVersion = ReactDOM.version || \"\";\n const isReact18 = reactVersion.startsWith(\"18\");\n const isReact19 = reactVersion.startsWith(\"19\");\n if (isReact19) {\n throw new Error(\n `React 19 detected in legacy mode. This is not supported. Please use the version-specific import: import { createBridgeComponent } from '@module-federation/bridge-react/v19'`\n );\n }\n if (isReact18) {\n LoggerInstance.warn(\n `[Bridge-React] React 18 detected in legacy mode. For better compatibility, please use the version-specific import: import { createBridgeComponent } from '@module-federation/bridge-react/v18'`\n );\n }\n ReactDOM.render(children, container);\n },\n unmount() {\n ReactDOM.unmountComponentAtNode(container);\n }\n };\n}\nfunction createBridgeComponent(bridgeInfo) {\n const fullBridgeInfo = {\n createRoot: createReact16Or17Root,\n ...bridgeInfo\n };\n return createBaseBridgeComponent(fullBridgeInfo);\n}\nconst RemoteAppWrapper = forwardRef(function(props, ref) {\n const {\n moduleName,\n memoryRoute,\n basename,\n providerInfo,\n className,\n style,\n fallback,\n loading,\n ...resProps\n } = props;\n const instance = federationRuntime.instance;\n const rootRef = ref && \"current\" in ref ? ref : useRef(null);\n const renderDom = useRef(null);\n const providerInfoRef = useRef(null);\n const [initialized, setInitialized] = useState(false);\n LoggerInstance.debug(`RemoteAppWrapper instance from props >>>`, instance);\n useEffect(() => {\n if (initialized) return;\n const providerReturn = providerInfo();\n providerInfoRef.current = providerReturn;\n setInitialized(true);\n return () => {\n var _a, _b, _c, _d, _e, _f, _g, _h;\n if ((_a = providerInfoRef.current) == null ? void 0 : _a.destroy) {\n LoggerInstance.debug(\n `createRemoteAppComponent LazyComponent destroy >>>`,\n { moduleName, basename, dom: renderDom.current }\n );\n (_d = (_c = (_b = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _b.lifecycle) == null ? void 0 : _c.beforeBridgeDestroy) == null ? void 0 : _d.emit({\n moduleName,\n dom: renderDom.current,\n basename,\n memoryRoute,\n fallback,\n ...resProps\n });\n (_e = providerInfoRef.current) == null ? void 0 : _e.destroy({\n moduleName,\n dom: renderDom.current\n });\n (_h = (_g = (_f = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _f.lifecycle) == null ? void 0 : _g.afterBridgeDestroy) == null ? void 0 : _h.emit({\n moduleName,\n dom: renderDom.current,\n basename,\n memoryRoute,\n fallback,\n ...resProps\n });\n }\n };\n }, [moduleName]);\n useEffect(() => {\n var _a, _b, _c, _d, _e, _f;\n if (!initialized || !providerInfoRef.current) return;\n let renderProps = {\n moduleName,\n dom: rootRef.current,\n basename,\n memoryRoute,\n fallback,\n ...resProps\n };\n renderDom.current = rootRef.current;\n const beforeBridgeRenderRes = ((_c = (_b = (_a = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _a.lifecycle) == null ? void 0 : _b.beforeBridgeRender) == null ? void 0 : _c.emit(renderProps)) || {};\n renderProps = { ...renderProps, ...beforeBridgeRenderRes.extraProps };\n providerInfoRef.current.render(renderProps);\n (_f = (_e = (_d = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _d.lifecycle) == null ? void 0 : _e.afterBridgeRender) == null ? void 0 : _f.emit(renderProps);\n }, [initialized, ...Object.values(props)]);\n const rootComponentClassName = `${getRootDomDefaultClassName(moduleName)} ${className || \"\"}`;\n return /* @__PURE__ */ React__default.createElement(\"div\", { className: rootComponentClassName, style, ref: rootRef }, loading);\n});\nfunction createLazyRemoteComponentFactory(RemoteApp) {\n return function createLazyRemoteComponent(info) {\n const exportName = (info == null ? void 0 : info.export) || \"default\";\n return React__default.lazy(async () => {\n LoggerInstance.debug(\n `createRemoteAppComponent LazyComponent create >>>`,\n {\n lazyComponent: info.loader,\n exportName\n }\n );\n try {\n const m = await info.loader();\n const moduleName = m && m[Symbol.for(\"mf_module_id\")];\n LoggerInstance.debug(\n `createRemoteAppComponent LazyComponent loadRemote info >>>`,\n { name: moduleName, module: m, exportName }\n );\n const exportFn = m[exportName];\n if (exportName in m && typeof exportFn === \"function\") {\n const RemoteAppComponent = forwardRef((props, ref) => {\n return /* @__PURE__ */ React__default.createElement(\n RemoteApp,\n {\n moduleName,\n providerInfo: exportFn,\n exportName: info.export || \"default\",\n fallback: info.fallback,\n loading: info.loading,\n ref,\n ...props\n }\n );\n });\n return {\n default: RemoteAppComponent\n };\n } else {\n LoggerInstance.debug(\n `createRemoteAppComponent LazyComponent module not found >>>`,\n { name: moduleName, module: m, exportName }\n );\n throw Error(\n `Make sure that ${moduleName} has the correct export when export is ${String(\n exportName\n )}`\n );\n }\n } catch (error) {\n throw error;\n }\n });\n };\n}\nfunction createRemoteAppComponentFactory(RemoteApp) {\n const createLazyRemoteComponent = createLazyRemoteComponentFactory(RemoteApp);\n return function createRemoteAppComponent(info) {\n const LazyComponent = createLazyRemoteComponent(info);\n return forwardRef((props, ref) => {\n return /* @__PURE__ */ React__default.createElement(\n ErrorBoundary,\n {\n FallbackComponent: info.fallback\n },\n /* @__PURE__ */ React__default.createElement(React__default.Suspense, { fallback: info.loading }, /* @__PURE__ */ React__default.createElement(LazyComponent, { ...props, ref }))\n );\n });\n };\n}\nfunction createDeprecatedRemoteComponentFactory(createFn) {\n return function createRemoteComponent(info) {\n LoggerInstance.warn(\n `createRemoteComponent is deprecated, please use createRemoteAppComponent instead!`\n );\n return createFn(info);\n };\n}\nexport {\n RemoteAppWrapper as R,\n createDeprecatedRemoteComponentFactory as a,\n createBridgeComponent as b,\n createRemoteAppComponentFactory as c\n};\n",
151
- "data-fetch-utils.es.js": "import { y as DATA_FETCH_FUNCTION } from \"./utils-BBP3hEeV.mjs\";\nimport { C, a, c, b, d, g, r } from \"./utils-BBP3hEeV.mjs\";\nimport { d as dataFetchFunction } from \"./prefetch-CTZuFBqh.mjs\";\nimport { i, p } from \"./prefetch-CTZuFBqh.mjs\";\nasync function callDataFetch() {\n const dataFetch = globalThis[DATA_FETCH_FUNCTION];\n if (dataFetch) {\n await Promise.all(\n dataFetch.map(async (options) => {\n await dataFetchFunction(options);\n })\n );\n }\n}\nexport {\n C as CacheSize,\n a as CacheTime,\n c as cache,\n callDataFetch,\n b as clearStore,\n d as configureCache,\n g as generateKey,\n i as injectDataFetch,\n p as prefetch,\n r as revalidateTag\n};\n",
151
+ "data-fetch-utils.es.js": "import { y as DATA_FETCH_FUNCTION } from \"./utils-BBP3hEeV.mjs\";\nimport { C, a, c, b, d, g, r } from \"./utils-BBP3hEeV.mjs\";\nimport { d as dataFetchFunction } from \"./prefetch-BzCq3MT3.mjs\";\nimport { i, p } from \"./prefetch-BzCq3MT3.mjs\";\nasync function callDataFetch() {\n const dataFetch = globalThis[DATA_FETCH_FUNCTION];\n if (dataFetch) {\n await Promise.all(\n dataFetch.map(async (options) => {\n await dataFetchFunction(options);\n })\n );\n }\n}\nexport {\n C as CacheSize,\n a as CacheTime,\n c as cache,\n callDataFetch,\n b as clearStore,\n d as configureCache,\n g as generateKey,\n i as injectDataFetch,\n p as prefetch,\n r as revalidateTag\n};\n",
152
152
  "index-Bs2NxD2z.mjs": "import React__default from \"react\";\nimport { c as createLogger } from \"./logger-DwWkXsWl.mjs\";\nconst RouterContext = React__default.createContext(null);\nconst LoggerInstance = createLogger(\n \"[ Module Federation Bridge React ]\"\n);\nfunction pathJoin(...args) {\n const res = args.reduce((res2, path) => {\n let nPath = path;\n if (!nPath || typeof nPath !== \"string\") {\n return res2;\n }\n if (nPath[0] !== \"/\") {\n nPath = `/${nPath}`;\n }\n const lastIndex = nPath.length - 1;\n if (nPath[lastIndex] === \"/\") {\n nPath = nPath.substring(0, lastIndex);\n }\n return res2 + nPath;\n }, \"\");\n return res || \"/\";\n}\nconst getModuleName = (id) => {\n if (!id) {\n return id;\n }\n const idArray = id.split(\"/\");\n if (idArray.length < 2) {\n return id;\n }\n return idArray[0] + \"/\" + idArray[1];\n};\nconst getRootDomDefaultClassName = (moduleName) => {\n if (!moduleName) {\n return \"\";\n }\n const name = getModuleName(moduleName).replace(/\\@/, \"\").replace(/\\//, \"-\");\n return `bridge-root-component-${name}`;\n};\nexport {\n LoggerInstance as L,\n RouterContext as R,\n getRootDomDefaultClassName as g,\n pathJoin as p\n};\n",
153
- "index.es.js": "import { R as RemoteAppWrapper, c as createRemoteAppComponentFactory, a as createDeprecatedRemoteComponentFactory } from \"./createHelpers-BSHeKyd-.mjs\";\nimport { b } from \"./createHelpers-BSHeKyd-.mjs\";\nimport { a, c, b as b2, l } from \"./lazy-load-component-plugin-DEu-DfZt.mjs\";\nimport { C, a as a2, E, c as c2, b as b3, d, g, r, s } from \"./utils-BBP3hEeV.mjs\";\nimport { callDataFetch } from \"./data-fetch-utils.es.js\";\nimport React__default, { forwardRef, useContext, useState, useEffect } from \"react\";\nimport * as ReactRouterDOM from \"react-router-dom\";\nimport { p as pathJoin, L as LoggerInstance } from \"./index-Bs2NxD2z.mjs\";\nimport { p } from \"./prefetch-CTZuFBqh.mjs\";\nfunction e() {\n const t = new PopStateEvent(\"popstate\", { state: window.history.state });\n window.dispatchEvent(t);\n}\nfunction withRouterData(WrappedComponent) {\n const Component = forwardRef(function(props, ref) {\n var _a;\n if (props == null ? void 0 : props.basename) {\n return /* @__PURE__ */ React__default.createElement(WrappedComponent, { ...props, basename: props.basename, ref });\n }\n let enableDispathPopstate = false;\n let routerContextVal;\n try {\n ReactRouterDOM.useLocation();\n enableDispathPopstate = true;\n } catch {\n enableDispathPopstate = false;\n }\n let basename = \"/\";\n if (!props.basename && enableDispathPopstate) {\n const ReactRouterDOMAny = ReactRouterDOM;\n const useRouteMatch = ReactRouterDOMAny[\"useRouteMatch\"];\n const useHistory = ReactRouterDOMAny[\"useHistory\"];\n const useHref = ReactRouterDOMAny[\"useHref\"];\n const UNSAFE_RouteContext = ReactRouterDOMAny[\"UNSAFE_RouteContext\"];\n if (UNSAFE_RouteContext) {\n if (useHref) {\n basename = useHref == null ? void 0 : useHref(\"/\");\n }\n routerContextVal = useContext(UNSAFE_RouteContext);\n if (routerContextVal && routerContextVal.matches && routerContextVal.matches.length > 0) {\n const matchIndex = routerContextVal.matches.length - 1;\n const pathnameBase = routerContextVal.matches[matchIndex].pathnameBase;\n basename = pathJoin(basename, pathnameBase || \"/\");\n }\n } else {\n const match = useRouteMatch == null ? void 0 : useRouteMatch();\n if (useHistory) {\n const history = useHistory == null ? void 0 : useHistory();\n basename = (_a = history == null ? void 0 : history.createHref) == null ? void 0 : _a.call(history, { pathname: \"/\" });\n }\n if (match) {\n basename = pathJoin(basename, (match == null ? void 0 : match.path) || \"/\");\n }\n }\n }\n LoggerInstance.debug(`createRemoteAppComponent withRouterData >>>`, {\n ...props,\n basename,\n routerContextVal,\n enableDispathPopstate\n });\n if (enableDispathPopstate) {\n const location = ReactRouterDOM.useLocation();\n const [pathname, setPathname] = useState(location.pathname);\n useEffect(() => {\n if (pathname !== \"\" && pathname !== location.pathname) {\n LoggerInstance.debug(\n `createRemoteAppComponent dispatchPopstateEnv >>>`,\n {\n name: props.name,\n pathname: location.pathname\n }\n );\n e();\n }\n setPathname(location.pathname);\n }, [location]);\n }\n return /* @__PURE__ */ React__default.createElement(WrappedComponent, { ...props, basename, ref });\n });\n return forwardRef(function(props, ref) {\n return /* @__PURE__ */ React__default.createElement(Component, { ...props, ref });\n });\n}\nconst RemoteApp = withRouterData(RemoteAppWrapper);\nconst createRemoteAppComponent = createRemoteAppComponentFactory(RemoteApp);\nconst createRemoteComponent = createDeprecatedRemoteComponentFactory(\n createRemoteAppComponent\n);\nexport {\n C as CacheSize,\n a2 as CacheTime,\n E as ERROR_TYPE,\n a as autoFetchDataPlugin,\n c2 as cache,\n callDataFetch,\n b3 as clearStore,\n c as collectSSRAssets,\n d as configureCache,\n b as createBridgeComponent,\n b2 as createLazyComponent,\n createRemoteAppComponent,\n createRemoteComponent,\n g as generateKey,\n l as lazyLoadComponentPlugin,\n p as prefetch,\n r as revalidateTag,\n s as setSSREnv\n};\n",
154
- "lazy-load-component-plugin-DEu-DfZt.mjs": 'import { i as injectDataFetch, p as prefetch } from "./prefetch-CTZuFBqh.mjs";\nimport { i as initDataFetchMap, k as isDataLoaderExpose, m as getDataFetchInfo, n as getDataFetchMapKey, l as logger, o as getDataFetchItem, p as DATA_FETCH_CLIENT_SUFFIX, q as MF_DATA_FETCH_TYPE, t as isCSROnly, M as MF_DATA_FETCH_STATUS, j as loadDataFetchModule, e as getDataFetchMap, u as isServerEnv, v as getDataFetchIdWithErrorMsgs, w as DATA_FETCH_ERROR_PREFIX, E as ERROR_TYPE, x as wrapDataFetchId, L as LOAD_REMOTE_ERROR_PREFIX, y as DATA_FETCH_FUNCTION, z as getLoadedRemoteInfos, h as fetchData$1, A as setDataFetchItemLoadedStatus, F as FS_HREF } from "./utils-BBP3hEeV.mjs";\nimport React__default, { useRef, useState, Suspense, useEffect } from "react";\nconst autoFetchData = () => {\n initDataFetchMap();\n injectDataFetch();\n return {\n name: "auto-fetch-data-plugin",\n afterLoadSnapshot(args) {\n const { id, moduleInfo, remoteSnapshot, host } = args;\n if (typeof id === "string" && isDataLoaderExpose(id)) {\n return args;\n }\n if (!remoteSnapshot || !id || !("modules" in remoteSnapshot)) {\n return args;\n }\n const { name, alias } = moduleInfo;\n const dataFetchInfo = getDataFetchInfo({\n name,\n alias,\n id,\n remoteSnapshot\n });\n if (!dataFetchInfo) {\n return args;\n }\n const { dataFetchId, dataFetchName } = dataFetchInfo;\n const dataFetchMapKey = getDataFetchMapKey(dataFetchInfo, {\n name: host.name,\n version: host.options.version\n });\n logger.debug(\n "======= auto fetch plugin dataFetchMapKey: ",\n dataFetchMapKey\n );\n if (!dataFetchMapKey) {\n return args;\n }\n const dataFetchItem = getDataFetchItem(dataFetchMapKey);\n if (dataFetchItem) {\n return args;\n }\n const dataFetchMap = getDataFetchMap();\n const hasSSRAsset = Boolean(remoteSnapshot.ssrRemoteEntry);\n const hasDataFetchClient = Boolean(\n remoteSnapshot.modules.find(\n (module) => module.moduleName === `${dataFetchName}${DATA_FETCH_CLIENT_SUFFIX}`\n )\n );\n const downgradeType = hasDataFetchClient ? MF_DATA_FETCH_TYPE.FETCH_CLIENT : hasSSRAsset ? MF_DATA_FETCH_TYPE.FETCH_SERVER : MF_DATA_FETCH_TYPE.FETCH_CLIENT;\n let finalDataFetchId = dataFetchId;\n if (!isServerEnv()) {\n finalDataFetchId = downgradeType === MF_DATA_FETCH_TYPE.FETCH_CLIENT ? hasDataFetchClient ? `${dataFetchId}${DATA_FETCH_CLIENT_SUFFIX}` : dataFetchId : dataFetchId;\n }\n const getDataFetchGetter = () => loadDataFetchModule(host, finalDataFetchId);\n const dataFetchFnItem = [\n getDataFetchGetter,\n downgradeType\n ];\n if (typeof window === "undefined" || isCSROnly()) {\n dataFetchFnItem.push(getDataFetchGetter());\n }\n dataFetchMap[dataFetchMapKey] = [\n dataFetchFnItem,\n void 0,\n MF_DATA_FETCH_STATUS.AWAIT\n ];\n return args;\n }\n };\n};\nfunction isPromise(obj) {\n return !!obj && (typeof obj === "object" || typeof obj === "function") && typeof obj.then === "function";\n}\nconst AWAIT_ERROR_PREFIX = "<Await /> caught the following error during render: ";\nconst transformError = (err) => {\n const errMsg = err instanceof Error ? err.message : err;\n const originalMsg = errMsg.replace(AWAIT_ERROR_PREFIX, "");\n const dataFetchMapKey = getDataFetchIdWithErrorMsgs(originalMsg);\n if (originalMsg.indexOf(DATA_FETCH_ERROR_PREFIX) === 0) {\n return {\n error: new Error(\n originalMsg.replace(DATA_FETCH_ERROR_PREFIX, "").replace(wrapDataFetchId(dataFetchMapKey), "")\n ),\n errorType: ERROR_TYPE.DATA_FETCH,\n dataFetchMapKey\n };\n }\n if (originalMsg.indexOf(LOAD_REMOTE_ERROR_PREFIX) === 0) {\n return {\n error: new Error(\n originalMsg.replace(LOAD_REMOTE_ERROR_PREFIX, "").replace(wrapDataFetchId(dataFetchMapKey), "")\n ),\n errorType: ERROR_TYPE.LOAD_REMOTE,\n dataFetchMapKey\n };\n }\n return {\n error: new Error(originalMsg.replace(wrapDataFetchId(dataFetchMapKey), "")),\n errorType: ERROR_TYPE.UNKNOWN,\n dataFetchMapKey\n };\n};\nconst DefaultLoading = /* @__PURE__ */ React__default.createElement(React__default.Fragment, null);\nconst DefaultErrorElement = (_data) => /* @__PURE__ */ React__default.createElement("div", null, "Error");\nfunction AwaitDataFetch({\n resolve,\n loading = DefaultLoading,\n errorElement = DefaultErrorElement,\n children,\n params,\n delayLoading\n}) {\n const dataRef = useRef();\n const data = dataRef.current || resolve;\n const getData = isPromise(data) ? fetchData(data, dataRef) : () => data;\n return /* @__PURE__ */ React__default.createElement(\n AwaitSuspense,\n {\n params,\n loading,\n errorElement,\n delayLoading,\n resolve: getData\n },\n children\n );\n}\nconst DelayedLoading = ({\n delayLoading,\n children\n}) => {\n const [show, setShow] = useState(false);\n const timerSet = useRef(false);\n if (!delayLoading) {\n return children;\n }\n if (typeof window !== "undefined" && !show && !timerSet.current) {\n timerSet.current = true;\n setTimeout(() => {\n setShow(true);\n }, delayLoading);\n }\n return show ? children : null;\n};\nfunction AwaitSuspense({\n resolve,\n children,\n loading = DefaultLoading,\n errorElement = DefaultErrorElement,\n delayLoading\n}) {\n return /* @__PURE__ */ React__default.createElement(\n Suspense,\n {\n fallback: /* @__PURE__ */ React__default.createElement(DelayedLoading, { delayLoading }, loading)\n },\n /* @__PURE__ */ React__default.createElement(ResolveAwait, { resolve, errorElement }, children)\n );\n}\nfunction ResolveAwait({\n children,\n resolve,\n errorElement,\n params\n}) {\n const data = resolve();\n logger.debug("resolve data: ", data);\n if (typeof data === "string" && data.indexOf(AWAIT_ERROR_PREFIX) === 0) {\n const transformedError = transformError(data);\n return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, typeof errorElement === "function" ? /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, globalThis.FEDERATION_SSR && /* @__PURE__ */ React__default.createElement(\n "script",\n {\n suppressHydrationWarning: true,\n dangerouslySetInnerHTML: {\n __html: String.raw`\n globalThis[\'${DATA_FETCH_FUNCTION}\'] = globalThis[\'${DATA_FETCH_FUNCTION}\'] || []\n globalThis[\'${DATA_FETCH_FUNCTION}\'].push([${transformedError.dataFetchMapKey ? `\'${transformedError.dataFetchMapKey}\'` : ""},${params ? JSON.stringify(params) : null},true]);`\n }\n }\n ), errorElement(transformedError)) : errorElement);\n }\n const toRender = typeof children === "function" ? children(data) : children;\n return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, toRender);\n}\nconst fetchData = (promise, ref) => {\n let data;\n let status = "pending";\n const suspender = promise.then((res) => {\n status = "success";\n data = res;\n ref.current = res;\n }).catch((e) => {\n status = "success";\n console.warn(e);\n data = AWAIT_ERROR_PREFIX + e;\n });\n return () => {\n if (status === "pending") {\n throw suspender;\n }\n return data;\n };\n};\nfunction getTargetModuleInfo(id, instance) {\n if (!instance) {\n return;\n }\n const loadedRemoteInfo = getLoadedRemoteInfos(id, instance);\n if (!loadedRemoteInfo) {\n return;\n }\n const { snapshot } = loadedRemoteInfo;\n if (!snapshot) {\n return;\n }\n const publicPath = "publicPath" in snapshot ? snapshot.publicPath : "getPublicPath" in snapshot ? new Function(snapshot.getPublicPath)() : "";\n if (!publicPath) {\n return;\n }\n const modules = "modules" in snapshot ? snapshot.modules : [];\n const targetModule = modules.find(\n (m) => m.modulePath === loadedRemoteInfo.expose\n );\n if (!targetModule) {\n return;\n }\n const remoteEntry = "remoteEntry" in snapshot ? snapshot.remoteEntry : "";\n if (!remoteEntry) {\n return;\n }\n return {\n module: targetModule,\n publicPath,\n remoteEntry\n };\n}\nfunction collectSSRAssets(options) {\n const {\n id,\n injectLink = true,\n injectScript = false\n } = typeof options === "string" ? { id: options } : options;\n const links = [];\n const scripts = [];\n const instance = options.instance;\n if (!instance || !injectLink && !injectScript) {\n return [...scripts, ...links];\n }\n const moduleAndPublicPath = getTargetModuleInfo(id, instance);\n if (!moduleAndPublicPath) {\n return [...scripts, ...links];\n }\n const { module: targetModule, publicPath, remoteEntry } = moduleAndPublicPath;\n if (injectLink) {\n [...targetModule.assets.css.sync, ...targetModule.assets.css.async].sort().forEach((file, index) => {\n links.push(\n /* @__PURE__ */ React__default.createElement(\n "link",\n {\n key: `${file.split(".")[0]}_${index}`,\n href: `${publicPath}${file}`,\n rel: "stylesheet",\n type: "text/css"\n }\n )\n );\n });\n }\n if (injectScript) {\n scripts.push(\n /* @__PURE__ */ React__default.createElement(\n "script",\n {\n async: true,\n key: remoteEntry.split(".")[0],\n src: `${publicPath}${remoteEntry}`,\n crossOrigin: "anonymous"\n }\n )\n );\n [...targetModule.assets.js.sync].sort().forEach((file, index) => {\n scripts.push(\n /* @__PURE__ */ React__default.createElement(\n "script",\n {\n key: `${file.split(".")[0]}_${index}`,\n async: true,\n src: `${publicPath}${file}`,\n crossOrigin: "anonymous"\n }\n )\n );\n });\n }\n return [...scripts, ...links];\n}\nfunction getServerNeedRemoteInfo(loadedRemoteInfo, id, noSSR) {\n var _a;\n if (noSSR || typeof window !== "undefined" && window.location.href !== window[FS_HREF]) {\n if (!(loadedRemoteInfo == null ? void 0 : loadedRemoteInfo.version)) {\n throw new Error(`${loadedRemoteInfo == null ? void 0 : loadedRemoteInfo.name} version is empty`);\n }\n const { snapshot } = loadedRemoteInfo;\n if (!snapshot) {\n throw new Error(`${loadedRemoteInfo == null ? void 0 : loadedRemoteInfo.name} snapshot is empty`);\n }\n const dataFetchItem = getDataFetchItem(id);\n const isFetchServer = ((_a = dataFetchItem == null ? void 0 : dataFetchItem[0]) == null ? void 0 : _a[1]) === MF_DATA_FETCH_TYPE.FETCH_SERVER;\n if (isFetchServer && (!("ssrPublicPath" in snapshot) || !snapshot.ssrPublicPath)) {\n throw new Error(\n `ssrPublicPath is required while fetching ${loadedRemoteInfo == null ? void 0 : loadedRemoteInfo.name} data in SSR project!`\n );\n }\n if (isFetchServer && (!("ssrRemoteEntry" in snapshot) || !snapshot.ssrRemoteEntry)) {\n throw new Error(\n `ssrRemoteEntry is required while loading ${loadedRemoteInfo == null ? void 0 : loadedRemoteInfo.name} data loader in SSR project!`\n );\n }\n return {\n name: loadedRemoteInfo.name,\n version: loadedRemoteInfo.version,\n ssrPublicPath: "ssrPublicPath" in snapshot ? snapshot.ssrPublicPath || "" : "",\n ssrRemoteEntry: "ssrRemoteEntry" in snapshot ? snapshot.ssrRemoteEntry || "" : "",\n globalName: loadedRemoteInfo.entryGlobalName\n };\n }\n return void 0;\n}\nfunction createLazyComponent(options) {\n const { instance, injectScript, injectLink } = options;\n if (!instance) {\n throw new Error("instance is required for createLazyComponent!");\n }\n const exportName = (options == null ? void 0 : options.export) || "default";\n const callLoader = async () => {\n logger.debug("callLoader start", Date.now());\n const m = await options.loader();\n logger.debug("callLoader end", Date.now());\n if (!m) {\n throw new Error("load remote failed");\n }\n return m;\n };\n const getData = async (noSSR) => {\n let loadedRemoteInfo;\n let moduleId;\n try {\n const m = await callLoader();\n moduleId = m && m[Symbol.for("mf_module_id")];\n if (!moduleId) {\n throw new Error("moduleId is empty");\n }\n loadedRemoteInfo = getLoadedRemoteInfos(moduleId, instance);\n if (!loadedRemoteInfo) {\n throw new Error(`can not find loaded remote(\'${moduleId}\') info!`);\n }\n } catch (e) {\n const errMsg = `${LOAD_REMOTE_ERROR_PREFIX}${e}`;\n logger.debug(e);\n throw new Error(errMsg);\n }\n let dataFetchMapKey;\n try {\n dataFetchMapKey = getDataFetchMapKey(\n getDataFetchInfo({\n name: loadedRemoteInfo.name,\n alias: loadedRemoteInfo.alias,\n id: moduleId,\n remoteSnapshot: loadedRemoteInfo.snapshot\n }),\n { name: instance.name, version: instance.options.version }\n );\n logger.debug("getData dataFetchMapKey: ", dataFetchMapKey);\n if (!dataFetchMapKey) {\n return;\n }\n const data = await fetchData$1(\n dataFetchMapKey,\n {\n ...options.dataFetchParams,\n isDowngrade: false\n },\n getServerNeedRemoteInfo(loadedRemoteInfo, dataFetchMapKey, noSSR)\n );\n setDataFetchItemLoadedStatus(dataFetchMapKey);\n logger.debug("get data res: \\n", data);\n return data;\n } catch (err) {\n const errMsg = `${DATA_FETCH_ERROR_PREFIX}${wrapDataFetchId(dataFetchMapKey)}${err}`;\n logger.debug(errMsg);\n throw new Error(errMsg);\n }\n };\n const LazyComponent = React__default.lazy(async () => {\n const m = await callLoader();\n const moduleId = m && m[Symbol.for("mf_module_id")];\n const loadedRemoteInfo = getLoadedRemoteInfos(moduleId, instance);\n loadedRemoteInfo == null ? void 0 : loadedRemoteInfo.snapshot;\n const dataFetchMapKey = loadedRemoteInfo ? getDataFetchMapKey(\n getDataFetchInfo({\n name: loadedRemoteInfo.name,\n alias: loadedRemoteInfo.alias,\n id: moduleId,\n remoteSnapshot: loadedRemoteInfo.snapshot\n }),\n { name: instance.name, version: instance == null ? void 0 : instance.options.version }\n ) : void 0;\n logger.debug("LazyComponent dataFetchMapKey: ", dataFetchMapKey);\n const assets = collectSSRAssets({\n id: moduleId,\n instance,\n injectLink,\n injectScript\n });\n const Com = m[exportName];\n if (exportName in m && typeof Com === "function") {\n return {\n default: (props) => /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, globalThis.FEDERATION_SSR && dataFetchMapKey && /* @__PURE__ */ React__default.createElement(\n "script",\n {\n suppressHydrationWarning: true,\n dangerouslySetInnerHTML: {\n __html: String.raw`\n globalThis[\'${DATA_FETCH_FUNCTION}\'] = globalThis[\'${DATA_FETCH_FUNCTION}\'] || [];\n globalThis[\'${DATA_FETCH_FUNCTION}\'].push([\'${dataFetchMapKey}\',${JSON.stringify(props.mfData)}]);\n `\n }\n }\n ), globalThis.FEDERATION_SSR && assets, /* @__PURE__ */ React__default.createElement(Com, { ...props }))\n };\n } else {\n throw Error(\n `Make sure that ${moduleId} has the correct export when export is ${String(\n exportName\n )}`\n );\n }\n });\n return (props) => {\n const { key, ...args } = props;\n if (!options.noSSR) {\n return /* @__PURE__ */ React__default.createElement(\n AwaitDataFetch,\n {\n resolve: getData(options.noSSR),\n loading: options.loading,\n delayLoading: options.delayLoading,\n errorElement: options.fallback\n },\n (data) => /* @__PURE__ */ React__default.createElement(LazyComponent, { ...args, mfData: data })\n );\n } else {\n const [data, setData] = useState(null);\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState(null);\n useEffect(() => {\n let isMounted = true;\n const fetchDataAsync = async () => {\n try {\n setLoading(true);\n const result = await getData(options.noSSR);\n if (isMounted) {\n setData(result);\n }\n } catch (e) {\n if (isMounted) {\n setError(transformError(e));\n }\n } finally {\n if (isMounted) {\n setLoading(false);\n }\n }\n };\n fetchDataAsync();\n return () => {\n isMounted = false;\n };\n }, []);\n if (loading) {\n return /* @__PURE__ */ React__default.createElement(DelayedLoading, { delayLoading: options.delayLoading }, options.loading);\n }\n if (error) {\n return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, typeof options.fallback === "function" ? options.fallback(error) : options.fallback);\n }\n return /* @__PURE__ */ React__default.createElement(LazyComponent, { ...args, mfData: data });\n }\n };\n}\nfunction lazyLoadComponentPlugin() {\n return {\n name: "lazy-load-component-plugin",\n apply(instance) {\n instance.registerPlugins([autoFetchData()]);\n instance.createLazyComponent = (options) => {\n return createLazyComponent({\n instance,\n ...options\n });\n };\n instance.prefetch = (options) => {\n return prefetch({\n instance,\n ...options\n });\n };\n instance.collectSSRAssets = (options) => {\n return collectSSRAssets({\n instance,\n ...options\n });\n };\n }\n };\n}\nexport {\n autoFetchData as a,\n createLazyComponent as b,\n collectSSRAssets as c,\n lazyLoadComponentPlugin as l\n};\n',
153
+ "index.es.js": "import { R as RemoteAppWrapper, c as createRemoteAppComponentFactory, a as createDeprecatedRemoteComponentFactory } from \"./createHelpers-BSHeKyd-.mjs\";\nimport { b } from \"./createHelpers-BSHeKyd-.mjs\";\nimport { a, c, b as b2, l } from \"./lazy-load-component-plugin-DlagtX0O.mjs\";\nimport { C, a as a2, E, c as c2, b as b3, d, g, r, s } from \"./utils-BBP3hEeV.mjs\";\nimport { callDataFetch } from \"./data-fetch-utils.es.js\";\nimport React__default, { forwardRef, useContext, useState, useEffect } from \"react\";\nimport * as ReactRouterDOM from \"react-router-dom\";\nimport { p as pathJoin, L as LoggerInstance } from \"./index-Bs2NxD2z.mjs\";\nimport { p } from \"./prefetch-BzCq3MT3.mjs\";\nfunction e() {\n const t = new PopStateEvent(\"popstate\", { state: window.history.state });\n window.dispatchEvent(t);\n}\nfunction withRouterData(WrappedComponent) {\n const Component = forwardRef(function(props, ref) {\n var _a;\n if (props == null ? void 0 : props.basename) {\n return /* @__PURE__ */ React__default.createElement(WrappedComponent, { ...props, basename: props.basename, ref });\n }\n let enableDispathPopstate = false;\n let routerContextVal;\n try {\n ReactRouterDOM.useLocation();\n enableDispathPopstate = true;\n } catch {\n enableDispathPopstate = false;\n }\n let basename = \"/\";\n if (!props.basename && enableDispathPopstate) {\n const ReactRouterDOMAny = ReactRouterDOM;\n const useRouteMatch = ReactRouterDOMAny[\"useRouteMatch\"];\n const useHistory = ReactRouterDOMAny[\"useHistory\"];\n const useHref = ReactRouterDOMAny[\"useHref\"];\n const UNSAFE_RouteContext = ReactRouterDOMAny[\"UNSAFE_RouteContext\"];\n if (UNSAFE_RouteContext) {\n if (useHref) {\n basename = useHref == null ? void 0 : useHref(\"/\");\n }\n routerContextVal = useContext(UNSAFE_RouteContext);\n if (routerContextVal && routerContextVal.matches && routerContextVal.matches.length > 0) {\n const matchIndex = routerContextVal.matches.length - 1;\n const pathnameBase = routerContextVal.matches[matchIndex].pathnameBase;\n basename = pathJoin(basename, pathnameBase || \"/\");\n }\n } else {\n const match = useRouteMatch == null ? void 0 : useRouteMatch();\n if (useHistory) {\n const history = useHistory == null ? void 0 : useHistory();\n basename = (_a = history == null ? void 0 : history.createHref) == null ? void 0 : _a.call(history, { pathname: \"/\" });\n }\n if (match) {\n basename = pathJoin(basename, (match == null ? void 0 : match.path) || \"/\");\n }\n }\n }\n LoggerInstance.debug(`createRemoteAppComponent withRouterData >>>`, {\n ...props,\n basename,\n routerContextVal,\n enableDispathPopstate\n });\n if (enableDispathPopstate) {\n const location = ReactRouterDOM.useLocation();\n const [pathname, setPathname] = useState(location.pathname);\n useEffect(() => {\n if (pathname !== \"\" && pathname !== location.pathname) {\n LoggerInstance.debug(\n `createRemoteAppComponent dispatchPopstateEnv >>>`,\n {\n name: props.name,\n pathname: location.pathname\n }\n );\n e();\n }\n setPathname(location.pathname);\n }, [location]);\n }\n return /* @__PURE__ */ React__default.createElement(WrappedComponent, { ...props, basename, ref });\n });\n return forwardRef(function(props, ref) {\n return /* @__PURE__ */ React__default.createElement(Component, { ...props, ref });\n });\n}\nconst RemoteApp = withRouterData(RemoteAppWrapper);\nconst createRemoteAppComponent = createRemoteAppComponentFactory(RemoteApp);\nconst createRemoteComponent = createDeprecatedRemoteComponentFactory(\n createRemoteAppComponent\n);\nexport {\n C as CacheSize,\n a2 as CacheTime,\n E as ERROR_TYPE,\n a as autoFetchDataPlugin,\n c2 as cache,\n callDataFetch,\n b3 as clearStore,\n c as collectSSRAssets,\n d as configureCache,\n b as createBridgeComponent,\n b2 as createLazyComponent,\n createRemoteAppComponent,\n createRemoteComponent,\n g as generateKey,\n l as lazyLoadComponentPlugin,\n p as prefetch,\n r as revalidateTag,\n s as setSSREnv\n};\n",
154
+ "lazy-load-component-plugin-DlagtX0O.mjs": 'import { i as injectDataFetch, p as prefetch } from "./prefetch-BzCq3MT3.mjs";\nimport { i as initDataFetchMap, k as isDataLoaderExpose, m as getDataFetchInfo, n as getDataFetchMapKey, l as logger, o as getDataFetchItem, p as DATA_FETCH_CLIENT_SUFFIX, q as MF_DATA_FETCH_TYPE, t as isCSROnly, M as MF_DATA_FETCH_STATUS, j as loadDataFetchModule, e as getDataFetchMap, u as isServerEnv, v as getDataFetchIdWithErrorMsgs, w as DATA_FETCH_ERROR_PREFIX, E as ERROR_TYPE, x as wrapDataFetchId, L as LOAD_REMOTE_ERROR_PREFIX, y as DATA_FETCH_FUNCTION, z as getLoadedRemoteInfos, h as fetchData$1, A as setDataFetchItemLoadedStatus, F as FS_HREF } from "./utils-BBP3hEeV.mjs";\nimport React__default, { useRef, useState, Suspense, useEffect } from "react";\nconst autoFetchData = () => {\n initDataFetchMap();\n injectDataFetch();\n return {\n name: "auto-fetch-data-plugin",\n afterLoadSnapshot(args) {\n const { id, moduleInfo, remoteSnapshot, host } = args;\n if (typeof id === "string" && isDataLoaderExpose(id)) {\n return args;\n }\n if (!remoteSnapshot || !id || !("modules" in remoteSnapshot)) {\n return args;\n }\n const { name, alias } = moduleInfo;\n const dataFetchInfo = getDataFetchInfo({\n name,\n alias,\n id,\n remoteSnapshot\n });\n if (!dataFetchInfo) {\n return args;\n }\n const { dataFetchId, dataFetchName } = dataFetchInfo;\n const dataFetchMapKey = getDataFetchMapKey(dataFetchInfo, {\n name: host.name,\n version: host.options.version\n });\n logger.debug(\n "======= auto fetch plugin dataFetchMapKey: ",\n dataFetchMapKey\n );\n if (!dataFetchMapKey) {\n return args;\n }\n const dataFetchItem = getDataFetchItem(dataFetchMapKey);\n if (dataFetchItem) {\n return args;\n }\n const dataFetchMap = getDataFetchMap();\n const hasSSRAsset = Boolean(remoteSnapshot.ssrRemoteEntry);\n const hasDataFetchClient = Boolean(\n remoteSnapshot.modules.find(\n (module) => module.moduleName === `${dataFetchName}${DATA_FETCH_CLIENT_SUFFIX}`\n )\n );\n const downgradeType = hasDataFetchClient ? MF_DATA_FETCH_TYPE.FETCH_CLIENT : hasSSRAsset ? MF_DATA_FETCH_TYPE.FETCH_SERVER : MF_DATA_FETCH_TYPE.FETCH_CLIENT;\n let finalDataFetchId = dataFetchId;\n if (!isServerEnv()) {\n finalDataFetchId = downgradeType === MF_DATA_FETCH_TYPE.FETCH_CLIENT ? hasDataFetchClient ? `${dataFetchId}${DATA_FETCH_CLIENT_SUFFIX}` : dataFetchId : dataFetchId;\n }\n const getDataFetchGetter = () => loadDataFetchModule(host, finalDataFetchId);\n const dataFetchFnItem = [\n getDataFetchGetter,\n downgradeType\n ];\n if (typeof window === "undefined" || isCSROnly()) {\n dataFetchFnItem.push(getDataFetchGetter());\n }\n dataFetchMap[dataFetchMapKey] = [\n dataFetchFnItem,\n void 0,\n MF_DATA_FETCH_STATUS.AWAIT\n ];\n return args;\n }\n };\n};\nfunction isPromise(obj) {\n return !!obj && (typeof obj === "object" || typeof obj === "function") && typeof obj.then === "function";\n}\nconst AWAIT_ERROR_PREFIX = "<Await /> caught the following error during render: ";\nconst transformError = (err) => {\n const errMsg = err instanceof Error ? err.message : err;\n const originalMsg = errMsg.replace(AWAIT_ERROR_PREFIX, "");\n const dataFetchMapKey = getDataFetchIdWithErrorMsgs(originalMsg);\n if (originalMsg.indexOf(DATA_FETCH_ERROR_PREFIX) === 0) {\n return {\n error: new Error(\n originalMsg.replace(DATA_FETCH_ERROR_PREFIX, "").replace(wrapDataFetchId(dataFetchMapKey), "")\n ),\n errorType: ERROR_TYPE.DATA_FETCH,\n dataFetchMapKey\n };\n }\n if (originalMsg.indexOf(LOAD_REMOTE_ERROR_PREFIX) === 0) {\n return {\n error: new Error(\n originalMsg.replace(LOAD_REMOTE_ERROR_PREFIX, "").replace(wrapDataFetchId(dataFetchMapKey), "")\n ),\n errorType: ERROR_TYPE.LOAD_REMOTE,\n dataFetchMapKey\n };\n }\n return {\n error: new Error(originalMsg.replace(wrapDataFetchId(dataFetchMapKey), "")),\n errorType: ERROR_TYPE.UNKNOWN,\n dataFetchMapKey\n };\n};\nconst DefaultLoading = /* @__PURE__ */ React__default.createElement(React__default.Fragment, null);\nconst DefaultErrorElement = (_data) => /* @__PURE__ */ React__default.createElement("div", null, "Error");\nfunction AwaitDataFetch({\n resolve,\n loading = DefaultLoading,\n errorElement = DefaultErrorElement,\n children,\n params,\n delayLoading\n}) {\n const dataRef = useRef();\n const data = dataRef.current || resolve;\n const getData = isPromise(data) ? fetchData(data, dataRef) : () => data;\n return /* @__PURE__ */ React__default.createElement(\n AwaitSuspense,\n {\n params,\n loading,\n errorElement,\n delayLoading,\n resolve: getData\n },\n children\n );\n}\nconst DelayedLoading = ({\n delayLoading,\n children\n}) => {\n const [show, setShow] = useState(false);\n const timerSet = useRef(false);\n if (!delayLoading) {\n return children;\n }\n if (typeof window !== "undefined" && !show && !timerSet.current) {\n timerSet.current = true;\n setTimeout(() => {\n setShow(true);\n }, delayLoading);\n }\n return show ? children : null;\n};\nfunction AwaitSuspense({\n resolve,\n children,\n loading = DefaultLoading,\n errorElement = DefaultErrorElement,\n delayLoading\n}) {\n return /* @__PURE__ */ React__default.createElement(\n Suspense,\n {\n fallback: /* @__PURE__ */ React__default.createElement(DelayedLoading, { delayLoading }, loading)\n },\n /* @__PURE__ */ React__default.createElement(ResolveAwait, { resolve, errorElement }, children)\n );\n}\nfunction ResolveAwait({\n children,\n resolve,\n errorElement,\n params\n}) {\n const data = resolve();\n logger.debug("resolve data: ", data);\n if (typeof data === "string" && data.indexOf(AWAIT_ERROR_PREFIX) === 0) {\n const transformedError = transformError(data);\n return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, typeof errorElement === "function" ? /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, globalThis.FEDERATION_SSR && /* @__PURE__ */ React__default.createElement(\n "script",\n {\n suppressHydrationWarning: true,\n dangerouslySetInnerHTML: {\n __html: String.raw`\n globalThis[\'${DATA_FETCH_FUNCTION}\'] = globalThis[\'${DATA_FETCH_FUNCTION}\'] || []\n globalThis[\'${DATA_FETCH_FUNCTION}\'].push([${transformedError.dataFetchMapKey ? `\'${transformedError.dataFetchMapKey}\'` : ""},${params ? JSON.stringify(params) : null},true]);`\n }\n }\n ), errorElement(transformedError)) : errorElement);\n }\n const toRender = typeof children === "function" ? children(data) : children;\n return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, toRender);\n}\nconst fetchData = (promise, ref) => {\n let data;\n let status = "pending";\n const suspender = promise.then((res) => {\n status = "success";\n data = res;\n ref.current = res;\n }).catch((e) => {\n status = "success";\n console.warn(e);\n data = AWAIT_ERROR_PREFIX + e;\n });\n return () => {\n if (status === "pending") {\n throw suspender;\n }\n return data;\n };\n};\nfunction getTargetModuleInfo(id, instance) {\n if (!instance) {\n return;\n }\n const loadedRemoteInfo = getLoadedRemoteInfos(id, instance);\n if (!loadedRemoteInfo) {\n return;\n }\n const { snapshot } = loadedRemoteInfo;\n if (!snapshot) {\n return;\n }\n const publicPath = "publicPath" in snapshot ? snapshot.publicPath : "getPublicPath" in snapshot ? new Function(snapshot.getPublicPath)() : "";\n if (!publicPath) {\n return;\n }\n const modules = "modules" in snapshot ? snapshot.modules : [];\n const targetModule = modules.find(\n (m) => m.modulePath === loadedRemoteInfo.expose\n );\n if (!targetModule) {\n return;\n }\n const remoteEntry = "remoteEntry" in snapshot ? snapshot.remoteEntry : "";\n if (!remoteEntry) {\n return;\n }\n return {\n module: targetModule,\n publicPath,\n remoteEntry\n };\n}\nfunction collectSSRAssets(options) {\n const {\n id,\n injectLink = true,\n injectScript = false\n } = typeof options === "string" ? { id: options } : options;\n const links = [];\n const scripts = [];\n const instance = options.instance;\n if (!instance || !injectLink && !injectScript) {\n return [...scripts, ...links];\n }\n const moduleAndPublicPath = getTargetModuleInfo(id, instance);\n if (!moduleAndPublicPath) {\n return [...scripts, ...links];\n }\n const { module: targetModule, publicPath, remoteEntry } = moduleAndPublicPath;\n if (injectLink) {\n [...targetModule.assets.css.sync, ...targetModule.assets.css.async].sort().forEach((file, index) => {\n links.push(\n /* @__PURE__ */ React__default.createElement(\n "link",\n {\n key: `${file.split(".")[0]}_${index}`,\n href: `${publicPath}${file}`,\n rel: "stylesheet",\n type: "text/css"\n }\n )\n );\n });\n }\n if (injectScript) {\n scripts.push(\n /* @__PURE__ */ React__default.createElement(\n "script",\n {\n async: true,\n key: remoteEntry.split(".")[0],\n src: `${publicPath}${remoteEntry}`,\n crossOrigin: "anonymous"\n }\n )\n );\n [...targetModule.assets.js.sync].sort().forEach((file, index) => {\n scripts.push(\n /* @__PURE__ */ React__default.createElement(\n "script",\n {\n key: `${file.split(".")[0]}_${index}`,\n async: true,\n src: `${publicPath}${file}`,\n crossOrigin: "anonymous"\n }\n )\n );\n });\n }\n return [...scripts, ...links];\n}\nfunction getServerNeedRemoteInfo(loadedRemoteInfo, id, noSSR) {\n var _a;\n if (noSSR || typeof window !== "undefined" && window.location.href !== window[FS_HREF]) {\n if (!(loadedRemoteInfo == null ? void 0 : loadedRemoteInfo.version)) {\n throw new Error(`${loadedRemoteInfo == null ? void 0 : loadedRemoteInfo.name} version is empty`);\n }\n const { snapshot } = loadedRemoteInfo;\n if (!snapshot) {\n throw new Error(`${loadedRemoteInfo == null ? void 0 : loadedRemoteInfo.name} snapshot is empty`);\n }\n const dataFetchItem = getDataFetchItem(id);\n const isFetchServer = ((_a = dataFetchItem == null ? void 0 : dataFetchItem[0]) == null ? void 0 : _a[1]) === MF_DATA_FETCH_TYPE.FETCH_SERVER;\n if (isFetchServer && (!("ssrPublicPath" in snapshot) || !snapshot.ssrPublicPath)) {\n throw new Error(\n `ssrPublicPath is required while fetching ${loadedRemoteInfo == null ? void 0 : loadedRemoteInfo.name} data in SSR project!`\n );\n }\n if (isFetchServer && (!("ssrRemoteEntry" in snapshot) || !snapshot.ssrRemoteEntry)) {\n throw new Error(\n `ssrRemoteEntry is required while loading ${loadedRemoteInfo == null ? void 0 : loadedRemoteInfo.name} data loader in SSR project!`\n );\n }\n return {\n name: loadedRemoteInfo.name,\n version: loadedRemoteInfo.version,\n ssrPublicPath: "ssrPublicPath" in snapshot ? snapshot.ssrPublicPath || "" : "",\n ssrRemoteEntry: "ssrRemoteEntry" in snapshot ? snapshot.ssrRemoteEntry || "" : "",\n globalName: loadedRemoteInfo.entryGlobalName\n };\n }\n return void 0;\n}\nfunction createLazyComponent(options) {\n const { instance, injectScript, injectLink } = options;\n if (!instance) {\n throw new Error("instance is required for createLazyComponent!");\n }\n const exportName = (options == null ? void 0 : options.export) || "default";\n const callLoader = async () => {\n logger.debug("callLoader start", Date.now());\n const m = await options.loader();\n logger.debug("callLoader end", Date.now());\n if (!m) {\n throw new Error("load remote failed");\n }\n return m;\n };\n const getData = async (noSSR) => {\n let loadedRemoteInfo;\n let moduleId;\n try {\n const m = await callLoader();\n moduleId = m && m[Symbol.for("mf_module_id")];\n if (!moduleId) {\n throw new Error("moduleId is empty");\n }\n loadedRemoteInfo = getLoadedRemoteInfos(moduleId, instance);\n if (!loadedRemoteInfo) {\n throw new Error(`can not find loaded remote(\'${moduleId}\') info!`);\n }\n } catch (e) {\n const errMsg = `${LOAD_REMOTE_ERROR_PREFIX}${e}`;\n logger.debug(e);\n throw new Error(errMsg);\n }\n let dataFetchMapKey;\n try {\n dataFetchMapKey = getDataFetchMapKey(\n getDataFetchInfo({\n name: loadedRemoteInfo.name,\n alias: loadedRemoteInfo.alias,\n id: moduleId,\n remoteSnapshot: loadedRemoteInfo.snapshot\n }),\n { name: instance.name, version: instance.options.version }\n );\n logger.debug("getData dataFetchMapKey: ", dataFetchMapKey);\n if (!dataFetchMapKey) {\n return;\n }\n const data = await fetchData$1(\n dataFetchMapKey,\n {\n ...options.dataFetchParams,\n isDowngrade: false\n },\n getServerNeedRemoteInfo(loadedRemoteInfo, dataFetchMapKey, noSSR)\n );\n setDataFetchItemLoadedStatus(dataFetchMapKey);\n logger.debug("get data res: \\n", data);\n return data;\n } catch (err) {\n const errMsg = `${DATA_FETCH_ERROR_PREFIX}${wrapDataFetchId(dataFetchMapKey)}${err}`;\n logger.debug(errMsg);\n throw new Error(errMsg);\n }\n };\n const LazyComponent = React__default.lazy(async () => {\n const m = await callLoader();\n const moduleId = m && m[Symbol.for("mf_module_id")];\n const loadedRemoteInfo = getLoadedRemoteInfos(moduleId, instance);\n loadedRemoteInfo == null ? void 0 : loadedRemoteInfo.snapshot;\n const dataFetchMapKey = loadedRemoteInfo ? getDataFetchMapKey(\n getDataFetchInfo({\n name: loadedRemoteInfo.name,\n alias: loadedRemoteInfo.alias,\n id: moduleId,\n remoteSnapshot: loadedRemoteInfo.snapshot\n }),\n { name: instance.name, version: instance == null ? void 0 : instance.options.version }\n ) : void 0;\n logger.debug("LazyComponent dataFetchMapKey: ", dataFetchMapKey);\n const assets = collectSSRAssets({\n id: moduleId,\n instance,\n injectLink,\n injectScript\n });\n const Com = m[exportName];\n if (exportName in m && typeof Com === "function") {\n return {\n default: (props) => /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, globalThis.FEDERATION_SSR && dataFetchMapKey && /* @__PURE__ */ React__default.createElement(\n "script",\n {\n suppressHydrationWarning: true,\n dangerouslySetInnerHTML: {\n __html: String.raw`\n globalThis[\'${DATA_FETCH_FUNCTION}\'] = globalThis[\'${DATA_FETCH_FUNCTION}\'] || [];\n globalThis[\'${DATA_FETCH_FUNCTION}\'].push([\'${dataFetchMapKey}\',${JSON.stringify(props.mfData)}]);\n `\n }\n }\n ), globalThis.FEDERATION_SSR && assets, /* @__PURE__ */ React__default.createElement(Com, { ...props }))\n };\n } else {\n throw Error(\n `Make sure that ${moduleId} has the correct export when export is ${String(\n exportName\n )}`\n );\n }\n });\n return (props) => {\n const { key, ...args } = props;\n if (!options.noSSR) {\n return /* @__PURE__ */ React__default.createElement(\n AwaitDataFetch,\n {\n resolve: getData(options.noSSR),\n loading: options.loading,\n delayLoading: options.delayLoading,\n errorElement: options.fallback\n },\n (data) => /* @__PURE__ */ React__default.createElement(LazyComponent, { ...args, mfData: data })\n );\n } else {\n const [data, setData] = useState(null);\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState(null);\n useEffect(() => {\n let isMounted = true;\n const fetchDataAsync = async () => {\n try {\n setLoading(true);\n const result = await getData(options.noSSR);\n if (isMounted) {\n setData(result);\n }\n } catch (e) {\n if (isMounted) {\n setError(transformError(e));\n }\n } finally {\n if (isMounted) {\n setLoading(false);\n }\n }\n };\n fetchDataAsync();\n return () => {\n isMounted = false;\n };\n }, []);\n if (loading) {\n return /* @__PURE__ */ React__default.createElement(DelayedLoading, { delayLoading: options.delayLoading }, options.loading);\n }\n if (error) {\n return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, typeof options.fallback === "function" ? options.fallback(error) : options.fallback);\n }\n return /* @__PURE__ */ React__default.createElement(LazyComponent, { ...args, mfData: data });\n }\n };\n}\nfunction lazyLoadComponentPlugin() {\n return {\n name: "lazy-load-component-plugin",\n apply(instance) {\n instance.registerPlugins([autoFetchData()]);\n instance.createLazyComponent = (options) => {\n return createLazyComponent({\n instance,\n ...options\n });\n };\n instance.prefetch = (options) => {\n return prefetch({\n instance,\n ...options\n });\n };\n instance.collectSSRAssets = (options) => {\n return collectSSRAssets({\n instance,\n ...options\n });\n };\n }\n };\n}\nexport {\n autoFetchData as a,\n createLazyComponent as b,\n collectSSRAssets as c,\n lazyLoadComponentPlugin as l\n};\n',
155
155
  "logger-DwWkXsWl.mjs": "const MANIFEST_EXT = \".json\";\nconst BROWSER_LOG_KEY = \"FEDERATION_DEBUG\";\nconst SEPARATOR = \":\";\nconst isBrowserEnvValue = typeof ENV_TARGET !== \"undefined\" ? ENV_TARGET === \"web\" : typeof window !== \"undefined\" && typeof window.document !== \"undefined\";\nfunction isBrowserEnv() {\n return isBrowserEnvValue;\n}\nfunction isBrowserDebug() {\n try {\n if (isBrowserEnv() && window.localStorage) return Boolean(localStorage.getItem(BROWSER_LOG_KEY));\n } catch (error) {\n return false;\n }\n return false;\n}\nfunction isDebugMode() {\n if (typeof process !== \"undefined\" && process.env && process.env[\"FEDERATION_DEBUG\"]) return Boolean(process.env[\"FEDERATION_DEBUG\"]);\n if (typeof FEDERATION_DEBUG !== \"undefined\" && Boolean(FEDERATION_DEBUG)) return true;\n return isBrowserDebug();\n}\nconst PREFIX = \"[ Module Federation ]\";\nconst DEFAULT_DELEGATE = console;\nconst LOGGER_STACK_SKIP_TOKENS = [\n \"logger.ts\",\n \"logger.js\",\n \"captureStackTrace\",\n \"Logger.emit\",\n \"Logger.log\",\n \"Logger.info\",\n \"Logger.warn\",\n \"Logger.error\",\n \"Logger.debug\"\n];\nfunction captureStackTrace() {\n try {\n const stack = (/* @__PURE__ */ new Error()).stack;\n if (!stack) return;\n const [, ...rawLines] = stack.split(\"\\n\");\n const filtered = rawLines.filter((line) => !LOGGER_STACK_SKIP_TOKENS.some((token) => line.includes(token)));\n if (!filtered.length) return;\n return `Stack trace:\n${filtered.slice(0, 5).join(\"\\n\")}`;\n } catch {\n return;\n }\n}\nvar Logger = class {\n constructor(prefix, delegate = DEFAULT_DELEGATE) {\n this.prefix = prefix;\n this.delegate = delegate ?? DEFAULT_DELEGATE;\n }\n setPrefix(prefix) {\n this.prefix = prefix;\n }\n setDelegate(delegate) {\n this.delegate = delegate ?? DEFAULT_DELEGATE;\n }\n emit(method, args) {\n const delegate = this.delegate;\n const stackTrace = isDebugMode() ? captureStackTrace() : void 0;\n const enrichedArgs = stackTrace ? [...args, stackTrace] : args;\n const order = (() => {\n switch (method) {\n case \"log\":\n return [\"log\", \"info\"];\n case \"info\":\n return [\"info\", \"log\"];\n case \"warn\":\n return [\n \"warn\",\n \"info\",\n \"log\"\n ];\n case \"error\":\n return [\n \"error\",\n \"warn\",\n \"log\"\n ];\n default:\n return [\"debug\", \"log\"];\n }\n })();\n for (const candidate of order) {\n const handler = delegate[candidate];\n if (typeof handler === \"function\") {\n handler.call(delegate, this.prefix, ...enrichedArgs);\n return;\n }\n }\n for (const candidate of order) {\n const handler = DEFAULT_DELEGATE[candidate];\n if (typeof handler === \"function\") {\n handler.call(DEFAULT_DELEGATE, this.prefix, ...enrichedArgs);\n return;\n }\n }\n }\n log(...args) {\n this.emit(\"log\", args);\n }\n warn(...args) {\n this.emit(\"warn\", args);\n }\n error(...args) {\n this.emit(\"error\", args);\n }\n success(...args) {\n this.emit(\"info\", args);\n }\n info(...args) {\n this.emit(\"info\", args);\n }\n ready(...args) {\n this.emit(\"info\", args);\n }\n debug(...args) {\n if (isDebugMode()) this.emit(\"debug\", args);\n }\n};\nfunction createLogger(prefix) {\n return new Logger(prefix);\n}\nfunction createInfrastructureLogger(prefix) {\n const infrastructureLogger = new Logger(prefix);\n Object.defineProperty(infrastructureLogger, \"__mf_infrastructure_logger__\", {\n value: true,\n enumerable: false,\n configurable: false\n });\n return infrastructureLogger;\n}\ncreateInfrastructureLogger(PREFIX);\nexport {\n MANIFEST_EXT as M,\n SEPARATOR as S,\n createLogger as c,\n isBrowserEnvValue as i\n};\n",
156
156
  "plugin.es.js": "const federationRuntime = { instance: null };\nfunction BridgeReactPlugin() {\n return {\n name: \"bridge-react-plugin\",\n beforeInit(args) {\n federationRuntime.instance = args.origin;\n return args;\n }\n };\n}\nexport {\n BridgeReactPlugin as default,\n federationRuntime\n};\n",
157
- "prefetch-CTZuFBqh.mjs": 'import { B as warn, y as DATA_FETCH_FUNCTION, F as FS_HREF, l as logger, e as getDataFetchMap, i as initDataFetchMap, o as getDataFetchItem, M as MF_DATA_FETCH_STATUS, q as MF_DATA_FETCH_TYPE, G as DOWNGRADE_KEY, H as callAllDowngrade, I as callDowngrade, J as getDowngradeTag, K as composeKeyWithSeparator, N as safeToString, m as getDataFetchInfo, n as getDataFetchMapKey } from "./utils-BBP3hEeV.mjs";\nimport { i as isBrowserEnvValue } from "./logger-DwWkXsWl.mjs";\nasync function safeWrapper(callback, disableWarn) {\n try {\n return await callback();\n } catch (e) {\n warn(e);\n return;\n }\n}\nfunction isStaticResourcesEqual(url1, url2) {\n const REG_EXP = /^(https?:)?\\/\\//i;\n return url1.replace(REG_EXP, "").replace(/\\/$/, "") === url2.replace(REG_EXP, "").replace(/\\/$/, "");\n}\nfunction createScript(info) {\n let script = null;\n let needAttach = true;\n let timeout = 2e4;\n let timeoutId;\n const scripts = document.getElementsByTagName("script");\n for (let i = 0; i < scripts.length; i++) {\n const s = scripts[i];\n const scriptSrc = s.getAttribute("src");\n if (scriptSrc && isStaticResourcesEqual(scriptSrc, info.url)) {\n script = s;\n needAttach = false;\n break;\n }\n }\n if (!script) {\n const attrs = info.attrs;\n script = document.createElement("script");\n script.type = (attrs == null ? void 0 : attrs["type"]) === "module" ? "module" : "text/javascript";\n let createScriptRes = void 0;\n if (info.createScriptHook) {\n createScriptRes = info.createScriptHook(info.url, info.attrs);\n if (createScriptRes instanceof HTMLScriptElement) script = createScriptRes;\n else if (typeof createScriptRes === "object") {\n if ("script" in createScriptRes && createScriptRes.script) script = createScriptRes.script;\n if ("timeout" in createScriptRes && createScriptRes.timeout) timeout = createScriptRes.timeout;\n }\n }\n if (!script.src) script.src = info.url;\n if (attrs && !createScriptRes) Object.keys(attrs).forEach((name) => {\n if (script) {\n if (name === "async" || name === "defer") script[name] = attrs[name];\n else if (!script.getAttribute(name)) script.setAttribute(name, attrs[name]);\n }\n });\n }\n let executionError = null;\n const executionErrorHandler = typeof window !== "undefined" ? (evt) => {\n if (evt.filename && isStaticResourcesEqual(evt.filename, info.url)) {\n const err = /* @__PURE__ */ new Error(`ScriptExecutionError: Script "${info.url}" loaded but threw a runtime error during execution: ${evt.message} (${evt.filename}:${evt.lineno}:${evt.colno})`);\n err.name = "ScriptExecutionError";\n executionError = err;\n }\n } : null;\n if (executionErrorHandler) window.addEventListener("error", executionErrorHandler);\n const onScriptComplete = async (prev, event) => {\n clearTimeout(timeoutId);\n if (executionErrorHandler) window.removeEventListener("error", executionErrorHandler);\n const onScriptCompleteCallback = () => {\n if ((event == null ? void 0 : event.type) === "error") {\n const networkError = /* @__PURE__ */ new Error((event == null ? void 0 : event.isTimeout) ? `ScriptNetworkError: Script "${info.url}" timed out.` : `ScriptNetworkError: Failed to load script "${info.url}" - the script URL is unreachable or the server returned an error (network failure, 404, CORS, etc.)`);\n networkError.name = "ScriptNetworkError";\n (info == null ? void 0 : info.onErrorCallback) && (info == null ? void 0 : info.onErrorCallback(networkError));\n } else if (executionError) (info == null ? void 0 : info.onErrorCallback) && (info == null ? void 0 : info.onErrorCallback(executionError));\n else (info == null ? void 0 : info.cb) && (info == null ? void 0 : info.cb());\n };\n if (script) {\n script.onerror = null;\n script.onload = null;\n safeWrapper(() => {\n const { needDeleteScript = true } = info;\n if (needDeleteScript) (script == null ? void 0 : script.parentNode) && script.parentNode.removeChild(script);\n });\n if (prev && typeof prev === "function") {\n const result = prev(event);\n if (result instanceof Promise) {\n const res = await result;\n onScriptCompleteCallback();\n return res;\n }\n onScriptCompleteCallback();\n return result;\n }\n }\n onScriptCompleteCallback();\n };\n script.onerror = onScriptComplete.bind(null, script.onerror);\n script.onload = onScriptComplete.bind(null, script.onload);\n timeoutId = setTimeout(() => {\n onScriptComplete(null, {\n type: "error",\n isTimeout: true\n });\n }, timeout);\n return {\n script,\n needAttach\n };\n}\nfunction createLink(info) {\n let link = null;\n let needAttach = true;\n let timeout = 2e4;\n let timeoutId;\n const links = document.getElementsByTagName("link");\n for (let i = 0; i < links.length; i++) {\n const l = links[i];\n const linkHref = l.getAttribute("href");\n const linkRel = l.getAttribute("rel");\n if (linkHref && isStaticResourcesEqual(linkHref, info.url) && linkRel === info.attrs["rel"]) {\n link = l;\n needAttach = false;\n break;\n }\n }\n if (!link) {\n link = document.createElement("link");\n link.setAttribute("href", info.url);\n let createLinkRes = void 0;\n let shouldApplyAttrs = true;\n const attrs = info.attrs;\n if (info.createLinkHook) {\n createLinkRes = info.createLinkHook(info.url, attrs);\n if (createLinkRes instanceof HTMLLinkElement) {\n link = createLinkRes;\n shouldApplyAttrs = false;\n } else if (typeof createLinkRes === "object") {\n if ("link" in createLinkRes && createLinkRes.link) {\n link = createLinkRes.link;\n shouldApplyAttrs = false;\n }\n if ("timeout" in createLinkRes && createLinkRes.timeout) timeout = createLinkRes.timeout;\n }\n }\n if (attrs && shouldApplyAttrs) Object.keys(attrs).forEach((name) => {\n if (link && !link.getAttribute(name)) link.setAttribute(name, attrs[name]);\n });\n }\n if (!needAttach) {\n Promise.resolve().then(() => {\n (info == null ? void 0 : info.cb) && (info == null ? void 0 : info.cb());\n });\n return {\n link,\n needAttach\n };\n }\n const onLinkComplete = (prev, event) => {\n if (timeoutId) clearTimeout(timeoutId);\n const onLinkCompleteCallback = () => {\n if ((event == null ? void 0 : event.type) === "error") {\n const linkError = /* @__PURE__ */ new Error((event == null ? void 0 : event.isTimeout) ? `LinkNetworkError: Link "${info.url}" timed out.` : `LinkNetworkError: Failed to load link "${info.url}" - the URL is unreachable or the server returned an error.`);\n linkError.name = "LinkNetworkError";\n (info == null ? void 0 : info.onErrorCallback) && (info == null ? void 0 : info.onErrorCallback(linkError));\n } else (info == null ? void 0 : info.cb) && (info == null ? void 0 : info.cb());\n };\n if (link) {\n link.onerror = null;\n link.onload = null;\n safeWrapper(() => {\n const { needDeleteLink = true } = info;\n if (needDeleteLink) (link == null ? void 0 : link.parentNode) && link.parentNode.removeChild(link);\n });\n if (prev) {\n const res = prev(event);\n onLinkCompleteCallback();\n return res;\n }\n }\n onLinkCompleteCallback();\n };\n link.onerror = onLinkComplete.bind(null, link.onerror);\n link.onload = onLinkComplete.bind(null, link.onload);\n timeoutId = setTimeout(() => {\n onLinkComplete(null, {\n type: "error",\n isTimeout: true\n });\n }, timeout);\n return {\n link,\n needAttach\n };\n}\nfunction loadScript(url, info) {\n const { attrs = {}, createScriptHook } = info;\n return new Promise((resolve, reject) => {\n const { script, needAttach } = createScript({\n url,\n cb: resolve,\n onErrorCallback: reject,\n attrs: {\n fetchpriority: "high",\n ...attrs\n },\n createScriptHook,\n needDeleteScript: true\n });\n needAttach && document.head.appendChild(script);\n });\n}\nconst sdkImportCache = /* @__PURE__ */ new Map();\nfunction importNodeModule(name) {\n if (!name) throw new Error("import specifier is required");\n if (sdkImportCache.has(name)) return sdkImportCache.get(name);\n const promise = new Function("name", `return import(name)`)(name).then((res) => res).catch((error2) => {\n console.error(`Error importing module ${name}:`, error2);\n sdkImportCache.delete(name);\n throw error2;\n });\n sdkImportCache.set(name, promise);\n return promise;\n}\nconst lazyLoaderHookFetch = async (input, init, loaderHook) => {\n const hook = (url, init2) => {\n return loaderHook.lifecycle.fetch.emit(url, init2);\n };\n const res = await hook(input, init || {});\n if (!res || !(res instanceof Response)) return fetch(input, init || {});\n return res;\n};\nconst createScriptNode = typeof ENV_TARGET === "undefined" || ENV_TARGET !== "web" ? (url, cb, attrs, loaderHook) => {\n if (loaderHook == null ? void 0 : loaderHook.createScriptHook) {\n const hookResult = loaderHook.createScriptHook(url);\n if (hookResult && typeof hookResult === "object" && "url" in hookResult) url = hookResult.url;\n }\n let urlObj;\n try {\n urlObj = new URL(url);\n } catch (e) {\n console.error("Error constructing URL:", e);\n cb(/* @__PURE__ */ new Error(`Invalid URL: ${e}`));\n return;\n }\n const getFetch = async () => {\n if (loaderHook == null ? void 0 : loaderHook.fetch) return (input, init) => lazyLoaderHookFetch(input, init, loaderHook);\n return fetch;\n };\n const handleScriptFetch = async (f, urlObj2) => {\n var _a;\n try {\n const res = await f(urlObj2.href);\n const data = await res.text();\n const [path, vm] = await Promise.all([importNodeModule("path"), importNodeModule("vm")]);\n const scriptContext = {\n exports: {},\n module: { exports: {} }\n };\n const urlDirname = urlObj2.pathname.split("/").slice(0, -1).join("/");\n const filename = path.basename(urlObj2.pathname);\n const script = new vm.Script(`(function(exports, module, require, __dirname, __filename) {${data}\n})`, {\n filename,\n importModuleDynamically: ((_a = vm.constants) == null ? void 0 : _a.USE_MAIN_CONTEXT_DEFAULT_LOADER) ?? importNodeModule\n });\n let requireFn;\n requireFn = (await importNodeModule("node:module")).createRequire(urlObj2.protocol === "file:" || urlObj2.protocol === "node:" ? urlObj2.href : path.join(process.cwd(), "__mf_require_base__.js"));\n script.runInThisContext()(scriptContext.exports, scriptContext.module, requireFn, urlDirname, filename);\n const exportedInterface = scriptContext.module.exports || scriptContext.exports;\n if (attrs && exportedInterface && attrs["globalName"]) {\n cb(void 0, exportedInterface[attrs["globalName"]] || exportedInterface);\n return;\n }\n cb(void 0, exportedInterface);\n } catch (e) {\n cb(e instanceof Error ? e : /* @__PURE__ */ new Error(`Script execution error: ${e}`));\n }\n };\n getFetch().then(async (f) => {\n if ((attrs == null ? void 0 : attrs["type"]) === "esm" || (attrs == null ? void 0 : attrs["type"]) === "module") return loadModule(urlObj.href, {\n fetch: f,\n vm: await importNodeModule("vm")\n }).then(async (module) => {\n await module.evaluate();\n cb(void 0, module.namespace);\n }).catch((e) => {\n cb(e instanceof Error ? e : /* @__PURE__ */ new Error(`Script execution error: ${e}`));\n });\n handleScriptFetch(f, urlObj);\n }).catch((err) => {\n cb(err);\n });\n} : (url, cb, attrs, loaderHook) => {\n cb(/* @__PURE__ */ new Error("createScriptNode is disabled in non-Node.js environment"));\n};\nconst loadScriptNode = typeof ENV_TARGET === "undefined" || ENV_TARGET !== "web" ? (url, info) => {\n return new Promise((resolve, reject) => {\n createScriptNode(url, (error2, scriptContext) => {\n var _a, _b;\n if (error2) reject(error2);\n else {\n const remoteEntryKey = ((_a = info == null ? void 0 : info.attrs) == null ? void 0 : _a["globalName"]) || `__FEDERATION_${(_b = info == null ? void 0 : info.attrs) == null ? void 0 : _b["name"]}:custom__`;\n resolve(globalThis[remoteEntryKey] = scriptContext);\n }\n }, info.attrs, info.loaderHook);\n });\n} : (url, info) => {\n throw new Error("loadScriptNode is disabled in non-Node.js environment");\n};\nconst esmModuleCache = /* @__PURE__ */ new Map();\nconst isFetchableRemoteModuleUrl = (url) => url.startsWith("http:") || url.startsWith("https:");\nconst isBareModuleSpecifier = (specifier) => !specifier.startsWith("./") && !specifier.startsWith("../") && !specifier.startsWith("/") && !specifier.includes(":");\nfunction encodeRemoteModulePath(url) {\n const remoteUrl = new URL(url);\n const encodedProtocol = encodeURIComponent(remoteUrl.protocol.slice(0, -1));\n const encodedHost = encodeURIComponent(remoteUrl.host);\n const encodedPathname = remoteUrl.pathname.split("/").map((segment) => encodeURIComponent(segment)).join("/");\n const encodedSearchHash = encodeURIComponent(`${remoteUrl.search}${remoteUrl.hash}`);\n return `/${encodedProtocol}/${encodedHost}${encodedPathname}${encodedSearchHash ? `/${encodedSearchHash}` : ""}`;\n}\nfunction createImportMetaUrl(url, baseFileUrl) {\n const baseUrl = baseFileUrl.endsWith("/") ? baseFileUrl : `${baseFileUrl}/`;\n return new URL(`__module_federation_remote__${encodeRemoteModulePath(url)}`, baseUrl).href;\n}\nasync function isNodeBuiltinSpecifier(specifier) {\n if (specifier.startsWith("node:")) return true;\n if (!isBareModuleSpecifier(specifier)) return false;\n return (await importNodeModule("node:module")).builtinModules.includes(specifier);\n}\nfunction getSyntheticModuleExports(moduleExports) {\n const namespaceObject = moduleExports && (typeof moduleExports === "object" || typeof moduleExports === "function") ? moduleExports : { default: moduleExports };\n const effectiveExports = { ...namespaceObject };\n if (!Object.prototype.hasOwnProperty.call(effectiveExports, "default")) effectiveExports.default = namespaceObject;\n return effectiveExports;\n}\nasync function createSyntheticModuleFromExports(identifier, moduleExports, vm) {\n if (typeof vm.SyntheticModule !== "function") throw new Error("vm.SyntheticModule is required to load Node.js built-in modules in ESM remote entries.");\n const effectiveExports = getSyntheticModuleExports(moduleExports);\n const exportNames = Object.keys(effectiveExports);\n const syntheticModule = new vm.SyntheticModule(exportNames, function setSyntheticModuleExports() {\n for (const name of exportNames) this.setExport(name, effectiveExports[name]);\n }, { identifier });\n esmModuleCache.set(identifier, syntheticModule);\n await syntheticModule.link(async () => {\n throw new Error(`Node.js built-in module "${identifier}" should not request child modules.`);\n });\n await syntheticModule.evaluate();\n return syntheticModule;\n}\nasync function loadNodeBuiltinModule(specifier, vm) {\n const cacheKey = `node-builtin:${specifier}`;\n if (esmModuleCache.has(cacheKey)) return esmModuleCache.get(cacheKey);\n return createSyntheticModuleFromExports(cacheKey, await importNodeModule(specifier), vm);\n}\nasync function loadResolvedModule(specifier, parentUrl, options) {\n if (await isNodeBuiltinSpecifier(specifier)) return loadNodeBuiltinModule(specifier, options.vm);\n if (isBareModuleSpecifier(specifier)) throw new Error(`Unsupported ESM module specifier "${specifier}". Only relative or absolute http(s) remote modules and Node.js built-in modules are supported.`);\n const resolvedUrl = new URL(specifier, parentUrl).href;\n if (!isFetchableRemoteModuleUrl(resolvedUrl)) throw new Error(`Unsupported ESM module specifier "${specifier}" resolved to "${resolvedUrl}". Only http(s) remote modules and Node.js built-in modules are supported.`);\n return loadModule(resolvedUrl, options);\n}\nasync function evaluateDynamicModule(module) {\n if (module.status === "linked") await module.evaluate();\n if (module.status === "errored") throw module.error;\n return module;\n}\nasync function loadModule(url, options) {\n if (esmModuleCache.has(url)) return esmModuleCache.get(url);\n const { fetch: fetch2, vm } = options;\n if (!isFetchableRemoteModuleUrl(url)) throw new Error(`Unsupported ESM module URL "${url}". Only http(s) remote modules and Node.js built-in modules are supported.`);\n const code = await (await fetch2(url)).text();\n const cwdFileUrl = (await importNodeModule("node:url")).pathToFileURL(process.cwd()).href;\n const sourceTextModule = new vm.SourceTextModule(code, {\n identifier: url,\n initializeImportMeta: (meta) => {\n meta.url = createImportMetaUrl(url, cwdFileUrl);\n },\n importModuleDynamically: async (specifier) => {\n return evaluateDynamicModule(await loadResolvedModule(specifier, url, options));\n }\n });\n esmModuleCache.set(url, sourceTextModule);\n await sourceTextModule.link(async (specifier) => {\n return loadResolvedModule(specifier, url, options);\n });\n return sourceTextModule;\n}\nconst dataFetchFunction = async function(options) {\n var _a, _b;\n const [id, data, downgrade] = options;\n logger.debug("==========call data fetch function!");\n if (data) {\n if (!id) {\n throw new Error("id is required!");\n }\n if (!getDataFetchMap()) {\n initDataFetchMap();\n }\n const dataFetchItem = getDataFetchItem(id);\n if (dataFetchItem) {\n (_b = (_a = dataFetchItem[1]) == null ? void 0 : _a[1]) == null ? void 0 : _b.call(_a, data);\n dataFetchItem[2] = MF_DATA_FETCH_STATUS.LOADED;\n return;\n }\n if (!dataFetchItem) {\n const dataFetchMap = getDataFetchMap();\n let res;\n let rej;\n const p = new Promise((resolve, reject) => {\n res = resolve;\n rej = reject;\n });\n dataFetchMap[id] = [\n [\n async () => async () => {\n return "";\n },\n MF_DATA_FETCH_TYPE.FETCH_SERVER\n ],\n [p, res, rej],\n MF_DATA_FETCH_STATUS.LOADED\n ];\n res && res(data);\n return;\n }\n }\n if (downgrade) {\n const mfDowngrade2 = getDowngradeTag();\n if (!mfDowngrade2) {\n globalThis[DOWNGRADE_KEY] = id ? [id] : true;\n } else if (Array.isArray(mfDowngrade2) && id && !mfDowngrade2.includes(id)) {\n mfDowngrade2.push(id);\n }\n }\n const mfDowngrade = getDowngradeTag();\n if (typeof mfDowngrade === "boolean") {\n return callAllDowngrade();\n }\n if (Array.isArray(mfDowngrade)) {\n if (!id) {\n globalThis[DOWNGRADE_KEY] = true;\n return callAllDowngrade();\n }\n if (!mfDowngrade.includes(id)) {\n mfDowngrade.push(id);\n }\n return callDowngrade(id);\n }\n};\nfunction injectDataFetch() {\n var _a;\n globalThis[_a = DATA_FETCH_FUNCTION] || (globalThis[_a] = []);\n const dataFetch = globalThis[DATA_FETCH_FUNCTION];\n if (dataFetch.push === dataFetchFunction) {\n return;\n }\n if (typeof window === "undefined") {\n return;\n }\n globalThis[FS_HREF] = window.location.href;\n dataFetch.push = dataFetchFunction;\n}\nconst getDocsUrl = (errorCode) => {\n return `View the docs to see how to solve: https://module-federation.io/guide/troubleshooting/${errorCode.split("-")[0].toLowerCase()}#${errorCode.toLowerCase()}`;\n};\nconst getShortErrorMsg = (errorCode, errorDescMap, args, originalErrorMsg) => {\n const msg = [`${[errorDescMap[errorCode]]} #${errorCode}`];\n args && msg.push(`args: ${JSON.stringify(args)}`);\n msg.push(getDocsUrl(errorCode));\n originalErrorMsg && msg.push(`Original Error Message:\n ${originalErrorMsg}`);\n return msg.join("\\n");\n};\nfunction logAndReport(code, descMap, args, logger2, originalErrorMsg, context) {\n return logger2(getShortErrorMsg(code, descMap, args, originalErrorMsg));\n}\nconst LOG_CATEGORY = "[ Federation Runtime ]";\nfunction assert(condition, msgOrCode, descMap, args, context) {\n if (!condition) error(msgOrCode);\n}\nfunction error(msgOrCode, descMap, args, originalErrorMsg, context) {\n if (descMap !== void 0) return logAndReport(msgOrCode, descMap, args ?? {}, (msg2) => {\n throw new Error(`${LOG_CATEGORY}: ${msg2}`);\n }, originalErrorMsg);\n const msg = msgOrCode;\n if (msg instanceof Error) {\n if (!msg.message.startsWith(LOG_CATEGORY)) msg.message = `${LOG_CATEGORY}: ${msg.message}`;\n throw msg;\n }\n throw new Error(`${LOG_CATEGORY}: ${msg}`);\n}\nconst processModuleAlias = (name, subPath) => {\n let moduleName;\n if (name.endsWith("/")) moduleName = name.slice(0, -1);\n else moduleName = name;\n if (subPath.startsWith(".")) subPath = subPath.slice(1);\n moduleName = moduleName + subPath;\n return moduleName;\n};\nconst CurrentGlobal = typeof globalThis === "object" ? globalThis : window;\nconst nativeGlobal = (() => {\n try {\n return document.defaultView;\n } catch {\n return CurrentGlobal;\n }\n})();\nfunction definePropertyGlobalVal(target, key, val) {\n Object.defineProperty(target, key, {\n value: val,\n configurable: false,\n writable: true\n });\n}\nfunction includeOwnProperty(target, key) {\n return Object.hasOwnProperty.call(target, key);\n}\nif (!includeOwnProperty(CurrentGlobal, "__GLOBAL_LOADING_REMOTE_ENTRY__")) definePropertyGlobalVal(CurrentGlobal, "__GLOBAL_LOADING_REMOTE_ENTRY__", {});\nconst globalLoading = CurrentGlobal.__GLOBAL_LOADING_REMOTE_ENTRY__;\nfunction setGlobalDefaultVal(target) {\n var _a, _b, _c, _d, _e, _f;\n if (includeOwnProperty(target, "__VMOK__") && !includeOwnProperty(target, "__FEDERATION__")) definePropertyGlobalVal(target, "__FEDERATION__", target.__VMOK__);\n if (!includeOwnProperty(target, "__FEDERATION__")) {\n definePropertyGlobalVal(target, "__FEDERATION__", {\n __GLOBAL_PLUGIN__: [],\n __INSTANCES__: [],\n moduleInfo: {},\n __SHARE__: {},\n __MANIFEST_LOADING__: {},\n __PRELOADED_MAP__: /* @__PURE__ */ new Map()\n });\n definePropertyGlobalVal(target, "__VMOK__", target.__FEDERATION__);\n }\n (_a = target.__FEDERATION__).__GLOBAL_PLUGIN__ ?? (_a.__GLOBAL_PLUGIN__ = []);\n (_b = target.__FEDERATION__).__INSTANCES__ ?? (_b.__INSTANCES__ = []);\n (_c = target.__FEDERATION__).moduleInfo ?? (_c.moduleInfo = {});\n (_d = target.__FEDERATION__).__SHARE__ ?? (_d.__SHARE__ = {});\n (_e = target.__FEDERATION__).__MANIFEST_LOADING__ ?? (_e.__MANIFEST_LOADING__ = {});\n (_f = target.__FEDERATION__).__PRELOADED_MAP__ ?? (_f.__PRELOADED_MAP__ = /* @__PURE__ */ new Map());\n}\nsetGlobalDefaultVal(CurrentGlobal);\nsetGlobalDefaultVal(nativeGlobal);\nconst getRemoteEntryExports = (name, globalName) => {\n const remoteEntryKey = globalName || `__FEDERATION_${name}:custom__`;\n return {\n remoteEntryKey,\n entryExports: CurrentGlobal[remoteEntryKey]\n };\n};\nconst DEFAULT_SCOPE = "default";\nconst DEFAULT_REMOTE_TYPE = "global";\nfunction composeRemoteRequestId(remoteName, expose) {\n if (!expose || expose === ".") return remoteName;\n return `${remoteName}/${expose.replace(/^\\.\\//, "")}`;\n}\nfunction matchRemoteWithNameAndExpose(remotes, id) {\n for (const remote of remotes) {\n const isNameMatched = id.startsWith(remote.name);\n let expose = id.replace(remote.name, "");\n if (isNameMatched) {\n if (expose.startsWith("/")) {\n const pkgNameOrAlias = remote.name;\n expose = `.${expose}`;\n return {\n pkgNameOrAlias,\n expose,\n remote\n };\n } else if (expose === "") return {\n pkgNameOrAlias: remote.name,\n expose: ".",\n remote\n };\n }\n const isAliasMatched = remote.alias && id.startsWith(remote.alias);\n let exposeWithAlias = remote.alias && id.replace(remote.alias, "");\n if (remote.alias && isAliasMatched) {\n if (exposeWithAlias && exposeWithAlias.startsWith("/")) {\n const pkgNameOrAlias = remote.alias;\n exposeWithAlias = `.${exposeWithAlias}`;\n return {\n pkgNameOrAlias,\n expose: exposeWithAlias,\n remote\n };\n } else if (exposeWithAlias === "") return {\n pkgNameOrAlias: remote.alias,\n expose: ".",\n remote\n };\n }\n }\n}\nconst RUNTIME_001 = "RUNTIME-001";\nconst RUNTIME_002 = "RUNTIME-002";\nconst RUNTIME_003 = "RUNTIME-003";\nconst RUNTIME_004 = "RUNTIME-004";\nconst RUNTIME_005 = "RUNTIME-005";\nconst RUNTIME_006 = "RUNTIME-006";\nconst RUNTIME_007 = "RUNTIME-007";\nconst RUNTIME_008 = "RUNTIME-008";\nconst RUNTIME_009 = "RUNTIME-009";\nconst RUNTIME_010 = "RUNTIME-010";\nconst RUNTIME_011 = "RUNTIME-011";\nconst RUNTIME_012 = "RUNTIME-012";\nconst RUNTIME_013 = "RUNTIME-013";\nconst RUNTIME_014 = "RUNTIME-014";\nconst RUNTIME_015 = "RUNTIME-015";\nconst runtimeDescMap = {\n [RUNTIME_001]: "Failed to get remoteEntry exports.",\n [RUNTIME_002]: \'The remote entry interface does not contain "init"\',\n [RUNTIME_003]: "Failed to get manifest.",\n [RUNTIME_004]: "Failed to locate remote.",\n [RUNTIME_005]: "Invalid loadShareSync function call from bundler runtime",\n [RUNTIME_006]: "Invalid loadShareSync function call from runtime",\n [RUNTIME_007]: "Failed to get remote snapshot.",\n [RUNTIME_008]: "Failed to load script resources.",\n [RUNTIME_009]: "Please call createInstance first.",\n [RUNTIME_010]: \'The name option cannot be changed after initialization. If you want to create a new instance with a different name, please use "createInstance" api.\',\n [RUNTIME_011]: "The remoteEntry URL is missing from the remote snapshot.",\n [RUNTIME_012]: \'The getter for the shared module is not a function. This may be caused by setting "shared.import: false" without the host providing the corresponding lib.\',\n [RUNTIME_013]: "The manifest is not a valid Module Federation manifest.",\n [RUNTIME_014]: "The remote does not expose the requested module.",\n [RUNTIME_015]: "Remote container initialization failed."\n};\n({\n ...runtimeDescMap\n});\nconst importCallback = ".then(callbacks[0]).catch(callbacks[1])";\nasync function loadEsmEntry({ entry, remoteEntryExports }) {\n return new Promise((resolve, reject) => {\n try {\n if (!remoteEntryExports) if (typeof FEDERATION_ALLOW_NEW_FUNCTION !== "undefined") new Function("callbacks", `import("${entry}")${importCallback}`)([resolve, reject]);\n else import(\n /* webpackIgnore: true */\n /* @vite-ignore */\n entry\n ).then(resolve).catch(reject);\n else resolve(remoteEntryExports);\n } catch (e) {\n error(`Failed to load ESM entry from "${entry}". ${e instanceof Error ? e.message : String(e)}`);\n }\n });\n}\nasync function loadSystemJsEntry({ entry, remoteEntryExports }) {\n return new Promise((resolve, reject) => {\n try {\n if (!remoteEntryExports) if (typeof __system_context__ === "undefined") System.import(entry).then(resolve).catch(reject);\n else new Function("callbacks", `System.import("${entry}")${importCallback}`)([resolve, reject]);\n else resolve(remoteEntryExports);\n } catch (e) {\n error(`Failed to load SystemJS entry from "${entry}". ${e instanceof Error ? e.message : String(e)}`);\n }\n });\n}\nfunction handleRemoteEntryLoaded(name, globalName, entry) {\n const { remoteEntryKey, entryExports } = getRemoteEntryExports(name, globalName);\n if (!entryExports) error(RUNTIME_001, runtimeDescMap, {\n remoteName: name,\n remoteEntryUrl: entry,\n remoteEntryKey\n });\n return entryExports;\n}\nasync function loadEntryScript({ name, globalName, entry, remoteInfo, loaderHook, getEntryUrl, resourceContext }) {\n const { entryExports: remoteEntryExports } = getRemoteEntryExports(name, globalName);\n if (remoteEntryExports) return remoteEntryExports;\n const url = getEntryUrl ? getEntryUrl(entry) : entry;\n return loadScript(url, {\n attrs: {},\n createScriptHook: (url2, attrs) => {\n const res = loaderHook.lifecycle.createScript.emit({\n url: url2,\n attrs,\n remoteInfo,\n resourceContext: resourceContext ? {\n ...resourceContext,\n url: url2\n } : void 0\n });\n if (!res) return;\n if (res instanceof HTMLScriptElement) return res;\n if ("script" in res || "timeout" in res) return res;\n }\n }).then(() => {\n return handleRemoteEntryLoaded(name, globalName, entry);\n }, (loadError) => {\n const originalMsg = loadError instanceof Error ? loadError.message : String(loadError);\n error(RUNTIME_008, runtimeDescMap, {\n remoteName: name,\n resourceUrl: url\n }, originalMsg);\n });\n}\nasync function loadEntryDom({ remoteInfo, remoteEntryExports, loaderHook, getEntryUrl, resourceContext }) {\n const { entry, entryGlobalName: globalName, name, type } = remoteInfo;\n switch (type) {\n case "esm":\n case "module":\n return loadEsmEntry({\n entry,\n remoteEntryExports\n });\n case "system":\n return loadSystemJsEntry({\n entry,\n remoteEntryExports\n });\n default:\n return loadEntryScript({\n entry,\n globalName,\n name,\n remoteInfo,\n loaderHook,\n getEntryUrl,\n resourceContext\n });\n }\n}\nasync function loadEntryNode({ remoteInfo, loaderHook, resourceContext }) {\n const { entry, entryGlobalName: globalName, name, type } = remoteInfo;\n const { entryExports: remoteEntryExports } = getRemoteEntryExports(name, globalName);\n if (remoteEntryExports) return remoteEntryExports;\n return loadScriptNode(entry, {\n attrs: {\n name,\n globalName,\n type\n },\n loaderHook: { createScriptHook: (url, attrs = {}) => {\n const res = loaderHook.lifecycle.createScript.emit({\n url,\n attrs,\n remoteInfo,\n resourceContext: resourceContext ? {\n ...resourceContext,\n url\n } : void 0\n });\n if (!res) return;\n if ("url" in res) return res;\n } }\n }).then(() => {\n return handleRemoteEntryLoaded(name, globalName, entry);\n }).catch((e) => {\n error(`Failed to load Node.js entry for remote "${name}" from "${entry}". ${e instanceof Error ? e.message : String(e)}`);\n });\n}\nfunction getRemoteEntryUniqueKey(remoteInfo) {\n const { entry, name } = remoteInfo;\n return composeKeyWithSeparator(name, entry);\n}\nasync function getRemoteEntry(params) {\n const { origin, remoteEntryExports, remoteInfo, getEntryUrl, resourceContext, _inErrorHandling = false } = params;\n const uniqueKey = getRemoteEntryUniqueKey(remoteInfo);\n if (remoteEntryExports) return remoteEntryExports;\n if (!globalLoading[uniqueKey]) {\n const loadEntryHook = origin.remoteHandler.hooks.lifecycle.loadEntry;\n const loaderHook = origin.loaderHook;\n globalLoading[uniqueKey] = loadEntryHook.emit({\n origin,\n loaderHook,\n remoteInfo,\n remoteEntryExports\n }).then((res) => {\n if (res) return res;\n return (typeof ENV_TARGET !== "undefined" ? ENV_TARGET === "web" : isBrowserEnvValue) ? loadEntryDom({\n remoteInfo,\n remoteEntryExports,\n loaderHook,\n getEntryUrl,\n resourceContext\n }) : loadEntryNode({\n remoteInfo,\n loaderHook,\n resourceContext\n });\n }).then(async (res) => {\n await origin.loaderHook.lifecycle.afterLoadEntry.emit({\n origin,\n remoteInfo,\n remoteEntryExports: res\n });\n return res;\n }).catch(async (err) => {\n const uniqueKey2 = getRemoteEntryUniqueKey(remoteInfo);\n const isScriptExecutionError = err instanceof Error && err.message.includes("ScriptExecutionError");\n if (err instanceof Error && err.message.includes(RUNTIME_008) && !isScriptExecutionError && !_inErrorHandling) {\n const wrappedGetRemoteEntry = (params2) => {\n return getRemoteEntry({\n ...params2,\n _inErrorHandling: true\n });\n };\n const RemoteEntryExports = await origin.loaderHook.lifecycle.loadEntryError.emit({\n getRemoteEntry: wrappedGetRemoteEntry,\n origin,\n remoteInfo,\n remoteEntryExports,\n globalLoading,\n uniqueKey: uniqueKey2\n });\n if (RemoteEntryExports) {\n await origin.loaderHook.lifecycle.afterLoadEntry.emit({\n origin,\n remoteInfo,\n remoteEntryExports: RemoteEntryExports,\n recovered: true\n });\n return RemoteEntryExports;\n }\n }\n await origin.loaderHook.lifecycle.afterLoadEntry.emit({\n origin,\n remoteInfo,\n error: err\n });\n throw err;\n });\n }\n return globalLoading[uniqueKey];\n}\nfunction getRemoteInfo(remote) {\n return {\n ...remote,\n entry: "entry" in remote ? remote.entry : "",\n type: remote.type || DEFAULT_REMOTE_TYPE,\n entryGlobalName: remote.entryGlobalName || remote.name,\n shareScope: remote.shareScope || DEFAULT_SCOPE\n };\n}\nfunction remoteToEntry(r) {\n return {\n name: r.name,\n alias: r.alias,\n entry: "entry" in r ? r.entry : void 0,\n version: "version" in r ? r.version : void 0,\n type: r.type,\n entryGlobalName: r.entryGlobalName,\n shareScope: r.shareScope\n };\n}\nfunction optionsToMFContext(options) {\n var _a, _b, _c, _d, _e, _f;\n const shared = {};\n for (const [pkgName, versions] of Object.entries(options.shared)) {\n const first = versions[0];\n if (first) shared[pkgName] = {\n version: first.version,\n singleton: (_a = first.shareConfig) == null ? void 0 : _a.singleton,\n requiredVersion: ((_b = first.shareConfig) == null ? void 0 : _b.requiredVersion) === false ? false : (_c = first.shareConfig) == null ? void 0 : _c.requiredVersion,\n eager: first.eager,\n strictVersion: (_d = first.shareConfig) == null ? void 0 : _d.strictVersion\n };\n }\n return {\n project: {\n name: options.name,\n mfRole: ((_e = options.remotes) == null ? void 0 : _e.length) > 0 ? "host" : "unknown"\n },\n mfConfig: {\n name: options.name,\n remotes: ((_f = options.remotes) == null ? void 0 : _f.map(remoteToEntry)) ?? [],\n shared\n }\n };\n}\nfunction isTimeoutError(error2) {\n if (!(error2 instanceof Error)) return false;\n return error2.message.includes("timed out") || error2.name.includes("Timeout");\n}\nfunction createAssetResult(context, url, status, error2) {\n return {\n url,\n status,\n resourceType: context.resourceType,\n initiator: context.initiator,\n id: context.id,\n error: error2\n };\n}\nasync function waitForRemoteEntryPreload(host, remoteInfo, entryRemoteInfo, context) {\n const cachedRemote = host.moduleCache.get(entryRemoteInfo.name);\n const url = entryRemoteInfo.entry;\n if (cachedRemote == null ? void 0 : cachedRemote.remoteEntryExports) return createAssetResult(context, url, "cached");\n try {\n if (!await getRemoteEntry({\n origin: host,\n remoteInfo: entryRemoteInfo,\n remoteEntryExports: cachedRemote == null ? void 0 : cachedRemote.remoteEntryExports,\n resourceContext: {\n ...context,\n url\n }\n })) throw new Error(`Failed to load remoteEntry "${url}".`);\n return createAssetResult(context, url, "success");\n } catch (error2) {\n return createAssetResult(context, url, isTimeoutError(error2) ? "timeout" : "error", error2);\n }\n}\nfunction waitForLinkPreload({ host, remoteInfo, url, attrs, context, needDeleteLink }) {\n return new Promise((resolve) => {\n const { link, needAttach } = createLink({\n url,\n cb: () => {\n resolve(createAssetResult(context, url, needAttach ? "success" : "cached"));\n },\n onErrorCallback: (error2) => {\n resolve(createAssetResult(context, url, isTimeoutError(error2) ? "timeout" : "error", error2));\n },\n attrs,\n createLinkHook: (hookUrl, hookAttrs) => {\n const res = host.loaderHook.lifecycle.createLink.emit({\n url: hookUrl,\n attrs: hookAttrs,\n remoteInfo,\n resourceContext: {\n ...context,\n url: hookUrl\n }\n });\n if (res instanceof HTMLLinkElement) return res;\n return res;\n },\n needDeleteLink\n });\n needAttach && document.head.appendChild(link);\n });\n}\nfunction waitForScriptPreload({ host, remoteInfo, url, attrs, context }) {\n return new Promise((resolve) => {\n const { script, needAttach } = createScript({\n url,\n cb: () => {\n resolve(createAssetResult(context, url, needAttach ? "success" : "cached"));\n },\n onErrorCallback: (error2) => {\n resolve(createAssetResult(context, url, isTimeoutError(error2) ? "timeout" : "error", error2));\n },\n attrs,\n createScriptHook: (hookUrl, hookAttrs) => {\n const res = host.loaderHook.lifecycle.createScript.emit({\n url: hookUrl,\n attrs: hookAttrs,\n remoteInfo,\n resourceContext: {\n ...context,\n url: hookUrl\n }\n });\n if (res instanceof HTMLScriptElement) return res;\n return res;\n },\n needDeleteScript: true\n });\n needAttach && document.head.appendChild(script);\n });\n}\nfunction createResourceContext(baseContext, resourceType) {\n return {\n ...baseContext,\n resourceType\n };\n}\nfunction preloadAssets(remoteInfo, host, assets, useLinkPreload = true, baseContext = {\n initiator: "preloadRemote",\n id: remoteInfo.name\n}) {\n const { cssAssets, jsAssetsWithoutEntry, entryAssets } = assets;\n const results = [];\n if (host.options.inBrowser) {\n entryAssets.forEach((asset) => {\n const { moduleInfo: entryRemoteInfo } = asset;\n results.push(waitForRemoteEntryPreload(host, remoteInfo, entryRemoteInfo, createResourceContext(baseContext, "remoteEntry")));\n });\n if (useLinkPreload) {\n const defaultAttrs = {\n rel: "preload",\n as: "style"\n };\n cssAssets.forEach((cssUrl) => {\n results.push(waitForLinkPreload({\n host,\n remoteInfo,\n url: cssUrl,\n attrs: defaultAttrs,\n context: createResourceContext(baseContext, "css")\n }));\n });\n } else {\n const defaultAttrs = {\n rel: "stylesheet",\n type: "text/css"\n };\n cssAssets.forEach((cssUrl) => {\n results.push(waitForLinkPreload({\n host,\n remoteInfo,\n url: cssUrl,\n attrs: defaultAttrs,\n needDeleteLink: false,\n context: createResourceContext(baseContext, "css")\n }));\n });\n }\n if (useLinkPreload) {\n const defaultAttrs = {\n rel: "preload",\n as: "script"\n };\n jsAssetsWithoutEntry.forEach((jsUrl) => {\n results.push(waitForLinkPreload({\n host,\n remoteInfo,\n url: jsUrl,\n attrs: defaultAttrs,\n context: createResourceContext(baseContext, "js")\n }));\n });\n } else {\n const defaultAttrs = {\n fetchpriority: "high",\n type: (remoteInfo == null ? void 0 : remoteInfo.type) === "module" ? "module" : "text/javascript"\n };\n jsAssetsWithoutEntry.forEach((jsUrl) => {\n results.push(waitForScriptPreload({\n host,\n remoteInfo,\n url: jsUrl,\n attrs: defaultAttrs,\n context: createResourceContext(baseContext, "js")\n }));\n });\n }\n }\n return Promise.all(results);\n}\nvar helpers_default = {\n utils: {\n matchRemoteWithNameAndExpose,\n preloadAssets,\n getRemoteInfo\n }\n};\nfunction getAvailableExposeNames(remoteSnapshot) {\n if (!remoteSnapshot || !("modules" in remoteSnapshot) || !Array.isArray(remoteSnapshot.modules)) return;\n const exposes = remoteSnapshot.modules.map((module) => module.moduleName).filter(Boolean);\n return exposes.length ? exposes.join(",") : void 0;\n}\nfunction createRemoteEntryInitOptions(remoteInfo, hostShareScopeMap, rawInitScope) {\n const localShareScopeMap = hostShareScopeMap;\n const shareScopeKeys = Array.isArray(remoteInfo.shareScope) ? remoteInfo.shareScope : [remoteInfo.shareScope];\n if (!shareScopeKeys.length) shareScopeKeys.push("default");\n shareScopeKeys.forEach((shareScopeKey) => {\n if (!localShareScopeMap[shareScopeKey]) localShareScopeMap[shareScopeKey] = {};\n });\n const remoteEntryInitOptions = {\n version: remoteInfo.version || "",\n shareScopeKeys: Array.isArray(remoteInfo.shareScope) ? shareScopeKeys : remoteInfo.shareScope || "default"\n };\n Object.defineProperty(remoteEntryInitOptions, "shareScopeMap", {\n value: localShareScopeMap,\n enumerable: false\n });\n return {\n remoteEntryInitOptions,\n shareScope: localShareScopeMap[shareScopeKeys[0]],\n initScope: rawInitScope ?? []\n };\n}\nvar Module$1 = class {\n constructor({ remoteInfo, host }) {\n this.inited = false;\n this.initing = false;\n this.lib = void 0;\n this.remoteInfo = remoteInfo;\n this.host = host;\n }\n async getEntry(expose) {\n if (this.remoteEntryExports) return this.remoteEntryExports;\n const remoteEntryExports = await getRemoteEntry({\n origin: this.host,\n remoteInfo: this.remoteInfo,\n remoteEntryExports: this.remoteEntryExports,\n resourceContext: {\n initiator: "loadRemote",\n id: composeRemoteRequestId(this.remoteInfo.name, expose),\n resourceType: "remoteEntry"\n }\n });\n assert(remoteEntryExports, `remoteEntryExports is undefined \n ${safeToString(this.remoteInfo)}`);\n this.remoteEntryExports = remoteEntryExports;\n return this.remoteEntryExports;\n }\n async init(id, remoteSnapshot, rawInitScope, expose) {\n const remoteEntryExports = await this.getEntry(expose);\n if (this.inited) {\n await this.host.loaderHook.lifecycle.afterInitRemote.emit({\n id,\n remoteInfo: this.remoteInfo,\n remoteSnapshot,\n remoteEntryExports,\n cached: true,\n origin: this.host\n });\n return remoteEntryExports;\n }\n if (this.initPromise) {\n try {\n await this.initPromise;\n await this.host.loaderHook.lifecycle.afterInitRemote.emit({\n id,\n remoteInfo: this.remoteInfo,\n remoteSnapshot,\n remoteEntryExports,\n cached: true,\n origin: this.host\n });\n } catch (initError) {\n await this.host.loaderHook.lifecycle.afterInitRemote.emit({\n id,\n remoteInfo: this.remoteInfo,\n remoteSnapshot,\n remoteEntryExports,\n error: initError,\n cached: true,\n origin: this.host\n });\n throw initError;\n }\n return remoteEntryExports;\n }\n this.initing = true;\n this.initPromise = (async () => {\n await this.host.loaderHook.lifecycle.beforeInitRemote.emit({\n id,\n remoteInfo: this.remoteInfo,\n remoteSnapshot,\n origin: this.host\n });\n const { remoteEntryInitOptions, shareScope, initScope } = createRemoteEntryInitOptions(this.remoteInfo, this.host.shareScopeMap, rawInitScope);\n const initContainerOptions = await this.host.hooks.lifecycle.beforeInitContainer.emit({\n shareScope,\n remoteEntryInitOptions,\n initScope,\n remoteInfo: this.remoteInfo,\n origin: this.host\n });\n if (typeof (remoteEntryExports == null ? void 0 : remoteEntryExports.init) === "undefined") error(RUNTIME_002, runtimeDescMap, {\n hostName: this.host.name,\n remoteName: this.remoteInfo.name,\n remoteEntryUrl: this.remoteInfo.entry,\n remoteEntryKey: this.remoteInfo.entryGlobalName\n }, void 0, optionsToMFContext(this.host.options));\n try {\n await remoteEntryExports.init(initContainerOptions.shareScope, initContainerOptions.initScope, initContainerOptions.remoteEntryInitOptions);\n } catch (initError) {\n error(RUNTIME_015, runtimeDescMap, {\n hostName: this.host.name,\n remoteName: this.remoteInfo.name,\n remoteEntryUrl: this.remoteInfo.entry,\n remoteEntryKey: this.remoteInfo.entryGlobalName,\n shareScope: this.remoteInfo.shareScope\n }, `${initError}`, optionsToMFContext(this.host.options));\n }\n await this.host.hooks.lifecycle.initContainer.emit({\n ...initContainerOptions,\n id,\n remoteSnapshot,\n remoteEntryExports\n });\n this.inited = true;\n })();\n try {\n await this.initPromise;\n await this.host.loaderHook.lifecycle.afterInitRemote.emit({\n id,\n remoteInfo: this.remoteInfo,\n remoteSnapshot,\n remoteEntryExports,\n origin: this.host\n });\n } catch (initError) {\n await this.host.loaderHook.lifecycle.afterInitRemote.emit({\n id,\n remoteInfo: this.remoteInfo,\n remoteSnapshot,\n remoteEntryExports,\n error: initError,\n origin: this.host\n });\n throw initError;\n } finally {\n this.initing = false;\n this.initPromise = void 0;\n }\n return remoteEntryExports;\n }\n async get(id, expose, options, remoteSnapshot) {\n const { loadFactory = true } = options || { loadFactory: true };\n const remoteEntryExports = await this.init(id, remoteSnapshot, void 0, expose);\n this.lib = remoteEntryExports;\n await this.host.loaderHook.lifecycle.beforeGetExpose.emit({\n id,\n expose,\n moduleInfo: this.remoteInfo,\n remoteEntryExports,\n origin: this.host\n });\n let moduleFactory;\n try {\n const hookModuleFactory = await this.host.loaderHook.lifecycle.getModuleFactory.emit({\n remoteEntryExports,\n expose,\n moduleInfo: this.remoteInfo\n });\n moduleFactory = typeof hookModuleFactory === "function" ? hookModuleFactory : void 0;\n if (!moduleFactory) moduleFactory = await remoteEntryExports.get(expose);\n if (!moduleFactory) error(RUNTIME_014, runtimeDescMap, {\n hostName: this.host.name,\n remoteName: this.remoteInfo.name,\n remoteEntryUrl: this.remoteInfo.entry,\n expose,\n requestId: id,\n availableExposes: getAvailableExposeNames(remoteSnapshot)\n }, void 0, optionsToMFContext(this.host.options));\n await this.host.loaderHook.lifecycle.afterGetExpose.emit({\n id,\n expose,\n moduleInfo: this.remoteInfo,\n remoteEntryExports,\n moduleFactory,\n origin: this.host\n });\n } catch (getExposeError) {\n await this.host.loaderHook.lifecycle.afterGetExpose.emit({\n id,\n expose,\n moduleInfo: this.remoteInfo,\n remoteEntryExports,\n error: getExposeError,\n origin: this.host\n });\n throw getExposeError;\n }\n const symbolName = processModuleAlias(this.remoteInfo.name, expose);\n const wrapModuleFactory = this.wraperFactory(moduleFactory, symbolName);\n if (!loadFactory) return wrapModuleFactory;\n await this.host.loaderHook.lifecycle.beforeExecuteFactory.emit({\n id,\n expose,\n moduleInfo: this.remoteInfo,\n loadFactory,\n origin: this.host\n });\n try {\n const exposeContent = await wrapModuleFactory();\n await this.host.loaderHook.lifecycle.afterExecuteFactory.emit({\n id,\n expose,\n moduleInfo: this.remoteInfo,\n loadFactory,\n exposeModule: exposeContent,\n origin: this.host\n });\n return exposeContent;\n } catch (executeFactoryError) {\n await this.host.loaderHook.lifecycle.afterExecuteFactory.emit({\n id,\n expose,\n moduleInfo: this.remoteInfo,\n loadFactory,\n error: executeFactoryError,\n origin: this.host\n });\n throw executeFactoryError;\n }\n }\n wraperFactory(moduleFactory, id) {\n function defineModuleId(res, id2) {\n if (res && typeof res === "object" && Object.isExtensible(res) && !Object.getOwnPropertyDescriptor(res, Symbol.for("mf_module_id"))) Object.defineProperty(res, Symbol.for("mf_module_id"), {\n value: id2,\n enumerable: false\n });\n }\n return () => {\n const res = moduleFactory();\n if (res instanceof Promise) return res.then((asyncRes) => {\n defineModuleId(asyncRes, id);\n return asyncRes;\n });\n defineModuleId(res, id);\n return res;\n };\n }\n};\nconst REMOTE_DISABLED_MESSAGE = "Remote loading is disabled by experiments.optimization.disableRemote.";\nvar UnavailableRemoteModule = class {\n constructor() {\n throw new Error(REMOTE_DISABLED_MESSAGE);\n }\n};\ntypeof FEDERATION_OPTIMIZE_NO_SNAPSHOT_PLUGIN === "boolean" ? !FEDERATION_OPTIMIZE_NO_SNAPSHOT_PLUGIN : true;\ntypeof FEDERATION_OPTIMIZE_NO_REMOTE === "boolean" ? !FEDERATION_OPTIMIZE_NO_REMOTE : true;\ntypeof FEDERATION_OPTIMIZE_NO_SHARED === "boolean" ? !FEDERATION_OPTIMIZE_NO_SHARED : true;\nconst helpers = helpers_default;\ntypeof FEDERATION_OPTIMIZE_NO_REMOTE === "boolean" && FEDERATION_OPTIMIZE_NO_REMOTE ? UnavailableRemoteModule : Module$1;\nconst utils = helpers.utils;\nconst runtimeHelpers = {\n utils\n};\nasync function prefetch(options) {\n const { instance, id, dataFetchParams, preloadComponentResource } = options;\n if (!id) {\n logger.error("id is required for prefetch!");\n return;\n }\n if (!instance) {\n logger.error("instance is required for prefetch!");\n return;\n }\n const matchedRemoteInfo = runtimeHelpers.utils.matchRemoteWithNameAndExpose(\n instance.options.remotes,\n id\n );\n if (!matchedRemoteInfo) {\n logger.error(`Can not found \'${id}\' in instance.options.remotes!`);\n return;\n }\n const { remote, expose } = matchedRemoteInfo;\n const { remoteSnapshot, globalSnapshot } = await instance.snapshotHandler.loadRemoteSnapshotInfo({\n moduleInfo: remote,\n id\n });\n if (preloadComponentResource) {\n const remoteInfo = runtimeHelpers.utils.getRemoteInfo(remote);\n Promise.resolve(\n instance.remoteHandler.hooks.lifecycle.generatePreloadAssets.emit({\n origin: instance,\n preloadOptions: {\n remote,\n preloadConfig: {\n nameOrAlias: remote.name,\n exposes: [expose]\n }\n },\n remote,\n remoteInfo,\n globalSnapshot,\n remoteSnapshot\n })\n ).then((assets) => {\n if (assets) {\n runtimeHelpers.utils.preloadAssets(remoteInfo, instance, assets);\n }\n });\n }\n const dataFetchMap = getDataFetchMap();\n if (!dataFetchMap) {\n return;\n }\n const dataFetchInfo = getDataFetchInfo({\n name: remote.name,\n alias: remote.alias,\n id,\n remoteSnapshot\n });\n const dataFetchMapKey = getDataFetchMapKey(dataFetchInfo, {\n name: instance.name,\n version: instance.options.version\n });\n if (!dataFetchMapKey) {\n return;\n }\n const dataFetchItem = dataFetchMap[dataFetchMapKey];\n if (!dataFetchItem) {\n return;\n }\n const [getDataFetchGetter, _type, getDataFetchPromise] = dataFetchItem[0];\n let _getDataFetchPromise = getDataFetchPromise;\n if (!getDataFetchPromise) {\n if (!getDataFetchGetter) {\n return;\n }\n _getDataFetchPromise = getDataFetchGetter();\n }\n _getDataFetchPromise.then((dataFetchFn) => {\n return dataFetchFn({\n ...dataFetchParams,\n _id: dataFetchMapKey,\n isDowngrade: false\n });\n });\n}\nexport {\n dataFetchFunction as d,\n injectDataFetch as i,\n prefetch as p\n};\n',
157
+ "prefetch-BzCq3MT3.mjs": 'import { B as warn, y as DATA_FETCH_FUNCTION, F as FS_HREF, l as logger, e as getDataFetchMap, i as initDataFetchMap, o as getDataFetchItem, M as MF_DATA_FETCH_STATUS, q as MF_DATA_FETCH_TYPE, G as DOWNGRADE_KEY, H as callAllDowngrade, I as callDowngrade, J as getDowngradeTag, K as composeKeyWithSeparator, N as safeToString, m as getDataFetchInfo, n as getDataFetchMapKey } from "./utils-BBP3hEeV.mjs";\nimport { i as isBrowserEnvValue } from "./logger-DwWkXsWl.mjs";\nasync function safeWrapper(callback, disableWarn) {\n try {\n return await callback();\n } catch (e) {\n warn(e);\n return;\n }\n}\nfunction isStaticResourcesEqual(url1, url2) {\n const REG_EXP = /^(https?:)?\\/\\//i;\n return url1.replace(REG_EXP, "").replace(/\\/$/, "") === url2.replace(REG_EXP, "").replace(/\\/$/, "");\n}\nfunction createScript(info) {\n let script = null;\n let needAttach = true;\n let timeout = 2e4;\n let timeoutId;\n const scripts = document.getElementsByTagName("script");\n for (let i = 0; i < scripts.length; i++) {\n const s = scripts[i];\n const scriptSrc = s.getAttribute("src");\n if (scriptSrc && isStaticResourcesEqual(scriptSrc, info.url)) {\n script = s;\n needAttach = false;\n break;\n }\n }\n if (!script) {\n const attrs = info.attrs;\n script = document.createElement("script");\n script.type = (attrs == null ? void 0 : attrs["type"]) === "module" ? "module" : "text/javascript";\n let createScriptRes = void 0;\n if (info.createScriptHook) {\n createScriptRes = info.createScriptHook(info.url, info.attrs);\n if (createScriptRes instanceof HTMLScriptElement) script = createScriptRes;\n else if (typeof createScriptRes === "object") {\n if ("script" in createScriptRes && createScriptRes.script) script = createScriptRes.script;\n if ("timeout" in createScriptRes && createScriptRes.timeout) timeout = createScriptRes.timeout;\n }\n }\n if (!script.src) script.src = info.url;\n if (attrs && !createScriptRes) Object.keys(attrs).forEach((name) => {\n if (script) {\n if (name === "async" || name === "defer") script[name] = attrs[name];\n else if (!script.getAttribute(name)) script.setAttribute(name, attrs[name]);\n }\n });\n }\n let executionError = null;\n const executionErrorHandler = typeof window !== "undefined" ? (evt) => {\n if (evt.filename && isStaticResourcesEqual(evt.filename, info.url)) {\n const err = /* @__PURE__ */ new Error(`ScriptExecutionError: Script "${info.url}" loaded but threw a runtime error during execution: ${evt.message} (${evt.filename}:${evt.lineno}:${evt.colno})`);\n err.name = "ScriptExecutionError";\n executionError = err;\n }\n } : null;\n if (executionErrorHandler) window.addEventListener("error", executionErrorHandler);\n const onScriptComplete = async (prev, event) => {\n clearTimeout(timeoutId);\n if (executionErrorHandler) window.removeEventListener("error", executionErrorHandler);\n const onScriptCompleteCallback = () => {\n if ((event == null ? void 0 : event.type) === "error") {\n const networkError = /* @__PURE__ */ new Error((event == null ? void 0 : event.isTimeout) ? `ScriptNetworkError: Script "${info.url}" timed out.` : `ScriptNetworkError: Failed to load script "${info.url}" - the script URL is unreachable or the server returned an error (network failure, 404, CORS, etc.)`);\n networkError.name = "ScriptNetworkError";\n (info == null ? void 0 : info.onErrorCallback) && (info == null ? void 0 : info.onErrorCallback(networkError));\n } else if (executionError) (info == null ? void 0 : info.onErrorCallback) && (info == null ? void 0 : info.onErrorCallback(executionError));\n else (info == null ? void 0 : info.cb) && (info == null ? void 0 : info.cb());\n };\n if (script) {\n script.onerror = null;\n script.onload = null;\n safeWrapper(() => {\n const { needDeleteScript = true } = info;\n if (needDeleteScript) (script == null ? void 0 : script.parentNode) && script.parentNode.removeChild(script);\n });\n if (prev && typeof prev === "function") {\n const result = prev(event);\n if (result instanceof Promise) {\n const res = await result;\n onScriptCompleteCallback();\n return res;\n }\n onScriptCompleteCallback();\n return result;\n }\n }\n onScriptCompleteCallback();\n };\n script.onerror = onScriptComplete.bind(null, script.onerror);\n script.onload = onScriptComplete.bind(null, script.onload);\n timeoutId = setTimeout(() => {\n onScriptComplete(null, {\n type: "error",\n isTimeout: true\n });\n }, timeout);\n return {\n script,\n needAttach\n };\n}\nfunction createLink(info) {\n let link = null;\n let needAttach = true;\n let timeout = 2e4;\n let timeoutId;\n const links = document.getElementsByTagName("link");\n for (let i = 0; i < links.length; i++) {\n const l = links[i];\n const linkHref = l.getAttribute("href");\n const linkRel = l.getAttribute("rel");\n if (linkHref && isStaticResourcesEqual(linkHref, info.url) && linkRel === info.attrs["rel"]) {\n link = l;\n needAttach = false;\n break;\n }\n }\n if (!link) {\n link = document.createElement("link");\n link.setAttribute("href", info.url);\n let createLinkRes = void 0;\n let shouldApplyAttrs = true;\n const attrs = info.attrs;\n if (info.createLinkHook) {\n createLinkRes = info.createLinkHook(info.url, attrs);\n if (createLinkRes instanceof HTMLLinkElement) {\n link = createLinkRes;\n shouldApplyAttrs = false;\n } else if (typeof createLinkRes === "object") {\n if ("link" in createLinkRes && createLinkRes.link) {\n link = createLinkRes.link;\n shouldApplyAttrs = false;\n }\n if ("timeout" in createLinkRes && createLinkRes.timeout) timeout = createLinkRes.timeout;\n }\n }\n if (attrs && shouldApplyAttrs) Object.keys(attrs).forEach((name) => {\n if (link && !link.getAttribute(name)) link.setAttribute(name, attrs[name]);\n });\n }\n if (!needAttach) {\n Promise.resolve().then(() => {\n (info == null ? void 0 : info.cb) && (info == null ? void 0 : info.cb());\n });\n return {\n link,\n needAttach\n };\n }\n const onLinkComplete = (prev, event) => {\n if (timeoutId) clearTimeout(timeoutId);\n const onLinkCompleteCallback = () => {\n if ((event == null ? void 0 : event.type) === "error") {\n const linkError = /* @__PURE__ */ new Error((event == null ? void 0 : event.isTimeout) ? `LinkNetworkError: Link "${info.url}" timed out.` : `LinkNetworkError: Failed to load link "${info.url}" - the URL is unreachable or the server returned an error.`);\n linkError.name = "LinkNetworkError";\n (info == null ? void 0 : info.onErrorCallback) && (info == null ? void 0 : info.onErrorCallback(linkError));\n } else (info == null ? void 0 : info.cb) && (info == null ? void 0 : info.cb());\n };\n if (link) {\n link.onerror = null;\n link.onload = null;\n safeWrapper(() => {\n const { needDeleteLink = true } = info;\n if (needDeleteLink) (link == null ? void 0 : link.parentNode) && link.parentNode.removeChild(link);\n });\n if (prev) {\n const res = prev(event);\n onLinkCompleteCallback();\n return res;\n }\n }\n onLinkCompleteCallback();\n };\n link.onerror = onLinkComplete.bind(null, link.onerror);\n link.onload = onLinkComplete.bind(null, link.onload);\n timeoutId = setTimeout(() => {\n onLinkComplete(null, {\n type: "error",\n isTimeout: true\n });\n }, timeout);\n return {\n link,\n needAttach\n };\n}\nfunction loadScript(url, info) {\n const { attrs = {}, createScriptHook } = info;\n return new Promise((resolve, reject) => {\n const { script, needAttach } = createScript({\n url,\n cb: resolve,\n onErrorCallback: reject,\n attrs: {\n fetchpriority: "high",\n ...attrs\n },\n createScriptHook,\n needDeleteScript: true\n });\n needAttach && document.head.appendChild(script);\n });\n}\nconst sdkImportCache = /* @__PURE__ */ new Map();\nfunction importNodeModule(name) {\n if (!name) throw new Error("import specifier is required");\n if (sdkImportCache.has(name)) return sdkImportCache.get(name);\n const promise = new Function("name", `return import(name)`)(name).then((res) => res).catch((error2) => {\n console.error(`Error importing module ${name}:`, error2);\n sdkImportCache.delete(name);\n throw error2;\n });\n sdkImportCache.set(name, promise);\n return promise;\n}\nconst lazyLoaderHookFetch = async (input, init, loaderHook) => {\n const hook = (url, init2) => {\n return loaderHook.lifecycle.fetch.emit(url, init2);\n };\n const res = await hook(input, init || {});\n if (!res || !(res instanceof Response)) return fetch(input, init || {});\n return res;\n};\nconst createScriptNode = typeof ENV_TARGET === "undefined" || ENV_TARGET !== "web" ? (url, cb, attrs, loaderHook) => {\n if (loaderHook == null ? void 0 : loaderHook.createScriptHook) {\n const hookResult = loaderHook.createScriptHook(url);\n if (hookResult && typeof hookResult === "object" && "url" in hookResult) url = hookResult.url;\n }\n let urlObj;\n try {\n urlObj = new URL(url);\n } catch (e) {\n console.error("Error constructing URL:", e);\n cb(/* @__PURE__ */ new Error(`Invalid URL: ${e}`));\n return;\n }\n const getFetch = async () => {\n if (loaderHook == null ? void 0 : loaderHook.fetch) return (input, init) => lazyLoaderHookFetch(input, init, loaderHook);\n return fetch;\n };\n const handleScriptFetch = async (f, urlObj2) => {\n var _a;\n try {\n const res = await f(urlObj2.href);\n const data = await res.text();\n const [path, vm] = await Promise.all([importNodeModule("path"), importNodeModule("vm")]);\n const scriptContext = {\n exports: {},\n module: { exports: {} }\n };\n const urlDirname = urlObj2.pathname.split("/").slice(0, -1).join("/");\n const filename = path.basename(urlObj2.pathname);\n const script = new vm.Script(`(function(exports, module, require, __dirname, __filename) {${data}\n})`, {\n filename,\n importModuleDynamically: ((_a = vm.constants) == null ? void 0 : _a.USE_MAIN_CONTEXT_DEFAULT_LOADER) ?? importNodeModule\n });\n let requireFn;\n requireFn = (await importNodeModule("node:module")).createRequire(urlObj2.protocol === "file:" || urlObj2.protocol === "node:" ? urlObj2.href : path.join(process.cwd(), "__mf_require_base__.js"));\n script.runInThisContext()(scriptContext.exports, scriptContext.module, requireFn, urlDirname, filename);\n const exportedInterface = scriptContext.module.exports || scriptContext.exports;\n if (attrs && exportedInterface && attrs["globalName"]) {\n cb(void 0, exportedInterface[attrs["globalName"]] || exportedInterface);\n return;\n }\n cb(void 0, exportedInterface);\n } catch (e) {\n cb(e instanceof Error ? e : /* @__PURE__ */ new Error(`Script execution error: ${e}`));\n }\n };\n getFetch().then(async (f) => {\n if ((attrs == null ? void 0 : attrs["type"]) === "esm" || (attrs == null ? void 0 : attrs["type"]) === "module") return loadModule(urlObj.href, {\n fetch: f,\n vm: await importNodeModule("vm")\n }).then(async (module) => {\n await module.evaluate();\n cb(void 0, module.namespace);\n }).catch((e) => {\n cb(e instanceof Error ? e : /* @__PURE__ */ new Error(`Script execution error: ${e}`));\n });\n handleScriptFetch(f, urlObj);\n }).catch((err) => {\n cb(err);\n });\n} : (url, cb, attrs, loaderHook) => {\n cb(/* @__PURE__ */ new Error("createScriptNode is disabled in non-Node.js environment"));\n};\nconst loadScriptNode = typeof ENV_TARGET === "undefined" || ENV_TARGET !== "web" ? (url, info) => {\n return new Promise((resolve, reject) => {\n createScriptNode(url, (error2, scriptContext) => {\n var _a, _b;\n if (error2) reject(error2);\n else {\n const remoteEntryKey = ((_a = info == null ? void 0 : info.attrs) == null ? void 0 : _a["globalName"]) || `__FEDERATION_${(_b = info == null ? void 0 : info.attrs) == null ? void 0 : _b["name"]}:custom__`;\n resolve(globalThis[remoteEntryKey] = scriptContext);\n }\n }, info.attrs, info.loaderHook);\n });\n} : (url, info) => {\n throw new Error("loadScriptNode is disabled in non-Node.js environment");\n};\nconst esmModuleCache = /* @__PURE__ */ new Map();\nconst isFetchableRemoteModuleUrl = (url) => url.startsWith("http:") || url.startsWith("https:");\nconst isBareModuleSpecifier = (specifier) => !specifier.startsWith("./") && !specifier.startsWith("../") && !specifier.startsWith("/") && !specifier.includes(":");\nfunction encodeRemoteModulePath(url) {\n const remoteUrl = new URL(url);\n const encodedProtocol = encodeURIComponent(remoteUrl.protocol.slice(0, -1));\n const encodedHost = encodeURIComponent(remoteUrl.host);\n const encodedPathname = remoteUrl.pathname.split("/").map((segment) => encodeURIComponent(segment)).join("/");\n const encodedSearchHash = encodeURIComponent(`${remoteUrl.search}${remoteUrl.hash}`);\n return `/${encodedProtocol}/${encodedHost}${encodedPathname}${encodedSearchHash ? `/${encodedSearchHash}` : ""}`;\n}\nfunction createImportMetaUrl(url, baseFileUrl) {\n const baseUrl = baseFileUrl.endsWith("/") ? baseFileUrl : `${baseFileUrl}/`;\n return new URL(`__module_federation_remote__${encodeRemoteModulePath(url)}`, baseUrl).href;\n}\nasync function isNodeBuiltinSpecifier(specifier) {\n if (specifier.startsWith("node:")) return true;\n if (!isBareModuleSpecifier(specifier)) return false;\n return (await importNodeModule("node:module")).builtinModules.includes(specifier);\n}\nfunction getSyntheticModuleExports(moduleExports) {\n const namespaceObject = moduleExports && (typeof moduleExports === "object" || typeof moduleExports === "function") ? moduleExports : { default: moduleExports };\n const effectiveExports = { ...namespaceObject };\n if (!Object.prototype.hasOwnProperty.call(effectiveExports, "default")) effectiveExports.default = namespaceObject;\n return effectiveExports;\n}\nasync function createSyntheticModuleFromExports(identifier, moduleExports, vm) {\n if (typeof vm.SyntheticModule !== "function") throw new Error("vm.SyntheticModule is required to load Node.js built-in modules in ESM remote entries.");\n const effectiveExports = getSyntheticModuleExports(moduleExports);\n const exportNames = Object.keys(effectiveExports);\n const syntheticModule = new vm.SyntheticModule(exportNames, function setSyntheticModuleExports() {\n for (const name of exportNames) this.setExport(name, effectiveExports[name]);\n }, { identifier });\n esmModuleCache.set(identifier, syntheticModule);\n await syntheticModule.link(async () => {\n throw new Error(`Node.js built-in module "${identifier}" should not request child modules.`);\n });\n await syntheticModule.evaluate();\n return syntheticModule;\n}\nasync function loadNodeBuiltinModule(specifier, vm) {\n const cacheKey = `node-builtin:${specifier}`;\n if (esmModuleCache.has(cacheKey)) return esmModuleCache.get(cacheKey);\n return createSyntheticModuleFromExports(cacheKey, await importNodeModule(specifier), vm);\n}\nasync function loadResolvedModule(specifier, parentUrl, options) {\n if (await isNodeBuiltinSpecifier(specifier)) return loadNodeBuiltinModule(specifier, options.vm);\n if (isBareModuleSpecifier(specifier)) throw new Error(`Unsupported ESM module specifier "${specifier}". Only relative or absolute http(s) remote modules and Node.js built-in modules are supported.`);\n const resolvedUrl = new URL(specifier, parentUrl).href;\n if (!isFetchableRemoteModuleUrl(resolvedUrl)) throw new Error(`Unsupported ESM module specifier "${specifier}" resolved to "${resolvedUrl}". Only http(s) remote modules and Node.js built-in modules are supported.`);\n return loadModule(resolvedUrl, options);\n}\nasync function evaluateDynamicModule(module) {\n if (module.status === "linked") await module.evaluate();\n if (module.status === "errored") throw module.error;\n return module;\n}\nasync function loadModule(url, options) {\n if (esmModuleCache.has(url)) return esmModuleCache.get(url);\n const { fetch: fetch2, vm } = options;\n if (!isFetchableRemoteModuleUrl(url)) throw new Error(`Unsupported ESM module URL "${url}". Only http(s) remote modules and Node.js built-in modules are supported.`);\n const code = await (await fetch2(url)).text();\n const cwdFileUrl = (await importNodeModule("node:url")).pathToFileURL(process.cwd()).href;\n const sourceTextModule = new vm.SourceTextModule(code, {\n identifier: url,\n initializeImportMeta: (meta) => {\n meta.url = createImportMetaUrl(url, cwdFileUrl);\n },\n importModuleDynamically: async (specifier) => {\n return evaluateDynamicModule(await loadResolvedModule(specifier, url, options));\n }\n });\n esmModuleCache.set(url, sourceTextModule);\n await sourceTextModule.link(async (specifier) => {\n return loadResolvedModule(specifier, url, options);\n });\n return sourceTextModule;\n}\nconst dataFetchFunction = async function(options) {\n var _a, _b;\n const [id, data, downgrade] = options;\n logger.debug("==========call data fetch function!");\n if (data) {\n if (!id) {\n throw new Error("id is required!");\n }\n if (!getDataFetchMap()) {\n initDataFetchMap();\n }\n const dataFetchItem = getDataFetchItem(id);\n if (dataFetchItem) {\n (_b = (_a = dataFetchItem[1]) == null ? void 0 : _a[1]) == null ? void 0 : _b.call(_a, data);\n dataFetchItem[2] = MF_DATA_FETCH_STATUS.LOADED;\n return;\n }\n if (!dataFetchItem) {\n const dataFetchMap = getDataFetchMap();\n let res;\n let rej;\n const p = new Promise((resolve, reject) => {\n res = resolve;\n rej = reject;\n });\n dataFetchMap[id] = [\n [\n async () => async () => {\n return "";\n },\n MF_DATA_FETCH_TYPE.FETCH_SERVER\n ],\n [p, res, rej],\n MF_DATA_FETCH_STATUS.LOADED\n ];\n res && res(data);\n return;\n }\n }\n if (downgrade) {\n const mfDowngrade2 = getDowngradeTag();\n if (!mfDowngrade2) {\n globalThis[DOWNGRADE_KEY] = id ? [id] : true;\n } else if (Array.isArray(mfDowngrade2) && id && !mfDowngrade2.includes(id)) {\n mfDowngrade2.push(id);\n }\n }\n const mfDowngrade = getDowngradeTag();\n if (typeof mfDowngrade === "boolean") {\n return callAllDowngrade();\n }\n if (Array.isArray(mfDowngrade)) {\n if (!id) {\n globalThis[DOWNGRADE_KEY] = true;\n return callAllDowngrade();\n }\n if (!mfDowngrade.includes(id)) {\n mfDowngrade.push(id);\n }\n return callDowngrade(id);\n }\n};\nfunction injectDataFetch() {\n var _a;\n globalThis[_a = DATA_FETCH_FUNCTION] || (globalThis[_a] = []);\n const dataFetch = globalThis[DATA_FETCH_FUNCTION];\n if (dataFetch.push === dataFetchFunction) {\n return;\n }\n if (typeof window === "undefined") {\n return;\n }\n globalThis[FS_HREF] = window.location.href;\n dataFetch.push = dataFetchFunction;\n}\nconst getDocsUrl = (errorCode) => {\n return `View the docs to see how to solve: https://module-federation.io/guide/troubleshooting/${errorCode.split("-")[0].toLowerCase()}#${errorCode.toLowerCase()}`;\n};\nconst getShortErrorMsg = (errorCode, errorDescMap, args, originalErrorMsg) => {\n const msg = [`${[errorDescMap[errorCode]]} #${errorCode}`];\n args && msg.push(`args: ${JSON.stringify(args)}`);\n msg.push(getDocsUrl(errorCode));\n originalErrorMsg && msg.push(`Original Error Message:\n ${originalErrorMsg}`);\n return msg.join("\\n");\n};\nfunction logAndReport(code, descMap, args, logger2, originalErrorMsg, context) {\n return logger2(getShortErrorMsg(code, descMap, args, originalErrorMsg));\n}\nconst LOG_CATEGORY = "[ Federation Runtime ]";\nfunction assert(condition, msgOrCode, descMap, args, context) {\n if (!condition) error(msgOrCode);\n}\nfunction error(msgOrCode, descMap, args, originalErrorMsg, context) {\n if (descMap !== void 0) return logAndReport(msgOrCode, descMap, args ?? {}, (msg2) => {\n throw new Error(`${LOG_CATEGORY}: ${msg2}`);\n }, originalErrorMsg);\n const msg = msgOrCode;\n if (msg instanceof Error) {\n if (!msg.message.startsWith(LOG_CATEGORY)) msg.message = `${LOG_CATEGORY}: ${msg.message}`;\n throw msg;\n }\n throw new Error(`${LOG_CATEGORY}: ${msg}`);\n}\nconst processModuleAlias = (name, subPath) => {\n let moduleName;\n if (name.endsWith("/")) moduleName = name.slice(0, -1);\n else moduleName = name;\n if (subPath.startsWith(".")) subPath = subPath.slice(1);\n moduleName = moduleName + subPath;\n return moduleName;\n};\nconst CurrentGlobal = typeof globalThis === "object" ? globalThis : window;\nconst nativeGlobal = (() => {\n try {\n return document.defaultView;\n } catch {\n return CurrentGlobal;\n }\n})();\nfunction definePropertyGlobalVal(target, key, val) {\n Object.defineProperty(target, key, {\n value: val,\n configurable: false,\n writable: true\n });\n}\nfunction includeOwnProperty(target, key) {\n return Object.hasOwnProperty.call(target, key);\n}\nif (!includeOwnProperty(CurrentGlobal, "__GLOBAL_LOADING_REMOTE_ENTRY__")) definePropertyGlobalVal(CurrentGlobal, "__GLOBAL_LOADING_REMOTE_ENTRY__", {});\nconst globalLoading = CurrentGlobal.__GLOBAL_LOADING_REMOTE_ENTRY__;\nfunction setGlobalDefaultVal(target) {\n var _a, _b, _c, _d, _e, _f;\n if (includeOwnProperty(target, "__VMOK__") && !includeOwnProperty(target, "__FEDERATION__")) definePropertyGlobalVal(target, "__FEDERATION__", target.__VMOK__);\n if (!includeOwnProperty(target, "__FEDERATION__")) {\n definePropertyGlobalVal(target, "__FEDERATION__", {\n __GLOBAL_PLUGIN__: [],\n __INSTANCES__: [],\n moduleInfo: {},\n __SHARE__: {},\n __MANIFEST_LOADING__: {},\n __PRELOADED_MAP__: /* @__PURE__ */ new Map()\n });\n definePropertyGlobalVal(target, "__VMOK__", target.__FEDERATION__);\n }\n (_a = target.__FEDERATION__).__GLOBAL_PLUGIN__ ?? (_a.__GLOBAL_PLUGIN__ = []);\n (_b = target.__FEDERATION__).__INSTANCES__ ?? (_b.__INSTANCES__ = []);\n (_c = target.__FEDERATION__).moduleInfo ?? (_c.moduleInfo = {});\n (_d = target.__FEDERATION__).__SHARE__ ?? (_d.__SHARE__ = {});\n (_e = target.__FEDERATION__).__MANIFEST_LOADING__ ?? (_e.__MANIFEST_LOADING__ = {});\n (_f = target.__FEDERATION__).__PRELOADED_MAP__ ?? (_f.__PRELOADED_MAP__ = /* @__PURE__ */ new Map());\n}\nsetGlobalDefaultVal(CurrentGlobal);\nsetGlobalDefaultVal(nativeGlobal);\nconst getRemoteEntryExports = (name, globalName) => {\n const remoteEntryKey = globalName || `__FEDERATION_${name}:custom__`;\n return {\n remoteEntryKey,\n entryExports: CurrentGlobal[remoteEntryKey]\n };\n};\nconst DEFAULT_SCOPE = "default";\nconst DEFAULT_REMOTE_TYPE = "global";\nfunction composeRemoteRequestId(remoteName, expose) {\n if (!expose || expose === ".") return remoteName;\n return `${remoteName}/${expose.replace(/^\\.\\//, "")}`;\n}\nfunction matchRemoteWithNameAndExpose(remotes, id) {\n for (const remote of remotes) {\n const isNameMatched = id.startsWith(remote.name);\n let expose = id.replace(remote.name, "");\n if (isNameMatched) {\n if (expose.startsWith("/")) {\n const pkgNameOrAlias = remote.name;\n expose = `.${expose}`;\n return {\n pkgNameOrAlias,\n expose,\n remote\n };\n } else if (expose === "") return {\n pkgNameOrAlias: remote.name,\n expose: ".",\n remote\n };\n }\n const isAliasMatched = remote.alias && id.startsWith(remote.alias);\n let exposeWithAlias = remote.alias && id.replace(remote.alias, "");\n if (remote.alias && isAliasMatched) {\n if (exposeWithAlias && exposeWithAlias.startsWith("/")) {\n const pkgNameOrAlias = remote.alias;\n exposeWithAlias = `.${exposeWithAlias}`;\n return {\n pkgNameOrAlias,\n expose: exposeWithAlias,\n remote\n };\n } else if (exposeWithAlias === "") return {\n pkgNameOrAlias: remote.alias,\n expose: ".",\n remote\n };\n }\n }\n}\nconst RUNTIME_001 = "RUNTIME-001";\nconst RUNTIME_002 = "RUNTIME-002";\nconst RUNTIME_003 = "RUNTIME-003";\nconst RUNTIME_004 = "RUNTIME-004";\nconst RUNTIME_005 = "RUNTIME-005";\nconst RUNTIME_006 = "RUNTIME-006";\nconst RUNTIME_007 = "RUNTIME-007";\nconst RUNTIME_008 = "RUNTIME-008";\nconst RUNTIME_009 = "RUNTIME-009";\nconst RUNTIME_010 = "RUNTIME-010";\nconst RUNTIME_011 = "RUNTIME-011";\nconst RUNTIME_012 = "RUNTIME-012";\nconst RUNTIME_013 = "RUNTIME-013";\nconst RUNTIME_014 = "RUNTIME-014";\nconst RUNTIME_015 = "RUNTIME-015";\nconst runtimeDescMap = {\n [RUNTIME_001]: "Failed to get remoteEntry exports.",\n [RUNTIME_002]: \'The remote entry interface does not contain "init"\',\n [RUNTIME_003]: "Failed to get manifest.",\n [RUNTIME_004]: "Failed to locate remote.",\n [RUNTIME_005]: "Invalid loadShareSync function call from bundler runtime",\n [RUNTIME_006]: "Invalid loadShareSync function call from runtime",\n [RUNTIME_007]: "Failed to get remote snapshot.",\n [RUNTIME_008]: "Failed to load script resources.",\n [RUNTIME_009]: "Please call createInstance first.",\n [RUNTIME_010]: \'The name option cannot be changed after initialization. If you want to create a new instance with a different name, please use "createInstance" api.\',\n [RUNTIME_011]: "The remoteEntry URL is missing from the remote snapshot.",\n [RUNTIME_012]: \'The getter for the shared module is not a function. This may be caused by setting "shared.import: false" without the host providing the corresponding lib.\',\n [RUNTIME_013]: "The manifest is not a valid Module Federation manifest.",\n [RUNTIME_014]: "The remote does not expose the requested module.",\n [RUNTIME_015]: "Remote container initialization failed."\n};\n({\n ...runtimeDescMap\n});\nconst importCallback = ".then(callbacks[0]).catch(callbacks[1])";\nfunction isEsmRemoteType(type) {\n return type === "esm" || type === "module";\n}\nasync function loadEsmEntry({ entry, remoteEntryExports }) {\n return new Promise((resolve, reject) => {\n try {\n if (!remoteEntryExports) if (typeof FEDERATION_ALLOW_NEW_FUNCTION !== "undefined") new Function("callbacks", `import("${entry}")${importCallback}`)([resolve, reject]);\n else import(\n /* webpackIgnore: true */\n /* @vite-ignore */\n entry\n ).then(resolve).catch(reject);\n else resolve(remoteEntryExports);\n } catch (e) {\n error(`Failed to load ESM entry from "${entry}". ${e instanceof Error ? e.message : String(e)}`);\n }\n });\n}\nasync function loadSystemJsEntry({ entry, remoteEntryExports }) {\n return new Promise((resolve, reject) => {\n try {\n if (!remoteEntryExports) if (typeof __system_context__ === "undefined") System.import(entry).then(resolve).catch(reject);\n else new Function("callbacks", `System.import("${entry}")${importCallback}`)([resolve, reject]);\n else resolve(remoteEntryExports);\n } catch (e) {\n error(`Failed to load SystemJS entry from "${entry}". ${e instanceof Error ? e.message : String(e)}`);\n }\n });\n}\nfunction handleRemoteEntryLoaded(name, globalName, entry) {\n const { remoteEntryKey, entryExports } = getRemoteEntryExports(name, globalName);\n if (!entryExports) error(RUNTIME_001, runtimeDescMap, {\n remoteName: name,\n remoteEntryUrl: entry,\n remoteEntryKey\n });\n return entryExports;\n}\nasync function loadEntryScript({ name, globalName, entry, remoteInfo, loaderHook, getEntryUrl, resourceContext }) {\n const { entryExports: remoteEntryExports } = getRemoteEntryExports(name, globalName);\n if (remoteEntryExports) return remoteEntryExports;\n const url = getEntryUrl ? getEntryUrl(entry) : entry;\n return loadScript(url, {\n attrs: {},\n createScriptHook: (url2, attrs) => {\n const res = loaderHook.lifecycle.createScript.emit({\n url: url2,\n attrs,\n remoteInfo,\n resourceContext: resourceContext ? {\n ...resourceContext,\n url: url2\n } : void 0\n });\n if (!res) return;\n if (res instanceof HTMLScriptElement) return res;\n if ("script" in res || "timeout" in res) return res;\n }\n }).then(() => {\n return handleRemoteEntryLoaded(name, globalName, entry);\n }, (loadError) => {\n const originalMsg = loadError instanceof Error ? loadError.message : String(loadError);\n error(RUNTIME_008, runtimeDescMap, {\n remoteName: name,\n resourceUrl: url\n }, originalMsg);\n });\n}\nasync function loadEntryDom({ remoteInfo, remoteEntryExports, loaderHook, getEntryUrl, resourceContext }) {\n const { entry, entryGlobalName: globalName, name, type } = remoteInfo;\n if (isEsmRemoteType(type)) return loadEsmEntry({\n entry,\n remoteEntryExports\n });\n if (type === "system") return loadSystemJsEntry({\n entry,\n remoteEntryExports\n });\n return loadEntryScript({\n entry,\n globalName,\n name,\n remoteInfo,\n loaderHook,\n getEntryUrl,\n resourceContext\n });\n}\nasync function loadEntryNode({ remoteInfo, loaderHook, resourceContext }) {\n const { entry, entryGlobalName: globalName, name, type } = remoteInfo;\n const { entryExports: remoteEntryExports } = getRemoteEntryExports(name, globalName);\n if (remoteEntryExports) return remoteEntryExports;\n return loadScriptNode(entry, {\n attrs: {\n name,\n globalName,\n type\n },\n loaderHook: { createScriptHook: (url, attrs = {}) => {\n const res = loaderHook.lifecycle.createScript.emit({\n url,\n attrs,\n remoteInfo,\n resourceContext: resourceContext ? {\n ...resourceContext,\n url\n } : void 0\n });\n if (!res) return;\n if ("url" in res) return res;\n } }\n }).then(() => {\n return handleRemoteEntryLoaded(name, globalName, entry);\n }).catch((e) => {\n error(`Failed to load Node.js entry for remote "${name}" from "${entry}". ${e instanceof Error ? e.message : String(e)}`);\n });\n}\nfunction getRemoteEntryUniqueKey(remoteInfo) {\n const { entry, name } = remoteInfo;\n return composeKeyWithSeparator(name, entry);\n}\nasync function getRemoteEntry(params) {\n const { origin, remoteEntryExports, remoteInfo, getEntryUrl, resourceContext, _inErrorHandling = false } = params;\n const uniqueKey = getRemoteEntryUniqueKey(remoteInfo);\n if (remoteEntryExports) return remoteEntryExports;\n if (!globalLoading[uniqueKey]) {\n const loadEntryHook = origin.remoteHandler.hooks.lifecycle.loadEntry;\n const loaderHook = origin.loaderHook;\n globalLoading[uniqueKey] = loadEntryHook.emit({\n origin,\n loaderHook,\n remoteInfo,\n remoteEntryExports\n }).then((res) => {\n if (res) return res;\n return (typeof ENV_TARGET !== "undefined" ? ENV_TARGET === "web" : isBrowserEnvValue) ? loadEntryDom({\n remoteInfo,\n remoteEntryExports,\n loaderHook,\n getEntryUrl,\n resourceContext\n }) : loadEntryNode({\n remoteInfo,\n loaderHook,\n resourceContext\n });\n }).then(async (res) => {\n await origin.loaderHook.lifecycle.afterLoadEntry.emit({\n origin,\n remoteInfo,\n remoteEntryExports: res\n });\n return res;\n }).catch(async (err) => {\n const uniqueKey2 = getRemoteEntryUniqueKey(remoteInfo);\n const isScriptExecutionError = err instanceof Error && err.message.includes("ScriptExecutionError");\n if (err instanceof Error && err.message.includes(RUNTIME_008) && !isScriptExecutionError && !_inErrorHandling) {\n const wrappedGetRemoteEntry = (params2) => {\n return getRemoteEntry({\n ...params2,\n _inErrorHandling: true\n });\n };\n const RemoteEntryExports = await origin.loaderHook.lifecycle.loadEntryError.emit({\n getRemoteEntry: wrappedGetRemoteEntry,\n origin,\n remoteInfo,\n remoteEntryExports,\n globalLoading,\n uniqueKey: uniqueKey2\n });\n if (RemoteEntryExports) {\n await origin.loaderHook.lifecycle.afterLoadEntry.emit({\n origin,\n remoteInfo,\n remoteEntryExports: RemoteEntryExports,\n recovered: true\n });\n return RemoteEntryExports;\n }\n }\n await origin.loaderHook.lifecycle.afterLoadEntry.emit({\n origin,\n remoteInfo,\n error: err\n });\n throw err;\n });\n }\n return globalLoading[uniqueKey];\n}\nfunction getRemoteInfo(remote) {\n return {\n ...remote,\n entry: "entry" in remote ? remote.entry : "",\n type: remote.type || DEFAULT_REMOTE_TYPE,\n entryGlobalName: remote.entryGlobalName || remote.name,\n shareScope: remote.shareScope || DEFAULT_SCOPE\n };\n}\nfunction remoteToEntry(r) {\n return {\n name: r.name,\n alias: r.alias,\n entry: "entry" in r ? r.entry : void 0,\n version: "version" in r ? r.version : void 0,\n type: r.type,\n entryGlobalName: r.entryGlobalName,\n shareScope: r.shareScope\n };\n}\nfunction optionsToMFContext(options) {\n var _a, _b, _c, _d, _e, _f;\n const shared = {};\n for (const [pkgName, versions] of Object.entries(options.shared)) {\n const first = versions[0];\n if (first) shared[pkgName] = {\n version: first.version,\n singleton: (_a = first.shareConfig) == null ? void 0 : _a.singleton,\n requiredVersion: ((_b = first.shareConfig) == null ? void 0 : _b.requiredVersion) === false ? false : (_c = first.shareConfig) == null ? void 0 : _c.requiredVersion,\n eager: first.eager,\n strictVersion: (_d = first.shareConfig) == null ? void 0 : _d.strictVersion\n };\n }\n return {\n project: {\n name: options.name,\n mfRole: ((_e = options.remotes) == null ? void 0 : _e.length) > 0 ? "host" : "unknown"\n },\n mfConfig: {\n name: options.name,\n remotes: ((_f = options.remotes) == null ? void 0 : _f.map(remoteToEntry)) ?? [],\n shared\n }\n };\n}\nfunction isTimeoutError(error2) {\n if (!(error2 instanceof Error)) return false;\n return error2.message.includes("timed out") || error2.name.includes("Timeout");\n}\nfunction createAssetResult(context, url, status, error2) {\n return {\n url,\n status,\n resourceType: context.resourceType,\n initiator: context.initiator,\n id: context.id,\n error: error2\n };\n}\nasync function waitForRemoteEntryPreload(host, remoteInfo, entryRemoteInfo, context) {\n const cachedRemote = host.moduleCache.get(entryRemoteInfo.name);\n const url = entryRemoteInfo.entry;\n if (cachedRemote == null ? void 0 : cachedRemote.remoteEntryExports) return createAssetResult(context, url, "cached");\n try {\n if (!await getRemoteEntry({\n origin: host,\n remoteInfo: entryRemoteInfo,\n remoteEntryExports: cachedRemote == null ? void 0 : cachedRemote.remoteEntryExports,\n resourceContext: {\n ...context,\n url\n }\n })) throw new Error(`Failed to load remoteEntry "${url}".`);\n return createAssetResult(context, url, "success");\n } catch (error2) {\n return createAssetResult(context, url, isTimeoutError(error2) ? "timeout" : "error", error2);\n }\n}\nfunction waitForLinkPreload({ host, remoteInfo, url, attrs, context, needDeleteLink }) {\n return new Promise((resolve) => {\n const { link, needAttach } = createLink({\n url,\n cb: () => {\n resolve(createAssetResult(context, url, needAttach ? "success" : "cached"));\n },\n onErrorCallback: (error2) => {\n resolve(createAssetResult(context, url, isTimeoutError(error2) ? "timeout" : "error", error2));\n },\n attrs,\n createLinkHook: (hookUrl, hookAttrs) => {\n const res = host.loaderHook.lifecycle.createLink.emit({\n url: hookUrl,\n attrs: hookAttrs,\n remoteInfo,\n resourceContext: {\n ...context,\n url: hookUrl\n }\n });\n if (res instanceof HTMLLinkElement) return res;\n return res;\n },\n needDeleteLink\n });\n needAttach && document.head.appendChild(link);\n });\n}\nfunction waitForScriptPreload({ host, remoteInfo, url, attrs, context }) {\n return new Promise((resolve) => {\n const { script, needAttach } = createScript({\n url,\n cb: () => {\n resolve(createAssetResult(context, url, needAttach ? "success" : "cached"));\n },\n onErrorCallback: (error2) => {\n resolve(createAssetResult(context, url, isTimeoutError(error2) ? "timeout" : "error", error2));\n },\n attrs,\n createScriptHook: (hookUrl, hookAttrs) => {\n const res = host.loaderHook.lifecycle.createScript.emit({\n url: hookUrl,\n attrs: hookAttrs,\n remoteInfo,\n resourceContext: {\n ...context,\n url: hookUrl\n }\n });\n if (res instanceof HTMLScriptElement) return res;\n return res;\n },\n needDeleteScript: true\n });\n needAttach && document.head.appendChild(script);\n });\n}\nfunction createResourceContext(baseContext, resourceType) {\n return {\n ...baseContext,\n resourceType\n };\n}\nfunction preloadAssets(remoteInfo, host, assets, useLinkPreload = true, baseContext = {\n initiator: "preloadRemote",\n id: remoteInfo.name\n}) {\n const { cssAssets, jsAssetsWithoutEntry, entryAssets } = assets;\n const results = [];\n if (host.options.inBrowser) {\n entryAssets.forEach((asset) => {\n const { moduleInfo: entryRemoteInfo } = asset;\n results.push(waitForRemoteEntryPreload(host, remoteInfo, entryRemoteInfo, createResourceContext(baseContext, "remoteEntry")));\n });\n if (useLinkPreload) {\n const defaultAttrs2 = {\n rel: "preload",\n as: "style"\n };\n cssAssets.forEach((cssUrl) => {\n results.push(waitForLinkPreload({\n host,\n remoteInfo,\n url: cssUrl,\n attrs: defaultAttrs2,\n context: createResourceContext(baseContext, "css")\n }));\n });\n } else {\n const defaultAttrs2 = {\n rel: "stylesheet",\n type: "text/css"\n };\n cssAssets.forEach((cssUrl) => {\n results.push(waitForLinkPreload({\n host,\n remoteInfo,\n url: cssUrl,\n attrs: defaultAttrs2,\n needDeleteLink: false,\n context: createResourceContext(baseContext, "css")\n }));\n });\n }\n let preloadJsAsset = waitForScriptPreload;\n let defaultAttrs = {\n fetchpriority: "high",\n type: "text/javascript"\n };\n if (useLinkPreload) {\n preloadJsAsset = waitForLinkPreload;\n defaultAttrs = {\n rel: "preload",\n as: "script"\n };\n } else if (isEsmRemoteType(remoteInfo.type)) {\n preloadJsAsset = waitForLinkPreload;\n defaultAttrs = {\n rel: "modulepreload",\n fetchpriority: "high"\n };\n }\n jsAssetsWithoutEntry.forEach((jsUrl) => {\n results.push(preloadJsAsset({\n host,\n remoteInfo,\n url: jsUrl,\n attrs: defaultAttrs,\n context: createResourceContext(baseContext, "js")\n }));\n });\n }\n return Promise.all(results);\n}\nvar helpers_default = {\n utils: {\n matchRemoteWithNameAndExpose,\n preloadAssets,\n getRemoteInfo\n }\n};\nfunction getAvailableExposeNames(remoteSnapshot) {\n if (!remoteSnapshot || !("modules" in remoteSnapshot) || !Array.isArray(remoteSnapshot.modules)) return;\n const exposes = remoteSnapshot.modules.map((module) => module.moduleName).filter(Boolean);\n return exposes.length ? exposes.join(",") : void 0;\n}\nfunction createRemoteEntryInitOptions(remoteInfo, hostShareScopeMap, rawInitScope) {\n const localShareScopeMap = hostShareScopeMap;\n const shareScopeKeys = Array.isArray(remoteInfo.shareScope) ? remoteInfo.shareScope : [remoteInfo.shareScope];\n if (!shareScopeKeys.length) shareScopeKeys.push("default");\n shareScopeKeys.forEach((shareScopeKey) => {\n if (!localShareScopeMap[shareScopeKey]) localShareScopeMap[shareScopeKey] = {};\n });\n const remoteEntryInitOptions = {\n version: remoteInfo.version || "",\n shareScopeKeys: Array.isArray(remoteInfo.shareScope) ? shareScopeKeys : remoteInfo.shareScope || "default"\n };\n Object.defineProperty(remoteEntryInitOptions, "shareScopeMap", {\n value: localShareScopeMap,\n enumerable: false\n });\n return {\n remoteEntryInitOptions,\n shareScope: localShareScopeMap[shareScopeKeys[0]],\n initScope: rawInitScope ?? []\n };\n}\nvar Module$1 = class {\n constructor({ remoteInfo, host }) {\n this.inited = false;\n this.initing = false;\n this.lib = void 0;\n this.remoteInfo = remoteInfo;\n this.host = host;\n }\n async getEntry(expose) {\n if (this.remoteEntryExports) return this.remoteEntryExports;\n const remoteEntryExports = await getRemoteEntry({\n origin: this.host,\n remoteInfo: this.remoteInfo,\n remoteEntryExports: this.remoteEntryExports,\n resourceContext: {\n initiator: "loadRemote",\n id: composeRemoteRequestId(this.remoteInfo.name, expose),\n resourceType: "remoteEntry"\n }\n });\n assert(remoteEntryExports, `remoteEntryExports is undefined \n ${safeToString(this.remoteInfo)}`);\n this.remoteEntryExports = remoteEntryExports;\n return this.remoteEntryExports;\n }\n async init(id, remoteSnapshot, rawInitScope, expose) {\n const remoteEntryExports = await this.getEntry(expose);\n if (this.inited) {\n await this.host.loaderHook.lifecycle.afterInitRemote.emit({\n id,\n remoteInfo: this.remoteInfo,\n remoteSnapshot,\n remoteEntryExports,\n cached: true,\n origin: this.host\n });\n return remoteEntryExports;\n }\n if (this.initPromise) {\n try {\n await this.initPromise;\n await this.host.loaderHook.lifecycle.afterInitRemote.emit({\n id,\n remoteInfo: this.remoteInfo,\n remoteSnapshot,\n remoteEntryExports,\n cached: true,\n origin: this.host\n });\n } catch (initError) {\n await this.host.loaderHook.lifecycle.afterInitRemote.emit({\n id,\n remoteInfo: this.remoteInfo,\n remoteSnapshot,\n remoteEntryExports,\n error: initError,\n cached: true,\n origin: this.host\n });\n throw initError;\n }\n return remoteEntryExports;\n }\n this.initing = true;\n this.initPromise = (async () => {\n await this.host.loaderHook.lifecycle.beforeInitRemote.emit({\n id,\n remoteInfo: this.remoteInfo,\n remoteSnapshot,\n origin: this.host\n });\n const { remoteEntryInitOptions, shareScope, initScope } = createRemoteEntryInitOptions(this.remoteInfo, this.host.shareScopeMap, rawInitScope);\n const initContainerOptions = await this.host.hooks.lifecycle.beforeInitContainer.emit({\n shareScope,\n remoteEntryInitOptions,\n initScope,\n remoteInfo: this.remoteInfo,\n origin: this.host\n });\n if (typeof (remoteEntryExports == null ? void 0 : remoteEntryExports.init) === "undefined") error(RUNTIME_002, runtimeDescMap, {\n hostName: this.host.name,\n remoteName: this.remoteInfo.name,\n remoteEntryUrl: this.remoteInfo.entry,\n remoteEntryKey: this.remoteInfo.entryGlobalName\n }, void 0, optionsToMFContext(this.host.options));\n try {\n await remoteEntryExports.init(initContainerOptions.shareScope, initContainerOptions.initScope, initContainerOptions.remoteEntryInitOptions);\n } catch (initError) {\n error(RUNTIME_015, runtimeDescMap, {\n hostName: this.host.name,\n remoteName: this.remoteInfo.name,\n remoteEntryUrl: this.remoteInfo.entry,\n remoteEntryKey: this.remoteInfo.entryGlobalName,\n shareScope: this.remoteInfo.shareScope\n }, `${initError}`, optionsToMFContext(this.host.options));\n }\n await this.host.hooks.lifecycle.initContainer.emit({\n ...initContainerOptions,\n id,\n remoteSnapshot,\n remoteEntryExports\n });\n this.inited = true;\n })();\n try {\n await this.initPromise;\n await this.host.loaderHook.lifecycle.afterInitRemote.emit({\n id,\n remoteInfo: this.remoteInfo,\n remoteSnapshot,\n remoteEntryExports,\n origin: this.host\n });\n } catch (initError) {\n await this.host.loaderHook.lifecycle.afterInitRemote.emit({\n id,\n remoteInfo: this.remoteInfo,\n remoteSnapshot,\n remoteEntryExports,\n error: initError,\n origin: this.host\n });\n throw initError;\n } finally {\n this.initing = false;\n this.initPromise = void 0;\n }\n return remoteEntryExports;\n }\n async get(id, expose, options, remoteSnapshot) {\n const { loadFactory = true } = options || { loadFactory: true };\n const remoteEntryExports = await this.init(id, remoteSnapshot, void 0, expose);\n this.lib = remoteEntryExports;\n await this.host.loaderHook.lifecycle.beforeGetExpose.emit({\n id,\n expose,\n moduleInfo: this.remoteInfo,\n remoteEntryExports,\n origin: this.host\n });\n let moduleFactory;\n try {\n const hookModuleFactory = await this.host.loaderHook.lifecycle.getModuleFactory.emit({\n remoteEntryExports,\n expose,\n moduleInfo: this.remoteInfo\n });\n moduleFactory = typeof hookModuleFactory === "function" ? hookModuleFactory : void 0;\n if (!moduleFactory) moduleFactory = await remoteEntryExports.get(expose);\n if (!moduleFactory) error(RUNTIME_014, runtimeDescMap, {\n hostName: this.host.name,\n remoteName: this.remoteInfo.name,\n remoteEntryUrl: this.remoteInfo.entry,\n expose,\n requestId: id,\n availableExposes: getAvailableExposeNames(remoteSnapshot)\n }, void 0, optionsToMFContext(this.host.options));\n await this.host.loaderHook.lifecycle.afterGetExpose.emit({\n id,\n expose,\n moduleInfo: this.remoteInfo,\n remoteEntryExports,\n moduleFactory,\n origin: this.host\n });\n } catch (getExposeError) {\n await this.host.loaderHook.lifecycle.afterGetExpose.emit({\n id,\n expose,\n moduleInfo: this.remoteInfo,\n remoteEntryExports,\n error: getExposeError,\n origin: this.host\n });\n throw getExposeError;\n }\n const symbolName = processModuleAlias(this.remoteInfo.name, expose);\n const wrapModuleFactory = this.wraperFactory(moduleFactory, symbolName);\n if (!loadFactory) return wrapModuleFactory;\n await this.host.loaderHook.lifecycle.beforeExecuteFactory.emit({\n id,\n expose,\n moduleInfo: this.remoteInfo,\n loadFactory,\n origin: this.host\n });\n try {\n const exposeContent = await wrapModuleFactory();\n await this.host.loaderHook.lifecycle.afterExecuteFactory.emit({\n id,\n expose,\n moduleInfo: this.remoteInfo,\n loadFactory,\n exposeModule: exposeContent,\n origin: this.host\n });\n return exposeContent;\n } catch (executeFactoryError) {\n await this.host.loaderHook.lifecycle.afterExecuteFactory.emit({\n id,\n expose,\n moduleInfo: this.remoteInfo,\n loadFactory,\n error: executeFactoryError,\n origin: this.host\n });\n throw executeFactoryError;\n }\n }\n wraperFactory(moduleFactory, id) {\n function defineModuleId(res, id2) {\n if (res && typeof res === "object" && Object.isExtensible(res) && !Object.getOwnPropertyDescriptor(res, Symbol.for("mf_module_id"))) Object.defineProperty(res, Symbol.for("mf_module_id"), {\n value: id2,\n enumerable: false\n });\n }\n return () => {\n const res = moduleFactory();\n if (res instanceof Promise) return res.then((asyncRes) => {\n defineModuleId(asyncRes, id);\n return asyncRes;\n });\n defineModuleId(res, id);\n return res;\n };\n }\n};\nconst REMOTE_DISABLED_MESSAGE = "Remote loading is disabled by experiments.optimization.disableRemote.";\nvar UnavailableRemoteModule = class {\n constructor() {\n throw new Error(REMOTE_DISABLED_MESSAGE);\n }\n};\ntypeof FEDERATION_OPTIMIZE_NO_SNAPSHOT_PLUGIN === "boolean" ? !FEDERATION_OPTIMIZE_NO_SNAPSHOT_PLUGIN : true;\ntypeof FEDERATION_OPTIMIZE_NO_REMOTE === "boolean" ? !FEDERATION_OPTIMIZE_NO_REMOTE : true;\ntypeof FEDERATION_OPTIMIZE_NO_SHARED === "boolean" ? !FEDERATION_OPTIMIZE_NO_SHARED : true;\nconst helpers = helpers_default;\ntypeof FEDERATION_OPTIMIZE_NO_REMOTE === "boolean" && FEDERATION_OPTIMIZE_NO_REMOTE ? UnavailableRemoteModule : Module$1;\nconst utils = helpers.utils;\nconst runtimeHelpers = {\n utils\n};\nasync function prefetch(options) {\n const { instance, id, dataFetchParams, preloadComponentResource } = options;\n if (!id) {\n logger.error("id is required for prefetch!");\n return;\n }\n if (!instance) {\n logger.error("instance is required for prefetch!");\n return;\n }\n const matchedRemoteInfo = runtimeHelpers.utils.matchRemoteWithNameAndExpose(\n instance.options.remotes,\n id\n );\n if (!matchedRemoteInfo) {\n logger.error(`Can not found \'${id}\' in instance.options.remotes!`);\n return;\n }\n const { remote, expose } = matchedRemoteInfo;\n const { remoteSnapshot, globalSnapshot } = await instance.snapshotHandler.loadRemoteSnapshotInfo({\n moduleInfo: remote,\n id\n });\n if (preloadComponentResource) {\n const remoteInfo = runtimeHelpers.utils.getRemoteInfo(remote);\n Promise.resolve(\n instance.remoteHandler.hooks.lifecycle.generatePreloadAssets.emit({\n origin: instance,\n preloadOptions: {\n remote,\n preloadConfig: {\n nameOrAlias: remote.name,\n exposes: [expose]\n }\n },\n remote,\n remoteInfo,\n globalSnapshot,\n remoteSnapshot\n })\n ).then((assets) => {\n if (assets) {\n runtimeHelpers.utils.preloadAssets(remoteInfo, instance, assets);\n }\n });\n }\n const dataFetchMap = getDataFetchMap();\n if (!dataFetchMap) {\n return;\n }\n const dataFetchInfo = getDataFetchInfo({\n name: remote.name,\n alias: remote.alias,\n id,\n remoteSnapshot\n });\n const dataFetchMapKey = getDataFetchMapKey(dataFetchInfo, {\n name: instance.name,\n version: instance.options.version\n });\n if (!dataFetchMapKey) {\n return;\n }\n const dataFetchItem = dataFetchMap[dataFetchMapKey];\n if (!dataFetchItem) {\n return;\n }\n const [getDataFetchGetter, _type, getDataFetchPromise] = dataFetchItem[0];\n let _getDataFetchPromise = getDataFetchPromise;\n if (!getDataFetchPromise) {\n if (!getDataFetchGetter) {\n return;\n }\n _getDataFetchPromise = getDataFetchGetter();\n }\n _getDataFetchPromise.then((dataFetchFn) => {\n return dataFetchFn({\n ...dataFetchParams,\n _id: dataFetchMapKey,\n isDowngrade: false\n });\n });\n}\nexport {\n dataFetchFunction as d,\n injectDataFetch as i,\n prefetch as p\n};\n',
158
158
  "size-limited-cache.es.js": "var __defProp = Object.defineProperty;\nvar __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;\nvar __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== \"symbol\" ? key + \"\" : key, value);\nclass SizeLimitedCache {\n constructor(options) {\n __publicField(this, \"maxSize\");\n __publicField(this, \"entries\", /* @__PURE__ */ new Map());\n __publicField(this, \"sizeCalculation\");\n __publicField(this, \"currentSize\", 0);\n if (!Number.isInteger(options.maxSize) || options.maxSize <= 0) {\n throw new TypeError(\"maxSize must be a positive integer\");\n }\n this.maxSize = options.maxSize;\n this.sizeCalculation = options.sizeCalculation;\n }\n get size() {\n return this.entries.size;\n }\n get calculatedSize() {\n return this.currentSize;\n }\n get(key) {\n const entry = this.entries.get(key);\n if (!entry) {\n return void 0;\n }\n this.refresh(key, entry);\n return entry.value;\n }\n has(key) {\n const entry = this.entries.get(key);\n if (!entry) {\n return false;\n }\n this.refresh(key, entry);\n return true;\n }\n set(key, value, options = {}) {\n var _a;\n const entrySize = options.size ?? ((_a = this.sizeCalculation) == null ? void 0 : _a.call(this, value, key)) ?? 1;\n if (!Number.isInteger(entrySize) || entrySize <= 0) {\n throw new TypeError(\"entry size must be a positive integer\");\n }\n this.delete(key);\n if (entrySize > this.maxSize) {\n return this;\n }\n this.entries.set(key, { value, size: entrySize });\n this.currentSize += entrySize;\n this.evictUntilWithinLimit();\n return this;\n }\n delete(key) {\n const entry = this.entries.get(key);\n if (!entry) {\n return false;\n }\n this.currentSize -= entry.size;\n return this.entries.delete(key);\n }\n clear() {\n this.entries.clear();\n this.currentSize = 0;\n }\n refresh(key, entry) {\n this.entries.delete(key);\n this.entries.set(key, entry);\n }\n evictUntilWithinLimit() {\n while (this.currentSize > this.maxSize) {\n const oldest = this.entries.keys().next();\n if (oldest.done) {\n this.currentSize = 0;\n return;\n }\n this.delete(oldest.value);\n }\n }\n}\nexport {\n SizeLimitedCache\n};\n",
159
159
  "utils-BBP3hEeV.mjs": "import { S as SEPARATOR, c as createLogger, i as isBrowserEnvValue } from \"./logger-DwWkXsWl.mjs\";\nimport { SizeLimitedCache } from \"./size-limited-cache.es.js\";\nconst LOG_CATEGORY = \"[ Federation Runtime ]\";\nconst composeKeyWithSeparator = function(...args) {\n if (!args.length) return \"\";\n return args.reduce((sum, cur) => {\n if (!cur) return sum;\n if (!sum) return cur;\n return `${sum}${SEPARATOR}${cur}`;\n }, \"\");\n};\nconst warn = (msg) => {\n console.warn(`${LOG_CATEGORY}: ${msg}`);\n};\nfunction safeToString(info) {\n try {\n return JSON.stringify(info, null, 2);\n } catch (e) {\n return \"\";\n }\n}\nconst PLUGIN_IDENTIFIER = \"[ Module Federation React ]\";\nconst DOWNGRADE_KEY = \"_mfSSRDowngrade\";\nconst DATA_FETCH_FUNCTION = \"_mfDataFetch\";\nconst FS_HREF = \"_mfFSHref\";\nconst ERROR_TYPE = {\n DATA_FETCH: 1,\n LOAD_REMOTE: 2,\n UNKNOWN: 3\n};\nconst WRAP_DATA_FETCH_ID_IDENTIFIER = \"wrap_dfip_identifier\";\nvar MF_DATA_FETCH_TYPE = /* @__PURE__ */ ((MF_DATA_FETCH_TYPE2) => {\n MF_DATA_FETCH_TYPE2[MF_DATA_FETCH_TYPE2[\"FETCH_SERVER\"] = 1] = \"FETCH_SERVER\";\n MF_DATA_FETCH_TYPE2[MF_DATA_FETCH_TYPE2[\"FETCH_CLIENT\"] = 2] = \"FETCH_CLIENT\";\n return MF_DATA_FETCH_TYPE2;\n})(MF_DATA_FETCH_TYPE || {});\nvar MF_DATA_FETCH_STATUS = /* @__PURE__ */ ((MF_DATA_FETCH_STATUS2) => {\n MF_DATA_FETCH_STATUS2[MF_DATA_FETCH_STATUS2[\"LOADED\"] = 1] = \"LOADED\";\n MF_DATA_FETCH_STATUS2[MF_DATA_FETCH_STATUS2[\"LOADING\"] = 2] = \"LOADING\";\n MF_DATA_FETCH_STATUS2[MF_DATA_FETCH_STATUS2[\"AWAIT\"] = 0] = \"AWAIT\";\n MF_DATA_FETCH_STATUS2[MF_DATA_FETCH_STATUS2[\"ERROR\"] = 3] = \"ERROR\";\n return MF_DATA_FETCH_STATUS2;\n})(MF_DATA_FETCH_STATUS || {});\nconst DATA_FETCH_IDENTIFIER = \"data\";\nconst DATA_FETCH_CLIENT_SUFFIX = \".client\";\nconst DATA_FETCH_QUERY = \"x-mf-data-fetch\";\nconst DATA_FETCH_ERROR_PREFIX = \"caught the following error during dataFetch: \";\nconst LOAD_REMOTE_ERROR_PREFIX = \"caught the following error during loadRemote: \";\nconst logger = createLogger(PLUGIN_IDENTIFIER);\nconst CacheSize = {\n KB: 1024,\n MB: 1024 * 1024,\n GB: 1024 * 1024 * 1024\n};\nconst CacheTime = {\n SECOND: 1e3,\n MINUTE: 60 * 1e3,\n HOUR: 60 * 60 * 1e3,\n DAY: 24 * 60 * 60 * 1e3,\n WEEK: 7 * 24 * 60 * 60 * 1e3,\n MONTH: 30 * 24 * 60 * 60 * 1e3\n};\nfunction getTagKeyMap() {\n const dataFetchCache = getDataFetchCache();\n if (!dataFetchCache || !dataFetchCache.tagKeyMap) {\n const tagKeyMap = /* @__PURE__ */ new Map();\n globalThis.__MF_DATA_FETCH_CACHE__ || (globalThis.__MF_DATA_FETCH_CACHE__ = {});\n globalThis.__MF_DATA_FETCH_CACHE__.tagKeyMap = tagKeyMap;\n return tagKeyMap;\n }\n return dataFetchCache.tagKeyMap;\n}\nfunction addTagKeyRelation(tag, key) {\n const tagKeyMap = getTagKeyMap();\n let keys = tagKeyMap.get(tag);\n if (!keys) {\n keys = /* @__PURE__ */ new Set();\n tagKeyMap.set(tag, keys);\n }\n keys.add(key);\n}\nfunction getCacheConfig() {\n const dataFetchCache = getDataFetchCache();\n if (!dataFetchCache || !dataFetchCache.cacheConfig) {\n const cacheConfig = {\n maxSize: CacheSize.GB\n };\n globalThis.__MF_DATA_FETCH_CACHE__ || (globalThis.__MF_DATA_FETCH_CACHE__ = {});\n globalThis.__MF_DATA_FETCH_CACHE__.cacheConfig = cacheConfig;\n return cacheConfig;\n }\n return dataFetchCache.cacheConfig;\n}\nfunction configureCache(config) {\n const cacheConfig = getCacheConfig();\n Object.assign(cacheConfig, config);\n}\nfunction getSizeLimitedCache() {\n const dataFetchCache = getDataFetchCache();\n const cacheConfig = getCacheConfig();\n if (!dataFetchCache || !dataFetchCache.cacheStore) {\n const cacheStore = new SizeLimitedCache({\n maxSize: cacheConfig.maxSize ?? CacheSize.GB,\n sizeCalculation: (value) => {\n if (!value.size) {\n return 1;\n }\n let size = 0;\n for (const [k, item] of value.entries()) {\n size += k.length * 2;\n size += estimateObjectSize(item.data);\n size += 8;\n }\n return size;\n }\n });\n globalThis.__MF_DATA_FETCH_CACHE__ || (globalThis.__MF_DATA_FETCH_CACHE__ = {});\n globalThis.__MF_DATA_FETCH_CACHE__.cacheStore = cacheStore;\n return cacheStore;\n }\n return dataFetchCache.cacheStore;\n}\nfunction estimateObjectSize(data) {\n const type = typeof data;\n if (type === \"number\") return 8;\n if (type === \"boolean\") return 4;\n if (type === \"string\") return Math.max(data.length * 2, 1);\n if (data === null || data === void 0) return 1;\n if (ArrayBuffer.isView(data)) {\n return Math.max(data.byteLength, 1);\n }\n if (Array.isArray(data)) {\n return Math.max(\n data.reduce((acc, item) => acc + estimateObjectSize(item), 0),\n 1\n );\n }\n if (data instanceof Map || data instanceof Set) {\n return 1024;\n }\n if (data instanceof Date) {\n return 8;\n }\n if (type === \"object\") {\n return Math.max(\n Object.entries(data).reduce(\n (acc, [key, value]) => acc + key.length * 2 + estimateObjectSize(value),\n 0\n ),\n 1\n );\n }\n return 1;\n}\nfunction generateKey(dataFetchOptions) {\n return JSON.stringify(dataFetchOptions, (_, value) => {\n if (value && typeof value === \"object\" && !Array.isArray(value)) {\n return Object.keys(value).sort().reduce((result, key) => {\n result[key] = value[key];\n return result;\n }, {});\n }\n return value;\n });\n}\nfunction cache(fn, options) {\n const {\n tag = \"default\",\n maxAge = CacheTime.MINUTE * 5,\n revalidate = 0,\n onCache,\n getKey\n } = options || {};\n const tags = Array.isArray(tag) ? tag : [tag];\n return async (dataFetchOptions) => {\n if (dataFetchOptions.isDowngrade || !dataFetchOptions._id) {\n return fn(dataFetchOptions);\n }\n const store = getSizeLimitedCache();\n const now = Date.now();\n const storeKey = dataFetchOptions._id;\n const cacheKey = getKey ? getKey(dataFetchOptions) : generateKey(dataFetchOptions);\n tags.forEach((t) => addTagKeyRelation(t, cacheKey));\n let cacheStore = store.get(cacheKey);\n if (!cacheStore) {\n cacheStore = /* @__PURE__ */ new Map();\n }\n const cached = cacheStore.get(storeKey);\n if (cached) {\n const age = now - cached.timestamp;\n if (age < maxAge) {\n if (onCache) {\n const useCache = onCache({\n status: \"hit\",\n key: cacheKey,\n params: dataFetchOptions,\n result: cached.data\n });\n if (!useCache) {\n return fn(dataFetchOptions);\n }\n }\n return cached.data;\n }\n if (revalidate > 0 && age < maxAge + revalidate) {\n if (onCache) {\n onCache({\n status: \"stale\",\n key: cacheKey,\n params: dataFetchOptions,\n result: cached.data\n });\n }\n if (!cached.isRevalidating) {\n cached.isRevalidating = true;\n Promise.resolve().then(async () => {\n try {\n const newData = await fn(dataFetchOptions);\n cacheStore.set(storeKey, {\n data: newData,\n timestamp: Date.now(),\n isRevalidating: false\n });\n store.set(cacheKey, cacheStore);\n } catch (error) {\n cached.isRevalidating = false;\n console.error(\"Background revalidation failed:\", error);\n }\n });\n }\n return cached.data;\n }\n }\n const data = await fn(dataFetchOptions);\n cacheStore.set(storeKey, {\n data,\n timestamp: now,\n isRevalidating: false\n });\n store.set(cacheKey, cacheStore);\n if (onCache) {\n onCache({\n status: \"miss\",\n key: cacheKey,\n params: dataFetchOptions,\n result: data\n });\n }\n return data;\n };\n}\nfunction revalidateTag(tag) {\n const tagKeyMap = getTagKeyMap();\n const keys = tagKeyMap.get(tag);\n const cacheStore = getSizeLimitedCache();\n if (keys) {\n keys.forEach((key) => {\n cacheStore == null ? void 0 : cacheStore.delete(key);\n });\n }\n}\nfunction clearStore() {\n var _a;\n const cacheStore = getSizeLimitedCache();\n const tagKeyMap = getTagKeyMap();\n cacheStore == null ? void 0 : cacheStore.clear();\n (_a = globalThis.__MF_DATA_FETCH_CACHE__) == null ? true : delete _a.cacheStore;\n tagKeyMap.clear();\n}\nconst getDataFetchInfo = ({\n name,\n alias,\n id,\n remoteSnapshot\n}) => {\n if (!remoteSnapshot) {\n return;\n }\n if (!(\"modules\" in remoteSnapshot)) {\n return;\n }\n const regex = new RegExp(`^${name}(/[^/].*|)$`);\n const nameOrAlias = regex.test(id) ? name : alias || name;\n const expose = id.replace(nameOrAlias, \"\");\n let dataFetchName = \"\";\n let dataFetchId = \"\";\n let dataFetchKey = \"\";\n if (expose.startsWith(\"/\")) {\n dataFetchName = `${expose.slice(1)}.${DATA_FETCH_IDENTIFIER}`;\n dataFetchId = `${id}.${DATA_FETCH_IDENTIFIER}`;\n dataFetchKey = `${name}${expose}.${DATA_FETCH_IDENTIFIER}`;\n } else if (expose === \"\") {\n dataFetchName = DATA_FETCH_IDENTIFIER;\n dataFetchId = `${id}/${DATA_FETCH_IDENTIFIER}`;\n dataFetchKey = `${name}/${DATA_FETCH_IDENTIFIER}`;\n } else {\n return;\n }\n if (!dataFetchName || !dataFetchId || !dataFetchKey) {\n return;\n }\n if (!remoteSnapshot.modules.find(\n (module) => module.moduleName === dataFetchName\n )) {\n return;\n }\n return {\n dataFetchName,\n dataFetchId,\n dataFetchKey\n };\n};\nfunction initDataFetchMap() {\n globalThis.__MF_DATA_FETCH_MAP__ || (globalThis.__MF_DATA_FETCH_MAP__ = {});\n}\nfunction getDataFetchItem(id) {\n var _a;\n return (_a = globalThis.__MF_DATA_FETCH_MAP__) == null ? void 0 : _a[id];\n}\nfunction getDataFetchMap() {\n return globalThis.__MF_DATA_FETCH_MAP__;\n}\nfunction getDataFetchCache() {\n return globalThis.__MF_DATA_FETCH_CACHE__;\n}\nconst flushDataFetch = () => {\n globalThis.__MF_DATA_FETCH_MAP__ = {};\n globalThis[DOWNGRADE_KEY] = void 0;\n clearStore();\n};\nfunction setDataFetchItemLoadedStatus(id) {\n const dataFetchItem = getDataFetchItem(id);\n if (!dataFetchItem) {\n return;\n }\n dataFetchItem[2] = MF_DATA_FETCH_STATUS.LOADED;\n}\nconst wrapDataFetchId = (id) => {\n return `${WRAP_DATA_FETCH_ID_IDENTIFIER}${id}${WRAP_DATA_FETCH_ID_IDENTIFIER}`;\n};\nconst getDataFetchIdWithErrorMsgs = (errMsgs) => {\n const firstIdentifierIndex = errMsgs.indexOf(WRAP_DATA_FETCH_ID_IDENTIFIER);\n if (firstIdentifierIndex === -1) {\n return void 0;\n }\n const secondIdentifierIndex = errMsgs.indexOf(\n WRAP_DATA_FETCH_ID_IDENTIFIER,\n firstIdentifierIndex + WRAP_DATA_FETCH_ID_IDENTIFIER.length\n );\n if (secondIdentifierIndex === -1) {\n return void 0;\n }\n return errMsgs.substring(\n firstIdentifierIndex + WRAP_DATA_FETCH_ID_IDENTIFIER.length,\n secondIdentifierIndex\n );\n};\nasync function fetchData(id, params, remoteInfo) {\n var _a;\n const callFetchData = async () => {\n const item = getDataFetchItem(id);\n if (!item) {\n return;\n }\n const [fetchDataFnArr, ..._rest] = item;\n const fetchDataFn = await fetchDataFnArr[2];\n if (!fetchDataFn) {\n return;\n }\n return fetchDataFn({\n ...params,\n _id: id\n });\n };\n if (isBrowserEnvValue) {\n const dataFetchItem = getDataFetchItem(id);\n if (!dataFetchItem) {\n throw new Error(`dataFetchItem not found, id: ${id}`);\n }\n if ((_a = dataFetchItem[1]) == null ? void 0 : _a[0]) {\n return dataFetchItem[1][0];\n }\n if (isCSROnly()) {\n logger.debug(\"==========csr only!\");\n return callFetchData();\n }\n if (remoteInfo) {\n return callDowngrade(id, params, remoteInfo);\n }\n const mfDowngrade = getDowngradeTag();\n if (mfDowngrade && (typeof mfDowngrade === \"boolean\" || mfDowngrade.includes(id))) {\n return callDowngrade(id, { ...params, isDowngrade: true });\n }\n let res;\n let rej;\n const p = new Promise((resolve, reject) => {\n res = resolve;\n rej = reject;\n });\n dataFetchItem[1] = [p, res, rej];\n dataFetchItem[2] = MF_DATA_FETCH_STATUS.AWAIT;\n return dataFetchItem[1][0];\n }\n return callFetchData();\n}\nfunction getDataFetchMapKey(dataFetchInfo, hostInfo) {\n if (!dataFetchInfo || !hostInfo) {\n return;\n }\n const { dataFetchKey } = dataFetchInfo;\n return composeKeyWithSeparator(dataFetchKey, hostInfo.name, hostInfo.version);\n}\nasync function loadDataFetchModule(instance, id) {\n return instance.loadRemote(id).then((m) => {\n if (m && typeof m === \"object\" && \"fetchData\" in m && typeof m.fetchData === \"function\") {\n return m.fetchData;\n }\n throw new Error(\n `fetchData not found in remote ${id}, ${JSON.stringify(m)}`\n );\n });\n}\nfunction isDataLoaderExpose(exposeKey) {\n return exposeKey.endsWith(DATA_FETCH_IDENTIFIER) || exposeKey.endsWith(DATA_FETCH_CLIENT_SUFFIX);\n}\nfunction getDowngradeTag() {\n return globalThis[DOWNGRADE_KEY];\n}\nfunction callAllDowngrade() {\n const dataFetchMap = getDataFetchMap();\n if (!dataFetchMap) {\n return;\n }\n Object.keys(dataFetchMap).forEach((key) => {\n callDowngrade(key);\n });\n}\nasync function callDowngrade(id, params, remoteInfo) {\n const dataFetchMap = getDataFetchMap();\n if (!dataFetchMap) {\n return;\n }\n const mfDataFetch = dataFetchMap[id];\n if ((mfDataFetch == null ? void 0 : mfDataFetch[2]) === MF_DATA_FETCH_STATUS.AWAIT) {\n mfDataFetch[2] = MF_DATA_FETCH_STATUS.LOADING;\n let promise;\n let res;\n let rej;\n if (mfDataFetch[1]) {\n promise = mfDataFetch[1][0];\n res = mfDataFetch[1][1];\n rej = mfDataFetch[1][2];\n } else {\n promise = new Promise((resolve, reject) => {\n res = resolve;\n rej = reject;\n });\n mfDataFetch[1] = [promise, res, rej];\n }\n const dataFetchType = mfDataFetch[0][1];\n if (dataFetchType === MF_DATA_FETCH_TYPE.FETCH_CLIENT) {\n try {\n mfDataFetch[0][0]().then(async (getDataFetchFn) => {\n return getDataFetchFn({\n ...params,\n isDowngrade: true,\n _id: id\n }).then((data) => {\n mfDataFetch[2] = MF_DATA_FETCH_STATUS.LOADED;\n res && res(data);\n });\n });\n } catch (e) {\n mfDataFetch[2] = MF_DATA_FETCH_STATUS.ERROR;\n rej && rej(e);\n }\n } else if (dataFetchType === MF_DATA_FETCH_TYPE.FETCH_SERVER) {\n try {\n const currentUrl = new URL(window.location.href);\n currentUrl.searchParams.set(DATA_FETCH_QUERY, encodeURIComponent(id));\n if (params) {\n currentUrl.searchParams.set(\n \"params\",\n encodeURIComponent(JSON.stringify(params))\n );\n }\n if (remoteInfo) {\n currentUrl.searchParams.set(\n \"remoteInfo\",\n encodeURIComponent(JSON.stringify(remoteInfo))\n );\n }\n const fetchServerQuery = globalThis.FEDERATION_SERVER_QUERY;\n if (fetchServerQuery && typeof fetchServerQuery === \"object\") {\n Object.keys(fetchServerQuery).forEach((key) => {\n currentUrl.searchParams.set(\n key,\n JSON.stringify(fetchServerQuery[key])\n );\n });\n }\n const fetchUrl = currentUrl.toString();\n const data = await fetch(fetchUrl).then((res2) => res2.json());\n mfDataFetch[2] = MF_DATA_FETCH_STATUS.LOADED;\n res && res(data);\n } catch (e) {\n mfDataFetch[2] = MF_DATA_FETCH_STATUS.ERROR;\n rej && rej(e);\n }\n }\n return promise;\n }\n}\nfunction isCSROnly() {\n return window._SSR_DATA === void 0;\n}\nfunction isServerEnv() {\n return typeof window === \"undefined\";\n}\nfunction setSSREnv({\n fetchServerQuery\n}) {\n globalThis.FEDERATION_SSR = true;\n globalThis.FEDERATION_SERVER_QUERY = fetchServerQuery;\n}\nfunction getLoadedRemoteInfos(id, instance) {\n if (!instance) {\n return;\n }\n const { name, expose } = instance.remoteHandler.idToRemoteMap[id] || {};\n if (!name) {\n return;\n }\n const module = instance.moduleCache.get(name);\n if (!module) {\n return;\n }\n const { remoteSnapshot } = instance.snapshotHandler.getGlobalRemoteInfo(\n module.remoteInfo\n );\n return {\n ...module.remoteInfo,\n snapshot: remoteSnapshot,\n expose\n };\n}\nexport {\n setDataFetchItemLoadedStatus as A,\n warn as B,\n CacheSize as C,\n DATA_FETCH_QUERY as D,\n ERROR_TYPE as E,\n FS_HREF as F,\n DOWNGRADE_KEY as G,\n callAllDowngrade as H,\n callDowngrade as I,\n getDowngradeTag as J,\n composeKeyWithSeparator as K,\n LOAD_REMOTE_ERROR_PREFIX as L,\n MF_DATA_FETCH_STATUS as M,\n safeToString as N,\n getDataFetchCache as O,\n CacheTime as a,\n clearStore as b,\n cache as c,\n configureCache as d,\n getDataFetchMap as e,\n flushDataFetch as f,\n generateKey as g,\n fetchData as h,\n initDataFetchMap as i,\n loadDataFetchModule as j,\n isDataLoaderExpose as k,\n logger as l,\n getDataFetchInfo as m,\n getDataFetchMapKey as n,\n getDataFetchItem as o,\n DATA_FETCH_CLIENT_SUFFIX as p,\n MF_DATA_FETCH_TYPE as q,\n revalidateTag as r,\n setSSREnv as s,\n isCSROnly as t,\n isServerEnv as u,\n getDataFetchIdWithErrorMsgs as v,\n DATA_FETCH_ERROR_PREFIX as w,\n wrapDataFetchId as x,\n DATA_FETCH_FUNCTION as y,\n getLoadedRemoteInfos as z\n};\n"
160
160
  };