@blade-hq/agent-client 1.1.1 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (583) hide show
  1. package/README.md +48 -25
  2. package/dist/blade-client.d.ts +2 -14
  3. package/dist/index.d.ts +5 -2
  4. package/dist/index.js +212 -106
  5. package/dist/index.js.map +1 -1
  6. package/dist/resources/models.d.ts +15 -0
  7. package/dist/resources/sessions.d.ts +8 -1
  8. package/dist/session/agent-session.d.ts +10 -0
  9. package/dist/session/definition.d.ts +49 -0
  10. package/dist/shared/projection/helpers.d.ts +1 -1
  11. package/dist/types/rest.d.ts +378 -10
  12. package/dist/version.d.ts +4 -42
  13. package/node_modules/@ark/schema/LICENSE +7 -0
  14. package/node_modules/@ark/schema/README.md +18 -0
  15. package/node_modules/@ark/schema/out/config.d.ts +58 -0
  16. package/node_modules/@ark/schema/out/config.js +95 -0
  17. package/node_modules/@ark/schema/out/constraint.d.ts +67 -0
  18. package/node_modules/@ark/schema/out/constraint.js +136 -0
  19. package/node_modules/@ark/schema/out/generic.d.ts +73 -0
  20. package/node_modules/@ark/schema/out/generic.js +76 -0
  21. package/node_modules/@ark/schema/out/index.d.ts +47 -0
  22. package/node_modules/@ark/schema/out/index.js +47 -0
  23. package/node_modules/@ark/schema/out/intrinsic.d.ts +24 -0
  24. package/node_modules/@ark/schema/out/intrinsic.js +56 -0
  25. package/node_modules/@ark/schema/out/kinds.d.ts +73 -0
  26. package/node_modules/@ark/schema/out/kinds.js +71 -0
  27. package/node_modules/@ark/schema/out/module.d.ts +24 -0
  28. package/node_modules/@ark/schema/out/module.js +15 -0
  29. package/node_modules/@ark/schema/out/node.d.ts +154 -0
  30. package/node_modules/@ark/schema/out/node.js +438 -0
  31. package/node_modules/@ark/schema/out/parse.d.ts +52 -0
  32. package/node_modules/@ark/schema/out/parse.js +215 -0
  33. package/node_modules/@ark/schema/out/predicate.d.ts +52 -0
  34. package/node_modules/@ark/schema/out/predicate.js +63 -0
  35. package/node_modules/@ark/schema/out/refinements/after.d.ts +41 -0
  36. package/node_modules/@ark/schema/out/refinements/after.js +35 -0
  37. package/node_modules/@ark/schema/out/refinements/before.d.ts +41 -0
  38. package/node_modules/@ark/schema/out/refinements/before.js +41 -0
  39. package/node_modules/@ark/schema/out/refinements/divisor.d.ts +43 -0
  40. package/node_modules/@ark/schema/out/refinements/divisor.js +58 -0
  41. package/node_modules/@ark/schema/out/refinements/exactLength.d.ts +49 -0
  42. package/node_modules/@ark/schema/out/refinements/exactLength.js +55 -0
  43. package/node_modules/@ark/schema/out/refinements/kinds.d.ts +34 -0
  44. package/node_modules/@ark/schema/out/refinements/kinds.js +25 -0
  45. package/node_modules/@ark/schema/out/refinements/max.d.ts +37 -0
  46. package/node_modules/@ark/schema/out/refinements/max.js +45 -0
  47. package/node_modules/@ark/schema/out/refinements/maxLength.d.ts +40 -0
  48. package/node_modules/@ark/schema/out/refinements/maxLength.js +49 -0
  49. package/node_modules/@ark/schema/out/refinements/min.d.ts +37 -0
  50. package/node_modules/@ark/schema/out/refinements/min.js +39 -0
  51. package/node_modules/@ark/schema/out/refinements/minLength.d.ts +40 -0
  52. package/node_modules/@ark/schema/out/refinements/minLength.js +47 -0
  53. package/node_modules/@ark/schema/out/refinements/pattern.d.ts +43 -0
  54. package/node_modules/@ark/schema/out/refinements/pattern.js +52 -0
  55. package/node_modules/@ark/schema/out/refinements/range.d.ts +106 -0
  56. package/node_modules/@ark/schema/out/refinements/range.js +103 -0
  57. package/node_modules/@ark/schema/out/roots/alias.d.ts +45 -0
  58. package/node_modules/@ark/schema/out/roots/alias.js +115 -0
  59. package/node_modules/@ark/schema/out/roots/basis.d.ts +12 -0
  60. package/node_modules/@ark/schema/out/roots/basis.js +26 -0
  61. package/node_modules/@ark/schema/out/roots/domain.d.ts +45 -0
  62. package/node_modules/@ark/schema/out/roots/domain.js +72 -0
  63. package/node_modules/@ark/schema/out/roots/intersection.d.ts +98 -0
  64. package/node_modules/@ark/schema/out/roots/intersection.js +292 -0
  65. package/node_modules/@ark/schema/out/roots/morph.d.ts +62 -0
  66. package/node_modules/@ark/schema/out/roots/morph.js +159 -0
  67. package/node_modules/@ark/schema/out/roots/proto.d.ts +53 -0
  68. package/node_modules/@ark/schema/out/roots/proto.js +101 -0
  69. package/node_modules/@ark/schema/out/roots/root.d.ts +145 -0
  70. package/node_modules/@ark/schema/out/roots/root.js +455 -0
  71. package/node_modules/@ark/schema/out/roots/union.d.ts +99 -0
  72. package/node_modules/@ark/schema/out/roots/union.js +718 -0
  73. package/node_modules/@ark/schema/out/roots/unit.d.ts +41 -0
  74. package/node_modules/@ark/schema/out/roots/unit.js +86 -0
  75. package/node_modules/@ark/schema/out/roots/utils.d.ts +3 -0
  76. package/node_modules/@ark/schema/out/roots/utils.js +6 -0
  77. package/node_modules/@ark/schema/out/scope.d.ts +158 -0
  78. package/node_modules/@ark/schema/out/scope.js +481 -0
  79. package/node_modules/@ark/schema/out/shared/compile.d.ts +62 -0
  80. package/node_modules/@ark/schema/out/shared/compile.js +145 -0
  81. package/node_modules/@ark/schema/out/shared/declare.d.ts +80 -0
  82. package/node_modules/@ark/schema/out/shared/declare.js +1 -0
  83. package/node_modules/@ark/schema/out/shared/disjoint.d.ts +41 -0
  84. package/node_modules/@ark/schema/out/shared/disjoint.js +65 -0
  85. package/node_modules/@ark/schema/out/shared/errors.d.ts +145 -0
  86. package/node_modules/@ark/schema/out/shared/errors.js +252 -0
  87. package/node_modules/@ark/schema/out/shared/implement.d.ts +151 -0
  88. package/node_modules/@ark/schema/out/shared/implement.js +98 -0
  89. package/node_modules/@ark/schema/out/shared/intersections.d.ts +10 -0
  90. package/node_modules/@ark/schema/out/shared/intersections.js +132 -0
  91. package/node_modules/@ark/schema/out/shared/jsonSchema.d.ts +93 -0
  92. package/node_modules/@ark/schema/out/shared/jsonSchema.js +1 -0
  93. package/node_modules/@ark/schema/out/shared/registry.d.ts +7 -0
  94. package/node_modules/@ark/schema/out/shared/registry.js +10 -0
  95. package/node_modules/@ark/schema/out/shared/standardSchema.d.ts +122 -0
  96. package/node_modules/@ark/schema/out/shared/standardSchema.js +2 -0
  97. package/node_modules/@ark/schema/out/shared/toJsonSchema.d.ts +139 -0
  98. package/node_modules/@ark/schema/out/shared/toJsonSchema.js +40 -0
  99. package/node_modules/@ark/schema/out/shared/traversal.d.ts +117 -0
  100. package/node_modules/@ark/schema/out/shared/traversal.js +226 -0
  101. package/node_modules/@ark/schema/out/shared/utils.d.ts +34 -0
  102. package/node_modules/@ark/schema/out/shared/utils.js +8 -0
  103. package/node_modules/@ark/schema/out/structure/index.d.ts +46 -0
  104. package/node_modules/@ark/schema/out/structure/index.js +89 -0
  105. package/node_modules/@ark/schema/out/structure/optional.d.ts +49 -0
  106. package/node_modules/@ark/schema/out/structure/optional.js +127 -0
  107. package/node_modules/@ark/schema/out/structure/prop.d.ts +45 -0
  108. package/node_modules/@ark/schema/out/structure/prop.js +85 -0
  109. package/node_modules/@ark/schema/out/structure/required.d.ts +39 -0
  110. package/node_modules/@ark/schema/out/structure/required.js +38 -0
  111. package/node_modules/@ark/schema/out/structure/sequence.d.ts +110 -0
  112. package/node_modules/@ark/schema/out/structure/sequence.js +521 -0
  113. package/node_modules/@ark/schema/out/structure/shared.d.ts +4 -0
  114. package/node_modules/@ark/schema/out/structure/shared.js +4 -0
  115. package/node_modules/@ark/schema/out/structure/structure.d.ts +113 -0
  116. package/node_modules/@ark/schema/out/structure/structure.js +747 -0
  117. package/node_modules/@ark/schema/package.json +51 -0
  118. package/node_modules/@ark/util/LICENSE +7 -0
  119. package/node_modules/@ark/util/out/arrays.d.ts +166 -0
  120. package/node_modules/@ark/util/out/arrays.js +147 -0
  121. package/node_modules/@ark/util/out/clone.d.ts +4 -0
  122. package/node_modules/@ark/util/out/clone.js +33 -0
  123. package/node_modules/@ark/util/out/describe.d.ts +25 -0
  124. package/node_modules/@ark/util/out/describe.js +1 -0
  125. package/node_modules/@ark/util/out/domain.d.ts +48 -0
  126. package/node_modules/@ark/util/out/domain.js +25 -0
  127. package/node_modules/@ark/util/out/errors.d.ts +29 -0
  128. package/node_modules/@ark/util/out/errors.js +17 -0
  129. package/node_modules/@ark/util/out/flatMorph.d.ts +41 -0
  130. package/node_modules/@ark/util/out/flatMorph.js +24 -0
  131. package/node_modules/@ark/util/out/functions.d.ts +33 -0
  132. package/node_modules/@ark/util/out/functions.js +53 -0
  133. package/node_modules/@ark/util/out/generics.d.ts +59 -0
  134. package/node_modules/@ark/util/out/generics.js +5 -0
  135. package/node_modules/@ark/util/out/get.d.ts +9 -0
  136. package/node_modules/@ark/util/out/get.js +7 -0
  137. package/node_modules/@ark/util/out/hkt.d.ts +27 -0
  138. package/node_modules/@ark/util/out/hkt.js +5 -0
  139. package/node_modules/@ark/util/out/index.d.ts +24 -0
  140. package/node_modules/@ark/util/out/index.js +24 -0
  141. package/node_modules/@ark/util/out/intersections.d.ts +50 -0
  142. package/node_modules/@ark/util/out/intersections.js +1 -0
  143. package/node_modules/@ark/util/out/isomorphic.d.ts +5 -0
  144. package/node_modules/@ark/util/out/isomorphic.js +19 -0
  145. package/node_modules/@ark/util/out/keys.d.ts +18 -0
  146. package/node_modules/@ark/util/out/keys.js +1 -0
  147. package/node_modules/@ark/util/out/lazily.d.ts +1 -0
  148. package/node_modules/@ark/util/out/lazily.js +16 -0
  149. package/node_modules/@ark/util/out/numbers.d.ts +72 -0
  150. package/node_modules/@ark/util/out/numbers.js +138 -0
  151. package/node_modules/@ark/util/out/objectKinds.d.ts +205 -0
  152. package/node_modules/@ark/util/out/objectKinds.js +150 -0
  153. package/node_modules/@ark/util/out/path.d.ts +22 -0
  154. package/node_modules/@ark/util/out/path.js +65 -0
  155. package/node_modules/@ark/util/out/primitive.d.ts +16 -0
  156. package/node_modules/@ark/util/out/primitive.js +3 -0
  157. package/node_modules/@ark/util/out/records.d.ts +183 -0
  158. package/node_modules/@ark/util/out/records.js +63 -0
  159. package/node_modules/@ark/util/out/registry.d.ts +21 -0
  160. package/node_modules/@ark/util/out/registry.js +49 -0
  161. package/node_modules/@ark/util/out/scanner.d.ts +44 -0
  162. package/node_modules/@ark/util/out/scanner.js +87 -0
  163. package/node_modules/@ark/util/out/serialize.d.ts +34 -0
  164. package/node_modules/@ark/util/out/serialize.js +150 -0
  165. package/node_modules/@ark/util/out/strings.d.ts +33 -0
  166. package/node_modules/@ark/util/out/strings.js +59 -0
  167. package/node_modules/@ark/util/out/traits.d.ts +89 -0
  168. package/node_modules/@ark/util/out/traits.js +75 -0
  169. package/node_modules/@ark/util/out/unionToTuple.d.ts +14 -0
  170. package/node_modules/@ark/util/out/unionToTuple.js +1 -0
  171. package/node_modules/@ark/util/package.json +39 -0
  172. package/node_modules/@ark/util/tsconfig.base.json +18 -0
  173. package/node_modules/@socket.io/component-emitter/LICENSE +24 -0
  174. package/node_modules/@socket.io/component-emitter/Readme.md +79 -0
  175. package/node_modules/@socket.io/component-emitter/lib/cjs/index.d.ts +179 -0
  176. package/node_modules/@socket.io/component-emitter/lib/cjs/index.js +176 -0
  177. package/node_modules/@socket.io/component-emitter/lib/cjs/package.json +4 -0
  178. package/node_modules/@socket.io/component-emitter/lib/esm/index.d.ts +179 -0
  179. package/node_modules/@socket.io/component-emitter/lib/esm/index.js +169 -0
  180. package/node_modules/@socket.io/component-emitter/lib/esm/package.json +4 -0
  181. package/node_modules/@socket.io/component-emitter/package.json +28 -0
  182. package/node_modules/arkregex/LICENSE +7 -0
  183. package/node_modules/arkregex/README.md +61 -0
  184. package/node_modules/arkregex/out/charset.d.ts +15 -0
  185. package/node_modules/arkregex/out/charset.js +1 -0
  186. package/node_modules/arkregex/out/escape.d.ts +29 -0
  187. package/node_modules/arkregex/out/escape.js +10 -0
  188. package/node_modules/arkregex/out/execArray.d.ts +23 -0
  189. package/node_modules/arkregex/out/execArray.js +1 -0
  190. package/node_modules/arkregex/out/group.d.ts +33 -0
  191. package/node_modules/arkregex/out/group.js +6 -0
  192. package/node_modules/arkregex/out/index.d.ts +1 -0
  193. package/node_modules/arkregex/out/index.js +1 -0
  194. package/node_modules/arkregex/out/parse.d.ts +10 -0
  195. package/node_modules/arkregex/out/parse.js +1 -0
  196. package/node_modules/arkregex/out/quantify.d.ts +43 -0
  197. package/node_modules/arkregex/out/quantify.js +2 -0
  198. package/node_modules/arkregex/out/regex.d.ts +38 -0
  199. package/node_modules/arkregex/out/regex.js +2 -0
  200. package/node_modules/arkregex/out/state.d.ts +359 -0
  201. package/node_modules/arkregex/out/state.js +2 -0
  202. package/node_modules/arkregex/package.json +42 -0
  203. package/node_modules/arktype/LICENSE +7 -0
  204. package/node_modules/arktype/README.md +157 -0
  205. package/node_modules/arktype/out/attributes.d.ts +104 -0
  206. package/node_modules/arktype/out/attributes.js +3 -0
  207. package/node_modules/arktype/out/config.d.ts +35 -0
  208. package/node_modules/arktype/out/config.js +3 -0
  209. package/node_modules/arktype/out/declare.d.ts +35 -0
  210. package/node_modules/arktype/out/declare.js +1 -0
  211. package/node_modules/arktype/out/fn.d.ts +61 -0
  212. package/node_modules/arktype/out/fn.js +54 -0
  213. package/node_modules/arktype/out/generic.d.ts +118 -0
  214. package/node_modules/arktype/out/generic.js +37 -0
  215. package/node_modules/arktype/out/index.d.ts +12 -0
  216. package/node_modules/arktype/out/index.js +9 -0
  217. package/node_modules/arktype/out/keywords/Array.d.ts +20 -0
  218. package/node_modules/arktype/out/keywords/Array.js +21 -0
  219. package/node_modules/arktype/out/keywords/FormData.d.ts +15 -0
  220. package/node_modules/arktype/out/keywords/FormData.js +40 -0
  221. package/node_modules/arktype/out/keywords/TypedArray.d.ts +19 -0
  222. package/node_modules/arktype/out/keywords/TypedArray.js +16 -0
  223. package/node_modules/arktype/out/keywords/builtins.d.ts +18 -0
  224. package/node_modules/arktype/out/keywords/builtins.js +11 -0
  225. package/node_modules/arktype/out/keywords/constructors.d.ts +31 -0
  226. package/node_modules/arktype/out/keywords/constructors.js +16 -0
  227. package/node_modules/arktype/out/keywords/keywords.d.ts +70 -0
  228. package/node_modules/arktype/out/keywords/keywords.js +48 -0
  229. package/node_modules/arktype/out/keywords/number.d.ts +23 -0
  230. package/node_modules/arktype/out/keywords/number.js +49 -0
  231. package/node_modules/arktype/out/keywords/string.d.ts +334 -0
  232. package/node_modules/arktype/out/keywords/string.js +463 -0
  233. package/node_modules/arktype/out/keywords/ts.d.ts +108 -0
  234. package/node_modules/arktype/out/keywords/ts.js +82 -0
  235. package/node_modules/arktype/out/match.d.ts +152 -0
  236. package/node_modules/arktype/out/match.js +95 -0
  237. package/node_modules/arktype/out/module.d.ts +22 -0
  238. package/node_modules/arktype/out/module.js +3 -0
  239. package/node_modules/arktype/out/nary.d.ts +473 -0
  240. package/node_modules/arktype/out/nary.js +1 -0
  241. package/node_modules/arktype/out/parser/ast/bounds.d.ts +18 -0
  242. package/node_modules/arktype/out/parser/ast/bounds.js +1 -0
  243. package/node_modules/arktype/out/parser/ast/default.d.ts +8 -0
  244. package/node_modules/arktype/out/parser/ast/default.js +1 -0
  245. package/node_modules/arktype/out/parser/ast/divisor.d.ts +9 -0
  246. package/node_modules/arktype/out/parser/ast/divisor.js +1 -0
  247. package/node_modules/arktype/out/parser/ast/generic.d.ts +17 -0
  248. package/node_modules/arktype/out/parser/ast/generic.js +1 -0
  249. package/node_modules/arktype/out/parser/ast/infer.d.ts +25 -0
  250. package/node_modules/arktype/out/parser/ast/infer.js +1 -0
  251. package/node_modules/arktype/out/parser/ast/keyof.d.ts +7 -0
  252. package/node_modules/arktype/out/parser/ast/keyof.js +1 -0
  253. package/node_modules/arktype/out/parser/ast/utils.d.ts +8 -0
  254. package/node_modules/arktype/out/parser/ast/utils.js +1 -0
  255. package/node_modules/arktype/out/parser/ast/validate.d.ts +30 -0
  256. package/node_modules/arktype/out/parser/ast/validate.js +3 -0
  257. package/node_modules/arktype/out/parser/definition.d.ts +30 -0
  258. package/node_modules/arktype/out/parser/definition.js +74 -0
  259. package/node_modules/arktype/out/parser/objectLiteral.d.ts +70 -0
  260. package/node_modules/arktype/out/parser/objectLiteral.js +113 -0
  261. package/node_modules/arktype/out/parser/property.d.ts +34 -0
  262. package/node_modules/arktype/out/parser/property.js +16 -0
  263. package/node_modules/arktype/out/parser/reduce/dynamic.d.ts +42 -0
  264. package/node_modules/arktype/out/parser/reduce/dynamic.js +153 -0
  265. package/node_modules/arktype/out/parser/reduce/shared.d.ts +39 -0
  266. package/node_modules/arktype/out/parser/reduce/shared.js +25 -0
  267. package/node_modules/arktype/out/parser/reduce/static.d.ts +186 -0
  268. package/node_modules/arktype/out/parser/reduce/static.js +1 -0
  269. package/node_modules/arktype/out/parser/shift/operand/date.d.ts +11 -0
  270. package/node_modules/arktype/out/parser/shift/operand/date.js +23 -0
  271. package/node_modules/arktype/out/parser/shift/operand/enclosed.d.ts +57 -0
  272. package/node_modules/arktype/out/parser/shift/operand/enclosed.js +78 -0
  273. package/node_modules/arktype/out/parser/shift/operand/genericArgs.d.ts +27 -0
  274. package/node_modules/arktype/out/parser/shift/operand/genericArgs.js +16 -0
  275. package/node_modules/arktype/out/parser/shift/operand/operand.d.ts +8 -0
  276. package/node_modules/arktype/out/parser/shift/operand/operand.js +16 -0
  277. package/node_modules/arktype/out/parser/shift/operand/unenclosed.d.ts +43 -0
  278. package/node_modules/arktype/out/parser/shift/operand/unenclosed.js +59 -0
  279. package/node_modules/arktype/out/parser/shift/operator/bounds.d.ts +24 -0
  280. package/node_modules/arktype/out/parser/shift/operator/bounds.js +91 -0
  281. package/node_modules/arktype/out/parser/shift/operator/brand.d.ts +7 -0
  282. package/node_modules/arktype/out/parser/shift/operator/brand.js +6 -0
  283. package/node_modules/arktype/out/parser/shift/operator/default.d.ts +24 -0
  284. package/node_modules/arktype/out/parser/shift/operator/default.js +15 -0
  285. package/node_modules/arktype/out/parser/shift/operator/divisor.d.ts +8 -0
  286. package/node_modules/arktype/out/parser/shift/operator/divisor.js +13 -0
  287. package/node_modules/arktype/out/parser/shift/operator/operator.d.ts +14 -0
  288. package/node_modules/arktype/out/parser/shift/operator/operator.js +28 -0
  289. package/node_modules/arktype/out/parser/shift/tokens.d.ts +33 -0
  290. package/node_modules/arktype/out/parser/shift/tokens.js +37 -0
  291. package/node_modules/arktype/out/parser/string.d.ts +30 -0
  292. package/node_modules/arktype/out/parser/string.js +42 -0
  293. package/node_modules/arktype/out/parser/tupleExpressions.d.ts +79 -0
  294. package/node_modules/arktype/out/parser/tupleExpressions.js +75 -0
  295. package/node_modules/arktype/out/parser/tupleLiteral.d.ts +95 -0
  296. package/node_modules/arktype/out/parser/tupleLiteral.js +128 -0
  297. package/node_modules/arktype/out/scope.d.ts +158 -0
  298. package/node_modules/arktype/out/scope.js +106 -0
  299. package/node_modules/arktype/out/type.d.ts +144 -0
  300. package/node_modules/arktype/out/type.js +55 -0
  301. package/node_modules/arktype/out/variants/array.d.ts +12 -0
  302. package/node_modules/arktype/out/variants/array.js +1 -0
  303. package/node_modules/arktype/out/variants/base.d.ts +542 -0
  304. package/node_modules/arktype/out/variants/base.js +1 -0
  305. package/node_modules/arktype/out/variants/date.d.ts +10 -0
  306. package/node_modules/arktype/out/variants/date.js +1 -0
  307. package/node_modules/arktype/out/variants/instantiate.d.ts +12 -0
  308. package/node_modules/arktype/out/variants/instantiate.js +1 -0
  309. package/node_modules/arktype/out/variants/number.d.ts +11 -0
  310. package/node_modules/arktype/out/variants/number.js +1 -0
  311. package/node_modules/arktype/out/variants/object.d.ts +107 -0
  312. package/node_modules/arktype/out/variants/object.js +1 -0
  313. package/node_modules/arktype/out/variants/string.d.ts +15 -0
  314. package/node_modules/arktype/out/variants/string.js +1 -0
  315. package/node_modules/arktype/package.json +57 -0
  316. package/node_modules/debug/LICENSE +20 -0
  317. package/node_modules/debug/README.md +481 -0
  318. package/node_modules/debug/package.json +64 -0
  319. package/node_modules/debug/src/browser.js +272 -0
  320. package/node_modules/debug/src/common.js +292 -0
  321. package/node_modules/debug/src/index.js +10 -0
  322. package/node_modules/debug/src/node.js +263 -0
  323. package/node_modules/engine.io-client/LICENSE +22 -0
  324. package/node_modules/engine.io-client/README.md +331 -0
  325. package/node_modules/engine.io-client/build/cjs/browser-entrypoint.d.ts +3 -0
  326. package/node_modules/engine.io-client/build/cjs/browser-entrypoint.js +4 -0
  327. package/node_modules/engine.io-client/build/cjs/contrib/has-cors.d.ts +1 -0
  328. package/node_modules/engine.io-client/build/cjs/contrib/has-cors.js +14 -0
  329. package/node_modules/engine.io-client/build/cjs/contrib/parseqs.d.ts +15 -0
  330. package/node_modules/engine.io-client/build/cjs/contrib/parseqs.js +38 -0
  331. package/node_modules/engine.io-client/build/cjs/contrib/parseuri.d.ts +1 -0
  332. package/node_modules/engine.io-client/build/cjs/contrib/parseuri.js +67 -0
  333. package/node_modules/engine.io-client/build/cjs/globals.d.ts +4 -0
  334. package/node_modules/engine.io-client/build/cjs/globals.js +26 -0
  335. package/node_modules/engine.io-client/build/cjs/globals.node.d.ts +21 -0
  336. package/node_modules/engine.io-client/build/cjs/globals.node.js +97 -0
  337. package/node_modules/engine.io-client/build/cjs/index.d.ts +15 -0
  338. package/node_modules/engine.io-client/build/cjs/index.js +32 -0
  339. package/node_modules/engine.io-client/build/cjs/package.json +10 -0
  340. package/node_modules/engine.io-client/build/cjs/socket.d.ts +482 -0
  341. package/node_modules/engine.io-client/build/cjs/socket.js +765 -0
  342. package/node_modules/engine.io-client/build/cjs/transport.d.ts +106 -0
  343. package/node_modules/engine.io-client/build/cjs/transport.js +153 -0
  344. package/node_modules/engine.io-client/build/cjs/transports/index.d.ts +8 -0
  345. package/node_modules/engine.io-client/build/cjs/transports/index.js +11 -0
  346. package/node_modules/engine.io-client/build/cjs/transports/polling-fetch.d.ts +15 -0
  347. package/node_modules/engine.io-client/build/cjs/transports/polling-fetch.js +60 -0
  348. package/node_modules/engine.io-client/build/cjs/transports/polling-xhr.d.ts +108 -0
  349. package/node_modules/engine.io-client/build/cjs/transports/polling-xhr.js +285 -0
  350. package/node_modules/engine.io-client/build/cjs/transports/polling-xhr.node.d.ts +11 -0
  351. package/node_modules/engine.io-client/build/cjs/transports/polling-xhr.node.js +44 -0
  352. package/node_modules/engine.io-client/build/cjs/transports/polling.d.ts +52 -0
  353. package/node_modules/engine.io-client/build/cjs/transports/polling.js +165 -0
  354. package/node_modules/engine.io-client/build/cjs/transports/websocket.d.ts +36 -0
  355. package/node_modules/engine.io-client/build/cjs/transports/websocket.js +136 -0
  356. package/node_modules/engine.io-client/build/cjs/transports/websocket.node.d.ts +14 -0
  357. package/node_modules/engine.io-client/build/cjs/transports/websocket.node.js +68 -0
  358. package/node_modules/engine.io-client/build/cjs/transports/webtransport.d.ts +18 -0
  359. package/node_modules/engine.io-client/build/cjs/transports/webtransport.js +94 -0
  360. package/node_modules/engine.io-client/build/cjs/util.d.ts +7 -0
  361. package/node_modules/engine.io-client/build/cjs/util.js +65 -0
  362. package/node_modules/engine.io-client/build/esm/browser-entrypoint.d.ts +3 -0
  363. package/node_modules/engine.io-client/build/esm/browser-entrypoint.js +2 -0
  364. package/node_modules/engine.io-client/build/esm/contrib/has-cors.d.ts +1 -0
  365. package/node_modules/engine.io-client/build/esm/contrib/has-cors.js +11 -0
  366. package/node_modules/engine.io-client/build/esm/contrib/parseqs.d.ts +15 -0
  367. package/node_modules/engine.io-client/build/esm/contrib/parseqs.js +34 -0
  368. package/node_modules/engine.io-client/build/esm/contrib/parseuri.d.ts +1 -0
  369. package/node_modules/engine.io-client/build/esm/contrib/parseuri.js +64 -0
  370. package/node_modules/engine.io-client/build/esm/globals.d.ts +4 -0
  371. package/node_modules/engine.io-client/build/esm/globals.js +22 -0
  372. package/node_modules/engine.io-client/build/esm/globals.node.d.ts +21 -0
  373. package/node_modules/engine.io-client/build/esm/globals.node.js +91 -0
  374. package/node_modules/engine.io-client/build/esm/index.d.ts +15 -0
  375. package/node_modules/engine.io-client/build/esm/index.js +15 -0
  376. package/node_modules/engine.io-client/build/esm/package.json +10 -0
  377. package/node_modules/engine.io-client/build/esm/socket.d.ts +482 -0
  378. package/node_modules/engine.io-client/build/esm/socket.js +727 -0
  379. package/node_modules/engine.io-client/build/esm/transport.d.ts +106 -0
  380. package/node_modules/engine.io-client/build/esm/transport.js +142 -0
  381. package/node_modules/engine.io-client/build/esm/transports/index.d.ts +8 -0
  382. package/node_modules/engine.io-client/build/esm/transports/index.js +8 -0
  383. package/node_modules/engine.io-client/build/esm/transports/polling-fetch.d.ts +15 -0
  384. package/node_modules/engine.io-client/build/esm/transports/polling-fetch.js +56 -0
  385. package/node_modules/engine.io-client/build/esm/transports/polling-xhr.d.ts +108 -0
  386. package/node_modules/engine.io-client/build/esm/transports/polling-xhr.js +271 -0
  387. package/node_modules/engine.io-client/build/esm/transports/polling-xhr.node.d.ts +11 -0
  388. package/node_modules/engine.io-client/build/esm/transports/polling-xhr.node.js +17 -0
  389. package/node_modules/engine.io-client/build/esm/transports/polling.d.ts +52 -0
  390. package/node_modules/engine.io-client/build/esm/transports/polling.js +145 -0
  391. package/node_modules/engine.io-client/build/esm/transports/websocket.d.ts +36 -0
  392. package/node_modules/engine.io-client/build/esm/transports/websocket.js +125 -0
  393. package/node_modules/engine.io-client/build/esm/transports/websocket.node.d.ts +14 -0
  394. package/node_modules/engine.io-client/build/esm/transports/websocket.node.js +41 -0
  395. package/node_modules/engine.io-client/build/esm/transports/webtransport.d.ts +18 -0
  396. package/node_modules/engine.io-client/build/esm/transports/webtransport.js +80 -0
  397. package/node_modules/engine.io-client/build/esm/util.d.ts +7 -0
  398. package/node_modules/engine.io-client/build/esm/util.js +59 -0
  399. package/node_modules/engine.io-client/build/esm-debug/browser-entrypoint.d.ts +3 -0
  400. package/node_modules/engine.io-client/build/esm-debug/browser-entrypoint.js +2 -0
  401. package/node_modules/engine.io-client/build/esm-debug/contrib/has-cors.d.ts +1 -0
  402. package/node_modules/engine.io-client/build/esm-debug/contrib/has-cors.js +11 -0
  403. package/node_modules/engine.io-client/build/esm-debug/contrib/parseqs.d.ts +15 -0
  404. package/node_modules/engine.io-client/build/esm-debug/contrib/parseqs.js +34 -0
  405. package/node_modules/engine.io-client/build/esm-debug/contrib/parseuri.d.ts +1 -0
  406. package/node_modules/engine.io-client/build/esm-debug/contrib/parseuri.js +64 -0
  407. package/node_modules/engine.io-client/build/esm-debug/globals.d.ts +4 -0
  408. package/node_modules/engine.io-client/build/esm-debug/globals.js +22 -0
  409. package/node_modules/engine.io-client/build/esm-debug/globals.node.d.ts +21 -0
  410. package/node_modules/engine.io-client/build/esm-debug/globals.node.js +91 -0
  411. package/node_modules/engine.io-client/build/esm-debug/index.d.ts +15 -0
  412. package/node_modules/engine.io-client/build/esm-debug/index.js +15 -0
  413. package/node_modules/engine.io-client/build/esm-debug/package.json +10 -0
  414. package/node_modules/engine.io-client/build/esm-debug/socket.d.ts +482 -0
  415. package/node_modules/engine.io-client/build/esm-debug/socket.js +756 -0
  416. package/node_modules/engine.io-client/build/esm-debug/transport.d.ts +106 -0
  417. package/node_modules/engine.io-client/build/esm-debug/transport.js +145 -0
  418. package/node_modules/engine.io-client/build/esm-debug/transports/index.d.ts +8 -0
  419. package/node_modules/engine.io-client/build/esm-debug/transports/index.js +8 -0
  420. package/node_modules/engine.io-client/build/esm-debug/transports/polling-fetch.d.ts +15 -0
  421. package/node_modules/engine.io-client/build/esm-debug/transports/polling-fetch.js +56 -0
  422. package/node_modules/engine.io-client/build/esm-debug/transports/polling-xhr.d.ts +108 -0
  423. package/node_modules/engine.io-client/build/esm-debug/transports/polling-xhr.js +276 -0
  424. package/node_modules/engine.io-client/build/esm-debug/transports/polling-xhr.node.d.ts +11 -0
  425. package/node_modules/engine.io-client/build/esm-debug/transports/polling-xhr.node.js +17 -0
  426. package/node_modules/engine.io-client/build/esm-debug/transports/polling.d.ts +52 -0
  427. package/node_modules/engine.io-client/build/esm-debug/transports/polling.js +158 -0
  428. package/node_modules/engine.io-client/build/esm-debug/transports/websocket.d.ts +36 -0
  429. package/node_modules/engine.io-client/build/esm-debug/transports/websocket.js +128 -0
  430. package/node_modules/engine.io-client/build/esm-debug/transports/websocket.node.d.ts +14 -0
  431. package/node_modules/engine.io-client/build/esm-debug/transports/websocket.node.js +41 -0
  432. package/node_modules/engine.io-client/build/esm-debug/transports/webtransport.d.ts +18 -0
  433. package/node_modules/engine.io-client/build/esm-debug/transports/webtransport.js +87 -0
  434. package/node_modules/engine.io-client/build/esm-debug/util.d.ts +7 -0
  435. package/node_modules/engine.io-client/build/esm-debug/util.js +59 -0
  436. package/node_modules/engine.io-client/dist/engine.io.esm.min.js +7 -0
  437. package/node_modules/engine.io-client/dist/engine.io.esm.min.js.map +1 -0
  438. package/node_modules/engine.io-client/dist/engine.io.js +3064 -0
  439. package/node_modules/engine.io-client/dist/engine.io.js.map +1 -0
  440. package/node_modules/engine.io-client/dist/engine.io.min.js +7 -0
  441. package/node_modules/engine.io-client/dist/engine.io.min.js.map +1 -0
  442. package/node_modules/engine.io-client/package.json +95 -0
  443. package/node_modules/engine.io-parser/LICENSE +22 -0
  444. package/node_modules/engine.io-parser/Readme.md +158 -0
  445. package/node_modules/engine.io-parser/build/cjs/commons.d.ts +14 -0
  446. package/node_modules/engine.io-parser/build/cjs/commons.js +19 -0
  447. package/node_modules/engine.io-parser/build/cjs/contrib/base64-arraybuffer.d.ts +2 -0
  448. package/node_modules/engine.io-parser/build/cjs/contrib/base64-arraybuffer.js +48 -0
  449. package/node_modules/engine.io-parser/build/cjs/decodePacket.browser.d.ts +2 -0
  450. package/node_modules/engine.io-parser/build/cjs/decodePacket.browser.js +66 -0
  451. package/node_modules/engine.io-parser/build/cjs/decodePacket.d.ts +2 -0
  452. package/node_modules/engine.io-parser/build/cjs/decodePacket.js +59 -0
  453. package/node_modules/engine.io-parser/build/cjs/encodePacket.browser.d.ts +4 -0
  454. package/node_modules/engine.io-parser/build/cjs/encodePacket.browser.js +72 -0
  455. package/node_modules/engine.io-parser/build/cjs/encodePacket.d.ts +3 -0
  456. package/node_modules/engine.io-parser/build/cjs/encodePacket.js +38 -0
  457. package/node_modules/engine.io-parser/build/cjs/index.d.ts +9 -0
  458. package/node_modules/engine.io-parser/build/cjs/index.js +164 -0
  459. package/node_modules/engine.io-parser/build/cjs/package.json +8 -0
  460. package/node_modules/engine.io-parser/build/esm/commons.d.ts +14 -0
  461. package/node_modules/engine.io-parser/build/esm/commons.js +14 -0
  462. package/node_modules/engine.io-parser/build/esm/contrib/base64-arraybuffer.d.ts +2 -0
  463. package/node_modules/engine.io-parser/build/esm/contrib/base64-arraybuffer.js +43 -0
  464. package/node_modules/engine.io-parser/build/esm/decodePacket.browser.d.ts +2 -0
  465. package/node_modules/engine.io-parser/build/esm/decodePacket.browser.js +62 -0
  466. package/node_modules/engine.io-parser/build/esm/decodePacket.d.ts +2 -0
  467. package/node_modules/engine.io-parser/build/esm/decodePacket.js +55 -0
  468. package/node_modules/engine.io-parser/build/esm/encodePacket.browser.d.ts +4 -0
  469. package/node_modules/engine.io-parser/build/esm/encodePacket.browser.js +68 -0
  470. package/node_modules/engine.io-parser/build/esm/encodePacket.d.ts +3 -0
  471. package/node_modules/engine.io-parser/build/esm/encodePacket.js +33 -0
  472. package/node_modules/engine.io-parser/build/esm/index.d.ts +9 -0
  473. package/node_modules/engine.io-parser/build/esm/index.js +156 -0
  474. package/node_modules/engine.io-parser/build/esm/package.json +8 -0
  475. package/node_modules/engine.io-parser/package.json +46 -0
  476. package/node_modules/ms/index.js +162 -0
  477. package/node_modules/ms/license.md +21 -0
  478. package/node_modules/ms/package.json +38 -0
  479. package/node_modules/ms/readme.md +59 -0
  480. package/node_modules/socket.io-client/LICENSE +21 -0
  481. package/node_modules/socket.io-client/README.md +29 -0
  482. package/node_modules/socket.io-client/build/cjs/browser-entrypoint.d.ts +2 -0
  483. package/node_modules/socket.io-client/build/cjs/browser-entrypoint.js +4 -0
  484. package/node_modules/socket.io-client/build/cjs/contrib/backo2.d.ts +12 -0
  485. package/node_modules/socket.io-client/build/cjs/contrib/backo2.js +69 -0
  486. package/node_modules/socket.io-client/build/cjs/index.d.ts +29 -0
  487. package/node_modules/socket.io-client/build/cjs/index.js +76 -0
  488. package/node_modules/socket.io-client/build/cjs/manager.d.ts +295 -0
  489. package/node_modules/socket.io-client/build/cjs/manager.js +416 -0
  490. package/node_modules/socket.io-client/build/cjs/on.d.ts +2 -0
  491. package/node_modules/socket.io-client/build/cjs/on.js +9 -0
  492. package/node_modules/socket.io-client/build/cjs/socket.d.ts +593 -0
  493. package/node_modules/socket.io-client/build/cjs/socket.js +909 -0
  494. package/node_modules/socket.io-client/build/cjs/url.d.ts +33 -0
  495. package/node_modules/socket.io-client/build/cjs/url.js +69 -0
  496. package/node_modules/socket.io-client/build/esm/browser-entrypoint.d.ts +2 -0
  497. package/node_modules/socket.io-client/build/esm/browser-entrypoint.js +2 -0
  498. package/node_modules/socket.io-client/build/esm/contrib/backo2.d.ts +12 -0
  499. package/node_modules/socket.io-client/build/esm/contrib/backo2.js +66 -0
  500. package/node_modules/socket.io-client/build/esm/index.d.ts +29 -0
  501. package/node_modules/socket.io-client/build/esm/index.js +58 -0
  502. package/node_modules/socket.io-client/build/esm/manager.d.ts +295 -0
  503. package/node_modules/socket.io-client/build/esm/manager.js +367 -0
  504. package/node_modules/socket.io-client/build/esm/on.d.ts +2 -0
  505. package/node_modules/socket.io-client/build/esm/on.js +6 -0
  506. package/node_modules/socket.io-client/build/esm/package.json +5 -0
  507. package/node_modules/socket.io-client/build/esm/socket.d.ts +593 -0
  508. package/node_modules/socket.io-client/build/esm/socket.js +880 -0
  509. package/node_modules/socket.io-client/build/esm/url.d.ts +33 -0
  510. package/node_modules/socket.io-client/build/esm/url.js +59 -0
  511. package/node_modules/socket.io-client/build/esm-debug/browser-entrypoint.d.ts +2 -0
  512. package/node_modules/socket.io-client/build/esm-debug/browser-entrypoint.js +2 -0
  513. package/node_modules/socket.io-client/build/esm-debug/contrib/backo2.d.ts +12 -0
  514. package/node_modules/socket.io-client/build/esm-debug/contrib/backo2.js +66 -0
  515. package/node_modules/socket.io-client/build/esm-debug/index.d.ts +29 -0
  516. package/node_modules/socket.io-client/build/esm-debug/index.js +62 -0
  517. package/node_modules/socket.io-client/build/esm-debug/manager.d.ts +295 -0
  518. package/node_modules/socket.io-client/build/esm-debug/manager.js +386 -0
  519. package/node_modules/socket.io-client/build/esm-debug/on.d.ts +2 -0
  520. package/node_modules/socket.io-client/build/esm-debug/on.js +6 -0
  521. package/node_modules/socket.io-client/build/esm-debug/package.json +5 -0
  522. package/node_modules/socket.io-client/build/esm-debug/socket.d.ts +593 -0
  523. package/node_modules/socket.io-client/build/esm-debug/socket.js +902 -0
  524. package/node_modules/socket.io-client/build/esm-debug/url.d.ts +33 -0
  525. package/node_modules/socket.io-client/build/esm-debug/url.js +63 -0
  526. package/node_modules/socket.io-client/dist/socket.io.esm.min.js +7 -0
  527. package/node_modules/socket.io-client/dist/socket.io.esm.min.js.map +1 -0
  528. package/node_modules/socket.io-client/dist/socket.io.js +4955 -0
  529. package/node_modules/socket.io-client/dist/socket.io.js.map +1 -0
  530. package/node_modules/socket.io-client/dist/socket.io.min.js +7 -0
  531. package/node_modules/socket.io-client/dist/socket.io.min.js.map +1 -0
  532. package/node_modules/socket.io-client/dist/socket.io.msgpack.min.js +7 -0
  533. package/node_modules/socket.io-client/dist/socket.io.msgpack.min.js.map +1 -0
  534. package/node_modules/socket.io-client/package.json +101 -0
  535. package/node_modules/socket.io-parser/LICENSE +20 -0
  536. package/node_modules/socket.io-parser/Readme.md +81 -0
  537. package/node_modules/socket.io-parser/build/cjs/binary.d.ts +20 -0
  538. package/node_modules/socket.io-parser/build/cjs/binary.js +87 -0
  539. package/node_modules/socket.io-parser/build/cjs/index.d.ts +91 -0
  540. package/node_modules/socket.io-parser/build/cjs/index.js +359 -0
  541. package/node_modules/socket.io-parser/build/cjs/is-binary.d.ts +7 -0
  542. package/node_modules/socket.io-parser/build/cjs/is-binary.js +54 -0
  543. package/node_modules/socket.io-parser/build/cjs/package.json +3 -0
  544. package/node_modules/socket.io-parser/build/esm/binary.d.ts +20 -0
  545. package/node_modules/socket.io-parser/build/esm/binary.js +83 -0
  546. package/node_modules/socket.io-parser/build/esm/index.d.ts +91 -0
  547. package/node_modules/socket.io-parser/build/esm/index.js +348 -0
  548. package/node_modules/socket.io-parser/build/esm/is-binary.d.ts +7 -0
  549. package/node_modules/socket.io-parser/build/esm/is-binary.js +50 -0
  550. package/node_modules/socket.io-parser/build/esm/package.json +3 -0
  551. package/node_modules/socket.io-parser/build/esm-debug/binary.d.ts +20 -0
  552. package/node_modules/socket.io-parser/build/esm-debug/binary.js +83 -0
  553. package/node_modules/socket.io-parser/build/esm-debug/index.d.ts +91 -0
  554. package/node_modules/socket.io-parser/build/esm-debug/index.js +353 -0
  555. package/node_modules/socket.io-parser/build/esm-debug/is-binary.d.ts +7 -0
  556. package/node_modules/socket.io-parser/build/esm-debug/is-binary.js +50 -0
  557. package/node_modules/socket.io-parser/build/esm-debug/package.json +3 -0
  558. package/node_modules/socket.io-parser/package.json +44 -0
  559. package/node_modules/ws/LICENSE +20 -0
  560. package/node_modules/ws/README.md +548 -0
  561. package/node_modules/ws/browser.js +8 -0
  562. package/node_modules/ws/index.js +13 -0
  563. package/node_modules/ws/lib/buffer-util.js +131 -0
  564. package/node_modules/ws/lib/constants.js +18 -0
  565. package/node_modules/ws/lib/event-target.js +292 -0
  566. package/node_modules/ws/lib/extension.js +203 -0
  567. package/node_modules/ws/lib/limiter.js +55 -0
  568. package/node_modules/ws/lib/permessage-deflate.js +528 -0
  569. package/node_modules/ws/lib/receiver.js +706 -0
  570. package/node_modules/ws/lib/sender.js +602 -0
  571. package/node_modules/ws/lib/stream.js +161 -0
  572. package/node_modules/ws/lib/subprotocol.js +62 -0
  573. package/node_modules/ws/lib/validation.js +152 -0
  574. package/node_modules/ws/lib/websocket-server.js +550 -0
  575. package/node_modules/ws/lib/websocket.js +1388 -0
  576. package/node_modules/ws/package.json +69 -0
  577. package/node_modules/ws/wrapper.mjs +8 -0
  578. package/node_modules/xmlhttprequest-ssl/LICENSE +22 -0
  579. package/node_modules/xmlhttprequest-ssl/README.md +67 -0
  580. package/node_modules/xmlhttprequest-ssl/lib/XMLHttpRequest.js +689 -0
  581. package/node_modules/xmlhttprequest-ssl/package.json +40 -0
  582. package/package.json +34 -4
  583. package/public-api.md +85 -23
@@ -0,0 +1,481 @@
1
+ import { ParseError, flatMorph, hasDomain, isArray, isThunk, printable, throwInternalError, throwParseError } from "@ark/util";
2
+ import { mergeConfigs } from "./config.js";
3
+ import { GenericRoot, LazyGenericBody } from "./generic.js";
4
+ import { nodeImplementationsByKind } from "./kinds.js";
5
+ import { RootModule, bindModule } from "./module.js";
6
+ import { nodesByRegisteredId, parseNode, registerNodeId, schemaKindOf, withId } from "./parse.js";
7
+ import { Alias } from "./roots/alias.js";
8
+ import { CompiledFunction, NodeCompiler } from "./shared/compile.js";
9
+ import { $ark } from "./shared/registry.js";
10
+ import { Traversal } from "./shared/traversal.js";
11
+ import { arkKind, hasArkKind, isNode } from "./shared/utils.js";
12
+ const schemaBranchesOf = (schema) => isArray(schema) ? schema
13
+ : "branches" in schema && isArray(schema.branches) ? schema.branches
14
+ : undefined;
15
+ const throwMismatchedNodeRootError = (expected, actual) => throwParseError(`Node of kind ${actual} is not valid as a ${expected} definition`);
16
+ export const writeDuplicateAliasError = (alias) => `#${alias} duplicates public alias ${alias}`;
17
+ const scopesByName = {};
18
+ $ark.ambient ??= {};
19
+ let rawUnknownUnion;
20
+ const rootScopeFnName = "function $";
21
+ const precompile = (references) => bindPrecompilation(references, precompileReferences(references));
22
+ const bindPrecompilation = (references, precompiler) => {
23
+ const precompilation = precompiler.write(rootScopeFnName, 4);
24
+ const compiledTraversals = precompiler.compile()();
25
+ for (const node of references) {
26
+ if (node.precompilation) {
27
+ // if node has already been bound to another scope or anonymous type, don't rebind it
28
+ continue;
29
+ }
30
+ node.traverseAllows =
31
+ compiledTraversals[`${node.id}Allows`].bind(compiledTraversals);
32
+ if (node.isRoot() && !node.allowsRequiresContext) {
33
+ // if the reference doesn't require context, we can assign over
34
+ // it directly to avoid having to initialize it
35
+ node.allows = node.traverseAllows;
36
+ }
37
+ node.traverseApply =
38
+ compiledTraversals[`${node.id}Apply`].bind(compiledTraversals);
39
+ if (compiledTraversals[`${node.id}Optimistic`]) {
40
+ ;
41
+ node.traverseOptimistic =
42
+ compiledTraversals[`${node.id}Optimistic`].bind(compiledTraversals);
43
+ }
44
+ node.precompilation = precompilation;
45
+ }
46
+ };
47
+ const precompileReferences = (references) => new CompiledFunction().return(references.reduce((js, node) => {
48
+ const allowsCompiler = new NodeCompiler({ kind: "Allows" }).indent();
49
+ node.compile(allowsCompiler);
50
+ const allowsJs = allowsCompiler.write(`${node.id}Allows`);
51
+ const applyCompiler = new NodeCompiler({ kind: "Apply" }).indent();
52
+ node.compile(applyCompiler);
53
+ const applyJs = applyCompiler.write(`${node.id}Apply`);
54
+ const result = `${js}${allowsJs},\n${applyJs},\n`;
55
+ if (!node.hasKind("union"))
56
+ return result;
57
+ const optimisticCompiler = new NodeCompiler({
58
+ kind: "Allows",
59
+ optimistic: true
60
+ }).indent();
61
+ node.compile(optimisticCompiler);
62
+ const optimisticJs = optimisticCompiler.write(`${node.id}Optimistic`);
63
+ return `${result}${optimisticJs},\n`;
64
+ }, "{\n") + "}");
65
+ export class BaseScope {
66
+ config;
67
+ resolvedConfig;
68
+ name;
69
+ get [arkKind]() {
70
+ return "scope";
71
+ }
72
+ referencesById = {};
73
+ references = [];
74
+ resolutions = {};
75
+ exportedNames = [];
76
+ aliases = {};
77
+ resolved = false;
78
+ nodesByHash = {};
79
+ intrinsic;
80
+ constructor(
81
+ /** The set of names defined at the root-level of the scope mapped to their
82
+ * corresponding definitions.**/
83
+ def, config) {
84
+ this.config = mergeConfigs($ark.config, config);
85
+ this.resolvedConfig = mergeConfigs($ark.resolvedConfig, config);
86
+ this.name =
87
+ this.resolvedConfig.name ??
88
+ `anonymousScope${Object.keys(scopesByName).length}`;
89
+ if (this.name in scopesByName)
90
+ throwParseError(`A Scope already named ${this.name} already exists`);
91
+ scopesByName[this.name] = this;
92
+ const aliasEntries = Object.entries(def).map(entry => this.preparseOwnAliasEntry(...entry));
93
+ for (const [k, v] of aliasEntries) {
94
+ let name = k;
95
+ if (k[0] === "#") {
96
+ name = k.slice(1);
97
+ if (name in this.aliases)
98
+ throwParseError(writeDuplicateAliasError(name));
99
+ this.aliases[name] = v;
100
+ }
101
+ else {
102
+ if (name in this.aliases)
103
+ throwParseError(writeDuplicateAliasError(k));
104
+ this.aliases[name] = v;
105
+ this.exportedNames.push(name);
106
+ }
107
+ if (!hasArkKind(v, "module") &&
108
+ !hasArkKind(v, "generic") &&
109
+ !isThunk(v)) {
110
+ const preparsed = this.preparseOwnDefinitionFormat(v, { alias: name });
111
+ this.resolutions[name] =
112
+ hasArkKind(preparsed, "root") ?
113
+ this.bindReference(preparsed)
114
+ : this.createParseContext(preparsed).id;
115
+ }
116
+ }
117
+ // reduce union of all possible values reduces to unknown
118
+ rawUnknownUnion ??= this.node("union", {
119
+ branches: [
120
+ "string",
121
+ "number",
122
+ "object",
123
+ "bigint",
124
+ "symbol",
125
+ { unit: true },
126
+ { unit: false },
127
+ { unit: undefined },
128
+ { unit: null }
129
+ ]
130
+ }, { prereduced: true });
131
+ this.nodesByHash[rawUnknownUnion.hash] = this.node("intersection", {}, { prereduced: true });
132
+ this.intrinsic =
133
+ $ark.intrinsic ?
134
+ flatMorph($ark.intrinsic, (k, v) =>
135
+ // don't include cyclic aliases from JSON scope
136
+ k.startsWith("json") ? [] : [k, this.bindReference(v)])
137
+ // intrinsic won't be available during bootstrapping, so we lie
138
+ // about the type here as an extrnal convenience
139
+ : {};
140
+ }
141
+ cacheGetter(name, value) {
142
+ Object.defineProperty(this, name, { value });
143
+ return value;
144
+ }
145
+ get internal() {
146
+ return this;
147
+ }
148
+ // json is populated when the scope is exported, so ensure it is populated
149
+ // before allowing external access
150
+ _json;
151
+ get json() {
152
+ if (!this._json)
153
+ this.export();
154
+ return this._json;
155
+ }
156
+ defineSchema(def) {
157
+ return def;
158
+ }
159
+ generic = (...params) => {
160
+ const $ = this;
161
+ return (def, possibleHkt) => new GenericRoot(params, possibleHkt ? new LazyGenericBody(def) : def, $, $, possibleHkt ?? null);
162
+ };
163
+ units = (values, opts) => {
164
+ const uniqueValues = [];
165
+ for (const value of values)
166
+ if (!uniqueValues.includes(value))
167
+ uniqueValues.push(value);
168
+ const branches = uniqueValues.map(unit => this.node("unit", { unit }, opts));
169
+ return this.node("union", branches, {
170
+ ...opts,
171
+ prereduced: true
172
+ });
173
+ };
174
+ lazyResolutions = [];
175
+ lazilyResolve(resolve, syntheticAlias) {
176
+ const node = this.node("alias", {
177
+ reference: syntheticAlias ?? "synthetic",
178
+ resolve
179
+ }, { prereduced: true });
180
+ if (!this.resolved)
181
+ this.lazyResolutions.push(node);
182
+ return node;
183
+ }
184
+ schema = (schema, opts) => this.finalize(this.parseSchema(schema, opts));
185
+ parseSchema = (schema, opts) => this.node(schemaKindOf(schema), schema, opts);
186
+ preparseNode(kinds, schema, opts) {
187
+ let kind = typeof kinds === "string" ? kinds : schemaKindOf(schema, kinds);
188
+ if (isNode(schema) && schema.kind === kind)
189
+ return schema;
190
+ if (kind === "alias" && !opts?.prereduced) {
191
+ const { reference } = Alias.implementation.normalize(schema, this);
192
+ if (reference.startsWith("$")) {
193
+ const resolution = this.resolveRoot(reference.slice(1));
194
+ schema = resolution;
195
+ kind = resolution.kind;
196
+ }
197
+ }
198
+ else if (kind === "union" && hasDomain(schema, "object")) {
199
+ const branches = schemaBranchesOf(schema);
200
+ if (branches?.length === 1) {
201
+ schema = branches[0];
202
+ kind = schemaKindOf(schema);
203
+ }
204
+ }
205
+ if (isNode(schema) && schema.kind === kind)
206
+ return schema;
207
+ const impl = nodeImplementationsByKind[kind];
208
+ const normalizedSchema = impl.normalize?.(schema, this) ?? schema;
209
+ // check again after normalization in case a node is a valid collapsed
210
+ // schema for the kind (e.g. sequence can collapse to element accepting a Node')
211
+ if (isNode(normalizedSchema)) {
212
+ return normalizedSchema.kind === kind ?
213
+ normalizedSchema
214
+ : throwMismatchedNodeRootError(kind, normalizedSchema.kind);
215
+ }
216
+ return {
217
+ ...opts,
218
+ $: this,
219
+ kind,
220
+ def: normalizedSchema,
221
+ prefix: opts.alias ?? kind
222
+ };
223
+ }
224
+ bindReference(reference) {
225
+ let bound;
226
+ if (isNode(reference)) {
227
+ bound =
228
+ reference.$ === this ?
229
+ reference
230
+ : new reference.constructor(reference.attachments, this);
231
+ }
232
+ else {
233
+ bound =
234
+ reference.$ === this ?
235
+ reference
236
+ : new GenericRoot(reference.params, reference.bodyDef, reference.$, this, reference.hkt);
237
+ }
238
+ if (!this.resolved) {
239
+ // we're still parsing the scope itself, so defer compilation but
240
+ // add the node as a reference
241
+ Object.assign(this.referencesById, bound.referencesById);
242
+ }
243
+ return bound;
244
+ }
245
+ resolveRoot(name) {
246
+ return (this.maybeResolveRoot(name) ??
247
+ throwParseError(writeUnresolvableMessage(name)));
248
+ }
249
+ maybeResolveRoot(name) {
250
+ const result = this.maybeResolve(name);
251
+ if (hasArkKind(result, "generic"))
252
+ return;
253
+ return result;
254
+ }
255
+ /** If name is a valid reference to a submodule alias, return its resolution */
256
+ maybeResolveSubalias(name) {
257
+ return (maybeResolveSubalias(this.aliases, name) ??
258
+ maybeResolveSubalias(this.ambient, name));
259
+ }
260
+ get ambient() {
261
+ return $ark.ambient;
262
+ }
263
+ maybeResolve(name) {
264
+ const cached = this.resolutions[name];
265
+ if (cached) {
266
+ if (typeof cached !== "string")
267
+ return this.bindReference(cached);
268
+ const v = nodesByRegisteredId[cached];
269
+ if (hasArkKind(v, "root"))
270
+ return (this.resolutions[name] = v);
271
+ if (hasArkKind(v, "context")) {
272
+ if (v.phase === "resolving") {
273
+ return this.node("alias", { reference: `$${name}` }, { prereduced: true });
274
+ }
275
+ if (v.phase === "resolved") {
276
+ return throwInternalError(`Unexpected resolved context for was uncached by its scope: ${printable(v)}`);
277
+ }
278
+ v.phase = "resolving";
279
+ const node = this.bindReference(this.parseOwnDefinitionFormat(v.def, v));
280
+ v.phase = "resolved";
281
+ nodesByRegisteredId[node.id] = node;
282
+ nodesByRegisteredId[v.id] = node;
283
+ return (this.resolutions[name] = node);
284
+ }
285
+ return throwInternalError(`Unexpected nodesById entry for ${cached}: ${printable(v)}`);
286
+ }
287
+ let def = this.aliases[name] ?? this.ambient?.[name];
288
+ if (!def)
289
+ return this.maybeResolveSubalias(name);
290
+ def = this.normalizeRootScopeValue(def);
291
+ if (hasArkKind(def, "generic"))
292
+ return (this.resolutions[name] = this.bindReference(def));
293
+ if (hasArkKind(def, "module")) {
294
+ if (!def.root)
295
+ throwParseError(writeMissingSubmoduleAccessMessage(name));
296
+ return (this.resolutions[name] = this.bindReference(def.root));
297
+ }
298
+ return (this.resolutions[name] = this.parse(def, {
299
+ alias: name
300
+ }));
301
+ }
302
+ createParseContext(input) {
303
+ const id = input.id ?? registerNodeId(input.prefix);
304
+ return (nodesByRegisteredId[id] = Object.assign(input, {
305
+ [arkKind]: "context",
306
+ $: this,
307
+ id,
308
+ phase: "unresolved"
309
+ }));
310
+ }
311
+ traversal(root) {
312
+ return new Traversal(root, this.resolvedConfig);
313
+ }
314
+ import(...names) {
315
+ return new RootModule(flatMorph(this.export(...names), (alias, value) => [
316
+ `#${alias}`,
317
+ value
318
+ ]));
319
+ }
320
+ precompilation;
321
+ _exportedResolutions;
322
+ _exports;
323
+ export(...names) {
324
+ if (!this._exports) {
325
+ this._exports = {};
326
+ for (const name of this.exportedNames) {
327
+ const def = this.aliases[name];
328
+ this._exports[name] =
329
+ hasArkKind(def, "module") ?
330
+ bindModule(def, this)
331
+ : bootstrapAliasReferences(this.maybeResolve(name));
332
+ }
333
+ // force node.resolution getter evaluation
334
+ // eslint-disable-next-line @typescript-eslint/no-unused-expressions
335
+ for (const node of this.lazyResolutions)
336
+ node.resolution;
337
+ this._exportedResolutions = resolutionsOfModule(this, this._exports);
338
+ this._json = resolutionsToJson(this._exportedResolutions);
339
+ Object.assign(this.resolutions, this._exportedResolutions);
340
+ this.references = Object.values(this.referencesById);
341
+ if (!this.resolvedConfig.jitless) {
342
+ const precompiler = precompileReferences(this.references);
343
+ this.precompilation = precompiler.write(rootScopeFnName, 4);
344
+ bindPrecompilation(this.references, precompiler);
345
+ }
346
+ this.resolved = true;
347
+ }
348
+ const namesToExport = names.length ? names : this.exportedNames;
349
+ return new RootModule(flatMorph(namesToExport, (_, name) => [
350
+ name,
351
+ this._exports[name]
352
+ ]));
353
+ }
354
+ resolve(name) {
355
+ return this.export()[name];
356
+ }
357
+ node = (kinds, nodeSchema, opts = {}) => {
358
+ const ctxOrNode = this.preparseNode(kinds, nodeSchema, opts);
359
+ if (isNode(ctxOrNode))
360
+ return this.bindReference(ctxOrNode);
361
+ const ctx = this.createParseContext(ctxOrNode);
362
+ const node = parseNode(ctx);
363
+ const bound = this.bindReference(node);
364
+ return (nodesByRegisteredId[ctx.id] = bound);
365
+ };
366
+ parse = (def, opts = {}) => this.finalize(this.parseDefinition(def, opts));
367
+ parseDefinition(def, opts = {}) {
368
+ if (hasArkKind(def, "root"))
369
+ return this.bindReference(def);
370
+ const ctxInputOrNode = this.preparseOwnDefinitionFormat(def, opts);
371
+ if (hasArkKind(ctxInputOrNode, "root"))
372
+ return this.bindReference(ctxInputOrNode);
373
+ const ctx = this.createParseContext(ctxInputOrNode);
374
+ nodesByRegisteredId[ctx.id] = ctx;
375
+ let node = this.bindReference(this.parseOwnDefinitionFormat(def, ctx));
376
+ // if the node is recursive e.g. { box: "this" }, we need to make sure it
377
+ // has the original id from context so that its references compile correctly
378
+ if (node.isCyclic)
379
+ node = withId(node, ctx.id);
380
+ nodesByRegisteredId[ctx.id] = node;
381
+ return node;
382
+ }
383
+ finalize(node) {
384
+ bootstrapAliasReferences(node);
385
+ if (!node.precompilation && !this.resolvedConfig.jitless)
386
+ precompile(node.references);
387
+ return node;
388
+ }
389
+ }
390
+ export class SchemaScope extends BaseScope {
391
+ parseOwnDefinitionFormat(def, ctx) {
392
+ return parseNode(ctx);
393
+ }
394
+ preparseOwnDefinitionFormat(schema, opts) {
395
+ return this.preparseNode(schemaKindOf(schema), schema, opts);
396
+ }
397
+ preparseOwnAliasEntry(k, v) {
398
+ return [k, v];
399
+ }
400
+ normalizeRootScopeValue(v) {
401
+ return v;
402
+ }
403
+ }
404
+ const bootstrapAliasReferences = (resolution) => {
405
+ const aliases = resolution.references.filter(node => node.hasKind("alias"));
406
+ for (const aliasNode of aliases) {
407
+ Object.assign(aliasNode.referencesById, aliasNode.resolution.referencesById);
408
+ for (const ref of resolution.references) {
409
+ if (aliasNode.id in ref.referencesById)
410
+ Object.assign(ref.referencesById, aliasNode.referencesById);
411
+ }
412
+ }
413
+ return resolution;
414
+ };
415
+ const resolutionsToJson = (resolutions) => flatMorph(resolutions, (k, v) => [
416
+ k,
417
+ hasArkKind(v, "root") || hasArkKind(v, "generic") ? v.json
418
+ : hasArkKind(v, "module") ? resolutionsToJson(v)
419
+ : throwInternalError(`Unexpected resolution ${printable(v)}`)
420
+ ]);
421
+ const maybeResolveSubalias = (base, name) => {
422
+ const dotIndex = name.indexOf(".");
423
+ if (dotIndex === -1)
424
+ return;
425
+ const dotPrefix = name.slice(0, dotIndex);
426
+ const prefixSchema = base[dotPrefix];
427
+ // if the name includes ".", but the prefix is not an alias, it
428
+ // might be something like a decimal literal, so just fall through to return
429
+ if (prefixSchema === undefined)
430
+ return;
431
+ if (!hasArkKind(prefixSchema, "module"))
432
+ return throwParseError(writeNonSubmoduleDotMessage(dotPrefix));
433
+ const subalias = name.slice(dotIndex + 1);
434
+ const resolution = prefixSchema[subalias];
435
+ if (resolution === undefined)
436
+ return maybeResolveSubalias(prefixSchema, subalias);
437
+ if (hasArkKind(resolution, "root") || hasArkKind(resolution, "generic"))
438
+ return resolution;
439
+ if (hasArkKind(resolution, "module")) {
440
+ return (resolution.root ??
441
+ throwParseError(writeMissingSubmoduleAccessMessage(name)));
442
+ }
443
+ throwInternalError(`Unexpected resolution for alias '${name}': ${printable(resolution)}`);
444
+ };
445
+ export const schemaScope = (aliases, config) => new SchemaScope(aliases, config);
446
+ export const rootSchemaScope = new SchemaScope({});
447
+ export const parseAsSchema = (def, opts) => {
448
+ try {
449
+ return rootSchema(def, opts);
450
+ }
451
+ catch (e) {
452
+ if (e instanceof ParseError)
453
+ return e;
454
+ throw e;
455
+ }
456
+ };
457
+ const resolutionsOfModule = ($, typeSet) => {
458
+ const result = {};
459
+ for (const k in typeSet) {
460
+ const v = typeSet[k];
461
+ if (hasArkKind(v, "module")) {
462
+ const innerResolutions = resolutionsOfModule($, v);
463
+ const prefixedResolutions = flatMorph(innerResolutions, (innerK, innerV) => [`${k}.${innerK}`, innerV]);
464
+ Object.assign(result, prefixedResolutions);
465
+ }
466
+ else if (hasArkKind(v, "root") || hasArkKind(v, "generic"))
467
+ result[k] = v;
468
+ else
469
+ throwInternalError(`Unexpected scope resolution ${printable(v)}`);
470
+ }
471
+ return result;
472
+ };
473
+ export const writeUnresolvableMessage = (token) => `'${token}' is unresolvable`;
474
+ export const writeNonSubmoduleDotMessage = (name) => `'${name}' must reference a module to be accessed using dot syntax`;
475
+ export const writeMissingSubmoduleAccessMessage = (name) => `Reference to submodule '${name}' must specify an alias`;
476
+ // ensure the scope is resolved so JIT will be applied to future types
477
+ rootSchemaScope.export();
478
+ export const rootSchema = rootSchemaScope.schema;
479
+ export const node = rootSchemaScope.node;
480
+ export const defineSchema = rootSchemaScope.defineSchema;
481
+ export const genericNode = rootSchemaScope.generic;
@@ -0,0 +1,62 @@
1
+ import { CastableBase, type Fn } from "@ark/util";
2
+ import type { BaseNode } from "../node.ts";
3
+ import type { NodeId } from "../parse.ts";
4
+ import type { TraversalKind } from "./traversal.ts";
5
+ export type CoercibleValue = string | number | boolean | null | undefined;
6
+ export declare class CompiledFunction<compiledSignature = (...args: unknown[]) => unknown, args extends readonly string[] = readonly string[]> extends CastableBase<{
7
+ [k in args[number]]: k;
8
+ }> {
9
+ readonly argNames: args;
10
+ readonly body = "";
11
+ constructor(...args: args);
12
+ indentation: number;
13
+ indent(): this;
14
+ dedent(): this;
15
+ prop(key: PropertyKey, optional?: boolean): string;
16
+ index(key: string | number, optional?: boolean): string;
17
+ line(statement: string): this;
18
+ const(identifier: string, expression: CoercibleValue): this;
19
+ let(identifier: string, expression: CoercibleValue): this;
20
+ set(identifier: string, expression: CoercibleValue): this;
21
+ if(condition: string, then: (self: this) => this): this;
22
+ elseIf(condition: string, then: (self: this) => this): this;
23
+ else(then: (self: this) => this): this;
24
+ /** Current index is "i" */
25
+ for(until: string, body: (self: this) => this, initialValue?: CoercibleValue): this;
26
+ /** Current key is "k" */
27
+ forIn(object: string, body: (self: this) => this): this;
28
+ block(prefix: string, contents: (self: this) => this, suffix?: string): this;
29
+ return(expression?: CoercibleValue): this;
30
+ write(name?: string, indent?: number): string;
31
+ compile(): compiledSignature;
32
+ }
33
+ export declare const compileSerializedValue: (value: unknown) => string;
34
+ export declare const compileLiteralPropAccess: (key: PropertyKey, optional?: boolean) => string;
35
+ export declare const serializeLiteralKey: (key: PropertyKey) => string;
36
+ export declare const indexPropAccess: (key: string, optional?: boolean) => string;
37
+ export interface InvokeOptions extends ReferenceOptions {
38
+ arg?: string;
39
+ }
40
+ export interface ReferenceOptions {
41
+ kind?: TraversalKind;
42
+ bind?: string;
43
+ }
44
+ export declare namespace NodeCompiler {
45
+ interface Context {
46
+ kind: TraversalKind;
47
+ optimistic?: true;
48
+ }
49
+ }
50
+ export declare class NodeCompiler extends CompiledFunction<Fn, ["data", "ctx"]> {
51
+ traversalKind: TraversalKind;
52
+ optimistic: boolean;
53
+ constructor(ctx: NodeCompiler.Context);
54
+ invoke(node: BaseNode | NodeId, opts?: InvokeOptions): string;
55
+ referenceToId(id: NodeId, opts?: ReferenceOptions): string;
56
+ requiresContextFor(node: BaseNode): boolean;
57
+ initializeErrorCount(): this;
58
+ returnIfFail(): this;
59
+ returnIfFailFast(): this;
60
+ traverseKey(keyExpression: string, accessExpression: string, node: BaseNode): this;
61
+ check(node: BaseNode, opts?: InvokeOptions): this;
62
+ }
@@ -0,0 +1,145 @@
1
+ import { CastableBase, DynamicFunction, hasDomain, isDotAccessible, serializePrimitive } from "@ark/util";
2
+ import { registeredReference } from "./registry.js";
3
+ export class CompiledFunction extends CastableBase {
4
+ argNames;
5
+ body = "";
6
+ constructor(...args) {
7
+ super();
8
+ this.argNames = args;
9
+ for (const arg of args) {
10
+ if (arg in this) {
11
+ throw new Error(`Arg name '${arg}' would overwrite an existing property on FunctionBody`);
12
+ }
13
+ ;
14
+ this[arg] = arg;
15
+ }
16
+ }
17
+ indentation = 0;
18
+ indent() {
19
+ this.indentation += 4;
20
+ return this;
21
+ }
22
+ dedent() {
23
+ this.indentation -= 4;
24
+ return this;
25
+ }
26
+ prop(key, optional = false) {
27
+ return compileLiteralPropAccess(key, optional);
28
+ }
29
+ index(key, optional = false) {
30
+ return indexPropAccess(`${key}`, optional);
31
+ }
32
+ line(statement) {
33
+ ;
34
+ this.body += `${" ".repeat(this.indentation)}${statement}\n`;
35
+ return this;
36
+ }
37
+ const(identifier, expression) {
38
+ this.line(`const ${identifier} = ${expression}`);
39
+ return this;
40
+ }
41
+ let(identifier, expression) {
42
+ return this.line(`let ${identifier} = ${expression}`);
43
+ }
44
+ set(identifier, expression) {
45
+ return this.line(`${identifier} = ${expression}`);
46
+ }
47
+ if(condition, then) {
48
+ return this.block(`if (${condition})`, then);
49
+ }
50
+ elseIf(condition, then) {
51
+ return this.block(`else if (${condition})`, then);
52
+ }
53
+ else(then) {
54
+ return this.block("else", then);
55
+ }
56
+ /** Current index is "i" */
57
+ for(until, body, initialValue = 0) {
58
+ return this.block(`for (let i = ${initialValue}; ${until}; i++)`, body);
59
+ }
60
+ /** Current key is "k" */
61
+ forIn(object, body) {
62
+ return this.block(`for (const k in ${object})`, body);
63
+ }
64
+ block(prefix, contents, suffix = "") {
65
+ this.line(`${prefix} {`);
66
+ this.indent();
67
+ contents(this);
68
+ this.dedent();
69
+ return this.line(`}${suffix}`);
70
+ }
71
+ return(expression = "") {
72
+ return this.line(`return ${expression}`);
73
+ }
74
+ write(name = "anonymous", indent = 0) {
75
+ return `${name}(${this.argNames.join(", ")}) { ${indent ?
76
+ this.body
77
+ .split("\n")
78
+ .map(l => " ".repeat(indent) + `${l}`)
79
+ .join("\n")
80
+ : this.body} }`;
81
+ }
82
+ compile() {
83
+ return new DynamicFunction(...this.argNames, this.body);
84
+ }
85
+ }
86
+ export const compileSerializedValue = (value) => hasDomain(value, "object") || typeof value === "symbol" ?
87
+ registeredReference(value)
88
+ : serializePrimitive(value);
89
+ export const compileLiteralPropAccess = (key, optional = false) => {
90
+ if (typeof key === "string" && isDotAccessible(key))
91
+ return `${optional ? "?" : ""}.${key}`;
92
+ return indexPropAccess(serializeLiteralKey(key), optional);
93
+ };
94
+ export const serializeLiteralKey = (key) => typeof key === "symbol" ? registeredReference(key) : JSON.stringify(key);
95
+ export const indexPropAccess = (key, optional = false) => `${optional ? "?." : ""}[${key}]`;
96
+ export class NodeCompiler extends CompiledFunction {
97
+ traversalKind;
98
+ optimistic;
99
+ constructor(ctx) {
100
+ super("data", "ctx");
101
+ this.traversalKind = ctx.kind;
102
+ this.optimistic = ctx.optimistic === true;
103
+ }
104
+ invoke(node, opts) {
105
+ const arg = opts?.arg ?? this.data;
106
+ const requiresContext = typeof node === "string" ? true : this.requiresContextFor(node);
107
+ const id = typeof node === "string" ? node : node.id;
108
+ if (requiresContext)
109
+ return `${this.referenceToId(id, opts)}(${arg}, ${this.ctx})`;
110
+ return `${this.referenceToId(id, opts)}(${arg})`;
111
+ }
112
+ referenceToId(id, opts) {
113
+ const invokedKind = opts?.kind ?? this.traversalKind;
114
+ const base = `this.${id}${invokedKind}`;
115
+ return opts?.bind ? `${base}.bind(${opts?.bind})` : base;
116
+ }
117
+ requiresContextFor(node) {
118
+ return this.traversalKind === "Apply" || node.allowsRequiresContext;
119
+ }
120
+ initializeErrorCount() {
121
+ return this.const("errorCount", "ctx.currentErrorCount");
122
+ }
123
+ returnIfFail() {
124
+ return this.if("ctx.currentErrorCount > errorCount", () => this.return());
125
+ }
126
+ returnIfFailFast() {
127
+ return this.if("ctx.failFast && ctx.currentErrorCount > errorCount", () => this.return());
128
+ }
129
+ traverseKey(keyExpression, accessExpression, node) {
130
+ const requiresContext = this.requiresContextFor(node);
131
+ if (requiresContext)
132
+ this.line(`${this.ctx}.path.push(${keyExpression})`);
133
+ this.check(node, {
134
+ arg: accessExpression
135
+ });
136
+ if (requiresContext)
137
+ this.line(`${this.ctx}.path.pop()`);
138
+ return this;
139
+ }
140
+ check(node, opts) {
141
+ return this.traversalKind === "Allows" ?
142
+ this.if(`!${this.invoke(node, opts)}`, () => this.return(false))
143
+ : this.line(this.invoke(node, opts));
144
+ }
145
+ }