@next-core/brick-kit 2.179.7 → 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.
@@ -1797,6 +1797,43 @@
1797
1797
  return true;
1798
1798
  }
1799
1799
 
1800
+ var realTimeDataInspectRoot;
1801
+ var RealTimeDataInspectHooks = [];
1802
+ function setRealTimeDataInspectRoot(root) {
1803
+ realTimeDataInspectRoot = root;
1804
+ var data = Object.fromEntries([..._dev_only_getAllContextValues({
1805
+ tplContextId: root.tplStateStoreId
1806
+ })].filter(_ref => {
1807
+ var [, item] = _ref;
1808
+ return item.type === "free-variable";
1809
+ }).map(_ref2 => {
1810
+ var [k, item] = _ref2;
1811
+ return [k, item.value];
1812
+ }));
1813
+ callRealTimeDataInspectHooks({
1814
+ changeType: "initialize",
1815
+ tplStateStoreId: root.tplStateStoreId,
1816
+ detail: {
1817
+ data
1818
+ }
1819
+ });
1820
+ }
1821
+ function addRealTimeDataInspectHook(hook) {
1822
+ RealTimeDataInspectHooks.push(hook);
1823
+ }
1824
+ function callRealTimeDataInspectHooks(detail) {
1825
+ setTimeout(() => {
1826
+ for (var hook of RealTimeDataInspectHooks) {
1827
+ try {
1828
+ hook(detail);
1829
+ } catch (error) {
1830
+ // eslint-disable-next-line no-console
1831
+ console.error("RealTimeDataInspectHook failed (".concat(detail.changeType, "):"), error);
1832
+ }
1833
+ }
1834
+ });
1835
+ }
1836
+
1800
1837
  class StoryboardContextWrapper {
1801
1838
  constructor(tplContextId, formContextId, renderId) {
1802
1839
  _defineProperty__default["default"](this, "data", new Map());
@@ -1829,6 +1866,23 @@
1829
1866
  var _this$data$get;
1830
1867
  return (_this$data$get = this.data.get(name)) === null || _this$data$get === void 0 ? void 0 : _this$data$get.value;
1831
1868
  }
1869
+ notifyRealTimeDataChange(name, value) {
1870
+ if (realTimeDataInspectRoot) {
1871
+ var {
1872
+ tplStateStoreId
1873
+ } = realTimeDataInspectRoot;
1874
+ if (tplStateStoreId ? this.tplContextId === tplStateStoreId : !this.tplContextId && !this.formContextId) {
1875
+ callRealTimeDataInspectHooks({
1876
+ changeType: "update",
1877
+ tplStateStoreId,
1878
+ detail: {
1879
+ name,
1880
+ value
1881
+ }
1882
+ });
1883
+ }
1884
+ }
1885
+ }
1832
1886
  getAffectListByContext(name) {
1833
1887
  var affectNames = [name];
1834
1888
  this.data.forEach((value, key) => {
@@ -2199,6 +2253,9 @@
2199
2253
  newContext.eventTarget.addEventListener(eventName, listenerFactory(handler, mergedContext, brick));
2200
2254
  }
2201
2255
  }
2256
+ newContext.eventTarget.addEventListener(eventName, e => {
2257
+ storyboardContextWrapper.notifyRealTimeDataChange(contextConf.name, e.detail);
2258
+ });
2202
2259
  if (contextConf.track) {
2203
2260
  var isTemplateState = !!storyboardContextWrapper.tplContextId;
2204
2261
  var isFormState = !!storyboardContextWrapper.formContextId;
@@ -14131,7 +14188,9 @@
14131
14188
  getAddedContracts: _dev_only_getAddedContracts,
14132
14189
  getContextValue: _dev_only_getContextValue,
14133
14190
  getAllContextValues: _dev_only_getAllContextValues,
14134
- render: _dev_only_render
14191
+ render: _dev_only_render,
14192
+ setRealTimeDataInspectRoot,
14193
+ addRealTimeDataInspectHook
14135
14194
  };
14136
14195
 
14137
14196
  var _excluded$2 = ["type"];