@module-federation/bridge-react 0.0.0-docs-remove-invalid-lark-link-20251205062649

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.
Files changed (112) hide show
  1. package/CHANGELOG.md +728 -0
  2. package/LICENSE +21 -0
  3. package/README.md +131 -0
  4. package/__tests__/bridge.spec.tsx +160 -0
  5. package/__tests__/createLazyComponent.spec.tsx +209 -0
  6. package/__tests__/prefetch.spec.ts +156 -0
  7. package/__tests__/router.spec.tsx +82 -0
  8. package/__tests__/setupTests.ts +8 -0
  9. package/__tests__/util.ts +36 -0
  10. package/dist/base.cjs.js +29 -0
  11. package/dist/base.d.ts +311 -0
  12. package/dist/base.es.js +30 -0
  13. package/dist/bridge-base-CPSTBjEp.mjs +211 -0
  14. package/dist/bridge-base-RStDxH71.js +226 -0
  15. package/dist/createHelpers-B_L612IN.js +190 -0
  16. package/dist/createHelpers-Ui5pt7je.mjs +191 -0
  17. package/dist/data-fetch-server-middleware.cjs.js +163 -0
  18. package/dist/data-fetch-server-middleware.d.ts +15 -0
  19. package/dist/data-fetch-server-middleware.es.js +164 -0
  20. package/dist/data-fetch-utils.cjs.js +24 -0
  21. package/dist/data-fetch-utils.d.ts +81 -0
  22. package/dist/data-fetch-utils.es.js +26 -0
  23. package/dist/index-DRSBaSu3.js +45 -0
  24. package/dist/index-DyQNwY2M.mjs +46 -0
  25. package/dist/index.cjs.js +125 -0
  26. package/dist/index.d.ts +299 -0
  27. package/dist/index.es.js +109 -0
  28. package/dist/index.esm-BWaKho-8.js +491 -0
  29. package/dist/index.esm-CPwSeCvw.mjs +492 -0
  30. package/dist/lazy-load-component-plugin-CSRkMmKF.js +521 -0
  31. package/dist/lazy-load-component-plugin-DXqhuywC.mjs +522 -0
  32. package/dist/lazy-load-component-plugin.cjs.js +6 -0
  33. package/dist/lazy-load-component-plugin.d.ts +16 -0
  34. package/dist/lazy-load-component-plugin.es.js +6 -0
  35. package/dist/lazy-utils.cjs.js +24 -0
  36. package/dist/lazy-utils.d.ts +149 -0
  37. package/dist/lazy-utils.es.js +24 -0
  38. package/dist/plugin.cjs.js +14 -0
  39. package/dist/plugin.d.ts +22 -0
  40. package/dist/plugin.es.js +14 -0
  41. package/dist/prefetch-A3QkU5oZ.js +1272 -0
  42. package/dist/prefetch-zMJL79zx.mjs +1273 -0
  43. package/dist/router-v5.cjs.js +55 -0
  44. package/dist/router-v5.d.ts +18 -0
  45. package/dist/router-v5.es.js +32 -0
  46. package/dist/router-v6.cjs.js +84 -0
  47. package/dist/router-v6.d.ts +20 -0
  48. package/dist/router-v6.es.js +61 -0
  49. package/dist/router-v7.cjs.js +83 -0
  50. package/dist/router-v7.d.ts +20 -0
  51. package/dist/router-v7.es.js +61 -0
  52. package/dist/router.cjs.js +82 -0
  53. package/dist/router.d.ts +20 -0
  54. package/dist/router.es.js +60 -0
  55. package/dist/utils-dUgb9Jkm.mjs +2016 -0
  56. package/dist/utils-tM9yE73c.js +2015 -0
  57. package/dist/v18.cjs.js +15 -0
  58. package/dist/v18.d.ts +114 -0
  59. package/dist/v18.es.js +15 -0
  60. package/dist/v19.cjs.js +15 -0
  61. package/dist/v19.d.ts +115 -0
  62. package/dist/v19.es.js +15 -0
  63. package/jest.config.ts +21 -0
  64. package/package.json +173 -0
  65. package/project.json +23 -0
  66. package/src/base.ts +50 -0
  67. package/src/index.ts +50 -0
  68. package/src/lazy/AwaitDataFetch.tsx +215 -0
  69. package/src/lazy/constant.ts +30 -0
  70. package/src/lazy/createLazyComponent.tsx +411 -0
  71. package/src/lazy/data-fetch/cache.ts +291 -0
  72. package/src/lazy/data-fetch/call-data-fetch.ts +13 -0
  73. package/src/lazy/data-fetch/data-fetch-server-middleware.ts +196 -0
  74. package/src/lazy/data-fetch/index.ts +16 -0
  75. package/src/lazy/data-fetch/inject-data-fetch.ts +109 -0
  76. package/src/lazy/data-fetch/prefetch.ts +112 -0
  77. package/src/lazy/data-fetch/runtime-plugin.ts +115 -0
  78. package/src/lazy/index.ts +35 -0
  79. package/src/lazy/logger.ts +6 -0
  80. package/src/lazy/types.ts +75 -0
  81. package/src/lazy/utils.ts +372 -0
  82. package/src/lazy/wrapNoSSR.tsx +10 -0
  83. package/src/modern-app-env.d.ts +2 -0
  84. package/src/plugins/lazy-load-component-plugin.spec.ts +21 -0
  85. package/src/plugins/lazy-load-component-plugin.ts +57 -0
  86. package/src/provider/context.tsx +4 -0
  87. package/src/provider/plugin.ts +22 -0
  88. package/src/provider/versions/bridge-base.tsx +150 -0
  89. package/src/provider/versions/legacy.ts +87 -0
  90. package/src/provider/versions/v18.ts +47 -0
  91. package/src/provider/versions/v19.ts +48 -0
  92. package/src/remote/RemoteAppWrapper.tsx +108 -0
  93. package/src/remote/base-component/component.tsx +2 -0
  94. package/src/remote/base-component/create.tsx +23 -0
  95. package/src/remote/base-component/index.tsx +10 -0
  96. package/src/remote/createHelpers.tsx +130 -0
  97. package/src/remote/router-component/component.tsx +104 -0
  98. package/src/remote/router-component/create.tsx +23 -0
  99. package/src/remote/router-component/index.tsx +10 -0
  100. package/src/router/default.tsx +73 -0
  101. package/src/router/v5.tsx +43 -0
  102. package/src/router/v6.tsx +74 -0
  103. package/src/router/v7.tsx +75 -0
  104. package/src/types.ts +147 -0
  105. package/src/utils/index.ts +44 -0
  106. package/src/v18.ts +9 -0
  107. package/src/v19.ts +9 -0
  108. package/tsconfig.json +42 -0
  109. package/tsconfig.node.json +11 -0
  110. package/tsconfig.spec.json +26 -0
  111. package/vite.config.ts +112 -0
  112. package/vitest.config.ts +27 -0
@@ -0,0 +1,1272 @@
1
+ "use strict";
2
+ const lazyUtils = require("./utils-tM9yE73c.js");
3
+ const index_esm = require("./index.esm-BWaKho-8.js");
4
+ const dataFetchFunction = async function(options) {
5
+ var _a, _b;
6
+ const [id, data, downgrade] = options;
7
+ lazyUtils.logger.debug("==========call data fetch function!");
8
+ if (data) {
9
+ if (!id) {
10
+ throw new Error("id is required!");
11
+ }
12
+ if (!lazyUtils.getDataFetchMap()) {
13
+ lazyUtils.initDataFetchMap();
14
+ }
15
+ const dataFetchItem = lazyUtils.getDataFetchItem(id);
16
+ if (dataFetchItem) {
17
+ (_b = (_a = dataFetchItem[1]) == null ? void 0 : _a[1]) == null ? void 0 : _b.call(_a, data);
18
+ dataFetchItem[2] = lazyUtils.MF_DATA_FETCH_STATUS.LOADED;
19
+ return;
20
+ }
21
+ if (!dataFetchItem) {
22
+ const dataFetchMap = lazyUtils.getDataFetchMap();
23
+ let res;
24
+ let rej;
25
+ const p = new Promise((resolve, reject) => {
26
+ res = resolve;
27
+ rej = reject;
28
+ });
29
+ dataFetchMap[id] = [
30
+ [
31
+ async () => async () => {
32
+ return "";
33
+ },
34
+ lazyUtils.MF_DATA_FETCH_TYPE.FETCH_SERVER
35
+ ],
36
+ [p, res, rej],
37
+ lazyUtils.MF_DATA_FETCH_STATUS.LOADED
38
+ ];
39
+ res && res(data);
40
+ return;
41
+ }
42
+ }
43
+ if (downgrade) {
44
+ const mfDowngrade2 = lazyUtils.getDowngradeTag();
45
+ if (!mfDowngrade2) {
46
+ globalThis[lazyUtils.DOWNGRADE_KEY] = id ? [id] : true;
47
+ } else if (Array.isArray(mfDowngrade2) && id && !mfDowngrade2.includes(id)) {
48
+ mfDowngrade2.push(id);
49
+ }
50
+ }
51
+ const mfDowngrade = lazyUtils.getDowngradeTag();
52
+ if (typeof mfDowngrade === "boolean") {
53
+ return lazyUtils.callAllDowngrade();
54
+ }
55
+ if (Array.isArray(mfDowngrade)) {
56
+ if (!id) {
57
+ globalThis[lazyUtils.DOWNGRADE_KEY] = true;
58
+ return lazyUtils.callAllDowngrade();
59
+ }
60
+ if (!mfDowngrade.includes(id)) {
61
+ mfDowngrade.push(id);
62
+ }
63
+ return lazyUtils.callDowngrade(id);
64
+ }
65
+ };
66
+ function injectDataFetch() {
67
+ var _a;
68
+ globalThis[_a = lazyUtils.DATA_FETCH_FUNCTION] || (globalThis[_a] = []);
69
+ const dataFetch = globalThis[lazyUtils.DATA_FETCH_FUNCTION];
70
+ if (dataFetch.push === dataFetchFunction) {
71
+ return;
72
+ }
73
+ if (typeof window === "undefined") {
74
+ return;
75
+ }
76
+ globalThis[lazyUtils.FS_HREF] = window.location.href;
77
+ dataFetch.push = dataFetchFunction;
78
+ }
79
+ const RUNTIME_001 = "RUNTIME-001";
80
+ const RUNTIME_002 = "RUNTIME-002";
81
+ const RUNTIME_003 = "RUNTIME-003";
82
+ const RUNTIME_004 = "RUNTIME-004";
83
+ const RUNTIME_005 = "RUNTIME-005";
84
+ const RUNTIME_006 = "RUNTIME-006";
85
+ const RUNTIME_007 = "RUNTIME-007";
86
+ const RUNTIME_008 = "RUNTIME-008";
87
+ const RUNTIME_009 = "RUNTIME-009";
88
+ const getDocsUrl = (errorCode) => {
89
+ const type = errorCode.split("-")[0].toLowerCase();
90
+ return `View the docs to see how to solve: https://module-federation.io/guide/troubleshooting/${type}/${errorCode}`;
91
+ };
92
+ const getShortErrorMsg = (errorCode, errorDescMap, args, originalErrorMsg) => {
93
+ const msg = [`${[errorDescMap[errorCode]]} #${errorCode}`];
94
+ args && msg.push(`args: ${JSON.stringify(args)}`);
95
+ msg.push(getDocsUrl(errorCode));
96
+ return msg.join("\n");
97
+ };
98
+ const runtimeDescMap = {
99
+ [RUNTIME_001]: "Failed to get remoteEntry exports.",
100
+ [RUNTIME_002]: 'The remote entry interface does not contain "init"',
101
+ [RUNTIME_003]: "Failed to get manifest.",
102
+ [RUNTIME_004]: "Failed to locate remote.",
103
+ [RUNTIME_005]: "Invalid loadShareSync function call from bundler runtime",
104
+ [RUNTIME_006]: "Invalid loadShareSync function call from runtime",
105
+ [RUNTIME_007]: "Failed to get remote snapshot.",
106
+ [RUNTIME_008]: "Failed to load script resources.",
107
+ [RUNTIME_009]: "Please call createInstance first."
108
+ };
109
+ ({
110
+ ...runtimeDescMap
111
+ });
112
+ const LOG_CATEGORY = "[ Federation Runtime ]";
113
+ const logger = index_esm.createLogger(LOG_CATEGORY);
114
+ function assert(condition, msg) {
115
+ if (!condition) {
116
+ error(msg);
117
+ }
118
+ }
119
+ function error(msg) {
120
+ if (msg instanceof Error) {
121
+ if (!msg.message.startsWith(LOG_CATEGORY)) {
122
+ msg.message = `${LOG_CATEGORY}: ${msg.message}`;
123
+ }
124
+ throw msg;
125
+ }
126
+ throw new Error(`${LOG_CATEGORY}: ${msg}`);
127
+ }
128
+ function warn(msg) {
129
+ if (msg instanceof Error) {
130
+ if (!msg.message.startsWith(LOG_CATEGORY)) {
131
+ msg.message = `${LOG_CATEGORY}: ${msg.message}`;
132
+ }
133
+ logger.warn(msg);
134
+ } else {
135
+ logger.warn(msg);
136
+ }
137
+ }
138
+ function getFMId(remoteInfo) {
139
+ if ("version" in remoteInfo && remoteInfo.version) {
140
+ return `${remoteInfo.name}:${remoteInfo.version}`;
141
+ } else if ("entry" in remoteInfo && remoteInfo.entry) {
142
+ return `${remoteInfo.name}:${remoteInfo.entry}`;
143
+ } else {
144
+ return `${remoteInfo.name}`;
145
+ }
146
+ }
147
+ const CurrentGlobal = typeof globalThis === "object" ? globalThis : window;
148
+ const nativeGlobal = (() => {
149
+ try {
150
+ return document.defaultView;
151
+ } catch {
152
+ return CurrentGlobal;
153
+ }
154
+ })();
155
+ const Global = nativeGlobal;
156
+ function definePropertyGlobalVal(target, key, val) {
157
+ Object.defineProperty(target, key, {
158
+ value: val,
159
+ configurable: false,
160
+ writable: true
161
+ });
162
+ }
163
+ function includeOwnProperty(target, key) {
164
+ return Object.hasOwnProperty.call(target, key);
165
+ }
166
+ if (!includeOwnProperty(CurrentGlobal, "__GLOBAL_LOADING_REMOTE_ENTRY__")) {
167
+ definePropertyGlobalVal(CurrentGlobal, "__GLOBAL_LOADING_REMOTE_ENTRY__", {});
168
+ }
169
+ const globalLoading = CurrentGlobal.__GLOBAL_LOADING_REMOTE_ENTRY__;
170
+ function setGlobalDefaultVal(target) {
171
+ var _a, _b, _c, _d, _e, _f;
172
+ if (includeOwnProperty(target, "__VMOK__") && !includeOwnProperty(target, "__FEDERATION__")) {
173
+ definePropertyGlobalVal(target, "__FEDERATION__", target.__VMOK__);
174
+ }
175
+ if (!includeOwnProperty(target, "__FEDERATION__")) {
176
+ definePropertyGlobalVal(target, "__FEDERATION__", {
177
+ __GLOBAL_PLUGIN__: [],
178
+ __INSTANCES__: [],
179
+ moduleInfo: {},
180
+ __SHARE__: {},
181
+ __MANIFEST_LOADING__: {},
182
+ __PRELOADED_MAP__: /* @__PURE__ */ new Map()
183
+ });
184
+ definePropertyGlobalVal(target, "__VMOK__", target.__FEDERATION__);
185
+ }
186
+ (_a = target.__FEDERATION__).__GLOBAL_PLUGIN__ ?? (_a.__GLOBAL_PLUGIN__ = []);
187
+ (_b = target.__FEDERATION__).__INSTANCES__ ?? (_b.__INSTANCES__ = []);
188
+ (_c = target.__FEDERATION__).moduleInfo ?? (_c.moduleInfo = {});
189
+ (_d = target.__FEDERATION__).__SHARE__ ?? (_d.__SHARE__ = {});
190
+ (_e = target.__FEDERATION__).__MANIFEST_LOADING__ ?? (_e.__MANIFEST_LOADING__ = {});
191
+ (_f = target.__FEDERATION__).__PRELOADED_MAP__ ?? (_f.__PRELOADED_MAP__ = /* @__PURE__ */ new Map());
192
+ }
193
+ setGlobalDefaultVal(CurrentGlobal);
194
+ setGlobalDefaultVal(nativeGlobal);
195
+ function resetFederationGlobalInfo() {
196
+ CurrentGlobal.__FEDERATION__.__GLOBAL_PLUGIN__ = [];
197
+ CurrentGlobal.__FEDERATION__.__INSTANCES__ = [];
198
+ CurrentGlobal.__FEDERATION__.moduleInfo = {};
199
+ CurrentGlobal.__FEDERATION__.__SHARE__ = {};
200
+ CurrentGlobal.__FEDERATION__.__MANIFEST_LOADING__ = {};
201
+ Object.keys(globalLoading).forEach((key) => {
202
+ delete globalLoading[key];
203
+ });
204
+ }
205
+ function setGlobalFederationInstance(FederationInstance) {
206
+ CurrentGlobal.__FEDERATION__.__INSTANCES__.push(FederationInstance);
207
+ }
208
+ function getGlobalFederationConstructor() {
209
+ return CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR__;
210
+ }
211
+ function setGlobalFederationConstructor(FederationConstructor, isDebug = index_esm.isDebugMode()) {
212
+ if (isDebug) {
213
+ CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = FederationConstructor;
214
+ CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.0.0-docs-remove-invalid-lark-link-20251205062649";
215
+ }
216
+ }
217
+ function getInfoWithoutType(target, key) {
218
+ if (typeof key === "string") {
219
+ const keyRes = target[key];
220
+ if (keyRes) {
221
+ return {
222
+ value: target[key],
223
+ key
224
+ };
225
+ } else {
226
+ const targetKeys = Object.keys(target);
227
+ for (const targetKey of targetKeys) {
228
+ const [targetTypeOrName, _] = targetKey.split(":");
229
+ const nKey = `${targetTypeOrName}:${key}`;
230
+ const typeWithKeyRes = target[nKey];
231
+ if (typeWithKeyRes) {
232
+ return {
233
+ value: typeWithKeyRes,
234
+ key: nKey
235
+ };
236
+ }
237
+ }
238
+ return {
239
+ value: void 0,
240
+ key
241
+ };
242
+ }
243
+ } else {
244
+ throw new Error("key must be string");
245
+ }
246
+ }
247
+ const getGlobalSnapshot = () => nativeGlobal.__FEDERATION__.moduleInfo;
248
+ const getTargetSnapshotInfoByModuleInfo = (moduleInfo, snapshot) => {
249
+ const moduleKey = getFMId(moduleInfo);
250
+ const getModuleInfo = getInfoWithoutType(snapshot, moduleKey).value;
251
+ if (getModuleInfo && !getModuleInfo.version && "version" in moduleInfo && moduleInfo["version"]) {
252
+ getModuleInfo.version = moduleInfo["version"];
253
+ }
254
+ if (getModuleInfo) {
255
+ return getModuleInfo;
256
+ }
257
+ if ("version" in moduleInfo && moduleInfo["version"]) {
258
+ const { version, ...resModuleInfo } = moduleInfo;
259
+ const moduleKeyWithoutVersion = getFMId(resModuleInfo);
260
+ const getModuleInfoWithoutVersion = getInfoWithoutType(nativeGlobal.__FEDERATION__.moduleInfo, moduleKeyWithoutVersion).value;
261
+ if ((getModuleInfoWithoutVersion == null ? void 0 : getModuleInfoWithoutVersion.version) === version) {
262
+ return getModuleInfoWithoutVersion;
263
+ }
264
+ }
265
+ return;
266
+ };
267
+ const getGlobalSnapshotInfoByModuleInfo = (moduleInfo) => getTargetSnapshotInfoByModuleInfo(moduleInfo, nativeGlobal.__FEDERATION__.moduleInfo);
268
+ const setGlobalSnapshotInfoByModuleInfo = (remoteInfo, moduleDetailInfo) => {
269
+ const moduleKey = getFMId(remoteInfo);
270
+ nativeGlobal.__FEDERATION__.moduleInfo[moduleKey] = moduleDetailInfo;
271
+ return nativeGlobal.__FEDERATION__.moduleInfo;
272
+ };
273
+ const addGlobalSnapshot = (moduleInfos) => {
274
+ nativeGlobal.__FEDERATION__.moduleInfo = {
275
+ ...nativeGlobal.__FEDERATION__.moduleInfo,
276
+ ...moduleInfos
277
+ };
278
+ return () => {
279
+ const keys = Object.keys(moduleInfos);
280
+ for (const key of keys) {
281
+ delete nativeGlobal.__FEDERATION__.moduleInfo[key];
282
+ }
283
+ };
284
+ };
285
+ const getRemoteEntryExports = (name, globalName) => {
286
+ const remoteEntryKey = globalName || `__FEDERATION_${name}:custom__`;
287
+ const entryExports = CurrentGlobal[remoteEntryKey];
288
+ return {
289
+ remoteEntryKey,
290
+ entryExports
291
+ };
292
+ };
293
+ const registerGlobalPlugins = (plugins) => {
294
+ const { __GLOBAL_PLUGIN__ } = nativeGlobal.__FEDERATION__;
295
+ plugins.forEach((plugin) => {
296
+ if (__GLOBAL_PLUGIN__.findIndex((p) => p.name === plugin.name) === -1) {
297
+ __GLOBAL_PLUGIN__.push(plugin);
298
+ } else {
299
+ warn(`The plugin ${plugin.name} has been registered.`);
300
+ }
301
+ });
302
+ };
303
+ const getGlobalHostPlugins = () => nativeGlobal.__FEDERATION__.__GLOBAL_PLUGIN__;
304
+ const getPreloaded = (id) => CurrentGlobal.__FEDERATION__.__PRELOADED_MAP__.get(id);
305
+ const setPreloaded = (id) => CurrentGlobal.__FEDERATION__.__PRELOADED_MAP__.set(id, true);
306
+ const DEFAULT_SCOPE = "default";
307
+ const DEFAULT_REMOTE_TYPE = "global";
308
+ const buildIdentifier = "[0-9A-Za-z-]+";
309
+ const build = `(?:\\+(${buildIdentifier}(?:\\.${buildIdentifier})*))`;
310
+ const numericIdentifier = "0|[1-9]\\d*";
311
+ const numericIdentifierLoose = "[0-9]+";
312
+ const nonNumericIdentifier = "\\d*[a-zA-Z-][a-zA-Z0-9-]*";
313
+ const preReleaseIdentifierLoose = `(?:${numericIdentifierLoose}|${nonNumericIdentifier})`;
314
+ const preReleaseLoose = `(?:-?(${preReleaseIdentifierLoose}(?:\\.${preReleaseIdentifierLoose})*))`;
315
+ const preReleaseIdentifier = `(?:${numericIdentifier}|${nonNumericIdentifier})`;
316
+ const preRelease = `(?:-(${preReleaseIdentifier}(?:\\.${preReleaseIdentifier})*))`;
317
+ const xRangeIdentifier = `${numericIdentifier}|x|X|\\*`;
318
+ const xRangePlain = `[v=\\s]*(${xRangeIdentifier})(?:\\.(${xRangeIdentifier})(?:\\.(${xRangeIdentifier})(?:${preRelease})?${build}?)?)?`;
319
+ const hyphenRange = `^\\s*(${xRangePlain})\\s+-\\s+(${xRangePlain})\\s*$`;
320
+ const mainVersionLoose = `(${numericIdentifierLoose})\\.(${numericIdentifierLoose})\\.(${numericIdentifierLoose})`;
321
+ const loosePlain = `[v=\\s]*${mainVersionLoose}${preReleaseLoose}?${build}?`;
322
+ const gtlt = "((?:<|>)?=?)";
323
+ const comparatorTrim = `(\\s*)${gtlt}\\s*(${loosePlain}|${xRangePlain})`;
324
+ const loneTilde = "(?:~>?)";
325
+ const tildeTrim = `(\\s*)${loneTilde}\\s+`;
326
+ const loneCaret = "(?:\\^)";
327
+ const caretTrim = `(\\s*)${loneCaret}\\s+`;
328
+ const star = "(<|>)?=?\\s*\\*";
329
+ const caret = `^${loneCaret}${xRangePlain}$`;
330
+ const mainVersion = `(${numericIdentifier})\\.(${numericIdentifier})\\.(${numericIdentifier})`;
331
+ const fullPlain = `v?${mainVersion}${preRelease}?${build}?`;
332
+ const tilde = `^${loneTilde}${xRangePlain}$`;
333
+ const xRange = `^${gtlt}\\s*${xRangePlain}$`;
334
+ const comparator = `^${gtlt}\\s*(${fullPlain})$|^$`;
335
+ const gte0 = "^\\s*>=\\s*0.0.0\\s*$";
336
+ function parseRegex(source) {
337
+ return new RegExp(source);
338
+ }
339
+ function isXVersion(version) {
340
+ return !version || version.toLowerCase() === "x" || version === "*";
341
+ }
342
+ function pipe(...fns) {
343
+ return (x) => fns.reduce((v, f) => f(v), x);
344
+ }
345
+ function extractComparator(comparatorString) {
346
+ return comparatorString.match(parseRegex(comparator));
347
+ }
348
+ function combineVersion(major, minor, patch, preRelease2) {
349
+ const mainVersion2 = `${major}.${minor}.${patch}`;
350
+ if (preRelease2) {
351
+ return `${mainVersion2}-${preRelease2}`;
352
+ }
353
+ return mainVersion2;
354
+ }
355
+ function parseHyphen(range) {
356
+ return range.replace(parseRegex(hyphenRange), (_range, from, fromMajor, fromMinor, fromPatch, _fromPreRelease, _fromBuild, to, toMajor, toMinor, toPatch, toPreRelease) => {
357
+ if (isXVersion(fromMajor)) {
358
+ from = "";
359
+ } else if (isXVersion(fromMinor)) {
360
+ from = `>=${fromMajor}.0.0`;
361
+ } else if (isXVersion(fromPatch)) {
362
+ from = `>=${fromMajor}.${fromMinor}.0`;
363
+ } else {
364
+ from = `>=${from}`;
365
+ }
366
+ if (isXVersion(toMajor)) {
367
+ to = "";
368
+ } else if (isXVersion(toMinor)) {
369
+ to = `<${Number(toMajor) + 1}.0.0-0`;
370
+ } else if (isXVersion(toPatch)) {
371
+ to = `<${toMajor}.${Number(toMinor) + 1}.0-0`;
372
+ } else if (toPreRelease) {
373
+ to = `<=${toMajor}.${toMinor}.${toPatch}-${toPreRelease}`;
374
+ } else {
375
+ to = `<=${to}`;
376
+ }
377
+ return `${from} ${to}`.trim();
378
+ });
379
+ }
380
+ function parseComparatorTrim(range) {
381
+ return range.replace(parseRegex(comparatorTrim), "$1$2$3");
382
+ }
383
+ function parseTildeTrim(range) {
384
+ return range.replace(parseRegex(tildeTrim), "$1~");
385
+ }
386
+ function parseCaretTrim(range) {
387
+ return range.replace(parseRegex(caretTrim), "$1^");
388
+ }
389
+ function parseCarets(range) {
390
+ return range.trim().split(/\s+/).map((rangeVersion) => rangeVersion.replace(parseRegex(caret), (_, major, minor, patch, preRelease2) => {
391
+ if (isXVersion(major)) {
392
+ return "";
393
+ } else if (isXVersion(minor)) {
394
+ return `>=${major}.0.0 <${Number(major) + 1}.0.0-0`;
395
+ } else if (isXVersion(patch)) {
396
+ if (major === "0") {
397
+ return `>=${major}.${minor}.0 <${major}.${Number(minor) + 1}.0-0`;
398
+ } else {
399
+ return `>=${major}.${minor}.0 <${Number(major) + 1}.0.0-0`;
400
+ }
401
+ } else if (preRelease2) {
402
+ if (major === "0") {
403
+ if (minor === "0") {
404
+ return `>=${major}.${minor}.${patch}-${preRelease2} <${major}.${minor}.${Number(patch) + 1}-0`;
405
+ } else {
406
+ return `>=${major}.${minor}.${patch}-${preRelease2} <${major}.${Number(minor) + 1}.0-0`;
407
+ }
408
+ } else {
409
+ return `>=${major}.${minor}.${patch}-${preRelease2} <${Number(major) + 1}.0.0-0`;
410
+ }
411
+ } else {
412
+ if (major === "0") {
413
+ if (minor === "0") {
414
+ return `>=${major}.${minor}.${patch} <${major}.${minor}.${Number(patch) + 1}-0`;
415
+ } else {
416
+ return `>=${major}.${minor}.${patch} <${major}.${Number(minor) + 1}.0-0`;
417
+ }
418
+ }
419
+ return `>=${major}.${minor}.${patch} <${Number(major) + 1}.0.0-0`;
420
+ }
421
+ })).join(" ");
422
+ }
423
+ function parseTildes(range) {
424
+ return range.trim().split(/\s+/).map((rangeVersion) => rangeVersion.replace(parseRegex(tilde), (_, major, minor, patch, preRelease2) => {
425
+ if (isXVersion(major)) {
426
+ return "";
427
+ } else if (isXVersion(minor)) {
428
+ return `>=${major}.0.0 <${Number(major) + 1}.0.0-0`;
429
+ } else if (isXVersion(patch)) {
430
+ return `>=${major}.${minor}.0 <${major}.${Number(minor) + 1}.0-0`;
431
+ } else if (preRelease2) {
432
+ return `>=${major}.${minor}.${patch}-${preRelease2} <${major}.${Number(minor) + 1}.0-0`;
433
+ }
434
+ return `>=${major}.${minor}.${patch} <${major}.${Number(minor) + 1}.0-0`;
435
+ })).join(" ");
436
+ }
437
+ function parseXRanges(range) {
438
+ return range.split(/\s+/).map((rangeVersion) => rangeVersion.trim().replace(parseRegex(xRange), (ret, gtlt2, major, minor, patch, preRelease2) => {
439
+ const isXMajor = isXVersion(major);
440
+ const isXMinor = isXMajor || isXVersion(minor);
441
+ const isXPatch = isXMinor || isXVersion(patch);
442
+ if (gtlt2 === "=" && isXPatch) {
443
+ gtlt2 = "";
444
+ }
445
+ preRelease2 = "";
446
+ if (isXMajor) {
447
+ if (gtlt2 === ">" || gtlt2 === "<") {
448
+ return "<0.0.0-0";
449
+ } else {
450
+ return "*";
451
+ }
452
+ } else if (gtlt2 && isXPatch) {
453
+ if (isXMinor) {
454
+ minor = 0;
455
+ }
456
+ patch = 0;
457
+ if (gtlt2 === ">") {
458
+ gtlt2 = ">=";
459
+ if (isXMinor) {
460
+ major = Number(major) + 1;
461
+ minor = 0;
462
+ patch = 0;
463
+ } else {
464
+ minor = Number(minor) + 1;
465
+ patch = 0;
466
+ }
467
+ } else if (gtlt2 === "<=") {
468
+ gtlt2 = "<";
469
+ if (isXMinor) {
470
+ major = Number(major) + 1;
471
+ } else {
472
+ minor = Number(minor) + 1;
473
+ }
474
+ }
475
+ if (gtlt2 === "<") {
476
+ preRelease2 = "-0";
477
+ }
478
+ return `${gtlt2 + major}.${minor}.${patch}${preRelease2}`;
479
+ } else if (isXMinor) {
480
+ return `>=${major}.0.0${preRelease2} <${Number(major) + 1}.0.0-0`;
481
+ } else if (isXPatch) {
482
+ return `>=${major}.${minor}.0${preRelease2} <${major}.${Number(minor) + 1}.0-0`;
483
+ }
484
+ return ret;
485
+ })).join(" ");
486
+ }
487
+ function parseStar(range) {
488
+ return range.trim().replace(parseRegex(star), "");
489
+ }
490
+ function parseGTE0(comparatorString) {
491
+ return comparatorString.trim().replace(parseRegex(gte0), "");
492
+ }
493
+ function compareAtom(rangeAtom, versionAtom) {
494
+ rangeAtom = Number(rangeAtom) || rangeAtom;
495
+ versionAtom = Number(versionAtom) || versionAtom;
496
+ if (rangeAtom > versionAtom) {
497
+ return 1;
498
+ }
499
+ if (rangeAtom === versionAtom) {
500
+ return 0;
501
+ }
502
+ return -1;
503
+ }
504
+ function comparePreRelease(rangeAtom, versionAtom) {
505
+ const { preRelease: rangePreRelease } = rangeAtom;
506
+ const { preRelease: versionPreRelease } = versionAtom;
507
+ if (rangePreRelease === void 0 && Boolean(versionPreRelease)) {
508
+ return 1;
509
+ }
510
+ if (Boolean(rangePreRelease) && versionPreRelease === void 0) {
511
+ return -1;
512
+ }
513
+ if (rangePreRelease === void 0 && versionPreRelease === void 0) {
514
+ return 0;
515
+ }
516
+ for (let i = 0, n = rangePreRelease.length; i <= n; i++) {
517
+ const rangeElement = rangePreRelease[i];
518
+ const versionElement = versionPreRelease[i];
519
+ if (rangeElement === versionElement) {
520
+ continue;
521
+ }
522
+ if (rangeElement === void 0 && versionElement === void 0) {
523
+ return 0;
524
+ }
525
+ if (!rangeElement) {
526
+ return 1;
527
+ }
528
+ if (!versionElement) {
529
+ return -1;
530
+ }
531
+ return compareAtom(rangeElement, versionElement);
532
+ }
533
+ return 0;
534
+ }
535
+ function compareVersion(rangeAtom, versionAtom) {
536
+ return compareAtom(rangeAtom.major, versionAtom.major) || compareAtom(rangeAtom.minor, versionAtom.minor) || compareAtom(rangeAtom.patch, versionAtom.patch) || comparePreRelease(rangeAtom, versionAtom);
537
+ }
538
+ function eq(rangeAtom, versionAtom) {
539
+ return rangeAtom.version === versionAtom.version;
540
+ }
541
+ function compare(rangeAtom, versionAtom) {
542
+ switch (rangeAtom.operator) {
543
+ case "":
544
+ case "=":
545
+ return eq(rangeAtom, versionAtom);
546
+ case ">":
547
+ return compareVersion(rangeAtom, versionAtom) < 0;
548
+ case ">=":
549
+ return eq(rangeAtom, versionAtom) || compareVersion(rangeAtom, versionAtom) < 0;
550
+ case "<":
551
+ return compareVersion(rangeAtom, versionAtom) > 0;
552
+ case "<=":
553
+ return eq(rangeAtom, versionAtom) || compareVersion(rangeAtom, versionAtom) > 0;
554
+ case void 0: {
555
+ return true;
556
+ }
557
+ default:
558
+ return false;
559
+ }
560
+ }
561
+ function parseComparatorString(range) {
562
+ return pipe(
563
+ // handle caret
564
+ // ^ --> * (any, kinda silly)
565
+ // ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0-0
566
+ // ^2.0, ^2.0.x --> >=2.0.0 <3.0.0-0
567
+ // ^1.2, ^1.2.x --> >=1.2.0 <2.0.0-0
568
+ // ^1.2.3 --> >=1.2.3 <2.0.0-0
569
+ // ^1.2.0 --> >=1.2.0 <2.0.0-0
570
+ parseCarets,
571
+ // handle tilde
572
+ // ~, ~> --> * (any, kinda silly)
573
+ // ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0-0
574
+ // ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0-0
575
+ // ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0-0
576
+ // ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0-0
577
+ // ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0-0
578
+ parseTildes,
579
+ parseXRanges,
580
+ parseStar
581
+ )(range);
582
+ }
583
+ function parseRange(range) {
584
+ return pipe(
585
+ // handle hyphenRange
586
+ // `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4`
587
+ parseHyphen,
588
+ // handle trim comparator
589
+ // `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5`
590
+ parseComparatorTrim,
591
+ // handle trim tilde
592
+ // `~ 1.2.3` => `~1.2.3`
593
+ parseTildeTrim,
594
+ // handle trim caret
595
+ // `^ 1.2.3` => `^1.2.3`
596
+ parseCaretTrim
597
+ )(range.trim()).split(/\s+/).join(" ");
598
+ }
599
+ function satisfy(version, range) {
600
+ if (!version) {
601
+ return false;
602
+ }
603
+ const extractedVersion = extractComparator(version);
604
+ if (!extractedVersion) {
605
+ return false;
606
+ }
607
+ const [, versionOperator, , versionMajor, versionMinor, versionPatch, versionPreRelease] = extractedVersion;
608
+ const versionAtom = {
609
+ operator: versionOperator,
610
+ version: combineVersion(versionMajor, versionMinor, versionPatch, versionPreRelease),
611
+ // exclude build atom
612
+ major: versionMajor,
613
+ minor: versionMinor,
614
+ patch: versionPatch,
615
+ preRelease: versionPreRelease == null ? void 0 : versionPreRelease.split(".")
616
+ };
617
+ const orRanges = range.split("||");
618
+ for (const orRange of orRanges) {
619
+ const trimmedOrRange = orRange.trim();
620
+ if (!trimmedOrRange) {
621
+ return true;
622
+ }
623
+ if (trimmedOrRange === "*" || trimmedOrRange === "x") {
624
+ return true;
625
+ }
626
+ try {
627
+ const parsedSubRange = parseRange(trimmedOrRange);
628
+ if (!parsedSubRange.trim()) {
629
+ return true;
630
+ }
631
+ const parsedComparatorString = parsedSubRange.split(" ").map((rangeVersion) => parseComparatorString(rangeVersion)).join(" ");
632
+ if (!parsedComparatorString.trim()) {
633
+ return true;
634
+ }
635
+ const comparators = parsedComparatorString.split(/\s+/).map((comparator2) => parseGTE0(comparator2)).filter(Boolean);
636
+ if (comparators.length === 0) {
637
+ continue;
638
+ }
639
+ let subRangeSatisfied = true;
640
+ for (const comparator2 of comparators) {
641
+ const extractedComparator = extractComparator(comparator2);
642
+ if (!extractedComparator) {
643
+ subRangeSatisfied = false;
644
+ break;
645
+ }
646
+ const [, rangeOperator, , rangeMajor, rangeMinor, rangePatch, rangePreRelease] = extractedComparator;
647
+ const rangeAtom = {
648
+ operator: rangeOperator,
649
+ version: combineVersion(rangeMajor, rangeMinor, rangePatch, rangePreRelease),
650
+ major: rangeMajor,
651
+ minor: rangeMinor,
652
+ patch: rangePatch,
653
+ preRelease: rangePreRelease == null ? void 0 : rangePreRelease.split(".")
654
+ };
655
+ if (!compare(rangeAtom, versionAtom)) {
656
+ subRangeSatisfied = false;
657
+ break;
658
+ }
659
+ }
660
+ if (subRangeSatisfied) {
661
+ return true;
662
+ }
663
+ } catch (e) {
664
+ console.error(`[semver] Error processing range part "${trimmedOrRange}":`, e);
665
+ continue;
666
+ }
667
+ }
668
+ return false;
669
+ }
670
+ function versionLt(a, b) {
671
+ const transformInvalidVersion = (version) => {
672
+ const isNumberVersion = !Number.isNaN(Number(version));
673
+ if (isNumberVersion) {
674
+ const splitArr = version.split(".");
675
+ let validVersion = version;
676
+ for (let i = 0; i < 3 - splitArr.length; i++) {
677
+ validVersion += ".0";
678
+ }
679
+ return validVersion;
680
+ }
681
+ return version;
682
+ };
683
+ if (satisfy(transformInvalidVersion(a), `<=${transformInvalidVersion(b)}`)) {
684
+ return true;
685
+ } else {
686
+ return false;
687
+ }
688
+ }
689
+ const findVersion = (shareVersionMap, cb) => {
690
+ const callback = cb || function(prev, cur) {
691
+ return versionLt(prev, cur);
692
+ };
693
+ return Object.keys(shareVersionMap).reduce((prev, cur) => {
694
+ if (!prev) {
695
+ return cur;
696
+ }
697
+ if (callback(prev, cur)) {
698
+ return cur;
699
+ }
700
+ if (prev === "0") {
701
+ return cur;
702
+ }
703
+ return prev;
704
+ }, 0);
705
+ };
706
+ const isLoaded = (shared) => {
707
+ return Boolean(shared.loaded) || typeof shared.lib === "function";
708
+ };
709
+ const isLoading = (shared) => {
710
+ return Boolean(shared.loading);
711
+ };
712
+ function findSingletonVersionOrderByVersion(shareScopeMap, scope, pkgName) {
713
+ const versions = shareScopeMap[scope][pkgName];
714
+ const callback = function(prev, cur) {
715
+ return !isLoaded(versions[prev]) && versionLt(prev, cur);
716
+ };
717
+ return findVersion(shareScopeMap[scope][pkgName], callback);
718
+ }
719
+ function findSingletonVersionOrderByLoaded(shareScopeMap, scope, pkgName) {
720
+ const versions = shareScopeMap[scope][pkgName];
721
+ const callback = function(prev, cur) {
722
+ const isLoadingOrLoaded = (shared) => {
723
+ return isLoaded(shared) || isLoading(shared);
724
+ };
725
+ if (isLoadingOrLoaded(versions[cur])) {
726
+ if (isLoadingOrLoaded(versions[prev])) {
727
+ return Boolean(versionLt(prev, cur));
728
+ } else {
729
+ return true;
730
+ }
731
+ }
732
+ if (isLoadingOrLoaded(versions[prev])) {
733
+ return false;
734
+ }
735
+ return versionLt(prev, cur);
736
+ };
737
+ return findVersion(shareScopeMap[scope][pkgName], callback);
738
+ }
739
+ function getFindShareFunction(strategy) {
740
+ if (strategy === "loaded-first") {
741
+ return findSingletonVersionOrderByLoaded;
742
+ }
743
+ return findSingletonVersionOrderByVersion;
744
+ }
745
+ function getRegisteredShare(localShareScopeMap, pkgName, shareInfo, resolveShare) {
746
+ if (!localShareScopeMap) {
747
+ return;
748
+ }
749
+ const { shareConfig, scope = DEFAULT_SCOPE, strategy } = shareInfo;
750
+ const scopes = Array.isArray(scope) ? scope : [scope];
751
+ for (const sc of scopes) {
752
+ if (shareConfig && localShareScopeMap[sc] && localShareScopeMap[sc][pkgName]) {
753
+ const { requiredVersion } = shareConfig;
754
+ const findShareFunction = getFindShareFunction(strategy);
755
+ const maxOrSingletonVersion = findShareFunction(localShareScopeMap, sc, pkgName);
756
+ const defaultResolver = () => {
757
+ if (shareConfig.singleton) {
758
+ if (typeof requiredVersion === "string" && !satisfy(maxOrSingletonVersion, requiredVersion)) {
759
+ const msg = `Version ${maxOrSingletonVersion} from ${maxOrSingletonVersion && localShareScopeMap[sc][pkgName][maxOrSingletonVersion].from} of shared singleton module ${pkgName} does not satisfy the requirement of ${shareInfo.from} which needs ${requiredVersion})`;
760
+ if (shareConfig.strictVersion) {
761
+ error(msg);
762
+ } else {
763
+ warn(msg);
764
+ }
765
+ }
766
+ return localShareScopeMap[sc][pkgName][maxOrSingletonVersion];
767
+ } else {
768
+ if (requiredVersion === false || requiredVersion === "*") {
769
+ return localShareScopeMap[sc][pkgName][maxOrSingletonVersion];
770
+ }
771
+ if (satisfy(maxOrSingletonVersion, requiredVersion)) {
772
+ return localShareScopeMap[sc][pkgName][maxOrSingletonVersion];
773
+ }
774
+ for (const [versionKey, versionValue] of Object.entries(localShareScopeMap[sc][pkgName])) {
775
+ if (satisfy(versionKey, requiredVersion)) {
776
+ return versionValue;
777
+ }
778
+ }
779
+ }
780
+ };
781
+ const params = {
782
+ shareScopeMap: localShareScopeMap,
783
+ scope: sc,
784
+ pkgName,
785
+ version: maxOrSingletonVersion,
786
+ GlobalFederation: Global.__FEDERATION__,
787
+ resolver: defaultResolver
788
+ };
789
+ const resolveShared = resolveShare.emit(params) || params;
790
+ return resolveShared.resolver();
791
+ }
792
+ }
793
+ }
794
+ function getGlobalShareScope() {
795
+ return Global.__FEDERATION__.__SHARE__;
796
+ }
797
+ function matchRemoteWithNameAndExpose(remotes, id) {
798
+ for (const remote of remotes) {
799
+ const isNameMatched = id.startsWith(remote.name);
800
+ let expose = id.replace(remote.name, "");
801
+ if (isNameMatched) {
802
+ if (expose.startsWith("/")) {
803
+ const pkgNameOrAlias = remote.name;
804
+ expose = `.${expose}`;
805
+ return {
806
+ pkgNameOrAlias,
807
+ expose,
808
+ remote
809
+ };
810
+ } else if (expose === "") {
811
+ return {
812
+ pkgNameOrAlias: remote.name,
813
+ expose: ".",
814
+ remote
815
+ };
816
+ }
817
+ }
818
+ const isAliasMatched = remote.alias && id.startsWith(remote.alias);
819
+ let exposeWithAlias = remote.alias && id.replace(remote.alias, "");
820
+ if (remote.alias && isAliasMatched) {
821
+ if (exposeWithAlias && exposeWithAlias.startsWith("/")) {
822
+ const pkgNameOrAlias = remote.alias;
823
+ exposeWithAlias = `.${exposeWithAlias}`;
824
+ return {
825
+ pkgNameOrAlias,
826
+ expose: exposeWithAlias,
827
+ remote
828
+ };
829
+ } else if (exposeWithAlias === "") {
830
+ return {
831
+ pkgNameOrAlias: remote.alias,
832
+ expose: ".",
833
+ remote
834
+ };
835
+ }
836
+ }
837
+ }
838
+ return;
839
+ }
840
+ const importCallback = ".then(callbacks[0]).catch(callbacks[1])";
841
+ async function loadEsmEntry({ entry, remoteEntryExports }) {
842
+ return new Promise((resolve, reject) => {
843
+ try {
844
+ if (!remoteEntryExports) {
845
+ if (typeof FEDERATION_ALLOW_NEW_FUNCTION !== "undefined") {
846
+ new Function("callbacks", `import("${entry}")${importCallback}`)([
847
+ resolve,
848
+ reject
849
+ ]);
850
+ } else {
851
+ import(
852
+ /* webpackIgnore: true */
853
+ /* @vite-ignore */
854
+ entry
855
+ ).then(resolve).catch(reject);
856
+ }
857
+ } else {
858
+ resolve(remoteEntryExports);
859
+ }
860
+ } catch (e) {
861
+ reject(e);
862
+ }
863
+ });
864
+ }
865
+ async function loadSystemJsEntry({ entry, remoteEntryExports }) {
866
+ return new Promise((resolve, reject) => {
867
+ try {
868
+ if (!remoteEntryExports) {
869
+ if (typeof __system_context__ === "undefined") {
870
+ System.import(entry).then(resolve).catch(reject);
871
+ } else {
872
+ new Function("callbacks", `System.import("${entry}")${importCallback}`)([resolve, reject]);
873
+ }
874
+ } else {
875
+ resolve(remoteEntryExports);
876
+ }
877
+ } catch (e) {
878
+ reject(e);
879
+ }
880
+ });
881
+ }
882
+ function handleRemoteEntryLoaded(name, globalName, entry) {
883
+ const { remoteEntryKey, entryExports } = getRemoteEntryExports(name, globalName);
884
+ assert(entryExports, getShortErrorMsg(RUNTIME_001, runtimeDescMap, {
885
+ remoteName: name,
886
+ remoteEntryUrl: entry,
887
+ remoteEntryKey
888
+ }));
889
+ return entryExports;
890
+ }
891
+ async function loadEntryScript({ name, globalName, entry, loaderHook, getEntryUrl }) {
892
+ const { entryExports: remoteEntryExports } = getRemoteEntryExports(name, globalName);
893
+ if (remoteEntryExports) {
894
+ return remoteEntryExports;
895
+ }
896
+ const url = getEntryUrl ? getEntryUrl(entry) : entry;
897
+ return index_esm.loadScript(url, {
898
+ attrs: {},
899
+ createScriptHook: (url2, attrs) => {
900
+ const res = loaderHook.lifecycle.createScript.emit({ url: url2, attrs });
901
+ if (!res)
902
+ return;
903
+ if (res instanceof HTMLScriptElement) {
904
+ return res;
905
+ }
906
+ if ("script" in res || "timeout" in res) {
907
+ return res;
908
+ }
909
+ return;
910
+ }
911
+ }).then(() => {
912
+ return handleRemoteEntryLoaded(name, globalName, entry);
913
+ }).catch((e) => {
914
+ assert(void 0, getShortErrorMsg(RUNTIME_008, runtimeDescMap, {
915
+ remoteName: name,
916
+ resourceUrl: entry
917
+ }));
918
+ throw e;
919
+ });
920
+ }
921
+ async function loadEntryDom({ remoteInfo, remoteEntryExports, loaderHook, getEntryUrl }) {
922
+ const { entry, entryGlobalName: globalName, name, type } = remoteInfo;
923
+ switch (type) {
924
+ case "esm":
925
+ case "module":
926
+ return loadEsmEntry({ entry, remoteEntryExports });
927
+ case "system":
928
+ return loadSystemJsEntry({ entry, remoteEntryExports });
929
+ default:
930
+ return loadEntryScript({
931
+ entry,
932
+ globalName,
933
+ name,
934
+ loaderHook,
935
+ getEntryUrl
936
+ });
937
+ }
938
+ }
939
+ async function loadEntryNode({ remoteInfo, loaderHook }) {
940
+ const { entry, entryGlobalName: globalName, name, type } = remoteInfo;
941
+ const { entryExports: remoteEntryExports } = getRemoteEntryExports(name, globalName);
942
+ if (remoteEntryExports) {
943
+ return remoteEntryExports;
944
+ }
945
+ return index_esm.loadScriptNode(entry, {
946
+ attrs: { name, globalName, type },
947
+ loaderHook: {
948
+ createScriptHook: (url, attrs = {}) => {
949
+ const res = loaderHook.lifecycle.createScript.emit({ url, attrs });
950
+ if (!res)
951
+ return;
952
+ if ("url" in res) {
953
+ return res;
954
+ }
955
+ return;
956
+ }
957
+ }
958
+ }).then(() => {
959
+ return handleRemoteEntryLoaded(name, globalName, entry);
960
+ }).catch((e) => {
961
+ throw e;
962
+ });
963
+ }
964
+ function getRemoteEntryUniqueKey(remoteInfo) {
965
+ const { entry, name } = remoteInfo;
966
+ return index_esm.composeKeyWithSeparator(name, entry);
967
+ }
968
+ async function getRemoteEntry(params) {
969
+ const { origin, remoteEntryExports, remoteInfo, getEntryUrl, _inErrorHandling = false } = params;
970
+ const uniqueKey = getRemoteEntryUniqueKey(remoteInfo);
971
+ if (remoteEntryExports) {
972
+ return remoteEntryExports;
973
+ }
974
+ if (!globalLoading[uniqueKey]) {
975
+ const loadEntryHook = origin.remoteHandler.hooks.lifecycle.loadEntry;
976
+ const loaderHook = origin.loaderHook;
977
+ globalLoading[uniqueKey] = loadEntryHook.emit({
978
+ loaderHook,
979
+ remoteInfo,
980
+ remoteEntryExports
981
+ }).then((res) => {
982
+ if (res) {
983
+ return res;
984
+ }
985
+ const isWebEnvironment = typeof ENV_TARGET !== "undefined" ? ENV_TARGET === "web" : index_esm.isBrowserEnv();
986
+ return isWebEnvironment ? loadEntryDom({
987
+ remoteInfo,
988
+ remoteEntryExports,
989
+ loaderHook,
990
+ getEntryUrl
991
+ }) : loadEntryNode({ remoteInfo, loaderHook });
992
+ }).catch(async (err) => {
993
+ const uniqueKey2 = getRemoteEntryUniqueKey(remoteInfo);
994
+ const isScriptLoadError = err instanceof Error && err.message.includes(RUNTIME_008);
995
+ if (isScriptLoadError && !_inErrorHandling) {
996
+ const wrappedGetRemoteEntry = (params2) => {
997
+ return getRemoteEntry({ ...params2, _inErrorHandling: true });
998
+ };
999
+ const RemoteEntryExports = await origin.loaderHook.lifecycle.loadEntryError.emit({
1000
+ getRemoteEntry: wrappedGetRemoteEntry,
1001
+ origin,
1002
+ remoteInfo,
1003
+ remoteEntryExports,
1004
+ globalLoading,
1005
+ uniqueKey: uniqueKey2
1006
+ });
1007
+ if (RemoteEntryExports) {
1008
+ return RemoteEntryExports;
1009
+ }
1010
+ }
1011
+ throw err;
1012
+ });
1013
+ }
1014
+ return globalLoading[uniqueKey];
1015
+ }
1016
+ function getRemoteInfo(remote) {
1017
+ return {
1018
+ ...remote,
1019
+ entry: "entry" in remote ? remote.entry : "",
1020
+ type: remote.type || DEFAULT_REMOTE_TYPE,
1021
+ entryGlobalName: remote.entryGlobalName || remote.name,
1022
+ shareScope: remote.shareScope || DEFAULT_SCOPE
1023
+ };
1024
+ }
1025
+ function preloadAssets(remoteInfo, host, assets, useLinkPreload = true) {
1026
+ const { cssAssets, jsAssetsWithoutEntry, entryAssets } = assets;
1027
+ if (host.options.inBrowser) {
1028
+ entryAssets.forEach((asset) => {
1029
+ const { moduleInfo } = asset;
1030
+ const module2 = host.moduleCache.get(remoteInfo.name);
1031
+ if (module2) {
1032
+ getRemoteEntry({
1033
+ origin: host,
1034
+ remoteInfo: moduleInfo,
1035
+ remoteEntryExports: module2.remoteEntryExports
1036
+ });
1037
+ } else {
1038
+ getRemoteEntry({
1039
+ origin: host,
1040
+ remoteInfo: moduleInfo,
1041
+ remoteEntryExports: void 0
1042
+ });
1043
+ }
1044
+ });
1045
+ if (useLinkPreload) {
1046
+ const defaultAttrs = {
1047
+ rel: "preload",
1048
+ as: "style"
1049
+ };
1050
+ cssAssets.forEach((cssUrl) => {
1051
+ const { link: cssEl, needAttach } = index_esm.createLink({
1052
+ url: cssUrl,
1053
+ cb: () => {
1054
+ },
1055
+ attrs: defaultAttrs,
1056
+ createLinkHook: (url, attrs) => {
1057
+ const res = host.loaderHook.lifecycle.createLink.emit({
1058
+ url,
1059
+ attrs
1060
+ });
1061
+ if (res instanceof HTMLLinkElement) {
1062
+ return res;
1063
+ }
1064
+ return;
1065
+ }
1066
+ });
1067
+ needAttach && document.head.appendChild(cssEl);
1068
+ });
1069
+ } else {
1070
+ const defaultAttrs = {
1071
+ rel: "stylesheet",
1072
+ type: "text/css"
1073
+ };
1074
+ cssAssets.forEach((cssUrl) => {
1075
+ const { link: cssEl, needAttach } = index_esm.createLink({
1076
+ url: cssUrl,
1077
+ cb: () => {
1078
+ },
1079
+ attrs: defaultAttrs,
1080
+ createLinkHook: (url, attrs) => {
1081
+ const res = host.loaderHook.lifecycle.createLink.emit({
1082
+ url,
1083
+ attrs
1084
+ });
1085
+ if (res instanceof HTMLLinkElement) {
1086
+ return res;
1087
+ }
1088
+ return;
1089
+ },
1090
+ needDeleteLink: false
1091
+ });
1092
+ needAttach && document.head.appendChild(cssEl);
1093
+ });
1094
+ }
1095
+ if (useLinkPreload) {
1096
+ const defaultAttrs = {
1097
+ rel: "preload",
1098
+ as: "script"
1099
+ };
1100
+ jsAssetsWithoutEntry.forEach((jsUrl) => {
1101
+ const { link: linkEl, needAttach } = index_esm.createLink({
1102
+ url: jsUrl,
1103
+ cb: () => {
1104
+ },
1105
+ attrs: defaultAttrs,
1106
+ createLinkHook: (url, attrs) => {
1107
+ const res = host.loaderHook.lifecycle.createLink.emit({
1108
+ url,
1109
+ attrs
1110
+ });
1111
+ if (res instanceof HTMLLinkElement) {
1112
+ return res;
1113
+ }
1114
+ return;
1115
+ }
1116
+ });
1117
+ needAttach && document.head.appendChild(linkEl);
1118
+ });
1119
+ } else {
1120
+ const defaultAttrs = {
1121
+ fetchpriority: "high",
1122
+ type: (remoteInfo == null ? void 0 : remoteInfo.type) === "module" ? "module" : "text/javascript"
1123
+ };
1124
+ jsAssetsWithoutEntry.forEach((jsUrl) => {
1125
+ const { script: scriptEl, needAttach } = index_esm.createScript({
1126
+ url: jsUrl,
1127
+ cb: () => {
1128
+ },
1129
+ attrs: defaultAttrs,
1130
+ createScriptHook: (url, attrs) => {
1131
+ const res = host.loaderHook.lifecycle.createScript.emit({
1132
+ url,
1133
+ attrs
1134
+ });
1135
+ if (res instanceof HTMLScriptElement) {
1136
+ return res;
1137
+ }
1138
+ return;
1139
+ },
1140
+ needDeleteScript: true
1141
+ });
1142
+ needAttach && document.head.appendChild(scriptEl);
1143
+ });
1144
+ }
1145
+ }
1146
+ }
1147
+ const ShareUtils = {
1148
+ getRegisteredShare,
1149
+ getGlobalShareScope
1150
+ };
1151
+ const GlobalUtils = {
1152
+ Global,
1153
+ nativeGlobal,
1154
+ resetFederationGlobalInfo,
1155
+ setGlobalFederationInstance,
1156
+ getGlobalFederationConstructor,
1157
+ setGlobalFederationConstructor,
1158
+ getInfoWithoutType,
1159
+ getGlobalSnapshot,
1160
+ getTargetSnapshotInfoByModuleInfo,
1161
+ getGlobalSnapshotInfoByModuleInfo,
1162
+ setGlobalSnapshotInfoByModuleInfo,
1163
+ addGlobalSnapshot,
1164
+ getRemoteEntryExports,
1165
+ registerGlobalPlugins,
1166
+ getGlobalHostPlugins,
1167
+ getPreloaded,
1168
+ setPreloaded
1169
+ };
1170
+ var helpers$1 = {
1171
+ global: GlobalUtils,
1172
+ share: ShareUtils,
1173
+ utils: {
1174
+ matchRemoteWithNameAndExpose,
1175
+ preloadAssets,
1176
+ getRemoteInfo
1177
+ }
1178
+ };
1179
+ typeof FEDERATION_OPTIMIZE_NO_SNAPSHOT_PLUGIN === "boolean" ? !FEDERATION_OPTIMIZE_NO_SNAPSHOT_PLUGIN : true;
1180
+ var helpers = {
1181
+ ...helpers$1,
1182
+ global: {
1183
+ ...helpers$1.global
1184
+ }
1185
+ };
1186
+ async function prefetch(options) {
1187
+ const { instance, id, dataFetchParams, preloadComponentResource } = options;
1188
+ if (!id) {
1189
+ lazyUtils.logger.error("id is required for prefetch!");
1190
+ return;
1191
+ }
1192
+ if (!instance) {
1193
+ lazyUtils.logger.error("instance is required for prefetch!");
1194
+ return;
1195
+ }
1196
+ const matchedRemoteInfo = helpers.utils.matchRemoteWithNameAndExpose(
1197
+ instance.options.remotes,
1198
+ id
1199
+ );
1200
+ if (!matchedRemoteInfo) {
1201
+ lazyUtils.logger.error(`Can not found '${id}' in instance.options.remotes!`);
1202
+ return;
1203
+ }
1204
+ const { remote, expose } = matchedRemoteInfo;
1205
+ const { remoteSnapshot, globalSnapshot } = await instance.snapshotHandler.loadRemoteSnapshotInfo({
1206
+ moduleInfo: remote,
1207
+ id,
1208
+ expose
1209
+ });
1210
+ if (preloadComponentResource) {
1211
+ const remoteInfo = helpers.utils.getRemoteInfo(remote);
1212
+ Promise.resolve(
1213
+ instance.remoteHandler.hooks.lifecycle.generatePreloadAssets.emit({
1214
+ origin: instance,
1215
+ preloadOptions: {
1216
+ remote,
1217
+ preloadConfig: {
1218
+ nameOrAlias: remote.name,
1219
+ exposes: [expose]
1220
+ }
1221
+ },
1222
+ remote,
1223
+ remoteInfo,
1224
+ globalSnapshot,
1225
+ remoteSnapshot
1226
+ })
1227
+ ).then((assets) => {
1228
+ if (assets) {
1229
+ helpers.utils.preloadAssets(remoteInfo, instance, assets);
1230
+ }
1231
+ });
1232
+ }
1233
+ const dataFetchMap = lazyUtils.getDataFetchMap();
1234
+ if (!dataFetchMap) {
1235
+ return;
1236
+ }
1237
+ const dataFetchInfo = lazyUtils.getDataFetchInfo({
1238
+ name: remote.name,
1239
+ alias: remote.alias,
1240
+ id,
1241
+ remoteSnapshot
1242
+ });
1243
+ const dataFetchMapKey = lazyUtils.getDataFetchMapKey(dataFetchInfo, {
1244
+ name: instance.name,
1245
+ version: instance.options.version
1246
+ });
1247
+ if (!dataFetchMapKey) {
1248
+ return;
1249
+ }
1250
+ const dataFetchItem = dataFetchMap[dataFetchMapKey];
1251
+ if (!dataFetchItem) {
1252
+ return;
1253
+ }
1254
+ const [getDataFetchGetter, _type, getDataFetchPromise] = dataFetchItem[0];
1255
+ let _getDataFetchPromise = getDataFetchPromise;
1256
+ if (!getDataFetchPromise) {
1257
+ if (!getDataFetchGetter) {
1258
+ return;
1259
+ }
1260
+ _getDataFetchPromise = getDataFetchGetter();
1261
+ }
1262
+ _getDataFetchPromise.then((dataFetchFn) => {
1263
+ return dataFetchFn({
1264
+ ...dataFetchParams,
1265
+ _id: dataFetchMapKey,
1266
+ isDowngrade: false
1267
+ });
1268
+ });
1269
+ }
1270
+ exports.dataFetchFunction = dataFetchFunction;
1271
+ exports.injectDataFetch = injectDataFetch;
1272
+ exports.prefetch = prefetch;