1 line
7.8 KiB
JavaScript
1 line
7.8 KiB
JavaScript
var e,t=Array(128).fill(void 0);t.push(void 0,null,!0,!1);var n=t.length;function r(e){n===t.length&&t.push(t.length+1);let r=n;return n=t[r],t[r]=e,r}function i(e){return t[e]}function a(e){e<132||(t[e]=n,n=e)}function o(e){let t=i(e);return a(e),t}var s=0,c=null;function l(){return(c===null||c.byteLength===0)&&(c=new Uint8Array(e.memory.buffer)),c}var u=typeof TextEncoder<`u`?new TextEncoder(`utf-8`):{encode:()=>{throw Error(`TextEncoder not available`)}},d=typeof u.encodeInto==`function`?function(e,t){return u.encodeInto(e,t)}:function(e,t){let n=u.encode(e);return t.set(n),{read:e.length,written:n.length}};function f(e,t,n){if(n===void 0){let n=u.encode(e),r=t(n.length,1)>>>0;return l().subarray(r,r+n.length).set(n),s=n.length,r}let r=e.length,i=t(r,1)>>>0,a=l(),o=0;for(;o<r;o++){let t=e.charCodeAt(o);if(t>127)break;a[i+o]=t}if(o!==r){o!==0&&(e=e.slice(o)),i=n(i,r,r=o+e.length*3,1)>>>0;let t=l().subarray(i+o,i+r),a=d(e,t);o+=a.written,i=n(i,r,o,1)>>>0}return s=o,i}function p(e){return e==null}var m=null;function h(){return(m===null||m.byteLength===0)&&(m=new Int32Array(e.memory.buffer)),m}var g=typeof TextDecoder<`u`?new TextDecoder(`utf-8`,{ignoreBOM:!0,fatal:!0}):{decode:()=>{throw Error(`TextDecoder not available`)}};typeof TextDecoder<`u`&&g.decode();function _(e,t){return e>>>=0,g.decode(l().subarray(e,e+t))}function v(e,t){if(!(e instanceof t))throw Error(`expected instance of ${t.name}`);return e.ptr}function y(t,n){try{return t.apply(this,n)}catch(t){e.__wbindgen_exn_store(r(t))}}var b=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(t=>e.__wbg_bbox_free(t>>>0)),x=class t{static __wrap(e){e>>>=0;let n=Object.create(t.prototype);return n.__wbg_ptr=e,b.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,b.unregister(this),e}free(){let t=this.__destroy_into_raw();e.__wbg_bbox_free(t)}get x(){return e.__wbg_get_bbox_x(this.__wbg_ptr)}set x(t){e.__wbg_set_bbox_x(this.__wbg_ptr,t)}get y(){return e.__wbg_get_bbox_y(this.__wbg_ptr)}set y(t){e.__wbg_set_bbox_y(this.__wbg_ptr,t)}get width(){return e.__wbg_get_bbox_width(this.__wbg_ptr)}set width(t){e.__wbg_set_bbox_width(this.__wbg_ptr,t)}get height(){return e.__wbg_get_bbox_height(this.__wbg_ptr)}set height(t){e.__wbg_set_bbox_height(this.__wbg_ptr,t)}},S=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(t=>e.__wbg_renderedimage_free(t>>>0)),C=class t{static __wrap(e){e>>>=0;let n=Object.create(t.prototype);return n.__wbg_ptr=e,S.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,S.unregister(this),e}free(){let t=this.__destroy_into_raw();e.__wbg_renderedimage_free(t)}get width(){return e.renderedimage_width(this.__wbg_ptr)>>>0}get height(){return e.renderedimage_height(this.__wbg_ptr)>>>0}asPng(){try{let r=e.__wbindgen_add_to_stack_pointer(-16);e.renderedimage_asPng(r,this.__wbg_ptr);var t=h()[r/4+0],n=h()[r/4+1];if(h()[r/4+2])throw o(n);return o(t)}finally{e.__wbindgen_add_to_stack_pointer(16)}}get pixels(){return o(e.renderedimage_pixels(this.__wbg_ptr))}},w=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(t=>e.__wbg_resvg_free(t>>>0)),T=class{__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,w.unregister(this),e}free(){let t=this.__destroy_into_raw();e.__wbg_resvg_free(t)}constructor(t,n,i){try{let d=e.__wbindgen_add_to_stack_pointer(-16);var a=p(n)?0:f(n,e.__wbindgen_malloc,e.__wbindgen_realloc),c=s;e.resvg_new(d,r(t),a,c,p(i)?0:r(i));var l=h()[d/4+0],u=h()[d/4+1];if(h()[d/4+2])throw o(u);return this.__wbg_ptr=l>>>0,this}finally{e.__wbindgen_add_to_stack_pointer(16)}}get width(){return e.resvg_width(this.__wbg_ptr)}get height(){return e.resvg_height(this.__wbg_ptr)}render(){try{let r=e.__wbindgen_add_to_stack_pointer(-16);e.resvg_render(r,this.__wbg_ptr);var t=h()[r/4+0],n=h()[r/4+1];if(h()[r/4+2])throw o(n);return C.__wrap(t)}finally{e.__wbindgen_add_to_stack_pointer(16)}}toString(){let t,n;try{let a=e.__wbindgen_add_to_stack_pointer(-16);e.resvg_toString(a,this.__wbg_ptr);var r=h()[a/4+0],i=h()[a/4+1];return t=r,n=i,_(r,i)}finally{e.__wbindgen_add_to_stack_pointer(16),e.__wbindgen_free(t,n,1)}}innerBBox(){let t=e.resvg_innerBBox(this.__wbg_ptr);return t===0?void 0:x.__wrap(t)}getBBox(){let t=e.resvg_getBBox(this.__wbg_ptr);return t===0?void 0:x.__wrap(t)}cropByBBox(t){v(t,x),e.resvg_cropByBBox(this.__wbg_ptr,t.__wbg_ptr)}imagesToResolve(){try{let r=e.__wbindgen_add_to_stack_pointer(-16);e.resvg_imagesToResolve(r,this.__wbg_ptr);var t=h()[r/4+0],n=h()[r/4+1];if(h()[r/4+2])throw o(n);return o(t)}finally{e.__wbindgen_add_to_stack_pointer(16)}}resolveImage(t,n){try{let a=e.__wbindgen_add_to_stack_pointer(-16),c=f(t,e.__wbindgen_malloc,e.__wbindgen_realloc),l=s;e.resvg_resolveImage(a,this.__wbg_ptr,c,l,r(n));var i=h()[a/4+0];if(h()[a/4+1])throw o(i)}finally{e.__wbindgen_add_to_stack_pointer(16)}}};async function E(e,t){if(typeof Response==`function`&&e instanceof Response){if(typeof WebAssembly.instantiateStreaming==`function`)try{return await WebAssembly.instantiateStreaming(e,t)}catch(t){if(e.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",t);else throw t}let n=await e.arrayBuffer();return await WebAssembly.instantiate(n,t)}else{let n=await WebAssembly.instantiate(e,t);return n instanceof WebAssembly.Instance?{instance:n,module:e}:n}}function D(){let t={};return t.wbg={},t.wbg.__wbg_new_28c511d9baebfa89=function(e,t){return r(Error(_(e,t)))},t.wbg.__wbindgen_memory=function(){let t=e.memory;return r(t)},t.wbg.__wbg_buffer_12d079cc21e14bdb=function(e){let t=i(e).buffer;return r(t)},t.wbg.__wbg_newwithbyteoffsetandlength_aa4a17c33a06e5cb=function(e,t,n){return r(new Uint8Array(i(e),t>>>0,n>>>0))},t.wbg.__wbindgen_object_drop_ref=function(e){o(e)},t.wbg.__wbg_new_63b92bc8671ed464=function(e){return r(new Uint8Array(i(e)))},t.wbg.__wbg_values_839f3396d5aac002=function(e){return r(i(e).values())},t.wbg.__wbg_next_196c84450b364254=function(){return y(function(e){return r(i(e).next())},arguments)},t.wbg.__wbg_done_298b57d23c0fc80c=function(e){return i(e).done},t.wbg.__wbg_value_d93c65011f51a456=function(e){let t=i(e).value;return r(t)},t.wbg.__wbg_instanceof_Uint8Array_2b3bbecd033d19f6=function(e){let t;try{t=i(e)instanceof Uint8Array}catch{t=!1}return t},t.wbg.__wbindgen_string_get=function(t,n){let r=i(n),a=typeof r==`string`?r:void 0;var o=p(a)?0:f(a,e.__wbindgen_malloc,e.__wbindgen_realloc),c=s;h()[t/4+1]=c,h()[t/4+0]=o},t.wbg.__wbg_new_16b304a2cfa7ff4a=function(){return r([])},t.wbg.__wbindgen_string_new=function(e,t){return r(_(e,t))},t.wbg.__wbg_push_a5b05aedc7234f9f=function(e,t){return i(e).push(i(t))},t.wbg.__wbg_length_c20a40f15020d68a=function(e){return i(e).length},t.wbg.__wbg_set_a47bac70306a19a7=function(e,t,n){i(e).set(i(t),n>>>0)},t.wbg.__wbindgen_throw=function(e,t){throw Error(_(e,t))},t}function O(t,n){return e=t.exports,k.__wbindgen_wasm_module=n,m=null,c=null,e}async function k(t){if(e!==void 0)return e;t===void 0&&(t=new URL(`index_bg.wasm`,void 0));let n=D();(typeof t==`string`||typeof Request==`function`&&t instanceof Request||typeof URL==`function`&&t instanceof URL)&&(t=fetch(t));let{instance:r,module:i}=await E(await t,n);return O(r,i)}var A=k,j=!1,M=async e=>{if(j)throw Error("Already initialized. The `initWasm()` function can be used only once.");await A(await e),j=!0},N=class extends T{constructor(e,t){if(!j)throw Error("Wasm has not been initialized. Call `initWasm()` function.");let n=t?.font;if(n&&P(n)){let r={...t,font:{...n,fontBuffers:void 0}};super(e,JSON.stringify(r),n.fontBuffers)}else super(e,JSON.stringify(t))}};function P(e){return Object.prototype.hasOwnProperty.call(e,`fontBuffers`)}export{N as Resvg,M as initWasm}; |