attaform 0.27.6 → 0.29.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 (192) hide show
  1. package/dist/abstract.d.mts +5 -4
  2. package/dist/abstract.mjs +4 -3
  3. package/dist/chunks/fingerprint.mjs +1 -2
  4. package/dist/chunks/fingerprint2.mjs +2 -3
  5. package/dist/dev/abstract.mjs +4 -0
  6. package/dist/{chunks → dev/chunks}/dev-key-collision-warnings.mjs +0 -1
  7. package/dist/{chunks → dev/chunks}/devtools.mjs +5 -6
  8. package/dist/{chunks/fingerprint.cjs → dev/chunks/fingerprint.mjs} +7 -10
  9. package/dist/{chunks/fingerprint2.cjs → dev/chunks/fingerprint2.mjs} +32 -35
  10. package/dist/dev/directive.mjs +1 -0
  11. package/dist/dev/history.mjs +89 -0
  12. package/dist/dev/index.mjs +5 -0
  13. package/dist/dev/runtime/plugins/attaform.mjs +40 -0
  14. package/dist/dev/shared/attaform-dev.A-TpJW0B.mjs +207 -0
  15. package/dist/dev/shared/attaform-dev.BO-71R54.mjs +820 -0
  16. package/dist/{shared/attaform.D6tk90Rc.cjs → dev/shared/attaform-dev.BgM6FdtA.mjs} +324 -73
  17. package/dist/dev/shared/attaform-dev.ButTkwHd.mjs +375 -0
  18. package/dist/{shared/attaform.BJGA_UOS.mjs → dev/shared/attaform-dev.BxfsuwBR.mjs} +8 -1
  19. package/dist/{shared/attaform.nMaz2C5P.mjs → dev/shared/attaform-dev.D8aoKb89.mjs} +190 -400
  20. package/dist/dev/shared/attaform-dev.DD5m2W51.mjs +220 -0
  21. package/dist/{shared/attaform.CKH2lGdL.mjs → dev/shared/attaform-dev.DHuydLAC.mjs} +3867 -4731
  22. package/dist/{shared/attaform.DYEr28Pt.mjs → dev/shared/attaform-dev.DrzObAZo.mjs} +6 -7
  23. package/dist/{shared/attaform.B1ZYt2Li.mjs → dev/shared/attaform-dev.q6UutkCx.mjs} +274 -672
  24. package/dist/dev/zod-v3.mjs +17 -0
  25. package/dist/dev/zod-v4.mjs +16 -0
  26. package/dist/dev/zod.mjs +5 -0
  27. package/dist/directive.d.mts +20 -0
  28. package/dist/directive.mjs +1 -0
  29. package/dist/esbuild.mjs +0 -1
  30. package/dist/history.d.mts +59 -0
  31. package/dist/history.mjs +89 -0
  32. package/dist/index.d.mts +14 -6
  33. package/dist/index.mjs +5 -4
  34. package/dist/nuxt.d.mts +10 -10
  35. package/dist/nuxt.mjs +5 -2
  36. package/dist/rollup.mjs +0 -1
  37. package/dist/rspack.d.mts +6 -1
  38. package/dist/rspack.mjs +0 -1
  39. package/dist/runtime/components/AttaformDevtoolsPanel.vue +9 -8
  40. package/dist/runtime/plugins/attaform.mjs +1 -2
  41. package/dist/shared/{attaform.CoR4mWfv.mjs → attaform.B0dKL8ST.mjs} +309 -46
  42. package/dist/shared/{attaform.Cs2Rbdlo.mjs → attaform.BK0cgu2K.mjs} +123 -140
  43. package/dist/shared/{attaform.B9Wyhfro.cjs → attaform.BndjUUYX.mjs} +11 -16
  44. package/dist/shared/{attaform.CQN9R62B.cjs → attaform.BxfsuwBR.mjs} +9 -4
  45. package/dist/shared/attaform.C2MVyuxC.mjs +811 -0
  46. package/dist/shared/{attaform.Fp3sCrVs.d.ts → attaform.CIWLMY-R.d.mts} +2 -2
  47. package/dist/shared/attaform.CZMAYwSK.mjs +6383 -0
  48. package/dist/shared/attaform.CZYt_5N_.mjs +207 -0
  49. package/dist/shared/{attaform.DniawQLP.d.cts → attaform.CsoeRi3P.d.mts} +490 -98
  50. package/dist/shared/attaform.Cvao8bW5.mjs +358 -0
  51. package/dist/shared/attaform.D0x-qSXm.mjs +197 -0
  52. package/dist/shared/{attaform.D8kliaKw.cjs → attaform.D1fnTifF.mjs} +279 -692
  53. package/dist/shared/{attaform.CHlJLAiv.d.mts → attaform.DDtqHYv1.d.mts} +155 -184
  54. package/dist/shared/{attaform.Biytrv0-.cjs → attaform.DffRL5pP.mjs} +215 -547
  55. package/dist/shared/attaform.DhnPb6nK.mjs +0 -1
  56. package/dist/shared/attaform.KvlEedlF.mjs +0 -1
  57. package/dist/shared/attaform.axHXVQO7.d.mts +44 -0
  58. package/dist/shared/attaform.v0fQtWyA.mjs +0 -1
  59. package/dist/transforms.d.mts +0 -22
  60. package/dist/transforms.mjs +1 -2
  61. package/dist/vite.d.mts +30 -9
  62. package/dist/vite.mjs +27 -4
  63. package/dist/webpack.d.mts +6 -1
  64. package/dist/webpack.mjs +0 -1
  65. package/dist/zod-v3.d.mts +13 -6
  66. package/dist/zod-v3.mjs +17 -4
  67. package/dist/zod-v4.d.mts +19 -26
  68. package/dist/zod-v4.mjs +16 -4
  69. package/dist/zod.d.mts +4 -3
  70. package/dist/zod.mjs +5 -4
  71. package/package.json +38 -20
  72. package/skills/attaform/SKILL.md +6 -2
  73. package/skills/attaform/references/custom-components.md +7 -2
  74. package/skills/attaform/references/errors.md +8 -3
  75. package/skills/attaform/references/saving.md +77 -0
  76. package/skills/attaform/references/wizards.md +10 -8
  77. package/dist/abstract.cjs +0 -48
  78. package/dist/abstract.cjs.map +0 -1
  79. package/dist/abstract.d.cts +0 -42
  80. package/dist/abstract.d.ts +0 -42
  81. package/dist/abstract.mjs.map +0 -1
  82. package/dist/chunks/dev-key-collision-warnings.cjs +0 -25
  83. package/dist/chunks/dev-key-collision-warnings.cjs.map +0 -1
  84. package/dist/chunks/dev-key-collision-warnings.mjs.map +0 -1
  85. package/dist/chunks/devtools.cjs +0 -157
  86. package/dist/chunks/devtools.cjs.map +0 -1
  87. package/dist/chunks/devtools.mjs.map +0 -1
  88. package/dist/chunks/fingerprint.cjs.map +0 -1
  89. package/dist/chunks/fingerprint.mjs.map +0 -1
  90. package/dist/chunks/fingerprint2.cjs.map +0 -1
  91. package/dist/chunks/fingerprint2.mjs.map +0 -1
  92. package/dist/esbuild.cjs +0 -28
  93. package/dist/esbuild.cjs.map +0 -1
  94. package/dist/esbuild.d.cts +0 -56
  95. package/dist/esbuild.d.ts +0 -56
  96. package/dist/esbuild.mjs.map +0 -1
  97. package/dist/index.cjs +0 -51
  98. package/dist/index.cjs.map +0 -1
  99. package/dist/index.d.cts +0 -249
  100. package/dist/index.d.ts +0 -249
  101. package/dist/index.mjs.map +0 -1
  102. package/dist/nuxt.cjs +0 -84
  103. package/dist/nuxt.cjs.map +0 -1
  104. package/dist/nuxt.d.cts +0 -66
  105. package/dist/nuxt.d.ts +0 -66
  106. package/dist/nuxt.mjs.map +0 -1
  107. package/dist/rollup.cjs +0 -24
  108. package/dist/rollup.cjs.map +0 -1
  109. package/dist/rollup.d.cts +0 -35
  110. package/dist/rollup.d.ts +0 -35
  111. package/dist/rollup.mjs.map +0 -1
  112. package/dist/rspack.cjs +0 -10
  113. package/dist/rspack.cjs.map +0 -1
  114. package/dist/rspack.d.cts +0 -40
  115. package/dist/rspack.d.ts +0 -40
  116. package/dist/rspack.mjs.map +0 -1
  117. package/dist/runtime/components/AttaformDevtoolsPanel.vue.d.ts +0 -7
  118. package/dist/runtime/components/DevtoolsValueTree.vue.d.ts +0 -35
  119. package/dist/runtime/plugins/attaform.cjs +0 -43
  120. package/dist/runtime/plugins/attaform.cjs.map +0 -1
  121. package/dist/runtime/plugins/attaform.d.cts +0 -5
  122. package/dist/runtime/plugins/attaform.d.ts +0 -5
  123. package/dist/runtime/plugins/attaform.mjs.map +0 -1
  124. package/dist/shared/attaform.B1ZYt2Li.mjs.map +0 -1
  125. package/dist/shared/attaform.B9Wyhfro.cjs.map +0 -1
  126. package/dist/shared/attaform.BGDV42hI.d.cts +0 -232
  127. package/dist/shared/attaform.BJGA_UOS.mjs.map +0 -1
  128. package/dist/shared/attaform.Biytrv0-.cjs.map +0 -1
  129. package/dist/shared/attaform.Bn0IzhD_.cjs +0 -800
  130. package/dist/shared/attaform.Bn0IzhD_.cjs.map +0 -1
  131. package/dist/shared/attaform.C9fPTxjB.d.cts +0 -41
  132. package/dist/shared/attaform.C9fPTxjB.d.ts +0 -41
  133. package/dist/shared/attaform.CKH2lGdL.mjs.map +0 -1
  134. package/dist/shared/attaform.CQN9R62B.cjs.map +0 -1
  135. package/dist/shared/attaform.CoR4mWfv.mjs.map +0 -1
  136. package/dist/shared/attaform.Cs2Rbdlo.mjs.map +0 -1
  137. package/dist/shared/attaform.D6tk90Rc.cjs.map +0 -1
  138. package/dist/shared/attaform.D8kliaKw.cjs.map +0 -1
  139. package/dist/shared/attaform.DLknk9nF.d.mts +0 -232
  140. package/dist/shared/attaform.DMxM2kol.mjs +0 -1275
  141. package/dist/shared/attaform.DMxM2kol.mjs.map +0 -1
  142. package/dist/shared/attaform.DRUT703x.d.cts +0 -56
  143. package/dist/shared/attaform.DRUT703x.d.ts +0 -56
  144. package/dist/shared/attaform.DYEr28Pt.mjs.map +0 -1
  145. package/dist/shared/attaform.DdQN7sgN.cjs +0 -1302
  146. package/dist/shared/attaform.DdQN7sgN.cjs.map +0 -1
  147. package/dist/shared/attaform.DhnPb6nK.mjs.map +0 -1
  148. package/dist/shared/attaform.DniawQLP.d.mts +0 -4763
  149. package/dist/shared/attaform.DniawQLP.d.ts +0 -4763
  150. package/dist/shared/attaform.DoQm_Vkd.cjs +0 -58
  151. package/dist/shared/attaform.DoQm_Vkd.cjs.map +0 -1
  152. package/dist/shared/attaform.DrvMscNX.cjs +0 -7697
  153. package/dist/shared/attaform.DrvMscNX.cjs.map +0 -1
  154. package/dist/shared/attaform.F2Q8iv38.d.ts +0 -2494
  155. package/dist/shared/attaform.FmqKO1Ex.d.cts +0 -2494
  156. package/dist/shared/attaform.KvlEedlF.mjs.map +0 -1
  157. package/dist/shared/attaform.RaTzp1WF.cjs +0 -26
  158. package/dist/shared/attaform.RaTzp1WF.cjs.map +0 -1
  159. package/dist/shared/attaform.nMaz2C5P.mjs.map +0 -1
  160. package/dist/shared/attaform.v0fQtWyA.mjs.map +0 -1
  161. package/dist/shared/attaform.yUrz7C2z.cjs +0 -29
  162. package/dist/shared/attaform.yUrz7C2z.cjs.map +0 -1
  163. package/dist/transforms.cjs +0 -12
  164. package/dist/transforms.cjs.map +0 -1
  165. package/dist/transforms.d.cts +0 -73
  166. package/dist/transforms.d.ts +0 -73
  167. package/dist/transforms.mjs.map +0 -1
  168. package/dist/vite.cjs +0 -363
  169. package/dist/vite.cjs.map +0 -1
  170. package/dist/vite.d.cts +0 -133
  171. package/dist/vite.d.ts +0 -133
  172. package/dist/vite.mjs.map +0 -1
  173. package/dist/webpack.cjs +0 -10
  174. package/dist/webpack.cjs.map +0 -1
  175. package/dist/webpack.d.cts +0 -37
  176. package/dist/webpack.d.ts +0 -37
  177. package/dist/webpack.mjs.map +0 -1
  178. package/dist/zod-v3.cjs +0 -53
  179. package/dist/zod-v3.cjs.map +0 -1
  180. package/dist/zod-v3.d.cts +0 -246
  181. package/dist/zod-v3.d.ts +0 -246
  182. package/dist/zod-v3.mjs.map +0 -1
  183. package/dist/zod-v4.cjs +0 -55
  184. package/dist/zod-v4.cjs.map +0 -1
  185. package/dist/zod-v4.d.cts +0 -172
  186. package/dist/zod-v4.d.ts +0 -172
  187. package/dist/zod-v4.mjs.map +0 -1
  188. package/dist/zod.cjs +0 -51
  189. package/dist/zod.cjs.map +0 -1
  190. package/dist/zod.d.cts +0 -7
  191. package/dist/zod.d.ts +0 -7
  192. package/dist/zod.mjs.map +0 -1
@@ -0,0 +1,220 @@
1
+ import { c as RegistryNotInstalledError, O as OutsideSetupError, g as pathKeyToDotted } from './attaform-dev.A-TpJW0B.mjs';
2
+ import { shallowReactive, getCurrentInstance, inject } from 'vue';
3
+
4
+ function detectSSR(options = {}) {
5
+ if (options.ssr !== void 0) return options.ssr;
6
+ return typeof window === "undefined" && typeof document === "undefined";
7
+ }
8
+
9
+ const kAttaformRegistry = /* @__PURE__ */ Symbol.for("attaform:registry");
10
+ const kAttaformAncestorWizard = /* @__PURE__ */ Symbol.for(
11
+ "attaform:ancestor-wizard"
12
+ );
13
+ const kAttaformWizardActiveStepResolver = /* @__PURE__ */ Symbol.for(
14
+ "attaform:wizard-active-step-resolver"
15
+ );
16
+ const kFormContext = /* @__PURE__ */ Symbol.for("attaform:form-context");
17
+ const kFormInstanceId = /* @__PURE__ */ Symbol.for("attaform:form-instance-id");
18
+ function createRegistry(options = {}) {
19
+ const ssr = detectSSR(options);
20
+ const defaults = Object.freeze({ ...options.defaults ?? {} });
21
+ const forms = shallowReactive(/* @__PURE__ */ new Map());
22
+ const wizards = shallowReactive(/* @__PURE__ */ new Map());
23
+ const pendingHydration = shallowReactive(/* @__PURE__ */ new Map());
24
+ const consumers = /* @__PURE__ */ new Map();
25
+ const pendingEvictions = /* @__PURE__ */ new Map();
26
+ function cancelPendingEviction(key) {
27
+ const pending = pendingEvictions.get(key);
28
+ if (pending === void 0) return;
29
+ pending.cancelled = true;
30
+ pendingEvictions.delete(key);
31
+ }
32
+ function trackConsumer(key) {
33
+ cancelPendingEviction(key);
34
+ consumers.set(key, (consumers.get(key) ?? 0) + 1);
35
+ let disposed = false;
36
+ return () => {
37
+ if (disposed) return;
38
+ disposed = true;
39
+ const remaining = (consumers.get(key) ?? 1) - 1;
40
+ if (remaining > 0) {
41
+ consumers.set(key, remaining);
42
+ return;
43
+ }
44
+ consumers.delete(key);
45
+ const token = { cancelled: false };
46
+ pendingEvictions.set(key, token);
47
+ queueMicrotask(() => {
48
+ if (token.cancelled) return;
49
+ if (pendingEvictions.get(key) !== token) return;
50
+ pendingEvictions.delete(key);
51
+ const state = forms.get(key);
52
+ forms.delete(key);
53
+ if (state === void 0) return;
54
+ state.dispose();
55
+ });
56
+ };
57
+ }
58
+ const wizardConsumers = /* @__PURE__ */ new Map();
59
+ const pendingWizardEvictions = /* @__PURE__ */ new Map();
60
+ function cancelPendingWizardEviction(key) {
61
+ const pending = pendingWizardEvictions.get(key);
62
+ if (pending === void 0) return;
63
+ pending.cancelled = true;
64
+ pendingWizardEvictions.delete(key);
65
+ }
66
+ function trackWizardConsumer(key) {
67
+ cancelPendingWizardEviction(key);
68
+ wizardConsumers.set(key, (wizardConsumers.get(key) ?? 0) + 1);
69
+ let disposed = false;
70
+ return () => {
71
+ if (disposed) return;
72
+ disposed = true;
73
+ const remaining = (wizardConsumers.get(key) ?? 1) - 1;
74
+ if (remaining > 0) {
75
+ wizardConsumers.set(key, remaining);
76
+ return;
77
+ }
78
+ wizardConsumers.delete(key);
79
+ const token = { cancelled: false };
80
+ pendingWizardEvictions.set(key, token);
81
+ queueMicrotask(() => {
82
+ if (token.cancelled) return;
83
+ if (pendingWizardEvictions.get(key) !== token) return;
84
+ pendingWizardEvictions.delete(key);
85
+ wizards.delete(key);
86
+ });
87
+ };
88
+ }
89
+ const prefetchEnqueued = /* @__PURE__ */ new Set();
90
+ const prefetchSkipped = /* @__PURE__ */ new Set();
91
+ function enqueuePrefetch(key) {
92
+ prefetchEnqueued.add(key);
93
+ }
94
+ function skipPrefetch(key) {
95
+ prefetchSkipped.add(key);
96
+ }
97
+ function shouldPrefetch(key) {
98
+ return prefetchEnqueued.has(key) && !prefetchSkipped.has(key);
99
+ }
100
+ return {
101
+ forms,
102
+ wizards,
103
+ pendingHydration,
104
+ ssr,
105
+ defaults,
106
+ trackConsumer,
107
+ trackWizardConsumer,
108
+ enqueuePrefetch,
109
+ skipPrefetch,
110
+ shouldPrefetch
111
+ };
112
+ }
113
+ function useRegistry() {
114
+ const instance = getCurrentInstance();
115
+ if (instance === null) {
116
+ throw new OutsideSetupError();
117
+ }
118
+ const registry = inject(kAttaformRegistry, null);
119
+ if (registry === null) {
120
+ throw new RegistryNotInstalledError();
121
+ }
122
+ return registry;
123
+ }
124
+ function getRegistryFromApp(app) {
125
+ const registry = app._attaform;
126
+ if (registry === void 0) {
127
+ throw new RegistryNotInstalledError();
128
+ }
129
+ return registry;
130
+ }
131
+ function attachRegistryToApp(app, registry) {
132
+ app.provide(kAttaformRegistry, registry);
133
+ app._attaform = registry;
134
+ }
135
+
136
+ function installAttaformOnApp(app, options, source) {
137
+ if (app._attaform !== void 0) {
138
+ if (source === "explicit") {
139
+ console.warn(
140
+ "[attaform] createAttaform() install was called twice on the same app; the second call is a no-op. Likely cause: registering the plugin via both the Nuxt module AND a manual `app.use(...)`."
141
+ );
142
+ }
143
+ return app._attaform;
144
+ }
145
+ const registry = createRegistry(options);
146
+ attachRegistryToApp(app, registry);
147
+ if (options.devtools !== false && !registry.ssr) {
148
+ void (async () => {
149
+ try {
150
+ const { setupAttaformDevtools } = await import('../chunks/devtools.mjs');
151
+ await setupAttaformDevtools(app, registry);
152
+ } catch {
153
+ }
154
+ })();
155
+ }
156
+ return registry;
157
+ }
158
+ function ensureAttaformInstalled(app) {
159
+ return installAttaformOnApp(app, {}, "lazy");
160
+ }
161
+ function createAttaform(options = {}) {
162
+ const plugin = {
163
+ install(app) {
164
+ installAttaformOnApp(app, options, "explicit");
165
+ }
166
+ };
167
+ return plugin;
168
+ }
169
+
170
+ const ATTAFORM_STATE_VERSION = 1;
171
+ function renderAttaformState(app) {
172
+ const registry = getRegistryFromApp(app);
173
+ const forms = [];
174
+ for (const [key, state] of registry.forms) {
175
+ const transientList = [];
176
+ for (const pk of state.blankPaths) {
177
+ const d = pathKeyToDotted(pk);
178
+ if (d !== null) transientList.push(d);
179
+ }
180
+ forms.push([
181
+ key,
182
+ {
183
+ form: state.form.value,
184
+ // The wire shape stays two per-source arrays; the tagged store
185
+ // splits at the boundary and the client replays each side into
186
+ // its cell half.
187
+ schemaErrors: [...state.errorCells.entries()].filter(([, cell]) => cell.schema.length > 0).map(([key2, cell]) => [key2, cell.schema]),
188
+ userErrors: [...state.errorCells.entries()].filter(([, cell]) => cell.user.length > 0).map(([key2, cell]) => [key2, cell.user]),
189
+ fields: Array.from(state.fields.entries()),
190
+ ...transientList.length > 0 ? { blankPaths: transientList } : {}
191
+ }
192
+ ]);
193
+ }
194
+ return { v: ATTAFORM_STATE_VERSION, forms };
195
+ }
196
+ function hydrateAttaformState(app, payload) {
197
+ if (!isHydratableEnvelope(payload)) {
198
+ {
199
+ let got = payload;
200
+ if (payload !== null && typeof payload === "object") {
201
+ got = "v" in payload ? payload.v : void 0;
202
+ }
203
+ console.warn(
204
+ `[attaform] hydrateAttaformState: payload version mismatch (expected ${ATTAFORM_STATE_VERSION}, got ${String(got)}). Skipping hydration \u2014 forms will construct fresh. This usually means the SSR bundle is on a different attaform version than the client (rolling deploy / stale cache).`
205
+ );
206
+ }
207
+ return;
208
+ }
209
+ const registry = getRegistryFromApp(app);
210
+ for (const [key, data] of payload.forms) {
211
+ registry.pendingHydration.set(key, data);
212
+ }
213
+ }
214
+ function isHydratableEnvelope(payload) {
215
+ return payload !== null && typeof payload === "object" && "v" in payload && payload.v === ATTAFORM_STATE_VERSION && "forms" in payload && Array.isArray(payload.forms);
216
+ }
217
+
218
+ const DEVTOOLS_WINDOW_KEY = "__attaform_devtools__";
219
+
220
+ export { DEVTOOLS_WINDOW_KEY as D, createRegistry as a, kAttaformWizardActiveStepResolver as b, createAttaform as c, kFormContext as d, ensureAttaformInstalled as e, kFormInstanceId as f, getRegistryFromApp as g, hydrateAttaformState as h, kAttaformAncestorWizard as i, kAttaformRegistry as k, renderAttaformState as r, useRegistry as u };