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