@module-federation/bridge-react 0.24.1 → 2.0.1

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 (42) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/base.cjs.js +4 -4
  3. package/dist/base.es.js +5 -5
  4. package/dist/{bridge-base-CIgEZf8X.mjs → bridge-base-BVX0EbsV.mjs} +1 -1
  5. package/dist/{bridge-base-1Grpgans.js → bridge-base-vSCG9ebE.js} +1 -1
  6. package/dist/{createHelpers-2UBGLdcA.js → createHelpers-12yCVhCu.js} +2 -2
  7. package/dist/{createHelpers-C9qvVTND.mjs → createHelpers-CGhHhtAd.mjs} +2 -2
  8. package/dist/data-fetch-server-middleware.cjs.js +2 -2
  9. package/dist/data-fetch-server-middleware.es.js +2 -2
  10. package/dist/data-fetch-utils.cjs.js +2 -2
  11. package/dist/data-fetch-utils.es.js +4 -4
  12. package/dist/{index-DRSBaSu3.js → index-DhFNWacm.js} +1 -1
  13. package/dist/{index-DyQNwY2M.mjs → index-DtXhorFI.mjs} +1 -1
  14. package/dist/index.cjs.js +5 -5
  15. package/dist/index.es.js +6 -6
  16. package/dist/{index.esm-CPwSeCvw.mjs → index.esm-BvTtsZnu.mjs} +3 -4
  17. package/dist/{index.esm-BWaKho-8.js → index.esm-CYiGJfQW.js} +0 -1
  18. package/dist/{lazy-load-component-plugin-DKejcTCw.js → lazy-load-component-plugin-C7jasFos.js} +2 -2
  19. package/dist/{lazy-load-component-plugin-Dk-ECNy-.mjs → lazy-load-component-plugin-CrSLH5YP.mjs} +2 -2
  20. package/dist/lazy-load-component-plugin.cjs.js +2 -2
  21. package/dist/lazy-load-component-plugin.es.js +2 -2
  22. package/dist/lazy-utils.cjs.js +2 -2
  23. package/dist/lazy-utils.es.js +2 -2
  24. package/dist/prefetch-CFRpPfZQ.js +632 -0
  25. package/dist/prefetch-DMJyBeIs.mjs +633 -0
  26. package/dist/router-v5.cjs.js +1 -1
  27. package/dist/router-v5.es.js +1 -1
  28. package/dist/router-v6.cjs.js +1 -1
  29. package/dist/router-v6.es.js +1 -1
  30. package/dist/router-v7.cjs.js +1 -1
  31. package/dist/router-v7.es.js +1 -1
  32. package/dist/router.cjs.js +1 -1
  33. package/dist/router.es.js +1 -1
  34. package/dist/{utils--qTri1IN.mjs → utils-DpoLOH_j.mjs} +1 -1
  35. package/dist/{utils-tM9yE73c.js → utils-TDonIHDD.js} +1 -1
  36. package/dist/v18.cjs.js +1 -1
  37. package/dist/v18.es.js +1 -1
  38. package/dist/v19.cjs.js +1 -1
  39. package/dist/v19.es.js +1 -1
  40. package/package.json +5 -5
  41. package/dist/prefetch-BiUqElFJ.mjs +0 -1391
  42. package/dist/prefetch-ebk8gbEI.js +0 -1390
@@ -0,0 +1,633 @@
1
+ import { x as DATA_FETCH_FUNCTION, F as FS_HREF, l as logger, e as getDataFetchMap, i as initDataFetchMap, n as getDataFetchItem, M as MF_DATA_FETCH_STATUS, p as MF_DATA_FETCH_TYPE, A as DOWNGRADE_KEY, B as callAllDowngrade, G as callDowngrade, H as getDowngradeTag, k as getDataFetchInfo, m as getDataFetchMapKey } from "./utils-DpoLOH_j.mjs";
2
+ import { a as createLink, b as createScript, i as isBrowserEnv, d as composeKeyWithSeparator, l as loadScriptNode, e as loadScript } from "./index.esm-BvTtsZnu.mjs";
3
+ const dataFetchFunction = async function(options) {
4
+ var _a, _b;
5
+ const [id, data, downgrade] = options;
6
+ logger.debug("==========call data fetch function!");
7
+ if (data) {
8
+ if (!id) {
9
+ throw new Error("id is required!");
10
+ }
11
+ if (!getDataFetchMap()) {
12
+ initDataFetchMap();
13
+ }
14
+ const dataFetchItem = getDataFetchItem(id);
15
+ if (dataFetchItem) {
16
+ (_b = (_a = dataFetchItem[1]) == null ? void 0 : _a[1]) == null ? void 0 : _b.call(_a, data);
17
+ dataFetchItem[2] = MF_DATA_FETCH_STATUS.LOADED;
18
+ return;
19
+ }
20
+ if (!dataFetchItem) {
21
+ const dataFetchMap = getDataFetchMap();
22
+ let res;
23
+ let rej;
24
+ const p = new Promise((resolve, reject) => {
25
+ res = resolve;
26
+ rej = reject;
27
+ });
28
+ dataFetchMap[id] = [
29
+ [
30
+ async () => async () => {
31
+ return "";
32
+ },
33
+ MF_DATA_FETCH_TYPE.FETCH_SERVER
34
+ ],
35
+ [p, res, rej],
36
+ MF_DATA_FETCH_STATUS.LOADED
37
+ ];
38
+ res && res(data);
39
+ return;
40
+ }
41
+ }
42
+ if (downgrade) {
43
+ const mfDowngrade2 = getDowngradeTag();
44
+ if (!mfDowngrade2) {
45
+ globalThis[DOWNGRADE_KEY] = id ? [id] : true;
46
+ } else if (Array.isArray(mfDowngrade2) && id && !mfDowngrade2.includes(id)) {
47
+ mfDowngrade2.push(id);
48
+ }
49
+ }
50
+ const mfDowngrade = getDowngradeTag();
51
+ if (typeof mfDowngrade === "boolean") {
52
+ return callAllDowngrade();
53
+ }
54
+ if (Array.isArray(mfDowngrade)) {
55
+ if (!id) {
56
+ globalThis[DOWNGRADE_KEY] = true;
57
+ return callAllDowngrade();
58
+ }
59
+ if (!mfDowngrade.includes(id)) {
60
+ mfDowngrade.push(id);
61
+ }
62
+ return callDowngrade(id);
63
+ }
64
+ };
65
+ function injectDataFetch() {
66
+ var _a;
67
+ globalThis[_a = DATA_FETCH_FUNCTION] || (globalThis[_a] = []);
68
+ const dataFetch = globalThis[DATA_FETCH_FUNCTION];
69
+ if (dataFetch.push === dataFetchFunction) {
70
+ return;
71
+ }
72
+ if (typeof window === "undefined") {
73
+ return;
74
+ }
75
+ globalThis[FS_HREF] = window.location.href;
76
+ dataFetch.push = dataFetchFunction;
77
+ }
78
+ const RUNTIME_001 = "RUNTIME-001";
79
+ const RUNTIME_002 = "RUNTIME-002";
80
+ const RUNTIME_003 = "RUNTIME-003";
81
+ const RUNTIME_004 = "RUNTIME-004";
82
+ const RUNTIME_005 = "RUNTIME-005";
83
+ const RUNTIME_006 = "RUNTIME-006";
84
+ const RUNTIME_007 = "RUNTIME-007";
85
+ const RUNTIME_008 = "RUNTIME-008";
86
+ const RUNTIME_009 = "RUNTIME-009";
87
+ const getDocsUrl = (errorCode) => {
88
+ const type = errorCode.split("-")[0].toLowerCase();
89
+ return `View the docs to see how to solve: https://module-federation.io/guide/troubleshooting/${type}#${errorCode.toLowerCase()}`;
90
+ };
91
+ const getShortErrorMsg = (errorCode, errorDescMap, args, originalErrorMsg) => {
92
+ const msg = [`${[errorDescMap[errorCode]]} #${errorCode}`];
93
+ args && msg.push(`args: ${JSON.stringify(args)}`);
94
+ msg.push(getDocsUrl(errorCode));
95
+ return msg.join("\n");
96
+ };
97
+ const runtimeDescMap = {
98
+ [RUNTIME_001]: "Failed to get remoteEntry exports.",
99
+ [RUNTIME_002]: 'The remote entry interface does not contain "init"',
100
+ [RUNTIME_003]: "Failed to get manifest.",
101
+ [RUNTIME_004]: "Failed to locate remote.",
102
+ [RUNTIME_005]: "Invalid loadShareSync function call from bundler runtime",
103
+ [RUNTIME_006]: "Invalid loadShareSync function call from runtime",
104
+ [RUNTIME_007]: "Failed to get remote snapshot.",
105
+ [RUNTIME_008]: "Failed to load script resources.",
106
+ [RUNTIME_009]: "Please call createInstance first."
107
+ };
108
+ ({
109
+ ...runtimeDescMap
110
+ });
111
+ const LOG_CATEGORY = "[ Federation Runtime ]";
112
+ function assert(condition, msg) {
113
+ if (!condition) {
114
+ error(msg);
115
+ }
116
+ }
117
+ function error(msg) {
118
+ if (msg instanceof Error) {
119
+ if (!msg.message.startsWith(LOG_CATEGORY)) {
120
+ msg.message = `${LOG_CATEGORY}: ${msg.message}`;
121
+ }
122
+ throw msg;
123
+ }
124
+ throw new Error(`${LOG_CATEGORY}: ${msg}`);
125
+ }
126
+ const CurrentGlobal = typeof globalThis === "object" ? globalThis : window;
127
+ const nativeGlobal = (() => {
128
+ try {
129
+ return document.defaultView;
130
+ } catch {
131
+ return CurrentGlobal;
132
+ }
133
+ })();
134
+ function definePropertyGlobalVal(target, key, val) {
135
+ Object.defineProperty(target, key, {
136
+ value: val,
137
+ configurable: false,
138
+ writable: true
139
+ });
140
+ }
141
+ function includeOwnProperty(target, key) {
142
+ return Object.hasOwnProperty.call(target, key);
143
+ }
144
+ if (!includeOwnProperty(CurrentGlobal, "__GLOBAL_LOADING_REMOTE_ENTRY__")) {
145
+ definePropertyGlobalVal(CurrentGlobal, "__GLOBAL_LOADING_REMOTE_ENTRY__", {});
146
+ }
147
+ const globalLoading = CurrentGlobal.__GLOBAL_LOADING_REMOTE_ENTRY__;
148
+ function setGlobalDefaultVal(target) {
149
+ var _a, _b, _c, _d, _e, _f;
150
+ if (includeOwnProperty(target, "__VMOK__") && !includeOwnProperty(target, "__FEDERATION__")) {
151
+ definePropertyGlobalVal(target, "__FEDERATION__", target.__VMOK__);
152
+ }
153
+ if (!includeOwnProperty(target, "__FEDERATION__")) {
154
+ definePropertyGlobalVal(target, "__FEDERATION__", {
155
+ __GLOBAL_PLUGIN__: [],
156
+ __INSTANCES__: [],
157
+ moduleInfo: {},
158
+ __SHARE__: {},
159
+ __MANIFEST_LOADING__: {},
160
+ __PRELOADED_MAP__: /* @__PURE__ */ new Map()
161
+ });
162
+ definePropertyGlobalVal(target, "__VMOK__", target.__FEDERATION__);
163
+ }
164
+ (_a = target.__FEDERATION__).__GLOBAL_PLUGIN__ ?? (_a.__GLOBAL_PLUGIN__ = []);
165
+ (_b = target.__FEDERATION__).__INSTANCES__ ?? (_b.__INSTANCES__ = []);
166
+ (_c = target.__FEDERATION__).moduleInfo ?? (_c.moduleInfo = {});
167
+ (_d = target.__FEDERATION__).__SHARE__ ?? (_d.__SHARE__ = {});
168
+ (_e = target.__FEDERATION__).__MANIFEST_LOADING__ ?? (_e.__MANIFEST_LOADING__ = {});
169
+ (_f = target.__FEDERATION__).__PRELOADED_MAP__ ?? (_f.__PRELOADED_MAP__ = /* @__PURE__ */ new Map());
170
+ }
171
+ setGlobalDefaultVal(CurrentGlobal);
172
+ setGlobalDefaultVal(nativeGlobal);
173
+ const getRemoteEntryExports = (name, globalName) => {
174
+ const remoteEntryKey = globalName || `__FEDERATION_${name}:custom__`;
175
+ const entryExports = CurrentGlobal[remoteEntryKey];
176
+ return {
177
+ remoteEntryKey,
178
+ entryExports
179
+ };
180
+ };
181
+ const DEFAULT_SCOPE = "default";
182
+ const DEFAULT_REMOTE_TYPE = "global";
183
+ function matchRemoteWithNameAndExpose(remotes, id) {
184
+ for (const remote of remotes) {
185
+ const isNameMatched = id.startsWith(remote.name);
186
+ let expose = id.replace(remote.name, "");
187
+ if (isNameMatched) {
188
+ if (expose.startsWith("/")) {
189
+ const pkgNameOrAlias = remote.name;
190
+ expose = `.${expose}`;
191
+ return {
192
+ pkgNameOrAlias,
193
+ expose,
194
+ remote
195
+ };
196
+ } else if (expose === "") {
197
+ return {
198
+ pkgNameOrAlias: remote.name,
199
+ expose: ".",
200
+ remote
201
+ };
202
+ }
203
+ }
204
+ const isAliasMatched = remote.alias && id.startsWith(remote.alias);
205
+ let exposeWithAlias = remote.alias && id.replace(remote.alias, "");
206
+ if (remote.alias && isAliasMatched) {
207
+ if (exposeWithAlias && exposeWithAlias.startsWith("/")) {
208
+ const pkgNameOrAlias = remote.alias;
209
+ exposeWithAlias = `.${exposeWithAlias}`;
210
+ return {
211
+ pkgNameOrAlias,
212
+ expose: exposeWithAlias,
213
+ remote
214
+ };
215
+ } else if (exposeWithAlias === "") {
216
+ return {
217
+ pkgNameOrAlias: remote.alias,
218
+ expose: ".",
219
+ remote
220
+ };
221
+ }
222
+ }
223
+ }
224
+ return;
225
+ }
226
+ const importCallback = ".then(callbacks[0]).catch(callbacks[1])";
227
+ async function loadEsmEntry({ entry, remoteEntryExports }) {
228
+ return new Promise((resolve, reject) => {
229
+ try {
230
+ if (!remoteEntryExports) {
231
+ if (typeof FEDERATION_ALLOW_NEW_FUNCTION !== "undefined") {
232
+ new Function("callbacks", `import("${entry}")${importCallback}`)([
233
+ resolve,
234
+ reject
235
+ ]);
236
+ } else {
237
+ import(
238
+ /* webpackIgnore: true */
239
+ /* @vite-ignore */
240
+ entry
241
+ ).then(resolve).catch(reject);
242
+ }
243
+ } else {
244
+ resolve(remoteEntryExports);
245
+ }
246
+ } catch (e) {
247
+ reject(e);
248
+ }
249
+ });
250
+ }
251
+ async function loadSystemJsEntry({ entry, remoteEntryExports }) {
252
+ return new Promise((resolve, reject) => {
253
+ try {
254
+ if (!remoteEntryExports) {
255
+ if (typeof __system_context__ === "undefined") {
256
+ System.import(entry).then(resolve).catch(reject);
257
+ } else {
258
+ new Function("callbacks", `System.import("${entry}")${importCallback}`)([resolve, reject]);
259
+ }
260
+ } else {
261
+ resolve(remoteEntryExports);
262
+ }
263
+ } catch (e) {
264
+ reject(e);
265
+ }
266
+ });
267
+ }
268
+ function handleRemoteEntryLoaded(name, globalName, entry) {
269
+ const { remoteEntryKey, entryExports } = getRemoteEntryExports(name, globalName);
270
+ assert(entryExports, getShortErrorMsg(RUNTIME_001, runtimeDescMap, {
271
+ remoteName: name,
272
+ remoteEntryUrl: entry,
273
+ remoteEntryKey
274
+ }));
275
+ return entryExports;
276
+ }
277
+ async function loadEntryScript({ name, globalName, entry, loaderHook, getEntryUrl }) {
278
+ const { entryExports: remoteEntryExports } = getRemoteEntryExports(name, globalName);
279
+ if (remoteEntryExports) {
280
+ return remoteEntryExports;
281
+ }
282
+ const url = getEntryUrl ? getEntryUrl(entry) : entry;
283
+ return loadScript(url, {
284
+ attrs: {},
285
+ createScriptHook: (url2, attrs) => {
286
+ const res = loaderHook.lifecycle.createScript.emit({ url: url2, attrs });
287
+ if (!res)
288
+ return;
289
+ if (res instanceof HTMLScriptElement) {
290
+ return res;
291
+ }
292
+ if ("script" in res || "timeout" in res) {
293
+ return res;
294
+ }
295
+ return;
296
+ }
297
+ }).then(() => {
298
+ return handleRemoteEntryLoaded(name, globalName, entry);
299
+ }).catch((e) => {
300
+ assert(void 0, getShortErrorMsg(RUNTIME_008, runtimeDescMap, {
301
+ remoteName: name,
302
+ resourceUrl: entry
303
+ }));
304
+ throw e;
305
+ });
306
+ }
307
+ async function loadEntryDom({ remoteInfo, remoteEntryExports, loaderHook, getEntryUrl }) {
308
+ const { entry, entryGlobalName: globalName, name, type } = remoteInfo;
309
+ switch (type) {
310
+ case "esm":
311
+ case "module":
312
+ return loadEsmEntry({ entry, remoteEntryExports });
313
+ case "system":
314
+ return loadSystemJsEntry({ entry, remoteEntryExports });
315
+ default:
316
+ return loadEntryScript({
317
+ entry,
318
+ globalName,
319
+ name,
320
+ loaderHook,
321
+ getEntryUrl
322
+ });
323
+ }
324
+ }
325
+ async function loadEntryNode({ remoteInfo, loaderHook }) {
326
+ const { entry, entryGlobalName: globalName, name, type } = remoteInfo;
327
+ const { entryExports: remoteEntryExports } = getRemoteEntryExports(name, globalName);
328
+ if (remoteEntryExports) {
329
+ return remoteEntryExports;
330
+ }
331
+ return loadScriptNode(entry, {
332
+ attrs: { name, globalName, type },
333
+ loaderHook: {
334
+ createScriptHook: (url, attrs = {}) => {
335
+ const res = loaderHook.lifecycle.createScript.emit({ url, attrs });
336
+ if (!res)
337
+ return;
338
+ if ("url" in res) {
339
+ return res;
340
+ }
341
+ return;
342
+ }
343
+ }
344
+ }).then(() => {
345
+ return handleRemoteEntryLoaded(name, globalName, entry);
346
+ }).catch((e) => {
347
+ throw e;
348
+ });
349
+ }
350
+ function getRemoteEntryUniqueKey(remoteInfo) {
351
+ const { entry, name } = remoteInfo;
352
+ return composeKeyWithSeparator(name, entry);
353
+ }
354
+ async function getRemoteEntry(params) {
355
+ const { origin, remoteEntryExports, remoteInfo, getEntryUrl, _inErrorHandling = false } = params;
356
+ const uniqueKey = getRemoteEntryUniqueKey(remoteInfo);
357
+ if (remoteEntryExports) {
358
+ return remoteEntryExports;
359
+ }
360
+ if (!globalLoading[uniqueKey]) {
361
+ const loadEntryHook = origin.remoteHandler.hooks.lifecycle.loadEntry;
362
+ const loaderHook = origin.loaderHook;
363
+ globalLoading[uniqueKey] = loadEntryHook.emit({
364
+ loaderHook,
365
+ remoteInfo,
366
+ remoteEntryExports
367
+ }).then((res) => {
368
+ if (res) {
369
+ return res;
370
+ }
371
+ const isWebEnvironment = typeof ENV_TARGET !== "undefined" ? ENV_TARGET === "web" : isBrowserEnv();
372
+ return isWebEnvironment ? loadEntryDom({
373
+ remoteInfo,
374
+ remoteEntryExports,
375
+ loaderHook,
376
+ getEntryUrl
377
+ }) : loadEntryNode({ remoteInfo, loaderHook });
378
+ }).catch(async (err) => {
379
+ const uniqueKey2 = getRemoteEntryUniqueKey(remoteInfo);
380
+ const isScriptLoadError = err instanceof Error && err.message.includes(RUNTIME_008);
381
+ if (isScriptLoadError && !_inErrorHandling) {
382
+ const wrappedGetRemoteEntry = (params2) => {
383
+ return getRemoteEntry({ ...params2, _inErrorHandling: true });
384
+ };
385
+ const RemoteEntryExports = await origin.loaderHook.lifecycle.loadEntryError.emit({
386
+ getRemoteEntry: wrappedGetRemoteEntry,
387
+ origin,
388
+ remoteInfo,
389
+ remoteEntryExports,
390
+ globalLoading,
391
+ uniqueKey: uniqueKey2
392
+ });
393
+ if (RemoteEntryExports) {
394
+ return RemoteEntryExports;
395
+ }
396
+ }
397
+ throw err;
398
+ });
399
+ }
400
+ return globalLoading[uniqueKey];
401
+ }
402
+ function getRemoteInfo(remote) {
403
+ return {
404
+ ...remote,
405
+ entry: "entry" in remote ? remote.entry : "",
406
+ type: remote.type || DEFAULT_REMOTE_TYPE,
407
+ entryGlobalName: remote.entryGlobalName || remote.name,
408
+ shareScope: remote.shareScope || DEFAULT_SCOPE
409
+ };
410
+ }
411
+ function preloadAssets(remoteInfo, host, assets, useLinkPreload = true) {
412
+ const { cssAssets, jsAssetsWithoutEntry, entryAssets } = assets;
413
+ if (host.options.inBrowser) {
414
+ entryAssets.forEach((asset) => {
415
+ const { moduleInfo } = asset;
416
+ const module = host.moduleCache.get(remoteInfo.name);
417
+ if (module) {
418
+ getRemoteEntry({
419
+ origin: host,
420
+ remoteInfo: moduleInfo,
421
+ remoteEntryExports: module.remoteEntryExports
422
+ });
423
+ } else {
424
+ getRemoteEntry({
425
+ origin: host,
426
+ remoteInfo: moduleInfo,
427
+ remoteEntryExports: void 0
428
+ });
429
+ }
430
+ });
431
+ if (useLinkPreload) {
432
+ const defaultAttrs = {
433
+ rel: "preload",
434
+ as: "style"
435
+ };
436
+ cssAssets.forEach((cssUrl) => {
437
+ const { link: cssEl, needAttach } = createLink({
438
+ url: cssUrl,
439
+ cb: () => {
440
+ },
441
+ attrs: defaultAttrs,
442
+ createLinkHook: (url, attrs) => {
443
+ const res = host.loaderHook.lifecycle.createLink.emit({
444
+ url,
445
+ attrs
446
+ });
447
+ if (res instanceof HTMLLinkElement) {
448
+ return res;
449
+ }
450
+ return;
451
+ }
452
+ });
453
+ needAttach && document.head.appendChild(cssEl);
454
+ });
455
+ } else {
456
+ const defaultAttrs = {
457
+ rel: "stylesheet",
458
+ type: "text/css"
459
+ };
460
+ cssAssets.forEach((cssUrl) => {
461
+ const { link: cssEl, needAttach } = createLink({
462
+ url: cssUrl,
463
+ cb: () => {
464
+ },
465
+ attrs: defaultAttrs,
466
+ createLinkHook: (url, attrs) => {
467
+ const res = host.loaderHook.lifecycle.createLink.emit({
468
+ url,
469
+ attrs
470
+ });
471
+ if (res instanceof HTMLLinkElement) {
472
+ return res;
473
+ }
474
+ return;
475
+ },
476
+ needDeleteLink: false
477
+ });
478
+ needAttach && document.head.appendChild(cssEl);
479
+ });
480
+ }
481
+ if (useLinkPreload) {
482
+ const defaultAttrs = {
483
+ rel: "preload",
484
+ as: "script"
485
+ };
486
+ jsAssetsWithoutEntry.forEach((jsUrl) => {
487
+ const { link: linkEl, needAttach } = createLink({
488
+ url: jsUrl,
489
+ cb: () => {
490
+ },
491
+ attrs: defaultAttrs,
492
+ createLinkHook: (url, attrs) => {
493
+ const res = host.loaderHook.lifecycle.createLink.emit({
494
+ url,
495
+ attrs
496
+ });
497
+ if (res instanceof HTMLLinkElement) {
498
+ return res;
499
+ }
500
+ return;
501
+ }
502
+ });
503
+ needAttach && document.head.appendChild(linkEl);
504
+ });
505
+ } else {
506
+ const defaultAttrs = {
507
+ fetchpriority: "high",
508
+ type: (remoteInfo == null ? void 0 : remoteInfo.type) === "module" ? "module" : "text/javascript"
509
+ };
510
+ jsAssetsWithoutEntry.forEach((jsUrl) => {
511
+ const { script: scriptEl, needAttach } = createScript({
512
+ url: jsUrl,
513
+ cb: () => {
514
+ },
515
+ attrs: defaultAttrs,
516
+ createScriptHook: (url, attrs) => {
517
+ const res = host.loaderHook.lifecycle.createScript.emit({
518
+ url,
519
+ attrs
520
+ });
521
+ if (res instanceof HTMLScriptElement) {
522
+ return res;
523
+ }
524
+ return;
525
+ },
526
+ needDeleteScript: true
527
+ });
528
+ needAttach && document.head.appendChild(scriptEl);
529
+ });
530
+ }
531
+ }
532
+ }
533
+ var helpers = {
534
+ utils: {
535
+ matchRemoteWithNameAndExpose,
536
+ preloadAssets,
537
+ getRemoteInfo
538
+ }
539
+ };
540
+ typeof FEDERATION_OPTIMIZE_NO_SNAPSHOT_PLUGIN === "boolean" ? !FEDERATION_OPTIMIZE_NO_SNAPSHOT_PLUGIN : true;
541
+ const utils = helpers.utils;
542
+ const runtimeHelpers = {
543
+ utils
544
+ };
545
+ async function prefetch(options) {
546
+ const { instance, id, dataFetchParams, preloadComponentResource } = options;
547
+ if (!id) {
548
+ logger.error("id is required for prefetch!");
549
+ return;
550
+ }
551
+ if (!instance) {
552
+ logger.error("instance is required for prefetch!");
553
+ return;
554
+ }
555
+ const matchedRemoteInfo = runtimeHelpers.utils.matchRemoteWithNameAndExpose(
556
+ instance.options.remotes,
557
+ id
558
+ );
559
+ if (!matchedRemoteInfo) {
560
+ logger.error(`Can not found '${id}' in instance.options.remotes!`);
561
+ return;
562
+ }
563
+ const { remote, expose } = matchedRemoteInfo;
564
+ const { remoteSnapshot, globalSnapshot } = await instance.snapshotHandler.loadRemoteSnapshotInfo({
565
+ moduleInfo: remote,
566
+ id,
567
+ expose
568
+ });
569
+ if (preloadComponentResource) {
570
+ const remoteInfo = runtimeHelpers.utils.getRemoteInfo(remote);
571
+ Promise.resolve(
572
+ instance.remoteHandler.hooks.lifecycle.generatePreloadAssets.emit({
573
+ origin: instance,
574
+ preloadOptions: {
575
+ remote,
576
+ preloadConfig: {
577
+ nameOrAlias: remote.name,
578
+ exposes: [expose]
579
+ }
580
+ },
581
+ remote,
582
+ remoteInfo,
583
+ globalSnapshot,
584
+ remoteSnapshot
585
+ })
586
+ ).then((assets) => {
587
+ if (assets) {
588
+ runtimeHelpers.utils.preloadAssets(remoteInfo, instance, assets);
589
+ }
590
+ });
591
+ }
592
+ const dataFetchMap = getDataFetchMap();
593
+ if (!dataFetchMap) {
594
+ return;
595
+ }
596
+ const dataFetchInfo = getDataFetchInfo({
597
+ name: remote.name,
598
+ alias: remote.alias,
599
+ id,
600
+ remoteSnapshot
601
+ });
602
+ const dataFetchMapKey = getDataFetchMapKey(dataFetchInfo, {
603
+ name: instance.name,
604
+ version: instance.options.version
605
+ });
606
+ if (!dataFetchMapKey) {
607
+ return;
608
+ }
609
+ const dataFetchItem = dataFetchMap[dataFetchMapKey];
610
+ if (!dataFetchItem) {
611
+ return;
612
+ }
613
+ const [getDataFetchGetter, _type, getDataFetchPromise] = dataFetchItem[0];
614
+ let _getDataFetchPromise = getDataFetchPromise;
615
+ if (!getDataFetchPromise) {
616
+ if (!getDataFetchGetter) {
617
+ return;
618
+ }
619
+ _getDataFetchPromise = getDataFetchGetter();
620
+ }
621
+ _getDataFetchPromise.then((dataFetchFn) => {
622
+ return dataFetchFn({
623
+ ...dataFetchParams,
624
+ _id: dataFetchMapKey,
625
+ isDowngrade: false
626
+ });
627
+ });
628
+ }
629
+ export {
630
+ dataFetchFunction as d,
631
+ injectDataFetch as i,
632
+ prefetch as p
633
+ };
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const React = require("react");
4
4
  const ReactRouterDom$1 = require("react-router-dom/index.js");
5
- const index = require("./index-DRSBaSu3.js");
5
+ const index = require("./index-DhFNWacm.js");
6
6
  const ReactRouterDom = require("react-router-dom/index.js");
7
7
  function _interopNamespaceDefault(e) {
8
8
  const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
@@ -1,6 +1,6 @@
1
1
  import React__default, { useContext } from "react";
2
2
  import * as ReactRouterDom$1 from "react-router-dom/index.js";
3
- import { R as RouterContext, L as LoggerInstance } from "./index-DyQNwY2M.mjs";
3
+ import { R as RouterContext, L as LoggerInstance } from "./index-DtXhorFI.mjs";
4
4
  export * from "react-router-dom/index.js";
5
5
  function WraperRouter(props) {
6
6
  const { basename, ...propsRes } = props;
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const React = require("react");
4
4
  const ReactRouterDom$1 = require("react-router-dom/dist/index.js");
5
- const index = require("./index-DRSBaSu3.js");
5
+ const index = require("./index-DhFNWacm.js");
6
6
  const ReactRouterDom = require("react-router-dom/dist/index.js");
7
7
  function _interopNamespaceDefault(e) {
8
8
  const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
@@ -1,6 +1,6 @@
1
1
  import React__default, { useContext } from "react";
2
2
  import * as ReactRouterDom$1 from "react-router-dom/dist/index.js";
3
- import { R as RouterContext, L as LoggerInstance } from "./index-DyQNwY2M.mjs";
3
+ import { R as RouterContext, L as LoggerInstance } from "./index-DtXhorFI.mjs";
4
4
  export * from "react-router-dom/dist/index.js";
5
5
  function WraperRouter(props) {
6
6
  const { basename, ...propsRes } = props;
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const React = require("react");
4
4
  const ReactRouterDom = require("react-router");
5
- const index = require("./index-DRSBaSu3.js");
5
+ const index = require("./index-DhFNWacm.js");
6
6
  function _interopNamespaceDefault(e) {
7
7
  const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
8
8
  if (e) {
@@ -1,7 +1,7 @@
1
1
  import React__default, { useContext } from "react";
2
2
  import * as ReactRouterDom from 'react-router/dist/production/index.js';
3
3
  export * from 'react-router/dist/production/index.js';
4
- import { R as RouterContext, L as LoggerInstance } from "./index-DyQNwY2M.mjs";
4
+ import { R as RouterContext, L as LoggerInstance } from "./index-DtXhorFI.mjs";
5
5
  function WraperRouter(props) {
6
6
  const { basename, ...propsRes } = props;
7
7
  const routerContextProps = useContext(RouterContext) || {};
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const React = require("react");
4
4
  const ReactRouterDom = require("react-router-dom/");
5
- const index = require("./index-DRSBaSu3.js");
5
+ const index = require("./index-DhFNWacm.js");
6
6
  function _interopNamespaceDefault(e) {
7
7
  const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
8
8
  if (e) {