attaform 0.22.0 → 0.24.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 (114) hide show
  1. package/README.md +8 -11
  2. package/dist/chunks/dev-key-collision-warnings.cjs +0 -33
  3. package/dist/chunks/dev-key-collision-warnings.cjs.map +1 -1
  4. package/dist/chunks/dev-key-collision-warnings.mjs +1 -33
  5. package/dist/chunks/dev-key-collision-warnings.mjs.map +1 -1
  6. package/dist/chunks/devtools.cjs +3 -5
  7. package/dist/chunks/devtools.cjs.map +1 -1
  8. package/dist/chunks/devtools.mjs +3 -5
  9. package/dist/chunks/devtools.mjs.map +1 -1
  10. package/dist/chunks/fingerprint2.cjs +1 -1
  11. package/dist/chunks/fingerprint2.mjs +1 -1
  12. package/dist/index.cjs +3 -151
  13. package/dist/index.cjs.map +1 -1
  14. package/dist/index.d.cts +7 -168
  15. package/dist/index.d.mts +7 -168
  16. package/dist/index.d.ts +7 -168
  17. package/dist/index.mjs +4 -150
  18. package/dist/index.mjs.map +1 -1
  19. package/dist/nuxt.d.cts +1 -1
  20. package/dist/nuxt.d.mts +1 -1
  21. package/dist/nuxt.d.ts +1 -1
  22. package/dist/runtime/components/AttaformDevtoolsPanel.vue +5 -13
  23. package/dist/runtime/plugins/attaform.cjs +2 -2
  24. package/dist/runtime/plugins/attaform.mjs +2 -2
  25. package/dist/shared/{attaform.DgCfLqay.mjs → attaform.BJ_W7q3U.mjs} +8 -6
  26. package/dist/shared/attaform.BJ_W7q3U.mjs.map +1 -0
  27. package/dist/shared/{attaform.aekT7mMx.d.cts → attaform.BNmkKz0q.d.mts} +38 -6
  28. package/dist/shared/{attaform.Q3eAD2wD.cjs → attaform.BV_HyaMO.cjs} +6 -4
  29. package/dist/shared/attaform.BV_HyaMO.cjs.map +1 -0
  30. package/dist/shared/{attaform.AyujQoHp.cjs → attaform.BnUXV01g.cjs} +4 -4
  31. package/dist/shared/attaform.BnUXV01g.cjs.map +1 -0
  32. package/dist/shared/{attaform.DNuiFCXG.mjs → attaform.C-dAB90u.mjs} +4 -4
  33. package/dist/shared/attaform.C-dAB90u.mjs.map +1 -0
  34. package/dist/shared/{attaform.CjMcwV7W.cjs → attaform.C42wL7EJ.cjs} +272 -776
  35. package/dist/shared/attaform.C42wL7EJ.cjs.map +1 -0
  36. package/dist/shared/{attaform.D4XYaasQ.d.ts → attaform.C6eE50re.d.ts} +27 -87
  37. package/dist/shared/{attaform.6xE0Lcfd.mjs → attaform.CAWKNCzc.mjs} +2 -2
  38. package/dist/shared/{attaform.6xE0Lcfd.mjs.map → attaform.CAWKNCzc.mjs.map} +1 -1
  39. package/dist/shared/{attaform.DkA5J8NW.d.cts → attaform.CO0e7YVY.d.cts} +1 -46
  40. package/dist/shared/{attaform.DkA5J8NW.d.ts → attaform.CO0e7YVY.d.mts} +1 -46
  41. package/dist/shared/{attaform.DkA5J8NW.d.mts → attaform.CO0e7YVY.d.ts} +1 -46
  42. package/dist/shared/{attaform.CsB-iKbU.mjs → attaform.CuBdtfbe.mjs} +274 -767
  43. package/dist/shared/attaform.CuBdtfbe.mjs.map +1 -0
  44. package/dist/shared/{attaform.FN0vaQAg.d.mts → attaform.CwFZGv5-.d.ts} +38 -6
  45. package/dist/shared/{attaform.BGwNZ9GV.d.cts → attaform.DdUYEhkV.d.cts} +27 -87
  46. package/dist/shared/attaform.DdjDqTah.d.cts +56 -0
  47. package/dist/shared/attaform.DdjDqTah.d.mts +56 -0
  48. package/dist/shared/attaform.DdjDqTah.d.ts +56 -0
  49. package/dist/shared/{attaform.BKFwekY2.mjs → attaform.Df-s8j1X.mjs} +3 -289
  50. package/dist/shared/attaform.Df-s8j1X.mjs.map +1 -0
  51. package/dist/shared/{attaform.CCCeEPwa.d.mts → attaform.DiWNbKWa.d.mts} +27 -87
  52. package/dist/shared/{attaform.01iKS_lz.cjs → attaform.DwkU0oY9.cjs} +2 -298
  53. package/dist/shared/attaform.DwkU0oY9.cjs.map +1 -0
  54. package/dist/shared/{attaform.DvUH4a3o.d.ts → attaform.GJbSmwLB.d.cts} +224 -824
  55. package/dist/shared/{attaform.DvUH4a3o.d.cts → attaform.GJbSmwLB.d.mts} +224 -824
  56. package/dist/shared/{attaform.DvUH4a3o.d.mts → attaform.GJbSmwLB.d.ts} +224 -824
  57. package/dist/shared/{attaform.DUMWQefY.d.ts → attaform.K-3glmiT.d.cts} +38 -6
  58. package/dist/shared/{attaform.C-RtnCJM.cjs → attaform.Z1qTwOYE.cjs} +8 -6
  59. package/dist/shared/attaform.Z1qTwOYE.cjs.map +1 -0
  60. package/dist/shared/{attaform.CRzpFCjV.cjs → attaform.nycEksJn.cjs} +2 -2
  61. package/dist/shared/{attaform.CRzpFCjV.cjs.map → attaform.nycEksJn.cjs.map} +1 -1
  62. package/dist/shared/{attaform.DCjgGir_.mjs → attaform.o95Kjd3U.mjs} +6 -4
  63. package/dist/shared/attaform.o95Kjd3U.mjs.map +1 -0
  64. package/dist/zod-v3.cjs +2 -2
  65. package/dist/zod-v3.d.cts +12 -11
  66. package/dist/zod-v3.d.mts +12 -11
  67. package/dist/zod-v3.d.ts +12 -11
  68. package/dist/zod-v3.mjs +2 -2
  69. package/dist/zod-v4.cjs +2 -2
  70. package/dist/zod-v4.d.cts +7 -6
  71. package/dist/zod-v4.d.mts +7 -6
  72. package/dist/zod-v4.d.ts +7 -6
  73. package/dist/zod-v4.mjs +2 -2
  74. package/dist/zod.cjs +5 -5
  75. package/dist/zod.cjs.map +1 -1
  76. package/dist/zod.d.cts +21 -52
  77. package/dist/zod.d.mts +21 -52
  78. package/dist/zod.d.ts +21 -52
  79. package/dist/zod.mjs +5 -5
  80. package/dist/zod.mjs.map +1 -1
  81. package/package.json +1 -1
  82. package/dist/chunks/indexeddb.cjs +0 -119
  83. package/dist/chunks/indexeddb.cjs.map +0 -1
  84. package/dist/chunks/indexeddb.mjs +0 -117
  85. package/dist/chunks/indexeddb.mjs.map +0 -1
  86. package/dist/chunks/local-storage.cjs +0 -58
  87. package/dist/chunks/local-storage.cjs.map +0 -1
  88. package/dist/chunks/local-storage.mjs +0 -56
  89. package/dist/chunks/local-storage.mjs.map +0 -1
  90. package/dist/chunks/multi-tab-sync.cjs +0 -367
  91. package/dist/chunks/multi-tab-sync.cjs.map +0 -1
  92. package/dist/chunks/multi-tab-sync.mjs +0 -364
  93. package/dist/chunks/multi-tab-sync.mjs.map +0 -1
  94. package/dist/chunks/session-storage.cjs +0 -58
  95. package/dist/chunks/session-storage.cjs.map +0 -1
  96. package/dist/chunks/session-storage.mjs +0 -56
  97. package/dist/chunks/session-storage.mjs.map +0 -1
  98. package/dist/chunks/wire-persistence.cjs +0 -396
  99. package/dist/chunks/wire-persistence.cjs.map +0 -1
  100. package/dist/chunks/wire-persistence.mjs +0 -394
  101. package/dist/chunks/wire-persistence.mjs.map +0 -1
  102. package/dist/shared/attaform.01iKS_lz.cjs.map +0 -1
  103. package/dist/shared/attaform.AyujQoHp.cjs.map +0 -1
  104. package/dist/shared/attaform.BKFwekY2.mjs.map +0 -1
  105. package/dist/shared/attaform.C-RtnCJM.cjs.map +0 -1
  106. package/dist/shared/attaform.CjMcwV7W.cjs.map +0 -1
  107. package/dist/shared/attaform.CsB-iKbU.mjs.map +0 -1
  108. package/dist/shared/attaform.DCjgGir_.mjs.map +0 -1
  109. package/dist/shared/attaform.DNuiFCXG.mjs.map +0 -1
  110. package/dist/shared/attaform.DgCfLqay.mjs.map +0 -1
  111. package/dist/shared/attaform.Q3eAD2wD.cjs.map +0 -1
  112. package/dist/shared/attaform.nf83TIR5.d.cts +0 -35
  113. package/dist/shared/attaform.nf83TIR5.d.mts +0 -35
  114. package/dist/shared/attaform.nf83TIR5.d.ts +0 -35
package/README.md CHANGED
@@ -121,7 +121,7 @@ It catches stale `form.values.contacts[N]` reads at compile time. Nuxt 3 / 4 set
121
121
  - **`form.history`**: consolidated undo/redo namespace (`undo()`, `redo()`, `clear()`, `canUndo`, `canRedo`, `size`).
122
122
  - **`form.register(path)`**: typed two-way binding. Pair with `v-register` on `<input>` / `<textarea>` / `<select>`.
123
123
  - **`form.handleSubmit(onValid, onInvalid?)`**: runs validation, dispatches. The valid callback receives the strict Zod-inferred type.
124
- - **`form.setValue(path, value)`**, **`form.reset()`**, field-array helpers, persistence: see [Entry points](https://www.attaform.com/docs/reference/entry-points).
124
+ - **`form.setValue(path, value)`**, **`form.reset()`**, field-array helpers: see [Entry points](https://www.attaform.com/docs/reference/entry-points).
125
125
 
126
126
  > **Try it live.** Tweak this schema, edit the template, and watch the form rebind in the browser at [attaform.com/demos](https://www.attaform.com/demos). No install needed.
127
127
 
@@ -136,18 +136,16 @@ It catches stale `form.values.contacts[N]` reads at compile time. Nuxt 3 / 4 set
136
136
  Typed two-way binding to `form.values.email`, with schema-driven coercion at the directive layer.
137
137
 
138
138
  ```vue
139
- <input v-register="form.register('email', { persist: true })" />
139
+ <input v-register="form.register('slug', { transforms: [lowercase] })" />
140
140
  ```
141
141
 
142
- Same line. The field now writes through to the form's persistence backend on every keystroke, with the sensitive-name guard catching accidental `password`-style opt-ins.
142
+ Same line. The field now runs a sync write-time transform, normalizing the value before it reaches form state.
143
143
 
144
144
  ```vue
145
- <input
146
- v-register="form.register('email', { persist: true, transforms: [lowercase], multiTab: false })"
147
- />
145
+ <input v-register="form.register('slug', { transforms: [lowercase, dashify], autoAria: false })" />
148
146
  ```
149
147
 
150
- Same line. Add a sync DOM-input transform, opt out of multi-tab sync, all without touching the markup elsewhere.
148
+ Same line. Compose a transform pipeline and opt this field out of automatic aria wiring, all without touching the markup elsewhere.
151
149
 
152
150
  ## Features
153
151
 
@@ -155,13 +153,12 @@ Same line. Add a sync DOM-input transform, opt out of multi-tab sync, all withou
155
153
  - **Live validation.** `validateOn: 'change'` by default with synchronous `debounceMs: 0`. `'blur'` and `'submit'` (opt-out) modes available. Async refinements await before submit dispatches.
156
154
  - **Schema-driven coercion.** String DOM input flows into the schema's typed slot (`string→number`, `string→boolean`) at the directive layer. Default-on; pass `useForm({ coerce: false })` to disable or a custom `CoercionRegistry` to extend.
157
155
  - **Register transforms.** `form.register('slug', { transforms: [lowercase, dashify] })` runs sync write-time normalization before storage commit.
158
- - **First-class multistep.** `useWizard` composes `useForm` instances into a flow with shared navigation, per-step validation, persistence across steps, and deep-link restore.
156
+ - **First-class multistep.** `useWizard` composes `useForm` instances into a flow with shared navigation, per-step validation, state retained across steps, and deep-link restore.
159
157
  - **DevTools panel.** Auto-wired in Nuxt. Walk history, edit values live, inspect every form on the page. No probes to install.
160
158
  - **Discriminated-union variant memory.** Switching a discriminator (`notify.channel: 'email' → 'sms' → 'email'`) restores the previous variant's typed subtree by default. Pass `useForm({ rememberVariants: false })` to drop on switch.
161
159
  - **Field arrays.** `append` / `prepend` / `insert` / `remove` / `swap` / `move` / `replace`, fully typed at the call site.
162
- - **Drafts and undo / redo.** Per-field opt-in persistence (`localStorage` / `sessionStorage` / IndexedDB / custom backend) and a bounded undo stack.
163
- - **Multi-tab sync.** Same-keyed `useForm` callsites in same-origin tabs auto-pair over `BroadcastChannel` and mirror every mutation in near real-time. Sensitive paths filtered both directions; HTTPS-or-localhost required.
164
- - **Server errors.** `parseApiErrors(payload, { formKey: form.key })` normalizes any API envelope into the same `ValidationError` shape your template already reads. Pair with `form.setFieldErrors(...)`; user errors survive schema revalidation.
160
+ - **Undo / redo.** A bounded undo stack via `form.history` (`undo()` / `redo()` / `canUndo` / `canRedo`).
161
+ - **Server errors.** `form.setErrors(response.errors)` mounts a server's `ValidationError[]` into the same reactive surface your template already reads. Each error carries an optional `data` payload (a captcha challenge, a lockout time); user errors survive schema revalidation.
165
162
  - **Stable error codes.** Every `ValidationError` carries `code: string`. Attaform codes (`atta:`) live on the exported `AttaformErrorCode` enum; adapter codes use a `zod:` prefix; consumers pick their own (`api:`, `auth:`, …).
166
163
  - **Clearable required fields.** The `unset` sentinel marks a field displayed-empty while storage holds the schema's slim default. Submit fails with `'No value supplied'` for required schemas; `.optional()` / `.nullable()` / `.default(N)` opt out.
167
164
  - **SSR.** Nuxt handles the payload round-trip automatically; bare Vue uses `renderAttaformState` / `hydrateAttaformState`.
@@ -1,7 +1,5 @@
1
1
  'use strict';
2
2
 
3
- const injectWizard = require('../shared/attaform.CjMcwV7W.cjs');
4
-
5
3
  async function warnOnSchemaFingerprintMismatch(key, existing, incoming) {
6
4
  let existingFp;
7
5
  let incomingFp;
@@ -22,37 +20,6 @@ async function warnOnSchemaFingerprintMismatch(key, existing, incoming) {
22
20
  incoming: ${incomingFp}`
23
21
  );
24
22
  }
25
- function warnOnPersistDivergence(key, existing, incomingPersist) {
26
- if (incomingPersist === void 0) return;
27
- const wired = existing.modules.get(injectWizard.PERSISTENCE_MODULE_KEY);
28
- const incomingNormalized = injectWizard.normalizePersistConfig(incomingPersist);
29
- if (wired === void 0) {
30
- console.warn(
31
- `[attaform] useForm({ key: "${key}" }) passed a persist config but the first useForm({ key }) call didn't wire persistence; the new config is silently dropped. Pass persist on the first call, or remove persist here to make the inheritance explicit.`
32
- );
33
- return;
34
- }
35
- if (persistConfigsEquivalent(wired.config, incomingNormalized)) return;
36
- console.warn(
37
- `[attaform] useForm({ key: "${key}" }) passed a persist config that differs from the first useForm({ key }) call's; first wins, this one is ignored.
38
- wired: ${describePersist(wired.config)}
39
- incoming: ${describePersist(incomingNormalized)}`
40
- );
41
- }
42
- function persistConfigsEquivalent(a, b) {
43
- if (a.storage !== b.storage) return false;
44
- if ((a.key ?? void 0) !== (b.key ?? void 0)) return false;
45
- if ((a.debounceMs ?? void 0) !== (b.debounceMs ?? void 0)) return false;
46
- return true;
47
- }
48
- function describePersist(config) {
49
- const storage = typeof config.storage === "string" ? config.storage : "custom-adapter";
50
- const parts = [`storage=${storage}`];
51
- if (config.key !== void 0) parts.push(`key=${config.key}`);
52
- if (config.debounceMs !== void 0) parts.push(`debounceMs=${config.debounceMs}`);
53
- return `{ ${parts.join(", ")} }`;
54
- }
55
23
 
56
- exports.warnOnPersistDivergence = warnOnPersistDivergence;
57
24
  exports.warnOnSchemaFingerprintMismatch = warnOnSchemaFingerprintMismatch;
58
25
  //# sourceMappingURL=dev-key-collision-warnings.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"dev-key-collision-warnings.cjs","sources":["../../src/runtime/core/dev-key-collision-warnings.ts"],"sourcesContent":["/**\n * Dev-only shared-key collision diagnostics for `useForm`. When two\n * `useForm({ key })` calls land on the same key, they resolve to one\n * `FormStore` by design (the shared-store semantic), and the second\n * call's schema and `persist:` config are silently dropped in favour of\n * the first's wiring. The warnings here surface that divergence so a\n * genuine collision (two unrelated call sites that happen to agree on a\n * key) is diagnosable rather than silent.\n *\n * This whole module is loaded behind a `__DEV__`-gated dynamic import in\n * `use-abstract-form.ts`. A production build folds that gate to `false`,\n * dead-code-eliminates the `import()` call, and leaves this module an\n * unreferenced chunk the consumer's bundler drops. Keeping the warnings\n * here (rather than as plain functions called from the gated block)\n * matters because esbuild removes the inline dead branch but NOT a\n * top-level function it is the sole caller of: tree-shaking runs before\n * the define-fold, so the function survives. A separately-imported\n * module sidesteps that and keeps the cluster out of every consumer's\n * production bundle.\n */\nimport { normalizePersistConfig, PERSISTENCE_MODULE_KEY } from './persistence'\nimport type { PersistenceHandle } from './persistence'\nimport type { FormStore } from './create-form-store'\nimport type {\n AbstractSchema,\n FormKey,\n PersistConfig,\n PersistConfigOptions,\n} from '../types/types-api'\nimport type { GenericForm } from '../types/types-core'\n\n/**\n * Dev-only: warn when a second `useForm` lands on the same key with\n * a structurally-different schema. Two schemas resolve their own\n * fingerprints; we compare the strings and flag mismatches. An adapter\n * `fingerprint()` that rejects is caught (never crashes the form) and\n * surfaced as a `console.error` in dev: the mismatch check is skipped,\n * matching the \"allow the inconsistency\" failure mode. See\n * `AbstractSchema.fingerprint()` in types-api.ts for the contract.\n */\nexport async function warnOnSchemaFingerprintMismatch(\n key: FormKey,\n existing: AbstractSchema<GenericForm, GenericForm>,\n incoming: AbstractSchema<GenericForm, GenericForm>\n): Promise<void> {\n let existingFp: string\n let incomingFp: string\n try {\n existingFp = await existing.fingerprint()\n incomingFp = await incoming.fingerprint()\n } catch (error) {\n console.error(\n `[attaform] fingerprint() rejected for key \"${key}\"; skipping mismatch check.`,\n error\n )\n return\n }\n if (existingFp === incomingFp) return\n console.warn(\n `[attaform] useForm() calls with key \"${key}\" use different schemas; first wins, second is ignored. Use identical schemas or unique keys.\\n existing: ${existingFp}\\n incoming: ${incomingFp}`\n )\n}\n\n/**\n * Dev-only: warn when a second `useForm` lands on the same key with a\n * `persist:` config that diverges from what the first call wired. The\n * persist channel is single-IO (one storage key, one debounce timer);\n * silent drop is a high-stakes footgun (\"I configured persist but\n * sessionStorage is empty\"). Skipped when the second call passes no\n * persist config (intentional inheritance), and when the comparison\n * is deemed equivalent (same `storage` reference / kind, same `key`,\n * same `debounceMs`). Custom adapter functions compare by reference\n * — distinct closures look distinct, which is conservative but\n * correct: distinct closures may persist to different backends.\n */\nexport function warnOnPersistDivergence<F extends GenericForm>(\n key: FormKey,\n existing: FormStore<F, GenericForm>,\n incomingPersist: PersistConfig | undefined\n): void {\n if (incomingPersist === undefined) return\n const wired = existing.modules.get(PERSISTENCE_MODULE_KEY) as PersistenceHandle | undefined\n const incomingNormalized = normalizePersistConfig(incomingPersist)\n if (wired === undefined) {\n console.warn(\n `[attaform] useForm({ key: \"${key}\" }) passed a persist config but the first useForm({ key }) call didn't wire persistence; the new config is silently dropped. Pass persist on the first call, or remove persist here to make the inheritance explicit.`\n )\n return\n }\n if (persistConfigsEquivalent(wired.config, incomingNormalized)) return\n console.warn(\n `[attaform] useForm({ key: \"${key}\" }) passed a persist config that differs from the first useForm({ key }) call's; first wins, this one is ignored.\\n wired: ${describePersist(wired.config)}\\n incoming: ${describePersist(incomingNormalized)}`\n )\n}\n\nfunction persistConfigsEquivalent(a: PersistConfigOptions, b: PersistConfigOptions): boolean {\n if (a.storage !== b.storage) return false\n if ((a.key ?? undefined) !== (b.key ?? undefined)) return false\n if ((a.debounceMs ?? undefined) !== (b.debounceMs ?? undefined)) return false\n return true\n}\n\nfunction describePersist(config: PersistConfigOptions): string {\n const storage = typeof config.storage === 'string' ? config.storage : 'custom-adapter'\n const parts = [`storage=${storage}`]\n if (config.key !== undefined) parts.push(`key=${config.key}`)\n if (config.debounceMs !== undefined) parts.push(`debounceMs=${config.debounceMs}`)\n return `{ ${parts.join(', ')} }`\n}\n"],"names":["PERSISTENCE_MODULE_KEY","normalizePersistConfig"],"mappings":";;;;AAwCA,eAAsB,+BAAA,CACpB,GAAA,EACA,QAAA,EACA,QAAA,EACe;AACf,EAAA,IAAI,UAAA;AACJ,EAAA,IAAI,UAAA;AACJ,EAAA,IAAI;AACF,IAAA,UAAA,GAAa,MAAM,SAAS,WAAA,EAAY;AACxC,IAAA,UAAA,GAAa,MAAM,SAAS,WAAA,EAAY;AAAA,EAC1C,SAAS,KAAA,EAAO;AACd,IAAA,OAAA,CAAQ,KAAA;AAAA,MACN,8CAA8C,GAAG,CAAA,2BAAA,CAAA;AAAA,MACjD;AAAA,KACF;AACA,IAAA;AAAA,EACF;AACA,EAAA,IAAI,eAAe,UAAA,EAAY;AAC/B,EAAA,OAAA,CAAQ,IAAA;AAAA,IACN,wCAAwC,GAAG,CAAA;AAAA,YAAA,EAA8G,UAAU;AAAA,YAAA,EAAiB,UAAU,CAAA;AAAA,GAChM;AACF;AAcO,SAAS,uBAAA,CACd,GAAA,EACA,QAAA,EACA,eAAA,EACM;AACN,EAAA,IAAI,oBAAoB,MAAA,EAAW;AACnC,EAAA,MAAM,KAAA,GAAQ,QAAA,CAAS,OAAA,CAAQ,GAAA,CAAIA,mCAAsB,CAAA;AACzD,EAAA,MAAM,kBAAA,GAAqBC,oCAAuB,eAAe,CAAA;AACjE,EAAA,IAAI,UAAU,MAAA,EAAW;AACvB,IAAA,OAAA,CAAQ,IAAA;AAAA,MACN,8BAA8B,GAAG,CAAA,sNAAA;AAAA,KACnC;AACA,IAAA;AAAA,EACF;AACA,EAAA,IAAI,wBAAA,CAAyB,KAAA,CAAM,MAAA,EAAQ,kBAAkB,CAAA,EAAG;AAChE,EAAA,OAAA,CAAQ,IAAA;AAAA,IACN,8BAA8B,GAAG,CAAA;AAAA,YAAA,EAAmI,eAAA,CAAgB,KAAA,CAAM,MAAM,CAAC;AAAA,YAAA,EAAiB,eAAA,CAAgB,kBAAkB,CAAC,CAAA;AAAA,GACvP;AACF;AAEA,SAAS,wBAAA,CAAyB,GAAyB,CAAA,EAAkC;AAC3F,EAAA,IAAI,CAAA,CAAE,OAAA,KAAY,CAAA,CAAE,OAAA,EAAS,OAAO,KAAA;AACpC,EAAA,IAAA,CAAK,EAAE,GAAA,IAAO,MAAA,OAAgB,CAAA,CAAE,GAAA,IAAO,SAAY,OAAO,KAAA;AAC1D,EAAA,IAAA,CAAK,EAAE,UAAA,IAAc,MAAA,OAAgB,CAAA,CAAE,UAAA,IAAc,SAAY,OAAO,KAAA;AACxE,EAAA,OAAO,IAAA;AACT;AAEA,SAAS,gBAAgB,MAAA,EAAsC;AAC7D,EAAA,MAAM,UAAU,OAAO,MAAA,CAAO,OAAA,KAAY,QAAA,GAAW,OAAO,OAAA,GAAU,gBAAA;AACtE,EAAA,MAAM,KAAA,GAAQ,CAAC,CAAA,QAAA,EAAW,OAAO,CAAA,CAAE,CAAA;AACnC,EAAA,IAAI,MAAA,CAAO,QAAQ,MAAA,EAAW,KAAA,CAAM,KAAK,CAAA,IAAA,EAAO,MAAA,CAAO,GAAG,CAAA,CAAE,CAAA;AAC5D,EAAA,IAAI,MAAA,CAAO,eAAe,MAAA,EAAW,KAAA,CAAM,KAAK,CAAA,WAAA,EAAc,MAAA,CAAO,UAAU,CAAA,CAAE,CAAA;AACjF,EAAA,OAAO,CAAA,EAAA,EAAK,KAAA,CAAM,IAAA,CAAK,IAAI,CAAC,CAAA,EAAA,CAAA;AAC9B;;;;;"}
1
+ {"version":3,"file":"dev-key-collision-warnings.cjs","sources":["../../src/runtime/core/dev-key-collision-warnings.ts"],"sourcesContent":["/**\n * Dev-only shared-key collision diagnostics for `useForm`. When two\n * `useForm({ key })` calls land on the same key, they resolve to one\n * `FormStore` by design (the shared-store semantic), and the second\n * call's schema is silently dropped in favour of the first's wiring.\n * The warnings here surface that divergence so a genuine collision (two\n * unrelated call sites that happen to agree on a key) is diagnosable\n * rather than silent.\n *\n * This whole module is loaded behind a `__DEV__`-gated dynamic import in\n * `use-abstract-form.ts`. A production build folds that gate to `false`,\n * dead-code-eliminates the `import()` call, and leaves this module an\n * unreferenced chunk the consumer's bundler drops. Keeping the warnings\n * here (rather than as plain functions called from the gated block)\n * matters because esbuild removes the inline dead branch but NOT a\n * top-level function it is the sole caller of: tree-shaking runs before\n * the define-fold, so the function survives. A separately-imported\n * module sidesteps that and keeps the cluster out of every consumer's\n * production bundle.\n */\nimport type { AbstractSchema, FormKey } from '../types/types-api'\nimport type { GenericForm } from '../types/types-core'\n\n/**\n * Dev-only: warn when a second `useForm` lands on the same key with\n * a structurally-different schema. Two schemas resolve their own\n * fingerprints; we compare the strings and flag mismatches. An adapter\n * `fingerprint()` that rejects is caught (never crashes the form) and\n * surfaced as a `console.error` in dev: the mismatch check is skipped,\n * matching the \"allow the inconsistency\" failure mode. See\n * `AbstractSchema.fingerprint()` in types-api.ts for the contract.\n */\nexport async function warnOnSchemaFingerprintMismatch(\n key: FormKey,\n existing: AbstractSchema<GenericForm, GenericForm>,\n incoming: AbstractSchema<GenericForm, GenericForm>\n): Promise<void> {\n let existingFp: string\n let incomingFp: string\n try {\n existingFp = await existing.fingerprint()\n incomingFp = await incoming.fingerprint()\n } catch (error) {\n console.error(\n `[attaform] fingerprint() rejected for key \"${key}\"; skipping mismatch check.`,\n error\n )\n return\n }\n if (existingFp === incomingFp) return\n console.warn(\n `[attaform] useForm() calls with key \"${key}\" use different schemas; first wins, second is ignored. Use identical schemas or unique keys.\\n existing: ${existingFp}\\n incoming: ${incomingFp}`\n )\n}\n"],"names":[],"mappings":";;AAgCA,eAAsB,+BAAA,CACpB,GAAA,EACA,QAAA,EACA,QAAA,EACe;AACf,EAAA,IAAI,UAAA;AACJ,EAAA,IAAI,UAAA;AACJ,EAAA,IAAI;AACF,IAAA,UAAA,GAAa,MAAM,SAAS,WAAA,EAAY;AACxC,IAAA,UAAA,GAAa,MAAM,SAAS,WAAA,EAAY;AAAA,EAC1C,SAAS,KAAA,EAAO;AACd,IAAA,OAAA,CAAQ,KAAA;AAAA,MACN,8CAA8C,GAAG,CAAA,2BAAA,CAAA;AAAA,MACjD;AAAA,KACF;AACA,IAAA;AAAA,EACF;AACA,EAAA,IAAI,eAAe,UAAA,EAAY;AAC/B,EAAA,OAAA,CAAQ,IAAA;AAAA,IACN,wCAAwC,GAAG,CAAA;AAAA,YAAA,EAA8G,UAAU;AAAA,YAAA,EAAiB,UAAU,CAAA;AAAA,GAChM;AACF;;;;"}
@@ -1,5 +1,3 @@
1
- import { P as PERSISTENCE_MODULE_KEY, n as normalizePersistConfig } from '../shared/attaform.CsB-iKbU.mjs';
2
-
3
1
  async function warnOnSchemaFingerprintMismatch(key, existing, incoming) {
4
2
  let existingFp;
5
3
  let incomingFp;
@@ -20,36 +18,6 @@ async function warnOnSchemaFingerprintMismatch(key, existing, incoming) {
20
18
  incoming: ${incomingFp}`
21
19
  );
22
20
  }
23
- function warnOnPersistDivergence(key, existing, incomingPersist) {
24
- if (incomingPersist === void 0) return;
25
- const wired = existing.modules.get(PERSISTENCE_MODULE_KEY);
26
- const incomingNormalized = normalizePersistConfig(incomingPersist);
27
- if (wired === void 0) {
28
- console.warn(
29
- `[attaform] useForm({ key: "${key}" }) passed a persist config but the first useForm({ key }) call didn't wire persistence; the new config is silently dropped. Pass persist on the first call, or remove persist here to make the inheritance explicit.`
30
- );
31
- return;
32
- }
33
- if (persistConfigsEquivalent(wired.config, incomingNormalized)) return;
34
- console.warn(
35
- `[attaform] useForm({ key: "${key}" }) passed a persist config that differs from the first useForm({ key }) call's; first wins, this one is ignored.
36
- wired: ${describePersist(wired.config)}
37
- incoming: ${describePersist(incomingNormalized)}`
38
- );
39
- }
40
- function persistConfigsEquivalent(a, b) {
41
- if (a.storage !== b.storage) return false;
42
- if ((a.key ?? void 0) !== (b.key ?? void 0)) return false;
43
- if ((a.debounceMs ?? void 0) !== (b.debounceMs ?? void 0)) return false;
44
- return true;
45
- }
46
- function describePersist(config) {
47
- const storage = typeof config.storage === "string" ? config.storage : "custom-adapter";
48
- const parts = [`storage=${storage}`];
49
- if (config.key !== void 0) parts.push(`key=${config.key}`);
50
- if (config.debounceMs !== void 0) parts.push(`debounceMs=${config.debounceMs}`);
51
- return `{ ${parts.join(", ")} }`;
52
- }
53
21
 
54
- export { warnOnPersistDivergence, warnOnSchemaFingerprintMismatch };
22
+ export { warnOnSchemaFingerprintMismatch };
55
23
  //# sourceMappingURL=dev-key-collision-warnings.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"dev-key-collision-warnings.mjs","sources":["../../src/runtime/core/dev-key-collision-warnings.ts"],"sourcesContent":["/**\n * Dev-only shared-key collision diagnostics for `useForm`. When two\n * `useForm({ key })` calls land on the same key, they resolve to one\n * `FormStore` by design (the shared-store semantic), and the second\n * call's schema and `persist:` config are silently dropped in favour of\n * the first's wiring. The warnings here surface that divergence so a\n * genuine collision (two unrelated call sites that happen to agree on a\n * key) is diagnosable rather than silent.\n *\n * This whole module is loaded behind a `__DEV__`-gated dynamic import in\n * `use-abstract-form.ts`. A production build folds that gate to `false`,\n * dead-code-eliminates the `import()` call, and leaves this module an\n * unreferenced chunk the consumer's bundler drops. Keeping the warnings\n * here (rather than as plain functions called from the gated block)\n * matters because esbuild removes the inline dead branch but NOT a\n * top-level function it is the sole caller of: tree-shaking runs before\n * the define-fold, so the function survives. A separately-imported\n * module sidesteps that and keeps the cluster out of every consumer's\n * production bundle.\n */\nimport { normalizePersistConfig, PERSISTENCE_MODULE_KEY } from './persistence'\nimport type { PersistenceHandle } from './persistence'\nimport type { FormStore } from './create-form-store'\nimport type {\n AbstractSchema,\n FormKey,\n PersistConfig,\n PersistConfigOptions,\n} from '../types/types-api'\nimport type { GenericForm } from '../types/types-core'\n\n/**\n * Dev-only: warn when a second `useForm` lands on the same key with\n * a structurally-different schema. Two schemas resolve their own\n * fingerprints; we compare the strings and flag mismatches. An adapter\n * `fingerprint()` that rejects is caught (never crashes the form) and\n * surfaced as a `console.error` in dev: the mismatch check is skipped,\n * matching the \"allow the inconsistency\" failure mode. See\n * `AbstractSchema.fingerprint()` in types-api.ts for the contract.\n */\nexport async function warnOnSchemaFingerprintMismatch(\n key: FormKey,\n existing: AbstractSchema<GenericForm, GenericForm>,\n incoming: AbstractSchema<GenericForm, GenericForm>\n): Promise<void> {\n let existingFp: string\n let incomingFp: string\n try {\n existingFp = await existing.fingerprint()\n incomingFp = await incoming.fingerprint()\n } catch (error) {\n console.error(\n `[attaform] fingerprint() rejected for key \"${key}\"; skipping mismatch check.`,\n error\n )\n return\n }\n if (existingFp === incomingFp) return\n console.warn(\n `[attaform] useForm() calls with key \"${key}\" use different schemas; first wins, second is ignored. Use identical schemas or unique keys.\\n existing: ${existingFp}\\n incoming: ${incomingFp}`\n )\n}\n\n/**\n * Dev-only: warn when a second `useForm` lands on the same key with a\n * `persist:` config that diverges from what the first call wired. The\n * persist channel is single-IO (one storage key, one debounce timer);\n * silent drop is a high-stakes footgun (\"I configured persist but\n * sessionStorage is empty\"). Skipped when the second call passes no\n * persist config (intentional inheritance), and when the comparison\n * is deemed equivalent (same `storage` reference / kind, same `key`,\n * same `debounceMs`). Custom adapter functions compare by reference\n * — distinct closures look distinct, which is conservative but\n * correct: distinct closures may persist to different backends.\n */\nexport function warnOnPersistDivergence<F extends GenericForm>(\n key: FormKey,\n existing: FormStore<F, GenericForm>,\n incomingPersist: PersistConfig | undefined\n): void {\n if (incomingPersist === undefined) return\n const wired = existing.modules.get(PERSISTENCE_MODULE_KEY) as PersistenceHandle | undefined\n const incomingNormalized = normalizePersistConfig(incomingPersist)\n if (wired === undefined) {\n console.warn(\n `[attaform] useForm({ key: \"${key}\" }) passed a persist config but the first useForm({ key }) call didn't wire persistence; the new config is silently dropped. Pass persist on the first call, or remove persist here to make the inheritance explicit.`\n )\n return\n }\n if (persistConfigsEquivalent(wired.config, incomingNormalized)) return\n console.warn(\n `[attaform] useForm({ key: \"${key}\" }) passed a persist config that differs from the first useForm({ key }) call's; first wins, this one is ignored.\\n wired: ${describePersist(wired.config)}\\n incoming: ${describePersist(incomingNormalized)}`\n )\n}\n\nfunction persistConfigsEquivalent(a: PersistConfigOptions, b: PersistConfigOptions): boolean {\n if (a.storage !== b.storage) return false\n if ((a.key ?? undefined) !== (b.key ?? undefined)) return false\n if ((a.debounceMs ?? undefined) !== (b.debounceMs ?? undefined)) return false\n return true\n}\n\nfunction describePersist(config: PersistConfigOptions): string {\n const storage = typeof config.storage === 'string' ? config.storage : 'custom-adapter'\n const parts = [`storage=${storage}`]\n if (config.key !== undefined) parts.push(`key=${config.key}`)\n if (config.debounceMs !== undefined) parts.push(`debounceMs=${config.debounceMs}`)\n return `{ ${parts.join(', ')} }`\n}\n"],"names":[],"mappings":";;AAwCA,eAAsB,+BAAA,CACpB,GAAA,EACA,QAAA,EACA,QAAA,EACe;AACf,EAAA,IAAI,UAAA;AACJ,EAAA,IAAI,UAAA;AACJ,EAAA,IAAI;AACF,IAAA,UAAA,GAAa,MAAM,SAAS,WAAA,EAAY;AACxC,IAAA,UAAA,GAAa,MAAM,SAAS,WAAA,EAAY;AAAA,EAC1C,SAAS,KAAA,EAAO;AACd,IAAA,OAAA,CAAQ,KAAA;AAAA,MACN,8CAA8C,GAAG,CAAA,2BAAA,CAAA;AAAA,MACjD;AAAA,KACF;AACA,IAAA;AAAA,EACF;AACA,EAAA,IAAI,eAAe,UAAA,EAAY;AAC/B,EAAA,OAAA,CAAQ,IAAA;AAAA,IACN,wCAAwC,GAAG,CAAA;AAAA,YAAA,EAA8G,UAAU;AAAA,YAAA,EAAiB,UAAU,CAAA;AAAA,GAChM;AACF;AAcO,SAAS,uBAAA,CACd,GAAA,EACA,QAAA,EACA,eAAA,EACM;AACN,EAAA,IA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CAAE,CAAA;AAC5D,EAAA,IAAI,MAAA,CAAO,eAAe,MAAA,EAAW,KAAA,CAAM,KAAK,CAAA,WAAA,EAAc,MAAA,CAAO,UAAU,CAAA,CAAE,CAAA;AACjF,EAAA,OAAO,CAAA,EAAA,EAAK,KAAA,CAAM,IAAA,CAAK,IAAI,CAAC,CAAA,EAAA,CAAA;AAC9B;;;;"}
1
+ {"version":3,"file":"dev-key-collision-warnings.mjs","sources":["../../src/runtime/core/dev-key-collision-warnings.ts"],"sourcesContent":["/**\n * Dev-only shared-key collision diagnostics for `useForm`. When two\n * `useForm({ key })` calls land on the same key, they resolve to one\n * `FormStore` by design (the shared-store semantic), and the second\n * call's schema is silently dropped in favour of the first's wiring.\n * The warnings here surface that divergence so a genuine collision (two\n * unrelated call sites that happen to agree on a key) is diagnosable\n * rather than silent.\n *\n * This whole module is loaded behind a `__DEV__`-gated dynamic import in\n * `use-abstract-form.ts`. A production build folds that gate to `false`,\n * dead-code-eliminates the `import()` call, and leaves this module an\n * unreferenced chunk the consumer's bundler drops. Keeping the warnings\n * here (rather than as plain functions called from the gated block)\n * matters because esbuild removes the inline dead branch but NOT a\n * top-level function it is the sole caller of: tree-shaking runs before\n * the define-fold, so the function survives. A separately-imported\n * module sidesteps that and keeps the cluster out of every consumer's\n * production bundle.\n */\nimport type { AbstractSchema, FormKey } from '../types/types-api'\nimport type { GenericForm } from '../types/types-core'\n\n/**\n * Dev-only: warn when a second `useForm` lands on the same key with\n * a structurally-different schema. Two schemas resolve their own\n * fingerprints; we compare the strings and flag mismatches. An adapter\n * `fingerprint()` that rejects is caught (never crashes the form) and\n * surfaced as a `console.error` in dev: the mismatch check is skipped,\n * matching the \"allow the inconsistency\" failure mode. See\n * `AbstractSchema.fingerprint()` in types-api.ts for the contract.\n */\nexport async function warnOnSchemaFingerprintMismatch(\n key: FormKey,\n existing: AbstractSchema<GenericForm, GenericForm>,\n incoming: AbstractSchema<GenericForm, GenericForm>\n): Promise<void> {\n let existingFp: string\n let incomingFp: string\n try {\n existingFp = await existing.fingerprint()\n incomingFp = await incoming.fingerprint()\n } catch (error) {\n console.error(\n `[attaform] fingerprint() rejected for key \"${key}\"; skipping mismatch check.`,\n error\n )\n return\n }\n if (existingFp === incomingFp) return\n console.warn(\n `[attaform] useForm() calls with key \"${key}\" use different schemas; first wins, second is ignored. Use identical schemas or unique keys.\\n existing: ${existingFp}\\n incoming: ${incomingFp}`\n )\n}\n"],"names":[],"mappings":"AAgCA,eAAsB,+BAAA,CACpB,GAAA,EACA,QAAA,EACA,QAAA,EACe;AACf,EAAA,IAAI,UAAA;AACJ,EAAA,IAAI,UAAA;AACJ,EAAA,IAAI;AACF,IAAA,UAAA,GAAa,MAAM,SAAS,WAAA,EAAY;AACxC,IAAA,UAAA,GAAa,MAAM,SAAS,WAAA,EAAY;AAAA,EAC1C,SAAS,KAAA,EAAO;AACd,IAAA,OAAA,CAAQ,KAAA;AAAA,MACN,8CAA8C,GAAG,CAAA,2BAAA,CAAA;AAAA,MACjD;AAAA,KACF;AACA,IAAA;AAAA,EACF;AACA,EAAA,IAAI,eAAe,UAAA,EAAY;AAC/B,EAAA,OAAA,CAAQ,IAAA;AAAA,IACN,wCAAwC,GAAG,CAAA;AAAA,YAAA,EAA8G,UAAU;AAAA,YAAA,EAAiB,UAAU,CAAA;AAAA,GAChM;AACF;;;;"}
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const paths = require('../shared/attaform.01iKS_lz.cjs');
3
+ const paths = require('../shared/attaform.DwkU0oY9.cjs');
4
4
 
5
5
  const INSPECTOR_ID = "attaform";
6
6
  const TIMELINE_LAYER_ID = "attaform:events";
@@ -145,10 +145,8 @@ function wire(api, app, registry) {
145
145
  const section = payload.path[0];
146
146
  if (section !== "Form value") return;
147
147
  const segments = payload.path.slice(2);
148
- const { segments: canonicalPath, key: canonicalKey } = paths.canonicalizePath(segments);
149
- state.setValueAtPath(canonicalPath, payload.state.value, {
150
- persist: state.persistOptIns.hasAnyOptInForPath(canonicalKey)
151
- });
148
+ const { segments: canonicalPath } = paths.canonicalizePath(segments);
149
+ state.setValueAtPath(canonicalPath, payload.state.value);
152
150
  refreshState();
153
151
  });
154
152
  syncForms();
@@ -1 +1 @@
1
- {"version":3,"file":"devtools.cjs","sources":["../../src/runtime/core/devtools.ts"],"sourcesContent":["import type { App } from 'vue'\nimport type { FormStore } from './create-form-store'\nimport type { AttaformRegistry } from './registry'\nimport type { GenericForm } from '../types/types-core'\nimport type { FormKey } from '../types/types-api'\nimport { canonicalizePath } from './paths'\n\n/**\n * Vue DevTools plugin wiring for attaform. Lazy-imported by\n * `createAttaform` under dev-mode guards so the production\n * bundle tree-shakes it out entirely.\n *\n * Registers:\n * - An inspector (per-app) that lists every registered form, with\n * nodes for form value / errors / aggregates / history.\n * - A timeline layer that emits events on submit start/success/\n * failure, reset, undo, redo, and form mutations.\n * - State editing — modifying a leaf inside the inspector tree\n * pushes through `state.setValueAtPath`, mutating the form.\n *\n * Tolerant of missing `@vue/devtools-api` — the peer dep is marked\n * optional. If the import fails, `setupAttaformDevtools` silently\n * no-ops so production builds / users without DevTools installed\n * don't see errors.\n */\n\nconst INSPECTOR_ID = 'attaform'\nconst TIMELINE_LAYER_ID = 'attaform:events'\n\ntype UnsafeDevtoolsApi = {\n addInspector(opts: { id: string; label: string; icon?: string; app: App }): void\n addTimelineLayer(opts: { id: string; label: string; color: number }): void\n sendInspectorTree(inspectorId: string): void\n sendInspectorState(inspectorId: string): void\n addTimelineEvent(payload: {\n layerId: string\n event: {\n time: number\n title: string\n subtitle?: string\n data?: Record<string, unknown>\n groupId?: string | number\n }\n }): void\n on: {\n getInspectorTree(\n handler: (payload: {\n inspectorId: string\n filter: string\n rootNodes: Array<{ id: string; label: string; tags?: unknown[] }>\n }) => void\n ): void\n getInspectorState(\n handler: (payload: {\n inspectorId: string\n nodeId: string\n state: Record<string, Array<{ key: string; value: unknown; editable?: boolean }>>\n }) => void\n ): void\n editInspectorState(\n handler: (payload: {\n inspectorId: string\n nodeId: string\n path: string[]\n state: { value: unknown; newKey?: string | null; remove?: boolean }\n }) => void\n ): void\n }\n}\n\ntype SetupDevtoolsPluginFn = (\n descriptor: {\n id: string\n label: string\n packageName?: string\n homepage?: string\n componentStateTypes?: string[]\n app: App\n },\n setup: (api: UnsafeDevtoolsApi) => void\n) => void\n\n/**\n * Install the DevTools plugin for the given Vue app + registry. Safe\n * to call in production — if `@vue/devtools-api` isn't installed, the\n * dynamic import fails and we log nothing. Returns `true` when\n * DevTools was wired successfully, `false` otherwise — useful for\n * tests.\n */\nexport async function setupAttaformDevtools(\n app: App,\n registry: AttaformRegistry\n): Promise<boolean> {\n let mod: { setupDevtoolsPlugin?: SetupDevtoolsPluginFn }\n try {\n mod = (await import('@vue/devtools-api')) as {\n setupDevtoolsPlugin?: SetupDevtoolsPluginFn\n }\n } catch {\n // Peer dep not installed — silently skip. Production builds pass\n // `{ devtools: false }` explicitly, but this catch covers the\n // \"dev without the peer dep\" case without a noisy warning.\n return false\n }\n const setupDevtoolsPlugin = mod.setupDevtoolsPlugin\n if (typeof setupDevtoolsPlugin !== 'function') return false\n\n setupDevtoolsPlugin(\n {\n id: INSPECTOR_ID,\n label: 'Attaform',\n packageName: 'attaform',\n homepage: 'https://github.com/attaform/Attaform',\n app,\n componentStateTypes: ['Attaform form'],\n },\n (api) => wire(api, app, registry)\n )\n return true\n}\n\nfunction wire(api: UnsafeDevtoolsApi, app: App, registry: AttaformRegistry): void {\n // Per-form subscriber bookkeeping — we keep the unsubscribers so\n // the registry's eviction path can detach them when a form is\n // disposed. Using a Map keyed by FormKey mirrors the registry.\n const subscriberUnsubs = new Map<FormKey, () => void>()\n\n api.addInspector({ id: INSPECTOR_ID, label: 'Attaform', app })\n api.addTimelineLayer({ id: TIMELINE_LAYER_ID, label: 'Attaform', color: 0x5b8def })\n\n function refreshTree(): void {\n api.sendInspectorTree(INSPECTOR_ID)\n }\n\n function refreshState(): void {\n api.sendInspectorState(INSPECTOR_ID)\n }\n\n function subscribeForm(state: FormStore<GenericForm>): void {\n if (subscriberUnsubs.has(state.formKey)) return\n const unsubChange = state.onFormChange(() => {\n refreshState()\n api.addTimelineEvent({\n layerId: TIMELINE_LAYER_ID,\n event: {\n time: Date.now(),\n title: 'form.change',\n subtitle: state.formKey,\n // Devtools is dev-only — emit raw values. Consumers worried\n // about screen-share leaks should close the panel before\n // sharing, same as they would for the browser DevTools\n // console.\n data: { form: state.form.value as Record<string, unknown> },\n },\n })\n })\n const unsubSubmit = state.onSubmitSuccess(() => {\n api.addTimelineEvent({\n layerId: TIMELINE_LAYER_ID,\n event: {\n time: Date.now(),\n title: 'submit.success',\n subtitle: state.formKey,\n data: { form: state.form.value as Record<string, unknown> },\n },\n })\n })\n const unsubReset = state.onReset(() => {\n refreshState()\n api.addTimelineEvent({\n layerId: TIMELINE_LAYER_ID,\n event: {\n time: Date.now(),\n title: 'reset',\n subtitle: state.formKey,\n },\n })\n })\n subscriberUnsubs.set(state.formKey, () => {\n unsubChange()\n unsubSubmit()\n unsubReset()\n })\n }\n\n // Subscribe all currently-registered forms + register as they're\n // added. The registry's `forms` Map is shallowReactive — we poll\n // once per render on refresh; for live change detection, each\n // useForm call that adds a new form triggers a tree/state refresh\n // via the form's own onFormChange emission on the first\n // applyFormReplacement.\n function syncForms(): void {\n for (const [, state] of registry.forms) {\n subscribeForm(state)\n }\n // Drop subscribers for forms that were evicted.\n for (const [formKey, unsub] of subscriberUnsubs) {\n if (!registry.forms.has(formKey)) {\n unsub()\n subscriberUnsubs.delete(formKey)\n }\n }\n }\n\n api.on.getInspectorTree((payload) => {\n if (payload.inspectorId !== INSPECTOR_ID) return\n syncForms()\n payload.rootNodes = [...registry.forms.keys()].map((key) => ({\n id: `form:${key}`,\n label: key,\n tags: [],\n }))\n })\n\n api.on.getInspectorState((payload) => {\n if (payload.inspectorId !== INSPECTOR_ID) return\n if (!payload.nodeId.startsWith('form:')) return\n const formKey = payload.nodeId.slice('form:'.length)\n const state = registry.forms.get(formKey)\n if (state === undefined) return\n // Devtools is dev-only — render raw values for everything,\n // including sensitive-named paths. Consumers concerned about\n // screen-share leaks should close the panel before sharing.\n payload.state['Form value'] = [\n {\n key: 'form',\n value: state.form.value,\n editable: true,\n },\n ]\n // Schema-driven and user-injected errors land in separate inspector\n // sections so devs can see the source distinction at a glance — a\n // user-injected entry surviving a successful submit, or a schema\n // entry that should have cleared after a value fix, are immediately\n // visible without cross-referencing call sites.\n payload.state['Schema Errors'] = [\n ...[...state.schemaErrors.entries()].map(([k, v]) => ({\n key: String(k),\n value: v as unknown,\n })),\n ]\n payload.state['User Errors'] = [\n ...[...state.userErrors.entries()].map(([k, v]) => ({\n key: String(k),\n value: v as unknown,\n })),\n ]\n payload.state['Aggregates'] = [\n { key: 'submitting', value: state.submitting.value },\n { key: 'submissionAttempts', value: state.submissionAttempts.value },\n { key: 'departAttempts', value: state.departAttempts.value },\n { key: 'submitError', value: state.submitError.value },\n { key: 'activeValidations', value: state.activeValidations.value },\n ]\n })\n\n api.on.editInspectorState((payload) => {\n if (payload.inspectorId !== INSPECTOR_ID) return\n if (!payload.nodeId.startsWith('form:')) return\n const formKey = payload.nodeId.slice('form:'.length)\n const state = registry.forms.get(formKey)\n if (state === undefined) return\n // payload.path is `['Form value', 'form', ...pathSegments]` — the\n // first two segments are the inspector section + key, the rest is\n // the target form path the user edited. Pass the segment array\n // directly to `canonicalizePath`: join('.') would collapse a\n // literal-dot field key (`{\"user.email\": ...}`) into two segments,\n // writing to the wrong leaf.\n if (payload.path.length < 3) return\n const section = payload.path[0]\n if (section !== 'Form value') return\n const segments = payload.path.slice(2)\n const { segments: canonicalPath, key: canonicalKey } = canonicalizePath(segments)\n // A devtools edit on a path that any element has opted in to should\n // persist (matches the user's expectation: editing via the inspector\n // should be indistinguishable from typing into the bound input).\n // No opt-in for this path → no write.\n state.setValueAtPath(canonicalPath, payload.state.value, {\n persist: state.persistOptIns.hasAnyOptInForPath(canonicalKey),\n })\n refreshState()\n })\n\n // Initial sync so existing for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;"}
1
+ {"version":3,"file":"devtools.cjs","sources":["../../src/runtime/core/devtools.ts"],"sourcesContent":["import type { App } from 'vue'\nimport type { FormStore } from './create-form-store'\nimport type { AttaformRegistry } from './registry'\nimport type { GenericForm } from '../types/types-core'\nimport type { FormKey } from '../types/types-api'\nimport { canonicalizePath } from './paths'\n\n/**\n * Vue DevTools plugin wiring for attaform. Lazy-imported by\n * `createAttaform` under dev-mode guards so the production\n * bundle tree-shakes it out entirely.\n *\n * Registers:\n * - An inspector (per-app) that lists every registered form, with\n * nodes for form value / errors / aggregates / history.\n * - A timeline layer that emits events on submit start/success/\n * failure, reset, undo, redo, and form mutations.\n * - State editing — modifying a leaf inside the inspector tree\n * pushes through `state.setValueAtPath`, mutating the form.\n *\n * Tolerant of missing `@vue/devtools-api` — the peer dep is marked\n * optional. If the import fails, `setupAttaformDevtools` silently\n * no-ops so production builds / users without DevTools installed\n * don't see errors.\n */\n\nconst INSPECTOR_ID = 'attaform'\nconst TIMELINE_LAYER_ID = 'attaform:events'\n\ntype UnsafeDevtoolsApi = {\n addInspector(opts: { id: string; label: string; icon?: string; app: App }): void\n addTimelineLayer(opts: { id: string; label: string; color: number }): void\n sendInspectorTree(inspectorId: string): void\n sendInspectorState(inspectorId: string): void\n addTimelineEvent(payload: {\n layerId: string\n event: {\n time: number\n title: string\n subtitle?: string\n data?: Record<string, unknown>\n groupId?: string | number\n }\n }): void\n on: {\n getInspectorTree(\n handler: (payload: {\n inspectorId: string\n filter: string\n rootNodes: Array<{ id: string; label: string; tags?: unknown[] }>\n }) => void\n ): void\n getInspectorState(\n handler: (payload: {\n inspectorId: string\n nodeId: string\n state: Record<string, Array<{ key: string; value: unknown; editable?: boolean }>>\n }) => void\n ): void\n editInspectorState(\n handler: (payload: {\n inspectorId: string\n nodeId: string\n path: string[]\n state: { value: unknown; newKey?: string | null; remove?: boolean }\n }) => void\n ): void\n }\n}\n\ntype SetupDevtoolsPluginFn = (\n descriptor: {\n id: string\n label: string\n packageName?: string\n homepage?: string\n componentStateTypes?: string[]\n app: App\n },\n setup: (api: UnsafeDevtoolsApi) => void\n) => void\n\n/**\n * Install the DevTools plugin for the given Vue app + registry. Safe\n * to call in production — if `@vue/devtools-api` isn't installed, the\n * dynamic import fails and we log nothing. Returns `true` when\n * DevTools was wired successfully, `false` otherwise — useful for\n * tests.\n */\nexport async function setupAttaformDevtools(\n app: App,\n registry: AttaformRegistry\n): Promise<boolean> {\n let mod: { setupDevtoolsPlugin?: SetupDevtoolsPluginFn }\n try {\n mod = (await import('@vue/devtools-api')) as {\n setupDevtoolsPlugin?: SetupDevtoolsPluginFn\n }\n } catch {\n // Peer dep not installed — silently skip. Production builds pass\n // `{ devtools: false }` explicitly, but this catch covers the\n // \"dev without the peer dep\" case without a noisy warning.\n return false\n }\n const setupDevtoolsPlugin = mod.setupDevtoolsPlugin\n if (typeof setupDevtoolsPlugin !== 'function') return false\n\n setupDevtoolsPlugin(\n {\n id: INSPECTOR_ID,\n label: 'Attaform',\n packageName: 'attaform',\n homepage: 'https://github.com/attaform/Attaform',\n app,\n componentStateTypes: ['Attaform form'],\n },\n (api) => wire(api, app, registry)\n )\n return true\n}\n\nfunction wire(api: UnsafeDevtoolsApi, app: App, registry: AttaformRegistry): void {\n // Per-form subscriber bookkeeping — we keep the unsubscribers so\n // the registry's eviction path can detach them when a form is\n // disposed. Using a Map keyed by FormKey mirrors the registry.\n const subscriberUnsubs = new Map<FormKey, () => void>()\n\n api.addInspector({ id: INSPECTOR_ID, label: 'Attaform', app })\n api.addTimelineLayer({ id: TIMELINE_LAYER_ID, label: 'Attaform', color: 0x5b8def })\n\n function refreshTree(): void {\n api.sendInspectorTree(INSPECTOR_ID)\n }\n\n function refreshState(): void {\n api.sendInspectorState(INSPECTOR_ID)\n }\n\n function subscribeForm(state: FormStore<GenericForm>): void {\n if (subscriberUnsubs.has(state.formKey)) return\n const unsubChange = state.onFormChange(() => {\n refreshState()\n api.addTimelineEvent({\n layerId: TIMELINE_LAYER_ID,\n event: {\n time: Date.now(),\n title: 'form.change',\n subtitle: state.formKey,\n // Devtools is dev-only — emit raw values. Consumers worried\n // about screen-share leaks should close the panel before\n // sharing, same as they would for the browser DevTools\n // console.\n data: { form: state.form.value as Record<string, unknown> },\n },\n })\n })\n const unsubSubmit = state.onSubmitSuccess(() => {\n api.addTimelineEvent({\n layerId: TIMELINE_LAYER_ID,\n event: {\n time: Date.now(),\n title: 'submit.success',\n subtitle: state.formKey,\n data: { form: state.form.value as Record<string, unknown> },\n },\n })\n })\n const unsubReset = state.onReset(() => {\n refreshState()\n api.addTimelineEvent({\n layerId: TIMELINE_LAYER_ID,\n event: {\n time: Date.now(),\n title: 'reset',\n subtitle: state.formKey,\n },\n })\n })\n subscriberUnsubs.set(state.formKey, () => {\n unsubChange()\n unsubSubmit()\n unsubReset()\n })\n }\n\n // Subscribe all currently-registered forms + register as they're\n // added. The registry's `forms` Map is shallowReactive — we poll\n // once per render on refresh; for live change detection, each\n // useForm call that adds a new form triggers a tree/state refresh\n // via the form's own onFormChange emission on the first\n // applyFormReplacement.\n function syncForms(): void {\n for (const [, state] of registry.forms) {\n subscribeForm(state)\n }\n // Drop subscribers for forms that were evicted.\n for (const [formKey, unsub] of subscriberUnsubs) {\n if (!registry.forms.has(formKey)) {\n unsub()\n subscriberUnsubs.delete(formKey)\n }\n }\n }\n\n api.on.getInspectorTree((payload) => {\n if (payload.inspectorId !== INSPECTOR_ID) return\n syncForms()\n payload.rootNodes = [...registry.forms.keys()].map((key) => ({\n id: `form:${key}`,\n label: key,\n tags: [],\n }))\n })\n\n api.on.getInspectorState((payload) => {\n if (payload.inspectorId !== INSPECTOR_ID) return\n if (!payload.nodeId.startsWith('form:')) return\n const formKey = payload.nodeId.slice('form:'.length)\n const state = registry.forms.get(formKey)\n if (state === undefined) return\n // Devtools is dev-only — render raw values for everything,\n // including sensitive-named paths. Consumers concerned about\n // screen-share leaks should close the panel before sharing.\n payload.state['Form value'] = [\n {\n key: 'form',\n value: state.form.value,\n editable: true,\n },\n ]\n // Schema-driven and user-injected errors land in separate inspector\n // sections so devs can see the source distinction at a glance — a\n // user-injected entry surviving a successful submit, or a schema\n // entry that should have cleared after a value fix, are immediately\n // visible without cross-referencing call sites.\n payload.state['Schema Errors'] = [\n ...[...state.schemaErrors.entries()].map(([k, v]) => ({\n key: String(k),\n value: v as unknown,\n })),\n ]\n payload.state['User Errors'] = [\n ...[...state.userErrors.entries()].map(([k, v]) => ({\n key: String(k),\n value: v as unknown,\n })),\n ]\n payload.state['Aggregates'] = [\n { key: 'submitting', value: state.submitting.value },\n { key: 'submissionAttempts', value: state.submissionAttempts.value },\n { key: 'departAttempts', value: state.departAttempts.value },\n { key: 'submitError', value: state.submitError.value },\n { key: 'activeValidations', value: state.activeValidations.value },\n ]\n })\n\n api.on.editInspectorState((payload) => {\n if (payload.inspectorId !== INSPECTOR_ID) return\n if (!payload.nodeId.startsWith('form:')) return\n const formKey = payload.nodeId.slice('form:'.length)\n const state = registry.forms.get(formKey)\n if (state === undefined) return\n // payload.path is `['Form value', 'form', ...pathSegments]` — the\n // first two segments are the inspector section + key, the rest is\n // the target form path the user edited. Pass the segment array\n // directly to `canonicalizePath`: join('.') would collapse a\n // literal-dot field key (`{\"user.email\": ...}`) into two segments,\n // writing to the wrong leaf.\n if (payload.path.length < 3) return\n const section = payload.path[0]\n if (section !== 'Form value') return\n const segments = payload.path.slice(2)\n const { segments: canonicalPath } = canonicalizePath(segments)\n state.setValueAtPath(canonicalPath, payload.state.value)\n refreshState()\n })\n\n // Initial sync so existing forms show up.\n syncForms()\n refreshTree()\n}\n"],"names":["canonicalizePath"],"mappings":";;;;AA0BA,MAAM,YAAA,GAAe,UAAA;AACrB,MAAM,iBAAA,GAAoB,iBAAA;AA8D1B,eAAsB,qBAAA,CACpB,KACA,QAAA,EACkB;AAClB,EAAA,IAAI,GAAA;AACJ,EAAA,IAAI;AACF,IAAA,GAAA,GAAO,MAAM,OAAO,mBAAmB,CAAA;AAAA,EAGzC,CAAA,CAAA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,IAAI,OAAA,CAAQ,gBAAgB,YAAA,EAAc;AAC1C,IAAA,IAAI,CAAC,OAAA,CAAQ,MAAA,CAAO,UAAA,CAAW,OAAO,CAAA,EAAG;AACzC,IAAA,MAAM,OAAA,GAAU,OAAA,CAAQ,MAAA,CAAO,KAAA,CAAM,QAAQ,MAAM,CAAA;AACnD,IAAA,MAAM,KAAA,GAAQ,QAAA,CAAS,KAAA,CAAM,GAAA,CAAI,OAAO,CAAA;AACxC,IAAA,IAAI,UAAU,MAAA,EAAW;AAOzB,IAAA,IAAI,OAAA,CAAQ,IAAA,CAAK,MAAA,GAAS,CAAA,EAAG;AAC7B,IAAA,MAAM,OAAA,GAAU,OAAA,CAAQ,IAAA,CAAK,CAAC,CAAA;AAC9B,IAAA,IAAI,YAAY,YAAA,EAAc;AAC9B,IAAA,MAAM,QAAA,GAAW,OAAA,CAAQ,IAAA,CAAK,KAAA,CAAM,CAAC,CAAA;AACrC,IAAA,MAAM,EAAE,QAAA,EAAU,aAAA,EAAc,GAAIA,uBAAiB,QAAQ,CAAA;AAC7D,IAAA,KAAA,CAAM,cAAA,CAAe,aAAA,EAAe,OAAA,CAAQ,KAAA,CAAM,KAAK,CAAA;AACvD,IAAA,YAAA,EAAa;AAAA,EACf,CAAC,CAAA;AAGD,EAAA,SAAA,EAAU;AACV,EAAA,WAAA,EAAY;AACd;;;;"}
@@ -1,4 +1,4 @@
1
- import { a as canonicalizePath } from '../shared/attaform.BKFwekY2.mjs';
1
+ import { f as canonicalizePath } from '../shared/attaform.Df-s8j1X.mjs';
2
2
 
3
3
  const INSPECTOR_ID = "attaform";
4
4
  const TIMELINE_LAYER_ID = "attaform:events";
@@ -143,10 +143,8 @@ function wire(api, app, registry) {
143
143
  const section = payload.path[0];
144
144
  if (section !== "Form value") return;
145
145
  const segments = payload.path.slice(2);
146
- const { segments: canonicalPath, key: canonicalKey } = canonicalizePath(segments);
147
- state.setValueAtPath(canonicalPath, payload.state.value, {
148
- persist: state.persistOptIns.hasAnyOptInForPath(canonicalKey)
149
- });
146
+ const { segments: canonicalPath } = canonicalizePath(segments);
147
+ state.setValueAtPath(canonicalPath, payload.state.value);
150
148
  refreshState();
151
149
  });
152
150
  syncForms();
@@ -1 +1 @@
1
- {"version":3,"file":"devtools.mjs","sources":["../../src/runtime/core/devtools.ts"],"sourcesContent":["import type { App } from 'vue'\nimport type { FormStore } from './create-form-store'\nimport type { AttaformRegistry } from './registry'\nimport type { GenericForm } from '../types/types-core'\nimport type { FormKey } from '../types/types-api'\nimport { canonicalizePath } from './paths'\n\n/**\n * Vue DevTools plugin wiring for attaform. Lazy-imported by\n * `createAttaform` under dev-mode guards so the production\n * bundle tree-shakes it out entirely.\n *\n * Registers:\n * - An inspector (per-app) that lists every registered form, with\n * nodes for form value / errors / aggregates / history.\n * - A timeline layer that emits events on submit start/success/\n * failure, reset, undo, redo, and form mutations.\n * - State editing — modifying a leaf inside the inspector tree\n * pushes through `state.setValueAtPath`, mutating the form.\n *\n * Tolerant of missing `@vue/devtools-api` — the peer dep is marked\n * optional. If the import fails, `setupAttaformDevtools` silently\n * no-ops so production builds / users without DevTools installed\n * don't see errors.\n */\n\nconst INSPECTOR_ID = 'attaform'\nconst TIMELINE_LAYER_ID = 'attaform:events'\n\ntype UnsafeDevtoolsApi = {\n addInspector(opts: { id: string; label: string; icon?: string; app: App }): void\n addTimelineLayer(opts: { id: string; label: string; color: number }): void\n sendInspectorTree(inspectorId: string): void\n sendInspectorState(inspectorId: string): void\n addTimelineEvent(payload: {\n layerId: string\n event: {\n time: number\n title: string\n subtitle?: string\n data?: Record<string, unknown>\n groupId?: string | number\n }\n }): void\n on: {\n getInspectorTree(\n handler: (payload: {\n inspectorId: string\n filter: string\n rootNodes: Array<{ id: string; label: string; tags?: unknown[] }>\n }) => void\n ): void\n getInspectorState(\n handler: (payload: {\n inspectorId: string\n nodeId: string\n state: Record<string, Array<{ key: string; value: unknown; editable?: boolean }>>\n }) => void\n ): void\n editInspectorState(\n handler: (payload: {\n inspectorId: string\n nodeId: string\n path: string[]\n state: { value: unknown; newKey?: string | null; remove?: boolean }\n }) => void\n ): void\n }\n}\n\ntype SetupDevtoolsPluginFn = (\n descriptor: {\n id: string\n label: string\n packageName?: string\n homepage?: string\n componentStateTypes?: string[]\n app: App\n },\n setup: (api: UnsafeDevtoolsApi) => void\n) => void\n\n/**\n * Install the DevTools plugin for the given Vue app + registry. Safe\n * to call in production — if `@vue/devtools-api` isn't installed, the\n * dynamic import fails and we log nothing. Returns `true` when\n * DevTools was wired successfully, `false` otherwise — useful for\n * tests.\n */\nexport async function setupAttaformDevtools(\n app: App,\n registry: AttaformRegistry\n): Promise<boolean> {\n let mod: { setupDevtoolsPlugin?: SetupDevtoolsPluginFn }\n try {\n mod = (await import('@vue/devtools-api')) as {\n setupDevtoolsPlugin?: SetupDevtoolsPluginFn\n }\n } catch {\n // Peer dep not installed — silently skip. Production builds pass\n // `{ devtools: false }` explicitly, but this catch covers the\n // \"dev without the peer dep\" case without a noisy warning.\n return false\n }\n const setupDevtoolsPlugin = mod.setupDevtoolsPlugin\n if (typeof setupDevtoolsPlugin !== 'function') return false\n\n setupDevtoolsPlugin(\n {\n id: INSPECTOR_ID,\n label: 'Attaform',\n packageName: 'attaform',\n homepage: 'https://github.com/attaform/Attaform',\n app,\n componentStateTypes: ['Attaform form'],\n },\n (api) => wire(api, app, registry)\n )\n return true\n}\n\nfunction wire(api: UnsafeDevtoolsApi, app: App, registry: AttaformRegistry): void {\n // Per-form subscriber bookkeeping — we keep the unsubscribers so\n // the registry's eviction path can detach them when a form is\n // disposed. Using a Map keyed by FormKey mirrors the registry.\n const subscriberUnsubs = new Map<FormKey, () => void>()\n\n api.addInspector({ id: INSPECTOR_ID, label: 'Attaform', app })\n api.addTimelineLayer({ id: TIMELINE_LAYER_ID, label: 'Attaform', color: 0x5b8def })\n\n function refreshTree(): void {\n api.sendInspectorTree(INSPECTOR_ID)\n }\n\n function refreshState(): void {\n api.sendInspectorState(INSPECTOR_ID)\n }\n\n function subscribeForm(state: FormStore<GenericForm>): void {\n if (subscriberUnsubs.has(state.formKey)) return\n const unsubChange = state.onFormChange(() => {\n refreshState()\n api.addTimelineEvent({\n layerId: TIMELINE_LAYER_ID,\n event: {\n time: Date.now(),\n title: 'form.change',\n subtitle: state.formKey,\n // Devtools is dev-only — emit raw values. Consumers worried\n // about screen-share leaks should close the panel before\n // sharing, same as they would for the browser DevTools\n // console.\n data: { form: state.form.value as Record<string, unknown> },\n },\n })\n })\n const unsubSubmit = state.onSubmitSuccess(() => {\n api.addTimelineEvent({\n layerId: TIMELINE_LAYER_ID,\n event: {\n time: Date.now(),\n title: 'submit.success',\n subtitle: state.formKey,\n data: { form: state.form.value as Record<string, unknown> },\n },\n })\n })\n const unsubReset = state.onReset(() => {\n refreshState()\n api.addTimelineEvent({\n layerId: TIMELINE_LAYER_ID,\n event: {\n time: Date.now(),\n title: 'reset',\n subtitle: state.formKey,\n },\n })\n })\n subscriberUnsubs.set(state.formKey, () => {\n unsubChange()\n unsubSubmit()\n unsubReset()\n })\n }\n\n // Subscribe all currently-registered forms + register as they're\n // added. The registry's `forms` Map is shallowReactive — we poll\n // once per render on refresh; for live change detection, each\n // useForm call that adds a new form triggers a tree/state refresh\n // via the form's own onFormChange emission on the first\n // applyFormReplacement.\n function syncForms(): void {\n for (const [, state] of registry.forms) {\n subscribeForm(state)\n }\n // Drop subscribers for forms that were evicted.\n for (const [formKey, unsub] of subscriberUnsubs) {\n if (!registry.forms.has(formKey)) {\n unsub()\n subscriberUnsubs.delete(formKey)\n }\n }\n }\n\n api.on.getInspectorTree((payload) => {\n if (payload.inspectorId !== INSPECTOR_ID) return\n syncForms()\n payload.rootNodes = [...registry.forms.keys()].map((key) => ({\n id: `form:${key}`,\n label: key,\n tags: [],\n }))\n })\n\n api.on.getInspectorState((payload) => {\n if (payload.inspectorId !== INSPECTOR_ID) return\n if (!payload.nodeId.startsWith('form:')) return\n const formKey = payload.nodeId.slice('form:'.length)\n const state = registry.forms.get(formKey)\n if (state === undefined) return\n // Devtools is dev-only — render raw values for everything,\n // including sensitive-named paths. Consumers concerned about\n // screen-share leaks should close the panel before sharing.\n payload.state['Form value'] = [\n {\n key: 'form',\n value: state.form.value,\n editable: true,\n },\n ]\n // Schema-driven and user-injected errors land in separate inspector\n // sections so devs can see the source distinction at a glance — a\n // user-injected entry surviving a successful submit, or a schema\n // entry that should have cleared after a value fix, are immediately\n // visible without cross-referencing call sites.\n payload.state['Schema Errors'] = [\n ...[...state.schemaErrors.entries()].map(([k, v]) => ({\n key: String(k),\n value: v as unknown,\n })),\n ]\n payload.state['User Errors'] = [\n ...[...state.userErrors.entries()].map(([k, v]) => ({\n key: String(k),\n value: v as unknown,\n })),\n ]\n payload.state['Aggregates'] = [\n { key: 'submitting', value: state.submitting.value },\n { key: 'submissionAttempts', value: state.submissionAttempts.value },\n { key: 'departAttempts', value: state.departAttempts.value },\n { key: 'submitError', value: state.submitError.value },\n { key: 'activeValidations', value: state.activeValidations.value },\n ]\n })\n\n api.on.editInspectorState((payload) => {\n if (payload.inspectorId !== INSPECTOR_ID) return\n if (!payload.nodeId.startsWith('form:')) return\n const formKey = payload.nodeId.slice('form:'.length)\n const state = registry.forms.get(formKey)\n if (state === undefined) return\n // payload.path is `['Form value', 'form', ...pathSegments]` — the\n // first two segments are the inspector section + key, the rest is\n // the target form path the user edited. Pass the segment array\n // directly to `canonicalizePath`: join('.') would collapse a\n // literal-dot field key (`{\"user.email\": ...}`) into two segments,\n // writing to the wrong leaf.\n if (payload.path.length < 3) return\n const section = payload.path[0]\n if (section !== 'Form value') return\n const segments = payload.path.slice(2)\n const { segments: canonicalPath, key: canonicalKey } = canonicalizePath(segments)\n // A devtools edit on a path that any element has opted in to should\n // persist (matches the user's expectation: editing via the inspector\n // should be indistinguishable from typing into the bound input).\n // No opt-in for this path → no write.\n state.setValueAtPath(canonicalPath, payload.state.value, {\n persist: state.persistOptIns.hasAnyOptInForPath(canonicalKey),\n })\n refreshState()\n })\n\n // Initial sync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 {"version":3,"file":"devtools.mjs","sources":["../../src/runtime/core/devtools.ts"],"sourcesContent":["import type { App } from 'vue'\nimport type { FormStore } from './create-form-store'\nimport type { AttaformRegistry } from './registry'\nimport type { GenericForm } from '../types/types-core'\nimport type { FormKey } from '../types/types-api'\nimport { canonicalizePath } from './paths'\n\n/**\n * Vue DevTools plugin wiring for attaform. Lazy-imported by\n * `createAttaform` under dev-mode guards so the production\n * bundle tree-shakes it out entirely.\n *\n * Registers:\n * - An inspector (per-app) that lists every registered form, with\n * nodes for form value / errors / aggregates / history.\n * - A timeline layer that emits events on submit start/success/\n * failure, reset, undo, redo, and form mutations.\n * - State editing — modifying a leaf inside the inspector tree\n * pushes through `state.setValueAtPath`, mutating the form.\n *\n * Tolerant of missing `@vue/devtools-api` — the peer dep is marked\n * optional. If the import fails, `setupAttaformDevtools` silently\n * no-ops so production builds / users without DevTools installed\n * don't see errors.\n */\n\nconst INSPECTOR_ID = 'attaform'\nconst TIMELINE_LAYER_ID = 'attaform:events'\n\ntype UnsafeDevtoolsApi = {\n addInspector(opts: { id: string; label: string; icon?: string; app: App }): void\n addTimelineLayer(opts: { id: string; label: string; color: number }): void\n sendInspectorTree(inspectorId: string): void\n sendInspectorState(inspectorId: string): void\n addTimelineEvent(payload: {\n layerId: string\n event: {\n time: number\n title: string\n subtitle?: string\n data?: Record<string, unknown>\n groupId?: string | number\n }\n }): void\n on: {\n getInspectorTree(\n handler: (payload: {\n inspectorId: string\n filter: string\n rootNodes: Array<{ id: string; label: string; tags?: unknown[] }>\n }) => void\n ): void\n getInspectorState(\n handler: (payload: {\n inspectorId: string\n nodeId: string\n state: Record<string, Array<{ key: string; value: unknown; editable?: boolean }>>\n }) => void\n ): void\n editInspectorState(\n handler: (payload: {\n inspectorId: string\n nodeId: string\n path: string[]\n state: { value: unknown; newKey?: string | null; remove?: boolean }\n }) => void\n ): void\n }\n}\n\ntype SetupDevtoolsPluginFn = (\n descriptor: {\n id: string\n label: string\n packageName?: string\n homepage?: string\n componentStateTypes?: string[]\n app: App\n },\n setup: (api: UnsafeDevtoolsApi) => void\n) => void\n\n/**\n * Install the DevTools plugin for the given Vue app + registry. Safe\n * to call in production — if `@vue/devtools-api` isn't installed, the\n * dynamic import fails and we log nothing. Returns `true` when\n * DevTools was wired successfully, `false` otherwise — useful for\n * tests.\n */\nexport async function setupAttaformDevtools(\n app: App,\n registry: AttaformRegistry\n): Promise<boolean> {\n let mod: { setupDevtoolsPlugin?: SetupDevtoolsPluginFn }\n try {\n mod = (await import('@vue/devtools-api')) as {\n setupDevtoolsPlugin?: SetupDevtoolsPluginFn\n }\n } catch {\n // Peer dep not installed — silently skip. Production builds pass\n // `{ devtools: false }` explicitly, but this catch covers the\n // \"dev without the peer dep\" case without a noisy warning.\n return false\n }\n const setupDevtoolsPlugin = mod.setupDevtoolsPlugin\n if (typeof setupDevtoolsPlugin !== 'function') return false\n\n setupDevtoolsPlugin(\n {\n id: INSPECTOR_ID,\n label: 'Attaform',\n packageName: 'attaform',\n homepage: 'https://github.com/attaform/Attaform',\n app,\n componentStateTypes: ['Attaform form'],\n },\n (api) => wire(api, app, registry)\n )\n return true\n}\n\nfunction wire(api: UnsafeDevtoolsApi, app: App, registry: AttaformRegistry): void {\n // Per-form subscriber bookkeeping — we keep the unsubscribers so\n // the registry's eviction path can detach them when a form is\n // disposed. Using a Map keyed by FormKey mirrors the registry.\n const subscriberUnsubs = new Map<FormKey, () => void>()\n\n api.addInspector({ id: INSPECTOR_ID, label: 'Attaform', app })\n api.addTimelineLayer({ id: TIMELINE_LAYER_ID, label: 'Attaform', color: 0x5b8def })\n\n function refreshTree(): void {\n api.sendInspectorTree(INSPECTOR_ID)\n }\n\n function refreshState(): void {\n api.sendInspectorState(INSPECTOR_ID)\n }\n\n function subscribeForm(state: FormStore<GenericForm>): void {\n if (subscriberUnsubs.has(state.formKey)) return\n const unsubChange = state.onFormChange(() => {\n refreshState()\n api.addTimelineEvent({\n layerId: TIMELINE_LAYER_ID,\n event: {\n time: Date.now(),\n title: 'form.change',\n subtitle: state.formKey,\n // Devtools is dev-only — emit raw values. Consumers worried\n // about screen-share leaks should close the panel before\n // sharing, same as they would for the browser DevTools\n // console.\n data: { form: state.form.value as Record<string, unknown> },\n },\n })\n })\n const unsubSubmit = state.onSubmitSuccess(() => {\n api.addTimelineEvent({\n layerId: TIMELINE_LAYER_ID,\n event: {\n time: Date.now(),\n title: 'submit.success',\n subtitle: state.formKey,\n data: { form: state.form.value as Record<string, unknown> },\n },\n })\n })\n const unsubReset = state.onReset(() => {\n refreshState()\n api.addTimelineEvent({\n layerId: TIMELINE_LAYER_ID,\n event: {\n time: Date.now(),\n title: 'reset',\n subtitle: state.formKey,\n },\n })\n })\n subscriberUnsubs.set(state.formKey, () => {\n unsubChange()\n unsubSubmit()\n unsubReset()\n })\n }\n\n // Subscribe all currently-registered forms + register as they're\n // added. The registry's `forms` Map is shallowReactive — we poll\n // once per render on refresh; for live change detection, each\n // useForm call that adds a new form triggers a tree/state refresh\n // via the form's own onFormChange emission on the first\n // applyFormReplacement.\n function syncForms(): void {\n for (const [, state] of registry.forms) {\n subscribeForm(state)\n }\n // Drop subscribers for forms that were evicted.\n for (const [formKey, unsub] of subscriberUnsubs) {\n if (!registry.forms.has(formKey)) {\n unsub()\n subscriberUnsubs.delete(formKey)\n }\n }\n }\n\n api.on.getInspectorTree((payload) => {\n if (payload.inspectorId !== INSPECTOR_ID) return\n syncForms()\n payload.rootNodes = [...registry.forms.keys()].map((key) => ({\n id: `form:${key}`,\n label: key,\n tags: [],\n }))\n })\n\n api.on.getInspectorState((payload) => {\n if (payload.inspectorId !== INSPECTOR_ID) return\n if (!payload.nodeId.startsWith('form:')) return\n const formKey = payload.nodeId.slice('form:'.length)\n const state = registry.forms.get(formKey)\n if (state === undefined) return\n // Devtools is dev-only — render raw values for everything,\n // including sensitive-named paths. Consumers concerned about\n // screen-share leaks should close the panel before sharing.\n payload.state['Form value'] = [\n {\n key: 'form',\n value: state.form.value,\n editable: true,\n },\n ]\n // Schema-driven and user-injected errors land in separate inspector\n // sections so devs can see the source distinction at a glance — a\n // user-injected entry surviving a successful submit, or a schema\n // entry that should have cleared after a value fix, are immediately\n // visible without cross-referencing call sites.\n payload.state['Schema Errors'] = [\n ...[...state.schemaErrors.entries()].map(([k, v]) => ({\n key: String(k),\n value: v as unknown,\n })),\n ]\n payload.state['User Errors'] = [\n ...[...state.userErrors.entries()].map(([k, v]) => ({\n key: String(k),\n value: v as unknown,\n })),\n ]\n payload.state['Aggregates'] = [\n { key: 'submitting', value: state.submitting.value },\n { key: 'submissionAttempts', value: state.submissionAttempts.value },\n { key: 'departAttempts', value: state.departAttempts.value },\n { key: 'submitError', value: state.submitError.value },\n { key: 'activeValidations', value: state.activeValidations.value },\n ]\n })\n\n api.on.editInspectorState((payload) => {\n if (payload.inspectorId !== INSPECTOR_ID) return\n if (!payload.nodeId.startsWith('form:')) return\n const formKey = payload.nodeId.slice('form:'.length)\n const state = registry.forms.get(formKey)\n if (state === undefined) return\n // payload.path is `['Form value', 'form', ...pathSegments]` — the\n // first two segments are the inspector section + key, the rest is\n // the target form path the user edited. Pass the segment array\n // directly to `canonicalizePath`: join('.') would collapse a\n // literal-dot field key (`{\"user.email\": ...}`) into two segments,\n // writing to the wrong leaf.\n if (payload.path.length < 3) return\n const section = payload.path[0]\n if (section !== 'Form value') return\n const segments = payload.path.slice(2)\n const { segments: canonicalPath } = canonicalizePath(segments)\n state.setValueAtPath(canonicalPath, payload.state.value)\n refreshState()\n })\n\n // Initial sync so existing forms show up.\n syncForms()\n refreshTree()\n}\n"],"names":[],"mappings":";;AA0BA,MAAM,YAAA,GAAe,UAAA;AACrB,MAAM,iBAAA,GAAoB,iBAAA;AA8D1B,eAAsB,qBAAA,CACpB,KACA,QAAA,EACkB;AAClB,EAAA,IAAI,GAAA;AACJ,EAAA,IAAI;AACF,IAAA,GAAA,GAAO,MAAM,OAAO,mBAAmB,CAAA;AAAA,EAGzC,CAAA,CAAA,MAAQ;AAIN,IAAA,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gBAAgB,YAAA,EAAc;AAC1C,IAAA,IAAI,CAAC,OAAA,CAAQ,MAAA,CAAO,UAAA,CAAW,OAAO,CAAA,EAAG;AACzC,IAAA,MAAM,OAAA,GAAU,OAAA,CAAQ,MAAA,CAAO,KAAA,CAAM,QAAQ,MAAM,CAAA;AACnD,IAAA,MAAM,KAAA,GAAQ,QAAA,CAAS,KAAA,CAAM,GAAA,CAAI,OAAO,CAAA;AACxC,IAAA,IAAI,UAAU,MAAA,EAAW;AAOzB,IAAA,IAAI,OAAA,CAAQ,IAAA,CAAK,MAAA,GAAS,CAAA,EAAG;AAC7B,IAAA,MAAM,OAAA,GAAU,OAAA,CAAQ,IAAA,CAAK,CAAC,CAAA;AAC9B,IAAA,IAAI,YAAY,YAAA,EAAc;AAC9B,IAAA,MAAM,QAAA,GAAW,OAAA,CAAQ,IAAA,CAAK,KAAA,CAAM,CAAC,CAAA;AACrC,IAAA,MAAM,EAAE,QAAA,EAAU,aAAA,EAAc,GAAI,iBAAiB,QAAQ,CAAA;AAC7D,IAAA,KAAA,CAAM,cAAA,CAAe,aAAA,EAAe,OAAA,CAAQ,KAAA,CAAM,KAAK,CAAA;AACvD,IAAA,YAAA,EAAa;AAAA,EACf,CAAC,CAAA;AAGD,EAAA,SAAA,EAAU;AACV,EAAA,WAAA,EAAY;AACd;;;;"}
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  const canonicalStringify = require('../shared/attaform.CQN9R62B.cjs');
4
- const index = require('../shared/attaform.AyujQoHp.cjs');
4
+ const index = require('../shared/attaform.BnUXV01g.cjs');
5
5
 
6
6
  const cyclicSentinel = "<cyclic>";
7
7
  function fingerprintZodSchema(schema) {
@@ -1,5 +1,5 @@
1
1
  import { c as canonicalStringify } from '../shared/attaform.BJGA_UOS.mjs';
2
- import { k as kindOf, g as getIntersectionLeft, b as getIntersectionRight, c as unwrapLazy, d as unwrapInner, e as unwrapPipe, h as getDiscriminator, i as getDiscriminatedOptions, j as getUnionOptions, l as getRecordKeyType, m as getRecordValueType, n as getTupleItems, o as getSetValueType, p as getArrayElement, q as getObjectShape, r as getEnumValues, s as getLiteralValues, t as getChecks, v as getCatchDefault, x as getDefaultValue } from '../shared/attaform.DNuiFCXG.mjs';
2
+ import { k as kindOf, g as getIntersectionLeft, b as getIntersectionRight, c as unwrapLazy, d as unwrapInner, e as unwrapPipe, h as getDiscriminator, i as getDiscriminatedOptions, j as getUnionOptions, l as getRecordKeyType, m as getRecordValueType, n as getTupleItems, o as getSetValueType, p as getArrayElement, q as getObjectShape, r as getEnumValues, s as getLiteralValues, t as getChecks, v as getCatchDefault, x as getDefaultValue } from '../shared/attaform.C-dAB90u.mjs';
3
3
 
4
4
  const cyclicSentinel = "<cyclic>";
5
5
  function fingerprintZodSchema(schema) {
package/dist/index.cjs CHANGED
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
- const paths = require('./shared/attaform.01iKS_lz.cjs');
4
- const devtoolsShared = require('./shared/attaform.CRzpFCjV.cjs');
5
- const injectWizard = require('./shared/attaform.CjMcwV7W.cjs');
3
+ const paths = require('./shared/attaform.DwkU0oY9.cjs');
4
+ const devtoolsShared = require('./shared/attaform.nycEksJn.cjs');
5
+ const injectWizard = require('./shared/attaform.C42wL7EJ.cjs');
6
6
 
7
7
  function escapeForInlineScript(json) {
8
8
  return json.replace(/[<>&\u2028\u2029]/g, (char) => {
@@ -23,153 +23,7 @@ function escapeForInlineScript(json) {
23
23
  });
24
24
  }
25
25
 
26
- const PARSE_API_ERRORS_DEFAULTS = {
27
- maxEntries: 1e3,
28
- maxPathDepth: 32,
29
- maxTotalSegments: 1e4,
30
- defaultCode: "api:unknown"
31
- };
32
- function parseApiErrors(payload, options) {
33
- const { maxEntries, maxPathDepth, maxTotalSegments, defaultCode } = normalizeParseCaps(options);
34
- if (payload === null || payload === void 0) {
35
- return { ok: true, errors: [] };
36
- }
37
- if (typeof payload !== "object") {
38
- return { ok: false, errors: [], rejected: `payload was ${typeof payload}, expected object` };
39
- }
40
- const extraction = extractDetails(payload);
41
- if (!extraction.ok) {
42
- return { ok: false, errors: [], rejected: extraction.reason };
43
- }
44
- const { details } = extraction;
45
- const entryCount = Object.keys(details).length;
46
- if (entryCount > maxEntries) {
47
- return {
48
- ok: false,
49
- errors: [],
50
- rejected: `payload has ${entryCount} entries, exceeds maxEntries=${maxEntries}`
51
- };
52
- }
53
- return convertDetailsToErrors(
54
- details,
55
- options.formKey,
56
- maxPathDepth,
57
- maxTotalSegments,
58
- defaultCode
59
- );
60
- }
61
- function normalizeParseCaps(options) {
62
- const maxEntries = injectWizard.normalizeNumericOption({
63
- value: options.maxEntries ?? PARSE_API_ERRORS_DEFAULTS.maxEntries,
64
- source: "parseApiErrors.maxEntries",
65
- allowInfinity: false,
66
- min: 0,
67
- defaultValue: PARSE_API_ERRORS_DEFAULTS.maxEntries
68
- });
69
- const maxPathDepth = injectWizard.normalizeNumericOption({
70
- value: options.maxPathDepth ?? PARSE_API_ERRORS_DEFAULTS.maxPathDepth,
71
- source: "parseApiErrors.maxPathDepth",
72
- allowInfinity: false,
73
- min: 0,
74
- defaultValue: PARSE_API_ERRORS_DEFAULTS.maxPathDepth
75
- });
76
- const maxTotalSegments = injectWizard.normalizeNumericOption({
77
- value: options.maxTotalSegments ?? PARSE_API_ERRORS_DEFAULTS.maxTotalSegments,
78
- source: "parseApiErrors.maxTotalSegments",
79
- allowInfinity: false,
80
- min: 0,
81
- defaultValue: PARSE_API_ERRORS_DEFAULTS.maxTotalSegments
82
- });
83
- const defaultCode = options.defaultCode ?? PARSE_API_ERRORS_DEFAULTS.defaultCode;
84
- return { maxEntries, maxPathDepth, maxTotalSegments, defaultCode };
85
- }
86
- function convertDetailsToErrors(details, formKey, maxPathDepth, maxTotalSegments, defaultCode) {
87
- const errors = [];
88
- let totalSegments = 0;
89
- for (const [key, value] of Object.entries(details)) {
90
- const entryList = Array.isArray(value) ? value : [value];
91
- let segments;
92
- try {
93
- segments = paths.canonicalizePath(key).segments;
94
- } catch (err) {
95
- if (err instanceof paths.InvalidPathError) continue;
96
- throw err;
97
- }
98
- if (segments.length > maxPathDepth) continue;
99
- totalSegments += segments.length;
100
- if (totalSegments > maxTotalSegments) {
101
- return {
102
- ok: false,
103
- errors: [],
104
- rejected: `payload total path segments exceeds maxTotalSegments=${maxTotalSegments}`
105
- };
106
- }
107
- for (const entry of entryList) {
108
- const message = typeof entry === "string" ? entry : entry.message;
109
- const code = typeof entry === "string" ? defaultCode : entry.code;
110
- if (message.length === 0) continue;
111
- errors.push({
112
- message,
113
- path: Array.from(segments),
114
- formKey,
115
- code
116
- });
117
- }
118
- }
119
- return { ok: true, errors };
120
- }
121
- function extractDetails(payload) {
122
- const wrappedError = payload["error"];
123
- if (wrappedError !== null && wrappedError !== void 0 && typeof wrappedError === "object") {
124
- const inner = wrappedError.details;
125
- if (inner === void 0) {
126
- return { ok: true, details: {} };
127
- }
128
- if (isDetailsRecord(inner)) return { ok: true, details: inner };
129
- return {
130
- ok: false,
131
- reason: "error.details entries must be strings or { message, code } objects"
132
- };
133
- }
134
- if (wrappedError !== null && wrappedError !== void 0 && typeof wrappedError !== "object") {
135
- return {
136
- ok: false,
137
- reason: `payload.error was ${typeof wrappedError}, expected an object with { details }`
138
- };
139
- }
140
- if ("details" in payload) {
141
- const inner = payload["details"];
142
- if (inner === void 0) return { ok: true, details: {} };
143
- if (isDetailsRecord(inner)) return { ok: true, details: inner };
144
- return { ok: false, reason: "details entries must be strings or { message, code } objects" };
145
- }
146
- if (isDetailsRecord(payload)) return { ok: true, details: payload };
147
- if (Object.keys(payload).length === 0) return { ok: true, details: {} };
148
- return { ok: false, reason: "unrecognised payload shape" };
149
- }
150
- function isStructuredEntry(value) {
151
- if (value === null || typeof value !== "object" || Array.isArray(value)) return false;
152
- const obj = value;
153
- return typeof obj.message === "string" && typeof obj.code === "string";
154
- }
155
- function isAcceptedEntry(value) {
156
- return typeof value === "string" || isStructuredEntry(value);
157
- }
158
- function isDetailsRecord(value) {
159
- if (value === null || typeof value !== "object" || Array.isArray(value)) return false;
160
- const record = value;
161
- for (const k of Object.keys(record)) {
162
- const v = record[k];
163
- if (isAcceptedEntry(v)) continue;
164
- if (Array.isArray(v) && v.every((entry) => isAcceptedEntry(entry))) continue;
165
- return false;
166
- }
167
- return true;
168
- }
169
-
170
- exports.AnonPersistError = paths.AnonPersistError;
171
26
  exports.AttaformError = paths.AttaformError;
172
- exports.DEFAULT_SENSITIVE_NAMES = paths.DEFAULT_SENSITIVE_NAMES;
173
27
  exports.InvalidPathError = paths.InvalidPathError;
174
28
  exports.InvalidUseFormConfigError = paths.InvalidUseFormConfigError;
175
29
  exports.OutsideSetupError = paths.OutsideSetupError;
@@ -206,7 +60,5 @@ exports.unset = injectWizard.unset;
206
60
  exports.useForm = injectWizard.useAbstractForm;
207
61
  exports.useRegister = injectWizard.useRegister;
208
62
  exports.useWizard = injectWizard.useWizard;
209
- exports.PARSE_API_ERRORS_DEFAULTS = PARSE_API_ERRORS_DEFAULTS;
210
63
  exports.escapeForInlineScript = escapeForInlineScript;
211
- exports.parseApiErrors = parseApiErrors;
212
64
  //# sourceMappingURL=index.cjs.map