attaform 0.26.0 → 0.27.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.
Files changed (163) hide show
  1. package/README.md +21 -11
  2. package/bin/attaform.mjs +125 -0
  3. package/dist/abstract.cjs +47 -0
  4. package/dist/abstract.cjs.map +1 -0
  5. package/dist/abstract.d.cts +42 -0
  6. package/dist/abstract.d.mts +42 -0
  7. package/dist/abstract.d.ts +42 -0
  8. package/dist/abstract.mjs +4 -0
  9. package/dist/abstract.mjs.map +1 -0
  10. package/dist/chunks/devtools.cjs +2 -2
  11. package/dist/chunks/devtools.cjs.map +1 -1
  12. package/dist/chunks/devtools.mjs +1 -1
  13. package/dist/chunks/fingerprint2.cjs +1 -1
  14. package/dist/chunks/fingerprint2.mjs +1 -1
  15. package/dist/esbuild.cjs +2 -2
  16. package/dist/esbuild.cjs.map +1 -1
  17. package/dist/esbuild.d.cts +3 -3
  18. package/dist/esbuild.d.mts +3 -3
  19. package/dist/esbuild.d.ts +3 -3
  20. package/dist/esbuild.mjs +2 -2
  21. package/dist/esbuild.mjs.map +1 -1
  22. package/dist/index.cjs +41 -56
  23. package/dist/index.cjs.map +1 -1
  24. package/dist/index.d.cts +194 -282
  25. package/dist/index.d.mts +194 -282
  26. package/dist/index.d.ts +194 -282
  27. package/dist/index.mjs +4 -25
  28. package/dist/index.mjs.map +1 -1
  29. package/dist/nuxt.cjs +3 -1
  30. package/dist/nuxt.cjs.map +1 -1
  31. package/dist/nuxt.d.cts +17 -4
  32. package/dist/nuxt.d.mts +17 -4
  33. package/dist/nuxt.d.ts +17 -4
  34. package/dist/nuxt.mjs +4 -2
  35. package/dist/nuxt.mjs.map +1 -1
  36. package/dist/rollup.cjs +2 -2
  37. package/dist/rollup.cjs.map +1 -1
  38. package/dist/rollup.d.cts +3 -3
  39. package/dist/rollup.d.mts +3 -3
  40. package/dist/rollup.d.ts +3 -3
  41. package/dist/rollup.mjs +2 -2
  42. package/dist/rollup.mjs.map +1 -1
  43. package/dist/rspack.cjs +1 -1
  44. package/dist/rspack.d.cts +1 -1
  45. package/dist/rspack.d.mts +1 -1
  46. package/dist/rspack.d.ts +1 -1
  47. package/dist/rspack.mjs +1 -1
  48. package/dist/runtime/plugins/attaform.cjs +4 -5
  49. package/dist/runtime/plugins/attaform.cjs.map +1 -1
  50. package/dist/runtime/plugins/attaform.mjs +1 -2
  51. package/dist/runtime/plugins/attaform.mjs.map +1 -1
  52. package/dist/shared/{attaform.BRzKBj2g.cjs → attaform.8tFZu1Ub.cjs} +2 -2
  53. package/dist/shared/{attaform.BRzKBj2g.cjs.map → attaform.8tFZu1Ub.cjs.map} +1 -1
  54. package/dist/shared/{attaform.k9V0py0s.mjs → attaform.BERt5YMU.mjs} +2 -2
  55. package/dist/shared/{attaform.k9V0py0s.mjs.map → attaform.BERt5YMU.mjs.map} +1 -1
  56. package/dist/shared/{attaform.DSOIz08n.mjs → attaform.BceJrhQ7.mjs} +5 -5
  57. package/dist/shared/{attaform.DSOIz08n.mjs.map → attaform.BceJrhQ7.mjs.map} +1 -1
  58. package/dist/shared/{attaform.DBNjHgNj.d.cts → attaform.C3WnCDXz.d.cts} +11 -9
  59. package/dist/shared/{attaform.DBNjHgNj.d.mts → attaform.C3WnCDXz.d.mts} +11 -9
  60. package/dist/shared/{attaform.DBNjHgNj.d.ts → attaform.C3WnCDXz.d.ts} +11 -9
  61. package/dist/shared/{attaform.DuzQYscR.d.mts → attaform.C9fPTxjB.d.cts} +5 -5
  62. package/dist/shared/{attaform.DuzQYscR.d.ts → attaform.C9fPTxjB.d.mts} +5 -5
  63. package/dist/shared/{attaform.DuzQYscR.d.cts → attaform.C9fPTxjB.d.ts} +5 -5
  64. package/dist/shared/{attaform.Be5otUVw.d.ts → attaform.CC_y1_Ej.d.ts} +33 -33
  65. package/dist/shared/{attaform.ceYeVkjn.d.ts → attaform.CEXUlUkc.d.ts} +1579 -1192
  66. package/dist/shared/{attaform.tZ0YKisf.cjs → attaform.C__F01CE.cjs} +15 -15
  67. package/dist/shared/{attaform.tZ0YKisf.cjs.map → attaform.C__F01CE.cjs.map} +1 -1
  68. package/dist/shared/{attaform.BPl-ECRT.cjs → attaform.Co5LNRnv.cjs} +162 -129
  69. package/dist/shared/attaform.Co5LNRnv.cjs.map +1 -0
  70. package/dist/shared/{attaform.B71rfNL5.d.mts → attaform.CpXHK60W.d.cts} +33 -33
  71. package/dist/shared/{attaform.BFfY7HRI.d.cts → attaform.CvVYOvZF.d.mts} +33 -33
  72. package/dist/shared/{attaform.BoYqnIPI.mjs → attaform.CyQxTOdX.mjs} +55 -36
  73. package/dist/shared/attaform.CyQxTOdX.mjs.map +1 -0
  74. package/dist/shared/{attaform.CEY_WLRJ.d.mts → attaform.D99pd7JG.d.cts} +1579 -1192
  75. package/dist/shared/{attaform.CXVmZtFq.mjs → attaform.DDAmSFnl.mjs} +4 -4
  76. package/dist/shared/{attaform.CXVmZtFq.mjs.map → attaform.DDAmSFnl.mjs.map} +1 -1
  77. package/dist/shared/{attaform.Du9RZp8m.cjs → attaform.DQT7_-FO.cjs} +272 -252
  78. package/dist/shared/attaform.DQT7_-FO.cjs.map +1 -0
  79. package/dist/shared/{attaform.DGhIix5D.mjs → attaform.Da8EdI2t.mjs} +160 -129
  80. package/dist/shared/attaform.Da8EdI2t.mjs.map +1 -0
  81. package/dist/shared/{attaform.Cs0UZ7q6.cjs → attaform.DhVgG2jh.cjs} +16 -16
  82. package/dist/shared/{attaform.Cs0UZ7q6.cjs.map → attaform.DhVgG2jh.cjs.map} +1 -1
  83. package/dist/shared/{attaform.sHkHv_98.mjs → attaform.DhnPb6nK.mjs} +6 -3
  84. package/dist/shared/attaform.DhnPb6nK.mjs.map +1 -0
  85. package/dist/shared/attaform.DkD0DR7R.mjs +42 -0
  86. package/dist/shared/attaform.DkD0DR7R.mjs.map +1 -0
  87. package/dist/shared/{attaform.CSXDW2tO.mjs → attaform.DlSu08F5.mjs} +4 -4
  88. package/dist/shared/{attaform.CSXDW2tO.mjs.map → attaform.DlSu08F5.mjs.map} +1 -1
  89. package/dist/shared/{attaform.LEWUFqUw.cjs → attaform.DoQm_Vkd.cjs} +7 -3
  90. package/dist/shared/attaform.DoQm_Vkd.cjs.map +1 -0
  91. package/dist/shared/{attaform.BQflyVOL.cjs → attaform.Drsi43GG.cjs} +19 -19
  92. package/dist/shared/{attaform.BQflyVOL.cjs.map → attaform.Drsi43GG.cjs.map} +1 -1
  93. package/dist/shared/attaform.K6Thc6By.cjs +46 -0
  94. package/dist/shared/attaform.K6Thc6By.cjs.map +1 -0
  95. package/dist/shared/{attaform.Vp2-CWZB.mjs → attaform.KvlEedlF.mjs} +3 -3
  96. package/dist/shared/{attaform.Vp2-CWZB.mjs.map → attaform.KvlEedlF.mjs.map} +1 -1
  97. package/dist/shared/{attaform.BRGIpZo4.cjs → attaform.RaTzp1WF.cjs} +3 -3
  98. package/dist/shared/attaform.RaTzp1WF.cjs.map +1 -0
  99. package/dist/shared/{attaform.MgaYKlPP.d.cts → attaform.kBkYlKP_.d.mts} +1579 -1192
  100. package/dist/shared/{attaform.C3Doa9Pt.mjs → attaform.v0fQtWyA.mjs} +3 -3
  101. package/dist/shared/attaform.v0fQtWyA.mjs.map +1 -0
  102. package/dist/shared/{attaform.ZXZ6dH72.cjs → attaform.yUrz7C2z.cjs} +3 -3
  103. package/dist/shared/{attaform.ZXZ6dH72.cjs.map → attaform.yUrz7C2z.cjs.map} +1 -1
  104. package/dist/transforms.cjs +1 -1
  105. package/dist/transforms.mjs +1 -1
  106. package/dist/vite.cjs +21 -3
  107. package/dist/vite.cjs.map +1 -1
  108. package/dist/vite.d.cts +70 -17
  109. package/dist/vite.d.mts +70 -17
  110. package/dist/vite.d.ts +70 -17
  111. package/dist/vite.mjs +20 -4
  112. package/dist/vite.mjs.map +1 -1
  113. package/dist/webpack.cjs +1 -1
  114. package/dist/webpack.d.cts +1 -1
  115. package/dist/webpack.d.mts +1 -1
  116. package/dist/webpack.d.ts +1 -1
  117. package/dist/webpack.mjs +1 -1
  118. package/dist/zod-v3.cjs +41 -10
  119. package/dist/zod-v3.cjs.map +1 -1
  120. package/dist/zod-v3.d.cts +5 -5
  121. package/dist/zod-v3.d.mts +5 -5
  122. package/dist/zod-v3.d.ts +5 -5
  123. package/dist/zod-v3.mjs +4 -2
  124. package/dist/zod-v3.mjs.map +1 -1
  125. package/dist/zod-v4.cjs +41 -10
  126. package/dist/zod-v4.cjs.map +1 -1
  127. package/dist/zod-v4.d.cts +7 -7
  128. package/dist/zod-v4.d.mts +7 -7
  129. package/dist/zod-v4.d.ts +7 -7
  130. package/dist/zod-v4.mjs +4 -2
  131. package/dist/zod-v4.mjs.map +1 -1
  132. package/dist/zod.cjs +44 -49
  133. package/dist/zod.cjs.map +1 -1
  134. package/dist/zod.d.cts +6 -248
  135. package/dist/zod.d.mts +6 -248
  136. package/dist/zod.d.ts +6 -248
  137. package/dist/zod.mjs +4 -42
  138. package/dist/zod.mjs.map +1 -1
  139. package/package.json +12 -2
  140. package/skills/attaform/SKILL.md +128 -0
  141. package/skills/attaform/references/custom-components.md +72 -0
  142. package/skills/attaform/references/errors.md +62 -0
  143. package/skills/attaform/references/ssr.md +26 -0
  144. package/skills/attaform/references/validation.md +40 -0
  145. package/skills/attaform/references/wizards.md +104 -0
  146. package/dist/shared/attaform.55hFR_cl.d.ts +0 -97
  147. package/dist/shared/attaform.BPl-ECRT.cjs.map +0 -1
  148. package/dist/shared/attaform.BRGIpZo4.cjs.map +0 -1
  149. package/dist/shared/attaform.BoYqnIPI.mjs.map +0 -1
  150. package/dist/shared/attaform.C3Doa9Pt.mjs.map +0 -1
  151. package/dist/shared/attaform.D51IwDtP.cjs +0 -39
  152. package/dist/shared/attaform.D51IwDtP.cjs.map +0 -1
  153. package/dist/shared/attaform.DGhIix5D.mjs.map +0 -1
  154. package/dist/shared/attaform.DJRz_bzM.d.cts +0 -97
  155. package/dist/shared/attaform.Du9RZp8m.cjs.map +0 -1
  156. package/dist/shared/attaform.JPsaqjLl.d.mts +0 -97
  157. package/dist/shared/attaform.LEWUFqUw.cjs.map +0 -1
  158. package/dist/shared/attaform.NqYEzRcM.mjs +0 -35
  159. package/dist/shared/attaform.NqYEzRcM.mjs.map +0 -1
  160. package/dist/shared/attaform.sHkHv_98.mjs.map +0 -1
  161. package/dist/shared/{attaform.DdjDqTah.d.ts → attaform.DRUT703x.d.cts} +14 -14
  162. package/dist/shared/{attaform.DdjDqTah.d.cts → attaform.DRUT703x.d.mts} +14 -14
  163. package/dist/shared/{attaform.DdjDqTah.d.mts → attaform.DRUT703x.d.ts} +14 -14
@@ -1,9 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  const vue = require('vue');
4
- const registerProtocol = require('./attaform.ZXZ6dH72.cjs');
5
-
6
- const __DEV__ = (typeof process !== "undefined" ? process.env.NODE_ENV : "production") !== "production";
4
+ const registerProtocol = require('./attaform.yUrz7C2z.cjs');
7
5
 
8
6
  class AttaformError extends Error {
9
7
  constructor(message, options) {
@@ -71,20 +69,140 @@ class ReservedFormKeyError extends AttaformError {
71
69
  }
72
70
  }
73
71
 
72
+ const INTEGER_SEGMENT = /^(?:0|[1-9]\d*)$/;
73
+ function normalizeSegment(raw) {
74
+ if (typeof raw === "number") {
75
+ if (!Number.isInteger(raw) || raw < 0) {
76
+ throw new InvalidPathError(
77
+ `Path segments must be non-negative integers when numeric; got ${String(raw)}`
78
+ );
79
+ }
80
+ return raw;
81
+ }
82
+ if (INTEGER_SEGMENT.test(raw)) return Number(raw);
83
+ return raw;
84
+ }
85
+ function parseDottedPath(path) {
86
+ if (path.length === 0) return [""];
87
+ const rawSegments = path.split(".");
88
+ const segments = [];
89
+ for (const raw of rawSegments) {
90
+ if (raw.length === 0) {
91
+ throw new InvalidPathError(
92
+ `Path '${path}' has an empty segment; use the array form for empty keys.`
93
+ );
94
+ }
95
+ segments.push(normalizeSegment(raw));
96
+ }
97
+ return segments;
98
+ }
99
+ const CANONICAL_STRING_CACHE_MAX = 128;
100
+ const canonicalStringCache = /* @__PURE__ */ new Map();
101
+ const PATHKEY_TO_SEGMENTS_MAX = 4096;
102
+ const pathKeyToSegments = /* @__PURE__ */ new Map();
103
+ function rememberSegmentsForPathKey(key, segments) {
104
+ if (!pathKeyToSegments.has(key) && pathKeyToSegments.size >= PATHKEY_TO_SEGMENTS_MAX) {
105
+ const oldest = pathKeyToSegments.keys().next().value;
106
+ if (oldest !== void 0) pathKeyToSegments.delete(oldest);
107
+ }
108
+ pathKeyToSegments.set(key, segments);
109
+ }
110
+ function segmentsForPathKey(key) {
111
+ const cached = pathKeyToSegments.get(key);
112
+ if (cached !== void 0) return cached;
113
+ let parsed;
114
+ try {
115
+ parsed = JSON.parse(key);
116
+ } catch {
117
+ return null;
118
+ }
119
+ if (!Array.isArray(parsed)) return null;
120
+ const segments = [];
121
+ for (const raw of parsed) {
122
+ if (typeof raw !== "string" && typeof raw !== "number") return null;
123
+ segments.push(normalizeSegment(raw));
124
+ }
125
+ rememberSegmentsForPathKey(key, segments);
126
+ return segments;
127
+ }
128
+ function canonicalizePath(input) {
129
+ if (typeof input === "string") {
130
+ const cached = canonicalStringCache.get(input);
131
+ if (cached !== void 0) return cached;
132
+ const segments = parseDottedPath(input);
133
+ const key = JSON.stringify(segments);
134
+ const entry = { segments, key };
135
+ if (canonicalStringCache.size >= CANONICAL_STRING_CACHE_MAX) {
136
+ const oldest = canonicalStringCache.keys().next().value;
137
+ if (oldest !== void 0) canonicalStringCache.delete(oldest);
138
+ }
139
+ canonicalStringCache.set(input, entry);
140
+ rememberSegmentsForPathKey(key, segments);
141
+ return entry;
142
+ }
143
+ return keyForSegments(input);
144
+ }
145
+ function keyForSegments(input) {
146
+ const segments = Array.from(input).map(normalizeSegment);
147
+ const key = JSON.stringify(segments);
148
+ rememberSegmentsForPathKey(key, segments);
149
+ return { segments, key };
150
+ }
151
+ function segmentsToDotted(segments) {
152
+ return segments.join(".");
153
+ }
154
+ function pathKeyToDotted(key) {
155
+ const segments = segmentsForPathKey(key);
156
+ if (segments === null) return null;
157
+ return segmentsToDotted(segments);
158
+ }
159
+ function coerceToPathKey(input) {
160
+ if (input.length > 0 && input.charCodeAt(0) === 91) {
161
+ try {
162
+ const parsed = JSON.parse(input);
163
+ if (Array.isArray(parsed) && parsed.every((s) => typeof s === "string" || typeof s === "number")) {
164
+ return input;
165
+ }
166
+ } catch {
167
+ }
168
+ }
169
+ return canonicalizePath(input).key;
170
+ }
171
+ const ROOT_PATH = Object.freeze([]);
172
+ const ROOT_PATH_KEY = "[]";
173
+ function isPathPrefix(prefix, path) {
174
+ if (path.length < prefix.length) return false;
175
+ for (let i = 0; i < prefix.length; i++) {
176
+ if (path[i] !== prefix[i]) return false;
177
+ }
178
+ return true;
179
+ }
180
+ function pathsEqual(a, b) {
181
+ if (a.length !== b.length) return false;
182
+ for (let i = 0; i < a.length; i++) {
183
+ if (a[i] !== b[i]) return false;
184
+ }
185
+ return true;
186
+ }
187
+
188
+ const __DEV__ = (typeof process !== "undefined" ? process.env.NODE_ENV : "production") !== "production";
189
+
190
+ const INTERACTIVE_TAG_NAMES = /* @__PURE__ */ new Set(["INPUT", "SELECT", "TEXTAREA"]);
191
+
74
192
  function detectSSR(options = {}) {
75
193
  if (options.ssr !== void 0) return options.ssr;
76
194
  return typeof window === "undefined" && typeof document === "undefined";
77
195
  }
78
196
 
79
- const kAttaformRegistry = Symbol.for("attaform:registry");
80
- const kAttaformAncestorWizard = Symbol.for(
197
+ const kAttaformRegistry = /* @__PURE__ */ Symbol.for("attaform:registry");
198
+ const kAttaformAncestorWizard = /* @__PURE__ */ Symbol.for(
81
199
  "attaform:ancestor-wizard"
82
200
  );
83
- const kAttaformWizardActiveStepResolver = Symbol.for(
201
+ const kAttaformWizardActiveStepResolver = /* @__PURE__ */ Symbol.for(
84
202
  "attaform:wizard-active-step-resolver"
85
203
  );
86
- const kFormContext = Symbol.for("attaform:form-context");
87
- const kFormInstanceId = Symbol.for("attaform:form-instance-id");
204
+ const kFormContext = /* @__PURE__ */ Symbol.for("attaform:form-context");
205
+ const kFormInstanceId = /* @__PURE__ */ Symbol.for("attaform:form-instance-id");
88
206
  function createRegistry(options = {}) {
89
207
  const ssr = detectSSR(options);
90
208
  const defaults = Object.freeze({ ...options.defaults ?? {} });
@@ -284,16 +402,14 @@ function invokeArrayFns(fns, ...args) {
284
402
  }
285
403
  }
286
404
 
287
- const INTERACTIVE_TAG_NAMES = /* @__PURE__ */ new Set(["INPUT", "SELECT", "TEXTAREA"]);
288
-
289
405
  const MANAGED_ARIA_ATTRS = [
290
406
  "aria-invalid",
291
407
  "aria-busy",
292
408
  "aria-required",
293
409
  "aria-describedby"
294
410
  ];
295
- const ariaLockKey = Symbol.for("attaform:aria-locks");
296
- const ariaScopeKey = Symbol.for("attaform:aria-scope");
411
+ const ariaLockKey = /* @__PURE__ */ Symbol.for("attaform:aria-locks");
412
+ const ariaScopeKey = /* @__PURE__ */ Symbol.for("attaform:aria-scope");
297
413
  const EMPTY_ARIA_LOCKS = /* @__PURE__ */ new Set();
298
414
  function mergeAriaLocks(el, vnode) {
299
415
  let locks = el[ariaLockKey];
@@ -410,7 +526,7 @@ function teardownAria(el) {
410
526
  delete el[ariaLockKey];
411
527
  }
412
528
 
413
- const listenersKey = Symbol.for("attaform:directive-listeners");
529
+ const listenersKey = /* @__PURE__ */ Symbol.for("attaform:directive-listeners");
414
530
  function addTrackedListener(el, event, handler, options) {
415
531
  el.addEventListener(event, handler, options);
416
532
  const carrier = el;
@@ -434,12 +550,12 @@ function isRegisterValueLike(val) {
434
550
  return typeof val === "object" && val !== null && "markInteracted" in val && typeof val.markInteracted === "function";
435
551
  }
436
552
 
437
- const assignKey = Symbol.for("attaform:assign-key");
438
- const DEFAULT_ASSIGNER_TAG = Symbol.for("attaform:default-assigner-tag");
553
+ const assignKey = /* @__PURE__ */ Symbol.for("attaform:assign-key");
554
+ const DEFAULT_ASSIGNER_TAG = /* @__PURE__ */ Symbol.for("attaform:default-assigner-tag");
439
555
  function isDefaultAssigner(fn) {
440
556
  return typeof fn === "function" && fn[DEFAULT_ASSIGNER_TAG] === true;
441
557
  }
442
- const CONSUMER_WRAPPED_TAG = Symbol.for("attaform:consumer-wrapped-assigner");
558
+ const CONSUMER_WRAPPED_TAG = /* @__PURE__ */ Symbol.for("attaform:consumer-wrapped-assigner");
443
559
  function isConsumerWrapped(fn) {
444
560
  return typeof fn === "function" && fn[CONSUMER_WRAPPED_TAG] === true;
445
561
  }
@@ -647,7 +763,7 @@ function readFilesFromInput(el) {
647
763
  if (files === null || files.length === 0) return null;
648
764
  return files.item(0);
649
765
  }
650
- const fileScopeKey = Symbol.for("attaform:file-scope");
766
+ const fileScopeKey = /* @__PURE__ */ Symbol.for("attaform:file-scope");
651
767
  const vRegisterFile = {
652
768
  created(el, { value }, vnode) {
653
769
  if (!registerProtocol.isRegisterValue(value)) return;
@@ -716,7 +832,7 @@ function syncElementRegistration(el, value, oldValue) {
716
832
  }
717
833
  }
718
834
 
719
- const valueSyncScopeKey = Symbol.for("attaform:value-sync-scope");
835
+ const valueSyncScopeKey = /* @__PURE__ */ Symbol.for("attaform:value-sync-scope");
720
836
  function isElementFocused(el) {
721
837
  const rootNode = el.getRootNode();
722
838
  const activeElement = rootNode instanceof Document || rootNode instanceof ShadowRoot ? rootNode.activeElement : null;
@@ -1500,123 +1616,39 @@ function createAttaform(options = {}) {
1500
1616
  return plugin;
1501
1617
  }
1502
1618
 
1503
- const INTEGER_SEGMENT = /^(?:0|[1-9]\d*)$/;
1504
- function normalizeSegment(raw) {
1505
- if (typeof raw === "number") {
1506
- if (!Number.isInteger(raw) || raw < 0) {
1507
- throw new InvalidPathError(
1508
- `Path segments must be non-negative integers when numeric; got ${String(raw)}`
1509
- );
1510
- }
1511
- return raw;
1512
- }
1513
- if (INTEGER_SEGMENT.test(raw)) return Number(raw);
1514
- return raw;
1515
- }
1516
- function parseDottedPath(path) {
1517
- if (path.length === 0) return [""];
1518
- const rawSegments = path.split(".");
1519
- const segments = [];
1520
- for (const raw of rawSegments) {
1521
- if (raw.length === 0) {
1522
- throw new InvalidPathError(
1523
- `Path '${path}' has an empty segment; use the array form for empty keys.`
1524
- );
1619
+ function renderAttaformState(app) {
1620
+ const registry = getRegistryFromApp(app);
1621
+ const forms = [];
1622
+ for (const [key, state] of registry.forms) {
1623
+ const transientList = [];
1624
+ for (const pk of state.blankPaths) {
1625
+ const d = pathKeyToDotted(pk);
1626
+ if (d !== null) transientList.push(d);
1525
1627
  }
1526
- segments.push(normalizeSegment(raw));
1527
- }
1528
- return segments;
1529
- }
1530
- const CANONICAL_STRING_CACHE_MAX = 128;
1531
- const canonicalStringCache = /* @__PURE__ */ new Map();
1532
- const PATHKEY_TO_SEGMENTS_MAX = 4096;
1533
- const pathKeyToSegments = /* @__PURE__ */ new Map();
1534
- function rememberSegmentsForPathKey(key, segments) {
1535
- if (!pathKeyToSegments.has(key) && pathKeyToSegments.size >= PATHKEY_TO_SEGMENTS_MAX) {
1536
- const oldest = pathKeyToSegments.keys().next().value;
1537
- if (oldest !== void 0) pathKeyToSegments.delete(oldest);
1538
- }
1539
- pathKeyToSegments.set(key, segments);
1540
- }
1541
- function segmentsForPathKey(key) {
1542
- const cached = pathKeyToSegments.get(key);
1543
- if (cached !== void 0) return cached;
1544
- let parsed;
1545
- try {
1546
- parsed = JSON.parse(key);
1547
- } catch {
1548
- return null;
1549
- }
1550
- if (!Array.isArray(parsed)) return null;
1551
- const segments = [];
1552
- for (const raw of parsed) {
1553
- if (typeof raw !== "string" && typeof raw !== "number") return null;
1554
- segments.push(normalizeSegment(raw));
1555
- }
1556
- rememberSegmentsForPathKey(key, segments);
1557
- return segments;
1558
- }
1559
- function canonicalizePath(input) {
1560
- if (typeof input === "string") {
1561
- const cached = canonicalStringCache.get(input);
1562
- if (cached !== void 0) return cached;
1563
- const segments = parseDottedPath(input);
1564
- const key = JSON.stringify(segments);
1565
- const entry = { segments, key };
1566
- if (canonicalStringCache.size >= CANONICAL_STRING_CACHE_MAX) {
1567
- const oldest = canonicalStringCache.keys().next().value;
1568
- if (oldest !== void 0) canonicalStringCache.delete(oldest);
1569
- }
1570
- canonicalStringCache.set(input, entry);
1571
- rememberSegmentsForPathKey(key, segments);
1572
- return entry;
1573
- }
1574
- return keyForSegments(input);
1575
- }
1576
- function keyForSegments(input) {
1577
- const segments = Array.from(input).map(normalizeSegment);
1578
- const key = JSON.stringify(segments);
1579
- rememberSegmentsForPathKey(key, segments);
1580
- return { segments, key };
1581
- }
1582
- function segmentsToDotted(segments) {
1583
- return segments.join(".");
1584
- }
1585
- function pathKeyToDotted(key) {
1586
- const segments = segmentsForPathKey(key);
1587
- if (segments === null) return null;
1588
- return segmentsToDotted(segments);
1589
- }
1590
- function coerceToPathKey(input) {
1591
- if (input.length > 0 && input.charCodeAt(0) === 91) {
1592
- try {
1593
- const parsed = JSON.parse(input);
1594
- if (Array.isArray(parsed) && parsed.every((s) => typeof s === "string" || typeof s === "number")) {
1595
- return input;
1628
+ forms.push([
1629
+ key,
1630
+ {
1631
+ form: state.form.value,
1632
+ schemaErrors: Array.from(state.schemaErrors.entries()),
1633
+ userErrors: Array.from(state.userErrors.entries()),
1634
+ fields: Array.from(state.fields.entries()),
1635
+ ...transientList.length > 0 ? { blankPaths: transientList } : {}
1596
1636
  }
1597
- } catch {
1598
- }
1637
+ ]);
1599
1638
  }
1600
- return canonicalizePath(input).key;
1639
+ return { forms };
1601
1640
  }
1602
- const ROOT_PATH = Object.freeze([]);
1603
- const ROOT_PATH_KEY = "[]";
1604
- function isPathPrefix(prefix, path) {
1605
- if (path.length < prefix.length) return false;
1606
- for (let i = 0; i < prefix.length; i++) {
1607
- if (path[i] !== prefix[i]) return false;
1608
- }
1609
- return true;
1610
- }
1611
- function pathsEqual(a, b) {
1612
- if (a.length !== b.length) return false;
1613
- for (let i = 0; i < a.length; i++) {
1614
- if (a[i] !== b[i]) return false;
1641
+ function hydrateAttaformState(app, payload) {
1642
+ const registry = getRegistryFromApp(app);
1643
+ for (const [key, data] of payload.forms) {
1644
+ registry.pendingHydration.set(key, data);
1615
1645
  }
1616
- return true;
1617
1646
  }
1618
1647
 
1648
+ const DEVTOOLS_WINDOW_KEY = "__attaform_devtools__";
1649
+
1619
1650
  exports.AttaformError = AttaformError;
1651
+ exports.DEVTOOLS_WINDOW_KEY = DEVTOOLS_WINDOW_KEY;
1620
1652
  exports.INTERACTIVE_TAG_NAMES = INTERACTIVE_TAG_NAMES;
1621
1653
  exports.InvalidPathError = InvalidPathError;
1622
1654
  exports.InvalidUseFormConfigError = InvalidUseFormConfigError;
@@ -1634,6 +1666,7 @@ exports.createAttaform = createAttaform;
1634
1666
  exports.createRegistry = createRegistry;
1635
1667
  exports.ensureAttaformInstalled = ensureAttaformInstalled;
1636
1668
  exports.getRegistryFromApp = getRegistryFromApp;
1669
+ exports.hydrateAttaformState = hydrateAttaformState;
1637
1670
  exports.isPathPrefix = isPathPrefix;
1638
1671
  exports.kAttaformAncestorWizard = kAttaformAncestorWizard;
1639
1672
  exports.kAttaformRegistry = kAttaformRegistry;
@@ -1644,10 +1677,10 @@ exports.keyForSegments = keyForSegments;
1644
1677
  exports.normalizeErrorInput = normalizeErrorInput;
1645
1678
  exports.normalizeErrorInputs = normalizeErrorInputs;
1646
1679
  exports.parseDottedPath = parseDottedPath;
1647
- exports.pathKeyToDotted = pathKeyToDotted;
1648
1680
  exports.pathsEqual = pathsEqual;
1681
+ exports.renderAttaformState = renderAttaformState;
1649
1682
  exports.segmentsForPathKey = segmentsForPathKey;
1650
1683
  exports.toError = toError;
1651
1684
  exports.useRegistry = useRegistry;
1652
1685
  exports.vRegister = vRegister;
1653
- //# sourceMappingURL=attaform.BPl-ECRT.cjs.map
1686
+ //# sourceMappingURL=attaform.Co5LNRnv.cjs.map