tjs-lang 0.8.3 → 0.8.4
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/CLAUDE.md +1 -1
- package/demo/docs.json +7 -7
- package/dist/experiments/predicates/css.predicates.d.ts +13 -0
- package/dist/experiments/predicates/verify.d.ts +39 -0
- package/dist/index.js +101 -97
- package/dist/index.js.map +4 -4
- package/dist/src/lang/index.d.ts +2 -0
- package/dist/src/lang/predicate-schema.d.ts +39 -0
- package/dist/src/lang/predicate.d.ts +103 -0
- package/dist/src/lang/transpiler.d.ts +2 -0
- package/dist/src/vm/runtime.d.ts +22 -0
- package/dist/tjs-eval.js +29 -29
- package/dist/tjs-eval.js.map +3 -3
- package/dist/tjs-from-ts.js +1 -1
- package/dist/tjs-from-ts.js.map +2 -2
- package/dist/tjs-lang.js +86 -82
- package/dist/tjs-lang.js.map +4 -4
- package/dist/tjs-vm.js +45 -45
- package/dist/tjs-vm.js.map +3 -3
- package/package.json +1 -1
- package/src/lang/runtime.test.ts +46 -0
- package/src/runtime.test.ts +6 -6
- package/src/vm/equality.test.ts +59 -0
- package/src/vm/runtime.ts +26 -59
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The CSS torture set — predicates for the exact cases where TS structural
|
|
3
|
+
* types and JSON Schema cave to `string`/`any`:
|
|
4
|
+
* - open value grammars: var(), calc(), !important
|
|
5
|
+
* - order-flexible shorthands: the `animation` family (tokenize + classify)
|
|
6
|
+
* - open recursive structure: nested selectors / keyframes (recurse)
|
|
7
|
+
*
|
|
8
|
+
* Written in named-composition style — no inline arrows, no IO, no async —
|
|
9
|
+
* so it reads as "synchronous AJS" and verifies predicate-safe. `||` composition
|
|
10
|
+
* and `.every(namedPredicate)` are natural here because predicates run as native
|
|
11
|
+
* JS (the verified fast path), not through the sandboxed VM interpreter.
|
|
12
|
+
*/
|
|
13
|
+
export declare const CSS_PREDICATE_SOURCE: string;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export interface PredicateDiagnostic {
|
|
2
|
+
predicate: string;
|
|
3
|
+
message: string;
|
|
4
|
+
line: number;
|
|
5
|
+
column: number;
|
|
6
|
+
}
|
|
7
|
+
export interface VerifyResult {
|
|
8
|
+
safe: boolean;
|
|
9
|
+
predicates: string[];
|
|
10
|
+
diagnostics: PredicateDiagnostic[];
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Build the effectful-name set from a VM atom registry: every atom tagged
|
|
14
|
+
* `effects: 'io'` (plus the non-atom globals). This is how the predicate
|
|
15
|
+
* verifier consumes the atom-effects classification.
|
|
16
|
+
*/
|
|
17
|
+
export declare function effectfulFrom(atoms: Record<string, {
|
|
18
|
+
op?: string;
|
|
19
|
+
effects?: 'pure' | 'io';
|
|
20
|
+
}>): Set<string>;
|
|
21
|
+
/**
|
|
22
|
+
* Verify every top-level function in `source` is predicate-safe. Because safety
|
|
23
|
+
* is a closure property, the whole cluster is safe iff each function is — so the
|
|
24
|
+
* transitive check is automatic: a call to another function in the set is fine,
|
|
25
|
+
* a call to anything effectful/unknown is not.
|
|
26
|
+
*/
|
|
27
|
+
export declare function verifyPredicates(source: string, opts?: {
|
|
28
|
+
effectful?: Set<string>;
|
|
29
|
+
}): VerifyResult;
|
|
30
|
+
/** Format diagnostics for a thrown error / log. */
|
|
31
|
+
export declare function formatDiagnostics(d: PredicateDiagnostic[]): string;
|
|
32
|
+
/**
|
|
33
|
+
* Verify, then compile the predicate cluster to native synchronous JS functions.
|
|
34
|
+
* Throws (with located diagnostics) at "definition time" if not predicate-safe —
|
|
35
|
+
* so an IO-using "predicate" never even compiles.
|
|
36
|
+
*/
|
|
37
|
+
export declare function compilePredicates(source: string, exports: string[], opts?: {
|
|
38
|
+
effectful?: Set<string>;
|
|
39
|
+
}): Record<string, (...args: any[]) => any>;
|