1/**2 * Render one ASCII source using svgbob's pure library API.3 *4 * The JavaScript adapter validates bounds and option syntax. Keeping this5 * wrapper free of DOM, filesystem, and network APIs makes it usable in a6 * Cloudflare Worker compiled-Wasm binding.7 * @param {string} source8 * @param {string} background9 * @param {string} fill_color10 * @param {string} font_family11 * @param {number} font_size12 * @param {number} scale13 * @param {number} stroke_width14 * @returns {string}15 */16export function render(source, background, fill_color, font_family, font_size, scale, stroke_width) {17 const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);18 const len0 = WASM_VECTOR_LEN;19 const ptr1 = passStringToWasm0(background, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);20 const len1 = WASM_VECTOR_LEN;21 const ptr2 = passStringToWasm0(fill_color, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);22 const len2 = WASM_VECTOR_LEN;23 const ptr3 = passStringToWasm0(font_family, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);24 const len3 = WASM_VECTOR_LEN;25 const ret = wasm.render(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, font_size, scale, stroke_width);26 var v5 = getCachedStringFromWasm0(ret[0], ret[1]);27 if (ret[0] !== 0) { wasm.__wbindgen_free(ret[0], ret[1], 1); }28 return v5;29}30export function __wbg___wbindgen_throw_bb96b2010945f0bc(arg0, arg1) {31 var v0 = getCachedStringFromWasm0(arg0, arg1);32 throw new Error(v0);33}34export function __wbindgen_init_externref_table() {35 const table = wasm.__wbindgen_externrefs;36 const offset = table.grow(4);37 table.set(0, undefined);38 table.set(offset + 0, undefined);39 table.set(offset + 1, null);40 table.set(offset + 2, true);41 table.set(offset + 3, false);42}43function getCachedStringFromWasm0(ptr, len) {44 if (ptr === 0) {45 return getFromExternrefTable0(len);46 } else {47 return getStringFromWasm0(ptr, len);48 }49}5051function getFromExternrefTable0(idx) { return wasm.__wbindgen_externrefs.get(idx); }5253function getStringFromWasm0(ptr, len) {54 return decodeText(ptr >>> 0, len);55}5657let cachedUint8ArrayMemory0 = null;58function getUint8ArrayMemory0() {59 if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {60 cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);61 }62 return cachedUint8ArrayMemory0;63}6465function passStringToWasm0(arg, malloc, realloc) {66 if (realloc === undefined) {67 const buf = cachedTextEncoder.encode(arg);68 const ptr = malloc(buf.length, 1) >>> 0;69 getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);70 WASM_VECTOR_LEN = buf.length;71 return ptr;72 }7374 let len = arg.length;75 let ptr = malloc(len, 1) >>> 0;7677 const mem = getUint8ArrayMemory0();7879 let offset = 0;8081 for (; offset < len; offset++) {82 const code = arg.charCodeAt(offset);83 if (code > 0x7F) break;84 mem[ptr + offset] = code;85 }86 if (offset !== len) {87 if (offset !== 0) {88 arg = arg.slice(offset);89 }90 ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;91 const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);92 const ret = cachedTextEncoder.encodeInto(arg, view);9394 offset += ret.written;95 ptr = realloc(ptr, len, offset, 1) >>> 0;96 }9798 WASM_VECTOR_LEN = offset;99 return ptr;100}101102let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });103cachedTextDecoder.decode();104const MAX_SAFARI_DECODE_BYTES = 2146435072;105let numBytesDecoded = 0;106function decodeText(ptr, len) {107 numBytesDecoded += len;108 if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {109 cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });110 cachedTextDecoder.decode();111 numBytesDecoded = len;112 }113 return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));114}115116const cachedTextEncoder = new TextEncoder();117118if (!('encodeInto' in cachedTextEncoder)) {119 cachedTextEncoder.encodeInto = function (arg, view) {120 const buf = cachedTextEncoder.encode(arg);121 view.set(buf);122 return {123 read: arg.length,124 written: buf.length125 };126 };127}128129let WASM_VECTOR_LEN = 0;130131132let wasm;133export function __wbg_set_wasm(val) {134 wasm = val;135}