@zod-to-form/vite 0.1.1

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 (72) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +40 -0
  3. package/dist/cache.d.ts +39 -0
  4. package/dist/cache.d.ts.map +1 -0
  5. package/dist/cache.js +56 -0
  6. package/dist/cache.js.map +1 -0
  7. package/dist/config/load.d.ts +59 -0
  8. package/dist/config/load.d.ts.map +1 -0
  9. package/dist/config/load.js +117 -0
  10. package/dist/config/load.js.map +1 -0
  11. package/dist/errors.d.ts +50 -0
  12. package/dist/errors.d.ts.map +1 -0
  13. package/dist/errors.js +62 -0
  14. package/dist/errors.js.map +1 -0
  15. package/dist/generate-mode/babel-traverse.d.ts +5 -0
  16. package/dist/generate-mode/babel-traverse.d.ts.map +1 -0
  17. package/dist/generate-mode/babel-traverse.js +16 -0
  18. package/dist/generate-mode/babel-traverse.js.map +1 -0
  19. package/dist/generate-mode/generate-source.d.ts +51 -0
  20. package/dist/generate-mode/generate-source.d.ts.map +1 -0
  21. package/dist/generate-mode/generate-source.js +187 -0
  22. package/dist/generate-mode/generate-source.js.map +1 -0
  23. package/dist/generate-mode/resolve-schema.d.ts +43 -0
  24. package/dist/generate-mode/resolve-schema.d.ts.map +1 -0
  25. package/dist/generate-mode/resolve-schema.js +182 -0
  26. package/dist/generate-mode/resolve-schema.js.map +1 -0
  27. package/dist/generate-mode/scan-jsx.d.ts +86 -0
  28. package/dist/generate-mode/scan-jsx.d.ts.map +1 -0
  29. package/dist/generate-mode/scan-jsx.js +161 -0
  30. package/dist/generate-mode/scan-jsx.js.map +1 -0
  31. package/dist/hmr.d.ts +44 -0
  32. package/dist/hmr.d.ts.map +1 -0
  33. package/dist/hmr.js +28 -0
  34. package/dist/hmr.js.map +1 -0
  35. package/dist/index.d.ts +61 -0
  36. package/dist/index.d.ts.map +1 -0
  37. package/dist/index.js +59 -0
  38. package/dist/index.js.map +1 -0
  39. package/dist/logger.d.ts +27 -0
  40. package/dist/logger.d.ts.map +1 -0
  41. package/dist/logger.js +46 -0
  42. package/dist/logger.js.map +1 -0
  43. package/dist/plugin.d.ts +61 -0
  44. package/dist/plugin.d.ts.map +1 -0
  45. package/dist/plugin.js +650 -0
  46. package/dist/plugin.js.map +1 -0
  47. package/dist/query-mode/parse-specifier.d.ts +23 -0
  48. package/dist/query-mode/parse-specifier.d.ts.map +1 -0
  49. package/dist/query-mode/parse-specifier.js +83 -0
  50. package/dist/query-mode/parse-specifier.js.map +1 -0
  51. package/dist/query-mode/resolve-id.d.ts +12 -0
  52. package/dist/query-mode/resolve-id.d.ts.map +1 -0
  53. package/dist/query-mode/resolve-id.js +61 -0
  54. package/dist/query-mode/resolve-id.js.map +1 -0
  55. package/dist/query-mode/transform.d.ts +33 -0
  56. package/dist/query-mode/transform.d.ts.map +1 -0
  57. package/dist/query-mode/transform.js +90 -0
  58. package/dist/query-mode/transform.js.map +1 -0
  59. package/dist/resolver-strip.d.ts +58 -0
  60. package/dist/resolver-strip.d.ts.map +1 -0
  61. package/dist/resolver-strip.js +141 -0
  62. package/dist/resolver-strip.js.map +1 -0
  63. package/dist/tsconfig.tsbuildinfo +1 -0
  64. package/dist/types.d.ts +242 -0
  65. package/dist/types.d.ts.map +1 -0
  66. package/dist/types.js +2 -0
  67. package/dist/types.js.map +1 -0
  68. package/dist/write-guard.d.ts +26 -0
  69. package/dist/write-guard.d.ts.map +1 -0
  70. package/dist/write-guard.js +32 -0
  71. package/dist/write-guard.js.map +1 -0
  72. package/package.json +69 -0
@@ -0,0 +1,26 @@
1
+ export interface WriteCollisionInput {
2
+ /** Absolute path the plugin wants to write to. */
3
+ targetPath: string;
4
+ /**
5
+ * Current contents of the file at `targetPath`, or `null` if the file
6
+ * does not exist. The caller is responsible for the actual `readFile`
7
+ * — we deliberately keep this function pure.
8
+ */
9
+ existingContents: string | null;
10
+ /**
11
+ * Set of absolute paths the plugin has already emitted during the
12
+ * current build/dev session. If the target path is in this set, we're
13
+ * updating our own output (subsequent compile of the same target after
14
+ * a cache miss/eviction) and overwriting is safe.
15
+ */
16
+ emittedThisRun: Set<string>;
17
+ }
18
+ /**
19
+ * Decide whether writing to `targetPath` is safe.
20
+ *
21
+ * Returns the literal string `'write'` when safe — chosen over a boolean
22
+ * so the call site reads naturally (`if (checkWriteCollision(...) ===
23
+ * 'write') { ... }`). Throws otherwise.
24
+ */
25
+ export declare function checkWriteCollision(input: WriteCollisionInput): 'write';
26
+ //# sourceMappingURL=write-guard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"write-guard.d.ts","sourceRoot":"","sources":["../src/write-guard.ts"],"names":[],"mappings":"AAaA,MAAM,WAAW,mBAAmB;IAClC,kDAAkD;IAClD,UAAU,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC;;;;;OAKG;IACH,cAAc,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CAC7B;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAgBvE"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Disk-write collision guard.
3
+ *
4
+ * When the user opts into `PluginOptions.write`, the plugin writes
5
+ * generated form files to disk. FR-007 forbids clobbering pre-existing
6
+ * `*.generated.tsx` files that the user committed (e.g. CLI output from
7
+ * a prior workflow). This guard is the pure check that gates every
8
+ * disk write.
9
+ *
10
+ * Closes finding M1 from /speckit.analyze.
11
+ */
12
+ import { Z2FViteError } from './errors.js';
13
+ /**
14
+ * Decide whether writing to `targetPath` is safe.
15
+ *
16
+ * Returns the literal string `'write'` when safe — chosen over a boolean
17
+ * so the call site reads naturally (`if (checkWriteCollision(...) ===
18
+ * 'write') { ... }`). Throws otherwise.
19
+ */
20
+ export function checkWriteCollision(input) {
21
+ const { targetPath, existingContents, emittedThisRun } = input;
22
+ // No file → safe
23
+ if (existingContents === null)
24
+ return 'write';
25
+ // File belongs to a target this plugin run already emitted → safe
26
+ // (we're overwriting our own output, e.g. after a cache eviction)
27
+ if (emittedThisRun.has(targetPath))
28
+ return 'write';
29
+ // File exists, was NOT produced by us → refuse
30
+ throw new Z2FViteError('Z2F_VITE_WOULD_CLOBBER_FILE', `Refusing to overwrite existing file '${targetPath}'. The file was not produced by this plugin run, so it is most likely a committed file (e.g. CLI output from a prior codegen run). To proceed: delete the file manually, change 'write.outDir' to point somewhere else, or disable disk writes by removing the 'write' option.`, { file: targetPath });
31
+ }
32
+ //# sourceMappingURL=write-guard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"write-guard.js","sourceRoot":"","sources":["../src/write-guard.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAoB3C;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAA0B;IAC5D,MAAM,EAAE,UAAU,EAAE,gBAAgB,EAAE,cAAc,EAAE,GAAG,KAAK,CAAC;IAE/D,iBAAiB;IACjB,IAAI,gBAAgB,KAAK,IAAI;QAAE,OAAO,OAAO,CAAC;IAE9C,kEAAkE;IAClE,kEAAkE;IAClE,IAAI,cAAc,CAAC,GAAG,CAAC,UAAU,CAAC;QAAE,OAAO,OAAO,CAAC;IAEnD,+CAA+C;IAC/C,MAAM,IAAI,YAAY,CACpB,6BAA6B,EAC7B,wCAAwC,UAAU,gRAAgR,EAClU,EAAE,IAAI,EAAE,UAAU,EAAE,CACrB,CAAC;AACJ,CAAC"}
package/package.json ADDED
@@ -0,0 +1,69 @@
1
+ {
2
+ "name": "@zod-to-form/vite",
3
+ "version": "0.1.1",
4
+ "description": "Vite plugin for zod-to-form — transforms ?z2f imports into generated form components and optionally replaces <ZodForm> JSX call sites with generated components at build time",
5
+ "license": "MIT",
6
+ "homepage": "https://github.com/pradeepmouli/zod-to-form#readme",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/pradeepmouli/zod-to-form.git",
10
+ "directory": "packages/vite"
11
+ },
12
+ "keywords": [
13
+ "vite",
14
+ "vite-plugin",
15
+ "zod",
16
+ "zod-v4",
17
+ "codegen",
18
+ "forms",
19
+ "form-generation",
20
+ "schema-driven",
21
+ "react-hook-form",
22
+ "build-plugin",
23
+ "jsx-transform"
24
+ ],
25
+ "type": "module",
26
+ "exports": {
27
+ ".": {
28
+ "types": "./dist/index.d.ts",
29
+ "import": "./dist/index.js"
30
+ },
31
+ "./client": {
32
+ "types": "./dist/virtual-types.d.ts"
33
+ }
34
+ },
35
+ "main": "./dist/index.js",
36
+ "types": "./dist/index.d.ts",
37
+ "files": [
38
+ "dist"
39
+ ],
40
+ "peerDependencies": {
41
+ "vite": "^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0"
42
+ },
43
+ "dependencies": {
44
+ "@babel/parser": "^7.29.2",
45
+ "@babel/traverse": "^7.29.0",
46
+ "@babel/types": "^7.29.0",
47
+ "magic-string": "^0.30.21",
48
+ "pathe": "^2.0.3",
49
+ "@zod-to-form/codegen": "0.6.5",
50
+ "@zod-to-form/core": "0.6.6"
51
+ },
52
+ "devDependencies": {
53
+ "@types/babel__traverse": "^7.28.0",
54
+ "vite": "^8.0.8",
55
+ "zod": "^4.3.6"
56
+ },
57
+ "publishConfig": {
58
+ "access": "public"
59
+ },
60
+ "author": "Pradeep Mouli <pmouli@mac.com> (https://github.com/pradeepmouli)",
61
+ "scripts": {
62
+ "build": "tsgo -p tsconfig.build.json",
63
+ "clean": "rm -rf dist tsconfig.build.tsbuildinfo tsconfig.tsbuildinfo",
64
+ "dev": "tsgo -p tsconfig.build.json --watch",
65
+ "test": "vitest run",
66
+ "test:coverage": "vitest run --coverage",
67
+ "type-check": "tsgo --noEmit"
68
+ }
69
+ }