Skip to content

Commit 239ab73

Browse files
committed
refactor(type): migrate serializer from jit.ts to jit2.ts API
Migrate the entire serializer module to use the new unified expression tree JIT architecture (jit2.ts). This provides: - Single tree built once, consumed by both JIT and Exec modes - Automatic CSP fallback when new Function() is blocked - Cleaner API: Builder/Ref instead of Context/Slot API changes: - Context → Builder - Slot<T> → Ref<T> - jit.fn() → fn() - ctx.when() → b.if_() - ctx.callExpr() → b.call() - ctx.newExpr() → b.new_() All 1949 type package tests passing.
1 parent 24027ea commit 239ab73

File tree

10 files changed

+3593
-3906
lines changed

10 files changed

+3593
-3906
lines changed

packages/core/index.ts

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,64 @@ export * from './src/network.js';
1818
export * from './src/perf.js';
1919
export * from './src/compiler.js';
2020
export * from './src/jit.js';
21+
// jit2 exports - Builder API for unified expression trees (JIT + Exec)
22+
// Note: Some exports overlap with jit.js (Arg, canJIT, etc.), so we selectively export
23+
export {
24+
// Expression tree types
25+
type LitExpr,
26+
type InputExpr,
27+
type VarExpr,
28+
type GetExpr,
29+
type AtExpr,
30+
type CallExpr,
31+
type NewExpr,
32+
type ObjExpr,
33+
type ArrExpr,
34+
type EqExpr,
35+
type NeqExpr,
36+
type LtExpr,
37+
type GtExpr,
38+
type LteExpr,
39+
type GteExpr,
40+
type NotExpr,
41+
type AndExpr,
42+
type OrExpr,
43+
type NullishExpr,
44+
type TypeofExpr,
45+
type IsTypeExpr,
46+
type IsNullExpr,
47+
type IsNullishExpr,
48+
type HasExpr,
49+
type LenExpr,
50+
type TernaryExpr,
51+
type InstanceofExpr,
52+
type ConcatExpr,
53+
type MapExpr,
54+
type Expr,
55+
// Statement types
56+
type LetStmt,
57+
type SetStmt,
58+
type PushStmt,
59+
type SetVarStmt,
60+
type ExecStmt,
61+
type ReturnStmt,
62+
type ThrowStmt,
63+
type IfStmt,
64+
type LoopStmt,
65+
type ForInStmt,
66+
type SwitchStmt,
67+
type Stmt,
68+
type Block,
69+
// Core classes
70+
Ref,
71+
VarRef,
72+
Builder,
73+
// Functions
74+
arg,
75+
fn,
76+
fnJIT,
77+
fnExec,
78+
} from './src/jit2.js';
2179
export * from './src/string.js';
2280
export * from './src/emitter.js';
2381
export * from './src/reactive.js';

packages/http/src/router.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,13 @@ export class UploadedFile {
9797
}
9898

9999
// Register type guard for UploadedFile - validates that the file was provided by the framework
100-
serializer.typeGuards.registerClass(UploadedFile, (type, input, ctx, state) => {
100+
serializer.typeGuards.registerClass(UploadedFile, (type, input, b, state) => {
101101
// Check if input is an UploadedFile with valid validator symbol
102-
return ctx.and(
103-
ctx.isType(input, 'object'),
104-
ctx.and(
105-
ctx.not(ctx.isNull(input)),
106-
ctx.callExpr((v: any, sym: symbol) => v.validator === sym, input, ctx.lit(UploadedFileSymbol)),
102+
return b.and(
103+
b.isType(input, 'object'),
104+
b.and(
105+
b.not(b.isNull(input)),
106+
b.call((v: any, sym: symbol) => v.validator === sym, input, b.lit(UploadedFileSymbol)),
107107
),
108108
);
109109
});

0 commit comments

Comments
 (0)