@json-render/react-native 0.18.0 → 0.20.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.mjs CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  import {
6
6
  elementTreeSchema,
7
7
  schema
8
- } from "./chunk-T27PQA6P.mjs";
8
+ } from "./chunk-TAJ5ASZ5.mjs";
9
9
 
10
10
  // ../react-state/dist/index.mjs
11
11
  import {
@@ -334,9 +334,8 @@ function ActionProvider({
334
334
  handler,
335
335
  setState: set,
336
336
  navigate,
337
- executeAction: async (name) => {
338
- const subBinding = { action: name };
339
- await execute(subBinding);
337
+ executeAction: async (binding2) => {
338
+ await execute(binding2);
340
339
  }
341
340
  });
342
341
  } finally {
@@ -355,9 +354,8 @@ function ActionProvider({
355
354
  handler,
356
355
  setState: set,
357
356
  navigate,
358
- executeAction: async (name) => {
359
- const subBinding = { action: name };
360
- await execute(subBinding);
357
+ executeAction: async (binding2) => {
358
+ await execute(binding2);
361
359
  }
362
360
  });
363
361
  } finally {
@@ -711,6 +709,8 @@ import {
711
709
  resolveElementProps,
712
710
  resolveBindings,
713
711
  resolveActionParam,
712
+ resolveRepeatItemStatePath,
713
+ resolveRepeatStatePath,
714
714
  evaluateVisibility as evaluateVisibility2,
715
715
  getByPath as getByPath3
716
716
  } from "@json-render/core";
@@ -1030,8 +1030,10 @@ The current spec state is provided. Continue generating from where you left off.
1030
1030
  if (!enableValidation || !currentSpec.root) {
1031
1031
  break;
1032
1032
  }
1033
- const { spec: fixedSpec, fixes } = autoFixSpec(currentSpec);
1034
- if (fixes.length > 0) {
1033
+ const { spec: fixedSpec, fixDetails } = autoFixSpec(currentSpec, {
1034
+ lossy: retriesUsed >= maxRetries
1035
+ });
1036
+ if (fixDetails.length > 0) {
1035
1037
  currentSpec = fixedSpec;
1036
1038
  setSpec({ ...currentSpec });
1037
1039
  }
@@ -1052,6 +1054,19 @@ The current spec state is provided. Continue generating from where you left off.
1052
1054
 
1053
1055
  ` + issueText;
1054
1056
  }
1057
+ if (enableValidation && retriesUsed >= maxRetries && currentSpec.root) {
1058
+ const finalValidation = validateSpec(currentSpec);
1059
+ if (!finalValidation.valid) {
1060
+ const issueText = formatSpecIssues(finalValidation.issues);
1061
+ const validationError = new Error(
1062
+ `Spec validation failed after ${maxRetries} retries:
1063
+ ${issueText}`
1064
+ );
1065
+ setError(validationError);
1066
+ onError?.(validationError);
1067
+ return;
1068
+ }
1069
+ }
1055
1070
  onComplete?.(currentSpec);
1056
1071
  } catch (err) {
1057
1072
  if (err.name === "AbortError") {
@@ -2062,8 +2077,18 @@ function RepeatChildren({
2062
2077
  fallback
2063
2078
  }) {
2064
2079
  const { state } = useStateStore();
2080
+ const parentScope = useRepeatScope();
2065
2081
  const repeat = element.repeat;
2066
- const statePath = repeat.statePath;
2082
+ const statePath = resolveRepeatStatePath(
2083
+ repeat.statePath,
2084
+ parentScope?.basePath
2085
+ );
2086
+ if (statePath === void 0) {
2087
+ console.warn(
2088
+ "[json-render/react-native] $item in repeat.statePath used outside of a repeat scope"
2089
+ );
2090
+ return null;
2091
+ }
2067
2092
  const items = getByPath3(state, statePath) ?? [];
2068
2093
  return /* @__PURE__ */ jsx7(Fragment, { children: items.map((itemValue, index) => {
2069
2094
  const key = repeat.key && typeof itemValue === "object" && itemValue !== null ? String(
@@ -2074,7 +2099,7 @@ function RepeatChildren({
2074
2099
  {
2075
2100
  item: itemValue,
2076
2101
  index,
2077
- basePath: `${statePath}/${index}`,
2102
+ basePath: resolveRepeatItemStatePath(statePath, index),
2078
2103
  children: element.children?.map((childKey) => {
2079
2104
  const childElement = spec.elements[childKey];
2080
2105
  if (!childElement) {