@module-federation/sdk 0.0.0-next-20240626050252 → 0.0.0-next-20240701101956
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 +274 -893
- package/dist/index.esm.js +274 -894
- package/dist/normalize-webpack-path.cjs.js +9 -12
- package/dist/normalize-webpack-path.esm.js +9 -12
- package/dist/package.json +1 -1
- package/dist/src/constant.d.ts +7 -0
- package/dist/src/dom.d.ts +2 -2
- package/dist/src/normalizeOptions.d.ts +1 -1
- package/dist/src/types/plugins/ModuleFederationPlugin.d.ts +5 -6
- package/dist/src/types/snapshot.d.ts +0 -3
- package/dist/src/types/stats.d.ts +1 -2
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -2,41 +2,41 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
-
|
|
39
|
-
|
|
31
|
+
const MODULE_DEVTOOL_IDENTIFIER = '__MF_DEVTOOLS_MODULE_INFO__';
|
|
32
|
+
const ENCODE_NAME_PREFIX = 'ENCODE_NAME_PREFIX';
|
|
33
|
+
const MFPrefetchCommon = {
|
|
34
|
+
identifier: 'MFDataPrefetch',
|
|
35
|
+
globalKey: '__PREFETCH__',
|
|
36
|
+
library: 'mf-data-prefetch',
|
|
37
|
+
exportsKey: '__PREFETCH_EXPORTS__',
|
|
38
|
+
fileName: 'bootstrap.js'
|
|
39
|
+
};
|
|
40
40
|
|
|
41
41
|
var ContainerPlugin = /*#__PURE__*/Object.freeze({
|
|
42
42
|
__proto__: null
|
|
@@ -63,67 +63,10 @@ function isDebugMode() {
|
|
|
63
63
|
}
|
|
64
64
|
return typeof FEDERATION_DEBUG !== 'undefined' && Boolean(FEDERATION_DEBUG);
|
|
65
65
|
}
|
|
66
|
-
|
|
66
|
+
const getProcessEnv = function() {
|
|
67
67
|
return typeof process !== 'undefined' && process.env ? process.env : {};
|
|
68
68
|
};
|
|
69
69
|
|
|
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
70
|
function safeToString(info) {
|
|
128
71
|
try {
|
|
129
72
|
return JSON.stringify(info, null, 2);
|
|
@@ -131,7 +74,7 @@ function safeToString(info) {
|
|
|
131
74
|
return '';
|
|
132
75
|
}
|
|
133
76
|
}
|
|
134
|
-
|
|
77
|
+
const DEBUG_LOG = '[ FEDERATION DEBUG ]';
|
|
135
78
|
function safeGetLocalStorageItem() {
|
|
136
79
|
try {
|
|
137
80
|
if (typeof window !== 'undefined' && window.localStorage) {
|
|
@@ -142,11 +85,30 @@ function safeGetLocalStorageItem() {
|
|
|
142
85
|
}
|
|
143
86
|
return false;
|
|
144
87
|
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
88
|
+
let Logger = class Logger {
|
|
89
|
+
info(msg, info) {
|
|
90
|
+
if (this.enable) {
|
|
91
|
+
const argsToString = safeToString(info) || '';
|
|
92
|
+
if (isBrowserEnv()) {
|
|
93
|
+
console.info(`%c ${this.identifier}: ${msg} ${argsToString}`, 'color:#3300CC');
|
|
94
|
+
} else {
|
|
95
|
+
console.info('\x1b[34m%s', `${this.identifier}: ${msg} ${argsToString ? `\n${argsToString}` : ''}`);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
logOriginalInfo(...args) {
|
|
100
|
+
if (this.enable) {
|
|
101
|
+
if (isBrowserEnv()) {
|
|
102
|
+
console.info(`%c ${this.identifier}: OriginalInfo`, 'color:#3300CC');
|
|
103
|
+
console.log(...args);
|
|
104
|
+
} else {
|
|
105
|
+
console.info(`%c ${this.identifier}: OriginalInfo`, 'color:#3300CC');
|
|
106
|
+
console.log(...args);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
constructor(identifier){
|
|
111
|
+
this.enable = false;
|
|
150
112
|
this.identifier = identifier || DEBUG_LOG;
|
|
151
113
|
if (isBrowserEnv() && safeGetLocalStorageItem()) {
|
|
152
114
|
this.enable = true;
|
|
@@ -154,182 +116,88 @@ var Logger = /*#__PURE__*/ function() {
|
|
|
154
116
|
this.enable = true;
|
|
155
117
|
}
|
|
156
118
|
}
|
|
157
|
-
|
|
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
|
-
}();
|
|
119
|
+
};
|
|
193
120
|
|
|
194
|
-
|
|
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 ]';
|
|
121
|
+
const LOG_CATEGORY = '[ Federation Runtime ]';
|
|
247
122
|
// entry: name:version version : 1.0.0 | ^1.2.3
|
|
248
123
|
// entry: name:entry entry: https://localhost:9000/federation-manifest.json
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
var isEntry = function(s) {
|
|
255
|
-
return s.startsWith('http') || s.includes(MANIFEST_EXT);
|
|
256
|
-
};
|
|
124
|
+
const parseEntry = (str, devVerOrUrl, separator = SEPARATOR)=>{
|
|
125
|
+
const strSplit = str.split(separator);
|
|
126
|
+
const devVersionOrUrl = getProcessEnv()['NODE_ENV'] === 'development' && devVerOrUrl;
|
|
127
|
+
const defaultVersion = '*';
|
|
128
|
+
const isEntry = (s)=>s.startsWith('http') || s.includes(MANIFEST_EXT);
|
|
257
129
|
// Check if the string starts with a type
|
|
258
130
|
if (strSplit.length >= 2) {
|
|
259
|
-
|
|
131
|
+
let [name, ...versionOrEntryArr] = strSplit;
|
|
260
132
|
if (str.startsWith(separator)) {
|
|
261
133
|
versionOrEntryArr = [
|
|
262
134
|
devVersionOrUrl || strSplit.slice(-1)[0]
|
|
263
135
|
];
|
|
264
136
|
name = strSplit.slice(0, -1).join(separator);
|
|
265
137
|
}
|
|
266
|
-
|
|
138
|
+
let versionOrEntry = devVersionOrUrl || versionOrEntryArr.join(separator);
|
|
267
139
|
if (isEntry(versionOrEntry)) {
|
|
268
140
|
return {
|
|
269
|
-
name
|
|
141
|
+
name,
|
|
270
142
|
entry: versionOrEntry
|
|
271
143
|
};
|
|
272
144
|
} else {
|
|
273
145
|
// Apply version rule
|
|
274
146
|
// devVersionOrUrl => inputVersion => defaultVersion
|
|
275
147
|
return {
|
|
276
|
-
name
|
|
148
|
+
name,
|
|
277
149
|
version: versionOrEntry || defaultVersion
|
|
278
150
|
};
|
|
279
151
|
}
|
|
280
152
|
} else if (strSplit.length === 1) {
|
|
281
|
-
|
|
153
|
+
const [name] = strSplit;
|
|
282
154
|
if (devVersionOrUrl && isEntry(devVersionOrUrl)) {
|
|
283
155
|
return {
|
|
284
|
-
name
|
|
156
|
+
name,
|
|
285
157
|
entry: devVersionOrUrl
|
|
286
158
|
};
|
|
287
159
|
}
|
|
288
160
|
return {
|
|
289
|
-
name
|
|
161
|
+
name,
|
|
290
162
|
version: devVersionOrUrl || defaultVersion
|
|
291
163
|
};
|
|
292
164
|
} else {
|
|
293
|
-
throw
|
|
165
|
+
throw `Invalid entry value: ${str}`;
|
|
294
166
|
}
|
|
295
167
|
};
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
299
|
-
args[_key] = arguments[_key];
|
|
300
|
-
}
|
|
168
|
+
const logger = new Logger();
|
|
169
|
+
const composeKeyWithSeparator = function(...args) {
|
|
301
170
|
if (!args.length) {
|
|
302
171
|
return '';
|
|
303
172
|
}
|
|
304
|
-
return args.reduce(
|
|
173
|
+
return args.reduce((sum, cur)=>{
|
|
305
174
|
if (!cur) {
|
|
306
175
|
return sum;
|
|
307
176
|
}
|
|
308
177
|
if (!sum) {
|
|
309
178
|
return cur;
|
|
310
179
|
}
|
|
311
|
-
return
|
|
180
|
+
return `${sum}${SEPARATOR}${cur}`;
|
|
312
181
|
}, '');
|
|
313
182
|
};
|
|
314
|
-
|
|
315
|
-
var prefix = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : '', withExt = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false;
|
|
183
|
+
const encodeName = function(name, prefix = '', withExt = false) {
|
|
316
184
|
try {
|
|
317
|
-
|
|
318
|
-
return
|
|
185
|
+
const ext = withExt ? '.js' : '';
|
|
186
|
+
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
187
|
} catch (err) {
|
|
320
188
|
throw err;
|
|
321
189
|
}
|
|
322
190
|
};
|
|
323
|
-
|
|
191
|
+
const decodeName = function(name, prefix, withExt) {
|
|
324
192
|
try {
|
|
325
|
-
|
|
193
|
+
let decodedName = name;
|
|
326
194
|
if (prefix) {
|
|
327
195
|
if (!decodedName.startsWith(prefix)) {
|
|
328
196
|
return decodedName;
|
|
329
197
|
}
|
|
330
198
|
decodedName = decodedName.replace(new RegExp(prefix, 'g'), '');
|
|
331
199
|
}
|
|
332
|
-
decodedName = decodedName.replace(new RegExp(
|
|
200
|
+
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
201
|
if (withExt) {
|
|
334
202
|
decodedName = decodedName.replace('.js', '');
|
|
335
203
|
}
|
|
@@ -338,11 +206,11 @@ var decodeName = function decodeName(name, prefix, withExt) {
|
|
|
338
206
|
throw err;
|
|
339
207
|
}
|
|
340
208
|
};
|
|
341
|
-
|
|
209
|
+
const generateExposeFilename = (exposeName, withExt)=>{
|
|
342
210
|
if (!exposeName) {
|
|
343
211
|
return '';
|
|
344
212
|
}
|
|
345
|
-
|
|
213
|
+
let expose = exposeName;
|
|
346
214
|
if (expose === '.') {
|
|
347
215
|
expose = 'default_export';
|
|
348
216
|
}
|
|
@@ -351,98 +219,57 @@ var generateExposeFilename = function(exposeName, withExt) {
|
|
|
351
219
|
}
|
|
352
220
|
return encodeName(expose, '__federation_expose_', withExt);
|
|
353
221
|
};
|
|
354
|
-
|
|
222
|
+
const generateShareFilename = (pkgName, withExt)=>{
|
|
355
223
|
if (!pkgName) {
|
|
356
224
|
return '';
|
|
357
225
|
}
|
|
358
226
|
return encodeName(pkgName, '__federation_shared_', withExt);
|
|
359
227
|
};
|
|
360
|
-
|
|
228
|
+
const getResourceUrl = (module, sourceUrl)=>{
|
|
361
229
|
if ('getPublicPath' in module) {
|
|
362
|
-
|
|
230
|
+
let publicPath;
|
|
363
231
|
if (!module.getPublicPath.startsWith('function')) {
|
|
364
232
|
publicPath = new Function(module.getPublicPath)();
|
|
365
233
|
} else {
|
|
366
234
|
publicPath = new Function('return ' + module.getPublicPath)()();
|
|
367
235
|
}
|
|
368
|
-
return
|
|
236
|
+
return `${publicPath}${sourceUrl}`;
|
|
369
237
|
} else if ('publicPath' in module) {
|
|
370
|
-
return
|
|
238
|
+
return `${module.publicPath}${sourceUrl}`;
|
|
371
239
|
} else {
|
|
372
240
|
console.warn('Cannot get resource URL. If in debug mode, please ignore.', module, sourceUrl);
|
|
373
241
|
return '';
|
|
374
242
|
}
|
|
375
243
|
};
|
|
376
244
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
377
|
-
|
|
245
|
+
const assert = (condition, msg)=>{
|
|
378
246
|
if (!condition) {
|
|
379
247
|
error(msg);
|
|
380
248
|
}
|
|
381
249
|
};
|
|
382
|
-
|
|
383
|
-
throw new Error(
|
|
250
|
+
const error = (msg)=>{
|
|
251
|
+
throw new Error(`${LOG_CATEGORY}: ${msg}`);
|
|
384
252
|
};
|
|
385
|
-
|
|
386
|
-
console.warn(
|
|
253
|
+
const warn = (msg)=>{
|
|
254
|
+
console.warn(`${LOG_CATEGORY}: ${msg}`);
|
|
387
255
|
};
|
|
388
256
|
|
|
389
|
-
function
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
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
|
-
}));
|
|
257
|
+
function _extends() {
|
|
258
|
+
_extends = Object.assign || function assign(target) {
|
|
259
|
+
for(var i = 1; i < arguments.length; i++){
|
|
260
|
+
var source = arguments[i];
|
|
261
|
+
for(var key in source)if (Object.prototype.hasOwnProperty.call(source, key)) target[key] = source[key];
|
|
410
262
|
}
|
|
411
|
-
|
|
412
|
-
|
|
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
|
-
});
|
|
425
|
-
}
|
|
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;
|
|
263
|
+
return target;
|
|
264
|
+
};
|
|
265
|
+
return _extends.apply(this, arguments);
|
|
440
266
|
}
|
|
441
|
-
|
|
267
|
+
|
|
268
|
+
const simpleJoinRemoteEntry = (rPath, rName)=>{
|
|
442
269
|
if (!rPath) {
|
|
443
270
|
return rName;
|
|
444
271
|
}
|
|
445
|
-
|
|
272
|
+
const transformPath = (str)=>{
|
|
446
273
|
if (str === '.') {
|
|
447
274
|
return '';
|
|
448
275
|
}
|
|
@@ -450,7 +277,7 @@ var simpleJoinRemoteEntry = function(rPath, rName) {
|
|
|
450
277
|
return str.replace('./', '');
|
|
451
278
|
}
|
|
452
279
|
if (str.startsWith('/')) {
|
|
453
|
-
|
|
280
|
+
const strWithoutSlash = str.slice(1);
|
|
454
281
|
if (strWithoutSlash.endsWith('/')) {
|
|
455
282
|
return strWithoutSlash.slice(0, -1);
|
|
456
283
|
}
|
|
@@ -458,26 +285,25 @@ var simpleJoinRemoteEntry = function(rPath, rName) {
|
|
|
458
285
|
}
|
|
459
286
|
return str;
|
|
460
287
|
};
|
|
461
|
-
|
|
288
|
+
const transformedPath = transformPath(rPath);
|
|
462
289
|
if (!transformedPath) {
|
|
463
290
|
return rName;
|
|
464
291
|
}
|
|
465
292
|
if (transformedPath.endsWith('/')) {
|
|
466
|
-
return
|
|
293
|
+
return `${transformedPath}${rName}`;
|
|
467
294
|
}
|
|
468
|
-
return
|
|
295
|
+
return `${transformedPath}/${rName}`;
|
|
469
296
|
};
|
|
470
297
|
function inferAutoPublicPath(url) {
|
|
471
298
|
return url.replace(/#.*$/, '').replace(/\?.*$/, '').replace(/\/[^\/]+$/, '/');
|
|
472
299
|
}
|
|
473
300
|
// Priority: overrides > remotes
|
|
474
301
|
// eslint-disable-next-line max-lines-per-function
|
|
475
|
-
function generateSnapshotFromManifest(manifest) {
|
|
476
|
-
var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
302
|
+
function generateSnapshotFromManifest(manifest, options = {}) {
|
|
477
303
|
var _manifest_metaData, _manifest_metaData1;
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
304
|
+
const { remotes = {}, overrides = {}, version } = options;
|
|
305
|
+
let remoteSnapshot;
|
|
306
|
+
const getPublicPath = ()=>{
|
|
481
307
|
if ('publicPath' in manifest.metaData) {
|
|
482
308
|
if (manifest.metaData.publicPath === 'auto' && version) {
|
|
483
309
|
// use same implementation as publicPath auto runtime module implements
|
|
@@ -488,14 +314,14 @@ function generateSnapshotFromManifest(manifest) {
|
|
|
488
314
|
return manifest.metaData.getPublicPath;
|
|
489
315
|
}
|
|
490
316
|
};
|
|
491
|
-
|
|
492
|
-
|
|
317
|
+
const overridesKeys = Object.keys(overrides);
|
|
318
|
+
let remotesInfo = {};
|
|
493
319
|
// If remotes are not provided, only the remotes in the manifest will be read
|
|
494
320
|
if (!Object.keys(remotes).length) {
|
|
495
321
|
var _manifest_remotes;
|
|
496
|
-
remotesInfo = ((_manifest_remotes = manifest.remotes)
|
|
497
|
-
|
|
498
|
-
|
|
322
|
+
remotesInfo = ((_manifest_remotes = manifest.remotes) == null ? void 0 : _manifest_remotes.reduce((res, next)=>{
|
|
323
|
+
let matchedVersion;
|
|
324
|
+
const name = next.federationContainerName;
|
|
499
325
|
// overrides have higher priority
|
|
500
326
|
if (overridesKeys.includes(name)) {
|
|
501
327
|
matchedVersion = overrides[name];
|
|
@@ -507,72 +333,61 @@ function generateSnapshotFromManifest(manifest) {
|
|
|
507
333
|
}
|
|
508
334
|
}
|
|
509
335
|
res[name] = {
|
|
510
|
-
matchedVersion
|
|
336
|
+
matchedVersion
|
|
511
337
|
};
|
|
512
338
|
return res;
|
|
513
339
|
}, {})) || {};
|
|
514
340
|
}
|
|
515
341
|
// If remotes (deploy scenario) are specified, they need to be traversed again
|
|
516
|
-
Object.keys(remotes).forEach(
|
|
517
|
-
return remotesInfo[key] = {
|
|
342
|
+
Object.keys(remotes).forEach((key)=>remotesInfo[key] = {
|
|
518
343
|
// overrides will override dependencies
|
|
519
344
|
matchedVersion: overridesKeys.includes(key) ? overrides[key] : remotes[key]
|
|
520
|
-
};
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
var basicRemoteSnapshot = {
|
|
345
|
+
});
|
|
346
|
+
const { remoteEntry: { path: remoteEntryPath, name: remoteEntryName, type: remoteEntryType }, types: remoteTypes, buildInfo: { buildVersion }, globalName } = manifest.metaData;
|
|
347
|
+
const { exposes } = manifest;
|
|
348
|
+
let basicRemoteSnapshot = {
|
|
525
349
|
version: version ? version : '',
|
|
526
|
-
buildVersion
|
|
527
|
-
globalName
|
|
350
|
+
buildVersion,
|
|
351
|
+
globalName,
|
|
528
352
|
remoteEntry: simpleJoinRemoteEntry(remoteEntryPath, remoteEntryName),
|
|
529
|
-
remoteEntryType
|
|
353
|
+
remoteEntryType,
|
|
530
354
|
remoteTypes: simpleJoinRemoteEntry(remoteTypes.path, remoteTypes.name),
|
|
531
355
|
remoteTypesZip: remoteTypes.zip || '',
|
|
532
356
|
remoteTypesAPI: remoteTypes.api || '',
|
|
533
|
-
remotesInfo
|
|
534
|
-
shared: manifest
|
|
535
|
-
return {
|
|
357
|
+
remotesInfo,
|
|
358
|
+
shared: manifest == null ? void 0 : manifest.shared.map((item)=>({
|
|
536
359
|
assets: item.assets,
|
|
537
360
|
sharedName: item.name,
|
|
538
361
|
version: item.version
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
modules: exposes === null || exposes === void 0 ? void 0 : exposes.map(function(expose) {
|
|
542
|
-
return {
|
|
362
|
+
})),
|
|
363
|
+
modules: exposes == null ? void 0 : exposes.map((expose)=>({
|
|
543
364
|
moduleName: expose.name,
|
|
544
365
|
modulePath: expose.path,
|
|
545
366
|
assets: expose.assets
|
|
546
|
-
}
|
|
547
|
-
})
|
|
367
|
+
}))
|
|
548
368
|
};
|
|
549
|
-
if ((_manifest_metaData = manifest.metaData)
|
|
550
|
-
|
|
551
|
-
basicRemoteSnapshot =
|
|
552
|
-
prefetchInterface
|
|
369
|
+
if ((_manifest_metaData = manifest.metaData) == null ? void 0 : _manifest_metaData.prefetchInterface) {
|
|
370
|
+
const prefetchInterface = manifest.metaData.prefetchInterface;
|
|
371
|
+
basicRemoteSnapshot = _extends({}, basicRemoteSnapshot, {
|
|
372
|
+
prefetchInterface
|
|
553
373
|
});
|
|
554
374
|
}
|
|
555
|
-
if ((_manifest_metaData1 = manifest.metaData)
|
|
556
|
-
|
|
557
|
-
basicRemoteSnapshot =
|
|
375
|
+
if ((_manifest_metaData1 = manifest.metaData) == null ? void 0 : _manifest_metaData1.prefetchEntry) {
|
|
376
|
+
const { path, name, type } = manifest.metaData.prefetchEntry;
|
|
377
|
+
basicRemoteSnapshot = _extends({}, basicRemoteSnapshot, {
|
|
558
378
|
prefetchEntry: simpleJoinRemoteEntry(path, name),
|
|
559
379
|
prefetchEntryType: type
|
|
560
380
|
});
|
|
561
381
|
}
|
|
562
382
|
if ('publicPath' in manifest.metaData) {
|
|
563
|
-
remoteSnapshot =
|
|
383
|
+
remoteSnapshot = _extends({}, basicRemoteSnapshot, {
|
|
564
384
|
publicPath: getPublicPath()
|
|
565
385
|
});
|
|
566
386
|
} else {
|
|
567
|
-
remoteSnapshot =
|
|
387
|
+
remoteSnapshot = _extends({}, basicRemoteSnapshot, {
|
|
568
388
|
getPublicPath: getPublicPath()
|
|
569
389
|
});
|
|
570
390
|
}
|
|
571
|
-
if (ssrRemoteEntry) {
|
|
572
|
-
var fullSSRRemoteEntry = simpleJoinRemoteEntry(ssrRemoteEntry.path, ssrRemoteEntry.name);
|
|
573
|
-
remoteSnapshot.ssrRemoteEntry = fullSSRRemoteEntry;
|
|
574
|
-
remoteSnapshot.ssrRemoteEntryType = 'commonjs-module';
|
|
575
|
-
}
|
|
576
391
|
return remoteSnapshot;
|
|
577
392
|
}
|
|
578
393
|
function isManifestProvider(moduleInfo) {
|
|
@@ -583,228 +398,34 @@ function isManifestProvider(moduleInfo) {
|
|
|
583
398
|
}
|
|
584
399
|
}
|
|
585
400
|
|
|
586
|
-
|
|
401
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
402
|
+
async function safeWrapper(callback, disableWarn) {
|
|
587
403
|
try {
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
} catch (
|
|
591
|
-
|
|
404
|
+
const res = await callback();
|
|
405
|
+
return res;
|
|
406
|
+
} catch (e) {
|
|
407
|
+
!disableWarn && warn(e);
|
|
592
408
|
return;
|
|
593
409
|
}
|
|
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
410
|
}
|
|
790
411
|
function isStaticResourcesEqual(url1, url2) {
|
|
791
|
-
|
|
412
|
+
const REG_EXP = /^(https?:)?\/\//i;
|
|
792
413
|
// Transform url1 and url2 into relative paths
|
|
793
|
-
|
|
794
|
-
|
|
414
|
+
const relativeUrl1 = url1.replace(REG_EXP, '').replace(/\/$/, '');
|
|
415
|
+
const relativeUrl2 = url2.replace(REG_EXP, '').replace(/\/$/, '');
|
|
795
416
|
// Check if the relative paths are identical
|
|
796
417
|
return relativeUrl1 === relativeUrl2;
|
|
797
418
|
}
|
|
798
419
|
function createScript(info) {
|
|
799
420
|
// Retrieve the existing script element by its src attribute
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
for(
|
|
806
|
-
|
|
807
|
-
|
|
421
|
+
let script = null;
|
|
422
|
+
let needAttach = true;
|
|
423
|
+
let timeout = 20000;
|
|
424
|
+
let timeoutId;
|
|
425
|
+
const scripts = document.getElementsByTagName('script');
|
|
426
|
+
for(let i = 0; i < scripts.length; i++){
|
|
427
|
+
const s = scripts[i];
|
|
428
|
+
const scriptSrc = s.getAttribute('src');
|
|
808
429
|
if (scriptSrc && isStaticResourcesEqual(scriptSrc, info.url)) {
|
|
809
430
|
script = s;
|
|
810
431
|
needAttach = false;
|
|
@@ -816,17 +437,17 @@ function createScript(info) {
|
|
|
816
437
|
script.type = 'text/javascript';
|
|
817
438
|
script.src = info.url;
|
|
818
439
|
if (info.createScriptHook) {
|
|
819
|
-
|
|
820
|
-
if (
|
|
440
|
+
const createScriptRes = info.createScriptHook(info.url, info.attrs);
|
|
441
|
+
if (createScriptRes instanceof HTMLScriptElement) {
|
|
821
442
|
script = createScriptRes;
|
|
822
|
-
} else if (
|
|
443
|
+
} else if (typeof createScriptRes === 'object') {
|
|
823
444
|
if (createScriptRes.script) script = createScriptRes.script;
|
|
824
445
|
if (createScriptRes.timeout) timeout = createScriptRes.timeout;
|
|
825
446
|
}
|
|
826
447
|
}
|
|
827
|
-
|
|
448
|
+
const attrs = info.attrs;
|
|
828
449
|
if (attrs) {
|
|
829
|
-
Object.keys(attrs).forEach(
|
|
450
|
+
Object.keys(attrs).forEach((name)=>{
|
|
830
451
|
if (script) {
|
|
831
452
|
if (name === 'async' || name === 'defer') {
|
|
832
453
|
script[name] = attrs[name];
|
|
@@ -838,50 +459,50 @@ function createScript(info) {
|
|
|
838
459
|
});
|
|
839
460
|
}
|
|
840
461
|
}
|
|
841
|
-
|
|
842
|
-
event)
|
|
462
|
+
const onScriptComplete = (prev, // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
463
|
+
event)=>{
|
|
843
464
|
var _info_cb;
|
|
844
465
|
clearTimeout(timeoutId);
|
|
845
466
|
// Prevent memory leaks in IE.
|
|
846
467
|
if (script) {
|
|
847
468
|
script.onerror = null;
|
|
848
469
|
script.onload = null;
|
|
849
|
-
safeWrapper(
|
|
850
|
-
|
|
470
|
+
safeWrapper(()=>{
|
|
471
|
+
const { needDeleteScript = true } = info;
|
|
851
472
|
if (needDeleteScript) {
|
|
852
|
-
(script
|
|
473
|
+
(script == null ? void 0 : script.parentNode) && script.parentNode.removeChild(script);
|
|
853
474
|
}
|
|
854
475
|
});
|
|
855
476
|
if (prev) {
|
|
856
477
|
var _info_cb1;
|
|
857
478
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
858
|
-
|
|
859
|
-
info
|
|
479
|
+
const res = prev(event);
|
|
480
|
+
info == null ? void 0 : (_info_cb1 = info.cb) == null ? void 0 : _info_cb1.call(info);
|
|
860
481
|
return res;
|
|
861
482
|
}
|
|
862
483
|
}
|
|
863
|
-
info
|
|
484
|
+
info == null ? void 0 : (_info_cb = info.cb) == null ? void 0 : _info_cb.call(info);
|
|
864
485
|
};
|
|
865
486
|
script.onerror = onScriptComplete.bind(null, script.onerror);
|
|
866
487
|
script.onload = onScriptComplete.bind(null, script.onload);
|
|
867
|
-
timeoutId = setTimeout(
|
|
868
|
-
onScriptComplete(null, new Error(
|
|
488
|
+
timeoutId = setTimeout(()=>{
|
|
489
|
+
onScriptComplete(null, new Error(`Remote script "${info.url}" time-outed.`));
|
|
869
490
|
}, timeout);
|
|
870
491
|
return {
|
|
871
|
-
script
|
|
872
|
-
needAttach
|
|
492
|
+
script,
|
|
493
|
+
needAttach
|
|
873
494
|
};
|
|
874
495
|
}
|
|
875
496
|
function createLink(info) {
|
|
876
497
|
// <link rel="preload" href="script.js" as="script">
|
|
877
498
|
// Retrieve the existing script element by its src attribute
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
for(
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
499
|
+
let link = null;
|
|
500
|
+
let needAttach = true;
|
|
501
|
+
const links = document.getElementsByTagName('link');
|
|
502
|
+
for(let i = 0; i < links.length; i++){
|
|
503
|
+
const l = links[i];
|
|
504
|
+
const linkHref = l.getAttribute('href');
|
|
505
|
+
const linkRef = l.getAttribute('ref');
|
|
885
506
|
if (linkHref && isStaticResourcesEqual(linkHref, info.url) && linkRef === info.attrs['ref']) {
|
|
886
507
|
link = l;
|
|
887
508
|
needAttach = false;
|
|
@@ -892,35 +513,35 @@ function createLink(info) {
|
|
|
892
513
|
link = document.createElement('link');
|
|
893
514
|
link.setAttribute('href', info.url);
|
|
894
515
|
if (info.createLinkHook) {
|
|
895
|
-
|
|
896
|
-
if (
|
|
516
|
+
const createLinkRes = info.createLinkHook(info.url);
|
|
517
|
+
if (createLinkRes instanceof HTMLLinkElement) {
|
|
897
518
|
link = createLinkRes;
|
|
898
519
|
}
|
|
899
520
|
}
|
|
900
|
-
|
|
521
|
+
const attrs = info.attrs;
|
|
901
522
|
if (attrs) {
|
|
902
|
-
Object.keys(attrs).forEach(
|
|
523
|
+
Object.keys(attrs).forEach((name)=>{
|
|
903
524
|
if (link && !link.getAttribute(name)) {
|
|
904
525
|
link.setAttribute(name, attrs[name]);
|
|
905
526
|
}
|
|
906
527
|
});
|
|
907
528
|
}
|
|
908
529
|
}
|
|
909
|
-
|
|
910
|
-
event)
|
|
530
|
+
const onLinkComplete = (prev, // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
531
|
+
event)=>{
|
|
911
532
|
// Prevent memory leaks in IE.
|
|
912
533
|
if (link) {
|
|
913
534
|
link.onerror = null;
|
|
914
535
|
link.onload = null;
|
|
915
|
-
safeWrapper(
|
|
916
|
-
|
|
536
|
+
safeWrapper(()=>{
|
|
537
|
+
const { needDeleteLink = true } = info;
|
|
917
538
|
if (needDeleteLink) {
|
|
918
|
-
(link
|
|
539
|
+
(link == null ? void 0 : link.parentNode) && link.parentNode.removeChild(link);
|
|
919
540
|
}
|
|
920
541
|
});
|
|
921
542
|
if (prev) {
|
|
922
543
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
923
|
-
|
|
544
|
+
const res = prev(event);
|
|
924
545
|
info.cb();
|
|
925
546
|
return res;
|
|
926
547
|
}
|
|
@@ -930,373 +551,132 @@ function createLink(info) {
|
|
|
930
551
|
link.onerror = onLinkComplete.bind(null, link.onerror);
|
|
931
552
|
link.onload = onLinkComplete.bind(null, link.onload);
|
|
932
553
|
return {
|
|
933
|
-
link
|
|
934
|
-
needAttach
|
|
554
|
+
link,
|
|
555
|
+
needAttach
|
|
935
556
|
};
|
|
936
557
|
}
|
|
937
558
|
function loadScript(url, info) {
|
|
938
|
-
|
|
939
|
-
return new Promise(
|
|
940
|
-
|
|
941
|
-
url
|
|
559
|
+
const { attrs = {}, createScriptHook } = info;
|
|
560
|
+
return new Promise((resolve, _reject)=>{
|
|
561
|
+
const { script, needAttach } = createScript({
|
|
562
|
+
url,
|
|
942
563
|
cb: resolve,
|
|
943
|
-
attrs:
|
|
564
|
+
attrs: _extends({
|
|
944
565
|
crossorigin: 'anonymous',
|
|
945
566
|
fetchpriority: 'high'
|
|
946
567
|
}, attrs),
|
|
947
|
-
createScriptHook
|
|
568
|
+
createScriptHook,
|
|
948
569
|
needDeleteScript: true
|
|
949
|
-
})
|
|
570
|
+
});
|
|
950
571
|
needAttach && document.head.appendChild(script);
|
|
951
572
|
});
|
|
952
573
|
}
|
|
953
574
|
|
|
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
575
|
function importNodeModule(name) {
|
|
1129
576
|
if (!name) {
|
|
1130
577
|
throw new Error('import specifier is required');
|
|
1131
578
|
}
|
|
1132
|
-
|
|
1133
|
-
return importModule(name).then(
|
|
1134
|
-
|
|
1135
|
-
}).catch(function(error) {
|
|
1136
|
-
console.error("Error importing module ".concat(name, ":"), error);
|
|
579
|
+
const importModule = new Function('name', `return import(name)`);
|
|
580
|
+
return importModule(name).then((res)=>res.default).catch((error)=>{
|
|
581
|
+
console.error(`Error importing module ${name}:`, error);
|
|
1137
582
|
throw error;
|
|
1138
583
|
});
|
|
1139
584
|
}
|
|
585
|
+
const loadNodeFetch = async ()=>{
|
|
586
|
+
const fetchModule = await importNodeModule('node-fetch');
|
|
587
|
+
return fetchModule.default || fetchModule;
|
|
588
|
+
};
|
|
589
|
+
const lazyLoaderHookFetch = async (input, init)=>{
|
|
590
|
+
// @ts-ignore
|
|
591
|
+
const loaderHooks = __webpack_require__.federation.instance.loaderHook;
|
|
592
|
+
const hook = (url, init)=>{
|
|
593
|
+
return loaderHooks.lifecycle.fetch.emit(url, init);
|
|
594
|
+
};
|
|
595
|
+
const res = await hook(input, init || {});
|
|
596
|
+
if (!res || !(res instanceof Response)) {
|
|
597
|
+
const fetchFunction = typeof fetch === 'undefined' ? await loadNodeFetch() : fetch;
|
|
598
|
+
return fetchFunction(input, init || {});
|
|
599
|
+
}
|
|
600
|
+
return res;
|
|
601
|
+
};
|
|
1140
602
|
function createScriptNode(url, cb, attrs, createScriptHook) {
|
|
1141
603
|
if (createScriptHook) {
|
|
1142
|
-
|
|
1143
|
-
if (hookResult &&
|
|
604
|
+
const hookResult = createScriptHook(url);
|
|
605
|
+
if (hookResult && typeof hookResult === 'object' && 'url' in hookResult) {
|
|
1144
606
|
url = hookResult.url;
|
|
1145
607
|
}
|
|
1146
608
|
}
|
|
1147
|
-
|
|
609
|
+
let urlObj;
|
|
1148
610
|
try {
|
|
1149
611
|
urlObj = new URL(url);
|
|
1150
612
|
} catch (e) {
|
|
1151
613
|
console.error('Error constructing URL:', e);
|
|
1152
|
-
cb(new Error(
|
|
614
|
+
cb(new Error(`Invalid URL: ${e}`));
|
|
1153
615
|
return;
|
|
1154
616
|
}
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
return [
|
|
1183
|
-
2
|
|
1184
|
-
];
|
|
617
|
+
const getFetch = async ()=>{
|
|
618
|
+
//@ts-ignore
|
|
619
|
+
if (typeof __webpack_require__ !== 'undefined') {
|
|
620
|
+
try {
|
|
621
|
+
//@ts-ignore
|
|
622
|
+
const loaderHooks = __webpack_require__.federation.instance.loaderHook;
|
|
623
|
+
if (loaderHooks.lifecycle.fetch) {
|
|
624
|
+
return lazyLoaderHookFetch;
|
|
625
|
+
}
|
|
626
|
+
} catch (e) {
|
|
627
|
+
console.warn('federation.instance.loaderHook.lifecycle.fetch failed:', e);
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
return typeof fetch === 'undefined' ? loadNodeFetch() : fetch;
|
|
631
|
+
};
|
|
632
|
+
const handleScriptFetch = async (f, urlObj)=>{
|
|
633
|
+
try {
|
|
634
|
+
const res = await f(urlObj.href);
|
|
635
|
+
const data = await res.text();
|
|
636
|
+
const [path, vm] = await Promise.all([
|
|
637
|
+
importNodeModule('path'),
|
|
638
|
+
importNodeModule('vm')
|
|
639
|
+
]);
|
|
640
|
+
const scriptContext = {
|
|
641
|
+
exports: {},
|
|
642
|
+
module: {
|
|
643
|
+
exports: {}
|
|
1185
644
|
}
|
|
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
645
|
};
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
646
|
+
const urlDirname = urlObj.pathname.split('/').slice(0, -1).join('/');
|
|
647
|
+
const filename = path.basename(urlObj.pathname);
|
|
648
|
+
const script = new vm.Script(`(function(exports, module, require, __dirname, __filename) {${data}\n})`, filename);
|
|
649
|
+
script.runInThisContext()(scriptContext.exports, scriptContext.module, eval('require'), urlDirname, filename);
|
|
650
|
+
const exportedInterface = scriptContext.module.exports || scriptContext.exports;
|
|
651
|
+
if (attrs && exportedInterface && attrs['globalName']) {
|
|
652
|
+
const container = exportedInterface[attrs['globalName']] || exportedInterface;
|
|
653
|
+
cb(undefined, container);
|
|
654
|
+
return;
|
|
655
|
+
}
|
|
656
|
+
cb(undefined, exportedInterface);
|
|
657
|
+
} catch (e) {
|
|
658
|
+
cb(new Error(`Script execution error: ${e}`));
|
|
659
|
+
}
|
|
660
|
+
};
|
|
661
|
+
getFetch().then((f)=>handleScriptFetch(f, urlObj)).catch((err)=>{
|
|
662
|
+
cb(err);
|
|
1251
663
|
});
|
|
1252
664
|
}
|
|
1253
665
|
function loadScriptNode(url, info) {
|
|
1254
|
-
return new Promise(
|
|
1255
|
-
createScriptNode(url,
|
|
666
|
+
return new Promise((resolve, reject)=>{
|
|
667
|
+
createScriptNode(url, (error, scriptContext)=>{
|
|
1256
668
|
if (error) {
|
|
1257
669
|
reject(error);
|
|
1258
670
|
} else {
|
|
1259
671
|
var _info_attrs, _info_attrs1;
|
|
1260
|
-
|
|
1261
|
-
|
|
672
|
+
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__`;
|
|
673
|
+
const entryExports = globalThis[remoteEntryKey] = scriptContext;
|
|
1262
674
|
resolve(entryExports);
|
|
1263
675
|
}
|
|
1264
676
|
}, info.attrs, info.createScriptHook);
|
|
1265
677
|
});
|
|
1266
678
|
}
|
|
1267
679
|
|
|
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
680
|
function normalizeOptions(enableDefault, defaultOptions, key) {
|
|
1301
681
|
return function(options) {
|
|
1302
682
|
if (options === false) {
|
|
@@ -1312,10 +692,10 @@ function normalizeOptions(enableDefault, defaultOptions, key) {
|
|
|
1312
692
|
if (options === true) {
|
|
1313
693
|
return defaultOptions;
|
|
1314
694
|
}
|
|
1315
|
-
if (options &&
|
|
1316
|
-
return
|
|
695
|
+
if (options && typeof options === 'object') {
|
|
696
|
+
return _extends({}, defaultOptions, options);
|
|
1317
697
|
}
|
|
1318
|
-
throw new Error(
|
|
698
|
+
throw new Error(`Unexpected type for \`${key}\`, expect boolean/undefined/object, got: ${typeof options}`);
|
|
1319
699
|
};
|
|
1320
700
|
}
|
|
1321
701
|
|
|
@@ -1327,6 +707,7 @@ exports.FederationModuleManifest = FederationModuleManifest;
|
|
|
1327
707
|
exports.Logger = Logger;
|
|
1328
708
|
exports.MANIFEST_EXT = MANIFEST_EXT;
|
|
1329
709
|
exports.MFModuleType = MFModuleType;
|
|
710
|
+
exports.MFPrefetchCommon = MFPrefetchCommon;
|
|
1330
711
|
exports.MODULE_DEVTOOL_IDENTIFIER = MODULE_DEVTOOL_IDENTIFIER;
|
|
1331
712
|
exports.ManifestFileName = ManifestFileName;
|
|
1332
713
|
exports.NameTransformMap = NameTransformMap;
|