@typbase/engine 0.3.2 → 0.4.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/engine.d.ts CHANGED
@@ -21,24 +21,28 @@ export interface SectionSpan {
21
21
  export type TypstRequest = { type: "source"; value: string } | { type: "file"; value: string } | { type: "package"; value: { namespace: string; name: string; version: string } };
22
22
 
23
23
  /**
24
- * A notebook cell: one `// %%` marker line plus the content below it, up to
25
- * the next marker or the end of the document. Ranges are UTF-16 offsets into
24
+ * A notebook cell: one `//%` attribute line plus the content below it, up to
25
+ * the next boundary or the end of the document. Ranges are UTF-16 offsets into
26
26
  * the raw source, so they can be used as editor positions directly.
27
27
  */
28
28
  export interface CellSpan {
29
29
  /**
30
- * Cell type from the marker label: `"markup"` or `"code"`.
30
+ * `"prose"`, `"code"`, `"log"`, or `"hidden"`.
31
31
  */
32
32
  kind: string;
33
33
  /**
34
- * Marker line range, excluding the newline. Both zero on the implicit
35
- * leading cell of a document whose first marker is not on line one.
34
+ * `name=` from the attribute line, when it carries one.
35
+ */
36
+ name: string | undefined;
37
+ /**
38
+ * Attribute line range, excluding the newline. Both zero on a cell that
39
+ * began at a heading and on the implicit cell above the first boundary.
36
40
  */
37
41
  marker_start: number;
38
42
  marker_end: number;
39
43
  /**
40
44
  * Content range. Blank lines below the content belong to the gap before
41
- * the next marker and are excluded.
45
+ * the next boundary and are excluded.
42
46
  */
43
47
  content_start: number;
44
48
  content_end: number;
@@ -152,9 +156,19 @@ export interface SvgRender {
152
156
  */
153
157
  frames: SvgRangedFrame[];
154
158
  /**
155
- * Rendered SVG frames for tooltips.
159
+ * Rendered SVG frames for tooltips. These keep their own definitions.
156
160
  */
157
161
  tooltips: SvgRangedFrame[];
162
+ /**
163
+ * The definitions [`frames`](Self::frames) reference, which the host has to
164
+ * place in the document. `None` when the frames drew nothing that needed
165
+ * any.
166
+ */
167
+ defs: string | undefined;
168
+ /**
169
+ * UTF-16 ranges of every equation, rendered or not.
170
+ */
171
+ equation_ranges: [number, number][];
158
172
  /**
159
173
  * Diagnostics and warnings produced during rendering.
160
174
  */
@@ -230,7 +244,22 @@ export interface CompileHTMLResult {
230
244
 
231
245
  export interface CompilePagedResult {
232
246
  frames: SvgRangedFrame[];
247
+ /**
248
+ * The definitions `frames` reference, for the host to place in the document.
249
+ * The frames are not self-contained without it.
250
+ */
251
+ defs: string | undefined;
252
+ /**
253
+ * Equation overlays, narrowed to the equation the caret is inside when the
254
+ * caller passed one.
255
+ */
233
256
  tooltips: SvgRangedFrame[];
257
+ /**
258
+ * UTF-16 ranges of every equation in the note, whether or not its overlay
259
+ * was rendered. The editor compares the cursor against these to know when
260
+ * it has entered math whose overlay the last render did not build.
261
+ */
262
+ equation_ranges: [number, number][];
234
263
  diagnostics: TypstDiagnostic[];
235
264
  requests: TypstRequest[];
236
265
  }
@@ -361,9 +390,14 @@ export class TypstState {
361
390
  * The editor's paged render: one SVG frame per source chunk, plus the
362
391
  * tooltip frames and diagnostics the editor needs.
363
392
  */
364
- compilePaged(id: FileId, text: string, prelude: string): CompilePagedResult;
393
+ compilePaged(id: FileId, text: string, prelude: string, caret?: number | null): CompilePagedResult;
365
394
  createFileId(path: string): FileId;
366
395
  createSourceId(path: string, space_id: string): FileId;
396
+ /**
397
+ * Diagnostics for the current text, through the same error recovery the
398
+ * render uses, without rendering frames and without publishing a document.
399
+ */
400
+ diagnosePaged(id: FileId, text: string, prelude: string): CheckResult;
367
401
  /**
368
402
  * Clears Typst's global memoization caches. They make repeated compiles
369
403
  * cheap but grow for the lifetime of the instance, so call this when
@@ -377,25 +411,30 @@ export class TypstState {
377
411
  */
378
412
  evictCachesAged(max_age: number): void;
379
413
  /**
380
- * Extracts notebook cells (`// %%` markers) as UTF-16 spans, ready for
381
- * CodeMirror positions. Pure syntax pass with no state needed.
414
+ * Extracts notebook cells as UTF-16 spans, ready for CodeMirror
415
+ * positions. Shares the note's parse tree, like the other syntax passes.
382
416
  */
383
- extractCells(text: string): CellSpan[];
417
+ extractCells(id: FileId, text: string): CellSpan[];
384
418
  /**
385
419
  * Extracts the app's link calls (`typbase.page-link`, `typbase.embed`,
386
- * and `typbase://page/` URLs) with UTF-16 ranges. Pure syntax pass
387
- * that needs no state.
420
+ * and `typbase://page/` URLs) with UTF-16 ranges. Shares the note's parse
421
+ * tree, like the other syntax passes.
388
422
  */
389
- extractLinks(text: string): LinkSpan[];
423
+ extractLinks(id: FileId | null | undefined, text: string): LinkSpan[];
390
424
  /**
391
425
  * Extracts `#typbase.section` spans for the page doc's sections list.
392
426
  */
393
- extractSections(text: string): SectionSpan[];
427
+ extractSections(id: FileId | null | undefined, text: string): SectionSpan[];
394
428
  /**
395
429
  * Plain-text flattening per block for the search index, plus the byte
396
- * map back to raw source. Pure syntax pass. No state needed.
430
+ * map back to raw source.
431
+ */
432
+ flattenDocument(id: FileId | null | undefined, text: string): FlattenedBlock[];
433
+ /**
434
+ * The families a font file declares, so an upload can be filed under the
435
+ * name the font itself carries. Empty when the bytes are not a font.
397
436
  */
398
- flattenDocument(text: string): FlattenedBlock[];
437
+ static fontFamilies(bytes: Uint8Array): string[];
399
438
  highlight(id: FileId, text: string): TypstHighlight[];
400
439
  hover(id: FileId, raw_cursor_utf16: number, side: number): string | undefined;
401
440
  insertFile(id: FileId, bytes: Uint8Array): void;
@@ -460,11 +499,23 @@ export class TypstState {
460
499
  setMathFont(id: FileId, math_font?: string | null): void;
461
500
  setTextSize(id: FileId, text_size: number): void;
462
501
  setTheme(id: FileId, theme: ThemeColors): void;
502
+ /**
503
+ * Typographic features the generated prelude turns on or off. They live in
504
+ * the space context rather than in an app-side prelude so the editor,
505
+ * previews, plugin surfaces, exports, and published pages all read the
506
+ * same values from one place.
507
+ */
508
+ setTypography(id: FileId, ligatures: boolean, kerning: boolean): void;
463
509
  /**
464
510
  * The style block alone, for exports and the project mirror: the same
465
511
  * text the engine prepends, minus the render-target page config.
466
512
  */
467
- static stylePrelude(theme: ThemeColors, text_size: number, font: string, math_font: string | null | undefined, code_font: string | null | undefined, locale: string): string;
513
+ static stylePrelude(theme: ThemeColors, text_size: number, font: string, math_font: string | null | undefined, code_font: string | null | undefined, locale: string, ligatures: boolean, kerning: boolean): string;
514
+ /**
515
+ * Brings the engine's sources and maps up to date with `text` without
516
+ * rendering anything.
517
+ */
518
+ syncSource(id: FileId, text: string, prelude: string): boolean;
468
519
  /**
469
520
  * The stdlib source as shipped, for writing a compilable project to disk.
470
521
  */
@@ -524,15 +575,17 @@ export interface InitOutput {
524
575
  readonly typststate_checkIndex: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
525
576
  readonly typststate_checkPaged: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
526
577
  readonly typststate_compileHTML: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
527
- readonly typststate_compilePaged: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
578
+ readonly typststate_compilePaged: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
528
579
  readonly typststate_createFileId: (a: number, b: number, c: number) => number;
529
580
  readonly typststate_createSourceId: (a: number, b: number, c: number, d: number, e: number) => number;
581
+ readonly typststate_diagnosePaged: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
530
582
  readonly typststate_evictCaches: (a: number) => void;
531
583
  readonly typststate_evictCachesAged: (a: number, b: number) => void;
532
- readonly typststate_extractCells: (a: number, b: number, c: number, d: number) => void;
533
- readonly typststate_extractLinks: (a: number, b: number, c: number, d: number) => void;
534
- readonly typststate_extractSections: (a: number, b: number, c: number, d: number) => void;
535
- readonly typststate_flattenDocument: (a: number, b: number, c: number, d: number) => void;
584
+ readonly typststate_extractCells: (a: number, b: number, c: number, d: number, e: number) => void;
585
+ readonly typststate_extractLinks: (a: number, b: number, c: number, d: number, e: number) => void;
586
+ readonly typststate_extractSections: (a: number, b: number, c: number, d: number, e: number) => void;
587
+ readonly typststate_flattenDocument: (a: number, b: number, c: number, d: number, e: number) => void;
588
+ readonly typststate_fontFamilies: (a: number, b: number, c: number) => void;
536
589
  readonly typststate_highlight: (a: number, b: number, c: number, d: number, e: number) => void;
537
590
  readonly typststate_hover: (a: number, b: number, c: number, d: number, e: number) => void;
538
591
  readonly typststate_insertFile: (a: number, b: number, c: number, d: number) => void;
@@ -559,7 +612,9 @@ export interface InitOutput {
559
612
  readonly typststate_setMathFont: (a: number, b: number, c: number, d: number) => void;
560
613
  readonly typststate_setTextSize: (a: number, b: number, c: number) => void;
561
614
  readonly typststate_setTheme: (a: number, b: number, c: number) => void;
562
- readonly typststate_stylePrelude: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number) => void;
615
+ readonly typststate_setTypography: (a: number, b: number, c: number, d: number) => void;
616
+ readonly typststate_stylePrelude: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number) => void;
617
+ readonly typststate_syncSource: (a: number, b: number, c: number, d: number, e: number, f: number) => number;
563
618
  readonly typststate_typbaseLib: (a: number, b: number) => void;
564
619
  readonly __wbindgen_export: (a: number, b: number) => number;
565
620
  readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
package/engine.js CHANGED
@@ -371,9 +371,10 @@ export class TypstState {
371
371
  * @param {FileId} id
372
372
  * @param {string} text
373
373
  * @param {string} prelude
374
+ * @param {number | null} [caret]
374
375
  * @returns {CompilePagedResult}
375
376
  */
376
- compilePaged(id, text, prelude) {
377
+ compilePaged(id, text, prelude, caret) {
377
378
  try {
378
379
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
379
380
  _assertClass(id, FileId);
@@ -381,7 +382,7 @@ export class TypstState {
381
382
  const len0 = WASM_VECTOR_LEN;
382
383
  const ptr1 = passStringToWasm0(prelude, wasm.__wbindgen_export, wasm.__wbindgen_export2);
383
384
  const len1 = WASM_VECTOR_LEN;
384
- wasm.typststate_compilePaged(retptr, this.__wbg_ptr, id.__wbg_ptr, ptr0, len0, ptr1, len1);
385
+ wasm.typststate_compilePaged(retptr, this.__wbg_ptr, id.__wbg_ptr, ptr0, len0, ptr1, len1, isLikeNone(caret) ? Number.MAX_SAFE_INTEGER : (caret) >>> 0);
385
386
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
386
387
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
387
388
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -416,6 +417,34 @@ export class TypstState {
416
417
  const ret = wasm.typststate_createSourceId(this.__wbg_ptr, ptr0, len0, ptr1, len1);
417
418
  return FileId.__wrap(ret);
418
419
  }
420
+ /**
421
+ * Diagnostics for the current text, through the same error recovery the
422
+ * render uses, without rendering frames and without publishing a document.
423
+ * @param {FileId} id
424
+ * @param {string} text
425
+ * @param {string} prelude
426
+ * @returns {CheckResult}
427
+ */
428
+ diagnosePaged(id, text, prelude) {
429
+ try {
430
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
431
+ _assertClass(id, FileId);
432
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export, wasm.__wbindgen_export2);
433
+ const len0 = WASM_VECTOR_LEN;
434
+ const ptr1 = passStringToWasm0(prelude, wasm.__wbindgen_export, wasm.__wbindgen_export2);
435
+ const len1 = WASM_VECTOR_LEN;
436
+ wasm.typststate_diagnosePaged(retptr, this.__wbg_ptr, id.__wbg_ptr, ptr0, len0, ptr1, len1);
437
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
438
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
439
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
440
+ if (r2) {
441
+ throw takeObject(r1);
442
+ }
443
+ return takeObject(r0);
444
+ } finally {
445
+ wasm.__wbindgen_add_to_stack_pointer(16);
446
+ }
447
+ }
419
448
  /**
420
449
  * Clears Typst's global memoization caches. They make repeated compiles
421
450
  * cheap but grow for the lifetime of the instance, so call this when
@@ -434,17 +463,19 @@ export class TypstState {
434
463
  wasm.typststate_evictCachesAged(this.__wbg_ptr, max_age);
435
464
  }
436
465
  /**
437
- * Extracts notebook cells (`// %%` markers) as UTF-16 spans, ready for
438
- * CodeMirror positions. Pure syntax pass with no state needed.
466
+ * Extracts notebook cells as UTF-16 spans, ready for CodeMirror
467
+ * positions. Shares the note's parse tree, like the other syntax passes.
468
+ * @param {FileId} id
439
469
  * @param {string} text
440
470
  * @returns {CellSpan[]}
441
471
  */
442
- extractCells(text) {
472
+ extractCells(id, text) {
443
473
  try {
444
474
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
475
+ _assertClass(id, FileId);
445
476
  const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export, wasm.__wbindgen_export2);
446
477
  const len0 = WASM_VECTOR_LEN;
447
- wasm.typststate_extractCells(retptr, this.__wbg_ptr, ptr0, len0);
478
+ wasm.typststate_extractCells(retptr, this.__wbg_ptr, id.__wbg_ptr, ptr0, len0);
448
479
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
449
480
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
450
481
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -461,17 +492,23 @@ export class TypstState {
461
492
  }
462
493
  /**
463
494
  * Extracts the app's link calls (`typbase.page-link`, `typbase.embed`,
464
- * and `typbase://page/` URLs) with UTF-16 ranges. Pure syntax pass
465
- * that needs no state.
495
+ * and `typbase://page/` URLs) with UTF-16 ranges. Shares the note's parse
496
+ * tree, like the other syntax passes.
497
+ * @param {FileId | null | undefined} id
466
498
  * @param {string} text
467
499
  * @returns {LinkSpan[]}
468
500
  */
469
- extractLinks(text) {
501
+ extractLinks(id, text) {
470
502
  try {
471
503
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
472
- const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export, wasm.__wbindgen_export2);
473
- const len0 = WASM_VECTOR_LEN;
474
- wasm.typststate_extractLinks(retptr, this.__wbg_ptr, ptr0, len0);
504
+ let ptr0 = 0;
505
+ if (!isLikeNone(id)) {
506
+ _assertClass(id, FileId);
507
+ ptr0 = id.__destroy_into_raw();
508
+ }
509
+ const ptr1 = passStringToWasm0(text, wasm.__wbindgen_export, wasm.__wbindgen_export2);
510
+ const len1 = WASM_VECTOR_LEN;
511
+ wasm.typststate_extractLinks(retptr, this.__wbg_ptr, ptr0, ptr1, len1);
475
512
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
476
513
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
477
514
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -479,24 +516,30 @@ export class TypstState {
479
516
  if (r3) {
480
517
  throw takeObject(r2);
481
518
  }
482
- var v2 = getArrayJsValueFromWasm0(r0, r1);
519
+ var v3 = getArrayJsValueFromWasm0(r0, r1);
483
520
  wasm.__wbindgen_export4(r0, r1 * 4, 4);
484
- return v2;
521
+ return v3;
485
522
  } finally {
486
523
  wasm.__wbindgen_add_to_stack_pointer(16);
487
524
  }
488
525
  }
489
526
  /**
490
527
  * Extracts `#typbase.section` spans for the page doc's sections list.
528
+ * @param {FileId | null | undefined} id
491
529
  * @param {string} text
492
530
  * @returns {SectionSpan[]}
493
531
  */
494
- extractSections(text) {
532
+ extractSections(id, text) {
495
533
  try {
496
534
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
497
- const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export, wasm.__wbindgen_export2);
498
- const len0 = WASM_VECTOR_LEN;
499
- wasm.typststate_extractSections(retptr, this.__wbg_ptr, ptr0, len0);
535
+ let ptr0 = 0;
536
+ if (!isLikeNone(id)) {
537
+ _assertClass(id, FileId);
538
+ ptr0 = id.__destroy_into_raw();
539
+ }
540
+ const ptr1 = passStringToWasm0(text, wasm.__wbindgen_export, wasm.__wbindgen_export2);
541
+ const len1 = WASM_VECTOR_LEN;
542
+ wasm.typststate_extractSections(retptr, this.__wbg_ptr, ptr0, ptr1, len1);
500
543
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
501
544
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
502
545
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -504,25 +547,31 @@ export class TypstState {
504
547
  if (r3) {
505
548
  throw takeObject(r2);
506
549
  }
507
- var v2 = getArrayJsValueFromWasm0(r0, r1);
550
+ var v3 = getArrayJsValueFromWasm0(r0, r1);
508
551
  wasm.__wbindgen_export4(r0, r1 * 4, 4);
509
- return v2;
552
+ return v3;
510
553
  } finally {
511
554
  wasm.__wbindgen_add_to_stack_pointer(16);
512
555
  }
513
556
  }
514
557
  /**
515
558
  * Plain-text flattening per block for the search index, plus the byte
516
- * map back to raw source. Pure syntax pass. No state needed.
559
+ * map back to raw source.
560
+ * @param {FileId | null | undefined} id
517
561
  * @param {string} text
518
562
  * @returns {FlattenedBlock[]}
519
563
  */
520
- flattenDocument(text) {
564
+ flattenDocument(id, text) {
521
565
  try {
522
566
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
523
- const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export, wasm.__wbindgen_export2);
524
- const len0 = WASM_VECTOR_LEN;
525
- wasm.typststate_flattenDocument(retptr, this.__wbg_ptr, ptr0, len0);
567
+ let ptr0 = 0;
568
+ if (!isLikeNone(id)) {
569
+ _assertClass(id, FileId);
570
+ ptr0 = id.__destroy_into_raw();
571
+ }
572
+ const ptr1 = passStringToWasm0(text, wasm.__wbindgen_export, wasm.__wbindgen_export2);
573
+ const len1 = WASM_VECTOR_LEN;
574
+ wasm.typststate_flattenDocument(retptr, this.__wbg_ptr, ptr0, ptr1, len1);
526
575
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
527
576
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
528
577
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -530,6 +579,27 @@ export class TypstState {
530
579
  if (r3) {
531
580
  throw takeObject(r2);
532
581
  }
582
+ var v3 = getArrayJsValueFromWasm0(r0, r1);
583
+ wasm.__wbindgen_export4(r0, r1 * 4, 4);
584
+ return v3;
585
+ } finally {
586
+ wasm.__wbindgen_add_to_stack_pointer(16);
587
+ }
588
+ }
589
+ /**
590
+ * The families a font file declares, so an upload can be filed under the
591
+ * name the font itself carries. Empty when the bytes are not a font.
592
+ * @param {Uint8Array} bytes
593
+ * @returns {string[]}
594
+ */
595
+ static fontFamilies(bytes) {
596
+ try {
597
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
598
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export);
599
+ const len0 = WASM_VECTOR_LEN;
600
+ wasm.typststate_fontFamilies(retptr, ptr0, len0);
601
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
602
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
533
603
  var v2 = getArrayJsValueFromWasm0(r0, r1);
534
604
  wasm.__wbindgen_export4(r0, r1 * 4, 4);
535
605
  return v2;
@@ -924,6 +994,19 @@ export class TypstState {
924
994
  var ptr0 = theme.__destroy_into_raw();
925
995
  wasm.typststate_setTheme(this.__wbg_ptr, id.__wbg_ptr, ptr0);
926
996
  }
997
+ /**
998
+ * Typographic features the generated prelude turns on or off. They live in
999
+ * the space context rather than in an app-side prelude so the editor,
1000
+ * previews, plugin surfaces, exports, and published pages all read the
1001
+ * same values from one place.
1002
+ * @param {FileId} id
1003
+ * @param {boolean} ligatures
1004
+ * @param {boolean} kerning
1005
+ */
1006
+ setTypography(id, ligatures, kerning) {
1007
+ _assertClass(id, FileId);
1008
+ wasm.typststate_setTypography(this.__wbg_ptr, id.__wbg_ptr, ligatures, kerning);
1009
+ }
927
1010
  /**
928
1011
  * The style block alone, for exports and the project mirror: the same
929
1012
  * text the engine prepends, minus the render-target page config.
@@ -933,9 +1016,11 @@ export class TypstState {
933
1016
  * @param {string | null | undefined} math_font
934
1017
  * @param {string | null | undefined} code_font
935
1018
  * @param {string} locale
1019
+ * @param {boolean} ligatures
1020
+ * @param {boolean} kerning
936
1021
  * @returns {string}
937
1022
  */
938
- static stylePrelude(theme, text_size, font, math_font, code_font, locale) {
1023
+ static stylePrelude(theme, text_size, font, math_font, code_font, locale, ligatures, kerning) {
939
1024
  let deferred6_0;
940
1025
  let deferred6_1;
941
1026
  try {
@@ -950,7 +1035,7 @@ export class TypstState {
950
1035
  var len3 = WASM_VECTOR_LEN;
951
1036
  const ptr4 = passStringToWasm0(locale, wasm.__wbindgen_export, wasm.__wbindgen_export2);
952
1037
  const len4 = WASM_VECTOR_LEN;
953
- wasm.typststate_stylePrelude(retptr, ptr0, text_size, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4);
1038
+ wasm.typststate_stylePrelude(retptr, ptr0, text_size, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, ligatures, kerning);
954
1039
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
955
1040
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
956
1041
  deferred6_0 = r0;
@@ -961,6 +1046,23 @@ export class TypstState {
961
1046
  wasm.__wbindgen_export4(deferred6_0, deferred6_1, 1);
962
1047
  }
963
1048
  }
1049
+ /**
1050
+ * Brings the engine's sources and maps up to date with `text` without
1051
+ * rendering anything.
1052
+ * @param {FileId} id
1053
+ * @param {string} text
1054
+ * @param {string} prelude
1055
+ * @returns {boolean}
1056
+ */
1057
+ syncSource(id, text, prelude) {
1058
+ _assertClass(id, FileId);
1059
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1060
+ const len0 = WASM_VECTOR_LEN;
1061
+ const ptr1 = passStringToWasm0(prelude, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1062
+ const len1 = WASM_VECTOR_LEN;
1063
+ const ret = wasm.typststate_syncSource(this.__wbg_ptr, id.__wbg_ptr, ptr0, len0, ptr1, len1);
1064
+ return ret !== 0;
1065
+ }
964
1066
  /**
965
1067
  * The stdlib source as shipped, for writing a compilable project to disk.
966
1068
  * @returns {string}
@@ -1067,10 +1169,10 @@ function __wbg_get_imports() {
1067
1169
  __wbg___wbindgen_throw_bb96b2010945f0bc: function(arg0, arg1) {
1068
1170
  throw new Error(getStringFromWasm0(arg0, arg1));
1069
1171
  },
1070
- __wbg_debug_e8912e4c5ebba290: function(arg0, arg1) {
1172
+ __wbg_debug_2e71d77890567dd4: function(arg0, arg1) {
1071
1173
  console.debug(getStringFromWasm0(arg0, arg1));
1072
1174
  },
1073
- __wbg_error_9c32e922355be9f2: function(arg0, arg1) {
1175
+ __wbg_error_f24aab6c41ae4ad8: function(arg0, arg1) {
1074
1176
  console.error(getStringFromWasm0(arg0, arg1));
1075
1177
  },
1076
1178
  __wbg_getTime_63fb0332e6c4ec17: function(arg0) {
package/engine_bg.wasm CHANGED
Binary file
package/package.json CHANGED
@@ -2,8 +2,8 @@
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.3.2",
6
- "license": "AGPL-3.0",
5
+ "version": "0.4.0",
6
+ "license": "Apache-2.0",
7
7
  "repository": {
8
8
  "type": "git",
9
9
  "url": "https://github.com/lemueldls/typbase"