@keroway/tdsl-wasm 1.11.0 → 1.13.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 keroway
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,76 @@
1
+ # @keroway/tdsl-wasm
2
+
3
+ WebAssembly bindings for the [Timeline DSL](https://github.com/keroway/timeline-dsl) compiler.
4
+ Compile `.tdsl` source to JSON IR and render it to SVG / HTML directly in the browser — no server required.
5
+
6
+ > **Limitation**: Wikidata imports (`import wikidata` / `query`) are **not** resolved in the browser (no network access). Only static `span`, `event`, and `event_range` items are compiled and rendered. Unresolved imports are silently skipped.
7
+
8
+ ## Install
9
+
10
+ ```bash
11
+ npm install @keroway/tdsl-wasm
12
+ ```
13
+
14
+ ## Usage
15
+
16
+ This package is built with `wasm-pack --target web`, so you must call the default-exported initializer once before using any function (it loads the `.wasm` binary). Works with bundlers such as Vite, webpack, and Rollup.
17
+
18
+ ```js
19
+ import init, {
20
+ compile_to_ir,
21
+ render_svg_from_source,
22
+ render_html_from_source,
23
+ check_source,
24
+ format_source,
25
+ } from "@keroway/tdsl-wasm";
26
+
27
+ // Load the WASM module once at startup.
28
+ await init();
29
+
30
+ const source = `
31
+ timeline "Demo" {
32
+ unit year;
33
+ range 1..100;
34
+ }
35
+ lane "Main" as main { kind dynasty; order 1; }
36
+ span main 10..50 "An era" {};
37
+ `;
38
+
39
+ // Compile to JSON IR (throws on error).
40
+ const ir = JSON.parse(compile_to_ir(source));
41
+
42
+ // Render to SVG. Pass 0 for auto scale (pixels-per-year derived from meta.range).
43
+ const svg = render_svg_from_source(source, 0);
44
+
45
+ // Render to a standalone HTML document.
46
+ const html = render_html_from_source(source);
47
+
48
+ // Lint / diagnostics: returns a JSON array [{severity, message, line, col}] (0-indexed).
49
+ const diagnostics = JSON.parse(check_source(source));
50
+
51
+ // Re-emit normalized source (2-space indent). Comments are not preserved.
52
+ const formatted = format_source(source);
53
+ ```
54
+
55
+ ## API
56
+
57
+ | Function | Signature | Description |
58
+ |---|---|---|
59
+ | `init(module_or_path?)` | `(…) => Promise<InitOutput>` | Default export. Loads the `.wasm` binary. Must be awaited before any call. |
60
+ | `compile_to_ir` | `(source: string) => string` | Compile to JSON IR. Throws on compile error. |
61
+ | `render_svg_from_source` | `(source: string, scale: number) => string` | Render SVG. `scale` = pixels-per-year; pass `0` for auto. |
62
+ | `render_html_from_source` | `(source: string) => string` | Render a standalone HTML document. |
63
+ | `check_source` | `(source: string) => string` | Diagnostics as a JSON array `[{severity, message, line, col}]`. |
64
+ | `format_source` | `(source: string) => string` | Re-emit normalized source from the AST. |
65
+
66
+ Full TypeScript definitions ship with the package (`tdsl_wasm.d.ts`).
67
+
68
+ ## Links
69
+
70
+ - [Timeline DSL repository](https://github.com/keroway/timeline-dsl) — language reference, CLI, examples
71
+ - [DSL Language Reference](https://github.com/keroway/timeline-dsl/blob/main/docs/dsl-spec.en.md)
72
+ - [Issues](https://github.com/keroway/timeline-dsl/issues)
73
+
74
+ ## License
75
+
76
+ MIT
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@keroway/tdsl-wasm",
3
3
  "type": "module",
4
4
  "description": "WebAssembly bindings for the Timeline DSL compiler (static compile + SVG/HTML render)",
5
- "version": "1.11.0",
5
+ "version": "1.13.0",
6
6
  "license": "MIT",
7
7
  "repository": {
8
8
  "type": "git",
@@ -25,5 +25,11 @@
25
25
  "dsl",
26
26
  "svg",
27
27
  "visualization"
28
- ]
29
- }
28
+ ],
29
+ "publishConfig": {
30
+ "access": "public"
31
+ },
32
+ "bugs": {
33
+ "url": "https://github.com/keroway/timeline-dsl/issues"
34
+ }
35
+ }
package/tdsl_wasm_bg.wasm CHANGED
Binary file