atproto blogging
1let wasm;
2
3function addHeapObject(obj) {
4 if (heap_next === heap.length) heap.push(heap.length + 1);
5 const idx = heap_next;
6 heap_next = heap[idx];
7
8 heap[idx] = obj;
9 return idx;
10}
11
12function _assertClass(instance, klass) {
13 if (!(instance instanceof klass)) {
14 throw new Error(`expected instance of ${klass.name}`);
15 }
16}
17
18function debugString(val) {
19 // primitive types
20 const type = typeof val;
21 if (type == 'number' || type == 'boolean' || val == null) {
22 return `${val}`;
23 }
24 if (type == 'string') {
25 return `"${val}"`;
26 }
27 if (type == 'symbol') {
28 const description = val.description;
29 if (description == null) {
30 return 'Symbol';
31 } else {
32 return `Symbol(${description})`;
33 }
34 }
35 if (type == 'function') {
36 const name = val.name;
37 if (typeof name == 'string' && name.length > 0) {
38 return `Function(${name})`;
39 } else {
40 return 'Function';
41 }
42 }
43 // objects
44 if (Array.isArray(val)) {
45 const length = val.length;
46 let debug = '[';
47 if (length > 0) {
48 debug += debugString(val[0]);
49 }
50 for(let i = 1; i < length; i++) {
51 debug += ', ' + debugString(val[i]);
52 }
53 debug += ']';
54 return debug;
55 }
56 // Test for built-in
57 const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
58 let className;
59 if (builtInMatches && builtInMatches.length > 1) {
60 className = builtInMatches[1];
61 } else {
62 // Failed to match the standard '[object ClassName]'
63 return toString.call(val);
64 }
65 if (className == 'Object') {
66 // we're a user defined class or Object
67 // JSON.stringify avoids problems with cycles, and is generally much
68 // easier than looping through ownProperties of `val`.
69 try {
70 return 'Object(' + JSON.stringify(val) + ')';
71 } catch (_) {
72 return 'Object';
73 }
74 }
75 // errors
76 if (val instanceof Error) {
77 return `${val.name}: ${val.message}\n${val.stack}`;
78 }
79 // TODO we could test for more things here, like `Set`s and `Map`s.
80 return className;
81}
82
83function dropObject(idx) {
84 if (idx < 132) return;
85 heap[idx] = heap_next;
86 heap_next = idx;
87}
88
89function getArrayU8FromWasm0(ptr, len) {
90 ptr = ptr >>> 0;
91 return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
92}
93
94let cachedDataViewMemory0 = null;
95function getDataViewMemory0() {
96 if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
97 cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
98 }
99 return cachedDataViewMemory0;
100}
101
102function getStringFromWasm0(ptr, len) {
103 ptr = ptr >>> 0;
104 return decodeText(ptr, len);
105}
106
107let cachedUint8ArrayMemory0 = null;
108function getUint8ArrayMemory0() {
109 if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
110 cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
111 }
112 return cachedUint8ArrayMemory0;
113}
114
115function getObject(idx) { return heap[idx]; }
116
117function handleError(f, args) {
118 try {
119 return f.apply(this, args);
120 } catch (e) {
121 wasm.__wbindgen_export3(addHeapObject(e));
122 }
123}
124
125let heap = new Array(128).fill(undefined);
126heap.push(undefined, null, true, false);
127
128let heap_next = heap.length;
129
130function isLikeNone(x) {
131 return x === undefined || x === null;
132}
133
134function passStringToWasm0(arg, malloc, realloc) {
135 if (realloc === undefined) {
136 const buf = cachedTextEncoder.encode(arg);
137 const ptr = malloc(buf.length, 1) >>> 0;
138 getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
139 WASM_VECTOR_LEN = buf.length;
140 return ptr;
141 }
142
143 let len = arg.length;
144 let ptr = malloc(len, 1) >>> 0;
145
146 const mem = getUint8ArrayMemory0();
147
148 let offset = 0;
149
150 for (; offset < len; offset++) {
151 const code = arg.charCodeAt(offset);
152 if (code > 0x7F) break;
153 mem[ptr + offset] = code;
154 }
155 if (offset !== len) {
156 if (offset !== 0) {
157 arg = arg.slice(offset);
158 }
159 ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
160 const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
161 const ret = cachedTextEncoder.encodeInto(arg, view);
162
163 offset += ret.written;
164 ptr = realloc(ptr, len, offset, 1) >>> 0;
165 }
166
167 WASM_VECTOR_LEN = offset;
168 return ptr;
169}
170
171function takeObject(idx) {
172 const ret = getObject(idx);
173 dropObject(idx);
174 return ret;
175}
176
177let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
178cachedTextDecoder.decode();
179const MAX_SAFARI_DECODE_BYTES = 2146435072;
180let numBytesDecoded = 0;
181function decodeText(ptr, len) {
182 numBytesDecoded += len;
183 if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
184 cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
185 cachedTextDecoder.decode();
186 numBytesDecoded = len;
187 }
188 return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
189}
190
191const cachedTextEncoder = new TextEncoder();
192
193if (!('encodeInto' in cachedTextEncoder)) {
194 cachedTextEncoder.encodeInto = function (arg, view) {
195 const buf = cachedTextEncoder.encode(arg);
196 view.set(buf);
197 return {
198 read: arg.length,
199 written: buf.length
200 };
201 }
202}
203
204let WASM_VECTOR_LEN = 0;
205
206const JsMathResultFinalization = (typeof FinalizationRegistry === 'undefined')
207 ? { register: () => {}, unregister: () => {} }
208 : new FinalizationRegistry(ptr => wasm.__wbg_jsmathresult_free(ptr >>> 0, 1));
209
210const JsResolvedContentFinalization = (typeof FinalizationRegistry === 'undefined')
211 ? { register: () => {}, unregister: () => {} }
212 : new FinalizationRegistry(ptr => wasm.__wbg_jsresolvedcontent_free(ptr >>> 0, 1));
213
214/**
215 * Result from rendering LaTeX math.
216 */
217export class JsMathResult {
218 static __wrap(ptr) {
219 ptr = ptr >>> 0;
220 const obj = Object.create(JsMathResult.prototype);
221 obj.__wbg_ptr = ptr;
222 JsMathResultFinalization.register(obj, obj.__wbg_ptr, obj);
223 return obj;
224 }
225 __destroy_into_raw() {
226 const ptr = this.__wbg_ptr;
227 this.__wbg_ptr = 0;
228 JsMathResultFinalization.unregister(this);
229 return ptr;
230 }
231 free() {
232 const ptr = this.__destroy_into_raw();
233 wasm.__wbg_jsmathresult_free(ptr, 0);
234 }
235 /**
236 * @returns {boolean}
237 */
238 get success() {
239 const ret = wasm.__wbg_get_jsmathresult_success(this.__wbg_ptr);
240 return ret !== 0;
241 }
242 /**
243 * @param {boolean} arg0
244 */
245 set success(arg0) {
246 wasm.__wbg_set_jsmathresult_success(this.__wbg_ptr, arg0);
247 }
248 /**
249 * @returns {string}
250 */
251 get html() {
252 let deferred1_0;
253 let deferred1_1;
254 try {
255 const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
256 wasm.__wbg_get_jsmathresult_html(retptr, this.__wbg_ptr);
257 var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
258 var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
259 deferred1_0 = r0;
260 deferred1_1 = r1;
261 return getStringFromWasm0(r0, r1);
262 } finally {
263 wasm.__wbindgen_add_to_stack_pointer(16);
264 wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
265 }
266 }
267 /**
268 * @param {string} arg0
269 */
270 set html(arg0) {
271 const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_export, wasm.__wbindgen_export2);
272 const len0 = WASM_VECTOR_LEN;
273 wasm.__wbg_set_jsmathresult_html(this.__wbg_ptr, ptr0, len0);
274 }
275 /**
276 * @returns {string | undefined}
277 */
278 get error() {
279 try {
280 const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
281 wasm.__wbg_get_jsmathresult_error(retptr, this.__wbg_ptr);
282 var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
283 var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
284 let v1;
285 if (r0 !== 0) {
286 v1 = getStringFromWasm0(r0, r1).slice();
287 wasm.__wbindgen_export4(r0, r1 * 1, 1);
288 }
289 return v1;
290 } finally {
291 wasm.__wbindgen_add_to_stack_pointer(16);
292 }
293 }
294 /**
295 * @param {string | null} [arg0]
296 */
297 set error(arg0) {
298 var ptr0 = isLikeNone(arg0) ? 0 : passStringToWasm0(arg0, wasm.__wbindgen_export, wasm.__wbindgen_export2);
299 var len0 = WASM_VECTOR_LEN;
300 wasm.__wbg_set_jsmathresult_error(this.__wbg_ptr, ptr0, len0);
301 }
302}
303if (Symbol.dispose) JsMathResult.prototype[Symbol.dispose] = JsMathResult.prototype.free;
304
305/**
306 * Pre-rendered embed content for synchronous rendering.
307 *
308 * Build this by calling `create_resolved_content()` and adding embeds
309 * with `resolved_content_add_embed()`.
310 */
311export class JsResolvedContent {
312 static __wrap(ptr) {
313 ptr = ptr >>> 0;
314 const obj = Object.create(JsResolvedContent.prototype);
315 obj.__wbg_ptr = ptr;
316 JsResolvedContentFinalization.register(obj, obj.__wbg_ptr, obj);
317 return obj;
318 }
319 __destroy_into_raw() {
320 const ptr = this.__wbg_ptr;
321 this.__wbg_ptr = 0;
322 JsResolvedContentFinalization.unregister(this);
323 return ptr;
324 }
325 free() {
326 const ptr = this.__destroy_into_raw();
327 wasm.__wbg_jsresolvedcontent_free(ptr, 0);
328 }
329 /**
330 * Create an empty resolved content container.
331 */
332 constructor() {
333 const ret = wasm.create_resolved_content();
334 this.__wbg_ptr = ret >>> 0;
335 JsResolvedContentFinalization.register(this, this.__wbg_ptr, this);
336 return this;
337 }
338 /**
339 * Add pre-rendered embed HTML for an AT URI.
340 *
341 * # Arguments
342 * * `at_uri` - The AT Protocol URI (e.g., "at://did:plc:.../app.bsky.feed.post/...")
343 * * `html` - The pre-rendered HTML for this embed
344 * @param {string} at_uri
345 * @param {string} html
346 */
347 addEmbed(at_uri, html) {
348 try {
349 const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
350 const ptr0 = passStringToWasm0(at_uri, wasm.__wbindgen_export, wasm.__wbindgen_export2);
351 const len0 = WASM_VECTOR_LEN;
352 const ptr1 = passStringToWasm0(html, wasm.__wbindgen_export, wasm.__wbindgen_export2);
353 const len1 = WASM_VECTOR_LEN;
354 wasm.jsresolvedcontent_addEmbed(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1);
355 var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
356 var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
357 if (r1) {
358 throw takeObject(r0);
359 }
360 } finally {
361 wasm.__wbindgen_add_to_stack_pointer(16);
362 }
363 }
364}
365if (Symbol.dispose) JsResolvedContent.prototype[Symbol.dispose] = JsResolvedContent.prototype.free;
366
367/**
368 * Create an empty resolved content container.
369 *
370 * Use this to pre-render embeds before calling render functions.
371 * @returns {JsResolvedContent}
372 */
373export function create_resolved_content() {
374 const ret = wasm.create_resolved_content();
375 return JsResolvedContent.__wrap(ret);
376}
377
378/**
379 * Initialize panic hook for better error messages in console.
380 */
381export function init() {
382 wasm.init();
383}
384
385/**
386 * Render faceted text (rich text with mentions, links, etc.) to HTML.
387 *
388 * Accepts facets from several AT Protocol lexicons (app.bsky, pub.leaflet, blog.pckt).
389 *
390 * # Arguments
391 * * `text` - The plain text content
392 * * `facets_json` - Array of facets with `index` (byteStart/byteEnd) and `features` array
393 * @param {string} text
394 * @param {any} facets_json
395 * @returns {string}
396 */
397export function render_faceted_text(text, facets_json) {
398 let deferred3_0;
399 let deferred3_1;
400 try {
401 const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
402 const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export, wasm.__wbindgen_export2);
403 const len0 = WASM_VECTOR_LEN;
404 wasm.render_faceted_text(retptr, ptr0, len0, addHeapObject(facets_json));
405 var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
406 var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
407 var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
408 var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
409 var ptr2 = r0;
410 var len2 = r1;
411 if (r3) {
412 ptr2 = 0; len2 = 0;
413 throw takeObject(r2);
414 }
415 deferred3_0 = ptr2;
416 deferred3_1 = len2;
417 return getStringFromWasm0(ptr2, len2);
418 } finally {
419 wasm.__wbindgen_add_to_stack_pointer(16);
420 wasm.__wbindgen_export4(deferred3_0, deferred3_1, 1);
421 }
422}
423
424/**
425 * Render markdown to HTML.
426 *
427 * # Arguments
428 * * `markdown` - The markdown source text
429 * * `resolved_content` - Optional pre-rendered embed content
430 * @param {string} markdown
431 * @param {JsResolvedContent | null} [resolved_content]
432 * @returns {string}
433 */
434export function render_markdown(markdown, resolved_content) {
435 let deferred4_0;
436 let deferred4_1;
437 try {
438 const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
439 const ptr0 = passStringToWasm0(markdown, wasm.__wbindgen_export, wasm.__wbindgen_export2);
440 const len0 = WASM_VECTOR_LEN;
441 let ptr1 = 0;
442 if (!isLikeNone(resolved_content)) {
443 _assertClass(resolved_content, JsResolvedContent);
444 ptr1 = resolved_content.__destroy_into_raw();
445 }
446 wasm.render_markdown(retptr, ptr0, len0, ptr1);
447 var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
448 var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
449 var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
450 var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
451 var ptr3 = r0;
452 var len3 = r1;
453 if (r3) {
454 ptr3 = 0; len3 = 0;
455 throw takeObject(r2);
456 }
457 deferred4_0 = ptr3;
458 deferred4_1 = len3;
459 return getStringFromWasm0(ptr3, len3);
460 } finally {
461 wasm.__wbindgen_add_to_stack_pointer(16);
462 wasm.__wbindgen_export4(deferred4_0, deferred4_1, 1);
463 }
464}
465
466/**
467 * Render LaTeX math to MathML.
468 *
469 * # Arguments
470 * * `latex` - The LaTeX math expression
471 * * `display_mode` - true for display math (block), false for inline math
472 * @param {string} latex
473 * @param {boolean} display_mode
474 * @returns {JsMathResult}
475 */
476export function render_math(latex, display_mode) {
477 const ptr0 = passStringToWasm0(latex, wasm.__wbindgen_export, wasm.__wbindgen_export2);
478 const len0 = WASM_VECTOR_LEN;
479 const ret = wasm.render_math(ptr0, len0, display_mode);
480 return JsMathResult.__wrap(ret);
481}
482
483/**
484 * Render an AT Protocol record as HTML.
485 *
486 * Takes a record URI and the record data (typically fetched from an appview).
487 * Returns the rendered HTML string.
488 *
489 * # Arguments
490 * * `at_uri` - The AT Protocol URI (e.g., "at://did:plc:.../app.bsky.feed.post/...")
491 * * `record_json` - The record data as JSON
492 * * `fallback_author` - Optional author profile for records that don't include author info
493 * * `resolved_content` - Optional pre-rendered embed content
494 * @param {string} at_uri
495 * @param {any} record_json
496 * @param {any | null} [fallback_author]
497 * @param {JsResolvedContent | null} [resolved_content]
498 * @returns {string}
499 */
500export function render_record(at_uri, record_json, fallback_author, resolved_content) {
501 let deferred4_0;
502 let deferred4_1;
503 try {
504 const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
505 const ptr0 = passStringToWasm0(at_uri, wasm.__wbindgen_export, wasm.__wbindgen_export2);
506 const len0 = WASM_VECTOR_LEN;
507 let ptr1 = 0;
508 if (!isLikeNone(resolved_content)) {
509 _assertClass(resolved_content, JsResolvedContent);
510 ptr1 = resolved_content.__destroy_into_raw();
511 }
512 wasm.render_record(retptr, ptr0, len0, addHeapObject(record_json), isLikeNone(fallback_author) ? 0 : addHeapObject(fallback_author), ptr1);
513 var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
514 var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
515 var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
516 var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
517 var ptr3 = r0;
518 var len3 = r1;
519 if (r3) {
520 ptr3 = 0; len3 = 0;
521 throw takeObject(r2);
522 }
523 deferred4_0 = ptr3;
524 deferred4_1 = len3;
525 return getStringFromWasm0(ptr3, len3);
526 } finally {
527 wasm.__wbindgen_add_to_stack_pointer(16);
528 wasm.__wbindgen_export4(deferred4_0, deferred4_1, 1);
529 }
530}
531
532const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
533
534async function __wbg_load(module, imports) {
535 if (typeof Response === 'function' && module instanceof Response) {
536 if (typeof WebAssembly.instantiateStreaming === 'function') {
537 try {
538 return await WebAssembly.instantiateStreaming(module, imports);
539 } catch (e) {
540 const validResponse = module.ok && EXPECTED_RESPONSE_TYPES.has(module.type);
541
542 if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
543 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);
544
545 } else {
546 throw e;
547 }
548 }
549 }
550
551 const bytes = await module.arrayBuffer();
552 return await WebAssembly.instantiate(bytes, imports);
553 } else {
554 const instance = await WebAssembly.instantiate(module, imports);
555
556 if (instance instanceof WebAssembly.Instance) {
557 return { instance, module };
558 } else {
559 return instance;
560 }
561 }
562}
563
564function __wbg_get_imports() {
565 const imports = {};
566 imports.wbg = {};
567 imports.wbg.__wbg_Error_52673b7de5a0ca89 = function(arg0, arg1) {
568 const ret = Error(getStringFromWasm0(arg0, arg1));
569 return addHeapObject(ret);
570 };
571 imports.wbg.__wbg_Number_2d1dcfcf4ec51736 = function(arg0) {
572 const ret = Number(getObject(arg0));
573 return ret;
574 };
575 imports.wbg.__wbg_String_8f0eb39a4a4c2f66 = function(arg0, arg1) {
576 const ret = String(getObject(arg1));
577 const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
578 const len1 = WASM_VECTOR_LEN;
579 getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
580 getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
581 };
582 imports.wbg.__wbg___wbindgen_bigint_get_as_i64_6e32f5e6aff02e1d = function(arg0, arg1) {
583 const v = getObject(arg1);
584 const ret = typeof(v) === 'bigint' ? v : undefined;
585 getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
586 getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
587 };
588 imports.wbg.__wbg___wbindgen_boolean_get_dea25b33882b895b = function(arg0) {
589 const v = getObject(arg0);
590 const ret = typeof(v) === 'boolean' ? v : undefined;
591 return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
592 };
593 imports.wbg.__wbg___wbindgen_debug_string_adfb662ae34724b6 = function(arg0, arg1) {
594 const ret = debugString(getObject(arg1));
595 const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
596 const len1 = WASM_VECTOR_LEN;
597 getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
598 getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
599 };
600 imports.wbg.__wbg___wbindgen_in_0d3e1e8f0c669317 = function(arg0, arg1) {
601 const ret = getObject(arg0) in getObject(arg1);
602 return ret;
603 };
604 imports.wbg.__wbg___wbindgen_is_bigint_0e1a2e3f55cfae27 = function(arg0) {
605 const ret = typeof(getObject(arg0)) === 'bigint';
606 return ret;
607 };
608 imports.wbg.__wbg___wbindgen_is_function_8d400b8b1af978cd = function(arg0) {
609 const ret = typeof(getObject(arg0)) === 'function';
610 return ret;
611 };
612 imports.wbg.__wbg___wbindgen_is_object_ce774f3490692386 = function(arg0) {
613 const val = getObject(arg0);
614 const ret = typeof(val) === 'object' && val !== null;
615 return ret;
616 };
617 imports.wbg.__wbg___wbindgen_is_undefined_f6b95eab589e0269 = function(arg0) {
618 const ret = getObject(arg0) === undefined;
619 return ret;
620 };
621 imports.wbg.__wbg___wbindgen_jsval_eq_b6101cc9cef1fe36 = function(arg0, arg1) {
622 const ret = getObject(arg0) === getObject(arg1);
623 return ret;
624 };
625 imports.wbg.__wbg___wbindgen_jsval_loose_eq_766057600fdd1b0d = function(arg0, arg1) {
626 const ret = getObject(arg0) == getObject(arg1);
627 return ret;
628 };
629 imports.wbg.__wbg___wbindgen_number_get_9619185a74197f95 = function(arg0, arg1) {
630 const obj = getObject(arg1);
631 const ret = typeof(obj) === 'number' ? obj : undefined;
632 getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
633 getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
634 };
635 imports.wbg.__wbg___wbindgen_string_get_a2a31e16edf96e42 = function(arg0, arg1) {
636 const obj = getObject(arg1);
637 const ret = typeof(obj) === 'string' ? obj : undefined;
638 var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
639 var len1 = WASM_VECTOR_LEN;
640 getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
641 getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
642 };
643 imports.wbg.__wbg___wbindgen_throw_dd24417ed36fc46e = function(arg0, arg1) {
644 throw new Error(getStringFromWasm0(arg0, arg1));
645 };
646 imports.wbg.__wbg_call_abb4ff46ce38be40 = function() { return handleError(function (arg0, arg1) {
647 const ret = getObject(arg0).call(getObject(arg1));
648 return addHeapObject(ret);
649 }, arguments) };
650 imports.wbg.__wbg_done_62ea16af4ce34b24 = function(arg0) {
651 const ret = getObject(arg0).done;
652 return ret;
653 };
654 imports.wbg.__wbg_entries_83c79938054e065f = function(arg0) {
655 const ret = Object.entries(getObject(arg0));
656 return addHeapObject(ret);
657 };
658 imports.wbg.__wbg_error_7534b8e9a36f1ab4 = function(arg0, arg1) {
659 let deferred0_0;
660 let deferred0_1;
661 try {
662 deferred0_0 = arg0;
663 deferred0_1 = arg1;
664 console.error(getStringFromWasm0(arg0, arg1));
665 } finally {
666 wasm.__wbindgen_export4(deferred0_0, deferred0_1, 1);
667 }
668 };
669 imports.wbg.__wbg_get_6b7bd52aca3f9671 = function(arg0, arg1) {
670 const ret = getObject(arg0)[arg1 >>> 0];
671 return addHeapObject(ret);
672 };
673 imports.wbg.__wbg_get_af9dab7e9603ea93 = function() { return handleError(function (arg0, arg1) {
674 const ret = Reflect.get(getObject(arg0), getObject(arg1));
675 return addHeapObject(ret);
676 }, arguments) };
677 imports.wbg.__wbg_get_with_ref_key_1dc361bd10053bfe = function(arg0, arg1) {
678 const ret = getObject(arg0)[getObject(arg1)];
679 return addHeapObject(ret);
680 };
681 imports.wbg.__wbg_instanceof_ArrayBuffer_f3320d2419cd0355 = function(arg0) {
682 let result;
683 try {
684 result = getObject(arg0) instanceof ArrayBuffer;
685 } catch (_) {
686 result = false;
687 }
688 const ret = result;
689 return ret;
690 };
691 imports.wbg.__wbg_instanceof_Map_084be8da74364158 = function(arg0) {
692 let result;
693 try {
694 result = getObject(arg0) instanceof Map;
695 } catch (_) {
696 result = false;
697 }
698 const ret = result;
699 return ret;
700 };
701 imports.wbg.__wbg_instanceof_Uint8Array_da54ccc9d3e09434 = function(arg0) {
702 let result;
703 try {
704 result = getObject(arg0) instanceof Uint8Array;
705 } catch (_) {
706 result = false;
707 }
708 const ret = result;
709 return ret;
710 };
711 imports.wbg.__wbg_isArray_51fd9e6422c0a395 = function(arg0) {
712 const ret = Array.isArray(getObject(arg0));
713 return ret;
714 };
715 imports.wbg.__wbg_isSafeInteger_ae7d3f054d55fa16 = function(arg0) {
716 const ret = Number.isSafeInteger(getObject(arg0));
717 return ret;
718 };
719 imports.wbg.__wbg_iterator_27b7c8b35ab3e86b = function() {
720 const ret = Symbol.iterator;
721 return addHeapObject(ret);
722 };
723 imports.wbg.__wbg_length_22ac23eaec9d8053 = function(arg0) {
724 const ret = getObject(arg0).length;
725 return ret;
726 };
727 imports.wbg.__wbg_length_d45040a40c570362 = function(arg0) {
728 const ret = getObject(arg0).length;
729 return ret;
730 };
731 imports.wbg.__wbg_new_6421f6084cc5bc5a = function(arg0) {
732 const ret = new Uint8Array(getObject(arg0));
733 return addHeapObject(ret);
734 };
735 imports.wbg.__wbg_new_8a6f238a6ece86ea = function() {
736 const ret = new Error();
737 return addHeapObject(ret);
738 };
739 imports.wbg.__wbg_next_138a17bbf04e926c = function(arg0) {
740 const ret = getObject(arg0).next;
741 return addHeapObject(ret);
742 };
743 imports.wbg.__wbg_next_3cfe5c0fe2a4cc53 = function() { return handleError(function (arg0) {
744 const ret = getObject(arg0).next();
745 return addHeapObject(ret);
746 }, arguments) };
747 imports.wbg.__wbg_prototypesetcall_dfe9b766cdc1f1fd = function(arg0, arg1, arg2) {
748 Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
749 };
750 imports.wbg.__wbg_stack_0ed75d68575b0f3c = function(arg0, arg1) {
751 const ret = getObject(arg1).stack;
752 const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
753 const len1 = WASM_VECTOR_LEN;
754 getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
755 getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
756 };
757 imports.wbg.__wbg_value_57b7b035e117f7ee = function(arg0) {
758 const ret = getObject(arg0).value;
759 return addHeapObject(ret);
760 };
761 imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
762 // Cast intrinsic for `Ref(String) -> Externref`.
763 const ret = getStringFromWasm0(arg0, arg1);
764 return addHeapObject(ret);
765 };
766 imports.wbg.__wbindgen_cast_4625c577ab2ec9ee = function(arg0) {
767 // Cast intrinsic for `U64 -> Externref`.
768 const ret = BigInt.asUintN(64, arg0);
769 return addHeapObject(ret);
770 };
771 imports.wbg.__wbindgen_cast_9ae0607507abb057 = function(arg0) {
772 // Cast intrinsic for `I64 -> Externref`.
773 const ret = arg0;
774 return addHeapObject(ret);
775 };
776 imports.wbg.__wbindgen_object_clone_ref = function(arg0) {
777 const ret = getObject(arg0);
778 return addHeapObject(ret);
779 };
780 imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
781 takeObject(arg0);
782 };
783 imports.wbg.__wbindgen_object_is_undefined = function(arg0) {
784 const ret = getObject(arg0) === undefined;
785 return ret;
786 };
787
788 return imports;
789}
790
791function __wbg_finalize_init(instance, module) {
792 wasm = instance.exports;
793 __wbg_init.__wbindgen_wasm_module = module;
794 cachedDataViewMemory0 = null;
795 cachedUint8ArrayMemory0 = null;
796
797
798 wasm.__wbindgen_start();
799 return wasm;
800}
801
802function initSync(module) {
803 if (wasm !== undefined) return wasm;
804
805
806 if (typeof module !== 'undefined') {
807 if (Object.getPrototypeOf(module) === Object.prototype) {
808 ({module} = module)
809 } else {
810 console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
811 }
812 }
813
814 const imports = __wbg_get_imports();
815 if (!(module instanceof WebAssembly.Module)) {
816 module = new WebAssembly.Module(module);
817 }
818 const instance = new WebAssembly.Instance(module, imports);
819 return __wbg_finalize_init(instance, module);
820}
821
822async function __wbg_init(module_or_path) {
823 if (wasm !== undefined) return wasm;
824
825
826 if (typeof module_or_path !== 'undefined') {
827 if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
828 ({module_or_path} = module_or_path)
829 } else {
830 console.warn('using deprecated parameters for the initialization function; pass a single object instead')
831 }
832 }
833
834 if (typeof module_or_path === 'undefined') {
835 module_or_path = new URL('weaver_renderer_bg.wasm', import.meta.url);
836 }
837 const imports = __wbg_get_imports();
838
839 if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
840 module_or_path = fetch(module_or_path);
841 }
842
843 const { instance, module } = await __wbg_load(await module_or_path, imports);
844
845 return __wbg_finalize_init(instance, module);
846}
847
848export { initSync };
849export default __wbg_init;