@fluxo-dev/shell-mfe 25.1.3 → 25.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/index.esm.js +1594 -1321
- package/package.json +4 -4
package/index.esm.js
CHANGED
|
@@ -156,7 +156,7 @@ var isCallable$d = typeof documentAll == 'undefined' && documentAll !== undefine
|
|
|
156
156
|
|
|
157
157
|
var isCallable$c = isCallable$d;
|
|
158
158
|
|
|
159
|
-
var isObject$
|
|
159
|
+
var isObject$4 = function (it) {
|
|
160
160
|
return typeof it == 'object' ? it !== null : isCallable$c(it);
|
|
161
161
|
};
|
|
162
162
|
|
|
@@ -278,7 +278,7 @@ var getMethod$2 = function (V, P) {
|
|
|
278
278
|
|
|
279
279
|
var call$7 = functionCall;
|
|
280
280
|
var isCallable$8 = isCallable$d;
|
|
281
|
-
var isObject$
|
|
281
|
+
var isObject$3 = isObject$4;
|
|
282
282
|
|
|
283
283
|
var $TypeError$4 = TypeError;
|
|
284
284
|
|
|
@@ -286,9 +286,9 @@ var $TypeError$4 = TypeError;
|
|
|
286
286
|
// https://tc39.es/ecma262/#sec-ordinarytoprimitive
|
|
287
287
|
var ordinaryToPrimitive$1 = function (input, pref) {
|
|
288
288
|
var fn, val;
|
|
289
|
-
if (pref === 'string' && isCallable$8(fn = input.toString) && !isObject$
|
|
290
|
-
if (isCallable$8(fn = input.valueOf) && !isObject$
|
|
291
|
-
if (pref !== 'string' && isCallable$8(fn = input.toString) && !isObject$
|
|
289
|
+
if (pref === 'string' && isCallable$8(fn = input.toString) && !isObject$3(val = call$7(fn, input))) return val;
|
|
290
|
+
if (isCallable$8(fn = input.valueOf) && !isObject$3(val = call$7(fn, input))) return val;
|
|
291
|
+
if (pref !== 'string' && isCallable$8(fn = input.toString) && !isObject$3(val = call$7(fn, input))) return val;
|
|
292
292
|
throw new $TypeError$4("Can't convert object to primitive value");
|
|
293
293
|
};
|
|
294
294
|
|
|
@@ -381,7 +381,7 @@ var wellKnownSymbol$5 = function (name) {
|
|
|
381
381
|
};
|
|
382
382
|
|
|
383
383
|
var call$6 = functionCall;
|
|
384
|
-
var isObject$
|
|
384
|
+
var isObject$2 = isObject$4;
|
|
385
385
|
var isSymbol$1 = isSymbol$2;
|
|
386
386
|
var getMethod$1 = getMethod$2;
|
|
387
387
|
var ordinaryToPrimitive = ordinaryToPrimitive$1;
|
|
@@ -393,13 +393,13 @@ var TO_PRIMITIVE = wellKnownSymbol$4('toPrimitive');
|
|
|
393
393
|
// `ToPrimitive` abstract operation
|
|
394
394
|
// https://tc39.es/ecma262/#sec-toprimitive
|
|
395
395
|
var toPrimitive$1 = function (input, pref) {
|
|
396
|
-
if (!isObject$
|
|
396
|
+
if (!isObject$2(input) || isSymbol$1(input)) return input;
|
|
397
397
|
var exoticToPrim = getMethod$1(input, TO_PRIMITIVE);
|
|
398
398
|
var result;
|
|
399
399
|
if (exoticToPrim) {
|
|
400
400
|
if (pref === undefined) pref = 'default';
|
|
401
401
|
result = call$6(exoticToPrim, input, pref);
|
|
402
|
-
if (!isObject$
|
|
402
|
+
if (!isObject$2(result) || isSymbol$1(result)) return result;
|
|
403
403
|
throw new $TypeError$3("Can't convert object to primitive value");
|
|
404
404
|
}
|
|
405
405
|
if (pref === undefined) pref = 'number';
|
|
@@ -417,11 +417,11 @@ var toPropertyKey$2 = function (argument) {
|
|
|
417
417
|
};
|
|
418
418
|
|
|
419
419
|
var global$7 = global$d;
|
|
420
|
-
var isObject$
|
|
420
|
+
var isObject$1 = isObject$4;
|
|
421
421
|
|
|
422
422
|
var document$1 = global$7.document;
|
|
423
423
|
// typeof document.createElement is 'object' in old IE
|
|
424
|
-
var EXISTS$1 = isObject$
|
|
424
|
+
var EXISTS$1 = isObject$1(document$1) && isObject$1(document$1.createElement);
|
|
425
425
|
|
|
426
426
|
var documentCreateElement$1 = function (it) {
|
|
427
427
|
return EXISTS$1 ? document$1.createElement(it) : {};
|
|
@@ -477,14 +477,14 @@ var v8PrototypeDefineBug = DESCRIPTORS$5 && fails$7(function () {
|
|
|
477
477
|
}).prototype !== 42;
|
|
478
478
|
});
|
|
479
479
|
|
|
480
|
-
var isObject
|
|
480
|
+
var isObject = isObject$4;
|
|
481
481
|
|
|
482
482
|
var $String$2 = String;
|
|
483
483
|
var $TypeError$2 = TypeError;
|
|
484
484
|
|
|
485
485
|
// `Assert: Type(argument) is Object`
|
|
486
486
|
var anObject$7 = function (argument) {
|
|
487
|
-
if (isObject
|
|
487
|
+
if (isObject(argument)) return argument;
|
|
488
488
|
throw new $TypeError$2($String$2(argument) + ' is not an object');
|
|
489
489
|
};
|
|
490
490
|
|
|
@@ -553,13 +553,9 @@ var FunctionPrototype$1 = Function.prototype;
|
|
|
553
553
|
var getDescriptor = DESCRIPTORS$2 && Object.getOwnPropertyDescriptor;
|
|
554
554
|
|
|
555
555
|
var EXISTS = hasOwn$4(FunctionPrototype$1, 'name');
|
|
556
|
-
// additional protection from minified / mangled / dropped function names
|
|
557
|
-
var PROPER = EXISTS && (function something() { /* empty */ }).name === 'something';
|
|
558
556
|
var CONFIGURABLE = EXISTS && (!DESCRIPTORS$2 || (DESCRIPTORS$2 && getDescriptor(FunctionPrototype$1, 'name').configurable));
|
|
559
557
|
|
|
560
558
|
var functionName = {
|
|
561
|
-
EXISTS: EXISTS,
|
|
562
|
-
PROPER: PROPER,
|
|
563
559
|
CONFIGURABLE: CONFIGURABLE
|
|
564
560
|
};
|
|
565
561
|
|
|
@@ -598,7 +594,6 @@ var hiddenKeys$4 = {};
|
|
|
598
594
|
|
|
599
595
|
var NATIVE_WEAK_MAP = weakMapBasicDetection;
|
|
600
596
|
var global$5 = global$d;
|
|
601
|
-
var isObject$1 = isObject$6;
|
|
602
597
|
var createNonEnumerableProperty$2 = createNonEnumerableProperty$3;
|
|
603
598
|
var hasOwn$3 = hasOwnProperty_1;
|
|
604
599
|
var shared$1 = sharedStoreExports;
|
|
@@ -614,15 +609,6 @@ var enforce = function (it) {
|
|
|
614
609
|
return has(it) ? get(it) : set(it, {});
|
|
615
610
|
};
|
|
616
611
|
|
|
617
|
-
var getterFor = function (TYPE) {
|
|
618
|
-
return function (it) {
|
|
619
|
-
var state;
|
|
620
|
-
if (!isObject$1(it) || (state = get(it)).type !== TYPE) {
|
|
621
|
-
throw new TypeError$1('Incompatible receiver, ' + TYPE + ' required');
|
|
622
|
-
} return state;
|
|
623
|
-
};
|
|
624
|
-
};
|
|
625
|
-
|
|
626
612
|
if (NATIVE_WEAK_MAP || shared$1.state) {
|
|
627
613
|
var store = shared$1.state || (shared$1.state = new WeakMap());
|
|
628
614
|
/* eslint-disable no-self-assign -- prototype methods protection */
|
|
@@ -660,12 +646,8 @@ if (NATIVE_WEAK_MAP || shared$1.state) {
|
|
|
660
646
|
}
|
|
661
647
|
|
|
662
648
|
var internalState = {
|
|
663
|
-
set: set,
|
|
664
649
|
get: get,
|
|
665
|
-
|
|
666
|
-
enforce: enforce,
|
|
667
|
-
getterFor: getterFor
|
|
668
|
-
};
|
|
650
|
+
enforce: enforce};
|
|
669
651
|
|
|
670
652
|
var uncurryThis$6 = functionUncurryThis;
|
|
671
653
|
var fails$6 = fails$d;
|
|
@@ -833,9 +815,6 @@ var createMethod$1 = function (IS_INCLUDES) {
|
|
|
833
815
|
};
|
|
834
816
|
|
|
835
817
|
var arrayIncludes = {
|
|
836
|
-
// `Array.prototype.includes` method
|
|
837
|
-
// https://tc39.es/ecma262/#sec-array.prototype.includes
|
|
838
|
-
includes: createMethod$1(true),
|
|
839
818
|
// `Array.prototype.indexOf` method
|
|
840
819
|
// https://tc39.es/ecma262/#sec-array.prototype.indexof
|
|
841
820
|
indexOf: createMethod$1(false)
|
|
@@ -1080,7 +1059,7 @@ var UNSUPPORTED_Y$1 = fails$4(function () {
|
|
|
1080
1059
|
|
|
1081
1060
|
// UC Browser bug
|
|
1082
1061
|
// https://github.com/zloirock/core-js/issues/1008
|
|
1083
|
-
|
|
1062
|
+
UNSUPPORTED_Y$1 || fails$4(function () {
|
|
1084
1063
|
return !$RegExp$2('a', 'y').sticky;
|
|
1085
1064
|
});
|
|
1086
1065
|
|
|
@@ -1092,10 +1071,7 @@ var BROKEN_CARET = UNSUPPORTED_Y$1 || fails$4(function () {
|
|
|
1092
1071
|
});
|
|
1093
1072
|
|
|
1094
1073
|
var regexpStickyHelpers = {
|
|
1095
|
-
BROKEN_CARET: BROKEN_CARET
|
|
1096
|
-
MISSED_STICKY: MISSED_STICKY,
|
|
1097
|
-
UNSUPPORTED_Y: UNSUPPORTED_Y$1
|
|
1098
|
-
};
|
|
1074
|
+
BROKEN_CARET: BROKEN_CARET};
|
|
1099
1075
|
|
|
1100
1076
|
var objectDefineProperties = {};
|
|
1101
1077
|
|
|
@@ -1483,9 +1459,6 @@ var createMethod = function (CONVERT_TO_STRING) {
|
|
|
1483
1459
|
};
|
|
1484
1460
|
|
|
1485
1461
|
var stringMultibyte = {
|
|
1486
|
-
// `String.prototype.codePointAt` method
|
|
1487
|
-
// https://tc39.es/ecma262/#sec-string.prototype.codepointat
|
|
1488
|
-
codeAt: createMethod(false),
|
|
1489
1462
|
// `String.prototype.at` method
|
|
1490
1463
|
// https://github.com/mathiasbynens/String.prototype.at
|
|
1491
1464
|
charAt: createMethod(true)
|
|
@@ -1712,19 +1685,21 @@ var runtime = {};
|
|
|
1712
1685
|
|
|
1713
1686
|
var runtime_cjs = {};
|
|
1714
1687
|
|
|
1715
|
-
var index_cjs$
|
|
1688
|
+
var index_cjs$3 = {};
|
|
1689
|
+
|
|
1690
|
+
var index_cjs$2 = {};
|
|
1716
1691
|
|
|
1717
1692
|
var polyfills_cjs$1 = {};
|
|
1718
1693
|
|
|
1719
|
-
function _extends$
|
|
1720
|
-
_extends$
|
|
1694
|
+
function _extends$2() {
|
|
1695
|
+
_extends$2 = Object.assign || function assign(target) {
|
|
1721
1696
|
for(var i = 1; i < arguments.length; i++){
|
|
1722
1697
|
var source = arguments[i];
|
|
1723
1698
|
for(var key in source)if (Object.prototype.hasOwnProperty.call(source, key)) target[key] = source[key];
|
|
1724
1699
|
}
|
|
1725
1700
|
return target;
|
|
1726
1701
|
};
|
|
1727
|
-
return _extends$
|
|
1702
|
+
return _extends$2.apply(this, arguments);
|
|
1728
1703
|
}
|
|
1729
1704
|
|
|
1730
1705
|
function _object_without_properties_loose(source, excluded) {
|
|
@@ -1740,29 +1715,27 @@ function _object_without_properties_loose(source, excluded) {
|
|
|
1740
1715
|
return target;
|
|
1741
1716
|
}
|
|
1742
1717
|
|
|
1743
|
-
polyfills_cjs$1._extends = _extends$
|
|
1718
|
+
polyfills_cjs$1._extends = _extends$2;
|
|
1744
1719
|
polyfills_cjs$1._object_without_properties_loose = _object_without_properties_loose;
|
|
1745
1720
|
|
|
1746
|
-
var index_cjs = {};
|
|
1721
|
+
var index_cjs$1 = {};
|
|
1747
1722
|
|
|
1748
1723
|
var polyfills_cjs = {};
|
|
1749
1724
|
|
|
1750
|
-
function _extends() {
|
|
1751
|
-
_extends = Object.assign || function assign(target) {
|
|
1725
|
+
function _extends$1() {
|
|
1726
|
+
_extends$1 = Object.assign || function assign(target) {
|
|
1752
1727
|
for(var i = 1; i < arguments.length; i++){
|
|
1753
1728
|
var source = arguments[i];
|
|
1754
1729
|
for(var key in source)if (Object.prototype.hasOwnProperty.call(source, key)) target[key] = source[key];
|
|
1755
1730
|
}
|
|
1756
1731
|
return target;
|
|
1757
1732
|
};
|
|
1758
|
-
return _extends.apply(this, arguments);
|
|
1733
|
+
return _extends$1.apply(this, arguments);
|
|
1759
1734
|
}
|
|
1760
1735
|
|
|
1761
|
-
polyfills_cjs._extends = _extends;
|
|
1762
|
-
|
|
1763
|
-
Object.defineProperty(index_cjs, '__esModule', { value: true });
|
|
1736
|
+
polyfills_cjs._extends = _extends$1;
|
|
1764
1737
|
|
|
1765
|
-
var polyfills
|
|
1738
|
+
var polyfills = polyfills_cjs;
|
|
1766
1739
|
|
|
1767
1740
|
const FederationModuleManifest = 'federation-manifest.json';
|
|
1768
1741
|
const MANIFEST_EXT = '.json';
|
|
@@ -1820,61 +1793,30 @@ var SharePlugin = /*#__PURE__*/Object.freeze({
|
|
|
1820
1793
|
function isBrowserEnv() {
|
|
1821
1794
|
return typeof window !== 'undefined';
|
|
1822
1795
|
}
|
|
1823
|
-
function
|
|
1824
|
-
if (typeof process !== 'undefined' && process.env && process.env['FEDERATION_DEBUG']) {
|
|
1825
|
-
return Boolean(process.env['FEDERATION_DEBUG']);
|
|
1826
|
-
}
|
|
1827
|
-
return typeof FEDERATION_DEBUG !== 'undefined' && Boolean(FEDERATION_DEBUG);
|
|
1828
|
-
}
|
|
1829
|
-
const getProcessEnv = function() {
|
|
1830
|
-
return typeof process !== 'undefined' && process.env ? process.env : {};
|
|
1831
|
-
};
|
|
1832
|
-
|
|
1833
|
-
const DEBUG_LOG = '[ FEDERATION DEBUG ]';
|
|
1834
|
-
function safeGetLocalStorageItem() {
|
|
1796
|
+
function isBrowserDebug() {
|
|
1835
1797
|
try {
|
|
1836
|
-
if (
|
|
1798
|
+
if (isBrowserEnv() && window.localStorage) {
|
|
1837
1799
|
return localStorage.getItem(BROWSER_LOG_KEY) === BROWSER_LOG_VALUE;
|
|
1838
1800
|
}
|
|
1839
1801
|
} catch (error) {
|
|
1840
|
-
return
|
|
1802
|
+
return false;
|
|
1841
1803
|
}
|
|
1842
1804
|
return false;
|
|
1843
1805
|
}
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
const argsToString = safeToString(info) || '';
|
|
1848
|
-
if (isBrowserEnv()) {
|
|
1849
|
-
console.info(`%c ${this.identifier}: ${msg} ${argsToString}`, 'color:#3300CC');
|
|
1850
|
-
} else {
|
|
1851
|
-
console.info('\x1b[34m%s', `${this.identifier}: ${msg} ${argsToString ? `\n${argsToString}` : ''}`);
|
|
1852
|
-
}
|
|
1853
|
-
}
|
|
1854
|
-
}
|
|
1855
|
-
logOriginalInfo(...args) {
|
|
1856
|
-
if (this.enable) {
|
|
1857
|
-
if (isBrowserEnv()) {
|
|
1858
|
-
console.info(`%c ${this.identifier}: OriginalInfo`, 'color:#3300CC');
|
|
1859
|
-
console.log(...args);
|
|
1860
|
-
} else {
|
|
1861
|
-
console.info(`%c ${this.identifier}: OriginalInfo`, 'color:#3300CC');
|
|
1862
|
-
console.log(...args);
|
|
1863
|
-
}
|
|
1864
|
-
}
|
|
1806
|
+
function isDebugMode() {
|
|
1807
|
+
if (typeof process !== 'undefined' && process.env && process.env['FEDERATION_DEBUG']) {
|
|
1808
|
+
return Boolean(process.env['FEDERATION_DEBUG']);
|
|
1865
1809
|
}
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
this.identifier = identifier || DEBUG_LOG;
|
|
1869
|
-
if (isBrowserEnv() && safeGetLocalStorageItem()) {
|
|
1870
|
-
this.enable = true;
|
|
1871
|
-
} else if (isDebugMode()) {
|
|
1872
|
-
this.enable = true;
|
|
1873
|
-
}
|
|
1810
|
+
if (typeof FEDERATION_DEBUG !== 'undefined' && Boolean(FEDERATION_DEBUG)) {
|
|
1811
|
+
return true;
|
|
1874
1812
|
}
|
|
1813
|
+
return isBrowserDebug();
|
|
1814
|
+
}
|
|
1815
|
+
const getProcessEnv = function() {
|
|
1816
|
+
return typeof process !== 'undefined' && process.env ? process.env : {};
|
|
1875
1817
|
};
|
|
1876
1818
|
|
|
1877
|
-
const LOG_CATEGORY
|
|
1819
|
+
const LOG_CATEGORY = '[ Federation Runtime ]';
|
|
1878
1820
|
// entry: name:version version : 1.0.0 | ^1.2.3
|
|
1879
1821
|
// entry: name:entry entry: https://localhost:9000/federation-manifest.json
|
|
1880
1822
|
const parseEntry = (str, devVerOrUrl, separator = SEPARATOR)=>{
|
|
@@ -1885,11 +1827,12 @@ const parseEntry = (str, devVerOrUrl, separator = SEPARATOR)=>{
|
|
|
1885
1827
|
// Check if the string starts with a type
|
|
1886
1828
|
if (strSplit.length >= 2) {
|
|
1887
1829
|
let [name, ...versionOrEntryArr] = strSplit;
|
|
1830
|
+
// @name@manifest-url.json
|
|
1888
1831
|
if (str.startsWith(separator)) {
|
|
1832
|
+
name = strSplit.slice(0, 2).join(separator);
|
|
1889
1833
|
versionOrEntryArr = [
|
|
1890
|
-
devVersionOrUrl || strSplit.slice(
|
|
1834
|
+
devVersionOrUrl || strSplit.slice(2).join(separator)
|
|
1891
1835
|
];
|
|
1892
|
-
name = strSplit.slice(0, -1).join(separator);
|
|
1893
1836
|
}
|
|
1894
1837
|
let versionOrEntry = devVersionOrUrl || versionOrEntryArr.join(separator);
|
|
1895
1838
|
if (isEntry(versionOrEntry)) {
|
|
@@ -1921,8 +1864,7 @@ const parseEntry = (str, devVerOrUrl, separator = SEPARATOR)=>{
|
|
|
1921
1864
|
throw `Invalid entry value: ${str}`;
|
|
1922
1865
|
}
|
|
1923
1866
|
};
|
|
1924
|
-
const
|
|
1925
|
-
const composeKeyWithSeparator = function(...args) {
|
|
1867
|
+
const composeKeyWithSeparator = function(...args) {
|
|
1926
1868
|
if (!args.length) {
|
|
1927
1869
|
return '';
|
|
1928
1870
|
}
|
|
@@ -1936,7 +1878,7 @@ const composeKeyWithSeparator = function(...args) {
|
|
|
1936
1878
|
return `${sum}${SEPARATOR}${cur}`;
|
|
1937
1879
|
}, '');
|
|
1938
1880
|
};
|
|
1939
|
-
const encodeName =
|
|
1881
|
+
const encodeName = function(name, prefix = '', withExt = false) {
|
|
1940
1882
|
try {
|
|
1941
1883
|
const ext = withExt ? '.js' : '';
|
|
1942
1884
|
return `${prefix}${name.replace(new RegExp(`${NameTransformSymbol.AT}`, 'g'), NameTransformMap[NameTransformSymbol.AT]).replace(new RegExp(`${NameTransformSymbol.HYPHEN}`, 'g'), NameTransformMap[NameTransformSymbol.HYPHEN]).replace(new RegExp(`${NameTransformSymbol.SLASH}`, 'g'), NameTransformMap[NameTransformSymbol.SLASH])}${ext}`;
|
|
@@ -1944,7 +1886,7 @@ const encodeName = function(name, prefix = '', withExt = false) {
|
|
|
1944
1886
|
throw err;
|
|
1945
1887
|
}
|
|
1946
1888
|
};
|
|
1947
|
-
const decodeName =
|
|
1889
|
+
const decodeName = function(name, prefix, withExt) {
|
|
1948
1890
|
try {
|
|
1949
1891
|
let decodedName = name;
|
|
1950
1892
|
if (prefix) {
|
|
@@ -1962,7 +1904,7 @@ const decodeName = function(name, prefix, withExt) {
|
|
|
1962
1904
|
throw err;
|
|
1963
1905
|
}
|
|
1964
1906
|
};
|
|
1965
|
-
const generateExposeFilename =
|
|
1907
|
+
const generateExposeFilename = (exposeName, withExt)=>{
|
|
1966
1908
|
if (!exposeName) {
|
|
1967
1909
|
return '';
|
|
1968
1910
|
}
|
|
@@ -1975,7 +1917,7 @@ const generateExposeFilename = (exposeName, withExt)=>{
|
|
|
1975
1917
|
}
|
|
1976
1918
|
return encodeName(expose, '__federation_expose_', withExt);
|
|
1977
1919
|
};
|
|
1978
|
-
const generateShareFilename =
|
|
1920
|
+
const generateShareFilename = (pkgName, withExt)=>{
|
|
1979
1921
|
if (!pkgName) {
|
|
1980
1922
|
return '';
|
|
1981
1923
|
}
|
|
@@ -1998,16 +1940,16 @@ const getResourceUrl = (module, sourceUrl)=>{
|
|
|
1998
1940
|
}
|
|
1999
1941
|
};
|
|
2000
1942
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
2001
|
-
const assert
|
|
1943
|
+
const assert = (condition, msg)=>{
|
|
2002
1944
|
if (!condition) {
|
|
2003
|
-
error
|
|
1945
|
+
error(msg);
|
|
2004
1946
|
}
|
|
2005
1947
|
};
|
|
2006
|
-
const error
|
|
2007
|
-
throw new Error(`${LOG_CATEGORY
|
|
1948
|
+
const error = (msg)=>{
|
|
1949
|
+
throw new Error(`${LOG_CATEGORY}: ${msg}`);
|
|
2008
1950
|
};
|
|
2009
|
-
const warn
|
|
2010
|
-
console.warn(`${LOG_CATEGORY
|
|
1951
|
+
const warn = (msg)=>{
|
|
1952
|
+
console.warn(`${LOG_CATEGORY}: ${msg}`);
|
|
2011
1953
|
};
|
|
2012
1954
|
function safeToString(info) {
|
|
2013
1955
|
try {
|
|
@@ -2016,6 +1958,11 @@ function safeToString(info) {
|
|
|
2016
1958
|
return '';
|
|
2017
1959
|
}
|
|
2018
1960
|
}
|
|
1961
|
+
// RegExp for version string
|
|
1962
|
+
const VERSION_PATTERN_REGEXP = /^([\d^=v<>~]|[*xX]$)/;
|
|
1963
|
+
function isRequiredVersion(str) {
|
|
1964
|
+
return VERSION_PATTERN_REGEXP.test(str);
|
|
1965
|
+
}
|
|
2019
1966
|
|
|
2020
1967
|
const simpleJoinRemoteEntry = (rPath, rName)=>{
|
|
2021
1968
|
if (!rPath) {
|
|
@@ -2120,30 +2067,30 @@ function generateSnapshotFromManifest(manifest, options = {}) {
|
|
|
2120
2067
|
};
|
|
2121
2068
|
if ((_manifest_metaData = manifest.metaData) == null ? void 0 : _manifest_metaData.prefetchInterface) {
|
|
2122
2069
|
const prefetchInterface = manifest.metaData.prefetchInterface;
|
|
2123
|
-
basicRemoteSnapshot = polyfills
|
|
2070
|
+
basicRemoteSnapshot = polyfills._extends({}, basicRemoteSnapshot, {
|
|
2124
2071
|
prefetchInterface
|
|
2125
2072
|
});
|
|
2126
2073
|
}
|
|
2127
2074
|
if ((_manifest_metaData1 = manifest.metaData) == null ? void 0 : _manifest_metaData1.prefetchEntry) {
|
|
2128
2075
|
const { path, name, type } = manifest.metaData.prefetchEntry;
|
|
2129
|
-
basicRemoteSnapshot = polyfills
|
|
2076
|
+
basicRemoteSnapshot = polyfills._extends({}, basicRemoteSnapshot, {
|
|
2130
2077
|
prefetchEntry: simpleJoinRemoteEntry(path, name),
|
|
2131
2078
|
prefetchEntryType: type
|
|
2132
2079
|
});
|
|
2133
2080
|
}
|
|
2134
2081
|
if ('publicPath' in manifest.metaData) {
|
|
2135
|
-
remoteSnapshot = polyfills
|
|
2082
|
+
remoteSnapshot = polyfills._extends({}, basicRemoteSnapshot, {
|
|
2136
2083
|
publicPath: getPublicPath()
|
|
2137
2084
|
});
|
|
2138
2085
|
} else {
|
|
2139
|
-
remoteSnapshot = polyfills
|
|
2086
|
+
remoteSnapshot = polyfills._extends({}, basicRemoteSnapshot, {
|
|
2140
2087
|
getPublicPath: getPublicPath()
|
|
2141
2088
|
});
|
|
2142
2089
|
}
|
|
2143
2090
|
if (ssrRemoteEntry) {
|
|
2144
2091
|
const fullSSRRemoteEntry = simpleJoinRemoteEntry(ssrRemoteEntry.path, ssrRemoteEntry.name);
|
|
2145
2092
|
remoteSnapshot.ssrRemoteEntry = fullSSRRemoteEntry;
|
|
2146
|
-
remoteSnapshot.ssrRemoteEntryType = 'commonjs-module';
|
|
2093
|
+
remoteSnapshot.ssrRemoteEntryType = ssrRemoteEntry.type || 'commonjs-module';
|
|
2147
2094
|
}
|
|
2148
2095
|
return remoteSnapshot;
|
|
2149
2096
|
}
|
|
@@ -2155,13 +2102,47 @@ function isManifestProvider(moduleInfo) {
|
|
|
2155
2102
|
}
|
|
2156
2103
|
}
|
|
2157
2104
|
|
|
2105
|
+
const PREFIX = '[ Module Federation ]';
|
|
2106
|
+
let Logger = class Logger {
|
|
2107
|
+
log(...args) {
|
|
2108
|
+
console.log(this.prefix, ...args);
|
|
2109
|
+
}
|
|
2110
|
+
warn(...args) {
|
|
2111
|
+
console.log(this.prefix, ...args);
|
|
2112
|
+
}
|
|
2113
|
+
error(...args) {
|
|
2114
|
+
console.log(this.prefix, ...args);
|
|
2115
|
+
}
|
|
2116
|
+
success(...args) {
|
|
2117
|
+
console.log(this.prefix, ...args);
|
|
2118
|
+
}
|
|
2119
|
+
info(...args) {
|
|
2120
|
+
console.log(this.prefix, ...args);
|
|
2121
|
+
}
|
|
2122
|
+
ready(...args) {
|
|
2123
|
+
console.log(this.prefix, ...args);
|
|
2124
|
+
}
|
|
2125
|
+
debug(...args) {
|
|
2126
|
+
if (isDebugMode()) {
|
|
2127
|
+
console.log(this.prefix, ...args);
|
|
2128
|
+
}
|
|
2129
|
+
}
|
|
2130
|
+
constructor(prefix){
|
|
2131
|
+
this.prefix = prefix;
|
|
2132
|
+
}
|
|
2133
|
+
};
|
|
2134
|
+
function createLogger(prefix) {
|
|
2135
|
+
return new Logger(prefix);
|
|
2136
|
+
}
|
|
2137
|
+
const logger = createLogger(PREFIX);
|
|
2138
|
+
|
|
2158
2139
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2159
2140
|
async function safeWrapper(callback, disableWarn) {
|
|
2160
2141
|
try {
|
|
2161
2142
|
const res = await callback();
|
|
2162
2143
|
return res;
|
|
2163
2144
|
} catch (e) {
|
|
2164
|
-
!disableWarn && warn
|
|
2145
|
+
!disableWarn && warn(e);
|
|
2165
2146
|
return;
|
|
2166
2147
|
}
|
|
2167
2148
|
}
|
|
@@ -2190,9 +2171,9 @@ function createScript(info) {
|
|
|
2190
2171
|
}
|
|
2191
2172
|
}
|
|
2192
2173
|
if (!script) {
|
|
2174
|
+
const attrs = info.attrs;
|
|
2193
2175
|
script = document.createElement('script');
|
|
2194
|
-
script.type = 'text/javascript';
|
|
2195
|
-
script.src = info.url;
|
|
2176
|
+
script.type = (attrs == null ? void 0 : attrs['type']) === 'module' ? 'module' : 'text/javascript';
|
|
2196
2177
|
let createScriptRes = undefined;
|
|
2197
2178
|
if (info.createScriptHook) {
|
|
2198
2179
|
createScriptRes = info.createScriptHook(info.url, info.attrs);
|
|
@@ -2207,7 +2188,9 @@ function createScript(info) {
|
|
|
2207
2188
|
}
|
|
2208
2189
|
}
|
|
2209
2190
|
}
|
|
2210
|
-
|
|
2191
|
+
if (!script.src) {
|
|
2192
|
+
script.src = info.url;
|
|
2193
|
+
}
|
|
2211
2194
|
if (attrs && !createScriptRes) {
|
|
2212
2195
|
Object.keys(attrs).forEach((name)=>{
|
|
2213
2196
|
if (script) {
|
|
@@ -2223,8 +2206,14 @@ function createScript(info) {
|
|
|
2223
2206
|
}
|
|
2224
2207
|
const onScriptComplete = async (prev, // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2225
2208
|
event)=>{
|
|
2226
|
-
var _info_cb;
|
|
2227
2209
|
clearTimeout(timeoutId);
|
|
2210
|
+
const onScriptCompleteCallback = ()=>{
|
|
2211
|
+
if ((event == null ? void 0 : event.type) === 'error') {
|
|
2212
|
+
(info == null ? void 0 : info.onErrorCallback) && (info == null ? void 0 : info.onErrorCallback(event));
|
|
2213
|
+
} else {
|
|
2214
|
+
(info == null ? void 0 : info.cb) && (info == null ? void 0 : info.cb());
|
|
2215
|
+
}
|
|
2216
|
+
};
|
|
2228
2217
|
// Prevent memory leaks in IE.
|
|
2229
2218
|
if (script) {
|
|
2230
2219
|
script.onerror = null;
|
|
@@ -2236,19 +2225,17 @@ function createScript(info) {
|
|
|
2236
2225
|
}
|
|
2237
2226
|
});
|
|
2238
2227
|
if (prev && typeof prev === 'function') {
|
|
2239
|
-
var _info_cb1;
|
|
2240
2228
|
const result = prev(event);
|
|
2241
2229
|
if (result instanceof Promise) {
|
|
2242
|
-
var _info_cb2;
|
|
2243
2230
|
const res = await result;
|
|
2244
|
-
|
|
2231
|
+
onScriptCompleteCallback();
|
|
2245
2232
|
return res;
|
|
2246
2233
|
}
|
|
2247
|
-
|
|
2234
|
+
onScriptCompleteCallback();
|
|
2248
2235
|
return result;
|
|
2249
2236
|
}
|
|
2250
2237
|
}
|
|
2251
|
-
|
|
2238
|
+
onScriptCompleteCallback();
|
|
2252
2239
|
};
|
|
2253
2240
|
script.onerror = onScriptComplete.bind(null, script.onerror);
|
|
2254
2241
|
script.onload = onScriptComplete.bind(null, script.onload);
|
|
@@ -2297,6 +2284,13 @@ function createLink(info) {
|
|
|
2297
2284
|
}
|
|
2298
2285
|
const onLinkComplete = (prev, // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2299
2286
|
event)=>{
|
|
2287
|
+
const onLinkCompleteCallback = ()=>{
|
|
2288
|
+
if ((event == null ? void 0 : event.type) === 'error') {
|
|
2289
|
+
(info == null ? void 0 : info.onErrorCallback) && (info == null ? void 0 : info.onErrorCallback(event));
|
|
2290
|
+
} else {
|
|
2291
|
+
(info == null ? void 0 : info.cb) && (info == null ? void 0 : info.cb());
|
|
2292
|
+
}
|
|
2293
|
+
};
|
|
2300
2294
|
// Prevent memory leaks in IE.
|
|
2301
2295
|
if (link) {
|
|
2302
2296
|
link.onerror = null;
|
|
@@ -2310,11 +2304,11 @@ function createLink(info) {
|
|
|
2310
2304
|
if (prev) {
|
|
2311
2305
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2312
2306
|
const res = prev(event);
|
|
2313
|
-
|
|
2307
|
+
onLinkCompleteCallback();
|
|
2314
2308
|
return res;
|
|
2315
2309
|
}
|
|
2316
2310
|
}
|
|
2317
|
-
|
|
2311
|
+
onLinkCompleteCallback();
|
|
2318
2312
|
};
|
|
2319
2313
|
link.onerror = onLinkComplete.bind(null, link.onerror);
|
|
2320
2314
|
link.onload = onLinkComplete.bind(null, link.onload);
|
|
@@ -2325,11 +2319,12 @@ function createLink(info) {
|
|
|
2325
2319
|
}
|
|
2326
2320
|
function loadScript(url, info) {
|
|
2327
2321
|
const { attrs = {}, createScriptHook } = info;
|
|
2328
|
-
return new Promise((resolve,
|
|
2322
|
+
return new Promise((resolve, reject)=>{
|
|
2329
2323
|
const { script, needAttach } = createScript({
|
|
2330
2324
|
url,
|
|
2331
2325
|
cb: resolve,
|
|
2332
|
-
|
|
2326
|
+
onErrorCallback: reject,
|
|
2327
|
+
attrs: polyfills._extends({
|
|
2333
2328
|
fetchpriority: 'high'
|
|
2334
2329
|
}, attrs),
|
|
2335
2330
|
createScriptHook,
|
|
@@ -2353,11 +2348,9 @@ const loadNodeFetch = async ()=>{
|
|
|
2353
2348
|
const fetchModule = await importNodeModule('node-fetch');
|
|
2354
2349
|
return fetchModule.default || fetchModule;
|
|
2355
2350
|
};
|
|
2356
|
-
const lazyLoaderHookFetch = async (input, init)=>{
|
|
2357
|
-
// @ts-ignore
|
|
2358
|
-
const loaderHooks = __webpack_require__.federation.instance.loaderHook;
|
|
2351
|
+
const lazyLoaderHookFetch = async (input, init, loaderHook)=>{
|
|
2359
2352
|
const hook = (url, init)=>{
|
|
2360
|
-
return
|
|
2353
|
+
return loaderHook.lifecycle.fetch.emit(url, init);
|
|
2361
2354
|
};
|
|
2362
2355
|
const res = await hook(input, init || {});
|
|
2363
2356
|
if (!res || !(res instanceof Response)) {
|
|
@@ -2366,9 +2359,9 @@ const lazyLoaderHookFetch = async (input, init)=>{
|
|
|
2366
2359
|
}
|
|
2367
2360
|
return res;
|
|
2368
2361
|
};
|
|
2369
|
-
function createScriptNode(url, cb, attrs,
|
|
2370
|
-
if (createScriptHook) {
|
|
2371
|
-
const hookResult = createScriptHook(url);
|
|
2362
|
+
function createScriptNode(url, cb, attrs, loaderHook) {
|
|
2363
|
+
if (loaderHook == null ? void 0 : loaderHook.createScriptHook) {
|
|
2364
|
+
const hookResult = loaderHook.createScriptHook(url);
|
|
2372
2365
|
if (hookResult && typeof hookResult === 'object' && 'url' in hookResult) {
|
|
2373
2366
|
url = hookResult.url;
|
|
2374
2367
|
}
|
|
@@ -2382,23 +2375,15 @@ function createScriptNode(url, cb, attrs, createScriptHook) {
|
|
|
2382
2375
|
return;
|
|
2383
2376
|
}
|
|
2384
2377
|
const getFetch = async ()=>{
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
try {
|
|
2388
|
-
//@ts-ignore
|
|
2389
|
-
const loaderHooks = __webpack_require__.federation.instance.loaderHook;
|
|
2390
|
-
if (loaderHooks.lifecycle.fetch) {
|
|
2391
|
-
return lazyLoaderHookFetch;
|
|
2392
|
-
}
|
|
2393
|
-
} catch (e) {
|
|
2394
|
-
console.warn('federation.instance.loaderHook.lifecycle.fetch failed:', e);
|
|
2395
|
-
}
|
|
2378
|
+
if (loaderHook == null ? void 0 : loaderHook.fetch) {
|
|
2379
|
+
return (input, init)=>lazyLoaderHookFetch(input, init, loaderHook);
|
|
2396
2380
|
}
|
|
2397
2381
|
return typeof fetch === 'undefined' ? loadNodeFetch() : fetch;
|
|
2398
2382
|
};
|
|
2399
2383
|
const handleScriptFetch = async (f, urlObj)=>{
|
|
2400
2384
|
try {
|
|
2401
|
-
var
|
|
2385
|
+
var //@ts-ignore
|
|
2386
|
+
_vm_constants;
|
|
2402
2387
|
const res = await f(urlObj.href);
|
|
2403
2388
|
const data = await res.text();
|
|
2404
2389
|
const [path, vm] = await Promise.all([
|
|
@@ -2430,7 +2415,20 @@ function createScriptNode(url, cb, attrs, createScriptHook) {
|
|
|
2430
2415
|
cb(e instanceof Error ? e : new Error(`Script execution error: ${e}`));
|
|
2431
2416
|
}
|
|
2432
2417
|
};
|
|
2433
|
-
getFetch().then((f)=>
|
|
2418
|
+
getFetch().then(async (f)=>{
|
|
2419
|
+
if ((attrs == null ? void 0 : attrs['type']) === 'esm' || (attrs == null ? void 0 : attrs['type']) === 'module') {
|
|
2420
|
+
return loadModule(urlObj.href, {
|
|
2421
|
+
fetch: f,
|
|
2422
|
+
vm: await importNodeModule('vm')
|
|
2423
|
+
}).then(async (module)=>{
|
|
2424
|
+
await module.evaluate();
|
|
2425
|
+
cb(undefined, module.namespace);
|
|
2426
|
+
}).catch((e)=>{
|
|
2427
|
+
cb(e instanceof Error ? e : new Error(`Script execution error: ${e}`));
|
|
2428
|
+
});
|
|
2429
|
+
}
|
|
2430
|
+
handleScriptFetch(f, urlObj);
|
|
2431
|
+
}).catch((err)=>{
|
|
2434
2432
|
cb(err);
|
|
2435
2433
|
});
|
|
2436
2434
|
}
|
|
@@ -2445,9 +2443,27 @@ function loadScriptNode(url, info) {
|
|
|
2445
2443
|
const entryExports = globalThis[remoteEntryKey] = scriptContext;
|
|
2446
2444
|
resolve(entryExports);
|
|
2447
2445
|
}
|
|
2448
|
-
}, info.attrs, info.
|
|
2446
|
+
}, info.attrs, info.loaderHook);
|
|
2449
2447
|
});
|
|
2450
2448
|
}
|
|
2449
|
+
async function loadModule(url, options) {
|
|
2450
|
+
const { fetch: fetch1, vm } = options;
|
|
2451
|
+
const response = await fetch1(url);
|
|
2452
|
+
const code = await response.text();
|
|
2453
|
+
const module = new vm.SourceTextModule(code, {
|
|
2454
|
+
// @ts-ignore
|
|
2455
|
+
importModuleDynamically: async (specifier, script)=>{
|
|
2456
|
+
const resolvedUrl = new URL(specifier, url).href;
|
|
2457
|
+
return loadModule(resolvedUrl, options);
|
|
2458
|
+
}
|
|
2459
|
+
});
|
|
2460
|
+
await module.link(async (specifier)=>{
|
|
2461
|
+
const resolvedUrl = new URL(specifier, url).href;
|
|
2462
|
+
const module = await loadModule(resolvedUrl, options);
|
|
2463
|
+
return module;
|
|
2464
|
+
});
|
|
2465
|
+
return module;
|
|
2466
|
+
}
|
|
2451
2467
|
|
|
2452
2468
|
function normalizeOptions(enableDefault, defaultOptions, key) {
|
|
2453
2469
|
return function(options) {
|
|
@@ -2465,953 +2481,1062 @@ function normalizeOptions(enableDefault, defaultOptions, key) {
|
|
|
2465
2481
|
return defaultOptions;
|
|
2466
2482
|
}
|
|
2467
2483
|
if (options && typeof options === 'object') {
|
|
2468
|
-
return polyfills
|
|
2484
|
+
return polyfills._extends({}, defaultOptions, options);
|
|
2469
2485
|
}
|
|
2470
2486
|
throw new Error(`Unexpected type for \`${key}\`, expect boolean/undefined/object, got: ${typeof options}`);
|
|
2471
2487
|
};
|
|
2472
2488
|
}
|
|
2473
2489
|
|
|
2474
|
-
index_cjs.BROWSER_LOG_KEY = BROWSER_LOG_KEY;
|
|
2475
|
-
index_cjs.BROWSER_LOG_VALUE = BROWSER_LOG_VALUE;
|
|
2476
|
-
index_cjs.ENCODE_NAME_PREFIX = ENCODE_NAME_PREFIX;
|
|
2477
|
-
index_cjs.EncodedNameTransformMap = EncodedNameTransformMap;
|
|
2478
|
-
index_cjs.FederationModuleManifest = FederationModuleManifest;
|
|
2479
|
-
index_cjs.
|
|
2480
|
-
index_cjs.
|
|
2481
|
-
index_cjs.
|
|
2482
|
-
index_cjs.
|
|
2483
|
-
index_cjs.
|
|
2484
|
-
index_cjs.
|
|
2485
|
-
index_cjs.
|
|
2486
|
-
index_cjs.
|
|
2487
|
-
index_cjs.
|
|
2488
|
-
index_cjs.
|
|
2489
|
-
index_cjs.
|
|
2490
|
-
index_cjs.
|
|
2491
|
-
index_cjs.
|
|
2492
|
-
index_cjs.
|
|
2493
|
-
index_cjs.
|
|
2494
|
-
index_cjs.
|
|
2495
|
-
index_cjs.createScript = createScript;
|
|
2496
|
-
index_cjs.createScriptNode = createScriptNode;
|
|
2497
|
-
index_cjs.decodeName = decodeName;
|
|
2498
|
-
index_cjs.encodeName = encodeName;
|
|
2499
|
-
index_cjs.error = error
|
|
2500
|
-
index_cjs.generateExposeFilename = generateExposeFilename;
|
|
2501
|
-
index_cjs.generateShareFilename = generateShareFilename;
|
|
2502
|
-
index_cjs.generateSnapshotFromManifest = generateSnapshotFromManifest;
|
|
2503
|
-
index_cjs.getProcessEnv = getProcessEnv;
|
|
2504
|
-
index_cjs.getResourceUrl = getResourceUrl;
|
|
2505
|
-
index_cjs.inferAutoPublicPath = inferAutoPublicPath;
|
|
2506
|
-
index_cjs.isBrowserEnv = isBrowserEnv;
|
|
2507
|
-
index_cjs.isDebugMode = isDebugMode;
|
|
2508
|
-
index_cjs.isManifestProvider = isManifestProvider;
|
|
2509
|
-
index_cjs.
|
|
2510
|
-
index_cjs.
|
|
2511
|
-
index_cjs.
|
|
2512
|
-
index_cjs.
|
|
2513
|
-
index_cjs.
|
|
2514
|
-
index_cjs.
|
|
2515
|
-
index_cjs.
|
|
2516
|
-
index_cjs.
|
|
2517
|
-
index_cjs.
|
|
2518
|
-
index_cjs.
|
|
2519
|
-
index_cjs.
|
|
2520
|
-
index_cjs.
|
|
2521
|
-
|
|
2522
|
-
var share_cjs = {};
|
|
2523
|
-
|
|
2524
|
-
var polyfills = polyfills_cjs$1;
|
|
2525
|
-
var sdk = index_cjs;
|
|
2490
|
+
index_cjs$1.BROWSER_LOG_KEY = BROWSER_LOG_KEY;
|
|
2491
|
+
index_cjs$1.BROWSER_LOG_VALUE = BROWSER_LOG_VALUE;
|
|
2492
|
+
index_cjs$1.ENCODE_NAME_PREFIX = ENCODE_NAME_PREFIX;
|
|
2493
|
+
index_cjs$1.EncodedNameTransformMap = EncodedNameTransformMap;
|
|
2494
|
+
index_cjs$1.FederationModuleManifest = FederationModuleManifest;
|
|
2495
|
+
index_cjs$1.MANIFEST_EXT = MANIFEST_EXT;
|
|
2496
|
+
index_cjs$1.MFModuleType = MFModuleType;
|
|
2497
|
+
index_cjs$1.MFPrefetchCommon = MFPrefetchCommon;
|
|
2498
|
+
index_cjs$1.MODULE_DEVTOOL_IDENTIFIER = MODULE_DEVTOOL_IDENTIFIER;
|
|
2499
|
+
index_cjs$1.ManifestFileName = ManifestFileName;
|
|
2500
|
+
index_cjs$1.NameTransformMap = NameTransformMap;
|
|
2501
|
+
index_cjs$1.NameTransformSymbol = NameTransformSymbol;
|
|
2502
|
+
index_cjs$1.SEPARATOR = SEPARATOR;
|
|
2503
|
+
index_cjs$1.StatsFileName = StatsFileName;
|
|
2504
|
+
index_cjs$1.TEMP_DIR = TEMP_DIR;
|
|
2505
|
+
index_cjs$1.assert = assert;
|
|
2506
|
+
index_cjs$1.composeKeyWithSeparator = composeKeyWithSeparator;
|
|
2507
|
+
index_cjs$1.containerPlugin = ContainerPlugin;
|
|
2508
|
+
index_cjs$1.containerReferencePlugin = ContainerReferencePlugin;
|
|
2509
|
+
index_cjs$1.createLink = createLink;
|
|
2510
|
+
index_cjs$1.createLogger = createLogger;
|
|
2511
|
+
index_cjs$1.createScript = createScript;
|
|
2512
|
+
index_cjs$1.createScriptNode = createScriptNode;
|
|
2513
|
+
index_cjs$1.decodeName = decodeName;
|
|
2514
|
+
index_cjs$1.encodeName = encodeName;
|
|
2515
|
+
index_cjs$1.error = error;
|
|
2516
|
+
index_cjs$1.generateExposeFilename = generateExposeFilename;
|
|
2517
|
+
index_cjs$1.generateShareFilename = generateShareFilename;
|
|
2518
|
+
index_cjs$1.generateSnapshotFromManifest = generateSnapshotFromManifest;
|
|
2519
|
+
index_cjs$1.getProcessEnv = getProcessEnv;
|
|
2520
|
+
index_cjs$1.getResourceUrl = getResourceUrl;
|
|
2521
|
+
index_cjs$1.inferAutoPublicPath = inferAutoPublicPath;
|
|
2522
|
+
index_cjs$1.isBrowserEnv = isBrowserEnv;
|
|
2523
|
+
index_cjs$1.isDebugMode = isDebugMode;
|
|
2524
|
+
index_cjs$1.isManifestProvider = isManifestProvider;
|
|
2525
|
+
index_cjs$1.isRequiredVersion = isRequiredVersion;
|
|
2526
|
+
index_cjs$1.isStaticResourcesEqual = isStaticResourcesEqual;
|
|
2527
|
+
index_cjs$1.loadScript = loadScript;
|
|
2528
|
+
index_cjs$1.loadScriptNode = loadScriptNode;
|
|
2529
|
+
index_cjs$1.logger = logger;
|
|
2530
|
+
index_cjs$1.moduleFederationPlugin = ModuleFederationPlugin;
|
|
2531
|
+
index_cjs$1.normalizeOptions = normalizeOptions;
|
|
2532
|
+
index_cjs$1.parseEntry = parseEntry;
|
|
2533
|
+
index_cjs$1.safeToString = safeToString;
|
|
2534
|
+
index_cjs$1.safeWrapper = safeWrapper;
|
|
2535
|
+
index_cjs$1.sharePlugin = SharePlugin;
|
|
2536
|
+
index_cjs$1.simpleJoinRemoteEntry = simpleJoinRemoteEntry;
|
|
2537
|
+
index_cjs$1.warn = warn;
|
|
2526
2538
|
|
|
2527
|
-
|
|
2528
|
-
//@ts-ignore
|
|
2529
|
-
return typeof FEDERATION_BUILD_IDENTIFIER !== 'undefined' ? FEDERATION_BUILD_IDENTIFIER : '';
|
|
2530
|
-
}
|
|
2531
|
-
|
|
2532
|
-
const LOG_CATEGORY = '[ Federation Runtime ]';
|
|
2533
|
-
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
2534
|
-
function assert(condition, msg) {
|
|
2535
|
-
if (!condition) {
|
|
2536
|
-
error(msg);
|
|
2537
|
-
}
|
|
2538
|
-
}
|
|
2539
|
-
function error(msg) {
|
|
2540
|
-
if (msg instanceof Error) {
|
|
2541
|
-
msg.message = `${LOG_CATEGORY}: ${msg.message}`;
|
|
2542
|
-
throw msg;
|
|
2543
|
-
}
|
|
2544
|
-
throw new Error(`${LOG_CATEGORY}: ${msg}`);
|
|
2545
|
-
}
|
|
2546
|
-
function warn(msg) {
|
|
2547
|
-
if (msg instanceof Error) {
|
|
2548
|
-
msg.message = `${LOG_CATEGORY}: ${msg.message}`;
|
|
2549
|
-
console.warn(msg);
|
|
2550
|
-
} else {
|
|
2551
|
-
console.warn(`${LOG_CATEGORY}: ${msg}`);
|
|
2552
|
-
}
|
|
2553
|
-
}
|
|
2554
|
-
|
|
2555
|
-
function addUniqueItem(arr, item) {
|
|
2556
|
-
if (arr.findIndex((name)=>name === item) === -1) {
|
|
2557
|
-
arr.push(item);
|
|
2558
|
-
}
|
|
2559
|
-
return arr;
|
|
2560
|
-
}
|
|
2561
|
-
function getFMId(remoteInfo) {
|
|
2562
|
-
if ('version' in remoteInfo && remoteInfo.version) {
|
|
2563
|
-
return `${remoteInfo.name}:${remoteInfo.version}`;
|
|
2564
|
-
} else if ('entry' in remoteInfo && remoteInfo.entry) {
|
|
2565
|
-
return `${remoteInfo.name}:${remoteInfo.entry}`;
|
|
2566
|
-
} else {
|
|
2567
|
-
return `${remoteInfo.name}`;
|
|
2568
|
-
}
|
|
2569
|
-
}
|
|
2570
|
-
function isRemoteInfoWithEntry(remote) {
|
|
2571
|
-
return typeof remote.entry !== 'undefined';
|
|
2572
|
-
}
|
|
2573
|
-
function isPureRemoteEntry(remote) {
|
|
2574
|
-
return !remote.entry.includes('.json') && remote.entry.includes('.js');
|
|
2575
|
-
}
|
|
2576
|
-
function isObject(val) {
|
|
2577
|
-
return val && typeof val === 'object';
|
|
2578
|
-
}
|
|
2579
|
-
const objectToString = Object.prototype.toString;
|
|
2580
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
2581
|
-
function isPlainObject(val) {
|
|
2582
|
-
return objectToString.call(val) === '[object Object]';
|
|
2583
|
-
}
|
|
2584
|
-
function arrayOptions(options) {
|
|
2585
|
-
return Array.isArray(options) ? options : [
|
|
2586
|
-
options
|
|
2587
|
-
];
|
|
2588
|
-
}
|
|
2589
|
-
function getRemoteEntryInfoFromSnapshot(snapshot) {
|
|
2590
|
-
const defaultRemoteEntryInfo = {
|
|
2591
|
-
url: '',
|
|
2592
|
-
type: 'global',
|
|
2593
|
-
globalName: ''
|
|
2594
|
-
};
|
|
2595
|
-
if (sdk.isBrowserEnv()) {
|
|
2596
|
-
return 'remoteEntry' in snapshot ? {
|
|
2597
|
-
url: snapshot.remoteEntry,
|
|
2598
|
-
type: snapshot.remoteEntryType,
|
|
2599
|
-
globalName: snapshot.globalName
|
|
2600
|
-
} : defaultRemoteEntryInfo;
|
|
2601
|
-
}
|
|
2602
|
-
if ('ssrRemoteEntry' in snapshot) {
|
|
2603
|
-
return {
|
|
2604
|
-
url: snapshot.ssrRemoteEntry || defaultRemoteEntryInfo.url,
|
|
2605
|
-
type: snapshot.ssrRemoteEntryType || defaultRemoteEntryInfo.type,
|
|
2606
|
-
globalName: snapshot.globalName
|
|
2607
|
-
};
|
|
2608
|
-
}
|
|
2609
|
-
return defaultRemoteEntryInfo;
|
|
2610
|
-
}
|
|
2539
|
+
var index_cjs = {};
|
|
2611
2540
|
|
|
2612
|
-
const
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
const
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
}
|
|
2626
|
-
}
|
|
2627
|
-
function includeOwnProperty(target, key) {
|
|
2628
|
-
return Object.hasOwnProperty.call(target, key);
|
|
2629
|
-
}
|
|
2630
|
-
// This section is to prevent encapsulation by certain microfrontend frameworks. Due to reuse policies, sandbox escapes.
|
|
2631
|
-
// The sandbox in the microfrontend does not replicate the value of 'configurable'.
|
|
2632
|
-
// If there is no loading content on the global object, this section defines the loading object.
|
|
2633
|
-
if (!includeOwnProperty(globalThis, '__GLOBAL_LOADING_REMOTE_ENTRY__')) {
|
|
2634
|
-
definePropertyGlobalVal(globalThis, '__GLOBAL_LOADING_REMOTE_ENTRY__', {});
|
|
2635
|
-
}
|
|
2636
|
-
const globalLoading = globalThis.__GLOBAL_LOADING_REMOTE_ENTRY__;
|
|
2637
|
-
function setGlobalDefaultVal(target) {
|
|
2638
|
-
var _target___FEDERATION__, _target___FEDERATION__1, _target___FEDERATION__2, _target___FEDERATION__3, _target___FEDERATION__4, _target___FEDERATION__5;
|
|
2639
|
-
if (includeOwnProperty(target, '__VMOK__') && !includeOwnProperty(target, '__FEDERATION__')) {
|
|
2640
|
-
definePropertyGlobalVal(target, '__FEDERATION__', target.__VMOK__);
|
|
2641
|
-
}
|
|
2642
|
-
if (!includeOwnProperty(target, '__FEDERATION__')) {
|
|
2643
|
-
definePropertyGlobalVal(target, '__FEDERATION__', {
|
|
2644
|
-
__GLOBAL_PLUGIN__: [],
|
|
2645
|
-
__INSTANCES__: [],
|
|
2646
|
-
moduleInfo: {},
|
|
2647
|
-
__SHARE__: {},
|
|
2648
|
-
__MANIFEST_LOADING__: {},
|
|
2649
|
-
__PRELOADED_MAP__: new Map()
|
|
2650
|
-
});
|
|
2651
|
-
definePropertyGlobalVal(target, '__VMOK__', target.__FEDERATION__);
|
|
2652
|
-
}
|
|
2653
|
-
var ___GLOBAL_PLUGIN__;
|
|
2654
|
-
(___GLOBAL_PLUGIN__ = (_target___FEDERATION__ = target.__FEDERATION__).__GLOBAL_PLUGIN__) != null ? ___GLOBAL_PLUGIN__ : _target___FEDERATION__.__GLOBAL_PLUGIN__ = [];
|
|
2655
|
-
var ___INSTANCES__;
|
|
2656
|
-
(___INSTANCES__ = (_target___FEDERATION__1 = target.__FEDERATION__).__INSTANCES__) != null ? ___INSTANCES__ : _target___FEDERATION__1.__INSTANCES__ = [];
|
|
2657
|
-
var _moduleInfo;
|
|
2658
|
-
(_moduleInfo = (_target___FEDERATION__2 = target.__FEDERATION__).moduleInfo) != null ? _moduleInfo : _target___FEDERATION__2.moduleInfo = {};
|
|
2659
|
-
var ___SHARE__;
|
|
2660
|
-
(___SHARE__ = (_target___FEDERATION__3 = target.__FEDERATION__).__SHARE__) != null ? ___SHARE__ : _target___FEDERATION__3.__SHARE__ = {};
|
|
2661
|
-
var ___MANIFEST_LOADING__;
|
|
2662
|
-
(___MANIFEST_LOADING__ = (_target___FEDERATION__4 = target.__FEDERATION__).__MANIFEST_LOADING__) != null ? ___MANIFEST_LOADING__ : _target___FEDERATION__4.__MANIFEST_LOADING__ = {};
|
|
2663
|
-
var ___PRELOADED_MAP__;
|
|
2664
|
-
(___PRELOADED_MAP__ = (_target___FEDERATION__5 = target.__FEDERATION__).__PRELOADED_MAP__) != null ? ___PRELOADED_MAP__ : _target___FEDERATION__5.__PRELOADED_MAP__ = new Map();
|
|
2665
|
-
}
|
|
2666
|
-
setGlobalDefaultVal(globalThis);
|
|
2667
|
-
setGlobalDefaultVal(nativeGlobal);
|
|
2668
|
-
function resetFederationGlobalInfo() {
|
|
2669
|
-
globalThis.__FEDERATION__.__GLOBAL_PLUGIN__ = [];
|
|
2670
|
-
globalThis.__FEDERATION__.__INSTANCES__ = [];
|
|
2671
|
-
globalThis.__FEDERATION__.moduleInfo = {};
|
|
2672
|
-
globalThis.__FEDERATION__.__SHARE__ = {};
|
|
2673
|
-
globalThis.__FEDERATION__.__MANIFEST_LOADING__ = {};
|
|
2674
|
-
}
|
|
2675
|
-
function getGlobalFederationInstance(name, version) {
|
|
2676
|
-
const buildId = getBuilderId();
|
|
2677
|
-
return globalThis.__FEDERATION__.__INSTANCES__.find((GMInstance)=>{
|
|
2678
|
-
if (buildId && GMInstance.options.id === getBuilderId()) {
|
|
2679
|
-
return true;
|
|
2680
|
-
}
|
|
2681
|
-
if (GMInstance.options.name === name && !GMInstance.options.version && !version) {
|
|
2682
|
-
return true;
|
|
2683
|
-
}
|
|
2684
|
-
if (GMInstance.options.name === name && version && GMInstance.options.version === version) {
|
|
2685
|
-
return true;
|
|
2686
|
-
}
|
|
2687
|
-
return false;
|
|
2688
|
-
});
|
|
2689
|
-
}
|
|
2690
|
-
function setGlobalFederationInstance(FederationInstance) {
|
|
2691
|
-
globalThis.__FEDERATION__.__INSTANCES__.push(FederationInstance);
|
|
2692
|
-
}
|
|
2693
|
-
function getGlobalFederationConstructor() {
|
|
2694
|
-
return globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR__;
|
|
2695
|
-
}
|
|
2696
|
-
function setGlobalFederationConstructor(FederationConstructor, isDebug = sdk.isDebugMode()) {
|
|
2697
|
-
if (isDebug) {
|
|
2698
|
-
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = FederationConstructor;
|
|
2699
|
-
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.6.6";
|
|
2700
|
-
}
|
|
2701
|
-
}
|
|
2702
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
2703
|
-
function getInfoWithoutType(target, key) {
|
|
2704
|
-
if (typeof key === 'string') {
|
|
2705
|
-
const keyRes = target[key];
|
|
2706
|
-
if (keyRes) {
|
|
2707
|
-
return {
|
|
2708
|
-
value: target[key],
|
|
2709
|
-
key: key
|
|
2710
|
-
};
|
|
2711
|
-
} else {
|
|
2712
|
-
const targetKeys = Object.keys(target);
|
|
2713
|
-
for (const targetKey of targetKeys){
|
|
2714
|
-
const [targetTypeOrName, _] = targetKey.split(':');
|
|
2715
|
-
const nKey = `${targetTypeOrName}:${key}`;
|
|
2716
|
-
const typeWithKeyRes = target[nKey];
|
|
2717
|
-
if (typeWithKeyRes) {
|
|
2718
|
-
return {
|
|
2719
|
-
value: typeWithKeyRes,
|
|
2720
|
-
key: nKey
|
|
2721
|
-
};
|
|
2722
|
-
}
|
|
2723
|
-
}
|
|
2724
|
-
return {
|
|
2725
|
-
value: undefined,
|
|
2726
|
-
key: key
|
|
2727
|
-
};
|
|
2728
|
-
}
|
|
2729
|
-
} else {
|
|
2730
|
-
throw new Error('key must be string');
|
|
2731
|
-
}
|
|
2732
|
-
}
|
|
2733
|
-
const getGlobalSnapshot = ()=>nativeGlobal.__FEDERATION__.moduleInfo;
|
|
2734
|
-
const getTargetSnapshotInfoByModuleInfo = (moduleInfo, snapshot)=>{
|
|
2735
|
-
// Check if the remote is included in the hostSnapshot
|
|
2736
|
-
const moduleKey = getFMId(moduleInfo);
|
|
2737
|
-
const getModuleInfo = getInfoWithoutType(snapshot, moduleKey).value;
|
|
2738
|
-
// The remoteSnapshot might not include a version
|
|
2739
|
-
if (getModuleInfo && !getModuleInfo.version && 'version' in moduleInfo && moduleInfo['version']) {
|
|
2740
|
-
getModuleInfo.version = moduleInfo['version'];
|
|
2741
|
-
}
|
|
2742
|
-
if (getModuleInfo) {
|
|
2743
|
-
return getModuleInfo;
|
|
2744
|
-
}
|
|
2745
|
-
// If the remote is not included in the hostSnapshot, deploy a micro app snapshot
|
|
2746
|
-
if ('version' in moduleInfo && moduleInfo['version']) {
|
|
2747
|
-
const { version } = moduleInfo, resModuleInfo = polyfills._object_without_properties_loose(moduleInfo, [
|
|
2748
|
-
"version"
|
|
2749
|
-
]);
|
|
2750
|
-
const moduleKeyWithoutVersion = getFMId(resModuleInfo);
|
|
2751
|
-
const getModuleInfoWithoutVersion = getInfoWithoutType(nativeGlobal.__FEDERATION__.moduleInfo, moduleKeyWithoutVersion).value;
|
|
2752
|
-
if ((getModuleInfoWithoutVersion == null ? void 0 : getModuleInfoWithoutVersion.version) === version) {
|
|
2753
|
-
return getModuleInfoWithoutVersion;
|
|
2754
|
-
}
|
|
2755
|
-
}
|
|
2756
|
-
return;
|
|
2541
|
+
const RUNTIME_001 = 'RUNTIME-001';
|
|
2542
|
+
const RUNTIME_002 = 'RUNTIME-002';
|
|
2543
|
+
const RUNTIME_003 = 'RUNTIME-003';
|
|
2544
|
+
const RUNTIME_004 = 'RUNTIME-004';
|
|
2545
|
+
const RUNTIME_005 = 'RUNTIME-005';
|
|
2546
|
+
const RUNTIME_006 = 'RUNTIME-006';
|
|
2547
|
+
const RUNTIME_007 = 'RUNTIME-007';
|
|
2548
|
+
const RUNTIME_008 = 'RUNTIME-008';
|
|
2549
|
+
const TYPE_001 = 'TYPE-001';
|
|
2550
|
+
const BUILD_001 = 'BUILD-001';
|
|
2551
|
+
|
|
2552
|
+
const getDocsUrl = (errorCode)=>{
|
|
2553
|
+
const type = errorCode.split('-')[0].toLowerCase();
|
|
2554
|
+
return `https://module-federation.io/guide/troubleshooting/${type}/${errorCode}`;
|
|
2757
2555
|
};
|
|
2758
|
-
const
|
|
2759
|
-
const
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2556
|
+
const getShortErrorMsg = (errorCode, errorDescMap, args, originalErrorMsg)=>{
|
|
2557
|
+
const msg = [
|
|
2558
|
+
`${[
|
|
2559
|
+
errorDescMap[errorCode]
|
|
2560
|
+
]} #${errorCode}`
|
|
2561
|
+
];
|
|
2562
|
+
args && msg.push(`args: ${JSON.stringify(args)}`);
|
|
2563
|
+
msg.push(getDocsUrl(errorCode));
|
|
2564
|
+
originalErrorMsg && msg.push(`Original Error Message:\n ${originalErrorMsg}`);
|
|
2565
|
+
return msg.join('\n');
|
|
2763
2566
|
};
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
|
|
2567
|
+
|
|
2568
|
+
function _extends() {
|
|
2569
|
+
_extends = Object.assign || function assign(target) {
|
|
2570
|
+
for(var i = 1; i < arguments.length; i++){
|
|
2571
|
+
var source = arguments[i];
|
|
2572
|
+
for(var key in source)if (Object.prototype.hasOwnProperty.call(source, key)) target[key] = source[key];
|
|
2770
2573
|
}
|
|
2574
|
+
return target;
|
|
2771
2575
|
};
|
|
2576
|
+
return _extends.apply(this, arguments);
|
|
2577
|
+
}
|
|
2578
|
+
|
|
2579
|
+
const runtimeDescMap = {
|
|
2580
|
+
[RUNTIME_001]: 'Failed to get remoteEntry exports.',
|
|
2581
|
+
[RUNTIME_002]: 'The remote entry interface does not contain "init"',
|
|
2582
|
+
[RUNTIME_003]: 'Failed to get manifest.',
|
|
2583
|
+
[RUNTIME_004]: 'Failed to locate remote.',
|
|
2584
|
+
[RUNTIME_005]: 'Invalid loadShareSync function call from bundler runtime',
|
|
2585
|
+
[RUNTIME_006]: 'Invalid loadShareSync function call from runtime',
|
|
2586
|
+
[RUNTIME_007]: 'Failed to get remote snapshot.',
|
|
2587
|
+
[RUNTIME_008]: 'Failed to load script resources.'
|
|
2772
2588
|
};
|
|
2773
|
-
const
|
|
2774
|
-
|
|
2775
|
-
const entryExports = globalThis[remoteEntryKey];
|
|
2776
|
-
return {
|
|
2777
|
-
remoteEntryKey,
|
|
2778
|
-
entryExports
|
|
2779
|
-
};
|
|
2589
|
+
const typeDescMap = {
|
|
2590
|
+
[TYPE_001]: 'Failed to generate type declaration.'
|
|
2780
2591
|
};
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
// If a plugin is not registered, it is added to the global plugins.
|
|
2784
|
-
// If a plugin is already registered, a warning message is logged.
|
|
2785
|
-
const registerGlobalPlugins = (plugins)=>{
|
|
2786
|
-
const { __GLOBAL_PLUGIN__ } = nativeGlobal.__FEDERATION__;
|
|
2787
|
-
plugins.forEach((plugin)=>{
|
|
2788
|
-
if (__GLOBAL_PLUGIN__.findIndex((p)=>p.name === plugin.name) === -1) {
|
|
2789
|
-
__GLOBAL_PLUGIN__.push(plugin);
|
|
2790
|
-
} else {
|
|
2791
|
-
warn(`The plugin ${plugin.name} has been registered.`);
|
|
2792
|
-
}
|
|
2793
|
-
});
|
|
2592
|
+
const buildDescMap = {
|
|
2593
|
+
[BUILD_001]: 'Failed to find expose module.'
|
|
2794
2594
|
};
|
|
2795
|
-
const
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
const build = `(?:\\+(${buildIdentifier}(?:\\.${buildIdentifier})*))`;
|
|
2813
|
-
const numericIdentifier = '0|[1-9]\\d*';
|
|
2814
|
-
const numericIdentifierLoose = '[0-9]+';
|
|
2815
|
-
const nonNumericIdentifier = '\\d*[a-zA-Z-][a-zA-Z0-9-]*';
|
|
2816
|
-
const preReleaseIdentifierLoose = `(?:${numericIdentifierLoose}|${nonNumericIdentifier})`;
|
|
2817
|
-
const preReleaseLoose = `(?:-?(${preReleaseIdentifierLoose}(?:\\.${preReleaseIdentifierLoose})*))`;
|
|
2818
|
-
const preReleaseIdentifier = `(?:${numericIdentifier}|${nonNumericIdentifier})`;
|
|
2819
|
-
const preRelease = `(?:-(${preReleaseIdentifier}(?:\\.${preReleaseIdentifier})*))`;
|
|
2820
|
-
const xRangeIdentifier = `${numericIdentifier}|x|X|\\*`;
|
|
2821
|
-
const xRangePlain = `[v=\\s]*(${xRangeIdentifier})(?:\\.(${xRangeIdentifier})(?:\\.(${xRangeIdentifier})(?:${preRelease})?${build}?)?)?`;
|
|
2822
|
-
const hyphenRange = `^\\s*(${xRangePlain})\\s+-\\s+(${xRangePlain})\\s*$`;
|
|
2823
|
-
const mainVersionLoose = `(${numericIdentifierLoose})\\.(${numericIdentifierLoose})\\.(${numericIdentifierLoose})`;
|
|
2824
|
-
const loosePlain = `[v=\\s]*${mainVersionLoose}${preReleaseLoose}?${build}?`;
|
|
2825
|
-
const gtlt = '((?:<|>)?=?)';
|
|
2826
|
-
const comparatorTrim = `(\\s*)${gtlt}\\s*(${loosePlain}|${xRangePlain})`;
|
|
2827
|
-
const loneTilde = '(?:~>?)';
|
|
2828
|
-
const tildeTrim = `(\\s*)${loneTilde}\\s+`;
|
|
2829
|
-
const loneCaret = '(?:\\^)';
|
|
2830
|
-
const caretTrim = `(\\s*)${loneCaret}\\s+`;
|
|
2831
|
-
const star = '(<|>)?=?\\s*\\*';
|
|
2832
|
-
const caret = `^${loneCaret}${xRangePlain}$`;
|
|
2833
|
-
const mainVersion = `(${numericIdentifier})\\.(${numericIdentifier})\\.(${numericIdentifier})`;
|
|
2834
|
-
const fullPlain = `v?${mainVersion}${preRelease}?${build}?`;
|
|
2835
|
-
const tilde = `^${loneTilde}${xRangePlain}$`;
|
|
2836
|
-
const xRange = `^${gtlt}\\s*${xRangePlain}$`;
|
|
2837
|
-
const comparator = `^${gtlt}\\s*(${fullPlain})$|^$`;
|
|
2838
|
-
// copy from semver package
|
|
2839
|
-
const gte0 = '^\\s*>=\\s*0.0.0\\s*$';
|
|
2840
|
-
|
|
2841
|
-
// fork from https://github.com/originjs/vite-plugin-federation/blob/v1.1.12/packages/lib/src/utils/semver/index.ts
|
|
2842
|
-
function parseRegex(source) {
|
|
2843
|
-
return new RegExp(source);
|
|
2844
|
-
}
|
|
2845
|
-
function isXVersion(version) {
|
|
2846
|
-
return !version || version.toLowerCase() === 'x' || version === '*';
|
|
2847
|
-
}
|
|
2848
|
-
function pipe(...fns) {
|
|
2849
|
-
return (x)=>fns.reduce((v, f)=>f(v), x);
|
|
2850
|
-
}
|
|
2851
|
-
function extractComparator(comparatorString) {
|
|
2852
|
-
return comparatorString.match(parseRegex(comparator));
|
|
2853
|
-
}
|
|
2854
|
-
function combineVersion(major, minor, patch, preRelease) {
|
|
2855
|
-
const mainVersion = `${major}.${minor}.${patch}`;
|
|
2856
|
-
if (preRelease) {
|
|
2857
|
-
return `${mainVersion}-${preRelease}`;
|
|
2858
|
-
}
|
|
2859
|
-
return mainVersion;
|
|
2860
|
-
}
|
|
2595
|
+
const errorDescMap = _extends({}, runtimeDescMap, typeDescMap, buildDescMap);
|
|
2596
|
+
|
|
2597
|
+
index_cjs.BUILD_001 = BUILD_001;
|
|
2598
|
+
index_cjs.RUNTIME_001 = RUNTIME_001;
|
|
2599
|
+
index_cjs.RUNTIME_002 = RUNTIME_002;
|
|
2600
|
+
index_cjs.RUNTIME_003 = RUNTIME_003;
|
|
2601
|
+
index_cjs.RUNTIME_004 = RUNTIME_004;
|
|
2602
|
+
index_cjs.RUNTIME_005 = RUNTIME_005;
|
|
2603
|
+
index_cjs.RUNTIME_006 = RUNTIME_006;
|
|
2604
|
+
index_cjs.RUNTIME_007 = RUNTIME_007;
|
|
2605
|
+
index_cjs.RUNTIME_008 = RUNTIME_008;
|
|
2606
|
+
index_cjs.TYPE_001 = TYPE_001;
|
|
2607
|
+
index_cjs.buildDescMap = buildDescMap;
|
|
2608
|
+
index_cjs.errorDescMap = errorDescMap;
|
|
2609
|
+
index_cjs.getShortErrorMsg = getShortErrorMsg;
|
|
2610
|
+
index_cjs.runtimeDescMap = runtimeDescMap;
|
|
2611
|
+
index_cjs.typeDescMap = typeDescMap;
|
|
2861
2612
|
|
|
2862
|
-
|
|
2863
|
-
function parseHyphen(range) {
|
|
2864
|
-
return range.replace(parseRegex(hyphenRange), (_range, from, fromMajor, fromMinor, fromPatch, _fromPreRelease, _fromBuild, to, toMajor, toMinor, toPatch, toPreRelease)=>{
|
|
2865
|
-
if (isXVersion(fromMajor)) {
|
|
2866
|
-
from = '';
|
|
2867
|
-
} else if (isXVersion(fromMinor)) {
|
|
2868
|
-
from = `>=${fromMajor}.0.0`;
|
|
2869
|
-
} else if (isXVersion(fromPatch)) {
|
|
2870
|
-
from = `>=${fromMajor}.${fromMinor}.0`;
|
|
2871
|
-
} else {
|
|
2872
|
-
from = `>=${from}`;
|
|
2873
|
-
}
|
|
2874
|
-
if (isXVersion(toMajor)) {
|
|
2875
|
-
to = '';
|
|
2876
|
-
} else if (isXVersion(toMinor)) {
|
|
2877
|
-
to = `<${Number(toMajor) + 1}.0.0-0`;
|
|
2878
|
-
} else if (isXVersion(toPatch)) {
|
|
2879
|
-
to = `<${toMajor}.${Number(toMinor) + 1}.0-0`;
|
|
2880
|
-
} else if (toPreRelease) {
|
|
2881
|
-
to = `<=${toMajor}.${toMinor}.${toPatch}-${toPreRelease}`;
|
|
2882
|
-
} else {
|
|
2883
|
-
to = `<=${to}`;
|
|
2884
|
-
}
|
|
2885
|
-
return `${from} ${to}`.trim();
|
|
2886
|
-
});
|
|
2887
|
-
}
|
|
2888
|
-
function parseComparatorTrim(range) {
|
|
2889
|
-
return range.replace(parseRegex(comparatorTrim), '$1$2$3');
|
|
2890
|
-
}
|
|
2891
|
-
function parseTildeTrim(range) {
|
|
2892
|
-
return range.replace(parseRegex(tildeTrim), '$1~');
|
|
2893
|
-
}
|
|
2894
|
-
function parseCaretTrim(range) {
|
|
2895
|
-
return range.replace(parseRegex(caretTrim), '$1^');
|
|
2896
|
-
}
|
|
2897
|
-
function parseCarets(range) {
|
|
2898
|
-
return range.trim().split(/\s+/).map((rangeVersion)=>rangeVersion.replace(parseRegex(caret), (_, major, minor, patch, preRelease)=>{
|
|
2899
|
-
if (isXVersion(major)) {
|
|
2900
|
-
return '';
|
|
2901
|
-
} else if (isXVersion(minor)) {
|
|
2902
|
-
return `>=${major}.0.0 <${Number(major) + 1}.0.0-0`;
|
|
2903
|
-
} else if (isXVersion(patch)) {
|
|
2904
|
-
if (major === '0') {
|
|
2905
|
-
return `>=${major}.${minor}.0 <${major}.${Number(minor) + 1}.0-0`;
|
|
2906
|
-
} else {
|
|
2907
|
-
return `>=${major}.${minor}.0 <${Number(major) + 1}.0.0-0`;
|
|
2908
|
-
}
|
|
2909
|
-
} else if (preRelease) {
|
|
2910
|
-
if (major === '0') {
|
|
2911
|
-
if (minor === '0') {
|
|
2912
|
-
return `>=${major}.${minor}.${patch}-${preRelease} <${major}.${minor}.${Number(patch) + 1}-0`;
|
|
2913
|
-
} else {
|
|
2914
|
-
return `>=${major}.${minor}.${patch}-${preRelease} <${major}.${Number(minor) + 1}.0-0`;
|
|
2915
|
-
}
|
|
2916
|
-
} else {
|
|
2917
|
-
return `>=${major}.${minor}.${patch}-${preRelease} <${Number(major) + 1}.0.0-0`;
|
|
2918
|
-
}
|
|
2919
|
-
} else {
|
|
2920
|
-
if (major === '0') {
|
|
2921
|
-
if (minor === '0') {
|
|
2922
|
-
return `>=${major}.${minor}.${patch} <${major}.${minor}.${Number(patch) + 1}-0`;
|
|
2923
|
-
} else {
|
|
2924
|
-
return `>=${major}.${minor}.${patch} <${major}.${Number(minor) + 1}.0-0`;
|
|
2925
|
-
}
|
|
2926
|
-
}
|
|
2927
|
-
return `>=${major}.${minor}.${patch} <${Number(major) + 1}.0.0-0`;
|
|
2928
|
-
}
|
|
2929
|
-
})).join(' ');
|
|
2930
|
-
}
|
|
2931
|
-
function parseTildes(range) {
|
|
2932
|
-
return range.trim().split(/\s+/).map((rangeVersion)=>rangeVersion.replace(parseRegex(tilde), (_, major, minor, patch, preRelease)=>{
|
|
2933
|
-
if (isXVersion(major)) {
|
|
2934
|
-
return '';
|
|
2935
|
-
} else if (isXVersion(minor)) {
|
|
2936
|
-
return `>=${major}.0.0 <${Number(major) + 1}.0.0-0`;
|
|
2937
|
-
} else if (isXVersion(patch)) {
|
|
2938
|
-
return `>=${major}.${minor}.0 <${major}.${Number(minor) + 1}.0-0`;
|
|
2939
|
-
} else if (preRelease) {
|
|
2940
|
-
return `>=${major}.${minor}.${patch}-${preRelease} <${major}.${Number(minor) + 1}.0-0`;
|
|
2941
|
-
}
|
|
2942
|
-
return `>=${major}.${minor}.${patch} <${major}.${Number(minor) + 1}.0-0`;
|
|
2943
|
-
})).join(' ');
|
|
2944
|
-
}
|
|
2945
|
-
function parseXRanges(range) {
|
|
2946
|
-
return range.split(/\s+/).map((rangeVersion)=>rangeVersion.trim().replace(parseRegex(xRange), (ret, gtlt, major, minor, patch, preRelease)=>{
|
|
2947
|
-
const isXMajor = isXVersion(major);
|
|
2948
|
-
const isXMinor = isXMajor || isXVersion(minor);
|
|
2949
|
-
const isXPatch = isXMinor || isXVersion(patch);
|
|
2950
|
-
if (gtlt === '=' && isXPatch) {
|
|
2951
|
-
gtlt = '';
|
|
2952
|
-
}
|
|
2953
|
-
preRelease = '';
|
|
2954
|
-
if (isXMajor) {
|
|
2955
|
-
if (gtlt === '>' || gtlt === '<') {
|
|
2956
|
-
// nothing is allowed
|
|
2957
|
-
return '<0.0.0-0';
|
|
2958
|
-
} else {
|
|
2959
|
-
// nothing is forbidden
|
|
2960
|
-
return '*';
|
|
2961
|
-
}
|
|
2962
|
-
} else if (gtlt && isXPatch) {
|
|
2963
|
-
// replace X with 0
|
|
2964
|
-
if (isXMinor) {
|
|
2965
|
-
minor = 0;
|
|
2966
|
-
}
|
|
2967
|
-
patch = 0;
|
|
2968
|
-
if (gtlt === '>') {
|
|
2969
|
-
// >1 => >=2.0.0
|
|
2970
|
-
// >1.2 => >=1.3.0
|
|
2971
|
-
gtlt = '>=';
|
|
2972
|
-
if (isXMinor) {
|
|
2973
|
-
major = Number(major) + 1;
|
|
2974
|
-
minor = 0;
|
|
2975
|
-
patch = 0;
|
|
2976
|
-
} else {
|
|
2977
|
-
minor = Number(minor) + 1;
|
|
2978
|
-
patch = 0;
|
|
2979
|
-
}
|
|
2980
|
-
} else if (gtlt === '<=') {
|
|
2981
|
-
// <=0.7.x is actually <0.8.0, since any 0.7.x should pass
|
|
2982
|
-
// Similarly, <=7.x is actually <8.0.0, etc.
|
|
2983
|
-
gtlt = '<';
|
|
2984
|
-
if (isXMinor) {
|
|
2985
|
-
major = Number(major) + 1;
|
|
2986
|
-
} else {
|
|
2987
|
-
minor = Number(minor) + 1;
|
|
2988
|
-
}
|
|
2989
|
-
}
|
|
2990
|
-
if (gtlt === '<') {
|
|
2991
|
-
preRelease = '-0';
|
|
2992
|
-
}
|
|
2993
|
-
return `${gtlt + major}.${minor}.${patch}${preRelease}`;
|
|
2994
|
-
} else if (isXMinor) {
|
|
2995
|
-
return `>=${major}.0.0${preRelease} <${Number(major) + 1}.0.0-0`;
|
|
2996
|
-
} else if (isXPatch) {
|
|
2997
|
-
return `>=${major}.${minor}.0${preRelease} <${major}.${Number(minor) + 1}.0-0`;
|
|
2998
|
-
}
|
|
2999
|
-
return ret;
|
|
3000
|
-
})).join(' ');
|
|
3001
|
-
}
|
|
3002
|
-
function parseStar(range) {
|
|
3003
|
-
return range.trim().replace(parseRegex(star), '');
|
|
3004
|
-
}
|
|
3005
|
-
function parseGTE0(comparatorString) {
|
|
3006
|
-
return comparatorString.trim().replace(parseRegex(gte0), '');
|
|
3007
|
-
}
|
|
2613
|
+
(function (exports) {
|
|
3008
2614
|
|
|
3009
|
-
|
|
3010
|
-
|
|
3011
|
-
|
|
3012
|
-
// You can use this software according to the terms and conditions of the Mulan PSL v2.
|
|
3013
|
-
// You may obtain a copy of Mulan PSL v2 at:
|
|
3014
|
-
// http://license.coscl.org.cn/MulanPSL2
|
|
3015
|
-
// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
|
3016
|
-
// See the Mulan PSL v2 for more details.
|
|
3017
|
-
function compareAtom(rangeAtom, versionAtom) {
|
|
3018
|
-
rangeAtom = Number(rangeAtom) || rangeAtom;
|
|
3019
|
-
versionAtom = Number(versionAtom) || versionAtom;
|
|
3020
|
-
if (rangeAtom > versionAtom) {
|
|
3021
|
-
return 1;
|
|
3022
|
-
}
|
|
3023
|
-
if (rangeAtom === versionAtom) {
|
|
3024
|
-
return 0;
|
|
3025
|
-
}
|
|
3026
|
-
return -1;
|
|
3027
|
-
}
|
|
3028
|
-
function comparePreRelease(rangeAtom, versionAtom) {
|
|
3029
|
-
const { preRelease: rangePreRelease } = rangeAtom;
|
|
3030
|
-
const { preRelease: versionPreRelease } = versionAtom;
|
|
3031
|
-
if (rangePreRelease === undefined && Boolean(versionPreRelease)) {
|
|
3032
|
-
return 1;
|
|
3033
|
-
}
|
|
3034
|
-
if (Boolean(rangePreRelease) && versionPreRelease === undefined) {
|
|
3035
|
-
return -1;
|
|
3036
|
-
}
|
|
3037
|
-
if (rangePreRelease === undefined && versionPreRelease === undefined) {
|
|
3038
|
-
return 0;
|
|
3039
|
-
}
|
|
3040
|
-
for(let i = 0, n = rangePreRelease.length; i <= n; i++){
|
|
3041
|
-
const rangeElement = rangePreRelease[i];
|
|
3042
|
-
const versionElement = versionPreRelease[i];
|
|
3043
|
-
if (rangeElement === versionElement) {
|
|
3044
|
-
continue;
|
|
3045
|
-
}
|
|
3046
|
-
if (rangeElement === undefined && versionElement === undefined) {
|
|
3047
|
-
return 0;
|
|
3048
|
-
}
|
|
3049
|
-
if (!rangeElement) {
|
|
3050
|
-
return 1;
|
|
3051
|
-
}
|
|
3052
|
-
if (!versionElement) {
|
|
3053
|
-
return -1;
|
|
3054
|
-
}
|
|
3055
|
-
return compareAtom(rangeElement, versionElement);
|
|
3056
|
-
}
|
|
3057
|
-
return 0;
|
|
3058
|
-
}
|
|
3059
|
-
function compareVersion(rangeAtom, versionAtom) {
|
|
3060
|
-
return compareAtom(rangeAtom.major, versionAtom.major) || compareAtom(rangeAtom.minor, versionAtom.minor) || compareAtom(rangeAtom.patch, versionAtom.patch) || comparePreRelease(rangeAtom, versionAtom);
|
|
3061
|
-
}
|
|
3062
|
-
function eq(rangeAtom, versionAtom) {
|
|
3063
|
-
return rangeAtom.version === versionAtom.version;
|
|
3064
|
-
}
|
|
3065
|
-
function compare(rangeAtom, versionAtom) {
|
|
3066
|
-
switch(rangeAtom.operator){
|
|
3067
|
-
case '':
|
|
3068
|
-
case '=':
|
|
3069
|
-
return eq(rangeAtom, versionAtom);
|
|
3070
|
-
case '>':
|
|
3071
|
-
return compareVersion(rangeAtom, versionAtom) < 0;
|
|
3072
|
-
case '>=':
|
|
3073
|
-
return eq(rangeAtom, versionAtom) || compareVersion(rangeAtom, versionAtom) < 0;
|
|
3074
|
-
case '<':
|
|
3075
|
-
return compareVersion(rangeAtom, versionAtom) > 0;
|
|
3076
|
-
case '<=':
|
|
3077
|
-
return eq(rangeAtom, versionAtom) || compareVersion(rangeAtom, versionAtom) > 0;
|
|
3078
|
-
case undefined:
|
|
3079
|
-
{
|
|
3080
|
-
// mean * or x -> all versions
|
|
3081
|
-
return true;
|
|
3082
|
-
}
|
|
3083
|
-
default:
|
|
3084
|
-
return false;
|
|
3085
|
-
}
|
|
3086
|
-
}
|
|
2615
|
+
var polyfills = polyfills_cjs$1;
|
|
2616
|
+
var sdk = index_cjs$1;
|
|
2617
|
+
var errorCodes = index_cjs;
|
|
3087
2618
|
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
// `~ 1.2.3` => `~1.2.3`
|
|
3113
|
-
parseTildeTrim, // handle trim caret
|
|
3114
|
-
// `^ 1.2.3` => `^1.2.3`
|
|
3115
|
-
parseCaretTrim)(range.trim()).split(/\s+/).join(' ');
|
|
3116
|
-
}
|
|
3117
|
-
function satisfy(version, range) {
|
|
3118
|
-
if (!version) {
|
|
3119
|
-
return false;
|
|
3120
|
-
}
|
|
3121
|
-
const parsedRange = parseRange(range);
|
|
3122
|
-
const parsedComparator = parsedRange.split(' ').map((rangeVersion)=>parseComparatorString(rangeVersion)).join(' ');
|
|
3123
|
-
const comparators = parsedComparator.split(/\s+/).map((comparator)=>parseGTE0(comparator));
|
|
3124
|
-
const extractedVersion = extractComparator(version);
|
|
3125
|
-
if (!extractedVersion) {
|
|
3126
|
-
return false;
|
|
3127
|
-
}
|
|
3128
|
-
const [, versionOperator, , versionMajor, versionMinor, versionPatch, versionPreRelease] = extractedVersion;
|
|
3129
|
-
const versionAtom = {
|
|
3130
|
-
operator: versionOperator,
|
|
3131
|
-
version: combineVersion(versionMajor, versionMinor, versionPatch, versionPreRelease),
|
|
3132
|
-
major: versionMajor,
|
|
3133
|
-
minor: versionMinor,
|
|
3134
|
-
patch: versionPatch,
|
|
3135
|
-
preRelease: versionPreRelease == null ? void 0 : versionPreRelease.split('.')
|
|
3136
|
-
};
|
|
3137
|
-
for (const comparator of comparators){
|
|
3138
|
-
const extractedComparator = extractComparator(comparator);
|
|
3139
|
-
if (!extractedComparator) {
|
|
3140
|
-
return false;
|
|
3141
|
-
}
|
|
3142
|
-
const [, rangeOperator, , rangeMajor, rangeMinor, rangePatch, rangePreRelease] = extractedComparator;
|
|
3143
|
-
const rangeAtom = {
|
|
3144
|
-
operator: rangeOperator,
|
|
3145
|
-
version: combineVersion(rangeMajor, rangeMinor, rangePatch, rangePreRelease),
|
|
3146
|
-
major: rangeMajor,
|
|
3147
|
-
minor: rangeMinor,
|
|
3148
|
-
patch: rangePatch,
|
|
3149
|
-
preRelease: rangePreRelease == null ? void 0 : rangePreRelease.split('.')
|
|
3150
|
-
};
|
|
3151
|
-
if (!compare(rangeAtom, versionAtom)) {
|
|
3152
|
-
return false; // early return
|
|
3153
|
-
}
|
|
3154
|
-
}
|
|
3155
|
-
return true;
|
|
3156
|
-
}
|
|
2619
|
+
const LOG_CATEGORY = '[ Federation Runtime ]';
|
|
2620
|
+
// FIXME: pre-bundle ?
|
|
2621
|
+
const logger = sdk.createLogger(LOG_CATEGORY);
|
|
2622
|
+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
2623
|
+
function assert(condition, msg) {
|
|
2624
|
+
if (!condition) {
|
|
2625
|
+
error(msg);
|
|
2626
|
+
}
|
|
2627
|
+
}
|
|
2628
|
+
function error(msg) {
|
|
2629
|
+
if (msg instanceof Error) {
|
|
2630
|
+
msg.message = `${LOG_CATEGORY}: ${msg.message}`;
|
|
2631
|
+
throw msg;
|
|
2632
|
+
}
|
|
2633
|
+
throw new Error(`${LOG_CATEGORY}: ${msg}`);
|
|
2634
|
+
}
|
|
2635
|
+
function warn(msg) {
|
|
2636
|
+
if (msg instanceof Error) {
|
|
2637
|
+
msg.message = `${LOG_CATEGORY}: ${msg.message}`;
|
|
2638
|
+
logger.warn(msg);
|
|
2639
|
+
} else {
|
|
2640
|
+
logger.warn(msg);
|
|
2641
|
+
}
|
|
2642
|
+
}
|
|
3157
2643
|
|
|
3158
|
-
function
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
|
|
3206
|
-
|
|
3207
|
-
|
|
3208
|
-
|
|
3209
|
-
|
|
3210
|
-
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
}
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
|
|
3257
|
-
|
|
3258
|
-
|
|
3259
|
-
|
|
3260
|
-
|
|
3261
|
-
|
|
3262
|
-
|
|
3263
|
-
};
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
|
|
3273
|
-
|
|
3274
|
-
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
|
|
3283
|
-
|
|
3284
|
-
|
|
3285
|
-
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
|
|
3298
|
-
|
|
3299
|
-
|
|
3300
|
-
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
|
|
3321
|
-
|
|
3322
|
-
|
|
3323
|
-
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
|
|
3328
|
-
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
|
|
3335
|
-
|
|
3336
|
-
|
|
3337
|
-
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
}
|
|
3349
|
-
|
|
3350
|
-
|
|
3351
|
-
|
|
3352
|
-
|
|
3353
|
-
|
|
3354
|
-
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
|
|
2644
|
+
function addUniqueItem(arr, item) {
|
|
2645
|
+
if (arr.findIndex((name)=>name === item) === -1) {
|
|
2646
|
+
arr.push(item);
|
|
2647
|
+
}
|
|
2648
|
+
return arr;
|
|
2649
|
+
}
|
|
2650
|
+
function getFMId(remoteInfo) {
|
|
2651
|
+
if ('version' in remoteInfo && remoteInfo.version) {
|
|
2652
|
+
return `${remoteInfo.name}:${remoteInfo.version}`;
|
|
2653
|
+
} else if ('entry' in remoteInfo && remoteInfo.entry) {
|
|
2654
|
+
return `${remoteInfo.name}:${remoteInfo.entry}`;
|
|
2655
|
+
} else {
|
|
2656
|
+
return `${remoteInfo.name}`;
|
|
2657
|
+
}
|
|
2658
|
+
}
|
|
2659
|
+
function isRemoteInfoWithEntry(remote) {
|
|
2660
|
+
return typeof remote.entry !== 'undefined';
|
|
2661
|
+
}
|
|
2662
|
+
function isPureRemoteEntry(remote) {
|
|
2663
|
+
return !remote.entry.includes('.json') && remote.entry.includes('.js');
|
|
2664
|
+
}
|
|
2665
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2666
|
+
async function safeWrapper(callback, disableWarn) {
|
|
2667
|
+
try {
|
|
2668
|
+
const res = await callback();
|
|
2669
|
+
return res;
|
|
2670
|
+
} catch (e) {
|
|
2671
|
+
!disableWarn && warn(e);
|
|
2672
|
+
return;
|
|
2673
|
+
}
|
|
2674
|
+
}
|
|
2675
|
+
function isObject(val) {
|
|
2676
|
+
return val && typeof val === 'object';
|
|
2677
|
+
}
|
|
2678
|
+
const objectToString = Object.prototype.toString;
|
|
2679
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
2680
|
+
function isPlainObject(val) {
|
|
2681
|
+
return objectToString.call(val) === '[object Object]';
|
|
2682
|
+
}
|
|
2683
|
+
function isStaticResourcesEqual(url1, url2) {
|
|
2684
|
+
const REG_EXP = /^(https?:)?\/\//i;
|
|
2685
|
+
// Transform url1 and url2 into relative paths
|
|
2686
|
+
const relativeUrl1 = url1.replace(REG_EXP, '').replace(/\/$/, '');
|
|
2687
|
+
const relativeUrl2 = url2.replace(REG_EXP, '').replace(/\/$/, '');
|
|
2688
|
+
// Check if the relative paths are identical
|
|
2689
|
+
return relativeUrl1 === relativeUrl2;
|
|
2690
|
+
}
|
|
2691
|
+
function arrayOptions(options) {
|
|
2692
|
+
return Array.isArray(options) ? options : [
|
|
2693
|
+
options
|
|
2694
|
+
];
|
|
2695
|
+
}
|
|
2696
|
+
function getRemoteEntryInfoFromSnapshot(snapshot) {
|
|
2697
|
+
const defaultRemoteEntryInfo = {
|
|
2698
|
+
url: '',
|
|
2699
|
+
type: 'global',
|
|
2700
|
+
globalName: ''
|
|
2701
|
+
};
|
|
2702
|
+
if (sdk.isBrowserEnv()) {
|
|
2703
|
+
return 'remoteEntry' in snapshot ? {
|
|
2704
|
+
url: snapshot.remoteEntry,
|
|
2705
|
+
type: snapshot.remoteEntryType,
|
|
2706
|
+
globalName: snapshot.globalName
|
|
2707
|
+
} : defaultRemoteEntryInfo;
|
|
2708
|
+
}
|
|
2709
|
+
if ('ssrRemoteEntry' in snapshot) {
|
|
2710
|
+
return {
|
|
2711
|
+
url: snapshot.ssrRemoteEntry || defaultRemoteEntryInfo.url,
|
|
2712
|
+
type: snapshot.ssrRemoteEntryType || defaultRemoteEntryInfo.type,
|
|
2713
|
+
globalName: snapshot.globalName
|
|
2714
|
+
};
|
|
2715
|
+
}
|
|
2716
|
+
return defaultRemoteEntryInfo;
|
|
2717
|
+
}
|
|
2718
|
+
const processModuleAlias = (name, subPath)=>{
|
|
2719
|
+
// @host/ ./button -> @host/button
|
|
2720
|
+
let moduleName;
|
|
2721
|
+
if (name.endsWith('/')) {
|
|
2722
|
+
moduleName = name.slice(0, -1);
|
|
2723
|
+
} else {
|
|
2724
|
+
moduleName = name;
|
|
2725
|
+
}
|
|
2726
|
+
if (subPath.startsWith('.')) {
|
|
2727
|
+
subPath = subPath.slice(1);
|
|
2728
|
+
}
|
|
2729
|
+
moduleName = moduleName + subPath;
|
|
2730
|
+
return moduleName;
|
|
2731
|
+
};
|
|
2732
|
+
|
|
2733
|
+
const CurrentGlobal = typeof globalThis === 'object' ? globalThis : window;
|
|
2734
|
+
const nativeGlobal = (()=>{
|
|
2735
|
+
try {
|
|
2736
|
+
// get real window (incase of sandbox)
|
|
2737
|
+
return document.defaultView;
|
|
2738
|
+
} catch (e) {
|
|
2739
|
+
// node env
|
|
2740
|
+
return CurrentGlobal;
|
|
2741
|
+
}
|
|
2742
|
+
})();
|
|
2743
|
+
const Global = nativeGlobal;
|
|
2744
|
+
function definePropertyGlobalVal(target, key, val) {
|
|
2745
|
+
Object.defineProperty(target, key, {
|
|
2746
|
+
value: val,
|
|
2747
|
+
configurable: false,
|
|
2748
|
+
writable: true
|
|
2749
|
+
});
|
|
2750
|
+
}
|
|
2751
|
+
function includeOwnProperty(target, key) {
|
|
2752
|
+
return Object.hasOwnProperty.call(target, key);
|
|
2753
|
+
}
|
|
2754
|
+
// This section is to prevent encapsulation by certain microfrontend frameworks. Due to reuse policies, sandbox escapes.
|
|
2755
|
+
// The sandbox in the microfrontend does not replicate the value of 'configurable'.
|
|
2756
|
+
// If there is no loading content on the global object, this section defines the loading object.
|
|
2757
|
+
if (!includeOwnProperty(CurrentGlobal, '__GLOBAL_LOADING_REMOTE_ENTRY__')) {
|
|
2758
|
+
definePropertyGlobalVal(CurrentGlobal, '__GLOBAL_LOADING_REMOTE_ENTRY__', {});
|
|
2759
|
+
}
|
|
2760
|
+
const globalLoading = CurrentGlobal.__GLOBAL_LOADING_REMOTE_ENTRY__;
|
|
2761
|
+
function setGlobalDefaultVal(target) {
|
|
2762
|
+
var _target___FEDERATION__, _target___FEDERATION__1, _target___FEDERATION__2, _target___FEDERATION__3, _target___FEDERATION__4, _target___FEDERATION__5;
|
|
2763
|
+
if (includeOwnProperty(target, '__VMOK__') && !includeOwnProperty(target, '__FEDERATION__')) {
|
|
2764
|
+
definePropertyGlobalVal(target, '__FEDERATION__', target.__VMOK__);
|
|
2765
|
+
}
|
|
2766
|
+
if (!includeOwnProperty(target, '__FEDERATION__')) {
|
|
2767
|
+
definePropertyGlobalVal(target, '__FEDERATION__', {
|
|
2768
|
+
__GLOBAL_PLUGIN__: [],
|
|
2769
|
+
__INSTANCES__: [],
|
|
2770
|
+
moduleInfo: {},
|
|
2771
|
+
__SHARE__: {},
|
|
2772
|
+
__MANIFEST_LOADING__: {},
|
|
2773
|
+
__PRELOADED_MAP__: new Map()
|
|
2774
|
+
});
|
|
2775
|
+
definePropertyGlobalVal(target, '__VMOK__', target.__FEDERATION__);
|
|
2776
|
+
}
|
|
2777
|
+
var ___GLOBAL_PLUGIN__;
|
|
2778
|
+
(___GLOBAL_PLUGIN__ = (_target___FEDERATION__ = target.__FEDERATION__).__GLOBAL_PLUGIN__) != null ? ___GLOBAL_PLUGIN__ : _target___FEDERATION__.__GLOBAL_PLUGIN__ = [];
|
|
2779
|
+
var ___INSTANCES__;
|
|
2780
|
+
(___INSTANCES__ = (_target___FEDERATION__1 = target.__FEDERATION__).__INSTANCES__) != null ? ___INSTANCES__ : _target___FEDERATION__1.__INSTANCES__ = [];
|
|
2781
|
+
var _moduleInfo;
|
|
2782
|
+
(_moduleInfo = (_target___FEDERATION__2 = target.__FEDERATION__).moduleInfo) != null ? _moduleInfo : _target___FEDERATION__2.moduleInfo = {};
|
|
2783
|
+
var ___SHARE__;
|
|
2784
|
+
(___SHARE__ = (_target___FEDERATION__3 = target.__FEDERATION__).__SHARE__) != null ? ___SHARE__ : _target___FEDERATION__3.__SHARE__ = {};
|
|
2785
|
+
var ___MANIFEST_LOADING__;
|
|
2786
|
+
(___MANIFEST_LOADING__ = (_target___FEDERATION__4 = target.__FEDERATION__).__MANIFEST_LOADING__) != null ? ___MANIFEST_LOADING__ : _target___FEDERATION__4.__MANIFEST_LOADING__ = {};
|
|
2787
|
+
var ___PRELOADED_MAP__;
|
|
2788
|
+
(___PRELOADED_MAP__ = (_target___FEDERATION__5 = target.__FEDERATION__).__PRELOADED_MAP__) != null ? ___PRELOADED_MAP__ : _target___FEDERATION__5.__PRELOADED_MAP__ = new Map();
|
|
2789
|
+
}
|
|
2790
|
+
setGlobalDefaultVal(CurrentGlobal);
|
|
2791
|
+
setGlobalDefaultVal(nativeGlobal);
|
|
2792
|
+
function resetFederationGlobalInfo() {
|
|
2793
|
+
CurrentGlobal.__FEDERATION__.__GLOBAL_PLUGIN__ = [];
|
|
2794
|
+
CurrentGlobal.__FEDERATION__.__INSTANCES__ = [];
|
|
2795
|
+
CurrentGlobal.__FEDERATION__.moduleInfo = {};
|
|
2796
|
+
CurrentGlobal.__FEDERATION__.__SHARE__ = {};
|
|
2797
|
+
CurrentGlobal.__FEDERATION__.__MANIFEST_LOADING__ = {};
|
|
2798
|
+
Object.keys(globalLoading).forEach((key)=>{
|
|
2799
|
+
delete globalLoading[key];
|
|
2800
|
+
});
|
|
2801
|
+
}
|
|
2802
|
+
function setGlobalFederationInstance(FederationInstance) {
|
|
2803
|
+
CurrentGlobal.__FEDERATION__.__INSTANCES__.push(FederationInstance);
|
|
2804
|
+
}
|
|
2805
|
+
function getGlobalFederationConstructor() {
|
|
2806
|
+
return CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR__;
|
|
2807
|
+
}
|
|
2808
|
+
function setGlobalFederationConstructor(FederationConstructor, isDebug = sdk.isDebugMode()) {
|
|
2809
|
+
if (isDebug) {
|
|
2810
|
+
CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = FederationConstructor;
|
|
2811
|
+
CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.9.1";
|
|
2812
|
+
}
|
|
2813
|
+
}
|
|
2814
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
2815
|
+
function getInfoWithoutType(target, key) {
|
|
2816
|
+
if (typeof key === 'string') {
|
|
2817
|
+
const keyRes = target[key];
|
|
2818
|
+
if (keyRes) {
|
|
2819
|
+
return {
|
|
2820
|
+
value: target[key],
|
|
2821
|
+
key: key
|
|
2822
|
+
};
|
|
2823
|
+
} else {
|
|
2824
|
+
const targetKeys = Object.keys(target);
|
|
2825
|
+
for (const targetKey of targetKeys){
|
|
2826
|
+
const [targetTypeOrName, _] = targetKey.split(':');
|
|
2827
|
+
const nKey = `${targetTypeOrName}:${key}`;
|
|
2828
|
+
const typeWithKeyRes = target[nKey];
|
|
2829
|
+
if (typeWithKeyRes) {
|
|
2830
|
+
return {
|
|
2831
|
+
value: typeWithKeyRes,
|
|
2832
|
+
key: nKey
|
|
2833
|
+
};
|
|
2834
|
+
}
|
|
2835
|
+
}
|
|
2836
|
+
return {
|
|
2837
|
+
value: undefined,
|
|
2838
|
+
key: key
|
|
2839
|
+
};
|
|
2840
|
+
}
|
|
2841
|
+
} else {
|
|
2842
|
+
throw new Error('key must be string');
|
|
2843
|
+
}
|
|
2844
|
+
}
|
|
2845
|
+
const getGlobalSnapshot = ()=>nativeGlobal.__FEDERATION__.moduleInfo;
|
|
2846
|
+
const getTargetSnapshotInfoByModuleInfo = (moduleInfo, snapshot)=>{
|
|
2847
|
+
// Check if the remote is included in the hostSnapshot
|
|
2848
|
+
const moduleKey = getFMId(moduleInfo);
|
|
2849
|
+
const getModuleInfo = getInfoWithoutType(snapshot, moduleKey).value;
|
|
2850
|
+
// The remoteSnapshot might not include a version
|
|
2851
|
+
if (getModuleInfo && !getModuleInfo.version && 'version' in moduleInfo && moduleInfo['version']) {
|
|
2852
|
+
getModuleInfo.version = moduleInfo['version'];
|
|
2853
|
+
}
|
|
2854
|
+
if (getModuleInfo) {
|
|
2855
|
+
return getModuleInfo;
|
|
2856
|
+
}
|
|
2857
|
+
// If the remote is not included in the hostSnapshot, deploy a micro app snapshot
|
|
2858
|
+
if ('version' in moduleInfo && moduleInfo['version']) {
|
|
2859
|
+
const { version } = moduleInfo, resModuleInfo = polyfills._object_without_properties_loose(moduleInfo, [
|
|
2860
|
+
"version"
|
|
2861
|
+
]);
|
|
2862
|
+
const moduleKeyWithoutVersion = getFMId(resModuleInfo);
|
|
2863
|
+
const getModuleInfoWithoutVersion = getInfoWithoutType(nativeGlobal.__FEDERATION__.moduleInfo, moduleKeyWithoutVersion).value;
|
|
2864
|
+
if ((getModuleInfoWithoutVersion == null ? void 0 : getModuleInfoWithoutVersion.version) === version) {
|
|
2865
|
+
return getModuleInfoWithoutVersion;
|
|
2866
|
+
}
|
|
2867
|
+
}
|
|
2868
|
+
return;
|
|
2869
|
+
};
|
|
2870
|
+
const getGlobalSnapshotInfoByModuleInfo = (moduleInfo)=>getTargetSnapshotInfoByModuleInfo(moduleInfo, nativeGlobal.__FEDERATION__.moduleInfo);
|
|
2871
|
+
const setGlobalSnapshotInfoByModuleInfo = (remoteInfo, moduleDetailInfo)=>{
|
|
2872
|
+
const moduleKey = getFMId(remoteInfo);
|
|
2873
|
+
nativeGlobal.__FEDERATION__.moduleInfo[moduleKey] = moduleDetailInfo;
|
|
2874
|
+
return nativeGlobal.__FEDERATION__.moduleInfo;
|
|
2875
|
+
};
|
|
2876
|
+
const addGlobalSnapshot = (moduleInfos)=>{
|
|
2877
|
+
nativeGlobal.__FEDERATION__.moduleInfo = polyfills._extends({}, nativeGlobal.__FEDERATION__.moduleInfo, moduleInfos);
|
|
2878
|
+
return ()=>{
|
|
2879
|
+
const keys = Object.keys(moduleInfos);
|
|
2880
|
+
for (const key of keys){
|
|
2881
|
+
delete nativeGlobal.__FEDERATION__.moduleInfo[key];
|
|
2882
|
+
}
|
|
2883
|
+
};
|
|
2884
|
+
};
|
|
2885
|
+
const getRemoteEntryExports = (name, globalName)=>{
|
|
2886
|
+
const remoteEntryKey = globalName || `__FEDERATION_${name}:custom__`;
|
|
2887
|
+
const entryExports = CurrentGlobal[remoteEntryKey];
|
|
2888
|
+
return {
|
|
2889
|
+
remoteEntryKey,
|
|
2890
|
+
entryExports
|
|
2891
|
+
};
|
|
2892
|
+
};
|
|
2893
|
+
// This function is used to register global plugins.
|
|
2894
|
+
// It iterates over the provided plugins and checks if they are already registered.
|
|
2895
|
+
// If a plugin is not registered, it is added to the global plugins.
|
|
2896
|
+
// If a plugin is already registered, a warning message is logged.
|
|
2897
|
+
const registerGlobalPlugins = (plugins)=>{
|
|
2898
|
+
const { __GLOBAL_PLUGIN__ } = nativeGlobal.__FEDERATION__;
|
|
2899
|
+
plugins.forEach((plugin)=>{
|
|
2900
|
+
if (__GLOBAL_PLUGIN__.findIndex((p)=>p.name === plugin.name) === -1) {
|
|
2901
|
+
__GLOBAL_PLUGIN__.push(plugin);
|
|
2902
|
+
} else {
|
|
2903
|
+
warn(`The plugin ${plugin.name} has been registered.`);
|
|
2904
|
+
}
|
|
2905
|
+
});
|
|
2906
|
+
};
|
|
2907
|
+
const getGlobalHostPlugins = ()=>nativeGlobal.__FEDERATION__.__GLOBAL_PLUGIN__;
|
|
2908
|
+
const getPreloaded = (id)=>CurrentGlobal.__FEDERATION__.__PRELOADED_MAP__.get(id);
|
|
2909
|
+
const setPreloaded = (id)=>CurrentGlobal.__FEDERATION__.__PRELOADED_MAP__.set(id, true);
|
|
2910
|
+
|
|
2911
|
+
const DEFAULT_SCOPE = 'default';
|
|
2912
|
+
const DEFAULT_REMOTE_TYPE = 'global';
|
|
2913
|
+
|
|
2914
|
+
// fork from https://github.com/originjs/vite-plugin-federation/blob/v1.1.12/packages/lib/src/utils/semver/index.ts
|
|
2915
|
+
// those constants are based on https://www.rubydoc.info/gems/semantic_range/3.0.0/SemanticRange#BUILDIDENTIFIER-constant
|
|
2916
|
+
// Copyright (c)
|
|
2917
|
+
// vite-plugin-federation is licensed under Mulan PSL v2.
|
|
2918
|
+
// You can use this software according to the terms and conditions of the Mulan PSL v2.
|
|
2919
|
+
// You may obtain a copy of Mulan PSL v2 at:
|
|
2920
|
+
// http://license.coscl.org.cn/MulanPSL2
|
|
2921
|
+
// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
|
2922
|
+
// See the Mulan PSL v2 for more details.
|
|
2923
|
+
const buildIdentifier = '[0-9A-Za-z-]+';
|
|
2924
|
+
const build = `(?:\\+(${buildIdentifier}(?:\\.${buildIdentifier})*))`;
|
|
2925
|
+
const numericIdentifier = '0|[1-9]\\d*';
|
|
2926
|
+
const numericIdentifierLoose = '[0-9]+';
|
|
2927
|
+
const nonNumericIdentifier = '\\d*[a-zA-Z-][a-zA-Z0-9-]*';
|
|
2928
|
+
const preReleaseIdentifierLoose = `(?:${numericIdentifierLoose}|${nonNumericIdentifier})`;
|
|
2929
|
+
const preReleaseLoose = `(?:-?(${preReleaseIdentifierLoose}(?:\\.${preReleaseIdentifierLoose})*))`;
|
|
2930
|
+
const preReleaseIdentifier = `(?:${numericIdentifier}|${nonNumericIdentifier})`;
|
|
2931
|
+
const preRelease = `(?:-(${preReleaseIdentifier}(?:\\.${preReleaseIdentifier})*))`;
|
|
2932
|
+
const xRangeIdentifier = `${numericIdentifier}|x|X|\\*`;
|
|
2933
|
+
const xRangePlain = `[v=\\s]*(${xRangeIdentifier})(?:\\.(${xRangeIdentifier})(?:\\.(${xRangeIdentifier})(?:${preRelease})?${build}?)?)?`;
|
|
2934
|
+
const hyphenRange = `^\\s*(${xRangePlain})\\s+-\\s+(${xRangePlain})\\s*$`;
|
|
2935
|
+
const mainVersionLoose = `(${numericIdentifierLoose})\\.(${numericIdentifierLoose})\\.(${numericIdentifierLoose})`;
|
|
2936
|
+
const loosePlain = `[v=\\s]*${mainVersionLoose}${preReleaseLoose}?${build}?`;
|
|
2937
|
+
const gtlt = '((?:<|>)?=?)';
|
|
2938
|
+
const comparatorTrim = `(\\s*)${gtlt}\\s*(${loosePlain}|${xRangePlain})`;
|
|
2939
|
+
const loneTilde = '(?:~>?)';
|
|
2940
|
+
const tildeTrim = `(\\s*)${loneTilde}\\s+`;
|
|
2941
|
+
const loneCaret = '(?:\\^)';
|
|
2942
|
+
const caretTrim = `(\\s*)${loneCaret}\\s+`;
|
|
2943
|
+
const star = '(<|>)?=?\\s*\\*';
|
|
2944
|
+
const caret = `^${loneCaret}${xRangePlain}$`;
|
|
2945
|
+
const mainVersion = `(${numericIdentifier})\\.(${numericIdentifier})\\.(${numericIdentifier})`;
|
|
2946
|
+
const fullPlain = `v?${mainVersion}${preRelease}?${build}?`;
|
|
2947
|
+
const tilde = `^${loneTilde}${xRangePlain}$`;
|
|
2948
|
+
const xRange = `^${gtlt}\\s*${xRangePlain}$`;
|
|
2949
|
+
const comparator = `^${gtlt}\\s*(${fullPlain})$|^$`;
|
|
2950
|
+
// copy from semver package
|
|
2951
|
+
const gte0 = '^\\s*>=\\s*0.0.0\\s*$';
|
|
2952
|
+
|
|
2953
|
+
// fork from https://github.com/originjs/vite-plugin-federation/blob/v1.1.12/packages/lib/src/utils/semver/index.ts
|
|
2954
|
+
// Copyright (c)
|
|
2955
|
+
// vite-plugin-federation is licensed under Mulan PSL v2.
|
|
2956
|
+
// You can use this software according to the terms and conditions of the Mulan PSL v2.
|
|
2957
|
+
// You may obtain a copy of Mulan PSL v2 at:
|
|
2958
|
+
// http://license.coscl.org.cn/MulanPSL2
|
|
2959
|
+
// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
|
2960
|
+
// See the Mulan PSL v2 for more details.
|
|
2961
|
+
function parseRegex(source) {
|
|
2962
|
+
return new RegExp(source);
|
|
2963
|
+
}
|
|
2964
|
+
function isXVersion(version) {
|
|
2965
|
+
return !version || version.toLowerCase() === 'x' || version === '*';
|
|
2966
|
+
}
|
|
2967
|
+
function pipe(...fns) {
|
|
2968
|
+
return (x)=>fns.reduce((v, f)=>f(v), x);
|
|
2969
|
+
}
|
|
2970
|
+
function extractComparator(comparatorString) {
|
|
2971
|
+
return comparatorString.match(parseRegex(comparator));
|
|
2972
|
+
}
|
|
2973
|
+
function combineVersion(major, minor, patch, preRelease) {
|
|
2974
|
+
const mainVersion = `${major}.${minor}.${patch}`;
|
|
2975
|
+
if (preRelease) {
|
|
2976
|
+
return `${mainVersion}-${preRelease}`;
|
|
2977
|
+
}
|
|
2978
|
+
return mainVersion;
|
|
2979
|
+
}
|
|
2980
|
+
|
|
2981
|
+
// fork from https://github.com/originjs/vite-plugin-federation/blob/v1.1.12/packages/lib/src/utils/semver/index.ts
|
|
2982
|
+
// Copyright (c)
|
|
2983
|
+
// vite-plugin-federation is licensed under Mulan PSL v2.
|
|
2984
|
+
// You can use this software according to the terms and conditions of the Mulan PSL v2.
|
|
2985
|
+
// You may obtain a copy of Mulan PSL v2 at:
|
|
2986
|
+
// http://license.coscl.org.cn/MulanPSL2
|
|
2987
|
+
// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
|
2988
|
+
// See the Mulan PSL v2 for more details.
|
|
2989
|
+
function parseHyphen(range) {
|
|
2990
|
+
return range.replace(parseRegex(hyphenRange), (_range, from, fromMajor, fromMinor, fromPatch, _fromPreRelease, _fromBuild, to, toMajor, toMinor, toPatch, toPreRelease)=>{
|
|
2991
|
+
if (isXVersion(fromMajor)) {
|
|
2992
|
+
from = '';
|
|
2993
|
+
} else if (isXVersion(fromMinor)) {
|
|
2994
|
+
from = `>=${fromMajor}.0.0`;
|
|
2995
|
+
} else if (isXVersion(fromPatch)) {
|
|
2996
|
+
from = `>=${fromMajor}.${fromMinor}.0`;
|
|
2997
|
+
} else {
|
|
2998
|
+
from = `>=${from}`;
|
|
2999
|
+
}
|
|
3000
|
+
if (isXVersion(toMajor)) {
|
|
3001
|
+
to = '';
|
|
3002
|
+
} else if (isXVersion(toMinor)) {
|
|
3003
|
+
to = `<${Number(toMajor) + 1}.0.0-0`;
|
|
3004
|
+
} else if (isXVersion(toPatch)) {
|
|
3005
|
+
to = `<${toMajor}.${Number(toMinor) + 1}.0-0`;
|
|
3006
|
+
} else if (toPreRelease) {
|
|
3007
|
+
to = `<=${toMajor}.${toMinor}.${toPatch}-${toPreRelease}`;
|
|
3008
|
+
} else {
|
|
3009
|
+
to = `<=${to}`;
|
|
3010
|
+
}
|
|
3011
|
+
return `${from} ${to}`.trim();
|
|
3012
|
+
});
|
|
3013
|
+
}
|
|
3014
|
+
function parseComparatorTrim(range) {
|
|
3015
|
+
return range.replace(parseRegex(comparatorTrim), '$1$2$3');
|
|
3016
|
+
}
|
|
3017
|
+
function parseTildeTrim(range) {
|
|
3018
|
+
return range.replace(parseRegex(tildeTrim), '$1~');
|
|
3019
|
+
}
|
|
3020
|
+
function parseCaretTrim(range) {
|
|
3021
|
+
return range.replace(parseRegex(caretTrim), '$1^');
|
|
3022
|
+
}
|
|
3023
|
+
function parseCarets(range) {
|
|
3024
|
+
return range.trim().split(/\s+/).map((rangeVersion)=>rangeVersion.replace(parseRegex(caret), (_, major, minor, patch, preRelease)=>{
|
|
3025
|
+
if (isXVersion(major)) {
|
|
3026
|
+
return '';
|
|
3027
|
+
} else if (isXVersion(minor)) {
|
|
3028
|
+
return `>=${major}.0.0 <${Number(major) + 1}.0.0-0`;
|
|
3029
|
+
} else if (isXVersion(patch)) {
|
|
3030
|
+
if (major === '0') {
|
|
3031
|
+
return `>=${major}.${minor}.0 <${major}.${Number(minor) + 1}.0-0`;
|
|
3032
|
+
} else {
|
|
3033
|
+
return `>=${major}.${minor}.0 <${Number(major) + 1}.0.0-0`;
|
|
3034
|
+
}
|
|
3035
|
+
} else if (preRelease) {
|
|
3036
|
+
if (major === '0') {
|
|
3037
|
+
if (minor === '0') {
|
|
3038
|
+
return `>=${major}.${minor}.${patch}-${preRelease} <${major}.${minor}.${Number(patch) + 1}-0`;
|
|
3039
|
+
} else {
|
|
3040
|
+
return `>=${major}.${minor}.${patch}-${preRelease} <${major}.${Number(minor) + 1}.0-0`;
|
|
3041
|
+
}
|
|
3042
|
+
} else {
|
|
3043
|
+
return `>=${major}.${minor}.${patch}-${preRelease} <${Number(major) + 1}.0.0-0`;
|
|
3044
|
+
}
|
|
3045
|
+
} else {
|
|
3046
|
+
if (major === '0') {
|
|
3047
|
+
if (minor === '0') {
|
|
3048
|
+
return `>=${major}.${minor}.${patch} <${major}.${minor}.${Number(patch) + 1}-0`;
|
|
3049
|
+
} else {
|
|
3050
|
+
return `>=${major}.${minor}.${patch} <${major}.${Number(minor) + 1}.0-0`;
|
|
3051
|
+
}
|
|
3052
|
+
}
|
|
3053
|
+
return `>=${major}.${minor}.${patch} <${Number(major) + 1}.0.0-0`;
|
|
3054
|
+
}
|
|
3055
|
+
})).join(' ');
|
|
3056
|
+
}
|
|
3057
|
+
function parseTildes(range) {
|
|
3058
|
+
return range.trim().split(/\s+/).map((rangeVersion)=>rangeVersion.replace(parseRegex(tilde), (_, major, minor, patch, preRelease)=>{
|
|
3059
|
+
if (isXVersion(major)) {
|
|
3060
|
+
return '';
|
|
3061
|
+
} else if (isXVersion(minor)) {
|
|
3062
|
+
return `>=${major}.0.0 <${Number(major) + 1}.0.0-0`;
|
|
3063
|
+
} else if (isXVersion(patch)) {
|
|
3064
|
+
return `>=${major}.${minor}.0 <${major}.${Number(minor) + 1}.0-0`;
|
|
3065
|
+
} else if (preRelease) {
|
|
3066
|
+
return `>=${major}.${minor}.${patch}-${preRelease} <${major}.${Number(minor) + 1}.0-0`;
|
|
3067
|
+
}
|
|
3068
|
+
return `>=${major}.${minor}.${patch} <${major}.${Number(minor) + 1}.0-0`;
|
|
3069
|
+
})).join(' ');
|
|
3070
|
+
}
|
|
3071
|
+
function parseXRanges(range) {
|
|
3072
|
+
return range.split(/\s+/).map((rangeVersion)=>rangeVersion.trim().replace(parseRegex(xRange), (ret, gtlt, major, minor, patch, preRelease)=>{
|
|
3073
|
+
const isXMajor = isXVersion(major);
|
|
3074
|
+
const isXMinor = isXMajor || isXVersion(minor);
|
|
3075
|
+
const isXPatch = isXMinor || isXVersion(patch);
|
|
3076
|
+
if (gtlt === '=' && isXPatch) {
|
|
3077
|
+
gtlt = '';
|
|
3078
|
+
}
|
|
3079
|
+
preRelease = '';
|
|
3080
|
+
if (isXMajor) {
|
|
3081
|
+
if (gtlt === '>' || gtlt === '<') {
|
|
3082
|
+
// nothing is allowed
|
|
3083
|
+
return '<0.0.0-0';
|
|
3084
|
+
} else {
|
|
3085
|
+
// nothing is forbidden
|
|
3086
|
+
return '*';
|
|
3087
|
+
}
|
|
3088
|
+
} else if (gtlt && isXPatch) {
|
|
3089
|
+
// replace X with 0
|
|
3090
|
+
if (isXMinor) {
|
|
3091
|
+
minor = 0;
|
|
3092
|
+
}
|
|
3093
|
+
patch = 0;
|
|
3094
|
+
if (gtlt === '>') {
|
|
3095
|
+
// >1 => >=2.0.0
|
|
3096
|
+
// >1.2 => >=1.3.0
|
|
3097
|
+
gtlt = '>=';
|
|
3098
|
+
if (isXMinor) {
|
|
3099
|
+
major = Number(major) + 1;
|
|
3100
|
+
minor = 0;
|
|
3101
|
+
patch = 0;
|
|
3102
|
+
} else {
|
|
3103
|
+
minor = Number(minor) + 1;
|
|
3104
|
+
patch = 0;
|
|
3105
|
+
}
|
|
3106
|
+
} else if (gtlt === '<=') {
|
|
3107
|
+
// <=0.7.x is actually <0.8.0, since any 0.7.x should pass
|
|
3108
|
+
// Similarly, <=7.x is actually <8.0.0, etc.
|
|
3109
|
+
gtlt = '<';
|
|
3110
|
+
if (isXMinor) {
|
|
3111
|
+
major = Number(major) + 1;
|
|
3112
|
+
} else {
|
|
3113
|
+
minor = Number(minor) + 1;
|
|
3114
|
+
}
|
|
3115
|
+
}
|
|
3116
|
+
if (gtlt === '<') {
|
|
3117
|
+
preRelease = '-0';
|
|
3118
|
+
}
|
|
3119
|
+
return `${gtlt + major}.${minor}.${patch}${preRelease}`;
|
|
3120
|
+
} else if (isXMinor) {
|
|
3121
|
+
return `>=${major}.0.0${preRelease} <${Number(major) + 1}.0.0-0`;
|
|
3122
|
+
} else if (isXPatch) {
|
|
3123
|
+
return `>=${major}.${minor}.0${preRelease} <${major}.${Number(minor) + 1}.0-0`;
|
|
3124
|
+
}
|
|
3125
|
+
return ret;
|
|
3126
|
+
})).join(' ');
|
|
3127
|
+
}
|
|
3128
|
+
function parseStar(range) {
|
|
3129
|
+
return range.trim().replace(parseRegex(star), '');
|
|
3130
|
+
}
|
|
3131
|
+
function parseGTE0(comparatorString) {
|
|
3132
|
+
return comparatorString.trim().replace(parseRegex(gte0), '');
|
|
3133
|
+
}
|
|
3369
3134
|
|
|
3370
|
-
|
|
3371
|
-
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
|
|
3379
|
-
|
|
3380
|
-
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
|
|
3397
|
-
|
|
3398
|
-
|
|
3399
|
-
|
|
3400
|
-
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
|
|
3135
|
+
// fork from https://github.com/originjs/vite-plugin-federation/blob/v1.1.12/packages/lib/src/utils/semver/index.ts
|
|
3136
|
+
// Copyright (c)
|
|
3137
|
+
// vite-plugin-federation is licensed under Mulan PSL v2.
|
|
3138
|
+
// You can use this software according to the terms and conditions of the Mulan PSL v2.
|
|
3139
|
+
// You may obtain a copy of Mulan PSL v2 at:
|
|
3140
|
+
// http://license.coscl.org.cn/MulanPSL2
|
|
3141
|
+
// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
|
3142
|
+
// See the Mulan PSL v2 for more details.
|
|
3143
|
+
function compareAtom(rangeAtom, versionAtom) {
|
|
3144
|
+
rangeAtom = Number(rangeAtom) || rangeAtom;
|
|
3145
|
+
versionAtom = Number(versionAtom) || versionAtom;
|
|
3146
|
+
if (rangeAtom > versionAtom) {
|
|
3147
|
+
return 1;
|
|
3148
|
+
}
|
|
3149
|
+
if (rangeAtom === versionAtom) {
|
|
3150
|
+
return 0;
|
|
3151
|
+
}
|
|
3152
|
+
return -1;
|
|
3153
|
+
}
|
|
3154
|
+
function comparePreRelease(rangeAtom, versionAtom) {
|
|
3155
|
+
const { preRelease: rangePreRelease } = rangeAtom;
|
|
3156
|
+
const { preRelease: versionPreRelease } = versionAtom;
|
|
3157
|
+
if (rangePreRelease === undefined && Boolean(versionPreRelease)) {
|
|
3158
|
+
return 1;
|
|
3159
|
+
}
|
|
3160
|
+
if (Boolean(rangePreRelease) && versionPreRelease === undefined) {
|
|
3161
|
+
return -1;
|
|
3162
|
+
}
|
|
3163
|
+
if (rangePreRelease === undefined && versionPreRelease === undefined) {
|
|
3164
|
+
return 0;
|
|
3165
|
+
}
|
|
3166
|
+
for(let i = 0, n = rangePreRelease.length; i <= n; i++){
|
|
3167
|
+
const rangeElement = rangePreRelease[i];
|
|
3168
|
+
const versionElement = versionPreRelease[i];
|
|
3169
|
+
if (rangeElement === versionElement) {
|
|
3170
|
+
continue;
|
|
3171
|
+
}
|
|
3172
|
+
if (rangeElement === undefined && versionElement === undefined) {
|
|
3173
|
+
return 0;
|
|
3174
|
+
}
|
|
3175
|
+
if (!rangeElement) {
|
|
3176
|
+
return 1;
|
|
3177
|
+
}
|
|
3178
|
+
if (!versionElement) {
|
|
3179
|
+
return -1;
|
|
3180
|
+
}
|
|
3181
|
+
return compareAtom(rangeElement, versionElement);
|
|
3182
|
+
}
|
|
3183
|
+
return 0;
|
|
3184
|
+
}
|
|
3185
|
+
function compareVersion(rangeAtom, versionAtom) {
|
|
3186
|
+
return compareAtom(rangeAtom.major, versionAtom.major) || compareAtom(rangeAtom.minor, versionAtom.minor) || compareAtom(rangeAtom.patch, versionAtom.patch) || comparePreRelease(rangeAtom, versionAtom);
|
|
3187
|
+
}
|
|
3188
|
+
function eq(rangeAtom, versionAtom) {
|
|
3189
|
+
return rangeAtom.version === versionAtom.version;
|
|
3190
|
+
}
|
|
3191
|
+
function compare(rangeAtom, versionAtom) {
|
|
3192
|
+
switch(rangeAtom.operator){
|
|
3193
|
+
case '':
|
|
3194
|
+
case '=':
|
|
3195
|
+
return eq(rangeAtom, versionAtom);
|
|
3196
|
+
case '>':
|
|
3197
|
+
return compareVersion(rangeAtom, versionAtom) < 0;
|
|
3198
|
+
case '>=':
|
|
3199
|
+
return eq(rangeAtom, versionAtom) || compareVersion(rangeAtom, versionAtom) < 0;
|
|
3200
|
+
case '<':
|
|
3201
|
+
return compareVersion(rangeAtom, versionAtom) > 0;
|
|
3202
|
+
case '<=':
|
|
3203
|
+
return eq(rangeAtom, versionAtom) || compareVersion(rangeAtom, versionAtom) > 0;
|
|
3204
|
+
case undefined:
|
|
3205
|
+
{
|
|
3206
|
+
// mean * or x -> all versions
|
|
3207
|
+
return true;
|
|
3208
|
+
}
|
|
3209
|
+
default:
|
|
3210
|
+
return false;
|
|
3211
|
+
}
|
|
3212
|
+
}
|
|
3407
3213
|
|
|
3408
|
-
|
|
3214
|
+
// fork from https://github.com/originjs/vite-plugin-federation/blob/v1.1.12/packages/lib/src/utils/semver/index.ts
|
|
3215
|
+
// Copyright (c)
|
|
3216
|
+
// vite-plugin-federation is licensed under Mulan PSL v2.
|
|
3217
|
+
// You can use this software according to the terms and conditions of the Mulan PSL v2.
|
|
3218
|
+
// You may obtain a copy of Mulan PSL v2 at:
|
|
3219
|
+
// http://license.coscl.org.cn/MulanPSL2
|
|
3220
|
+
// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
|
3221
|
+
// See the Mulan PSL v2 for more details.
|
|
3222
|
+
function parseComparatorString(range) {
|
|
3223
|
+
return pipe(// handle caret
|
|
3224
|
+
// ^ --> * (any, kinda silly)
|
|
3225
|
+
// ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0-0
|
|
3226
|
+
// ^2.0, ^2.0.x --> >=2.0.0 <3.0.0-0
|
|
3227
|
+
// ^1.2, ^1.2.x --> >=1.2.0 <2.0.0-0
|
|
3228
|
+
// ^1.2.3 --> >=1.2.3 <2.0.0-0
|
|
3229
|
+
// ^1.2.0 --> >=1.2.0 <2.0.0-0
|
|
3230
|
+
parseCarets, // handle tilde
|
|
3231
|
+
// ~, ~> --> * (any, kinda silly)
|
|
3232
|
+
// ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0-0
|
|
3233
|
+
// ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0-0
|
|
3234
|
+
// ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0-0
|
|
3235
|
+
// ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0-0
|
|
3236
|
+
// ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0-0
|
|
3237
|
+
parseTildes, parseXRanges, parseStar)(range);
|
|
3238
|
+
}
|
|
3239
|
+
function parseRange(range) {
|
|
3240
|
+
return pipe(// handle hyphenRange
|
|
3241
|
+
// `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4`
|
|
3242
|
+
parseHyphen, // handle trim comparator
|
|
3243
|
+
// `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5`
|
|
3244
|
+
parseComparatorTrim, // handle trim tilde
|
|
3245
|
+
// `~ 1.2.3` => `~1.2.3`
|
|
3246
|
+
parseTildeTrim, // handle trim caret
|
|
3247
|
+
// `^ 1.2.3` => `^1.2.3`
|
|
3248
|
+
parseCaretTrim)(range.trim()).split(/\s+/).join(' ');
|
|
3249
|
+
}
|
|
3250
|
+
function satisfy(version, range) {
|
|
3251
|
+
if (!version) {
|
|
3252
|
+
return false;
|
|
3253
|
+
}
|
|
3254
|
+
const parsedRange = parseRange(range);
|
|
3255
|
+
const parsedComparator = parsedRange.split(' ').map((rangeVersion)=>parseComparatorString(rangeVersion)).join(' ');
|
|
3256
|
+
const comparators = parsedComparator.split(/\s+/).map((comparator)=>parseGTE0(comparator));
|
|
3257
|
+
const extractedVersion = extractComparator(version);
|
|
3258
|
+
if (!extractedVersion) {
|
|
3259
|
+
return false;
|
|
3260
|
+
}
|
|
3261
|
+
const [, versionOperator, , versionMajor, versionMinor, versionPatch, versionPreRelease] = extractedVersion;
|
|
3262
|
+
const versionAtom = {
|
|
3263
|
+
version: combineVersion(versionMajor, versionMinor, versionPatch, versionPreRelease),
|
|
3264
|
+
major: versionMajor,
|
|
3265
|
+
minor: versionMinor,
|
|
3266
|
+
patch: versionPatch,
|
|
3267
|
+
preRelease: versionPreRelease == null ? void 0 : versionPreRelease.split('.')
|
|
3268
|
+
};
|
|
3269
|
+
for (const comparator of comparators){
|
|
3270
|
+
const extractedComparator = extractComparator(comparator);
|
|
3271
|
+
if (!extractedComparator) {
|
|
3272
|
+
return false;
|
|
3273
|
+
}
|
|
3274
|
+
const [, rangeOperator, , rangeMajor, rangeMinor, rangePatch, rangePreRelease] = extractedComparator;
|
|
3275
|
+
const rangeAtom = {
|
|
3276
|
+
operator: rangeOperator,
|
|
3277
|
+
version: combineVersion(rangeMajor, rangeMinor, rangePatch, rangePreRelease),
|
|
3278
|
+
major: rangeMajor,
|
|
3279
|
+
minor: rangeMinor,
|
|
3280
|
+
patch: rangePatch,
|
|
3281
|
+
preRelease: rangePreRelease == null ? void 0 : rangePreRelease.split('.')
|
|
3282
|
+
};
|
|
3283
|
+
if (!compare(rangeAtom, versionAtom)) {
|
|
3284
|
+
return false; // early return
|
|
3285
|
+
}
|
|
3286
|
+
}
|
|
3287
|
+
return true;
|
|
3288
|
+
}
|
|
3409
3289
|
|
|
3410
|
-
|
|
3290
|
+
function formatShare(shareArgs, from, name, shareStrategy) {
|
|
3291
|
+
let get;
|
|
3292
|
+
if ('get' in shareArgs) {
|
|
3293
|
+
// eslint-disable-next-line prefer-destructuring
|
|
3294
|
+
get = shareArgs.get;
|
|
3295
|
+
} else if ('lib' in shareArgs) {
|
|
3296
|
+
get = ()=>Promise.resolve(shareArgs.lib);
|
|
3297
|
+
} else {
|
|
3298
|
+
get = ()=>Promise.resolve(()=>{
|
|
3299
|
+
throw new Error(`Can not get shared '${name}'!`);
|
|
3300
|
+
});
|
|
3301
|
+
}
|
|
3302
|
+
if (shareArgs.strategy) {
|
|
3303
|
+
warn(`"shared.strategy is deprecated, please set in initOptions.shareStrategy instead!"`);
|
|
3304
|
+
}
|
|
3305
|
+
var _shareArgs_version, _shareArgs_scope, _shareArgs_strategy;
|
|
3306
|
+
return polyfills._extends({
|
|
3307
|
+
deps: [],
|
|
3308
|
+
useIn: [],
|
|
3309
|
+
from,
|
|
3310
|
+
loading: null
|
|
3311
|
+
}, shareArgs, {
|
|
3312
|
+
shareConfig: polyfills._extends({
|
|
3313
|
+
requiredVersion: `^${shareArgs.version}`,
|
|
3314
|
+
singleton: false,
|
|
3315
|
+
eager: false,
|
|
3316
|
+
strictVersion: false
|
|
3317
|
+
}, shareArgs.shareConfig),
|
|
3318
|
+
get,
|
|
3319
|
+
loaded: (shareArgs == null ? void 0 : shareArgs.loaded) || 'lib' in shareArgs ? true : undefined,
|
|
3320
|
+
version: (_shareArgs_version = shareArgs.version) != null ? _shareArgs_version : '0',
|
|
3321
|
+
scope: Array.isArray(shareArgs.scope) ? shareArgs.scope : [
|
|
3322
|
+
(_shareArgs_scope = shareArgs.scope) != null ? _shareArgs_scope : 'default'
|
|
3323
|
+
],
|
|
3324
|
+
strategy: ((_shareArgs_strategy = shareArgs.strategy) != null ? _shareArgs_strategy : shareStrategy) || 'version-first'
|
|
3325
|
+
});
|
|
3326
|
+
}
|
|
3327
|
+
function formatShareConfigs(globalOptions, userOptions) {
|
|
3328
|
+
const shareArgs = userOptions.shared || {};
|
|
3329
|
+
const from = userOptions.name;
|
|
3330
|
+
const shareInfos = Object.keys(shareArgs).reduce((res, pkgName)=>{
|
|
3331
|
+
const arrayShareArgs = arrayOptions(shareArgs[pkgName]);
|
|
3332
|
+
res[pkgName] = res[pkgName] || [];
|
|
3333
|
+
arrayShareArgs.forEach((shareConfig)=>{
|
|
3334
|
+
res[pkgName].push(formatShare(shareConfig, from, pkgName, userOptions.shareStrategy));
|
|
3335
|
+
});
|
|
3336
|
+
return res;
|
|
3337
|
+
}, {});
|
|
3338
|
+
const shared = polyfills._extends({}, globalOptions.shared);
|
|
3339
|
+
Object.keys(shareInfos).forEach((shareKey)=>{
|
|
3340
|
+
if (!shared[shareKey]) {
|
|
3341
|
+
shared[shareKey] = shareInfos[shareKey];
|
|
3342
|
+
} else {
|
|
3343
|
+
shareInfos[shareKey].forEach((newUserSharedOptions)=>{
|
|
3344
|
+
const isSameVersion = shared[shareKey].find((sharedVal)=>sharedVal.version === newUserSharedOptions.version);
|
|
3345
|
+
if (!isSameVersion) {
|
|
3346
|
+
shared[shareKey].push(newUserSharedOptions);
|
|
3347
|
+
}
|
|
3348
|
+
});
|
|
3349
|
+
}
|
|
3350
|
+
});
|
|
3351
|
+
return {
|
|
3352
|
+
shared,
|
|
3353
|
+
shareInfos
|
|
3354
|
+
};
|
|
3355
|
+
}
|
|
3356
|
+
function versionLt(a, b) {
|
|
3357
|
+
const transformInvalidVersion = (version)=>{
|
|
3358
|
+
const isNumberVersion = !Number.isNaN(Number(version));
|
|
3359
|
+
if (isNumberVersion) {
|
|
3360
|
+
const splitArr = version.split('.');
|
|
3361
|
+
let validVersion = version;
|
|
3362
|
+
for(let i = 0; i < 3 - splitArr.length; i++){
|
|
3363
|
+
validVersion += '.0';
|
|
3364
|
+
}
|
|
3365
|
+
return validVersion;
|
|
3366
|
+
}
|
|
3367
|
+
return version;
|
|
3368
|
+
};
|
|
3369
|
+
if (satisfy(transformInvalidVersion(a), `<=${transformInvalidVersion(b)}`)) {
|
|
3370
|
+
return true;
|
|
3371
|
+
} else {
|
|
3372
|
+
return false;
|
|
3373
|
+
}
|
|
3374
|
+
}
|
|
3375
|
+
const findVersion = (shareVersionMap, cb)=>{
|
|
3376
|
+
const callback = cb || function(prev, cur) {
|
|
3377
|
+
return versionLt(prev, cur);
|
|
3378
|
+
};
|
|
3379
|
+
return Object.keys(shareVersionMap).reduce((prev, cur)=>{
|
|
3380
|
+
if (!prev) {
|
|
3381
|
+
return cur;
|
|
3382
|
+
}
|
|
3383
|
+
if (callback(prev, cur)) {
|
|
3384
|
+
return cur;
|
|
3385
|
+
}
|
|
3386
|
+
// default version is '0' https://github.com/webpack/webpack/blob/main/lib/sharing/ProvideSharedModule.js#L136
|
|
3387
|
+
if (prev === '0') {
|
|
3388
|
+
return cur;
|
|
3389
|
+
}
|
|
3390
|
+
return prev;
|
|
3391
|
+
}, 0);
|
|
3392
|
+
};
|
|
3393
|
+
const isLoaded = (shared)=>{
|
|
3394
|
+
return Boolean(shared.loaded) || typeof shared.lib === 'function';
|
|
3395
|
+
};
|
|
3396
|
+
const isLoading = (shared)=>{
|
|
3397
|
+
return Boolean(shared.loading);
|
|
3398
|
+
};
|
|
3399
|
+
function findSingletonVersionOrderByVersion(shareScopeMap, scope, pkgName) {
|
|
3400
|
+
const versions = shareScopeMap[scope][pkgName];
|
|
3401
|
+
const callback = function(prev, cur) {
|
|
3402
|
+
return !isLoaded(versions[prev]) && versionLt(prev, cur);
|
|
3403
|
+
};
|
|
3404
|
+
return findVersion(shareScopeMap[scope][pkgName], callback);
|
|
3405
|
+
}
|
|
3406
|
+
function findSingletonVersionOrderByLoaded(shareScopeMap, scope, pkgName) {
|
|
3407
|
+
const versions = shareScopeMap[scope][pkgName];
|
|
3408
|
+
const callback = function(prev, cur) {
|
|
3409
|
+
const isLoadingOrLoaded = (shared)=>{
|
|
3410
|
+
return isLoaded(shared) || isLoading(shared);
|
|
3411
|
+
};
|
|
3412
|
+
if (isLoadingOrLoaded(versions[cur])) {
|
|
3413
|
+
if (isLoadingOrLoaded(versions[prev])) {
|
|
3414
|
+
return Boolean(versionLt(prev, cur));
|
|
3415
|
+
} else {
|
|
3416
|
+
return true;
|
|
3417
|
+
}
|
|
3418
|
+
}
|
|
3419
|
+
if (isLoadingOrLoaded(versions[prev])) {
|
|
3420
|
+
return false;
|
|
3421
|
+
}
|
|
3422
|
+
return versionLt(prev, cur);
|
|
3423
|
+
};
|
|
3424
|
+
return findVersion(shareScopeMap[scope][pkgName], callback);
|
|
3425
|
+
}
|
|
3426
|
+
function getFindShareFunction(strategy) {
|
|
3427
|
+
if (strategy === 'loaded-first') {
|
|
3428
|
+
return findSingletonVersionOrderByLoaded;
|
|
3429
|
+
}
|
|
3430
|
+
return findSingletonVersionOrderByVersion;
|
|
3431
|
+
}
|
|
3432
|
+
function getRegisteredShare(localShareScopeMap, pkgName, shareInfo, resolveShare) {
|
|
3433
|
+
if (!localShareScopeMap) {
|
|
3434
|
+
return;
|
|
3435
|
+
}
|
|
3436
|
+
const { shareConfig, scope = DEFAULT_SCOPE, strategy } = shareInfo;
|
|
3437
|
+
const scopes = Array.isArray(scope) ? scope : [
|
|
3438
|
+
scope
|
|
3439
|
+
];
|
|
3440
|
+
for (const sc of scopes){
|
|
3441
|
+
if (shareConfig && localShareScopeMap[sc] && localShareScopeMap[sc][pkgName]) {
|
|
3442
|
+
const { requiredVersion } = shareConfig;
|
|
3443
|
+
const findShareFunction = getFindShareFunction(strategy);
|
|
3444
|
+
const maxOrSingletonVersion = findShareFunction(localShareScopeMap, sc, pkgName);
|
|
3445
|
+
//@ts-ignore
|
|
3446
|
+
const defaultResolver = ()=>{
|
|
3447
|
+
if (shareConfig.singleton) {
|
|
3448
|
+
if (typeof requiredVersion === 'string' && !satisfy(maxOrSingletonVersion, requiredVersion)) {
|
|
3449
|
+
const msg = `Version ${maxOrSingletonVersion} from ${maxOrSingletonVersion && localShareScopeMap[sc][pkgName][maxOrSingletonVersion].from} of shared singleton module ${pkgName} does not satisfy the requirement of ${shareInfo.from} which needs ${requiredVersion})`;
|
|
3450
|
+
if (shareConfig.strictVersion) {
|
|
3451
|
+
error(msg);
|
|
3452
|
+
} else {
|
|
3453
|
+
warn(msg);
|
|
3454
|
+
}
|
|
3455
|
+
}
|
|
3456
|
+
return localShareScopeMap[sc][pkgName][maxOrSingletonVersion];
|
|
3457
|
+
} else {
|
|
3458
|
+
if (requiredVersion === false || requiredVersion === '*') {
|
|
3459
|
+
return localShareScopeMap[sc][pkgName][maxOrSingletonVersion];
|
|
3460
|
+
}
|
|
3461
|
+
if (satisfy(maxOrSingletonVersion, requiredVersion)) {
|
|
3462
|
+
return localShareScopeMap[sc][pkgName][maxOrSingletonVersion];
|
|
3463
|
+
}
|
|
3464
|
+
for (const [versionKey, versionValue] of Object.entries(localShareScopeMap[sc][pkgName])){
|
|
3465
|
+
if (satisfy(versionKey, requiredVersion)) {
|
|
3466
|
+
return versionValue;
|
|
3467
|
+
}
|
|
3468
|
+
}
|
|
3469
|
+
}
|
|
3470
|
+
};
|
|
3471
|
+
const params = {
|
|
3472
|
+
shareScopeMap: localShareScopeMap,
|
|
3473
|
+
scope: sc,
|
|
3474
|
+
pkgName,
|
|
3475
|
+
version: maxOrSingletonVersion,
|
|
3476
|
+
GlobalFederation: Global.__FEDERATION__,
|
|
3477
|
+
resolver: defaultResolver
|
|
3478
|
+
};
|
|
3479
|
+
const resolveShared = resolveShare.emit(params) || params;
|
|
3480
|
+
return resolveShared.resolver();
|
|
3481
|
+
}
|
|
3482
|
+
}
|
|
3483
|
+
}
|
|
3484
|
+
function getGlobalShareScope() {
|
|
3485
|
+
return Global.__FEDERATION__.__SHARE__;
|
|
3486
|
+
}
|
|
3487
|
+
function getTargetSharedOptions(options) {
|
|
3488
|
+
const { pkgName, extraOptions, shareInfos } = options;
|
|
3489
|
+
const defaultResolver = (sharedOptions)=>{
|
|
3490
|
+
if (!sharedOptions) {
|
|
3491
|
+
return undefined;
|
|
3492
|
+
}
|
|
3493
|
+
const shareVersionMap = {};
|
|
3494
|
+
sharedOptions.forEach((shared)=>{
|
|
3495
|
+
shareVersionMap[shared.version] = shared;
|
|
3496
|
+
});
|
|
3497
|
+
const callback = function(prev, cur) {
|
|
3498
|
+
return !isLoaded(shareVersionMap[prev]) && versionLt(prev, cur);
|
|
3499
|
+
};
|
|
3500
|
+
const maxVersion = findVersion(shareVersionMap, callback);
|
|
3501
|
+
return shareVersionMap[maxVersion];
|
|
3502
|
+
};
|
|
3503
|
+
var _extraOptions_resolver;
|
|
3504
|
+
const resolver = (_extraOptions_resolver = extraOptions == null ? void 0 : extraOptions.resolver) != null ? _extraOptions_resolver : defaultResolver;
|
|
3505
|
+
return Object.assign({}, resolver(shareInfos[pkgName]), extraOptions == null ? void 0 : extraOptions.customShareInfo);
|
|
3506
|
+
}
|
|
3411
3507
|
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
|
|
3508
|
+
const ShareUtils = {
|
|
3509
|
+
getRegisteredShare,
|
|
3510
|
+
getGlobalShareScope
|
|
3511
|
+
};
|
|
3512
|
+
const GlobalUtils = {
|
|
3513
|
+
Global,
|
|
3514
|
+
nativeGlobal,
|
|
3515
|
+
resetFederationGlobalInfo,
|
|
3516
|
+
setGlobalFederationInstance,
|
|
3517
|
+
getGlobalFederationConstructor,
|
|
3518
|
+
setGlobalFederationConstructor,
|
|
3519
|
+
getInfoWithoutType,
|
|
3520
|
+
getGlobalSnapshot,
|
|
3521
|
+
getTargetSnapshotInfoByModuleInfo,
|
|
3522
|
+
getGlobalSnapshotInfoByModuleInfo,
|
|
3523
|
+
setGlobalSnapshotInfoByModuleInfo,
|
|
3524
|
+
addGlobalSnapshot,
|
|
3525
|
+
getRemoteEntryExports,
|
|
3526
|
+
registerGlobalPlugins,
|
|
3527
|
+
getGlobalHostPlugins,
|
|
3528
|
+
getPreloaded,
|
|
3529
|
+
setPreloaded
|
|
3530
|
+
};
|
|
3531
|
+
var helpers = {
|
|
3532
|
+
global: GlobalUtils,
|
|
3533
|
+
share: ShareUtils
|
|
3534
|
+
};
|
|
3535
|
+
|
|
3536
|
+
function getBuilderId() {
|
|
3537
|
+
//@ts-ignore
|
|
3538
|
+
return typeof FEDERATION_BUILD_IDENTIFIER !== 'undefined' ? FEDERATION_BUILD_IDENTIFIER : '';
|
|
3539
|
+
}
|
|
3415
3540
|
|
|
3416
3541
|
// Function to match a remote with its name and expose
|
|
3417
3542
|
// id: pkgName(@federation/app1) + expose(button) = @federation/app1/button
|
|
@@ -3477,8 +3602,8 @@ share_cjs.warn = warn;
|
|
|
3477
3602
|
return;
|
|
3478
3603
|
}
|
|
3479
3604
|
|
|
3480
|
-
function registerPlugins
|
|
3481
|
-
const globalPlugins =
|
|
3605
|
+
function registerPlugins(plugins, hookInstances) {
|
|
3606
|
+
const globalPlugins = getGlobalHostPlugins();
|
|
3482
3607
|
// Incorporate global plugins
|
|
3483
3608
|
if (globalPlugins.length > 0) {
|
|
3484
3609
|
globalPlugins.forEach((plugin)=>{
|
|
@@ -3501,11 +3626,14 @@ share_cjs.warn = warn;
|
|
|
3501
3626
|
return new Promise((resolve, reject)=>{
|
|
3502
3627
|
try {
|
|
3503
3628
|
if (!remoteEntryExports) {
|
|
3504
|
-
|
|
3505
|
-
|
|
3506
|
-
|
|
3507
|
-
|
|
3508
|
-
|
|
3629
|
+
if (typeof FEDERATION_ALLOW_NEW_FUNCTION !== 'undefined') {
|
|
3630
|
+
new Function('callbacks', `import("${entry}").then(callbacks[0]).catch(callbacks[1])`)([
|
|
3631
|
+
resolve,
|
|
3632
|
+
reject
|
|
3633
|
+
]);
|
|
3634
|
+
} else {
|
|
3635
|
+
import(/* webpackIgnore: true */ /* @vite-ignore */ entry).then(resolve).catch(reject);
|
|
3636
|
+
}
|
|
3509
3637
|
} else {
|
|
3510
3638
|
resolve(remoteEntryExports);
|
|
3511
3639
|
}
|
|
@@ -3518,11 +3646,16 @@ share_cjs.warn = warn;
|
|
|
3518
3646
|
return new Promise((resolve, reject)=>{
|
|
3519
3647
|
try {
|
|
3520
3648
|
if (!remoteEntryExports) {
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
|
|
3524
|
-
reject
|
|
3525
|
-
|
|
3649
|
+
//@ts-ignore
|
|
3650
|
+
if (typeof __system_context__ === 'undefined') {
|
|
3651
|
+
//@ts-ignore
|
|
3652
|
+
System.import(entry).then(resolve).catch(reject);
|
|
3653
|
+
} else {
|
|
3654
|
+
new Function('callbacks', `System.import("${entry}").then(callbacks[0]).catch(callbacks[1])`)([
|
|
3655
|
+
resolve,
|
|
3656
|
+
reject
|
|
3657
|
+
]);
|
|
3658
|
+
}
|
|
3526
3659
|
} else {
|
|
3527
3660
|
resolve(remoteEntryExports);
|
|
3528
3661
|
}
|
|
@@ -3531,15 +3664,15 @@ share_cjs.warn = warn;
|
|
|
3531
3664
|
}
|
|
3532
3665
|
});
|
|
3533
3666
|
}
|
|
3534
|
-
async function loadEntryScript({ name, globalName, entry,
|
|
3535
|
-
const { entryExports: remoteEntryExports } =
|
|
3667
|
+
async function loadEntryScript({ name, globalName, entry, loaderHook }) {
|
|
3668
|
+
const { entryExports: remoteEntryExports } = getRemoteEntryExports(name, globalName);
|
|
3536
3669
|
if (remoteEntryExports) {
|
|
3537
3670
|
return remoteEntryExports;
|
|
3538
3671
|
}
|
|
3539
3672
|
return sdk.loadScript(entry, {
|
|
3540
3673
|
attrs: {},
|
|
3541
3674
|
createScriptHook: (url, attrs)=>{
|
|
3542
|
-
const res =
|
|
3675
|
+
const res = loaderHook.lifecycle.createScript.emit({
|
|
3543
3676
|
url,
|
|
3544
3677
|
attrs
|
|
3545
3678
|
});
|
|
@@ -3553,19 +3686,22 @@ share_cjs.warn = warn;
|
|
|
3553
3686
|
return;
|
|
3554
3687
|
}
|
|
3555
3688
|
}).then(()=>{
|
|
3556
|
-
const { remoteEntryKey, entryExports } =
|
|
3557
|
-
|
|
3558
|
-
|
|
3559
|
-
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
`);
|
|
3689
|
+
const { remoteEntryKey, entryExports } = getRemoteEntryExports(name, globalName);
|
|
3690
|
+
assert(entryExports, errorCodes.getShortErrorMsg(errorCodes.RUNTIME_001, errorCodes.runtimeDescMap, {
|
|
3691
|
+
remoteName: name,
|
|
3692
|
+
remoteEntryUrl: entry,
|
|
3693
|
+
remoteEntryKey
|
|
3694
|
+
}));
|
|
3563
3695
|
return entryExports;
|
|
3564
3696
|
}).catch((e)=>{
|
|
3697
|
+
assert(undefined, errorCodes.getShortErrorMsg(errorCodes.RUNTIME_008, errorCodes.runtimeDescMap, {
|
|
3698
|
+
remoteName: name,
|
|
3699
|
+
resourceUrl: entry
|
|
3700
|
+
}));
|
|
3565
3701
|
throw e;
|
|
3566
3702
|
});
|
|
3567
3703
|
}
|
|
3568
|
-
async function loadEntryDom({ remoteInfo, remoteEntryExports,
|
|
3704
|
+
async function loadEntryDom({ remoteInfo, remoteEntryExports, loaderHook }) {
|
|
3569
3705
|
const { entry, entryGlobalName: globalName, name, type } = remoteInfo;
|
|
3570
3706
|
switch(type){
|
|
3571
3707
|
case 'esm':
|
|
@@ -3584,40 +3720,42 @@ share_cjs.warn = warn;
|
|
|
3584
3720
|
entry,
|
|
3585
3721
|
globalName,
|
|
3586
3722
|
name,
|
|
3587
|
-
|
|
3723
|
+
loaderHook
|
|
3588
3724
|
});
|
|
3589
3725
|
}
|
|
3590
3726
|
}
|
|
3591
|
-
async function loadEntryNode({ remoteInfo,
|
|
3592
|
-
const { entry, entryGlobalName: globalName, name } = remoteInfo;
|
|
3593
|
-
const { entryExports: remoteEntryExports } =
|
|
3727
|
+
async function loadEntryNode({ remoteInfo, loaderHook }) {
|
|
3728
|
+
const { entry, entryGlobalName: globalName, name, type } = remoteInfo;
|
|
3729
|
+
const { entryExports: remoteEntryExports } = getRemoteEntryExports(name, globalName);
|
|
3594
3730
|
if (remoteEntryExports) {
|
|
3595
3731
|
return remoteEntryExports;
|
|
3596
3732
|
}
|
|
3597
3733
|
return sdk.loadScriptNode(entry, {
|
|
3598
3734
|
attrs: {
|
|
3599
3735
|
name,
|
|
3600
|
-
globalName
|
|
3736
|
+
globalName,
|
|
3737
|
+
type
|
|
3601
3738
|
},
|
|
3602
|
-
|
|
3603
|
-
|
|
3604
|
-
|
|
3605
|
-
|
|
3606
|
-
|
|
3607
|
-
|
|
3608
|
-
|
|
3609
|
-
|
|
3739
|
+
loaderHook: {
|
|
3740
|
+
createScriptHook: (url, attrs = {})=>{
|
|
3741
|
+
const res = loaderHook.lifecycle.createScript.emit({
|
|
3742
|
+
url,
|
|
3743
|
+
attrs
|
|
3744
|
+
});
|
|
3745
|
+
if (!res) return;
|
|
3746
|
+
if ('url' in res) {
|
|
3747
|
+
return res;
|
|
3748
|
+
}
|
|
3749
|
+
return;
|
|
3610
3750
|
}
|
|
3611
|
-
return;
|
|
3612
3751
|
}
|
|
3613
3752
|
}).then(()=>{
|
|
3614
|
-
const { remoteEntryKey, entryExports } =
|
|
3615
|
-
|
|
3616
|
-
|
|
3617
|
-
|
|
3618
|
-
|
|
3619
|
-
|
|
3620
|
-
`);
|
|
3753
|
+
const { remoteEntryKey, entryExports } = getRemoteEntryExports(name, globalName);
|
|
3754
|
+
assert(entryExports, errorCodes.getShortErrorMsg(errorCodes.RUNTIME_001, errorCodes.runtimeDescMap, {
|
|
3755
|
+
remoteName: name,
|
|
3756
|
+
remoteEntryUrl: entry,
|
|
3757
|
+
remoteEntryKey
|
|
3758
|
+
}));
|
|
3621
3759
|
return entryExports;
|
|
3622
3760
|
}).catch((e)=>{
|
|
3623
3761
|
throw e;
|
|
@@ -3632,38 +3770,35 @@ share_cjs.warn = warn;
|
|
|
3632
3770
|
if (remoteEntryExports) {
|
|
3633
3771
|
return remoteEntryExports;
|
|
3634
3772
|
}
|
|
3635
|
-
if (!
|
|
3773
|
+
if (!globalLoading[uniqueKey]) {
|
|
3636
3774
|
const loadEntryHook = origin.remoteHandler.hooks.lifecycle.loadEntry;
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
|
|
3641
|
-
|
|
3642
|
-
|
|
3643
|
-
|
|
3644
|
-
|
|
3645
|
-
if (!sdk.isBrowserEnv()) {
|
|
3646
|
-
share.globalLoading[uniqueKey] = loadEntryNode({
|
|
3647
|
-
remoteInfo,
|
|
3648
|
-
createScriptHook
|
|
3649
|
-
});
|
|
3650
|
-
} else {
|
|
3651
|
-
share.globalLoading[uniqueKey] = loadEntryDom({
|
|
3652
|
-
remoteInfo,
|
|
3653
|
-
remoteEntryExports,
|
|
3654
|
-
createScriptHook
|
|
3655
|
-
});
|
|
3775
|
+
const loaderHook = origin.loaderHook;
|
|
3776
|
+
globalLoading[uniqueKey] = loadEntryHook.emit({
|
|
3777
|
+
loaderHook,
|
|
3778
|
+
remoteInfo,
|
|
3779
|
+
remoteEntryExports
|
|
3780
|
+
}).then((res)=>{
|
|
3781
|
+
if (res) {
|
|
3782
|
+
return res;
|
|
3656
3783
|
}
|
|
3657
|
-
|
|
3784
|
+
return sdk.isBrowserEnv() ? loadEntryDom({
|
|
3785
|
+
remoteInfo,
|
|
3786
|
+
remoteEntryExports,
|
|
3787
|
+
loaderHook
|
|
3788
|
+
}) : loadEntryNode({
|
|
3789
|
+
remoteInfo,
|
|
3790
|
+
loaderHook
|
|
3791
|
+
});
|
|
3792
|
+
});
|
|
3658
3793
|
}
|
|
3659
|
-
return
|
|
3794
|
+
return globalLoading[uniqueKey];
|
|
3660
3795
|
}
|
|
3661
3796
|
function getRemoteInfo(remote) {
|
|
3662
3797
|
return polyfills._extends({}, remote, {
|
|
3663
3798
|
entry: 'entry' in remote ? remote.entry : '',
|
|
3664
|
-
type: remote.type ||
|
|
3799
|
+
type: remote.type || DEFAULT_REMOTE_TYPE,
|
|
3665
3800
|
entryGlobalName: remote.entryGlobalName || remote.name,
|
|
3666
|
-
shareScope: remote.shareScope ||
|
|
3801
|
+
shareScope: remote.shareScope || DEFAULT_SCOPE
|
|
3667
3802
|
});
|
|
3668
3803
|
}
|
|
3669
3804
|
|
|
@@ -3672,13 +3807,25 @@ share_cjs.warn = warn;
|
|
|
3672
3807
|
if (this.remoteEntryExports) {
|
|
3673
3808
|
return this.remoteEntryExports;
|
|
3674
3809
|
}
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3810
|
+
let remoteEntryExports;
|
|
3811
|
+
try {
|
|
3812
|
+
remoteEntryExports = await getRemoteEntry({
|
|
3813
|
+
origin: this.host,
|
|
3814
|
+
remoteInfo: this.remoteInfo,
|
|
3815
|
+
remoteEntryExports: this.remoteEntryExports
|
|
3816
|
+
});
|
|
3817
|
+
} catch (err) {
|
|
3818
|
+
const uniqueKey = getRemoteEntryUniqueKey(this.remoteInfo);
|
|
3819
|
+
remoteEntryExports = await this.host.loaderHook.lifecycle.loadEntryError.emit({
|
|
3820
|
+
getRemoteEntry,
|
|
3821
|
+
origin: this.host,
|
|
3822
|
+
remoteInfo: this.remoteInfo,
|
|
3823
|
+
remoteEntryExports: this.remoteEntryExports,
|
|
3824
|
+
globalLoading,
|
|
3825
|
+
uniqueKey
|
|
3826
|
+
});
|
|
3827
|
+
}
|
|
3828
|
+
assert(remoteEntryExports, `remoteEntryExports is undefined \n ${sdk.safeToString(this.remoteInfo)}`);
|
|
3682
3829
|
this.remoteEntryExports = remoteEntryExports;
|
|
3683
3830
|
return this.remoteEntryExports;
|
|
3684
3831
|
}
|
|
@@ -3715,7 +3862,11 @@ share_cjs.warn = warn;
|
|
|
3715
3862
|
origin: this.host
|
|
3716
3863
|
});
|
|
3717
3864
|
if (typeof (remoteEntryExports == null ? void 0 : remoteEntryExports.init) === 'undefined') {
|
|
3718
|
-
|
|
3865
|
+
error(errorCodes.getShortErrorMsg(errorCodes.RUNTIME_002, errorCodes.runtimeDescMap, {
|
|
3866
|
+
remoteName: name,
|
|
3867
|
+
remoteEntryUrl: this.remoteInfo.entry,
|
|
3868
|
+
remoteEntryKey: this.remoteInfo.entryGlobalName
|
|
3869
|
+
}));
|
|
3719
3870
|
}
|
|
3720
3871
|
await remoteEntryExports.init(initContainerOptions.shareScope, initContainerOptions.initScope, initContainerOptions.remoteEntryInitOptions);
|
|
3721
3872
|
await this.host.hooks.lifecycle.initContainer.emit(polyfills._extends({}, initContainerOptions, {
|
|
@@ -3726,10 +3877,20 @@ share_cjs.warn = warn;
|
|
|
3726
3877
|
}
|
|
3727
3878
|
this.lib = remoteEntryExports;
|
|
3728
3879
|
this.inited = true;
|
|
3880
|
+
let moduleFactory;
|
|
3881
|
+
moduleFactory = await this.host.loaderHook.lifecycle.getModuleFactory.emit({
|
|
3882
|
+
remoteEntryExports,
|
|
3883
|
+
expose,
|
|
3884
|
+
moduleInfo: this.remoteInfo
|
|
3885
|
+
});
|
|
3729
3886
|
// get exposeGetter
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
3887
|
+
if (!moduleFactory) {
|
|
3888
|
+
moduleFactory = await remoteEntryExports.get(expose);
|
|
3889
|
+
}
|
|
3890
|
+
assert(moduleFactory, `${getFMId(this.remoteInfo)} remote don't export ${expose}.`);
|
|
3891
|
+
// keep symbol for module name always one format
|
|
3892
|
+
const symbolName = processModuleAlias(this.remoteInfo.name, expose);
|
|
3893
|
+
const wrapModuleFactory = this.wraperFactory(moduleFactory, symbolName);
|
|
3733
3894
|
if (!loadFactory) {
|
|
3734
3895
|
return wrapModuleFactory;
|
|
3735
3896
|
}
|
|
@@ -3832,7 +3993,7 @@ share_cjs.warn = warn;
|
|
|
3832
3993
|
|
|
3833
3994
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
3834
3995
|
function checkReturnData(originalData, returnedData) {
|
|
3835
|
-
if (!
|
|
3996
|
+
if (!isObject(returnedData)) {
|
|
3836
3997
|
return false;
|
|
3837
3998
|
}
|
|
3838
3999
|
if (originalData !== returnedData) {
|
|
@@ -3847,8 +4008,8 @@ share_cjs.warn = warn;
|
|
|
3847
4008
|
}
|
|
3848
4009
|
class SyncWaterfallHook extends SyncHook {
|
|
3849
4010
|
emit(data) {
|
|
3850
|
-
if (!
|
|
3851
|
-
|
|
4011
|
+
if (!isObject(data)) {
|
|
4012
|
+
error(`The data for the "${this.type}" hook should be an object.`);
|
|
3852
4013
|
}
|
|
3853
4014
|
for (const fn of this.listeners){
|
|
3854
4015
|
try {
|
|
@@ -3860,29 +4021,28 @@ share_cjs.warn = warn;
|
|
|
3860
4021
|
break;
|
|
3861
4022
|
}
|
|
3862
4023
|
} catch (e) {
|
|
3863
|
-
|
|
4024
|
+
warn(e);
|
|
3864
4025
|
this.onerror(e);
|
|
3865
4026
|
}
|
|
3866
4027
|
}
|
|
3867
4028
|
return data;
|
|
3868
4029
|
}
|
|
3869
4030
|
constructor(type){
|
|
3870
|
-
super();
|
|
3871
|
-
this.onerror = share.error;
|
|
4031
|
+
super(), this.onerror = error;
|
|
3872
4032
|
this.type = type;
|
|
3873
4033
|
}
|
|
3874
4034
|
}
|
|
3875
4035
|
|
|
3876
4036
|
class AsyncWaterfallHook extends SyncHook {
|
|
3877
4037
|
emit(data) {
|
|
3878
|
-
if (!
|
|
3879
|
-
|
|
4038
|
+
if (!isObject(data)) {
|
|
4039
|
+
error(`The response data for the "${this.type}" hook must be an object.`);
|
|
3880
4040
|
}
|
|
3881
4041
|
const ls = Array.from(this.listeners);
|
|
3882
4042
|
if (ls.length > 0) {
|
|
3883
4043
|
let i = 0;
|
|
3884
4044
|
const processError = (e)=>{
|
|
3885
|
-
|
|
4045
|
+
warn(e);
|
|
3886
4046
|
this.onerror(e);
|
|
3887
4047
|
return data;
|
|
3888
4048
|
};
|
|
@@ -3906,18 +4066,17 @@ share_cjs.warn = warn;
|
|
|
3906
4066
|
return Promise.resolve(data);
|
|
3907
4067
|
}
|
|
3908
4068
|
constructor(type){
|
|
3909
|
-
super();
|
|
3910
|
-
this.onerror = share.error;
|
|
4069
|
+
super(), this.onerror = error;
|
|
3911
4070
|
this.type = type;
|
|
3912
4071
|
}
|
|
3913
4072
|
}
|
|
3914
4073
|
|
|
3915
4074
|
class PluginSystem {
|
|
3916
4075
|
applyPlugin(plugin) {
|
|
3917
|
-
|
|
4076
|
+
assert(isPlainObject(plugin), 'Plugin configuration is invalid.');
|
|
3918
4077
|
// The plugin's name is mandatory and must be unique
|
|
3919
4078
|
const pluginName = plugin.name;
|
|
3920
|
-
|
|
4079
|
+
assert(pluginName, 'A name must be provided by the plugin.');
|
|
3921
4080
|
if (!this.registerPlugins[pluginName]) {
|
|
3922
4081
|
this.registerPlugins[pluginName] = plugin;
|
|
3923
4082
|
Object.keys(this.lifecycle).forEach((key)=>{
|
|
@@ -3929,9 +4088,9 @@ share_cjs.warn = warn;
|
|
|
3929
4088
|
}
|
|
3930
4089
|
}
|
|
3931
4090
|
removePlugin(pluginName) {
|
|
3932
|
-
|
|
4091
|
+
assert(pluginName, 'A name is required.');
|
|
3933
4092
|
const plugin = this.registerPlugins[pluginName];
|
|
3934
|
-
|
|
4093
|
+
assert(plugin, `The plugin "${pluginName}" is not registered.`);
|
|
3935
4094
|
Object.keys(plugin).forEach((key)=>{
|
|
3936
4095
|
if (key !== 'name') {
|
|
3937
4096
|
this.lifecycle[key].remove(plugin[key]);
|
|
@@ -3941,11 +4100,11 @@ share_cjs.warn = warn;
|
|
|
3941
4100
|
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
3942
4101
|
inherit({ lifecycle, registerPlugins }) {
|
|
3943
4102
|
Object.keys(lifecycle).forEach((hookName)=>{
|
|
3944
|
-
|
|
4103
|
+
assert(!this.lifecycle[hookName], `The hook "${hookName}" has a conflict and cannot be inherited.`);
|
|
3945
4104
|
this.lifecycle[hookName] = lifecycle[hookName];
|
|
3946
4105
|
});
|
|
3947
4106
|
Object.keys(registerPlugins).forEach((pluginName)=>{
|
|
3948
|
-
|
|
4107
|
+
assert(!this.registerPlugins[pluginName], `The plugin "${pluginName}" has a conflict and cannot be inherited.`);
|
|
3949
4108
|
this.applyPlugin(registerPlugins[pluginName]);
|
|
3950
4109
|
});
|
|
3951
4110
|
}
|
|
@@ -3967,7 +4126,7 @@ share_cjs.warn = warn;
|
|
|
3967
4126
|
function formatPreloadArgs(remotes, preloadArgs) {
|
|
3968
4127
|
return preloadArgs.map((args)=>{
|
|
3969
4128
|
const remoteInfo = matchRemote(remotes, args.nameOrAlias);
|
|
3970
|
-
|
|
4129
|
+
assert(remoteInfo, `Unable to preload ${args.nameOrAlias} as it is not included in ${!remoteInfo && sdk.safeToString({
|
|
3971
4130
|
remoteInfo,
|
|
3972
4131
|
remotes
|
|
3973
4132
|
})}`);
|
|
@@ -4015,13 +4174,14 @@ share_cjs.warn = warn;
|
|
|
4015
4174
|
if (useLinkPreload) {
|
|
4016
4175
|
const defaultAttrs = {
|
|
4017
4176
|
rel: 'preload',
|
|
4018
|
-
as: 'style'
|
|
4019
|
-
crossorigin: 'anonymous'
|
|
4177
|
+
as: 'style'
|
|
4020
4178
|
};
|
|
4021
4179
|
cssAssets.forEach((cssUrl)=>{
|
|
4022
4180
|
const { link: cssEl, needAttach } = sdk.createLink({
|
|
4023
4181
|
url: cssUrl,
|
|
4024
|
-
cb: ()=>{
|
|
4182
|
+
cb: ()=>{
|
|
4183
|
+
// noop
|
|
4184
|
+
},
|
|
4025
4185
|
attrs: defaultAttrs,
|
|
4026
4186
|
createLinkHook: (url, attrs)=>{
|
|
4027
4187
|
const res = host.loaderHook.lifecycle.createLink.emit({
|
|
@@ -4044,7 +4204,9 @@ share_cjs.warn = warn;
|
|
|
4044
4204
|
cssAssets.forEach((cssUrl)=>{
|
|
4045
4205
|
const { link: cssEl, needAttach } = sdk.createLink({
|
|
4046
4206
|
url: cssUrl,
|
|
4047
|
-
cb: ()=>{
|
|
4207
|
+
cb: ()=>{
|
|
4208
|
+
// noop
|
|
4209
|
+
},
|
|
4048
4210
|
attrs: defaultAttrs,
|
|
4049
4211
|
createLinkHook: (url, attrs)=>{
|
|
4050
4212
|
const res = host.loaderHook.lifecycle.createLink.emit({
|
|
@@ -4064,13 +4226,14 @@ share_cjs.warn = warn;
|
|
|
4064
4226
|
if (useLinkPreload) {
|
|
4065
4227
|
const defaultAttrs = {
|
|
4066
4228
|
rel: 'preload',
|
|
4067
|
-
as: 'script'
|
|
4068
|
-
crossorigin: 'anonymous'
|
|
4229
|
+
as: 'script'
|
|
4069
4230
|
};
|
|
4070
4231
|
jsAssetsWithoutEntry.forEach((jsUrl)=>{
|
|
4071
4232
|
const { link: linkEl, needAttach } = sdk.createLink({
|
|
4072
4233
|
url: jsUrl,
|
|
4073
|
-
cb: ()=>{
|
|
4234
|
+
cb: ()=>{
|
|
4235
|
+
// noop
|
|
4236
|
+
},
|
|
4074
4237
|
attrs: defaultAttrs,
|
|
4075
4238
|
createLinkHook: (url, attrs)=>{
|
|
4076
4239
|
const res = host.loaderHook.lifecycle.createLink.emit({
|
|
@@ -4093,7 +4256,9 @@ share_cjs.warn = warn;
|
|
|
4093
4256
|
jsAssetsWithoutEntry.forEach((jsUrl)=>{
|
|
4094
4257
|
const { script: scriptEl, needAttach } = sdk.createScript({
|
|
4095
4258
|
url: jsUrl,
|
|
4096
|
-
cb: ()=>{
|
|
4259
|
+
cb: ()=>{
|
|
4260
|
+
// noop
|
|
4261
|
+
},
|
|
4097
4262
|
attrs: defaultAttrs,
|
|
4098
4263
|
createScriptHook: (url, attrs)=>{
|
|
4099
4264
|
const res = host.loaderHook.lifecycle.createScript.emit({
|
|
@@ -4114,9 +4279,9 @@ share_cjs.warn = warn;
|
|
|
4114
4279
|
}
|
|
4115
4280
|
|
|
4116
4281
|
function assignRemoteInfo(remoteInfo, remoteSnapshot) {
|
|
4117
|
-
const remoteEntryInfo =
|
|
4282
|
+
const remoteEntryInfo = getRemoteEntryInfoFromSnapshot(remoteSnapshot);
|
|
4118
4283
|
if (!remoteEntryInfo.url) {
|
|
4119
|
-
|
|
4284
|
+
error(`The attribute remoteEntry of ${remoteInfo.name} must not be undefined.`);
|
|
4120
4285
|
}
|
|
4121
4286
|
let entryUrl = sdk.getResourceUrl(remoteSnapshot, remoteEntryInfo.url);
|
|
4122
4287
|
if (!sdk.isBrowserEnv() && !entryUrl.startsWith('http')) {
|
|
@@ -4133,7 +4298,7 @@ share_cjs.warn = warn;
|
|
|
4133
4298
|
name: 'snapshot-plugin',
|
|
4134
4299
|
async afterResolve (args) {
|
|
4135
4300
|
const { remote, pkgNameOrAlias, expose, origin, remoteInfo } = args;
|
|
4136
|
-
if (!
|
|
4301
|
+
if (!isRemoteInfoWithEntry(remote) || !isPureRemoteEntry(remote)) {
|
|
4137
4302
|
const { remoteSnapshot, globalSnapshot } = await origin.snapshotHandler.loadRemoteSnapshotInfo(remote);
|
|
4138
4303
|
assignRemoteInfo(remoteInfo, remoteSnapshot);
|
|
4139
4304
|
// preloading assets
|
|
@@ -4192,8 +4357,8 @@ share_cjs.warn = warn;
|
|
|
4192
4357
|
}
|
|
4193
4358
|
// Traverse all nodes in moduleInfo and traverse the entire snapshot
|
|
4194
4359
|
function traverseModuleInfo(globalSnapshot, remoteInfo, traverse, isRoot, memo = {}, remoteSnapshot) {
|
|
4195
|
-
const id =
|
|
4196
|
-
const { value: snapshotValue } =
|
|
4360
|
+
const id = getFMId(remoteInfo);
|
|
4361
|
+
const { value: snapshotValue } = getInfoWithoutType(globalSnapshot, id);
|
|
4197
4362
|
const effectiveRemoteSnapshot = remoteSnapshot || snapshotValue;
|
|
4198
4363
|
if (effectiveRemoteSnapshot && !sdk.isManifestProvider(effectiveRemoteSnapshot)) {
|
|
4199
4364
|
traverse(effectiveRemoteSnapshot, remoteInfo, isRoot);
|
|
@@ -4248,7 +4413,7 @@ share_cjs.warn = warn;
|
|
|
4248
4413
|
return;
|
|
4249
4414
|
}
|
|
4250
4415
|
}
|
|
4251
|
-
const remoteEntryUrl = sdk.getResourceUrl(moduleInfoSnapshot,
|
|
4416
|
+
const remoteEntryUrl = sdk.getResourceUrl(moduleInfoSnapshot, getRemoteEntryInfoFromSnapshot(moduleInfoSnapshot).url);
|
|
4252
4417
|
if (remoteEntryUrl) {
|
|
4253
4418
|
entryAssets.push({
|
|
4254
4419
|
name: remoteInfo.name,
|
|
@@ -4294,7 +4459,7 @@ share_cjs.warn = warn;
|
|
|
4294
4459
|
remote: remoteInfo,
|
|
4295
4460
|
origin
|
|
4296
4461
|
});
|
|
4297
|
-
const preloaded =
|
|
4462
|
+
const preloaded = getPreloaded(exposeFullPath);
|
|
4298
4463
|
if (preloaded) {
|
|
4299
4464
|
continue;
|
|
4300
4465
|
}
|
|
@@ -4308,13 +4473,13 @@ share_cjs.warn = warn;
|
|
|
4308
4473
|
cssAssets.push(...handleAssets(assetsInfo.assets.css.sync));
|
|
4309
4474
|
jsAssets.push(...handleAssets(assetsInfo.assets.js.sync));
|
|
4310
4475
|
}
|
|
4311
|
-
|
|
4476
|
+
setPreloaded(exposeFullPath);
|
|
4312
4477
|
}
|
|
4313
4478
|
}
|
|
4314
4479
|
}, true, memo, remoteSnapshot);
|
|
4315
4480
|
if (remoteSnapshot.shared) {
|
|
4316
4481
|
const collectSharedAssets = (shareInfo, snapshotShared)=>{
|
|
4317
|
-
const registeredShared =
|
|
4482
|
+
const registeredShared = getRegisteredShare(origin.shareScopeMap, snapshotShared.sharedName, shareInfo, origin.sharedHandler.hooks.lifecycle.resolveShare);
|
|
4318
4483
|
// If the global share does not exist, or the lib function does not exist, it means that the shared has not been loaded yet and can be preloaded.
|
|
4319
4484
|
if (registeredShared && typeof registeredShared.lib === 'function') {
|
|
4320
4485
|
snapshotShared.assets.js.sync.forEach((asset)=>{
|
|
@@ -4336,7 +4501,7 @@ share_cjs.warn = warn;
|
|
|
4336
4501
|
if (!sharedOptions) {
|
|
4337
4502
|
return;
|
|
4338
4503
|
}
|
|
4339
|
-
const arrayShareInfo =
|
|
4504
|
+
const arrayShareInfo = arrayOptions(sharedOptions);
|
|
4340
4505
|
arrayShareInfo.forEach((s)=>{
|
|
4341
4506
|
collectSharedAssets(s, shared);
|
|
4342
4507
|
});
|
|
@@ -4355,7 +4520,7 @@ share_cjs.warn = warn;
|
|
|
4355
4520
|
name: 'generate-preload-assets-plugin',
|
|
4356
4521
|
async generatePreloadAssets (args) {
|
|
4357
4522
|
const { origin, preloadOptions, remoteInfo, remote, globalSnapshot, remoteSnapshot } = args;
|
|
4358
|
-
if (
|
|
4523
|
+
if (isRemoteInfoWithEntry(remote) && isPureRemoteEntry(remote)) {
|
|
4359
4524
|
return {
|
|
4360
4525
|
cssAssets: [],
|
|
4361
4526
|
jsAssetsWithoutEntry: [],
|
|
@@ -4366,7 +4531,7 @@ share_cjs.warn = warn;
|
|
|
4366
4531
|
moduleInfo: {
|
|
4367
4532
|
name: remoteInfo.name,
|
|
4368
4533
|
entry: remote.entry,
|
|
4369
|
-
type: 'global',
|
|
4534
|
+
type: remoteInfo.type || 'global',
|
|
4370
4535
|
entryGlobalName: '',
|
|
4371
4536
|
shareScope: ''
|
|
4372
4537
|
}
|
|
@@ -4382,17 +4547,17 @@ share_cjs.warn = warn;
|
|
|
4382
4547
|
};
|
|
4383
4548
|
|
|
4384
4549
|
function getGlobalRemoteInfo(moduleInfo, origin) {
|
|
4385
|
-
const hostGlobalSnapshot =
|
|
4550
|
+
const hostGlobalSnapshot = getGlobalSnapshotInfoByModuleInfo({
|
|
4386
4551
|
name: origin.options.name,
|
|
4387
4552
|
version: origin.options.version
|
|
4388
4553
|
});
|
|
4389
4554
|
// get remote detail info from global
|
|
4390
|
-
const globalRemoteInfo = hostGlobalSnapshot && 'remotesInfo' in hostGlobalSnapshot && hostGlobalSnapshot.remotesInfo &&
|
|
4555
|
+
const globalRemoteInfo = hostGlobalSnapshot && 'remotesInfo' in hostGlobalSnapshot && hostGlobalSnapshot.remotesInfo && getInfoWithoutType(hostGlobalSnapshot.remotesInfo, moduleInfo.name).value;
|
|
4391
4556
|
if (globalRemoteInfo && globalRemoteInfo.matchedVersion) {
|
|
4392
4557
|
return {
|
|
4393
4558
|
hostGlobalSnapshot,
|
|
4394
|
-
globalSnapshot:
|
|
4395
|
-
remoteSnapshot:
|
|
4559
|
+
globalSnapshot: getGlobalSnapshot(),
|
|
4560
|
+
remoteSnapshot: getGlobalSnapshotInfoByModuleInfo({
|
|
4396
4561
|
name: moduleInfo.name,
|
|
4397
4562
|
version: globalRemoteInfo.matchedVersion
|
|
4398
4563
|
})
|
|
@@ -4400,8 +4565,8 @@ share_cjs.warn = warn;
|
|
|
4400
4565
|
}
|
|
4401
4566
|
return {
|
|
4402
4567
|
hostGlobalSnapshot: undefined,
|
|
4403
|
-
globalSnapshot:
|
|
4404
|
-
remoteSnapshot:
|
|
4568
|
+
globalSnapshot: getGlobalSnapshot(),
|
|
4569
|
+
remoteSnapshot: getGlobalSnapshotInfoByModuleInfo({
|
|
4405
4570
|
name: moduleInfo.name,
|
|
4406
4571
|
version: 'version' in moduleInfo ? moduleInfo.version : undefined
|
|
4407
4572
|
})
|
|
@@ -4430,7 +4595,7 @@ share_cjs.warn = warn;
|
|
|
4430
4595
|
options,
|
|
4431
4596
|
moduleInfo
|
|
4432
4597
|
});
|
|
4433
|
-
let hostSnapshot =
|
|
4598
|
+
let hostSnapshot = getGlobalSnapshotInfoByModuleInfo({
|
|
4434
4599
|
name: this.HostInstance.options.name,
|
|
4435
4600
|
version: this.HostInstance.options.version
|
|
4436
4601
|
});
|
|
@@ -4440,13 +4605,13 @@ share_cjs.warn = warn;
|
|
|
4440
4605
|
remoteEntry: '',
|
|
4441
4606
|
remotesInfo: {}
|
|
4442
4607
|
};
|
|
4443
|
-
|
|
4608
|
+
addGlobalSnapshot({
|
|
4444
4609
|
[this.HostInstance.options.name]: hostSnapshot
|
|
4445
4610
|
});
|
|
4446
4611
|
}
|
|
4447
4612
|
// In dynamic loadRemote scenarios, incomplete remotesInfo delivery may occur. In such cases, the remotesInfo in the host needs to be completed in the snapshot at runtime.
|
|
4448
4613
|
// This ensures the snapshot's integrity and helps the chrome plugin correctly identify all producer modules, ensuring that proxyable producer modules will not be missing.
|
|
4449
|
-
if (hostSnapshot && 'remotesInfo' in hostSnapshot && !
|
|
4614
|
+
if (hostSnapshot && 'remotesInfo' in hostSnapshot && !getInfoWithoutType(hostSnapshot.remotesInfo, moduleInfo.name).value) {
|
|
4450
4615
|
if ('version' in moduleInfo || 'entry' in moduleInfo) {
|
|
4451
4616
|
hostSnapshot.remotesInfo = polyfills._extends({}, hostSnapshot == null ? void 0 : hostSnapshot.remotesInfo, {
|
|
4452
4617
|
[moduleInfo.name]: {
|
|
@@ -4463,21 +4628,21 @@ share_cjs.warn = warn;
|
|
|
4463
4628
|
remoteSnapshot,
|
|
4464
4629
|
globalSnapshot
|
|
4465
4630
|
});
|
|
4631
|
+
let mSnapshot;
|
|
4632
|
+
let gSnapshot;
|
|
4466
4633
|
// global snapshot includes manifest or module info includes manifest
|
|
4467
4634
|
if (globalRemoteSnapshot) {
|
|
4468
4635
|
if (sdk.isManifestProvider(globalRemoteSnapshot)) {
|
|
4469
4636
|
const remoteEntry = sdk.isBrowserEnv() ? globalRemoteSnapshot.remoteEntry : globalRemoteSnapshot.ssrRemoteEntry || globalRemoteSnapshot.remoteEntry || '';
|
|
4470
4637
|
const moduleSnapshot = await this.getManifestJson(remoteEntry, moduleInfo, {});
|
|
4471
4638
|
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
4472
|
-
const globalSnapshotRes =
|
|
4639
|
+
const globalSnapshotRes = setGlobalSnapshotInfoByModuleInfo(polyfills._extends({}, moduleInfo, {
|
|
4473
4640
|
// The global remote may be overridden
|
|
4474
4641
|
// Therefore, set the snapshot key to the global address of the actual request
|
|
4475
4642
|
entry: remoteEntry
|
|
4476
4643
|
}), moduleSnapshot);
|
|
4477
|
-
|
|
4478
|
-
|
|
4479
|
-
globalSnapshot: globalSnapshotRes
|
|
4480
|
-
};
|
|
4644
|
+
mSnapshot = moduleSnapshot;
|
|
4645
|
+
gSnapshot = globalSnapshotRes;
|
|
4481
4646
|
} else {
|
|
4482
4647
|
const { remoteSnapshot: remoteSnapshotRes } = await this.hooks.lifecycle.loadRemoteSnapshot.emit({
|
|
4483
4648
|
options: this.HostInstance.options,
|
|
@@ -4485,36 +4650,40 @@ share_cjs.warn = warn;
|
|
|
4485
4650
|
remoteSnapshot: globalRemoteSnapshot,
|
|
4486
4651
|
from: 'global'
|
|
4487
4652
|
});
|
|
4488
|
-
|
|
4489
|
-
|
|
4490
|
-
globalSnapshot: globalSnapshotRes
|
|
4491
|
-
};
|
|
4653
|
+
mSnapshot = remoteSnapshotRes;
|
|
4654
|
+
gSnapshot = globalSnapshotRes;
|
|
4492
4655
|
}
|
|
4493
4656
|
} else {
|
|
4494
|
-
if (
|
|
4657
|
+
if (isRemoteInfoWithEntry(moduleInfo)) {
|
|
4495
4658
|
// get from manifest.json and merge remote info from remote server
|
|
4496
4659
|
const moduleSnapshot = await this.getManifestJson(moduleInfo.entry, moduleInfo, {});
|
|
4497
4660
|
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
4498
|
-
const globalSnapshotRes =
|
|
4661
|
+
const globalSnapshotRes = setGlobalSnapshotInfoByModuleInfo(moduleInfo, moduleSnapshot);
|
|
4499
4662
|
const { remoteSnapshot: remoteSnapshotRes } = await this.hooks.lifecycle.loadRemoteSnapshot.emit({
|
|
4500
4663
|
options: this.HostInstance.options,
|
|
4501
4664
|
moduleInfo,
|
|
4502
4665
|
remoteSnapshot: moduleSnapshot,
|
|
4503
4666
|
from: 'global'
|
|
4504
4667
|
});
|
|
4505
|
-
|
|
4506
|
-
|
|
4507
|
-
globalSnapshot: globalSnapshotRes
|
|
4508
|
-
};
|
|
4668
|
+
mSnapshot = remoteSnapshotRes;
|
|
4669
|
+
gSnapshot = globalSnapshotRes;
|
|
4509
4670
|
} else {
|
|
4510
|
-
|
|
4511
|
-
|
|
4512
|
-
|
|
4513
|
-
|
|
4514
|
-
|
|
4515
|
-
`);
|
|
4671
|
+
error(errorCodes.getShortErrorMsg(errorCodes.RUNTIME_007, errorCodes.runtimeDescMap, {
|
|
4672
|
+
hostName: moduleInfo.name,
|
|
4673
|
+
hostVersion: moduleInfo.version,
|
|
4674
|
+
globalSnapshot: JSON.stringify(globalSnapshotRes)
|
|
4675
|
+
}));
|
|
4516
4676
|
}
|
|
4517
4677
|
}
|
|
4678
|
+
await this.hooks.lifecycle.afterLoadSnapshot.emit({
|
|
4679
|
+
options,
|
|
4680
|
+
moduleInfo,
|
|
4681
|
+
remoteSnapshot: mSnapshot
|
|
4682
|
+
});
|
|
4683
|
+
return {
|
|
4684
|
+
remoteSnapshot: mSnapshot,
|
|
4685
|
+
globalSnapshot: gSnapshot
|
|
4686
|
+
};
|
|
4518
4687
|
}
|
|
4519
4688
|
getGlobalRemoteInfo(moduleInfo) {
|
|
4520
4689
|
return getGlobalRemoteInfo(moduleInfo, this.HostInstance);
|
|
@@ -4531,15 +4700,25 @@ share_cjs.warn = warn;
|
|
|
4531
4700
|
res = await fetch(manifestUrl, {});
|
|
4532
4701
|
}
|
|
4533
4702
|
manifestJson = await res.json();
|
|
4534
|
-
share.assert(manifestJson.metaData && manifestJson.exposes && manifestJson.shared, `${manifestUrl} is not a federation manifest`);
|
|
4535
|
-
this.manifestCache.set(manifestUrl, manifestJson);
|
|
4536
|
-
return manifestJson;
|
|
4537
4703
|
} catch (err) {
|
|
4538
|
-
|
|
4539
|
-
|
|
4540
|
-
|
|
4541
|
-
|
|
4704
|
+
manifestJson = await this.HostInstance.remoteHandler.hooks.lifecycle.errorLoadRemote.emit({
|
|
4705
|
+
id: manifestUrl,
|
|
4706
|
+
error,
|
|
4707
|
+
from: 'runtime',
|
|
4708
|
+
lifecycle: 'afterResolve',
|
|
4709
|
+
origin: this.HostInstance
|
|
4710
|
+
});
|
|
4711
|
+
if (!manifestJson) {
|
|
4712
|
+
delete this.manifestLoading[manifestUrl];
|
|
4713
|
+
error(errorCodes.getShortErrorMsg(errorCodes.RUNTIME_003, errorCodes.runtimeDescMap, {
|
|
4714
|
+
manifestUrl,
|
|
4715
|
+
moduleName: moduleInfo.name
|
|
4716
|
+
}, `${err}`));
|
|
4717
|
+
}
|
|
4542
4718
|
}
|
|
4719
|
+
assert(manifestJson.metaData && manifestJson.exposes && manifestJson.shared, `${manifestUrl} is not a federation manifest`);
|
|
4720
|
+
this.manifestCache.set(manifestUrl, manifestJson);
|
|
4721
|
+
return manifestJson;
|
|
4543
4722
|
};
|
|
4544
4723
|
const asyncLoadProcess = async ()=>{
|
|
4545
4724
|
const manifestJson = await getManifest();
|
|
@@ -4567,9 +4746,10 @@ share_cjs.warn = warn;
|
|
|
4567
4746
|
this.hooks = new PluginSystem({
|
|
4568
4747
|
beforeLoadRemoteSnapshot: new AsyncHook('beforeLoadRemoteSnapshot'),
|
|
4569
4748
|
loadSnapshot: new AsyncWaterfallHook('loadGlobalSnapshot'),
|
|
4570
|
-
loadRemoteSnapshot: new AsyncWaterfallHook('loadRemoteSnapshot')
|
|
4749
|
+
loadRemoteSnapshot: new AsyncWaterfallHook('loadRemoteSnapshot'),
|
|
4750
|
+
afterLoadSnapshot: new AsyncWaterfallHook('afterLoadSnapshot')
|
|
4571
4751
|
});
|
|
4572
|
-
this.manifestLoading =
|
|
4752
|
+
this.manifestLoading = Global.__FEDERATION__.__MANIFEST_LOADING__;
|
|
4573
4753
|
this.HostInstance = HostInstance;
|
|
4574
4754
|
this.loaderHook = HostInstance.loaderHook;
|
|
4575
4755
|
}
|
|
@@ -4578,12 +4758,12 @@ share_cjs.warn = warn;
|
|
|
4578
4758
|
class SharedHandler {
|
|
4579
4759
|
// register shared in shareScopeMap
|
|
4580
4760
|
registerShared(globalOptions, userOptions) {
|
|
4581
|
-
const { shareInfos, shared } =
|
|
4761
|
+
const { shareInfos, shared } = formatShareConfigs(globalOptions, userOptions);
|
|
4582
4762
|
const sharedKeys = Object.keys(shareInfos);
|
|
4583
4763
|
sharedKeys.forEach((sharedKey)=>{
|
|
4584
4764
|
const sharedVals = shareInfos[sharedKey];
|
|
4585
4765
|
sharedVals.forEach((sharedVal)=>{
|
|
4586
|
-
const registeredShared =
|
|
4766
|
+
const registeredShared = getRegisteredShare(this.shareScopeMap, sharedKey, sharedVal, this.hooks.lifecycle.resolveShare);
|
|
4587
4767
|
if (!registeredShared && sharedVal && sharedVal.lib) {
|
|
4588
4768
|
this.setShared({
|
|
4589
4769
|
pkgName: sharedKey,
|
|
@@ -4607,7 +4787,7 @@ share_cjs.warn = warn;
|
|
|
4607
4787
|
// 1. Checks if the currently loaded share already exists, if not, it throws an error
|
|
4608
4788
|
// 2. Searches globally for a matching share, if found, it uses it directly
|
|
4609
4789
|
// 3. If not found, it retrieves it from the current share and stores the obtained share globally.
|
|
4610
|
-
const shareInfo =
|
|
4790
|
+
const shareInfo = getTargetSharedOptions({
|
|
4611
4791
|
pkgName,
|
|
4612
4792
|
extraOptions,
|
|
4613
4793
|
shareInfos: host.options.shared
|
|
@@ -4628,14 +4808,14 @@ share_cjs.warn = warn;
|
|
|
4628
4808
|
});
|
|
4629
4809
|
const { shareInfo: shareInfoRes } = loadShareRes;
|
|
4630
4810
|
// Assert that shareInfoRes exists, if not, throw an error
|
|
4631
|
-
|
|
4811
|
+
assert(shareInfoRes, `Cannot find ${pkgName} Share in the ${host.options.name}. Please ensure that the ${pkgName} Share parameters have been injected`);
|
|
4632
4812
|
// Retrieve from cache
|
|
4633
|
-
const registeredShared =
|
|
4813
|
+
const registeredShared = getRegisteredShare(this.shareScopeMap, pkgName, shareInfoRes, this.hooks.lifecycle.resolveShare);
|
|
4634
4814
|
const addUseIn = (shared)=>{
|
|
4635
4815
|
if (!shared.useIn) {
|
|
4636
4816
|
shared.useIn = [];
|
|
4637
4817
|
}
|
|
4638
|
-
|
|
4818
|
+
addUniqueItem(shared.useIn, host.options.name);
|
|
4639
4819
|
};
|
|
4640
4820
|
if (registeredShared && registeredShared.lib) {
|
|
4641
4821
|
addUseIn(registeredShared);
|
|
@@ -4654,7 +4834,7 @@ share_cjs.warn = warn;
|
|
|
4654
4834
|
shareInfoRes.lib = factory;
|
|
4655
4835
|
shareInfoRes.loaded = true;
|
|
4656
4836
|
addUseIn(shareInfoRes);
|
|
4657
|
-
const gShared =
|
|
4837
|
+
const gShared = getRegisteredShare(this.shareScopeMap, pkgName, shareInfoRes, this.hooks.lifecycle.resolveShare);
|
|
4658
4838
|
if (gShared) {
|
|
4659
4839
|
gShared.lib = factory;
|
|
4660
4840
|
gShared.loaded = true;
|
|
@@ -4680,7 +4860,7 @@ share_cjs.warn = warn;
|
|
|
4680
4860
|
shareInfoRes.lib = factory;
|
|
4681
4861
|
shareInfoRes.loaded = true;
|
|
4682
4862
|
addUseIn(shareInfoRes);
|
|
4683
|
-
const gShared =
|
|
4863
|
+
const gShared = getRegisteredShare(this.shareScopeMap, pkgName, shareInfoRes, this.hooks.lifecycle.resolveShare);
|
|
4684
4864
|
if (gShared) {
|
|
4685
4865
|
gShared.lib = factory;
|
|
4686
4866
|
gShared.loaded = true;
|
|
@@ -4704,7 +4884,7 @@ share_cjs.warn = warn;
|
|
|
4704
4884
|
* It accepts one argument, the name of the share scope.
|
|
4705
4885
|
* If the share scope does not exist, it creates one.
|
|
4706
4886
|
*/ // eslint-disable-next-line @typescript-eslint/member-ordering
|
|
4707
|
-
initializeSharing(shareScopeName =
|
|
4887
|
+
initializeSharing(shareScopeName = DEFAULT_SCOPE, extraOptions) {
|
|
4708
4888
|
const { host } = this;
|
|
4709
4889
|
const from = extraOptions == null ? void 0 : extraOptions.from;
|
|
4710
4890
|
const strategy = extraOptions == null ? void 0 : extraOptions.strategy;
|
|
@@ -4745,9 +4925,20 @@ share_cjs.warn = warn;
|
|
|
4745
4925
|
id: key
|
|
4746
4926
|
});
|
|
4747
4927
|
if (module.getEntry) {
|
|
4748
|
-
|
|
4928
|
+
let remoteEntryExports;
|
|
4929
|
+
try {
|
|
4930
|
+
remoteEntryExports = await module.getEntry();
|
|
4931
|
+
} catch (error) {
|
|
4932
|
+
remoteEntryExports = await host.remoteHandler.hooks.lifecycle.errorLoadRemote.emit({
|
|
4933
|
+
id: key,
|
|
4934
|
+
error,
|
|
4935
|
+
from: 'runtime',
|
|
4936
|
+
lifecycle: 'beforeLoadShare',
|
|
4937
|
+
origin: host
|
|
4938
|
+
});
|
|
4939
|
+
}
|
|
4749
4940
|
if (!module.inited) {
|
|
4750
|
-
await initFn(
|
|
4941
|
+
await initFn(remoteEntryExports);
|
|
4751
4942
|
module.inited = true;
|
|
4752
4943
|
}
|
|
4753
4944
|
}
|
|
@@ -4776,7 +4967,7 @@ share_cjs.warn = warn;
|
|
|
4776
4967
|
// 3. If the local get returns something other than Promise, then it will be used directly
|
|
4777
4968
|
loadShareSync(pkgName, extraOptions) {
|
|
4778
4969
|
const { host } = this;
|
|
4779
|
-
const shareInfo =
|
|
4970
|
+
const shareInfo = getTargetSharedOptions({
|
|
4780
4971
|
pkgName,
|
|
4781
4972
|
extraOptions,
|
|
4782
4973
|
shareInfos: host.options.shared
|
|
@@ -4788,12 +4979,12 @@ share_cjs.warn = warn;
|
|
|
4788
4979
|
});
|
|
4789
4980
|
});
|
|
4790
4981
|
}
|
|
4791
|
-
const registeredShared =
|
|
4982
|
+
const registeredShared = getRegisteredShare(this.shareScopeMap, pkgName, shareInfo, this.hooks.lifecycle.resolveShare);
|
|
4792
4983
|
const addUseIn = (shared)=>{
|
|
4793
4984
|
if (!shared.useIn) {
|
|
4794
4985
|
shared.useIn = [];
|
|
4795
4986
|
}
|
|
4796
|
-
|
|
4987
|
+
addUniqueItem(shared.useIn, host.options.name);
|
|
4797
4988
|
};
|
|
4798
4989
|
if (registeredShared) {
|
|
4799
4990
|
if (typeof registeredShared.lib === 'function') {
|
|
@@ -4830,12 +5021,11 @@ share_cjs.warn = warn;
|
|
|
4830
5021
|
if (shareInfo.get) {
|
|
4831
5022
|
const module = shareInfo.get();
|
|
4832
5023
|
if (module instanceof Promise) {
|
|
4833
|
-
|
|
4834
|
-
|
|
4835
|
-
|
|
4836
|
-
|
|
4837
|
-
|
|
4838
|
-
`);
|
|
5024
|
+
const errorCode = (extraOptions == null ? void 0 : extraOptions.from) === 'build' ? errorCodes.RUNTIME_005 : errorCodes.RUNTIME_006;
|
|
5025
|
+
throw new Error(errorCodes.getShortErrorMsg(errorCode, errorCodes.runtimeDescMap, {
|
|
5026
|
+
hostName: host.options.name,
|
|
5027
|
+
sharedPkgName: pkgName
|
|
5028
|
+
}));
|
|
4839
5029
|
}
|
|
4840
5030
|
shareInfo.lib = module;
|
|
4841
5031
|
this.setShared({
|
|
@@ -4847,12 +5037,10 @@ share_cjs.warn = warn;
|
|
|
4847
5037
|
});
|
|
4848
5038
|
return shareInfo.lib;
|
|
4849
5039
|
}
|
|
4850
|
-
throw new Error(
|
|
4851
|
-
|
|
4852
|
-
|
|
4853
|
-
|
|
4854
|
-
2. The ${pkgName} share was not registered with the 'lib' attribute.\n
|
|
4855
|
-
`);
|
|
5040
|
+
throw new Error(errorCodes.getShortErrorMsg(errorCodes.RUNTIME_006, errorCodes.runtimeDescMap, {
|
|
5041
|
+
hostName: host.options.name,
|
|
5042
|
+
sharedPkgName: pkgName
|
|
5043
|
+
}));
|
|
4856
5044
|
}
|
|
4857
5045
|
initShareScopeMap(scopeName, shareScope, extraOptions = {}) {
|
|
4858
5046
|
const { host } = this;
|
|
@@ -4903,7 +5091,7 @@ share_cjs.warn = warn;
|
|
|
4903
5091
|
});
|
|
4904
5092
|
}
|
|
4905
5093
|
_setGlobalShareScopeMap(hostOptions) {
|
|
4906
|
-
const globalShareScopeMap =
|
|
5094
|
+
const globalShareScopeMap = getGlobalShareScope();
|
|
4907
5095
|
const identifier = hostOptions.id || hostOptions.name;
|
|
4908
5096
|
if (identifier && !globalShareScopeMap[identifier]) {
|
|
4909
5097
|
globalShareScopeMap[identifier] = this.shareScopeMap;
|
|
@@ -5072,14 +5260,10 @@ share_cjs.warn = warn;
|
|
|
5072
5260
|
}
|
|
5073
5261
|
const { id: idRes } = loadRemoteArgs;
|
|
5074
5262
|
const remoteSplitInfo = matchRemoteWithNameAndExpose(host.options.remotes, idRes);
|
|
5075
|
-
|
|
5076
|
-
|
|
5077
|
-
|
|
5078
|
-
|
|
5079
|
-
3. ${idRes} is not online, injected, or loaded.
|
|
5080
|
-
4. ${idRes} cannot be accessed on the expected.
|
|
5081
|
-
5. The 'beforeRequest' hook was provided but did not return the correct 'remoteInfo' when attempting to load ${idRes}.
|
|
5082
|
-
`);
|
|
5263
|
+
assert(remoteSplitInfo, errorCodes.getShortErrorMsg(errorCodes.RUNTIME_004, errorCodes.runtimeDescMap, {
|
|
5264
|
+
hostName: host.options.name,
|
|
5265
|
+
requestId: idRes
|
|
5266
|
+
}));
|
|
5083
5267
|
const { remote: rawRemote } = remoteSplitInfo;
|
|
5084
5268
|
const remoteInfo = getRemoteInfo(rawRemote);
|
|
5085
5269
|
const matchInfo = await host.sharedHandler.hooks.lifecycle.afterResolve.emit(polyfills._extends({
|
|
@@ -5090,7 +5274,7 @@ share_cjs.warn = warn;
|
|
|
5090
5274
|
remoteInfo
|
|
5091
5275
|
}));
|
|
5092
5276
|
const { remote, expose } = matchInfo;
|
|
5093
|
-
|
|
5277
|
+
assert(remote && expose, `The 'beforeRequest' hook was executed, but it failed to return the correct 'remote' and 'expose' values while loading ${idRes}.`);
|
|
5094
5278
|
let module = host.moduleCache.get(remote.name);
|
|
5095
5279
|
const moduleOptions = {
|
|
5096
5280
|
host: host,
|
|
@@ -5116,7 +5300,7 @@ share_cjs.warn = warn;
|
|
|
5116
5300
|
var _item_alias;
|
|
5117
5301
|
return remote.alias && (item.name.startsWith(remote.alias) || ((_item_alias = item.alias) == null ? void 0 : _item_alias.startsWith(remote.alias)));
|
|
5118
5302
|
});
|
|
5119
|
-
|
|
5303
|
+
assert(!findEqual, `The alias ${remote.alias} of remote ${remote.name} is not allowed to be the prefix of ${findEqual && findEqual.name} name or alias`);
|
|
5120
5304
|
}
|
|
5121
5305
|
// Set the remote entry to a complete path
|
|
5122
5306
|
if ('entry' in remote) {
|
|
@@ -5125,10 +5309,10 @@ share_cjs.warn = warn;
|
|
|
5125
5309
|
}
|
|
5126
5310
|
}
|
|
5127
5311
|
if (!remote.shareScope) {
|
|
5128
|
-
remote.shareScope =
|
|
5312
|
+
remote.shareScope = DEFAULT_SCOPE;
|
|
5129
5313
|
}
|
|
5130
5314
|
if (!remote.type) {
|
|
5131
|
-
remote.type =
|
|
5315
|
+
remote.type = DEFAULT_REMOTE_TYPE;
|
|
5132
5316
|
}
|
|
5133
5317
|
};
|
|
5134
5318
|
this.hooks.lifecycle.beforeRegisterRemote.emit({
|
|
@@ -5146,7 +5330,7 @@ share_cjs.warn = warn;
|
|
|
5146
5330
|
} else {
|
|
5147
5331
|
const messages = [
|
|
5148
5332
|
`The remote "${remote.name}" is already registered.`,
|
|
5149
|
-
|
|
5333
|
+
'Please note that overriding it may cause unexpected errors.'
|
|
5150
5334
|
];
|
|
5151
5335
|
if (options == null ? void 0 : options.force) {
|
|
5152
5336
|
// remove registered remote
|
|
@@ -5157,8 +5341,8 @@ share_cjs.warn = warn;
|
|
|
5157
5341
|
remote,
|
|
5158
5342
|
origin: host
|
|
5159
5343
|
});
|
|
5344
|
+
sdk.warn(messages.join(' '));
|
|
5160
5345
|
}
|
|
5161
|
-
sdk.warn(messages.join(' '));
|
|
5162
5346
|
}
|
|
5163
5347
|
}
|
|
5164
5348
|
removeRemote(remote) {
|
|
@@ -5173,23 +5357,23 @@ share_cjs.warn = warn;
|
|
|
5173
5357
|
if (loadedModule) {
|
|
5174
5358
|
const remoteInfo = loadedModule.remoteInfo;
|
|
5175
5359
|
const key = remoteInfo.entryGlobalName;
|
|
5176
|
-
if (
|
|
5360
|
+
if (CurrentGlobal[key]) {
|
|
5177
5361
|
var _Object_getOwnPropertyDescriptor;
|
|
5178
|
-
if ((_Object_getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor(
|
|
5179
|
-
delete
|
|
5362
|
+
if ((_Object_getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor(CurrentGlobal, key)) == null ? void 0 : _Object_getOwnPropertyDescriptor.configurable) {
|
|
5363
|
+
delete CurrentGlobal[key];
|
|
5180
5364
|
} else {
|
|
5181
5365
|
// @ts-ignore
|
|
5182
|
-
|
|
5366
|
+
CurrentGlobal[key] = undefined;
|
|
5183
5367
|
}
|
|
5184
5368
|
}
|
|
5185
5369
|
const remoteEntryUniqueKey = getRemoteEntryUniqueKey(loadedModule.remoteInfo);
|
|
5186
|
-
if (
|
|
5187
|
-
delete
|
|
5370
|
+
if (globalLoading[remoteEntryUniqueKey]) {
|
|
5371
|
+
delete globalLoading[remoteEntryUniqueKey];
|
|
5188
5372
|
}
|
|
5189
5373
|
host.snapshotHandler.manifestCache.delete(remoteInfo.entry);
|
|
5190
5374
|
// delete unloaded shared and instance
|
|
5191
5375
|
let remoteInsId = remoteInfo.buildVersion ? sdk.composeKeyWithSeparator(remoteInfo.name, remoteInfo.buildVersion) : remoteInfo.name;
|
|
5192
|
-
const remoteInsIndex =
|
|
5376
|
+
const remoteInsIndex = CurrentGlobal.__FEDERATION__.__INSTANCES__.findIndex((ins)=>{
|
|
5193
5377
|
if (remoteInfo.buildVersion) {
|
|
5194
5378
|
return ins.options.id === remoteInsId;
|
|
5195
5379
|
} else {
|
|
@@ -5197,9 +5381,9 @@ share_cjs.warn = warn;
|
|
|
5197
5381
|
}
|
|
5198
5382
|
});
|
|
5199
5383
|
if (remoteInsIndex !== -1) {
|
|
5200
|
-
const remoteIns =
|
|
5384
|
+
const remoteIns = CurrentGlobal.__FEDERATION__.__INSTANCES__[remoteInsIndex];
|
|
5201
5385
|
remoteInsId = remoteIns.options.id || remoteInsId;
|
|
5202
|
-
const globalShareScopeMap =
|
|
5386
|
+
const globalShareScopeMap = getGlobalShareScope();
|
|
5203
5387
|
let isAllSharedNotUsed = true;
|
|
5204
5388
|
const needDeleteKeys = [];
|
|
5205
5389
|
Object.keys(globalShareScopeMap).forEach((instId)=>{
|
|
@@ -5244,23 +5428,23 @@ share_cjs.warn = warn;
|
|
|
5244
5428
|
var _globalShareScopeMap_insId_shareScope_shareName, _globalShareScopeMap_insId_shareScope, _globalShareScopeMap_insId;
|
|
5245
5429
|
(_globalShareScopeMap_insId = globalShareScopeMap[insId]) == null ? true : (_globalShareScopeMap_insId_shareScope = _globalShareScopeMap_insId[shareScope]) == null ? true : (_globalShareScopeMap_insId_shareScope_shareName = _globalShareScopeMap_insId_shareScope[shareName]) == null ? true : delete _globalShareScopeMap_insId_shareScope_shareName[shareVersion];
|
|
5246
5430
|
});
|
|
5247
|
-
|
|
5431
|
+
CurrentGlobal.__FEDERATION__.__INSTANCES__.splice(remoteInsIndex, 1);
|
|
5248
5432
|
}
|
|
5249
5433
|
const { hostGlobalSnapshot } = getGlobalRemoteInfo(remote, host);
|
|
5250
5434
|
if (hostGlobalSnapshot) {
|
|
5251
|
-
const remoteKey = hostGlobalSnapshot && 'remotesInfo' in hostGlobalSnapshot && hostGlobalSnapshot.remotesInfo &&
|
|
5435
|
+
const remoteKey = hostGlobalSnapshot && 'remotesInfo' in hostGlobalSnapshot && hostGlobalSnapshot.remotesInfo && getInfoWithoutType(hostGlobalSnapshot.remotesInfo, remote.name).key;
|
|
5252
5436
|
if (remoteKey) {
|
|
5253
5437
|
delete hostGlobalSnapshot.remotesInfo[remoteKey];
|
|
5254
5438
|
if (//eslint-disable-next-line no-extra-boolean-cast
|
|
5255
|
-
Boolean(
|
|
5256
|
-
delete
|
|
5439
|
+
Boolean(Global.__FEDERATION__.__MANIFEST_LOADING__[remoteKey])) {
|
|
5440
|
+
delete Global.__FEDERATION__.__MANIFEST_LOADING__[remoteKey];
|
|
5257
5441
|
}
|
|
5258
5442
|
}
|
|
5259
5443
|
}
|
|
5260
5444
|
host.moduleCache.delete(remote.name);
|
|
5261
5445
|
}
|
|
5262
5446
|
} catch (err) {
|
|
5263
|
-
|
|
5447
|
+
logger.log('removeRemote fail: ', err);
|
|
5264
5448
|
}
|
|
5265
5449
|
}
|
|
5266
5450
|
constructor(host){
|
|
@@ -5299,7 +5483,7 @@ share_cjs.warn = warn;
|
|
|
5299
5483
|
loadShareSync(pkgName, extraOptions) {
|
|
5300
5484
|
return this.sharedHandler.loadShareSync(pkgName, extraOptions);
|
|
5301
5485
|
}
|
|
5302
|
-
initializeSharing(shareScopeName =
|
|
5486
|
+
initializeSharing(shareScopeName = DEFAULT_SCOPE, extraOptions) {
|
|
5303
5487
|
return this.sharedHandler.initializeSharing(shareScopeName, extraOptions);
|
|
5304
5488
|
}
|
|
5305
5489
|
initRawContainer(name, url, container) {
|
|
@@ -5328,7 +5512,7 @@ share_cjs.warn = warn;
|
|
|
5328
5512
|
this.sharedHandler.initShareScopeMap(scopeName, shareScope, extraOptions);
|
|
5329
5513
|
}
|
|
5330
5514
|
formatOptions(globalOptions, userOptions) {
|
|
5331
|
-
const { shared } =
|
|
5515
|
+
const { shared } = formatShareConfigs(globalOptions, userOptions);
|
|
5332
5516
|
const { userOptions: userOptionsRes, options: globalOptionsRes } = this.hooks.lifecycle.beforeInit.emit({
|
|
5333
5517
|
origin: this,
|
|
5334
5518
|
userOptions,
|
|
@@ -5359,12 +5543,13 @@ share_cjs.warn = warn;
|
|
|
5359
5543
|
return optionsRes;
|
|
5360
5544
|
}
|
|
5361
5545
|
registerPlugins(plugins) {
|
|
5362
|
-
const pluginRes = registerPlugins
|
|
5546
|
+
const pluginRes = registerPlugins(plugins, [
|
|
5363
5547
|
this.hooks,
|
|
5364
5548
|
this.remoteHandler.hooks,
|
|
5365
5549
|
this.sharedHandler.hooks,
|
|
5366
5550
|
this.snapshotHandler.hooks,
|
|
5367
|
-
this.loaderHook
|
|
5551
|
+
this.loaderHook,
|
|
5552
|
+
this.bridgeHook
|
|
5368
5553
|
]);
|
|
5369
5554
|
// Merge plugin
|
|
5370
5555
|
this.options.plugins = this.options.plugins.reduce((res, plugin)=>{
|
|
@@ -5387,20 +5572,27 @@ share_cjs.warn = warn;
|
|
|
5387
5572
|
// maybe will change, temporarily for internal use only
|
|
5388
5573
|
initContainer: new AsyncWaterfallHook('initContainer')
|
|
5389
5574
|
});
|
|
5390
|
-
this.version = "0.
|
|
5575
|
+
this.version = "0.9.1";
|
|
5391
5576
|
this.moduleCache = new Map();
|
|
5392
5577
|
this.loaderHook = new PluginSystem({
|
|
5393
5578
|
// FIXME: may not be suitable , not open to the public yet
|
|
5394
5579
|
getModuleInfo: new SyncHook(),
|
|
5395
5580
|
createScript: new SyncHook(),
|
|
5396
5581
|
createLink: new SyncHook(),
|
|
5397
|
-
|
|
5398
|
-
|
|
5582
|
+
fetch: new AsyncHook(),
|
|
5583
|
+
loadEntryError: new AsyncHook(),
|
|
5584
|
+
getModuleFactory: new AsyncHook()
|
|
5585
|
+
});
|
|
5586
|
+
this.bridgeHook = new PluginSystem({
|
|
5587
|
+
beforeBridgeRender: new SyncHook(),
|
|
5588
|
+
afterBridgeRender: new SyncHook(),
|
|
5589
|
+
beforeBridgeDestroy: new SyncHook(),
|
|
5590
|
+
afterBridgeDestroy: new SyncHook()
|
|
5399
5591
|
});
|
|
5400
5592
|
// TODO: Validate the details of the options
|
|
5401
5593
|
// Initialize options with default values
|
|
5402
5594
|
const defaultOptions = {
|
|
5403
|
-
id:
|
|
5595
|
+
id: getBuilderId(),
|
|
5404
5596
|
name: userOptions.name,
|
|
5405
5597
|
plugins: [
|
|
5406
5598
|
snapshotPlugin(),
|
|
@@ -5424,15 +5616,83 @@ share_cjs.warn = warn;
|
|
|
5424
5616
|
}
|
|
5425
5617
|
}
|
|
5426
5618
|
|
|
5619
|
+
var index = /*#__PURE__*/Object.freeze({
|
|
5620
|
+
__proto__: null
|
|
5621
|
+
});
|
|
5622
|
+
|
|
5623
|
+
Object.defineProperty(exports, "loadScript", {
|
|
5624
|
+
enumerable: true,
|
|
5625
|
+
get: function () { return sdk.loadScript; }
|
|
5626
|
+
});
|
|
5627
|
+
Object.defineProperty(exports, "loadScriptNode", {
|
|
5628
|
+
enumerable: true,
|
|
5629
|
+
get: function () { return sdk.loadScriptNode; }
|
|
5630
|
+
});
|
|
5631
|
+
exports.CurrentGlobal = CurrentGlobal;
|
|
5632
|
+
exports.FederationHost = FederationHost;
|
|
5633
|
+
exports.Global = Global;
|
|
5634
|
+
exports.Module = Module;
|
|
5635
|
+
exports.addGlobalSnapshot = addGlobalSnapshot;
|
|
5636
|
+
exports.assert = assert;
|
|
5637
|
+
exports.getGlobalFederationConstructor = getGlobalFederationConstructor;
|
|
5638
|
+
exports.getGlobalSnapshot = getGlobalSnapshot;
|
|
5639
|
+
exports.getInfoWithoutType = getInfoWithoutType;
|
|
5640
|
+
exports.getRegisteredShare = getRegisteredShare;
|
|
5641
|
+
exports.getRemoteEntry = getRemoteEntry;
|
|
5642
|
+
exports.getRemoteInfo = getRemoteInfo;
|
|
5643
|
+
exports.helpers = helpers;
|
|
5644
|
+
exports.isStaticResourcesEqual = isStaticResourcesEqual;
|
|
5645
|
+
exports.matchRemoteWithNameAndExpose = matchRemoteWithNameAndExpose;
|
|
5646
|
+
exports.registerGlobalPlugins = registerGlobalPlugins;
|
|
5647
|
+
exports.resetFederationGlobalInfo = resetFederationGlobalInfo;
|
|
5648
|
+
exports.safeWrapper = safeWrapper;
|
|
5649
|
+
exports.satisfy = satisfy;
|
|
5650
|
+
exports.setGlobalFederationConstructor = setGlobalFederationConstructor;
|
|
5651
|
+
exports.setGlobalFederationInstance = setGlobalFederationInstance;
|
|
5652
|
+
exports.types = index;
|
|
5653
|
+
} (index_cjs$2));
|
|
5654
|
+
|
|
5655
|
+
var utils_cjs = {};
|
|
5656
|
+
|
|
5657
|
+
var runtimeCore = index_cjs$2;
|
|
5658
|
+
|
|
5659
|
+
// injected by bundler, so it can not use runtime-core stuff
|
|
5660
|
+
function getBuilderId() {
|
|
5661
|
+
//@ts-ignore
|
|
5662
|
+
return typeof FEDERATION_BUILD_IDENTIFIER !== 'undefined' ? FEDERATION_BUILD_IDENTIFIER : '';
|
|
5663
|
+
}
|
|
5664
|
+
function getGlobalFederationInstance(name, version) {
|
|
5665
|
+
const buildId = getBuilderId();
|
|
5666
|
+
return runtimeCore.CurrentGlobal.__FEDERATION__.__INSTANCES__.find((GMInstance)=>{
|
|
5667
|
+
if (buildId && GMInstance.options.id === getBuilderId()) {
|
|
5668
|
+
return true;
|
|
5669
|
+
}
|
|
5670
|
+
if (GMInstance.options.name === name && !GMInstance.options.version && !version) {
|
|
5671
|
+
return true;
|
|
5672
|
+
}
|
|
5673
|
+
if (GMInstance.options.name === name && version && GMInstance.options.version === version) {
|
|
5674
|
+
return true;
|
|
5675
|
+
}
|
|
5676
|
+
return false;
|
|
5677
|
+
});
|
|
5678
|
+
}
|
|
5679
|
+
|
|
5680
|
+
utils_cjs.getGlobalFederationInstance = getGlobalFederationInstance;
|
|
5681
|
+
|
|
5682
|
+
(function (exports) {
|
|
5683
|
+
|
|
5684
|
+
var runtimeCore = index_cjs$2;
|
|
5685
|
+
var utils = utils_cjs;
|
|
5686
|
+
|
|
5427
5687
|
let FederationInstance = null;
|
|
5428
5688
|
function init(options) {
|
|
5429
5689
|
// Retrieve the same instance with the same name
|
|
5430
|
-
const instance =
|
|
5690
|
+
const instance = utils.getGlobalFederationInstance(options.name, options.version);
|
|
5431
5691
|
if (!instance) {
|
|
5432
5692
|
// Retrieve debug constructor
|
|
5433
|
-
const FederationConstructor =
|
|
5693
|
+
const FederationConstructor = runtimeCore.getGlobalFederationConstructor() || runtimeCore.FederationHost;
|
|
5434
5694
|
FederationInstance = new FederationConstructor(options);
|
|
5435
|
-
|
|
5695
|
+
runtimeCore.setGlobalFederationInstance(FederationInstance);
|
|
5436
5696
|
return FederationInstance;
|
|
5437
5697
|
} else {
|
|
5438
5698
|
// Merge options
|
|
@@ -5444,35 +5704,35 @@ share_cjs.warn = warn;
|
|
|
5444
5704
|
}
|
|
5445
5705
|
}
|
|
5446
5706
|
function loadRemote(...args) {
|
|
5447
|
-
|
|
5707
|
+
runtimeCore.assert(FederationInstance, 'Please call init first');
|
|
5448
5708
|
const loadRemote1 = FederationInstance.loadRemote;
|
|
5449
5709
|
// eslint-disable-next-line prefer-spread
|
|
5450
5710
|
return loadRemote1.apply(FederationInstance, args);
|
|
5451
5711
|
}
|
|
5452
5712
|
function loadShare(...args) {
|
|
5453
|
-
|
|
5713
|
+
runtimeCore.assert(FederationInstance, 'Please call init first');
|
|
5454
5714
|
// eslint-disable-next-line prefer-spread
|
|
5455
5715
|
const loadShare1 = FederationInstance.loadShare;
|
|
5456
5716
|
return loadShare1.apply(FederationInstance, args);
|
|
5457
5717
|
}
|
|
5458
5718
|
function loadShareSync(...args) {
|
|
5459
|
-
|
|
5719
|
+
runtimeCore.assert(FederationInstance, 'Please call init first');
|
|
5460
5720
|
const loadShareSync1 = FederationInstance.loadShareSync;
|
|
5461
5721
|
// eslint-disable-next-line prefer-spread
|
|
5462
5722
|
return loadShareSync1.apply(FederationInstance, args);
|
|
5463
5723
|
}
|
|
5464
5724
|
function preloadRemote(...args) {
|
|
5465
|
-
|
|
5725
|
+
runtimeCore.assert(FederationInstance, 'Please call init first');
|
|
5466
5726
|
// eslint-disable-next-line prefer-spread
|
|
5467
5727
|
return FederationInstance.preloadRemote.apply(FederationInstance, args);
|
|
5468
5728
|
}
|
|
5469
5729
|
function registerRemotes(...args) {
|
|
5470
|
-
|
|
5730
|
+
runtimeCore.assert(FederationInstance, 'Please call init first');
|
|
5471
5731
|
// eslint-disable-next-line prefer-spread
|
|
5472
5732
|
return FederationInstance.registerRemotes.apply(FederationInstance, args);
|
|
5473
5733
|
}
|
|
5474
5734
|
function registerPlugins(...args) {
|
|
5475
|
-
|
|
5735
|
+
runtimeCore.assert(FederationInstance, 'Please call init first');
|
|
5476
5736
|
// eslint-disable-next-line prefer-spread
|
|
5477
5737
|
return FederationInstance.registerPlugins.apply(FederationInstance, args);
|
|
5478
5738
|
}
|
|
@@ -5480,22 +5740,37 @@ share_cjs.warn = warn;
|
|
|
5480
5740
|
return FederationInstance;
|
|
5481
5741
|
}
|
|
5482
5742
|
// Inject for debug
|
|
5483
|
-
|
|
5743
|
+
runtimeCore.setGlobalFederationConstructor(runtimeCore.FederationHost);
|
|
5484
5744
|
|
|
5485
|
-
Object.defineProperty(exports,
|
|
5745
|
+
Object.defineProperty(exports, "FederationHost", {
|
|
5486
5746
|
enumerable: true,
|
|
5487
|
-
get: function () { return
|
|
5747
|
+
get: function () { return runtimeCore.FederationHost; }
|
|
5488
5748
|
});
|
|
5489
|
-
Object.defineProperty(exports,
|
|
5749
|
+
Object.defineProperty(exports, "Module", {
|
|
5490
5750
|
enumerable: true,
|
|
5491
|
-
get: function () { return
|
|
5751
|
+
get: function () { return runtimeCore.Module; }
|
|
5752
|
+
});
|
|
5753
|
+
Object.defineProperty(exports, "getRemoteEntry", {
|
|
5754
|
+
enumerable: true,
|
|
5755
|
+
get: function () { return runtimeCore.getRemoteEntry; }
|
|
5756
|
+
});
|
|
5757
|
+
Object.defineProperty(exports, "getRemoteInfo", {
|
|
5758
|
+
enumerable: true,
|
|
5759
|
+
get: function () { return runtimeCore.getRemoteInfo; }
|
|
5760
|
+
});
|
|
5761
|
+
Object.defineProperty(exports, "loadScript", {
|
|
5762
|
+
enumerable: true,
|
|
5763
|
+
get: function () { return runtimeCore.loadScript; }
|
|
5764
|
+
});
|
|
5765
|
+
Object.defineProperty(exports, "loadScriptNode", {
|
|
5766
|
+
enumerable: true,
|
|
5767
|
+
get: function () { return runtimeCore.loadScriptNode; }
|
|
5768
|
+
});
|
|
5769
|
+
Object.defineProperty(exports, "registerGlobalPlugins", {
|
|
5770
|
+
enumerable: true,
|
|
5771
|
+
get: function () { return runtimeCore.registerGlobalPlugins; }
|
|
5492
5772
|
});
|
|
5493
|
-
exports.registerGlobalPlugins = share.registerGlobalPlugins;
|
|
5494
|
-
exports.FederationHost = FederationHost;
|
|
5495
|
-
exports.Module = Module;
|
|
5496
5773
|
exports.getInstance = getInstance;
|
|
5497
|
-
exports.getRemoteEntry = getRemoteEntry;
|
|
5498
|
-
exports.getRemoteInfo = getRemoteInfo;
|
|
5499
5774
|
exports.init = init;
|
|
5500
5775
|
exports.loadRemote = loadRemote;
|
|
5501
5776
|
exports.loadShare = loadShare;
|
|
@@ -5503,18 +5778,16 @@ share_cjs.warn = warn;
|
|
|
5503
5778
|
exports.preloadRemote = preloadRemote;
|
|
5504
5779
|
exports.registerPlugins = registerPlugins;
|
|
5505
5780
|
exports.registerRemotes = registerRemotes;
|
|
5506
|
-
} (index_cjs$
|
|
5781
|
+
} (index_cjs$3));
|
|
5507
5782
|
|
|
5508
5783
|
(function (exports) {
|
|
5509
5784
|
|
|
5510
|
-
|
|
5511
|
-
|
|
5512
|
-
var runtime = index_cjs$1;
|
|
5785
|
+
var runtime = index_cjs$3;
|
|
5513
5786
|
|
|
5514
5787
|
|
|
5515
5788
|
|
|
5516
5789
|
Object.keys(runtime).forEach(function (k) {
|
|
5517
|
-
if (k !== 'default' && !
|
|
5790
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
5518
5791
|
enumerable: true,
|
|
5519
5792
|
get: function () { return runtime[k]; }
|
|
5520
5793
|
});
|