@next-core/brick-kit 2.199.1 → 2.199.3

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.
@@ -1430,9 +1430,16 @@
1430
1430
  }
1431
1431
  });
1432
1432
  var currentApp;
1433
+ var needPerf = false;
1433
1434
  function registerStoryboardFunctions(functions, app) {
1434
1435
  if (app) {
1436
+ var _app$config, _app$config$settings;
1435
1437
  currentApp = app;
1438
+ needPerf = app === null || app === void 0 ? void 0 : (_app$config = app.config) === null || _app$config === void 0 ? void 0 : (_app$config$settings = _app$config.settings) === null || _app$config$settings === void 0 ? void 0 : _app$config$settings.perfStoryboardFunctions;
1439
+ if (needPerf) {
1440
+ // Clear perf data when initialize functions.
1441
+ window.STORYBOARD_FUNCTIONS_PERF = [];
1442
+ }
1436
1443
  }
1437
1444
  registeredFunctions.clear();
1438
1445
  if (Array.isArray(functions)) {
@@ -1457,6 +1464,7 @@
1457
1464
  collector = collectCoverage.createCollector(name);
1458
1465
  }
1459
1466
  var precooked = brickUtils.precookFunction(fn.source, {
1467
+ cacheKey: fn,
1460
1468
  typescript: fn.typescript,
1461
1469
  hooks: collector && {
1462
1470
  beforeVisit: collector.beforeVisit
@@ -1474,11 +1482,15 @@
1474
1482
  storyboardFunctions,
1475
1483
  isStoryboardFunction: true
1476
1484
  }), !!collectCoverage),
1477
- hooks: collector && {
1485
+ hooks: _objectSpread__default["default"]({
1486
+ perfCall: needPerf ? duration => {
1487
+ perf(name, fn.source, duration);
1488
+ } : undefined
1489
+ }, collector ? {
1478
1490
  beforeEvaluate: collector.beforeEvaluate,
1479
1491
  beforeCall: collector.beforeCall,
1480
1492
  beforeBranch: collector.beforeBranch
1481
- }
1493
+ } : null)
1482
1494
  });
1483
1495
  fn.processed = true;
1484
1496
  return fn.cooked;
@@ -1494,6 +1506,19 @@
1494
1506
  }
1495
1507
  };
1496
1508
  }
1509
+ function perf(name, source, duration) {
1510
+ var _window, _window$STORYBOARD_FU;
1511
+ var list = (_window$STORYBOARD_FU = (_window = window).STORYBOARD_FUNCTIONS_PERF) !== null && _window$STORYBOARD_FU !== void 0 ? _window$STORYBOARD_FU : _window.STORYBOARD_FUNCTIONS_PERF = [];
1512
+ var data = list.find(item => item.name === name);
1513
+ if (!data) {
1514
+ list.push(data = {
1515
+ name,
1516
+ durations: [],
1517
+ source
1518
+ });
1519
+ }
1520
+ data.durations.push(Math.round(duration * 1000));
1521
+ }
1497
1522
 
1498
1523
  var {
1499
1524
  storyboardFunctions,
@@ -2702,7 +2727,9 @@
2702
2727
  if (globals.some(key => data.includes(key))) {
2703
2728
  var {
2704
2729
  attemptToVisitGlobals
2705
- } = brickUtils.preevaluate(data);
2730
+ } = brickUtils.preevaluate(data, {
2731
+ cache: true
2732
+ });
2706
2733
  return globals.some(key => attemptToVisitGlobals.has(key));
2707
2734
  }
2708
2735
  } else if (globals.includes("APP")) {
@@ -2871,7 +2898,9 @@
2871
2898
  // A `SyntaxError` maybe thrown.
2872
2899
  var precooked;
2873
2900
  try {
2874
- precooked = brickUtils.preevaluate(raw);
2901
+ precooked = brickUtils.preevaluate(raw, {
2902
+ cache: true
2903
+ });
2875
2904
  } catch (error) {
2876
2905
  var message = "".concat(error.message, ", in \"").concat(raw, "\"");
2877
2906
  if (options.isReEvaluation) {
@@ -12067,7 +12096,7 @@
12067
12096
  render(location) {
12068
12097
  var _this3 = this;
12069
12098
  return _asyncToGenerator__default["default"](function* () {
12070
- var _apiAnalyzer$getInsta, _storyboard$app, _this3$kernel$previou, _currentApp$config, _currentApp$config$_e, _this3$kernel$bootstr, _this3$kernel$bootstr2, _getLocalAppsTheme, _storyboard$app$homep, _storyboard$app2;
12099
+ var _apiAnalyzer$getInsta, _storyboard$app, _this3$kernel$previou, _currentApp, _currentApp2, _currentApp2$config, _currentApp2$config$_, _this3$kernel$bootstr, _this3$kernel$bootstr2, _getLocalAppsTheme, _currentApp3, _currentApp4, _storyboard$app$homep, _storyboard$app2;
12071
12100
  _this3.state = "initial";
12072
12101
  var renderId = _this3.renderId = _.uniqueId("render-id-");
12073
12102
  resetAllInjected();
@@ -12099,6 +12128,14 @@
12099
12128
  version: storyboard.app.currentVersion
12100
12129
  });
12101
12130
  }
12131
+ var previousApp = _this3.kernel.currentApp;
12132
+ var currentApp = storyboard ? storyboard.app : undefined;
12133
+ // Storyboard maybe re-assigned, e.g. when open launchpad.
12134
+ var appChanged = previousApp && currentApp ? previousApp.id !== currentApp.id : previousApp !== currentApp;
12135
+ brickUtils.clearExpressionASTCache();
12136
+ if (appChanged) {
12137
+ brickUtils.clearFunctionASTCache();
12138
+ }
12102
12139
 
12103
12140
  /** Pending task for loading bricks */
12104
12141
  var pendingTask;
@@ -12145,18 +12182,15 @@
12145
12182
  registerMock((_storyboard$meta2 = storyboard.meta) === null || _storyboard$meta2 === void 0 ? void 0 : _storyboard$meta2.mocks);
12146
12183
  registerFormRenderer();
12147
12184
  collectContract((_storyboard$meta3 = storyboard.meta) === null || _storyboard$meta3 === void 0 ? void 0 : _storyboard$meta3.contracts);
12185
+
12186
+ // `app` maybe fulfilled
12187
+ currentApp = storyboard.app;
12148
12188
  }
12149
- var {
12150
- mountPoints,
12151
- currentApp: previousApp
12152
- } = _this3.kernel;
12153
- var currentApp = storyboard ? storyboard.app : undefined;
12154
- // Storyboard maybe re-assigned, e.g. when open launchpad.
12155
- var appChanged = previousApp && currentApp ? previousApp.id !== currentApp.id : previousApp !== currentApp;
12189
+ var mountPoints = _this3.kernel.mountPoints;
12156
12190
  var legacy = currentApp ? currentApp.legacy : undefined;
12157
- var layoutType = (currentApp === null || currentApp === void 0 ? void 0 : currentApp.layoutType) || "console";
12191
+ var layoutType = ((_currentApp = currentApp) === null || _currentApp === void 0 ? void 0 : _currentApp.layoutType) || "console";
12158
12192
  var faviconElement = document.querySelector("link[rel='shortcut icon']");
12159
- var customFaviconHref = currentApp === null || currentApp === void 0 ? void 0 : (_currentApp$config = currentApp.config) === null || _currentApp$config === void 0 ? void 0 : (_currentApp$config$_e = _currentApp$config._easyops_app_favicon) === null || _currentApp$config$_e === void 0 ? void 0 : _currentApp$config$_e.default;
12193
+ var customFaviconHref = (_currentApp2 = currentApp) === null || _currentApp2 === void 0 ? void 0 : (_currentApp2$config = _currentApp2.config) === null || _currentApp2$config === void 0 ? void 0 : (_currentApp2$config$_ = _currentApp2$config._easyops_app_favicon) === null || _currentApp2$config$_ === void 0 ? void 0 : _currentApp2$config$_.default;
12160
12194
  var settingsFaviconHref = (_this3$kernel$bootstr = _this3.kernel.bootstrapData.settings) === null || _this3$kernel$bootstr === void 0 ? void 0 : (_this3$kernel$bootstr2 = _this3$kernel$bootstr.brand) === null || _this3$kernel$bootstr2 === void 0 ? void 0 : _this3$kernel$bootstr2.favicon;
12161
12195
  if (faviconElement) {
12162
12196
  if (customFaviconHref) {
@@ -12175,7 +12209,7 @@
12175
12209
  transform: "translateY(-100px)",
12176
12210
  height: "calc(100vh - var(--app-bar-height))"
12177
12211
  };
12178
- setTheme(((_getLocalAppsTheme = getLocalAppsTheme()) === null || _getLocalAppsTheme === void 0 ? void 0 : _getLocalAppsTheme[currentApp === null || currentApp === void 0 ? void 0 : currentApp.id]) || (currentApp === null || currentApp === void 0 ? void 0 : currentApp.theme) || "light");
12212
+ setTheme(((_getLocalAppsTheme = getLocalAppsTheme()) === null || _getLocalAppsTheme === void 0 ? void 0 : _getLocalAppsTheme[(_currentApp3 = currentApp) === null || _currentApp3 === void 0 ? void 0 : _currentApp3.id]) || ((_currentApp4 = currentApp) === null || _currentApp4 === void 0 ? void 0 : _currentApp4.theme) || "light");
12179
12213
  getRuntime().getFeatureFlags()["support-ui-8.2-compact-layout"] ? document.body.classList.add("compact-layout") : document.body.classList.remove("compact-layout");
12180
12214
  setMode("default");
12181
12215
  devtoolsHookEmit("rendering");
@@ -12371,12 +12405,12 @@
12371
12405
  // When we have a matched route other than an abstract route,
12372
12406
  // we say *page found*, otherwise, *page not found*.
12373
12407
  if (route && route.type !== "routes" || failed) {
12374
- var _this3$kernel$bootstr3, _this3$kernel$bootstr4, _getAuth$license;
12408
+ var _currentApp5, _this3$kernel$bootstr3, _this3$kernel$bootstr4, _getAuth$license;
12375
12409
  if (!failed) {
12376
12410
  yield pendingTask;
12377
12411
  }
12378
12412
  window.DISABLE_REACT_FLUSH_SYNC = false;
12379
- setUIVersion(currentApp === null || currentApp === void 0 ? void 0 : currentApp.uiVersion);
12413
+ setUIVersion((_currentApp5 = currentApp) === null || _currentApp5 === void 0 ? void 0 : _currentApp5.uiVersion);
12380
12414
  main.length > 0 && mountTree(main, mountPoints.main);
12381
12415
  portal.length > 0 && mountTree(portal, mountPoints.portal);
12382
12416
  afterMountTree(mountPoints.main);