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