diff --git a/pkg/argus_wasm.d.ts b/pkg/argus_wasm.d.ts index 4aa98fe..6ae1681 100644 --- a/pkg/argus_wasm.d.ts +++ b/pkg/argus_wasm.d.ts @@ -1,39 +1,17 @@ /* tslint:disable */ /* eslint-disable */ -export function eval_boolean(s: string, trace: StateBuddyTrace): StateBuddyEvalResult; -export class StateBuddyEvalResult { - private constructor(); - free(): void; - [Symbol.dispose](): void; -} -export class StateBuddyEvalResultEntry { - private constructor(); - free(): void; - [Symbol.dispose](): void; -} -export class StateBuddyTrace { - private constructor(); - free(): void; - [Symbol.dispose](): void; -} -export class StateBuddyTraceEntry { - private constructor(); - free(): void; - [Symbol.dispose](): void; -} +export function eval_boolean(s: string, js_trace: any): any; export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module; export interface InitOutput { readonly memory: WebAssembly.Memory; - readonly __wbg_statebuddytraceentry_free: (a: number, b: number) => void; - readonly __wbg_statebuddytrace_free: (a: number, b: number) => void; - readonly eval_boolean: (a: number, b: number, c: number) => number; - readonly __wbg_statebuddyevalresultentry_free: (a: number, b: number) => void; - readonly __wbg_statebuddyevalresult_free: (a: number, b: number) => void; - readonly __wbindgen_externrefs: WebAssembly.Table; + readonly eval_boolean: (a: number, b: number, c: any) => any; readonly __wbindgen_malloc: (a: number, b: number) => number; readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number; + readonly __wbindgen_exn_store: (a: number) => void; + readonly __externref_table_alloc: () => number; + readonly __wbindgen_externrefs: WebAssembly.Table; readonly __wbindgen_start: () => void; } diff --git a/pkg/argus_wasm.js b/pkg/argus_wasm.js index e9accae..8cc58dd 100644 --- a/pkg/argus_wasm.js +++ b/pkg/argus_wasm.js @@ -30,6 +30,75 @@ function getStringFromWasm0(ptr, len) { return decodeText(ptr, len); } +function isLikeNone(x) { + return x === undefined || x === null; +} + +function debugString(val) { + // primitive types + const type = typeof val; + if (type == 'number' || type == 'boolean' || val == null) { + return `${val}`; + } + if (type == 'string') { + return `"${val}"`; + } + if (type == 'symbol') { + const description = val.description; + if (description == null) { + return 'Symbol'; + } else { + return `Symbol(${description})`; + } + } + if (type == 'function') { + const name = val.name; + if (typeof name == 'string' && name.length > 0) { + return `Function(${name})`; + } else { + return 'Function'; + } + } + // objects + if (Array.isArray(val)) { + const length = val.length; + let debug = '['; + if (length > 0) { + debug += debugString(val[0]); + } + for(let i = 1; i < length; i++) { + debug += ', ' + debugString(val[i]); + } + debug += ']'; + return debug; + } + // Test for built-in + const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val)); + let className; + if (builtInMatches && builtInMatches.length > 1) { + className = builtInMatches[1]; + } else { + // Failed to match the standard '[object ClassName]' + return toString.call(val); + } + if (className == 'Object') { + // we're a user defined class or Object + // JSON.stringify avoids problems with cycles, and is generally much + // easier than looping through ownProperties of `val`. + try { + return 'Object(' + JSON.stringify(val) + ')'; + } catch (_) { + return 'Object'; + } + } + // errors + if (val instanceof Error) { + return `${val.name}: ${val.message}\n${val.stack}`; + } + // TODO we could test for more things here, like `Set`s and `Map`s. + return className; +} + let WASM_VECTOR_LEN = 0; const cachedTextEncoder = new TextEncoder(); @@ -84,112 +153,46 @@ function passStringToWasm0(arg, malloc, realloc) { return ptr; } -function _assertClass(instance, klass) { - if (!(instance instanceof klass)) { - throw new Error(`expected instance of ${klass.name}`); +let cachedDataViewMemory0 = null; + +function getDataViewMemory0() { + if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) { + cachedDataViewMemory0 = new DataView(wasm.memory.buffer); } + return cachedDataViewMemory0; +} + +function addToExternrefTable0(obj) { + const idx = wasm.__externref_table_alloc(); + wasm.__wbindgen_externrefs.set(idx, obj); + return idx; +} + +function handleError(f, args) { + try { + return f.apply(this, args); + } catch (e) { + const idx = addToExternrefTable0(e); + wasm.__wbindgen_exn_store(idx); + } +} + +function getArrayU8FromWasm0(ptr, len) { + ptr = ptr >>> 0; + return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len); } /** * @param {string} s - * @param {StateBuddyTrace} trace - * @returns {StateBuddyEvalResult} + * @param {any} js_trace + * @returns {any} */ -export function eval_boolean(s, trace) { +export function eval_boolean(s, js_trace) { const ptr0 = passStringToWasm0(s, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); const len0 = WASM_VECTOR_LEN; - _assertClass(trace, StateBuddyTrace); - const ret = wasm.eval_boolean(ptr0, len0, trace.__wbg_ptr); - return StateBuddyEvalResult.__wrap(ret); + const ret = wasm.eval_boolean(ptr0, len0, js_trace); + return ret; } -const StateBuddyEvalResultFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_statebuddyevalresult_free(ptr >>> 0, 1)); - -export class StateBuddyEvalResult { - - static __wrap(ptr) { - ptr = ptr >>> 0; - const obj = Object.create(StateBuddyEvalResult.prototype); - obj.__wbg_ptr = ptr; - StateBuddyEvalResultFinalization.register(obj, obj.__wbg_ptr, obj); - return obj; - } - - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - StateBuddyEvalResultFinalization.unregister(this); - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_statebuddyevalresult_free(ptr, 0); - } -} -if (Symbol.dispose) StateBuddyEvalResult.prototype[Symbol.dispose] = StateBuddyEvalResult.prototype.free; - -const StateBuddyEvalResultEntryFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_statebuddyevalresultentry_free(ptr >>> 0, 1)); - -export class StateBuddyEvalResultEntry { - - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - StateBuddyEvalResultEntryFinalization.unregister(this); - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_statebuddyevalresultentry_free(ptr, 0); - } -} -if (Symbol.dispose) StateBuddyEvalResultEntry.prototype[Symbol.dispose] = StateBuddyEvalResultEntry.prototype.free; - -const StateBuddyTraceFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_statebuddytrace_free(ptr >>> 0, 1)); - -export class StateBuddyTrace { - - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - StateBuddyTraceFinalization.unregister(this); - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_statebuddytrace_free(ptr, 0); - } -} -if (Symbol.dispose) StateBuddyTrace.prototype[Symbol.dispose] = StateBuddyTrace.prototype.free; - -const StateBuddyTraceEntryFinalization = (typeof FinalizationRegistry === 'undefined') - ? { register: () => {}, unregister: () => {} } - : new FinalizationRegistry(ptr => wasm.__wbg_statebuddytraceentry_free(ptr >>> 0, 1)); - -export class StateBuddyTraceEntry { - - __destroy_into_raw() { - const ptr = this.__wbg_ptr; - this.__wbg_ptr = 0; - StateBuddyTraceEntryFinalization.unregister(this); - return ptr; - } - - free() { - const ptr = this.__destroy_into_raw(); - wasm.__wbg_statebuddytraceentry_free(ptr, 0); - } -} -if (Symbol.dispose) StateBuddyTraceEntry.prototype[Symbol.dispose] = StateBuddyTraceEntry.prototype.free; - const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']); async function __wbg_load(module, imports) { @@ -228,9 +231,159 @@ async function __wbg_load(module, imports) { function __wbg_get_imports() { const imports = {}; imports.wbg = {}; + imports.wbg.__wbg_Error_e83987f665cf5504 = function(arg0, arg1) { + const ret = Error(getStringFromWasm0(arg0, arg1)); + return ret; + }; + imports.wbg.__wbg___wbindgen_boolean_get_6d5a1ee65bab5f68 = function(arg0) { + const v = arg0; + const ret = typeof(v) === 'boolean' ? v : undefined; + return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0; + }; + imports.wbg.__wbg___wbindgen_debug_string_df47ffb5e35e6763 = function(arg0, arg1) { + const ret = debugString(arg1); + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true); + getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true); + }; + imports.wbg.__wbg___wbindgen_in_bb933bd9e1b3bc0f = function(arg0, arg1) { + const ret = arg0 in arg1; + return ret; + }; + imports.wbg.__wbg___wbindgen_is_function_ee8a6c5833c90377 = function(arg0) { + const ret = typeof(arg0) === 'function'; + return ret; + }; + imports.wbg.__wbg___wbindgen_is_object_c818261d21f283a4 = function(arg0) { + const val = arg0; + const ret = typeof(val) === 'object' && val !== null; + return ret; + }; + imports.wbg.__wbg___wbindgen_is_undefined_2d472862bd29a478 = function(arg0) { + const ret = arg0 === undefined; + return ret; + }; + imports.wbg.__wbg___wbindgen_jsval_loose_eq_b664b38a2f582147 = function(arg0, arg1) { + const ret = arg0 == arg1; + return ret; + }; + imports.wbg.__wbg___wbindgen_number_get_a20bf9b85341449d = function(arg0, arg1) { + const obj = arg1; + const ret = typeof(obj) === 'number' ? obj : undefined; + getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true); + getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true); + }; + imports.wbg.__wbg___wbindgen_string_get_e4f06c90489ad01b = function(arg0, arg1) { + const obj = arg1; + const ret = typeof(obj) === 'string' ? obj : undefined; + var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + var len1 = WASM_VECTOR_LEN; + getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true); + getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true); + }; imports.wbg.__wbg___wbindgen_throw_b855445ff6a94295 = function(arg0, arg1) { throw new Error(getStringFromWasm0(arg0, arg1)); }; + imports.wbg.__wbg_call_e762c39fa8ea36bf = function() { return handleError(function (arg0, arg1) { + const ret = arg0.call(arg1); + return ret; + }, arguments) }; + imports.wbg.__wbg_done_2042aa2670fb1db1 = function(arg0) { + const ret = arg0.done; + return ret; + }; + imports.wbg.__wbg_get_7bed016f185add81 = function(arg0, arg1) { + const ret = arg0[arg1 >>> 0]; + return ret; + }; + imports.wbg.__wbg_get_efcb449f58ec27c2 = function() { return handleError(function (arg0, arg1) { + const ret = Reflect.get(arg0, arg1); + return ret; + }, arguments) }; + imports.wbg.__wbg_get_with_ref_key_1dc361bd10053bfe = function(arg0, arg1) { + const ret = arg0[arg1]; + return ret; + }; + imports.wbg.__wbg_instanceof_ArrayBuffer_70beb1189ca63b38 = function(arg0) { + let result; + try { + result = arg0 instanceof ArrayBuffer; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbg_instanceof_Uint8Array_20c8e73002f7af98 = function(arg0) { + let result; + try { + result = arg0 instanceof Uint8Array; + } catch (_) { + result = false; + } + const ret = result; + return ret; + }; + imports.wbg.__wbg_isArray_96e0af9891d0945d = function(arg0) { + const ret = Array.isArray(arg0); + return ret; + }; + imports.wbg.__wbg_iterator_e5822695327a3c39 = function() { + const ret = Symbol.iterator; + return ret; + }; + imports.wbg.__wbg_length_69bca3cb64fc8748 = function(arg0) { + const ret = arg0.length; + return ret; + }; + imports.wbg.__wbg_length_cdd215e10d9dd507 = function(arg0) { + const ret = arg0.length; + return ret; + }; + imports.wbg.__wbg_new_1acc0b6eea89d040 = function() { + const ret = new Object(); + return ret; + }; + imports.wbg.__wbg_new_5a79be3ab53b8aa5 = function(arg0) { + const ret = new Uint8Array(arg0); + return ret; + }; + imports.wbg.__wbg_new_e17d9f43105b08be = function() { + const ret = new Array(); + return ret; + }; + imports.wbg.__wbg_next_020810e0ae8ebcb0 = function() { return handleError(function (arg0) { + const ret = arg0.next(); + return ret; + }, arguments) }; + imports.wbg.__wbg_next_2c826fe5dfec6b6a = function(arg0) { + const ret = arg0.next; + return ret; + }; + imports.wbg.__wbg_prototypesetcall_2a6620b6922694b2 = function(arg0, arg1, arg2) { + Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2); + }; + imports.wbg.__wbg_set_3f1d0b984ed272ed = function(arg0, arg1, arg2) { + arg0[arg1] = arg2; + }; + imports.wbg.__wbg_set_c213c871859d6500 = function(arg0, arg1, arg2) { + arg0[arg1 >>> 0] = arg2; + }; + imports.wbg.__wbg_value_692627309814bb8c = function(arg0) { + const ret = arg0.value; + return ret; + }; + imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) { + // Cast intrinsic for `Ref(String) -> Externref`. + const ret = getStringFromWasm0(arg0, arg1); + return ret; + }; + imports.wbg.__wbindgen_cast_d6cd19b81560fd6e = function(arg0) { + // Cast intrinsic for `F64 -> Externref`. + const ret = arg0; + return ret; + }; imports.wbg.__wbindgen_init_externref_table = function() { const table = wasm.__wbindgen_externrefs; const offset = table.grow(4); @@ -248,6 +401,7 @@ function __wbg_get_imports() { function __wbg_finalize_init(instance, module) { wasm = instance.exports; __wbg_init.__wbindgen_wasm_module = module; + cachedDataViewMemory0 = null; cachedUint8ArrayMemory0 = null; diff --git a/pkg/argus_wasm_bg.wasm b/pkg/argus_wasm_bg.wasm index bcc1b44..e705a7e 100644 Binary files a/pkg/argus_wasm_bg.wasm and b/pkg/argus_wasm_bg.wasm differ diff --git a/pkg/argus_wasm_bg.wasm.d.ts b/pkg/argus_wasm_bg.wasm.d.ts index 2d93571..ae2987d 100644 --- a/pkg/argus_wasm_bg.wasm.d.ts +++ b/pkg/argus_wasm_bg.wasm.d.ts @@ -1,12 +1,10 @@ /* tslint:disable */ /* eslint-disable */ export const memory: WebAssembly.Memory; -export const __wbg_statebuddytraceentry_free: (a: number, b: number) => void; -export const __wbg_statebuddytrace_free: (a: number, b: number) => void; -export const eval_boolean: (a: number, b: number, c: number) => number; -export const __wbg_statebuddyevalresultentry_free: (a: number, b: number) => void; -export const __wbg_statebuddyevalresult_free: (a: number, b: number) => void; -export const __wbindgen_externrefs: WebAssembly.Table; +export const eval_boolean: (a: number, b: number, c: any) => any; export const __wbindgen_malloc: (a: number, b: number) => number; export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number; +export const __wbindgen_exn_store: (a: number) => void; +export const __externref_table_alloc: () => number; +export const __wbindgen_externrefs: WebAssembly.Table; export const __wbindgen_start: () => void;