@next-core/brick-kit 2.179.6 → 2.180.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
@@ -1799,6 +1799,43 @@ function _checkIf(rawIf, ctx, fn) {
1799
1799
  return true;
1800
1800
  }
1801
1801
 
1802
+ var realTimeDataInspectRoot;
1803
+ var RealTimeDataInspectHooks = [];
1804
+ function setRealTimeDataInspectRoot(root) {
1805
+ realTimeDataInspectRoot = root;
1806
+ var data = Object.fromEntries([..._dev_only_getAllContextValues({
1807
+ tplContextId: root.tplStateStoreId
1808
+ })].filter(_ref => {
1809
+ var [, item] = _ref;
1810
+ return item.type === "free-variable";
1811
+ }).map(_ref2 => {
1812
+ var [k, item] = _ref2;
1813
+ return [k, item.value];
1814
+ }));
1815
+ callRealTimeDataInspectHooks({
1816
+ changeType: "initialize",
1817
+ tplStateStoreId: root.tplStateStoreId,
1818
+ detail: {
1819
+ data
1820
+ }
1821
+ });
1822
+ }
1823
+ function addRealTimeDataInspectHook(hook) {
1824
+ RealTimeDataInspectHooks.push(hook);
1825
+ }
1826
+ function callRealTimeDataInspectHooks(detail) {
1827
+ setTimeout(() => {
1828
+ for (var hook of RealTimeDataInspectHooks) {
1829
+ try {
1830
+ hook(detail);
1831
+ } catch (error) {
1832
+ // eslint-disable-next-line no-console
1833
+ console.error("RealTimeDataInspectHook failed (".concat(detail.changeType, "):"), error);
1834
+ }
1835
+ }
1836
+ });
1837
+ }
1838
+
1802
1839
  class StoryboardContextWrapper {
1803
1840
  constructor(tplContextId, formContextId, renderId) {
1804
1841
  _defineProperty$1(this, "data", new Map());
@@ -1831,6 +1868,23 @@ class StoryboardContextWrapper {
1831
1868
  var _this$data$get;
1832
1869
  return (_this$data$get = this.data.get(name)) === null || _this$data$get === void 0 ? void 0 : _this$data$get.value;
1833
1870
  }
1871
+ notifyRealTimeDataChange(name, value) {
1872
+ if (realTimeDataInspectRoot) {
1873
+ var {
1874
+ tplStateStoreId
1875
+ } = realTimeDataInspectRoot;
1876
+ if (tplStateStoreId ? this.tplContextId === tplStateStoreId : !this.tplContextId && !this.formContextId) {
1877
+ callRealTimeDataInspectHooks({
1878
+ changeType: "update",
1879
+ tplStateStoreId,
1880
+ detail: {
1881
+ name,
1882
+ value
1883
+ }
1884
+ });
1885
+ }
1886
+ }
1887
+ }
1834
1888
  getAffectListByContext(name) {
1835
1889
  var affectNames = [name];
1836
1890
  this.data.forEach((value, key) => {
@@ -2201,6 +2255,9 @@ function resolveFreeVariableValue(value, contextConf, mergedContext, storyboardC
2201
2255
  newContext.eventTarget.addEventListener(eventName, listenerFactory(handler, mergedContext, brick));
2202
2256
  }
2203
2257
  }
2258
+ newContext.eventTarget.addEventListener(eventName, e => {
2259
+ storyboardContextWrapper.notifyRealTimeDataChange(contextConf.name, e.detail);
2260
+ });
2204
2261
  if (contextConf.track) {
2205
2262
  var isTemplateState = !!storyboardContextWrapper.tplContextId;
2206
2263
  var isFormState = !!storyboardContextWrapper.formContextId;
@@ -12022,7 +12079,13 @@ class Router {
12022
12079
  } = getAuth();
12023
12080
  return "".concat(key, ":").concat(org);
12024
12081
  };
12025
- var renderTime = performance.now() - renderStartTime;
12082
+ var renderTime = Math.round(performance.now() - renderStartTime);
12083
+ // For bricks which would take actions with render time.
12084
+ window.dispatchEvent(new CustomEvent("route.render", {
12085
+ detail: {
12086
+ renderTime
12087
+ }
12088
+ }));
12026
12089
  var {
12027
12090
  loadTime = 0,
12028
12091
  loadInfoPage
@@ -14127,7 +14190,9 @@ var developHelper = {
14127
14190
  getAddedContracts: _dev_only_getAddedContracts,
14128
14191
  getContextValue: _dev_only_getContextValue,
14129
14192
  getAllContextValues: _dev_only_getAllContextValues,
14130
- render: _dev_only_render
14193
+ render: _dev_only_render,
14194
+ setRealTimeDataInspectRoot,
14195
+ addRealTimeDataInspectHook
14131
14196
  };
14132
14197
 
14133
14198
  var _excluded$2 = ["type"];