@vedivad/typst-web-service 0.18.3 → 0.18.5

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/dist/index.d.ts CHANGED
@@ -100,6 +100,18 @@ interface PageInfo {
100
100
  height: number;
101
101
  }
102
102
 
103
+ /**
104
+ * Where a click in the preview should take the user, resolved by Typst from the
105
+ * laid-out frame under the cursor (`typst_ide::jump_from_click`).
106
+ *
107
+ * - `Source`, the click was over text; jump the editor to that 1-based source
108
+ * location (file/line/column, matching `Diagnostic`\'s `Location`).
109
+ * - `Position`, the click was over an internal link (e.g. an `#outline()`
110
+ * entry); scroll the preview to that page and point (in points).
111
+ * - `Url`, the click was over an external link.
112
+ */
113
+ type ClickJump = { kind: "source"; file: string; line: number; column: number } | { kind: "position"; page: number; x: number; y: number } | { kind: "url"; url: string };
114
+
103
115
  /**
104
116
  * Where a diagnostic points, when its span resolves to a real location.
105
117
  *
@@ -115,6 +127,18 @@ interface Location {
115
127
  column: number;
116
128
  }
117
129
 
130
+ /**
131
+ * Where a source cursor renders in the laid-out document, from
132
+ * `typst_ide::jump_from_cursor`: a 0-based `page` and a `point` (in points). The
133
+ * reverse of `ClickJump::Position`, for scrolling the preview to follow the
134
+ * editor cursor.
135
+ */
136
+ interface CursorJump {
137
+ page: number;
138
+ x: number;
139
+ y: number;
140
+ }
141
+
118
142
  /**
119
143
  * Whether a diagnostic is a fatal error or a non-fatal warning.
120
144
  */
@@ -243,6 +267,19 @@ declare class TypstProject {
243
267
  * yet. The bytes are a fresh `Uint8Array` (copied across the worker boundary).
244
268
  */
245
269
  exportPdf(): Promise<Uint8Array | undefined>;
270
+ /**
271
+ * Resolve a click at `(x, y)` points on page `index` of the last compile into
272
+ * where it should take the user: a source location (file/line/column) for a
273
+ * click on text, an internal link target (page + point in points) to scroll to,
274
+ * or a URL. `undefined` if nothing compiled, the page is out of range, or the
275
+ * click hit nothing actionable. Powers click-to-source and clickable links,
276
+ * which the SVG can't express on its own.
277
+ */
278
+ clickJump(index: number, x: number, y: number): Promise<ClickJump | undefined>;
279
+ /** Resolve a CodeMirror `offset` in `path` (with `source` as the live buffer)
280
+ * to where it renders in the last compile: a 0-based page and point (in
281
+ * points), or `undefined` if the cursor maps nowhere. Reverse of `clickJump`. */
282
+ jumpFromCursor(path: Path, source: string, offset: number): Promise<CursorJump | undefined>;
246
283
  /** Completions at a CodeMirror `offset` in `path`, using `source` as the live buffer. */
247
284
  completion(path: Path, source: string, offset: number, explicit?: boolean): Promise<CompletionResponse | undefined>;
248
285
  /** Hover tooltip at a CodeMirror `offset` in `path`, using `source` as the live buffer. */
@@ -266,4 +303,111 @@ declare class TypstProject {
266
303
  destroy(): void;
267
304
  }
268
305
 
269
- export { type AutoCompileOptions, type CompileListener, type CompileResult, type Completion, type CompletionKind, type CompletionResponse, type Diagnostic, type HlSpan, type Hover, type HoverKind, type Location, type PageInfo, type Path, type RenderedSvgPage, type Severity, TypstProject, type TypstProjectCreateOptions, byteToCmOffset, cmOffsetToByte, normalizePath };
306
+ interface PreviewNavigatorOptions {
307
+ /** The project whose `clickJump` resolves clicks, or a thunk returning it.
308
+ * Pass a thunk when the host swaps project instances (e.g. on file change) so
309
+ * the navigator always reads the current one without being re-created. */
310
+ project: TypstProject | (() => TypstProject);
311
+ /** The scroll container holding the rendered pages. Used to scroll to
312
+ * destinations and, unless `listen` is false, to delegate click handling. */
313
+ scroller: HTMLElement;
314
+ /** One element per page, in order: each the page's root `<svg>` or a wrapper
315
+ * containing it. Read live on every event so DOM changes are always reflected.
316
+ * Holes (`null`) mark absent pages. */
317
+ pages: () => ArrayLike<Element | null | undefined>;
318
+ /** Attach a `click` listener on `scroller` that routes clicks through the
319
+ * engine. Set false when the host owns pointer handling (drag/pan/snap) and
320
+ * calls `jumpAt` itself. Default true. */
321
+ listen?: boolean;
322
+ /** A `source` jump: move the editor to `file` at 1-based `line`/`column`. */
323
+ onSource?: (file: string, line: number, column: number) => void;
324
+ /** A `url` jump. Defaults to opening the URL in a new tab. */
325
+ onUrl?: (url: string) => void;
326
+ /** A `position` (internal-link) jump. Defaults to scrolling the destination
327
+ * into view; override to drive your own scroll/highlight. */
328
+ onPosition?: (page: number, yPt: number) => void;
329
+ /** Px above the destination when scrolling to a `position`. */
330
+ margin?: number;
331
+ /** Scroll behavior for the default `position` handler. Default "smooth". */
332
+ behavior?: ScrollBehavior;
333
+ }
334
+ interface PreviewScrollOptions {
335
+ /** Where the target sits in the viewport, like `scrollIntoView`'s `block`:
336
+ * "start" (top, offset by `margin`), "center", or "end" (bottom, less
337
+ * `margin`). Default "start". */
338
+ align?: "start" | "center" | "end";
339
+ /** Override the navigator's default scroll behavior for this call. */
340
+ behavior?: ScrollBehavior;
341
+ }
342
+ /**
343
+ * Drives click-to-jump navigation for a Typst preview without owning rendering
344
+ * or page state. Resolves clicks via `project.clickJump` and routes the result
345
+ * to the editor (`source`), a scroll (`position`), or a URL. `scrollToSource`
346
+ * runs the reverse: editor cursor to preview position.
347
+ *
348
+ * const preview = PreviewNavigator.create({
349
+ * project,
350
+ * scroller,
351
+ * pages: () => scroller.querySelectorAll(".page"),
352
+ * onSource,
353
+ * });
354
+ * // ...
355
+ * preview.dispose();
356
+ */
357
+ declare class PreviewNavigator {
358
+ private readonly opts;
359
+ private readonly onClick?;
360
+ private constructor();
361
+ /** Create a preview view bound to `project` and `scroller`. */
362
+ static create(opts: PreviewNavigatorOptions): PreviewNavigator;
363
+ /** The 0-based page under a viewport point and the point in that page's own
364
+ * coordinates (the SVG viewBox unit, what `clickJump` expects), or null when
365
+ * the point is over no page. */
366
+ pointToPage(clientX: number, clientY: number): {
367
+ page: number;
368
+ x: number;
369
+ y: number;
370
+ } | null;
371
+ /** Resolve a viewport point through the engine and route the resulting jump
372
+ * (`source` to the editor, `position` to a scroll, `url` to open). No-op when
373
+ * the point is over no page or the engine finds nothing actionable. */
374
+ jumpAt(clientX: number, clientY: number): Promise<void>;
375
+ /** Resolve a CodeMirror `offset` in `path` (with `source` as the live buffer)
376
+ * to where it renders and scroll there. Returns the position for a highlight,
377
+ * or null if the cursor maps nowhere. Reverse of `jumpAt`. */
378
+ scrollToSource(path: Path, source: string, offset: number, opts?: PreviewScrollOptions): Promise<CursorJump | null>;
379
+ /** The current project, resolving the thunk form of `opts.project`. */
380
+ private currentProject;
381
+ /** Scroll `yPt` points down page `page` to `opts.align` in the viewport
382
+ * (default "start", offset by `margin`). Default handler for a `position` jump. */
383
+ scrollToPosition(page: number, yPt: number, opts?: PreviewScrollOptions): void;
384
+ /** Detach the click listener, if one was attached. */
385
+ dispose(): void;
386
+ }
387
+
388
+ /** The subset of `DOMRect` these helpers read. `el.getBoundingClientRect()`
389
+ * satisfies it at runtime; a plain object works in tests. */
390
+ interface Rect {
391
+ left: number;
392
+ top: number;
393
+ width: number;
394
+ }
395
+ /** CSS pixels per typst point for a page rendered `renderedWidthPx` wide,
396
+ * where `pageWidthPt` is `RenderedSvgPage.width`. Falls back to 1 for zero-width pages. */
397
+ declare function pageScale(renderedWidthPx: number, pageWidthPt: number): number;
398
+ /** Rendered height in CSS px of a page laid out `renderedWidthPx` wide,
399
+ * from its point dimensions. Used for fit-to-height and visibility checks. */
400
+ declare function pageRenderedHeight(pageWidthPt: number, pageHeightPt: number, renderedWidthPx: number): number;
401
+ /** Maps a viewport point to page point coordinates given the page's
402
+ * on-screen rect and `RenderedSvgPage.width`. Inverse of SVG layout,
403
+ * e.g. to pass a click to `clickJump`. */
404
+ declare function clientToPagePoint(pageRect: Rect, pageWidthPt: number, clientX: number, clientY: number): {
405
+ x: number;
406
+ y: number;
407
+ };
408
+ /** Returns the `scrollTop` that places `yPt` points from a page's top at
409
+ * `margin` px below the scroller's top edge. Pass page and scroller
410
+ * `getBoundingClientRect()`s and the scroller's current `scrollTop`. */
411
+ declare function scrollTopForPageY(pageRect: Rect, scrollerRect: Rect, scrollerScrollTop: number, pageWidthPt: number, yPt: number, margin?: number): number;
412
+
413
+ export { type AutoCompileOptions, type ClickJump, type CompileListener, type CompileResult, type Completion, type CompletionKind, type CompletionResponse, type CursorJump, type Diagnostic, type HlSpan, type Hover, type HoverKind, type Location, type PageInfo, type Path, PreviewNavigator, type PreviewNavigatorOptions, type PreviewScrollOptions, type Rect, type RenderedSvgPage, type Severity, TypstProject, type TypstProjectCreateOptions, byteToCmOffset, clientToPagePoint, cmOffsetToByte, normalizePath, pageRenderedHeight, pageScale, scrollTopForPageY };
package/dist/index.js CHANGED
@@ -67,6 +67,144 @@ function normalizePath(path) {
67
67
  return path.startsWith("/") ? path : `/${path}`;
68
68
  }
69
69
 
70
+ // src/preview.ts
71
+ function pageScale(renderedWidthPx, pageWidthPt) {
72
+ return pageWidthPt > 0 ? renderedWidthPx / pageWidthPt : 1;
73
+ }
74
+ function pageRenderedHeight(pageWidthPt, pageHeightPt, renderedWidthPx) {
75
+ return pageWidthPt > 0 ? renderedWidthPx * pageHeightPt / pageWidthPt : 0;
76
+ }
77
+ function clientToPagePoint(pageRect, pageWidthPt, clientX, clientY) {
78
+ const scale = pageScale(pageRect.width, pageWidthPt);
79
+ return {
80
+ x: (clientX - pageRect.left) / scale,
81
+ y: (clientY - pageRect.top) / scale
82
+ };
83
+ }
84
+ function scrollTopForPageY(pageRect, scrollerRect, scrollerScrollTop, pageWidthPt, yPt, margin = 0) {
85
+ const scale = pageScale(pageRect.width, pageWidthPt);
86
+ return scrollerScrollTop + (pageRect.top - scrollerRect.top) + yPt * scale - margin;
87
+ }
88
+
89
+ // src/preview-navigator.ts
90
+ var PreviewNavigator = class _PreviewNavigator {
91
+ constructor(opts) {
92
+ this.opts = opts;
93
+ if (opts.listen !== false) {
94
+ this.onClick = (e) => {
95
+ e.preventDefault();
96
+ void this.jumpAt(e.clientX, e.clientY);
97
+ };
98
+ opts.scroller.addEventListener("click", this.onClick);
99
+ }
100
+ }
101
+ onClick;
102
+ /** Create a preview view bound to `project` and `scroller`. */
103
+ static create(opts) {
104
+ return new _PreviewNavigator(opts);
105
+ }
106
+ /** The 0-based page under a viewport point and the point in that page's own
107
+ * coordinates (the SVG viewBox unit, what `clickJump` expects), or null when
108
+ * the point is over no page. */
109
+ pointToPage(clientX, clientY) {
110
+ const pages = this.opts.pages();
111
+ for (let page = 0; page < pages.length; page++) {
112
+ const svg = rootSvg(pages[page]);
113
+ if (!svg) continue;
114
+ const rect = svg.getBoundingClientRect();
115
+ if (clientX < rect.left || clientX > rect.right || clientY < rect.top || clientY > rect.bottom) {
116
+ continue;
117
+ }
118
+ const { x, y } = clientToPagePoint(
119
+ rect,
120
+ svg.viewBox.baseVal.width,
121
+ clientX,
122
+ clientY
123
+ );
124
+ return { page, x, y };
125
+ }
126
+ return null;
127
+ }
128
+ /** Resolve a viewport point through the engine and route the resulting jump
129
+ * (`source` to the editor, `position` to a scroll, `url` to open). No-op when
130
+ * the point is over no page or the engine finds nothing actionable. */
131
+ async jumpAt(clientX, clientY) {
132
+ const hit = this.pointToPage(clientX, clientY);
133
+ if (!hit) return;
134
+ let jump;
135
+ try {
136
+ jump = await this.currentProject().clickJump(hit.page, hit.x, hit.y);
137
+ } catch (err) {
138
+ console.error("[typst] clickJump failed:", err);
139
+ return;
140
+ }
141
+ if (!jump) return;
142
+ if (jump.kind === "source") {
143
+ this.opts.onSource?.(jump.file, jump.line, jump.column);
144
+ } else if (jump.kind === "url") {
145
+ (this.opts.onUrl ?? openInNewTab)(jump.url);
146
+ } else if (this.opts.onPosition) {
147
+ this.opts.onPosition(jump.page, jump.y);
148
+ } else {
149
+ this.scrollToPosition(jump.page, jump.y);
150
+ }
151
+ }
152
+ /** Resolve a CodeMirror `offset` in `path` (with `source` as the live buffer)
153
+ * to where it renders and scroll there. Returns the position for a highlight,
154
+ * or null if the cursor maps nowhere. Reverse of `jumpAt`. */
155
+ async scrollToSource(path, source, offset, opts = {}) {
156
+ let pos;
157
+ try {
158
+ pos = await this.currentProject().jumpFromCursor(path, source, offset);
159
+ } catch (err) {
160
+ console.error("[typst] jumpFromCursor failed:", err);
161
+ return null;
162
+ }
163
+ if (!pos) return null;
164
+ this.scrollToPosition(pos.page, pos.y, opts);
165
+ return pos;
166
+ }
167
+ /** The current project, resolving the thunk form of `opts.project`. */
168
+ currentProject() {
169
+ const { project } = this.opts;
170
+ return typeof project === "function" ? project() : project;
171
+ }
172
+ /** Scroll `yPt` points down page `page` to `opts.align` in the viewport
173
+ * (default "start", offset by `margin`). Default handler for a `position` jump. */
174
+ scrollToPosition(page, yPt, opts = {}) {
175
+ const svg = rootSvg(this.opts.pages()[page]);
176
+ if (!svg) return;
177
+ const { scroller } = this.opts;
178
+ const margin = this.opts.margin ?? 0;
179
+ const height = scroller.clientHeight;
180
+ const offsetFromTop = opts.align === "center" ? height / 2 : opts.align === "end" ? height - margin : margin;
181
+ scroller.scrollTo({
182
+ top: scrollTopForPageY(
183
+ svg.getBoundingClientRect(),
184
+ scroller.getBoundingClientRect(),
185
+ scroller.scrollTop,
186
+ svg.viewBox.baseVal.width,
187
+ yPt,
188
+ offsetFromTop
189
+ ),
190
+ behavior: opts.behavior ?? this.opts.behavior ?? "smooth"
191
+ });
192
+ }
193
+ /** Detach the click listener, if one was attached. */
194
+ dispose() {
195
+ if (this.onClick) {
196
+ this.opts.scroller.removeEventListener("click", this.onClick);
197
+ }
198
+ }
199
+ };
200
+ function rootSvg(el) {
201
+ if (!el) return null;
202
+ return el instanceof SVGSVGElement ? el : el.querySelector("svg");
203
+ }
204
+ function openInNewTab(url) {
205
+ window.open(url, "_blank", "noopener,noreferrer");
206
+ }
207
+
70
208
  // src/project.ts
71
209
  import * as Comlink from "comlink";
72
210
 
@@ -423,6 +561,25 @@ var TypstProject = class _TypstProject {
423
561
  exportPdf() {
424
562
  return this.engine.exportPdf();
425
563
  }
564
+ /**
565
+ * Resolve a click at `(x, y)` points on page `index` of the last compile into
566
+ * where it should take the user: a source location (file/line/column) for a
567
+ * click on text, an internal link target (page + point in points) to scroll to,
568
+ * or a URL. `undefined` if nothing compiled, the page is out of range, or the
569
+ * click hit nothing actionable. Powers click-to-source and clickable links,
570
+ * which the SVG can't express on its own.
571
+ */
572
+ clickJump(index, x, y) {
573
+ return this.engine.clickJump(index, x, y);
574
+ }
575
+ /** Resolve a CodeMirror `offset` in `path` (with `source` as the live buffer)
576
+ * to where it renders in the last compile: a 0-based page and point (in
577
+ * points), or `undefined` if the cursor maps nowhere. Reverse of `clickJump`. */
578
+ async jumpFromCursor(path, source, offset) {
579
+ const p = normalizePath(path);
580
+ await this.writeText(p, source);
581
+ return this.engine.jumpFromCursor(p, cmOffsetToByte(source, offset));
582
+ }
426
583
  /** Completions at a CodeMirror `offset` in `path`, using `source` as the live buffer. */
427
584
  async completion(path, source, offset, explicit = false) {
428
585
  const p = normalizePath(path);
@@ -482,9 +639,14 @@ var TypstProject = class _TypstProject {
482
639
  }
483
640
  };
484
641
  export {
642
+ PreviewNavigator,
485
643
  TypstProject,
486
644
  byteToCmOffset,
645
+ clientToPagePoint,
487
646
  cmOffsetToByte,
488
- normalizePath
647
+ normalizePath,
648
+ pageRenderedHeight,
649
+ pageScale,
650
+ scrollTopForPageY
489
651
  };
490
652
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/coords.ts","../src/identifiers.ts","../src/project.ts","../src/compile-scheduler.ts","../src/packages.ts"],"sourcesContent":["// typsten speaks UTF-8 byte offsets; CodeMirror/JS strings speak UTF-16 code\n// units. These convert between the two at code-point boundaries (where all\n// engine offsets land).\n\nconst encoder = new TextEncoder();\nconst decoder = new TextDecoder();\n\n/** UTF-16 string offset (CodeMirror position) -> UTF-8 byte offset (typsten). */\nexport function cmOffsetToByte(text: string, offset: number): number {\n return encoder.encode(text.slice(0, offset)).length;\n}\n\n/** UTF-8 byte offset (typsten) -> UTF-16 string offset (CodeMirror position). */\nexport function byteToCmOffset(text: string, byte: number): number {\n if (byte <= 0) return 0;\n const bytes = encoder.encode(text);\n if (byte >= bytes.length) return text.length;\n return decoder.decode(bytes.subarray(0, byte)).length;\n}\n\n/** Whether `text` has any non-ASCII code unit (byte offset != UTF-16 offset). */\nfunction hasNonAscii(text: string): boolean {\n for (let i = 0; i < text.length; i++) {\n if (text.charCodeAt(i) > 0x7f) return true;\n }\n return false;\n}\n\n/** UTF-8 length in bytes of a Unicode code point. */\nfunction utf8Len(codePoint: number): number {\n if (codePoint < 0x80) return 1;\n if (codePoint < 0x800) return 2;\n if (codePoint < 0x10000) return 3;\n return 4;\n}\n\n/**\n * Map a batch of offsets from one coordinate space to the other in a single pass\n * over `text`, walking both running positions (`key` = input space, `val` =\n * output space) one code point at a time. `keyStep`/`valStep` give each space's\n * advance per code point. Input may be in any order (nested highlight spans\n * produce non-monotonic boundaries); the result is aligned with the input, and\n * offsets past the end clamp to the output length. Pure-ASCII text (where the\n * two spaces coincide) short-circuits to identity.\n */\nfunction mapOffsets(\n text: string,\n offsets: number[],\n keyStep: (codePoint: number, ch: string) => number,\n valStep: (codePoint: number, ch: string) => number,\n): number[] {\n if (offsets.length === 0 || !hasNonAscii(text)) return offsets;\n\n // Walk in ascending input order, but remember each offset's original slot.\n const order = offsets.map((offset, i) => [offset, i] as const);\n order.sort((a, b) => a[0] - b[0]);\n\n const out = new Array<number>(offsets.length);\n let key = 0;\n let val = 0;\n let next = 0;\n const flush = () => {\n while (next < order.length && order[next][0] <= key)\n out[order[next++][1]] = val;\n };\n flush(); // offsets at position 0\n for (const ch of text) {\n if (next >= order.length) break;\n const cp = ch.codePointAt(0)!;\n key += keyStep(cp, ch);\n val += valStep(cp, ch);\n flush();\n }\n // Past the end: the loop ran to completion, so `val` is the full output length.\n while (next < order.length) out[order[next++][1]] = val;\n return out;\n}\n\n/**\n * Convert a batch of UTF-8 byte offsets to UTF-16 (CodeMirror) offsets in one\n * pass. Unlike `byteToCmOffset` (which re-encodes a prefix per call, so N\n * offsets cost O(N * len)), this is O(len + N log N). Used to map highlight span\n * boundaries back to editor coordinates.\n */\nexport function byteOffsetsToCm(text: string, offsets: number[]): number[] {\n return mapOffsets(\n text,\n offsets,\n (cp) => utf8Len(cp),\n (_cp, ch) => ch.length,\n );\n}\n\n/**\n * Convert a batch of UTF-16 (CodeMirror) offsets to UTF-8 byte offsets in one\n * pass. The batched, ASCII-fast-path counterpart to `cmOffsetToByte` (which\n * re-encodes a prefix per call). Used for the highlight viewport bounds.\n */\nexport function cmOffsetsToByte(text: string, offsets: number[]): number[] {\n return mapOffsets(\n text,\n offsets,\n (_cp, ch) => ch.length,\n (cp) => utf8Len(cp),\n );\n}\n","/**\n * Project file paths. `/main.typ` form, leading slash, forward slashes only.\n * `@preview/...` package paths bypass this (they are pushed to the VFS verbatim).\n */\n\n/** `/path/to/file.typ`, leading-slash, forward slashes only. */\nexport type Path = string;\n\n/** Ensure a path starts with a leading slash. Idempotent. */\nexport function normalizePath(path: string): Path {\n return path.startsWith(\"/\") ? path : `/${path}`;\n}\n","import * as Comlink from \"comlink\";\nimport type { Remote } from \"comlink\";\nimport { CompileScheduler } from \"./compile-scheduler.js\";\nimport { byteOffsetsToCm, cmOffsetsToByte, cmOffsetToByte } from \"./coords.js\";\nimport { normalizePath, type Path } from \"./identifiers.js\";\nimport { createPackageLoader, type PackageLoader } from \"./packages.js\";\nimport type {\n CompileResult,\n CompletionResponse,\n HlSpan,\n Hover,\n RenderedSvgPage,\n} from \"./types.js\";\nimport type { TypstenWorkerApi } from \"./typsten-worker.js\";\n\nexport interface TypstProjectCreateOptions {\n /** Default entry file path. Default: \"/main.typ\". */\n entry?: string;\n /** Auto-compile scheduling after VFS mutations. */\n autoCompile?: AutoCompileOptions;\n}\n\nexport interface AutoCompileOptions {\n /** Idle time (ms) after the last mutation before a compile fires. Default: 0. */\n debounceMs?: number;\n /** Max time (ms) the debounce may defer during sustained edits. Default: 0. */\n maxWaitMs?: number;\n}\n\nexport type CompileListener = (result: CompileResult) => void;\n\nconst DEFAULT_ENTRY = \"/main.typ\";\nconst encoder = new TextEncoder();\n\nfunction errorAsCompileResult(err: unknown): CompileResult {\n const message = err instanceof Error ? err.message : String(err);\n return {\n pages: [],\n diagnostics: [\n { severity: \"error\", message, hints: [], location: undefined },\n ],\n };\n}\n\nfunction toBytes(content: ArrayBuffer | ArrayBufferView): Uint8Array {\n if (content instanceof Uint8Array) return content;\n if (ArrayBuffer.isView(content)) {\n return new Uint8Array(\n content.buffer,\n content.byteOffset,\n content.byteLength,\n );\n }\n return new Uint8Array(content);\n}\n\n/**\n * Multi-file Typst project backed by a single typsten wasm worker. Owns the\n * VFS; editors push `setText` edits as the user types; the project mirrors them\n * to the worker, fetches `@preview` packages on demand, and compiles or renders\n * against the current state.\n *\n * const project = await TypstProject.create();\n * await project.setMany({ \"/main.typ\": \"...\" });\n * const { pages } = await project.compile();\n * const svg = await project.renderPage(0);\n */\nexport class TypstProject {\n /**\n * Tracked project files: the text content for a text file, or `null` for a\n * binary one. Drives dedup, `getText`, `files`, and `clear`. (Cached `@preview`\n * package files live only in the worker VFS, never here.)\n */\n private readonly tracked = new Map<Path, string | null>();\n private readonly compileListeners = new Set<CompileListener>();\n private readonly scheduler: CompileScheduler;\n private readonly packageLoader: PackageLoader;\n private compileVersion = 0;\n private _lastResult: CompileResult | undefined;\n private _entry: Path;\n private destroyed = false;\n\n private constructor(\n private readonly engine: Remote<TypstenWorkerApi>,\n private readonly worker: Worker,\n options: TypstProjectCreateOptions,\n ) {\n this._entry = normalizePath(options.entry ?? DEFAULT_ENTRY);\n this.scheduler = new CompileScheduler({\n debounceMs: options.autoCompile?.debounceMs,\n maxWaitMs: options.autoCompile?.maxWaitMs,\n });\n this.packageLoader = createPackageLoader((path, bytes) =>\n this.engine.setFile(path, bytes),\n );\n }\n\n /** Create a project: spin up the worker, init the wasm, set the entry. */\n static async create(\n options: TypstProjectCreateOptions = {},\n ): Promise<TypstProject> {\n const worker = new Worker(new URL(\"./typsten-worker.js\", import.meta.url), {\n type: \"module\",\n });\n const engine = Comlink.wrap<TypstenWorkerApi>(worker);\n\n const wasmUrl = new URL(\"./typsten_bg.wasm\", import.meta.url).href;\n await engine.init(wasmUrl);\n\n const project = new TypstProject(engine, worker, options);\n await engine.setEntry(project._entry);\n\n return project;\n }\n\n private scheduleCompile(): void {\n if (this.destroyed) return;\n this.scheduler.schedule(() => {\n this.compile().catch((err) => console.error(\"[typst]\", err));\n });\n }\n\n /**\n * Mirror text into the VFS without scheduling a compile. Returns the in-flight\n * write to await, or `null` if the content is unchanged (deduped to a no-op).\n */\n private writeText(p: Path, content: string): Promise<unknown> | null {\n if (this.tracked.get(p) === content) return null;\n this.tracked.set(p, content);\n return this.engine.setFile(p, encoder.encode(content));\n }\n\n /** Mirror binary bytes into the VFS (always writes; binaries are not deduped). */\n private writeBinary(p: Path, bytes: Uint8Array): Promise<unknown> {\n this.tracked.set(p, null);\n return this.engine.setFile(p, bytes);\n }\n\n get entry(): Path {\n return this._entry;\n }\n\n set entry(path: Path) {\n const next = normalizePath(path);\n if (next === this._entry) return;\n this._entry = next;\n void this.engine.setEntry(next);\n this.scheduleCompile();\n }\n\n /** Most recent compile result, or `undefined` before the first compile. */\n get lastResult(): CompileResult | undefined {\n return this._lastResult;\n }\n\n /** Tracked text file paths, in insertion order (fresh array). */\n get files(): Path[] {\n return [...this.tracked]\n .filter(([, content]) => content !== null)\n .map(([path]) => path);\n }\n\n /** Current text for a tracked file, or `undefined` (binary or absent). */\n getText(path: Path): string | undefined {\n return this.tracked.get(normalizePath(path)) ?? undefined;\n }\n\n /** Add or overwrite a text file. No-op if unchanged. */\n async setText(path: Path, content: string): Promise<void> {\n const write = this.writeText(normalizePath(path), content);\n if (write) {\n await write;\n this.scheduleCompile();\n }\n }\n\n /** Add or overwrite a binary file (retires any text tracking for the path). */\n async setBinary(\n path: Path,\n content: ArrayBuffer | ArrayBufferView,\n ): Promise<void> {\n await this.writeBinary(normalizePath(path), toBytes(content));\n this.scheduleCompile();\n }\n\n /** Batch set files. Strings dedup against tracked content; binaries always write. */\n async setMany(files: Record<Path, string | Uint8Array>): Promise<void> {\n const writes: Promise<unknown>[] = [];\n for (const [path, content] of Object.entries(files)) {\n const p = normalizePath(path);\n const write =\n typeof content === \"string\"\n ? this.writeText(p, content)\n : this.writeBinary(p, content);\n if (write) writes.push(write);\n }\n if (writes.length === 0) return;\n await Promise.all(writes);\n this.scheduleCompile();\n }\n\n /** Remove a file from the VFS. */\n async remove(path: Path): Promise<void> {\n const p = normalizePath(path);\n await this.engine.remove(p);\n this.tracked.delete(p);\n this.scheduleCompile();\n }\n\n /** Remove all tracked project files (cached `@preview` packages are kept). */\n async clear(): Promise<void> {\n await Promise.all(\n [...this.tracked.keys()].map((p) => this.engine.remove(p)),\n );\n this.tracked.clear();\n this.scheduleCompile();\n }\n\n /**\n * Register a font (TTF/OTF, or TTC collection bytes) so compilation can use\n * it, then recompile. The engine bundles default body, math, and monospace\n * fonts; use this to add families it does not ship (e.g. CJK or a custom\n * font). Fonts persist for the project's lifetime.\n *\n * Returns the canonical family name of each added face, the name Typst\n * groups and matches by (width/weight/style folded into the variant, so e.g.\n * \"Roboto Condensed\" reports as \"Roboto\"). Use it to label the font the way\n * `#set text(font: ...)` expects, instead of parsing the name table yourself.\n */\n async addFont(bytes: Uint8Array): Promise<string[]> {\n const families = await this.engine.addFont(bytes);\n this.scheduleCompile();\n return families;\n }\n\n /**\n * Drop every font added via `addFont`, resetting to the embedded defaults,\n * then recompile. The engine has no per-font removal, so to remove a font,\n * call this and re-`addFont` the ones to keep.\n */\n async clearFonts(): Promise<void> {\n await this.engine.clearFonts();\n this.scheduleCompile();\n }\n\n /**\n * Subscribe to compile results. Late subscribers get `lastResult` synchronously.\n * Returns an unsubscribe function.\n */\n onCompile(listener: CompileListener): () => void {\n this.compileListeners.add(listener);\n if (this._lastResult !== undefined) {\n try {\n listener(this._lastResult);\n } catch (err) {\n console.error(\"[typst] compile listener threw:\", err);\n }\n }\n return () => {\n this.compileListeners.delete(listener);\n };\n }\n\n /**\n * Compile the current VFS state. Fetches any referenced `@preview` packages\n * first. Errors become a synthetic diagnostic. Listeners fire only for the\n * most recent compile (stale results are dropped).\n */\n async compile(): Promise<CompileResult> {\n this.scheduler.cancel();\n const version = ++this.compileVersion;\n let result: CompileResult;\n try {\n await this.packageLoader.ensure(\n [...this.tracked.values()].filter((v): v is string => v !== null),\n );\n result = await this.engine.compile();\n } catch (err) {\n result = errorAsCompileResult(err);\n }\n if (version === this.compileVersion) {\n this._lastResult = result;\n for (const listener of this.compileListeners) {\n try {\n listener(result);\n } catch (err) {\n console.error(\"[typst] compile listener threw:\", err);\n }\n }\n }\n return result;\n }\n\n /** Render a single page of the last compile to SVG, or `undefined`. */\n renderPage(index: number): Promise<string | undefined> {\n return this.engine.renderPage(index);\n }\n\n /**\n * Render pages `[start, end)` as `RenderedSvgPage`s (index + dims + svg),\n * zipping the SVG strings with the page metadata from the last compile.\n */\n async renderedPages(start: number, end: number): Promise<RenderedSvgPage[]> {\n const pages = this._lastResult?.pages ?? [];\n const svgs = await this.engine.renderPages(start, end);\n return svgs.map((svg, i) => {\n const index = start + i;\n const dims = pages[index];\n return {\n index,\n width: dims?.width ?? 0,\n height: dims?.height ?? 0,\n svg,\n };\n });\n }\n\n /**\n * Export the last compile as a PDF, or `undefined` if nothing has compiled\n * yet. The bytes are a fresh `Uint8Array` (copied across the worker boundary).\n */\n exportPdf(): Promise<Uint8Array | undefined> {\n return this.engine.exportPdf();\n }\n\n /** Completions at a CodeMirror `offset` in `path`, using `source` as the live buffer. */\n async completion(\n path: Path,\n source: string,\n offset: number,\n explicit = false,\n ): Promise<CompletionResponse | undefined> {\n const p = normalizePath(path);\n await this.writeText(p, source);\n return this.engine.complete(p, cmOffsetToByte(source, offset), explicit);\n }\n\n /** Hover tooltip at a CodeMirror `offset` in `path`, using `source` as the live buffer. */\n async hover(\n path: Path,\n source: string,\n offset: number,\n ): Promise<Hover | undefined> {\n const p = normalizePath(path);\n await this.writeText(p, source);\n return this.engine.hover(p, cmOffsetToByte(source, offset));\n }\n\n /** Format `source` (the live buffer for `path`); returns the formatted text or `undefined`. */\n async format(path: Path, source: string): Promise<string | undefined> {\n const p = normalizePath(path);\n await this.writeText(p, source);\n return this.engine.format(p);\n }\n\n /**\n * Syntax-highlight `source` over the CodeMirror window `[from, to)` (UTF-16\n * offsets; defaults to the whole string). Returns spans whose `from`/`to` are\n * CodeMirror offsets, ready to drive decorations. Stateless: the worker parses\n * `source` directly via typst-syntax, so this neither reads nor mutates the\n * VFS and works for any text (the live buffer, a hover code snippet).\n */\n async highlight(\n source: string,\n from = 0,\n to = source.length,\n ): Promise<HlSpan[]> {\n const [byteFrom, byteTo] = cmOffsetsToByte(source, [from, to]);\n const spans = await this.engine.highlight(source, byteFrom, byteTo);\n if (spans.length === 0) return spans;\n // The worker speaks UTF-8 bytes; map every span boundary back to UTF-16\n // (CodeMirror) offsets in one pass over the source. Boundaries are not\n // monotonic (nested spans wrap inner ones), so byteOffsetsToCm sorts them.\n const cm = byteOffsetsToCm(\n source,\n spans.flatMap((s) => [s.from, s.to]),\n );\n return spans.map((s, i) => ({\n from: cm[i * 2],\n to: cm[i * 2 + 1],\n tag: s.tag,\n }));\n }\n\n /**\n * Syntax-highlight `source` to nested `<span class=\"typ-*\">` HTML for a static\n * context (e.g. a hover tooltip). Stateless, like `highlight`.\n */\n highlightHtml(source: string): Promise<string> {\n return this.engine.highlightHtml(source);\n }\n\n /** Tear down the worker and drop all state. Idempotent. */\n destroy(): void {\n if (this.destroyed) return;\n this.destroyed = true;\n this.scheduler.cancel();\n this.compileListeners.clear();\n this.tracked.clear();\n this._lastResult = undefined;\n this.engine[Comlink.releaseProxy]();\n this.worker.terminate();\n }\n}\n","interface CompileSchedulerOptions {\n /** Minimum idle time (ms) after the last request before firing. Default: 0. */\n debounceMs?: number;\n /**\n * Maximum time (ms) the debounce may keep deferring during continuous\n * requests. Guarantees a fire at least this often so users see progress\n * while typing. Default: 0 (no cap).\n */\n maxWaitMs?: number;\n}\n\n/**\n * Debounce helper with a max-wait ceiling for coalescing compile requests. A\n * burst of `schedule(cb)` calls within `debounceMs` collapses into one fire;\n * during sustained bursts, `maxWaitMs` caps how long the debounce may keep\n * deferring.\n */\nexport class CompileScheduler {\n private debounceTimer: ReturnType<typeof setTimeout> | null = null;\n private maxWaitTimer: ReturnType<typeof setTimeout> | null = null;\n\n constructor(private readonly options: CompileSchedulerOptions = {}) {}\n\n schedule(callback: () => void): void {\n if (this.debounceTimer) {\n clearTimeout(this.debounceTimer);\n this.debounceTimer = null;\n }\n\n const delay = Math.max(0, this.options.debounceMs ?? 0);\n this.debounceTimer = setTimeout(() => {\n this.debounceTimer = null;\n this.clearMaxWait();\n callback();\n }, delay);\n\n const maxWait = this.options.maxWaitMs;\n if (maxWait != null && maxWait > 0 && !this.maxWaitTimer) {\n this.maxWaitTimer = setTimeout(() => {\n this.maxWaitTimer = null;\n if (this.debounceTimer) {\n clearTimeout(this.debounceTimer);\n this.debounceTimer = null;\n callback();\n }\n }, maxWait);\n }\n }\n\n /** Cancel any pending scheduled fire without calling the callback. */\n cancel(): void {\n if (this.debounceTimer) {\n clearTimeout(this.debounceTimer);\n this.debounceTimer = null;\n }\n this.clearMaxWait();\n }\n\n private clearMaxWait(): void {\n if (this.maxWaitTimer) {\n clearTimeout(this.maxWaitTimer);\n this.maxWaitTimer = null;\n }\n }\n}\n","// typsten resolves `@preview` packages from its in-memory VFS but does no I/O.\n// This is the JS side: scan sources for `@preview` imports, fetch the tarball\n// from the registry, unpack it, and push every member into the VFS. A package's\n// own sources may import further `@preview` packages, so after unpacking we scan\n// the fetched `.typ` files and follow those transitive imports to a fixed point.\n// (The eager import-scanner approach; a lazy JSPI fetch is a future typsten\n// milestone that would let the engine drive resolution instead.)\nimport { gunzipSync } from \"fflate\";\nimport { parseTar } from \"nanotar\";\n\nconst REGISTRY = \"https://packages.typst.org/preview\";\nconst PREVIEW_IMPORT = /@preview\\/([a-zA-Z0-9_-]+):(\\d+\\.\\d+\\.\\d+)/g;\n\nexport type SetFile = (path: string, bytes: Uint8Array) => Promise<void> | void;\n\nexport interface PackageLoader {\n /**\n * Ensure every `@preview` package referenced in `sources`, and transitively\n * by the packages they pull in, is present in the VFS, fetching any missing.\n */\n ensure(sources: Iterable<string>): Promise<void>;\n}\n\n/** Collect the `name:version` spec of every `@preview` import in `text`. */\nfunction specsIn(text: string): string[] {\n const specs: string[] = [];\n for (const m of text.matchAll(PREVIEW_IMPORT)) specs.push(`${m[1]}:${m[2]}`);\n return specs;\n}\n\nexport function createPackageLoader(setFile: SetFile): PackageLoader {\n const decoder = new TextDecoder();\n // spec (\"name:version\") -> the transitive specs found inside that package.\n // Doubles as the fetch cache: a settled entry means the package is resident.\n const fetched = new Map<string, Promise<string[]>>();\n\n async function fetchPackage(spec: string): Promise<string[]> {\n const [name, version] = spec.split(\":\");\n const qualified = `@preview/${spec}`;\n const res = await fetch(`${REGISTRY}/${name}-${version}.tar.gz`);\n if (!res.ok) {\n throw new Error(\n `failed to fetch ${qualified}: ${res.status} ${res.statusText}`,\n );\n }\n const tar = gunzipSync(new Uint8Array(await res.arrayBuffer()));\n const nested = new Set<string>();\n for (const entry of parseTar(tar)) {\n // Skip directories and anything without bytes.\n if (!entry.data || entry.name.endsWith(\"/\")) continue;\n await setFile(`${qualified}/${entry.name}`, entry.data);\n // A package's own `.typ` sources may import further `@preview` packages.\n if (entry.name.endsWith(\".typ\")) {\n for (const s of specsIn(decoder.decode(entry.data))) nested.add(s);\n }\n }\n return [...nested];\n }\n\n function fetchOnce(spec: string): Promise<string[]> {\n let task = fetched.get(spec);\n if (!task) {\n task = fetchPackage(spec).catch((err: unknown) => {\n // Drop failed fetches so a later compile can retry (transient network).\n fetched.delete(spec);\n throw err;\n });\n fetched.set(spec, task);\n }\n return task;\n }\n\n return {\n async ensure(sources) {\n const seen = new Set<string>();\n let frontier = new Set<string>();\n for (const text of sources) {\n for (const s of specsIn(text)) frontier.add(s);\n }\n // Breadth-first fetch to a fixed point; each package can reveal more.\n while (frontier.size > 0) {\n const batch = [...frontier].filter((s) => !seen.has(s));\n for (const s of batch) seen.add(s);\n frontier = new Set();\n const nestedLists = await Promise.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,MAAM,WAAW,EAAG,QAAO;AAI/B,UAAM,KAAK;AAAA,MACT;AAAA,MACA,MAAM,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC;AAAA,IACrC;AACA,WAAO,MAAM,IAAI,CAAC,GAAG,OAAO;AAAA,MAC1B,MAAM,GAAG,IAAI,CAAC;AAAA,MACd,IAAI,GAAG,IAAI,IAAI,CAAC;AAAA,MAChB,KAAK,EAAE;AAAA,IACT,EAAE;AAAA,EACJ;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,cAAc,QAAiC;AAC7C,WAAO,KAAK,OAAO,cAAc,MAAM;AAAA,EACzC;AAAA;AAAA,EAGA,UAAgB;AACd,QAAI,KAAK,UAAW;AACpB,SAAK,YAAY;AACjB,SAAK,UAAU,OAAO;AACtB,SAAK,iBAAiB,MAAM;AAC5B,SAAK,QAAQ,MAAM;AACnB,SAAK,cAAc;AACnB,SAAK,OAAe,oBAAY,EAAE;AAClC,SAAK,OAAO,UAAU;AAAA,EACxB;AACF;","names":["decoder","encoder"]}
1
+ {"version":3,"sources":["../src/coords.ts","../src/identifiers.ts","../src/preview.ts","../src/preview-navigator.ts","../src/project.ts","../src/compile-scheduler.ts","../src/packages.ts"],"sourcesContent":["// typsten speaks UTF-8 byte offsets; CodeMirror/JS strings speak UTF-16 code\n// units. These convert between the two at code-point boundaries (where all\n// engine offsets land).\n\nconst encoder = new TextEncoder();\nconst decoder = new TextDecoder();\n\n/** UTF-16 string offset (CodeMirror position) -> UTF-8 byte offset (typsten). */\nexport function cmOffsetToByte(text: string, offset: number): number {\n return encoder.encode(text.slice(0, offset)).length;\n}\n\n/** UTF-8 byte offset (typsten) -> UTF-16 string offset (CodeMirror position). */\nexport function byteToCmOffset(text: string, byte: number): number {\n if (byte <= 0) return 0;\n const bytes = encoder.encode(text);\n if (byte >= bytes.length) return text.length;\n return decoder.decode(bytes.subarray(0, byte)).length;\n}\n\n/** Whether `text` has any non-ASCII code unit (byte offset != UTF-16 offset). */\nfunction hasNonAscii(text: string): boolean {\n for (let i = 0; i < text.length; i++) {\n if (text.charCodeAt(i) > 0x7f) return true;\n }\n return false;\n}\n\n/** UTF-8 length in bytes of a Unicode code point. */\nfunction utf8Len(codePoint: number): number {\n if (codePoint < 0x80) return 1;\n if (codePoint < 0x800) return 2;\n if (codePoint < 0x10000) return 3;\n return 4;\n}\n\n/**\n * Map a batch of offsets from one coordinate space to the other in a single pass\n * over `text`, walking both running positions (`key` = input space, `val` =\n * output space) one code point at a time. `keyStep`/`valStep` give each space's\n * advance per code point. Input may be in any order (nested highlight spans\n * produce non-monotonic boundaries); the result is aligned with the input, and\n * offsets past the end clamp to the output length. Pure-ASCII text (where the\n * two spaces coincide) short-circuits to identity.\n */\nfunction mapOffsets(\n text: string,\n offsets: number[],\n keyStep: (codePoint: number, ch: string) => number,\n valStep: (codePoint: number, ch: string) => number,\n): number[] {\n if (offsets.length === 0 || !hasNonAscii(text)) return offsets;\n\n // Walk in ascending input order, but remember each offset's original slot.\n const order = offsets.map((offset, i) => [offset, i] as const);\n order.sort((a, b) => a[0] - b[0]);\n\n const out = new Array<number>(offsets.length);\n let key = 0;\n let val = 0;\n let next = 0;\n const flush = () => {\n while (next < order.length && order[next][0] <= key)\n out[order[next++][1]] = val;\n };\n flush(); // offsets at position 0\n for (const ch of text) {\n if (next >= order.length) break;\n const cp = ch.codePointAt(0)!;\n key += keyStep(cp, ch);\n val += valStep(cp, ch);\n flush();\n }\n // Past the end: the loop ran to completion, so `val` is the full output length.\n while (next < order.length) out[order[next++][1]] = val;\n return out;\n}\n\n/**\n * Convert a batch of UTF-8 byte offsets to UTF-16 (CodeMirror) offsets in one\n * pass. Unlike `byteToCmOffset` (which re-encodes a prefix per call, so N\n * offsets cost O(N * len)), this is O(len + N log N). Used to map highlight span\n * boundaries back to editor coordinates.\n */\nexport function byteOffsetsToCm(text: string, offsets: number[]): number[] {\n return mapOffsets(\n text,\n offsets,\n (cp) => utf8Len(cp),\n (_cp, ch) => ch.length,\n );\n}\n\n/**\n * Convert a batch of UTF-16 (CodeMirror) offsets to UTF-8 byte offsets in one\n * pass. The batched, ASCII-fast-path counterpart to `cmOffsetToByte` (which\n * re-encodes a prefix per call). Used for the highlight viewport bounds.\n */\nexport function cmOffsetsToByte(text: string, offsets: number[]): number[] {\n return mapOffsets(\n text,\n offsets,\n (_cp, ch) => ch.length,\n (cp) => utf8Len(cp),\n );\n}\n","/**\n * Project file paths. `/main.typ` form, leading slash, forward slashes only.\n * `@preview/...` package paths bypass this (they are pushed to the VFS verbatim).\n */\n\n/** `/path/to/file.typ`, leading-slash, forward slashes only. */\nexport type Path = string;\n\n/** Ensure a path starts with a leading slash. Idempotent. */\nexport function normalizePath(path: string): Path {\n return path.startsWith(\"/\") ? path : `/${path}`;\n}\n","// Geometry for SVG page previews: converts between viewport pixels and page\n// point coordinates (the SVG viewBox unit and `RenderedSvgPage.width/height`).\n// Pure geometry, the preview counterpart of `coords.ts`. A single scale\n// (rendered width / point width) maps both axes because Typst preserves aspect\n// ratio. `PreviewNavigator` composes these into click-to-jump navigation.\n\n/** The subset of `DOMRect` these helpers read. `el.getBoundingClientRect()`\n * satisfies it at runtime; a plain object works in tests. */\nexport interface Rect {\n left: number;\n top: number;\n width: number;\n}\n\n/** CSS pixels per typst point for a page rendered `renderedWidthPx` wide,\n * where `pageWidthPt` is `RenderedSvgPage.width`. Falls back to 1 for zero-width pages. */\nexport function pageScale(\n renderedWidthPx: number,\n pageWidthPt: number,\n): number {\n return pageWidthPt > 0 ? renderedWidthPx / pageWidthPt : 1;\n}\n\n/** Rendered height in CSS px of a page laid out `renderedWidthPx` wide,\n * from its point dimensions. Used for fit-to-height and visibility checks. */\nexport function pageRenderedHeight(\n pageWidthPt: number,\n pageHeightPt: number,\n renderedWidthPx: number,\n): number {\n return pageWidthPt > 0 ? (renderedWidthPx * pageHeightPt) / pageWidthPt : 0;\n}\n\n/** Maps a viewport point to page point coordinates given the page's\n * on-screen rect and `RenderedSvgPage.width`. Inverse of SVG layout,\n * e.g. to pass a click to `clickJump`. */\nexport function clientToPagePoint(\n pageRect: Rect,\n pageWidthPt: number,\n clientX: number,\n clientY: number,\n): { x: number; y: number } {\n const scale = pageScale(pageRect.width, pageWidthPt);\n return {\n x: (clientX - pageRect.left) / scale,\n y: (clientY - pageRect.top) / scale,\n };\n}\n\n/** Returns the `scrollTop` that places `yPt` points from a page's top at\n * `margin` px below the scroller's top edge. Pass page and scroller\n * `getBoundingClientRect()`s and the scroller's current `scrollTop`. */\nexport function scrollTopForPageY(\n pageRect: Rect,\n scrollerRect: Rect,\n scrollerScrollTop: number,\n pageWidthPt: number,\n yPt: number,\n margin = 0,\n): number {\n const scale = pageScale(pageRect.width, pageWidthPt);\n return (\n scrollerScrollTop + (pageRect.top - scrollerRect.top) + yPt * scale - margin\n );\n}\n","import type { Path } from \"./identifiers.js\";\nimport type { TypstProject } from \"./project.js\";\nimport { clientToPagePoint, scrollTopForPageY } from \"./preview.js\";\nimport type { ClickJump, CursorJump } from \"./types.js\";\n\nexport interface PreviewNavigatorOptions {\n /** The project whose `clickJump` resolves clicks, or a thunk returning it.\n * Pass a thunk when the host swaps project instances (e.g. on file change) so\n * the navigator always reads the current one without being re-created. */\n project: TypstProject | (() => TypstProject);\n /** The scroll container holding the rendered pages. Used to scroll to\n * destinations and, unless `listen` is false, to delegate click handling. */\n scroller: HTMLElement;\n /** One element per page, in order: each the page's root `<svg>` or a wrapper\n * containing it. Read live on every event so DOM changes are always reflected.\n * Holes (`null`) mark absent pages. */\n pages: () => ArrayLike<Element | null | undefined>;\n /** Attach a `click` listener on `scroller` that routes clicks through the\n * engine. Set false when the host owns pointer handling (drag/pan/snap) and\n * calls `jumpAt` itself. Default true. */\n listen?: boolean;\n /** A `source` jump: move the editor to `file` at 1-based `line`/`column`. */\n onSource?: (file: string, line: number, column: number) => void;\n /** A `url` jump. Defaults to opening the URL in a new tab. */\n onUrl?: (url: string) => void;\n /** A `position` (internal-link) jump. Defaults to scrolling the destination\n * into view; override to drive your own scroll/highlight. */\n onPosition?: (page: number, yPt: number) => void;\n /** Px above the destination when scrolling to a `position`. */\n margin?: number;\n /** Scroll behavior for the default `position` handler. Default \"smooth\". */\n behavior?: ScrollBehavior;\n}\n\nexport interface PreviewScrollOptions {\n /** Where the target sits in the viewport, like `scrollIntoView`'s `block`:\n * \"start\" (top, offset by `margin`), \"center\", or \"end\" (bottom, less\n * `margin`). Default \"start\". */\n align?: \"start\" | \"center\" | \"end\";\n /** Override the navigator's default scroll behavior for this call. */\n behavior?: ScrollBehavior;\n}\n\n/**\n * Drives click-to-jump navigation for a Typst preview without owning rendering\n * or page state. Resolves clicks via `project.clickJump` and routes the result\n * to the editor (`source`), a scroll (`position`), or a URL. `scrollToSource`\n * runs the reverse: editor cursor to preview position.\n *\n * const preview = PreviewNavigator.create({\n * project,\n * scroller,\n * pages: () => scroller.querySelectorAll(\".page\"),\n * onSource,\n * });\n * // ...\n * preview.dispose();\n */\nexport class PreviewNavigator {\n private readonly onClick?: (e: MouseEvent) => void;\n\n private constructor(private readonly opts: PreviewNavigatorOptions) {\n if (opts.listen !== false) {\n this.onClick = (e) => {\n e.preventDefault();\n void this.jumpAt(e.clientX, e.clientY);\n };\n opts.scroller.addEventListener(\"click\", this.onClick);\n }\n }\n\n /** Create a preview view bound to `project` and `scroller`. */\n static create(opts: PreviewNavigatorOptions): PreviewNavigator {\n return new PreviewNavigator(opts);\n }\n\n /** The 0-based page under a viewport point and the point in that page's own\n * coordinates (the SVG viewBox unit, what `clickJump` expects), or null when\n * the point is over no page. */\n pointToPage(\n clientX: number,\n clientY: number,\n ): { page: number; x: number; y: number } | null {\n const pages = this.opts.pages();\n for (let page = 0; page < pages.length; page++) {\n const svg = rootSvg(pages[page]);\n if (!svg) continue;\n const rect = svg.getBoundingClientRect();\n if (\n clientX < rect.left ||\n clientX > rect.right ||\n clientY < rect.top ||\n clientY > rect.bottom\n ) {\n continue;\n }\n const { x, y } = clientToPagePoint(\n rect,\n svg.viewBox.baseVal.width,\n clientX,\n clientY,\n );\n return { page, x, y };\n }\n return null;\n }\n\n /** Resolve a viewport point through the engine and route the resulting jump\n * (`source` to the editor, `position` to a scroll, `url` to open). No-op when\n * the point is over no page or the engine finds nothing actionable. */\n async jumpAt(clientX: number, clientY: number): Promise<void> {\n const hit = this.pointToPage(clientX, clientY);\n if (!hit) return;\n let jump: ClickJump | undefined;\n try {\n jump = await this.currentProject().clickJump(hit.page, hit.x, hit.y);\n } catch (err) {\n console.error(\"[typst] clickJump failed:\", err);\n return;\n }\n if (!jump) return;\n if (jump.kind === \"source\") {\n this.opts.onSource?.(jump.file, jump.line, jump.column);\n } else if (jump.kind === \"url\") {\n (this.opts.onUrl ?? openInNewTab)(jump.url);\n } else if (this.opts.onPosition) {\n this.opts.onPosition(jump.page, jump.y);\n } else {\n this.scrollToPosition(jump.page, jump.y);\n }\n }\n\n /** Resolve a CodeMirror `offset` in `path` (with `source` as the live buffer)\n * to where it renders and scroll there. Returns the position for a highlight,\n * or null if the cursor maps nowhere. Reverse of `jumpAt`. */\n async scrollToSource(\n path: Path,\n source: string,\n offset: number,\n opts: PreviewScrollOptions = {},\n ): Promise<CursorJump | null> {\n let pos: CursorJump | undefined;\n try {\n pos = await this.currentProject().jumpFromCursor(path, source, offset);\n } catch (err) {\n console.error(\"[typst] jumpFromCursor failed:\", err);\n return null;\n }\n if (!pos) return null;\n this.scrollToPosition(pos.page, pos.y, opts);\n return pos;\n }\n\n /** The current project, resolving the thunk form of `opts.project`. */\n private currentProject(): TypstProject {\n const { project } = this.opts;\n return typeof project === \"function\" ? project() : project;\n }\n\n /** Scroll `yPt` points down page `page` to `opts.align` in the viewport\n * (default \"start\", offset by `margin`). Default handler for a `position` jump. */\n scrollToPosition(\n page: number,\n yPt: number,\n opts: PreviewScrollOptions = {},\n ): void {\n const svg = rootSvg(this.opts.pages()[page]);\n if (!svg) return;\n const { scroller } = this.opts;\n const margin = this.opts.margin ?? 0;\n const height = scroller.clientHeight;\n const offsetFromTop =\n opts.align === \"center\"\n ? height / 2\n : opts.align === \"end\"\n ? height - margin\n : margin;\n scroller.scrollTo({\n top: scrollTopForPageY(\n svg.getBoundingClientRect(),\n scroller.getBoundingClientRect(),\n scroller.scrollTop,\n svg.viewBox.baseVal.width,\n yPt,\n offsetFromTop,\n ),\n behavior: opts.behavior ?? this.opts.behavior ?? \"smooth\",\n });\n }\n\n /** Detach the click listener, if one was attached. */\n dispose(): void {\n if (this.onClick) {\n this.opts.scroller.removeEventListener(\"click\", this.onClick);\n }\n }\n}\n\n/** The page's root `<svg>`: the element itself if it is one, else its first\n * descendant `<svg>` (document order puts the root before any nested image svg). */\nfunction rootSvg(el: Element | null | undefined): SVGSVGElement | null {\n if (!el) return null;\n return el instanceof SVGSVGElement ? el : el.querySelector(\"svg\");\n}\n\nfunction openInNewTab(url: string) {\n window.open(url, \"_blank\", \"noopener,noreferrer\");\n}\n","import * as Comlink from \"comlink\";\nimport type { Remote } from \"comlink\";\nimport { CompileScheduler } from \"./compile-scheduler.js\";\nimport { byteOffsetsToCm, cmOffsetsToByte, cmOffsetToByte } from \"./coords.js\";\nimport { normalizePath, type Path } from \"./identifiers.js\";\nimport { createPackageLoader, type PackageLoader } from \"./packages.js\";\nimport type {\n ClickJump,\n CompileResult,\n CompletionResponse,\n CursorJump,\n HlSpan,\n Hover,\n RenderedSvgPage,\n} from \"./types.js\";\nimport type { TypstenWorkerApi } from \"./typsten-worker.js\";\n\nexport interface TypstProjectCreateOptions {\n /** Default entry file path. Default: \"/main.typ\". */\n entry?: string;\n /** Auto-compile scheduling after VFS mutations. */\n autoCompile?: AutoCompileOptions;\n}\n\nexport interface AutoCompileOptions {\n /** Idle time (ms) after the last mutation before a compile fires. Default: 0. */\n debounceMs?: number;\n /** Max time (ms) the debounce may defer during sustained edits. Default: 0. */\n maxWaitMs?: number;\n}\n\nexport type CompileListener = (result: CompileResult) => void;\n\nconst DEFAULT_ENTRY = \"/main.typ\";\nconst encoder = new TextEncoder();\n\nfunction errorAsCompileResult(err: unknown): CompileResult {\n const message = err instanceof Error ? err.message : String(err);\n return {\n pages: [],\n diagnostics: [\n { severity: \"error\", message, hints: [], location: undefined },\n ],\n };\n}\n\nfunction toBytes(content: ArrayBuffer | ArrayBufferView): Uint8Array {\n if (content instanceof Uint8Array) return content;\n if (ArrayBuffer.isView(content)) {\n return new Uint8Array(\n content.buffer,\n content.byteOffset,\n content.byteLength,\n );\n }\n return new Uint8Array(content);\n}\n\n/**\n * Multi-file Typst project backed by a single typsten wasm worker. Owns the\n * VFS; editors push `setText` edits as the user types; the project mirrors them\n * to the worker, fetches `@preview` packages on demand, and compiles or renders\n * against the current state.\n *\n * const project = await TypstProject.create();\n * await project.setMany({ \"/main.typ\": \"...\" });\n * const { pages } = await project.compile();\n * const svg = await project.renderPage(0);\n */\nexport class TypstProject {\n /**\n * Tracked project files: the text content for a text file, or `null` for a\n * binary one. Drives dedup, `getText`, `files`, and `clear`. (Cached `@preview`\n * package files live only in the worker VFS, never here.)\n */\n private readonly tracked = new Map<Path, string | null>();\n private readonly compileListeners = new Set<CompileListener>();\n private readonly scheduler: CompileScheduler;\n private readonly packageLoader: PackageLoader;\n private compileVersion = 0;\n private _lastResult: CompileResult | undefined;\n private _entry: Path;\n private destroyed = false;\n\n private constructor(\n private readonly engine: Remote<TypstenWorkerApi>,\n private readonly worker: Worker,\n options: TypstProjectCreateOptions,\n ) {\n this._entry = normalizePath(options.entry ?? DEFAULT_ENTRY);\n this.scheduler = new CompileScheduler({\n debounceMs: options.autoCompile?.debounceMs,\n maxWaitMs: options.autoCompile?.maxWaitMs,\n });\n this.packageLoader = createPackageLoader((path, bytes) =>\n this.engine.setFile(path, bytes),\n );\n }\n\n /** Create a project: spin up the worker, init the wasm, set the entry. */\n static async create(\n options: TypstProjectCreateOptions = {},\n ): Promise<TypstProject> {\n const worker = new Worker(new URL(\"./typsten-worker.js\", import.meta.url), {\n type: \"module\",\n });\n const engine = Comlink.wrap<TypstenWorkerApi>(worker);\n\n const wasmUrl = new URL(\"./typsten_bg.wasm\", import.meta.url).href;\n await engine.init(wasmUrl);\n\n const project = new TypstProject(engine, worker, options);\n await engine.setEntry(project._entry);\n\n return project;\n }\n\n private scheduleCompile(): void {\n if (this.destroyed) return;\n this.scheduler.schedule(() => {\n this.compile().catch((err) => console.error(\"[typst]\", err));\n });\n }\n\n /**\n * Mirror text into the VFS without scheduling a compile. Returns the in-flight\n * write to await, or `null` if the content is unchanged (deduped to a no-op).\n */\n private writeText(p: Path, content: string): Promise<unknown> | null {\n if (this.tracked.get(p) === content) return null;\n this.tracked.set(p, content);\n return this.engine.setFile(p, encoder.encode(content));\n }\n\n /** Mirror binary bytes into the VFS (always writes; binaries are not deduped). */\n private writeBinary(p: Path, bytes: Uint8Array): Promise<unknown> {\n this.tracked.set(p, null);\n return this.engine.setFile(p, bytes);\n }\n\n get entry(): Path {\n return this._entry;\n }\n\n set entry(path: Path) {\n const next = normalizePath(path);\n if (next === this._entry) return;\n this._entry = next;\n void this.engine.setEntry(next);\n this.scheduleCompile();\n }\n\n /** Most recent compile result, or `undefined` before the first compile. */\n get lastResult(): CompileResult | undefined {\n return this._lastResult;\n }\n\n /** Tracked text file paths, in insertion order (fresh array). */\n get files(): Path[] {\n return [...this.tracked]\n .filter(([, content]) => content !== null)\n .map(([path]) => path);\n }\n\n /** Current text for a tracked file, or `undefined` (binary or absent). */\n getText(path: Path): string | undefined {\n return this.tracked.get(normalizePath(path)) ?? undefined;\n }\n\n /** Add or overwrite a text file. No-op if unchanged. */\n async setText(path: Path, content: string): Promise<void> {\n const write = this.writeText(normalizePath(path), content);\n if (write) {\n await write;\n this.scheduleCompile();\n }\n }\n\n /** Add or overwrite a binary file (retires any text tracking for the path). */\n async setBinary(\n path: Path,\n content: ArrayBuffer | ArrayBufferView,\n ): Promise<void> {\n await this.writeBinary(normalizePath(path), toBytes(content));\n this.scheduleCompile();\n }\n\n /** Batch set files. Strings dedup against tracked content; binaries always write. */\n async setMany(files: Record<Path, string | Uint8Array>): Promise<void> {\n const writes: Promise<unknown>[] = [];\n for (const [path, content] of Object.entries(files)) {\n const p = normalizePath(path);\n const write =\n typeof content === \"string\"\n ? this.writeText(p, content)\n : this.writeBinary(p, content);\n if (write) writes.push(write);\n }\n if (writes.length === 0) return;\n await Promise.all(writes);\n this.scheduleCompile();\n }\n\n /** Remove a file from the VFS. */\n async remove(path: Path): Promise<void> {\n const p = normalizePath(path);\n await this.engine.remove(p);\n this.tracked.delete(p);\n this.scheduleCompile();\n }\n\n /** Remove all tracked project files (cached `@preview` packages are kept). */\n async clear(): Promise<void> {\n await Promise.all(\n [...this.tracked.keys()].map((p) => this.engine.remove(p)),\n );\n this.tracked.clear();\n this.scheduleCompile();\n }\n\n /**\n * Register a font (TTF/OTF, or TTC collection bytes) so compilation can use\n * it, then recompile. The engine bundles default body, math, and monospace\n * fonts; use this to add families it does not ship (e.g. CJK or a custom\n * font). Fonts persist for the project's lifetime.\n *\n * Returns the canonical family name of each added face, the name Typst\n * groups and matches by (width/weight/style folded into the variant, so e.g.\n * \"Roboto Condensed\" reports as \"Roboto\"). Use it to label the font the way\n * `#set text(font: ...)` expects, instead of parsing the name table yourself.\n */\n async addFont(bytes: Uint8Array): Promise<string[]> {\n const families = await this.engine.addFont(bytes);\n this.scheduleCompile();\n return families;\n }\n\n /**\n * Drop every font added via `addFont`, resetting to the embedded defaults,\n * then recompile. The engine has no per-font removal, so to remove a font,\n * call this and re-`addFont` the ones to keep.\n */\n async clearFonts(): Promise<void> {\n await this.engine.clearFonts();\n this.scheduleCompile();\n }\n\n /**\n * Subscribe to compile results. Late subscribers get `lastResult` synchronously.\n * Returns an unsubscribe function.\n */\n onCompile(listener: CompileListener): () => void {\n this.compileListeners.add(listener);\n if (this._lastResult !== undefined) {\n try {\n listener(this._lastResult);\n } catch (err) {\n console.error(\"[typst] compile listener threw:\", err);\n }\n }\n return () => {\n this.compileListeners.delete(listener);\n };\n }\n\n /**\n * Compile the current VFS state. Fetches any referenced `@preview` packages\n * first. Errors become a synthetic diagnostic. Listeners fire only for the\n * most recent compile (stale results are dropped).\n */\n async compile(): Promise<CompileResult> {\n this.scheduler.cancel();\n const version = ++this.compileVersion;\n let result: CompileResult;\n try {\n await this.packageLoader.ensure(\n [...this.tracked.values()].filter((v): v is string => v !== null),\n );\n result = await this.engine.compile();\n } catch (err) {\n result = errorAsCompileResult(err);\n }\n if (version === this.compileVersion) {\n this._lastResult = result;\n for (const listener of this.compileListeners) {\n try {\n listener(result);\n } catch (err) {\n console.error(\"[typst] compile listener threw:\", err);\n }\n }\n }\n return result;\n }\n\n /** Render a single page of the last compile to SVG, or `undefined`. */\n renderPage(index: number): Promise<string | undefined> {\n return this.engine.renderPage(index);\n }\n\n /**\n * Render pages `[start, end)` as `RenderedSvgPage`s (index + dims + svg),\n * zipping the SVG strings with the page metadata from the last compile.\n */\n async renderedPages(start: number, end: number): Promise<RenderedSvgPage[]> {\n const pages = this._lastResult?.pages ?? [];\n const svgs = await this.engine.renderPages(start, end);\n return svgs.map((svg, i) => {\n const index = start + i;\n const dims = pages[index];\n return {\n index,\n width: dims?.width ?? 0,\n height: dims?.height ?? 0,\n svg,\n };\n });\n }\n\n /**\n * Export the last compile as a PDF, or `undefined` if nothing has compiled\n * yet. The bytes are a fresh `Uint8Array` (copied across the worker boundary).\n */\n exportPdf(): Promise<Uint8Array | undefined> {\n return this.engine.exportPdf();\n }\n\n /**\n * Resolve a click at `(x, y)` points on page `index` of the last compile into\n * where it should take the user: a source location (file/line/column) for a\n * click on text, an internal link target (page + point in points) to scroll to,\n * or a URL. `undefined` if nothing compiled, the page is out of range, or the\n * click hit nothing actionable. Powers click-to-source and clickable links,\n * which the SVG can't express on its own.\n */\n clickJump(\n index: number,\n x: number,\n y: number,\n ): Promise<ClickJump | undefined> {\n return this.engine.clickJump(index, x, y);\n }\n\n /** Resolve a CodeMirror `offset` in `path` (with `source` as the live buffer)\n * to where it renders in the last compile: a 0-based page and point (in\n * points), or `undefined` if the cursor maps nowhere. Reverse of `clickJump`. */\n async jumpFromCursor(\n path: Path,\n source: string,\n offset: number,\n ): Promise<CursorJump | undefined> {\n const p = normalizePath(path);\n await this.writeText(p, source);\n return this.engine.jumpFromCursor(p, cmOffsetToByte(source, offset));\n }\n\n /** Completions at a CodeMirror `offset` in `path`, using `source` as the live buffer. */\n async completion(\n path: Path,\n source: string,\n offset: number,\n explicit = false,\n ): Promise<CompletionResponse | undefined> {\n const p = normalizePath(path);\n await this.writeText(p, source);\n return this.engine.complete(p, cmOffsetToByte(source, offset), explicit);\n }\n\n /** Hover tooltip at a CodeMirror `offset` in `path`, using `source` as the live buffer. */\n async hover(\n path: Path,\n source: string,\n offset: number,\n ): Promise<Hover | undefined> {\n const p = normalizePath(path);\n await this.writeText(p, source);\n return this.engine.hover(p, cmOffsetToByte(source, offset));\n }\n\n /** Format `source` (the live buffer for `path`); returns the formatted text or `undefined`. */\n async format(path: Path, source: string): Promise<string | undefined> {\n const p = normalizePath(path);\n await this.writeText(p, source);\n return this.engine.format(p);\n }\n\n /**\n * Syntax-highlight `source` over the CodeMirror window `[from, to)` (UTF-16\n * offsets; defaults to the whole string). Returns spans whose `from`/`to` are\n * CodeMirror offsets, ready to drive decorations. Stateless: the worker parses\n * `source` directly via typst-syntax, so this neither reads nor mutates the\n * VFS and works for any text (the live buffer, a hover code snippet).\n */\n async highlight(\n source: string,\n from = 0,\n to = source.length,\n ): Promise<HlSpan[]> {\n const [byteFrom, byteTo] = cmOffsetsToByte(source, [from, to]);\n const spans = await this.engine.highlight(source, byteFrom, byteTo);\n if (spans.length === 0) return spans;\n // The worker speaks UTF-8 bytes; map every span boundary back to UTF-16\n // (CodeMirror) offsets in one pass over the source. Boundaries are not\n // monotonic (nested spans wrap inner ones), so byteOffsetsToCm sorts them.\n const cm = byteOffsetsToCm(\n source,\n spans.flatMap((s) => [s.from, s.to]),\n );\n return spans.map((s, i) => ({\n from: cm[i * 2],\n to: cm[i * 2 + 1],\n tag: s.tag,\n }));\n }\n\n /**\n * Syntax-highlight `source` to nested `<span class=\"typ-*\">` HTML for a static\n * context (e.g. a hover tooltip). Stateless, like `highlight`.\n */\n highlightHtml(source: string): Promise<string> {\n return this.engine.highlightHtml(source);\n }\n\n /** Tear down the worker and drop all state. Idempotent. */\n destroy(): void {\n if (this.destroyed) return;\n this.destroyed = true;\n this.scheduler.cancel();\n this.compileListeners.clear();\n this.tracked.clear();\n this._lastResult = undefined;\n this.engine[Comlink.releaseProxy]();\n this.worker.terminate();\n }\n}\n","interface CompileSchedulerOptions {\n /** Minimum idle time (ms) after the last request before firing. Default: 0. */\n debounceMs?: number;\n /**\n * Maximum time (ms) the debounce may keep deferring during continuous\n * requests. Guarantees a fire at least this often so users see progress\n * while typing. Default: 0 (no cap).\n */\n maxWaitMs?: number;\n}\n\n/**\n * Debounce helper with a max-wait ceiling for coalescing compile requests. A\n * burst of `schedule(cb)` calls within `debounceMs` collapses into one fire;\n * during sustained bursts, `maxWaitMs` caps how long the debounce may keep\n * deferring.\n */\nexport class CompileScheduler {\n private debounceTimer: ReturnType<typeof setTimeout> | null = null;\n private maxWaitTimer: ReturnType<typeof setTimeout> | null = null;\n\n constructor(private readonly options: CompileSchedulerOptions = {}) {}\n\n schedule(callback: () => void): void {\n if (this.debounceTimer) {\n clearTimeout(this.debounceTimer);\n this.debounceTimer = null;\n }\n\n const delay = Math.max(0, this.options.debounceMs ?? 0);\n this.debounceTimer = setTimeout(() => {\n this.debounceTimer = null;\n this.clearMaxWait();\n callback();\n }, delay);\n\n const maxWait = this.options.maxWaitMs;\n if (maxWait != null && maxWait > 0 && !this.maxWaitTimer) {\n this.maxWaitTimer = setTimeout(() => {\n this.maxWaitTimer = null;\n if (this.debounceTimer) {\n clearTimeout(this.debounceTimer);\n this.debounceTimer = null;\n callback();\n }\n }, maxWait);\n }\n }\n\n /** Cancel any pending scheduled fire without calling the callback. */\n cancel(): void {\n if (this.debounceTimer) {\n clearTimeout(this.debounceTimer);\n this.debounceTimer = null;\n }\n this.clearMaxWait();\n }\n\n private clearMaxWait(): void {\n if (this.maxWaitTimer) {\n clearTimeout(this.maxWaitTimer);\n this.maxWaitTimer = null;\n }\n }\n}\n","// typsten resolves `@preview` packages from its in-memory VFS but does no I/O.\n// This is the JS side: scan sources for `@preview` imports, fetch the tarball\n// from the registry, unpack it, and push every member into the VFS. A package's\n// own sources may import further `@preview` packages, so after unpacking we scan\n// the fetched `.typ` files and follow those transitive imports to a fixed point.\n// (The eager import-scanner approach; a lazy JSPI fetch is a future typsten\n// milestone that would let the engine drive resolution instead.)\nimport { gunzipSync } from \"fflate\";\nimport { parseTar } from \"nanotar\";\n\nconst REGISTRY = \"https://packages.typst.org/preview\";\nconst PREVIEW_IMPORT = /@preview\\/([a-zA-Z0-9_-]+):(\\d+\\.\\d+\\.\\d+)/g;\n\nexport type SetFile = (path: string, bytes: Uint8Array) => Promise<void> | void;\n\nexport interface PackageLoader {\n /**\n * Ensure every `@preview` package referenced in `sources`, and transitively\n * by the packages they pull in, is present in the VFS, fetching any missing.\n */\n ensure(sources: Iterable<string>): Promise<void>;\n}\n\n/** Collect the `name:version` spec of every `@preview` import in `text`. */\nfunction specsIn(text: string): string[] {\n const specs: string[] = [];\n for (const m of text.matchAll(PREVIEW_IMPORT)) specs.push(`${m[1]}:${m[2]}`);\n return specs;\n}\n\nexport function createPackageLoader(setFile: SetFile): PackageLoader {\n const decoder = new TextDecoder();\n // spec (\"name:version\") -> the transitive specs found inside that package.\n // Doubles as the fetch cache: a settled entry means the package is resident.\n const fetched = new Map<string, Promise<string[]>>();\n\n async function fetchPackage(spec: string): Promise<string[]> {\n const [name, version] = spec.split(\":\");\n const qualified = `@preview/${spec}`;\n const res = await fetch(`${REGISTRY}/${name}-${version}.tar.gz`);\n if (!res.ok) {\n throw new Error(\n `failed to fetch ${qualified}: ${res.status} ${res.statusText}`,\n );\n }\n const tar = gunzipSync(new Uint8Array(await res.arrayBuffer()));\n const nested = new Set<string>();\n for (const entry of parseTar(tar)) {\n // Skip directories and anything without bytes.\n if (!entry.data || entry.name.endsWith(\"/\")) continue;\n await setFile(`${qualified}/${entry.name}`, entry.data);\n // A package's own `.typ` sources may import further `@preview` packages.\n if (entry.name.endsWith(\".typ\")) {\n for (const s of specsIn(decoder.decode(entry.data))) nested.add(s);\n }\n }\n return [...nested];\n }\n\n function fetchOnce(spec: string): Promise<string[]> {\n let task = fetched.get(spec);\n if (!task) {\n task = fetchPackage(spec).catch((err: unknown) => {\n // Drop failed fetches so a later compile can retry (transient network).\n fetched.delete(spec);\n throw err;\n });\n fetched.set(spec, task);\n }\n return task;\n }\n\n return {\n async ensure(sources) {\n const seen = new Set<string>();\n let frontier = new Set<string>();\n for (const text of sources) {\n for (const s of specsIn(text)) frontier.add(s);\n }\n // Breadth-first fetch to a fixed point; each package can reveal more.\n while (frontier.size > 0) {\n const batch = [...frontier].filter((s) => !seen.has(s));\n for (const s of batch) seen.add(s);\n frontier = new Set();\n const nestedLists = await Promise.all(batch.map(fetchOnce));\n for (const list of nestedLists) {\n for (const s of list) if (!seen.has(s)) frontier.add(s);\n }\n }\n },\n };\n}\n"],"mappings":";AAIA,IAAM,UAAU,IAAI,YAAY;AAChC,IAAM,UAAU,IAAI,YAAY;AAGzB,SAAS,eAAe,MAAc,QAAwB;AACnE,SAAO,QAAQ,OAAO,KAAK,MAAM,GAAG,MAAM,CAAC,EAAE;AAC/C;AAGO,SAAS,eAAe,MAAc,MAAsB;AACjE,MAAI,QAAQ,EAAG,QAAO;AACtB,QAAM,QAAQ,QAAQ,OAAO,IAAI;AACjC,MAAI,QAAQ,MAAM,OAAQ,QAAO,KAAK;AACtC,SAAO,QAAQ,OAAO,MAAM,SAAS,GAAG,IAAI,CAAC,EAAE;AACjD;AAGA,SAAS,YAAY,MAAuB;AAC1C,WAAS,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;AACpC,QAAI,KAAK,WAAW,CAAC,IAAI,IAAM,QAAO;AAAA,EACxC;AACA,SAAO;AACT;AAGA,SAAS,QAAQ,WAA2B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AClC,SAAK,OAAO,UAAU;AAAA,EACxB;AACF;","names":["decoder","encoder"]}
@@ -37,6 +37,20 @@ var Project = class {
37
37
  clear_fonts() {
38
38
  wasm.project_clear_fonts(this.__wbg_ptr);
39
39
  }
40
+ /**
41
+ * Resolve a click at `(x, y)` points on page `index` of the last compiled
42
+ * document: a source location to jump the editor to, an internal link target
43
+ * to scroll the preview to, or a URL. `None` if nothing compiled, the page is
44
+ * out of range, or the click hit nothing actionable.
45
+ * @param {number} index
46
+ * @param {number} x
47
+ * @param {number} y
48
+ * @returns {ClickJump | undefined}
49
+ */
50
+ click_jump(index, x, y) {
51
+ const ret = wasm.project_click_jump(this.__wbg_ptr, index, x, y);
52
+ return ret;
53
+ }
40
54
  /**
41
55
  * Compile the project, returning the rendered SVG and typed diagnostics.
42
56
  *
@@ -142,6 +156,20 @@ var Project = class {
142
156
  const ret = wasm.project_hover(this.__wbg_ptr, ptr0, len0, cursor);
143
157
  return ret;
144
158
  }
159
+ /**
160
+ * Resolve a `cursor` (byte offset) in `path` to where it renders in the last
161
+ * compiled document (0-based page + point in points), or `None`. The reverse
162
+ * of `click_jump`, for scrolling the preview to follow the editor cursor.
163
+ * @param {string} path
164
+ * @param {number} cursor
165
+ * @returns {CursorJump | undefined}
166
+ */
167
+ jump_from_cursor(path, cursor) {
168
+ const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
169
+ const len0 = WASM_VECTOR_LEN;
170
+ const ret = wasm.project_jump_from_cursor(this.__wbg_ptr, ptr0, len0, cursor);
171
+ return ret;
172
+ }
145
173
  constructor() {
146
174
  const ret = wasm.project_new();
147
175
  this.__wbg_ptr = ret;
@@ -527,6 +555,12 @@ var TypstenWorker = class {
527
555
  exportPdf() {
528
556
  return this.#p().export_pdf();
529
557
  }
558
+ clickJump(index, x, y) {
559
+ return this.#p().click_jump(index, x, y);
560
+ }
561
+ jumpFromCursor(path, cursor) {
562
+ return this.#p().jump_from_cursor(path, cursor);
563
+ }
530
564
  complete(path, cursor, explicit) {
531
565
  return this.#p().complete(path, cursor, explicit);
532
566
  }
@@ -1 +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): string[] {\n return this.#p().add_font(bytes);\n }\n\n clearFonts(): void {\n this.#p().clear_fonts();\n }\n\n remove(path: string): void {\n this.#p().remove_file(path);\n }\n\n compile(): ReturnType<Project[\"compile\"]> {\n // WASM has no clock; refresh the date the world serves to `datetime.today()`\n // right before each compile, so a long-lived worker doesn't go stale.\n const now = new Date();\n this.#p().set_today(\n now.getFullYear(),\n now.getMonth() + 1,\n now.getDate(),\n now.getHours(),\n now.getMinutes(),\n now.getSeconds(),\n );\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). Returns the canonical family name of\n * each added face (the name Typst groups and matches by).\n * @param {Uint8Array} bytes\n * @returns {string[]}\n */\n add_font(bytes) {\n const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.project_add_font(this.__wbg_ptr, ptr0, len0);\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 * Drop every font added via `add_font`, resetting to the embedded defaults.\n * The engine has no per-font removal, so to remove a font, call this and\n * re-`add_font` the ones to keep.\n */\n clear_fonts() {\n wasm.project_clear_fonts(this.__wbg_ptr);\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 * Set the date `datetime.today()` returns. WASM has no clock, so JS\n * pushes this in (typically the user's local date) before each compile.\n * @param {number} year\n * @param {number} month\n * @param {number} day\n * @param {number} hour\n * @param {number} minute\n * @param {number} second\n */\n set_today(year, month, day, hour, minute, second) {\n wasm.project_set_today(this.__wbg_ptr, year, month, day, hour, minute, second);\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;;;ACClB,IAAM,UAAN,MAAc;AAAA,EACjB,qBAAqB;AACjB,UAAM,MAAM,KAAK;AACjB,SAAK,YAAY;AACjB,wBAAoB,WAAW,IAAI;AACnC,WAAO;AAAA,EACX;AAAA,EACA,OAAO;AACH,UAAM,MAAM,KAAK,mBAAmB;AACpC,SAAK,mBAAmB,KAAK,CAAC;AAAA,EAClC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,SAAS,OAAO;AACZ,UAAM,OAAO,kBAAkB,OAAO,KAAK,iBAAiB;AAC5D,UAAM,OAAO;AACb,UAAM,MAAM,KAAK,iBAAiB,KAAK,WAAW,MAAM,IAAI;AAC5D,QAAI,KAAK,yBAAyB,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC,EAAE,MAAM;AACxD,SAAK,gBAAgB,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI,GAAG,CAAC;AAC1C,WAAO;AAAA,EACX;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,cAAc;AACV,SAAK,oBAAoB,KAAK,SAAS;AAAA,EAC3C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,UAAU;AACN,UAAM,MAAM,KAAK,gBAAgB,KAAK,SAAS;AAC/C,WAAO;AAAA,EACX;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,SAAS,MAAM,QAAQ,UAAU;AAC7B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AAM,oBAAI,KAAK;AACrB,SAAK,GAAG,EAAE;AAAA,MACR,IAAI,YAAY;AAAA,MAChB,IAAI,SAAS,IAAI;AAAA,MACjB,IAAI,QAAQ;AAAA,MACZ,IAAI,SAAS;AAAA,MACb,IAAI,WAAW;AAAA,MACf,IAAI,WAAW;AAAA,IACjB;AACA,WAAO,KAAK,GAAG,EAAE,QAAQ;AAAA,EAC3B;AAAA,EAEA,WAAW,OAAmC;AAC5C,WAAO,KAAK,GAAG,EAAE,YAAY,KAAK;AAAA,EACpC;AAAA,EAEA,YAAY,OAAe,KAAuB;AAChD,WAAO,KAAK,GAAG,EAAE,aAAa,OAAO,GAAG;AAAA,EAC1C;AAAA,EAEA,YAAoC;AAClC,WAAO,KAAK,GAAG,EAAE,WAAW;AAAA,EAC9B;AAAA,EAEA,SACE,MACA,QACA,UACiC;AACjC,WAAO,KAAK,GAAG,EAAE,SAAS,MAAM,QAAQ,QAAQ;AAAA,EAClD;AAAA,EAEA,MAAM,MAAc,QAA8C;AAChE,WAAO,KAAK,GAAG,EAAE,MAAM,MAAM,MAAM;AAAA,EACrC;AAAA,EAEA,OAAO,MAAkC;AACvC,WAAO,KAAK,GAAG,EAAE,OAAO,IAAI;AAAA,EAC9B;AAAA,EAEA,UACE,MACA,MACA,IACkC;AAClC,WAAO,KAAK,GAAG,EAAE,UAAU,MAAM,MAAM,EAAE;AAAA,EAC3C;AAAA,EAEA,cAAc,MAAsB;AAClC,WAAO,KAAK,GAAG,EAAE,eAAe,IAAI;AAAA,EACtC;AACF;AAKQ,eAAO,IAAI,cAAc,CAAC;","names":["ptr"]}
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): string[] {\n return this.#p().add_font(bytes);\n }\n\n clearFonts(): void {\n this.#p().clear_fonts();\n }\n\n remove(path: string): void {\n this.#p().remove_file(path);\n }\n\n compile(): ReturnType<Project[\"compile\"]> {\n // WASM has no clock; refresh the date the world serves to `datetime.today()`\n // right before each compile, so a long-lived worker doesn't go stale.\n const now = new Date();\n this.#p().set_today(\n now.getFullYear(),\n now.getMonth() + 1,\n now.getDate(),\n now.getHours(),\n now.getMinutes(),\n now.getSeconds(),\n );\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 clickJump(\n index: number,\n x: number,\n y: number,\n ): ReturnType<Project[\"click_jump\"]> {\n return this.#p().click_jump(index, x, y);\n }\n\n jumpFromCursor(\n path: string,\n cursor: number,\n ): ReturnType<Project[\"jump_from_cursor\"]> {\n return this.#p().jump_from_cursor(path, cursor);\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). Returns the canonical family name of\n * each added face (the name Typst groups and matches by).\n * @param {Uint8Array} bytes\n * @returns {string[]}\n */\n add_font(bytes) {\n const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.project_add_font(this.__wbg_ptr, ptr0, len0);\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 * Drop every font added via `add_font`, resetting to the embedded defaults.\n * The engine has no per-font removal, so to remove a font, call this and\n * re-`add_font` the ones to keep.\n */\n clear_fonts() {\n wasm.project_clear_fonts(this.__wbg_ptr);\n }\n /**\n * Resolve a click at `(x, y)` points on page `index` of the last compiled\n * document: a source location to jump the editor to, an internal link target\n * to scroll the preview to, or a URL. `None` if nothing compiled, the page is\n * out of range, or the click hit nothing actionable.\n * @param {number} index\n * @param {number} x\n * @param {number} y\n * @returns {ClickJump | undefined}\n */\n click_jump(index, x, y) {\n const ret = wasm.project_click_jump(this.__wbg_ptr, index, x, y);\n return ret;\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 /**\n * Resolve a `cursor` (byte offset) in `path` to where it renders in the last\n * compiled document (0-based page + point in points), or `None`. The reverse\n * of `click_jump`, for scrolling the preview to follow the editor cursor.\n * @param {string} path\n * @param {number} cursor\n * @returns {CursorJump | undefined}\n */\n jump_from_cursor(path, cursor) {\n const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.project_jump_from_cursor(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 * Set the date `datetime.today()` returns. WASM has no clock, so JS\n * pushes this in (typically the user's local date) before each compile.\n * @param {number} year\n * @param {number} month\n * @param {number} day\n * @param {number} hour\n * @param {number} minute\n * @param {number} second\n */\n set_today(year, month, day, hour, minute, second) {\n wasm.project_set_today(this.__wbg_ptr, year, month, day, hour, minute, second);\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;;;ACClB,IAAM,UAAN,MAAc;AAAA,EACjB,qBAAqB;AACjB,UAAM,MAAM,KAAK;AACjB,SAAK,YAAY;AACjB,wBAAoB,WAAW,IAAI;AACnC,WAAO;AAAA,EACX;AAAA,EACA,OAAO;AACH,UAAM,MAAM,KAAK,mBAAmB;AACpC,SAAK,mBAAmB,KAAK,CAAC;AAAA,EAClC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,SAAS,OAAO;AACZ,UAAM,OAAO,kBAAkB,OAAO,KAAK,iBAAiB;AAC5D,UAAM,OAAO;AACb,UAAM,MAAM,KAAK,iBAAiB,KAAK,WAAW,MAAM,IAAI;AAC5D,QAAI,KAAK,yBAAyB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AAuB;AAChD,WAAO,KAAK,GAAG,EAAE,aAAa,OAAO,GAAG;AAAA,EAC1C;AAAA,EAEA,YAAoC;AAClC,WAAO,KAAK,GAAG,EAAE,WAAW;AAAA,EAC9B;AAAA,EAEA,UACE,OACA,GACA,GACmC;AACnC,WAAO,KAAK,GAAG,EAAE,WAAW,OAAO,GAAG,CAAC;AAAA,EACzC;AAAA,EAEA,eACE,MACA,QACyC;AACzC,WAAO,KAAK,GAAG,EAAE,iBAAiB,MAAM,MAAM;AAAA,EAChD;AAAA,EAEA,SACE,MACA,QACA,UACiC;AACjC,WAAO,KAAK,GAAG,EAAE,SAAS,MAAM,QAAQ,QAAQ;AAAA,EAClD;AAAA,EAEA,MAAM,MAAc,QAA8C;AAChE,WAAO,KAAK,GAAG,EAAE,MAAM,MAAM,MAAM;AAAA,EACrC;AAAA,EAEA,OAAO,MAAkC;AACvC,WAAO,KAAK,GAAG,EAAE,OAAO,IAAI;AAAA,EAC9B;AAAA,EAEA,UACE,MACA,MACA,IACkC;AAClC,WAAO,KAAK,GAAG,EAAE,UAAU,MAAM,MAAM,EAAE;AAAA,EAC3C;AAAA,EAEA,cAAc,MAAsB;AAClC,WAAO,KAAK,GAAG,EAAE,eAAe,IAAI;AAAA,EACtC;AACF;AAKQ,eAAO,IAAI,cAAc,CAAC;","names":["ptr"]}
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vedivad/typst-web-service",
3
- "version": "0.18.3",
3
+ "version": "0.18.5",
4
4
  "description": "Editor-agnostic Typst compilation service running in a Web Worker",
5
5
  "license": "MIT",
6
6
  "repository": {