diff --git a/Cargo.toml b/Cargo.toml index 22687f7d..3cea5cce 100755 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,8 +30,8 @@ mimalloc = "0.1" mimalloc = { version = "0.1", features = ["local_dynamic_tls"] } [target.'cfg(target_arch = "wasm32")'.dependencies] -wasm-bindgen = "0.2.87" -js-sys = "0.3.64" +wasm-bindgen = "0.2.92" +js-sys = "0.3.69" resvg = { version = "0.34.0", default-features = false, features = [ "raster-images", "text", diff --git a/wasm/index.js b/wasm/index.js index 57d07aba..bb90fef2 100644 --- a/wasm/index.js +++ b/wasm/index.js @@ -99,6 +99,7 @@ function passStringToWasm0(arg, malloc, realloc) { const view = getUint8Memory0().subarray(ptr + offset, ptr + len); const ret = encodeString(arg, view); offset += ret.written; + ptr = realloc(ptr, len, offset, 1) >>> 0; } WASM_VECTOR_LEN = offset; return ptr; @@ -136,16 +137,21 @@ function handleError(f, args) { wasm.__wbindgen_exn_store(addHeapObject(e)); } } +var BBoxFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => { +}, unregister: () => { +} } : new FinalizationRegistry((ptr) => wasm.__wbg_bbox_free(ptr >>> 0)); var BBox = class _BBox { static __wrap(ptr) { ptr = ptr >>> 0; const obj = Object.create(_BBox.prototype); obj.__wbg_ptr = ptr; + BBoxFinalization.register(obj, obj.__wbg_ptr, obj); return obj; } __destroy_into_raw() { const ptr = this.__wbg_ptr; this.__wbg_ptr = 0; + BBoxFinalization.unregister(this); return ptr; } free() { @@ -205,16 +211,21 @@ var BBox = class _BBox { wasm.__wbg_set_bbox_height(this.__wbg_ptr, arg0); } }; +var RenderedImageFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => { +}, unregister: () => { +} } : new FinalizationRegistry((ptr) => wasm.__wbg_renderedimage_free(ptr >>> 0)); var RenderedImage = class _RenderedImage { static __wrap(ptr) { ptr = ptr >>> 0; const obj = Object.create(_RenderedImage.prototype); obj.__wbg_ptr = ptr; + RenderedImageFinalization.register(obj, obj.__wbg_ptr, obj); return obj; } __destroy_into_raw() { const ptr = this.__wbg_ptr; this.__wbg_ptr = 0; + RenderedImageFinalization.unregister(this); return ptr; } free() { @@ -265,16 +276,14 @@ var RenderedImage = class _RenderedImage { return takeObject(ret); } }; -var Resvg = class _Resvg { - static __wrap(ptr) { - ptr = ptr >>> 0; - const obj = Object.create(_Resvg.prototype); - obj.__wbg_ptr = ptr; - return obj; - } +var ResvgFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => { +}, unregister: () => { +} } : new FinalizationRegistry((ptr) => wasm.__wbg_resvg_free(ptr >>> 0)); +var Resvg = class { __destroy_into_raw() { const ptr = this.__wbg_ptr; this.__wbg_ptr = 0; + ResvgFinalization.unregister(this); return ptr; } free() { @@ -283,8 +292,8 @@ var Resvg = class _Resvg { } /** * @param {Uint8Array | string} svg - * @param {string | undefined} options - * @param {Array | undefined} custom_font_buffers + * @param {string | undefined} [options] + * @param {Array | undefined} [custom_font_buffers] */ constructor(svg, options, custom_font_buffers) { try { @@ -298,7 +307,8 @@ var Resvg = class _Resvg { if (r2) { throw takeObject(r1); } - return _Resvg.__wrap(r0); + this.__wbg_ptr = r0 >>> 0; + return this; } finally { wasm.__wbindgen_add_to_stack_pointer(16); } @@ -452,7 +462,7 @@ async function __wbg_load(module2, imports) { function __wbg_get_imports() { const imports = {}; imports.wbg = {}; - imports.wbg.__wbg_new_d258248ed531ff54 = function(arg0, arg1) { + imports.wbg.__wbg_new_28c511d9baebfa89 = function(arg0, arg1) { const ret = new Error(getStringFromWasm0(arg0, arg1)); return addHeapObject(ret); }; @@ -460,44 +470,44 @@ function __wbg_get_imports() { const ret = wasm.memory; return addHeapObject(ret); }; - imports.wbg.__wbg_buffer_085ec1f694018c4f = function(arg0) { + imports.wbg.__wbg_buffer_12d079cc21e14bdb = function(arg0) { const ret = getObject(arg0).buffer; return addHeapObject(ret); }; - imports.wbg.__wbg_newwithbyteoffsetandlength_6da8e527659b86aa = function(arg0, arg1, arg2) { + imports.wbg.__wbg_newwithbyteoffsetandlength_aa4a17c33a06e5cb = function(arg0, arg1, arg2) { const ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0); return addHeapObject(ret); }; imports.wbg.__wbindgen_object_drop_ref = function(arg0) { takeObject(arg0); }; - imports.wbg.__wbg_new_8125e318e6245eed = function(arg0) { + imports.wbg.__wbg_new_63b92bc8671ed464 = function(arg0) { const ret = new Uint8Array(getObject(arg0)); return addHeapObject(ret); }; - imports.wbg.__wbg_values_e80af618f92c8649 = function(arg0) { + imports.wbg.__wbg_values_839f3396d5aac002 = function(arg0) { const ret = getObject(arg0).values(); return addHeapObject(ret); }; - imports.wbg.__wbg_next_ddb3312ca1c4e32a = function() { + imports.wbg.__wbg_next_196c84450b364254 = function() { return handleError(function(arg0) { const ret = getObject(arg0).next(); return addHeapObject(ret); }, arguments); }; - imports.wbg.__wbg_done_5c1f01fb660d73b5 = function(arg0) { + imports.wbg.__wbg_done_298b57d23c0fc80c = function(arg0) { const ret = getObject(arg0).done; return ret; }; - imports.wbg.__wbg_value_1695675138684bd5 = function(arg0) { + imports.wbg.__wbg_value_d93c65011f51a456 = function(arg0) { const ret = getObject(arg0).value; return addHeapObject(ret); }; - imports.wbg.__wbg_instanceof_Uint8Array_d8d9cb2b8e8ac1d4 = function(arg0) { + imports.wbg.__wbg_instanceof_Uint8Array_2b3bbecd033d19f6 = function(arg0) { let result; try { result = getObject(arg0) instanceof Uint8Array; - } catch { + } catch (_) { result = false; } const ret = result; @@ -511,7 +521,7 @@ function __wbg_get_imports() { getInt32Memory0()[arg0 / 4 + 1] = len1; getInt32Memory0()[arg0 / 4 + 0] = ptr1; }; - imports.wbg.__wbg_new_898a68150f225f2e = function() { + imports.wbg.__wbg_new_16b304a2cfa7ff4a = function() { const ret = new Array(); return addHeapObject(ret); }; @@ -519,15 +529,15 @@ function __wbg_get_imports() { const ret = getStringFromWasm0(arg0, arg1); return addHeapObject(ret); }; - imports.wbg.__wbg_push_ca1c26067ef907ac = function(arg0, arg1) { + imports.wbg.__wbg_push_a5b05aedc7234f9f = function(arg0, arg1) { const ret = getObject(arg0).push(getObject(arg1)); return ret; }; - imports.wbg.__wbg_length_72e2208bbc0efc61 = function(arg0) { + imports.wbg.__wbg_length_c20a40f15020d68a = function(arg0) { const ret = getObject(arg0).length; return ret; }; - imports.wbg.__wbg_set_5cf90238115182c3 = function(arg0, arg1, arg2) { + imports.wbg.__wbg_set_a47bac70306a19a7 = function(arg0, arg1, arg2) { getObject(arg0).set(getObject(arg1), arg2 >>> 0); }; imports.wbg.__wbindgen_throw = function(arg0, arg1) { diff --git a/wasm/index.min.js b/wasm/index.min.js index 717a64dc..7a7aa7f1 100644 --- a/wasm/index.min.js +++ b/wasm/index.min.js @@ -1 +1 @@ -"use strict";var resvg=(()=>{var B=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var M=Object.prototype.hasOwnProperty;var C=(e,t)=>{for(var n in t)B(e,n,{get:t[n],enumerable:!0})},F=(e,t,n,_)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of U(t))!M.call(e,o)&&o!==n&&B(e,o,{get:()=>t[o],enumerable:!(_=j(t,o))||_.enumerable});return e};var L=e=>F(B({},"__esModule",{value:!0}),e);var K={};C(K,{Resvg:()=>$,initWasm:()=>V});var r,w=new Array(128).fill(void 0);w.push(void 0,null,!0,!1);var p=w.length;function a(e){p===w.length&&w.push(w.length+1);let t=p;return p=w[t],w[t]=e,t}function c(e){return w[e]}function z(e){e<132||(w[e]=p,p=e)}function f(e){let t=c(e);return z(e),t}var y=0,d=null;function v(){return(d===null||d.byteLength===0)&&(d=new Uint8Array(r.memory.buffer)),d}var x=typeof TextEncoder<"u"?new TextEncoder("utf-8"):{encode:()=>{throw Error("TextEncoder not available")}},D=typeof x.encodeInto=="function"?function(e,t){return x.encodeInto(e,t)}:function(e,t){let n=x.encode(e);return t.set(n),{read:e.length,written:n.length}};function W(e,t,n){if(n===void 0){let b=x.encode(e),u=t(b.length,1)>>>0;return v().subarray(u,u+b.length).set(b),y=b.length,u}let _=e.length,o=t(_,1)>>>0,g=v(),s=0;for(;s<_;s++){let b=e.charCodeAt(s);if(b>127)break;g[o+s]=b}if(s!==_){s!==0&&(e=e.slice(s)),o=n(o,_,_=s+e.length*3,1)>>>0;let b=v().subarray(o+s,o+_),u=D(e,b);s+=u.written}return y=s,o}function k(e){return e==null}var l=null;function i(){return(l===null||l.byteLength===0)&&(l=new Int32Array(r.memory.buffer)),l}var R=typeof TextDecoder<"u"?new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}):{decode:()=>{throw Error("TextDecoder not available")}};typeof TextDecoder<"u"&&R.decode();function O(e,t){return e=e>>>0,R.decode(v().subarray(e,e+t))}function P(e,t){if(!(e instanceof t))throw new Error(`expected instance of ${t.name}`);return e.ptr}function N(e,t){try{return e.apply(this,t)}catch(n){r.__wbindgen_exn_store(a(n))}}var h=class e{static __wrap(t){t=t>>>0;let n=Object.create(e.prototype);return n.__wbg_ptr=t,n}__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,t}free(){let t=this.__destroy_into_raw();r.__wbg_bbox_free(t)}get x(){return r.__wbg_get_bbox_x(this.__wbg_ptr)}set x(t){r.__wbg_set_bbox_x(this.__wbg_ptr,t)}get y(){return r.__wbg_get_bbox_y(this.__wbg_ptr)}set y(t){r.__wbg_set_bbox_y(this.__wbg_ptr,t)}get width(){return r.__wbg_get_bbox_width(this.__wbg_ptr)}set width(t){r.__wbg_set_bbox_width(this.__wbg_ptr,t)}get height(){return r.__wbg_get_bbox_height(this.__wbg_ptr)}set height(t){r.__wbg_set_bbox_height(this.__wbg_ptr,t)}},E=class e{static __wrap(t){t=t>>>0;let n=Object.create(e.prototype);return n.__wbg_ptr=t,n}__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,t}free(){let t=this.__destroy_into_raw();r.__wbg_renderedimage_free(t)}get width(){return r.renderedimage_width(this.__wbg_ptr)>>>0}get height(){return r.renderedimage_height(this.__wbg_ptr)>>>0}asPng(){try{let o=r.__wbindgen_add_to_stack_pointer(-16);r.renderedimage_asPng(o,this.__wbg_ptr);var t=i()[o/4+0],n=i()[o/4+1],_=i()[o/4+2];if(_)throw f(n);return f(t)}finally{r.__wbindgen_add_to_stack_pointer(16)}}get pixels(){let t=r.renderedimage_pixels(this.__wbg_ptr);return f(t)}},A=class e{static __wrap(t){t=t>>>0;let n=Object.create(e.prototype);return n.__wbg_ptr=t,n}__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,t}free(){let t=this.__destroy_into_raw();r.__wbg_resvg_free(t)}constructor(t,n,_){try{let m=r.__wbindgen_add_to_stack_pointer(-16);var o=k(n)?0:W(n,r.__wbindgen_malloc,r.__wbindgen_realloc),g=y;r.resvg_new(m,a(t),o,g,k(_)?0:a(_));var s=i()[m/4+0],b=i()[m/4+1],u=i()[m/4+2];if(u)throw f(b);return e.__wrap(s)}finally{r.__wbindgen_add_to_stack_pointer(16)}}get width(){return r.resvg_width(this.__wbg_ptr)}get height(){return r.resvg_height(this.__wbg_ptr)}render(){try{let o=r.__wbindgen_add_to_stack_pointer(-16);r.resvg_render(o,this.__wbg_ptr);var t=i()[o/4+0],n=i()[o/4+1],_=i()[o/4+2];if(_)throw f(n);return E.__wrap(t)}finally{r.__wbindgen_add_to_stack_pointer(16)}}toString(){let t,n;try{let g=r.__wbindgen_add_to_stack_pointer(-16);r.resvg_toString(g,this.__wbg_ptr);var _=i()[g/4+0],o=i()[g/4+1];return t=_,n=o,O(_,o)}finally{r.__wbindgen_add_to_stack_pointer(16),r.__wbindgen_free(t,n,1)}}innerBBox(){let t=r.resvg_innerBBox(this.__wbg_ptr);return t===0?void 0:h.__wrap(t)}getBBox(){let t=r.resvg_getBBox(this.__wbg_ptr);return t===0?void 0:h.__wrap(t)}cropByBBox(t){P(t,h),r.resvg_cropByBBox(this.__wbg_ptr,t.__wbg_ptr)}imagesToResolve(){try{let o=r.__wbindgen_add_to_stack_pointer(-16);r.resvg_imagesToResolve(o,this.__wbg_ptr);var t=i()[o/4+0],n=i()[o/4+1],_=i()[o/4+2];if(_)throw f(n);return f(t)}finally{r.__wbindgen_add_to_stack_pointer(16)}}resolveImage(t,n){try{let g=r.__wbindgen_add_to_stack_pointer(-16),s=W(t,r.__wbindgen_malloc,r.__wbindgen_realloc),b=y;r.resvg_resolveImage(g,this.__wbg_ptr,s,b,a(n));var _=i()[g/4+0],o=i()[g/4+1];if(o)throw f(_)}finally{r.__wbindgen_add_to_stack_pointer(16)}}};async function q(e,t){if(typeof Response=="function"&&e instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(e,t)}catch(_){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",_);else throw _}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 J(){let e={};return e.wbg={},e.wbg.__wbg_new_d258248ed531ff54=function(t,n){let _=new Error(O(t,n));return a(_)},e.wbg.__wbindgen_memory=function(){let t=r.memory;return a(t)},e.wbg.__wbg_buffer_085ec1f694018c4f=function(t){let n=c(t).buffer;return a(n)},e.wbg.__wbg_newwithbyteoffsetandlength_6da8e527659b86aa=function(t,n,_){let o=new Uint8Array(c(t),n>>>0,_>>>0);return a(o)},e.wbg.__wbindgen_object_drop_ref=function(t){f(t)},e.wbg.__wbg_new_8125e318e6245eed=function(t){let n=new Uint8Array(c(t));return a(n)},e.wbg.__wbg_values_e80af618f92c8649=function(t){let n=c(t).values();return a(n)},e.wbg.__wbg_next_ddb3312ca1c4e32a=function(){return N(function(t){let n=c(t).next();return a(n)},arguments)},e.wbg.__wbg_done_5c1f01fb660d73b5=function(t){return c(t).done},e.wbg.__wbg_value_1695675138684bd5=function(t){let n=c(t).value;return a(n)},e.wbg.__wbg_instanceof_Uint8Array_d8d9cb2b8e8ac1d4=function(t){let n;try{n=c(t)instanceof Uint8Array}catch{n=!1}return n},e.wbg.__wbindgen_string_get=function(t,n){let _=c(n),o=typeof _=="string"?_:void 0;var g=k(o)?0:W(o,r.__wbindgen_malloc,r.__wbindgen_realloc),s=y;i()[t/4+1]=s,i()[t/4+0]=g},e.wbg.__wbg_new_898a68150f225f2e=function(){let t=new Array;return a(t)},e.wbg.__wbindgen_string_new=function(t,n){let _=O(t,n);return a(_)},e.wbg.__wbg_push_ca1c26067ef907ac=function(t,n){return c(t).push(c(n))},e.wbg.__wbg_length_72e2208bbc0efc61=function(t){return c(t).length},e.wbg.__wbg_set_5cf90238115182c3=function(t,n,_){c(t).set(c(n),_>>>0)},e.wbg.__wbindgen_throw=function(t,n){throw new Error(O(t,n))},e}function H(e,t){return r=e.exports,T.__wbindgen_wasm_module=t,l=null,d=null,r}async function T(e){if(r!==void 0)return r;typeof e>"u"&&(e=new URL("index_bg.wasm",void 0));let t=J();(typeof e=="string"||typeof Request=="function"&&e instanceof Request||typeof URL=="function"&&e instanceof URL)&&(e=fetch(e));let{instance:n,module:_}=await q(await e,t);return H(n,_)}var S=T;var I=!1,V=async e=>{if(I)throw new Error("Already initialized. The `initWasm()` function can be used only once.");await S(await e),I=!0},$=class extends A{constructor(e,t){if(!I)throw new Error("Wasm has not been initialized. Call `initWasm()` function.");let n=t?.font;if(n&&G(n)){let _={...t,font:{...n,fontBuffers:void 0}};super(e,JSON.stringify(_),n.fontBuffers)}else super(e,JSON.stringify(t))}};function G(e){return Object.prototype.hasOwnProperty.call(e,"fontBuffers")}return L(K);})(); +"use strict";var resvg=(()=>{var O=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var M=Object.prototype.hasOwnProperty;var C=(e,t)=>{for(var n in t)O(e,n,{get:t[n],enumerable:!0})},L=(e,t,n,_)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of U(t))!M.call(e,i)&&i!==n&&O(e,i,{get:()=>t[i],enumerable:!(_=j(t,i))||_.enumerable});return e};var D=e=>L(O({},"__esModule",{value:!0}),e);var Y={};C(Y,{Resvg:()=>Q,initWasm:()=>K});var r,w=new Array(128).fill(void 0);w.push(void 0,null,!0,!1);var p=w.length;function c(e){p===w.length&&w.push(w.length+1);let t=p;return p=w[t],w[t]=e,t}function a(e){return w[e]}function P(e){e<132||(w[e]=p,p=e)}function f(e){let t=a(e);return P(e),t}var y=0,u=null;function v(){return(u===null||u.byteLength===0)&&(u=new Uint8Array(r.memory.buffer)),u}var x=typeof TextEncoder<"u"?new TextEncoder("utf-8"):{encode:()=>{throw Error("TextEncoder not available")}},N=typeof x.encodeInto=="function"?function(e,t){return x.encodeInto(e,t)}:function(e,t){let n=x.encode(e);return t.set(n),{read:e.length,written:n.length}};function B(e,t,n){if(n===void 0){let b=x.encode(e),d=t(b.length,1)>>>0;return v().subarray(d,d+b.length).set(b),y=b.length,d}let _=e.length,i=t(_,1)>>>0,g=v(),o=0;for(;o<_;o++){let b=e.charCodeAt(o);if(b>127)break;g[i+o]=b}if(o!==_){o!==0&&(e=e.slice(o)),i=n(i,_,_=o+e.length*3,1)>>>0;let b=v().subarray(i+o,i+_),d=N(e,b);o+=d.written,i=n(i,_,o,1)>>>0}return y=o,i}function F(e){return e==null}var l=null;function s(){return(l===null||l.byteLength===0)&&(l=new Int32Array(r.memory.buffer)),l}var T=typeof TextDecoder<"u"?new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}):{decode:()=>{throw Error("TextDecoder not available")}};typeof TextDecoder<"u"&&T.decode();function R(e,t){return e=e>>>0,T.decode(v().subarray(e,e+t))}function q(e,t){if(!(e instanceof t))throw new Error(`expected instance of ${t.name}`);return e.ptr}function J(e,t){try{return e.apply(this,t)}catch(n){r.__wbindgen_exn_store(c(n))}}var k=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>r.__wbg_bbox_free(e>>>0)),h=class e{static __wrap(t){t=t>>>0;let n=Object.create(e.prototype);return n.__wbg_ptr=t,k.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,k.unregister(this),t}free(){let t=this.__destroy_into_raw();r.__wbg_bbox_free(t)}get x(){return r.__wbg_get_bbox_x(this.__wbg_ptr)}set x(t){r.__wbg_set_bbox_x(this.__wbg_ptr,t)}get y(){return r.__wbg_get_bbox_y(this.__wbg_ptr)}set y(t){r.__wbg_set_bbox_y(this.__wbg_ptr,t)}get width(){return r.__wbg_get_bbox_width(this.__wbg_ptr)}set width(t){r.__wbg_set_bbox_width(this.__wbg_ptr,t)}get height(){return r.__wbg_get_bbox_height(this.__wbg_ptr)}set height(t){r.__wbg_set_bbox_height(this.__wbg_ptr,t)}},E=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>r.__wbg_renderedimage_free(e>>>0)),W=class e{static __wrap(t){t=t>>>0;let n=Object.create(e.prototype);return n.__wbg_ptr=t,E.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,E.unregister(this),t}free(){let t=this.__destroy_into_raw();r.__wbg_renderedimage_free(t)}get width(){return r.renderedimage_width(this.__wbg_ptr)>>>0}get height(){return r.renderedimage_height(this.__wbg_ptr)>>>0}asPng(){try{let i=r.__wbindgen_add_to_stack_pointer(-16);r.renderedimage_asPng(i,this.__wbg_ptr);var t=s()[i/4+0],n=s()[i/4+1],_=s()[i/4+2];if(_)throw f(n);return f(t)}finally{r.__wbindgen_add_to_stack_pointer(16)}}get pixels(){let t=r.renderedimage_pixels(this.__wbg_ptr);return f(t)}},H=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>r.__wbg_resvg_free(e>>>0)),A=class{__destroy_into_raw(){let t=this.__wbg_ptr;return this.__wbg_ptr=0,H.unregister(this),t}free(){let t=this.__destroy_into_raw();r.__wbg_resvg_free(t)}constructor(t,n,_){try{let m=r.__wbindgen_add_to_stack_pointer(-16);var i=F(n)?0:B(n,r.__wbindgen_malloc,r.__wbindgen_realloc),g=y;r.resvg_new(m,c(t),i,g,F(_)?0:c(_));var o=s()[m/4+0],b=s()[m/4+1],d=s()[m/4+2];if(d)throw f(b);return this.__wbg_ptr=o>>>0,this}finally{r.__wbindgen_add_to_stack_pointer(16)}}get width(){return r.resvg_width(this.__wbg_ptr)}get height(){return r.resvg_height(this.__wbg_ptr)}render(){try{let i=r.__wbindgen_add_to_stack_pointer(-16);r.resvg_render(i,this.__wbg_ptr);var t=s()[i/4+0],n=s()[i/4+1],_=s()[i/4+2];if(_)throw f(n);return W.__wrap(t)}finally{r.__wbindgen_add_to_stack_pointer(16)}}toString(){let t,n;try{let g=r.__wbindgen_add_to_stack_pointer(-16);r.resvg_toString(g,this.__wbg_ptr);var _=s()[g/4+0],i=s()[g/4+1];return t=_,n=i,R(_,i)}finally{r.__wbindgen_add_to_stack_pointer(16),r.__wbindgen_free(t,n,1)}}innerBBox(){let t=r.resvg_innerBBox(this.__wbg_ptr);return t===0?void 0:h.__wrap(t)}getBBox(){let t=r.resvg_getBBox(this.__wbg_ptr);return t===0?void 0:h.__wrap(t)}cropByBBox(t){q(t,h),r.resvg_cropByBBox(this.__wbg_ptr,t.__wbg_ptr)}imagesToResolve(){try{let i=r.__wbindgen_add_to_stack_pointer(-16);r.resvg_imagesToResolve(i,this.__wbg_ptr);var t=s()[i/4+0],n=s()[i/4+1],_=s()[i/4+2];if(_)throw f(n);return f(t)}finally{r.__wbindgen_add_to_stack_pointer(16)}}resolveImage(t,n){try{let g=r.__wbindgen_add_to_stack_pointer(-16),o=B(t,r.__wbindgen_malloc,r.__wbindgen_realloc),b=y;r.resvg_resolveImage(g,this.__wbg_ptr,o,b,c(n));var _=s()[g/4+0],i=s()[g/4+1];if(i)throw f(_)}finally{r.__wbindgen_add_to_stack_pointer(16)}}};async function V(e,t){if(typeof Response=="function"&&e instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(e,t)}catch(_){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",_);else throw _}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 $(){let e={};return e.wbg={},e.wbg.__wbg_new_28c511d9baebfa89=function(t,n){let _=new Error(R(t,n));return c(_)},e.wbg.__wbindgen_memory=function(){let t=r.memory;return c(t)},e.wbg.__wbg_buffer_12d079cc21e14bdb=function(t){let n=a(t).buffer;return c(n)},e.wbg.__wbg_newwithbyteoffsetandlength_aa4a17c33a06e5cb=function(t,n,_){let i=new Uint8Array(a(t),n>>>0,_>>>0);return c(i)},e.wbg.__wbindgen_object_drop_ref=function(t){f(t)},e.wbg.__wbg_new_63b92bc8671ed464=function(t){let n=new Uint8Array(a(t));return c(n)},e.wbg.__wbg_values_839f3396d5aac002=function(t){let n=a(t).values();return c(n)},e.wbg.__wbg_next_196c84450b364254=function(){return J(function(t){let n=a(t).next();return c(n)},arguments)},e.wbg.__wbg_done_298b57d23c0fc80c=function(t){return a(t).done},e.wbg.__wbg_value_d93c65011f51a456=function(t){let n=a(t).value;return c(n)},e.wbg.__wbg_instanceof_Uint8Array_2b3bbecd033d19f6=function(t){let n;try{n=a(t)instanceof Uint8Array}catch{n=!1}return n},e.wbg.__wbindgen_string_get=function(t,n){let _=a(n),i=typeof _=="string"?_:void 0;var g=F(i)?0:B(i,r.__wbindgen_malloc,r.__wbindgen_realloc),o=y;s()[t/4+1]=o,s()[t/4+0]=g},e.wbg.__wbg_new_16b304a2cfa7ff4a=function(){let t=new Array;return c(t)},e.wbg.__wbindgen_string_new=function(t,n){let _=R(t,n);return c(_)},e.wbg.__wbg_push_a5b05aedc7234f9f=function(t,n){return a(t).push(a(n))},e.wbg.__wbg_length_c20a40f15020d68a=function(t){return a(t).length},e.wbg.__wbg_set_a47bac70306a19a7=function(t,n,_){a(t).set(a(n),_>>>0)},e.wbg.__wbindgen_throw=function(t,n){throw new Error(R(t,n))},e}function G(e,t){return r=e.exports,z.__wbindgen_wasm_module=t,l=null,u=null,r}async function z(e){if(r!==void 0)return r;typeof e>"u"&&(e=new URL("index_bg.wasm",void 0));let t=$();(typeof e=="string"||typeof Request=="function"&&e instanceof Request||typeof URL=="function"&&e instanceof URL)&&(e=fetch(e));let{instance:n,module:_}=await V(await e,t);return G(n,_)}var S=z;var I=!1,K=async e=>{if(I)throw new Error("Already initialized. The `initWasm()` function can be used only once.");await S(await e),I=!0},Q=class extends A{constructor(e,t){if(!I)throw new Error("Wasm has not been initialized. Call `initWasm()` function.");let n=t?.font;if(n&&X(n)){let _={...t,font:{...n,fontBuffers:void 0}};super(e,JSON.stringify(_),n.fontBuffers)}else super(e,JSON.stringify(t))}};function X(e){return Object.prototype.hasOwnProperty.call(e,"fontBuffers")}return D(Y);})(); diff --git a/wasm/index.mjs b/wasm/index.mjs index e0281ba5..60f7b616 100644 --- a/wasm/index.mjs +++ b/wasm/index.mjs @@ -72,6 +72,7 @@ function passStringToWasm0(arg, malloc, realloc) { const view = getUint8Memory0().subarray(ptr + offset, ptr + len); const ret = encodeString(arg, view); offset += ret.written; + ptr = realloc(ptr, len, offset, 1) >>> 0; } WASM_VECTOR_LEN = offset; return ptr; @@ -109,16 +110,21 @@ function handleError(f, args) { wasm.__wbindgen_exn_store(addHeapObject(e)); } } +var BBoxFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => { +}, unregister: () => { +} } : new FinalizationRegistry((ptr) => wasm.__wbg_bbox_free(ptr >>> 0)); var BBox = class _BBox { static __wrap(ptr) { ptr = ptr >>> 0; const obj = Object.create(_BBox.prototype); obj.__wbg_ptr = ptr; + BBoxFinalization.register(obj, obj.__wbg_ptr, obj); return obj; } __destroy_into_raw() { const ptr = this.__wbg_ptr; this.__wbg_ptr = 0; + BBoxFinalization.unregister(this); return ptr; } free() { @@ -178,16 +184,21 @@ var BBox = class _BBox { wasm.__wbg_set_bbox_height(this.__wbg_ptr, arg0); } }; +var RenderedImageFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => { +}, unregister: () => { +} } : new FinalizationRegistry((ptr) => wasm.__wbg_renderedimage_free(ptr >>> 0)); var RenderedImage = class _RenderedImage { static __wrap(ptr) { ptr = ptr >>> 0; const obj = Object.create(_RenderedImage.prototype); obj.__wbg_ptr = ptr; + RenderedImageFinalization.register(obj, obj.__wbg_ptr, obj); return obj; } __destroy_into_raw() { const ptr = this.__wbg_ptr; this.__wbg_ptr = 0; + RenderedImageFinalization.unregister(this); return ptr; } free() { @@ -238,16 +249,14 @@ var RenderedImage = class _RenderedImage { return takeObject(ret); } }; -var Resvg = class _Resvg { - static __wrap(ptr) { - ptr = ptr >>> 0; - const obj = Object.create(_Resvg.prototype); - obj.__wbg_ptr = ptr; - return obj; - } +var ResvgFinalization = typeof FinalizationRegistry === "undefined" ? { register: () => { +}, unregister: () => { +} } : new FinalizationRegistry((ptr) => wasm.__wbg_resvg_free(ptr >>> 0)); +var Resvg = class { __destroy_into_raw() { const ptr = this.__wbg_ptr; this.__wbg_ptr = 0; + ResvgFinalization.unregister(this); return ptr; } free() { @@ -256,8 +265,8 @@ var Resvg = class _Resvg { } /** * @param {Uint8Array | string} svg - * @param {string | undefined} options - * @param {Array | undefined} custom_font_buffers + * @param {string | undefined} [options] + * @param {Array | undefined} [custom_font_buffers] */ constructor(svg, options, custom_font_buffers) { try { @@ -271,7 +280,8 @@ var Resvg = class _Resvg { if (r2) { throw takeObject(r1); } - return _Resvg.__wrap(r0); + this.__wbg_ptr = r0 >>> 0; + return this; } finally { wasm.__wbindgen_add_to_stack_pointer(16); } @@ -425,7 +435,7 @@ async function __wbg_load(module, imports) { function __wbg_get_imports() { const imports = {}; imports.wbg = {}; - imports.wbg.__wbg_new_d258248ed531ff54 = function(arg0, arg1) { + imports.wbg.__wbg_new_28c511d9baebfa89 = function(arg0, arg1) { const ret = new Error(getStringFromWasm0(arg0, arg1)); return addHeapObject(ret); }; @@ -433,44 +443,44 @@ function __wbg_get_imports() { const ret = wasm.memory; return addHeapObject(ret); }; - imports.wbg.__wbg_buffer_085ec1f694018c4f = function(arg0) { + imports.wbg.__wbg_buffer_12d079cc21e14bdb = function(arg0) { const ret = getObject(arg0).buffer; return addHeapObject(ret); }; - imports.wbg.__wbg_newwithbyteoffsetandlength_6da8e527659b86aa = function(arg0, arg1, arg2) { + imports.wbg.__wbg_newwithbyteoffsetandlength_aa4a17c33a06e5cb = function(arg0, arg1, arg2) { const ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0); return addHeapObject(ret); }; imports.wbg.__wbindgen_object_drop_ref = function(arg0) { takeObject(arg0); }; - imports.wbg.__wbg_new_8125e318e6245eed = function(arg0) { + imports.wbg.__wbg_new_63b92bc8671ed464 = function(arg0) { const ret = new Uint8Array(getObject(arg0)); return addHeapObject(ret); }; - imports.wbg.__wbg_values_e80af618f92c8649 = function(arg0) { + imports.wbg.__wbg_values_839f3396d5aac002 = function(arg0) { const ret = getObject(arg0).values(); return addHeapObject(ret); }; - imports.wbg.__wbg_next_ddb3312ca1c4e32a = function() { + imports.wbg.__wbg_next_196c84450b364254 = function() { return handleError(function(arg0) { const ret = getObject(arg0).next(); return addHeapObject(ret); }, arguments); }; - imports.wbg.__wbg_done_5c1f01fb660d73b5 = function(arg0) { + imports.wbg.__wbg_done_298b57d23c0fc80c = function(arg0) { const ret = getObject(arg0).done; return ret; }; - imports.wbg.__wbg_value_1695675138684bd5 = function(arg0) { + imports.wbg.__wbg_value_d93c65011f51a456 = function(arg0) { const ret = getObject(arg0).value; return addHeapObject(ret); }; - imports.wbg.__wbg_instanceof_Uint8Array_d8d9cb2b8e8ac1d4 = function(arg0) { + imports.wbg.__wbg_instanceof_Uint8Array_2b3bbecd033d19f6 = function(arg0) { let result; try { result = getObject(arg0) instanceof Uint8Array; - } catch { + } catch (_) { result = false; } const ret = result; @@ -484,7 +494,7 @@ function __wbg_get_imports() { getInt32Memory0()[arg0 / 4 + 1] = len1; getInt32Memory0()[arg0 / 4 + 0] = ptr1; }; - imports.wbg.__wbg_new_898a68150f225f2e = function() { + imports.wbg.__wbg_new_16b304a2cfa7ff4a = function() { const ret = new Array(); return addHeapObject(ret); }; @@ -492,15 +502,15 @@ function __wbg_get_imports() { const ret = getStringFromWasm0(arg0, arg1); return addHeapObject(ret); }; - imports.wbg.__wbg_push_ca1c26067ef907ac = function(arg0, arg1) { + imports.wbg.__wbg_push_a5b05aedc7234f9f = function(arg0, arg1) { const ret = getObject(arg0).push(getObject(arg1)); return ret; }; - imports.wbg.__wbg_length_72e2208bbc0efc61 = function(arg0) { + imports.wbg.__wbg_length_c20a40f15020d68a = function(arg0) { const ret = getObject(arg0).length; return ret; }; - imports.wbg.__wbg_set_5cf90238115182c3 = function(arg0, arg1, arg2) { + imports.wbg.__wbg_set_a47bac70306a19a7 = function(arg0, arg1, arg2) { getObject(arg0).set(getObject(arg1), arg2 >>> 0); }; imports.wbg.__wbindgen_throw = function(arg0, arg1) { diff --git a/wasm/index_bg.wasm b/wasm/index_bg.wasm index 1a5daaf4..58853d92 100644 Binary files a/wasm/index_bg.wasm and b/wasm/index_bg.wasm differ