glassjar 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/glassjar.umd.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(a,Z){typeof exports=="object"&&typeof module<"u"?Z(exports):typeof define=="function"&&define.amd?define(["exports"],Z):(a=typeof globalThis<"u"?globalThis:a||self,Z(a.engine={}))})(this,(function(a){"use strict";var Z=typeof document<"u"?document.currentScript:null;function JA(Q){return Q&&Q.__esModule&&Object.prototype.hasOwnProperty.call(Q,"default")?Q.default:Q}var m={exports:{}},BA;function UA(){if(BA)return m.exports;BA=1;var Q=typeof Reflect=="object"?Reflect:null,A=Q&&typeof Q.apply=="function"?Q.apply:function(E,o,F){return Function.prototype.apply.call(E,o,F)},g;Q&&typeof Q.ownKeys=="function"?g=Q.ownKeys:Object.getOwnPropertySymbols?g=function(E){return Object.getOwnPropertyNames(E).concat(Object.getOwnPropertySymbols(E))}:g=function(E){return Object.getOwnPropertyNames(E)};function I(w){console&&console.warn&&console.warn(w)}var C=Number.isNaN||function(E){return E!==E};function B(){B.init.call(this)}m.exports=B,m.exports.once=rA,B.EventEmitter=B,B.prototype._events=void 0,B.prototype._eventsCount=0,B.prototype._maxListeners=void 0;var i=10;function D(w){if(typeof w!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof w)}Object.defineProperty(B,"defaultMaxListeners",{enumerable:!0,get:function(){return i},set:function(w){if(typeof w!="number"||w<0||C(w))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+w+".");i=w}}),B.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},B.prototype.setMaxListeners=function(E){if(typeof E!="number"||E<0||C(E))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+E+".");return this._maxListeners=E,this};function N(w){return w._maxListeners===void 0?B.defaultMaxListeners:w._maxListeners}B.prototype.getMaxListeners=function(){return N(this)},B.prototype.emit=function(E){for(var o=[],F=1;F<arguments.length;F++)o.push(arguments[F]);var M=E==="error",R=this._events;if(R!==void 0)M=M&&R.error===void 0;else if(!M)return!1;if(M){var G;if(o.length>0&&(G=o[0]),G instanceof Error)throw G;var q=new Error("Unhandled error."+(G?" ("+G.message+")":""));throw q.context=G,q}var b=R[E];if(b===void 0)return!1;if(typeof b=="function")A(b,this,o);else for(var YA=b.length,vA=W(b,YA),F=0;F<YA;++F)A(vA[F],this,o);return!0};function K(w,E,o,F){var M,R,G;if(D(o),R=w._events,R===void 0?(R=w._events=Object.create(null),w._eventsCount=0):(R.newListener!==void 0&&(w.emit("newListener",E,o.listener?o.listener:o),R=w._events),G=R[E]),G===void 0)G=R[E]=o,++w._eventsCount;else if(typeof G=="function"?G=R[E]=F?[o,G]:[G,o]:F?G.unshift(o):G.push(o),M=N(w),M>0&&G.length>M&&!G.warned){G.warned=!0;var q=new Error("Possible EventEmitter memory leak detected. "+G.length+" "+String(E)+" listeners added. Use emitter.setMaxListeners() to increase limit");q.name="MaxListenersExceededWarning",q.emitter=w,q.type=E,q.count=G.length,I(q)}return w}B.prototype.addListener=function(E,o){return K(this,E,o,!1)},B.prototype.on=B.prototype.addListener,B.prototype.prependListener=function(E,o){return K(this,E,o,!0)};function U(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function h(w,E,o){var F={fired:!1,wrapFn:void 0,target:w,type:E,listener:o},M=U.bind(F);return M.listener=o,F.wrapFn=M,M}B.prototype.once=function(E,o){return D(o),this.on(E,h(this,E,o)),this},B.prototype.prependOnceListener=function(E,o){return D(o),this.prependListener(E,h(this,E,o)),this},B.prototype.removeListener=function(E,o){var F,M,R,G,q;if(D(o),M=this._events,M===void 0)return this;if(F=M[E],F===void 0)return this;if(F===o||F.listener===o)--this._eventsCount===0?this._events=Object.create(null):(delete M[E],M.removeListener&&this.emit("removeListener",E,F.listener||o));else if(typeof F!="function"){for(R=-1,G=F.length-1;G>=0;G--)if(F[G]===o||F[G].listener===o){q=F[G].listener,R=G;break}if(R<0)return this;R===0?F.shift():x(F,R),F.length===1&&(M[E]=F[0]),M.removeListener!==void 0&&this.emit("removeListener",E,q||o)}return this},B.prototype.off=B.prototype.removeListener,B.prototype.removeAllListeners=function(E){var o,F,M;if(F=this._events,F===void 0)return this;if(F.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):F[E]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete F[E]),this;if(arguments.length===0){var R=Object.keys(F),G;for(M=0;M<R.length;++M)G=R[M],G!=="removeListener"&&this.removeAllListeners(G);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(o=F[E],typeof o=="function")this.removeListener(E,o);else if(o!==void 0)for(M=o.length-1;M>=0;M--)this.removeListener(E,o[M]);return this};function Y(w,E,o){var F=w._events;if(F===void 0)return[];var M=F[E];return M===void 0?[]:typeof M=="function"?o?[M.listener||M]:[M]:o?nA(M):W(M,M.length)}B.prototype.listeners=function(E){return Y(this,E,!0)},B.prototype.rawListeners=function(E){return Y(this,E,!1)},B.listenerCount=function(w,E){return typeof w.listenerCount=="function"?w.listenerCount(E):S.call(w,E)},B.prototype.listenerCount=S;function S(w){var E=this._events;if(E!==void 0){var o=E[w];if(typeof o=="function")return 1;if(o!==void 0)return o.length}return 0}B.prototype.eventNames=function(){return this._eventsCount>0?g(this._events):[]};function W(w,E){for(var o=new Array(E),F=0;F<E;++F)o[F]=w[F];return o}function x(w,E){for(;E+1<w.length;E++)w[E]=w[E+1];w.pop()}function nA(w){for(var E=new Array(w.length),o=0;o<E.length;++o)E[o]=w[o].listener||w[o];return E}function rA(w,E){return new Promise(function(o,F){function M(G){w.removeListener(E,R),F(G)}function R(){typeof w.removeListener=="function"&&w.removeListener("error",M),o([].slice.call(arguments))}RA(w,E,R,{once:!0}),E!=="error"&&uA(w,M,{once:!0})})}function uA(w,E,o){typeof w.on=="function"&&RA(w,"error",E,o)}function RA(w,E,o,F){if(typeof w.on=="function")F.once?w.once(E,o):w.on(E,o);else if(typeof w.addEventListener=="function")w.addEventListener(E,function M(R){F.once&&w.removeEventListener(E,M),o(R)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof w)}return m.exports}var SA=UA();const EA=JA(SA);class e{__destroy_into_raw(){const A=this.__wbg_ptr;return this.__wbg_ptr=0,iA.unregister(this),A}free(){const A=this.__destroy_into_raw();k.__wbg_dapadapter_free(A,0)}attach(A){k.dapadapter_attach(this.__wbg_ptr,A)}detach(){k.dapadapter_detach(this.__wbg_ptr)}constructor(){const A=k.dapadapter_new();return this.__wbg_ptr=A>>>0,iA.register(this,this.__wbg_ptr,this),this}on(A){k.dapadapter_on(this.__wbg_ptr,A)}resetRun(){k.dapadapter_resetRun(this.__wbg_ptr)}sendMessage(A){return k.dapadapter_sendMessage(this.__wbg_ptr,A)}setFilterInternals(A){k.dapadapter_setFilterInternals(this.__wbg_ptr,A)}}Symbol.dispose&&(e.prototype[Symbol.dispose]=e.prototype.free);class j{static __wrap(A){A=A>>>0;const g=Object.create(j.prototype);return g.__wbg_ptr=A,oA.register(g,g.__wbg_ptr,g),g}__destroy_into_raw(){const A=this.__wbg_ptr;return this.__wbg_ptr=0,oA.unregister(this),A}free(){const A=this.__destroy_into_raw();k.__wbg_trap_free(A,0)}static __wbg_wasmer_trap(){k.trap___wbg_wasmer_trap()}}Symbol.dispose&&(j.prototype[Symbol.dispose]=j.prototype.free);function hA(){let Q,A;try{const g=k.cpp_exception_hash();return Q=g[0],A=g[1],c(g[0],g[1])}finally{k.__wbindgen_free(Q,A,1)}}function DA(Q){const A=V(Q,k.__wbindgen_malloc,k.__wbindgen_realloc),g=d,I=k.prefetch_urls(A,g);var C=NA(I[0],I[1]).slice();return k.__wbindgen_free(I[0],I[1]*4,4),C}function LA(){return{__proto__:null,"./engine_bg.js":{__proto__:null,__wbg_BigInt_b7bbccdff258c9f2:function(A){return BigInt(A)},__wbg_Error_8c4e43fe74559d73:function(A,g){return Error(c(A,g))},__wbg_Number_04624de7d0e8332d:function(A){return Number(A)},__wbg_String_8f0eb39a4a4c2f66:function(A,g){const I=String(g),C=V(I,k.__wbindgen_malloc,k.__wbindgen_realloc),B=d;L().setInt32(A+4,B,!0),L().setInt32(A+0,C,!0)},__wbg___wbindgen_bigint_get_as_i64_8fcf4ce7f1ca72a2:function(A,g){const I=g,C=typeof I=="bigint"?I:void 0;L().setBigInt64(A+8,p(C)?BigInt(0):C,!0),L().setInt32(A+0,!p(C),!0)},__wbg___wbindgen_boolean_get_bbbb1c18aa2f5e25:function(A){const g=A,I=typeof g=="boolean"?g:void 0;return p(I)?16777215:I?1:0},__wbg___wbindgen_debug_string_0bc8482c6e3508ae:function(A,g){const I=_(g),C=V(I,k.__wbindgen_malloc,k.__wbindgen_realloc),B=d;L().setInt32(A+4,B,!0),L().setInt32(A+0,C,!0)},__wbg___wbindgen_function_table_5ae7216dfcbcc506:function(){return k.__wbindgen_export},__wbg___wbindgen_in_47fa6863be6f2f25:function(A,g){return A in g},__wbg___wbindgen_is_bigint_31b12575b56f32fc:function(A){return typeof A=="bigint"},__wbg___wbindgen_is_function_0095a73b8b156f76:function(A){return typeof A=="function"},__wbg___wbindgen_is_object_5ae8e5880f2c1fbd:function(A){const g=A;return typeof g=="object"&&g!==null},__wbg___wbindgen_is_string_cd444516edc5b180:function(A){return typeof A=="string"},__wbg___wbindgen_is_undefined_9e4d92534c42d778:function(A){return A===void 0},__wbg___wbindgen_jsval_eq_11888390b0186270:function(A,g){return A===g},__wbg___wbindgen_jsval_loose_eq_9dd77d8cd6671811:function(A,g){return A==g},__wbg___wbindgen_lt_bb59cc3d23526e0d:function(A,g){return A<g},__wbg___wbindgen_neg_6b4d356dff49dcc6:function(A){return-A},__wbg___wbindgen_number_get_8ff4255516ccad3e:function(A,g){const I=g,C=typeof I=="number"?I:void 0;L().setFloat64(A+8,p(C)?0:C,!0),L().setInt32(A+0,!p(C),!0)},__wbg___wbindgen_rethrow_05525c567f154472:function(A){throw A},__wbg___wbindgen_shr_ef8e07cce709eb54:function(A,g){return A>>g},__wbg___wbindgen_string_get_72fb696202c56729:function(A,g){const I=g,C=typeof I=="string"?I:void 0;var B=p(C)?0:V(C,k.__wbindgen_malloc,k.__wbindgen_realloc),i=d;L().setInt32(A+4,i,!0),L().setInt32(A+0,B,!0)},__wbg___wbindgen_throw_be289d5034ed271b:function(A,g){throw new Error(c(A,g))},__wbg__wbg_cb_unref_d9b87ff7982e3b21:function(A){A._wbg_cb_unref()},__wbg_addEventListener_3acb0aad4483804c:function(){return y(function(A,g,I,C){A.addEventListener(c(g,I),C)},arguments)},__wbg_apply_2e22c45cb4f12415:function(){return y(function(A,g,I){return Reflect.apply(A,g,I)},arguments)},__wbg_apply_ada2ee1a60ac7b3c:function(){return y(function(A,g,I){return A.apply(g,I)},arguments)},__wbg_arrayBuffer_bb54076166006c39:function(){return y(function(A){return A.arrayBuffer()},arguments)},__wbg_bind_1dc37de2b9939128:function(A,g,I,C){return A.bind(g,I,C)},__wbg_bind_29ba380591735d8c:function(A,g,I){return A.bind(g,I)},__wbg_buffer_7b5f53e46557d8f1:function(A){return A.buffer},__wbg_byteLength_7b03c17ff1e4037f:function(A){return A.byteLength},__wbg_byteLength_b5d783d06792ed2c:function(A){return A.byteLength},__wbg_call_389efe28435a9388:function(){return y(function(A,g){return A.call(g)},arguments)},__wbg_call_4708e0c13bdc8e95:function(){return y(function(A,g,I){return A.call(g,I)},arguments)},__wbg_compareExchange_b578410c358e695e:function(){return y(function(A,g,I,C){return Atomics.compareExchange(A,g>>>0,I,C)},arguments)},__wbg_constructor_ad6c0ed428f55d34:function(A){return A.constructor},__wbg_crypto_86f2631e91b51511:function(A){return A.crypto},__wbg_customSections_193491b069139fb1:function(A,g,I){return WebAssembly.Module.customSections(A,c(g,I))},__wbg_data_5330da50312d0bc1:function(A){return A.data},__wbg_done_57b39ecd9addfe81:function(A){return A.done},__wbg_entries_58c7934c745daac7:function(A){return Object.entries(A)},__wbg_error_7534b8e9a36f1ab4:function(A,g){let I,C;try{I=A,C=g,console.error(c(A,g))}finally{k.__wbindgen_free(I,C,1)}},__wbg_exports_794a42000dacd046:function(A){return WebAssembly.Module.exports(A)},__wbg_exports_86b4926134c40288:function(A){return A.exports},__wbg_fetch_d1488f40cef1e210:function(A,g,I){return A.fetch(c(g,I))},__wbg_from_bddd64e7d5ff6941:function(A){return Array.from(A)},__wbg_getPrototypeOf_2653517f1dc884d5:function(){return y(function(A){return Reflect.getPrototypeOf(A)},arguments)},__wbg_getRandomValues_b3f15fcbfabb0f8b:function(){return y(function(A,g){A.getRandomValues(g)},arguments)},__wbg_getTime_1e3cd1391c5c3995:function(A){return A.getTime()},__wbg_getTimezoneOffset_81776d10a4ec18a8:function(A){return A.getTimezoneOffset()},__wbg_getUint32_bb6f5a401408e7fa:function(A,g,I){return A.getUint32(g>>>0,I!==0)},__wbg_get_7efbcc3819719b0f:function(){return y(function(A,g){return A.get(g>>>0)},arguments)},__wbg_get_9b94d73e6221f75c:function(A,g){return A[g>>>0]},__wbg_get_b3ed3ad4be2bc8ac:function(){return y(function(A,g){return Reflect.get(A,g)},arguments)},__wbg_get_index_253dd2a9e007656d:function(A,g){return A[g>>>0]},__wbg_get_index_9a5bfdd2ca49c65f:function(A,g){return A[g>>>0]},__wbg_get_with_ref_key_1dc361bd10053bfe:function(A,g){return A[g]},__wbg_grow_5d42bf28c2da22cb:function(){return y(function(A,g){return A.grow(g>>>0)},arguments)},__wbg_grow_d034989fce14cc8e:function(){return y(function(A,g){return A.grow(g>>>0)},arguments)},__wbg_imports_8333d40ab24779ad:function(A){return WebAssembly.Module.imports(A)},__wbg_instanceof_ArrayBuffer_c367199e2fa2aa04:function(A){let g;try{g=A instanceof ArrayBuffer}catch{g=!1}return g},__wbg_instanceof_Error_8573fe0b0b480f46:function(A){let g;try{g=A instanceof Error}catch{g=!1}return g},__wbg_instanceof_Function_2a29eec978bb3b11:function(A){let g;try{g=A instanceof Function}catch{g=!1}return g},__wbg_instanceof_Global_2db767b6b2347f01:function(A){let g;try{g=A instanceof WebAssembly.Global}catch{g=!1}return g},__wbg_instanceof_Map_53af74335dec57f4:function(A){let g;try{g=A instanceof Map}catch{g=!1}return g},__wbg_instanceof_Memory_dc8c61e3f831ee37:function(A){let g;try{g=A instanceof WebAssembly.Memory}catch{g=!1}return g},__wbg_instanceof_Module_d0d412b14363ba9a:function(A){let g;try{g=A instanceof WebAssembly.Module}catch{g=!1}return g},__wbg_instanceof_Object_1c6af87502b733ed:function(A){let g;try{g=A instanceof Object}catch{g=!1}return g},__wbg_instanceof_RangeError_0b0dd056bc557b89:function(A){let g;try{g=A instanceof RangeError}catch{g=!1}return g},__wbg_instanceof_Response_ee1d54d79ae41977:function(A){let g;try{g=A instanceof Response}catch{g=!1}return g},__wbg_instanceof_SharedArrayBuffer_91d8a2fa16a2cc26:function(A){let g;try{g=A instanceof SharedArrayBuffer}catch{g=!1}return g},__wbg_instanceof_Table_127f216e592f4159:function(A){let g;try{g=A instanceof WebAssembly.Table}catch{g=!1}return g},__wbg_instanceof_Tag_f1d6b24a98b95210:function(A){let g;try{g=A instanceof WebAssembly.Tag}catch{g=!1}return g},__wbg_instanceof_Uint8Array_9b9075935c74707c:function(A){let g;try{g=A instanceof Uint8Array}catch{g=!1}return g},__wbg_isArray_d314bb98fcf08331:function(A){return Array.isArray(A)},__wbg_isSafeInteger_bfbc7332a9768d2a:function(A){return Number.isSafeInteger(A)},__wbg_is_f29129f676e5410c:function(A,g){return Object.is(A,g)},__wbg_iterator_6ff6560ca1568e55:function(){return Symbol.iterator},__wbg_length_32ed9a279acd054c:function(A){return A.length},__wbg_length_35a7bace40f36eac:function(A){return A.length},__wbg_length_aeb94ff17a8a8556:function(A){return A.length},__wbg_load_eff64ff5e429a422:function(){return y(function(A,g){return Atomics.load(A,g>>>0)},arguments)},__wbg_message_9ddc4b9a62a7c379:function(A){return A.message},__wbg_msCrypto_d562bbe83e0d4b91:function(A){return A.msCrypto},__wbg_new_0728bd2d4c5d41dd:function(){return y(function(A){return new WebAssembly.Tag(A)},arguments)},__wbg_new_0_73afc35eb544e539:function(){return new Date},__wbg_new_245cd5c49157e602:function(A){return new Date(A)},__wbg_new_2ac7fa8be584d280:function(A,g,I){return new DataView(A,g>>>0,I>>>0)},__wbg_new_361308b2356cecd0:function(){return new Object},__wbg_new_3eb36ae241fe6f44:function(){return new Array},__wbg_new_4a996a46a82782b6:function(){return y(function(A,g){return new WebAssembly.Global(A,g)},arguments)},__wbg_new_57c27ff3ddf5b62c:function(){return y(function(A){return new WebAssembly.Module(A)},arguments)},__wbg_new_67274f72d5abea37:function(){return y(function(A){return new WebAssembly.Table(A)},arguments)},__wbg_new_8a6f238a6ece86ea:function(){return new Error},__wbg_new_a4e3cab1cdd635ba:function(){return y(function(A,g){return new WebAssembly.Instance(A,g)},arguments)},__wbg_new_b061c0550d9f3281:function(){return y(function(A){return new WebAssembly.Memory(A)},arguments)},__wbg_new_b5d9e2fb389fef91:function(A,g){try{var I={a:A,b:g},C=(i,D)=>{const N=I.a;I.a=0;try{return qA(N,I.b,i,D)}finally{I.a=N}};return new Promise(C)}finally{I.a=I.b=0}},__wbg_new_ca409f861989e0c5:function(A){return new SharedArrayBuffer(A>>>0)},__wbg_new_dca287b076112a51:function(){return new Map},__wbg_new_dd2b680c8bf6ae29:function(A){return new Uint8Array(A)},__wbg_new_from_slice_a3d2629dc1826784:function(A,g){return new Uint8Array(n(A,g))},__wbg_new_no_args_1c7c842f08d00ebb:function(A,g){return new Function(c(A,g))},__wbg_new_with_args_7bba34e94b1cfa40:function(A,g,I,C){return new Function(c(A,g),c(I,C))},__wbg_new_with_byte_offset_9120ba79e057895b:function(A,g){return new Uint8Array(A,g>>>0)},__wbg_new_with_byte_offset_and_length_aa261d9c9da49eb1:function(A,g,I){return new Uint8Array(A,g>>>0,I>>>0)},__wbg_new_with_byte_offset_and_length_bc2e7b72cc96d1c1:function(A,g,I){return new Int32Array(A,g>>>0,I>>>0)},__wbg_new_with_length_1763c527b2923202:function(A){return new Array(A>>>0)},__wbg_new_with_length_a2c39cbe88fd8ff1:function(A){return new Uint8Array(A>>>0)},__wbg_next_3482f54c49e8af19:function(){return y(function(A){return A.next()},arguments)},__wbg_next_418f80d8f5303233:function(A){return A.next},__wbg_node_e1f24f89a7336c2e:function(A){return A.node},__wbg_notify_78a90977fab74963:function(){return y(function(A,g){return Atomics.notify(A,g>>>0)},arguments)},__wbg_now_a3af9a2f4bbaa4d1:function(){return Date.now()},__wbg_now_ebffdf7e580f210d:function(A){return A.now()},__wbg_ok_87f537440a0acf85:function(A){return A.ok},__wbg_postMessage_2041f4e90af61318:function(){return y(function(A,g){A.postMessage(g)},arguments)},__wbg_process_3975fd6c72f520aa:function(A){return A.process},__wbg_prototypesetcall_bdcdcc5842e4d77d:function(A,g,I){Uint8Array.prototype.set.call(n(A,g),I)},__wbg_push_8ffdcb2063340ba5:function(A,g){return A.push(g)},__wbg_queueMicrotask_0aa0a927f78f5d98:function(A){return A.queueMicrotask},__wbg_queueMicrotask_5bb536982f78a56f:function(A){queueMicrotask(A)},__wbg_randomFillSync_f8c153b79f285817:function(){return y(function(A,g){A.randomFillSync(g)},arguments)},__wbg_removeEventListener_e63328781a5b9af9:function(){return y(function(A,g,I,C){A.removeEventListener(c(g,I),C)},arguments)},__wbg_require_b74f47fc2d022fd6:function(){return y(function(){return module.require},arguments)},__wbg_resolve_002c4b7d9d8f6b64:function(A){return Promise.resolve(A)},__wbg_setTimeout_e0aacd5a637418a6:function(){return y(function(A,g,I){return A.setTimeout(g,I)},arguments)},__wbg_setUint32_d168af7751a8557e:function(A,g,I,C){A.setUint32(g>>>0,I>>>0,C!==0)},__wbg_set_0af2522656c2a71b:function(){return y(function(A,g,I){A.set(g>>>0,I)},arguments)},__wbg_set_1eb0999cf5d27fc8:function(A,g,I){return A.set(g,I)},__wbg_set_25cf9deff6bf0ea8:function(A,g,I){A.set(g,I>>>0)},__wbg_set_3f1d0b984ed272ed:function(A,g,I){A[g]=I},__wbg_set_6cb8631f80447a67:function(){return y(function(A,g,I){return Reflect.set(A,g,I)},arguments)},__wbg_set_cc56eefd2dd91957:function(A,g,I){A.set(n(g,I))},__wbg_set_f43e577aea94465b:function(A,g,I){A[g>>>0]=I},__wbg_set_index_b3244a6c458021e4:function(A,g,I){A[g>>>0]=I},__wbg_set_index_f259b54e97f7b177:function(A,g,I){A[g>>>0]=I},__wbg_set_onmessage_ea7cc2ba099021cd:function(A,g){A.onmessage=g},__wbg_set_value_fc06e541de098215:function(A,g){A.value=g},__wbg_slice_8bbd46adb2100583:function(A,g,I){return A.slice(g>>>0,I>>>0)},__wbg_stack_0ed75d68575b0f3c:function(A,g){const I=g.stack,C=V(I,k.__wbindgen_malloc,k.__wbindgen_realloc),B=d;L().setInt32(A+4,B,!0),L().setInt32(A+0,C,!0)},__wbg_static_accessor_GLOBAL_12837167ad935116:function(){const A=typeof global>"u"?null:global;return p(A)?0:t(A)},__wbg_static_accessor_GLOBAL_THIS_e628e89ab3b1c95f:function(){const A=typeof globalThis>"u"?null:globalThis;return p(A)?0:t(A)},__wbg_static_accessor_SELF_a621d3dfbb60d0ce:function(){const A=typeof self>"u"?null:self;return p(A)?0:t(A)},__wbg_static_accessor_WINDOW_f8727f0cf888e0bd:function(){const A=typeof window>"u"?null:window;return p(A)?0:t(A)},__wbg_store_d1d951c98d9bed41:function(){return y(function(A,g,I){return Atomics.store(A,g>>>0,I)},arguments)},__wbg_subarray_a96e1fef17ed23cb:function(A,g,I){return A.subarray(g>>>0,I>>>0)},__wbg_then_0d9fe2c7b1857d32:function(A,g,I){return A.then(g,I)},__wbg_then_b9e7b3b5f1a9e1b5:function(A,g){return A.then(g)},__wbg_toString_56d946daff83867b:function(A,g,I){const C=g.toString(I),B=V(C,k.__wbindgen_malloc,k.__wbindgen_realloc),i=d;L().setInt32(A+4,i,!0),L().setInt32(A+0,B,!0)},__wbg_toString_964ff7fe6eca8362:function(A){return A.toString()},__wbg_trap_new:function(A){return j.__wrap(A)},__wbg_validate_71c2d02a71bda62f:function(){return y(function(A){return WebAssembly.validate(A)},arguments)},__wbg_value_0546255b415e96c1:function(A){return A.value},__wbg_value_ce37a60e576310ff:function(A){return A.value},__wbg_versions_4e31226f5e8dc909:function(A){return A.versions},__wbg_wait_be5dae1e53f590f1:function(){return y(function(A,g,I){return Atomics.wait(A,g>>>0,I)},arguments)},__wbg_warn_81ab00e6e16e886d:function(A,g,I){console.warn(A,g,I)},__wbindgen_cast_0000000000000001:function(A,g){return f(A,g,k.wasm_bindgen_36932265c58943ab___closure__destroy___dyn_for__a__core_37ee0ce0c4cd57d5___ops__function__FnMut____a_js_sys_9eaf8169b8189500___Array____Output___core_37ee0ce0c4cd57d5___result__Result_js_sys_9eaf8169b8189500___Array__wasm_bindgen_36932265c58943ab___JsValue___,wA)},__wbindgen_cast_0000000000000002:function(A,g){return f(A,g,k.wasm_bindgen_36932265c58943ab___closure__destroy___dyn_for__a__core_37ee0ce0c4cd57d5___ops__function__FnMut____a_js_sys_9eaf8169b8189500___Array____Output___core_37ee0ce0c4cd57d5___result__Result_js_sys_9eaf8169b8189500___Array__wasm_bindgen_36932265c58943ab___JsValue___,wA)},__wbindgen_cast_0000000000000003:function(A,g){return f(A,g,k.wasm_bindgen_36932265c58943ab___closure__destroy___dyn_for__a__core_37ee0ce0c4cd57d5___ops__function__FnMut____a_js_sys_9eaf8169b8189500___Array____Output___core_37ee0ce0c4cd57d5___result__Result_js_sys_9eaf8169b8189500___Array__wasm_bindgen_36932265c58943ab___JsValue___,aA)},__wbindgen_cast_0000000000000004:function(A,g){return f(A,g,k.wasm_bindgen_36932265c58943ab___closure__destroy___dyn_core_37ee0ce0c4cd57d5___ops__function__FnMut__wasm_bindgen_36932265c58943ab___JsValue____Output_______,sA)},__wbindgen_cast_0000000000000005:function(A,g){return pA(A,g,k.wasm_bindgen_36932265c58943ab___closure__destroy___dyn_core_37ee0ce0c4cd57d5___ops__function__Fn__web_sys_ca373f7aaf47173f___features__gen_MessageEvent__MessageEvent____Output_______,cA)},__wbindgen_cast_0000000000000006:function(A,g){return f(A,g,k.wasm_bindgen_36932265c58943ab___closure__destroy___dyn_core_37ee0ce0c4cd57d5___ops__function__Fn__web_sys_ca373f7aaf47173f___features__gen_MessageEvent__MessageEvent____Output_______,HA)},__wbindgen_cast_0000000000000007:function(A){return A},__wbindgen_cast_0000000000000008:function(A){return A},__wbindgen_cast_0000000000000009:function(A,g){return n(A,g)},__wbindgen_cast_000000000000000a:function(A,g){return c(A,g)},__wbindgen_cast_000000000000000b:function(A,g){return BigInt.asUintN(64,A)|BigInt.asUintN(64,g)<<BigInt(64)},__wbindgen_cast_000000000000000c:function(A){return BigInt.asUintN(64,A)},__wbindgen_cast_000000000000000d:function(A,g){var I=NA(A,g).slice();return k.__wbindgen_free(A,g*4,4),I},__wbindgen_init_externref_table:function(){const A=k.__wbindgen_externrefs,g=A.grow(4);A.set(0,void 0),A.set(g+0,void 0),A.set(g+1,null),A.set(g+2,!0),A.set(g+3,!1)}}}}function sA(Q,A,g){k.wasm_bindgen_36932265c58943ab___convert__closures_____invoke___wasm_bindgen_36932265c58943ab___JsValue_____(Q,A,g)}function cA(Q,A,g){k.wasm_bindgen_36932265c58943ab___convert__closures_____invoke___web_sys_ca373f7aaf47173f___features__gen_MessageEvent__MessageEvent_____(Q,A,g)}function HA(Q,A,g){k.wasm_bindgen_36932265c58943ab___convert__closures_____invoke___web_sys_ca373f7aaf47173f___features__gen_MessageEvent__MessageEvent______1_(Q,A,g)}function aA(Q,A,g){const I=k.wasm_bindgen_36932265c58943ab___convert__closures________invoke___js_sys_9eaf8169b8189500___Array__core_37ee0ce0c4cd57d5___result__Result_____wasm_bindgen_36932265c58943ab___JsValue__(Q,A,g);if(I[1])throw $(I[0])}function wA(Q,A,g){const I=k.wasm_bindgen_36932265c58943ab___convert__closures________invoke___js_sys_9eaf8169b8189500___Array__core_37ee0ce0c4cd57d5___result__Result_js_sys_9eaf8169b8189500___Array__wasm_bindgen_36932265c58943ab___JsValue__(Q,A,g);if(I[2])throw $(I[1]);return $(I[0])}function qA(Q,A,g,I){k.wasm_bindgen_36932265c58943ab___convert__closures_____invoke___wasm_bindgen_36932265c58943ab___JsValue__wasm_bindgen_36932265c58943ab___JsValue_____(Q,A,g,I)}const iA=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(Q=>k.__wbg_dapadapter_free(Q>>>0,1)),oA=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(Q=>k.__wbg_trap_free(Q>>>0,1));function t(Q){const A=k.__externref_table_alloc();return k.__wbindgen_externrefs.set(A,Q),A}const P=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(Q=>Q.dtor(Q.a,Q.b));function _(Q){const A=typeof Q;if(A=="number"||A=="boolean"||Q==null)return`${Q}`;if(A=="string")return`"${Q}"`;if(A=="symbol"){const C=Q.description;return C==null?"Symbol":`Symbol(${C})`}if(A=="function"){const C=Q.name;return typeof C=="string"&&C.length>0?`Function(${C})`:"Function"}if(Array.isArray(Q)){const C=Q.length;let B="[";C>0&&(B+=_(Q[0]));for(let i=1;i<C;i++)B+=", "+_(Q[i]);return B+="]",B}const g=/\[object ([^\]]+)\]/.exec(toString.call(Q));let I;if(g&&g.length>1)I=g[1];else return toString.call(Q);if(I=="Object")try{return"Object("+JSON.stringify(Q)+")"}catch{return"Object"}return Q instanceof Error?`${Q.name}: ${Q.message}
|
|
2
|
-
${Q.stack}`:I}function NA(Q,A){Q=Q>>>0;const g=L(),I=[];for(let C=Q;C<Q+4*A;C+=4)I.push(k.__wbindgen_externrefs.get(g.getUint32(C,!0)));return k.__externref_drop_slice(Q,A),I}function n(Q,A){return Q=Q>>>0,z().subarray(Q/1,Q/1+A)}let O=null;function L(){return(O===null||O.buffer.detached===!0||O.buffer.detached===void 0&&O.buffer!==k.memory.buffer)&&(O=new DataView(k.memory.buffer)),O}function c(Q,A){return Q=Q>>>0,xA(Q,A)}let T=null;function z(){return(T===null||T.byteLength===0)&&(T=new Uint8Array(k.memory.buffer)),T}function y(Q,A){try{return Q.apply(this,A)}catch(g){const I=t(g);k.__wbindgen_exn_store(I)}}function p(Q){return Q==null}function pA(Q,A,g,I){const C={a:Q,b:A,cnt:1,dtor:g},B=(...i)=>{C.cnt++;try{return I(C.a,C.b,...i)}finally{B._wbg_cb_unref()}};return B._wbg_cb_unref=()=>{--C.cnt===0&&(C.dtor(C.a,C.b),C.a=0,P.unregister(C))},P.register(B,C,C),B}function f(Q,A,g,I){const C={a:Q,b:A,cnt:1,dtor:g},B=(...i)=>{C.cnt++;const D=C.a;C.a=0;try{return I(D,C.b,...i)}finally{C.a=D,B._wbg_cb_unref()}};return B._wbg_cb_unref=()=>{--C.cnt===0&&(C.dtor(C.a,C.b),C.a=0,P.unregister(C))},P.register(B,C,C),B}function V(Q,A,g){if(g===void 0){const D=X.encode(Q),N=A(D.length,1)>>>0;return z().subarray(N,N+D.length).set(D),d=D.length,N}let I=Q.length,C=A(I,1)>>>0;const B=z();let i=0;for(;i<I;i++){const D=Q.charCodeAt(i);if(D>127)break;B[C+i]=D}if(i!==I){i!==0&&(Q=Q.slice(i)),C=g(C,I,I=i+Q.length*3,1)>>>0;const D=z().subarray(C+i,C+I),N=X.encodeInto(Q,D);i+=N.written,C=g(C,I,i,1)>>>0}return d=i,C}function $(Q){const A=k.__wbindgen_externrefs.get(Q);return k.__externref_table_dealloc(Q),A}let r=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});r.decode();const dA=2146435072;let AA=0;function xA(Q,A){return AA+=A,AA>=dA&&(r=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),r.decode(),AA=A),r.decode(z().subarray(Q,Q+A))}const X=new TextEncoder;"encodeInto"in X||(X.encodeInto=function(Q,A){const g=X.encode(Q);return A.set(g),{read:Q.length,written:g.length}});let d=0,k;function ZA(Q,A){return k=Q.exports,O=null,T=null,k.__wbindgen_start(),k}async function OA(Q,A){if(typeof Response=="function"&&Q instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(Q,A)}catch(C){if(Q.ok&&g(Q.type)&&Q.headers.get("Content-Type")!=="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",C);else throw C}const I=await Q.arrayBuffer();return await WebAssembly.instantiate(I,A)}else{const I=await WebAssembly.instantiate(Q,A);return I instanceof WebAssembly.Instance?{instance:I,module:Q}:I}function g(I){switch(I){case"basic":case"cors":case"default":return!0}return!1}}async function VA(Q){if(k!==void 0)return k;Q!==void 0&&(Object.getPrototypeOf(Q)===Object.prototype?{module_or_path:Q}=Q:console.warn("using deprecated parameters for the initialization function; pass a single object instead")),Q===void 0&&(Q=new URL("",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:Z&&Z.tagName.toUpperCase()==="SCRIPT"&&Z.src||new URL("glassjar.umd.cjs",document.baseURI).href));const A=LA();(typeof Q=="string"||typeof Request=="function"&&Q instanceof Request||typeof URL=="function"&&Q instanceof URL)&&(Q=fetch(Q));const{instance:g,module:I}=await OA(await Q,A);return ZA(g)}const WA=new URL("https://cdn.jsdelivr.net/npm/glassjar@0.4.0/dist/engine_bg.wasm"),jA=Object.freeze({maxObjectBytes:128*1024*1024,maxEntries:256,maxMetadataBytes:8*1024*1024,maxEntryMetadataBytes:1024*1024});class tA{records=new Map;staged=new Map;stagingFailed=!1;objectBytes=0;metadataBytes=0;evictions=0;oversized=0;limits;constructor(A={}){this.limits=Object.freeze({...jA,...A});for(const g of Object.values(this.limits))if(!Number.isSafeInteger(g)||g<0)throw new RangeError("C++ cache limits must be nonnegative safe integers")}beginBatch(){this.discardBatch(),this.stagingFailed=!1}stage(A){if(this.stagingFailed)return;const g=this.recordSize(A);if(g===void 0||this.staged.has(A.source)){this.failBatch();return}const I=this.limits;for(;this.records.size&&(this.records.size+this.staged.size>=I.maxEntries||this.objectBytes+A.object.byteLength>I.maxObjectBytes||this.metadataBytes+g>I.maxMetadataBytes);)this.remove(this.records.keys().next().value),this.evictions++;if(this.records.size+this.staged.size>=I.maxEntries||this.objectBytes+A.object.byteLength>I.maxObjectBytes||this.metadataBytes+g>I.maxMetadataBytes||g>I.maxEntryMetadataBytes){this.oversized++,this.failBatch();return}this.staged.set(A.source,{...A,object:new Uint8Array(A.object),metadataBytes:g}),this.objectBytes+=A.object.byteLength,this.metadataBytes+=g}abandonBatch(){this.failBatch()}failBatch(){this.discardBatch(),this.stagingFailed=!0}recordSize(A){if(!(typeof A.source!="string"||!A.source.startsWith("/")||A.source.split("/").slice(1).some(g=>!g||g==="."||g==="..")||typeof A.key!="string"||typeof A.object_hash!="string"||!/^[a-f0-9]{64}$/.test(A.key)||!/^[a-f0-9]{64}$/.test(A.object_hash)||A.receipt!=null&&typeof A.receipt!="string"||!(A.object instanceof Uint8Array)))return new TextEncoder().encode(JSON.stringify({source:A.source,key:A.key,object_hash:A.object_hash,...A.receipt==null?{}:{receipt:A.receipt}})).byteLength}async validateBatch(){if(this.stagingFailed)return!1;const A=[...this.staged.values()];for(const g of A){if(!TA(g.object))return!1;const I=await crypto.subtle.digest("SHA-256",g.object);if(Array.from(new Uint8Array(I),B=>B.toString(16).padStart(2,"0")).join("")!==g.object_hash)return!1}return!0}commitBatch(){for(const[A,g]of this.staged)this.remove(A),this.records.set(A,g);this.staged.clear(),this.stagingFailed=!1}discardBatch(){for(const A of this.staged.values())this.objectBytes-=A.object.byteLength,this.metadataBytes-=A.metadataBytes;this.staged.clear()}snapshot(){return[...this.records.values()].map(({source:A,key:g,object_hash:I,object:C,receipt:B})=>({source:A,key:g,object_hash:I,...B==null?{}:{receipt:B},object:C.slice()}))}touch(A){const g=this.records.get(A);g&&(this.records.delete(A),this.records.set(A,g))}put(A){if(typeof A.source!="string"||!A.source.startsWith("/")||A.source.split("/").slice(1).some(B=>!B||B==="."||B==="..")||typeof A.key!="string"||typeof A.object_hash!="string"||!/^[a-f0-9]{64}$/.test(A.object_hash)||!/^[a-f0-9]{64}$/.test(A.key)||!(A.object instanceof Uint8Array))return;const g=this.recordSize(A);if(g===void 0)return;const I=this.limits;if(this.remove(A.source),I.maxEntries===0||A.object.byteLength>I.maxObjectBytes||g>I.maxMetadataBytes||g>I.maxEntryMetadataBytes){this.oversized++;return}for(;this.records.size>=I.maxEntries||this.objectBytes+A.object.byteLength>I.maxObjectBytes||this.metadataBytes+g>I.maxMetadataBytes;)this.remove(this.records.keys().next().value),this.evictions++;const C={...A,object:new Uint8Array(A.object),metadataBytes:g};this.records.set(A.source,C),this.objectBytes+=C.object.byteLength,this.metadataBytes+=g}delete(A){this.remove(A)}remove(A){const g=this.records.get(A);g&&(this.objectBytes-=g.object.byteLength,this.metadataBytes-=g.metadataBytes,this.records.delete(A))}clear(){this.records.clear(),this.staged.clear(),this.stagingFailed=!1,this.objectBytes=this.metadataBytes=0}stats(){return{objectBytes:this.objectBytes,metadataBytes:this.metadataBytes,entries:this.records.size,stagingEntries:this.staged.size,stagingObjectBytes:[...this.staged.values()].reduce((A,g)=>A+g.object.byteLength,0),stagingMetadataBytes:[...this.staged.values()].reduce((A,g)=>A+g.metadataBytes,0),evictions:this.evictions,oversized:this.oversized}}}function TA(Q){if(!WebAssembly.validate(Q)||Q.length<8)return!1;let A=8,g=!1;const I=()=>{let C=0,B=0;for(let i=0;i<5&&A<Q.length;i++,B+=7){const D=Q[A++];if(C+=(D&127)*2**B,!(D&128))return C}throw new Error("Malformed object section")};try{for(;A<Q.length;){const C=Q[A++],B=I(),i=A+B;if(i>Q.length||C===8)return!1;if(C===0){const D=I();if(A+D>i)return!1;const N=new TextDecoder().decode(Q.subarray(A,A+D));if(A+=D,N==="linking"){if(g||I()!==2)return!1;g=!0}}A=i}return g}catch{return!1}}const J=Symbol();function s(Q){return Q instanceof Error?{type:"error",error:{type:Q.constructor.name,message:Q.message}}:{type:"error",error:{type:typeof Q,message:String(Q)}}}class kA{name;data;constructor(A,g){this.name=A,this.data=g}download(){const A=new Uint8Array(this.data),g=new Blob([A]),I=URL.createObjectURL(g),C=document.createElement("a");C.href=I,C.download=this.name,document.body.appendChild(C),C.click(),document.body.removeChild(C),URL.revokeObjectURL(I)}}class FA extends EA{[J];dap;enabled=!0;set filterInternals(A){this.dap.setFilterInternals(A)}constructor(){super(),this[J]={attach:this.attach.bind(this),detach:this.detach.bind(this),beginRun:()=>this.dap.resetRun()},this.onMessage=this.onMessage.bind(this),this.dap=new e,this.dap.on(this.onMessage)}send(A){return this.dap.sendMessage(A)}artifactListener=A=>{if(A.data.type!=="artifact")return;const g=new kA(A.data.name,new Uint8Array(A.data.data));this.emit("artifact",g)};attach(A){A.addEventListener("message",this.artifactListener),this.dap.attach(A)}detach(A){A.removeEventListener("message",this.artifactListener),this.dap.detach()}onMessage(A){this.emit("event",A)}}const zA="glassjar-wasm:";function fA(Q,A){const g=new URL(String(Q),A);if(g.protocol!=="https:"&&g.protocol!=="http:")throw new TypeError(`Engine Wasm must be served over http(s), not ${g.protocol}`);return g.href}function XA(Q){return new Worker(""+(typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__dirname+"/assets/worker-KgNayWZL.js").href:new URL("assets/worker-KgNayWZL.js",typeof document>"u"?location.href:document.currentScript&&document.currentScript.tagName.toUpperCase()==="SCRIPT"&&document.currentScript.src||document.baseURI).href),{type:"module",name:Q?.name})}function lA(Q){return new XA(Q?{name:zA+Q}:void 0)}const bA="/dev/debugger-sh-host";class MA{buffer=new SharedArrayBuffer(4+64*1024);length=new Int32Array(this.buffer,0,1);bytes=new Uint8Array(this.buffer,4);publish(A){Atomics.store(this.length,0,A),Atomics.notify(this.length,0)}}function gA(Q){try{return new Error(`Host device callback failed: ${Q instanceof Error?Q.message:String(Q)}`)}catch{return new Error("Host device callback failed")}}function GA(Q){try{const A=Q?.();if(A&&typeof A.then=="function")return Promise.resolve(A).catch(()=>{}),new TypeError("Host device cleanup must be synchronous")}catch(A){return gA(A)}}class mA{constructor(A){this.onFailure=A}incoming=new MA;outgoing=new MA;workerStart={guest_to_host:this.incoming.buffer,host_to_guest:this.outgoing.buffer};abort=new AbortController;listeners=new Set;cleanup;worker;writing=!1;open(A){let g;try{g=A({signal:this.abort.signal,onData:I=>{if(this.assertOpen(),typeof I!="function")throw new TypeError("Host device listener must be a function");return this.listeners.add(I),()=>{this.listeners.delete(I)}},write:I=>this.write(I)})}catch(I){throw gA(I)}if(g!==void 0&&typeof g!="function")throw Promise.resolve(g).catch(()=>{}),new TypeError("Host device opener must return a cleanup function or undefined");if(typeof g=="function")if(this.abort.signal.aborted){const I=GA(g);if(I)throw I}else this.cleanup=g}attach(A){this.assertOpen(),this.worker=A,A.addEventListener("message",this.onMessage)}assertOpen(){if(this.abort.signal.aborted)throw new Error("Host device is closed")}async write(A){if(this.assertOpen(),!(A instanceof Uint8Array))throw new TypeError("Host device writes require Uint8Array");if(this.writing)throw new Error("Await the previous host device write before writing again");this.writing=!0;try{const g=new Uint8Array(A),I=this.outgoing;let C=0;for(;C<g.length;){this.assertOpen();const B=Atomics.load(I.length,0);if(B!==0){await Atomics.waitAsync(I.length,0,B).value;continue}const i=g.subarray(C,C+I.bytes.length);I.bytes.set(i),I.publish(i.length),C+=i.length}}finally{this.writing=!1}}onMessage=A=>{if(!(this.abort.signal.aborted||A.data?.type!=="host_wake"))try{const g=Atomics.load(this.incoming.length,0);if(g<=0)return;const I=this.incoming.bytes.slice(0,g);this.incoming.publish(0);for(const C of this.listeners){if(this.abort.signal.aborted)break;Promise.resolve(C(I)).catch(B=>this.fail(B))}}catch(g){this.fail(g)}};fail(A){this.abort.signal.aborted||(this.close(),this.onFailure(gA(A)))}close(){if(this.abort.signal.aborted)return;this.worker?.removeEventListener("message",this.onMessage),this.worker=void 0,this.incoming.publish(-1),this.outgoing.publish(-1),this.abort.abort(),this.listeners.clear();const A=this.cleanup;return this.cleanup=void 0,GA(A)}}const PA=["4847c7cda81eb51b1cec18fe40b396605579fe84e17eca2760702b8a9666e4e1"],u=Object.freeze({compiler:"24fbed474c7b5b4968fd73fc4827440b93fb351c1b6264516130300eff3e7bf5",sysroot:"8745c6af23fd841fa507d0c73f6b6b8e8da1b4ec216a6339739a28b38ff7227b",exceptions:"20986166552953de0e3ca5c1e9f341e7aec8b9ba54dcb244d0d2b2f9ca843ab4"});function yA(Q="legacy"){if(Q==="legacy")return{profile:Q,digests:u};if(Q==="stock-certified-v1"&&PA.length>0)return{profile:Q,digests:u};throw new Error(`The ${Q} toolchain is not available in this build`)}class l{#A;hashCount=3;hashMs;constructor(A,g){this.#A=A,this.hashMs=g}static async load(A,g,I,C=u.exceptions,B="legacy"){const i=yA(B);if(A.length!==2)throw new Error("Missing C++ toolchain assets");let D;const N=await Promise.allSettled(A.map(async W=>{try{const x=await fetch(W,{cache:"force-cache",signal:I});if(!x.ok)throw new Error(`Cannot load C++ toolchain (${x.status})`);return new Uint8Array(await x.arrayBuffer())}catch(x){throw D??={error:x},x}}));if(N[0].status==="rejected"||N[1].status==="rejected")throw D?.error;const[K,U]=[N[0].value,N[1].value],[h,Y]=await Promise.allSettled([l.ingestOwned(K,U,!1,C),g?Promise.resolve().then(()=>WebAssembly.compile(K)):Promise.resolve(void 0)]);if(h.status==="rejected")throw h.reason;const S=h.value;if(S.#A.compilerHash!==i.digests.compiler||S.#A.sysrootHash!==i.digests.sysroot||S.#A.exceptionsHash!==i.digests.exceptions)throw new Error("C++ toolchain integrity mismatch");if(I?.aborted)throw new DOMException("Toolchain loading aborted","AbortError");if(Y.status==="rejected")throw Y.reason;return S.#A.stockProfile=i.profile==="stock-certified-v1",S.#A.module=Y.value,S}static async fromBytes(A,g,I){const C=new Uint8Array(A),B=new Uint8Array(g);return l.ingestOwned(C,B,I,u.exceptions)}static async ingestOwned(A,g,I,C){const B=performance.now(),i=await Promise.allSettled([KA(A),KA(g)]);if(i[0].status==="rejected")throw i[0].reason;if(i[1].status==="rejected")throw i[1].reason;const[D,N]=[i[0].value,i[1].value],K=I?await WebAssembly.compile(A):void 0;return new l({compiler:A,sysroot:g,compilerHash:D,sysrootHash:N,exceptionsHash:C,module:K},performance.now()-B)}matchesExpectation(A){return A.compilerSha256===this.#A.compilerHash&&A.sysrootSha256===this.#A.sysrootHash&&A.exceptionsSha256===this.#A.exceptionsHash}get identity(){return`${this.#A.compilerHash}:${this.#A.sysrootHash}:${this.#A.exceptionsHash}`}get identityBytes(){return this.#A.compiler.byteLength+this.#A.sysroot.byteLength}get compilerBytes(){return this.#A.compiler.byteLength}configure(A,g){try{return A.postMessage({...g,toolchain:this.#A}),!!this.#A.module}catch(I){if(!(I instanceof DOMException)||I.name!=="DataCloneError"||!this.#A.module)throw I;return A.postMessage({...g,toolchain:{...this.#A,module:void 0}}),!1}}}async function KA(Q){const A=await crypto.subtle.digest("SHA-256",Q);return Array.from(new Uint8Array(A),g=>g.toString(16).padStart(2,"0")).join("")}let IA,v;class CA{stdout=new QA(1);stderr=new QA(2);stdin=new H;debugger;lang;scope;fs={};binaryFiles={};cppArtifacts;hostDevice;options;retain;idleTimeoutMs;wasmUrl;objects;generation=0;scopeEpoch=0;operationId=0;disposed=!1;active;promise;slot;idleTimer;toolchain;toolchainLoading;toolchainController;initializing=new Set;toolchainIdentity;toolchainIngestions=0;toolchainHashCount=0;toolchainHashMs=0;compilerModuleCloned=!1;disposal;cancellationDraining;releaseDrain;releases=new Set;retirements=0;latest;cacheValidation;static async create(A,g={}){const{wasmUrl:I,...C}=g,B=I===void 0?void 0:fA(I,globalThis.location?.href),i=structuredClone(C),D=B??null;if(v!==void 0&&v!==D)throw new Error("The engine Wasm is already loaded from a different wasmUrl");v=D,IA??=VA({module_or_path:B??WA}).catch(K=>{throw IA=void 0,v=void 0,K}),await IA;const N=new CA(A,i);if(N.wasmUrl=B,A!=="c"&&typeof window<"u"&&typeof fetch<"u")for(const K of DA(A))fetch(K,{cache:"force-cache"}).then(U=>U.arrayBuffer()).catch(()=>{});return N}constructor(A,g){const I=g.cpp;this.retain=g.retainWorker??I?.retainWorker??!0;const C=g.idleTimeoutMs??I?.idleTimeoutMs??3e4;if(!Number.isSafeInteger(C)||C<1||C>3e5)throw new RangeError("Worker idle timeout must be between 1 and 300000 milliseconds");if(this.idleTimeoutMs=C,I){if(A!=="c")throw new TypeError("C++ performance options require C/C++");if(!I.scope?.projectId||!I.scope.accountId)throw new TypeError("C++ performance options require project and account identity");if(I.compilerLifetime!==void 0&&!["idle","project"].includes(I.compilerLifetime))throw new TypeError("Invalid compiler lifetime");yA(I.toolchainProfile),this.scope=Object.freeze({...I.scope}),this.options=Object.freeze({...I,scope:this.scope,idleTimeoutMs:C})}this.objects=new tA(typeof I?.objectCache=="object"?I.objectCache:{}),this.debugger=new FA,this.lang=A}get cacheCompilerModule(){return this.options?.cacheCompilerModule??this.retain}get cacheStats(){return structuredClone({...this.objects.stats(),generation:this.generation,scopeEpoch:this.scopeEpoch,operationId:this.operationId,cacheEpoch:this.generation,toolchainProfile:this.options?.toolchainProfile??"legacy",cacheEligible:this.cacheValidation?.eligible??!1,stockCertificateSha256:this.cacheValidation?.certificate,cacheEligibilitySnapshot:this.cacheValidation?.snapshot,cacheEligibilityOperationId:this.cacheValidation?.operationId,cacheEligibilityReason:this.cacheValidation?.reason,toolchainIdentityBytes:this.toolchain?.identityBytes??0,toolchainIngestions:this.toolchainIngestions,toolchainHashCount:this.toolchainHashCount,toolchainHashMs:this.toolchainHashMs,compilerModuleCloned:this.compilerModuleCloned,workerRetained:!!this.slot&&!this.active,workerRetirements:this.retirements,compilerModuleIdentityBytes:this.cacheCompilerModule?this.toolchain?.compilerBytes??0:0,latest:this.active?.stats??this.latest})}clearCaches(){this.cacheValidation=void 0,this.generation++,this.objects.clear(),this.toolchain=void 0,this.active||(this.toolchainController?.abort(),this.toolchainLoading=void 0),this.active||this.retireWorker()}stop(){return this.clearCaches(),this.cancelCurrentOperation()}cancelCurrentOperation(){if(this.cancellationDraining)return this.cancellationDraining;this.operationId++;const A=this.promise,g=this.active?.publication;this.retireWorker(),this.objects.discardBatch(),this.active&&this.finish(this.active,{type:"stopped"});const I=Promise.allSettled([A,g]).then(()=>{this.cancellationDraining===I&&(this.cancellationDraining=void 0)});return this.cancellationDraining=I,I}releaseCompilerResources(A={}){const g=A.signal;return g?.aborted?Promise.resolve("cancelled"):this.disposed?Promise.resolve("released"):new Promise(I=>{const C={resolve:I,signal:g,abort:()=>this.settleRelease(C,"cancelled")};this.releases.add(C),g?.addEventListener("abort",C.abort,{once:!0}),this.flushReleases()})}settleRelease(A,g){this.releases.delete(A)&&(A.signal?.removeEventListener("abort",A.abort),A.resolve(g))}flushReleases(){if(!(this.active||!this.releases.size||this.releaseDrain)){if(this.initializing.size){this.toolchainController?.abort();const A=[...this.initializing];this.toolchainLoading=void 0,this.releaseDrain=Promise.allSettled(A).then(()=>{this.releaseDrain=void 0,this.flushReleases()});return}this.retireWorker(),this.toolchainController?.abort(),this.toolchain=void 0,this.toolchainLoading=void 0;for(const A of this.releases)this.settleRelease(A,"released")}}dispose(){if(this.disposal)return this.disposal;this.disposed=!0,this.scopeEpoch++,this.fs={},this.binaryFiles={},this.cppArtifacts=void 0,this.hostDevice=void 0,this.stdout.removeAllListeners(),this.stderr.removeAllListeners(),this.debugger.removeAllListeners();const A=[...this.initializing];return this.toolchainController?.abort(),this.disposal=Promise.allSettled([this.stop(),...A]).then(()=>{this.latest=void 0,this.flushReleases()}),this.disposal}prepareCompiler(A){if(A?.validateCacheInputs!==void 0&&typeof A.validateCacheInputs!="boolean")return Promise.resolve(s(new TypeError("Invalid compiler preparation options")));const g=A?.validateCacheInputs===!0&&this.options?.toolchainProfile==="stock-certified-v1"&&!!this.options?.objectCache&&this.objects.limits.maxEntries>0&&this.objects.limits.maxObjectBytes>0&&this.objects.limits.maxMetadataBytes>0&&this.objects.limits.maxEntryMetadataBytes>0;return this.submit(!0,!0,g)}run(){return this.submit(!1)}compile(){return this.submit(!0)}submit(A,g=!1,I=!1){if(this.disposed)return Promise.resolve(s(new Error("Engine is disposed")));if(this.active||this.cancellationDraining)return Promise.resolve(s(new Error("An engine job is already active")));if(A&&this.lang!=="c")return Promise.resolve(s(new Error("Compile-only is supported for C/C++")));this.cacheValidation=void 0;const C=g&&!I;let B;try{const Y=C||!this.cppArtifacts?null:{...this.cppArtifacts};if(Y?.cacheCertificate!==void 0){const S=Y.cacheCertificate;(typeof S!="string"||S.length>1024*1024||new TextEncoder().encode(S).byteLength>1024*1024)&&delete Y.cacheCertificate}B={fs:C?{}:structuredClone(this.fs),binary_files:Object.fromEntries(Object.entries(C?{}:this.binaryFiles).map(([S,W])=>[S,new Uint8Array(W)])),cpp_artifacts:structuredClone(Y)}}catch(Y){return Promise.resolve(s(Y))}const i=!A&&this.debugger.enabled,D=A?void 0:this.hostDevice;if(D!==void 0&&(typeof D!="function"||!["c","python"].includes(this.lang)))return Promise.resolve(s(new TypeError("Invalid host device configuration")));clearTimeout(this.idleTimer),this.stdin[J].clear();const N=!!this.slot;let K;const U=new Promise(Y=>{K=Y});this.promise=U;const h={generation:this.generation,scopeEpoch:this.scopeEpoch,operationId:++this.operationId,cacheEpoch:this.generation,prepareOnly:g,validateCacheInputs:I,settled:!1,buildOnly:A,debug:i,opener:D,startedAt:performance.now(),resolve:K,stats:{operation:g?"prepare_compiler":A?"compile":"run",workerReadyMs:0,workerReused:N},start:{...B,lang:this.lang,prepare_compiler:g,validate_cache_inputs:I,scope_epoch:this.scopeEpoch,operation_id:this.operationId,cache_epoch:this.generation,is_debug:i,build_only:A,stdin_buffer:this.stdin[J].buffer,cpp_cache:this.options?.objectCache&&!i&&!g?{generation:this.generation,entries:this.objects.snapshot(),max_entry_metadata_bytes:Math.min(this.objects.limits.maxEntryMetadataBytes,this.objects.limits.maxMetadataBytes,1024*1024)}:null}};this.objects.beginBatch(),this.active=h;try{if(this.slot||this.makeWorker(),!this.current(h))return U;const Y=this.slot;this.lang==="c"&&!this.toolchain&&this.ensureToolchain().catch(S=>{this.current(h)&&this.slot===Y&&this.finish(h,s(S))}),this.slot.ready&&this.dispatch(h)}catch(Y){this.finish(h,s(Y))}return U}current(A){return this.active===A&&!A.settled}makeWorker(){const A=lA(this.wasmUrl),g={worker:A,ready:!1,remove:()=>{}};this.slot=g;const I=i=>{if(this.slot!==g)return;const D=i.data,N=this.active;if(D.type==="ready"){if(g.ready)return;g.ready=!0,N&&this.current(N)&&this.dispatch(N);return}if(!(!N||!this.current(N))){if(!g.ready&&D.type==="error"){this.finish(N,s(new Error(D.message)));return}if(!(D.operationId!==N.operationId||D.scopeEpoch!==N.scopeEpoch))try{if(D.type==="cpp_cache_eligibility"){if(this.options?.toolchainProfile!=="stock-certified-v1"||N.prepareOnly&&!N.validateCacheInputs)return;const K=h=>typeof h=="string"&&/^[0-9a-f]{64}$/.test(h),U=D.eligible===!0&&K(D.certificate_sha256)&&K(D.snapshot);this.cacheValidation={eligible:U,certificate:K(D.certificate_sha256)?D.certificate_sha256:void 0,snapshot:U?D.snapshot:void 0,operationId:N.operationId,reason:U?void 0:typeof D.reason=="string"?D.reason.slice(0,128):"stock-input-validation"}}else if(D.type==="stop")this.finish(N,{type:"completed",exitCode:D.exit_code,timing:{totalMs:performance.now()-N.startedAt,buildMs:D.build_ms,runMs:D.run_ms}});else if(D.type==="error")this.finish(N,s(new Error(D.message)));else if(D.type==="cpp_cache_object"&&D.generation===this.generation&&N.generation===this.generation)try{this.objects.stage(D)}catch{this.objects.abandonBatch()}else D.type==="cpp_cache_stats"&&D.generation===N.generation?N.stats.cache=D.stats:D.type==="cpp_cache_abandon"?this.objects.abandonBatch():D.type==="object_build_complete"?N.publication??=this.publishObjects(N,g):D.type==="compiler_module_stats"&&(N.stats.compilerModule=D)}catch(K){this.finish(N,s(K))}}},C=i=>{this.slot===g&&(this.clearCaches(),this.active?this.finish(this.active,s(i.error??new Error(i.message))):this.retireWorker())},B=()=>C({message:"Unreadable execution worker message"});this.debugger[J].attach(A),A.addEventListener("message",I),A.addEventListener("error",C),A.addEventListener("messageerror",B),g.remove=()=>{A.removeEventListener("message",I),A.removeEventListener("error",C),A.removeEventListener("messageerror",B),this.debugger[J].detach(A)}}async publishObjects(A,g){let I=!1;try{I=await this.objects.validateBatch()}catch{}if(!(!this.current(A)||this.slot!==g)){try{I&&A.cacheEpoch===this.generation?this.objects.commitBatch():(this.objects.abandonBatch(),this.cacheValidation?.operationId===A.operationId&&(this.cacheValidation={...this.cacheValidation,eligible:!1,snapshot:void 0,reason:"stock-publication-budget-or-validation"}))}catch{this.objects.clear(),this.cacheValidation?.operationId===A.operationId&&(this.cacheValidation={...this.cacheValidation,eligible:!1,snapshot:void 0,reason:"stock-publication-failure"})}this.current(A)&&g.worker.postMessage({type:"object_build_ack",scopeEpoch:A.scopeEpoch,operationId:A.operationId,cacheEpoch:A.cacheEpoch})}}ensureToolchain(){if(this.toolchain)return Promise.resolve(this.toolchain);if(this.toolchainLoading)return this.toolchainLoading;this.toolchainController=new AbortController;const A=l.load(DA("c"),this.cacheCompilerModule,this.toolchainController.signal,hA(),this.options?.toolchainProfile);return this.toolchainLoading=A,this.initializing.add(A),A.then(()=>this.initializing.delete(A),()=>{this.initializing.delete(A),this.toolchainLoading===A&&(this.toolchainLoading=void 0)}),A}async dispatch(A){const g=this.slot;if(!(!this.current(A)||!g))try{if(this.lang==="c"){const B=this.scopeEpoch,i=this.generation,D=this.ensureToolchain(),N=this.toolchain??await D;if(!this.current(A)||this.slot!==g||B!==this.scopeEpoch)return;const K=A.start.cpp_artifacts?.requiredToolchain;if(K&&!N.matchesExpectation(K)){this.finish(A,{type:"error",error:{type:"artifact-toolchain-integrity",message:"C++ artifacts require a different compiler, sysroot, or exception runtime"}});return}i===this.generation&&(this.toolchainIdentity&&this.toolchainIdentity!==N.identity&&(this.objects.clear(),A.start.cpp_cache=null),this.toolchain!==N&&(this.toolchainIngestions++,this.toolchainHashCount+=N.hashCount,this.toolchainHashMs+=N.hashMs),this.toolchainIdentity=N.identity,this.toolchain=N,this.toolchainLoading===D&&(this.toolchainLoading=void 0)),g.toolchain!==N&&(this.compilerModuleCloned=N.configure(g.worker,{type:"configure_cpp",cacheCompilerModule:this.cacheCompilerModule}),g.toolchain=N)}if(!this.current(A)||this.slot!==g)return;const I=g.worker;A.stats.workerReadyMs=performance.now()-A.startedAt;const C=B=>this.current(A)&&B.scopeEpoch===A.scopeEpoch&&B.operationId===A.operationId;if(this.stdout[J].attach(I,C),this.stderr[J].attach(I,C),A.prepareOnly||this.debugger[J].beginRun(),A.opener){if(A.device=new mA(B=>this.finish(A,s(B))),A.device.attach(I),A.device.open(A.opener),!this.current(A))return;A.start.host_device=A.device.workerStart}this.current(A)&&(I.postMessage(A.start),A.start.fs={},A.start.binary_files={},A.start.cpp_artifacts=null,A.start.cpp_cache=null)}catch(I){this.current(A)&&(this.toolchainLoading=void 0,this.finish(A,s(I)))}}finish(A,g){if(!this.current(A))return;(g.type!=="completed"||g.exitCode!==0)&&(this.cacheValidation=void 0),A.settled=!0;const I=this.slot?.worker;I&&(this.stdout[J].detach(I),this.stderr[J].detach(I));const C=A.device?.close();C&&(g=s(C));const B=g.type==="completed"&&A.generation===this.generation&&!this.disposed,i=B&&g.type==="completed"&&g.exitCode===0;if(A.generation===this.generation)for(const D of A.stats.cache?.invalid_sources??[])this.objects.delete(D);if(i)for(const D of A.stats.cache?.hit_sources??[])this.objects.touch(D);this.objects.discardBatch(),this.latest=A.stats,this.stdin[J].clear(),(!B||!this.retain)&&this.retireWorker(),!this.disposed&&A.cacheEpoch===this.generation&&(this.slot||this.toolchain&&this.cacheCompilerModule)&&this.options?.compilerLifetime!=="project"&&(this.idleTimer=setTimeout(()=>{this.retireWorker(),this.toolchain=void 0,this.toolchainLoading=void 0},this.idleTimeoutMs)),!this.retain&&!this.cacheCompilerModule&&(this.toolchain=void 0),A.cacheEpoch!==this.generation&&(this.toolchainController?.abort(),this.toolchainLoading=void 0),this.active=void 0,this.promise=void 0,this.flushReleases(),A.resolve(g)}retireWorker(){clearTimeout(this.idleTimer);const A=this.slot;A&&(this.slot=void 0,A.remove(),this.stdout[J].detach(A.worker),this.stderr[J].detach(A.worker),A.worker.onerror=g=>g.preventDefault(),A.worker.terminate(),this.retirements++)}}class QA extends EA{constructor(A){super(),this.mode=A,this.callback=(g=>{const I=g.data;if(this.accepts&&!this.accepts(I)||I.type!=="stdout"||I.mode!==this.mode)return;const C=I.data;this.emit("data",C)}).bind(this),this[J]={attach:this.attach.bind(this),detach:this.detach.bind(this)}}callback;accepts;[J];attach(A,g){this.accepts=g,A.addEventListener("message",this.callback)}detach(A){A.removeEventListener("message",this.callback)}}class H{static BUFFER_SIZE=2048;static HEADER_SIZE=8;static DATA_SIZE=H.BUFFER_SIZE-H.HEADER_SIZE;static READ_IDX=0;static WRITE_IDX=1;static encoder=new TextEncoder;buffer=new SharedArrayBuffer(H.BUFFER_SIZE);generation=0;indices;data;[J];constructor(){this.indices=new Int32Array(this.buffer,0,2),this.data=new Int8Array(this.buffer,H.HEADER_SIZE);const A=()=>this.buffer;this[J]={clear:this.clear.bind(this),get buffer(){return A()}}}clear(){this.generation++,Atomics.notify(this.indices,H.READ_IDX),this.buffer=new SharedArrayBuffer(H.BUFFER_SIZE),this.indices=new Int32Array(this.buffer,0,2),this.data=new Int8Array(this.buffer,H.HEADER_SIZE)}async write(A){const g=typeof A=="string"?H.encoder.encode(A):A;return this.writeBytes(g)}async writeBytes(A){const{DATA_SIZE:g,READ_IDX:I,WRITE_IDX:C}=H;let B=0;const i=this.generation;for(;B<A.length&&i===this.generation;){const D=Atomics.load(this.indices,I);let N=Atomics.load(this.indices,C);N===g-1&&D>0&&(N=0);const K=D<=N?g-N-1:D-N-1;if(K===0){await Atomics.waitAsync(this.indices,I,D).value;continue}const U=Math.min(A.length-B,K);this.data.set(A.subarray(B,B+U),N),Atomics.store(this.indices,C,(N+U)%g),Atomics.notify(this.indices,C),B+=U}}}a.Artifact=kA,a.Debugger=FA,a.Engine=CA,a.HOST_DEVICE_PATH=bA,a.Stdin=H,a.Stdout=QA,Object.defineProperty(a,Symbol.toStringTag,{value:"Module"})}));
|
|
1
|
+
(function(a,O){typeof exports=="object"&&typeof module<"u"?O(exports):typeof define=="function"&&define.amd?define(["exports"],O):(a=typeof globalThis<"u"?globalThis:a||self,O(a.engine={}))})(this,(function(a){"use strict";var O=typeof document<"u"?document.currentScript:null;function SA(Q){return Q&&Q.__esModule&&Object.prototype.hasOwnProperty.call(Q,"default")?Q.default:Q}var m={exports:{}},DA;function hA(){if(DA)return m.exports;DA=1;var Q=typeof Reflect=="object"?Reflect:null,A=Q&&typeof Q.apply=="function"?Q.apply:function(E,o,F){return Function.prototype.apply.call(E,o,F)},g;Q&&typeof Q.ownKeys=="function"?g=Q.ownKeys:Object.getOwnPropertySymbols?g=function(E){return Object.getOwnPropertyNames(E).concat(Object.getOwnPropertySymbols(E))}:g=function(E){return Object.getOwnPropertyNames(E)};function I(w){console&&console.warn&&console.warn(w)}var C=Number.isNaN||function(E){return E!==E};function B(){B.init.call(this)}m.exports=B,m.exports.once=x,B.EventEmitter=B,B.prototype._events=void 0,B.prototype._eventsCount=0,B.prototype._maxListeners=void 0;var i=10;function D(w){if(typeof w!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof w)}Object.defineProperty(B,"defaultMaxListeners",{enumerable:!0,get:function(){return i},set:function(w){if(typeof w!="number"||w<0||C(w))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+w+".");i=w}}),B.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},B.prototype.setMaxListeners=function(E){if(typeof E!="number"||E<0||C(E))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+E+".");return this._maxListeners=E,this};function N(w){return w._maxListeners===void 0?B.defaultMaxListeners:w._maxListeners}B.prototype.getMaxListeners=function(){return N(this)},B.prototype.emit=function(E){for(var o=[],F=1;F<arguments.length;F++)o.push(arguments[F]);var M=E==="error",R=this._events;if(R!==void 0)M=M&&R.error===void 0;else if(!M)return!1;if(M){var G;if(o.length>0&&(G=o[0]),G instanceof Error)throw G;var p=new Error("Unhandled error."+(G?" ("+G.message+")":""));throw p.context=G,p}var b=R[E];if(b===void 0)return!1;if(typeof b=="function")A(b,this,o);else for(var UA=b.length,vA=q(b,UA),F=0;F<UA;++F)A(vA[F],this,o);return!0};function K(w,E,o,F){var M,R,G;if(D(o),R=w._events,R===void 0?(R=w._events=Object.create(null),w._eventsCount=0):(R.newListener!==void 0&&(w.emit("newListener",E,o.listener?o.listener:o),R=w._events),G=R[E]),G===void 0)G=R[E]=o,++w._eventsCount;else if(typeof G=="function"?G=R[E]=F?[o,G]:[G,o]:F?G.unshift(o):G.push(o),M=N(w),M>0&&G.length>M&&!G.warned){G.warned=!0;var p=new Error("Possible EventEmitter memory leak detected. "+G.length+" "+String(E)+" listeners added. Use emitter.setMaxListeners() to increase limit");p.name="MaxListenersExceededWarning",p.emitter=w,p.type=E,p.count=G.length,I(p)}return w}B.prototype.addListener=function(E,o){return K(this,E,o,!1)},B.prototype.on=B.prototype.addListener,B.prototype.prependListener=function(E,o){return K(this,E,o,!0)};function U(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function L(w,E,o){var F={fired:!1,wrapFn:void 0,target:w,type:E,listener:o},M=U.bind(F);return M.listener=o,F.wrapFn=M,M}B.prototype.once=function(E,o){return D(o),this.on(E,L(this,E,o)),this},B.prototype.prependOnceListener=function(E,o){return D(o),this.prependListener(E,L(this,E,o)),this},B.prototype.removeListener=function(E,o){var F,M,R,G,p;if(D(o),M=this._events,M===void 0)return this;if(F=M[E],F===void 0)return this;if(F===o||F.listener===o)--this._eventsCount===0?this._events=Object.create(null):(delete M[E],M.removeListener&&this.emit("removeListener",E,F.listener||o));else if(typeof F!="function"){for(R=-1,G=F.length-1;G>=0;G--)if(F[G]===o||F[G].listener===o){p=F[G].listener,R=G;break}if(R<0)return this;R===0?F.shift():BA(F,R),F.length===1&&(M[E]=F[0]),M.removeListener!==void 0&&this.emit("removeListener",E,p||o)}return this},B.prototype.off=B.prototype.removeListener,B.prototype.removeAllListeners=function(E){var o,F,M;if(F=this._events,F===void 0)return this;if(F.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):F[E]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete F[E]),this;if(arguments.length===0){var R=Object.keys(F),G;for(M=0;M<R.length;++M)G=R[M],G!=="removeListener"&&this.removeAllListeners(G);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(o=F[E],typeof o=="function")this.removeListener(E,o);else if(o!==void 0)for(M=o.length-1;M>=0;M--)this.removeListener(E,o[M]);return this};function Y(w,E,o){var F=w._events;if(F===void 0)return[];var M=F[E];return M===void 0?[]:typeof M=="function"?o?[M.listener||M]:[M]:o?EA(M):q(M,M.length)}B.prototype.listeners=function(E){return Y(this,E,!0)},B.prototype.rawListeners=function(E){return Y(this,E,!1)},B.listenerCount=function(w,E){return typeof w.listenerCount=="function"?w.listenerCount(E):s.call(w,E)},B.prototype.listenerCount=s;function s(w){var E=this._events;if(E!==void 0){var o=E[w];if(typeof o=="function")return 1;if(o!==void 0)return o.length}return 0}B.prototype.eventNames=function(){return this._eventsCount>0?g(this._events):[]};function q(w,E){for(var o=new Array(E),F=0;F<E;++F)o[F]=w[F];return o}function BA(w,E){for(;E+1<w.length;E++)w[E]=w[E+1];w.pop()}function EA(w){for(var E=new Array(w.length),o=0;o<E.length;++o)E[o]=w[o].listener||w[o];return E}function x(w,E){return new Promise(function(o,F){function M(G){w.removeListener(E,R),F(G)}function R(){typeof w.removeListener=="function"&&w.removeListener("error",M),o([].slice.call(arguments))}JA(w,E,R,{once:!0}),E!=="error"&&uA(w,M,{once:!0})})}function uA(w,E,o){typeof w.on=="function"&&JA(w,"error",E,o)}function JA(w,E,o,F){if(typeof w.on=="function")F.once?w.once(E,o):w.on(E,o);else if(typeof w.addEventListener=="function")w.addEventListener(E,function M(R){F.once&&w.removeEventListener(E,M),o(R)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof w)}return m.exports}var LA=hA();const wA=SA(LA);class e{__destroy_into_raw(){const A=this.__wbg_ptr;return this.__wbg_ptr=0,NA.unregister(this),A}free(){const A=this.__destroy_into_raw();k.__wbg_dapadapter_free(A,0)}attach(A){k.dapadapter_attach(this.__wbg_ptr,A)}detach(){k.dapadapter_detach(this.__wbg_ptr)}constructor(){const A=k.dapadapter_new();return this.__wbg_ptr=A>>>0,NA.register(this,this.__wbg_ptr,this),this}on(A){k.dapadapter_on(this.__wbg_ptr,A)}resetRun(){k.dapadapter_resetRun(this.__wbg_ptr)}sendMessage(A){return k.dapadapter_sendMessage(this.__wbg_ptr,A)}setFilterInternals(A){k.dapadapter_setFilterInternals(this.__wbg_ptr,A)}}Symbol.dispose&&(e.prototype[Symbol.dispose]=e.prototype.free);class j{static __wrap(A){A=A>>>0;const g=Object.create(j.prototype);return g.__wbg_ptr=A,kA.register(g,g.__wbg_ptr,g),g}__destroy_into_raw(){const A=this.__wbg_ptr;return this.__wbg_ptr=0,kA.unregister(this),A}free(){const A=this.__destroy_into_raw();k.__wbg_trap_free(A,0)}static __wbg_wasmer_trap(){k.trap___wbg_wasmer_trap()}}Symbol.dispose&&(j.prototype[Symbol.dispose]=j.prototype.free);function sA(){let Q,A;try{const g=k.cpp_exception_hash();return Q=g[0],A=g[1],c(g[0],g[1])}finally{k.__wbindgen_free(Q,A,1)}}function iA(Q){const A=W(Q,k.__wbindgen_malloc,k.__wbindgen_realloc),g=Z,I=k.prefetch_urls(A,g);var C=FA(I[0],I[1]).slice();return k.__wbindgen_free(I[0],I[1]*4,4),C}function cA(){return{__proto__:null,"./engine_bg.js":{__proto__:null,__wbg_BigInt_b7bbccdff258c9f2:function(A){return BigInt(A)},__wbg_Error_8c4e43fe74559d73:function(A,g){return Error(c(A,g))},__wbg_Number_04624de7d0e8332d:function(A){return Number(A)},__wbg_String_8f0eb39a4a4c2f66:function(A,g){const I=String(g),C=W(I,k.__wbindgen_malloc,k.__wbindgen_realloc),B=Z;S().setInt32(A+4,B,!0),S().setInt32(A+0,C,!0)},__wbg___wbindgen_bigint_get_as_i64_8fcf4ce7f1ca72a2:function(A,g){const I=g,C=typeof I=="bigint"?I:void 0;S().setBigInt64(A+8,d(C)?BigInt(0):C,!0),S().setInt32(A+0,!d(C),!0)},__wbg___wbindgen_boolean_get_bbbb1c18aa2f5e25:function(A){const g=A,I=typeof g=="boolean"?g:void 0;return d(I)?16777215:I?1:0},__wbg___wbindgen_debug_string_0bc8482c6e3508ae:function(A,g){const I=_(g),C=W(I,k.__wbindgen_malloc,k.__wbindgen_realloc),B=Z;S().setInt32(A+4,B,!0),S().setInt32(A+0,C,!0)},__wbg___wbindgen_function_table_5ae7216dfcbcc506:function(){return k.__wbindgen_export},__wbg___wbindgen_in_47fa6863be6f2f25:function(A,g){return A in g},__wbg___wbindgen_is_bigint_31b12575b56f32fc:function(A){return typeof A=="bigint"},__wbg___wbindgen_is_function_0095a73b8b156f76:function(A){return typeof A=="function"},__wbg___wbindgen_is_object_5ae8e5880f2c1fbd:function(A){const g=A;return typeof g=="object"&&g!==null},__wbg___wbindgen_is_string_cd444516edc5b180:function(A){return typeof A=="string"},__wbg___wbindgen_is_undefined_9e4d92534c42d778:function(A){return A===void 0},__wbg___wbindgen_jsval_eq_11888390b0186270:function(A,g){return A===g},__wbg___wbindgen_jsval_loose_eq_9dd77d8cd6671811:function(A,g){return A==g},__wbg___wbindgen_lt_bb59cc3d23526e0d:function(A,g){return A<g},__wbg___wbindgen_neg_6b4d356dff49dcc6:function(A){return-A},__wbg___wbindgen_number_get_8ff4255516ccad3e:function(A,g){const I=g,C=typeof I=="number"?I:void 0;S().setFloat64(A+8,d(C)?0:C,!0),S().setInt32(A+0,!d(C),!0)},__wbg___wbindgen_rethrow_05525c567f154472:function(A){throw A},__wbg___wbindgen_shr_ef8e07cce709eb54:function(A,g){return A>>g},__wbg___wbindgen_string_get_72fb696202c56729:function(A,g){const I=g,C=typeof I=="string"?I:void 0;var B=d(C)?0:W(C,k.__wbindgen_malloc,k.__wbindgen_realloc),i=Z;S().setInt32(A+4,i,!0),S().setInt32(A+0,B,!0)},__wbg___wbindgen_throw_be289d5034ed271b:function(A,g){throw new Error(c(A,g))},__wbg__wbg_cb_unref_d9b87ff7982e3b21:function(A){A._wbg_cb_unref()},__wbg_addEventListener_3acb0aad4483804c:function(){return y(function(A,g,I,C){A.addEventListener(c(g,I),C)},arguments)},__wbg_apply_2e22c45cb4f12415:function(){return y(function(A,g,I){return Reflect.apply(A,g,I)},arguments)},__wbg_apply_ada2ee1a60ac7b3c:function(){return y(function(A,g,I){return A.apply(g,I)},arguments)},__wbg_arrayBuffer_bb54076166006c39:function(){return y(function(A){return A.arrayBuffer()},arguments)},__wbg_bind_1dc37de2b9939128:function(A,g,I,C){return A.bind(g,I,C)},__wbg_bind_29ba380591735d8c:function(A,g,I){return A.bind(g,I)},__wbg_buffer_7b5f53e46557d8f1:function(A){return A.buffer},__wbg_byteLength_7b03c17ff1e4037f:function(A){return A.byteLength},__wbg_byteLength_b5d783d06792ed2c:function(A){return A.byteLength},__wbg_call_389efe28435a9388:function(){return y(function(A,g){return A.call(g)},arguments)},__wbg_call_4708e0c13bdc8e95:function(){return y(function(A,g,I){return A.call(g,I)},arguments)},__wbg_compareExchange_b578410c358e695e:function(){return y(function(A,g,I,C){return Atomics.compareExchange(A,g>>>0,I,C)},arguments)},__wbg_constructor_ad6c0ed428f55d34:function(A){return A.constructor},__wbg_crypto_86f2631e91b51511:function(A){return A.crypto},__wbg_customSections_193491b069139fb1:function(A,g,I){return WebAssembly.Module.customSections(A,c(g,I))},__wbg_data_5330da50312d0bc1:function(A){return A.data},__wbg_done_57b39ecd9addfe81:function(A){return A.done},__wbg_entries_58c7934c745daac7:function(A){return Object.entries(A)},__wbg_error_7534b8e9a36f1ab4:function(A,g){let I,C;try{I=A,C=g,console.error(c(A,g))}finally{k.__wbindgen_free(I,C,1)}},__wbg_exports_794a42000dacd046:function(A){return WebAssembly.Module.exports(A)},__wbg_exports_86b4926134c40288:function(A){return A.exports},__wbg_fetch_d1488f40cef1e210:function(A,g,I){return A.fetch(c(g,I))},__wbg_from_bddd64e7d5ff6941:function(A){return Array.from(A)},__wbg_getPrototypeOf_2653517f1dc884d5:function(){return y(function(A){return Reflect.getPrototypeOf(A)},arguments)},__wbg_getRandomValues_b3f15fcbfabb0f8b:function(){return y(function(A,g){A.getRandomValues(g)},arguments)},__wbg_getTime_1e3cd1391c5c3995:function(A){return A.getTime()},__wbg_getTimezoneOffset_81776d10a4ec18a8:function(A){return A.getTimezoneOffset()},__wbg_getUint32_bb6f5a401408e7fa:function(A,g,I){return A.getUint32(g>>>0,I!==0)},__wbg_get_7efbcc3819719b0f:function(){return y(function(A,g){return A.get(g>>>0)},arguments)},__wbg_get_9b94d73e6221f75c:function(A,g){return A[g>>>0]},__wbg_get_b3ed3ad4be2bc8ac:function(){return y(function(A,g){return Reflect.get(A,g)},arguments)},__wbg_get_index_253dd2a9e007656d:function(A,g){return A[g>>>0]},__wbg_get_index_9a5bfdd2ca49c65f:function(A,g){return A[g>>>0]},__wbg_get_with_ref_key_1dc361bd10053bfe:function(A,g){return A[g]},__wbg_grow_5d42bf28c2da22cb:function(){return y(function(A,g){return A.grow(g>>>0)},arguments)},__wbg_grow_d034989fce14cc8e:function(){return y(function(A,g){return A.grow(g>>>0)},arguments)},__wbg_imports_8333d40ab24779ad:function(A){return WebAssembly.Module.imports(A)},__wbg_instanceof_ArrayBuffer_c367199e2fa2aa04:function(A){let g;try{g=A instanceof ArrayBuffer}catch{g=!1}return g},__wbg_instanceof_Error_8573fe0b0b480f46:function(A){let g;try{g=A instanceof Error}catch{g=!1}return g},__wbg_instanceof_Function_2a29eec978bb3b11:function(A){let g;try{g=A instanceof Function}catch{g=!1}return g},__wbg_instanceof_Global_2db767b6b2347f01:function(A){let g;try{g=A instanceof WebAssembly.Global}catch{g=!1}return g},__wbg_instanceof_Map_53af74335dec57f4:function(A){let g;try{g=A instanceof Map}catch{g=!1}return g},__wbg_instanceof_Memory_dc8c61e3f831ee37:function(A){let g;try{g=A instanceof WebAssembly.Memory}catch{g=!1}return g},__wbg_instanceof_Module_d0d412b14363ba9a:function(A){let g;try{g=A instanceof WebAssembly.Module}catch{g=!1}return g},__wbg_instanceof_Object_1c6af87502b733ed:function(A){let g;try{g=A instanceof Object}catch{g=!1}return g},__wbg_instanceof_RangeError_0b0dd056bc557b89:function(A){let g;try{g=A instanceof RangeError}catch{g=!1}return g},__wbg_instanceof_Response_ee1d54d79ae41977:function(A){let g;try{g=A instanceof Response}catch{g=!1}return g},__wbg_instanceof_SharedArrayBuffer_91d8a2fa16a2cc26:function(A){let g;try{g=A instanceof SharedArrayBuffer}catch{g=!1}return g},__wbg_instanceof_Table_127f216e592f4159:function(A){let g;try{g=A instanceof WebAssembly.Table}catch{g=!1}return g},__wbg_instanceof_Tag_f1d6b24a98b95210:function(A){let g;try{g=A instanceof WebAssembly.Tag}catch{g=!1}return g},__wbg_instanceof_Uint8Array_9b9075935c74707c:function(A){let g;try{g=A instanceof Uint8Array}catch{g=!1}return g},__wbg_isArray_d314bb98fcf08331:function(A){return Array.isArray(A)},__wbg_isSafeInteger_bfbc7332a9768d2a:function(A){return Number.isSafeInteger(A)},__wbg_is_f29129f676e5410c:function(A,g){return Object.is(A,g)},__wbg_iterator_6ff6560ca1568e55:function(){return Symbol.iterator},__wbg_length_32ed9a279acd054c:function(A){return A.length},__wbg_length_35a7bace40f36eac:function(A){return A.length},__wbg_length_aeb94ff17a8a8556:function(A){return A.length},__wbg_load_eff64ff5e429a422:function(){return y(function(A,g){return Atomics.load(A,g>>>0)},arguments)},__wbg_message_9ddc4b9a62a7c379:function(A){return A.message},__wbg_msCrypto_d562bbe83e0d4b91:function(A){return A.msCrypto},__wbg_new_0728bd2d4c5d41dd:function(){return y(function(A){return new WebAssembly.Tag(A)},arguments)},__wbg_new_0_73afc35eb544e539:function(){return new Date},__wbg_new_245cd5c49157e602:function(A){return new Date(A)},__wbg_new_2ac7fa8be584d280:function(A,g,I){return new DataView(A,g>>>0,I>>>0)},__wbg_new_361308b2356cecd0:function(){return new Object},__wbg_new_3eb36ae241fe6f44:function(){return new Array},__wbg_new_4a996a46a82782b6:function(){return y(function(A,g){return new WebAssembly.Global(A,g)},arguments)},__wbg_new_57c27ff3ddf5b62c:function(){return y(function(A){return new WebAssembly.Module(A)},arguments)},__wbg_new_67274f72d5abea37:function(){return y(function(A){return new WebAssembly.Table(A)},arguments)},__wbg_new_8a6f238a6ece86ea:function(){return new Error},__wbg_new_a4e3cab1cdd635ba:function(){return y(function(A,g){return new WebAssembly.Instance(A,g)},arguments)},__wbg_new_b061c0550d9f3281:function(){return y(function(A){return new WebAssembly.Memory(A)},arguments)},__wbg_new_b5d9e2fb389fef91:function(A,g){try{var I={a:A,b:g},C=(i,D)=>{const N=I.a;I.a=0;try{return dA(N,I.b,i,D)}finally{I.a=N}};return new Promise(C)}finally{I.a=I.b=0}},__wbg_new_ca409f861989e0c5:function(A){return new SharedArrayBuffer(A>>>0)},__wbg_new_dca287b076112a51:function(){return new Map},__wbg_new_dd2b680c8bf6ae29:function(A){return new Uint8Array(A)},__wbg_new_from_slice_a3d2629dc1826784:function(A,g){return new Uint8Array(n(A,g))},__wbg_new_no_args_1c7c842f08d00ebb:function(A,g){return new Function(c(A,g))},__wbg_new_with_args_7bba34e94b1cfa40:function(A,g,I,C){return new Function(c(A,g),c(I,C))},__wbg_new_with_byte_offset_9120ba79e057895b:function(A,g){return new Uint8Array(A,g>>>0)},__wbg_new_with_byte_offset_and_length_aa261d9c9da49eb1:function(A,g,I){return new Uint8Array(A,g>>>0,I>>>0)},__wbg_new_with_byte_offset_and_length_bc2e7b72cc96d1c1:function(A,g,I){return new Int32Array(A,g>>>0,I>>>0)},__wbg_new_with_length_1763c527b2923202:function(A){return new Array(A>>>0)},__wbg_new_with_length_a2c39cbe88fd8ff1:function(A){return new Uint8Array(A>>>0)},__wbg_next_3482f54c49e8af19:function(){return y(function(A){return A.next()},arguments)},__wbg_next_418f80d8f5303233:function(A){return A.next},__wbg_node_e1f24f89a7336c2e:function(A){return A.node},__wbg_notify_78a90977fab74963:function(){return y(function(A,g){return Atomics.notify(A,g>>>0)},arguments)},__wbg_now_a3af9a2f4bbaa4d1:function(){return Date.now()},__wbg_now_ebffdf7e580f210d:function(A){return A.now()},__wbg_ok_87f537440a0acf85:function(A){return A.ok},__wbg_postMessage_2041f4e90af61318:function(){return y(function(A,g){A.postMessage(g)},arguments)},__wbg_process_3975fd6c72f520aa:function(A){return A.process},__wbg_prototypesetcall_bdcdcc5842e4d77d:function(A,g,I){Uint8Array.prototype.set.call(n(A,g),I)},__wbg_push_8ffdcb2063340ba5:function(A,g){return A.push(g)},__wbg_queueMicrotask_0aa0a927f78f5d98:function(A){return A.queueMicrotask},__wbg_queueMicrotask_5bb536982f78a56f:function(A){queueMicrotask(A)},__wbg_randomFillSync_f8c153b79f285817:function(){return y(function(A,g){A.randomFillSync(g)},arguments)},__wbg_removeEventListener_e63328781a5b9af9:function(){return y(function(A,g,I,C){A.removeEventListener(c(g,I),C)},arguments)},__wbg_require_b74f47fc2d022fd6:function(){return y(function(){return module.require},arguments)},__wbg_resolve_002c4b7d9d8f6b64:function(A){return Promise.resolve(A)},__wbg_setTimeout_e0aacd5a637418a6:function(){return y(function(A,g,I){return A.setTimeout(g,I)},arguments)},__wbg_setUint32_d168af7751a8557e:function(A,g,I,C){A.setUint32(g>>>0,I>>>0,C!==0)},__wbg_set_0af2522656c2a71b:function(){return y(function(A,g,I){A.set(g>>>0,I)},arguments)},__wbg_set_1eb0999cf5d27fc8:function(A,g,I){return A.set(g,I)},__wbg_set_25cf9deff6bf0ea8:function(A,g,I){A.set(g,I>>>0)},__wbg_set_3f1d0b984ed272ed:function(A,g,I){A[g]=I},__wbg_set_6cb8631f80447a67:function(){return y(function(A,g,I){return Reflect.set(A,g,I)},arguments)},__wbg_set_cc56eefd2dd91957:function(A,g,I){A.set(n(g,I))},__wbg_set_f43e577aea94465b:function(A,g,I){A[g>>>0]=I},__wbg_set_index_b3244a6c458021e4:function(A,g,I){A[g>>>0]=I},__wbg_set_index_f259b54e97f7b177:function(A,g,I){A[g>>>0]=I},__wbg_set_onmessage_ea7cc2ba099021cd:function(A,g){A.onmessage=g},__wbg_set_value_fc06e541de098215:function(A,g){A.value=g},__wbg_slice_8bbd46adb2100583:function(A,g,I){return A.slice(g>>>0,I>>>0)},__wbg_stack_0ed75d68575b0f3c:function(A,g){const I=g.stack,C=W(I,k.__wbindgen_malloc,k.__wbindgen_realloc),B=Z;S().setInt32(A+4,B,!0),S().setInt32(A+0,C,!0)},__wbg_static_accessor_GLOBAL_12837167ad935116:function(){const A=typeof global>"u"?null:global;return d(A)?0:t(A)},__wbg_static_accessor_GLOBAL_THIS_e628e89ab3b1c95f:function(){const A=typeof globalThis>"u"?null:globalThis;return d(A)?0:t(A)},__wbg_static_accessor_SELF_a621d3dfbb60d0ce:function(){const A=typeof self>"u"?null:self;return d(A)?0:t(A)},__wbg_static_accessor_WINDOW_f8727f0cf888e0bd:function(){const A=typeof window>"u"?null:window;return d(A)?0:t(A)},__wbg_store_d1d951c98d9bed41:function(){return y(function(A,g,I){return Atomics.store(A,g>>>0,I)},arguments)},__wbg_subarray_a96e1fef17ed23cb:function(A,g,I){return A.subarray(g>>>0,I>>>0)},__wbg_then_0d9fe2c7b1857d32:function(A,g,I){return A.then(g,I)},__wbg_then_b9e7b3b5f1a9e1b5:function(A,g){return A.then(g)},__wbg_toString_56d946daff83867b:function(A,g,I){const C=g.toString(I),B=W(C,k.__wbindgen_malloc,k.__wbindgen_realloc),i=Z;S().setInt32(A+4,i,!0),S().setInt32(A+0,B,!0)},__wbg_toString_964ff7fe6eca8362:function(A){return A.toString()},__wbg_trap_new:function(A){return j.__wrap(A)},__wbg_validate_71c2d02a71bda62f:function(){return y(function(A){return WebAssembly.validate(A)},arguments)},__wbg_value_0546255b415e96c1:function(A){return A.value},__wbg_value_ce37a60e576310ff:function(A){return A.value},__wbg_versions_4e31226f5e8dc909:function(A){return A.versions},__wbg_wait_be5dae1e53f590f1:function(){return y(function(A,g,I){return Atomics.wait(A,g>>>0,I)},arguments)},__wbg_warn_81ab00e6e16e886d:function(A,g,I){console.warn(A,g,I)},__wbindgen_cast_0000000000000001:function(A,g){return f(A,g,k.wasm_bindgen_36932265c58943ab___closure__destroy___dyn_for__a__core_37ee0ce0c4cd57d5___ops__function__FnMut____a_js_sys_9eaf8169b8189500___Array____Output___core_37ee0ce0c4cd57d5___result__Result_js_sys_9eaf8169b8189500___Array__wasm_bindgen_36932265c58943ab___JsValue___,oA)},__wbindgen_cast_0000000000000002:function(A,g){return f(A,g,k.wasm_bindgen_36932265c58943ab___closure__destroy___dyn_for__a__core_37ee0ce0c4cd57d5___ops__function__FnMut____a_js_sys_9eaf8169b8189500___Array____Output___core_37ee0ce0c4cd57d5___result__Result_js_sys_9eaf8169b8189500___Array__wasm_bindgen_36932265c58943ab___JsValue___,oA)},__wbindgen_cast_0000000000000003:function(A,g){return f(A,g,k.wasm_bindgen_36932265c58943ab___closure__destroy___dyn_for__a__core_37ee0ce0c4cd57d5___ops__function__FnMut____a_js_sys_9eaf8169b8189500___Array____Output___core_37ee0ce0c4cd57d5___result__Result_js_sys_9eaf8169b8189500___Array__wasm_bindgen_36932265c58943ab___JsValue___,pA)},__wbindgen_cast_0000000000000004:function(A,g){return f(A,g,k.wasm_bindgen_36932265c58943ab___closure__destroy___dyn_core_37ee0ce0c4cd57d5___ops__function__FnMut__wasm_bindgen_36932265c58943ab___JsValue____Output_______,HA)},__wbindgen_cast_0000000000000005:function(A,g){return xA(A,g,k.wasm_bindgen_36932265c58943ab___closure__destroy___dyn_core_37ee0ce0c4cd57d5___ops__function__Fn__web_sys_ca373f7aaf47173f___features__gen_MessageEvent__MessageEvent____Output_______,aA)},__wbindgen_cast_0000000000000006:function(A,g){return f(A,g,k.wasm_bindgen_36932265c58943ab___closure__destroy___dyn_core_37ee0ce0c4cd57d5___ops__function__Fn__web_sys_ca373f7aaf47173f___features__gen_MessageEvent__MessageEvent____Output_______,qA)},__wbindgen_cast_0000000000000007:function(A){return A},__wbindgen_cast_0000000000000008:function(A){return A},__wbindgen_cast_0000000000000009:function(A,g){return n(A,g)},__wbindgen_cast_000000000000000a:function(A,g){return c(A,g)},__wbindgen_cast_000000000000000b:function(A,g){return BigInt.asUintN(64,A)|BigInt.asUintN(64,g)<<BigInt(64)},__wbindgen_cast_000000000000000c:function(A){return BigInt.asUintN(64,A)},__wbindgen_cast_000000000000000d:function(A,g){var I=FA(A,g).slice();return k.__wbindgen_free(A,g*4,4),I},__wbindgen_init_externref_table:function(){const A=k.__wbindgen_externrefs,g=A.grow(4);A.set(0,void 0),A.set(g+0,void 0),A.set(g+1,null),A.set(g+2,!0),A.set(g+3,!1)}}}}function HA(Q,A,g){k.wasm_bindgen_36932265c58943ab___convert__closures_____invoke___wasm_bindgen_36932265c58943ab___JsValue_____(Q,A,g)}function aA(Q,A,g){k.wasm_bindgen_36932265c58943ab___convert__closures_____invoke___web_sys_ca373f7aaf47173f___features__gen_MessageEvent__MessageEvent_____(Q,A,g)}function qA(Q,A,g){k.wasm_bindgen_36932265c58943ab___convert__closures_____invoke___web_sys_ca373f7aaf47173f___features__gen_MessageEvent__MessageEvent______1_(Q,A,g)}function pA(Q,A,g){const I=k.wasm_bindgen_36932265c58943ab___convert__closures________invoke___js_sys_9eaf8169b8189500___Array__core_37ee0ce0c4cd57d5___result__Result_____wasm_bindgen_36932265c58943ab___JsValue__(Q,A,g);if(I[1])throw $(I[0])}function oA(Q,A,g){const I=k.wasm_bindgen_36932265c58943ab___convert__closures________invoke___js_sys_9eaf8169b8189500___Array__core_37ee0ce0c4cd57d5___result__Result_js_sys_9eaf8169b8189500___Array__wasm_bindgen_36932265c58943ab___JsValue__(Q,A,g);if(I[2])throw $(I[1]);return $(I[0])}function dA(Q,A,g,I){k.wasm_bindgen_36932265c58943ab___convert__closures_____invoke___wasm_bindgen_36932265c58943ab___JsValue__wasm_bindgen_36932265c58943ab___JsValue_____(Q,A,g,I)}const NA=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(Q=>k.__wbg_dapadapter_free(Q>>>0,1)),kA=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(Q=>k.__wbg_trap_free(Q>>>0,1));function t(Q){const A=k.__externref_table_alloc();return k.__wbindgen_externrefs.set(A,Q),A}const P=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(Q=>Q.dtor(Q.a,Q.b));function _(Q){const A=typeof Q;if(A=="number"||A=="boolean"||Q==null)return`${Q}`;if(A=="string")return`"${Q}"`;if(A=="symbol"){const C=Q.description;return C==null?"Symbol":`Symbol(${C})`}if(A=="function"){const C=Q.name;return typeof C=="string"&&C.length>0?`Function(${C})`:"Function"}if(Array.isArray(Q)){const C=Q.length;let B="[";C>0&&(B+=_(Q[0]));for(let i=1;i<C;i++)B+=", "+_(Q[i]);return B+="]",B}const g=/\[object ([^\]]+)\]/.exec(toString.call(Q));let I;if(g&&g.length>1)I=g[1];else return toString.call(Q);if(I=="Object")try{return"Object("+JSON.stringify(Q)+")"}catch{return"Object"}return Q instanceof Error?`${Q.name}: ${Q.message}
|
|
2
|
+
${Q.stack}`:I}function FA(Q,A){Q=Q>>>0;const g=S(),I=[];for(let C=Q;C<Q+4*A;C+=4)I.push(k.__wbindgen_externrefs.get(g.getUint32(C,!0)));return k.__externref_drop_slice(Q,A),I}function n(Q,A){return Q=Q>>>0,z().subarray(Q/1,Q/1+A)}let V=null;function S(){return(V===null||V.buffer.detached===!0||V.buffer.detached===void 0&&V.buffer!==k.memory.buffer)&&(V=new DataView(k.memory.buffer)),V}function c(Q,A){return Q=Q>>>0,OA(Q,A)}let T=null;function z(){return(T===null||T.byteLength===0)&&(T=new Uint8Array(k.memory.buffer)),T}function y(Q,A){try{return Q.apply(this,A)}catch(g){const I=t(g);k.__wbindgen_exn_store(I)}}function d(Q){return Q==null}function xA(Q,A,g,I){const C={a:Q,b:A,cnt:1,dtor:g},B=(...i)=>{C.cnt++;try{return I(C.a,C.b,...i)}finally{B._wbg_cb_unref()}};return B._wbg_cb_unref=()=>{--C.cnt===0&&(C.dtor(C.a,C.b),C.a=0,P.unregister(C))},P.register(B,C,C),B}function f(Q,A,g,I){const C={a:Q,b:A,cnt:1,dtor:g},B=(...i)=>{C.cnt++;const D=C.a;C.a=0;try{return I(D,C.b,...i)}finally{C.a=D,B._wbg_cb_unref()}};return B._wbg_cb_unref=()=>{--C.cnt===0&&(C.dtor(C.a,C.b),C.a=0,P.unregister(C))},P.register(B,C,C),B}function W(Q,A,g){if(g===void 0){const D=X.encode(Q),N=A(D.length,1)>>>0;return z().subarray(N,N+D.length).set(D),Z=D.length,N}let I=Q.length,C=A(I,1)>>>0;const B=z();let i=0;for(;i<I;i++){const D=Q.charCodeAt(i);if(D>127)break;B[C+i]=D}if(i!==I){i!==0&&(Q=Q.slice(i)),C=g(C,I,I=i+Q.length*3,1)>>>0;const D=z().subarray(C+i,C+I),N=X.encodeInto(Q,D);i+=N.written,C=g(C,I,i,1)>>>0}return Z=i,C}function $(Q){const A=k.__wbindgen_externrefs.get(Q);return k.__externref_table_dealloc(Q),A}let r=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});r.decode();const ZA=2146435072;let AA=0;function OA(Q,A){return AA+=A,AA>=ZA&&(r=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),r.decode(),AA=A),r.decode(z().subarray(Q,Q+A))}const X=new TextEncoder;"encodeInto"in X||(X.encodeInto=function(Q,A){const g=X.encode(Q);return A.set(g),{read:Q.length,written:g.length}});let Z=0,k;function VA(Q,A){return k=Q.exports,V=null,T=null,k.__wbindgen_start(),k}async function WA(Q,A){if(typeof Response=="function"&&Q instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(Q,A)}catch(C){if(Q.ok&&g(Q.type)&&Q.headers.get("Content-Type")!=="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",C);else throw C}const I=await Q.arrayBuffer();return await WebAssembly.instantiate(I,A)}else{const I=await WebAssembly.instantiate(Q,A);return I instanceof WebAssembly.Instance?{instance:I,module:Q}:I}function g(I){switch(I){case"basic":case"cors":case"default":return!0}return!1}}async function jA(Q){if(k!==void 0)return k;Q!==void 0&&(Object.getPrototypeOf(Q)===Object.prototype?{module_or_path:Q}=Q:console.warn("using deprecated parameters for the initialization function; pass a single object instead")),Q===void 0&&(Q=new URL("",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:O&&O.tagName.toUpperCase()==="SCRIPT"&&O.src||new URL("glassjar.umd.cjs",document.baseURI).href));const A=cA();(typeof Q=="string"||typeof Request=="function"&&Q instanceof Request||typeof URL=="function"&&Q instanceof URL)&&(Q=fetch(Q));const{instance:g,module:I}=await WA(await Q,A);return VA(g)}const tA=new URL("https://cdn.jsdelivr.net/npm/glassjar@0.4.1/dist/engine_bg.wasm"),TA=Object.freeze({maxObjectBytes:128*1024*1024,maxEntries:256,maxMetadataBytes:8*1024*1024,maxEntryMetadataBytes:1024*1024});class zA{records=new Map;staged=new Map;stagingFailed=!1;objectBytes=0;metadataBytes=0;evictions=0;oversized=0;limits;constructor(A={}){this.limits=Object.freeze({...TA,...A});for(const g of Object.values(this.limits))if(!Number.isSafeInteger(g)||g<0)throw new RangeError("C++ cache limits must be nonnegative safe integers")}beginBatch(){this.discardBatch(),this.stagingFailed=!1}stage(A){if(this.stagingFailed)return;const g=this.recordSize(A);if(g===void 0||this.staged.has(A.source)){this.failBatch();return}const I=this.limits;for(;this.records.size&&(this.records.size+this.staged.size>=I.maxEntries||this.objectBytes+A.object.byteLength>I.maxObjectBytes||this.metadataBytes+g>I.maxMetadataBytes);)this.remove(this.records.keys().next().value),this.evictions++;if(this.records.size+this.staged.size>=I.maxEntries||this.objectBytes+A.object.byteLength>I.maxObjectBytes||this.metadataBytes+g>I.maxMetadataBytes||g>I.maxEntryMetadataBytes){this.oversized++,this.failBatch();return}this.staged.set(A.source,{...A,object:new Uint8Array(A.object),metadataBytes:g}),this.objectBytes+=A.object.byteLength,this.metadataBytes+=g}abandonBatch(){this.failBatch()}failBatch(){this.discardBatch(),this.stagingFailed=!0}recordSize(A){if(!(typeof A.source!="string"||!A.source.startsWith("/")||A.source.split("/").slice(1).some(g=>!g||g==="."||g==="..")||typeof A.key!="string"||typeof A.object_hash!="string"||!/^[a-f0-9]{64}$/.test(A.key)||!/^[a-f0-9]{64}$/.test(A.object_hash)||A.receipt!=null&&typeof A.receipt!="string"||!(A.object instanceof Uint8Array)))return new TextEncoder().encode(JSON.stringify({source:A.source,key:A.key,object_hash:A.object_hash,...A.receipt==null?{}:{receipt:A.receipt}})).byteLength}async validateBatch(){if(this.stagingFailed)return!1;const A=[...this.staged.values()];for(const g of A){if(!fA(g.object))return!1;const I=await crypto.subtle.digest("SHA-256",g.object);if(Array.from(new Uint8Array(I),B=>B.toString(16).padStart(2,"0")).join("")!==g.object_hash)return!1}return!0}commitBatch(){for(const[A,g]of this.staged)this.remove(A),this.records.set(A,g);this.staged.clear(),this.stagingFailed=!1}discardBatch(){for(const A of this.staged.values())this.objectBytes-=A.object.byteLength,this.metadataBytes-=A.metadataBytes;this.staged.clear()}snapshot(){return[...this.records.values()].map(({source:A,key:g,object_hash:I,object:C,receipt:B})=>({source:A,key:g,object_hash:I,...B==null?{}:{receipt:B},object:C.slice()}))}touch(A){const g=this.records.get(A);g&&(this.records.delete(A),this.records.set(A,g))}put(A){if(typeof A.source!="string"||!A.source.startsWith("/")||A.source.split("/").slice(1).some(B=>!B||B==="."||B==="..")||typeof A.key!="string"||typeof A.object_hash!="string"||!/^[a-f0-9]{64}$/.test(A.object_hash)||!/^[a-f0-9]{64}$/.test(A.key)||!(A.object instanceof Uint8Array))return;const g=this.recordSize(A);if(g===void 0)return;const I=this.limits;if(this.remove(A.source),I.maxEntries===0||A.object.byteLength>I.maxObjectBytes||g>I.maxMetadataBytes||g>I.maxEntryMetadataBytes){this.oversized++;return}for(;this.records.size>=I.maxEntries||this.objectBytes+A.object.byteLength>I.maxObjectBytes||this.metadataBytes+g>I.maxMetadataBytes;)this.remove(this.records.keys().next().value),this.evictions++;const C={...A,object:new Uint8Array(A.object),metadataBytes:g};this.records.set(A.source,C),this.objectBytes+=C.object.byteLength,this.metadataBytes+=g}delete(A){this.remove(A)}remove(A){const g=this.records.get(A);g&&(this.objectBytes-=g.object.byteLength,this.metadataBytes-=g.metadataBytes,this.records.delete(A))}clear(){this.records.clear(),this.staged.clear(),this.stagingFailed=!1,this.objectBytes=this.metadataBytes=0}stats(){return{objectBytes:this.objectBytes,metadataBytes:this.metadataBytes,entries:this.records.size,stagingEntries:this.staged.size,stagingObjectBytes:[...this.staged.values()].reduce((A,g)=>A+g.object.byteLength,0),stagingMetadataBytes:[...this.staged.values()].reduce((A,g)=>A+g.metadataBytes,0),evictions:this.evictions,oversized:this.oversized}}}function fA(Q){if(!WebAssembly.validate(Q)||Q.length<8)return!1;let A=8,g=!1;const I=()=>{let C=0,B=0;for(let i=0;i<5&&A<Q.length;i++,B+=7){const D=Q[A++];if(C+=(D&127)*2**B,!(D&128))return C}throw new Error("Malformed object section")};try{for(;A<Q.length;){const C=Q[A++],B=I(),i=A+B;if(i>Q.length||C===8)return!1;if(C===0){const D=I();if(A+D>i)return!1;const N=new TextDecoder().decode(Q.subarray(A,A+D));if(A+=D,N==="linking"){if(g||I()!==2)return!1;g=!0}}A=i}return g}catch{return!1}}const J=Symbol();function h(Q){return Q instanceof Error?{type:"error",error:{type:Q.constructor.name,message:Q.message}}:{type:"error",error:{type:typeof Q,message:String(Q)}}}class MA{name;data;constructor(A,g){this.name=A,this.data=g}download(){const A=new Uint8Array(this.data),g=new Blob([A]),I=URL.createObjectURL(g),C=document.createElement("a");C.href=I,C.download=this.name,document.body.appendChild(C),C.click(),document.body.removeChild(C),URL.revokeObjectURL(I)}}class GA extends wA{[J];dap;enabled=!0;set filterInternals(A){this.dap.setFilterInternals(A)}constructor(){super(),this[J]={attach:this.attach.bind(this),detach:this.detach.bind(this),beginRun:()=>this.dap.resetRun()},this.onMessage=this.onMessage.bind(this),this.dap=new e,this.dap.on(this.onMessage)}send(A){return this.dap.sendMessage(A)}artifactListener=A=>{if(A.data.type!=="artifact")return;const g=new MA(A.data.name,new Uint8Array(A.data.data));this.emit("artifact",g)};attach(A){A.addEventListener("message",this.artifactListener),this.dap.attach(A)}detach(A){A.removeEventListener("message",this.artifactListener),this.dap.detach()}onMessage(A){this.emit("event",A)}}const XA="glassjar-wasm:";function lA(Q,A){const g=new URL(String(Q),A);if(g.protocol!=="https:"&&g.protocol!=="http:")throw new TypeError(`Engine Wasm must be served over http(s), not ${g.protocol}`);return g.href}function bA(Q){return new Worker(""+(typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__dirname+"/assets/worker-CgVDPM2f.js").href:new URL("assets/worker-CgVDPM2f.js",typeof document>"u"?location.href:document.currentScript&&document.currentScript.tagName.toUpperCase()==="SCRIPT"&&document.currentScript.src||document.baseURI).href),{type:"module",name:Q?.name})}function mA(Q){return new bA(Q?{name:XA+Q}:void 0)}const PA="/dev/debugger-sh-host";class yA{buffer=new SharedArrayBuffer(4+64*1024);length=new Int32Array(this.buffer,0,1);bytes=new Uint8Array(this.buffer,4);publish(A){Atomics.store(this.length,0,A),Atomics.notify(this.length,0)}}function gA(Q){try{return new Error(`Host device callback failed: ${Q instanceof Error?Q.message:String(Q)}`)}catch{return new Error("Host device callback failed")}}function KA(Q){try{const A=Q?.();if(A&&typeof A.then=="function")return Promise.resolve(A).catch(()=>{}),new TypeError("Host device cleanup must be synchronous")}catch(A){return gA(A)}}class nA{constructor(A){this.onFailure=A}incoming=new yA;outgoing=new yA;workerStart={guest_to_host:this.incoming.buffer,host_to_guest:this.outgoing.buffer};abort=new AbortController;listeners=new Set;cleanup;worker;writing=!1;open(A){let g;try{g=A({signal:this.abort.signal,onData:I=>{if(this.assertOpen(),typeof I!="function")throw new TypeError("Host device listener must be a function");return this.listeners.add(I),()=>{this.listeners.delete(I)}},write:I=>this.write(I)})}catch(I){throw gA(I)}if(g!==void 0&&typeof g!="function")throw Promise.resolve(g).catch(()=>{}),new TypeError("Host device opener must return a cleanup function or undefined");if(typeof g=="function")if(this.abort.signal.aborted){const I=KA(g);if(I)throw I}else this.cleanup=g}attach(A){this.assertOpen(),this.worker=A,A.addEventListener("message",this.onMessage)}assertOpen(){if(this.abort.signal.aborted)throw new Error("Host device is closed")}async write(A){if(this.assertOpen(),!(A instanceof Uint8Array))throw new TypeError("Host device writes require Uint8Array");if(this.writing)throw new Error("Await the previous host device write before writing again");this.writing=!0;try{const g=new Uint8Array(A),I=this.outgoing;let C=0;for(;C<g.length;){this.assertOpen();const B=Atomics.load(I.length,0);if(B!==0){await Atomics.waitAsync(I.length,0,B).value;continue}const i=g.subarray(C,C+I.bytes.length);I.bytes.set(i),I.publish(i.length),C+=i.length}}finally{this.writing=!1}}onMessage=A=>{if(!(this.abort.signal.aborted||A.data?.type!=="host_wake"))try{const g=Atomics.load(this.incoming.length,0);if(g<=0)return;const I=this.incoming.bytes.slice(0,g);this.incoming.publish(0);for(const C of this.listeners){if(this.abort.signal.aborted)break;Promise.resolve(C(I)).catch(B=>this.fail(B))}}catch(g){this.fail(g)}};fail(A){this.abort.signal.aborted||(this.close(),this.onFailure(gA(A)))}close(){if(this.abort.signal.aborted)return;this.worker?.removeEventListener("message",this.onMessage),this.worker=void 0,this.incoming.publish(-1),this.outgoing.publish(-1),this.abort.abort(),this.listeners.clear();const A=this.cleanup;return this.cleanup=void 0,KA(A)}}const rA=["4847c7cda81eb51b1cec18fe40b396605579fe84e17eca2760702b8a9666e4e1"],u=Object.freeze({compiler:"24fbed474c7b5b4968fd73fc4827440b93fb351c1b6264516130300eff3e7bf5",sysroot:"8745c6af23fd841fa507d0c73f6b6b8e8da1b4ec216a6339739a28b38ff7227b",exceptions:"20986166552953de0e3ca5c1e9f341e7aec8b9ba54dcb244d0d2b2f9ca843ab4"});function RA(Q="legacy"){if(Q==="legacy")return{profile:Q,digests:u};if(Q==="stock-certified-v1"&&rA.length>0)return{profile:Q,digests:u};throw new Error(`The ${Q} toolchain is not available in this build`)}class l{#A;hashCount=3;hashMs;constructor(A,g){this.#A=A,this.hashMs=g}static async load(A,g,I,C=u.exceptions,B="legacy"){const i=RA(B);if(A.length!==2)throw new Error("Missing C++ toolchain assets");let D,N;const K=await Promise.allSettled(A.map(async(BA,EA)=>{try{const x=await fetch(BA,{cache:"force-cache",signal:I});if(!x.ok)throw new Error(`Cannot load C++ toolchain (${x.status})`);return EA===0&&g&&(N=WebAssembly.compileStreaming(x.clone()),N.catch(()=>{})),new Uint8Array(await x.arrayBuffer())}catch(x){throw D??={error:x},x}}));if(K[0].status==="rejected"||K[1].status==="rejected")throw D?.error;const[U,L]=[K[0].value,K[1].value],[Y,s]=await Promise.allSettled([l.ingestOwned(U,L,!1,C),g?N??Promise.resolve().then(()=>WebAssembly.compile(U)):Promise.resolve(void 0)]);if(Y.status==="rejected")throw Y.reason;const q=Y.value;if(q.#A.compilerHash!==i.digests.compiler||q.#A.sysrootHash!==i.digests.sysroot||q.#A.exceptionsHash!==i.digests.exceptions)throw new Error("C++ toolchain integrity mismatch");if(I?.aborted)throw new DOMException("Toolchain loading aborted","AbortError");if(s.status==="rejected")throw s.reason;return q.#A.stockProfile=i.profile==="stock-certified-v1",q.#A.module=s.value,q}static async fromBytes(A,g,I){const C=new Uint8Array(A),B=new Uint8Array(g);return l.ingestOwned(C,B,I,u.exceptions)}static async ingestOwned(A,g,I,C){const B=performance.now(),i=await Promise.allSettled([YA(A),YA(g)]);if(i[0].status==="rejected")throw i[0].reason;if(i[1].status==="rejected")throw i[1].reason;const[D,N]=[i[0].value,i[1].value],K=I?await WebAssembly.compile(A):void 0;return new l({compiler:A,sysroot:g,compilerHash:D,sysrootHash:N,exceptionsHash:C,module:K},performance.now()-B)}matchesExpectation(A){return A.compilerSha256===this.#A.compilerHash&&A.sysrootSha256===this.#A.sysrootHash&&A.exceptionsSha256===this.#A.exceptionsHash}get identity(){return`${this.#A.compilerHash}:${this.#A.sysrootHash}:${this.#A.exceptionsHash}`}get identityBytes(){return this.#A.compiler.byteLength+this.#A.sysroot.byteLength}get compilerBytes(){return this.#A.compiler.byteLength}configure(A,g){try{return A.postMessage({...g,toolchain:this.#A}),!!this.#A.module}catch(I){if(!(I instanceof DOMException)||I.name!=="DataCloneError"||!this.#A.module)throw I;return A.postMessage({...g,toolchain:{...this.#A,module:void 0}}),!1}}}async function YA(Q){const A=await crypto.subtle.digest("SHA-256",Q);return Array.from(new Uint8Array(A),g=>g.toString(16).padStart(2,"0")).join("")}let IA,v;class CA{stdout=new QA(1);stderr=new QA(2);stdin=new H;debugger;lang;scope;fs={};binaryFiles={};cppArtifacts;hostDevice;options;retain;idleTimeoutMs;wasmUrl;objects;generation=0;scopeEpoch=0;operationId=0;disposed=!1;active;promise;slot;idleTimer;toolchain;toolchainLoading;toolchainController;initializing=new Set;toolchainIdentity;toolchainIngestions=0;toolchainHashCount=0;toolchainHashMs=0;compilerModuleCloned=!1;disposal;cancellationDraining;releaseDrain;releases=new Set;retirements=0;latest;cacheValidation;static async create(A,g={}){const{wasmUrl:I,...C}=g,B=I===void 0?void 0:lA(I,globalThis.location?.href),i=structuredClone(C),D=B??null;if(v!==void 0&&v!==D)throw new Error("The engine Wasm is already loaded from a different wasmUrl");v=D,IA??=jA({module_or_path:B??tA}).catch(K=>{throw IA=void 0,v=void 0,K}),await IA;const N=new CA(A,i);if(N.wasmUrl=B,A!=="c"&&typeof window<"u"&&typeof fetch<"u")for(const K of iA(A))fetch(K,{cache:"force-cache"}).then(U=>U.arrayBuffer()).catch(()=>{});return N}constructor(A,g){const I=g.cpp;this.retain=g.retainWorker??I?.retainWorker??!0;const C=g.idleTimeoutMs??I?.idleTimeoutMs??3e4;if(!Number.isSafeInteger(C)||C<1||C>3e5)throw new RangeError("Worker idle timeout must be between 1 and 300000 milliseconds");if(this.idleTimeoutMs=C,I){if(A!=="c")throw new TypeError("C++ performance options require C/C++");if(!I.scope?.projectId||!I.scope.accountId)throw new TypeError("C++ performance options require project and account identity");if(I.compilerLifetime!==void 0&&!["idle","project"].includes(I.compilerLifetime))throw new TypeError("Invalid compiler lifetime");RA(I.toolchainProfile),this.scope=Object.freeze({...I.scope}),this.options=Object.freeze({...I,scope:this.scope,idleTimeoutMs:C})}this.objects=new zA(typeof I?.objectCache=="object"?I.objectCache:{}),this.debugger=new GA,this.lang=A}get cacheCompilerModule(){return this.options?.cacheCompilerModule??this.retain}get cacheStats(){return structuredClone({...this.objects.stats(),generation:this.generation,scopeEpoch:this.scopeEpoch,operationId:this.operationId,cacheEpoch:this.generation,toolchainProfile:this.options?.toolchainProfile??"legacy",cacheEligible:this.cacheValidation?.eligible??!1,stockCertificateSha256:this.cacheValidation?.certificate,cacheEligibilitySnapshot:this.cacheValidation?.snapshot,cacheEligibilityOperationId:this.cacheValidation?.operationId,cacheEligibilityReason:this.cacheValidation?.reason,toolchainIdentityBytes:this.toolchain?.identityBytes??0,toolchainIngestions:this.toolchainIngestions,toolchainHashCount:this.toolchainHashCount,toolchainHashMs:this.toolchainHashMs,compilerModuleCloned:this.compilerModuleCloned,workerRetained:!!this.slot&&!this.active,workerRetirements:this.retirements,compilerModuleIdentityBytes:this.cacheCompilerModule?this.toolchain?.compilerBytes??0:0,latest:this.active?.stats??this.latest})}clearCaches(){this.cacheValidation=void 0,this.generation++,this.objects.clear(),this.toolchain=void 0,this.active||(this.toolchainController?.abort(),this.toolchainLoading=void 0),this.active||this.retireWorker()}stop(){return this.clearCaches(),this.cancelCurrentOperation()}cancelCurrentOperation(){if(this.cancellationDraining)return this.cancellationDraining;this.operationId++;const A=this.promise,g=this.active?.publication;this.retireWorker(),this.objects.discardBatch(),this.active&&this.finish(this.active,{type:"stopped"});const I=Promise.allSettled([A,g]).then(()=>{this.cancellationDraining===I&&(this.cancellationDraining=void 0)});return this.cancellationDraining=I,I}releaseCompilerResources(A={}){const g=A.signal;return g?.aborted?Promise.resolve("cancelled"):this.disposed?Promise.resolve("released"):new Promise(I=>{const C={resolve:I,signal:g,abort:()=>this.settleRelease(C,"cancelled")};this.releases.add(C),g?.addEventListener("abort",C.abort,{once:!0}),this.flushReleases()})}settleRelease(A,g){this.releases.delete(A)&&(A.signal?.removeEventListener("abort",A.abort),A.resolve(g))}flushReleases(){if(!(this.active||!this.releases.size||this.releaseDrain)){if(this.initializing.size){this.toolchainController?.abort();const A=[...this.initializing];this.toolchainLoading=void 0,this.releaseDrain=Promise.allSettled(A).then(()=>{this.releaseDrain=void 0,this.flushReleases()});return}this.retireWorker(),this.toolchainController?.abort(),this.toolchain=void 0,this.toolchainLoading=void 0;for(const A of this.releases)this.settleRelease(A,"released")}}dispose(){if(this.disposal)return this.disposal;this.disposed=!0,this.scopeEpoch++,this.fs={},this.binaryFiles={},this.cppArtifacts=void 0,this.hostDevice=void 0,this.stdout.removeAllListeners(),this.stderr.removeAllListeners(),this.debugger.removeAllListeners();const A=[...this.initializing];return this.toolchainController?.abort(),this.disposal=Promise.allSettled([this.stop(),...A]).then(()=>{this.latest=void 0,this.flushReleases()}),this.disposal}prepareCompiler(A){if(A?.validateCacheInputs!==void 0&&typeof A.validateCacheInputs!="boolean")return Promise.resolve(h(new TypeError("Invalid compiler preparation options")));const g=A?.validateCacheInputs===!0&&this.options?.toolchainProfile==="stock-certified-v1"&&!!this.options?.objectCache&&this.objects.limits.maxEntries>0&&this.objects.limits.maxObjectBytes>0&&this.objects.limits.maxMetadataBytes>0&&this.objects.limits.maxEntryMetadataBytes>0;return this.submit(!0,!0,g)}run(){return this.submit(!1)}compile(){return this.submit(!0)}submit(A,g=!1,I=!1){if(this.disposed)return Promise.resolve(h(new Error("Engine is disposed")));if(this.active||this.cancellationDraining)return Promise.resolve(h(new Error("An engine job is already active")));if(A&&this.lang!=="c")return Promise.resolve(h(new Error("Compile-only is supported for C/C++")));this.cacheValidation=void 0;const C=g&&!I;let B;try{const Y=C||!this.cppArtifacts?null:{...this.cppArtifacts};if(Y?.cacheCertificate!==void 0){const s=Y.cacheCertificate;(typeof s!="string"||s.length>1024*1024||new TextEncoder().encode(s).byteLength>1024*1024)&&delete Y.cacheCertificate}B={fs:C?{}:structuredClone(this.fs),binary_files:Object.fromEntries(Object.entries(C?{}:this.binaryFiles).map(([s,q])=>[s,new Uint8Array(q)])),cpp_artifacts:structuredClone(Y)}}catch(Y){return Promise.resolve(h(Y))}const i=!A&&this.debugger.enabled,D=A?void 0:this.hostDevice;if(D!==void 0&&(typeof D!="function"||!["c","python"].includes(this.lang)))return Promise.resolve(h(new TypeError("Invalid host device configuration")));clearTimeout(this.idleTimer),this.stdin[J].clear();const N=!!this.slot;let K;const U=new Promise(Y=>{K=Y});this.promise=U;const L={generation:this.generation,scopeEpoch:this.scopeEpoch,operationId:++this.operationId,cacheEpoch:this.generation,prepareOnly:g,validateCacheInputs:I,settled:!1,buildOnly:A,debug:i,opener:D,startedAt:performance.now(),resolve:K,stats:{operation:g?"prepare_compiler":A?"compile":"run",workerReadyMs:0,workerReused:N},start:{...B,lang:this.lang,prepare_compiler:g,validate_cache_inputs:I,scope_epoch:this.scopeEpoch,operation_id:this.operationId,cache_epoch:this.generation,is_debug:i,build_only:A,stdin_buffer:this.stdin[J].buffer,cpp_cache:this.options?.objectCache&&!i&&!g?{generation:this.generation,entries:this.objects.snapshot(),max_entry_metadata_bytes:Math.min(this.objects.limits.maxEntryMetadataBytes,this.objects.limits.maxMetadataBytes,1024*1024)}:null}};this.objects.beginBatch(),this.active=L;try{if(this.slot||this.makeWorker(),!this.current(L))return U;const Y=this.slot;this.lang==="c"&&!this.toolchain&&this.ensureToolchain().catch(s=>{this.current(L)&&this.slot===Y&&this.finish(L,h(s))}),this.slot.ready&&this.dispatch(L)}catch(Y){this.finish(L,h(Y))}return U}current(A){return this.active===A&&!A.settled}makeWorker(){const A=mA(this.wasmUrl),g={worker:A,ready:!1,remove:()=>{}};this.slot=g;const I=i=>{if(this.slot!==g)return;const D=i.data,N=this.active;if(D.type==="ready"){if(g.ready)return;g.ready=!0,N&&this.current(N)&&this.dispatch(N);return}if(!(!N||!this.current(N))){if(!g.ready&&D.type==="error"){this.finish(N,h(new Error(D.message)));return}if(!(D.operationId!==N.operationId||D.scopeEpoch!==N.scopeEpoch))try{if(D.type==="cpp_cache_eligibility"){if(this.options?.toolchainProfile!=="stock-certified-v1"||N.prepareOnly&&!N.validateCacheInputs)return;const K=L=>typeof L=="string"&&/^[0-9a-f]{64}$/.test(L),U=D.eligible===!0&&K(D.certificate_sha256)&&K(D.snapshot);this.cacheValidation={eligible:U,certificate:K(D.certificate_sha256)?D.certificate_sha256:void 0,snapshot:U?D.snapshot:void 0,operationId:N.operationId,reason:U?void 0:typeof D.reason=="string"?D.reason.slice(0,128):"stock-input-validation"}}else if(D.type==="stop")this.finish(N,{type:"completed",exitCode:D.exit_code,timing:{totalMs:performance.now()-N.startedAt,buildMs:D.build_ms,runMs:D.run_ms}});else if(D.type==="error")this.finish(N,h(new Error(D.message)));else if(D.type==="cpp_cache_object"&&D.generation===this.generation&&N.generation===this.generation)try{this.objects.stage(D)}catch{this.objects.abandonBatch()}else D.type==="cpp_cache_stats"&&D.generation===N.generation?N.stats.cache=D.stats:D.type==="cpp_cache_abandon"?this.objects.abandonBatch():D.type==="object_build_complete"?N.publication??=this.publishObjects(N,g):D.type==="compiler_module_stats"&&(N.stats.compilerModule=D)}catch(K){this.finish(N,h(K))}}},C=i=>{this.slot===g&&(this.clearCaches(),this.active?this.finish(this.active,h(i.error??new Error(i.message))):this.retireWorker())},B=()=>C({message:"Unreadable execution worker message"});this.debugger[J].attach(A),A.addEventListener("message",I),A.addEventListener("error",C),A.addEventListener("messageerror",B),g.remove=()=>{A.removeEventListener("message",I),A.removeEventListener("error",C),A.removeEventListener("messageerror",B),this.debugger[J].detach(A)}}async publishObjects(A,g){let I=!1;try{I=await this.objects.validateBatch()}catch{}if(!(!this.current(A)||this.slot!==g)){try{I&&A.cacheEpoch===this.generation?this.objects.commitBatch():(this.objects.abandonBatch(),this.cacheValidation?.operationId===A.operationId&&(this.cacheValidation={...this.cacheValidation,eligible:!1,snapshot:void 0,reason:"stock-publication-budget-or-validation"}))}catch{this.objects.clear(),this.cacheValidation?.operationId===A.operationId&&(this.cacheValidation={...this.cacheValidation,eligible:!1,snapshot:void 0,reason:"stock-publication-failure"})}this.current(A)&&g.worker.postMessage({type:"object_build_ack",scopeEpoch:A.scopeEpoch,operationId:A.operationId,cacheEpoch:A.cacheEpoch})}}ensureToolchain(){if(this.toolchain)return Promise.resolve(this.toolchain);if(this.toolchainLoading)return this.toolchainLoading;this.toolchainController=new AbortController;const A=l.load(iA("c"),this.cacheCompilerModule,this.toolchainController.signal,sA(),this.options?.toolchainProfile);return this.toolchainLoading=A,this.initializing.add(A),A.then(()=>this.initializing.delete(A),()=>{this.initializing.delete(A),this.toolchainLoading===A&&(this.toolchainLoading=void 0)}),A}async dispatch(A){const g=this.slot;if(!(!this.current(A)||!g))try{if(this.lang==="c"){const B=this.scopeEpoch,i=this.generation,D=this.ensureToolchain(),N=this.toolchain??await D;if(!this.current(A)||this.slot!==g||B!==this.scopeEpoch)return;const K=A.start.cpp_artifacts?.requiredToolchain;if(K&&!N.matchesExpectation(K)){this.finish(A,{type:"error",error:{type:"artifact-toolchain-integrity",message:"C++ artifacts require a different compiler, sysroot, or exception runtime"}});return}i===this.generation&&(this.toolchainIdentity&&this.toolchainIdentity!==N.identity&&(this.objects.clear(),A.start.cpp_cache=null),this.toolchain!==N&&(this.toolchainIngestions++,this.toolchainHashCount+=N.hashCount,this.toolchainHashMs+=N.hashMs),this.toolchainIdentity=N.identity,this.toolchain=N,this.toolchainLoading===D&&(this.toolchainLoading=void 0)),g.toolchain!==N&&(this.compilerModuleCloned=N.configure(g.worker,{type:"configure_cpp",cacheCompilerModule:this.cacheCompilerModule}),g.toolchain=N)}if(!this.current(A)||this.slot!==g)return;const I=g.worker;A.stats.workerReadyMs=performance.now()-A.startedAt;const C=B=>this.current(A)&&B.scopeEpoch===A.scopeEpoch&&B.operationId===A.operationId;if(this.stdout[J].attach(I,C),this.stderr[J].attach(I,C),A.prepareOnly||this.debugger[J].beginRun(),A.opener){if(A.device=new nA(B=>this.finish(A,h(B))),A.device.attach(I),A.device.open(A.opener),!this.current(A))return;A.start.host_device=A.device.workerStart}this.current(A)&&(I.postMessage(A.start),A.start.fs={},A.start.binary_files={},A.start.cpp_artifacts=null,A.start.cpp_cache=null)}catch(I){this.current(A)&&(this.toolchainLoading=void 0,this.finish(A,h(I)))}}finish(A,g){if(!this.current(A))return;(g.type!=="completed"||g.exitCode!==0)&&(this.cacheValidation=void 0),A.settled=!0;const I=this.slot?.worker;I&&(this.stdout[J].detach(I),this.stderr[J].detach(I));const C=A.device?.close();C&&(g=h(C));const B=g.type==="completed"&&A.generation===this.generation&&!this.disposed,i=B&&g.type==="completed"&&g.exitCode===0;if(A.generation===this.generation)for(const D of A.stats.cache?.invalid_sources??[])this.objects.delete(D);if(i)for(const D of A.stats.cache?.hit_sources??[])this.objects.touch(D);this.objects.discardBatch(),this.latest=A.stats,this.stdin[J].clear(),(!B||!this.retain)&&this.retireWorker(),!this.disposed&&A.cacheEpoch===this.generation&&(this.slot||this.toolchain&&this.cacheCompilerModule)&&this.options?.compilerLifetime!=="project"&&(this.idleTimer=setTimeout(()=>{this.retireWorker(),this.toolchain=void 0,this.toolchainLoading=void 0},this.idleTimeoutMs)),!this.retain&&!this.cacheCompilerModule&&(this.toolchain=void 0),A.cacheEpoch!==this.generation&&(this.toolchainController?.abort(),this.toolchainLoading=void 0),this.active=void 0,this.promise=void 0,this.flushReleases(),A.resolve(g)}retireWorker(){clearTimeout(this.idleTimer);const A=this.slot;A&&(this.slot=void 0,A.remove(),this.stdout[J].detach(A.worker),this.stderr[J].detach(A.worker),A.worker.onerror=g=>g.preventDefault(),A.worker.terminate(),this.retirements++)}}class QA extends wA{constructor(A){super(),this.mode=A,this.callback=(g=>{const I=g.data;if(this.accepts&&!this.accepts(I)||I.type!=="stdout"||I.mode!==this.mode)return;const C=I.data;this.emit("data",C)}).bind(this),this[J]={attach:this.attach.bind(this),detach:this.detach.bind(this)}}callback;accepts;[J];attach(A,g){this.accepts=g,A.addEventListener("message",this.callback)}detach(A){A.removeEventListener("message",this.callback)}}class H{static BUFFER_SIZE=2048;static HEADER_SIZE=8;static DATA_SIZE=H.BUFFER_SIZE-H.HEADER_SIZE;static READ_IDX=0;static WRITE_IDX=1;static encoder=new TextEncoder;buffer=new SharedArrayBuffer(H.BUFFER_SIZE);generation=0;indices;data;[J];constructor(){this.indices=new Int32Array(this.buffer,0,2),this.data=new Int8Array(this.buffer,H.HEADER_SIZE);const A=()=>this.buffer;this[J]={clear:this.clear.bind(this),get buffer(){return A()}}}clear(){this.generation++,Atomics.notify(this.indices,H.READ_IDX),this.buffer=new SharedArrayBuffer(H.BUFFER_SIZE),this.indices=new Int32Array(this.buffer,0,2),this.data=new Int8Array(this.buffer,H.HEADER_SIZE)}async write(A){const g=typeof A=="string"?H.encoder.encode(A):A;return this.writeBytes(g)}async writeBytes(A){const{DATA_SIZE:g,READ_IDX:I,WRITE_IDX:C}=H;let B=0;const i=this.generation;for(;B<A.length&&i===this.generation;){const D=Atomics.load(this.indices,I);let N=Atomics.load(this.indices,C);N===g-1&&D>0&&(N=0);const K=D<=N?g-N-1:D-N-1;if(K===0){await Atomics.waitAsync(this.indices,I,D).value;continue}const U=Math.min(A.length-B,K);this.data.set(A.subarray(B,B+U),N),Atomics.store(this.indices,C,(N+U)%g),Atomics.notify(this.indices,C),B+=U}}}a.Artifact=MA,a.Debugger=GA,a.Engine=CA,a.HOST_DEVICE_PATH=PA,a.Stdin=H,a.Stdout=QA,Object.defineProperty(a,Symbol.toStringTag,{value:"Module"})}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verified-toolchain.d.ts","sourceRoot":"","sources":["../src/ts/verified-toolchain.ts"],"names":[],"mappings":"AAEA,sFAAsF;AACtF,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,UAAU,CAAC;IACrB,OAAO,EAAE,UAAU,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,MAAM,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC;CAC7B;AAED,qBAAa,iBAAiB;;IAE5B,QAAQ,CAAC,SAAS,KAAK;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,OAAO;WAKM,IAAI,CACf,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,WAAW,EAAE,OAAO,EACpB,MAAM,CAAC,EAAE,WAAW,EACpB,cAAc,GAAE,MAA4C,EAC5D,OAAO,SAAW,GACjB,OAAO,CAAC,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"verified-toolchain.d.ts","sourceRoot":"","sources":["../src/ts/verified-toolchain.ts"],"names":[],"mappings":"AAEA,sFAAsF;AACtF,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,UAAU,CAAC;IACrB,OAAO,EAAE,UAAU,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,MAAM,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC;CAC7B;AAED,qBAAa,iBAAiB;;IAE5B,QAAQ,CAAC,SAAS,KAAK;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,OAAO;WAKM,IAAI,CACf,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,WAAW,EAAE,OAAO,EACpB,MAAM,CAAC,EAAE,WAAW,EACpB,cAAc,GAAE,MAA4C,EAC5D,OAAO,SAAW,GACjB,OAAO,CAAC,iBAAiB,CAAC;IAoD7B,mFAAmF;WACtE,SAAS,CACpB,aAAa,EAAE,UAAU,EACzB,YAAY,EAAE,UAAU,EACxB,WAAW,EAAE,OAAO,GACnB,OAAO,CAAC,iBAAiB,CAAC;mBAWR,WAAW;IAkBhC,kBAAkB,CAAC,QAAQ,EAAE;QAC3B,cAAc,EAAE,MAAM,CAAC;QACvB,aAAa,EAAE,MAAM,CAAC;QACtB,gBAAgB,EAAE,MAAM,CAAC;KAC1B,GAAG,OAAO;IAQX,IAAI,QAAQ,IAAI,MAAM,CAErB;IACD,IAAI,aAAa,IAAI,MAAM,CAE1B;IACD,IAAI,aAAa,IAAI,MAAM,CAE1B;IAED,oFAAoF;IACpF,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO;CAWrD"}
|