@typbase/engine 0.3.2 → 0.4.1
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 +190 -661
- package/engine.d.ts +119 -24
- package/engine.js +183 -25
- package/engine_bg.wasm +0 -0
- package/package.json +2 -2
package/engine.d.ts
CHANGED
|
@@ -21,29 +21,53 @@ 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
|
|
25
|
-
* the next
|
|
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
|
-
*
|
|
30
|
+
* `"prose"`, `"code"`, `"log"`, or `"hidden"`.
|
|
31
31
|
*/
|
|
32
32
|
kind: string;
|
|
33
33
|
/**
|
|
34
|
-
*
|
|
35
|
-
|
|
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
|
|
45
|
+
* the next boundary and are excluded.
|
|
42
46
|
*/
|
|
43
47
|
content_start: number;
|
|
44
48
|
content_end: number;
|
|
45
49
|
}
|
|
46
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
|
+
|
|
47
71
|
/**
|
|
48
72
|
* An SVG frame with its corresponding source range.
|
|
49
73
|
*/
|
|
@@ -101,6 +125,14 @@ export interface LinkSpan {
|
|
|
101
125
|
dynamic: boolean;
|
|
102
126
|
}
|
|
103
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
|
+
|
|
104
136
|
/**
|
|
105
137
|
* One segment in the check report, labelled for humans.
|
|
106
138
|
*/
|
|
@@ -152,9 +184,19 @@ export interface SvgRender {
|
|
|
152
184
|
*/
|
|
153
185
|
frames: SvgRangedFrame[];
|
|
154
186
|
/**
|
|
155
|
-
* Rendered SVG frames for tooltips.
|
|
187
|
+
* Rendered SVG frames for tooltips. These keep their own definitions.
|
|
156
188
|
*/
|
|
157
189
|
tooltips: SvgRangedFrame[];
|
|
190
|
+
/**
|
|
191
|
+
* The definitions [`frames`](Self::frames) reference, which the host has to
|
|
192
|
+
* place in the document. `None` when the frames drew nothing that needed
|
|
193
|
+
* any.
|
|
194
|
+
*/
|
|
195
|
+
defs: string | undefined;
|
|
196
|
+
/**
|
|
197
|
+
* UTF-16 ranges of every equation, rendered or not.
|
|
198
|
+
*/
|
|
199
|
+
equation_ranges: [number, number][];
|
|
158
200
|
/**
|
|
159
201
|
* Diagnostics and warnings produced during rendering.
|
|
160
202
|
*/
|
|
@@ -230,7 +272,22 @@ export interface CompileHTMLResult {
|
|
|
230
272
|
|
|
231
273
|
export interface CompilePagedResult {
|
|
232
274
|
frames: SvgRangedFrame[];
|
|
275
|
+
/**
|
|
276
|
+
* The definitions `frames` reference, for the host to place in the document.
|
|
277
|
+
* The frames are not self-contained without it.
|
|
278
|
+
*/
|
|
279
|
+
defs: string | undefined;
|
|
280
|
+
/**
|
|
281
|
+
* Equation overlays, narrowed to the equation the caret is inside when the
|
|
282
|
+
* caller passed one.
|
|
283
|
+
*/
|
|
233
284
|
tooltips: SvgRangedFrame[];
|
|
285
|
+
/**
|
|
286
|
+
* UTF-16 ranges of every equation in the note, whether or not its overlay
|
|
287
|
+
* was rendered. The editor compares the cursor against these to know when
|
|
288
|
+
* it has entered math whose overlay the last render did not build.
|
|
289
|
+
*/
|
|
290
|
+
equation_ranges: [number, number][];
|
|
234
291
|
diagnostics: TypstDiagnostic[];
|
|
235
292
|
requests: TypstRequest[];
|
|
236
293
|
}
|
|
@@ -361,9 +418,14 @@ export class TypstState {
|
|
|
361
418
|
* The editor's paged render: one SVG frame per source chunk, plus the
|
|
362
419
|
* tooltip frames and diagnostics the editor needs.
|
|
363
420
|
*/
|
|
364
|
-
compilePaged(id: FileId, text: string, prelude: string): CompilePagedResult;
|
|
421
|
+
compilePaged(id: FileId, text: string, prelude: string, caret?: number | null): CompilePagedResult;
|
|
365
422
|
createFileId(path: string): FileId;
|
|
366
423
|
createSourceId(path: string, space_id: string): FileId;
|
|
424
|
+
/**
|
|
425
|
+
* Diagnostics for the current text, through the same error recovery the
|
|
426
|
+
* render uses, without rendering frames and without publishing a document.
|
|
427
|
+
*/
|
|
428
|
+
diagnosePaged(id: FileId, text: string, prelude: string): CheckResult;
|
|
367
429
|
/**
|
|
368
430
|
* Clears Typst's global memoization caches. They make repeated compiles
|
|
369
431
|
* cheap but grow for the lifetime of the instance, so call this when
|
|
@@ -377,25 +439,40 @@ export class TypstState {
|
|
|
377
439
|
*/
|
|
378
440
|
evictCachesAged(max_age: number): void;
|
|
379
441
|
/**
|
|
380
|
-
* Extracts notebook cells
|
|
381
|
-
*
|
|
442
|
+
* Extracts notebook cells as UTF-16 spans, ready for CodeMirror
|
|
443
|
+
* positions. Shares the note's parse tree, like the other syntax passes.
|
|
382
444
|
*/
|
|
383
|
-
extractCells(text: string): CellSpan[];
|
|
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[];
|
|
384
456
|
/**
|
|
385
457
|
* Extracts the app's link calls (`typbase.page-link`, `typbase.embed`,
|
|
386
|
-
* and `typbase://page/` URLs) with UTF-16 ranges.
|
|
387
|
-
*
|
|
458
|
+
* and `typbase://page/` URLs) with UTF-16 ranges. Shares the note's parse
|
|
459
|
+
* tree, like the other syntax passes.
|
|
388
460
|
*/
|
|
389
|
-
extractLinks(text: string): LinkSpan[];
|
|
461
|
+
extractLinks(id: FileId | null | undefined, text: string): LinkSpan[];
|
|
390
462
|
/**
|
|
391
463
|
* Extracts `#typbase.section` spans for the page doc's sections list.
|
|
392
464
|
*/
|
|
393
|
-
extractSections(text: string): SectionSpan[];
|
|
465
|
+
extractSections(id: FileId | null | undefined, text: string): SectionSpan[];
|
|
394
466
|
/**
|
|
395
467
|
* Plain-text flattening per block for the search index, plus the byte
|
|
396
|
-
* map back to raw source.
|
|
468
|
+
* map back to raw source.
|
|
469
|
+
*/
|
|
470
|
+
flattenDocument(id: FileId | null | undefined, text: string): FlattenedBlock[];
|
|
471
|
+
/**
|
|
472
|
+
* The families a font file declares, so an upload can be filed under the
|
|
473
|
+
* name the font itself carries. Empty when the bytes are not a font.
|
|
397
474
|
*/
|
|
398
|
-
|
|
475
|
+
static fontFamilies(bytes: Uint8Array): string[];
|
|
399
476
|
highlight(id: FileId, text: string): TypstHighlight[];
|
|
400
477
|
hover(id: FileId, raw_cursor_utf16: number, side: number): string | undefined;
|
|
401
478
|
insertFile(id: FileId, bytes: Uint8Array): void;
|
|
@@ -460,11 +537,23 @@ export class TypstState {
|
|
|
460
537
|
setMathFont(id: FileId, math_font?: string | null): void;
|
|
461
538
|
setTextSize(id: FileId, text_size: number): void;
|
|
462
539
|
setTheme(id: FileId, theme: ThemeColors): void;
|
|
540
|
+
/**
|
|
541
|
+
* Typographic features the generated prelude turns on or off. They live in
|
|
542
|
+
* the space context rather than in an app-side prelude so the editor,
|
|
543
|
+
* previews, plugin surfaces, exports, and published pages all read the
|
|
544
|
+
* same values from one place.
|
|
545
|
+
*/
|
|
546
|
+
setTypography(id: FileId, ligatures: boolean, kerning: boolean): void;
|
|
463
547
|
/**
|
|
464
548
|
* The style block alone, for exports and the project mirror: the same
|
|
465
549
|
* text the engine prepends, minus the render-target page config.
|
|
466
550
|
*/
|
|
467
|
-
static stylePrelude(theme: ThemeColors, text_size: number, font: string, math_font: string | null | undefined, code_font: string | null | undefined, locale: string): string;
|
|
551
|
+
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;
|
|
552
|
+
/**
|
|
553
|
+
* Brings the engine's sources and maps up to date with `text` without
|
|
554
|
+
* rendering anything.
|
|
555
|
+
*/
|
|
556
|
+
syncSource(id: FileId, text: string, prelude: string): boolean;
|
|
468
557
|
/**
|
|
469
558
|
* The stdlib source as shipped, for writing a compilable project to disk.
|
|
470
559
|
*/
|
|
@@ -524,15 +613,19 @@ export interface InitOutput {
|
|
|
524
613
|
readonly typststate_checkIndex: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
525
614
|
readonly typststate_checkPaged: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
526
615
|
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;
|
|
616
|
+
readonly typststate_compilePaged: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
|
|
528
617
|
readonly typststate_createFileId: (a: number, b: number, c: number) => number;
|
|
529
618
|
readonly typststate_createSourceId: (a: number, b: number, c: number, d: number, e: number) => number;
|
|
619
|
+
readonly typststate_diagnosePaged: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
530
620
|
readonly typststate_evictCaches: (a: number) => void;
|
|
531
621
|
readonly typststate_evictCachesAged: (a: number, b: number) => void;
|
|
532
|
-
readonly typststate_extractCells: (a: number, b: number, c: number, d: number) => void;
|
|
533
|
-
readonly
|
|
534
|
-
readonly
|
|
535
|
-
readonly
|
|
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;
|
|
625
|
+
readonly typststate_extractLinks: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
626
|
+
readonly typststate_extractSections: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
627
|
+
readonly typststate_flattenDocument: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
628
|
+
readonly typststate_fontFamilies: (a: number, b: number, c: number) => void;
|
|
536
629
|
readonly typststate_highlight: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
537
630
|
readonly typststate_hover: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
538
631
|
readonly typststate_insertFile: (a: number, b: number, c: number, d: number) => void;
|
|
@@ -559,7 +652,9 @@ export interface InitOutput {
|
|
|
559
652
|
readonly typststate_setMathFont: (a: number, b: number, c: number, d: number) => void;
|
|
560
653
|
readonly typststate_setTextSize: (a: number, b: number, c: number) => void;
|
|
561
654
|
readonly typststate_setTheme: (a: number, b: number, c: number) => void;
|
|
562
|
-
readonly
|
|
655
|
+
readonly typststate_setTypography: (a: number, b: number, c: number, d: number) => void;
|
|
656
|
+
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;
|
|
657
|
+
readonly typststate_syncSource: (a: number, b: number, c: number, d: number, e: number, f: number) => number;
|
|
563
658
|
readonly typststate_typbaseLib: (a: number, b: number) => void;
|
|
564
659
|
readonly __wbindgen_export: (a: number, b: number) => number;
|
|
565
660
|
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
|
|
438
|
-
*
|
|
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);
|
|
@@ -460,18 +491,19 @@ export class TypstState {
|
|
|
460
491
|
}
|
|
461
492
|
}
|
|
462
493
|
/**
|
|
463
|
-
* Extracts
|
|
464
|
-
*
|
|
465
|
-
*
|
|
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
|
|
466
497
|
* @param {string} text
|
|
467
|
-
* @returns {
|
|
498
|
+
* @returns {EquationSpan[]}
|
|
468
499
|
*/
|
|
469
|
-
|
|
500
|
+
extractEquations(id, text) {
|
|
470
501
|
try {
|
|
471
502
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
503
|
+
_assertClass(id, FileId);
|
|
472
504
|
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
473
505
|
const len0 = WASM_VECTOR_LEN;
|
|
474
|
-
wasm.
|
|
506
|
+
wasm.typststate_extractEquations(retptr, this.__wbg_ptr, id.__wbg_ptr, ptr0, len0);
|
|
475
507
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
476
508
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
477
509
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -487,16 +519,19 @@ export class TypstState {
|
|
|
487
519
|
}
|
|
488
520
|
}
|
|
489
521
|
/**
|
|
490
|
-
* Extracts
|
|
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
|
|
491
525
|
* @param {string} text
|
|
492
|
-
* @returns {
|
|
526
|
+
* @returns {HeadingSpan[]}
|
|
493
527
|
*/
|
|
494
|
-
|
|
528
|
+
extractHeadings(id, text) {
|
|
495
529
|
try {
|
|
496
530
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
531
|
+
_assertClass(id, FileId);
|
|
497
532
|
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
498
533
|
const len0 = WASM_VECTOR_LEN;
|
|
499
|
-
wasm.
|
|
534
|
+
wasm.typststate_extractHeadings(retptr, this.__wbg_ptr, id.__wbg_ptr, ptr0, len0);
|
|
500
535
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
501
536
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
502
537
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -511,18 +546,88 @@ export class TypstState {
|
|
|
511
546
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
512
547
|
}
|
|
513
548
|
}
|
|
549
|
+
/**
|
|
550
|
+
* Extracts the app's link calls (`typbase.page-link`, `typbase.embed`,
|
|
551
|
+
* and `typbase://page/` URLs) with UTF-16 ranges. Shares the note's parse
|
|
552
|
+
* tree, like the other syntax passes.
|
|
553
|
+
* @param {FileId | null | undefined} id
|
|
554
|
+
* @param {string} text
|
|
555
|
+
* @returns {LinkSpan[]}
|
|
556
|
+
*/
|
|
557
|
+
extractLinks(id, text) {
|
|
558
|
+
try {
|
|
559
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
560
|
+
let ptr0 = 0;
|
|
561
|
+
if (!isLikeNone(id)) {
|
|
562
|
+
_assertClass(id, FileId);
|
|
563
|
+
ptr0 = id.__destroy_into_raw();
|
|
564
|
+
}
|
|
565
|
+
const ptr1 = passStringToWasm0(text, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
566
|
+
const len1 = WASM_VECTOR_LEN;
|
|
567
|
+
wasm.typststate_extractLinks(retptr, this.__wbg_ptr, ptr0, ptr1, len1);
|
|
568
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
569
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
570
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
571
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
572
|
+
if (r3) {
|
|
573
|
+
throw takeObject(r2);
|
|
574
|
+
}
|
|
575
|
+
var v3 = getArrayJsValueFromWasm0(r0, r1);
|
|
576
|
+
wasm.__wbindgen_export4(r0, r1 * 4, 4);
|
|
577
|
+
return v3;
|
|
578
|
+
} finally {
|
|
579
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
/**
|
|
583
|
+
* Extracts `#typbase.section` spans for the page doc's sections list.
|
|
584
|
+
* @param {FileId | null | undefined} id
|
|
585
|
+
* @param {string} text
|
|
586
|
+
* @returns {SectionSpan[]}
|
|
587
|
+
*/
|
|
588
|
+
extractSections(id, text) {
|
|
589
|
+
try {
|
|
590
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
591
|
+
let ptr0 = 0;
|
|
592
|
+
if (!isLikeNone(id)) {
|
|
593
|
+
_assertClass(id, FileId);
|
|
594
|
+
ptr0 = id.__destroy_into_raw();
|
|
595
|
+
}
|
|
596
|
+
const ptr1 = passStringToWasm0(text, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
597
|
+
const len1 = WASM_VECTOR_LEN;
|
|
598
|
+
wasm.typststate_extractSections(retptr, this.__wbg_ptr, ptr0, ptr1, len1);
|
|
599
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
600
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
601
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
602
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
603
|
+
if (r3) {
|
|
604
|
+
throw takeObject(r2);
|
|
605
|
+
}
|
|
606
|
+
var v3 = getArrayJsValueFromWasm0(r0, r1);
|
|
607
|
+
wasm.__wbindgen_export4(r0, r1 * 4, 4);
|
|
608
|
+
return v3;
|
|
609
|
+
} finally {
|
|
610
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
611
|
+
}
|
|
612
|
+
}
|
|
514
613
|
/**
|
|
515
614
|
* Plain-text flattening per block for the search index, plus the byte
|
|
516
|
-
* map back to raw source.
|
|
615
|
+
* map back to raw source.
|
|
616
|
+
* @param {FileId | null | undefined} id
|
|
517
617
|
* @param {string} text
|
|
518
618
|
* @returns {FlattenedBlock[]}
|
|
519
619
|
*/
|
|
520
|
-
flattenDocument(text) {
|
|
620
|
+
flattenDocument(id, text) {
|
|
521
621
|
try {
|
|
522
622
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
623
|
+
let ptr0 = 0;
|
|
624
|
+
if (!isLikeNone(id)) {
|
|
625
|
+
_assertClass(id, FileId);
|
|
626
|
+
ptr0 = id.__destroy_into_raw();
|
|
627
|
+
}
|
|
628
|
+
const ptr1 = passStringToWasm0(text, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
629
|
+
const len1 = WASM_VECTOR_LEN;
|
|
630
|
+
wasm.typststate_flattenDocument(retptr, this.__wbg_ptr, ptr0, ptr1, len1);
|
|
526
631
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
527
632
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
528
633
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -530,6 +635,27 @@ export class TypstState {
|
|
|
530
635
|
if (r3) {
|
|
531
636
|
throw takeObject(r2);
|
|
532
637
|
}
|
|
638
|
+
var v3 = getArrayJsValueFromWasm0(r0, r1);
|
|
639
|
+
wasm.__wbindgen_export4(r0, r1 * 4, 4);
|
|
640
|
+
return v3;
|
|
641
|
+
} finally {
|
|
642
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
/**
|
|
646
|
+
* The families a font file declares, so an upload can be filed under the
|
|
647
|
+
* name the font itself carries. Empty when the bytes are not a font.
|
|
648
|
+
* @param {Uint8Array} bytes
|
|
649
|
+
* @returns {string[]}
|
|
650
|
+
*/
|
|
651
|
+
static fontFamilies(bytes) {
|
|
652
|
+
try {
|
|
653
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
654
|
+
const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export);
|
|
655
|
+
const len0 = WASM_VECTOR_LEN;
|
|
656
|
+
wasm.typststate_fontFamilies(retptr, ptr0, len0);
|
|
657
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
658
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
533
659
|
var v2 = getArrayJsValueFromWasm0(r0, r1);
|
|
534
660
|
wasm.__wbindgen_export4(r0, r1 * 4, 4);
|
|
535
661
|
return v2;
|
|
@@ -924,6 +1050,19 @@ export class TypstState {
|
|
|
924
1050
|
var ptr0 = theme.__destroy_into_raw();
|
|
925
1051
|
wasm.typststate_setTheme(this.__wbg_ptr, id.__wbg_ptr, ptr0);
|
|
926
1052
|
}
|
|
1053
|
+
/**
|
|
1054
|
+
* Typographic features the generated prelude turns on or off. They live in
|
|
1055
|
+
* the space context rather than in an app-side prelude so the editor,
|
|
1056
|
+
* previews, plugin surfaces, exports, and published pages all read the
|
|
1057
|
+
* same values from one place.
|
|
1058
|
+
* @param {FileId} id
|
|
1059
|
+
* @param {boolean} ligatures
|
|
1060
|
+
* @param {boolean} kerning
|
|
1061
|
+
*/
|
|
1062
|
+
setTypography(id, ligatures, kerning) {
|
|
1063
|
+
_assertClass(id, FileId);
|
|
1064
|
+
wasm.typststate_setTypography(this.__wbg_ptr, id.__wbg_ptr, ligatures, kerning);
|
|
1065
|
+
}
|
|
927
1066
|
/**
|
|
928
1067
|
* The style block alone, for exports and the project mirror: the same
|
|
929
1068
|
* text the engine prepends, minus the render-target page config.
|
|
@@ -933,9 +1072,11 @@ export class TypstState {
|
|
|
933
1072
|
* @param {string | null | undefined} math_font
|
|
934
1073
|
* @param {string | null | undefined} code_font
|
|
935
1074
|
* @param {string} locale
|
|
1075
|
+
* @param {boolean} ligatures
|
|
1076
|
+
* @param {boolean} kerning
|
|
936
1077
|
* @returns {string}
|
|
937
1078
|
*/
|
|
938
|
-
static stylePrelude(theme, text_size, font, math_font, code_font, locale) {
|
|
1079
|
+
static stylePrelude(theme, text_size, font, math_font, code_font, locale, ligatures, kerning) {
|
|
939
1080
|
let deferred6_0;
|
|
940
1081
|
let deferred6_1;
|
|
941
1082
|
try {
|
|
@@ -950,7 +1091,7 @@ export class TypstState {
|
|
|
950
1091
|
var len3 = WASM_VECTOR_LEN;
|
|
951
1092
|
const ptr4 = passStringToWasm0(locale, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
952
1093
|
const len4 = WASM_VECTOR_LEN;
|
|
953
|
-
wasm.typststate_stylePrelude(retptr, ptr0, text_size, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4);
|
|
1094
|
+
wasm.typststate_stylePrelude(retptr, ptr0, text_size, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, ligatures, kerning);
|
|
954
1095
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
955
1096
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
956
1097
|
deferred6_0 = r0;
|
|
@@ -961,6 +1102,23 @@ export class TypstState {
|
|
|
961
1102
|
wasm.__wbindgen_export4(deferred6_0, deferred6_1, 1);
|
|
962
1103
|
}
|
|
963
1104
|
}
|
|
1105
|
+
/**
|
|
1106
|
+
* Brings the engine's sources and maps up to date with `text` without
|
|
1107
|
+
* rendering anything.
|
|
1108
|
+
* @param {FileId} id
|
|
1109
|
+
* @param {string} text
|
|
1110
|
+
* @param {string} prelude
|
|
1111
|
+
* @returns {boolean}
|
|
1112
|
+
*/
|
|
1113
|
+
syncSource(id, text, prelude) {
|
|
1114
|
+
_assertClass(id, FileId);
|
|
1115
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
1116
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1117
|
+
const ptr1 = passStringToWasm0(prelude, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
1118
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1119
|
+
const ret = wasm.typststate_syncSource(this.__wbg_ptr, id.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
1120
|
+
return ret !== 0;
|
|
1121
|
+
}
|
|
964
1122
|
/**
|
|
965
1123
|
* The stdlib source as shipped, for writing a compilable project to disk.
|
|
966
1124
|
* @returns {string}
|
|
@@ -1067,10 +1225,10 @@ function __wbg_get_imports() {
|
|
|
1067
1225
|
__wbg___wbindgen_throw_bb96b2010945f0bc: function(arg0, arg1) {
|
|
1068
1226
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
1069
1227
|
},
|
|
1070
|
-
|
|
1228
|
+
__wbg_debug_29ace34228806e23: function(arg0, arg1) {
|
|
1071
1229
|
console.debug(getStringFromWasm0(arg0, arg1));
|
|
1072
1230
|
},
|
|
1073
|
-
|
|
1231
|
+
__wbg_error_f6f4cf0f40c5887c: function(arg0, arg1) {
|
|
1074
1232
|
console.error(getStringFromWasm0(arg0, arg1));
|
|
1075
1233
|
},
|
|
1076
1234
|
__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.
|
|
6
|
-
"license": "
|
|
5
|
+
"version": "0.4.1",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
9
|
"url": "https://github.com/lemueldls/typbase"
|