@module-federation/managers 0.1.3 → 0.1.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/package.json +2 -2
- package/dist/LICENSE +0 -21
- package/dist/index.cjs.d.ts +0 -1
- package/dist/index.cjs.js +0 -1237
- package/dist/index.esm.js +0 -1220
- package/dist/package.json +0 -43
- package/dist/src/BasicPluginOptionsManager.d.ts +0 -7
- package/dist/src/ContainerManager.d.ts +0 -19
- package/dist/src/PKGJsonManager.d.ts +0 -6
- package/dist/src/RemoteManager.d.ts +0 -18
- package/dist/src/SharedManager.d.ts +0 -19
- package/dist/src/constant.d.ts +0 -1
- package/dist/src/index.d.ts +0 -7
- package/dist/src/types.d.ts +0 -16
- package/dist/src/utils.d.ts +0 -5
package/dist/index.cjs.js
DELETED
|
@@ -1,1237 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var path = require('path');
|
|
6
|
-
var sdk = require('@module-federation/sdk');
|
|
7
|
-
var finder = require('find-pkg');
|
|
8
|
-
var fs = require('fs');
|
|
9
|
-
var fs$1 = require('fs-extra');
|
|
10
|
-
|
|
11
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
12
|
-
|
|
13
|
-
var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
|
|
14
|
-
var finder__default = /*#__PURE__*/_interopDefaultLegacy(finder);
|
|
15
|
-
var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
|
|
16
|
-
var fs__default$1 = /*#__PURE__*/_interopDefaultLegacy(fs$1);
|
|
17
|
-
|
|
18
|
-
function _class_call_check$4(instance, Constructor) {
|
|
19
|
-
if (!(instance instanceof Constructor)) {
|
|
20
|
-
throw new TypeError("Cannot call a class as a function");
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
function _defineProperties$4(target, props) {
|
|
24
|
-
for(var i = 0; i < props.length; i++){
|
|
25
|
-
var descriptor = props[i];
|
|
26
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
27
|
-
descriptor.configurable = true;
|
|
28
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
29
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
function _create_class$4(Constructor, protoProps, staticProps) {
|
|
33
|
-
if (protoProps) _defineProperties$4(Constructor.prototype, protoProps);
|
|
34
|
-
if (staticProps) _defineProperties$4(Constructor, staticProps);
|
|
35
|
-
return Constructor;
|
|
36
|
-
}
|
|
37
|
-
function _define_property$4(obj, key, value) {
|
|
38
|
-
if (key in obj) {
|
|
39
|
-
Object.defineProperty(obj, key, {
|
|
40
|
-
value: value,
|
|
41
|
-
enumerable: true,
|
|
42
|
-
configurable: true,
|
|
43
|
-
writable: true
|
|
44
|
-
});
|
|
45
|
-
} else {
|
|
46
|
-
obj[key] = value;
|
|
47
|
-
}
|
|
48
|
-
return obj;
|
|
49
|
-
}
|
|
50
|
-
var BasicPluginOptionsManager = /*#__PURE__*/ function() {
|
|
51
|
-
function BasicPluginOptionsManager() {
|
|
52
|
-
_class_call_check$4(this, BasicPluginOptionsManager);
|
|
53
|
-
_define_property$4(this, "_options", void 0);
|
|
54
|
-
}
|
|
55
|
-
_create_class$4(BasicPluginOptionsManager, [
|
|
56
|
-
{
|
|
57
|
-
key: "enable",
|
|
58
|
-
get: function get() {
|
|
59
|
-
return Boolean(this._options);
|
|
60
|
-
}
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
key: "options",
|
|
64
|
-
get: function get() {
|
|
65
|
-
return this._options;
|
|
66
|
-
}
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
key: "init",
|
|
70
|
-
value: function init(options, extraArgs) {
|
|
71
|
-
this._options = options;
|
|
72
|
-
}
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
key: "setOptions",
|
|
76
|
-
value: function setOptions(options) {
|
|
77
|
-
this._options = options;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
]);
|
|
81
|
-
return BasicPluginOptionsManager;
|
|
82
|
-
}();
|
|
83
|
-
|
|
84
|
-
var LOCAL_BUILD_VERSION = "local";
|
|
85
|
-
|
|
86
|
-
function _array_like_to_array$2(arr, len) {
|
|
87
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
88
|
-
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
89
|
-
return arr2;
|
|
90
|
-
}
|
|
91
|
-
function _array_with_holes$2(arr) {
|
|
92
|
-
if (Array.isArray(arr)) return arr;
|
|
93
|
-
}
|
|
94
|
-
function _iterable_to_array_limit$2(arr, i) {
|
|
95
|
-
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
96
|
-
if (_i == null) return;
|
|
97
|
-
var _arr = [];
|
|
98
|
-
var _n = true;
|
|
99
|
-
var _d = false;
|
|
100
|
-
var _s, _e;
|
|
101
|
-
try {
|
|
102
|
-
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
103
|
-
_arr.push(_s.value);
|
|
104
|
-
if (i && _arr.length === i) break;
|
|
105
|
-
}
|
|
106
|
-
} catch (err) {
|
|
107
|
-
_d = true;
|
|
108
|
-
_e = err;
|
|
109
|
-
} finally{
|
|
110
|
-
try {
|
|
111
|
-
if (!_n && _i["return"] != null) _i["return"]();
|
|
112
|
-
} finally{
|
|
113
|
-
if (_d) throw _e;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
return _arr;
|
|
117
|
-
}
|
|
118
|
-
function _non_iterable_rest$2() {
|
|
119
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
120
|
-
}
|
|
121
|
-
function _sliced_to_array$2(arr, i) {
|
|
122
|
-
return _array_with_holes$2(arr) || _iterable_to_array_limit$2(arr, i) || _unsupported_iterable_to_array$2(arr, i) || _non_iterable_rest$2();
|
|
123
|
-
}
|
|
124
|
-
function _unsupported_iterable_to_array$2(o, minLen) {
|
|
125
|
-
if (!o) return;
|
|
126
|
-
if (typeof o === "string") return _array_like_to_array$2(o, minLen);
|
|
127
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
128
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
129
|
-
if (n === "Map" || n === "Set") return Array.from(n);
|
|
130
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$2(o, minLen);
|
|
131
|
-
}
|
|
132
|
-
function processFn(options, normalizeSimple, normalizeOptions, fn) {
|
|
133
|
-
var object = function(obj) {
|
|
134
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
135
|
-
try {
|
|
136
|
-
for(var _iterator = Object.entries(obj)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
137
|
-
var _step_value = _sliced_to_array$2(_step.value, 2), key = _step_value[0], value = _step_value[1];
|
|
138
|
-
if (typeof value === "string") {
|
|
139
|
-
fn(key, normalizeSimple(value, key));
|
|
140
|
-
} else {
|
|
141
|
-
fn(key, normalizeOptions(value, key));
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
} catch (err) {
|
|
145
|
-
_didIteratorError = true;
|
|
146
|
-
_iteratorError = err;
|
|
147
|
-
} finally{
|
|
148
|
-
try {
|
|
149
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
150
|
-
_iterator.return();
|
|
151
|
-
}
|
|
152
|
-
} finally{
|
|
153
|
-
if (_didIteratorError) {
|
|
154
|
-
throw _iteratorError;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
};
|
|
159
|
-
var array = function(items) {
|
|
160
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
161
|
-
try {
|
|
162
|
-
for(var _iterator = items[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
163
|
-
var item = _step.value;
|
|
164
|
-
if (typeof item === "string") {
|
|
165
|
-
fn(item, normalizeSimple(item, item));
|
|
166
|
-
} else if (item && typeof item === "object") {
|
|
167
|
-
object(item);
|
|
168
|
-
} else {
|
|
169
|
-
throw new Error("Unexpected options format");
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
} catch (err) {
|
|
173
|
-
_didIteratorError = true;
|
|
174
|
-
_iteratorError = err;
|
|
175
|
-
} finally{
|
|
176
|
-
try {
|
|
177
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
178
|
-
_iterator.return();
|
|
179
|
-
}
|
|
180
|
-
} finally{
|
|
181
|
-
if (_didIteratorError) {
|
|
182
|
-
throw _iteratorError;
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
};
|
|
187
|
-
if (!options) {
|
|
188
|
-
return;
|
|
189
|
-
} else if (Array.isArray(options)) {
|
|
190
|
-
array(options);
|
|
191
|
-
} else if (typeof options === "object") {
|
|
192
|
-
object(options);
|
|
193
|
-
} else {
|
|
194
|
-
throw new Error("Unexpected options format");
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
function parseOptions(options, normalizeSimple, normalizeOptions) {
|
|
198
|
-
var items = [];
|
|
199
|
-
processFn(options, normalizeSimple, normalizeOptions, function(key, value) {
|
|
200
|
-
items.push([
|
|
201
|
-
key,
|
|
202
|
-
value
|
|
203
|
-
]);
|
|
204
|
-
});
|
|
205
|
-
return items;
|
|
206
|
-
}
|
|
207
|
-
function getBuildVersion() {
|
|
208
|
-
return process.env["MF_BUILD_VERSION"] || LOCAL_BUILD_VERSION;
|
|
209
|
-
}
|
|
210
|
-
function getBuildName() {
|
|
211
|
-
return process.env["MF_BUILD_NAME"];
|
|
212
|
-
}
|
|
213
|
-
// RegExp for version string
|
|
214
|
-
var VERSION_PATTERN_REGEXP = /^([\d^=v<>~]|[*xX]$)/;
|
|
215
|
-
function isRequiredVersion(str) {
|
|
216
|
-
return VERSION_PATTERN_REGEXP.test(str);
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
var utils = /*#__PURE__*/Object.freeze({
|
|
220
|
-
__proto__: null,
|
|
221
|
-
parseOptions: parseOptions,
|
|
222
|
-
getBuildVersion: getBuildVersion,
|
|
223
|
-
getBuildName: getBuildName,
|
|
224
|
-
isRequiredVersion: isRequiredVersion
|
|
225
|
-
});
|
|
226
|
-
|
|
227
|
-
function _array_like_to_array$1(arr, len) {
|
|
228
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
229
|
-
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
230
|
-
return arr2;
|
|
231
|
-
}
|
|
232
|
-
function _array_with_holes$1(arr) {
|
|
233
|
-
if (Array.isArray(arr)) return arr;
|
|
234
|
-
}
|
|
235
|
-
function _array_without_holes(arr) {
|
|
236
|
-
if (Array.isArray(arr)) return _array_like_to_array$1(arr);
|
|
237
|
-
}
|
|
238
|
-
function _assert_this_initialized$2(self) {
|
|
239
|
-
if (self === void 0) {
|
|
240
|
-
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
241
|
-
}
|
|
242
|
-
return self;
|
|
243
|
-
}
|
|
244
|
-
function _class_call_check$3(instance, Constructor) {
|
|
245
|
-
if (!(instance instanceof Constructor)) {
|
|
246
|
-
throw new TypeError("Cannot call a class as a function");
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
function _defineProperties$3(target, props) {
|
|
250
|
-
for(var i = 0; i < props.length; i++){
|
|
251
|
-
var descriptor = props[i];
|
|
252
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
253
|
-
descriptor.configurable = true;
|
|
254
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
255
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
function _create_class$3(Constructor, protoProps, staticProps) {
|
|
259
|
-
if (protoProps) _defineProperties$3(Constructor.prototype, protoProps);
|
|
260
|
-
if (staticProps) _defineProperties$3(Constructor, staticProps);
|
|
261
|
-
return Constructor;
|
|
262
|
-
}
|
|
263
|
-
function _define_property$3(obj, key, value) {
|
|
264
|
-
if (key in obj) {
|
|
265
|
-
Object.defineProperty(obj, key, {
|
|
266
|
-
value: value,
|
|
267
|
-
enumerable: true,
|
|
268
|
-
configurable: true,
|
|
269
|
-
writable: true
|
|
270
|
-
});
|
|
271
|
-
} else {
|
|
272
|
-
obj[key] = value;
|
|
273
|
-
}
|
|
274
|
-
return obj;
|
|
275
|
-
}
|
|
276
|
-
function _get_prototype_of$2(o) {
|
|
277
|
-
_get_prototype_of$2 = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
|
|
278
|
-
return o.__proto__ || Object.getPrototypeOf(o);
|
|
279
|
-
};
|
|
280
|
-
return _get_prototype_of$2(o);
|
|
281
|
-
}
|
|
282
|
-
function _inherits$2(subClass, superClass) {
|
|
283
|
-
if (typeof superClass !== "function" && superClass !== null) {
|
|
284
|
-
throw new TypeError("Super expression must either be null or a function");
|
|
285
|
-
}
|
|
286
|
-
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
287
|
-
constructor: {
|
|
288
|
-
value: subClass,
|
|
289
|
-
writable: true,
|
|
290
|
-
configurable: true
|
|
291
|
-
}
|
|
292
|
-
});
|
|
293
|
-
if (superClass) _set_prototype_of$2(subClass, superClass);
|
|
294
|
-
}
|
|
295
|
-
function _iterable_to_array(iter) {
|
|
296
|
-
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
297
|
-
}
|
|
298
|
-
function _iterable_to_array_limit$1(arr, i) {
|
|
299
|
-
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
300
|
-
if (_i == null) return;
|
|
301
|
-
var _arr = [];
|
|
302
|
-
var _n = true;
|
|
303
|
-
var _d = false;
|
|
304
|
-
var _s, _e;
|
|
305
|
-
try {
|
|
306
|
-
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
307
|
-
_arr.push(_s.value);
|
|
308
|
-
if (i && _arr.length === i) break;
|
|
309
|
-
}
|
|
310
|
-
} catch (err) {
|
|
311
|
-
_d = true;
|
|
312
|
-
_e = err;
|
|
313
|
-
} finally{
|
|
314
|
-
try {
|
|
315
|
-
if (!_n && _i["return"] != null) _i["return"]();
|
|
316
|
-
} finally{
|
|
317
|
-
if (_d) throw _e;
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
return _arr;
|
|
321
|
-
}
|
|
322
|
-
function _non_iterable_rest$1() {
|
|
323
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
324
|
-
}
|
|
325
|
-
function _non_iterable_spread() {
|
|
326
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
327
|
-
}
|
|
328
|
-
function _possible_constructor_return$2(self, call) {
|
|
329
|
-
if (call && (_type_of$2(call) === "object" || typeof call === "function")) {
|
|
330
|
-
return call;
|
|
331
|
-
}
|
|
332
|
-
return _assert_this_initialized$2(self);
|
|
333
|
-
}
|
|
334
|
-
function _set_prototype_of$2(o, p) {
|
|
335
|
-
_set_prototype_of$2 = Object.setPrototypeOf || function setPrototypeOf(o, p) {
|
|
336
|
-
o.__proto__ = p;
|
|
337
|
-
return o;
|
|
338
|
-
};
|
|
339
|
-
return _set_prototype_of$2(o, p);
|
|
340
|
-
}
|
|
341
|
-
function _sliced_to_array$1(arr, i) {
|
|
342
|
-
return _array_with_holes$1(arr) || _iterable_to_array_limit$1(arr, i) || _unsupported_iterable_to_array$1(arr, i) || _non_iterable_rest$1();
|
|
343
|
-
}
|
|
344
|
-
function _to_consumable_array(arr) {
|
|
345
|
-
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array$1(arr) || _non_iterable_spread();
|
|
346
|
-
}
|
|
347
|
-
function _type_of$2(obj) {
|
|
348
|
-
"@swc/helpers - typeof";
|
|
349
|
-
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
350
|
-
}
|
|
351
|
-
function _unsupported_iterable_to_array$1(o, minLen) {
|
|
352
|
-
if (!o) return;
|
|
353
|
-
if (typeof o === "string") return _array_like_to_array$1(o, minLen);
|
|
354
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
355
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
356
|
-
if (n === "Map" || n === "Set") return Array.from(n);
|
|
357
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$1(o, minLen);
|
|
358
|
-
}
|
|
359
|
-
function _is_native_reflect_construct$2() {
|
|
360
|
-
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
361
|
-
if (Reflect.construct.sham) return false;
|
|
362
|
-
if (typeof Proxy === "function") return true;
|
|
363
|
-
try {
|
|
364
|
-
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
365
|
-
return true;
|
|
366
|
-
} catch (e) {
|
|
367
|
-
return false;
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
function _create_super$2(Derived) {
|
|
371
|
-
var hasNativeReflectConstruct = _is_native_reflect_construct$2();
|
|
372
|
-
return function _createSuperInternal() {
|
|
373
|
-
var Super = _get_prototype_of$2(Derived), result;
|
|
374
|
-
if (hasNativeReflectConstruct) {
|
|
375
|
-
var NewTarget = _get_prototype_of$2(this).constructor;
|
|
376
|
-
result = Reflect.construct(Super, arguments, NewTarget);
|
|
377
|
-
} else {
|
|
378
|
-
result = Super.apply(this, arguments);
|
|
379
|
-
}
|
|
380
|
-
return _possible_constructor_return$2(this, result);
|
|
381
|
-
};
|
|
382
|
-
}
|
|
383
|
-
function normalizeExposeModuleName(exposeKey) {
|
|
384
|
-
var relativePath = path__default["default"].relative(".", exposeKey);
|
|
385
|
-
if (!relativePath) {
|
|
386
|
-
return "ExposeEntry";
|
|
387
|
-
}
|
|
388
|
-
return relativePath;
|
|
389
|
-
}
|
|
390
|
-
var ContainerManager = /*#__PURE__*/ function(BasicPluginOptionsManager) {
|
|
391
|
-
_inherits$2(ContainerManager, BasicPluginOptionsManager);
|
|
392
|
-
var _super = _create_super$2(ContainerManager);
|
|
393
|
-
function ContainerManager() {
|
|
394
|
-
_class_call_check$3(this, ContainerManager);
|
|
395
|
-
var _this;
|
|
396
|
-
_this = _super.apply(this, arguments);
|
|
397
|
-
_define_property$3(_assert_this_initialized$2(_this), "_manifestModuleInfos", void 0);
|
|
398
|
-
_define_property$3(_assert_this_initialized$2(_this), "_parsedOptions", void 0);
|
|
399
|
-
return _this;
|
|
400
|
-
}
|
|
401
|
-
_create_class$3(ContainerManager, [
|
|
402
|
-
{
|
|
403
|
-
key: "enable",
|
|
404
|
-
get: function get() {
|
|
405
|
-
return Boolean(this.options.name && this.options.exposes && (Array.isArray(this.options.exposes) ? this.options.exposes.length > 0 : Object.keys(this.options.exposes).length > 0));
|
|
406
|
-
}
|
|
407
|
-
},
|
|
408
|
-
{
|
|
409
|
-
key: "globalEntryName",
|
|
410
|
-
get: function get() {
|
|
411
|
-
var _this_options = this.options, name = _this_options.name, library = _this_options.library;
|
|
412
|
-
if (library) {
|
|
413
|
-
if (typeof library.name === "string") {
|
|
414
|
-
return library.name;
|
|
415
|
-
}
|
|
416
|
-
return undefined;
|
|
417
|
-
}
|
|
418
|
-
return name;
|
|
419
|
-
}
|
|
420
|
-
},
|
|
421
|
-
{
|
|
422
|
-
key: "containerPluginExposesOptions",
|
|
423
|
-
get: function get() {
|
|
424
|
-
var exposes = this.options.exposes;
|
|
425
|
-
var parsedOptions = parseOptions(exposes, function(item, key) {
|
|
426
|
-
return {
|
|
427
|
-
import: Array.isArray(item) ? item : [
|
|
428
|
-
item
|
|
429
|
-
],
|
|
430
|
-
name: sdk.generateExposeFilename(key, false)
|
|
431
|
-
};
|
|
432
|
-
}, function(item, key) {
|
|
433
|
-
return {
|
|
434
|
-
import: Array.isArray(item.import) ? item.import : [
|
|
435
|
-
item.import
|
|
436
|
-
],
|
|
437
|
-
name: item.name || sdk.generateExposeFilename(key, false)
|
|
438
|
-
};
|
|
439
|
-
});
|
|
440
|
-
return parsedOptions.reduce(function(sum, item) {
|
|
441
|
-
var _item = _sliced_to_array$1(item, 2), exposeKey = _item[0], exposeObj = _item[1];
|
|
442
|
-
sum[exposeKey] = exposeObj;
|
|
443
|
-
return sum;
|
|
444
|
-
}, {});
|
|
445
|
-
}
|
|
446
|
-
},
|
|
447
|
-
{
|
|
448
|
-
key: "exposeFileNameImportMap",
|
|
449
|
-
get: // { '.' : './src/Button.jsx' } => { '__federation_expose_Component' : ['src/Buttton'] }
|
|
450
|
-
function get() {
|
|
451
|
-
var exposes = this.options.exposes;
|
|
452
|
-
var parsedOptions = parseOptions(exposes, function(item, key) {
|
|
453
|
-
return {
|
|
454
|
-
import: Array.isArray(item) ? item : [
|
|
455
|
-
item
|
|
456
|
-
],
|
|
457
|
-
name: sdk.generateExposeFilename(key, false)
|
|
458
|
-
};
|
|
459
|
-
}, function(item, key) {
|
|
460
|
-
return {
|
|
461
|
-
import: Array.isArray(item.import) ? item.import : [
|
|
462
|
-
item.import
|
|
463
|
-
],
|
|
464
|
-
name: item.name || sdk.generateExposeFilename(key, false)
|
|
465
|
-
};
|
|
466
|
-
});
|
|
467
|
-
return parsedOptions.reduce(function(sum, item) {
|
|
468
|
-
var _item = _sliced_to_array$1(item, 2); _item[0]; var exposeObj = _item[1];
|
|
469
|
-
var name = exposeObj.name, importPath = exposeObj.import;
|
|
470
|
-
sum[name] = importPath;
|
|
471
|
-
return sum;
|
|
472
|
-
}, {});
|
|
473
|
-
}
|
|
474
|
-
},
|
|
475
|
-
{
|
|
476
|
-
key: "exposeObject",
|
|
477
|
-
get: // { '.' : './src/Button.jsx' } => { '.' : ['src/Button'] }
|
|
478
|
-
function get() {
|
|
479
|
-
var parsedOptions = this._parseOptions();
|
|
480
|
-
return parsedOptions.reduce(function(sum, item) {
|
|
481
|
-
var _item = _sliced_to_array$1(item, 2), exposeKey = _item[0], exposeObject = _item[1];
|
|
482
|
-
sum[exposeKey] = [];
|
|
483
|
-
exposeObject.import.forEach(function(item) {
|
|
484
|
-
var relativePath = path__default["default"].relative(".", item.replace(path__default["default"].extname(item), ""));
|
|
485
|
-
sum[exposeKey].push(relativePath);
|
|
486
|
-
});
|
|
487
|
-
return sum;
|
|
488
|
-
}, {});
|
|
489
|
-
}
|
|
490
|
-
},
|
|
491
|
-
{
|
|
492
|
-
key: "exposeFiles",
|
|
493
|
-
get: // { '.' : './src/Button.jsx' } => ['./src/Button.jsx']
|
|
494
|
-
function get() {
|
|
495
|
-
var parsedOptions = this._parseOptions();
|
|
496
|
-
return parsedOptions.reduce(function(sum, item) {
|
|
497
|
-
var _sum;
|
|
498
|
-
var _item = _sliced_to_array$1(item, 2); _item[0]; var exposeObject = _item[1];
|
|
499
|
-
(_sum = sum).push.apply(_sum, _to_consumable_array(exposeObject.import));
|
|
500
|
-
return sum;
|
|
501
|
-
}, []);
|
|
502
|
-
}
|
|
503
|
-
},
|
|
504
|
-
{
|
|
505
|
-
key: "manifestModuleInfos",
|
|
506
|
-
get: function get() {
|
|
507
|
-
if (this._manifestModuleInfos) {
|
|
508
|
-
return this._manifestModuleInfos;
|
|
509
|
-
}
|
|
510
|
-
// { '.' : './src/Button.jsx' } => { '.' : { name: 'ExposeEntry', file: './src/Button.jsx', requires: {} } }
|
|
511
|
-
var parsedOptions = this._parseOptions();
|
|
512
|
-
this._manifestModuleInfos = parsedOptions.reduce(function(sum, item) {
|
|
513
|
-
var _item = _sliced_to_array$1(item, 2), exposeKey = _item[0], exposeObject = _item[1];
|
|
514
|
-
sum[exposeKey] = {
|
|
515
|
-
name: exposeObject.name || normalizeExposeModuleName(exposeKey),
|
|
516
|
-
file: exposeObject.import
|
|
517
|
-
};
|
|
518
|
-
return sum;
|
|
519
|
-
}, {});
|
|
520
|
-
return this._manifestModuleInfos;
|
|
521
|
-
}
|
|
522
|
-
},
|
|
523
|
-
{
|
|
524
|
-
key: "webpackEntry",
|
|
525
|
-
get: // { '.' : './src/Button.jsx' } => { index: ['./src/Button.jsx'] }
|
|
526
|
-
function get() {
|
|
527
|
-
return Object.values(this.manifestModuleInfos).reduce(function(sum, cur) {
|
|
528
|
-
var entry = cur.name === "ExposeEntry" ? "index" : cur.name.slice(0, 1).toLowerCase() + cur.name.slice(1);
|
|
529
|
-
sum[entry] = cur.file;
|
|
530
|
-
return sum;
|
|
531
|
-
}, {});
|
|
532
|
-
}
|
|
533
|
-
},
|
|
534
|
-
{
|
|
535
|
-
key: "_parseOptions",
|
|
536
|
-
value: function _parseOptions() {
|
|
537
|
-
if (this._parsedOptions) {
|
|
538
|
-
return this._parsedOptions;
|
|
539
|
-
}
|
|
540
|
-
this._parsedOptions = parseOptions(this.options.exposes, function(item) {
|
|
541
|
-
return {
|
|
542
|
-
import: Array.isArray(item) ? item : [
|
|
543
|
-
item
|
|
544
|
-
],
|
|
545
|
-
name: undefined
|
|
546
|
-
};
|
|
547
|
-
}, function(item) {
|
|
548
|
-
return {
|
|
549
|
-
import: Array.isArray(item.import) ? item.import : [
|
|
550
|
-
item.import
|
|
551
|
-
],
|
|
552
|
-
name: undefined
|
|
553
|
-
};
|
|
554
|
-
});
|
|
555
|
-
return this._parsedOptions;
|
|
556
|
-
}
|
|
557
|
-
},
|
|
558
|
-
{
|
|
559
|
-
key: "init",
|
|
560
|
-
value: function init(options) {
|
|
561
|
-
this.setOptions(options);
|
|
562
|
-
this.validate(options.name);
|
|
563
|
-
}
|
|
564
|
-
},
|
|
565
|
-
{
|
|
566
|
-
key: "validate",
|
|
567
|
-
value: function validate(name) {
|
|
568
|
-
if (!name) {
|
|
569
|
-
throw new Error("container name can not be empty!");
|
|
570
|
-
}
|
|
571
|
-
}
|
|
572
|
-
}
|
|
573
|
-
]);
|
|
574
|
-
return ContainerManager;
|
|
575
|
-
}(BasicPluginOptionsManager);
|
|
576
|
-
|
|
577
|
-
function _class_call_check$2(instance, Constructor) {
|
|
578
|
-
if (!(instance instanceof Constructor)) {
|
|
579
|
-
throw new TypeError("Cannot call a class as a function");
|
|
580
|
-
}
|
|
581
|
-
}
|
|
582
|
-
function _defineProperties$2(target, props) {
|
|
583
|
-
for(var i = 0; i < props.length; i++){
|
|
584
|
-
var descriptor = props[i];
|
|
585
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
586
|
-
descriptor.configurable = true;
|
|
587
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
588
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
589
|
-
}
|
|
590
|
-
}
|
|
591
|
-
function _create_class$2(Constructor, protoProps, staticProps) {
|
|
592
|
-
if (protoProps) _defineProperties$2(Constructor.prototype, protoProps);
|
|
593
|
-
if (staticProps) _defineProperties$2(Constructor, staticProps);
|
|
594
|
-
return Constructor;
|
|
595
|
-
}
|
|
596
|
-
function _define_property$2(obj, key, value) {
|
|
597
|
-
if (key in obj) {
|
|
598
|
-
Object.defineProperty(obj, key, {
|
|
599
|
-
value: value,
|
|
600
|
-
enumerable: true,
|
|
601
|
-
configurable: true,
|
|
602
|
-
writable: true
|
|
603
|
-
});
|
|
604
|
-
} else {
|
|
605
|
-
obj[key] = value;
|
|
606
|
-
}
|
|
607
|
-
return obj;
|
|
608
|
-
}
|
|
609
|
-
var PKGJsonManager = /*#__PURE__*/ function() {
|
|
610
|
-
function PKGJsonManager() {
|
|
611
|
-
_class_call_check$2(this, PKGJsonManager);
|
|
612
|
-
_define_property$2(this, "_pkg", void 0);
|
|
613
|
-
}
|
|
614
|
-
_create_class$2(PKGJsonManager, [
|
|
615
|
-
{
|
|
616
|
-
key: "setPKGJson",
|
|
617
|
-
value: function setPKGJson(pkg) {
|
|
618
|
-
this._pkg = pkg;
|
|
619
|
-
}
|
|
620
|
-
},
|
|
621
|
-
{
|
|
622
|
-
key: "readPKGJson",
|
|
623
|
-
value: function readPKGJson() {
|
|
624
|
-
var ctx = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : process.cwd();
|
|
625
|
-
if (this._pkg) {
|
|
626
|
-
return this._pkg;
|
|
627
|
-
}
|
|
628
|
-
try {
|
|
629
|
-
// eslint-disable-next-line no-restricted-globals
|
|
630
|
-
var pkg = JSON.parse(fs__default["default"].readFileSync(path__default["default"].resolve(ctx, "package.json"), "utf8"));
|
|
631
|
-
this._pkg = pkg;
|
|
632
|
-
return pkg;
|
|
633
|
-
} catch (_err) {
|
|
634
|
-
try {
|
|
635
|
-
var pkg1 = finder__default["default"].sync(ctx);
|
|
636
|
-
this._pkg = pkg1;
|
|
637
|
-
return pkg1;
|
|
638
|
-
} catch (err) {
|
|
639
|
-
console.error(err);
|
|
640
|
-
return {};
|
|
641
|
-
}
|
|
642
|
-
}
|
|
643
|
-
}
|
|
644
|
-
},
|
|
645
|
-
{
|
|
646
|
-
key: "getExposeGarfishModuleType",
|
|
647
|
-
value: function getExposeGarfishModuleType() {
|
|
648
|
-
var ctx = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : process.cwd();
|
|
649
|
-
var _pkg_mf;
|
|
650
|
-
var pkg = this.readPKGJson(ctx);
|
|
651
|
-
return (pkg === null || pkg === void 0 ? void 0 : (_pkg_mf = pkg["mf"]) === null || _pkg_mf === void 0 ? void 0 : _pkg_mf.type) === sdk.MFModuleType.NPM ? sdk.MFModuleType.NPM : sdk.MFModuleType.APP;
|
|
652
|
-
}
|
|
653
|
-
}
|
|
654
|
-
]);
|
|
655
|
-
return PKGJsonManager;
|
|
656
|
-
}();
|
|
657
|
-
|
|
658
|
-
function _assert_this_initialized$1(self) {
|
|
659
|
-
if (self === void 0) {
|
|
660
|
-
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
661
|
-
}
|
|
662
|
-
return self;
|
|
663
|
-
}
|
|
664
|
-
function _class_call_check$1(instance, Constructor) {
|
|
665
|
-
if (!(instance instanceof Constructor)) {
|
|
666
|
-
throw new TypeError("Cannot call a class as a function");
|
|
667
|
-
}
|
|
668
|
-
}
|
|
669
|
-
function _defineProperties$1(target, props) {
|
|
670
|
-
for(var i = 0; i < props.length; i++){
|
|
671
|
-
var descriptor = props[i];
|
|
672
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
673
|
-
descriptor.configurable = true;
|
|
674
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
675
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
676
|
-
}
|
|
677
|
-
}
|
|
678
|
-
function _create_class$1(Constructor, protoProps, staticProps) {
|
|
679
|
-
if (protoProps) _defineProperties$1(Constructor.prototype, protoProps);
|
|
680
|
-
if (staticProps) _defineProperties$1(Constructor, staticProps);
|
|
681
|
-
return Constructor;
|
|
682
|
-
}
|
|
683
|
-
function _define_property$1(obj, key, value) {
|
|
684
|
-
if (key in obj) {
|
|
685
|
-
Object.defineProperty(obj, key, {
|
|
686
|
-
value: value,
|
|
687
|
-
enumerable: true,
|
|
688
|
-
configurable: true,
|
|
689
|
-
writable: true
|
|
690
|
-
});
|
|
691
|
-
} else {
|
|
692
|
-
obj[key] = value;
|
|
693
|
-
}
|
|
694
|
-
return obj;
|
|
695
|
-
}
|
|
696
|
-
function _get_prototype_of$1(o) {
|
|
697
|
-
_get_prototype_of$1 = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
|
|
698
|
-
return o.__proto__ || Object.getPrototypeOf(o);
|
|
699
|
-
};
|
|
700
|
-
return _get_prototype_of$1(o);
|
|
701
|
-
}
|
|
702
|
-
function _inherits$1(subClass, superClass) {
|
|
703
|
-
if (typeof superClass !== "function" && superClass !== null) {
|
|
704
|
-
throw new TypeError("Super expression must either be null or a function");
|
|
705
|
-
}
|
|
706
|
-
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
707
|
-
constructor: {
|
|
708
|
-
value: subClass,
|
|
709
|
-
writable: true,
|
|
710
|
-
configurable: true
|
|
711
|
-
}
|
|
712
|
-
});
|
|
713
|
-
if (superClass) _set_prototype_of$1(subClass, superClass);
|
|
714
|
-
}
|
|
715
|
-
function _object_spread$1(target) {
|
|
716
|
-
for(var i = 1; i < arguments.length; i++){
|
|
717
|
-
var source = arguments[i] != null ? arguments[i] : {};
|
|
718
|
-
var ownKeys = Object.keys(source);
|
|
719
|
-
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
720
|
-
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
721
|
-
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
722
|
-
}));
|
|
723
|
-
}
|
|
724
|
-
ownKeys.forEach(function(key) {
|
|
725
|
-
_define_property$1(target, key, source[key]);
|
|
726
|
-
});
|
|
727
|
-
}
|
|
728
|
-
return target;
|
|
729
|
-
}
|
|
730
|
-
function ownKeys$1(object, enumerableOnly) {
|
|
731
|
-
var keys = Object.keys(object);
|
|
732
|
-
if (Object.getOwnPropertySymbols) {
|
|
733
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
734
|
-
if (enumerableOnly) {
|
|
735
|
-
symbols = symbols.filter(function(sym) {
|
|
736
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
737
|
-
});
|
|
738
|
-
}
|
|
739
|
-
keys.push.apply(keys, symbols);
|
|
740
|
-
}
|
|
741
|
-
return keys;
|
|
742
|
-
}
|
|
743
|
-
function _object_spread_props$1(target, source) {
|
|
744
|
-
source = source != null ? source : {};
|
|
745
|
-
if (Object.getOwnPropertyDescriptors) {
|
|
746
|
-
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
747
|
-
} else {
|
|
748
|
-
ownKeys$1(Object(source)).forEach(function(key) {
|
|
749
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
750
|
-
});
|
|
751
|
-
}
|
|
752
|
-
return target;
|
|
753
|
-
}
|
|
754
|
-
function _possible_constructor_return$1(self, call) {
|
|
755
|
-
if (call && (_type_of$1(call) === "object" || typeof call === "function")) {
|
|
756
|
-
return call;
|
|
757
|
-
}
|
|
758
|
-
return _assert_this_initialized$1(self);
|
|
759
|
-
}
|
|
760
|
-
function _set_prototype_of$1(o, p) {
|
|
761
|
-
_set_prototype_of$1 = Object.setPrototypeOf || function setPrototypeOf(o, p) {
|
|
762
|
-
o.__proto__ = p;
|
|
763
|
-
return o;
|
|
764
|
-
};
|
|
765
|
-
return _set_prototype_of$1(o, p);
|
|
766
|
-
}
|
|
767
|
-
function _type_of$1(obj) {
|
|
768
|
-
"@swc/helpers - typeof";
|
|
769
|
-
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
770
|
-
}
|
|
771
|
-
function _is_native_reflect_construct$1() {
|
|
772
|
-
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
773
|
-
if (Reflect.construct.sham) return false;
|
|
774
|
-
if (typeof Proxy === "function") return true;
|
|
775
|
-
try {
|
|
776
|
-
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
777
|
-
return true;
|
|
778
|
-
} catch (e) {
|
|
779
|
-
return false;
|
|
780
|
-
}
|
|
781
|
-
}
|
|
782
|
-
function _create_super$1(Derived) {
|
|
783
|
-
var hasNativeReflectConstruct = _is_native_reflect_construct$1();
|
|
784
|
-
return function _createSuperInternal() {
|
|
785
|
-
var Super = _get_prototype_of$1(Derived), result;
|
|
786
|
-
if (hasNativeReflectConstruct) {
|
|
787
|
-
var NewTarget = _get_prototype_of$1(this).constructor;
|
|
788
|
-
result = Reflect.construct(Super, arguments, NewTarget);
|
|
789
|
-
} else {
|
|
790
|
-
result = Super.apply(this, arguments);
|
|
791
|
-
}
|
|
792
|
-
return _possible_constructor_return$1(this, result);
|
|
793
|
-
};
|
|
794
|
-
}
|
|
795
|
-
function getEntry(remoteObj) {
|
|
796
|
-
if (typeof remoteObj === "string") {
|
|
797
|
-
return remoteObj;
|
|
798
|
-
}
|
|
799
|
-
if (typeof remoteObj.external === "string") {
|
|
800
|
-
return remoteObj.external;
|
|
801
|
-
}
|
|
802
|
-
throw new Error('Not support "array" remote value yet!');
|
|
803
|
-
}
|
|
804
|
-
var RemoteManager = /*#__PURE__*/ function(BasicPluginOptionsManager) {
|
|
805
|
-
_inherits$1(RemoteManager, BasicPluginOptionsManager);
|
|
806
|
-
var _super = _create_super$1(RemoteManager);
|
|
807
|
-
function RemoteManager() {
|
|
808
|
-
_class_call_check$1(this, RemoteManager);
|
|
809
|
-
var _this;
|
|
810
|
-
_this = _super.apply(this, arguments);
|
|
811
|
-
_define_property$1(_assert_this_initialized$1(_this), "normalizedOptions", {});
|
|
812
|
-
return _this;
|
|
813
|
-
}
|
|
814
|
-
_create_class$1(RemoteManager, [
|
|
815
|
-
{
|
|
816
|
-
key: "enable",
|
|
817
|
-
get: function get() {
|
|
818
|
-
return Boolean(this.remotes && (Array.isArray(this.remotes) ? this.remotes.length > 0 : Object.keys(this.remotes).length > 0));
|
|
819
|
-
}
|
|
820
|
-
},
|
|
821
|
-
{
|
|
822
|
-
key: "statsRemoteWithEmptyUsedIn",
|
|
823
|
-
get: function get() {
|
|
824
|
-
var _this = this;
|
|
825
|
-
var name = this.options.name;
|
|
826
|
-
return Object.keys(this.normalizedOptions).reduce(function(sum, cur) {
|
|
827
|
-
var normalizedOption = _this.normalizedOptions[cur];
|
|
828
|
-
var curObj;
|
|
829
|
-
if ("entry" in normalizedOption) {
|
|
830
|
-
curObj = {
|
|
831
|
-
entry: normalizedOption.entry,
|
|
832
|
-
alias: normalizedOption.alias,
|
|
833
|
-
moduleName: normalizedOption.name,
|
|
834
|
-
federationContainerName: normalizedOption.name,
|
|
835
|
-
consumingFederationContainerName: name,
|
|
836
|
-
usedIn: []
|
|
837
|
-
};
|
|
838
|
-
} else {
|
|
839
|
-
curObj = {
|
|
840
|
-
alias: normalizedOption.alias,
|
|
841
|
-
moduleName: normalizedOption.name,
|
|
842
|
-
version: normalizedOption.version,
|
|
843
|
-
federationContainerName: normalizedOption.name,
|
|
844
|
-
consumingFederationContainerName: name,
|
|
845
|
-
usedIn: []
|
|
846
|
-
};
|
|
847
|
-
}
|
|
848
|
-
sum.push(curObj);
|
|
849
|
-
return sum;
|
|
850
|
-
}, []);
|
|
851
|
-
}
|
|
852
|
-
},
|
|
853
|
-
{
|
|
854
|
-
key: "dtsRemotes",
|
|
855
|
-
get: // 'micro-app-sub3': 'app:@garfish/micro-app-sub3:0.0.4',
|
|
856
|
-
// ↓↓↓
|
|
857
|
-
// {
|
|
858
|
-
// 'micro-app-sub3': @garfish/micro-app-sub3:0.0.4
|
|
859
|
-
// }
|
|
860
|
-
function get() {
|
|
861
|
-
var _this = this;
|
|
862
|
-
return Object.keys(this.normalizedOptions).reduce(function(sum, remoteAlias) {
|
|
863
|
-
var remoteInfo = _this.normalizedOptions[remoteAlias];
|
|
864
|
-
sum[remoteAlias] = sdk.composeKeyWithSeparator(remoteInfo.name, "entry" in remoteInfo ? remoteInfo.entry : remoteInfo.version);
|
|
865
|
-
return sum;
|
|
866
|
-
}, {});
|
|
867
|
-
}
|
|
868
|
-
},
|
|
869
|
-
{
|
|
870
|
-
key: "remotes",
|
|
871
|
-
get: function get() {
|
|
872
|
-
return this.options.remotes;
|
|
873
|
-
}
|
|
874
|
-
},
|
|
875
|
-
{
|
|
876
|
-
// INFO: only support remoteType: script now
|
|
877
|
-
key: "normalizeOptions",
|
|
878
|
-
value: function normalizeOptions() {
|
|
879
|
-
var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
880
|
-
this.normalizedOptions = Object.keys(options).reduce(function(sum, remoteAlias) {
|
|
881
|
-
if (Array.isArray(options)) {
|
|
882
|
-
return sum;
|
|
883
|
-
}
|
|
884
|
-
var remoteInfo = options[remoteAlias];
|
|
885
|
-
if (Array.isArray(remoteInfo)) {
|
|
886
|
-
return sum;
|
|
887
|
-
}
|
|
888
|
-
var parsedOptions;
|
|
889
|
-
try {
|
|
890
|
-
parsedOptions = sdk.parseEntry(typeof remoteInfo === "string" ? remoteInfo : getEntry(remoteInfo), "", "@");
|
|
891
|
-
} catch (e) {
|
|
892
|
-
// noop
|
|
893
|
-
}
|
|
894
|
-
if (!parsedOptions) {
|
|
895
|
-
return sum;
|
|
896
|
-
}
|
|
897
|
-
sum[remoteAlias] = _object_spread_props$1(_object_spread$1({}, parsedOptions), {
|
|
898
|
-
alias: remoteAlias,
|
|
899
|
-
shareScope: typeof remoteInfo === "object" ? remoteInfo.shareScope || "default" : "default"
|
|
900
|
-
});
|
|
901
|
-
return sum;
|
|
902
|
-
}, {});
|
|
903
|
-
}
|
|
904
|
-
},
|
|
905
|
-
{
|
|
906
|
-
key: "init",
|
|
907
|
-
value: function init(options) {
|
|
908
|
-
this.setOptions(options);
|
|
909
|
-
this.normalizeOptions(options.remotes);
|
|
910
|
-
}
|
|
911
|
-
}
|
|
912
|
-
]);
|
|
913
|
-
return RemoteManager;
|
|
914
|
-
}(BasicPluginOptionsManager);
|
|
915
|
-
|
|
916
|
-
function _array_like_to_array(arr, len) {
|
|
917
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
918
|
-
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
919
|
-
return arr2;
|
|
920
|
-
}
|
|
921
|
-
function _array_with_holes(arr) {
|
|
922
|
-
if (Array.isArray(arr)) return arr;
|
|
923
|
-
}
|
|
924
|
-
function _assert_this_initialized(self) {
|
|
925
|
-
if (self === void 0) {
|
|
926
|
-
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
927
|
-
}
|
|
928
|
-
return self;
|
|
929
|
-
}
|
|
930
|
-
function _class_call_check(instance, Constructor) {
|
|
931
|
-
if (!(instance instanceof Constructor)) {
|
|
932
|
-
throw new TypeError("Cannot call a class as a function");
|
|
933
|
-
}
|
|
934
|
-
}
|
|
935
|
-
function _defineProperties(target, props) {
|
|
936
|
-
for(var i = 0; i < props.length; i++){
|
|
937
|
-
var descriptor = props[i];
|
|
938
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
939
|
-
descriptor.configurable = true;
|
|
940
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
941
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
942
|
-
}
|
|
943
|
-
}
|
|
944
|
-
function _create_class(Constructor, protoProps, staticProps) {
|
|
945
|
-
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
946
|
-
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
947
|
-
return Constructor;
|
|
948
|
-
}
|
|
949
|
-
function _define_property(obj, key, value) {
|
|
950
|
-
if (key in obj) {
|
|
951
|
-
Object.defineProperty(obj, key, {
|
|
952
|
-
value: value,
|
|
953
|
-
enumerable: true,
|
|
954
|
-
configurable: true,
|
|
955
|
-
writable: true
|
|
956
|
-
});
|
|
957
|
-
} else {
|
|
958
|
-
obj[key] = value;
|
|
959
|
-
}
|
|
960
|
-
return obj;
|
|
961
|
-
}
|
|
962
|
-
function _get_prototype_of(o) {
|
|
963
|
-
_get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
|
|
964
|
-
return o.__proto__ || Object.getPrototypeOf(o);
|
|
965
|
-
};
|
|
966
|
-
return _get_prototype_of(o);
|
|
967
|
-
}
|
|
968
|
-
function _inherits(subClass, superClass) {
|
|
969
|
-
if (typeof superClass !== "function" && superClass !== null) {
|
|
970
|
-
throw new TypeError("Super expression must either be null or a function");
|
|
971
|
-
}
|
|
972
|
-
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
973
|
-
constructor: {
|
|
974
|
-
value: subClass,
|
|
975
|
-
writable: true,
|
|
976
|
-
configurable: true
|
|
977
|
-
}
|
|
978
|
-
});
|
|
979
|
-
if (superClass) _set_prototype_of(subClass, superClass);
|
|
980
|
-
}
|
|
981
|
-
function _iterable_to_array_limit(arr, i) {
|
|
982
|
-
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
983
|
-
if (_i == null) return;
|
|
984
|
-
var _arr = [];
|
|
985
|
-
var _n = true;
|
|
986
|
-
var _d = false;
|
|
987
|
-
var _s, _e;
|
|
988
|
-
try {
|
|
989
|
-
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
990
|
-
_arr.push(_s.value);
|
|
991
|
-
if (i && _arr.length === i) break;
|
|
992
|
-
}
|
|
993
|
-
} catch (err) {
|
|
994
|
-
_d = true;
|
|
995
|
-
_e = err;
|
|
996
|
-
} finally{
|
|
997
|
-
try {
|
|
998
|
-
if (!_n && _i["return"] != null) _i["return"]();
|
|
999
|
-
} finally{
|
|
1000
|
-
if (_d) throw _e;
|
|
1001
|
-
}
|
|
1002
|
-
}
|
|
1003
|
-
return _arr;
|
|
1004
|
-
}
|
|
1005
|
-
function _non_iterable_rest() {
|
|
1006
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
1007
|
-
}
|
|
1008
|
-
function _object_spread(target) {
|
|
1009
|
-
for(var i = 1; i < arguments.length; i++){
|
|
1010
|
-
var source = arguments[i] != null ? arguments[i] : {};
|
|
1011
|
-
var ownKeys = Object.keys(source);
|
|
1012
|
-
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
1013
|
-
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
1014
|
-
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
1015
|
-
}));
|
|
1016
|
-
}
|
|
1017
|
-
ownKeys.forEach(function(key) {
|
|
1018
|
-
_define_property(target, key, source[key]);
|
|
1019
|
-
});
|
|
1020
|
-
}
|
|
1021
|
-
return target;
|
|
1022
|
-
}
|
|
1023
|
-
function ownKeys(object, enumerableOnly) {
|
|
1024
|
-
var keys = Object.keys(object);
|
|
1025
|
-
if (Object.getOwnPropertySymbols) {
|
|
1026
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
1027
|
-
if (enumerableOnly) {
|
|
1028
|
-
symbols = symbols.filter(function(sym) {
|
|
1029
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
1030
|
-
});
|
|
1031
|
-
}
|
|
1032
|
-
keys.push.apply(keys, symbols);
|
|
1033
|
-
}
|
|
1034
|
-
return keys;
|
|
1035
|
-
}
|
|
1036
|
-
function _object_spread_props(target, source) {
|
|
1037
|
-
source = source != null ? source : {};
|
|
1038
|
-
if (Object.getOwnPropertyDescriptors) {
|
|
1039
|
-
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
1040
|
-
} else {
|
|
1041
|
-
ownKeys(Object(source)).forEach(function(key) {
|
|
1042
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
1043
|
-
});
|
|
1044
|
-
}
|
|
1045
|
-
return target;
|
|
1046
|
-
}
|
|
1047
|
-
function _possible_constructor_return(self, call) {
|
|
1048
|
-
if (call && (_type_of(call) === "object" || typeof call === "function")) {
|
|
1049
|
-
return call;
|
|
1050
|
-
}
|
|
1051
|
-
return _assert_this_initialized(self);
|
|
1052
|
-
}
|
|
1053
|
-
function _set_prototype_of(o, p) {
|
|
1054
|
-
_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
|
|
1055
|
-
o.__proto__ = p;
|
|
1056
|
-
return o;
|
|
1057
|
-
};
|
|
1058
|
-
return _set_prototype_of(o, p);
|
|
1059
|
-
}
|
|
1060
|
-
function _sliced_to_array(arr, i) {
|
|
1061
|
-
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
1062
|
-
}
|
|
1063
|
-
function _type_of(obj) {
|
|
1064
|
-
"@swc/helpers - typeof";
|
|
1065
|
-
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
1066
|
-
}
|
|
1067
|
-
function _unsupported_iterable_to_array(o, minLen) {
|
|
1068
|
-
if (!o) return;
|
|
1069
|
-
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
1070
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
1071
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
1072
|
-
if (n === "Map" || n === "Set") return Array.from(n);
|
|
1073
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
1074
|
-
}
|
|
1075
|
-
function _is_native_reflect_construct() {
|
|
1076
|
-
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
1077
|
-
if (Reflect.construct.sham) return false;
|
|
1078
|
-
if (typeof Proxy === "function") return true;
|
|
1079
|
-
try {
|
|
1080
|
-
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
1081
|
-
return true;
|
|
1082
|
-
} catch (e) {
|
|
1083
|
-
return false;
|
|
1084
|
-
}
|
|
1085
|
-
}
|
|
1086
|
-
function _create_super(Derived) {
|
|
1087
|
-
var hasNativeReflectConstruct = _is_native_reflect_construct();
|
|
1088
|
-
return function _createSuperInternal() {
|
|
1089
|
-
var Super = _get_prototype_of(Derived), result;
|
|
1090
|
-
if (hasNativeReflectConstruct) {
|
|
1091
|
-
var NewTarget = _get_prototype_of(this).constructor;
|
|
1092
|
-
result = Reflect.construct(Super, arguments, NewTarget);
|
|
1093
|
-
} else {
|
|
1094
|
-
result = Super.apply(this, arguments);
|
|
1095
|
-
}
|
|
1096
|
-
return _possible_constructor_return(this, result);
|
|
1097
|
-
};
|
|
1098
|
-
}
|
|
1099
|
-
var SharedManager = /*#__PURE__*/ function(BasicPluginOptionsManager) {
|
|
1100
|
-
_inherits(SharedManager, BasicPluginOptionsManager);
|
|
1101
|
-
var _super = _create_super(SharedManager);
|
|
1102
|
-
function SharedManager() {
|
|
1103
|
-
_class_call_check(this, SharedManager);
|
|
1104
|
-
var _this;
|
|
1105
|
-
_this = _super.apply(this, arguments);
|
|
1106
|
-
_define_property(_assert_this_initialized(_this), "normalizedOptions", {});
|
|
1107
|
-
return _this;
|
|
1108
|
-
}
|
|
1109
|
-
_create_class(SharedManager, [
|
|
1110
|
-
{
|
|
1111
|
-
key: "enable",
|
|
1112
|
-
get: function get() {
|
|
1113
|
-
return Boolean(Object.keys(this.sharedPluginOptions.shared).length);
|
|
1114
|
-
}
|
|
1115
|
-
},
|
|
1116
|
-
{
|
|
1117
|
-
key: "sharedPluginOptions",
|
|
1118
|
-
get: function get() {
|
|
1119
|
-
var normalizedShared = this.normalizedOptions;
|
|
1120
|
-
var shared = Object.keys(normalizedShared).reduce(function(sum, cur) {
|
|
1121
|
-
var _normalizedShared_cur = normalizedShared[cur], singleton = _normalizedShared_cur.singleton, requiredVersion = _normalizedShared_cur.requiredVersion, version = _normalizedShared_cur.version, eager = _normalizedShared_cur.eager, shareScope = _normalizedShared_cur.shareScope;
|
|
1122
|
-
sum[cur] = {
|
|
1123
|
-
singleton: singleton,
|
|
1124
|
-
requiredVersion: requiredVersion,
|
|
1125
|
-
version: version,
|
|
1126
|
-
eager: eager,
|
|
1127
|
-
shareScope: shareScope
|
|
1128
|
-
};
|
|
1129
|
-
return sum;
|
|
1130
|
-
}, {});
|
|
1131
|
-
return {
|
|
1132
|
-
shared: shared,
|
|
1133
|
-
shareScope: this.options.shareScope || "default"
|
|
1134
|
-
};
|
|
1135
|
-
}
|
|
1136
|
-
},
|
|
1137
|
-
{
|
|
1138
|
-
key: "findPkg",
|
|
1139
|
-
value: function findPkg1(name, shareConfig) {
|
|
1140
|
-
try {
|
|
1141
|
-
var pkgPath = "";
|
|
1142
|
-
var depName = name;
|
|
1143
|
-
if (shareConfig.import) {
|
|
1144
|
-
if (path__default["default"].isAbsolute(shareConfig.import)) {
|
|
1145
|
-
pkgPath = shareConfig.import;
|
|
1146
|
-
} else if (shareConfig.import.startsWith(".")) {
|
|
1147
|
-
pkgPath = path__default["default"].resolve(process.cwd(), shareConfig.import);
|
|
1148
|
-
}
|
|
1149
|
-
} else {
|
|
1150
|
-
if (shareConfig.packageName) {
|
|
1151
|
-
depName = shareConfig.packageName;
|
|
1152
|
-
}
|
|
1153
|
-
}
|
|
1154
|
-
pkgPath = pkgPath || require.resolve(depName, {
|
|
1155
|
-
paths: [
|
|
1156
|
-
process.cwd()
|
|
1157
|
-
]
|
|
1158
|
-
});
|
|
1159
|
-
var pkgJsonPath = finder__default["default"].sync(pkgPath);
|
|
1160
|
-
return {
|
|
1161
|
-
pkg: JSON.parse(fs__default$1["default"].readFileSync(pkgJsonPath, "utf-8")),
|
|
1162
|
-
path: "",
|
|
1163
|
-
pkgPath: ""
|
|
1164
|
-
};
|
|
1165
|
-
} catch (err) {
|
|
1166
|
-
return {
|
|
1167
|
-
pkg: {},
|
|
1168
|
-
path: "",
|
|
1169
|
-
pkgPath: ""
|
|
1170
|
-
};
|
|
1171
|
-
}
|
|
1172
|
-
}
|
|
1173
|
-
},
|
|
1174
|
-
{
|
|
1175
|
-
key: "transformSharedConfig",
|
|
1176
|
-
value: function transformSharedConfig(sharedConfig) {
|
|
1177
|
-
var defaultSharedConfig = {
|
|
1178
|
-
singleton: true,
|
|
1179
|
-
requiredVersion: undefined,
|
|
1180
|
-
shareScope: "default"
|
|
1181
|
-
};
|
|
1182
|
-
return _object_spread({}, defaultSharedConfig, sharedConfig);
|
|
1183
|
-
}
|
|
1184
|
-
},
|
|
1185
|
-
{
|
|
1186
|
-
key: "normalizeOptions",
|
|
1187
|
-
value: function normalizeOptions(options) {
|
|
1188
|
-
var _this = this;
|
|
1189
|
-
var normalizedShared = {};
|
|
1190
|
-
var sharedOptions = parseOptions(options, function(item, key) {
|
|
1191
|
-
if (typeof item !== "string") throw new Error("Unexpected array in shared");
|
|
1192
|
-
var config = item === key || !isRequiredVersion(item) ? {
|
|
1193
|
-
import: item
|
|
1194
|
-
} : {
|
|
1195
|
-
import: key,
|
|
1196
|
-
requiredVersion: item
|
|
1197
|
-
};
|
|
1198
|
-
return config;
|
|
1199
|
-
}, function(item) {
|
|
1200
|
-
return item;
|
|
1201
|
-
});
|
|
1202
|
-
sharedOptions.forEach(function(item) {
|
|
1203
|
-
var _item = _sliced_to_array(item, 2), sharedName = _item[0], sharedOptions = _item[1];
|
|
1204
|
-
var pkgInfo = _this.findPkg(sharedName, sharedOptions);
|
|
1205
|
-
var sharedConfig = _this.transformSharedConfig(sharedOptions[sharedName]);
|
|
1206
|
-
normalizedShared[sharedName] = _object_spread_props(_object_spread({}, sharedConfig), {
|
|
1207
|
-
requiredVersion: typeof sharedConfig.requiredVersion !== "undefined" ? sharedConfig.requiredVersion : "^".concat(pkgInfo.pkg["version"]),
|
|
1208
|
-
name: sharedName,
|
|
1209
|
-
version: pkgInfo.pkg["version"],
|
|
1210
|
-
eager: Boolean(sharedConfig.eager)
|
|
1211
|
-
});
|
|
1212
|
-
});
|
|
1213
|
-
this.normalizedOptions = normalizedShared;
|
|
1214
|
-
}
|
|
1215
|
-
},
|
|
1216
|
-
{
|
|
1217
|
-
key: "init",
|
|
1218
|
-
value: function init(options) {
|
|
1219
|
-
this.setOptions(options);
|
|
1220
|
-
this.normalizeOptions(options.shared);
|
|
1221
|
-
}
|
|
1222
|
-
}
|
|
1223
|
-
]);
|
|
1224
|
-
return SharedManager;
|
|
1225
|
-
}(BasicPluginOptionsManager);
|
|
1226
|
-
|
|
1227
|
-
var types = /*#__PURE__*/Object.freeze({
|
|
1228
|
-
__proto__: null
|
|
1229
|
-
});
|
|
1230
|
-
|
|
1231
|
-
exports.BasicPluginOptionsManager = BasicPluginOptionsManager;
|
|
1232
|
-
exports.ContainerManager = ContainerManager;
|
|
1233
|
-
exports.PKGJsonManager = PKGJsonManager;
|
|
1234
|
-
exports.RemoteManager = RemoteManager;
|
|
1235
|
-
exports.SharedManager = SharedManager;
|
|
1236
|
-
exports.types = types;
|
|
1237
|
-
exports.utils = utils;
|