@next-core/brick-kit 2.109.0 → 2.110.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/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
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.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)
7
+
8
+
9
+ ### Features
10
+
11
+ * support console in storyboard functions ([db24b0b](https://github.com/easyops-cn/next-core/commit/db24b0b1e6545a64974ab2ec1ffb1d8a2220d726))
12
+
13
+
14
+
15
+
16
+
6
17
  # [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
18
 
8
19
 
@@ -1510,6 +1510,39 @@
1510
1510
  permissionMap.clear();
1511
1511
  }
1512
1512
 
1513
+ var THROW = () => {
1514
+ throw new Error("Can't modify read-only proxy object");
1515
+ };
1516
+
1517
+ var readOnlyHandler = {
1518
+ set: THROW,
1519
+ defineProperty: THROW,
1520
+ deleteProperty: THROW,
1521
+ setPrototypeOf: THROW
1522
+ };
1523
+ function getReadOnlyProxy(object) {
1524
+ return new Proxy(object, readOnlyHandler);
1525
+ } // First, we want to make accessing property of globals lazy,
1526
+ // So we use *Proxy* to make a dynamic accessor for each of these globals.
1527
+ // But we also want to keep them working in devtools.
1528
+
1529
+ function getDynamicReadOnlyProxy(_ref) {
1530
+ var {
1531
+ get,
1532
+ ownKeys
1533
+ } = _ref;
1534
+
1535
+ if (getDevHook()) {
1536
+ // In devtools, we extract them at beginning.
1537
+ var target = Object.fromEntries(ownKeys(null).map(key => [key, get(null, key, null)]));
1538
+ return getReadOnlyProxy(target);
1539
+ }
1540
+
1541
+ return new Proxy(Object.freeze({}), {
1542
+ get
1543
+ });
1544
+ }
1545
+
1513
1546
  // `GeneralGlobals` are globals which are page-state-agnostic,
1514
1547
  // thus they can be used both in storyboard expressions and functions.
1515
1548
  function getGeneralGlobals(attemptToVisitGlobals, options) {
@@ -1531,7 +1564,8 @@
1531
1564
  collectCoverage,
1532
1565
  widgetId,
1533
1566
  app,
1534
- storyboardFunctions
1567
+ storyboardFunctions,
1568
+ isStoryboardFunction
1535
1569
  } = _ref;
1536
1570
 
1537
1571
  switch (variableName) {
@@ -1559,6 +1593,9 @@
1559
1593
  return {
1560
1594
  getTheme: collectCoverage ? () => "light" : getTheme
1561
1595
  };
1596
+
1597
+ case "console":
1598
+ return isStoryboardFunction ? getReadOnlyProxy(console) : undefined;
1562
1599
  }
1563
1600
  }
1564
1601
 
@@ -1645,7 +1682,8 @@
1645
1682
  collectCoverage,
1646
1683
  widgetId,
1647
1684
  app: currentApp,
1648
- storyboardFunctions
1685
+ storyboardFunctions,
1686
+ isStoryboardFunction: true
1649
1687
  })),
1650
1688
  hooks: collector && {
1651
1689
  beforeEvaluate: collector.beforeEvaluate,
@@ -1699,39 +1737,6 @@
1699
1737
  registerStoryboardFunctions(functions);
1700
1738
  }
1701
1739
 
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
1740
  /*! (c) Andrea Giammarchi - ISC */
1736
1741
  var self = {};
1737
1742