tjs-lang 0.6.19 → 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.
Files changed (111) hide show
  1. package/CLAUDE.md +29 -24
  2. package/bin/dev.ts +9 -0
  3. package/demo/docs.json +49 -1
  4. package/demo/src/playground-shared.ts +8 -39
  5. package/demo/src/tjs-playground.ts +8 -0
  6. package/demo/src/tjs-runtime-iframe.ts +10 -0
  7. package/demo/src/ts-playground.ts +8 -0
  8. package/package.json +1 -1
  9. package/src/cli/commands/run.ts +4 -1
  10. package/src/cli/tjs.ts +1 -1
  11. package/src/lang/codegen.test.ts +26 -27
  12. package/src/lang/emitters/dts.test.ts +22 -0
  13. package/src/lang/emitters/dts.ts +5 -1
  14. package/src/lang/emitters/js-tests.ts +13 -19
  15. package/src/lang/emitters/js.ts +39 -7
  16. package/src/lang/parser-transforms.ts +18 -5
  17. package/src/lang/roundtrip.test.ts +1 -1
  18. package/src/lang/runtime.ts +88 -2
  19. package/src/lang/wasm.ts +1 -1
  20. package/dist/bin/benchmarks.d.ts +0 -9
  21. package/dist/bin/dev.d.ts +0 -1
  22. package/dist/bin/docs.d.ts +0 -1
  23. package/dist/bin/select-local-models.d.ts +0 -1
  24. package/dist/examples/modules/dist/main.d.ts +0 -34
  25. package/dist/examples/modules/dist/math.d.ts +0 -120
  26. package/dist/index.js +0 -426
  27. package/dist/index.js.map +0 -45
  28. package/dist/scripts/build-demo.d.ts +0 -2
  29. package/dist/scripts/build.d.ts +0 -11
  30. package/dist/scripts/seed-blog-rules.d.ts +0 -2
  31. package/dist/scripts/seed-stored-function.d.ts +0 -2
  32. package/dist/src/atoms/batteries.d.ts +0 -4
  33. package/dist/src/atoms/browser.d.ts +0 -4
  34. package/dist/src/atoms/index.d.ts +0 -4
  35. package/dist/src/batteries/audit.d.ts +0 -9
  36. package/dist/src/batteries/index.d.ts +0 -28
  37. package/dist/src/batteries/llm.d.ts +0 -18
  38. package/dist/src/batteries/models.d.ts +0 -19
  39. package/dist/src/batteries/store.d.ts +0 -13
  40. package/dist/src/builder.d.ts +0 -127
  41. package/dist/src/bun-plugin/tjs-plugin.d.ts +0 -12
  42. package/dist/src/cli/commands/check.d.ts +0 -4
  43. package/dist/src/cli/commands/convert.d.ts +0 -20
  44. package/dist/src/cli/commands/emit.d.ts +0 -34
  45. package/dist/src/cli/commands/run.d.ts +0 -6
  46. package/dist/src/cli/commands/test.d.ts +0 -21
  47. package/dist/src/cli/commands/types.d.ts +0 -4
  48. package/dist/src/cli/create-app.d.ts +0 -9
  49. package/dist/src/cli/playground.d.ts +0 -9
  50. package/dist/src/cli/tjs.d.ts +0 -15
  51. package/dist/src/cli/tjsx.d.ts +0 -16
  52. package/dist/src/index.d.ts +0 -11
  53. package/dist/src/inference.types.d.ts +0 -1
  54. package/dist/src/lang/core.d.ts +0 -56
  55. package/dist/src/lang/docs.d.ts +0 -69
  56. package/dist/src/lang/emitters/ast.d.ts +0 -24
  57. package/dist/src/lang/emitters/dts.d.ts +0 -48
  58. package/dist/src/lang/emitters/from-ts.d.ts +0 -94
  59. package/dist/src/lang/emitters/js-tests.d.ts +0 -70
  60. package/dist/src/lang/emitters/js-wasm.d.ts +0 -15
  61. package/dist/src/lang/emitters/js.d.ts +0 -175
  62. package/dist/src/lang/eval.d.ts +0 -63
  63. package/dist/src/lang/index.d.ts +0 -216
  64. package/dist/src/lang/inference.d.ts +0 -40
  65. package/dist/src/lang/linter.d.ts +0 -53
  66. package/dist/src/lang/metadata-cache.d.ts +0 -172
  67. package/dist/src/lang/parser-params.d.ts +0 -37
  68. package/dist/src/lang/parser-transforms.d.ts +0 -281
  69. package/dist/src/lang/parser-types.d.ts +0 -175
  70. package/dist/src/lang/parser.d.ts +0 -56
  71. package/dist/src/lang/runtime.d.ts +0 -454
  72. package/dist/src/lang/schema.d.ts +0 -35
  73. package/dist/src/lang/tests.d.ts +0 -94
  74. package/dist/src/lang/transpiler.d.ts +0 -25
  75. package/dist/src/lang/types.d.ts +0 -147
  76. package/dist/src/lang/wasm.d.ts +0 -83
  77. package/dist/src/rbac/index.d.ts +0 -85
  78. package/dist/src/rbac/rules.d.ts +0 -184
  79. package/dist/src/runtime.d.ts +0 -4
  80. package/dist/src/store/index.d.ts +0 -3
  81. package/dist/src/store/indexeddb.d.ts +0 -6
  82. package/dist/src/store/interface.d.ts +0 -90
  83. package/dist/src/store/memory.d.ts +0 -10
  84. package/dist/src/test-examples.d.ts +0 -41
  85. package/dist/src/test-utils.d.ts +0 -86
  86. package/dist/src/transpiler/index.d.ts +0 -6
  87. package/dist/src/transpiler/parser.d.ts +0 -4
  88. package/dist/src/transpiler/transformer.d.ts +0 -4
  89. package/dist/src/transpiler/type-system/inference.d.ts +0 -1
  90. package/dist/src/transpiler/types.d.ts +0 -4
  91. package/dist/src/types/LegalDate.d.ts +0 -241
  92. package/dist/src/types/Timestamp.d.ts +0 -233
  93. package/dist/src/types/Type.d.ts +0 -234
  94. package/dist/src/types/index.d.ts +0 -8
  95. package/dist/src/vm/atoms/batteries.d.ts +0 -6
  96. package/dist/src/vm/atoms/browser.d.ts +0 -18
  97. package/dist/src/vm/atoms/index.d.ts +0 -10
  98. package/dist/src/vm/index.d.ts +0 -12
  99. package/dist/src/vm/runtime.d.ts +0 -333
  100. package/dist/src/vm/vm.d.ts +0 -28
  101. package/dist/src/vm.d.ts +0 -4
  102. package/dist/test-preprocess.d.ts +0 -1
  103. package/dist/tjs-batteries.js +0 -4
  104. package/dist/tjs-batteries.js.map +0 -15
  105. package/dist/tjs-full.js +0 -426
  106. package/dist/tjs-full.js.map +0 -45
  107. package/dist/tjs-src/runtime.d.ts +0 -1
  108. package/dist/tjs-transpiler.js +0 -3
  109. package/dist/tjs-transpiler.js.map +0 -11
  110. package/dist/tjs-vm.js +0 -54
  111. package/dist/tjs-vm.js.map +0 -22
@@ -1,53 +0,0 @@
1
- /**
2
- * TJS Linter
3
- *
4
- * Static analysis for TJS code:
5
- * - Unused variables
6
- * - Undefined variables
7
- * - Type mismatches (when __tjs metadata available)
8
- * - Unreachable code
9
- *
10
- * POC: Focus on variable usage first, then type checking.
11
- */
12
- export interface LintDiagnostic {
13
- severity: 'error' | 'warning' | 'info';
14
- message: string;
15
- line?: number;
16
- column?: number;
17
- rule: string;
18
- }
19
- export interface LintResult {
20
- diagnostics: LintDiagnostic[];
21
- valid: boolean;
22
- }
23
- export interface LintOptions {
24
- /** Check for unused variables */
25
- unusedVariables?: boolean;
26
- /** Check for undefined variables */
27
- undefinedVariables?: boolean;
28
- /** Check for unreachable code */
29
- unreachableCode?: boolean;
30
- /** Warn about explicit `new` keyword usage (TJS makes classes callable without new) */
31
- noExplicitNew?: boolean;
32
- /** Filename for error messages */
33
- filename?: string;
34
- }
35
- /**
36
- * Lint TJS source code
37
- */
38
- export declare function lint(source: string, options?: LintOptions): LintResult;
39
- /**
40
- * Questions/Notes for future:
41
- *
42
- * Q1: Should we integrate with __tjs metadata for cross-file type checking?
43
- * - Would need to load metadata from imported modules
44
- * - Could check function call arguments against declared parameter types
45
- *
46
- * Q2: How strict should undefined variable checking be?
47
- * - Currently relies on JS globals being available
48
- * - Could have a whitelist of known globals (console, Math, etc.)
49
- *
50
- * Q3: Should linting be incremental / cacheable?
51
- * - For large projects, re-linting everything is slow
52
- * - Could hash files and skip unchanged ones
53
- */
@@ -1,172 +0,0 @@
1
- /**
2
- * IndexedDB-based cache for module metadata
3
- *
4
- * Caches transpilation results (AST, signatures, type info) to avoid
5
- * re-parsing unchanged source code. Particularly useful for:
6
- * - Playground editors (instant feedback on unchanged code)
7
- * - Autocomplete metadata retrieval
8
- * - Development workflows with rapid iteration
9
- *
10
- * @example
11
- * ```typescript
12
- * const cache = new MetadataCache()
13
- * await cache.open()
14
- *
15
- * // Check cache before transpiling
16
- * const cached = await cache.get(source)
17
- * if (cached) {
18
- * return cached // Skip transpilation
19
- * }
20
- *
21
- * // Transpile and cache
22
- * const result = transpile(source)
23
- * await cache.set(source, result)
24
- * ```
25
- */
26
- import type { SeqNode } from '../builder';
27
- import type { FunctionSignature, TranspileWarning } from './types';
28
- import type { TJSTypeInfo } from './emitters/js';
29
- /** Cached entry for AsyncJS transpilation (ajs/transpile) */
30
- export interface CachedTranspileResult {
31
- ast: SeqNode;
32
- signature: FunctionSignature;
33
- warnings: TranspileWarning[];
34
- }
35
- /** Cached entry for TJS transpilation (tjs/transpileToJS) */
36
- export interface CachedTJSResult {
37
- code: string;
38
- types: Record<string, TJSTypeInfo>;
39
- testRunner?: string;
40
- testCount?: number;
41
- warnings?: string[];
42
- }
43
- /** Full cache entry stored in IndexedDB */
44
- export interface CacheEntry {
45
- /** SHA-256 hash of source + version */
46
- hash: string;
47
- /** TJS version used during transpilation */
48
- version: string;
49
- /** Timestamp when cached */
50
- timestamp: number;
51
- /** AsyncJS transpilation result */
52
- transpile?: CachedTranspileResult;
53
- /** TJS transpilation result */
54
- tjs?: CachedTJSResult;
55
- }
56
- /** Cache statistics */
57
- export interface CacheStats {
58
- /** Number of entries in cache */
59
- entries: number;
60
- /** Total bytes used (approximate) */
61
- bytes: number;
62
- /** Cache hit count this session */
63
- hits: number;
64
- /** Cache miss count this session */
65
- misses: number;
66
- /** Hit rate (hits / (hits + misses)) */
67
- hitRate: number;
68
- }
69
- /**
70
- * Compute SHA-256 hash of source code + version
71
- * Falls back to simple hash if crypto.subtle unavailable
72
- */
73
- export declare function hashSource(source: string): Promise<string>;
74
- /**
75
- * Synchronous hash for environments without async support
76
- * Uses djb2 algorithm
77
- */
78
- export declare function hashSourceSync(source: string): string;
79
- /**
80
- * IndexedDB-based metadata cache
81
- *
82
- * Thread-safe and persistent across browser sessions.
83
- * Automatically handles versioning - entries from old TJS versions
84
- * are ignored (stale data won't cause issues).
85
- */
86
- export declare class MetadataCache {
87
- private db;
88
- private stats;
89
- private pendingOpen;
90
- /**
91
- * Open the cache database
92
- * Safe to call multiple times - will reuse existing connection
93
- */
94
- open(): Promise<void>;
95
- private _open;
96
- /**
97
- * Get cached entry by source code
98
- * Returns undefined if not cached or version mismatch
99
- */
100
- get(source: string): Promise<CacheEntry | undefined>;
101
- /**
102
- * Get cached transpile result (AsyncJS -> AST)
103
- */
104
- getTranspile(source: string): Promise<CachedTranspileResult | undefined>;
105
- /**
106
- * Get cached TJS result (TJS -> JS)
107
- */
108
- getTJS(source: string): Promise<CachedTJSResult | undefined>;
109
- /**
110
- * Store transpile result
111
- */
112
- setTranspile(source: string, result: CachedTranspileResult): Promise<void>;
113
- /**
114
- * Store TJS result
115
- */
116
- setTJS(source: string, result: CachedTJSResult): Promise<void>;
117
- /**
118
- * Store or update cache entry
119
- */
120
- private _set;
121
- /**
122
- * Delete a specific entry
123
- */
124
- delete(source: string): Promise<void>;
125
- /**
126
- * Clear all cached entries
127
- */
128
- clear(): Promise<void>;
129
- /**
130
- * Remove entries older than maxAge milliseconds
131
- * Returns count of entries removed
132
- */
133
- prune(maxAge: number): Promise<number>;
134
- /**
135
- * Remove entries from old TJS versions
136
- * Returns count of entries removed
137
- */
138
- pruneOldVersions(): Promise<number>;
139
- /**
140
- * Get cache statistics
141
- */
142
- getStats(): Promise<CacheStats>;
143
- /**
144
- * Count entries in cache
145
- */
146
- count(): Promise<number>;
147
- /**
148
- * Estimate storage size in bytes
149
- */
150
- estimateSize(): Promise<number>;
151
- /**
152
- * Close the database connection
153
- */
154
- close(): void;
155
- /**
156
- * Check if cache is available (IndexedDB accessible)
157
- */
158
- isAvailable(): boolean;
159
- /**
160
- * Reset session statistics
161
- */
162
- resetStats(): void;
163
- }
164
- /**
165
- * Get or create the global cache instance
166
- * Automatically opens the database on first call
167
- */
168
- export declare function getGlobalCache(): Promise<MetadataCache>;
169
- /**
170
- * Set a custom global cache instance (for testing)
171
- */
172
- export declare function setGlobalCache(cache: MetadataCache | null): void;
@@ -1,37 +0,0 @@
1
- /**
2
- * Parser parameter and annotation processing
3
- *
4
- * Handles the unified paren expression transformer that converts TJS syntax
5
- * (colon defaults, return type annotations, safe/unsafe markers) into valid JS.
6
- */
7
- export declare function transformParenExpressions(source: string, ctx: {
8
- originalSource: string;
9
- requiredParams: Set<string>;
10
- unsafeFunctions: Set<string>;
11
- safeFunctions: Set<string>;
12
- }): {
13
- source: string;
14
- returnType?: string;
15
- returnSafety?: 'safe' | 'unsafe';
16
- };
17
- /**
18
- * Extract a JS value starting at a position in source.
19
- * Handles nested objects {}, arrays [], strings, numbers, booleans, null.
20
- * Uses state machine to properly track nesting.
21
- */
22
- export declare function extractJSValue(source: string, start: number): {
23
- value: string;
24
- endPos: number;
25
- } | null;
26
- /**
27
- * Preprocess source to handle custom syntax extensions
28
- *
29
- * Transforms:
30
- * function foo(x: 'example') { }
31
- * Into:
32
- * function foo(x = 'example') { }
33
- * And tracks that 'x' is a required parameter.
34
- *
35
- * Also handles return type annotation:
36
- * function foo(x: 'example') -> { result: 'string' } { }
37
- */
@@ -1,281 +0,0 @@
1
- /**
2
- * Parser source transforms
3
- *
4
- * All source-to-source text transforms used by the preprocess pipeline.
5
- * These operate on raw source strings before Acorn parsing.
6
- */
7
- import type { WasmBlock, TestBlock } from './parser-types';
8
- export declare function transformTryWithoutCatch(source: string): string;
9
- /**
10
- * Extract WASM blocks from source and replace with runtime dispatch code
11
- *
12
- * Simple form (body used as both WASM source and JS fallback):
13
- * wasm {
14
- * for (let i = 0; i < arr.length; i++) { arr[i] *= 2 }
15
- * }
16
- *
17
- * With explicit fallback (when you need different JS code):
18
- * wasm {
19
- * // WASM-optimized version
20
- * } fallback {
21
- * // Different JS implementation
22
- * }
23
- *
24
- * Output:
25
- * (globalThis.__tjs_wasm_0
26
- * ? globalThis.__tjs_wasm_0(captures...)
27
- * : (() => { body })())
28
- *
29
- * Variables are auto-captured from the body.
30
- */
31
- export declare function extractWasmBlocks(source: string): {
32
- source: string;
33
- blocks: WasmBlock[];
34
- };
35
- /**
36
- * Transform Is/IsNot infix operators to function calls
37
- *
38
- * Syntax:
39
- * a Is b -> Is(a, b)
40
- * a IsNot b -> IsNot(a, b)
41
- *
42
- * This enables structural equality with a clean syntax.
43
- */
44
- export declare function transformIsOperators(source: string): string;
45
- /**
46
- * Insert semicolons to prevent ASI footguns (TjsStandard mode)
47
- *
48
- * JavaScript's ASI (Automatic Semicolon Insertion) has notorious footguns:
49
- *
50
- * foo // Intended: call foo, then IIFE
51
- * (() => {})() // Actual: foo(...)(...) - calls foo with IIFE as argument!
52
- *
53
- * TjsStandard prevents this by treating newlines as statement terminators
54
- * (like Go, Swift, Kotlin). When a line starts with a problematic character
55
- * that could continue the previous line, we insert a semicolon.
56
- *
57
- * Problematic line starts: ( [ / + - `
58
- *
59
- * We only insert when the previous line doesn't already end with:
60
- * - A semicolon
61
- * - An opening brace/bracket/paren (multi-line expression)
62
- * - A comma (array/object literal or params)
63
- * - An operator that clearly continues (+, -, *, /, =, etc.)
64
- * - A keyword that expects continuation (return, throw, etc. followed by value)
65
- */
66
- export declare function insertAsiProtection(source: string): string;
67
- /**
68
- * Transform == and != to Is() and IsNot() calls
69
- *
70
- * In TJS normal mode:
71
- * a == b -> Is(a, b) (structural equality)
72
- * a != b -> IsNot(a, b) (structural inequality)
73
- * a === b -> a === b (identity, unchanged)
74
- *
75
- * Uses a two-pass algorithm:
76
- * 1. Find all == and != positions (outside strings/comments/regex)
77
- * 2. Transform from end to start (so positions remain valid)
78
- */
79
- export declare function transformEqualityToStructural(source: string): string;
80
- /**
81
- * Transform Type block declarations
82
- *
83
- * Syntax forms:
84
- * Type Foo 'example' -> const Foo = Type('Foo', 'example')
85
- * Type Foo { example: 'value' } -> const Foo = Type('Foo', 'value')
86
- * Type Foo 'description' { example: 'value' }
87
- * -> const Foo = Type('description', 'value')
88
- * Type Foo 'description' { example: 0, predicate(x) { return x > 0 } }
89
- * -> const Foo = Type('description', (x) => { ... }, 0)
90
- *
91
- * When predicate + example: auto-generate type guard from example
92
- */
93
- export declare function transformTypeDeclarations(source: string): string;
94
- /**
95
- * Transform FunctionPredicate declarations
96
- *
97
- * Block form:
98
- * FunctionPredicate Callback {
99
- * params: { x: 0, y: '' }
100
- * returns: false
101
- * }
102
- * → const Callback = FunctionPredicate('Callback', { params: { x: 0, y: '' }, returns: false })
103
- *
104
- * Generic block form:
105
- * FunctionPredicate Creator<T = {}> {
106
- * params: { contents: [null] }
107
- * returns: T
108
- * }
109
- * → const Creator = FunctionPredicate('Creator', [['T', {}]], (T) => ({ params: { contents: [null] }, returns: T }))
110
- *
111
- * Function form:
112
- * FunctionPredicate Handler(existingFn, 'description')
113
- * → const Handler = FunctionPredicate('description', existingFn)
114
- */
115
- export declare function transformFunctionPredicateDeclarations(source: string): string;
116
- /**
117
- * Transform Generic block declarations
118
- *
119
- * Syntax:
120
- * Generic Pair<T, U> { description: '...', predicate(obj, T, U) { ... } }
121
- * Generic Container<T, U = ''> { ... } // U has default
122
- *
123
- * Transforms to:
124
- * const Pair = Generic(['T', 'U'], (obj, checkT, checkU) => { ... }, '...')
125
- * const Container = Generic(['T', ['U', '']], (obj, checkT, checkU) => { ... }, '...')
126
- */
127
- export declare function transformGenericDeclarations(source: string): string;
128
- /**
129
- * Transform Union declarations
130
- *
131
- * Syntax:
132
- * Union Direction 'cardinal direction' {
133
- * 'up' | 'down' | 'left' | 'right'
134
- * }
135
- *
136
- * Transforms to:
137
- * const Direction = Union('cardinal direction', ['up', 'down', 'left', 'right'])
138
- *
139
- * Also supports inline form:
140
- * Union Direction 'cardinal direction' 'up' | 'down' | 'left' | 'right'
141
- */
142
- export declare function transformUnionDeclarations(source: string): string;
143
- /**
144
- * Transform Enum declarations
145
- *
146
- * Syntax:
147
- * Enum Status 'task status' {
148
- * Pending
149
- * Active
150
- * Done
151
- * }
152
- *
153
- * Enum Color 'CSS color' {
154
- * Red = 'red'
155
- * Green = 'green'
156
- * Blue = 'blue'
157
- * }
158
- *
159
- * Transforms to:
160
- * const Status = Enum('task status', { Pending: 0, Active: 1, Done: 2 })
161
- * const Color = Enum('CSS color', { Red: 'red', Green: 'green', Blue: 'blue' })
162
- */
163
- export declare function transformEnumDeclarations(source: string): string;
164
- /**
165
- * Extension info for a single extend block
166
- */
167
- export declare function transformExtendDeclarations(source: string): {
168
- source: string;
169
- extensions: Map<string, Set<string>>;
170
- };
171
- /**
172
- * Transform method calls on known-type receivers to use extension objects.
173
- *
174
- * For literals and typed variables where the type is known:
175
- * 'hello'.capitalize() -> __ext_String.capitalize.call('hello')
176
- * [1,2,3].last() -> __ext_Array.last.call([1,2,3])
177
- *
178
- * This is a best-effort source-level transform. For unknown types,
179
- * the runtime fallback (resolveExtension) handles it.
180
- */
181
- export declare function transformExtensionCalls(source: string, extensions: Map<string, Set<string>>): string;
182
- /**
183
- * Compute {line, column} from a character offset in source.
184
- */
185
- export declare function locAt(source: string, pos: number): {
186
- line: number;
187
- column: number;
188
- };
189
- /**
190
- * Find the end of a function body (matching closing brace).
191
- * Handles nested braces, strings, template literals, comments, and regex.
192
- * Returns the index AFTER the closing brace.
193
- */
194
- export declare function findFunctionBodyEnd(source: string, openBracePos: number): number;
195
- /**
196
- * Transform polymorphic functions: multiple function declarations with the
197
- * same name are merged into a single dispatcher function.
198
- *
199
- * Must be called AFTER transformParenExpressions (so params have = defaults)
200
- * but BEFORE wrapClassDeclarations.
201
- *
202
- * function greet(name = '') { ... }
203
- * function greet(first = '', last = '') { ... }
204
- *
205
- * becomes:
206
- *
207
- * function greet$1(name = '') { ... }
208
- * function greet$2(first = '', last = '') { ... }
209
- * function greet(...__args) {
210
- * if (__args.length === 1 && typeof __args[0] === 'string') return greet$1(__args[0])
211
- * if (__args.length === 2 && ...) return greet$2(__args[0], __args[1])
212
- * return __tjs.typeError('greet', 'no matching overload', __args)
213
- * }
214
- */
215
- export declare function transformPolymorphicFunctions(source: string, requiredParams: Set<string>): {
216
- source: string;
217
- polymorphicNames: Set<string>;
218
- };
219
- /**
220
- * Transform bare assignments to const declarations
221
- *
222
- * Foo = ... -> const Foo = ...
223
- *
224
- * Only transforms assignments at statement level (start of line or after semicolon/brace)
225
- * where the identifier starts with uppercase (to avoid breaking normal assignments)
226
- */
227
- export declare function transformBareAssignments(source: string): string;
228
- /**
229
- * Parse source code into an Acorn AST
230
- */
231
- export declare function extractAndRunTests(source: string, skipTests?: boolean): {
232
- source: string;
233
- tests: TestBlock[];
234
- errors: string[];
235
- };
236
- /**
237
- * Wrap class declarations to make them callable without `new`
238
- *
239
- * Transforms:
240
- * class Foo { ... }
241
- * To:
242
- * let Foo = class Foo { ... };
243
- * Foo = new Proxy(Foo, { apply(t, _, a) { return Reflect.construct(t, a) } });
244
- *
245
- * This emits standalone JS with no runtime dependencies.
246
- */
247
- /**
248
- * Transform polymorphic constructors into static factory functions.
249
- *
250
- * When a class has multiple constructor() declarations, the first becomes
251
- * the real constructor and the rest become factory functions. The wrapClass
252
- * Proxy routes through a polymorphic dispatcher.
253
- *
254
- * class Point {
255
- * constructor(x: 0.0, y: 0.0) { this.x = x; this.y = y }
256
- * constructor(coords: { x: 0.0, y: 0.0 }) { this.x = coords.x; this.y = coords.y }
257
- * }
258
- *
259
- * becomes:
260
- *
261
- * class Point {
262
- * constructor(x = 0.0, y = 0.0) { this.x = x; this.y = y }
263
- * }
264
- * function Point$ctor$2(coords = { x: 0.0, y: 0.0 }) { return new Point(coords.x, coords.y) }
265
- * // wrapClass Proxy dispatches through polymorphic factory
266
- */
267
- export declare function transformPolymorphicConstructors(source: string, requiredParams: Set<string>): {
268
- source: string;
269
- polyCtorClasses: Set<string>;
270
- };
271
- export declare function wrapClassDeclarations(source: string, polyCtorClasses?: Set<string>): string;
272
- /**
273
- * Validate that Date is not used (TjsDate mode)
274
- * Throws an error if Date constructor or static methods are found
275
- */
276
- export declare function validateNoDate(source: string): string;
277
- /**
278
- * Validate that eval and Function constructor are not used (TjsNoeval mode)
279
- * Note: Eval and SafeFunction from TJS runtime are allowed
280
- */
281
- export declare function validateNoEval(source: string): string;