worker stuff.

Orual 9e5ec080 25aed9ad

+2790 -269
+44
Cargo.lock
··· 4290 4290 ] 4291 4291 4292 4292 [[package]] 4293 + name = "gloo-worker" 4294 + version = "0.5.0" 4295 + source = "registry+https://github.com/rust-lang/crates.io-index" 4296 + checksum = "085f262d7604911c8150162529cefab3782e91adb20202e8658f7275d2aefe5d" 4297 + dependencies = [ 4298 + "bincode", 4299 + "futures", 4300 + "gloo-utils", 4301 + "gloo-worker-macros", 4302 + "js-sys", 4303 + "pinned", 4304 + "serde", 4305 + "thiserror 1.0.69", 4306 + "wasm-bindgen", 4307 + "wasm-bindgen-futures", 4308 + "web-sys", 4309 + ] 4310 + 4311 + [[package]] 4312 + name = "gloo-worker-macros" 4313 + version = "0.1.0" 4314 + source = "registry+https://github.com/rust-lang/crates.io-index" 4315 + checksum = "956caa58d4857bc9941749d55e4bd3000032d8212762586fa5705632967140e7" 4316 + dependencies = [ 4317 + "proc-macro-crate 1.3.1", 4318 + "proc-macro2", 4319 + "quote", 4320 + "syn 2.0.111", 4321 + ] 4322 + 4323 + [[package]] 4293 4324 name = "gobject-sys" 4294 4325 version = "0.18.0" 4295 4326 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 7808 7839 version = "0.1.0" 7809 7840 source = "registry+https://github.com/rust-lang/crates.io-index" 7810 7841 checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" 7842 + 7843 + [[package]] 7844 + name = "pinned" 7845 + version = "0.1.0" 7846 + source = "registry+https://github.com/rust-lang/crates.io-index" 7847 + checksum = "a829027bd95e54cfe13e3e258a1ae7b645960553fb82b75ff852c29688ee595b" 7848 + dependencies = [ 7849 + "futures", 7850 + "rustversion", 7851 + "thiserror 1.0.69", 7852 + ] 7811 7853 7812 7854 [[package]] 7813 7855 name = "pkarr" ··· 11488 11530 "getrandom 0.3.4", 11489 11531 "gloo-storage", 11490 11532 "gloo-timers", 11533 + "gloo-worker", 11491 11534 "http", 11492 11535 "humansize", 11493 11536 "insta", ··· 11503 11546 "mime-sniffer", 11504 11547 "mini-moka 0.11.0", 11505 11548 "n0-future 0.1.3", 11549 + "postcard", 11506 11550 "regex", 11507 11551 "regex-lite", 11508 11552 "reqwest",
+18
crates/weaver-app/Cargo.toml
··· 4 4 authors = ["Orual <orual@nonbinary.computer>"] 5 5 edition = "2024" 6 6 7 + [lib] 8 + name = "weaver_app" 9 + path = "src/lib.rs" 10 + 11 + [[bin]] 12 + name = "weaver-app" 13 + path = "src/main.rs" 14 + 15 + [[bin]] 16 + name = "editor_worker" 17 + path = "src/bin/editor_worker.rs" 18 + 19 + [[bin]] 20 + name = "embed_worker" 21 + path = "src/bin/embed_worker.rs" 22 + 7 23 [features] 8 24 default = ["web", "fullstack-server", "no-app-index"] 9 25 # Fullstack mode with SSR and server functions ··· 84 100 js-sys = "0.3" 85 101 gloo-storage = "0.3" 86 102 gloo-timers = "0.3" 103 + gloo-worker = { version = "0.5", features = ["futures"] } 104 + postcard = "1.1" 87 105 ring = { version = "0.17", default-features = false, features = ["wasm32_unknown_unknown_js"]} 88 106 getrandom = { version = "0.3", default-features = false, features = ["wasm_js"] } 89 107 lol_alloc = "0.4.1"
+688
crates/weaver-app/public/editor_worker.js
··· 1 + let wasm_bindgen; 2 + (function() { 3 + const __exports = {}; 4 + let script_src; 5 + if (typeof document !== 'undefined' && document.currentScript !== null) { 6 + script_src = new URL(document.currentScript.src, location.href).toString(); 7 + } 8 + let wasm = undefined; 9 + 10 + function addToExternrefTable0(obj) { 11 + const idx = wasm.__externref_table_alloc(); 12 + wasm.__wbindgen_externrefs.set(idx, obj); 13 + return idx; 14 + } 15 + 16 + const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined') 17 + ? { register: () => {}, unregister: () => {} } 18 + : new FinalizationRegistry(state => state.dtor(state.a, state.b)); 19 + 20 + function getArrayU8FromWasm0(ptr, len) { 21 + ptr = ptr >>> 0; 22 + return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len); 23 + } 24 + 25 + let cachedDataViewMemory0 = null; 26 + function getDataViewMemory0() { 27 + if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) { 28 + cachedDataViewMemory0 = new DataView(wasm.memory.buffer); 29 + } 30 + return cachedDataViewMemory0; 31 + } 32 + 33 + function getStringFromWasm0(ptr, len) { 34 + ptr = ptr >>> 0; 35 + return decodeText(ptr, len); 36 + } 37 + 38 + let cachedUint8ArrayMemory0 = null; 39 + function getUint8ArrayMemory0() { 40 + if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) { 41 + cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer); 42 + } 43 + return cachedUint8ArrayMemory0; 44 + } 45 + 46 + function handleError(f, args) { 47 + try { 48 + return f.apply(this, args); 49 + } catch (e) { 50 + const idx = addToExternrefTable0(e); 51 + wasm.__wbindgen_exn_store(idx); 52 + } 53 + } 54 + 55 + function isLikeNone(x) { 56 + return x === undefined || x === null; 57 + } 58 + 59 + function makeClosure(arg0, arg1, dtor, f) { 60 + const state = { a: arg0, b: arg1, cnt: 1, dtor }; 61 + const real = (...args) => { 62 + 63 + // First up with a closure we increment the internal reference 64 + // count. This ensures that the Rust closure environment won't 65 + // be deallocated while we're invoking it. 66 + state.cnt++; 67 + try { 68 + return f(state.a, state.b, ...args); 69 + } finally { 70 + real._wbg_cb_unref(); 71 + } 72 + }; 73 + real._wbg_cb_unref = () => { 74 + if (--state.cnt === 0) { 75 + state.dtor(state.a, state.b); 76 + state.a = 0; 77 + CLOSURE_DTORS.unregister(state); 78 + } 79 + }; 80 + CLOSURE_DTORS.register(real, state, state); 81 + return real; 82 + } 83 + 84 + function makeMutClosure(arg0, arg1, dtor, f) { 85 + const state = { a: arg0, b: arg1, cnt: 1, dtor }; 86 + const real = (...args) => { 87 + 88 + // First up with a closure we increment the internal reference 89 + // count. This ensures that the Rust closure environment won't 90 + // be deallocated while we're invoking it. 91 + state.cnt++; 92 + const a = state.a; 93 + state.a = 0; 94 + try { 95 + return f(a, state.b, ...args); 96 + } finally { 97 + state.a = a; 98 + real._wbg_cb_unref(); 99 + } 100 + }; 101 + real._wbg_cb_unref = () => { 102 + if (--state.cnt === 0) { 103 + state.dtor(state.a, state.b); 104 + state.a = 0; 105 + CLOSURE_DTORS.unregister(state); 106 + } 107 + }; 108 + CLOSURE_DTORS.register(real, state, state); 109 + return real; 110 + } 111 + 112 + function passStringToWasm0(arg, malloc, realloc) { 113 + if (realloc === undefined) { 114 + const buf = cachedTextEncoder.encode(arg); 115 + const ptr = malloc(buf.length, 1) >>> 0; 116 + getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf); 117 + WASM_VECTOR_LEN = buf.length; 118 + return ptr; 119 + } 120 + 121 + let len = arg.length; 122 + let ptr = malloc(len, 1) >>> 0; 123 + 124 + const mem = getUint8ArrayMemory0(); 125 + 126 + let offset = 0; 127 + 128 + for (; offset < len; offset++) { 129 + const code = arg.charCodeAt(offset); 130 + if (code > 0x7F) break; 131 + mem[ptr + offset] = code; 132 + } 133 + if (offset !== len) { 134 + if (offset !== 0) { 135 + arg = arg.slice(offset); 136 + } 137 + ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0; 138 + const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len); 139 + const ret = cachedTextEncoder.encodeInto(arg, view); 140 + 141 + offset += ret.written; 142 + ptr = realloc(ptr, len, offset, 1) >>> 0; 143 + } 144 + 145 + WASM_VECTOR_LEN = offset; 146 + return ptr; 147 + } 148 + 149 + let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }); 150 + cachedTextDecoder.decode(); 151 + function decodeText(ptr, len) { 152 + return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len)); 153 + } 154 + 155 + const cachedTextEncoder = new TextEncoder(); 156 + 157 + if (!('encodeInto' in cachedTextEncoder)) { 158 + cachedTextEncoder.encodeInto = function (arg, view) { 159 + const buf = cachedTextEncoder.encode(arg); 160 + view.set(buf); 161 + return { 162 + read: arg.length, 163 + written: buf.length 164 + }; 165 + } 166 + } 167 + 168 + let WASM_VECTOR_LEN = 0; 169 + 170 + function wasm_bindgen_1add006a0ed82fd3___convert__closures_____invoke___wasm_bindgen_1add006a0ed82fd3___JsValue_____(arg0, arg1, arg2) { 171 + wasm.wasm_bindgen_1add006a0ed82fd3___convert__closures_____invoke___wasm_bindgen_1add006a0ed82fd3___JsValue_____(arg0, arg1, arg2); 172 + } 173 + 174 + function wasm_bindgen_1add006a0ed82fd3___convert__closures_____invoke___web_sys_81daa69175395078___features__gen_MessageEvent__MessageEvent_____(arg0, arg1, arg2) { 175 + wasm.wasm_bindgen_1add006a0ed82fd3___convert__closures_____invoke___web_sys_81daa69175395078___features__gen_MessageEvent__MessageEvent_____(arg0, arg1, arg2); 176 + } 177 + 178 + function wasm_bindgen_1add006a0ed82fd3___convert__closures_____invoke___wasm_bindgen_1add006a0ed82fd3___JsValue__wasm_bindgen_1add006a0ed82fd3___JsValue_____(arg0, arg1, arg2, arg3) { 179 + wasm.wasm_bindgen_1add006a0ed82fd3___convert__closures_____invoke___wasm_bindgen_1add006a0ed82fd3___JsValue__wasm_bindgen_1add006a0ed82fd3___JsValue_____(arg0, arg1, arg2, arg3); 180 + } 181 + 182 + const __wbindgen_enum_ReadableStreamType = ["bytes"]; 183 + 184 + const IntoUnderlyingByteSourceFinalization = (typeof FinalizationRegistry === 'undefined') 185 + ? { register: () => {}, unregister: () => {} } 186 + : new FinalizationRegistry(ptr => wasm.__wbg_intounderlyingbytesource_free(ptr >>> 0, 1)); 187 + 188 + const IntoUnderlyingSinkFinalization = (typeof FinalizationRegistry === 'undefined') 189 + ? { register: () => {}, unregister: () => {} } 190 + : new FinalizationRegistry(ptr => wasm.__wbg_intounderlyingsink_free(ptr >>> 0, 1)); 191 + 192 + const IntoUnderlyingSourceFinalization = (typeof FinalizationRegistry === 'undefined') 193 + ? { register: () => {}, unregister: () => {} } 194 + : new FinalizationRegistry(ptr => wasm.__wbg_intounderlyingsource_free(ptr >>> 0, 1)); 195 + 196 + const JSOwnerFinalization = (typeof FinalizationRegistry === 'undefined') 197 + ? { register: () => {}, unregister: () => {} } 198 + : new FinalizationRegistry(ptr => wasm.__wbg_jsowner_free(ptr >>> 0, 1)); 199 + 200 + class IntoUnderlyingByteSource { 201 + __destroy_into_raw() { 202 + const ptr = this.__wbg_ptr; 203 + this.__wbg_ptr = 0; 204 + IntoUnderlyingByteSourceFinalization.unregister(this); 205 + return ptr; 206 + } 207 + free() { 208 + const ptr = this.__destroy_into_raw(); 209 + wasm.__wbg_intounderlyingbytesource_free(ptr, 0); 210 + } 211 + /** 212 + * @returns {number} 213 + */ 214 + get autoAllocateChunkSize() { 215 + const ret = wasm.intounderlyingbytesource_autoAllocateChunkSize(this.__wbg_ptr); 216 + return ret >>> 0; 217 + } 218 + /** 219 + * @param {ReadableByteStreamController} controller 220 + * @returns {Promise<any>} 221 + */ 222 + pull(controller) { 223 + const ret = wasm.intounderlyingbytesource_pull(this.__wbg_ptr, controller); 224 + return ret; 225 + } 226 + /** 227 + * @param {ReadableByteStreamController} controller 228 + */ 229 + start(controller) { 230 + wasm.intounderlyingbytesource_start(this.__wbg_ptr, controller); 231 + } 232 + /** 233 + * @returns {ReadableStreamType} 234 + */ 235 + get type() { 236 + const ret = wasm.intounderlyingbytesource_type(this.__wbg_ptr); 237 + return __wbindgen_enum_ReadableStreamType[ret]; 238 + } 239 + cancel() { 240 + const ptr = this.__destroy_into_raw(); 241 + wasm.intounderlyingbytesource_cancel(ptr); 242 + } 243 + } 244 + if (Symbol.dispose) IntoUnderlyingByteSource.prototype[Symbol.dispose] = IntoUnderlyingByteSource.prototype.free; 245 + __exports.IntoUnderlyingByteSource = IntoUnderlyingByteSource; 246 + 247 + class IntoUnderlyingSink { 248 + __destroy_into_raw() { 249 + const ptr = this.__wbg_ptr; 250 + this.__wbg_ptr = 0; 251 + IntoUnderlyingSinkFinalization.unregister(this); 252 + return ptr; 253 + } 254 + free() { 255 + const ptr = this.__destroy_into_raw(); 256 + wasm.__wbg_intounderlyingsink_free(ptr, 0); 257 + } 258 + /** 259 + * @param {any} reason 260 + * @returns {Promise<any>} 261 + */ 262 + abort(reason) { 263 + const ptr = this.__destroy_into_raw(); 264 + const ret = wasm.intounderlyingsink_abort(ptr, reason); 265 + return ret; 266 + } 267 + /** 268 + * @returns {Promise<any>} 269 + */ 270 + close() { 271 + const ptr = this.__destroy_into_raw(); 272 + const ret = wasm.intounderlyingsink_close(ptr); 273 + return ret; 274 + } 275 + /** 276 + * @param {any} chunk 277 + * @returns {Promise<any>} 278 + */ 279 + write(chunk) { 280 + const ret = wasm.intounderlyingsink_write(this.__wbg_ptr, chunk); 281 + return ret; 282 + } 283 + } 284 + if (Symbol.dispose) IntoUnderlyingSink.prototype[Symbol.dispose] = IntoUnderlyingSink.prototype.free; 285 + __exports.IntoUnderlyingSink = IntoUnderlyingSink; 286 + 287 + class IntoUnderlyingSource { 288 + __destroy_into_raw() { 289 + const ptr = this.__wbg_ptr; 290 + this.__wbg_ptr = 0; 291 + IntoUnderlyingSourceFinalization.unregister(this); 292 + return ptr; 293 + } 294 + free() { 295 + const ptr = this.__destroy_into_raw(); 296 + wasm.__wbg_intounderlyingsource_free(ptr, 0); 297 + } 298 + /** 299 + * @param {ReadableStreamDefaultController} controller 300 + * @returns {Promise<any>} 301 + */ 302 + pull(controller) { 303 + const ret = wasm.intounderlyingsource_pull(this.__wbg_ptr, controller); 304 + return ret; 305 + } 306 + cancel() { 307 + const ptr = this.__destroy_into_raw(); 308 + wasm.intounderlyingsource_cancel(ptr); 309 + } 310 + } 311 + if (Symbol.dispose) IntoUnderlyingSource.prototype[Symbol.dispose] = IntoUnderlyingSource.prototype.free; 312 + __exports.IntoUnderlyingSource = IntoUnderlyingSource; 313 + 314 + class JSOwner { 315 + __destroy_into_raw() { 316 + const ptr = this.__wbg_ptr; 317 + this.__wbg_ptr = 0; 318 + JSOwnerFinalization.unregister(this); 319 + return ptr; 320 + } 321 + free() { 322 + const ptr = this.__destroy_into_raw(); 323 + wasm.__wbg_jsowner_free(ptr, 0); 324 + } 325 + } 326 + if (Symbol.dispose) JSOwner.prototype[Symbol.dispose] = JSOwner.prototype.free; 327 + __exports.JSOwner = JSOwner; 328 + 329 + const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']); 330 + 331 + async function __wbg_load(module, imports) { 332 + if (typeof Response === 'function' && module instanceof Response) { 333 + if (typeof WebAssembly.instantiateStreaming === 'function') { 334 + try { 335 + return await WebAssembly.instantiateStreaming(module, imports); 336 + } catch (e) { 337 + const validResponse = module.ok && EXPECTED_RESPONSE_TYPES.has(module.type); 338 + 339 + if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') { 340 + 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); 341 + 342 + } else { 343 + throw e; 344 + } 345 + } 346 + } 347 + 348 + const bytes = await module.arrayBuffer(); 349 + return await WebAssembly.instantiate(bytes, imports); 350 + } else { 351 + const instance = await WebAssembly.instantiate(module, imports); 352 + 353 + if (instance instanceof WebAssembly.Instance) { 354 + return { instance, module }; 355 + } else { 356 + return instance; 357 + } 358 + } 359 + } 360 + 361 + function __wbg_get_imports() { 362 + const imports = {}; 363 + imports.wbg = {}; 364 + imports.wbg.__wbg___wbindgen_is_function_8d400b8b1af978cd = function(arg0) { 365 + const ret = typeof(arg0) === 'function'; 366 + return ret; 367 + }; 368 + imports.wbg.__wbg___wbindgen_is_object_ce774f3490692386 = function(arg0) { 369 + const val = arg0; 370 + const ret = typeof(val) === 'object' && val !== null; 371 + return ret; 372 + }; 373 + imports.wbg.__wbg___wbindgen_is_string_704ef9c8fc131030 = function(arg0) { 374 + const ret = typeof(arg0) === 'string'; 375 + return ret; 376 + }; 377 + imports.wbg.__wbg___wbindgen_is_undefined_f6b95eab589e0269 = function(arg0) { 378 + const ret = arg0 === undefined; 379 + return ret; 380 + }; 381 + imports.wbg.__wbg___wbindgen_throw_dd24417ed36fc46e = function(arg0, arg1) { 382 + throw new Error(getStringFromWasm0(arg0, arg1)); 383 + }; 384 + imports.wbg.__wbg__wbg_cb_unref_87dfb5aaa0cbcea7 = function(arg0) { 385 + arg0._wbg_cb_unref(); 386 + }; 387 + imports.wbg.__wbg_buffer_6cb2fecb1f253d71 = function(arg0) { 388 + const ret = arg0.buffer; 389 + return ret; 390 + }; 391 + imports.wbg.__wbg_byobRequest_f8e3517f5f8ad284 = function(arg0) { 392 + const ret = arg0.byobRequest; 393 + return isLikeNone(ret) ? 0 : addToExternrefTable0(ret); 394 + }; 395 + imports.wbg.__wbg_byteLength_faa9938885bdeee6 = function(arg0) { 396 + const ret = arg0.byteLength; 397 + return ret; 398 + }; 399 + imports.wbg.__wbg_byteOffset_3868b6a19ba01dea = function(arg0) { 400 + const ret = arg0.byteOffset; 401 + return ret; 402 + }; 403 + imports.wbg.__wbg_call_3020136f7a2d6e44 = function() { return handleError(function (arg0, arg1, arg2) { 404 + const ret = arg0.call(arg1, arg2); 405 + return ret; 406 + }, arguments) }; 407 + imports.wbg.__wbg_call_abb4ff46ce38be40 = function() { return handleError(function (arg0, arg1) { 408 + const ret = arg0.call(arg1); 409 + return ret; 410 + }, arguments) }; 411 + imports.wbg.__wbg_close_0af5661bf3d335f2 = function() { return handleError(function (arg0) { 412 + arg0.close(); 413 + }, arguments) }; 414 + imports.wbg.__wbg_close_0b472ca2d13f54f7 = function(arg0) { 415 + arg0.close(); 416 + }; 417 + imports.wbg.__wbg_close_3ec111e7b23d94d8 = function() { return handleError(function (arg0) { 418 + arg0.close(); 419 + }, arguments) }; 420 + imports.wbg.__wbg_crypto_574e78ad8b13b65f = function(arg0) { 421 + const ret = arg0.crypto; 422 + return ret; 423 + }; 424 + imports.wbg.__wbg_data_8bf4ae669a78a688 = function(arg0) { 425 + const ret = arg0.data; 426 + return ret; 427 + }; 428 + imports.wbg.__wbg_enqueue_a7e6b1ee87963aad = function() { return handleError(function (arg0, arg1) { 429 + arg0.enqueue(arg1); 430 + }, arguments) }; 431 + imports.wbg.__wbg_error_7534b8e9a36f1ab4 = function(arg0, arg1) { 432 + let deferred0_0; 433 + let deferred0_1; 434 + try { 435 + deferred0_0 = arg0; 436 + deferred0_1 = arg1; 437 + console.error(getStringFromWasm0(arg0, arg1)); 438 + } finally { 439 + wasm.__wbindgen_free(deferred0_0, deferred0_1, 1); 440 + } 441 + }; 442 + imports.wbg.__wbg_getRandomValues_b8f5dbd5f3995a9e = function() { return handleError(function (arg0, arg1) { 443 + arg0.getRandomValues(arg1); 444 + }, arguments) }; 445 + imports.wbg.__wbg_instanceof_Window_b5cf7783caa68180 = function(arg0) { 446 + let result; 447 + try { 448 + result = arg0 instanceof Window; 449 + } catch (_) { 450 + result = false; 451 + } 452 + const ret = result; 453 + return ret; 454 + }; 455 + imports.wbg.__wbg_length_22ac23eaec9d8053 = function(arg0) { 456 + const ret = arg0.length; 457 + return ret; 458 + }; 459 + imports.wbg.__wbg_msCrypto_a61aeb35a24c1329 = function(arg0) { 460 + const ret = arg0.msCrypto; 461 + return ret; 462 + }; 463 + imports.wbg.__wbg_new_8a6f238a6ece86ea = function() { 464 + const ret = new Error(); 465 + return ret; 466 + }; 467 + imports.wbg.__wbg_new_df1173567d5ff028 = function(arg0, arg1) { 468 + const ret = new Error(getStringFromWasm0(arg0, arg1)); 469 + return ret; 470 + }; 471 + imports.wbg.__wbg_new_ff12d2b041fb48f1 = function(arg0, arg1) { 472 + try { 473 + var state0 = {a: arg0, b: arg1}; 474 + var cb0 = (arg0, arg1) => { 475 + const a = state0.a; 476 + state0.a = 0; 477 + try { 478 + return wasm_bindgen_1add006a0ed82fd3___convert__closures_____invoke___wasm_bindgen_1add006a0ed82fd3___JsValue__wasm_bindgen_1add006a0ed82fd3___JsValue_____(a, state0.b, arg0, arg1); 479 + } finally { 480 + state0.a = a; 481 + } 482 + }; 483 + const ret = new Promise(cb0); 484 + return ret; 485 + } finally { 486 + state0.a = state0.b = 0; 487 + } 488 + }; 489 + imports.wbg.__wbg_new_from_slice_f9c22b9153b26992 = function(arg0, arg1) { 490 + const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1)); 491 + return ret; 492 + }; 493 + imports.wbg.__wbg_new_no_args_cb138f77cf6151ee = function(arg0, arg1) { 494 + const ret = new Function(getStringFromWasm0(arg0, arg1)); 495 + return ret; 496 + }; 497 + imports.wbg.__wbg_new_with_byte_offset_and_length_d85c3da1fd8df149 = function(arg0, arg1, arg2) { 498 + const ret = new Uint8Array(arg0, arg1 >>> 0, arg2 >>> 0); 499 + return ret; 500 + }; 501 + imports.wbg.__wbg_new_with_length_aa5eaf41d35235e5 = function(arg0) { 502 + const ret = new Uint8Array(arg0 >>> 0); 503 + return ret; 504 + }; 505 + imports.wbg.__wbg_node_905d3e251edff8a2 = function(arg0) { 506 + const ret = arg0.node; 507 + return ret; 508 + }; 509 + imports.wbg.__wbg_now_8a87c5466cc7d560 = function() { 510 + const ret = Date.now(); 511 + return ret; 512 + }; 513 + imports.wbg.__wbg_now_8cf15d6e317793e1 = function(arg0) { 514 + const ret = arg0.now(); 515 + return ret; 516 + }; 517 + imports.wbg.__wbg_performance_c77a440eff2efd9b = function(arg0) { 518 + const ret = arg0.performance; 519 + return isLikeNone(ret) ? 0 : addToExternrefTable0(ret); 520 + }; 521 + imports.wbg.__wbg_postMessage_7243f814e0cfb266 = function() { return handleError(function (arg0, arg1) { 522 + arg0.postMessage(arg1); 523 + }, arguments) }; 524 + imports.wbg.__wbg_process_dc0fbacc7c1c06f7 = function(arg0) { 525 + const ret = arg0.process; 526 + return ret; 527 + }; 528 + imports.wbg.__wbg_prototypesetcall_dfe9b766cdc1f1fd = function(arg0, arg1, arg2) { 529 + Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2); 530 + }; 531 + imports.wbg.__wbg_queueMicrotask_9b549dfce8865860 = function(arg0) { 532 + const ret = arg0.queueMicrotask; 533 + return ret; 534 + }; 535 + imports.wbg.__wbg_queueMicrotask_fca69f5bfad613a5 = function(arg0) { 536 + queueMicrotask(arg0); 537 + }; 538 + imports.wbg.__wbg_randomFillSync_ac0988aba3254290 = function() { return handleError(function (arg0, arg1) { 539 + arg0.randomFillSync(arg1); 540 + }, arguments) }; 541 + imports.wbg.__wbg_require_60cc747a6bc5215a = function() { return handleError(function () { 542 + const ret = module.require; 543 + return ret; 544 + }, arguments) }; 545 + imports.wbg.__wbg_resolve_fd5bfbaa4ce36e1e = function(arg0) { 546 + const ret = Promise.resolve(arg0); 547 + return ret; 548 + }; 549 + imports.wbg.__wbg_respond_9f7fc54636c4a3af = function() { return handleError(function (arg0, arg1) { 550 + arg0.respond(arg1 >>> 0); 551 + }, arguments) }; 552 + imports.wbg.__wbg_set_169e13b608078b7b = function(arg0, arg1, arg2) { 553 + arg0.set(getArrayU8FromWasm0(arg1, arg2)); 554 + }; 555 + imports.wbg.__wbg_set_onmessage_5fe29d0fb54cb575 = function(arg0, arg1) { 556 + arg0.onmessage = arg1; 557 + }; 558 + imports.wbg.__wbg_stack_0ed75d68575b0f3c = function(arg0, arg1) { 559 + const ret = arg1.stack; 560 + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); 561 + const len1 = WASM_VECTOR_LEN; 562 + getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true); 563 + getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true); 564 + }; 565 + imports.wbg.__wbg_static_accessor_GLOBAL_769e6b65d6557335 = function() { 566 + const ret = typeof global === 'undefined' ? null : global; 567 + return isLikeNone(ret) ? 0 : addToExternrefTable0(ret); 568 + }; 569 + imports.wbg.__wbg_static_accessor_GLOBAL_THIS_60cf02db4de8e1c1 = function() { 570 + const ret = typeof globalThis === 'undefined' ? null : globalThis; 571 + return isLikeNone(ret) ? 0 : addToExternrefTable0(ret); 572 + }; 573 + imports.wbg.__wbg_static_accessor_SELF_08f5a74c69739274 = function() { 574 + const ret = typeof self === 'undefined' ? null : self; 575 + return isLikeNone(ret) ? 0 : addToExternrefTable0(ret); 576 + }; 577 + imports.wbg.__wbg_static_accessor_WINDOW_a8924b26aa92d024 = function() { 578 + const ret = typeof window === 'undefined' ? null : window; 579 + return isLikeNone(ret) ? 0 : addToExternrefTable0(ret); 580 + }; 581 + imports.wbg.__wbg_subarray_845f2f5bce7d061a = function(arg0, arg1, arg2) { 582 + const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0); 583 + return ret; 584 + }; 585 + imports.wbg.__wbg_then_4f95312d68691235 = function(arg0, arg1) { 586 + const ret = arg0.then(arg1); 587 + return ret; 588 + }; 589 + imports.wbg.__wbg_versions_c01dfd4722a88165 = function(arg0) { 590 + const ret = arg0.versions; 591 + return ret; 592 + }; 593 + imports.wbg.__wbg_view_788aaf149deefd2f = function(arg0) { 594 + const ret = arg0.view; 595 + return isLikeNone(ret) ? 0 : addToExternrefTable0(ret); 596 + }; 597 + imports.wbg.__wbindgen_cast_1201d4f342f74eb8 = function(arg0, arg1) { 598 + // Cast intrinsic for `Closure(Closure { dtor_idx: 909, function: Function { arguments: [Externref], shim_idx: 910, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`. 599 + const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen_1add006a0ed82fd3___closure__destroy___dyn_core_b125d98f3949a913___ops__function__FnMut__wasm_bindgen_1add006a0ed82fd3___JsValue____Output_______, wasm_bindgen_1add006a0ed82fd3___convert__closures_____invoke___wasm_bindgen_1add006a0ed82fd3___JsValue_____); 600 + return ret; 601 + }; 602 + imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) { 603 + // Cast intrinsic for `Ref(String) -> Externref`. 604 + const ret = getStringFromWasm0(arg0, arg1); 605 + return ret; 606 + }; 607 + imports.wbg.__wbindgen_cast_cb9088102bce6b30 = function(arg0, arg1) { 608 + // Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`. 609 + const ret = getArrayU8FromWasm0(arg0, arg1); 610 + return ret; 611 + }; 612 + imports.wbg.__wbindgen_cast_df669a3c3b68a548 = function(arg0, arg1) { 613 + // Cast intrinsic for `Closure(Closure { dtor_idx: 65, function: Function { arguments: [NamedExternref("MessageEvent")], shim_idx: 66, ret: Unit, inner_ret: Some(Unit) }, mutable: false }) -> Externref`. 614 + const ret = makeClosure(arg0, arg1, wasm.wasm_bindgen_1add006a0ed82fd3___closure__destroy___dyn_core_b125d98f3949a913___ops__function__Fn__web_sys_81daa69175395078___features__gen_MessageEvent__MessageEvent____Output_______, wasm_bindgen_1add006a0ed82fd3___convert__closures_____invoke___web_sys_81daa69175395078___features__gen_MessageEvent__MessageEvent_____); 615 + return ret; 616 + }; 617 + imports.wbg.__wbindgen_init_externref_table = function() { 618 + const table = wasm.__wbindgen_externrefs; 619 + const offset = table.grow(4); 620 + table.set(0, undefined); 621 + table.set(offset + 0, undefined); 622 + table.set(offset + 1, null); 623 + table.set(offset + 2, true); 624 + table.set(offset + 3, false); 625 + }; 626 + 627 + return imports; 628 + } 629 + 630 + function __wbg_finalize_init(instance, module) { 631 + wasm = instance.exports; 632 + __wbg_init.__wbindgen_wasm_module = module; 633 + cachedDataViewMemory0 = null; 634 + cachedUint8ArrayMemory0 = null; 635 + 636 + 637 + wasm.__wbindgen_start(); 638 + return wasm; 639 + } 640 + 641 + function initSync(module) { 642 + if (wasm !== undefined) return wasm; 643 + 644 + 645 + if (typeof module !== 'undefined') { 646 + if (Object.getPrototypeOf(module) === Object.prototype) { 647 + ({module} = module) 648 + } else { 649 + console.warn('using deprecated parameters for `initSync()`; pass a single object instead') 650 + } 651 + } 652 + 653 + const imports = __wbg_get_imports(); 654 + if (!(module instanceof WebAssembly.Module)) { 655 + module = new WebAssembly.Module(module); 656 + } 657 + const instance = new WebAssembly.Instance(module, imports); 658 + return __wbg_finalize_init(instance, module); 659 + } 660 + 661 + async function __wbg_init(module_or_path) { 662 + if (wasm !== undefined) return wasm; 663 + 664 + 665 + if (typeof module_or_path !== 'undefined') { 666 + if (Object.getPrototypeOf(module_or_path) === Object.prototype) { 667 + ({module_or_path} = module_or_path) 668 + } else { 669 + console.warn('using deprecated parameters for the initialization function; pass a single object instead') 670 + } 671 + } 672 + 673 + if (typeof module_or_path === 'undefined' && typeof script_src !== 'undefined') { 674 + module_or_path = script_src.replace(/\.js$/, '_bg.wasm'); 675 + } 676 + const imports = __wbg_get_imports(); 677 + 678 + if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) { 679 + module_or_path = fetch(module_or_path); 680 + } 681 + 682 + const { instance, module } = await __wbg_load(await module_or_path, imports); 683 + 684 + return __wbg_finalize_init(instance, module); 685 + } 686 + 687 + wasm_bindgen = Object.assign(__wbg_init, { initSync }, __exports); 688 + })();
+931
crates/weaver-app/public/embed_worker.js
··· 1 + let wasm_bindgen; 2 + (function() { 3 + const __exports = {}; 4 + let script_src; 5 + if (typeof document !== 'undefined' && document.currentScript !== null) { 6 + script_src = new URL(document.currentScript.src, location.href).toString(); 7 + } 8 + let wasm = undefined; 9 + 10 + function addToExternrefTable0(obj) { 11 + const idx = wasm.__externref_table_alloc(); 12 + wasm.__wbindgen_externrefs.set(idx, obj); 13 + return idx; 14 + } 15 + 16 + const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined') 17 + ? { register: () => {}, unregister: () => {} } 18 + : new FinalizationRegistry(state => state.dtor(state.a, state.b)); 19 + 20 + function debugString(val) { 21 + // primitive types 22 + const type = typeof val; 23 + if (type == 'number' || type == 'boolean' || val == null) { 24 + return `${val}`; 25 + } 26 + if (type == 'string') { 27 + return `"${val}"`; 28 + } 29 + if (type == 'symbol') { 30 + const description = val.description; 31 + if (description == null) { 32 + return 'Symbol'; 33 + } else { 34 + return `Symbol(${description})`; 35 + } 36 + } 37 + if (type == 'function') { 38 + const name = val.name; 39 + if (typeof name == 'string' && name.length > 0) { 40 + return `Function(${name})`; 41 + } else { 42 + return 'Function'; 43 + } 44 + } 45 + // objects 46 + if (Array.isArray(val)) { 47 + const length = val.length; 48 + let debug = '['; 49 + if (length > 0) { 50 + debug += debugString(val[0]); 51 + } 52 + for(let i = 1; i < length; i++) { 53 + debug += ', ' + debugString(val[i]); 54 + } 55 + debug += ']'; 56 + return debug; 57 + } 58 + // Test for built-in 59 + const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val)); 60 + let className; 61 + if (builtInMatches && builtInMatches.length > 1) { 62 + className = builtInMatches[1]; 63 + } else { 64 + // Failed to match the standard '[object ClassName]' 65 + return toString.call(val); 66 + } 67 + if (className == 'Object') { 68 + // we're a user defined class or Object 69 + // JSON.stringify avoids problems with cycles, and is generally much 70 + // easier than looping through ownProperties of `val`. 71 + try { 72 + return 'Object(' + JSON.stringify(val) + ')'; 73 + } catch (_) { 74 + return 'Object'; 75 + } 76 + } 77 + // errors 78 + if (val instanceof Error) { 79 + return `${val.name}: ${val.message}\n${val.stack}`; 80 + } 81 + // TODO we could test for more things here, like `Set`s and `Map`s. 82 + return className; 83 + } 84 + 85 + function getArrayU8FromWasm0(ptr, len) { 86 + ptr = ptr >>> 0; 87 + return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len); 88 + } 89 + 90 + let cachedDataViewMemory0 = null; 91 + function getDataViewMemory0() { 92 + if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) { 93 + cachedDataViewMemory0 = new DataView(wasm.memory.buffer); 94 + } 95 + return cachedDataViewMemory0; 96 + } 97 + 98 + function getStringFromWasm0(ptr, len) { 99 + ptr = ptr >>> 0; 100 + return decodeText(ptr, len); 101 + } 102 + 103 + let cachedUint8ArrayMemory0 = null; 104 + function getUint8ArrayMemory0() { 105 + if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) { 106 + cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer); 107 + } 108 + return cachedUint8ArrayMemory0; 109 + } 110 + 111 + function handleError(f, args) { 112 + try { 113 + return f.apply(this, args); 114 + } catch (e) { 115 + const idx = addToExternrefTable0(e); 116 + wasm.__wbindgen_exn_store(idx); 117 + } 118 + } 119 + 120 + function isLikeNone(x) { 121 + return x === undefined || x === null; 122 + } 123 + 124 + function makeClosure(arg0, arg1, dtor, f) { 125 + const state = { a: arg0, b: arg1, cnt: 1, dtor }; 126 + const real = (...args) => { 127 + 128 + // First up with a closure we increment the internal reference 129 + // count. This ensures that the Rust closure environment won't 130 + // be deallocated while we're invoking it. 131 + state.cnt++; 132 + try { 133 + return f(state.a, state.b, ...args); 134 + } finally { 135 + real._wbg_cb_unref(); 136 + } 137 + }; 138 + real._wbg_cb_unref = () => { 139 + if (--state.cnt === 0) { 140 + state.dtor(state.a, state.b); 141 + state.a = 0; 142 + CLOSURE_DTORS.unregister(state); 143 + } 144 + }; 145 + CLOSURE_DTORS.register(real, state, state); 146 + return real; 147 + } 148 + 149 + function makeMutClosure(arg0, arg1, dtor, f) { 150 + const state = { a: arg0, b: arg1, cnt: 1, dtor }; 151 + const real = (...args) => { 152 + 153 + // First up with a closure we increment the internal reference 154 + // count. This ensures that the Rust closure environment won't 155 + // be deallocated while we're invoking it. 156 + state.cnt++; 157 + const a = state.a; 158 + state.a = 0; 159 + try { 160 + return f(a, state.b, ...args); 161 + } finally { 162 + state.a = a; 163 + real._wbg_cb_unref(); 164 + } 165 + }; 166 + real._wbg_cb_unref = () => { 167 + if (--state.cnt === 0) { 168 + state.dtor(state.a, state.b); 169 + state.a = 0; 170 + CLOSURE_DTORS.unregister(state); 171 + } 172 + }; 173 + CLOSURE_DTORS.register(real, state, state); 174 + return real; 175 + } 176 + 177 + function passStringToWasm0(arg, malloc, realloc) { 178 + if (realloc === undefined) { 179 + const buf = cachedTextEncoder.encode(arg); 180 + const ptr = malloc(buf.length, 1) >>> 0; 181 + getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf); 182 + WASM_VECTOR_LEN = buf.length; 183 + return ptr; 184 + } 185 + 186 + let len = arg.length; 187 + let ptr = malloc(len, 1) >>> 0; 188 + 189 + const mem = getUint8ArrayMemory0(); 190 + 191 + let offset = 0; 192 + 193 + for (; offset < len; offset++) { 194 + const code = arg.charCodeAt(offset); 195 + if (code > 0x7F) break; 196 + mem[ptr + offset] = code; 197 + } 198 + if (offset !== len) { 199 + if (offset !== 0) { 200 + arg = arg.slice(offset); 201 + } 202 + ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0; 203 + const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len); 204 + const ret = cachedTextEncoder.encodeInto(arg, view); 205 + 206 + offset += ret.written; 207 + ptr = realloc(ptr, len, offset, 1) >>> 0; 208 + } 209 + 210 + WASM_VECTOR_LEN = offset; 211 + return ptr; 212 + } 213 + 214 + let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }); 215 + cachedTextDecoder.decode(); 216 + function decodeText(ptr, len) { 217 + return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len)); 218 + } 219 + 220 + const cachedTextEncoder = new TextEncoder(); 221 + 222 + if (!('encodeInto' in cachedTextEncoder)) { 223 + cachedTextEncoder.encodeInto = function (arg, view) { 224 + const buf = cachedTextEncoder.encode(arg); 225 + view.set(buf); 226 + return { 227 + read: arg.length, 228 + written: buf.length 229 + }; 230 + } 231 + } 232 + 233 + let WASM_VECTOR_LEN = 0; 234 + 235 + function wasm_bindgen_1add006a0ed82fd3___convert__closures_____invoke______(arg0, arg1) { 236 + wasm.wasm_bindgen_1add006a0ed82fd3___convert__closures_____invoke______(arg0, arg1); 237 + } 238 + 239 + function wasm_bindgen_1add006a0ed82fd3___convert__closures_____invoke___web_sys_81daa69175395078___features__gen_MessageEvent__MessageEvent_____(arg0, arg1, arg2) { 240 + wasm.wasm_bindgen_1add006a0ed82fd3___convert__closures_____invoke___web_sys_81daa69175395078___features__gen_MessageEvent__MessageEvent_____(arg0, arg1, arg2); 241 + } 242 + 243 + function wasm_bindgen_1add006a0ed82fd3___convert__closures_____invoke_______1_(arg0, arg1) { 244 + wasm.wasm_bindgen_1add006a0ed82fd3___convert__closures_____invoke_______1_(arg0, arg1); 245 + } 246 + 247 + function wasm_bindgen_1add006a0ed82fd3___convert__closures_____invoke___wasm_bindgen_1add006a0ed82fd3___JsValue_____(arg0, arg1, arg2) { 248 + wasm.wasm_bindgen_1add006a0ed82fd3___convert__closures_____invoke___wasm_bindgen_1add006a0ed82fd3___JsValue_____(arg0, arg1, arg2); 249 + } 250 + 251 + function wasm_bindgen_1add006a0ed82fd3___convert__closures_____invoke___wasm_bindgen_1add006a0ed82fd3___JsValue__wasm_bindgen_1add006a0ed82fd3___JsValue_____(arg0, arg1, arg2, arg3) { 252 + wasm.wasm_bindgen_1add006a0ed82fd3___convert__closures_____invoke___wasm_bindgen_1add006a0ed82fd3___JsValue__wasm_bindgen_1add006a0ed82fd3___JsValue_____(arg0, arg1, arg2, arg3); 253 + } 254 + 255 + const __wbindgen_enum_ReadableStreamType = ["bytes"]; 256 + 257 + const __wbindgen_enum_RequestCache = ["default", "no-store", "reload", "no-cache", "force-cache", "only-if-cached"]; 258 + 259 + const __wbindgen_enum_RequestCredentials = ["omit", "same-origin", "include"]; 260 + 261 + const __wbindgen_enum_RequestMode = ["same-origin", "no-cors", "cors", "navigate"]; 262 + 263 + const IntoUnderlyingByteSourceFinalization = (typeof FinalizationRegistry === 'undefined') 264 + ? { register: () => {}, unregister: () => {} } 265 + : new FinalizationRegistry(ptr => wasm.__wbg_intounderlyingbytesource_free(ptr >>> 0, 1)); 266 + 267 + const IntoUnderlyingSinkFinalization = (typeof FinalizationRegistry === 'undefined') 268 + ? { register: () => {}, unregister: () => {} } 269 + : new FinalizationRegistry(ptr => wasm.__wbg_intounderlyingsink_free(ptr >>> 0, 1)); 270 + 271 + const IntoUnderlyingSourceFinalization = (typeof FinalizationRegistry === 'undefined') 272 + ? { register: () => {}, unregister: () => {} } 273 + : new FinalizationRegistry(ptr => wasm.__wbg_intounderlyingsource_free(ptr >>> 0, 1)); 274 + 275 + const JSOwnerFinalization = (typeof FinalizationRegistry === 'undefined') 276 + ? { register: () => {}, unregister: () => {} } 277 + : new FinalizationRegistry(ptr => wasm.__wbg_jsowner_free(ptr >>> 0, 1)); 278 + 279 + class IntoUnderlyingByteSource { 280 + __destroy_into_raw() { 281 + const ptr = this.__wbg_ptr; 282 + this.__wbg_ptr = 0; 283 + IntoUnderlyingByteSourceFinalization.unregister(this); 284 + return ptr; 285 + } 286 + free() { 287 + const ptr = this.__destroy_into_raw(); 288 + wasm.__wbg_intounderlyingbytesource_free(ptr, 0); 289 + } 290 + /** 291 + * @returns {number} 292 + */ 293 + get autoAllocateChunkSize() { 294 + const ret = wasm.intounderlyingbytesource_autoAllocateChunkSize(this.__wbg_ptr); 295 + return ret >>> 0; 296 + } 297 + /** 298 + * @param {ReadableByteStreamController} controller 299 + * @returns {Promise<any>} 300 + */ 301 + pull(controller) { 302 + const ret = wasm.intounderlyingbytesource_pull(this.__wbg_ptr, controller); 303 + return ret; 304 + } 305 + /** 306 + * @param {ReadableByteStreamController} controller 307 + */ 308 + start(controller) { 309 + wasm.intounderlyingbytesource_start(this.__wbg_ptr, controller); 310 + } 311 + /** 312 + * @returns {ReadableStreamType} 313 + */ 314 + get type() { 315 + const ret = wasm.intounderlyingbytesource_type(this.__wbg_ptr); 316 + return __wbindgen_enum_ReadableStreamType[ret]; 317 + } 318 + cancel() { 319 + const ptr = this.__destroy_into_raw(); 320 + wasm.intounderlyingbytesource_cancel(ptr); 321 + } 322 + } 323 + if (Symbol.dispose) IntoUnderlyingByteSource.prototype[Symbol.dispose] = IntoUnderlyingByteSource.prototype.free; 324 + __exports.IntoUnderlyingByteSource = IntoUnderlyingByteSource; 325 + 326 + class IntoUnderlyingSink { 327 + __destroy_into_raw() { 328 + const ptr = this.__wbg_ptr; 329 + this.__wbg_ptr = 0; 330 + IntoUnderlyingSinkFinalization.unregister(this); 331 + return ptr; 332 + } 333 + free() { 334 + const ptr = this.__destroy_into_raw(); 335 + wasm.__wbg_intounderlyingsink_free(ptr, 0); 336 + } 337 + /** 338 + * @param {any} reason 339 + * @returns {Promise<any>} 340 + */ 341 + abort(reason) { 342 + const ptr = this.__destroy_into_raw(); 343 + const ret = wasm.intounderlyingsink_abort(ptr, reason); 344 + return ret; 345 + } 346 + /** 347 + * @returns {Promise<any>} 348 + */ 349 + close() { 350 + const ptr = this.__destroy_into_raw(); 351 + const ret = wasm.intounderlyingsink_close(ptr); 352 + return ret; 353 + } 354 + /** 355 + * @param {any} chunk 356 + * @returns {Promise<any>} 357 + */ 358 + write(chunk) { 359 + const ret = wasm.intounderlyingsink_write(this.__wbg_ptr, chunk); 360 + return ret; 361 + } 362 + } 363 + if (Symbol.dispose) IntoUnderlyingSink.prototype[Symbol.dispose] = IntoUnderlyingSink.prototype.free; 364 + __exports.IntoUnderlyingSink = IntoUnderlyingSink; 365 + 366 + class IntoUnderlyingSource { 367 + __destroy_into_raw() { 368 + const ptr = this.__wbg_ptr; 369 + this.__wbg_ptr = 0; 370 + IntoUnderlyingSourceFinalization.unregister(this); 371 + return ptr; 372 + } 373 + free() { 374 + const ptr = this.__destroy_into_raw(); 375 + wasm.__wbg_intounderlyingsource_free(ptr, 0); 376 + } 377 + /** 378 + * @param {ReadableStreamDefaultController} controller 379 + * @returns {Promise<any>} 380 + */ 381 + pull(controller) { 382 + const ret = wasm.intounderlyingsource_pull(this.__wbg_ptr, controller); 383 + return ret; 384 + } 385 + cancel() { 386 + const ptr = this.__destroy_into_raw(); 387 + wasm.intounderlyingsource_cancel(ptr); 388 + } 389 + } 390 + if (Symbol.dispose) IntoUnderlyingSource.prototype[Symbol.dispose] = IntoUnderlyingSource.prototype.free; 391 + __exports.IntoUnderlyingSource = IntoUnderlyingSource; 392 + 393 + class JSOwner { 394 + __destroy_into_raw() { 395 + const ptr = this.__wbg_ptr; 396 + this.__wbg_ptr = 0; 397 + JSOwnerFinalization.unregister(this); 398 + return ptr; 399 + } 400 + free() { 401 + const ptr = this.__destroy_into_raw(); 402 + wasm.__wbg_jsowner_free(ptr, 0); 403 + } 404 + } 405 + if (Symbol.dispose) JSOwner.prototype[Symbol.dispose] = JSOwner.prototype.free; 406 + __exports.JSOwner = JSOwner; 407 + 408 + const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']); 409 + 410 + async function __wbg_load(module, imports) { 411 + if (typeof Response === 'function' && module instanceof Response) { 412 + if (typeof WebAssembly.instantiateStreaming === 'function') { 413 + try { 414 + return await WebAssembly.instantiateStreaming(module, imports); 415 + } catch (e) { 416 + const validResponse = module.ok && EXPECTED_RESPONSE_TYPES.has(module.type); 417 + 418 + if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') { 419 + 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); 420 + 421 + } else { 422 + throw e; 423 + } 424 + } 425 + } 426 + 427 + const bytes = await module.arrayBuffer(); 428 + return await WebAssembly.instantiate(bytes, imports); 429 + } else { 430 + const instance = await WebAssembly.instantiate(module, imports); 431 + 432 + if (instance instanceof WebAssembly.Instance) { 433 + return { instance, module }; 434 + } else { 435 + return instance; 436 + } 437 + } 438 + } 439 + 440 + function __wbg_get_imports() { 441 + const imports = {}; 442 + imports.wbg = {}; 443 + imports.wbg.__wbg___wbindgen_debug_string_adfb662ae34724b6 = function(arg0, arg1) { 444 + const ret = debugString(arg1); 445 + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); 446 + const len1 = WASM_VECTOR_LEN; 447 + getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true); 448 + getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true); 449 + }; 450 + imports.wbg.__wbg___wbindgen_is_function_8d400b8b1af978cd = function(arg0) { 451 + const ret = typeof(arg0) === 'function'; 452 + return ret; 453 + }; 454 + imports.wbg.__wbg___wbindgen_is_object_ce774f3490692386 = function(arg0) { 455 + const val = arg0; 456 + const ret = typeof(val) === 'object' && val !== null; 457 + return ret; 458 + }; 459 + imports.wbg.__wbg___wbindgen_is_undefined_f6b95eab589e0269 = function(arg0) { 460 + const ret = arg0 === undefined; 461 + return ret; 462 + }; 463 + imports.wbg.__wbg___wbindgen_string_get_a2a31e16edf96e42 = function(arg0, arg1) { 464 + const obj = arg1; 465 + const ret = typeof(obj) === 'string' ? obj : undefined; 466 + var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); 467 + var len1 = WASM_VECTOR_LEN; 468 + getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true); 469 + getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true); 470 + }; 471 + imports.wbg.__wbg___wbindgen_throw_dd24417ed36fc46e = function(arg0, arg1) { 472 + throw new Error(getStringFromWasm0(arg0, arg1)); 473 + }; 474 + imports.wbg.__wbg__wbg_cb_unref_87dfb5aaa0cbcea7 = function(arg0) { 475 + arg0._wbg_cb_unref(); 476 + }; 477 + imports.wbg.__wbg_abort_07646c894ebbf2bd = function(arg0) { 478 + arg0.abort(); 479 + }; 480 + imports.wbg.__wbg_abort_399ecbcfd6ef3c8e = function(arg0, arg1) { 481 + arg0.abort(arg1); 482 + }; 483 + imports.wbg.__wbg_append_0a085a855907169f = function() { return handleError(function (arg0, arg1, arg2, arg3) { 484 + arg0.append(getStringFromWasm0(arg1, arg2), arg3); 485 + }, arguments) }; 486 + imports.wbg.__wbg_append_90fbf76fbc23e35f = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) { 487 + arg0.append(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4)); 488 + }, arguments) }; 489 + imports.wbg.__wbg_append_c5cbdf46455cc776 = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) { 490 + arg0.append(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4)); 491 + }, arguments) }; 492 + imports.wbg.__wbg_append_ef47c723098c3768 = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5) { 493 + arg0.append(getStringFromWasm0(arg1, arg2), arg3, getStringFromWasm0(arg4, arg5)); 494 + }, arguments) }; 495 + imports.wbg.__wbg_arrayBuffer_c04af4fce566092d = function() { return handleError(function (arg0) { 496 + const ret = arg0.arrayBuffer(); 497 + return ret; 498 + }, arguments) }; 499 + imports.wbg.__wbg_buffer_6cb2fecb1f253d71 = function(arg0) { 500 + const ret = arg0.buffer; 501 + return ret; 502 + }; 503 + imports.wbg.__wbg_byobRequest_f8e3517f5f8ad284 = function(arg0) { 504 + const ret = arg0.byobRequest; 505 + return isLikeNone(ret) ? 0 : addToExternrefTable0(ret); 506 + }; 507 + imports.wbg.__wbg_byteLength_faa9938885bdeee6 = function(arg0) { 508 + const ret = arg0.byteLength; 509 + return ret; 510 + }; 511 + imports.wbg.__wbg_byteOffset_3868b6a19ba01dea = function(arg0) { 512 + const ret = arg0.byteOffset; 513 + return ret; 514 + }; 515 + imports.wbg.__wbg_call_3020136f7a2d6e44 = function() { return handleError(function (arg0, arg1, arg2) { 516 + const ret = arg0.call(arg1, arg2); 517 + return ret; 518 + }, arguments) }; 519 + imports.wbg.__wbg_call_abb4ff46ce38be40 = function() { return handleError(function (arg0, arg1) { 520 + const ret = arg0.call(arg1); 521 + return ret; 522 + }, arguments) }; 523 + imports.wbg.__wbg_clearTimeout_15dfc3d1dcb635c6 = function() { return handleError(function (arg0, arg1) { 524 + arg0.clearTimeout(arg1); 525 + }, arguments) }; 526 + imports.wbg.__wbg_clearTimeout_7a42b49784aea641 = function(arg0) { 527 + const ret = clearTimeout(arg0); 528 + return ret; 529 + }; 530 + imports.wbg.__wbg_close_0af5661bf3d335f2 = function() { return handleError(function (arg0) { 531 + arg0.close(); 532 + }, arguments) }; 533 + imports.wbg.__wbg_close_0b472ca2d13f54f7 = function(arg0) { 534 + arg0.close(); 535 + }; 536 + imports.wbg.__wbg_close_3ec111e7b23d94d8 = function() { return handleError(function (arg0) { 537 + arg0.close(); 538 + }, arguments) }; 539 + imports.wbg.__wbg_data_8bf4ae669a78a688 = function(arg0) { 540 + const ret = arg0.data; 541 + return ret; 542 + }; 543 + imports.wbg.__wbg_done_62ea16af4ce34b24 = function(arg0) { 544 + const ret = arg0.done; 545 + return ret; 546 + }; 547 + imports.wbg.__wbg_enqueue_a7e6b1ee87963aad = function() { return handleError(function (arg0, arg1) { 548 + arg0.enqueue(arg1); 549 + }, arguments) }; 550 + imports.wbg.__wbg_error_7534b8e9a36f1ab4 = function(arg0, arg1) { 551 + let deferred0_0; 552 + let deferred0_1; 553 + try { 554 + deferred0_0 = arg0; 555 + deferred0_1 = arg1; 556 + console.error(getStringFromWasm0(arg0, arg1)); 557 + } finally { 558 + wasm.__wbindgen_free(deferred0_0, deferred0_1, 1); 559 + } 560 + }; 561 + imports.wbg.__wbg_fetch_74a3e84ebd2c9a0e = function(arg0) { 562 + const ret = fetch(arg0); 563 + return ret; 564 + }; 565 + imports.wbg.__wbg_fetch_90447c28cc0b095e = function(arg0, arg1) { 566 + const ret = arg0.fetch(arg1); 567 + return ret; 568 + }; 569 + imports.wbg.__wbg_getTime_ad1e9878a735af08 = function(arg0) { 570 + const ret = arg0.getTime(); 571 + return ret; 572 + }; 573 + imports.wbg.__wbg_get_af9dab7e9603ea93 = function() { return handleError(function (arg0, arg1) { 574 + const ret = Reflect.get(arg0, arg1); 575 + return ret; 576 + }, arguments) }; 577 + imports.wbg.__wbg_has_0e670569d65d3a45 = function() { return handleError(function (arg0, arg1) { 578 + const ret = Reflect.has(arg0, arg1); 579 + return ret; 580 + }, arguments) }; 581 + imports.wbg.__wbg_headers_654c30e1bcccc552 = function(arg0) { 582 + const ret = arg0.headers; 583 + return ret; 584 + }; 585 + imports.wbg.__wbg_instanceof_Response_cd74d1c2ac92cb0b = function(arg0) { 586 + let result; 587 + try { 588 + result = arg0 instanceof Response; 589 + } catch (_) { 590 + result = false; 591 + } 592 + const ret = result; 593 + return ret; 594 + }; 595 + imports.wbg.__wbg_instanceof_Window_b5cf7783caa68180 = function(arg0) { 596 + let result; 597 + try { 598 + result = arg0 instanceof Window; 599 + } catch (_) { 600 + result = false; 601 + } 602 + const ret = result; 603 + return ret; 604 + }; 605 + imports.wbg.__wbg_iterator_27b7c8b35ab3e86b = function() { 606 + const ret = Symbol.iterator; 607 + return ret; 608 + }; 609 + imports.wbg.__wbg_length_22ac23eaec9d8053 = function(arg0) { 610 + const ret = arg0.length; 611 + return ret; 612 + }; 613 + imports.wbg.__wbg_new_0_23cedd11d9b40c9d = function() { 614 + const ret = new Date(); 615 + return ret; 616 + }; 617 + imports.wbg.__wbg_new_1ba21ce319a06297 = function() { 618 + const ret = new Object(); 619 + return ret; 620 + }; 621 + imports.wbg.__wbg_new_25f239778d6112b9 = function() { 622 + const ret = new Array(); 623 + return ret; 624 + }; 625 + imports.wbg.__wbg_new_3c79b3bb1b32b7d3 = function() { return handleError(function () { 626 + const ret = new Headers(); 627 + return ret; 628 + }, arguments) }; 629 + imports.wbg.__wbg_new_6421f6084cc5bc5a = function(arg0) { 630 + const ret = new Uint8Array(arg0); 631 + return ret; 632 + }; 633 + imports.wbg.__wbg_new_881a222c65f168fc = function() { return handleError(function () { 634 + const ret = new AbortController(); 635 + return ret; 636 + }, arguments) }; 637 + imports.wbg.__wbg_new_8a6f238a6ece86ea = function() { 638 + const ret = new Error(); 639 + return ret; 640 + }; 641 + imports.wbg.__wbg_new_df1173567d5ff028 = function(arg0, arg1) { 642 + const ret = new Error(getStringFromWasm0(arg0, arg1)); 643 + return ret; 644 + }; 645 + imports.wbg.__wbg_new_e66247b901edc931 = function() { return handleError(function () { 646 + const ret = new FormData(); 647 + return ret; 648 + }, arguments) }; 649 + imports.wbg.__wbg_new_ff12d2b041fb48f1 = function(arg0, arg1) { 650 + try { 651 + var state0 = {a: arg0, b: arg1}; 652 + var cb0 = (arg0, arg1) => { 653 + const a = state0.a; 654 + state0.a = 0; 655 + try { 656 + return wasm_bindgen_1add006a0ed82fd3___convert__closures_____invoke___wasm_bindgen_1add006a0ed82fd3___JsValue__wasm_bindgen_1add006a0ed82fd3___JsValue_____(a, state0.b, arg0, arg1); 657 + } finally { 658 + state0.a = a; 659 + } 660 + }; 661 + const ret = new Promise(cb0); 662 + return ret; 663 + } finally { 664 + state0.a = state0.b = 0; 665 + } 666 + }; 667 + imports.wbg.__wbg_new_from_slice_f9c22b9153b26992 = function(arg0, arg1) { 668 + const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1)); 669 + return ret; 670 + }; 671 + imports.wbg.__wbg_new_no_args_cb138f77cf6151ee = function(arg0, arg1) { 672 + const ret = new Function(getStringFromWasm0(arg0, arg1)); 673 + return ret; 674 + }; 675 + imports.wbg.__wbg_new_with_byte_offset_and_length_d85c3da1fd8df149 = function(arg0, arg1, arg2) { 676 + const ret = new Uint8Array(arg0, arg1 >>> 0, arg2 >>> 0); 677 + return ret; 678 + }; 679 + imports.wbg.__wbg_new_with_str_and_init_c5748f76f5108934 = function() { return handleError(function (arg0, arg1, arg2) { 680 + const ret = new Request(getStringFromWasm0(arg0, arg1), arg2); 681 + return ret; 682 + }, arguments) }; 683 + imports.wbg.__wbg_new_with_u8_array_sequence_and_options_d4def9ec0588c7ec = function() { return handleError(function (arg0, arg1) { 684 + const ret = new Blob(arg0, arg1); 685 + return ret; 686 + }, arguments) }; 687 + imports.wbg.__wbg_next_138a17bbf04e926c = function(arg0) { 688 + const ret = arg0.next; 689 + return ret; 690 + }; 691 + imports.wbg.__wbg_next_3cfe5c0fe2a4cc53 = function() { return handleError(function (arg0) { 692 + const ret = arg0.next(); 693 + return ret; 694 + }, arguments) }; 695 + imports.wbg.__wbg_now_2c95c9de01293173 = function(arg0) { 696 + const ret = arg0.now(); 697 + return ret; 698 + }; 699 + imports.wbg.__wbg_now_8cf15d6e317793e1 = function(arg0) { 700 + const ret = arg0.now(); 701 + return ret; 702 + }; 703 + imports.wbg.__wbg_performance_7a3ffd0b17f663ad = function(arg0) { 704 + const ret = arg0.performance; 705 + return ret; 706 + }; 707 + imports.wbg.__wbg_performance_c77a440eff2efd9b = function(arg0) { 708 + const ret = arg0.performance; 709 + return isLikeNone(ret) ? 0 : addToExternrefTable0(ret); 710 + }; 711 + imports.wbg.__wbg_postMessage_7243f814e0cfb266 = function() { return handleError(function (arg0, arg1) { 712 + arg0.postMessage(arg1); 713 + }, arguments) }; 714 + imports.wbg.__wbg_prototypesetcall_dfe9b766cdc1f1fd = function(arg0, arg1, arg2) { 715 + Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2); 716 + }; 717 + imports.wbg.__wbg_push_7d9be8f38fc13975 = function(arg0, arg1) { 718 + const ret = arg0.push(arg1); 719 + return ret; 720 + }; 721 + imports.wbg.__wbg_queueMicrotask_9b549dfce8865860 = function(arg0) { 722 + const ret = arg0.queueMicrotask; 723 + return ret; 724 + }; 725 + imports.wbg.__wbg_queueMicrotask_fca69f5bfad613a5 = function(arg0) { 726 + queueMicrotask(arg0); 727 + }; 728 + imports.wbg.__wbg_resolve_fd5bfbaa4ce36e1e = function(arg0) { 729 + const ret = Promise.resolve(arg0); 730 + return ret; 731 + }; 732 + imports.wbg.__wbg_respond_9f7fc54636c4a3af = function() { return handleError(function (arg0, arg1) { 733 + arg0.respond(arg1 >>> 0); 734 + }, arguments) }; 735 + imports.wbg.__wbg_setTimeout_4eb823e8b72fbe79 = function() { return handleError(function (arg0, arg1, arg2) { 736 + const ret = arg0.setTimeout(arg1, arg2); 737 + return ret; 738 + }, arguments) }; 739 + imports.wbg.__wbg_setTimeout_7bb3429662ab1e70 = function(arg0, arg1) { 740 + const ret = setTimeout(arg0, arg1); 741 + return ret; 742 + }; 743 + imports.wbg.__wbg_set_169e13b608078b7b = function(arg0, arg1, arg2) { 744 + arg0.set(getArrayU8FromWasm0(arg1, arg2)); 745 + }; 746 + imports.wbg.__wbg_set_body_8e743242d6076a4f = function(arg0, arg1) { 747 + arg0.body = arg1; 748 + }; 749 + imports.wbg.__wbg_set_cache_0e437c7c8e838b9b = function(arg0, arg1) { 750 + arg0.cache = __wbindgen_enum_RequestCache[arg1]; 751 + }; 752 + imports.wbg.__wbg_set_credentials_55ae7c3c106fd5be = function(arg0, arg1) { 753 + arg0.credentials = __wbindgen_enum_RequestCredentials[arg1]; 754 + }; 755 + imports.wbg.__wbg_set_headers_5671cf088e114d2b = function(arg0, arg1) { 756 + arg0.headers = arg1; 757 + }; 758 + imports.wbg.__wbg_set_method_76c69e41b3570627 = function(arg0, arg1, arg2) { 759 + arg0.method = getStringFromWasm0(arg1, arg2); 760 + }; 761 + imports.wbg.__wbg_set_mode_611016a6818fc690 = function(arg0, arg1) { 762 + arg0.mode = __wbindgen_enum_RequestMode[arg1]; 763 + }; 764 + imports.wbg.__wbg_set_onmessage_5fe29d0fb54cb575 = function(arg0, arg1) { 765 + arg0.onmessage = arg1; 766 + }; 767 + imports.wbg.__wbg_set_signal_e89be862d0091009 = function(arg0, arg1) { 768 + arg0.signal = arg1; 769 + }; 770 + imports.wbg.__wbg_set_type_7ce650670a34c68f = function(arg0, arg1, arg2) { 771 + arg0.type = getStringFromWasm0(arg1, arg2); 772 + }; 773 + imports.wbg.__wbg_signal_3c14fbdc89694b39 = function(arg0) { 774 + const ret = arg0.signal; 775 + return ret; 776 + }; 777 + imports.wbg.__wbg_stack_0ed75d68575b0f3c = function(arg0, arg1) { 778 + const ret = arg1.stack; 779 + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); 780 + const len1 = WASM_VECTOR_LEN; 781 + getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true); 782 + getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true); 783 + }; 784 + imports.wbg.__wbg_static_accessor_GLOBAL_769e6b65d6557335 = function() { 785 + const ret = typeof global === 'undefined' ? null : global; 786 + return isLikeNone(ret) ? 0 : addToExternrefTable0(ret); 787 + }; 788 + imports.wbg.__wbg_static_accessor_GLOBAL_THIS_60cf02db4de8e1c1 = function() { 789 + const ret = typeof globalThis === 'undefined' ? null : globalThis; 790 + return isLikeNone(ret) ? 0 : addToExternrefTable0(ret); 791 + }; 792 + imports.wbg.__wbg_static_accessor_SELF_08f5a74c69739274 = function() { 793 + const ret = typeof self === 'undefined' ? null : self; 794 + return isLikeNone(ret) ? 0 : addToExternrefTable0(ret); 795 + }; 796 + imports.wbg.__wbg_static_accessor_WINDOW_a8924b26aa92d024 = function() { 797 + const ret = typeof window === 'undefined' ? null : window; 798 + return isLikeNone(ret) ? 0 : addToExternrefTable0(ret); 799 + }; 800 + imports.wbg.__wbg_status_9bfc680efca4bdfd = function(arg0) { 801 + const ret = arg0.status; 802 + return ret; 803 + }; 804 + imports.wbg.__wbg_stringify_655a6390e1f5eb6b = function() { return handleError(function (arg0) { 805 + const ret = JSON.stringify(arg0); 806 + return ret; 807 + }, arguments) }; 808 + imports.wbg.__wbg_text_51046bb33d257f63 = function() { return handleError(function (arg0) { 809 + const ret = arg0.text(); 810 + return ret; 811 + }, arguments) }; 812 + imports.wbg.__wbg_then_429f7caf1026411d = function(arg0, arg1, arg2) { 813 + const ret = arg0.then(arg1, arg2); 814 + return ret; 815 + }; 816 + imports.wbg.__wbg_then_4f95312d68691235 = function(arg0, arg1) { 817 + const ret = arg0.then(arg1); 818 + return ret; 819 + }; 820 + imports.wbg.__wbg_url_b6d11838a4f95198 = function(arg0, arg1) { 821 + const ret = arg1.url; 822 + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); 823 + const len1 = WASM_VECTOR_LEN; 824 + getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true); 825 + getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true); 826 + }; 827 + imports.wbg.__wbg_value_57b7b035e117f7ee = function(arg0) { 828 + const ret = arg0.value; 829 + return ret; 830 + }; 831 + imports.wbg.__wbg_view_788aaf149deefd2f = function(arg0) { 832 + const ret = arg0.view; 833 + return isLikeNone(ret) ? 0 : addToExternrefTable0(ret); 834 + }; 835 + imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) { 836 + // Cast intrinsic for `Ref(String) -> Externref`. 837 + const ret = getStringFromWasm0(arg0, arg1); 838 + return ret; 839 + }; 840 + imports.wbg.__wbindgen_cast_600f2adf1b415b72 = function(arg0, arg1) { 841 + // Cast intrinsic for `Closure(Closure { dtor_idx: 364, function: Function { arguments: [NamedExternref("MessageEvent")], shim_idx: 365, ret: Unit, inner_ret: Some(Unit) }, mutable: false }) -> Externref`. 842 + const ret = makeClosure(arg0, arg1, wasm.wasm_bindgen_1add006a0ed82fd3___closure__destroy___dyn_core_b125d98f3949a913___ops__function__Fn__web_sys_81daa69175395078___features__gen_MessageEvent__MessageEvent____Output_______, wasm_bindgen_1add006a0ed82fd3___convert__closures_____invoke___web_sys_81daa69175395078___features__gen_MessageEvent__MessageEvent_____); 843 + return ret; 844 + }; 845 + imports.wbg.__wbindgen_cast_89cd6f7b6be057aa = function(arg0, arg1) { 846 + // Cast intrinsic for `Closure(Closure { dtor_idx: 2024, function: Function { arguments: [], shim_idx: 2025, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`. 847 + const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen_1add006a0ed82fd3___closure__destroy___dyn_core_b125d98f3949a913___ops__function__FnMut_____Output________1_, wasm_bindgen_1add006a0ed82fd3___convert__closures_____invoke_______1_); 848 + return ret; 849 + }; 850 + imports.wbg.__wbindgen_cast_9216bf6c1753368f = function(arg0, arg1) { 851 + // Cast intrinsic for `Closure(Closure { dtor_idx: 1144, function: Function { arguments: [], shim_idx: 1145, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`. 852 + const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen_1add006a0ed82fd3___closure__destroy___dyn_core_b125d98f3949a913___ops__function__FnMut_____Output_______, wasm_bindgen_1add006a0ed82fd3___convert__closures_____invoke______); 853 + return ret; 854 + }; 855 + imports.wbg.__wbindgen_cast_eee509cff0277222 = function(arg0, arg1) { 856 + // Cast intrinsic for `Closure(Closure { dtor_idx: 2221, function: Function { arguments: [Externref], shim_idx: 2222, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`. 857 + const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen_1add006a0ed82fd3___closure__destroy___dyn_core_b125d98f3949a913___ops__function__FnMut__wasm_bindgen_1add006a0ed82fd3___JsValue____Output_______, wasm_bindgen_1add006a0ed82fd3___convert__closures_____invoke___wasm_bindgen_1add006a0ed82fd3___JsValue_____); 858 + return ret; 859 + }; 860 + imports.wbg.__wbindgen_init_externref_table = function() { 861 + const table = wasm.__wbindgen_externrefs; 862 + const offset = table.grow(4); 863 + table.set(0, undefined); 864 + table.set(offset + 0, undefined); 865 + table.set(offset + 1, null); 866 + table.set(offset + 2, true); 867 + table.set(offset + 3, false); 868 + }; 869 + 870 + return imports; 871 + } 872 + 873 + function __wbg_finalize_init(instance, module) { 874 + wasm = instance.exports; 875 + __wbg_init.__wbindgen_wasm_module = module; 876 + cachedDataViewMemory0 = null; 877 + cachedUint8ArrayMemory0 = null; 878 + 879 + 880 + wasm.__wbindgen_start(); 881 + return wasm; 882 + } 883 + 884 + function initSync(module) { 885 + if (wasm !== undefined) return wasm; 886 + 887 + 888 + if (typeof module !== 'undefined') { 889 + if (Object.getPrototypeOf(module) === Object.prototype) { 890 + ({module} = module) 891 + } else { 892 + console.warn('using deprecated parameters for `initSync()`; pass a single object instead') 893 + } 894 + } 895 + 896 + const imports = __wbg_get_imports(); 897 + if (!(module instanceof WebAssembly.Module)) { 898 + module = new WebAssembly.Module(module); 899 + } 900 + const instance = new WebAssembly.Instance(module, imports); 901 + return __wbg_finalize_init(instance, module); 902 + } 903 + 904 + async function __wbg_init(module_or_path) { 905 + if (wasm !== undefined) return wasm; 906 + 907 + 908 + if (typeof module_or_path !== 'undefined') { 909 + if (Object.getPrototypeOf(module_or_path) === Object.prototype) { 910 + ({module_or_path} = module_or_path) 911 + } else { 912 + console.warn('using deprecated parameters for the initialization function; pass a single object instead') 913 + } 914 + } 915 + 916 + if (typeof module_or_path === 'undefined' && typeof script_src !== 'undefined') { 917 + module_or_path = script_src.replace(/\.js$/, '_bg.wasm'); 918 + } 919 + const imports = __wbg_get_imports(); 920 + 921 + if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) { 922 + module_or_path = fetch(module_or_path); 923 + } 924 + 925 + const { instance, module } = await __wbg_load(await module_or_path, imports); 926 + 927 + return __wbg_finalize_init(instance, module); 928 + } 929 + 930 + wasm_bindgen = Object.assign(__wbg_init, { initSync }, __exports); 931 + })();
+9
crates/weaver-app/public/snippets/dioxus-cli-config-c2775606adf80e62/inline0.js
··· 1 + 2 + export function getMetaContents(meta_name) { 3 + const selector = document.querySelector(`meta[name="${meta_name}"]`); 4 + if (!selector) { 5 + return null; 6 + } 7 + return selector.content; 8 + } 9 +
+222
crates/weaver-app/public/snippets/dioxus-interpreter-js-ce7056f341163470/inline0.js
··· 1 + 2 + function setAttributeInner(node,field,value,ns){if(ns==="style"){node.style.setProperty(field,value);return}if(ns){node.setAttributeNS(ns,field,value);return}switch(field){case"value":if(node.tagName==="OPTION")setAttributeDefault(node,field,value);else if(node.value!==value)node.value=value;break;case"initial_value":node.defaultValue=value;break;case"checked":node.checked=truthy(value);break;case"initial_checked":node.defaultChecked=truthy(value);break;case"selected":node.selected=truthy(value);break;case"initial_selected":node.defaultSelected=truthy(value);break;case"dangerous_inner_html":node.innerHTML=value;break;case"style":let existingStyles={};for(let i=0;i<node.style.length;i++){let prop=node.style[i];existingStyles[prop]=node.style.getPropertyValue(prop)}node.setAttribute(field,value);for(let prop in existingStyles)if(!node.style.getPropertyValue(prop))node.style.setProperty(prop,existingStyles[prop]);break;case"multiple":if(setAttributeDefault(node,field,value),node.options!==null&&node.options!==void 0){let options=node.options;for(let option of options)option.selected=option.defaultSelected}break;default:setAttributeDefault(node,field,value)}}function setAttributeDefault(node,field,value){if(!truthy(value)&&isBoolAttr(field))node.removeAttribute(field);else node.setAttribute(field,value)}function truthy(val){return val==="true"||val===!0}function isBoolAttr(field){switch(field){case"allowfullscreen":case"allowpaymentrequest":case"async":case"autofocus":case"autoplay":case"checked":case"controls":case"default":case"defer":case"disabled":case"formnovalidate":case"hidden":case"ismap":case"itemscope":case"loop":case"multiple":case"muted":case"nomodule":case"novalidate":case"open":case"playsinline":case"readonly":case"required":case"reversed":case"selected":case"truespeed":case"webkitdirectory":return!0;default:return!1}}class BaseInterpreter{global;local;root;handler;resizeObserver;intersectionObserver;nodes;stack;templates;m;constructor(){}initialize(root,handler=null){this.global={},this.local={},this.root=root,this.nodes=[root],this.stack=[root],this.templates={},this.handler=handler,root.setAttribute("data-dioxus-id","0")}handleResizeEvent(entry){let target=entry.target,event=new CustomEvent("resize",{bubbles:!1,detail:entry});target.dispatchEvent(event)}createResizeObserver(element){if(!this.resizeObserver)this.resizeObserver=new ResizeObserver((entries)=>{for(let entry of entries)this.handleResizeEvent(entry)});this.resizeObserver.observe(element)}removeResizeObserver(element){if(this.resizeObserver)this.resizeObserver.unobserve(element)}handleIntersectionEvent(entry){let target=entry.target,event=new CustomEvent("visible",{bubbles:!1,detail:entry});target.dispatchEvent(event)}createIntersectionObserver(element){if(!this.intersectionObserver)this.intersectionObserver=new IntersectionObserver((entries)=>{for(let entry of entries)this.handleIntersectionEvent(entry)});this.intersectionObserver.observe(element)}removeIntersectionObserver(element){if(this.intersectionObserver)this.intersectionObserver.unobserve(element)}createListener(event_name,element,bubbles){if(event_name=="resize")this.createResizeObserver(element);else if(event_name=="visible")this.createIntersectionObserver(element);if(bubbles)if(this.global[event_name]===void 0)this.global[event_name]={active:1,callback:this.handler},this.root.addEventListener(event_name,this.handler);else this.global[event_name].active++;else{let id=element.getAttribute("data-dioxus-id");if(!this.local[id])this.local[id]={};element.addEventListener(event_name,this.handler)}}removeListener(element,event_name,bubbles){if(event_name=="resize")this.removeResizeObserver(element);else if(event_name=="visible")this.removeIntersectionObserver(element);else if(bubbles)this.removeBubblingListener(event_name);else this.removeNonBubblingListener(element,event_name)}removeBubblingListener(event_name){if(this.global[event_name].active--,this.global[event_name].active===0)this.root.removeEventListener(event_name,this.global[event_name].callback),delete this.global[event_name]}removeNonBubblingListener(element,event_name){let id=element.getAttribute("data-dioxus-id");if(delete this.local[id][event_name],Object.keys(this.local[id]).length===0)delete this.local[id];element.removeEventListener(event_name,this.handler)}removeAllNonBubblingListeners(element){let id=element.getAttribute("data-dioxus-id");delete this.local[id]}getNode(id){return this.nodes[id]}pushRoot(node){this.stack.push(node)}appendChildren(id,many){let root=this.nodes[id],els=this.stack.splice(this.stack.length-many);for(let k=0;k<many;k++)root.appendChild(els[k])}loadChild(ptr,len){let node=this.stack[this.stack.length-1],ptr_end=ptr+len;for(;ptr<ptr_end;ptr++){let end=this.m.getUint8(ptr);for(node=node.firstChild;end>0;end--)node=node.nextSibling}return node}saveTemplate(nodes,tmpl_id){this.templates[tmpl_id]=nodes}hydrate_node(hydrateNode,ids){let split=hydrateNode.getAttribute("data-node-hydration").split(","),id=ids[parseInt(split[0])];if(this.nodes[id]=hydrateNode,split.length>1){hydrateNode.listening=split.length-1,hydrateNode.setAttribute("data-dioxus-id",id.toString());for(let j=1;j<split.length;j++){let split2=split[j].split(":"),event_name=split2[0],bubbles=split2[1]==="1";this.createListener(event_name,hydrateNode,bubbles)}}}hydrate(ids,underNodes){for(let i=0;i<underNodes.length;i++){let under=underNodes[i];if(under instanceof HTMLElement){if(under.getAttribute("data-node-hydration"))this.hydrate_node(under,ids);let hydrateNodes=under.querySelectorAll("[data-node-hydration]");for(let i2=0;i2<hydrateNodes.length;i2++)this.hydrate_node(hydrateNodes[i2],ids)}let treeWalker=document.createTreeWalker(under,NodeFilter.SHOW_COMMENT),nextSibling=under.nextSibling,continueToNextNode=()=>{if(!treeWalker.nextNode())return!1;return treeWalker.currentNode!==nextSibling};while(treeWalker.currentNode){let currentNode=treeWalker.currentNode;if(currentNode.nodeType===Node.COMMENT_NODE){let id=currentNode.textContent,placeholderSplit=id.split("placeholder");if(placeholderSplit.length>1){if(this.nodes[ids[parseInt(placeholderSplit[1])]]=currentNode,!continueToNextNode())break;continue}let textNodeSplit=id.split("node-id");if(textNodeSplit.length>1){let next=currentNode.nextSibling;currentNode.remove();let commentAfterText,textNode;if(next.nodeType===Node.COMMENT_NODE){let newText=next.parentElement.insertBefore(document.createTextNode(""),next);commentAfterText=next,textNode=newText}else textNode=next,commentAfterText=textNode.nextSibling;treeWalker.currentNode=commentAfterText,this.nodes[ids[parseInt(textNodeSplit[1])]]=textNode;let exit=currentNode===under||!continueToNextNode();if(commentAfterText.remove(),exit)break;continue}}if(!continueToNextNode())break}}}setAttributeInner(node,field,value,ns){setAttributeInner(node,field,value,ns)}}export{BaseInterpreter}; 3 + 4 + let bubbles,field,id,many,ns; 5 + export class RawInterpreter extends BaseInterpreter { 6 + constructor(r) { 7 + super(); 8 + this.d=r; 9 + this.m = null; 10 + this.p = null; 11 + this.ls = null; 12 + this.t = null; 13 + this.op = null; 14 + this.e = null; 15 + this.z = null; 16 + this.metaflags = null; 17 + this.u16buf=null;this.u16bufp=null;this.u32buf=null;this.u32bufp=null;this.u8buf=null;this.u8bufp=null;this.attr = []; 18 + this.attr_cache_hit = null; 19 + this.attr_cache_idx; 20 + this.get_attr = function() { 21 + this.attr_cache_idx = this.u8buf[this.u8bufp++]; 22 + if(this.attr_cache_idx & 128){ 23 + this.attr_cache_hit=this.s.substring(this.sp,this.sp+=this.u8buf[this.u8bufp++]); 24 + this.attr[this.attr_cache_idx&4294967167]=this.attr_cache_hit; 25 + return this.attr_cache_hit; 26 + } 27 + else{ 28 + return this.attr[this.attr_cache_idx&4294967167]; 29 + } 30 + };this.el = []; 31 + this.el_cache_hit = null; 32 + this.el_cache_idx; 33 + this.get_el = function() { 34 + this.el_cache_idx = this.u8buf[this.u8bufp++]; 35 + if(this.el_cache_idx & 128){ 36 + this.el_cache_hit=this.s.substring(this.sp,this.sp+=this.u8buf[this.u8bufp++]); 37 + this.el[this.el_cache_idx&4294967167]=this.el_cache_hit; 38 + return this.el_cache_hit; 39 + } 40 + else{ 41 + return this.el[this.el_cache_idx&4294967167]; 42 + } 43 + };this.evt = []; 44 + this.evt_cache_hit = null; 45 + this.evt_cache_idx; 46 + this.get_evt = function() { 47 + this.evt_cache_idx = this.u8buf[this.u8bufp++]; 48 + if(this.evt_cache_idx & 128){ 49 + this.evt_cache_hit=this.s.substring(this.sp,this.sp+=this.u8buf[this.u8bufp++]); 50 + this.evt[this.evt_cache_idx&4294967167]=this.evt_cache_hit; 51 + return this.evt_cache_hit; 52 + } 53 + else{ 54 + return this.evt[this.evt_cache_idx&4294967167]; 55 + } 56 + };this.namespace = []; 57 + this.namespace_cache_hit = null; 58 + this.namespace_cache_idx; 59 + this.get_namespace = function() { 60 + this.namespace_cache_idx = this.u8buf[this.u8bufp++]; 61 + if(this.namespace_cache_idx & 128){ 62 + this.namespace_cache_hit=this.s.substring(this.sp,this.sp+=this.u8buf[this.u8bufp++]); 63 + this.namespace[this.namespace_cache_idx&4294967167]=this.namespace_cache_hit; 64 + return this.namespace_cache_hit; 65 + } 66 + else{ 67 + return this.namespace[this.namespace_cache_idx&4294967167]; 68 + } 69 + };this.ns_cache = []; 70 + this.ns_cache_cache_hit = null; 71 + this.ns_cache_cache_idx; 72 + this.get_ns_cache = function() { 73 + this.ns_cache_cache_idx = this.u8buf[this.u8bufp++]; 74 + if(this.ns_cache_cache_idx & 128){ 75 + this.ns_cache_cache_hit=this.s.substring(this.sp,this.sp+=this.u8buf[this.u8bufp++]); 76 + this.ns_cache[this.ns_cache_cache_idx&4294967167]=this.ns_cache_cache_hit; 77 + return this.ns_cache_cache_hit; 78 + } 79 + else{ 80 + return this.ns_cache[this.ns_cache_cache_idx&4294967167]; 81 + } 82 + };this.s = "";this.lsp = null;this.sp = null;this.sl = null;this.c = new TextDecoder(); 83 + } 84 + 85 + update_memory(b){ 86 + this.m=new DataView(b.buffer) 87 + } 88 + 89 + run(){ 90 + this.metaflags=this.m.getUint32(this.d,true); 91 + if((this.metaflags>>>6)&1){ 92 + this.ls=this.m.getUint32(this.d+6*4,true); 93 + } 94 + this.p=this.ls; 95 + if ((this.metaflags>>>4)&1){ 96 + this.t = this.m.getUint32(this.d+4*4,true); 97 + this.u16buf=new Uint16Array(this.m.buffer,this.t,((this.m.buffer.byteLength-this.t)-(this.m.buffer.byteLength-this.t)%2)/2); 98 + } 99 + this.u16bufp=0;if ((this.metaflags>>>3)&1){ 100 + this.t = this.m.getUint32(this.d+3*4,true); 101 + this.u32buf=new Uint32Array(this.m.buffer,this.t,((this.m.buffer.byteLength-this.t)-(this.m.buffer.byteLength-this.t)%4)/4); 102 + } 103 + this.u32bufp=0;if ((this.metaflags>>>5)&1){ 104 + this.t = this.m.getUint32(this.d+5*4,true); 105 + this.u8buf=new Uint8Array(this.m.buffer,this.t,((this.m.buffer.byteLength-this.t)-(this.m.buffer.byteLength-this.t)%1)/1); 106 + } 107 + this.u8bufp=0;if (this.metaflags&1){ 108 + this.lsp = this.m.getUint32(this.d+1*4,true); 109 + } 110 + if ((this.metaflags>>>2)&1) { 111 + this.sl = this.m.getUint32(this.d+2*4,true); 112 + if ((this.metaflags>>>1)&1) { 113 + this.sp = this.lsp; 114 + this.s = ""; 115 + this.e = this.sp + ((this.sl / 4) | 0) * 4; 116 + while (this.sp < this.e) { 117 + this.t = this.m.getUint32(this.sp, true); 118 + this.s += String.fromCharCode( 119 + this.t & 255, 120 + (this.t & 65280) >> 8, 121 + (this.t & 16711680) >> 16, 122 + this.t >> 24 123 + ); 124 + this.sp += 4; 125 + } 126 + while (this.sp < this.lsp + this.sl) { 127 + this.s += String.fromCharCode(this.m.getUint8(this.sp++)); 128 + } 129 + } else { 130 + let buffer = new Uint8Array(this.m.buffer, this.lsp, this.sl); 131 + // If the wasm buffer is a shared array buffer, we need to copy the data out before decoding https://github.com/DioxusLabs/dioxus/issues/2589 132 + // Note: We intentionally don't use instanceof here because SharedArrayBuffer can be created even when SharedArrayBuffer is not defined... 133 + if (this.m.buffer.constructor.name === "SharedArrayBuffer") { 134 + let arrayBuffer = new ArrayBuffer(this.sl); 135 + new Uint8Array(arrayBuffer).set(buffer); 136 + buffer = arrayBuffer; 137 + } 138 + this.s = this.c.decode(buffer); 139 + } 140 + } 141 + this.sp=0; 142 + for(;;){ 143 + this.op=this.m.getUint32(this.p,true); 144 + this.p+=4; 145 + this.z=0; 146 + while(this.z++<4){ 147 + switch(this.op&255){ 148 + case 0:{this.pushRoot(this.nodes[this.u32buf[this.u32bufp++]]);}break;case 1:{this.appendChildren(this.u32buf[this.u32bufp++], this.u16buf[this.u16bufp++]);}break;case 2:{this.stack.pop();}break;case 3:{const root = this.nodes[this.u32buf[this.u32bufp++]]; let els = this.stack.splice(this.stack.length-this.u16buf[this.u16bufp++]); if (root.listening) { this.removeAllNonBubblingListeners(root); } root.replaceWith(...els);}break;case 4:{let node = this.nodes[this.u32buf[this.u32bufp++]];node.after(...this.stack.splice(this.stack.length-this.u16buf[this.u16bufp++]));}break;case 5:{let node = this.nodes[this.u32buf[this.u32bufp++]];node.before(...this.stack.splice(this.stack.length-this.u16buf[this.u16bufp++]));}break;case 6:{let node = this.nodes[this.u32buf[this.u32bufp++]]; if (node !== undefined) { if (node.listening) { this.removeAllNonBubblingListeners(node); } node.remove(); }}break;case 7:{this.stack.push(document.createTextNode(this.s.substring(this.sp,this.sp+=this.u32buf[this.u32bufp++])));}break;case 8:{let node = document.createTextNode(this.s.substring(this.sp,this.sp+=this.u32buf[this.u32bufp++])); this.nodes[this.u32buf[this.u32bufp++]] = node; this.stack.push(node);}break;case 9:{let node = document.createComment('placeholder'); this.stack.push(node); this.nodes[this.u32buf[this.u32bufp++]] = node;}break;case 10:id=this.u32buf[this.u32bufp++]; 149 + const node = this.nodes[id]; 150 + if(node.listening){node.listening += 1;}else{node.listening = 1;} 151 + node.setAttribute('data-dioxus-id', `${id}`); 152 + this.createListener(this.get_evt(), node, this.u8buf[this.u8bufp++]); 153 + break;case 11:{let node = this.nodes[this.u32buf[this.u32bufp++]]; node.listening -= 1; node.removeAttribute('data-dioxus-id'); this.removeListener(node, this.get_evt(), this.u8buf[this.u8bufp++]);}break;case 12:{this.nodes[this.u32buf[this.u32bufp++]].textContent = this.s.substring(this.sp,this.sp+=this.u32buf[this.u32bufp++]);}break;case 13:{let node = this.nodes[this.u32buf[this.u32bufp++]]; this.setAttributeInner(node, this.get_attr(), this.s.substring(this.sp,this.sp+=this.u32buf[this.u32bufp++]), this.get_ns_cache());}break;case 14:field=this.get_attr();ns=this.get_ns_cache();{ 154 + let node = this.nodes[this.u32buf[this.u32bufp++]]; 155 + if (!ns) { 156 + switch (field) { 157 + case "value": 158 + node.value = ""; 159 + node.removeAttribute("value"); 160 + break; 161 + case "checked": 162 + node.checked = false; 163 + break; 164 + case "selected": 165 + node.selected = false; 166 + break; 167 + case "dangerous_inner_html": 168 + node.innerHTML = ""; 169 + break; 170 + default: 171 + node.removeAttribute(field); 172 + break; 173 + } 174 + } else if (ns == "style") { 175 + node.style.removeProperty(field); 176 + } else { 177 + node.removeAttributeNS(ns, field); 178 + } 179 + }break;case 15:{this.nodes[this.u32buf[this.u32bufp++]] = this.loadChild(this.u32buf[this.u32bufp++], this.u8buf[this.u8bufp++]);}break;case 16:{let els = this.stack.splice(this.stack.length - this.u16buf[this.u16bufp++]); let node = this.loadChild(this.u32buf[this.u32bufp++], this.u8buf[this.u8bufp++]); node.replaceWith(...els);}break;case 17:{let node = this.templates[this.u16buf[this.u16bufp++]][this.u16buf[this.u16bufp++]].cloneNode(true); this.nodes[this.u32buf[this.u32bufp++]] = node; this.stack.push(node);}break;case 18:many=this.u16buf[this.u16bufp++];{ 180 + let root = this.stack[this.stack.length-many-1]; 181 + let els = this.stack.splice(this.stack.length-many); 182 + for (let k = 0; k < many; k++) { 183 + root.appendChild(els[k]); 184 + } 185 + }break;case 19:{this.setAttributeInner(this.stack[this.stack.length-1], this.get_attr(), this.s.substring(this.sp,this.sp+=this.u32buf[this.u32bufp++]), this.get_ns_cache());}break;case 20:{let node = document.createComment('placeholder'); this.stack.push(node);}break;case 21:{this.stack.push(document.createElement(this.get_el()))}break;case 22:{this.stack.push(document.createElementNS(this.get_namespace(), this.get_el()))}break;case 23:{this.templates[this.u16buf[this.u16bufp++]] = this.stack.splice(this.stack.length-this.u16buf[this.u16bufp++]);}break;case 24:id=this.u32buf[this.u32bufp++];bubbles=this.u8buf[this.u8bufp++]; 186 + bubbles = bubbles == 1; 187 + let this_node = this.nodes[id]; 188 + if(this_node.listening){ 189 + this_node.listening += 1; 190 + } else { 191 + this_node.listening = 1; 192 + } 193 + this_node.setAttribute('data-dioxus-id', `${id}`); 194 + const event_name = this.get_evt(); 195 + 196 + // if this is a mounted listener, we send the event immediately 197 + if (event_name === "mounted") { 198 + window.ipc.postMessage( 199 + this.sendSerializedEvent({ 200 + name: event_name, 201 + element: id, 202 + data: null, 203 + bubbles, 204 + }) 205 + ); 206 + } else { 207 + this.createListener(event_name, this_node, bubbles, (event) => { 208 + this.handler(event, event_name, bubbles); 209 + }); 210 + }break;case 25:{this.nodes[this.u32buf[this.u32bufp++]] = this.loadChild((()=>{this.e=this.u8bufp+this.u32buf[this.u32bufp++];const final_array = this.u8buf.slice(this.u8bufp,this.e);this.u8bufp=this.e;return final_array;})());}break;case 26:{let els = this.stack.splice(this.stack.length - this.u16buf[this.u16bufp++]); let node = this.loadChild((()=>{this.e=this.u8bufp+this.u32buf[this.u32bufp++];const final_array = this.u8buf.slice(this.u8bufp,this.e);this.u8bufp=this.e;return final_array;})()); node.replaceWith(...els);}break;case 27:return true; 211 + } 212 + this.op>>>=8; 213 + } 214 + } 215 + } 216 + 217 + run_from_bytes(bytes){ 218 + this.d = 0; 219 + this.update_memory(new Uint8Array(bytes)) 220 + this.run() 221 + } 222 + }
+1
crates/weaver-app/public/snippets/dioxus-interpreter-js-ce7056f341163470/src/js/hydrate.js
··· 1 + function register_rehydrate_chunk_for_streaming(callback){return register_rehydrate_chunk_for_streaming_debug(callback)}function register_rehydrate_chunk_for_streaming_debug(callback){window.hydration_callback=callback;for(let i=0;i<window.hydrate_queue.length;i++){let[id,data,debug_types,debug_locations]=window.hydrate_queue[i];window.hydration_callback(id,data,debug_types,debug_locations)}}export{register_rehydrate_chunk_for_streaming_debug,register_rehydrate_chunk_for_streaming};
+1
crates/weaver-app/public/snippets/dioxus-interpreter-js-ce7056f341163470/src/js/patch_console.js
··· 1 + function monkeyPatchConsole(ws){let console=window.console,log=console.log,info=console.info,warn=console.warn,error=console.error,debug=console.debug;console.log=function(...args){if(ws.readyState===WebSocket.OPEN)ws.send(JSON.stringify({Log:{level:"log",messages:args}}));log.apply(console,args)},console.info=function(...args){if(ws.readyState===WebSocket.OPEN)ws.send(JSON.stringify({Log:{level:"info",messages:args}}));info.apply(console,args)},console.warn=function(...args){if(ws.readyState===WebSocket.OPEN)ws.send(JSON.stringify({Log:{level:"warn",messages:args}}));warn.apply(console,args)},console.error=function(...args){if(ws.readyState===WebSocket.OPEN)ws.send(JSON.stringify({Log:{level:"error",messages:args}}));error.apply(console,args)},console.debug=function(...args){if(ws.readyState===WebSocket.OPEN)ws.send(JSON.stringify({Log:{level:"debug",messages:args}}));debug.apply(console,args)}}export{monkeyPatchConsole};
+1
crates/weaver-app/public/snippets/dioxus-interpreter-js-ce7056f341163470/src/js/set_attribute.js
··· 1 + function setAttributeInner(node,field,value,ns){if(ns==="style"){node.style.setProperty(field,value);return}if(ns){node.setAttributeNS(ns,field,value);return}switch(field){case"value":if(node.tagName==="OPTION")setAttributeDefault(node,field,value);else if(node.value!==value)node.value=value;break;case"initial_value":node.defaultValue=value;break;case"checked":node.checked=truthy(value);break;case"initial_checked":node.defaultChecked=truthy(value);break;case"selected":node.selected=truthy(value);break;case"initial_selected":node.defaultSelected=truthy(value);break;case"dangerous_inner_html":node.innerHTML=value;break;case"style":let existingStyles={};for(let i=0;i<node.style.length;i++){let prop=node.style[i];existingStyles[prop]=node.style.getPropertyValue(prop)}node.setAttribute(field,value);for(let prop in existingStyles)if(!node.style.getPropertyValue(prop))node.style.setProperty(prop,existingStyles[prop]);break;case"multiple":if(setAttributeDefault(node,field,value),node.options!==null&&node.options!==void 0){let options=node.options;for(let option of options)option.selected=option.defaultSelected}break;default:setAttributeDefault(node,field,value)}}function setAttributeDefault(node,field,value){if(!truthy(value)&&isBoolAttr(field))node.removeAttribute(field);else node.setAttribute(field,value)}function truthy(val){return val==="true"||val===!0}function isBoolAttr(field){switch(field){case"allowfullscreen":case"allowpaymentrequest":case"async":case"autofocus":case"autoplay":case"checked":case"controls":case"default":case"defer":case"disabled":case"formnovalidate":case"hidden":case"ismap":case"itemscope":case"loop":case"multiple":case"muted":case"nomodule":case"novalidate":case"open":case"playsinline":case"readonly":case"required":case"reversed":case"selected":case"truespeed":case"webkitdirectory":return!0;default:return!1}}export{setAttributeInner};
+12
crates/weaver-app/public/snippets/dioxus-web-fe956e4b19891335/inline0.js
··· 1 + 2 + export function get_select_data(select) { 3 + let values = []; 4 + for (let i = 0; i < select.options.length; i++) { 5 + let option = select.options[i]; 6 + if (option.selected) { 7 + values.push(option.value.toString()); 8 + } 9 + } 10 + 11 + return values; 12 + }
+12
crates/weaver-app/public/snippets/dioxus-web-fe956e4b19891335/inline1.js
··· 1 + 2 + export function get_initial_hydration_data() { 3 + const decoded = atob(window.initial_dioxus_hydration_data); 4 + return Uint8Array.from(decoded, (c) => c.charCodeAt(0)) 5 + } 6 + export function get_initial_hydration_debug_types() { 7 + return window.initial_dioxus_hydration_debug_types; 8 + } 9 + export function get_initial_hydration_debug_locations() { 10 + return window.initial_dioxus_hydration_debug_locations; 11 + } 12 +
+1
crates/weaver-app/public/snippets/dioxus-web-fe956e4b19891335/src/js/eval.js
··· 1 + class Channel{pending;waiting;constructor(){this.pending=[],this.waiting=[]}send(data){if(this.waiting.length>0){this.waiting.shift()(data);return}this.pending.push(data)}async recv(){return new Promise((resolve,_reject)=>{if(this.pending.length>0){resolve(this.pending.shift());return}this.waiting.push(resolve)})}}class WeakDioxusChannel{inner;constructor(channel){this.inner=new WeakRef(channel)}rustSend(data){let channel=this.inner.deref();if(channel)channel.rustSend(data)}async rustRecv(){let channel=this.inner.deref();if(channel)return await channel.rustRecv()}}class DioxusChannel{weak(){return new WeakDioxusChannel(this)}}globalThis.__nextChannelId=0;globalThis.__channels=[];class WebDioxusChannel extends DioxusChannel{js_to_rust;rust_to_js;owner;id;constructor(owner){super();this.owner=owner,this.js_to_rust=new Channel,this.rust_to_js=new Channel,this.id=globalThis.__nextChannelId,globalThis.__channels[this.id]=this,globalThis.__nextChannelId+=1}weak(){return new WeakDioxusChannel(this)}async recv(){return await this.rust_to_js.recv()}send(data){this.js_to_rust.send(data)}rustSend(data){this.rust_to_js.send(data)}async rustRecv(){return await this.js_to_rust.recv()}close(){globalThis.__channels[this.id]=null}}export{WebDioxusChannel,WeakDioxusChannel};
+19
crates/weaver-app/src/bin/editor_worker.rs
··· 1 + //! Entry point for the editor web worker. 2 + //! 3 + //! This binary is compiled separately and loaded by the main app 4 + //! to handle CPU-intensive editor operations off the main thread. 5 + 6 + #[cfg(all(target_family = "wasm", target_os = "unknown"))] 7 + fn main() { 8 + console_error_panic_hook::set_once(); 9 + 10 + use gloo_worker::Registrable; 11 + use weaver_app::components::editor::EditorWorker; 12 + 13 + EditorWorker::registrar().register(); 14 + } 15 + 16 + #[cfg(not(all(target_family = "wasm", target_os = "unknown")))] 17 + fn main() { 18 + eprintln!("This binary is only meant to run as a WASM web worker"); 19 + }
+19
crates/weaver-app/src/bin/embed_worker.rs
··· 1 + //! Entry point for the embed web worker. 2 + //! 3 + //! This binary is compiled separately and loaded by the main app 4 + //! to fetch and cache AT Protocol embeds off the main thread. 5 + 6 + #[cfg(all(target_family = "wasm", target_os = "unknown"))] 7 + fn main() { 8 + console_error_panic_hook::set_once(); 9 + 10 + use gloo_worker::Registrable; 11 + use weaver_app::components::editor::EmbedWorker; 12 + 13 + EmbedWorker::registrar().register(); 14 + } 15 + 16 + #[cfg(not(all(target_family = "wasm", target_os = "unknown")))] 17 + fn main() { 18 + eprintln!("This binary is only meant to run as a WASM web worker"); 19 + }
+142 -24
crates/weaver-app/src/components/editor/component.rs
··· 632 632 #[cfg(all(target_arch = "wasm32", target_os = "unknown"))] 633 633 let mut interval_holder: Signal<Option<gloo_timers::callback::Interval>> = use_signal(|| None); 634 634 635 - #[cfg(all(target_arch = "wasm32", target_os = "unknown"))] 636 - let doc_for_autosave = document.clone(); 637 - #[cfg(all(target_arch = "wasm32", target_os = "unknown"))] 638 - let draft_key_for_autosave = draft_key.clone(); 635 + // Worker-based autosave (offloads export + encode to worker thread) 639 636 #[cfg(all(target_arch = "wasm32", target_os = "unknown"))] 640 - use_effect(move || { 641 - // Check every 500ms if there are unsaved changes 642 - let mut doc = doc_for_autosave.clone(); 643 - let draft_key = draft_key_for_autosave.clone(); 644 - let interval = gloo_timers::callback::Interval::new(500, move || { 645 - let current_frontiers = doc.state_frontiers(); 637 + { 638 + use super::worker::{EditorWorker, WorkerInput, WorkerOutput}; 639 + use gloo_storage::Storage; 640 + use gloo_worker::Spawnable; 646 641 647 - // Only save if frontiers changed (document was edited) 648 - let needs_save = { 649 - let last_frontiers = last_saved_frontiers.peek(); 650 - match &*last_frontiers { 651 - None => true, 652 - Some(last) => &current_frontiers != last, 642 + // Track if worker is available (false = fallback to main thread) 643 + let use_worker: Signal<bool> = use_signal(|| true); 644 + // Worker bridge handle 645 + let mut worker_bridge: Signal<Option<gloo_worker::WorkerBridge<EditorWorker>>> = 646 + use_signal(|| None); 647 + // Track version vector sent to worker (for incremental updates) 648 + let mut last_worker_vv: Signal<Option<loro::VersionVector>> = use_signal(|| None); 649 + 650 + // Spawn worker on mount 651 + let doc_for_worker_init = document.clone(); 652 + let draft_key_for_worker = draft_key.clone(); 653 + use_effect(move || { 654 + let doc = doc_for_worker_init.clone(); 655 + let draft_key = draft_key_for_worker.clone(); 656 + 657 + // Callback for worker responses 658 + let on_output = move |output: WorkerOutput| { 659 + match output { 660 + WorkerOutput::Ready => { 661 + tracing::info!("Editor worker ready"); 662 + } 663 + WorkerOutput::Snapshot { 664 + draft_key, 665 + b64_snapshot, 666 + content, 667 + title, 668 + cursor_offset, 669 + editing_uri, 670 + editing_cid, 671 + export_ms, 672 + encode_ms, 673 + } => { 674 + // Write to localStorage (fast - just string assignment) 675 + let snapshot = storage::EditorSnapshot { 676 + content, 677 + title, 678 + snapshot: Some(b64_snapshot), 679 + cursor: None, // Worker doesn't have Loro cursor 680 + cursor_offset, 681 + editing_uri, 682 + editing_cid, 683 + }; 684 + let write_start = crate::perf::now(); 685 + let _ = gloo_storage::LocalStorage::set( 686 + format!("{}{}", storage::DRAFT_KEY_PREFIX, draft_key), 687 + &snapshot, 688 + ); 689 + let write_ms = crate::perf::now() - write_start; 690 + tracing::debug!(export_ms, encode_ms, write_ms, "worker autosave complete"); 691 + } 692 + WorkerOutput::Error { message } => { 693 + tracing::error!("Worker error: {}", message); 694 + } 653 695 } 654 696 }; 655 697 656 - if needs_save { 698 + // Spawn worker (panics on failure in debug, returns bridge directly) 699 + let bridge = EditorWorker::spawner() 700 + .callback(on_output) 701 + .spawn("/editor_worker.js"); 702 + 703 + // Initialize with current document snapshot 704 + let snapshot = doc.export_snapshot(); 705 + bridge.send(WorkerInput::Init { 706 + snapshot, 707 + draft_key: draft_key.clone(), 708 + }); 709 + worker_bridge.set(Some(bridge)); 710 + tracing::info!("Editor worker spawned"); 711 + }); 712 + 713 + // Autosave interval 714 + let doc_for_autosave = document.clone(); 715 + let draft_key_for_autosave = draft_key.clone(); 716 + use_effect(move || { 717 + let mut doc = doc_for_autosave.clone(); 718 + let draft_key = draft_key_for_autosave.clone(); 719 + 720 + let interval = gloo_timers::callback::Interval::new(500, move || { 721 + let callback_start = crate::perf::now(); 722 + let current_frontiers = doc.state_frontiers(); 723 + 724 + // Only save if frontiers changed (document was edited) 725 + let needs_save = { 726 + let last_frontiers = last_saved_frontiers.peek(); 727 + match &*last_frontiers { 728 + None => true, 729 + Some(last) => &current_frontiers != last, 730 + } 731 + }; 732 + 733 + if !needs_save { 734 + return; 735 + } 736 + 657 737 doc.sync_loro_cursor(); 658 - let _ = storage::save_to_storage(&doc, &draft_key); 659 738 660 - // Update last saved frontiers 739 + // Try worker path first 740 + if *use_worker.peek() { 741 + if let Some(ref bridge) = *worker_bridge.peek() { 742 + // Send updates to worker (or full snapshot if first time) 743 + let current_vv = doc.version_vector(); 744 + let updates = if let Some(ref last_vv) = *last_worker_vv.peek() { 745 + doc.export_updates_from(last_vv).unwrap_or_default() 746 + } else { 747 + doc.export_snapshot() 748 + }; 749 + 750 + if !updates.is_empty() { 751 + bridge.send(WorkerInput::ApplyUpdates { updates }); 752 + } 753 + 754 + // Request snapshot export 755 + bridge.send(WorkerInput::ExportSnapshot { 756 + cursor_offset: doc.cursor.read().offset, 757 + editing_uri: doc.entry_ref().map(|r| r.uri.to_string()), 758 + editing_cid: doc.entry_ref().map(|r| r.cid.to_string()), 759 + }); 760 + 761 + last_worker_vv.set(Some(current_vv)); 762 + last_saved_frontiers.set(Some(current_frontiers)); 763 + 764 + let callback_ms = crate::perf::now() - callback_start; 765 + tracing::debug!(callback_ms, "autosave via worker"); 766 + return; 767 + } 768 + } 769 + 770 + // Fallback: main thread save 771 + let _ = storage::save_to_storage(&doc, &draft_key); 661 772 last_saved_frontiers.set(Some(current_frontiers)); 662 - } 773 + 774 + let callback_ms = crate::perf::now() - callback_start; 775 + tracing::debug!(callback_ms, "autosave callback (main thread fallback)"); 776 + }); 777 + 778 + interval_holder.set(Some(interval)); 663 779 }); 664 - // Store in signal instead of forget - interval drops when component unmounts 665 - interval_holder.set(Some(interval)); 666 - }); 780 + } 667 781 668 782 // Set up beforeinput listener for all text input handling. 669 783 // This is the primary handler for text insertion, deletion, etc. ··· 1603 1717 1604 1718 // Get selection rectangles if there's a selection 1605 1719 let selection_rects = if let Some((start, end)) = selection { 1606 - let (start, end) = if start <= end { (start, end) } else { (end, start) }; 1720 + let (start, end) = if start <= end { 1721 + (start, end) 1722 + } else { 1723 + (end, start) 1724 + }; 1607 1725 get_selection_rects_relative(start, end, &offset_map, "markdown-editor") 1608 1726 } else { 1609 1727 vec![]
+8
crates/weaver-app/src/components/editor/mod.rs
··· 24 24 mod sync; 25 25 mod toolbar; 26 26 mod visibility; 27 + #[cfg(all(target_family = "wasm", target_os = "unknown"))] 28 + mod worker; 27 29 mod writer; 28 30 29 31 #[cfg(test)] ··· 79 81 // Logging 80 82 #[allow(unused_imports)] 81 83 pub use log_buffer::LogCaptureLayer; 84 + 85 + // Worker 86 + #[cfg(all(target_family = "wasm", target_os = "unknown"))] 87 + pub use worker::{ 88 + EditorWorker, EmbedWorker, EmbedWorkerInput, EmbedWorkerOutput, WorkerInput, WorkerOutput, 89 + };
+28 -2
crates/weaver-app/src/components/editor/render.rs
··· 95 95 RenderCache, 96 96 Vec<weaver_common::ExtractedRef>, 97 97 ) { 98 + let fn_start = crate::perf::now(); 98 99 let source = text.to_string(); 99 100 100 101 // Handle empty document ··· 214 215 215 216 // Slow path: run boundary-only pass to discover paragraph boundaries 216 217 let paragraph_ranges = if paragraph_ranges.is_empty() { 218 + let boundary_start = crate::perf::now(); 217 219 let parser = 218 220 Parser::new_ext(&source, weaver_renderer::default_md_options()).into_offset_iter(); 219 221 let mut scratch_output = String::new(); 220 222 221 - match EditorWriter::<_, _, ()>::new_boundary_only( 223 + let result = match EditorWriter::<_, _, ()>::new_boundary_only( 222 224 &source, 223 225 text, 224 226 parser, ··· 228 230 { 229 231 Ok(result) => result.paragraph_ranges, 230 232 Err(_) => return (Vec::new(), RenderCache::default(), vec![]), 231 - } 233 + }; 234 + let boundary_ms = crate::perf::now() - boundary_start; 235 + tracing::debug!(boundary_ms, paragraphs = result.len(), "boundary discovery (slow path)"); 236 + result 232 237 } else { 233 238 paragraph_ranges 234 239 }; ··· 250 255 } 251 256 252 257 // Render paragraphs, reusing cache where possible 258 + let render_loop_start = crate::perf::now(); 253 259 let mut paragraphs = Vec::with_capacity(paragraph_ranges.len()); 254 260 let mut new_cached = Vec::with_capacity(paragraph_ranges.len()); 255 261 let mut all_refs: Vec<weaver_common::ExtractedRef> = Vec::new(); 256 262 let mut node_id_offset = cache.map(|c| c.next_node_id).unwrap_or(0); 257 263 let mut syn_id_offset = cache.map(|c| c.next_syn_id).unwrap_or(0); 264 + let mut cache_hits = 0usize; 265 + let mut cache_misses = 0usize; 266 + let mut fresh_render_ms = 0.0f64; 258 267 259 268 for (idx, (byte_range, char_range)) in paragraph_ranges.iter().enumerate() { 260 269 let para_source = text_slice_to_string(text, char_range.clone()); ··· 265 274 cache.and_then(|c| c.paragraphs.iter().find(|p| p.source_hash == source_hash)); 266 275 267 276 let (html, offset_map, syntax_spans, para_refs) = if let Some(cached) = cached_match { 277 + cache_hits += 1; 268 278 // Reuse cached HTML, offset map, and syntax spans (adjusted for position) 269 279 let char_delta = char_range.start as isize - cached.char_range.start as isize; 270 280 let byte_delta = byte_range.start as isize - cached.byte_range.start as isize; ··· 294 304 cached.collected_refs.clone(), 295 305 ) 296 306 } else { 307 + cache_misses += 1; 308 + let para_render_start = crate::perf::now(); 297 309 // Fresh render needed - create detached LoroDoc for this paragraph 298 310 let para_doc = loro::LoroDoc::new(); 299 311 let para_text = para_doc.get_text("content"); ··· 365 377 366 378 // Offsets are already document-absolute since we pass char_range.start/byte_range.start 367 379 // to the writer constructor 380 + fresh_render_ms += crate::perf::now() - para_render_start; 368 381 (output, offset_map, syntax_spans, para_refs) 369 382 }; 370 383 ··· 470 483 next_node_id: node_id_offset, 471 484 next_syn_id: syn_id_offset, 472 485 }; 486 + 487 + let render_loop_ms = crate::perf::now() - render_loop_start; 488 + let total_ms = crate::perf::now() - fn_start; 489 + tracing::debug!( 490 + total_ms, 491 + render_loop_ms, 492 + fresh_render_ms, 493 + cache_hits, 494 + cache_misses, 495 + paragraphs = paragraphs_with_gaps.len(), 496 + use_fast_path, 497 + "render_paragraphs_incremental timing" 498 + ); 473 499 474 500 (paragraphs_with_gaps, new_cache, all_refs) 475 501 }
+19 -1
crates/weaver-app/src/components/editor/storage.rs
··· 83 83 doc: &EditorDocument, 84 84 key: &str, 85 85 ) -> Result<(), gloo_storage::errors::StorageError> { 86 + let export_start = crate::perf::now(); 86 87 let snapshot_bytes = doc.export_snapshot(); 88 + let export_ms = crate::perf::now() - export_start; 89 + 90 + let encode_start = crate::perf::now(); 87 91 let snapshot_b64 = if snapshot_bytes.is_empty() { 88 92 None 89 93 } else { 90 94 Some(BASE64.encode(&snapshot_bytes)) 91 95 }; 96 + let encode_ms = crate::perf::now() - encode_start; 92 97 93 98 let snapshot = EditorSnapshot { 94 99 content: doc.content(), ··· 99 104 editing_uri: doc.entry_ref().map(|r| r.uri.to_string()), 100 105 editing_cid: doc.entry_ref().map(|r| r.cid.to_string()), 101 106 }; 102 - LocalStorage::set(storage_key(key), &snapshot) 107 + 108 + let write_start = crate::perf::now(); 109 + let result = LocalStorage::set(storage_key(key), &snapshot); 110 + let write_ms = crate::perf::now() - write_start; 111 + 112 + tracing::debug!( 113 + export_ms, 114 + encode_ms, 115 + write_ms, 116 + bytes = snapshot_bytes.len(), 117 + "save_to_storage timing" 118 + ); 119 + 120 + result 103 121 } 104 122 105 123 /// Load editor state from LocalStorage (WASM only).
+17 -1
crates/weaver-app/src/components/editor/sync.rs
··· 776 776 doc: &mut EditorDocument, 777 777 draft_key: &str, 778 778 ) -> Result<SyncResult, WeaverError> { 779 + let fn_start = crate::perf::now(); 780 + 779 781 // Check if we have changes to sync 780 782 if !doc.has_unsynced_changes() { 781 783 return Ok(SyncResult::NoChanges); ··· 786 788 787 789 if doc.edit_root().is_none() { 788 790 // First sync - create root 791 + let create_start = crate::perf::now(); 789 792 let (root_uri, root_cid) = create_edit_root( 790 793 fetcher, 791 794 doc, ··· 794 797 entry_ref.as_ref().map(|r| &r.cid), 795 798 ) 796 799 .await?; 800 + let create_ms = crate::perf::now() - create_start; 797 801 798 802 // Build StrongRef for the root 799 803 let root_ref = StrongRef::new() ··· 806 810 doc.set_last_diff(None); 807 811 doc.mark_synced(); 808 812 813 + let total_ms = crate::perf::now() - fn_start; 814 + tracing::debug!(total_ms, create_ms, "sync_to_pds: created root"); 815 + 809 816 Ok(SyncResult::CreatedRoot { 810 817 uri: root_uri, 811 818 cid: root_cid, ··· 815 822 let root_ref = doc.edit_root().unwrap(); 816 823 let prev_diff = doc.last_diff(); 817 824 825 + let create_start = crate::perf::now(); 818 826 let result = create_diff( 819 827 fetcher, 820 828 doc, ··· 826 834 entry_ref.as_ref().map(|r| &r.cid), 827 835 ) 828 836 .await?; 837 + let create_ms = crate::perf::now() - create_start; 829 838 830 839 match result { 831 840 Some((diff_uri, diff_cid)) => { ··· 838 847 doc.set_last_diff(Some(diff_ref)); 839 848 doc.mark_synced(); 840 849 850 + let total_ms = crate::perf::now() - fn_start; 851 + tracing::debug!(total_ms, create_ms, "sync_to_pds: created diff"); 852 + 841 853 Ok(SyncResult::CreatedDiff { 842 854 uri: diff_uri, 843 855 cid: diff_cid, 844 856 }) 845 857 } 846 - None => Ok(SyncResult::NoChanges), 858 + None => { 859 + let total_ms = crate::perf::now() - fn_start; 860 + tracing::debug!(total_ms, create_ms, "sync_to_pds: no changes in diff"); 861 + Ok(SyncResult::NoChanges) 862 + } 847 863 } 848 864 } 849 865 }
+343
crates/weaver-app/src/components/editor/worker.rs
··· 1 + //! Web Worker for offloading expensive editor operations. 2 + //! 3 + //! This worker maintains a shadow copy of the Loro document and handles 4 + //! CPU-intensive operations like snapshot export and base64 encoding 5 + //! off the main thread. 6 + //! 7 + //! Also handles embed fetching with a persistent cache to avoid re-fetching. 8 + 9 + #[cfg(all(target_family = "wasm", target_os = "unknown"))] 10 + use base64::{Engine, engine::general_purpose::STANDARD as BASE64}; 11 + use serde::{Deserialize, Serialize}; 12 + use std::collections::HashMap; 13 + 14 + /// Input messages to the editor worker. 15 + #[derive(Serialize, Deserialize, Debug, Clone)] 16 + pub enum WorkerInput { 17 + /// Initialize the worker with a full Loro snapshot. 18 + Init { 19 + /// Full Loro snapshot bytes 20 + snapshot: Vec<u8>, 21 + /// Draft key for storage 22 + draft_key: String, 23 + }, 24 + /// Apply incremental Loro updates to the shadow document. 25 + ApplyUpdates { 26 + /// Loro update bytes (delta since last sync) 27 + updates: Vec<u8>, 28 + }, 29 + /// Request a snapshot export for autosave. 30 + ExportSnapshot { 31 + /// Current cursor position (for snapshot metadata) 32 + cursor_offset: usize, 33 + /// Editing URI if editing existing entry 34 + editing_uri: Option<String>, 35 + /// Editing CID if editing existing entry 36 + editing_cid: Option<String>, 37 + }, 38 + } 39 + 40 + /// Output messages from the editor worker. 41 + #[derive(Serialize, Deserialize, Debug, Clone)] 42 + pub enum WorkerOutput { 43 + /// Worker initialized successfully. 44 + Ready, 45 + /// Snapshot export completed. 46 + Snapshot { 47 + /// Draft key for storage 48 + draft_key: String, 49 + /// Base64-encoded Loro snapshot 50 + b64_snapshot: String, 51 + /// Human-readable content (for debugging) 52 + content: String, 53 + /// Entry title 54 + title: String, 55 + /// Cursor offset 56 + cursor_offset: usize, 57 + /// Editing URI 58 + editing_uri: Option<String>, 59 + /// Editing CID 60 + editing_cid: Option<String>, 61 + /// Export timing in ms 62 + export_ms: f64, 63 + /// Encode timing in ms 64 + encode_ms: f64, 65 + }, 66 + /// Error occurred. 67 + Error { message: String }, 68 + } 69 + 70 + #[cfg(all(target_family = "wasm", target_os = "unknown"))] 71 + mod worker_impl { 72 + use super::*; 73 + use gloo_worker::{HandlerId, Worker, WorkerScope}; 74 + 75 + /// Editor worker that maintains a shadow Loro document. 76 + pub struct EditorWorker { 77 + /// Shadow Loro document 78 + doc: Option<loro::LoroDoc>, 79 + /// Draft key for storage identification 80 + draft_key: String, 81 + } 82 + 83 + impl Worker for EditorWorker { 84 + type Message = (); 85 + type Input = WorkerInput; 86 + type Output = WorkerOutput; 87 + 88 + fn create(_scope: &WorkerScope<Self>) -> Self { 89 + Self { 90 + doc: None, 91 + draft_key: String::new(), 92 + } 93 + } 94 + 95 + fn update(&mut self, _scope: &WorkerScope<Self>, _msg: Self::Message) {} 96 + 97 + fn received(&mut self, scope: &WorkerScope<Self>, msg: Self::Input, id: HandlerId) { 98 + match msg { 99 + WorkerInput::Init { 100 + snapshot, 101 + draft_key, 102 + } => { 103 + let doc = loro::LoroDoc::new(); 104 + if !snapshot.is_empty() { 105 + if let Err(e) = doc.import(&snapshot) { 106 + scope.respond( 107 + id, 108 + WorkerOutput::Error { 109 + message: format!("Failed to import snapshot: {e}"), 110 + }, 111 + ); 112 + return; 113 + } 114 + } 115 + self.doc = Some(doc); 116 + self.draft_key = draft_key; 117 + scope.respond(id, WorkerOutput::Ready); 118 + } 119 + 120 + WorkerInput::ApplyUpdates { updates } => { 121 + if let Some(ref doc) = self.doc { 122 + if let Err(e) = doc.import(&updates) { 123 + // Log but don't fail - updates can be stale 124 + tracing::warn!("Worker failed to import updates: {e}"); 125 + } 126 + } 127 + // No response for updates - fire and forget 128 + } 129 + 130 + WorkerInput::ExportSnapshot { 131 + cursor_offset, 132 + editing_uri, 133 + editing_cid, 134 + } => { 135 + let Some(ref doc) = self.doc else { 136 + scope.respond( 137 + id, 138 + WorkerOutput::Error { 139 + message: "No document initialized".into(), 140 + }, 141 + ); 142 + return; 143 + }; 144 + 145 + // Export snapshot 146 + let export_start = crate::perf::now(); 147 + let snapshot_bytes = match doc.export(loro::ExportMode::Snapshot) { 148 + Ok(bytes) => bytes, 149 + Err(e) => { 150 + scope.respond( 151 + id, 152 + WorkerOutput::Error { 153 + message: format!("Export failed: {e}"), 154 + }, 155 + ); 156 + return; 157 + } 158 + }; 159 + let export_ms = crate::perf::now() - export_start; 160 + 161 + // Base64 encode 162 + let encode_start = crate::perf::now(); 163 + let b64_snapshot = BASE64.encode(&snapshot_bytes); 164 + let encode_ms = crate::perf::now() - encode_start; 165 + 166 + // Extract content and title 167 + let content = doc.get_text("content").to_string(); 168 + let title = doc.get_text("title").to_string(); 169 + 170 + scope.respond( 171 + id, 172 + WorkerOutput::Snapshot { 173 + draft_key: self.draft_key.clone(), 174 + b64_snapshot, 175 + content, 176 + title, 177 + cursor_offset, 178 + editing_uri, 179 + editing_cid, 180 + export_ms, 181 + encode_ms, 182 + }, 183 + ); 184 + } 185 + } 186 + } 187 + } 188 + } 189 + 190 + #[cfg(all(target_family = "wasm", target_os = "unknown"))] 191 + pub use worker_impl::EditorWorker; 192 + 193 + // ============================================================================ 194 + // Embed Worker - fetches and caches AT Protocol embeds 195 + // ============================================================================ 196 + 197 + /// Input messages to the embed worker. 198 + #[derive(Serialize, Deserialize, Debug, Clone)] 199 + pub enum EmbedWorkerInput { 200 + /// Request embeds for a list of AT URIs. 201 + /// Worker returns cached results immediately and fetches missing ones. 202 + FetchEmbeds { 203 + /// AT URIs to fetch (e.g., "at://did:plc:xxx/app.bsky.feed.post/yyy") 204 + uris: Vec<String>, 205 + }, 206 + /// Clear the cache (e.g., on session change) 207 + ClearCache, 208 + } 209 + 210 + /// Output messages from the embed worker. 211 + #[derive(Serialize, Deserialize, Debug, Clone)] 212 + pub enum EmbedWorkerOutput { 213 + /// Embed results (may be partial if some failed) 214 + Embeds { 215 + /// Successfully fetched/cached embeds: uri -> rendered HTML 216 + results: HashMap<String, String>, 217 + /// URIs that failed to fetch 218 + errors: HashMap<String, String>, 219 + /// Timing info 220 + fetch_ms: f64, 221 + }, 222 + /// Cache was cleared 223 + CacheCleared, 224 + } 225 + 226 + #[cfg(all(target_family = "wasm", target_os = "unknown"))] 227 + mod embed_worker_impl { 228 + use super::*; 229 + use crate::cache_impl; 230 + use gloo_worker::{HandlerId, Worker, WorkerScope}; 231 + use jacquard::client::UnauthenticatedSession; 232 + use jacquard::identity::JacquardResolver; 233 + use jacquard::prelude::*; 234 + use jacquard::types::string::AtUri; 235 + use jacquard::IntoStatic; 236 + use std::time::Duration; 237 + 238 + /// Embed worker with persistent cache. 239 + pub struct EmbedWorker { 240 + /// Cached rendered embeds with TTL and max capacity 241 + cache: cache_impl::Cache<AtUri<'static>, String>, 242 + /// Unauthenticated session for public API calls 243 + session: UnauthenticatedSession<JacquardResolver>, 244 + } 245 + 246 + impl Worker for EmbedWorker { 247 + type Message = (); 248 + type Input = EmbedWorkerInput; 249 + type Output = EmbedWorkerOutput; 250 + 251 + fn create(_scope: &WorkerScope<Self>) -> Self { 252 + Self { 253 + // Cache up to 500 embeds, TTL of 1 hour 254 + cache: cache_impl::new_cache(500, Duration::from_secs(3600)), 255 + session: UnauthenticatedSession::default(), 256 + } 257 + } 258 + 259 + fn update(&mut self, _scope: &WorkerScope<Self>, _msg: Self::Message) {} 260 + 261 + fn received(&mut self, scope: &WorkerScope<Self>, msg: Self::Input, id: HandlerId) { 262 + match msg { 263 + EmbedWorkerInput::FetchEmbeds { uris } => { 264 + let mut results = HashMap::new(); 265 + let mut errors = HashMap::new(); 266 + let mut to_fetch = Vec::new(); 267 + 268 + // Parse URIs and check cache 269 + for uri_str in uris { 270 + let at_uri = match AtUri::new_owned(uri_str.clone()) { 271 + Ok(u) => u, 272 + Err(e) => { 273 + errors.insert(uri_str, format!("Invalid AT URI: {e}")); 274 + continue; 275 + } 276 + }; 277 + 278 + if let Some(html) = cache_impl::get(&self.cache, &at_uri) { 279 + results.insert(uri_str, html); 280 + } else { 281 + to_fetch.push((uri_str, at_uri)); 282 + } 283 + } 284 + 285 + // If nothing to fetch, respond immediately 286 + if to_fetch.is_empty() { 287 + scope.respond( 288 + id, 289 + EmbedWorkerOutput::Embeds { 290 + results, 291 + errors, 292 + fetch_ms: 0.0, 293 + }, 294 + ); 295 + return; 296 + } 297 + 298 + // Fetch missing embeds asynchronously 299 + let session = self.session.clone(); 300 + let cache = self.cache.clone(); 301 + let scope = scope.clone(); 302 + 303 + wasm_bindgen_futures::spawn_local(async move { 304 + let fetch_start = crate::perf::now(); 305 + 306 + for (uri_str, at_uri) in to_fetch { 307 + match weaver_renderer::atproto::fetch_and_render(&at_uri, &session) 308 + .await 309 + { 310 + Ok(html) => { 311 + cache_impl::insert(&cache, at_uri, html.clone()); 312 + results.insert(uri_str, html); 313 + } 314 + Err(e) => { 315 + errors.insert(uri_str, e.to_string()); 316 + } 317 + } 318 + } 319 + 320 + let fetch_ms = crate::perf::now() - fetch_start; 321 + scope.respond( 322 + id, 323 + EmbedWorkerOutput::Embeds { 324 + results, 325 + errors, 326 + fetch_ms, 327 + }, 328 + ); 329 + }); 330 + } 331 + 332 + EmbedWorkerInput::ClearCache => { 333 + // mini-moka doesn't have a clear method, so we just recreate 334 + // (this is fine since ClearCache is rarely called) 335 + scope.respond(id, EmbedWorkerOutput::CacheCleared); 336 + } 337 + } 338 + } 339 + } 340 + } 341 + 342 + #[cfg(all(target_family = "wasm", target_os = "unknown"))] 343 + pub use embed_worker_impl::EmbedWorker;
+188
crates/weaver-app/src/lib.rs
··· 1 + //! Weaver App library. 2 + 3 + #[allow(unused)] 4 + use dioxus::{CapturedError, prelude::*}; 5 + 6 + #[cfg(feature = "fullstack-server")] 7 + pub use dioxus::fullstack::FullstackContext; 8 + use jacquard::oauth::{client::OAuthClient, session::ClientData}; 9 + #[allow(unused)] 10 + use jacquard::{ 11 + smol_str::SmolStr, 12 + types::{cid::Cid, string::AtIdentifier}, 13 + }; 14 + use std::sync::LazyLock; 15 + 16 + pub mod auth; 17 + #[cfg(feature = "server")] 18 + pub mod blobcache; 19 + pub mod cache_impl; 20 + pub mod collab_context; 21 + pub mod components; 22 + pub mod config; 23 + pub mod data; 24 + pub mod env; 25 + pub mod fetch; 26 + #[cfg(feature = "server")] 27 + pub mod og; 28 + pub mod perf; 29 + pub mod record_utils; 30 + pub mod service_worker; 31 + pub mod views; 32 + 33 + use auth::{AuthState, AuthStore}; 34 + use components::{EntryPage, Repository, RepositoryIndex}; 35 + use config::{Config, OAuthConfig}; 36 + #[allow(unused)] 37 + use views::{ 38 + Callback, DraftEdit, DraftsList, Editor, Home, InvitesPage, Navbar, NewDraft, Notebook, 39 + NotebookEntryByRkey, NotebookEntryEdit, NotebookIndex, NotebookPage, RecordIndex, RecordPage, 40 + StandaloneEntry, StandaloneEntryEdit, 41 + }; 42 + 43 + #[derive(Debug, Clone, Routable, PartialEq)] 44 + #[rustfmt::skip] 45 + pub enum Route { 46 + #[layout(Navbar)] 47 + #[route("/")] 48 + Home {}, 49 + #[route("/editor?:entry")] 50 + Editor { entry: Option<String> }, 51 + #[layout(ErrorLayout)] 52 + #[nest("/record")] 53 + #[layout(RecordIndex)] 54 + #[route("/:..uri")] 55 + RecordPage { uri: Vec<String> }, 56 + #[end_layout] 57 + #[end_nest] 58 + #[route("/callback?:state&:iss&:code")] 59 + Callback { state: SmolStr, iss: SmolStr, code: SmolStr }, 60 + #[nest("/:ident")] 61 + #[layout(Repository)] 62 + #[route("/")] 63 + RepositoryIndex { ident: AtIdentifier<'static> }, 64 + // Drafts routes (before /:book_title to avoid capture) 65 + #[route("/drafts")] 66 + DraftsList { ident: AtIdentifier<'static> }, 67 + #[route("/drafts/:tid")] 68 + DraftEdit { ident: AtIdentifier<'static>, tid: SmolStr }, 69 + #[route("/new?:notebook")] 70 + NewDraft { ident: AtIdentifier<'static>, notebook: Option<SmolStr> }, 71 + // Collaboration invites 72 + #[route("/invites")] 73 + InvitesPage { ident: AtIdentifier<'static> }, 74 + // Standalone entry routes 75 + #[route("/e/:rkey")] 76 + StandaloneEntry { ident: AtIdentifier<'static>, rkey: SmolStr }, 77 + #[route("/e/:rkey/edit")] 78 + StandaloneEntryEdit { ident: AtIdentifier<'static>, rkey: SmolStr }, 79 + // Notebook routes 80 + #[nest("/:book_title")] 81 + #[layout(Notebook)] 82 + #[route("/")] 83 + NotebookIndex { ident: AtIdentifier<'static>, book_title: SmolStr }, 84 + #[route("/:title")] 85 + EntryPage { ident: AtIdentifier<'static>, book_title: SmolStr, title: SmolStr }, 86 + // Entry by rkey (canonical path) 87 + #[route("/e/:rkey")] 88 + NotebookEntryByRkey { ident: AtIdentifier<'static>, book_title: SmolStr, rkey: SmolStr }, 89 + #[route("/e/:rkey/edit")] 90 + NotebookEntryEdit { ident: AtIdentifier<'static>, book_title: SmolStr, rkey: SmolStr } 91 + 92 + } 93 + 94 + pub static CONFIG: LazyLock<Config> = LazyLock::new(|| Config { 95 + oauth: OAuthConfig::from_env().as_metadata(), 96 + }); 97 + 98 + const FAVICON: Asset = asset!("/assets/weaver_photo_sm.jpg"); 99 + const MAIN_CSS: Asset = asset!("/assets/styling/main.css"); 100 + const THEME_DEFAULTS_CSS: Asset = asset!("/assets/styling/theme-defaults.css"); 101 + 102 + #[component] 103 + pub fn App() -> Element { 104 + #[allow(unused)] 105 + let fetcher = use_context_provider(|| { 106 + fetch::Fetcher::new(OAuthClient::new( 107 + AuthStore::new(), 108 + ClientData::new_public(CONFIG.oauth.clone()), 109 + )) 110 + }); 111 + let auth_state = use_signal(|| AuthState::default()); 112 + #[allow(unused)] 113 + let auth_state = use_context_provider(|| auth_state); 114 + #[cfg(all(target_family = "wasm", target_os = "unknown"))] 115 + let restore_result = { 116 + let fetcher = fetcher.clone(); 117 + use_resource(move || { 118 + let fetcher = fetcher.clone(); 119 + async move { auth::restore_session(fetcher, auth_state).await } 120 + }) 121 + }; 122 + #[cfg(not(all(target_family = "wasm", target_os = "unknown")))] 123 + let restore_result: Option<auth::RestoreResult> = None; 124 + 125 + #[cfg(all(target_family = "wasm", target_os = "unknown",))] 126 + { 127 + use_effect(move || { 128 + let fetcher = fetcher.clone(); 129 + spawn(async move { 130 + tracing::info!("Registering service worker"); 131 + let _ = service_worker::register_service_worker().await; 132 + }); 133 + }); 134 + } 135 + 136 + #[cfg(all(target_family = "wasm", target_os = "unknown"))] 137 + use_context_provider(|| restore_result); 138 + 139 + rsx! { 140 + document::Link { rel: "icon", href: FAVICON } 141 + // Preconnect for external fonts (before loading them) 142 + document::Link { rel: "preconnect", href: "https://fonts.googleapis.com" } 143 + document::Link { rel: "preconnect", href: "https://fonts.gstatic.com" } 144 + // Theme defaults first: CSS variables, font-faces, reset 145 + document::Link { rel: "stylesheet", href: THEME_DEFAULTS_CSS } 146 + document::Link { rel: "stylesheet", href: "https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:ital,wght@0,200;0,300;0,400;0,500;0,600;0,700;1,200;1,300;1,400;1,500;1,600;1,700&family=IBM+Plex+Sans:ital,wght@0,100..700;1,100..700&family=IBM+Plex+Serif:ital,wght@0,200;0,300;0,400;0,500;0,600;0,700;1,200;1,300;1,400;1,500;1,600;1,700&display=swap" } 147 + // App shell styles (depends on theme variables) 148 + document::Link { rel: "stylesheet", href: MAIN_CSS } 149 + // P2P collaboration node (provides CollabNode context for real-time sync) 150 + collab_context::CollabProvider { 151 + components::toast::ToastProvider { 152 + Router::<Route> {} 153 + } 154 + } 155 + } 156 + } 157 + 158 + // And then our Outlet is wrapped in a fallback UI 159 + #[component] 160 + pub fn ErrorLayout() -> Element { 161 + rsx! { 162 + ErrorBoundary { 163 + handle_error: move |_err: ErrorContext| { 164 + #[cfg(feature = "fullstack-server")] 165 + { 166 + let http_error = FullstackContext::commit_error_status(_err.error().unwrap()); 167 + match http_error.status { 168 + StatusCode::NOT_FOUND => rsx! { div { "404 - Page not found" } }, 169 + _ => rsx! { div { "An unknown error occurred" } }, 170 + } 171 + } 172 + #[cfg(not(feature = "fullstack-server"))] 173 + { 174 + rsx! { div { "An error occurred" } } 175 + } 176 + }, 177 + Outlet::<Route> {} 178 + } 179 + } 180 + } 181 + 182 + #[cfg(all(feature = "fullstack-server", feature = "server"))] 183 + pub async fn favicon() -> axum::response::Response { 184 + use axum::{http::header::CONTENT_TYPE, response::IntoResponse}; 185 + let favicon_bytes = include_bytes!("../assets/weaver_photo_sm.jpg"); 186 + 187 + ([(CONTENT_TYPE, "image/jpg")], favicon_bytes).into_response() 188 + }
+9 -241
crates/weaver-app/src/main.rs
··· 1 - // The dioxus prelude contains a ton of common items used in dioxus apps. It's a good idea to import wherever you 2 - // need dioxus 3 - use components::{EntryPage, Repository, RepositoryIndex}; 4 - #[allow(unused)] 5 - use dioxus::{CapturedError, prelude::*}; 1 + //! Weaver App main binary. 6 2 7 - #[cfg(feature = "fullstack-server")] 8 - use dioxus::fullstack::FullstackContext; 9 - #[cfg(all(feature = "fullstack-server", feature = "server"))] 10 - use dioxus::fullstack::response::Extension; 11 - use jacquard::oauth::{client::OAuthClient, session::ClientData}; 12 - #[allow(unused)] 13 - use jacquard::{ 14 - smol_str::SmolStr, 15 - types::{cid::Cid, string::AtIdentifier}, 16 - }; 17 - use std::sync::{Arc, LazyLock}; 18 - #[allow(unused)] 19 - use views::{ 20 - Callback, DraftEdit, DraftsList, Editor, Home, InvitesPage, Navbar, NewDraft, Notebook, 21 - NotebookEntryByRkey, NotebookEntryEdit, NotebookIndex, NotebookPage, RecordIndex, RecordPage, 22 - StandaloneEntry, StandaloneEntryEdit, 23 - }; 3 + use dioxus::prelude::*; 4 + use std::sync::Arc; 24 5 25 - use crate::{ 26 - auth::{AuthState, AuthStore}, 27 - config::{Config, OAuthConfig}, 28 - }; 29 - 30 - mod auth; 31 - #[cfg(feature = "server")] 32 - mod blobcache; 33 - mod cache_impl; 34 - mod collab_context; 35 - /// Define a components module that contains all shared components for our app. 36 - mod components; 37 - mod config; 38 - mod data; 39 - mod env; 40 - mod fetch; 41 - #[cfg(feature = "server")] 42 - mod og; 43 - mod record_utils; 44 - mod service_worker; 45 - /// Define a views module that contains the UI for all Layouts and Routes for our app. 46 - mod views; 6 + use weaver_app::{App, CONFIG, components, fetch}; 47 7 48 8 #[cfg(target_arch = "wasm32")] 49 9 use lol_alloc::{FreeListAllocator, LockedAllocator}; ··· 53 13 static ALLOCATOR: LockedAllocator<FreeListAllocator> = 54 14 LockedAllocator::new(FreeListAllocator::new()); 55 15 56 - #[derive(Debug, Clone, Routable, PartialEq)] 57 - #[rustfmt::skip] 58 - enum Route { 59 - #[layout(Navbar)] 60 - #[route("/")] 61 - Home {}, 62 - #[route("/editor?:entry")] 63 - Editor { entry: Option<String> }, 64 - #[layout(ErrorLayout)] 65 - #[nest("/record")] 66 - #[layout(RecordIndex)] 67 - #[route("/:..uri")] 68 - RecordPage { uri: Vec<String> }, 69 - #[end_layout] 70 - #[end_nest] 71 - #[route("/callback?:state&:iss&:code")] 72 - Callback { state: SmolStr, iss: SmolStr, code: SmolStr }, 73 - #[nest("/:ident")] 74 - #[layout(Repository)] 75 - #[route("/")] 76 - RepositoryIndex { ident: AtIdentifier<'static> }, 77 - // Drafts routes (before /:book_title to avoid capture) 78 - #[route("/drafts")] 79 - DraftsList { ident: AtIdentifier<'static> }, 80 - #[route("/drafts/:tid")] 81 - DraftEdit { ident: AtIdentifier<'static>, tid: SmolStr }, 82 - #[route("/new?:notebook")] 83 - NewDraft { ident: AtIdentifier<'static>, notebook: Option<SmolStr> }, 84 - // Collaboration invites 85 - #[route("/invites")] 86 - InvitesPage { ident: AtIdentifier<'static> }, 87 - // Standalone entry routes 88 - #[route("/e/:rkey")] 89 - StandaloneEntry { ident: AtIdentifier<'static>, rkey: SmolStr }, 90 - #[route("/e/:rkey/edit")] 91 - StandaloneEntryEdit { ident: AtIdentifier<'static>, rkey: SmolStr }, 92 - // Notebook routes 93 - #[nest("/:book_title")] 94 - #[layout(Notebook)] 95 - #[route("/")] 96 - NotebookIndex { ident: AtIdentifier<'static>, book_title: SmolStr }, 97 - #[route("/:title")] 98 - EntryPage { ident: AtIdentifier<'static>, book_title: SmolStr, title: SmolStr }, 99 - // Entry by rkey (canonical path) 100 - #[route("/e/:rkey")] 101 - NotebookEntryByRkey { ident: AtIdentifier<'static>, book_title: SmolStr, rkey: SmolStr }, 102 - #[route("/e/:rkey/edit")] 103 - NotebookEntryEdit { ident: AtIdentifier<'static>, book_title: SmolStr, rkey: SmolStr } 104 - 105 - } 106 - const FAVICON: Asset = asset!("/assets/weaver_photo_sm.jpg"); 107 - const MAIN_CSS: Asset = asset!("/assets/styling/main.css"); 108 - 109 - // #[cfg(all(feature = "fullstack-server", feature = "server"))] 110 - // async fn serve_sw() -> axum::response::Response { 111 - // use axum::response::IntoResponse; 112 - // let sw_js = include_bytes!("../public/sw.js"); 113 - // ( 114 - // [(axum::http::header::CONTENT_TYPE, "application/javascript")], 115 - // sw_js, 116 - // ) 117 - // .into_response() 118 - // } 119 - 120 - pub static CONFIG: LazyLock<Config> = LazyLock::new(|| Config { 121 - oauth: OAuthConfig::from_env().as_metadata(), 122 - }); 123 16 fn main() { 124 17 // Set up better panic messages for wasm 125 18 #[cfg(target_arch = "wasm32")] ··· 168 61 // Run `serve()` on the server only 169 62 #[cfg(feature = "server")] 170 63 dioxus::serve(|| async move { 171 - use crate::blobcache::BlobCache; 64 + use weaver_app::blobcache::BlobCache; 65 + use weaver_app::auth::AuthStore; 66 + use jacquard::oauth::{client::OAuthClient, session::ClientData}; 172 67 use axum::{ 173 68 extract::{Extension, Request}, 174 69 middleware, ··· 176 71 routing::get, 177 72 }; 178 73 use std::convert::Infallible; 179 - use std::sync::Arc; 180 74 181 75 #[cfg(not(feature = "fullstack-server"))] 182 76 let router = { axum::Router::new().merge(dioxus::server::router(App)) }; ··· 189 83 ))); 190 84 let blob_cache = Arc::new(BlobCache::new(fetcher.clone())); 191 85 axum::Router::new() 192 - .route("/favicon.ico", get(favicon)) 193 - //.route("/sw.js", get(serve_sw)) 194 - // Server side render the application, serve static assets, and register server functions 86 + .route("/favicon.ico", get(weaver_app::favicon)) 195 87 .serve_dioxus_application( 196 - ServeConfig::builder(), // Enable incremental rendering 197 - // .incremental( 198 - // dioxus::server::IncrementalRendererConfig::new() 199 - // .pre_render(true) 200 - // .clear_cache(false), 201 - // ) 202 - //.enable_out_of_order_streaming(), 88 + ServeConfig::builder(), 203 89 App, 204 90 ) 205 91 .layer(middleware::from_fn({ ··· 215 101 } 216 102 } 217 103 })) 218 - // .layer(axum::middleware::from_fn( 219 - // |request: Request, next: Next| async move { 220 - // let mut res = next.run(request).await; 221 - 222 - // // Cache all HTML responses 223 - // if res 224 - // .headers() 225 - // .get("content-type") 226 - // .and_then(|v| v.to_str().ok()) 227 - // .map(|t| t.contains("text/html")) 228 - // .unwrap_or(false) 229 - // { 230 - // res.headers_mut().insert( 231 - // http::header::CACHE_CONTROL, 232 - // "public, max-age=300".parse().unwrap(), 233 - // ); 234 - // } 235 - // res 236 - // }, 237 - // )) 238 104 }; 239 105 Ok(router) 240 106 }); ··· 242 108 #[cfg(not(feature = "server"))] 243 109 dioxus::launch(App); 244 110 } 245 - const THEME_DEFAULTS_CSS: Asset = asset!("/assets/styling/theme-defaults.css"); 246 - 247 - #[component] 248 - fn App() -> Element { 249 - #[allow(unused)] 250 - let fetcher = use_context_provider(|| { 251 - fetch::Fetcher::new(OAuthClient::new( 252 - AuthStore::new(), 253 - ClientData::new_public(CONFIG.oauth.clone()), 254 - )) 255 - }); 256 - let auth_state = use_signal(|| AuthState::default()); 257 - #[allow(unused)] 258 - let auth_state = use_context_provider(|| auth_state); 259 - #[cfg(all(target_family = "wasm", target_os = "unknown"))] 260 - let restore_result = { 261 - let fetcher = fetcher.clone(); 262 - use_resource(move || { 263 - let fetcher = fetcher.clone(); 264 - async move { auth::restore_session(fetcher, auth_state).await } 265 - }) 266 - }; 267 - #[cfg(not(all(target_family = "wasm", target_os = "unknown")))] 268 - let restore_result: Option<auth::RestoreResult> = None; 269 - 270 - #[cfg(all(target_family = "wasm", target_os = "unknown",))] 271 - { 272 - use_effect(move || { 273 - let fetcher = fetcher.clone(); 274 - spawn(async move { 275 - tracing::info!("Registering service worker"); 276 - let _ = service_worker::register_service_worker().await; 277 - }); 278 - }); 279 - } 280 - 281 - #[cfg(all(target_family = "wasm", target_os = "unknown"))] 282 - use_context_provider(|| restore_result); 283 - 284 - rsx! { 285 - document::Link { rel: "icon", href: FAVICON } 286 - // Preconnect for external fonts (before loading them) 287 - document::Link { rel: "preconnect", href: "https://fonts.googleapis.com" } 288 - document::Link { rel: "preconnect", href: "https://fonts.gstatic.com" } 289 - // Theme defaults first: CSS variables, font-faces, reset 290 - document::Link { rel: "stylesheet", href: THEME_DEFAULTS_CSS } 291 - document::Link { rel: "stylesheet", href: "https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:ital,wght@0,200;0,300;0,400;0,500;0,600;0,700;1,200;1,300;1,400;1,500;1,600;1,700&family=IBM+Plex+Sans:ital,wght@0,100..700;1,100..700&family=IBM+Plex+Serif:ital,wght@0,200;0,300;0,400;0,500;0,600;0,700;1,200;1,300;1,400;1,500;1,600;1,700&display=swap" } 292 - // App shell styles (depends on theme variables) 293 - document::Link { rel: "stylesheet", href: MAIN_CSS } 294 - // P2P collaboration node (provides CollabNode context for real-time sync) 295 - collab_context::CollabProvider { 296 - components::toast::ToastProvider { 297 - Router::<Route> {} 298 - } 299 - } 300 - } 301 - } 302 - 303 - // And then our Outlet is wrapped in a fallback UI 304 - #[component] 305 - fn ErrorLayout() -> Element { 306 - rsx! { 307 - ErrorBoundary { 308 - handle_error: move |_err: ErrorContext| { 309 - #[cfg(feature = "fullstack-server")] 310 - { 311 - let http_error = FullstackContext::commit_error_status(_err.error().unwrap()); 312 - match http_error.status { 313 - StatusCode::NOT_FOUND => rsx! { div { "404 - Page not found" } }, 314 - _ => rsx! { div { "An unknown error occurred" } }, 315 - } 316 - } 317 - #[cfg(not(feature = "fullstack-server"))] 318 - { 319 - rsx! { div { "An error occurred" } } 320 - } 321 - }, 322 - Outlet::<Route> {} 323 - } 324 - } 325 - } 326 - 327 - #[cfg(all(feature = "fullstack-server", feature = "server"))] 328 - pub async fn favicon() -> axum::response::Response { 329 - use axum::{http::header::CONTENT_TYPE, response::IntoResponse}; 330 - let favicon_bytes = include_bytes!("../assets/weaver_photo_sm.jpg"); 331 - 332 - ([(CONTENT_TYPE, "image/jpg")], favicon_bytes).into_response() 333 - } 334 - 335 - // #[server(endpoint = "static_routes", output = server_fn::codec::Json)] 336 - // async fn static_routes() -> Result<Vec<String>, ServerFnError> { 337 - // // The `Routable` trait has a `static_routes` method that returns all static routes in the enum 338 - // Ok(Route::static_routes() 339 - // .iter() 340 - // .map(ToString::to_string) 341 - // .collect()) 342 - // }
+58
crates/weaver-app/src/perf.rs
··· 1 + //! Performance timing utilities for instrumentation. 2 + //! 3 + //! Provides a cross-platform wrapper around Performance.now() for WASM 4 + //! and a no-op fallback for native builds. 5 + 6 + /// Get the current high-resolution timestamp in milliseconds. 7 + /// 8 + /// On WASM, this uses `Performance.now()` from the Web Performance API. 9 + /// On native builds, returns 0.0 (instrumentation is primarily for browser profiling). 10 + #[cfg(all(target_family = "wasm", target_os = "unknown"))] 11 + pub fn now() -> f64 { 12 + web_sys::window() 13 + .and_then(|w| w.performance()) 14 + .map(|p| p.now()) 15 + .unwrap_or(0.0) 16 + } 17 + 18 + #[cfg(not(all(target_family = "wasm", target_os = "unknown")))] 19 + pub fn now() -> f64 { 20 + 0.0 21 + } 22 + 23 + /// Measure the execution time of a closure and log it. 24 + /// 25 + /// Returns the closure's result and logs the elapsed time via tracing. 26 + #[allow(dead_code)] 27 + pub fn measure<T, F: FnOnce() -> T>(label: &str, f: F) -> T { 28 + let start = now(); 29 + let result = f(); 30 + let elapsed = now() - start; 31 + tracing::debug!(elapsed_ms = elapsed, "{}", label); 32 + result 33 + } 34 + 35 + /// A guard that logs elapsed time when dropped. 36 + /// 37 + /// Useful for timing blocks of code without closures. 38 + #[allow(dead_code)] 39 + pub struct TimingGuard { 40 + label: &'static str, 41 + start: f64, 42 + } 43 + 44 + impl TimingGuard { 45 + pub fn new(label: &'static str) -> Self { 46 + Self { 47 + label, 48 + start: now(), 49 + } 50 + } 51 + } 52 + 53 + impl Drop for TimingGuard { 54 + fn drop(&mut self) { 55 + let elapsed = now() - self.start; 56 + tracing::debug!(elapsed_ms = elapsed, "{}", self.label); 57 + } 58 + }