tjs-lang 0.8.3 → 0.8.5
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 +23 -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 +104 -100
- package/dist/index.js.map +4 -4
- package/dist/src/lang/browser-from-ts.d.ts +38 -0
- package/dist/src/lang/browser.d.ts +13 -0
- 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/lang/ts-cdn-shim.d.ts +2 -0
- package/dist/src/vm/runtime.d.ts +22 -0
- package/dist/tjs-browser-from-ts.js +58 -0
- package/dist/tjs-browser-from-ts.js.map +7 -0
- package/dist/tjs-browser.js +370 -0
- package/dist/tjs-browser.js.map +7 -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/llms.txt +2 -0
- package/package.json +15 -1
- package/src/lang/browser-bundle.test.ts +69 -0
- package/src/lang/browser-from-ts.ts +81 -0
- package/src/lang/browser.ts +13 -0
- package/src/lang/runtime.test.ts +46 -0
- package/src/lang/ts-cdn-shim.ts +35 -0
- package/src/runtime.test.ts +6 -6
- package/src/vm/equality.test.ts +59 -0
- package/src/vm/runtime.ts +26 -59
package/CLAUDE.md
CHANGED
|
@@ -147,8 +147,30 @@ import { AgentVM } from 'tjs-lang/vm' // VM only (smaller bundle)
|
|
|
147
147
|
import { batteryAtoms } from 'tjs-lang/batteries' // LM Studio batteries
|
|
148
148
|
import { dot, norm_sq } from 'tjs-lang/linalg' // SIMD linear-algebra kernels
|
|
149
149
|
// Editor integrations: 'tjs-lang/editors/monaco', '/codemirror', '/ace'
|
|
150
|
+
|
|
151
|
+
// Self-contained BROWSER bundles — drop-in via import() from any CDN, no
|
|
152
|
+
// import-map/config (acorn + tosijs-schema inlined):
|
|
153
|
+
const { tjs } = await import(
|
|
154
|
+
'https://cdn.jsdelivr.net/npm/tjs-lang/dist/tjs-browser.js'
|
|
155
|
+
)
|
|
156
|
+
// TS→TJS in the browser: lazy-loads the TypeScript compiler from a CDN on first call:
|
|
157
|
+
const { fromTS } = await import(
|
|
158
|
+
'https://cdn.jsdelivr.net/npm/tjs-lang/dist/tjs-browser-from-ts.js'
|
|
159
|
+
)
|
|
160
|
+
// → exports: 'tjs-lang/browser' (TJS/AJS) and 'tjs-lang/browser/from-ts' (TS).
|
|
150
161
|
```
|
|
151
162
|
|
|
163
|
+
**Browser bundles + CDN reality** (build targets `tjs-browser` / `tjs-browser-from-ts`
|
|
164
|
+
in `scripts/build.ts`; `src/lang/browser.ts`, `browser-from-ts.ts`, `ts-cdn-shim.ts`):
|
|
165
|
+
the TJS/AJS bundle is fully self-contained → loads from **any** CDN (jsDelivr,
|
|
166
|
+
unpkg, esm.sh). The TS path lazy-loads the `typescript` compiler from a CDN on
|
|
167
|
+
demand (Proxy shim aliased over `from-ts`'s `typescript` import; no source change).
|
|
168
|
+
**Verified in a real browser: esm.sh is the ONLY CDN that reliably serves
|
|
169
|
+
`typescript`** (~700ms) — jsDelivr `+esm` / esm.run time out on its ~10MB CJS,
|
|
170
|
+
skypack is dead. So `DEFAULT_TYPESCRIPT_URL = https://esm.sh/typescript@5`,
|
|
171
|
+
overridable via `fromTS(src, { typescriptUrl })` or by preloading
|
|
172
|
+
`globalThis.__TJS_TS__`. Self-containment guarded by `src/lang/browser-bundle.test.ts`.
|
|
173
|
+
|
|
152
174
|
### Transpiler Chain (TS → TJS → JS)
|
|
153
175
|
|
|
154
176
|
TJS supports transpiling TypeScript to JavaScript with runtime type validation. The pipeline has two distinct, independently testable steps:
|
|
@@ -314,7 +336,7 @@ Full syntax documentation is in [`CLAUDE-TJS-SYNTAX.md`](CLAUDE-TJS-SYNTAX.md).
|
|
|
314
336
|
- **Bang access**: `x!.foo` — returns MonadicError if `x` is null/undefined, otherwise bare `x.foo`. Chains propagate: `x!.foo!.bar`.
|
|
315
337
|
- **Type/Generic/FunctionPredicate**: Three declaration forms for runtime type predicates
|
|
316
338
|
- **`const!`**: Compile-time immutability, zero runtime cost
|
|
317
|
-
- **Equality**: `==`/`!=`
|
|
339
|
+
- **Equality**: `==`/`!=` in native TJS (via `Eq`/`NotEq` under `TjsEquals`) are **footgun-free `===`** — they unwrap boxed primitives (`new Boolean(false) == false`) and treat `null`/`undefined` as equal, but do **NOT** coerce types (`'5' != 5`, `'' != false`) and are **NOT structural** (distinct objects/arrays are distinct: `{a:1} != {a:1}` — a real distinction, and structural `==` would be a silent O(n) hit). For deep structural comparison use the `Is`/`IsNot` function (or a type's `.Equals` hook). `===`/`!==` = strict identity.
|
|
318
340
|
- **Polymorphic functions**: Multiple same-name declarations merge into arity/type dispatcher
|
|
319
341
|
- **`extend` blocks**: Local class extensions without prototype pollution
|
|
320
342
|
- **WASM blocks**: Inline WebAssembly compiled at transpile time, with SIMD intrinsics and `wasmBuffer()` zero-copy arrays
|