@next-core/brick-kit 2.109.0 → 2.111.1
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/CHANGELOG.md +33 -0
- package/dist/index.bundle.js +76 -48
- package/dist/index.bundle.js.map +1 -1
- package/dist/index.esm.js +77 -49
- package/dist/index.esm.js.map +1 -1
- package/dist/types/core/LocationContext.d.ts.map +1 -1
- package/dist/types/core/StoryboardFunctionRegistryFactory.d.ts.map +1 -1
- package/dist/types/internal/evaluate.d.ts.map +1 -1
- package/dist/types/internal/getGeneralGlobals.d.ts +1 -0
- package/dist/types/internal/getGeneralGlobals.d.ts.map +1 -1
- package/dist/types/internal/menu.d.ts +2 -0
- package/dist/types/internal/menu.d.ts.map +1 -1
- package/package.json +4 -4
package/dist/index.esm.js
CHANGED
|
@@ -4,7 +4,7 @@ import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProper
|
|
|
4
4
|
import _asyncToGenerator$4 from '@babel/runtime/helpers/asyncToGenerator';
|
|
5
5
|
import _defineProperty$1 from '@babel/runtime/helpers/defineProperty';
|
|
6
6
|
import React, { useState, useEffect, useRef, forwardRef, useImperativeHandle, useMemo, useContext, createContext, useReducer, useCallback } from 'react';
|
|
7
|
-
import { JsonStorage, toPath, computeRealRoutePath, hasOwnProperty, isObject, isEvaluable, transformAndInject, transform, trackContext, trackState, scanPermissionActionsInStoryboard, precookFunction, cook, resolveContextConcurrently, syncResolveContextConcurrently, shouldAllowRecursiveEvaluations, preevaluate, inject, deepFreeze, createProviderClass, scanRouteAliasInStoryboard, loadScript, getTemplateDepsOfStoryboard, getDllAndDepsOfStoryboard, asyncProcessStoryboard, prefetchScript, scanBricksInBrickConf, scanProcessorsInAny, getDllAndDepsByResource, matchPath, asyncProcessBrick, restoreDynamicTemplates, mapCustomApisToNameAndNamespace, scanCustomApisInStoryboard } from '@next-core/brick-utils';
|
|
7
|
+
import { JsonStorage, toPath, computeRealRoutePath, hasOwnProperty, isObject, isEvaluable, transformAndInject, transform, trackContext, trackState, scanPermissionActionsInStoryboard, precookFunction, cook, resolveContextConcurrently, syncResolveContextConcurrently, shouldAllowRecursiveEvaluations, preevaluate, inject, deepFreeze, createProviderClass, scanRouteAliasInStoryboard, loadScript, getTemplateDepsOfStoryboard, getDllAndDepsOfStoryboard, asyncProcessStoryboard, prefetchScript, scanBricksInBrickConf, scanProcessorsInAny, getDllAndDepsByResource, matchPath, scanAppGetMenuInAny, asyncProcessBrick, restoreDynamicTemplates, mapCustomApisToNameAndNamespace, scanCustomApisInStoryboard } from '@next-core/brick-utils';
|
|
8
8
|
import lodash, { set, get, difference, identity, uniqueId, cloneDeep, isNil, sortBy, merge, orderBy, omit, clamp, isEmpty, noop, isObject as isObject$1, isString } from 'lodash';
|
|
9
9
|
import { http, HttpResponseError, HttpFetchError } from '@next-core/brick-http';
|
|
10
10
|
import moment from 'moment';
|
|
@@ -636,12 +636,6 @@ function supplyIndividual(variableName) {
|
|
|
636
636
|
case "PIPES":
|
|
637
637
|
return pipes;
|
|
638
638
|
|
|
639
|
-
case "location":
|
|
640
|
-
return {
|
|
641
|
-
href: location.href,
|
|
642
|
-
origin: location.origin
|
|
643
|
-
};
|
|
644
|
-
|
|
645
639
|
case "TAG_URL":
|
|
646
640
|
return tagUrlFactory(true);
|
|
647
641
|
|
|
@@ -1511,6 +1505,39 @@ function resetPermissionPreChecks() {
|
|
|
1511
1505
|
permissionMap.clear();
|
|
1512
1506
|
}
|
|
1513
1507
|
|
|
1508
|
+
var THROW = () => {
|
|
1509
|
+
throw new Error("Can't modify read-only proxy object");
|
|
1510
|
+
};
|
|
1511
|
+
|
|
1512
|
+
var readOnlyHandler = {
|
|
1513
|
+
set: THROW,
|
|
1514
|
+
defineProperty: THROW,
|
|
1515
|
+
deleteProperty: THROW,
|
|
1516
|
+
setPrototypeOf: THROW
|
|
1517
|
+
};
|
|
1518
|
+
function getReadOnlyProxy(object) {
|
|
1519
|
+
return new Proxy(object, readOnlyHandler);
|
|
1520
|
+
} // First, we want to make accessing property of globals lazy,
|
|
1521
|
+
// So we use *Proxy* to make a dynamic accessor for each of these globals.
|
|
1522
|
+
// But we also want to keep them working in devtools.
|
|
1523
|
+
|
|
1524
|
+
function getDynamicReadOnlyProxy(_ref) {
|
|
1525
|
+
var {
|
|
1526
|
+
get,
|
|
1527
|
+
ownKeys
|
|
1528
|
+
} = _ref;
|
|
1529
|
+
|
|
1530
|
+
if (getDevHook()) {
|
|
1531
|
+
// In devtools, we extract them at beginning.
|
|
1532
|
+
var target = Object.fromEntries(ownKeys(null).map(key => [key, get(null, key, null)]));
|
|
1533
|
+
return getReadOnlyProxy(target);
|
|
1534
|
+
}
|
|
1535
|
+
|
|
1536
|
+
return new Proxy(Object.freeze({}), {
|
|
1537
|
+
get
|
|
1538
|
+
});
|
|
1539
|
+
}
|
|
1540
|
+
|
|
1514
1541
|
// `GeneralGlobals` are globals which are page-state-agnostic,
|
|
1515
1542
|
// thus they can be used both in storyboard expressions and functions.
|
|
1516
1543
|
function getGeneralGlobals(attemptToVisitGlobals, options) {
|
|
@@ -1532,7 +1559,8 @@ function getIndividualGlobal(variableName, _ref) {
|
|
|
1532
1559
|
collectCoverage,
|
|
1533
1560
|
widgetId,
|
|
1534
1561
|
app,
|
|
1535
|
-
storyboardFunctions
|
|
1562
|
+
storyboardFunctions,
|
|
1563
|
+
isStoryboardFunction
|
|
1536
1564
|
} = _ref;
|
|
1537
1565
|
|
|
1538
1566
|
switch (variableName) {
|
|
@@ -1560,6 +1588,18 @@ function getIndividualGlobal(variableName, _ref) {
|
|
|
1560
1588
|
return {
|
|
1561
1589
|
getTheme: collectCoverage ? () => "light" : getTheme
|
|
1562
1590
|
};
|
|
1591
|
+
|
|
1592
|
+
case "console":
|
|
1593
|
+
return isStoryboardFunction ? getReadOnlyProxy(console) : undefined;
|
|
1594
|
+
|
|
1595
|
+
case "location":
|
|
1596
|
+
return collectCoverage ? {
|
|
1597
|
+
href: "http://localhost:3000/functions/test",
|
|
1598
|
+
origin: "http://localhost:3000"
|
|
1599
|
+
} : {
|
|
1600
|
+
href: location.href,
|
|
1601
|
+
origin: location.origin
|
|
1602
|
+
};
|
|
1563
1603
|
}
|
|
1564
1604
|
}
|
|
1565
1605
|
|
|
@@ -1646,7 +1686,8 @@ function StoryboardFunctionRegistryFactory() {
|
|
|
1646
1686
|
collectCoverage,
|
|
1647
1687
|
widgetId,
|
|
1648
1688
|
app: currentApp,
|
|
1649
|
-
storyboardFunctions
|
|
1689
|
+
storyboardFunctions,
|
|
1690
|
+
isStoryboardFunction: true
|
|
1650
1691
|
})),
|
|
1651
1692
|
hooks: collector && {
|
|
1652
1693
|
beforeEvaluate: collector.beforeEvaluate,
|
|
@@ -1700,39 +1741,6 @@ function registerWidgetFunctions(widgetId, functions) {
|
|
|
1700
1741
|
registerStoryboardFunctions(functions);
|
|
1701
1742
|
}
|
|
1702
1743
|
|
|
1703
|
-
var THROW = () => {
|
|
1704
|
-
throw new Error("Can't modify read-only proxy object");
|
|
1705
|
-
};
|
|
1706
|
-
|
|
1707
|
-
var readOnlyHandler = {
|
|
1708
|
-
set: THROW,
|
|
1709
|
-
defineProperty: THROW,
|
|
1710
|
-
deleteProperty: THROW,
|
|
1711
|
-
setPrototypeOf: THROW
|
|
1712
|
-
};
|
|
1713
|
-
function getReadOnlyProxy(object) {
|
|
1714
|
-
return new Proxy(object, readOnlyHandler);
|
|
1715
|
-
} // First, we want to make accessing property of globals lazy,
|
|
1716
|
-
// So we use *Proxy* to make a dynamic accessor for each of these globals.
|
|
1717
|
-
// But we also want to keep them working in devtools.
|
|
1718
|
-
|
|
1719
|
-
function getDynamicReadOnlyProxy(_ref) {
|
|
1720
|
-
var {
|
|
1721
|
-
get,
|
|
1722
|
-
ownKeys
|
|
1723
|
-
} = _ref;
|
|
1724
|
-
|
|
1725
|
-
if (getDevHook()) {
|
|
1726
|
-
// In devtools, we extract them at beginning.
|
|
1727
|
-
var target = Object.fromEntries(ownKeys(null).map(key => [key, get(null, key, null)]));
|
|
1728
|
-
return getReadOnlyProxy(target);
|
|
1729
|
-
}
|
|
1730
|
-
|
|
1731
|
-
return new Proxy(Object.freeze({}), {
|
|
1732
|
-
get
|
|
1733
|
-
});
|
|
1734
|
-
}
|
|
1735
|
-
|
|
1736
1744
|
/*! (c) Andrea Giammarchi - ISC */
|
|
1737
1745
|
var self = {};
|
|
1738
1746
|
|
|
@@ -2327,7 +2335,9 @@ function evaluate(raw) {
|
|
|
2327
2335
|
return hash ? hash.substr(1) : null;
|
|
2328
2336
|
|
|
2329
2337
|
case "APP":
|
|
2330
|
-
return cloneDeep(app)
|
|
2338
|
+
return _objectSpread(_objectSpread({}, cloneDeep(app)), {}, {
|
|
2339
|
+
getMenu
|
|
2340
|
+
});
|
|
2331
2341
|
|
|
2332
2342
|
case "CTX":
|
|
2333
2343
|
return getDynamicReadOnlyProxy({
|
|
@@ -2684,7 +2694,19 @@ function _constructMenu() {
|
|
|
2684
2694
|
return _constructMenu.apply(this, arguments);
|
|
2685
2695
|
}
|
|
2686
2696
|
|
|
2687
|
-
function
|
|
2697
|
+
function constructMenuByMenusList(_x4, _x5, _x6) {
|
|
2698
|
+
return _constructMenuByMenusList.apply(this, arguments);
|
|
2699
|
+
}
|
|
2700
|
+
|
|
2701
|
+
function _constructMenuByMenusList() {
|
|
2702
|
+
_constructMenuByMenusList = _asyncToGenerator$4(function* (menus, context, kernel) {
|
|
2703
|
+
yield Promise.all(menus.map(menuId => processMenu(menuId, context, kernel)));
|
|
2704
|
+
});
|
|
2705
|
+
return _constructMenuByMenusList.apply(this, arguments);
|
|
2706
|
+
}
|
|
2707
|
+
|
|
2708
|
+
var getMenu = menuId => menuCache.get(menuId);
|
|
2709
|
+
function fetchMenuById(_x7, _x8) {
|
|
2688
2710
|
return _fetchMenuById.apply(this, arguments);
|
|
2689
2711
|
}
|
|
2690
2712
|
|
|
@@ -2790,7 +2812,7 @@ function processGroupInject(items, menu, injectWithMenus) {
|
|
|
2790
2812
|
});
|
|
2791
2813
|
}
|
|
2792
2814
|
|
|
2793
|
-
function loadDynamicMenuItems(
|
|
2815
|
+
function loadDynamicMenuItems(_x9) {
|
|
2794
2816
|
return _loadDynamicMenuItems.apply(this, arguments);
|
|
2795
2817
|
}
|
|
2796
2818
|
|
|
@@ -2808,7 +2830,7 @@ function _loadDynamicMenuItems() {
|
|
|
2808
2830
|
return _loadDynamicMenuItems.apply(this, arguments);
|
|
2809
2831
|
}
|
|
2810
2832
|
|
|
2811
|
-
function processMenu(
|
|
2833
|
+
function processMenu(_x10, _x11, _x12, _x13) {
|
|
2812
2834
|
return _processMenu.apply(this, arguments);
|
|
2813
2835
|
}
|
|
2814
2836
|
|
|
@@ -2867,13 +2889,13 @@ function computeMenuItemsWithOverrideApp(items, context, kernel) {
|
|
|
2867
2889
|
});
|
|
2868
2890
|
});
|
|
2869
2891
|
|
|
2870
|
-
return function (
|
|
2892
|
+
return function (_x14) {
|
|
2871
2893
|
return _ref2.apply(this, arguments);
|
|
2872
2894
|
};
|
|
2873
2895
|
}()));
|
|
2874
2896
|
}
|
|
2875
2897
|
|
|
2876
|
-
function processMenuTitle(
|
|
2898
|
+
function processMenuTitle(_x15) {
|
|
2877
2899
|
return _processMenuTitle.apply(this, arguments);
|
|
2878
2900
|
}
|
|
2879
2901
|
|
|
@@ -2968,7 +2990,7 @@ function requireOverrideApp(data) {
|
|
|
2968
2990
|
return false;
|
|
2969
2991
|
}
|
|
2970
2992
|
|
|
2971
|
-
function computeRealValueWithOverrideApp(
|
|
2993
|
+
function computeRealValueWithOverrideApp(_x16, _x17, _x18, _x19) {
|
|
2972
2994
|
return _computeRealValueWithOverrideApp.apply(this, arguments);
|
|
2973
2995
|
}
|
|
2974
2996
|
|
|
@@ -8740,6 +8762,12 @@ class LocationContext {
|
|
|
8740
8762
|
if (isRouteConfOfRoutes(route) && Array.isArray(route.routes)) {
|
|
8741
8763
|
yield _this.mountRoutes(route.routes, slotId, mountRoutesResult);
|
|
8742
8764
|
} else if (isRouteConfOfBricks(route) && Array.isArray(route.bricks)) {
|
|
8765
|
+
var useMenus = scanAppGetMenuInAny(route);
|
|
8766
|
+
|
|
8767
|
+
if (useMenus.length) {
|
|
8768
|
+
yield constructMenuByMenusList(useMenus, _this.getCurrentContext(), _this.kernel);
|
|
8769
|
+
}
|
|
8770
|
+
|
|
8743
8771
|
yield _this.mountBricks(route.bricks, matched.match, slotId, mountRoutesResult); // analytics data (page_view event)
|
|
8744
8772
|
|
|
8745
8773
|
if (route.analyticsData) {
|