@next-core/brick-kit 2.166.0 → 2.167.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -3,8 +3,8 @@ import _objectSpread from '@babel/runtime/helpers/objectSpread2';
3
3
  import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
4
4
  import _defineProperty$1 from '@babel/runtime/helpers/defineProperty';
5
5
  import _asyncToGenerator$3 from '@babel/runtime/helpers/asyncToGenerator';
6
- import _, { set, get, difference, identity, uniqueId, cloneDeep, isNil, isEmpty, merge, sortBy, orderBy, isObject as isObject$1, clamp, uniq, pick, omit, findLastIndex, noop, isString as isString$1 } from 'lodash';
7
- import { JsonStorage, toPath, computeRealRoutePath, hasOwnProperty, isObject, isEvaluable, transformAndInject, transform, trackContext, trackState, trackFormState, scanPermissionActionsInStoryboard, precookFunction, cook, collectContextUsage, deferResolveContextConcurrently, resolveContextConcurrently, syncResolveContextConcurrently, trackUsedFormState, trackUsedState, trackUsedContext, shouldAllowRecursiveEvaluations, preevaluate, inject, scanPermissionActionsInAny, deepFreeze, matchPath, asyncProcessBrick, createProviderClass, removeDeadConditionsInTpl, getTemplateDepsOfStoryboard, getDllAndDepsOfStoryboard, asyncProcessStoryboard, getDllAndDepsByResource, scanRouteAliasInStoryboard, prefetchScript, scanBricksInBrickConf, scanProcessorsInAny, loadScript, scanAppGetMenuInAny, scanInstalledAppsInStoryboard, removeDeadConditions, restoreDynamicTemplates, scanStoryboard, mapCustomApisToNameAndNamespace } from '@next-core/brick-utils';
6
+ import _, { set, get, difference, identity, uniqueId, cloneDeep, clamp, isNil, isEmpty, merge, sortBy, orderBy, isObject as isObject$1, uniq, pick, omit, findLastIndex, noop, isString as isString$1 } from 'lodash';
7
+ import { JsonStorage, toPath, computeRealRoutePath, hasOwnProperty, isObject, isEvaluable, transformAndInject, transform, trackContext, trackState, trackFormState, scanPermissionActionsInStoryboard, precookFunction, cook, collectContextUsage, deferResolveContextConcurrently, resolveContextConcurrently, syncResolveContextConcurrently, trackUsedFormState, trackUsedState, trackUsedContext, shouldAllowRecursiveEvaluations, preevaluate, inject, scanPermissionActionsInAny, deepFreeze, matchPath, asyncProcessBrick, createProviderClass, removeDeadConditionsInTpl, getTemplateDepsOfStoryboard, getDllAndDepsOfStoryboard, asyncProcessStoryboard, getDllAndDepsByResource, scanRouteAliasInStoryboard, prefetchScript, scanBricksInBrickConf, scanProcessorsInAny, loadScript as loadScript$1, scanAppGetMenuInAny, scanInstalledAppsInStoryboard, removeDeadConditions, restoreDynamicTemplates, scanStoryboard, mapCustomApisToNameAndNamespace } from '@next-core/brick-utils';
8
8
  import React, { useState, useEffect, useRef, useMemo, useCallback, forwardRef, useImperativeHandle, useContext, createContext, useReducer } from 'react';
9
9
  import { http, HttpResponseError, HttpAbortError, HttpFetchError } from '@next-core/brick-http';
10
10
  import { Modal, message, Empty, ConfigProvider } from 'antd';
@@ -2431,6 +2431,229 @@ function evaluate(raw) {
2431
2431
  }
2432
2432
  }
2433
2433
 
2434
+ function isBasicProperty(propRef) {
2435
+ return !!propRef.refProperty;
2436
+ }
2437
+ function isTransformableProperty(propRef) {
2438
+ return !!propRef.refTransform;
2439
+ }
2440
+ function isMergeableProperty(propRef) {
2441
+ return !!propRef.mergeProperty;
2442
+ }
2443
+ function isRefProperty(propRef) {
2444
+ return !!propRef.ref;
2445
+ }
2446
+ function isVariableProperty(propRef) {
2447
+ return !!propRef.asVariable;
2448
+ }
2449
+
2450
+ var customTemplateRegistry = new Map();
2451
+ var appRegistered = new Set();
2452
+ var symbolForComputedPropsFromProxy = Symbol.for("tpl.computedPropsFromProxy");
2453
+ var symbolForRefForProxy = Symbol.for("tpl.refForProxy");
2454
+ var symbolForTplContextId = Symbol.for("tpl.contextId");
2455
+
2456
+ function propertyMerge(conf, value, object) {
2457
+ return propertyMergeAll(conf.$$mergeBase, Object.fromEntries(conf.$$mergeBase.proxies.map(proxy => [proxy.$$reversedRef, proxy === conf ? value : object[proxy.$$reversedRef]])));
2458
+ }
2459
+ function propertyMergeAll(mergeBase, object) {
2460
+ if (mergeBase.mergeType === "array") {
2461
+ return propertyMergeAllOfArray(mergeBase, object);
2462
+ }
2463
+ if (mergeBase.mergeType === "object") {
2464
+ return propertyMergeAllOfObject(mergeBase, object);
2465
+ }
2466
+ // istanbul ignore next: should never reach
2467
+ throw new TypeError("unsupported mergeType: \"".concat(mergeBase.mergeType, "\""));
2468
+ }
2469
+ function propertyMergeAllOfArray(_ref, object) {
2470
+ var _, _proxy$mergeArgs;
2471
+ var {
2472
+ baseValue,
2473
+ context,
2474
+ proxies
2475
+ } = _ref;
2476
+ // Use an approach like template-literal's quasis:
2477
+ // `quasi0${0}quais1${1}quasi2...`
2478
+ // Every quasi can be merged with multiple items.
2479
+ var computedBaseValue = Array.isArray(baseValue) ? computeRealValue(baseValue, context, true, {
2480
+ $$lazyForUseBrick: true
2481
+ }) : [];
2482
+ var quasis = [];
2483
+ var size = computedBaseValue.length + 1;
2484
+ for (var i = 0; i < size; i += 1) {
2485
+ quasis.push([]);
2486
+ }
2487
+ for (var proxy of proxies) {
2488
+ var position = void 0;
2489
+ switch (proxy.mergeMethod) {
2490
+ case "append":
2491
+ position = computedBaseValue.length;
2492
+ break;
2493
+ case "prepend":
2494
+ position = 0;
2495
+ break;
2496
+ case "insertAt":
2497
+ // Defaults to `-1`.
2498
+ position = (_ = (_proxy$mergeArgs = proxy.mergeArgs) === null || _proxy$mergeArgs === void 0 ? void 0 : _proxy$mergeArgs[0]) !== null && _ !== void 0 ? _ : -1;
2499
+ if (position < 0) {
2500
+ // It's counted from the end if position is negative.
2501
+ position += quasis.length;
2502
+ }
2503
+ position = clamp(position, 0, computedBaseValue.length);
2504
+ break;
2505
+ // istanbul ignore next: should never reach
2506
+ default:
2507
+ throw new TypeError("unsupported mergeMethod: \"".concat(proxy.mergeMethod, "\" for mergeType \"").concat(proxy.mergeType, "\""));
2508
+ }
2509
+ var patchValue = object[proxy.$$reversedRef];
2510
+ if (!Array.isArray(patchValue)) {
2511
+ patchValue = [];
2512
+ }
2513
+ quasis[position].push(...patchValue);
2514
+ }
2515
+ return quasis.flatMap((item, index) => index < computedBaseValue.length ? item.concat(computedBaseValue[index]) : item);
2516
+ }
2517
+ function propertyMergeAllOfObject(_ref2, object) {
2518
+ var {
2519
+ baseValue,
2520
+ proxies,
2521
+ context
2522
+ } = _ref2;
2523
+ var computedBaseValue = isObject(baseValue) ? computeRealValue(baseValue, context, true) : {};
2524
+ return proxies.reduce((acc, proxy) => {
2525
+ switch (proxy.mergeMethod) {
2526
+ case "extend":
2527
+ return _objectSpread(_objectSpread({}, acc), object[proxy.$$reversedRef]);
2528
+ // istanbul ignore next: should never reach
2529
+ default:
2530
+ throw new TypeError("unsupported mergeMethod: \"".concat(proxy.mergeMethod, "\" for mergeType \"").concat(proxy.mergeType, "\""));
2531
+ }
2532
+ }, computedBaseValue);
2533
+ }
2534
+
2535
+ function setupTemplateProxy(proxyContext, ref, slots) {
2536
+ var computedPropsFromProxy = {};
2537
+ var refForProxy;
2538
+ var {
2539
+ reversedProxies,
2540
+ templateProperties,
2541
+ externalSlots,
2542
+ templateContextId,
2543
+ proxyBrick
2544
+ } = proxyContext;
2545
+ if (ref && reversedProxies) {
2546
+ refForProxy = {};
2547
+ proxyBrick.proxyRefs.set(ref, refForProxy);
2548
+
2549
+ // Reversed proxies are used for expand storyboard before rendering page.
2550
+ if (reversedProxies.properties.has(ref)) {
2551
+ Object.assign(computedPropsFromProxy, Object.fromEntries(reversedProxies.properties.get(ref).flatMap(propRef => {
2552
+ // `propValue` is computed.
2553
+ var propValue = templateProperties === null || templateProperties === void 0 ? void 0 : templateProperties[propRef.$$reversedRef];
2554
+ if (isTransformableProperty(propRef)) {
2555
+ return Object.entries(preprocessTransformProperties({
2556
+ [propRef.$$reversedRef]: propValue
2557
+ }, propRef.refTransform));
2558
+ }
2559
+ if (isBasicProperty(propRef)) {
2560
+ return [[propRef.refProperty, propValue]];
2561
+ }
2562
+ // Ignore Variable properties.
2563
+ // And mergeable properties are processed later.
2564
+ return [];
2565
+ }).filter(propRef => propRef[1] !== undefined)));
2566
+
2567
+ // Brick properties can be merged multiple times.
2568
+ if (reversedProxies.mergeBases.has(ref)) {
2569
+ Object.assign(computedPropsFromProxy, Object.fromEntries(Array.from(reversedProxies.mergeBases.get(ref).entries()).map(_ref => {
2570
+ var [mergeProperty, mergeBase] = _ref;
2571
+ return [mergeProperty, propertyMergeAll(mergeBase, templateProperties !== null && templateProperties !== void 0 ? templateProperties : {})];
2572
+ }).filter(item => item[1] !== undefined)));
2573
+ }
2574
+ }
2575
+
2576
+ // Use an approach like template-literal's quasis:
2577
+ // `quasi0${0}quais1${1}quasi2...`
2578
+ // Every quasi (indexed by `refPosition`) can be slotted with multiple bricks.
2579
+ var quasisMap = new Map();
2580
+ if (reversedProxies.slots.has(ref)) {
2581
+ for (var item of reversedProxies.slots.get(ref)) {
2582
+ var _item$refPosition, _externalSlots$item$$, _externalSlots$item$$2;
2583
+ if (!quasisMap.has(item.refSlot)) {
2584
+ var quasis = [];
2585
+ // The size of quasis should be the existed slotted bricks' size plus one.
2586
+ var size = hasOwnProperty(slots, item.refSlot) ? slots[item.refSlot].bricks.length + 1 : 1;
2587
+ for (var i = 0; i < size; i += 1) {
2588
+ quasis.push([]);
2589
+ }
2590
+ quasisMap.set(item.refSlot, quasis);
2591
+ }
2592
+ var expandableSlot = quasisMap.get(item.refSlot);
2593
+ var refPosition = (_item$refPosition = item.refPosition) !== null && _item$refPosition !== void 0 ? _item$refPosition : -1;
2594
+ expandableSlot[clamp(refPosition < 0 ? expandableSlot.length + refPosition : refPosition, 0, expandableSlot.length - 1)].push(...((_externalSlots$item$$ = externalSlots === null || externalSlots === void 0 ? void 0 : (_externalSlots$item$$2 = externalSlots[item.$$reversedRef]) === null || _externalSlots$item$$2 === void 0 ? void 0 : _externalSlots$item$$2.bricks) !== null && _externalSlots$item$$ !== void 0 ? _externalSlots$item$$ : []));
2595
+ }
2596
+ }
2597
+ var _loop = function (slotName, _quasis) {
2598
+ if (!hasOwnProperty(slots, slotName)) {
2599
+ slots[slotName] = {
2600
+ type: "bricks",
2601
+ bricks: []
2602
+ };
2603
+ }
2604
+ var slotConf = slots[slotName];
2605
+ slotConf.bricks = _quasis.flatMap((bricks, index) => index < slotConf.bricks.length ? bricks.concat(slotConf.bricks[index]) : bricks);
2606
+ if (slotConf.bricks.length === 0) {
2607
+ delete slots[slotName];
2608
+ }
2609
+ };
2610
+ for (var [slotName, _quasis] of quasisMap.entries()) {
2611
+ _loop(slotName, _quasis);
2612
+ }
2613
+ }
2614
+ return {
2615
+ [symbolForComputedPropsFromProxy]: computedPropsFromProxy,
2616
+ [symbolForRefForProxy]: refForProxy,
2617
+ [symbolForTplContextId]: templateContextId
2618
+ };
2619
+ }
2620
+
2621
+ var _excluded$7 = ["properties", "slots"];
2622
+ function setupUseBrickInTemplate(props, proxyContext) {
2623
+ function walk(props) {
2624
+ if (!isObject(props)) {
2625
+ return props;
2626
+ }
2627
+ if (Array.isArray(props)) {
2628
+ return props.map(walk);
2629
+ }
2630
+ return Object.fromEntries(Object.entries(props).map(_ref => {
2631
+ var [key, value] = _ref;
2632
+ return isObject(value) && key === "useBrick" ? Array.isArray(value) ? [key, value.map(setup)] : [key, setup(value)] : [key, walk(value)];
2633
+ }).concat(Object.getOwnPropertySymbols(props).map(k => [k, props[k]])));
2634
+ }
2635
+ function setup(item) {
2636
+ var {
2637
+ properties,
2638
+ slots: originalSlots
2639
+ } = item,
2640
+ restConf = _objectWithoutProperties(item, _excluded$7);
2641
+ var slots = Object.fromEntries(Object.entries(originalSlots !== null && originalSlots !== void 0 ? originalSlots : {}).map(_ref2 => {
2642
+ var _slotConf$bricks;
2643
+ var [slotName, slotConf] = _ref2;
2644
+ return [slotName, {
2645
+ type: "bricks",
2646
+ bricks: ((_slotConf$bricks = slotConf.bricks) !== null && _slotConf$bricks !== void 0 ? _slotConf$bricks : []).map(setup)
2647
+ }];
2648
+ }));
2649
+ return _objectSpread(_objectSpread({}, restConf), {}, {
2650
+ properties: walk(properties),
2651
+ slots
2652
+ }, setupTemplateProxy(proxyContext, restConf.ref, slots));
2653
+ }
2654
+ return walk(props);
2655
+ }
2656
+
2434
2657
  var computeRealValue = (value, context, injectDeep, internalOptions) => {
2435
2658
  var preEvaluated = isPreEvaluated(value);
2436
2659
  if (preEvaluated || typeof value === "string") {
@@ -2482,6 +2705,11 @@ var computeRealValue = (value, context, injectDeep, internalOptions) => {
2482
2705
  };
2483
2706
  function setProperties(bricks, properties, context, injectDeep) {
2484
2707
  var realProps = computeRealProperties(properties, context, injectDeep);
2708
+ if (context.tplContextId) {
2709
+ realProps = setupUseBrickInTemplate(realProps, {
2710
+ templateContextId: context.tplContextId
2711
+ });
2712
+ }
2485
2713
  if (!Array.isArray(bricks)) {
2486
2714
  bricks = [bricks];
2487
2715
  }
@@ -2549,7 +2777,7 @@ function getNextInternalOptions(internalOptions, isArray, key) {
2549
2777
  }) : internalOptions;
2550
2778
  }
2551
2779
 
2552
- var _excluded$7 = ["children"],
2780
+ var _excluded$6 = ["children"],
2553
2781
  _excluded2$2 = ["children"],
2554
2782
  _excluded3 = ["items", "app"];
2555
2783
  var symbolAppId = Symbol("appId");
@@ -2812,7 +3040,7 @@ function collectAppsRequireI18nFulfilled(items, contextAppId, appIds) {
2812
3040
  var {
2813
3041
  children
2814
3042
  } = _ref,
2815
- rest = _objectWithoutProperties(_ref, _excluded$7);
3043
+ rest = _objectWithoutProperties(_ref, _excluded$6);
2816
3044
  var overrideAppId = rest[symbolAppId];
2817
3045
  if (!rest[symbolMenuI18nNamespace] && overrideAppId !== contextAppId && !appIds.has(overrideAppId) && attemptToVisit(rest, ["I18N"])) {
2818
3046
  appIds.add(overrideAppId);
@@ -3434,7 +3662,7 @@ function _internalApiLoadDynamicBricksInBrickConf(brickConf) {
3434
3662
  return kernel.loadDynamicBricksInBrickConf(brickConf);
3435
3663
  }
3436
3664
 
3437
- var _excluded$6 = ["extraQuery", "clear", "keepHash"];
3665
+ var _excluded$5 = ["extraQuery", "clear", "keepHash"];
3438
3666
  var blocked = false;
3439
3667
  function getUserConfirmation(message, callback) {
3440
3668
  blocked = !confirm(message);
@@ -3464,7 +3692,7 @@ function historyExtended(browserHistory) {
3464
3692
  clear,
3465
3693
  keepHash
3466
3694
  } = options,
3467
- state = _objectWithoutProperties(options, _excluded$6);
3695
+ state = _objectWithoutProperties(options, _excluded$5);
3468
3696
  var urlSearchParams = new URLSearchParams(clear ? "" : browserHistory.location.search);
3469
3697
  var params = {};
3470
3698
  Object.assign(params, query, extraQuery);
@@ -6324,41 +6552,302 @@ var UserAdminApi_searchAllUsersInfo = /*#__PURE__*/function () {
6324
6552
  };
6325
6553
  }();
6326
6554
 
6327
- /**
6328
- * Merge `app.defaultConfig` and `app.userConfig` to `app.config`.
6329
- *
6330
- * @param bootstrapResponse - Response of bootstrap API.
6331
- */
6332
- function processBootstrapResponse(bootstrapResponse) {
6333
- for (var storyboard of bootstrapResponse.storyboards) {
6334
- var app = storyboard.app;
6335
- if (app) {
6336
- app.config = deepFreeze(merge({}, app.defaultConfig, app.userConfig));
6337
- if (app.locales) {
6338
- (function () {
6339
- // Prefix to avoid conflict between brick package's i18n namespace.
6340
- var ns = "$tmp-".concat(app.id);
6341
- // Support any languages in `app.locales`.
6342
- Object.entries(app.locales).forEach(_ref => {
6343
- var [lang, resources] = _ref;
6344
- i18next.addResourceBundle(lang, ns, resources);
6345
- });
6346
- // Use `app.name` as the fallback `app.localeName`.
6347
- app.localeName = i18next.getFixedT(null, ns)("name", app.name);
6348
- // Remove the temporary i18n resource bundles.
6349
- Object.keys(app.locales).forEach(lang => {
6350
- i18next.removeResourceBundle(lang, ns);
6351
- });
6352
- })();
6353
- } else {
6354
- app.localeName = app.name;
6355
- }
6356
- }
6555
+ var cache$1 = new Map();
6556
+ function loadScript(src, prefix) {
6557
+ if (Array.isArray(src)) {
6558
+ return Promise.all(src.map(item => loadScript(item, prefix)));
6357
6559
  }
6358
- if (bootstrapResponse.settings) {
6359
- bootstrapResponse.settings = deepFreeze(bootstrapResponse.settings);
6560
+ var fixedSrc = prefix ? "".concat(prefix).concat(src) : src;
6561
+ var cachedPromise = cache$1.get(fixedSrc);
6562
+ if (cachedPromise) {
6563
+ return cachedPromise;
6360
6564
  }
6361
- bootstrapResponse.brickPackages = deepFreeze(bootstrapResponse.brickPackages);
6565
+ var promise = new Promise((resolve, reject) => {
6566
+ var end = () => {
6567
+ window.dispatchEvent(new Event("request.end"));
6568
+ };
6569
+ var script = document.createElement("script");
6570
+ script.src = fixedSrc;
6571
+ script.type = "text/javascript";
6572
+ script.async = true;
6573
+ script.onload = () => {
6574
+ resolve(fixedSrc);
6575
+ end();
6576
+ };
6577
+ script.onerror = e => {
6578
+ reject(e);
6579
+ end();
6580
+ };
6581
+ var firstScript = document.currentScript || document.getElementsByTagName("script")[0];
6582
+ firstScript.parentNode.insertBefore(script, firstScript);
6583
+ window.dispatchEvent(new Event("request.start"));
6584
+ });
6585
+ cache$1.set(fixedSrc, promise);
6586
+ return promise;
6587
+ }
6588
+
6589
+ // https://github.com/module-federation/module-federation-examples/blob/eda9493f3991a423479fd834cfb1d7b241d9d1f0/advanced-api/dynamic-remotes/app1/src/App.js
6590
+ function loadSharedModule(_x, _x2) {
6591
+ return _loadSharedModule.apply(this, arguments);
6592
+ }
6593
+ function _loadSharedModule() {
6594
+ _loadSharedModule = _asyncToGenerator$3(function* (scope, module) {
6595
+ // Initializes the share scope. This fills it with known provided modules from this build and all remotes
6596
+ yield __webpack_init_sharing__("default");
6597
+ var container = window[scope]; // or get the container somewhere else
6598
+ // Initialize the container, it may provide shared modules
6599
+ yield container.init(__webpack_share_scopes__.default);
6600
+ var factory = yield container.get(module);
6601
+ return factory();
6602
+ });
6603
+ return _loadSharedModule.apply(this, arguments);
6604
+ }
6605
+
6606
+ var resolveBasicPkg;
6607
+ var basicPkgWillBeResolved = false;
6608
+ var waitBasicPkg = new Promise(resolve => {
6609
+ resolveBasicPkg = resolve;
6610
+ });
6611
+ function flushStableLoadBricks() {
6612
+ if (!basicPkgWillBeResolved) {
6613
+ resolveBasicPkg();
6614
+ }
6615
+ }
6616
+ function loadBricksImperatively(_x, _x2) {
6617
+ return _loadBricksImperatively.apply(this, arguments);
6618
+ }
6619
+ function _loadBricksImperatively() {
6620
+ _loadBricksImperatively = _asyncToGenerator$3(function* (bricks, brickPackages) {
6621
+ var promise = enqueueStableLoad("bricks", bricks, brickPackages);
6622
+ flushStableLoadBricks();
6623
+ return dispatchRequestStatus(promise);
6624
+ });
6625
+ return _loadBricksImperatively.apply(this, arguments);
6626
+ }
6627
+ function loadProcessorsImperatively(processors, brickPackages) {
6628
+ var promise = enqueueStableLoad("processors", processors, brickPackages);
6629
+ flushStableLoadBricks();
6630
+ return dispatchRequestStatus(promise);
6631
+ }
6632
+ var v2AdapterPromise;
6633
+ var V2_ADAPTER_LOAD_BRICKS = "v2-adapter.load-bricks";
6634
+
6635
+ // Get brick/processor items including their dependencies
6636
+ function getItemsByPkg(type, list, brickPackagesMap) {
6637
+ var itemsByPkg = new Map();
6638
+ var listToLoad = new Set();
6639
+ var add = item => {
6640
+ var _pkg$dependencies;
6641
+ if (listToLoad.has(item)) {
6642
+ return;
6643
+ }
6644
+ listToLoad.add(item);
6645
+ var pkg;
6646
+ var namespace;
6647
+ var itemName;
6648
+ if (type === "processors" || item.includes(".")) {
6649
+ [namespace, itemName] = item.split(".");
6650
+ var pkgId = "bricks/".concat(type === "processors" ? getProcessorPackageName(namespace) : namespace);
6651
+ pkg = brickPackagesMap.get(pkgId);
6652
+ } else {
6653
+ itemName = item;
6654
+ for (var p of brickPackagesMap.values()) {
6655
+ var _p$elements;
6656
+ if ((_p$elements = p.elements) !== null && _p$elements !== void 0 && _p$elements.some(e => e === itemName)) {
6657
+ pkg = p;
6658
+ break;
6659
+ }
6660
+ }
6661
+ }
6662
+ if (!pkg) {
6663
+ throw new Error("Package for ".concat(item, " not found."));
6664
+ }
6665
+ var groupItems = itemsByPkg.get(pkg);
6666
+ if (!groupItems) {
6667
+ groupItems = [];
6668
+ itemsByPkg.set(pkg, groupItems);
6669
+ }
6670
+ groupItems.push(itemName);
6671
+
6672
+ // Load their dependencies too
6673
+ var deps = (_pkg$dependencies = pkg.dependencies) === null || _pkg$dependencies === void 0 ? void 0 : _pkg$dependencies[item];
6674
+ if (deps) {
6675
+ for (var dep of deps) {
6676
+ add(dep);
6677
+ }
6678
+ }
6679
+ };
6680
+ for (var item of list) {
6681
+ add(item);
6682
+ }
6683
+ return itemsByPkg;
6684
+ }
6685
+ function loadBrickModule(_x3, _x4, _x5) {
6686
+ return _loadBrickModule.apply(this, arguments);
6687
+ }
6688
+ function _loadBrickModule() {
6689
+ _loadBrickModule = _asyncToGenerator$3(function* (type, pkgId, itemName) {
6690
+ var moduleName = "".concat(type === "processors" ? "./processors/" : "./").concat(itemName);
6691
+ try {
6692
+ yield loadSharedModule(pkgId, moduleName);
6693
+ } catch (error) {
6694
+ // eslint-disable-next-line no-console
6695
+ console.error(error);
6696
+ throw new Error("Load ".concat(type, " of \"").concat(pkgId.split("/").pop(), ".").concat(moduleName.split("/").pop(), "\" failed"));
6697
+ }
6698
+ });
6699
+ return _loadBrickModule.apply(this, arguments);
6700
+ }
6701
+ function loadRestBricks(type, pkgs, itemsMap) {
6702
+ return pkgs.map( /*#__PURE__*/function () {
6703
+ var _ref = _asyncToGenerator$3(function* (pkg) {
6704
+ var _window$PUBLIC_ROOT;
6705
+ yield loadScript(pkg.filePath, (_window$PUBLIC_ROOT = window.PUBLIC_ROOT) !== null && _window$PUBLIC_ROOT !== void 0 ? _window$PUBLIC_ROOT : "");
6706
+ yield waitBasicPkg;
6707
+ return Promise.all(
6708
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
6709
+ itemsMap.get(pkg).map(itemName => loadBrickModule(type, pkg.id, itemName)));
6710
+ });
6711
+ return function (_x6) {
6712
+ return _ref.apply(this, arguments);
6713
+ };
6714
+ }());
6715
+ }
6716
+ function enqueueStableLoad(_x7, _x8, _x9) {
6717
+ return _enqueueStableLoad.apply(this, arguments);
6718
+ }
6719
+ function _enqueueStableLoad() {
6720
+ _enqueueStableLoad = _asyncToGenerator$3(function* (type, list, brickPackages) {
6721
+ var brickPackagesMap = new Map();
6722
+ for (var pkg of brickPackages) {
6723
+ var _pkg$id;
6724
+ var pkgId = (_pkg$id = pkg.id) !== null && _pkg$id !== void 0 ? _pkg$id : getPkgIdByFilePath(pkg.filePath);
6725
+ brickPackagesMap.set(pkgId, pkg);
6726
+ }
6727
+ var itemsByPkg = getItemsByPkg(type, list, brickPackagesMap);
6728
+ var foundBasicPkg;
6729
+ var v2Packages = [];
6730
+ var v3PackagesOtherThanBasic = [];
6731
+ var maybeV2Adapter;
6732
+ for (var _pkg of itemsByPkg.keys()) {
6733
+ if (_pkg.id) {
6734
+ if (_pkg.id === "bricks/basic") {
6735
+ foundBasicPkg = _pkg;
6736
+ } else {
6737
+ v3PackagesOtherThanBasic.push(_pkg);
6738
+ }
6739
+ } else {
6740
+ // Brick packages of v2 has no `id`
6741
+ v2Packages.push(_pkg);
6742
+ maybeV2Adapter = brickPackagesMap.get("bricks/v2-adapter");
6743
+ if (!maybeV2Adapter) {
6744
+ // eslint-disable-next-line no-console
6745
+ console.error("Using v2 bricks, but v2-adapter not found");
6746
+ }
6747
+ }
6748
+ }
6749
+ var v2Adapter = maybeV2Adapter;
6750
+ var basicPkgPromise;
6751
+ var basicPkg = foundBasicPkg;
6752
+ if (basicPkg) {
6753
+ var _window$PUBLIC_ROOT2;
6754
+ var tempPromise = loadScript(basicPkg.filePath, (_window$PUBLIC_ROOT2 = window.PUBLIC_ROOT) !== null && _window$PUBLIC_ROOT2 !== void 0 ? _window$PUBLIC_ROOT2 : "");
6755
+ // Packages other than BASIC will wait for an extra micro-task tick.
6756
+ if (!basicPkgWillBeResolved) {
6757
+ basicPkgWillBeResolved = true;
6758
+ tempPromise.then(() => Promise.resolve()).then(resolveBasicPkg);
6759
+ }
6760
+ basicPkgPromise = tempPromise.then(() => Promise.all(
6761
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
6762
+ itemsByPkg.get(basicPkg).map(itemName => loadBrickModule(type, basicPkg.id, itemName))));
6763
+ }
6764
+ var pkgPromises = [basicPkgPromise].concat(loadRestBricks(type, v3PackagesOtherThanBasic, itemsByPkg));
6765
+ if (v2Adapter && v2Packages.length > 0) {
6766
+ if (!v2AdapterPromise) {
6767
+ // Load `v2-adapter.load-bricks` and its dependencies
6768
+ var v2AdapterItemsByPkg = getItemsByPkg("bricks", [V2_ADAPTER_LOAD_BRICKS], brickPackagesMap);
6769
+ var v2AdapterPackages = [...v2AdapterItemsByPkg.keys()];
6770
+ var loadV2Adapter = /*#__PURE__*/function () {
6771
+ var _ref2 = _asyncToGenerator$3(function* () {
6772
+ yield Promise.all(loadRestBricks("bricks", v2AdapterPackages, v2AdapterItemsByPkg));
6773
+ return document.createElement(V2_ADAPTER_LOAD_BRICKS);
6774
+ });
6775
+ return function loadV2Adapter() {
6776
+ return _ref2.apply(this, arguments);
6777
+ };
6778
+ }();
6779
+ v2AdapterPromise = loadV2Adapter();
6780
+ }
6781
+ pkgPromises.push(v2AdapterPromise.then(adapter => Promise.all(v2Packages.map(pkg => {
6782
+ var pkgId = getPkgIdByFilePath(pkg.filePath);
6783
+ var pkgNamespace = pkgId.split("/")[1];
6784
+ return adapter.resolve(v2Adapter.filePath, pkg.filePath, type === "bricks" ?
6785
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
6786
+ itemsByPkg.get(pkg).map(itemName => "".concat(pkgNamespace, ".").concat(itemName)) : [], pkg.dll,
6787
+ // Todo: remove `brickPackages` as an argument
6788
+ brickPackages);
6789
+ }))));
6790
+ }
6791
+ yield Promise.all(pkgPromises);
6792
+ });
6793
+ return _enqueueStableLoad.apply(this, arguments);
6794
+ }
6795
+ function dispatchRequestStatus(_x10) {
6796
+ return _dispatchRequestStatus.apply(this, arguments);
6797
+ }
6798
+ function _dispatchRequestStatus() {
6799
+ _dispatchRequestStatus = _asyncToGenerator$3(function* (promise) {
6800
+ window.dispatchEvent(new Event("request.start"));
6801
+ try {
6802
+ yield promise;
6803
+ } finally {
6804
+ window.dispatchEvent(new Event("request.end"));
6805
+ }
6806
+ });
6807
+ return _dispatchRequestStatus.apply(this, arguments);
6808
+ }
6809
+ function getProcessorPackageName(camelPackageName) {
6810
+ return camelPackageName.replace(/[A-Z]/g, match => "-".concat(match[0].toLocaleLowerCase())).replace(/_[0-9]/g, match => "-".concat(match[1]));
6811
+ }
6812
+ function getPkgIdByFilePath(filePath) {
6813
+ return filePath.split("/").slice(0, 2).join("/");
6814
+ }
6815
+
6816
+ /**
6817
+ * Merge `app.defaultConfig` and `app.userConfig` to `app.config`.
6818
+ *
6819
+ * @param bootstrapResponse - Response of bootstrap API.
6820
+ */
6821
+ function processBootstrapResponse(bootstrapResponse) {
6822
+ for (var storyboard of bootstrapResponse.storyboards) {
6823
+ var app = storyboard.app;
6824
+ if (app) {
6825
+ app.config = deepFreeze(merge({}, app.defaultConfig, app.userConfig));
6826
+ if (app.locales) {
6827
+ (function () {
6828
+ // Prefix to avoid conflict between brick package's i18n namespace.
6829
+ var ns = "$tmp-".concat(app.id);
6830
+ // Support any languages in `app.locales`.
6831
+ Object.entries(app.locales).forEach(_ref => {
6832
+ var [lang, resources] = _ref;
6833
+ i18next.addResourceBundle(lang, ns, resources);
6834
+ });
6835
+ // Use `app.name` as the fallback `app.localeName`.
6836
+ app.localeName = i18next.getFixedT(null, ns)("name", app.name);
6837
+ // Remove the temporary i18n resource bundles.
6838
+ Object.keys(app.locales).forEach(lang => {
6839
+ i18next.removeResourceBundle(lang, ns);
6840
+ });
6841
+ })();
6842
+ } else {
6843
+ app.localeName = app.name;
6844
+ }
6845
+ }
6846
+ }
6847
+ if (bootstrapResponse.settings) {
6848
+ bootstrapResponse.settings = deepFreeze(bootstrapResponse.settings);
6849
+ }
6850
+ bootstrapResponse.brickPackages = deepFreeze(bootstrapResponse.brickPackages);
6362
6851
  bootstrapResponse.templatePackages = deepFreeze(bootstrapResponse.templatePackages);
6363
6852
  }
6364
6853
 
@@ -6535,7 +7024,7 @@ var RuntimeApi_searchMicroAppStandalone = /*#__PURE__*/function () {
6535
7024
  };
6536
7025
  }();
6537
7026
 
6538
- var _excluded$5 = ["feature_flags"],
7027
+ var _excluded$4 = ["feature_flags"],
6539
7028
  _excluded2$1 = ["featureFlags", "misc"];
6540
7029
  function standaloneBootstrap() {
6541
7030
  return _standaloneBootstrap.apply(this, arguments);
@@ -6581,7 +7070,7 @@ function _standaloneBootstrap() {
6581
7070
  var {
6582
7071
  feature_flags: featureFlags
6583
7072
  } = sys_settings,
6584
- rest = _objectWithoutProperties(sys_settings, _excluded$5);
7073
+ rest = _objectWithoutProperties(sys_settings, _excluded$4);
6585
7074
  settings = _objectSpread({
6586
7075
  featureFlags
6587
7076
  }, rest);
@@ -7539,28 +8028,6 @@ var formRenderer = "form-renderer.form-renderer";
7539
8028
  var filterProperties = ["instanceId", "brick", "slots", "properties", "events", "if", "context", "bricks", "mountPoint"];
7540
8029
  var symbolForFormContextId = Symbol.for("form.contextId");
7541
8030
 
7542
- var customTemplateRegistry = new Map();
7543
- var appRegistered = new Set();
7544
- var symbolForComputedPropsFromProxy = Symbol.for("tpl.computedPropsFromProxy");
7545
- var symbolForRefForProxy = Symbol.for("tpl.refForProxy");
7546
- var symbolForTplContextId = Symbol.for("tpl.contextId");
7547
-
7548
- function isBasicProperty(propRef) {
7549
- return !!propRef.refProperty;
7550
- }
7551
- function isTransformableProperty(propRef) {
7552
- return !!propRef.refTransform;
7553
- }
7554
- function isMergeableProperty(propRef) {
7555
- return !!propRef.mergeProperty;
7556
- }
7557
- function isRefProperty(propRef) {
7558
- return !!propRef.ref;
7559
- }
7560
- function isVariableProperty(propRef) {
7561
- return !!propRef.asVariable;
7562
- }
7563
-
7564
8031
  function collectRefsInTemplate(template) {
7565
8032
  var refMap = new Map();
7566
8033
  collectRefsInBrickConfs(template.bricks, refMap);
@@ -7616,207 +8083,6 @@ function collectMergeBases(conf, mergeBases, contextInTemplate, refToBrickConf)
7616
8083
  }
7617
8084
  }
7618
8085
 
7619
- function propertyMerge(conf, value, object) {
7620
- return propertyMergeAll(conf.$$mergeBase, Object.fromEntries(conf.$$mergeBase.proxies.map(proxy => [proxy.$$reversedRef, proxy === conf ? value : object[proxy.$$reversedRef]])));
7621
- }
7622
- function propertyMergeAll(mergeBase, object) {
7623
- if (mergeBase.mergeType === "array") {
7624
- return propertyMergeAllOfArray(mergeBase, object);
7625
- }
7626
- if (mergeBase.mergeType === "object") {
7627
- return propertyMergeAllOfObject(mergeBase, object);
7628
- }
7629
- // istanbul ignore next: should never reach
7630
- throw new TypeError("unsupported mergeType: \"".concat(mergeBase.mergeType, "\""));
7631
- }
7632
- function propertyMergeAllOfArray(_ref, object) {
7633
- var _, _proxy$mergeArgs;
7634
- var {
7635
- baseValue,
7636
- context,
7637
- proxies
7638
- } = _ref;
7639
- // Use an approach like template-literal's quasis:
7640
- // `quasi0${0}quais1${1}quasi2...`
7641
- // Every quasi can be merged with multiple items.
7642
- var computedBaseValue = Array.isArray(baseValue) ? computeRealValue(baseValue, context, true, {
7643
- $$lazyForUseBrick: true
7644
- }) : [];
7645
- var quasis = [];
7646
- var size = computedBaseValue.length + 1;
7647
- for (var i = 0; i < size; i += 1) {
7648
- quasis.push([]);
7649
- }
7650
- for (var proxy of proxies) {
7651
- var position = void 0;
7652
- switch (proxy.mergeMethod) {
7653
- case "append":
7654
- position = computedBaseValue.length;
7655
- break;
7656
- case "prepend":
7657
- position = 0;
7658
- break;
7659
- case "insertAt":
7660
- // Defaults to `-1`.
7661
- position = (_ = (_proxy$mergeArgs = proxy.mergeArgs) === null || _proxy$mergeArgs === void 0 ? void 0 : _proxy$mergeArgs[0]) !== null && _ !== void 0 ? _ : -1;
7662
- if (position < 0) {
7663
- // It's counted from the end if position is negative.
7664
- position += quasis.length;
7665
- }
7666
- position = clamp(position, 0, computedBaseValue.length);
7667
- break;
7668
- // istanbul ignore next: should never reach
7669
- default:
7670
- throw new TypeError("unsupported mergeMethod: \"".concat(proxy.mergeMethod, "\" for mergeType \"").concat(proxy.mergeType, "\""));
7671
- }
7672
- var patchValue = object[proxy.$$reversedRef];
7673
- if (!Array.isArray(patchValue)) {
7674
- patchValue = [];
7675
- }
7676
- quasis[position].push(...patchValue);
7677
- }
7678
- return quasis.flatMap((item, index) => index < computedBaseValue.length ? item.concat(computedBaseValue[index]) : item);
7679
- }
7680
- function propertyMergeAllOfObject(_ref2, object) {
7681
- var {
7682
- baseValue,
7683
- proxies,
7684
- context
7685
- } = _ref2;
7686
- var computedBaseValue = isObject(baseValue) ? computeRealValue(baseValue, context, true) : {};
7687
- return proxies.reduce((acc, proxy) => {
7688
- switch (proxy.mergeMethod) {
7689
- case "extend":
7690
- return _objectSpread(_objectSpread({}, acc), object[proxy.$$reversedRef]);
7691
- // istanbul ignore next: should never reach
7692
- default:
7693
- throw new TypeError("unsupported mergeMethod: \"".concat(proxy.mergeMethod, "\" for mergeType \"").concat(proxy.mergeType, "\""));
7694
- }
7695
- }, computedBaseValue);
7696
- }
7697
-
7698
- function setupTemplateProxy(proxyContext, ref, slots) {
7699
- var computedPropsFromProxy = {};
7700
- var refForProxy;
7701
- var {
7702
- reversedProxies,
7703
- templateProperties,
7704
- externalSlots,
7705
- templateContextId,
7706
- proxyBrick
7707
- } = proxyContext;
7708
- if (ref && reversedProxies) {
7709
- refForProxy = {};
7710
- proxyBrick.proxyRefs.set(ref, refForProxy);
7711
-
7712
- // Reversed proxies are used for expand storyboard before rendering page.
7713
- if (reversedProxies.properties.has(ref)) {
7714
- Object.assign(computedPropsFromProxy, Object.fromEntries(reversedProxies.properties.get(ref).flatMap(propRef => {
7715
- // `propValue` is computed.
7716
- var propValue = templateProperties === null || templateProperties === void 0 ? void 0 : templateProperties[propRef.$$reversedRef];
7717
- if (isTransformableProperty(propRef)) {
7718
- return Object.entries(preprocessTransformProperties({
7719
- [propRef.$$reversedRef]: propValue
7720
- }, propRef.refTransform));
7721
- }
7722
- if (isBasicProperty(propRef)) {
7723
- return [[propRef.refProperty, propValue]];
7724
- }
7725
- // Ignore Variable properties.
7726
- // And mergeable properties are processed later.
7727
- return [];
7728
- }).filter(propRef => propRef[1] !== undefined)));
7729
-
7730
- // Brick properties can be merged multiple times.
7731
- if (reversedProxies.mergeBases.has(ref)) {
7732
- Object.assign(computedPropsFromProxy, Object.fromEntries(Array.from(reversedProxies.mergeBases.get(ref).entries()).map(_ref => {
7733
- var [mergeProperty, mergeBase] = _ref;
7734
- return [mergeProperty, propertyMergeAll(mergeBase, templateProperties !== null && templateProperties !== void 0 ? templateProperties : {})];
7735
- }).filter(item => item[1] !== undefined)));
7736
- }
7737
- }
7738
-
7739
- // Use an approach like template-literal's quasis:
7740
- // `quasi0${0}quais1${1}quasi2...`
7741
- // Every quasi (indexed by `refPosition`) can be slotted with multiple bricks.
7742
- var quasisMap = new Map();
7743
- if (reversedProxies.slots.has(ref)) {
7744
- for (var item of reversedProxies.slots.get(ref)) {
7745
- var _item$refPosition, _externalSlots$item$$, _externalSlots$item$$2;
7746
- if (!quasisMap.has(item.refSlot)) {
7747
- var quasis = [];
7748
- // The size of quasis should be the existed slotted bricks' size plus one.
7749
- var size = hasOwnProperty(slots, item.refSlot) ? slots[item.refSlot].bricks.length + 1 : 1;
7750
- for (var i = 0; i < size; i += 1) {
7751
- quasis.push([]);
7752
- }
7753
- quasisMap.set(item.refSlot, quasis);
7754
- }
7755
- var expandableSlot = quasisMap.get(item.refSlot);
7756
- var refPosition = (_item$refPosition = item.refPosition) !== null && _item$refPosition !== void 0 ? _item$refPosition : -1;
7757
- expandableSlot[clamp(refPosition < 0 ? expandableSlot.length + refPosition : refPosition, 0, expandableSlot.length - 1)].push(...((_externalSlots$item$$ = externalSlots === null || externalSlots === void 0 ? void 0 : (_externalSlots$item$$2 = externalSlots[item.$$reversedRef]) === null || _externalSlots$item$$2 === void 0 ? void 0 : _externalSlots$item$$2.bricks) !== null && _externalSlots$item$$ !== void 0 ? _externalSlots$item$$ : []));
7758
- }
7759
- }
7760
- var _loop = function (slotName, _quasis) {
7761
- if (!hasOwnProperty(slots, slotName)) {
7762
- slots[slotName] = {
7763
- type: "bricks",
7764
- bricks: []
7765
- };
7766
- }
7767
- var slotConf = slots[slotName];
7768
- slotConf.bricks = _quasis.flatMap((bricks, index) => index < slotConf.bricks.length ? bricks.concat(slotConf.bricks[index]) : bricks);
7769
- if (slotConf.bricks.length === 0) {
7770
- delete slots[slotName];
7771
- }
7772
- };
7773
- for (var [slotName, _quasis] of quasisMap.entries()) {
7774
- _loop(slotName, _quasis);
7775
- }
7776
- }
7777
- return {
7778
- [symbolForComputedPropsFromProxy]: computedPropsFromProxy,
7779
- [symbolForRefForProxy]: refForProxy,
7780
- [symbolForTplContextId]: templateContextId
7781
- };
7782
- }
7783
-
7784
- var _excluded$4 = ["properties", "slots"];
7785
- function setupUseBrickInTemplate(props, proxyContext) {
7786
- function walk(props) {
7787
- if (!isObject(props)) {
7788
- return props;
7789
- }
7790
- if (Array.isArray(props)) {
7791
- return props.map(walk);
7792
- }
7793
- return Object.fromEntries(Object.entries(props).map(_ref => {
7794
- var [key, value] = _ref;
7795
- return isObject(value) && key === "useBrick" ? Array.isArray(value) ? [key, value.map(setup)] : [key, setup(value)] : [key, walk(value)];
7796
- }).concat(Object.getOwnPropertySymbols(props).map(k => [k, props[k]])));
7797
- }
7798
- function setup(item) {
7799
- var {
7800
- properties,
7801
- slots: originalSlots
7802
- } = item,
7803
- restConf = _objectWithoutProperties(item, _excluded$4);
7804
- var slots = Object.fromEntries(Object.entries(originalSlots !== null && originalSlots !== void 0 ? originalSlots : {}).map(_ref2 => {
7805
- var _slotConf$bricks;
7806
- var [slotName, slotConf] = _ref2;
7807
- return [slotName, {
7808
- type: "bricks",
7809
- bricks: ((_slotConf$bricks = slotConf.bricks) !== null && _slotConf$bricks !== void 0 ? _slotConf$bricks : []).map(setup)
7810
- }];
7811
- }));
7812
- return _objectSpread(_objectSpread({}, restConf), {}, {
7813
- properties: walk(properties),
7814
- slots
7815
- }, setupTemplateProxy(proxyContext, restConf.ref, slots));
7816
- }
7817
- return walk(props);
7818
- }
7819
-
7820
8086
  var _excluded$3 = ["properties", "slots"],
7821
8087
  _excluded2 = ["ref", "slots"];
7822
8088
  function expandCustomTemplate(brickConf, proxyBrick, context) {
@@ -8314,6 +8580,7 @@ class Kernel {
8314
8580
  pendingTask: Promise.resolve()
8315
8581
  };
8316
8582
  } else {
8583
+ var _eager$v3Bricks;
8317
8584
  // 先加载模板
8318
8585
  var templateDeps = getTemplateDepsOfStoryboard(storyboard, templatePackages);
8319
8586
  yield loadScriptOfBricksOrTemplates(templateDeps);
@@ -8322,6 +8589,8 @@ class Kernel {
8322
8589
  dll,
8323
8590
  deps,
8324
8591
  bricks,
8592
+ v3Bricks,
8593
+ v3Processors,
8325
8594
  eager
8326
8595
  } = getDllAndDepsOfStoryboard(yield asyncProcessStoryboard(storyboard, brickTemplateRegistry, templatePackages), brickPackages, {
8327
8596
  ignoreBricksInUnusedCustomTemplates: true
@@ -8329,10 +8598,15 @@ class Kernel {
8329
8598
  // 需要先阻塞加载 Custom Processors 和 widgets。
8330
8599
  yield loadScriptOfDll(eager.dll);
8331
8600
  yield loadScriptOfBricksOrTemplates(eager.deps);
8601
+ if ((_eager$v3Bricks = eager.v3Bricks) !== null && _eager$v3Bricks !== void 0 && _eager$v3Bricks.length) {
8602
+ yield loadBricksImperatively(eager.v3Bricks, brickPackages);
8603
+ }
8332
8604
  // 加载构件资源时,不再阻塞后续业务数据的加载,在挂载构件时再等待该任务完成。
8333
8605
  // 挂载构件可能包括:Provider 构件实时挂载、路由准备完成后的统一挂载等。
8334
8606
  return {
8335
- pendingTask: loadScriptOfDll(dll).then(() => loadScriptOfBricksOrTemplates(deps)).then(() => loadLazyBricks(bricks))
8607
+ pendingTask: loadScriptOfDll(dll).then(() => loadScriptOfBricksOrTemplates(deps)).then( /*#__PURE__*/_asyncToGenerator$3(function* () {
8608
+ yield Promise.all([loadLazyBricks(bricks), (v3Bricks === null || v3Bricks === void 0 ? void 0 : v3Bricks.length) && loadBricksImperatively(v3Bricks, brickPackages), (v3Processors === null || v3Processors === void 0 ? void 0 : v3Processors.length) && loadProcessorsImperatively(v3Processors, brickPackages)]);
8609
+ }))
8336
8610
  };
8337
8611
  }
8338
8612
  });
@@ -8341,28 +8615,33 @@ class Kernel {
8341
8615
  };
8342
8616
  }());
8343
8617
  _defineProperty$1(this, "_loadDynamicBricks", /*#__PURE__*/function () {
8344
- var _ref2 = _asyncToGenerator$3(function* (bricks, processors) {
8618
+ var _ref3 = _asyncToGenerator$3(function* (bricks, processors) {
8345
8619
  var filteredBricks = bricks.filter(
8346
8620
  // Only try to load undefined custom elements.
8347
8621
  item => !customElements.get(item));
8622
+ var {
8623
+ brickPackages
8624
+ } = _this.bootstrapData;
8348
8625
  // Try to load deps for dynamic added bricks.
8349
8626
  var {
8350
8627
  dll,
8351
- deps
8628
+ deps,
8629
+ v3Bricks,
8630
+ v3Processors
8352
8631
  } = getDllAndDepsByResource({
8353
8632
  bricks: filteredBricks,
8354
8633
  processors
8355
8634
  }, _this.bootstrapData.brickPackages);
8356
8635
  yield loadScriptOfDll(dll);
8357
8636
  yield loadScriptOfBricksOrTemplates(deps);
8358
- yield loadLazyBricks(filteredBricks);
8637
+ yield Promise.all([loadLazyBricks(filteredBricks), (v3Bricks === null || v3Bricks === void 0 ? void 0 : v3Bricks.length) && loadBricksImperatively(v3Bricks, brickPackages), (v3Processors === null || v3Processors === void 0 ? void 0 : v3Processors.length) && loadProcessorsImperatively(v3Processors, brickPackages)]);
8359
8638
  });
8360
8639
  return function (_x2, _x3) {
8361
- return _ref2.apply(this, arguments);
8640
+ return _ref3.apply(this, arguments);
8362
8641
  };
8363
8642
  }());
8364
8643
  _defineProperty$1(this, "_loadEditorBricks", /*#__PURE__*/function () {
8365
- var _ref3 = _asyncToGenerator$3(function* (editorBricks) {
8644
+ var _ref4 = _asyncToGenerator$3(function* (editorBricks) {
8366
8645
  var {
8367
8646
  dll,
8368
8647
  deps
@@ -8375,7 +8654,7 @@ class Kernel {
8375
8654
  yield loadScriptOfBricksOrTemplates(deps);
8376
8655
  });
8377
8656
  return function (_x4) {
8378
- return _ref3.apply(this, arguments);
8657
+ return _ref4.apply(this, arguments);
8379
8658
  };
8380
8659
  }());
8381
8660
  }
@@ -8559,8 +8838,8 @@ class Kernel {
8559
8838
  // Prefix to avoid conflict between brick package's i18n namespace.
8560
8839
  var i18nNamespace = getI18nNamespace("app", storyboard.app.id);
8561
8840
  // Support any language in `meta.i18n`.
8562
- Object.entries(storyboard.meta.i18n).forEach(_ref4 => {
8563
- var [lang, resources] = _ref4;
8841
+ Object.entries(storyboard.meta.i18n).forEach(_ref5 => {
8842
+ var [lang, resources] = _ref5;
8564
8843
  i18next.addResourceBundle(lang, i18nNamespace, resources);
8565
8844
  });
8566
8845
  }
@@ -8982,8 +9261,8 @@ class Kernel {
8982
9261
  });
8983
9262
  });
8984
9263
  if (!filterMenus.length) {
8985
- var _ref5, _yield$InstanceApi_po;
8986
- filterMenus = (_ref5 = (_yield$InstanceApi_po = yield InstanceApi_postSearch("STANDALONE_MENU@EASYOPS", {
9264
+ var _ref6, _yield$InstanceApi_po;
9265
+ filterMenus = (_ref6 = (_yield$InstanceApi_po = yield InstanceApi_postSearch("STANDALONE_MENU@EASYOPS", {
8987
9266
  page: 1,
8988
9267
  page_size: 200,
8989
9268
  fields: {
@@ -9012,7 +9291,7 @@ class Kernel {
9012
9291
  $eq: true
9013
9292
  }
9014
9293
  }
9015
- })) === null || _yield$InstanceApi_po === void 0 ? void 0 : _yield$InstanceApi_po.list) !== null && _ref5 !== void 0 ? _ref5 : [];
9294
+ })) === null || _yield$InstanceApi_po === void 0 ? void 0 : _yield$InstanceApi_po.list) !== null && _ref6 !== void 0 ? _ref6 : [];
9016
9295
  }
9017
9296
  return filterMenus;
9018
9297
  })();
@@ -9055,15 +9334,15 @@ function _loadScriptOfDll() {
9055
9334
  _loadScriptOfDll = _asyncToGenerator$3(function* (dlls) {
9056
9335
  if (dlls.some(dll => dll.startsWith("dll-of-editor-bricks-helper."))) {
9057
9336
  var dllPath = window.DLL_PATH || {};
9058
- yield loadScript(dllPath["react-dnd"], window.CORE_ROOT);
9337
+ yield loadScript$1(dllPath["react-dnd"], window.CORE_ROOT);
9059
9338
  }
9060
9339
  // `loadScript` is auto cached, no need to filter out `react-dnd`.
9061
- yield loadScript(dlls, window.CORE_ROOT);
9340
+ yield loadScript$1(dlls, window.CORE_ROOT);
9062
9341
  });
9063
9342
  return _loadScriptOfDll.apply(this, arguments);
9064
9343
  }
9065
9344
  function loadScriptOfBricksOrTemplates(src) {
9066
- return loadScript(src, window.PUBLIC_ROOT);
9345
+ return loadScript$1(src, window.PUBLIC_ROOT);
9067
9346
  }
9068
9347
  function generateColorTheme(theme) {
9069
9348
  if (!theme) {