hakuban 0.8.3 → 0.8.5

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/hakuban.js CHANGED
@@ -1,105 +1,95 @@
1
- let wasm;
2
-
3
- function addToExternrefTable0(obj) {
4
- const idx = wasm.__externref_table_alloc();
5
- wasm.__wbindgen_export_2.set(idx, obj);
6
- return idx;
7
- }
8
-
9
- function handleError(f, args) {
10
- try {
11
- return f.apply(this, args);
12
- } catch (e) {
13
- const idx = addToExternrefTable0(e);
14
- wasm.__wbindgen_exn_store(idx);
15
- }
16
- }
17
-
18
- const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
19
-
20
- if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); }
21
- let cachedUint8ArrayMemory0 = null;
1
+ /* @ts-self-types="./hakuban.d.ts" */
22
2
 
23
- function getUint8ArrayMemory0() {
24
- if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
25
- cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
3
+ class WasmResult {
4
+ static __wrap(ptr) {
5
+ ptr = ptr >>> 0;
6
+ const obj = Object.create(WasmResult.prototype);
7
+ obj.__wbg_ptr = ptr;
8
+ WasmResultFinalization.register(obj, obj.__wbg_ptr, obj);
9
+ return obj;
26
10
  }
27
- return cachedUint8ArrayMemory0;
28
- }
29
-
30
- function getStringFromWasm0(ptr, len) {
31
- ptr = ptr >>> 0;
32
- return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
33
- }
34
-
35
- let WASM_VECTOR_LEN = 0;
36
-
37
- const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
38
-
39
- const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
40
- ? function (arg, view) {
41
- return cachedTextEncoder.encodeInto(arg, view);
42
- }
43
- : function (arg, view) {
44
- const buf = cachedTextEncoder.encode(arg);
45
- view.set(buf);
46
- return {
47
- read: arg.length,
48
- written: buf.length
49
- };
50
- });
51
-
52
- function passStringToWasm0(arg, malloc, realloc) {
53
-
54
- if (realloc === undefined) {
55
- const buf = cachedTextEncoder.encode(arg);
56
- const ptr = malloc(buf.length, 1) >>> 0;
57
- getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
58
- WASM_VECTOR_LEN = buf.length;
11
+ __destroy_into_raw() {
12
+ const ptr = this.__wbg_ptr;
13
+ this.__wbg_ptr = 0;
14
+ WasmResultFinalization.unregister(this);
59
15
  return ptr;
60
16
  }
61
-
62
- let len = arg.length;
63
- let ptr = malloc(len, 1) >>> 0;
64
-
65
- const mem = getUint8ArrayMemory0();
66
-
67
- let offset = 0;
68
-
69
- for (; offset < len; offset++) {
70
- const code = arg.charCodeAt(offset);
71
- if (code > 0x7F) break;
72
- mem[ptr + offset] = code;
17
+ free() {
18
+ const ptr = this.__destroy_into_raw();
19
+ wasm.__wbg_wasmresult_free(ptr, 0);
73
20
  }
74
-
75
- if (offset !== len) {
76
- if (offset !== 0) {
77
- arg = arg.slice(offset);
21
+ /**
22
+ * @returns {string | undefined}
23
+ */
24
+ get error_message() {
25
+ const ret = wasm.__wbg_get_wasmresult_error_message(this.__wbg_ptr);
26
+ let v1;
27
+ if (ret[0] !== 0) {
28
+ v1 = getStringFromWasm0(ret[0], ret[1]).slice();
29
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
78
30
  }
79
- ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
80
- const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
81
- const ret = encodeString(arg, view);
82
-
83
- offset += ret.written;
84
- ptr = realloc(ptr, len, offset, 1) >>> 0;
31
+ return v1;
32
+ }
33
+ /**
34
+ * @returns {number | undefined}
35
+ */
36
+ get pointer() {
37
+ const ret = wasm.__wbg_get_wasmresult_pointer(this.__wbg_ptr);
38
+ return ret === 0x100000001 ? undefined : ret;
39
+ }
40
+ /**
41
+ * @returns {WasmResultStatus}
42
+ */
43
+ get status() {
44
+ const ret = wasm.__wbg_get_wasmresult_status(this.__wbg_ptr);
45
+ return ret;
46
+ }
47
+ /**
48
+ * @param {string | null} [arg0]
49
+ */
50
+ set error_message(arg0) {
51
+ var ptr0 = isLikeNone(arg0) ? 0 : passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
52
+ var len0 = WASM_VECTOR_LEN;
53
+ wasm.__wbg_set_wasmresult_error_message(this.__wbg_ptr, ptr0, len0);
54
+ }
55
+ /**
56
+ * @param {number | null} [arg0]
57
+ */
58
+ set pointer(arg0) {
59
+ wasm.__wbg_set_wasmresult_pointer(this.__wbg_ptr, isLikeNone(arg0) ? 0x100000001 : (arg0) >>> 0);
60
+ }
61
+ /**
62
+ * @param {WasmResultStatus} arg0
63
+ */
64
+ set status(arg0) {
65
+ wasm.__wbg_set_wasmresult_status(this.__wbg_ptr, arg0);
85
66
  }
86
-
87
- WASM_VECTOR_LEN = offset;
88
- return ptr;
89
67
  }
68
+ if (Symbol.dispose) WasmResult.prototype[Symbol.dispose] = WasmResult.prototype.free;
90
69
 
91
- let cachedDataViewMemory0 = null;
70
+ /**
71
+ * @enum {0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9}
72
+ */
73
+ Object.freeze({
74
+ Ok: 0, "0": "Ok",
75
+ Pointer: 1, "1": "Pointer",
76
+ Pending: 2, "2": "Pending",
77
+ EndOfStream: 3, "3": "EndOfStream",
78
+ InvalidString: 4, "4": "InvalidString",
79
+ InvalidJSON: 5, "5": "InvalidJSON",
80
+ InvalidURL: 6, "6": "InvalidURL",
81
+ InvalidLogLevel: 7, "7": "InvalidLogLevel",
82
+ LoggerInitializationError: 8, "8": "LoggerInitializationError",
83
+ ConnectionTerminated: 9, "9": "ConnectionTerminated",
84
+ });
92
85
 
93
- function getDataViewMemory0() {
94
- if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
95
- cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
96
- }
97
- return cachedDataViewMemory0;
86
+ /**
87
+ * @param {number} exchange
88
+ */
89
+ function hakuban_exchange_drop(exchange) {
90
+ wasm.hakuban_exchange_drop(exchange);
98
91
  }
99
92
 
100
- function isLikeNone(x) {
101
- return x === undefined || x === null;
102
- }
103
93
  /**
104
94
  * @returns {WasmResult}
105
95
  */
@@ -110,35 +100,111 @@ function hakuban_exchange_new() {
110
100
 
111
101
  /**
112
102
  * @param {number} exchange
103
+ * @returns {BigUint64Array}
113
104
  */
114
- function hakuban_exchange_drop(exchange) {
115
- wasm.hakuban_exchange_drop(exchange);
105
+ function hakuban_exchange_notified(exchange) {
106
+ const ret = wasm.hakuban_exchange_notified(exchange);
107
+ var v1 = getArrayU64FromWasm0(ret[0], ret[1]).slice();
108
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
109
+ return v1;
116
110
  }
117
111
 
118
- let cachedBigUint64ArrayMemory0 = null;
112
+ /**
113
+ * @param {number} future
114
+ */
115
+ function hakuban_future_drop(future) {
116
+ wasm.hakuban_future_drop(future);
117
+ }
119
118
 
120
- function getBigUint64ArrayMemory0() {
121
- if (cachedBigUint64ArrayMemory0 === null || cachedBigUint64ArrayMemory0.byteLength === 0) {
122
- cachedBigUint64ArrayMemory0 = new BigUint64Array(wasm.memory.buffer);
119
+ /**
120
+ * @param {number} exchange_pointer
121
+ * @param {number} future_pointer
122
+ * @param {bigint} waker_id
123
+ * @returns {WasmResult}
124
+ */
125
+ function hakuban_future_poll(exchange_pointer, future_pointer, waker_id) {
126
+ const ret = wasm.hakuban_future_poll(exchange_pointer, future_pointer, waker_id);
127
+ return WasmResult.__wrap(ret);
128
+ }
129
+
130
+ /**
131
+ * @param {string} default_log_level
132
+ * @returns {WasmResult}
133
+ */
134
+ function hakuban_logger_initialize(default_log_level) {
135
+ const ptr0 = passStringToWasm0(default_log_level, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
136
+ const len0 = WASM_VECTOR_LEN;
137
+ const ret = wasm.hakuban_logger_initialize(ptr0, len0);
138
+ return WasmResult.__wrap(ret);
139
+ }
140
+
141
+ /**
142
+ * @param {number} message_pointer
143
+ * @returns {Uint8Array}
144
+ */
145
+ function hakuban_message_serialize(message_pointer) {
146
+ const ret = wasm.hakuban_message_serialize(message_pointer);
147
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
148
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
149
+ return v1;
150
+ }
151
+
152
+ /**
153
+ * @param {number} descriptor_pointer
154
+ */
155
+ function hakuban_object_descriptor_drop(descriptor_pointer) {
156
+ wasm.hakuban_object_descriptor_drop(descriptor_pointer);
157
+ }
158
+
159
+ /**
160
+ * @param {number} descriptor_pointer
161
+ * @returns {string}
162
+ */
163
+ function hakuban_object_descriptor_json(descriptor_pointer) {
164
+ let deferred1_0;
165
+ let deferred1_1;
166
+ try {
167
+ const ret = wasm.hakuban_object_descriptor_json(descriptor_pointer);
168
+ deferred1_0 = ret[0];
169
+ deferred1_1 = ret[1];
170
+ return getStringFromWasm0(ret[0], ret[1]);
171
+ } finally {
172
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
123
173
  }
124
- return cachedBigUint64ArrayMemory0;
125
174
  }
126
175
 
127
- function getArrayU64FromWasm0(ptr, len) {
128
- ptr = ptr >>> 0;
129
- return getBigUint64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
176
+ /**
177
+ * @param {string} json_string
178
+ * @param {Uint32Array} tag_pointers
179
+ * @returns {WasmResult}
180
+ */
181
+ function hakuban_object_descriptor_new(json_string, tag_pointers) {
182
+ const ptr0 = passStringToWasm0(json_string, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
183
+ const len0 = WASM_VECTOR_LEN;
184
+ const ptr1 = passArray32ToWasm0(tag_pointers, wasm.__wbindgen_malloc);
185
+ const len1 = WASM_VECTOR_LEN;
186
+ const ret = wasm.hakuban_object_descriptor_new(ptr0, len0, ptr1, len1);
187
+ return WasmResult.__wrap(ret);
130
188
  }
189
+
131
190
  /**
132
- * @param {number} exchange
133
- * @returns {BigUint64Array}
191
+ * @param {number} descriptor_pointer
192
+ * @returns {Uint32Array}
134
193
  */
135
- function hakuban_exchange_notified(exchange) {
136
- const ret = wasm.hakuban_exchange_notified(exchange);
137
- var v1 = getArrayU64FromWasm0(ret[0], ret[1]).slice();
138
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
194
+ function hakuban_object_descriptor_tags(descriptor_pointer) {
195
+ const ret = wasm.hakuban_object_descriptor_tags(descriptor_pointer);
196
+ var v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
197
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
139
198
  return v1;
140
199
  }
141
200
 
201
+ /**
202
+ * @param {number} object_ptr
203
+ */
204
+ function hakuban_object_expose_contract_drop(object_ptr) {
205
+ wasm.hakuban_object_expose_contract_drop(object_ptr);
206
+ }
207
+
142
208
  /**
143
209
  * @param {number} exchange
144
210
  * @param {number} descriptor
@@ -150,13 +216,6 @@ function hakuban_object_expose_contract_new(exchange, descriptor, capacity) {
150
216
  return ret >>> 0;
151
217
  }
152
218
 
153
- /**
154
- * @param {number} object_ptr
155
- */
156
- function hakuban_object_expose_contract_drop(object_ptr) {
157
- wasm.hakuban_object_expose_contract_drop(object_ptr);
158
- }
159
-
160
219
  /**
161
220
  * @param {number} object_expose_pointer
162
221
  * @returns {number}
@@ -166,6 +225,13 @@ function hakuban_object_expose_contract_next(object_expose_pointer) {
166
225
  return ret >>> 0;
167
226
  }
168
227
 
228
+ /**
229
+ * @param {number} object_ptr
230
+ */
231
+ function hakuban_object_observe_contract_drop(object_ptr) {
232
+ wasm.hakuban_object_observe_contract_drop(object_ptr);
233
+ }
234
+
169
235
  /**
170
236
  * @param {number} exchange
171
237
  * @param {number} descriptor
@@ -176,13 +242,6 @@ function hakuban_object_observe_contract_new(exchange, descriptor) {
176
242
  return ret >>> 0;
177
243
  }
178
244
 
179
- /**
180
- * @param {number} object_ptr
181
- */
182
- function hakuban_object_observe_contract_drop(object_ptr) {
183
- wasm.hakuban_object_observe_contract_drop(object_ptr);
184
- }
185
-
186
245
  /**
187
246
  * @param {number} object_observe_pointer
188
247
  * @returns {number}
@@ -192,6 +251,53 @@ function hakuban_object_observe_contract_next(object_observe_pointer) {
192
251
  return ret >>> 0;
193
252
  }
194
253
 
254
+ /**
255
+ * @param {number} object_state_pointer
256
+ * @returns {Uint8Array}
257
+ */
258
+ function hakuban_object_state_data(object_state_pointer) {
259
+ const ret = wasm.hakuban_object_state_data(object_state_pointer);
260
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
261
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
262
+ return v1;
263
+ }
264
+
265
+ /**
266
+ * @param {number} object_state_pointer
267
+ */
268
+ function hakuban_object_state_drop(object_state_pointer) {
269
+ wasm.hakuban_object_state_drop(object_state_pointer);
270
+ }
271
+
272
+ /**
273
+ * @param {number} object_state_pointer
274
+ * @returns {any[]}
275
+ */
276
+ function hakuban_object_state_format(object_state_pointer) {
277
+ const ret = wasm.hakuban_object_state_format(object_state_pointer);
278
+ var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
279
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
280
+ return v1;
281
+ }
282
+
283
+ /**
284
+ * @param {BigInt64Array} version
285
+ * @param {any[]} format_jsvalues
286
+ * @param {Uint8Array} data
287
+ * @param {bigint} synchronized_us_ago
288
+ * @returns {WasmResult}
289
+ */
290
+ function hakuban_object_state_new(version, format_jsvalues, data, synchronized_us_ago) {
291
+ const ptr0 = passArray64ToWasm0(version, wasm.__wbindgen_malloc);
292
+ const len0 = WASM_VECTOR_LEN;
293
+ const ptr1 = passArrayJsValueToWasm0(format_jsvalues, wasm.__wbindgen_malloc);
294
+ const len1 = WASM_VECTOR_LEN;
295
+ const ptr2 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
296
+ const len2 = WASM_VECTOR_LEN;
297
+ const ret = wasm.hakuban_object_state_new(ptr0, len0, ptr1, len1, ptr2, len2, synchronized_us_ago);
298
+ return WasmResult.__wrap(ret);
299
+ }
300
+
195
301
  /**
196
302
  * @param {number} object_state_sink_pointer
197
303
  * @returns {number}
@@ -217,6 +323,13 @@ function hakuban_object_state_sink_next(object_state_sink_pointer) {
217
323
  return ret >>> 0;
218
324
  }
219
325
 
326
+ /**
327
+ * @param {number} object_state_sink_params_pointer
328
+ */
329
+ function hakuban_object_state_sink_params_drop(object_state_sink_params_pointer) {
330
+ wasm.hakuban_object_state_sink_params_drop(object_state_sink_params_pointer);
331
+ }
332
+
220
333
  /**
221
334
  * @param {number} object_state_sink_pointer
222
335
  * @param {number} object_state_pointer
@@ -228,10 +341,12 @@ function hakuban_object_state_sink_push(object_state_sink_pointer, object_state_
228
341
  }
229
342
 
230
343
  /**
231
- * @param {number} object_state_sink_params_pointer
344
+ * @param {number} object_state_stream_pointer
345
+ * @returns {number}
232
346
  */
233
- function hakuban_object_state_sink_params_drop(object_state_sink_params_pointer) {
234
- wasm.hakuban_object_state_sink_params_drop(object_state_sink_params_pointer);
347
+ function hakuban_object_state_stream_descriptor(object_state_stream_pointer) {
348
+ const ret = wasm.hakuban_object_state_stream_descriptor(object_state_stream_pointer);
349
+ return ret >>> 0;
235
350
  }
236
351
 
237
352
  /**
@@ -251,21 +366,67 @@ function hakuban_object_state_stream_next(object_state_stream_pointer) {
251
366
  }
252
367
 
253
368
  /**
254
- * @param {number} object_state_stream_pointer
255
- * @returns {number}
369
+ * @param {number} object_state_pointer
370
+ * @returns {bigint}
256
371
  */
257
- function hakuban_object_state_stream_descriptor(object_state_stream_pointer) {
258
- const ret = wasm.hakuban_object_state_stream_descriptor(object_state_stream_pointer);
259
- return ret >>> 0;
372
+ function hakuban_object_state_synchronized_ago(object_state_pointer) {
373
+ const ret = wasm.hakuban_object_state_synchronized_ago(object_state_pointer);
374
+ return BigInt.asUintN(64, ret);
375
+ }
376
+
377
+ /**
378
+ * @param {number} object_state_pointer
379
+ * @returns {BigInt64Array}
380
+ */
381
+ function hakuban_object_state_version(object_state_pointer) {
382
+ const ret = wasm.hakuban_object_state_version(object_state_pointer);
383
+ var v1 = getArrayI64FromWasm0(ret[0], ret[1]).slice();
384
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
385
+ return v1;
386
+ }
387
+
388
+ /**
389
+ * @param {number} descriptor_pointer
390
+ */
391
+ function hakuban_tag_descriptor_drop(descriptor_pointer) {
392
+ wasm.hakuban_tag_descriptor_drop(descriptor_pointer);
393
+ }
394
+
395
+ /**
396
+ * @param {string} json_string
397
+ * @returns {WasmResult}
398
+ */
399
+ function hakuban_tag_descriptor_new(json_string) {
400
+ const ptr0 = passStringToWasm0(json_string, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
401
+ const len0 = WASM_VECTOR_LEN;
402
+ const ret = wasm.hakuban_tag_descriptor_new(ptr0, len0);
403
+ return WasmResult.__wrap(ret);
404
+ }
405
+
406
+ /**
407
+ * @param {number} tag_expose_contract_pointer
408
+ */
409
+ function hakuban_tag_expose_contract_drop(tag_expose_contract_pointer) {
410
+ wasm.hakuban_tag_expose_contract_drop(tag_expose_contract_pointer);
260
411
  }
261
412
 
262
413
  /**
263
414
  * @param {number} exchange
264
415
  * @param {number} descriptor
416
+ * @param {number} capacity
265
417
  * @returns {number}
266
418
  */
267
- function hakuban_tag_observe_contract_new(exchange, descriptor) {
268
- const ret = wasm.hakuban_tag_observe_contract_new(exchange, descriptor);
419
+ function hakuban_tag_expose_contract_new(exchange, descriptor, capacity) {
420
+ const ret = wasm.hakuban_tag_expose_contract_new(exchange, descriptor, capacity);
421
+ return ret >>> 0;
422
+ }
423
+
424
+ /**
425
+ * @param {number} tag_expose_pointer
426
+ * @returns {number}
427
+ */
428
+ function hakuban_tag_expose_contract_next(tag_expose_pointer) {
429
+ const ret = wasm.hakuban_tag_expose_contract_next(tag_expose_pointer);
269
430
  return ret >>> 0;
270
431
  }
271
432
 
@@ -276,6 +437,16 @@ function hakuban_tag_observe_contract_drop(tag_pointer) {
276
437
  wasm.hakuban_tag_observe_contract_drop(tag_pointer);
277
438
  }
278
439
 
440
+ /**
441
+ * @param {number} exchange
442
+ * @param {number} descriptor
443
+ * @returns {number}
444
+ */
445
+ function hakuban_tag_observe_contract_new(exchange, descriptor) {
446
+ const ret = wasm.hakuban_tag_observe_contract_new(exchange, descriptor);
447
+ return ret >>> 0;
448
+ }
449
+
279
450
  /**
280
451
  * @param {number} tag_observe_pointer
281
452
  * @returns {number}
@@ -285,6 +456,13 @@ function hakuban_tag_observe_contract_next(tag_observe_pointer) {
285
456
  return ret >>> 0;
286
457
  }
287
458
 
459
+ /**
460
+ * @param {number} wasm_upstream_connection
461
+ */
462
+ function hakuban_upstream_connection_drop(wasm_upstream_connection) {
463
+ wasm.hakuban_upstream_connection_drop(wasm_upstream_connection);
464
+ }
465
+
288
466
  /**
289
467
  * @param {number} exchange_pointer
290
468
  * @param {string} local_name
@@ -300,13 +478,6 @@ function hakuban_upstream_connection_new(exchange_pointer, local_name, local_add
300
478
  return ret >>> 0;
301
479
  }
302
480
 
303
- /**
304
- * @param {number} wasm_upstream_connection
305
- */
306
- function hakuban_upstream_connection_drop(wasm_upstream_connection) {
307
- wasm.hakuban_upstream_connection_drop(wasm_upstream_connection);
308
- }
309
-
310
481
  /**
311
482
  * @param {number} wasm_upstream_connection
312
483
  * @returns {number}
@@ -316,27 +487,6 @@ function hakuban_upstream_connection_next_message_to_network(wasm_upstream_conne
316
487
  return ret >>> 0;
317
488
  }
318
489
 
319
- function getArrayU8FromWasm0(ptr, len) {
320
- ptr = ptr >>> 0;
321
- return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
322
- }
323
- /**
324
- * @param {number} message_pointer
325
- * @returns {Uint8Array}
326
- */
327
- function hakuban_message_serialize(message_pointer) {
328
- const ret = wasm.hakuban_message_serialize(message_pointer);
329
- var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
330
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
331
- return v1;
332
- }
333
-
334
- function passArray8ToWasm0(arg, malloc) {
335
- const ptr = malloc(arg.length * 1, 1) >>> 0;
336
- getUint8ArrayMemory0().set(arg, ptr / 1);
337
- WASM_VECTOR_LEN = arg.length;
338
- return ptr;
339
- }
340
490
  /**
341
491
  * @param {number} wasm_upstream_connection
342
492
  * @param {Uint8Array} message_data
@@ -348,342 +498,303 @@ function hakuban_upstream_connection_send_message_from_network(wasm_upstream_con
348
498
  const ret = wasm.hakuban_upstream_connection_send_message_from_network(wasm_upstream_connection, ptr0, len0);
349
499
  return ret >>> 0;
350
500
  }
351
-
352
- /**
353
- * @param {number} exchange_pointer
354
- * @param {number} future_pointer
355
- * @param {bigint} waker_id
356
- * @returns {WasmResult}
357
- */
358
- function hakuban_future_poll(exchange_pointer, future_pointer, waker_id) {
359
- const ret = wasm.hakuban_future_poll(exchange_pointer, future_pointer, waker_id);
360
- return WasmResult.__wrap(ret);
361
- }
362
-
363
- /**
364
- * @param {number} future
365
- */
366
- function hakuban_future_drop(future) {
367
- wasm.hakuban_future_drop(future);
368
- }
369
-
370
- function passArray64ToWasm0(arg, malloc) {
371
- const ptr = malloc(arg.length * 8, 8) >>> 0;
372
- getBigUint64ArrayMemory0().set(arg, ptr / 8);
373
- WASM_VECTOR_LEN = arg.length;
374
- return ptr;
375
- }
376
-
377
- function passArrayJsValueToWasm0(array, malloc) {
378
- const ptr = malloc(array.length * 4, 4) >>> 0;
379
- for (let i = 0; i < array.length; i++) {
380
- const add = addToExternrefTable0(array[i]);
381
- getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
382
- }
383
- WASM_VECTOR_LEN = array.length;
384
- return ptr;
385
- }
386
- /**
387
- * @param {BigInt64Array} version
388
- * @param {any[]} format_jsvalues
389
- * @param {Uint8Array} data
390
- * @param {bigint} synchronized_us_ago
391
- * @returns {WasmResult}
392
- */
393
- function hakuban_object_state_new(version, format_jsvalues, data, synchronized_us_ago) {
394
- const ptr0 = passArray64ToWasm0(version, wasm.__wbindgen_malloc);
395
- const len0 = WASM_VECTOR_LEN;
396
- const ptr1 = passArrayJsValueToWasm0(format_jsvalues, wasm.__wbindgen_malloc);
397
- const len1 = WASM_VECTOR_LEN;
398
- const ptr2 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
399
- const len2 = WASM_VECTOR_LEN;
400
- const ret = wasm.hakuban_object_state_new(ptr0, len0, ptr1, len1, ptr2, len2, synchronized_us_ago);
401
- return WasmResult.__wrap(ret);
402
- }
403
-
404
- /**
405
- * @param {number} object_state_pointer
406
- */
407
- function hakuban_object_state_drop(object_state_pointer) {
408
- wasm.hakuban_object_state_drop(object_state_pointer);
501
+ function __wbg_get_imports() {
502
+ const import0 = {
503
+ __proto__: null,
504
+ __wbg___wbindgen_is_undefined_29a43b4d42920abd: function(arg0) {
505
+ const ret = arg0 === undefined;
506
+ return ret;
507
+ },
508
+ __wbg___wbindgen_string_get_7ed5322991caaec5: function(arg0, arg1) {
509
+ const obj = arg1;
510
+ const ret = typeof(obj) === 'string' ? obj : undefined;
511
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
512
+ var len1 = WASM_VECTOR_LEN;
513
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
514
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
515
+ },
516
+ __wbg___wbindgen_throw_6b64449b9b9ed33c: function(arg0, arg1) {
517
+ throw new Error(getStringFromWasm0(arg0, arg1));
518
+ },
519
+ __wbg_debug_c014a160490283dc: function(arg0) {
520
+ console.debug(arg0);
521
+ },
522
+ __wbg_error_2001591ad2463697: function(arg0) {
523
+ console.error(arg0);
524
+ },
525
+ __wbg_error_a6fa202b58aa1cd3: function(arg0, arg1) {
526
+ let deferred0_0;
527
+ let deferred0_1;
528
+ try {
529
+ deferred0_0 = arg0;
530
+ deferred0_1 = arg1;
531
+ console.error(getStringFromWasm0(arg0, arg1));
532
+ } finally {
533
+ wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
534
+ }
535
+ },
536
+ __wbg_info_7479429238bffbce: function(arg0) {
537
+ console.info(arg0);
538
+ },
539
+ __wbg_log_7e1aa9064a1dbdbd: function(arg0) {
540
+ console.log(arg0);
541
+ },
542
+ __wbg_new_227d7c05414eb861: function() {
543
+ const ret = new Error();
544
+ return ret;
545
+ },
546
+ __wbg_now_e7c6795a7f81e10f: function(arg0) {
547
+ const ret = arg0.now();
548
+ return ret;
549
+ },
550
+ __wbg_performance_3fcf6e32a7e1ed0a: function(arg0) {
551
+ const ret = arg0.performance;
552
+ return ret;
553
+ },
554
+ __wbg_stack_3b0d974bbf31e44f: function(arg0, arg1) {
555
+ const ret = arg1.stack;
556
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
557
+ const len1 = WASM_VECTOR_LEN;
558
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
559
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
560
+ },
561
+ __wbg_static_accessor_GLOBAL_8cfadc87a297ca02: function() {
562
+ const ret = typeof global === 'undefined' ? null : global;
563
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
564
+ },
565
+ __wbg_static_accessor_GLOBAL_THIS_602256ae5c8f42cf: function() {
566
+ const ret = typeof globalThis === 'undefined' ? null : globalThis;
567
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
568
+ },
569
+ __wbg_static_accessor_SELF_e445c1c7484aecc3: function() {
570
+ const ret = typeof self === 'undefined' ? null : self;
571
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
572
+ },
573
+ __wbg_static_accessor_WINDOW_f20e8576ef1e0f17: function() {
574
+ const ret = typeof window === 'undefined' ? null : window;
575
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
576
+ },
577
+ __wbg_warn_3cc416af27dbdc02: function(arg0) {
578
+ console.warn(arg0);
579
+ },
580
+ __wbindgen_cast_0000000000000001: function(arg0, arg1) {
581
+ // Cast intrinsic for `Ref(String) -> Externref`.
582
+ const ret = getStringFromWasm0(arg0, arg1);
583
+ return ret;
584
+ },
585
+ __wbindgen_init_externref_table: function() {
586
+ const table = wasm.__wbindgen_externrefs;
587
+ const offset = table.grow(4);
588
+ table.set(0, undefined);
589
+ table.set(offset + 0, undefined);
590
+ table.set(offset + 1, null);
591
+ table.set(offset + 2, true);
592
+ table.set(offset + 3, false);
593
+ },
594
+ };
595
+ return {
596
+ __proto__: null,
597
+ "./hakuban_bg.js": import0,
598
+ };
409
599
  }
410
600
 
411
- let cachedBigInt64ArrayMemory0 = null;
601
+ const WasmResultFinalization = (typeof FinalizationRegistry === 'undefined')
602
+ ? { register: () => {}, unregister: () => {} }
603
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmresult_free(ptr >>> 0, 1));
412
604
 
413
- function getBigInt64ArrayMemory0() {
414
- if (cachedBigInt64ArrayMemory0 === null || cachedBigInt64ArrayMemory0.byteLength === 0) {
415
- cachedBigInt64ArrayMemory0 = new BigInt64Array(wasm.memory.buffer);
416
- }
417
- return cachedBigInt64ArrayMemory0;
605
+ function addToExternrefTable0(obj) {
606
+ const idx = wasm.__externref_table_alloc();
607
+ wasm.__wbindgen_externrefs.set(idx, obj);
608
+ return idx;
418
609
  }
419
610
 
420
611
  function getArrayI64FromWasm0(ptr, len) {
421
612
  ptr = ptr >>> 0;
422
613
  return getBigInt64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
423
614
  }
424
- /**
425
- * @param {number} object_state_pointer
426
- * @returns {BigInt64Array}
427
- */
428
- function hakuban_object_state_version(object_state_pointer) {
429
- const ret = wasm.hakuban_object_state_version(object_state_pointer);
430
- var v1 = getArrayI64FromWasm0(ret[0], ret[1]).slice();
431
- wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
432
- return v1;
433
- }
434
-
435
- /**
436
- * @param {number} object_state_pointer
437
- * @returns {bigint}
438
- */
439
- function hakuban_object_state_synchronized_ago(object_state_pointer) {
440
- const ret = wasm.hakuban_object_state_synchronized_ago(object_state_pointer);
441
- return BigInt.asUintN(64, ret);
442
- }
443
615
 
444
616
  function getArrayJsValueFromWasm0(ptr, len) {
445
617
  ptr = ptr >>> 0;
446
618
  const mem = getDataViewMemory0();
447
619
  const result = [];
448
620
  for (let i = ptr; i < ptr + 4 * len; i += 4) {
449
- result.push(wasm.__wbindgen_export_2.get(mem.getUint32(i, true)));
621
+ result.push(wasm.__wbindgen_externrefs.get(mem.getUint32(i, true)));
450
622
  }
451
623
  wasm.__externref_drop_slice(ptr, len);
452
624
  return result;
453
625
  }
454
- /**
455
- * @param {number} object_state_pointer
456
- * @returns {any[]}
457
- */
458
- function hakuban_object_state_format(object_state_pointer) {
459
- const ret = wasm.hakuban_object_state_format(object_state_pointer);
460
- var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
461
- wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
462
- return v1;
463
- }
464
-
465
- /**
466
- * @param {number} object_state_pointer
467
- * @returns {Uint8Array}
468
- */
469
- function hakuban_object_state_data(object_state_pointer) {
470
- const ret = wasm.hakuban_object_state_data(object_state_pointer);
471
- var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
472
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
473
- return v1;
474
- }
475
626
 
476
- /**
477
- * @param {string} default_log_level
478
- * @returns {WasmResult}
479
- */
480
- function hakuban_logger_initialize(default_log_level) {
481
- const ptr0 = passStringToWasm0(default_log_level, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
482
- const len0 = WASM_VECTOR_LEN;
483
- const ret = wasm.hakuban_logger_initialize(ptr0, len0);
484
- return WasmResult.__wrap(ret);
627
+ function getArrayU32FromWasm0(ptr, len) {
628
+ ptr = ptr >>> 0;
629
+ return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
485
630
  }
486
631
 
487
- /**
488
- * @param {string} json_string
489
- * @returns {WasmResult}
490
- */
491
- function hakuban_tag_descriptor_new(json_string) {
492
- const ptr0 = passStringToWasm0(json_string, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
493
- const len0 = WASM_VECTOR_LEN;
494
- const ret = wasm.hakuban_tag_descriptor_new(ptr0, len0);
495
- return WasmResult.__wrap(ret);
632
+ function getArrayU64FromWasm0(ptr, len) {
633
+ ptr = ptr >>> 0;
634
+ return getBigUint64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
496
635
  }
497
636
 
498
- /**
499
- * @param {number} descriptor_pointer
500
- */
501
- function hakuban_tag_descriptor_drop(descriptor_pointer) {
502
- wasm.hakuban_tag_descriptor_drop(descriptor_pointer);
637
+ function getArrayU8FromWasm0(ptr, len) {
638
+ ptr = ptr >>> 0;
639
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
503
640
  }
504
641
 
505
- let cachedUint32ArrayMemory0 = null;
506
-
507
- function getUint32ArrayMemory0() {
508
- if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
509
- cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
642
+ let cachedBigInt64ArrayMemory0 = null;
643
+ function getBigInt64ArrayMemory0() {
644
+ if (cachedBigInt64ArrayMemory0 === null || cachedBigInt64ArrayMemory0.byteLength === 0) {
645
+ cachedBigInt64ArrayMemory0 = new BigInt64Array(wasm.memory.buffer);
510
646
  }
511
- return cachedUint32ArrayMemory0;
512
- }
513
-
514
- function passArray32ToWasm0(arg, malloc) {
515
- const ptr = malloc(arg.length * 4, 4) >>> 0;
516
- getUint32ArrayMemory0().set(arg, ptr / 4);
517
- WASM_VECTOR_LEN = arg.length;
518
- return ptr;
519
- }
520
- /**
521
- * @param {string} json_string
522
- * @param {Uint32Array} tag_pointers
523
- * @returns {WasmResult}
524
- */
525
- function hakuban_object_descriptor_new(json_string, tag_pointers) {
526
- const ptr0 = passStringToWasm0(json_string, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
527
- const len0 = WASM_VECTOR_LEN;
528
- const ptr1 = passArray32ToWasm0(tag_pointers, wasm.__wbindgen_malloc);
529
- const len1 = WASM_VECTOR_LEN;
530
- const ret = wasm.hakuban_object_descriptor_new(ptr0, len0, ptr1, len1);
531
- return WasmResult.__wrap(ret);
532
- }
533
-
534
- /**
535
- * @param {number} descriptor_pointer
536
- */
537
- function hakuban_object_descriptor_drop(descriptor_pointer) {
538
- wasm.hakuban_object_descriptor_drop(descriptor_pointer);
647
+ return cachedBigInt64ArrayMemory0;
539
648
  }
540
649
 
541
- /**
542
- * @param {number} descriptor_pointer
543
- * @returns {string}
544
- */
545
- function hakuban_object_descriptor_json(descriptor_pointer) {
546
- let deferred1_0;
547
- let deferred1_1;
548
- try {
549
- const ret = wasm.hakuban_object_descriptor_json(descriptor_pointer);
550
- deferred1_0 = ret[0];
551
- deferred1_1 = ret[1];
552
- return getStringFromWasm0(ret[0], ret[1]);
553
- } finally {
554
- wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
650
+ let cachedBigUint64ArrayMemory0 = null;
651
+ function getBigUint64ArrayMemory0() {
652
+ if (cachedBigUint64ArrayMemory0 === null || cachedBigUint64ArrayMemory0.byteLength === 0) {
653
+ cachedBigUint64ArrayMemory0 = new BigUint64Array(wasm.memory.buffer);
555
654
  }
655
+ return cachedBigUint64ArrayMemory0;
556
656
  }
557
657
 
558
- function getArrayU32FromWasm0(ptr, len) {
559
- ptr = ptr >>> 0;
560
- return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
561
- }
562
- /**
563
- * @param {number} descriptor_pointer
564
- * @returns {Uint32Array}
565
- */
566
- function hakuban_object_descriptor_tags(descriptor_pointer) {
567
- const ret = wasm.hakuban_object_descriptor_tags(descriptor_pointer);
568
- var v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
569
- wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
570
- return v1;
658
+ let cachedDataViewMemory0 = null;
659
+ function getDataViewMemory0() {
660
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
661
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
662
+ }
663
+ return cachedDataViewMemory0;
571
664
  }
572
665
 
573
- /**
574
- * @param {number} exchange
575
- * @param {number} descriptor
576
- * @param {number} capacity
577
- * @returns {number}
578
- */
579
- function hakuban_tag_expose_contract_new(exchange, descriptor, capacity) {
580
- const ret = wasm.hakuban_tag_expose_contract_new(exchange, descriptor, capacity);
581
- return ret >>> 0;
666
+ function getStringFromWasm0(ptr, len) {
667
+ ptr = ptr >>> 0;
668
+ return decodeText(ptr, len);
582
669
  }
583
670
 
584
- /**
585
- * @param {number} tag_expose_contract_pointer
586
- */
587
- function hakuban_tag_expose_contract_drop(tag_expose_contract_pointer) {
588
- wasm.hakuban_tag_expose_contract_drop(tag_expose_contract_pointer);
671
+ let cachedUint32ArrayMemory0 = null;
672
+ function getUint32ArrayMemory0() {
673
+ if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
674
+ cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
675
+ }
676
+ return cachedUint32ArrayMemory0;
589
677
  }
590
678
 
591
- /**
592
- * @param {number} tag_expose_pointer
593
- * @returns {number}
594
- */
595
- function hakuban_tag_expose_contract_next(tag_expose_pointer) {
596
- const ret = wasm.hakuban_tag_expose_contract_next(tag_expose_pointer);
597
- return ret >>> 0;
679
+ let cachedUint8ArrayMemory0 = null;
680
+ function getUint8ArrayMemory0() {
681
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
682
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
683
+ }
684
+ return cachedUint8ArrayMemory0;
598
685
  }
599
686
 
600
- /**
601
- * @enum {0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9}
602
- */
603
- Object.freeze({
604
- Ok: 0, "0": "Ok",
605
- Pointer: 1, "1": "Pointer",
606
- Pending: 2, "2": "Pending",
607
- EndOfStream: 3, "3": "EndOfStream",
608
- InvalidString: 4, "4": "InvalidString",
609
- InvalidJSON: 5, "5": "InvalidJSON",
610
- InvalidURL: 6, "6": "InvalidURL",
611
- InvalidLogLevel: 7, "7": "InvalidLogLevel",
612
- LoggerInitializationError: 8, "8": "LoggerInitializationError",
613
- ConnectionTerminated: 9, "9": "ConnectionTerminated",
614
- });
687
+ function isLikeNone(x) {
688
+ return x === undefined || x === null;
689
+ }
615
690
 
616
- const WasmResultFinalization = (typeof FinalizationRegistry === 'undefined')
617
- ? { register: () => {}, unregister: () => {} }
618
- : new FinalizationRegistry(ptr => wasm.__wbg_wasmresult_free(ptr >>> 0, 1));
691
+ function passArray32ToWasm0(arg, malloc) {
692
+ const ptr = malloc(arg.length * 4, 4) >>> 0;
693
+ getUint32ArrayMemory0().set(arg, ptr / 4);
694
+ WASM_VECTOR_LEN = arg.length;
695
+ return ptr;
696
+ }
619
697
 
620
- class WasmResult {
698
+ function passArray64ToWasm0(arg, malloc) {
699
+ const ptr = malloc(arg.length * 8, 8) >>> 0;
700
+ getBigUint64ArrayMemory0().set(arg, ptr / 8);
701
+ WASM_VECTOR_LEN = arg.length;
702
+ return ptr;
703
+ }
621
704
 
622
- static __wrap(ptr) {
623
- ptr = ptr >>> 0;
624
- const obj = Object.create(WasmResult.prototype);
625
- obj.__wbg_ptr = ptr;
626
- WasmResultFinalization.register(obj, obj.__wbg_ptr, obj);
627
- return obj;
705
+ function passArray8ToWasm0(arg, malloc) {
706
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
707
+ getUint8ArrayMemory0().set(arg, ptr / 1);
708
+ WASM_VECTOR_LEN = arg.length;
709
+ return ptr;
710
+ }
711
+
712
+ function passArrayJsValueToWasm0(array, malloc) {
713
+ const ptr = malloc(array.length * 4, 4) >>> 0;
714
+ for (let i = 0; i < array.length; i++) {
715
+ const add = addToExternrefTable0(array[i]);
716
+ getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
628
717
  }
718
+ WASM_VECTOR_LEN = array.length;
719
+ return ptr;
720
+ }
629
721
 
630
- __destroy_into_raw() {
631
- const ptr = this.__wbg_ptr;
632
- this.__wbg_ptr = 0;
633
- WasmResultFinalization.unregister(this);
722
+ function passStringToWasm0(arg, malloc, realloc) {
723
+ if (realloc === undefined) {
724
+ const buf = cachedTextEncoder.encode(arg);
725
+ const ptr = malloc(buf.length, 1) >>> 0;
726
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
727
+ WASM_VECTOR_LEN = buf.length;
634
728
  return ptr;
635
729
  }
636
730
 
637
- free() {
638
- const ptr = this.__destroy_into_raw();
639
- wasm.__wbg_wasmresult_free(ptr, 0);
640
- }
641
- /**
642
- * @returns {WasmResultStatus}
643
- */
644
- get status() {
645
- const ret = wasm.__wbg_get_wasmresult_status(this.__wbg_ptr);
646
- return ret;
647
- }
648
- /**
649
- * @param {WasmResultStatus} arg0
650
- */
651
- set status(arg0) {
652
- wasm.__wbg_set_wasmresult_status(this.__wbg_ptr, arg0);
653
- }
654
- /**
655
- * @returns {number | undefined}
656
- */
657
- get pointer() {
658
- const ret = wasm.__wbg_get_wasmresult_pointer(this.__wbg_ptr);
659
- return ret === 0x100000001 ? undefined : ret;
660
- }
661
- /**
662
- * @param {number | null} [arg0]
663
- */
664
- set pointer(arg0) {
665
- wasm.__wbg_set_wasmresult_pointer(this.__wbg_ptr, isLikeNone(arg0) ? 0x100000001 : (arg0) >>> 0);
731
+ let len = arg.length;
732
+ let ptr = malloc(len, 1) >>> 0;
733
+
734
+ const mem = getUint8ArrayMemory0();
735
+
736
+ let offset = 0;
737
+
738
+ for (; offset < len; offset++) {
739
+ const code = arg.charCodeAt(offset);
740
+ if (code > 0x7F) break;
741
+ mem[ptr + offset] = code;
666
742
  }
667
- /**
668
- * @returns {string | undefined}
669
- */
670
- get error_message() {
671
- const ret = wasm.__wbg_get_wasmresult_error_message(this.__wbg_ptr);
672
- let v1;
673
- if (ret[0] !== 0) {
674
- v1 = getStringFromWasm0(ret[0], ret[1]).slice();
675
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
743
+ if (offset !== len) {
744
+ if (offset !== 0) {
745
+ arg = arg.slice(offset);
676
746
  }
677
- return v1;
747
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
748
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
749
+ const ret = cachedTextEncoder.encodeInto(arg, view);
750
+
751
+ offset += ret.written;
752
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
678
753
  }
679
- /**
680
- * @param {string | null} [arg0]
681
- */
682
- set error_message(arg0) {
683
- var ptr0 = isLikeNone(arg0) ? 0 : passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
684
- var len0 = WASM_VECTOR_LEN;
685
- wasm.__wbg_set_wasmresult_error_message(this.__wbg_ptr, ptr0, len0);
754
+
755
+ WASM_VECTOR_LEN = offset;
756
+ return ptr;
757
+ }
758
+
759
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
760
+ cachedTextDecoder.decode();
761
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
762
+ let numBytesDecoded = 0;
763
+ function decodeText(ptr, len) {
764
+ numBytesDecoded += len;
765
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
766
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
767
+ cachedTextDecoder.decode();
768
+ numBytesDecoded = len;
686
769
  }
770
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
771
+ }
772
+
773
+ const cachedTextEncoder = new TextEncoder();
774
+
775
+ if (!('encodeInto' in cachedTextEncoder)) {
776
+ cachedTextEncoder.encodeInto = function (arg, view) {
777
+ const buf = cachedTextEncoder.encode(arg);
778
+ view.set(buf);
779
+ return {
780
+ read: arg.length,
781
+ written: buf.length
782
+ };
783
+ };
784
+ }
785
+
786
+ let WASM_VECTOR_LEN = 0;
787
+
788
+ let wasm;
789
+ function __wbg_finalize_init(instance, module) {
790
+ wasm = instance.exports;
791
+ cachedBigInt64ArrayMemory0 = null;
792
+ cachedBigUint64ArrayMemory0 = null;
793
+ cachedDataViewMemory0 = null;
794
+ cachedUint32ArrayMemory0 = null;
795
+ cachedUint8ArrayMemory0 = null;
796
+ wasm.__wbindgen_start();
797
+ return wasm;
687
798
  }
688
799
 
689
800
  async function __wbg_load(module, imports) {
@@ -691,155 +802,41 @@ async function __wbg_load(module, imports) {
691
802
  if (typeof WebAssembly.instantiateStreaming === 'function') {
692
803
  try {
693
804
  return await WebAssembly.instantiateStreaming(module, imports);
694
-
695
805
  } catch (e) {
696
- if (module.headers.get('Content-Type') != 'application/wasm') {
806
+ const validResponse = module.ok && expectedResponseType(module.type);
807
+
808
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
697
809
  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);
698
810
 
699
- } else {
700
- throw e;
701
- }
811
+ } else { throw e; }
702
812
  }
703
813
  }
704
814
 
705
815
  const bytes = await module.arrayBuffer();
706
816
  return await WebAssembly.instantiate(bytes, imports);
707
-
708
817
  } else {
709
818
  const instance = await WebAssembly.instantiate(module, imports);
710
819
 
711
820
  if (instance instanceof WebAssembly.Instance) {
712
821
  return { instance, module };
713
-
714
822
  } else {
715
823
  return instance;
716
824
  }
717
825
  }
718
- }
719
826
 
720
- function __wbg_get_imports() {
721
- const imports = {};
722
- imports.wbg = {};
723
- imports.wbg.__wbg_call_672a4d21634d4a24 = function() { return handleError(function (arg0, arg1) {
724
- const ret = arg0.call(arg1);
725
- return ret;
726
- }, arguments) };
727
- imports.wbg.__wbg_debug_3cb59063b29f58c1 = function(arg0) {
728
- console.debug(arg0);
729
- };
730
- imports.wbg.__wbg_error_524f506f44df1645 = function(arg0) {
731
- console.error(arg0);
732
- };
733
- imports.wbg.__wbg_error_7534b8e9a36f1ab4 = function(arg0, arg1) {
734
- let deferred0_0;
735
- let deferred0_1;
736
- try {
737
- deferred0_0 = arg0;
738
- deferred0_1 = arg1;
739
- console.error(getStringFromWasm0(arg0, arg1));
740
- } finally {
741
- wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
827
+ function expectedResponseType(type) {
828
+ switch (type) {
829
+ case 'basic': case 'cors': case 'default': return true;
742
830
  }
743
- };
744
- imports.wbg.__wbg_info_3daf2e093e091b66 = function(arg0) {
745
- console.info(arg0);
746
- };
747
- imports.wbg.__wbg_log_c222819a41e063d3 = function(arg0) {
748
- console.log(arg0);
749
- };
750
- imports.wbg.__wbg_new_8a6f238a6ece86ea = function() {
751
- const ret = new Error();
752
- return ret;
753
- };
754
- imports.wbg.__wbg_newnoargs_105ed471475aaf50 = function(arg0, arg1) {
755
- const ret = new Function(getStringFromWasm0(arg0, arg1));
756
- return ret;
757
- };
758
- imports.wbg.__wbg_now_2c95c9de01293173 = function(arg0) {
759
- const ret = arg0.now();
760
- return ret;
761
- };
762
- imports.wbg.__wbg_performance_7a3ffd0b17f663ad = function(arg0) {
763
- const ret = arg0.performance;
764
- return ret;
765
- };
766
- imports.wbg.__wbg_stack_0ed75d68575b0f3c = function(arg0, arg1) {
767
- const ret = arg1.stack;
768
- const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
769
- const len1 = WASM_VECTOR_LEN;
770
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
771
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
772
- };
773
- imports.wbg.__wbg_static_accessor_GLOBAL_88a902d13a557d07 = function() {
774
- const ret = typeof global === 'undefined' ? null : global;
775
- return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
776
- };
777
- imports.wbg.__wbg_static_accessor_GLOBAL_THIS_56578be7e9f832b0 = function() {
778
- const ret = typeof globalThis === 'undefined' ? null : globalThis;
779
- return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
780
- };
781
- imports.wbg.__wbg_static_accessor_SELF_37c5d418e4bf5819 = function() {
782
- const ret = typeof self === 'undefined' ? null : self;
783
- return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
784
- };
785
- imports.wbg.__wbg_static_accessor_WINDOW_5de37043a91a9c40 = function() {
786
- const ret = typeof window === 'undefined' ? null : window;
787
- return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
788
- };
789
- imports.wbg.__wbg_warn_4ca3906c248c47c4 = function(arg0) {
790
- console.warn(arg0);
791
- };
792
- imports.wbg.__wbindgen_init_externref_table = function() {
793
- const table = wasm.__wbindgen_export_2;
794
- const offset = table.grow(4);
795
- table.set(0, undefined);
796
- table.set(offset + 0, undefined);
797
- table.set(offset + 1, null);
798
- table.set(offset + 2, true);
799
- table.set(offset + 3, false);
800
- };
801
- imports.wbg.__wbindgen_is_undefined = function(arg0) {
802
- const ret = arg0 === undefined;
803
- return ret;
804
- };
805
- imports.wbg.__wbindgen_string_get = function(arg0, arg1) {
806
- const obj = arg1;
807
- const ret = typeof(obj) === 'string' ? obj : undefined;
808
- var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
809
- var len1 = WASM_VECTOR_LEN;
810
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
811
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
812
- };
813
- imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
814
- const ret = getStringFromWasm0(arg0, arg1);
815
- return ret;
816
- };
817
- imports.wbg.__wbindgen_throw = function(arg0, arg1) {
818
- throw new Error(getStringFromWasm0(arg0, arg1));
819
- };
820
-
821
- return imports;
822
- }
823
-
824
- function __wbg_finalize_init(instance, module) {
825
- wasm = instance.exports;
826
- __wbg_init.__wbindgen_wasm_module = module;
827
- cachedBigInt64ArrayMemory0 = null;
828
- cachedBigUint64ArrayMemory0 = null;
829
- cachedDataViewMemory0 = null;
830
- cachedUint32ArrayMemory0 = null;
831
- cachedUint8ArrayMemory0 = null;
832
-
833
-
834
- wasm.__wbindgen_start();
835
- return wasm;
831
+ return false;
832
+ }
836
833
  }
837
834
 
838
835
  async function __wbg_init(module_or_path) {
839
836
  if (wasm !== undefined) return wasm;
840
837
 
841
838
 
842
- if (typeof module_or_path !== 'undefined') {
839
+ if (module_or_path !== undefined) {
843
840
  if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
844
841
  ({module_or_path} = module_or_path);
845
842
  } else {
@@ -847,7 +844,7 @@ async function __wbg_init(module_or_path) {
847
844
  }
848
845
  }
849
846
 
850
- if (typeof module_or_path === 'undefined') {
847
+ if (module_or_path === undefined) {
851
848
  module_or_path = new URL('hakuban_bg.wasm', import.meta.url);
852
849
  }
853
850
  const imports = __wbg_get_imports();
@@ -858,9 +855,21 @@ async function __wbg_init(module_or_path) {
858
855
 
859
856
  const { instance, module } = await __wbg_load(await module_or_path, imports);
860
857
 
861
- return __wbg_finalize_init(instance, module);
858
+ return __wbg_finalize_init(instance);
862
859
  }
863
860
 
861
+ var logger_log_level;
862
+
863
+ logger_log_level = void 0;
864
+
865
+ var log_level = function() {
866
+ return logger_log_level;
867
+ };
868
+
869
+ var log_level_set = function(value) {
870
+ return logger_log_level = value;
871
+ };
872
+
864
873
  var unwrap_pointer = function(result) {
865
874
  if (result.status === 1) {
866
875
  return result.pointer;
@@ -932,29 +941,23 @@ var Future = class Future {
932
941
 
933
942
  };
934
943
 
935
- var logger_initialized, logger_log_level;
944
+ var logger_initialized;
936
945
 
937
946
  logger_initialized = false;
938
947
 
939
- logger_log_level = void 0;
940
-
941
948
  var logger_initialize = function(log_level, skip_if_already_initialized = false) {
942
949
  var result;
943
950
  if (!logger_initialized || !skip_if_already_initialized) {
944
951
  result = hakuban_logger_initialize(log_level);
945
952
  if (result.status === 0) {
946
953
  logger_initialized = true;
947
- return logger_log_level = log_level;
954
+ return log_level_set(log_level);
948
955
  } else {
949
956
  return console.error("Failed to initialize logger, error " + result.error_message);
950
957
  }
951
958
  }
952
959
  };
953
960
 
954
- var log_level = function() {
955
- return logger_log_level;
956
- };
957
-
958
961
  var do_and_drop, do_and_drop_or_return, finalization_registry;
959
962
 
960
963
  finalization_registry = new FinalizationRegistry(function(function_and_arg) {
@@ -1161,7 +1164,7 @@ var ObjectState = class ObjectState extends FFIObject {
1161
1164
  })();
1162
1165
  this.synchronized_us_ago = hakuban_object_state_synchronized_ago(pointer);
1163
1166
  this.format = hakuban_object_state_format(pointer);
1164
- this.data = new TextDecoder().decode(hakuban_object_state_data(pointer));
1167
+ this.data = hakuban_object_state_data(pointer);
1165
1168
  } else {
1166
1169
  if (version == null) {
1167
1170
  timestamp = new Date().getTime();
@@ -1201,7 +1204,7 @@ var ObjectState = class ObjectState extends FFIObject {
1201
1204
  if (this._pointer != null) {
1202
1205
  return block(this._pointer);
1203
1206
  } else {
1204
- pointer = unwrap_pointer(hakuban_object_state_new(this.version, this.format, new TextEncoder().encode(this.data), this.synchronized_us_ago));
1207
+ pointer = unwrap_pointer(hakuban_object_state_new(this.version, this.format, this.data, this.synchronized_us_ago));
1205
1208
  this.initialize_pointer(null, pointer, hakuban_object_state_drop);
1206
1209
  return block(this._pointer);
1207
1210
  }
@@ -1227,11 +1230,11 @@ var ObjectState = class ObjectState extends FFIObject {
1227
1230
  if (this.format[this.format.length - 1] !== "JSON") {
1228
1231
  throw "Invalid data format";
1229
1232
  }
1230
- return new ObjectState(JSON.parse(this.data), this.version, this.format.slice(0, -1), this.synchronized_us_ago);
1233
+ return new ObjectState(JSON.parse(new TextDecoder().decode(this.data)), this.version, this.format.slice(0, -1), this.synchronized_us_ago);
1231
1234
  }
1232
1235
 
1233
1236
  json_serialize() {
1234
- return new ObjectState(JSON.stringify(this.data), this.version, this.format.concat("JSON"), this.synchronized_us_ago);
1237
+ return new ObjectState(new TextEncoder().encode(JSON.stringify(this.data)), this.version, this.format.concat("JSON"), this.synchronized_us_ago);
1235
1238
  }
1236
1239
 
1237
1240
  };