@next-core/brick-kit 2.179.7 → 2.181.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;
@@ -2536,9 +2593,15 @@
2536
2593
  }
2537
2594
  });
2538
2595
  case "QUERY":
2539
- return Object.fromEntries(Array.from(query.keys()).map(key => [key, query.get(key)]));
2596
+ {
2597
+ var params = options.useRealTimeQuery ? new URLSearchParams(getHistory().location.search) : query;
2598
+ return Object.fromEntries(Array.from(params.keys()).map(key => [key, params.get(key)]));
2599
+ }
2540
2600
  case "QUERY_ARRAY":
2541
- return Object.fromEntries(Array.from(query.keys()).map(key => [key, query.getAll(key)]));
2601
+ {
2602
+ var _params = options.useRealTimeQuery ? new URLSearchParams(getHistory().location.search) : query;
2603
+ return Object.fromEntries(Array.from(_params.keys()).map(key => [key, _params.getAll(key)]));
2604
+ }
2542
2605
  case "SEGUE":
2543
2606
  return {
2544
2607
  getUrl: getUrlBySegueFactory(app, segues)
@@ -14131,7 +14194,9 @@
14131
14194
  getAddedContracts: _dev_only_getAddedContracts,
14132
14195
  getContextValue: _dev_only_getContextValue,
14133
14196
  getAllContextValues: _dev_only_getAllContextValues,
14134
- render: _dev_only_render
14197
+ render: _dev_only_render,
14198
+ setRealTimeDataInspectRoot,
14199
+ addRealTimeDataInspectHook
14135
14200
  };
14136
14201
 
14137
14202
  var _excluded$2 = ["type"];
@@ -14733,10 +14798,15 @@
14733
14798
  * @returns Computed real value.
14734
14799
  */
14735
14800
  function getRealValue(value) {
14801
+ var {
14802
+ useRealTimeQuery
14803
+ } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
14736
14804
  var compute = (data, ctx) => {
14737
14805
  if (typeof data === "string") {
14738
14806
  if (brickUtils.isEvaluable(data)) {
14739
- var result = evaluate(data);
14807
+ var result = evaluate(data, undefined, {
14808
+ useRealTimeQuery
14809
+ });
14740
14810
  recursiveMarkAsInjected(result);
14741
14811
  return result;
14742
14812
  }