@vedivad/typst-web-service 0.6.0 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +98 -0
- package/dist/analyzer-worker.js +12 -0
- package/dist/analyzer-worker.js.map +1 -1
- package/dist/index.d.ts +90 -91
- package/dist/index.js +105 -126
- package/dist/index.js.map +1 -1
- package/dist/worker.js +6 -7
- package/dist/worker.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -11,10 +11,10 @@ function createBlobWorker(code) {
|
|
|
11
11
|
return worker;
|
|
12
12
|
}
|
|
13
13
|
function createWorker() {
|
|
14
|
-
return createBlobWorker('"use strict";(()=>{var Nt=Object.defineProperty;var dt=(n,t)=>()=>(n&&(t=n(n=0)),t);var Jt=(n,t)=>{for(var e in t)Nt(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 Yt(n){n<132||(S[n]=q,q=n)}function Kt(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 Zt(n,t){return n=n>>>0,te().subarray(n/4,n/4+t)}function it(n,t){return n=n>>>0,T().subarray(n/1,n/1+t)}function a(){return(R===null||R.buffer.detached===!0||R.buffer.detached===void 0&&R.buffer!==i.memory.buffer)&&(R=new DataView(i.memory.buffer)),R}function I(n,t){return n=n>>>0,re(n,t)}function te(){return(D===null||D.byteLength===0)&&(D=new Uint32Array(i.memory.buffer)),D}function T(){return(z===null||z.byteLength===0)&&(z=new Uint8Array(i.memory.buffer)),z}function c(n){return S[n]}function M(n,t){try{return n.apply(this,t)}catch(e){i.__wbindgen_export3(f(e))}}function y(n){return n==null}function ee(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,bt.unregister(o))},bt.register(s,o,o),s}function kt(n,t){let e=t(n.length*1,1)>>>0;return T().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 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 Yt(n),t}function re(n,t){return et+=t,et>=ne&&(G=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),G.decode(),et=t),G.decode(T().subarray(n,n+t))}function oe(n,t,e){i.__wasm_bindgen_func_elem_944(n,t,f(e))}function ie(n,t,e,r){i.__wasm_bindgen_func_elem_37348(n,t,f(e),f(r))}function se(n){let t=i.get_font_info(f(n));return d(t)}async function ae(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&&_e.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 St(){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 M(function(t,e,r){let o=c(t).call(c(e),c(r));return f(o)},arguments)},n.wbg.__wbg_call_78f94eb02ec7f9b2=function(){return M(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 M(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 M(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 ie(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(Zt(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 M(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=O.__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 M(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=B.__wrap(t);return f(e)},n.wbg.__wbg_typstfontresolver_new=function(t){let e=A.__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=ee(t,e,i.__wasm_bindgen_func_elem_957,oe);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 Ft(n,t){return i=n.exports,Rt.__wbindgen_wasm_module=t,R=null,D=null,z=null,i}function ce(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=St();n instanceof WebAssembly.Module||(n=new WebAssembly.Module(n));let e=new WebAssembly.Instance(n,t);return Ft(e,n)}async function Rt(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=Mt("typst_ts_web_compiler_bg.wasm",ue.url));let t=St();(typeof n=="string"||typeof Request=="function"&&n instanceof Request||typeof URL=="function"&&n instanceof URL)&&(n=fetch(n));let{instance:e,module:r}=await ae(await n,t);return Ft(e,r)}function st(n){Mt=n}var ue,i,bt,R,D,z,S,q,G,ne,et,U,l,yt,nt,mt,ht,vt,xt,It,F,O,j,B,N,A,J,_e,At,Mt,Q=dt(()=>{ue={};bt=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>n.dtor(n.a,n.b));R=null;D=null;z=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();ne=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;yt=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)),mt=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>i.__wbg_typstcompileworld_free(n>>>0,1)),ht=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>i.__wbg_typstcompiler_free(n>>>0,1)),vt=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>i.__wbg_typstcompilerbuilder_free(n>>>0,1)),xt=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>i.__wbg_typstfontresolver_free(n>>>0,1)),It=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,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_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);O=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),_=kt(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&&(O.prototype[Symbol.dispose]=O.prototype.free);j=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_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&&(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,ht.register(e,e.__wbg_ptr,e),e}__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_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,A),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=kt(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=Kt(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 j.__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),Dt=b(t,i.__wbindgen_export,i.__wbindgen_export2),zt=l;var u=y(e)?0:H(e,i.__wbindgen_export),g=l;let qt=b(r,i.__wbindgen_export,i.__wbindgen_export2),Ut=l;var p=y(o)?0:b(o,i.__wbindgen_export,i.__wbindgen_export2),w=l;i.typstcompiler_query(L,this.__wbg_ptr,Dt,zt,u,g,qt,Ut,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&&(B.prototype[Symbol.dispose]=B.prototype.free);N=class{__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_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,vt.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);A=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_typstfontresolver_free(t,0)}};Symbol.dispose&&(A.prototype[Symbol.dispose]=A.prototype.free);J=class{__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_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,It.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);_e=new Set(["basic","cors","default"]);At=Rt,Mt=async function(n,t){throw new Error("Cannot import wasm module without importer: "+n+" "+t)}});var Tt={};Jt(Tt,{IncrServer:()=>F,ProxyContext:()=>O,TypstCompileWorld:()=>j,TypstCompiler:()=>B,TypstCompilerBuilder:()=>N,TypstFontResolver:()=>A,TypstFontResolverBuilder:()=>J,default:()=>fe,get_font_info:()=>se,initSync:()=>ce,setImportWasmModule:()=>st});var fe,de,ge,Ot=dt(()=>{Q();Q();Q();fe=At,de=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},ge=typeof process<"u"&&process.versions!=null&&process.versions.node!=null;ge&&st(de)});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:$t(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 gt(n,t,e,r){return await t.init(n?.getModule?.()),await new tt().build(n,new e,r)}function $t(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 lt;(function(n){n[n.PIXEL_PER_PT=3]="PIXEL_PER_PT"})(lt||(lt={}));var Vt=["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"],Xt=["InriaSerif-Bold.ttf","InriaSerif-BoldItalic.ttf","InriaSerif-Italic.ttf","InriaSerif-Regular.ttf","Roboto-Regular.ttf","NotoSerifCJKsc-Regular.otf"],Ht=["TwitterColorEmoji.ttf","NotoColorEmoji-Regular-COLR.subset.ttf"];function Gt(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,Vt));break;case"cjk":t.push(...o(s,Xt));break;case"emoji":t.push(...o(s,Ht));break}}return t}function V(n,t){let e=Gt(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 pt(n){return async(t,{builder:e})=>new Promise(r=>{e.set_package_registry(n,function(o){return n.resolve(o,this)}),r()})}function wt(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 Qt=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=Qt(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)}},jt;jt||(jt={});var at=class{[x];constructor(t){this[x]=t}compile(t){return this[x].compile(0,E(t?.diagnostics))}compileHtml(t){return this[x].compile(1,E(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,E(t?.diagnostics))||{}}pdf(t){return this[x].get_artifact(1,E(t?.diagnostics))||{}}},le=n=>new X(async t=>await n.default(t));function ct(){return new Y}var Y=class n{compiler;compilerJs;static defaultAssets=["text"];constructor(){}async init(t){this.compilerJs=await(t?.getWrapper?.()||Promise.resolve().then(()=>(Ot(),Tt)));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 gt(t,le(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,Bt(t.inputs));if("incrementalServer"in t){e(r.incr_compile(t.incrementalServer[x],E(t.diagnostics)));return}e(r.get_artifact(t.format||$.vector,E(t.diagnostics)))})}async runWithWorld(t,e){let r=this.compiler.snapshot(t.root,t.mainFilePath,Bt(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=Y;function Bt(n){return n?Object.entries(n):void 0}function E(n){switch(n){case"none":return 1;case"unix":return 2;default:return 3}}var K=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 pe=()=>new Promise(n=>setTimeout(n,0));function ut(n,t){let e=null,r=!1;async function o(){for(r=!0;e;){let s=e;if(e=null,await pe(),e){t?.(s);continue}try{await n(s)}catch{}}r=!1}return s=>{e=s,r||o()}}var Et="/main.typ",Pt=new K,we=new Z(Pt),P=null;async function be(n,t,e){P=ct(),await P.init({getModule:()=>n,beforeBuild:[V(t),...e?[wt(Pt),pt(we)]:[]]})}function ye(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)}function Ct(n){if(!P)throw new Error("Compiler not initialized");for(let[t,e]of Object.entries(n))P.addSource(t,e)}async function me(n){Ct(n);let t=await P.compile({mainFilePath:Et,diagnostics:"full"});return{diagnostics:(t.diagnostics??[]).flatMap(r=>{let o=ye(r.range);return o?[{...r,severity:r.severity,range:o}]:[]}),vector:t.result??void 0}}function ft(n,t){self.postMessage({type:"error",id:n,message:t instanceof Error?t.message:String(t)})}function Wt(n){return n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength)}function Lt(n){self.postMessage({type:"cancelled",id:n.id})}var he=ut(async n=>{try{let{diagnostics:t,vector:e}=await me(n.files),r=e?Wt(e):void 0,o={type:"result",id:n.id,diagnostics:t,vector:r};self.postMessage(o,r?[r]:[])}catch(t){ft(n.id,t)}},Lt),ve=ut(async n=>{try{Ct(n.files);let t=await P.compile({mainFilePath:Et,format:$.pdf,diagnostics:"none"});if(!t.result)throw new Error("Compilation produced no output");let e=Wt(t.result);self.postMessage({type:"pdf",id:n.id,data:e},[e])}catch(t){ft(n.id,t)}},Lt);self.onmessage=async n=>{let t=n.data;if(t.type==="init"){try{await be(t.wasmUrl,t.fonts,t.packages),self.postMessage({type:"ready",id:t.id})}catch(e){ft(t.id,e)}return}if(t.type==="compile"){he(t);return}if(t.type==="render"){ve(t);return}t.type==="destroy"&&self.postMessage({type:"destroyed",id:t.id})};})();\n');
|
|
14
|
+
return createBlobWorker('"use strict";(()=>{var Nt=Object.defineProperty;var dt=(n,t)=>()=>(n&&(t=n(n=0)),t);var Jt=(n,t)=>{for(var e in t)Nt(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 Yt(n){n<132||(S[n]=q,q=n)}function Kt(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 Zt(n,t){return n=n>>>0,te().subarray(n/4,n/4+t)}function st(n,t){return n=n>>>0,T().subarray(n/1,n/1+t)}function a(){return(R===null||R.buffer.detached===!0||R.buffer.detached===void 0&&R.buffer!==i.memory.buffer)&&(R=new DataView(i.memory.buffer)),R}function I(n,t){return n=n>>>0,re(n,t)}function te(){return(D===null||D.byteLength===0)&&(D=new Uint32Array(i.memory.buffer)),D}function T(){return(z===null||z.byteLength===0)&&(z=new Uint8Array(i.memory.buffer)),z}function c(n){return S[n]}function M(n,t){try{return n.apply(this,t)}catch(e){i.__wbindgen_export3(f(e))}}function y(n){return n==null}function ee(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,bt.unregister(o))},bt.register(s,o,o),s}function kt(n,t){let e=t(n.length*1,1)>>>0;return T().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 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 Yt(n),t}function re(n,t){return nt+=t,nt>=ne&&(G=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),G.decode(),nt=t),G.decode(T().subarray(n,n+t))}function oe(n,t,e){i.__wasm_bindgen_func_elem_944(n,t,f(e))}function ie(n,t,e,r){i.__wasm_bindgen_func_elem_37348(n,t,f(e),f(r))}function se(n){let t=i.get_font_info(f(n));return d(t)}async function ae(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&&_e.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 St(){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 M(function(t,e,r){let o=c(t).call(c(e),c(r));return f(o)},arguments)},n.wbg.__wbg_call_78f94eb02ec7f9b2=function(){return M(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 M(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 M(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 ie(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(Zt(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 M(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=O.__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 M(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=B.__wrap(t);return f(e)},n.wbg.__wbg_typstfontresolver_new=function(t){let e=A.__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=ee(t,e,i.__wasm_bindgen_func_elem_957,oe);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 Ft(n,t){return i=n.exports,Rt.__wbindgen_wasm_module=t,R=null,D=null,z=null,i}function ce(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=St();n instanceof WebAssembly.Module||(n=new WebAssembly.Module(n));let e=new WebAssembly.Instance(n,t);return Ft(e,n)}async function Rt(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=Mt("typst_ts_web_compiler_bg.wasm",ue.url));let t=St();(typeof n=="string"||typeof Request=="function"&&n instanceof Request||typeof URL=="function"&&n instanceof URL)&&(n=fetch(n));let{instance:e,module:r}=await ae(await n,t);return Ft(e,r)}function _t(n){Mt=n}var ue,i,bt,R,D,z,S,q,G,ne,nt,U,l,yt,rt,mt,ht,vt,xt,It,F,O,j,B,N,A,J,_e,At,Mt,Q=dt(()=>{ue={};bt=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>n.dtor(n.a,n.b));R=null;D=null;z=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();ne=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;yt=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)),mt=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>i.__wbg_typstcompileworld_free(n>>>0,1)),ht=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>i.__wbg_typstcompiler_free(n>>>0,1)),vt=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>i.__wbg_typstcompilerbuilder_free(n>>>0,1)),xt=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>i.__wbg_typstfontresolver_free(n>>>0,1)),It=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,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_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);O=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),_=kt(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&&(O.prototype[Symbol.dispose]=O.prototype.free);j=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_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);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&&(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,ht.register(e,e.__wbg_ptr,e),e}__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_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,A),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=kt(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=Kt(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 j.__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),Dt=b(t,i.__wbindgen_export,i.__wbindgen_export2),zt=l;var u=y(e)?0:H(e,i.__wbindgen_export),g=l;let qt=b(r,i.__wbindgen_export,i.__wbindgen_export2),Ut=l;var p=y(o)?0:b(o,i.__wbindgen_export,i.__wbindgen_export2),w=l;i.typstcompiler_query(L,this.__wbg_ptr,Dt,zt,u,g,qt,Ut,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;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&&(B.prototype[Symbol.dispose]=B.prototype.free);N=class{__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_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,vt.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);A=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_typstfontresolver_free(t,0)}};Symbol.dispose&&(A.prototype[Symbol.dispose]=A.prototype.free);J=class{__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_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,It.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);_e=new Set(["basic","cors","default"]);At=Rt,Mt=async function(n,t){throw new Error("Cannot import wasm module without importer: "+n+" "+t)}});var Tt={};Jt(Tt,{IncrServer:()=>F,ProxyContext:()=>O,TypstCompileWorld:()=>j,TypstCompiler:()=>B,TypstCompilerBuilder:()=>N,TypstFontResolver:()=>A,TypstFontResolverBuilder:()=>J,default:()=>fe,get_font_info:()=>se,initSync:()=>ce,setImportWasmModule:()=>_t});var fe,de,ge,Ot=dt(()=>{Q();Q();Q();fe=At,de=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},ge=typeof process<"u"&&process.versions!=null&&process.versions.node!=null;ge&&_t(de)});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:$t(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 gt(n,t,e,r){return await t.init(n?.getModule?.()),await new et().build(n,new e,r)}function $t(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 lt;(function(n){n[n.PIXEL_PER_PT=3]="PIXEL_PER_PT"})(lt||(lt={}));var Vt=["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"],Xt=["InriaSerif-Bold.ttf","InriaSerif-BoldItalic.ttf","InriaSerif-Italic.ttf","InriaSerif-Regular.ttf","Roboto-Regular.ttf","NotoSerifCJKsc-Regular.otf"],Ht=["TwitterColorEmoji.ttf","NotoColorEmoji-Regular-COLR.subset.ttf"];function Gt(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,Vt));break;case"cjk":t.push(...o(s,Xt));break;case"emoji":t.push(...o(s,Ht));break}}return t}function V(n,t){let e=Gt(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 pt(n){return async(t,{builder:e})=>new Promise(r=>{e.set_package_registry(n,function(o){return n.resolve(o,this)}),r()})}function wt(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 Qt=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=Qt(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 at=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)}},jt;jt||(jt={});var ct=class{[x];constructor(t){this[x]=t}compile(t){return this[x].compile(0,E(t?.diagnostics))}compileHtml(t){return this[x].compile(1,E(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,E(t?.diagnostics))||{}}pdf(t){return this[x].get_artifact(1,E(t?.diagnostics))||{}}},le=n=>new X(async t=>await n.default(t));function ut(){return new Y}var Y=class n{compiler;compilerJs;static defaultAssets=["text"];constructor(){}async init(t){this.compilerJs=await(t?.getWrapper?.()||Promise.resolve().then(()=>(Ot(),Tt)));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 gt(t,le(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,Bt(t.inputs));if("incrementalServer"in t){e(r.incr_compile(t.incrementalServer[x],E(t.diagnostics)));return}e(r.get_artifact(t.format||$.vector,E(t.diagnostics)))})}async runWithWorld(t,e){let r=this.compiler.snapshot(t.root,t.mainFilePath,Bt(t.inputs)),o=await e(new ct(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 at(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")}};ut._impl=Y;function Bt(n){return n?Object.entries(n):void 0}function E(n){switch(n){case"none":return 1;case"unix":return 2;default:return 3}}var K=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 pe=()=>new Promise(n=>setTimeout(n,0));function ft(n,t){let e=null,r=!1;async function o(){for(r=!0;e;){let s=e;if(e=null,await pe(),e){t?.(s);continue}try{await n(s)}catch{}}r=!1}return s=>{e=s,r||o()}}function tt(n,t){let e=t instanceof Error?t.message:String(t);self.postMessage({type:"error",id:n,message:e})}var Et="/main.typ",Pt=new K,we=new Z(Pt),P=null;async function be(n,t,e){P=ut(),await P.init({getModule:()=>n,beforeBuild:[V(t),...e?[wt(Pt),pt(we)]:[]]})}function ye(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)}function Ct(n){if(!P)throw new Error("Compiler not initialized");for(let[t,e]of Object.entries(n))P.addSource(t,e)}async function me(n){Ct(n);let t=await P.compile({mainFilePath:Et,diagnostics:"full"});return{diagnostics:(t.diagnostics??[]).flatMap(r=>{let o=ye(r.range);return o?[{...r,severity:r.severity,range:o}]:[]}),vector:t.result??void 0}}function Wt(n){return n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength)}function Lt(n){self.postMessage({type:"cancelled",id:n.id})}var he=ft(async n=>{try{let{diagnostics:t,vector:e}=await me(n.files),r=e?Wt(e):void 0,o={type:"result",id:n.id,diagnostics:t,vector:r};self.postMessage(o,r?[r]:[])}catch(t){tt(n.id,t)}},Lt),ve=ft(async n=>{try{Ct(n.files);let t=await P.compile({mainFilePath:Et,format:$.pdf,diagnostics:"none"});if(!t.result)throw new Error("Compilation produced no output");let e=Wt(t.result);self.postMessage({type:"pdf",id:n.id,data:e},[e])}catch(t){tt(n.id,t)}},Lt);self.onmessage=async n=>{let t=n.data;if(t.type==="init"){try{await be(t.wasmUrl,t.fonts,t.packages),self.postMessage({type:"ready",id:t.id})}catch(e){tt(t.id,e)}return}if(t.type==="compile"){he(t);return}if(t.type==="render"){ve(t);return}t.type==="destroy"&&self.postMessage({type:"destroyed",id:t.id})};})();\n');
|
|
15
15
|
}
|
|
16
16
|
function createAnalyzerWorker() {
|
|
17
|
-
return createBlobWorker('"use strict";(()=>{var K={},i;function v(n){let e=i.__externref_table_alloc();return i.__wbindgen_externrefs.set(e,n),e}var I=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>n.dtor(n.a,n.b));function O(n){let e=typeof n;if(e=="number"||e=="boolean"||n==null)return`${n}`;if(e=="string")return`"${n}"`;if(e=="symbol"){let _=n.description;return _==null?"Symbol":`Symbol(${_})`}if(e=="function"){let _=n.name;return typeof _=="string"&&_.length>0?`Function(${_})`:"Function"}if(Array.isArray(n)){let _=n.length,o="[";_>0&&(o+=O(n[0]));for(let s=1;s<_;s++)o+=", "+O(n[s]);return o+="]",o}let t=/\\[object ([^\\]]+)\\]/.exec(toString.call(n)),r;if(t&&t.length>1)r=t[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 k(n,e){return n=n>>>0,m().subarray(n/1,n/1+e)}var l=null;function u(){return(l===null||l.buffer.detached===!0||l.buffer.detached===void 0&&l.buffer!==i.memory.buffer)&&(l=new DataView(i.memory.buffer)),l}function a(n,e){return n=n>>>0,$(n,e)}var A=null;function m(){return(A===null||A.byteLength===0)&&(A=new Uint8Array(i.memory.buffer)),A}function p(n,e){try{return n.apply(this,e)}catch(t){let r=v(t);i.__wbindgen_exn_store(r)}}function b(n){return n==null}function N(n,e,t,r){let _={a:n,b:e,cnt:1,dtor:t},o=(...s)=>{_.cnt++;let c=_.a;_.a=0;try{return r(c,_.b,...s)}finally{_.a=c,o._wbg_cb_unref()}};return o._wbg_cb_unref=()=>{--_.cnt===0&&(_.dtor(_.a,_.b),_.a=0,I.unregister(_))},I.register(o,_,_),o}function C(n,e){let t=e(n.length*1,1)>>>0;return m().set(n,t/1),g=n.length,t}function y(n,e,t){if(t===void 0){let c=S.encode(n),d=e(c.length,1)>>>0;return m().subarray(d,d+c.length).set(c),g=c.length,d}let r=n.length,_=e(r,1)>>>0,o=m(),s=0;for(;s<r;s++){let c=n.charCodeAt(s);if(c>127)break;o[_+s]=c}if(s!==r){s!==0&&(n=n.slice(s)),_=t(_,r,r=s+n.length*3,1)>>>0;let c=m().subarray(_+s,_+r),d=S.encodeInto(n,c);s+=d.written,_=t(_,r,s,1)>>>0}return g=s,_}function U(n){let e=i.__wbindgen_externrefs.get(n);return i.__externref_table_dealloc(n),e}var E=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});E.decode();var P=2146435072,D=0;function $(n,e){return D+=e,D>=P&&(E=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),E.decode(),D=e),E.decode(m().subarray(n,n+e))}var S=new TextEncoder;"encodeInto"in S||(S.encodeInto=function(n,e){let t=S.encode(n);return e.set(t),{read:n.length,written:t.length}});var g=0;function V(n,e,t){i.wasm_bindgen__convert__closures_____invoke__h4b569589ab16bc8b(n,e,t)}function G(n,e,t,r){i.wasm_bindgen__convert__closures_____invoke__h298f91ca76697d7d(n,e,t,r)}var T=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>i.__wbg_individuallanguages_free(n>>>0,1)),W=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>i.__wbg_languagecode_free(n>>>0,1)),M=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>i.__wbg_proxycontext_free(n>>>0,1)),q=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>i.__wbg_tinymistlanguageserver_free(n>>>0,1)),R=class n{static __wrap(e){e=e>>>0;let t=Object.create(n.prototype);return t.__wbg_ptr=e,T.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,T.unregister(this),e}free(){let e=this.__destroy_into_raw();i.__wbg_individuallanguages_free(e,0)}get name(){let e,t;try{let r=i.individuallanguages_name(this.__wbg_ptr);return e=r[0],t=r[1],a(r[0],r[1])}finally{i.__wbindgen_free(e,t,1)}}get code(){let e,t;try{let r=i.individuallanguages_code(this.__wbg_ptr);return e=r[0],t=r[1],a(r[0],r[1])}finally{i.__wbindgen_free(e,t,1)}}};Symbol.dispose&&(R.prototype[Symbol.dispose]=R.prototype.free);var F=class n{static __wrap(e){e=e>>>0;let t=Object.create(n.prototype);return t.__wbg_ptr=e,W.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,W.unregister(this),e}free(){let e=this.__destroy_into_raw();i.__wbg_languagecode_free(e,0)}get name(){let e,t;try{let r=i.languagecode_name(this.__wbg_ptr);return e=r[0],t=r[1],a(r[0],r[1])}finally{i.__wbindgen_free(e,t,1)}}get code(){let e,t;try{let r=i.languagecode_code(this.__wbg_ptr);return e=r[0],t=r[1],a(r[0],r[1])}finally{i.__wbindgen_free(e,t,1)}}get code_2t(){let e,t;try{let r=i.languagecode_code_2t(this.__wbg_ptr);return e=r[0],t=r[1],a(r[0],r[1])}finally{i.__wbindgen_free(e,t,1)}}get code_2b(){let e,t;try{let r=i.languagecode_code_2b(this.__wbg_ptr);return e=r[0],t=r[1],a(r[0],r[1])}finally{i.__wbindgen_free(e,t,1)}}get code_3(){let e,t;try{let r=i.languagecode_code_3(this.__wbg_ptr);return e=r[0],t=r[1],a(r[0],r[1])}finally{i.__wbindgen_free(e,t,1)}}get individual_languages(){return i.languagecode_individual_languages(this.__wbg_ptr)}};Symbol.dispose&&(F.prototype[Symbol.dispose]=F.prototype.free);var z=class n{static __wrap(e){e=e>>>0;let t=Object.create(n.prototype);return t.__wbg_ptr=e,M.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,M.unregister(this),e}free(){let e=this.__destroy_into_raw();i.__wbg_proxycontext_free(e,0)}constructor(e){let t=i.proxycontext_new(e);return this.__wbg_ptr=t>>>0,M.register(this,this.__wbg_ptr,this),this}get context(){return i.proxycontext_context(this.__wbg_ptr)}untar(e,t){let r=C(e,i.__wbindgen_malloc),_=g,o=i.proxycontext_untar(this.__wbg_ptr,r,_,t);if(o[1])throw U(o[0])}};Symbol.dispose&&(z.prototype[Symbol.dispose]=z.prototype.free);var h=class{__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,q.unregister(this),e}free(){let e=this.__destroy_into_raw();i.__wbg_tinymistlanguageserver_free(e,0)}constructor(e){let t=i.tinymistlanguageserver_new(e);if(t[2])throw U(t[1]);return this.__wbg_ptr=t[0]>>>0,q.register(this,this.__wbg_ptr,this),this}on_event(e){i.tinymistlanguageserver_on_event(this.__wbg_ptr,e)}on_request(e,t){let r=y(e,i.__wbindgen_malloc,i.__wbindgen_realloc),_=g;return i.tinymistlanguageserver_on_request(this.__wbg_ptr,r,_,t)}on_notification(e,t){let r=y(e,i.__wbindgen_malloc,i.__wbindgen_realloc),_=g;i.tinymistlanguageserver_on_notification(this.__wbg_ptr,r,_,t)}on_response(e){i.tinymistlanguageserver_on_response(this.__wbg_ptr,e)}static version(){let e,t;try{let r=i.tinymistlanguageserver_version();return e=r[0],t=r[1],a(r[0],r[1])}finally{i.__wbindgen_free(e,t,1)}}};Symbol.dispose&&(h.prototype[Symbol.dispose]=h.prototype.free);var X=new Set(["basic","cors","default"]);async function Y(n,e){if(typeof Response=="function"&&n instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(n,e)}catch(r){if(n.ok&&X.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 t=await n.arrayBuffer();return await WebAssembly.instantiate(t,e)}else{let t=await WebAssembly.instantiate(n,e);return t instanceof WebAssembly.Instance?{instance:t,module:n}:t}}function H(){let n={};return n.wbg={},n.wbg.__wbg_Error_52673b7de5a0ca89=function(e,t){return Error(a(e,t))},n.wbg.__wbg_Number_2d1dcfcf4ec51736=function(e){return Number(e)},n.wbg.__wbg_String_8f0eb39a4a4c2f66=function(e,t){let r=String(t),_=y(r,i.__wbindgen_malloc,i.__wbindgen_realloc),o=g;u().setInt32(e+4,o,!0),u().setInt32(e+0,_,!0)},n.wbg.__wbg___wbindgen_bigint_get_as_i64_6e32f5e6aff02e1d=function(e,t){let r=t,_=typeof r=="bigint"?r:void 0;u().setBigInt64(e+8,b(_)?BigInt(0):_,!0),u().setInt32(e+0,!b(_),!0)},n.wbg.__wbg___wbindgen_boolean_get_dea25b33882b895b=function(e){let t=e,r=typeof t=="boolean"?t:void 0;return b(r)?16777215:r?1:0},n.wbg.__wbg___wbindgen_debug_string_adfb662ae34724b6=function(e,t){let r=O(t),_=y(r,i.__wbindgen_malloc,i.__wbindgen_realloc),o=g;u().setInt32(e+4,o,!0),u().setInt32(e+0,_,!0)},n.wbg.__wbg___wbindgen_in_0d3e1e8f0c669317=function(e,t){return e in t},n.wbg.__wbg___wbindgen_is_bigint_0e1a2e3f55cfae27=function(e){return typeof e=="bigint"},n.wbg.__wbg___wbindgen_is_function_8d400b8b1af978cd=function(e){return typeof e=="function"},n.wbg.__wbg___wbindgen_is_object_ce774f3490692386=function(e){let t=e;return typeof t=="object"&&t!==null},n.wbg.__wbg___wbindgen_is_string_704ef9c8fc131030=function(e){return typeof e=="string"},n.wbg.__wbg___wbindgen_is_undefined_f6b95eab589e0269=function(e){return e===void 0},n.wbg.__wbg___wbindgen_jsval_eq_b6101cc9cef1fe36=function(e,t){return e===t},n.wbg.__wbg___wbindgen_jsval_loose_eq_766057600fdd1b0d=function(e,t){return e==t},n.wbg.__wbg___wbindgen_number_get_9619185a74197f95=function(e,t){let r=t,_=typeof r=="number"?r:void 0;u().setFloat64(e+8,b(_)?0:_,!0),u().setInt32(e+0,!b(_),!0)},n.wbg.__wbg___wbindgen_string_get_a2a31e16edf96e42=function(e,t){let r=t,_=typeof r=="string"?r:void 0;var o=b(_)?0:y(_,i.__wbindgen_malloc,i.__wbindgen_realloc),s=g;u().setInt32(e+4,s,!0),u().setInt32(e+0,o,!0)},n.wbg.__wbg___wbindgen_throw_dd24417ed36fc46e=function(e,t){throw new Error(a(e,t))},n.wbg.__wbg__wbg_cb_unref_87dfb5aaa0cbcea7=function(e){e._wbg_cb_unref()},n.wbg.__wbg_call_3020136f7a2d6e44=function(){return p(function(e,t,r){return e.call(t,r)},arguments)},n.wbg.__wbg_call_78f94eb02ec7f9b2=function(){return p(function(e,t,r,_,o){return e.call(t,r,_,o)},arguments)},n.wbg.__wbg_call_abb4ff46ce38be40=function(){return p(function(e,t){return e.call(t)},arguments)},n.wbg.__wbg_done_62ea16af4ce34b24=function(e){return e.done},n.wbg.__wbg_entries_83c79938054e065f=function(e){return Object.entries(e)},n.wbg.__wbg_error_7534b8e9a36f1ab4=function(e,t){let r,_;try{r=e,_=t,console.error(a(e,t))}finally{i.__wbindgen_free(r,_,1)}},n.wbg.__wbg_getTimezoneOffset_45389e26d6f46823=function(e){return e.getTimezoneOffset()},n.wbg.__wbg_get_6b7bd52aca3f9671=function(e,t){return e[t>>>0]},n.wbg.__wbg_get_af9dab7e9603ea93=function(){return p(function(e,t){return Reflect.get(e,t)},arguments)},n.wbg.__wbg_get_with_ref_key_1dc361bd10053bfe=function(e,t){return e[t]},n.wbg.__wbg_individuallanguages_new=function(e){return R.__wrap(e)},n.wbg.__wbg_instanceof_ArrayBuffer_f3320d2419cd0355=function(e){let t;try{t=e instanceof ArrayBuffer}catch{t=!1}return t},n.wbg.__wbg_instanceof_Map_084be8da74364158=function(e){let t;try{t=e instanceof Map}catch{t=!1}return t},n.wbg.__wbg_instanceof_Uint8Array_da54ccc9d3e09434=function(e){let t;try{t=e instanceof Uint8Array}catch{t=!1}return t},n.wbg.__wbg_isArray_51fd9e6422c0a395=function(e){return Array.isArray(e)},n.wbg.__wbg_isSafeInteger_ae7d3f054d55fa16=function(e){return Number.isSafeInteger(e)},n.wbg.__wbg_iterator_27b7c8b35ab3e86b=function(){return Symbol.iterator},n.wbg.__wbg_length_22ac23eaec9d8053=function(e){return e.length},n.wbg.__wbg_length_d45040a40c570362=function(e){return e.length},n.wbg.__wbg_new_1ba21ce319a06297=function(){return new Object},n.wbg.__wbg_new_25f239778d6112b9=function(){return new Array},n.wbg.__wbg_new_6421f6084cc5bc5a=function(e){return new Uint8Array(e)},n.wbg.__wbg_new_8a6f238a6ece86ea=function(){return new Error},n.wbg.__wbg_new_b2db8aa2650f793a=function(e){return new Date(e)},n.wbg.__wbg_new_b546ae120718850e=function(){return new Map},n.wbg.__wbg_new_ff12d2b041fb48f1=function(e,t){try{var r={a:e,b:t},_=(s,c)=>{let d=r.a;r.a=0;try{return G(d,r.b,s,c)}finally{r.a=d}};return new Promise(_)}finally{r.a=r.b=0}},n.wbg.__wbg_new_from_slice_f9c22b9153b26992=function(e,t){return new Uint8Array(k(e,t))},n.wbg.__wbg_new_no_args_cb138f77cf6151ee=function(e,t){return new Function(a(e,t))},n.wbg.__wbg_next_138a17bbf04e926c=function(e){return e.next},n.wbg.__wbg_next_3cfe5c0fe2a4cc53=function(){return p(function(e){return e.next()},arguments)},n.wbg.__wbg_now_2c95c9de01293173=function(e){return e.now()},n.wbg.__wbg_now_69d776cd24f5215b=function(){return Date.now()},n.wbg.__wbg_performance_7a3ffd0b17f663ad=function(e){return e.performance},n.wbg.__wbg_prototypesetcall_dfe9b766cdc1f1fd=function(e,t,r){Uint8Array.prototype.set.call(k(e,t),r)},n.wbg.__wbg_proxycontext_new=function(e){return z.__wrap(e)},n.wbg.__wbg_push_7d9be8f38fc13975=function(e,t){return e.push(t)},n.wbg.__wbg_queueMicrotask_9b549dfce8865860=function(e){return e.queueMicrotask},n.wbg.__wbg_queueMicrotask_fca69f5bfad613a5=function(e){queueMicrotask(e)},n.wbg.__wbg_resolve_fd5bfbaa4ce36e1e=function(e){return Promise.resolve(e)},n.wbg.__wbg_set_3f1d0b984ed272ed=function(e,t,r){e[t]=r},n.wbg.__wbg_set_781438a03c0c3c81=function(){return p(function(e,t,r){return Reflect.set(e,t,r)},arguments)},n.wbg.__wbg_set_7df433eea03a5c14=function(e,t,r){e[t>>>0]=r},n.wbg.__wbg_set_efaaf145b9377369=function(e,t,r){return e.set(t,r)},n.wbg.__wbg_stack_0ed75d68575b0f3c=function(e,t){let r=t.stack,_=y(r,i.__wbindgen_malloc,i.__wbindgen_realloc),o=g;u().setInt32(e+4,o,!0),u().setInt32(e+0,_,!0)},n.wbg.__wbg_static_accessor_GLOBAL_769e6b65d6557335=function(){let e=typeof global>"u"?null:global;return b(e)?0:v(e)},n.wbg.__wbg_static_accessor_GLOBAL_THIS_60cf02db4de8e1c1=function(){let e=typeof globalThis>"u"?null:globalThis;return b(e)?0:v(e)},n.wbg.__wbg_static_accessor_SELF_08f5a74c69739274=function(){let e=typeof self>"u"?null:self;return b(e)?0:v(e)},n.wbg.__wbg_static_accessor_WINDOW_a8924b26aa92d024=function(){let e=typeof window>"u"?null:window;return b(e)?0:v(e)},n.wbg.__wbg_then_4f95312d68691235=function(e,t){return e.then(t)},n.wbg.__wbg_value_57b7b035e117f7ee=function(e){return e.value},n.wbg.__wbindgen_cast_2241b6af4c4b2941=function(e,t){return a(e,t)},n.wbg.__wbindgen_cast_4625c577ab2ec9ee=function(e){return BigInt.asUintN(64,e)},n.wbg.__wbindgen_cast_9ae0607507abb057=function(e){return e},n.wbg.__wbindgen_cast_b5bc9a99b1b9b782=function(e,t){return N(e,t,i.wasm_bindgen__closure__destroy__h21ca932816a58917,V)},n.wbg.__wbindgen_cast_d6cd19b81560fd6e=function(e){return e},n.wbg.__wbindgen_init_externref_table=function(){let e=i.__wbindgen_externrefs,t=e.grow(4);e.set(0,void 0),e.set(t+0,void 0),e.set(t+1,null),e.set(t+2,!0),e.set(t+3,!1)},n}function J(n,e){return i=n.exports,L.__wbindgen_wasm_module=e,l=null,A=null,i.__wbindgen_start(),i}async function L(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=new URL("tinymist_bg.wasm",K.url));let e=H();(typeof n=="string"||typeof Request=="function"&&n instanceof Request||typeof URL=="function"&&n instanceof URL)&&(n=fetch(n));let{instance:t,module:r}=await Y(await n,e);return J(t,r)}var B=L;function w(n,e){let t=e instanceof Error?e.message:String(e);self.postMessage({type:"error",id:n,message:t})}var f=null,j=[];function Q(n){return n.startsWith("untitled:/")?`untitled:${n.slice(10)}`:n}function x(){if(f)for(;j.length>0;)for(let n of j.splice(0))f.on_event(n)}async function Z(n){await B(n),f=new h({sendEvent:t=>{j.push(t)},sendRequest({id:t}){f.on_response({id:t,result:null})},sendNotification:({method:t,params:r})=>{if(t==="textDocument/publishDiagnostics"){let{uri:_,diagnostics:o}=r;self.postMessage({type:"diagnostics",uri:Q(_),diagnostics:o})}},resolveFn:()=>{}});let e=f.on_request("initialize",{capabilities:{textDocument:{publishDiagnostics:{relatedInformation:!0},completion:{completionItem:{snippetSupport:!0}},hover:{contentFormat:["markdown","plaintext"]}}},rootUri:"file:///"});e&&typeof e=="object"&&"then"in e&&await e,x(),f.on_notification("initialized",{}),x()}self.onmessage=async n=>{let e=n.data;if(e.type==="init"){try{await Z(e.wasmUrl),self.postMessage({type:"ready",id:e.id})}catch(t){w(e.id,t)}return}if(!f){w(e.id,new Error("Analyzer not initialized"));return}if(e.type==="didOpen"){try{f.on_notification("textDocument/didOpen",{textDocument:{uri:e.uri,languageId:"typst",version:1,text:e.content}}),x(),self.postMessage({type:"ack",id:e.id})}catch(t){w(e.id,t)}return}if(e.type==="didChange"){try{f.on_notification("textDocument/didChange",{textDocument:{uri:e.uri,version:e.version},contentChanges:[{text:e.content}]}),x(),self.postMessage({type:"ack",id:e.id})}catch(t){w(e.id,t)}return}if(e.type==="completion"){try{let t=f.on_request("textDocument/completion",{textDocument:{uri:e.uri},position:{line:e.line,character:e.character}}),r=t&&typeof t=="object"&&"then"in t?await t:t;x(),self.postMessage({type:"completionResult",id:e.id,result:r??null})}catch(t){w(e.id,t)}return}if(e.type==="hover"){try{let t=f.on_request("textDocument/hover",{textDocument:{uri:e.uri},position:{line:e.line,character:e.character}}),r=t&&typeof t=="object"&&"then"in t?await t:t;x(),self.postMessage({type:"hoverResult",id:e.id,result:r??null})}catch(t){w(e.id,t)}return}e.type==="destroy"&&(f.free(),f=null,self.postMessage({type:"destroyed",id:e.id}))};})();\n');
|
|
17
|
+
return createBlobWorker('"use strict";(()=>{var K={},i;function v(n){let e=i.__externref_table_alloc();return i.__wbindgen_externrefs.set(e,n),e}var I=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>n.dtor(n.a,n.b));function O(n){let e=typeof n;if(e=="number"||e=="boolean"||n==null)return`${n}`;if(e=="string")return`"${n}"`;if(e=="symbol"){let _=n.description;return _==null?"Symbol":`Symbol(${_})`}if(e=="function"){let _=n.name;return typeof _=="string"&&_.length>0?`Function(${_})`:"Function"}if(Array.isArray(n)){let _=n.length,o="[";_>0&&(o+=O(n[0]));for(let s=1;s<_;s++)o+=", "+O(n[s]);return o+="]",o}let t=/\\[object ([^\\]]+)\\]/.exec(toString.call(n)),r;if(t&&t.length>1)r=t[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 k(n,e){return n=n>>>0,h().subarray(n/1,n/1+e)}var w=null;function u(){return(w===null||w.buffer.detached===!0||w.buffer.detached===void 0&&w.buffer!==i.memory.buffer)&&(w=new DataView(i.memory.buffer)),w}function f(n,e){return n=n>>>0,$(n,e)}var A=null;function h(){return(A===null||A.byteLength===0)&&(A=new Uint8Array(i.memory.buffer)),A}function y(n,e){try{return n.apply(this,e)}catch(t){let r=v(t);i.__wbindgen_exn_store(r)}}function b(n){return n==null}function C(n,e,t,r){let _={a:n,b:e,cnt:1,dtor:t},o=(...s)=>{_.cnt++;let c=_.a;_.a=0;try{return r(c,_.b,...s)}finally{_.a=c,o._wbg_cb_unref()}};return o._wbg_cb_unref=()=>{--_.cnt===0&&(_.dtor(_.a,_.b),_.a=0,I.unregister(_))},I.register(o,_,_),o}function N(n,e){let t=e(n.length*1,1)>>>0;return h().set(n,t/1),g=n.length,t}function m(n,e,t){if(t===void 0){let c=S.encode(n),d=e(c.length,1)>>>0;return h().subarray(d,d+c.length).set(c),g=c.length,d}let r=n.length,_=e(r,1)>>>0,o=h(),s=0;for(;s<r;s++){let c=n.charCodeAt(s);if(c>127)break;o[_+s]=c}if(s!==r){s!==0&&(n=n.slice(s)),_=t(_,r,r=s+n.length*3,1)>>>0;let c=h().subarray(_+s,_+r),d=S.encodeInto(n,c);s+=d.written,_=t(_,r,s,1)>>>0}return g=s,_}function U(n){let e=i.__wbindgen_externrefs.get(n);return i.__externref_table_dealloc(n),e}var E=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});E.decode();var P=2146435072,D=0;function $(n,e){return D+=e,D>=P&&(E=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),E.decode(),D=e),E.decode(h().subarray(n,n+e))}var S=new TextEncoder;"encodeInto"in S||(S.encodeInto=function(n,e){let t=S.encode(n);return e.set(t),{read:n.length,written:t.length}});var g=0;function V(n,e,t){i.wasm_bindgen__convert__closures_____invoke__h4b569589ab16bc8b(n,e,t)}function G(n,e,t,r){i.wasm_bindgen__convert__closures_____invoke__h298f91ca76697d7d(n,e,t,r)}var T=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>i.__wbg_individuallanguages_free(n>>>0,1)),W=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>i.__wbg_languagecode_free(n>>>0,1)),M=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>i.__wbg_proxycontext_free(n>>>0,1)),q=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>i.__wbg_tinymistlanguageserver_free(n>>>0,1)),R=class n{static __wrap(e){e=e>>>0;let t=Object.create(n.prototype);return t.__wbg_ptr=e,T.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,T.unregister(this),e}free(){let e=this.__destroy_into_raw();i.__wbg_individuallanguages_free(e,0)}get name(){let e,t;try{let r=i.individuallanguages_name(this.__wbg_ptr);return e=r[0],t=r[1],f(r[0],r[1])}finally{i.__wbindgen_free(e,t,1)}}get code(){let e,t;try{let r=i.individuallanguages_code(this.__wbg_ptr);return e=r[0],t=r[1],f(r[0],r[1])}finally{i.__wbindgen_free(e,t,1)}}};Symbol.dispose&&(R.prototype[Symbol.dispose]=R.prototype.free);var F=class n{static __wrap(e){e=e>>>0;let t=Object.create(n.prototype);return t.__wbg_ptr=e,W.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,W.unregister(this),e}free(){let e=this.__destroy_into_raw();i.__wbg_languagecode_free(e,0)}get name(){let e,t;try{let r=i.languagecode_name(this.__wbg_ptr);return e=r[0],t=r[1],f(r[0],r[1])}finally{i.__wbindgen_free(e,t,1)}}get code(){let e,t;try{let r=i.languagecode_code(this.__wbg_ptr);return e=r[0],t=r[1],f(r[0],r[1])}finally{i.__wbindgen_free(e,t,1)}}get code_2t(){let e,t;try{let r=i.languagecode_code_2t(this.__wbg_ptr);return e=r[0],t=r[1],f(r[0],r[1])}finally{i.__wbindgen_free(e,t,1)}}get code_2b(){let e,t;try{let r=i.languagecode_code_2b(this.__wbg_ptr);return e=r[0],t=r[1],f(r[0],r[1])}finally{i.__wbindgen_free(e,t,1)}}get code_3(){let e,t;try{let r=i.languagecode_code_3(this.__wbg_ptr);return e=r[0],t=r[1],f(r[0],r[1])}finally{i.__wbindgen_free(e,t,1)}}get individual_languages(){return i.languagecode_individual_languages(this.__wbg_ptr)}};Symbol.dispose&&(F.prototype[Symbol.dispose]=F.prototype.free);var z=class n{static __wrap(e){e=e>>>0;let t=Object.create(n.prototype);return t.__wbg_ptr=e,M.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,M.unregister(this),e}free(){let e=this.__destroy_into_raw();i.__wbg_proxycontext_free(e,0)}constructor(e){let t=i.proxycontext_new(e);return this.__wbg_ptr=t>>>0,M.register(this,this.__wbg_ptr,this),this}get context(){return i.proxycontext_context(this.__wbg_ptr)}untar(e,t){let r=N(e,i.__wbindgen_malloc),_=g,o=i.proxycontext_untar(this.__wbg_ptr,r,_,t);if(o[1])throw U(o[0])}};Symbol.dispose&&(z.prototype[Symbol.dispose]=z.prototype.free);var x=class{__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,q.unregister(this),e}free(){let e=this.__destroy_into_raw();i.__wbg_tinymistlanguageserver_free(e,0)}constructor(e){let t=i.tinymistlanguageserver_new(e);if(t[2])throw U(t[1]);return this.__wbg_ptr=t[0]>>>0,q.register(this,this.__wbg_ptr,this),this}on_event(e){i.tinymistlanguageserver_on_event(this.__wbg_ptr,e)}on_request(e,t){let r=m(e,i.__wbindgen_malloc,i.__wbindgen_realloc),_=g;return i.tinymistlanguageserver_on_request(this.__wbg_ptr,r,_,t)}on_notification(e,t){let r=m(e,i.__wbindgen_malloc,i.__wbindgen_realloc),_=g;i.tinymistlanguageserver_on_notification(this.__wbg_ptr,r,_,t)}on_response(e){i.tinymistlanguageserver_on_response(this.__wbg_ptr,e)}static version(){let e,t;try{let r=i.tinymistlanguageserver_version();return e=r[0],t=r[1],f(r[0],r[1])}finally{i.__wbindgen_free(e,t,1)}}};Symbol.dispose&&(x.prototype[Symbol.dispose]=x.prototype.free);var X=new Set(["basic","cors","default"]);async function Y(n,e){if(typeof Response=="function"&&n instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(n,e)}catch(r){if(n.ok&&X.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 t=await n.arrayBuffer();return await WebAssembly.instantiate(t,e)}else{let t=await WebAssembly.instantiate(n,e);return t instanceof WebAssembly.Instance?{instance:t,module:n}:t}}function H(){let n={};return n.wbg={},n.wbg.__wbg_Error_52673b7de5a0ca89=function(e,t){return Error(f(e,t))},n.wbg.__wbg_Number_2d1dcfcf4ec51736=function(e){return Number(e)},n.wbg.__wbg_String_8f0eb39a4a4c2f66=function(e,t){let r=String(t),_=m(r,i.__wbindgen_malloc,i.__wbindgen_realloc),o=g;u().setInt32(e+4,o,!0),u().setInt32(e+0,_,!0)},n.wbg.__wbg___wbindgen_bigint_get_as_i64_6e32f5e6aff02e1d=function(e,t){let r=t,_=typeof r=="bigint"?r:void 0;u().setBigInt64(e+8,b(_)?BigInt(0):_,!0),u().setInt32(e+0,!b(_),!0)},n.wbg.__wbg___wbindgen_boolean_get_dea25b33882b895b=function(e){let t=e,r=typeof t=="boolean"?t:void 0;return b(r)?16777215:r?1:0},n.wbg.__wbg___wbindgen_debug_string_adfb662ae34724b6=function(e,t){let r=O(t),_=m(r,i.__wbindgen_malloc,i.__wbindgen_realloc),o=g;u().setInt32(e+4,o,!0),u().setInt32(e+0,_,!0)},n.wbg.__wbg___wbindgen_in_0d3e1e8f0c669317=function(e,t){return e in t},n.wbg.__wbg___wbindgen_is_bigint_0e1a2e3f55cfae27=function(e){return typeof e=="bigint"},n.wbg.__wbg___wbindgen_is_function_8d400b8b1af978cd=function(e){return typeof e=="function"},n.wbg.__wbg___wbindgen_is_object_ce774f3490692386=function(e){let t=e;return typeof t=="object"&&t!==null},n.wbg.__wbg___wbindgen_is_string_704ef9c8fc131030=function(e){return typeof e=="string"},n.wbg.__wbg___wbindgen_is_undefined_f6b95eab589e0269=function(e){return e===void 0},n.wbg.__wbg___wbindgen_jsval_eq_b6101cc9cef1fe36=function(e,t){return e===t},n.wbg.__wbg___wbindgen_jsval_loose_eq_766057600fdd1b0d=function(e,t){return e==t},n.wbg.__wbg___wbindgen_number_get_9619185a74197f95=function(e,t){let r=t,_=typeof r=="number"?r:void 0;u().setFloat64(e+8,b(_)?0:_,!0),u().setInt32(e+0,!b(_),!0)},n.wbg.__wbg___wbindgen_string_get_a2a31e16edf96e42=function(e,t){let r=t,_=typeof r=="string"?r:void 0;var o=b(_)?0:m(_,i.__wbindgen_malloc,i.__wbindgen_realloc),s=g;u().setInt32(e+4,s,!0),u().setInt32(e+0,o,!0)},n.wbg.__wbg___wbindgen_throw_dd24417ed36fc46e=function(e,t){throw new Error(f(e,t))},n.wbg.__wbg__wbg_cb_unref_87dfb5aaa0cbcea7=function(e){e._wbg_cb_unref()},n.wbg.__wbg_call_3020136f7a2d6e44=function(){return y(function(e,t,r){return e.call(t,r)},arguments)},n.wbg.__wbg_call_78f94eb02ec7f9b2=function(){return y(function(e,t,r,_,o){return e.call(t,r,_,o)},arguments)},n.wbg.__wbg_call_abb4ff46ce38be40=function(){return y(function(e,t){return e.call(t)},arguments)},n.wbg.__wbg_done_62ea16af4ce34b24=function(e){return e.done},n.wbg.__wbg_entries_83c79938054e065f=function(e){return Object.entries(e)},n.wbg.__wbg_error_7534b8e9a36f1ab4=function(e,t){let r,_;try{r=e,_=t,console.error(f(e,t))}finally{i.__wbindgen_free(r,_,1)}},n.wbg.__wbg_getTimezoneOffset_45389e26d6f46823=function(e){return e.getTimezoneOffset()},n.wbg.__wbg_get_6b7bd52aca3f9671=function(e,t){return e[t>>>0]},n.wbg.__wbg_get_af9dab7e9603ea93=function(){return y(function(e,t){return Reflect.get(e,t)},arguments)},n.wbg.__wbg_get_with_ref_key_1dc361bd10053bfe=function(e,t){return e[t]},n.wbg.__wbg_individuallanguages_new=function(e){return R.__wrap(e)},n.wbg.__wbg_instanceof_ArrayBuffer_f3320d2419cd0355=function(e){let t;try{t=e instanceof ArrayBuffer}catch{t=!1}return t},n.wbg.__wbg_instanceof_Map_084be8da74364158=function(e){let t;try{t=e instanceof Map}catch{t=!1}return t},n.wbg.__wbg_instanceof_Uint8Array_da54ccc9d3e09434=function(e){let t;try{t=e instanceof Uint8Array}catch{t=!1}return t},n.wbg.__wbg_isArray_51fd9e6422c0a395=function(e){return Array.isArray(e)},n.wbg.__wbg_isSafeInteger_ae7d3f054d55fa16=function(e){return Number.isSafeInteger(e)},n.wbg.__wbg_iterator_27b7c8b35ab3e86b=function(){return Symbol.iterator},n.wbg.__wbg_length_22ac23eaec9d8053=function(e){return e.length},n.wbg.__wbg_length_d45040a40c570362=function(e){return e.length},n.wbg.__wbg_new_1ba21ce319a06297=function(){return new Object},n.wbg.__wbg_new_25f239778d6112b9=function(){return new Array},n.wbg.__wbg_new_6421f6084cc5bc5a=function(e){return new Uint8Array(e)},n.wbg.__wbg_new_8a6f238a6ece86ea=function(){return new Error},n.wbg.__wbg_new_b2db8aa2650f793a=function(e){return new Date(e)},n.wbg.__wbg_new_b546ae120718850e=function(){return new Map},n.wbg.__wbg_new_ff12d2b041fb48f1=function(e,t){try{var r={a:e,b:t},_=(s,c)=>{let d=r.a;r.a=0;try{return G(d,r.b,s,c)}finally{r.a=d}};return new Promise(_)}finally{r.a=r.b=0}},n.wbg.__wbg_new_from_slice_f9c22b9153b26992=function(e,t){return new Uint8Array(k(e,t))},n.wbg.__wbg_new_no_args_cb138f77cf6151ee=function(e,t){return new Function(f(e,t))},n.wbg.__wbg_next_138a17bbf04e926c=function(e){return e.next},n.wbg.__wbg_next_3cfe5c0fe2a4cc53=function(){return y(function(e){return e.next()},arguments)},n.wbg.__wbg_now_2c95c9de01293173=function(e){return e.now()},n.wbg.__wbg_now_69d776cd24f5215b=function(){return Date.now()},n.wbg.__wbg_performance_7a3ffd0b17f663ad=function(e){return e.performance},n.wbg.__wbg_prototypesetcall_dfe9b766cdc1f1fd=function(e,t,r){Uint8Array.prototype.set.call(k(e,t),r)},n.wbg.__wbg_proxycontext_new=function(e){return z.__wrap(e)},n.wbg.__wbg_push_7d9be8f38fc13975=function(e,t){return e.push(t)},n.wbg.__wbg_queueMicrotask_9b549dfce8865860=function(e){return e.queueMicrotask},n.wbg.__wbg_queueMicrotask_fca69f5bfad613a5=function(e){queueMicrotask(e)},n.wbg.__wbg_resolve_fd5bfbaa4ce36e1e=function(e){return Promise.resolve(e)},n.wbg.__wbg_set_3f1d0b984ed272ed=function(e,t,r){e[t]=r},n.wbg.__wbg_set_781438a03c0c3c81=function(){return y(function(e,t,r){return Reflect.set(e,t,r)},arguments)},n.wbg.__wbg_set_7df433eea03a5c14=function(e,t,r){e[t>>>0]=r},n.wbg.__wbg_set_efaaf145b9377369=function(e,t,r){return e.set(t,r)},n.wbg.__wbg_stack_0ed75d68575b0f3c=function(e,t){let r=t.stack,_=m(r,i.__wbindgen_malloc,i.__wbindgen_realloc),o=g;u().setInt32(e+4,o,!0),u().setInt32(e+0,_,!0)},n.wbg.__wbg_static_accessor_GLOBAL_769e6b65d6557335=function(){let e=typeof global>"u"?null:global;return b(e)?0:v(e)},n.wbg.__wbg_static_accessor_GLOBAL_THIS_60cf02db4de8e1c1=function(){let e=typeof globalThis>"u"?null:globalThis;return b(e)?0:v(e)},n.wbg.__wbg_static_accessor_SELF_08f5a74c69739274=function(){let e=typeof self>"u"?null:self;return b(e)?0:v(e)},n.wbg.__wbg_static_accessor_WINDOW_a8924b26aa92d024=function(){let e=typeof window>"u"?null:window;return b(e)?0:v(e)},n.wbg.__wbg_then_4f95312d68691235=function(e,t){return e.then(t)},n.wbg.__wbg_value_57b7b035e117f7ee=function(e){return e.value},n.wbg.__wbindgen_cast_2241b6af4c4b2941=function(e,t){return f(e,t)},n.wbg.__wbindgen_cast_4625c577ab2ec9ee=function(e){return BigInt.asUintN(64,e)},n.wbg.__wbindgen_cast_9ae0607507abb057=function(e){return e},n.wbg.__wbindgen_cast_b5bc9a99b1b9b782=function(e,t){return C(e,t,i.wasm_bindgen__closure__destroy__h21ca932816a58917,V)},n.wbg.__wbindgen_cast_d6cd19b81560fd6e=function(e){return e},n.wbg.__wbindgen_init_externref_table=function(){let e=i.__wbindgen_externrefs,t=e.grow(4);e.set(0,void 0),e.set(t+0,void 0),e.set(t+1,null),e.set(t+2,!0),e.set(t+3,!1)},n}function J(n,e){return i=n.exports,L.__wbindgen_wasm_module=e,w=null,A=null,i.__wbindgen_start(),i}async function L(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=new URL("tinymist_bg.wasm",K.url));let e=H();(typeof n=="string"||typeof Request=="function"&&n instanceof Request||typeof URL=="function"&&n instanceof URL)&&(n=fetch(n));let{instance:t,module:r}=await Y(await n,e);return J(t,r)}var B=L;function l(n,e){let t=e instanceof Error?e.message:String(e);self.postMessage({type:"error",id:n,message:t})}var a=null,j=[];function Q(n){return n.startsWith("untitled:/")?`untitled:${n.slice(10)}`:n}function p(){if(a)for(;j.length>0;)for(let n of j.splice(0))a.on_event(n)}async function Z(n){await B(n),a=new x({sendEvent:t=>{j.push(t)},sendRequest({id:t}){a.on_response({id:t,result:null})},sendNotification:({method:t,params:r})=>{if(t==="textDocument/publishDiagnostics"){let{uri:_,diagnostics:o}=r;self.postMessage({type:"diagnostics",uri:Q(_),diagnostics:o})}},resolveFn:()=>{}});let e=a.on_request("initialize",{capabilities:{textDocument:{publishDiagnostics:{relatedInformation:!0},completion:{completionItem:{snippetSupport:!0}},hover:{contentFormat:["markdown","plaintext"]}}},rootUri:"file:///"});e&&typeof e=="object"&&"then"in e&&await e,p(),a.on_notification("initialized",{}),p()}self.onmessage=async n=>{let e=n.data;if(e.type==="init"){try{await Z(e.wasmUrl),self.postMessage({type:"ready",id:e.id})}catch(t){l(e.id,t)}return}if(!a){l(e.id,new Error("Analyzer not initialized"));return}if(e.type==="didOpen"){try{a.on_notification("textDocument/didOpen",{textDocument:{uri:e.uri,languageId:"typst",version:1,text:e.content}}),p(),self.postMessage({type:"ack",id:e.id})}catch(t){l(e.id,t)}return}if(e.type==="didClose"){try{a.on_notification("textDocument/didClose",{textDocument:{uri:e.uri}}),p(),self.postMessage({type:"ack",id:e.id})}catch(t){l(e.id,t)}return}if(e.type==="didChange"){try{a.on_notification("textDocument/didChange",{textDocument:{uri:e.uri,version:e.version},contentChanges:[{text:e.content}]}),p(),self.postMessage({type:"ack",id:e.id})}catch(t){l(e.id,t)}return}if(e.type==="completion"){try{let t=a.on_request("textDocument/completion",{textDocument:{uri:e.uri},position:{line:e.line,character:e.character}}),r=t&&typeof t=="object"&&"then"in t?await t:t;p(),self.postMessage({type:"completionResult",id:e.id,result:r??null})}catch(t){l(e.id,t)}return}if(e.type==="hover"){try{let t=a.on_request("textDocument/hover",{textDocument:{uri:e.uri},position:{line:e.line,character:e.character}}),r=t&&typeof t=="object"&&"then"in t?await t:t;p(),self.postMessage({type:"hoverResult",id:e.id,result:r??null})}catch(t){l(e.id,t)}return}e.type==="destroy"&&(a.free(),a=null,self.postMessage({type:"destroyed",id:e.id}))};})();\n');
|
|
18
18
|
}
|
|
19
19
|
function workerRpc(worker, request, timeoutMs = 3e4, transfer) {
|
|
20
20
|
return new Promise((resolve, reject) => {
|
|
@@ -51,37 +51,40 @@ function normalizeRoot(rootPath) {
|
|
|
51
51
|
|
|
52
52
|
// src/analyzer.ts
|
|
53
53
|
var TIMEOUT = { INIT: 12e4, REQUEST: 3e4, DESTROY: 5e3 };
|
|
54
|
-
var TypstAnalyzer = class {
|
|
55
|
-
|
|
56
|
-
idCounter = 0;
|
|
54
|
+
var TypstAnalyzer = class _TypstAnalyzer {
|
|
55
|
+
idCounter;
|
|
57
56
|
versionCounter = 0;
|
|
58
57
|
worker;
|
|
59
58
|
openedUris = /* @__PURE__ */ new Set();
|
|
60
59
|
diagnosticsListeners = /* @__PURE__ */ new Set();
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
this.
|
|
64
|
-
const absoluteWasmUrl = new URL(options.wasmUrl, globalThis.location?.href).href;
|
|
60
|
+
constructor(worker, idCounter) {
|
|
61
|
+
this.worker = worker;
|
|
62
|
+
this.idCounter = idCounter;
|
|
65
63
|
this.worker.addEventListener(
|
|
66
64
|
"message",
|
|
67
65
|
(e) => {
|
|
68
66
|
if (e.data.type === "diagnostics" && !("id" in e.data)) {
|
|
69
67
|
const event = e.data;
|
|
70
68
|
const normalizedUri = normalizeUntitledUri(event.uri);
|
|
71
|
-
this.latestDiagnosticsByUri.set(normalizedUri, event.diagnostics);
|
|
72
69
|
for (const listener of this.diagnosticsListeners) {
|
|
73
70
|
listener(normalizedUri, event.diagnostics);
|
|
74
71
|
}
|
|
75
72
|
}
|
|
76
73
|
}
|
|
77
74
|
);
|
|
78
|
-
|
|
79
|
-
|
|
75
|
+
}
|
|
76
|
+
static async create(options) {
|
|
77
|
+
const worker = options.worker ?? createAnalyzerWorker();
|
|
78
|
+
let idCounter = 0;
|
|
79
|
+
const absoluteWasmUrl = new URL(options.wasmUrl, globalThis.location?.href).href;
|
|
80
|
+
const res = await workerRpc(
|
|
81
|
+
worker,
|
|
82
|
+
{ type: "init", id: ++idCounter, wasmUrl: absoluteWasmUrl },
|
|
80
83
|
TIMEOUT.INIT
|
|
81
|
-
)
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
84
|
+
);
|
|
85
|
+
if (res.type === "error")
|
|
86
|
+
throw new Error(`TypstAnalyzer init failed: ${res.message}`);
|
|
87
|
+
return new _TypstAnalyzer(worker, idCounter);
|
|
85
88
|
}
|
|
86
89
|
/**
|
|
87
90
|
* Register a listener for push-based diagnostics.
|
|
@@ -91,15 +94,10 @@ var TypstAnalyzer = class {
|
|
|
91
94
|
this.diagnosticsListeners.add(listener);
|
|
92
95
|
return () => this.diagnosticsListeners.delete(listener);
|
|
93
96
|
}
|
|
94
|
-
/** Returns the latest pushed diagnostics for a URI, if available. */
|
|
95
|
-
getLatestDiagnostics(uri) {
|
|
96
|
-
return this.latestDiagnosticsByUri.get(normalizeUntitledUri(uri));
|
|
97
|
-
}
|
|
98
97
|
rpc(request, timeoutMs = TIMEOUT.REQUEST) {
|
|
99
98
|
return workerRpc(this.worker, request, timeoutMs);
|
|
100
99
|
}
|
|
101
100
|
async didOpen(uri, content) {
|
|
102
|
-
await this.ready;
|
|
103
101
|
const res = await this.rpc({
|
|
104
102
|
type: "didOpen",
|
|
105
103
|
id: ++this.idCounter,
|
|
@@ -109,12 +107,21 @@ var TypstAnalyzer = class {
|
|
|
109
107
|
if (res.type === "error") throw new Error(res.message);
|
|
110
108
|
this.openedUris.add(uri);
|
|
111
109
|
}
|
|
110
|
+
async didClose(uri) {
|
|
111
|
+
if (!this.openedUris.has(uri)) return;
|
|
112
|
+
const res = await this.rpc({
|
|
113
|
+
type: "didClose",
|
|
114
|
+
id: ++this.idCounter,
|
|
115
|
+
uri
|
|
116
|
+
});
|
|
117
|
+
if (res.type === "error") throw new Error(res.message);
|
|
118
|
+
this.openedUris.delete(uri);
|
|
119
|
+
}
|
|
112
120
|
/**
|
|
113
121
|
* Notify the analyzer that a document has changed.
|
|
114
122
|
* Diagnostics will arrive asynchronously via `onDiagnostics()` listeners.
|
|
115
123
|
*/
|
|
116
124
|
async didChange(uri, content) {
|
|
117
|
-
await this.ready;
|
|
118
125
|
if (!this.openedUris.has(uri)) {
|
|
119
126
|
await this.didOpen(uri, content);
|
|
120
127
|
return;
|
|
@@ -130,7 +137,6 @@ var TypstAnalyzer = class {
|
|
|
130
137
|
if (res.type === "error") throw new Error(res.message);
|
|
131
138
|
}
|
|
132
139
|
async completion(uri, line, character) {
|
|
133
|
-
await this.ready;
|
|
134
140
|
const res = await this.rpc({
|
|
135
141
|
type: "completion",
|
|
136
142
|
id: ++this.idCounter,
|
|
@@ -143,7 +149,6 @@ var TypstAnalyzer = class {
|
|
|
143
149
|
return null;
|
|
144
150
|
}
|
|
145
151
|
async hover(uri, line, character) {
|
|
146
|
-
await this.ready;
|
|
147
152
|
const res = await this.rpc({
|
|
148
153
|
type: "hover",
|
|
149
154
|
id: ++this.idCounter,
|
|
@@ -157,7 +162,6 @@ var TypstAnalyzer = class {
|
|
|
157
162
|
}
|
|
158
163
|
destroy() {
|
|
159
164
|
this.diagnosticsListeners.clear();
|
|
160
|
-
this.latestDiagnosticsByUri.clear();
|
|
161
165
|
destroyWorker(
|
|
162
166
|
this.worker,
|
|
163
167
|
{ type: "destroy", id: ++this.idCounter },
|
|
@@ -169,29 +173,23 @@ var TypstAnalyzer = class {
|
|
|
169
173
|
|
|
170
174
|
// src/analyzer-session.ts
|
|
171
175
|
var AnalyzerSession = class {
|
|
172
|
-
ready;
|
|
173
176
|
analyzer;
|
|
174
177
|
rootPath;
|
|
175
178
|
entryPath;
|
|
176
179
|
syncedFiles = /* @__PURE__ */ new Map();
|
|
177
180
|
queue = Promise.resolve();
|
|
178
|
-
syncRevision = 0;
|
|
179
181
|
// Diagnostic subscription state
|
|
180
182
|
listenersByUri = /* @__PURE__ */ new Map();
|
|
181
|
-
|
|
182
|
-
|
|
183
|
+
/** Last push received per URI. Replayed on subscribe() so tab-back shows correct diagnostics instantly. */
|
|
184
|
+
diagnosticsCache = /* @__PURE__ */ new Map();
|
|
183
185
|
unsubscribeAnalyzer;
|
|
184
186
|
constructor(options) {
|
|
185
187
|
this.analyzer = options.analyzer;
|
|
186
188
|
this.rootPath = normalizeRoot(options.rootPath ?? "/project");
|
|
187
189
|
this.entryPath = normalizePath(options.entryPath ?? "/main.typ");
|
|
188
|
-
this.ready = this.analyzer.ready;
|
|
189
190
|
this.unsubscribeAnalyzer = this.analyzer.onDiagnostics(
|
|
190
191
|
(uri, diagnostics) => {
|
|
191
|
-
|
|
192
|
-
if (this.diagnosticsHashByUri.get(uri) === nextHash) return;
|
|
193
|
-
this.diagnosticsByUri.set(uri, diagnostics);
|
|
194
|
-
this.diagnosticsHashByUri.set(uri, nextHash);
|
|
192
|
+
this.diagnosticsCache.set(uri, diagnostics);
|
|
195
193
|
const listeners = this.listenersByUri.get(uri);
|
|
196
194
|
if (!listeners) return;
|
|
197
195
|
for (const listener of listeners) listener(diagnostics);
|
|
@@ -205,7 +203,7 @@ var AnalyzerSession = class {
|
|
|
205
203
|
}
|
|
206
204
|
/**
|
|
207
205
|
* Subscribe to push-based diagnostics for a file path.
|
|
208
|
-
* Returns an unsubscribe function.
|
|
206
|
+
* Returns an unsubscribe function.
|
|
209
207
|
*/
|
|
210
208
|
subscribe(path, listener) {
|
|
211
209
|
const uri = this.toUri(path);
|
|
@@ -215,7 +213,7 @@ var AnalyzerSession = class {
|
|
|
215
213
|
this.listenersByUri.set(uri, listeners);
|
|
216
214
|
}
|
|
217
215
|
listeners.add(listener);
|
|
218
|
-
const cached = this.
|
|
216
|
+
const cached = this.diagnosticsCache.get(uri);
|
|
219
217
|
if (cached) listener(cached);
|
|
220
218
|
return () => {
|
|
221
219
|
const current = this.listenersByUri.get(uri);
|
|
@@ -225,100 +223,86 @@ var AnalyzerSession = class {
|
|
|
225
223
|
};
|
|
226
224
|
}
|
|
227
225
|
/**
|
|
228
|
-
* Sync all project files with the analyzer
|
|
229
|
-
*
|
|
226
|
+
* Sync all project files with the analyzer.
|
|
227
|
+
* `files` must include the active file's current content under `path`.
|
|
228
|
+
*
|
|
229
|
+
* If the active file's content hasn't changed since the last sync, a
|
|
230
|
+
* lightweight hover is triggered to ensure the analyzer re-analyzes with
|
|
231
|
+
* the current project state and publishes fresh diagnostics.
|
|
230
232
|
*/
|
|
231
|
-
async sync(path,
|
|
232
|
-
++this.syncRevision;
|
|
233
|
-
const activePath = normalizePath(path);
|
|
234
|
-
const mergedFiles = { ...files, [activePath]: content };
|
|
233
|
+
async sync(path, files) {
|
|
235
234
|
await this.enqueue(async () => {
|
|
236
|
-
await this.
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
235
|
+
const changed = await this.syncFiles(path, files);
|
|
236
|
+
if (!changed) {
|
|
237
|
+
try {
|
|
238
|
+
await this.analyzer.hover(this.toUri(normalizePath(path)), 0, 0);
|
|
239
|
+
} catch {
|
|
240
|
+
}
|
|
240
241
|
}
|
|
241
|
-
await this.syncFile(activePath, mergedFiles[activePath], true);
|
|
242
242
|
for (const filePath of this.syncedFiles.keys()) {
|
|
243
|
-
if (!Object.hasOwn(
|
|
243
|
+
if (!Object.hasOwn(files, filePath)) {
|
|
244
244
|
this.syncedFiles.delete(filePath);
|
|
245
245
|
}
|
|
246
246
|
}
|
|
247
247
|
});
|
|
248
248
|
}
|
|
249
|
-
/**
|
|
250
|
-
* Sync files, then compile with the provided compiler.
|
|
251
|
-
* Diagnostics come from the analyzer (push-based); the compiler provides preview artifacts.
|
|
252
|
-
*/
|
|
253
|
-
async syncAndCompile(path, content, files, compiler, onCompile, signal) {
|
|
254
|
-
await this.sync(path, content, files);
|
|
255
|
-
if (signal?.aborted) return;
|
|
256
|
-
try {
|
|
257
|
-
const result = await compiler.compile(files);
|
|
258
|
-
if (signal?.aborted) return;
|
|
259
|
-
onCompile?.(result);
|
|
260
|
-
} catch {
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
249
|
/**
|
|
264
250
|
* Sync files and request completions at the given position.
|
|
265
251
|
* Returns the raw LSP CompletionList/CompletionItem[] from tinymist.
|
|
266
252
|
*/
|
|
267
|
-
async completion(path,
|
|
268
|
-
const enqueuedRevision = this.syncRevision;
|
|
269
|
-
const activePath = normalizePath(path);
|
|
270
|
-
const mergedFiles = { ...files, [activePath]: content };
|
|
253
|
+
async completion(path, files, line, character) {
|
|
271
254
|
return this.enqueue(async () => {
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
await this.syncFile(activePath, mergedFiles[activePath], false);
|
|
279
|
-
return this.analyzer.completion(this.toUri(activePath), line, character);
|
|
255
|
+
await this.syncFiles(path, files);
|
|
256
|
+
return this.analyzer.completion(
|
|
257
|
+
this.toUri(normalizePath(path)),
|
|
258
|
+
line,
|
|
259
|
+
character
|
|
260
|
+
);
|
|
280
261
|
});
|
|
281
262
|
}
|
|
282
263
|
/**
|
|
283
264
|
* Sync files and request hover info at the given position.
|
|
284
265
|
* Returns the raw LSP Hover result from tinymist.
|
|
285
266
|
*/
|
|
286
|
-
async hover(path,
|
|
287
|
-
const enqueuedRevision = this.syncRevision;
|
|
288
|
-
const activePath = normalizePath(path);
|
|
289
|
-
const mergedFiles = { ...files, [activePath]: content };
|
|
267
|
+
async hover(path, files, line, character) {
|
|
290
268
|
return this.enqueue(async () => {
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
await this.syncFile(activePath, mergedFiles[activePath], false);
|
|
298
|
-
return this.analyzer.hover(this.toUri(activePath), line, character);
|
|
269
|
+
await this.syncFiles(path, files);
|
|
270
|
+
return this.analyzer.hover(
|
|
271
|
+
this.toUri(normalizePath(path)),
|
|
272
|
+
line,
|
|
273
|
+
character
|
|
274
|
+
);
|
|
299
275
|
});
|
|
300
276
|
}
|
|
301
277
|
destroy() {
|
|
302
278
|
this.unsubscribeAnalyzer();
|
|
303
279
|
this.listenersByUri.clear();
|
|
304
|
-
this.
|
|
305
|
-
this.diagnosticsHashByUri.clear();
|
|
280
|
+
this.diagnosticsCache.clear();
|
|
306
281
|
}
|
|
307
282
|
/**
|
|
308
|
-
* Sync
|
|
309
|
-
*
|
|
283
|
+
* Sync all project files: dependencies first, active file last.
|
|
284
|
+
* Returns whether the active file's content was actually sent to the analyzer.
|
|
310
285
|
*/
|
|
311
|
-
async
|
|
286
|
+
async syncFiles(path, files) {
|
|
287
|
+
const activePath = normalizePath(path);
|
|
288
|
+
for (const filePath of this.orderedPaths(files)) {
|
|
289
|
+
if (filePath === activePath) continue;
|
|
290
|
+
await this.syncFile(filePath, files[filePath]);
|
|
291
|
+
}
|
|
292
|
+
return this.syncFile(activePath, files[activePath]);
|
|
293
|
+
}
|
|
294
|
+
/** Sync a single file. Returns true if content was sent to the analyzer. */
|
|
295
|
+
async syncFile(path, content) {
|
|
312
296
|
const prev = this.syncedFiles.get(path);
|
|
313
|
-
if (
|
|
297
|
+
if (prev == null) {
|
|
314
298
|
await this.analyzer.didOpen(this.toUri(path), content);
|
|
315
|
-
|
|
316
|
-
return;
|
|
317
|
-
}
|
|
318
|
-
if (prev !== content) {
|
|
299
|
+
} else if (prev !== content) {
|
|
319
300
|
await this.analyzer.didChange(this.toUri(path), content);
|
|
320
|
-
|
|
301
|
+
} else {
|
|
302
|
+
return false;
|
|
321
303
|
}
|
|
304
|
+
this.syncedFiles.set(path, content);
|
|
305
|
+
return true;
|
|
322
306
|
}
|
|
323
307
|
orderedPaths(files) {
|
|
324
308
|
return Object.keys(files).map((p) => normalizePath(p)).sort((a, b) => {
|
|
@@ -336,19 +320,6 @@ var AnalyzerSession = class {
|
|
|
336
320
|
return run;
|
|
337
321
|
}
|
|
338
322
|
};
|
|
339
|
-
function diagnosticsHash(diagnostics) {
|
|
340
|
-
return JSON.stringify(
|
|
341
|
-
diagnostics.map((d) => [
|
|
342
|
-
d.range.start.line,
|
|
343
|
-
d.range.start.character,
|
|
344
|
-
d.range.end.line,
|
|
345
|
-
d.range.end.character,
|
|
346
|
-
d.severity ?? 1,
|
|
347
|
-
d.message,
|
|
348
|
-
d.source ?? ""
|
|
349
|
-
])
|
|
350
|
-
);
|
|
351
|
-
}
|
|
352
323
|
|
|
353
324
|
// src/compiler.ts
|
|
354
325
|
var DEFAULT_FONTS = [
|
|
@@ -359,32 +330,35 @@ var TIMEOUT2 = { INIT: 6e4, RENDER: 6e4, DESTROY: 5e3 };
|
|
|
359
330
|
function toFiles(source) {
|
|
360
331
|
return typeof source === "string" ? { "/main.typ": source } : source;
|
|
361
332
|
}
|
|
362
|
-
var TypstCompiler = class {
|
|
363
|
-
|
|
364
|
-
idCounter = 0;
|
|
333
|
+
var TypstCompiler = class _TypstCompiler {
|
|
334
|
+
idCounter;
|
|
365
335
|
worker;
|
|
366
336
|
/** The most recent vector artifact from a compile, if any. */
|
|
367
337
|
lastVector;
|
|
368
|
-
constructor(
|
|
369
|
-
this.worker =
|
|
370
|
-
this.
|
|
371
|
-
|
|
338
|
+
constructor(worker, idCounter) {
|
|
339
|
+
this.worker = worker;
|
|
340
|
+
this.idCounter = idCounter;
|
|
341
|
+
}
|
|
342
|
+
static async create(options = {}) {
|
|
343
|
+
const worker = options.worker ?? createWorker();
|
|
344
|
+
let idCounter = 0;
|
|
345
|
+
const res = await workerRpc(
|
|
346
|
+
worker,
|
|
372
347
|
{
|
|
373
348
|
type: "init",
|
|
374
|
-
id: ++
|
|
349
|
+
id: ++idCounter,
|
|
375
350
|
wasmUrl: options.wasmUrl ?? DEFAULT_WASM_URL,
|
|
376
351
|
fonts: options.fonts ?? DEFAULT_FONTS,
|
|
377
352
|
packages: options.packages ?? true
|
|
378
353
|
},
|
|
379
354
|
TIMEOUT2.INIT
|
|
380
|
-
)
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
355
|
+
);
|
|
356
|
+
if (res.type === "error")
|
|
357
|
+
throw new Error(`TypstCompiler init failed: ${res.message}`);
|
|
358
|
+
return new _TypstCompiler(worker, idCounter);
|
|
384
359
|
}
|
|
385
360
|
/** Compile a single source string (treated as /main.typ) or a map of files. */
|
|
386
361
|
async compile(source) {
|
|
387
|
-
await this.ready;
|
|
388
362
|
const id = ++this.idCounter;
|
|
389
363
|
const files = toFiles(source);
|
|
390
364
|
const response = await workerRpc(
|
|
@@ -406,7 +380,6 @@ var TypstCompiler = class {
|
|
|
406
380
|
}
|
|
407
381
|
/** Compile to PDF from a single source string (treated as /main.typ) or a map of files. */
|
|
408
382
|
async compilePdf(source) {
|
|
409
|
-
await this.ready;
|
|
410
383
|
const id = ++this.idCounter;
|
|
411
384
|
const files = toFiles(source);
|
|
412
385
|
const response = await workerRpc(
|
|
@@ -441,13 +414,16 @@ function getTypstyle() {
|
|
|
441
414
|
}
|
|
442
415
|
return typstylePromise;
|
|
443
416
|
}
|
|
444
|
-
var TypstFormatter = class {
|
|
417
|
+
var TypstFormatter = class _TypstFormatter {
|
|
445
418
|
config;
|
|
446
419
|
constructor(config = {}) {
|
|
447
420
|
this.config = config;
|
|
448
421
|
getTypstyle().catch(() => {
|
|
449
422
|
});
|
|
450
423
|
}
|
|
424
|
+
static create(config = {}) {
|
|
425
|
+
return new _TypstFormatter(config);
|
|
426
|
+
}
|
|
451
427
|
/** Format an entire Typst source string. */
|
|
452
428
|
async format(source) {
|
|
453
429
|
const typstyle = await getTypstyle();
|
|
@@ -475,7 +451,7 @@ function getRendererModule() {
|
|
|
475
451
|
}
|
|
476
452
|
return rendererModulePromise;
|
|
477
453
|
}
|
|
478
|
-
var TypstRenderer = class {
|
|
454
|
+
var TypstRenderer = class _TypstRenderer {
|
|
479
455
|
wasmUrl;
|
|
480
456
|
instance = null;
|
|
481
457
|
constructor(options = {}) {
|
|
@@ -483,6 +459,9 @@ var TypstRenderer = class {
|
|
|
483
459
|
getRendererModule().catch(() => {
|
|
484
460
|
});
|
|
485
461
|
}
|
|
462
|
+
static create(options = {}) {
|
|
463
|
+
return new _TypstRenderer(options);
|
|
464
|
+
}
|
|
486
465
|
getInstance() {
|
|
487
466
|
if (!this.instance) {
|
|
488
467
|
this.instance = this.#init().catch((err) => {
|