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