honse-sim 0.1.0
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/LICENSE +674 -0
- package/package.json +21 -0
- package/uma_sim_wasm.d.ts +130 -0
- package/uma_sim_wasm.js +675 -0
- package/uma_sim_wasm_bg.wasm +0 -0
package/uma_sim_wasm.js
ADDED
|
@@ -0,0 +1,675 @@
|
|
|
1
|
+
/* @ts-self-types="./uma_sim_wasm.d.ts" */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A streaming race simulator with per-event JS callbacks.
|
|
5
|
+
*
|
|
6
|
+
* Construct with [`WasmRaceSimulator::new`], register callbacks, then call
|
|
7
|
+
* [`run`](WasmRaceSimulator::run) to drive the race aggregate over the
|
|
8
|
+
* configured rounds. Callbacks fire live; the serialized batch result is
|
|
9
|
+
* returned at the end.
|
|
10
|
+
*/
|
|
11
|
+
export class WasmRaceSimulator {
|
|
12
|
+
__destroy_into_raw() {
|
|
13
|
+
const ptr = this.__wbg_ptr;
|
|
14
|
+
this.__wbg_ptr = 0;
|
|
15
|
+
WasmRaceSimulatorFinalization.unregister(this);
|
|
16
|
+
return ptr;
|
|
17
|
+
}
|
|
18
|
+
free() {
|
|
19
|
+
const ptr = this.__destroy_into_raw();
|
|
20
|
+
wasm.__wbg_wasmracesimulator_free(ptr, 0);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Build a simulator from a [`WasmRaceSimParams`] JS object.
|
|
24
|
+
* @param {any} params
|
|
25
|
+
*/
|
|
26
|
+
constructor(params) {
|
|
27
|
+
const ret = wasm.wasmracesimulator_new(params);
|
|
28
|
+
if (ret[2]) {
|
|
29
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
30
|
+
}
|
|
31
|
+
this.__wbg_ptr = ret[0];
|
|
32
|
+
WasmRaceSimulatorFinalization.register(this, this.__wbg_ptr, this);
|
|
33
|
+
return this;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Run the configured rounds, firing callbacks live, and return the
|
|
37
|
+
* serialized [`WasmRaceSimResult`].
|
|
38
|
+
* @returns {any}
|
|
39
|
+
*/
|
|
40
|
+
run() {
|
|
41
|
+
const ptr = this.__destroy_into_raw();
|
|
42
|
+
const ret = wasm.wasmracesimulator_run(ptr);
|
|
43
|
+
if (ret[2]) {
|
|
44
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
45
|
+
}
|
|
46
|
+
return takeFromExternrefTable0(ret[0]);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Register the `after-runner-tick(snapshot)` callback.
|
|
50
|
+
* @param {Function} cb
|
|
51
|
+
*/
|
|
52
|
+
setOnAfterRunnerTick(cb) {
|
|
53
|
+
wasm.wasmracesimulator_setOnAfterRunnerTick(this.__wbg_ptr, cb);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Register the `before-tick(dt)` callback.
|
|
57
|
+
* @param {Function} cb
|
|
58
|
+
*/
|
|
59
|
+
setOnBeforeTick(cb) {
|
|
60
|
+
wasm.wasmracesimulator_setOnBeforeTick(this.__wbg_ptr, cb);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Register the `round-end()` callback.
|
|
64
|
+
* @param {Function} cb
|
|
65
|
+
*/
|
|
66
|
+
setOnRoundEnd(cb) {
|
|
67
|
+
wasm.wasmracesimulator_setOnRoundEnd(this.__wbg_ptr, cb);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Register the `round-start(seed)` callback.
|
|
71
|
+
* @param {Function} cb
|
|
72
|
+
*/
|
|
73
|
+
setOnRoundStart(cb) {
|
|
74
|
+
wasm.wasmracesimulator_setOnRoundStart(this.__wbg_ptr, cb);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Register the `runner-finished(runnerId)` callback.
|
|
78
|
+
* @param {Function} cb
|
|
79
|
+
*/
|
|
80
|
+
setOnRunnerFinished(cb) {
|
|
81
|
+
wasm.wasmracesimulator_setOnRunnerFinished(this.__wbg_ptr, cb);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
if (Symbol.dispose) WasmRaceSimulator.prototype[Symbol.dispose] = WasmRaceSimulator.prototype.free;
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* All condition tokens the Rust engine's catalog recognizes.
|
|
88
|
+
*
|
|
89
|
+
* Exposed so the TS-side simulatability gate (ADR-0003, driven by the TS
|
|
90
|
+
* `knownConditionTokens` vocabulary) can be cross-checked against the engine
|
|
91
|
+
* that actually runs the sim, closing the dual-parser drift risk (ADR-0004):
|
|
92
|
+
* any token the UI treats as simulatable must be resolvable by this engine.
|
|
93
|
+
* Returned as a sorted JS string array.
|
|
94
|
+
* @returns {string[]}
|
|
95
|
+
*/
|
|
96
|
+
export function knownConditionTokens() {
|
|
97
|
+
const ret = wasm.knownConditionTokens();
|
|
98
|
+
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
|
|
99
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
100
|
+
return v1;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Run a batch compare-family simulation and return the serialized result.
|
|
105
|
+
*
|
|
106
|
+
* `params` is a [`WasmCompareParams`] JS object (a small vacuum field over
|
|
107
|
+
* `nsamples` rounds). Returns a [`WasmCompareData`] (per-round, per-runner
|
|
108
|
+
* telemetry); the bashin-delta + summary stats are computed on the TS side.
|
|
109
|
+
* @param {any} params
|
|
110
|
+
* @returns {any}
|
|
111
|
+
*/
|
|
112
|
+
export function runCompare(params) {
|
|
113
|
+
const ret = wasm.runCompare(params);
|
|
114
|
+
if (ret[2]) {
|
|
115
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
116
|
+
}
|
|
117
|
+
return takeFromExternrefTable0(ret[0]);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Run a same-race compare-family simulation and return the serialized result.
|
|
122
|
+
*
|
|
123
|
+
* `params` is a [`WasmContestedCompareParams`] JS object (2..=12 compared
|
|
124
|
+
* runners, optionally mob-filled via `fillTo`). Returns the same [`WasmCompareData`] shape
|
|
125
|
+
* as vacuum compare so the TS reducer can be reused.
|
|
126
|
+
* @param {any} params
|
|
127
|
+
* @returns {any}
|
|
128
|
+
*/
|
|
129
|
+
export function runContestedCompare(params) {
|
|
130
|
+
const ret = wasm.runContestedCompare(params);
|
|
131
|
+
if (ret[2]) {
|
|
132
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
133
|
+
}
|
|
134
|
+
return takeFromExternrefTable0(ret[0]);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Run a batch race simulation and return the serialized result.
|
|
139
|
+
*
|
|
140
|
+
* `params` is a [`WasmRaceSimParams`] JS object. Returns a
|
|
141
|
+
* [`WasmRaceSimResult`] (per-round finish orders + focus telemetry).
|
|
142
|
+
* @param {any} params
|
|
143
|
+
* @returns {any}
|
|
144
|
+
*/
|
|
145
|
+
export function runRaceSim(params) {
|
|
146
|
+
const ret = wasm.runRaceSim(params);
|
|
147
|
+
if (ret[2]) {
|
|
148
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
149
|
+
}
|
|
150
|
+
return takeFromExternrefTable0(ret[0]);
|
|
151
|
+
}
|
|
152
|
+
function __wbg_get_imports() {
|
|
153
|
+
const import0 = {
|
|
154
|
+
__proto__: null,
|
|
155
|
+
__wbg_Error_ef53bc310eb298a0: function(arg0, arg1) {
|
|
156
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
157
|
+
return ret;
|
|
158
|
+
},
|
|
159
|
+
__wbg_Number_6b506e6536831eaa: function(arg0) {
|
|
160
|
+
const ret = Number(arg0);
|
|
161
|
+
return ret;
|
|
162
|
+
},
|
|
163
|
+
__wbg_String_8564e559799eccda: function(arg0, arg1) {
|
|
164
|
+
const ret = String(arg1);
|
|
165
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
166
|
+
const len1 = WASM_VECTOR_LEN;
|
|
167
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
168
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
169
|
+
},
|
|
170
|
+
__wbg___wbindgen_bigint_get_as_i64_38130e98eecd467d: function(arg0, arg1) {
|
|
171
|
+
const v = arg1;
|
|
172
|
+
const ret = typeof(v) === 'bigint' ? v : undefined;
|
|
173
|
+
getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
|
|
174
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
175
|
+
},
|
|
176
|
+
__wbg___wbindgen_boolean_get_1a45e2c38d4d41b9: function(arg0) {
|
|
177
|
+
const v = arg0;
|
|
178
|
+
const ret = typeof(v) === 'boolean' ? v : undefined;
|
|
179
|
+
return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
|
|
180
|
+
},
|
|
181
|
+
__wbg___wbindgen_debug_string_0accd80f45e5faa2: function(arg0, arg1) {
|
|
182
|
+
const ret = debugString(arg1);
|
|
183
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
184
|
+
const len1 = WASM_VECTOR_LEN;
|
|
185
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
186
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
187
|
+
},
|
|
188
|
+
__wbg___wbindgen_in_70a403a56e771704: function(arg0, arg1) {
|
|
189
|
+
const ret = arg0 in arg1;
|
|
190
|
+
return ret;
|
|
191
|
+
},
|
|
192
|
+
__wbg___wbindgen_is_bigint_6ffd6468a9bc44b9: function(arg0) {
|
|
193
|
+
const ret = typeof(arg0) === 'bigint';
|
|
194
|
+
return ret;
|
|
195
|
+
},
|
|
196
|
+
__wbg___wbindgen_is_function_754e9f305ff6029e: function(arg0) {
|
|
197
|
+
const ret = typeof(arg0) === 'function';
|
|
198
|
+
return ret;
|
|
199
|
+
},
|
|
200
|
+
__wbg___wbindgen_is_object_56732c2bc353f41d: function(arg0) {
|
|
201
|
+
const val = arg0;
|
|
202
|
+
const ret = typeof(val) === 'object' && val !== null;
|
|
203
|
+
return ret;
|
|
204
|
+
},
|
|
205
|
+
__wbg___wbindgen_is_string_c236cabd84a4d769: function(arg0) {
|
|
206
|
+
const ret = typeof(arg0) === 'string';
|
|
207
|
+
return ret;
|
|
208
|
+
},
|
|
209
|
+
__wbg___wbindgen_is_undefined_67b456be8673d3d7: function(arg0) {
|
|
210
|
+
const ret = arg0 === undefined;
|
|
211
|
+
return ret;
|
|
212
|
+
},
|
|
213
|
+
__wbg___wbindgen_jsval_eq_1068e624fa87f6ab: function(arg0, arg1) {
|
|
214
|
+
const ret = arg0 === arg1;
|
|
215
|
+
return ret;
|
|
216
|
+
},
|
|
217
|
+
__wbg___wbindgen_jsval_loose_eq_2c56564c75129511: function(arg0, arg1) {
|
|
218
|
+
const ret = arg0 == arg1;
|
|
219
|
+
return ret;
|
|
220
|
+
},
|
|
221
|
+
__wbg___wbindgen_number_get_9bb1761122181af2: function(arg0, arg1) {
|
|
222
|
+
const obj = arg1;
|
|
223
|
+
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
224
|
+
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
225
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
226
|
+
},
|
|
227
|
+
__wbg___wbindgen_string_get_72bdf95d3ae505b1: function(arg0, arg1) {
|
|
228
|
+
const obj = arg1;
|
|
229
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
230
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
231
|
+
var len1 = WASM_VECTOR_LEN;
|
|
232
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
233
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
234
|
+
},
|
|
235
|
+
__wbg___wbindgen_throw_1506f2235d1bdba0: function(arg0, arg1) {
|
|
236
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
237
|
+
},
|
|
238
|
+
__wbg_call_8a89609d89f6608a: function() { return handleError(function (arg0, arg1) {
|
|
239
|
+
const ret = arg0.call(arg1);
|
|
240
|
+
return ret;
|
|
241
|
+
}, arguments); },
|
|
242
|
+
__wbg_call_9c758de292015997: function() { return handleError(function (arg0, arg1, arg2) {
|
|
243
|
+
const ret = arg0.call(arg1, arg2);
|
|
244
|
+
return ret;
|
|
245
|
+
}, arguments); },
|
|
246
|
+
__wbg_done_60cf307fcc680536: function(arg0) {
|
|
247
|
+
const ret = arg0.done;
|
|
248
|
+
return ret;
|
|
249
|
+
},
|
|
250
|
+
__wbg_entries_04b37a02507f1713: function(arg0) {
|
|
251
|
+
const ret = Object.entries(arg0);
|
|
252
|
+
return ret;
|
|
253
|
+
},
|
|
254
|
+
__wbg_get_1f8f054ddbaa7db2: function() { return handleError(function (arg0, arg1) {
|
|
255
|
+
const ret = Reflect.get(arg0, arg1);
|
|
256
|
+
return ret;
|
|
257
|
+
}, arguments); },
|
|
258
|
+
__wbg_get_2b48c7d0d006a781: function(arg0, arg1) {
|
|
259
|
+
const ret = arg0[arg1 >>> 0];
|
|
260
|
+
return ret;
|
|
261
|
+
},
|
|
262
|
+
__wbg_get_unchecked_33f6e5c9e2f2d6b2: function(arg0, arg1) {
|
|
263
|
+
const ret = arg0[arg1 >>> 0];
|
|
264
|
+
return ret;
|
|
265
|
+
},
|
|
266
|
+
__wbg_get_with_ref_key_6412cf3094599694: function(arg0, arg1) {
|
|
267
|
+
const ret = arg0[arg1];
|
|
268
|
+
return ret;
|
|
269
|
+
},
|
|
270
|
+
__wbg_instanceof_ArrayBuffer_8f49811467741499: function(arg0) {
|
|
271
|
+
let result;
|
|
272
|
+
try {
|
|
273
|
+
result = arg0 instanceof ArrayBuffer;
|
|
274
|
+
} catch (_) {
|
|
275
|
+
result = false;
|
|
276
|
+
}
|
|
277
|
+
const ret = result;
|
|
278
|
+
return ret;
|
|
279
|
+
},
|
|
280
|
+
__wbg_instanceof_Uint8Array_86f30649f63ef9c2: function(arg0) {
|
|
281
|
+
let result;
|
|
282
|
+
try {
|
|
283
|
+
result = arg0 instanceof Uint8Array;
|
|
284
|
+
} catch (_) {
|
|
285
|
+
result = false;
|
|
286
|
+
}
|
|
287
|
+
const ret = result;
|
|
288
|
+
return ret;
|
|
289
|
+
},
|
|
290
|
+
__wbg_isArray_67c2c9c4313f4448: function(arg0) {
|
|
291
|
+
const ret = Array.isArray(arg0);
|
|
292
|
+
return ret;
|
|
293
|
+
},
|
|
294
|
+
__wbg_isSafeInteger_66acec27e09e99a7: function(arg0) {
|
|
295
|
+
const ret = Number.isSafeInteger(arg0);
|
|
296
|
+
return ret;
|
|
297
|
+
},
|
|
298
|
+
__wbg_iterator_8732428d309e270e: function() {
|
|
299
|
+
const ret = Symbol.iterator;
|
|
300
|
+
return ret;
|
|
301
|
+
},
|
|
302
|
+
__wbg_length_4a591ecaa01354d9: function(arg0) {
|
|
303
|
+
const ret = arg0.length;
|
|
304
|
+
return ret;
|
|
305
|
+
},
|
|
306
|
+
__wbg_length_66f1a4b2e9026940: function(arg0) {
|
|
307
|
+
const ret = arg0.length;
|
|
308
|
+
return ret;
|
|
309
|
+
},
|
|
310
|
+
__wbg_new_578aeef4b6b94378: function(arg0) {
|
|
311
|
+
const ret = new Uint8Array(arg0);
|
|
312
|
+
return ret;
|
|
313
|
+
},
|
|
314
|
+
__wbg_new_622fc80556be2e26: function() {
|
|
315
|
+
const ret = new Map();
|
|
316
|
+
return ret;
|
|
317
|
+
},
|
|
318
|
+
__wbg_new_ce1ab61c1c2b300d: function() {
|
|
319
|
+
const ret = new Object();
|
|
320
|
+
return ret;
|
|
321
|
+
},
|
|
322
|
+
__wbg_new_d90091b82fdf5b91: function() {
|
|
323
|
+
const ret = new Array();
|
|
324
|
+
return ret;
|
|
325
|
+
},
|
|
326
|
+
__wbg_next_9e03acdf51c4960d: function(arg0) {
|
|
327
|
+
const ret = arg0.next;
|
|
328
|
+
return ret;
|
|
329
|
+
},
|
|
330
|
+
__wbg_next_eb8ca7351fa27906: function() { return handleError(function (arg0) {
|
|
331
|
+
const ret = arg0.next();
|
|
332
|
+
return ret;
|
|
333
|
+
}, arguments); },
|
|
334
|
+
__wbg_prototypesetcall_3249fc62a0fafa30: function(arg0, arg1, arg2) {
|
|
335
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
336
|
+
},
|
|
337
|
+
__wbg_set_52b1e1eb5bed906a: function(arg0, arg1, arg2) {
|
|
338
|
+
const ret = arg0.set(arg1, arg2);
|
|
339
|
+
return ret;
|
|
340
|
+
},
|
|
341
|
+
__wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
|
|
342
|
+
arg0[arg1] = arg2;
|
|
343
|
+
},
|
|
344
|
+
__wbg_set_dca99999bba88a9a: function(arg0, arg1, arg2) {
|
|
345
|
+
arg0[arg1 >>> 0] = arg2;
|
|
346
|
+
},
|
|
347
|
+
__wbg_value_f3625092ee4b37f4: function(arg0) {
|
|
348
|
+
const ret = arg0.value;
|
|
349
|
+
return ret;
|
|
350
|
+
},
|
|
351
|
+
__wbindgen_cast_0000000000000001: function(arg0) {
|
|
352
|
+
// Cast intrinsic for `F64 -> Externref`.
|
|
353
|
+
const ret = arg0;
|
|
354
|
+
return ret;
|
|
355
|
+
},
|
|
356
|
+
__wbindgen_cast_0000000000000002: function(arg0) {
|
|
357
|
+
// Cast intrinsic for `I64 -> Externref`.
|
|
358
|
+
const ret = arg0;
|
|
359
|
+
return ret;
|
|
360
|
+
},
|
|
361
|
+
__wbindgen_cast_0000000000000003: function(arg0, arg1) {
|
|
362
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
363
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
364
|
+
return ret;
|
|
365
|
+
},
|
|
366
|
+
__wbindgen_cast_0000000000000004: function(arg0) {
|
|
367
|
+
// Cast intrinsic for `U64 -> Externref`.
|
|
368
|
+
const ret = BigInt.asUintN(64, arg0);
|
|
369
|
+
return ret;
|
|
370
|
+
},
|
|
371
|
+
__wbindgen_init_externref_table: function() {
|
|
372
|
+
const table = wasm.__wbindgen_externrefs;
|
|
373
|
+
const offset = table.grow(4);
|
|
374
|
+
table.set(0, undefined);
|
|
375
|
+
table.set(offset + 0, undefined);
|
|
376
|
+
table.set(offset + 1, null);
|
|
377
|
+
table.set(offset + 2, true);
|
|
378
|
+
table.set(offset + 3, false);
|
|
379
|
+
},
|
|
380
|
+
};
|
|
381
|
+
return {
|
|
382
|
+
__proto__: null,
|
|
383
|
+
"./uma_sim_wasm_bg.js": import0,
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
const WasmRaceSimulatorFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
388
|
+
? { register: () => {}, unregister: () => {} }
|
|
389
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmracesimulator_free(ptr, 1));
|
|
390
|
+
|
|
391
|
+
function addToExternrefTable0(obj) {
|
|
392
|
+
const idx = wasm.__externref_table_alloc();
|
|
393
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
394
|
+
return idx;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
function debugString(val) {
|
|
398
|
+
// primitive types
|
|
399
|
+
const type = typeof val;
|
|
400
|
+
if (type == 'number' || type == 'boolean' || val == null) {
|
|
401
|
+
return `${val}`;
|
|
402
|
+
}
|
|
403
|
+
if (type == 'string') {
|
|
404
|
+
return `"${val}"`;
|
|
405
|
+
}
|
|
406
|
+
if (type == 'symbol') {
|
|
407
|
+
const description = val.description;
|
|
408
|
+
if (description == null) {
|
|
409
|
+
return 'Symbol';
|
|
410
|
+
} else {
|
|
411
|
+
return `Symbol(${description})`;
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
if (type == 'function') {
|
|
415
|
+
const name = val.name;
|
|
416
|
+
if (typeof name == 'string' && name.length > 0) {
|
|
417
|
+
return `Function(${name})`;
|
|
418
|
+
} else {
|
|
419
|
+
return 'Function';
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
// objects
|
|
423
|
+
if (Array.isArray(val)) {
|
|
424
|
+
const length = val.length;
|
|
425
|
+
let debug = '[';
|
|
426
|
+
if (length > 0) {
|
|
427
|
+
debug += debugString(val[0]);
|
|
428
|
+
}
|
|
429
|
+
for(let i = 1; i < length; i++) {
|
|
430
|
+
debug += ', ' + debugString(val[i]);
|
|
431
|
+
}
|
|
432
|
+
debug += ']';
|
|
433
|
+
return debug;
|
|
434
|
+
}
|
|
435
|
+
// Test for built-in
|
|
436
|
+
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
|
|
437
|
+
let className;
|
|
438
|
+
if (builtInMatches && builtInMatches.length > 1) {
|
|
439
|
+
className = builtInMatches[1];
|
|
440
|
+
} else {
|
|
441
|
+
// Failed to match the standard '[object ClassName]'
|
|
442
|
+
return toString.call(val);
|
|
443
|
+
}
|
|
444
|
+
if (className == 'Object') {
|
|
445
|
+
// we're a user defined class or Object
|
|
446
|
+
// JSON.stringify avoids problems with cycles, and is generally much
|
|
447
|
+
// easier than looping through ownProperties of `val`.
|
|
448
|
+
try {
|
|
449
|
+
return 'Object(' + JSON.stringify(val) + ')';
|
|
450
|
+
} catch (_) {
|
|
451
|
+
return 'Object';
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
// errors
|
|
455
|
+
if (val instanceof Error) {
|
|
456
|
+
return `${val.name}: ${val.message}\n${val.stack}`;
|
|
457
|
+
}
|
|
458
|
+
// TODO we could test for more things here, like `Set`s and `Map`s.
|
|
459
|
+
return className;
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
function getArrayJsValueFromWasm0(ptr, len) {
|
|
463
|
+
ptr = ptr >>> 0;
|
|
464
|
+
const mem = getDataViewMemory0();
|
|
465
|
+
const result = [];
|
|
466
|
+
for (let i = ptr; i < ptr + 4 * len; i += 4) {
|
|
467
|
+
result.push(wasm.__wbindgen_externrefs.get(mem.getUint32(i, true)));
|
|
468
|
+
}
|
|
469
|
+
wasm.__externref_drop_slice(ptr, len);
|
|
470
|
+
return result;
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
474
|
+
ptr = ptr >>> 0;
|
|
475
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
let cachedDataViewMemory0 = null;
|
|
479
|
+
function getDataViewMemory0() {
|
|
480
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
481
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
482
|
+
}
|
|
483
|
+
return cachedDataViewMemory0;
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
function getStringFromWasm0(ptr, len) {
|
|
487
|
+
return decodeText(ptr >>> 0, len);
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
let cachedUint8ArrayMemory0 = null;
|
|
491
|
+
function getUint8ArrayMemory0() {
|
|
492
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
493
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
494
|
+
}
|
|
495
|
+
return cachedUint8ArrayMemory0;
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
function handleError(f, args) {
|
|
499
|
+
try {
|
|
500
|
+
return f.apply(this, args);
|
|
501
|
+
} catch (e) {
|
|
502
|
+
const idx = addToExternrefTable0(e);
|
|
503
|
+
wasm.__wbindgen_exn_store(idx);
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
function isLikeNone(x) {
|
|
508
|
+
return x === undefined || x === null;
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
512
|
+
if (realloc === undefined) {
|
|
513
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
514
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
515
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
516
|
+
WASM_VECTOR_LEN = buf.length;
|
|
517
|
+
return ptr;
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
let len = arg.length;
|
|
521
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
522
|
+
|
|
523
|
+
const mem = getUint8ArrayMemory0();
|
|
524
|
+
|
|
525
|
+
let offset = 0;
|
|
526
|
+
|
|
527
|
+
for (; offset < len; offset++) {
|
|
528
|
+
const code = arg.charCodeAt(offset);
|
|
529
|
+
if (code > 0x7F) break;
|
|
530
|
+
mem[ptr + offset] = code;
|
|
531
|
+
}
|
|
532
|
+
if (offset !== len) {
|
|
533
|
+
if (offset !== 0) {
|
|
534
|
+
arg = arg.slice(offset);
|
|
535
|
+
}
|
|
536
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
537
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
538
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
539
|
+
|
|
540
|
+
offset += ret.written;
|
|
541
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
WASM_VECTOR_LEN = offset;
|
|
545
|
+
return ptr;
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
function takeFromExternrefTable0(idx) {
|
|
549
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
550
|
+
wasm.__externref_table_dealloc(idx);
|
|
551
|
+
return value;
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
555
|
+
cachedTextDecoder.decode();
|
|
556
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
557
|
+
let numBytesDecoded = 0;
|
|
558
|
+
function decodeText(ptr, len) {
|
|
559
|
+
numBytesDecoded += len;
|
|
560
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
561
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
562
|
+
cachedTextDecoder.decode();
|
|
563
|
+
numBytesDecoded = len;
|
|
564
|
+
}
|
|
565
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
const cachedTextEncoder = new TextEncoder();
|
|
569
|
+
|
|
570
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
571
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
572
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
573
|
+
view.set(buf);
|
|
574
|
+
return {
|
|
575
|
+
read: arg.length,
|
|
576
|
+
written: buf.length
|
|
577
|
+
};
|
|
578
|
+
};
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
let WASM_VECTOR_LEN = 0;
|
|
582
|
+
|
|
583
|
+
let wasmModule, wasmInstance, wasm;
|
|
584
|
+
function __wbg_finalize_init(instance, module) {
|
|
585
|
+
wasmInstance = instance;
|
|
586
|
+
wasm = instance.exports;
|
|
587
|
+
wasmModule = module;
|
|
588
|
+
cachedDataViewMemory0 = null;
|
|
589
|
+
cachedUint8ArrayMemory0 = null;
|
|
590
|
+
wasm.__wbindgen_start();
|
|
591
|
+
return wasm;
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
async function __wbg_load(module, imports) {
|
|
595
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
596
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
597
|
+
try {
|
|
598
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
599
|
+
} catch (e) {
|
|
600
|
+
const validResponse = module.ok && expectedResponseType(module.type);
|
|
601
|
+
|
|
602
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
603
|
+
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
|
604
|
+
|
|
605
|
+
} else { throw e; }
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
const bytes = await module.arrayBuffer();
|
|
610
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
611
|
+
} else {
|
|
612
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
613
|
+
|
|
614
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
615
|
+
return { instance, module };
|
|
616
|
+
} else {
|
|
617
|
+
return instance;
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
function expectedResponseType(type) {
|
|
622
|
+
switch (type) {
|
|
623
|
+
case 'basic': case 'cors': case 'default': return true;
|
|
624
|
+
}
|
|
625
|
+
return false;
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
function initSync(module) {
|
|
630
|
+
if (wasm !== undefined) return wasm;
|
|
631
|
+
|
|
632
|
+
|
|
633
|
+
if (module !== undefined) {
|
|
634
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
635
|
+
({module} = module)
|
|
636
|
+
} else {
|
|
637
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
const imports = __wbg_get_imports();
|
|
642
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
643
|
+
module = new WebAssembly.Module(module);
|
|
644
|
+
}
|
|
645
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
646
|
+
return __wbg_finalize_init(instance, module);
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
async function __wbg_init(module_or_path) {
|
|
650
|
+
if (wasm !== undefined) return wasm;
|
|
651
|
+
|
|
652
|
+
|
|
653
|
+
if (module_or_path !== undefined) {
|
|
654
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
655
|
+
({module_or_path} = module_or_path)
|
|
656
|
+
} else {
|
|
657
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
if (module_or_path === undefined) {
|
|
662
|
+
module_or_path = new URL('uma_sim_wasm_bg.wasm', import.meta.url);
|
|
663
|
+
}
|
|
664
|
+
const imports = __wbg_get_imports();
|
|
665
|
+
|
|
666
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
667
|
+
module_or_path = fetch(module_or_path);
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
671
|
+
|
|
672
|
+
return __wbg_finalize_init(instance, module);
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
export { initSync, __wbg_init as default };
|
|
Binary file
|