@module-federation/sdk 0.0.0-next-20240626050252 → 0.0.0-next-20240701075157

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.
package/dist/index.esm.js CHANGED
@@ -1,38 +1,31 @@
1
- function _define_property$4(obj, key, value) {
2
- if (key in obj) {
3
- Object.defineProperty(obj, key, {
4
- value: value,
5
- enumerable: true,
6
- configurable: true,
7
- writable: true
8
- });
9
- } else {
10
- obj[key] = value;
11
- }
12
- return obj;
13
- }
14
- var FederationModuleManifest = 'federation-manifest.json';
15
- var MANIFEST_EXT = '.json';
16
- var BROWSER_LOG_KEY = 'FEDERATION_DEBUG';
17
- var BROWSER_LOG_VALUE = '1';
18
- var NameTransformSymbol = {
1
+ const FederationModuleManifest = 'federation-manifest.json';
2
+ const MANIFEST_EXT = '.json';
3
+ const BROWSER_LOG_KEY = 'FEDERATION_DEBUG';
4
+ const BROWSER_LOG_VALUE = '1';
5
+ const NameTransformSymbol = {
19
6
  AT: '@',
20
7
  HYPHEN: '-',
21
8
  SLASH: '/'
22
9
  };
23
- var _obj;
24
- var NameTransformMap = (_obj = {}, _define_property$4(_obj, NameTransformSymbol.AT, 'scope_'), _define_property$4(_obj, NameTransformSymbol.HYPHEN, '_'), _define_property$4(_obj, NameTransformSymbol.SLASH, '__'), _obj);
25
- var _obj1;
26
- var EncodedNameTransformMap = (_obj1 = {}, _define_property$4(_obj1, NameTransformMap[NameTransformSymbol.AT], NameTransformSymbol.AT), _define_property$4(_obj1, NameTransformMap[NameTransformSymbol.HYPHEN], NameTransformSymbol.HYPHEN), _define_property$4(_obj1, NameTransformMap[NameTransformSymbol.SLASH], NameTransformSymbol.SLASH), _obj1);
27
- var SEPARATOR = ':';
28
- var ManifestFileName = 'mf-manifest.json';
29
- var StatsFileName = 'mf-stats.json';
30
- var MFModuleType = {
10
+ const NameTransformMap = {
11
+ [NameTransformSymbol.AT]: 'scope_',
12
+ [NameTransformSymbol.HYPHEN]: '_',
13
+ [NameTransformSymbol.SLASH]: '__'
14
+ };
15
+ const EncodedNameTransformMap = {
16
+ [NameTransformMap[NameTransformSymbol.AT]]: NameTransformSymbol.AT,
17
+ [NameTransformMap[NameTransformSymbol.HYPHEN]]: NameTransformSymbol.HYPHEN,
18
+ [NameTransformMap[NameTransformSymbol.SLASH]]: NameTransformSymbol.SLASH
19
+ };
20
+ const SEPARATOR = ':';
21
+ const ManifestFileName = 'mf-manifest.json';
22
+ const StatsFileName = 'mf-stats.json';
23
+ const MFModuleType = {
31
24
  NPM: 'npm',
32
25
  APP: 'app'
33
26
  };
34
- var MODULE_DEVTOOL_IDENTIFIER = '__MF_DEVTOOLS_MODULE_INFO__';
35
- var ENCODE_NAME_PREFIX = 'ENCODE_NAME_PREFIX';
27
+ const MODULE_DEVTOOL_IDENTIFIER = '__MF_DEVTOOLS_MODULE_INFO__';
28
+ const ENCODE_NAME_PREFIX = 'ENCODE_NAME_PREFIX';
36
29
 
37
30
  var ContainerPlugin = /*#__PURE__*/Object.freeze({
38
31
  __proto__: null
@@ -59,67 +52,10 @@ function isDebugMode() {
59
52
  }
60
53
  return typeof FEDERATION_DEBUG !== 'undefined' && Boolean(FEDERATION_DEBUG);
61
54
  }
62
- var getProcessEnv = function getProcessEnv() {
55
+ const getProcessEnv = function() {
63
56
  return typeof process !== 'undefined' && process.env ? process.env : {};
64
57
  };
65
58
 
66
- function _array_like_to_array$2(arr, len) {
67
- if (len == null || len > arr.length) len = arr.length;
68
- for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
69
- return arr2;
70
- }
71
- function _array_without_holes(arr) {
72
- if (Array.isArray(arr)) return _array_like_to_array$2(arr);
73
- }
74
- function _class_call_check(instance, Constructor) {
75
- if (!(instance instanceof Constructor)) {
76
- throw new TypeError("Cannot call a class as a function");
77
- }
78
- }
79
- function _defineProperties(target, props) {
80
- for(var i = 0; i < props.length; i++){
81
- var descriptor = props[i];
82
- descriptor.enumerable = descriptor.enumerable || false;
83
- descriptor.configurable = true;
84
- if ("value" in descriptor) descriptor.writable = true;
85
- Object.defineProperty(target, descriptor.key, descriptor);
86
- }
87
- }
88
- function _create_class(Constructor, protoProps, staticProps) {
89
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
90
- if (staticProps) _defineProperties(Constructor, staticProps);
91
- return Constructor;
92
- }
93
- function _define_property$3(obj, key, value) {
94
- if (key in obj) {
95
- Object.defineProperty(obj, key, {
96
- value: value,
97
- enumerable: true,
98
- configurable: true,
99
- writable: true
100
- });
101
- } else {
102
- obj[key] = value;
103
- }
104
- return obj;
105
- }
106
- function _iterable_to_array$1(iter) {
107
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
108
- }
109
- function _non_iterable_spread() {
110
- throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
111
- }
112
- function _to_consumable_array(arr) {
113
- return _array_without_holes(arr) || _iterable_to_array$1(arr) || _unsupported_iterable_to_array$2(arr) || _non_iterable_spread();
114
- }
115
- function _unsupported_iterable_to_array$2(o, minLen) {
116
- if (!o) return;
117
- if (typeof o === "string") return _array_like_to_array$2(o, minLen);
118
- var n = Object.prototype.toString.call(o).slice(8, -1);
119
- if (n === "Object" && o.constructor) n = o.constructor.name;
120
- if (n === "Map" || n === "Set") return Array.from(n);
121
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$2(o, minLen);
122
- }
123
59
  function safeToString(info) {
124
60
  try {
125
61
  return JSON.stringify(info, null, 2);
@@ -127,7 +63,7 @@ function safeToString(info) {
127
63
  return '';
128
64
  }
129
65
  }
130
- var DEBUG_LOG = '[ FEDERATION DEBUG ]';
66
+ const DEBUG_LOG = '[ FEDERATION DEBUG ]';
131
67
  function safeGetLocalStorageItem() {
132
68
  try {
133
69
  if (typeof window !== 'undefined' && window.localStorage) {
@@ -138,11 +74,30 @@ function safeGetLocalStorageItem() {
138
74
  }
139
75
  return false;
140
76
  }
141
- var Logger = /*#__PURE__*/ function() {
142
- function Logger(identifier) {
143
- _class_call_check(this, Logger);
144
- _define_property$3(this, "enable", false);
145
- _define_property$3(this, "identifier", void 0);
77
+ let Logger = class Logger {
78
+ info(msg, info) {
79
+ if (this.enable) {
80
+ const argsToString = safeToString(info) || '';
81
+ if (isBrowserEnv()) {
82
+ console.info(`%c ${this.identifier}: ${msg} ${argsToString}`, 'color:#3300CC');
83
+ } else {
84
+ console.info('\x1b[34m%s', `${this.identifier}: ${msg} ${argsToString ? `\n${argsToString}` : ''}`);
85
+ }
86
+ }
87
+ }
88
+ logOriginalInfo(...args) {
89
+ if (this.enable) {
90
+ if (isBrowserEnv()) {
91
+ console.info(`%c ${this.identifier}: OriginalInfo`, 'color:#3300CC');
92
+ console.log(...args);
93
+ } else {
94
+ console.info(`%c ${this.identifier}: OriginalInfo`, 'color:#3300CC');
95
+ console.log(...args);
96
+ }
97
+ }
98
+ }
99
+ constructor(identifier){
100
+ this.enable = false;
146
101
  this.identifier = identifier || DEBUG_LOG;
147
102
  if (isBrowserEnv() && safeGetLocalStorageItem()) {
148
103
  this.enable = true;
@@ -150,182 +105,88 @@ var Logger = /*#__PURE__*/ function() {
150
105
  this.enable = true;
151
106
  }
152
107
  }
153
- _create_class(Logger, [
154
- {
155
- key: "info",
156
- value: function info(msg, info) {
157
- if (this.enable) {
158
- var argsToString = safeToString(info) || '';
159
- if (isBrowserEnv()) {
160
- console.info("%c ".concat(this.identifier, ": ").concat(msg, " ").concat(argsToString), 'color:#3300CC');
161
- } else {
162
- console.info('\x1b[34m%s', "".concat(this.identifier, ": ").concat(msg, " ").concat(argsToString ? "\n".concat(argsToString) : ''));
163
- }
164
- }
165
- }
166
- },
167
- {
168
- key: "logOriginalInfo",
169
- value: function logOriginalInfo() {
170
- for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
171
- args[_key] = arguments[_key];
172
- }
173
- if (this.enable) {
174
- if (isBrowserEnv()) {
175
- var _console;
176
- console.info("%c ".concat(this.identifier, ": OriginalInfo"), 'color:#3300CC');
177
- (_console = console).log.apply(_console, _to_consumable_array(args));
178
- } else {
179
- var _console1;
180
- console.info("%c ".concat(this.identifier, ": OriginalInfo"), 'color:#3300CC');
181
- (_console1 = console).log.apply(_console1, _to_consumable_array(args));
182
- }
183
- }
184
- }
185
- }
186
- ]);
187
- return Logger;
188
- }();
108
+ };
189
109
 
190
- function _array_like_to_array$1(arr, len) {
191
- if (len == null || len > arr.length) len = arr.length;
192
- for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
193
- return arr2;
194
- }
195
- function _array_with_holes$1(arr) {
196
- if (Array.isArray(arr)) return arr;
197
- }
198
- function _iterable_to_array(iter) {
199
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
200
- }
201
- function _iterable_to_array_limit$1(arr, i) {
202
- var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
203
- if (_i == null) return;
204
- var _arr = [];
205
- var _n = true;
206
- var _d = false;
207
- var _s, _e;
208
- try {
209
- for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
210
- _arr.push(_s.value);
211
- if (i && _arr.length === i) break;
212
- }
213
- } catch (err) {
214
- _d = true;
215
- _e = err;
216
- } finally{
217
- try {
218
- if (!_n && _i["return"] != null) _i["return"]();
219
- } finally{
220
- if (_d) throw _e;
221
- }
222
- }
223
- return _arr;
224
- }
225
- function _non_iterable_rest$1() {
226
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
227
- }
228
- function _sliced_to_array$1(arr, i) {
229
- return _array_with_holes$1(arr) || _iterable_to_array_limit$1(arr, i) || _unsupported_iterable_to_array$1(arr, i) || _non_iterable_rest$1();
230
- }
231
- function _to_array(arr) {
232
- return _array_with_holes$1(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array$1(arr) || _non_iterable_rest$1();
233
- }
234
- function _unsupported_iterable_to_array$1(o, minLen) {
235
- if (!o) return;
236
- if (typeof o === "string") return _array_like_to_array$1(o, minLen);
237
- var n = Object.prototype.toString.call(o).slice(8, -1);
238
- if (n === "Object" && o.constructor) n = o.constructor.name;
239
- if (n === "Map" || n === "Set") return Array.from(n);
240
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$1(o, minLen);
241
- }
242
- var LOG_CATEGORY = '[ Federation Runtime ]';
110
+ const LOG_CATEGORY = '[ Federation Runtime ]';
243
111
  // entry: name:version version : 1.0.0 | ^1.2.3
244
112
  // entry: name:entry entry: https://localhost:9000/federation-manifest.json
245
- var parseEntry = function(str, devVerOrUrl) {
246
- var separator = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : SEPARATOR;
247
- var strSplit = str.split(separator);
248
- var devVersionOrUrl = getProcessEnv()['NODE_ENV'] === 'development' && devVerOrUrl;
249
- var defaultVersion = '*';
250
- var isEntry = function(s) {
251
- return s.startsWith('http') || s.includes(MANIFEST_EXT);
252
- };
113
+ const parseEntry = (str, devVerOrUrl, separator = SEPARATOR)=>{
114
+ const strSplit = str.split(separator);
115
+ const devVersionOrUrl = getProcessEnv()['NODE_ENV'] === 'development' && devVerOrUrl;
116
+ const defaultVersion = '*';
117
+ const isEntry = (s)=>s.startsWith('http') || s.includes(MANIFEST_EXT);
253
118
  // Check if the string starts with a type
254
119
  if (strSplit.length >= 2) {
255
- var _strSplit = _to_array(strSplit), name = _strSplit[0], versionOrEntryArr = _strSplit.slice(1);
120
+ let [name, ...versionOrEntryArr] = strSplit;
256
121
  if (str.startsWith(separator)) {
257
122
  versionOrEntryArr = [
258
123
  devVersionOrUrl || strSplit.slice(-1)[0]
259
124
  ];
260
125
  name = strSplit.slice(0, -1).join(separator);
261
126
  }
262
- var versionOrEntry = devVersionOrUrl || versionOrEntryArr.join(separator);
127
+ let versionOrEntry = devVersionOrUrl || versionOrEntryArr.join(separator);
263
128
  if (isEntry(versionOrEntry)) {
264
129
  return {
265
- name: name,
130
+ name,
266
131
  entry: versionOrEntry
267
132
  };
268
133
  } else {
269
134
  // Apply version rule
270
135
  // devVersionOrUrl => inputVersion => defaultVersion
271
136
  return {
272
- name: name,
137
+ name,
273
138
  version: versionOrEntry || defaultVersion
274
139
  };
275
140
  }
276
141
  } else if (strSplit.length === 1) {
277
- var _strSplit1 = _sliced_to_array$1(strSplit, 1), name1 = _strSplit1[0];
142
+ const [name] = strSplit;
278
143
  if (devVersionOrUrl && isEntry(devVersionOrUrl)) {
279
144
  return {
280
- name: name1,
145
+ name,
281
146
  entry: devVersionOrUrl
282
147
  };
283
148
  }
284
149
  return {
285
- name: name1,
150
+ name,
286
151
  version: devVersionOrUrl || defaultVersion
287
152
  };
288
153
  } else {
289
- throw "Invalid entry value: ".concat(str);
154
+ throw `Invalid entry value: ${str}`;
290
155
  }
291
156
  };
292
- var logger = new Logger();
293
- var composeKeyWithSeparator = function composeKeyWithSeparator() {
294
- for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
295
- args[_key] = arguments[_key];
296
- }
157
+ const logger = new Logger();
158
+ const composeKeyWithSeparator = function(...args) {
297
159
  if (!args.length) {
298
160
  return '';
299
161
  }
300
- return args.reduce(function(sum, cur) {
162
+ return args.reduce((sum, cur)=>{
301
163
  if (!cur) {
302
164
  return sum;
303
165
  }
304
166
  if (!sum) {
305
167
  return cur;
306
168
  }
307
- return "".concat(sum).concat(SEPARATOR).concat(cur);
169
+ return `${sum}${SEPARATOR}${cur}`;
308
170
  }, '');
309
171
  };
310
- var encodeName = function encodeName(name) {
311
- var prefix = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : '', withExt = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false;
172
+ const encodeName = function(name, prefix = '', withExt = false) {
312
173
  try {
313
- var ext = withExt ? '.js' : '';
314
- return "".concat(prefix).concat(name.replace(new RegExp("".concat(NameTransformSymbol.AT), 'g'), NameTransformMap[NameTransformSymbol.AT]).replace(new RegExp("".concat(NameTransformSymbol.HYPHEN), 'g'), NameTransformMap[NameTransformSymbol.HYPHEN]).replace(new RegExp("".concat(NameTransformSymbol.SLASH), 'g'), NameTransformMap[NameTransformSymbol.SLASH])).concat(ext);
174
+ const ext = withExt ? '.js' : '';
175
+ return `${prefix}${name.replace(new RegExp(`${NameTransformSymbol.AT}`, 'g'), NameTransformMap[NameTransformSymbol.AT]).replace(new RegExp(`${NameTransformSymbol.HYPHEN}`, 'g'), NameTransformMap[NameTransformSymbol.HYPHEN]).replace(new RegExp(`${NameTransformSymbol.SLASH}`, 'g'), NameTransformMap[NameTransformSymbol.SLASH])}${ext}`;
315
176
  } catch (err) {
316
177
  throw err;
317
178
  }
318
179
  };
319
- var decodeName = function decodeName(name, prefix, withExt) {
180
+ const decodeName = function(name, prefix, withExt) {
320
181
  try {
321
- var decodedName = name;
182
+ let decodedName = name;
322
183
  if (prefix) {
323
184
  if (!decodedName.startsWith(prefix)) {
324
185
  return decodedName;
325
186
  }
326
187
  decodedName = decodedName.replace(new RegExp(prefix, 'g'), '');
327
188
  }
328
- decodedName = decodedName.replace(new RegExp("".concat(NameTransformMap[NameTransformSymbol.AT]), 'g'), EncodedNameTransformMap[NameTransformMap[NameTransformSymbol.AT]]).replace(new RegExp("".concat(NameTransformMap[NameTransformSymbol.SLASH]), 'g'), EncodedNameTransformMap[NameTransformMap[NameTransformSymbol.SLASH]]).replace(new RegExp("".concat(NameTransformMap[NameTransformSymbol.HYPHEN]), 'g'), EncodedNameTransformMap[NameTransformMap[NameTransformSymbol.HYPHEN]]);
189
+ decodedName = decodedName.replace(new RegExp(`${NameTransformMap[NameTransformSymbol.AT]}`, 'g'), EncodedNameTransformMap[NameTransformMap[NameTransformSymbol.AT]]).replace(new RegExp(`${NameTransformMap[NameTransformSymbol.SLASH]}`, 'g'), EncodedNameTransformMap[NameTransformMap[NameTransformSymbol.SLASH]]).replace(new RegExp(`${NameTransformMap[NameTransformSymbol.HYPHEN]}`, 'g'), EncodedNameTransformMap[NameTransformMap[NameTransformSymbol.HYPHEN]]);
329
190
  if (withExt) {
330
191
  decodedName = decodedName.replace('.js', '');
331
192
  }
@@ -334,11 +195,11 @@ var decodeName = function decodeName(name, prefix, withExt) {
334
195
  throw err;
335
196
  }
336
197
  };
337
- var generateExposeFilename = function(exposeName, withExt) {
198
+ const generateExposeFilename = (exposeName, withExt)=>{
338
199
  if (!exposeName) {
339
200
  return '';
340
201
  }
341
- var expose = exposeName;
202
+ let expose = exposeName;
342
203
  if (expose === '.') {
343
204
  expose = 'default_export';
344
205
  }
@@ -347,98 +208,57 @@ var generateExposeFilename = function(exposeName, withExt) {
347
208
  }
348
209
  return encodeName(expose, '__federation_expose_', withExt);
349
210
  };
350
- var generateShareFilename = function(pkgName, withExt) {
211
+ const generateShareFilename = (pkgName, withExt)=>{
351
212
  if (!pkgName) {
352
213
  return '';
353
214
  }
354
215
  return encodeName(pkgName, '__federation_shared_', withExt);
355
216
  };
356
- var getResourceUrl = function(module, sourceUrl) {
217
+ const getResourceUrl = (module, sourceUrl)=>{
357
218
  if ('getPublicPath' in module) {
358
- var publicPath;
219
+ let publicPath;
359
220
  if (!module.getPublicPath.startsWith('function')) {
360
221
  publicPath = new Function(module.getPublicPath)();
361
222
  } else {
362
223
  publicPath = new Function('return ' + module.getPublicPath)()();
363
224
  }
364
- return "".concat(publicPath).concat(sourceUrl);
225
+ return `${publicPath}${sourceUrl}`;
365
226
  } else if ('publicPath' in module) {
366
- return "".concat(module.publicPath).concat(sourceUrl);
227
+ return `${module.publicPath}${sourceUrl}`;
367
228
  } else {
368
229
  console.warn('Cannot get resource URL. If in debug mode, please ignore.', module, sourceUrl);
369
230
  return '';
370
231
  }
371
232
  };
372
233
  // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
373
- var assert = function(condition, msg) {
234
+ const assert = (condition, msg)=>{
374
235
  if (!condition) {
375
236
  error(msg);
376
237
  }
377
238
  };
378
- var error = function(msg) {
379
- throw new Error("".concat(LOG_CATEGORY, ": ").concat(msg));
239
+ const error = (msg)=>{
240
+ throw new Error(`${LOG_CATEGORY}: ${msg}`);
380
241
  };
381
- var warn = function(msg) {
382
- console.warn("".concat(LOG_CATEGORY, ": ").concat(msg));
242
+ const warn = (msg)=>{
243
+ console.warn(`${LOG_CATEGORY}: ${msg}`);
383
244
  };
384
245
 
385
- function _define_property$2(obj, key, value) {
386
- if (key in obj) {
387
- Object.defineProperty(obj, key, {
388
- value: value,
389
- enumerable: true,
390
- configurable: true,
391
- writable: true
392
- });
393
- } else {
394
- obj[key] = value;
395
- }
396
- return obj;
397
- }
398
- function _object_spread$2(target) {
399
- for(var i = 1; i < arguments.length; i++){
400
- var source = arguments[i] != null ? arguments[i] : {};
401
- var ownKeys = Object.keys(source);
402
- if (typeof Object.getOwnPropertySymbols === "function") {
403
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
404
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
405
- }));
406
- }
407
- ownKeys.forEach(function(key) {
408
- _define_property$2(target, key, source[key]);
409
- });
410
- }
411
- return target;
412
- }
413
- function ownKeys(object, enumerableOnly) {
414
- var keys = Object.keys(object);
415
- if (Object.getOwnPropertySymbols) {
416
- var symbols = Object.getOwnPropertySymbols(object);
417
- if (enumerableOnly) {
418
- symbols = symbols.filter(function(sym) {
419
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
420
- });
246
+ function _extends() {
247
+ _extends = Object.assign || function assign(target) {
248
+ for(var i = 1; i < arguments.length; i++){
249
+ var source = arguments[i];
250
+ for(var key in source)if (Object.prototype.hasOwnProperty.call(source, key)) target[key] = source[key];
421
251
  }
422
- keys.push.apply(keys, symbols);
423
- }
424
- return keys;
425
- }
426
- function _object_spread_props(target, source) {
427
- source = source != null ? source : {};
428
- if (Object.getOwnPropertyDescriptors) {
429
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
430
- } else {
431
- ownKeys(Object(source)).forEach(function(key) {
432
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
433
- });
434
- }
435
- return target;
252
+ return target;
253
+ };
254
+ return _extends.apply(this, arguments);
436
255
  }
437
- var simpleJoinRemoteEntry = function(rPath, rName) {
256
+
257
+ const simpleJoinRemoteEntry = (rPath, rName)=>{
438
258
  if (!rPath) {
439
259
  return rName;
440
260
  }
441
- var transformPath = function(str) {
261
+ const transformPath = (str)=>{
442
262
  if (str === '.') {
443
263
  return '';
444
264
  }
@@ -446,7 +266,7 @@ var simpleJoinRemoteEntry = function(rPath, rName) {
446
266
  return str.replace('./', '');
447
267
  }
448
268
  if (str.startsWith('/')) {
449
- var strWithoutSlash = str.slice(1);
269
+ const strWithoutSlash = str.slice(1);
450
270
  if (strWithoutSlash.endsWith('/')) {
451
271
  return strWithoutSlash.slice(0, -1);
452
272
  }
@@ -454,26 +274,25 @@ var simpleJoinRemoteEntry = function(rPath, rName) {
454
274
  }
455
275
  return str;
456
276
  };
457
- var transformedPath = transformPath(rPath);
277
+ const transformedPath = transformPath(rPath);
458
278
  if (!transformedPath) {
459
279
  return rName;
460
280
  }
461
281
  if (transformedPath.endsWith('/')) {
462
- return "".concat(transformedPath).concat(rName);
282
+ return `${transformedPath}${rName}`;
463
283
  }
464
- return "".concat(transformedPath, "/").concat(rName);
284
+ return `${transformedPath}/${rName}`;
465
285
  };
466
286
  function inferAutoPublicPath(url) {
467
287
  return url.replace(/#.*$/, '').replace(/\?.*$/, '').replace(/\/[^\/]+$/, '/');
468
288
  }
469
289
  // Priority: overrides > remotes
470
290
  // eslint-disable-next-line max-lines-per-function
471
- function generateSnapshotFromManifest(manifest) {
472
- var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
291
+ function generateSnapshotFromManifest(manifest, options = {}) {
473
292
  var _manifest_metaData, _manifest_metaData1;
474
- var _options_remotes = options.remotes, remotes = _options_remotes === void 0 ? {} : _options_remotes, _options_overrides = options.overrides, overrides = _options_overrides === void 0 ? {} : _options_overrides, version = options.version;
475
- var remoteSnapshot;
476
- var getPublicPath = function() {
293
+ const { remotes = {}, overrides = {}, version } = options;
294
+ let remoteSnapshot;
295
+ const getPublicPath = ()=>{
477
296
  if ('publicPath' in manifest.metaData) {
478
297
  if (manifest.metaData.publicPath === 'auto' && version) {
479
298
  // use same implementation as publicPath auto runtime module implements
@@ -484,14 +303,14 @@ function generateSnapshotFromManifest(manifest) {
484
303
  return manifest.metaData.getPublicPath;
485
304
  }
486
305
  };
487
- var overridesKeys = Object.keys(overrides);
488
- var remotesInfo = {};
306
+ const overridesKeys = Object.keys(overrides);
307
+ let remotesInfo = {};
489
308
  // If remotes are not provided, only the remotes in the manifest will be read
490
309
  if (!Object.keys(remotes).length) {
491
310
  var _manifest_remotes;
492
- remotesInfo = ((_manifest_remotes = manifest.remotes) === null || _manifest_remotes === void 0 ? void 0 : _manifest_remotes.reduce(function(res, next) {
493
- var matchedVersion;
494
- var name = next.federationContainerName;
311
+ remotesInfo = ((_manifest_remotes = manifest.remotes) == null ? void 0 : _manifest_remotes.reduce((res, next)=>{
312
+ let matchedVersion;
313
+ const name = next.federationContainerName;
495
314
  // overrides have higher priority
496
315
  if (overridesKeys.includes(name)) {
497
316
  matchedVersion = overrides[name];
@@ -503,69 +322,63 @@ function generateSnapshotFromManifest(manifest) {
503
322
  }
504
323
  }
505
324
  res[name] = {
506
- matchedVersion: matchedVersion
325
+ matchedVersion
507
326
  };
508
327
  return res;
509
328
  }, {})) || {};
510
329
  }
511
330
  // If remotes (deploy scenario) are specified, they need to be traversed again
512
- Object.keys(remotes).forEach(function(key) {
513
- return remotesInfo[key] = {
331
+ Object.keys(remotes).forEach((key)=>remotesInfo[key] = {
514
332
  // overrides will override dependencies
515
333
  matchedVersion: overridesKeys.includes(key) ? overrides[key] : remotes[key]
516
- };
517
- });
518
- var _manifest_metaData2 = manifest.metaData, _manifest_metaData_remoteEntry = _manifest_metaData2.remoteEntry, remoteEntryPath = _manifest_metaData_remoteEntry.path, remoteEntryName = _manifest_metaData_remoteEntry.name, remoteEntryType = _manifest_metaData_remoteEntry.type, remoteTypes = _manifest_metaData2.types, buildVersion = _manifest_metaData2.buildInfo.buildVersion, globalName = _manifest_metaData2.globalName, ssrRemoteEntry = _manifest_metaData2.ssrRemoteEntry;
519
- var exposes = manifest.exposes;
520
- var basicRemoteSnapshot = {
334
+ });
335
+ const { remoteEntry: { path: remoteEntryPath, name: remoteEntryName, type: remoteEntryType }, types: remoteTypes, buildInfo: { buildVersion }, globalName, ssrRemoteEntry } = manifest.metaData;
336
+ const { exposes } = manifest;
337
+ let basicRemoteSnapshot = {
521
338
  version: version ? version : '',
522
- buildVersion: buildVersion,
523
- globalName: globalName,
339
+ buildVersion,
340
+ globalName,
524
341
  remoteEntry: simpleJoinRemoteEntry(remoteEntryPath, remoteEntryName),
525
- remoteEntryType: remoteEntryType,
342
+ remoteEntryType,
526
343
  remoteTypes: simpleJoinRemoteEntry(remoteTypes.path, remoteTypes.name),
527
344
  remoteTypesZip: remoteTypes.zip || '',
528
345
  remoteTypesAPI: remoteTypes.api || '',
529
- remotesInfo: remotesInfo,
530
- shared: manifest === null || manifest === void 0 ? void 0 : manifest.shared.map(function(item) {
531
- return {
346
+ remotesInfo,
347
+ shared: manifest == null ? void 0 : manifest.shared.map((item)=>({
532
348
  assets: item.assets,
533
349
  sharedName: item.name,
534
350
  version: item.version
535
- };
536
- }),
537
- modules: exposes === null || exposes === void 0 ? void 0 : exposes.map(function(expose) {
538
- return {
351
+ })),
352
+ modules: exposes == null ? void 0 : exposes.map((expose)=>({
539
353
  moduleName: expose.name,
540
354
  modulePath: expose.path,
541
355
  assets: expose.assets
542
- };
543
- })
356
+ }))
544
357
  };
545
- if ((_manifest_metaData = manifest.metaData) === null || _manifest_metaData === void 0 ? void 0 : _manifest_metaData.prefetchInterface) {
546
- var prefetchInterface = manifest.metaData.prefetchInterface;
547
- basicRemoteSnapshot = _object_spread_props(_object_spread$2({}, basicRemoteSnapshot), {
548
- prefetchInterface: prefetchInterface
358
+ if ((_manifest_metaData = manifest.metaData) == null ? void 0 : _manifest_metaData.prefetchInterface) {
359
+ const prefetchInterface = manifest.metaData.prefetchInterface;
360
+ basicRemoteSnapshot = _extends({}, basicRemoteSnapshot, {
361
+ prefetchInterface
549
362
  });
550
363
  }
551
- if ((_manifest_metaData1 = manifest.metaData) === null || _manifest_metaData1 === void 0 ? void 0 : _manifest_metaData1.prefetchEntry) {
552
- var _manifest_metaData_prefetchEntry = manifest.metaData.prefetchEntry, path = _manifest_metaData_prefetchEntry.path, name = _manifest_metaData_prefetchEntry.name, type = _manifest_metaData_prefetchEntry.type;
553
- basicRemoteSnapshot = _object_spread_props(_object_spread$2({}, basicRemoteSnapshot), {
364
+ if ((_manifest_metaData1 = manifest.metaData) == null ? void 0 : _manifest_metaData1.prefetchEntry) {
365
+ const { path, name, type } = manifest.metaData.prefetchEntry;
366
+ basicRemoteSnapshot = _extends({}, basicRemoteSnapshot, {
554
367
  prefetchEntry: simpleJoinRemoteEntry(path, name),
555
368
  prefetchEntryType: type
556
369
  });
557
370
  }
558
371
  if ('publicPath' in manifest.metaData) {
559
- remoteSnapshot = _object_spread_props(_object_spread$2({}, basicRemoteSnapshot), {
372
+ remoteSnapshot = _extends({}, basicRemoteSnapshot, {
560
373
  publicPath: getPublicPath()
561
374
  });
562
375
  } else {
563
- remoteSnapshot = _object_spread_props(_object_spread$2({}, basicRemoteSnapshot), {
376
+ remoteSnapshot = _extends({}, basicRemoteSnapshot, {
564
377
  getPublicPath: getPublicPath()
565
378
  });
566
379
  }
567
380
  if (ssrRemoteEntry) {
568
- var fullSSRRemoteEntry = simpleJoinRemoteEntry(ssrRemoteEntry.path, ssrRemoteEntry.name);
381
+ const fullSSRRemoteEntry = simpleJoinRemoteEntry(ssrRemoteEntry.path, ssrRemoteEntry.name);
569
382
  remoteSnapshot.ssrRemoteEntry = fullSSRRemoteEntry;
570
383
  remoteSnapshot.ssrRemoteEntryType = 'commonjs-module';
571
384
  }
@@ -579,228 +392,34 @@ function isManifestProvider(moduleInfo) {
579
392
  }
580
393
  }
581
394
 
582
- function asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, key, arg) {
395
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
396
+ async function safeWrapper(callback, disableWarn) {
583
397
  try {
584
- var info = gen[key](arg);
585
- var value = info.value;
586
- } catch (error) {
587
- reject(error);
398
+ const res = await callback();
399
+ return res;
400
+ } catch (e) {
401
+ !disableWarn && warn(e);
588
402
  return;
589
403
  }
590
- if (info.done) {
591
- resolve(value);
592
- } else {
593
- Promise.resolve(value).then(_next, _throw);
594
- }
595
- }
596
- function _async_to_generator$1(fn) {
597
- return function() {
598
- var self = this, args = arguments;
599
- return new Promise(function(resolve, reject) {
600
- var gen = fn.apply(self, args);
601
- function _next(value) {
602
- asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "next", value);
603
- }
604
- function _throw(err) {
605
- asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "throw", err);
606
- }
607
- _next(undefined);
608
- });
609
- };
610
- }
611
- function _define_property$1(obj, key, value) {
612
- if (key in obj) {
613
- Object.defineProperty(obj, key, {
614
- value: value,
615
- enumerable: true,
616
- configurable: true,
617
- writable: true
618
- });
619
- } else {
620
- obj[key] = value;
621
- }
622
- return obj;
623
- }
624
- function _instanceof(left, right) {
625
- if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
626
- return !!right[Symbol.hasInstance](left);
627
- } else {
628
- return left instanceof right;
629
- }
630
- }
631
- function _object_spread$1(target) {
632
- for(var i = 1; i < arguments.length; i++){
633
- var source = arguments[i] != null ? arguments[i] : {};
634
- var ownKeys = Object.keys(source);
635
- if (typeof Object.getOwnPropertySymbols === "function") {
636
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
637
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
638
- }));
639
- }
640
- ownKeys.forEach(function(key) {
641
- _define_property$1(target, key, source[key]);
642
- });
643
- }
644
- return target;
645
- }
646
- function _type_of$2(obj) {
647
- "@swc/helpers - typeof";
648
- return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
649
- }
650
- function _ts_generator$1(thisArg, body) {
651
- var f, y, t, g, _ = {
652
- label: 0,
653
- sent: function() {
654
- if (t[0] & 1) throw t[1];
655
- return t[1];
656
- },
657
- trys: [],
658
- ops: []
659
- };
660
- return g = {
661
- next: verb(0),
662
- "throw": verb(1),
663
- "return": verb(2)
664
- }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
665
- return this;
666
- }), g;
667
- function verb(n) {
668
- return function(v) {
669
- return step([
670
- n,
671
- v
672
- ]);
673
- };
674
- }
675
- function step(op) {
676
- if (f) throw new TypeError("Generator is already executing.");
677
- while(_)try {
678
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
679
- if (y = 0, t) op = [
680
- op[0] & 2,
681
- t.value
682
- ];
683
- switch(op[0]){
684
- case 0:
685
- case 1:
686
- t = op;
687
- break;
688
- case 4:
689
- _.label++;
690
- return {
691
- value: op[1],
692
- done: false
693
- };
694
- case 5:
695
- _.label++;
696
- y = op[1];
697
- op = [
698
- 0
699
- ];
700
- continue;
701
- case 7:
702
- op = _.ops.pop();
703
- _.trys.pop();
704
- continue;
705
- default:
706
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
707
- _ = 0;
708
- continue;
709
- }
710
- if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
711
- _.label = op[1];
712
- break;
713
- }
714
- if (op[0] === 6 && _.label < t[1]) {
715
- _.label = t[1];
716
- t = op;
717
- break;
718
- }
719
- if (t && _.label < t[2]) {
720
- _.label = t[2];
721
- _.ops.push(op);
722
- break;
723
- }
724
- if (t[2]) _.ops.pop();
725
- _.trys.pop();
726
- continue;
727
- }
728
- op = body.call(thisArg, _);
729
- } catch (e) {
730
- op = [
731
- 6,
732
- e
733
- ];
734
- y = 0;
735
- } finally{
736
- f = t = 0;
737
- }
738
- if (op[0] & 5) throw op[1];
739
- return {
740
- value: op[0] ? op[1] : void 0,
741
- done: true
742
- };
743
- }
744
- }
745
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
746
- function safeWrapper(callback, disableWarn) {
747
- return _safeWrapper.apply(this, arguments);
748
- }
749
- function _safeWrapper() {
750
- _safeWrapper = _async_to_generator$1(function(callback, disableWarn) {
751
- var res, e;
752
- return _ts_generator$1(this, function(_state) {
753
- switch(_state.label){
754
- case 0:
755
- _state.trys.push([
756
- 0,
757
- 2,
758
- ,
759
- 3
760
- ]);
761
- return [
762
- 4,
763
- callback()
764
- ];
765
- case 1:
766
- res = _state.sent();
767
- return [
768
- 2,
769
- res
770
- ];
771
- case 2:
772
- e = _state.sent();
773
- !disableWarn && warn(e);
774
- return [
775
- 2
776
- ];
777
- case 3:
778
- return [
779
- 2
780
- ];
781
- }
782
- });
783
- });
784
- return _safeWrapper.apply(this, arguments);
785
404
  }
786
405
  function isStaticResourcesEqual(url1, url2) {
787
- var REG_EXP = /^(https?:)?\/\//i;
406
+ const REG_EXP = /^(https?:)?\/\//i;
788
407
  // Transform url1 and url2 into relative paths
789
- var relativeUrl1 = url1.replace(REG_EXP, '').replace(/\/$/, '');
790
- var relativeUrl2 = url2.replace(REG_EXP, '').replace(/\/$/, '');
408
+ const relativeUrl1 = url1.replace(REG_EXP, '').replace(/\/$/, '');
409
+ const relativeUrl2 = url2.replace(REG_EXP, '').replace(/\/$/, '');
791
410
  // Check if the relative paths are identical
792
411
  return relativeUrl1 === relativeUrl2;
793
412
  }
794
413
  function createScript(info) {
795
414
  // Retrieve the existing script element by its src attribute
796
- var script = null;
797
- var needAttach = true;
798
- var timeout = 20000;
799
- var timeoutId;
800
- var scripts = document.getElementsByTagName('script');
801
- for(var i = 0; i < scripts.length; i++){
802
- var s = scripts[i];
803
- var scriptSrc = s.getAttribute('src');
415
+ let script = null;
416
+ let needAttach = true;
417
+ let timeout = 20000;
418
+ let timeoutId;
419
+ const scripts = document.getElementsByTagName('script');
420
+ for(let i = 0; i < scripts.length; i++){
421
+ const s = scripts[i];
422
+ const scriptSrc = s.getAttribute('src');
804
423
  if (scriptSrc && isStaticResourcesEqual(scriptSrc, info.url)) {
805
424
  script = s;
806
425
  needAttach = false;
@@ -812,17 +431,17 @@ function createScript(info) {
812
431
  script.type = 'text/javascript';
813
432
  script.src = info.url;
814
433
  if (info.createScriptHook) {
815
- var createScriptRes = info.createScriptHook(info.url);
816
- if (_instanceof(createScriptRes, HTMLScriptElement)) {
434
+ const createScriptRes = info.createScriptHook(info.url);
435
+ if (createScriptRes instanceof HTMLScriptElement) {
817
436
  script = createScriptRes;
818
- } else if ((typeof createScriptRes === "undefined" ? "undefined" : _type_of$2(createScriptRes)) === 'object') {
437
+ } else if (typeof createScriptRes === 'object') {
819
438
  if (createScriptRes.script) script = createScriptRes.script;
820
439
  if (createScriptRes.timeout) timeout = createScriptRes.timeout;
821
440
  }
822
441
  }
823
- var attrs = info.attrs;
442
+ const attrs = info.attrs;
824
443
  if (attrs) {
825
- Object.keys(attrs).forEach(function(name) {
444
+ Object.keys(attrs).forEach((name)=>{
826
445
  if (script) {
827
446
  if (name === 'async' || name === 'defer') {
828
447
  script[name] = attrs[name];
@@ -834,50 +453,50 @@ function createScript(info) {
834
453
  });
835
454
  }
836
455
  }
837
- var onScriptComplete = function(prev, // eslint-disable-next-line @typescript-eslint/no-explicit-any
838
- event) {
456
+ const onScriptComplete = (prev, // eslint-disable-next-line @typescript-eslint/no-explicit-any
457
+ event)=>{
839
458
  var _info_cb;
840
459
  clearTimeout(timeoutId);
841
460
  // Prevent memory leaks in IE.
842
461
  if (script) {
843
462
  script.onerror = null;
844
463
  script.onload = null;
845
- safeWrapper(function() {
846
- var _info_needDeleteScript = info.needDeleteScript, needDeleteScript = _info_needDeleteScript === void 0 ? true : _info_needDeleteScript;
464
+ safeWrapper(()=>{
465
+ const { needDeleteScript = true } = info;
847
466
  if (needDeleteScript) {
848
- (script === null || script === void 0 ? void 0 : script.parentNode) && script.parentNode.removeChild(script);
467
+ (script == null ? void 0 : script.parentNode) && script.parentNode.removeChild(script);
849
468
  }
850
469
  });
851
470
  if (prev) {
852
471
  var _info_cb1;
853
472
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
854
- var res = prev(event);
855
- info === null || info === void 0 ? void 0 : (_info_cb1 = info.cb) === null || _info_cb1 === void 0 ? void 0 : _info_cb1.call(info);
473
+ const res = prev(event);
474
+ info == null ? void 0 : (_info_cb1 = info.cb) == null ? void 0 : _info_cb1.call(info);
856
475
  return res;
857
476
  }
858
477
  }
859
- info === null || info === void 0 ? void 0 : (_info_cb = info.cb) === null || _info_cb === void 0 ? void 0 : _info_cb.call(info);
478
+ info == null ? void 0 : (_info_cb = info.cb) == null ? void 0 : _info_cb.call(info);
860
479
  };
861
480
  script.onerror = onScriptComplete.bind(null, script.onerror);
862
481
  script.onload = onScriptComplete.bind(null, script.onload);
863
- timeoutId = setTimeout(function() {
864
- onScriptComplete(null, new Error('Remote script "'.concat(info.url, '" time-outed.')));
482
+ timeoutId = setTimeout(()=>{
483
+ onScriptComplete(null, new Error(`Remote script "${info.url}" time-outed.`));
865
484
  }, timeout);
866
485
  return {
867
- script: script,
868
- needAttach: needAttach
486
+ script,
487
+ needAttach
869
488
  };
870
489
  }
871
490
  function createLink(info) {
872
491
  // <link rel="preload" href="script.js" as="script">
873
492
  // Retrieve the existing script element by its src attribute
874
- var link = null;
875
- var needAttach = true;
876
- var links = document.getElementsByTagName('link');
877
- for(var i = 0; i < links.length; i++){
878
- var l = links[i];
879
- var linkHref = l.getAttribute('href');
880
- var linkRef = l.getAttribute('ref');
493
+ let link = null;
494
+ let needAttach = true;
495
+ const links = document.getElementsByTagName('link');
496
+ for(let i = 0; i < links.length; i++){
497
+ const l = links[i];
498
+ const linkHref = l.getAttribute('href');
499
+ const linkRef = l.getAttribute('ref');
881
500
  if (linkHref && isStaticResourcesEqual(linkHref, info.url) && linkRef === info.attrs['ref']) {
882
501
  link = l;
883
502
  needAttach = false;
@@ -888,35 +507,35 @@ function createLink(info) {
888
507
  link = document.createElement('link');
889
508
  link.setAttribute('href', info.url);
890
509
  if (info.createLinkHook) {
891
- var createLinkRes = info.createLinkHook(info.url);
892
- if (_instanceof(createLinkRes, HTMLLinkElement)) {
510
+ const createLinkRes = info.createLinkHook(info.url);
511
+ if (createLinkRes instanceof HTMLLinkElement) {
893
512
  link = createLinkRes;
894
513
  }
895
514
  }
896
- var attrs = info.attrs;
515
+ const attrs = info.attrs;
897
516
  if (attrs) {
898
- Object.keys(attrs).forEach(function(name) {
517
+ Object.keys(attrs).forEach((name)=>{
899
518
  if (link && !link.getAttribute(name)) {
900
519
  link.setAttribute(name, attrs[name]);
901
520
  }
902
521
  });
903
522
  }
904
523
  }
905
- var onLinkComplete = function(prev, // eslint-disable-next-line @typescript-eslint/no-explicit-any
906
- event) {
524
+ const onLinkComplete = (prev, // eslint-disable-next-line @typescript-eslint/no-explicit-any
525
+ event)=>{
907
526
  // Prevent memory leaks in IE.
908
527
  if (link) {
909
528
  link.onerror = null;
910
529
  link.onload = null;
911
- safeWrapper(function() {
912
- var _info_needDeleteLink = info.needDeleteLink, needDeleteLink = _info_needDeleteLink === void 0 ? true : _info_needDeleteLink;
530
+ safeWrapper(()=>{
531
+ const { needDeleteLink = true } = info;
913
532
  if (needDeleteLink) {
914
- (link === null || link === void 0 ? void 0 : link.parentNode) && link.parentNode.removeChild(link);
533
+ (link == null ? void 0 : link.parentNode) && link.parentNode.removeChild(link);
915
534
  }
916
535
  });
917
536
  if (prev) {
918
537
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
919
- var res = prev(event);
538
+ const res = prev(event);
920
539
  info.cb();
921
540
  return res;
922
541
  }
@@ -926,373 +545,132 @@ function createLink(info) {
926
545
  link.onerror = onLinkComplete.bind(null, link.onerror);
927
546
  link.onload = onLinkComplete.bind(null, link.onload);
928
547
  return {
929
- link: link,
930
- needAttach: needAttach
548
+ link,
549
+ needAttach
931
550
  };
932
551
  }
933
552
  function loadScript(url, info) {
934
- var _info_attrs = info.attrs, attrs = _info_attrs === void 0 ? {} : _info_attrs, createScriptHook = info.createScriptHook;
935
- return new Promise(function(resolve, _reject) {
936
- var _createScript = createScript({
937
- url: url,
553
+ const { attrs = {}, createScriptHook } = info;
554
+ return new Promise((resolve, _reject)=>{
555
+ const { script, needAttach } = createScript({
556
+ url,
938
557
  cb: resolve,
939
- attrs: _object_spread$1({
558
+ attrs: _extends({
940
559
  crossorigin: 'anonymous',
941
560
  fetchpriority: 'high'
942
561
  }, attrs),
943
- createScriptHook: createScriptHook,
562
+ createScriptHook,
944
563
  needDeleteScript: true
945
- }), script = _createScript.script, needAttach = _createScript.needAttach;
564
+ });
946
565
  needAttach && document.head.appendChild(script);
947
566
  });
948
567
  }
949
568
 
950
- function _array_like_to_array(arr, len) {
951
- if (len == null || len > arr.length) len = arr.length;
952
- for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
953
- return arr2;
954
- }
955
- function _array_with_holes(arr) {
956
- if (Array.isArray(arr)) return arr;
957
- }
958
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
959
- try {
960
- var info = gen[key](arg);
961
- var value = info.value;
962
- } catch (error) {
963
- reject(error);
964
- return;
965
- }
966
- if (info.done) {
967
- resolve(value);
968
- } else {
969
- Promise.resolve(value).then(_next, _throw);
970
- }
971
- }
972
- function _async_to_generator(fn) {
973
- return function() {
974
- var self = this, args = arguments;
975
- return new Promise(function(resolve, reject) {
976
- var gen = fn.apply(self, args);
977
- function _next(value) {
978
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
979
- }
980
- function _throw(err) {
981
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
982
- }
983
- _next(undefined);
984
- });
985
- };
986
- }
987
- function _iterable_to_array_limit(arr, i) {
988
- var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
989
- if (_i == null) return;
990
- var _arr = [];
991
- var _n = true;
992
- var _d = false;
993
- var _s, _e;
994
- try {
995
- for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
996
- _arr.push(_s.value);
997
- if (i && _arr.length === i) break;
998
- }
999
- } catch (err) {
1000
- _d = true;
1001
- _e = err;
1002
- } finally{
1003
- try {
1004
- if (!_n && _i["return"] != null) _i["return"]();
1005
- } finally{
1006
- if (_d) throw _e;
1007
- }
1008
- }
1009
- return _arr;
1010
- }
1011
- function _non_iterable_rest() {
1012
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
1013
- }
1014
- function _sliced_to_array(arr, i) {
1015
- return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
1016
- }
1017
- function _type_of$1(obj) {
1018
- "@swc/helpers - typeof";
1019
- return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
1020
- }
1021
- function _unsupported_iterable_to_array(o, minLen) {
1022
- if (!o) return;
1023
- if (typeof o === "string") return _array_like_to_array(o, minLen);
1024
- var n = Object.prototype.toString.call(o).slice(8, -1);
1025
- if (n === "Object" && o.constructor) n = o.constructor.name;
1026
- if (n === "Map" || n === "Set") return Array.from(n);
1027
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
1028
- }
1029
- function _ts_generator(thisArg, body) {
1030
- var f, y, t, g, _ = {
1031
- label: 0,
1032
- sent: function() {
1033
- if (t[0] & 1) throw t[1];
1034
- return t[1];
1035
- },
1036
- trys: [],
1037
- ops: []
1038
- };
1039
- return g = {
1040
- next: verb(0),
1041
- "throw": verb(1),
1042
- "return": verb(2)
1043
- }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
1044
- return this;
1045
- }), g;
1046
- function verb(n) {
1047
- return function(v) {
1048
- return step([
1049
- n,
1050
- v
1051
- ]);
1052
- };
1053
- }
1054
- function step(op) {
1055
- if (f) throw new TypeError("Generator is already executing.");
1056
- while(_)try {
1057
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
1058
- if (y = 0, t) op = [
1059
- op[0] & 2,
1060
- t.value
1061
- ];
1062
- switch(op[0]){
1063
- case 0:
1064
- case 1:
1065
- t = op;
1066
- break;
1067
- case 4:
1068
- _.label++;
1069
- return {
1070
- value: op[1],
1071
- done: false
1072
- };
1073
- case 5:
1074
- _.label++;
1075
- y = op[1];
1076
- op = [
1077
- 0
1078
- ];
1079
- continue;
1080
- case 7:
1081
- op = _.ops.pop();
1082
- _.trys.pop();
1083
- continue;
1084
- default:
1085
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
1086
- _ = 0;
1087
- continue;
1088
- }
1089
- if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
1090
- _.label = op[1];
1091
- break;
1092
- }
1093
- if (op[0] === 6 && _.label < t[1]) {
1094
- _.label = t[1];
1095
- t = op;
1096
- break;
1097
- }
1098
- if (t && _.label < t[2]) {
1099
- _.label = t[2];
1100
- _.ops.push(op);
1101
- break;
1102
- }
1103
- if (t[2]) _.ops.pop();
1104
- _.trys.pop();
1105
- continue;
1106
- }
1107
- op = body.call(thisArg, _);
1108
- } catch (e) {
1109
- op = [
1110
- 6,
1111
- e
1112
- ];
1113
- y = 0;
1114
- } finally{
1115
- f = t = 0;
1116
- }
1117
- if (op[0] & 5) throw op[1];
1118
- return {
1119
- value: op[0] ? op[1] : void 0,
1120
- done: true
1121
- };
1122
- }
1123
- }
1124
569
  function importNodeModule(name) {
1125
570
  if (!name) {
1126
571
  throw new Error('import specifier is required');
1127
572
  }
1128
- var importModule = new Function('name', "return import(name)");
1129
- return importModule(name).then(function(res) {
1130
- return res.default;
1131
- }).catch(function(error) {
1132
- console.error("Error importing module ".concat(name, ":"), error);
573
+ const importModule = new Function('name', `return import(name)`);
574
+ return importModule(name).then((res)=>res.default).catch((error)=>{
575
+ console.error(`Error importing module ${name}:`, error);
1133
576
  throw error;
1134
577
  });
1135
578
  }
579
+ const loadNodeFetch = async ()=>{
580
+ const fetchModule = await importNodeModule('node-fetch');
581
+ return fetchModule.default || fetchModule;
582
+ };
583
+ const lazyLoaderHookFetch = async (input, init)=>{
584
+ // @ts-ignore
585
+ const loaderHooks = __webpack_require__.federation.instance.loaderHook;
586
+ const hook = (url, init)=>{
587
+ return loaderHooks.lifecycle.fetch.emit(url, init);
588
+ };
589
+ const res = await hook(input, init || {});
590
+ if (!res || !(res instanceof Response)) {
591
+ const fetchFunction = typeof fetch === 'undefined' ? await loadNodeFetch() : fetch;
592
+ return fetchFunction(input, init || {});
593
+ }
594
+ return res;
595
+ };
1136
596
  function createScriptNode(url, cb, attrs, createScriptHook) {
1137
597
  if (createScriptHook) {
1138
- var hookResult = createScriptHook(url);
1139
- if (hookResult && (typeof hookResult === "undefined" ? "undefined" : _type_of$1(hookResult)) === 'object' && 'url' in hookResult) {
598
+ const hookResult = createScriptHook(url);
599
+ if (hookResult && typeof hookResult === 'object' && 'url' in hookResult) {
1140
600
  url = hookResult.url;
1141
601
  }
1142
602
  }
1143
- var urlObj;
603
+ let urlObj;
1144
604
  try {
1145
605
  urlObj = new URL(url);
1146
606
  } catch (e) {
1147
607
  console.error('Error constructing URL:', e);
1148
- cb(new Error("Invalid URL: ".concat(e)));
608
+ cb(new Error(`Invalid URL: ${e}`));
1149
609
  return;
1150
610
  }
1151
- var getFetch = function() {
1152
- var _ref = _async_to_generator(function() {
1153
- var fetchModule;
1154
- return _ts_generator(this, function(_state) {
1155
- switch(_state.label){
1156
- case 0:
1157
- if (!(typeof fetch === 'undefined')) return [
1158
- 3,
1159
- 2
1160
- ];
1161
- return [
1162
- 4,
1163
- importNodeModule('node-fetch')
1164
- ];
1165
- case 1:
1166
- fetchModule = _state.sent();
1167
- //@ts-ignore
1168
- return [
1169
- 2,
1170
- (fetchModule === null || fetchModule === void 0 ? void 0 : fetchModule.default) || fetchModule
1171
- ];
1172
- case 2:
1173
- return [
1174
- 2,
1175
- fetch
1176
- ];
1177
- case 3:
1178
- return [
1179
- 2
1180
- ];
611
+ const getFetch = async ()=>{
612
+ //@ts-ignore
613
+ if (typeof __webpack_require__ !== 'undefined') {
614
+ try {
615
+ //@ts-ignore
616
+ const loaderHooks = __webpack_require__.federation.instance.loaderHook;
617
+ if (loaderHooks.lifecycle.fetch) {
618
+ return lazyLoaderHookFetch;
619
+ }
620
+ } catch (e) {
621
+ console.warn('federation.instance.loaderHook.lifecycle.fetch failed:', e);
622
+ }
623
+ }
624
+ return typeof fetch === 'undefined' ? loadNodeFetch() : fetch;
625
+ };
626
+ const handleScriptFetch = async (f, urlObj)=>{
627
+ try {
628
+ const res = await f(urlObj.href);
629
+ const data = await res.text();
630
+ const [path, vm] = await Promise.all([
631
+ importNodeModule('path'),
632
+ importNodeModule('vm')
633
+ ]);
634
+ const scriptContext = {
635
+ exports: {},
636
+ module: {
637
+ exports: {}
1181
638
  }
1182
- });
1183
- });
1184
- return function getFetch() {
1185
- return _ref.apply(this, arguments);
1186
- };
1187
- }();
1188
- console.log('fetching', urlObj.href);
1189
- getFetch().then(function(f) {
1190
- f(urlObj.href).then(function(res) {
1191
- return res.text();
1192
- }).then(function() {
1193
- var _ref = _async_to_generator(function(data) {
1194
- var _ref, path, vm, scriptContext, urlDirname, filename, script, exportedInterface, container;
1195
- return _ts_generator(this, function(_state) {
1196
- switch(_state.label){
1197
- case 0:
1198
- return [
1199
- 4,
1200
- Promise.all([
1201
- importNodeModule('path'),
1202
- importNodeModule('vm')
1203
- ])
1204
- ];
1205
- case 1:
1206
- _ref = _sliced_to_array.apply(void 0, [
1207
- _state.sent(),
1208
- 2
1209
- ]), path = _ref[0], vm = _ref[1];
1210
- scriptContext = {
1211
- exports: {},
1212
- module: {
1213
- exports: {}
1214
- }
1215
- };
1216
- urlDirname = urlObj.pathname.split('/').slice(0, -1).join('/');
1217
- filename = path.basename(urlObj.pathname);
1218
- try {
1219
- script = new vm.Script("(function(exports, module, require, __dirname, __filename) {".concat(data, "\n})"), filename);
1220
- script.runInThisContext()(scriptContext.exports, scriptContext.module, eval('require'), urlDirname, filename);
1221
- exportedInterface = scriptContext.module.exports || scriptContext.exports;
1222
- if (attrs && exportedInterface && attrs['globalName']) {
1223
- container = exportedInterface[attrs['globalName']] || exportedInterface;
1224
- cb(undefined, container);
1225
- return [
1226
- 2
1227
- ];
1228
- }
1229
- cb(undefined, exportedInterface);
1230
- } catch (e) {
1231
- // console.error('Error running script:', e);
1232
- cb(new Error("Script execution error: ".concat(e)));
1233
- }
1234
- return [
1235
- 2
1236
- ];
1237
- }
1238
- });
1239
- });
1240
- return function(data) {
1241
- return _ref.apply(this, arguments);
1242
639
  };
1243
- }()).catch(function(err) {
1244
- // console.error('Error fetching script:', err);
1245
- cb(err);
1246
- });
640
+ const urlDirname = urlObj.pathname.split('/').slice(0, -1).join('/');
641
+ const filename = path.basename(urlObj.pathname);
642
+ const script = new vm.Script(`(function(exports, module, require, __dirname, __filename) {${data}\n})`, filename);
643
+ script.runInThisContext()(scriptContext.exports, scriptContext.module, eval('require'), urlDirname, filename);
644
+ const exportedInterface = scriptContext.module.exports || scriptContext.exports;
645
+ if (attrs && exportedInterface && attrs['globalName']) {
646
+ const container = exportedInterface[attrs['globalName']] || exportedInterface;
647
+ cb(undefined, container);
648
+ return;
649
+ }
650
+ cb(undefined, exportedInterface);
651
+ } catch (e) {
652
+ cb(e instanceof Error ? e : new Error(`Script execution error: ${e}`));
653
+ }
654
+ };
655
+ getFetch().then((f)=>handleScriptFetch(f, urlObj)).catch((err)=>{
656
+ cb(err);
1247
657
  });
1248
658
  }
1249
659
  function loadScriptNode(url, info) {
1250
- return new Promise(function(resolve, reject) {
1251
- createScriptNode(url, function(error, scriptContext) {
660
+ return new Promise((resolve, reject)=>{
661
+ createScriptNode(url, (error, scriptContext)=>{
1252
662
  if (error) {
1253
663
  reject(error);
1254
664
  } else {
1255
665
  var _info_attrs, _info_attrs1;
1256
- var remoteEntryKey = (info === null || info === void 0 ? void 0 : (_info_attrs = info.attrs) === null || _info_attrs === void 0 ? void 0 : _info_attrs['globalName']) || "__FEDERATION_".concat(info === null || info === void 0 ? void 0 : (_info_attrs1 = info.attrs) === null || _info_attrs1 === void 0 ? void 0 : _info_attrs1['name'], ":custom__");
1257
- var entryExports = globalThis[remoteEntryKey] = scriptContext;
666
+ const remoteEntryKey = (info == null ? void 0 : (_info_attrs = info.attrs) == null ? void 0 : _info_attrs['globalName']) || `__FEDERATION_${info == null ? void 0 : (_info_attrs1 = info.attrs) == null ? void 0 : _info_attrs1['name']}:custom__`;
667
+ const entryExports = globalThis[remoteEntryKey] = scriptContext;
1258
668
  resolve(entryExports);
1259
669
  }
1260
670
  }, info.attrs, info.createScriptHook);
1261
671
  });
1262
672
  }
1263
673
 
1264
- function _define_property(obj, key, value) {
1265
- if (key in obj) {
1266
- Object.defineProperty(obj, key, {
1267
- value: value,
1268
- enumerable: true,
1269
- configurable: true,
1270
- writable: true
1271
- });
1272
- } else {
1273
- obj[key] = value;
1274
- }
1275
- return obj;
1276
- }
1277
- function _object_spread(target) {
1278
- for(var i = 1; i < arguments.length; i++){
1279
- var source = arguments[i] != null ? arguments[i] : {};
1280
- var ownKeys = Object.keys(source);
1281
- if (typeof Object.getOwnPropertySymbols === "function") {
1282
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
1283
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
1284
- }));
1285
- }
1286
- ownKeys.forEach(function(key) {
1287
- _define_property(target, key, source[key]);
1288
- });
1289
- }
1290
- return target;
1291
- }
1292
- function _type_of(obj) {
1293
- "@swc/helpers - typeof";
1294
- return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
1295
- }
1296
674
  function normalizeOptions(enableDefault, defaultOptions, key) {
1297
675
  return function(options) {
1298
676
  if (options === false) {
@@ -1308,10 +686,10 @@ function normalizeOptions(enableDefault, defaultOptions, key) {
1308
686
  if (options === true) {
1309
687
  return defaultOptions;
1310
688
  }
1311
- if (options && (typeof options === "undefined" ? "undefined" : _type_of(options)) === 'object') {
1312
- return _object_spread({}, defaultOptions, options);
689
+ if (options && typeof options === 'object') {
690
+ return _extends({}, defaultOptions, options);
1313
691
  }
1314
- throw new Error("Unexpected type for `".concat(key, "`, expect boolean/undefined/object, got: ").concat(typeof options === "undefined" ? "undefined" : _type_of(options)));
692
+ throw new Error(`Unexpected type for \`${key}\`, expect boolean/undefined/object, got: ${typeof options}`);
1315
693
  };
1316
694
  }
1317
695