@next-core/brick-kit 2.93.1 → 2.96.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/dist/index.esm.js CHANGED
@@ -7,9 +7,9 @@ import React, { useState, useEffect, forwardRef, useRef, useImperativeHandle, us
7
7
  import lodash, { set, get, difference, identity, cloneDeep, isNil, sortBy, merge, clamp, uniqueId, orderBy, omit, isEmpty } from 'lodash';
8
8
  import { toPath, computeRealRoutePath, hasOwnProperty, isObject, isEvaluable, transformAndInject, transform, trackContext, scanPermissionActionsInStoryboard, precookFunction, cook, shouldAllowRecursiveEvaluations, preevaluate, inject, deepFreeze, createProviderClass, scanRouteAliasInStoryboard, loadScript, getTemplateDepsOfStoryboard, getDllAndDepsOfStoryboard, asyncProcessStoryboard, prefetchScript, scanBricksInBrickConf, scanProcessorsInAny, getDllAndDepsByResource, resolveContextConcurrently, matchPath, asyncProcessBrick, restoreDynamicTemplates, mapCustomApisToNameAndNamespace, scanCustomApisInStoryboard } from '@next-core/brick-utils';
9
9
  import { http, HttpResponseError, HttpFetchError } from '@next-core/brick-http';
10
- import i18next, { getFixedT } from 'i18next';
11
10
  import moment from 'moment';
12
11
  import { pipes } from '@next-core/pipes';
12
+ import i18next, { getFixedT } from 'i18next';
13
13
  import { userAnalytics, apiAnalyzer } from '@next-core/easyops-analytics';
14
14
  import yaml from 'js-yaml';
15
15
  import { Modal, message, Empty, ConfigProvider } from 'antd';
@@ -1159,7 +1159,6 @@ function listenDevtools() {
1159
1159
  }
1160
1160
  });
1161
1161
  }
1162
-
1163
1162
  function getDevHook() {
1164
1163
  return window.__BRICK_NEXT_DEVTOOLS_HOOK__;
1165
1164
  }
@@ -1170,6 +1169,90 @@ function restoreDehydrated(value) {
1170
1169
  return (_getDevHook$restoreDe = (_getDevHook2 = getDevHook()) === null || _getDevHook2 === void 0 ? void 0 : _getDevHook2.restoreDehydrated(value)) !== null && _getDevHook$restoreDe !== void 0 ? _getDevHook$restoreDe : value;
1171
1170
  }
1172
1171
 
1172
+ function getItemFactory(storageType) {
1173
+ return function (name) {
1174
+ var storage = storageType === "local" ? localStorage : sessionStorage;
1175
+ return JSON.parse(storage.getItem(name));
1176
+ };
1177
+ }
1178
+
1179
+ var locale$7 = {
1180
+ [K.REQUEST_FAILED]: "Request Failed",
1181
+ [K.MODAL_OK]: "Ok",
1182
+ [K.MODAL_CANCEL]: "Cancel",
1183
+ [K.SOMETHING_WENT_WRONG]: "Something went wrong!",
1184
+ [K.LOGIN_TIMEOUT_MESSAGE]: "You haven't logged in or your login session has expired. Login right now?",
1185
+ [K.NETWORK_ERROR]: "Network error, please check your network."
1186
+ };
1187
+ var en = locale$7;
1188
+
1189
+ var locale$6 = {
1190
+ [K.REQUEST_FAILED]: "请求失败",
1191
+ [K.MODAL_OK]: "确认",
1192
+ [K.MODAL_CANCEL]: "取消",
1193
+ [K.SOMETHING_WENT_WRONG]: "出现了一些问题!",
1194
+ [K.LOGIN_TIMEOUT_MESSAGE]: "您还未登录或登录信息已过期,现在重新登录?",
1195
+ [K.NETWORK_ERROR]: "网络错误,请检查您的网络连接。"
1196
+ };
1197
+ var zh = locale$6;
1198
+
1199
+ /** @internal */
1200
+
1201
+ var initI18n = () => {
1202
+ i18next.addResourceBundle("en", NS_BRICK_KIT, en);
1203
+ i18next.addResourceBundle("zh", NS_BRICK_KIT, zh);
1204
+ };
1205
+ /** @internal */
1206
+
1207
+ function getI18nNamespace(type, id) {
1208
+ return "$".concat(type, "-").concat(id);
1209
+ }
1210
+
1211
+ function registerWidgetI18n(widgetId, i18n) {
1212
+ var ns = getI18nNamespace("widget", widgetId);
1213
+ Object.entries(i18n).forEach(_ref => {
1214
+ var [lang, resources] = _ref;
1215
+ i18next.addResourceBundle(lang, ns, resources);
1216
+ });
1217
+ }
1218
+ function widgetI18nFactory(widgetId) {
1219
+ return getFixedT(null, getI18nNamespace("widget", widgetId));
1220
+ }
1221
+
1222
+ function i18nText(data) {
1223
+ var _i18next$language;
1224
+
1225
+ if (!data) {
1226
+ return;
1227
+ }
1228
+
1229
+ var language = (_i18next$language = i18next.language) !== null && _i18next$language !== void 0 ? _i18next$language : "zh-CN"; // First, make a perfect match.
1230
+
1231
+ if (hasOwnProperty(data, language)) {
1232
+ return data[language];
1233
+ } // https://en.wikipedia.org/wiki/IETF_language_tag
1234
+
1235
+
1236
+ var primaryLanguage = language.split("-")[0];
1237
+
1238
+ if (primaryLanguage !== language) {
1239
+ // Then, match the primary language (which omits other subtags).
1240
+ // E.g., match `zh` if the current language is `zh-CN`.
1241
+ return hasOwnProperty(data, primaryLanguage) ? data[primaryLanguage] : undefined;
1242
+ } // At last, match the first key which starts with the primary language,
1243
+ // if the current language contains primary subtag only.
1244
+ // E.g., match `zh-CN` if the current language is `zh`.
1245
+
1246
+
1247
+ var prefix = "".concat(primaryLanguage, "-");
1248
+
1249
+ for (var key of Object.keys(data)) {
1250
+ if (key.startsWith(prefix)) {
1251
+ return data[key];
1252
+ }
1253
+ }
1254
+ }
1255
+
1173
1256
  function asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, key, arg) {
1174
1257
  try {
1175
1258
  var info = gen[key](arg);
@@ -1382,88 +1465,68 @@ function resetPermissionPreChecks() {
1382
1465
  permissionMap.clear();
1383
1466
  }
1384
1467
 
1385
- function getItemFactory(storageType) {
1386
- return function (name) {
1387
- var storage = storageType === "local" ? localStorage : sessionStorage;
1388
- return JSON.parse(storage.getItem(name));
1389
- };
1390
- }
1468
+ // `GeneralGlobals` are globals which are page-state-agnostic,
1469
+ // thus they can be used both in storyboard expressions and functions.
1470
+ function getGeneralGlobals(attemptToVisitGlobals, options) {
1471
+ var globalVariables = {};
1391
1472
 
1392
- function i18nText(data) {
1393
- var _i18next$language;
1473
+ for (var variableName of attemptToVisitGlobals) {
1474
+ var variable = getIndividualGlobal(variableName, options);
1394
1475
 
1395
- if (!data) {
1396
- return;
1476
+ if (variable !== undefined) {
1477
+ globalVariables[variableName] = variable;
1478
+ }
1397
1479
  }
1398
1480
 
1399
- var language = (_i18next$language = i18next.language) !== null && _i18next$language !== void 0 ? _i18next$language : "zh-CN"; // First, make a perfect match.
1481
+ return globalVariables;
1482
+ }
1400
1483
 
1401
- if (hasOwnProperty(data, language)) {
1402
- return data[language];
1403
- } // https://en.wikipedia.org/wiki/IETF_language_tag
1484
+ function getIndividualGlobal(variableName, _ref) {
1485
+ var {
1486
+ collectCoverage,
1487
+ widgetId,
1488
+ app,
1489
+ storyboardFunctions
1490
+ } = _ref;
1404
1491
 
1492
+ switch (variableName) {
1493
+ case "BASE_URL":
1494
+ return collectCoverage ? "/next" : getBasePath().replace(/\/$/, "");
1405
1495
 
1406
- var primaryLanguage = language.split("-")[0];
1496
+ case "FN":
1497
+ return storyboardFunctions;
1407
1498
 
1408
- if (primaryLanguage !== language) {
1409
- // Then, match the primary language (which omits other subtags).
1410
- // E.g., match `zh` if the current language is `zh-CN`.
1411
- return hasOwnProperty(data, primaryLanguage) ? data[primaryLanguage] : undefined;
1412
- } // At last, match the first key which starts with the primary language,
1413
- // if the current language contains primary subtag only.
1414
- // E.g., match `zh-CN` if the current language is `zh`.
1499
+ case "IMG":
1500
+ return collectCoverage ? fakeImageFactory() : widgetId ? widgetImagesFactory(widgetId) : imagesFactory(app.id, app.isBuildPush);
1415
1501
 
1502
+ case "I18N":
1503
+ return collectCoverage ? identity : widgetId ? widgetI18nFactory(widgetId) : getFixedT(null, getI18nNamespace("app", app.id));
1416
1504
 
1417
- var prefix = "".concat(primaryLanguage, "-");
1505
+ case "I18N_TEXT":
1506
+ return collectCoverage ? fakeI18nText : i18nText;
1418
1507
 
1419
- for (var key of Object.keys(data)) {
1420
- if (key.startsWith(prefix)) {
1421
- return data[key];
1422
- }
1508
+ case "PERMISSIONS":
1509
+ return {
1510
+ check: collectCoverage ? fakeCheckPermissions : checkPermissions
1511
+ };
1423
1512
  }
1424
1513
  }
1425
1514
 
1426
- var locale$7 = {
1427
- [K.REQUEST_FAILED]: "Request Failed",
1428
- [K.MODAL_OK]: "Ok",
1429
- [K.MODAL_CANCEL]: "Cancel",
1430
- [K.SOMETHING_WENT_WRONG]: "Something went wrong!",
1431
- [K.LOGIN_TIMEOUT_MESSAGE]: "You haven't logged in or your login session has expired. Login right now?",
1432
- [K.NETWORK_ERROR]: "Network error, please check your network."
1433
- };
1434
- var en = locale$7;
1435
-
1436
- var locale$6 = {
1437
- [K.REQUEST_FAILED]: "请求失败",
1438
- [K.MODAL_OK]: "确认",
1439
- [K.MODAL_CANCEL]: "取消",
1440
- [K.SOMETHING_WENT_WRONG]: "出现了一些问题!",
1441
- [K.LOGIN_TIMEOUT_MESSAGE]: "您还未登录或登录信息已过期,现在重新登录?",
1442
- [K.NETWORK_ERROR]: "网络错误,请检查您的网络连接。"
1443
- };
1444
- var zh = locale$6;
1445
-
1446
- /** @internal */
1515
+ function fakeI18nText(data) {
1516
+ return data === null || data === void 0 ? void 0 : data.en;
1517
+ }
1447
1518
 
1448
- var initI18n = () => {
1449
- i18next.addResourceBundle("en", NS_BRICK_KIT, en);
1450
- i18next.addResourceBundle("zh", NS_BRICK_KIT, zh);
1451
- };
1452
- /** @internal */
1519
+ function fakeImageFactory() {
1520
+ return {
1521
+ get(name) {
1522
+ return "mock/images/".concat(name);
1523
+ }
1453
1524
 
1454
- function getI18nNamespace(type, id) {
1455
- return "$".concat(type, "-").concat(id);
1525
+ };
1456
1526
  }
1457
1527
 
1458
- function registerWidgetI18n(widgetId, i18n) {
1459
- var ns = getI18nNamespace("widget", widgetId);
1460
- Object.entries(i18n).forEach(_ref => {
1461
- var [lang, resources] = _ref;
1462
- i18next.addResourceBundle(lang, ns, resources);
1463
- });
1464
- }
1465
- function widgetI18nFactory(widgetId) {
1466
- return getFixedT(null, getI18nNamespace("widget", widgetId));
1528
+ function fakeCheckPermissions() {
1529
+ return true;
1467
1530
  }
1468
1531
 
1469
1532
  /** @internal */
@@ -1482,29 +1545,11 @@ function StoryboardFunctionRegistryFactory() {
1482
1545
  }
1483
1546
 
1484
1547
  });
1485
-
1486
- var builtinSupply = _objectSpread({
1487
- // Functions can call other functions.
1488
- FN: storyboardFunctions
1489
- }, collectCoverage ? {
1490
- // Fake builtin methods for tests.
1491
- I18N: identity,
1492
- I18N_TEXT: fakeI18nText,
1493
- IMG: fakeImageFactory()
1494
- } : widgetId ? {
1495
- I18N: widgetI18nFactory(widgetId),
1496
- I18N_TEXT: i18nText,
1497
- IMG: widgetImagesFactory(widgetId)
1498
- } : {
1499
- I18N_TEXT: i18nText
1500
- });
1548
+ var currentApp;
1501
1549
 
1502
1550
  function registerStoryboardFunctions(functions, app) {
1503
1551
  if (app) {
1504
- Object.assign(builtinSupply, {
1505
- I18N: getFixedT(null, getI18nNamespace("app", app.id)),
1506
- IMG: imagesFactory(app.id, app.isBuildPush)
1507
- });
1552
+ currentApp = app;
1508
1553
  }
1509
1554
 
1510
1555
  registeredFunctions.clear();
@@ -1546,7 +1591,12 @@ function StoryboardFunctionRegistryFactory() {
1546
1591
  rules: {
1547
1592
  noVar: true
1548
1593
  },
1549
- globalVariables: supply(precooked.attemptToVisitGlobals, builtinSupply),
1594
+ globalVariables: supply(precooked.attemptToVisitGlobals, getGeneralGlobals(precooked.attemptToVisitGlobals, {
1595
+ collectCoverage,
1596
+ widgetId,
1597
+ app: currentApp,
1598
+ storyboardFunctions
1599
+ })),
1550
1600
  hooks: collector && {
1551
1601
  beforeEvaluate: collector.beforeEvaluate,
1552
1602
  beforeCall: collector.beforeCall,
@@ -1571,19 +1621,6 @@ function StoryboardFunctionRegistryFactory() {
1571
1621
  };
1572
1622
  }
1573
1623
 
1574
- function fakeI18nText(data) {
1575
- return data === null || data === void 0 ? void 0 : data.en;
1576
- }
1577
-
1578
- function fakeImageFactory() {
1579
- return {
1580
- get(name) {
1581
- return "mock/images/".concat(name);
1582
- }
1583
-
1584
- };
1585
- }
1586
-
1587
1624
  var {
1588
1625
  storyboardFunctions,
1589
1626
  registerStoryboardFunctions
@@ -1612,6 +1649,39 @@ function registerWidgetFunctions(widgetId, functions) {
1612
1649
  registerStoryboardFunctions(functions);
1613
1650
  }
1614
1651
 
1652
+ var THROW = () => {
1653
+ throw new Error("Can't modify read-only proxy object");
1654
+ };
1655
+
1656
+ var readOnlyHandler = {
1657
+ set: THROW,
1658
+ defineProperty: THROW,
1659
+ deleteProperty: THROW,
1660
+ setPrototypeOf: THROW
1661
+ };
1662
+ function getReadOnlyProxy(object) {
1663
+ return new Proxy(object, readOnlyHandler);
1664
+ } // First, we want to make accessing property of globals lazy,
1665
+ // So we use *Proxy* to make a dynamic accessor for each of these globals.
1666
+ // But we also want to keep them working in devtools.
1667
+
1668
+ function getDynamicReadOnlyProxy(_ref) {
1669
+ var {
1670
+ get,
1671
+ ownKeys
1672
+ } = _ref;
1673
+
1674
+ if (getDevHook()) {
1675
+ // In devtools, we extract them at beginning.
1676
+ var target = Object.fromEntries(ownKeys(null).map(key => [key, get(null, key, null)]));
1677
+ return getReadOnlyProxy(target);
1678
+ }
1679
+
1680
+ return new Proxy(Object.freeze({}), {
1681
+ get
1682
+ });
1683
+ }
1684
+
1615
1685
  var symbolForRaw = Symbol.for("pre.evaluated.raw");
1616
1686
  var symbolForContext = Symbol.for("pre.evaluated.context");
1617
1687
  function isPreEvaluated(raw) {
@@ -1729,130 +1799,142 @@ function evaluate(raw) {
1729
1799
 
1730
1800
  var app = (_runtimeContext$overr = runtimeContext.overrideApp) !== null && _runtimeContext$overr !== void 0 ? _runtimeContext$overr : currentApp;
1731
1801
 
1732
- if (attemptToVisitGlobals.has("QUERY")) {
1733
- globalVariables.QUERY = Object.fromEntries(Array.from(query.keys()).map(key => [key, query.get(key)]));
1734
- }
1802
+ function getIndividualGlobal(variableName) {
1803
+ switch (variableName) {
1804
+ case "ALIAS":
1805
+ return {
1806
+ getUrl: getUrlByAliasFactory(app)
1807
+ };
1735
1808
 
1736
- if (attemptToVisitGlobals.has("QUERY_ARRAY")) {
1737
- globalVariables.QUERY_ARRAY = Object.fromEntries(Array.from(query.keys()).map(key => [key, query.getAll(key)]));
1738
- }
1809
+ case "ANCHOR":
1810
+ return hash ? hash.substr(1) : null;
1739
1811
 
1740
- if (attemptToVisitGlobals.has("PARAMS")) {
1741
- globalVariables.PARAMS = new URLSearchParams(query);
1742
- }
1812
+ case "APP":
1813
+ return cloneDeep(app);
1743
1814
 
1744
- if (attemptToVisitGlobals.has("APP")) {
1745
- globalVariables.APP = cloneDeep(app);
1746
- }
1815
+ case "CTX":
1816
+ return getDynamicReadOnlyProxy({
1817
+ get(target, key) {
1818
+ var _item$brick$element;
1747
1819
 
1748
- if (attemptToVisitGlobals.has("PATH")) {
1749
- globalVariables.PATH = cloneDeep(match.params);
1750
- }
1820
+ var item = storyboardContext.get(key);
1821
+ 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;
1822
+ },
1751
1823
 
1752
- if (attemptToVisitGlobals.has("SYS")) {
1753
- globalVariables.SYS = cloneDeep(sys);
1754
- }
1824
+ ownKeys() {
1825
+ return Array.from(storyboardContext.keys());
1826
+ }
1755
1827
 
1756
- if (attemptToVisitGlobals.has("FLAGS")) {
1757
- globalVariables.FLAGS = cloneDeep(flags);
1758
- }
1828
+ });
1759
1829
 
1760
- if (attemptToVisitGlobals.has("HASH")) {
1761
- globalVariables.HASH = hash;
1762
- }
1830
+ case "FLAGS":
1831
+ return getReadOnlyProxy(flags);
1763
1832
 
1764
- if (attemptToVisitGlobals.has("ANCHOR")) {
1765
- globalVariables.ANCHOR = hash ? hash.substr(1) : null;
1766
- }
1833
+ case "HASH":
1834
+ return hash;
1767
1835
 
1768
- if (attemptToVisitGlobals.has("SEGUE")) {
1769
- globalVariables.SEGUE = {
1770
- getUrl: getUrlBySegueFactory(app, segues)
1771
- };
1772
- }
1836
+ case "INSTALLED_APPS":
1837
+ return {
1838
+ has: (appId, matchVersion) => getRuntime().hasInstalledApp(appId, matchVersion)
1839
+ };
1773
1840
 
1774
- if (attemptToVisitGlobals.has("ALIAS")) {
1775
- globalVariables.ALIAS = {
1776
- getUrl: getUrlByAliasFactory(app)
1777
- };
1778
- }
1841
+ case "LOCAL_STORAGE":
1842
+ return {
1843
+ getItem: getItemFactory("local")
1844
+ };
1779
1845
 
1780
- if (attemptToVisitGlobals.has("IMG")) {
1781
- globalVariables.IMG = imagesFactory(app.id, app.isBuildPush);
1782
- }
1846
+ case "MISC":
1847
+ return getRuntime().getMiscSettings();
1783
1848
 
1784
- if (attemptToVisitGlobals.has("__WIDGET_IMG__")) {
1785
- globalVariables.__WIDGET_IMG__ = widgetImagesFactory;
1786
- }
1849
+ case "PARAMS":
1850
+ return new URLSearchParams(query);
1787
1851
 
1788
- if (attemptToVisitGlobals.has("I18N")) {
1789
- globalVariables.I18N = i18next.getFixedT(null, getI18nNamespace("app", app.id));
1790
- }
1852
+ case "PATH":
1853
+ return getReadOnlyProxy(match.params);
1791
1854
 
1792
- if (attemptToVisitGlobals.has("__WIDGET_I18N__")) {
1793
- globalVariables.__WIDGET_I18N__ = widgetI18nFactory;
1794
- }
1855
+ case "PROCESSORS":
1856
+ return getDynamicReadOnlyProxy({
1857
+ get(target, key) {
1858
+ var pkg = customProcessorRegistry.get(key);
1859
+ return pkg ? getDynamicReadOnlyProxy({
1860
+ get(t, k) {
1861
+ return pkg.get(k);
1862
+ },
1795
1863
 
1796
- if (attemptToVisitGlobals.has("I18N_TEXT")) {
1797
- globalVariables.I18N_TEXT = i18nText;
1798
- }
1864
+ ownKeys() {
1865
+ return Array.from(pkg.keys());
1866
+ }
1799
1867
 
1800
- if (attemptToVisitGlobals.has("CTX")) {
1801
- globalVariables.CTX = Object.fromEntries(Array.from(storyboardContext.entries()).map(_ref => {
1802
- var _item$brick$element;
1868
+ }) : pkg;
1869
+ },
1803
1870
 
1804
- var [name, item] = _ref;
1805
- 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];
1806
- }));
1807
- }
1871
+ ownKeys() {
1872
+ return Array.from(customProcessorRegistry.keys());
1873
+ }
1808
1874
 
1809
- if (attemptToVisitGlobals.has("PROCESSORS")) {
1810
- globalVariables.PROCESSORS = Object.fromEntries(Array.from(customProcessorRegistry.entries()).map(_ref2 => {
1811
- var [namespace, registry] = _ref2;
1812
- return [namespace, Object.fromEntries(registry.entries())];
1813
- }));
1814
- }
1875
+ });
1815
1876
 
1816
- if (attemptToVisitGlobals.has("PERMISSIONS")) {
1817
- globalVariables.PERMISSIONS = {
1818
- check: checkPermissions
1819
- };
1820
- }
1877
+ case "QUERY":
1878
+ return getDynamicReadOnlyProxy({
1879
+ get(target, key) {
1880
+ return query.get(key);
1881
+ },
1821
1882
 
1822
- if (attemptToVisitGlobals.has("LOCAL_STORAGE")) {
1823
- globalVariables.LOCAL_STORAGE = {
1824
- getItem: getItemFactory("local")
1825
- };
1826
- }
1883
+ ownKeys() {
1884
+ return Array.from(query.keys());
1885
+ }
1827
1886
 
1828
- if (attemptToVisitGlobals.has("SESSION_STORAGE")) {
1829
- globalVariables.SESSION_STORAGE = {
1830
- getItem: getItemFactory("session")
1831
- };
1832
- }
1887
+ });
1833
1888
 
1834
- if (attemptToVisitGlobals.has("INSTALLED_APPS")) {
1835
- globalVariables.INSTALLED_APPS = {
1836
- has: (appId, matchVersion) => getRuntime().hasInstalledApp(appId, matchVersion)
1837
- };
1838
- }
1889
+ case "QUERY_ARRAY":
1890
+ return getDynamicReadOnlyProxy({
1891
+ get(target, key) {
1892
+ return query.getAll(key);
1893
+ },
1839
1894
 
1840
- if (attemptToVisitGlobals.has("FN")) {
1841
- globalVariables.FN = storyboardFunctions;
1842
- }
1895
+ ownKeys() {
1896
+ return Array.from(query.keys());
1897
+ }
1843
1898
 
1844
- if (attemptToVisitGlobals.has("__WIDGET_FN__")) {
1845
- globalVariables.__WIDGET_FN__ = widgetFunctions;
1846
- }
1899
+ });
1847
1900
 
1848
- if (attemptToVisitGlobals.has("MISC")) {
1849
- globalVariables.MISC = getRuntime().getMiscSettings();
1901
+ case "SEGUE":
1902
+ return {
1903
+ getUrl: getUrlBySegueFactory(app, segues)
1904
+ };
1905
+
1906
+ case "SESSION_STORAGE":
1907
+ return {
1908
+ getItem: getItemFactory("session")
1909
+ };
1910
+
1911
+ case "SYS":
1912
+ return getReadOnlyProxy(sys);
1913
+
1914
+ case "__WIDGET_FN__":
1915
+ return widgetFunctions;
1916
+
1917
+ case "__WIDGET_IMG__":
1918
+ return widgetImagesFactory;
1919
+
1920
+ case "__WIDGET_I18N__":
1921
+ return widgetI18nFactory;
1922
+ }
1850
1923
  }
1851
1924
 
1852
- if (attemptToVisitGlobals.has("BASE_URL")) {
1853
- globalVariables.BASE_URL = getBasePath().replace(/\/$/, "");
1925
+ for (var variableName of attemptToVisitGlobals) {
1926
+ var variable = getIndividualGlobal(variableName);
1927
+
1928
+ if (variable !== undefined) {
1929
+ globalVariables[variableName] = variable;
1930
+ }
1854
1931
  }
1855
1932
 
1933
+ Object.assign(globalVariables, getGeneralGlobals(precooked.attemptToVisitGlobals, {
1934
+ storyboardFunctions,
1935
+ app
1936
+ }));
1937
+
1856
1938
  try {
1857
1939
  var result = cook(precooked.expression, precooked.source, {
1858
1940
  globalVariables: supply(precooked.attemptToVisitGlobals, globalVariables)
@@ -9073,6 +9155,23 @@ function shouldBeDefaultCollapsed(defaultCollapsed, defaultCollapsedBreakpoint)
9073
9155
  return defaultCollapsed || defaultCollapsedBreakpoint && document.documentElement.clientWidth < defaultCollapsedBreakpoint;
9074
9156
  }
9075
9157
 
9158
+ var useMockList = [];
9159
+ function registerMock(mockList) {
9160
+ if (mockList) useMockList = mockList;
9161
+ }
9162
+
9163
+ function getUrlRegExp(str) {
9164
+ return new RegExp("".concat(str.replace(/:\w+/g, "[\\w|-]+"), "$"));
9165
+ }
9166
+
9167
+ var isMatchMockUrl = (requestUrl, uri) => {
9168
+ var reg = getUrlRegExp(uri);
9169
+ return reg.test(requestUrl);
9170
+ };
9171
+ var getMockRule = requestUrl => {
9172
+ return useMockList.find(item => isMatchMockUrl(requestUrl, item.uri));
9173
+ };
9174
+
9076
9175
  class Router {
9077
9176
  constructor(kernel) {
9078
9177
  _defineProperty$1(this, "defaultCollapsed", false);
@@ -9258,7 +9357,7 @@ class Router {
9258
9357
  var storyboard = locationContext.matchStoryboard(_this3.kernel.bootstrapData.storyboards);
9259
9358
 
9260
9359
  if (storyboard) {
9261
- var _storyboard$meta;
9360
+ var _storyboard$meta, _storyboard$meta2;
9262
9361
 
9263
9362
  yield _this3.kernel.fulfilStoryboard(storyboard); // 将动态解析后的模板还原,以便重新动态解析。
9264
9363
 
@@ -9276,6 +9375,7 @@ class Router {
9276
9375
  _this3.kernel.registerCustomTemplatesInStoryboard(storyboard);
9277
9376
 
9278
9377
  registerStoryboardFunctions((_storyboard$meta = storyboard.meta) === null || _storyboard$meta === void 0 ? void 0 : _storyboard$meta.functions, storyboard.app);
9378
+ registerMock((_storyboard$meta2 = storyboard.meta) === null || _storyboard$meta2 === void 0 ? void 0 : _storyboard$meta2.mocks);
9279
9379
  }
9280
9380
 
9281
9381
  var {
@@ -10763,17 +10863,27 @@ var localeValues = {
10763
10863
  };
10764
10864
  var defaultLocale = localeValues;
10765
10865
 
10766
- var emptyImage = "empty-image.397ff6359f4066d8.png";
10866
+ var emptyImage = "empty-image.8e18d87fea570ef0.png";
10867
+
10868
+ var bigEmptyImage = "big-empty-image.397ff6359f4066d8.png";
10767
10869
 
10768
10870
  /**
10769
10871
  * 用于展示空数据的 React 组件。
10770
10872
  */
10771
10873
  function EasyopsEmpty(props) {
10874
+ var _props$imageStyle;
10875
+
10772
10876
  var illustration = useMemo(() => props.illustration && getIllustration(props.illustration), [props.illustration]);
10773
- var image = props.illustration ? illustration : getImageUrl(emptyImage);
10877
+
10878
+ var _emptyImage = props.useBigEmptyImage ? bigEmptyImage : emptyImage;
10879
+
10880
+ var image = props.illustration ? illustration : getImageUrl(_emptyImage);
10881
+ var imageStyle = (_props$imageStyle = props.imageStyle) !== null && _props$imageStyle !== void 0 ? _props$imageStyle : props.useBigEmptyImage ? undefined : {
10882
+ height: "60px"
10883
+ };
10774
10884
  return /*#__PURE__*/React.createElement(Empty, {
10775
10885
  image: image,
10776
- imageStyle: props.imageStyle,
10886
+ imageStyle: imageStyle,
10777
10887
  description: props.description
10778
10888
  });
10779
10889
  }
@@ -11264,5 +11374,5 @@ var ModalElement = _decorate(null, function (_initialize, _UpdatingElement) {
11264
11374
  };
11265
11375
  }, UpdatingElement);
11266
11376
 
11267
- export { BrickAsComponent, BrickWrapper, DisplayByFeatureFlags, EasyopsEmpty, ErrorBoundary, FeatureFlagsProvider, ForwardRefSingleBrickAsComponent, ModalElement, SingleBrickAsComponent, StoryboardFunctionRegistryFactory, UpdatingElement, authenticate, checkIf, checkIfByTransform, createHistory, createRuntime, developHelper, doTransform, event, getAuth, getHistory, getRuntime, handleHttpError, httpErrorToString, i18nText, initI18n, isLoggedIn, logout, looseCheckIf, looseCheckIfByTransform, looseCheckIfOfComputed, method, preprocessTransformProperties, property, reTransformForDevtools, renderEasyopsEmpty, transformElementProperties, transformIntermediateData, transformProperties, useApplyPageTitle, useCurrentApp, useCurrentMode, useCurrentTheme, useFeatureFlags, useLocation, useRecentApps };
11377
+ export { BrickAsComponent, BrickWrapper, DisplayByFeatureFlags, EasyopsEmpty, ErrorBoundary, FeatureFlagsProvider, ForwardRefSingleBrickAsComponent, ModalElement, SingleBrickAsComponent, StoryboardFunctionRegistryFactory, UpdatingElement, authenticate, checkIf, checkIfByTransform, createHistory, createRuntime, developHelper, doTransform, event, getAuth, getHistory, getMockRule, getRuntime, handleHttpError, httpErrorToString, i18nText, initI18n, isLoggedIn, logout, looseCheckIf, looseCheckIfByTransform, looseCheckIfOfComputed, method, preprocessTransformProperties, property, reTransformForDevtools, renderEasyopsEmpty, transformElementProperties, transformIntermediateData, transformProperties, useApplyPageTitle, useCurrentApp, useCurrentMode, useCurrentTheme, useFeatureFlags, useLocation, useRecentApps };
11268
11378
  //# sourceMappingURL=index.esm.js.map