@pulse-editor/react-api 0.1.1-beta.82 → 0.1.1-beta.84
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/hooks/editor/use-app-settings.d.ts +13 -0
- package/dist/hooks/editor/use-oauth.d.ts +36 -0
- package/dist/hooks/editor/use-snapshot-state.d.ts +9 -1
- package/dist/main.d.ts +5 -2
- package/dist/main.js +1122 -682
- package/dist/main.js.map +1 -1
- package/dist/pulse-editor-react-api-0.1.1-beta.84.tgz +0 -0
- package/package.json +2 -2
- package/dist/pulse-editor-react-api-0.1.1-beta.82.tgz +0 -0
package/dist/main.js
CHANGED
|
@@ -492,40 +492,6 @@ function useAgents() {
|
|
|
492
492
|
};
|
|
493
493
|
}
|
|
494
494
|
|
|
495
|
-
function useLoading() {
|
|
496
|
-
const receiverHandlerMap = new Map();
|
|
497
|
-
const { imc, isReady } = useIMC(receiverHandlerMap, "loading");
|
|
498
|
-
const [isLoading, setIsLoading] = useState(true);
|
|
499
|
-
useEffect(() => {
|
|
500
|
-
if (isReady) {
|
|
501
|
-
imc?.sendMessage(IMCMessageTypeEnum.EditorLoadingApp, {
|
|
502
|
-
isLoading,
|
|
503
|
-
});
|
|
504
|
-
}
|
|
505
|
-
}, [isLoading]);
|
|
506
|
-
function toggleLoading(isLoading) {
|
|
507
|
-
setIsLoading((prev) => isLoading);
|
|
508
|
-
}
|
|
509
|
-
return {
|
|
510
|
-
isReady,
|
|
511
|
-
toggleLoading,
|
|
512
|
-
};
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
function useNotification() {
|
|
516
|
-
const receiverHandlerMap = new Map();
|
|
517
|
-
const { imc, isReady } = useIMC(receiverHandlerMap, "notification");
|
|
518
|
-
function openNotification(text, type) {
|
|
519
|
-
if (isReady) {
|
|
520
|
-
imc?.sendMessage(IMCMessageTypeEnum.EditorShowNotification, {
|
|
521
|
-
text,
|
|
522
|
-
type,
|
|
523
|
-
});
|
|
524
|
-
}
|
|
525
|
-
}
|
|
526
|
-
return { isReady, openNotification };
|
|
527
|
-
}
|
|
528
|
-
|
|
529
495
|
var MANIFEST_EXT = '.json';
|
|
530
496
|
var BROWSER_LOG_KEY = 'FEDERATION_DEBUG';
|
|
531
497
|
var NameTransformSymbol = {
|
|
@@ -724,7 +690,9 @@ function generateSnapshotFromManifest(manifest) {
|
|
|
724
690
|
return {
|
|
725
691
|
assets: item.assets,
|
|
726
692
|
sharedName: item.name,
|
|
727
|
-
version: item.version
|
|
693
|
+
version: item.version,
|
|
694
|
+
// @ts-ignore
|
|
695
|
+
usedExports: item.referenceExports || []
|
|
728
696
|
};
|
|
729
697
|
}),
|
|
730
698
|
modules: exposes === null || exposes === void 0 ? void 0 : exposes.map(function (expose) {
|
|
@@ -1531,7 +1499,7 @@ var BUILD_001 = 'BUILD-001';
|
|
|
1531
1499
|
var BUILD_002 = 'BUILD-002';
|
|
1532
1500
|
var getDocsUrl = function getDocsUrl(errorCode) {
|
|
1533
1501
|
var type = errorCode.split('-')[0].toLowerCase();
|
|
1534
|
-
return "View the docs to see how to solve: https://module-federation.io/guide/troubleshooting/".concat(type, "
|
|
1502
|
+
return "View the docs to see how to solve: https://module-federation.io/guide/troubleshooting/".concat(type, "#").concat(errorCode.toLowerCase());
|
|
1535
1503
|
};
|
|
1536
1504
|
var getShortErrorMsg = function getShortErrorMsg(errorCode, errorDescMap, args, originalErrorMsg) {
|
|
1537
1505
|
var msg = ["".concat([errorDescMap[errorCode]], " #").concat(errorCode)];
|
|
@@ -1617,7 +1585,7 @@ function getRemoteEntryInfoFromSnapshot(snapshot) {
|
|
|
1617
1585
|
type: 'global',
|
|
1618
1586
|
globalName: ''
|
|
1619
1587
|
};
|
|
1620
|
-
if (isBrowserEnv() || isReactNativeEnv()) {
|
|
1588
|
+
if (isBrowserEnv() || isReactNativeEnv() || !('ssrRemoteEntry' in snapshot)) {
|
|
1621
1589
|
return 'remoteEntry' in snapshot ? {
|
|
1622
1590
|
url: snapshot.remoteEntry,
|
|
1623
1591
|
type: snapshot.remoteEntryType,
|
|
@@ -1710,7 +1678,7 @@ function setGlobalFederationConstructor(FederationConstructor) {
|
|
|
1710
1678
|
var isDebug = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : isDebugMode();
|
|
1711
1679
|
if (isDebug) {
|
|
1712
1680
|
CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = FederationConstructor;
|
|
1713
|
-
CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.
|
|
1681
|
+
CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "2.0.1";
|
|
1714
1682
|
}
|
|
1715
1683
|
}
|
|
1716
1684
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
@@ -2294,7 +2262,7 @@ function satisfy(version, range) {
|
|
|
2294
2262
|
return false;
|
|
2295
2263
|
}
|
|
2296
2264
|
function formatShare(shareArgs, from, name, shareStrategy) {
|
|
2297
|
-
var _shareArgs$version, _shareArgs$scope, _shareArgs$strategy;
|
|
2265
|
+
var _shareArgs$shareConfi, _shareArgs$treeShakin, _shareArgs$version, _shareArgs$scope, _shareArgs$strategy, _shareArgs$treeShakin2, _shareArgs$treeShakin3;
|
|
2298
2266
|
var get;
|
|
2299
2267
|
if ('get' in shareArgs) {
|
|
2300
2268
|
// eslint-disable-next-line prefer-destructuring
|
|
@@ -2310,6 +2278,9 @@ function formatShare(shareArgs, from, name, shareStrategy) {
|
|
|
2310
2278
|
});
|
|
2311
2279
|
};
|
|
2312
2280
|
}
|
|
2281
|
+
if ((_shareArgs$shareConfi = shareArgs.shareConfig) !== null && _shareArgs$shareConfi !== void 0 && _shareArgs$shareConfi.eager && (_shareArgs$treeShakin = shareArgs.treeShaking) !== null && _shareArgs$treeShakin !== void 0 && _shareArgs$treeShakin.mode) {
|
|
2282
|
+
throw new Error('Can not set "eager:true" and "treeShaking" at the same time!');
|
|
2283
|
+
}
|
|
2313
2284
|
return _objectSpread2(_objectSpread2({
|
|
2314
2285
|
deps: [],
|
|
2315
2286
|
useIn: [],
|
|
@@ -2326,40 +2297,68 @@ function formatShare(shareArgs, from, name, shareStrategy) {
|
|
|
2326
2297
|
loaded: shareArgs !== null && shareArgs !== void 0 && shareArgs.loaded || 'lib' in shareArgs ? true : undefined,
|
|
2327
2298
|
version: (_shareArgs$version = shareArgs.version) !== null && _shareArgs$version !== void 0 ? _shareArgs$version : '0',
|
|
2328
2299
|
scope: Array.isArray(shareArgs.scope) ? shareArgs.scope : [(_shareArgs$scope = shareArgs.scope) !== null && _shareArgs$scope !== void 0 ? _shareArgs$scope : 'default'],
|
|
2329
|
-
strategy: ((_shareArgs$strategy = shareArgs.strategy) !== null && _shareArgs$strategy !== void 0 ? _shareArgs$strategy : shareStrategy) || 'version-first'
|
|
2300
|
+
strategy: ((_shareArgs$strategy = shareArgs.strategy) !== null && _shareArgs$strategy !== void 0 ? _shareArgs$strategy : shareStrategy) || 'version-first',
|
|
2301
|
+
treeShaking: shareArgs.treeShaking ? _objectSpread2(_objectSpread2({}, shareArgs.treeShaking), {}, {
|
|
2302
|
+
mode: (_shareArgs$treeShakin2 = shareArgs.treeShaking.mode) !== null && _shareArgs$treeShakin2 !== void 0 ? _shareArgs$treeShakin2 : 'server-calc',
|
|
2303
|
+
status: (_shareArgs$treeShakin3 = shareArgs.treeShaking.status) !== null && _shareArgs$treeShakin3 !== void 0 ? _shareArgs$treeShakin3 : 1 /* TreeShakingStatus.UNKNOWN */,
|
|
2304
|
+
useIn: []
|
|
2305
|
+
}) : undefined
|
|
2330
2306
|
});
|
|
2331
2307
|
}
|
|
2332
|
-
function formatShareConfigs(
|
|
2333
|
-
var shareArgs =
|
|
2334
|
-
var from =
|
|
2335
|
-
var
|
|
2308
|
+
function formatShareConfigs(prevOptions, newOptions) {
|
|
2309
|
+
var shareArgs = newOptions.shared || {};
|
|
2310
|
+
var from = newOptions.name;
|
|
2311
|
+
var newShareInfos = Object.keys(shareArgs).reduce(function (res, pkgName) {
|
|
2336
2312
|
var arrayShareArgs = arrayOptions(shareArgs[pkgName]);
|
|
2337
2313
|
res[pkgName] = res[pkgName] || [];
|
|
2338
2314
|
arrayShareArgs.forEach(function (shareConfig) {
|
|
2339
|
-
res[pkgName].push(formatShare(shareConfig, from, pkgName,
|
|
2315
|
+
res[pkgName].push(formatShare(shareConfig, from, pkgName, newOptions.shareStrategy));
|
|
2340
2316
|
});
|
|
2341
2317
|
return res;
|
|
2342
2318
|
}, {});
|
|
2343
|
-
var
|
|
2344
|
-
Object.keys(
|
|
2345
|
-
if (!
|
|
2346
|
-
|
|
2319
|
+
var allShareInfos = _objectSpread2({}, prevOptions.shared);
|
|
2320
|
+
Object.keys(newShareInfos).forEach(function (shareKey) {
|
|
2321
|
+
if (!allShareInfos[shareKey]) {
|
|
2322
|
+
allShareInfos[shareKey] = newShareInfos[shareKey];
|
|
2347
2323
|
} else {
|
|
2348
|
-
|
|
2349
|
-
var isSameVersion =
|
|
2324
|
+
newShareInfos[shareKey].forEach(function (newUserSharedOptions) {
|
|
2325
|
+
var isSameVersion = allShareInfos[shareKey].find(function (sharedVal) {
|
|
2350
2326
|
return sharedVal.version === newUserSharedOptions.version;
|
|
2351
2327
|
});
|
|
2352
2328
|
if (!isSameVersion) {
|
|
2353
|
-
|
|
2329
|
+
allShareInfos[shareKey].push(newUserSharedOptions);
|
|
2354
2330
|
}
|
|
2355
2331
|
});
|
|
2356
2332
|
}
|
|
2357
2333
|
});
|
|
2358
2334
|
return {
|
|
2359
|
-
|
|
2360
|
-
|
|
2335
|
+
allShareInfos: allShareInfos,
|
|
2336
|
+
newShareInfos: newShareInfos
|
|
2361
2337
|
};
|
|
2362
2338
|
}
|
|
2339
|
+
function shouldUseTreeShaking(treeShaking, usedExports) {
|
|
2340
|
+
if (!treeShaking) {
|
|
2341
|
+
return false;
|
|
2342
|
+
}
|
|
2343
|
+
var status = treeShaking.status,
|
|
2344
|
+
mode = treeShaking.mode;
|
|
2345
|
+
if (status === 0 /* TreeShakingStatus.NO_USE */) {
|
|
2346
|
+
return false;
|
|
2347
|
+
}
|
|
2348
|
+
if (status === 2 /* TreeShakingStatus.CALCULATED */) {
|
|
2349
|
+
return true;
|
|
2350
|
+
}
|
|
2351
|
+
if (mode === 'runtime-infer') {
|
|
2352
|
+
if (!usedExports) {
|
|
2353
|
+
return true;
|
|
2354
|
+
}
|
|
2355
|
+
return isMatchUsedExports(treeShaking, usedExports);
|
|
2356
|
+
}
|
|
2357
|
+
return false;
|
|
2358
|
+
}
|
|
2359
|
+
/**
|
|
2360
|
+
* compare version a and b, return true if a is less than b
|
|
2361
|
+
*/
|
|
2363
2362
|
function versionLt(a, b) {
|
|
2364
2363
|
var transformInvalidVersion = function transformInvalidVersion(version) {
|
|
2365
2364
|
var isNumberVersion = !Number.isNaN(Number(version));
|
|
@@ -2403,19 +2402,80 @@ var isLoaded = function isLoaded(shared) {
|
|
|
2403
2402
|
var isLoading = function isLoading(shared) {
|
|
2404
2403
|
return Boolean(shared.loading);
|
|
2405
2404
|
};
|
|
2406
|
-
function
|
|
2405
|
+
var isMatchUsedExports = function isMatchUsedExports(treeShaking, usedExports) {
|
|
2406
|
+
if (!treeShaking || !usedExports) {
|
|
2407
|
+
return false;
|
|
2408
|
+
}
|
|
2409
|
+
var treeShakingUsedExports = treeShaking.usedExports;
|
|
2410
|
+
if (!treeShakingUsedExports) {
|
|
2411
|
+
return false;
|
|
2412
|
+
}
|
|
2413
|
+
if (usedExports.every(function (e) {
|
|
2414
|
+
return treeShakingUsedExports.includes(e);
|
|
2415
|
+
})) {
|
|
2416
|
+
return true;
|
|
2417
|
+
}
|
|
2418
|
+
return false;
|
|
2419
|
+
};
|
|
2420
|
+
function findSingletonVersionOrderByVersion(shareScopeMap, scope, pkgName, treeShaking) {
|
|
2407
2421
|
var versions = shareScopeMap[scope][pkgName];
|
|
2422
|
+
var version = '';
|
|
2423
|
+
var useTreesShaking = shouldUseTreeShaking(treeShaking);
|
|
2424
|
+
// return false means use prev version
|
|
2408
2425
|
var callback = function callback(prev, cur) {
|
|
2426
|
+
if (useTreesShaking) {
|
|
2427
|
+
if (!versions[prev].treeShaking) {
|
|
2428
|
+
return true;
|
|
2429
|
+
}
|
|
2430
|
+
if (!versions[cur].treeShaking) {
|
|
2431
|
+
return false;
|
|
2432
|
+
}
|
|
2433
|
+
return !isLoaded(versions[prev].treeShaking) && versionLt(prev, cur);
|
|
2434
|
+
}
|
|
2409
2435
|
return !isLoaded(versions[prev]) && versionLt(prev, cur);
|
|
2410
2436
|
};
|
|
2411
|
-
|
|
2437
|
+
if (useTreesShaking) {
|
|
2438
|
+
version = findVersion(shareScopeMap[scope][pkgName], callback);
|
|
2439
|
+
if (version) {
|
|
2440
|
+
return {
|
|
2441
|
+
version: version,
|
|
2442
|
+
useTreesShaking: useTreesShaking
|
|
2443
|
+
};
|
|
2444
|
+
}
|
|
2445
|
+
useTreesShaking = false;
|
|
2446
|
+
}
|
|
2447
|
+
return {
|
|
2448
|
+
version: findVersion(shareScopeMap[scope][pkgName], callback),
|
|
2449
|
+
useTreesShaking: useTreesShaking
|
|
2450
|
+
};
|
|
2412
2451
|
}
|
|
2413
|
-
function
|
|
2452
|
+
var isLoadingOrLoaded = function isLoadingOrLoaded(shared) {
|
|
2453
|
+
return isLoaded(shared) || isLoading(shared);
|
|
2454
|
+
};
|
|
2455
|
+
function findSingletonVersionOrderByLoaded(shareScopeMap, scope, pkgName, treeShaking) {
|
|
2414
2456
|
var versions = shareScopeMap[scope][pkgName];
|
|
2457
|
+
var version = '';
|
|
2458
|
+
var useTreesShaking = shouldUseTreeShaking(treeShaking);
|
|
2459
|
+
// return false means use prev version
|
|
2415
2460
|
var callback = function callback(prev, cur) {
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2461
|
+
if (useTreesShaking) {
|
|
2462
|
+
if (!versions[prev].treeShaking) {
|
|
2463
|
+
return true;
|
|
2464
|
+
}
|
|
2465
|
+
if (!versions[cur].treeShaking) {
|
|
2466
|
+
return false;
|
|
2467
|
+
}
|
|
2468
|
+
if (isLoadingOrLoaded(versions[cur].treeShaking)) {
|
|
2469
|
+
if (isLoadingOrLoaded(versions[prev].treeShaking)) {
|
|
2470
|
+
return Boolean(versionLt(prev, cur));
|
|
2471
|
+
} else {
|
|
2472
|
+
return true;
|
|
2473
|
+
}
|
|
2474
|
+
}
|
|
2475
|
+
if (isLoadingOrLoaded(versions[prev].treeShaking)) {
|
|
2476
|
+
return false;
|
|
2477
|
+
}
|
|
2478
|
+
}
|
|
2419
2479
|
if (isLoadingOrLoaded(versions[cur])) {
|
|
2420
2480
|
if (isLoadingOrLoaded(versions[prev])) {
|
|
2421
2481
|
return Boolean(versionLt(prev, cur));
|
|
@@ -2428,7 +2488,20 @@ function findSingletonVersionOrderByLoaded(shareScopeMap, scope, pkgName) {
|
|
|
2428
2488
|
}
|
|
2429
2489
|
return versionLt(prev, cur);
|
|
2430
2490
|
};
|
|
2431
|
-
|
|
2491
|
+
if (useTreesShaking) {
|
|
2492
|
+
version = findVersion(shareScopeMap[scope][pkgName], callback);
|
|
2493
|
+
if (version) {
|
|
2494
|
+
return {
|
|
2495
|
+
version: version,
|
|
2496
|
+
useTreesShaking: useTreesShaking
|
|
2497
|
+
};
|
|
2498
|
+
}
|
|
2499
|
+
useTreesShaking = false;
|
|
2500
|
+
}
|
|
2501
|
+
return {
|
|
2502
|
+
version: findVersion(shareScopeMap[scope][pkgName], callback),
|
|
2503
|
+
useTreesShaking: useTreesShaking
|
|
2504
|
+
};
|
|
2432
2505
|
}
|
|
2433
2506
|
function getFindShareFunction(strategy) {
|
|
2434
2507
|
if (strategy === 'loaded-first') {
|
|
@@ -2443,7 +2516,8 @@ function getRegisteredShare(localShareScopeMap, pkgName, shareInfo, resolveShare
|
|
|
2443
2516
|
var shareConfig = shareInfo.shareConfig,
|
|
2444
2517
|
_shareInfo$scope = shareInfo.scope,
|
|
2445
2518
|
scope = _shareInfo$scope === void 0 ? DEFAULT_SCOPE : _shareInfo$scope,
|
|
2446
|
-
strategy = shareInfo.strategy
|
|
2519
|
+
strategy = shareInfo.strategy,
|
|
2520
|
+
treeShaking = shareInfo.treeShaking;
|
|
2447
2521
|
var scopes = Array.isArray(scope) ? scope : [scope];
|
|
2448
2522
|
var _iterator3 = _createForOfIteratorHelper(scopes),
|
|
2449
2523
|
_step3;
|
|
@@ -2453,35 +2527,67 @@ function getRegisteredShare(localShareScopeMap, pkgName, shareInfo, resolveShare
|
|
|
2453
2527
|
if (shareConfig && localShareScopeMap[sc] && localShareScopeMap[sc][pkgName]) {
|
|
2454
2528
|
var requiredVersion = shareConfig.requiredVersion;
|
|
2455
2529
|
var findShareFunction = getFindShareFunction(strategy);
|
|
2456
|
-
var
|
|
2457
|
-
|
|
2530
|
+
var _findShareFunction = findShareFunction(localShareScopeMap, sc, pkgName, treeShaking),
|
|
2531
|
+
maxOrSingletonVersion = _findShareFunction.version,
|
|
2532
|
+
useTreesShaking = _findShareFunction.useTreesShaking;
|
|
2458
2533
|
var defaultResolver = function defaultResolver() {
|
|
2534
|
+
var shared = localShareScopeMap[sc][pkgName][maxOrSingletonVersion];
|
|
2459
2535
|
if (shareConfig.singleton) {
|
|
2460
2536
|
if (typeof requiredVersion === 'string' && !satisfy(maxOrSingletonVersion, requiredVersion)) {
|
|
2461
|
-
var msg = "Version ".concat(maxOrSingletonVersion, " from ").concat(maxOrSingletonVersion &&
|
|
2537
|
+
var msg = "Version ".concat(maxOrSingletonVersion, " from ").concat(maxOrSingletonVersion && shared.from, " of shared singleton module ").concat(pkgName, " does not satisfy the requirement of ").concat(shareInfo.from, " which needs ").concat(requiredVersion, ")");
|
|
2462
2538
|
if (shareConfig.strictVersion) {
|
|
2463
2539
|
error(msg);
|
|
2464
2540
|
} else {
|
|
2465
2541
|
warn(msg);
|
|
2466
2542
|
}
|
|
2467
2543
|
}
|
|
2468
|
-
return
|
|
2544
|
+
return {
|
|
2545
|
+
shared: shared,
|
|
2546
|
+
useTreesShaking: useTreesShaking
|
|
2547
|
+
};
|
|
2469
2548
|
} else {
|
|
2470
2549
|
if (requiredVersion === false || requiredVersion === '*') {
|
|
2471
|
-
return
|
|
2550
|
+
return {
|
|
2551
|
+
shared: shared,
|
|
2552
|
+
useTreesShaking: useTreesShaking
|
|
2553
|
+
};
|
|
2472
2554
|
}
|
|
2473
2555
|
if (satisfy(maxOrSingletonVersion, requiredVersion)) {
|
|
2474
|
-
return
|
|
2556
|
+
return {
|
|
2557
|
+
shared: shared,
|
|
2558
|
+
useTreesShaking: useTreesShaking
|
|
2559
|
+
};
|
|
2560
|
+
}
|
|
2561
|
+
var _usedTreeShaking = shouldUseTreeShaking(treeShaking);
|
|
2562
|
+
if (_usedTreeShaking) {
|
|
2563
|
+
for (var _i3 = 0, _Object$entries = Object.entries(localShareScopeMap[sc][pkgName]); _i3 < _Object$entries.length; _i3++) {
|
|
2564
|
+
var _Object$entries$_i = _slicedToArray(_Object$entries[_i3], 2),
|
|
2565
|
+
versionKey = _Object$entries$_i[0],
|
|
2566
|
+
versionValue = _Object$entries$_i[1];
|
|
2567
|
+
if (!shouldUseTreeShaking(versionValue.treeShaking, treeShaking === null || treeShaking === void 0 ? void 0 : treeShaking.usedExports)) {
|
|
2568
|
+
continue;
|
|
2569
|
+
}
|
|
2570
|
+
if (satisfy(versionKey, requiredVersion)) {
|
|
2571
|
+
return {
|
|
2572
|
+
shared: versionValue,
|
|
2573
|
+
useTreesShaking: _usedTreeShaking
|
|
2574
|
+
};
|
|
2575
|
+
}
|
|
2576
|
+
}
|
|
2475
2577
|
}
|
|
2476
|
-
for (var
|
|
2477
|
-
var _Object$
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
if (satisfy(
|
|
2481
|
-
return
|
|
2578
|
+
for (var _i4 = 0, _Object$entries2 = Object.entries(localShareScopeMap[sc][pkgName]); _i4 < _Object$entries2.length; _i4++) {
|
|
2579
|
+
var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i4], 2),
|
|
2580
|
+
_versionKey = _Object$entries2$_i[0],
|
|
2581
|
+
_versionValue = _Object$entries2$_i[1];
|
|
2582
|
+
if (satisfy(_versionKey, requiredVersion)) {
|
|
2583
|
+
return {
|
|
2584
|
+
shared: _versionValue,
|
|
2585
|
+
useTreesShaking: false
|
|
2586
|
+
};
|
|
2482
2587
|
}
|
|
2483
2588
|
}
|
|
2484
2589
|
}
|
|
2590
|
+
return;
|
|
2485
2591
|
};
|
|
2486
2592
|
var params = {
|
|
2487
2593
|
shareScopeMap: localShareScopeMap,
|
|
@@ -2489,6 +2595,7 @@ function getRegisteredShare(localShareScopeMap, pkgName, shareInfo, resolveShare
|
|
|
2489
2595
|
pkgName: pkgName,
|
|
2490
2596
|
version: maxOrSingletonVersion,
|
|
2491
2597
|
GlobalFederation: Global.__FEDERATION__,
|
|
2598
|
+
shareInfo: shareInfo,
|
|
2492
2599
|
resolver: defaultResolver
|
|
2493
2600
|
};
|
|
2494
2601
|
var resolveShared = resolveShare.emit(params) || params;
|
|
@@ -2525,13 +2632,53 @@ function getTargetSharedOptions(options) {
|
|
|
2525
2632
|
shareVersionMap[shared.version] = shared;
|
|
2526
2633
|
});
|
|
2527
2634
|
var callback = function callback(prev, cur) {
|
|
2528
|
-
return
|
|
2635
|
+
return (
|
|
2636
|
+
// TODO: consider multiple treeShaking shared scenes
|
|
2637
|
+
!isLoaded(shareVersionMap[prev]) && versionLt(prev, cur)
|
|
2638
|
+
);
|
|
2529
2639
|
};
|
|
2530
2640
|
var maxVersion = findVersion(shareVersionMap, callback);
|
|
2531
2641
|
return shareVersionMap[maxVersion];
|
|
2532
2642
|
};
|
|
2533
2643
|
var resolver = (_extraOptions$resolve = extraOptions === null || extraOptions === void 0 ? void 0 : extraOptions.resolver) !== null && _extraOptions$resolve !== void 0 ? _extraOptions$resolve : defaultResolver;
|
|
2534
|
-
|
|
2644
|
+
var isPlainObject = function isPlainObject(val) {
|
|
2645
|
+
return val !== null && _typeof(val) === 'object' && !Array.isArray(val);
|
|
2646
|
+
};
|
|
2647
|
+
var _merge = function merge() {
|
|
2648
|
+
var out = {};
|
|
2649
|
+
for (var _len2 = arguments.length, sources = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
2650
|
+
sources[_key2] = arguments[_key2];
|
|
2651
|
+
}
|
|
2652
|
+
for (var _i5 = 0, _sources = sources; _i5 < _sources.length; _i5++) {
|
|
2653
|
+
var src = _sources[_i5];
|
|
2654
|
+
if (!src) continue;
|
|
2655
|
+
for (var _i6 = 0, _Object$entries3 = Object.entries(src); _i6 < _Object$entries3.length; _i6++) {
|
|
2656
|
+
var _Object$entries3$_i = _slicedToArray(_Object$entries3[_i6], 2),
|
|
2657
|
+
key = _Object$entries3$_i[0],
|
|
2658
|
+
value = _Object$entries3$_i[1];
|
|
2659
|
+
var prev = out[key];
|
|
2660
|
+
if (isPlainObject(prev) && isPlainObject(value)) {
|
|
2661
|
+
out[key] = _merge(prev, value);
|
|
2662
|
+
} else if (value !== undefined) {
|
|
2663
|
+
out[key] = value;
|
|
2664
|
+
}
|
|
2665
|
+
}
|
|
2666
|
+
}
|
|
2667
|
+
return out;
|
|
2668
|
+
};
|
|
2669
|
+
return _merge(resolver(shareInfos[pkgName]), extraOptions === null || extraOptions === void 0 ? void 0 : extraOptions.customShareInfo);
|
|
2670
|
+
}
|
|
2671
|
+
var addUseIn = function addUseIn(shared, from) {
|
|
2672
|
+
if (!shared.useIn) {
|
|
2673
|
+
shared.useIn = [];
|
|
2674
|
+
}
|
|
2675
|
+
addUniqueItem(shared.useIn, from);
|
|
2676
|
+
};
|
|
2677
|
+
function directShare(shared, useTreesShaking) {
|
|
2678
|
+
if (useTreesShaking && shared.treeShaking) {
|
|
2679
|
+
return shared.treeShaking;
|
|
2680
|
+
}
|
|
2681
|
+
return shared;
|
|
2535
2682
|
}
|
|
2536
2683
|
function getBuilderId() {
|
|
2537
2684
|
//@ts-ignore
|
|
@@ -2648,13 +2795,13 @@ function loadEsmEntry(_x3) {
|
|
|
2648
2795
|
return _loadEsmEntry.apply(this, arguments);
|
|
2649
2796
|
}
|
|
2650
2797
|
function _loadEsmEntry() {
|
|
2651
|
-
_loadEsmEntry = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
2798
|
+
_loadEsmEntry = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee23(_ref) {
|
|
2652
2799
|
var entry, remoteEntryExports;
|
|
2653
|
-
return _regenerator().w(function (
|
|
2654
|
-
while (1) switch (
|
|
2800
|
+
return _regenerator().w(function (_context23) {
|
|
2801
|
+
while (1) switch (_context23.n) {
|
|
2655
2802
|
case 0:
|
|
2656
2803
|
entry = _ref.entry, remoteEntryExports = _ref.remoteEntryExports;
|
|
2657
|
-
return
|
|
2804
|
+
return _context23.a(2, new Promise(function (resolve, reject) {
|
|
2658
2805
|
try {
|
|
2659
2806
|
if (!remoteEntryExports) {
|
|
2660
2807
|
if (typeof FEDERATION_ALLOW_NEW_FUNCTION !== 'undefined') {
|
|
@@ -2670,7 +2817,7 @@ function _loadEsmEntry() {
|
|
|
2670
2817
|
}
|
|
2671
2818
|
}));
|
|
2672
2819
|
}
|
|
2673
|
-
},
|
|
2820
|
+
}, _callee23);
|
|
2674
2821
|
}));
|
|
2675
2822
|
return _loadEsmEntry.apply(this, arguments);
|
|
2676
2823
|
}
|
|
@@ -2678,13 +2825,13 @@ function loadSystemJsEntry(_x4) {
|
|
|
2678
2825
|
return _loadSystemJsEntry.apply(this, arguments);
|
|
2679
2826
|
}
|
|
2680
2827
|
function _loadSystemJsEntry() {
|
|
2681
|
-
_loadSystemJsEntry = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
2828
|
+
_loadSystemJsEntry = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee24(_ref2) {
|
|
2682
2829
|
var entry, remoteEntryExports;
|
|
2683
|
-
return _regenerator().w(function (
|
|
2684
|
-
while (1) switch (
|
|
2830
|
+
return _regenerator().w(function (_context24) {
|
|
2831
|
+
while (1) switch (_context24.n) {
|
|
2685
2832
|
case 0:
|
|
2686
2833
|
entry = _ref2.entry, remoteEntryExports = _ref2.remoteEntryExports;
|
|
2687
|
-
return
|
|
2834
|
+
return _context24.a(2, new Promise(function (resolve, reject) {
|
|
2688
2835
|
try {
|
|
2689
2836
|
if (!remoteEntryExports) {
|
|
2690
2837
|
//@ts-ignore
|
|
@@ -2702,7 +2849,7 @@ function _loadSystemJsEntry() {
|
|
|
2702
2849
|
}
|
|
2703
2850
|
}));
|
|
2704
2851
|
}
|
|
2705
|
-
},
|
|
2852
|
+
}, _callee24);
|
|
2706
2853
|
}));
|
|
2707
2854
|
return _loadSystemJsEntry.apply(this, arguments);
|
|
2708
2855
|
}
|
|
@@ -2721,22 +2868,22 @@ function loadEntryScript(_x5) {
|
|
|
2721
2868
|
return _loadEntryScript.apply(this, arguments);
|
|
2722
2869
|
}
|
|
2723
2870
|
function _loadEntryScript() {
|
|
2724
|
-
_loadEntryScript = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
2871
|
+
_loadEntryScript = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee25(_ref3) {
|
|
2725
2872
|
var name, globalName, entry, loaderHook, getEntryUrl, _getRemoteEntryExport2, remoteEntryExports, url;
|
|
2726
|
-
return _regenerator().w(function (
|
|
2727
|
-
while (1) switch (
|
|
2873
|
+
return _regenerator().w(function (_context25) {
|
|
2874
|
+
while (1) switch (_context25.n) {
|
|
2728
2875
|
case 0:
|
|
2729
2876
|
name = _ref3.name, globalName = _ref3.globalName, entry = _ref3.entry, loaderHook = _ref3.loaderHook, getEntryUrl = _ref3.getEntryUrl;
|
|
2730
2877
|
_getRemoteEntryExport2 = getRemoteEntryExports(name, globalName), remoteEntryExports = _getRemoteEntryExport2.entryExports;
|
|
2731
2878
|
if (!remoteEntryExports) {
|
|
2732
|
-
|
|
2879
|
+
_context25.n = 1;
|
|
2733
2880
|
break;
|
|
2734
2881
|
}
|
|
2735
|
-
return
|
|
2882
|
+
return _context25.a(2, remoteEntryExports);
|
|
2736
2883
|
case 1:
|
|
2737
2884
|
// if getEntryUrl is passed, use the getEntryUrl to get the entry url
|
|
2738
2885
|
url = getEntryUrl ? getEntryUrl(entry) : entry;
|
|
2739
|
-
return
|
|
2886
|
+
return _context25.a(2, loadScript(url, {
|
|
2740
2887
|
attrs: {},
|
|
2741
2888
|
createScriptHook: function createScriptHook(url, attrs) {
|
|
2742
2889
|
var res = loaderHook.lifecycle.createScript.emit({
|
|
@@ -2762,7 +2909,7 @@ function _loadEntryScript() {
|
|
|
2762
2909
|
throw e;
|
|
2763
2910
|
}));
|
|
2764
2911
|
}
|
|
2765
|
-
},
|
|
2912
|
+
}, _callee25);
|
|
2766
2913
|
}));
|
|
2767
2914
|
return _loadEntryScript.apply(this, arguments);
|
|
2768
2915
|
}
|
|
@@ -2770,28 +2917,28 @@ function loadEntryDom(_x6) {
|
|
|
2770
2917
|
return _loadEntryDom.apply(this, arguments);
|
|
2771
2918
|
}
|
|
2772
2919
|
function _loadEntryDom() {
|
|
2773
|
-
_loadEntryDom = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
2920
|
+
_loadEntryDom = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee26(_ref4) {
|
|
2774
2921
|
var remoteInfo, remoteEntryExports, loaderHook, getEntryUrl, entry, globalName, name, type, _t6;
|
|
2775
|
-
return _regenerator().w(function (
|
|
2776
|
-
while (1) switch (
|
|
2922
|
+
return _regenerator().w(function (_context26) {
|
|
2923
|
+
while (1) switch (_context26.n) {
|
|
2777
2924
|
case 0:
|
|
2778
2925
|
remoteInfo = _ref4.remoteInfo, remoteEntryExports = _ref4.remoteEntryExports, loaderHook = _ref4.loaderHook, getEntryUrl = _ref4.getEntryUrl;
|
|
2779
2926
|
entry = remoteInfo.entry, globalName = remoteInfo.entryGlobalName, name = remoteInfo.name, type = remoteInfo.type;
|
|
2780
2927
|
_t6 = type;
|
|
2781
|
-
|
|
2928
|
+
_context26.n = _t6 === 'esm' ? 1 : _t6 === 'module' ? 1 : _t6 === 'system' ? 2 : 3;
|
|
2782
2929
|
break;
|
|
2783
2930
|
case 1:
|
|
2784
|
-
return
|
|
2931
|
+
return _context26.a(2, loadEsmEntry({
|
|
2785
2932
|
entry: entry,
|
|
2786
2933
|
remoteEntryExports: remoteEntryExports
|
|
2787
2934
|
}));
|
|
2788
2935
|
case 2:
|
|
2789
|
-
return
|
|
2936
|
+
return _context26.a(2, loadSystemJsEntry({
|
|
2790
2937
|
entry: entry,
|
|
2791
2938
|
remoteEntryExports: remoteEntryExports
|
|
2792
2939
|
}));
|
|
2793
2940
|
case 3:
|
|
2794
|
-
return
|
|
2941
|
+
return _context26.a(2, loadEntryScript({
|
|
2795
2942
|
entry: entry,
|
|
2796
2943
|
globalName: globalName,
|
|
2797
2944
|
name: name,
|
|
@@ -2799,9 +2946,9 @@ function _loadEntryDom() {
|
|
|
2799
2946
|
getEntryUrl: getEntryUrl
|
|
2800
2947
|
}));
|
|
2801
2948
|
case 4:
|
|
2802
|
-
return
|
|
2949
|
+
return _context26.a(2);
|
|
2803
2950
|
}
|
|
2804
|
-
},
|
|
2951
|
+
}, _callee26);
|
|
2805
2952
|
}));
|
|
2806
2953
|
return _loadEntryDom.apply(this, arguments);
|
|
2807
2954
|
}
|
|
@@ -2809,21 +2956,21 @@ function loadEntryNode(_x7) {
|
|
|
2809
2956
|
return _loadEntryNode.apply(this, arguments);
|
|
2810
2957
|
}
|
|
2811
2958
|
function _loadEntryNode() {
|
|
2812
|
-
_loadEntryNode = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
2959
|
+
_loadEntryNode = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee27(_ref5) {
|
|
2813
2960
|
var remoteInfo, loaderHook, entry, globalName, name, type, _getRemoteEntryExport3, remoteEntryExports;
|
|
2814
|
-
return _regenerator().w(function (
|
|
2815
|
-
while (1) switch (
|
|
2961
|
+
return _regenerator().w(function (_context27) {
|
|
2962
|
+
while (1) switch (_context27.n) {
|
|
2816
2963
|
case 0:
|
|
2817
2964
|
remoteInfo = _ref5.remoteInfo, loaderHook = _ref5.loaderHook;
|
|
2818
2965
|
entry = remoteInfo.entry, globalName = remoteInfo.entryGlobalName, name = remoteInfo.name, type = remoteInfo.type;
|
|
2819
2966
|
_getRemoteEntryExport3 = getRemoteEntryExports(name, globalName), remoteEntryExports = _getRemoteEntryExport3.entryExports;
|
|
2820
2967
|
if (!remoteEntryExports) {
|
|
2821
|
-
|
|
2968
|
+
_context27.n = 1;
|
|
2822
2969
|
break;
|
|
2823
2970
|
}
|
|
2824
|
-
return
|
|
2971
|
+
return _context27.a(2, remoteEntryExports);
|
|
2825
2972
|
case 1:
|
|
2826
|
-
return
|
|
2973
|
+
return _context27.a(2, loadScriptNode(entry, {
|
|
2827
2974
|
attrs: {
|
|
2828
2975
|
name: name,
|
|
2829
2976
|
globalName: globalName,
|
|
@@ -2849,7 +2996,7 @@ function _loadEntryNode() {
|
|
|
2849
2996
|
throw e;
|
|
2850
2997
|
}));
|
|
2851
2998
|
}
|
|
2852
|
-
},
|
|
2999
|
+
}, _callee27);
|
|
2853
3000
|
}));
|
|
2854
3001
|
return _loadEntryNode.apply(this, arguments);
|
|
2855
3002
|
}
|
|
@@ -2862,18 +3009,18 @@ function getRemoteEntry(_x8) {
|
|
|
2862
3009
|
return _getRemoteEntry.apply(this, arguments);
|
|
2863
3010
|
}
|
|
2864
3011
|
function _getRemoteEntry() {
|
|
2865
|
-
_getRemoteEntry = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
3012
|
+
_getRemoteEntry = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee29(params) {
|
|
2866
3013
|
var origin, remoteEntryExports, remoteInfo, getEntryUrl, _params$_inErrorHandl, _inErrorHandling, uniqueKey, loadEntryHook, loaderHook;
|
|
2867
|
-
return _regenerator().w(function (
|
|
2868
|
-
while (1) switch (
|
|
3014
|
+
return _regenerator().w(function (_context29) {
|
|
3015
|
+
while (1) switch (_context29.n) {
|
|
2869
3016
|
case 0:
|
|
2870
3017
|
origin = params.origin, remoteEntryExports = params.remoteEntryExports, remoteInfo = params.remoteInfo, getEntryUrl = params.getEntryUrl, _params$_inErrorHandl = params._inErrorHandling, _inErrorHandling = _params$_inErrorHandl === void 0 ? false : _params$_inErrorHandl;
|
|
2871
3018
|
uniqueKey = getRemoteEntryUniqueKey(remoteInfo);
|
|
2872
3019
|
if (!remoteEntryExports) {
|
|
2873
|
-
|
|
3020
|
+
_context29.n = 1;
|
|
2874
3021
|
break;
|
|
2875
3022
|
}
|
|
2876
|
-
return
|
|
3023
|
+
return _context29.a(2, remoteEntryExports);
|
|
2877
3024
|
case 1:
|
|
2878
3025
|
if (!globalLoading[uniqueKey]) {
|
|
2879
3026
|
loadEntryHook = origin.remoteHandler.hooks.lifecycle.loadEntry;
|
|
@@ -2898,15 +3045,15 @@ function _getRemoteEntry() {
|
|
|
2898
3045
|
loaderHook: loaderHook
|
|
2899
3046
|
});
|
|
2900
3047
|
})["catch"](/*#__PURE__*/function () {
|
|
2901
|
-
var
|
|
3048
|
+
var _ref25 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee28(err) {
|
|
2902
3049
|
var uniqueKey, isScriptLoadError, wrappedGetRemoteEntry, RemoteEntryExports;
|
|
2903
|
-
return _regenerator().w(function (
|
|
2904
|
-
while (1) switch (
|
|
3050
|
+
return _regenerator().w(function (_context28) {
|
|
3051
|
+
while (1) switch (_context28.n) {
|
|
2905
3052
|
case 0:
|
|
2906
3053
|
uniqueKey = getRemoteEntryUniqueKey(remoteInfo);
|
|
2907
3054
|
isScriptLoadError = err instanceof Error && err.message.includes(RUNTIME_008);
|
|
2908
3055
|
if (!(isScriptLoadError && !_inErrorHandling)) {
|
|
2909
|
-
|
|
3056
|
+
_context28.n = 2;
|
|
2910
3057
|
break;
|
|
2911
3058
|
}
|
|
2912
3059
|
wrappedGetRemoteEntry = function wrappedGetRemoteEntry(params) {
|
|
@@ -2914,7 +3061,7 @@ function _getRemoteEntry() {
|
|
|
2914
3061
|
_inErrorHandling: true
|
|
2915
3062
|
}));
|
|
2916
3063
|
};
|
|
2917
|
-
|
|
3064
|
+
_context28.n = 1;
|
|
2918
3065
|
return origin.loaderHook.lifecycle.loadEntryError.emit({
|
|
2919
3066
|
getRemoteEntry: wrappedGetRemoteEntry,
|
|
2920
3067
|
origin: origin,
|
|
@@ -2924,27 +3071,27 @@ function _getRemoteEntry() {
|
|
|
2924
3071
|
uniqueKey: uniqueKey
|
|
2925
3072
|
});
|
|
2926
3073
|
case 1:
|
|
2927
|
-
RemoteEntryExports =
|
|
3074
|
+
RemoteEntryExports = _context28.v;
|
|
2928
3075
|
if (!RemoteEntryExports) {
|
|
2929
|
-
|
|
3076
|
+
_context28.n = 2;
|
|
2930
3077
|
break;
|
|
2931
3078
|
}
|
|
2932
|
-
return
|
|
3079
|
+
return _context28.a(2, RemoteEntryExports);
|
|
2933
3080
|
case 2:
|
|
2934
3081
|
throw err;
|
|
2935
3082
|
case 3:
|
|
2936
|
-
return
|
|
3083
|
+
return _context28.a(2);
|
|
2937
3084
|
}
|
|
2938
|
-
},
|
|
3085
|
+
}, _callee28);
|
|
2939
3086
|
}));
|
|
2940
|
-
return function (
|
|
2941
|
-
return
|
|
3087
|
+
return function (_x31) {
|
|
3088
|
+
return _ref25.apply(this, arguments);
|
|
2942
3089
|
};
|
|
2943
3090
|
}());
|
|
2944
3091
|
}
|
|
2945
|
-
return
|
|
3092
|
+
return _context29.a(2, globalLoading[uniqueKey]);
|
|
2946
3093
|
}
|
|
2947
|
-
},
|
|
3094
|
+
}, _callee29);
|
|
2948
3095
|
}));
|
|
2949
3096
|
return _getRemoteEntry.apply(this, arguments);
|
|
2950
3097
|
}
|
|
@@ -3128,12 +3275,43 @@ function preloadAssets(remoteInfo, host, assets) {
|
|
|
3128
3275
|
}
|
|
3129
3276
|
}
|
|
3130
3277
|
}
|
|
3278
|
+
function createRemoteEntryInitOptions(remoteInfo, hostShareScopeMap) {
|
|
3279
|
+
var localShareScopeMap = hostShareScopeMap;
|
|
3280
|
+
var shareScopeKeys = Array.isArray(remoteInfo.shareScope) ? remoteInfo.shareScope : [remoteInfo.shareScope];
|
|
3281
|
+
if (!shareScopeKeys.length) {
|
|
3282
|
+
shareScopeKeys.push('default');
|
|
3283
|
+
}
|
|
3284
|
+
shareScopeKeys.forEach(function (shareScopeKey) {
|
|
3285
|
+
if (!localShareScopeMap[shareScopeKey]) {
|
|
3286
|
+
localShareScopeMap[shareScopeKey] = {};
|
|
3287
|
+
}
|
|
3288
|
+
});
|
|
3289
|
+
var remoteEntryInitOptions = {
|
|
3290
|
+
version: remoteInfo.version || '',
|
|
3291
|
+
shareScopeKeys: Array.isArray(remoteInfo.shareScope) ? shareScopeKeys : remoteInfo.shareScope || 'default'
|
|
3292
|
+
};
|
|
3293
|
+
// Help to find host instance
|
|
3294
|
+
Object.defineProperty(remoteEntryInitOptions, 'shareScopeMap', {
|
|
3295
|
+
value: localShareScopeMap,
|
|
3296
|
+
// remoteEntryInitOptions will be traversed and assigned during container init, ,so this attribute is not allowed to be traversed
|
|
3297
|
+
enumerable: false
|
|
3298
|
+
});
|
|
3299
|
+
// TODO: compate legacy init params, should use shareScopeMap if exist
|
|
3300
|
+
var shareScope = localShareScopeMap[shareScopeKeys[0]];
|
|
3301
|
+
var initScope = [];
|
|
3302
|
+
return {
|
|
3303
|
+
remoteEntryInitOptions: remoteEntryInitOptions,
|
|
3304
|
+
shareScope: shareScope,
|
|
3305
|
+
initScope: initScope
|
|
3306
|
+
};
|
|
3307
|
+
}
|
|
3131
3308
|
var Module = /*#__PURE__*/function () {
|
|
3132
3309
|
function Module(_ref6) {
|
|
3133
3310
|
var remoteInfo = _ref6.remoteInfo,
|
|
3134
3311
|
host = _ref6.host;
|
|
3135
3312
|
_classCallCheck(this, Module);
|
|
3136
3313
|
this.inited = false;
|
|
3314
|
+
this.initing = false;
|
|
3137
3315
|
this.lib = undefined;
|
|
3138
3316
|
this.remoteInfo = remoteInfo;
|
|
3139
3317
|
this.host = host;
|
|
@@ -3172,113 +3350,145 @@ var Module = /*#__PURE__*/function () {
|
|
|
3172
3350
|
return getEntry;
|
|
3173
3351
|
}() // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
3174
3352
|
}, {
|
|
3175
|
-
key: "
|
|
3353
|
+
key: "init",
|
|
3176
3354
|
value: function () {
|
|
3177
|
-
var
|
|
3178
|
-
var
|
|
3179
|
-
|
|
3180
|
-
|
|
3355
|
+
var _init = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(id, remoteSnapshot) {
|
|
3356
|
+
var _this = this;
|
|
3357
|
+
var remoteEntryExports;
|
|
3358
|
+
return _regenerator().w(function (_context3) {
|
|
3359
|
+
while (1) switch (_context3.p = _context3.n) {
|
|
3181
3360
|
case 0:
|
|
3182
|
-
|
|
3183
|
-
loadFactory: true
|
|
3184
|
-
}, _ref7$loadFactory = _ref7.loadFactory, loadFactory = _ref7$loadFactory === void 0 ? true : _ref7$loadFactory; // Get remoteEntry.js
|
|
3185
|
-
_context2.n = 1;
|
|
3361
|
+
_context3.n = 1;
|
|
3186
3362
|
return this.getEntry();
|
|
3187
3363
|
case 1:
|
|
3188
|
-
remoteEntryExports =
|
|
3189
|
-
if (this.inited) {
|
|
3190
|
-
|
|
3364
|
+
remoteEntryExports = _context3.v;
|
|
3365
|
+
if (!this.inited) {
|
|
3366
|
+
_context3.n = 2;
|
|
3191
3367
|
break;
|
|
3192
3368
|
}
|
|
3193
|
-
|
|
3194
|
-
shareScopeKeys = Array.isArray(this.remoteInfo.shareScope) ? this.remoteInfo.shareScope : [this.remoteInfo.shareScope];
|
|
3195
|
-
if (!shareScopeKeys.length) {
|
|
3196
|
-
shareScopeKeys.push('default');
|
|
3197
|
-
}
|
|
3198
|
-
shareScopeKeys.forEach(function (shareScopeKey) {
|
|
3199
|
-
if (!localShareScopeMap[shareScopeKey]) {
|
|
3200
|
-
localShareScopeMap[shareScopeKey] = {};
|
|
3201
|
-
}
|
|
3202
|
-
});
|
|
3203
|
-
// TODO: compate legacy init params, should use shareScopeMap if exist
|
|
3204
|
-
shareScope = localShareScopeMap[shareScopeKeys[0]];
|
|
3205
|
-
initScope = [];
|
|
3206
|
-
remoteEntryInitOptions = {
|
|
3207
|
-
version: this.remoteInfo.version || '',
|
|
3208
|
-
shareScopeKeys: Array.isArray(this.remoteInfo.shareScope) ? shareScopeKeys : this.remoteInfo.shareScope || 'default'
|
|
3209
|
-
}; // Help to find host instance
|
|
3210
|
-
Object.defineProperty(remoteEntryInitOptions, 'shareScopeMap', {
|
|
3211
|
-
value: localShareScopeMap,
|
|
3212
|
-
// remoteEntryInitOptions will be traversed and assigned during container init, ,so this attribute is not allowed to be traversed
|
|
3213
|
-
enumerable: false
|
|
3214
|
-
});
|
|
3215
|
-
_context2.n = 2;
|
|
3216
|
-
return this.host.hooks.lifecycle.beforeInitContainer.emit({
|
|
3217
|
-
shareScope: shareScope,
|
|
3218
|
-
// @ts-ignore shareScopeMap will be set by Object.defineProperty
|
|
3219
|
-
remoteEntryInitOptions: remoteEntryInitOptions,
|
|
3220
|
-
initScope: initScope,
|
|
3221
|
-
remoteInfo: this.remoteInfo,
|
|
3222
|
-
origin: this.host
|
|
3223
|
-
});
|
|
3369
|
+
return _context3.a(2, remoteEntryExports);
|
|
3224
3370
|
case 2:
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
hostName: this.host.name,
|
|
3229
|
-
remoteName: this.remoteInfo.name,
|
|
3230
|
-
remoteEntryUrl: this.remoteInfo.entry,
|
|
3231
|
-
remoteEntryKey: this.remoteInfo.entryGlobalName
|
|
3232
|
-
}));
|
|
3371
|
+
if (!this.initPromise) {
|
|
3372
|
+
_context3.n = 4;
|
|
3373
|
+
break;
|
|
3233
3374
|
}
|
|
3234
|
-
|
|
3235
|
-
return
|
|
3375
|
+
_context3.n = 3;
|
|
3376
|
+
return this.initPromise;
|
|
3236
3377
|
case 3:
|
|
3237
|
-
|
|
3238
|
-
return this.host.hooks.lifecycle.initContainer.emit(_objectSpread2(_objectSpread2({}, initContainerOptions), {}, {
|
|
3239
|
-
id: id,
|
|
3240
|
-
remoteSnapshot: remoteSnapshot,
|
|
3241
|
-
remoteEntryExports: remoteEntryExports
|
|
3242
|
-
}));
|
|
3378
|
+
return _context3.a(2, remoteEntryExports);
|
|
3243
3379
|
case 4:
|
|
3380
|
+
this.initing = true;
|
|
3381
|
+
this.initPromise = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
|
|
3382
|
+
var _createRemoteEntryIni, remoteEntryInitOptions, shareScope, initScope, initContainerOptions;
|
|
3383
|
+
return _regenerator().w(function (_context2) {
|
|
3384
|
+
while (1) switch (_context2.n) {
|
|
3385
|
+
case 0:
|
|
3386
|
+
_createRemoteEntryIni = createRemoteEntryInitOptions(_this.remoteInfo, _this.host.shareScopeMap), remoteEntryInitOptions = _createRemoteEntryIni.remoteEntryInitOptions, shareScope = _createRemoteEntryIni.shareScope, initScope = _createRemoteEntryIni.initScope;
|
|
3387
|
+
_context2.n = 1;
|
|
3388
|
+
return _this.host.hooks.lifecycle.beforeInitContainer.emit({
|
|
3389
|
+
shareScope: shareScope,
|
|
3390
|
+
// @ts-ignore shareScopeMap will be set by Object.defineProperty
|
|
3391
|
+
remoteEntryInitOptions: remoteEntryInitOptions,
|
|
3392
|
+
initScope: initScope,
|
|
3393
|
+
remoteInfo: _this.remoteInfo,
|
|
3394
|
+
origin: _this.host
|
|
3395
|
+
});
|
|
3396
|
+
case 1:
|
|
3397
|
+
initContainerOptions = _context2.v;
|
|
3398
|
+
if (typeof (remoteEntryExports === null || remoteEntryExports === void 0 ? void 0 : remoteEntryExports.init) === 'undefined') {
|
|
3399
|
+
error(getShortErrorMsg(RUNTIME_002, runtimeDescMap, {
|
|
3400
|
+
hostName: _this.host.name,
|
|
3401
|
+
remoteName: _this.remoteInfo.name,
|
|
3402
|
+
remoteEntryUrl: _this.remoteInfo.entry,
|
|
3403
|
+
remoteEntryKey: _this.remoteInfo.entryGlobalName
|
|
3404
|
+
}));
|
|
3405
|
+
}
|
|
3406
|
+
_context2.n = 2;
|
|
3407
|
+
return remoteEntryExports.init(initContainerOptions.shareScope, initContainerOptions.initScope, initContainerOptions.remoteEntryInitOptions);
|
|
3408
|
+
case 2:
|
|
3409
|
+
_context2.n = 3;
|
|
3410
|
+
return _this.host.hooks.lifecycle.initContainer.emit(_objectSpread2(_objectSpread2({}, initContainerOptions), {}, {
|
|
3411
|
+
id: id,
|
|
3412
|
+
remoteSnapshot: remoteSnapshot,
|
|
3413
|
+
remoteEntryExports: remoteEntryExports
|
|
3414
|
+
}));
|
|
3415
|
+
case 3:
|
|
3416
|
+
_this.inited = true;
|
|
3417
|
+
case 4:
|
|
3418
|
+
return _context2.a(2);
|
|
3419
|
+
}
|
|
3420
|
+
}, _callee2);
|
|
3421
|
+
}))();
|
|
3422
|
+
_context3.p = 5;
|
|
3423
|
+
_context3.n = 6;
|
|
3424
|
+
return this.initPromise;
|
|
3425
|
+
case 6:
|
|
3426
|
+
_context3.p = 6;
|
|
3427
|
+
this.initing = false;
|
|
3428
|
+
this.initPromise = undefined;
|
|
3429
|
+
return _context3.f(6);
|
|
3430
|
+
case 7:
|
|
3431
|
+
return _context3.a(2, remoteEntryExports);
|
|
3432
|
+
}
|
|
3433
|
+
}, _callee3, this, [[5,, 6, 7]]);
|
|
3434
|
+
}));
|
|
3435
|
+
function init(_x9, _x0) {
|
|
3436
|
+
return _init.apply(this, arguments);
|
|
3437
|
+
}
|
|
3438
|
+
return init;
|
|
3439
|
+
}() // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
3440
|
+
}, {
|
|
3441
|
+
key: "get",
|
|
3442
|
+
value: function () {
|
|
3443
|
+
var _get = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(id, expose, options, remoteSnapshot) {
|
|
3444
|
+
var _ref8, _ref8$loadFactory, loadFactory, remoteEntryExports, moduleFactory, symbolName, wrapModuleFactory, exposeContent;
|
|
3445
|
+
return _regenerator().w(function (_context4) {
|
|
3446
|
+
while (1) switch (_context4.n) {
|
|
3447
|
+
case 0:
|
|
3448
|
+
_ref8 = options || {
|
|
3449
|
+
loadFactory: true
|
|
3450
|
+
}, _ref8$loadFactory = _ref8.loadFactory, loadFactory = _ref8$loadFactory === void 0 ? true : _ref8$loadFactory;
|
|
3451
|
+
_context4.n = 1;
|
|
3452
|
+
return this.init(id, remoteSnapshot);
|
|
3453
|
+
case 1:
|
|
3454
|
+
remoteEntryExports = _context4.v;
|
|
3244
3455
|
this.lib = remoteEntryExports;
|
|
3245
|
-
|
|
3246
|
-
_context2.n = 5;
|
|
3456
|
+
_context4.n = 2;
|
|
3247
3457
|
return this.host.loaderHook.lifecycle.getModuleFactory.emit({
|
|
3248
3458
|
remoteEntryExports: remoteEntryExports,
|
|
3249
3459
|
expose: expose,
|
|
3250
3460
|
moduleInfo: this.remoteInfo
|
|
3251
3461
|
});
|
|
3252
|
-
case
|
|
3253
|
-
moduleFactory =
|
|
3462
|
+
case 2:
|
|
3463
|
+
moduleFactory = _context4.v;
|
|
3254
3464
|
if (moduleFactory) {
|
|
3255
|
-
|
|
3465
|
+
_context4.n = 4;
|
|
3256
3466
|
break;
|
|
3257
3467
|
}
|
|
3258
|
-
|
|
3468
|
+
_context4.n = 3;
|
|
3259
3469
|
return remoteEntryExports.get(expose);
|
|
3260
|
-
case
|
|
3261
|
-
moduleFactory =
|
|
3262
|
-
case
|
|
3470
|
+
case 3:
|
|
3471
|
+
moduleFactory = _context4.v;
|
|
3472
|
+
case 4:
|
|
3263
3473
|
assert(moduleFactory, "".concat(getFMId(this.remoteInfo), " remote don't export ").concat(expose, "."));
|
|
3264
3474
|
// keep symbol for module name always one format
|
|
3265
3475
|
symbolName = processModuleAlias(this.remoteInfo.name, expose);
|
|
3266
3476
|
wrapModuleFactory = this.wraperFactory(moduleFactory, symbolName);
|
|
3267
3477
|
if (loadFactory) {
|
|
3268
|
-
|
|
3478
|
+
_context4.n = 5;
|
|
3269
3479
|
break;
|
|
3270
3480
|
}
|
|
3271
|
-
return
|
|
3272
|
-
case
|
|
3273
|
-
|
|
3481
|
+
return _context4.a(2, wrapModuleFactory);
|
|
3482
|
+
case 5:
|
|
3483
|
+
_context4.n = 6;
|
|
3274
3484
|
return wrapModuleFactory();
|
|
3275
|
-
case
|
|
3276
|
-
exposeContent =
|
|
3277
|
-
return
|
|
3485
|
+
case 6:
|
|
3486
|
+
exposeContent = _context4.v;
|
|
3487
|
+
return _context4.a(2, exposeContent);
|
|
3278
3488
|
}
|
|
3279
|
-
},
|
|
3489
|
+
}, _callee4, this);
|
|
3280
3490
|
}));
|
|
3281
|
-
function get(
|
|
3491
|
+
function get(_x1, _x10, _x11, _x12) {
|
|
3282
3492
|
return _get.apply(this, arguments);
|
|
3283
3493
|
}
|
|
3284
3494
|
return get;
|
|
@@ -3295,20 +3505,20 @@ var Module = /*#__PURE__*/function () {
|
|
|
3295
3505
|
}
|
|
3296
3506
|
}
|
|
3297
3507
|
if (moduleFactory instanceof Promise) {
|
|
3298
|
-
return /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
3508
|
+
return /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5() {
|
|
3299
3509
|
var res;
|
|
3300
|
-
return _regenerator().w(function (
|
|
3301
|
-
while (1) switch (
|
|
3510
|
+
return _regenerator().w(function (_context5) {
|
|
3511
|
+
while (1) switch (_context5.n) {
|
|
3302
3512
|
case 0:
|
|
3303
|
-
|
|
3513
|
+
_context5.n = 1;
|
|
3304
3514
|
return moduleFactory();
|
|
3305
3515
|
case 1:
|
|
3306
|
-
res =
|
|
3516
|
+
res = _context5.v;
|
|
3307
3517
|
// This parameter is used for bridge debugging
|
|
3308
3518
|
defineModuleId(res, id);
|
|
3309
|
-
return
|
|
3519
|
+
return _context5.a(2, res);
|
|
3310
3520
|
}
|
|
3311
|
-
},
|
|
3521
|
+
}, _callee5);
|
|
3312
3522
|
}));
|
|
3313
3523
|
} else {
|
|
3314
3524
|
return function () {
|
|
@@ -3345,8 +3555,8 @@ var SyncHook = /*#__PURE__*/function () {
|
|
|
3345
3555
|
this.on(function wrapper() {
|
|
3346
3556
|
self.remove(wrapper);
|
|
3347
3557
|
// eslint-disable-next-line prefer-spread
|
|
3348
|
-
for (var
|
|
3349
|
-
args[
|
|
3558
|
+
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
3559
|
+
args[_key3] = arguments[_key3];
|
|
3350
3560
|
}
|
|
3351
3561
|
return fn.apply(null, args);
|
|
3352
3562
|
});
|
|
@@ -3354,8 +3564,8 @@ var SyncHook = /*#__PURE__*/function () {
|
|
|
3354
3564
|
}, {
|
|
3355
3565
|
key: "emit",
|
|
3356
3566
|
value: function emit() {
|
|
3357
|
-
for (var
|
|
3358
|
-
data[
|
|
3567
|
+
for (var _len4 = arguments.length, data = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
|
|
3568
|
+
data[_key4] = arguments[_key4];
|
|
3359
3569
|
}
|
|
3360
3570
|
var result;
|
|
3361
3571
|
if (this.listeners.size > 0) {
|
|
@@ -3387,8 +3597,8 @@ var AsyncHook = /*#__PURE__*/function (_SyncHook) {
|
|
|
3387
3597
|
return _createClass(AsyncHook, [{
|
|
3388
3598
|
key: "emit",
|
|
3389
3599
|
value: function emit() {
|
|
3390
|
-
for (var
|
|
3391
|
-
data[
|
|
3600
|
+
for (var _len5 = arguments.length, data = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
|
|
3601
|
+
data[_key5] = arguments[_key5];
|
|
3392
3602
|
}
|
|
3393
3603
|
var result;
|
|
3394
3604
|
var ls = Array.from(this.listeners);
|
|
@@ -3425,12 +3635,12 @@ function checkReturnData(originalData, returnedData) {
|
|
|
3425
3635
|
}
|
|
3426
3636
|
var SyncWaterfallHook = /*#__PURE__*/function (_SyncHook2) {
|
|
3427
3637
|
function SyncWaterfallHook(type) {
|
|
3428
|
-
var
|
|
3638
|
+
var _this2;
|
|
3429
3639
|
_classCallCheck(this, SyncWaterfallHook);
|
|
3430
|
-
|
|
3431
|
-
|
|
3432
|
-
|
|
3433
|
-
return
|
|
3640
|
+
_this2 = _callSuper(this, SyncWaterfallHook);
|
|
3641
|
+
_this2.onerror = error;
|
|
3642
|
+
_this2.type = type;
|
|
3643
|
+
return _this2;
|
|
3434
3644
|
}
|
|
3435
3645
|
_inherits(SyncWaterfallHook, _SyncHook2);
|
|
3436
3646
|
return _createClass(SyncWaterfallHook, [{
|
|
@@ -3468,18 +3678,18 @@ var SyncWaterfallHook = /*#__PURE__*/function (_SyncHook2) {
|
|
|
3468
3678
|
}(SyncHook);
|
|
3469
3679
|
var AsyncWaterfallHook = /*#__PURE__*/function (_SyncHook3) {
|
|
3470
3680
|
function AsyncWaterfallHook(type) {
|
|
3471
|
-
var
|
|
3681
|
+
var _this3;
|
|
3472
3682
|
_classCallCheck(this, AsyncWaterfallHook);
|
|
3473
|
-
|
|
3474
|
-
|
|
3475
|
-
|
|
3476
|
-
return
|
|
3683
|
+
_this3 = _callSuper(this, AsyncWaterfallHook);
|
|
3684
|
+
_this3.onerror = error;
|
|
3685
|
+
_this3.type = type;
|
|
3686
|
+
return _this3;
|
|
3477
3687
|
}
|
|
3478
3688
|
_inherits(AsyncWaterfallHook, _SyncHook3);
|
|
3479
3689
|
return _createClass(AsyncWaterfallHook, [{
|
|
3480
3690
|
key: "emit",
|
|
3481
3691
|
value: function emit(data) {
|
|
3482
|
-
var
|
|
3692
|
+
var _this4 = this;
|
|
3483
3693
|
if (!isObject(data)) {
|
|
3484
3694
|
error("The response data for the \"".concat(this.type, "\" hook must be an object."));
|
|
3485
3695
|
}
|
|
@@ -3488,7 +3698,7 @@ var AsyncWaterfallHook = /*#__PURE__*/function (_SyncHook3) {
|
|
|
3488
3698
|
var i = 0;
|
|
3489
3699
|
var processError = function processError(e) {
|
|
3490
3700
|
warn(e);
|
|
3491
|
-
|
|
3701
|
+
_this4.onerror(e);
|
|
3492
3702
|
return data;
|
|
3493
3703
|
};
|
|
3494
3704
|
var _call2 = function call(prevData) {
|
|
@@ -3502,7 +3712,7 @@ var AsyncWaterfallHook = /*#__PURE__*/function (_SyncHook3) {
|
|
|
3502
3712
|
}
|
|
3503
3713
|
}
|
|
3504
3714
|
} else {
|
|
3505
|
-
|
|
3715
|
+
_this4.onerror("A plugin returned an incorrect value for the \"".concat(_this4.type, "\" type."));
|
|
3506
3716
|
}
|
|
3507
3717
|
return data;
|
|
3508
3718
|
};
|
|
@@ -3522,7 +3732,7 @@ var PluginSystem = /*#__PURE__*/function () {
|
|
|
3522
3732
|
return _createClass(PluginSystem, [{
|
|
3523
3733
|
key: "applyPlugin",
|
|
3524
3734
|
value: function applyPlugin(plugin, instance) {
|
|
3525
|
-
var
|
|
3735
|
+
var _this5 = this;
|
|
3526
3736
|
assert(isPlainObject(plugin), 'Plugin configuration is invalid.');
|
|
3527
3737
|
// The plugin's name is mandatory and must be unique
|
|
3528
3738
|
var pluginName = plugin.name;
|
|
@@ -3534,7 +3744,7 @@ var PluginSystem = /*#__PURE__*/function () {
|
|
|
3534
3744
|
Object.keys(this.lifecycle).forEach(function (key) {
|
|
3535
3745
|
var pluginLife = plugin[key];
|
|
3536
3746
|
if (pluginLife) {
|
|
3537
|
-
|
|
3747
|
+
_this5.lifecycle[key].on(pluginLife);
|
|
3538
3748
|
}
|
|
3539
3749
|
});
|
|
3540
3750
|
}
|
|
@@ -3542,13 +3752,13 @@ var PluginSystem = /*#__PURE__*/function () {
|
|
|
3542
3752
|
}, {
|
|
3543
3753
|
key: "removePlugin",
|
|
3544
3754
|
value: function removePlugin(pluginName) {
|
|
3545
|
-
var
|
|
3755
|
+
var _this6 = this;
|
|
3546
3756
|
assert(pluginName, 'A name is required.');
|
|
3547
3757
|
var plugin = this.registerPlugins[pluginName];
|
|
3548
3758
|
assert(plugin, "The plugin \"".concat(pluginName, "\" is not registered."));
|
|
3549
3759
|
Object.keys(plugin).forEach(function (key) {
|
|
3550
3760
|
if (key !== 'name') {
|
|
3551
|
-
|
|
3761
|
+
_this6.lifecycle[key].remove(plugin[key]);
|
|
3552
3762
|
}
|
|
3553
3763
|
});
|
|
3554
3764
|
}
|
|
@@ -3573,23 +3783,23 @@ function snapshotPlugin() {
|
|
|
3573
3783
|
return {
|
|
3574
3784
|
name: 'snapshot-plugin',
|
|
3575
3785
|
afterResolve: function afterResolve(args) {
|
|
3576
|
-
return _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
3786
|
+
return _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6() {
|
|
3577
3787
|
var remote, pkgNameOrAlias, expose, origin, remoteInfo, id, _yield$origin$snapsho, remoteSnapshot, globalSnapshot, preloadOptions, assets;
|
|
3578
|
-
return _regenerator().w(function (
|
|
3579
|
-
while (1) switch (
|
|
3788
|
+
return _regenerator().w(function (_context6) {
|
|
3789
|
+
while (1) switch (_context6.n) {
|
|
3580
3790
|
case 0:
|
|
3581
3791
|
remote = args.remote, pkgNameOrAlias = args.pkgNameOrAlias, expose = args.expose, origin = args.origin, remoteInfo = args.remoteInfo, id = args.id;
|
|
3582
3792
|
if (!(!isRemoteInfoWithEntry(remote) || !isPureRemoteEntry(remote))) {
|
|
3583
|
-
|
|
3793
|
+
_context6.n = 3;
|
|
3584
3794
|
break;
|
|
3585
3795
|
}
|
|
3586
|
-
|
|
3796
|
+
_context6.n = 1;
|
|
3587
3797
|
return origin.snapshotHandler.loadRemoteSnapshotInfo({
|
|
3588
3798
|
moduleInfo: remote,
|
|
3589
3799
|
id: id
|
|
3590
3800
|
});
|
|
3591
3801
|
case 1:
|
|
3592
|
-
_yield$origin$snapsho =
|
|
3802
|
+
_yield$origin$snapsho = _context6.v;
|
|
3593
3803
|
remoteSnapshot = _yield$origin$snapsho.remoteSnapshot;
|
|
3594
3804
|
globalSnapshot = _yield$origin$snapsho.globalSnapshot;
|
|
3595
3805
|
assignRemoteInfo(remoteInfo, remoteSnapshot);
|
|
@@ -3604,7 +3814,7 @@ function snapshotPlugin() {
|
|
|
3604
3814
|
depsRemote: false
|
|
3605
3815
|
}
|
|
3606
3816
|
};
|
|
3607
|
-
|
|
3817
|
+
_context6.n = 2;
|
|
3608
3818
|
return origin.remoteHandler.hooks.lifecycle.generatePreloadAssets.emit({
|
|
3609
3819
|
origin: origin,
|
|
3610
3820
|
preloadOptions: preloadOptions,
|
|
@@ -3614,17 +3824,17 @@ function snapshotPlugin() {
|
|
|
3614
3824
|
globalSnapshot: globalSnapshot
|
|
3615
3825
|
});
|
|
3616
3826
|
case 2:
|
|
3617
|
-
assets =
|
|
3827
|
+
assets = _context6.v;
|
|
3618
3828
|
if (assets) {
|
|
3619
3829
|
preloadAssets(remoteInfo, origin, assets, false);
|
|
3620
3830
|
}
|
|
3621
|
-
return
|
|
3831
|
+
return _context6.a(2, _objectSpread2(_objectSpread2({}, args), {}, {
|
|
3622
3832
|
remoteSnapshot: remoteSnapshot
|
|
3623
3833
|
}));
|
|
3624
3834
|
case 3:
|
|
3625
|
-
return
|
|
3835
|
+
return _context6.a(2, args);
|
|
3626
3836
|
}
|
|
3627
|
-
},
|
|
3837
|
+
}, _callee6);
|
|
3628
3838
|
}))();
|
|
3629
3839
|
}
|
|
3630
3840
|
};
|
|
@@ -3663,8 +3873,8 @@ function traverseModuleInfo(globalSnapshot, remoteInfo, traverse, isRoot) {
|
|
|
3663
3873
|
traverse(effectiveRemoteSnapshot, remoteInfo, isRoot);
|
|
3664
3874
|
if (effectiveRemoteSnapshot.remotesInfo) {
|
|
3665
3875
|
var remoteKeys = Object.keys(effectiveRemoteSnapshot.remotesInfo);
|
|
3666
|
-
for (var
|
|
3667
|
-
var key = _remoteKeys[
|
|
3876
|
+
for (var _i7 = 0, _remoteKeys = remoteKeys; _i7 < _remoteKeys.length; _i7++) {
|
|
3877
|
+
var key = _remoteKeys[_i7];
|
|
3668
3878
|
if (memo[key]) {
|
|
3669
3879
|
continue;
|
|
3670
3880
|
}
|
|
@@ -3784,7 +3994,8 @@ function _generatePreloadAssets(origin, preloadOptions, remote, globalSnapshot,
|
|
|
3784
3994
|
}, true, memo, remoteSnapshot);
|
|
3785
3995
|
if (remoteSnapshot.shared && remoteSnapshot.shared.length > 0) {
|
|
3786
3996
|
var collectSharedAssets = function collectSharedAssets(shareInfo, snapshotShared) {
|
|
3787
|
-
var
|
|
3997
|
+
var _ref0 = getRegisteredShare(origin.shareScopeMap, snapshotShared.sharedName, shareInfo, origin.sharedHandler.hooks.lifecycle.resolveShare) || {},
|
|
3998
|
+
registeredShared = _ref0.shared;
|
|
3788
3999
|
// 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.
|
|
3789
4000
|
if (registeredShared && typeof registeredShared.lib === 'function') {
|
|
3790
4001
|
snapshotShared.assets.js.sync.forEach(function (asset) {
|
|
@@ -3832,27 +4043,27 @@ var generatePreloadAssetsPlugin = function generatePreloadAssetsPlugin() {
|
|
|
3832
4043
|
return {
|
|
3833
4044
|
name: 'generate-preload-assets-plugin',
|
|
3834
4045
|
generatePreloadAssets: function generatePreloadAssets(args) {
|
|
3835
|
-
return _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
4046
|
+
return _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7() {
|
|
3836
4047
|
var origin, preloadOptions, remoteInfo, remote, globalSnapshot, remoteSnapshot, assets;
|
|
3837
|
-
return _regenerator().w(function (
|
|
3838
|
-
while (1) switch (
|
|
4048
|
+
return _regenerator().w(function (_context7) {
|
|
4049
|
+
while (1) switch (_context7.n) {
|
|
3839
4050
|
case 0:
|
|
3840
4051
|
origin = args.origin, preloadOptions = args.preloadOptions, remoteInfo = args.remoteInfo, remote = args.remote, globalSnapshot = args.globalSnapshot, remoteSnapshot = args.remoteSnapshot;
|
|
3841
4052
|
if (isBrowserEnv()) {
|
|
3842
|
-
|
|
4053
|
+
_context7.n = 1;
|
|
3843
4054
|
break;
|
|
3844
4055
|
}
|
|
3845
|
-
return
|
|
4056
|
+
return _context7.a(2, {
|
|
3846
4057
|
cssAssets: [],
|
|
3847
4058
|
jsAssetsWithoutEntry: [],
|
|
3848
4059
|
entryAssets: []
|
|
3849
4060
|
});
|
|
3850
4061
|
case 1:
|
|
3851
4062
|
if (!(isRemoteInfoWithEntry(remote) && isPureRemoteEntry(remote))) {
|
|
3852
|
-
|
|
4063
|
+
_context7.n = 2;
|
|
3853
4064
|
break;
|
|
3854
4065
|
}
|
|
3855
|
-
return
|
|
4066
|
+
return _context7.a(2, {
|
|
3856
4067
|
cssAssets: [],
|
|
3857
4068
|
jsAssetsWithoutEntry: [],
|
|
3858
4069
|
entryAssets: [{
|
|
@@ -3870,9 +4081,9 @@ var generatePreloadAssetsPlugin = function generatePreloadAssetsPlugin() {
|
|
|
3870
4081
|
case 2:
|
|
3871
4082
|
assignRemoteInfo(remoteInfo, remoteSnapshot);
|
|
3872
4083
|
assets = _generatePreloadAssets(origin, preloadOptions, remoteInfo, globalSnapshot, remoteSnapshot);
|
|
3873
|
-
return
|
|
4084
|
+
return _context7.a(2, assets);
|
|
3874
4085
|
}
|
|
3875
|
-
},
|
|
4086
|
+
}, _callee7);
|
|
3876
4087
|
}))();
|
|
3877
4088
|
}
|
|
3878
4089
|
};
|
|
@@ -3922,14 +4133,14 @@ var SnapshotHandler = /*#__PURE__*/function () {
|
|
|
3922
4133
|
return _createClass(SnapshotHandler, [{
|
|
3923
4134
|
key: "loadRemoteSnapshotInfo",
|
|
3924
4135
|
value: function () {
|
|
3925
|
-
var _loadRemoteSnapshotInfo = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
4136
|
+
var _loadRemoteSnapshotInfo = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8(_ref1) {
|
|
3926
4137
|
var moduleInfo, id, options, hostSnapshot, _hostSnapshot, _this$getGlobalRemote, hostGlobalSnapshot, remoteSnapshot, globalSnapshot, _yield$this$hooks$lif, globalRemoteSnapshot, globalSnapshotRes, mSnapshot, gSnapshot, remoteEntry, moduleSnapshot, _globalSnapshotRes, _yield$this$hooks$lif2, remoteSnapshotRes, _moduleSnapshot, _globalSnapshotRes2, _yield$this$hooks$lif3, _remoteSnapshotRes;
|
|
3927
|
-
return _regenerator().w(function (
|
|
3928
|
-
while (1) switch (
|
|
4138
|
+
return _regenerator().w(function (_context8) {
|
|
4139
|
+
while (1) switch (_context8.n) {
|
|
3929
4140
|
case 0:
|
|
3930
|
-
moduleInfo =
|
|
4141
|
+
moduleInfo = _ref1.moduleInfo, id = _ref1.id, _ref1.expose;
|
|
3931
4142
|
options = this.HostInstance.options;
|
|
3932
|
-
|
|
4143
|
+
_context8.n = 1;
|
|
3933
4144
|
return this.hooks.lifecycle.beforeLoadRemoteSnapshot.emit({
|
|
3934
4145
|
options: options,
|
|
3935
4146
|
moduleInfo: moduleInfo
|
|
@@ -3957,7 +4168,7 @@ var SnapshotHandler = /*#__PURE__*/function () {
|
|
|
3957
4168
|
}
|
|
3958
4169
|
}
|
|
3959
4170
|
_this$getGlobalRemote = this.getGlobalRemoteInfo(moduleInfo), hostGlobalSnapshot = _this$getGlobalRemote.hostGlobalSnapshot, remoteSnapshot = _this$getGlobalRemote.remoteSnapshot, globalSnapshot = _this$getGlobalRemote.globalSnapshot;
|
|
3960
|
-
|
|
4171
|
+
_context8.n = 2;
|
|
3961
4172
|
return this.hooks.lifecycle.loadSnapshot.emit({
|
|
3962
4173
|
options: options,
|
|
3963
4174
|
moduleInfo: moduleInfo,
|
|
@@ -3966,22 +4177,22 @@ var SnapshotHandler = /*#__PURE__*/function () {
|
|
|
3966
4177
|
globalSnapshot: globalSnapshot
|
|
3967
4178
|
});
|
|
3968
4179
|
case 2:
|
|
3969
|
-
_yield$this$hooks$lif =
|
|
4180
|
+
_yield$this$hooks$lif = _context8.v;
|
|
3970
4181
|
globalRemoteSnapshot = _yield$this$hooks$lif.remoteSnapshot;
|
|
3971
4182
|
globalSnapshotRes = _yield$this$hooks$lif.globalSnapshot;
|
|
3972
4183
|
if (!globalRemoteSnapshot) {
|
|
3973
|
-
|
|
4184
|
+
_context8.n = 7;
|
|
3974
4185
|
break;
|
|
3975
4186
|
}
|
|
3976
4187
|
if (!isManifestProvider(globalRemoteSnapshot)) {
|
|
3977
|
-
|
|
4188
|
+
_context8.n = 4;
|
|
3978
4189
|
break;
|
|
3979
4190
|
}
|
|
3980
4191
|
remoteEntry = isBrowserEnv() ? globalRemoteSnapshot.remoteEntry : globalRemoteSnapshot.ssrRemoteEntry || globalRemoteSnapshot.remoteEntry || '';
|
|
3981
|
-
|
|
4192
|
+
_context8.n = 3;
|
|
3982
4193
|
return this.getManifestJson(remoteEntry, moduleInfo, {});
|
|
3983
4194
|
case 3:
|
|
3984
|
-
moduleSnapshot =
|
|
4195
|
+
moduleSnapshot = _context8.v;
|
|
3985
4196
|
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
3986
4197
|
_globalSnapshotRes = setGlobalSnapshotInfoByModuleInfo(_objectSpread2(_objectSpread2({}, moduleInfo), {}, {
|
|
3987
4198
|
// The global remote may be overridden
|
|
@@ -3990,10 +4201,10 @@ var SnapshotHandler = /*#__PURE__*/function () {
|
|
|
3990
4201
|
}), moduleSnapshot);
|
|
3991
4202
|
mSnapshot = moduleSnapshot;
|
|
3992
4203
|
gSnapshot = _globalSnapshotRes;
|
|
3993
|
-
|
|
4204
|
+
_context8.n = 6;
|
|
3994
4205
|
break;
|
|
3995
4206
|
case 4:
|
|
3996
|
-
|
|
4207
|
+
_context8.n = 5;
|
|
3997
4208
|
return this.hooks.lifecycle.loadRemoteSnapshot.emit({
|
|
3998
4209
|
options: this.HostInstance.options,
|
|
3999
4210
|
moduleInfo: moduleInfo,
|
|
@@ -4001,25 +4212,25 @@ var SnapshotHandler = /*#__PURE__*/function () {
|
|
|
4001
4212
|
from: 'global'
|
|
4002
4213
|
});
|
|
4003
4214
|
case 5:
|
|
4004
|
-
_yield$this$hooks$lif2 =
|
|
4215
|
+
_yield$this$hooks$lif2 = _context8.v;
|
|
4005
4216
|
remoteSnapshotRes = _yield$this$hooks$lif2.remoteSnapshot;
|
|
4006
4217
|
mSnapshot = remoteSnapshotRes;
|
|
4007
4218
|
gSnapshot = globalSnapshotRes;
|
|
4008
4219
|
case 6:
|
|
4009
|
-
|
|
4220
|
+
_context8.n = 11;
|
|
4010
4221
|
break;
|
|
4011
4222
|
case 7:
|
|
4012
4223
|
if (!isRemoteInfoWithEntry(moduleInfo)) {
|
|
4013
|
-
|
|
4224
|
+
_context8.n = 10;
|
|
4014
4225
|
break;
|
|
4015
4226
|
}
|
|
4016
|
-
|
|
4227
|
+
_context8.n = 8;
|
|
4017
4228
|
return this.getManifestJson(moduleInfo.entry, moduleInfo, {});
|
|
4018
4229
|
case 8:
|
|
4019
|
-
_moduleSnapshot =
|
|
4230
|
+
_moduleSnapshot = _context8.v;
|
|
4020
4231
|
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
4021
4232
|
_globalSnapshotRes2 = setGlobalSnapshotInfoByModuleInfo(moduleInfo, _moduleSnapshot);
|
|
4022
|
-
|
|
4233
|
+
_context8.n = 9;
|
|
4023
4234
|
return this.hooks.lifecycle.loadRemoteSnapshot.emit({
|
|
4024
4235
|
options: this.HostInstance.options,
|
|
4025
4236
|
moduleInfo: moduleInfo,
|
|
@@ -4027,11 +4238,11 @@ var SnapshotHandler = /*#__PURE__*/function () {
|
|
|
4027
4238
|
from: 'global'
|
|
4028
4239
|
});
|
|
4029
4240
|
case 9:
|
|
4030
|
-
_yield$this$hooks$lif3 =
|
|
4241
|
+
_yield$this$hooks$lif3 = _context8.v;
|
|
4031
4242
|
_remoteSnapshotRes = _yield$this$hooks$lif3.remoteSnapshot;
|
|
4032
4243
|
mSnapshot = _remoteSnapshotRes;
|
|
4033
4244
|
gSnapshot = _globalSnapshotRes2;
|
|
4034
|
-
|
|
4245
|
+
_context8.n = 11;
|
|
4035
4246
|
break;
|
|
4036
4247
|
case 10:
|
|
4037
4248
|
error(getShortErrorMsg(RUNTIME_007, runtimeDescMap, {
|
|
@@ -4040,7 +4251,7 @@ var SnapshotHandler = /*#__PURE__*/function () {
|
|
|
4040
4251
|
globalSnapshot: JSON.stringify(globalSnapshotRes)
|
|
4041
4252
|
}));
|
|
4042
4253
|
case 11:
|
|
4043
|
-
|
|
4254
|
+
_context8.n = 12;
|
|
4044
4255
|
return this.hooks.lifecycle.afterLoadSnapshot.emit({
|
|
4045
4256
|
id: id,
|
|
4046
4257
|
host: this.HostInstance,
|
|
@@ -4049,14 +4260,14 @@ var SnapshotHandler = /*#__PURE__*/function () {
|
|
|
4049
4260
|
remoteSnapshot: mSnapshot
|
|
4050
4261
|
});
|
|
4051
4262
|
case 12:
|
|
4052
|
-
return
|
|
4263
|
+
return _context8.a(2, {
|
|
4053
4264
|
remoteSnapshot: mSnapshot,
|
|
4054
4265
|
globalSnapshot: gSnapshot
|
|
4055
4266
|
});
|
|
4056
4267
|
}
|
|
4057
|
-
},
|
|
4268
|
+
}, _callee8, this);
|
|
4058
4269
|
}));
|
|
4059
|
-
function loadRemoteSnapshotInfo(
|
|
4270
|
+
function loadRemoteSnapshotInfo(_x13) {
|
|
4060
4271
|
return _loadRemoteSnapshotInfo.apply(this, arguments);
|
|
4061
4272
|
}
|
|
4062
4273
|
return loadRemoteSnapshotInfo;
|
|
@@ -4069,93 +4280,93 @@ var SnapshotHandler = /*#__PURE__*/function () {
|
|
|
4069
4280
|
}, {
|
|
4070
4281
|
key: "getManifestJson",
|
|
4071
4282
|
value: function () {
|
|
4072
|
-
var _getManifestJson = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
4073
|
-
var
|
|
4283
|
+
var _getManifestJson = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1(manifestUrl, moduleInfo, extraOptions) {
|
|
4284
|
+
var _this7 = this;
|
|
4074
4285
|
var getManifest, asyncLoadProcess;
|
|
4075
|
-
return _regenerator().w(function (
|
|
4076
|
-
while (1) switch (
|
|
4286
|
+
return _regenerator().w(function (_context1) {
|
|
4287
|
+
while (1) switch (_context1.n) {
|
|
4077
4288
|
case 0:
|
|
4078
4289
|
getManifest = /*#__PURE__*/function () {
|
|
4079
|
-
var
|
|
4290
|
+
var _ref10 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9() {
|
|
4080
4291
|
var manifestJson, res, _t;
|
|
4081
|
-
return _regenerator().w(function (
|
|
4082
|
-
while (1) switch (
|
|
4292
|
+
return _regenerator().w(function (_context9) {
|
|
4293
|
+
while (1) switch (_context9.p = _context9.n) {
|
|
4083
4294
|
case 0:
|
|
4084
|
-
manifestJson =
|
|
4295
|
+
manifestJson = _this7.manifestCache.get(manifestUrl);
|
|
4085
4296
|
if (!manifestJson) {
|
|
4086
|
-
|
|
4297
|
+
_context9.n = 1;
|
|
4087
4298
|
break;
|
|
4088
4299
|
}
|
|
4089
|
-
return
|
|
4300
|
+
return _context9.a(2, manifestJson);
|
|
4090
4301
|
case 1:
|
|
4091
|
-
|
|
4092
|
-
|
|
4093
|
-
return
|
|
4302
|
+
_context9.p = 1;
|
|
4303
|
+
_context9.n = 2;
|
|
4304
|
+
return _this7.loaderHook.lifecycle.fetch.emit(manifestUrl, {});
|
|
4094
4305
|
case 2:
|
|
4095
|
-
res =
|
|
4306
|
+
res = _context9.v;
|
|
4096
4307
|
if (!(!res || !(res instanceof Response))) {
|
|
4097
|
-
|
|
4308
|
+
_context9.n = 4;
|
|
4098
4309
|
break;
|
|
4099
4310
|
}
|
|
4100
|
-
|
|
4311
|
+
_context9.n = 3;
|
|
4101
4312
|
return fetch(manifestUrl, {});
|
|
4102
4313
|
case 3:
|
|
4103
|
-
res =
|
|
4314
|
+
res = _context9.v;
|
|
4104
4315
|
case 4:
|
|
4105
|
-
|
|
4316
|
+
_context9.n = 5;
|
|
4106
4317
|
return res.json();
|
|
4107
4318
|
case 5:
|
|
4108
|
-
manifestJson =
|
|
4109
|
-
|
|
4319
|
+
manifestJson = _context9.v;
|
|
4320
|
+
_context9.n = 8;
|
|
4110
4321
|
break;
|
|
4111
4322
|
case 6:
|
|
4112
|
-
|
|
4113
|
-
_t =
|
|
4114
|
-
|
|
4115
|
-
return
|
|
4323
|
+
_context9.p = 6;
|
|
4324
|
+
_t = _context9.v;
|
|
4325
|
+
_context9.n = 7;
|
|
4326
|
+
return _this7.HostInstance.remoteHandler.hooks.lifecycle.errorLoadRemote.emit({
|
|
4116
4327
|
id: manifestUrl,
|
|
4117
4328
|
error: _t,
|
|
4118
4329
|
from: 'runtime',
|
|
4119
4330
|
lifecycle: 'afterResolve',
|
|
4120
|
-
origin:
|
|
4331
|
+
origin: _this7.HostInstance
|
|
4121
4332
|
});
|
|
4122
4333
|
case 7:
|
|
4123
|
-
manifestJson =
|
|
4334
|
+
manifestJson = _context9.v;
|
|
4124
4335
|
if (!manifestJson) {
|
|
4125
|
-
delete
|
|
4336
|
+
delete _this7.manifestLoading[manifestUrl];
|
|
4126
4337
|
error(getShortErrorMsg(RUNTIME_003, runtimeDescMap, {
|
|
4127
4338
|
manifestUrl: manifestUrl,
|
|
4128
4339
|
moduleName: moduleInfo.name,
|
|
4129
|
-
hostName:
|
|
4340
|
+
hostName: _this7.HostInstance.options.name
|
|
4130
4341
|
}, "".concat(_t)));
|
|
4131
4342
|
}
|
|
4132
4343
|
case 8:
|
|
4133
4344
|
assert(manifestJson.metaData && manifestJson.exposes && manifestJson.shared, "".concat(manifestUrl, " is not a federation manifest"));
|
|
4134
|
-
|
|
4135
|
-
return
|
|
4345
|
+
_this7.manifestCache.set(manifestUrl, manifestJson);
|
|
4346
|
+
return _context9.a(2, manifestJson);
|
|
4136
4347
|
}
|
|
4137
|
-
},
|
|
4348
|
+
}, _callee9, null, [[1, 6]]);
|
|
4138
4349
|
}));
|
|
4139
4350
|
return function getManifest() {
|
|
4140
|
-
return
|
|
4351
|
+
return _ref10.apply(this, arguments);
|
|
4141
4352
|
};
|
|
4142
4353
|
}();
|
|
4143
4354
|
asyncLoadProcess = /*#__PURE__*/function () {
|
|
4144
|
-
var
|
|
4145
|
-
var manifestJson, remoteSnapshot, _yield$
|
|
4146
|
-
return _regenerator().w(function (
|
|
4147
|
-
while (1) switch (
|
|
4355
|
+
var _ref11 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0() {
|
|
4356
|
+
var manifestJson, remoteSnapshot, _yield$_this7$hooks$l, remoteSnapshotRes;
|
|
4357
|
+
return _regenerator().w(function (_context0) {
|
|
4358
|
+
while (1) switch (_context0.n) {
|
|
4148
4359
|
case 0:
|
|
4149
|
-
|
|
4360
|
+
_context0.n = 1;
|
|
4150
4361
|
return getManifest();
|
|
4151
4362
|
case 1:
|
|
4152
|
-
manifestJson =
|
|
4363
|
+
manifestJson = _context0.v;
|
|
4153
4364
|
remoteSnapshot = generateSnapshotFromManifest(manifestJson, {
|
|
4154
4365
|
version: manifestUrl
|
|
4155
4366
|
});
|
|
4156
|
-
|
|
4157
|
-
return
|
|
4158
|
-
options:
|
|
4367
|
+
_context0.n = 2;
|
|
4368
|
+
return _this7.hooks.lifecycle.loadRemoteSnapshot.emit({
|
|
4369
|
+
options: _this7.HostInstance.options,
|
|
4159
4370
|
moduleInfo: moduleInfo,
|
|
4160
4371
|
manifestJson: manifestJson,
|
|
4161
4372
|
remoteSnapshot: remoteSnapshot,
|
|
@@ -4163,14 +4374,14 @@ var SnapshotHandler = /*#__PURE__*/function () {
|
|
|
4163
4374
|
from: 'manifest'
|
|
4164
4375
|
});
|
|
4165
4376
|
case 2:
|
|
4166
|
-
_yield$
|
|
4167
|
-
remoteSnapshotRes = _yield$
|
|
4168
|
-
return
|
|
4377
|
+
_yield$_this7$hooks$l = _context0.v;
|
|
4378
|
+
remoteSnapshotRes = _yield$_this7$hooks$l.remoteSnapshot;
|
|
4379
|
+
return _context0.a(2, remoteSnapshotRes);
|
|
4169
4380
|
}
|
|
4170
|
-
},
|
|
4381
|
+
}, _callee0);
|
|
4171
4382
|
}));
|
|
4172
4383
|
return function asyncLoadProcess() {
|
|
4173
|
-
return
|
|
4384
|
+
return _ref11.apply(this, arguments);
|
|
4174
4385
|
};
|
|
4175
4386
|
}();
|
|
4176
4387
|
if (!this.manifestLoading[manifestUrl]) {
|
|
@@ -4178,11 +4389,11 @@ var SnapshotHandler = /*#__PURE__*/function () {
|
|
|
4178
4389
|
return res;
|
|
4179
4390
|
});
|
|
4180
4391
|
}
|
|
4181
|
-
return
|
|
4392
|
+
return _context1.a(2, this.manifestLoading[manifestUrl]);
|
|
4182
4393
|
}
|
|
4183
|
-
},
|
|
4394
|
+
}, _callee1, this);
|
|
4184
4395
|
}));
|
|
4185
|
-
function getManifestJson(
|
|
4396
|
+
function getManifestJson(_x14, _x15, _x16) {
|
|
4186
4397
|
return _getManifestJson.apply(this, arguments);
|
|
4187
4398
|
}
|
|
4188
4399
|
return getManifestJson;
|
|
@@ -4193,6 +4404,7 @@ var SharedHandler = /*#__PURE__*/function () {
|
|
|
4193
4404
|
function SharedHandler(host) {
|
|
4194
4405
|
_classCallCheck(this, SharedHandler);
|
|
4195
4406
|
this.hooks = new PluginSystem({
|
|
4407
|
+
beforeRegisterShare: new SyncWaterfallHook('beforeRegisterShare'),
|
|
4196
4408
|
afterResolve: new AsyncWaterfallHook('afterResolve'),
|
|
4197
4409
|
beforeLoadShare: new AsyncWaterfallHook('beforeLoadShare'),
|
|
4198
4410
|
// not used yet
|
|
@@ -4210,19 +4422,24 @@ var SharedHandler = /*#__PURE__*/function () {
|
|
|
4210
4422
|
return _createClass(SharedHandler, [{
|
|
4211
4423
|
key: "registerShared",
|
|
4212
4424
|
value: function registerShared(globalOptions, userOptions) {
|
|
4213
|
-
var
|
|
4425
|
+
var _this8 = this;
|
|
4214
4426
|
var _formatShareConfigs = formatShareConfigs(globalOptions, userOptions),
|
|
4215
|
-
|
|
4216
|
-
|
|
4217
|
-
var sharedKeys = Object.keys(
|
|
4427
|
+
newShareInfos = _formatShareConfigs.newShareInfos,
|
|
4428
|
+
allShareInfos = _formatShareConfigs.allShareInfos;
|
|
4429
|
+
var sharedKeys = Object.keys(newShareInfos);
|
|
4218
4430
|
sharedKeys.forEach(function (sharedKey) {
|
|
4219
|
-
var sharedVals =
|
|
4431
|
+
var sharedVals = newShareInfos[sharedKey];
|
|
4220
4432
|
sharedVals.forEach(function (sharedVal) {
|
|
4221
4433
|
sharedVal.scope.forEach(function (sc) {
|
|
4222
|
-
var
|
|
4223
|
-
|
|
4434
|
+
var _this8$shareScopeMap$;
|
|
4435
|
+
_this8.hooks.lifecycle.beforeRegisterShare.emit({
|
|
4436
|
+
origin: _this8.host,
|
|
4437
|
+
pkgName: sharedKey,
|
|
4438
|
+
shared: sharedVal
|
|
4439
|
+
});
|
|
4440
|
+
var registeredShared = (_this8$shareScopeMap$ = _this8.shareScopeMap[sc]) === null || _this8$shareScopeMap$ === void 0 ? void 0 : _this8$shareScopeMap$[sharedKey];
|
|
4224
4441
|
if (!registeredShared) {
|
|
4225
|
-
|
|
4442
|
+
_this8.setShared({
|
|
4226
4443
|
pkgName: sharedKey,
|
|
4227
4444
|
lib: sharedVal.lib,
|
|
4228
4445
|
get: sharedVal.get,
|
|
@@ -4235,18 +4452,18 @@ var SharedHandler = /*#__PURE__*/function () {
|
|
|
4235
4452
|
});
|
|
4236
4453
|
});
|
|
4237
4454
|
return {
|
|
4238
|
-
|
|
4239
|
-
|
|
4455
|
+
newShareInfos: newShareInfos,
|
|
4456
|
+
allShareInfos: allShareInfos
|
|
4240
4457
|
};
|
|
4241
4458
|
}
|
|
4242
4459
|
}, {
|
|
4243
4460
|
key: "loadShare",
|
|
4244
4461
|
value: function () {
|
|
4245
|
-
var _loadShare = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
4246
|
-
var
|
|
4247
|
-
var host, shareOptions, loadShareRes, shareOptionsRes, registeredShared,
|
|
4248
|
-
return _regenerator().w(function (
|
|
4249
|
-
while (1) switch (
|
|
4462
|
+
var _loadShare = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee13(pkgName, extraOptions) {
|
|
4463
|
+
var _this9 = this;
|
|
4464
|
+
var host, shareOptions, loadShareRes, shareOptionsRes, _ref13, registeredShared, useTreesShaking, targetShared, factory, asyncLoadProcess, loading, _useTreeShaking, _targetShared, _asyncLoadProcess, _loading;
|
|
4465
|
+
return _regenerator().w(function (_context13) {
|
|
4466
|
+
while (1) switch (_context13.n) {
|
|
4250
4467
|
case 0:
|
|
4251
4468
|
host = this.host; // This function performs the following steps:
|
|
4252
4469
|
// 1. Checks if the currently loaded share already exists, if not, it throws an error
|
|
@@ -4258,30 +4475,30 @@ var SharedHandler = /*#__PURE__*/function () {
|
|
|
4258
4475
|
shareInfos: host.options.shared
|
|
4259
4476
|
});
|
|
4260
4477
|
if (!(shareOptions !== null && shareOptions !== void 0 && shareOptions.scope)) {
|
|
4261
|
-
|
|
4478
|
+
_context13.n = 1;
|
|
4262
4479
|
break;
|
|
4263
4480
|
}
|
|
4264
|
-
|
|
4481
|
+
_context13.n = 1;
|
|
4265
4482
|
return Promise.all(shareOptions.scope.map(/*#__PURE__*/function () {
|
|
4266
|
-
var
|
|
4267
|
-
return _regenerator().w(function (
|
|
4268
|
-
while (1) switch (
|
|
4483
|
+
var _ref12 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10(shareScope) {
|
|
4484
|
+
return _regenerator().w(function (_context10) {
|
|
4485
|
+
while (1) switch (_context10.n) {
|
|
4269
4486
|
case 0:
|
|
4270
|
-
|
|
4271
|
-
return Promise.all(
|
|
4487
|
+
_context10.n = 1;
|
|
4488
|
+
return Promise.all(_this9.initializeSharing(shareScope, {
|
|
4272
4489
|
strategy: shareOptions.strategy
|
|
4273
4490
|
}));
|
|
4274
4491
|
case 1:
|
|
4275
|
-
return
|
|
4492
|
+
return _context10.a(2);
|
|
4276
4493
|
}
|
|
4277
|
-
},
|
|
4494
|
+
}, _callee10);
|
|
4278
4495
|
}));
|
|
4279
|
-
return function (
|
|
4280
|
-
return
|
|
4496
|
+
return function (_x19) {
|
|
4497
|
+
return _ref12.apply(this, arguments);
|
|
4281
4498
|
};
|
|
4282
4499
|
}()));
|
|
4283
4500
|
case 1:
|
|
4284
|
-
|
|
4501
|
+
_context13.n = 2;
|
|
4285
4502
|
return this.hooks.lifecycle.beforeLoadShare.emit({
|
|
4286
4503
|
pkgName: pkgName,
|
|
4287
4504
|
shareInfo: shareOptions,
|
|
@@ -4289,62 +4506,56 @@ var SharedHandler = /*#__PURE__*/function () {
|
|
|
4289
4506
|
origin: host
|
|
4290
4507
|
});
|
|
4291
4508
|
case 2:
|
|
4292
|
-
loadShareRes =
|
|
4509
|
+
loadShareRes = _context13.v;
|
|
4293
4510
|
shareOptionsRes = loadShareRes.shareInfo; // Assert that shareInfoRes exists, if not, throw an error
|
|
4294
4511
|
assert(shareOptionsRes, "Cannot find ".concat(pkgName, " Share in the ").concat(host.options.name, ". Please ensure that the ").concat(pkgName, " Share parameters have been injected"));
|
|
4295
|
-
|
|
4296
|
-
|
|
4297
|
-
|
|
4298
|
-
|
|
4299
|
-
|
|
4300
|
-
|
|
4301
|
-
|
|
4302
|
-
|
|
4303
|
-
if (!(registeredShared && registeredShared.lib)) {
|
|
4304
|
-
_context11.n = 3;
|
|
4512
|
+
_ref13 = getRegisteredShare(this.shareScopeMap, pkgName, shareOptionsRes, this.hooks.lifecycle.resolveShare) || {}, registeredShared = _ref13.shared, useTreesShaking = _ref13.useTreesShaking;
|
|
4513
|
+
if (!registeredShared) {
|
|
4514
|
+
_context13.n = 7;
|
|
4515
|
+
break;
|
|
4516
|
+
}
|
|
4517
|
+
targetShared = directShare(registeredShared, useTreesShaking);
|
|
4518
|
+
if (!targetShared.lib) {
|
|
4519
|
+
_context13.n = 3;
|
|
4305
4520
|
break;
|
|
4306
4521
|
}
|
|
4307
|
-
addUseIn(
|
|
4308
|
-
return
|
|
4522
|
+
addUseIn(targetShared, host.options.name);
|
|
4523
|
+
return _context13.a(2, targetShared.lib);
|
|
4309
4524
|
case 3:
|
|
4310
|
-
if (!(
|
|
4311
|
-
|
|
4525
|
+
if (!(targetShared.loading && !targetShared.loaded)) {
|
|
4526
|
+
_context13.n = 5;
|
|
4312
4527
|
break;
|
|
4313
4528
|
}
|
|
4314
|
-
|
|
4315
|
-
return
|
|
4529
|
+
_context13.n = 4;
|
|
4530
|
+
return targetShared.loading;
|
|
4316
4531
|
case 4:
|
|
4317
|
-
factory =
|
|
4318
|
-
|
|
4319
|
-
if (!
|
|
4320
|
-
|
|
4532
|
+
factory = _context13.v;
|
|
4533
|
+
targetShared.loaded = true;
|
|
4534
|
+
if (!targetShared.lib) {
|
|
4535
|
+
targetShared.lib = factory;
|
|
4321
4536
|
}
|
|
4322
|
-
addUseIn(
|
|
4323
|
-
return
|
|
4537
|
+
addUseIn(targetShared, host.options.name);
|
|
4538
|
+
return _context13.a(2, factory);
|
|
4324
4539
|
case 5:
|
|
4325
|
-
if (!registeredShared) {
|
|
4326
|
-
_context11.n = 6;
|
|
4327
|
-
break;
|
|
4328
|
-
}
|
|
4329
4540
|
asyncLoadProcess = /*#__PURE__*/function () {
|
|
4330
|
-
var
|
|
4541
|
+
var _ref14 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee11() {
|
|
4331
4542
|
var factory;
|
|
4332
|
-
return _regenerator().w(function (
|
|
4333
|
-
while (1) switch (
|
|
4543
|
+
return _regenerator().w(function (_context11) {
|
|
4544
|
+
while (1) switch (_context11.n) {
|
|
4334
4545
|
case 0:
|
|
4335
|
-
|
|
4336
|
-
return
|
|
4546
|
+
_context11.n = 1;
|
|
4547
|
+
return targetShared.get();
|
|
4337
4548
|
case 1:
|
|
4338
|
-
factory =
|
|
4339
|
-
addUseIn(
|
|
4340
|
-
|
|
4341
|
-
|
|
4342
|
-
return
|
|
4549
|
+
factory = _context11.v;
|
|
4550
|
+
addUseIn(targetShared, host.options.name);
|
|
4551
|
+
targetShared.loaded = true;
|
|
4552
|
+
targetShared.lib = factory;
|
|
4553
|
+
return _context11.a(2, factory);
|
|
4343
4554
|
}
|
|
4344
|
-
},
|
|
4555
|
+
}, _callee11);
|
|
4345
4556
|
}));
|
|
4346
4557
|
return function asyncLoadProcess() {
|
|
4347
|
-
return
|
|
4558
|
+
return _ref14.apply(this, arguments);
|
|
4348
4559
|
};
|
|
4349
4560
|
}();
|
|
4350
4561
|
loading = asyncLoadProcess();
|
|
@@ -4354,41 +4565,48 @@ var SharedHandler = /*#__PURE__*/function () {
|
|
|
4354
4565
|
shared: registeredShared,
|
|
4355
4566
|
from: host.options.name,
|
|
4356
4567
|
lib: null,
|
|
4357
|
-
loading: loading
|
|
4568
|
+
loading: loading,
|
|
4569
|
+
treeShaking: useTreesShaking ? targetShared : undefined
|
|
4358
4570
|
});
|
|
4359
|
-
return
|
|
4571
|
+
return _context13.a(2, loading);
|
|
4360
4572
|
case 6:
|
|
4573
|
+
_context13.n = 9;
|
|
4574
|
+
break;
|
|
4575
|
+
case 7:
|
|
4361
4576
|
if (!(extraOptions !== null && extraOptions !== void 0 && extraOptions.customShareInfo)) {
|
|
4362
|
-
|
|
4577
|
+
_context13.n = 8;
|
|
4363
4578
|
break;
|
|
4364
4579
|
}
|
|
4365
|
-
return
|
|
4366
|
-
case
|
|
4580
|
+
return _context13.a(2, false);
|
|
4581
|
+
case 8:
|
|
4582
|
+
_useTreeShaking = shouldUseTreeShaking(shareOptionsRes.treeShaking);
|
|
4583
|
+
_targetShared = directShare(shareOptionsRes, _useTreeShaking);
|
|
4367
4584
|
_asyncLoadProcess = /*#__PURE__*/function () {
|
|
4368
|
-
var
|
|
4369
|
-
var factory, gShared;
|
|
4370
|
-
return _regenerator().w(function (
|
|
4371
|
-
while (1) switch (
|
|
4585
|
+
var _ref15 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12() {
|
|
4586
|
+
var factory, _ref16, gShared, gUseTreeShaking, targetGShared;
|
|
4587
|
+
return _regenerator().w(function (_context12) {
|
|
4588
|
+
while (1) switch (_context12.n) {
|
|
4372
4589
|
case 0:
|
|
4373
|
-
|
|
4374
|
-
return
|
|
4590
|
+
_context12.n = 1;
|
|
4591
|
+
return _targetShared.get();
|
|
4375
4592
|
case 1:
|
|
4376
|
-
factory =
|
|
4377
|
-
|
|
4378
|
-
|
|
4379
|
-
addUseIn(
|
|
4380
|
-
|
|
4593
|
+
factory = _context12.v;
|
|
4594
|
+
_targetShared.lib = factory;
|
|
4595
|
+
_targetShared.loaded = true;
|
|
4596
|
+
addUseIn(_targetShared, host.options.name);
|
|
4597
|
+
_ref16 = getRegisteredShare(_this9.shareScopeMap, pkgName, shareOptionsRes, _this9.hooks.lifecycle.resolveShare) || {}, gShared = _ref16.shared, gUseTreeShaking = _ref16.useTreesShaking;
|
|
4381
4598
|
if (gShared) {
|
|
4382
|
-
|
|
4383
|
-
|
|
4599
|
+
targetGShared = directShare(gShared, gUseTreeShaking);
|
|
4600
|
+
targetGShared.lib = factory;
|
|
4601
|
+
targetGShared.loaded = true;
|
|
4384
4602
|
gShared.from = shareOptionsRes.from;
|
|
4385
4603
|
}
|
|
4386
|
-
return
|
|
4604
|
+
return _context12.a(2, factory);
|
|
4387
4605
|
}
|
|
4388
|
-
},
|
|
4606
|
+
}, _callee12);
|
|
4389
4607
|
}));
|
|
4390
4608
|
return function _asyncLoadProcess() {
|
|
4391
|
-
return
|
|
4609
|
+
return _ref15.apply(this, arguments);
|
|
4392
4610
|
};
|
|
4393
4611
|
}();
|
|
4394
4612
|
_loading = _asyncLoadProcess();
|
|
@@ -4398,15 +4616,16 @@ var SharedHandler = /*#__PURE__*/function () {
|
|
|
4398
4616
|
shared: shareOptionsRes,
|
|
4399
4617
|
from: host.options.name,
|
|
4400
4618
|
lib: null,
|
|
4401
|
-
loading: _loading
|
|
4619
|
+
loading: _loading,
|
|
4620
|
+
treeShaking: _useTreeShaking ? _targetShared : undefined
|
|
4402
4621
|
});
|
|
4403
|
-
return
|
|
4404
|
-
case
|
|
4405
|
-
return
|
|
4622
|
+
return _context13.a(2, _loading);
|
|
4623
|
+
case 9:
|
|
4624
|
+
return _context13.a(2);
|
|
4406
4625
|
}
|
|
4407
|
-
},
|
|
4626
|
+
}, _callee13, this);
|
|
4408
4627
|
}));
|
|
4409
|
-
function loadShare(
|
|
4628
|
+
function loadShare(_x17, _x18) {
|
|
4410
4629
|
return _loadShare.apply(this, arguments);
|
|
4411
4630
|
}
|
|
4412
4631
|
return loadShare;
|
|
@@ -4451,43 +4670,37 @@ var SharedHandler = /*#__PURE__*/function () {
|
|
|
4451
4670
|
eager = shared.eager;
|
|
4452
4671
|
scope[name] = scope[name] || {};
|
|
4453
4672
|
var versions = scope[name];
|
|
4454
|
-
var activeVersion = versions[version];
|
|
4455
|
-
var activeVersionEager = Boolean(activeVersion && (activeVersion.eager || ((_activeVersion$shareC = activeVersion.shareConfig) === null || _activeVersion$shareC === void 0 ? void 0 : _activeVersion$shareC.eager)));
|
|
4456
|
-
if (!activeVersion || activeVersion.strategy !== 'loaded-first' && !activeVersion.loaded && (Boolean(!eager) !== !activeVersionEager ? eager : hostName >
|
|
4673
|
+
var activeVersion = versions[version] && directShare(versions[version]);
|
|
4674
|
+
var activeVersionEager = Boolean(activeVersion && ('eager' in activeVersion && activeVersion.eager || 'shareConfig' in activeVersion && ((_activeVersion$shareC = activeVersion.shareConfig) === null || _activeVersion$shareC === void 0 ? void 0 : _activeVersion$shareC.eager)));
|
|
4675
|
+
if (!activeVersion || activeVersion.strategy !== 'loaded-first' && !activeVersion.loaded && (Boolean(!eager) !== !activeVersionEager ? eager : hostName > versions[version].from)) {
|
|
4457
4676
|
versions[version] = shared;
|
|
4458
4677
|
}
|
|
4459
4678
|
};
|
|
4460
|
-
var initFn = function initFn(mod) {
|
|
4461
|
-
return mod && mod.init && mod.init(shareScope[shareScopeName], initScope);
|
|
4462
|
-
};
|
|
4463
4679
|
var initRemoteModule = /*#__PURE__*/function () {
|
|
4464
|
-
var
|
|
4465
|
-
var _yield$host$remoteHan, module, remoteEntryExports, _t2;
|
|
4466
|
-
return _regenerator().w(function (
|
|
4467
|
-
while (1) switch (
|
|
4680
|
+
var _ref17 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee14(key) {
|
|
4681
|
+
var _yield$host$remoteHan, module, remoteEntryExports, _remoteEntryExports, _t2;
|
|
4682
|
+
return _regenerator().w(function (_context14) {
|
|
4683
|
+
while (1) switch (_context14.p = _context14.n) {
|
|
4468
4684
|
case 0:
|
|
4469
|
-
|
|
4685
|
+
_context14.n = 1;
|
|
4470
4686
|
return host.remoteHandler.getRemoteModuleAndOptions({
|
|
4471
4687
|
id: key
|
|
4472
4688
|
});
|
|
4473
4689
|
case 1:
|
|
4474
|
-
_yield$host$remoteHan =
|
|
4690
|
+
_yield$host$remoteHan = _context14.v;
|
|
4475
4691
|
module = _yield$host$remoteHan.module;
|
|
4476
|
-
|
|
4477
|
-
|
|
4478
|
-
|
|
4479
|
-
}
|
|
4480
|
-
_context12.p = 2;
|
|
4481
|
-
_context12.n = 3;
|
|
4692
|
+
remoteEntryExports = undefined;
|
|
4693
|
+
_context14.p = 2;
|
|
4694
|
+
_context14.n = 3;
|
|
4482
4695
|
return module.getEntry();
|
|
4483
4696
|
case 3:
|
|
4484
|
-
remoteEntryExports =
|
|
4485
|
-
|
|
4697
|
+
remoteEntryExports = _context14.v;
|
|
4698
|
+
_context14.n = 6;
|
|
4486
4699
|
break;
|
|
4487
4700
|
case 4:
|
|
4488
|
-
|
|
4489
|
-
_t2 =
|
|
4490
|
-
|
|
4701
|
+
_context14.p = 4;
|
|
4702
|
+
_t2 = _context14.v;
|
|
4703
|
+
_context14.n = 5;
|
|
4491
4704
|
return host.remoteHandler.hooks.lifecycle.errorLoadRemote.emit({
|
|
4492
4705
|
id: key,
|
|
4493
4706
|
error: _t2,
|
|
@@ -4496,23 +4709,25 @@ var SharedHandler = /*#__PURE__*/function () {
|
|
|
4496
4709
|
origin: host
|
|
4497
4710
|
});
|
|
4498
4711
|
case 5:
|
|
4499
|
-
remoteEntryExports =
|
|
4712
|
+
remoteEntryExports = _context14.v;
|
|
4500
4713
|
case 6:
|
|
4501
|
-
|
|
4502
|
-
|
|
4714
|
+
_context14.p = 6;
|
|
4715
|
+
if (!((_remoteEntryExports = remoteEntryExports) !== null && _remoteEntryExports !== void 0 && _remoteEntryExports.init)) {
|
|
4716
|
+
_context14.n = 7;
|
|
4503
4717
|
break;
|
|
4504
4718
|
}
|
|
4505
|
-
|
|
4506
|
-
|
|
4719
|
+
module.remoteEntryExports = remoteEntryExports;
|
|
4720
|
+
_context14.n = 7;
|
|
4721
|
+
return module.init();
|
|
4507
4722
|
case 7:
|
|
4508
|
-
|
|
4723
|
+
return _context14.f(6);
|
|
4509
4724
|
case 8:
|
|
4510
|
-
return
|
|
4725
|
+
return _context14.a(2);
|
|
4511
4726
|
}
|
|
4512
|
-
},
|
|
4727
|
+
}, _callee14, null, [[2, 4, 6, 8]]);
|
|
4513
4728
|
}));
|
|
4514
|
-
return function initRemoteModule(
|
|
4515
|
-
return
|
|
4729
|
+
return function initRemoteModule(_x20) {
|
|
4730
|
+
return _ref17.apply(this, arguments);
|
|
4516
4731
|
};
|
|
4517
4732
|
}();
|
|
4518
4733
|
Object.keys(host.options.shared).forEach(function (shareName) {
|
|
@@ -4540,7 +4755,7 @@ var SharedHandler = /*#__PURE__*/function () {
|
|
|
4540
4755
|
}, {
|
|
4541
4756
|
key: "loadShareSync",
|
|
4542
4757
|
value: function loadShareSync(pkgName, extraOptions) {
|
|
4543
|
-
var
|
|
4758
|
+
var _this0 = this;
|
|
4544
4759
|
var host = this.host;
|
|
4545
4760
|
var shareOptions = getTargetSharedOptions({
|
|
4546
4761
|
pkgName: pkgName,
|
|
@@ -4549,21 +4764,17 @@ var SharedHandler = /*#__PURE__*/function () {
|
|
|
4549
4764
|
});
|
|
4550
4765
|
if (shareOptions !== null && shareOptions !== void 0 && shareOptions.scope) {
|
|
4551
4766
|
shareOptions.scope.forEach(function (shareScope) {
|
|
4552
|
-
|
|
4767
|
+
_this0.initializeSharing(shareScope, {
|
|
4553
4768
|
strategy: shareOptions.strategy
|
|
4554
4769
|
});
|
|
4555
4770
|
});
|
|
4556
4771
|
}
|
|
4557
|
-
var
|
|
4558
|
-
|
|
4559
|
-
|
|
4560
|
-
shared.useIn = [];
|
|
4561
|
-
}
|
|
4562
|
-
addUniqueItem(shared.useIn, host.options.name);
|
|
4563
|
-
};
|
|
4772
|
+
var _ref18 = getRegisteredShare(this.shareScopeMap, pkgName, shareOptions, this.hooks.lifecycle.resolveShare) || {},
|
|
4773
|
+
registeredShared = _ref18.shared;
|
|
4774
|
+
_ref18.useTreesShaking;
|
|
4564
4775
|
if (registeredShared) {
|
|
4565
4776
|
if (typeof registeredShared.lib === 'function') {
|
|
4566
|
-
addUseIn(registeredShared);
|
|
4777
|
+
addUseIn(registeredShared, host.options.name);
|
|
4567
4778
|
if (!registeredShared.loaded) {
|
|
4568
4779
|
registeredShared.loaded = true;
|
|
4569
4780
|
if (registeredShared.from === host.options.name) {
|
|
@@ -4575,7 +4786,7 @@ var SharedHandler = /*#__PURE__*/function () {
|
|
|
4575
4786
|
if (typeof registeredShared.get === 'function') {
|
|
4576
4787
|
var module = registeredShared.get();
|
|
4577
4788
|
if (!(module instanceof Promise)) {
|
|
4578
|
-
addUseIn(registeredShared);
|
|
4789
|
+
addUseIn(registeredShared, host.options.name);
|
|
4579
4790
|
this.setShared({
|
|
4580
4791
|
pkgName: pkgName,
|
|
4581
4792
|
loaded: true,
|
|
@@ -4633,48 +4844,49 @@ var SharedHandler = /*#__PURE__*/function () {
|
|
|
4633
4844
|
}
|
|
4634
4845
|
}, {
|
|
4635
4846
|
key: "setShared",
|
|
4636
|
-
value: function setShared(
|
|
4637
|
-
var
|
|
4638
|
-
var pkgName =
|
|
4639
|
-
shared =
|
|
4640
|
-
from =
|
|
4641
|
-
lib =
|
|
4642
|
-
loading =
|
|
4643
|
-
loaded =
|
|
4644
|
-
get =
|
|
4847
|
+
value: function setShared(_ref19) {
|
|
4848
|
+
var _this1 = this;
|
|
4849
|
+
var pkgName = _ref19.pkgName,
|
|
4850
|
+
shared = _ref19.shared,
|
|
4851
|
+
from = _ref19.from,
|
|
4852
|
+
lib = _ref19.lib,
|
|
4853
|
+
loading = _ref19.loading,
|
|
4854
|
+
loaded = _ref19.loaded,
|
|
4855
|
+
get = _ref19.get,
|
|
4856
|
+
treeShaking = _ref19.treeShaking;
|
|
4645
4857
|
var version = shared.version,
|
|
4646
4858
|
_shared$scope = shared.scope,
|
|
4647
4859
|
scope = _shared$scope === void 0 ? 'default' : _shared$scope,
|
|
4648
4860
|
shareInfo = _objectWithoutProperties(shared, _excluded2);
|
|
4649
4861
|
var scopes = Array.isArray(scope) ? scope : [scope];
|
|
4862
|
+
var mergeAttrs = function mergeAttrs(shared) {
|
|
4863
|
+
var merge = function merge(s, key, val) {
|
|
4864
|
+
if (val && !s[key]) {
|
|
4865
|
+
s[key] = val;
|
|
4866
|
+
}
|
|
4867
|
+
};
|
|
4868
|
+
var targetShared = treeShaking ? shared.treeShaking : shared;
|
|
4869
|
+
merge(targetShared, 'loaded', loaded);
|
|
4870
|
+
merge(targetShared, 'loading', loading);
|
|
4871
|
+
merge(targetShared, 'get', get);
|
|
4872
|
+
};
|
|
4650
4873
|
scopes.forEach(function (sc) {
|
|
4651
|
-
if (!
|
|
4652
|
-
|
|
4874
|
+
if (!_this1.shareScopeMap[sc]) {
|
|
4875
|
+
_this1.shareScopeMap[sc] = {};
|
|
4653
4876
|
}
|
|
4654
|
-
if (!
|
|
4655
|
-
|
|
4877
|
+
if (!_this1.shareScopeMap[sc][pkgName]) {
|
|
4878
|
+
_this1.shareScopeMap[sc][pkgName] = {};
|
|
4656
4879
|
}
|
|
4657
|
-
if (!
|
|
4658
|
-
|
|
4880
|
+
if (!_this1.shareScopeMap[sc][pkgName][version]) {
|
|
4881
|
+
_this1.shareScopeMap[sc][pkgName][version] = _objectSpread2(_objectSpread2({
|
|
4659
4882
|
version: version,
|
|
4660
4883
|
scope: [sc]
|
|
4661
4884
|
}, shareInfo), {}, {
|
|
4662
|
-
lib: lib
|
|
4663
|
-
loaded: loaded,
|
|
4664
|
-
loading: loading
|
|
4885
|
+
lib: lib
|
|
4665
4886
|
});
|
|
4666
|
-
if (get) {
|
|
4667
|
-
_this0.shareScopeMap[sc][pkgName][version].get = get;
|
|
4668
|
-
}
|
|
4669
|
-
return;
|
|
4670
|
-
}
|
|
4671
|
-
var registeredShared = _this0.shareScopeMap[sc][pkgName][version];
|
|
4672
|
-
if (loading && !registeredShared.loading) {
|
|
4673
|
-
registeredShared.loading = loading;
|
|
4674
|
-
}
|
|
4675
|
-
if (loaded && !registeredShared.loaded) {
|
|
4676
|
-
registeredShared.loaded = loaded;
|
|
4677
4887
|
}
|
|
4888
|
+
var registeredShared = _this1.shareScopeMap[sc][pkgName][version];
|
|
4889
|
+
mergeAttrs(registeredShared);
|
|
4678
4890
|
if (from && registeredShared.from !== from) {
|
|
4679
4891
|
registeredShared.from = from;
|
|
4680
4892
|
}
|
|
@@ -4705,6 +4917,7 @@ var RemoteHandler = /*#__PURE__*/function () {
|
|
|
4705
4917
|
generatePreloadAssets: new AsyncHook('generatePreloadAssets'),
|
|
4706
4918
|
// not used yet
|
|
4707
4919
|
afterPreloadRemote: new AsyncHook(),
|
|
4920
|
+
// TODO: Move to loaderHook
|
|
4708
4921
|
loadEntry: new AsyncHook()
|
|
4709
4922
|
});
|
|
4710
4923
|
this.host = host;
|
|
@@ -4713,10 +4926,10 @@ var RemoteHandler = /*#__PURE__*/function () {
|
|
|
4713
4926
|
return _createClass(RemoteHandler, [{
|
|
4714
4927
|
key: "formatAndRegisterRemote",
|
|
4715
4928
|
value: function formatAndRegisterRemote(globalOptions, userOptions) {
|
|
4716
|
-
var
|
|
4929
|
+
var _this10 = this;
|
|
4717
4930
|
var userRemotes = userOptions.remotes || [];
|
|
4718
4931
|
return userRemotes.reduce(function (res, remote) {
|
|
4719
|
-
|
|
4932
|
+
_this10.registerRemote(remote, res, {
|
|
4720
4933
|
force: false
|
|
4721
4934
|
});
|
|
4722
4935
|
return res;
|
|
@@ -4754,37 +4967,37 @@ var RemoteHandler = /*#__PURE__*/function () {
|
|
|
4754
4967
|
}, {
|
|
4755
4968
|
key: "loadRemote",
|
|
4756
4969
|
value: function () {
|
|
4757
|
-
var _loadRemote = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
4758
|
-
var host,
|
|
4759
|
-
return _regenerator().w(function (
|
|
4760
|
-
while (1) switch (
|
|
4970
|
+
var _loadRemote = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee15(id, options) {
|
|
4971
|
+
var host, _ref20, _ref20$loadFactory, loadFactory, _yield$this$getRemote, module, moduleOptions, remoteMatchInfo, pkgNameOrAlias, remote, expose, idRes, remoteSnapshot, moduleOrFactory, moduleWrapper, _ref21, _ref21$from, from, failOver, _t3;
|
|
4972
|
+
return _regenerator().w(function (_context15) {
|
|
4973
|
+
while (1) switch (_context15.p = _context15.n) {
|
|
4761
4974
|
case 0:
|
|
4762
4975
|
host = this.host;
|
|
4763
|
-
|
|
4764
|
-
|
|
4976
|
+
_context15.p = 1;
|
|
4977
|
+
_ref20 = options || {
|
|
4765
4978
|
loadFactory: true
|
|
4766
|
-
},
|
|
4979
|
+
}, _ref20$loadFactory = _ref20.loadFactory, loadFactory = _ref20$loadFactory === void 0 ? true : _ref20$loadFactory; // 1. Validate the parameters of the retrieved module. There are two module request methods: pkgName + expose and alias + expose.
|
|
4767
4980
|
// 2. Request the snapshot information of the current host and globally store the obtained snapshot information. The retrieved module information is partially offline and partially online. The online module information will retrieve the modules used online.
|
|
4768
4981
|
// 3. Retrieve the detailed information of the current module from global (remoteEntry address, expose resource address)
|
|
4769
4982
|
// 4. After retrieving remoteEntry, call the init of the module, and then retrieve the exported content of the module through get
|
|
4770
4983
|
// id: pkgName(@federation/app1) + expose(button) = @federation/app1/button
|
|
4771
4984
|
// id: alias(app1) + expose(button) = app1/button
|
|
4772
4985
|
// id: alias(app1/utils) + expose(loadash/sort) = app1/utils/loadash/sort
|
|
4773
|
-
|
|
4986
|
+
_context15.n = 2;
|
|
4774
4987
|
return this.getRemoteModuleAndOptions({
|
|
4775
4988
|
id: id
|
|
4776
4989
|
});
|
|
4777
4990
|
case 2:
|
|
4778
|
-
_yield$this$getRemote =
|
|
4991
|
+
_yield$this$getRemote = _context15.v;
|
|
4779
4992
|
module = _yield$this$getRemote.module;
|
|
4780
4993
|
moduleOptions = _yield$this$getRemote.moduleOptions;
|
|
4781
4994
|
remoteMatchInfo = _yield$this$getRemote.remoteMatchInfo;
|
|
4782
4995
|
pkgNameOrAlias = remoteMatchInfo.pkgNameOrAlias, remote = remoteMatchInfo.remote, expose = remoteMatchInfo.expose, idRes = remoteMatchInfo.id, remoteSnapshot = remoteMatchInfo.remoteSnapshot;
|
|
4783
|
-
|
|
4996
|
+
_context15.n = 3;
|
|
4784
4997
|
return module.get(idRes, expose, options, remoteSnapshot);
|
|
4785
4998
|
case 3:
|
|
4786
|
-
moduleOrFactory =
|
|
4787
|
-
|
|
4999
|
+
moduleOrFactory = _context15.v;
|
|
5000
|
+
_context15.n = 4;
|
|
4788
5001
|
return this.hooks.lifecycle.onLoad.emit({
|
|
4789
5002
|
id: idRes,
|
|
4790
5003
|
pkgNameOrAlias: pkgNameOrAlias,
|
|
@@ -4797,22 +5010,22 @@ var RemoteHandler = /*#__PURE__*/function () {
|
|
|
4797
5010
|
origin: host
|
|
4798
5011
|
});
|
|
4799
5012
|
case 4:
|
|
4800
|
-
moduleWrapper =
|
|
5013
|
+
moduleWrapper = _context15.v;
|
|
4801
5014
|
this.setIdToRemoteMap(id, remoteMatchInfo);
|
|
4802
5015
|
if (!(typeof moduleWrapper === 'function')) {
|
|
4803
|
-
|
|
5016
|
+
_context15.n = 5;
|
|
4804
5017
|
break;
|
|
4805
5018
|
}
|
|
4806
|
-
return
|
|
5019
|
+
return _context15.a(2, moduleWrapper);
|
|
4807
5020
|
case 5:
|
|
4808
|
-
return
|
|
5021
|
+
return _context15.a(2, moduleOrFactory);
|
|
4809
5022
|
case 6:
|
|
4810
|
-
|
|
4811
|
-
_t3 =
|
|
4812
|
-
|
|
5023
|
+
_context15.p = 6;
|
|
5024
|
+
_t3 = _context15.v;
|
|
5025
|
+
_ref21 = options || {
|
|
4813
5026
|
from: 'runtime'
|
|
4814
|
-
},
|
|
4815
|
-
|
|
5027
|
+
}, _ref21$from = _ref21.from, from = _ref21$from === void 0 ? 'runtime' : _ref21$from;
|
|
5028
|
+
_context15.n = 7;
|
|
4816
5029
|
return this.hooks.lifecycle.errorLoadRemote.emit({
|
|
4817
5030
|
id: id,
|
|
4818
5031
|
error: _t3,
|
|
@@ -4821,18 +5034,18 @@ var RemoteHandler = /*#__PURE__*/function () {
|
|
|
4821
5034
|
origin: host
|
|
4822
5035
|
});
|
|
4823
5036
|
case 7:
|
|
4824
|
-
failOver =
|
|
5037
|
+
failOver = _context15.v;
|
|
4825
5038
|
if (failOver) {
|
|
4826
|
-
|
|
5039
|
+
_context15.n = 8;
|
|
4827
5040
|
break;
|
|
4828
5041
|
}
|
|
4829
5042
|
throw _t3;
|
|
4830
5043
|
case 8:
|
|
4831
|
-
return
|
|
5044
|
+
return _context15.a(2, failOver);
|
|
4832
5045
|
}
|
|
4833
|
-
},
|
|
5046
|
+
}, _callee15, this, [[1, 6]]);
|
|
4834
5047
|
}));
|
|
4835
|
-
function loadRemote(
|
|
5048
|
+
function loadRemote(_x21, _x22) {
|
|
4836
5049
|
return _loadRemote.apply(this, arguments);
|
|
4837
5050
|
}
|
|
4838
5051
|
return loadRemote;
|
|
@@ -4840,14 +5053,14 @@ var RemoteHandler = /*#__PURE__*/function () {
|
|
|
4840
5053
|
}, {
|
|
4841
5054
|
key: "preloadRemote",
|
|
4842
5055
|
value: function () {
|
|
4843
|
-
var _preloadRemote = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
4844
|
-
var
|
|
5056
|
+
var _preloadRemote = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee17(preloadOptions) {
|
|
5057
|
+
var _this11 = this;
|
|
4845
5058
|
var host, preloadOps;
|
|
4846
|
-
return _regenerator().w(function (
|
|
4847
|
-
while (1) switch (
|
|
5059
|
+
return _regenerator().w(function (_context17) {
|
|
5060
|
+
while (1) switch (_context17.n) {
|
|
4848
5061
|
case 0:
|
|
4849
5062
|
host = this.host;
|
|
4850
|
-
|
|
5063
|
+
_context17.n = 1;
|
|
4851
5064
|
return this.hooks.lifecycle.beforePreloadRemote.emit({
|
|
4852
5065
|
preloadOps: preloadOptions,
|
|
4853
5066
|
options: host.options,
|
|
@@ -4855,25 +5068,25 @@ var RemoteHandler = /*#__PURE__*/function () {
|
|
|
4855
5068
|
});
|
|
4856
5069
|
case 1:
|
|
4857
5070
|
preloadOps = formatPreloadArgs(host.options.remotes, preloadOptions);
|
|
4858
|
-
|
|
5071
|
+
_context17.n = 2;
|
|
4859
5072
|
return Promise.all(preloadOps.map(/*#__PURE__*/function () {
|
|
4860
|
-
var
|
|
5073
|
+
var _ref22 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee16(ops) {
|
|
4861
5074
|
var remote, remoteInfo, _yield$host$snapshotH, globalSnapshot, remoteSnapshot, assets;
|
|
4862
|
-
return _regenerator().w(function (
|
|
4863
|
-
while (1) switch (
|
|
5075
|
+
return _regenerator().w(function (_context16) {
|
|
5076
|
+
while (1) switch (_context16.n) {
|
|
4864
5077
|
case 0:
|
|
4865
5078
|
remote = ops.remote;
|
|
4866
5079
|
remoteInfo = getRemoteInfo(remote);
|
|
4867
|
-
|
|
5080
|
+
_context16.n = 1;
|
|
4868
5081
|
return host.snapshotHandler.loadRemoteSnapshotInfo({
|
|
4869
5082
|
moduleInfo: remote
|
|
4870
5083
|
});
|
|
4871
5084
|
case 1:
|
|
4872
|
-
_yield$host$snapshotH =
|
|
5085
|
+
_yield$host$snapshotH = _context16.v;
|
|
4873
5086
|
globalSnapshot = _yield$host$snapshotH.globalSnapshot;
|
|
4874
5087
|
remoteSnapshot = _yield$host$snapshotH.remoteSnapshot;
|
|
4875
|
-
|
|
4876
|
-
return
|
|
5088
|
+
_context16.n = 2;
|
|
5089
|
+
return _this11.hooks.lifecycle.generatePreloadAssets.emit({
|
|
4877
5090
|
origin: host,
|
|
4878
5091
|
preloadOptions: ops,
|
|
4879
5092
|
remote: remote,
|
|
@@ -4882,29 +5095,29 @@ var RemoteHandler = /*#__PURE__*/function () {
|
|
|
4882
5095
|
remoteSnapshot: remoteSnapshot
|
|
4883
5096
|
});
|
|
4884
5097
|
case 2:
|
|
4885
|
-
assets =
|
|
5098
|
+
assets = _context16.v;
|
|
4886
5099
|
if (assets) {
|
|
4887
|
-
|
|
5100
|
+
_context16.n = 3;
|
|
4888
5101
|
break;
|
|
4889
5102
|
}
|
|
4890
|
-
return
|
|
5103
|
+
return _context16.a(2);
|
|
4891
5104
|
case 3:
|
|
4892
5105
|
preloadAssets(remoteInfo, host, assets);
|
|
4893
5106
|
case 4:
|
|
4894
|
-
return
|
|
5107
|
+
return _context16.a(2);
|
|
4895
5108
|
}
|
|
4896
|
-
},
|
|
5109
|
+
}, _callee16);
|
|
4897
5110
|
}));
|
|
4898
|
-
return function (
|
|
4899
|
-
return
|
|
5111
|
+
return function (_x24) {
|
|
5112
|
+
return _ref22.apply(this, arguments);
|
|
4900
5113
|
};
|
|
4901
5114
|
}()));
|
|
4902
5115
|
case 2:
|
|
4903
|
-
return
|
|
5116
|
+
return _context17.a(2);
|
|
4904
5117
|
}
|
|
4905
|
-
},
|
|
5118
|
+
}, _callee17, this);
|
|
4906
5119
|
}));
|
|
4907
|
-
function preloadRemote(
|
|
5120
|
+
function preloadRemote(_x23) {
|
|
4908
5121
|
return _preloadRemote.apply(this, arguments);
|
|
4909
5122
|
}
|
|
4910
5123
|
return preloadRemote;
|
|
@@ -4912,10 +5125,10 @@ var RemoteHandler = /*#__PURE__*/function () {
|
|
|
4912
5125
|
}, {
|
|
4913
5126
|
key: "registerRemotes",
|
|
4914
5127
|
value: function registerRemotes(remotes, options) {
|
|
4915
|
-
var
|
|
5128
|
+
var _this12 = this;
|
|
4916
5129
|
var host = this.host;
|
|
4917
5130
|
remotes.forEach(function (remote) {
|
|
4918
|
-
|
|
5131
|
+
_this12.registerRemote(remote, host.options.remotes, {
|
|
4919
5132
|
force: options === null || options === void 0 ? void 0 : options.force
|
|
4920
5133
|
});
|
|
4921
5134
|
});
|
|
@@ -4923,28 +5136,28 @@ var RemoteHandler = /*#__PURE__*/function () {
|
|
|
4923
5136
|
}, {
|
|
4924
5137
|
key: "getRemoteModuleAndOptions",
|
|
4925
5138
|
value: function () {
|
|
4926
|
-
var _getRemoteModuleAndOptions = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
5139
|
+
var _getRemoteModuleAndOptions = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee18(options) {
|
|
4927
5140
|
var host, id, loadRemoteArgs, _loadRemoteArgs, idRes, remoteSplitInfo, rawRemote, remoteInfo, matchInfo, remote, expose, module, moduleOptions, _t4;
|
|
4928
|
-
return _regenerator().w(function (
|
|
4929
|
-
while (1) switch (
|
|
5141
|
+
return _regenerator().w(function (_context18) {
|
|
5142
|
+
while (1) switch (_context18.p = _context18.n) {
|
|
4930
5143
|
case 0:
|
|
4931
5144
|
host = this.host;
|
|
4932
5145
|
id = options.id;
|
|
4933
|
-
|
|
4934
|
-
|
|
5146
|
+
_context18.p = 1;
|
|
5147
|
+
_context18.n = 2;
|
|
4935
5148
|
return this.hooks.lifecycle.beforeRequest.emit({
|
|
4936
5149
|
id: id,
|
|
4937
5150
|
options: host.options,
|
|
4938
5151
|
origin: host
|
|
4939
5152
|
});
|
|
4940
5153
|
case 2:
|
|
4941
|
-
loadRemoteArgs =
|
|
4942
|
-
|
|
5154
|
+
loadRemoteArgs = _context18.v;
|
|
5155
|
+
_context18.n = 5;
|
|
4943
5156
|
break;
|
|
4944
5157
|
case 3:
|
|
4945
|
-
|
|
4946
|
-
_t4 =
|
|
4947
|
-
|
|
5158
|
+
_context18.p = 3;
|
|
5159
|
+
_t4 = _context18.v;
|
|
5160
|
+
_context18.n = 4;
|
|
4948
5161
|
return this.hooks.lifecycle.errorLoadRemote.emit({
|
|
4949
5162
|
id: id,
|
|
4950
5163
|
options: host.options,
|
|
@@ -4954,9 +5167,9 @@ var RemoteHandler = /*#__PURE__*/function () {
|
|
|
4954
5167
|
lifecycle: 'beforeRequest'
|
|
4955
5168
|
});
|
|
4956
5169
|
case 4:
|
|
4957
|
-
loadRemoteArgs =
|
|
5170
|
+
loadRemoteArgs = _context18.v;
|
|
4958
5171
|
if (loadRemoteArgs) {
|
|
4959
|
-
|
|
5172
|
+
_context18.n = 5;
|
|
4960
5173
|
break;
|
|
4961
5174
|
}
|
|
4962
5175
|
throw _t4;
|
|
@@ -4969,7 +5182,7 @@ var RemoteHandler = /*#__PURE__*/function () {
|
|
|
4969
5182
|
}));
|
|
4970
5183
|
rawRemote = remoteSplitInfo.remote;
|
|
4971
5184
|
remoteInfo = getRemoteInfo(rawRemote);
|
|
4972
|
-
|
|
5185
|
+
_context18.n = 6;
|
|
4973
5186
|
return host.sharedHandler.hooks.lifecycle.afterResolve.emit(_objectSpread2(_objectSpread2({
|
|
4974
5187
|
id: idRes
|
|
4975
5188
|
}, remoteSplitInfo), {}, {
|
|
@@ -4978,7 +5191,7 @@ var RemoteHandler = /*#__PURE__*/function () {
|
|
|
4978
5191
|
remoteInfo: remoteInfo
|
|
4979
5192
|
}));
|
|
4980
5193
|
case 6:
|
|
4981
|
-
matchInfo =
|
|
5194
|
+
matchInfo = _context18.v;
|
|
4982
5195
|
remote = matchInfo.remote, expose = matchInfo.expose;
|
|
4983
5196
|
assert(remote && expose, "The 'beforeRequest' hook was executed, but it failed to return the correct 'remote' and 'expose' values while loading ".concat(idRes, "."));
|
|
4984
5197
|
module = host.moduleCache.get(remote.name);
|
|
@@ -4990,15 +5203,15 @@ var RemoteHandler = /*#__PURE__*/function () {
|
|
|
4990
5203
|
module = new Module(moduleOptions);
|
|
4991
5204
|
host.moduleCache.set(remote.name, module);
|
|
4992
5205
|
}
|
|
4993
|
-
return
|
|
5206
|
+
return _context18.a(2, {
|
|
4994
5207
|
module: module,
|
|
4995
5208
|
moduleOptions: moduleOptions,
|
|
4996
5209
|
remoteMatchInfo: matchInfo
|
|
4997
5210
|
});
|
|
4998
5211
|
}
|
|
4999
|
-
},
|
|
5212
|
+
}, _callee18, this, [[1, 3]]);
|
|
5000
5213
|
}));
|
|
5001
|
-
function getRemoteModuleAndOptions(
|
|
5214
|
+
function getRemoteModuleAndOptions(_x25) {
|
|
5002
5215
|
return _getRemoteModuleAndOptions.apply(this, arguments);
|
|
5003
5216
|
}
|
|
5004
5217
|
return getRemoteModuleAndOptions;
|
|
@@ -5063,15 +5276,15 @@ var RemoteHandler = /*#__PURE__*/function () {
|
|
|
5063
5276
|
key: "removeRemote",
|
|
5064
5277
|
value: function removeRemote(remote) {
|
|
5065
5278
|
try {
|
|
5066
|
-
var
|
|
5279
|
+
var host = this.host;
|
|
5067
5280
|
var name = remote.name;
|
|
5068
|
-
var remoteIndex =
|
|
5281
|
+
var remoteIndex = host.options.remotes.findIndex(function (item) {
|
|
5069
5282
|
return item.name === name;
|
|
5070
5283
|
});
|
|
5071
5284
|
if (remoteIndex !== -1) {
|
|
5072
|
-
|
|
5285
|
+
host.options.remotes.splice(remoteIndex, 1);
|
|
5073
5286
|
}
|
|
5074
|
-
var loadedModule =
|
|
5287
|
+
var loadedModule = host.moduleCache.get(remote.name);
|
|
5075
5288
|
if (loadedModule) {
|
|
5076
5289
|
var remoteInfo = loadedModule.remoteInfo;
|
|
5077
5290
|
var key = remoteInfo.entryGlobalName;
|
|
@@ -5088,7 +5301,7 @@ var RemoteHandler = /*#__PURE__*/function () {
|
|
|
5088
5301
|
if (globalLoading[remoteEntryUniqueKey]) {
|
|
5089
5302
|
delete globalLoading[remoteEntryUniqueKey];
|
|
5090
5303
|
}
|
|
5091
|
-
|
|
5304
|
+
host.snapshotHandler.manifestCache["delete"](remoteInfo.entry);
|
|
5092
5305
|
// delete unloaded shared and instance
|
|
5093
5306
|
var remoteInsId = remoteInfo.buildVersion ? composeKeyWithSeparator(remoteInfo.name, remoteInfo.buildVersion) : remoteInfo.name;
|
|
5094
5307
|
var remoteInsIndex = CurrentGlobal.__FEDERATION__.__INSTANCES__.findIndex(function (ins) {
|
|
@@ -5134,18 +5347,18 @@ var RemoteHandler = /*#__PURE__*/function () {
|
|
|
5134
5347
|
remoteIns.shareScopeMap = {};
|
|
5135
5348
|
delete globalShareScopeMap[remoteInsId];
|
|
5136
5349
|
}
|
|
5137
|
-
needDeleteKeys.forEach(function (
|
|
5350
|
+
needDeleteKeys.forEach(function (_ref23) {
|
|
5138
5351
|
var _globalShareScopeMap$;
|
|
5139
|
-
var
|
|
5140
|
-
insId =
|
|
5141
|
-
shareScope =
|
|
5142
|
-
shareName =
|
|
5143
|
-
shareVersion =
|
|
5352
|
+
var _ref24 = _slicedToArray(_ref23, 4),
|
|
5353
|
+
insId = _ref24[0],
|
|
5354
|
+
shareScope = _ref24[1],
|
|
5355
|
+
shareName = _ref24[2],
|
|
5356
|
+
shareVersion = _ref24[3];
|
|
5144
5357
|
(_globalShareScopeMap$ = globalShareScopeMap[insId]) === null || _globalShareScopeMap$ === void 0 || (_globalShareScopeMap$ = _globalShareScopeMap$[shareScope]) === null || _globalShareScopeMap$ === void 0 || (_globalShareScopeMap$ = _globalShareScopeMap$[shareName]) === null || _globalShareScopeMap$ === void 0 || delete _globalShareScopeMap$[shareVersion];
|
|
5145
5358
|
});
|
|
5146
5359
|
CurrentGlobal.__FEDERATION__.__INSTANCES__.splice(remoteInsIndex, 1);
|
|
5147
5360
|
}
|
|
5148
|
-
var _getGlobalRemoteInfo2 = _getGlobalRemoteInfo(remote,
|
|
5361
|
+
var _getGlobalRemoteInfo2 = _getGlobalRemoteInfo(remote, host),
|
|
5149
5362
|
hostGlobalSnapshot = _getGlobalRemoteInfo2.hostGlobalSnapshot;
|
|
5150
5363
|
if (hostGlobalSnapshot) {
|
|
5151
5364
|
var remoteKey = hostGlobalSnapshot && 'remotesInfo' in hostGlobalSnapshot && hostGlobalSnapshot.remotesInfo && getInfoWithoutType(hostGlobalSnapshot.remotesInfo, remote.name).key;
|
|
@@ -5158,7 +5371,7 @@ var RemoteHandler = /*#__PURE__*/function () {
|
|
|
5158
5371
|
}
|
|
5159
5372
|
}
|
|
5160
5373
|
}
|
|
5161
|
-
|
|
5374
|
+
host.moduleCache["delete"](remote.name);
|
|
5162
5375
|
}
|
|
5163
5376
|
} catch (err) {
|
|
5164
5377
|
logger.log('removeRemote fail: ', err);
|
|
@@ -5178,7 +5391,7 @@ var ModuleFederation = /*#__PURE__*/function () {
|
|
|
5178
5391
|
// maybe will change, temporarily for internal use only
|
|
5179
5392
|
initContainer: new AsyncWaterfallHook('initContainer')
|
|
5180
5393
|
});
|
|
5181
|
-
this.version = "0.
|
|
5394
|
+
this.version = "2.0.1";
|
|
5182
5395
|
this.moduleCache = new Map();
|
|
5183
5396
|
this.loaderHook = new PluginSystem({
|
|
5184
5397
|
// FIXME: may not be suitable , not open to the public yet
|
|
@@ -5226,15 +5439,15 @@ var ModuleFederation = /*#__PURE__*/function () {
|
|
|
5226
5439
|
}, {
|
|
5227
5440
|
key: "loadShare",
|
|
5228
5441
|
value: function () {
|
|
5229
|
-
var _loadShare2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
5230
|
-
return _regenerator().w(function (
|
|
5231
|
-
while (1) switch (
|
|
5442
|
+
var _loadShare2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee19(pkgName, extraOptions) {
|
|
5443
|
+
return _regenerator().w(function (_context19) {
|
|
5444
|
+
while (1) switch (_context19.n) {
|
|
5232
5445
|
case 0:
|
|
5233
|
-
return
|
|
5446
|
+
return _context19.a(2, this.sharedHandler.loadShare(pkgName, extraOptions));
|
|
5234
5447
|
}
|
|
5235
|
-
},
|
|
5448
|
+
}, _callee19, this);
|
|
5236
5449
|
}));
|
|
5237
|
-
function loadShare(
|
|
5450
|
+
function loadShare(_x26, _x27) {
|
|
5238
5451
|
return _loadShare2.apply(this, arguments);
|
|
5239
5452
|
}
|
|
5240
5453
|
return loadShare;
|
|
@@ -5274,15 +5487,15 @@ var ModuleFederation = /*#__PURE__*/function () {
|
|
|
5274
5487
|
}, {
|
|
5275
5488
|
key: "loadRemote",
|
|
5276
5489
|
value: function () {
|
|
5277
|
-
var _loadRemote2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
5278
|
-
return _regenerator().w(function (
|
|
5279
|
-
while (1) switch (
|
|
5490
|
+
var _loadRemote2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee20(id, options) {
|
|
5491
|
+
return _regenerator().w(function (_context20) {
|
|
5492
|
+
while (1) switch (_context20.n) {
|
|
5280
5493
|
case 0:
|
|
5281
|
-
return
|
|
5494
|
+
return _context20.a(2, this.remoteHandler.loadRemote(id, options));
|
|
5282
5495
|
}
|
|
5283
|
-
},
|
|
5496
|
+
}, _callee20, this);
|
|
5284
5497
|
}));
|
|
5285
|
-
function loadRemote(
|
|
5498
|
+
function loadRemote(_x28, _x29) {
|
|
5286
5499
|
return _loadRemote2.apply(this, arguments);
|
|
5287
5500
|
}
|
|
5288
5501
|
return loadRemote;
|
|
@@ -5290,15 +5503,15 @@ var ModuleFederation = /*#__PURE__*/function () {
|
|
|
5290
5503
|
}, {
|
|
5291
5504
|
key: "preloadRemote",
|
|
5292
5505
|
value: function () {
|
|
5293
|
-
var _preloadRemote2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
5294
|
-
return _regenerator().w(function (
|
|
5295
|
-
while (1) switch (
|
|
5506
|
+
var _preloadRemote2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee21(preloadOptions) {
|
|
5507
|
+
return _regenerator().w(function (_context21) {
|
|
5508
|
+
while (1) switch (_context21.n) {
|
|
5296
5509
|
case 0:
|
|
5297
|
-
return
|
|
5510
|
+
return _context21.a(2, this.remoteHandler.preloadRemote(preloadOptions));
|
|
5298
5511
|
}
|
|
5299
|
-
},
|
|
5512
|
+
}, _callee21, this);
|
|
5300
5513
|
}));
|
|
5301
|
-
function preloadRemote(
|
|
5514
|
+
function preloadRemote(_x30) {
|
|
5302
5515
|
return _preloadRemote2.apply(this, arguments);
|
|
5303
5516
|
}
|
|
5304
5517
|
return preloadRemote;
|
|
@@ -5313,7 +5526,7 @@ var ModuleFederation = /*#__PURE__*/function () {
|
|
|
5313
5526
|
key: "formatOptions",
|
|
5314
5527
|
value: function formatOptions(globalOptions, userOptions) {
|
|
5315
5528
|
var _formatShareConfigs2 = formatShareConfigs(globalOptions, userOptions),
|
|
5316
|
-
shared = _formatShareConfigs2.
|
|
5529
|
+
shared = _formatShareConfigs2.allShareInfos;
|
|
5317
5530
|
var _this$hooks$lifecycle = this.hooks.lifecycle.beforeInit.emit({
|
|
5318
5531
|
origin: this,
|
|
5319
5532
|
userOptions: userOptions,
|
|
@@ -5324,7 +5537,7 @@ var ModuleFederation = /*#__PURE__*/function () {
|
|
|
5324
5537
|
globalOptionsRes = _this$hooks$lifecycle.options;
|
|
5325
5538
|
var remotes = this.remoteHandler.formatAndRegisterRemote(globalOptionsRes, userOptionsRes);
|
|
5326
5539
|
var _this$sharedHandler$r = this.sharedHandler.registerShared(globalOptionsRes, userOptionsRes),
|
|
5327
|
-
|
|
5540
|
+
allShareInfos = _this$sharedHandler$r.allShareInfos;
|
|
5328
5541
|
var plugins = _toConsumableArray(globalOptionsRes.plugins);
|
|
5329
5542
|
if (userOptionsRes.plugins) {
|
|
5330
5543
|
userOptionsRes.plugins.forEach(function (plugin) {
|
|
@@ -5336,7 +5549,7 @@ var ModuleFederation = /*#__PURE__*/function () {
|
|
|
5336
5549
|
var optionsRes = _objectSpread2(_objectSpread2(_objectSpread2({}, globalOptions), userOptions), {}, {
|
|
5337
5550
|
plugins: plugins,
|
|
5338
5551
|
remotes: remotes,
|
|
5339
|
-
shared:
|
|
5552
|
+
shared: allShareInfos
|
|
5340
5553
|
});
|
|
5341
5554
|
this.hooks.lifecycle.init.emit({
|
|
5342
5555
|
origin: this,
|
|
@@ -5456,20 +5669,32 @@ function useActionEffect(params, deps, isExtReady = true) {
|
|
|
5456
5669
|
};
|
|
5457
5670
|
}
|
|
5458
5671
|
async function updateAction() {
|
|
5459
|
-
if (!remoteOrigin) {
|
|
5460
|
-
console.error("Remote origin is not set");
|
|
5461
|
-
return;
|
|
5462
|
-
}
|
|
5463
5672
|
// Register or update action.
|
|
5464
5673
|
// This will only pass signature info to the editor.
|
|
5465
5674
|
// The actual handler is stored in this hook,
|
|
5466
5675
|
// so the execution happens inside the extension app.
|
|
5467
5676
|
const { appId, version, actionInfo } = await getActionInfo(params.actionName);
|
|
5468
|
-
|
|
5469
|
-
|
|
5470
|
-
|
|
5471
|
-
|
|
5472
|
-
|
|
5677
|
+
let func;
|
|
5678
|
+
if (remoteOrigin) {
|
|
5679
|
+
// Production: load handler from Module Federation remote
|
|
5680
|
+
const loadedFunc = await loadAppActionFromMF(actionInfo.name, appId, remoteOrigin, version);
|
|
5681
|
+
if (!loadedFunc) {
|
|
5682
|
+
console.error(`Failed to load action handler for ${actionInfo.name}`);
|
|
5683
|
+
throw new Error(`Failed to load action handler for ${actionInfo.name}`);
|
|
5684
|
+
}
|
|
5685
|
+
func = loadedFunc;
|
|
5686
|
+
}
|
|
5687
|
+
else {
|
|
5688
|
+
// Preview mode: no MF server, call the skill endpoint via fetch
|
|
5689
|
+
const origin = window.location.origin;
|
|
5690
|
+
func = async (args) => {
|
|
5691
|
+
const response = await fetch(`${origin}/skill/${actionInfo.name}`, {
|
|
5692
|
+
method: "POST",
|
|
5693
|
+
headers: { "Content-Type": "application/json" },
|
|
5694
|
+
body: JSON.stringify(args),
|
|
5695
|
+
});
|
|
5696
|
+
return response.json();
|
|
5697
|
+
};
|
|
5473
5698
|
}
|
|
5474
5699
|
setActionHandler(() => func);
|
|
5475
5700
|
await imc?.sendMessage(IMCMessageTypeEnum.EditorRegisterAction, {
|
|
@@ -5592,6 +5817,40 @@ function useActionEffect(params, deps, isExtReady = true) {
|
|
|
5592
5817
|
};
|
|
5593
5818
|
}
|
|
5594
5819
|
|
|
5820
|
+
function useLoading() {
|
|
5821
|
+
const receiverHandlerMap = new Map();
|
|
5822
|
+
const { imc, isReady } = useIMC(receiverHandlerMap, "loading");
|
|
5823
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
5824
|
+
useEffect(() => {
|
|
5825
|
+
if (isReady) {
|
|
5826
|
+
imc?.sendMessage(IMCMessageTypeEnum.EditorLoadingApp, {
|
|
5827
|
+
isLoading,
|
|
5828
|
+
});
|
|
5829
|
+
}
|
|
5830
|
+
}, [isLoading]);
|
|
5831
|
+
function toggleLoading(isLoading) {
|
|
5832
|
+
setIsLoading((prev) => isLoading);
|
|
5833
|
+
}
|
|
5834
|
+
return {
|
|
5835
|
+
isReady,
|
|
5836
|
+
toggleLoading,
|
|
5837
|
+
};
|
|
5838
|
+
}
|
|
5839
|
+
|
|
5840
|
+
function useNotification() {
|
|
5841
|
+
const receiverHandlerMap = new Map();
|
|
5842
|
+
const { imc, isReady } = useIMC(receiverHandlerMap, "notification");
|
|
5843
|
+
function openNotification(text, type) {
|
|
5844
|
+
if (isReady) {
|
|
5845
|
+
imc?.sendMessage(IMCMessageTypeEnum.EditorShowNotification, {
|
|
5846
|
+
text,
|
|
5847
|
+
type,
|
|
5848
|
+
});
|
|
5849
|
+
}
|
|
5850
|
+
}
|
|
5851
|
+
return { isReady, openNotification };
|
|
5852
|
+
}
|
|
5853
|
+
|
|
5595
5854
|
function useTheme() {
|
|
5596
5855
|
const [theme, setTheme] = useState("light");
|
|
5597
5856
|
const receiverHandlerMap = new Map();
|
|
@@ -5616,80 +5875,87 @@ function useTheme() {
|
|
|
5616
5875
|
}
|
|
5617
5876
|
|
|
5618
5877
|
function c(e, u, c, i) {
|
|
5619
|
-
var
|
|
5620
|
-
|
|
5878
|
+
var l = this,
|
|
5879
|
+
a = useRef(null),
|
|
5880
|
+
o = useRef(0),
|
|
5621
5881
|
f = useRef(0),
|
|
5622
|
-
l = useRef(0),
|
|
5623
5882
|
v = useRef(null),
|
|
5624
|
-
|
|
5625
|
-
|
|
5626
|
-
|
|
5627
|
-
|
|
5628
|
-
|
|
5629
|
-
|
|
5630
|
-
|
|
5631
|
-
|
|
5883
|
+
d = useRef([]),
|
|
5884
|
+
m = useRef(),
|
|
5885
|
+
s = useRef(),
|
|
5886
|
+
g = useRef(e),
|
|
5887
|
+
h = useRef(true),
|
|
5888
|
+
x = useRef(),
|
|
5889
|
+
E = useRef();
|
|
5890
|
+
g.current = e;
|
|
5891
|
+
var b = "undefined" != typeof window,
|
|
5892
|
+
p = !u && 0 !== u && b;
|
|
5632
5893
|
if ("function" != typeof e) throw new TypeError("Expected a function");
|
|
5633
5894
|
u = +u || 0;
|
|
5634
|
-
var
|
|
5635
|
-
|
|
5895
|
+
var y = !!(c = c || {}).leading,
|
|
5896
|
+
w = !("trailing" in c) || !!c.trailing,
|
|
5897
|
+
O = !!c.flushOnExit && w,
|
|
5636
5898
|
F = "maxWait" in c,
|
|
5637
|
-
|
|
5638
|
-
|
|
5639
|
-
|
|
5640
|
-
|
|
5641
|
-
|
|
5642
|
-
|
|
5643
|
-
|
|
5644
|
-
|
|
5645
|
-
|
|
5646
|
-
|
|
5647
|
-
|
|
5648
|
-
|
|
5649
|
-
|
|
5650
|
-
|
|
5651
|
-
|
|
5652
|
-
|
|
5653
|
-
|
|
5654
|
-
|
|
5655
|
-
|
|
5656
|
-
|
|
5657
|
-
|
|
5658
|
-
|
|
5659
|
-
|
|
5660
|
-
|
|
5661
|
-
|
|
5662
|
-
|
|
5663
|
-
if (h && l.current === f.current && T(), t(c)) return e(c);
|
|
5664
|
-
if (w.current) {
|
|
5665
|
-
var i = u - (c - o.current),
|
|
5666
|
-
a = F ? Math.min(i, D - (c - f.current)) : i;
|
|
5667
|
-
n(r, a);
|
|
5668
|
-
}
|
|
5669
|
-
},
|
|
5670
|
-
T = function T() {
|
|
5671
|
-
},
|
|
5672
|
-
W = function W() {
|
|
5673
|
-
if (s || A) {
|
|
5674
|
-
var e = Date.now(),
|
|
5675
|
-
i = t(e);
|
|
5676
|
-
if (m.current = [].slice.call(arguments), d.current = a, o.current = e, i) {
|
|
5677
|
-
if (!v.current && w.current) return f.current = o.current, n(c, u), h ? r(o.current) : g.current;
|
|
5678
|
-
if (F) return n(c, u), r(o.current);
|
|
5899
|
+
L = "debounceOnServer" in c && !!c.debounceOnServer,
|
|
5900
|
+
A = F ? Math.max(+c.maxWait || 0, u) : null,
|
|
5901
|
+
D = useMemo(function () {
|
|
5902
|
+
var r = function r(_r) {
|
|
5903
|
+
var n = d.current,
|
|
5904
|
+
t = m.current;
|
|
5905
|
+
return d.current = m.current = null, o.current = _r, f.current = f.current || _r, s.current = g.current.apply(t, n);
|
|
5906
|
+
},
|
|
5907
|
+
n = function n(r, _n) {
|
|
5908
|
+
p && cancelAnimationFrame(v.current), v.current = p ? requestAnimationFrame(r) : setTimeout(r, _n);
|
|
5909
|
+
},
|
|
5910
|
+
t = function t(r) {
|
|
5911
|
+
if (!h.current) return false;
|
|
5912
|
+
var n = r - a.current;
|
|
5913
|
+
return !a.current || n >= u || n < 0 || F && r - o.current >= A;
|
|
5914
|
+
},
|
|
5915
|
+
e = function e(n) {
|
|
5916
|
+
return v.current = null, w && d.current ? r(n) : (d.current = m.current = null, s.current);
|
|
5917
|
+
},
|
|
5918
|
+
c = function r() {
|
|
5919
|
+
var c = Date.now();
|
|
5920
|
+
if (y && f.current === o.current && D(), t(c)) return e(c);
|
|
5921
|
+
if (h.current) {
|
|
5922
|
+
var i = u - (c - a.current),
|
|
5923
|
+
l = F ? Math.min(i, A - (c - o.current)) : i;
|
|
5924
|
+
n(r, l);
|
|
5679
5925
|
}
|
|
5680
|
-
|
|
5681
|
-
|
|
5682
|
-
|
|
5683
|
-
|
|
5684
|
-
|
|
5685
|
-
|
|
5686
|
-
|
|
5687
|
-
|
|
5688
|
-
|
|
5689
|
-
|
|
5690
|
-
|
|
5691
|
-
|
|
5692
|
-
|
|
5926
|
+
},
|
|
5927
|
+
D = function D() {
|
|
5928
|
+
},
|
|
5929
|
+
S = function S() {
|
|
5930
|
+
if (b || L) {
|
|
5931
|
+
var e,
|
|
5932
|
+
i = Date.now(),
|
|
5933
|
+
f = t(i);
|
|
5934
|
+
if (d.current = [].slice.call(arguments), m.current = l, a.current = i, O && !x.current && (x.current = function () {
|
|
5935
|
+
var r;
|
|
5936
|
+
"hidden" === (null == (r = global.document) ? void 0 : r.visibilityState) && E.current.flush();
|
|
5937
|
+
}, null == (e = global.document) || null == e.addEventListener || e.addEventListener("visibilitychange", x.current)), f) {
|
|
5938
|
+
if (!v.current && h.current) return o.current = a.current, n(c, u), y ? r(a.current) : s.current;
|
|
5939
|
+
if (F) return n(c, u), r(a.current);
|
|
5940
|
+
}
|
|
5941
|
+
return v.current || n(c, u), s.current;
|
|
5942
|
+
}
|
|
5943
|
+
};
|
|
5944
|
+
return S.cancel = function () {
|
|
5945
|
+
var r = v.current;
|
|
5946
|
+
r && (p ? cancelAnimationFrame(v.current) : clearTimeout(v.current)), o.current = 0, d.current = a.current = m.current = v.current = null;
|
|
5947
|
+
}, S.isPending = function () {
|
|
5948
|
+
return !!v.current;
|
|
5949
|
+
}, S.flush = function () {
|
|
5950
|
+
return v.current ? e(Date.now()) : s.current;
|
|
5951
|
+
}, S;
|
|
5952
|
+
}, [y, F, u, A, w, O, p, b, L, i]);
|
|
5953
|
+
return E.current = D, useEffect(function () {
|
|
5954
|
+
return h.current = true, function () {
|
|
5955
|
+
var r;
|
|
5956
|
+
O && E.current.flush(), x.current && (null == (r = global.document) || null == r.removeEventListener || r.removeEventListener("visibilitychange", x.current), x.current = null), h.current = false;
|
|
5957
|
+
};
|
|
5958
|
+
}, [O]), D;
|
|
5693
5959
|
}
|
|
5694
5960
|
|
|
5695
5961
|
/**
|
|
@@ -5916,6 +6182,54 @@ function useVideoGen() {
|
|
|
5916
6182
|
};
|
|
5917
6183
|
}
|
|
5918
6184
|
|
|
6185
|
+
/**
|
|
6186
|
+
* Hook to access and update persisted settings for a specific app in the editor.
|
|
6187
|
+
* @param appId The ID of the app whose settings should be retrieved and updated.
|
|
6188
|
+
* @returns `isReady`, the current `settings` object, and an `updateSettings` function.
|
|
6189
|
+
*/
|
|
6190
|
+
function useAppSettings(appId) {
|
|
6191
|
+
const receiverHandlerMap = new Map();
|
|
6192
|
+
const { imc, isReady } = useIMC(receiverHandlerMap, "app-settings");
|
|
6193
|
+
const [settings, setSettings] = useState({});
|
|
6194
|
+
const [isLoaded, setIsLoaded] = useState(false);
|
|
6195
|
+
useEffect(() => {
|
|
6196
|
+
if (isReady) {
|
|
6197
|
+
refetch();
|
|
6198
|
+
}
|
|
6199
|
+
}, [isReady]);
|
|
6200
|
+
async function refetch() {
|
|
6201
|
+
const result = await imc?.sendMessage(IMCMessageTypeEnum.EditorGetAppSettings, { appId });
|
|
6202
|
+
setSettings(result ?? {});
|
|
6203
|
+
setIsLoaded(true);
|
|
6204
|
+
}
|
|
6205
|
+
async function updateSettings(newSettings) {
|
|
6206
|
+
await imc?.sendMessage(IMCMessageTypeEnum.EditorSetAppSettings, {
|
|
6207
|
+
appId,
|
|
6208
|
+
settings: newSettings,
|
|
6209
|
+
});
|
|
6210
|
+
setSettings((prev) => ({ ...prev, ...newSettings }));
|
|
6211
|
+
}
|
|
6212
|
+
async function deleteSetting(key) {
|
|
6213
|
+
await imc?.sendMessage(IMCMessageTypeEnum.EditorDeleteAppSetting, {
|
|
6214
|
+
appId,
|
|
6215
|
+
key,
|
|
6216
|
+
});
|
|
6217
|
+
setSettings((prev) => {
|
|
6218
|
+
const next = { ...prev };
|
|
6219
|
+
delete next[key];
|
|
6220
|
+
return next;
|
|
6221
|
+
});
|
|
6222
|
+
}
|
|
6223
|
+
return {
|
|
6224
|
+
isReady,
|
|
6225
|
+
isLoaded,
|
|
6226
|
+
settings,
|
|
6227
|
+
refetch,
|
|
6228
|
+
updateSettings,
|
|
6229
|
+
deleteSetting,
|
|
6230
|
+
};
|
|
6231
|
+
}
|
|
6232
|
+
|
|
5919
6233
|
function useArtifact() {
|
|
5920
6234
|
const receiverHandlerMap = new Map();
|
|
5921
6235
|
const { imc, isReady } = useIMC(receiverHandlerMap, "artifact");
|
|
@@ -6019,6 +6333,124 @@ function useOwnedAppView() {
|
|
|
6019
6333
|
};
|
|
6020
6334
|
}
|
|
6021
6335
|
|
|
6336
|
+
function generateRandomString(length) {
|
|
6337
|
+
const array = new Uint8Array(length);
|
|
6338
|
+
crypto.getRandomValues(array);
|
|
6339
|
+
return Array.from(array, (b) => b.toString(16).padStart(2, "0")).join("");
|
|
6340
|
+
}
|
|
6341
|
+
/**
|
|
6342
|
+
* Hook to manage OAuth credentials for a Pulse App.
|
|
6343
|
+
*
|
|
6344
|
+
* Handles the full OAuth flow automatically:
|
|
6345
|
+
* - Dynamic client registration (RFC 7591) when `registrationEndpoint` is provided
|
|
6346
|
+
* - PKCE code challenge generation
|
|
6347
|
+
* - Opening the authorization modal
|
|
6348
|
+
* - Token exchange and storage (via the Pulse Editor backend)
|
|
6349
|
+
*
|
|
6350
|
+
* @param appId The ID of the app.
|
|
6351
|
+
* @param provider A provider identifier used to namespace the OAuth state.
|
|
6352
|
+
*/
|
|
6353
|
+
function useOAuth(appId, provider = "default") {
|
|
6354
|
+
const { isReady, isLoaded, settings, deleteSetting, refetch } = useAppSettings(appId);
|
|
6355
|
+
const keyPrefix = `oauth:${provider}:`;
|
|
6356
|
+
const oauthEntries = Object.entries(settings).filter(([k]) => k.startsWith(keyPrefix));
|
|
6357
|
+
const oauthRaw = oauthEntries.length > 0
|
|
6358
|
+
? Object.fromEntries(oauthEntries.map(([k, v]) => [k.slice(keyPrefix.length), v]))
|
|
6359
|
+
: null;
|
|
6360
|
+
const oauth = oauthRaw &&
|
|
6361
|
+
Object.values(oauthRaw).some((v) => v !== null && v !== undefined)
|
|
6362
|
+
? oauthRaw
|
|
6363
|
+
: null;
|
|
6364
|
+
const receiverHandlerMap = new Map();
|
|
6365
|
+
const { imc, isReady: isIMCReady } = useIMC(receiverHandlerMap, "oauth");
|
|
6366
|
+
/**
|
|
6367
|
+
* Initiate the OAuth flow. The editor handles everything:
|
|
6368
|
+
* - Dynamic client registration (if `registrationEndpoint` is provided and `clientId` is omitted)
|
|
6369
|
+
* - PKCE (`codeVerifier` is auto-generated if not provided)
|
|
6370
|
+
* - Opening the consent modal and authorization window
|
|
6371
|
+
* - Token exchange and storage
|
|
6372
|
+
*/
|
|
6373
|
+
async function connect(config) {
|
|
6374
|
+
if (!isIMCReady) {
|
|
6375
|
+
throw new Error("IMC is not ready.");
|
|
6376
|
+
}
|
|
6377
|
+
// Auto-generate PKCE code verifier if not provided
|
|
6378
|
+
const resolvedConfig = { ...config };
|
|
6379
|
+
if (!resolvedConfig.codeVerifier) {
|
|
6380
|
+
resolvedConfig.codeVerifier = generateRandomString(64);
|
|
6381
|
+
resolvedConfig.codeChallengeMethod =
|
|
6382
|
+
resolvedConfig.codeChallengeMethod ?? "S256";
|
|
6383
|
+
}
|
|
6384
|
+
await imc?.sendMessage(IMCMessageTypeEnum.EditorOAuthConnect, {
|
|
6385
|
+
appId,
|
|
6386
|
+
provider,
|
|
6387
|
+
config: resolvedConfig,
|
|
6388
|
+
});
|
|
6389
|
+
}
|
|
6390
|
+
/**
|
|
6391
|
+
* Sign out: removes all stored OAuth tokens for this provider from the
|
|
6392
|
+
* editor backend and resets local auth state immediately.
|
|
6393
|
+
*/
|
|
6394
|
+
async function disconnect() {
|
|
6395
|
+
// Collect keys before deletion so we don't rely on stale `oauth`
|
|
6396
|
+
const keysToDelete = oauthEntries.map(([k]) => k);
|
|
6397
|
+
await Promise.all(keysToDelete.map((key) => deleteSetting(key)));
|
|
6398
|
+
}
|
|
6399
|
+
/**
|
|
6400
|
+
* Re-fetch OAuth state from app settings.
|
|
6401
|
+
* Call this after the user completes the OAuth flow in the external window.
|
|
6402
|
+
*/
|
|
6403
|
+
async function refetchOAuth() {
|
|
6404
|
+
await refetch();
|
|
6405
|
+
}
|
|
6406
|
+
// Revalidate OAuth state when the user returns to the tab
|
|
6407
|
+
useEffect(() => {
|
|
6408
|
+
function handleVisibilityChange() {
|
|
6409
|
+
if (document.visibilityState === "visible") {
|
|
6410
|
+
refetch();
|
|
6411
|
+
}
|
|
6412
|
+
}
|
|
6413
|
+
document.addEventListener("visibilitychange", handleVisibilityChange);
|
|
6414
|
+
return () => {
|
|
6415
|
+
document.removeEventListener("visibilitychange", handleVisibilityChange);
|
|
6416
|
+
};
|
|
6417
|
+
}, [isReady]);
|
|
6418
|
+
/**
|
|
6419
|
+
* Refresh the access token using the stored refresh token.
|
|
6420
|
+
* The editor backend exchanges the refresh token with the OAuth provider
|
|
6421
|
+
* and persists the new tokens automatically.
|
|
6422
|
+
*/
|
|
6423
|
+
async function refreshToken(params) {
|
|
6424
|
+
if (!isIMCReady) {
|
|
6425
|
+
throw new Error("IMC is not ready.");
|
|
6426
|
+
}
|
|
6427
|
+
if (!oauth?.refreshToken) {
|
|
6428
|
+
throw new Error("No refresh token available.");
|
|
6429
|
+
}
|
|
6430
|
+
const result = await imc?.sendMessage(IMCMessageTypeEnum.EditorOAuthRefreshToken, {
|
|
6431
|
+
appId,
|
|
6432
|
+
provider,
|
|
6433
|
+
tokenEndpoint: params.tokenEndpoint,
|
|
6434
|
+
refreshToken: oauth.refreshToken,
|
|
6435
|
+
clientId: params.clientId,
|
|
6436
|
+
clientSecret: params.clientSecret,
|
|
6437
|
+
});
|
|
6438
|
+
// Re-fetch settings to sync local state
|
|
6439
|
+
await refetchOAuth();
|
|
6440
|
+
return result ?? null;
|
|
6441
|
+
}
|
|
6442
|
+
return {
|
|
6443
|
+
isReady,
|
|
6444
|
+
isLoading: !isLoaded,
|
|
6445
|
+
oauth,
|
|
6446
|
+
isAuthenticated: Boolean(oauth?.accessToken),
|
|
6447
|
+
connect,
|
|
6448
|
+
disconnect,
|
|
6449
|
+
refetchOAuth,
|
|
6450
|
+
refreshToken,
|
|
6451
|
+
};
|
|
6452
|
+
}
|
|
6453
|
+
|
|
6022
6454
|
const SnapshotContext = createContext(undefined);
|
|
6023
6455
|
function SnapshotProvider({ children, }) {
|
|
6024
6456
|
const [states, setStates] = useState({});
|
|
@@ -6049,7 +6481,15 @@ function SnapshotProvider({ children, }) {
|
|
|
6049
6481
|
return (React.createElement(SnapshotContext.Provider, { value: { states, setStates } }, children));
|
|
6050
6482
|
}
|
|
6051
6483
|
|
|
6052
|
-
|
|
6484
|
+
/**
|
|
6485
|
+
* A hook that syncs state with a snapshot context,
|
|
6486
|
+
* allowing for state restoration across component unmounts and remounts.
|
|
6487
|
+
* @param key
|
|
6488
|
+
* @param initialValue
|
|
6489
|
+
* @param onRestore
|
|
6490
|
+
* @returns
|
|
6491
|
+
*/
|
|
6492
|
+
function useSnapshotState(key, initialValue, onRestore) {
|
|
6053
6493
|
const snapshotContext = useContext(SnapshotContext);
|
|
6054
6494
|
if (!snapshotContext) {
|
|
6055
6495
|
throw new Error("useSnapShotState must be used within a SnapshotProvider");
|
|
@@ -6277,5 +6717,5 @@ function useWorkspaceInfo() {
|
|
|
6277
6717
|
};
|
|
6278
6718
|
}
|
|
6279
6719
|
|
|
6280
|
-
export { ReceiveFileProvider, SnapshotProvider, useActionEffect, useAgentTools, useAgents, useArtifact, useEditorEnv, useFile, useFileSystem, useImageGen, useLLM, useLoading, useNotification, useOCR, useOpenApp, useOpenLink, useOwnedAppView, useReceiveFile, useSTT,
|
|
6720
|
+
export { ReceiveFileProvider, SnapshotProvider, useActionEffect, useAgentTools, useAgents, useAppSettings, useArtifact, useEditorEnv, useFile, useFileSystem, useImageGen, useLLM, useLoading, useNotification, useOAuth, useOCR, useOpenApp, useOpenLink, useOwnedAppView, useReceiveFile, useSTT, useSnapshotState, useTTS, useTerminal, useTheme, useTranslations, useVideoGen, useWorkspaceInfo };
|
|
6281
6721
|
//# sourceMappingURL=main.js.map
|