typesea 0.1.0 → 0.2.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.
- package/CHANGELOG.md +67 -6
- package/README.md +98 -17
- package/dist/adapters/index.d.ts +50 -8
- package/dist/adapters/index.d.ts.map +1 -1
- package/dist/adapters/index.js +169 -48
- package/dist/aot/index.d.ts +18 -2
- package/dist/aot/index.d.ts.map +1 -1
- package/dist/aot/index.js +93 -14
- package/dist/async/index.d.ts +28 -56
- package/dist/async/index.d.ts.map +1 -1
- package/dist/async/index.js +94 -37
- package/dist/builders/composite.d.ts +37 -6
- package/dist/builders/composite.d.ts.map +1 -1
- package/dist/builders/composite.js +84 -10
- package/dist/builders/index.d.ts +2 -0
- package/dist/builders/index.d.ts.map +1 -1
- package/dist/builders/index.js +2 -0
- package/dist/builders/modifier.d.ts +30 -5
- package/dist/builders/modifier.d.ts.map +1 -1
- package/dist/builders/modifier.js +38 -5
- package/dist/builders/object/guard.d.ts +18 -22
- package/dist/builders/object/guard.d.ts.map +1 -1
- package/dist/builders/object/guard.js +26 -26
- package/dist/builders/object/index.d.ts +2 -0
- package/dist/builders/object/index.d.ts.map +1 -1
- package/dist/builders/object/index.js +2 -0
- package/dist/builders/object/schema.d.ts +55 -9
- package/dist/builders/object/schema.d.ts.map +1 -1
- package/dist/builders/object/schema.js +92 -15
- package/dist/builders/object/types.d.ts +5 -31
- package/dist/builders/object/types.d.ts.map +1 -1
- package/dist/builders/object/types.js +2 -0
- package/dist/builders/scalar.d.ts +29 -8
- package/dist/builders/scalar.d.ts.map +1 -1
- package/dist/builders/scalar.js +33 -8
- package/dist/builders/table.d.ts +4 -0
- package/dist/builders/table.d.ts.map +1 -1
- package/dist/builders/table.js +4 -0
- package/dist/builders/types.d.ts +14 -4
- package/dist/builders/types.d.ts.map +1 -1
- package/dist/builders/types.js +2 -0
- package/dist/compile/check-composite.d.ts +22 -1
- package/dist/compile/check-composite.d.ts.map +1 -1
- package/dist/compile/check-composite.js +564 -24
- package/dist/compile/check-scalar.d.ts +78 -0
- package/dist/compile/check-scalar.d.ts.map +1 -1
- package/dist/compile/check-scalar.js +432 -1
- package/dist/compile/check.d.ts +12 -0
- package/dist/compile/check.d.ts.map +1 -1
- package/dist/compile/check.js +37 -0
- package/dist/compile/context.d.ts +47 -9
- package/dist/compile/context.d.ts.map +1 -1
- package/dist/compile/context.js +51 -8
- package/dist/compile/graph-predicate.d.ts +4 -2
- package/dist/compile/graph-predicate.d.ts.map +1 -1
- package/dist/compile/graph-predicate.js +1907 -171
- package/dist/compile/guard.d.ts +15 -24
- package/dist/compile/guard.d.ts.map +1 -1
- package/dist/compile/guard.js +158 -74
- package/dist/compile/index.d.ts +3 -1
- package/dist/compile/index.d.ts.map +1 -1
- package/dist/compile/index.js +2 -0
- package/dist/compile/issue.d.ts +110 -0
- package/dist/compile/issue.d.ts.map +1 -1
- package/dist/compile/issue.js +184 -1
- package/dist/compile/names.d.ts +12 -2
- package/dist/compile/names.d.ts.map +1 -1
- package/dist/compile/names.js +19 -3
- package/dist/compile/predicate.d.ts +24 -0
- package/dist/compile/predicate.d.ts.map +1 -1
- package/dist/compile/predicate.js +131 -5
- package/dist/compile/runtime.d.ts +80 -12
- package/dist/compile/runtime.d.ts.map +1 -1
- package/dist/compile/runtime.js +25 -6
- package/dist/compile/source.d.ts +10 -2
- package/dist/compile/source.d.ts.map +1 -1
- package/dist/compile/source.js +361 -26
- package/dist/compile/types.d.ts +20 -0
- package/dist/compile/types.d.ts.map +1 -1
- package/dist/compile/types.js +2 -0
- package/dist/decoder/index.d.ts +32 -46
- package/dist/decoder/index.d.ts.map +1 -1
- package/dist/decoder/index.js +102 -38
- package/dist/evaluate/check-composite.d.ts +59 -0
- package/dist/evaluate/check-composite.d.ts.map +1 -1
- package/dist/evaluate/check-composite.js +151 -3
- package/dist/evaluate/check-scalar.d.ts +16 -0
- package/dist/evaluate/check-scalar.d.ts.map +1 -1
- package/dist/evaluate/check-scalar.js +32 -0
- package/dist/evaluate/check.d.ts +7 -0
- package/dist/evaluate/check.d.ts.map +1 -1
- package/dist/evaluate/check.js +43 -0
- package/dist/evaluate/index.d.ts +2 -0
- package/dist/evaluate/index.d.ts.map +1 -1
- package/dist/evaluate/index.js +2 -0
- package/dist/evaluate/issue.d.ts +11 -1
- package/dist/evaluate/issue.d.ts.map +1 -1
- package/dist/evaluate/issue.js +15 -1
- package/dist/evaluate/predicate.d.ts +16 -5
- package/dist/evaluate/predicate.d.ts.map +1 -1
- package/dist/evaluate/predicate.js +20 -5
- package/dist/evaluate/shared.d.ts +59 -13
- package/dist/evaluate/shared.d.ts.map +1 -1
- package/dist/evaluate/shared.js +66 -8
- package/dist/evaluate/state.d.ts +35 -13
- package/dist/evaluate/state.d.ts.map +1 -1
- package/dist/evaluate/state.js +35 -2
- package/dist/guard/base.d.ts +79 -29
- package/dist/guard/base.d.ts.map +1 -1
- package/dist/guard/base.js +91 -29
- package/dist/guard/error.d.ts +10 -5
- package/dist/guard/error.d.ts.map +1 -1
- package/dist/guard/error.js +10 -5
- package/dist/guard/index.d.ts +2 -0
- package/dist/guard/index.d.ts.map +1 -1
- package/dist/guard/index.js +2 -0
- package/dist/guard/number.d.ts +26 -11
- package/dist/guard/number.d.ts.map +1 -1
- package/dist/guard/number.js +30 -11
- package/dist/guard/props.d.ts +27 -3
- package/dist/guard/props.d.ts.map +1 -1
- package/dist/guard/props.js +27 -3
- package/dist/guard/read.d.ts +62 -9
- package/dist/guard/read.d.ts.map +1 -1
- package/dist/guard/read.js +83 -10
- package/dist/guard/registry.d.ts +12 -2
- package/dist/guard/registry.d.ts.map +1 -1
- package/dist/guard/registry.js +15 -3
- package/dist/guard/string.d.ts +33 -13
- package/dist/guard/string.d.ts.map +1 -1
- package/dist/guard/string.js +37 -13
- package/dist/guard/types.d.ts +92 -40
- package/dist/guard/types.d.ts.map +1 -1
- package/dist/guard/types.js +2 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/internal/index.d.ts +42 -6
- package/dist/internal/index.d.ts.map +1 -1
- package/dist/internal/index.js +51 -8
- package/dist/ir/builder.d.ts +16 -126
- package/dist/ir/builder.d.ts.map +1 -1
- package/dist/ir/builder.js +77 -137
- package/dist/ir/freeze.d.ts +4 -0
- package/dist/ir/freeze.d.ts.map +1 -1
- package/dist/ir/freeze.js +59 -0
- package/dist/ir/index.d.ts +3 -1
- package/dist/ir/index.d.ts.map +1 -1
- package/dist/ir/index.js +2 -0
- package/dist/ir/regexp.d.ts +2 -0
- package/dist/ir/regexp.d.ts.map +1 -1
- package/dist/ir/regexp.js +2 -0
- package/dist/ir/types.d.ts +90 -55
- package/dist/ir/types.d.ts.map +1 -1
- package/dist/ir/types.js +2 -0
- package/dist/ir/validate.d.ts +8 -1
- package/dist/ir/validate.d.ts.map +1 -1
- package/dist/ir/validate.js +477 -61
- package/dist/issue/index.d.ts +41 -9
- package/dist/issue/index.d.ts.map +1 -1
- package/dist/issue/index.js +61 -11
- package/dist/json-schema/emit-combinator.d.ts +44 -4
- package/dist/json-schema/emit-combinator.d.ts.map +1 -1
- package/dist/json-schema/emit-combinator.js +44 -4
- package/dist/json-schema/emit-composite.d.ts +10 -0
- package/dist/json-schema/emit-composite.d.ts.map +1 -1
- package/dist/json-schema/emit-composite.js +15 -1
- package/dist/json-schema/emit-scalar.d.ts +26 -3
- package/dist/json-schema/emit-scalar.d.ts.map +1 -1
- package/dist/json-schema/emit-scalar.js +70 -9
- package/dist/json-schema/emit-types.d.ts +11 -1
- package/dist/json-schema/emit-types.d.ts.map +1 -1
- package/dist/json-schema/emit-types.js +2 -0
- package/dist/json-schema/emit.d.ts +12 -1
- package/dist/json-schema/emit.d.ts.map +1 -1
- package/dist/json-schema/emit.js +12 -1
- package/dist/json-schema/freeze.d.ts +13 -2
- package/dist/json-schema/freeze.d.ts.map +1 -1
- package/dist/json-schema/freeze.js +41 -8
- package/dist/json-schema/index.d.ts +16 -2
- package/dist/json-schema/index.d.ts.map +1 -1
- package/dist/json-schema/index.js +23 -3
- package/dist/json-schema/issue.d.ts +4 -1
- package/dist/json-schema/issue.d.ts.map +1 -1
- package/dist/json-schema/issue.js +4 -1
- package/dist/json-schema/read.d.ts +24 -3
- package/dist/json-schema/read.d.ts.map +1 -1
- package/dist/json-schema/read.js +59 -12
- package/dist/json-schema/types.d.ts +38 -15
- package/dist/json-schema/types.d.ts.map +1 -1
- package/dist/json-schema/types.js +2 -0
- package/dist/kind/index.d.ts +15 -28
- package/dist/kind/index.d.ts.map +1 -1
- package/dist/kind/index.js +15 -10
- package/dist/lower/index.d.ts +6 -1
- package/dist/lower/index.d.ts.map +1 -1
- package/dist/lower/index.js +411 -44
- package/dist/message/index.d.ts +46 -10
- package/dist/message/index.d.ts.map +1 -1
- package/dist/message/index.js +88 -17
- package/dist/optimize/algebraic.d.ts +54 -0
- package/dist/optimize/algebraic.d.ts.map +1 -0
- package/dist/optimize/algebraic.js +314 -0
- package/dist/optimize/compact.d.ts +8 -1
- package/dist/optimize/compact.d.ts.map +1 -1
- package/dist/optimize/compact.js +13 -2
- package/dist/optimize/domain.d.ts +16 -0
- package/dist/optimize/domain.d.ts.map +1 -0
- package/dist/optimize/domain.js +615 -0
- package/dist/optimize/fold-boolean.d.ts +17 -2
- package/dist/optimize/fold-boolean.d.ts.map +1 -1
- package/dist/optimize/fold-boolean.js +59 -14
- package/dist/optimize/fold-common.d.ts +43 -8
- package/dist/optimize/fold-common.d.ts.map +1 -1
- package/dist/optimize/fold-common.js +37 -6
- package/dist/optimize/fold-constraints.d.ts +33 -0
- package/dist/optimize/fold-constraints.d.ts.map +1 -0
- package/dist/optimize/fold-constraints.js +484 -0
- package/dist/optimize/fold-scalar.d.ts +98 -13
- package/dist/optimize/fold-scalar.d.ts.map +1 -1
- package/dist/optimize/fold-scalar.js +98 -13
- package/dist/optimize/fold.d.ts +8 -1
- package/dist/optimize/fold.d.ts.map +1 -1
- package/dist/optimize/fold.js +22 -2
- package/dist/optimize/index.d.ts +9 -1
- package/dist/optimize/index.d.ts.map +1 -1
- package/dist/optimize/index.js +18 -3
- package/dist/optimize/map-node.d.ts +3 -1
- package/dist/optimize/map-node.d.ts.map +1 -1
- package/dist/optimize/map-node.js +45 -3
- package/dist/optimize/peephole.d.ts +16 -0
- package/dist/optimize/peephole.d.ts.map +1 -0
- package/dist/optimize/peephole.js +254 -0
- package/dist/optimize/remap.d.ts +2 -0
- package/dist/optimize/remap.d.ts.map +1 -1
- package/dist/optimize/remap.js +2 -0
- package/dist/optimize/rewrite.d.ts +13 -8
- package/dist/optimize/rewrite.d.ts.map +1 -1
- package/dist/optimize/rewrite.js +13 -8
- package/dist/plan/cache.d.ts +9 -3
- package/dist/plan/cache.d.ts.map +1 -1
- package/dist/plan/cache.js +21 -5
- package/dist/plan/index.d.ts +2 -0
- package/dist/plan/index.d.ts.map +1 -1
- package/dist/plan/index.js +2 -0
- package/dist/plan/predicate.d.ts +2 -0
- package/dist/plan/predicate.d.ts.map +1 -1
- package/dist/plan/predicate.js +268 -29
- package/dist/plan/schema-predicate.d.ts +6 -0
- package/dist/plan/schema-predicate.d.ts.map +1 -1
- package/dist/plan/schema-predicate.js +117 -13
- package/dist/plan/types.d.ts +2 -0
- package/dist/plan/types.d.ts.map +1 -1
- package/dist/plan/types.js +2 -0
- package/dist/result/index.d.ts +19 -5
- package/dist/result/index.d.ts.map +1 -1
- package/dist/result/index.js +10 -2
- package/dist/schema/common.d.ts +69 -6
- package/dist/schema/common.d.ts.map +1 -1
- package/dist/schema/common.js +104 -10
- package/dist/schema/freeze.d.ts +4 -0
- package/dist/schema/freeze.d.ts.map +1 -1
- package/dist/schema/freeze.js +18 -0
- package/dist/schema/index.d.ts +3 -0
- package/dist/schema/index.d.ts.map +1 -1
- package/dist/schema/index.js +3 -0
- package/dist/schema/lazy.d.ts +4 -0
- package/dist/schema/lazy.d.ts.map +1 -1
- package/dist/schema/lazy.js +4 -0
- package/dist/schema/literal.d.ts +7 -1
- package/dist/schema/literal.d.ts.map +1 -1
- package/dist/schema/literal.js +7 -1
- package/dist/schema/types.d.ts +20 -96
- package/dist/schema/types.d.ts.map +1 -1
- package/dist/schema/types.js +5 -1
- package/dist/schema/undefined.d.ts +17 -0
- package/dist/schema/undefined.d.ts.map +1 -0
- package/dist/schema/undefined.js +72 -0
- package/dist/schema/validate.d.ts +8 -1
- package/dist/schema/validate.d.ts.map +1 -1
- package/dist/schema/validate.js +146 -55
- package/docs/api.md +57 -0
- package/docs/assets/benchmark-headline.svg +163 -0
- package/docs/engine-notes.md +58 -15
- package/docs/index.html +130 -110
- package/package.json +65 -65
package/dist/compile/check.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file compile/check.ts
|
|
3
3
|
* @brief Diagnostic validator function table emitter.
|
|
4
|
+
* @details Generated-source helpers keep the side-table ABI and JavaScript source shape
|
|
5
|
+
* stable across runtime and AOT emission.
|
|
4
6
|
*/
|
|
5
7
|
import { SchemaTag } from "../kind/index.js";
|
|
6
8
|
import { emitArrayCheck, emitDiscriminatedUnionCheck, emitObjectCheck, emitRecordCheck, emitTupleCheck } from "./check-composite.js";
|
|
@@ -10,12 +12,22 @@ import { emitIssue } from "./issue.js";
|
|
|
10
12
|
import { emitUnion } from "./predicate.js";
|
|
11
13
|
/**
|
|
12
14
|
* @brief emit check function.
|
|
15
|
+
* @details Generated-source helpers keep the side-table ABI and JavaScript source shape
|
|
16
|
+
* stable across runtime and AOT emission.
|
|
17
|
+
* @param schema Schema whose diagnostics should be emitted.
|
|
18
|
+
* @param context Shared code-generation context.
|
|
19
|
+
* @returns Generated diagnostic function name.
|
|
20
|
+
* @invariant The same schema object maps to one diagnostic function per bundle.
|
|
13
21
|
*/
|
|
14
22
|
export function emitCheckFunction(schema, context) {
|
|
15
23
|
const cached = context.checkFunctionNames.get(schema);
|
|
16
24
|
if (cached !== undefined) {
|
|
17
25
|
return cached;
|
|
18
26
|
}
|
|
27
|
+
/*
|
|
28
|
+
* Insert the placeholder before emitting the body. Recursive schemas can
|
|
29
|
+
* request this same function while the current body is still being built.
|
|
30
|
+
*/
|
|
19
31
|
const name = `c${String(context.checkFunctions.length)}`;
|
|
20
32
|
const source = {
|
|
21
33
|
name,
|
|
@@ -28,6 +40,10 @@ export function emitCheckFunction(schema, context) {
|
|
|
28
40
|
}
|
|
29
41
|
/**
|
|
30
42
|
* @brief emit check functions.
|
|
43
|
+
* @details Generated-source helpers keep the side-table ABI and JavaScript source shape
|
|
44
|
+
* stable across runtime and AOT emission.
|
|
45
|
+
* @param context Shared code-generation context with accumulated check sources.
|
|
46
|
+
* @returns Concatenated JavaScript function declarations.
|
|
31
47
|
*/
|
|
32
48
|
export function emitCheckFunctions(context) {
|
|
33
49
|
const chunks = new Array(context.checkFunctions.length);
|
|
@@ -42,6 +58,14 @@ export function emitCheckFunctions(context) {
|
|
|
42
58
|
}
|
|
43
59
|
/**
|
|
44
60
|
* @brief emit check body.
|
|
61
|
+
* @details Generated-source helpers keep the side-table ABI and JavaScript source shape
|
|
62
|
+
* stable across runtime and AOT emission.
|
|
63
|
+
* @param schema Schema represented by this diagnostic body.
|
|
64
|
+
* @param value Generated expression for the candidate value.
|
|
65
|
+
* @param path Generated expression for the mutable path stack.
|
|
66
|
+
* @param issues Generated expression for the issue buffer.
|
|
67
|
+
* @param context Shared code-generation context.
|
|
68
|
+
* @returns JavaScript source for diagnostic collection.
|
|
45
69
|
*/
|
|
46
70
|
function emitCheckBody(schema, value, path, issues, context) {
|
|
47
71
|
switch (schema.tag) {
|
|
@@ -87,11 +111,24 @@ function emitCheckBody(schema, value, path, issues, context) {
|
|
|
87
111
|
return emitCheckCall(schema.inner, value, path, issues, context);
|
|
88
112
|
case SchemaTag.Lazy:
|
|
89
113
|
case SchemaTag.Refine:
|
|
114
|
+
/*
|
|
115
|
+
* Lazy and refine schemas execute runtime logic that cannot be safely
|
|
116
|
+
* inlined into generated source. The `m` helper calls the interpreter
|
|
117
|
+
* diagnostic path through the dynamic schema side table.
|
|
118
|
+
*/
|
|
90
119
|
return `m(${String(pushSchema(context, schema))},${value},${path},${issues});`;
|
|
91
120
|
}
|
|
92
121
|
}
|
|
93
122
|
/**
|
|
94
123
|
* @brief emit check call.
|
|
124
|
+
* @details Generated-source helpers keep the side-table ABI and JavaScript source shape
|
|
125
|
+
* stable across runtime and AOT emission.
|
|
126
|
+
* @param schema Child schema to dispatch to.
|
|
127
|
+
* @param value Generated expression for the child value.
|
|
128
|
+
* @param path Generated expression for the mutable path stack.
|
|
129
|
+
* @param issues Generated expression for the issue buffer.
|
|
130
|
+
* @param context Shared code-generation context.
|
|
131
|
+
* @returns JavaScript source for invoking the child diagnostic function.
|
|
95
132
|
*/
|
|
96
133
|
function emitCheckCall(schema, value, path, issues, context) {
|
|
97
134
|
return `${emitCheckFunction(schema, context)}(${value},${path},${issues});`;
|
|
@@ -1,35 +1,73 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file compile/context.ts
|
|
3
3
|
* @brief Generated-source emitter side-table context.
|
|
4
|
+
* @details Generated-source helpers keep the side-table ABI and JavaScript source shape
|
|
5
|
+
* stable across runtime and AOT emission.
|
|
4
6
|
*/
|
|
5
7
|
import type { LiteralValue, Schema } from "../schema/index.js";
|
|
6
|
-
import type { EmitContext } from "./types.js";
|
|
8
|
+
import type { CompileMode, EmitContext } from "./types.js";
|
|
7
9
|
/**
|
|
8
|
-
* @brief
|
|
10
|
+
* @brief Create one mutable source-emission context.
|
|
11
|
+
* @details Generated-source helpers keep the side-table ABI and JavaScript source shape
|
|
12
|
+
* stable across runtime and AOT emission.
|
|
13
|
+
* @param mode Compile mode that controls safety and allocation tradeoffs.
|
|
14
|
+
* @returns Fresh side-table context consumed by predicate and diagnostic emitters.
|
|
15
|
+
* @invariant Side tables are append-only during one bundle emission.
|
|
9
16
|
*/
|
|
10
|
-
export declare function createEmitContext(): EmitContext;
|
|
17
|
+
export declare function createEmitContext(mode: CompileMode): EmitContext;
|
|
11
18
|
/**
|
|
12
|
-
* @brief
|
|
19
|
+
* @brief Append a literal to the generated factory side table.
|
|
20
|
+
* @details Generated-source helpers keep the side-table ABI and JavaScript source shape
|
|
21
|
+
* stable across runtime and AOT emission.
|
|
22
|
+
* @param context Mutable emission context.
|
|
23
|
+
* @param value Literal value referenced by generated source.
|
|
24
|
+
* @returns Index used by generated code to read `l[index]`.
|
|
13
25
|
*/
|
|
14
26
|
export declare function pushLiteral(context: EmitContext, value: LiteralValue): number;
|
|
15
27
|
/**
|
|
16
|
-
* @brief
|
|
28
|
+
* @brief Append a regular expression to the generated factory side table.
|
|
29
|
+
* @details Generated-source helpers keep the side-table ABI and JavaScript source shape
|
|
30
|
+
* stable across runtime and AOT emission.
|
|
31
|
+
* @param context Mutable emission context.
|
|
32
|
+
* @param value Source RegExp from the schema.
|
|
33
|
+
* @returns Index used by generated code to read `r[index]`.
|
|
34
|
+
* @post The stored RegExp is cloned so generated validation does not mutate user state.
|
|
17
35
|
*/
|
|
18
36
|
export declare function pushRegex(context: EmitContext, value: RegExp): number;
|
|
19
37
|
/**
|
|
20
|
-
* @brief
|
|
38
|
+
* @brief Append a keyset to the generated factory side table.
|
|
39
|
+
* @details Generated-source helpers keep the side-table ABI and JavaScript source shape
|
|
40
|
+
* stable across runtime and AOT emission.
|
|
41
|
+
* @param context Mutable emission context.
|
|
42
|
+
* @param value Frozen or caller-owned key list used by object checks.
|
|
43
|
+
* @returns Index used by generated code to read `k[index]`.
|
|
21
44
|
*/
|
|
22
45
|
export declare function pushKeyset(context: EmitContext, value: readonly string[]): number;
|
|
23
46
|
/**
|
|
24
|
-
* @brief string
|
|
47
|
+
* @brief Return a generated expression for a string side-table entry.
|
|
48
|
+
* @details Generated-source helpers keep the side-table ABI and JavaScript source shape
|
|
49
|
+
* stable across runtime and AOT emission.
|
|
50
|
+
* @param context Mutable emission context.
|
|
51
|
+
* @param value String value to intern.
|
|
52
|
+
* @returns Generated expression of the form `u[index]`.
|
|
25
53
|
*/
|
|
26
54
|
export declare function stringRef(context: EmitContext, value: string): string;
|
|
27
55
|
/**
|
|
28
|
-
* @brief
|
|
56
|
+
* @brief Intern a string in the generated factory side table.
|
|
57
|
+
* @details Generated-source helpers keep the side-table ABI and JavaScript source shape
|
|
58
|
+
* stable across runtime and AOT emission.
|
|
59
|
+
* @param context Mutable emission context.
|
|
60
|
+
* @param value String value referenced by generated source.
|
|
61
|
+
* @returns Stable side-table index for the string.
|
|
29
62
|
*/
|
|
30
63
|
export declare function pushString(context: EmitContext, value: string): number;
|
|
31
64
|
/**
|
|
32
|
-
* @brief
|
|
65
|
+
* @brief Append a dynamic schema to the generated factory side table.
|
|
66
|
+
* @details Generated-source helpers keep the side-table ABI and JavaScript source shape
|
|
67
|
+
* stable across runtime and AOT emission.
|
|
68
|
+
* @param context Mutable emission context.
|
|
69
|
+
* @param value Schema used by fallback or lazy generated paths.
|
|
70
|
+
* @returns Index used by generated code to read `d[index]`.
|
|
33
71
|
*/
|
|
34
72
|
export declare function pushSchema(context: EmitContext, value: Schema): number;
|
|
35
73
|
//# sourceMappingURL=context.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/compile/context.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/compile/context.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE3D;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,WAAW,GAAG,WAAW,CAchE;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,YAAY,GAAG,MAAM,CAI7E;AAED;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAIrE;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAIjF;AAED;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAErE;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAatE;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAItE"}
|
package/dist/compile/context.js
CHANGED
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file compile/context.ts
|
|
3
3
|
* @brief Generated-source emitter side-table context.
|
|
4
|
+
* @details Generated-source helpers keep the side-table ABI and JavaScript source shape
|
|
5
|
+
* stable across runtime and AOT emission.
|
|
4
6
|
*/
|
|
5
7
|
/**
|
|
6
|
-
* @brief
|
|
8
|
+
* @brief Create one mutable source-emission context.
|
|
9
|
+
* @details Generated-source helpers keep the side-table ABI and JavaScript source shape
|
|
10
|
+
* stable across runtime and AOT emission.
|
|
11
|
+
* @param mode Compile mode that controls safety and allocation tradeoffs.
|
|
12
|
+
* @returns Fresh side-table context consumed by predicate and diagnostic emitters.
|
|
13
|
+
* @invariant Side tables are append-only during one bundle emission.
|
|
7
14
|
*/
|
|
8
|
-
export function createEmitContext() {
|
|
15
|
+
export function createEmitContext(mode) {
|
|
9
16
|
return {
|
|
17
|
+
mode,
|
|
10
18
|
literals: [],
|
|
11
19
|
regexps: [],
|
|
12
20
|
keysets: [],
|
|
@@ -20,7 +28,12 @@ export function createEmitContext() {
|
|
|
20
28
|
};
|
|
21
29
|
}
|
|
22
30
|
/**
|
|
23
|
-
* @brief
|
|
31
|
+
* @brief Append a literal to the generated factory side table.
|
|
32
|
+
* @details Generated-source helpers keep the side-table ABI and JavaScript source shape
|
|
33
|
+
* stable across runtime and AOT emission.
|
|
34
|
+
* @param context Mutable emission context.
|
|
35
|
+
* @param value Literal value referenced by generated source.
|
|
36
|
+
* @returns Index used by generated code to read `l[index]`.
|
|
24
37
|
*/
|
|
25
38
|
export function pushLiteral(context, value) {
|
|
26
39
|
const index = context.literals.length;
|
|
@@ -28,7 +41,13 @@ export function pushLiteral(context, value) {
|
|
|
28
41
|
return index;
|
|
29
42
|
}
|
|
30
43
|
/**
|
|
31
|
-
* @brief
|
|
44
|
+
* @brief Append a regular expression to the generated factory side table.
|
|
45
|
+
* @details Generated-source helpers keep the side-table ABI and JavaScript source shape
|
|
46
|
+
* stable across runtime and AOT emission.
|
|
47
|
+
* @param context Mutable emission context.
|
|
48
|
+
* @param value Source RegExp from the schema.
|
|
49
|
+
* @returns Index used by generated code to read `r[index]`.
|
|
50
|
+
* @post The stored RegExp is cloned so generated validation does not mutate user state.
|
|
32
51
|
*/
|
|
33
52
|
export function pushRegex(context, value) {
|
|
34
53
|
const index = context.regexps.length;
|
|
@@ -36,7 +55,12 @@ export function pushRegex(context, value) {
|
|
|
36
55
|
return index;
|
|
37
56
|
}
|
|
38
57
|
/**
|
|
39
|
-
* @brief
|
|
58
|
+
* @brief Append a keyset to the generated factory side table.
|
|
59
|
+
* @details Generated-source helpers keep the side-table ABI and JavaScript source shape
|
|
60
|
+
* stable across runtime and AOT emission.
|
|
61
|
+
* @param context Mutable emission context.
|
|
62
|
+
* @param value Frozen or caller-owned key list used by object checks.
|
|
63
|
+
* @returns Index used by generated code to read `k[index]`.
|
|
40
64
|
*/
|
|
41
65
|
export function pushKeyset(context, value) {
|
|
42
66
|
const index = context.keysets.length;
|
|
@@ -44,26 +68,45 @@ export function pushKeyset(context, value) {
|
|
|
44
68
|
return index;
|
|
45
69
|
}
|
|
46
70
|
/**
|
|
47
|
-
* @brief string
|
|
71
|
+
* @brief Return a generated expression for a string side-table entry.
|
|
72
|
+
* @details Generated-source helpers keep the side-table ABI and JavaScript source shape
|
|
73
|
+
* stable across runtime and AOT emission.
|
|
74
|
+
* @param context Mutable emission context.
|
|
75
|
+
* @param value String value to intern.
|
|
76
|
+
* @returns Generated expression of the form `u[index]`.
|
|
48
77
|
*/
|
|
49
78
|
export function stringRef(context, value) {
|
|
50
79
|
return `u[${String(pushString(context, value))}]`;
|
|
51
80
|
}
|
|
52
81
|
/**
|
|
53
|
-
* @brief
|
|
82
|
+
* @brief Intern a string in the generated factory side table.
|
|
83
|
+
* @details Generated-source helpers keep the side-table ABI and JavaScript source shape
|
|
84
|
+
* stable across runtime and AOT emission.
|
|
85
|
+
* @param context Mutable emission context.
|
|
86
|
+
* @param value String value referenced by generated source.
|
|
87
|
+
* @returns Stable side-table index for the string.
|
|
54
88
|
*/
|
|
55
89
|
export function pushString(context, value) {
|
|
56
90
|
const cached = context.stringIndexes.get(value);
|
|
57
91
|
if (cached !== undefined) {
|
|
58
92
|
return cached;
|
|
59
93
|
}
|
|
94
|
+
/*
|
|
95
|
+
* String interning keeps generated source small and lets repeated object
|
|
96
|
+
* keys reuse the same frozen path segment cache.
|
|
97
|
+
*/
|
|
60
98
|
const index = context.strings.length;
|
|
61
99
|
context.strings.push(value);
|
|
62
100
|
context.stringIndexes.set(value, index);
|
|
63
101
|
return index;
|
|
64
102
|
}
|
|
65
103
|
/**
|
|
66
|
-
* @brief
|
|
104
|
+
* @brief Append a dynamic schema to the generated factory side table.
|
|
105
|
+
* @details Generated-source helpers keep the side-table ABI and JavaScript source shape
|
|
106
|
+
* stable across runtime and AOT emission.
|
|
107
|
+
* @param context Mutable emission context.
|
|
108
|
+
* @param value Schema used by fallback or lazy generated paths.
|
|
109
|
+
* @returns Index used by generated code to read `d[index]`.
|
|
67
110
|
*/
|
|
68
111
|
export function pushSchema(context, value) {
|
|
69
112
|
const index = context.schemas.length;
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file graph-predicate.ts
|
|
3
3
|
* @brief Predicate source emitter backed by optimized Sea-of-Nodes graphs.
|
|
4
|
+
* @details Generated-source helpers keep the side-table ABI and JavaScript source shape
|
|
5
|
+
* stable across runtime and AOT emission.
|
|
4
6
|
*/
|
|
5
|
-
import type
|
|
7
|
+
import { type Schema } from "../schema/index.js";
|
|
6
8
|
import type { EmitContext } from "./types.js";
|
|
7
9
|
/**
|
|
8
10
|
* @brief emit graph function.
|
|
9
11
|
* @details Emits one predicate function from the optimized graph owned by a schema plan.
|
|
10
12
|
* @returns Generated function name.
|
|
11
13
|
*/
|
|
12
|
-
export declare function emitGraphFunction(schema: Schema, context: EmitContext): string;
|
|
14
|
+
export declare function emitGraphFunction(schema: Schema, context: EmitContext, preferredName?: string): string;
|
|
13
15
|
/**
|
|
14
16
|
* @brief emit graph functions.
|
|
15
17
|
* @details Serializes every graph predicate function accumulated in the context.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graph-predicate.d.ts","sourceRoot":"","sources":["../../src/compile/graph-predicate.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"graph-predicate.d.ts","sourceRoot":"","sources":["../../src/compile/graph-predicate.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAYH,OAAO,EAGH,KAAK,MAAM,EACd,MAAM,oBAAoB,CAAC;AAQ5B,OAAO,KAAK,EAAE,WAAW,EAAkB,MAAM,YAAY,CAAC;AA8G9D;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC7B,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,WAAW,EACpB,aAAa,CAAC,EAAE,MAAM,GACvB,MAAM,CAoBR;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,WAAW,GAAG,MAAM,CAS/D"}
|