attaform 0.25.0 → 0.27.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.
Files changed (163) hide show
  1. package/README.md +21 -11
  2. package/bin/attaform.mjs +78 -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.CN4ZEGo6.mjs → attaform.BceJrhQ7.mjs} +5 -5
  57. package/dist/shared/{attaform.CN4ZEGo6.mjs.map → attaform.BceJrhQ7.mjs.map} +1 -1
  58. package/dist/shared/{attaform.i_LA3X9o.d.cts → attaform.C3WnCDXz.d.cts} +81 -24
  59. package/dist/shared/{attaform.i_LA3X9o.d.ts → attaform.C3WnCDXz.d.mts} +81 -24
  60. package/dist/shared/{attaform.i_LA3X9o.d.mts → attaform.C3WnCDXz.d.ts} +81 -24
  61. package/dist/shared/{attaform.DuzQYscR.d.ts → attaform.C9fPTxjB.d.cts} +5 -5
  62. package/dist/shared/{attaform.DuzQYscR.d.cts → attaform.C9fPTxjB.d.mts} +5 -5
  63. package/dist/shared/{attaform.DuzQYscR.d.mts → attaform.C9fPTxjB.d.ts} +5 -5
  64. package/dist/shared/{attaform.B3cgZE3c.d.ts → attaform.CC_y1_Ej.d.ts} +33 -33
  65. package/dist/shared/{attaform.DS_zBcdr.d.ts → attaform.CEXUlUkc.d.ts} +1588 -1190
  66. package/dist/shared/{attaform.Xe8dATED.cjs → attaform.C__F01CE.cjs} +15 -15
  67. package/dist/shared/{attaform.Xe8dATED.cjs.map → attaform.C__F01CE.cjs.map} +1 -1
  68. package/dist/shared/{attaform.3heDHayA.cjs → attaform.Co5LNRnv.cjs} +186 -129
  69. package/dist/shared/attaform.Co5LNRnv.cjs.map +1 -0
  70. package/dist/shared/{attaform.BJt4ZCkM.d.mts → attaform.CpXHK60W.d.cts} +33 -33
  71. package/dist/shared/{attaform.DmKLa4tL.d.cts → attaform.CvVYOvZF.d.mts} +33 -33
  72. package/dist/shared/{attaform.DK3xUBkj.mjs → attaform.CyQxTOdX.mjs} +162 -79
  73. package/dist/shared/attaform.CyQxTOdX.mjs.map +1 -0
  74. package/dist/shared/{attaform.B5GFS3Su.d.cts → attaform.D99pd7JG.d.cts} +1588 -1190
  75. package/dist/shared/{attaform.CwXXbZIQ.mjs → attaform.DDAmSFnl.mjs} +4 -4
  76. package/dist/shared/{attaform.CwXXbZIQ.mjs.map → attaform.DDAmSFnl.mjs.map} +1 -1
  77. package/dist/shared/{attaform.BkUzunyB.cjs → attaform.DQT7_-FO.cjs} +371 -287
  78. package/dist/shared/attaform.DQT7_-FO.cjs.map +1 -0
  79. package/dist/shared/{attaform.CqwcTExO.mjs → attaform.Da8EdI2t.mjs} +182 -129
  80. package/dist/shared/attaform.Da8EdI2t.mjs.map +1 -0
  81. package/dist/shared/{attaform.sks1MFVO.cjs → attaform.DhVgG2jh.cjs} +16 -16
  82. package/dist/shared/{attaform.sks1MFVO.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.DMNnfQq_.mjs → attaform.DlSu08F5.mjs} +4 -4
  88. package/dist/shared/{attaform.DMNnfQq_.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.B5YcWrKi.cjs → attaform.Drsi43GG.cjs} +19 -19
  92. package/dist/shared/{attaform.B5YcWrKi.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.8vmdOURQ.d.mts → attaform.kBkYlKP_.d.mts} +1588 -1190
  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.3heDHayA.cjs.map +0 -1
  147. package/dist/shared/attaform.BRGIpZo4.cjs.map +0 -1
  148. package/dist/shared/attaform.BkUzunyB.cjs.map +0 -1
  149. package/dist/shared/attaform.C3Doa9Pt.mjs.map +0 -1
  150. package/dist/shared/attaform.CO0e7YVY.d.cts +0 -94
  151. package/dist/shared/attaform.CO0e7YVY.d.mts +0 -94
  152. package/dist/shared/attaform.CO0e7YVY.d.ts +0 -94
  153. package/dist/shared/attaform.CqwcTExO.mjs.map +0 -1
  154. package/dist/shared/attaform.DK3xUBkj.mjs.map +0 -1
  155. package/dist/shared/attaform.LEWUFqUw.cjs.map +0 -1
  156. package/dist/shared/attaform.OLtKd9gM.mjs +0 -35
  157. package/dist/shared/attaform.OLtKd9gM.mjs.map +0 -1
  158. package/dist/shared/attaform.sHkHv_98.mjs.map +0 -1
  159. package/dist/shared/attaform.xBDo0Ko0.cjs +0 -39
  160. package/dist/shared/attaform.xBDo0Ko0.cjs.map +0 -1
  161. package/dist/shared/{attaform.DdjDqTah.d.mts → attaform.DRUT703x.d.cts} +14 -14
  162. package/dist/shared/{attaform.DdjDqTah.d.ts → attaform.DRUT703x.d.mts} +14 -14
  163. package/dist/shared/{attaform.DdjDqTah.d.cts → 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) {
@@ -27,6 +25,28 @@ function toError(value) {
27
25
  const message = typeof value === "string" && value.length > 0 ? value : `Submit callback threw a non-Error value (${typeof value})`;
28
26
  return new Error(message, { cause: value });
29
27
  }
28
+ function normalizeErrorInput(item, scope, formKey, defaultCode) {
29
+ if (item instanceof Error) {
30
+ return {
31
+ message: item.message.length > 0 ? item.message : "Unknown error",
32
+ path: scope !== void 0 ? [...scope] : [],
33
+ formKey,
34
+ code: defaultCode
35
+ };
36
+ }
37
+ const entry = {
38
+ message: typeof item.message === "string" && item.message.length > 0 ? item.message : "Unknown error",
39
+ path: scope !== void 0 ? [...scope] : Array.isArray(item.path) ? [...item.path] : [],
40
+ formKey,
41
+ code: typeof item.code === "string" && item.code.length > 0 ? item.code : defaultCode
42
+ };
43
+ if (item.data !== void 0) entry.data = item.data;
44
+ return entry;
45
+ }
46
+ function normalizeErrorInputs(input, scope, formKey, defaultCode) {
47
+ const items = Array.isArray(input) ? input : [input];
48
+ return items.map((item) => normalizeErrorInput(item, scope, formKey, defaultCode));
49
+ }
30
50
  class RegistryNotInstalledError extends AttaformError {
31
51
  constructor() {
32
52
  super(
@@ -49,20 +69,140 @@ class ReservedFormKeyError extends AttaformError {
49
69
  }
50
70
  }
51
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
+
52
192
  function detectSSR(options = {}) {
53
193
  if (options.ssr !== void 0) return options.ssr;
54
194
  return typeof window === "undefined" && typeof document === "undefined";
55
195
  }
56
196
 
57
- const kAttaformRegistry = Symbol.for("attaform:registry");
58
- const kAttaformAncestorWizard = Symbol.for(
197
+ const kAttaformRegistry = /* @__PURE__ */ Symbol.for("attaform:registry");
198
+ const kAttaformAncestorWizard = /* @__PURE__ */ Symbol.for(
59
199
  "attaform:ancestor-wizard"
60
200
  );
61
- const kAttaformWizardActiveStepResolver = Symbol.for(
201
+ const kAttaformWizardActiveStepResolver = /* @__PURE__ */ Symbol.for(
62
202
  "attaform:wizard-active-step-resolver"
63
203
  );
64
- const kFormContext = Symbol.for("attaform:form-context");
65
- 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");
66
206
  function createRegistry(options = {}) {
67
207
  const ssr = detectSSR(options);
68
208
  const defaults = Object.freeze({ ...options.defaults ?? {} });
@@ -262,16 +402,14 @@ function invokeArrayFns(fns, ...args) {
262
402
  }
263
403
  }
264
404
 
265
- const INTERACTIVE_TAG_NAMES = /* @__PURE__ */ new Set(["INPUT", "SELECT", "TEXTAREA"]);
266
-
267
405
  const MANAGED_ARIA_ATTRS = [
268
406
  "aria-invalid",
269
407
  "aria-busy",
270
408
  "aria-required",
271
409
  "aria-describedby"
272
410
  ];
273
- const ariaLockKey = Symbol.for("attaform:aria-locks");
274
- 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");
275
413
  const EMPTY_ARIA_LOCKS = /* @__PURE__ */ new Set();
276
414
  function mergeAriaLocks(el, vnode) {
277
415
  let locks = el[ariaLockKey];
@@ -388,7 +526,7 @@ function teardownAria(el) {
388
526
  delete el[ariaLockKey];
389
527
  }
390
528
 
391
- const listenersKey = Symbol.for("attaform:directive-listeners");
529
+ const listenersKey = /* @__PURE__ */ Symbol.for("attaform:directive-listeners");
392
530
  function addTrackedListener(el, event, handler, options) {
393
531
  el.addEventListener(event, handler, options);
394
532
  const carrier = el;
@@ -412,12 +550,12 @@ function isRegisterValueLike(val) {
412
550
  return typeof val === "object" && val !== null && "markInteracted" in val && typeof val.markInteracted === "function";
413
551
  }
414
552
 
415
- const assignKey = Symbol.for("attaform:assign-key");
416
- 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");
417
555
  function isDefaultAssigner(fn) {
418
556
  return typeof fn === "function" && fn[DEFAULT_ASSIGNER_TAG] === true;
419
557
  }
420
- const CONSUMER_WRAPPED_TAG = Symbol.for("attaform:consumer-wrapped-assigner");
558
+ const CONSUMER_WRAPPED_TAG = /* @__PURE__ */ Symbol.for("attaform:consumer-wrapped-assigner");
421
559
  function isConsumerWrapped(fn) {
422
560
  return typeof fn === "function" && fn[CONSUMER_WRAPPED_TAG] === true;
423
561
  }
@@ -625,7 +763,7 @@ function readFilesFromInput(el) {
625
763
  if (files === null || files.length === 0) return null;
626
764
  return files.item(0);
627
765
  }
628
- const fileScopeKey = Symbol.for("attaform:file-scope");
766
+ const fileScopeKey = /* @__PURE__ */ Symbol.for("attaform:file-scope");
629
767
  const vRegisterFile = {
630
768
  created(el, { value }, vnode) {
631
769
  if (!registerProtocol.isRegisterValue(value)) return;
@@ -694,7 +832,7 @@ function syncElementRegistration(el, value, oldValue) {
694
832
  }
695
833
  }
696
834
 
697
- const valueSyncScopeKey = Symbol.for("attaform:value-sync-scope");
835
+ const valueSyncScopeKey = /* @__PURE__ */ Symbol.for("attaform:value-sync-scope");
698
836
  function isElementFocused(el) {
699
837
  const rootNode = el.getRootNode();
700
838
  const activeElement = rootNode instanceof Document || rootNode instanceof ShadowRoot ? rootNode.activeElement : null;
@@ -1478,123 +1616,39 @@ function createAttaform(options = {}) {
1478
1616
  return plugin;
1479
1617
  }
1480
1618
 
1481
- const INTEGER_SEGMENT = /^(?:0|[1-9]\d*)$/;
1482
- function normalizeSegment(raw) {
1483
- if (typeof raw === "number") {
1484
- if (!Number.isInteger(raw) || raw < 0) {
1485
- throw new InvalidPathError(
1486
- `Path segments must be non-negative integers when numeric; got ${String(raw)}`
1487
- );
1488
- }
1489
- return raw;
1490
- }
1491
- if (INTEGER_SEGMENT.test(raw)) return Number(raw);
1492
- return raw;
1493
- }
1494
- function parseDottedPath(path) {
1495
- if (path.length === 0) return [""];
1496
- const rawSegments = path.split(".");
1497
- const segments = [];
1498
- for (const raw of rawSegments) {
1499
- if (raw.length === 0) {
1500
- throw new InvalidPathError(
1501
- `Path '${path}' has an empty segment; use the array form for empty keys.`
1502
- );
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);
1503
1627
  }
1504
- segments.push(normalizeSegment(raw));
1505
- }
1506
- return segments;
1507
- }
1508
- const CANONICAL_STRING_CACHE_MAX = 128;
1509
- const canonicalStringCache = /* @__PURE__ */ new Map();
1510
- const PATHKEY_TO_SEGMENTS_MAX = 4096;
1511
- const pathKeyToSegments = /* @__PURE__ */ new Map();
1512
- function rememberSegmentsForPathKey(key, segments) {
1513
- if (!pathKeyToSegments.has(key) && pathKeyToSegments.size >= PATHKEY_TO_SEGMENTS_MAX) {
1514
- const oldest = pathKeyToSegments.keys().next().value;
1515
- if (oldest !== void 0) pathKeyToSegments.delete(oldest);
1516
- }
1517
- pathKeyToSegments.set(key, segments);
1518
- }
1519
- function segmentsForPathKey(key) {
1520
- const cached = pathKeyToSegments.get(key);
1521
- if (cached !== void 0) return cached;
1522
- let parsed;
1523
- try {
1524
- parsed = JSON.parse(key);
1525
- } catch {
1526
- return null;
1527
- }
1528
- if (!Array.isArray(parsed)) return null;
1529
- const segments = [];
1530
- for (const raw of parsed) {
1531
- if (typeof raw !== "string" && typeof raw !== "number") return null;
1532
- segments.push(normalizeSegment(raw));
1533
- }
1534
- rememberSegmentsForPathKey(key, segments);
1535
- return segments;
1536
- }
1537
- function canonicalizePath(input) {
1538
- if (typeof input === "string") {
1539
- const cached = canonicalStringCache.get(input);
1540
- if (cached !== void 0) return cached;
1541
- const segments = parseDottedPath(input);
1542
- const key = JSON.stringify(segments);
1543
- const entry = { segments, key };
1544
- if (canonicalStringCache.size >= CANONICAL_STRING_CACHE_MAX) {
1545
- const oldest = canonicalStringCache.keys().next().value;
1546
- if (oldest !== void 0) canonicalStringCache.delete(oldest);
1547
- }
1548
- canonicalStringCache.set(input, entry);
1549
- rememberSegmentsForPathKey(key, segments);
1550
- return entry;
1551
- }
1552
- return keyForSegments(input);
1553
- }
1554
- function keyForSegments(input) {
1555
- const segments = Array.from(input).map(normalizeSegment);
1556
- const key = JSON.stringify(segments);
1557
- rememberSegmentsForPathKey(key, segments);
1558
- return { segments, key };
1559
- }
1560
- function segmentsToDotted(segments) {
1561
- return segments.join(".");
1562
- }
1563
- function pathKeyToDotted(key) {
1564
- const segments = segmentsForPathKey(key);
1565
- if (segments === null) return null;
1566
- return segmentsToDotted(segments);
1567
- }
1568
- function coerceToPathKey(input) {
1569
- if (input.length > 0 && input.charCodeAt(0) === 91) {
1570
- try {
1571
- const parsed = JSON.parse(input);
1572
- if (Array.isArray(parsed) && parsed.every((s) => typeof s === "string" || typeof s === "number")) {
1573
- 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 } : {}
1574
1636
  }
1575
- } catch {
1576
- }
1637
+ ]);
1577
1638
  }
1578
- return canonicalizePath(input).key;
1639
+ return { forms };
1579
1640
  }
1580
- const ROOT_PATH = Object.freeze([]);
1581
- const ROOT_PATH_KEY = "[]";
1582
- function isPathPrefix(prefix, path) {
1583
- if (path.length < prefix.length) return false;
1584
- for (let i = 0; i < prefix.length; i++) {
1585
- if (path[i] !== prefix[i]) return false;
1586
- }
1587
- return true;
1588
- }
1589
- function pathsEqual(a, b) {
1590
- if (a.length !== b.length) return false;
1591
- for (let i = 0; i < a.length; i++) {
1592
- 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);
1593
1645
  }
1594
- return true;
1595
1646
  }
1596
1647
 
1648
+ const DEVTOOLS_WINDOW_KEY = "__attaform_devtools__";
1649
+
1597
1650
  exports.AttaformError = AttaformError;
1651
+ exports.DEVTOOLS_WINDOW_KEY = DEVTOOLS_WINDOW_KEY;
1598
1652
  exports.INTERACTIVE_TAG_NAMES = INTERACTIVE_TAG_NAMES;
1599
1653
  exports.InvalidPathError = InvalidPathError;
1600
1654
  exports.InvalidUseFormConfigError = InvalidUseFormConfigError;
@@ -1612,6 +1666,7 @@ exports.createAttaform = createAttaform;
1612
1666
  exports.createRegistry = createRegistry;
1613
1667
  exports.ensureAttaformInstalled = ensureAttaformInstalled;
1614
1668
  exports.getRegistryFromApp = getRegistryFromApp;
1669
+ exports.hydrateAttaformState = hydrateAttaformState;
1615
1670
  exports.isPathPrefix = isPathPrefix;
1616
1671
  exports.kAttaformAncestorWizard = kAttaformAncestorWizard;
1617
1672
  exports.kAttaformRegistry = kAttaformRegistry;
@@ -1619,11 +1674,13 @@ exports.kAttaformWizardActiveStepResolver = kAttaformWizardActiveStepResolver;
1619
1674
  exports.kFormContext = kFormContext;
1620
1675
  exports.kFormInstanceId = kFormInstanceId;
1621
1676
  exports.keyForSegments = keyForSegments;
1677
+ exports.normalizeErrorInput = normalizeErrorInput;
1678
+ exports.normalizeErrorInputs = normalizeErrorInputs;
1622
1679
  exports.parseDottedPath = parseDottedPath;
1623
- exports.pathKeyToDotted = pathKeyToDotted;
1624
1680
  exports.pathsEqual = pathsEqual;
1681
+ exports.renderAttaformState = renderAttaformState;
1625
1682
  exports.segmentsForPathKey = segmentsForPathKey;
1626
1683
  exports.toError = toError;
1627
1684
  exports.useRegistry = useRegistry;
1628
1685
  exports.vRegister = vRegister;
1629
- //# sourceMappingURL=attaform.3heDHayA.cjs.map
1686
+ //# sourceMappingURL=attaform.Co5LNRnv.cjs.map