@module-federation/sdk 0.0.7 → 0.0.8
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 +341 -24
- package/dist/index.esm.js +340 -25
- package/dist/normalize-webpack-path.cjs.js +9 -0
- package/dist/normalize-webpack-path.esm.js +9 -0
- package/dist/package.json +1 -1
- package/dist/src/index.d.ts +1 -0
- package/dist/src/node.d.ts +5 -0
- package/dist/src/normalize-webpack-path.d.ts +3 -1
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -43,13 +43,13 @@ var getProcessEnv = function getProcessEnv() {
|
|
|
43
43
|
return typeof process !== "undefined" && process.env ? process.env : {};
|
|
44
44
|
};
|
|
45
45
|
|
|
46
|
-
function _array_like_to_array$
|
|
46
|
+
function _array_like_to_array$2(arr, len) {
|
|
47
47
|
if (len == null || len > arr.length) len = arr.length;
|
|
48
48
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
49
49
|
return arr2;
|
|
50
50
|
}
|
|
51
51
|
function _array_without_holes(arr) {
|
|
52
|
-
if (Array.isArray(arr)) return _array_like_to_array$
|
|
52
|
+
if (Array.isArray(arr)) return _array_like_to_array$2(arr);
|
|
53
53
|
}
|
|
54
54
|
function _class_call_check(instance, Constructor) {
|
|
55
55
|
if (!(instance instanceof Constructor)) {
|
|
@@ -90,15 +90,15 @@ function _non_iterable_spread() {
|
|
|
90
90
|
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
91
91
|
}
|
|
92
92
|
function _to_consumable_array(arr) {
|
|
93
|
-
return _array_without_holes(arr) || _iterable_to_array$1(arr) || _unsupported_iterable_to_array$
|
|
93
|
+
return _array_without_holes(arr) || _iterable_to_array$1(arr) || _unsupported_iterable_to_array$2(arr) || _non_iterable_spread();
|
|
94
94
|
}
|
|
95
|
-
function _unsupported_iterable_to_array$
|
|
95
|
+
function _unsupported_iterable_to_array$2(o, minLen) {
|
|
96
96
|
if (!o) return;
|
|
97
|
-
if (typeof o === "string") return _array_like_to_array$
|
|
97
|
+
if (typeof o === "string") return _array_like_to_array$2(o, minLen);
|
|
98
98
|
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
99
99
|
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
100
100
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
101
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$
|
|
101
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$2(o, minLen);
|
|
102
102
|
}
|
|
103
103
|
function safeToString(info) {
|
|
104
104
|
try {
|
|
@@ -157,18 +157,18 @@ var Logger = /*#__PURE__*/ function() {
|
|
|
157
157
|
return Logger;
|
|
158
158
|
}();
|
|
159
159
|
|
|
160
|
-
function _array_like_to_array(arr, len) {
|
|
160
|
+
function _array_like_to_array$1(arr, len) {
|
|
161
161
|
if (len == null || len > arr.length) len = arr.length;
|
|
162
162
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
163
163
|
return arr2;
|
|
164
164
|
}
|
|
165
|
-
function _array_with_holes(arr) {
|
|
165
|
+
function _array_with_holes$1(arr) {
|
|
166
166
|
if (Array.isArray(arr)) return arr;
|
|
167
167
|
}
|
|
168
168
|
function _iterable_to_array(iter) {
|
|
169
169
|
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
170
170
|
}
|
|
171
|
-
function _iterable_to_array_limit(arr, i) {
|
|
171
|
+
function _iterable_to_array_limit$1(arr, i) {
|
|
172
172
|
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
173
173
|
if (_i == null) return;
|
|
174
174
|
var _arr = [];
|
|
@@ -192,22 +192,22 @@ function _iterable_to_array_limit(arr, i) {
|
|
|
192
192
|
}
|
|
193
193
|
return _arr;
|
|
194
194
|
}
|
|
195
|
-
function _non_iterable_rest() {
|
|
195
|
+
function _non_iterable_rest$1() {
|
|
196
196
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
197
197
|
}
|
|
198
|
-
function _sliced_to_array(arr, i) {
|
|
199
|
-
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
198
|
+
function _sliced_to_array$1(arr, i) {
|
|
199
|
+
return _array_with_holes$1(arr) || _iterable_to_array_limit$1(arr, i) || _unsupported_iterable_to_array$1(arr, i) || _non_iterable_rest$1();
|
|
200
200
|
}
|
|
201
201
|
function _to_array(arr) {
|
|
202
|
-
return _array_with_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_rest();
|
|
202
|
+
return _array_with_holes$1(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array$1(arr) || _non_iterable_rest$1();
|
|
203
203
|
}
|
|
204
|
-
function _unsupported_iterable_to_array(o, minLen) {
|
|
204
|
+
function _unsupported_iterable_to_array$1(o, minLen) {
|
|
205
205
|
if (!o) return;
|
|
206
|
-
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
206
|
+
if (typeof o === "string") return _array_like_to_array$1(o, minLen);
|
|
207
207
|
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
208
208
|
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
209
209
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
210
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
210
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$1(o, minLen);
|
|
211
211
|
}
|
|
212
212
|
var LOG_CATEGORY = "[ Federation Runtime ]";
|
|
213
213
|
// entry: name:version version : 1.0.0 | ^1.2.3
|
|
@@ -237,7 +237,7 @@ var parseEntry = function(str, devVerOrUrl) {
|
|
|
237
237
|
};
|
|
238
238
|
}
|
|
239
239
|
} else if (strSplit.length === 1) {
|
|
240
|
-
var _strSplit1 = _sliced_to_array(strSplit, 1), name1 = _strSplit1[0];
|
|
240
|
+
var _strSplit1 = _sliced_to_array$1(strSplit, 1), name1 = _strSplit1[0];
|
|
241
241
|
if (devVersionOrUrl && isEntry(devVersionOrUrl)) {
|
|
242
242
|
return {
|
|
243
243
|
name: name1,
|
|
@@ -283,6 +283,9 @@ var decodeName = function decodeName(name, prefix, withExt) {
|
|
|
283
283
|
try {
|
|
284
284
|
var decodedName = name;
|
|
285
285
|
if (prefix) {
|
|
286
|
+
if (!decodedName.startsWith(prefix)) {
|
|
287
|
+
return decodedName;
|
|
288
|
+
}
|
|
286
289
|
decodedName = decodedName.replace(new RegExp(prefix, "g"), "");
|
|
287
290
|
}
|
|
288
291
|
decodedName = decodedName.replace(new RegExp("".concat(NameTransformMap[NameTransformSymbol.AT]), "g"), EncodedNameTransformMap[NameTransformMap[NameTransformSymbol.AT]]).replace(new RegExp("".concat(NameTransformMap[NameTransformSymbol.SLASH]), "g"), EncodedNameTransformMap[NameTransformMap[NameTransformSymbol.SLASH]]).replace(new RegExp("".concat(NameTransformMap[NameTransformSymbol.HYPHEN]), "g"), EncodedNameTransformMap[NameTransformMap[NameTransformSymbol.HYPHEN]]);
|
|
@@ -513,7 +516,7 @@ function isManifestProvider(moduleInfo) {
|
|
|
513
516
|
}
|
|
514
517
|
}
|
|
515
518
|
|
|
516
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
519
|
+
function asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, key, arg) {
|
|
517
520
|
try {
|
|
518
521
|
var info = gen[key](arg);
|
|
519
522
|
var value = info.value;
|
|
@@ -527,16 +530,16 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
|
527
530
|
Promise.resolve(value).then(_next, _throw);
|
|
528
531
|
}
|
|
529
532
|
}
|
|
530
|
-
function _async_to_generator(fn) {
|
|
533
|
+
function _async_to_generator$1(fn) {
|
|
531
534
|
return function() {
|
|
532
535
|
var self = this, args = arguments;
|
|
533
536
|
return new Promise(function(resolve, reject) {
|
|
534
537
|
var gen = fn.apply(self, args);
|
|
535
538
|
function _next(value) {
|
|
536
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
539
|
+
asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "next", value);
|
|
537
540
|
}
|
|
538
541
|
function _throw(err) {
|
|
539
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
542
|
+
asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "throw", err);
|
|
540
543
|
}
|
|
541
544
|
_next(undefined);
|
|
542
545
|
});
|
|
@@ -549,7 +552,7 @@ function _instanceof(left, right) {
|
|
|
549
552
|
return left instanceof right;
|
|
550
553
|
}
|
|
551
554
|
}
|
|
552
|
-
function _ts_generator(thisArg, body) {
|
|
555
|
+
function _ts_generator$1(thisArg, body) {
|
|
553
556
|
var f, y, t, g, _ = {
|
|
554
557
|
label: 0,
|
|
555
558
|
sent: function() {
|
|
@@ -649,9 +652,9 @@ function safeWrapper(callback, disableWarn) {
|
|
|
649
652
|
return _safeWrapper.apply(this, arguments);
|
|
650
653
|
}
|
|
651
654
|
function _safeWrapper() {
|
|
652
|
-
_safeWrapper = _async_to_generator(function(callback, disableWarn) {
|
|
655
|
+
_safeWrapper = _async_to_generator$1(function(callback, disableWarn) {
|
|
653
656
|
var res, e;
|
|
654
|
-
return _ts_generator(this, function(_state) {
|
|
657
|
+
return _ts_generator$1(this, function(_state) {
|
|
655
658
|
switch(_state.label){
|
|
656
659
|
case 0:
|
|
657
660
|
_state.trys.push([
|
|
@@ -762,6 +765,318 @@ function loadScript(url, info) {
|
|
|
762
765
|
});
|
|
763
766
|
}
|
|
764
767
|
|
|
768
|
+
function _array_like_to_array(arr, len) {
|
|
769
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
770
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
771
|
+
return arr2;
|
|
772
|
+
}
|
|
773
|
+
function _array_with_holes(arr) {
|
|
774
|
+
if (Array.isArray(arr)) return arr;
|
|
775
|
+
}
|
|
776
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
777
|
+
try {
|
|
778
|
+
var info = gen[key](arg);
|
|
779
|
+
var value = info.value;
|
|
780
|
+
} catch (error) {
|
|
781
|
+
reject(error);
|
|
782
|
+
return;
|
|
783
|
+
}
|
|
784
|
+
if (info.done) {
|
|
785
|
+
resolve(value);
|
|
786
|
+
} else {
|
|
787
|
+
Promise.resolve(value).then(_next, _throw);
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
function _async_to_generator(fn) {
|
|
791
|
+
return function() {
|
|
792
|
+
var self = this, args = arguments;
|
|
793
|
+
return new Promise(function(resolve, reject) {
|
|
794
|
+
var gen = fn.apply(self, args);
|
|
795
|
+
function _next(value) {
|
|
796
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
797
|
+
}
|
|
798
|
+
function _throw(err) {
|
|
799
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
800
|
+
}
|
|
801
|
+
_next(undefined);
|
|
802
|
+
});
|
|
803
|
+
};
|
|
804
|
+
}
|
|
805
|
+
function _iterable_to_array_limit(arr, i) {
|
|
806
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
807
|
+
if (_i == null) return;
|
|
808
|
+
var _arr = [];
|
|
809
|
+
var _n = true;
|
|
810
|
+
var _d = false;
|
|
811
|
+
var _s, _e;
|
|
812
|
+
try {
|
|
813
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
814
|
+
_arr.push(_s.value);
|
|
815
|
+
if (i && _arr.length === i) break;
|
|
816
|
+
}
|
|
817
|
+
} catch (err) {
|
|
818
|
+
_d = true;
|
|
819
|
+
_e = err;
|
|
820
|
+
} finally{
|
|
821
|
+
try {
|
|
822
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
823
|
+
} finally{
|
|
824
|
+
if (_d) throw _e;
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
return _arr;
|
|
828
|
+
}
|
|
829
|
+
function _non_iterable_rest() {
|
|
830
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
831
|
+
}
|
|
832
|
+
function _sliced_to_array(arr, i) {
|
|
833
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
834
|
+
}
|
|
835
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
836
|
+
if (!o) return;
|
|
837
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
838
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
839
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
840
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
841
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
842
|
+
}
|
|
843
|
+
function _ts_generator(thisArg, body) {
|
|
844
|
+
var f, y, t, g, _ = {
|
|
845
|
+
label: 0,
|
|
846
|
+
sent: function() {
|
|
847
|
+
if (t[0] & 1) throw t[1];
|
|
848
|
+
return t[1];
|
|
849
|
+
},
|
|
850
|
+
trys: [],
|
|
851
|
+
ops: []
|
|
852
|
+
};
|
|
853
|
+
return g = {
|
|
854
|
+
next: verb(0),
|
|
855
|
+
"throw": verb(1),
|
|
856
|
+
"return": verb(2)
|
|
857
|
+
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
858
|
+
return this;
|
|
859
|
+
}), g;
|
|
860
|
+
function verb(n) {
|
|
861
|
+
return function(v) {
|
|
862
|
+
return step([
|
|
863
|
+
n,
|
|
864
|
+
v
|
|
865
|
+
]);
|
|
866
|
+
};
|
|
867
|
+
}
|
|
868
|
+
function step(op) {
|
|
869
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
870
|
+
while(_)try {
|
|
871
|
+
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;
|
|
872
|
+
if (y = 0, t) op = [
|
|
873
|
+
op[0] & 2,
|
|
874
|
+
t.value
|
|
875
|
+
];
|
|
876
|
+
switch(op[0]){
|
|
877
|
+
case 0:
|
|
878
|
+
case 1:
|
|
879
|
+
t = op;
|
|
880
|
+
break;
|
|
881
|
+
case 4:
|
|
882
|
+
_.label++;
|
|
883
|
+
return {
|
|
884
|
+
value: op[1],
|
|
885
|
+
done: false
|
|
886
|
+
};
|
|
887
|
+
case 5:
|
|
888
|
+
_.label++;
|
|
889
|
+
y = op[1];
|
|
890
|
+
op = [
|
|
891
|
+
0
|
|
892
|
+
];
|
|
893
|
+
continue;
|
|
894
|
+
case 7:
|
|
895
|
+
op = _.ops.pop();
|
|
896
|
+
_.trys.pop();
|
|
897
|
+
continue;
|
|
898
|
+
default:
|
|
899
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
900
|
+
_ = 0;
|
|
901
|
+
continue;
|
|
902
|
+
}
|
|
903
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
904
|
+
_.label = op[1];
|
|
905
|
+
break;
|
|
906
|
+
}
|
|
907
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
908
|
+
_.label = t[1];
|
|
909
|
+
t = op;
|
|
910
|
+
break;
|
|
911
|
+
}
|
|
912
|
+
if (t && _.label < t[2]) {
|
|
913
|
+
_.label = t[2];
|
|
914
|
+
_.ops.push(op);
|
|
915
|
+
break;
|
|
916
|
+
}
|
|
917
|
+
if (t[2]) _.ops.pop();
|
|
918
|
+
_.trys.pop();
|
|
919
|
+
continue;
|
|
920
|
+
}
|
|
921
|
+
op = body.call(thisArg, _);
|
|
922
|
+
} catch (e) {
|
|
923
|
+
op = [
|
|
924
|
+
6,
|
|
925
|
+
e
|
|
926
|
+
];
|
|
927
|
+
y = 0;
|
|
928
|
+
} finally{
|
|
929
|
+
f = t = 0;
|
|
930
|
+
}
|
|
931
|
+
if (op[0] & 5) throw op[1];
|
|
932
|
+
return {
|
|
933
|
+
value: op[0] ? op[1] : void 0,
|
|
934
|
+
done: true
|
|
935
|
+
};
|
|
936
|
+
}
|
|
937
|
+
}
|
|
938
|
+
function importNodeModule(name) {
|
|
939
|
+
if (!name) {
|
|
940
|
+
throw new Error("import specifier is required");
|
|
941
|
+
}
|
|
942
|
+
var importModule = new Function("name", "return import(name)");
|
|
943
|
+
return importModule(name).then(function(res) {
|
|
944
|
+
return res.default;
|
|
945
|
+
}).catch(function(error) {
|
|
946
|
+
console.error("Error importing module ".concat(name, ":"), error);
|
|
947
|
+
throw error;
|
|
948
|
+
});
|
|
949
|
+
}
|
|
950
|
+
function createScriptNode(url, cb, attrs, createScriptHook) {
|
|
951
|
+
if (createScriptHook) {
|
|
952
|
+
var hookResult = createScriptHook(url);
|
|
953
|
+
if (hookResult && typeof hookResult === "object" && "url" in hookResult) {
|
|
954
|
+
url = hookResult.url;
|
|
955
|
+
}
|
|
956
|
+
}
|
|
957
|
+
var urlObj;
|
|
958
|
+
try {
|
|
959
|
+
urlObj = new URL(url);
|
|
960
|
+
} catch (e) {
|
|
961
|
+
console.error("Error constructing URL:", e);
|
|
962
|
+
cb(new Error("Invalid URL: ".concat(e)));
|
|
963
|
+
return;
|
|
964
|
+
}
|
|
965
|
+
var getFetch = function() {
|
|
966
|
+
var _ref = _async_to_generator(function() {
|
|
967
|
+
var fetchModule;
|
|
968
|
+
return _ts_generator(this, function(_state) {
|
|
969
|
+
switch(_state.label){
|
|
970
|
+
case 0:
|
|
971
|
+
if (!(typeof fetch === "undefined")) return [
|
|
972
|
+
3,
|
|
973
|
+
2
|
|
974
|
+
];
|
|
975
|
+
return [
|
|
976
|
+
4,
|
|
977
|
+
importNodeModule("node-fetch")
|
|
978
|
+
];
|
|
979
|
+
case 1:
|
|
980
|
+
fetchModule = _state.sent();
|
|
981
|
+
//@ts-ignore
|
|
982
|
+
return [
|
|
983
|
+
2,
|
|
984
|
+
(fetchModule === null || fetchModule === void 0 ? void 0 : fetchModule.default) || fetchModule
|
|
985
|
+
];
|
|
986
|
+
case 2:
|
|
987
|
+
return [
|
|
988
|
+
2,
|
|
989
|
+
fetch
|
|
990
|
+
];
|
|
991
|
+
case 3:
|
|
992
|
+
return [
|
|
993
|
+
2
|
|
994
|
+
];
|
|
995
|
+
}
|
|
996
|
+
});
|
|
997
|
+
});
|
|
998
|
+
return function getFetch() {
|
|
999
|
+
return _ref.apply(this, arguments);
|
|
1000
|
+
};
|
|
1001
|
+
}();
|
|
1002
|
+
console.log("fetching", urlObj.href);
|
|
1003
|
+
getFetch().then(function(f) {
|
|
1004
|
+
f(urlObj.href).then(function(res) {
|
|
1005
|
+
return res.text();
|
|
1006
|
+
}).then(function() {
|
|
1007
|
+
var _ref = _async_to_generator(function(data) {
|
|
1008
|
+
var _ref, path, vm, scriptContext, urlDirname, filename, script, exportedInterface, container;
|
|
1009
|
+
return _ts_generator(this, function(_state) {
|
|
1010
|
+
switch(_state.label){
|
|
1011
|
+
case 0:
|
|
1012
|
+
return [
|
|
1013
|
+
4,
|
|
1014
|
+
Promise.all([
|
|
1015
|
+
importNodeModule("path"),
|
|
1016
|
+
importNodeModule("vm")
|
|
1017
|
+
])
|
|
1018
|
+
];
|
|
1019
|
+
case 1:
|
|
1020
|
+
_ref = _sliced_to_array.apply(void 0, [
|
|
1021
|
+
_state.sent(),
|
|
1022
|
+
2
|
|
1023
|
+
]), path = _ref[0], vm = _ref[1];
|
|
1024
|
+
scriptContext = {
|
|
1025
|
+
exports: {},
|
|
1026
|
+
module: {
|
|
1027
|
+
exports: {}
|
|
1028
|
+
}
|
|
1029
|
+
};
|
|
1030
|
+
urlDirname = urlObj.pathname.split("/").slice(0, -1).join("/");
|
|
1031
|
+
filename = path.basename(urlObj.pathname);
|
|
1032
|
+
try {
|
|
1033
|
+
script = new vm.Script("(function(exports, module, require, __dirname, __filename) {".concat(data, "\n})"), {
|
|
1034
|
+
filename: filename
|
|
1035
|
+
});
|
|
1036
|
+
script.runInThisContext()(scriptContext.exports, scriptContext.module, eval("require"), urlDirname, filename);
|
|
1037
|
+
exportedInterface = scriptContext.module.exports || scriptContext.exports;
|
|
1038
|
+
if (attrs && exportedInterface && attrs["globalName"]) {
|
|
1039
|
+
container = exportedInterface[attrs["globalName"]];
|
|
1040
|
+
cb(undefined, container);
|
|
1041
|
+
return [
|
|
1042
|
+
2
|
|
1043
|
+
];
|
|
1044
|
+
}
|
|
1045
|
+
cb(undefined, exportedInterface);
|
|
1046
|
+
} catch (e) {
|
|
1047
|
+
// console.error('Error running script:', e);
|
|
1048
|
+
cb(new Error("Script execution error: ".concat(e)));
|
|
1049
|
+
}
|
|
1050
|
+
return [
|
|
1051
|
+
2
|
|
1052
|
+
];
|
|
1053
|
+
}
|
|
1054
|
+
});
|
|
1055
|
+
});
|
|
1056
|
+
return function(data) {
|
|
1057
|
+
return _ref.apply(this, arguments);
|
|
1058
|
+
};
|
|
1059
|
+
}()).catch(function(err) {
|
|
1060
|
+
// console.error('Error fetching script:', err);
|
|
1061
|
+
cb(err);
|
|
1062
|
+
});
|
|
1063
|
+
});
|
|
1064
|
+
}
|
|
1065
|
+
function loadScriptNode(url, info) {
|
|
1066
|
+
return new Promise(function(resolve, reject) {
|
|
1067
|
+
createScriptNode(url, function(error, scriptContext) {
|
|
1068
|
+
if (error) {
|
|
1069
|
+
reject(error);
|
|
1070
|
+
} else {
|
|
1071
|
+
var _info_attrs, _info_attrs1;
|
|
1072
|
+
var remoteEntryKey = (info === null || info === void 0 ? void 0 : (_info_attrs = info.attrs) === null || _info_attrs === void 0 ? void 0 : _info_attrs["globalName"]) || "__FEDERATION_".concat(info === null || info === void 0 ? void 0 : (_info_attrs1 = info.attrs) === null || _info_attrs1 === void 0 ? void 0 : _info_attrs1["name"], ":custom__");
|
|
1073
|
+
var entryExports = globalThis[remoteEntryKey] = scriptContext;
|
|
1074
|
+
resolve(entryExports);
|
|
1075
|
+
}
|
|
1076
|
+
}, info.attrs, info.createScriptHook);
|
|
1077
|
+
});
|
|
1078
|
+
}
|
|
1079
|
+
|
|
765
1080
|
exports.BROWSER_LOG_KEY = BROWSER_LOG_KEY;
|
|
766
1081
|
exports.BROWSER_LOG_VALUE = BROWSER_LOG_VALUE;
|
|
767
1082
|
exports.EncodedNameTransformMap = EncodedNameTransformMap;
|
|
@@ -774,6 +1089,7 @@ exports.SEPARATOR = SEPARATOR;
|
|
|
774
1089
|
exports.assert = assert;
|
|
775
1090
|
exports.composeKeyWithSeparator = composeKeyWithSeparator;
|
|
776
1091
|
exports.createScript = createScript;
|
|
1092
|
+
exports.createScriptNode = createScriptNode;
|
|
777
1093
|
exports.decodeName = decodeName;
|
|
778
1094
|
exports.encodeName = encodeName;
|
|
779
1095
|
exports.error = error;
|
|
@@ -787,6 +1103,7 @@ exports.isDebugMode = isDebugMode;
|
|
|
787
1103
|
exports.isManifestProvider = isManifestProvider;
|
|
788
1104
|
exports.isStaticResourcesEqual = isStaticResourcesEqual;
|
|
789
1105
|
exports.loadScript = loadScript;
|
|
1106
|
+
exports.loadScriptNode = loadScriptNode;
|
|
790
1107
|
exports.logger = logger;
|
|
791
1108
|
exports.parseEntry = parseEntry;
|
|
792
1109
|
exports.safeWrapper = safeWrapper;
|
package/dist/index.esm.js
CHANGED
|
@@ -39,13 +39,13 @@ var getProcessEnv = function getProcessEnv() {
|
|
|
39
39
|
return typeof process !== "undefined" && process.env ? process.env : {};
|
|
40
40
|
};
|
|
41
41
|
|
|
42
|
-
function _array_like_to_array$
|
|
42
|
+
function _array_like_to_array$2(arr, len) {
|
|
43
43
|
if (len == null || len > arr.length) len = arr.length;
|
|
44
44
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
45
45
|
return arr2;
|
|
46
46
|
}
|
|
47
47
|
function _array_without_holes(arr) {
|
|
48
|
-
if (Array.isArray(arr)) return _array_like_to_array$
|
|
48
|
+
if (Array.isArray(arr)) return _array_like_to_array$2(arr);
|
|
49
49
|
}
|
|
50
50
|
function _class_call_check(instance, Constructor) {
|
|
51
51
|
if (!(instance instanceof Constructor)) {
|
|
@@ -86,15 +86,15 @@ function _non_iterable_spread() {
|
|
|
86
86
|
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
87
87
|
}
|
|
88
88
|
function _to_consumable_array(arr) {
|
|
89
|
-
return _array_without_holes(arr) || _iterable_to_array$1(arr) || _unsupported_iterable_to_array$
|
|
89
|
+
return _array_without_holes(arr) || _iterable_to_array$1(arr) || _unsupported_iterable_to_array$2(arr) || _non_iterable_spread();
|
|
90
90
|
}
|
|
91
|
-
function _unsupported_iterable_to_array$
|
|
91
|
+
function _unsupported_iterable_to_array$2(o, minLen) {
|
|
92
92
|
if (!o) return;
|
|
93
|
-
if (typeof o === "string") return _array_like_to_array$
|
|
93
|
+
if (typeof o === "string") return _array_like_to_array$2(o, minLen);
|
|
94
94
|
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
95
95
|
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
96
96
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
97
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$
|
|
97
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$2(o, minLen);
|
|
98
98
|
}
|
|
99
99
|
function safeToString(info) {
|
|
100
100
|
try {
|
|
@@ -153,18 +153,18 @@ var Logger = /*#__PURE__*/ function() {
|
|
|
153
153
|
return Logger;
|
|
154
154
|
}();
|
|
155
155
|
|
|
156
|
-
function _array_like_to_array(arr, len) {
|
|
156
|
+
function _array_like_to_array$1(arr, len) {
|
|
157
157
|
if (len == null || len > arr.length) len = arr.length;
|
|
158
158
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
159
159
|
return arr2;
|
|
160
160
|
}
|
|
161
|
-
function _array_with_holes(arr) {
|
|
161
|
+
function _array_with_holes$1(arr) {
|
|
162
162
|
if (Array.isArray(arr)) return arr;
|
|
163
163
|
}
|
|
164
164
|
function _iterable_to_array(iter) {
|
|
165
165
|
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
166
166
|
}
|
|
167
|
-
function _iterable_to_array_limit(arr, i) {
|
|
167
|
+
function _iterable_to_array_limit$1(arr, i) {
|
|
168
168
|
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
169
169
|
if (_i == null) return;
|
|
170
170
|
var _arr = [];
|
|
@@ -188,22 +188,22 @@ function _iterable_to_array_limit(arr, i) {
|
|
|
188
188
|
}
|
|
189
189
|
return _arr;
|
|
190
190
|
}
|
|
191
|
-
function _non_iterable_rest() {
|
|
191
|
+
function _non_iterable_rest$1() {
|
|
192
192
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
193
193
|
}
|
|
194
|
-
function _sliced_to_array(arr, i) {
|
|
195
|
-
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
194
|
+
function _sliced_to_array$1(arr, i) {
|
|
195
|
+
return _array_with_holes$1(arr) || _iterable_to_array_limit$1(arr, i) || _unsupported_iterable_to_array$1(arr, i) || _non_iterable_rest$1();
|
|
196
196
|
}
|
|
197
197
|
function _to_array(arr) {
|
|
198
|
-
return _array_with_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_rest();
|
|
198
|
+
return _array_with_holes$1(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array$1(arr) || _non_iterable_rest$1();
|
|
199
199
|
}
|
|
200
|
-
function _unsupported_iterable_to_array(o, minLen) {
|
|
200
|
+
function _unsupported_iterable_to_array$1(o, minLen) {
|
|
201
201
|
if (!o) return;
|
|
202
|
-
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
202
|
+
if (typeof o === "string") return _array_like_to_array$1(o, minLen);
|
|
203
203
|
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
204
204
|
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
205
205
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
206
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
206
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$1(o, minLen);
|
|
207
207
|
}
|
|
208
208
|
var LOG_CATEGORY = "[ Federation Runtime ]";
|
|
209
209
|
// entry: name:version version : 1.0.0 | ^1.2.3
|
|
@@ -233,7 +233,7 @@ var parseEntry = function(str, devVerOrUrl) {
|
|
|
233
233
|
};
|
|
234
234
|
}
|
|
235
235
|
} else if (strSplit.length === 1) {
|
|
236
|
-
var _strSplit1 = _sliced_to_array(strSplit, 1), name1 = _strSplit1[0];
|
|
236
|
+
var _strSplit1 = _sliced_to_array$1(strSplit, 1), name1 = _strSplit1[0];
|
|
237
237
|
if (devVersionOrUrl && isEntry(devVersionOrUrl)) {
|
|
238
238
|
return {
|
|
239
239
|
name: name1,
|
|
@@ -279,6 +279,9 @@ var decodeName = function decodeName(name, prefix, withExt) {
|
|
|
279
279
|
try {
|
|
280
280
|
var decodedName = name;
|
|
281
281
|
if (prefix) {
|
|
282
|
+
if (!decodedName.startsWith(prefix)) {
|
|
283
|
+
return decodedName;
|
|
284
|
+
}
|
|
282
285
|
decodedName = decodedName.replace(new RegExp(prefix, "g"), "");
|
|
283
286
|
}
|
|
284
287
|
decodedName = decodedName.replace(new RegExp("".concat(NameTransformMap[NameTransformSymbol.AT]), "g"), EncodedNameTransformMap[NameTransformMap[NameTransformSymbol.AT]]).replace(new RegExp("".concat(NameTransformMap[NameTransformSymbol.SLASH]), "g"), EncodedNameTransformMap[NameTransformMap[NameTransformSymbol.SLASH]]).replace(new RegExp("".concat(NameTransformMap[NameTransformSymbol.HYPHEN]), "g"), EncodedNameTransformMap[NameTransformMap[NameTransformSymbol.HYPHEN]]);
|
|
@@ -509,7 +512,7 @@ function isManifestProvider(moduleInfo) {
|
|
|
509
512
|
}
|
|
510
513
|
}
|
|
511
514
|
|
|
512
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
515
|
+
function asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, key, arg) {
|
|
513
516
|
try {
|
|
514
517
|
var info = gen[key](arg);
|
|
515
518
|
var value = info.value;
|
|
@@ -523,16 +526,16 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
|
523
526
|
Promise.resolve(value).then(_next, _throw);
|
|
524
527
|
}
|
|
525
528
|
}
|
|
526
|
-
function _async_to_generator(fn) {
|
|
529
|
+
function _async_to_generator$1(fn) {
|
|
527
530
|
return function() {
|
|
528
531
|
var self = this, args = arguments;
|
|
529
532
|
return new Promise(function(resolve, reject) {
|
|
530
533
|
var gen = fn.apply(self, args);
|
|
531
534
|
function _next(value) {
|
|
532
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
535
|
+
asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "next", value);
|
|
533
536
|
}
|
|
534
537
|
function _throw(err) {
|
|
535
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
538
|
+
asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "throw", err);
|
|
536
539
|
}
|
|
537
540
|
_next(undefined);
|
|
538
541
|
});
|
|
@@ -545,7 +548,7 @@ function _instanceof(left, right) {
|
|
|
545
548
|
return left instanceof right;
|
|
546
549
|
}
|
|
547
550
|
}
|
|
548
|
-
function _ts_generator(thisArg, body) {
|
|
551
|
+
function _ts_generator$1(thisArg, body) {
|
|
549
552
|
var f, y, t, g, _ = {
|
|
550
553
|
label: 0,
|
|
551
554
|
sent: function() {
|
|
@@ -645,9 +648,9 @@ function safeWrapper(callback, disableWarn) {
|
|
|
645
648
|
return _safeWrapper.apply(this, arguments);
|
|
646
649
|
}
|
|
647
650
|
function _safeWrapper() {
|
|
648
|
-
_safeWrapper = _async_to_generator(function(callback, disableWarn) {
|
|
651
|
+
_safeWrapper = _async_to_generator$1(function(callback, disableWarn) {
|
|
649
652
|
var res, e;
|
|
650
|
-
return _ts_generator(this, function(_state) {
|
|
653
|
+
return _ts_generator$1(this, function(_state) {
|
|
651
654
|
switch(_state.label){
|
|
652
655
|
case 0:
|
|
653
656
|
_state.trys.push([
|
|
@@ -758,4 +761,316 @@ function loadScript(url, info) {
|
|
|
758
761
|
});
|
|
759
762
|
}
|
|
760
763
|
|
|
761
|
-
|
|
764
|
+
function _array_like_to_array(arr, len) {
|
|
765
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
766
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
767
|
+
return arr2;
|
|
768
|
+
}
|
|
769
|
+
function _array_with_holes(arr) {
|
|
770
|
+
if (Array.isArray(arr)) return arr;
|
|
771
|
+
}
|
|
772
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
773
|
+
try {
|
|
774
|
+
var info = gen[key](arg);
|
|
775
|
+
var value = info.value;
|
|
776
|
+
} catch (error) {
|
|
777
|
+
reject(error);
|
|
778
|
+
return;
|
|
779
|
+
}
|
|
780
|
+
if (info.done) {
|
|
781
|
+
resolve(value);
|
|
782
|
+
} else {
|
|
783
|
+
Promise.resolve(value).then(_next, _throw);
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
function _async_to_generator(fn) {
|
|
787
|
+
return function() {
|
|
788
|
+
var self = this, args = arguments;
|
|
789
|
+
return new Promise(function(resolve, reject) {
|
|
790
|
+
var gen = fn.apply(self, args);
|
|
791
|
+
function _next(value) {
|
|
792
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
793
|
+
}
|
|
794
|
+
function _throw(err) {
|
|
795
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
796
|
+
}
|
|
797
|
+
_next(undefined);
|
|
798
|
+
});
|
|
799
|
+
};
|
|
800
|
+
}
|
|
801
|
+
function _iterable_to_array_limit(arr, i) {
|
|
802
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
803
|
+
if (_i == null) return;
|
|
804
|
+
var _arr = [];
|
|
805
|
+
var _n = true;
|
|
806
|
+
var _d = false;
|
|
807
|
+
var _s, _e;
|
|
808
|
+
try {
|
|
809
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
810
|
+
_arr.push(_s.value);
|
|
811
|
+
if (i && _arr.length === i) break;
|
|
812
|
+
}
|
|
813
|
+
} catch (err) {
|
|
814
|
+
_d = true;
|
|
815
|
+
_e = err;
|
|
816
|
+
} finally{
|
|
817
|
+
try {
|
|
818
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
819
|
+
} finally{
|
|
820
|
+
if (_d) throw _e;
|
|
821
|
+
}
|
|
822
|
+
}
|
|
823
|
+
return _arr;
|
|
824
|
+
}
|
|
825
|
+
function _non_iterable_rest() {
|
|
826
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
827
|
+
}
|
|
828
|
+
function _sliced_to_array(arr, i) {
|
|
829
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
830
|
+
}
|
|
831
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
832
|
+
if (!o) return;
|
|
833
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
834
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
835
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
836
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
837
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
838
|
+
}
|
|
839
|
+
function _ts_generator(thisArg, body) {
|
|
840
|
+
var f, y, t, g, _ = {
|
|
841
|
+
label: 0,
|
|
842
|
+
sent: function() {
|
|
843
|
+
if (t[0] & 1) throw t[1];
|
|
844
|
+
return t[1];
|
|
845
|
+
},
|
|
846
|
+
trys: [],
|
|
847
|
+
ops: []
|
|
848
|
+
};
|
|
849
|
+
return g = {
|
|
850
|
+
next: verb(0),
|
|
851
|
+
"throw": verb(1),
|
|
852
|
+
"return": verb(2)
|
|
853
|
+
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
854
|
+
return this;
|
|
855
|
+
}), g;
|
|
856
|
+
function verb(n) {
|
|
857
|
+
return function(v) {
|
|
858
|
+
return step([
|
|
859
|
+
n,
|
|
860
|
+
v
|
|
861
|
+
]);
|
|
862
|
+
};
|
|
863
|
+
}
|
|
864
|
+
function step(op) {
|
|
865
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
866
|
+
while(_)try {
|
|
867
|
+
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;
|
|
868
|
+
if (y = 0, t) op = [
|
|
869
|
+
op[0] & 2,
|
|
870
|
+
t.value
|
|
871
|
+
];
|
|
872
|
+
switch(op[0]){
|
|
873
|
+
case 0:
|
|
874
|
+
case 1:
|
|
875
|
+
t = op;
|
|
876
|
+
break;
|
|
877
|
+
case 4:
|
|
878
|
+
_.label++;
|
|
879
|
+
return {
|
|
880
|
+
value: op[1],
|
|
881
|
+
done: false
|
|
882
|
+
};
|
|
883
|
+
case 5:
|
|
884
|
+
_.label++;
|
|
885
|
+
y = op[1];
|
|
886
|
+
op = [
|
|
887
|
+
0
|
|
888
|
+
];
|
|
889
|
+
continue;
|
|
890
|
+
case 7:
|
|
891
|
+
op = _.ops.pop();
|
|
892
|
+
_.trys.pop();
|
|
893
|
+
continue;
|
|
894
|
+
default:
|
|
895
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
896
|
+
_ = 0;
|
|
897
|
+
continue;
|
|
898
|
+
}
|
|
899
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
900
|
+
_.label = op[1];
|
|
901
|
+
break;
|
|
902
|
+
}
|
|
903
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
904
|
+
_.label = t[1];
|
|
905
|
+
t = op;
|
|
906
|
+
break;
|
|
907
|
+
}
|
|
908
|
+
if (t && _.label < t[2]) {
|
|
909
|
+
_.label = t[2];
|
|
910
|
+
_.ops.push(op);
|
|
911
|
+
break;
|
|
912
|
+
}
|
|
913
|
+
if (t[2]) _.ops.pop();
|
|
914
|
+
_.trys.pop();
|
|
915
|
+
continue;
|
|
916
|
+
}
|
|
917
|
+
op = body.call(thisArg, _);
|
|
918
|
+
} catch (e) {
|
|
919
|
+
op = [
|
|
920
|
+
6,
|
|
921
|
+
e
|
|
922
|
+
];
|
|
923
|
+
y = 0;
|
|
924
|
+
} finally{
|
|
925
|
+
f = t = 0;
|
|
926
|
+
}
|
|
927
|
+
if (op[0] & 5) throw op[1];
|
|
928
|
+
return {
|
|
929
|
+
value: op[0] ? op[1] : void 0,
|
|
930
|
+
done: true
|
|
931
|
+
};
|
|
932
|
+
}
|
|
933
|
+
}
|
|
934
|
+
function importNodeModule(name) {
|
|
935
|
+
if (!name) {
|
|
936
|
+
throw new Error("import specifier is required");
|
|
937
|
+
}
|
|
938
|
+
var importModule = new Function("name", "return import(name)");
|
|
939
|
+
return importModule(name).then(function(res) {
|
|
940
|
+
return res.default;
|
|
941
|
+
}).catch(function(error) {
|
|
942
|
+
console.error("Error importing module ".concat(name, ":"), error);
|
|
943
|
+
throw error;
|
|
944
|
+
});
|
|
945
|
+
}
|
|
946
|
+
function createScriptNode(url, cb, attrs, createScriptHook) {
|
|
947
|
+
if (createScriptHook) {
|
|
948
|
+
var hookResult = createScriptHook(url);
|
|
949
|
+
if (hookResult && typeof hookResult === "object" && "url" in hookResult) {
|
|
950
|
+
url = hookResult.url;
|
|
951
|
+
}
|
|
952
|
+
}
|
|
953
|
+
var urlObj;
|
|
954
|
+
try {
|
|
955
|
+
urlObj = new URL(url);
|
|
956
|
+
} catch (e) {
|
|
957
|
+
console.error("Error constructing URL:", e);
|
|
958
|
+
cb(new Error("Invalid URL: ".concat(e)));
|
|
959
|
+
return;
|
|
960
|
+
}
|
|
961
|
+
var getFetch = function() {
|
|
962
|
+
var _ref = _async_to_generator(function() {
|
|
963
|
+
var fetchModule;
|
|
964
|
+
return _ts_generator(this, function(_state) {
|
|
965
|
+
switch(_state.label){
|
|
966
|
+
case 0:
|
|
967
|
+
if (!(typeof fetch === "undefined")) return [
|
|
968
|
+
3,
|
|
969
|
+
2
|
|
970
|
+
];
|
|
971
|
+
return [
|
|
972
|
+
4,
|
|
973
|
+
importNodeModule("node-fetch")
|
|
974
|
+
];
|
|
975
|
+
case 1:
|
|
976
|
+
fetchModule = _state.sent();
|
|
977
|
+
//@ts-ignore
|
|
978
|
+
return [
|
|
979
|
+
2,
|
|
980
|
+
(fetchModule === null || fetchModule === void 0 ? void 0 : fetchModule.default) || fetchModule
|
|
981
|
+
];
|
|
982
|
+
case 2:
|
|
983
|
+
return [
|
|
984
|
+
2,
|
|
985
|
+
fetch
|
|
986
|
+
];
|
|
987
|
+
case 3:
|
|
988
|
+
return [
|
|
989
|
+
2
|
|
990
|
+
];
|
|
991
|
+
}
|
|
992
|
+
});
|
|
993
|
+
});
|
|
994
|
+
return function getFetch() {
|
|
995
|
+
return _ref.apply(this, arguments);
|
|
996
|
+
};
|
|
997
|
+
}();
|
|
998
|
+
console.log("fetching", urlObj.href);
|
|
999
|
+
getFetch().then(function(f) {
|
|
1000
|
+
f(urlObj.href).then(function(res) {
|
|
1001
|
+
return res.text();
|
|
1002
|
+
}).then(function() {
|
|
1003
|
+
var _ref = _async_to_generator(function(data) {
|
|
1004
|
+
var _ref, path, vm, scriptContext, urlDirname, filename, script, exportedInterface, container;
|
|
1005
|
+
return _ts_generator(this, function(_state) {
|
|
1006
|
+
switch(_state.label){
|
|
1007
|
+
case 0:
|
|
1008
|
+
return [
|
|
1009
|
+
4,
|
|
1010
|
+
Promise.all([
|
|
1011
|
+
importNodeModule("path"),
|
|
1012
|
+
importNodeModule("vm")
|
|
1013
|
+
])
|
|
1014
|
+
];
|
|
1015
|
+
case 1:
|
|
1016
|
+
_ref = _sliced_to_array.apply(void 0, [
|
|
1017
|
+
_state.sent(),
|
|
1018
|
+
2
|
|
1019
|
+
]), path = _ref[0], vm = _ref[1];
|
|
1020
|
+
scriptContext = {
|
|
1021
|
+
exports: {},
|
|
1022
|
+
module: {
|
|
1023
|
+
exports: {}
|
|
1024
|
+
}
|
|
1025
|
+
};
|
|
1026
|
+
urlDirname = urlObj.pathname.split("/").slice(0, -1).join("/");
|
|
1027
|
+
filename = path.basename(urlObj.pathname);
|
|
1028
|
+
try {
|
|
1029
|
+
script = new vm.Script("(function(exports, module, require, __dirname, __filename) {".concat(data, "\n})"), {
|
|
1030
|
+
filename: filename
|
|
1031
|
+
});
|
|
1032
|
+
script.runInThisContext()(scriptContext.exports, scriptContext.module, eval("require"), urlDirname, filename);
|
|
1033
|
+
exportedInterface = scriptContext.module.exports || scriptContext.exports;
|
|
1034
|
+
if (attrs && exportedInterface && attrs["globalName"]) {
|
|
1035
|
+
container = exportedInterface[attrs["globalName"]];
|
|
1036
|
+
cb(undefined, container);
|
|
1037
|
+
return [
|
|
1038
|
+
2
|
|
1039
|
+
];
|
|
1040
|
+
}
|
|
1041
|
+
cb(undefined, exportedInterface);
|
|
1042
|
+
} catch (e) {
|
|
1043
|
+
// console.error('Error running script:', e);
|
|
1044
|
+
cb(new Error("Script execution error: ".concat(e)));
|
|
1045
|
+
}
|
|
1046
|
+
return [
|
|
1047
|
+
2
|
|
1048
|
+
];
|
|
1049
|
+
}
|
|
1050
|
+
});
|
|
1051
|
+
});
|
|
1052
|
+
return function(data) {
|
|
1053
|
+
return _ref.apply(this, arguments);
|
|
1054
|
+
};
|
|
1055
|
+
}()).catch(function(err) {
|
|
1056
|
+
// console.error('Error fetching script:', err);
|
|
1057
|
+
cb(err);
|
|
1058
|
+
});
|
|
1059
|
+
});
|
|
1060
|
+
}
|
|
1061
|
+
function loadScriptNode(url, info) {
|
|
1062
|
+
return new Promise(function(resolve, reject) {
|
|
1063
|
+
createScriptNode(url, function(error, scriptContext) {
|
|
1064
|
+
if (error) {
|
|
1065
|
+
reject(error);
|
|
1066
|
+
} else {
|
|
1067
|
+
var _info_attrs, _info_attrs1;
|
|
1068
|
+
var remoteEntryKey = (info === null || info === void 0 ? void 0 : (_info_attrs = info.attrs) === null || _info_attrs === void 0 ? void 0 : _info_attrs["globalName"]) || "__FEDERATION_".concat(info === null || info === void 0 ? void 0 : (_info_attrs1 = info.attrs) === null || _info_attrs1 === void 0 ? void 0 : _info_attrs1["name"], ":custom__");
|
|
1069
|
+
var entryExports = globalThis[remoteEntryKey] = scriptContext;
|
|
1070
|
+
resolve(entryExports);
|
|
1071
|
+
}
|
|
1072
|
+
}, info.attrs, info.createScriptHook);
|
|
1073
|
+
});
|
|
1074
|
+
}
|
|
1075
|
+
|
|
1076
|
+
export { BROWSER_LOG_KEY, BROWSER_LOG_VALUE, EncodedNameTransformMap, FederationModuleManifest, Logger, MANIFEST_EXT, NameTransformMap, NameTransformSymbol, SEPARATOR, assert, composeKeyWithSeparator, createScript, createScriptNode, decodeName, encodeName, error, generateExposeFilename, generateShareFilename, generateSnapshotFromManifest, getProcessEnv, getResourceUrl, isBrowserEnv, isDebugMode, isManifestProvider, isStaticResourcesEqual, loadScript, loadScriptNode, logger, parseEntry, safeWrapper, simpleJoinRemoteEntry, warn };
|
|
@@ -9,6 +9,9 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
9
9
|
var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
|
|
10
10
|
|
|
11
11
|
function getWebpackPath(compiler) {
|
|
12
|
+
var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {
|
|
13
|
+
framework: "other"
|
|
14
|
+
};
|
|
12
15
|
try {
|
|
13
16
|
// @ts-ignore just throw err
|
|
14
17
|
compiler.webpack();
|
|
@@ -21,6 +24,12 @@ function getWebpackPath(compiler) {
|
|
|
21
24
|
}) || "";
|
|
22
25
|
var webpackLocationWithDetail = webpackErrLocation.replace(/[^\(\)]+/, "").slice(1, -1);
|
|
23
26
|
var webpackPath = webpackLocationWithDetail.split(":").slice(0, -2)[0];
|
|
27
|
+
if ((options === null || options === void 0 ? void 0 : options.framework) === "nextjs") {
|
|
28
|
+
if (webpackPath.endsWith("webpack.js")) {
|
|
29
|
+
return webpackPath.replace("webpack.js", "index.js");
|
|
30
|
+
}
|
|
31
|
+
return "";
|
|
32
|
+
}
|
|
24
33
|
return require.resolve("webpack", {
|
|
25
34
|
paths: [
|
|
26
35
|
webpackPath
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
2
|
|
|
3
3
|
function getWebpackPath(compiler) {
|
|
4
|
+
var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {
|
|
5
|
+
framework: "other"
|
|
6
|
+
};
|
|
4
7
|
try {
|
|
5
8
|
// @ts-ignore just throw err
|
|
6
9
|
compiler.webpack();
|
|
@@ -13,6 +16,12 @@ function getWebpackPath(compiler) {
|
|
|
13
16
|
}) || "";
|
|
14
17
|
var webpackLocationWithDetail = webpackErrLocation.replace(/[^\(\)]+/, "").slice(1, -1);
|
|
15
18
|
var webpackPath = webpackLocationWithDetail.split(":").slice(0, -2)[0];
|
|
19
|
+
if ((options === null || options === void 0 ? void 0 : options.framework) === "nextjs") {
|
|
20
|
+
if (webpackPath.endsWith("webpack.js")) {
|
|
21
|
+
return webpackPath.replace("webpack.js", "index.js");
|
|
22
|
+
}
|
|
23
|
+
return "";
|
|
24
|
+
}
|
|
16
25
|
return require.resolve("webpack", {
|
|
17
26
|
paths: [
|
|
18
27
|
webpackPath
|
package/dist/package.json
CHANGED
package/dist/src/index.d.ts
CHANGED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare function createScriptNode(url: string, cb: (error?: Error, scriptContext?: any) => void, attrs?: Record<string, any>, createScriptHook?: (url: string) => any | void): void;
|
|
2
|
+
export declare function loadScriptNode(url: string, info: {
|
|
3
|
+
attrs?: Record<string, any>;
|
|
4
|
+
createScriptHook?: (url: string) => void;
|
|
5
|
+
}): Promise<void>;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import type webpack from 'webpack';
|
|
2
|
-
export declare function getWebpackPath(compiler: webpack.Compiler
|
|
2
|
+
export declare function getWebpackPath(compiler: webpack.Compiler, options?: {
|
|
3
|
+
framework: 'nextjs' | 'other';
|
|
4
|
+
}): string;
|
|
3
5
|
export declare const normalizeWebpackPath: (fullPath: string) => string;
|