UNPKG

og_image_writer

Version:

Generate an Open Graphic Image using a CSS-like API.

1,261 lines (1,159 loc) 31.9 kB
let wasm; const heap = new Array(32).fill(undefined); heap.push(undefined, null, true, false); function getObject(idx) { return heap[idx]; } let WASM_VECTOR_LEN = 0; let cachedUint8Memory0 = new Uint8Array(); function getUint8Memory0() { if (cachedUint8Memory0.byteLength === 0) { cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer); } return cachedUint8Memory0; } const cachedTextEncoder = new TextEncoder('utf-8'); const encodeString = (typeof cachedTextEncoder.encodeInto === 'function' ? function (arg, view) { return cachedTextEncoder.encodeInto(arg, view); } : function (arg, view) { const buf = cachedTextEncoder.encode(arg); view.set(buf); return { read: arg.length, written: buf.length }; }); function passStringToWasm0(arg, malloc, realloc) { if (realloc === undefined) { const buf = cachedTextEncoder.encode(arg); const ptr = malloc(buf.length); getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf); WASM_VECTOR_LEN = buf.length; return ptr; } let len = arg.length; let ptr = malloc(len); const mem = getUint8Memory0(); let offset = 0; for (; offset < len; offset++) { const code = arg.charCodeAt(offset); if (code > 0x7F) break; mem[ptr + offset] = code; } if (offset !== len) { if (offset !== 0) { arg = arg.slice(offset); } ptr = realloc(ptr, len, len = offset + arg.length * 3); const view = getUint8Memory0().subarray(ptr + offset, ptr + len); const ret = encodeString(arg, view); offset += ret.written; } WASM_VECTOR_LEN = offset; return ptr; } let cachedInt32Memory0 = new Int32Array(); function getInt32Memory0() { if (cachedInt32Memory0.byteLength === 0) { cachedInt32Memory0 = new Int32Array(wasm.memory.buffer); } return cachedInt32Memory0; } let heap_next = heap.length; function dropObject(idx) { if (idx < 36) return; heap[idx] = heap_next; heap_next = idx; } function takeObject(idx) { const ret = getObject(idx); dropObject(idx); return ret; } const cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }); cachedTextDecoder.decode(); function getStringFromWasm0(ptr, len) { return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len)); } function _assertClass(instance, klass) { if (!(instance instanceof klass)) { throw new Error(`expected instance of ${klass.name}`); } return instance.ptr; } function isLikeNone(x) { return x === undefined || x === null; } function addHeapObject(obj) { if (heap_next === heap.length) heap.push(heap.length + 1); const idx = heap_next; heap_next = heap[idx]; heap[idx] = obj; return idx; } function passArray8ToWasm0(arg, malloc) { const ptr = malloc(arg.length * 1); getUint8Memory0().set(arg, ptr / 1); WASM_VECTOR_LEN = arg.length; return ptr; } /** */ export function wasm_init() { wasm.wasm_init(); } function getArrayU8FromWasm0(ptr, len) { return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len); } /** */ export const ImageOutputFormat = Object.freeze({ Png:0,"0":"Png",Jpeg:1,"1":"Jpeg", }); /** */ export const ImageInputFormat = Object.freeze({ Png:0,"0":"Png",Jpeg:1,"1":"Jpeg", }); /** */ export const KernSetting = Object.freeze({ Normal:0,"0":"Normal",Metrics:1,"1":"Metrics",Optical:2,"2":"Optical", }); /** */ export const WordBreak = Object.freeze({ Normal:0,"0":"Normal",BreakAll:1,"1":"BreakAll", }); /** */ export const WhiteSpace = Object.freeze({ Normal:0,"0":"Normal",PreLine:1,"1":"PreLine", }); /** * Adjust the horizontal position. */ export const AlignItems = Object.freeze({ Start:0,"0":"Start",Center:1,"1":"Center",End:2,"2":"End", }); /** * Adjust the vertical position. */ export const JustifyContent = Object.freeze({ Start:0,"0":"Start",Center:1,"1":"Center",End:2,"2":"End", }); /** * Adjust the text horizontal position. */ export const TextAlign = Object.freeze({ Start:0,"0":"Start",Center:1,"1":"Center",End:2,"2":"End", }); /** */ export const Position = Object.freeze({ Static:0,"0":"Static",Absolute:1,"1":"Absolute", }); /** */ export const FlexDirection = Object.freeze({ Column:0,"0":"Column",Row:1,"1":"Row", }); /** */ export class BorderRadius { static __wrap(ptr) { const obj = Object.create(BorderRadius.prototype); obj.ptr = ptr; return obj; } __destroy_into_raw() { const ptr = this.ptr; this.ptr = 0; return ptr; } free() { const ptr = this.__destroy_into_raw(); wasm.__wbg_borderradius_free(ptr); } /** * @returns {number} */ get top_left() { const ret = wasm.__wbg_get_borderradius_top_left(this.ptr); return ret >>> 0; } /** * @param {number} arg0 */ set top_left(arg0) { wasm.__wbg_set_borderradius_top_left(this.ptr, arg0); } /** * @returns {number} */ get top_right() { const ret = wasm.__wbg_get_borderradius_top_right(this.ptr); return ret >>> 0; } /** * @param {number} arg0 */ set top_right(arg0) { wasm.__wbg_set_borderradius_top_right(this.ptr, arg0); } /** * @returns {number} */ get bottom_left() { const ret = wasm.__wbg_get_borderradius_bottom_left(this.ptr); return ret >>> 0; } /** * @param {number} arg0 */ set bottom_left(arg0) { wasm.__wbg_set_borderradius_bottom_left(this.ptr, arg0); } /** * @returns {number} */ get bottom_right() { const ret = wasm.__wbg_get_borderradius_bottom_right(this.ptr); return ret >>> 0; } /** * @param {number} arg0 */ set bottom_right(arg0) { wasm.__wbg_set_borderradius_bottom_right(this.ptr, arg0); } /** * @param {number} tl * @param {number} tr * @param {number} bl * @param {number} br * @returns {BorderRadius} */ static new(tl, tr, bl, br) { const ret = wasm.borderradius_new(tl, tr, bl, br); return BorderRadius.__wrap(ret); } } /** */ export class FontContext { static __wrap(ptr) { const obj = Object.create(FontContext.prototype); obj.ptr = ptr; return obj; } __destroy_into_raw() { const ptr = this.ptr; this.ptr = 0; return ptr; } free() { const ptr = this.__destroy_into_raw(); wasm.__wbg_fontcontext_free(ptr); } /** * @returns {FontContext} */ static new() { const ret = wasm.fontcontext_new(); return FontContext.__wrap(ret); } /** * @param {Uint8Array} font */ push(font) { const ptr0 = passArray8ToWasm0(font, wasm.__wbindgen_malloc); const len0 = WASM_VECTOR_LEN; wasm.fontcontext_push(this.ptr, ptr0, len0); } /** */ clear() { wasm.fontcontext_clear(this.ptr); } /** * @returns {number} */ len() { const ret = wasm.fontcontext_len(this.ptr); return ret >>> 0; } /** * @returns {boolean} */ is_empty() { const ret = wasm.fontcontext_is_empty(this.ptr); return ret !== 0; } } /** */ export class ImageOutputFormatOption { static __wrap(ptr) { const obj = Object.create(ImageOutputFormatOption.prototype); obj.ptr = ptr; return obj; } __destroy_into_raw() { const ptr = this.ptr; this.ptr = 0; return ptr; } free() { const ptr = this.__destroy_into_raw(); wasm.__wbg_imageoutputformatoption_free(ptr); } /** * @returns {number} */ get q() { const ret = wasm.__wbg_get_imageoutputformatoption_q(this.ptr); return ret; } /** * @param {number} arg0 */ set q(arg0) { wasm.__wbg_set_imageoutputformatoption_q(this.ptr, arg0); } /** * @returns {ImageOutputFormatOption} */ static new() { const ret = wasm.imageoutputformatoption_new(); return ImageOutputFormatOption.__wrap(ret); } } /** */ export class Margin { static __wrap(ptr) { const obj = Object.create(Margin.prototype); obj.ptr = ptr; return obj; } __destroy_into_raw() { const ptr = this.ptr; this.ptr = 0; return ptr; } free() { const ptr = this.__destroy_into_raw(); wasm.__wbg_margin_free(ptr); } /** * @returns {number} */ get top() { const ret = wasm.__wbg_get_borderradius_top_left(this.ptr); return ret; } /** * @param {number} arg0 */ set top(arg0) { wasm.__wbg_set_borderradius_top_left(this.ptr, arg0); } /** * @returns {number} */ get right() { const ret = wasm.__wbg_get_borderradius_top_right(this.ptr); return ret; } /** * @param {number} arg0 */ set right(arg0) { wasm.__wbg_set_borderradius_top_right(this.ptr, arg0); } /** * @returns {number} */ get bottom() { const ret = wasm.__wbg_get_borderradius_bottom_left(this.ptr); return ret; } /** * @param {number} arg0 */ set bottom(arg0) { wasm.__wbg_set_borderradius_bottom_left(this.ptr, arg0); } /** * @returns {number} */ get left() { const ret = wasm.__wbg_get_borderradius_bottom_right(this.ptr); return ret; } /** * @param {number} arg0 */ set left(arg0) { wasm.__wbg_set_borderradius_bottom_right(this.ptr, arg0); } /** * @param {number} top * @param {number} right * @param {number} bottom * @param {number} left * @returns {Margin} */ static new(top, right, bottom, left) { const ret = wasm.borderradius_new(top, right, bottom, left); return Margin.__wrap(ret); } } /** */ export class OGImageWriter { static __wrap(ptr) { const obj = Object.create(OGImageWriter.prototype); obj.ptr = ptr; return obj; } __destroy_into_raw() { const ptr = this.ptr; this.ptr = 0; return ptr; } free() { const ptr = this.__destroy_into_raw(); wasm.__wbg_ogimagewriter_free(ptr); } /** * @param {WindowStyle} style * @returns {OGImageWriter} */ static new(style) { _assertClass(style, WindowStyle); var ptr0 = style.ptr; style.ptr = 0; const ret = wasm.ogimagewriter_new(ptr0); return OGImageWriter.__wrap(ret); } /** * @param {WindowStyle} style * @param {Uint8Array} data * @param {number} format * @returns {OGImageWriter} */ static from_data(style, data, format) { _assertClass(style, WindowStyle); var ptr0 = style.ptr; style.ptr = 0; const ptr1 = passArray8ToWasm0(data, wasm.__wbindgen_malloc); const len1 = WASM_VECTOR_LEN; const ret = wasm.ogimagewriter_from_data(ptr0, ptr1, len1, format); return OGImageWriter.__wrap(ret); } /** * @returns {number} */ width() { const ret = wasm.ogimagewriter_width(this.ptr); return ret >>> 0; } /** * @returns {number} */ height() { const ret = wasm.ogimagewriter_height(this.ptr); return ret >>> 0; } /** * @param {string} text * @param {Style} style * @param {Uint8Array | undefined} font */ set_text(text, style, font) { const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); const len0 = WASM_VECTOR_LEN; _assertClass(style, Style); var ptr1 = style.ptr; style.ptr = 0; var ptr2 = isLikeNone(font) ? 0 : passArray8ToWasm0(font, wasm.__wbindgen_malloc); var len2 = WASM_VECTOR_LEN; wasm.ogimagewriter_set_text(this.ptr, ptr0, len0, ptr1, ptr2, len2); } /** * @param {TextArea} textarea * @param {Style} style * @param {Uint8Array | undefined} font */ set_textarea(textarea, style, font) { _assertClass(textarea, TextArea); var ptr0 = textarea.ptr; textarea.ptr = 0; _assertClass(style, Style); var ptr1 = style.ptr; style.ptr = 0; var ptr2 = isLikeNone(font) ? 0 : passArray8ToWasm0(font, wasm.__wbindgen_malloc); var len2 = WASM_VECTOR_LEN; wasm.ogimagewriter_set_textarea(this.ptr, ptr0, ptr1, ptr2, len2); } /** * @param {Uint8Array} data * @param {number} width * @param {number} height * @param {number} format * @param {Style} style */ set_img_with_data(data, width, height, format, style) { const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc); const len0 = WASM_VECTOR_LEN; _assertClass(style, Style); var ptr1 = style.ptr; style.ptr = 0; wasm.ogimagewriter_set_img_with_data(this.ptr, ptr0, len0, width, height, format, ptr1); } /** * @param {OGImageWriter} writer * @param {Style} style */ set_container(writer, style) { _assertClass(writer, OGImageWriter); _assertClass(style, Style); var ptr0 = style.ptr; style.ptr = 0; wasm.ogimagewriter_set_container(this.ptr, writer.ptr, ptr0); } /** * @param {string} dest */ generate(dest) { const ptr0 = passStringToWasm0(dest, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); const len0 = WASM_VECTOR_LEN; wasm.ogimagewriter_generate(this.ptr, ptr0, len0); } /** */ paint() { wasm.ogimagewriter_paint(this.ptr); } /** * @returns {Uint8Array} */ into_vec() { try { const ptr = this.__destroy_into_raw(); const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); wasm.ogimagewriter_into_vec(retptr, ptr); var r0 = getInt32Memory0()[retptr / 4 + 0]; var r1 = getInt32Memory0()[retptr / 4 + 1]; var v0 = getArrayU8FromWasm0(r0, r1).slice(); wasm.__wbindgen_free(r0, r1 * 1); return v0; } finally { wasm.__wbindgen_add_to_stack_pointer(16); } } /** * @param {number} f * @param {ImageOutputFormatOption} option * @returns {Uint8Array} */ encode(f, option) { try { const ptr = this.__destroy_into_raw(); const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); _assertClass(option, ImageOutputFormatOption); var ptr0 = option.ptr; option.ptr = 0; wasm.ogimagewriter_encode(retptr, ptr, f, ptr0); var r0 = getInt32Memory0()[retptr / 4 + 0]; var r1 = getInt32Memory0()[retptr / 4 + 1]; var v1 = getArrayU8FromWasm0(r0, r1).slice(); wasm.__wbindgen_free(r0, r1 * 1); return v1; } finally { wasm.__wbindgen_add_to_stack_pointer(16); } } } /** */ export class Rgba { static __wrap(ptr) { const obj = Object.create(Rgba.prototype); obj.ptr = ptr; return obj; } __destroy_into_raw() { const ptr = this.ptr; this.ptr = 0; return ptr; } free() { const ptr = this.__destroy_into_raw(); wasm.__wbg_rgba_free(ptr); } /** * @param {number} r * @param {number} g * @param {number} b * @param {number} a * @returns {Rgba} */ static new(r, g, b, a) { const ret = wasm.rgba_new(r, g, b, a); return Rgba.__wrap(ret); } } /** */ export class Style { static __wrap(ptr) { const obj = Object.create(Style.prototype); obj.ptr = ptr; return obj; } __destroy_into_raw() { const ptr = this.ptr; this.ptr = 0; return ptr; } free() { const ptr = this.__destroy_into_raw(); wasm.__wbg_style_free(ptr); } /** * @returns {Margin} */ get margin() { const ret = wasm.__wbg_get_style_margin(this.ptr); return Margin.__wrap(ret); } /** * @param {Margin} arg0 */ set margin(arg0) { _assertClass(arg0, Margin); var ptr0 = arg0.ptr; arg0.ptr = 0; wasm.__wbg_set_style_margin(this.ptr, ptr0); } /** * For Text element * @returns {number} */ get line_height() { const ret = wasm.__wbg_get_style_line_height(this.ptr); return ret; } /** * For Text element * @param {number} arg0 */ set line_height(arg0) { wasm.__wbg_set_style_line_height(this.ptr, arg0); } /** * For Text element * @returns {number} */ get font_size() { const ret = wasm.__wbg_get_style_font_size(this.ptr); return ret; } /** * For Text element * @param {number} arg0 */ set font_size(arg0) { wasm.__wbg_set_style_font_size(this.ptr, arg0); } /** * For Text element * @returns {number} */ get letter_spacing() { const ret = wasm.__wbg_get_style_letter_spacing(this.ptr); return ret; } /** * For Text element * @param {number} arg0 */ set letter_spacing(arg0) { wasm.__wbg_set_style_letter_spacing(this.ptr, arg0); } /** * @returns {number} */ get kern_setting() { const ret = wasm.__wbg_get_style_kern_setting(this.ptr); return ret >>> 0; } /** * @param {number} arg0 */ set kern_setting(arg0) { wasm.__wbg_set_style_kern_setting(this.ptr, arg0); } /** * For Text element * @returns {number} */ get word_break() { const ret = wasm.__wbg_get_style_word_break(this.ptr); return ret >>> 0; } /** * For Text element * @param {number} arg0 */ set word_break(arg0) { wasm.__wbg_set_style_word_break(this.ptr, arg0); } /** * For Text element * @returns {number} */ get white_space() { const ret = wasm.__wbg_get_style_white_space(this.ptr); return ret >>> 0; } /** * For Text element * @param {number} arg0 */ set white_space(arg0) { wasm.__wbg_set_style_white_space(this.ptr, arg0); } /** * For Text element * @returns {Rgba} */ get color() { const ret = wasm.__wbg_get_style_color(this.ptr); return Rgba.__wrap(ret); } /** * For Text element * @param {Rgba} arg0 */ set color(arg0) { _assertClass(arg0, Rgba); var ptr0 = arg0.ptr; arg0.ptr = 0; wasm.__wbg_set_style_color(this.ptr, ptr0); } /** * For Text element * @returns {number} */ get text_align() { const ret = wasm.__wbg_get_style_text_align(this.ptr); return ret >>> 0; } /** * For Text element * @param {number} arg0 */ set text_align(arg0) { wasm.__wbg_set_style_text_align(this.ptr, arg0); } /** * For Text element * @returns {number | undefined} */ get max_height() { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); wasm.__wbg_get_style_max_height(retptr, this.ptr); var r0 = getInt32Memory0()[retptr / 4 + 0]; var r1 = getInt32Memory0()[retptr / 4 + 1]; return r0 === 0 ? undefined : r1 >>> 0; } finally { wasm.__wbindgen_add_to_stack_pointer(16); } } /** * For Text element * @param {number | undefined} arg0 */ set max_height(arg0) { wasm.__wbg_set_style_max_height(this.ptr, !isLikeNone(arg0), isLikeNone(arg0) ? 0 : arg0); } /** * For Text element * @returns {number | undefined} */ get max_width() { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); wasm.__wbg_get_style_max_width(retptr, this.ptr); var r0 = getInt32Memory0()[retptr / 4 + 0]; var r1 = getInt32Memory0()[retptr / 4 + 1]; return r0 === 0 ? undefined : r1 >>> 0; } finally { wasm.__wbindgen_add_to_stack_pointer(16); } } /** * For Text element * @param {number | undefined} arg0 */ set max_width(arg0) { wasm.__wbg_set_style_max_width(this.ptr, !isLikeNone(arg0), isLikeNone(arg0) ? 0 : arg0); } /** * @returns {number} */ get position() { const ret = wasm.__wbg_get_style_position(this.ptr); return ret >>> 0; } /** * @param {number} arg0 */ set position(arg0) { wasm.__wbg_set_style_position(this.ptr, arg0); } /** * @returns {number | undefined} */ get top() { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); wasm.__wbg_get_style_top(retptr, this.ptr); var r0 = getInt32Memory0()[retptr / 4 + 0]; var r1 = getInt32Memory0()[retptr / 4 + 1]; return r0 === 0 ? undefined : r1; } finally { wasm.__wbindgen_add_to_stack_pointer(16); } } /** * @param {number | undefined} arg0 */ set top(arg0) { wasm.__wbg_set_style_top(this.ptr, !isLikeNone(arg0), isLikeNone(arg0) ? 0 : arg0); } /** * @returns {number | undefined} */ get right() { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); wasm.__wbg_get_style_right(retptr, this.ptr); var r0 = getInt32Memory0()[retptr / 4 + 0]; var r1 = getInt32Memory0()[retptr / 4 + 1]; return r0 === 0 ? undefined : r1; } finally { wasm.__wbindgen_add_to_stack_pointer(16); } } /** * @param {number | undefined} arg0 */ set right(arg0) { wasm.__wbg_set_style_right(this.ptr, !isLikeNone(arg0), isLikeNone(arg0) ? 0 : arg0); } /** * @returns {number | undefined} */ get bottom() { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); wasm.__wbg_get_style_bottom(retptr, this.ptr); var r0 = getInt32Memory0()[retptr / 4 + 0]; var r1 = getInt32Memory0()[retptr / 4 + 1]; return r0 === 0 ? undefined : r1; } finally { wasm.__wbindgen_add_to_stack_pointer(16); } } /** * @param {number | undefined} arg0 */ set bottom(arg0) { wasm.__wbg_set_style_bottom(this.ptr, !isLikeNone(arg0), isLikeNone(arg0) ? 0 : arg0); } /** * @returns {number | undefined} */ get left() { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); wasm.__wbg_get_style_left(retptr, this.ptr); var r0 = getInt32Memory0()[retptr / 4 + 0]; var r1 = getInt32Memory0()[retptr / 4 + 1]; return r0 === 0 ? undefined : r1; } finally { wasm.__wbindgen_add_to_stack_pointer(16); } } /** * @param {number | undefined} arg0 */ set left(arg0) { wasm.__wbg_set_style_left(this.ptr, !isLikeNone(arg0), isLikeNone(arg0) ? 0 : arg0); } /** * For Img element * @returns {BorderRadius} */ get border_radius() { const ret = wasm.__wbg_get_style_border_radius(this.ptr); return BorderRadius.__wrap(ret); } /** * For Img element * @param {BorderRadius} arg0 */ set border_radius(arg0) { _assertClass(arg0, BorderRadius); var ptr0 = arg0.ptr; arg0.ptr = 0; wasm.__wbg_set_style_border_radius(this.ptr, ptr0); } /** * @returns {Style} */ static new() { const ret = wasm.style_new(); return Style.__wrap(ret); } /** * @param {TextOverflow} value */ set text_overflow(value) { wasm.style_set_text_overflow(this.ptr, addHeapObject(value)); } } /** */ export class TextArea { static __wrap(ptr) { const obj = Object.create(TextArea.prototype); obj.ptr = ptr; return obj; } __destroy_into_raw() { const ptr = this.ptr; this.ptr = 0; return ptr; } free() { const ptr = this.__destroy_into_raw(); wasm.__wbg_textarea_free(ptr); } /** * @returns {TextArea} */ static new() { const ret = wasm.textarea_new(); return TextArea.__wrap(ret); } /** * @param {string} text * @param {Style | undefined} style * @param {Uint8Array | undefined} font */ push(text, style, font) { const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); const len0 = WASM_VECTOR_LEN; let ptr1 = 0; if (!isLikeNone(style)) { _assertClass(style, Style); ptr1 = style.ptr; style.ptr = 0; } var ptr2 = isLikeNone(font) ? 0 : passArray8ToWasm0(font, wasm.__wbindgen_malloc); var len2 = WASM_VECTOR_LEN; wasm.textarea_push(this.ptr, ptr0, len0, ptr1, ptr2, len2); } } /** */ export class WindowStyle { static __wrap(ptr) { const obj = Object.create(WindowStyle.prototype); obj.ptr = ptr; return obj; } __destroy_into_raw() { const ptr = this.ptr; this.ptr = 0; return ptr; } free() { const ptr = this.__destroy_into_raw(); wasm.__wbg_windowstyle_free(ptr); } /** * @returns {number} */ get height() { const ret = wasm.__wbg_get_borderradius_top_left(this.ptr); return ret >>> 0; } /** * @param {number} arg0 */ set height(arg0) { wasm.__wbg_set_borderradius_top_left(this.ptr, arg0); } /** * @returns {number} */ get width() { const ret = wasm.__wbg_get_borderradius_top_right(this.ptr); return ret >>> 0; } /** * @param {number} arg0 */ set width(arg0) { wasm.__wbg_set_borderradius_top_right(this.ptr, arg0); } /** * @returns {Rgba | undefined} */ get background_color() { const ret = wasm.__wbg_get_windowstyle_background_color(this.ptr); return ret === 0 ? undefined : Rgba.__wrap(ret); } /** * @param {Rgba | undefined} arg0 */ set background_color(arg0) { let ptr0 = 0; if (!isLikeNone(arg0)) { _assertClass(arg0, Rgba); ptr0 = arg0.ptr; arg0.ptr = 0; } wasm.__wbg_set_windowstyle_background_color(this.ptr, ptr0); } /** * @returns {number} */ get align_items() { const ret = wasm.__wbg_get_windowstyle_align_items(this.ptr); return ret >>> 0; } /** * @param {number} arg0 */ set align_items(arg0) { wasm.__wbg_set_windowstyle_align_items(this.ptr, arg0); } /** * @returns {number} */ get justify_content() { const ret = wasm.__wbg_get_windowstyle_justify_content(this.ptr); return ret >>> 0; } /** * @param {number} arg0 */ set justify_content(arg0) { wasm.__wbg_set_windowstyle_justify_content(this.ptr, arg0); } /** * This controls the direction in which the children of a node are laid out. * @returns {number} */ get flex_direction() { const ret = wasm.__wbg_get_windowstyle_flex_direction(this.ptr); return ret >>> 0; } /** * This controls the direction in which the children of a node are laid out. * @param {number} arg0 */ set flex_direction(arg0) { wasm.__wbg_set_windowstyle_flex_direction(this.ptr, arg0); } /** * @returns {WindowStyle} */ static new() { const ret = wasm.windowstyle_new(); return WindowStyle.__wrap(ret); } } async function load(module, imports) { if (typeof Response === 'function' && module instanceof Response) { if (typeof WebAssembly.instantiateStreaming === 'function') { try { return await WebAssembly.instantiateStreaming(module, imports); } catch (e) { if (module.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", e); } else { throw e; } } } const bytes = await module.arrayBuffer(); return await WebAssembly.instantiate(bytes, imports); } else { const instance = await WebAssembly.instantiate(module, imports); if (instance instanceof WebAssembly.Instance) { return { instance, module }; } else { return instance; } } } function getImports() { const imports = {}; imports.wbg = {}; imports.wbg.__wbindgen_json_serialize = function(arg0, arg1) { const obj = getObject(arg1); const ret = JSON.stringify(obj === undefined ? null : obj); const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); const len0 = WASM_VECTOR_LEN; getInt32Memory0()[arg0 / 4 + 1] = len0; getInt32Memory0()[arg0 / 4 + 0] = ptr0; }; imports.wbg.__wbindgen_object_drop_ref = function(arg0) { takeObject(arg0); }; imports.wbg.__wbg_new_abda76e883ba8a5f = function() { const ret = new Error(); return addHeapObject(ret); }; imports.wbg.__wbg_stack_658279fe44541cf6 = function(arg0, arg1) { const ret = getObject(arg1).stack; const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); const len0 = WASM_VECTOR_LEN; getInt32Memory0()[arg0 / 4 + 1] = len0; getInt32Memory0()[arg0 / 4 + 0] = ptr0; }; imports.wbg.__wbg_error_f851667af71bcfc6 = function(arg0, arg1) { try { console.error(getStringFromWasm0(arg0, arg1)); } finally { wasm.__wbindgen_free(arg0, arg1); } }; imports.wbg.__wbindgen_throw = function(arg0, arg1) { throw new Error(getStringFromWasm0(arg0, arg1)); }; return imports; } function initMemory(imports, maybe_memory) { } function finalizeInit(instance, module) { wasm = instance.exports; init.__wbindgen_wasm_module = module; cachedInt32Memory0 = new Int32Array(); cachedUint8Memory0 = new Uint8Array(); wasm.__wbindgen_start(); return wasm; } function initSync(module) { const imports = getImports(); initMemory(imports); if (!(module instanceof WebAssembly.Module)) { module = new WebAssembly.Module(module); } const instance = new WebAssembly.Instance(module, imports); return finalizeInit(instance, module); } async function init(input) { if (typeof input === 'undefined') { input = new URL('wasm_bg.wasm', import.meta.url); } const imports = getImports(); if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) { input = fetch(input); } initMemory(imports); const { instance, module } = await load(await input, imports); return finalizeInit(instance, module); } export { initSync } export default init;