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/vite.d.ts ADDED
@@ -0,0 +1,53 @@
1
+ import { Plugin } from 'vite';
2
+
3
+ /**
4
+ * `attaform/vite` — Vite plugin that registers the compile-time
5
+ * node transforms with @vitejs/plugin-vue.
6
+ *
7
+ * Usage (bare Vue 3 consumers):
8
+ *
9
+ * // vite.config.ts
10
+ * import vue from '@vitejs/plugin-vue'
11
+ * import { attaform } from 'attaform/vite'
12
+ *
13
+ * export default defineConfig({
14
+ * plugins: [vue(), attaform()],
15
+ * })
16
+ *
17
+ * The transforms inject `:value`, `:checked`, and `:selected` bindings into
18
+ * elements that use the `v-register` directive — load-bearing for SSR
19
+ * initial-render correctness. Omitting this plugin under CSR is tolerable
20
+ * (one-frame flash on mount); omitting it under SSR produces visibly wrong
21
+ * initial HTML.
22
+ *
23
+ * Implementation note: this plugin mutates @vitejs/plugin-vue's options via
24
+ * the documented but somewhat informal `api.options` surface used by
25
+ * VueUse, Vite PWA, and other Vue ecosystem plugins. If you're using a
26
+ * custom Vue plugin wrapper, fall back to `attaform/transforms`
27
+ * and wire them yourself.
28
+ */
29
+
30
+ /** Options for `attaform()`. Reserved for future use; pass `{}` or omit. */
31
+ type AttaformVitePluginOptions = Record<string, never>;
32
+ /**
33
+ * Vite plugin that wires the form library's compile-time template
34
+ * transforms into `@vitejs/plugin-vue`. Required for SSR and for
35
+ * hydration accuracy under bare Vue 3.
36
+ *
37
+ * ```ts
38
+ * // vite.config.ts
39
+ * import vue from '@vitejs/plugin-vue'
40
+ * import { attaform } from 'attaform/vite'
41
+ *
42
+ * export default defineConfig({
43
+ * plugins: [vue(), attaform()],
44
+ * })
45
+ * ```
46
+ *
47
+ * Place the call after `vue()` in the plugins array. Nuxt projects
48
+ * don't need this — `attaform/nuxt` handles it.
49
+ */
50
+ declare function attaform(_options?: AttaformVitePluginOptions): Plugin;
51
+
52
+ export { attaform };
53
+ export type { AttaformVitePluginOptions };
package/dist/vite.mjs ADDED
@@ -0,0 +1,37 @@
1
+ import { a as vRegisterPreambleTransform, s as selectNodeTransform, i as inputTextAreaNodeTransform, v as vRegisterHintTransform } from './shared/attaform.CXpzmj38.mjs';
2
+
3
+ function attaform(_options = {}) {
4
+ return {
5
+ name: "attaform",
6
+ enforce: "pre",
7
+ configResolved(resolved) {
8
+ var _a, _b;
9
+ const vuePlugin = resolved.plugins.find((p) => p.name === "vite:vue");
10
+ if (vuePlugin === void 0) {
11
+ throw new Error(
12
+ "[attaform/vite] @vitejs/plugin-vue is not installed (or not registered before attaform()). Install @vitejs/plugin-vue and place `attaform()` after `vue()` in your plugins array."
13
+ );
14
+ }
15
+ const api = vuePlugin.api;
16
+ if (api?.options === void 0) {
17
+ throw new Error(
18
+ "[attaform/vite] Found @vitejs/plugin-vue but it does not expose `api.options`. This usually means a version-incompatible @vitejs/plugin-vue (or a wrapper plugin re-exporting it). Pin @vitejs/plugin-vue to a version compatible with the documented `api.options.template.compilerOptions.nodeTransforms` surface."
19
+ );
20
+ }
21
+ (_a = api.options).template ?? (_a.template = {});
22
+ (_b = api.options.template).compilerOptions ?? (_b.compilerOptions = {});
23
+ const existing = api.options.template.compilerOptions.nodeTransforms ?? [];
24
+ if (existing.includes(vRegisterPreambleTransform)) return;
25
+ api.options.template.compilerOptions.nodeTransforms = [
26
+ ...existing,
27
+ selectNodeTransform,
28
+ inputTextAreaNodeTransform,
29
+ vRegisterPreambleTransform,
30
+ vRegisterHintTransform
31
+ ];
32
+ }
33
+ };
34
+ }
35
+
36
+ export { attaform };
37
+ //# sourceMappingURL=vite.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vite.mjs","sources":["../src/vite.ts"],"sourcesContent":["/**\n * `attaform/vite` — Vite plugin that registers the compile-time\n * node transforms with @vitejs/plugin-vue.\n *\n * Usage (bare Vue 3 consumers):\n *\n * // vite.config.ts\n * import vue from '@vitejs/plugin-vue'\n * import { attaform } from 'attaform/vite'\n *\n * export default defineConfig({\n * plugins: [vue(), attaform()],\n * })\n *\n * The transforms inject `:value`, `:checked`, and `:selected` bindings into\n * elements that use the `v-register` directive — load-bearing for SSR\n * initial-render correctness. Omitting this plugin under CSR is tolerable\n * (one-frame flash on mount); omitting it under SSR produces visibly wrong\n * initial HTML.\n *\n * Implementation note: this plugin mutates @vitejs/plugin-vue's options via\n * the documented but somewhat informal `api.options` surface used by\n * VueUse, Vite PWA, and other Vue ecosystem plugins. If you're using a\n * custom Vue plugin wrapper, fall back to `attaform/transforms`\n * and wire them yourself.\n */\nimport type { Plugin } from 'vite'\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'\n\n/** Options for `attaform()`. Reserved for future use; pass `{}` or omit. */\nexport type AttaformVitePluginOptions = Record<string, never>\n\ninterface VitePluginVueApi {\n options?: {\n template?: {\n compilerOptions?: {\n nodeTransforms?: unknown[]\n }\n }\n }\n}\n\n/**\n * Vite plugin that wires the form library's compile-time template\n * transforms into `@vitejs/plugin-vue`. Required for SSR and for\n * hydration accuracy under bare Vue 3.\n *\n * ```ts\n * // vite.config.ts\n * import vue from '@vitejs/plugin-vue'\n * import { attaform } from 'attaform/vite'\n *\n * export default defineConfig({\n * plugins: [vue(), attaform()],\n * })\n * ```\n *\n * Place the call after `vue()` in the plugins array. Nuxt projects\n * don't need this — `attaform/nuxt` handles it.\n */\nexport function attaform(_options: AttaformVitePluginOptions = {}): Plugin {\n // Unused-var suppression until options exist.\n void _options\n return {\n name: 'attaform',\n enforce: 'pre',\n configResolved(resolved) {\n const vuePlugin = resolved.plugins.find((p) => p.name === 'vite:vue')\n // Two distinct failure modes — separate error messages so the\n // consumer's fix is unambiguous:\n // 1. plugin not in the plugins array → install + register vue()\n // 2. plugin found but version-incompatible (no `api.options`) →\n // version mismatch with @vitejs/plugin-vue\n if (vuePlugin === undefined) {\n throw new Error(\n '[attaform/vite] @vitejs/plugin-vue is not installed (or not registered before attaform()). ' +\n 'Install @vitejs/plugin-vue and place `attaform()` after `vue()` in your plugins array.'\n )\n }\n const api = (vuePlugin as unknown as { api?: VitePluginVueApi }).api\n if (api?.options === undefined) {\n throw new Error(\n '[attaform/vite] Found @vitejs/plugin-vue but it does not expose `api.options`. ' +\n 'This usually means a version-incompatible @vitejs/plugin-vue (or a wrapper plugin re-exporting it). ' +\n 'Pin @vitejs/plugin-vue to a version compatible with the documented `api.options.template.compilerOptions.nodeTransforms` surface.'\n )\n }\n api.options.template ??= {}\n api.options.template.compilerOptions ??= {}\n const existing = api.options.template.compilerOptions.nodeTransforms ?? []\n // Idempotent install: if a previous attaform() invocation\n // (vite + nuxt module + manual `plugins: [attaform()]`) has\n // already pushed our transforms, skip — re-pushing would double\n // every binding the AST emits, breaking the IIFE-wrapping\n // invariants downstream transforms depend on. We detect the\n // sentinel via reference equality; user-supplied transforms with\n // the same name don't collide.\n if (existing.includes(vRegisterPreambleTransform as unknown)) return\n // vRegisterPreambleTransform MUST come before vRegisterHintTransform\n // — the preamble's pre-order captures each `v-register` expression\n // in its raw (un-wrapped) form, and the hint then mutates the same\n // directive's `exp` to wrap it. Reversing the order would have the\n // preamble pick up an already-wrapped IIFE, double-wrapping it\n // when injected at the root.\n api.options.template.compilerOptions.nodeTransforms = [\n ...existing,\n selectNodeTransform,\n inputTextAreaNodeTransform,\n vRegisterPreambleTransform,\n vRegisterHintTransform,\n ]\n },\n }\n}\n"],"names":[],"mappings":";;AA+DO,SAAS,QAAA,CAAS,QAAA,GAAsC,EAAC,EAAW;AAGzE,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,UAAA;AAAA,IACN,OAAA,EAAS,KAAA;AAAA,IACT,eAAe,QAAA,EAAU;AArE7B,MAAA,IAAA,EAAA,EAAA,EAAA;AAsEM,MAAA,MAAM,SAAA,GAAY,SAAS,OAAA,CAAQ,IAAA,CAAK,CAAC,CAAA,KAAM,CAAA,CAAE,SAAS,UAAU,CAAA;AAMpE,MAAA,IAAI,cAAc,MAAA,EAAW;AAC3B,QAAA,MAAM,IAAI,KAAA;AAAA,UACR;AAAA,SAEF;AAAA,MACF;AACA,MAAA,MAAM,MAAO,SAAA,CAAoD,GAAA;AACjE,MAAA,IAAI,GAAA,EAAK,YAAY,MAAA,EAAW;AAC9B,QAAA,MAAM,IAAI,KAAA;AAAA,UACR;AAAA,SAGF;AAAA,MACF;AACA,MAAA,CAAA,EAAA,GAAA,GAAA,CAAI,OAAA,EAAQ,QAAA,KAAZ,EAAA,CAAY,QAAA,GAAa,EAAC,CAAA;AAC1B,MAAA,CAAA,EAAA,GAAA,GAAA,CAAI,OAAA,CAAQ,QAAA,EAAS,eAAA,KAArB,EAAA,CAAqB,kBAAoB,EAAC,CAAA;AAC1C,MAAA,MAAM,WAAW,GAAA,CAAI,OAAA,CAAQ,QAAA,CAAS,eAAA,CAAgB,kBAAkB,EAAC;AAQzE,MAAA,IAAI,QAAA,CAAS,QAAA,CAAS,0BAAqC,CAAA,EAAG;AAO9D,MAAA,GAAA,CAAI,OAAA,CAAQ,QAAA,CAAS,eAAA,CAAgB,cAAA,GAAiB;AAAA,QACpD,GAAG,QAAA;AAAA,QACH,mBAAA;AAAA,QACA,0BAAA;AAAA,QACA,0BAAA;AAAA,QACA;AAAA,OACF;AAAA,IACF;AAAA,GACF;AACF;;;;"}