tjs-lang 0.2.7 → 0.2.8
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/demo/docs.json +15 -15
- package/demo/src/tjs-playground.ts +18 -27
- package/dist/index.js +108 -160
- package/dist/index.js.map +6 -6
- package/dist/src/lang/emitters/js.d.ts +34 -2
- package/dist/src/lang/index.d.ts +1 -1
- package/dist/tjs-full.js +108 -160
- package/dist/tjs-full.js.map +6 -6
- package/dist/tjs-transpiler.js +87 -55
- package/dist/tjs-transpiler.js.map +5 -4
- package/docs/docs.json +792 -0
- package/docs/index.js +1962 -1875
- package/docs/index.js.map +7 -7
- package/package.json +1 -1
- package/src/lang/emitters/js.ts +154 -4
- package/src/lang/index.ts +0 -3
- package/src/lang/lang.test.ts +38 -19
- package/src/lang/roundtrip.test.ts +155 -0
- package/src/lang/wasm.test.ts +20 -0
- package/src/lang/wasm.ts +143 -0
|
@@ -17,6 +17,33 @@
|
|
|
17
17
|
* params: { name: { type: 'string', required: true, example: 'world' } },
|
|
18
18
|
* returns: { type: 'string' }
|
|
19
19
|
* }
|
|
20
|
+
*
|
|
21
|
+
* TODO: Self-contained output (no runtime dependency)
|
|
22
|
+
* =====================================================
|
|
23
|
+
* Currently, transpiled code references `globalThis.__tjs` for:
|
|
24
|
+
* - __tjs.pushStack() / popStack() - debug stack traces
|
|
25
|
+
* - __tjs.typeError() - monadic error creation
|
|
26
|
+
* - __tjs.Is() / IsNot() - structural equality (when == / != used)
|
|
27
|
+
*
|
|
28
|
+
* This requires either:
|
|
29
|
+
* 1. The runtime to be installed via installRuntime()
|
|
30
|
+
* 2. A stub to be provided (e.g., playground's inline stub)
|
|
31
|
+
*
|
|
32
|
+
* The ideal is that TJS produces completely independent code that only needs
|
|
33
|
+
* things it semantically needs (like fetch for HTTP calls). The runtime
|
|
34
|
+
* functions above are ~30 lines and could be inlined when used:
|
|
35
|
+
*
|
|
36
|
+
* - typeError: Create a simple Error with extra properties
|
|
37
|
+
* - pushStack/popStack: Could be no-ops in production, or inline array ops
|
|
38
|
+
* - Is/IsNot: ~20 lines for deep structural equality
|
|
39
|
+
*
|
|
40
|
+
* Options to explore:
|
|
41
|
+
* 1. Inline minimal runtime when needed (adds ~1KB unminified per output)
|
|
42
|
+
* 2. Add transpile option: { standalone: true } to emit self-contained code
|
|
43
|
+
* 3. Tree-shake: only inline the specific functions actually referenced
|
|
44
|
+
*
|
|
45
|
+
* See also: demo/src/tjs-playground.ts which has a manual __tjs stub that
|
|
46
|
+
* must stay in sync with the runtime - a symptom of this leaky abstraction.
|
|
20
47
|
*/
|
|
21
48
|
import type { TypeDescriptor, ParameterDescriptor } from '../types';
|
|
22
49
|
export interface TJSTranspileOptions {
|
|
@@ -77,8 +104,13 @@ export interface TJSTranspileResult {
|
|
|
77
104
|
testCount?: number;
|
|
78
105
|
/** Test results (when runTests is true or 'only') */
|
|
79
106
|
testResults?: TestResult[];
|
|
80
|
-
/** WASM
|
|
81
|
-
|
|
107
|
+
/** WASM compilation results (for debugging/inspection) */
|
|
108
|
+
wasmCompiled?: {
|
|
109
|
+
id: string;
|
|
110
|
+
success: boolean;
|
|
111
|
+
error?: string;
|
|
112
|
+
byteLength?: number;
|
|
113
|
+
}[];
|
|
82
114
|
}
|
|
83
115
|
export interface TJSTypeInfo {
|
|
84
116
|
/** Function name */
|
package/dist/src/lang/index.d.ts
CHANGED
|
@@ -34,7 +34,7 @@ export { lint, type LintResult, type LintDiagnostic, type LintOptions, } from '.
|
|
|
34
34
|
export { generateDocs, generateDocsMarkdown, type DocResult, type DocItem, type FunctionTypeInfo, type ParamTypeInfo, } from './docs';
|
|
35
35
|
export { extractTests, assertFunction, expectFunction, testUtils, type ExtractedTest, type ExtractedMock, type TestExtractionResult, } from './tests';
|
|
36
36
|
export { runtime, installRuntime, isError, error, typeOf, checkType, validateArgs, wrap, emitRuntimeWrapper, TJS_VERSION, type TJSError, } from './runtime';
|
|
37
|
-
export { compileToWasm, instantiateWasm, registerWasmBlock, compileWasmBlocks,
|
|
37
|
+
export { compileToWasm, instantiateWasm, registerWasmBlock, compileWasmBlocks, type WasmCompileResult, } from './wasm';
|
|
38
38
|
export type { WasmBlock } from './parser';
|
|
39
39
|
export { Eval, SafeFunction, type EvalOptions, type SafeFunctionOptions, } from './eval';
|
|
40
40
|
export { hashSource, hashSourceSync, type CacheEntry, type CachedTranspileResult, type CachedTJSResult, type CacheStats, } from './metadata-cache';
|