@telorun/cel 0.0.0-stage → 0.107.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (223) hide show
  1. package/LICENSE +17 -0
  2. package/README.md +281 -2
  3. package/dist/activation.d.ts +27 -0
  4. package/dist/activation.d.ts.map +1 -0
  5. package/dist/activation.js +24 -0
  6. package/dist/backend-runtime.d.ts +146 -0
  7. package/dist/backend-runtime.d.ts.map +1 -0
  8. package/dist/backend-runtime.js +322 -0
  9. package/dist/bounded-cache.d.ts +21 -0
  10. package/dist/bounded-cache.d.ts.map +1 -0
  11. package/dist/bounded-cache.js +42 -0
  12. package/dist/catalog-runtime.d.ts +59 -0
  13. package/dist/catalog-runtime.d.ts.map +1 -0
  14. package/dist/catalog-runtime.js +785 -0
  15. package/dist/cel-expression.d.ts +32 -0
  16. package/dist/cel-expression.d.ts.map +1 -0
  17. package/dist/cel-expression.js +29 -0
  18. package/dist/cel-map-value.d.ts +34 -0
  19. package/dist/cel-map-value.d.ts.map +1 -0
  20. package/dist/cel-map-value.js +74 -0
  21. package/dist/cel-program.d.ts +44 -0
  22. package/dist/cel-program.d.ts.map +1 -0
  23. package/dist/cel-program.js +72 -0
  24. package/dist/cel-type.d.ts +131 -0
  25. package/dist/cel-type.d.ts.map +1 -0
  26. package/dist/cel-type.js +293 -0
  27. package/dist/cel-value.d.ts +159 -0
  28. package/dist/cel-value.d.ts.map +1 -0
  29. package/dist/cel-value.js +225 -0
  30. package/dist/check-diagnostic.d.ts +53 -0
  31. package/dist/check-diagnostic.d.ts.map +1 -0
  32. package/dist/check-diagnostic.js +66 -0
  33. package/dist/checker.d.ts +77 -0
  34. package/dist/checker.d.ts.map +1 -0
  35. package/dist/checker.js +721 -0
  36. package/dist/closure-backend.d.ts +21 -0
  37. package/dist/closure-backend.d.ts.map +1 -0
  38. package/dist/closure-backend.js +436 -0
  39. package/dist/comprehension-bindings.d.ts +33 -0
  40. package/dist/comprehension-bindings.d.ts.map +1 -0
  41. package/dist/comprehension-bindings.js +50 -0
  42. package/dist/comprehension-runtime.d.ts +44 -0
  43. package/dist/comprehension-runtime.d.ts.map +1 -0
  44. package/dist/comprehension-runtime.js +137 -0
  45. package/dist/declared-chain.d.ts +35 -0
  46. package/dist/declared-chain.d.ts.map +1 -0
  47. package/dist/declared-chain.js +36 -0
  48. package/dist/duration-value.d.ts +59 -0
  49. package/dist/duration-value.d.ts.map +1 -0
  50. package/dist/duration-value.js +135 -0
  51. package/dist/emitted-module.d.ts +207 -0
  52. package/dist/emitted-module.d.ts.map +1 -0
  53. package/dist/emitted-module.js +359 -0
  54. package/dist/engine-version.d.ts +3 -0
  55. package/dist/engine-version.d.ts.map +1 -0
  56. package/dist/engine-version.js +8 -0
  57. package/dist/environment-digest.d.ts +44 -0
  58. package/dist/environment-digest.d.ts.map +1 -0
  59. package/dist/environment-digest.js +98 -0
  60. package/dist/environment.d.ts +283 -0
  61. package/dist/environment.d.ts.map +1 -0
  62. package/dist/environment.js +459 -0
  63. package/dist/function-catalog.d.ts +66 -0
  64. package/dist/function-catalog.d.ts.map +1 -0
  65. package/dist/function-catalog.js +77 -0
  66. package/dist/function-registry.d.ts +78 -0
  67. package/dist/function-registry.d.ts.map +1 -0
  68. package/dist/function-registry.js +189 -0
  69. package/dist/index.d.ts +91 -0
  70. package/dist/index.d.ts.map +1 -0
  71. package/dist/index.js +59 -0
  72. package/dist/integer-arithmetic.d.ts +27 -0
  73. package/dist/integer-arithmetic.d.ts.map +1 -0
  74. package/dist/integer-arithmetic.js +58 -0
  75. package/dist/js-emitter.d.ts +132 -0
  76. package/dist/js-emitter.d.ts.map +1 -0
  77. package/dist/js-emitter.js +562 -0
  78. package/dist/json-schema-type.d.ts +182 -0
  79. package/dist/json-schema-type.d.ts.map +1 -0
  80. package/dist/json-schema-type.js +487 -0
  81. package/dist/json-text-scan.d.ts +28 -0
  82. package/dist/json-text-scan.d.ts.map +1 -0
  83. package/dist/json-text-scan.js +159 -0
  84. package/dist/lexer.d.ts +103 -0
  85. package/dist/lexer.d.ts.map +1 -0
  86. package/dist/lexer.js +458 -0
  87. package/dist/macro-check.d.ts +33 -0
  88. package/dist/macro-check.d.ts.map +1 -0
  89. package/dist/macro-check.js +162 -0
  90. package/dist/macro-shape.d.ts +24 -0
  91. package/dist/macro-shape.d.ts.map +1 -0
  92. package/dist/macro-shape.js +55 -0
  93. package/dist/member-read.d.ts +52 -0
  94. package/dist/member-read.d.ts.map +1 -0
  95. package/dist/member-read.js +125 -0
  96. package/dist/namespace-resolution.d.ts +35 -0
  97. package/dist/namespace-resolution.d.ts.map +1 -0
  98. package/dist/namespace-resolution.js +160 -0
  99. package/dist/nominal-type.d.ts +63 -0
  100. package/dist/nominal-type.d.ts.map +1 -0
  101. package/dist/nominal-type.js +98 -0
  102. package/dist/nullable-access.d.ts +38 -0
  103. package/dist/nullable-access.d.ts.map +1 -0
  104. package/dist/nullable-access.js +93 -0
  105. package/dist/parse-limits.d.ts +26 -0
  106. package/dist/parse-limits.d.ts.map +1 -0
  107. package/dist/parse-limits.js +21 -0
  108. package/dist/parser.d.ts +48 -0
  109. package/dist/parser.d.ts.map +1 -0
  110. package/dist/parser.js +503 -0
  111. package/dist/qualified-calls.d.ts +22 -0
  112. package/dist/qualified-calls.d.ts.map +1 -0
  113. package/dist/qualified-calls.js +27 -0
  114. package/dist/regular-expression.d.ts +48 -0
  115. package/dist/regular-expression.d.ts.map +1 -0
  116. package/dist/regular-expression.js +77 -0
  117. package/dist/reserved-words.d.ts +52 -0
  118. package/dist/reserved-words.d.ts.map +1 -0
  119. package/dist/reserved-words.js +77 -0
  120. package/dist/resolved-call.d.ts +33 -0
  121. package/dist/resolved-call.d.ts.map +1 -0
  122. package/dist/resolved-call.js +15 -0
  123. package/dist/root-references.d.ts +23 -0
  124. package/dist/root-references.d.ts.map +1 -0
  125. package/dist/root-references.js +120 -0
  126. package/dist/runtime-library.d.ts +56 -0
  127. package/dist/runtime-library.d.ts.map +1 -0
  128. package/dist/runtime-library.js +545 -0
  129. package/dist/serializer.d.ts +24 -0
  130. package/dist/serializer.d.ts.map +1 -0
  131. package/dist/serializer.js +240 -0
  132. package/dist/sha256.d.ts +20 -0
  133. package/dist/sha256.d.ts.map +1 -0
  134. package/dist/sha256.js +103 -0
  135. package/dist/signature.d.ts +72 -0
  136. package/dist/signature.d.ts.map +1 -0
  137. package/dist/signature.js +61 -0
  138. package/dist/signatures/function-catalog.json +788 -0
  139. package/dist/signatures/standard-library.json +229 -0
  140. package/dist/standard-library.d.ts +41 -0
  141. package/dist/standard-library.d.ts.map +1 -0
  142. package/dist/standard-library.js +85 -0
  143. package/dist/syntax-diagnostic.d.ts +61 -0
  144. package/dist/syntax-diagnostic.d.ts.map +1 -0
  145. package/dist/syntax-diagnostic.js +28 -0
  146. package/dist/syntax-tree.d.ts +160 -0
  147. package/dist/syntax-tree.d.ts.map +1 -0
  148. package/dist/syntax-tree.js +58 -0
  149. package/dist/timestamp-value.d.ts +53 -0
  150. package/dist/timestamp-value.d.ts.map +1 -0
  151. package/dist/timestamp-value.js +223 -0
  152. package/dist/tree-equality.d.ts +15 -0
  153. package/dist/tree-equality.d.ts.map +1 -0
  154. package/dist/tree-equality.js +105 -0
  155. package/dist/type-expression.d.ts +26 -0
  156. package/dist/type-expression.d.ts.map +1 -0
  157. package/dist/type-expression.js +134 -0
  158. package/dist/value-equality.d.ts +38 -0
  159. package/dist/value-equality.d.ts.map +1 -0
  160. package/dist/value-equality.js +196 -0
  161. package/dist/value-text.d.ts +25 -0
  162. package/dist/value-text.d.ts.map +1 -0
  163. package/dist/value-text.js +44 -0
  164. package/dist/zoned-calendar.d.ts +61 -0
  165. package/dist/zoned-calendar.d.ts.map +1 -0
  166. package/dist/zoned-calendar.js +143 -0
  167. package/package.json +56 -3
  168. package/src/activation.ts +32 -0
  169. package/src/backend-runtime.ts +454 -0
  170. package/src/bounded-cache.ts +45 -0
  171. package/src/catalog-runtime.ts +921 -0
  172. package/src/cel-expression.ts +53 -0
  173. package/src/cel-map-value.ts +86 -0
  174. package/src/cel-program.ts +103 -0
  175. package/src/cel-type.ts +359 -0
  176. package/src/cel-value.ts +353 -0
  177. package/src/check-diagnostic.ts +102 -0
  178. package/src/checker.ts +932 -0
  179. package/src/closure-backend.ts +502 -0
  180. package/src/comprehension-bindings.ts +66 -0
  181. package/src/comprehension-runtime.ts +157 -0
  182. package/src/declared-chain.ts +45 -0
  183. package/src/duration-value.ts +145 -0
  184. package/src/emitted-module.ts +494 -0
  185. package/src/engine-version.ts +9 -0
  186. package/src/environment-digest.ts +111 -0
  187. package/src/environment.ts +740 -0
  188. package/src/function-catalog.ts +140 -0
  189. package/src/function-registry.ts +229 -0
  190. package/src/index.ts +386 -0
  191. package/src/integer-arithmetic.ts +64 -0
  192. package/src/js-emitter.ts +713 -0
  193. package/src/json-schema-type.ts +664 -0
  194. package/src/json-text-scan.ts +163 -0
  195. package/src/lexer.ts +562 -0
  196. package/src/macro-check.ts +191 -0
  197. package/src/macro-shape.ts +66 -0
  198. package/src/member-read.ts +126 -0
  199. package/src/namespace-resolution.ts +167 -0
  200. package/src/nominal-type.ts +149 -0
  201. package/src/nullable-access.ts +95 -0
  202. package/src/parse-limits.ts +36 -0
  203. package/src/parser.ts +554 -0
  204. package/src/qualified-calls.ts +39 -0
  205. package/src/regular-expression.ts +101 -0
  206. package/src/reserved-words.ts +94 -0
  207. package/src/resolved-call.ts +34 -0
  208. package/src/root-references.ts +126 -0
  209. package/src/runtime-library.ts +615 -0
  210. package/src/serializer.ts +246 -0
  211. package/src/sha256.ts +112 -0
  212. package/src/signature.ts +127 -0
  213. package/src/signatures/function-catalog.json +788 -0
  214. package/src/signatures/standard-library.json +235 -0
  215. package/src/standard-library.ts +149 -0
  216. package/src/syntax-diagnostic.ts +72 -0
  217. package/src/syntax-tree.ts +229 -0
  218. package/src/timestamp-value.ts +294 -0
  219. package/src/tree-equality.ts +130 -0
  220. package/src/type-expression.ts +160 -0
  221. package/src/value-equality.ts +201 -0
  222. package/src/value-text.ts +45 -0
  223. package/src/zoned-calendar.ts +178 -0
@@ -0,0 +1,132 @@
1
+ /**
2
+ * The JavaScript emitter: a tree compiled to **source**, not to closures.
3
+ *
4
+ * It decides nothing the closure backend decides differently. Every operator and standard
5
+ * function is the runtime library's, every comprehension is `comprehension-runtime.ts`, and
6
+ * every member read, name read, bool operand and call-site dispatch is `backend-runtime.ts`
7
+ * — so what this file produces is a tree of CALLS into those, in the same order, with the
8
+ * same short-circuit. That is why the two backends can be held to one answer case for case:
9
+ * the only thing that differs is how control gets from one call to the next.
10
+ *
11
+ * Three properties the shape of the output exists for:
12
+ *
13
+ * - **The runtime is a parameter, never an import.** The emitted module's default export is
14
+ * a factory; it names no specifier, so it loads from a `data:` URL, from a cache directory
15
+ * mounted anywhere, and under a host that resolves nothing. A module naming
16
+ * `@telorun/cel` would also silently accept a runtime of another version, which the cache
17
+ * key could not see.
18
+ * - **No bare property access implements a CEL read.** `a.b`, `a['b']`, `a[expr]`, `.?`,
19
+ * `[?]` and `has()` all emit a call to the member-read seam, so no key an author or a
20
+ * request wrote reaches a prototype, a method or a function property. The frame's own
21
+ * fields are the engine's structure and are read directly, as they are in a closure.
22
+ * - **Nothing is asynchronous.** No `async`, no `await`, no promise: a thenable is refused
23
+ * at the same doors, because the doors are the shared runtime's.
24
+ *
25
+ * Emission is **deterministic**: temporaries are numbered per emitted function in tree
26
+ * order, bindings per module in tree order, and every hoisted constant is keyed by its own
27
+ * text, so the same tree against the same environment is the same bytes.
28
+ */
29
+ import { type CompileTarget } from "./backend-runtime.js";
30
+ import type { CelNode } from "./syntax-tree.js";
31
+ /**
32
+ * The names an emitted module destructures from the runtime it is handed, in the order it
33
+ * destructures them. It is the module's whole contract with the engine: `emitterRuntime`
34
+ * (`emitted-module.ts`) builds an object with exactly these keys, and a module emitted by
35
+ * one engine against another's runtime fails at load rather than running on a missing
36
+ * binding — which is the second reason the key carries the engine version.
37
+ */
38
+ export declare const RUNTIME_BINDINGS: readonly ["asyncValueRefused", "boolOperand", "callSite", "celAll", "celError", "celExists", "celExistsOne", "celFilter", "celIterable", "celMapComprehension", "celMapFromEntries", "celSome", "celUint", "constants", "hasMember", "isCelError", "isCelOptional", "none", "optionalEntry", "optionalOfNonZero", "readHostValue", "readName", "readNameChain", "readThrough", "searchNameChain"];
39
+ export type RuntimeBinding = (typeof RUNTIME_BINDINGS)[number];
40
+ /**
41
+ * One module's worth of emission. The hoist table is shared by every expression in the
42
+ * module, so two expressions reading the same name share one range and one rest-list: a
43
+ * constant allocated per evaluation is the cost the closure backend does not pay, and
44
+ * hoisting is how the emitter does not pay it either.
45
+ */
46
+ export declare class ModuleEmitter {
47
+ private readonly target;
48
+ private readonly hoisted;
49
+ private readonly hoistedByText;
50
+ private locals;
51
+ private bindings;
52
+ constructor(target: CompileTarget);
53
+ /** The source of one expression's function: a `CelStep` over the evaluation frame. */
54
+ emitFunction(root: CelNode): string;
55
+ /** A fresh function's temporaries, drawing names from the module's own numbering. */
56
+ private temporaries;
57
+ /** The `const` lines every emitted expression reads, in first-use order. */
58
+ hoistedLines(): readonly string[];
59
+ private hoist;
60
+ private range;
61
+ /**
62
+ * The name a comprehension's element is bound to: a **parameter** of the body function,
63
+ * numbered per module so a nested body can never shadow the one around it.
64
+ */
65
+ private elementName;
66
+ private node;
67
+ /**
68
+ * A literal as the source that builds its value. A plain value is written inline; a uint
69
+ * and a bytes literal are **hoisted**, because each is an object and allocating one per
70
+ * evaluation would be work the closure backend does once at compile time.
71
+ */
72
+ private literal;
73
+ private ident;
74
+ /**
75
+ * A chain of plain member names rooted at a free name. The split over the names the host
76
+ * declared happens **here, at emit time**, through the same function the checker and the
77
+ * closure backend split it with — so the emitted code performs one activation read and
78
+ * then member reads, and can never read a different name than the one the check typed.
79
+ */
80
+ private chain;
81
+ private select;
82
+ private index;
83
+ private list;
84
+ private map;
85
+ /**
86
+ * `&&` and `||` carry an error-valued operand through: `false && <error>` is `false` and
87
+ * `true || <error>` is `true`, whichever side the error is on. The emitted form is the
88
+ * closure backend's branch order written out, so an error on one side and a non-bool on
89
+ * the other decide the same way.
90
+ */
91
+ private binary;
92
+ private conditional;
93
+ private anyCall;
94
+ /**
95
+ * One dispatch: evaluate the arguments, carry the first error out, then hand the values to
96
+ * the site. The site is hoisted, so it is built once per loaded module and holds the
97
+ * overloads it resolved — exactly as a compiled closure's does.
98
+ */
99
+ private call;
100
+ private qualifiedCall;
101
+ private macro;
102
+ /** `has(a.b)` — presence, which a missing key answers `false` rather than erroring. */
103
+ private has;
104
+ private celBind;
105
+ /** `optional.of(v)`, `optional.ofNonZeroValue(v)` and `optional.none()`. */
106
+ private optionalNamespace;
107
+ /** `opt.optMap(v, body)` wraps what the body answers; `optFlatMap` does not. */
108
+ private optionalBinding;
109
+ /**
110
+ * A comprehension. The body becomes a function of the element, exactly as the closure
111
+ * backend passes one, so the macro's meaning — including which error outranks which
112
+ * decided answer — stays `comprehension-runtime.ts`'s alone.
113
+ */
114
+ private comprehension;
115
+ /** A body a comprehension calls per element: its own function, with its own temporaries. */
116
+ private body;
117
+ /**
118
+ * Evaluate each expression in order and carry the first error out, then build the answer
119
+ * from the values. Every form that evaluates more than one thing goes through here, so a
120
+ * later operand is never evaluated after an earlier one failed — which is what makes an
121
+ * error a value that short-circuits rather than an exception.
122
+ */
123
+ private carrying;
124
+ }
125
+ /**
126
+ * Text as a JavaScript string literal. Every character outside printable ASCII is written
127
+ * as an escape — a lone surrogate, a line separator and a zero-width joiner all read back
128
+ * as themselves, and the emitted module is pure ASCII however its expressions were written,
129
+ * so no encoding assumption about the file it is stored in can change its meaning.
130
+ */
131
+ export declare function textSource(text: string): string;
132
+ //# sourceMappingURL=js-emitter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"js-emitter.d.ts","sourceRoot":"","sources":["../src/js-emitter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EAIL,KAAK,aAAa,EACnB,MAAM,sBA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