@whaaaley/crush 0.0.0-stage → 0.2.6

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 (358) hide show
  1. package/LICENSE +32 -0
  2. package/README.md +185 -2
  3. package/SKILL.md +187 -0
  4. package/THIRD_PARTY_NOTICES.md +277 -0
  5. package/dist/capture/capture.operations.d.ts +23 -0
  6. package/dist/capture/capture.operations.js +231 -0
  7. package/dist/capture/capture.schema.d.ts +73 -0
  8. package/dist/capture/capture.schema.js +28 -0
  9. package/dist/collapse/collapse.operations.d.ts +2 -0
  10. package/dist/collapse/collapse.operations.js +82 -0
  11. package/dist/collapse/collapse.schema.d.ts +40 -0
  12. package/dist/collapse/collapse.schema.js +35 -0
  13. package/dist/crush.tables.d.ts +3583 -0
  14. package/dist/crush.tables.js +456 -0
  15. package/dist/crushes/callback.crush.d.ts +2 -0
  16. package/dist/crushes/callback.crush.js +19 -0
  17. package/dist/crushes/crush.d.ts +36 -0
  18. package/dist/crushes/crush.js +12 -0
  19. package/dist/crushes/crush.names.d.ts +1 -0
  20. package/dist/crushes/crush.names.js +2 -0
  21. package/dist/crushes/crushes.d.ts +2 -0
  22. package/dist/crushes/crushes.js +9 -0
  23. package/dist/crushes/default-value.crush.d.ts +2 -0
  24. package/dist/crushes/default-value.crush.js +29 -0
  25. package/dist/crushes/drop-operand.crush.d.ts +2 -0
  26. package/dist/crushes/drop-operand.crush.js +37 -0
  27. package/dist/crushes/fold.d.ts +64 -0
  28. package/dist/crushes/fold.js +366 -0
  29. package/dist/crushes/force-fork.crush.d.ts +2 -0
  30. package/dist/crushes/force-fork.crush.js +79 -0
  31. package/dist/crushes/loop-once.crush.d.ts +2 -0
  32. package/dist/crushes/loop-once.crush.js +71 -0
  33. package/dist/crushes/optional-chain.crush.d.ts +2 -0
  34. package/dist/crushes/optional-chain.crush.js +30 -0
  35. package/dist/crushes/switch-case.crush.d.ts +2 -0
  36. package/dist/crushes/switch-case.crush.js +19 -0
  37. package/dist/decisions/decide.d.ts +61 -0
  38. package/dist/decisions/decide.js +161 -0
  39. package/dist/decisions/decisions.d.ts +24 -0
  40. package/dist/decisions/decisions.js +62 -0
  41. package/dist/decisions/forks.decision.d.ts +4 -0
  42. package/dist/decisions/forks.decision.js +32 -0
  43. package/dist/decisions/kinds.d.ts +101 -0
  44. package/dist/decisions/kinds.js +38 -0
  45. package/dist/decisions/loops.decision.d.ts +4 -0
  46. package/dist/decisions/loops.decision.js +39 -0
  47. package/dist/decisions/shorts.decision.d.ts +3 -0
  48. package/dist/decisions/shorts.decision.js +66 -0
  49. package/dist/decisions/switches.decision.d.ts +3 -0
  50. package/dist/decisions/switches.decision.js +20 -0
  51. package/dist/decisions/throws.decision.d.ts +3 -0
  52. package/dist/decisions/throws.decision.js +35 -0
  53. package/dist/decisions/values.decision.d.ts +3 -0
  54. package/dist/decisions/values.decision.js +67 -0
  55. package/dist/explore/edges/explore.d.ts +60 -0
  56. package/dist/explore/edges/explore.db.d.ts +22 -0
  57. package/dist/explore/edges/explore.db.js +55 -0
  58. package/dist/explore/edges/explore.js +305 -0
  59. package/dist/explore/edges/random.d.ts +2 -0
  60. package/dist/explore/edges/random.js +32 -0
  61. package/dist/explore/explore.operations.d.ts +30 -0
  62. package/dist/explore/explore.operations.js +117 -0
  63. package/dist/explore/limits.operations.d.ts +14 -0
  64. package/dist/explore/limits.operations.js +20 -0
  65. package/dist/explore/targets.operations.d.ts +36 -0
  66. package/dist/explore/targets.operations.js +32 -0
  67. package/dist/explore/utils/draws.d.ts +6 -0
  68. package/dist/explore/utils/draws.js +2 -0
  69. package/dist/explore/utils/edits.d.ts +15 -0
  70. package/dist/explore/utils/edits.js +151 -0
  71. package/dist/explore/utils/guide.d.ts +23 -0
  72. package/dist/explore/utils/guide.js +35 -0
  73. package/dist/explore/utils/keep.d.ts +10 -0
  74. package/dist/explore/utils/keep.js +61 -0
  75. package/dist/explore/utils/pools.d.ts +17 -0
  76. package/dist/explore/utils/pools.js +121 -0
  77. package/dist/explore/utils/reads.d.ts +19 -0
  78. package/dist/explore/utils/reads.js +118 -0
  79. package/dist/explore/utils/twin.d.ts +21 -0
  80. package/dist/explore/utils/twin.js +55 -0
  81. package/dist/forks/forks.operations.d.ts +32 -0
  82. package/dist/forks/forks.operations.js +134 -0
  83. package/dist/forks/forks.schema.d.ts +20 -0
  84. package/dist/forks/forks.schema.js +14 -0
  85. package/dist/graph/cfg/cfg.d.ts +28 -0
  86. package/dist/graph/cfg/cfg.js +31 -0
  87. package/dist/graph/cfg/code-paths/analyzer.d.ts +27 -0
  88. package/dist/graph/cfg/code-paths/analyzer.js +358 -0
  89. package/dist/graph/cfg/code-paths/segments.d.ts +44 -0
  90. package/dist/graph/cfg/code-paths/segments.js +105 -0
  91. package/dist/graph/cfg/code-paths/state.d.ts +121 -0
  92. package/dist/graph/cfg/code-paths/state.js +611 -0
  93. package/dist/graph/cfg/entries.d.ts +13 -0
  94. package/dist/graph/cfg/entries.js +120 -0
  95. package/dist/graph/cfg/functions.d.ts +6 -0
  96. package/dist/graph/cfg/functions.js +47 -0
  97. package/dist/graph/cfg/paths.d.ts +27 -0
  98. package/dist/graph/cfg/paths.js +91 -0
  99. package/dist/graph/cfg/scopes/scopes.d.ts +40 -0
  100. package/dist/graph/cfg/scopes/scopes.js +375 -0
  101. package/dist/graph/symbols/file.d.ts +90 -0
  102. package/dist/graph/symbols/file.js +427 -0
  103. package/dist/graph/symbols/keys.d.ts +13 -0
  104. package/dist/graph/symbols/keys.js +22 -0
  105. package/dist/graph/symbols/resolve.operations.d.ts +4 -0
  106. package/dist/graph/symbols/resolve.operations.js +33 -0
  107. package/dist/graph/symbols/symbols.d.ts +12 -0
  108. package/dist/graph/symbols/symbols.js +155 -0
  109. package/dist/graph/symbols/symbols.schema.d.ts +32 -0
  110. package/dist/graph/symbols/symbols.schema.js +19 -0
  111. package/dist/graph/unused/tests.d.ts +7 -0
  112. package/dist/graph/unused/tests.js +95 -0
  113. package/dist/graph/unused/unused.d.ts +53 -0
  114. package/dist/graph/unused/unused.js +319 -0
  115. package/dist/graph/walk/walk.d.ts +7 -0
  116. package/dist/graph/walk/walk.js +39 -0
  117. package/dist/instrument/instrument.operations.d.ts +72 -0
  118. package/dist/instrument/instrument.operations.js +786 -0
  119. package/dist/instrument/instrument.schema.d.ts +257 -0
  120. package/dist/instrument/instrument.schema.js +100 -0
  121. package/dist/judge/counters.d.ts +86 -0
  122. package/dist/judge/counters.js +402 -0
  123. package/dist/judge/edges/api.d.ts +14 -0
  124. package/dist/judge/edges/api.js +80 -0
  125. package/dist/judge/edges/completion.reporter.d.ts +9 -0
  126. package/dist/judge/edges/completion.reporter.js +51 -0
  127. package/dist/judge/edges/hints.reporter.d.ts +13 -0
  128. package/dist/judge/edges/hints.reporter.js +29 -0
  129. package/dist/judge/edges/judge.edges.d.ts +52 -0
  130. package/dist/judge/edges/judge.edges.js +59 -0
  131. package/dist/judge/edges/judge.fs.d.ts +8 -0
  132. package/dist/judge/edges/judge.fs.js +45 -0
  133. package/dist/judge/edges/merge.d.ts +11 -0
  134. package/dist/judge/edges/merge.js +60 -0
  135. package/dist/judge/edges/plugin.d.ts +132 -0
  136. package/dist/judge/edges/plugin.js +441 -0
  137. package/dist/judge/edges/reach.d.ts +68 -0
  138. package/dist/judge/edges/reach.js +132 -0
  139. package/dist/judge/edges/speed.d.ts +32 -0
  140. package/dist/judge/edges/speed.js +34 -0
  141. package/dist/judge/edges/strays.d.ts +1 -0
  142. package/dist/judge/edges/strays.js +14 -0
  143. package/dist/judge/edges/vitest.d.ts +20 -0
  144. package/dist/judge/edges/vitest.js +36 -0
  145. package/dist/judge/edges/vitest.schema.d.ts +14 -0
  146. package/dist/judge/edges/vitest.schema.js +16 -0
  147. package/dist/judge/explore.test.d.ts +1 -0
  148. package/dist/judge/explore.test.js +101 -0
  149. package/dist/judge/hints.d.ts +11 -0
  150. package/dist/judge/hints.js +44 -0
  151. package/dist/judge/judge.operations.d.ts +218 -0
  152. package/dist/judge/judge.operations.js +464 -0
  153. package/dist/judge/judge.schema.d.ts +135 -0
  154. package/dist/judge/judge.schema.js +129 -0
  155. package/dist/judge/judge.shard-1.test.d.ts +1 -0
  156. package/dist/judge/judge.shard-1.test.js +3 -0
  157. package/dist/judge/judge.shard-2.test.d.ts +1 -0
  158. package/dist/judge/judge.shard-2.test.js +3 -0
  159. package/dist/judge/judge.test.d.ts +1 -0
  160. package/dist/judge/judge.test.js +3 -0
  161. package/dist/judge/refusals.d.ts +14 -0
  162. package/dist/judge/refusals.js +10 -0
  163. package/dist/judge/report.test.d.ts +1 -0
  164. package/dist/judge/report.test.js +432 -0
  165. package/dist/judge/runner.d.ts +3 -0
  166. package/dist/judge/runner.js +1602 -0
  167. package/dist/judge/stresses.test.d.ts +1 -0
  168. package/dist/judge/stresses.test.js +12 -0
  169. package/dist/judge/task-meta.d.ts +51 -0
  170. package/dist/judge/task-meta.js +3 -0
  171. package/dist/justify/edges/load.d.ts +7 -0
  172. package/dist/justify/edges/load.js +40 -0
  173. package/dist/justify/edges/refresh.fs.d.ts +8 -0
  174. package/dist/justify/edges/refresh.fs.js +15 -0
  175. package/dist/justify/justify.operations.d.ts +46 -0
  176. package/dist/justify/justify.operations.js +80 -0
  177. package/dist/justify/justify.schema.d.ts +21 -0
  178. package/dist/justify/justify.schema.js +11 -0
  179. package/dist/mutators/arithmetic-operator.mutator.d.ts +2 -0
  180. package/dist/mutators/arithmetic-operator.mutator.js +22 -0
  181. package/dist/mutators/array-declaration.mutator.d.ts +2 -0
  182. package/dist/mutators/array-declaration.mutator.js +12 -0
  183. package/dist/mutators/arrow-function.mutator.d.ts +2 -0
  184. package/dist/mutators/arrow-function.mutator.js +10 -0
  185. package/dist/mutators/assignment-operator.mutator.d.ts +2 -0
  186. package/dist/mutators/assignment-operator.mutator.js +29 -0
  187. package/dist/mutators/await-expression.mutator.d.ts +2 -0
  188. package/dist/mutators/await-expression.mutator.js +7 -0
  189. package/dist/mutators/bitwise-operator.mutator.d.ts +2 -0
  190. package/dist/mutators/bitwise-operator.mutator.js +19 -0
  191. package/dist/mutators/block-statement.mutator.d.ts +2 -0
  192. package/dist/mutators/block-statement.mutator.js +30 -0
  193. package/dist/mutators/boolean-literal.mutator.d.ts +2 -0
  194. package/dist/mutators/boolean-literal.mutator.js +5 -0
  195. package/dist/mutators/coercion.mutator.d.ts +2 -0
  196. package/dist/mutators/coercion.mutator.js +28 -0
  197. package/dist/mutators/conditional-expression.mutator.d.ts +2 -0
  198. package/dist/mutators/conditional-expression.mutator.js +36 -0
  199. package/dist/mutators/disposal.mutator.d.ts +2 -0
  200. package/dist/mutators/disposal.mutator.js +13 -0
  201. package/dist/mutators/empty-destructuring.mutator.d.ts +2 -0
  202. package/dist/mutators/empty-destructuring.mutator.js +35 -0
  203. package/dist/mutators/empty-return.mutator.d.ts +2 -0
  204. package/dist/mutators/empty-return.mutator.js +35 -0
  205. package/dist/mutators/equality-operator.mutator.d.ts +2 -0
  206. package/dist/mutators/equality-operator.mutator.js +16 -0
  207. package/dist/mutators/loop-exit.mutator.d.ts +2 -0
  208. package/dist/mutators/loop-exit.mutator.js +5 -0
  209. package/dist/mutators/method-expression.mutator.d.ts +2 -0
  210. package/dist/mutators/method-expression.mutator.js +59 -0
  211. package/dist/mutators/missing-lookup.mutator.d.ts +2 -0
  212. package/dist/mutators/missing-lookup.mutator.js +25 -0
  213. package/dist/mutators/mutator.d.ts +40 -0
  214. package/dist/mutators/mutator.js +49 -0
  215. package/dist/mutators/mutator.names.d.ts +3 -0
  216. package/dist/mutators/mutator.names.js +43 -0
  217. package/dist/mutators/mutators.d.ts +8 -0
  218. package/dist/mutators/mutators.js +84 -0
  219. package/dist/mutators/nested-condition.mutator.d.ts +2 -0
  220. package/dist/mutators/nested-condition.mutator.js +16 -0
  221. package/dist/mutators/number-literal.mutator.d.ts +3 -0
  222. package/dist/mutators/number-literal.mutator.js +13 -0
  223. package/dist/mutators/object-literal.mutator.d.ts +2 -0
  224. package/dist/mutators/object-literal.mutator.js +6 -0
  225. package/dist/mutators/odd-number.mutator.d.ts +2 -0
  226. package/dist/mutators/odd-number.mutator.js +15 -0
  227. package/dist/mutators/operand-deletion.mutator.d.ts +2 -0
  228. package/dist/mutators/operand-deletion.mutator.js +9 -0
  229. package/dist/mutators/outcome.mutator.d.ts +3 -0
  230. package/dist/mutators/outcome.mutator.js +45 -0
  231. package/dist/mutators/plain-assignment.mutator.d.ts +2 -0
  232. package/dist/mutators/plain-assignment.mutator.js +7 -0
  233. package/dist/mutators/power-operator.mutator.d.ts +2 -0
  234. package/dist/mutators/power-operator.mutator.js +13 -0
  235. package/dist/mutators/private-brand.mutator.d.ts +2 -0
  236. package/dist/mutators/private-brand.mutator.js +7 -0
  237. package/dist/mutators/regex.mutator.d.ts +2 -0
  238. package/dist/mutators/regex.mutator.js +29 -0
  239. package/dist/mutators/short-iteration.mutator.d.ts +2 -0
  240. package/dist/mutators/short-iteration.mutator.js +8 -0
  241. package/dist/mutators/string-literal.mutator.d.ts +3 -0
  242. package/dist/mutators/string-literal.mutator.js +149 -0
  243. package/dist/mutators/switch-default.mutator.d.ts +2 -0
  244. package/dist/mutators/switch-default.mutator.js +13 -0
  245. package/dist/mutators/sync-iteration.mutator.d.ts +3 -0
  246. package/dist/mutators/sync-iteration.mutator.js +9 -0
  247. package/dist/mutators/thrown-call.mutator.d.ts +2 -0
  248. package/dist/mutators/thrown-call.mutator.js +7 -0
  249. package/dist/mutators/unary-operator.mutator.d.ts +2 -0
  250. package/dist/mutators/unary-operator.mutator.js +18 -0
  251. package/dist/mutators/unbound-call.mutator.d.ts +2 -0
  252. package/dist/mutators/unbound-call.mutator.js +14 -0
  253. package/dist/mutators/update-operator.mutator.d.ts +2 -0
  254. package/dist/mutators/update-operator.mutator.js +15 -0
  255. package/dist/mutators/yield-value.mutator.d.ts +2 -0
  256. package/dist/mutators/yield-value.mutator.js +7 -0
  257. package/dist/parity/compare.d.ts +27 -0
  258. package/dist/parity/compare.js +26 -0
  259. package/dist/parity/corpus.parity.d.ts +1 -0
  260. package/dist/parity/corpus.parity.js +97 -0
  261. package/dist/parity/edges/corpus.fs.d.ts +3 -0
  262. package/dist/parity/edges/corpus.fs.js +30 -0
  263. package/dist/parity/edges/ports.d.ts +2 -0
  264. package/dist/parity/edges/ports.js +21 -0
  265. package/dist/parity/edges/vitest.d.ts +2 -0
  266. package/dist/parity/edges/vitest.js +3 -0
  267. package/dist/parity/parity.operations.d.ts +33 -0
  268. package/dist/parity/parity.operations.js +60 -0
  269. package/dist/parity/parity.schema.d.ts +5 -0
  270. package/dist/parity/parity.schema.js +6 -0
  271. package/dist/parity/stryker/compare.d.ts +14 -0
  272. package/dist/parity/stryker/compare.js +52 -0
  273. package/dist/parity/stryker/edges/ports.d.ts +12 -0
  274. package/dist/parity/stryker/edges/ports.js +28 -0
  275. package/dist/parity/stryker/equivalence.d.ts +1 -0
  276. package/dist/parity/stryker/equivalence.js +42 -0
  277. package/dist/parity/stryker/intended.d.ts +29 -0
  278. package/dist/parity/stryker/intended.js +152 -0
  279. package/dist/parity/stryker/normalize.d.ts +27 -0
  280. package/dist/parity/stryker/normalize.js +181 -0
  281. package/dist/parity/stryker/rules.d.ts +6 -0
  282. package/dist/parity/stryker/rules.js +116 -0
  283. package/dist/parity/stryker/sides.d.ts +46 -0
  284. package/dist/parity/stryker/sides.js +199 -0
  285. package/dist/parity/stryker/stryker.parity.d.ts +1 -0
  286. package/dist/parity/stryker/stryker.parity.js +147 -0
  287. package/dist/parity/stryker/stryker.schema.d.ts +6 -0
  288. package/dist/parity/stryker/stryker.schema.js +7 -0
  289. package/dist/parity/views.d.ts +21 -0
  290. package/dist/parity/views.js +119 -0
  291. package/dist/questions/questions.operations.d.ts +110 -0
  292. package/dist/questions/questions.operations.js +446 -0
  293. package/dist/questions/questions.schema.d.ts +57 -0
  294. package/dist/questions/questions.schema.js +28 -0
  295. package/dist/record/edges/calls.db.d.ts +10 -0
  296. package/dist/record/edges/calls.db.js +91 -0
  297. package/dist/record/edges/hits.db.d.ts +3 -0
  298. package/dist/record/edges/hits.db.js +5 -0
  299. package/dist/record/edges/holds.db.d.ts +4 -0
  300. package/dist/record/edges/holds.db.js +31 -0
  301. package/dist/record/edges/judged-state.db.d.ts +5 -0
  302. package/dist/record/edges/judged-state.db.js +25 -0
  303. package/dist/record/edges/markers.db.d.ts +11 -0
  304. package/dist/record/edges/markers.db.js +55 -0
  305. package/dist/record/edges/merge.db.d.ts +7 -0
  306. package/dist/record/edges/merge.db.js +46 -0
  307. package/dist/record/edges/parts.db.d.ts +42 -0
  308. package/dist/record/edges/parts.db.js +389 -0
  309. package/dist/record/edges/parts.edges.d.ts +2 -0
  310. package/dist/record/edges/parts.edges.js +7 -0
  311. package/dist/record/edges/parts.fs.d.ts +1 -0
  312. package/dist/record/edges/parts.fs.js +11 -0
  313. package/dist/record/edges/parts.writer.d.ts +1 -0
  314. package/dist/record/edges/parts.writer.js +85 -0
  315. package/dist/record/edges/passes.db.d.ts +19 -0
  316. package/dist/record/edges/passes.db.js +31 -0
  317. package/dist/record/edges/plan.db.d.ts +21 -0
  318. package/dist/record/edges/plan.db.js +174 -0
  319. package/dist/record/edges/reach.db.d.ts +6 -0
  320. package/dist/record/edges/reach.db.js +62 -0
  321. package/dist/record/edges/record.db.d.ts +22 -0
  322. package/dist/record/edges/record.db.js +176 -0
  323. package/dist/record/edges/record.fs.d.ts +3 -0
  324. package/dist/record/edges/record.fs.js +7 -0
  325. package/dist/record/edges/site-verdicts.db.d.ts +11 -0
  326. package/dist/record/edges/site-verdicts.db.js +66 -0
  327. package/dist/record/edges/verified.db.d.ts +7 -0
  328. package/dist/record/edges/verified.db.js +71 -0
  329. package/dist/record/parts.operations.d.ts +26 -0
  330. package/dist/record/parts.operations.js +31 -0
  331. package/dist/record/path-checks.operations.d.ts +15 -0
  332. package/dist/record/path-checks.operations.js +84 -0
  333. package/dist/record/record.operations.d.ts +36 -0
  334. package/dist/record/record.operations.js +11 -0
  335. package/dist/stresses/edges/stresses.record.d.ts +4 -0
  336. package/dist/stresses/edges/stresses.record.js +37 -0
  337. package/dist/stresses/stresses.operations.d.ts +28 -0
  338. package/dist/stresses/stresses.operations.js +22 -0
  339. package/dist/utils/ast.d.ts +55 -0
  340. package/dist/utils/ast.js +181 -0
  341. package/dist/utils/errors.d.ts +8 -0
  342. package/dist/utils/errors.js +12 -0
  343. package/dist/utils/faults.d.ts +6 -0
  344. package/dist/utils/faults.js +10 -0
  345. package/dist/utils/lookup.d.ts +4 -0
  346. package/dist/utils/lookup.js +27 -0
  347. package/dist/utils/order.d.ts +2 -0
  348. package/dist/utils/order.js +17 -0
  349. package/dist/utils/retry.d.ts +14 -0
  350. package/dist/utils/retry.js +15 -0
  351. package/dist/utils/safe.d.ts +11 -0
  352. package/dist/utils/safe.js +31 -0
  353. package/migrations/main/20261129123324_initial/migration.sql +418 -0
  354. package/migrations/main/20261129123324_initial/snapshot.json +3641 -0
  355. package/package.json +89 -4
  356. package/references/consumer-setup.md +92 -0
  357. package/src/graph/cfg/code-paths/LICENSE +21 -0
  358. package/src/graph/cfg/scopes/LICENSE +24 -0
@@ -0,0 +1,277 @@
1
+ # Third-party notices
2
+
3
+ crush is MIT licensed, copyright 2026 Dustin Dowell, as `LICENSE` says.
4
+ Parts of crush are translated from the projects below, each under its own license, which this file carries in full.
5
+
6
+ ## ESLint 10.15.0
7
+
8
+ - **License:** MIT.
9
+ - **Copyright:** OpenJS Foundation and other contributors, <www.openjsf.org>.
10
+ - **Taken:** the code-path analysis, ported to TypeScript as plain functions.
11
+ - **Where:** `src/graph/cfg/code-paths/`, with this license beside it.
12
+
13
+ ```text
14
+ Copyright OpenJS Foundation and other contributors, <www.openjsf.org>
15
+
16
+ Permission is hereby granted, free of charge, to any person obtaining a copy
17
+ of this software and associated documentation files (the "Software"), to deal
18
+ in the Software without restriction, including without limitation the rights
19
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
20
+ copies of the Software, and to permit persons to whom the Software is
21
+ furnished to do so, subject to the following conditions:
22
+
23
+ The above copyright notice and this permission notice shall be included in
24
+ all copies or substantial portions of the Software.
25
+
26
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
27
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
28
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
29
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
30
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
31
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
32
+ THE SOFTWARE.
33
+ ```
34
+
35
+ ## eslint-scope 9.1.2
36
+
37
+ - **License:** BSD-2-Clause.
38
+ - **Copyright:** JS Foundation and other contributors, https://js.foundation, and (C) 2012-2013 Yusuke Suzuki and other contributors.
39
+ - **Taken:** the scope referencer, ported to TypeScript.
40
+ - **Where:** `src/graph/cfg/scopes/`, with this license beside it.
41
+
42
+ ```text
43
+ Copyright JS Foundation and other contributors, https://js.foundation
44
+ Copyright (C) 2012-2013 Yusuke Suzuki (twitter: @Constellation) and other contributors.
45
+
46
+ Redistribution and use in source and binary forms, with or without
47
+ modification, are permitted provided that the following conditions are met:
48
+
49
+ * Redistributions of source code must retain the above copyright
50
+ notice, this list of conditions and the following disclaimer.
51
+ * Redistributions in binary form must reproduce the above copyright
52
+ notice, this list of conditions and the following disclaimer in the
53
+ documentation and/or other materials provided with the distribution.
54
+
55
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
56
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
57
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
58
+ ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
59
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
60
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
61
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
62
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
63
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
64
+ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
65
+ ```
66
+
67
+ ## StrykerJS instrumenter 10.1.1
68
+
69
+ - **License:** Apache-2.0.
70
+ - **Copyright:** its `LICENSE` names no holder, leaving the template's placeholder unfilled; its `package.json` names Nico Jansen and Simon de Lang as authors, with the StrykerJS contributors.
71
+ - **Taken:** the mutators marked `source: 'stryker'`, ported to TypeScript, with changes by Dustin Dowell.
72
+ - **Where:** `src/mutators/`.
73
+ - **NOTICE:** the package ships none.
74
+
75
+ ```text
76
+ Apache License
77
+ Version 2.0, January 2004
78
+ http://www.apache.org/licenses/
79
+
80
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
81
+
82
+ 1. Definitions.
83
+
84
+ "License" shall mean the terms and conditions for use, reproduction,
85
+ and distribution as defined by Sections 1 through 9 of this document.
86
+
87
+ "Licensor" shall mean the copyright owner or entity authorized by
88
+ the copyright owner that is granting the License.
89
+
90
+ "Legal Entity" shall mean the union of the acting entity and all
91
+ other entities that control, are controlled by, or are under common
92
+ control with that entity. For the purposes of this definition,
93
+ "control" means (i) the power, direct or indirect, to cause the
94
+ direction or management of such entity, whether by contract or
95
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
96
+ outstanding shares, or (iii) beneficial ownership of such entity.
97
+
98
+ "You" (or "Your") shall mean an individual or Legal Entity
99
+ exercising permissions granted by this License.
100
+
101
+ "Source" form shall mean the preferred form for making modifications,
102
+ including but not limited to software source code, documentation
103
+ source, and configuration files.
104
+
105
+ "Object" form shall mean any form resulting from mechanical
106
+ transformation or translation of a Source form, including but
107
+ not limited to compiled object code, generated documentation,
108
+ and conversions to other media types.
109
+
110
+ "Work" shall mean the work of authorship, whether in Source or
111
+ Object form, made available under the License, as indicated by a
112
+ copyright notice that is included in or attached to the work
113
+ (an example is provided in the Appendix below).
114
+
115
+ "Derivative Works" shall mean any work, whether in Source or Object
116
+ form, that is based on (or derived from) the Work and for which the
117
+ editorial revisions, annotations, elaborations, or other modifications
118
+ represent, as a whole, an original work of authorship. For the purposes
119
+ of this License, Derivative Works shall not include works that remain
120
+ separable from, or merely link (or bind by name) to the interfaces of,
121
+ the Work and Derivative Works thereof.
122
+
123
+ "Contribution" shall mean any work of authorship, including
124
+ the original version of the Work and any modifications or additions
125
+ to that Work or Derivative Works thereof, that is intentionally
126
+ submitted to Licensor for inclusion in the Work by the copyright owner
127
+ or by an individual or Legal Entity authorized to submit on behalf of
128
+ the copyright owner. For the purposes of this definition, "submitted"
129
+ means any form of electronic, verbal, or written communication sent
130
+ to the Licensor or its representatives, including but not limited to
131
+ communication on electronic mailing lists, source code control systems,
132
+ and issue tracking systems that are managed by, or on behalf of, the
133
+ Licensor for the purpose of discussing and improving the Work, but
134
+ excluding communication that is conspicuously marked or otherwise
135
+ designated in writing by the copyright owner as "Not a Contribution."
136
+
137
+ "Contributor" shall mean Licensor and any individual or Legal Entity
138
+ on behalf of whom a Contribution has been received by Licensor and
139
+ subsequently incorporated within the Work.
140
+
141
+ 2. Grant of Copyright License. Subject to the terms and conditions of
142
+ this License, each Contributor hereby grants to You a perpetual,
143
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
144
+ copyright license to reproduce, prepare Derivative Works of,
145
+ publicly display, publicly perform, sublicense, and distribute the
146
+ Work and such Derivative Works in Source or Object form.
147
+
148
+ 3. Grant of Patent License. Subject to the terms and conditions of
149
+ this License, each Contributor hereby grants to You a perpetual,
150
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
151
+ (except as stated in this section) patent license to make, have made,
152
+ use, offer to sell, sell, import, and otherwise transfer the Work,
153
+ where such license applies only to those patent claims licensable
154
+ by such Contributor that are necessarily infringed by their
155
+ Contribution(s) alone or by combination of their Contribution(s)
156
+ with the Work to which such Contribution(s) was submitted. If You
157
+ institute patent litigation against any entity (including a
158
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
159
+ or a Contribution incorporated within the Work constitutes direct
160
+ or contributory patent infringement, then any patent licenses
161
+ granted to You under this License for that Work shall terminate
162
+ as of the date such litigation is filed.
163
+
164
+ 4. Redistribution. You may reproduce and distribute copies of the
165
+ Work or Derivative Works thereof in any medium, with or without
166
+ modifications, and in Source or Object form, provided that You
167
+ meet the following conditions:
168
+
169
+ (a) You must give any other recipients of the Work or
170
+ Derivative Works a copy of this License; and
171
+
172
+ (b) You must cause any modified files to carry prominent notices
173
+ stating that You changed the files; and
174
+
175
+ (c) You must retain, in the Source form of any Derivative Works
176
+ that You distribute, all copyright, patent, trademark, and
177
+ attribution notices from the Source form of the Work,
178
+ excluding those notices that do not pertain to any part of
179
+ the Derivative Works; and
180
+
181
+ (d) If the Work includes a "NOTICE" text file as part of its
182
+ distribution, then any Derivative Works that You distribute must
183
+ include a readable copy of the attribution notices contained
184
+ within such NOTICE file, excluding those notices that do not
185
+ pertain to any part of the Derivative Works, in at least one
186
+ of the following places: within a NOTICE text file distributed
187
+ as part of the Derivative Works; within the Source form or
188
+ documentation, if provided along with the Derivative Works; or,
189
+ within a display generated by the Derivative Works, if and
190
+ wherever such third-party notices normally appear. The contents
191
+ of the NOTICE file are for informational purposes only and
192
+ do not modify the License. You may add Your own attribution
193
+ notices within Derivative Works that You distribute, alongside
194
+ or as an addendum to the NOTICE text from the Work, provided
195
+ that such additional attribution notices cannot be construed
196
+ as modifying the License.
197
+
198
+ You may add Your own copyright statement to Your modifications and
199
+ may provide additional or different license terms and conditions
200
+ for use, reproduction, or distribution of Your modifications, or
201
+ for any such Derivative Works as a whole, provided Your use,
202
+ reproduction, and distribution of the Work otherwise complies with
203
+ the conditions stated in this License.
204
+
205
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
206
+ any Contribution intentionally submitted for inclusion in the Work
207
+ by You to the Licensor shall be under the terms and conditions of
208
+ this License, without any additional terms or conditions.
209
+ Notwithstanding the above, nothing herein shall supersede or modify
210
+ the terms of any separate license agreement you may have executed
211
+ with Licensor regarding such Contributions.
212
+
213
+ 6. Trademarks. This License does not grant permission to use the trade
214
+ names, trademarks, service marks, or product names of the Licensor,
215
+ except as required for reasonable and customary use in describing the
216
+ origin of the Work and reproducing the content of the NOTICE file.
217
+
218
+ 7. Disclaimer of Warranty. Unless required by applicable law or
219
+ agreed to in writing, Licensor provides the Work (and each
220
+ Contributor provides its Contributions) on an "AS IS" BASIS,
221
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
222
+ implied, including, without limitation, any warranties or conditions
223
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
224
+ PARTICULAR PURPOSE. You are solely responsible for determining the
225
+ appropriateness of using or redistributing the Work and assume any
226
+ risks associated with Your exercise of permissions under this License.
227
+
228
+ 8. Limitation of Liability. In no event and under no legal theory,
229
+ whether in tort (including negligence), contract, or otherwise,
230
+ unless required by applicable law (such as deliberate and grossly
231
+ negligent acts) or agreed to in writing, shall any Contributor be
232
+ liable to You for damages, including any direct, indirect, special,
233
+ incidental, or consequential damages of any character arising as a
234
+ result of this License or out of the use or inability to use the
235
+ Work (including but not limited to damages for loss of goodwill,
236
+ work stoppage, computer failure or malfunction, or any and all
237
+ other commercial damages or losses), even if such Contributor
238
+ has been advised of the possibility of such damages.
239
+
240
+ 9. Accepting Warranty or Additional Liability. While redistributing
241
+ the Work or Derivative Works thereof, You may choose to offer,
242
+ and charge a fee for, acceptance of support, warranty, indemnity,
243
+ or other liability obligations and/or rights consistent with this
244
+ License. However, in accepting such obligations, You may act only
245
+ on Your own behalf and on Your sole responsibility, not on behalf
246
+ of any other Contributor, and only if You agree to indemnify,
247
+ defend, and hold each Contributor harmless for any liability
248
+ incurred by, or claims asserted against, such Contributor by reason
249
+ of your accepting any such warranty or additional liability.
250
+
251
+ END OF TERMS AND CONDITIONS
252
+
253
+ APPENDIX: How to apply the Apache License to your work.
254
+
255
+ To apply the Apache License to your work, attach the following
256
+ boilerplate notice, with the fields enclosed by brackets "{}"
257
+ replaced with your own identifying information. (Don't include
258
+ the brackets!) The text should be enclosed in the appropriate
259
+ comment syntax for the file format. We also recommend that a
260
+ file or class name and description of purpose be included on the
261
+ same "printed page" as the copyright notice for easier
262
+ identification within third-party archives.
263
+
264
+ Copyright {yyyy} {name of copyright owner}
265
+
266
+ Licensed under the Apache License, Version 2.0 (the "License");
267
+ you may not use this file except in compliance with the License.
268
+ You may obtain a copy of the License at
269
+
270
+ http://www.apache.org/licenses/LICENSE-2.0
271
+
272
+ Unless required by applicable law or agreed to in writing, software
273
+ distributed under the License is distributed on an "AS IS" BASIS,
274
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
275
+ See the License for the specific language governing permissions and
276
+ limitations under the License.
277
+ ```
@@ -0,0 +1,23 @@
1
+ export declare const uncloned: unique symbol;
2
+ export declare const snapshotLimit = 4096;
3
+ export declare const snapshotOf: (value: unknown) => unknown;
4
+ export declare const snapshotsOf: (args: ArrayLike<unknown>) => unknown[];
5
+ type Snapshotter = {
6
+ snapshotOf: typeof snapshotOf;
7
+ snapshotsOf: typeof snapshotsOf;
8
+ };
9
+ export declare const snapshotterOf: (plainCrypto: WeakSet<object>) => Snapshotter;
10
+ export declare const encodedOf: (data: unknown) => string;
11
+ export declare const decodedOf: (json: string) => unknown;
12
+ export declare const framePattern: RegExp;
13
+ export declare const fileUrlPattern: RegExp;
14
+ type ThrowSiteInput = {
15
+ stack: string;
16
+ root: string;
17
+ };
18
+ export declare const throwLocationOf: ({ stack, root }: ThrowSiteInput) => {
19
+ file: string;
20
+ line: number;
21
+ } | null;
22
+ export declare const throwSiteOf: (input: ThrowSiteInput) => string | null;
23
+ export {};
@@ -0,0 +1,231 @@
1
+ // oxlint-disable typescript/no-unsafe-assignment, typescript/no-unsafe-return -- this file handles values the code under test makes, passes or throws, which no static type names
2
+ import { relative } from 'node:path';
3
+ import { types } from 'node:util';
4
+ import { z } from 'zod';
5
+ import { safe } from '../utils/safe.js';
6
+ // What stands in for a value the record cannot hold as it was, as a callback, a class instance or a cycle.
7
+ export const uncloned = Symbol.for('crush:uncloned');
8
+ // A value plain JSON cannot hold, written with a reserved `$crush` tag.
9
+ const taggedInput = z.discriminatedUnion('$crush', [
10
+ z.object({ $crush: z.literal('undefined') }),
11
+ z.object({ $crush: z.literal('uncloned') }),
12
+ z.object({ $crush: z.literal('bigint'), value: z.string() }),
13
+ z.object({ $crush: z.literal('number'), value: z.enum(['NaN', 'Infinity', '-Infinity', '-0']) }),
14
+ z.object({ $crush: z.literal('date'), value: z.number() }),
15
+ z.object({ $crush: z.literal('map'), entries: z.array(z.tuple([z.unknown(), z.unknown()])) }),
16
+ z.object({ $crush: z.literal('set'), values: z.array(z.unknown()) }),
17
+ ]);
18
+ const { isKeyObject, isCryptoKey } = types;
19
+ const brandChecks = Object.values(types).filter((check) => check !== isKeyObject && check !== isCryptoKey);
20
+ const numberOf = (value) => {
21
+ if (Object.is(value, -0))
22
+ return { $crush: 'number', value: '-0' };
23
+ return Number.isFinite(value) ? value : { $crush: 'number', value: String(value) };
24
+ };
25
+ // Each item as data, or `uncloned` when any one cannot be.
26
+ const itemsOf = (items, walk) => {
27
+ const data = [];
28
+ for (const item of items) {
29
+ const each = dataOf(item, walk);
30
+ if (each === uncloned)
31
+ return uncloned;
32
+ data.push(each);
33
+ }
34
+ return data;
35
+ };
36
+ const isReplayableField = (descriptor) => {
37
+ return descriptor !== undefined && 'value' in descriptor && descriptor.enumerable === true && descriptor.writable === true && descriptor.configurable === true;
38
+ };
39
+ // A snapshot walks many small objects, so each key's descriptor is read alone in one pass rather than built with every other at once.
40
+ const ownFieldsOf = (value) => {
41
+ const fields = [];
42
+ for (const key of Reflect.ownKeys(value)) {
43
+ if (typeof key === 'symbol' || key === '$crush')
44
+ return null;
45
+ fields.push([key, Object.getOwnPropertyDescriptor(value, key)]);
46
+ }
47
+ return fields;
48
+ };
49
+ // Plain fields must decode with the same key and default descriptor.
50
+ const fieldsOf = (value, walk) => {
51
+ const fields = ownFieldsOf(value);
52
+ if (!fields)
53
+ return uncloned;
54
+ for (const field of fields) {
55
+ const descriptor = field[1];
56
+ if (!isReplayableField(descriptor))
57
+ return uncloned;
58
+ const each = dataOf(descriptor.value, walk);
59
+ if (each === uncloned)
60
+ return uncloned;
61
+ const snapshotField = field;
62
+ snapshotField[1] = each;
63
+ }
64
+ return Object.fromEntries(fields);
65
+ };
66
+ const arrayDataOf = (value, walk) => {
67
+ const length = Object.getOwnPropertyDescriptor(value, 'length');
68
+ if (!length?.writable || Reflect.ownKeys(value).length !== value.length + 1)
69
+ return uncloned;
70
+ const data = [];
71
+ for (let index = 0; index < value.length; index++) {
72
+ const field = Object.getOwnPropertyDescriptor(value, index);
73
+ if (!isReplayableField(field))
74
+ return uncloned;
75
+ const item = dataOf(field.value, walk);
76
+ if (item === uncloned)
77
+ return uncloned;
78
+ data.push(item);
79
+ }
80
+ return data;
81
+ };
82
+ const objectDataOf = (value, walk) => {
83
+ const prototype = Object.getPrototypeOf(value);
84
+ if (Array.isArray(value))
85
+ return prototype === Array.prototype ? arrayDataOf(value, walk) : uncloned;
86
+ if (prototype === Object.prototype) {
87
+ // An ordinary prototype can conceal a built-in's internal data.
88
+ if (isBranded(value, walk.plainCrypto))
89
+ return uncloned;
90
+ return fieldsOf(value, walk);
91
+ }
92
+ if (Reflect.ownKeys(value).length)
93
+ return uncloned;
94
+ // A built-in's own prototype refuses a subclass a replay would lose, and its brand check refuses an object that only borrows that prototype.
95
+ if (prototype === Date.prototype && types.isDate(value)) {
96
+ const time = value.getTime();
97
+ return Number.isFinite(time) ? { $crush: 'date', value: time } : uncloned;
98
+ }
99
+ if (prototype === Map.prototype && types.isMap(value)) {
100
+ // Finish copying the iteration before inspecting any key or value.
101
+ const pairs = [...value];
102
+ const entries = [];
103
+ for (const [key, item] of pairs) {
104
+ const savedKey = dataOf(key, walk);
105
+ if (savedKey === uncloned)
106
+ return uncloned;
107
+ const savedItem = dataOf(item, walk);
108
+ if (savedItem === uncloned)
109
+ return uncloned;
110
+ entries.push([savedKey, savedItem]);
111
+ }
112
+ return { $crush: 'map', entries };
113
+ }
114
+ if (prototype === Set.prototype && types.isSet(value)) {
115
+ const values = itemsOf([...value], walk);
116
+ return values === uncloned ? uncloned : { $crush: 'set', values };
117
+ }
118
+ return uncloned;
119
+ };
120
+ const dataOf = (value, walk) => {
121
+ if (value === undefined)
122
+ return { $crush: 'undefined' };
123
+ if (typeof value === 'bigint')
124
+ return { $crush: 'bigint', value: String(value) };
125
+ if (typeof value === 'number')
126
+ return numberOf(value);
127
+ if (typeof value === 'function' || typeof value === 'symbol')
128
+ return uncloned;
129
+ if (typeof value !== 'object' || value === null)
130
+ return value;
131
+ // Reading a proxy runs its traps, which can see the read, as a test watching which fields its code reads does, so a proxy is never read.
132
+ // See "Capture refuses values a replay would change" in the decision log.
133
+ // Decoding would lose non-extensibility or shared identity, so these values cannot round-trip.
134
+ if (types.isProxy(value) || !Object.isExtensible(value))
135
+ return uncloned;
136
+ if (walk.seen.has(value) || walk.left === 0)
137
+ return uncloned;
138
+ walk.left -= 1;
139
+ walk.seen.add(value);
140
+ return objectDataOf(value, walk);
141
+ };
142
+ // The most objects one snapshot walks, so a call passed a large structure costs a bounded walk and keeps none of it.
143
+ export const snapshotLimit = 4096;
144
+ const isBranded = (value, plainCrypto) => {
145
+ if (brandChecks.some((check) => check(value)))
146
+ return true;
147
+ if (plainCrypto?.has(value))
148
+ return false;
149
+ if (isKeyObject(value) || isCryptoKey(value))
150
+ return true;
151
+ plainCrypto?.add(value);
152
+ return false;
153
+ };
154
+ const snapshotWith = (value, plainCrypto) => {
155
+ const { data, error } = safe(() => dataOf(value, { seen: new Set(), left: snapshotLimit, plainCrypto }));
156
+ return error ? uncloned : data;
157
+ };
158
+ const snapshotsWith = (args, plainCrypto) => {
159
+ const walk = { seen: new Set(), left: snapshotLimit, plainCrypto };
160
+ return Array.from(args, (arg) => {
161
+ const { data, error } = safe(() => dataOf(arg, walk));
162
+ return error ? uncloned : data;
163
+ });
164
+ };
165
+ // A value as the JSON data the record keeps, taken as it is now so a later change to it cannot reach the record, or `uncloned` where JSON cannot hold it as it was.
166
+ // A proxy's trap may throw while it is read, which leaves the value uncloned rather than failing the call it was passed to.
167
+ export const snapshotOf = (value) => snapshotWith(value);
168
+ // Arguments can share references with each other, so snapshot them with the same walk.
169
+ export const snapshotsOf = (args) => snapshotsWith(args);
170
+ // Node's crypto brands come from internal slots. Reuse only negative checks and always read the value's fields and prototype afresh.
171
+ export const snapshotterOf = (plainCrypto) => ({
172
+ snapshotOf: (value) => snapshotWith(value, plainCrypto),
173
+ snapshotsOf: (args) => snapshotsWith(args, plainCrypto),
174
+ });
175
+ const unclonedTag = { $crush: 'uncloned' };
176
+ // A snapshot, or an argument list of snapshots, as the JSON the record stores, each uncloned one tagged as such.
177
+ export const encodedOf = (data) => {
178
+ if (data === uncloned)
179
+ return JSON.stringify(unclonedTag);
180
+ return JSON.stringify(Array.isArray(data) ? data.map((item) => (item === uncloned ? unclonedTag : item)) : data);
181
+ };
182
+ const valueOf = (data) => {
183
+ if (Array.isArray(data))
184
+ return data.map(valueOf);
185
+ if (typeof data !== 'object' || data === null)
186
+ return data;
187
+ const { data: tagged, error } = taggedInput.safeParse(data);
188
+ if (error)
189
+ return Object.fromEntries(Object.entries(data).map(([key, item]) => [key, valueOf(item)]));
190
+ switch (tagged.$crush) {
191
+ case 'undefined':
192
+ return undefined;
193
+ case 'uncloned':
194
+ return uncloned;
195
+ case 'bigint':
196
+ return BigInt(tagged.value);
197
+ case 'number':
198
+ return Number(tagged.value);
199
+ case 'date':
200
+ return new Date(tagged.value);
201
+ case 'map':
202
+ return new Map(tagged.entries.map(([key, item]) => [valueOf(key), valueOf(item)]));
203
+ case 'set':
204
+ return new Set(tagged.values.map(valueOf));
205
+ }
206
+ };
207
+ // A stored snapshot back as the value it was taken from, with `uncloned` where none was kept.
208
+ export const decodedOf = (json) => valueOf(JSON.parse(json));
209
+ // Matches one stack frame's location, as `at name (/path/file.ts:4:11)` or `at /path/file.ts:4:11`, capturing the path and line.
210
+ export const framePattern = /^\s*at (?:.*\()?(.+?):(\d+):\d+\)?$/;
211
+ // Matches the `file://` scheme a module frame's path starts with, which a path from the root leaves off.
212
+ export const fileUrlPattern = /^file:\/\//;
213
+ // Where a throw came from in the project, as `path:line` from the root, its first stack frame under the root and outside its dependencies, or null for one with none.
214
+ // Instrumenting moves columns and keeps lines, so the column is dropped.
215
+ export const throwLocationOf = ({ stack, root }) => {
216
+ for (const line of stack.split('\n')) {
217
+ const matched = framePattern.exec(line);
218
+ if (!matched)
219
+ continue;
220
+ const [, path = '', at = ''] = matched;
221
+ const from = relative(root, path.replace(fileUrlPattern, ''));
222
+ if (from.startsWith('..') || from === path || from.split('/').includes('node_modules'))
223
+ continue;
224
+ return { file: from, line: Number(at) };
225
+ }
226
+ return null;
227
+ };
228
+ export const throwSiteOf = (input) => {
229
+ const location = throwLocationOf(input);
230
+ return location && `${location.file}:${location.line}`;
231
+ };
@@ -0,0 +1,73 @@
1
+ import { z } from 'zod';
2
+ export declare const callStepInput: z.ZodObject<{
3
+ step: z.ZodNumber;
4
+ siteKey: z.ZodString;
5
+ side: z.ZodEnum<{
6
+ false: "false";
7
+ true: "true";
8
+ }>;
9
+ passes: z.ZodNumber;
10
+ }, z.core.$strip>;
11
+ export type CallStep = z.infer<typeof callStepInput>;
12
+ declare const exportCallInput: z.ZodObject<{
13
+ exportKey: z.ZodString;
14
+ testKey: z.ZodString;
15
+ parent: z.ZodNullable<z.ZodNumber>;
16
+ depth: z.ZodNumber;
17
+ args: z.ZodArray<z.ZodUnknown>;
18
+ outcome: z.ZodEnum<{
19
+ promised: "promised";
20
+ returned: "returned";
21
+ threw: "threw";
22
+ }>;
23
+ result: z.ZodUnknown;
24
+ thrownAt: z.ZodNullable<z.ZodString>;
25
+ steps: z.ZodArray<z.ZodObject<{
26
+ step: z.ZodNumber;
27
+ siteKey: z.ZodString;
28
+ side: z.ZodEnum<{
29
+ false: "false";
30
+ true: "true";
31
+ }>;
32
+ passes: z.ZodNumber;
33
+ }, z.core.$strip>>;
34
+ isPathCut: z.ZodBoolean;
35
+ }, z.core.$strip>;
36
+ export type ExportCallInput = z.infer<typeof exportCallInput>;
37
+ export declare const exportCallOutput: z.ZodObject<{
38
+ exportKey: z.ZodString;
39
+ testKey: z.ZodString;
40
+ parent: z.ZodNullable<z.ZodNumber>;
41
+ depth: z.ZodNumber;
42
+ args: z.ZodArray<z.ZodUnknown>;
43
+ outcome: z.ZodEnum<{
44
+ promised: "promised";
45
+ returned: "returned";
46
+ threw: "threw";
47
+ }>;
48
+ result: z.ZodUnknown;
49
+ thrownAt: z.ZodNullable<z.ZodString>;
50
+ steps: z.ZodArray<z.ZodObject<{
51
+ step: z.ZodNumber;
52
+ siteKey: z.ZodString;
53
+ side: z.ZodEnum<{
54
+ false: "false";
55
+ true: "true";
56
+ }>;
57
+ passes: z.ZodNumber;
58
+ }, z.core.$strip>>;
59
+ isPathCut: z.ZodBoolean;
60
+ file: z.ZodString;
61
+ position: z.ZodNumber;
62
+ path: z.ZodArray<z.ZodObject<{
63
+ step: z.ZodNumber;
64
+ siteKey: z.ZodString;
65
+ side: z.ZodEnum<{
66
+ false: "false";
67
+ true: "true";
68
+ }>;
69
+ passes: z.ZodNumber;
70
+ }, z.core.$strip>>;
71
+ }, z.core.$strip>;
72
+ export type ExportCallOutput = z.infer<typeof exportCallOutput>;
73
+ export {};
@@ -0,0 +1,28 @@
1
+ import { z } from 'zod';
2
+ import { callOutcomes, forkSides } from '../crush.tables.js';
3
+ // One step a captured call took: its number in its file's one sequence of steps, a fork side by its site's key, and how many times running the call took it there.
4
+ export const callStepInput = z.object({
5
+ step: z.number().int().positive(),
6
+ siteKey: z.string().min(1).max(1_048_576),
7
+ side: z.enum(forkSides),
8
+ passes: z.number().int().positive(),
9
+ });
10
+ // One call a baseline kept of an export, in the order the file's calls began: the place of the kept call it ran inside, null for one straight from the test, each argument and the result as snapshots, `uncloned` where none was kept, and the steps it took itself.
11
+ const exportCallInput = z.object({
12
+ exportKey: z.string().min(1).max(4096),
13
+ testKey: z.string().min(1).max(4096),
14
+ parent: z.number().int().nonnegative().nullable(),
15
+ depth: z.number().int().nonnegative(),
16
+ args: z.array(z.unknown()),
17
+ outcome: z.enum(callOutcomes),
18
+ result: z.unknown(),
19
+ thrownAt: z.string().min(1).max(4096).nullable(),
20
+ steps: z.array(callStepInput),
21
+ isPathCut: z.boolean(),
22
+ });
23
+ // One stored call as the record hands it back, under the test file whose baseline made it, at its place in that file's calls, with its whole path: its own steps and those of every call it made, in step order, cut when any of those calls was cut.
24
+ export const exportCallOutput = exportCallInput.extend({
25
+ file: z.string().min(1).max(4096),
26
+ position: z.number().int().nonnegative(),
27
+ path: z.array(callStepInput),
28
+ });
@@ -0,0 +1,2 @@
1
+ import type { CollapseInput, CollapseOutput } from './collapse.schema.ts';
2
+ export declare const collapsedOf: ({ path, source, fallen }: CollapseInput) => CollapseOutput;