@vedivad/typst-web-service 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,3 +1,43 @@
1
+ interface FormatConfig {
2
+ /** Number of spaces per indentation level. Default: 2 */
3
+ tab_spaces?: number;
4
+ /** Maximum line width. Default: 80 */
5
+ max_width?: number;
6
+ /** Maximum consecutive blank lines allowed. */
7
+ blank_lines_upper_bound?: number;
8
+ /** Collapse consecutive whitespace in markup to a single space. */
9
+ collapse_markup_spaces?: boolean;
10
+ /** Sort import items alphabetically. */
11
+ reorder_import_items?: boolean;
12
+ /** Wrap text in markup to fit within max_width. Implies collapse_markup_spaces. */
13
+ wrap_text?: boolean;
14
+ }
15
+ interface FormatRangeResult {
16
+ /** Start index (UTF-16) of the actual formatted range. */
17
+ start: number;
18
+ /** End index (UTF-16) of the actual formatted range. */
19
+ end: number;
20
+ /** The formatted text for the range. */
21
+ text: string;
22
+ }
23
+ /**
24
+ * Typst code formatter powered by typstyle.
25
+ *
26
+ * Runs on the main thread — typstyle is lightweight and fast.
27
+ * The WASM module is loaded lazily on first format call.
28
+ *
29
+ * const formatter = new TypstFormatter({ tab_spaces: 2, max_width: 80 });
30
+ * const formatted = await formatter.format(source);
31
+ */
32
+ declare class TypstFormatter {
33
+ private config;
34
+ constructor(config?: FormatConfig);
35
+ /** Format an entire Typst source string. */
36
+ format(source: string): Promise<string>;
37
+ /** Format a range within a Typst source string. Indices are UTF-16 code units. */
38
+ formatRange(source: string, start: number, end: number): Promise<FormatRangeResult>;
39
+ }
40
+
1
41
  /** Source range for a diagnostic. All values are 0-indexed. */
2
42
  interface DiagnosticRange {
3
43
  startLine: number;
@@ -18,12 +58,16 @@ interface CompileResult {
18
58
  /** Vector artifact bytes from the compiler, usable with typst-ts-renderer for SVG rendering. */
19
59
  vector?: Uint8Array;
20
60
  }
21
- type RendererModuleExports = {
61
+ /**
62
+ * A dynamic `import()` expression that resolves to the `@myriaddreamin/typst-ts-renderer` module.
63
+ * Keeps the renderer dependency opt-in — users who only need diagnostics never load the WASM.
64
+ */
65
+ type RendererModule = () => Promise<{
22
66
  default: (wasmUrl?: string) => Promise<unknown>;
23
67
  TypstRendererBuilder: new () => {
24
68
  build(): Promise<RendererInstance>;
25
69
  };
26
- };
70
+ }>;
27
71
  /** Minimal interface for the built TypstRenderer. */
28
72
  interface RendererInstance {
29
73
  create_session(): RendererSession;
@@ -36,8 +80,11 @@ interface RendererSession {
36
80
  }
37
81
  /** Options for the opt-in SVG renderer. */
38
82
  interface RendererOptions {
39
- /** Dynamic import for the renderer module. Defaults to `() => import('@myriaddreamin/typst-ts-renderer')`. */
40
- module?: () => Promise<RendererModuleExports>;
83
+ /**
84
+ * Dynamic import for the renderer module.
85
+ * Example: () => import('@myriaddreamin/typst-ts-renderer')
86
+ */
87
+ module: RendererModule;
41
88
  /** URL to the typst-ts-renderer WASM binary. Defaults to jsDelivr CDN. */
42
89
  wasmUrl?: string;
43
90
  /** Called after each compile with the rendered SVG string. */
@@ -64,6 +111,7 @@ interface TypstServiceOptions {
64
111
  *
65
112
  * Example:
66
113
  * renderer: {
114
+ * module: () => import('@myriaddreamin/typst-ts-renderer'),
67
115
  * onSvg: (svg) => { previewEl.innerHTML = svg },
68
116
  * }
69
117
  */
@@ -90,13 +138,15 @@ declare class TypstService {
90
138
  /** The most recent vector artifact from a compile, if any. */
91
139
  lastVector?: Uint8Array;
92
140
  constructor(worker: Worker, options?: TypstServiceOptions);
93
- compile(source: string): Promise<CompileResult>;
141
+ /** Compile a single source string (treated as /main.typ) or a map of files. */
142
+ compile(source: string | Record<string, string>): Promise<CompileResult>;
94
143
  /**
95
144
  * Render a vector artifact to an SVG string.
96
145
  * Requires the `renderer` option to be set. Returns null if the renderer is unavailable.
97
146
  */
98
147
  renderSvg(vector: Uint8Array): Promise<string | null>;
99
- renderPdf(source: string): Promise<Uint8Array>;
148
+ /** Render to PDF from a single source string (treated as /main.typ) or a map of files. */
149
+ renderPdf(source: string | Record<string, string>): Promise<Uint8Array>;
100
150
  /**
101
151
  * Create a TypstService using an inlined worker blob.
102
152
  * Works without any bundler configuration.
@@ -108,4 +158,4 @@ declare class TypstService {
108
158
  destroy(): void;
109
159
  }
110
160
 
111
- export { type CompileResult, type DiagnosticMessage, type DiagnosticRange, type RendererInstance, type RendererOptions, type RendererSession, TypstService, type TypstServiceOptions };
161
+ export { type CompileResult, type DiagnosticMessage, type DiagnosticRange, type FormatConfig, type FormatRangeResult, type RendererInstance, type RendererModule, type RendererOptions, type RendererSession, TypstFormatter, TypstService, type TypstServiceOptions };
package/dist/index.js CHANGED
@@ -5,9 +5,35 @@ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot
5
5
  var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
6
6
  var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
7
7
 
8
+ // src/formatter.ts
9
+ var typstylePromise = null;
10
+ function getTypstyle() {
11
+ if (!typstylePromise) {
12
+ typstylePromise = import("@typstyle/typstyle-wasm-bundler");
13
+ }
14
+ return typstylePromise;
15
+ }
16
+ var TypstFormatter = class {
17
+ constructor(config = {}) {
18
+ this.config = config;
19
+ getTypstyle();
20
+ }
21
+ /** Format an entire Typst source string. */
22
+ async format(source) {
23
+ const typstyle = await getTypstyle();
24
+ return typstyle.format(source, this.config);
25
+ }
26
+ /** Format a range within a Typst source string. Indices are UTF-16 code units. */
27
+ async formatRange(source, start, end) {
28
+ const typstyle = await getTypstyle();
29
+ const result = typstyle.format_range(source, start, end, this.config);
30
+ return { start: result.start, end: result.end, text: result.text };
31
+ }
32
+ };
33
+
8
34
  // src/rpc.ts
9
35
  function createWorker() {
10
- const blob = new Blob(['"use strict";(()=>{var Jt=Object.defineProperty;var pt=(n,t)=>()=>(n&&(t=n(n=0)),t);var $t=(n,t)=>{for(var e in t)Jt(n,e,{get:t[e],enumerable:!0})};function f(n){q===S.length&&S.push(S.length+1);let t=q;return q=S[t],S[t]=n,t}function ot(n,t){if(!(n instanceof t))throw new Error(`expected instance of ${t.name}`)}function it(n){let t=typeof n;if(t=="number"||t=="boolean"||n==null)return`${n}`;if(t=="string")return`"${n}"`;if(t=="symbol"){let o=n.description;return o==null?"Symbol":`Symbol(${o})`}if(t=="function"){let o=n.name;return typeof o=="string"&&o.length>0?`Function(${o})`:"Function"}if(Array.isArray(n)){let o=n.length,s="[";o>0&&(s+=it(n[0]));for(let _=1;_<o;_++)s+=", "+it(n[_]);return s+="]",s}let e=/\\[object ([^\\]]+)\\]/.exec(toString.call(n)),r;if(e&&e.length>1)r=e[1];else return toString.call(n);if(r=="Object")try{return"Object("+JSON.stringify(n)+")"}catch{return"Object"}return n instanceof Error?`${n.name}: ${n.message}\n${n.stack}`:r}function Kt(n){n<132||(S[n]=q,q=n)}function Zt(n,t){n=n>>>0;let e=a(),r=[];for(let o=n;o<n+4*t;o+=4)r.push(d(e.getUint32(o,!0)));return r}function te(n,t){return n=n>>>0,ee().subarray(n/4,n/4+t)}function st(n,t){return n=n>>>0,T().subarray(n/1,n/1+t)}function a(){return(A===null||A.buffer.detached===!0||A.buffer.detached===void 0&&A.buffer!==i.memory.buffer)&&(A=new DataView(i.memory.buffer)),A}function I(n,t){return n=n>>>0,oe(n,t)}function ee(){return(z===null||z.byteLength===0)&&(z=new Uint32Array(i.memory.buffer)),z}function T(){return(L===null||L.byteLength===0)&&(L=new Uint8Array(i.memory.buffer)),L}function c(n){return S[n]}function O(n,t){try{return n.apply(this,t)}catch(e){i.__wbindgen_export3(f(e))}}function y(n){return n==null}function ne(n,t,e,r){let o={a:n,b:t,cnt:1,dtor:e},s=(..._)=>{o.cnt++;let u=o.a;o.a=0;try{return r(u,o.b,..._)}finally{o.a=u,s._wbg_cb_unref()}};return s._wbg_cb_unref=()=>{--o.cnt===0&&(o.dtor(o.a,o.b),o.a=0,ht.unregister(o))},ht.register(s,o,o),s}function Rt(n,t){let e=t(n.length*1,1)>>>0;return T().set(n,e/1),l=n.length,e}function G(n,t){let e=t(n.length*4,4)>>>0,r=a();for(let o=0;o<n.length;o++)r.setUint32(e+4*o,f(n[o]),!0);return l=n.length,e}function b(n,t,e){if(e===void 0){let u=U.encode(n),g=t(u.length,1)>>>0;return T().subarray(g,g+u.length).set(u),l=u.length,g}let r=n.length,o=t(r,1)>>>0,s=T(),_=0;for(;_<r;_++){let u=n.charCodeAt(_);if(u>127)break;s[o+_]=u}if(_!==r){_!==0&&(n=n.slice(_)),o=e(o,r,r=_+n.length*3,1)>>>0;let u=T().subarray(o+_,o+r),g=U.encodeInto(n,u);_+=g.written,o=e(o,r,_,1)>>>0}return l=_,o}function d(n){let t=c(n);return Kt(n),t}function oe(n,t){return nt+=t,nt>=re&&(Q=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),Q.decode(),nt=t),Q.decode(T().subarray(n,n+t))}function ie(n,t,e){i.__wasm_bindgen_func_elem_944(n,t,f(e))}function se(n,t,e,r){i.__wasm_bindgen_func_elem_37348(n,t,f(e),f(r))}function _e(n){let t=i.get_font_info(f(n));return d(t)}async function ce(n,t){if(typeof Response=="function"&&n instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(n,t)}catch(r){if(n.ok&&ae.has(n.type)&&n.headers.get("Content-Type")!=="application/wasm")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",r);else throw r}let e=await n.arrayBuffer();return await WebAssembly.instantiate(e,t)}else{let e=await WebAssembly.instantiate(n,t);return e instanceof WebAssembly.Instance?{instance:e,module:n}:e}}function At(){let n={};return n.wbg={},n.wbg.__wbg_Error_52673b7de5a0ca89=function(t,e){let r=Error(I(t,e));return f(r)},n.wbg.__wbg_Number_2d1dcfcf4ec51736=function(t){return Number(c(t))},n.wbg.__wbg___wbindgen_bigint_get_as_i64_6e32f5e6aff02e1d=function(t,e){let r=c(e),o=typeof r=="bigint"?r:void 0;a().setBigInt64(t+8,y(o)?BigInt(0):o,!0),a().setInt32(t+0,!y(o),!0)},n.wbg.__wbg___wbindgen_boolean_get_dea25b33882b895b=function(t){let e=c(t),r=typeof e=="boolean"?e:void 0;return y(r)?16777215:r?1:0},n.wbg.__wbg___wbindgen_debug_string_adfb662ae34724b6=function(t,e){let r=it(c(e)),o=b(r,i.__wbindgen_export,i.__wbindgen_export2),s=l;a().setInt32(t+4,s,!0),a().setInt32(t+0,o,!0)},n.wbg.__wbg___wbindgen_in_0d3e1e8f0c669317=function(t,e){return c(t)in c(e)},n.wbg.__wbg___wbindgen_is_bigint_0e1a2e3f55cfae27=function(t){return typeof c(t)=="bigint"},n.wbg.__wbg___wbindgen_is_function_8d400b8b1af978cd=function(t){return typeof c(t)=="function"},n.wbg.__wbg___wbindgen_is_object_ce774f3490692386=function(t){let e=c(t);return typeof e=="object"&&e!==null},n.wbg.__wbg___wbindgen_is_string_704ef9c8fc131030=function(t){return typeof c(t)=="string"},n.wbg.__wbg___wbindgen_is_undefined_f6b95eab589e0269=function(t){return c(t)===void 0},n.wbg.__wbg___wbindgen_jsval_eq_b6101cc9cef1fe36=function(t,e){return c(t)===c(e)},n.wbg.__wbg___wbindgen_jsval_loose_eq_766057600fdd1b0d=function(t,e){return c(t)==c(e)},n.wbg.__wbg___wbindgen_number_get_9619185a74197f95=function(t,e){let r=c(e),o=typeof r=="number"?r:void 0;a().setFloat64(t+8,y(o)?0:o,!0),a().setInt32(t+0,!y(o),!0)},n.wbg.__wbg___wbindgen_string_get_a2a31e16edf96e42=function(t,e){let r=c(e),o=typeof r=="string"?r:void 0;var s=y(o)?0:b(o,i.__wbindgen_export,i.__wbindgen_export2),_=l;a().setInt32(t+4,_,!0),a().setInt32(t+0,s,!0)},n.wbg.__wbg___wbindgen_throw_dd24417ed36fc46e=function(t,e){throw new Error(I(t,e))},n.wbg.__wbg__wbg_cb_unref_87dfb5aaa0cbcea7=function(t){c(t)._wbg_cb_unref()},n.wbg.__wbg_call_3020136f7a2d6e44=function(){return O(function(t,e,r){let o=c(t).call(c(e),c(r));return f(o)},arguments)},n.wbg.__wbg_call_78f94eb02ec7f9b2=function(){return O(function(t,e,r,o,s){let _=c(t).call(c(e),c(r),c(o),c(s));return f(_)},arguments)},n.wbg.__wbg_call_abb4ff46ce38be40=function(){return O(function(t,e){let r=c(t).call(c(e));return f(r)},arguments)},n.wbg.__wbg_done_62ea16af4ce34b24=function(t){return c(t).done},n.wbg.__wbg_entries_83c79938054e065f=function(t){let e=Object.entries(c(t));return f(e)},n.wbg.__wbg_error_7534b8e9a36f1ab4=function(t,e){let r,o;try{r=t,o=e,console.error(I(t,e))}finally{i.__wbindgen_export4(r,o,1)}},n.wbg.__wbg_error_85faeb8919b11cc6=function(t,e,r){console.error(c(t),c(e),c(r))},n.wbg.__wbg_getTimezoneOffset_45389e26d6f46823=function(t){return c(t).getTimezoneOffset()},n.wbg.__wbg_get_6b7bd52aca3f9671=function(t,e){let r=c(t)[e>>>0];return f(r)},n.wbg.__wbg_get_af9dab7e9603ea93=function(){return O(function(t,e){let r=Reflect.get(c(t),c(e));return f(r)},arguments)},n.wbg.__wbg_get_with_ref_key_1dc361bd10053bfe=function(t,e){let r=c(t)[c(e)];return f(r)},n.wbg.__wbg_info_ce6bcc489c22f6f0=function(t){console.info(c(t))},n.wbg.__wbg_instanceof_ArrayBuffer_f3320d2419cd0355=function(t){let e;try{e=c(t)instanceof ArrayBuffer}catch{e=!1}return e},n.wbg.__wbg_instanceof_Map_084be8da74364158=function(t){let e;try{e=c(t)instanceof Map}catch{e=!1}return e},n.wbg.__wbg_instanceof_Uint8Array_da54ccc9d3e09434=function(t){let e;try{e=c(t)instanceof Uint8Array}catch{e=!1}return e},n.wbg.__wbg_isArray_51fd9e6422c0a395=function(t){return Array.isArray(c(t))},n.wbg.__wbg_isSafeInteger_ae7d3f054d55fa16=function(t){return Number.isSafeInteger(c(t))},n.wbg.__wbg_iterator_27b7c8b35ab3e86b=function(){return f(Symbol.iterator)},n.wbg.__wbg_length_22ac23eaec9d8053=function(t){return c(t).length},n.wbg.__wbg_length_d45040a40c570362=function(t){return c(t).length},n.wbg.__wbg_new_1ba21ce319a06297=function(){let t=new Object;return f(t)},n.wbg.__wbg_new_25f239778d6112b9=function(){let t=new Array;return f(t)},n.wbg.__wbg_new_6421f6084cc5bc5a=function(t){let e=new Uint8Array(c(t));return f(e)},n.wbg.__wbg_new_8a6f238a6ece86ea=function(){let t=new Error;return f(t)},n.wbg.__wbg_new_b2db8aa2650f793a=function(t){let e=new Date(c(t));return f(e)},n.wbg.__wbg_new_df1173567d5ff028=function(t,e){let r=new Error(I(t,e));return f(r)},n.wbg.__wbg_new_ff12d2b041fb48f1=function(t,e){try{var r={a:t,b:e},o=(_,u)=>{let g=r.a;r.a=0;try{return se(g,r.b,_,u)}finally{r.a=g}};let s=new Promise(o);return f(s)}finally{r.a=r.b=0}},n.wbg.__wbg_new_from_slice_db0691b69e9d3891=function(t,e){let r=new Uint32Array(te(t,e));return f(r)},n.wbg.__wbg_new_from_slice_f9c22b9153b26992=function(t,e){let r=new Uint8Array(st(t,e));return f(r)},n.wbg.__wbg_new_no_args_cb138f77cf6151ee=function(t,e){let r=new Function(I(t,e));return f(r)},n.wbg.__wbg_new_with_args_df9e7125ffe55248=function(t,e,r,o){let s=new Function(I(t,e),I(r,o));return f(s)},n.wbg.__wbg_next_138a17bbf04e926c=function(t){let e=c(t).next;return f(e)},n.wbg.__wbg_next_3cfe5c0fe2a4cc53=function(){return O(function(t){let e=c(t).next();return f(e)},arguments)},n.wbg.__wbg_now_69d776cd24f5215b=function(){return Date.now()},n.wbg.__wbg_prototypesetcall_dfe9b766cdc1f1fd=function(t,e,r){Uint8Array.prototype.set.call(st(t,e),c(r))},n.wbg.__wbg_proxycontext_new=function(t){let e=j.__wrap(t);return f(e)},n.wbg.__wbg_push_7d9be8f38fc13975=function(t,e){return c(t).push(c(e))},n.wbg.__wbg_queueMicrotask_9b549dfce8865860=function(t){let e=c(t).queueMicrotask;return f(e)},n.wbg.__wbg_queueMicrotask_fca69f5bfad613a5=function(t){queueMicrotask(c(t))},n.wbg.__wbg_resolve_fd5bfbaa4ce36e1e=function(t){let e=Promise.resolve(c(t));return f(e)},n.wbg.__wbg_set_3f1d0b984ed272ed=function(t,e,r){c(t)[d(e)]=d(r)},n.wbg.__wbg_set_781438a03c0c3c81=function(){return O(function(t,e,r){return Reflect.set(c(t),c(e),c(r))},arguments)},n.wbg.__wbg_set_7df433eea03a5c14=function(t,e,r){c(t)[e>>>0]=d(r)},n.wbg.__wbg_stack_0ed75d68575b0f3c=function(t,e){let r=c(e).stack,o=b(r,i.__wbindgen_export,i.__wbindgen_export2),s=l;a().setInt32(t+4,s,!0),a().setInt32(t+0,o,!0)},n.wbg.__wbg_static_accessor_GLOBAL_769e6b65d6557335=function(){let t=typeof global>"u"?null:global;return y(t)?0:f(t)},n.wbg.__wbg_static_accessor_GLOBAL_THIS_60cf02db4de8e1c1=function(){let t=typeof globalThis>"u"?null:globalThis;return y(t)?0:f(t)},n.wbg.__wbg_static_accessor_SELF_08f5a74c69739274=function(){let t=typeof self>"u"?null:self;return y(t)?0:f(t)},n.wbg.__wbg_static_accessor_WINDOW_a8924b26aa92d024=function(){let t=typeof window>"u"?null:window;return y(t)?0:f(t)},n.wbg.__wbg_then_4f95312d68691235=function(t,e){let r=c(t).then(c(e));return f(r)},n.wbg.__wbg_typstcompiler_new=function(t){let e=P.__wrap(t);return f(e)},n.wbg.__wbg_typstfontresolver_new=function(t){let e=M.__wrap(t);return f(e)},n.wbg.__wbg_value_57b7b035e117f7ee=function(t){let e=c(t).value;return f(e)},n.wbg.__wbindgen_cast_2241b6af4c4b2941=function(t,e){let r=I(t,e);return f(r)},n.wbg.__wbindgen_cast_3334ea73b4b28ba3=function(t,e){let r=ne(t,e,i.__wasm_bindgen_func_elem_957,ie);return f(r)},n.wbg.__wbindgen_cast_4625c577ab2ec9ee=function(t){let e=BigInt.asUintN(64,t);return f(e)},n.wbg.__wbindgen_cast_9ae0607507abb057=function(t){return f(t)},n.wbg.__wbindgen_cast_d6cd19b81560fd6e=function(t){return f(t)},n.wbg.__wbindgen_object_clone_ref=function(t){let e=c(t);return f(e)},n.wbg.__wbindgen_object_drop_ref=function(t){d(t)},n}function Mt(n,t){return i=n.exports,Ot.__wbindgen_wasm_module=t,A=null,z=null,L=null,i}function ue(n){if(i!==void 0)return i;typeof n<"u"&&(Object.getPrototypeOf(n)===Object.prototype?{module:n}=n:console.warn("using deprecated parameters for `initSync()`; pass a single object instead"));let t=At();n instanceof WebAssembly.Module||(n=new WebAssembly.Module(n));let e=new WebAssembly.Instance(n,t);return Mt(e,n)}async function Ot(n){if(i!==void 0)return i;typeof n<"u"&&(Object.getPrototypeOf(n)===Object.prototype?{module_or_path:n}=n:console.warn("using deprecated parameters for the initialization function; pass a single object instead")),typeof n>"u"&&(n=jt("typst_ts_web_compiler_bg.wasm",fe.url));let t=At();(typeof n=="string"||typeof Request=="function"&&n instanceof Request||typeof URL=="function"&&n instanceof URL)&&(n=fetch(n));let{instance:e,module:r}=await ce(await n,t);return Mt(e,r)}function _t(n){jt=n}var fe,i,ht,A,z,L,S,q,Q,re,nt,U,l,vt,rt,xt,It,kt,St,Ft,F,j,B,P,N,M,J,ae,Tt,jt,Y=pt(()=>{fe={};ht=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>n.dtor(n.a,n.b));A=null;z=null;L=null;S=new Array(128).fill(void 0);S.push(void 0,null,!0,!1);q=S.length;Q=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});Q.decode();re=2146435072,nt=0;U=new TextEncoder;"encodeInto"in U||(U.encodeInto=function(n,t){let e=U.encode(n);return t.set(e),{read:n.length,written:e.length}});l=0;vt=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>i.__wbg_incrserver_free(n>>>0,1)),rt=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>i.__wbg_proxycontext_free(n>>>0,1)),xt=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>i.__wbg_typstcompileworld_free(n>>>0,1)),It=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>i.__wbg_typstcompiler_free(n>>>0,1)),kt=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>i.__wbg_typstcompilerbuilder_free(n>>>0,1)),St=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>i.__wbg_typstfontresolver_free(n>>>0,1)),Ft=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>i.__wbg_typstfontresolverbuilder_free(n>>>0,1)),F=class n{static __wrap(t){t=t>>>0;let e=Object.create(n.prototype);return e.__wbg_ptr=t,vt.register(e,e.__wbg_ptr,e),e}__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,vt.unregister(this),t}free(){let t=this.__destroy_into_raw();i.__wbg_incrserver_free(t,0)}set_attach_debug_info(t){i.incrserver_set_attach_debug_info(this.__wbg_ptr,t)}current(){try{let r=i.__wbindgen_add_to_stack_pointer(-16);i.incrserver_current(r,this.__wbg_ptr);var t=a().getInt32(r+0,!0),e=a().getInt32(r+4,!0);let o;return t!==0&&(o=st(t,e).slice(),i.__wbindgen_export4(t,e*1,1)),o}finally{i.__wbindgen_add_to_stack_pointer(16)}}reset(){i.incrserver_reset(this.__wbg_ptr)}};Symbol.dispose&&(F.prototype[Symbol.dispose]=F.prototype.free);j=class n{static __wrap(t){t=t>>>0;let e=Object.create(n.prototype);return e.__wbg_ptr=t,rt.register(e,e.__wbg_ptr,e),e}__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,rt.unregister(this),t}free(){let t=this.__destroy_into_raw();i.__wbg_proxycontext_free(t,0)}constructor(t){let e=i.proxycontext_new(f(t));return this.__wbg_ptr=e>>>0,rt.register(this,this.__wbg_ptr,this),this}get context(){let t=i.proxycontext_context(this.__wbg_ptr);return d(t)}untar(t,e){try{let s=i.__wbindgen_add_to_stack_pointer(-16),_=Rt(t,i.__wbindgen_export),u=l;i.proxycontext_untar(s,this.__wbg_ptr,_,u,f(e));var r=a().getInt32(s+0,!0),o=a().getInt32(s+4,!0);if(o)throw d(r)}finally{i.__wbindgen_add_to_stack_pointer(16)}}};Symbol.dispose&&(j.prototype[Symbol.dispose]=j.prototype.free);B=class n{static __wrap(t){t=t>>>0;let e=Object.create(n.prototype);return e.__wbg_ptr=t,xt.register(e,e.__wbg_ptr,e),e}__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,xt.unregister(this),t}free(){let t=this.__destroy_into_raw();i.__wbg_typstcompileworld_free(t,0)}compile(t,e){try{let _=i.__wbindgen_add_to_stack_pointer(-16);i.typstcompileworld_compile(_,this.__wbg_ptr,t,e);var r=a().getInt32(_+0,!0),o=a().getInt32(_+4,!0),s=a().getInt32(_+8,!0);if(s)throw d(o);return d(r)}finally{i.__wbindgen_add_to_stack_pointer(16)}}title(t){try{let _=i.__wbindgen_add_to_stack_pointer(-16);i.typstcompileworld_title(_,this.__wbg_ptr,t);var e=a().getInt32(_+0,!0),r=a().getInt32(_+4,!0),o=a().getInt32(_+8,!0),s=a().getInt32(_+12,!0);if(s)throw d(o);let u;return e!==0&&(u=I(e,r).slice(),i.__wbindgen_export4(e,r*1,1)),u}finally{i.__wbindgen_add_to_stack_pointer(16)}}get_artifact(t,e){try{let _=i.__wbindgen_add_to_stack_pointer(-16);i.typstcompileworld_get_artifact(_,this.__wbg_ptr,t,e);var r=a().getInt32(_+0,!0),o=a().getInt32(_+4,!0),s=a().getInt32(_+8,!0);if(s)throw d(o);return d(r)}finally{i.__wbindgen_add_to_stack_pointer(16)}}query(t,e,r){let o,s;try{let k=i.__wbindgen_add_to_stack_pointer(-16),E=b(e,i.__wbindgen_export,i.__wbindgen_export2),W=l;var _=y(r)?0:b(r,i.__wbindgen_export,i.__wbindgen_export2),u=l;i.typstcompileworld_query(k,this.__wbg_ptr,t,E,W,_,u);var g=a().getInt32(k+0,!0),p=a().getInt32(k+4,!0),w=a().getInt32(k+8,!0),h=a().getInt32(k+12,!0),m=g,v=p;if(h)throw m=0,v=0,d(w);return o=m,s=v,I(m,v)}finally{i.__wbindgen_add_to_stack_pointer(16),i.__wbindgen_export4(o,s,1)}}incr_compile(t,e){try{let _=i.__wbindgen_add_to_stack_pointer(-16);ot(t,F),i.typstcompileworld_incr_compile(_,this.__wbg_ptr,t.__wbg_ptr,e);var r=a().getInt32(_+0,!0),o=a().getInt32(_+4,!0),s=a().getInt32(_+8,!0);if(s)throw d(o);return d(r)}finally{i.__wbindgen_add_to_stack_pointer(16)}}};Symbol.dispose&&(B.prototype[Symbol.dispose]=B.prototype.free);P=class n{static __wrap(t){t=t>>>0;let e=Object.create(n.prototype);return e.__wbg_ptr=t,It.register(e,e.__wbg_ptr,e),e}__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,It.unregister(this),t}free(){let t=this.__destroy_into_raw();i.__wbg_typstcompiler_free(t,0)}reset(){try{let r=i.__wbindgen_add_to_stack_pointer(-16);i.typstcompiler_reset(r,this.__wbg_ptr);var t=a().getInt32(r+0,!0),e=a().getInt32(r+4,!0);if(e)throw d(t)}finally{i.__wbindgen_add_to_stack_pointer(16)}}set_fonts(t){try{let o=i.__wbindgen_add_to_stack_pointer(-16);ot(t,M),i.typstcompiler_set_fonts(o,this.__wbg_ptr,t.__wbg_ptr);var e=a().getInt32(o+0,!0),r=a().getInt32(o+4,!0);if(r)throw d(e)}finally{i.__wbindgen_add_to_stack_pointer(16)}}set_inputs(t){try{let o=i.__wbindgen_add_to_stack_pointer(-16);i.typstcompiler_set_inputs(o,this.__wbg_ptr,f(t));var e=a().getInt32(o+0,!0),r=a().getInt32(o+4,!0);if(r)throw d(e)}finally{i.__wbindgen_add_to_stack_pointer(16)}}add_source(t,e){let r=b(t,i.__wbindgen_export,i.__wbindgen_export2),o=l,s=b(e,i.__wbindgen_export,i.__wbindgen_export2),_=l;return i.typstcompiler_add_source(this.__wbg_ptr,r,o,s,_)!==0}map_shadow(t,e){let r=b(t,i.__wbindgen_export,i.__wbindgen_export2),o=l,s=Rt(e,i.__wbindgen_export),_=l;return i.typstcompiler_map_shadow(this.__wbg_ptr,r,o,s,_)!==0}unmap_shadow(t){let e=b(t,i.__wbindgen_export,i.__wbindgen_export2),r=l;return i.typstcompiler_unmap_shadow(this.__wbg_ptr,e,r)!==0}reset_shadow(){i.typstcompiler_reset_shadow(this.__wbg_ptr)}get_loaded_fonts(){try{let o=i.__wbindgen_add_to_stack_pointer(-16);i.typstcompiler_get_loaded_fonts(o,this.__wbg_ptr);var t=a().getInt32(o+0,!0),e=a().getInt32(o+4,!0),r=Zt(t,e).slice();return i.__wbindgen_export4(t,e*4,4),r}finally{i.__wbindgen_add_to_stack_pointer(16)}}get_ast(t){let e,r;try{let w=i.__wbindgen_add_to_stack_pointer(-16),h=b(t,i.__wbindgen_export,i.__wbindgen_export2),m=l;i.typstcompiler_get_ast(w,this.__wbg_ptr,h,m);var o=a().getInt32(w+0,!0),s=a().getInt32(w+4,!0),_=a().getInt32(w+8,!0),u=a().getInt32(w+12,!0),g=o,p=s;if(u)throw g=0,p=0,d(_);return e=g,r=p,I(g,p)}finally{i.__wbindgen_add_to_stack_pointer(16),i.__wbindgen_export4(e,r,1)}}get_semantic_token_legend(){try{let o=i.__wbindgen_add_to_stack_pointer(-16);i.typstcompiler_get_semantic_token_legend(o,this.__wbg_ptr);var t=a().getInt32(o+0,!0),e=a().getInt32(o+4,!0),r=a().getInt32(o+8,!0);if(r)throw d(e);return d(t)}finally{i.__wbindgen_add_to_stack_pointer(16)}}get_semantic_tokens(t,e,r){try{let h=i.__wbindgen_add_to_stack_pointer(-16),m=b(t,i.__wbindgen_export,i.__wbindgen_export2),v=l;var o=y(e)?0:b(e,i.__wbindgen_export,i.__wbindgen_export2),s=l,_=y(r)?0:b(r,i.__wbindgen_export,i.__wbindgen_export2),u=l;i.typstcompiler_get_semantic_tokens(h,this.__wbg_ptr,m,v,o,s,_,u);var g=a().getInt32(h+0,!0),p=a().getInt32(h+4,!0),w=a().getInt32(h+8,!0);if(w)throw d(p);return d(g)}finally{i.__wbindgen_add_to_stack_pointer(16)}}snapshot(t,e,r){try{let v=i.__wbindgen_add_to_stack_pointer(-16);var o=y(t)?0:b(t,i.__wbindgen_export,i.__wbindgen_export2),s=l,_=y(e)?0:b(e,i.__wbindgen_export,i.__wbindgen_export2),u=l,g=y(r)?0:G(r,i.__wbindgen_export),p=l;i.typstcompiler_snapshot(v,this.__wbg_ptr,o,s,_,u,g,p);var w=a().getInt32(v+0,!0),h=a().getInt32(v+4,!0),m=a().getInt32(v+8,!0);if(m)throw d(h);return B.__wrap(w)}finally{i.__wbindgen_add_to_stack_pointer(16)}}get_artifact(t,e){try{let _=i.__wbindgen_add_to_stack_pointer(-16),u=b(t,i.__wbindgen_export,i.__wbindgen_export2),g=l;i.typstcompiler_get_artifact(_,this.__wbg_ptr,u,g,e);var r=a().getInt32(_+0,!0),o=a().getInt32(_+4,!0),s=a().getInt32(_+8,!0);if(s)throw d(o);return d(r)}finally{i.__wbindgen_add_to_stack_pointer(16)}}compile(t,e,r,o){try{let m=i.__wbindgen_add_to_stack_pointer(-16);var s=y(t)?0:b(t,i.__wbindgen_export,i.__wbindgen_export2),_=l,u=y(e)?0:G(e,i.__wbindgen_export),g=l;let v=b(r,i.__wbindgen_export,i.__wbindgen_export2),k=l;i.typstcompiler_compile(m,this.__wbg_ptr,s,_,u,g,v,k,o);var p=a().getInt32(m+0,!0),w=a().getInt32(m+4,!0),h=a().getInt32(m+8,!0);if(h)throw d(w);return d(p)}finally{i.__wbindgen_add_to_stack_pointer(16)}}query(t,e,r,o){let s,_;try{let D=i.__wbindgen_add_to_stack_pointer(-16),Lt=b(t,i.__wbindgen_export,i.__wbindgen_export2),qt=l;var u=y(e)?0:G(e,i.__wbindgen_export),g=l;let Ut=b(r,i.__wbindgen_export,i.__wbindgen_export2),Nt=l;var p=y(o)?0:b(o,i.__wbindgen_export,i.__wbindgen_export2),w=l;i.typstcompiler_query(D,this.__wbg_ptr,Lt,qt,u,g,Ut,Nt,p,w);var h=a().getInt32(D+0,!0),m=a().getInt32(D+4,!0),v=a().getInt32(D+8,!0),k=a().getInt32(D+12,!0),E=h,W=m;if(k)throw E=0,W=0,d(v);return s=E,_=W,I(E,W)}finally{i.__wbindgen_add_to_stack_pointer(16),i.__wbindgen_export4(s,_,1)}}create_incr_server(){try{let o=i.__wbindgen_add_to_stack_pointer(-16);i.typstcompiler_create_incr_server(o,this.__wbg_ptr);var t=a().getInt32(o+0,!0),e=a().getInt32(o+4,!0),r=a().getInt32(o+8,!0);if(r)throw d(e);return F.__wrap(t)}finally{i.__wbindgen_add_to_stack_pointer(16)}}incr_compile(t,e,r,o){try{let w=i.__wbindgen_add_to_stack_pointer(-16),h=b(t,i.__wbindgen_export,i.__wbindgen_export2),m=l;var s=y(e)?0:G(e,i.__wbindgen_export),_=l;ot(r,F),i.typstcompiler_incr_compile(w,this.__wbg_ptr,h,m,s,_,r.__wbg_ptr,o);var u=a().getInt32(w+0,!0),g=a().getInt32(w+4,!0),p=a().getInt32(w+8,!0);if(p)throw d(g);return d(u)}finally{i.__wbindgen_add_to_stack_pointer(16)}}};Symbol.dispose&&(P.prototype[Symbol.dispose]=P.prototype.free);N=class{__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,kt.unregister(this),t}free(){let t=this.__destroy_into_raw();i.__wbg_typstcompilerbuilder_free(t,0)}constructor(){try{let o=i.__wbindgen_add_to_stack_pointer(-16);i.typstcompilerbuilder_new(o);var t=a().getInt32(o+0,!0),e=a().getInt32(o+4,!0),r=a().getInt32(o+8,!0);if(r)throw d(e);return this.__wbg_ptr=t>>>0,kt.register(this,this.__wbg_ptr,this),this}finally{i.__wbindgen_add_to_stack_pointer(16)}}set_dummy_access_model(){try{let r=i.__wbindgen_add_to_stack_pointer(-16);i.typstcompilerbuilder_set_dummy_access_model(r,this.__wbg_ptr);var t=a().getInt32(r+0,!0),e=a().getInt32(r+4,!0);if(e)throw d(t)}finally{i.__wbindgen_add_to_stack_pointer(16)}}set_access_model(t,e,r,o,s){let _=i.typstcompilerbuilder_set_access_model(this.__wbg_ptr,f(t),f(e),f(r),f(o),f(s));return d(_)}set_package_registry(t,e){let r=i.typstcompilerbuilder_set_package_registry(this.__wbg_ptr,f(t),f(e));return d(r)}add_raw_font(t){let e=i.typstcompilerbuilder_add_raw_font(this.__wbg_ptr,f(t));return d(e)}add_lazy_font(t,e){let r=i.typstcompilerbuilder_add_lazy_font(this.__wbg_ptr,f(t),f(e));return d(r)}build(){let t=this.__destroy_into_raw(),e=i.typstcompilerbuilder_build(t);return d(e)}};Symbol.dispose&&(N.prototype[Symbol.dispose]=N.prototype.free);M=class n{static __wrap(t){t=t>>>0;let e=Object.create(n.prototype);return e.__wbg_ptr=t,St.register(e,e.__wbg_ptr,e),e}__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,St.unregister(this),t}free(){let t=this.__destroy_into_raw();i.__wbg_typstfontresolver_free(t,0)}};Symbol.dispose&&(M.prototype[Symbol.dispose]=M.prototype.free);J=class{__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,Ft.unregister(this),t}free(){let t=this.__destroy_into_raw();i.__wbg_typstfontresolverbuilder_free(t,0)}constructor(){try{let o=i.__wbindgen_add_to_stack_pointer(-16);i.typstfontresolverbuilder_new(o);var t=a().getInt32(o+0,!0),e=a().getInt32(o+4,!0),r=a().getInt32(o+8,!0);if(r)throw d(e);return this.__wbg_ptr=t>>>0,Ft.register(this,this.__wbg_ptr,this),this}finally{i.__wbindgen_add_to_stack_pointer(16)}}get_font_info(t){try{let s=i.__wbindgen_add_to_stack_pointer(-16);i.typstfontresolverbuilder_get_font_info(s,this.__wbg_ptr,f(t));var e=a().getInt32(s+0,!0),r=a().getInt32(s+4,!0),o=a().getInt32(s+8,!0);if(o)throw d(r);return d(e)}finally{i.__wbindgen_add_to_stack_pointer(16)}}add_raw_font(t){try{let o=i.__wbindgen_add_to_stack_pointer(-16);i.typstfontresolverbuilder_add_raw_font(o,this.__wbg_ptr,f(t));var e=a().getInt32(o+0,!0),r=a().getInt32(o+4,!0);if(r)throw d(e)}finally{i.__wbindgen_add_to_stack_pointer(16)}}add_lazy_font(t,e){try{let s=i.__wbindgen_add_to_stack_pointer(-16);i.typstfontresolverbuilder_add_lazy_font(s,this.__wbg_ptr,f(t),f(e));var r=a().getInt32(s+0,!0),o=a().getInt32(s+4,!0);if(o)throw d(r)}finally{i.__wbindgen_add_to_stack_pointer(16)}}build(){let t=this.__destroy_into_raw(),e=i.typstfontresolverbuilder_build(t);return d(e)}};Symbol.dispose&&(J.prototype[Symbol.dispose]=J.prototype.free);ae=new Set(["basic","cors","default"]);Tt=Ot,jt=async function(n,t){throw new Error("Cannot import wasm module without importer: "+n+" "+t)}});var Bt={};$t(Bt,{IncrServer:()=>F,ProxyContext:()=>j,TypstCompileWorld:()=>B,TypstCompiler:()=>P,TypstCompilerBuilder:()=>N,TypstFontResolver:()=>M,TypstFontResolverBuilder:()=>J,default:()=>de,get_font_info:()=>_e,initSync:()=>ue,setImportWasmModule:()=>_t});var de,ge,le,Pt=pt(()=>{Y();Y();Y();de=Tt,ge=async function(n,t){let e=new Function("m","return import(m)"),{readFileSync:r}=await e("fs"),o=new URL(n,t);return await r(o).buffer},le=typeof process<"u"&&process.versions!=null&&process.versions.node!=null;le&&_t(ge)});var et=class{loadedFonts=new Set;fetcher=fetch;setFetcher(t){this.fetcher=t}async loadFonts(t,e){let r=new Function("m","return import(m)"),o=this.fetcher||=await(async function(){let{fetchBuilder:u,FileSystemCache:g}=await r("node-fetch-cache"),p=new g({cacheDirectory:".cache/typst/fonts"}),w=u.withCache(p);return function(h,m){let v=setTimeout(()=>{console.warn("font fetching is stucking:",h)},15e3);return w(h,m).finally(()=>{clearTimeout(v)})}})(),s=e.filter(u=>u instanceof Uint8Array||typeof u=="object"&&"info"in u?!0:this.loadedFonts.has(u)?!1:(this.loadedFonts.add(u),!0)),_=await Promise.all(s.map(async u=>{if(u instanceof Uint8Array){await t.add_raw_font(u);return}if(typeof u=="object"&&"info"in u){await t.add_lazy_font(u,"blob"in u?u.blob:Vt(u));return}return new Uint8Array(await(await o(u)).arrayBuffer())}));for(let u of _)u&&await t.add_raw_font(u)}async build(t,e,r){let o={ref:this,builder:e,hooks:r};for(let s of t?.beforeBuild??[])await s(void 0,o);return r.latelyBuild&&r.latelyBuild(o),await e.build()}};async function wt(n,t,e,r){return await t.init(n?.getModule?.()),await new et().build(n,new e,r)}function Vt(n){return()=>{let t=new XMLHttpRequest;return t.overrideMimeType("text/plain; charset=x-user-defined"),t.open("GET",n.url,!1),t.send(null),t.status===200&&(t.response instanceof String||typeof t.response=="string")?Uint8Array.from(t.response,e=>e.charCodeAt(0)):new Uint8Array}}var x=Symbol.for("reflexo-obj");var bt;(function(n){n[n.PIXEL_PER_PT=3]="PIXEL_PER_PT"})(bt||(bt={}));var Xt=["DejaVuSansMono-Bold.ttf","DejaVuSansMono-BoldOblique.ttf","DejaVuSansMono-Oblique.ttf","DejaVuSansMono.ttf","LibertinusSerif-Bold.otf","LibertinusSerif-BoldItalic.otf","LibertinusSerif-Italic.otf","LibertinusSerif-Regular.otf","LibertinusSerif-Semibold.otf","LibertinusSerif-SemiboldItalic.otf","NewCM10-Bold.otf","NewCM10-BoldItalic.otf","NewCM10-Italic.otf","NewCM10-Regular.otf","NewCMMath-Bold.otf","NewCMMath-Book.otf","NewCMMath-Regular.otf"],Ht=["InriaSerif-Bold.ttf","InriaSerif-BoldItalic.ttf","InriaSerif-Italic.ttf","InriaSerif-Regular.ttf","Roboto-Regular.ttf","NotoSerifCJKsc-Regular.otf"],Gt=["TwitterColorEmoji.ttf","NotoColorEmoji-Regular-COLR.subset.ttf"];function Qt(n){let t=[];if(n&&n?.assets!==!1&&n?.assets?.length&&n?.assets?.length>0){let e={text:"https://cdn.jsdelivr.net/gh/typst/typst-assets@v0.13.1/files/fonts/",_:"https://cdn.jsdelivr.net/gh/typst/typst-dev-assets@v0.13.1/files/fonts/"},r=n.assetUrlPrefix??e;typeof r=="string"?r={_:r}:r={...e,...r};for(let s of Object.keys(r)){let _=r[s];_[_.length-1]!=="/"&&(r[s]=_+"/")}let o=(s,_)=>_.map(u=>(r[s]||r._)+u);for(let s of n.assets)switch(s){case"text":t.push(...o(s,Xt));break;case"cjk":t.push(...o(s,Ht));break;case"emoji":t.push(...o(s,Gt));break}}return t}function X(n,t){let e=Qt(t),r=async(o,{ref:s,builder:_})=>{t?.fetcher&&s.setFetcher(t.fetcher),await s.loadFonts(_,[...n,...e])};return r._preloadRemoteFontOptions=t,r._kind="fontLoader",r}function yt(n){return async(t,{builder:e})=>new Promise(r=>{e.set_package_registry(n,function(o){return n.resolve(o,this)}),r()})}function mt(n){return async(t,e)=>{if(e.alreadySetAccessModel)throw new Error(`already set some assess model before: ${e.alreadySetAccessModel.constructor?.name}(${e.alreadySetAccessModel})`);return e.alreadySetAccessModel=n,new Promise(r=>{e.builder.set_access_model(n,o=>{let s=n.getMTime(o);return s?s.getTime():0},o=>n.isFile(o)||!1,o=>n.getRealPath(o)||o,o=>n.readAll(o)),r()})}}var Yt=n=>{let t=!1,e;return()=>t?e:(t=!0,e=n())},H=class{wasmBin;initOnce;constructor(t){if(typeof t!="function")throw new Error("initFn is not a function");this.initOnce=Yt(async()=>{await t(this.wasmBin)})}async init(t){this.wasmBin=t,await this.initOnce()}};var at;(function(n){n[n.vector=0]="vector",n[n.pdf=1]="pdf",n[n._dummy=2]="_dummy"})(at||(at={}));var ct=class{[x];constructor(t){this[x]=t}reset(){this[x].reset()}current(){return this[x].current()}setAttachDebugInfo(t){this[x].set_attach_debug_info(t)}},Ct;Ct||(Ct={});var ut=class{[x];constructor(t){this[x]=t}compile(t){return this[x].compile(0,C(t?.diagnostics))}compileHtml(t){return this[x].compile(1,C(t?.diagnostics))}async query(t){return JSON.parse(this[x].query(0,t.selector,t.field))}title(){return this[x].title(0)}vector(t){return this[x].get_artifact(0,C(t?.diagnostics))||{}}pdf(t){return this[x].get_artifact(1,C(t?.diagnostics))||{}}},pe=n=>new H(async t=>await n.default(t));function ft(){return new K}var K=class n{compiler;compilerJs;static defaultAssets=["text"];constructor(){}async init(t){this.compilerJs=await(t?.getWrapper?.()||Promise.resolve().then(()=>(Pt(),Bt)));let e=this.compilerJs.TypstCompilerBuilder,r={...t||{}},o=r.beforeBuild??=[],s=o.some(p=>p._preloadRemoteFontOptions!==void 0),_=o.some(p=>p._preloadRemoteFontOptions?.assets!==void 0),u=o.some(p=>p._preloadRemoteFontOptions?.assets===!1);if((!s||!_&&!u)&&o.push(X([],{assets:n.defaultAssets})),!o.some(p=>p._kind==="fontLoader"))throw new Error("TypstCompiler: no font loader found, please use font loaders, e.g. loadFonts or preloadSystemFonts");this.compiler=await wt(t,pe(this.compilerJs),e,{})}setFonts(t){this.compiler.set_fonts(t)}compile(t){return new Promise(e=>{let r=this.compiler.snapshot(t.root,t.mainFilePath,Et(t.inputs));if("incrementalServer"in t){e(r.incr_compile(t.incrementalServer[x],C(t.diagnostics)));return}e(r.get_artifact(t.format||at.vector,C(t.diagnostics)))})}async runWithWorld(t,e){let r=this.compiler.snapshot(t.root,t.mainFilePath,Et(t.inputs)),o=await e(new ut(r));return r.free(),o}query(t){return this.runWithWorld(t,async e=>JSON.parse(await e.query(t)))}getSemanticTokenLegend(){return new Promise(t=>{t(this.compiler.get_semantic_token_legend())})}getSemanticTokens(t){return new Promise(e=>{this.compiler.reset(),e(this.compiler.get_semantic_tokens(t.offsetEncoding||"utf-16",t.mainFilePath,t.resultId))})}async withIncrementalServer(t){let e=new ct(this.compiler.create_incr_server());try{return await t(e)}finally{e[x].free()}}async getAst(t){return this.compiler.get_ast(t)}async reset(){await new Promise(t=>{this.compiler.reset(),t(void 0)})}addSource(t,e){if(arguments.length>2)throw new Error("use of addSource(path, source, isMain) is deprecated, please use addSource(path, source) instead");this.compiler.add_source(t,e)}mapShadow(t,e){this.compiler.map_shadow(t,e)}unmapShadow(t){this.compiler.unmap_shadow(t)}resetShadow(){this.compiler.reset_shadow()}renderPageToCanvas(){throw new Error("Please use the api TypstRenderer.renderToCanvas in v0.4.0")}};ft._impl=K;function Et(n){return n?Object.entries(n):void 0}function C(n){switch(n){case"none":return 1;case"unix":return 2;default:return 3}}var Z=class{am;cache=new Map;constructor(t){this.am=t}resolvePath(t){return`https://packages.typst.org/preview/${t.name}-${t.version}.tar.gz`}pullPackageData(t){let e=new XMLHttpRequest;if(e.overrideMimeType("text/plain; charset=x-user-defined"),e.open("GET",this.resolvePath(t),!1),e.send(null),e.status===200&&(e.response instanceof String||typeof e.response=="string"))return Uint8Array.from(e.response,r=>r.charCodeAt(0))}resolve(t,e){if(t.namespace!=="preview")return;let r=this.resolvePath(t);if(this.cache.has(r))return this.cache.get(r)();let o=this.pullPackageData(t);if(!o)return;let s=`/@memory/fetch/packages/${t.namespace}/${t.name}/${t.version}`,_=[];e.untar(o,(g,p,w)=>{_.push([s+"/"+g,p,new Date(w)])});let u=()=>{for(let[g,p,w]of _)this.am.insertFile(g,p,w);return s};return this.cache.set(r,u),u()}};var tt=class{mTimes=new Map;mData=new Map;constructor(){}reset(){this.mTimes.clear(),this.mData.clear()}insertFile(t,e,r){this.mTimes.set(t,r),this.mData.set(t,e)}removeFile(t){this.mTimes.delete(t),this.mData.delete(t)}getMTime(t){if(t.startsWith("/@memory/")&&this.mTimes.has(t))return this.mTimes.get(t)}isFile(){return!0}getRealPath(t){return t}readAll(t){if(t.startsWith("/@memory/")&&this.mData.has(t))return this.mData.get(t)}};var we=1,Wt=new tt,be=new Z(Wt),R=null;async function ye(n,t,e){R=ft(),await R.init({getModule:()=>n,beforeBuild:[X(t),...e?[mt(Wt),yt(be)]:[]]})}function me(n){let t=n.match(/(\\d+):(\\d+)-(\\d+):(\\d+)/);return t?{startLine:+t[1],startCol:+t[2],endLine:+t[3],endCol:+t[4]}:(console.warn(`[typst-web-service] Skipping diagnostic with unrecognized range format: ${JSON.stringify(n)}`),null)}async function he(n){if(!R)throw new Error("Compiler not initialized");R.addSource("/main.typ",n);let t=await R.compile({mainFilePath:"/main.typ",diagnostics:"full"});return{diagnostics:(t.diagnostics??[]).flatMap(r=>{let o=me(r.range);return o?[{...r,severity:r.severity,range:o}]:[]}),vector:t.result??void 0}}function lt(n,t){self.postMessage({type:"error",id:n,message:t instanceof Error?t.message:String(t)})}function Dt(n){return n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength)}var zt=()=>new Promise(n=>setTimeout(n,0)),$=null,dt=!1,V=null,gt=!1;async function ve(){for(dt=!0;$;){let n=$;if($=null,await zt(),$){self.postMessage({type:"cancelled",id:n.id});continue}try{let{diagnostics:t,vector:e}=await he(n.source),r=e?Dt(e):void 0,o={type:"result",id:n.id,diagnostics:t,vector:r};self.postMessage(o,r?[r]:[])}catch(t){lt(n.id,t)}}dt=!1}async function xe(){for(gt=!0;V;){let n=V;if(V=null,await zt(),V){self.postMessage({type:"cancelled",id:n.id});continue}try{if(!R)throw new Error("Compiler not initialized");R.addSource("/main.typ",n.source);let t=await R.compile({mainFilePath:"/main.typ",format:we,diagnostics:"none"});if(!t.result)throw new Error("Compilation produced no output");let e=Dt(t.result);self.postMessage({type:"pdf",id:n.id,data:e},[e])}catch(t){lt(n.id,t)}}gt=!1}self.onmessage=async n=>{let t=n.data;if(t.type==="init"){try{await ye(t.wasmUrl,t.fonts,t.packages),self.postMessage({type:"ready",id:t.id})}catch(e){lt(t.id,e)}return}if(t.type==="compile"){$=t,dt||ve();return}if(t.type==="render"){V=t,gt||xe();return}t.type==="destroy"&&self.postMessage({type:"destroyed",id:t.id})};})();\n'], { type: "application/javascript" });
36
+ const blob = new Blob(['"use strict";(()=>{var qt=Object.defineProperty;var ft=(n,t)=>()=>(n&&(t=n(n=0)),t);var Ut=(n,t)=>{for(var e in t)qt(n,e,{get:t[e],enumerable:!0})};function f(n){q===S.length&&S.push(S.length+1);let t=q;return q=S[t],S[t]=n,t}function rt(n,t){if(!(n instanceof t))throw new Error(`expected instance of ${t.name}`)}function ot(n){let t=typeof n;if(t=="number"||t=="boolean"||n==null)return`${n}`;if(t=="string")return`"${n}"`;if(t=="symbol"){let o=n.description;return o==null?"Symbol":`Symbol(${o})`}if(t=="function"){let o=n.name;return typeof o=="string"&&o.length>0?`Function(${o})`:"Function"}if(Array.isArray(n)){let o=n.length,s="[";o>0&&(s+=ot(n[0]));for(let _=1;_<o;_++)s+=", "+ot(n[_]);return s+="]",s}let e=/\\[object ([^\\]]+)\\]/.exec(toString.call(n)),r;if(e&&e.length>1)r=e[1];else return toString.call(n);if(r=="Object")try{return"Object("+JSON.stringify(n)+")"}catch{return"Object"}return n instanceof Error?`${n.name}: ${n.message}\n${n.stack}`:r}function Gt(n){n<132||(S[n]=q,q=n)}function Yt(n,t){n=n>>>0;let e=a(),r=[];for(let o=n;o<n+4*t;o+=4)r.push(d(e.getUint32(o,!0)));return r}function Kt(n,t){return n=n>>>0,Qt().subarray(n/4,n/4+t)}function it(n,t){return n=n>>>0,O().subarray(n/1,n/1+t)}function a(){return(A===null||A.buffer.detached===!0||A.buffer.detached===void 0&&A.buffer!==i.memory.buffer)&&(A=new DataView(i.memory.buffer)),A}function I(n,t){return n=n>>>0,ee(n,t)}function Qt(){return(z===null||z.byteLength===0)&&(z=new Uint32Array(i.memory.buffer)),z}function O(){return(D===null||D.byteLength===0)&&(D=new Uint8Array(i.memory.buffer)),D}function c(n){return S[n]}function T(n,t){try{return n.apply(this,t)}catch(e){i.__wbindgen_export3(f(e))}}function y(n){return n==null}function Zt(n,t,e,r){let o={a:n,b:t,cnt:1,dtor:e},s=(..._)=>{o.cnt++;let u=o.a;o.a=0;try{return r(u,o.b,..._)}finally{o.a=u,s._wbg_cb_unref()}};return s._wbg_cb_unref=()=>{--o.cnt===0&&(o.dtor(o.a,o.b),o.a=0,wt.unregister(o))},wt.register(s,o,o),s}function It(n,t){let e=t(n.length*1,1)>>>0;return O().set(n,e/1),l=n.length,e}function H(n,t){let e=t(n.length*4,4)>>>0,r=a();for(let o=0;o<n.length;o++)r.setUint32(e+4*o,f(n[o]),!0);return l=n.length,e}function b(n,t,e){if(e===void 0){let u=U.encode(n),g=t(u.length,1)>>>0;return O().subarray(g,g+u.length).set(u),l=u.length,g}let r=n.length,o=t(r,1)>>>0,s=O(),_=0;for(;_<r;_++){let u=n.charCodeAt(_);if(u>127)break;s[o+_]=u}if(_!==r){_!==0&&(n=n.slice(_)),o=e(o,r,r=_+n.length*3,1)>>>0;let u=O().subarray(o+_,o+r),g=U.encodeInto(n,u);_+=g.written,o=e(o,r,_,1)>>>0}return l=_,o}function d(n){let t=c(n);return Gt(n),t}function ee(n,t){return et+=t,et>=te&&(G=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),G.decode(),et=t),G.decode(O().subarray(n,n+t))}function ne(n,t,e){i.__wasm_bindgen_func_elem_944(n,t,f(e))}function re(n,t,e,r){i.__wasm_bindgen_func_elem_37348(n,t,f(e),f(r))}function oe(n){let t=i.get_font_info(f(n));return d(t)}async function se(n,t){if(typeof Response=="function"&&n instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(n,t)}catch(r){if(n.ok&&ie.has(n.type)&&n.headers.get("Content-Type")!=="application/wasm")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",r);else throw r}let e=await n.arrayBuffer();return await WebAssembly.instantiate(e,t)}else{let e=await WebAssembly.instantiate(n,t);return e instanceof WebAssembly.Instance?{instance:e,module:n}:e}}function kt(){let n={};return n.wbg={},n.wbg.__wbg_Error_52673b7de5a0ca89=function(t,e){let r=Error(I(t,e));return f(r)},n.wbg.__wbg_Number_2d1dcfcf4ec51736=function(t){return Number(c(t))},n.wbg.__wbg___wbindgen_bigint_get_as_i64_6e32f5e6aff02e1d=function(t,e){let r=c(e),o=typeof r=="bigint"?r:void 0;a().setBigInt64(t+8,y(o)?BigInt(0):o,!0),a().setInt32(t+0,!y(o),!0)},n.wbg.__wbg___wbindgen_boolean_get_dea25b33882b895b=function(t){let e=c(t),r=typeof e=="boolean"?e:void 0;return y(r)?16777215:r?1:0},n.wbg.__wbg___wbindgen_debug_string_adfb662ae34724b6=function(t,e){let r=ot(c(e)),o=b(r,i.__wbindgen_export,i.__wbindgen_export2),s=l;a().setInt32(t+4,s,!0),a().setInt32(t+0,o,!0)},n.wbg.__wbg___wbindgen_in_0d3e1e8f0c669317=function(t,e){return c(t)in c(e)},n.wbg.__wbg___wbindgen_is_bigint_0e1a2e3f55cfae27=function(t){return typeof c(t)=="bigint"},n.wbg.__wbg___wbindgen_is_function_8d400b8b1af978cd=function(t){return typeof c(t)=="function"},n.wbg.__wbg___wbindgen_is_object_ce774f3490692386=function(t){let e=c(t);return typeof e=="object"&&e!==null},n.wbg.__wbg___wbindgen_is_string_704ef9c8fc131030=function(t){return typeof c(t)=="string"},n.wbg.__wbg___wbindgen_is_undefined_f6b95eab589e0269=function(t){return c(t)===void 0},n.wbg.__wbg___wbindgen_jsval_eq_b6101cc9cef1fe36=function(t,e){return c(t)===c(e)},n.wbg.__wbg___wbindgen_jsval_loose_eq_766057600fdd1b0d=function(t,e){return c(t)==c(e)},n.wbg.__wbg___wbindgen_number_get_9619185a74197f95=function(t,e){let r=c(e),o=typeof r=="number"?r:void 0;a().setFloat64(t+8,y(o)?0:o,!0),a().setInt32(t+0,!y(o),!0)},n.wbg.__wbg___wbindgen_string_get_a2a31e16edf96e42=function(t,e){let r=c(e),o=typeof r=="string"?r:void 0;var s=y(o)?0:b(o,i.__wbindgen_export,i.__wbindgen_export2),_=l;a().setInt32(t+4,_,!0),a().setInt32(t+0,s,!0)},n.wbg.__wbg___wbindgen_throw_dd24417ed36fc46e=function(t,e){throw new Error(I(t,e))},n.wbg.__wbg__wbg_cb_unref_87dfb5aaa0cbcea7=function(t){c(t)._wbg_cb_unref()},n.wbg.__wbg_call_3020136f7a2d6e44=function(){return T(function(t,e,r){let o=c(t).call(c(e),c(r));return f(o)},arguments)},n.wbg.__wbg_call_78f94eb02ec7f9b2=function(){return T(function(t,e,r,o,s){let _=c(t).call(c(e),c(r),c(o),c(s));return f(_)},arguments)},n.wbg.__wbg_call_abb4ff46ce38be40=function(){return T(function(t,e){let r=c(t).call(c(e));return f(r)},arguments)},n.wbg.__wbg_done_62ea16af4ce34b24=function(t){return c(t).done},n.wbg.__wbg_entries_83c79938054e065f=function(t){let e=Object.entries(c(t));return f(e)},n.wbg.__wbg_error_7534b8e9a36f1ab4=function(t,e){let r,o;try{r=t,o=e,console.error(I(t,e))}finally{i.__wbindgen_export4(r,o,1)}},n.wbg.__wbg_error_85faeb8919b11cc6=function(t,e,r){console.error(c(t),c(e),c(r))},n.wbg.__wbg_getTimezoneOffset_45389e26d6f46823=function(t){return c(t).getTimezoneOffset()},n.wbg.__wbg_get_6b7bd52aca3f9671=function(t,e){let r=c(t)[e>>>0];return f(r)},n.wbg.__wbg_get_af9dab7e9603ea93=function(){return T(function(t,e){let r=Reflect.get(c(t),c(e));return f(r)},arguments)},n.wbg.__wbg_get_with_ref_key_1dc361bd10053bfe=function(t,e){let r=c(t)[c(e)];return f(r)},n.wbg.__wbg_info_ce6bcc489c22f6f0=function(t){console.info(c(t))},n.wbg.__wbg_instanceof_ArrayBuffer_f3320d2419cd0355=function(t){let e;try{e=c(t)instanceof ArrayBuffer}catch{e=!1}return e},n.wbg.__wbg_instanceof_Map_084be8da74364158=function(t){let e;try{e=c(t)instanceof Map}catch{e=!1}return e},n.wbg.__wbg_instanceof_Uint8Array_da54ccc9d3e09434=function(t){let e;try{e=c(t)instanceof Uint8Array}catch{e=!1}return e},n.wbg.__wbg_isArray_51fd9e6422c0a395=function(t){return Array.isArray(c(t))},n.wbg.__wbg_isSafeInteger_ae7d3f054d55fa16=function(t){return Number.isSafeInteger(c(t))},n.wbg.__wbg_iterator_27b7c8b35ab3e86b=function(){return f(Symbol.iterator)},n.wbg.__wbg_length_22ac23eaec9d8053=function(t){return c(t).length},n.wbg.__wbg_length_d45040a40c570362=function(t){return c(t).length},n.wbg.__wbg_new_1ba21ce319a06297=function(){let t=new Object;return f(t)},n.wbg.__wbg_new_25f239778d6112b9=function(){let t=new Array;return f(t)},n.wbg.__wbg_new_6421f6084cc5bc5a=function(t){let e=new Uint8Array(c(t));return f(e)},n.wbg.__wbg_new_8a6f238a6ece86ea=function(){let t=new Error;return f(t)},n.wbg.__wbg_new_b2db8aa2650f793a=function(t){let e=new Date(c(t));return f(e)},n.wbg.__wbg_new_df1173567d5ff028=function(t,e){let r=new Error(I(t,e));return f(r)},n.wbg.__wbg_new_ff12d2b041fb48f1=function(t,e){try{var r={a:t,b:e},o=(_,u)=>{let g=r.a;r.a=0;try{return re(g,r.b,_,u)}finally{r.a=g}};let s=new Promise(o);return f(s)}finally{r.a=r.b=0}},n.wbg.__wbg_new_from_slice_db0691b69e9d3891=function(t,e){let r=new Uint32Array(Kt(t,e));return f(r)},n.wbg.__wbg_new_from_slice_f9c22b9153b26992=function(t,e){let r=new Uint8Array(it(t,e));return f(r)},n.wbg.__wbg_new_no_args_cb138f77cf6151ee=function(t,e){let r=new Function(I(t,e));return f(r)},n.wbg.__wbg_new_with_args_df9e7125ffe55248=function(t,e,r,o){let s=new Function(I(t,e),I(r,o));return f(s)},n.wbg.__wbg_next_138a17bbf04e926c=function(t){let e=c(t).next;return f(e)},n.wbg.__wbg_next_3cfe5c0fe2a4cc53=function(){return T(function(t){let e=c(t).next();return f(e)},arguments)},n.wbg.__wbg_now_69d776cd24f5215b=function(){return Date.now()},n.wbg.__wbg_prototypesetcall_dfe9b766cdc1f1fd=function(t,e,r){Uint8Array.prototype.set.call(it(t,e),c(r))},n.wbg.__wbg_proxycontext_new=function(t){let e=j.__wrap(t);return f(e)},n.wbg.__wbg_push_7d9be8f38fc13975=function(t,e){return c(t).push(c(e))},n.wbg.__wbg_queueMicrotask_9b549dfce8865860=function(t){let e=c(t).queueMicrotask;return f(e)},n.wbg.__wbg_queueMicrotask_fca69f5bfad613a5=function(t){queueMicrotask(c(t))},n.wbg.__wbg_resolve_fd5bfbaa4ce36e1e=function(t){let e=Promise.resolve(c(t));return f(e)},n.wbg.__wbg_set_3f1d0b984ed272ed=function(t,e,r){c(t)[d(e)]=d(r)},n.wbg.__wbg_set_781438a03c0c3c81=function(){return T(function(t,e,r){return Reflect.set(c(t),c(e),c(r))},arguments)},n.wbg.__wbg_set_7df433eea03a5c14=function(t,e,r){c(t)[e>>>0]=d(r)},n.wbg.__wbg_stack_0ed75d68575b0f3c=function(t,e){let r=c(e).stack,o=b(r,i.__wbindgen_export,i.__wbindgen_export2),s=l;a().setInt32(t+4,s,!0),a().setInt32(t+0,o,!0)},n.wbg.__wbg_static_accessor_GLOBAL_769e6b65d6557335=function(){let t=typeof global>"u"?null:global;return y(t)?0:f(t)},n.wbg.__wbg_static_accessor_GLOBAL_THIS_60cf02db4de8e1c1=function(){let t=typeof globalThis>"u"?null:globalThis;return y(t)?0:f(t)},n.wbg.__wbg_static_accessor_SELF_08f5a74c69739274=function(){let t=typeof self>"u"?null:self;return y(t)?0:f(t)},n.wbg.__wbg_static_accessor_WINDOW_a8924b26aa92d024=function(){let t=typeof window>"u"?null:window;return y(t)?0:f(t)},n.wbg.__wbg_then_4f95312d68691235=function(t,e){let r=c(t).then(c(e));return f(r)},n.wbg.__wbg_typstcompiler_new=function(t){let e=E.__wrap(t);return f(e)},n.wbg.__wbg_typstfontresolver_new=function(t){let e=M.__wrap(t);return f(e)},n.wbg.__wbg_value_57b7b035e117f7ee=function(t){let e=c(t).value;return f(e)},n.wbg.__wbindgen_cast_2241b6af4c4b2941=function(t,e){let r=I(t,e);return f(r)},n.wbg.__wbindgen_cast_3334ea73b4b28ba3=function(t,e){let r=Zt(t,e,i.__wasm_bindgen_func_elem_957,ne);return f(r)},n.wbg.__wbindgen_cast_4625c577ab2ec9ee=function(t){let e=BigInt.asUintN(64,t);return f(e)},n.wbg.__wbindgen_cast_9ae0607507abb057=function(t){return f(t)},n.wbg.__wbindgen_cast_d6cd19b81560fd6e=function(t){return f(t)},n.wbg.__wbindgen_object_clone_ref=function(t){let e=c(t);return f(e)},n.wbg.__wbindgen_object_drop_ref=function(t){d(t)},n}function St(n,t){return i=n.exports,Ft.__wbindgen_wasm_module=t,A=null,z=null,D=null,i}function _e(n){if(i!==void 0)return i;typeof n<"u"&&(Object.getPrototypeOf(n)===Object.prototype?{module:n}=n:console.warn("using deprecated parameters for `initSync()`; pass a single object instead"));let t=kt();n instanceof WebAssembly.Module||(n=new WebAssembly.Module(n));let e=new WebAssembly.Instance(n,t);return St(e,n)}async function Ft(n){if(i!==void 0)return i;typeof n<"u"&&(Object.getPrototypeOf(n)===Object.prototype?{module_or_path:n}=n:console.warn("using deprecated parameters for the initialization function; pass a single object instead")),typeof n>"u"&&(n=At("typst_ts_web_compiler_bg.wasm",ae.url));let t=kt();(typeof n=="string"||typeof Request=="function"&&n instanceof Request||typeof URL=="function"&&n instanceof URL)&&(n=fetch(n));let{instance:e,module:r}=await se(await n,t);return St(e,r)}function st(n){At=n}var ae,i,wt,A,z,D,S,q,G,te,et,U,l,bt,nt,yt,mt,ht,vt,xt,F,j,B,E,N,M,J,ie,Rt,At,Y=ft(()=>{ae={};wt=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>n.dtor(n.a,n.b));A=null;z=null;D=null;S=new Array(128).fill(void 0);S.push(void 0,null,!0,!1);q=S.length;G=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});G.decode();te=2146435072,et=0;U=new TextEncoder;"encodeInto"in U||(U.encodeInto=function(n,t){let e=U.encode(n);return t.set(e),{read:n.length,written:e.length}});l=0;bt=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>i.__wbg_incrserver_free(n>>>0,1)),nt=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>i.__wbg_proxycontext_free(n>>>0,1)),yt=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>i.__wbg_typstcompileworld_free(n>>>0,1)),mt=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>i.__wbg_typstcompiler_free(n>>>0,1)),ht=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>i.__wbg_typstcompilerbuilder_free(n>>>0,1)),vt=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>i.__wbg_typstfontresolver_free(n>>>0,1)),xt=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>i.__wbg_typstfontresolverbuilder_free(n>>>0,1)),F=class n{static __wrap(t){t=t>>>0;let e=Object.create(n.prototype);return e.__wbg_ptr=t,bt.register(e,e.__wbg_ptr,e),e}__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,bt.unregister(this),t}free(){let t=this.__destroy_into_raw();i.__wbg_incrserver_free(t,0)}set_attach_debug_info(t){i.incrserver_set_attach_debug_info(this.__wbg_ptr,t)}current(){try{let r=i.__wbindgen_add_to_stack_pointer(-16);i.incrserver_current(r,this.__wbg_ptr);var t=a().getInt32(r+0,!0),e=a().getInt32(r+4,!0);let o;return t!==0&&(o=it(t,e).slice(),i.__wbindgen_export4(t,e*1,1)),o}finally{i.__wbindgen_add_to_stack_pointer(16)}}reset(){i.incrserver_reset(this.__wbg_ptr)}};Symbol.dispose&&(F.prototype[Symbol.dispose]=F.prototype.free);j=class n{static __wrap(t){t=t>>>0;let e=Object.create(n.prototype);return e.__wbg_ptr=t,nt.register(e,e.__wbg_ptr,e),e}__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,nt.unregister(this),t}free(){let t=this.__destroy_into_raw();i.__wbg_proxycontext_free(t,0)}constructor(t){let e=i.proxycontext_new(f(t));return this.__wbg_ptr=e>>>0,nt.register(this,this.__wbg_ptr,this),this}get context(){let t=i.proxycontext_context(this.__wbg_ptr);return d(t)}untar(t,e){try{let s=i.__wbindgen_add_to_stack_pointer(-16),_=It(t,i.__wbindgen_export),u=l;i.proxycontext_untar(s,this.__wbg_ptr,_,u,f(e));var r=a().getInt32(s+0,!0),o=a().getInt32(s+4,!0);if(o)throw d(r)}finally{i.__wbindgen_add_to_stack_pointer(16)}}};Symbol.dispose&&(j.prototype[Symbol.dispose]=j.prototype.free);B=class n{static __wrap(t){t=t>>>0;let e=Object.create(n.prototype);return e.__wbg_ptr=t,yt.register(e,e.__wbg_ptr,e),e}__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,yt.unregister(this),t}free(){let t=this.__destroy_into_raw();i.__wbg_typstcompileworld_free(t,0)}compile(t,e){try{let _=i.__wbindgen_add_to_stack_pointer(-16);i.typstcompileworld_compile(_,this.__wbg_ptr,t,e);var r=a().getInt32(_+0,!0),o=a().getInt32(_+4,!0),s=a().getInt32(_+8,!0);if(s)throw d(o);return d(r)}finally{i.__wbindgen_add_to_stack_pointer(16)}}title(t){try{let _=i.__wbindgen_add_to_stack_pointer(-16);i.typstcompileworld_title(_,this.__wbg_ptr,t);var e=a().getInt32(_+0,!0),r=a().getInt32(_+4,!0),o=a().getInt32(_+8,!0),s=a().getInt32(_+12,!0);if(s)throw d(o);let u;return e!==0&&(u=I(e,r).slice(),i.__wbindgen_export4(e,r*1,1)),u}finally{i.__wbindgen_add_to_stack_pointer(16)}}get_artifact(t,e){try{let _=i.__wbindgen_add_to_stack_pointer(-16);i.typstcompileworld_get_artifact(_,this.__wbg_ptr,t,e);var r=a().getInt32(_+0,!0),o=a().getInt32(_+4,!0),s=a().getInt32(_+8,!0);if(s)throw d(o);return d(r)}finally{i.__wbindgen_add_to_stack_pointer(16)}}query(t,e,r){let o,s;try{let k=i.__wbindgen_add_to_stack_pointer(-16),C=b(e,i.__wbindgen_export,i.__wbindgen_export2),W=l;var _=y(r)?0:b(r,i.__wbindgen_export,i.__wbindgen_export2),u=l;i.typstcompileworld_query(k,this.__wbg_ptr,t,C,W,_,u);var g=a().getInt32(k+0,!0),p=a().getInt32(k+4,!0),w=a().getInt32(k+8,!0),h=a().getInt32(k+12,!0),m=g,v=p;if(h)throw m=0,v=0,d(w);return o=m,s=v,I(m,v)}finally{i.__wbindgen_add_to_stack_pointer(16),i.__wbindgen_export4(o,s,1)}}incr_compile(t,e){try{let _=i.__wbindgen_add_to_stack_pointer(-16);rt(t,F),i.typstcompileworld_incr_compile(_,this.__wbg_ptr,t.__wbg_ptr,e);var r=a().getInt32(_+0,!0),o=a().getInt32(_+4,!0),s=a().getInt32(_+8,!0);if(s)throw d(o);return d(r)}finally{i.__wbindgen_add_to_stack_pointer(16)}}};Symbol.dispose&&(B.prototype[Symbol.dispose]=B.prototype.free);E=class n{static __wrap(t){t=t>>>0;let e=Object.create(n.prototype);return e.__wbg_ptr=t,mt.register(e,e.__wbg_ptr,e),e}__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,mt.unregister(this),t}free(){let t=this.__destroy_into_raw();i.__wbg_typstcompiler_free(t,0)}reset(){try{let r=i.__wbindgen_add_to_stack_pointer(-16);i.typstcompiler_reset(r,this.__wbg_ptr);var t=a().getInt32(r+0,!0),e=a().getInt32(r+4,!0);if(e)throw d(t)}finally{i.__wbindgen_add_to_stack_pointer(16)}}set_fonts(t){try{let o=i.__wbindgen_add_to_stack_pointer(-16);rt(t,M),i.typstcompiler_set_fonts(o,this.__wbg_ptr,t.__wbg_ptr);var e=a().getInt32(o+0,!0),r=a().getInt32(o+4,!0);if(r)throw d(e)}finally{i.__wbindgen_add_to_stack_pointer(16)}}set_inputs(t){try{let o=i.__wbindgen_add_to_stack_pointer(-16);i.typstcompiler_set_inputs(o,this.__wbg_ptr,f(t));var e=a().getInt32(o+0,!0),r=a().getInt32(o+4,!0);if(r)throw d(e)}finally{i.__wbindgen_add_to_stack_pointer(16)}}add_source(t,e){let r=b(t,i.__wbindgen_export,i.__wbindgen_export2),o=l,s=b(e,i.__wbindgen_export,i.__wbindgen_export2),_=l;return i.typstcompiler_add_source(this.__wbg_ptr,r,o,s,_)!==0}map_shadow(t,e){let r=b(t,i.__wbindgen_export,i.__wbindgen_export2),o=l,s=It(e,i.__wbindgen_export),_=l;return i.typstcompiler_map_shadow(this.__wbg_ptr,r,o,s,_)!==0}unmap_shadow(t){let e=b(t,i.__wbindgen_export,i.__wbindgen_export2),r=l;return i.typstcompiler_unmap_shadow(this.__wbg_ptr,e,r)!==0}reset_shadow(){i.typstcompiler_reset_shadow(this.__wbg_ptr)}get_loaded_fonts(){try{let o=i.__wbindgen_add_to_stack_pointer(-16);i.typstcompiler_get_loaded_fonts(o,this.__wbg_ptr);var t=a().getInt32(o+0,!0),e=a().getInt32(o+4,!0),r=Yt(t,e).slice();return i.__wbindgen_export4(t,e*4,4),r}finally{i.__wbindgen_add_to_stack_pointer(16)}}get_ast(t){let e,r;try{let w=i.__wbindgen_add_to_stack_pointer(-16),h=b(t,i.__wbindgen_export,i.__wbindgen_export2),m=l;i.typstcompiler_get_ast(w,this.__wbg_ptr,h,m);var o=a().getInt32(w+0,!0),s=a().getInt32(w+4,!0),_=a().getInt32(w+8,!0),u=a().getInt32(w+12,!0),g=o,p=s;if(u)throw g=0,p=0,d(_);return e=g,r=p,I(g,p)}finally{i.__wbindgen_add_to_stack_pointer(16),i.__wbindgen_export4(e,r,1)}}get_semantic_token_legend(){try{let o=i.__wbindgen_add_to_stack_pointer(-16);i.typstcompiler_get_semantic_token_legend(o,this.__wbg_ptr);var t=a().getInt32(o+0,!0),e=a().getInt32(o+4,!0),r=a().getInt32(o+8,!0);if(r)throw d(e);return d(t)}finally{i.__wbindgen_add_to_stack_pointer(16)}}get_semantic_tokens(t,e,r){try{let h=i.__wbindgen_add_to_stack_pointer(-16),m=b(t,i.__wbindgen_export,i.__wbindgen_export2),v=l;var o=y(e)?0:b(e,i.__wbindgen_export,i.__wbindgen_export2),s=l,_=y(r)?0:b(r,i.__wbindgen_export,i.__wbindgen_export2),u=l;i.typstcompiler_get_semantic_tokens(h,this.__wbg_ptr,m,v,o,s,_,u);var g=a().getInt32(h+0,!0),p=a().getInt32(h+4,!0),w=a().getInt32(h+8,!0);if(w)throw d(p);return d(g)}finally{i.__wbindgen_add_to_stack_pointer(16)}}snapshot(t,e,r){try{let v=i.__wbindgen_add_to_stack_pointer(-16);var o=y(t)?0:b(t,i.__wbindgen_export,i.__wbindgen_export2),s=l,_=y(e)?0:b(e,i.__wbindgen_export,i.__wbindgen_export2),u=l,g=y(r)?0:H(r,i.__wbindgen_export),p=l;i.typstcompiler_snapshot(v,this.__wbg_ptr,o,s,_,u,g,p);var w=a().getInt32(v+0,!0),h=a().getInt32(v+4,!0),m=a().getInt32(v+8,!0);if(m)throw d(h);return B.__wrap(w)}finally{i.__wbindgen_add_to_stack_pointer(16)}}get_artifact(t,e){try{let _=i.__wbindgen_add_to_stack_pointer(-16),u=b(t,i.__wbindgen_export,i.__wbindgen_export2),g=l;i.typstcompiler_get_artifact(_,this.__wbg_ptr,u,g,e);var r=a().getInt32(_+0,!0),o=a().getInt32(_+4,!0),s=a().getInt32(_+8,!0);if(s)throw d(o);return d(r)}finally{i.__wbindgen_add_to_stack_pointer(16)}}compile(t,e,r,o){try{let m=i.__wbindgen_add_to_stack_pointer(-16);var s=y(t)?0:b(t,i.__wbindgen_export,i.__wbindgen_export2),_=l,u=y(e)?0:H(e,i.__wbindgen_export),g=l;let v=b(r,i.__wbindgen_export,i.__wbindgen_export2),k=l;i.typstcompiler_compile(m,this.__wbg_ptr,s,_,u,g,v,k,o);var p=a().getInt32(m+0,!0),w=a().getInt32(m+4,!0),h=a().getInt32(m+8,!0);if(h)throw d(w);return d(p)}finally{i.__wbindgen_add_to_stack_pointer(16)}}query(t,e,r,o){let s,_;try{let L=i.__wbindgen_add_to_stack_pointer(-16),Wt=b(t,i.__wbindgen_export,i.__wbindgen_export2),Lt=l;var u=y(e)?0:H(e,i.__wbindgen_export),g=l;let zt=b(r,i.__wbindgen_export,i.__wbindgen_export2),Dt=l;var p=y(o)?0:b(o,i.__wbindgen_export,i.__wbindgen_export2),w=l;i.typstcompiler_query(L,this.__wbg_ptr,Wt,Lt,u,g,zt,Dt,p,w);var h=a().getInt32(L+0,!0),m=a().getInt32(L+4,!0),v=a().getInt32(L+8,!0),k=a().getInt32(L+12,!0),C=h,W=m;if(k)throw C=0,W=0,d(v);return s=C,_=W,I(C,W)}finally{i.__wbindgen_add_to_stack_pointer(16),i.__wbindgen_export4(s,_,1)}}create_incr_server(){try{let o=i.__wbindgen_add_to_stack_pointer(-16);i.typstcompiler_create_incr_server(o,this.__wbg_ptr);var t=a().getInt32(o+0,!0),e=a().getInt32(o+4,!0),r=a().getInt32(o+8,!0);if(r)throw d(e);return F.__wrap(t)}finally{i.__wbindgen_add_to_stack_pointer(16)}}incr_compile(t,e,r,o){try{let w=i.__wbindgen_add_to_stack_pointer(-16),h=b(t,i.__wbindgen_export,i.__wbindgen_export2),m=l;var s=y(e)?0:H(e,i.__wbindgen_export),_=l;rt(r,F),i.typstcompiler_incr_compile(w,this.__wbg_ptr,h,m,s,_,r.__wbg_ptr,o);var u=a().getInt32(w+0,!0),g=a().getInt32(w+4,!0),p=a().getInt32(w+8,!0);if(p)throw d(g);return d(u)}finally{i.__wbindgen_add_to_stack_pointer(16)}}};Symbol.dispose&&(E.prototype[Symbol.dispose]=E.prototype.free);N=class{__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,ht.unregister(this),t}free(){let t=this.__destroy_into_raw();i.__wbg_typstcompilerbuilder_free(t,0)}constructor(){try{let o=i.__wbindgen_add_to_stack_pointer(-16);i.typstcompilerbuilder_new(o);var t=a().getInt32(o+0,!0),e=a().getInt32(o+4,!0),r=a().getInt32(o+8,!0);if(r)throw d(e);return this.__wbg_ptr=t>>>0,ht.register(this,this.__wbg_ptr,this),this}finally{i.__wbindgen_add_to_stack_pointer(16)}}set_dummy_access_model(){try{let r=i.__wbindgen_add_to_stack_pointer(-16);i.typstcompilerbuilder_set_dummy_access_model(r,this.__wbg_ptr);var t=a().getInt32(r+0,!0),e=a().getInt32(r+4,!0);if(e)throw d(t)}finally{i.__wbindgen_add_to_stack_pointer(16)}}set_access_model(t,e,r,o,s){let _=i.typstcompilerbuilder_set_access_model(this.__wbg_ptr,f(t),f(e),f(r),f(o),f(s));return d(_)}set_package_registry(t,e){let r=i.typstcompilerbuilder_set_package_registry(this.__wbg_ptr,f(t),f(e));return d(r)}add_raw_font(t){let e=i.typstcompilerbuilder_add_raw_font(this.__wbg_ptr,f(t));return d(e)}add_lazy_font(t,e){let r=i.typstcompilerbuilder_add_lazy_font(this.__wbg_ptr,f(t),f(e));return d(r)}build(){let t=this.__destroy_into_raw(),e=i.typstcompilerbuilder_build(t);return d(e)}};Symbol.dispose&&(N.prototype[Symbol.dispose]=N.prototype.free);M=class n{static __wrap(t){t=t>>>0;let e=Object.create(n.prototype);return e.__wbg_ptr=t,vt.register(e,e.__wbg_ptr,e),e}__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,vt.unregister(this),t}free(){let t=this.__destroy_into_raw();i.__wbg_typstfontresolver_free(t,0)}};Symbol.dispose&&(M.prototype[Symbol.dispose]=M.prototype.free);J=class{__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,xt.unregister(this),t}free(){let t=this.__destroy_into_raw();i.__wbg_typstfontresolverbuilder_free(t,0)}constructor(){try{let o=i.__wbindgen_add_to_stack_pointer(-16);i.typstfontresolverbuilder_new(o);var t=a().getInt32(o+0,!0),e=a().getInt32(o+4,!0),r=a().getInt32(o+8,!0);if(r)throw d(e);return this.__wbg_ptr=t>>>0,xt.register(this,this.__wbg_ptr,this),this}finally{i.__wbindgen_add_to_stack_pointer(16)}}get_font_info(t){try{let s=i.__wbindgen_add_to_stack_pointer(-16);i.typstfontresolverbuilder_get_font_info(s,this.__wbg_ptr,f(t));var e=a().getInt32(s+0,!0),r=a().getInt32(s+4,!0),o=a().getInt32(s+8,!0);if(o)throw d(r);return d(e)}finally{i.__wbindgen_add_to_stack_pointer(16)}}add_raw_font(t){try{let o=i.__wbindgen_add_to_stack_pointer(-16);i.typstfontresolverbuilder_add_raw_font(o,this.__wbg_ptr,f(t));var e=a().getInt32(o+0,!0),r=a().getInt32(o+4,!0);if(r)throw d(e)}finally{i.__wbindgen_add_to_stack_pointer(16)}}add_lazy_font(t,e){try{let s=i.__wbindgen_add_to_stack_pointer(-16);i.typstfontresolverbuilder_add_lazy_font(s,this.__wbg_ptr,f(t),f(e));var r=a().getInt32(s+0,!0),o=a().getInt32(s+4,!0);if(o)throw d(r)}finally{i.__wbindgen_add_to_stack_pointer(16)}}build(){let t=this.__destroy_into_raw(),e=i.typstfontresolverbuilder_build(t);return d(e)}};Symbol.dispose&&(J.prototype[Symbol.dispose]=J.prototype.free);ie=new Set(["basic","cors","default"]);Rt=Ft,At=async function(n,t){throw new Error("Cannot import wasm module without importer: "+n+" "+t)}});var Mt={};Ut(Mt,{IncrServer:()=>F,ProxyContext:()=>j,TypstCompileWorld:()=>B,TypstCompiler:()=>E,TypstCompilerBuilder:()=>N,TypstFontResolver:()=>M,TypstFontResolverBuilder:()=>J,default:()=>ce,get_font_info:()=>oe,initSync:()=>_e,setImportWasmModule:()=>st});var ce,ue,fe,Tt=ft(()=>{Y();Y();Y();ce=Rt,ue=async function(n,t){let e=new Function("m","return import(m)"),{readFileSync:r}=await e("fs"),o=new URL(n,t);return await r(o).buffer},fe=typeof process<"u"&&process.versions!=null&&process.versions.node!=null;fe&&st(ue)});var tt=class{loadedFonts=new Set;fetcher=fetch;setFetcher(t){this.fetcher=t}async loadFonts(t,e){let r=new Function("m","return import(m)"),o=this.fetcher||=await(async function(){let{fetchBuilder:u,FileSystemCache:g}=await r("node-fetch-cache"),p=new g({cacheDirectory:".cache/typst/fonts"}),w=u.withCache(p);return function(h,m){let v=setTimeout(()=>{console.warn("font fetching is stucking:",h)},15e3);return w(h,m).finally(()=>{clearTimeout(v)})}})(),s=e.filter(u=>u instanceof Uint8Array||typeof u=="object"&&"info"in u?!0:this.loadedFonts.has(u)?!1:(this.loadedFonts.add(u),!0)),_=await Promise.all(s.map(async u=>{if(u instanceof Uint8Array){await t.add_raw_font(u);return}if(typeof u=="object"&&"info"in u){await t.add_lazy_font(u,"blob"in u?u.blob:Nt(u));return}return new Uint8Array(await(await o(u)).arrayBuffer())}));for(let u of _)u&&await t.add_raw_font(u)}async build(t,e,r){let o={ref:this,builder:e,hooks:r};for(let s of t?.beforeBuild??[])await s(void 0,o);return r.latelyBuild&&r.latelyBuild(o),await e.build()}};async function dt(n,t,e,r){return await t.init(n?.getModule?.()),await new tt().build(n,new e,r)}function Nt(n){return()=>{let t=new XMLHttpRequest;return t.overrideMimeType("text/plain; charset=x-user-defined"),t.open("GET",n.url,!1),t.send(null),t.status===200&&(t.response instanceof String||typeof t.response=="string")?Uint8Array.from(t.response,e=>e.charCodeAt(0)):new Uint8Array}}var x=Symbol.for("reflexo-obj");var gt;(function(n){n[n.PIXEL_PER_PT=3]="PIXEL_PER_PT"})(gt||(gt={}));var Jt=["DejaVuSansMono-Bold.ttf","DejaVuSansMono-BoldOblique.ttf","DejaVuSansMono-Oblique.ttf","DejaVuSansMono.ttf","LibertinusSerif-Bold.otf","LibertinusSerif-BoldItalic.otf","LibertinusSerif-Italic.otf","LibertinusSerif-Regular.otf","LibertinusSerif-Semibold.otf","LibertinusSerif-SemiboldItalic.otf","NewCM10-Bold.otf","NewCM10-BoldItalic.otf","NewCM10-Italic.otf","NewCM10-Regular.otf","NewCMMath-Bold.otf","NewCMMath-Book.otf","NewCMMath-Regular.otf"],$t=["InriaSerif-Bold.ttf","InriaSerif-BoldItalic.ttf","InriaSerif-Italic.ttf","InriaSerif-Regular.ttf","Roboto-Regular.ttf","NotoSerifCJKsc-Regular.otf"],Vt=["TwitterColorEmoji.ttf","NotoColorEmoji-Regular-COLR.subset.ttf"];function Xt(n){let t=[];if(n&&n?.assets!==!1&&n?.assets?.length&&n?.assets?.length>0){let e={text:"https://cdn.jsdelivr.net/gh/typst/typst-assets@v0.13.1/files/fonts/",_:"https://cdn.jsdelivr.net/gh/typst/typst-dev-assets@v0.13.1/files/fonts/"},r=n.assetUrlPrefix??e;typeof r=="string"?r={_:r}:r={...e,...r};for(let s of Object.keys(r)){let _=r[s];_[_.length-1]!=="/"&&(r[s]=_+"/")}let o=(s,_)=>_.map(u=>(r[s]||r._)+u);for(let s of n.assets)switch(s){case"text":t.push(...o(s,Jt));break;case"cjk":t.push(...o(s,$t));break;case"emoji":t.push(...o(s,Vt));break}}return t}function V(n,t){let e=Xt(t),r=async(o,{ref:s,builder:_})=>{t?.fetcher&&s.setFetcher(t.fetcher),await s.loadFonts(_,[...n,...e])};return r._preloadRemoteFontOptions=t,r._kind="fontLoader",r}function lt(n){return async(t,{builder:e})=>new Promise(r=>{e.set_package_registry(n,function(o){return n.resolve(o,this)}),r()})}function pt(n){return async(t,e)=>{if(e.alreadySetAccessModel)throw new Error(`already set some assess model before: ${e.alreadySetAccessModel.constructor?.name}(${e.alreadySetAccessModel})`);return e.alreadySetAccessModel=n,new Promise(r=>{e.builder.set_access_model(n,o=>{let s=n.getMTime(o);return s?s.getTime():0},o=>n.isFile(o)||!1,o=>n.getRealPath(o)||o,o=>n.readAll(o)),r()})}}var Ht=n=>{let t=!1,e;return()=>t?e:(t=!0,e=n())},X=class{wasmBin;initOnce;constructor(t){if(typeof t!="function")throw new Error("initFn is not a function");this.initOnce=Ht(async()=>{await t(this.wasmBin)})}async init(t){this.wasmBin=t,await this.initOnce()}};var $;(function(n){n[n.vector=0]="vector",n[n.pdf=1]="pdf",n[n._dummy=2]="_dummy"})($||($={}));var _t=class{[x];constructor(t){this[x]=t}reset(){this[x].reset()}current(){return this[x].current()}setAttachDebugInfo(t){this[x].set_attach_debug_info(t)}},Ot;Ot||(Ot={});var at=class{[x];constructor(t){this[x]=t}compile(t){return this[x].compile(0,P(t?.diagnostics))}compileHtml(t){return this[x].compile(1,P(t?.diagnostics))}async query(t){return JSON.parse(this[x].query(0,t.selector,t.field))}title(){return this[x].title(0)}vector(t){return this[x].get_artifact(0,P(t?.diagnostics))||{}}pdf(t){return this[x].get_artifact(1,P(t?.diagnostics))||{}}},de=n=>new X(async t=>await n.default(t));function ct(){return new K}var K=class n{compiler;compilerJs;static defaultAssets=["text"];constructor(){}async init(t){this.compilerJs=await(t?.getWrapper?.()||Promise.resolve().then(()=>(Tt(),Mt)));let e=this.compilerJs.TypstCompilerBuilder,r={...t||{}},o=r.beforeBuild??=[],s=o.some(p=>p._preloadRemoteFontOptions!==void 0),_=o.some(p=>p._preloadRemoteFontOptions?.assets!==void 0),u=o.some(p=>p._preloadRemoteFontOptions?.assets===!1);if((!s||!_&&!u)&&o.push(V([],{assets:n.defaultAssets})),!o.some(p=>p._kind==="fontLoader"))throw new Error("TypstCompiler: no font loader found, please use font loaders, e.g. loadFonts or preloadSystemFonts");this.compiler=await dt(t,de(this.compilerJs),e,{})}setFonts(t){this.compiler.set_fonts(t)}compile(t){return new Promise(e=>{let r=this.compiler.snapshot(t.root,t.mainFilePath,jt(t.inputs));if("incrementalServer"in t){e(r.incr_compile(t.incrementalServer[x],P(t.diagnostics)));return}e(r.get_artifact(t.format||$.vector,P(t.diagnostics)))})}async runWithWorld(t,e){let r=this.compiler.snapshot(t.root,t.mainFilePath,jt(t.inputs)),o=await e(new at(r));return r.free(),o}query(t){return this.runWithWorld(t,async e=>JSON.parse(await e.query(t)))}getSemanticTokenLegend(){return new Promise(t=>{t(this.compiler.get_semantic_token_legend())})}getSemanticTokens(t){return new Promise(e=>{this.compiler.reset(),e(this.compiler.get_semantic_tokens(t.offsetEncoding||"utf-16",t.mainFilePath,t.resultId))})}async withIncrementalServer(t){let e=new _t(this.compiler.create_incr_server());try{return await t(e)}finally{e[x].free()}}async getAst(t){return this.compiler.get_ast(t)}async reset(){await new Promise(t=>{this.compiler.reset(),t(void 0)})}addSource(t,e){if(arguments.length>2)throw new Error("use of addSource(path, source, isMain) is deprecated, please use addSource(path, source) instead");this.compiler.add_source(t,e)}mapShadow(t,e){this.compiler.map_shadow(t,e)}unmapShadow(t){this.compiler.unmap_shadow(t)}resetShadow(){this.compiler.reset_shadow()}renderPageToCanvas(){throw new Error("Please use the api TypstRenderer.renderToCanvas in v0.4.0")}};ct._impl=K;function jt(n){return n?Object.entries(n):void 0}function P(n){switch(n){case"none":return 1;case"unix":return 2;default:return 3}}var Q=class{mTimes=new Map;mData=new Map;constructor(){}reset(){this.mTimes.clear(),this.mData.clear()}insertFile(t,e,r){this.mTimes.set(t,r),this.mData.set(t,e)}removeFile(t){this.mTimes.delete(t),this.mData.delete(t)}getMTime(t){if(t.startsWith("/@memory/")&&this.mTimes.has(t))return this.mTimes.get(t)}isFile(){return!0}getRealPath(t){return t}readAll(t){if(t.startsWith("/@memory/")&&this.mData.has(t))return this.mData.get(t)}};var Z=class{am;cache=new Map;constructor(t){this.am=t}resolvePath(t){return`https://packages.typst.org/preview/${t.name}-${t.version}.tar.gz`}pullPackageData(t){let e=new XMLHttpRequest;if(e.overrideMimeType("text/plain; charset=x-user-defined"),e.open("GET",this.resolvePath(t),!1),e.send(null),e.status===200&&(e.response instanceof String||typeof e.response=="string"))return Uint8Array.from(e.response,r=>r.charCodeAt(0))}resolve(t,e){if(t.namespace!=="preview")return;let r=this.resolvePath(t);if(this.cache.has(r))return this.cache.get(r)();let o=this.pullPackageData(t);if(!o)return;let s=`/@memory/fetch/packages/${t.namespace}/${t.name}/${t.version}`,_=[];e.untar(o,(g,p,w)=>{_.push([s+"/"+g,p,new Date(w)])});let u=()=>{for(let[g,p,w]of _)this.am.insertFile(g,p,w);return s};return this.cache.set(r,u),u()}};var Bt="/main.typ",Et=new Q,ge=new Z(Et),R=null;async function le(n,t,e){R=ct(),await R.init({getModule:()=>n,beforeBuild:[V(t),...e?[pt(Et),lt(ge)]:[]]})}function pe(n){let t=n.match(/(\\d+):(\\d+)-(\\d+):(\\d+)/);return t?{startLine:+t[1],startCol:+t[2],endLine:+t[3],endCol:+t[4]}:(console.warn(`[typst-web-service] Skipping diagnostic with unrecognized range format: ${JSON.stringify(n)}`),null)}async function we(n){if(!R)throw new Error("Compiler not initialized");for(let[r,o]of Object.entries(n))R.addSource(r,o);let t=await R.compile({mainFilePath:Bt,diagnostics:"full"});return{diagnostics:(t.diagnostics??[]).flatMap(r=>{let o=pe(r.range);return o?[{...r,severity:r.severity,range:o}]:[]}),vector:t.result??void 0}}function ut(n,t){self.postMessage({type:"error",id:n,message:t instanceof Error?t.message:String(t)})}function Pt(n){return n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength)}var be=()=>new Promise(n=>setTimeout(n,0));function Ct(n){let t=null,e=!1;async function r(){for(e=!0;t;){let o=t;if(t=null,await be(),t){self.postMessage({type:"cancelled",id:o.id});continue}await n(o)}e=!1}return o=>{t=o,e||r()}}var ye=Ct(async n=>{try{let{diagnostics:t,vector:e}=await we(n.files),r=e?Pt(e):void 0,o={type:"result",id:n.id,diagnostics:t,vector:r};self.postMessage(o,r?[r]:[])}catch(t){ut(n.id,t)}}),me=Ct(async n=>{try{if(!R)throw new Error("Compiler not initialized");for(let[r,o]of Object.entries(n.files))R.addSource(r,o);let t=await R.compile({mainFilePath:Bt,format:$.pdf,diagnostics:"none"});if(!t.result)throw new Error("Compilation produced no output");let e=Pt(t.result);self.postMessage({type:"pdf",id:n.id,data:e},[e])}catch(t){ut(n.id,t)}});self.onmessage=async n=>{let t=n.data;if(t.type==="init"){try{await le(t.wasmUrl,t.fonts,t.packages),self.postMessage({type:"ready",id:t.id})}catch(e){ut(t.id,e)}return}if(t.type==="compile"){ye(t);return}if(t.type==="render"){me(t);return}t.type==="destroy"&&self.postMessage({type:"destroyed",id:t.id})};})();\n'], { type: "application/javascript" });
11
37
  const url = URL.createObjectURL(blob);
12
38
  const worker = new Worker(url);
13
39
  const origTerminate = worker.terminate.bind(worker);
@@ -40,6 +66,7 @@ var DEFAULT_FONTS = [
40
66
  ];
41
67
  var DEFAULT_WASM_URL = "https://cdn.jsdelivr.net/npm/@myriaddreamin/typst-ts-web-compiler@0.7.0-rc2/pkg/typst_ts_web_compiler_bg.wasm";
42
68
  var DEFAULT_RENDERER_WASM_URL = "https://cdn.jsdelivr.net/npm/@myriaddreamin/typst-ts-renderer@0.7.0-rc2/pkg/typst_ts_renderer_bg.wasm";
69
+ var TIMEOUT = { INIT: 6e4, RENDER: 6e4, DESTROY: 5e3 };
43
70
  var _TypstService_instances, initRenderer_fn, vectorToSvg_fn, emitSvg_fn;
44
71
  var _TypstService = class _TypstService {
45
72
  constructor(worker, options = {}) {
@@ -48,7 +75,7 @@ var _TypstService = class _TypstService {
48
75
  this.idCounter = 0;
49
76
  this.onSvg = options.renderer?.onSvg;
50
77
  if (options.renderer) {
51
- this.rendererInstance = __privateMethod(this, _TypstService_instances, initRenderer_fn).call(this, options.renderer.module ?? (() => import("@myriaddreamin/typst-ts-renderer")), options.renderer.wasmUrl);
78
+ this.rendererInstance = __privateMethod(this, _TypstService_instances, initRenderer_fn).call(this, options.renderer.module, options.renderer.wasmUrl);
52
79
  this.rendererReady = this.rendererInstance.then(() => {
53
80
  });
54
81
  }
@@ -61,19 +88,21 @@ var _TypstService = class _TypstService {
61
88
  fonts: options.fonts ?? DEFAULT_FONTS,
62
89
  packages: options.packages ?? true
63
90
  },
64
- 6e4
91
+ TIMEOUT.INIT
65
92
  ).then((res) => {
66
93
  if (res.type === "error")
67
94
  throw new Error(`TypstService init failed: ${res.message}`);
68
95
  });
69
96
  }
97
+ /** Compile a single source string (treated as /main.typ) or a map of files. */
70
98
  async compile(source) {
71
99
  await this.ready;
72
100
  const id = ++this.idCounter;
101
+ const files = typeof source === "string" ? { "/main.typ": source } : source;
73
102
  const response = await workerRpc(this.worker, {
74
103
  type: "compile",
75
104
  id,
76
- source
105
+ files
77
106
  });
78
107
  if (response.type === "cancelled") return { diagnostics: [] };
79
108
  if (response.type === "result") {
@@ -96,10 +125,16 @@ var _TypstService = class _TypstService {
96
125
  const renderer = await this.rendererInstance;
97
126
  return __privateMethod(this, _TypstService_instances, vectorToSvg_fn).call(this, renderer, vector);
98
127
  }
128
+ /** Render to PDF from a single source string (treated as /main.typ) or a map of files. */
99
129
  async renderPdf(source) {
100
130
  await this.ready;
101
131
  const id = ++this.idCounter;
102
- const response = await workerRpc(this.worker, { type: "render", id, source }, 6e4);
132
+ const files = typeof source === "string" ? { "/main.typ": source } : source;
133
+ const response = await workerRpc(
134
+ this.worker,
135
+ { type: "render", id, files },
136
+ TIMEOUT.RENDER
137
+ );
103
138
  if (response.type === "cancelled") throw new Error("Render cancelled");
104
139
  if (response.type === "pdf") return new Uint8Array(response.data);
105
140
  if (response.type === "error") throw new Error(response.message);
@@ -117,7 +152,7 @@ var _TypstService = class _TypstService {
117
152
  }
118
153
  destroy() {
119
154
  const id = ++this.idCounter;
120
- workerRpc(this.worker, { type: "destroy", id }, 5e3).catch((err) => console.error("TypstService destroy failed:", err)).finally(() => this.worker.terminate());
155
+ workerRpc(this.worker, { type: "destroy", id }, TIMEOUT.DESTROY).catch((err) => console.error("TypstService destroy failed:", err)).finally(() => this.worker.terminate());
121
156
  }
122
157
  };
123
158
  _TypstService_instances = new WeakSet();
@@ -145,6 +180,7 @@ emitSvg_fn = async function(vector) {
145
180
  };
146
181
  var TypstService = _TypstService;
147
182
  export {
183
+ TypstFormatter,
148
184
  TypstService
149
185
  };
150
186
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/rpc.ts","../src/service.ts"],"sourcesContent":["import type { WorkerRequest, WorkerResponse } from \"./types.js\";\n\n// Injected at build time by tsup (see tsup.config.ts)\ndeclare const __WORKER_CODE__: string;\n\nexport function createWorker(): Worker {\n const blob = new Blob([__WORKER_CODE__], { type: \"application/javascript\" });\n const url = URL.createObjectURL(blob);\n const worker = new Worker(url);\n const origTerminate = worker.terminate.bind(worker);\n worker.terminate = () => {\n origTerminate();\n URL.revokeObjectURL(url);\n };\n return worker;\n}\n\nexport function workerRpc(\n worker: Worker,\n request: WorkerRequest,\n timeoutMs = 30_000,\n): Promise<WorkerResponse> {\n return new Promise((resolve, reject) => {\n const handler = (e: MessageEvent<WorkerResponse>) => {\n if (e.data.id !== request.id) return;\n clearTimeout(timer);\n worker.removeEventListener(\"message\", handler);\n resolve(e.data);\n };\n const timer = setTimeout(() => {\n worker.removeEventListener(\"message\", handler);\n reject(new Error(`typst worker timed out after ${timeoutMs}ms`));\n }, timeoutMs);\n worker.addEventListener(\"message\", handler);\n worker.postMessage(request);\n });\n}\n","import type { DiagnosticMessage } from \"./types.js\";\nimport { createWorker, workerRpc } from \"./rpc.js\";\n\nexport interface CompileResult {\n diagnostics: DiagnosticMessage[];\n /** Vector artifact bytes from the compiler, usable with typst-ts-renderer for SVG rendering. */\n vector?: Uint8Array;\n}\n\ntype RendererModuleExports = {\n default: (wasmUrl?: string) => Promise<unknown>;\n TypstRendererBuilder: new () => {\n build(): Promise<RendererInstance>;\n };\n};\n\n/** Minimal interface for the built TypstRenderer. */\nexport interface RendererInstance {\n create_session(): RendererSession;\n manipulate_data(session: RendererSession, action: string, data: Uint8Array): void;\n svg_data(session: RendererSession): string;\n}\n\n/** Minimal interface for a TypstRenderer session. */\nexport interface RendererSession {\n free(): void;\n}\n\n/** Options for the opt-in SVG renderer. */\nexport interface RendererOptions {\n /** Dynamic import for the renderer module. Defaults to `() => import('@myriaddreamin/typst-ts-renderer')`. */\n module?: () => Promise<RendererModuleExports>;\n /** URL to the typst-ts-renderer WASM binary. Defaults to jsDelivr CDN. */\n wasmUrl?: string;\n /** Called after each compile with the rendered SVG string. */\n onSvg: (svg: string) => void;\n}\n\nexport interface TypstServiceOptions {\n /**\n * URL to the typst-ts-web-compiler WASM binary.\n * Defaults to the matching version on jsDelivr CDN.\n * Override with a local asset URL for offline support or faster load:\n * `new URL('@myriaddreamin/typst-ts-web-compiler/pkg/typst_ts_web_compiler_bg.wasm', import.meta.url).href`\n */\n wasmUrl?: string;\n /** Font URLs to load into the Typst compiler. Defaults to Roboto from jsDelivr. */\n fonts?: string[];\n /**\n * Enable fetching @preview/ packages from packages.typst.org on demand.\n * Default: true.\n */\n packages?: boolean;\n /**\n * Opt-in SVG preview. When set, the renderer is initialized lazily and `onSvg`\n * is called after each successful compile.\n *\n * Example:\n * renderer: {\n * onSvg: (svg) => { previewEl.innerHTML = svg },\n * }\n */\n renderer?: RendererOptions;\n}\n\nconst DEFAULT_FONTS = [\n \"https://cdn.jsdelivr.net/npm/roboto-font@0.1.0/fonts/Roboto/roboto-regular-webfont.ttf\",\n];\n\nconst DEFAULT_WASM_URL =\n \"https://cdn.jsdelivr.net/npm/@myriaddreamin/typst-ts-web-compiler@0.7.0-rc2/pkg/typst_ts_web_compiler_bg.wasm\";\n\nconst DEFAULT_RENDERER_WASM_URL =\n \"https://cdn.jsdelivr.net/npm/@myriaddreamin/typst-ts-renderer@0.7.0-rc2/pkg/typst_ts_renderer_bg.wasm\";\n\n/**\n * Manages a Typst compiler worker. Create one instance and share it across\n * all extensions (linter, autocomplete, preview, etc.).\n *\n * Prefer constructing with an explicit Worker for Vite apps:\n * new TypstService(new Worker(new URL('typst-web-service/worker', import.meta.url)), options)\n *\n * Or use createTypstService() for a zero-config setup via an inlined blob worker.\n */\nexport class TypstService {\n readonly ready: Promise<void>;\n /** Resolves when the SVG renderer is ready, or rejects if it failed to initialize. Undefined if no renderer was configured. */\n readonly rendererReady?: Promise<void>;\n private idCounter = 0;\n\n private onSvg?: (svg: string) => void;\n private rendererInstance?: Promise<RendererInstance>;\n\n /** The most recent vector artifact from a compile, if any. */\n lastVector?: Uint8Array;\n\n constructor(\n private worker: Worker,\n options: TypstServiceOptions = {},\n ) {\n this.onSvg = options.renderer?.onSvg;\n\n if (options.renderer) {\n this.rendererInstance = this.#initRenderer(\n options.renderer.module ?? (() => import(\"@myriaddreamin/typst-ts-renderer\")),\n options.renderer.wasmUrl,\n );\n this.rendererReady = this.rendererInstance.then(() => {});\n }\n\n this.ready = workerRpc(\n this.worker,\n {\n type: \"init\",\n id: ++this.idCounter,\n wasmUrl: options.wasmUrl ?? DEFAULT_WASM_URL,\n fonts: options.fonts ?? DEFAULT_FONTS,\n packages: options.packages ?? true,\n },\n 60_000,\n ).then((res) => {\n if (res.type === \"error\")\n throw new Error(`TypstService init failed: ${res.message}`);\n });\n }\n\n async #initRenderer(\n loadModule: () => Promise<RendererModuleExports>,\n wasmUrl?: string,\n ): Promise<RendererInstance> {\n const mod = await loadModule();\n await mod.default(wasmUrl ?? DEFAULT_RENDERER_WASM_URL);\n return new mod.TypstRendererBuilder().build();\n }\n\n #vectorToSvg(renderer: RendererInstance, vector: Uint8Array): string {\n const session = renderer.create_session();\n try {\n renderer.manipulate_data(session, \"reset\", vector);\n return renderer.svg_data(session);\n } finally {\n session.free();\n }\n }\n\n async compile(source: string): Promise<CompileResult> {\n await this.ready;\n const id = ++this.idCounter;\n const response = await workerRpc(this.worker, {\n type: \"compile\",\n id,\n source,\n });\n if (response.type === \"cancelled\") return { diagnostics: [] };\n if (response.type === \"result\") {\n const vector = response.vector ? new Uint8Array(response.vector) : undefined;\n if (vector) {\n this.lastVector = vector;\n this.#emitSvg(vector);\n }\n return { diagnostics: response.diagnostics, vector };\n }\n if (response.type === \"error\") throw new Error(response.message);\n return { diagnostics: [] };\n }\n\n async #emitSvg(vector: Uint8Array): Promise<void> {\n if (!this.onSvg || !this.rendererInstance) return;\n try {\n const renderer = await this.rendererInstance;\n this.onSvg(this.#vectorToSvg(renderer, vector));\n } catch {\n // renderer init failed; observable via rendererReady\n }\n }\n\n /**\n * Render a vector artifact to an SVG string.\n * Requires the `renderer` option to be set. Returns null if the renderer is unavailable.\n */\n async renderSvg(vector: Uint8Array): Promise<string | null> {\n if (!this.rendererInstance) return null;\n const renderer = await this.rendererInstance;\n return this.#vectorToSvg(renderer, vector);\n }\n\n async renderPdf(source: string): Promise<Uint8Array> {\n await this.ready;\n const id = ++this.idCounter;\n const response = await workerRpc(this.worker, { type: \"render\", id, source }, 60_000);\n if (response.type === \"cancelled\") throw new Error(\"Render cancelled\");\n if (response.type === \"pdf\") return new Uint8Array(response.data);\n if (response.type === \"error\") throw new Error(response.message);\n throw new Error(\"Unexpected response type\");\n }\n\n /**\n * Create a TypstService using an inlined worker blob.\n * Works without any bundler configuration.\n *\n * For Vite apps, prefer the explicit Worker constructor to avoid the blob indirection:\n * new TypstService(new Worker(new URL('typst-web-service/worker', import.meta.url)), options)\n */\n static create(options: TypstServiceOptions = {}): TypstService {\n return new TypstService(createWorker(), options);\n }\n\n destroy(): void {\n const id = ++this.idCounter;\n workerRpc(this.worker, { type: \"destroy\", id }, 5_000)\n .catch((err) => console.error(\"TypstService destroy failed:\", err))\n .finally(() => this.worker.terminate());\n }\n}\n\n"],"mappings":";;;;;;;;AAKO,SAAS,eAAuB;AACrC,QAAM,OAAO,IAAI,KAAK,CAAC,4pmCAAe,GAAG,EAAE,MAAM,yBAAyB,CAAC;AAC3E,QAAM,MAAM,IAAI,gBAAgB,IAAI;AACpC,QAAM,SAAS,IAAI,OAAO,GAAG;AAC7B,QAAM,gBAAgB,OAAO,UAAU,KAAK,MAAM;AAClD,SAAO,YAAY,MAAM;AACvB,kBAAc;AACd,QAAI,gBAAgB,GAAG;AAAA,EACzB;AACA,SAAO;AACT;AAEO,SAAS,UACd,QACA,SACA,YAAY,KACa;AACzB,SAAO,IAAI,QAAQ,CAAC,SAAS,WAAW;AACtC,UAAM,UAAU,CAAC,MAAoC;AACnD,UAAI,EAAE,KAAK,OAAO,QAAQ,GAAI;AAC9B,mBAAa,KAAK;AAClB,aAAO,oBAAoB,WAAW,OAAO;AAC7C,cAAQ,EAAE,IAAI;AAAA,IAChB;AACA,UAAM,QAAQ,WAAW,MAAM;AAC7B,aAAO,oBAAoB,WAAW,OAAO;AAC7C,aAAO,IAAI,MAAM,gCAAgC,SAAS,IAAI,CAAC;AAAA,IACjE,GAAG,SAAS;AACZ,WAAO,iBAAiB,WAAW,OAAO;AAC1C,WAAO,YAAY,OAAO;AAAA,EAC5B,CAAC;AACH;;;AC6BA,IAAM,gBAAgB;AAAA,EACpB;AACF;AAEA,IAAM,mBACJ;AAEF,IAAM,4BACJ;AAzEF;AAoFO,IAAM,gBAAN,MAAM,cAAa;AAAA,EAYxB,YACU,QACR,UAA+B,CAAC,GAChC;AAFQ;AAbL;AAIL,SAAQ,YAAY;AAYlB,SAAK,QAAQ,QAAQ,UAAU;AAE/B,QAAI,QAAQ,UAAU;AACpB,WAAK,mBAAmB,sBAAK,0CAAL,WACtB,QAAQ,SAAS,WAAW,MAAM,OAAO,kCAAkC,IAC3E,QAAQ,SAAS;AAEnB,WAAK,gBAAgB,KAAK,iBAAiB,KAAK,MAAM;AAAA,MAAC,CAAC;AAAA,IAC1D;AAEA,SAAK,QAAQ;AAAA,MACX,KAAK;AAAA,MACL;AAAA,QACE,MAAM;AAAA,QACN,IAAI,EAAE,KAAK;AAAA,QACX,SAAS,QAAQ,WAAW;AAAA,QAC5B,OAAO,QAAQ,SAAS;AAAA,QACxB,UAAU,QAAQ,YAAY;AAAA,MAChC;AAAA,MACA;AAAA,IACF,EAAE,KAAK,CAAC,QAAQ;AACd,UAAI,IAAI,SAAS;AACf,cAAM,IAAI,MAAM,6BAA6B,IAAI,OAAO,EAAE;AAAA,IAC9D,CAAC;AAAA,EACH;AAAA,EAqBA,MAAM,QAAQ,QAAwC;AACpD,UAAM,KAAK;AACX,UAAM,KAAK,EAAE,KAAK;AAClB,UAAM,WAAW,MAAM,UAAU,KAAK,QAAQ;AAAA,MAC5C,MAAM;AAAA,MACN;AAAA,MACA;AAAA,IACF,CAAC;AACD,QAAI,SAAS,SAAS,YAAa,QAAO,EAAE,aAAa,CAAC,EAAE;AAC5D,QAAI,SAAS,SAAS,UAAU;AAC9B,YAAM,SAAS,SAAS,SAAS,IAAI,WAAW,SAAS,MAAM,IAAI;AACnE,UAAI,QAAQ;AACV,aAAK,aAAa;AAClB,8BAAK,qCAAL,WAAc;AAAA,MAChB;AACA,aAAO,EAAE,aAAa,SAAS,aAAa,OAAO;AAAA,IACrD;AACA,QAAI,SAAS,SAAS,QAAS,OAAM,IAAI,MAAM,SAAS,OAAO;AAC/D,WAAO,EAAE,aAAa,CAAC,EAAE;AAAA,EAC3B;AAAA;AAAA;AAAA;AAAA;AAAA,EAgBA,MAAM,UAAU,QAA4C;AAC1D,QAAI,CAAC,KAAK,iBAAkB,QAAO;AACnC,UAAM,WAAW,MAAM,KAAK;AAC5B,WAAO,sBAAK,yCAAL,WAAkB,UAAU;AAAA,EACrC;AAAA,EAEA,MAAM,UAAU,QAAqC;AACnD,UAAM,KAAK;AACX,UAAM,KAAK,EAAE,KAAK;AAClB,UAAM,WAAW,MAAM,UAAU,KAAK,QAAQ,EAAE,MAAM,UAAU,IAAI,OAAO,GAAG,GAAM;AACpF,QAAI,SAAS,SAAS,YAAa,OAAM,IAAI,MAAM,kBAAkB;AACrE,QAAI,SAAS,SAAS,MAAO,QAAO,IAAI,WAAW,SAAS,IAAI;AAChE,QAAI,SAAS,SAAS,QAAS,OAAM,IAAI,MAAM,SAAS,OAAO;AAC/D,UAAM,IAAI,MAAM,0BAA0B;AAAA,EAC5C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,OAAO,OAAO,UAA+B,CAAC,GAAiB;AAC7D,WAAO,IAAI,cAAa,aAAa,GAAG,OAAO;AAAA,EACjD;AAAA,EAEA,UAAgB;AACd,UAAM,KAAK,EAAE,KAAK;AAClB,cAAU,KAAK,QAAQ,EAAE,MAAM,WAAW,GAAG,GAAG,GAAK,EAClD,MAAM,CAAC,QAAQ,QAAQ,MAAM,gCAAgC,GAAG,CAAC,EACjE,QAAQ,MAAM,KAAK,OAAO,UAAU,CAAC;AAAA,EAC1C;AACF;AAjIO;AA0CC,kBAAa,eACjB,YACA,SAC2B;AAC3B,QAAM,MAAM,MAAM,WAAW;AAC7B,QAAM,IAAI,QAAQ,WAAW,yBAAyB;AACtD,SAAO,IAAI,IAAI,qBAAqB,EAAE,MAAM;AAC9C;AAEA,iBAAY,SAAC,UAA4B,QAA4B;AACnE,QAAM,UAAU,SAAS,eAAe;AACxC,MAAI;AACF,aAAS,gBAAgB,SAAS,SAAS,MAAM;AACjD,WAAO,SAAS,SAAS,OAAO;AAAA,EAClC,UAAE;AACA,YAAQ,KAAK;AAAA,EACf;AACF;AAuBM,aAAQ,eAAC,QAAmC;AAChD,MAAI,CAAC,KAAK,SAAS,CAAC,KAAK,iBAAkB;AAC3C,MAAI;AACF,UAAM,WAAW,MAAM,KAAK;AAC5B,SAAK,MAAM,sBAAK,yCAAL,WAAkB,UAAU,OAAO;AAAA,EAChD,QAAQ;AAAA,EAER;AACF;AA1FK,IAAM,eAAN;","names":[]}
1
+ {"version":3,"sources":["../src/formatter.ts","../src/rpc.ts","../src/service.ts"],"sourcesContent":["export interface FormatConfig {\n /** Number of spaces per indentation level. Default: 2 */\n tab_spaces?: number;\n /** Maximum line width. Default: 80 */\n max_width?: number;\n /** Maximum consecutive blank lines allowed. */\n blank_lines_upper_bound?: number;\n /** Collapse consecutive whitespace in markup to a single space. */\n collapse_markup_spaces?: boolean;\n /** Sort import items alphabetically. */\n reorder_import_items?: boolean;\n /** Wrap text in markup to fit within max_width. Implies collapse_markup_spaces. */\n wrap_text?: boolean;\n}\n\nexport interface FormatRangeResult {\n /** Start index (UTF-16) of the actual formatted range. */\n start: number;\n /** End index (UTF-16) of the actual formatted range. */\n end: number;\n /** The formatted text for the range. */\n text: string;\n}\n\ntype TypstyleModule = typeof import(\"@typstyle/typstyle-wasm-bundler\");\n\nlet typstylePromise: Promise<TypstyleModule> | null = null;\n\nfunction getTypstyle(): Promise<TypstyleModule> {\n if (!typstylePromise) {\n typstylePromise = import(\"@typstyle/typstyle-wasm-bundler\");\n }\n return typstylePromise;\n}\n\n/**\n * Typst code formatter powered by typstyle.\n *\n * Runs on the main thread — typstyle is lightweight and fast.\n * The WASM module is loaded lazily on first format call.\n *\n * const formatter = new TypstFormatter({ tab_spaces: 2, max_width: 80 });\n * const formatted = await formatter.format(source);\n */\nexport class TypstFormatter {\n private config: FormatConfig;\n\n constructor(config: FormatConfig = {}) {\n this.config = config;\n // Eagerly start loading WASM so it's ready by first use\n getTypstyle();\n }\n\n /** Format an entire Typst source string. */\n async format(source: string): Promise<string> {\n const typstyle = await getTypstyle();\n return typstyle.format(source, this.config);\n }\n\n /** Format a range within a Typst source string. Indices are UTF-16 code units. */\n async formatRange(\n source: string,\n start: number,\n end: number,\n ): Promise<FormatRangeResult> {\n const typstyle = await getTypstyle();\n const result = typstyle.format_range(source, start, end, this.config);\n return { start: result.start, end: result.end, text: result.text };\n }\n}\n","import type { WorkerRequest, WorkerResponse } from \"./types.js\";\n\n// Injected at build time by tsup (see tsup.config.ts)\ndeclare const __WORKER_CODE__: string;\n\nexport function createWorker(): Worker {\n const blob = new Blob([__WORKER_CODE__], { type: \"application/javascript\" });\n const url = URL.createObjectURL(blob);\n const worker = new Worker(url);\n const origTerminate = worker.terminate.bind(worker);\n worker.terminate = () => {\n origTerminate();\n URL.revokeObjectURL(url);\n };\n return worker;\n}\n\nexport function workerRpc(\n worker: Worker,\n request: WorkerRequest,\n timeoutMs = 30_000,\n): Promise<WorkerResponse> {\n return new Promise((resolve, reject) => {\n const handler = (e: MessageEvent<WorkerResponse>) => {\n if (e.data.id !== request.id) return;\n clearTimeout(timer);\n worker.removeEventListener(\"message\", handler);\n resolve(e.data);\n };\n const timer = setTimeout(() => {\n worker.removeEventListener(\"message\", handler);\n reject(new Error(`typst worker timed out after ${timeoutMs}ms`));\n }, timeoutMs);\n worker.addEventListener(\"message\", handler);\n worker.postMessage(request);\n });\n}\n","import { createWorker, workerRpc } from \"./rpc.js\";\nimport type { DiagnosticMessage } from \"./types.js\";\n\nexport interface CompileResult {\n diagnostics: DiagnosticMessage[];\n /** Vector artifact bytes from the compiler, usable with typst-ts-renderer for SVG rendering. */\n vector?: Uint8Array;\n}\n\n/**\n * A dynamic `import()` expression that resolves to the `@myriaddreamin/typst-ts-renderer` module.\n * Keeps the renderer dependency opt-in — users who only need diagnostics never load the WASM.\n */\nexport type RendererModule = () => Promise<{\n default: (wasmUrl?: string) => Promise<unknown>;\n TypstRendererBuilder: new () => {\n build(): Promise<RendererInstance>;\n };\n}>;\n\n/** Minimal interface for the built TypstRenderer. */\nexport interface RendererInstance {\n create_session(): RendererSession;\n manipulate_data(\n session: RendererSession,\n action: string,\n data: Uint8Array,\n ): void;\n svg_data(session: RendererSession): string;\n}\n\n/** Minimal interface for a TypstRenderer session. */\nexport interface RendererSession {\n free(): void;\n}\n\n/** Options for the opt-in SVG renderer. */\nexport interface RendererOptions {\n /**\n * Dynamic import for the renderer module.\n * Example: () => import('@myriaddreamin/typst-ts-renderer')\n */\n module: RendererModule;\n /** URL to the typst-ts-renderer WASM binary. Defaults to jsDelivr CDN. */\n wasmUrl?: string;\n /** Called after each compile with the rendered SVG string. */\n onSvg: (svg: string) => void;\n}\n\nexport interface TypstServiceOptions {\n /**\n * URL to the typst-ts-web-compiler WASM binary.\n * Defaults to the matching version on jsDelivr CDN.\n * Override with a local asset URL for offline support or faster load:\n * `new URL('@myriaddreamin/typst-ts-web-compiler/pkg/typst_ts_web_compiler_bg.wasm', import.meta.url).href`\n */\n wasmUrl?: string;\n /** Font URLs to load into the Typst compiler. Defaults to Roboto from jsDelivr. */\n fonts?: string[];\n /**\n * Enable fetching @preview/ packages from packages.typst.org on demand.\n * Default: true.\n */\n packages?: boolean;\n /**\n * Opt-in SVG preview. When set, the renderer is initialized lazily and `onSvg`\n * is called after each successful compile.\n *\n * Example:\n * renderer: {\n * module: () => import('@myriaddreamin/typst-ts-renderer'),\n * onSvg: (svg) => { previewEl.innerHTML = svg },\n * }\n */\n renderer?: RendererOptions;\n}\n\nconst DEFAULT_FONTS = [\n \"https://cdn.jsdelivr.net/npm/roboto-font@0.1.0/fonts/Roboto/roboto-regular-webfont.ttf\",\n];\n\nconst DEFAULT_WASM_URL =\n \"https://cdn.jsdelivr.net/npm/@myriaddreamin/typst-ts-web-compiler@0.7.0-rc2/pkg/typst_ts_web_compiler_bg.wasm\";\n\nconst DEFAULT_RENDERER_WASM_URL =\n \"https://cdn.jsdelivr.net/npm/@myriaddreamin/typst-ts-renderer@0.7.0-rc2/pkg/typst_ts_renderer_bg.wasm\";\n\nconst TIMEOUT = { INIT: 60_000, RENDER: 60_000, DESTROY: 5_000 } as const;\n\n/**\n * Manages a Typst compiler worker. Create one instance and share it across\n * all extensions (linter, autocomplete, preview, etc.).\n *\n * Prefer constructing with an explicit Worker for Vite apps:\n * new TypstService(new Worker(new URL('typst-web-service/worker', import.meta.url)), options)\n *\n * Or use createTypstService() for a zero-config setup via an inlined blob worker.\n */\nexport class TypstService {\n readonly ready: Promise<void>;\n /** Resolves when the SVG renderer is ready, or rejects if it failed to initialize. Undefined if no renderer was configured. */\n readonly rendererReady?: Promise<void>;\n private idCounter = 0;\n\n private onSvg?: (svg: string) => void;\n private rendererInstance?: Promise<RendererInstance>;\n\n /** The most recent vector artifact from a compile, if any. */\n lastVector?: Uint8Array;\n\n constructor(\n private worker: Worker,\n options: TypstServiceOptions = {},\n ) {\n this.onSvg = options.renderer?.onSvg;\n\n if (options.renderer) {\n this.rendererInstance = this.#initRenderer(\n options.renderer.module,\n options.renderer.wasmUrl,\n );\n this.rendererReady = this.rendererInstance.then(() => {});\n }\n\n this.ready = workerRpc(\n this.worker,\n {\n type: \"init\",\n id: ++this.idCounter,\n wasmUrl: options.wasmUrl ?? DEFAULT_WASM_URL,\n fonts: options.fonts ?? DEFAULT_FONTS,\n packages: options.packages ?? true,\n },\n TIMEOUT.INIT,\n ).then((res) => {\n if (res.type === \"error\")\n throw new Error(`TypstService init failed: ${res.message}`);\n });\n }\n\n async #initRenderer(\n loadModule: RendererModule,\n wasmUrl?: string,\n ): Promise<RendererInstance> {\n const mod = await loadModule();\n await mod.default(wasmUrl ?? DEFAULT_RENDERER_WASM_URL);\n return new mod.TypstRendererBuilder().build();\n }\n\n #vectorToSvg(renderer: RendererInstance, vector: Uint8Array): string {\n const session = renderer.create_session();\n try {\n renderer.manipulate_data(session, \"reset\", vector);\n return renderer.svg_data(session);\n } finally {\n session.free();\n }\n }\n\n /** Compile a single source string (treated as /main.typ) or a map of files. */\n async compile(\n source: string | Record<string, string>,\n ): Promise<CompileResult> {\n await this.ready;\n const id = ++this.idCounter;\n const files = typeof source === \"string\" ? { \"/main.typ\": source } : source;\n const response = await workerRpc(this.worker, {\n type: \"compile\",\n id,\n files,\n });\n if (response.type === \"cancelled\") return { diagnostics: [] };\n if (response.type === \"result\") {\n const vector = response.vector\n ? new Uint8Array(response.vector)\n : undefined;\n if (vector) {\n this.lastVector = vector;\n this.#emitSvg(vector);\n }\n return { diagnostics: response.diagnostics, vector };\n }\n if (response.type === \"error\") throw new Error(response.message);\n return { diagnostics: [] };\n }\n\n async #emitSvg(vector: Uint8Array): Promise<void> {\n if (!this.onSvg || !this.rendererInstance) return;\n try {\n const renderer = await this.rendererInstance;\n this.onSvg(this.#vectorToSvg(renderer, vector));\n } catch {\n // renderer init failed; observable via rendererReady\n }\n }\n\n /**\n * Render a vector artifact to an SVG string.\n * Requires the `renderer` option to be set. Returns null if the renderer is unavailable.\n */\n async renderSvg(vector: Uint8Array): Promise<string | null> {\n if (!this.rendererInstance) return null;\n const renderer = await this.rendererInstance;\n return this.#vectorToSvg(renderer, vector);\n }\n\n /** Render to PDF from a single source string (treated as /main.typ) or a map of files. */\n async renderPdf(\n source: string | Record<string, string>,\n ): Promise<Uint8Array> {\n await this.ready;\n const id = ++this.idCounter;\n const files = typeof source === \"string\" ? { \"/main.typ\": source } : source;\n const response = await workerRpc(\n this.worker,\n { type: \"render\", id, files },\n TIMEOUT.RENDER,\n );\n if (response.type === \"cancelled\") throw new Error(\"Render cancelled\");\n if (response.type === \"pdf\") return new Uint8Array(response.data);\n if (response.type === \"error\") throw new Error(response.message);\n throw new Error(\"Unexpected response type\");\n }\n\n /**\n * Create a TypstService using an inlined worker blob.\n * Works without any bundler configuration.\n *\n * For Vite apps, prefer the explicit Worker constructor to avoid the blob indirection:\n * new TypstService(new Worker(new URL('typst-web-service/worker', import.meta.url)), options)\n */\n static create(options: TypstServiceOptions = {}): TypstService {\n return new TypstService(createWorker(), options);\n }\n\n destroy(): void {\n const id = ++this.idCounter;\n workerRpc(this.worker, { type: \"destroy\", id }, TIMEOUT.DESTROY)\n .catch((err) => console.error(\"TypstService destroy failed:\", err))\n .finally(() => this.worker.terminate());\n }\n}\n"],"mappings":"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","names":[]}