@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 CHANGED
@@ -3,6 +3,39 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [2.111.1](https://github.com/easyops-cn/next-core/compare/@next-core/brick-kit@2.111.0...@next-core/brick-kit@2.111.1) (2022-03-24)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * support mocked location in storyboard functions ([260e775](https://github.com/easyops-cn/next-core/commit/260e77567a61c7f3199a174171de2eead4007d06))
12
+
13
+
14
+
15
+
16
+
17
+ # [2.111.0](https://github.com/easyops-cn/next-core/compare/@next-core/brick-kit@2.110.0...@next-core/brick-kit@2.111.0) (2022-03-24)
18
+
19
+
20
+ ### Features
21
+
22
+ * support APP.getMenu ([#1651](https://github.com/easyops-cn/next-core/issues/1651)) ([5b9f53a](https://github.com/easyops-cn/next-core/commit/5b9f53a3367087a062f415dd68070f15b98bf966))
23
+
24
+
25
+
26
+
27
+
28
+ # [2.110.0](https://github.com/easyops-cn/next-core/compare/@next-core/brick-kit@2.109.0...@next-core/brick-kit@2.110.0) (2022-03-23)
29
+
30
+
31
+ ### Features
32
+
33
+ * support console in storyboard functions ([db24b0b](https://github.com/easyops-cn/next-core/commit/db24b0b1e6545a64974ab2ec1ffb1d8a2220d726))
34
+
35
+
36
+
37
+
38
+
6
39
  # [2.109.0](https://github.com/easyops-cn/next-core/compare/@next-core/brick-kit@2.108.0...@next-core/brick-kit@2.109.0) (2022-03-22)
7
40
 
8
41
 
@@ -635,12 +635,6 @@
635
635
  case "PIPES":
636
636
  return pipes.pipes;
637
637
 
638
- case "location":
639
- return {
640
- href: location.href,
641
- origin: location.origin
642
- };
643
-
644
638
  case "TAG_URL":
645
639
  return tagUrlFactory(true);
646
640
 
@@ -1510,6 +1504,39 @@
1510
1504
  permissionMap.clear();
1511
1505
  }
1512
1506
 
1507
+ var THROW = () => {
1508
+ throw new Error("Can't modify read-only proxy object");
1509
+ };
1510
+
1511
+ var readOnlyHandler = {
1512
+ set: THROW,
1513
+ defineProperty: THROW,
1514
+ deleteProperty: THROW,
1515
+ setPrototypeOf: THROW
1516
+ };
1517
+ function getReadOnlyProxy(object) {
1518
+ return new Proxy(object, readOnlyHandler);
1519
+ } // First, we want to make accessing property of globals lazy,
1520
+ // So we use *Proxy* to make a dynamic accessor for each of these globals.
1521
+ // But we also want to keep them working in devtools.
1522
+
1523
+ function getDynamicReadOnlyProxy(_ref) {
1524
+ var {
1525
+ get,
1526
+ ownKeys
1527
+ } = _ref;
1528
+
1529
+ if (getDevHook()) {
1530
+ // In devtools, we extract them at beginning.
1531
+ var target = Object.fromEntries(ownKeys(null).map(key => [key, get(null, key, null)]));
1532
+ return getReadOnlyProxy(target);
1533
+ }
1534
+
1535
+ return new Proxy(Object.freeze({}), {
1536
+ get
1537
+ });
1538
+ }
1539
+
1513
1540
  // `GeneralGlobals` are globals which are page-state-agnostic,
1514
1541
  // thus they can be used both in storyboard expressions and functions.
1515
1542
  function getGeneralGlobals(attemptToVisitGlobals, options) {
@@ -1531,7 +1558,8 @@
1531
1558
  collectCoverage,
1532
1559
  widgetId,
1533
1560
  app,
1534
- storyboardFunctions
1561
+ storyboardFunctions,
1562
+ isStoryboardFunction
1535
1563
  } = _ref;
1536
1564
 
1537
1565
  switch (variableName) {
@@ -1559,6 +1587,18 @@
1559
1587
  return {
1560
1588
  getTheme: collectCoverage ? () => "light" : getTheme
1561
1589
  };
1590
+
1591
+ case "console":
1592
+ return isStoryboardFunction ? getReadOnlyProxy(console) : undefined;
1593
+
1594
+ case "location":
1595
+ return collectCoverage ? {
1596
+ href: "http://localhost:3000/functions/test",
1597
+ origin: "http://localhost:3000"
1598
+ } : {
1599
+ href: location.href,
1600
+ origin: location.origin
1601
+ };
1562
1602
  }
1563
1603
  }
1564
1604
 
@@ -1645,7 +1685,8 @@
1645
1685
  collectCoverage,
1646
1686
  widgetId,
1647
1687
  app: currentApp,
1648
- storyboardFunctions
1688
+ storyboardFunctions,
1689
+ isStoryboardFunction: true
1649
1690
  })),
1650
1691
  hooks: collector && {
1651
1692
  beforeEvaluate: collector.beforeEvaluate,
@@ -1699,39 +1740,6 @@
1699
1740
  registerStoryboardFunctions(functions);
1700
1741
  }
1701
1742
 
1702
- var THROW = () => {
1703
- throw new Error("Can't modify read-only proxy object");
1704
- };
1705
-
1706
- var readOnlyHandler = {
1707
- set: THROW,
1708
- defineProperty: THROW,
1709
- deleteProperty: THROW,
1710
- setPrototypeOf: THROW
1711
- };
1712
- function getReadOnlyProxy(object) {
1713
- return new Proxy(object, readOnlyHandler);
1714
- } // First, we want to make accessing property of globals lazy,
1715
- // So we use *Proxy* to make a dynamic accessor for each of these globals.
1716
- // But we also want to keep them working in devtools.
1717
-
1718
- function getDynamicReadOnlyProxy(_ref) {
1719
- var {
1720
- get,
1721
- ownKeys
1722
- } = _ref;
1723
-
1724
- if (getDevHook()) {
1725
- // In devtools, we extract them at beginning.
1726
- var target = Object.fromEntries(ownKeys(null).map(key => [key, get(null, key, null)]));
1727
- return getReadOnlyProxy(target);
1728
- }
1729
-
1730
- return new Proxy(Object.freeze({}), {
1731
- get
1732
- });
1733
- }
1734
-
1735
1743
  /*! (c) Andrea Giammarchi - ISC */
1736
1744
  var self = {};
1737
1745
 
@@ -2326,7 +2334,9 @@
2326
2334
  return hash ? hash.substr(1) : null;
2327
2335
 
2328
2336
  case "APP":
2329
- return lodash.cloneDeep(app);
2337
+ return _objectSpread__default["default"](_objectSpread__default["default"]({}, lodash.cloneDeep(app)), {}, {
2338
+ getMenu
2339
+ });
2330
2340
 
2331
2341
  case "CTX":
2332
2342
  return getDynamicReadOnlyProxy({
@@ -2683,7 +2693,19 @@
2683
2693
  return _constructMenu.apply(this, arguments);
2684
2694
  }
2685
2695
 
2686
- function fetchMenuById(_x4, _x5) {
2696
+ function constructMenuByMenusList(_x4, _x5, _x6) {
2697
+ return _constructMenuByMenusList.apply(this, arguments);
2698
+ }
2699
+
2700
+ function _constructMenuByMenusList() {
2701
+ _constructMenuByMenusList = _asyncToGenerator__default["default"](function* (menus, context, kernel) {
2702
+ yield Promise.all(menus.map(menuId => processMenu(menuId, context, kernel)));
2703
+ });
2704
+ return _constructMenuByMenusList.apply(this, arguments);
2705
+ }
2706
+
2707
+ var getMenu = menuId => menuCache.get(menuId);
2708
+ function fetchMenuById(_x7, _x8) {
2687
2709
  return _fetchMenuById.apply(this, arguments);
2688
2710
  }
2689
2711
 
@@ -2789,7 +2811,7 @@
2789
2811
  });
2790
2812
  }
2791
2813
 
2792
- function loadDynamicMenuItems(_x6) {
2814
+ function loadDynamicMenuItems(_x9) {
2793
2815
  return _loadDynamicMenuItems.apply(this, arguments);
2794
2816
  }
2795
2817
 
@@ -2807,7 +2829,7 @@
2807
2829
  return _loadDynamicMenuItems.apply(this, arguments);
2808
2830
  }
2809
2831
 
2810
- function processMenu(_x7, _x8, _x9, _x10) {
2832
+ function processMenu(_x10, _x11, _x12, _x13) {
2811
2833
  return _processMenu.apply(this, arguments);
2812
2834
  }
2813
2835
 
@@ -2866,13 +2888,13 @@
2866
2888
  });
2867
2889
  });
2868
2890
 
2869
- return function (_x11) {
2891
+ return function (_x14) {
2870
2892
  return _ref2.apply(this, arguments);
2871
2893
  };
2872
2894
  }()));
2873
2895
  }
2874
2896
 
2875
- function processMenuTitle(_x12) {
2897
+ function processMenuTitle(_x15) {
2876
2898
  return _processMenuTitle.apply(this, arguments);
2877
2899
  }
2878
2900
 
@@ -2967,7 +2989,7 @@
2967
2989
  return false;
2968
2990
  }
2969
2991
 
2970
- function computeRealValueWithOverrideApp(_x13, _x14, _x15, _x16) {
2992
+ function computeRealValueWithOverrideApp(_x16, _x17, _x18, _x19) {
2971
2993
  return _computeRealValueWithOverrideApp.apply(this, arguments);
2972
2994
  }
2973
2995
 
@@ -8739,6 +8761,12 @@
8739
8761
  if (isRouteConfOfRoutes(route) && Array.isArray(route.routes)) {
8740
8762
  yield _this.mountRoutes(route.routes, slotId, mountRoutesResult);
8741
8763
  } else if (isRouteConfOfBricks(route) && Array.isArray(route.bricks)) {
8764
+ var useMenus = brickUtils.scanAppGetMenuInAny(route);
8765
+
8766
+ if (useMenus.length) {
8767
+ yield constructMenuByMenusList(useMenus, _this.getCurrentContext(), _this.kernel);
8768
+ }
8769
+
8742
8770
  yield _this.mountBricks(route.bricks, matched.match, slotId, mountRoutesResult); // analytics data (page_view event)
8743
8771
 
8744
8772
  if (route.analyticsData) {