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,289 +1,253 @@
1
- /**
2
- * Static per-file dependency graphs for disk-cache invalidation.
3
- *
4
- * The disk cache used to record `getFirstPartyModulePaths()` — the superset
5
- * of EVERY first-party module the loader had executed so far — as each
6
- * entry's dependency set. Supersets never serve stale results, but in a
7
- * large codebase every entry ends up recording the whole project (~1,900
8
- * deps, ~400KB JSON per entry in the field report), so ANY commit
9
- * invalidates essentially the entire cache and CI re-pays full discovery
10
- * every run.
11
- *
12
- * This module computes the file's ACTUAL import graph statically: scan
13
- * import/export/require specifiers, resolve them (relative paths with
14
- * extension probing, tsconfig path aliases via the loader's config, bare
15
- * specifiers through node resolution), and BFS across first-party files.
16
- * No file is executed. Type-only imports are included (over-approximation
17
- * only over-invalidates).
18
- *
19
- * Soundness rule: when anything cannot be analyzed — a non-literal dynamic
20
- * import, an unresolvable relative specifier — the crawl reports
21
- * `complete: false` and the caller falls back to the superset. A static
22
- * crawl may only replace the superset when it provably covers everything
23
- * the file can load.
24
- *
25
- * Cost discipline (this runs serialized on the bundler's main process, once
26
- * per discovery file, over closures that reach thousands of files):
27
- * - every existence probe uses `statSync(p, { throwIfNoEntry: false })` —
28
- * a thrown ENOENT pays V8 error-plus-stack construction, and a cold crawl
29
- * issues these probes by the million (the dominant cost in field samples);
30
- * - resolution is memoized at every level: realpath per path, createRequire
31
- * per directory, resolved specifier per (directory, specifier), and the
32
- * full edge list per file (mtime-validated) — repeat crawls over the
33
- * shared core graph are Map lookups plus one cheap stat per file;
34
- * - the BFS aborts the moment the graph becomes unanalyzable: the caller
35
- * discards an incomplete result for the superset anyway, so finishing the
36
- * crawl would be pure waste (and incomplete is the COMMON outcome on
37
- * large graphs — one dynamic import anywhere poisons the whole closure).
38
- */
39
- import * as fs from "node:fs";
40
- import { createRequire } from "node:module";
41
- import * as path from "node:path";
42
1
  import { resolveTsconfigPathCandidates } from "../loader.js";
43
- const SOURCE_EXTENSIONS = [".ts", ".tsx", ".mts", ".cts", ".js", ".jsx", ".mjs", ".cjs"];
44
- const NODE_MODULES_SEGMENT = `${path.sep}node_modules${path.sep}`;
2
+ import { createRequire } from "node:module";
3
+ import * as path$1 from "node:path";
4
+ import * as fs$1 from "node:fs";
5
+ //#region src/unplugin/dep-graph.ts
6
+ /**
7
+ * Static per-file dependency graphs for disk-cache invalidation.
8
+ *
9
+ * The disk cache used to record `getFirstPartyModulePaths()` — the superset
10
+ * of EVERY first-party module the loader had executed so far — as each
11
+ * entry's dependency set. Supersets never serve stale results, but in a
12
+ * large codebase every entry ends up recording the whole project (~1,900
13
+ * deps, ~400KB JSON per entry in the field report), so ANY commit
14
+ * invalidates essentially the entire cache and CI re-pays full discovery
15
+ * every run.
16
+ *
17
+ * This module computes the file's ACTUAL import graph statically: scan
18
+ * import/export/require specifiers, resolve them (relative paths with
19
+ * extension probing, tsconfig path aliases via the loader's config, bare
20
+ * specifiers through node resolution), and BFS across first-party files.
21
+ * No file is executed. Type-only imports are included (over-approximation
22
+ * only over-invalidates).
23
+ *
24
+ * Soundness rule: when anything cannot be analyzed — a non-literal dynamic
25
+ * import, an unresolvable relative specifier — the crawl reports
26
+ * `complete: false` and the caller falls back to the superset. A static
27
+ * crawl may only replace the superset when it provably covers everything
28
+ * the file can load.
29
+ *
30
+ * Cost discipline (this runs serialized on the bundler's main process, once
31
+ * per discovery file, over closures that reach thousands of files):
32
+ * - every existence probe uses `statSync(p, { throwIfNoEntry: false })` —
33
+ * a thrown ENOENT pays V8 error-plus-stack construction, and a cold crawl
34
+ * issues these probes by the million (the dominant cost in field samples);
35
+ * - resolution is memoized at every level: realpath per path, createRequire
36
+ * per directory, resolved specifier per (directory, specifier), and the
37
+ * full edge list per file (mtime-validated) — repeat crawls over the
38
+ * shared core graph are Map lookups plus one cheap stat per file;
39
+ * - the BFS aborts the moment the graph becomes unanalyzable: the caller
40
+ * discards an incomplete result for the superset anyway, so finishing the
41
+ * crawl would be pure waste (and incomplete is the COMMON outcome on
42
+ * large graphs — one dynamic import anywhere poisons the whole closure).
43
+ */
44
+ const SOURCE_EXTENSIONS = [
45
+ ".ts",
46
+ ".tsx",
47
+ ".mts",
48
+ ".cts",
49
+ ".js",
50
+ ".jsx",
51
+ ".mjs",
52
+ ".cjs"
53
+ ];
54
+ const NODE_MODULES_SEGMENT = `${path$1.sep}node_modules${path$1.sep}`;
45
55
  /** Specifier schemes that never resolve to project files. */
46
- // oxlint-disable-next-line no-control-regex -- rollup-convention virtual module ids begin with NUL
47
56
  const SKIP_SPECIFIER = /^(?:node:|data:|virtual:|\u0000)/;
48
57
  /** Runaway guard — graphs larger than this fall back to the superset. */
49
- const MAX_FILES = 10_000;
50
- const INCOMPLETE = { deps: [], complete: false };
58
+ const MAX_FILES = 1e4;
59
+ const INCOMPLETE = {
60
+ deps: [],
61
+ complete: false
62
+ };
51
63
  /**
52
- * Resolution-failure sentinel. A unique symbol rather than a string literal:
53
- * `"incomplete" | string` collapses to `string`, so the type system could
54
- * not distinguish a resolved path from the failure marker.
55
- */
64
+ * Resolution-failure sentinel. A unique symbol rather than a string literal:
65
+ * `"incomplete" | string` collapses to `string`, so the type system could
66
+ * not distinguish a resolved path from the failure marker.
67
+ */
56
68
  const UNRESOLVED = Symbol("unresolved");
57
69
  /**
58
- * Per-process memos. The file node memo is revalidated by mtime on every
59
- * visit; the resolution memos (specifier, realpath, require) depend on the
60
- * filesystem layout rather than file contents and are only dropped by
61
- * resetDepGraphMemo() — the same wholesale invalidation watch mode already
62
- * applies to the module cache (a memoized resolution can only go stale when
63
- * files appear/move, which fires watchChange).
64
- */
65
- const nodeMemo = new Map();
66
- const resolveMemo = new Map();
67
- const realpathMemo = new Map();
68
- const requireMemo = new Map();
70
+ * Per-process memos. The file node memo is revalidated by mtime on every
71
+ * visit; the resolution memos (specifier, realpath, require) depend on the
72
+ * filesystem layout rather than file contents and are only dropped by
73
+ * resetDepGraphMemo() — the same wholesale invalidation watch mode already
74
+ * applies to the module cache (a memoized resolution can only go stale when
75
+ * files appear/move, which fires watchChange).
76
+ */
77
+ const nodeMemo = /* @__PURE__ */ new Map();
78
+ const resolveMemo = /* @__PURE__ */ new Map();
79
+ const realpathMemo = /* @__PURE__ */ new Map();
80
+ const requireMemo = /* @__PURE__ */ new Map();
69
81
  /** Reset the per-process dep-graph memos (watch-mode file changes). */
70
- export function resetDepGraphMemo() {
71
- nodeMemo.clear();
72
- resolveMemo.clear();
73
- realpathMemo.clear();
74
- requireMemo.clear();
82
+ function resetDepGraphMemo() {
83
+ nodeMemo.clear();
84
+ resolveMemo.clear();
85
+ realpathMemo.clear();
86
+ requireMemo.clear();
75
87
  }
76
88
  const STATIC_SPECIFIER = /(?:\bfrom\s*|\bimport\s+|\bimport\s*\(\s*|\brequire\s*\(\s*)["']([^"'\n]+)["']/g;
77
- // No /g flag: `.test()` on a global regex resumes from lastIndex of the
78
- // PREVIOUS file's match, silently missing dynamic imports (a missed
79
- // detection records a falsely-complete dep set — stale cache).
80
89
  const DYNAMIC_CALL = /\b(?:import|require)\s*\(\s*(?!["'])[^)\s]/;
81
90
  /** statSync that reports ENOENT as undefined instead of an exception. */
82
91
  function tryStat(p) {
83
- try {
84
- return fs.statSync(p, { throwIfNoEntry: false });
85
- }
86
- catch {
87
- // Non-ENOENT errors (ENOTDIR from probing `file.ts/index.ts`, EACCES):
88
- // treat as absent.
89
- return undefined;
90
- }
92
+ try {
93
+ return fs$1.statSync(p, { throwIfNoEntry: false });
94
+ } catch {
95
+ return;
96
+ }
91
97
  }
92
98
  function tryFile(p) {
93
- return tryStat(p)?.isFile() ? p : null;
99
+ return tryStat(p)?.isFile() ? p : null;
94
100
  }
95
101
  /** Probe a path (possibly extensionless) to an existing file. */
96
102
  function probeFile(base) {
97
- const hasExtension = path.extname(base) !== "";
98
- if (hasExtension) {
99
- if (tryFile(base))
100
- return base;
101
- // Extensioned path that doesn't exist as-is: TS source referenced with a
102
- // .js specifier (nodenext style). Probe the extension-family swap before
103
- // the append/index probes — in nodenext codebases this is the common hit
104
- // and skips ~16 dead probes per import.
105
- if (/\.[cm]?js$/.test(base)) {
106
- const hit = tryFile(base.replace(/\.([cm]?)js$/, ".$1ts")) ??
107
- tryFile(base.replace(/\.[cm]?js$/, ".tsx"));
108
- if (hit)
109
- return hit;
110
- }
111
- }
112
- for (const ext of SOURCE_EXTENSIONS) {
113
- const hit = tryFile(base + ext);
114
- if (hit)
115
- return hit;
116
- }
117
- for (const ext of SOURCE_EXTENSIONS) {
118
- const hit = tryFile(path.join(base, `index${ext}`));
119
- if (hit)
120
- return hit;
121
- }
122
- // Extensionless path that exists exactly (e.g. ./bin/cli).
123
- return hasExtension ? null : tryFile(base);
103
+ const hasExtension = path$1.extname(base) !== "";
104
+ if (hasExtension) {
105
+ if (tryFile(base)) return base;
106
+ if (/\.[cm]?js$/.test(base)) {
107
+ const hit = tryFile(base.replace(/\.([cm]?)js$/, ".$1ts")) ?? tryFile(base.replace(/\.[cm]?js$/, ".tsx"));
108
+ if (hit) return hit;
109
+ }
110
+ }
111
+ for (const ext of SOURCE_EXTENSIONS) {
112
+ const hit = tryFile(base + ext);
113
+ if (hit) return hit;
114
+ }
115
+ for (const ext of SOURCE_EXTENSIONS) {
116
+ const hit = tryFile(path$1.join(base, `index${ext}`));
117
+ if (hit) return hit;
118
+ }
119
+ return hasExtension ? null : tryFile(base);
124
120
  }
125
121
  function realpathOf(p) {
126
- let real = realpathMemo.get(p);
127
- if (real === undefined) {
128
- try {
129
- real = fs.realpathSync(p);
130
- }
131
- catch {
132
- real = p; // keep the unresolved path
133
- }
134
- realpathMemo.set(p, real);
135
- }
136
- return real;
122
+ let real = realpathMemo.get(p);
123
+ if (real === void 0) {
124
+ try {
125
+ real = fs$1.realpathSync(p);
126
+ } catch {
127
+ real = p;
128
+ }
129
+ realpathMemo.set(p, real);
130
+ }
131
+ return real;
137
132
  }
138
133
  function firstPartyOrNull(resolved) {
139
- const real = realpathOf(resolved);
140
- return real.includes(NODE_MODULES_SEGMENT) ? null : real;
134
+ const real = realpathOf(resolved);
135
+ return real.includes(NODE_MODULES_SEGMENT) ? null : real;
141
136
  }
142
137
  /** Node resolution is a function of the importing DIRECTORY, not the file. */
143
138
  function requireFor(dir) {
144
- let req = requireMemo.get(dir);
145
- if (req === undefined) {
146
- req = createRequire(path.join(dir, "__zod_compiler_resolve__.js"));
147
- requireMemo.set(dir, req);
148
- }
149
- return req;
139
+ let req = requireMemo.get(dir);
140
+ if (req === void 0) {
141
+ req = createRequire(path$1.join(dir, "__zod_compiler_resolve__.js"));
142
+ requireMemo.set(dir, req);
143
+ }
144
+ return req;
150
145
  }
151
146
  /**
152
- * Resolve one specifier from a directory. Returns:
153
- * - an absolute path (first-party file to record + crawl)
154
- * - null when the dep is intentionally out of scope (node_modules, builtins)
155
- * - UNRESOLVED when resolution failed and the graph cannot be trusted
156
- */
147
+ * Resolve one specifier from a directory. Returns:
148
+ * - an absolute path (first-party file to record + crawl)
149
+ * - null when the dep is intentionally out of scope (node_modules, builtins)
150
+ * - UNRESOLVED when resolution failed and the graph cannot be trusted
151
+ */
157
152
  function resolveSpecifier(rawSpec, fromDir) {
158
- if (SKIP_SPECIFIER.test(rawSpec))
159
- return null;
160
- const memoKey = `${fromDir}\0${rawSpec}`;
161
- const memoized = resolveMemo.get(memoKey);
162
- if (memoized !== undefined)
163
- return memoized;
164
- const result = resolveSpecifierUncached(rawSpec, fromDir);
165
- resolveMemo.set(memoKey, result);
166
- return result;
153
+ if (SKIP_SPECIFIER.test(rawSpec)) return null;
154
+ const memoKey = `${fromDir}\0${rawSpec}`;
155
+ const memoized = resolveMemo.get(memoKey);
156
+ if (memoized !== void 0) return memoized;
157
+ const result = resolveSpecifierUncached(rawSpec, fromDir);
158
+ resolveMemo.set(memoKey, result);
159
+ return result;
167
160
  }
168
161
  function resolveSpecifierUncached(rawSpec, fromDir) {
169
- // Vite-style resource queries (./logo.svg?url, ./shader.glsl?raw) resolve
170
- // to the underlying file.
171
- const q = rawSpec.indexOf("?");
172
- const spec = q === -1 ? rawSpec : rawSpec.slice(0, q);
173
- if (spec === "")
174
- return null;
175
- if (spec.startsWith("./") || spec.startsWith("../")) {
176
- const hit = probeFile(path.resolve(fromDir, spec));
177
- return hit === null ? UNRESOLVED : firstPartyOrNull(hit);
178
- }
179
- const { candidates, authoritative } = resolveTsconfigPathCandidates(fromDir, spec);
180
- for (const candidate of candidates) {
181
- const hit = probeFile(candidate);
182
- if (hit !== null) {
183
- return firstPartyOrNull(hit);
184
- }
185
- }
186
- // An authoritative miss (explicit `paths` pattern matched, or the paths
187
- // config is present but uninterpretable) means the import cannot be
188
- // trusted. Implicit baseUrl candidates are proposed for EVERY bare
189
- // specifier (npm packages, `#` imports) and only mean "try baseDir
190
- // first" — a miss falls through to node resolution below.
191
- if (authoritative)
192
- return UNRESOLVED;
193
- // Bare specifier (package) or package.json "imports" (#...): node
194
- // resolution from the importing directory. node_modules results are out of
195
- // scope (zod's version is part of the cache key); symlinked workspace
196
- // packages realpath outside node_modules and are crawled as first-party.
197
- try {
198
- const resolved = requireFor(fromDir).resolve(spec);
199
- if (!path.isAbsolute(resolved))
200
- return null; // node builtin
201
- return firstPartyOrNull(resolved);
202
- }
203
- catch {
204
- // Unresolvable from Node's algorithm. jiti may still resolve it (e.g.
205
- // ESM-only packages without CJS entries) — the file itself stays a dep
206
- // through the entry, but its subtree is unknown for bare packages.
207
- // Treat unresolvable BARE specifiers as out-of-scope third-party
208
- // (caught by the zod-version/plugin key when relevant) only when they
209
- // cannot be project files; '#' subpath imports stay strict.
210
- return spec.startsWith("#") ? UNRESOLVED : null;
211
- }
162
+ const q = rawSpec.indexOf("?");
163
+ const spec = q === -1 ? rawSpec : rawSpec.slice(0, q);
164
+ if (spec === "") return null;
165
+ if (spec.startsWith("./") || spec.startsWith("../")) {
166
+ const hit = probeFile(path$1.resolve(fromDir, spec));
167
+ return hit === null ? UNRESOLVED : firstPartyOrNull(hit);
168
+ }
169
+ const { candidates, authoritative } = resolveTsconfigPathCandidates(fromDir, spec);
170
+ for (const candidate of candidates) {
171
+ const hit = probeFile(candidate);
172
+ if (hit !== null) return firstPartyOrNull(hit);
173
+ }
174
+ if (authoritative) return UNRESOLVED;
175
+ try {
176
+ const resolved = requireFor(fromDir).resolve(spec);
177
+ if (!path$1.isAbsolute(resolved)) return null;
178
+ return firstPartyOrNull(resolved);
179
+ } catch {
180
+ return spec.startsWith("#") ? UNRESOLVED : null;
181
+ }
212
182
  }
213
183
  /**
214
- * Scan + resolve one file into its edge list. Memoized by mtime, so the
215
- * shared core graph is read and resolved once per process — each entry's
216
- * closure walk after that is one cheap stat plus Map lookups per file.
217
- * Returns null for unreadable files.
218
- */
184
+ * Scan + resolve one file into its edge list. Memoized by mtime, so the
185
+ * shared core graph is read and resolved once per process — each entry's
186
+ * closure walk after that is one cheap stat plus Map lookups per file.
187
+ * Returns null for unreadable files.
188
+ */
219
189
  function fileNode(filePath) {
220
- const stat = tryStat(filePath);
221
- if (stat === undefined || !stat.isFile()) {
222
- nodeMemo.set(filePath, null);
223
- return null;
224
- }
225
- const memo = nodeMemo.get(filePath);
226
- if (memo !== undefined && memo !== null && memo.mtimeMs === stat.mtimeMs)
227
- return memo;
228
- let source;
229
- try {
230
- source = fs.readFileSync(filePath, "utf8");
231
- }
232
- catch {
233
- nodeMemo.set(filePath, null);
234
- return null;
235
- }
236
- // String/comment contents can false-positive both patterns; extra
237
- // specifiers only add deps (safe), a false `incomplete` only falls back
238
- // to the superset (safe).
239
- let incomplete = DYNAMIC_CALL.test(source);
240
- const edges = [];
241
- const seen = new Set();
242
- const dir = path.dirname(filePath);
243
- for (const m of source.matchAll(STATIC_SPECIFIER)) {
244
- const spec = m[1];
245
- if (!spec)
246
- continue;
247
- const resolved = resolveSpecifier(spec, dir);
248
- if (resolved === UNRESOLVED) {
249
- incomplete = true;
250
- }
251
- else if (resolved !== null && !seen.has(resolved)) {
252
- seen.add(resolved);
253
- edges.push(resolved);
254
- }
255
- }
256
- const node = { mtimeMs: stat.mtimeMs, edges, incomplete };
257
- nodeMemo.set(filePath, node);
258
- return node;
190
+ const stat = tryStat(filePath);
191
+ if (stat === void 0 || !stat.isFile()) {
192
+ nodeMemo.set(filePath, null);
193
+ return null;
194
+ }
195
+ const memo = nodeMemo.get(filePath);
196
+ if (memo !== void 0 && memo !== null && memo.mtimeMs === stat.mtimeMs) return memo;
197
+ let source;
198
+ try {
199
+ source = fs$1.readFileSync(filePath, "utf8");
200
+ } catch {
201
+ nodeMemo.set(filePath, null);
202
+ return null;
203
+ }
204
+ let incomplete = DYNAMIC_CALL.test(source);
205
+ const edges = [];
206
+ const seen = /* @__PURE__ */ new Set();
207
+ const dir = path$1.dirname(filePath);
208
+ for (const m of source.matchAll(STATIC_SPECIFIER)) {
209
+ const spec = m[1];
210
+ if (!spec) continue;
211
+ const resolved = resolveSpecifier(spec, dir);
212
+ if (resolved === UNRESOLVED) incomplete = true;
213
+ else if (resolved !== null && !seen.has(resolved)) {
214
+ seen.add(resolved);
215
+ edges.push(resolved);
216
+ }
217
+ }
218
+ const node = {
219
+ mtimeMs: stat.mtimeMs,
220
+ edges,
221
+ incomplete
222
+ };
223
+ nodeMemo.set(filePath, node);
224
+ return node;
259
225
  }
260
226
  /**
261
- * Compute the static first-party dependency closure of `entryFile`.
262
- * The entry itself is excluded (its content is part of the cache key).
263
- */
264
- export function collectStaticDeps(entryFile) {
265
- const entry = firstPartyOrNull(path.resolve(entryFile));
266
- if (entry === null)
267
- return INCOMPLETE;
268
- const visited = new Set([entry]);
269
- const queue = [entry];
270
- while (queue.length > 0) {
271
- if (visited.size > MAX_FILES)
272
- return INCOMPLETE;
273
- const file = queue.pop();
274
- const node = fileNode(file);
275
- // Any unanalyzable node poisons the whole closure; the caller falls back
276
- // to the superset, so abort instead of crawling to exhaustion.
277
- if (node === null || node.incomplete)
278
- return INCOMPLETE;
279
- for (const dep of node.edges) {
280
- if (!visited.has(dep)) {
281
- visited.add(dep);
282
- queue.push(dep);
283
- }
284
- }
285
- }
286
- visited.delete(entry);
287
- return { deps: [...visited], complete: true };
227
+ * Compute the static first-party dependency closure of `entryFile`.
228
+ * The entry itself is excluded (its content is part of the cache key).
229
+ */
230
+ function collectStaticDeps(entryFile) {
231
+ const entry = firstPartyOrNull(path$1.resolve(entryFile));
232
+ if (entry === null) return INCOMPLETE;
233
+ const visited = /* @__PURE__ */ new Set([entry]);
234
+ const queue = [entry];
235
+ while (queue.length > 0) {
236
+ if (visited.size > MAX_FILES) return INCOMPLETE;
237
+ const node = fileNode(queue.pop());
238
+ if (node === null || node.incomplete) return INCOMPLETE;
239
+ for (const dep of node.edges) if (!visited.has(dep)) {
240
+ visited.add(dep);
241
+ queue.push(dep);
242
+ }
243
+ }
244
+ visited.delete(entry);
245
+ return {
246
+ deps: [...visited],
247
+ complete: true
248
+ };
288
249
  }
250
+ //#endregion
251
+ export { collectStaticDeps, resetDepGraphMemo };
252
+
289
253
  //# sourceMappingURL=dep-graph.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"dep-graph.js","sourceRoot":"","sources":["../../src/unplugin/dep-graph.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,6BAA6B,EAAE,MAAM,cAAc,CAAC;AAS7D,MAAM,iBAAiB,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AACzF,MAAM,oBAAoB,GAAG,GAAG,IAAI,CAAC,GAAG,eAAe,IAAI,CAAC,GAAG,EAAE,CAAC;AAClE,6DAA6D;AAC7D,mGAAmG;AACnG,MAAM,cAAc,GAAG,kCAAkC,CAAC;AAC1D,yEAAyE;AACzE,MAAM,SAAS,GAAG,MAAM,CAAC;AAEzB,MAAM,UAAU,GAAe,EAAE,IAAI,EAAE,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;AAE7D;;;;GAIG;AACH,MAAM,UAAU,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC;AAUxC;;;;;;;GAOG;AACH,MAAM,QAAQ,GAAG,IAAI,GAAG,EAA2B,CAAC;AACpD,MAAM,WAAW,GAAG,IAAI,GAAG,EAA6C,CAAC;AACzE,MAAM,YAAY,GAAG,IAAI,GAAG,EAAkB,CAAC;AAC/C,MAAM,WAAW,GAAG,IAAI,GAAG,EAA4C,CAAC;AAExE,uEAAuE;AACvE,MAAM,UAAU,iBAAiB;IAC/B,QAAQ,CAAC,KAAK,EAAE,CAAC;IACjB,WAAW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CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACtB,OAAO,EAAE,IAAI,EAAE,CAAC,GAAG,OAAO,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;AAChD,CAAC"}
1
+ {"version":3,"file":"dep-graph.js","names":["path","fs"],"sources":["../../src/unplugin/dep-graph.ts"],"sourcesContent":["/**\n * Static per-file dependency graphs for disk-cache invalidation.\n *\n * The disk cache used to record `getFirstPartyModulePaths()` — the superset\n * of EVERY first-party module the loader had executed so far — as each\n * entry's dependency set. Supersets never serve stale results, but in a\n * large codebase every entry ends up recording the whole project (~1,900\n * deps, ~400KB JSON per entry in the field report), so ANY commit\n * invalidates essentially the entire cache and CI re-pays full discovery\n * every run.\n *\n * This module computes the file's ACTUAL import graph statically: scan\n * import/export/require specifiers, resolve them (relative paths with\n * extension probing, tsconfig path aliases via the loader's config, bare\n * specifiers through node resolution), and BFS across first-party files.\n * No file is executed. Type-only imports are included (over-approximation\n * only over-invalidates).\n *\n * Soundness rule: when anything cannot be analyzed — a non-literal dynamic\n * import, an unresolvable relative specifier — the crawl reports\n * `complete: false` and the caller falls back to the superset. A static\n * crawl may only replace the superset when it provably covers everything\n * the file can load.\n *\n * Cost discipline (this runs serialized on the bundler's main process, once\n * per discovery file, over closures that reach thousands of files):\n * - every existence probe uses `statSync(p, { throwIfNoEntry: false })` —\n * a thrown ENOENT pays V8 error-plus-stack construction, and a cold crawl\n * issues these probes by the million (the dominant cost in field samples);\n * - resolution is memoized at every level: realpath per path, createRequire\n * per directory, resolved specifier per (directory, specifier), and the\n * full edge list per file (mtime-validated) — repeat crawls over the\n * shared core graph are Map lookups plus one cheap stat per file;\n * - the BFS aborts the moment the graph becomes unanalyzable: the caller\n * discards an incomplete result for the superset anyway, so finishing the\n * crawl would be pure waste (and incomplete is the COMMON outcome on\n * large graphs — one dynamic import anywhere poisons the whole closure).\n */\n\nimport * as fs from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport * as path from \"node:path\";\nimport { resolveTsconfigPathCandidates } from \"../loader.js\";\n\nexport interface StaticDeps {\n /** Absolute real paths of first-party files reachable from the entry. */\n deps: string[];\n /** False when the graph could not be fully analyzed — use the superset. */\n complete: boolean;\n}\n\nconst SOURCE_EXTENSIONS = [\".ts\", \".tsx\", \".mts\", \".cts\", \".js\", \".jsx\", \".mjs\", \".cjs\"];\nconst NODE_MODULES_SEGMENT = `${path.sep}node_modules${path.sep}`;\n/** Specifier schemes that never resolve to project files. */\n// oxlint-disable-next-line no-control-regex -- rollup-convention virtual module ids begin with NUL\nconst SKIP_SPECIFIER = /^(?:node:|data:|virtual:|\\u0000)/;\n/** Runaway guard — graphs larger than this fall back to the superset. */\nconst MAX_FILES = 10_000;\n\nconst INCOMPLETE: StaticDeps = { deps: [], complete: false };\n\n/**\n * Resolution-failure sentinel. A unique symbol rather than a string literal:\n * `\"incomplete\" | string` collapses to `string`, so the type system could\n * not distinguish a resolved path from the failure marker.\n */\nconst UNRESOLVED = Symbol(\"unresolved\");\n\ninterface FileNode {\n mtimeMs: number;\n /** Resolved first-party imports (absolute real paths), deduped. */\n edges: string[];\n /** Non-literal dynamic import/require or unresolvable specifier. */\n incomplete: boolean;\n}\n\n/**\n * Per-process memos. The file node memo is revalidated by mtime on every\n * visit; the resolution memos (specifier, realpath, require) depend on the\n * filesystem layout rather than file contents and are only dropped by\n * resetDepGraphMemo() — the same wholesale invalidation watch mode already\n * applies to the module cache (a memoized resolution can only go stale when\n * files appear/move, which fires watchChange).\n */\nconst nodeMemo = new Map<string, FileNode | null>();\nconst resolveMemo = new Map<string, string | null | typeof UNRESOLVED>();\nconst realpathMemo = new Map<string, string>();\nconst requireMemo = new Map<string, ReturnType<typeof createRequire>>();\n\n/** Reset the per-process dep-graph memos (watch-mode file changes). */\nexport function resetDepGraphMemo(): void {\n nodeMemo.clear();\n resolveMemo.clear();\n realpathMemo.clear();\n requireMemo.clear();\n}\n\nconst STATIC_SPECIFIER =\n /(?:\\bfrom\\s*|\\bimport\\s+|\\bimport\\s*\\(\\s*|\\brequire\\s*\\(\\s*)[\"']([^\"'\\n]+)[\"']/g;\n// No /g flag: `.test()` on a global regex resumes from lastIndex of the\n// PREVIOUS file's match, silently missing dynamic imports (a missed\n// detection records a falsely-complete dep set — stale cache).\nconst DYNAMIC_CALL = /\\b(?:import|require)\\s*\\(\\s*(?![\"'])[^)\\s]/;\n\n/** statSync that reports ENOENT as undefined instead of an exception. */\nfunction tryStat(p: string): fs.Stats | undefined {\n try {\n return fs.statSync(p, { throwIfNoEntry: false });\n } catch {\n // Non-ENOENT errors (ENOTDIR from probing `file.ts/index.ts`, EACCES):\n // treat as absent.\n return undefined;\n }\n}\n\nfunction tryFile(p: string): string | null {\n return tryStat(p)?.isFile() ? p : null;\n}\n\n/** Probe a path (possibly extensionless) to an existing file. */\nfunction probeFile(base: string): string | null {\n const hasExtension = path.extname(base) !== \"\";\n if (hasExtension) {\n if (tryFile(base)) return base;\n // Extensioned path that doesn't exist as-is: TS source referenced with a\n // .js specifier (nodenext style). Probe the extension-family swap before\n // the append/index probes — in nodenext codebases this is the common hit\n // and skips ~16 dead probes per import.\n if (/\\.[cm]?js$/.test(base)) {\n const hit =\n tryFile(base.replace(/\\.([cm]?)js$/, \".$1ts\")) ??\n tryFile(base.replace(/\\.[cm]?js$/, \".tsx\"));\n if (hit) return hit;\n }\n }\n for (const ext of SOURCE_EXTENSIONS) {\n const hit = tryFile(base + ext);\n if (hit) return hit;\n }\n for (const ext of SOURCE_EXTENSIONS) {\n const hit = tryFile(path.join(base, `index${ext}`));\n if (hit) return hit;\n }\n // Extensionless path that exists exactly (e.g. ./bin/cli).\n return hasExtension ? null : tryFile(base);\n}\n\nfunction realpathOf(p: string): string {\n let real = realpathMemo.get(p);\n if (real === undefined) {\n try {\n real = fs.realpathSync(p);\n } catch {\n real = p; // keep the unresolved path\n }\n realpathMemo.set(p, real);\n }\n return real;\n}\n\nfunction firstPartyOrNull(resolved: string): string | null {\n const real = realpathOf(resolved);\n return real.includes(NODE_MODULES_SEGMENT) ? null : real;\n}\n\n/** Node resolution is a function of the importing DIRECTORY, not the file. */\nfunction requireFor(dir: string): ReturnType<typeof createRequire> {\n let req = requireMemo.get(dir);\n if (req === undefined) {\n req = createRequire(path.join(dir, \"__zod_compiler_resolve__.js\"));\n requireMemo.set(dir, req);\n }\n return req;\n}\n\n/**\n * Resolve one specifier from a directory. Returns:\n * - an absolute path (first-party file to record + crawl)\n * - null when the dep is intentionally out of scope (node_modules, builtins)\n * - UNRESOLVED when resolution failed and the graph cannot be trusted\n */\nfunction resolveSpecifier(rawSpec: string, fromDir: string): string | null | typeof UNRESOLVED {\n if (SKIP_SPECIFIER.test(rawSpec)) return null;\n const memoKey = `${fromDir}\\0${rawSpec}`;\n const memoized = resolveMemo.get(memoKey);\n if (memoized !== undefined) return memoized;\n const result = resolveSpecifierUncached(rawSpec, fromDir);\n resolveMemo.set(memoKey, result);\n return result;\n}\n\nfunction resolveSpecifierUncached(\n rawSpec: string,\n fromDir: string,\n): string | null | typeof UNRESOLVED {\n // Vite-style resource queries (./logo.svg?url, ./shader.glsl?raw) resolve\n // to the underlying file.\n const q = rawSpec.indexOf(\"?\");\n const spec = q === -1 ? rawSpec : rawSpec.slice(0, q);\n if (spec === \"\") return null;\n\n if (spec.startsWith(\"./\") || spec.startsWith(\"../\")) {\n const hit = probeFile(path.resolve(fromDir, spec));\n return hit === null ? UNRESOLVED : firstPartyOrNull(hit);\n }\n\n const { candidates, authoritative } = resolveTsconfigPathCandidates(fromDir, spec);\n for (const candidate of candidates) {\n const hit = probeFile(candidate);\n if (hit !== null) {\n return firstPartyOrNull(hit);\n }\n }\n // An authoritative miss (explicit `paths` pattern matched, or the paths\n // config is present but uninterpretable) means the import cannot be\n // trusted. Implicit baseUrl candidates are proposed for EVERY bare\n // specifier (npm packages, `#` imports) and only mean \"try baseDir\n // first\" — a miss falls through to node resolution below.\n if (authoritative) return UNRESOLVED;\n\n // Bare specifier (package) or package.json \"imports\" (#...): node\n // resolution from the importing directory. node_modules results are out of\n // scope (zod's version is part of the cache key); symlinked workspace\n // packages realpath outside node_modules and are crawled as first-party.\n try {\n const resolved = requireFor(fromDir).resolve(spec);\n if (!path.isAbsolute(resolved)) return null; // node builtin\n return firstPartyOrNull(resolved);\n } catch {\n // Unresolvable from Node's algorithm. jiti may still resolve it (e.g.\n // ESM-only packages without CJS entries) — the file itself stays a dep\n // through the entry, but its subtree is unknown for bare packages.\n // Treat unresolvable BARE specifiers as out-of-scope third-party\n // (caught by the zod-version/plugin key when relevant) only when they\n // cannot be project files; '#' subpath imports stay strict.\n return spec.startsWith(\"#\") ? UNRESOLVED : null;\n }\n}\n\n/**\n * Scan + resolve one file into its edge list. Memoized by mtime, so the\n * shared core graph is read and resolved once per process — each entry's\n * closure walk after that is one cheap stat plus Map lookups per file.\n * Returns null for unreadable files.\n */\nfunction fileNode(filePath: string): FileNode | null {\n const stat = tryStat(filePath);\n if (stat === undefined || !stat.isFile()) {\n nodeMemo.set(filePath, null);\n return null;\n }\n const memo = nodeMemo.get(filePath);\n if (memo !== undefined && memo !== null && memo.mtimeMs === stat.mtimeMs) return memo;\n\n let source: string;\n try {\n source = fs.readFileSync(filePath, \"utf8\");\n } catch {\n nodeMemo.set(filePath, null);\n return null;\n }\n // String/comment contents can false-positive both patterns; extra\n // specifiers only add deps (safe), a false `incomplete` only falls back\n // to the superset (safe).\n let incomplete = DYNAMIC_CALL.test(source);\n const edges: string[] = [];\n const seen = new Set<string>();\n const dir = path.dirname(filePath);\n for (const m of source.matchAll(STATIC_SPECIFIER)) {\n const spec = m[1];\n if (!spec) continue;\n const resolved = resolveSpecifier(spec, dir);\n if (resolved === UNRESOLVED) {\n incomplete = true;\n } else if (resolved !== null && !seen.has(resolved)) {\n seen.add(resolved);\n edges.push(resolved);\n }\n }\n const node: FileNode = { mtimeMs: stat.mtimeMs, edges, incomplete };\n nodeMemo.set(filePath, node);\n return node;\n}\n\n/**\n * Compute the static first-party dependency closure of `entryFile`.\n * The entry itself is excluded (its content is part of the cache key).\n */\nexport function collectStaticDeps(entryFile: string): StaticDeps {\n const entry = firstPartyOrNull(path.resolve(entryFile));\n if (entry === null) return INCOMPLETE;\n\n const visited = new Set<string>([entry]);\n const queue: string[] = [entry];\n\n while (queue.length > 0) {\n if (visited.size > MAX_FILES) return INCOMPLETE;\n const file = queue.pop() as string;\n const node = fileNode(file);\n // Any unanalyzable node poisons the whole closure; the caller falls back\n // to the superset, so abort instead of crawling to exhaustion.\n if (node === null || node.incomplete) return INCOMPLETE;\n for (const dep of node.edges) {\n if (!visited.has(dep)) {\n visited.add(dep);\n queue.push(dep);\n }\n }\n }\n\n visited.delete(entry);\n return { deps: [...visited], complete: true };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmDA,MAAM,oBAAoB;CAAC;CAAO;CAAQ;CAAQ;CAAQ;CAAO;CAAQ;CAAQ;AAAM;AACvF,MAAM,uBAAuB,GAAGA,OAAK,IAAI,cAAcA,OAAK;;AAG5D,MAAM,iBAAiB;;AAEvB,MAAM,YAAY;AAElB,MAAM,aAAyB;CAAE,MAAM,CAAC;CAAG,UAAU;AAAM;;;;;;AAO3D,MAAM,aAAa,OAAO,YAAY;;;;;;;;;AAkBtC,MAAM,2BAAW,IAAI,IAA6B;AAClD,MAAM,8BAAc,IAAI,IAA+C;AACvE,MAAM,+BAAe,IAAI,IAAoB;AAC7C,MAAM,8BAAc,IAAI,IAA8C;;AAGtE,SAAgB,oBAA0B;CACxC,SAAS,MAAM;CACf,YAAY,MAAM;CAClB,aAAa,MAAM;CACnB,YAAY,MAAM;AACpB;AAEA,MAAM,mBACJ;AAIF,MAAM,eAAe;;AAGrB,SAAS,QAAQ,GAAiC;CAChD,IAAI;EACF,OAAOC,KAAG,SAAS,GAAG,EAAE,gBAAgB,MAAM,CAAC;CACjD,QAAQ;EAGN;CACF;AACF;AAEA,SAAS,QAAQ,GA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