attaform 0.27.6 → 0.28.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 (184) hide show
  1. package/dist/abstract.d.mts +5 -4
  2. package/dist/abstract.mjs +4 -3
  3. package/dist/chunks/fingerprint.mjs +0 -1
  4. package/dist/chunks/fingerprint2.mjs +1 -2
  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/{shared/attaform.D6tk90Rc.cjs → dev/shared/attaform-dev.6qxD-Yqo.mjs} +187 -43
  15. package/dist/{shared/attaform.CQN9R62B.cjs → dev/shared/attaform-dev.BJGA_UOS.mjs} +1 -4
  16. package/dist/{shared/attaform.DYEr28Pt.mjs → dev/shared/attaform-dev.BR8u0YOZ.mjs} +6 -7
  17. package/dist/dev/shared/attaform-dev.BXE2cr0L.mjs +220 -0
  18. package/dist/dev/shared/attaform-dev.By4PRjt0.mjs +248 -0
  19. package/dist/{shared/attaform.B1ZYt2Li.mjs → dev/shared/attaform-dev.D2I8e_Mm.mjs} +132 -568
  20. package/dist/dev/shared/attaform-dev.Dr2YzS5B.mjs +197 -0
  21. package/dist/{shared/attaform.nMaz2C5P.mjs → dev/shared/attaform-dev.P7cseiEG.mjs} +178 -397
  22. package/dist/{shared/attaform.CKH2lGdL.mjs → dev/shared/attaform-dev.WmuhD_CZ.mjs} +3944 -5056
  23. package/dist/{shared/attaform.DMxM2kol.mjs → dev/shared/attaform-dev.oYrkP9dj.mjs} +160 -508
  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 +11 -5
  33. package/dist/index.mjs +5 -4
  34. package/dist/nuxt.d.mts +1 -1
  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.Fp3sCrVs.d.ts → attaform.B4VkS43-.d.mts} +2 -2
  42. package/dist/shared/{attaform.DrvMscNX.cjs → attaform.B8k8JrmK.mjs} +4073 -5630
  43. package/dist/shared/attaform.BJGA_UOS.mjs +0 -1
  44. package/dist/shared/{attaform.CoR4mWfv.mjs → attaform.C09fpdLS.mjs} +172 -16
  45. package/dist/shared/{attaform.D8kliaKw.cjs → attaform.CJP3RkGa.mjs} +141 -590
  46. package/dist/shared/{attaform.DniawQLP.d.cts → attaform.Cgu-hdSb.d.mts} +268 -68
  47. package/dist/shared/attaform.Cs2Rbdlo.mjs +0 -1
  48. package/dist/shared/{attaform.CHlJLAiv.d.mts → attaform.D5V4tZWq.d.mts} +69 -179
  49. package/dist/shared/{attaform.B9Wyhfro.cjs → attaform.D6DCnnQu.mjs} +11 -16
  50. package/dist/shared/attaform.DhnPb6nK.mjs +0 -1
  51. package/dist/shared/attaform.Dq4vWxuG.mjs +197 -0
  52. package/dist/shared/attaform.JfSWdEcb.d.mts +44 -0
  53. package/dist/shared/attaform.KvlEedlF.mjs +0 -1
  54. package/dist/shared/{attaform.DdQN7sgN.cjs → attaform.NLmerepI.mjs} +175 -557
  55. package/dist/shared/attaform.h0i6LijT.mjs +242 -0
  56. package/dist/shared/{attaform.Biytrv0-.cjs → attaform.uLbun31C.mjs} +204 -544
  57. package/dist/shared/attaform.v0fQtWyA.mjs +0 -1
  58. package/dist/shared/attaform.wfY8XFvm.mjs +197 -0
  59. package/dist/transforms.mjs +0 -1
  60. package/dist/vite.d.mts +17 -5
  61. package/dist/vite.mjs +24 -2
  62. package/dist/webpack.d.mts +6 -1
  63. package/dist/webpack.mjs +0 -1
  64. package/dist/zod-v3.d.mts +11 -6
  65. package/dist/zod-v3.mjs +17 -4
  66. package/dist/zod-v4.d.mts +12 -6
  67. package/dist/zod-v4.mjs +16 -4
  68. package/dist/zod.d.mts +4 -3
  69. package/dist/zod.mjs +5 -4
  70. package/package.json +23 -8
  71. package/skills/attaform/SKILL.md +2 -1
  72. package/dist/abstract.cjs +0 -48
  73. package/dist/abstract.cjs.map +0 -1
  74. package/dist/abstract.d.cts +0 -42
  75. package/dist/abstract.d.ts +0 -42
  76. package/dist/abstract.mjs.map +0 -1
  77. package/dist/chunks/dev-key-collision-warnings.cjs +0 -25
  78. package/dist/chunks/dev-key-collision-warnings.cjs.map +0 -1
  79. package/dist/chunks/dev-key-collision-warnings.mjs.map +0 -1
  80. package/dist/chunks/devtools.cjs +0 -157
  81. package/dist/chunks/devtools.cjs.map +0 -1
  82. package/dist/chunks/devtools.mjs.map +0 -1
  83. package/dist/chunks/fingerprint.cjs.map +0 -1
  84. package/dist/chunks/fingerprint.mjs.map +0 -1
  85. package/dist/chunks/fingerprint2.cjs.map +0 -1
  86. package/dist/chunks/fingerprint2.mjs.map +0 -1
  87. package/dist/esbuild.cjs +0 -28
  88. package/dist/esbuild.cjs.map +0 -1
  89. package/dist/esbuild.d.cts +0 -56
  90. package/dist/esbuild.d.ts +0 -56
  91. package/dist/esbuild.mjs.map +0 -1
  92. package/dist/index.cjs +0 -51
  93. package/dist/index.cjs.map +0 -1
  94. package/dist/index.d.cts +0 -249
  95. package/dist/index.d.ts +0 -249
  96. package/dist/index.mjs.map +0 -1
  97. package/dist/nuxt.cjs +0 -84
  98. package/dist/nuxt.cjs.map +0 -1
  99. package/dist/nuxt.d.cts +0 -66
  100. package/dist/nuxt.d.ts +0 -66
  101. package/dist/nuxt.mjs.map +0 -1
  102. package/dist/rollup.cjs +0 -24
  103. package/dist/rollup.cjs.map +0 -1
  104. package/dist/rollup.d.cts +0 -35
  105. package/dist/rollup.d.ts +0 -35
  106. package/dist/rollup.mjs.map +0 -1
  107. package/dist/rspack.cjs +0 -10
  108. package/dist/rspack.cjs.map +0 -1
  109. package/dist/rspack.d.cts +0 -40
  110. package/dist/rspack.d.ts +0 -40
  111. package/dist/rspack.mjs.map +0 -1
  112. package/dist/runtime/components/AttaformDevtoolsPanel.vue.d.ts +0 -7
  113. package/dist/runtime/components/DevtoolsValueTree.vue.d.ts +0 -35
  114. package/dist/runtime/plugins/attaform.cjs +0 -43
  115. package/dist/runtime/plugins/attaform.cjs.map +0 -1
  116. package/dist/runtime/plugins/attaform.d.cts +0 -5
  117. package/dist/runtime/plugins/attaform.d.ts +0 -5
  118. package/dist/runtime/plugins/attaform.mjs.map +0 -1
  119. package/dist/shared/attaform.B1ZYt2Li.mjs.map +0 -1
  120. package/dist/shared/attaform.B9Wyhfro.cjs.map +0 -1
  121. package/dist/shared/attaform.BGDV42hI.d.cts +0 -232
  122. package/dist/shared/attaform.BJGA_UOS.mjs.map +0 -1
  123. package/dist/shared/attaform.Biytrv0-.cjs.map +0 -1
  124. package/dist/shared/attaform.Bn0IzhD_.cjs +0 -800
  125. package/dist/shared/attaform.Bn0IzhD_.cjs.map +0 -1
  126. package/dist/shared/attaform.C9fPTxjB.d.cts +0 -41
  127. package/dist/shared/attaform.C9fPTxjB.d.ts +0 -41
  128. package/dist/shared/attaform.CKH2lGdL.mjs.map +0 -1
  129. package/dist/shared/attaform.CQN9R62B.cjs.map +0 -1
  130. package/dist/shared/attaform.CoR4mWfv.mjs.map +0 -1
  131. package/dist/shared/attaform.Cs2Rbdlo.mjs.map +0 -1
  132. package/dist/shared/attaform.D6tk90Rc.cjs.map +0 -1
  133. package/dist/shared/attaform.D8kliaKw.cjs.map +0 -1
  134. package/dist/shared/attaform.DLknk9nF.d.mts +0 -232
  135. package/dist/shared/attaform.DMxM2kol.mjs.map +0 -1
  136. package/dist/shared/attaform.DRUT703x.d.cts +0 -56
  137. package/dist/shared/attaform.DRUT703x.d.ts +0 -56
  138. package/dist/shared/attaform.DYEr28Pt.mjs.map +0 -1
  139. package/dist/shared/attaform.DdQN7sgN.cjs.map +0 -1
  140. package/dist/shared/attaform.DhnPb6nK.mjs.map +0 -1
  141. package/dist/shared/attaform.DniawQLP.d.mts +0 -4763
  142. package/dist/shared/attaform.DniawQLP.d.ts +0 -4763
  143. package/dist/shared/attaform.DoQm_Vkd.cjs +0 -58
  144. package/dist/shared/attaform.DoQm_Vkd.cjs.map +0 -1
  145. package/dist/shared/attaform.DrvMscNX.cjs.map +0 -1
  146. package/dist/shared/attaform.F2Q8iv38.d.ts +0 -2494
  147. package/dist/shared/attaform.FmqKO1Ex.d.cts +0 -2494
  148. package/dist/shared/attaform.KvlEedlF.mjs.map +0 -1
  149. package/dist/shared/attaform.RaTzp1WF.cjs +0 -26
  150. package/dist/shared/attaform.RaTzp1WF.cjs.map +0 -1
  151. package/dist/shared/attaform.nMaz2C5P.mjs.map +0 -1
  152. package/dist/shared/attaform.v0fQtWyA.mjs.map +0 -1
  153. package/dist/shared/attaform.yUrz7C2z.cjs +0 -29
  154. package/dist/shared/attaform.yUrz7C2z.cjs.map +0 -1
  155. package/dist/transforms.cjs +0 -12
  156. package/dist/transforms.cjs.map +0 -1
  157. package/dist/transforms.d.cts +0 -73
  158. package/dist/transforms.d.ts +0 -73
  159. package/dist/transforms.mjs.map +0 -1
  160. package/dist/vite.cjs +0 -363
  161. package/dist/vite.cjs.map +0 -1
  162. package/dist/vite.d.cts +0 -133
  163. package/dist/vite.d.ts +0 -133
  164. package/dist/vite.mjs.map +0 -1
  165. package/dist/webpack.cjs +0 -10
  166. package/dist/webpack.cjs.map +0 -1
  167. package/dist/webpack.d.cts +0 -37
  168. package/dist/webpack.d.ts +0 -37
  169. package/dist/webpack.mjs.map +0 -1
  170. package/dist/zod-v3.cjs +0 -53
  171. package/dist/zod-v3.cjs.map +0 -1
  172. package/dist/zod-v3.d.cts +0 -246
  173. package/dist/zod-v3.d.ts +0 -246
  174. package/dist/zod-v3.mjs.map +0 -1
  175. package/dist/zod-v4.cjs +0 -55
  176. package/dist/zod-v4.cjs.map +0 -1
  177. package/dist/zod-v4.d.cts +0 -172
  178. package/dist/zod-v4.d.ts +0 -172
  179. package/dist/zod-v4.mjs.map +0 -1
  180. package/dist/zod.cjs +0 -51
  181. package/dist/zod.cjs.map +0 -1
  182. package/dist/zod.d.cts +0 -7
  183. package/dist/zod.d.ts +0 -7
  184. package/dist/zod.mjs.map +0 -1
package/dist/index.d.ts DELETED
@@ -1,249 +0,0 @@
1
- export { a as AnyForm, b as AttaformDevtoolsBridge, c as AttaformError, d as AttaformErrorCode, e as AttaformPluginOptions, A as AttaformRegistry, C as CompiledStep, D as DEFAULT_TIMINGS, f as DEVTOOLS_WINDOW_KEY, g as DisplayTimings, F as FormStatus, h as FormStatusSeed, G as GateMarker, I as InjectWizardInput, i as InvalidPathError, j as InvalidUseFormConfigError, L as LazyMarker, O as OutsideSetupError, R as RegistryNotInstalledError, k as ReservedFormKeyError, S as SerializedAttaformState, l as SerializedFormData, m as StepSlot, n as SubmitErrorHandlerError, U as UseRegisterReturn, o as UseWizardReturnType, W as WizardAggregateError, p as WizardCtx, q as WizardCtxForm, r as WizardOnError, s as WizardOnSubmit, t as WizardOptions, u as WizardPersistFn, v as WizardRestoreFn, w as WizardRestoreState, x as WizardStatusesProxy, y as WizardSubmitContext, z as assignKey, B as createAttaform, E as createRegistry, H as defaultCoercionRules, J as defaultDisplayState, K as defineCoercion, M as escapeForInlineScript, N as gate, P as getRegistryFromApp, Q as hydrateAttaformState, T as injectForm, V as injectWizard, X as isRegisterValue, Y as kAttaformRegistry, Z as lazy, _ as makeDefaultDisplayState, $ as renderAttaformState, a0 as useRegister, a1 as useRegistry, a2 as useWizard, a3 as vRegister } from './shared/attaform.F2Q8iv38.js';
2
- import { G as GenericForm, F as FormKey, U as UseFormConfiguration, A as AbstractSchema, aq as AcceptableDefaults, ae as ValidateOnConfig, a as UseFormReturnType, D as DefaultValuesInput, o as FieldMetaPayload } from './shared/attaform.DniawQLP.js';
3
- export { b as ArrayItem, c as ArrayPath, d as AttaformDefaults, C as CoercionEntry, e as CoercionRegistry, f as CoercionResult, g as CustomDirectiveRegisterAssignerFn, h as DeepPartial, i as DefaultValuesResponse, j as DefaultValuesShape, k as DisplayCtx, l as DisplayMachine, m as DisplayState, E as ErrorInput, n as ErrorsProxyShape, p as FieldState, q as FieldStateMap, r as FieldStateMapEntry, s as FlatPath, t as FormErrorRecord, u as FormErrorsSurface, v as FormMeta, w as GetDisplayState, H as HandleSubmit, x as HistoryConfig, I as IsTuple, y as IsUnion, J as JoinSegments, z as Json, K as KeyofUnion, L as LiftedValueShape, M as MetaTrackerValue, N as NestedReadType, B as NestedType, O as OnError, P as OnInvalidSubmitPolicy, Q as OnSubmit, R as PartialFlatPath, S as Path, T as PathKey, V as PendingValidationStatus, W as Primitive, X as ROOT_PATH, Y as ROOT_PATH_KEY, Z as ReactiveValidationStatus, _ as RegisterDirective, $ as RegisterFlatPath, a0 as RegisterOptions, a1 as RegisterSelectModifier, a2 as RegisterTextModifier, a3 as RegisterTransform, a4 as RegisterValue, a5 as Segment, a6 as SetValueCallback, a7 as SetValuePayload, a8 as SettledValidationStatus, a9 as SlimPrimitiveKind, aa as SlimRuntimeOf, ab as SubmitHandler, ac as Unset, ad as ValidateOn, af as ValidationError, ag as ValidationResponse, ah as ValidationResponseWithoutValue, ai as ValueOfUnion, aj as WriteMeta, ak as WriteShape, al as canonicalizePath, am as isPathPrefix, an as isUnset, ao as parseDottedPath, ap as unset } from './shared/attaform.DniawQLP.js';
4
- import { S as SupportedRootSchema, b as StorageShape } from './shared/attaform.Fp3sCrVs.js';
5
- export { P as PathInput, a as PathOutput } from './shared/attaform.Fp3sCrVs.js';
6
- import { S as SupportedRootSchema$1, U as UnwrapZodRoot, a as StorageShape$1 } from './shared/attaform.DRUT703x.js';
7
- import { z } from 'zod';
8
- import 'vue';
9
-
10
- /**
11
- * Type-level Zod-major discriminator for the unified `attaform/zod`
12
- * entry. The runtime dispatch (`use-form.ts`'s impl) already routes on
13
- * the schema's shape via `isZodV4SchemaShape`; this is the type-level
14
- * mirror so the overloads and projection helpers discriminate the same
15
- * way.
16
- *
17
- * Why a structural marker instead of `z.ZodObject`: the unified entry's
18
- * overloads constrain on `z.ZodObject`, but the published `.d.mts`
19
- * resolves `z` against whichever single Zod major the consumer
20
- * installed. In a v3-only install `z.ZodObject` is v3's `ZodObject`
21
- * (and, lacking its required type arguments, degrades to an `any`-like
22
- * error type under `skipLibCheck`), so a v3 schema satisfies the v4
23
- * overload's constraint and binds it — collapsing the read slot to
24
- * `never`. A Zod v4 schema carries the `_zod` internals brand; a v3
25
- * schema never does.
26
- * Intersecting a v4-only constraint or conditional branch with this
27
- * marker keeps it unreachable for a v3 schema regardless of how `zod`
28
- * resolves, so v3 schemas fall through to the v3 overload.
29
- *
30
- * Distinct from `core/zod-shape.ts`'s runtime `ZodV4Shape` (which reads
31
- * the public `def` getter): at the type level the stable v4 brand is
32
- * `_zod.def`, the same internals `StorageShape` (v4) already reads.
33
- *
34
- * Pairing requirement: a v4 overload/branch must constrain on
35
- * `z.ZodObject<z.ZodRawShape> & ZodV4Internals`, NOT bare
36
- * `z.ZodObject & ZodV4Internals`. In a v3-only install `z.ZodObject`
37
- * with no type argument is `ZodObject<T, ...>` missing its required
38
- * arguments — an error type that behaves like `any` under
39
- * `skipLibCheck`, so `any & ZodV4Internals` collapses back to `any` and
40
- * the marker stops excluding v3 schemas. Supplying `z.ZodRawShape`
41
- * keeps it a concrete object type in both majors, so the intersection
42
- * stays meaningful.
43
- */
44
- type ZodV4Internals = {
45
- _zod: {
46
- def: unknown;
47
- };
48
- };
49
-
50
- /**
51
- * Per-major projection helpers shared by the unified `attaform/zod`
52
- * entry. Each maps an arbitrary Zod v4 OR v3 object schema to the
53
- * `GenericForm`-shaped input / output / storage-read projections the
54
- * form types are parameterised over. The constraint on each alias scopes
55
- * `S` to one Zod major, so the projection is a direct read with no
56
- * dispatch in the type body.
57
- *
58
- * Hoisted out of `types-unified.ts` and `use-form.ts` so the two entry
59
- * points share one definition. Internal — consumer code never reaches
60
- * for these; the overloaded `useForm` already gives full inference at
61
- * call sites.
62
- */
63
-
64
- /**
65
- * The schema's own input type, exactly as a consumer would reference it
66
- * (`z.input<S>`) — NOT routed through `GenericForm` / `UnwrapZodRoot`. This
67
- * is the reflexive escape arm `AcceptableDefaults` adds to the
68
- * `defaultValues` slot so a generic form wrapper forwarding `z.input<S>`
69
- * type-checks under a free `S` (#422). It must stay syntactically identical
70
- * to what the wrapper forwards: wrapping it in a conditional makes it a
71
- * deferred conditional that no longer matches the forwarded value under a
72
- * generic. Wrong-major schemas can't actually bind the slot — they are
73
- * rejected at the overload's `schema` constraint — so the raw input never
74
- * widens the slot for the wrong major.
75
- */
76
- type V4SchemaInput<S extends SupportedRootSchema> = z.input<S>;
77
- type V3SchemaInput<S extends SupportedRootSchema$1> = z.input<S>;
78
- type V4FormOf<S extends SupportedRootSchema> = z.input<S> extends GenericForm ? z.input<S> : never;
79
- type V4OutOf<S extends SupportedRootSchema> = z.output<S> extends GenericForm ? z.output<S> : never;
80
- type V4ReadOf<S extends SupportedRootSchema> = StorageShape<S> extends GenericForm ? StorageShape<S> : never;
81
- type V3FormOf<S extends SupportedRootSchema$1> = z.input<UnwrapZodRoot<S>> extends GenericForm ? z.input<UnwrapZodRoot<S>> : never;
82
- type V3OutOf<S extends SupportedRootSchema$1> = z.output<UnwrapZodRoot<S>> extends GenericForm ? z.output<UnwrapZodRoot<S>> : never;
83
- type V3ReadOf<S extends SupportedRootSchema$1> = StorageShape$1<UnwrapZodRoot<S>> extends GenericForm ? StorageShape$1<UnwrapZodRoot<S>> : never;
84
-
85
- /**
86
- * Create a form bound to a Zod v4 schema.
87
- *
88
- * ```ts
89
- * import { useForm } from 'attaform/zod'
90
- * import { z } from 'zod'
91
- *
92
- * const form = useForm({
93
- * schema: z.object({
94
- * username: z.string().min(2, 'At least 2 characters'),
95
- * password: z.string().min(8, 'At least 8 characters'),
96
- * }),
97
- * })
98
- * ```
99
- *
100
- * The constraint intersects `ZodV4Internals` (the v4-only `_zod`
101
- * brand) so a v3 schema can't bind this overload even when `z`
102
- * resolves to v3 in a single-major consumer install; v3 schemas fall
103
- * through to the v3 overload below. See `types-zod-major.ts`.
104
- */
105
- declare function useForm<Schema extends SupportedRootSchema & ZodV4Internals, K extends FormKey = FormKey>(configuration: Omit<UseFormConfiguration<V4FormOf<Schema>, V4OutOf<Schema>, AbstractSchema<V4FormOf<Schema>, V4OutOf<Schema>>, never, K>, 'schema' | 'validateOn' | 'debounceMs' | 'defaultValues'> & {
106
- schema: Schema;
107
- defaultValues?: AcceptableDefaults<V4FormOf<Schema>, V4SchemaInput<Schema>>;
108
- } & ValidateOnConfig): UseFormReturnType<V4FormOf<Schema>, V4OutOf<Schema>, V4ReadOf<Schema>, K>;
109
- /**
110
- * Create a form bound to a Zod v3 schema.
111
- *
112
- * ```ts
113
- * import { useForm } from 'attaform/zod'
114
- * import { z } from 'zod-v3'
115
- *
116
- * const form = useForm({
117
- * schema: z.object({
118
- * username: z.string().min(2, 'At least 2 characters'),
119
- * password: z.string().min(8, 'At least 8 characters'),
120
- * }),
121
- * })
122
- * ```
123
- *
124
- * v3 schemas match this overload; v4 schemas hit the v4 overload
125
- * above first and never reach here.
126
- */
127
- declare function useForm<Schema extends SupportedRootSchema$1, K extends FormKey = FormKey>(configuration: Omit<UseFormConfiguration<V3FormOf<Schema>, V3OutOf<Schema>, AbstractSchema<V3FormOf<Schema>, V3OutOf<Schema>>, never, K>, 'schema' | 'validateOn' | 'debounceMs' | 'defaultValues'> & {
128
- schema: Schema;
129
- defaultValues?: AcceptableDefaults<V3FormOf<Schema>, V3SchemaInput<Schema>>;
130
- } & ValidateOnConfig): UseFormReturnType<V3FormOf<Schema>, V3OutOf<Schema>, V3ReadOf<Schema>, K>;
131
-
132
- /**
133
- * Type-level helpers for the unified `attaform/zod` entry. These give
134
- * tests and other type-query call sites a deterministic projection
135
- * over an arbitrary v4 OR v3 schema, sidestepping the brittle
136
- * instantiation-expression resolution rules TypeScript applies to
137
- * overloaded functions (`typeof useForm<X>` can pick the wrong
138
- * overload or the impl signature, depending on whether the type
139
- * argument is a concrete schema, a generic, or a constraint).
140
- *
141
- * The helpers dispatch ONCE per use site via a binary conditional —
142
- * no stacking, no amplification across the return type. Equivalent
143
- * to writing `ReturnType<typeof useForm<S>>` but cache-stable across
144
- * call patterns.
145
- *
146
- * Per `inference-first DX`, these helpers are test- and
147
- * internal-facing. Consumer code shouldn't reach for them — the
148
- * overloaded `useForm` already gives full inference at call sites.
149
- */
150
-
151
- /**
152
- * Direct V4 projection — no major-dispatch. Use when the schema's
153
- * Zod major is known statically (typical for V4 generic helpers like
154
- * `function setup<S extends z.ZodObject>(s: S)`). TS simplifies the
155
- * helper cleanly under generic constraints because no conditional
156
- * is present.
157
- */
158
- type UseFormReturnV4<Schema extends z.ZodObject, K extends FormKey = FormKey> = UseFormReturnType<V4FormOf<Schema>, V4OutOf<Schema>, V4ReadOf<Schema>, K>;
159
- /**
160
- * Direct V4 configuration projection. Mirrors `UseFormReturnV4`.
161
- */
162
- type UseFormConfigV4<Schema extends z.ZodObject, K extends FormKey = FormKey> = Omit<UseFormConfiguration<V4FormOf<Schema>, V4OutOf<Schema>, AbstractSchema<V4FormOf<Schema>, V4OutOf<Schema>>, DefaultValuesInput<V4FormOf<Schema>>, K>, 'schema' | 'validateOn' | 'debounceMs'> & {
163
- schema: Schema;
164
- } & ValidateOnConfig;
165
- /**
166
- * Direct V3 projection — no major-dispatch. Use when the schema's
167
- * Zod major is known statically.
168
- */
169
- type UseFormReturnV3<Schema extends z.ZodObject<z.ZodRawShape>, K extends FormKey = FormKey> = UseFormReturnType<V3FormOf<Schema>, V3OutOf<Schema>, V3ReadOf<Schema>, K>;
170
- /**
171
- * Direct V3 configuration projection. Mirrors `UseFormReturnV3`.
172
- */
173
- type UseFormConfigV3<Schema extends z.ZodObject<z.ZodRawShape>, K extends FormKey = FormKey> = Omit<UseFormConfiguration<V3FormOf<Schema>, V3OutOf<Schema>, AbstractSchema<V3FormOf<Schema>, V3OutOf<Schema>>, DefaultValuesInput<V3FormOf<Schema>>, K>, 'schema' | 'validateOn' | 'debounceMs'> & {
174
- schema: Schema;
175
- } & ValidateOnConfig;
176
- /**
177
- * The return shape of `useForm` for a given Zod schema. Dispatches
178
- * once on the schema's major version and projects to the matching
179
- * adapter's `Form` / `Out` / `Read` slots. The dispatch matches the
180
- * full `SupportedRootSchema` per major, so an object, record, or
181
- * discriminated-union root all resolve here exactly as the runtime
182
- * `useForm` overloads accept them.
183
- *
184
- * Replaces `ReturnType<typeof useForm<Schema, K>>` in test code with
185
- * concrete schemas. For generic helpers (`<S extends z.ZodObject>`),
186
- * use `UseFormReturnV4<S>` directly — TS doesn't simplify
187
- * conditional types under generic constraints, so the dispatch in
188
- * this helper stays deferred and TS can't prove return-type
189
- * compatibility.
190
- */
191
- type UseFormReturn<Schema, K extends FormKey = FormKey> = Schema extends SupportedRootSchema & ZodV4Internals ? UseFormReturnType<V4FormOf<Schema>, V4OutOf<Schema>, V4ReadOf<Schema>, K> : Schema extends SupportedRootSchema$1 ? UseFormReturnType<V3FormOf<Schema>, V3OutOf<Schema>, V3ReadOf<Schema>, K> : never;
192
- /**
193
- * The configuration parameter shape of `useForm` for a given Zod
194
- * schema. Mirrors `UseFormReturn`'s dispatch — replaces
195
- * `Parameters<typeof useForm<Schema, K>>[0]` in test code.
196
- */
197
- type UseFormConfig<Schema, K extends FormKey = FormKey> = Schema extends SupportedRootSchema & ZodV4Internals ? Omit<UseFormConfiguration<V4FormOf<Schema>, V4OutOf<Schema>, AbstractSchema<V4FormOf<Schema>, V4OutOf<Schema>>, DefaultValuesInput<V4FormOf<Schema>>, K>, 'schema' | 'validateOn' | 'debounceMs'> & {
198
- schema: Schema;
199
- } & ValidateOnConfig : Schema extends SupportedRootSchema$1 ? Omit<UseFormConfiguration<V3FormOf<Schema>, V3OutOf<Schema>, AbstractSchema<V3FormOf<Schema>, V3OutOf<Schema>>, DefaultValuesInput<V3FormOf<Schema>>, K>, 'schema' | 'validateOn' | 'debounceMs'> & {
200
- schema: Schema;
201
- } & ValidateOnConfig : never;
202
-
203
- /**
204
- * Field-metadata write/read API for the unified `attaform/zod` entry.
205
- *
206
- * Storage is shared with both adapters via `field-meta-store` — a
207
- * payload written here is visible to whichever adapter the unified
208
- * `useForm` dispatches to at runtime, regardless of Zod major. No
209
- * `zod` runtime import; the type-only `import type` is erased at
210
- * build, so `attaform/zod` carries no `z.registry` reference even
211
- * when consumed by a Zod 3 project without the Vite plugin alias.
212
- *
213
- * The native v4 chain `schema.register(fieldMeta, payload)` continues
214
- * to work — Zod 4's `.register()` only calls `.add(this, payload)`
215
- * structurally, satisfied by the shared store.
216
- */
217
-
218
- type ZodFieldMetaRegistry = ReturnType<typeof z.registry<FieldMetaPayload>>;
219
- /**
220
- * The shared registry every Attaform-aware Zod schema can register
221
- * field metadata against, regardless of major. Same instance the v3
222
- * and v4 adapter entries expose — write in one place, read from
223
- * any.
224
- *
225
- * Cast to Zod 4's `$ZodRegistry<FieldMetaPayload>` so the native
226
- * `schema.register(fieldMeta, payload)` chain type-checks for v4
227
- * users; the runtime call only needs `.add` structurally, which the
228
- * shared store provides.
229
- */
230
- declare const fieldMeta: ZodFieldMetaRegistry;
231
- /**
232
- * Attach `payload` to `schema` in the shared registry and return a
233
- * clone of `schema` so each call gets its own identity (the registry
234
- * keys on schema reference, so cloning prevents last-write-wins
235
- * collisions for sub-schemas reused at multiple paths).
236
- *
237
- * Works on both Zod 3 and Zod 4 schemas — branches on the runtime
238
- * shape of the schema:
239
- * - Zod 4 schemas expose a public `.clone()` method; we call it.
240
- * - Zod 3 schemas don't, so we reconstruct via
241
- * `new schema.constructor(schema._def)`.
242
- *
243
- * Both forms produce a fresh schema with the same effective
244
- * structure, so the registry slot is unique to this call site.
245
- */
246
- declare function withMeta<S>(schema: S, payload: FieldMetaPayload): S;
247
-
248
- export { DefaultValuesInput, FieldMetaPayload, FormKey, GenericForm, UseFormConfiguration, UseFormReturnType, ValidateOnConfig, fieldMeta, useForm, withMeta };
249
- export type { UseFormConfig, UseFormConfigV3, UseFormConfigV4, UseFormReturn, UseFormReturnV3, UseFormReturnV4 };
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
package/dist/nuxt.cjs DELETED
@@ -1,84 +0,0 @@
1
- 'use strict';
2
-
3
- const node_module = require('node:module');
4
- const node_path = require('node:path');
5
- const node_url = require('node:url');
6
- const kit = require('@nuxt/kit');
7
- const vite = require('./vite.cjs');
8
-
9
- var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
10
- const pkgVersion = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('nuxt.cjs', document.baseURI).href)))("../package.json").version;
11
- function isResolvableForVite(specifier, consumerRootDir) {
12
- const consumerURL = node_url.pathToFileURL(node_path.join(consumerRootDir, "package.json")).href;
13
- return canResolve(specifier, consumerURL) || canResolve(specifier, (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('nuxt.cjs', document.baseURI).href)));
14
- }
15
- function canResolve(specifier, fromURL) {
16
- try {
17
- undefined(specifier, fromURL);
18
- return true;
19
- } catch {
20
- return false;
21
- }
22
- }
23
- var nuxt_default = kit.defineNuxtModule({
24
- meta: {
25
- name: "Attaform",
26
- configKey: "attaform",
27
- version: pkgVersion,
28
- docs: "https://attaform.dev/docs",
29
- compatibility: {
30
- nuxt: ">=3.0.0"
31
- }
32
- },
33
- defaults: {},
34
- setup(_options, nuxt) {
35
- var _a, _b;
36
- kit.addVitePlugin(vite.attaform({ resolveZodAlias: _options.resolveZodAlias !== false }));
37
- const runtimePublic = nuxt.options.runtimeConfig.public;
38
- runtimePublic["attaform"] = {
39
- defaults: _options.defaults ?? {},
40
- version: pkgVersion
41
- };
42
- (_a = nuxt.options.vite).optimizeDeps ?? (_a.optimizeDeps = {});
43
- (_b = nuxt.options.vite.optimizeDeps).include ?? (_b.include = []);
44
- const include = nuxt.options.vite.optimizeDeps.include;
45
- for (const spec of ["@vue/devtools-api", "zod"]) {
46
- if (!isResolvableForVite(spec, nuxt.options.rootDir)) continue;
47
- if (!include.includes(spec)) include.push(spec);
48
- }
49
- const resolver = kit.createResolver((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('nuxt.cjs', document.baseURI).href)));
50
- if (_options.autoImports !== false) {
51
- kit.addImports(vite.attaformAutoImports);
52
- }
53
- kit.addPlugin({
54
- src: resolver.resolve("./runtime/plugins/attaform")
55
- });
56
- if (nuxt.options.dev) {
57
- nuxt.hook("ready", async () => {
58
- try {
59
- const { addCustomTab } = await import('@nuxt/devtools-kit');
60
- addCustomTab({
61
- name: "attaform",
62
- title: "Attaform",
63
- // Brand mark — purple square with a white "A" silhouette,
64
- // matching `apps/site/public/favicon.svg`. Served by the
65
- // `attaform/vite` middleware at the same `/_attaform_devtools`
66
- // route family (sibling to the panel HTML). A real URL
67
- // renders reliably across Nuxt DevTools versions where
68
- // `data:` URIs don't.
69
- icon: "/_attaform_devtools/icon.svg",
70
- view: {
71
- type: "iframe",
72
- src: "/_attaform_devtools",
73
- persistent: true
74
- }
75
- });
76
- } catch {
77
- }
78
- });
79
- }
80
- }
81
- });
82
-
83
- module.exports = nuxt_default;
84
- //# sourceMappingURL=nuxt.cjs.map
package/dist/nuxt.cjs.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"nuxt.cjs","sources":["../src/nuxt.ts"],"sourcesContent":["import { createRequire } from 'node:module'\nimport { join } from 'node:path'\nimport { pathToFileURL } from 'node:url'\nimport { addImports, addPlugin, addVitePlugin, createResolver, defineNuxtModule } from '@nuxt/kit'\nimport { attaformAutoImports } from './runtime/auto-imports'\nimport type { AttaformDefaults } from './runtime/types/types-api'\nimport { attaform as attaformVitePlugin } from './vite'\n\n// Read the published version from the package's own package.json so the\n// module's DevTools panel surfaces the live version pill without a\n// build-time string injection. `createRequire` reads sync at module load —\n// run once, free at steady state. Works under unbuild's Rollup output\n// without bundler-specific JSON-import handling.\nconst pkgVersion = (createRequire(import.meta.url)('../package.json') as { version: string })\n .version\n\n/**\n * Options accepted by `attaform/nuxt` under the `attaform`\n * config key.\n *\n * ```ts\n * // nuxt.config.ts\n * export default defineNuxtConfig({\n * modules: ['attaform/nuxt'],\n * attaform: {\n * defaults: { debounceMs: 100 },\n * },\n * })\n * ```\n */\nexport interface AttaformModuleOptions {\n /**\n * App-level defaults applied to every `useForm` call. Per-form\n * options always win. See `AttaformDefaults` for the\n * supported option set and merge rules.\n */\n defaults?: AttaformDefaults\n /**\n * Forwarded to `attaform/vite`'s `resolveZodAlias` option.\n * Default `true` — `attaform` and `attaform/zod` imports are rewritten\n * at build time to either `attaform/zod-v3` or `attaform/zod-v4`, based\n * on the consumer's installed Zod major. Set to `false` to bypass\n * the rewrite and ship the runtime-dispatch unified entry instead.\n */\n resolveZodAlias?: boolean\n /**\n * Auto-import Attaform's form composables (`useForm`, `useWizard`,\n * `injectForm`, `injectWizard`, `fieldMeta`, `withMeta`, `lazy`) so\n * components can call them without an explicit `import`. Default\n * `true`. The set is declared in Attaform's auto-import manifest and\n * resolves from `attaform/zod`, so the build-time adapter rewrite\n * still ships a single Zod major. Set to `false` to suppress the\n * names entirely and import the composables yourself. Note a Nuxt\n * auto-import already loses to an explicit or local binding of the\n * same name, so opting out is only needed to keep the names out of\n * global scope altogether.\n */\n autoImports?: boolean\n}\n\n/**\n * Shape of the Nuxt public runtime-config slot the module populates.\n * Reach it via `useRuntimeConfig().public.attaform` if you need to\n * read the configured defaults outside the form library itself.\n */\nexport type AttaformRuntimeConfig = {\n defaults: AttaformDefaults\n /**\n * Library version, read from the package's own `package.json` at\n * module setup. Surfaced to the runtime plugin so the DevTools\n * overlay panel can render a version pill — single source of truth\n * matches the `meta.version` Nuxt DevTools sees in the Modules panel.\n */\n version: string\n}\n\n/**\n * Whether `specifier` is resolvable using ESM resolution from either the\n * consumer's project root or attaform's own module location. Returning\n * true matches what Vite's resolver would do for `optimizeDeps.include`,\n * so a true here means Vite will pre-bundle the dep without warning.\n *\n * Why two probe locations:\n * - Consumer-rootDir probe finds direct deps + their declared peers\n * (the standard pnpm strict-isolation visibility).\n * - attaform-module probe finds peers attaform itself declares —\n * specifically the optional `@vue/devtools-api`, which lands in\n * attaform's own node_modules tree (or pnpm virtual store) when\n * installed, even if the consumer never references it directly.\n *\n * Why ESM resolution (`import.meta.resolve`) rather than CJS\n * (`createRequire(...).resolve`):\n * - attaform's exports map declares only `import` conditions for\n * non-`/nuxt` entries. CJS resolve hits ERR_PACKAGE_PATH_NOT_EXPORTED\n * for `attaform` and its sub-entries.\n * - pnpm strict isolation hides hoisted transitives behind the\n * virtual store. CJS resolve walks the bare node_modules chain and\n * misses them; ESM resolve follows pnpm's symlinks correctly.\n * - `import.meta.resolve(spec, parentURL)` is sync and stable in\n * Node 20.6+, which attaform already requires (engines.node).\n */\nfunction isResolvableForVite(specifier: string, consumerRootDir: string): boolean {\n const consumerURL = pathToFileURL(join(consumerRootDir, 'package.json')).href\n return canResolve(specifier, consumerURL) || canResolve(specifier, import.meta.url)\n}\n\nfunction canResolve(specifier: string, fromURL: string): boolean {\n try {\n import.meta.resolve(specifier, fromURL)\n return true\n } catch {\n return false\n }\n}\n\nexport default defineNuxtModule<AttaformModuleOptions>({\n meta: {\n name: 'Attaform',\n configKey: 'attaform',\n version: pkgVersion,\n docs: 'https://attaform.dev/docs',\n compatibility: {\n nuxt: '>=3.0.0',\n },\n },\n defaults: {},\n setup(_options, nuxt) {\n // Register `attaform/vite` so the same plugin handles every Vite-\n // surface concern: pushing the compile-time node transforms into\n // `@vitejs/plugin-vue`'s `api.options.template.compilerOptions.\n // nodeTransforms`, AND rewriting `attaform/zod` imports at build\n // time to either `/zod-v3` or `/zod-v4` based on the consumer's\n // installed Zod major. Consolidating both behaviors in one Vite\n // plugin instance keeps the Nuxt-side wiring minimal and ensures\n // the consumer's Nuxt build sees the exact same DX as a bare-Vite\n // consumer.\n addVitePlugin(attaformVitePlugin({ resolveZodAlias: _options.resolveZodAlias !== false }))\n\n // Publish module options to public runtime config so the plugin can\n // read them at install time on both server and client. Frozen-empty\n // by default — the plugin's merge code reads this slot directly\n // without a `?? {}` guard at every call site.\n const runtimePublic = nuxt.options.runtimeConfig.public as Record<string, unknown>\n runtimePublic['attaform'] = {\n defaults: _options.defaults ?? {},\n version: pkgVersion,\n } satisfies AttaformRuntimeConfig\n\n // Force-include attaform's own peers that Vite's startup crawl\n // tends to miss for Nuxt projects. Vite scans `index.html` + the\n // statically-known entry points but doesn't deeply follow into\n // pages that get loaded via Nuxt's dynamic router; deps imported\n // exclusively from page chunks are discovered when the page first\n // requests, the optimizer rebundles, and Vite silently broadcasts\n // `{\"type\":\"full-reload\",\"path\":\"*\"}` over the HMR WebSocket — what\n // consumers see as \"the page loads, then reloads itself a second\n // later.\" Vite's own \"discovered new dependencies at runtime\"\n // warning recommends exactly this remediation.\n //\n // We declare here only deps attaform itself owns the relationship\n // with — `@vue/devtools-api` (attaform's DevTools integration\n // peer) and `zod` (the adapter peer for `/zod`, `/zod-v3`, and\n // `/zod-v4`). Consumer-\n // side deps (vue-query, immer, etc.) are the consumer's\n // responsibility — they declare them in their own\n // `vite.optimizeDeps.include`. Each push is gated on the spec\n // being resolvable from the consumer's project (or attaform's\n // own module context for attaform's optional peers like\n // devtools-api), so consumers without the optional peer don't see\n // a \"failed to resolve\" warning at boot.\n nuxt.options.vite.optimizeDeps ??= {}\n nuxt.options.vite.optimizeDeps.include ??= []\n const include = nuxt.options.vite.optimizeDeps.include\n for (const spec of ['@vue/devtools-api', 'zod']) {\n if (!isResolvableForVite(spec, nuxt.options.rootDir)) continue\n if (!include.includes(spec)) include.push(spec)\n }\n\n const resolver = createResolver(import.meta.url)\n\n // Auto-import the Zod-default form composables so a component can\n // reach for `useForm` / `useWizard` / `injectForm` / `injectWizard` /\n // `fieldMeta` / `withMeta` / `lazy` with no import line. The manifest\n // in `./runtime/auto-imports` is the single source of truth, shared\n // with the `attaform/vite` preset re-export.\n //\n // Each entry resolves from `attaform/zod`, not the bare `attaform`\n // barrel: the Vite/bundler plugin rewrites the exact `attaform/zod`\n // specifier to the one installed Zod major at build time, so a Nuxt\n // consumer's bundle ships a single adapter instead of the runtime\n // dispatcher. After the schema-entry re-partition the two surfaces\n // are byte-identical (`attaform` re-exports exactly what\n // `attaform/zod` does), so pointing at `/zod` costs nothing and buys\n // the lean bundle for free. Resolving a public subpath rather than a\n // relative `./runtime/…` path also keeps the published package honest\n // — `attaform/zod` maps to a real `dist/zod.mjs`, so Nuxt's\n // auto-import step never chases a source path with no built artifact.\n //\n // A Nuxt auto-import always loses to an explicit or local binding, so\n // registering these never shadows a consumer's own `useForm`. The\n // `autoImports: false` option suppresses the whole set for consumers\n // who prefer explicit imports everywhere.\n if (_options.autoImports !== false) {\n addImports(attaformAutoImports)\n }\n\n // Plugin that installs `createAttaform()` on the Vue app and\n // wires the payload serialize/hydrate bridge. Uses a physical\n // `src/runtime/plugins/attaform.ts` file (shipped to\n // `dist/runtime/plugins/attaform.mjs` via an explicit entry in\n // build.config.ts) rather than an inline plugin template, because a\n // template's `import { createAttaform } from 'attaform'`\n // resolves through the `attaform` package entry — which in\n // local dev (`unbuild --stub`) is a jiti runtime transpiler whose\n // `node:module`/`createRequire` imports Nitro's Rollup build cannot\n // bundle. A physical file lets Nitro follow its imports directly\n // (TS source in dev, ESM in the published package), avoiding the\n // jiti indirection entirely. Unbuild's shared-chunk splitter keeps\n // `core/plugin` + `core/serialize` deduplicated with `src/zod` /\n // `src/index`, so there's still only one `registry` module at runtime.\n //\n // `addPlugin` defaults to PREPEND so the plugin runs before any\n // user plugin / page; `enforce: 'pre'` inside the plugin body makes\n // that ordering explicit at the Nuxt-plugin layer too. Together\n // they guarantee the registry is installed (and SSR payload staged\n // into `pendingHydration`) before any `useForm` call runs.\n addPlugin({\n src: resolver.resolve('./runtime/plugins/attaform'),\n })\n\n // Dev-only: register a Nuxt DevTools overlay tab pointing at an\n // iframe that mounts the Attaform inspector. The iframe URL\n // (`/_attaform_devtools`) is served by a Vite-layer middleware\n // wired up in `attaform/vite` — by intercepting at the Vite layer\n // rather than via `extendPages`, the route stays invisible to\n // vue-router and works regardless of whether the consumer uses\n // a `pages/` directory or `app.vue`-only mode.\n //\n // `@nuxt/devtools-kit` is NOT a transitive peer of `@nuxt/kit`; it\n // ships alongside `@nuxt/devtools`. Consumers who don't install\n // Nuxt DevTools (rare in real Nuxt projects, common in test\n // fixtures) get a silent no-op instead of an \"unresolved import\"\n // error. Mirrors the same try/import pattern used for\n // `@vue/devtools-api` in the runtime devtools wire-up.\n if (nuxt.options.dev) {\n nuxt.hook('ready', async () => {\n try {\n const { addCustomTab } = await import('@nuxt/devtools-kit')\n addCustomTab({\n name: 'attaform',\n title: 'Attaform',\n // Brand mark — purple square with a white \"A\" silhouette,\n // matching `apps/site/public/favicon.svg`. Served by the\n // `attaform/vite` middleware at the same `/_attaform_devtools`\n // route family (sibling to the panel HTML). A real URL\n // renders reliably across Nuxt DevTools versions where\n // `data:` URIs don't.\n icon: '/_attaform_devtools/icon.svg',\n view: {\n type: 'iframe',\n src: '/_attaform_devtools',\n persistent: true,\n },\n })\n } catch {\n // Nuxt DevTools (and thus @nuxt/devtools-kit) isn't installed\n // in this consumer — silently skip. The library still works;\n // only the overlay tab is missing.\n }\n })\n }\n },\n})\n"],"names":["createRequire","pathToFileURL","join","defineNuxtModule","addVitePlugin","attaformVitePlugin","createResolver","addImports","attaformAutoImports","addPlugin"],"mappings":"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"}
package/dist/nuxt.d.cts DELETED
@@ -1,66 +0,0 @@
1
- import * as _nuxt_schema from '@nuxt/schema';
2
- import { d as AttaformDefaults } from './shared/attaform.DniawQLP.cjs';
3
- import 'vue';
4
-
5
- /**
6
- * Options accepted by `attaform/nuxt` under the `attaform`
7
- * config key.
8
- *
9
- * ```ts
10
- * // nuxt.config.ts
11
- * export default defineNuxtConfig({
12
- * modules: ['attaform/nuxt'],
13
- * attaform: {
14
- * defaults: { debounceMs: 100 },
15
- * },
16
- * })
17
- * ```
18
- */
19
- interface AttaformModuleOptions {
20
- /**
21
- * App-level defaults applied to every `useForm` call. Per-form
22
- * options always win. See `AttaformDefaults` for the
23
- * supported option set and merge rules.
24
- */
25
- defaults?: AttaformDefaults;
26
- /**
27
- * Forwarded to `attaform/vite`'s `resolveZodAlias` option.
28
- * Default `true` — `attaform` and `attaform/zod` imports are rewritten
29
- * at build time to either `attaform/zod-v3` or `attaform/zod-v4`, based
30
- * on the consumer's installed Zod major. Set to `false` to bypass
31
- * the rewrite and ship the runtime-dispatch unified entry instead.
32
- */
33
- resolveZodAlias?: boolean;
34
- /**
35
- * Auto-import Attaform's form composables (`useForm`, `useWizard`,
36
- * `injectForm`, `injectWizard`, `fieldMeta`, `withMeta`, `lazy`) so
37
- * components can call them without an explicit `import`. Default
38
- * `true`. The set is declared in Attaform's auto-import manifest and
39
- * resolves from `attaform/zod`, so the build-time adapter rewrite
40
- * still ships a single Zod major. Set to `false` to suppress the
41
- * names entirely and import the composables yourself. Note a Nuxt
42
- * auto-import already loses to an explicit or local binding of the
43
- * same name, so opting out is only needed to keep the names out of
44
- * global scope altogether.
45
- */
46
- autoImports?: boolean;
47
- }
48
- /**
49
- * Shape of the Nuxt public runtime-config slot the module populates.
50
- * Reach it via `useRuntimeConfig().public.attaform` if you need to
51
- * read the configured defaults outside the form library itself.
52
- */
53
- type AttaformRuntimeConfig = {
54
- defaults: AttaformDefaults;
55
- /**
56
- * Library version, read from the package's own `package.json` at
57
- * module setup. Surfaced to the runtime plugin so the DevTools
58
- * overlay panel can render a version pill — single source of truth
59
- * matches the `meta.version` Nuxt DevTools sees in the Modules panel.
60
- */
61
- version: string;
62
- };
63
- declare const _default: _nuxt_schema.NuxtModule<AttaformModuleOptions, AttaformModuleOptions, false>;
64
-
65
- export = _default;
66
- export type { AttaformModuleOptions, AttaformRuntimeConfig };
package/dist/nuxt.d.ts DELETED
@@ -1,66 +0,0 @@
1
- import * as _nuxt_schema from '@nuxt/schema';
2
- import { d as AttaformDefaults } from './shared/attaform.DniawQLP.js';
3
- import 'vue';
4
-
5
- /**
6
- * Options accepted by `attaform/nuxt` under the `attaform`
7
- * config key.
8
- *
9
- * ```ts
10
- * // nuxt.config.ts
11
- * export default defineNuxtConfig({
12
- * modules: ['attaform/nuxt'],
13
- * attaform: {
14
- * defaults: { debounceMs: 100 },
15
- * },
16
- * })
17
- * ```
18
- */
19
- interface AttaformModuleOptions {
20
- /**
21
- * App-level defaults applied to every `useForm` call. Per-form
22
- * options always win. See `AttaformDefaults` for the
23
- * supported option set and merge rules.
24
- */
25
- defaults?: AttaformDefaults;
26
- /**
27
- * Forwarded to `attaform/vite`'s `resolveZodAlias` option.
28
- * Default `true` — `attaform` and `attaform/zod` imports are rewritten
29
- * at build time to either `attaform/zod-v3` or `attaform/zod-v4`, based
30
- * on the consumer's installed Zod major. Set to `false` to bypass
31
- * the rewrite and ship the runtime-dispatch unified entry instead.
32
- */
33
- resolveZodAlias?: boolean;
34
- /**
35
- * Auto-import Attaform's form composables (`useForm`, `useWizard`,
36
- * `injectForm`, `injectWizard`, `fieldMeta`, `withMeta`, `lazy`) so
37
- * components can call them without an explicit `import`. Default
38
- * `true`. The set is declared in Attaform's auto-import manifest and
39
- * resolves from `attaform/zod`, so the build-time adapter rewrite
40
- * still ships a single Zod major. Set to `false` to suppress the
41
- * names entirely and import the composables yourself. Note a Nuxt
42
- * auto-import already loses to an explicit or local binding of the
43
- * same name, so opting out is only needed to keep the names out of
44
- * global scope altogether.
45
- */
46
- autoImports?: boolean;
47
- }
48
- /**
49
- * Shape of the Nuxt public runtime-config slot the module populates.
50
- * Reach it via `useRuntimeConfig().public.attaform` if you need to
51
- * read the configured defaults outside the form library itself.
52
- */
53
- type AttaformRuntimeConfig = {
54
- defaults: AttaformDefaults;
55
- /**
56
- * Library version, read from the package's own `package.json` at
57
- * module setup. Surfaced to the runtime plugin so the DevTools
58
- * overlay panel can render a version pill — single source of truth
59
- * matches the `meta.version` Nuxt DevTools sees in the Modules panel.
60
- */
61
- version: string;
62
- };
63
- declare const _default: _nuxt_schema.NuxtModule<AttaformModuleOptions, AttaformModuleOptions, false>;
64
-
65
- export = _default;
66
- export type { AttaformModuleOptions, AttaformRuntimeConfig };
package/dist/nuxt.mjs.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"nuxt.mjs","sources":["../src/nuxt.ts"],"sourcesContent":["import { createRequire } from 'node:module'\nimport { join } from 'node:path'\nimport { pathToFileURL } from 'node:url'\nimport { addImports, addPlugin, addVitePlugin, createResolver, defineNuxtModule } from '@nuxt/kit'\nimport { attaformAutoImports } from './runtime/auto-imports'\nimport type { AttaformDefaults } from './runtime/types/types-api'\nimport { attaform as attaformVitePlugin } from './vite'\n\n// Read the published version from the package's own package.json so the\n// module's DevTools panel surfaces the live version pill without a\n// build-time string injection. `createRequire` reads sync at module load —\n// run once, free at steady state. Works under unbuild's Rollup output\n// without bundler-specific JSON-import handling.\nconst pkgVersion = (createRequire(import.meta.url)('../package.json') as { version: string })\n .version\n\n/**\n * Options accepted by `attaform/nuxt` under the `attaform`\n * config key.\n *\n * ```ts\n * // nuxt.config.ts\n * export default defineNuxtConfig({\n * modules: ['attaform/nuxt'],\n * attaform: {\n * defaults: { debounceMs: 100 },\n * },\n * })\n * ```\n */\nexport interface AttaformModuleOptions {\n /**\n * App-level defaults applied to every `useForm` call. Per-form\n * options always win. See `AttaformDefaults` for the\n * supported option set and merge rules.\n */\n defaults?: AttaformDefaults\n /**\n * Forwarded to `attaform/vite`'s `resolveZodAlias` option.\n * Default `true` — `attaform` and `attaform/zod` imports are rewritten\n * at build time to either `attaform/zod-v3` or `attaform/zod-v4`, based\n * on the consumer's installed Zod major. Set to `false` to bypass\n * the rewrite and ship the runtime-dispatch unified entry instead.\n */\n resolveZodAlias?: boolean\n /**\n * Auto-import Attaform's form composables (`useForm`, `useWizard`,\n * `injectForm`, `injectWizard`, `fieldMeta`, `withMeta`, `lazy`) so\n * components can call them without an explicit `import`. Default\n * `true`. The set is declared in Attaform's auto-import manifest and\n * resolves from `attaform/zod`, so the build-time adapter rewrite\n * still ships a single Zod major. Set to `false` to suppress the\n * names entirely and import the composables yourself. Note a Nuxt\n * auto-import already loses to an explicit or local binding of the\n * same name, so opting out is only needed to keep the names out of\n * global scope altogether.\n */\n autoImports?: boolean\n}\n\n/**\n * Shape of the Nuxt public runtime-config slot the module populates.\n * Reach it via `useRuntimeConfig().public.attaform` if you need to\n * read the configured defaults outside the form library itself.\n */\nexport type AttaformRuntimeConfig = {\n defaults: AttaformDefaults\n /**\n * Library version, read from the package's own `package.json` at\n * module setup. Surfaced to the runtime plugin so the DevTools\n * overlay panel can render a version pill — single source of truth\n * matches the `meta.version` Nuxt DevTools sees in the Modules panel.\n */\n version: string\n}\n\n/**\n * Whether `specifier` is resolvable using ESM resolution from either the\n * consumer's project root or attaform's own module location. Returning\n * true matches what Vite's resolver would do for `optimizeDeps.include`,\n * so a true here means Vite will pre-bundle the dep without warning.\n *\n * Why two probe locations:\n * - Consumer-rootDir probe finds direct deps + their declared peers\n * (the standard pnpm strict-isolation visibility).\n * - attaform-module probe finds peers attaform itself declares —\n * specifically the optional `@vue/devtools-api`, which lands in\n * attaform's own node_modules tree (or pnpm virtual store) when\n * installed, even if the consumer never references it directly.\n *\n * Why ESM resolution (`import.meta.resolve`) rather than CJS\n * (`createRequire(...).resolve`):\n * - attaform's exports map declares only `import` conditions for\n * non-`/nuxt` entries. CJS resolve hits ERR_PACKAGE_PATH_NOT_EXPORTED\n * for `attaform` and its sub-entries.\n * - pnpm strict isolation hides hoisted transitives behind the\n * virtual store. CJS resolve walks the bare node_modules chain and\n * misses them; ESM resolve follows pnpm's symlinks correctly.\n * - `import.meta.resolve(spec, parentURL)` is sync and stable in\n * Node 20.6+, which attaform already requires (engines.node).\n */\nfunction isResolvableForVite(specifier: string, consumerRootDir: string): boolean {\n const consumerURL = pathToFileURL(join(consumerRootDir, 'package.json')).href\n return canResolve(specifier, consumerURL) || canResolve(specifier, import.meta.url)\n}\n\nfunction canResolve(specifier: string, fromURL: string): boolean {\n try {\n import.meta.resolve(specifier, fromURL)\n return true\n } catch {\n return false\n }\n}\n\nexport default defineNuxtModule<AttaformModuleOptions>({\n meta: {\n name: 'Attaform',\n configKey: 'attaform',\n version: pkgVersion,\n docs: 'https://attaform.dev/docs',\n compatibility: {\n nuxt: '>=3.0.0',\n },\n },\n defaults: {},\n setup(_options, nuxt) {\n // Register `attaform/vite` so the same plugin handles every Vite-\n // surface concern: pushing the compile-time node transforms into\n // `@vitejs/plugin-vue`'s `api.options.template.compilerOptions.\n // nodeTransforms`, AND rewriting `attaform/zod` imports at build\n // time to either `/zod-v3` or `/zod-v4` based on the consumer's\n // installed Zod major. Consolidating both behaviors in one Vite\n // plugin instance keeps the Nuxt-side wiring minimal and ensures\n // the consumer's Nuxt build sees the exact same DX as a bare-Vite\n // consumer.\n addVitePlugin(attaformVitePlugin({ resolveZodAlias: _options.resolveZodAlias !== false }))\n\n // Publish module options to public runtime config so the plugin can\n // read them at install time on both server and client. Frozen-empty\n // by default — the plugin's merge code reads this slot directly\n // without a `?? {}` guard at every call site.\n const runtimePublic = nuxt.options.runtimeConfig.public as Record<string, unknown>\n runtimePublic['attaform'] = {\n defaults: _options.defaults ?? {},\n version: pkgVersion,\n } satisfies AttaformRuntimeConfig\n\n // Force-include attaform's own peers that Vite's startup crawl\n // tends to miss for Nuxt projects. Vite scans `index.html` + the\n // statically-known entry points but doesn't deeply follow into\n // pages that get loaded via Nuxt's dynamic router; deps imported\n // exclusively from page chunks are discovered when the page first\n // requests, the optimizer rebundles, and Vite silently broadcasts\n // `{\"type\":\"full-reload\",\"path\":\"*\"}` over the HMR WebSocket — what\n // consumers see as \"the page loads, then reloads itself a second\n // later.\" Vite's own \"discovered new dependencies at runtime\"\n // warning recommends exactly this remediation.\n //\n // We declare here only deps attaform itself owns the relationship\n // with — `@vue/devtools-api` (attaform's DevTools integration\n // peer) and `zod` (the adapter peer for `/zod`, `/zod-v3`, and\n // `/zod-v4`). Consumer-\n // side deps (vue-query, immer, etc.) are the consumer's\n // responsibility — they declare them in their own\n // `vite.optimizeDeps.include`. Each push is gated on the spec\n // being resolvable from the consumer's project (or attaform's\n // own module context for attaform's optional peers like\n // devtools-api), so consumers without the optional peer don't see\n // a \"failed to resolve\" warning at boot.\n nuxt.options.vite.optimizeDeps ??= {}\n nuxt.options.vite.optimizeDeps.include ??= []\n const include = nuxt.options.vite.optimizeDeps.include\n for (const spec of ['@vue/devtools-api', 'zod']) {\n if (!isResolvableForVite(spec, nuxt.options.rootDir)) continue\n if (!include.includes(spec)) include.push(spec)\n }\n\n const resolver = createResolver(import.meta.url)\n\n // Auto-import the Zod-default form composables so a component can\n // reach for `useForm` / `useWizard` / `injectForm` / `injectWizard` /\n // `fieldMeta` / `withMeta` / `lazy` with no import line. The manifest\n // in `./runtime/auto-imports` is the single source of truth, shared\n // with the `attaform/vite` preset re-export.\n //\n // Each entry resolves from `attaform/zod`, not the bare `attaform`\n // barrel: the Vite/bundler plugin rewrites the exact `attaform/zod`\n // specifier to the one installed Zod major at build time, so a Nuxt\n // consumer's bundle ships a single adapter instead of the runtime\n // dispatcher. After the schema-entry re-partition the two surfaces\n // are byte-identical (`attaform` re-exports exactly what\n // `attaform/zod` does), so pointing at `/zod` costs nothing and buys\n // the lean bundle for free. Resolving a public subpath rather than a\n // relative `./runtime/…` path also keeps the published package honest\n // — `attaform/zod` maps to a real `dist/zod.mjs`, so Nuxt's\n // auto-import step never chases a source path with no built artifact.\n //\n // A Nuxt auto-import always loses to an explicit or local binding, so\n // registering these never shadows a consumer's own `useForm`. The\n // `autoImports: false` option suppresses the whole set for consumers\n // who prefer explicit imports everywhere.\n if (_options.autoImports !== false) {\n addImports(attaformAutoImports)\n }\n\n // Plugin that installs `createAttaform()` on the Vue app and\n // wires the payload serialize/hydrate bridge. Uses a physical\n // `src/runtime/plugins/attaform.ts` file (shipped to\n // `dist/runtime/plugins/attaform.mjs` via an explicit entry in\n // build.config.ts) rather than an inline plugin template, because a\n // template's `import { createAttaform } from 'attaform'`\n // resolves through the `attaform` package entry — which in\n // local dev (`unbuild --stub`) is a jiti runtime transpiler whose\n // `node:module`/`createRequire` imports Nitro's Rollup build cannot\n // bundle. A physical file lets Nitro follow its imports directly\n // (TS source in dev, ESM in the published package), avoiding the\n // jiti indirection entirely. Unbuild's shared-chunk splitter keeps\n // `core/plugin` + `core/serialize` deduplicated with `src/zod` /\n // `src/index`, so there's still only one `registry` module at runtime.\n //\n // `addPlugin` defaults to PREPEND so the plugin runs before any\n // user plugin / page; `enforce: 'pre'` inside the plugin body makes\n // that ordering explicit at the Nuxt-plugin layer too. Together\n // they guarantee the registry is installed (and SSR payload staged\n // into `pendingHydration`) before any `useForm` call runs.\n addPlugin({\n src: resolver.resolve('./runtime/plugins/attaform'),\n })\n\n // Dev-only: register a Nuxt DevTools overlay tab pointing at an\n // iframe that mounts the Attaform inspector. The iframe URL\n // (`/_attaform_devtools`) is served by a Vite-layer middleware\n // wired up in `attaform/vite` — by intercepting at the Vite layer\n // rather than via `extendPages`, the route stays invisible to\n // vue-router and works regardless of whether the consumer uses\n // a `pages/` directory or `app.vue`-only mode.\n //\n // `@nuxt/devtools-kit` is NOT a transitive peer of `@nuxt/kit`; it\n // ships alongside `@nuxt/devtools`. Consumers who don't install\n // Nuxt DevTools (rare in real Nuxt projects, common in test\n // fixtures) get a silent no-op instead of an \"unresolved import\"\n // error. Mirrors the same try/import pattern used for\n // `@vue/devtools-api` in the runtime devtools wire-up.\n if (nuxt.options.dev) {\n nuxt.hook('ready', async () => {\n try {\n const { addCustomTab } = await import('@nuxt/devtools-kit')\n addCustomTab({\n name: 'attaform',\n title: 'Attaform',\n // Brand mark — purple square with a white \"A\" silhouette,\n // matching `apps/site/public/favicon.svg`. Served by the\n // `attaform/vite` middleware at the same `/_attaform_devtools`\n // route family (sibling to the panel HTML). A real URL\n // renders reliably across Nuxt DevTools versions where\n // `data:` URIs don't.\n icon: '/_attaform_devtools/icon.svg',\n view: {\n type: 'iframe',\n src: '/_attaform_devtools',\n persistent: true,\n },\n })\n } catch {\n // Nuxt DevTools (and thus @nuxt/devtools-kit) isn't installed\n // in this consumer — silently skip. The library still works;\n // only the overlay tab is missing.\n }\n })\n }\n },\n})\n"],"names":["attaformVitePlugin"],"mappings":";;;;;;AAaA,MAAM,aAAc,aAAA,CAAc,MAAA,CAAA,IAAA,CAAY,GAAG,CAAA,CAAE,iBAAiB,CAAA,CACjE,OAAA;AAuFH,SAAS,mBAAA,CAAoB,WAAmB,eAAA,EAAkC;AAChF,EAAA,MAAM,cAAc,aAAA,CAAc,IAAA,CAAK,eAAA,EAAiB,cAAc,CAAC,CAAA,CAAE,IAAA;AACzE,EAAA,OAAO,WAAW,SAAA,EAAW,WAAW,KAAK,UAAA,CAAW,SAAA,EAAW,YAAY,GAAG,CAAA;AACpF;AAEA,SAAS,UAAA,CAAW,WAAmB,OAAA,EAA0B;AAC/D,EAAA,IAAI;AACF,IAAA,MAAA,CAAA,IAAA,CAAY,OAAA,CAAQ,WAAW,OAAO,CAAA;AACtC,IAAA,OAAO,IAAA;AAAA,EACT,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,KAAA;AAAA,EACT;AACF;AAEA,IAAO,eAAQ,gBAAA,CAAwC;AAAA,EACrD,IAAA,EAAM;AAAA,IACJ,IAAA,EAAM,UAAA;AAAA,IACN,SAAA,EAAW,UAAA;AAAA,IACX,OAAA,EAAS,UAAA;AAAA,IACT,IAAA,EAAM,2BAAA;AAAA,IACN,aAAA,EAAe;AAAA,MACb,IAAA,EAAM;AAAA;AACR,GACF;AAAA,EACA,UAAU,EAAC;AAAA,EACX,KAAA,CAAM,UAAU,IAAA,EAAM;AA9HxB,IAAA,IAAA,EAAA,EAAA,EAAA;AAwII,IAAA,aAAA,CAAcA,SAAmB,EAAE,eAAA,EAAiB,SAAS,eAAA,KAAoB,KAAA,EAAO,CAAC,CAAA;AAMzF,IAAA,MAAM,aAAA,GAAgB,IAAA,CAAK,OAAA,CAAQ,aAAA,CAAc,MAAA;AACjD,IAAA,aAAA,CAAc,UAAU,CAAA,GAAI;AAAA,MAC1B,QAAA,EAAU,QAAA,CAAS,QAAA,IAAY,EAAC;AAAA,MAChC,OAAA,EAAS;AAAA,KACX;AAwBA,IAAA,CAAA,EAAA,GAAA,IAAA,CAAK,OAAA,CAAQ,IAAA,EAAK,YAAA,KAAlB,EAAA,CAAkB,eAAiB,EAAC,CAAA;AACpC,IAAA,CAAA,EAAA,GAAA,IAAA,CAAK,QAAQ,IAAA,CAAK,YAAA,EAAa,OAAA,KAA/B,EAAA,CAA+B,UAAY,EAAC,CAAA;AAC5C,IAAA,MAAM,OAAA,GAAU,IAAA,CAAK,OAAA,CAAQ,IAAA,CAAK,YAAA,CAAa,OAAA;AAC/C,IAAA,KAAA,MAAW,IAAA,IAAQ,CAAC,mBAAA,EAAqB,KAAK,CAAA,EAAG;AAC/C,MAAA,IAAI,CAAC,mBAAA,CAAoB,IAAA,EAAM,IAAA,CAAK,OAAA,CAAQ,OAAO,CAAA,EAAG;AACtD,MAAA,IAAI,CAAC,OAAA,CAAQ,QAAA,CAAS,IAAI,CAAA,EAAG,OAAA,CAAQ,KAAK,IAAI,CAAA;AAAA,IAChD;AAEA,IAAA,MAAM,QAAA,GAAW,cAAA,CAAe,MAAA,CAAA,IAAA,CAAY,GAAG,CAAA;AAwB/C,IAAA,IAAI,QAAA,CAAS,gBAAgB,KAAA,EAAO;AAClC,MAAA,UAAA,CAAW,mBAAmB,CAAA;AAAA,IAChC;AAsBA,IAAA,SAAA,CAAU;AAAA,MACR,GAAA,EAAK,QAAA,CAAS,OAAA,CAAQ,4BAA4B;AAAA,KACnD,CAAA;AAgBD,IAAA,IAAI,IAAA,CAAK,QAAQ,GAAA,EAAK;AACpB,MAAA,IAAA,CAAK,IAAA,CAAK,SAAS,YAAY;AAC7B,QAAA,IAAI;AACF,UAAA,MAAM,EAAE,YAAA,EAAa,GAAI,MAAM,OAAO,oBAAoB,CAAA;AAC1D,UAAA,YAAA,CAAa;AAAA,YACX,IAAA,EAAM,UAAA;AAAA,YACN,KAAA,EAAO,UAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,YAOP,IAAA,EAAM,8BAAA;AAAA,YACN,IAAA,EAAM;AAAA,cACJ,IAAA,EAAM,QAAA;AAAA,cACN,GAAA,EAAK,qBAAA;AAAA,cACL,UAAA,EAAY;AAAA;AACd,WACD,CAAA;AAAA,QACH,CAAA,CAAA,MAAQ;AAAA,QAIR;AAAA,MACF,CAAC,CAAA;AAAA,IACH;AAAA,EACF;AACF,CAAC;;;;"}
package/dist/rollup.cjs DELETED
@@ -1,24 +0,0 @@
1
- 'use strict';
2
-
3
- const detectZodMajor = require('./shared/attaform.DoQm_Vkd.cjs');
4
-
5
- function attaform(options = {}) {
6
- const resolveZodAlias = options.resolveZodAlias !== false;
7
- const root = options.root ?? process.cwd();
8
- const warnState = { warned: false };
9
- let aliasTarget = null;
10
- return {
11
- name: "attaform",
12
- buildStart() {
13
- aliasTarget = detectZodMajor.resolveZodAliasTarget(root, "attaform/rollup", resolveZodAlias, warnState);
14
- },
15
- resolveId(source, importer) {
16
- if (aliasTarget === null) return null;
17
- if (!detectZodMajor.isRewritableZodSpecifier(source)) return null;
18
- return this.resolve(aliasTarget, importer, { skipSelf: true });
19
- }
20
- };
21
- }
22
-
23
- exports.attaform = attaform;
24
- //# sourceMappingURL=rollup.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"rollup.cjs","sources":["../src/rollup.ts"],"sourcesContent":["/**\n * `attaform/rollup` — Rollup plugin that rewrites `attaform` and\n * `attaform/zod` imports to the single matching adapter subpath\n * (`attaform/zod-v3` or `attaform/zod-v4`) at build time, based on the\n * consumer's installed Zod major. Without it, Rollup ships both adapters\n * because those entries import both for runtime dispatch.\n *\n * Usage:\n *\n * // rollup.config.js\n * import { attaform } from 'attaform/rollup'\n *\n * export default {\n * plugins: [attaform()],\n * }\n *\n * This plugin only does the adapter rewrite. The Vue SFC `v-register`\n * transforms that `attaform/vite` wires (load-bearing for SSR initial\n * render) are `@vitejs/plugin-vue`-specific and do not transfer; a\n * non-Vite consumer that needs them wires `attaform/transforms` into\n * their Vue compiler separately.\n *\n * Zero-dep: the plugin imports nothing from `rollup` (the bundler injects\n * its plugin context at the consumer's build); the structural types below\n * are all it needs to compile.\n */\nimport { isRewritableZodSpecifier, resolveZodAliasTarget } from './core/detect-zod-major'\n\n/** Options for the Rollup `attaform()` plugin. */\nexport interface AttaformRollupPluginOptions {\n /**\n * Rewrite `attaform` and `attaform/zod` imports at build time to the\n * matching adapter subpath. Default `true`. Set to `false` to keep the\n * runtime-dispatch unified entry (ships both adapters).\n */\n resolveZodAlias?: boolean\n /**\n * Project root to resolve the installed Zod from. Defaults to\n * `process.cwd()`. Set this when the build runs from a directory other\n * than the project that owns the Zod dependency.\n */\n root?: string\n}\n\ninterface RollupResolveContext {\n resolve(\n source: string,\n importer: string | undefined,\n options: { skipSelf: boolean }\n ): Promise<{ id: string; external: boolean | 'absolute' | 'relative' } | null>\n}\n\n/** The structural shape Rollup requires of the plugin. */\nexport interface AttaformRollupPlugin {\n name: string\n buildStart(): void\n resolveId(\n this: RollupResolveContext,\n source: string,\n importer: string | undefined\n ): Promise<{ id: string } | null> | null\n}\n\nexport function attaform(options: AttaformRollupPluginOptions = {}): AttaformRollupPlugin {\n const resolveZodAlias = options.resolveZodAlias !== false\n const root = options.root ?? process.cwd()\n const warnState = { warned: false }\n let aliasTarget: string | null = null\n\n return {\n name: 'attaform',\n buildStart() {\n // Detect once at build start (fail fast on missing zod). `buildStart`\n // is guaranteed to run before any `resolveId`, so the target is set\n // before the rewrite hook fires.\n aliasTarget = resolveZodAliasTarget(root, 'attaform/rollup', resolveZodAlias, warnState)\n },\n resolveId(source, importer) {\n if (aliasTarget === null) return null\n // Both the bare `attaform` barrel and the explicit `attaform/zod`\n // carry the runtime dispatcher, so both collapse to the one detected\n // adapter; the pinned subpaths pass through untouched.\n if (!isRewritableZodSpecifier(source)) return null\n // Re-run the rewritten specifier through the resolver chain so the\n // matching subpath export lands as a real module. `skipSelf` keeps\n // the hook reentrant (our source check rejects the rewritten target\n // anyway, since it is no longer a rewritable specifier).\n return this.resolve(aliasTarget, importer, { skipSelf: true })\n },\n }\n}\n"],"names":["resolveZodAliasTarget","isRewritableZodSpecifier"],"mappings":";;;;AA+DO,SAAS,QAAA,CAAS,OAAA,GAAuC,EAAC,EAAyB;AACxF,EAAA,MAAM,eAAA,GAAkB,QAAQ,eAAA,KAAoB,KAAA;AACpD,EAAA,MAAM,IAAA,GAAO,OAAA,CAAQ,IAAA,IAAQ,OAAA,CAAQ,GAAA,EAAI;AACzC,EAAA,MAAM,SAAA,GAAY,EAAE,MAAA,EAAQ,KAAA,EAAM;AAClC,EAAA,IAAI,WAAA,GAA6B,IAAA;AAEjC,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,UAAA;AAAA,IACN,UAAA,GAAa;AAIX,MAAA,WAAA,GAAcA,oCAAA,CAAsB,IAAA,EAAM,iBAAA,EAAmB,eAAA,EAAiB,SAAS,CAAA;AAAA,IACzF,CAAA;AAAA,IACA,SAAA,CAAU,QAAQ,QAAA,EAAU;AAC1B,MAAA,IAAI,WAAA,KAAgB,MAAM,OAAO,IAAA;AAIjC,MAAA,IAAI,CAACC,uCAAA,CAAyB,MAAM,CAAA,EAAG,OAAO,IAAA;AAK9C,MAAA,OAAO,KAAK,OAAA,CAAQ,WAAA,EAAa,UAAU,EAAE,QAAA,EAAU,MAAM,CAAA;AAAA,IAC/D;AAAA,GACF;AACF;;;;"}
package/dist/rollup.d.cts DELETED
@@ -1,35 +0,0 @@
1
- /** Options for the Rollup `attaform()` plugin. */
2
- interface AttaformRollupPluginOptions {
3
- /**
4
- * Rewrite `attaform` and `attaform/zod` imports at build time to the
5
- * matching adapter subpath. Default `true`. Set to `false` to keep the
6
- * runtime-dispatch unified entry (ships both adapters).
7
- */
8
- resolveZodAlias?: boolean;
9
- /**
10
- * Project root to resolve the installed Zod from. Defaults to
11
- * `process.cwd()`. Set this when the build runs from a directory other
12
- * than the project that owns the Zod dependency.
13
- */
14
- root?: string;
15
- }
16
- interface RollupResolveContext {
17
- resolve(source: string, importer: string | undefined, options: {
18
- skipSelf: boolean;
19
- }): Promise<{
20
- id: string;
21
- external: boolean | 'absolute' | 'relative';
22
- } | null>;
23
- }
24
- /** The structural shape Rollup requires of the plugin. */
25
- interface AttaformRollupPlugin {
26
- name: string;
27
- buildStart(): void;
28
- resolveId(this: RollupResolveContext, source: string, importer: string | undefined): Promise<{
29
- id: string;
30
- } | null> | null;
31
- }
32
- declare function attaform(options?: AttaformRollupPluginOptions): AttaformRollupPlugin;
33
-
34
- export { attaform };
35
- export type { AttaformRollupPlugin, AttaformRollupPluginOptions };