@next-core/brick-kit 2.110.0 → 2.111.2

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
@@ -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
 
@@ -1597,6 +1591,15 @@ function getIndividualGlobal(variableName, _ref) {
1597
1591
 
1598
1592
  case "console":
1599
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
+ };
1600
1603
  }
1601
1604
  }
1602
1605
 
@@ -2332,7 +2335,9 @@ function evaluate(raw) {
2332
2335
  return hash ? hash.substr(1) : null;
2333
2336
 
2334
2337
  case "APP":
2335
- return cloneDeep(app);
2338
+ return _objectSpread(_objectSpread({}, cloneDeep(app)), {}, {
2339
+ getMenu
2340
+ });
2336
2341
 
2337
2342
  case "CTX":
2338
2343
  return getDynamicReadOnlyProxy({
@@ -2689,7 +2694,19 @@ function _constructMenu() {
2689
2694
  return _constructMenu.apply(this, arguments);
2690
2695
  }
2691
2696
 
2692
- function fetchMenuById(_x4, _x5) {
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) {
2693
2710
  return _fetchMenuById.apply(this, arguments);
2694
2711
  }
2695
2712
 
@@ -2795,7 +2812,7 @@ function processGroupInject(items, menu, injectWithMenus) {
2795
2812
  });
2796
2813
  }
2797
2814
 
2798
- function loadDynamicMenuItems(_x6) {
2815
+ function loadDynamicMenuItems(_x9) {
2799
2816
  return _loadDynamicMenuItems.apply(this, arguments);
2800
2817
  }
2801
2818
 
@@ -2813,7 +2830,7 @@ function _loadDynamicMenuItems() {
2813
2830
  return _loadDynamicMenuItems.apply(this, arguments);
2814
2831
  }
2815
2832
 
2816
- function processMenu(_x7, _x8, _x9, _x10) {
2833
+ function processMenu(_x10, _x11, _x12, _x13) {
2817
2834
  return _processMenu.apply(this, arguments);
2818
2835
  }
2819
2836
 
@@ -2872,13 +2889,13 @@ function computeMenuItemsWithOverrideApp(items, context, kernel) {
2872
2889
  });
2873
2890
  });
2874
2891
 
2875
- return function (_x11) {
2892
+ return function (_x14) {
2876
2893
  return _ref2.apply(this, arguments);
2877
2894
  };
2878
2895
  }()));
2879
2896
  }
2880
2897
 
2881
- function processMenuTitle(_x12) {
2898
+ function processMenuTitle(_x15) {
2882
2899
  return _processMenuTitle.apply(this, arguments);
2883
2900
  }
2884
2901
 
@@ -2973,7 +2990,7 @@ function requireOverrideApp(data) {
2973
2990
  return false;
2974
2991
  }
2975
2992
 
2976
- function computeRealValueWithOverrideApp(_x13, _x14, _x15, _x16) {
2993
+ function computeRealValueWithOverrideApp(_x16, _x17, _x18, _x19) {
2977
2994
  return _computeRealValueWithOverrideApp.apply(this, arguments);
2978
2995
  }
2979
2996
 
@@ -8745,6 +8762,12 @@ class LocationContext {
8745
8762
  if (isRouteConfOfRoutes(route) && Array.isArray(route.routes)) {
8746
8763
  yield _this.mountRoutes(route.routes, slotId, mountRoutesResult);
8747
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
+
8748
8771
  yield _this.mountBricks(route.bricks, matched.match, slotId, mountRoutesResult); // analytics data (page_view event)
8749
8772
 
8750
8773
  if (route.analyticsData) {