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,108 +1,71 @@
1
- import { declareFastTemps, emitEffectCallable, emitRuntimeHelper, escapeString, extendPath, extendStaticPath, hasMutation, keyMembershipTest, outputAlwaysDefined, } from "../context.js";
1
+ import { declareFastTemps, emitEffectCallable, emitRuntimeHelper, escapeString, extendPath, extendStaticPath, hasMutation, keyMembershipTest, outputAlwaysDefined } from "../context.js";
2
2
  import { emit } from "../emit.js";
3
3
  import { invalidType, unrecognizedKeys } from "../emit-issue.js";
4
4
  import { ZC_AB_DECL } from "../issue-decls.js";
5
- import { orderByRuntimeCost } from "../fast-size.js";
6
5
  import { refineCheck, superRefineCheck, superRefineFastTest } from "./effect.js";
7
- export function slowObject(ir, g) {
8
- let code = emit `
6
+ import { orderByRuntimeCost } from "../fast-size.js";
7
+ //#region src/core/codegen/schemas/object.ts
8
+ function slowObject(ir, g) {
9
+ let code = emit`
9
10
  if(typeof ${g.input}!=="object"||${g.input}===null||Array.isArray(${g.input})){
10
11
  ${invalidType(g, "object")}
11
12
  }else{`;
12
- // Strip mode (zod's default z.object() output) rebuilds a FRESH object from
13
- // the declared keys, so it always writes back. Otherwise clone only when a
14
- // property mutates the value.
15
- const strip = ir.stripUnknownKeys === true;
16
- const needsClone = strip ||
17
- (ir.catchall !== undefined && hasMutation(ir.catchall)) ||
18
- Object.values(ir.properties).some(hasMutation);
19
- const objVar = g.temp("o");
20
- if (!strip) {
21
- // Spread, not Object.assign: V8's CloneObjectIC makes `{...x}` ~25% faster
22
- // on the whole safeParse call for mutation-bearing schemas.
23
- code += needsClone ? `var ${objVar}={...${g.input}};` : `var ${objVar}=${g.input};`;
24
- }
25
- // Object-level refines are gated on zod's ABORT rule, not on "did anything
26
- // fail": zod parses the properties (plus the strict/catchall passes) into the
27
- // payload and then skips its check chain only when `util.aborted` holds — i.e.
28
- // when one of those issues is non-continuable. A property that failed its own
29
- // `min`/format check reports a CONTINUABLE issue, so the outer refine still
30
- // runs and both messages surface; a property that failed to parse at all
31
- // (`invalid_type`, an unrecognized key, a bad record key) aborts and
32
- // suppresses it. Snapshot the issue count before the properties so the scan
33
- // covers exactly this node's own parse, as zod's fresh sub-payload does.
34
- const refineMark = ir.checks && ir.checks.length > 0 ? g.temp("rm") : "";
35
- if (refineMark)
36
- code += `var ${refineMark}=${g.issues}.length;`;
37
- const suppressAbsent = new Set(ir.suppressAbsentKeys ?? []);
38
- /** Strip only: per-property output slot + whether it is always in the result. */
39
- const slots = [];
40
- for (const [key, propIR] of Object.entries(ir.properties)) {
41
- const keyStr = escapeString(key);
42
- const propPath = extendStaticPath(g.path, key);
43
- // Strip validates the value read from the INPUT, held in a local, and
44
- // assembles the result afterwards. Reading through the half-built copy (the
45
- // previous shape) both cost a megamorphic access per key — the copy's map
46
- // changes with every key added — and diverged from zod, which parses
47
- // `input[key]` and so accepts a value found on the prototype.
48
- const propExpr = strip ? g.temp("sv") : `${objVar}[${keyStr}]`;
49
- if (strip) {
50
- code += `var ${propExpr}=${g.input}[${keyStr}];`;
51
- slots.push({ always: outputAlwaysDefined(propIR), keyStr, value: propExpr });
52
- }
53
- const propCode = g.visit(propIR, { input: propExpr, output: propExpr, path: propPath });
54
- if (suppressAbsent.has(key)) {
55
- // Mirrors zod's handlePropertyResult: optional-out fallback props run,
56
- // but their issues are discarded when the key is absent from the input.
57
- const beforeVar = g.temp("ob");
58
- code += emit `
13
+ const strip = ir.stripUnknownKeys === true;
14
+ const needsClone = strip || ir.catchall !== void 0 && hasMutation(ir.catchall) || Object.values(ir.properties).some(hasMutation);
15
+ const objVar = g.temp("o");
16
+ if (!strip) code += needsClone ? `var ${objVar}={...${g.input}};` : `var ${objVar}=${g.input};`;
17
+ const refineMark = ir.checks && ir.checks.length > 0 ? g.temp("rm") : "";
18
+ if (refineMark) code += `var ${refineMark}=${g.issues}.length;`;
19
+ const suppressAbsent = new Set(ir.suppressAbsentKeys ?? []);
20
+ /** Strip only: per-property output slot + whether it is always in the result. */
21
+ const slots = [];
22
+ for (const [key, propIR] of Object.entries(ir.properties)) {
23
+ const keyStr = escapeString(key);
24
+ const propPath = extendStaticPath(g.path, key);
25
+ const propExpr = strip ? g.temp("sv") : `${objVar}[${keyStr}]`;
26
+ if (strip) {
27
+ code += `var ${propExpr}=${g.input}[${keyStr}];`;
28
+ slots.push({
29
+ always: outputAlwaysDefined(propIR),
30
+ keyStr,
31
+ value: propExpr
32
+ });
33
+ }
34
+ const propCode = g.visit(propIR, {
35
+ input: propExpr,
36
+ output: propExpr,
37
+ path: propPath
38
+ });
39
+ if (suppressAbsent.has(key)) {
40
+ const beforeVar = g.temp("ob");
41
+ code += emit`
59
42
  var ${beforeVar}=${g.issues}.length;
60
43
  ${propCode}
61
44
  if(!(${keyStr} in ${strip ? g.input : objVar})&&${g.issues}.length>${beforeVar}){
62
45
  ${g.issues}.length=${beforeVar};
63
46
  }`;
64
- }
65
- else {
66
- code += propCode;
67
- }
68
- }
69
- if (strip) {
70
- // Assemble the result in shape order (zod's key order), taking as long a
71
- // LEADING run of always-present keys as possible into one object literal:
72
- // V8 stamps a literal out of a cached boilerplate map in a single
73
- // allocation, where adding keys one at a time walks a transition chain and
74
- // re-checks the map on every store — measured 8.1x (20 keys) / 2.8x (7
75
- // keys, one optional) on the whole safeParse.
76
- //
77
- // Everything after the first conditional key is appended so insertion order
78
- // still matches zod. The per-key test is zod's own: keep the key when the
79
- // parsed value is defined, or when it was present on the input at all
80
- // (`key in input`, prototype included — an own `k: undefined` survives).
81
- const literal = [];
82
- let appends = "";
83
- let leading = true;
84
- for (const slot of slots) {
85
- if (leading && slot.always) {
86
- literal.push(`${slot.keyStr}:${slot.value}`);
87
- continue;
88
- }
89
- leading = false;
90
- appends += slot.always
91
- ? `${objVar}[${slot.keyStr}]=${slot.value};`
92
- : `if(${slot.value}!==undefined||(${slot.keyStr} in ${g.input})){${objVar}[${slot.keyStr}]=${slot.value};}`;
93
- }
94
- code += `var ${objVar}={${literal.join(",")}};${appends}`;
95
- }
96
- // Strict unknown-key pass — zod's handleCatchall, byte-exact: for-in over
97
- // the ORIGINAL input (inherited enumerable keys count, no hasOwnProperty),
98
- // ALL unknown keys collected into one issue, pushed AFTER property issues
99
- // and before object-level refines.
100
- if (ir.strict) {
101
- const keys = Object.keys(ir.properties);
102
- const ukVar = g.temp("uk");
103
- const kVar = g.temp("k");
104
- const test = keyMembershipTest(g.ctx, keys, kVar);
105
- code += emit `
47
+ } else code += propCode;
48
+ }
49
+ if (strip) {
50
+ const literal = [];
51
+ let appends = "";
52
+ let leading = true;
53
+ for (const slot of slots) {
54
+ if (leading && slot.always) {
55
+ literal.push(`${slot.keyStr}:${slot.value}`);
56
+ continue;
57
+ }
58
+ leading = false;
59
+ appends += slot.always ? `${objVar}[${slot.keyStr}]=${slot.value};` : `if(${slot.value}!==undefined||(${slot.keyStr} in ${g.input})){${objVar}[${slot.keyStr}]=${slot.value};}`;
60
+ }
61
+ code += `var ${objVar}={${literal.join(",")}};${appends}`;
62
+ }
63
+ if (ir.strict) {
64
+ const keys = Object.keys(ir.properties);
65
+ const ukVar = g.temp("uk");
66
+ const kVar = g.temp("k");
67
+ const test = keyMembershipTest(g.ctx, keys, kVar);
68
+ code += emit`
106
69
  var ${ukVar}=null;
107
70
  for(var ${kVar} in ${g.input}){
108
71
  if(!(${test})){(${ukVar}=${ukVar}||[]).push(${kVar});}
@@ -110,156 +73,106 @@ export function slowObject(ir, g) {
110
73
  if(${ukVar}!==null){
111
74
  ${unrecognizedKeys(g, ukVar)}
112
75
  }`;
113
- }
114
- // .catchall(schema): validate every key NOT in the shape, mirroring zod's
115
- // handleCatchall — same bare for-in over the ORIGINAL input as the strict
116
- // pass (inherited enumerable keys count, no hasOwnProperty guard), each
117
- // issue reported at the key. Runs after the properties, as zod does.
118
- //
119
- // The key's slot is BOTH the input and the output, exactly as a shape
120
- // property's is: a value-rewriting catchall (coerce, .trim(), a default)
121
- // writes through the same expression it later re-reads, so splitting them
122
- // makes the rewrite invisible to its own checks.
123
- //
124
- // When the catchall mutates, objVar is a clone, and each unknown key is
125
- // copied into it before validation — which also reproduces zod, whose fresh
126
- // output object gains an OWN key for every for-in key it saw, inherited ones
127
- // included. A non-mutating catchall writes nothing, so objVar is the input
128
- // and the object stays pass-through by reference.
129
- if (ir.catchall) {
130
- const keys = Object.keys(ir.properties);
131
- const kVar = g.temp("ck");
132
- const test = keyMembershipTest(g.ctx, keys, kVar);
133
- const slot = `${objVar}[${kVar}]`;
134
- const seed = needsClone ? `${slot}=${g.input}[${kVar}];` : "";
135
- code += emit `
76
+ }
77
+ if (ir.catchall) {
78
+ const keys = Object.keys(ir.properties);
79
+ const kVar = g.temp("ck");
80
+ const test = keyMembershipTest(g.ctx, keys, kVar);
81
+ const slot = `${objVar}[${kVar}]`;
82
+ const seed = needsClone ? `${slot}=${g.input}[${kVar}];` : "";
83
+ code += emit`
136
84
  for(var ${kVar} in ${g.input}){
137
85
  if(!(${test})){
138
86
  ${seed}
139
87
  ${g.visit(ir.catchall, {
140
- input: slot,
141
- output: slot,
142
- path: extendPath(g.path, kVar),
143
- })}
88
+ input: slot,
89
+ output: slot,
90
+ path: extendPath(g.path, kVar)
91
+ })}
144
92
  }
145
93
  }`;
146
- }
147
- if (needsClone) {
148
- code += `${g.output}=${objVar};`;
149
- }
150
- // Object-level refine effects: z.object({...}).refine(fn), suppressed when the
151
- // parse phase aborted (see refineMark). One gate covers every effect: each of
152
- // them can only add a continuable `custom` issue, so zod's per-check
153
- // re-evaluation of `isAborted` can never flip between them.
154
- if (ir.checks && ir.checks.length > 0) {
155
- let refines = "";
156
- for (const check of ir.checks) {
157
- refines +=
158
- check.kind === "super_refine_effect"
159
- ? superRefineCheck(check, objVar, g)
160
- : refineCheck(check, objVar, g);
161
- }
162
- const aborted = emitRuntimeHelper(g.ctx, "__zcAb", ZC_AB_DECL);
163
- code += `if(!${aborted}(${g.issues},${refineMark})){${refines}}`;
164
- }
165
- code += `}\n`;
166
- return code;
94
+ }
95
+ if (needsClone) code += `${g.output}=${objVar};`;
96
+ if (ir.checks && ir.checks.length > 0) {
97
+ let refines = "";
98
+ for (const check of ir.checks) refines += check.kind === "super_refine_effect" ? superRefineCheck(check, objVar, g) : refineCheck(check, objVar, g);
99
+ const aborted = emitRuntimeHelper(g.ctx, "__zcAb", ZC_AB_DECL);
100
+ code += `if(!${aborted}(${g.issues},${refineMark})){${refines}}`;
101
+ }
102
+ code += `}\n`;
103
+ return code;
167
104
  }
168
105
  /**
169
- * Property entries in the order their fast-checks should be `&&`-chained:
170
- * cheapest first, declaration order preserved among equals (Array#sort is
171
- * stable). Valid input runs every conjunct whatever the order, so this costs
172
- * nothing on the hot path; a REJECT stops at the first false conjunct, so
173
- * pricing a `z.email()` behind the `kind` literal that actually discriminates
174
- * is what makes union probing and `.is()` misses cheap (see
175
- * estimateRuntimeCost). The SLOW path keeps declaration order — that one's
176
- * output is the issue list, whose order is part of zod parity.
177
- */
106
+ * Property entries in the order their fast-checks should be `&&`-chained:
107
+ * cheapest first, declaration order preserved among equals (Array#sort is
108
+ * stable). Valid input runs every conjunct whatever the order, so this costs
109
+ * nothing on the hot path; a REJECT stops at the first false conjunct, so
110
+ * pricing a `z.email()` behind the `kind` literal that actually discriminates
111
+ * is what makes union probing and `.is()` misses cheap (see
112
+ * estimateRuntimeCost). The SLOW path keeps declaration order — that one's
113
+ * output is the issue list, whose order is part of zod parity.
114
+ */
178
115
  function orderedProperties(ir, g) {
179
- return orderByRuntimeCost(Object.entries(ir.properties), ([, propIR]) => propIR, g.ctx);
116
+ return orderByRuntimeCost(Object.entries(ir.properties), ([, propIR]) => propIR, g.ctx);
180
117
  }
181
118
  /**
182
- * Property/strict/refine fast-checks for an object, WITHOUT the leading
183
- * `typeof===object && !==null && !Array.isArray` type-guard. Returns the
184
- * conjunct parts (joinable with `&&`), or null if any child is fast-ineligible.
185
- *
186
- * `skipKey`, when given, omits that one property's check. Used by the
187
- * discriminated-union fast path (via `g.discSkipKey`): the enclosing `switch`
188
- * has already matched the discriminator's value, so re-checking it is redundant.
189
- */
119
+ * Property/strict/refine fast-checks for an object, WITHOUT the leading
120
+ * `typeof===object && !==null && !Array.isArray` type-guard. Returns the
121
+ * conjunct parts (joinable with `&&`), or null if any child is fast-ineligible.
122
+ *
123
+ * `skipKey`, when given, omits that one property's check. Used by the
124
+ * discriminated-union fast path (via `g.discSkipKey`): the enclosing `switch`
125
+ * has already matched the discriminator's value, so re-checking it is redundant.
126
+ */
190
127
  function fastObjectBody(ir, g, skipKey) {
191
- const x = g.input;
192
- const parts = [];
193
- for (const [key, propIR] of orderedProperties(ir, g)) {
194
- if (key === skipKey)
195
- continue;
196
- const propExpr = `${x}[${escapeString(key)}]`;
197
- const propCheck = g.visit(propIR, { input: propExpr });
198
- if (propCheck === null)
199
- return null; // All-or-nothing
200
- parts.push(propCheck);
201
- }
202
- // Strict unknown-key pass: hosted boolean helper (a for-in loop cannot live
203
- // in the && chain). Same for-in iteration as the slow path — fast/slow
204
- // agreement is load-bearing under the __zcFinD deferral. The membership set is
205
- // the FULL key list (the discriminator is a recognized key), independent of
206
- // skipKey, which only suppresses re-validating the discriminator's value.
207
- if (ir.strict) {
208
- const keys = Object.keys(ir.properties);
209
- const fnName = g.temp("so");
210
- const test = keyMembershipTest(g.ctx, keys, "k");
211
- g.ctx.preamble.push(`function ${fnName}(o){for(var k in o){if(!(${test}))return false;}return true;}`);
212
- parts.push(`${fnName}(${x})`);
213
- }
214
- // .catchall(schema): same hosted for-in as strict, but each unrecognized key
215
- // is checked against the catchall rather than rejected outright. The value is
216
- // hoisted into a local for the same reason fastRecord does it — repeated
217
- // `o[k]` computed loads are not eliminated across check boundaries.
218
- if (ir.catchall) {
219
- const kv = g.temp("cak");
220
- const vv = g.temp("cav");
221
- const catchallGen = g.scoped(vv);
222
- const valCheck = catchallGen.visit(ir.catchall, { input: vv });
223
- if (valCheck === null)
224
- return null;
225
- if (valCheck !== "true") {
226
- const fnName = g.temp("co");
227
- const test = keyMembershipTest(g.ctx, Object.keys(ir.properties), kv);
228
- g.ctx.preamble.push(`function ${fnName}(o){${declareFastTemps(catchallGen.scope)}var ${kv},${vv};for(${kv} in o){if(!(${test})){${vv}=o[${kv}];if(!(${valCheck}))return false;}}return true;}`);
229
- parts.push(`${fnName}(${x})`);
230
- }
231
- }
232
- // Object-level refine effects (appended last — run after property checks short-circuit)
233
- if (ir.checks) {
234
- for (const check of ir.checks) {
235
- if (check.kind === "refine_effect") {
236
- parts.push(`${emitEffectCallable(g.ctx, check)}(${x})`);
237
- }
238
- else if (check.kind === "super_refine_effect") {
239
- parts.push(superRefineFastTest(check, x, g));
240
- }
241
- }
242
- }
243
- return parts;
128
+ const x = g.input;
129
+ const parts = [];
130
+ for (const [key, propIR] of orderedProperties(ir, g)) {
131
+ if (key === skipKey) continue;
132
+ const propExpr = `${x}[${escapeString(key)}]`;
133
+ const propCheck = g.visit(propIR, { input: propExpr });
134
+ if (propCheck === null) return null;
135
+ parts.push(propCheck);
136
+ }
137
+ if (ir.strict) {
138
+ const keys = Object.keys(ir.properties);
139
+ const fnName = g.temp("so");
140
+ const test = keyMembershipTest(g.ctx, keys, "k");
141
+ g.ctx.preamble.push(`function ${fnName}(o){for(var k in o){if(!(${test}))return false;}return true;}`);
142
+ parts.push(`${fnName}(${x})`);
143
+ }
144
+ if (ir.catchall) {
145
+ const kv = g.temp("cak");
146
+ const vv = g.temp("cav");
147
+ const catchallGen = g.scoped(vv);
148
+ const valCheck = catchallGen.visit(ir.catchall, { input: vv });
149
+ if (valCheck === null) return null;
150
+ if (valCheck !== "true") {
151
+ const fnName = g.temp("co");
152
+ const test = keyMembershipTest(g.ctx, Object.keys(ir.properties), kv);
153
+ g.ctx.preamble.push(`function ${fnName}(o){${declareFastTemps(catchallGen.scope)}var ${kv},${vv};for(${kv} in o){if(!(${test})){${vv}=o[${kv}];if(!(${valCheck}))return false;}}return true;}`);
154
+ parts.push(`${fnName}(${x})`);
155
+ }
156
+ }
157
+ if (ir.checks) {
158
+ for (const check of ir.checks) if (check.kind === "refine_effect") parts.push(`${emitEffectCallable(g.ctx, check)}(${x})`);
159
+ else if (check.kind === "super_refine_effect") parts.push(superRefineFastTest(check, x, g));
160
+ }
161
+ return parts;
244
162
  }
245
- export function fastObject(ir, g) {
246
- // A strip object still gets an expression. Stripping reshapes the OUTPUT, not
247
- // the verdict, so this remains an exact acceptance predicate — which is what
248
- // `.is()` installs, and what the build path reuses to validate the subtrees it
249
- // passes through by reference. What it must NOT do is stand in for the parse
250
- // result: generateValidator withholds the `data:input` shortcut whenever the
251
- // schema rebuilds (see rebuildsOutput).
252
- const x = g.input;
253
- const body = fastObjectBody(ir, g, g.discSkipKey);
254
- if (body === null)
255
- return null;
256
- // Discriminated-union option: the enclosing switch (and the caller's guard)
257
- // already established object-ness and the discriminator value, so emit only
258
- // the remaining checks — no leading type-guard. An option with nothing left
259
- // to check accepts unconditionally ("true").
260
- if (g.discSkipKey !== undefined) {
261
- return body.length > 0 ? body.join("&&") : "true";
262
- }
263
- return [`typeof ${x}==="object"`, `${x}!==null`, `!Array.isArray(${x})`, ...body].join("&&");
163
+ function fastObject(ir, g) {
164
+ const x = g.input;
165
+ const body = fastObjectBody(ir, g, g.discSkipKey);
166
+ if (body === null) return null;
167
+ if (g.discSkipKey !== void 0) return body.length > 0 ? body.join("&&") : "true";
168
+ return [
169
+ `typeof ${x}==="object"`,
170
+ `${x}!==null`,
171
+ `!Array.isArray(${x})`,
172
+ ...body
173
+ ].join("&&");
264
174
  }
175
+ //#endregion
176
+ export { fastObject, slowObject };
177
+
265
178
  //# sourceMappingURL=object.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"object.js","sourceRoot":"","sources":["../../../../src/core/codegen/schemas/object.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,EACjB,YAAY,EACZ,UAAU,EACV,gBAAgB,EAChB,WAAW,EACX,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAEjF,MAAM,UAAU,UAAU,CAAC,EAAiC,EAAE,CAAU;IACtE,IAAI,IAAI,GAAG,IAAI,CAAA;gBACD,CAAC,CAAC,KAAK,gBAAgB,CAAC,CAAC,KAAK,0BAA0B,CAAC,CAAC,KAAK;QACvE,WAAW,CAAC,CAAC,EAAE,QAA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GAAG,CAAC,CAAC;YAC1D,CAAC;iBAAM,IAAI,KAAK,CAAC,IAAI,KAAK,qBAAqB,EAAE,CAAC;gBAChD,KAAK,CAAC,IAAI,CAAC,mBAAmB,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;YAC/C,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,EAAY,EAAE,CAAU;IACjD,8EAA8E;IAC9E,6EAA6E;IAC7E,+EAA+E;IAC/E,6EAA6E;IAC7E,6EAA6E;IAC7E,wCAAwC;IACxC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC;IAClB,MAAM,IAAI,GAAG,cAAc,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC;IAClD,IAAI,IAAI,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAC/B,4EAA4E;IAC5E,4EAA4E;IAC5E,4EAA4E;IAC5E,6CAA6C;IAC7C,IAAI,CAAC,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;QAChC,OAAO,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;IACpD,CAAC;IACD,OAAO,CAAC,UAAU,CAAC,aAAa,EAAE,GAAG,CAAC,SAAS,EAAE,kBAAkB,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC/F,CAAC"}
1
+ {"version":3,"file":"object.js","names":[],"sources":["../../../../src/core/codegen/schemas/object.ts"],"sourcesContent":["import type { ObjectIR, SchemaIR } from \"../../types.js\";\nimport type { FastGen, SlowGen } from \"../context.js\";\nimport {\n declareFastTemps,\n emitEffectCallable,\n emitRuntimeHelper,\n escapeString,\n extendPath,\n extendStaticPath,\n hasMutation,\n keyMembershipTest,\n outputAlwaysDefined,\n} from \"../context.js\";\nimport { emit } from \"../emit.js\";\nimport { invalidType, unrecognizedKeys } from \"../emit-issue.js\";\nimport { ZC_AB_DECL } from \"../issue-decls.js\";\nimport { orderByRuntimeCost } from \"../fast-size.js\";\nimport { refineCheck, superRefineCheck, superRefineFastTest } from \"./effect.js\";\n\nexport function slowObject(ir: SchemaIR & { type: \"object\" }, g: SlowGen): string {\n let code = emit`\n if(typeof ${g.input}!==\"object\"||${g.input}===null||Array.isArray(${g.input})){\n ${invalidType(g, \"object\")}\n }else{`;\n\n // Strip mode (zod's default z.object() output) rebuilds a FRESH object from\n // the declared keys, so it always writes back. Otherwise clone only when a\n // property mutates the value.\n const strip = ir.stripUnknownKeys === true;\n const needsClone =\n strip ||\n (ir.catchall !== undefined && hasMutation(ir.catchall)) ||\n Object.values(ir.properties).some(hasMutation);\n const objVar = g.temp(\"o\");\n if (!strip) {\n // Spread, not Object.assign: V8's CloneObjectIC makes `{...x}` ~25% faster\n // on the whole safeParse call for mutation-bearing schemas.\n code += needsClone ? `var ${objVar}={...${g.input}};` : `var ${objVar}=${g.input};`;\n }\n\n // Object-level refines are gated on zod's ABORT rule, not on \"did anything\n // fail\": zod parses the properties (plus the strict/catchall passes) into the\n // payload and then skips its check chain only when `util.aborted` holds — i.e.\n // when one of those issues is non-continuable. A property that failed its own\n // `min`/format check reports a CONTINUABLE issue, so the outer refine still\n // runs and both messages surface; a property that failed to parse at all\n // (`invalid_type`, an unrecognized key, a bad record key) aborts and\n // suppresses it. Snapshot the issue count before the properties so the scan\n // covers exactly this node's own parse, as zod's fresh sub-payload does.\n const refineMark = ir.checks && ir.checks.length > 0 ? g.temp(\"rm\") : \"\";\n if (refineMark) code += `var ${refineMark}=${g.issues}.length;`;\n\n const suppressAbsent = new Set(ir.suppressAbsentKeys ?? []);\n /** Strip only: per-property output slot + whether it is always in the result. */\n const slots: { always: boolean; keyStr: string; value: string }[] = [];\n\n for (const [key, propIR] of Object.entries(ir.properties)) {\n const keyStr = escapeString(key);\n const propPath = extendStaticPath(g.path, key);\n // Strip validates the value read from the INPUT, held in a local, and\n // assembles the result afterwards. Reading through the half-built copy (the\n // previous shape) both cost a megamorphic access per key — the copy's map\n // changes with every key added — and diverged from zod, which parses\n // `input[key]` and so accepts a value found on the prototype.\n const propExpr = strip ? g.temp(\"sv\") : `${objVar}[${keyStr}]`;\n if (strip) {\n code += `var ${propExpr}=${g.input}[${keyStr}];`;\n slots.push({ always: outputAlwaysDefined(propIR), keyStr, value: propExpr });\n }\n const propCode = g.visit(propIR, { input: propExpr, output: propExpr, path: propPath });\n if (suppressAbsent.has(key)) {\n // Mirrors zod's handlePropertyResult: optional-out fallback props run,\n // but their issues are discarded when the key is absent from the input.\n const beforeVar = g.temp(\"ob\");\n code += emit`\n var ${beforeVar}=${g.issues}.length;\n ${propCode}\n if(!(${keyStr} in ${strip ? g.input : objVar})&&${g.issues}.length>${beforeVar}){\n ${g.issues}.length=${beforeVar};\n }`;\n } else {\n code += propCode;\n }\n }\n\n if (strip) {\n // Assemble the result in shape order (zod's key order), taking as long a\n // LEADING run of always-present keys as possible into one object literal:\n // V8 stamps a literal out of a cached boilerplate map in a single\n // allocation, where adding keys one at a time walks a transition chain and\n // re-checks the map on every store — measured 8.1x (20 keys) / 2.8x (7\n // keys, one optional) on the whole safeParse.\n //\n // Everything after the first conditional key is appended so insertion order\n // still matches zod. The per-key test is zod's own: keep the key when the\n // parsed value is defined, or when it was present on the input at all\n // (`key in input`, prototype included — an own `k: undefined` survives).\n const literal: string[] = [];\n let appends = \"\";\n let leading = true;\n for (const slot of slots) {\n if (leading && slot.always) {\n literal.push(`${slot.keyStr}:${slot.value}`);\n continue;\n }\n leading = false;\n appends += slot.always\n ? `${objVar}[${slot.keyStr}]=${slot.value};`\n : `if(${slot.value}!==undefined||(${slot.keyStr} in ${g.input})){${objVar}[${slot.keyStr}]=${slot.value};}`;\n }\n code += `var ${objVar}={${literal.join(\",\")}};${appends}`;\n }\n\n // Strict unknown-key pass — zod's handleCatchall, byte-exact: for-in over\n // the ORIGINAL input (inherited enumerable keys count, no hasOwnProperty),\n // ALL unknown keys collected into one issue, pushed AFTER property issues\n // and before object-level refines.\n if (ir.strict) {\n const keys = Object.keys(ir.properties);\n const ukVar = g.temp(\"uk\");\n const kVar = g.temp(\"k\");\n const test = keyMembershipTest(g.ctx, keys, kVar);\n code += emit`\n var ${ukVar}=null;\n for(var ${kVar} in ${g.input}){\n if(!(${test})){(${ukVar}=${ukVar}||[]).push(${kVar});}\n }\n if(${ukVar}!==null){\n ${unrecognizedKeys(g, ukVar)}\n }`;\n }\n\n // .catchall(schema): validate every key NOT in the shape, mirroring zod's\n // handleCatchall — same bare for-in over the ORIGINAL input as the strict\n // pass (inherited enumerable keys count, no hasOwnProperty guard), each\n // issue reported at the key. Runs after the properties, as zod does.\n //\n // The key's slot is BOTH the input and the output, exactly as a shape\n // property's is: a value-rewriting catchall (coerce, .trim(), a default)\n // writes through the same expression it later re-reads, so splitting them\n // makes the rewrite invisible to its own checks.\n //\n // When the catchall mutates, objVar is a clone, and each unknown key is\n // copied into it before validation — which also reproduces zod, whose fresh\n // output object gains an OWN key for every for-in key it saw, inherited ones\n // included. A non-mutating catchall writes nothing, so objVar is the input\n // and the object stays pass-through by reference.\n if (ir.catchall) {\n const keys = Object.keys(ir.properties);\n const kVar = g.temp(\"ck\");\n const test = keyMembershipTest(g.ctx, keys, kVar);\n const slot = `${objVar}[${kVar}]`;\n const seed = needsClone ? `${slot}=${g.input}[${kVar}];` : \"\";\n code += emit`\n for(var ${kVar} in ${g.input}){\n if(!(${test})){\n ${seed}\n ${g.visit(ir.catchall, {\n input: slot,\n output: slot,\n path: extendPath(g.path, kVar),\n })}\n }\n }`;\n }\n\n if (needsClone) {\n code += `${g.output}=${objVar};`;\n }\n\n // Object-level refine effects: z.object({...}).refine(fn), suppressed when the\n // parse phase aborted (see refineMark). One gate covers every effect: each of\n // them can only add a continuable `custom` issue, so zod's per-check\n // re-evaluation of `isAborted` can never flip between them.\n if (ir.checks && ir.checks.length > 0) {\n let refines = \"\";\n for (const check of ir.checks) {\n refines +=\n check.kind === \"super_refine_effect\"\n ? superRefineCheck(check, objVar, g)\n : refineCheck(check, objVar, g);\n }\n const aborted = emitRuntimeHelper(g.ctx, \"__zcAb\", ZC_AB_DECL);\n code += `if(!${aborted}(${g.issues},${refineMark})){${refines}}`;\n }\n\n code += `}\\n`;\n return code;\n}\n\n/**\n * Property entries in the order their fast-checks should be `&&`-chained:\n * cheapest first, declaration order preserved among equals (Array#sort is\n * stable). Valid input runs every conjunct whatever the order, so this costs\n * nothing on the hot path; a REJECT stops at the first false conjunct, so\n * pricing a `z.email()` behind the `kind` literal that actually discriminates\n * is what makes union probing and `.is()` misses cheap (see\n * estimateRuntimeCost). The SLOW path keeps declaration order — that one's\n * output is the issue list, whose order is part of zod parity.\n */\nfunction orderedProperties(ir: ObjectIR, g: FastGen): [string, SchemaIR][] {\n return orderByRuntimeCost(Object.entries(ir.properties), ([, propIR]) => propIR, g.ctx);\n}\n\n/**\n * Property/strict/refine fast-checks for an object, WITHOUT the leading\n * `typeof===object && !==null && !Array.isArray` type-guard. Returns the\n * conjunct parts (joinable with `&&`), or null if any child is fast-ineligible.\n *\n * `skipKey`, when given, omits that one property's check. Used by the\n * discriminated-union fast path (via `g.discSkipKey`): the enclosing `switch`\n * has already matched the discriminator's value, so re-checking it is redundant.\n */\nfunction fastObjectBody(ir: ObjectIR, g: FastGen, skipKey?: string): string[] | null {\n const x = g.input;\n const parts: string[] = [];\n\n for (const [key, propIR] of orderedProperties(ir, g)) {\n if (key === skipKey) continue;\n const propExpr = `${x}[${escapeString(key)}]`;\n const propCheck = g.visit(propIR, { input: propExpr });\n if (propCheck === null) return null; // All-or-nothing\n parts.push(propCheck);\n }\n\n // Strict unknown-key pass: hosted boolean helper (a for-in loop cannot live\n // in the && chain). Same for-in iteration as the slow path — fast/slow\n // agreement is load-bearing under the __zcFinD deferral. The membership set is\n // the FULL key list (the discriminator is a recognized key), independent of\n // skipKey, which only suppresses re-validating the discriminator's value.\n if (ir.strict) {\n const keys = Object.keys(ir.properties);\n const fnName = g.temp(\"so\");\n const test = keyMembershipTest(g.ctx, keys, \"k\");\n g.ctx.preamble.push(\n `function ${fnName}(o){for(var k in o){if(!(${test}))return false;}return true;}`,\n );\n parts.push(`${fnName}(${x})`);\n }\n\n // .catchall(schema): same hosted for-in as strict, but each unrecognized key\n // is checked against the catchall rather than rejected outright. The value is\n // hoisted into a local for the same reason fastRecord does it — repeated\n // `o[k]` computed loads are not eliminated across check boundaries.\n if (ir.catchall) {\n const kv = g.temp(\"cak\");\n const vv = g.temp(\"cav\");\n const catchallGen = g.scoped(vv);\n const valCheck = catchallGen.visit(ir.catchall, { input: vv });\n if (valCheck === null) return null;\n if (valCheck !== \"true\") {\n const fnName = g.temp(\"co\");\n const test = keyMembershipTest(g.ctx, Object.keys(ir.properties), kv);\n g.ctx.preamble.push(\n `function ${fnName}(o){${declareFastTemps(catchallGen.scope)}var ${kv},${vv};for(${kv} in o){if(!(${test})){${vv}=o[${kv}];if(!(${valCheck}))return false;}}return true;}`,\n );\n parts.push(`${fnName}(${x})`);\n }\n }\n\n // Object-level refine effects (appended last — run after property checks short-circuit)\n if (ir.checks) {\n for (const check of ir.checks) {\n if (check.kind === \"refine_effect\") {\n parts.push(`${emitEffectCallable(g.ctx, check)}(${x})`);\n } else if (check.kind === \"super_refine_effect\") {\n parts.push(superRefineFastTest(check, x, g));\n }\n }\n }\n\n return parts;\n}\n\nexport function fastObject(ir: ObjectIR, g: FastGen): string | null {\n // A strip object still gets an expression. Stripping reshapes the OUTPUT, not\n // the verdict, so this remains an exact acceptance predicate — which is what\n // `.is()` installs, and what the build path reuses to validate the subtrees it\n // passes through by reference. What it must NOT do is stand in for the parse\n // result: generateValidator withholds the `data:input` shortcut whenever the\n // schema rebuilds (see rebuildsOutput).\n const x = g.input;\n const body = fastObjectBody(ir, g, g.discSkipKey);\n if (body === null) return null;\n // Discriminated-union option: the enclosing switch (and the caller's guard)\n // already established object-ness and the discriminator value, so emit only\n // the remaining checks — no leading type-guard. An option with nothing left\n // to check accepts unconditionally (\"true\").\n if (g.discSkipKey !== undefined) {\n return body.length > 0 ? body.join(\"&&\") : \"true\";\n }\n return [`typeof ${x}===\"object\"`, `${x}!==null`, `!Array.isArray(${x})`, ...body].join(\"&&\");\n}\n"],"mappings":";;;;;;;AAmBA,SAAgB,WAAW,IAAmC,GAAoB;CAChF,IAAI,OAAO,IAAI;gBACD,EAAE,MAAM,eAAe,EAAE,MAAM,yBAAyB,EAAE,MAAM;QACxE,YAAY,GAAG,QAAQ,EAAE;;CAM/B,MAAM,QAAQ,GAAG,qBAAqB;CACtC,MAAM,aACJ,SACC,GAAG,aAAa,KAAA,KAAa,YAAY,GAAG,QAAQ,KACrD,OAAO,OAAO,GAAG,UAAU,CAAC,CAAC,KAAK,WAAW;CAC/C,MAAM,SAAS,EAAE,KAAK,GAAG;CACzB,IAAI,CAAC,OAGH,QAAQ,aAAa,OAAO,OAAO,OAAO,EAAE,MAAM,MAAM,OAAO,OAAO,GAAG,EAAE,MAAM;CAYnF,MAAM,aAAa,GAAG,UAAU,GAAG,OAAO,SAAS,IAAI,EAAE,KAAK,IAAI,IAAI;CACtE,IAAI,YAAY,QAAQ,OAAO,WAAW,GAAG,EAAE,OAAO;CAEtD,MAAM,iBAAiB,IAAI,IAAI,GAAG,sBAAsB,CAAC,CAAC;;CAE1D,MAAM,QAA8D,CAAC;CAErE,KAAK,MAAM,CAAC,KAAK,WAAW,OAAO,QAAQ,GAAG,UAAU,GAAG;EACzD,MAAM,SAAS,aAAa,GAAG;EAC/B,MAAM,WAAW,iBAAiB,EAAE,MAAM,GAAG;EAM7C,MAAM,WAAW,QAAQ,EAAE,KAAK,IAAI,IAAI,GAAG,OAAO,GAAG,OAAO;EAC5D,IAAI,OAAO;GACT,QAAQ,OAAO,SAAS,GAAG,EAAE,MAAM,GAAG,OAAO;GAC7C,MAAM,KAAK;IAAE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jD,OAAO;AACT;AAEA,SAAgB,WAAW,IAAc,GAA2B;CAOlE,MAAM,IAAI,EAAE;CACZ,MAAM,OAAO,eAAe,IAAI,GAAG,EAAE,WAAW;CAChD,IAAI,SAAS,MAAM,OAAO;CAK1B,IAAI,EAAE,gBAAgB,KAAA,GACpB,OAAO,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,IAAI;CAE7C,OAAO;EAAC,UAAU,EAAE;EAAc,GAAG,EAAE;EAAU,kBAAkB,EAAE;EAAI,GAAG;CAAI,CAAC,CAAC,KAAK,IAAI;AAC7F"}
@@ -1,5 +1,6 @@
1
- import type { OptionalIR, SchemaIR } from "../../types.js";
2
- import type { FastGen, SlowGen } from "../context.js";
1
+ import { OptionalIR, SchemaIR } from "../../types.js";
2
+ import { FastGen, SlowGen } from "../context.js";
3
+ //#region src/core/codegen/schemas/optional.d.ts
3
4
  /**
4
5
  * Zod's `.optional()` short-circuits `undefined → undefined`, EXCEPT when its
5
6
  * inner chain applies a default to undefined: `z.string().default("d").optional()`
@@ -9,9 +10,11 @@ import type { FastGen, SlowGen } from "../context.js";
9
10
  * a value; `catch`, object-field defaults, and plain types do not, so the optional
10
11
  * legitimately short-circuits there. Peel optional/nullable wrappers to decide.
11
12
  */
12
- export declare function innerAppliesDefaultOnUndefined(ir: SchemaIR): boolean;
13
- export declare function slowOptional(ir: SchemaIR & {
14
- type: "optional";
13
+ declare function innerAppliesDefaultOnUndefined(ir: SchemaIR): boolean;
14
+ declare function slowOptional(ir: SchemaIR & {
15
+ type: "optional";
15
16
  }, g: SlowGen): string;
16
- export declare function fastOptional(ir: OptionalIR, g: FastGen): string | null;
17
+ declare function fastOptional(ir: OptionalIR, g: FastGen): string | null;
18
+ //#endregion
19
+ export { fastOptional, innerAppliesDefaultOnUndefined, slowOptional };
17
20
  //# sourceMappingURL=optional.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"optional.d.ts","sourceRoot":"","sources":["../../../../src/core/codegen/schemas/optional.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAItD;;;;;;;;GAQG;AACH,wBAAgB,8BAA8B,CAAC,EAAE,EAAE,QAAQ,GAAG,OAAO,CAIpE;AAED,wBAAgB,YAAY,CAAC,EAAE,EAAE,QAAQ,GAAG;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,EAAE,CAAC,EAAE,OAAO,GAAG,MAAM,CAcpF;AAED,wBAAgB,YAAY,CAAC,EAAE,EAAE,UAAU,EAAE,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAOtE"}
1
+ {"version":3,"file":"optional.d.ts","names":[],"sources":["../../../../src/core/codegen/schemas/optional.ts"],"mappings":";;;;;;;;;;;;iBAcgB,+BAA+B,IAAI;iBAMnC,aAAa,IAAI;EAAa;GAAoB,GAAG;iBAgBrD,aAAa,IAAI,YAAY,GAAG"}
@@ -1,42 +1,34 @@
1
1
  import { fastSentinelWrapper } from "../context.js";
2
2
  import { emit } from "../emit.js";
3
+ //#region src/core/codegen/schemas/optional.ts
3
4
  /**
4
- * Zod's `.optional()` short-circuits `undefined → undefined`, EXCEPT when its
5
- * inner chain applies a default to undefined: `z.string().default("d").optional()`
6
- * yields "d", not undefined (the default fires THROUGH the optional, and through
7
- * any nullable/optional wrappers between them — `default().nullish()`,
8
- * `default().optional().nullable()`, ...). Only `default` consumes undefined into
9
- * a value; `catch`, object-field defaults, and plain types do not, so the optional
10
- * legitimately short-circuits there. Peel optional/nullable wrappers to decide.
11
- */
12
- export function innerAppliesDefaultOnUndefined(ir) {
13
- let cur = ir;
14
- while (cur.type === "optional" || cur.type === "nullable")
15
- cur = cur.inner;
16
- return cur.type === "default";
5
+ * Zod's `.optional()` short-circuits `undefined → undefined`, EXCEPT when its
6
+ * inner chain applies a default to undefined: `z.string().default("d").optional()`
7
+ * yields "d", not undefined (the default fires THROUGH the optional, and through
8
+ * any nullable/optional wrappers between them — `default().nullish()`,
9
+ * `default().optional().nullable()`, ...). Only `default` consumes undefined into
10
+ * a value; `catch`, object-field defaults, and plain types do not, so the optional
11
+ * legitimately short-circuits there. Peel optional/nullable wrappers to decide.
12
+ */
13
+ function innerAppliesDefaultOnUndefined(ir) {
14
+ let cur = ir;
15
+ while (cur.type === "optional" || cur.type === "nullable") cur = cur.inner;
16
+ return cur.type === "default";
17
17
  }
18
- export function slowOptional(ir, g) {
19
- // Pass-through wrapper: forward the union abort flag (zod returns the inner
20
- // payload unchanged, so a pipe inner's `aborted` must reach the option).
21
- const fwd = { aborted: g.aborted };
22
- // When the inner chain handles undefined (a default), undefined must flow into
23
- // it so the default applies — the inner code already gates on undefined itself.
24
- if (innerAppliesDefaultOnUndefined(ir.inner)) {
25
- return `${g.visit(ir.inner, fwd)}\n`;
26
- }
27
- return `${emit `
18
+ function slowOptional(ir, g) {
19
+ const fwd = { aborted: g.aborted };
20
+ if (innerAppliesDefaultOnUndefined(ir.inner)) return `${g.visit(ir.inner, fwd)}\n`;
21
+ return `${emit`
28
22
  if(${g.input}!==undefined){
29
23
  ${g.visit(ir.inner, fwd)}
30
24
  }
31
25
  `}\n`;
32
26
  }
33
- export function fastOptional(ir, g) {
34
- // Same rule as the slow path: an inner default needs undefined to reach it, so
35
- // drop the `===undefined` shortcut (which would let safeParse return the raw
36
- // undefined before the eager slow path applies the default). The inner
37
- // fast-default expr already returns false on undefined, routing to the slow path.
38
- if (innerAppliesDefaultOnUndefined(ir.inner))
39
- return g.visit(ir.inner);
40
- return fastSentinelWrapper(g, ir.inner, "===undefined", "||");
27
+ function fastOptional(ir, g) {
28
+ if (innerAppliesDefaultOnUndefined(ir.inner)) return g.visit(ir.inner);
29
+ return fastSentinelWrapper(g, ir.inner, "===undefined", "||");
41
30
  }
31
+ //#endregion
32
+ export { fastOptional, innerAppliesDefaultOnUndefined, slowOptional };
33
+
42
34
  //# sourceMappingURL=optional.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"optional.js","sourceRoot":"","sources":["../../../../src/core/codegen/schemas/optional.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAElC;;;;;;;;GAQG;AACH,MAAM,UAAU,8BAA8B,CAAC,EAAY;IACzD,IAAI,GAAG,GAAG,EAAE,CAAC;IACb,OAAO,GAAG,CAAC,IAAI,KAAK,UAAU,IAAI,GAAG,CAAC,IAAI,KAAK,UAAU;QAAE,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC;IAC3E,OAAO,GAAG,CAAC,IAAI,KAAK,SAAS,CAAC;AAChC,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,EAAmC,EAAE,CAAU;IAC1E,4EAA4E;IAC5E,yEAAyE;IACzE,MAAM,GAAG,GAAG,EAAE,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC;IACnC,+EAA+E;IAC/E,gFAAgF;IAChF,IAAI,8BAA8B,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC;QAC7C,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,CAAC,IAAI,CAAC;IACvC,CAAC;IACD,OAAO,GAAG,IAAI,CAAA;SACP,CAAC,CAAC,KAAK;QACR,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,CAAC;;GAE3B,IAAI,CAAC;AACR,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,EAAc,EAAE,CAAU;IACrD,+EAA+E;IAC/E,6EAA6E;IAC7E,uEAAuE;IACvE,kFAAkF;IAClF,IAAI,8BAA8B,CAAC,EAAE,CAAC,KAAK,CAAC;QAAE,OAAO,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;IACvE,OAAO,mBAAmB,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,EAAE,cAAc,EAAE,IAAI,CAAC,CAAC;AAChE,CAAC"}
1
+ {"version":3,"file":"optional.js","names":[],"sources":["../../../../src/core/codegen/schemas/optional.ts"],"sourcesContent":["import type { OptionalIR, SchemaIR } from \"../../types.js\";\nimport type { FastGen, SlowGen } from \"../context.js\";\nimport { fastSentinelWrapper } from \"../context.js\";\nimport { emit } from \"../emit.js\";\n\n/**\n * Zod's `.optional()` short-circuits `undefined → undefined`, EXCEPT when its\n * inner chain applies a default to undefined: `z.string().default(\"d\").optional()`\n * yields \"d\", not undefined (the default fires THROUGH the optional, and through\n * any nullable/optional wrappers between them — `default().nullish()`,\n * `default().optional().nullable()`, ...). Only `default` consumes undefined into\n * a value; `catch`, object-field defaults, and plain types do not, so the optional\n * legitimately short-circuits there. Peel optional/nullable wrappers to decide.\n */\nexport function innerAppliesDefaultOnUndefined(ir: SchemaIR): boolean {\n let cur = ir;\n while (cur.type === \"optional\" || cur.type === \"nullable\") cur = cur.inner;\n return cur.type === \"default\";\n}\n\nexport function slowOptional(ir: SchemaIR & { type: \"optional\" }, g: SlowGen): string {\n // Pass-through wrapper: forward the union abort flag (zod returns the inner\n // payload unchanged, so a pipe inner's `aborted` must reach the option).\n const fwd = { aborted: g.aborted };\n // When the inner chain handles undefined (a default), undefined must flow into\n // it so the default applies — the inner code already gates on undefined itself.\n if (innerAppliesDefaultOnUndefined(ir.inner)) {\n return `${g.visit(ir.inner, fwd)}\\n`;\n }\n return `${emit`\n if(${g.input}!==undefined){\n ${g.visit(ir.inner, fwd)}\n }\n `}\\n`;\n}\n\nexport function fastOptional(ir: OptionalIR, g: FastGen): string | null {\n // Same rule as the slow path: an inner default needs undefined to reach it, so\n // drop the `===undefined` shortcut (which would let safeParse return the raw\n // undefined before the eager slow path applies the default). The inner\n // fast-default expr already returns false on undefined, routing to the slow path.\n if (innerAppliesDefaultOnUndefined(ir.inner)) return g.visit(ir.inner);\n return fastSentinelWrapper(g, ir.inner, \"===undefined\", \"||\");\n}\n"],"mappings":";;;;;;;;;;;;AAcA,SAAgB,+BAA+B,IAAuB;CACpE,IAAI,MAAM;CACV,OAAO,IAAI,SAAS,cAAc,IAAI,SAAS,YAAY,MAAM,IAAI;CACrE,OAAO,IAAI,SAAS;AACtB;AAEA,SAAgB,aAAa,IAAqC,GAAoB;CAGpF,MAAM,MAAM,EAAE,SAAS,EAAE,QAAQ;CAGjC,IAAI,+BAA+B,GAAG,KAAK,GACzC,OAAO,GAAG,EAAE,MAAM,GAAG,OAAO,GAAG,EAAE;CAEnC,OAAO,GAAG,IAAI;SACP,EAAE,MAAM;QACT,EAAE,MAAM,GAAG,OAAO,GAAG,EAAE;;IAE3B;AACJ;AAEA,SAAgB,aAAa,IAAgB,GAA2B;CAKtE,IAAI,+BAA+B,GAAG,KAAK,GAAG,OAAO,EAAE,MAAM,GAAG,KAAK;CACrE,OAAO,oBAAoB,GAAG,GAAG,OAAO,gBAAgB,IAAI;AAC9D"}
@@ -1,7 +1,10 @@
1
- import type { PipeIR, SchemaIR } from "../../types.js";
2
- import type { FastGen, SlowGen } from "../context.js";
3
- export declare function slowPipe(ir: SchemaIR & {
4
- type: "pipe";
1
+ import { PipeIR, SchemaIR } from "../../types.js";
2
+ import { FastGen, SlowGen } from "../context.js";
3
+ //#region src/core/codegen/schemas/pipe.d.ts
4
+ declare function slowPipe(ir: SchemaIR & {
5
+ type: "pipe";
5
6
  }, g: SlowGen): string;
6
- export declare function fastPipe(ir: PipeIR, g: FastGen): string | null;
7
+ declare function fastPipe(ir: PipeIR, g: FastGen): string | null;
8
+ //#endregion
9
+ export { fastPipe, slowPipe };
7
10
  //# sourceMappingURL=pipe.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"pipe.d.ts","sourceRoot":"","sources":["../../../../src/core/codegen/schemas/pipe.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAEtD,wBAAgB,QAAQ,CAAC,EAAE,EAAE,QAAQ,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,EAAE,CAAC,EAAE,OAAO,GAAG,MAAM,CAe5E;AAED,wBAAgB,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAU9D"}
1
+ {"version":3,"file":"pipe.d.ts","names":[],"sources":["../../../../src/core/codegen/schemas/pipe.ts"],"mappings":";;;iBAGgB,SAAS,IAAI;EAAa;GAAgB,GAAG;iBAiB7C,SAAS,IAAI,QAAQ,GAAG"}