@elaraai/east 0.0.1-beta.9 → 1.0.0

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 (410) hide show
  1. package/LICENSE.md +15 -666
  2. package/README.md +113 -88
  3. package/dist/src/analyze.d.ts +3 -0
  4. package/dist/src/analyze.d.ts.map +1 -1
  5. package/dist/src/analyze.js +223 -111
  6. package/dist/src/analyze.js.map +1 -1
  7. package/dist/src/analyze.spec.d.ts +2 -0
  8. package/dist/src/analyze.spec.d.ts.map +1 -0
  9. package/dist/src/analyze.spec.js +445 -0
  10. package/dist/src/analyze.spec.js.map +1 -0
  11. package/dist/src/ast.d.ts +54 -35
  12. package/dist/src/ast.d.ts.map +1 -1
  13. package/dist/src/ast_to_ir.coerce_to.spec.d.ts +15 -0
  14. package/dist/src/ast_to_ir.coerce_to.spec.d.ts.map +1 -0
  15. package/dist/src/ast_to_ir.coerce_to.spec.js +420 -0
  16. package/dist/src/ast_to_ir.coerce_to.spec.js.map +1 -0
  17. package/dist/src/ast_to_ir.d.ts +18 -4
  18. package/dist/src/ast_to_ir.d.ts.map +1 -1
  19. package/dist/src/ast_to_ir.js +233 -178
  20. package/dist/src/ast_to_ir.js.map +1 -1
  21. package/dist/src/builtins.d.ts +1 -1
  22. package/dist/src/builtins.d.ts.map +1 -1
  23. package/dist/src/builtins.js +194 -2
  24. package/dist/src/builtins.js.map +1 -1
  25. package/dist/src/comparison.d.ts +2 -2
  26. package/dist/src/comparison.d.ts.map +1 -1
  27. package/dist/src/comparison.js +115 -40
  28. package/dist/src/comparison.js.map +1 -1
  29. package/dist/src/comparison.spec.d.ts +2 -0
  30. package/dist/src/comparison.spec.d.ts.map +1 -0
  31. package/dist/src/comparison.spec.js +1200 -0
  32. package/dist/src/comparison.spec.js.map +1 -0
  33. package/dist/src/compile.d.ts +31 -9
  34. package/dist/src/compile.d.ts.map +1 -1
  35. package/dist/src/compile.js +1048 -548
  36. package/dist/src/compile.js.map +1 -1
  37. package/dist/src/containers/matrix.d.ts +15 -0
  38. package/dist/src/containers/matrix.d.ts.map +1 -0
  39. package/dist/src/containers/matrix.js +15 -0
  40. package/dist/src/containers/matrix.js.map +1 -0
  41. package/dist/src/containers/ref.d.ts.map +1 -1
  42. package/dist/src/containers/ref.js +1 -1
  43. package/dist/src/containers/ref.js.map +1 -1
  44. package/dist/src/containers/sortedmap.spec.d.ts +2 -0
  45. package/dist/src/containers/sortedmap.spec.d.ts.map +1 -0
  46. package/dist/src/containers/sortedmap.spec.js +180 -0
  47. package/dist/src/containers/sortedmap.spec.js.map +1 -0
  48. package/dist/src/containers/sortedset.spec.d.ts +2 -0
  49. package/dist/src/containers/sortedset.spec.d.ts.map +1 -0
  50. package/dist/src/containers/sortedset.spec.js +228 -0
  51. package/dist/src/containers/sortedset.spec.js.map +1 -0
  52. package/dist/src/containers/variant.d.ts.map +1 -1
  53. package/dist/src/containers/variant.js +1 -1
  54. package/dist/src/containers/variant.js.map +1 -1
  55. package/dist/src/containers/variant.spec.d.ts +2 -0
  56. package/dist/src/containers/variant.spec.d.ts.map +1 -0
  57. package/dist/src/containers/variant.spec.js +217 -0
  58. package/dist/src/containers/variant.spec.js.map +1 -0
  59. package/dist/src/datetime_format/parse.spec.d.ts +6 -0
  60. package/dist/src/datetime_format/parse.spec.d.ts.map +1 -0
  61. package/dist/src/datetime_format/parse.spec.js +379 -0
  62. package/dist/src/datetime_format/parse.spec.js.map +1 -0
  63. package/dist/src/datetime_format/print.spec.d.ts +6 -0
  64. package/dist/src/datetime_format/print.spec.d.ts.map +1 -0
  65. package/dist/src/datetime_format/print.spec.js +257 -0
  66. package/dist/src/datetime_format/print.spec.js.map +1 -0
  67. package/dist/src/datetime_format/tokenize.spec.d.ts +2 -0
  68. package/dist/src/datetime_format/tokenize.spec.d.ts.map +1 -0
  69. package/dist/src/datetime_format/tokenize.spec.js +508 -0
  70. package/dist/src/datetime_format/tokenize.spec.js.map +1 -0
  71. package/dist/src/datetime_format/types.d.ts +23 -23
  72. package/dist/src/default.d.ts.map +1 -1
  73. package/dist/src/default.js +33 -0
  74. package/dist/src/default.js.map +1 -1
  75. package/dist/src/default.spec.d.ts +2 -0
  76. package/dist/src/default.spec.d.ts.map +1 -0
  77. package/dist/src/default.spec.js +178 -0
  78. package/dist/src/default.spec.js.map +1 -0
  79. package/dist/src/eastir.d.ts +7 -0
  80. package/dist/src/eastir.d.ts.map +1 -1
  81. package/dist/src/eastir.js +55 -7
  82. package/dist/src/eastir.js.map +1 -1
  83. package/dist/src/error.d.ts +14 -4
  84. package/dist/src/error.d.ts.map +1 -1
  85. package/dist/src/error.js +28 -3
  86. package/dist/src/error.js.map +1 -1
  87. package/dist/src/example.d.ts +87 -0
  88. package/dist/src/example.d.ts.map +1 -0
  89. package/dist/src/example.js +18 -0
  90. package/dist/src/example.js.map +1 -0
  91. package/dist/src/expr/array.d.ts +43 -1
  92. package/dist/src/expr/array.d.ts.map +1 -1
  93. package/dist/src/expr/array.js +103 -53
  94. package/dist/src/expr/array.js.map +1 -1
  95. package/dist/src/expr/ast.d.ts +1 -1
  96. package/dist/src/expr/ast.d.ts.map +1 -1
  97. package/dist/src/expr/ast.js +112 -54
  98. package/dist/src/expr/ast.js.map +1 -1
  99. package/dist/src/expr/asyncfunction.d.ts.map +1 -1
  100. package/dist/src/expr/asyncfunction.js +6 -4
  101. package/dist/src/expr/asyncfunction.js.map +1 -1
  102. package/dist/src/expr/blob.d.ts +48 -0
  103. package/dist/src/expr/blob.d.ts.map +1 -1
  104. package/dist/src/expr/blob.js +63 -8
  105. package/dist/src/expr/blob.js.map +1 -1
  106. package/dist/src/expr/block.d.ts +213 -12
  107. package/dist/src/expr/block.d.ts.map +1 -1
  108. package/dist/src/expr/block.js +796 -293
  109. package/dist/src/expr/block.js.map +1 -1
  110. package/dist/src/expr/boolean.d.ts +44 -0
  111. package/dist/src/expr/boolean.d.ts.map +1 -1
  112. package/dist/src/expr/boolean.js +58 -6
  113. package/dist/src/expr/boolean.js.map +1 -1
  114. package/dist/src/expr/datetime.d.ts +135 -0
  115. package/dist/src/expr/datetime.d.ts.map +1 -1
  116. package/dist/src/expr/datetime.js +184 -34
  117. package/dist/src/expr/datetime.js.map +1 -1
  118. package/dist/src/expr/dict.d.ts +47 -2
  119. package/dist/src/expr/dict.d.ts.map +1 -1
  120. package/dist/src/expr/dict.js +122 -61
  121. package/dist/src/expr/dict.js.map +1 -1
  122. package/dist/src/expr/expr.d.ts +3 -1
  123. package/dist/src/expr/expr.d.ts.map +1 -1
  124. package/dist/src/expr/expr.js +4 -3
  125. package/dist/src/expr/expr.js.map +1 -1
  126. package/dist/src/expr/float.d.ts +153 -0
  127. package/dist/src/expr/float.d.ts.map +1 -1
  128. package/dist/src/expr/float.js +191 -17
  129. package/dist/src/expr/float.js.map +1 -1
  130. package/dist/src/expr/function.d.ts +7 -2
  131. package/dist/src/expr/function.d.ts.map +1 -1
  132. package/dist/src/expr/function.js +6 -4
  133. package/dist/src/expr/function.js.map +1 -1
  134. package/dist/src/expr/index.d.ts +186 -2
  135. package/dist/src/expr/index.d.ts.map +1 -1
  136. package/dist/src/expr/index.js +183 -2
  137. package/dist/src/expr/index.js.map +1 -1
  138. package/dist/src/expr/integer.d.ts +180 -0
  139. package/dist/src/expr/integer.d.ts.map +1 -1
  140. package/dist/src/expr/integer.js +189 -18
  141. package/dist/src/expr/integer.js.map +1 -1
  142. package/dist/src/expr/libs/array.js +3 -3
  143. package/dist/src/expr/libs/array.js.map +1 -1
  144. package/dist/src/expr/libs/blob.js +3 -3
  145. package/dist/src/expr/libs/blob.js.map +1 -1
  146. package/dist/src/expr/libs/dict.js +1 -1
  147. package/dist/src/expr/libs/dict.js.map +1 -1
  148. package/dist/src/expr/libs/matrix.d.ts +17 -0
  149. package/dist/src/expr/libs/matrix.d.ts.map +1 -0
  150. package/dist/src/expr/libs/matrix.js +60 -0
  151. package/dist/src/expr/libs/matrix.js.map +1 -0
  152. package/dist/src/expr/libs/set.js +1 -1
  153. package/dist/src/expr/libs/set.js.map +1 -1
  154. package/dist/src/expr/libs/string.d.ts.map +1 -1
  155. package/dist/src/expr/libs/string.js +2 -1
  156. package/dist/src/expr/libs/string.js.map +1 -1
  157. package/dist/src/expr/libs/vector.d.ts +16 -0
  158. package/dist/src/expr/libs/vector.d.ts.map +1 -0
  159. package/dist/src/expr/libs/vector.js +44 -0
  160. package/dist/src/expr/libs/vector.js.map +1 -0
  161. package/dist/src/expr/matrix.d.ts +109 -0
  162. package/dist/src/expr/matrix.d.ts.map +1 -0
  163. package/dist/src/expr/matrix.js +224 -0
  164. package/dist/src/expr/matrix.js.map +1 -0
  165. package/dist/src/expr/recursive.d.ts +83 -0
  166. package/dist/src/expr/recursive.d.ts.map +1 -0
  167. package/dist/src/expr/recursive.js +99 -0
  168. package/dist/src/expr/recursive.js.map +1 -0
  169. package/dist/src/expr/ref.js +5 -5
  170. package/dist/src/expr/ref.js.map +1 -1
  171. package/dist/src/expr/set.d.ts +44 -2
  172. package/dist/src/expr/set.d.ts.map +1 -1
  173. package/dist/src/expr/set.js +102 -52
  174. package/dist/src/expr/set.js.map +1 -1
  175. package/dist/src/expr/string.d.ts +134 -0
  176. package/dist/src/expr/string.d.ts.map +1 -1
  177. package/dist/src/expr/string.js +173 -23
  178. package/dist/src/expr/string.js.map +1 -1
  179. package/dist/src/expr/struct.d.ts +1 -1
  180. package/dist/src/expr/struct.d.ts.map +1 -1
  181. package/dist/src/expr/struct.js +2 -2
  182. package/dist/src/expr/struct.js.map +1 -1
  183. package/dist/src/expr/types.d.ts +12 -9
  184. package/dist/src/expr/types.d.ts.map +1 -1
  185. package/dist/src/expr/variant.d.ts +108 -11
  186. package/dist/src/expr/variant.d.ts.map +1 -1
  187. package/dist/src/expr/variant.js +76 -38
  188. package/dist/src/expr/variant.js.map +1 -1
  189. package/dist/src/expr/vector.d.ts +102 -0
  190. package/dist/src/expr/vector.d.ts.map +1 -0
  191. package/dist/src/expr/vector.js +202 -0
  192. package/dist/src/expr/vector.js.map +1 -0
  193. package/dist/src/fuzz.d.ts +36 -2
  194. package/dist/src/fuzz.d.ts.map +1 -1
  195. package/dist/src/fuzz.js +409 -77
  196. package/dist/src/fuzz.js.map +1 -1
  197. package/dist/src/index.d.ts +4 -0
  198. package/dist/src/index.d.ts.map +1 -1
  199. package/dist/src/index.js +4 -0
  200. package/dist/src/index.js.map +1 -1
  201. package/dist/src/internal.d.ts +12 -2
  202. package/dist/src/internal.d.ts.map +1 -1
  203. package/dist/src/internal.js +13 -2
  204. package/dist/src/internal.js.map +1 -1
  205. package/dist/src/ir.d.ts +1754 -1484
  206. package/dist/src/ir.d.ts.map +1 -1
  207. package/dist/src/ir.js +51 -34
  208. package/dist/src/ir.js.map +1 -1
  209. package/dist/src/ir.spec.d.ts +2 -0
  210. package/dist/src/ir.spec.d.ts.map +1 -0
  211. package/dist/src/ir.spec.js +35 -0
  212. package/dist/src/ir.spec.js.map +1 -0
  213. package/dist/src/location.d.ts +56 -17
  214. package/dist/src/location.d.ts.map +1 -1
  215. package/dist/src/location.js +226 -29
  216. package/dist/src/location.js.map +1 -1
  217. package/dist/src/location.spec.d.ts +2 -0
  218. package/dist/src/location.spec.d.ts.map +1 -0
  219. package/dist/src/location.spec.js +102 -0
  220. package/dist/src/location.spec.js.map +1 -0
  221. package/dist/src/patch/apply.d.ts +15 -0
  222. package/dist/src/patch/apply.d.ts.map +1 -0
  223. package/dist/src/patch/apply.js +352 -0
  224. package/dist/src/patch/apply.js.map +1 -0
  225. package/dist/src/patch/compose.d.ts +15 -0
  226. package/dist/src/patch/compose.d.ts.map +1 -0
  227. package/dist/src/patch/compose.js +448 -0
  228. package/dist/src/patch/compose.js.map +1 -0
  229. package/dist/src/patch/diff.d.ts +15 -0
  230. package/dist/src/patch/diff.d.ts.map +1 -0
  231. package/dist/src/patch/diff.js +347 -0
  232. package/dist/src/patch/diff.js.map +1 -0
  233. package/dist/src/patch/fuzz.d.ts +73 -0
  234. package/dist/src/patch/fuzz.d.ts.map +1 -0
  235. package/dist/src/patch/fuzz.js +159 -0
  236. package/dist/src/patch/fuzz.js.map +1 -0
  237. package/dist/src/patch/index.d.ts +32 -0
  238. package/dist/src/patch/index.d.ts.map +1 -0
  239. package/dist/src/patch/index.js +48 -0
  240. package/dist/src/patch/index.js.map +1 -0
  241. package/dist/src/patch/invert.d.ts +15 -0
  242. package/dist/src/patch/invert.d.ts.map +1 -0
  243. package/dist/src/patch/invert.js +284 -0
  244. package/dist/src/patch/invert.js.map +1 -0
  245. package/dist/src/patch/merge.d.ts +56 -0
  246. package/dist/src/patch/merge.d.ts.map +1 -0
  247. package/dist/src/patch/merge.js +586 -0
  248. package/dist/src/patch/merge.js.map +1 -0
  249. package/dist/src/patch/merge.spec.d.ts +2 -0
  250. package/dist/src/patch/merge.spec.d.ts.map +1 -0
  251. package/dist/src/patch/merge.spec.js +1139 -0
  252. package/dist/src/patch/merge.spec.js.map +1 -0
  253. package/dist/src/patch/patch.spec.d.ts +2 -0
  254. package/dist/src/patch/patch.spec.d.ts.map +1 -0
  255. package/dist/src/patch/patch.spec.js +452 -0
  256. package/dist/src/patch/patch.spec.js.map +1 -0
  257. package/dist/src/patch/path.d.ts +115 -0
  258. package/dist/src/patch/path.d.ts.map +1 -0
  259. package/dist/src/patch/path.js +192 -0
  260. package/dist/src/patch/path.js.map +1 -0
  261. package/dist/src/patch/path.spec.d.ts +6 -0
  262. package/dist/src/patch/path.spec.d.ts.map +1 -0
  263. package/dist/src/patch/path.spec.js +322 -0
  264. package/dist/src/patch/path.spec.js.map +1 -0
  265. package/dist/src/patch/prune.d.ts +77 -0
  266. package/dist/src/patch/prune.d.ts.map +1 -0
  267. package/dist/src/patch/prune.js +115 -0
  268. package/dist/src/patch/prune.js.map +1 -0
  269. package/dist/src/patch/prune.spec.d.ts +6 -0
  270. package/dist/src/patch/prune.spec.d.ts.map +1 -0
  271. package/dist/src/patch/prune.spec.js +473 -0
  272. package/dist/src/patch/prune.spec.js.map +1 -0
  273. package/dist/src/patch/type_of_patch.d.ts +25 -0
  274. package/dist/src/patch/type_of_patch.d.ts.map +1 -0
  275. package/dist/src/patch/type_of_patch.js +144 -0
  276. package/dist/src/patch/type_of_patch.js.map +1 -0
  277. package/dist/src/patch/types.d.ts +220 -0
  278. package/dist/src/patch/types.d.ts.map +1 -0
  279. package/dist/src/patch/types.js +62 -0
  280. package/dist/src/patch/types.js.map +1 -0
  281. package/dist/src/patch/validate.d.ts +44 -0
  282. package/dist/src/patch/validate.d.ts.map +1 -0
  283. package/dist/src/patch/validate.js +190 -0
  284. package/dist/src/patch/validate.js.map +1 -0
  285. package/dist/src/patch/validate.spec.d.ts +6 -0
  286. package/dist/src/patch/validate.spec.d.ts.map +1 -0
  287. package/dist/src/patch/validate.spec.js +225 -0
  288. package/dist/src/patch/validate.spec.js.map +1 -0
  289. package/dist/src/patch/walk.d.ts +121 -0
  290. package/dist/src/patch/walk.d.ts.map +1 -0
  291. package/dist/src/patch/walk.js +385 -0
  292. package/dist/src/patch/walk.js.map +1 -0
  293. package/dist/src/patch/walk.spec.d.ts +6 -0
  294. package/dist/src/patch/walk.spec.d.ts.map +1 -0
  295. package/dist/src/patch/walk.spec.js +621 -0
  296. package/dist/src/patch/walk.spec.js.map +1 -0
  297. package/dist/src/platform.d.ts +6 -0
  298. package/dist/src/platform.d.ts.map +1 -1
  299. package/dist/src/platform.spec.d.ts +2 -0
  300. package/dist/src/platform.spec.d.ts.map +1 -0
  301. package/dist/src/platform.spec.js +330 -0
  302. package/dist/src/platform.spec.js.map +1 -0
  303. package/dist/src/serialization/beast.d.ts.map +1 -1
  304. package/dist/src/serialization/beast.js +12 -0
  305. package/dist/src/serialization/beast.js.map +1 -1
  306. package/dist/src/serialization/beast.spec.d.ts +6 -0
  307. package/dist/src/serialization/beast.spec.d.ts.map +1 -0
  308. package/dist/src/serialization/beast.spec.js +406 -0
  309. package/dist/src/serialization/beast.spec.js.map +1 -0
  310. package/dist/src/serialization/beast2/index.d.ts +50 -0
  311. package/dist/src/serialization/beast2/index.d.ts.map +1 -0
  312. package/dist/src/serialization/beast2/index.js +756 -0
  313. package/dist/src/serialization/beast2/index.js.map +1 -0
  314. package/dist/src/serialization/beast2/index.spec.d.ts +6 -0
  315. package/dist/src/serialization/beast2/index.spec.d.ts.map +1 -0
  316. package/dist/src/serialization/beast2/index.spec.js +528 -0
  317. package/dist/src/serialization/beast2/index.spec.js.map +1 -0
  318. package/dist/src/serialization/beast2/sourcemap-table.d.ts +29 -0
  319. package/dist/src/serialization/beast2/sourcemap-table.d.ts.map +1 -0
  320. package/dist/src/serialization/beast2/sourcemap-table.js +82 -0
  321. package/dist/src/serialization/beast2/sourcemap-table.js.map +1 -0
  322. package/dist/src/serialization/beast2/string-table.d.ts +16 -0
  323. package/dist/src/serialization/beast2/string-table.d.ts.map +1 -0
  324. package/dist/src/serialization/beast2/string-table.js +38 -0
  325. package/dist/src/serialization/beast2/string-table.js.map +1 -0
  326. package/dist/src/serialization/beast2/type-table.d.ts +86 -0
  327. package/dist/src/serialization/beast2/type-table.d.ts.map +1 -0
  328. package/dist/src/serialization/beast2/type-table.js +618 -0
  329. package/dist/src/serialization/beast2/type-table.js.map +1 -0
  330. package/dist/src/serialization/beast2/value-table.d.ts +40 -0
  331. package/dist/src/serialization/beast2/value-table.d.ts.map +1 -0
  332. package/dist/src/serialization/beast2/value-table.js +157 -0
  333. package/dist/src/serialization/beast2/value-table.js.map +1 -0
  334. package/dist/src/serialization/binary-utils.d.ts +33 -0
  335. package/dist/src/serialization/binary-utils.d.ts.map +1 -1
  336. package/dist/src/serialization/binary-utils.js +157 -0
  337. package/dist/src/serialization/binary-utils.js.map +1 -1
  338. package/dist/src/serialization/csv.d.ts +17 -17
  339. package/dist/src/serialization/csv.d.ts.map +1 -1
  340. package/dist/src/serialization/csv.js +10 -8
  341. package/dist/src/serialization/csv.js.map +1 -1
  342. package/dist/src/serialization/csv.spec.d.ts +2 -0
  343. package/dist/src/serialization/csv.spec.d.ts.map +1 -0
  344. package/dist/src/serialization/csv.spec.js +556 -0
  345. package/dist/src/serialization/csv.spec.js.map +1 -0
  346. package/dist/src/serialization/east-inferred.spec.d.ts +2 -0
  347. package/dist/src/serialization/east-inferred.spec.d.ts.map +1 -0
  348. package/dist/src/serialization/east-inferred.spec.js +322 -0
  349. package/dist/src/serialization/east-inferred.spec.js.map +1 -0
  350. package/dist/src/serialization/east.d.ts +1 -1
  351. package/dist/src/serialization/east.d.ts.map +1 -1
  352. package/dist/src/serialization/east.js +178 -26
  353. package/dist/src/serialization/east.js.map +1 -1
  354. package/dist/src/serialization/east.spec.d.ts +2 -0
  355. package/dist/src/serialization/east.spec.d.ts.map +1 -0
  356. package/dist/src/serialization/east.spec.js +1548 -0
  357. package/dist/src/serialization/east.spec.js.map +1 -0
  358. package/dist/src/serialization/index.d.ts +1 -2
  359. package/dist/src/serialization/index.d.ts.map +1 -1
  360. package/dist/src/serialization/index.js +1 -2
  361. package/dist/src/serialization/index.js.map +1 -1
  362. package/dist/src/serialization/json.d.ts +1 -1
  363. package/dist/src/serialization/json.d.ts.map +1 -1
  364. package/dist/src/serialization/json.js +123 -24
  365. package/dist/src/serialization/json.js.map +1 -1
  366. package/dist/src/serialization/json.spec.d.ts +2 -0
  367. package/dist/src/serialization/json.spec.d.ts.map +1 -0
  368. package/dist/src/serialization/json.spec.js +1297 -0
  369. package/dist/src/serialization/json.spec.js.map +1 -0
  370. package/dist/src/type_of_type.d.ts +72 -35
  371. package/dist/src/type_of_type.d.ts.map +1 -1
  372. package/dist/src/type_of_type.is_data.spec.d.ts +6 -0
  373. package/dist/src/type_of_type.is_data.spec.d.ts.map +1 -0
  374. package/dist/src/type_of_type.is_data.spec.js +221 -0
  375. package/dist/src/type_of_type.is_data.spec.js.map +1 -0
  376. package/dist/src/type_of_type.js +355 -80
  377. package/dist/src/type_of_type.js.map +1 -1
  378. package/dist/src/type_of_type.to_etv.spec.d.ts +6 -0
  379. package/dist/src/type_of_type.to_etv.spec.d.ts.map +1 -0
  380. package/dist/src/type_of_type.to_etv.spec.js +263 -0
  381. package/dist/src/type_of_type.to_etv.spec.js.map +1 -0
  382. package/dist/src/types.d.ts +82 -12
  383. package/dist/src/types.d.ts.map +1 -1
  384. package/dist/src/types.error.spec.d.ts +2 -0
  385. package/dist/src/types.error.spec.d.ts.map +1 -0
  386. package/dist/src/types.error.spec.js +665 -0
  387. package/dist/src/types.error.spec.js.map +1 -0
  388. package/dist/src/types.js +663 -156
  389. package/dist/src/types.js.map +1 -1
  390. package/dist/src/types.spec.d.ts +2 -0
  391. package/dist/src/types.spec.d.ts.map +1 -0
  392. package/dist/src/types.spec.js +946 -0
  393. package/dist/src/types.spec.js.map +1 -0
  394. package/dist/src/walker.d.ts +65 -0
  395. package/dist/src/walker.d.ts.map +1 -0
  396. package/dist/src/walker.js +165 -0
  397. package/dist/src/walker.js.map +1 -0
  398. package/dist/src/walker.spec.d.ts +6 -0
  399. package/dist/src/walker.spec.d.ts.map +1 -0
  400. package/dist/src/walker.spec.js +109 -0
  401. package/dist/src/walker.spec.js.map +1 -0
  402. package/package.json +16 -38
  403. package/dist/src/serialization/beast2-stream.d.ts +0 -38
  404. package/dist/src/serialization/beast2-stream.d.ts.map +0 -1
  405. package/dist/src/serialization/beast2-stream.js +0 -670
  406. package/dist/src/serialization/beast2-stream.js.map +0 -1
  407. package/dist/src/serialization/beast2.d.ts +0 -41
  408. package/dist/src/serialization/beast2.d.ts.map +0 -1
  409. package/dist/src/serialization/beast2.js +0 -495
  410. package/dist/src/serialization/beast2.js.map +0 -1
@@ -1,12 +1,12 @@
1
1
  /**
2
- * Formats a location as a human-readable string.
2
+ * Formats a single location as a human-readable string.
3
3
  *
4
4
  * @param location - The source location to format
5
5
  * @returns A string in the format `"<filename> <line>:<column>"`
6
6
  *
7
7
  * @example
8
8
  * ```ts
9
- * const loc = { filename: "main.ts", line: 42, column: 15 };
9
+ * const loc = { filename: "main.ts", line: 42n, column: 15n };
10
10
  * printLocation(loc); // "main.ts 42:15"
11
11
  * ```
12
12
  */
@@ -14,49 +14,246 @@ export function printLocation(location) {
14
14
  return `${location.filename} ${location.line}:${location.column}`;
15
15
  }
16
16
  /**
17
- * Captures the source location of the calling code using stack trace inspection.
17
+ * Formats an array of locations as a stack trace string.
18
18
  *
19
- * @param skip - Number of stack frames to skip (default = 1 returns the caller's location)
20
- * @returns A {@link Location} object representing the source position
19
+ * @param locations - The source locations to format
20
+ * @returns A stack trace string with each location on a new line
21
+ *
22
+ * @example
23
+ * ```ts
24
+ * const locs = [
25
+ * { filename: "main.ts", line: 42n, column: 15n },
26
+ * { filename: "lib.ts", line: 10n, column: 5n }
27
+ * ];
28
+ * printLocations(locs);
29
+ * // "main.ts 42:15
30
+ * // at lib.ts 10:5"
31
+ * ```
32
+ */
33
+ export function printLocations(locations) {
34
+ if (locations.length === 0)
35
+ return '<unknown>';
36
+ const [first, ...rest] = locations;
37
+ const header = printLocation(first);
38
+ if (rest.length === 0)
39
+ return header;
40
+ return header + '\n' + rest.map(loc => ` at ${printLocation(loc)}`).join('\n');
41
+ }
42
+ /**
43
+ * Determines if a stack frame should be included in location captures.
44
+ * Filters out internal frames (Node.js internals, node_modules) to show
45
+ * only user code in error stack traces.
46
+ *
47
+ * @param filename - The file path from the stack frame
48
+ * @returns true if the frame should be included, false to filter it out
49
+ */
50
+ function shouldIncludeFrame(filename) {
51
+ // Skip Node.js internal modules (e.g., node:internal/modules/...)
52
+ if (filename.startsWith('node:'))
53
+ return false;
54
+ // Skip node_modules - filters out third-party packages including East
55
+ // when installed as a dependency. Handles both Unix and Windows paths.
56
+ if (filename.includes('/node_modules/') || filename.includes('\\node_modules\\'))
57
+ return false;
58
+ return true;
59
+ }
60
+ /**
61
+ * Captures the call stack as an array of source locations, filtered to
62
+ * show only user code.
63
+ *
64
+ * @returns An array of {@link Location} objects representing the call stack,
65
+ * from innermost (most recent) to outermost frame
21
66
  *
22
67
  * @remarks
23
- * This function uses JavaScript's Error stack traces to determine the caller's
24
- * source location. Returns `{ filename: "<unknown>", line: 0, column: 0 }` if
25
- * the stack trace cannot be parsed.
68
+ * This function uses JavaScript's Error stack traces to capture the call
69
+ * stack. Internal frames (Node.js internals, node_modules packages) are
70
+ * filtered out to provide clean stack traces showing only user code.
71
+ * Returns an empty array if the stack trace cannot be parsed.
26
72
  *
27
73
  * @example
28
74
  * ```ts
29
75
  * function myFunction() {
30
- * const loc = get_location(); // Gets location of this call
31
- * console.log(printLocation(loc));
76
+ * const stack = get_location(); // Gets call stack of user code
77
+ * console.log(printLocations(stack));
32
78
  * }
33
79
  * ```
34
80
  */
35
- export function get_location(skip = 1) {
36
- // Create an Error object to capture the stack trace
81
+ // ── Frame path normalization ───────────────────────────────────────────
82
+ //
83
+ // Stack-trace paths are absolute and environment-specific (and `file://` URLs
84
+ // under ESM). Baking them into serialized IR leaks the author's filesystem
85
+ // layout and makes the IR non-reproducible across machines and build modes. We
86
+ // normalize each frame path to a portable form: strip the `file://` scheme,
87
+ // normalize separators, and relativize to a base directory. The base defaults
88
+ // to the working directory when one is available (Node) and can be set with
89
+ // `setLocationBasePath` (e.g. for deterministic fixtures). Browser / no-cwd
90
+ // environments keep the cleaned path. This stays free of `node:` imports
91
+ // (browser-safe) and never throws.
92
+ let explicitBaseSet = false;
93
+ let explicitBase;
94
+ let autoBase;
95
+ let autoBaseComputed = false;
96
+ function normalizeSeparators(p) {
97
+ return p.replace(/\\/g, '/');
98
+ }
99
+ function stripTrailingSlash(p) {
100
+ return p.length > 1 && p.endsWith('/') ? p.slice(0, -1) : p;
101
+ }
102
+ function stripFileUrl(p) {
103
+ if (!p.startsWith('file://'))
104
+ return p;
105
+ try {
106
+ // `URL` is a universal (WHATWG) global — present in Node and browsers, no
107
+ // `node:url` import. `.pathname` is percent-encoded; decode it.
108
+ const pathname = decodeURIComponent(new URL(p).pathname);
109
+ return pathname.replace(/^\/([A-Za-z]:)/, '$1'); // Windows: "/C:/x" → "C:/x"
110
+ }
111
+ catch {
112
+ return p;
113
+ }
114
+ }
115
+ function computeAutoBase() {
116
+ if (!autoBaseComputed) {
117
+ autoBaseComputed = true;
118
+ // Guarded global access (not a `node:` import) — `process` is undefined in
119
+ // the browser, where we simply skip relativization.
120
+ const proc = globalThis.process;
121
+ if (proc !== undefined && typeof proc.cwd === 'function') {
122
+ try {
123
+ autoBase = stripTrailingSlash(normalizeSeparators(String(proc.cwd())));
124
+ }
125
+ catch {
126
+ autoBase = undefined;
127
+ }
128
+ }
129
+ }
130
+ return autoBase;
131
+ }
132
+ function currentBase() {
133
+ return explicitBaseSet ? explicitBase : computeAutoBase();
134
+ }
135
+ /**
136
+ * Set the base directory that captured locations are relativized against.
137
+ * Pass a path to relativize against it (paths outside it stay absolute); pass
138
+ * `undefined` to reset to the automatic default (the working directory in
139
+ * Node, none in the browser).
140
+ */
141
+ export function setLocationBasePath(base) {
142
+ if (base === undefined) {
143
+ explicitBaseSet = false;
144
+ explicitBase = undefined;
145
+ }
146
+ else {
147
+ explicitBaseSet = true;
148
+ explicitBase = stripTrailingSlash(normalizeSeparators(stripFileUrl(base)));
149
+ }
150
+ }
151
+ /**
152
+ * Normalize a stack-frame path to a portable, deterministic form: `file://`
153
+ * stripped, separators as `/`, and relativized to the current base when the
154
+ * path is under it. Exported for testing. Never throws.
155
+ */
156
+ export function normalizeFramePath(raw) {
157
+ try {
158
+ const cleaned = normalizeSeparators(stripFileUrl(raw));
159
+ const base = currentBase();
160
+ if (base !== undefined && base !== '') {
161
+ if (cleaned === base)
162
+ return '.';
163
+ if (cleaned.startsWith(base + '/'))
164
+ return cleaned.slice(base.length + 1);
165
+ }
166
+ return cleaned;
167
+ }
168
+ catch {
169
+ return raw;
170
+ }
171
+ }
172
+ function capture_stack_frames() {
37
173
  const err = new Error();
38
- // Parse the stack trace
39
174
  const stack = err.stack;
40
- if (!stack) {
41
- return { filename: "<unknown>", line: 0, column: 0 };
42
- }
43
- // Split into lines and remove the 'Error' line and this function's line
44
- const lines = stack.split('\n').slice(skip + 1);
45
- // Find the first meaningful stack frame
175
+ if (!stack)
176
+ return [];
177
+ const lines = stack.split('\n').slice(1); // Skip "Error" line
178
+ const frames = [];
46
179
  for (const line of lines) {
47
- // First match the whole path with line and column
48
- const match = line.match(/at\s[<>a-zA-Z0-9_$]*\s+(?:(?:\w+\.)*\w+\s+)?\(?(.*?):(\d+):(\d+)\)?$/);
180
+ // Simple regex that matches file:line:col at end of line
181
+ const match = line.match(/\(?([^()\s]+):(\d+):(\d+)\)?$/);
49
182
  if (match) {
50
- const [, fullPath, line, column] = match;
51
- // Skip if it's an anonymous internal file
52
- if (fullPath == undefined || fullPath === '') {
53
- continue;
183
+ const [, filename, lineNum, column] = match;
184
+ // `shouldIncludeFrame` runs on the raw path so its node_modules/internal
185
+ // filters see absolute paths; the stored path is normalized.
186
+ if (filename && filename !== '' && shouldIncludeFrame(filename)) {
187
+ frames.push({ filename: normalizeFramePath(filename), line: BigInt(lineNum), column: BigInt(column) });
54
188
  }
55
- // TODO should we extract a subset of the fullPath?
56
- // Return filename with line and column
57
- return { filename: fullPath, line: Number(line), column: Number(column) };
58
189
  }
59
190
  }
60
- return { filename: "<unknown>", line: 0, column: 0 };
191
+ return frames;
192
+ }
193
+ export function get_location() {
194
+ return capture_stack_frames();
195
+ }
196
+ // ── SourceMap ──────────────────────────────────────────────────────────
197
+ /** Reserved sentinel: resolve(0n) returns [], the "no/unknown location" id. */
198
+ export const UNKNOWN_LOC_ID = 0n;
199
+ export class SourceMap {
200
+ /** Location stacks, indexed by Number(loc_id). stacks[0] is always []. */
201
+ stacks = [[]];
202
+ /** Content key → loc_id for dedup during construction. */
203
+ intern = new Map();
204
+ /** Intern a location stack. Returns a stable loc_id (bigint).
205
+ * Equal content returns the same id. Empty stack → UNKNOWN_LOC_ID. */
206
+ intern_stack(stack) {
207
+ if (stack.length === 0)
208
+ return UNKNOWN_LOC_ID;
209
+ const key = stack.map(l => `${l.filename}|${l.line}|${l.column}`).join('\n');
210
+ const existing = this.intern.get(key);
211
+ if (existing !== undefined)
212
+ return existing;
213
+ const id = BigInt(this.stacks.length);
214
+ this.stacks.push(stack);
215
+ this.intern.set(key, id);
216
+ return id;
217
+ }
218
+ /** Resolve a loc_id to its stack. Returns [] for UNKNOWN_LOC_ID or out-of-range. */
219
+ resolve(loc_id) {
220
+ return this.stacks[Number(loc_id)] ?? [];
221
+ }
222
+ /** Total number of entries, including the reserved empty entry at index 0. */
223
+ get size() { return BigInt(this.stacks.length); }
224
+ /** All entries in loc_id order (for serialization). Entry 0 is always []. */
225
+ entries() { return this.stacks; }
226
+ }
227
+ // ── Scoped context ─────────────────────────────────────────────────────
228
+ let _currentMap = null;
229
+ /** Run `fn` with `map` as the current scope's source map. Re-entrant safe. */
230
+ export function with_source_map(map, fn) {
231
+ const prev = _currentMap;
232
+ _currentMap = map;
233
+ try {
234
+ return fn();
235
+ }
236
+ finally {
237
+ _currentMap = prev;
238
+ }
239
+ }
240
+ /** Wraps `fn` in a new `with_source_map` only if no map is currently active.
241
+ * Nested calls inherit the existing map. */
242
+ export function ensure_source_map(fn) {
243
+ if (_currentMap)
244
+ return fn();
245
+ return with_source_map(new SourceMap(), fn);
246
+ }
247
+ /** Returns the current SourceMap, or null if outside any with_source_map scope. */
248
+ export function get_current_source_map() {
249
+ return _currentMap;
250
+ }
251
+ /** Capture current stack and intern into the active SourceMap.
252
+ * Returns UNKNOWN_LOC_ID (0n) if no map is active. */
253
+ export function get_location_id() {
254
+ if (!_currentMap)
255
+ return UNKNOWN_LOC_ID;
256
+ const stack = capture_stack_frames();
257
+ return _currentMap.intern_stack(stack);
61
258
  }
62
259
  //# sourceMappingURL=location.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"location.js","sourceRoot":"","sources":["../../src/location.ts"],"names":[],"mappings":"AAeA;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,aAAa,CAAC,QAAkB;IAC9C,OAAO,GAAG,QAAQ,CAAC,QAAQ,IAAI,QAAQ,CAAC,IAAI,IAAI,QAAQ,CAAC,MAAM,EAAE,CAAC;AACpE,CAAC;AAED;;;;;;;;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,EAAE,EAAE,CAAC;IAC7B,OAAO,eAAe,CAAC,IAAI,SAAS,EAAE,EAAE,EAAE,CAAC,CAAC;AAC9C,CAAC;AAED,mFAAmF;AACnF,MAAM,UAAU,sBAAsB;IACpC,OAAO,WAAW,CAAC;AACrB,CAAC;AAED;uDACuD;AACvD,MAAM,UAAU,eAAe;IAC7B,IAAI,CAAC,WAAW;QAAE,OAAO,cAAc,CAAC;IACxC,MAAM,KAAK,GAAG,oBAAoB,EAAE,CAAC;IACrC,OAAO,WAAW,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;AACzC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=location.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"location.spec.d.ts","sourceRoot":"","sources":["../../src/location.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,102 @@
1
+ /**
2
+ * Copyright (c) 2025 Elara AI Pty Ltd
3
+ * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
4
+ */
5
+ import assert from "node:assert/strict";
6
+ import { afterEach, describe, test } from "node:test";
7
+ import { normalizeFramePath, setLocationBasePath } from "./location.js";
8
+ describe("normalizeFramePath", () => {
9
+ // Reset to the automatic (cwd) base after every test so cases don't leak.
10
+ afterEach(() => setLocationBasePath(undefined));
11
+ describe("file:// scheme stripping", () => {
12
+ test("strips a Unix file:// URL and relativizes to the base", () => {
13
+ setLocationBasePath("/home/u/proj");
14
+ assert.equal(normalizeFramePath("file:///home/u/proj/dist/src/foo.js"), "dist/src/foo.js");
15
+ });
16
+ test("strips a Windows file:// URL (drops the leading slash before the drive)", () => {
17
+ setLocationBasePath("C:/Users/x/proj");
18
+ assert.equal(normalizeFramePath("file:///C:/Users/x/proj/src/foo.ts"), "src/foo.ts");
19
+ });
20
+ test("decodes percent-encoding (e.g. spaces) in file:// URLs", () => {
21
+ setLocationBasePath("/home/u/my proj");
22
+ assert.equal(normalizeFramePath("file:///home/u/my%20proj/src/foo.ts"), "src/foo.ts");
23
+ });
24
+ test("a file:// URL outside the base is returned cleaned but absolute", () => {
25
+ setLocationBasePath("/home/u/proj");
26
+ assert.equal(normalizeFramePath("file:///opt/other/foo.ts"), "/opt/other/foo.ts");
27
+ });
28
+ });
29
+ describe("plain paths", () => {
30
+ test("relativizes a plain Unix absolute path under the base", () => {
31
+ setLocationBasePath("/home/u/proj");
32
+ assert.equal(normalizeFramePath("/home/u/proj/src/a/b/foo.ts"), "src/a/b/foo.ts");
33
+ });
34
+ test("normalizes Windows backslashes and relativizes", () => {
35
+ setLocationBasePath("C:\\Users\\x\\proj");
36
+ assert.equal(normalizeFramePath("C:\\Users\\x\\proj\\dist\\foo.js"), "dist/foo.js");
37
+ });
38
+ test("a path not under the base is returned unchanged (cleaned)", () => {
39
+ setLocationBasePath("/home/u/proj");
40
+ assert.equal(normalizeFramePath("/somewhere/else/foo.ts"), "/somewhere/else/foo.ts");
41
+ });
42
+ });
43
+ describe("base-boundary correctness", () => {
44
+ test("a sibling dir sharing a prefix is NOT falsely relativized", () => {
45
+ setLocationBasePath("/a/proj");
46
+ // "/a/proj-extra/..." must not be treated as inside "/a/proj"
47
+ assert.equal(normalizeFramePath("/a/proj-extra/foo.ts"), "/a/proj-extra/foo.ts");
48
+ });
49
+ test("a trailing slash on the base is handled", () => {
50
+ setLocationBasePath("/a/proj/");
51
+ assert.equal(normalizeFramePath("/a/proj/foo.ts"), "foo.ts");
52
+ });
53
+ test("a path equal to the base resolves to '.'", () => {
54
+ setLocationBasePath("/a/proj");
55
+ assert.equal(normalizeFramePath("/a/proj"), ".");
56
+ });
57
+ test("setLocationBasePath accepts a file:// base", () => {
58
+ setLocationBasePath("file:///home/u/proj");
59
+ assert.equal(normalizeFramePath("file:///home/u/proj/src/foo.ts"), "src/foo.ts");
60
+ });
61
+ });
62
+ describe("non-file environments", () => {
63
+ test("a browser http(s) URL is left as-is", () => {
64
+ setLocationBasePath("/home/u/proj");
65
+ assert.equal(normalizeFramePath("https://example.com/app/foo.js"), "https://example.com/app/foo.js");
66
+ });
67
+ });
68
+ describe("automatic base (process.cwd) and reset", () => {
69
+ test("relativizes paths under the working directory when no base is set", () => {
70
+ setLocationBasePath(undefined); // auto → process.cwd()
71
+ const cwd = process.cwd().replace(/\\/g, "/");
72
+ assert.equal(normalizeFramePath(`${cwd}/dist/src/foo.js`), "dist/src/foo.js");
73
+ });
74
+ test("leaves paths outside the working directory absolute", () => {
75
+ setLocationBasePath(undefined);
76
+ assert.equal(normalizeFramePath("/definitely/not/under/cwd/foo.ts"), "/definitely/not/under/cwd/foo.ts");
77
+ });
78
+ test("an explicit base overrides the automatic one, and undefined resets it", () => {
79
+ setLocationBasePath("/explicit/root");
80
+ assert.equal(normalizeFramePath("/explicit/root/x.ts"), "x.ts");
81
+ setLocationBasePath(undefined);
82
+ // back to cwd-relative: an /explicit/root path is now (almost certainly) absolute
83
+ assert.equal(normalizeFramePath("/explicit/root/x.ts"), "/explicit/root/x.ts");
84
+ });
85
+ });
86
+ describe("robustness — never throws, returns sensible output", () => {
87
+ test("empty string", () => {
88
+ setLocationBasePath("/a/proj");
89
+ assert.equal(normalizeFramePath(""), "");
90
+ });
91
+ test("garbage with no path structure", () => {
92
+ setLocationBasePath("/a/proj");
93
+ assert.equal(normalizeFramePath("<anonymous>"), "<anonymous>");
94
+ });
95
+ test("malformed file:// URL is returned without throwing", () => {
96
+ setLocationBasePath(undefined);
97
+ const out = normalizeFramePath("file://");
98
+ assert.equal(typeof out, "string");
99
+ });
100
+ });
101
+ });
102
+ //# sourceMappingURL=location.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"location.spec.js","sourceRoot":"","sources":["../../src/location.spec.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,E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,oDAAoD,EAAE,GAAG,EAAE;QAClE,IAAI,CAAC,cAAc,EAAE,GAAG,EAAE;YACxB,mBAAmB,CAAC,SAAS,CAAC,CAAC;YAC/B,MAAM,CAAC,KAAK,CAAC,kBAAkB,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;QAC3C,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,gCAAgC,EAAE,GAAG,EAAE;YAC1C,mBAAmB,CAAC,SAAS,CAAC,CAAC;YAC/B,MAAM,CAAC,KAAK,CAAC,kBAAkB,CAAC,aAAa,CAAC,EAAE,aAAa,CAAC,CAAC;QACjE,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,oDAAoD,EAAE,GAAG,EAAE;YAC9D,mBAAmB,CAAC,SAAS,CAAC,CAAC;YAC/B,MAAM,GAAG,GAAG,kBAAkB,CAAC,SAAS,CAAC,CAAC;YAC1C,MAAM,CAAC,KAAK,CAAC,OAAO,GAAG,EAAE,QAAQ,CAAC,CAAC;QACrC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Copyright (c) 2025 Elara AI Pty Ltd
3
+ * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
4
+ */
5
+ /**
6
+ * applyFor - Apply a patch to an East value.
7
+ *
8
+ * @module
9
+ */
10
+ import { type EastTypeValue } from "../type_of_type.js";
11
+ import type { EastType, ValueTypeOf } from "../types.js";
12
+ import { type ApplyContext } from "./types.js";
13
+ export declare function applyFor(type: EastTypeValue, ctx?: ApplyContext): (base: any, patch: any) => any;
14
+ export declare function applyFor<T extends EastType>(type: T): (base: ValueTypeOf<T>, patch: any) => ValueTypeOf<T>;
15
+ //# sourceMappingURL=apply.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apply.d.ts","sourceRoot":"","sources":["../../../src/patch/apply.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AAEH,OAAO,EAAmB,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACzE,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAOzD,OAAO,EAAE,KAAK,YAAY,EAAiB,MAAM,YAAY,CAAC;AAE9D,wBAAgB,QAAQ,CAAC,IAAI,EAAE,aAAa,EAAE,GAAG,CAAC,EAAE,YAAY,GAAG,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,KAAK,GAAG,CAAC;AAClG,wBAAgB,QAAQ,CAAC,CAAC,SAAS,QAAQ,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,KAAK,WAAW,CAAC,CAAC,CAAC,CAAC"}