@next-core/brick-kit 2.92.2 → 2.95.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.
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('history'), require('@babel/runtime/helpers/objectSpread2'), require('@babel/runtime/helpers/objectWithoutProperties'), require('@babel/runtime/helpers/asyncToGenerator'), require('@babel/runtime/helpers/defineProperty'), require('react'), require('lodash'), require('@next-core/brick-utils'), require('@next-core/brick-http'), require('i18next'), require('moment'), require('@next-core/pipes'), require('@next-core/easyops-analytics'), require('js-yaml'), require('antd'), require('@ant-design/icons'), require('react-i18next'), require('@babel/runtime/helpers/esm/extends'), require('@next-core/illustrations'), require('@babel/runtime/helpers/decorate')) :
3
- typeof define === 'function' && define.amd ? define(['exports', 'history', '@babel/runtime/helpers/objectSpread2', '@babel/runtime/helpers/objectWithoutProperties', '@babel/runtime/helpers/asyncToGenerator', '@babel/runtime/helpers/defineProperty', 'react', 'lodash', '@next-core/brick-utils', '@next-core/brick-http', 'i18next', 'moment', '@next-core/pipes', '@next-core/easyops-analytics', 'js-yaml', 'antd', '@ant-design/icons', 'react-i18next', '@babel/runtime/helpers/esm/extends', '@next-core/illustrations', '@babel/runtime/helpers/decorate'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.BrickKit = {}, global.history$1, global._objectSpread, global._objectWithoutProperties, global._asyncToGenerator$4, global._defineProperty$1, global.React, global.lodash, global.brickUtils, global.brickHttp, global.i18next, global.moment, global.pipes, global.easyopsAnalytics, global.yaml, global.antd, global.icons, global.reactI18next, global._extends, global.illustrations, global._decorate));
5
- })(this, (function (exports, history$1, _objectSpread, _objectWithoutProperties, _asyncToGenerator$4, _defineProperty$1, React, lodash, brickUtils, brickHttp, i18next, moment, pipes, easyopsAnalytics, yaml, antd, icons, reactI18next, _extends, illustrations, _decorate) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('history'), require('@babel/runtime/helpers/objectSpread2'), require('@babel/runtime/helpers/objectWithoutProperties'), require('@babel/runtime/helpers/asyncToGenerator'), require('@babel/runtime/helpers/defineProperty'), require('react'), require('lodash'), require('@next-core/brick-utils'), require('@next-core/brick-http'), require('moment'), require('@next-core/pipes'), require('i18next'), require('@next-core/easyops-analytics'), require('js-yaml'), require('antd'), require('@ant-design/icons'), require('react-i18next'), require('@babel/runtime/helpers/esm/extends'), require('@next-core/illustrations'), require('@babel/runtime/helpers/decorate')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'history', '@babel/runtime/helpers/objectSpread2', '@babel/runtime/helpers/objectWithoutProperties', '@babel/runtime/helpers/asyncToGenerator', '@babel/runtime/helpers/defineProperty', 'react', 'lodash', '@next-core/brick-utils', '@next-core/brick-http', 'moment', '@next-core/pipes', 'i18next', '@next-core/easyops-analytics', 'js-yaml', 'antd', '@ant-design/icons', 'react-i18next', '@babel/runtime/helpers/esm/extends', '@next-core/illustrations', '@babel/runtime/helpers/decorate'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.BrickKit = {}, global.history$1, global._objectSpread, global._objectWithoutProperties, global._asyncToGenerator$4, global._defineProperty$1, global.React, global.lodash, global.brickUtils, global.brickHttp, global.moment, global.pipes, global.i18next, global.easyopsAnalytics, global.yaml, global.antd, global.icons, global.reactI18next, global._extends, global.illustrations, global._decorate));
5
+ })(this, (function (exports, history$1, _objectSpread, _objectWithoutProperties, _asyncToGenerator$4, _defineProperty$1, React, lodash, brickUtils, brickHttp, moment, pipes, i18next, easyopsAnalytics, yaml, antd, icons, reactI18next, _extends, illustrations, _decorate) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
@@ -12,8 +12,8 @@
12
12
  var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty$1);
13
13
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
14
14
  var lodash__default = /*#__PURE__*/_interopDefaultLegacy(lodash);
15
- var i18next__default = /*#__PURE__*/_interopDefaultLegacy(i18next);
16
15
  var moment__default = /*#__PURE__*/_interopDefaultLegacy(moment);
16
+ var i18next__default = /*#__PURE__*/_interopDefaultLegacy(i18next);
17
17
  var yaml__default = /*#__PURE__*/_interopDefaultLegacy(yaml);
18
18
  var _extends__default = /*#__PURE__*/_interopDefaultLegacy(_extends);
19
19
  var _decorate__default = /*#__PURE__*/_interopDefaultLegacy(_decorate);
@@ -1158,7 +1158,6 @@
1158
1158
  }
1159
1159
  });
1160
1160
  }
1161
-
1162
1161
  function getDevHook() {
1163
1162
  return window.__BRICK_NEXT_DEVTOOLS_HOOK__;
1164
1163
  }
@@ -1169,6 +1168,90 @@
1169
1168
  return (_getDevHook$restoreDe = (_getDevHook2 = getDevHook()) === null || _getDevHook2 === void 0 ? void 0 : _getDevHook2.restoreDehydrated(value)) !== null && _getDevHook$restoreDe !== void 0 ? _getDevHook$restoreDe : value;
1170
1169
  }
1171
1170
 
1171
+ function getItemFactory(storageType) {
1172
+ return function (name) {
1173
+ var storage = storageType === "local" ? localStorage : sessionStorage;
1174
+ return JSON.parse(storage.getItem(name));
1175
+ };
1176
+ }
1177
+
1178
+ var locale$7 = {
1179
+ [K.REQUEST_FAILED]: "Request Failed",
1180
+ [K.MODAL_OK]: "Ok",
1181
+ [K.MODAL_CANCEL]: "Cancel",
1182
+ [K.SOMETHING_WENT_WRONG]: "Something went wrong!",
1183
+ [K.LOGIN_TIMEOUT_MESSAGE]: "You haven't logged in or your login session has expired. Login right now?",
1184
+ [K.NETWORK_ERROR]: "Network error, please check your network."
1185
+ };
1186
+ var en = locale$7;
1187
+
1188
+ var locale$6 = {
1189
+ [K.REQUEST_FAILED]: "请求失败",
1190
+ [K.MODAL_OK]: "确认",
1191
+ [K.MODAL_CANCEL]: "取消",
1192
+ [K.SOMETHING_WENT_WRONG]: "出现了一些问题!",
1193
+ [K.LOGIN_TIMEOUT_MESSAGE]: "您还未登录或登录信息已过期,现在重新登录?",
1194
+ [K.NETWORK_ERROR]: "网络错误,请检查您的网络连接。"
1195
+ };
1196
+ var zh = locale$6;
1197
+
1198
+ /** @internal */
1199
+
1200
+ var initI18n = () => {
1201
+ i18next__default["default"].addResourceBundle("en", NS_BRICK_KIT, en);
1202
+ i18next__default["default"].addResourceBundle("zh", NS_BRICK_KIT, zh);
1203
+ };
1204
+ /** @internal */
1205
+
1206
+ function getI18nNamespace(type, id) {
1207
+ return "$".concat(type, "-").concat(id);
1208
+ }
1209
+
1210
+ function registerWidgetI18n(widgetId, i18n) {
1211
+ var ns = getI18nNamespace("widget", widgetId);
1212
+ Object.entries(i18n).forEach(_ref => {
1213
+ var [lang, resources] = _ref;
1214
+ i18next__default["default"].addResourceBundle(lang, ns, resources);
1215
+ });
1216
+ }
1217
+ function widgetI18nFactory(widgetId) {
1218
+ return i18next.getFixedT(null, getI18nNamespace("widget", widgetId));
1219
+ }
1220
+
1221
+ function i18nText(data) {
1222
+ var _i18next$language;
1223
+
1224
+ if (!data) {
1225
+ return;
1226
+ }
1227
+
1228
+ var language = (_i18next$language = i18next__default["default"].language) !== null && _i18next$language !== void 0 ? _i18next$language : "zh-CN"; // First, make a perfect match.
1229
+
1230
+ if (brickUtils.hasOwnProperty(data, language)) {
1231
+ return data[language];
1232
+ } // https://en.wikipedia.org/wiki/IETF_language_tag
1233
+
1234
+
1235
+ var primaryLanguage = language.split("-")[0];
1236
+
1237
+ if (primaryLanguage !== language) {
1238
+ // Then, match the primary language (which omits other subtags).
1239
+ // E.g., match `zh` if the current language is `zh-CN`.
1240
+ return brickUtils.hasOwnProperty(data, primaryLanguage) ? data[primaryLanguage] : undefined;
1241
+ } // At last, match the first key which starts with the primary language,
1242
+ // if the current language contains primary subtag only.
1243
+ // E.g., match `zh-CN` if the current language is `zh`.
1244
+
1245
+
1246
+ var prefix = "".concat(primaryLanguage, "-");
1247
+
1248
+ for (var key of Object.keys(data)) {
1249
+ if (key.startsWith(prefix)) {
1250
+ return data[key];
1251
+ }
1252
+ }
1253
+ }
1254
+
1172
1255
  function asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, key, arg) {
1173
1256
  try {
1174
1257
  var info = gen[key](arg);
@@ -1381,88 +1464,68 @@
1381
1464
  permissionMap.clear();
1382
1465
  }
1383
1466
 
1384
- function getItemFactory(storageType) {
1385
- return function (name) {
1386
- var storage = storageType === "local" ? localStorage : sessionStorage;
1387
- return JSON.parse(storage.getItem(name));
1388
- };
1389
- }
1467
+ // `GeneralGlobals` are globals which are page-state-agnostic,
1468
+ // thus they can be used both in storyboard expressions and functions.
1469
+ function getGeneralGlobals(attemptToVisitGlobals, options) {
1470
+ var globalVariables = {};
1390
1471
 
1391
- function i18nText(data) {
1392
- var _i18next$language;
1472
+ for (var variableName of attemptToVisitGlobals) {
1473
+ var variable = getIndividualGlobal(variableName, options);
1393
1474
 
1394
- if (!data) {
1395
- return;
1475
+ if (variable !== undefined) {
1476
+ globalVariables[variableName] = variable;
1477
+ }
1396
1478
  }
1397
1479
 
1398
- var language = (_i18next$language = i18next__default["default"].language) !== null && _i18next$language !== void 0 ? _i18next$language : "zh-CN"; // First, make a perfect match.
1480
+ return globalVariables;
1481
+ }
1399
1482
 
1400
- if (brickUtils.hasOwnProperty(data, language)) {
1401
- return data[language];
1402
- } // https://en.wikipedia.org/wiki/IETF_language_tag
1483
+ function getIndividualGlobal(variableName, _ref) {
1484
+ var {
1485
+ collectCoverage,
1486
+ widgetId,
1487
+ app,
1488
+ storyboardFunctions
1489
+ } = _ref;
1403
1490
 
1491
+ switch (variableName) {
1492
+ case "BASE_URL":
1493
+ return collectCoverage ? "/next" : getBasePath().replace(/\/$/, "");
1404
1494
 
1405
- var primaryLanguage = language.split("-")[0];
1495
+ case "FN":
1496
+ return storyboardFunctions;
1406
1497
 
1407
- if (primaryLanguage !== language) {
1408
- // Then, match the primary language (which omits other subtags).
1409
- // E.g., match `zh` if the current language is `zh-CN`.
1410
- return brickUtils.hasOwnProperty(data, primaryLanguage) ? data[primaryLanguage] : undefined;
1411
- } // At last, match the first key which starts with the primary language,
1412
- // if the current language contains primary subtag only.
1413
- // E.g., match `zh-CN` if the current language is `zh`.
1498
+ case "IMG":
1499
+ return collectCoverage ? fakeImageFactory() : widgetId ? widgetImagesFactory(widgetId) : imagesFactory(app.id, app.isBuildPush);
1414
1500
 
1501
+ case "I18N":
1502
+ return collectCoverage ? lodash.identity : widgetId ? widgetI18nFactory(widgetId) : i18next.getFixedT(null, getI18nNamespace("app", app.id));
1415
1503
 
1416
- var prefix = "".concat(primaryLanguage, "-");
1504
+ case "I18N_TEXT":
1505
+ return collectCoverage ? fakeI18nText : i18nText;
1417
1506
 
1418
- for (var key of Object.keys(data)) {
1419
- if (key.startsWith(prefix)) {
1420
- return data[key];
1421
- }
1507
+ case "PERMISSIONS":
1508
+ return {
1509
+ check: collectCoverage ? fakeCheckPermissions : checkPermissions
1510
+ };
1422
1511
  }
1423
1512
  }
1424
1513
 
1425
- var locale$7 = {
1426
- [K.REQUEST_FAILED]: "Request Failed",
1427
- [K.MODAL_OK]: "Ok",
1428
- [K.MODAL_CANCEL]: "Cancel",
1429
- [K.SOMETHING_WENT_WRONG]: "Something went wrong!",
1430
- [K.LOGIN_TIMEOUT_MESSAGE]: "You haven't logged in or your login session has expired. Login right now?",
1431
- [K.NETWORK_ERROR]: "Network error, please check your network."
1432
- };
1433
- var en = locale$7;
1434
-
1435
- var locale$6 = {
1436
- [K.REQUEST_FAILED]: "请求失败",
1437
- [K.MODAL_OK]: "确认",
1438
- [K.MODAL_CANCEL]: "取消",
1439
- [K.SOMETHING_WENT_WRONG]: "出现了一些问题!",
1440
- [K.LOGIN_TIMEOUT_MESSAGE]: "您还未登录或登录信息已过期,现在重新登录?",
1441
- [K.NETWORK_ERROR]: "网络错误,请检查您的网络连接。"
1442
- };
1443
- var zh = locale$6;
1444
-
1445
- /** @internal */
1514
+ function fakeI18nText(data) {
1515
+ return data === null || data === void 0 ? void 0 : data.en;
1516
+ }
1446
1517
 
1447
- var initI18n = () => {
1448
- i18next__default["default"].addResourceBundle("en", NS_BRICK_KIT, en);
1449
- i18next__default["default"].addResourceBundle("zh", NS_BRICK_KIT, zh);
1450
- };
1451
- /** @internal */
1518
+ function fakeImageFactory() {
1519
+ return {
1520
+ get(name) {
1521
+ return "mock/images/".concat(name);
1522
+ }
1452
1523
 
1453
- function getI18nNamespace(type, id) {
1454
- return "$".concat(type, "-").concat(id);
1524
+ };
1455
1525
  }
1456
1526
 
1457
- function registerWidgetI18n(widgetId, i18n) {
1458
- var ns = getI18nNamespace("widget", widgetId);
1459
- Object.entries(i18n).forEach(_ref => {
1460
- var [lang, resources] = _ref;
1461
- i18next__default["default"].addResourceBundle(lang, ns, resources);
1462
- });
1463
- }
1464
- function widgetI18nFactory(widgetId) {
1465
- return i18next.getFixedT(null, getI18nNamespace("widget", widgetId));
1527
+ function fakeCheckPermissions() {
1528
+ return true;
1466
1529
  }
1467
1530
 
1468
1531
  /** @internal */
@@ -1481,29 +1544,11 @@
1481
1544
  }
1482
1545
 
1483
1546
  });
1484
-
1485
- var builtinSupply = _objectSpread__default["default"]({
1486
- // Functions can call other functions.
1487
- FN: storyboardFunctions
1488
- }, collectCoverage ? {
1489
- // Fake builtin methods for tests.
1490
- I18N: lodash.identity,
1491
- I18N_TEXT: fakeI18nText,
1492
- IMG: fakeImageFactory()
1493
- } : widgetId ? {
1494
- I18N: widgetI18nFactory(widgetId),
1495
- I18N_TEXT: i18nText,
1496
- IMG: widgetImagesFactory(widgetId)
1497
- } : {
1498
- I18N_TEXT: i18nText
1499
- });
1547
+ var currentApp;
1500
1548
 
1501
1549
  function registerStoryboardFunctions(functions, app) {
1502
1550
  if (app) {
1503
- Object.assign(builtinSupply, {
1504
- I18N: i18next.getFixedT(null, getI18nNamespace("app", app.id)),
1505
- IMG: imagesFactory(app.id, app.isBuildPush)
1506
- });
1551
+ currentApp = app;
1507
1552
  }
1508
1553
 
1509
1554
  registeredFunctions.clear();
@@ -1545,7 +1590,12 @@
1545
1590
  rules: {
1546
1591
  noVar: true
1547
1592
  },
1548
- globalVariables: supply(precooked.attemptToVisitGlobals, builtinSupply),
1593
+ globalVariables: supply(precooked.attemptToVisitGlobals, getGeneralGlobals(precooked.attemptToVisitGlobals, {
1594
+ collectCoverage,
1595
+ widgetId,
1596
+ app: currentApp,
1597
+ storyboardFunctions
1598
+ })),
1549
1599
  hooks: collector && {
1550
1600
  beforeEvaluate: collector.beforeEvaluate,
1551
1601
  beforeCall: collector.beforeCall,
@@ -1570,19 +1620,6 @@
1570
1620
  };
1571
1621
  }
1572
1622
 
1573
- function fakeI18nText(data) {
1574
- return data === null || data === void 0 ? void 0 : data.en;
1575
- }
1576
-
1577
- function fakeImageFactory() {
1578
- return {
1579
- get(name) {
1580
- return "mock/images/".concat(name);
1581
- }
1582
-
1583
- };
1584
- }
1585
-
1586
1623
  var {
1587
1624
  storyboardFunctions,
1588
1625
  registerStoryboardFunctions
@@ -1611,6 +1648,39 @@
1611
1648
  registerStoryboardFunctions(functions);
1612
1649
  }
1613
1650
 
1651
+ var THROW = () => {
1652
+ throw new Error("Can't modify read-only proxy object");
1653
+ };
1654
+
1655
+ var readOnlyHandler = {
1656
+ set: THROW,
1657
+ defineProperty: THROW,
1658
+ deleteProperty: THROW,
1659
+ setPrototypeOf: THROW
1660
+ };
1661
+ function getReadOnlyProxy(object) {
1662
+ return new Proxy(object, readOnlyHandler);
1663
+ } // First, we want to make accessing property of globals lazy,
1664
+ // So we use *Proxy* to make a dynamic accessor for each of these globals.
1665
+ // But we also want to keep them working in devtools.
1666
+
1667
+ function getDynamicReadOnlyProxy(_ref) {
1668
+ var {
1669
+ get,
1670
+ ownKeys
1671
+ } = _ref;
1672
+
1673
+ if (getDevHook()) {
1674
+ // In devtools, we extract them at beginning.
1675
+ var target = Object.fromEntries(ownKeys(null).map(key => [key, get(null, key, null)]));
1676
+ return getReadOnlyProxy(target);
1677
+ }
1678
+
1679
+ return new Proxy(Object.freeze({}), {
1680
+ get
1681
+ });
1682
+ }
1683
+
1614
1684
  var symbolForRaw = Symbol.for("pre.evaluated.raw");
1615
1685
  var symbolForContext = Symbol.for("pre.evaluated.context");
1616
1686
  function isPreEvaluated(raw) {
@@ -1728,126 +1798,142 @@
1728
1798
 
1729
1799
  var app = (_runtimeContext$overr = runtimeContext.overrideApp) !== null && _runtimeContext$overr !== void 0 ? _runtimeContext$overr : currentApp;
1730
1800
 
1731
- if (attemptToVisitGlobals.has("QUERY")) {
1732
- globalVariables.QUERY = Object.fromEntries(Array.from(query.keys()).map(key => [key, query.get(key)]));
1733
- }
1801
+ function getIndividualGlobal(variableName) {
1802
+ switch (variableName) {
1803
+ case "ALIAS":
1804
+ return {
1805
+ getUrl: getUrlByAliasFactory(app)
1806
+ };
1734
1807
 
1735
- if (attemptToVisitGlobals.has("QUERY_ARRAY")) {
1736
- globalVariables.QUERY_ARRAY = Object.fromEntries(Array.from(query.keys()).map(key => [key, query.getAll(key)]));
1737
- }
1808
+ case "ANCHOR":
1809
+ return hash ? hash.substr(1) : null;
1738
1810
 
1739
- if (attemptToVisitGlobals.has("PARAMS")) {
1740
- globalVariables.PARAMS = new URLSearchParams(query);
1741
- }
1811
+ case "APP":
1812
+ return lodash.cloneDeep(app);
1742
1813
 
1743
- if (attemptToVisitGlobals.has("APP")) {
1744
- globalVariables.APP = lodash.cloneDeep(app);
1745
- }
1814
+ case "CTX":
1815
+ return getDynamicReadOnlyProxy({
1816
+ get(target, key) {
1817
+ var _item$brick$element;
1746
1818
 
1747
- if (attemptToVisitGlobals.has("PATH")) {
1748
- globalVariables.PATH = lodash.cloneDeep(match.params);
1749
- }
1819
+ var item = storyboardContext.get(key);
1820
+ return !item ? item : item.type === "brick-property" ? (_item$brick$element = item.brick.element) === null || _item$brick$element === void 0 ? void 0 : _item$brick$element[item.prop] : item.value;
1821
+ },
1750
1822
 
1751
- if (attemptToVisitGlobals.has("SYS")) {
1752
- globalVariables.SYS = lodash.cloneDeep(sys);
1753
- }
1823
+ ownKeys() {
1824
+ return Array.from(storyboardContext.keys());
1825
+ }
1754
1826
 
1755
- if (attemptToVisitGlobals.has("FLAGS")) {
1756
- globalVariables.FLAGS = lodash.cloneDeep(flags);
1757
- }
1827
+ });
1758
1828
 
1759
- if (attemptToVisitGlobals.has("HASH")) {
1760
- globalVariables.HASH = hash;
1761
- }
1829
+ case "FLAGS":
1830
+ return getReadOnlyProxy(flags);
1762
1831
 
1763
- if (attemptToVisitGlobals.has("ANCHOR")) {
1764
- globalVariables.ANCHOR = hash ? hash.substr(1) : null;
1765
- }
1832
+ case "HASH":
1833
+ return hash;
1766
1834
 
1767
- if (attemptToVisitGlobals.has("SEGUE")) {
1768
- globalVariables.SEGUE = {
1769
- getUrl: getUrlBySegueFactory(app, segues)
1770
- };
1771
- }
1835
+ case "INSTALLED_APPS":
1836
+ return {
1837
+ has: (appId, matchVersion) => getRuntime().hasInstalledApp(appId, matchVersion)
1838
+ };
1772
1839
 
1773
- if (attemptToVisitGlobals.has("ALIAS")) {
1774
- globalVariables.ALIAS = {
1775
- getUrl: getUrlByAliasFactory(app)
1776
- };
1777
- }
1840
+ case "LOCAL_STORAGE":
1841
+ return {
1842
+ getItem: getItemFactory("local")
1843
+ };
1778
1844
 
1779
- if (attemptToVisitGlobals.has("IMG")) {
1780
- globalVariables.IMG = imagesFactory(app.id, app.isBuildPush);
1781
- }
1845
+ case "MISC":
1846
+ return getRuntime().getMiscSettings();
1782
1847
 
1783
- if (attemptToVisitGlobals.has("__WIDGET_IMG__")) {
1784
- globalVariables.__WIDGET_IMG__ = widgetImagesFactory;
1785
- }
1848
+ case "PARAMS":
1849
+ return new URLSearchParams(query);
1786
1850
 
1787
- if (attemptToVisitGlobals.has("I18N")) {
1788
- globalVariables.I18N = i18next__default["default"].getFixedT(null, getI18nNamespace("app", app.id));
1789
- }
1851
+ case "PATH":
1852
+ return getReadOnlyProxy(match.params);
1790
1853
 
1791
- if (attemptToVisitGlobals.has("__WIDGET_I18N__")) {
1792
- globalVariables.__WIDGET_I18N__ = widgetI18nFactory;
1793
- }
1854
+ case "PROCESSORS":
1855
+ return getDynamicReadOnlyProxy({
1856
+ get(target, key) {
1857
+ var pkg = customProcessorRegistry.get(key);
1858
+ return pkg ? getDynamicReadOnlyProxy({
1859
+ get(t, k) {
1860
+ return pkg.get(k);
1861
+ },
1794
1862
 
1795
- if (attemptToVisitGlobals.has("I18N_TEXT")) {
1796
- globalVariables.I18N_TEXT = i18nText;
1797
- }
1863
+ ownKeys() {
1864
+ return Array.from(pkg.keys());
1865
+ }
1798
1866
 
1799
- if (attemptToVisitGlobals.has("CTX")) {
1800
- globalVariables.CTX = Object.fromEntries(Array.from(storyboardContext.entries()).map(_ref => {
1801
- var _item$brick$element;
1867
+ }) : pkg;
1868
+ },
1802
1869
 
1803
- var [name, item] = _ref;
1804
- return [name, item.type === "brick-property" ? (_item$brick$element = item.brick.element) === null || _item$brick$element === void 0 ? void 0 : _item$brick$element[item.prop] : item.value];
1805
- }));
1806
- }
1870
+ ownKeys() {
1871
+ return Array.from(customProcessorRegistry.keys());
1872
+ }
1807
1873
 
1808
- if (attemptToVisitGlobals.has("PROCESSORS")) {
1809
- globalVariables.PROCESSORS = Object.fromEntries(Array.from(customProcessorRegistry.entries()).map(_ref2 => {
1810
- var [namespace, registry] = _ref2;
1811
- return [namespace, Object.fromEntries(registry.entries())];
1812
- }));
1813
- }
1874
+ });
1814
1875
 
1815
- if (attemptToVisitGlobals.has("PERMISSIONS")) {
1816
- globalVariables.PERMISSIONS = {
1817
- check: checkPermissions
1818
- };
1819
- }
1876
+ case "QUERY":
1877
+ return getDynamicReadOnlyProxy({
1878
+ get(target, key) {
1879
+ return query.get(key);
1880
+ },
1820
1881
 
1821
- if (attemptToVisitGlobals.has("LOCAL_STORAGE")) {
1822
- globalVariables.LOCAL_STORAGE = {
1823
- getItem: getItemFactory("local")
1824
- };
1825
- }
1882
+ ownKeys() {
1883
+ return Array.from(query.keys());
1884
+ }
1826
1885
 
1827
- if (attemptToVisitGlobals.has("SESSION_STORAGE")) {
1828
- globalVariables.SESSION_STORAGE = {
1829
- getItem: getItemFactory("session")
1830
- };
1831
- }
1886
+ });
1832
1887
 
1833
- if (attemptToVisitGlobals.has("INSTALLED_APPS")) {
1834
- globalVariables.INSTALLED_APPS = {
1835
- has: (appId, matchVersion) => getRuntime().hasInstalledApp(appId, matchVersion)
1836
- };
1837
- }
1888
+ case "QUERY_ARRAY":
1889
+ return getDynamicReadOnlyProxy({
1890
+ get(target, key) {
1891
+ return query.getAll(key);
1892
+ },
1838
1893
 
1839
- if (attemptToVisitGlobals.has("FN")) {
1840
- globalVariables.FN = storyboardFunctions;
1841
- }
1894
+ ownKeys() {
1895
+ return Array.from(query.keys());
1896
+ }
1897
+
1898
+ });
1899
+
1900
+ case "SEGUE":
1901
+ return {
1902
+ getUrl: getUrlBySegueFactory(app, segues)
1903
+ };
1904
+
1905
+ case "SESSION_STORAGE":
1906
+ return {
1907
+ getItem: getItemFactory("session")
1908
+ };
1909
+
1910
+ case "SYS":
1911
+ return getReadOnlyProxy(sys);
1842
1912
 
1843
- if (attemptToVisitGlobals.has("__WIDGET_FN__")) {
1844
- globalVariables.__WIDGET_FN__ = widgetFunctions;
1913
+ case "__WIDGET_FN__":
1914
+ return widgetFunctions;
1915
+
1916
+ case "__WIDGET_IMG__":
1917
+ return widgetImagesFactory;
1918
+
1919
+ case "__WIDGET_I18N__":
1920
+ return widgetI18nFactory;
1921
+ }
1845
1922
  }
1846
1923
 
1847
- if (attemptToVisitGlobals.has("MISC")) {
1848
- globalVariables.MISC = getRuntime().getMiscSettings();
1924
+ for (var variableName of attemptToVisitGlobals) {
1925
+ var variable = getIndividualGlobal(variableName);
1926
+
1927
+ if (variable !== undefined) {
1928
+ globalVariables[variableName] = variable;
1929
+ }
1849
1930
  }
1850
1931
 
1932
+ Object.assign(globalVariables, getGeneralGlobals(precooked.attemptToVisitGlobals, {
1933
+ storyboardFunctions,
1934
+ app
1935
+ }));
1936
+
1851
1937
  try {
1852
1938
  var result = brickUtils.cook(precooked.expression, precooked.source, {
1853
1939
  globalVariables: supply(precooked.attemptToVisitGlobals, globalVariables)
@@ -6096,14 +6182,6 @@
6096
6182
 
6097
6183
  _defineProperty__default["default"](this, "loadingBar", void 0);
6098
6184
 
6099
- _defineProperty__default["default"](this, "navBar", void 0);
6100
-
6101
- _defineProperty__default["default"](this, "sideBar", void 0);
6102
-
6103
- _defineProperty__default["default"](this, "footer", void 0);
6104
-
6105
- _defineProperty__default["default"](this, "breadcrumb", void 0);
6106
-
6107
6185
  _defineProperty__default["default"](this, "router", void 0);
6108
6186
 
6109
6187
  _defineProperty__default["default"](this, "currentApp", void 0);
@@ -6120,8 +6198,6 @@
6120
6198
 
6121
6199
  _defineProperty__default["default"](this, "currentLayout", void 0);
6122
6200
 
6123
- _defineProperty__default["default"](this, "enableUiV8", false);
6124
-
6125
6201
  _defineProperty__default["default"](this, "allUserMapPromise", Promise.resolve(new Map()));
6126
6202
 
6127
6203
  _defineProperty__default["default"](this, "allMagicBrickConfigMapPromise", Promise.resolve(new Map()));
@@ -6148,20 +6224,13 @@
6148
6224
  throw new Error("No storyboard were found.");
6149
6225
  }
6150
6226
 
6151
- _this.setUiVersion();
6152
-
6153
6227
  if (isLoggedIn()) {
6154
6228
  _this.loadSharedData();
6155
6229
  }
6156
6230
 
6157
6231
  _this.menuBar = new MenuBar(_this, "menuBar");
6158
6232
  _this.appBar = new AppBar(_this, "appBar");
6159
- _this.loadingBar = new BaseBar(_this, "loadingBar"); // Todo(nlicro): 这里需要新写对应的NavBar...
6160
-
6161
- _this.navBar = new BaseBar(_this, "navBar");
6162
- _this.sideBar = new BaseBar(_this, "sideBar");
6163
- _this.breadcrumb = new BaseBar(_this, "breadcrumb");
6164
- _this.footer = new BaseBar(_this, "footer");
6233
+ _this.loadingBar = new BaseBar(_this, "loadingBar");
6165
6234
  _this.router = new Router(_this);
6166
6235
  initAnalytics();
6167
6236
  yield _this.router.bootstrap();
@@ -6189,13 +6258,7 @@
6189
6258
  loadingBar: "business-website.loading-bar",
6190
6259
  pageNotFound: "business-website.page-not-found",
6191
6260
  pageError: "business-website.page-error"
6192
- } : _objectSpread__default["default"](_objectSpread__default["default"]({}, _this2.enableUiV8 ? {
6193
- loadingBar: _this2.bootstrapData.navbar.loadingBar,
6194
- navBar: "frame-bricks.nav-bar",
6195
- sideBar: "frame-bricks.side-bar",
6196
- breadcrumb: null,
6197
- footer: null
6198
- } : _this2.bootstrapData.navbar), {}, {
6261
+ } : _objectSpread__default["default"](_objectSpread__default["default"]({}, _this2.bootstrapData.navbar), {}, {
6199
6262
  pageNotFound: "basic-bricks.page-not-found",
6200
6263
  pageError: "basic-bricks.page-error"
6201
6264
  });
@@ -6210,7 +6273,7 @@
6210
6273
 
6211
6274
  yield Promise.all([_this2.menuBar.bootstrap(_this2.presetBricks.menuBar, {
6212
6275
  testid: "brick-next-menu-bar"
6213
- }), _this2.appBar.bootstrap(_this2.presetBricks.appBar), _this2.navBar.bootstrap(_this2.presetBricks.navBar), _this2.sideBar.bootstrap(_this2.presetBricks.sideBar), _this2.footer.bootstrap(_this2.presetBricks.footer), _this2.breadcrumb.bootstrap(_this2.presetBricks.breadcrumb), _this2.loadingBar.bootstrap(_this2.presetBricks.loadingBar)]);
6276
+ }), _this2.appBar.bootstrap(_this2.presetBricks.appBar), _this2.loadingBar.bootstrap(_this2.presetBricks.loadingBar)]);
6214
6277
  })();
6215
6278
  }
6216
6279
 
@@ -6762,16 +6825,6 @@
6762
6825
  })();
6763
6826
  }
6764
6827
 
6765
- setUiVersion() {
6766
- // get from localStorage fot test
6767
- // this.enableUiV8 = this.getFeatureFlags()["ui-v8"];
6768
- this.enableUiV8 = !!localStorage.getItem("test-ui-v8");
6769
-
6770
- if (this.enableUiV8) {
6771
- document.documentElement.dataset.ui = "v8";
6772
- }
6773
- }
6774
-
6775
6828
  } // Since `@next-dll/editor-bricks-helper` depends on `@next-dll/react-dnd`,
6776
6829
  // always load react-dnd before loading editor-bricks-helper.
6777
6830
 
@@ -6976,8 +7029,6 @@
6976
7029
 
6977
7030
  /** @internal */
6978
7031
 
6979
- /** @internal */
6980
-
6981
7032
  /**
6982
7033
  * 应用的 Storyboard 配置。
6983
7034
  */
@@ -9103,6 +9154,23 @@
9103
9154
  return defaultCollapsed || defaultCollapsedBreakpoint && document.documentElement.clientWidth < defaultCollapsedBreakpoint;
9104
9155
  }
9105
9156
 
9157
+ var useMockList = [];
9158
+ function registerMock(mockList) {
9159
+ if (mockList) useMockList = mockList;
9160
+ }
9161
+
9162
+ function getUrlRegExp(str) {
9163
+ return new RegExp("".concat(str.replace(/:\w+/g, "[\\w|-]+"), "$"));
9164
+ }
9165
+
9166
+ var isMatchMockUrl = (requestUrl, uri) => {
9167
+ var reg = getUrlRegExp(uri);
9168
+ return reg.test(requestUrl);
9169
+ };
9170
+ var getMockRule = requestUrl => {
9171
+ return useMockList.find(item => isMatchMockUrl(requestUrl, item.uri));
9172
+ };
9173
+
9106
9174
  class Router {
9107
9175
  constructor(kernel) {
9108
9176
  _defineProperty__default["default"](this, "defaultCollapsed", false);
@@ -9288,7 +9356,7 @@
9288
9356
  var storyboard = locationContext.matchStoryboard(_this3.kernel.bootstrapData.storyboards);
9289
9357
 
9290
9358
  if (storyboard) {
9291
- var _storyboard$meta;
9359
+ var _storyboard$meta, _storyboard$meta2;
9292
9360
 
9293
9361
  yield _this3.kernel.fulfilStoryboard(storyboard); // 将动态解析后的模板还原,以便重新动态解析。
9294
9362
 
@@ -9306,6 +9374,7 @@
9306
9374
  _this3.kernel.registerCustomTemplatesInStoryboard(storyboard);
9307
9375
 
9308
9376
  registerStoryboardFunctions((_storyboard$meta = storyboard.meta) === null || _storyboard$meta === void 0 ? void 0 : _storyboard$meta.functions, storyboard.app);
9377
+ registerMock((_storyboard$meta2 = storyboard.meta) === null || _storyboard$meta2 === void 0 ? void 0 : _storyboard$meta2.mocks);
9309
9378
  }
9310
9379
 
9311
9380
  var {
@@ -9444,33 +9513,30 @@
9444
9513
  if (barsHidden || getRuntimeMisc().isInIframeOfLegacyConsole) {
9445
9514
  _this3.kernel.toggleBars(false);
9446
9515
  } else if (_this3.kernel.currentLayout === "console") {
9447
- /* istanbul ignore next */
9448
- if (!_this3.kernel.enableUiV8) {
9449
- var _menuBar$menu, _menuBar$menu2;
9450
-
9451
- yield constructMenu(menuBar, _this3.locationContext.getCurrentContext(), _this3.kernel);
9516
+ var _menuBar$menu, _menuBar$menu2;
9452
9517
 
9453
- if (shouldBeDefaultCollapsed((_menuBar$menu = menuBar.menu) === null || _menuBar$menu === void 0 ? void 0 : _menuBar$menu.defaultCollapsed, (_menuBar$menu2 = menuBar.menu) === null || _menuBar$menu2 === void 0 ? void 0 : _menuBar$menu2.defaultCollapsedBreakpoint)) {
9454
- _this3.kernel.menuBar.collapse(true);
9518
+ yield constructMenu(menuBar, _this3.locationContext.getCurrentContext(), _this3.kernel);
9455
9519
 
9456
- _this3.defaultCollapsed = true;
9457
- } else {
9458
- if (_this3.defaultCollapsed) {
9459
- _this3.kernel.menuBar.collapse(false);
9460
- }
9520
+ if (shouldBeDefaultCollapsed((_menuBar$menu = menuBar.menu) === null || _menuBar$menu === void 0 ? void 0 : _menuBar$menu.defaultCollapsed, (_menuBar$menu2 = menuBar.menu) === null || _menuBar$menu2 === void 0 ? void 0 : _menuBar$menu2.defaultCollapsedBreakpoint)) {
9521
+ _this3.kernel.menuBar.collapse(true);
9461
9522
 
9462
- _this3.defaultCollapsed = false;
9523
+ _this3.defaultCollapsed = true;
9524
+ } else {
9525
+ if (_this3.defaultCollapsed) {
9526
+ _this3.kernel.menuBar.collapse(false);
9463
9527
  }
9464
9528
 
9465
- if (actualLegacy === "iframe") {
9466
- // Do not modify breadcrumb in iframe mode,
9467
- // it will be *popped* from iframe automatically.
9468
- delete appBar.breadcrumb;
9469
- }
9529
+ _this3.defaultCollapsed = false;
9530
+ }
9470
9531
 
9471
- mountStaticNode(_this3.kernel.menuBar.element, menuBar);
9472
- mountStaticNode(_this3.kernel.appBar.element, appBar);
9532
+ if (actualLegacy === "iframe") {
9533
+ // Do not modify breadcrumb in iframe mode,
9534
+ // it will be *popped* from iframe automatically.
9535
+ delete appBar.breadcrumb;
9473
9536
  }
9537
+
9538
+ mountStaticNode(_this3.kernel.menuBar.element, menuBar);
9539
+ mountStaticNode(_this3.kernel.appBar.element, appBar);
9474
9540
  }
9475
9541
 
9476
9542
  _this3.kernel.toggleLegacyIframe(actualLegacy === "iframe");
@@ -11318,6 +11384,7 @@
11318
11384
  exports.event = event;
11319
11385
  exports.getAuth = getAuth;
11320
11386
  exports.getHistory = getHistory;
11387
+ exports.getMockRule = getMockRule;
11321
11388
  exports.getRuntime = getRuntime;
11322
11389
  exports.handleHttpError = handleHttpError;
11323
11390
  exports.httpErrorToString = httpErrorToString;