tjs-lang 0.6.20 → 0.6.26
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 +29 -24
- package/bin/dev.ts +9 -0
- package/demo/docs.json +49 -1
- package/demo/src/playground-shared.ts +8 -39
- package/demo/src/tjs-playground.ts +8 -0
- package/demo/src/tjs-runtime-iframe.ts +10 -0
- package/demo/src/ts-playground.ts +8 -0
- package/package.json +1 -1
- package/src/cli/commands/run.ts +4 -1
- package/src/cli/tjs.ts +1 -1
- package/src/lang/codegen.test.ts +26 -27
- package/src/lang/emitters/js-tests.ts +13 -19
- package/src/lang/emitters/js.ts +39 -7
- package/src/lang/parser-transforms.ts +18 -5
- package/src/lang/roundtrip.test.ts +1 -1
- package/src/lang/runtime.ts +88 -2
- package/src/lang/wasm.ts +1 -1
- package/dist/bin/benchmarks.d.ts +0 -9
- package/dist/bin/dev.d.ts +0 -1
- package/dist/bin/docs.d.ts +0 -1
- package/dist/bin/select-local-models.d.ts +0 -1
- package/dist/examples/modules/dist/main.d.ts +0 -34
- package/dist/examples/modules/dist/math.d.ts +0 -120
- package/dist/index.js +0 -426
- package/dist/index.js.map +0 -45
- package/dist/scripts/build-demo.d.ts +0 -2
- package/dist/scripts/build.d.ts +0 -11
- package/dist/scripts/seed-blog-rules.d.ts +0 -2
- package/dist/scripts/seed-stored-function.d.ts +0 -2
- package/dist/src/atoms/batteries.d.ts +0 -4
- package/dist/src/atoms/browser.d.ts +0 -4
- package/dist/src/atoms/index.d.ts +0 -4
- package/dist/src/batteries/audit.d.ts +0 -9
- package/dist/src/batteries/index.d.ts +0 -28
- package/dist/src/batteries/llm.d.ts +0 -18
- package/dist/src/batteries/models.d.ts +0 -19
- package/dist/src/batteries/store.d.ts +0 -13
- package/dist/src/builder.d.ts +0 -127
- package/dist/src/bun-plugin/tjs-plugin.d.ts +0 -12
- package/dist/src/cli/commands/check.d.ts +0 -4
- package/dist/src/cli/commands/convert.d.ts +0 -20
- package/dist/src/cli/commands/emit.d.ts +0 -34
- package/dist/src/cli/commands/run.d.ts +0 -6
- package/dist/src/cli/commands/test.d.ts +0 -21
- package/dist/src/cli/commands/types.d.ts +0 -4
- package/dist/src/cli/create-app.d.ts +0 -9
- package/dist/src/cli/playground.d.ts +0 -9
- package/dist/src/cli/tjs.d.ts +0 -15
- package/dist/src/cli/tjsx.d.ts +0 -16
- package/dist/src/index.d.ts +0 -11
- package/dist/src/inference.types.d.ts +0 -1
- package/dist/src/lang/core.d.ts +0 -56
- package/dist/src/lang/docs.d.ts +0 -69
- package/dist/src/lang/emitters/ast.d.ts +0 -24
- package/dist/src/lang/emitters/dts.d.ts +0 -48
- package/dist/src/lang/emitters/from-ts.d.ts +0 -94
- package/dist/src/lang/emitters/js-tests.d.ts +0 -70
- package/dist/src/lang/emitters/js-wasm.d.ts +0 -15
- package/dist/src/lang/emitters/js.d.ts +0 -175
- package/dist/src/lang/eval.d.ts +0 -63
- package/dist/src/lang/index.d.ts +0 -216
- package/dist/src/lang/inference.d.ts +0 -40
- package/dist/src/lang/linter.d.ts +0 -53
- package/dist/src/lang/metadata-cache.d.ts +0 -172
- package/dist/src/lang/parser-params.d.ts +0 -37
- package/dist/src/lang/parser-transforms.d.ts +0 -281
- package/dist/src/lang/parser-types.d.ts +0 -175
- package/dist/src/lang/parser.d.ts +0 -56
- package/dist/src/lang/runtime.d.ts +0 -454
- package/dist/src/lang/schema.d.ts +0 -35
- package/dist/src/lang/tests.d.ts +0 -94
- package/dist/src/lang/transpiler.d.ts +0 -25
- package/dist/src/lang/types.d.ts +0 -147
- package/dist/src/lang/wasm.d.ts +0 -83
- package/dist/src/rbac/index.d.ts +0 -85
- package/dist/src/rbac/rules.d.ts +0 -184
- package/dist/src/runtime.d.ts +0 -4
- package/dist/src/store/index.d.ts +0 -3
- package/dist/src/store/indexeddb.d.ts +0 -6
- package/dist/src/store/interface.d.ts +0 -90
- package/dist/src/store/memory.d.ts +0 -10
- package/dist/src/test-examples.d.ts +0 -41
- package/dist/src/test-utils.d.ts +0 -86
- package/dist/src/transpiler/index.d.ts +0 -6
- package/dist/src/transpiler/parser.d.ts +0 -4
- package/dist/src/transpiler/transformer.d.ts +0 -4
- package/dist/src/transpiler/type-system/inference.d.ts +0 -1
- package/dist/src/transpiler/types.d.ts +0 -4
- package/dist/src/types/LegalDate.d.ts +0 -241
- package/dist/src/types/Timestamp.d.ts +0 -233
- package/dist/src/types/Type.d.ts +0 -234
- package/dist/src/types/index.d.ts +0 -8
- package/dist/src/vm/atoms/batteries.d.ts +0 -6
- package/dist/src/vm/atoms/browser.d.ts +0 -18
- package/dist/src/vm/atoms/index.d.ts +0 -10
- package/dist/src/vm/index.d.ts +0 -12
- package/dist/src/vm/runtime.d.ts +0 -333
- package/dist/src/vm/vm.d.ts +0 -28
- package/dist/src/vm.d.ts +0 -4
- package/dist/test-preprocess.d.ts +0 -1
- package/dist/tjs-batteries.js +0 -4
- package/dist/tjs-batteries.js.map +0 -15
- package/dist/tjs-full.js +0 -426
- package/dist/tjs-full.js.map +0 -45
- package/dist/tjs-src/runtime.d.ts +0 -1
- package/dist/tjs-transpiler.js +0 -3
- package/dist/tjs-transpiler.js.map +0 -11
- package/dist/tjs-vm.js +0 -54
- package/dist/tjs-vm.js.map +0 -22
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* TJS Schema - Runtime type system for Typed JavaScript
|
|
3
|
-
*
|
|
4
|
-
* Builds on tosijs-schema to provide:
|
|
5
|
-
* - Schema(x) callable for inference by example
|
|
6
|
-
* - Schema.type(x) for "fixed typeof" (null returns 'null', not 'object')
|
|
7
|
-
* - All tosijs-schema methods (string, number, object, array, etc.)
|
|
8
|
-
*
|
|
9
|
-
* Usage:
|
|
10
|
-
* Schema('hello') // Schema matching string
|
|
11
|
-
* Schema(42) // Schema matching number (integer)
|
|
12
|
-
* Schema(null) // Schema matching null
|
|
13
|
-
* Schema(undefined) // Schema matching undefined
|
|
14
|
-
* Schema([1, 2, 3]) // Schema matching array of integers
|
|
15
|
-
* Schema({name: 'Anne'}) // Schema matching object with name: string
|
|
16
|
-
*
|
|
17
|
-
* Schema.type(null) // 'null' (not 'object' like typeof)
|
|
18
|
-
* Schema.type(undefined) // 'undefined'
|
|
19
|
-
* Schema.type([]) // 'array' (not 'object' like typeof)
|
|
20
|
-
*
|
|
21
|
-
* Schema.null.validate(x) // true if x is null
|
|
22
|
-
* Schema.undefined.validate(x) // true if x is undefined
|
|
23
|
-
*/
|
|
24
|
-
import { s, type Base } from 'tosijs-schema';
|
|
25
|
-
type SchemaCallable = {
|
|
26
|
-
(value: unknown): Base<unknown>;
|
|
27
|
-
type: (value: unknown) => string;
|
|
28
|
-
infer: (value: unknown) => Base<unknown>;
|
|
29
|
-
} & typeof s;
|
|
30
|
-
/**
|
|
31
|
-
* Schema - callable for inference, with all tosijs-schema methods attached
|
|
32
|
-
* Uses a Proxy to delegate property access to tosijs-schema's s object
|
|
33
|
-
*/
|
|
34
|
-
export declare const Schema: SchemaCallable;
|
|
35
|
-
export type { Base, Infer } from 'tosijs-schema';
|
package/dist/src/lang/tests.d.ts
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* TJS Inline Tests
|
|
3
|
-
*
|
|
4
|
-
* Extracts test blocks from TJS source and generates test runners.
|
|
5
|
-
*
|
|
6
|
-
* Syntax (TJS):
|
|
7
|
-
* test 'description' {
|
|
8
|
-
* assert(condition)
|
|
9
|
-
* expect(a).toBe(b)
|
|
10
|
-
* }
|
|
11
|
-
*
|
|
12
|
-
* test {
|
|
13
|
-
* // Anonymous test
|
|
14
|
-
* }
|
|
15
|
-
*
|
|
16
|
-
* mock {
|
|
17
|
-
* // Setup code that runs before each test
|
|
18
|
-
* }
|
|
19
|
-
*
|
|
20
|
-
* Syntax (TypeScript - embedded in comments):
|
|
21
|
-
* /*test 'description' {
|
|
22
|
-
* expect(add(2, 3)).toBe(5)
|
|
23
|
-
* }* /
|
|
24
|
-
*
|
|
25
|
-
* This syntax survives TypeScript compilation, enabling literate
|
|
26
|
-
* programming for TypeScript: tests live alongside the code they
|
|
27
|
-
* verify, extracted and executed at runtime by TJS.
|
|
28
|
-
*
|
|
29
|
-
* For TS developers who don't care about TJS: you still get inline
|
|
30
|
-
* tests that live with your code, literate development, and faster
|
|
31
|
-
* debug loops. Set `safety none` and keep living in your world.
|
|
32
|
-
*
|
|
33
|
-
* Output:
|
|
34
|
-
* - code: Clean source with tests stripped
|
|
35
|
-
* - tests: Array of extracted test definitions
|
|
36
|
-
* - testRunner: Generated code to execute tests
|
|
37
|
-
*/
|
|
38
|
-
export interface ExtractedTest {
|
|
39
|
-
description: string;
|
|
40
|
-
body: string;
|
|
41
|
-
line?: number;
|
|
42
|
-
}
|
|
43
|
-
export interface ExtractedMock {
|
|
44
|
-
body: string;
|
|
45
|
-
line?: number;
|
|
46
|
-
}
|
|
47
|
-
export interface TestExtractionResult {
|
|
48
|
-
/** Source code with tests and mocks removed */
|
|
49
|
-
code: string;
|
|
50
|
-
/** Extracted test definitions */
|
|
51
|
-
tests: ExtractedTest[];
|
|
52
|
-
/** Extracted mock/setup blocks */
|
|
53
|
-
mocks: ExtractedMock[];
|
|
54
|
-
/** Generated test runner code */
|
|
55
|
-
testRunner: string;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Extract inline tests from TJS source
|
|
59
|
-
*
|
|
60
|
-
* Note: Signature tests (from -> return types) are handled separately by the
|
|
61
|
-
* transpiler in js.ts. This function only extracts explicit test blocks.
|
|
62
|
-
*/
|
|
63
|
-
export declare function extractTests(source: string): TestExtractionResult;
|
|
64
|
-
/**
|
|
65
|
-
* Test utilities - assert and expect
|
|
66
|
-
* Include this in the runtime or inject it
|
|
67
|
-
*/
|
|
68
|
-
export declare const assertFunction = "\nfunction assert(condition, message) {\n if (!condition) {\n throw new Error(message || 'Assertion failed')\n }\n}\n";
|
|
69
|
-
/**
|
|
70
|
-
* Expect API for richer test assertions
|
|
71
|
-
* Uses deep equality, handles null/undefined correctly
|
|
72
|
-
*/
|
|
73
|
-
export declare const expectFunction = "\nfunction expect(actual) {\n const deepEqual = (a, b) => {\n if (a === b) return true\n if (a === null || b === null) return a === b\n if (a === undefined || b === undefined) return a === undefined && b === undefined\n if (typeof a !== typeof b) return false\n if (typeof a !== 'object') return a === b\n if (Array.isArray(a) !== Array.isArray(b)) return false\n if (Array.isArray(a)) {\n if (a.length !== b.length) return false\n return a.every((v, i) => deepEqual(v, b[i]))\n }\n const keysA = Object.keys(a)\n const keysB = Object.keys(b)\n if (keysA.length !== keysB.length) return false\n return keysA.every(k => deepEqual(a[k], b[k]))\n }\n\n const format = (v) => {\n if (v === null) return 'null'\n if (v === undefined) return 'undefined'\n if (typeof v === 'string') return JSON.stringify(v)\n if (typeof v === 'object') return JSON.stringify(v)\n return String(v)\n }\n\n return {\n toBe(expected) {\n if (!deepEqual(actual, expected)) {\n throw new Error(`Expected ${format(expected)} but got ${format(actual)}`)\n }\n },\n toEqual(expected) {\n if (!deepEqual(actual, expected)) {\n throw new Error(`Expected ${format(expected)} but got ${format(actual)}`)\n }\n },\n toContain(item) {\n if (!Array.isArray(actual) || !actual.some(v => deepEqual(v, item))) {\n throw new Error(`Expected ${format(actual)} to contain ${format(item)}`)\n }\n },\n toThrow(message) {\n let threw = false\n let thrownMessage = ''\n try {\n if (typeof actual === 'function') actual()\n } catch (e) {\n threw = true\n thrownMessage = e.message || String(e)\n }\n if (!threw) {\n throw new Error('Expected function to throw but it did not')\n }\n if (message && !thrownMessage.includes(message)) {\n throw new Error(`Expected error containing \"${message}\" but got \"${thrownMessage}\"`)\n }\n },\n toBeTruthy() {\n if (!actual) {\n throw new Error(`Expected ${format(actual)} to be truthy`)\n }\n },\n toBeFalsy() {\n if (actual) {\n throw new Error(`Expected ${format(actual)} to be falsy`)\n }\n },\n toBeNull() {\n if (actual !== null) {\n throw new Error(`Expected null but got ${format(actual)}`)\n }\n },\n toBeUndefined() {\n if (actual !== undefined) {\n throw new Error(`Expected undefined but got ${format(actual)}`)\n }\n },\n toBeGreaterThan(n) {\n if (!(actual > n)) {\n throw new Error(`Expected ${format(actual)} to be greater than ${n}`)\n }\n },\n toBeLessThan(n) {\n if (!(actual < n)) {\n throw new Error(`Expected ${format(actual)} to be less than ${n}`)\n }\n }\n }\n}\n";
|
|
74
|
-
/**
|
|
75
|
-
* Combined test utilities (assert + expect)
|
|
76
|
-
*/
|
|
77
|
-
export declare const testUtils: string;
|
|
78
|
-
/**
|
|
79
|
-
* Questions/Notes:
|
|
80
|
-
*
|
|
81
|
-
* Q1: Should mocks be scoped per-test or shared?
|
|
82
|
-
* Current: Each test runs all mocks before executing
|
|
83
|
-
*
|
|
84
|
-
* Q2: Should we support test.only / test.skip?
|
|
85
|
-
* Easy to add with syntax: test.only('...') { } or test.skip('...') { }
|
|
86
|
-
*
|
|
87
|
-
* Q3: Integration with playground?
|
|
88
|
-
* Playground could run extractTests() and show test results in a panel
|
|
89
|
-
*
|
|
90
|
-
* Q4: DOM tests - test.browser('desc') { }?
|
|
91
|
-
* SHELVED: Plan is to run tests in actual browser (playground)
|
|
92
|
-
* Happy-DOM is ~1MB packed, too heavy to bundle
|
|
93
|
-
* If needed later: lazy-load happy-dom only for Node/Bun DOM tests
|
|
94
|
-
*/
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* TJS Transpiler - Core transpilation without TS compiler
|
|
3
|
-
*
|
|
4
|
-
* This is the lightweight entry point for TJS/AJS transpilation.
|
|
5
|
-
* Does NOT include fromTS (which requires the full TypeScript compiler).
|
|
6
|
-
*
|
|
7
|
-
* For TS -> TJS conversion, use the full bundle or import fromTS separately.
|
|
8
|
-
*
|
|
9
|
-
* NOTE: We import directly from source files, NOT from ./index, because
|
|
10
|
-
* ./index imports from-ts.ts which pulls in the TypeScript compiler (~4MB).
|
|
11
|
-
*/
|
|
12
|
-
export { transpile, ajs, tjs, createAgent, getToolDefinitions } from './core';
|
|
13
|
-
export { parse, preprocess, extractTDoc } from './parser';
|
|
14
|
-
export { transformFunction } from './emitters/ast';
|
|
15
|
-
export { transpileToJS } from './emitters/js';
|
|
16
|
-
export type { TJSTranspileOptions, TJSTranspileResult, TJSTypeInfo, } from './emitters/js';
|
|
17
|
-
export * from './inference';
|
|
18
|
-
export { Schema } from './schema';
|
|
19
|
-
export { lint } from './linter';
|
|
20
|
-
export type { LintResult, LintDiagnostic, LintOptions } from './linter';
|
|
21
|
-
export { extractTests, assertFunction, expectFunction, testUtils, } from './tests';
|
|
22
|
-
export type { ExtractedTest, ExtractedMock, TestExtractionResult, } from './tests';
|
|
23
|
-
export { runtime, installRuntime, isError, error, typeOf, checkType, validateArgs, wrap, emitRuntimeWrapper, TJS_VERSION, } from './runtime';
|
|
24
|
-
export type { TJSError } from './runtime';
|
|
25
|
-
export type { TypeDescriptor, ParameterDescriptor, FunctionSignature, TranspileOptions, TranspileResult, TranspileWarning, } from './types';
|
package/dist/src/lang/types.d.ts
DELETED
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Type definitions for the Agent99 JavaScript transpiler
|
|
3
|
-
*/
|
|
4
|
-
import type { Node } from 'acorn';
|
|
5
|
-
import type { SeqNode } from '../builder';
|
|
6
|
-
/** Represents a type extracted from value patterns */
|
|
7
|
-
export interface TypeDescriptor {
|
|
8
|
-
kind: 'string' | 'number' | 'integer' | 'non-negative-integer' | 'boolean' | 'null' | 'undefined' | 'array' | 'object' | 'union' | 'any';
|
|
9
|
-
nullable?: boolean;
|
|
10
|
-
/** For arrays: the element type */
|
|
11
|
-
items?: TypeDescriptor;
|
|
12
|
-
/** For objects: the shape */
|
|
13
|
-
shape?: Record<string, TypeDescriptor>;
|
|
14
|
-
/** For unions: the member types */
|
|
15
|
-
members?: TypeDescriptor[];
|
|
16
|
-
/** For destructured parameters: full parameter descriptors */
|
|
17
|
-
destructuredParams?: Record<string, ParameterDescriptor>;
|
|
18
|
-
}
|
|
19
|
-
/** Describes a function parameter */
|
|
20
|
-
export interface ParameterDescriptor {
|
|
21
|
-
name: string;
|
|
22
|
-
type: TypeDescriptor;
|
|
23
|
-
required: boolean;
|
|
24
|
-
default?: any;
|
|
25
|
-
/** The example value used to infer the type (for autocomplete) */
|
|
26
|
-
example?: any;
|
|
27
|
-
description?: string;
|
|
28
|
-
/** Source location for error reporting */
|
|
29
|
-
loc?: {
|
|
30
|
-
start: number;
|
|
31
|
-
end: number;
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
/** Describes a function's complete signature */
|
|
35
|
-
export interface FunctionSignature {
|
|
36
|
-
name: string;
|
|
37
|
-
description?: string;
|
|
38
|
-
parameters: Record<string, ParameterDescriptor>;
|
|
39
|
-
returns?: TypeDescriptor;
|
|
40
|
-
}
|
|
41
|
-
/** Options for the transpile function */
|
|
42
|
-
export interface TranspileOptions {
|
|
43
|
-
/** Include source locations in output AST */
|
|
44
|
-
sourceMaps?: boolean;
|
|
45
|
-
/** Atom registry for validation (optional) */
|
|
46
|
-
atoms?: Record<string, {
|
|
47
|
-
op: string;
|
|
48
|
-
}>;
|
|
49
|
-
/** Filename for error messages */
|
|
50
|
-
filename?: string;
|
|
51
|
-
/** Whether to use strict type checking */
|
|
52
|
-
strict?: boolean;
|
|
53
|
-
}
|
|
54
|
-
/** Result of transpilation */
|
|
55
|
-
export interface TranspileResult {
|
|
56
|
-
/** The Agent99 AST */
|
|
57
|
-
ast: SeqNode;
|
|
58
|
-
/** The function signature with types */
|
|
59
|
-
signature: FunctionSignature;
|
|
60
|
-
/** Source map (if enabled) */
|
|
61
|
-
sourceMap?: SourceMap;
|
|
62
|
-
/** Warnings (non-fatal issues) */
|
|
63
|
-
warnings: TranspileWarning[];
|
|
64
|
-
}
|
|
65
|
-
/** A non-fatal warning during transpilation */
|
|
66
|
-
export interface TranspileWarning {
|
|
67
|
-
message: string;
|
|
68
|
-
line: number;
|
|
69
|
-
column: number;
|
|
70
|
-
source?: string;
|
|
71
|
-
}
|
|
72
|
-
/** Source map for debugging */
|
|
73
|
-
export interface SourceMap {
|
|
74
|
-
version: 3;
|
|
75
|
-
file: string;
|
|
76
|
-
sources: string[];
|
|
77
|
-
mappings: string;
|
|
78
|
-
}
|
|
79
|
-
/** Base class for transpiler errors with source location */
|
|
80
|
-
export declare class TranspileError extends Error {
|
|
81
|
-
line: number;
|
|
82
|
-
column: number;
|
|
83
|
-
source?: string;
|
|
84
|
-
filename?: string;
|
|
85
|
-
constructor(message: string, location: {
|
|
86
|
-
line: number;
|
|
87
|
-
column: number;
|
|
88
|
-
}, source?: string, filename?: string);
|
|
89
|
-
}
|
|
90
|
-
/** Syntax error during parsing */
|
|
91
|
-
export declare class SyntaxError extends TranspileError {
|
|
92
|
-
constructor(message: string, location: {
|
|
93
|
-
line: number;
|
|
94
|
-
column: number;
|
|
95
|
-
}, source?: string, filename?: string);
|
|
96
|
-
/**
|
|
97
|
-
* Format the error with source context for better debugging
|
|
98
|
-
* Shows the problematic line with a caret pointing to the error location
|
|
99
|
-
*/
|
|
100
|
-
formatWithContext(contextLines?: number): string;
|
|
101
|
-
}
|
|
102
|
-
/** Type error during transpilation or runtime */
|
|
103
|
-
export declare class TypeError extends TranspileError {
|
|
104
|
-
expected?: string;
|
|
105
|
-
received?: string;
|
|
106
|
-
suggestion?: string;
|
|
107
|
-
constructor(message: string, location: {
|
|
108
|
-
line: number;
|
|
109
|
-
column: number;
|
|
110
|
-
}, options?: {
|
|
111
|
-
expected?: string;
|
|
112
|
-
received?: string;
|
|
113
|
-
suggestion?: string;
|
|
114
|
-
source?: string;
|
|
115
|
-
filename?: string;
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
/** Context passed through the transformer */
|
|
119
|
-
export interface TransformContext {
|
|
120
|
-
/** Current scope depth */
|
|
121
|
-
depth: number;
|
|
122
|
-
/** Variables declared in current scope with their types */
|
|
123
|
-
locals: Map<string, TypeDescriptor>;
|
|
124
|
-
/** Parent scope's context (for scope chain) */
|
|
125
|
-
parent?: TransformContext;
|
|
126
|
-
/** Function parameters */
|
|
127
|
-
parameters: Map<string, ParameterDescriptor>;
|
|
128
|
-
/** Registered atom names */
|
|
129
|
-
atoms: Set<string>;
|
|
130
|
-
/** Accumulated warnings */
|
|
131
|
-
warnings: TranspileWarning[];
|
|
132
|
-
/** Source code for error messages */
|
|
133
|
-
source: string;
|
|
134
|
-
/** Filename */
|
|
135
|
-
filename: string;
|
|
136
|
-
/** Options */
|
|
137
|
-
options: TranspileOptions;
|
|
138
|
-
}
|
|
139
|
-
/** Create a child context for nested scopes */
|
|
140
|
-
export declare function createChildContext(parent: TransformContext): TransformContext;
|
|
141
|
-
/** Look up a variable in the scope chain */
|
|
142
|
-
export declare function lookupVariable(name: string, ctx: TransformContext): TypeDescriptor | undefined;
|
|
143
|
-
/** Extract location from an Acorn node */
|
|
144
|
-
export declare function getLocation(node: Node): {
|
|
145
|
-
line: number;
|
|
146
|
-
column: number;
|
|
147
|
-
};
|
package/dist/src/lang/wasm.d.ts
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* TJS to WebAssembly Compiler
|
|
3
|
-
*
|
|
4
|
-
* Compiles a subset of TJS to WebAssembly for performance-critical code.
|
|
5
|
-
*
|
|
6
|
-
* Supported features:
|
|
7
|
-
* - Numeric operations (+, -, *, /, %)
|
|
8
|
-
* - Typed arrays (Float32Array, Float64Array, Int32Array, Uint8Array)
|
|
9
|
-
* - For loops with numeric bounds
|
|
10
|
-
* - Math functions (sin, cos, sqrt, abs, floor, ceil, min, max)
|
|
11
|
-
* - Basic conditionals (if/else)
|
|
12
|
-
* - Variable declarations (let)
|
|
13
|
-
*
|
|
14
|
-
* The goal is to enable real-world WASM acceleration for hot paths like
|
|
15
|
-
* audio processing, image manipulation, and physics simulations.
|
|
16
|
-
*/
|
|
17
|
-
import type { WasmBlock } from './parser';
|
|
18
|
-
/** Compile result */
|
|
19
|
-
export interface WasmCompileResult {
|
|
20
|
-
/** The compiled WebAssembly module bytes */
|
|
21
|
-
bytes: Uint8Array;
|
|
22
|
-
/** Any warnings during compilation */
|
|
23
|
-
warnings: string[];
|
|
24
|
-
/** Whether compilation succeeded */
|
|
25
|
-
success: boolean;
|
|
26
|
-
/** Error message if compilation failed */
|
|
27
|
-
error?: string;
|
|
28
|
-
/** Whether the module needs imported memory */
|
|
29
|
-
needsMemory?: boolean;
|
|
30
|
-
/** WAT text representation (for debugging) */
|
|
31
|
-
wat?: string;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Compile a WASM block to WebAssembly
|
|
35
|
-
*/
|
|
36
|
-
export declare function compileToWasm(block: WasmBlock): WasmCompileResult;
|
|
37
|
-
/**
|
|
38
|
-
* Instantiate a compiled WASM module
|
|
39
|
-
*/
|
|
40
|
-
export declare function instantiateWasm(bytes: Uint8Array, memory?: WebAssembly.Memory): Promise<WebAssembly.Instance>;
|
|
41
|
-
/**
|
|
42
|
-
* Create a callable function from a WASM block with typed array support
|
|
43
|
-
*/
|
|
44
|
-
export declare function createWasmFunction(block: WasmBlock): Promise<{
|
|
45
|
-
fn: (...args: any[]) => any;
|
|
46
|
-
memory?: WebAssembly.Memory;
|
|
47
|
-
success: boolean;
|
|
48
|
-
error?: string;
|
|
49
|
-
}>;
|
|
50
|
-
/**
|
|
51
|
-
* Compile and register a WASM block globally
|
|
52
|
-
*/
|
|
53
|
-
export declare function registerWasmBlock(block: WasmBlock): Promise<boolean>;
|
|
54
|
-
/**
|
|
55
|
-
* Compile all WASM blocks from a preprocessed source
|
|
56
|
-
*/
|
|
57
|
-
export declare function compileWasmBlocks(blocks: WasmBlock[]): Promise<{
|
|
58
|
-
compiled: number;
|
|
59
|
-
failed: number;
|
|
60
|
-
errors: string[];
|
|
61
|
-
}>;
|
|
62
|
-
/**
|
|
63
|
-
* Compiled WASM data that can be serialized and passed to an iframe
|
|
64
|
-
*/
|
|
65
|
-
export interface CompiledWasmData {
|
|
66
|
-
id: string;
|
|
67
|
-
bytes: number[];
|
|
68
|
-
captures: string[];
|
|
69
|
-
needsMemory: boolean;
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Compile WASM blocks and return serializable data for iframe instantiation
|
|
73
|
-
*/
|
|
74
|
-
export declare function compileWasmBlocksForIframe(blocks: WasmBlock[]): Promise<{
|
|
75
|
-
compiled: CompiledWasmData[];
|
|
76
|
-
failed: number;
|
|
77
|
-
errors: string[];
|
|
78
|
-
}>;
|
|
79
|
-
/**
|
|
80
|
-
* Generate JavaScript code that instantiates compiled WASM in an iframe
|
|
81
|
-
* This code should be injected into the iframe's script
|
|
82
|
-
*/
|
|
83
|
-
export declare function generateWasmInstantiationCode(compiledBlocks: CompiledWasmData[]): string;
|
package/dist/src/rbac/index.d.ts
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import type { Store } from '../store/interface';
|
|
2
|
-
export { evaluateAccessShortcut, selectAccessRule, validateSchema, interpretRuleResult, hasRoleLevel, buildRuleContext, } from './rules.js';
|
|
3
|
-
/**
|
|
4
|
-
* Security rule definition
|
|
5
|
-
*/
|
|
6
|
-
export interface SecurityRule {
|
|
7
|
-
/** Rule for read operations */
|
|
8
|
-
read?: string | {
|
|
9
|
-
code: string;
|
|
10
|
-
fuel?: number;
|
|
11
|
-
};
|
|
12
|
-
/** Rule for write operations (fallback for create/update) */
|
|
13
|
-
write?: string | {
|
|
14
|
-
code: string;
|
|
15
|
-
fuel?: number;
|
|
16
|
-
};
|
|
17
|
-
/** Rule for create operations */
|
|
18
|
-
create?: string | {
|
|
19
|
-
code: string;
|
|
20
|
-
fuel?: number;
|
|
21
|
-
};
|
|
22
|
-
/** Rule for update operations */
|
|
23
|
-
update?: string | {
|
|
24
|
-
code: string;
|
|
25
|
-
fuel?: number;
|
|
26
|
-
};
|
|
27
|
-
/** Rule for delete operations */
|
|
28
|
-
delete?: string | {
|
|
29
|
-
code: string;
|
|
30
|
-
fuel?: number;
|
|
31
|
-
};
|
|
32
|
-
/** Legacy: single code rule for all operations */
|
|
33
|
-
code?: string;
|
|
34
|
-
/** Schema validation for writes */
|
|
35
|
-
schema?: {
|
|
36
|
-
required?: string[];
|
|
37
|
-
properties?: Record<string, {
|
|
38
|
-
type: string;
|
|
39
|
-
}>;
|
|
40
|
-
};
|
|
41
|
-
/** Max fuel for AJS evaluation */
|
|
42
|
-
fuel?: number;
|
|
43
|
-
/** Timeout for AJS evaluation */
|
|
44
|
-
timeoutMs?: number;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Access check options
|
|
48
|
-
*/
|
|
49
|
-
export interface CheckOptions {
|
|
50
|
-
uid?: string | null;
|
|
51
|
-
roles?: string[];
|
|
52
|
-
method: 'read' | 'write' | 'delete';
|
|
53
|
-
collection: string;
|
|
54
|
-
docId?: string | null;
|
|
55
|
-
doc?: Record<string, any> | null;
|
|
56
|
-
newData?: Record<string, any> | null;
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Access check result
|
|
60
|
-
*/
|
|
61
|
-
export interface CheckResult {
|
|
62
|
-
allowed: boolean;
|
|
63
|
-
reason?: string;
|
|
64
|
-
ruleType: 'shortcut' | 'schema' | 'code' | 'default' | 'error';
|
|
65
|
-
evalTimeMs: number;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* RBAC instance with store backend
|
|
69
|
-
*/
|
|
70
|
-
export interface RBAC {
|
|
71
|
-
/** Check if an operation is allowed */
|
|
72
|
-
check(options: CheckOptions): Promise<CheckResult>;
|
|
73
|
-
/** Set a security rule for a collection */
|
|
74
|
-
setRule(collection: string, rule: SecurityRule): Promise<void>;
|
|
75
|
-
/** Get the security rule for a collection */
|
|
76
|
-
getRule(collection: string): Promise<SecurityRule | null>;
|
|
77
|
-
/** Delete a security rule */
|
|
78
|
-
deleteRule(collection: string): Promise<void>;
|
|
79
|
-
/** Load user roles from store */
|
|
80
|
-
loadUserRoles(uid: string): Promise<string[]>;
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Create an RBAC instance with a store backend
|
|
84
|
-
*/
|
|
85
|
-
export declare function createRBAC(store: Store): RBAC;
|
package/dist/src/rbac/rules.d.ts
DELETED
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
export function evaluateAccessShortcut(accessRule: any, context: any): {
|
|
2
|
-
allowed: boolean;
|
|
3
|
-
reason: string;
|
|
4
|
-
} | {
|
|
5
|
-
allowed: boolean;
|
|
6
|
-
reason?: undefined;
|
|
7
|
-
} | null;
|
|
8
|
-
export namespace evaluateAccessShortcut {
|
|
9
|
-
namespace __tjs {
|
|
10
|
-
namespace params {
|
|
11
|
-
namespace accessRule {
|
|
12
|
-
namespace type {
|
|
13
|
-
let kind: string;
|
|
14
|
-
}
|
|
15
|
-
let required: boolean;
|
|
16
|
-
}
|
|
17
|
-
namespace context {
|
|
18
|
-
export namespace type_1 {
|
|
19
|
-
let kind_1: string;
|
|
20
|
-
export { kind_1 as kind };
|
|
21
|
-
}
|
|
22
|
-
export { type_1 as type };
|
|
23
|
-
let required_1: boolean;
|
|
24
|
-
export { required_1 as required };
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
let unsafe: boolean;
|
|
28
|
-
let source: string;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
export function selectAccessRule(rule: any, context: any): any;
|
|
32
|
-
export namespace selectAccessRule {
|
|
33
|
-
export namespace __tjs_1 {
|
|
34
|
-
export namespace params_1 {
|
|
35
|
-
export namespace rule {
|
|
36
|
-
export namespace type_2 {
|
|
37
|
-
let kind_2: string;
|
|
38
|
-
export { kind_2 as kind };
|
|
39
|
-
}
|
|
40
|
-
export { type_2 as type };
|
|
41
|
-
let required_2: boolean;
|
|
42
|
-
export { required_2 as required };
|
|
43
|
-
}
|
|
44
|
-
export namespace context_1 {
|
|
45
|
-
export namespace type_3 {
|
|
46
|
-
let kind_3: string;
|
|
47
|
-
export { kind_3 as kind };
|
|
48
|
-
}
|
|
49
|
-
export { type_3 as type };
|
|
50
|
-
let required_3: boolean;
|
|
51
|
-
export { required_3 as required };
|
|
52
|
-
}
|
|
53
|
-
export { context_1 as context };
|
|
54
|
-
}
|
|
55
|
-
export { params_1 as params };
|
|
56
|
-
let unsafe_1: boolean;
|
|
57
|
-
export { unsafe_1 as unsafe };
|
|
58
|
-
let source_1: string;
|
|
59
|
-
export { source_1 as source };
|
|
60
|
-
}
|
|
61
|
-
export { __tjs_1 as __tjs };
|
|
62
|
-
}
|
|
63
|
-
export function validateSchema(schema: any, data: any): {
|
|
64
|
-
valid: boolean;
|
|
65
|
-
errors: string[];
|
|
66
|
-
};
|
|
67
|
-
export namespace validateSchema {
|
|
68
|
-
export namespace __tjs_2 {
|
|
69
|
-
export namespace params_2 {
|
|
70
|
-
namespace schema {
|
|
71
|
-
export namespace type_4 {
|
|
72
|
-
let kind_4: string;
|
|
73
|
-
export { kind_4 as kind };
|
|
74
|
-
}
|
|
75
|
-
export { type_4 as type };
|
|
76
|
-
let required_4: boolean;
|
|
77
|
-
export { required_4 as required };
|
|
78
|
-
}
|
|
79
|
-
namespace data {
|
|
80
|
-
export namespace type_5 {
|
|
81
|
-
let kind_5: string;
|
|
82
|
-
export { kind_5 as kind };
|
|
83
|
-
}
|
|
84
|
-
export { type_5 as type };
|
|
85
|
-
let required_5: boolean;
|
|
86
|
-
export { required_5 as required };
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
export { params_2 as params };
|
|
90
|
-
let unsafe_2: boolean;
|
|
91
|
-
export { unsafe_2 as unsafe };
|
|
92
|
-
let source_2: string;
|
|
93
|
-
export { source_2 as source };
|
|
94
|
-
}
|
|
95
|
-
export { __tjs_2 as __tjs };
|
|
96
|
-
}
|
|
97
|
-
export function interpretRuleResult(result: any): {
|
|
98
|
-
allowed: boolean;
|
|
99
|
-
reason: any;
|
|
100
|
-
};
|
|
101
|
-
export namespace interpretRuleResult {
|
|
102
|
-
export namespace __tjs_3 {
|
|
103
|
-
export namespace params_3 {
|
|
104
|
-
namespace result {
|
|
105
|
-
export namespace type_6 {
|
|
106
|
-
let kind_6: string;
|
|
107
|
-
export { kind_6 as kind };
|
|
108
|
-
}
|
|
109
|
-
export { type_6 as type };
|
|
110
|
-
let required_6: boolean;
|
|
111
|
-
export { required_6 as required };
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
export { params_3 as params };
|
|
115
|
-
let unsafe_3: boolean;
|
|
116
|
-
export { unsafe_3 as unsafe };
|
|
117
|
-
let source_3: string;
|
|
118
|
-
export { source_3 as source };
|
|
119
|
-
}
|
|
120
|
-
export { __tjs_3 as __tjs };
|
|
121
|
-
}
|
|
122
|
-
export function hasRoleLevel(userRoles: any, requiredRole: any): boolean;
|
|
123
|
-
export namespace hasRoleLevel {
|
|
124
|
-
export namespace __tjs_4 {
|
|
125
|
-
export namespace params_4 {
|
|
126
|
-
namespace userRoles {
|
|
127
|
-
export namespace type_7 {
|
|
128
|
-
let kind_7: string;
|
|
129
|
-
export { kind_7 as kind };
|
|
130
|
-
}
|
|
131
|
-
export { type_7 as type };
|
|
132
|
-
let required_7: boolean;
|
|
133
|
-
export { required_7 as required };
|
|
134
|
-
}
|
|
135
|
-
namespace requiredRole {
|
|
136
|
-
export namespace type_8 {
|
|
137
|
-
let kind_8: string;
|
|
138
|
-
export { kind_8 as kind };
|
|
139
|
-
}
|
|
140
|
-
export { type_8 as type };
|
|
141
|
-
let required_8: boolean;
|
|
142
|
-
export { required_8 as required };
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
export { params_4 as params };
|
|
146
|
-
let unsafe_4: boolean;
|
|
147
|
-
export { unsafe_4 as unsafe };
|
|
148
|
-
let source_4: string;
|
|
149
|
-
export { source_4 as source };
|
|
150
|
-
}
|
|
151
|
-
export { __tjs_4 as __tjs };
|
|
152
|
-
}
|
|
153
|
-
export function buildRuleContext(options: any): {
|
|
154
|
-
_uid: any;
|
|
155
|
-
_roles: any;
|
|
156
|
-
_isAdmin: any;
|
|
157
|
-
_isAuthor: any;
|
|
158
|
-
_method: any;
|
|
159
|
-
_collection: any;
|
|
160
|
-
_docId: any;
|
|
161
|
-
doc: any;
|
|
162
|
-
newData: any;
|
|
163
|
-
};
|
|
164
|
-
export namespace buildRuleContext {
|
|
165
|
-
export namespace __tjs_5 {
|
|
166
|
-
export namespace params_5 {
|
|
167
|
-
namespace options {
|
|
168
|
-
export namespace type_9 {
|
|
169
|
-
let kind_9: string;
|
|
170
|
-
export { kind_9 as kind };
|
|
171
|
-
}
|
|
172
|
-
export { type_9 as type };
|
|
173
|
-
let required_9: boolean;
|
|
174
|
-
export { required_9 as required };
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
export { params_5 as params };
|
|
178
|
-
let unsafe_5: boolean;
|
|
179
|
-
export { unsafe_5 as unsafe };
|
|
180
|
-
let source_5: string;
|
|
181
|
-
export { source_5 as source };
|
|
182
|
-
}
|
|
183
|
-
export { __tjs_5 as __tjs };
|
|
184
|
-
}
|
package/dist/src/runtime.d.ts
DELETED