@keroway/tdsl-wasm 1.16.0 → 1.18.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/package.json +1 -1
- package/tdsl_wasm.d.ts +92 -5
- package/tdsl_wasm.js +310 -5
- package/tdsl_wasm_bg.wasm +0 -0
package/package.json
CHANGED
package/tdsl_wasm.d.ts
CHANGED
|
@@ -1,11 +1,43 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Rendering options exposed to JavaScript.
|
|
6
|
+
*
|
|
7
|
+
* Create with `new JsRenderOptions()` — all fields default to the same values
|
|
8
|
+
* as `RenderOptions::default()`. String fields (`orientation`, `grid`, `theme`)
|
|
9
|
+
* accept the lowercase variant names defined below.
|
|
10
|
+
*
|
|
11
|
+
* | Field | Accepted values | Default |
|
|
12
|
+
* |-------|----------------|---------|
|
|
13
|
+
* | `orientation` | `"horizontal"`, `"vertical"` | `"horizontal"` |
|
|
14
|
+
* | `grid` | `"none"`, `"decade"`, `"year"`, `"month"` | `"none"` |
|
|
15
|
+
* | `theme` | `"default"`, `"dark"`, `"print"`, `"pastel"` | `"default"` |
|
|
16
|
+
* | `show_table` | `true`, `false` | `false` |
|
|
17
|
+
* | `show_event_labels` | `true`, `false` | `false` |
|
|
18
|
+
*/
|
|
19
|
+
export class JsRenderOptions {
|
|
20
|
+
free(): void;
|
|
21
|
+
[Symbol.dispose](): void;
|
|
22
|
+
constructor();
|
|
23
|
+
/**
|
|
24
|
+
* When true, labels are rendered next to Event/EventRange items.
|
|
25
|
+
*/
|
|
26
|
+
show_event_labels: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* `"horizontal"` (default) or `"vertical"`
|
|
29
|
+
*/
|
|
30
|
+
show_table: boolean;
|
|
31
|
+
grid: string;
|
|
32
|
+
orientation: string;
|
|
33
|
+
theme: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
4
36
|
/**
|
|
5
37
|
* Check TDSL source and return diagnostics as JSON.
|
|
6
38
|
*
|
|
7
39
|
* Returns a JSON array of diagnostic objects: `[{severity, message, line, col}]`.
|
|
8
|
-
* `severity` is `"error"` or `"
|
|
40
|
+
* `severity` is `"error"`, `"warning"`, or `"info"`.
|
|
9
41
|
*
|
|
10
42
|
* `line`/`col` are **1-based** when a source position is available (parse errors via
|
|
11
43
|
* `ParseError::source_location`, validation warnings via the item's `source_span`),
|
|
@@ -13,10 +45,9 @@
|
|
|
13
45
|
* attributes. Diagnostics that carry no position (lowering errors such as unknown-lane
|
|
14
46
|
* references) report `line: 0, col: 0`; the WebUI treats a `0` line as non-clickable.
|
|
15
47
|
*
|
|
16
|
-
* **Note on `import` blocks**:
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* `event`, and `event_range` statements for content that must render in the browser.
|
|
48
|
+
* **Note on `import`/`map` blocks**: Wikidata fetch is not available in the browser.
|
|
49
|
+
* Each `import` or `map` block receives an `"info"` diagnostic pointing to its start
|
|
50
|
+
* line so the user knows to run `tdsl build` for full resolution.
|
|
20
51
|
*/
|
|
21
52
|
export function check_source(source: string): string;
|
|
22
53
|
|
|
@@ -37,6 +68,32 @@ export function compile_to_ir(source: string): string;
|
|
|
37
68
|
*/
|
|
38
69
|
export function format_source(source: string): string;
|
|
39
70
|
|
|
71
|
+
/**
|
|
72
|
+
* Apply `tdsl lint --fix` to TDSL source and return the rewritten source.
|
|
73
|
+
*
|
|
74
|
+
* - When at least one fixable issue is applied, the rewritten source is returned.
|
|
75
|
+
* - When the input has no fixable issues, the original source is returned unchanged
|
|
76
|
+
* (callers can compare lengths / equality to detect a no-op).
|
|
77
|
+
* - On parse failure, returns `Err(parse_error_message)`.
|
|
78
|
+
*
|
|
79
|
+
* Comments are not preserved because `tdsl-parser` skips them at the PEG layer,
|
|
80
|
+
* matching the behavior of `format_source` and the `tdsl lint --fix` CLI.
|
|
81
|
+
*/
|
|
82
|
+
export function lint_fix_source(source: string): string;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Run lint rules on TDSL source and return issues as JSON.
|
|
86
|
+
*
|
|
87
|
+
* Returns a JSON array of `{code, severity, line, message, fixable}` objects.
|
|
88
|
+
* `severity` is `"error"` or `"warning"` (lint does not emit `"info"`).
|
|
89
|
+
* `line` is **1-based** and matches `check_source`'s line numbering.
|
|
90
|
+
* `fixable` is `true` when `lint_fix_source` can automatically resolve the issue.
|
|
91
|
+
*
|
|
92
|
+
* On parse error, the array contains a single entry with `code: "parse_error"`
|
|
93
|
+
* so callers can still surface the failure through the same path as lint issues.
|
|
94
|
+
*/
|
|
95
|
+
export function lint_source(source: string): string;
|
|
96
|
+
|
|
40
97
|
/**
|
|
41
98
|
* Initialize the panic hook for better error messages in the browser console.
|
|
42
99
|
*/
|
|
@@ -48,6 +105,12 @@ export function main(): void;
|
|
|
48
105
|
*/
|
|
49
106
|
export function render_html_from_source(source: string): string;
|
|
50
107
|
|
|
108
|
+
/**
|
|
109
|
+
* Render standalone HTML from TDSL source with explicit render options.
|
|
110
|
+
* Returns Ok(html_string) or Err(error_message).
|
|
111
|
+
*/
|
|
112
|
+
export function render_html_from_source_with_options(source: string, opts: JsRenderOptions): string;
|
|
113
|
+
|
|
51
114
|
/**
|
|
52
115
|
* Render SVG from TDSL source (static items only).
|
|
53
116
|
* `scale` controls pixels-per-year. Pass `0.0` (or negative) to auto-calculate
|
|
@@ -58,15 +121,39 @@ export function render_html_from_source(source: string): string;
|
|
|
58
121
|
*/
|
|
59
122
|
export function render_svg_from_source(source: string, scale: number): string;
|
|
60
123
|
|
|
124
|
+
/**
|
|
125
|
+
* Render SVG from TDSL source with explicit render options.
|
|
126
|
+
*
|
|
127
|
+
* `scale` controls pixels-per-year. Pass `0.0` (or negative) to auto-calculate.
|
|
128
|
+
* Returns Ok(svg_string) or Err(error_message).
|
|
129
|
+
*/
|
|
130
|
+
export function render_svg_from_source_with_options(source: string, scale: number, opts: JsRenderOptions): string;
|
|
131
|
+
|
|
61
132
|
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
62
133
|
|
|
63
134
|
export interface InitOutput {
|
|
64
135
|
readonly memory: WebAssembly.Memory;
|
|
136
|
+
readonly __wbg_get_jsrenderoptions_show_event_labels: (a: number) => number;
|
|
137
|
+
readonly __wbg_get_jsrenderoptions_show_table: (a: number) => number;
|
|
138
|
+
readonly __wbg_jsrenderoptions_free: (a: number, b: number) => void;
|
|
139
|
+
readonly __wbg_set_jsrenderoptions_show_event_labels: (a: number, b: number) => void;
|
|
140
|
+
readonly __wbg_set_jsrenderoptions_show_table: (a: number, b: number) => void;
|
|
65
141
|
readonly check_source: (a: number, b: number, c: number) => void;
|
|
66
142
|
readonly compile_to_ir: (a: number, b: number, c: number) => void;
|
|
67
143
|
readonly format_source: (a: number, b: number, c: number) => void;
|
|
144
|
+
readonly jsrenderoptions_grid: (a: number, b: number) => void;
|
|
145
|
+
readonly jsrenderoptions_new: () => number;
|
|
146
|
+
readonly jsrenderoptions_orientation: (a: number, b: number) => void;
|
|
147
|
+
readonly jsrenderoptions_set_grid: (a: number, b: number, c: number) => void;
|
|
148
|
+
readonly jsrenderoptions_set_orientation: (a: number, b: number, c: number) => void;
|
|
149
|
+
readonly jsrenderoptions_set_theme: (a: number, b: number, c: number) => void;
|
|
150
|
+
readonly jsrenderoptions_theme: (a: number, b: number) => void;
|
|
151
|
+
readonly lint_fix_source: (a: number, b: number, c: number) => void;
|
|
152
|
+
readonly lint_source: (a: number, b: number, c: number) => void;
|
|
68
153
|
readonly render_html_from_source: (a: number, b: number, c: number) => void;
|
|
154
|
+
readonly render_html_from_source_with_options: (a: number, b: number, c: number, d: number) => void;
|
|
69
155
|
readonly render_svg_from_source: (a: number, b: number, c: number, d: number) => void;
|
|
156
|
+
readonly render_svg_from_source_with_options: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
70
157
|
readonly main: () => void;
|
|
71
158
|
readonly __wbindgen_export: (a: number, b: number, c: number) => void;
|
|
72
159
|
readonly __wbindgen_export2: (a: number, b: number) => number;
|
package/tdsl_wasm.js
CHANGED
|
@@ -1,10 +1,156 @@
|
|
|
1
1
|
/* @ts-self-types="./tdsl_wasm.d.ts" */
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Rendering options exposed to JavaScript.
|
|
5
|
+
*
|
|
6
|
+
* Create with `new JsRenderOptions()` — all fields default to the same values
|
|
7
|
+
* as `RenderOptions::default()`. String fields (`orientation`, `grid`, `theme`)
|
|
8
|
+
* accept the lowercase variant names defined below.
|
|
9
|
+
*
|
|
10
|
+
* | Field | Accepted values | Default |
|
|
11
|
+
* |-------|----------------|---------|
|
|
12
|
+
* | `orientation` | `"horizontal"`, `"vertical"` | `"horizontal"` |
|
|
13
|
+
* | `grid` | `"none"`, `"decade"`, `"year"`, `"month"` | `"none"` |
|
|
14
|
+
* | `theme` | `"default"`, `"dark"`, `"print"`, `"pastel"` | `"default"` |
|
|
15
|
+
* | `show_table` | `true`, `false` | `false` |
|
|
16
|
+
* | `show_event_labels` | `true`, `false` | `false` |
|
|
17
|
+
*/
|
|
18
|
+
export class JsRenderOptions {
|
|
19
|
+
__destroy_into_raw() {
|
|
20
|
+
const ptr = this.__wbg_ptr;
|
|
21
|
+
this.__wbg_ptr = 0;
|
|
22
|
+
JsRenderOptionsFinalization.unregister(this);
|
|
23
|
+
return ptr;
|
|
24
|
+
}
|
|
25
|
+
free() {
|
|
26
|
+
const ptr = this.__destroy_into_raw();
|
|
27
|
+
wasm.__wbg_jsrenderoptions_free(ptr, 0);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* When true, labels are rendered next to Event/EventRange items.
|
|
31
|
+
* @returns {boolean}
|
|
32
|
+
*/
|
|
33
|
+
get show_event_labels() {
|
|
34
|
+
const ret = wasm.__wbg_get_jsrenderoptions_show_event_labels(this.__wbg_ptr);
|
|
35
|
+
return ret !== 0;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* `"horizontal"` (default) or `"vertical"`
|
|
39
|
+
* @returns {boolean}
|
|
40
|
+
*/
|
|
41
|
+
get show_table() {
|
|
42
|
+
const ret = wasm.__wbg_get_jsrenderoptions_show_table(this.__wbg_ptr);
|
|
43
|
+
return ret !== 0;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* @returns {string}
|
|
47
|
+
*/
|
|
48
|
+
get grid() {
|
|
49
|
+
let deferred1_0;
|
|
50
|
+
let deferred1_1;
|
|
51
|
+
try {
|
|
52
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
53
|
+
wasm.jsrenderoptions_grid(retptr, this.__wbg_ptr);
|
|
54
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
55
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
56
|
+
deferred1_0 = r0;
|
|
57
|
+
deferred1_1 = r1;
|
|
58
|
+
return getStringFromWasm0(r0, r1);
|
|
59
|
+
} finally {
|
|
60
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
61
|
+
wasm.__wbindgen_export(deferred1_0, deferred1_1, 1);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
constructor() {
|
|
65
|
+
const ret = wasm.jsrenderoptions_new();
|
|
66
|
+
this.__wbg_ptr = ret >>> 0;
|
|
67
|
+
JsRenderOptionsFinalization.register(this, this.__wbg_ptr, this);
|
|
68
|
+
return this;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* @returns {string}
|
|
72
|
+
*/
|
|
73
|
+
get orientation() {
|
|
74
|
+
let deferred1_0;
|
|
75
|
+
let deferred1_1;
|
|
76
|
+
try {
|
|
77
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
78
|
+
wasm.jsrenderoptions_orientation(retptr, this.__wbg_ptr);
|
|
79
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
80
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
81
|
+
deferred1_0 = r0;
|
|
82
|
+
deferred1_1 = r1;
|
|
83
|
+
return getStringFromWasm0(r0, r1);
|
|
84
|
+
} finally {
|
|
85
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
86
|
+
wasm.__wbindgen_export(deferred1_0, deferred1_1, 1);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* @param {string} val
|
|
91
|
+
*/
|
|
92
|
+
set grid(val) {
|
|
93
|
+
const ptr0 = passStringToWasm0(val, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
|
|
94
|
+
const len0 = WASM_VECTOR_LEN;
|
|
95
|
+
wasm.jsrenderoptions_set_grid(this.__wbg_ptr, ptr0, len0);
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* @param {string} val
|
|
99
|
+
*/
|
|
100
|
+
set orientation(val) {
|
|
101
|
+
const ptr0 = passStringToWasm0(val, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
|
|
102
|
+
const len0 = WASM_VECTOR_LEN;
|
|
103
|
+
wasm.jsrenderoptions_set_orientation(this.__wbg_ptr, ptr0, len0);
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* @param {string} val
|
|
107
|
+
*/
|
|
108
|
+
set theme(val) {
|
|
109
|
+
const ptr0 = passStringToWasm0(val, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
|
|
110
|
+
const len0 = WASM_VECTOR_LEN;
|
|
111
|
+
wasm.jsrenderoptions_set_theme(this.__wbg_ptr, ptr0, len0);
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* @returns {string}
|
|
115
|
+
*/
|
|
116
|
+
get theme() {
|
|
117
|
+
let deferred1_0;
|
|
118
|
+
let deferred1_1;
|
|
119
|
+
try {
|
|
120
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
121
|
+
wasm.jsrenderoptions_theme(retptr, this.__wbg_ptr);
|
|
122
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
123
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
124
|
+
deferred1_0 = r0;
|
|
125
|
+
deferred1_1 = r1;
|
|
126
|
+
return getStringFromWasm0(r0, r1);
|
|
127
|
+
} finally {
|
|
128
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
129
|
+
wasm.__wbindgen_export(deferred1_0, deferred1_1, 1);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* When true, labels are rendered next to Event/EventRange items.
|
|
134
|
+
* @param {boolean} arg0
|
|
135
|
+
*/
|
|
136
|
+
set show_event_labels(arg0) {
|
|
137
|
+
wasm.__wbg_set_jsrenderoptions_show_event_labels(this.__wbg_ptr, arg0);
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* `"horizontal"` (default) or `"vertical"`
|
|
141
|
+
* @param {boolean} arg0
|
|
142
|
+
*/
|
|
143
|
+
set show_table(arg0) {
|
|
144
|
+
wasm.__wbg_set_jsrenderoptions_show_table(this.__wbg_ptr, arg0);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
if (Symbol.dispose) JsRenderOptions.prototype[Symbol.dispose] = JsRenderOptions.prototype.free;
|
|
148
|
+
|
|
3
149
|
/**
|
|
4
150
|
* Check TDSL source and return diagnostics as JSON.
|
|
5
151
|
*
|
|
6
152
|
* Returns a JSON array of diagnostic objects: `[{severity, message, line, col}]`.
|
|
7
|
-
* `severity` is `"error"` or `"
|
|
153
|
+
* `severity` is `"error"`, `"warning"`, or `"info"`.
|
|
8
154
|
*
|
|
9
155
|
* `line`/`col` are **1-based** when a source position is available (parse errors via
|
|
10
156
|
* `ParseError::source_location`, validation warnings via the item's `source_span`),
|
|
@@ -12,10 +158,9 @@
|
|
|
12
158
|
* attributes. Diagnostics that carry no position (lowering errors such as unknown-lane
|
|
13
159
|
* references) report `line: 0, col: 0`; the WebUI treats a `0` line as non-clickable.
|
|
14
160
|
*
|
|
15
|
-
* **Note on `import` blocks**:
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* `event`, and `event_range` statements for content that must render in the browser.
|
|
161
|
+
* **Note on `import`/`map` blocks**: Wikidata fetch is not available in the browser.
|
|
162
|
+
* Each `import` or `map` block receives an `"info"` diagnostic pointing to its start
|
|
163
|
+
* line so the user knows to run `tdsl build` for full resolution.
|
|
19
164
|
* @param {string} source
|
|
20
165
|
* @returns {string}
|
|
21
166
|
*/
|
|
@@ -109,6 +254,78 @@ export function format_source(source) {
|
|
|
109
254
|
}
|
|
110
255
|
}
|
|
111
256
|
|
|
257
|
+
/**
|
|
258
|
+
* Apply `tdsl lint --fix` to TDSL source and return the rewritten source.
|
|
259
|
+
*
|
|
260
|
+
* - When at least one fixable issue is applied, the rewritten source is returned.
|
|
261
|
+
* - When the input has no fixable issues, the original source is returned unchanged
|
|
262
|
+
* (callers can compare lengths / equality to detect a no-op).
|
|
263
|
+
* - On parse failure, returns `Err(parse_error_message)`.
|
|
264
|
+
*
|
|
265
|
+
* Comments are not preserved because `tdsl-parser` skips them at the PEG layer,
|
|
266
|
+
* matching the behavior of `format_source` and the `tdsl lint --fix` CLI.
|
|
267
|
+
* @param {string} source
|
|
268
|
+
* @returns {string}
|
|
269
|
+
*/
|
|
270
|
+
export function lint_fix_source(source) {
|
|
271
|
+
let deferred3_0;
|
|
272
|
+
let deferred3_1;
|
|
273
|
+
try {
|
|
274
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
275
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
|
|
276
|
+
const len0 = WASM_VECTOR_LEN;
|
|
277
|
+
wasm.lint_fix_source(retptr, ptr0, len0);
|
|
278
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
279
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
280
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
281
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
282
|
+
var ptr2 = r0;
|
|
283
|
+
var len2 = r1;
|
|
284
|
+
if (r3) {
|
|
285
|
+
ptr2 = 0; len2 = 0;
|
|
286
|
+
throw takeObject(r2);
|
|
287
|
+
}
|
|
288
|
+
deferred3_0 = ptr2;
|
|
289
|
+
deferred3_1 = len2;
|
|
290
|
+
return getStringFromWasm0(ptr2, len2);
|
|
291
|
+
} finally {
|
|
292
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
293
|
+
wasm.__wbindgen_export(deferred3_0, deferred3_1, 1);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* Run lint rules on TDSL source and return issues as JSON.
|
|
299
|
+
*
|
|
300
|
+
* Returns a JSON array of `{code, severity, line, message, fixable}` objects.
|
|
301
|
+
* `severity` is `"error"` or `"warning"` (lint does not emit `"info"`).
|
|
302
|
+
* `line` is **1-based** and matches `check_source`'s line numbering.
|
|
303
|
+
* `fixable` is `true` when `lint_fix_source` can automatically resolve the issue.
|
|
304
|
+
*
|
|
305
|
+
* On parse error, the array contains a single entry with `code: "parse_error"`
|
|
306
|
+
* so callers can still surface the failure through the same path as lint issues.
|
|
307
|
+
* @param {string} source
|
|
308
|
+
* @returns {string}
|
|
309
|
+
*/
|
|
310
|
+
export function lint_source(source) {
|
|
311
|
+
let deferred2_0;
|
|
312
|
+
let deferred2_1;
|
|
313
|
+
try {
|
|
314
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
315
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
|
|
316
|
+
const len0 = WASM_VECTOR_LEN;
|
|
317
|
+
wasm.lint_source(retptr, ptr0, len0);
|
|
318
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
319
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
320
|
+
deferred2_0 = r0;
|
|
321
|
+
deferred2_1 = r1;
|
|
322
|
+
return getStringFromWasm0(r0, r1);
|
|
323
|
+
} finally {
|
|
324
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
325
|
+
wasm.__wbindgen_export(deferred2_0, deferred2_1, 1);
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
|
|
112
329
|
/**
|
|
113
330
|
* Initialize the panic hook for better error messages in the browser console.
|
|
114
331
|
*/
|
|
@@ -149,6 +366,42 @@ export function render_html_from_source(source) {
|
|
|
149
366
|
}
|
|
150
367
|
}
|
|
151
368
|
|
|
369
|
+
/**
|
|
370
|
+
* Render standalone HTML from TDSL source with explicit render options.
|
|
371
|
+
* Returns Ok(html_string) or Err(error_message).
|
|
372
|
+
* @param {string} source
|
|
373
|
+
* @param {JsRenderOptions} opts
|
|
374
|
+
* @returns {string}
|
|
375
|
+
*/
|
|
376
|
+
export function render_html_from_source_with_options(source, opts) {
|
|
377
|
+
let deferred4_0;
|
|
378
|
+
let deferred4_1;
|
|
379
|
+
try {
|
|
380
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
381
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
|
|
382
|
+
const len0 = WASM_VECTOR_LEN;
|
|
383
|
+
_assertClass(opts, JsRenderOptions);
|
|
384
|
+
var ptr1 = opts.__destroy_into_raw();
|
|
385
|
+
wasm.render_html_from_source_with_options(retptr, ptr0, len0, ptr1);
|
|
386
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
387
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
388
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
389
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
390
|
+
var ptr3 = r0;
|
|
391
|
+
var len3 = r1;
|
|
392
|
+
if (r3) {
|
|
393
|
+
ptr3 = 0; len3 = 0;
|
|
394
|
+
throw takeObject(r2);
|
|
395
|
+
}
|
|
396
|
+
deferred4_0 = ptr3;
|
|
397
|
+
deferred4_1 = len3;
|
|
398
|
+
return getStringFromWasm0(ptr3, len3);
|
|
399
|
+
} finally {
|
|
400
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
401
|
+
wasm.__wbindgen_export(deferred4_0, deferred4_1, 1);
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
|
|
152
405
|
/**
|
|
153
406
|
* Render SVG from TDSL source (static items only).
|
|
154
407
|
* `scale` controls pixels-per-year. Pass `0.0` (or negative) to auto-calculate
|
|
@@ -186,9 +439,51 @@ export function render_svg_from_source(source, scale) {
|
|
|
186
439
|
wasm.__wbindgen_export(deferred3_0, deferred3_1, 1);
|
|
187
440
|
}
|
|
188
441
|
}
|
|
442
|
+
|
|
443
|
+
/**
|
|
444
|
+
* Render SVG from TDSL source with explicit render options.
|
|
445
|
+
*
|
|
446
|
+
* `scale` controls pixels-per-year. Pass `0.0` (or negative) to auto-calculate.
|
|
447
|
+
* Returns Ok(svg_string) or Err(error_message).
|
|
448
|
+
* @param {string} source
|
|
449
|
+
* @param {number} scale
|
|
450
|
+
* @param {JsRenderOptions} opts
|
|
451
|
+
* @returns {string}
|
|
452
|
+
*/
|
|
453
|
+
export function render_svg_from_source_with_options(source, scale, opts) {
|
|
454
|
+
let deferred4_0;
|
|
455
|
+
let deferred4_1;
|
|
456
|
+
try {
|
|
457
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
458
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
|
|
459
|
+
const len0 = WASM_VECTOR_LEN;
|
|
460
|
+
_assertClass(opts, JsRenderOptions);
|
|
461
|
+
var ptr1 = opts.__destroy_into_raw();
|
|
462
|
+
wasm.render_svg_from_source_with_options(retptr, ptr0, len0, scale, ptr1);
|
|
463
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
464
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
465
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
466
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
467
|
+
var ptr3 = r0;
|
|
468
|
+
var len3 = r1;
|
|
469
|
+
if (r3) {
|
|
470
|
+
ptr3 = 0; len3 = 0;
|
|
471
|
+
throw takeObject(r2);
|
|
472
|
+
}
|
|
473
|
+
deferred4_0 = ptr3;
|
|
474
|
+
deferred4_1 = len3;
|
|
475
|
+
return getStringFromWasm0(ptr3, len3);
|
|
476
|
+
} finally {
|
|
477
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
478
|
+
wasm.__wbindgen_export(deferred4_0, deferred4_1, 1);
|
|
479
|
+
}
|
|
480
|
+
}
|
|
189
481
|
function __wbg_get_imports() {
|
|
190
482
|
const import0 = {
|
|
191
483
|
__proto__: null,
|
|
484
|
+
__wbg___wbindgen_throw_6b64449b9b9ed33c: function(arg0, arg1) {
|
|
485
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
486
|
+
},
|
|
192
487
|
__wbg_error_a6fa202b58aa1cd3: function(arg0, arg1) {
|
|
193
488
|
let deferred0_0;
|
|
194
489
|
let deferred0_1;
|
|
@@ -226,6 +521,10 @@ function __wbg_get_imports() {
|
|
|
226
521
|
};
|
|
227
522
|
}
|
|
228
523
|
|
|
524
|
+
const JsRenderOptionsFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
525
|
+
? { register: () => {}, unregister: () => {} }
|
|
526
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_jsrenderoptions_free(ptr >>> 0, 1));
|
|
527
|
+
|
|
229
528
|
function addHeapObject(obj) {
|
|
230
529
|
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
231
530
|
const idx = heap_next;
|
|
@@ -235,6 +534,12 @@ function addHeapObject(obj) {
|
|
|
235
534
|
return idx;
|
|
236
535
|
}
|
|
237
536
|
|
|
537
|
+
function _assertClass(instance, klass) {
|
|
538
|
+
if (!(instance instanceof klass)) {
|
|
539
|
+
throw new Error(`expected instance of ${klass.name}`);
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
|
|
238
543
|
function dropObject(idx) {
|
|
239
544
|
if (idx < 1028) return;
|
|
240
545
|
heap[idx] = heap_next;
|
package/tdsl_wasm_bg.wasm
CHANGED
|
Binary file
|