@vedivad/typst-web-service 0.15.4 → 0.17.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.
@@ -0,0 +1,509 @@
1
+ // src/typsten-worker.ts
2
+ import * as Comlink from "comlink";
3
+
4
+ // ../typsten/pkg/typsten.js
5
+ var Project = class {
6
+ __destroy_into_raw() {
7
+ const ptr = this.__wbg_ptr;
8
+ this.__wbg_ptr = 0;
9
+ ProjectFinalization.unregister(this);
10
+ return ptr;
11
+ }
12
+ free() {
13
+ const ptr = this.__destroy_into_raw();
14
+ wasm.__wbg_project_free(ptr, 0);
15
+ }
16
+ /**
17
+ * Register a font file (TTF/OTF, or a TTC collection) for compilation,
18
+ * extending the embedded default fonts with families the engine does not
19
+ * bundle (e.g. CJK or a custom font).
20
+ * @param {Uint8Array} bytes
21
+ */
22
+ add_font(bytes) {
23
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
24
+ const len0 = WASM_VECTOR_LEN;
25
+ wasm.project_add_font(this.__wbg_ptr, ptr0, len0);
26
+ }
27
+ /**
28
+ * Compile the project, returning the rendered SVG and typed diagnostics.
29
+ *
30
+ * A query, so `&self`: the `Source` cache it touches is interior-mutable.
31
+ * @returns {CompileResult}
32
+ */
33
+ compile() {
34
+ const ret = wasm.project_compile(this.__wbg_ptr);
35
+ return ret;
36
+ }
37
+ /**
38
+ * Completions at a byte-offset `cursor` in `path`. `explicit` is `true`
39
+ * when the user explicitly requested completion (e.g. Ctrl-Space).
40
+ * @param {string} path
41
+ * @param {number} cursor
42
+ * @param {boolean} explicit
43
+ * @returns {CompletionResponse | undefined}
44
+ */
45
+ complete(path, cursor, explicit) {
46
+ const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
47
+ const len0 = WASM_VECTOR_LEN;
48
+ const ret = wasm.project_complete(this.__wbg_ptr, ptr0, len0, cursor, explicit);
49
+ return ret;
50
+ }
51
+ /**
52
+ * Export the last compiled document as PDF bytes, or `None` if nothing has
53
+ * compiled yet. Returns a `Uint8Array` across the boundary.
54
+ * @returns {Uint8Array | undefined}
55
+ */
56
+ export_pdf() {
57
+ const ret = wasm.project_export_pdf(this.__wbg_ptr);
58
+ let v1;
59
+ if (ret[0] !== 0) {
60
+ v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
61
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
62
+ }
63
+ return v1;
64
+ }
65
+ /**
66
+ * Format the file at `path`, returning the formatted source or `None` if
67
+ * it is absent or has syntax errors.
68
+ * @param {string} path
69
+ * @returns {string | undefined}
70
+ */
71
+ format(path) {
72
+ const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
73
+ const len0 = WASM_VECTOR_LEN;
74
+ const ret = wasm.project_format(this.__wbg_ptr, ptr0, len0);
75
+ let v2;
76
+ if (ret[0] !== 0) {
77
+ v2 = getStringFromWasm0(ret[0], ret[1]).slice();
78
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
79
+ }
80
+ return v2;
81
+ }
82
+ /**
83
+ * Syntax-highlight `text`, returning the spans overlapping the byte window
84
+ * `[from, to)` (the editor's visible viewport; pass `0..len` for all of it).
85
+ * Stateless: it parses `text` directly, so it neither reads nor mutates the
86
+ * VFS and works for the live buffer and hover snippets alike.
87
+ * @param {string} text
88
+ * @param {number} from
89
+ * @param {number} to
90
+ * @returns {HlSpan[]}
91
+ */
92
+ highlight(text, from, to) {
93
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
94
+ const len0 = WASM_VECTOR_LEN;
95
+ const ret = wasm.project_highlight(this.__wbg_ptr, ptr0, len0, from, to);
96
+ var v2 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
97
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
98
+ return v2;
99
+ }
100
+ /**
101
+ * Syntax-highlight `text` to nested `<span class="typ-*">` HTML, for static
102
+ * contexts like hover tooltips. Stateless, like `highlight`.
103
+ * @param {string} text
104
+ * @returns {string}
105
+ */
106
+ highlight_html(text) {
107
+ let deferred2_0;
108
+ let deferred2_1;
109
+ try {
110
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
111
+ const len0 = WASM_VECTOR_LEN;
112
+ const ret = wasm.project_highlight_html(this.__wbg_ptr, ptr0, len0);
113
+ deferred2_0 = ret[0];
114
+ deferred2_1 = ret[1];
115
+ return getStringFromWasm0(ret[0], ret[1]);
116
+ } finally {
117
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
118
+ }
119
+ }
120
+ /**
121
+ * Hover tooltip at a byte-offset `cursor` in `path`.
122
+ * @param {string} path
123
+ * @param {number} cursor
124
+ * @returns {Hover | undefined}
125
+ */
126
+ hover(path, cursor) {
127
+ const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
128
+ const len0 = WASM_VECTOR_LEN;
129
+ const ret = wasm.project_hover(this.__wbg_ptr, ptr0, len0, cursor);
130
+ return ret;
131
+ }
132
+ constructor() {
133
+ const ret = wasm.project_new();
134
+ this.__wbg_ptr = ret;
135
+ ProjectFinalization.register(this, this.__wbg_ptr, this);
136
+ return this;
137
+ }
138
+ /**
139
+ * Remove a file from the VFS.
140
+ * @param {string} path
141
+ */
142
+ remove_file(path) {
143
+ const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
144
+ const len0 = WASM_VECTOR_LEN;
145
+ wasm.project_remove_file(this.__wbg_ptr, ptr0, len0);
146
+ }
147
+ /**
148
+ * Render a single page of the last compiled document to SVG, or `None` if
149
+ * nothing has compiled yet or the index is out of range.
150
+ * @param {number} index
151
+ * @returns {string | undefined}
152
+ */
153
+ render_page(index) {
154
+ const ret = wasm.project_render_page(this.__wbg_ptr, index);
155
+ let v1;
156
+ if (ret[0] !== 0) {
157
+ v1 = getStringFromWasm0(ret[0], ret[1]).slice();
158
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
159
+ }
160
+ return v1;
161
+ }
162
+ /**
163
+ * Render pages `[start, end)` of the last compiled document to SVG (`end`
164
+ * clamped to the page count), the on-demand path for a virtualized viewer.
165
+ * @param {number} start
166
+ * @param {number} end
167
+ * @returns {string[]}
168
+ */
169
+ render_pages(start, end) {
170
+ const ret = wasm.project_render_pages(this.__wbg_ptr, start, end);
171
+ var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
172
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
173
+ return v1;
174
+ }
175
+ /**
176
+ * Set the entry (main) file that compilation starts from.
177
+ * @param {string} path
178
+ */
179
+ set_entry(path) {
180
+ const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
181
+ const len0 = WASM_VECTOR_LEN;
182
+ wasm.project_set_entry(this.__wbg_ptr, ptr0, len0);
183
+ }
184
+ /**
185
+ * Insert or replace a file in the VFS. Source files are just their UTF-8
186
+ * bytes; package and asset bytes are stored the same way.
187
+ * @param {string} path
188
+ * @param {Uint8Array} bytes
189
+ */
190
+ set_file(path, bytes) {
191
+ const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
192
+ const len0 = WASM_VECTOR_LEN;
193
+ const ptr1 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
194
+ const len1 = WASM_VECTOR_LEN;
195
+ wasm.project_set_file(this.__wbg_ptr, ptr0, len0, ptr1, len1);
196
+ }
197
+ /**
198
+ * The Typst engine version this crate is built against, e.g. "0.14.2".
199
+ * @returns {string}
200
+ */
201
+ version() {
202
+ let deferred1_0;
203
+ let deferred1_1;
204
+ try {
205
+ const ret = wasm.project_version(this.__wbg_ptr);
206
+ deferred1_0 = ret[0];
207
+ deferred1_1 = ret[1];
208
+ return getStringFromWasm0(ret[0], ret[1]);
209
+ } finally {
210
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
211
+ }
212
+ }
213
+ };
214
+ if (Symbol.dispose) Project.prototype[Symbol.dispose] = Project.prototype.free;
215
+ function __wbg_get_imports() {
216
+ const import0 = {
217
+ __proto__: null,
218
+ __wbg_Error_ef53bc310eb298a0: function(arg0, arg1) {
219
+ const ret = Error(getStringFromWasm0(arg0, arg1));
220
+ return ret;
221
+ },
222
+ __wbg_String_8564e559799eccda: function(arg0, arg1) {
223
+ const ret = String(arg1);
224
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
225
+ const len1 = WASM_VECTOR_LEN;
226
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
227
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
228
+ },
229
+ __wbg___wbindgen_throw_1506f2235d1bdba0: function(arg0, arg1) {
230
+ throw new Error(getStringFromWasm0(arg0, arg1));
231
+ },
232
+ __wbg_error_a6fa202b58aa1cd3: function(arg0, arg1) {
233
+ let deferred0_0;
234
+ let deferred0_1;
235
+ try {
236
+ deferred0_0 = arg0;
237
+ deferred0_1 = arg1;
238
+ console.error(getStringFromWasm0(arg0, arg1));
239
+ } finally {
240
+ wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
241
+ }
242
+ },
243
+ __wbg_new_227d7c05414eb861: function() {
244
+ const ret = new Error();
245
+ return ret;
246
+ },
247
+ __wbg_new_ce1ab61c1c2b300d: function() {
248
+ const ret = new Object();
249
+ return ret;
250
+ },
251
+ __wbg_new_d90091b82fdf5b91: function() {
252
+ const ret = new Array();
253
+ return ret;
254
+ },
255
+ __wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
256
+ arg0[arg1] = arg2;
257
+ },
258
+ __wbg_set_dca99999bba88a9a: function(arg0, arg1, arg2) {
259
+ arg0[arg1 >>> 0] = arg2;
260
+ },
261
+ __wbg_stack_3b0d974bbf31e44f: function(arg0, arg1) {
262
+ const ret = arg1.stack;
263
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
264
+ const len1 = WASM_VECTOR_LEN;
265
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
266
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
267
+ },
268
+ __wbindgen_cast_0000000000000001: function(arg0) {
269
+ const ret = arg0;
270
+ return ret;
271
+ },
272
+ __wbindgen_cast_0000000000000002: function(arg0, arg1) {
273
+ const ret = getStringFromWasm0(arg0, arg1);
274
+ return ret;
275
+ },
276
+ __wbindgen_cast_0000000000000003: function(arg0) {
277
+ const ret = BigInt.asUintN(64, arg0);
278
+ return ret;
279
+ },
280
+ __wbindgen_init_externref_table: function() {
281
+ const table = wasm.__wbindgen_externrefs;
282
+ const offset = table.grow(4);
283
+ table.set(0, void 0);
284
+ table.set(offset + 0, void 0);
285
+ table.set(offset + 1, null);
286
+ table.set(offset + 2, true);
287
+ table.set(offset + 3, false);
288
+ }
289
+ };
290
+ return {
291
+ __proto__: null,
292
+ "./typsten_bg.js": import0
293
+ };
294
+ }
295
+ var ProjectFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => {
296
+ }, unregister: () => {
297
+ } } : new FinalizationRegistry((ptr) => wasm.__wbg_project_free(ptr, 1));
298
+ function getArrayJsValueFromWasm0(ptr, len) {
299
+ ptr = ptr >>> 0;
300
+ const mem = getDataViewMemory0();
301
+ const result = [];
302
+ for (let i = ptr; i < ptr + 4 * len; i += 4) {
303
+ result.push(wasm.__wbindgen_externrefs.get(mem.getUint32(i, true)));
304
+ }
305
+ wasm.__externref_drop_slice(ptr, len);
306
+ return result;
307
+ }
308
+ function getArrayU8FromWasm0(ptr, len) {
309
+ ptr = ptr >>> 0;
310
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
311
+ }
312
+ var cachedDataViewMemory0 = null;
313
+ function getDataViewMemory0() {
314
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || cachedDataViewMemory0.buffer.detached === void 0 && cachedDataViewMemory0.buffer !== wasm.memory.buffer) {
315
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
316
+ }
317
+ return cachedDataViewMemory0;
318
+ }
319
+ function getStringFromWasm0(ptr, len) {
320
+ return decodeText(ptr >>> 0, len);
321
+ }
322
+ var cachedUint8ArrayMemory0 = null;
323
+ function getUint8ArrayMemory0() {
324
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
325
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
326
+ }
327
+ return cachedUint8ArrayMemory0;
328
+ }
329
+ function passArray8ToWasm0(arg, malloc) {
330
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
331
+ getUint8ArrayMemory0().set(arg, ptr / 1);
332
+ WASM_VECTOR_LEN = arg.length;
333
+ return ptr;
334
+ }
335
+ function passStringToWasm0(arg, malloc, realloc) {
336
+ if (realloc === void 0) {
337
+ const buf = cachedTextEncoder.encode(arg);
338
+ const ptr2 = malloc(buf.length, 1) >>> 0;
339
+ getUint8ArrayMemory0().subarray(ptr2, ptr2 + buf.length).set(buf);
340
+ WASM_VECTOR_LEN = buf.length;
341
+ return ptr2;
342
+ }
343
+ let len = arg.length;
344
+ let ptr = malloc(len, 1) >>> 0;
345
+ const mem = getUint8ArrayMemory0();
346
+ let offset = 0;
347
+ for (; offset < len; offset++) {
348
+ const code = arg.charCodeAt(offset);
349
+ if (code > 127) break;
350
+ mem[ptr + offset] = code;
351
+ }
352
+ if (offset !== len) {
353
+ if (offset !== 0) {
354
+ arg = arg.slice(offset);
355
+ }
356
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
357
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
358
+ const ret = cachedTextEncoder.encodeInto(arg, view);
359
+ offset += ret.written;
360
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
361
+ }
362
+ WASM_VECTOR_LEN = offset;
363
+ return ptr;
364
+ }
365
+ var cachedTextDecoder = new TextDecoder("utf-8", { ignoreBOM: true, fatal: true });
366
+ cachedTextDecoder.decode();
367
+ var MAX_SAFARI_DECODE_BYTES = 2146435072;
368
+ var numBytesDecoded = 0;
369
+ function decodeText(ptr, len) {
370
+ numBytesDecoded += len;
371
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
372
+ cachedTextDecoder = new TextDecoder("utf-8", { ignoreBOM: true, fatal: true });
373
+ cachedTextDecoder.decode();
374
+ numBytesDecoded = len;
375
+ }
376
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
377
+ }
378
+ var cachedTextEncoder = new TextEncoder();
379
+ if (!("encodeInto" in cachedTextEncoder)) {
380
+ cachedTextEncoder.encodeInto = function(arg, view) {
381
+ const buf = cachedTextEncoder.encode(arg);
382
+ view.set(buf);
383
+ return {
384
+ read: arg.length,
385
+ written: buf.length
386
+ };
387
+ };
388
+ }
389
+ var WASM_VECTOR_LEN = 0;
390
+ var wasmModule;
391
+ var wasmInstance;
392
+ var wasm;
393
+ function __wbg_finalize_init(instance, module) {
394
+ wasmInstance = instance;
395
+ wasm = instance.exports;
396
+ wasmModule = module;
397
+ cachedDataViewMemory0 = null;
398
+ cachedUint8ArrayMemory0 = null;
399
+ wasm.__wbindgen_start();
400
+ return wasm;
401
+ }
402
+ async function __wbg_load(module, imports) {
403
+ if (typeof Response === "function" && module instanceof Response) {
404
+ if (typeof WebAssembly.instantiateStreaming === "function") {
405
+ try {
406
+ return await WebAssembly.instantiateStreaming(module, imports);
407
+ } catch (e) {
408
+ const validResponse = module.ok && expectedResponseType(module.type);
409
+ if (validResponse && module.headers.get("Content-Type") !== "application/wasm") {
410
+ console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
411
+ } else {
412
+ throw e;
413
+ }
414
+ }
415
+ }
416
+ const bytes = await module.arrayBuffer();
417
+ return await WebAssembly.instantiate(bytes, imports);
418
+ } else {
419
+ const instance = await WebAssembly.instantiate(module, imports);
420
+ if (instance instanceof WebAssembly.Instance) {
421
+ return { instance, module };
422
+ } else {
423
+ return instance;
424
+ }
425
+ }
426
+ function expectedResponseType(type) {
427
+ switch (type) {
428
+ case "basic":
429
+ case "cors":
430
+ case "default":
431
+ return true;
432
+ }
433
+ return false;
434
+ }
435
+ }
436
+ async function __wbg_init(module_or_path) {
437
+ if (wasm !== void 0) return wasm;
438
+ if (module_or_path !== void 0) {
439
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
440
+ ({ module_or_path } = module_or_path);
441
+ } else {
442
+ console.warn("using deprecated parameters for the initialization function; pass a single object instead");
443
+ }
444
+ }
445
+ if (module_or_path === void 0) {
446
+ module_or_path = new URL("typsten_bg.wasm", import.meta.url);
447
+ }
448
+ const imports = __wbg_get_imports();
449
+ if (typeof module_or_path === "string" || typeof Request === "function" && module_or_path instanceof Request || typeof URL === "function" && module_or_path instanceof URL) {
450
+ module_or_path = fetch(module_or_path);
451
+ }
452
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
453
+ return __wbg_finalize_init(instance, module);
454
+ }
455
+
456
+ // src/typsten-worker.ts
457
+ var TypstenWorker = class {
458
+ #project;
459
+ /** Initialize the wasm from `wasmUrl` and create the project handle. */
460
+ async init(wasmUrl) {
461
+ await __wbg_init({ module_or_path: wasmUrl });
462
+ this.#project = new Project();
463
+ }
464
+ #p() {
465
+ if (!this.#project) throw new Error("typsten worker: init() not called");
466
+ return this.#project;
467
+ }
468
+ setFile(path, bytes) {
469
+ this.#p().set_file(path, bytes);
470
+ }
471
+ setEntry(path) {
472
+ this.#p().set_entry(path);
473
+ }
474
+ addFont(bytes) {
475
+ this.#p().add_font(bytes);
476
+ }
477
+ remove(path) {
478
+ this.#p().remove_file(path);
479
+ }
480
+ compile() {
481
+ return this.#p().compile();
482
+ }
483
+ renderPage(index) {
484
+ return this.#p().render_page(index);
485
+ }
486
+ renderPages(start, end) {
487
+ return this.#p().render_pages(start, end);
488
+ }
489
+ exportPdf() {
490
+ return this.#p().export_pdf();
491
+ }
492
+ complete(path, cursor, explicit) {
493
+ return this.#p().complete(path, cursor, explicit);
494
+ }
495
+ hover(path, cursor) {
496
+ return this.#p().hover(path, cursor);
497
+ }
498
+ format(path) {
499
+ return this.#p().format(path);
500
+ }
501
+ highlight(text, from, to) {
502
+ return this.#p().highlight(text, from, to);
503
+ }
504
+ highlightHtml(text) {
505
+ return this.#p().highlight_html(text);
506
+ }
507
+ };
508
+ Comlink.expose(new TypstenWorker());
509
+ //# sourceMappingURL=typsten-worker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/typsten-worker.ts","../../typsten/pkg/typsten.js"],"sourcesContent":["// The single Web Worker that hosts the typsten wasm. Replaces the former\n// compiler / renderer / analyzer / formatter workers (typsten is one module).\n// Exposed over Comlink; the `Project` wasm object never crosses the boundary -\n// only plain data does.\nimport * as Comlink from \"comlink\";\nimport init, { Project } from \"typsten\";\n\nclass TypstenWorker {\n #project: Project | undefined;\n\n /** Initialize the wasm from `wasmUrl` and create the project handle. */\n async init(wasmUrl: string): Promise<void> {\n await init({ module_or_path: wasmUrl });\n this.#project = new Project();\n }\n\n #p(): Project {\n if (!this.#project) throw new Error(\"typsten worker: init() not called\");\n return this.#project;\n }\n\n setFile(path: string, bytes: Uint8Array): void {\n this.#p().set_file(path, bytes);\n }\n\n setEntry(path: string): void {\n this.#p().set_entry(path);\n }\n\n addFont(bytes: Uint8Array): void {\n this.#p().add_font(bytes);\n }\n\n remove(path: string): void {\n this.#p().remove_file(path);\n }\n\n compile(): ReturnType<Project[\"compile\"]> {\n return this.#p().compile();\n }\n\n renderPage(index: number): string | undefined {\n return this.#p().render_page(index);\n }\n\n renderPages(start: number, end: number): string[] {\n return this.#p().render_pages(start, end);\n }\n\n exportPdf(): Uint8Array | undefined {\n return this.#p().export_pdf();\n }\n\n complete(\n path: string,\n cursor: number,\n explicit: boolean,\n ): ReturnType<Project[\"complete\"]> {\n return this.#p().complete(path, cursor, explicit);\n }\n\n hover(path: string, cursor: number): ReturnType<Project[\"hover\"]> {\n return this.#p().hover(path, cursor);\n }\n\n format(path: string): string | undefined {\n return this.#p().format(path);\n }\n\n highlight(\n text: string,\n from: number,\n to: number,\n ): ReturnType<Project[\"highlight\"]> {\n return this.#p().highlight(text, from, to);\n }\n\n highlightHtml(text: string): string {\n return this.#p().highlight_html(text);\n }\n}\n\n/** The worker's RPC surface, for `Comlink.wrap<TypstenWorkerApi>` on the main thread. */\nexport type TypstenWorkerApi = TypstenWorker;\n\nComlink.expose(new TypstenWorker());\n","/* @ts-self-types=\"./typsten.d.ts\" */\n\n/**\n * The typsten project handle. JS pushes files in and asks for compiled output.\n */\nexport class Project {\n __destroy_into_raw() {\n const ptr = this.__wbg_ptr;\n this.__wbg_ptr = 0;\n ProjectFinalization.unregister(this);\n return ptr;\n }\n free() {\n const ptr = this.__destroy_into_raw();\n wasm.__wbg_project_free(ptr, 0);\n }\n /**\n * Register a font file (TTF/OTF, or a TTC collection) for compilation,\n * extending the embedded default fonts with families the engine does not\n * bundle (e.g. CJK or a custom font).\n * @param {Uint8Array} bytes\n */\n add_font(bytes) {\n const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n wasm.project_add_font(this.__wbg_ptr, ptr0, len0);\n }\n /**\n * Compile the project, returning the rendered SVG and typed diagnostics.\n *\n * A query, so `&self`: the `Source` cache it touches is interior-mutable.\n * @returns {CompileResult}\n */\n compile() {\n const ret = wasm.project_compile(this.__wbg_ptr);\n return ret;\n }\n /**\n * Completions at a byte-offset `cursor` in `path`. `explicit` is `true`\n * when the user explicitly requested completion (e.g. Ctrl-Space).\n * @param {string} path\n * @param {number} cursor\n * @param {boolean} explicit\n * @returns {CompletionResponse | undefined}\n */\n complete(path, cursor, explicit) {\n const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.project_complete(this.__wbg_ptr, ptr0, len0, cursor, explicit);\n return ret;\n }\n /**\n * Export the last compiled document as PDF bytes, or `None` if nothing has\n * compiled yet. Returns a `Uint8Array` across the boundary.\n * @returns {Uint8Array | undefined}\n */\n export_pdf() {\n const ret = wasm.project_export_pdf(this.__wbg_ptr);\n let v1;\n if (ret[0] !== 0) {\n v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n }\n return v1;\n }\n /**\n * Format the file at `path`, returning the formatted source or `None` if\n * it is absent or has syntax errors.\n * @param {string} path\n * @returns {string | undefined}\n */\n format(path) {\n const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.project_format(this.__wbg_ptr, ptr0, len0);\n let v2;\n if (ret[0] !== 0) {\n v2 = getStringFromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n }\n return v2;\n }\n /**\n * Syntax-highlight `text`, returning the spans overlapping the byte window\n * `[from, to)` (the editor's visible viewport; pass `0..len` for all of it).\n * Stateless: it parses `text` directly, so it neither reads nor mutates the\n * VFS and works for the live buffer and hover snippets alike.\n * @param {string} text\n * @param {number} from\n * @param {number} to\n * @returns {HlSpan[]}\n */\n highlight(text, from, to) {\n const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.project_highlight(this.__wbg_ptr, ptr0, len0, from, to);\n var v2 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);\n return v2;\n }\n /**\n * Syntax-highlight `text` to nested `<span class=\"typ-*\">` HTML, for static\n * contexts like hover tooltips. Stateless, like `highlight`.\n * @param {string} text\n * @returns {string}\n */\n highlight_html(text) {\n let deferred2_0;\n let deferred2_1;\n try {\n const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.project_highlight_html(this.__wbg_ptr, ptr0, len0);\n deferred2_0 = ret[0];\n deferred2_1 = ret[1];\n return getStringFromWasm0(ret[0], ret[1]);\n } finally {\n wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);\n }\n }\n /**\n * Hover tooltip at a byte-offset `cursor` in `path`.\n * @param {string} path\n * @param {number} cursor\n * @returns {Hover | undefined}\n */\n hover(path, cursor) {\n const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.project_hover(this.__wbg_ptr, ptr0, len0, cursor);\n return ret;\n }\n constructor() {\n const ret = wasm.project_new();\n this.__wbg_ptr = ret;\n ProjectFinalization.register(this, this.__wbg_ptr, this);\n return this;\n }\n /**\n * Remove a file from the VFS.\n * @param {string} path\n */\n remove_file(path) {\n const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len0 = WASM_VECTOR_LEN;\n wasm.project_remove_file(this.__wbg_ptr, ptr0, len0);\n }\n /**\n * Render a single page of the last compiled document to SVG, or `None` if\n * nothing has compiled yet or the index is out of range.\n * @param {number} index\n * @returns {string | undefined}\n */\n render_page(index) {\n const ret = wasm.project_render_page(this.__wbg_ptr, index);\n let v1;\n if (ret[0] !== 0) {\n v1 = getStringFromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n }\n return v1;\n }\n /**\n * Render pages `[start, end)` of the last compiled document to SVG (`end`\n * clamped to the page count), the on-demand path for a virtualized viewer.\n * @param {number} start\n * @param {number} end\n * @returns {string[]}\n */\n render_pages(start, end) {\n const ret = wasm.project_render_pages(this.__wbg_ptr, start, end);\n var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);\n return v1;\n }\n /**\n * Set the entry (main) file that compilation starts from.\n * @param {string} path\n */\n set_entry(path) {\n const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len0 = WASM_VECTOR_LEN;\n wasm.project_set_entry(this.__wbg_ptr, ptr0, len0);\n }\n /**\n * Insert or replace a file in the VFS. Source files are just their UTF-8\n * bytes; package and asset bytes are stored the same way.\n * @param {string} path\n * @param {Uint8Array} bytes\n */\n set_file(path, bytes) {\n const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);\n const len1 = WASM_VECTOR_LEN;\n wasm.project_set_file(this.__wbg_ptr, ptr0, len0, ptr1, len1);\n }\n /**\n * The Typst engine version this crate is built against, e.g. \"0.14.2\".\n * @returns {string}\n */\n version() {\n let deferred1_0;\n let deferred1_1;\n try {\n const ret = wasm.project_version(this.__wbg_ptr);\n deferred1_0 = ret[0];\n deferred1_1 = ret[1];\n return getStringFromWasm0(ret[0], ret[1]);\n } finally {\n wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);\n }\n }\n}\nif (Symbol.dispose) Project.prototype[Symbol.dispose] = Project.prototype.free;\n\nexport function start() {\n wasm.start();\n}\nfunction __wbg_get_imports() {\n const import0 = {\n __proto__: null,\n __wbg_Error_ef53bc310eb298a0: function(arg0, arg1) {\n const ret = Error(getStringFromWasm0(arg0, arg1));\n return ret;\n },\n __wbg_String_8564e559799eccda: function(arg0, arg1) {\n const ret = String(arg1);\n const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len1 = WASM_VECTOR_LEN;\n getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);\n getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);\n },\n __wbg___wbindgen_throw_1506f2235d1bdba0: function(arg0, arg1) {\n throw new Error(getStringFromWasm0(arg0, arg1));\n },\n __wbg_error_a6fa202b58aa1cd3: function(arg0, arg1) {\n let deferred0_0;\n let deferred0_1;\n try {\n deferred0_0 = arg0;\n deferred0_1 = arg1;\n console.error(getStringFromWasm0(arg0, arg1));\n } finally {\n wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);\n }\n },\n __wbg_new_227d7c05414eb861: function() {\n const ret = new Error();\n return ret;\n },\n __wbg_new_ce1ab61c1c2b300d: function() {\n const ret = new Object();\n return ret;\n },\n __wbg_new_d90091b82fdf5b91: function() {\n const ret = new Array();\n return ret;\n },\n __wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {\n arg0[arg1] = arg2;\n },\n __wbg_set_dca99999bba88a9a: function(arg0, arg1, arg2) {\n arg0[arg1 >>> 0] = arg2;\n },\n __wbg_stack_3b0d974bbf31e44f: function(arg0, arg1) {\n const ret = arg1.stack;\n const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len1 = WASM_VECTOR_LEN;\n getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);\n getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);\n },\n __wbindgen_cast_0000000000000001: function(arg0) {\n // Cast intrinsic for `F64 -> Externref`.\n const ret = arg0;\n return ret;\n },\n __wbindgen_cast_0000000000000002: function(arg0, arg1) {\n // Cast intrinsic for `Ref(String) -> Externref`.\n const ret = getStringFromWasm0(arg0, arg1);\n return ret;\n },\n __wbindgen_cast_0000000000000003: function(arg0) {\n // Cast intrinsic for `U64 -> Externref`.\n const ret = BigInt.asUintN(64, arg0);\n return ret;\n },\n __wbindgen_init_externref_table: function() {\n const table = wasm.__wbindgen_externrefs;\n const offset = table.grow(4);\n table.set(0, undefined);\n table.set(offset + 0, undefined);\n table.set(offset + 1, null);\n table.set(offset + 2, true);\n table.set(offset + 3, false);\n },\n };\n return {\n __proto__: null,\n \"./typsten_bg.js\": import0,\n };\n}\n\nconst ProjectFinalization = (typeof FinalizationRegistry === 'undefined')\n ? { register: () => {}, unregister: () => {} }\n : new FinalizationRegistry(ptr => wasm.__wbg_project_free(ptr, 1));\n\nfunction getArrayJsValueFromWasm0(ptr, len) {\n ptr = ptr >>> 0;\n const mem = getDataViewMemory0();\n const result = [];\n for (let i = ptr; i < ptr + 4 * len; i += 4) {\n result.push(wasm.__wbindgen_externrefs.get(mem.getUint32(i, true)));\n }\n wasm.__externref_drop_slice(ptr, len);\n return result;\n}\n\nfunction getArrayU8FromWasm0(ptr, len) {\n ptr = ptr >>> 0;\n return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);\n}\n\nlet cachedDataViewMemory0 = null;\nfunction getDataViewMemory0() {\n if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {\n cachedDataViewMemory0 = new DataView(wasm.memory.buffer);\n }\n return cachedDataViewMemory0;\n}\n\nfunction getStringFromWasm0(ptr, len) {\n return decodeText(ptr >>> 0, len);\n}\n\nlet cachedUint8ArrayMemory0 = null;\nfunction getUint8ArrayMemory0() {\n if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {\n cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);\n }\n return cachedUint8ArrayMemory0;\n}\n\nfunction passArray8ToWasm0(arg, malloc) {\n const ptr = malloc(arg.length * 1, 1) >>> 0;\n getUint8ArrayMemory0().set(arg, ptr / 1);\n WASM_VECTOR_LEN = arg.length;\n return ptr;\n}\n\nfunction passStringToWasm0(arg, malloc, realloc) {\n if (realloc === undefined) {\n const buf = cachedTextEncoder.encode(arg);\n const ptr = malloc(buf.length, 1) >>> 0;\n getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);\n WASM_VECTOR_LEN = buf.length;\n return ptr;\n }\n\n let len = arg.length;\n let ptr = malloc(len, 1) >>> 0;\n\n const mem = getUint8ArrayMemory0();\n\n let offset = 0;\n\n for (; offset < len; offset++) {\n const code = arg.charCodeAt(offset);\n if (code > 0x7F) break;\n mem[ptr + offset] = code;\n }\n if (offset !== len) {\n if (offset !== 0) {\n arg = arg.slice(offset);\n }\n ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;\n const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);\n const ret = cachedTextEncoder.encodeInto(arg, view);\n\n offset += ret.written;\n ptr = realloc(ptr, len, offset, 1) >>> 0;\n }\n\n WASM_VECTOR_LEN = offset;\n return ptr;\n}\n\nlet cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });\ncachedTextDecoder.decode();\nconst MAX_SAFARI_DECODE_BYTES = 2146435072;\nlet numBytesDecoded = 0;\nfunction decodeText(ptr, len) {\n numBytesDecoded += len;\n if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {\n cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });\n cachedTextDecoder.decode();\n numBytesDecoded = len;\n }\n return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));\n}\n\nconst cachedTextEncoder = new TextEncoder();\n\nif (!('encodeInto' in cachedTextEncoder)) {\n cachedTextEncoder.encodeInto = function (arg, view) {\n const buf = cachedTextEncoder.encode(arg);\n view.set(buf);\n return {\n read: arg.length,\n written: buf.length\n };\n };\n}\n\nlet WASM_VECTOR_LEN = 0;\n\nlet wasmModule, wasmInstance, wasm;\nfunction __wbg_finalize_init(instance, module) {\n wasmInstance = instance;\n wasm = instance.exports;\n wasmModule = module;\n cachedDataViewMemory0 = null;\n cachedUint8ArrayMemory0 = null;\n wasm.__wbindgen_start();\n return wasm;\n}\n\nasync function __wbg_load(module, imports) {\n if (typeof Response === 'function' && module instanceof Response) {\n if (typeof WebAssembly.instantiateStreaming === 'function') {\n try {\n return await WebAssembly.instantiateStreaming(module, imports);\n } catch (e) {\n const validResponse = module.ok && expectedResponseType(module.type);\n\n if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {\n console.warn(\"`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\\n\", e);\n\n } else { throw e; }\n }\n }\n\n const bytes = await module.arrayBuffer();\n return await WebAssembly.instantiate(bytes, imports);\n } else {\n const instance = await WebAssembly.instantiate(module, imports);\n\n if (instance instanceof WebAssembly.Instance) {\n return { instance, module };\n } else {\n return instance;\n }\n }\n\n function expectedResponseType(type) {\n switch (type) {\n case 'basic': case 'cors': case 'default': return true;\n }\n return false;\n }\n}\n\nfunction initSync(module) {\n if (wasm !== undefined) return wasm;\n\n\n if (module !== undefined) {\n if (Object.getPrototypeOf(module) === Object.prototype) {\n ({module} = module)\n } else {\n console.warn('using deprecated parameters for `initSync()`; pass a single object instead')\n }\n }\n\n const imports = __wbg_get_imports();\n if (!(module instanceof WebAssembly.Module)) {\n module = new WebAssembly.Module(module);\n }\n const instance = new WebAssembly.Instance(module, imports);\n return __wbg_finalize_init(instance, module);\n}\n\nasync function __wbg_init(module_or_path) {\n if (wasm !== undefined) return wasm;\n\n\n if (module_or_path !== undefined) {\n if (Object.getPrototypeOf(module_or_path) === Object.prototype) {\n ({module_or_path} = module_or_path)\n } else {\n console.warn('using deprecated parameters for the initialization function; pass a single object instead')\n }\n }\n\n if (module_or_path === undefined) {\n module_or_path = new URL('typsten_bg.wasm', import.meta.url);\n }\n const imports = __wbg_get_imports();\n\n if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {\n module_or_path = fetch(module_or_path);\n }\n\n const { instance, module } = await __wbg_load(await module_or_path, imports);\n\n return __wbg_finalize_init(instance, module);\n}\n\nexport { initSync, __wbg_init as default };\n"],"mappings":";AAIA,YAAY,aAAa;;;AC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": "0.17.1",
4
4
  "description": "Editor-agnostic Typst compilation service running in a Web Worker",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -18,15 +18,6 @@
18
18
  ".": {
19
19
  "types": "./dist/index.d.ts",
20
20
  "import": "./dist/index.js"
21
- },
22
- "./compiler-worker": {
23
- "import": "./dist/compiler-worker.js"
24
- },
25
- "./analyzer-worker": {
26
- "import": "./dist/analyzer-worker.js"
27
- },
28
- "./renderer-worker": {
29
- "import": "./dist/renderer-worker.js"
30
21
  }
31
22
  },
32
23
  "scripts": {
@@ -34,16 +25,13 @@
34
25
  "dev": "tsup --watch"
35
26
  },
36
27
  "dependencies": {
37
- "@myriaddreamin/typst-ts-renderer": "^0.7.0-rc2",
38
- "@myriaddreamin/typst-ts-web-compiler": "^0.7.0-rc2",
39
- "@myriaddreamin/typst.ts": "^0.7.0-rc2",
40
- "@typstyle/typstyle-wasm-bundler": "^0.14.4",
41
28
  "comlink": "^4.4.2",
42
- "tinymist-web": "https://github.com/Myriad-Dreamin/tinymist/releases/download/v0.14.10/tinymist-web.tar.gz"
29
+ "fflate": "^0.8.2",
30
+ "nanotar": "^0.2.0"
43
31
  },
44
32
  "devDependencies": {
45
- "esbuild": "^0.27.3",
46
33
  "tsup": "^8.0.0",
47
- "typescript": "^5.9.3"
34
+ "typescript": "^5.9.3",
35
+ "typsten": "workspace:*"
48
36
  }
49
37
  }