zod-compiler 1.23.0 → 1.23.2

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 (494) hide show
  1. package/README.md +9 -6
  2. package/dist/cli/commands/check.d.ts +10 -7
  3. package/dist/cli/commands/check.d.ts.map +1 -1
  4. package/dist/cli/commands/check.js +125 -148
  5. package/dist/cli/commands/check.js.map +1 -1
  6. package/dist/cli/commands/generate.d.ts +22 -19
  7. package/dist/cli/commands/generate.d.ts.map +1 -1
  8. package/dist/cli/commands/generate.js +102 -133
  9. package/dist/cli/commands/generate.js.map +1 -1
  10. package/dist/cli/commands/watch.d.ts +17 -15
  11. package/dist/cli/commands/watch.d.ts.map +1 -1
  12. package/dist/cli/commands/watch.js +126 -154
  13. package/dist/cli/commands/watch.js.map +1 -1
  14. package/dist/cli/emitter.d.ts +19 -16
  15. package/dist/cli/emitter.d.ts.map +1 -1
  16. package/dist/cli/emitter.js +55 -71
  17. package/dist/cli/emitter.js.map +1 -1
  18. package/dist/cli/errors.d.ts +4 -1
  19. package/dist/cli/errors.d.ts.map +1 -1
  20. package/dist/cli/errors.js +6 -2
  21. package/dist/cli/errors.js.map +1 -1
  22. package/dist/cli/index.d.ts +1 -3
  23. package/dist/cli/index.js +147 -160
  24. package/dist/cli/index.js.map +1 -1
  25. package/dist/cli/logger.d.ts +18 -15
  26. package/dist/cli/logger.d.ts.map +1 -1
  27. package/dist/cli/logger.js +38 -37
  28. package/dist/cli/logger.js.map +1 -1
  29. package/dist/core/codegen/build-path.d.ts +7 -41
  30. package/dist/core/codegen/build-path.d.ts.map +1 -1
  31. package/dist/core/codegen/build-path.js +481 -570
  32. package/dist/core/codegen/build-path.js.map +1 -1
  33. package/dist/core/codegen/context.d.ts +256 -253
  34. package/dist/core/codegen/context.d.ts.map +1 -1
  35. package/dist/core/codegen/context.js +363 -437
  36. package/dist/core/codegen/context.js.map +1 -1
  37. package/dist/core/codegen/dedupe.d.ts +22 -56
  38. package/dist/core/codegen/dedupe.d.ts.map +1 -1
  39. package/dist/core/codegen/dedupe.js +150 -242
  40. package/dist/core/codegen/dedupe.js.map +1 -1
  41. package/dist/core/codegen/emit-issue.d.ts +44 -68
  42. package/dist/core/codegen/emit-issue.d.ts.map +1 -1
  43. package/dist/core/codegen/emit-issue.js +76 -108
  44. package/dist/core/codegen/emit-issue.js.map +1 -1
  45. package/dist/core/codegen/emit.d.ts +4 -1
  46. package/dist/core/codegen/emit.d.ts.map +1 -1
  47. package/dist/core/codegen/emit.js +16 -13
  48. package/dist/core/codegen/emit.js.map +1 -1
  49. package/dist/core/codegen/fast-path.d.ts +7 -12
  50. package/dist/core/codegen/fast-path.d.ts.map +1 -1
  51. package/dist/core/codegen/fast-path.js +116 -145
  52. package/dist/core/codegen/fast-path.js.map +1 -1
  53. package/dist/core/codegen/fast-size.d.ts +12 -26
  54. package/dist/core/codegen/fast-size.d.ts.map +1 -1
  55. package/dist/core/codegen/fast-size.js +169 -244
  56. package/dist/core/codegen/fast-size.js.map +1 -1
  57. package/dist/core/codegen/index.d.ts +25 -23
  58. package/dist/core/codegen/index.d.ts.map +1 -1
  59. package/dist/core/codegen/index.js +239 -405
  60. package/dist/core/codegen/index.js.map +1 -1
  61. package/dist/core/codegen/issue-decls.d.ts +15 -12
  62. package/dist/core/codegen/issue-decls.d.ts.map +1 -1
  63. package/dist/core/codegen/issue-decls.js +131 -162
  64. package/dist/core/codegen/issue-decls.js.map +1 -1
  65. package/dist/core/codegen/regex-unroll.d.ts +4 -1
  66. package/dist/core/codegen/regex-unroll.d.ts.map +1 -1
  67. package/dist/core/codegen/regex-unroll.js +173 -197
  68. package/dist/core/codegen/regex-unroll.js.map +1 -1
  69. package/dist/core/codegen/schemas/any.d.ts +7 -4
  70. package/dist/core/codegen/schemas/any.d.ts.map +1 -1
  71. package/dist/core/codegen/schemas/any.js +8 -4
  72. package/dist/core/codegen/schemas/any.js.map +1 -1
  73. package/dist/core/codegen/schemas/array.d.ts +8 -5
  74. package/dist/core/codegen/schemas/array.d.ts.map +1 -1
  75. package/dist/core/codegen/schemas/array.js +77 -95
  76. package/dist/core/codegen/schemas/array.js.map +1 -1
  77. package/dist/core/codegen/schemas/bigint.d.ts +7 -4
  78. package/dist/core/codegen/schemas/bigint.d.ts.map +1 -1
  79. package/dist/core/codegen/schemas/bigint.js +44 -56
  80. package/dist/core/codegen/schemas/bigint.js.map +1 -1
  81. package/dist/core/codegen/schemas/boolean.d.ts +7 -4
  82. package/dist/core/codegen/schemas/boolean.d.ts.map +1 -1
  83. package/dist/core/codegen/schemas/boolean.js +12 -11
  84. package/dist/core/codegen/schemas/boolean.js.map +1 -1
  85. package/dist/core/codegen/schemas/catch.d.ts +8 -5
  86. package/dist/core/codegen/schemas/catch.d.ts.map +1 -1
  87. package/dist/core/codegen/schemas/catch.js +23 -23
  88. package/dist/core/codegen/schemas/catch.js.map +1 -1
  89. package/dist/core/codegen/schemas/date.d.ts +7 -4
  90. package/dist/core/codegen/schemas/date.d.ts.map +1 -1
  91. package/dist/core/codegen/schemas/date.js +49 -68
  92. package/dist/core/codegen/schemas/date.js.map +1 -1
  93. package/dist/core/codegen/schemas/default.d.ts +9 -6
  94. package/dist/core/codegen/schemas/default.d.ts.map +1 -1
  95. package/dist/core/codegen/schemas/default.js +29 -27
  96. package/dist/core/codegen/schemas/default.js.map +1 -1
  97. package/dist/core/codegen/schemas/discriminated-union.d.ts +12 -10
  98. package/dist/core/codegen/schemas/discriminated-union.d.ts.map +1 -1
  99. package/dist/core/codegen/schemas/discriminated-union.js +153 -178
  100. package/dist/core/codegen/schemas/discriminated-union.js.map +1 -1
  101. package/dist/core/codegen/schemas/effect.d.ts +9 -6
  102. package/dist/core/codegen/schemas/effect.d.ts.map +1 -1
  103. package/dist/core/codegen/schemas/effect.js +54 -67
  104. package/dist/core/codegen/schemas/effect.js.map +1 -1
  105. package/dist/core/codegen/schemas/enum.d.ts +7 -4
  106. package/dist/core/codegen/schemas/enum.d.ts.map +1 -1
  107. package/dist/core/codegen/schemas/enum.js +15 -21
  108. package/dist/core/codegen/schemas/enum.js.map +1 -1
  109. package/dist/core/codegen/schemas/fallback.d.ts +6 -3
  110. package/dist/core/codegen/schemas/fallback.d.ts.map +1 -1
  111. package/dist/core/codegen/schemas/fallback.js +14 -13
  112. package/dist/core/codegen/schemas/fallback.js.map +1 -1
  113. package/dist/core/codegen/schemas/file.d.ts +7 -4
  114. package/dist/core/codegen/schemas/file.d.ts.map +1 -1
  115. package/dist/core/codegen/schemas/file.js +51 -57
  116. package/dist/core/codegen/schemas/file.js.map +1 -1
  117. package/dist/core/codegen/schemas/intersection.d.ts +8 -5
  118. package/dist/core/codegen/schemas/intersection.d.ts.map +1 -1
  119. package/dist/core/codegen/schemas/intersection.js +16 -13
  120. package/dist/core/codegen/schemas/intersection.js.map +1 -1
  121. package/dist/core/codegen/schemas/literal.d.ts +7 -4
  122. package/dist/core/codegen/schemas/literal.d.ts.map +1 -1
  123. package/dist/core/codegen/schemas/literal.js +20 -23
  124. package/dist/core/codegen/schemas/literal.js.map +1 -1
  125. package/dist/core/codegen/schemas/map.d.ts +8 -5
  126. package/dist/core/codegen/schemas/map.d.ts.map +1 -1
  127. package/dist/core/codegen/schemas/map.js +61 -67
  128. package/dist/core/codegen/schemas/map.js.map +1 -1
  129. package/dist/core/codegen/schemas/nan.d.ts +7 -4
  130. package/dist/core/codegen/schemas/nan.d.ts.map +1 -1
  131. package/dist/core/codegen/schemas/nan.js +8 -4
  132. package/dist/core/codegen/schemas/nan.js.map +1 -1
  133. package/dist/core/codegen/schemas/never.d.ts +7 -4
  134. package/dist/core/codegen/schemas/never.d.ts.map +1 -1
  135. package/dist/core/codegen/schemas/never.js +8 -4
  136. package/dist/core/codegen/schemas/never.js.map +1 -1
  137. package/dist/core/codegen/schemas/null.d.ts +7 -4
  138. package/dist/core/codegen/schemas/null.d.ts.map +1 -1
  139. package/dist/core/codegen/schemas/null.js +8 -4
  140. package/dist/core/codegen/schemas/null.js.map +1 -1
  141. package/dist/core/codegen/schemas/nullable.d.ts +8 -5
  142. package/dist/core/codegen/schemas/nullable.d.ts.map +1 -1
  143. package/dist/core/codegen/schemas/nullable.js +8 -5
  144. package/dist/core/codegen/schemas/nullable.js.map +1 -1
  145. package/dist/core/codegen/schemas/number.d.ts +7 -4
  146. package/dist/core/codegen/schemas/number.d.ts.map +1 -1
  147. package/dist/core/codegen/schemas/number.js +120 -176
  148. package/dist/core/codegen/schemas/number.js.map +1 -1
  149. package/dist/core/codegen/schemas/object.d.ts +8 -5
  150. package/dist/core/codegen/schemas/object.d.ts.map +1 -1
  151. package/dist/core/codegen/schemas/object.js +144 -231
  152. package/dist/core/codegen/schemas/object.js.map +1 -1
  153. package/dist/core/codegen/schemas/optional.d.ts +9 -6
  154. package/dist/core/codegen/schemas/optional.d.ts.map +1 -1
  155. package/dist/core/codegen/schemas/optional.js +23 -31
  156. package/dist/core/codegen/schemas/optional.js.map +1 -1
  157. package/dist/core/codegen/schemas/pipe.d.ts +8 -5
  158. package/dist/core/codegen/schemas/pipe.d.ts.map +1 -1
  159. package/dist/core/codegen/schemas/pipe.js +20 -27
  160. package/dist/core/codegen/schemas/pipe.js.map +1 -1
  161. package/dist/core/codegen/schemas/readonly.d.ts +8 -5
  162. package/dist/core/codegen/schemas/readonly.d.ts.map +1 -1
  163. package/dist/core/codegen/schemas/readonly.js +8 -5
  164. package/dist/core/codegen/schemas/readonly.js.map +1 -1
  165. package/dist/core/codegen/schemas/record.d.ts +8 -5
  166. package/dist/core/codegen/schemas/record.d.ts.map +1 -1
  167. package/dist/core/codegen/schemas/record.js +52 -65
  168. package/dist/core/codegen/schemas/record.js.map +1 -1
  169. package/dist/core/codegen/schemas/recursive-ref.d.ts +9 -6
  170. package/dist/core/codegen/schemas/recursive-ref.d.ts.map +1 -1
  171. package/dist/core/codegen/schemas/recursive-ref.js +44 -44
  172. package/dist/core/codegen/schemas/recursive-ref.js.map +1 -1
  173. package/dist/core/codegen/schemas/set.d.ts +8 -5
  174. package/dist/core/codegen/schemas/set.d.ts.map +1 -1
  175. package/dist/core/codegen/schemas/set.js +61 -73
  176. package/dist/core/codegen/schemas/set.js.map +1 -1
  177. package/dist/core/codegen/schemas/string-bool.d.ts +6 -3
  178. package/dist/core/codegen/schemas/string-bool.d.ts.map +1 -1
  179. package/dist/core/codegen/schemas/string-bool.js +22 -23
  180. package/dist/core/codegen/schemas/string-bool.js.map +1 -1
  181. package/dist/core/codegen/schemas/string.d.ts +8 -5
  182. package/dist/core/codegen/schemas/string.d.ts.map +1 -1
  183. package/dist/core/codegen/schemas/string.js +168 -207
  184. package/dist/core/codegen/schemas/string.js.map +1 -1
  185. package/dist/core/codegen/schemas/symbol.d.ts +7 -4
  186. package/dist/core/codegen/schemas/symbol.d.ts.map +1 -1
  187. package/dist/core/codegen/schemas/symbol.js +8 -4
  188. package/dist/core/codegen/schemas/symbol.js.map +1 -1
  189. package/dist/core/codegen/schemas/template-literal.d.ts +7 -4
  190. package/dist/core/codegen/schemas/template-literal.d.ts.map +1 -1
  191. package/dist/core/codegen/schemas/template-literal.js +12 -13
  192. package/dist/core/codegen/schemas/template-literal.js.map +1 -1
  193. package/dist/core/codegen/schemas/tuple.d.ts +8 -5
  194. package/dist/core/codegen/schemas/tuple.d.ts.map +1 -1
  195. package/dist/core/codegen/schemas/tuple.js +84 -94
  196. package/dist/core/codegen/schemas/tuple.js.map +1 -1
  197. package/dist/core/codegen/schemas/undefined.d.ts +7 -4
  198. package/dist/core/codegen/schemas/undefined.d.ts.map +1 -1
  199. package/dist/core/codegen/schemas/undefined.js +8 -4
  200. package/dist/core/codegen/schemas/undefined.js.map +1 -1
  201. package/dist/core/codegen/schemas/union.d.ts +8 -5
  202. package/dist/core/codegen/schemas/union.d.ts.map +1 -1
  203. package/dist/core/codegen/schemas/union.js +49 -69
  204. package/dist/core/codegen/schemas/union.js.map +1 -1
  205. package/dist/core/codegen/schemas/unknown.d.ts +7 -4
  206. package/dist/core/codegen/schemas/unknown.d.ts.map +1 -1
  207. package/dist/core/codegen/schemas/unknown.js +8 -4
  208. package/dist/core/codegen/schemas/unknown.js.map +1 -1
  209. package/dist/core/codegen/schemas/void.d.ts +7 -4
  210. package/dist/core/codegen/schemas/void.d.ts.map +1 -1
  211. package/dist/core/codegen/schemas/void.js +8 -4
  212. package/dist/core/codegen/schemas/void.js.map +1 -1
  213. package/dist/core/codegen/slow-path.d.ts +7 -4
  214. package/dist/core/codegen/slow-path.d.ts.map +1 -1
  215. package/dist/core/codegen/slow-path.js +71 -96
  216. package/dist/core/codegen/slow-path.js.map +1 -1
  217. package/dist/core/codegen/well-known-regex.d.ts +22 -19
  218. package/dist/core/codegen/well-known-regex.d.ts.map +1 -1
  219. package/dist/core/codegen/well-known-regex.js +127 -96
  220. package/dist/core/codegen/well-known-regex.js.map +1 -1
  221. package/dist/core/compile.d.ts +7 -4
  222. package/dist/core/compile.d.ts.map +1 -1
  223. package/dist/core/compile.js +48 -48
  224. package/dist/core/compile.js.map +1 -1
  225. package/dist/core/diagnostic.d.ts +38 -39
  226. package/dist/core/diagnostic.d.ts.map +1 -1
  227. package/dist/core/diagnostic.js +140 -164
  228. package/dist/core/diagnostic.js.map +1 -1
  229. package/dist/core/extract/checks.d.ts +18 -15
  230. package/dist/core/extract/checks.d.ts.map +1 -1
  231. package/dist/core/extract/checks.js +318 -311
  232. package/dist/core/extract/checks.js.map +1 -1
  233. package/dist/core/extract/effects.d.ts +13 -10
  234. package/dist/core/extract/effects.d.ts.map +1 -1
  235. package/dist/core/extract/effects.js +153 -222
  236. package/dist/core/extract/effects.js.map +1 -1
  237. package/dist/core/extract/extractors/any.d.ts +5 -2
  238. package/dist/core/extract/extractors/any.d.ts.map +1 -1
  239. package/dist/core/extract/extractors/any.js +5 -1
  240. package/dist/core/extract/extractors/any.js.map +1 -1
  241. package/dist/core/extract/extractors/array.d.ts +6 -3
  242. package/dist/core/extract/extractors/array.d.ts.map +1 -1
  243. package/dist/core/extract/extractors/array.js +25 -20
  244. package/dist/core/extract/extractors/array.js.map +1 -1
  245. package/dist/core/extract/extractors/bigint.d.ts +6 -3
  246. package/dist/core/extract/extractors/bigint.d.ts.map +1 -1
  247. package/dist/core/extract/extractors/bigint.js +66 -64
  248. package/dist/core/extract/extractors/bigint.js.map +1 -1
  249. package/dist/core/extract/extractors/boolean.d.ts +5 -2
  250. package/dist/core/extract/extractors/boolean.d.ts.map +1 -1
  251. package/dist/core/extract/extractors/boolean.js +7 -3
  252. package/dist/core/extract/extractors/boolean.js.map +1 -1
  253. package/dist/core/extract/extractors/catch.d.ts +6 -3
  254. package/dist/core/extract/extractors/catch.d.ts.map +1 -1
  255. package/dist/core/extract/extractors/catch.js +26 -17
  256. package/dist/core/extract/extractors/catch.js.map +1 -1
  257. package/dist/core/extract/extractors/date.d.ts +6 -3
  258. package/dist/core/extract/extractors/date.d.ts.map +1 -1
  259. package/dist/core/extract/extractors/date.js +42 -46
  260. package/dist/core/extract/extractors/date.js.map +1 -1
  261. package/dist/core/extract/extractors/default.d.ts +6 -3
  262. package/dist/core/extract/extractors/default.d.ts.map +1 -1
  263. package/dist/core/extract/extractors/default.js +20 -14
  264. package/dist/core/extract/extractors/default.js.map +1 -1
  265. package/dist/core/extract/extractors/enum.d.ts +5 -2
  266. package/dist/core/extract/extractors/enum.d.ts.map +1 -1
  267. package/dist/core/extract/extractors/enum.js +12 -13
  268. package/dist/core/extract/extractors/enum.js.map +1 -1
  269. package/dist/core/extract/extractors/file.d.ts +6 -3
  270. package/dist/core/extract/extractors/file.d.ts.map +1 -1
  271. package/dist/core/extract/extractors/file.js +34 -28
  272. package/dist/core/extract/extractors/file.js.map +1 -1
  273. package/dist/core/extract/extractors/intersection.d.ts +5 -2
  274. package/dist/core/extract/extractors/intersection.d.ts.map +1 -1
  275. package/dist/core/extract/extractors/intersection.js +13 -11
  276. package/dist/core/extract/extractors/intersection.js.map +1 -1
  277. package/dist/core/extract/extractors/lazy.d.ts +6 -3
  278. package/dist/core/extract/extractors/lazy.d.ts.map +1 -1
  279. package/dist/core/extract/extractors/lazy.js +21 -30
  280. package/dist/core/extract/extractors/lazy.js.map +1 -1
  281. package/dist/core/extract/extractors/literal.d.ts +5 -2
  282. package/dist/core/extract/extractors/literal.d.ts.map +1 -1
  283. package/dist/core/extract/extractors/literal.js +8 -1
  284. package/dist/core/extract/extractors/literal.js.map +1 -1
  285. package/dist/core/extract/extractors/map.d.ts +6 -3
  286. package/dist/core/extract/extractors/map.d.ts.map +1 -1
  287. package/dist/core/extract/extractors/map.js +10 -4
  288. package/dist/core/extract/extractors/map.js.map +1 -1
  289. package/dist/core/extract/extractors/nan.d.ts +5 -2
  290. package/dist/core/extract/extractors/nan.d.ts.map +1 -1
  291. package/dist/core/extract/extractors/nan.js +5 -1
  292. package/dist/core/extract/extractors/nan.js.map +1 -1
  293. package/dist/core/extract/extractors/never.d.ts +5 -2
  294. package/dist/core/extract/extractors/never.d.ts.map +1 -1
  295. package/dist/core/extract/extractors/never.js +5 -1
  296. package/dist/core/extract/extractors/never.js.map +1 -1
  297. package/dist/core/extract/extractors/null.d.ts +5 -2
  298. package/dist/core/extract/extractors/null.d.ts.map +1 -1
  299. package/dist/core/extract/extractors/null.js +5 -1
  300. package/dist/core/extract/extractors/null.js.map +1 -1
  301. package/dist/core/extract/extractors/nullable.d.ts +5 -2
  302. package/dist/core/extract/extractors/nullable.d.ts.map +1 -1
  303. package/dist/core/extract/extractors/nullable.js +7 -3
  304. package/dist/core/extract/extractors/nullable.js.map +1 -1
  305. package/dist/core/extract/extractors/number.d.ts +6 -3
  306. package/dist/core/extract/extractors/number.d.ts.map +1 -1
  307. package/dist/core/extract/extractors/number.js +35 -35
  308. package/dist/core/extract/extractors/number.js.map +1 -1
  309. package/dist/core/extract/extractors/object.d.ts +6 -3
  310. package/dist/core/extract/extractors/object.d.ts.map +1 -1
  311. package/dist/core/extract/extractors/object.js +49 -76
  312. package/dist/core/extract/extractors/object.js.map +1 -1
  313. package/dist/core/extract/extractors/optional.d.ts +5 -2
  314. package/dist/core/extract/extractors/optional.d.ts.map +1 -1
  315. package/dist/core/extract/extractors/optional.js +10 -12
  316. package/dist/core/extract/extractors/optional.js.map +1 -1
  317. package/dist/core/extract/extractors/pipe.d.ts +6 -3
  318. package/dist/core/extract/extractors/pipe.d.ts.map +1 -1
  319. package/dist/core/extract/extractors/pipe.js +40 -41
  320. package/dist/core/extract/extractors/pipe.js.map +1 -1
  321. package/dist/core/extract/extractors/readonly.d.ts +5 -2
  322. package/dist/core/extract/extractors/readonly.d.ts.map +1 -1
  323. package/dist/core/extract/extractors/readonly.js +10 -6
  324. package/dist/core/extract/extractors/readonly.js.map +1 -1
  325. package/dist/core/extract/extractors/record.d.ts +6 -3
  326. package/dist/core/extract/extractors/record.d.ts.map +1 -1
  327. package/dist/core/extract/extractors/record.js +24 -35
  328. package/dist/core/extract/extractors/record.js.map +1 -1
  329. package/dist/core/extract/extractors/set.d.ts +6 -3
  330. package/dist/core/extract/extractors/set.d.ts.map +1 -1
  331. package/dist/core/extract/extractors/set.js +36 -30
  332. package/dist/core/extract/extractors/set.js.map +1 -1
  333. package/dist/core/extract/extractors/string-bool.d.ts +7 -4
  334. package/dist/core/extract/extractors/string-bool.d.ts.map +1 -1
  335. package/dist/core/extract/extractors/string-bool.js +66 -84
  336. package/dist/core/extract/extractors/string-bool.js.map +1 -1
  337. package/dist/core/extract/extractors/string.d.ts +6 -3
  338. package/dist/core/extract/extractors/string.d.ts.map +1 -1
  339. package/dist/core/extract/extractors/string.js +34 -37
  340. package/dist/core/extract/extractors/string.js.map +1 -1
  341. package/dist/core/extract/extractors/symbol.d.ts +5 -2
  342. package/dist/core/extract/extractors/symbol.d.ts.map +1 -1
  343. package/dist/core/extract/extractors/symbol.js +5 -1
  344. package/dist/core/extract/extractors/symbol.js.map +1 -1
  345. package/dist/core/extract/extractors/template-literal.d.ts +6 -3
  346. package/dist/core/extract/extractors/template-literal.d.ts.map +1 -1
  347. package/dist/core/extract/extractors/template-literal.js +11 -6
  348. package/dist/core/extract/extractors/template-literal.js.map +1 -1
  349. package/dist/core/extract/extractors/tuple.d.ts +6 -3
  350. package/dist/core/extract/extractors/tuple.d.ts.map +1 -1
  351. package/dist/core/extract/extractors/tuple.js +10 -4
  352. package/dist/core/extract/extractors/tuple.js.map +1 -1
  353. package/dist/core/extract/extractors/undefined.d.ts +5 -2
  354. package/dist/core/extract/extractors/undefined.d.ts.map +1 -1
  355. package/dist/core/extract/extractors/undefined.js +5 -1
  356. package/dist/core/extract/extractors/undefined.js.map +1 -1
  357. package/dist/core/extract/extractors/union.d.ts +6 -3
  358. package/dist/core/extract/extractors/union.d.ts.map +1 -1
  359. package/dist/core/extract/extractors/union.js +38 -64
  360. package/dist/core/extract/extractors/union.js.map +1 -1
  361. package/dist/core/extract/extractors/unknown.d.ts +5 -2
  362. package/dist/core/extract/extractors/unknown.d.ts.map +1 -1
  363. package/dist/core/extract/extractors/unknown.js +5 -1
  364. package/dist/core/extract/extractors/unknown.js.map +1 -1
  365. package/dist/core/extract/extractors/void.d.ts +5 -2
  366. package/dist/core/extract/extractors/void.d.ts.map +1 -1
  367. package/dist/core/extract/extractors/void.js +5 -1
  368. package/dist/core/extract/extractors/void.js.map +1 -1
  369. package/dist/core/extract/fallback.d.ts +6 -3
  370. package/dist/core/extract/fallback.d.ts.map +1 -1
  371. package/dist/core/extract/fallback.js +21 -7
  372. package/dist/core/extract/fallback.js.map +1 -1
  373. package/dist/core/extract/index.d.ts +6 -4
  374. package/dist/core/extract/index.d.ts.map +1 -1
  375. package/dist/core/extract/index.js +15 -15
  376. package/dist/core/extract/index.js.map +1 -1
  377. package/dist/core/extract/registry.d.ts +39 -36
  378. package/dist/core/extract/registry.d.ts.map +1 -1
  379. package/dist/core/extract/registry.js +96 -123
  380. package/dist/core/extract/registry.js.map +1 -1
  381. package/dist/core/extract/types.d.ts +124 -120
  382. package/dist/core/extract/types.d.ts.map +1 -1
  383. package/dist/core/extract/types.js +0 -1
  384. package/dist/core/iife.d.ts +14 -15
  385. package/dist/core/iife.d.ts.map +1 -1
  386. package/dist/core/iife.js +182 -206
  387. package/dist/core/iife.js.map +1 -1
  388. package/dist/core/pipeline.d.ts +33 -30
  389. package/dist/core/pipeline.d.ts.map +1 -1
  390. package/dist/core/pipeline.js +67 -74
  391. package/dist/core/pipeline.js.map +1 -1
  392. package/dist/core/types.d.ts +430 -427
  393. package/dist/core/types.d.ts.map +1 -1
  394. package/dist/core/types.js +0 -5
  395. package/dist/discovery.d.ts +8 -5
  396. package/dist/discovery.d.ts.map +1 -1
  397. package/dist/discovery.js +31 -32
  398. package/dist/discovery.js.map +1 -1
  399. package/dist/index.d.ts +4 -4
  400. package/dist/index.js +2 -2
  401. package/dist/jit.d.ts +15 -42
  402. package/dist/jit.d.ts.map +1 -1
  403. package/dist/jit.js +187 -216
  404. package/dist/jit.js.map +1 -1
  405. package/dist/loader.d.ts +14 -11
  406. package/dist/loader.d.ts.map +1 -1
  407. package/dist/loader.js +226 -258
  408. package/dist/loader.js.map +1 -1
  409. package/dist/static-filter.d.ts +4 -1
  410. package/dist/static-filter.d.ts.map +1 -1
  411. package/dist/static-filter.js +240 -367
  412. package/dist/static-filter.js.map +1 -1
  413. package/dist/swc.d.ts +38 -35
  414. package/dist/swc.d.ts.map +1 -1
  415. package/dist/swc.js +83 -76
  416. package/dist/swc.js.map +1 -1
  417. package/dist/unplugin/bun.d.ts +5 -2
  418. package/dist/unplugin/bun.d.ts.map +1 -1
  419. package/dist/unplugin/bun.js +5 -1
  420. package/dist/unplugin/bun.js.map +1 -1
  421. package/dist/unplugin/dep-graph.d.ts +10 -7
  422. package/dist/unplugin/dep-graph.d.ts.map +1 -1
  423. package/dist/unplugin/dep-graph.js +216 -252
  424. package/dist/unplugin/dep-graph.js.map +1 -1
  425. package/dist/unplugin/disk-cache.d.ts +121 -92
  426. package/dist/unplugin/disk-cache.d.ts.map +1 -1
  427. package/dist/unplugin/disk-cache.js +425 -444
  428. package/dist/unplugin/disk-cache.js.map +1 -1
  429. package/dist/unplugin/edits.d.ts +15 -12
  430. package/dist/unplugin/edits.d.ts.map +1 -1
  431. package/dist/unplugin/edits.js +24 -37
  432. package/dist/unplugin/edits.js.map +1 -1
  433. package/dist/unplugin/esbuild.d.ts +5 -2
  434. package/dist/unplugin/esbuild.d.ts.map +1 -1
  435. package/dist/unplugin/esbuild.js +5 -1
  436. package/dist/unplugin/esbuild.js.map +1 -1
  437. package/dist/unplugin/farm.d.ts +5 -2
  438. package/dist/unplugin/farm.d.ts.map +1 -1
  439. package/dist/unplugin/farm.js +5 -1
  440. package/dist/unplugin/farm.js.map +1 -1
  441. package/dist/unplugin/hoist-compile.d.ts +14 -42
  442. package/dist/unplugin/hoist-compile.d.ts.map +1 -1
  443. package/dist/unplugin/hoist-compile.js +67 -112
  444. package/dist/unplugin/hoist-compile.js.map +1 -1
  445. package/dist/unplugin/hoist.d.ts +56 -54
  446. package/dist/unplugin/hoist.d.ts.map +1 -1
  447. package/dist/unplugin/hoist.js +945 -1170
  448. package/dist/unplugin/hoist.js.map +1 -1
  449. package/dist/unplugin/index.d.ts +5 -3
  450. package/dist/unplugin/index.d.ts.map +1 -1
  451. package/dist/unplugin/index.js +175 -250
  452. package/dist/unplugin/index.js.map +1 -1
  453. package/dist/unplugin/rolldown.d.ts +5 -2
  454. package/dist/unplugin/rolldown.d.ts.map +1 -1
  455. package/dist/unplugin/rolldown.js +5 -1
  456. package/dist/unplugin/rolldown.js.map +1 -1
  457. package/dist/unplugin/rollup.d.ts +5 -2
  458. package/dist/unplugin/rollup.d.ts.map +1 -1
  459. package/dist/unplugin/rollup.js +5 -1
  460. package/dist/unplugin/rollup.js.map +1 -1
  461. package/dist/unplugin/rsbuild.d.ts +6 -3
  462. package/dist/unplugin/rsbuild.d.ts.map +1 -1
  463. package/dist/unplugin/rsbuild.js +15 -11
  464. package/dist/unplugin/rsbuild.js.map +1 -1
  465. package/dist/unplugin/rspack.d.ts +5 -2
  466. package/dist/unplugin/rspack.d.ts.map +1 -1
  467. package/dist/unplugin/rspack.js +5 -1
  468. package/dist/unplugin/rspack.js.map +1 -1
  469. package/dist/unplugin/transform.d.ts +30 -27
  470. package/dist/unplugin/transform.d.ts.map +1 -1
  471. package/dist/unplugin/transform.js +433 -620
  472. package/dist/unplugin/transform.js.map +1 -1
  473. package/dist/unplugin/types.d.ts +189 -184
  474. package/dist/unplugin/types.d.ts.map +1 -1
  475. package/dist/unplugin/types.js +22 -18
  476. package/dist/unplugin/types.js.map +1 -1
  477. package/dist/unplugin/virtual.d.ts +11 -8
  478. package/dist/unplugin/virtual.d.ts.map +1 -1
  479. package/dist/unplugin/virtual.js +65 -83
  480. package/dist/unplugin/virtual.js.map +1 -1
  481. package/dist/unplugin/vite.d.ts +5 -2
  482. package/dist/unplugin/vite.d.ts.map +1 -1
  483. package/dist/unplugin/vite.js +5 -1
  484. package/dist/unplugin/vite.js.map +1 -1
  485. package/dist/unplugin/webpack.d.ts +5 -2
  486. package/dist/unplugin/webpack.d.ts.map +1 -1
  487. package/dist/unplugin/webpack.js +5 -1
  488. package/dist/unplugin/webpack.js.map +1 -1
  489. package/package.json +23 -14
  490. package/dist/cli/index.d.ts.map +0 -1
  491. package/dist/core/extract/types.js.map +0 -1
  492. package/dist/core/types.js.map +0 -1
  493. package/dist/index.d.ts.map +0 -1
  494. package/dist/index.js.map +0 -1
@@ -1,331 +1,338 @@
1
1
  import { isPayloadCheck, isReferenceablePredicate, tryCompileEffect } from "./effects.js";
2
+ //#region src/core/extract/checks.ts
2
3
  /**
3
- * Build the `refineRef` registrar for {@link extractChecks} from an extractor's
4
- * context: it appends a {@link RefEntry} pointing at the check's own predicate
5
- * (`<schema>._zod.def.checks[i]._zod.def.fn`) so generated code can call the
6
- * user's function object directly. Returns undefined — meaning "fall back as
7
- * before" — when the extraction is not collecting refs.
8
- */
9
- export function refineRefRegistrar(ctx, checks) {
10
- const refs = ctx.refs;
11
- if (!refs)
12
- return undefined;
13
- return (index) => {
14
- const fn = checks[index]?._zod?.def?.fn;
15
- if (!isReferenceablePredicate(fn))
16
- return undefined;
17
- refs.push({ schema: fn, accessPath: `${ctx.path}._zod.def.checks[${index}]._zod.def.fn` });
18
- return refs.length - 1;
19
- };
4
+ * Build the `refineRef` registrar for {@link extractChecks} from an extractor's
5
+ * context: it appends a {@link RefEntry} pointing at the check's own predicate
6
+ * (`<schema>._zod.def.checks[i]._zod.def.fn`) so generated code can call the
7
+ * user's function object directly. Returns undefined — meaning "fall back as
8
+ * before" — when the extraction is not collecting refs.
9
+ */
10
+ function refineRefRegistrar(ctx, checks) {
11
+ const refs = ctx.refs;
12
+ if (!refs) return void 0;
13
+ return (index) => {
14
+ const fn = checks[index]?._zod?.def?.fn;
15
+ if (!isReferenceablePredicate(fn)) return void 0;
16
+ refs.push({
17
+ schema: fn,
18
+ accessPath: `${ctx.path}._zod.def.checks[${index}]._zod.def.fn`
19
+ });
20
+ return refs.length - 1;
21
+ };
20
22
  }
21
23
  /**
22
- * Register the payload-taking callback of check `index` (`superRefine`) as an
23
- * `__rf[N]` reference, pointing at zod's own wrapper
24
- * (`<schema>._zod.def.checks[i]._zod.check`).
25
- *
26
- * Only the LAST check on a node qualifies: an issue carrying
27
- * `fatal`/`continue:false` aborts zod's remaining chain, and compiled output
28
- * runs every check unconditionally — with nothing following, there is nothing
29
- * left to abort, so the two agree.
30
- */
31
- export function payloadCheckRef(ctx, checks, index) {
32
- if (index !== checks.length - 1)
33
- return undefined;
34
- const check = checks[index];
35
- const refs = ctx.refs;
36
- if (!refs || !check || !isPayloadCheck(check))
37
- return undefined;
38
- refs.push({
39
- schema: check._zod.check,
40
- accessPath: `${ctx.path}._zod.def.checks[${index}]._zod.check`,
41
- });
42
- return refs.length - 1;
24
+ * Register the payload-taking callback of check `index` (`superRefine`) as an
25
+ * `__rf[N]` reference, pointing at zod's own wrapper
26
+ * (`<schema>._zod.def.checks[i]._zod.check`).
27
+ *
28
+ * Only the LAST check on a node qualifies: an issue carrying
29
+ * `fatal`/`continue:false` aborts zod's remaining chain, and compiled output
30
+ * runs every check unconditionally — with nothing following, there is nothing
31
+ * left to abort, so the two agree.
32
+ */
33
+ function payloadCheckRef(ctx, checks, index) {
34
+ if (index !== checks.length - 1) return void 0;
35
+ const check = checks[index];
36
+ const refs = ctx.refs;
37
+ if (!refs || !check || !isPayloadCheck(check)) return void 0;
38
+ refs.push({
39
+ schema: check._zod.check,
40
+ accessPath: `${ctx.path}._zod.def.checks[${index}]._zod.check`
41
+ });
42
+ return refs.length - 1;
43
43
  }
44
44
  /**
45
- * String formats the codegen can validate without a regex pattern.
46
- * Everything else without a pattern (e.g. z.jwt(), which validates
47
- * algorithmically) must fall back to Zod instead of being silently skipped.
48
- */
49
- const PATTERNLESS_FORMATS = new Set(["email", "uuid", "url"]);
45
+ * String formats the codegen can validate without a regex pattern.
46
+ * Everything else without a pattern (e.g. z.jwt(), which validates
47
+ * algorithmically) must fall back to Zod instead of being silently skipped.
48
+ */
49
+ const PATTERNLESS_FORMATS = /* @__PURE__ */ new Set([
50
+ "email",
51
+ "uuid",
52
+ "url"
53
+ ]);
50
54
  /**
51
- * Formats whose def.pattern is NOT the authoritative validator — zod's
52
- * runtime check is algorithmic and accepts inputs the pattern rejects
53
- * (e.g. z.cidrv6() splits the prefix and validates the IPv6 part separately).
54
- */
55
- const NON_AUTHORITATIVE_PATTERN_FORMATS = new Set(["cidrv6"]);
55
+ * Formats whose def.pattern is NOT the authoritative validator — zod's
56
+ * runtime check is algorithmic and accepts inputs the pattern rejects
57
+ * (e.g. z.cidrv6() splits the prefix and validates the IPv6 part separately).
58
+ */
59
+ const NON_AUTHORITATIVE_PATTERN_FORMATS = /* @__PURE__ */ new Set(["cidrv6"]);
56
60
  /**
57
- * Check kinds where Zod itself installs a `when` guard
58
- * (`!nullish(value) && value.length/size !== undefined`). Compiled output
59
- * reproduces that gating structurally — length/size checks only run after the
60
- * typeof/instanceof guard — so a `when` on these kinds is expected and safe.
61
- * A `when` anywhere else must be user-supplied → fall back to Zod.
62
- * (A user-supplied `when` on one of these six kinds is indistinguishable from
63
- * the internal guard and remains unsupported.)
64
- */
65
- const INTERNAL_WHEN_CHECK_KINDS = new Set([
66
- "min_length",
67
- "max_length",
68
- "length_equals",
69
- "min_size",
70
- "max_size",
71
- "size_equals",
61
+ * Check kinds where Zod itself installs a `when` guard
62
+ * (`!nullish(value) && value.length/size !== undefined`). Compiled output
63
+ * reproduces that gating structurally — length/size checks only run after the
64
+ * typeof/instanceof guard — so a `when` on these kinds is expected and safe.
65
+ * A `when` anywhere else must be user-supplied → fall back to Zod.
66
+ * (A user-supplied `when` on one of these six kinds is indistinguishable from
67
+ * the internal guard and remains unsupported.)
68
+ */
69
+ const INTERNAL_WHEN_CHECK_KINDS = /* @__PURE__ */ new Set([
70
+ "min_length",
71
+ "max_length",
72
+ "length_equals",
73
+ "min_size",
74
+ "max_size",
75
+ "size_equals"
72
76
  ]);
73
77
  /** True when a check carries a runtime `when` predicate we cannot reproduce. */
74
78
  function hasUserWhen(def) {
75
- return Boolean(def.when) && !INTERNAL_WHEN_CHECK_KINDS.has(def.check);
79
+ return Boolean(def.when) && !INTERNAL_WHEN_CHECK_KINDS.has(def.check);
76
80
  }
77
81
  /**
78
- * True when a check can't be compiled because of runtime modifiers:
79
- * a user-supplied `when` predicate, or `abort: true` (which stops later
80
- * checks and marks the option as aborted in union pruning — compiled
81
- * output always runs every check).
82
- */
83
- export function hasUncompilableModifiers(def) {
84
- return hasUserWhen(def) || def.abort === true;
82
+ * True when a check can't be compiled because of runtime modifiers:
83
+ * a user-supplied `when` predicate, or `abort: true` (which stops later
84
+ * checks and marks the option as aborted in union pruning — compiled
85
+ * output always runs every check).
86
+ */
87
+ function hasUncompilableModifiers(def) {
88
+ return hasUserWhen(def) || def.abort === true;
85
89
  }
86
- export function extractChecks(checks,
87
- /**
88
- * Registers the predicate of the check at `index` as an `__rf[N]` reference
89
- * and returns N, or undefined when references are unavailable (no refs array)
90
- * or the callback's shape cannot be called directly. Supplied by extractors
91
- * that know their schema's access path; omitted by callers that do not, which
92
- * simply keeps the old fall-back-to-zod behavior.
93
- */
94
- refineRef,
95
- /** Registers a payload-taking callback (superRefine); see payloadCheckRef. */
96
- payloadRefFor) {
97
- const checkIRs = [];
98
- let hasFallback = false;
99
- for (const [index, check] of checks.entries()) {
100
- const def = check._zod?.def;
101
- if (!def)
102
- continue;
103
- // Checks gated by a user-supplied runtime `when` predicate or abort:true
104
- // can't be reproduced in compiled output — delegate the schema to Zod.
105
- if (hasUncompilableModifiers(def)) {
106
- hasFallback = true;
107
- continue;
108
- }
109
- // Per-check custom error: bake static messages into the IR; error maps
110
- // that read the issue (dynamic) can't be compiled — fall back so Zod
111
- // produces the exact message.
112
- const resolved = resolveCheckMessage(def.error);
113
- if (resolved.kind === "dynamic") {
114
- hasFallback = true;
115
- continue;
116
- }
117
- const message = resolved.kind === "static" ? { message: resolved.message } : {};
118
- switch (def.check) {
119
- case "min_length":
120
- checkIRs.push({ kind: "min_length", minimum: def.minimum, ...message });
121
- break;
122
- case "max_length":
123
- checkIRs.push({ kind: "max_length", maximum: def.maximum, ...message });
124
- break;
125
- case "length_equals":
126
- checkIRs.push({ kind: "length_equals", length: def.length, ...message });
127
- break;
128
- case "greater_than":
129
- checkIRs.push({
130
- kind: "greater_than",
131
- value: def.value,
132
- inclusive: def.inclusive,
133
- ...message,
134
- });
135
- break;
136
- case "less_than":
137
- checkIRs.push({
138
- kind: "less_than",
139
- value: def.value,
140
- inclusive: def.inclusive,
141
- ...message,
142
- });
143
- break;
144
- case "multiple_of":
145
- checkIRs.push({ kind: "multiple_of", value: def.value, ...message });
146
- break;
147
- case "number_format":
148
- checkIRs.push({
149
- kind: "number_format",
150
- format: def.format,
151
- ...message,
152
- });
153
- break;
154
- case "string_format": {
155
- if (def.format === "includes" && typeof def.includes === "string") {
156
- checkIRs.push({
157
- kind: "includes",
158
- includes: def.includes,
159
- ...(typeof def.position === "number" ? { position: def.position } : {}),
160
- ...message,
161
- });
162
- break;
163
- }
164
- if (def.format === "starts_with" && typeof def.prefix === "string") {
165
- checkIRs.push({ kind: "starts_with", prefix: def.prefix, ...message });
166
- break;
167
- }
168
- if (def.format === "ends_with" && typeof def.suffix === "string") {
169
- checkIRs.push({ kind: "ends_with", suffix: def.suffix, ...message });
170
- break;
171
- }
172
- if (def.format === "url") {
173
- checkIRs.push({
174
- kind: "string_format",
175
- format: "url",
176
- ...regexFields("hostname", "hostnameFlags", def.hostname),
177
- ...regexFields("protocol", "protocolFlags", def.protocol),
178
- ...(def.normalize ? { normalize: true } : {}),
179
- ...message,
180
- });
181
- break;
182
- }
183
- if (NON_AUTHORITATIVE_PATTERN_FORMATS.has(def.format)) {
184
- hasFallback = true;
185
- break;
186
- }
187
- const pattern = def.pattern instanceof RegExp ? def.pattern.source : def.pattern;
188
- const flags = def.pattern instanceof RegExp && def.pattern.flags ? def.pattern.flags : "";
189
- if (!pattern && !PATTERNLESS_FORMATS.has(def.format)) {
190
- // Algorithmic format (e.g. jwt) — nothing to compile.
191
- hasFallback = true;
192
- break;
193
- }
194
- checkIRs.push({
195
- kind: "string_format",
196
- format: def.format,
197
- ...(pattern ? { pattern } : {}),
198
- ...(flags ? { patternFlags: flags } : {}),
199
- ...message,
200
- });
201
- break;
202
- }
203
- case "overwrite": {
204
- // $ZodCheckOverwrite (.trim(), .toLowerCase(), ...): value = def.tx(value)
205
- const source = tryCompileEffect(def.tx);
206
- if (source) {
207
- checkIRs.push({ kind: "overwrite_effect", source });
208
- }
209
- else {
210
- hasFallback = true;
211
- }
212
- break;
213
- }
214
- case "custom": {
215
- // superRefine / raw .check(): the callback collects issues from zod's
216
- // payload rather than returning a verdict, so it is referenced and
217
- // called with a synthesized payload (see SuperRefineEffectCheckIR).
218
- if (isPayloadCheck(check)) {
219
- const payloadRef = payloadRefFor?.(index);
220
- if (payloadRef === undefined) {
221
- hasFallback = true;
222
- break;
223
- }
224
- checkIRs.push({ kind: "super_refine_effect", refIndex: payloadRef });
225
- break;
226
- }
227
- // `.refine(fn, { path })` reports the issue against a member of the
228
- // refined value; anything but plain string/number segments is a shape
229
- // the generated path expression cannot reproduce.
230
- const customPath = Array.isArray(def.path) ? def.path : undefined;
231
- if (customPath?.some((p) => typeof p !== "string" && typeof p !== "number")) {
232
- hasFallback = true;
233
- break;
234
- }
235
- const pathIR = customPath && customPath.length > 0 ? { path: customPath } : {};
236
- const source = tryCompileEffect(def.fn);
237
- if (source) {
238
- checkIRs.push({ kind: "refine_effect", source, ...pathIR, ...message });
239
- break;
240
- }
241
- // Not inlineable (the predicate captures outer variables). Call the
242
- // user's own function object through a schema reference instead of
243
- // delegating: a captured `.refine()` at the root otherwise costs the
244
- // whole schema its compiled path.
245
- const refIndex = refineRef?.(index);
246
- if (refIndex !== undefined) {
247
- checkIRs.push({ kind: "refine_effect", refIndex, ...pathIR, ...message });
248
- }
249
- else {
250
- hasFallback = true;
251
- }
252
- break;
253
- }
254
- default:
255
- // Unknown check kind — never drop silently; delegate to Zod.
256
- hasFallback = true;
257
- break;
258
- }
259
- }
260
- return { checkIRs, hasFallback };
90
+ function extractChecks(checks, refineRef, payloadRefFor) {
91
+ const checkIRs = [];
92
+ let hasFallback = false;
93
+ for (const [index, check] of checks.entries()) {
94
+ const def = check._zod?.def;
95
+ if (!def) continue;
96
+ if (hasUncompilableModifiers(def)) {
97
+ hasFallback = true;
98
+ continue;
99
+ }
100
+ const resolved = resolveCheckMessage(def.error);
101
+ if (resolved.kind === "dynamic") {
102
+ hasFallback = true;
103
+ continue;
104
+ }
105
+ const message = resolved.kind === "static" ? { message: resolved.message } : {};
106
+ switch (def.check) {
107
+ case "min_length":
108
+ checkIRs.push({
109
+ kind: "min_length",
110
+ minimum: def.minimum,
111
+ ...message
112
+ });
113
+ break;
114
+ case "max_length":
115
+ checkIRs.push({
116
+ kind: "max_length",
117
+ maximum: def.maximum,
118
+ ...message
119
+ });
120
+ break;
121
+ case "length_equals":
122
+ checkIRs.push({
123
+ kind: "length_equals",
124
+ length: def.length,
125
+ ...message
126
+ });
127
+ break;
128
+ case "greater_than":
129
+ checkIRs.push({
130
+ kind: "greater_than",
131
+ value: def.value,
132
+ inclusive: def.inclusive,
133
+ ...message
134
+ });
135
+ break;
136
+ case "less_than":
137
+ checkIRs.push({
138
+ kind: "less_than",
139
+ value: def.value,
140
+ inclusive: def.inclusive,
141
+ ...message
142
+ });
143
+ break;
144
+ case "multiple_of":
145
+ checkIRs.push({
146
+ kind: "multiple_of",
147
+ value: def.value,
148
+ ...message
149
+ });
150
+ break;
151
+ case "number_format":
152
+ checkIRs.push({
153
+ kind: "number_format",
154
+ format: def.format,
155
+ ...message
156
+ });
157
+ break;
158
+ case "string_format": {
159
+ if (def.format === "includes" && typeof def.includes === "string") {
160
+ checkIRs.push({
161
+ kind: "includes",
162
+ includes: def.includes,
163
+ ...typeof def.position === "number" ? { position: def.position } : {},
164
+ ...message
165
+ });
166
+ break;
167
+ }
168
+ if (def.format === "starts_with" && typeof def.prefix === "string") {
169
+ checkIRs.push({
170
+ kind: "starts_with",
171
+ prefix: def.prefix,
172
+ ...message
173
+ });
174
+ break;
175
+ }
176
+ if (def.format === "ends_with" && typeof def.suffix === "string") {
177
+ checkIRs.push({
178
+ kind: "ends_with",
179
+ suffix: def.suffix,
180
+ ...message
181
+ });
182
+ break;
183
+ }
184
+ if (def.format === "url") {
185
+ checkIRs.push({
186
+ kind: "string_format",
187
+ format: "url",
188
+ ...regexFields("hostname", "hostnameFlags", def.hostname),
189
+ ...regexFields("protocol", "protocolFlags", def.protocol),
190
+ ...def.normalize ? { normalize: true } : {},
191
+ ...message
192
+ });
193
+ break;
194
+ }
195
+ if (NON_AUTHORITATIVE_PATTERN_FORMATS.has(def.format)) {
196
+ hasFallback = true;
197
+ break;
198
+ }
199
+ const pattern = def.pattern instanceof RegExp ? def.pattern.source : def.pattern;
200
+ const flags = def.pattern instanceof RegExp && def.pattern.flags ? def.pattern.flags : "";
201
+ if (!pattern && !PATTERNLESS_FORMATS.has(def.format)) {
202
+ hasFallback = true;
203
+ break;
204
+ }
205
+ checkIRs.push({
206
+ kind: "string_format",
207
+ format: def.format,
208
+ ...pattern ? { pattern } : {},
209
+ ...flags ? { patternFlags: flags } : {},
210
+ ...message
211
+ });
212
+ break;
213
+ }
214
+ case "overwrite": {
215
+ const source = tryCompileEffect(def.tx);
216
+ if (source) checkIRs.push({
217
+ kind: "overwrite_effect",
218
+ source
219
+ });
220
+ else hasFallback = true;
221
+ break;
222
+ }
223
+ case "custom": {
224
+ if (isPayloadCheck(check)) {
225
+ const payloadRef = payloadRefFor?.(index);
226
+ if (payloadRef === void 0) {
227
+ hasFallback = true;
228
+ break;
229
+ }
230
+ checkIRs.push({
231
+ kind: "super_refine_effect",
232
+ refIndex: payloadRef
233
+ });
234
+ break;
235
+ }
236
+ const customPath = Array.isArray(def.path) ? def.path : void 0;
237
+ if (customPath?.some((p) => typeof p !== "string" && typeof p !== "number")) {
238
+ hasFallback = true;
239
+ break;
240
+ }
241
+ const pathIR = customPath && customPath.length > 0 ? { path: customPath } : {};
242
+ const source = tryCompileEffect(def.fn);
243
+ if (source) {
244
+ checkIRs.push({
245
+ kind: "refine_effect",
246
+ source,
247
+ ...pathIR,
248
+ ...message
249
+ });
250
+ break;
251
+ }
252
+ const refIndex = refineRef?.(index);
253
+ if (refIndex !== void 0) checkIRs.push({
254
+ kind: "refine_effect",
255
+ refIndex,
256
+ ...pathIR,
257
+ ...message
258
+ });
259
+ else hasFallback = true;
260
+ break;
261
+ }
262
+ default:
263
+ hasFallback = true;
264
+ break;
265
+ }
266
+ }
267
+ return {
268
+ checkIRs,
269
+ hasFallback
270
+ };
261
271
  }
262
272
  function regexFields(sourceKey, flagsKey, value) {
263
- if (!(value instanceof RegExp))
264
- return {};
265
- return { [sourceKey]: value.source, ...(value.flags ? { [flagsKey]: value.flags } : {}) };
273
+ if (!(value instanceof RegExp)) return {};
274
+ return {
275
+ [sourceKey]: value.source,
276
+ ...value.flags ? { [flagsKey]: value.flags } : {}
277
+ };
266
278
  }
267
279
  /**
268
- * Classify a check/schema-level `error` param.
269
- *
270
- * Zod normalizes `.min(3, "msg")` / `{ error: "msg" }` / `{ message: "msg" }`
271
- * into an error-map function that ignores its issue argument and returns the
272
- * string. We call the function with an access-tracking Proxy: if it never
273
- * inspects the issue, its return value is a constant we can bake into the
274
- * generated issue. If it reads any issue property (input-dependent message),
275
- * it is dynamic and the schema must fall back to Zod for exact messages.
276
- */
277
- export function resolveCheckMessage(error) {
278
- if (error === null || error === undefined)
279
- return { kind: "none" };
280
- if (typeof error === "string")
281
- return { kind: "static", message: error };
282
- if (typeof error !== "function")
283
- return { kind: "dynamic" };
284
- let accessed = false;
285
- const track = () => {
286
- accessed = true;
287
- };
288
- const probe = new Proxy({}, {
289
- get(_t, prop) {
290
- track();
291
- // Avoid breaking string coercion / await probing inside error maps.
292
- if (prop === Symbol.toPrimitive || prop === "toString" || prop === "valueOf") {
293
- return () => "";
294
- }
295
- return undefined;
296
- },
297
- has() {
298
- track();
299
- return false;
300
- },
301
- ownKeys() {
302
- track();
303
- return [];
304
- },
305
- getOwnPropertyDescriptor() {
306
- track();
307
- return undefined;
308
- },
309
- });
310
- let result;
311
- try {
312
- result = error(probe);
313
- }
314
- catch {
315
- return { kind: "dynamic" };
316
- }
317
- if (accessed)
318
- return { kind: "dynamic" };
319
- if (typeof result === "string")
320
- return { kind: "static", message: result };
321
- if (result !== null &&
322
- typeof result === "object" &&
323
- typeof result.message === "string") {
324
- return { kind: "static", message: result.message };
325
- }
326
- // Error map deferred (returned undefined) — no custom message.
327
- if (result === undefined)
328
- return { kind: "none" };
329
- return { kind: "dynamic" };
280
+ * Classify a check/schema-level `error` param.
281
+ *
282
+ * Zod normalizes `.min(3, "msg")` / `{ error: "msg" }` / `{ message: "msg" }`
283
+ * into an error-map function that ignores its issue argument and returns the
284
+ * string. We call the function with an access-tracking Proxy: if it never
285
+ * inspects the issue, its return value is a constant we can bake into the
286
+ * generated issue. If it reads any issue property (input-dependent message),
287
+ * it is dynamic and the schema must fall back to Zod for exact messages.
288
+ */
289
+ function resolveCheckMessage(error) {
290
+ if (error === null || error === void 0) return { kind: "none" };
291
+ if (typeof error === "string") return {
292
+ kind: "static",
293
+ message: error
294
+ };
295
+ if (typeof error !== "function") return { kind: "dynamic" };
296
+ let accessed = false;
297
+ const track = () => {
298
+ accessed = true;
299
+ };
300
+ const probe = new Proxy({}, {
301
+ get(_t, prop) {
302
+ track();
303
+ if (prop === Symbol.toPrimitive || prop === "toString" || prop === "valueOf") return () => "";
304
+ },
305
+ has() {
306
+ track();
307
+ return false;
308
+ },
309
+ ownKeys() {
310
+ track();
311
+ return [];
312
+ },
313
+ getOwnPropertyDescriptor() {
314
+ track();
315
+ }
316
+ });
317
+ let result;
318
+ try {
319
+ result = error(probe);
320
+ } catch {
321
+ return { kind: "dynamic" };
322
+ }
323
+ if (accessed) return { kind: "dynamic" };
324
+ if (typeof result === "string") return {
325
+ kind: "static",
326
+ message: result
327
+ };
328
+ if (result !== null && typeof result === "object" && typeof result.message === "string") return {
329
+ kind: "static",
330
+ message: result.message
331
+ };
332
+ if (result === void 0) return { kind: "none" };
333
+ return { kind: "dynamic" };
330
334
  }
335
+ //#endregion
336
+ export { extractChecks, hasUncompilableModifiers, payloadCheckRef, refineRefRegistrar, resolveCheckMessage };
337
+
331
338
  //# sourceMappingURL=checks.js.map