@elaraai/east 1.0.79 → 1.0.81

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 (379) hide show
  1. package/README.md +1 -1
  2. package/dist/src/builtins.d.ts +1 -1
  3. package/dist/src/builtins.d.ts.map +1 -1
  4. package/dist/src/builtins.js +19 -0
  5. package/dist/src/builtins.js.map +1 -1
  6. package/dist/src/codegen/spellings.d.ts.map +1 -1
  7. package/dist/src/codegen/spellings.js +3 -0
  8. package/dist/src/codegen/spellings.js.map +1 -1
  9. package/dist/src/comparison.d.ts +54 -0
  10. package/dist/src/comparison.d.ts.map +1 -1
  11. package/dist/src/comparison.equivalent.spec.d.ts +6 -0
  12. package/dist/src/comparison.equivalent.spec.d.ts.map +1 -0
  13. package/dist/src/comparison.equivalent.spec.js +130 -0
  14. package/dist/src/comparison.equivalent.spec.js.map +1 -0
  15. package/dist/src/comparison.js +97 -25
  16. package/dist/src/comparison.js.map +1 -1
  17. package/dist/src/compile/builtins/array.d.ts +60 -0
  18. package/dist/src/compile/builtins/array.d.ts.map +1 -0
  19. package/dist/src/compile/builtins/array.js +691 -0
  20. package/dist/src/compile/builtins/array.js.map +1 -0
  21. package/dist/src/compile/builtins/blob.d.ts +18 -0
  22. package/dist/src/compile/builtins/blob.d.ts.map +1 -0
  23. package/dist/src/compile/builtins/blob.js +150 -0
  24. package/dist/src/compile/builtins/blob.js.map +1 -0
  25. package/dist/src/compile/builtins/compare.d.ts +18 -0
  26. package/dist/src/compile/builtins/compare.d.ts.map +1 -0
  27. package/dist/src/compile/builtins/compare.js +52 -0
  28. package/dist/src/compile/builtins/compare.js.map +1 -0
  29. package/dist/src/compile/builtins/datetime.d.ts +21 -0
  30. package/dist/src/compile/builtins/datetime.d.ts.map +1 -0
  31. package/dist/src/compile/builtins/datetime.js +46 -0
  32. package/dist/src/compile/builtins/datetime.js.map +1 -0
  33. package/dist/src/compile/builtins/dict.d.ts +47 -0
  34. package/dist/src/compile/builtins/dict.d.ts.map +1 -0
  35. package/dist/src/compile/builtins/dict.js +576 -0
  36. package/dist/src/compile/builtins/dict.js.map +1 -0
  37. package/dist/src/compile/builtins/index.d.ts +9 -0
  38. package/dist/src/compile/builtins/index.d.ts.map +1 -0
  39. package/dist/src/compile/builtins/index.js +28 -0
  40. package/dist/src/compile/builtins/index.js.map +1 -0
  41. package/dist/src/compile/builtins/matrix.d.ts +31 -0
  42. package/dist/src/compile/builtins/matrix.d.ts.map +1 -0
  43. package/dist/src/compile/builtins/matrix.js +310 -0
  44. package/dist/src/compile/builtins/matrix.js.map +1 -0
  45. package/dist/src/compile/builtins/primitives.d.ts +36 -0
  46. package/dist/src/compile/builtins/primitives.d.ts.map +1 -0
  47. package/dist/src/compile/builtins/primitives.js +67 -0
  48. package/dist/src/compile/builtins/primitives.js.map +1 -0
  49. package/dist/src/compile/builtins/ref.d.ts +11 -0
  50. package/dist/src/compile/builtins/ref.d.ts.map +1 -0
  51. package/dist/src/compile/builtins/ref.js +30 -0
  52. package/dist/src/compile/builtins/ref.js.map +1 -0
  53. package/dist/src/compile/builtins/set.d.ts +42 -0
  54. package/dist/src/compile/builtins/set.d.ts.map +1 -0
  55. package/dist/src/compile/builtins/set.js +410 -0
  56. package/dist/src/compile/builtins/set.js.map +1 -0
  57. package/dist/src/compile/builtins/sparse.d.ts +19 -0
  58. package/dist/src/compile/builtins/sparse.d.ts.map +1 -0
  59. package/dist/src/compile/builtins/sparse.js +143 -0
  60. package/dist/src/compile/builtins/sparse.js.map +1 -0
  61. package/dist/src/compile/builtins/string.d.ts +34 -0
  62. package/dist/src/compile/builtins/string.d.ts.map +1 -0
  63. package/dist/src/compile/builtins/string.js +238 -0
  64. package/dist/src/compile/builtins/string.js.map +1 -0
  65. package/dist/src/compile/builtins/tree.d.ts +32 -0
  66. package/dist/src/compile/builtins/tree.d.ts.map +1 -0
  67. package/dist/src/compile/builtins/tree.js +108 -0
  68. package/dist/src/compile/builtins/tree.js.map +1 -0
  69. package/dist/src/compile/builtins/vector.d.ts +44 -0
  70. package/dist/src/compile/builtins/vector.d.ts.map +1 -0
  71. package/dist/src/compile/builtins/vector.js +463 -0
  72. package/dist/src/compile/builtins/vector.js.map +1 -0
  73. package/dist/src/compile/constructors.d.ts +13 -0
  74. package/dist/src/compile/constructors.d.ts.map +1 -0
  75. package/dist/src/compile/constructors.js +179 -0
  76. package/dist/src/compile/constructors.js.map +1 -0
  77. package/dist/src/compile/control.d.ts +13 -0
  78. package/dist/src/compile/control.d.ts.map +1 -0
  79. package/dist/src/compile/control.js +513 -0
  80. package/dist/src/compile/control.js.map +1 -0
  81. package/dist/src/compile/functions.d.ts +13 -0
  82. package/dist/src/compile/functions.d.ts.map +1 -0
  83. package/dist/src/compile/functions.js +492 -0
  84. package/dist/src/compile/functions.js.map +1 -0
  85. package/dist/src/compile/ir.d.ts +19 -0
  86. package/dist/src/compile/ir.d.ts.map +1 -0
  87. package/dist/src/compile/ir.js +193 -0
  88. package/dist/src/compile/ir.js.map +1 -0
  89. package/dist/src/compile/runtime.d.ts +75 -0
  90. package/dist/src/compile/runtime.d.ts.map +1 -0
  91. package/dist/src/compile/runtime.js +114 -0
  92. package/dist/src/compile/runtime.js.map +1 -0
  93. package/dist/src/compile/type_parameters.d.ts +4 -0
  94. package/dist/src/compile/type_parameters.d.ts.map +1 -0
  95. package/dist/src/compile/type_parameters.js +55 -0
  96. package/dist/src/compile/type_parameters.js.map +1 -0
  97. package/dist/src/compile/typed_arrays.d.ts +28 -0
  98. package/dist/src/compile/typed_arrays.d.ts.map +1 -0
  99. package/dist/src/compile/typed_arrays.js +77 -0
  100. package/dist/src/compile/typed_arrays.js.map +1 -0
  101. package/dist/src/compile.d.ts +6 -41
  102. package/dist/src/compile.d.ts.map +1 -1
  103. package/dist/src/compile.js +8 -4415
  104. package/dist/src/compile.js.map +1 -1
  105. package/dist/src/compile.open_beast.spec.js +5 -4
  106. package/dist/src/compile.open_beast.spec.js.map +1 -1
  107. package/dist/src/compile.signature.spec.d.ts +6 -0
  108. package/dist/src/compile.signature.spec.d.ts.map +1 -0
  109. package/dist/src/compile.signature.spec.js +53 -0
  110. package/dist/src/compile.signature.spec.js.map +1 -0
  111. package/dist/src/containers/sortedmap.d.ts +2 -1
  112. package/dist/src/containers/sortedmap.d.ts.map +1 -1
  113. package/dist/src/containers/sortedmap.js +4 -2
  114. package/dist/src/containers/sortedmap.js.map +1 -1
  115. package/dist/src/containers/sortedset.d.ts +2 -1
  116. package/dist/src/containers/sortedset.d.ts.map +1 -1
  117. package/dist/src/containers/sortedset.js +4 -2
  118. package/dist/src/containers/sortedset.js.map +1 -1
  119. package/dist/src/error.d.ts +15 -0
  120. package/dist/src/error.d.ts.map +1 -1
  121. package/dist/src/error.js +16 -0
  122. package/dist/src/error.js.map +1 -1
  123. package/dist/src/expr/array.d.ts +158 -81
  124. package/dist/src/expr/array.d.ts.map +1 -1
  125. package/dist/src/expr/array.js +68 -51
  126. package/dist/src/expr/array.js.map +1 -1
  127. package/dist/src/expr/ast.d.ts.map +1 -1
  128. package/dist/src/expr/ast.js +13 -0
  129. package/dist/src/expr/ast.js.map +1 -1
  130. package/dist/src/expr/blob.d.ts +8 -8
  131. package/dist/src/expr/blob.js +8 -8
  132. package/dist/src/expr/block.d.ts +18 -5
  133. package/dist/src/expr/block.d.ts.map +1 -1
  134. package/dist/src/expr/block.js +19 -0
  135. package/dist/src/expr/block.js.map +1 -1
  136. package/dist/src/expr/boolean.d.ts +10 -10
  137. package/dist/src/expr/boolean.js +10 -10
  138. package/dist/src/expr/datetime.d.ts +28 -28
  139. package/dist/src/expr/datetime.js +28 -28
  140. package/dist/src/expr/dict.d.ts +101 -51
  141. package/dist/src/expr/dict.d.ts.map +1 -1
  142. package/dist/src/expr/dict.js +97 -36
  143. package/dist/src/expr/dict.js.map +1 -1
  144. package/dist/src/expr/float.d.ts +23 -23
  145. package/dist/src/expr/float.js +23 -23
  146. package/dist/src/expr/integer.d.ts +17 -17
  147. package/dist/src/expr/integer.js +11 -11
  148. package/dist/src/expr/libs/array.d.ts +6 -6
  149. package/dist/src/expr/libs/array.js +6 -6
  150. package/dist/src/expr/libs/blob.d.ts +2 -2
  151. package/dist/src/expr/libs/blob.js +2 -2
  152. package/dist/src/expr/libs/datetime.d.ts +25 -25
  153. package/dist/src/expr/libs/datetime.js +25 -25
  154. package/dist/src/expr/libs/dict.d.ts +2 -2
  155. package/dist/src/expr/libs/dict.js +2 -2
  156. package/dist/src/expr/libs/float.d.ts +15 -15
  157. package/dist/src/expr/libs/float.js +15 -15
  158. package/dist/src/expr/libs/integer.d.ts +12 -12
  159. package/dist/src/expr/libs/integer.js +12 -12
  160. package/dist/src/expr/libs/set.d.ts +2 -2
  161. package/dist/src/expr/libs/set.js +2 -2
  162. package/dist/src/expr/libs/string.d.ts +4 -4
  163. package/dist/src/expr/libs/string.js +4 -4
  164. package/dist/src/expr/recursive.d.ts +22 -5
  165. package/dist/src/expr/recursive.d.ts.map +1 -1
  166. package/dist/src/expr/recursive.js +22 -5
  167. package/dist/src/expr/recursive.js.map +1 -1
  168. package/dist/src/expr/ref.d.ts +5 -5
  169. package/dist/src/expr/ref.js +5 -5
  170. package/dist/src/expr/set.d.ts +96 -51
  171. package/dist/src/expr/set.d.ts.map +1 -1
  172. package/dist/src/expr/set.js +85 -29
  173. package/dist/src/expr/set.js.map +1 -1
  174. package/dist/src/expr/string.d.ts +28 -28
  175. package/dist/src/expr/string.js +28 -28
  176. package/dist/src/expr/struct.d.ts.map +1 -1
  177. package/dist/src/expr/struct.js +2 -2
  178. package/dist/src/expr/variant.d.ts +12 -12
  179. package/dist/src/expr/variant.js +7 -7
  180. package/dist/src/function_symbols.d.ts +28 -0
  181. package/dist/src/function_symbols.d.ts.map +1 -0
  182. package/dist/src/function_symbols.js +28 -0
  183. package/dist/src/function_symbols.js.map +1 -0
  184. package/dist/src/index.d.ts +1 -0
  185. package/dist/src/index.d.ts.map +1 -1
  186. package/dist/src/index.js +1 -0
  187. package/dist/src/index.js.map +1 -1
  188. package/dist/src/location.d.ts +32 -0
  189. package/dist/src/location.d.ts.map +1 -1
  190. package/dist/src/location.js +38 -0
  191. package/dist/src/location.js.map +1 -1
  192. package/dist/src/location.spec.js +89 -1
  193. package/dist/src/location.spec.js.map +1 -1
  194. package/dist/src/patch/index.d.ts +1 -1
  195. package/dist/src/patch/index.d.ts.map +1 -1
  196. package/dist/src/patch/index.js +1 -1
  197. package/dist/src/patch/index.js.map +1 -1
  198. package/dist/src/patch/type_of_patch.d.ts +25 -1
  199. package/dist/src/patch/type_of_patch.d.ts.map +1 -1
  200. package/dist/src/patch/type_of_patch.js +33 -10
  201. package/dist/src/patch/type_of_patch.js.map +1 -1
  202. package/dist/src/platform.spec.js +19 -1
  203. package/dist/src/platform.spec.js.map +1 -1
  204. package/dist/src/runner_protocol.d.ts +357 -0
  205. package/dist/src/runner_protocol.d.ts.map +1 -0
  206. package/dist/src/runner_protocol.js +154 -0
  207. package/dist/src/runner_protocol.js.map +1 -0
  208. package/dist/src/serialization/beast2/index.d.ts +22 -5
  209. package/dist/src/serialization/beast2/index.d.ts.map +1 -1
  210. package/dist/src/serialization/beast2/index.js +13 -2
  211. package/dist/src/serialization/beast2/index.js.map +1 -1
  212. package/dist/src/serialization/beast2/index.spec.js +84 -3
  213. package/dist/src/serialization/beast2/index.spec.js.map +1 -1
  214. package/dist/src/serialization/beast2/shared.d.ts +32 -3
  215. package/dist/src/serialization/beast2/shared.d.ts.map +1 -1
  216. package/dist/src/serialization/beast2/shared.js +135 -10
  217. package/dist/src/serialization/beast2/shared.js.map +1 -1
  218. package/dist/src/serialization/beast2/v4/container.d.ts.map +1 -1
  219. package/dist/src/serialization/beast2/v4/container.js +5 -3
  220. package/dist/src/serialization/beast2/v4/container.js.map +1 -1
  221. package/dist/src/serialization/beast2/v5/aliasing.spec.d.ts +6 -0
  222. package/dist/src/serialization/beast2/v5/aliasing.spec.d.ts.map +1 -0
  223. package/dist/src/serialization/beast2/v5/aliasing.spec.js +75 -0
  224. package/dist/src/serialization/beast2/v5/aliasing.spec.js.map +1 -0
  225. package/dist/src/serialization/beast2/v5/boundary.d.ts +176 -0
  226. package/dist/src/serialization/beast2/v5/boundary.d.ts.map +1 -0
  227. package/dist/src/serialization/beast2/v5/boundary.js +297 -0
  228. package/dist/src/serialization/beast2/v5/boundary.js.map +1 -0
  229. package/dist/src/serialization/beast2/v5/boundary.spec.d.ts +6 -0
  230. package/dist/src/serialization/beast2/v5/boundary.spec.d.ts.map +1 -0
  231. package/dist/src/serialization/beast2/v5/boundary.spec.js +479 -0
  232. package/dist/src/serialization/beast2/v5/boundary.spec.js.map +1 -0
  233. package/dist/src/serialization/beast2/v5/canonical.d.ts +101 -0
  234. package/dist/src/serialization/beast2/v5/canonical.d.ts.map +1 -0
  235. package/dist/src/serialization/beast2/v5/canonical.js +436 -0
  236. package/dist/src/serialization/beast2/v5/canonical.js.map +1 -0
  237. package/dist/src/serialization/beast2/v5/canonical.spec.d.ts +6 -0
  238. package/dist/src/serialization/beast2/v5/canonical.spec.d.ts.map +1 -0
  239. package/dist/src/serialization/beast2/v5/canonical.spec.js +124 -0
  240. package/dist/src/serialization/beast2/v5/canonical.spec.js.map +1 -0
  241. package/dist/src/serialization/beast2/v5/codec.d.ts +6 -5
  242. package/dist/src/serialization/beast2/v5/codec.d.ts.map +1 -1
  243. package/dist/src/serialization/beast2/v5/codec.js +18 -3
  244. package/dist/src/serialization/beast2/v5/codec.js.map +1 -1
  245. package/dist/src/serialization/beast2/v5/deflate.d.ts +24 -2
  246. package/dist/src/serialization/beast2/v5/deflate.d.ts.map +1 -1
  247. package/dist/src/serialization/beast2/v5/deflate.js +47 -12
  248. package/dist/src/serialization/beast2/v5/deflate.js.map +1 -1
  249. package/dist/src/serialization/beast2/v5/deflate.spec.js +15 -1
  250. package/dist/src/serialization/beast2/v5/deflate.spec.js.map +1 -1
  251. package/dist/src/serialization/beast2/v5/elements.d.ts +66 -0
  252. package/dist/src/serialization/beast2/v5/elements.d.ts.map +1 -0
  253. package/dist/src/serialization/beast2/v5/elements.js +325 -0
  254. package/dist/src/serialization/beast2/v5/elements.js.map +1 -0
  255. package/dist/src/serialization/beast2/v5/elements.spec.d.ts +6 -0
  256. package/dist/src/serialization/beast2/v5/elements.spec.d.ts.map +1 -0
  257. package/dist/src/serialization/beast2/v5/elements.spec.js +161 -0
  258. package/dist/src/serialization/beast2/v5/elements.spec.js.map +1 -0
  259. package/dist/src/serialization/beast2/v5/frame-pool.d.ts +62 -21
  260. package/dist/src/serialization/beast2/v5/frame-pool.d.ts.map +1 -1
  261. package/dist/src/serialization/beast2/v5/frame-pool.js +138 -27
  262. package/dist/src/serialization/beast2/v5/frame-pool.js.map +1 -1
  263. package/dist/src/serialization/beast2/v5/frame-pool.spec.js +198 -71
  264. package/dist/src/serialization/beast2/v5/frame-pool.spec.js.map +1 -1
  265. package/dist/src/serialization/beast2/v5/frame-worker.js +25 -15
  266. package/dist/src/serialization/beast2/v5/frame-worker.js.map +1 -1
  267. package/dist/src/serialization/beast2/v5/frames.d.ts +22 -12
  268. package/dist/src/serialization/beast2/v5/frames.d.ts.map +1 -1
  269. package/dist/src/serialization/beast2/v5/frames.js +52 -27
  270. package/dist/src/serialization/beast2/v5/frames.js.map +1 -1
  271. package/dist/src/serialization/beast2/v5/geometry.d.ts +38 -1
  272. package/dist/src/serialization/beast2/v5/geometry.d.ts.map +1 -1
  273. package/dist/src/serialization/beast2/v5/geometry.js +73 -1
  274. package/dist/src/serialization/beast2/v5/geometry.js.map +1 -1
  275. package/dist/src/serialization/beast2/v5/geometry.spec.js +34 -23
  276. package/dist/src/serialization/beast2/v5/geometry.spec.js.map +1 -1
  277. package/dist/src/serialization/beast2/v5/index.spec.js +32 -28
  278. package/dist/src/serialization/beast2/v5/index.spec.js.map +1 -1
  279. package/dist/src/serialization/beast2/v5/intake.d.ts +98 -0
  280. package/dist/src/serialization/beast2/v5/intake.d.ts.map +1 -0
  281. package/dist/src/serialization/beast2/v5/intake.js +462 -0
  282. package/dist/src/serialization/beast2/v5/intake.js.map +1 -0
  283. package/dist/src/serialization/beast2/v5/intake.spec.d.ts +6 -0
  284. package/dist/src/serialization/beast2/v5/intake.spec.d.ts.map +1 -0
  285. package/dist/src/serialization/beast2/v5/intake.spec.js +202 -0
  286. package/dist/src/serialization/beast2/v5/intake.spec.js.map +1 -0
  287. package/dist/src/serialization/beast2/v5/lazy.d.ts +42 -1
  288. package/dist/src/serialization/beast2/v5/lazy.d.ts.map +1 -1
  289. package/dist/src/serialization/beast2/v5/lazy.js +143 -28
  290. package/dist/src/serialization/beast2/v5/lazy.js.map +1 -1
  291. package/dist/src/serialization/beast2/v5/lazy.spec.js +102 -24
  292. package/dist/src/serialization/beast2/v5/lazy.spec.js.map +1 -1
  293. package/dist/src/serialization/beast2/v5/manifest-writer.d.ts +110 -0
  294. package/dist/src/serialization/beast2/v5/manifest-writer.d.ts.map +1 -0
  295. package/dist/src/serialization/beast2/v5/manifest-writer.js +118 -0
  296. package/dist/src/serialization/beast2/v5/manifest-writer.js.map +1 -0
  297. package/dist/src/serialization/beast2/v5/manifest-writer.spec.d.ts +6 -0
  298. package/dist/src/serialization/beast2/v5/manifest-writer.spec.d.ts.map +1 -0
  299. package/dist/src/serialization/beast2/v5/manifest-writer.spec.js +207 -0
  300. package/dist/src/serialization/beast2/v5/manifest-writer.spec.js.map +1 -0
  301. package/dist/src/serialization/beast2/v5/manifest.d.ts +241 -0
  302. package/dist/src/serialization/beast2/v5/manifest.d.ts.map +1 -0
  303. package/dist/src/serialization/beast2/v5/manifest.js +233 -0
  304. package/dist/src/serialization/beast2/v5/manifest.js.map +1 -0
  305. package/dist/src/serialization/beast2/v5/merge.d.ts +93 -0
  306. package/dist/src/serialization/beast2/v5/merge.d.ts.map +1 -0
  307. package/dist/src/serialization/beast2/v5/merge.js +202 -0
  308. package/dist/src/serialization/beast2/v5/merge.js.map +1 -0
  309. package/dist/src/serialization/beast2/v5/merge.spec.d.ts +6 -0
  310. package/dist/src/serialization/beast2/v5/merge.spec.d.ts.map +1 -0
  311. package/dist/src/serialization/beast2/v5/merge.spec.js +118 -0
  312. package/dist/src/serialization/beast2/v5/merge.spec.js.map +1 -0
  313. package/dist/src/serialization/beast2/v5/recut.d.ts +143 -0
  314. package/dist/src/serialization/beast2/v5/recut.d.ts.map +1 -0
  315. package/dist/src/serialization/beast2/v5/recut.js +365 -0
  316. package/dist/src/serialization/beast2/v5/recut.js.map +1 -0
  317. package/dist/src/serialization/beast2/v5/recut.spec.d.ts +6 -0
  318. package/dist/src/serialization/beast2/v5/recut.spec.d.ts.map +1 -0
  319. package/dist/src/serialization/beast2/v5/recut.spec.js +215 -0
  320. package/dist/src/serialization/beast2/v5/recut.spec.js.map +1 -0
  321. package/dist/src/serialization/beast2/v5/runs.d.ts +148 -0
  322. package/dist/src/serialization/beast2/v5/runs.d.ts.map +1 -0
  323. package/dist/src/serialization/beast2/v5/runs.js +260 -0
  324. package/dist/src/serialization/beast2/v5/runs.js.map +1 -0
  325. package/dist/src/serialization/beast2/v5/runs.spec.d.ts +6 -0
  326. package/dist/src/serialization/beast2/v5/runs.spec.d.ts.map +1 -0
  327. package/dist/src/serialization/beast2/v5/runs.spec.js +182 -0
  328. package/dist/src/serialization/beast2/v5/runs.spec.js.map +1 -0
  329. package/dist/src/serialization/beast2/v5/sha256.d.ts +19 -0
  330. package/dist/src/serialization/beast2/v5/sha256.d.ts.map +1 -0
  331. package/dist/src/serialization/beast2/v5/sha256.js +103 -0
  332. package/dist/src/serialization/beast2/v5/sha256.js.map +1 -0
  333. package/dist/src/serialization/beast2/v5/sha256.spec.d.ts +6 -0
  334. package/dist/src/serialization/beast2/v5/sha256.spec.d.ts.map +1 -0
  335. package/dist/src/serialization/beast2/v5/sha256.spec.js +42 -0
  336. package/dist/src/serialization/beast2/v5/sha256.spec.js.map +1 -0
  337. package/dist/src/serialization/beast2/v5/stream.d.ts +273 -86
  338. package/dist/src/serialization/beast2/v5/stream.d.ts.map +1 -1
  339. package/dist/src/serialization/beast2/v5/stream.js +576 -244
  340. package/dist/src/serialization/beast2/v5/stream.js.map +1 -1
  341. package/dist/src/serialization/beast2/v5/sync-reader.spec.js +24 -10
  342. package/dist/src/serialization/beast2/v5/sync-reader.spec.js.map +1 -1
  343. package/dist/src/serialization/index.d.ts +1 -1
  344. package/dist/src/serialization/index.d.ts.map +1 -1
  345. package/dist/src/serialization/index.js +1 -1
  346. package/dist/src/serialization/index.js.map +1 -1
  347. package/dist/src/serialization/json.d.ts +28 -0
  348. package/dist/src/serialization/json.d.ts.map +1 -1
  349. package/dist/src/serialization/json.js +141 -30
  350. package/dist/src/serialization/json.js.map +1 -1
  351. package/dist/src/serialization/json.spec.js +47 -2
  352. package/dist/src/serialization/json.spec.js.map +1 -1
  353. package/dist/src/serialization/json_schema.d.ts +15 -11
  354. package/dist/src/serialization/json_schema.d.ts.map +1 -1
  355. package/dist/src/serialization/json_schema.js +21 -36
  356. package/dist/src/serialization/json_schema.js.map +1 -1
  357. package/dist/src/serialization/json_schema.spec.js +26 -32
  358. package/dist/src/serialization/json_schema.spec.js.map +1 -1
  359. package/dist/src/serialization/json_schema_to_type.d.ts +10 -5
  360. package/dist/src/serialization/json_schema_to_type.d.ts.map +1 -1
  361. package/dist/src/serialization/json_schema_to_type.js +13 -6
  362. package/dist/src/serialization/json_schema_to_type.js.map +1 -1
  363. package/dist/src/serialization/json_schema_to_type.spec.js +19 -0
  364. package/dist/src/serialization/json_schema_to_type.spec.js.map +1 -1
  365. package/dist/src/string_order.d.ts +36 -0
  366. package/dist/src/string_order.d.ts.map +1 -0
  367. package/dist/src/string_order.js +64 -0
  368. package/dist/src/string_order.js.map +1 -0
  369. package/dist/src/string_order.spec.d.ts +6 -0
  370. package/dist/src/string_order.spec.d.ts.map +1 -0
  371. package/dist/src/string_order.spec.js +79 -0
  372. package/dist/src/string_order.spec.js.map +1 -0
  373. package/dist/src/type_of_type.d.ts +17 -0
  374. package/dist/src/type_of_type.d.ts.map +1 -1
  375. package/dist/src/type_of_type.js +66 -0
  376. package/dist/src/type_of_type.js.map +1 -1
  377. package/dist/src/type_of_type.to_etv.spec.js +69 -1
  378. package/dist/src/type_of_type.to_etv.spec.js.map +1 -1
  379. package/package.json +1 -1
@@ -0,0 +1,436 @@
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
+ * Stepping over a value's v5 encoding without decoding it, and proving on the
7
+ * way that the bytes are the ones the Writer writes for the value they hold.
8
+ *
9
+ * Decoding a value and encoding it again gives its canonical bytes, but builds
10
+ * the value to do it. A reader that needs only where a value ends, and that its
11
+ * bytes are the Writer's, can step over them instead, holding each to what the
12
+ * encoder writes:
13
+ *
14
+ * - varints are minimal, and a length is a safe integer;
15
+ * - an Integer fits 64 bits, and a DateTime is a date a `Date` holds;
16
+ * - a Boolean is 0 or 1, and a NaN is the one NaN the encoder writes;
17
+ * - a String is well-formed UTF-8;
18
+ * - a Variant's case is one its type has;
19
+ * - a container's content is one run, and an alias names an earlier container
20
+ * of the same type within the root element;
21
+ * - a Set's elements and a Dict's keys strictly ascend.
22
+ *
23
+ * Whatever decodes but would encode otherwise — what decoding and encoding
24
+ * again would change — is refused. Only a Set's elements and a Dict's keys are
25
+ * decoded, to be ordered; they are of immutable types, so each decodes on its
26
+ * own. A function value is refused: its captures' types are known only once
27
+ * its IR is decoded.
28
+ *
29
+ * A lenient skipper holds bytes to what the decoder reads instead, where that
30
+ * is looser than what the Writer writes: a varint need not be minimal, a NaN
31
+ * may be the negative one, a container's content may come in several runs, and
32
+ * an alias may name a container of an earlier root element, when the caller
33
+ * shares one `defs` list across them. Bytes that pass it decode, and encoding
34
+ * what they decode to gives the Writer's bytes; everything else it refuses as
35
+ * the strict one does.
36
+ */
37
+ import { isTypeValueEqual } from "../../../type_of_type.js";
38
+ import { compareFor } from "../../../comparison.js";
39
+ import { asTypeValue } from "./type-section.js";
40
+ import { TAG_NEW, TAG_REF } from "./codec.js";
41
+ import { decodeBeast2FenceFor } from "./boundary.js";
42
+ /** Thrown where bytes are not the encoding the Writer writes — or, for a
43
+ * lenient skipper, not an encoding the decoder reads. */
44
+ export class Beast2NotCanonicalError extends Error {
45
+ /** What is wrong with the bytes, as a refusal names it. */
46
+ reason;
47
+ /**
48
+ * @param reason - what the Writer would not have written
49
+ */
50
+ constructor(reason) {
51
+ super(`beast2 v5: ${reason}`);
52
+ this.name = "Beast2NotCanonicalError";
53
+ this.reason = reason;
54
+ }
55
+ }
56
+ /** The largest zigzag form of a date a `Date` holds: 8.64e15 ms either side of
57
+ * the epoch. */
58
+ const DATE_ZIGZAG_MAX = 2n * 8640000000000000n;
59
+ /** The most elements a container of zero-width elements holds, as every
60
+ * decoder bounds it: a Null costs no bytes, so the bytes left bound nothing. */
61
+ const ZERO_WIDTH_MAX = 2 ** 28;
62
+ /** The most elements a container of zero-width elements holds, as every
63
+ * decoder bounds it. */
64
+ export const BEAST2_ZERO_WIDTH_MAX = ZERO_WIDTH_MAX;
65
+ /** Whether a value of `type` encodes to no bytes: Null, Never, and structs of
66
+ * them.
67
+ * @internal */
68
+ export function zeroWidth(type) {
69
+ if (type.type === "Null" || type.type === "Never")
70
+ return true;
71
+ return type.type === "Struct" && type.value.every((field) => zeroWidth(field.type));
72
+ }
73
+ function refuse(reason) {
74
+ throw new Beast2NotCanonicalError(reason);
75
+ }
76
+ /**
77
+ * Reads a varint the Writer writes: minimal, and no larger than a safe integer.
78
+ *
79
+ * @param reader - positioned at the varint
80
+ * @param what - what the varint is, for the refusal
81
+ * @param lenient - whether a varint that is not minimal reads
82
+ * @returns its value
83
+ * @throws {Beast2NotCanonicalError} When it is not minimal, too large, or
84
+ * runs past the bytes.
85
+ */
86
+ export function canonicalVarint(reader, what, lenient = false) {
87
+ const buf = reader.buffer;
88
+ let off = reader.offset;
89
+ let value = 0;
90
+ let scale = 1;
91
+ for (let i = 0;; i++) {
92
+ if (off >= buf.length)
93
+ refuse(`${what} runs past the end of its bytes`);
94
+ const byte = buf[off++];
95
+ value += (byte & 0x7f) * scale;
96
+ if ((byte & 0x80) === 0) {
97
+ if (byte === 0 && i > 0 && !lenient)
98
+ refuse(`${what} is not a minimal varint`);
99
+ break;
100
+ }
101
+ if (i === 7)
102
+ refuse(`${what} is larger than a safe integer`);
103
+ scale *= 128;
104
+ }
105
+ if (value > Number.MAX_SAFE_INTEGER)
106
+ refuse(`${what} is larger than a safe integer`);
107
+ reader.offset = off;
108
+ return value;
109
+ }
110
+ /** Steps over `length` bytes. */
111
+ function bytes(reader, length, what) {
112
+ if (reader.offset + length > reader.buffer.length)
113
+ refuse(`${what} runs past the end of its bytes`);
114
+ reader.offset += length;
115
+ }
116
+ /** An Integer: a minimal zigzag varint of 64 bits at most. Ten bytes carry
117
+ * bits 63 and up in the last, which 64 bits leave 1 — or, lenient, 0 too,
118
+ * when the varint is padded. */
119
+ function integer(reader, lenient) {
120
+ const buf = reader.buffer;
121
+ let off = reader.offset;
122
+ for (let i = 0;; i++) {
123
+ if (off >= buf.length)
124
+ refuse("an Integer runs past the end of its bytes");
125
+ const byte = buf[off++];
126
+ if ((byte & 0x80) === 0) {
127
+ if (byte === 0 && i > 0 && !lenient)
128
+ refuse("an Integer is not a minimal varint");
129
+ if (i === 9 && byte > 1)
130
+ refuse("an Integer is larger than 64 bits");
131
+ break;
132
+ }
133
+ if (i === 9)
134
+ refuse("an Integer is larger than 64 bits");
135
+ }
136
+ reader.offset = off;
137
+ }
138
+ /** A DateTime: a zigzag varint of the milliseconds of a date a `Date` holds.
139
+ * Seven bytes or fewer always are one; more are measured. */
140
+ function dateTime(reader, lenient) {
141
+ const start = reader.offset;
142
+ integer(reader, lenient);
143
+ const length = reader.offset - start;
144
+ if (length < 8)
145
+ return;
146
+ let zigzag = 0n;
147
+ for (let i = length - 1; i >= 0; i--)
148
+ zigzag = (zigzag << 7n) | BigInt(reader.buffer[start + i] & 0x7f);
149
+ if (zigzag > DATE_ZIGZAG_MAX)
150
+ refuse("a DateTime is outside the dates a Date holds");
151
+ }
152
+ /** A Float: any 64 bits but a NaN other than the encoder's,
153
+ * `0x7FF8000000000000` — or, lenient, the negative one the decoder also
154
+ * reads, `0xFFF8000000000000`. */
155
+ function float(reader, lenient) {
156
+ const buf = reader.buffer;
157
+ const off = reader.offset;
158
+ if (off + 8 > buf.length)
159
+ refuse("a Float runs past the end of its bytes");
160
+ const top = buf[off + 7];
161
+ const next = buf[off + 6];
162
+ if ((top & 0x7f) === 0x7f && (next & 0xf0) === 0xf0) {
163
+ const low = (buf[off] | buf[off + 1] | buf[off + 2] | buf[off + 3] | buf[off + 4] | buf[off + 5]) === 0;
164
+ const infinite = low && (next & 0x0f) === 0;
165
+ const writers = low && next === 0xf8 && (top === 0x7f || (lenient && top === 0xff));
166
+ if (!infinite && !writers)
167
+ refuse("a Float is a NaN other than the one the Writer writes");
168
+ }
169
+ reader.offset = off + 8;
170
+ }
171
+ /** A String: a length, then that many bytes of well-formed UTF-8 — no overlong
172
+ * form, surrogate or code point past U+10FFFF, each of which a decode
173
+ * replaces and an encode then writes otherwise. */
174
+ function string(reader, lenient) {
175
+ const length = canonicalVarint(reader, "a String's length", lenient);
176
+ const buf = reader.buffer;
177
+ let off = reader.offset;
178
+ const end = off + length;
179
+ if (end > buf.length)
180
+ refuse("a String runs past the end of its bytes");
181
+ while (off < end) {
182
+ const lead = buf[off];
183
+ if (lead < 0x80) {
184
+ off++;
185
+ continue;
186
+ }
187
+ // The well-formed sequences: the second byte's range turns on the lead.
188
+ let follow;
189
+ let low = 0x80;
190
+ let high = 0xbf;
191
+ if (lead >= 0xc2 && lead <= 0xdf)
192
+ follow = 1;
193
+ else if (lead === 0xe0) {
194
+ follow = 2;
195
+ low = 0xa0;
196
+ }
197
+ else if ((lead >= 0xe1 && lead <= 0xec) || lead === 0xee || lead === 0xef)
198
+ follow = 2;
199
+ else if (lead === 0xed) {
200
+ follow = 2;
201
+ high = 0x9f;
202
+ }
203
+ else if (lead === 0xf0) {
204
+ follow = 3;
205
+ low = 0x90;
206
+ }
207
+ else if (lead >= 0xf1 && lead <= 0xf3)
208
+ follow = 3;
209
+ else if (lead === 0xf4) {
210
+ follow = 3;
211
+ high = 0x8f;
212
+ }
213
+ else
214
+ refuse("a String is not well-formed UTF-8");
215
+ if (off + follow >= end)
216
+ refuse("a String is not well-formed UTF-8");
217
+ const second = buf[off + 1];
218
+ if (second < low || second > high)
219
+ refuse("a String is not well-formed UTF-8");
220
+ for (let k = 2; k <= follow; k++) {
221
+ const byte = buf[off + k];
222
+ if (byte < 0x80 || byte > 0xbf)
223
+ refuse("a String is not well-formed UTF-8");
224
+ }
225
+ off += follow + 1;
226
+ }
227
+ reader.offset = end;
228
+ }
229
+ /**
230
+ * A mutable container's tag: `NEW`, whose content follows, recorded as a
231
+ * definition of `type`; or `REF` to an earlier definition of the same type in
232
+ * `defs`.
233
+ *
234
+ * @returns whether the container's content follows
235
+ */
236
+ function container(reader, defs, type, lenient) {
237
+ const buf = reader.buffer;
238
+ if (reader.offset >= buf.length)
239
+ refuse("a container runs past the end of its bytes");
240
+ const tag = buf[reader.offset++];
241
+ if (tag === TAG_NEW) {
242
+ defs.push(type);
243
+ return true;
244
+ }
245
+ if (tag !== TAG_REF)
246
+ refuse(`a container's tag is 0x${tag.toString(16)}, neither NEW nor REF`);
247
+ const delta = canonicalVarint(reader, "a container alias", lenient);
248
+ if (delta < 1 || delta > defs.length) {
249
+ refuse(lenient ? "a container alias reaches outside its segment" : "a container alias reaches outside its root element");
250
+ }
251
+ const target = defs[defs.length - delta];
252
+ if (target !== type && !isTypeValueEqual(target, type))
253
+ refuse("a container alias names a container of another type");
254
+ return false;
255
+ }
256
+ /** A container's content: `varint(0)` when empty, else `varint(n)`, the n
257
+ * elements, and `varint(0)` — one run, as the encoder writes it; lenient,
258
+ * any number of runs before the `varint(0)`. Each element is given its index
259
+ * in the content. `zero` says the elements encode to no bytes, whose count
260
+ * is bounded as every decoder bounds it. */
261
+ function run(reader, what, lenient, zero, element) {
262
+ let index = 0;
263
+ for (;;) {
264
+ const n = canonicalVarint(reader, index === 0 ? `${what}'s length` : `${what}'s end`, lenient);
265
+ if (n === 0)
266
+ return;
267
+ if (index > 0 && !lenient)
268
+ refuse(`${what}'s elements are not written in one run`);
269
+ if (zero && index + n > ZERO_WIDTH_MAX)
270
+ refuse(`${what} holds more elements than a reader takes`);
271
+ for (let i = 0; i < n; i++)
272
+ element(index++);
273
+ }
274
+ }
275
+ /**
276
+ * Builds the {@link CanonicalSkipper} for a type.
277
+ *
278
+ * @param type - the type of the values to step over
279
+ * @param options - whether the skipper is lenient
280
+ * @returns the skipper
281
+ *
282
+ * @example
283
+ * ```ts
284
+ * const bytes = encodeBeast2FenceFor(StringType)("key");
285
+ * const reader = new BufferReader(bytes, 0);
286
+ * canonicalSkipperFor(StringType)(reader, []);
287
+ * // reader.offset === bytes.length
288
+ * ```
289
+ */
290
+ export function canonicalSkipperFor(type, options) {
291
+ return build(asTypeValue(type), new Map(), options?.lenient ?? false);
292
+ }
293
+ function build(type, recursive, lenient) {
294
+ switch (type.type) {
295
+ case "Never":
296
+ return () => refuse("a value of type Never");
297
+ case "Null":
298
+ return () => { };
299
+ case "Boolean":
300
+ return (reader) => {
301
+ if (reader.offset >= reader.buffer.length)
302
+ refuse("a Boolean runs past the end of its bytes");
303
+ if (reader.buffer[reader.offset++] > 1)
304
+ refuse("a Boolean is neither 0 nor 1");
305
+ };
306
+ case "Integer":
307
+ return (reader) => integer(reader, lenient);
308
+ case "Float":
309
+ return (reader) => float(reader, lenient);
310
+ case "String":
311
+ return (reader) => string(reader, lenient);
312
+ case "DateTime":
313
+ return (reader) => dateTime(reader, lenient);
314
+ case "Blob":
315
+ return (reader) => bytes(reader, canonicalVarint(reader, "a Blob's length", lenient), "a Blob");
316
+ case "Vector": {
317
+ const width = type.value.type === "Boolean" ? 1 : 8;
318
+ return (reader) => {
319
+ const length = canonicalVarint(reader, "a Vector's length", lenient);
320
+ if (length > (reader.buffer.length - reader.offset) / width)
321
+ refuse("a Vector runs past the end of its bytes");
322
+ bytes(reader, length * width, "a Vector");
323
+ };
324
+ }
325
+ case "Matrix": {
326
+ const width = type.value.type === "Boolean" ? 1 : 8;
327
+ return (reader) => {
328
+ const rows = canonicalVarint(reader, "a Matrix's rows", lenient);
329
+ const cols = canonicalVarint(reader, "a Matrix's columns", lenient);
330
+ if (rows > 0 && cols > (reader.buffer.length - reader.offset) / width / rows)
331
+ refuse("a Matrix runs past the end of its bytes");
332
+ bytes(reader, rows * cols * width, "a Matrix");
333
+ };
334
+ }
335
+ case "Array": {
336
+ let element;
337
+ const zero = zeroWidth(type.value);
338
+ const skip = (reader, defs) => {
339
+ if (container(reader, defs, type, lenient))
340
+ run(reader, "an Array", lenient, zero, () => element(reader, defs));
341
+ };
342
+ element = build(type.value, recursive, lenient);
343
+ return skip;
344
+ }
345
+ case "Set": {
346
+ let element;
347
+ const decode = decodeBeast2FenceFor(type.value);
348
+ const cmp = compareFor(type.value);
349
+ const zero = zeroWidth(type.value);
350
+ const skip = (reader, defs) => {
351
+ if (!container(reader, defs, type, lenient))
352
+ return;
353
+ let previous;
354
+ run(reader, "a Set", lenient, zero, (index) => {
355
+ const start = reader.offset;
356
+ element(reader, defs);
357
+ const value = decode(reader.buffer.subarray(start, reader.offset));
358
+ if (index > 0 && cmp(previous, value) >= 0)
359
+ refuse("a Set's elements do not strictly ascend");
360
+ previous = value;
361
+ });
362
+ };
363
+ element = build(type.value, recursive, lenient);
364
+ return skip;
365
+ }
366
+ case "Dict": {
367
+ let key;
368
+ let value;
369
+ const decode = decodeBeast2FenceFor(type.value.key);
370
+ const cmp = compareFor(type.value.key);
371
+ const zero = zeroWidth(type.value.key) && zeroWidth(type.value.value);
372
+ const skip = (reader, defs) => {
373
+ if (!container(reader, defs, type, lenient))
374
+ return;
375
+ let previous;
376
+ run(reader, "a Dict", lenient, zero, (index) => {
377
+ const start = reader.offset;
378
+ key(reader, defs);
379
+ const k = decode(reader.buffer.subarray(start, reader.offset));
380
+ if (index > 0 && cmp(previous, k) >= 0)
381
+ refuse("a Dict's keys do not strictly ascend");
382
+ previous = k;
383
+ value(reader, defs);
384
+ });
385
+ };
386
+ key = build(type.value.key, recursive, lenient);
387
+ value = build(type.value.value, recursive, lenient);
388
+ return skip;
389
+ }
390
+ case "Ref": {
391
+ let inner;
392
+ const skip = (reader, defs) => {
393
+ if (container(reader, defs, type, lenient))
394
+ inner(reader, defs);
395
+ };
396
+ inner = build(type.value, recursive, lenient);
397
+ return skip;
398
+ }
399
+ case "Struct": {
400
+ const fields = type.value.map((field) => build(field.type, recursive, lenient));
401
+ return (reader, defs) => {
402
+ for (const field of fields)
403
+ field(reader, defs);
404
+ };
405
+ }
406
+ case "Variant": {
407
+ const cases = type.value.map((c) => build(c.type, recursive, lenient));
408
+ return (reader, defs) => {
409
+ const tag = canonicalVarint(reader, "a Variant's case", lenient);
410
+ if (tag >= cases.length)
411
+ refuse(`a Variant's case ${tag} is not one of its ${cases.length}`);
412
+ cases[tag](reader, defs);
413
+ };
414
+ }
415
+ case "Recursive": {
416
+ const node = type.value;
417
+ if (node.type === "wrapper") {
418
+ let inner;
419
+ const skip = (reader, defs) => inner(reader, defs);
420
+ recursive.set(node.value.id, skip);
421
+ inner = build(node.value.inner, recursive, lenient);
422
+ return skip;
423
+ }
424
+ const target = recursive.get(node.value);
425
+ if (target === undefined)
426
+ throw new Error("beast2 v5: a recursive type refers to one not being built");
427
+ return target;
428
+ }
429
+ case "Function":
430
+ case "AsyncFunction":
431
+ return () => refuse("a function value, whose captures' types only its decoded IR says");
432
+ default:
433
+ throw new Error(`beast2 v5: unknown type ${type.type}`);
434
+ }
435
+ }
436
+ //# sourceMappingURL=canonical.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"canonical.js","sourceRoot":"","sources":["../../../../../src/serialization/beast2/v5/canonical.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,EA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AAC,KAAK,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;gBACpD,OAAO,IAAI,CAAC;YACd,CAAC;YACD,MAAM,MAAM,GAAG,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACzC,IAAI,MAAM,KAAK,SAAS;gBAAE,MAAM,IAAI,KAAK,CAAC,2DAA2D,CAAC,CAAC;YACvG,OAAO,MAAM,CAAC;QAChB,CAAC;QACD,KAAK,UAAU,CAAC;QAChB,KAAK,eAAe;YAClB,OAAO,GAAG,EAAE,CAAC,MAAM,CAAC,kEAAkE,CAAC,CAAC;QAC1F;YACE,MAAM,IAAI,KAAK,CAAC,2BAA4B,IAAyB,CAAC,IAAI,EAAE,CAAC,CAAC;IAClF,CAAC;AACH,CAAC"}
@@ -0,0 +1,6 @@
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
+ export {};
6
+ //# sourceMappingURL=canonical.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"canonical.spec.d.ts","sourceRoot":"","sources":["../../../../../src/serialization/beast2/v5/canonical.spec.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
@@ -0,0 +1,124 @@
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
+ * The canonical skipper, held to the encoder: it steps over exactly what the
7
+ * encoder writes for any value, aliasing among its containers included, and
8
+ * refuses what a decoder reads but the encoder would never write. The lenient
9
+ * one steps over what the decoder reads, too.
10
+ */
11
+ import { describe, test } from "node:test";
12
+ import assert from "node:assert/strict";
13
+ import { ArrayType, BooleanType, DateTimeType, DictType, FloatType, FunctionType, IntegerType, NullType, RefType, SetType, StringType, StructType, VariantType, } from "../../../types.js";
14
+ import { ref } from "../../../containers/ref.js";
15
+ import { generateFuzzValues } from "../../../fuzz.js";
16
+ import { BufferReader, BufferWriter } from "../../binary-utils.js";
17
+ import { encodeBeast2FenceFor } from "./boundary.js";
18
+ import { Beast2NotCanonicalError, canonicalSkipperFor, canonicalVarint } from "./canonical.js";
19
+ /** Where the skipper leaves a reader over `bytes`, or its refusal. */
20
+ function skip(type, bytes) {
21
+ const reader = new BufferReader(bytes, 0);
22
+ canonicalSkipperFor(type)(reader, []);
23
+ return reader.offset;
24
+ }
25
+ /** Bytes written with a writer's own calls. */
26
+ function bytesOf(write) {
27
+ const writer = new BufferWriter();
28
+ write(writer);
29
+ return writer.toUint8Array().slice();
30
+ }
31
+ describe("canonicalSkipperFor", () => {
32
+ test("steps over exactly what the encoder writes, for every random type", () => {
33
+ const cases = generateFuzzValues({ numTypes: 120, numSamples: 6, seed: 0xca70, includeFunctions: false, nestedRecursive: true, includeTypeValues: true });
34
+ assert.ok(cases.length >= 100, `the fuzz made ${cases.length} types`);
35
+ for (const c of cases) {
36
+ const encode = encodeBeast2FenceFor(c.type);
37
+ for (const value of c.values) {
38
+ const bytes = encode(value);
39
+ assert.equal(skip(c.type, bytes), bytes.length, `${c.typeName}: every byte of the value, and no more`);
40
+ }
41
+ }
42
+ });
43
+ test("steps over a value whose containers alias one another, as the encoder writes them", () => {
44
+ const Pair = StructType({ left: ArrayType(IntegerType), right: ArrayType(IntegerType) });
45
+ const shared = [1n, 2n];
46
+ const pair = encodeBeast2FenceFor(Pair)({ left: shared, right: shared });
47
+ assert.equal(skip(Pair, pair), pair.length);
48
+ const Cells = StructType({ x: RefType(IntegerType), y: RefType(IntegerType) });
49
+ const cell = ref(7n);
50
+ const cells = encodeBeast2FenceFor(Cells)({ x: cell, y: cell });
51
+ assert.equal(skip(Cells, cells), cells.length);
52
+ });
53
+ test("refuses what a decoder reads but the encoder would never write", () => {
54
+ const refused = (type, bytes, message) => {
55
+ assert.throws(() => skip(type, bytes), (err) => err instanceof Beast2NotCanonicalError && message.test(err.message));
56
+ };
57
+ // 5 is zigzag 10: one byte, 0x0A — not 0x8A 0x00.
58
+ refused(IntegerType, new Uint8Array([0x8a, 0x00]), /an Integer is not a minimal varint/);
59
+ refused(IntegerType, new Uint8Array([0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x02]), /an Integer is larger than 64 bits/);
60
+ refused(BooleanType, new Uint8Array([0x02]), /a Boolean is neither 0 nor 1/);
61
+ // U+0000 as two bytes, a surrogate, a code point past U+10FFFF, a lone continuation.
62
+ refused(StringType, new Uint8Array([0x02, 0xc0, 0x80]), /a String is not well-formed UTF-8/);
63
+ refused(StringType, new Uint8Array([0x03, 0xed, 0xa0, 0x80]), /a String is not well-formed UTF-8/);
64
+ refused(StringType, new Uint8Array([0x04, 0xf4, 0x90, 0x80, 0x80]), /a String is not well-formed UTF-8/);
65
+ refused(StringType, new Uint8Array([0x01, 0x80]), /a String is not well-formed UTF-8/);
66
+ // The encoder writes 0x7FF8000000000000 for every NaN.
67
+ refused(FloatType, new Uint8Array([0, 0, 0, 0, 0, 0, 0xf8, 0xff]), /a NaN other than the one the Writer writes/);
68
+ refused(FloatType, new Uint8Array([1, 0, 0, 0, 0, 0, 0xf0, 0x7f]), /a NaN other than the one the Writer writes/);
69
+ // 8.64e15 ms is the last date a Date holds.
70
+ refused(DateTimeType, bytesOf((w) => w.writeZigzag(8640000000000001n)), /a DateTime is outside the dates a Date holds/);
71
+ // [1, 2] as two runs, where the encoder writes one.
72
+ refused(ArrayType(IntegerType), new Uint8Array([0x00, 0x01, 0x02, 0x01, 0x04, 0x00]), /an Array's elements are not written in one run/);
73
+ refused(SetType(StringType), bytesOf((w) => { w.writeUint8(0); w.writeVarint(2); w.writeStringUtf8Varint("b"); w.writeStringUtf8Varint("a"); w.writeVarint(0); }), /a Set's elements do not strictly ascend/);
74
+ refused(DictType(StringType, IntegerType), bytesOf((w) => { w.writeUint8(0); w.writeVarint(2); w.writeStringUtf8Varint("a"); w.writeZigzag(1n); w.writeStringUtf8Varint("a"); w.writeZigzag(2n); w.writeVarint(0); }), /a Dict's keys do not strictly ascend/);
75
+ // `right` aliases `left`, an Array of another type.
76
+ refused(StructType({ left: ArrayType(IntegerType), right: ArrayType(StringType) }), new Uint8Array([0x00, 0x01, 0x02, 0x00, 0x01, 0x01]), /a container alias names a container of another type/);
77
+ // An alias to a container before the value's own.
78
+ refused(ArrayType(IntegerType), new Uint8Array([0x01, 0x01]), /a container alias reaches outside its root element/);
79
+ refused(ArrayType(IntegerType), new Uint8Array([0x02]), /a container's tag is 0x2, neither NEW nor REF/);
80
+ // Nulls cost no bytes, so their count is bounded as every decoder bounds it.
81
+ refused(ArrayType(NullType), bytesOf((w) => { w.writeUint8(0); w.writeVarint(2 ** 28 + 1); w.writeVarint(0); }), /an Array holds more elements than a reader takes/);
82
+ refused(VariantType({ a: IntegerType, b: StringType }), new Uint8Array([0x02]), /a Variant's case 2 is not one of its 2/);
83
+ refused(FunctionType([], IntegerType), new Uint8Array([0x00]), /a function value/);
84
+ });
85
+ test("a lenient skipper reads what the decoder reads, and refuses the rest as the strict one does", () => {
86
+ const lenient = (type, bytes, defs = []) => {
87
+ const reader = new BufferReader(bytes, 0);
88
+ canonicalSkipperFor(type, { lenient: true })(reader, defs);
89
+ return reader.offset;
90
+ };
91
+ const refused = (type, bytes, message) => {
92
+ assert.throws(() => lenient(type, bytes), (err) => err instanceof Beast2NotCanonicalError && message.test(err.message));
93
+ };
94
+ // Varints that are not minimal, padded to ten bytes for an Integer.
95
+ assert.equal(lenient(IntegerType, new Uint8Array([0x8a, 0x00])), 2);
96
+ assert.equal(lenient(IntegerType, new Uint8Array([0x8a, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00])), 10);
97
+ assert.equal(lenient(StringType, new Uint8Array([0x81, 0x00, 0x61])), 3);
98
+ // A DateTime padded past eight bytes is measured, not refused by length.
99
+ assert.equal(lenient(DateTimeType, new Uint8Array([0x82, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00])), 9);
100
+ // The negative NaN, which the decoder reads as NaN.
101
+ assert.equal(lenient(FloatType, new Uint8Array([0, 0, 0, 0, 0, 0, 0xf8, 0xff])), 8);
102
+ // [1, 2] as two runs.
103
+ assert.equal(lenient(ArrayType(IntegerType), new Uint8Array([0x00, 0x01, 0x02, 0x01, 0x04, 0x00])), 6);
104
+ // An alias into an earlier row, when the rows share their definitions.
105
+ const shared = [];
106
+ assert.equal(lenient(ArrayType(IntegerType), new Uint8Array([0x00, 0x01, 0x02, 0x00]), shared), 4);
107
+ assert.equal(lenient(ArrayType(IntegerType), new Uint8Array([0x01, 0x01]), shared), 2);
108
+ refused(ArrayType(IntegerType), new Uint8Array([0x01, 0x01]), /a container alias reaches outside its segment/);
109
+ refused(FloatType, new Uint8Array([1, 0, 0, 0, 0, 0, 0xf0, 0x7f]), /a NaN other than the one the Writer writes/);
110
+ refused(BooleanType, new Uint8Array([0x02]), /a Boolean is neither 0 nor 1/);
111
+ refused(StringType, new Uint8Array([0x01, 0x80]), /a String is not well-formed UTF-8/);
112
+ refused(IntegerType, new Uint8Array([0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x02]), /an Integer is larger than 64 bits/);
113
+ refused(DateTimeType, bytesOf((w) => w.writeZigzag(8640000000000001n)), /a DateTime is outside the dates a Date holds/);
114
+ refused(SetType(StringType), bytesOf((w) => { w.writeUint8(0); w.writeVarint(1); w.writeStringUtf8Varint("b"); w.writeVarint(1); w.writeStringUtf8Varint("a"); w.writeVarint(0); }), /a Set's elements do not strictly ascend/);
115
+ });
116
+ test("reads a varint only as the encoder writes it", () => {
117
+ assert.equal(canonicalVarint(new BufferReader(new Uint8Array([0x7f]), 0), "a length"), 127);
118
+ assert.equal(canonicalVarint(new BufferReader(bytesOf((w) => w.writeVarint(Number.MAX_SAFE_INTEGER)), 0), "a length"), Number.MAX_SAFE_INTEGER);
119
+ assert.throws(() => canonicalVarint(new BufferReader(new Uint8Array([0xff, 0x00]), 0), "a length"), /a length is not a minimal varint/);
120
+ assert.throws(() => canonicalVarint(new BufferReader(new Uint8Array([0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x01]), 0), "a length"), /larger than a safe integer/);
121
+ assert.throws(() => canonicalVarint(new BufferReader(new Uint8Array([0x80]), 0), "a length"), /a length runs past the end of its bytes/);
122
+ });
123
+ });
124
+ //# sourceMappingURL=canonical.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"canonical.spec.js","sourceRoot":"","sources":["../../../../../src/serialization/beast2/v5/canonical.spec.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;GAKG;AAEH,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,EACL,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAC5H,UAAU,EAAE,WAAW,GACxB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,GAAG,EAAE,MAAM,4BAA4B,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAE/F,sEAAsE;AACtE,SAAS,IAAI,CAAC,IAAc,EAAE,KAAiB;IAC7C,MAAM,MAAM,GAAG,IAAI,YAAY,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IAC1C,mBAAmB,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IACtC,OAAO,MAAM,CA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AE,GAAG,CAAC,CAAC;QAC5F,MAAM,CAAC,KAAK,CAAC,eAAe,CAAC,IAAI,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,UAAU,CAAC,EAAE,MAAM,CAAC,gBAAgB,CAAC,CAAC;QAChJ,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,eAAe,CAAC,IAAI,YAAY,CAAC,IAAI,UAAU,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,UAAU,CAAC,EAAE,kCAAkC,CAAC,CAAC;QACxI,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,eAAe,CAAC,IAAI,YAAY,CAAC,IAAI,UAAU,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,UAAU,CAAC,EAAE,4BAA4B,CAAC,CAAC;QAC5K,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,eAAe,CAAC,IAAI,YAAY,CAAC,IAAI,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,UAAU,CAAC,EAAE,yCAAyC,CAAC,CAAC;IAC3I,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -52,13 +52,13 @@ export declare const TAG_NEW = 0;
52
52
  export declare const TAG_REF = 1;
53
53
  /** Mutable state threaded through a v5 encode pass. */
54
54
  export interface V5EncodeContext {
55
- /** Identity map: container object → definition index. Cleared per root
56
- * segment by self-contained writers. */
55
+ /** Identity map: container object → definition index. Cleared at every root
56
+ * element of a segmented collection, so no REF reaches past its element. */
57
57
  containerIndex: Map<any, number>;
58
58
  /** Count of container definitions so far (the definition counter). */
59
59
  containerCount: number;
60
- /** Definition count at the start of the current root segment — REFs
61
- * reaching below this mark are cross-segment aliases. */
60
+ /** Definition count at the start of the current root element — REFs
61
+ * reaching below this mark would alias across elements. */
62
62
  segmentBaseDef: number;
63
63
  /** Whether any REF crossed a root-segment boundary. */
64
64
  crossSegmentRef: boolean;
@@ -75,7 +75,8 @@ export interface V5EncodeContext {
75
75
  /** Creates a fresh v5 encode context.
76
76
  *
77
77
  * @param sourceMap - the pre-resolved header source map, if any
78
- * @param selfContained - whether the writer scopes aliasing per segment
78
+ * @param selfContained - whether the writer's segments must decode on their
79
+ * own, which forbids inline source-map growth
79
80
  * @returns the initialized context
80
81
  */
81
82
  export declare function createV5EncodeContext(sourceMap: SourceMap | null, selfContained: boolean): V5EncodeContext;