@xmachines/json-render-react 0.21.0-xm.7 → 0.23.1-xm.1

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.d.mts CHANGED
@@ -460,7 +460,8 @@ interface DefineRegistryResult {
460
460
  /**
461
461
  * Create ActionProvider-compatible handlers.
462
462
  * Accepts getter functions so handlers always read the latest state/setState
463
- * (e.g. from React refs).
463
+ * (e.g. from React refs). When `getSetState` returns `undefined`, actions
464
+ * still run and receive a no-op setter, so state updates are discarded.
464
465
  */
465
466
  handlers: (getSetState: () => SetState | undefined, getState: () => StateModel) => Record<string, (params: Record<string, unknown>) => Promise<void>>;
466
467
  /**
package/dist/index.d.ts CHANGED
@@ -460,7 +460,8 @@ interface DefineRegistryResult {
460
460
  /**
461
461
  * Create ActionProvider-compatible handlers.
462
462
  * Accepts getter functions so handlers always read the latest state/setState
463
- * (e.g. from React refs).
463
+ * (e.g. from React refs). When `getSetState` returns `undefined`, actions
464
+ * still run and receive a no-op setter, so state updates are discarded.
464
465
  */
465
466
  handlers: (getSetState: () => SetState | undefined, getState: () => StateModel) => Record<string, (params: Record<string, unknown>) => Promise<void>>;
466
467
  /**
package/dist/index.js CHANGED
@@ -1686,11 +1686,9 @@ function defineRegistry(catalog, options) {
1686
1686
  const result = {};
1687
1687
  for (const [name, actionFn] of actionMap) {
1688
1688
  result[name] = async (params) => {
1689
- const setState = getSetState();
1689
+ const setState = getSetState() ?? (() => void 0);
1690
1690
  const state = getState();
1691
- if (setState) {
1692
- await actionFn(params, setState, state);
1693
- }
1691
+ await actionFn(params, setState, state);
1694
1692
  };
1695
1693
  }
1696
1694
  return result;
@@ -2067,6 +2065,9 @@ function isSpecDataPart(data) {
2067
2065
  return false;
2068
2066
  }
2069
2067
  }
2068
+ function cloneJson(value) {
2069
+ return JSON.parse(JSON.stringify(value));
2070
+ }
2070
2071
  function buildSpecFromParts(parts) {
2071
2072
  const spec = { root: "", elements: {} };
2072
2073
  let hasSpec = false;
@@ -2076,13 +2077,13 @@ function buildSpecFromParts(parts) {
2076
2077
  const payload = part.data;
2077
2078
  if (payload.type === "patch") {
2078
2079
  hasSpec = true;
2079
- (0, import_core10.applySpecPatch)(spec, payload.patch);
2080
+ (0, import_core10.applySpecPatch)(spec, cloneJson(payload.patch));
2080
2081
  } else if (payload.type === "flat") {
2081
2082
  hasSpec = true;
2082
- Object.assign(spec, payload.spec);
2083
+ Object.assign(spec, cloneJson(payload.spec));
2083
2084
  } else if (payload.type === "nested") {
2084
2085
  hasSpec = true;
2085
- const flat = (0, import_core10.nestedToFlat)(payload.spec);
2086
+ const flat = (0, import_core10.nestedToFlat)(cloneJson(payload.spec));
2086
2087
  Object.assign(spec, flat);
2087
2088
  }
2088
2089
  }