@typbase/engine 0.4.0 → 0.4.2

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/engine.d.ts CHANGED
@@ -48,6 +48,26 @@ export interface CellSpan {
48
48
  content_end: number;
49
49
  }
50
50
 
51
+ /**
52
+ * A top-level heading for the page outline. Ranges are UTF-16 offsets into
53
+ * the raw source, so they are editor positions.
54
+ */
55
+ export interface HeadingSpan {
56
+ /**
57
+ * 1 through 6, from the number of `=` markers.
58
+ */
59
+ level: number;
60
+ /**
61
+ * Heading text with markup markers removed.
62
+ */
63
+ title: string;
64
+ /**
65
+ * UTF-16 range of the whole heading line.
66
+ */
67
+ from: number;
68
+ to: number;
69
+ }
70
+
51
71
  /**
52
72
  * An SVG frame with its corresponding source range.
53
73
  */
@@ -105,6 +125,14 @@ export interface LinkSpan {
105
125
  dynamic: boolean;
106
126
  }
107
127
 
128
+ /**
129
+ * One math equation, in UTF-16 offsets into the raw source.
130
+ */
131
+ export interface EquationSpan {
132
+ from: number;
133
+ to: number;
134
+ }
135
+
108
136
  /**
109
137
  * One segment in the check report, labelled for humans.
110
138
  */
@@ -415,6 +443,16 @@ export class TypstState {
415
443
  * positions. Shares the note's parse tree, like the other syntax passes.
416
444
  */
417
445
  extractCells(id: FileId, text: string): CellSpan[];
446
+ /**
447
+ * Extracts math equation ranges as UTF-16 spans. The editor marks them
448
+ * so math can use a monospaced face while prose keeps the text font.
449
+ */
450
+ extractEquations(id: FileId, text: string): EquationSpan[];
451
+ /**
452
+ * Extracts top-level headings as UTF-16 spans for the page outline.
453
+ * Shares the note's parse tree, like the other syntax passes.
454
+ */
455
+ extractHeadings(id: FileId, text: string): HeadingSpan[];
418
456
  /**
419
457
  * Extracts the app's link calls (`typbase.page-link`, `typbase.embed`,
420
458
  * and `typbase://page/` URLs) with UTF-16 ranges. Shares the note's parse
@@ -582,6 +620,8 @@ export interface InitOutput {
582
620
  readonly typststate_evictCaches: (a: number) => void;
583
621
  readonly typststate_evictCachesAged: (a: number, b: number) => void;
584
622
  readonly typststate_extractCells: (a: number, b: number, c: number, d: number, e: number) => void;
623
+ readonly typststate_extractEquations: (a: number, b: number, c: number, d: number, e: number) => void;
624
+ readonly typststate_extractHeadings: (a: number, b: number, c: number, d: number, e: number) => void;
585
625
  readonly typststate_extractLinks: (a: number, b: number, c: number, d: number, e: number) => void;
586
626
  readonly typststate_extractSections: (a: number, b: number, c: number, d: number, e: number) => void;
587
627
  readonly typststate_flattenDocument: (a: number, b: number, c: number, d: number, e: number) => void;
package/engine.js CHANGED
@@ -490,6 +490,62 @@ export class TypstState {
490
490
  wasm.__wbindgen_add_to_stack_pointer(16);
491
491
  }
492
492
  }
493
+ /**
494
+ * Extracts math equation ranges as UTF-16 spans. The editor marks them
495
+ * so math can use a monospaced face while prose keeps the text font.
496
+ * @param {FileId} id
497
+ * @param {string} text
498
+ * @returns {EquationSpan[]}
499
+ */
500
+ extractEquations(id, text) {
501
+ try {
502
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
503
+ _assertClass(id, FileId);
504
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export, wasm.__wbindgen_export2);
505
+ const len0 = WASM_VECTOR_LEN;
506
+ wasm.typststate_extractEquations(retptr, this.__wbg_ptr, id.__wbg_ptr, ptr0, len0);
507
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
508
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
509
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
510
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
511
+ if (r3) {
512
+ throw takeObject(r2);
513
+ }
514
+ var v2 = getArrayJsValueFromWasm0(r0, r1);
515
+ wasm.__wbindgen_export4(r0, r1 * 4, 4);
516
+ return v2;
517
+ } finally {
518
+ wasm.__wbindgen_add_to_stack_pointer(16);
519
+ }
520
+ }
521
+ /**
522
+ * Extracts top-level headings as UTF-16 spans for the page outline.
523
+ * Shares the note's parse tree, like the other syntax passes.
524
+ * @param {FileId} id
525
+ * @param {string} text
526
+ * @returns {HeadingSpan[]}
527
+ */
528
+ extractHeadings(id, text) {
529
+ try {
530
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
531
+ _assertClass(id, FileId);
532
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export, wasm.__wbindgen_export2);
533
+ const len0 = WASM_VECTOR_LEN;
534
+ wasm.typststate_extractHeadings(retptr, this.__wbg_ptr, id.__wbg_ptr, ptr0, len0);
535
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
536
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
537
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
538
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
539
+ if (r3) {
540
+ throw takeObject(r2);
541
+ }
542
+ var v2 = getArrayJsValueFromWasm0(r0, r1);
543
+ wasm.__wbindgen_export4(r0, r1 * 4, 4);
544
+ return v2;
545
+ } finally {
546
+ wasm.__wbindgen_add_to_stack_pointer(16);
547
+ }
548
+ }
493
549
  /**
494
550
  * Extracts the app's link calls (`typbase.page-link`, `typbase.embed`,
495
551
  * and `typbase://page/` URLs) with UTF-16 ranges. Shares the note's parse
@@ -1169,10 +1225,10 @@ function __wbg_get_imports() {
1169
1225
  __wbg___wbindgen_throw_bb96b2010945f0bc: function(arg0, arg1) {
1170
1226
  throw new Error(getStringFromWasm0(arg0, arg1));
1171
1227
  },
1172
- __wbg_debug_2e71d77890567dd4: function(arg0, arg1) {
1228
+ __wbg_debug_ae65d086f59ab2b9: function(arg0, arg1) {
1173
1229
  console.debug(getStringFromWasm0(arg0, arg1));
1174
1230
  },
1175
- __wbg_error_f24aab6c41ae4ad8: function(arg0, arg1) {
1231
+ __wbg_error_712632c960c118c6: function(arg0, arg1) {
1176
1232
  console.error(getStringFromWasm0(arg0, arg1));
1177
1233
  },
1178
1234
  __wbg_getTime_63fb0332e6c4ec17: function(arg0) {
package/engine_bg.wasm CHANGED
Binary file
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@typbase/engine",
3
3
  "type": "module",
4
4
  "description": "Local-first knowledge base made for Typst and the Atmosphere.",
5
- "version": "0.4.0",
5
+ "version": "0.4.2",
6
6
  "license": "Apache-2.0",
7
7
  "repository": {
8
8
  "type": "git",