@keroway/tdsl-wasm 1.17.0 → 1.19.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 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.17.0",
5
+ "version": "1.19.0",
6
6
  "license": "MIT",
7
7
  "repository": {
8
8
  "type": "git",
package/tdsl_wasm.d.ts CHANGED
@@ -1,6 +1,38 @@
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
  *
@@ -36,6 +68,32 @@ export function compile_to_ir(source: string): string;
36
68
  */
37
69
  export function format_source(source: string): string;
38
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
+
39
97
  /**
40
98
  * Initialize the panic hook for better error messages in the browser console.
41
99
  */
@@ -47,6 +105,12 @@ export function main(): void;
47
105
  */
48
106
  export function render_html_from_source(source: string): string;
49
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
+
50
114
  /**
51
115
  * Render SVG from TDSL source (static items only).
52
116
  * `scale` controls pixels-per-year. Pass `0.0` (or negative) to auto-calculate
@@ -57,15 +121,39 @@ export function render_html_from_source(source: string): string;
57
121
  */
58
122
  export function render_svg_from_source(source: string, scale: number): string;
59
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
+
60
132
  export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
61
133
 
62
134
  export interface InitOutput {
63
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;
64
141
  readonly check_source: (a: number, b: number, c: number) => void;
65
142
  readonly compile_to_ir: (a: number, b: number, c: number) => void;
66
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;
67
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;
68
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;
69
157
  readonly main: () => void;
70
158
  readonly __wbindgen_export: (a: number, b: number, c: number) => void;
71
159
  readonly __wbindgen_export2: (a: number, b: number) => number;
package/tdsl_wasm.js CHANGED
@@ -1,5 +1,151 @@
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;
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
  *
@@ -108,6 +254,78 @@ export function format_source(source) {
108
254
  }
109
255
  }
110
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
+
111
329
  /**
112
330
  * Initialize the panic hook for better error messages in the browser console.
113
331
  */
@@ -148,6 +366,42 @@ export function render_html_from_source(source) {
148
366
  }
149
367
  }
150
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
+
151
405
  /**
152
406
  * Render SVG from TDSL source (static items only).
153
407
  * `scale` controls pixels-per-year. Pass `0.0` (or negative) to auto-calculate
@@ -185,9 +439,51 @@ export function render_svg_from_source(source, scale) {
185
439
  wasm.__wbindgen_export(deferred3_0, deferred3_1, 1);
186
440
  }
187
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
+ }
188
481
  function __wbg_get_imports() {
189
482
  const import0 = {
190
483
  __proto__: null,
484
+ __wbg___wbindgen_throw_ea4887a5f8f9a9db: function(arg0, arg1) {
485
+ throw new Error(getStringFromWasm0(arg0, arg1));
486
+ },
191
487
  __wbg_error_a6fa202b58aa1cd3: function(arg0, arg1) {
192
488
  let deferred0_0;
193
489
  let deferred0_1;
@@ -225,6 +521,10 @@ function __wbg_get_imports() {
225
521
  };
226
522
  }
227
523
 
524
+ const JsRenderOptionsFinalization = (typeof FinalizationRegistry === 'undefined')
525
+ ? { register: () => {}, unregister: () => {} }
526
+ : new FinalizationRegistry(ptr => wasm.__wbg_jsrenderoptions_free(ptr, 1));
527
+
228
528
  function addHeapObject(obj) {
229
529
  if (heap_next === heap.length) heap.push(heap.length + 1);
230
530
  const idx = heap_next;
@@ -234,6 +534,12 @@ function addHeapObject(obj) {
234
534
  return idx;
235
535
  }
236
536
 
537
+ function _assertClass(instance, klass) {
538
+ if (!(instance instanceof klass)) {
539
+ throw new Error(`expected instance of ${klass.name}`);
540
+ }
541
+ }
542
+
237
543
  function dropObject(idx) {
238
544
  if (idx < 1028) return;
239
545
  heap[idx] = heap_next;
@@ -249,8 +555,7 @@ function getDataViewMemory0() {
249
555
  }
250
556
 
251
557
  function getStringFromWasm0(ptr, len) {
252
- ptr = ptr >>> 0;
253
- return decodeText(ptr, len);
558
+ return decodeText(ptr >>> 0, len);
254
559
  }
255
560
 
256
561
  let cachedUint8ArrayMemory0 = null;
@@ -340,8 +645,9 @@ if (!('encodeInto' in cachedTextEncoder)) {
340
645
 
341
646
  let WASM_VECTOR_LEN = 0;
342
647
 
343
- let wasmModule, wasm;
648
+ let wasmModule, wasmInstance, wasm;
344
649
  function __wbg_finalize_init(instance, module) {
650
+ wasmInstance = instance;
345
651
  wasm = instance.exports;
346
652
  wasmModule = module;
347
653
  cachedDataViewMemory0 = null;
package/tdsl_wasm_bg.wasm CHANGED
Binary file