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.
@@ -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 blocks extracted from source (need to be compiled before execution) */
81
- wasmBlocks?: import('../parser').WasmBlock[];
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 */
@@ -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, compileWasmBlocksForIframe, generateWasmInstantiationCode, type WasmCompileResult, type CompiledWasmData, } from './wasm';
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';