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,490 +1,416 @@
1
- import { fastTestSource, lookupWellKnownRegex, wellKnownRegexSourceName, } from "./well-known-regex.js";
1
+ import { fastTestSource, lookupWellKnownRegex, wellKnownRegexSourceName } from "./well-known-regex.js";
2
+ //#region src/core/codegen/context.ts
2
3
  /** `var a,b;` declaration for a scope's temps, or "" when it allocated none. */
3
- export function declareFastTemps(scope) {
4
- return scope.temps.length > 0 ? `var ${scope.temps.join(",")};` : "";
4
+ function declareFastTemps(scope) {
5
+ return scope.temps.length > 0 ? `var ${scope.temps.join(",")};` : "";
5
6
  }
6
7
  /**
7
- * Fast check for a wrapper that compares its input against a sentinel and
8
- * otherwise delegates to an inner schema — `optional` (`===undefined`),
9
- * `nullable` (`===null`) and `default` (`!==undefined`).
10
- *
11
- * Written naively these read the input TWICE: once for the sentinel test and
12
- * again inside the inner check (which may itself read it several more times —
13
- * `typeof x==="string"&&x.length>=3&&x.length<=20`). V8's load elimination
14
- * removes the repeats only while the access is monomorphic; on the polymorphic
15
- * and megamorphic call sites real payloads produce (an array of objects with
16
- * differing key order, anything out of `JSON.parse`) every repeat is a fresh
17
- * megamorphic lookup. Binding the value to a local once is worth 1.1-1.7x on
18
- * the whole object check when the optional key is present, and is neutral when
19
- * it is absent.
20
- *
21
- * Only hoisted when the input is a property access; a bare local (an array
22
- * element variable, a record value) is already a single load, so it keeps the
23
- * shorter form and byte-identical output.
24
- */
25
- export function fastSentinelWrapper(g, innerIR, sentinel, joiner) {
26
- if (!isPropertyAccess(g.input)) {
27
- const inner = g.visit(innerIR);
28
- return inner === null ? null : `(${g.input}${sentinel}${joiner}(${inner}))`;
29
- }
30
- const value = g.local("w");
31
- const inner = g.visit(innerIR, { input: value });
32
- if (inner === null)
33
- return null;
34
- return `((${value}=${g.input})${sentinel}${joiner}(${inner}))`;
8
+ * Fast check for a wrapper that compares its input against a sentinel and
9
+ * otherwise delegates to an inner schema — `optional` (`===undefined`),
10
+ * `nullable` (`===null`) and `default` (`!==undefined`).
11
+ *
12
+ * Written naively these read the input TWICE: once for the sentinel test and
13
+ * again inside the inner check (which may itself read it several more times —
14
+ * `typeof x==="string"&&x.length>=3&&x.length<=20`). V8's load elimination
15
+ * removes the repeats only while the access is monomorphic; on the polymorphic
16
+ * and megamorphic call sites real payloads produce (an array of objects with
17
+ * differing key order, anything out of `JSON.parse`) every repeat is a fresh
18
+ * megamorphic lookup. Binding the value to a local once is worth 1.1-1.7x on
19
+ * the whole object check when the optional key is present, and is neutral when
20
+ * it is absent.
21
+ *
22
+ * Only hoisted when the input is a property access; a bare local (an array
23
+ * element variable, a record value) is already a single load, so it keeps the
24
+ * shorter form and byte-identical output.
25
+ */
26
+ function fastSentinelWrapper(g, innerIR, sentinel, joiner) {
27
+ if (!isPropertyAccess(g.input)) {
28
+ const inner = g.visit(innerIR);
29
+ return inner === null ? null : `(${g.input}${sentinel}${joiner}(${inner}))`;
30
+ }
31
+ const value = g.local("w");
32
+ const inner = g.visit(innerIR, { input: value });
33
+ if (inner === null) return null;
34
+ return `((${value}=${g.input})${sentinel}${joiner}(${inner}))`;
35
35
  }
36
36
  /** True for an expression that performs a property load (`x["a"]`, `x.a`, `x[0][1]`). */
37
37
  function isPropertyAccess(expr) {
38
- return expr.includes("[") || expr.includes(".");
38
+ return expr.includes("[") || expr.includes(".");
39
39
  }
40
- // ─── Shared emit helpers (used by both slow-path and fast-path factories) ────
41
40
  /** Allocate a fresh `__${prefix}_${n}` identifier and bump the shared counter. */
42
- export function emitTemp(ctx, prefix) {
43
- return `__${prefix}_${ctx.counter++}`;
41
+ function emitTemp(ctx, prefix) {
42
+ return `__${prefix}_${ctx.counter++}`;
44
43
  }
45
44
  /**
46
- * Host a zero-capture effect function (refine predicate, transform,
47
- * overwrite) in the preamble and return its variable name. The inline
48
- * `(${source})(x)` form evaluates the function expression — allocating a
49
- * function object — on EVERY parse at every effect site, including inside
50
- * the "zero-allocation" fast chain. V8's escape analysis erases that in
51
- * optimized frames, but interpreter/baseline/deopt frames pay it, and the
52
- * full source text re-parses as bytecode at each site. Zero-capture sources
53
- * reference only their own parameters and safe globals by construction, so
54
- * a single preamble binding is semantically identical. Deduped per schema
55
- * by source text.
56
- */
57
- export function emitEffectFn(ctx, source) {
58
- ctx.effectFnCache ??= new Map();
59
- const cached = ctx.effectFnCache.get(source);
60
- if (cached !== undefined)
61
- return cached;
62
- const name = `__ef_${ctx.counter++}`;
63
- ctx.preamble.push(`var ${name}=(${source});`);
64
- ctx.effectFnCache.set(source, name);
65
- return name;
45
+ * Host a zero-capture effect function (refine predicate, transform,
46
+ * overwrite) in the preamble and return its variable name. The inline
47
+ * `(${source})(x)` form evaluates the function expression — allocating a
48
+ * function object — on EVERY parse at every effect site, including inside
49
+ * the "zero-allocation" fast chain. V8's escape analysis erases that in
50
+ * optimized frames, but interpreter/baseline/deopt frames pay it, and the
51
+ * full source text re-parses as bytecode at each site. Zero-capture sources
52
+ * reference only their own parameters and safe globals by construction, so
53
+ * a single preamble binding is semantically identical. Deduped per schema
54
+ * by source text.
55
+ */
56
+ function emitEffectFn(ctx, source) {
57
+ ctx.effectFnCache ??= /* @__PURE__ */ new Map();
58
+ const cached = ctx.effectFnCache.get(source);
59
+ if (cached !== void 0) return cached;
60
+ const name = `__ef_${ctx.counter++}`;
61
+ ctx.preamble.push(`var ${name}=(${source});`);
62
+ ctx.effectFnCache.set(source, name);
63
+ return name;
66
64
  }
67
65
  /**
68
- * Callable expression for a user callback — a refine predicate or a transform.
69
- *
70
- * A zero-capture callback is hosted from its source text; one that CAPTURES
71
- * outer variables is called by reference through `__rf[N]` — the user's own
72
- * function object, reached from the schema — instead of costing the schema its
73
- * compiled path. The reference is aliased into a preamble binding rather than
74
- * re-read per call, for the same reason call-invoked helpers are (a per-call
75
- * array element load is not a foldable callee).
76
- */
77
- export function emitEffectCallable(ctx, effect) {
78
- if (effect.refIndex !== undefined)
79
- return emitConstant(ctx, "rfn", `__rf[${effect.refIndex}]`);
80
- if (effect.source === undefined) {
81
- throw new Error("effect has neither inlineable source nor a reference index");
82
- }
83
- return emitEffectFn(ctx, effect.source);
66
+ * Callable expression for a user callback — a refine predicate or a transform.
67
+ *
68
+ * A zero-capture callback is hosted from its source text; one that CAPTURES
69
+ * outer variables is called by reference through `__rf[N]` — the user's own
70
+ * function object, reached from the schema — instead of costing the schema its
71
+ * compiled path. The reference is aliased into a preamble binding rather than
72
+ * re-read per call, for the same reason call-invoked helpers are (a per-call
73
+ * array element load is not a foldable callee).
74
+ */
75
+ function emitEffectCallable(ctx, effect) {
76
+ if (effect.refIndex !== void 0) return emitConstant(ctx, "rfn", `__rf[${effect.refIndex}]`);
77
+ if (effect.source === void 0) throw new Error("effect has neither inlineable source nor a reference index");
78
+ return emitEffectFn(ctx, effect.source);
84
79
  }
85
80
  /**
86
- * Pristine fallback delegate: declare `var __rfp_N=__rf[N].safeParse.bind(__rf[N]);`
87
- * in the preamble and return the variable name. Generated code must NEVER read
88
- * `__rf[N].safeParse` at parse time: `__zcMkv` installs the compiled safeParse as
89
- * an OWN property on the original schema object, and whenever `__rf[N]` is that
90
- * same object the read resolves to the compiled delegate itself — infinite
91
- * recursion (RangeError on every parse). The fallback entry and the __zcMkv
92
- * target ARE the same object in compile mode (schemaExpr is the compile()
93
- * argument identifier) and the CLI emitter ((__src_X as any).schema); in
94
- * autoDiscover mode they are two textually identical constructions that any
95
- * downstream CSE/dedup transform (babel-plugin-zod-hoist in a field incident)
96
- * collapses back into one. Capturing at IIFE evaluation — before the trailing
97
- * `return __zcMkv(...)` mutates anything — pins zod's own implementation; the
98
- * worst case under cross-validator merges is delegating to an equivalent
99
- * compiled validator (whose own delegates were captured even earlier), never
100
- * a cycle.
101
- */
102
- export function emitRfDelegate(ctx, refIndex) {
103
- const name = `__rfp_${refIndex}`;
104
- const decl = `var ${name}=__rf[${refIndex}].safeParse.bind(__rf[${refIndex}]);`;
105
- if (!ctx.preamble.includes(decl)) {
106
- ctx.preamble.push(decl);
107
- }
108
- return name;
81
+ * Pristine fallback delegate: declare `var __rfp_N=__rf[N].safeParse.bind(__rf[N]);`
82
+ * in the preamble and return the variable name. Generated code must NEVER read
83
+ * `__rf[N].safeParse` at parse time: `__zcMkv` installs the compiled safeParse as
84
+ * an OWN property on the original schema object, and whenever `__rf[N]` is that
85
+ * same object the read resolves to the compiled delegate itself — infinite
86
+ * recursion (RangeError on every parse). The fallback entry and the __zcMkv
87
+ * target ARE the same object in compile mode (schemaExpr is the compile()
88
+ * argument identifier) and the CLI emitter ((__src_X as any).schema); in
89
+ * autoDiscover mode they are two textually identical constructions that any
90
+ * downstream CSE/dedup transform (babel-plugin-zod-hoist in a field incident)
91
+ * collapses back into one. Capturing at IIFE evaluation — before the trailing
92
+ * `return __zcMkv(...)` mutates anything — pins zod's own implementation; the
93
+ * worst case under cross-validator merges is delegating to an equivalent
94
+ * compiled validator (whose own delegates were captured even earlier), never
95
+ * a cycle.
96
+ */
97
+ function emitRfDelegate(ctx, refIndex) {
98
+ const name = `__rfp_${refIndex}`;
99
+ const decl = `var ${name}=__rf[${refIndex}].safeParse.bind(__rf[${refIndex}]);`;
100
+ if (!ctx.preamble.includes(decl)) ctx.preamble.push(decl);
101
+ return name;
109
102
  }
110
103
  /**
111
- * Resolve a regex pattern to a runtime variable name.
112
- * Lean mode short-circuits well-known patterns to virtual-module names so the
113
- * bundler can dedup across files; everything else is cached + declared in the
114
- * per-IIFE preamble exactly once per pattern.
115
- */
116
- export function emitRegex(ctx, prefix, pattern, flags) {
117
- if (ctx.mode === "lean" && !flags) {
118
- const wellKnown = lookupWellKnownRegex(pattern);
119
- if (wellKnown !== null) {
120
- ctx.usedHelpers.add(wellKnown);
121
- return wellKnown;
122
- }
123
- }
124
- const cacheKey = flags ? `${flags}\u0000${pattern}` : pattern;
125
- const cached = ctx.regexCache.get(cacheKey);
126
- if (cached)
127
- return cached;
128
- const name = `__re_${prefix}_${ctx.counter++}`;
129
- const flagsArg = flags ? `,${escapeString(flags)}` : "";
130
- // Flag-less patterns may carry a faster behavior-equivalent rewrite (a
131
- // well-known table entry, repeat unrolling, or both); the regex OBJECT uses
132
- // it while issue sites keep reporting the original pattern (see slowString).
133
- const testSource = flags ? null : fastTestSource(pattern);
134
- ctx.preamble.push(`var ${name}=new RegExp(${escapeString(testSource ?? pattern)}${flagsArg});`);
135
- ctx.regexCache.set(cacheKey, name);
136
- return name;
104
+ * Resolve a regex pattern to a runtime variable name.
105
+ * Lean mode short-circuits well-known patterns to virtual-module names so the
106
+ * bundler can dedup across files; everything else is cached + declared in the
107
+ * per-IIFE preamble exactly once per pattern.
108
+ */
109
+ function emitRegex(ctx, prefix, pattern, flags) {
110
+ if (ctx.mode === "lean" && !flags) {
111
+ const wellKnown = lookupWellKnownRegex(pattern);
112
+ if (wellKnown !== null) {
113
+ ctx.usedHelpers.add(wellKnown);
114
+ return wellKnown;
115
+ }
116
+ }
117
+ const cacheKey = flags ? `${flags}\u0000${pattern}` : pattern;
118
+ const cached = ctx.regexCache.get(cacheKey);
119
+ if (cached) return cached;
120
+ const name = `__re_${prefix}_${ctx.counter++}`;
121
+ const flagsArg = flags ? `,${escapeString(flags)}` : "";
122
+ const testSource = flags ? null : fastTestSource(pattern);
123
+ ctx.preamble.push(`var ${name}=new RegExp(${escapeString(testSource ?? pattern)}${flagsArg});`);
124
+ ctx.regexCache.set(cacheKey, name);
125
+ return name;
137
126
  }
138
127
  /**
139
- * Resolve the ORIGINAL `/source/flags` pattern string of a regex for issue
140
- * reporting. Only needed when emitRegex swapped in a faster equivalent test
141
- * pattern (the runtime regex's toString() would leak the rewrite). Lean mode
142
- * references the shared `<name>Src` virtual export so the original pattern
143
- * stays a single bundle-wide string; inline mode declares it once per IIFE.
144
- */
145
- export function emitRegexSourceString(ctx, pattern) {
146
- if (ctx.mode === "lean") {
147
- const srcName = wellKnownRegexSourceName(pattern);
148
- if (srcName !== null) {
149
- ctx.usedHelpers.add(srcName);
150
- return srcName;
151
- }
152
- }
153
- const cacheKey = `src\u0000${pattern}`;
154
- const cached = ctx.regexCache.get(cacheKey);
155
- if (cached)
156
- return cached;
157
- const name = `__res_${ctx.counter++}`;
158
- ctx.preamble.push(`var ${name}=${escapeString(`/${pattern}/`)};`);
159
- ctx.regexCache.set(cacheKey, name);
160
- return name;
128
+ * Resolve the ORIGINAL `/source/flags` pattern string of a regex for issue
129
+ * reporting. Only needed when emitRegex swapped in a faster equivalent test
130
+ * pattern (the runtime regex's toString() would leak the rewrite). Lean mode
131
+ * references the shared `<name>Src` virtual export so the original pattern
132
+ * stays a single bundle-wide string; inline mode declares it once per IIFE.
133
+ */
134
+ function emitRegexSourceString(ctx, pattern) {
135
+ if (ctx.mode === "lean") {
136
+ const srcName = wellKnownRegexSourceName(pattern);
137
+ if (srcName !== null) {
138
+ ctx.usedHelpers.add(srcName);
139
+ return srcName;
140
+ }
141
+ }
142
+ const cacheKey = `src\u0000${pattern}`;
143
+ const cached = ctx.regexCache.get(cacheKey);
144
+ if (cached) return cached;
145
+ const name = `__res_${ctx.counter++}`;
146
+ ctx.preamble.push(`var ${name}=${escapeString(`/${pattern}/`)};`);
147
+ ctx.regexCache.set(cacheKey, name);
148
+ return name;
161
149
  }
162
150
  /**
163
- * Declare a constant value in the preamble and return its variable name,
164
- * reusing an earlier declaration of the SAME initializer.
165
- *
166
- * Value tables are reached from both halves of a validator — an enum's `Set`
167
- * from its fast check and again from its slow walk, a strict shape's key table
168
- * likewise — and repeat across sibling properties that share a value list. One
169
- * declaration per USE emitted the payload two or four times: measured 17% of a
170
- * 20-value enum schema's generated bytes, 16% for an object with two identical
171
- * enums. Keyed by initializer text, so only identical payloads collapse.
172
- */
173
- export function emitConstant(ctx, prefix, initializer) {
174
- ctx.valueCache ??= new Map();
175
- const cached = ctx.valueCache.get(initializer);
176
- if (cached !== undefined)
177
- return cached;
178
- const name = `__${prefix}_${ctx.counter++}`;
179
- ctx.preamble.push(`var ${name}=${initializer};`);
180
- ctx.valueCache.set(initializer, name);
181
- return name;
151
+ * Declare a constant value in the preamble and return its variable name,
152
+ * reusing an earlier declaration of the SAME initializer.
153
+ *
154
+ * Value tables are reached from both halves of a validator — an enum's `Set`
155
+ * from its fast check and again from its slow walk, a strict shape's key table
156
+ * likewise — and repeat across sibling properties that share a value list. One
157
+ * declaration per USE emitted the payload two or four times: measured 17% of a
158
+ * 20-value enum schema's generated bytes, 16% for an object with two identical
159
+ * enums. Keyed by initializer text, so only identical payloads collapse.
160
+ */
161
+ function emitConstant(ctx, prefix, initializer) {
162
+ ctx.valueCache ??= /* @__PURE__ */ new Map();
163
+ const cached = ctx.valueCache.get(initializer);
164
+ if (cached !== void 0) return cached;
165
+ const name = `__${prefix}_${ctx.counter++}`;
166
+ ctx.preamble.push(`var ${name}=${initializer};`);
167
+ ctx.valueCache.set(initializer, name);
168
+ return name;
182
169
  }
183
170
  /** Declare a `new Set([...])` in the preamble and return its variable name. */
184
- export function emitSet(ctx, prefix, values) {
185
- return emitConstant(ctx, `set_${prefix}`, `new Set(${JSON.stringify([...values])})`);
171
+ function emitSet(ctx, prefix, values) {
172
+ return emitConstant(ctx, `set_${prefix}`, `new Set(${JSON.stringify([...values])})`);
186
173
  }
187
174
  /**
188
- * Shape-key count at or below which the unknown-key pass compares with an
189
- * inline `===` chain rather than a hashed lookup.
190
- *
191
- * This is deliberately NOT {@link ENUM_INLINE_THRESHOLD}: the two look alike but
192
- * are different workloads. An enum compares schema literals against arbitrary
193
- * INPUT strings, which may be long, share prefixes, and are not necessarily
194
- * internalized — so a hashed set earns its keep quickly. A shape-key test
195
- * compares them against keys arriving from `for-in`, i.e. the object's own
196
- * internalized key strings, so every arm of the chain is a pointer compare that
197
- * V8 predicts perfectly, while `table[k]` / `set.has(k)` pays a string hash and
198
- * probe per key.
199
- *
200
- * Measured over a strict object's for-in pass (JSON-parsed input, 8 rotated
201
- * shapes), `===` chain vs the previous `{k:1}` table: 3.7x at 6 keys, 3.8x at
202
- * 10, 3.1x at 20, 3.1x at 48 — the chain still leads at 64 (283 ns vs 690) and
203
- * only loses past ~96, where `Set.has` (not the table, which never wins at any
204
- * size) takes over. 64 sits below that crossover and above any realistic shape.
205
- */
206
- export const KEY_MEMBERSHIP_INLINE_THRESHOLD = 64;
175
+ * Shape-key count at or below which the unknown-key pass compares with an
176
+ * inline `===` chain rather than a hashed lookup.
177
+ *
178
+ * This is deliberately NOT {@link ENUM_INLINE_THRESHOLD}: the two look alike but
179
+ * are different workloads. An enum compares schema literals against arbitrary
180
+ * INPUT strings, which may be long, share prefixes, and are not necessarily
181
+ * internalized — so a hashed set earns its keep quickly. A shape-key test
182
+ * compares them against keys arriving from `for-in`, i.e. the object's own
183
+ * internalized key strings, so every arm of the chain is a pointer compare that
184
+ * V8 predicts perfectly, while `table[k]` / `set.has(k)` pays a string hash and
185
+ * probe per key.
186
+ *
187
+ * Measured over a strict object's for-in pass (JSON-parsed input, 8 rotated
188
+ * shapes), `===` chain vs the previous `{k:1}` table: 3.7x at 6 keys, 3.8x at
189
+ * 10, 3.1x at 20, 3.1x at 48 — the chain still leads at 64 (283 ns vs 690) and
190
+ * only loses past ~96, where `Set.has` (not the table, which never wins at any
191
+ * size) takes over. 64 sits below that crossover and above any realistic shape.
192
+ */
193
+ const KEY_MEMBERSHIP_INLINE_THRESHOLD = 64;
207
194
  /**
208
- * Boolean membership test for one key variable against a fixed key list.
209
- * Empty list recognizes nothing.
210
- *
211
- * `Set.has` is the large-shape fallback rather than a `{key:1}` object table:
212
- * the table is also `__proto__`-hostile (an own `__proto__` key cannot be set
213
- * by an object literal, so that key would silently read as unknown), which the
214
- * Set has no trouble with.
215
- */
216
- export function keyMembershipTest(ctx, keys, keyVar) {
217
- if (keys.length === 0)
218
- return "false";
219
- if (keys.length <= KEY_MEMBERSHIP_INLINE_THRESHOLD) {
220
- return keys.map((k) => `${keyVar}===${escapeString(k)}`).join("||");
221
- }
222
- return `${emitSet(ctx, "ks", keys)}.has(${keyVar})`;
195
+ * Boolean membership test for one key variable against a fixed key list.
196
+ * Empty list recognizes nothing.
197
+ *
198
+ * `Set.has` is the large-shape fallback rather than a `{key:1}` object table:
199
+ * the table is also `__proto__`-hostile (an own `__proto__` key cannot be set
200
+ * by an object literal, so that key would silently read as unknown), which the
201
+ * Set has no trouble with.
202
+ */
203
+ function keyMembershipTest(ctx, keys, keyVar) {
204
+ if (keys.length === 0) return "false";
205
+ if (keys.length <= 64) return keys.map((k) => `${keyVar}===${escapeString(k)}`).join("||");
206
+ return `${emitSet(ctx, "ks", keys)}.has(${keyVar})`;
223
207
  }
224
208
  /**
225
- * Enum values at or below this count use inline === checks instead of Set.has().
226
- * Measured on V8: for ≤5 values, an === chain beats Set.has by up to ~3x with
227
- * realistic (distinct-prefix, JSON-parsed) values — V8 internalizes strings on
228
- * successful comparison, making subsequent arms pointer-equality — and is no
229
- * worse than Set.has even with adversarial shared-prefix values.
230
- */
231
- export const ENUM_INLINE_THRESHOLD = 5;
209
+ * Enum values at or below this count use inline === checks instead of Set.has().
210
+ * Measured on V8: for ≤5 values, an === chain beats Set.has by up to ~3x with
211
+ * realistic (distinct-prefix, JSON-parsed) values — V8 internalizes strings on
212
+ * successful comparison, making subsequent arms pointer-equality — and is no
213
+ * worse than Set.has even with adversarial shared-prefix values.
214
+ */
215
+ const ENUM_INLINE_THRESHOLD = 5;
232
216
  const CHECK_PRIORITY = {
233
- // Cheapest: length/size comparisons (O(1))
234
- min_length: 10,
235
- max_length: 11,
236
- length_equals: 12,
237
- min_size: 13,
238
- max_size: 14,
239
- // Number format checks (comparison + bitwise)
240
- number_format: 15,
241
- // Range comparisons
242
- greater_than: 20,
243
- less_than: 21,
244
- bigint_greater_than: 20,
245
- bigint_less_than: 21,
246
- date_greater_than: 22,
247
- date_less_than: 23,
248
- // Modulo
249
- multiple_of: 30,
250
- bigint_multiple_of: 30,
251
- // String prefix/suffix (O(prefix/suffix length))
252
- starts_with: 40,
253
- ends_with: 41,
254
- // String search (O(n·m) worst case)
255
- includes: 42,
256
- // Regex (most expensive)
257
- string_format: 50,
217
+ min_length: 10,
218
+ max_length: 11,
219
+ length_equals: 12,
220
+ min_size: 13,
221
+ max_size: 14,
222
+ number_format: 15,
223
+ greater_than: 20,
224
+ less_than: 21,
225
+ bigint_greater_than: 20,
226
+ bigint_less_than: 21,
227
+ date_greater_than: 22,
228
+ date_less_than: 23,
229
+ multiple_of: 30,
230
+ bigint_multiple_of: 30,
231
+ starts_with: 40,
232
+ ends_with: 41,
233
+ includes: 42,
234
+ string_format: 50
258
235
  };
259
- export function escapeString(s) {
260
- return JSON.stringify(s);
236
+ function escapeString(s) {
237
+ return JSON.stringify(s);
261
238
  }
262
239
  /**
263
- * JS source for a primitive literal value (literal schemas, discriminator
264
- * case labels). JSON.stringify covers string/number/boolean/null; bigint
265
- * needs the `n` suffix (JSON.stringify throws and String(5n) renders a
266
- * number literal that never strict-equals a bigint); undefined isn't JSON.
267
- */
268
- export function literalToJs(v) {
269
- if (typeof v === "bigint")
270
- return `${v}n`;
271
- if (v === undefined)
272
- return "undefined";
273
- // JSON.stringify maps NaN/±Infinity to "null"; emit them as JS expressions so a
274
- // non-finite numeric literal round-trips (z.literal(Infinity) must compare
275
- // against Infinity, not null). String(NaN)="NaN", String(Infinity)="Infinity",
276
- // String(-Infinity)="-Infinity" — all valid JS that evaluate to the value.
277
- if (typeof v === "number" && !Number.isFinite(v))
278
- return String(v);
279
- return JSON.stringify(v);
240
+ * JS source for a primitive literal value (literal schemas, discriminator
241
+ * case labels). JSON.stringify covers string/number/boolean/null; bigint
242
+ * needs the `n` suffix (JSON.stringify throws and String(5n) renders a
243
+ * number literal that never strict-equals a bigint); undefined isn't JSON.
244
+ */
245
+ function literalToJs(v) {
246
+ if (typeof v === "bigint") return `${v}n`;
247
+ if (v === void 0) return "undefined";
248
+ if (typeof v === "number" && !Number.isFinite(v)) return String(v);
249
+ return JSON.stringify(v);
280
250
  }
281
251
  /**
282
- * Helpers that generated code invokes through `Function.prototype.call`, and
283
- * which therefore must be aliased into a module-local binding in lean mode.
284
- *
285
- * V8 folds a local `const` callee into a constant and inlines straight through
286
- * `x.call(...)`; an IMPORTED binding is a cell it will not fold, so the same
287
- * expression stays a generic property load plus a generic call — measured 4.5x
288
- * (5 keys) to 6.5x (20 keys) slower on the record fast path, 35.9 ns vs 7.2 ns
289
- * for a 5-key record. Aliasing the import into the IIFE recovers all of it
290
- * (7.4 ns). A DIRECT call to an imported function (`__zcFsr(v,s)`) is not
291
- * penalized — measured identical — and neither is an imported RegExp receiver,
292
- * so only the `.call` sites are listed here.
293
- */
294
- const CALL_INVOKED_HELPERS = new Set(["__zcHop"]);
252
+ * Helpers that generated code invokes through `Function.prototype.call`, and
253
+ * which therefore must be aliased into a module-local binding in lean mode.
254
+ *
255
+ * V8 folds a local `const` callee into a constant and inlines straight through
256
+ * `x.call(...)`; an IMPORTED binding is a cell it will not fold, so the same
257
+ * expression stays a generic property load plus a generic call — measured 4.5x
258
+ * (5 keys) to 6.5x (20 keys) slower on the record fast path, 35.9 ns vs 7.2 ns
259
+ * for a 5-key record. Aliasing the import into the IIFE recovers all of it
260
+ * (7.4 ns). A DIRECT call to an imported function (`__zcFsr(v,s)`) is not
261
+ * penalized — measured identical — and neither is an imported RegExp receiver,
262
+ * so only the `.call` sites are listed here.
263
+ */
264
+ const CALL_INVOKED_HELPERS = /* @__PURE__ */ new Set(["__zcHop"]);
295
265
  /**
296
- * Reference a shared runtime helper (e.g. __zcFsr) from generated code.
297
- * Lean mode: registers it for the `virtual:zod-compiler/runtime` import.
298
- * Inline mode: declares it once in the per-IIFE preamble.
299
- */
300
- export function emitRuntimeHelper(ctx, name, decl) {
301
- if (ctx.mode === "lean") {
302
- ctx.usedHelpers.add(name);
303
- if (CALL_INVOKED_HELPERS.has(name))
304
- return emitConstant(ctx, "lh", name);
305
- }
306
- else if (!ctx.preamble.includes(decl)) {
307
- ctx.preamble.push(decl);
308
- }
309
- return name;
266
+ * Reference a shared runtime helper (e.g. __zcFsr) from generated code.
267
+ * Lean mode: registers it for the `virtual:zod-compiler/runtime` import.
268
+ * Inline mode: declares it once in the per-IIFE preamble.
269
+ */
270
+ function emitRuntimeHelper(ctx, name, decl) {
271
+ if (ctx.mode === "lean") {
272
+ ctx.usedHelpers.add(name);
273
+ if (CALL_INVOKED_HELPERS.has(name)) return emitConstant(ctx, "lh", name);
274
+ } else if (!ctx.preamble.includes(decl)) ctx.preamble.push(decl);
275
+ return name;
310
276
  }
311
277
  /**
312
- * Extend a path expression with one or more scalar segment expressions
313
- * (escaped string literals, numeric literals, or loop-variable names).
314
- *
315
- * Path expressions are only ever composed by these helpers starting from the
316
- * `[]` root, so any path that looks like an array literal IS one — the new
317
- * segment is spliced in to keep issue paths a single array allocation
318
- * (`["data","items",__i_7]`) instead of an allocation per nesting level
319
- * (`["data"].concat("items").concat(__i_7)`). Opaque expressions fall back
320
- * to .concat().
321
- */
322
- export function extendPath(parentPath, segExpr) {
323
- if (parentPath === "[]")
324
- return `[${segExpr}]`;
325
- if (parentPath.startsWith("[") && parentPath.endsWith("]")) {
326
- return `${parentPath.slice(0, -1)},${segExpr}]`;
327
- }
328
- return `${parentPath}.concat(${segExpr})`;
278
+ * Extend a path expression with one or more scalar segment expressions
279
+ * (escaped string literals, numeric literals, or loop-variable names).
280
+ *
281
+ * Path expressions are only ever composed by these helpers starting from the
282
+ * `[]` root, so any path that looks like an array literal IS one — the new
283
+ * segment is spliced in to keep issue paths a single array allocation
284
+ * (`["data","items",__i_7]`) instead of an allocation per nesting level
285
+ * (`["data"].concat("items").concat(__i_7)`). Opaque expressions fall back
286
+ * to .concat().
287
+ */
288
+ function extendPath(parentPath, segExpr) {
289
+ if (parentPath === "[]") return `[${segExpr}]`;
290
+ if (parentPath.startsWith("[") && parentPath.endsWith("]")) return `${parentPath.slice(0, -1)},${segExpr}]`;
291
+ return `${parentPath}.concat(${segExpr})`;
329
292
  }
330
293
  /** Extend a path expression with a static string key. */
331
- export function extendStaticPath(parentPath, key) {
332
- return extendPath(parentPath, escapeString(key));
294
+ function extendStaticPath(parentPath, key) {
295
+ return extendPath(parentPath, escapeString(key));
333
296
  }
334
297
  /** Extend a path expression with a numeric index. */
335
- export function extendStaticPathIndex(parentPath, index) {
336
- return extendPath(parentPath, String(index));
298
+ function extendStaticPathIndex(parentPath, index) {
299
+ return extendPath(parentPath, String(index));
337
300
  }
338
301
  /**
339
- * A superRefine callback receives zod's payload, whose `value` is public,
340
- * typed, writable API ($RefinementCtx extends ParsePayload) — so any node
341
- * carrying one MAY rewrite its value and must be treated as mutating. Which
342
- * callbacks actually do is undecidable here; the emitted fast check settles it
343
- * at runtime by refusing when the value changed (see ZC_SR_OK_DECL), so a
344
- * non-mutating callback still exits through the fast path.
345
- */
302
+ * A superRefine callback receives zod's payload, whose `value` is public,
303
+ * typed, writable API ($RefinementCtx extends ParsePayload) — so any node
304
+ * carrying one MAY rewrite its value and must be treated as mutating. Which
305
+ * callbacks actually do is undecidable here; the emitted fast check settles it
306
+ * at runtime by refusing when the value changed (see ZC_SR_OK_DECL), so a
307
+ * non-mutating callback still exits through the fast path.
308
+ */
346
309
  function hasSuperRefine(checks) {
347
- return checks !== undefined && checks.some((c) => c.kind === "super_refine_effect");
310
+ return checks !== void 0 && checks.some((c) => c.kind === "super_refine_effect");
348
311
  }
349
312
  /**
350
- * Check if a SchemaIR tree produces output that is not the input itself —
351
- * either value-mutating operations (coerce, default, catch, overwrite) that
352
- * write back to the input expression, or a strip object that rebuilds a fresh
353
- * object from its known keys. Used by container generators to decide whether to
354
- * clone (so the rebuilt/mutated value never writes through to the caller's
355
- * input), by generateValidator to keep such schemas off the by-reference fast
356
- * path, and by the shared-walk dedup + intersection extractor to exclude them.
357
- */
358
- export function hasMutation(ir) {
359
- switch (ir.type) {
360
- case "string":
361
- // url checks trim (and optionally normalize) the value; overwrite
362
- // effects (.trim(), .toLowerCase()) rewrite it.
363
- return (ir.coerce === true ||
364
- hasSuperRefine(ir.checks) ||
365
- ir.checks.some((c) => c.kind === "overwrite_effect" || (c.kind === "string_format" && c.format === "url")));
366
- case "number":
367
- return ir.coerce === true || hasSuperRefine(ir.checks);
368
- case "boolean":
369
- case "bigint":
370
- case "date":
371
- return ir.coerce === true;
372
- case "default":
373
- case "catch":
374
- case "effect":
375
- case "fallback":
376
- case "stringBool":
377
- return true;
378
- case "object":
379
- // A strip object produces a FRESH output (only the declared keys), so it
380
- // mutates: parents must clone before it writes back, it never takes the
381
- // by-reference fast path, and intersections of strip objects delegate to
382
- // zod (see extractIntersection's hasMutation guard) — matching zod's
383
- // parse-both-sides-then-merge semantics instead of over-stripping.
384
- return (ir.stripUnknownKeys === true ||
385
- hasSuperRefine(ir.checks) ||
386
- (ir.catchall !== undefined && hasMutation(ir.catchall)) ||
387
- Object.values(ir.properties).some((p) => hasMutation(p)));
388
- case "array":
389
- return hasSuperRefine(ir.checks) || hasMutation(ir.element);
390
- case "tuple":
391
- return ir.items.some(hasMutation) || (ir.rest !== null && hasMutation(ir.rest));
392
- case "record":
393
- return hasMutation(ir.valueType);
394
- case "optional":
395
- case "nullable":
396
- case "readonly":
397
- case "recursionTarget":
398
- return hasMutation(ir.inner);
399
- case "union":
400
- case "discriminatedUnion":
401
- return ir.options.some(hasMutation);
402
- case "intersection":
403
- return hasMutation(ir.left) || hasMutation(ir.right);
404
- case "pipe":
405
- return hasMutation(ir.in) || hasMutation(ir.out);
406
- case "set":
407
- return hasMutation(ir.valueType);
408
- case "map":
409
- return hasMutation(ir.keyType) || hasMutation(ir.valueType);
410
- case "file":
411
- return false;
412
- default:
413
- return false;
414
- }
313
+ * Check if a SchemaIR tree produces output that is not the input itself —
314
+ * either value-mutating operations (coerce, default, catch, overwrite) that
315
+ * write back to the input expression, or a strip object that rebuilds a fresh
316
+ * object from its known keys. Used by container generators to decide whether to
317
+ * clone (so the rebuilt/mutated value never writes through to the caller's
318
+ * input), by generateValidator to keep such schemas off the by-reference fast
319
+ * path, and by the shared-walk dedup + intersection extractor to exclude them.
320
+ */
321
+ function hasMutation(ir) {
322
+ switch (ir.type) {
323
+ case "string": return ir.coerce === true || hasSuperRefine(ir.checks) || ir.checks.some((c) => c.kind === "overwrite_effect" || c.kind === "string_format" && c.format === "url");
324
+ case "number": return ir.coerce === true || hasSuperRefine(ir.checks);
325
+ case "boolean":
326
+ case "bigint":
327
+ case "date": return ir.coerce === true;
328
+ case "default":
329
+ case "catch":
330
+ case "effect":
331
+ case "fallback":
332
+ case "stringBool": return true;
333
+ case "object": return ir.stripUnknownKeys === true || hasSuperRefine(ir.checks) || ir.catchall !== void 0 && hasMutation(ir.catchall) || Object.values(ir.properties).some((p) => hasMutation(p));
334
+ case "array": return hasSuperRefine(ir.checks) || hasMutation(ir.element);
335
+ case "tuple": return ir.items.some(hasMutation) || ir.rest !== null && hasMutation(ir.rest);
336
+ case "record": return hasMutation(ir.valueType);
337
+ case "optional":
338
+ case "nullable":
339
+ case "readonly":
340
+ case "recursionTarget": return hasMutation(ir.inner);
341
+ case "union":
342
+ case "discriminatedUnion": return ir.options.some(hasMutation);
343
+ case "intersection": return hasMutation(ir.left) || hasMutation(ir.right);
344
+ case "pipe": return hasMutation(ir.in) || hasMutation(ir.out);
345
+ case "set": return hasMutation(ir.valueType);
346
+ case "map": return hasMutation(ir.keyType) || hasMutation(ir.valueType);
347
+ case "file": return false;
348
+ default: return false;
349
+ }
415
350
  }
416
351
  /**
417
- * Is a defaulted property's key guaranteed to appear in the stripped output?
418
- *
419
- * Distinct from {@link rejectsUndefined}, which asks whether `undefined` is
420
- * REJECTED — a `.default()` accepts it and yet still produces a defined value, so
421
- * only this question earns the key a slot in the output object literal. The two
422
- * answers coincide everywhere else.
423
- *
424
- * Sound for both branches of a default: the substituted value is defined
425
- * (`alwaysDefined`, checked against the schema at extraction time), and the inner
426
- * branch runs only when `input[key] !== undefined`, which implies `key in input`
427
- * — so zod's presence test keeps the key whatever the inner produced.
428
- */
429
- export function outputAlwaysDefined(ir) {
430
- return ir.type === "default" ? ir.alwaysDefined === true : rejectsUndefined(ir);
352
+ * Is a defaulted property's key guaranteed to appear in the stripped output?
353
+ *
354
+ * Distinct from {@link rejectsUndefined}, which asks whether `undefined` is
355
+ * REJECTED — a `.default()` accepts it and yet still produces a defined value, so
356
+ * only this question earns the key a slot in the output object literal. The two
357
+ * answers coincide everywhere else.
358
+ *
359
+ * Sound for both branches of a default: the substituted value is defined
360
+ * (`alwaysDefined`, checked against the schema at extraction time), and the inner
361
+ * branch runs only when `input[key] !== undefined`, which implies `key in input`
362
+ * — so zod's presence test keeps the key whatever the inner produced.
363
+ */
364
+ function outputAlwaysDefined(ir) {
365
+ return ir.type === "default" ? ir.alwaysDefined === true : rejectsUndefined(ir);
431
366
  }
432
367
  /**
433
- * Does this schema reject `undefined` outright?
434
- *
435
- * Read as "can this slot be ABSENT from the input" by the tuple build, whose
436
- * output length depends on it — zod marks a defaulted or optional item
437
- * `optin: "optional"` and accepts a shorter array. Conservative: anything that
438
- * might accept, produce, or default to `undefined` answers false.
439
- */
440
- export function rejectsUndefined(ir) {
441
- switch (ir.type) {
442
- // Coercion turns undefined into a value (`String(undefined)`), so a
443
- // coercing primitive is NOT a rejector.
444
- case "string":
445
- case "number":
446
- case "boolean":
447
- case "bigint":
448
- case "date":
449
- return ir.coerce !== true;
450
- case "symbol":
451
- case "null":
452
- case "nan":
453
- case "never":
454
- case "enum":
455
- case "object":
456
- case "array":
457
- case "tuple":
458
- case "record":
459
- case "set":
460
- case "map":
461
- case "file":
462
- case "templateLiteral":
463
- case "discriminatedUnion":
464
- case "stringBool":
465
- return true;
466
- case "literal":
467
- return !ir.values.includes(undefined);
468
- case "union":
469
- return ir.options.every(rejectsUndefined);
470
- case "intersection":
471
- return rejectsUndefined(ir.left) || rejectsUndefined(ir.right);
472
- case "nullable":
473
- case "readonly":
474
- case "recursionTarget":
475
- return rejectsUndefined(ir.inner);
476
- default:
477
- // optional / any / unknown / undefined / void / default / catch /
478
- // fallback / effect / pipe / recursiveRef — each can yield undefined,
479
- // or is opaque enough that we must not assume otherwise.
480
- return false;
481
- }
368
+ * Does this schema reject `undefined` outright?
369
+ *
370
+ * Read as "can this slot be ABSENT from the input" by the tuple build, whose
371
+ * output length depends on it — zod marks a defaulted or optional item
372
+ * `optin: "optional"` and accepts a shorter array. Conservative: anything that
373
+ * might accept, produce, or default to `undefined` answers false.
374
+ */
375
+ function rejectsUndefined(ir) {
376
+ switch (ir.type) {
377
+ case "string":
378
+ case "number":
379
+ case "boolean":
380
+ case "bigint":
381
+ case "date": return ir.coerce !== true;
382
+ case "symbol":
383
+ case "null":
384
+ case "nan":
385
+ case "never":
386
+ case "enum":
387
+ case "object":
388
+ case "array":
389
+ case "tuple":
390
+ case "record":
391
+ case "set":
392
+ case "map":
393
+ case "file":
394
+ case "templateLiteral":
395
+ case "discriminatedUnion":
396
+ case "stringBool": return true;
397
+ case "literal": return !ir.values.includes(void 0);
398
+ case "union": return ir.options.every(rejectsUndefined);
399
+ case "intersection": return rejectsUndefined(ir.left) || rejectsUndefined(ir.right);
400
+ case "nullable":
401
+ case "readonly":
402
+ case "recursionTarget": return rejectsUndefined(ir.inner);
403
+ default: return false;
404
+ }
482
405
  }
483
406
  /**
484
- * Sort comparator for CheckIR: cheapest/most-discriminating checks first.
485
- * Used by fast-path generators after filtering out refine_effect entries.
486
- */
487
- export function checkPriority(a, b) {
488
- return (CHECK_PRIORITY[a.kind] ?? 99) - (CHECK_PRIORITY[b.kind] ?? 99);
407
+ * Sort comparator for CheckIR: cheapest/most-discriminating checks first.
408
+ * Used by fast-path generators after filtering out refine_effect entries.
409
+ */
410
+ function checkPriority(a, b) {
411
+ return (CHECK_PRIORITY[a.kind] ?? 99) - (CHECK_PRIORITY[b.kind] ?? 99);
489
412
  }
413
+ //#endregion
414
+ export { ENUM_INLINE_THRESHOLD, KEY_MEMBERSHIP_INLINE_THRESHOLD, checkPriority, declareFastTemps, emitConstant, emitEffectCallable, emitEffectFn, emitRegex, emitRegexSourceString, emitRfDelegate, emitRuntimeHelper, emitSet, emitTemp, escapeString, extendPath, extendStaticPath, extendStaticPathIndex, fastSentinelWrapper, hasMutation, keyMembershipTest, literalToJs, outputAlwaysDefined, rejectsUndefined };
415
+
490
416
  //# sourceMappingURL=context.js.map