attaform 0.0.1 → 0.14.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 (97) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +142 -2
  3. package/dist/chunks/devtools.cjs +179 -0
  4. package/dist/chunks/devtools.cjs.map +1 -0
  5. package/dist/chunks/devtools.mjs +177 -0
  6. package/dist/chunks/devtools.mjs.map +1 -0
  7. package/dist/chunks/indexeddb.cjs +119 -0
  8. package/dist/chunks/indexeddb.cjs.map +1 -0
  9. package/dist/chunks/indexeddb.mjs +117 -0
  10. package/dist/chunks/indexeddb.mjs.map +1 -0
  11. package/dist/chunks/local-storage.cjs +58 -0
  12. package/dist/chunks/local-storage.cjs.map +1 -0
  13. package/dist/chunks/local-storage.mjs +56 -0
  14. package/dist/chunks/local-storage.mjs.map +1 -0
  15. package/dist/chunks/session-storage.cjs +58 -0
  16. package/dist/chunks/session-storage.cjs.map +1 -0
  17. package/dist/chunks/session-storage.mjs +56 -0
  18. package/dist/chunks/session-storage.mjs.map +1 -0
  19. package/dist/index.cjs +173 -0
  20. package/dist/index.cjs.map +1 -0
  21. package/dist/index.d.cts +493 -0
  22. package/dist/index.d.mts +493 -0
  23. package/dist/index.d.ts +493 -0
  24. package/dist/index.mjs +141 -0
  25. package/dist/index.mjs.map +1 -0
  26. package/dist/nuxt.cjs +97 -0
  27. package/dist/nuxt.cjs.map +1 -0
  28. package/dist/nuxt.d.cts +38 -0
  29. package/dist/nuxt.d.mts +38 -0
  30. package/dist/nuxt.d.ts +38 -0
  31. package/dist/nuxt.mjs +94 -0
  32. package/dist/nuxt.mjs.map +1 -0
  33. package/dist/runtime/plugins/attaform.cjs +32 -0
  34. package/dist/runtime/plugins/attaform.cjs.map +1 -0
  35. package/dist/runtime/plugins/attaform.d.cts +5 -0
  36. package/dist/runtime/plugins/attaform.d.mts +5 -0
  37. package/dist/runtime/plugins/attaform.d.ts +5 -0
  38. package/dist/runtime/plugins/attaform.mjs +30 -0
  39. package/dist/runtime/plugins/attaform.mjs.map +1 -0
  40. package/dist/shared/attaform.B5GWYl76.cjs +386 -0
  41. package/dist/shared/attaform.B5GWYl76.cjs.map +1 -0
  42. package/dist/shared/attaform.BRTxpA3q.mjs +3283 -0
  43. package/dist/shared/attaform.BRTxpA3q.mjs.map +1 -0
  44. package/dist/shared/attaform.BYc9kugA.d.ts +124 -0
  45. package/dist/shared/attaform.Bubm_slq.cjs +622 -0
  46. package/dist/shared/attaform.Bubm_slq.cjs.map +1 -0
  47. package/dist/shared/attaform.BwaYWtMs.d.cts +126 -0
  48. package/dist/shared/attaform.BwaYWtMs.d.mts +126 -0
  49. package/dist/shared/attaform.BwaYWtMs.d.ts +126 -0
  50. package/dist/shared/attaform.CNJO3mME.cjs +3295 -0
  51. package/dist/shared/attaform.CNJO3mME.cjs.map +1 -0
  52. package/dist/shared/attaform.CRgix6_n.cjs +796 -0
  53. package/dist/shared/attaform.CRgix6_n.cjs.map +1 -0
  54. package/dist/shared/attaform.CXZgUECn.d.cts +124 -0
  55. package/dist/shared/attaform.CXpzmj38.mjs +617 -0
  56. package/dist/shared/attaform.CXpzmj38.mjs.map +1 -0
  57. package/dist/shared/attaform.Cc93zNzD.mjs +83 -0
  58. package/dist/shared/attaform.Cc93zNzD.mjs.map +1 -0
  59. package/dist/shared/attaform.DDXrY-1Q.d.cts +2568 -0
  60. package/dist/shared/attaform.DDXrY-1Q.d.mts +2568 -0
  61. package/dist/shared/attaform.DDXrY-1Q.d.ts +2568 -0
  62. package/dist/shared/attaform.DOKOyb3Y.d.mts +124 -0
  63. package/dist/shared/attaform.DlgKK10S.mjs +789 -0
  64. package/dist/shared/attaform.DlgKK10S.mjs.map +1 -0
  65. package/dist/shared/attaform.al_rpt7_.mjs +361 -0
  66. package/dist/shared/attaform.al_rpt7_.mjs.map +1 -0
  67. package/dist/shared/attaform.xKWYHMdq.cjs +89 -0
  68. package/dist/shared/attaform.xKWYHMdq.cjs.map +1 -0
  69. package/dist/transforms.cjs +11 -0
  70. package/dist/transforms.cjs.map +1 -0
  71. package/dist/transforms.d.cts +49 -0
  72. package/dist/transforms.d.mts +49 -0
  73. package/dist/transforms.d.ts +49 -0
  74. package/dist/transforms.mjs +2 -0
  75. package/dist/transforms.mjs.map +1 -0
  76. package/dist/vite.cjs +39 -0
  77. package/dist/vite.cjs.map +1 -0
  78. package/dist/vite.d.cts +53 -0
  79. package/dist/vite.d.mts +53 -0
  80. package/dist/vite.d.ts +53 -0
  81. package/dist/vite.mjs +37 -0
  82. package/dist/vite.mjs.map +1 -0
  83. package/dist/zod-v3.cjs +1511 -0
  84. package/dist/zod-v3.cjs.map +1 -0
  85. package/dist/zod-v3.d.cts +164 -0
  86. package/dist/zod-v3.d.mts +164 -0
  87. package/dist/zod-v3.d.ts +164 -0
  88. package/dist/zod-v3.mjs +1504 -0
  89. package/dist/zod-v3.mjs.map +1 -0
  90. package/dist/zod.cjs +1548 -0
  91. package/dist/zod.cjs.map +1 -0
  92. package/dist/zod.d.cts +67 -0
  93. package/dist/zod.d.mts +67 -0
  94. package/dist/zod.d.ts +67 -0
  95. package/dist/zod.mjs +1541 -0
  96. package/dist/zod.mjs.map +1 -0
  97. package/package.json +182 -6
package/dist/nuxt.cjs ADDED
@@ -0,0 +1,97 @@
1
+ 'use strict';
2
+
3
+ const node_path = require('node:path');
4
+ const node_url = require('node:url');
5
+ const kit = require('@nuxt/kit');
6
+ const vRegisterPreambleTransform = require('./shared/attaform.Bubm_slq.cjs');
7
+
8
+ var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
9
+ function isResolvableForVite(specifier, consumerRootDir) {
10
+ const consumerURL = node_url.pathToFileURL(node_path.join(consumerRootDir, "package.json")).href;
11
+ 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)));
12
+ }
13
+ function canResolve(specifier, fromURL) {
14
+ try {
15
+ undefined(specifier, fromURL);
16
+ return true;
17
+ } catch {
18
+ return false;
19
+ }
20
+ }
21
+ var nuxt_default = kit.defineNuxtModule({
22
+ meta: {
23
+ name: "attaform",
24
+ configKey: "attaform",
25
+ compatibility: {
26
+ nuxt: ">=3.0.0"
27
+ }
28
+ },
29
+ defaults: {},
30
+ setup(_options, nuxt) {
31
+ var _a, _b, _c;
32
+ (_a = nuxt.options.vue.compilerOptions).nodeTransforms ?? (_a.nodeTransforms = []);
33
+ nuxt.options.vue.compilerOptions.nodeTransforms.push(
34
+ vRegisterPreambleTransform.selectNodeTransform,
35
+ vRegisterPreambleTransform.inputTextAreaNodeTransform,
36
+ vRegisterPreambleTransform.vRegisterPreambleTransform,
37
+ vRegisterPreambleTransform.vRegisterHintTransform
38
+ );
39
+ const runtimePublic = nuxt.options.runtimeConfig.public;
40
+ runtimePublic["attaform"] = {
41
+ defaults: _options.defaults ?? {}
42
+ };
43
+ (_b = nuxt.options.vite).optimizeDeps ?? (_b.optimizeDeps = {});
44
+ (_c = nuxt.options.vite.optimizeDeps).include ?? (_c.include = []);
45
+ const include = nuxt.options.vite.optimizeDeps.include;
46
+ for (const spec of ["@vue/devtools-api", "zod"]) {
47
+ if (!isResolvableForVite(spec, nuxt.options.rootDir)) continue;
48
+ if (!include.includes(spec)) include.push(spec);
49
+ }
50
+ 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)));
51
+ kit.addImports([{ name: "useForm", from: "attaform" }]);
52
+ kit.addPlugin({
53
+ src: resolver.resolve("./runtime/plugins/attaform")
54
+ });
55
+ kit.addTypeTemplate({
56
+ filename: "types/v-register.d.ts",
57
+ getContents: () => `// Generated by attaform
58
+ import type { ObjectDirective } from "vue"
59
+ import type { RegisterDirective } from "attaform/types"
60
+
61
+ declare module "vue" {
62
+ interface GlobalDirectives {
63
+ /**
64
+ * The \`v-register\` directive. Binds a form field to a native
65
+ * input, select, textarea, checkbox, or radio:
66
+ *
67
+ * \`\`\`vue
68
+ * <input v-register="form.register('email')" />
69
+ * \`\`\`
70
+ *
71
+ * Also works on custom components whose root is NOT a native
72
+ * input \u2014 call \`useRegister()\` in the child's setup to read
73
+ * the parent's binding, then re-bind \`v-register\` onto an
74
+ * inner native element. (When the wrapper's root IS the input
75
+ * itself, attribute fallthrough handles it; \`useRegister\` is
76
+ * unnecessary.) See \`RegisterDirective\` for the full
77
+ * non-input-root example.
78
+ *
79
+ * Modifier support varies by element:
80
+ * - text / number / textarea: \`.lazy\`, \`.trim\`, \`.number\`
81
+ * - select: \`.number\`
82
+ * - checkbox / radio: none
83
+ *
84
+ * See \`RegisterDirective\` for full usage and per-modifier
85
+ * semantics.
86
+ */
87
+ vRegister: RegisterDirective
88
+ }
89
+ }
90
+
91
+ export { }`
92
+ });
93
+ }
94
+ });
95
+
96
+ module.exports = nuxt_default;
97
+ //# sourceMappingURL=nuxt.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nuxt.cjs","sources":["../src/nuxt.ts"],"sourcesContent":["import { join } from 'node:path'\nimport { pathToFileURL } from 'node:url'\nimport { addImports, addPlugin, addTypeTemplate, createResolver, defineNuxtModule } from '@nuxt/kit'\nimport { inputTextAreaNodeTransform } from './runtime/lib/core/transforms/input-text-area-transform'\nimport { selectNodeTransform } from './runtime/lib/core/transforms/select-transform'\nimport { vRegisterHintTransform } from './runtime/lib/core/transforms/v-register-hint-transform'\nimport { vRegisterPreambleTransform } from './runtime/lib/core/transforms/v-register-preamble-transform'\nimport type { AttaformDefaults } from './runtime/types/types-api'\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\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\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 compatibility: {\n nuxt: '>=3.0.0',\n },\n },\n defaults: {},\n setup(_options, nuxt) {\n // vRegisterPreambleTransform MUST come before vRegisterHintTransform\n // — see src/vite.ts for the ordering rationale.\n nuxt.options.vue.compilerOptions.nodeTransforms ??= []\n nuxt.options.vue.compilerOptions.nodeTransforms.push(\n selectNodeTransform,\n inputTextAreaNodeTransform,\n vRegisterPreambleTransform,\n vRegisterHintTransform\n )\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 } 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 `/zod` and `/zod-v3` adapter peer). 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 `useForm` — the framework-agnostic core composable (same\n // binding as `attaform`'s top-level `useForm` export, which\n // is the abstract form composable). Consumers who want the zod-typed\n // wrapper must import from `attaform/zod` or `/zod-v3`\n // explicitly.\n //\n // We point at the public package entry rather than a relative\n // `./runtime/…` path on purpose: in the published package the\n // `src/runtime/composables/use-abstract-form` path has no matching\n // `dist/runtime/…` file (build.config's entries don't include it),\n // so a `resolver.resolve(...)` would raise ENOENT at Nuxt's auto-\n // import step. Importing from `attaform` resolves through\n // the shared chunk, identical to what `attaform/zod`\n // consumers bundle — single registry instance across both import\n // surfaces.\n addImports([{ name: 'useForm', from: 'attaform' }])\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 // v-register directive type. The directive itself is globally\n // registered by `createAttaform().install(app)` in the plugin\n // above; this template only publishes the type so that\n // `<input v-register=\"…\">` type-checks in consumer SFCs.\n addTypeTemplate({\n filename: 'types/v-register.d.ts',\n getContents: () => `// Generated by attaform\nimport type { ObjectDirective } from \"vue\"\nimport type { RegisterDirective } from \"attaform/types\"\n\ndeclare module \"vue\" {\n interface GlobalDirectives {\n /**\n * The \\`v-register\\` directive. Binds a form field to a native\n * input, select, textarea, checkbox, or radio:\n *\n * \\`\\`\\`vue\n * <input v-register=\"form.register('email')\" />\n * \\`\\`\\`\n *\n * Also works on custom components whose root is NOT a native\n * input — call \\`useRegister()\\` in the child's setup to read\n * the parent's binding, then re-bind \\`v-register\\` onto an\n * inner native element. (When the wrapper's root IS the input\n * itself, attribute fallthrough handles it; \\`useRegister\\` is\n * unnecessary.) See \\`RegisterDirective\\` for the full\n * non-input-root example.\n *\n * Modifier support varies by element:\n * - text / number / textarea: \\`.lazy\\`, \\`.trim\\`, \\`.number\\`\n * - select: \\`.number\\`\n * - checkbox / radio: none\n *\n * See \\`RegisterDirective\\` for full usage and per-modifier\n * semantics.\n */\n vRegister: RegisterDirective\n }\n}\n\nexport { }`,\n })\n },\n})\n"],"names":["pathToFileURL","join","defineNuxtModule","selectNodeTransform","inputTextAreaNodeTransform","vRegisterPreambleTransform","vRegisterHintTransform","createResolver","addImports","addPlugin","addTypeTemplate"],"mappings":";;;;;;;;AAkEA,SAAS,mBAAA,CAAoB,WAAmB,eAAA,EAAkC;AAChF,EAAA,MAAM,cAAcA,sBAAA,CAAcC,cAAA,CAAK,eAAA,EAAiB,cAAc,CAAC,CAAA,CAAE,IAAA;AACzE,EAAA,OAAO,WAAW,SAAA,EAAW,WAAW,KAAK,UAAA,CAAW,SAAA,EAAW,0PAAe,CAAA;AACpF;AAEA,SAAS,UAAA,CAAW,WAAmB,OAAA,EAA0B;AAC/D,EAAA,IAAI;AACF,IAAA,SAAY,CAAQ,WAAW,OAAO,CAAA;AACtC,IAAA,OAAO,IAAA;AAAA,EACT,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,KAAA;AAAA,EACT;AACF;AAEA,IAAO,eAAQC,oBAAA,CAAwC;AA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AC,OAAA,CAAQ,QAAA,CAAS,IAAI,CAAA,EAAG,OAAA,CAAQ,KAAK,IAAI,CAAA;AAAA,IAChD;AAEA,IAAA,MAAM,QAAA,GAAWC,kBAAA,CAAe,0PAAe,CAAA;AAiB/C,IAAAC,cAAA,CAAW,CAAC,EAAE,IAAA,EAAM,WAAW,IAAA,EAAM,UAAA,EAAY,CAAC,CAAA;AAsBlD,IAAAC,aAAA,CAAU;AAAA,MACR,GAAA,EAAK,QAAA,CAAS,OAAA,CAAQ,4BAA4B;AAAA,KACnD,CAAA;AAMD,IAAAC,mBAAA,CAAgB;AAAA,MACd,QAAA,EAAU,uBAAA;AAAA,MACV,aAAa,MAAM,CAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA,UAAA;AAAA,KAmCpB,CAAA;AAAA,EACH;AACF,CAAC;;;;"}
@@ -0,0 +1,38 @@
1
+ import * as _nuxt_schema from '@nuxt/schema';
2
+ import { A as AttaformDefaults } from './shared/attaform.DDXrY-1Q.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
+ /**
28
+ * Shape of the Nuxt public runtime-config slot the module populates.
29
+ * Reach it via `useRuntimeConfig().public.attaform` if you need to
30
+ * read the configured defaults outside the form library itself.
31
+ */
32
+ type AttaformRuntimeConfig = {
33
+ defaults: AttaformDefaults;
34
+ };
35
+ declare const _default: _nuxt_schema.NuxtModule<AttaformModuleOptions, AttaformModuleOptions, false>;
36
+
37
+ export = _default;
38
+ export type { AttaformModuleOptions, AttaformRuntimeConfig };
@@ -0,0 +1,38 @@
1
+ import * as _nuxt_schema from '@nuxt/schema';
2
+ import { A as AttaformDefaults } from './shared/attaform.DDXrY-1Q.mjs';
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
+ /**
28
+ * Shape of the Nuxt public runtime-config slot the module populates.
29
+ * Reach it via `useRuntimeConfig().public.attaform` if you need to
30
+ * read the configured defaults outside the form library itself.
31
+ */
32
+ type AttaformRuntimeConfig = {
33
+ defaults: AttaformDefaults;
34
+ };
35
+ declare const _default: _nuxt_schema.NuxtModule<AttaformModuleOptions, AttaformModuleOptions, false>;
36
+
37
+ export { _default as default };
38
+ export type { AttaformModuleOptions, AttaformRuntimeConfig };
package/dist/nuxt.d.ts ADDED
@@ -0,0 +1,38 @@
1
+ import * as _nuxt_schema from '@nuxt/schema';
2
+ import { A as AttaformDefaults } from './shared/attaform.DDXrY-1Q.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
+ /**
28
+ * Shape of the Nuxt public runtime-config slot the module populates.
29
+ * Reach it via `useRuntimeConfig().public.attaform` if you need to
30
+ * read the configured defaults outside the form library itself.
31
+ */
32
+ type AttaformRuntimeConfig = {
33
+ defaults: AttaformDefaults;
34
+ };
35
+ declare const _default: _nuxt_schema.NuxtModule<AttaformModuleOptions, AttaformModuleOptions, false>;
36
+
37
+ export = _default;
38
+ export type { AttaformModuleOptions, AttaformRuntimeConfig };
package/dist/nuxt.mjs ADDED
@@ -0,0 +1,94 @@
1
+ import { join } from 'node:path';
2
+ import { pathToFileURL } from 'node:url';
3
+ import { defineNuxtModule, createResolver, addImports, addPlugin, addTypeTemplate } from '@nuxt/kit';
4
+ import { s as selectNodeTransform, i as inputTextAreaNodeTransform, a as vRegisterPreambleTransform, v as vRegisterHintTransform } from './shared/attaform.CXpzmj38.mjs';
5
+
6
+ function isResolvableForVite(specifier, consumerRootDir) {
7
+ const consumerURL = pathToFileURL(join(consumerRootDir, "package.json")).href;
8
+ return canResolve(specifier, consumerURL) || canResolve(specifier, import.meta.url);
9
+ }
10
+ function canResolve(specifier, fromURL) {
11
+ try {
12
+ import.meta.resolve(specifier, fromURL);
13
+ return true;
14
+ } catch {
15
+ return false;
16
+ }
17
+ }
18
+ var nuxt_default = defineNuxtModule({
19
+ meta: {
20
+ name: "attaform",
21
+ configKey: "attaform",
22
+ compatibility: {
23
+ nuxt: ">=3.0.0"
24
+ }
25
+ },
26
+ defaults: {},
27
+ setup(_options, nuxt) {
28
+ var _a, _b, _c;
29
+ (_a = nuxt.options.vue.compilerOptions).nodeTransforms ?? (_a.nodeTransforms = []);
30
+ nuxt.options.vue.compilerOptions.nodeTransforms.push(
31
+ selectNodeTransform,
32
+ inputTextAreaNodeTransform,
33
+ vRegisterPreambleTransform,
34
+ vRegisterHintTransform
35
+ );
36
+ const runtimePublic = nuxt.options.runtimeConfig.public;
37
+ runtimePublic["attaform"] = {
38
+ defaults: _options.defaults ?? {}
39
+ };
40
+ (_b = nuxt.options.vite).optimizeDeps ?? (_b.optimizeDeps = {});
41
+ (_c = nuxt.options.vite.optimizeDeps).include ?? (_c.include = []);
42
+ const include = nuxt.options.vite.optimizeDeps.include;
43
+ for (const spec of ["@vue/devtools-api", "zod"]) {
44
+ if (!isResolvableForVite(spec, nuxt.options.rootDir)) continue;
45
+ if (!include.includes(spec)) include.push(spec);
46
+ }
47
+ const resolver = createResolver(import.meta.url);
48
+ addImports([{ name: "useForm", from: "attaform" }]);
49
+ addPlugin({
50
+ src: resolver.resolve("./runtime/plugins/attaform")
51
+ });
52
+ addTypeTemplate({
53
+ filename: "types/v-register.d.ts",
54
+ getContents: () => `// Generated by attaform
55
+ import type { ObjectDirective } from "vue"
56
+ import type { RegisterDirective } from "attaform/types"
57
+
58
+ declare module "vue" {
59
+ interface GlobalDirectives {
60
+ /**
61
+ * The \`v-register\` directive. Binds a form field to a native
62
+ * input, select, textarea, checkbox, or radio:
63
+ *
64
+ * \`\`\`vue
65
+ * <input v-register="form.register('email')" />
66
+ * \`\`\`
67
+ *
68
+ * Also works on custom components whose root is NOT a native
69
+ * input \u2014 call \`useRegister()\` in the child's setup to read
70
+ * the parent's binding, then re-bind \`v-register\` onto an
71
+ * inner native element. (When the wrapper's root IS the input
72
+ * itself, attribute fallthrough handles it; \`useRegister\` is
73
+ * unnecessary.) See \`RegisterDirective\` for the full
74
+ * non-input-root example.
75
+ *
76
+ * Modifier support varies by element:
77
+ * - text / number / textarea: \`.lazy\`, \`.trim\`, \`.number\`
78
+ * - select: \`.number\`
79
+ * - checkbox / radio: none
80
+ *
81
+ * See \`RegisterDirective\` for full usage and per-modifier
82
+ * semantics.
83
+ */
84
+ vRegister: RegisterDirective
85
+ }
86
+ }
87
+
88
+ export { }`
89
+ });
90
+ }
91
+ });
92
+
93
+ export { nuxt_default as default };
94
+ //# sourceMappingURL=nuxt.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nuxt.mjs","sources":["../src/nuxt.ts"],"sourcesContent":["import { join } from 'node:path'\nimport { pathToFileURL } from 'node:url'\nimport { addImports, addPlugin, addTypeTemplate, createResolver, defineNuxtModule } from '@nuxt/kit'\nimport { inputTextAreaNodeTransform } from './runtime/lib/core/transforms/input-text-area-transform'\nimport { selectNodeTransform } from './runtime/lib/core/transforms/select-transform'\nimport { vRegisterHintTransform } from './runtime/lib/core/transforms/v-register-hint-transform'\nimport { vRegisterPreambleTransform } from './runtime/lib/core/transforms/v-register-preamble-transform'\nimport type { AttaformDefaults } from './runtime/types/types-api'\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\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\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 compatibility: {\n nuxt: '>=3.0.0',\n },\n },\n defaults: {},\n setup(_options, nuxt) {\n // vRegisterPreambleTransform MUST come before vRegisterHintTransform\n // — see src/vite.ts for the ordering rationale.\n nuxt.options.vue.compilerOptions.nodeTransforms ??= []\n nuxt.options.vue.compilerOptions.nodeTransforms.push(\n selectNodeTransform,\n inputTextAreaNodeTransform,\n vRegisterPreambleTransform,\n vRegisterHintTransform\n )\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 } 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 `/zod` and `/zod-v3` adapter peer). 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 `useForm` — the framework-agnostic core composable (same\n // binding as `attaform`'s top-level `useForm` export, which\n // is the abstract form composable). Consumers who want the zod-typed\n // wrapper must import from `attaform/zod` or `/zod-v3`\n // explicitly.\n //\n // We point at the public package entry rather than a relative\n // `./runtime/…` path on purpose: in the published package the\n // `src/runtime/composables/use-abstract-form` path has no matching\n // `dist/runtime/…` file (build.config's entries don't include it),\n // so a `resolver.resolve(...)` would raise ENOENT at Nuxt's auto-\n // import step. Importing from `attaform` resolves through\n // the shared chunk, identical to what `attaform/zod`\n // consumers bundle — single registry instance across both import\n // surfaces.\n addImports([{ name: 'useForm', from: 'attaform' }])\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 // v-register directive type. The directive itself is globally\n // registered by `createAttaform().install(app)` in the plugin\n // above; this template only publishes the type so that\n // `<input v-register=\"…\">` type-checks in consumer SFCs.\n addTypeTemplate({\n filename: 'types/v-register.d.ts',\n getContents: () => `// Generated by attaform\nimport type { ObjectDirective } from \"vue\"\nimport type { RegisterDirective } from \"attaform/types\"\n\ndeclare module \"vue\" {\n interface GlobalDirectives {\n /**\n * The \\`v-register\\` directive. Binds a form field to a native\n * input, select, textarea, checkbox, or radio:\n *\n * \\`\\`\\`vue\n * <input v-register=\"form.register('email')\" />\n * \\`\\`\\`\n *\n * Also works on custom components whose root is NOT a native\n * input — call \\`useRegister()\\` in the child's setup to read\n * the parent's binding, then re-bind \\`v-register\\` onto an\n * inner native element. (When the wrapper's root IS the input\n * itself, attribute fallthrough handles it; \\`useRegister\\` is\n * unnecessary.) See \\`RegisterDirective\\` for the full\n * non-input-root example.\n *\n * Modifier support varies by element:\n * - text / number / textarea: \\`.lazy\\`, \\`.trim\\`, \\`.number\\`\n * - select: \\`.number\\`\n * - checkbox / radio: none\n *\n * See \\`RegisterDirective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A;AAAA,KAmCpB,CAAA;AAAA,EACH;AACF,CAAC;;;;"}
@@ -0,0 +1,32 @@
1
+ 'use strict';
2
+
3
+ const app = require('nuxt/app');
4
+ const serialize = require('../../shared/attaform.CRgix6_n.cjs');
5
+
6
+ var attaform_default = app.defineNuxtPlugin({
7
+ // `enforce: 'pre'` makes the "we run before any component's setup" claim
8
+ // explicit. Combined with `prepend: true` on the addPlugin call in
9
+ // src/nuxt.ts, this guarantees hydration is staged into pendingHydration
10
+ // before any user plugin or page can call `useForm`. Without it, a user
11
+ // plugin running first would observe an empty registry and skip hydration.
12
+ enforce: "pre",
13
+ setup(nuxtApp) {
14
+ const isServer = undefined;
15
+ const { defaults } = app.useRuntimeConfig().public.attaform;
16
+ nuxtApp.vueApp.use(serialize.createAttaform({ override: isServer, defaults }));
17
+ if (isServer) {
18
+ nuxtApp.hook("app:rendered", () => {
19
+ const state = serialize.renderAttaformState(nuxtApp.vueApp);
20
+ nuxtApp.payload.attaform = state;
21
+ });
22
+ } else {
23
+ const serialized = nuxtApp.payload.attaform;
24
+ if (serialized !== void 0) {
25
+ serialize.hydrateAttaformState(nuxtApp.vueApp, serialized);
26
+ }
27
+ }
28
+ }
29
+ });
30
+
31
+ module.exports = attaform_default;
32
+ //# sourceMappingURL=attaform.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attaform.cjs","sources":["../../../src/runtime/plugins/attaform.ts"],"sourcesContent":["/**\n * Nuxt plugin: installs the framework-agnostic createAttaform Vue\n * plugin on nuxtApp.vueApp and wires the Nuxt payload mechanism to the\n * registry's SSR serialization helpers. Replaces the old split of\n * register.ts (client-only) + register-stub.ts (server-only).\n *\n * Runs on BOTH server and client — Vue's SSR renderer is a natural no-op\n * for directive lifecycle hooks, so the same plugin works on both sides\n * without a stub.\n */\nimport { defineNuxtPlugin, useRuntimeConfig } from 'nuxt/app'\nimport { createAttaform } from '../core/plugin'\nimport { hydrateAttaformState, renderAttaformState } from '../core/serialize'\nimport type { SerializedAttaformState } from '../core/serialize'\nimport type { AttaformDefaults } from '../types/types-api'\n\nexport default defineNuxtPlugin({\n // `enforce: 'pre'` makes the \"we run before any component's setup\" claim\n // explicit. Combined with `prepend: true` on the addPlugin call in\n // src/nuxt.ts, this guarantees hydration is staged into pendingHydration\n // before any user plugin or page can call `useForm`. Without it, a user\n // plugin running first would observe an empty registry and skip hydration.\n enforce: 'pre',\n setup(nuxtApp) {\n const isServer = import.meta.server\n\n // Read app-level defaults from the Nuxt module's runtime-config slot\n // (populated in src/nuxt.ts). The module ships in the same package\n // as this plugin, so the slot is always present and well-typed.\n const { defaults } = (useRuntimeConfig().public as { attaform: { defaults: AttaformDefaults } })\n .attaform\n\n nuxtApp.vueApp.use(createAttaform({ override: isServer, defaults }))\n\n if (isServer) {\n // After the app renders, capture every FormStore into the Nuxt payload\n // so the client can hydrate with matching form values and errors.\n nuxtApp.hook('app:rendered', () => {\n const state = renderAttaformState(nuxtApp.vueApp)\n ;(nuxtApp.payload as unknown as { attaform?: SerializedAttaformState }).attaform = state\n })\n } else {\n // Stage the payload into pendingHydration so `useForm` finds it. The\n // `enforce: 'pre'` + `prepend: true` pair above is what makes it safe\n // to assume this runs before any user setup.\n const serialized = (nuxtApp.payload as unknown as { attaform?: SerializedAttaformState })\n .attaform\n if (serialized !== undefined) {\n hydrateAttaformState(nuxtApp.vueApp, serialized)\n }\n }\n },\n})\n"],"names":["defineNuxtPlugin","useRuntimeConfig","createAttaform","renderAttaformState","hydrateAttaformState"],"mappings":";;;;;AAgBA,IAAO,mBAAQA,oBAAA,CAAiB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAM9B,OAAA,EAAS,KAAA;AAAA,EACT,MAAM,OAAA,EAAS;AACb,IAAA,MAAM,WAAW,SAAY;AAK7B,IAAA,MAAM,EAAE,QAAA,EAAS,GAAKC,oBAAA,GAAmB,MAAA,CACtC,QAAA;AAEH,IAAA,OAAA,CAAQ,MAAA,CAAO,IAAIC,wBAAA,CAAe,EAAE,UAAU,QAAA,EAAU,QAAA,EAAU,CAAC,CAAA;AAEnE,IAAA,IAAI,QAAA,EAAU;AAGZ,MAAA,OAAA,CAAQ,IAAA,CAAK,gBAAgB,MAAM;AACjC,QAAA,MAAM,KAAA,GAAQC,6BAAA,CAAoB,OAAA,CAAQ,MAAM,CAAA;AAC/C,QAAC,OAAA,CAAQ,QAA8D,QAAA,GAAW,KAAA;AAAA,MACrF,CAAC,CAAA;AAAA,IACH,CAAA,MAAO;AAIL,MAAA,MAAM,UAAA,GAAc,QAAQ,OAAA,CACzB,QAAA;AACH,MAAA,IAAI,eAAe,MAAA,EAAW;AAC5B,QAAAC,8BAAA,CAAqB,OAAA,CAAQ,QAAQ,UAAU,CAAA;AAAA,MACjD;AAAA,IACF;AAAA,EACF;AACF,CAAC;;;;"}
@@ -0,0 +1,5 @@
1
+ import * as nuxt_app from 'nuxt/app';
2
+
3
+ declare const _default: nuxt_app.Plugin<Record<string, unknown>> & nuxt_app.ObjectPlugin<Record<string, unknown>>;
4
+
5
+ export = _default;
@@ -0,0 +1,5 @@
1
+ import * as nuxt_app from 'nuxt/app';
2
+
3
+ declare const _default: nuxt_app.Plugin<Record<string, unknown>> & nuxt_app.ObjectPlugin<Record<string, unknown>>;
4
+
5
+ export { _default as default };
@@ -0,0 +1,5 @@
1
+ import * as nuxt_app from 'nuxt/app';
2
+
3
+ declare const _default: nuxt_app.Plugin<Record<string, unknown>> & nuxt_app.ObjectPlugin<Record<string, unknown>>;
4
+
5
+ export = _default;
@@ -0,0 +1,30 @@
1
+ import { defineNuxtPlugin, useRuntimeConfig } from 'nuxt/app';
2
+ import { c as createAttaform, r as renderAttaformState, h as hydrateAttaformState } from '../../shared/attaform.DlgKK10S.mjs';
3
+
4
+ var attaform_default = defineNuxtPlugin({
5
+ // `enforce: 'pre'` makes the "we run before any component's setup" claim
6
+ // explicit. Combined with `prepend: true` on the addPlugin call in
7
+ // src/nuxt.ts, this guarantees hydration is staged into pendingHydration
8
+ // before any user plugin or page can call `useForm`. Without it, a user
9
+ // plugin running first would observe an empty registry and skip hydration.
10
+ enforce: "pre",
11
+ setup(nuxtApp) {
12
+ const isServer = import.meta.server;
13
+ const { defaults } = useRuntimeConfig().public.attaform;
14
+ nuxtApp.vueApp.use(createAttaform({ override: isServer, defaults }));
15
+ if (isServer) {
16
+ nuxtApp.hook("app:rendered", () => {
17
+ const state = renderAttaformState(nuxtApp.vueApp);
18
+ nuxtApp.payload.attaform = state;
19
+ });
20
+ } else {
21
+ const serialized = nuxtApp.payload.attaform;
22
+ if (serialized !== void 0) {
23
+ hydrateAttaformState(nuxtApp.vueApp, serialized);
24
+ }
25
+ }
26
+ }
27
+ });
28
+
29
+ export { attaform_default as default };
30
+ //# sourceMappingURL=attaform.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attaform.mjs","sources":["../../../src/runtime/plugins/attaform.ts"],"sourcesContent":["/**\n * Nuxt plugin: installs the framework-agnostic createAttaform Vue\n * plugin on nuxtApp.vueApp and wires the Nuxt payload mechanism to the\n * registry's SSR serialization helpers. Replaces the old split of\n * register.ts (client-only) + register-stub.ts (server-only).\n *\n * Runs on BOTH server and client — Vue's SSR renderer is a natural no-op\n * for directive lifecycle hooks, so the same plugin works on both sides\n * without a stub.\n */\nimport { defineNuxtPlugin, useRuntimeConfig } from 'nuxt/app'\nimport { createAttaform } from '../core/plugin'\nimport { hydrateAttaformState, renderAttaformState } from '../core/serialize'\nimport type { SerializedAttaformState } from '../core/serialize'\nimport type { AttaformDefaults } from '../types/types-api'\n\nexport default defineNuxtPlugin({\n // `enforce: 'pre'` makes the \"we run before any component's setup\" claim\n // explicit. Combined with `prepend: true` on the addPlugin call in\n // src/nuxt.ts, this guarantees hydration is staged into pendingHydration\n // before any user plugin or page can call `useForm`. Without it, a user\n // plugin running first would observe an empty registry and skip hydration.\n enforce: 'pre',\n setup(nuxtApp) {\n const isServer = import.meta.server\n\n // Read app-level defaults from the Nuxt module's runtime-config slot\n // (populated in src/nuxt.ts). The module ships in the same package\n // as this plugin, so the slot is always present and well-typed.\n const { defaults } = (useRuntimeConfig().public as { attaform: { defaults: AttaformDefaults } })\n .attaform\n\n nuxtApp.vueApp.use(createAttaform({ override: isServer, defaults }))\n\n if (isServer) {\n // After the app renders, capture every FormStore into the Nuxt payload\n // so the client can hydrate with matching form values and errors.\n nuxtApp.hook('app:rendered', () => {\n const state = renderAttaformState(nuxtApp.vueApp)\n ;(nuxtApp.payload as unknown as { attaform?: SerializedAttaformState }).attaform = state\n })\n } else {\n // Stage the payload into pendingHydration so `useForm` finds it. The\n // `enforce: 'pre'` + `prepend: true` pair above is what makes it safe\n // to assume this runs before any user setup.\n const serialized = (nuxtApp.payload as unknown as { attaform?: SerializedAttaformState })\n .attaform\n if (serialized !== undefined) {\n hydrateAttaformState(nuxtApp.vueApp, serialized)\n }\n }\n },\n})\n"],"names":[],"mappings":";;;AAgBA,IAAO,mBAAQ,gBAAA,CAAiB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAM9B,OAAA,EAAS,KAAA;AAAA,EACT,MAAM,OAAA,EAAS;AACb,IAAA,MAAM,WAAW,MAAA,CAAA,IAAA,CAAY,MAAA;AAK7B,IAAA,MAAM,EAAE,QAAA,EAAS,GAAK,gBAAA,GAAmB,MAAA,CACtC,QAAA;AAEH,IAAA,OAAA,CAAQ,MAAA,CAAO,IAAI,cAAA,CAAe,EAAE,UAAU,QAAA,EAAU,QAAA,EAAU,CAAC,CAAA;AAEnE,IAAA,IAAI,QAAA,EAAU;AAGZ,MAAA,OAAA,CAAQ,IAAA,CAAK,gBAAgB,MAAM;AACjC,QAAA,MAAM,KAAA,GAAQ,mBAAA,CAAoB,OAAA,CAAQ,MAAM,CAAA;AAC/C,QAAC,OAAA,CAAQ,QAA8D,QAAA,GAAW,KAAA;AAAA,MACrF,CAAC,CAAA;AAAA,IACH,CAAA,MAAO;AAIL,MAAA,MAAM,UAAA,GAAc,QAAQ,OAAA,CACzB,QAAA;AACH,MAAA,IAAI,eAAe,MAAA,EAAW;AAC5B,QAAA,oBAAA,CAAqB,OAAA,CAAQ,QAAQ,UAAU,CAAA;AAAA,MACjD;AAAA,IACF;AAAA,EACF;AACF,CAAC;;;;"}