hakuban 0.5.5 → 0.6.2
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/README.md +7 -2
- package/hakuban-with-wasm.js +2680 -0
- package/hakuban-with-wasm.js.map +1 -0
- package/hakuban-with-wasm.min.js +2 -0
- package/hakuban-with-wasm.min.js.map +1 -0
- package/hakuban.js +2671 -0
- package/hakuban.js.map +1 -0
- package/hakuban.min.js +2 -0
- package/hakuban.min.js.map +1 -0
- package/hakuban.wasm +0 -0
- package/package.json +29 -8
- package/dist/es/hakuban.js +0 -1909
package/hakuban.js
ADDED
|
@@ -0,0 +1,2671 @@
|
|
|
1
|
+
let wasm;
|
|
2
|
+
|
|
3
|
+
const heap = new Array(32).fill(undefined);
|
|
4
|
+
|
|
5
|
+
heap.push(undefined, null, true, false);
|
|
6
|
+
|
|
7
|
+
function getObject(idx) { return heap[idx]; }
|
|
8
|
+
|
|
9
|
+
let heap_next = heap.length;
|
|
10
|
+
|
|
11
|
+
function dropObject(idx) {
|
|
12
|
+
if (idx < 36) return;
|
|
13
|
+
heap[idx] = heap_next;
|
|
14
|
+
heap_next = idx;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function takeObject(idx) {
|
|
18
|
+
const ret = getObject(idx);
|
|
19
|
+
dropObject(idx);
|
|
20
|
+
return ret;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
24
|
+
|
|
25
|
+
cachedTextDecoder.decode();
|
|
26
|
+
|
|
27
|
+
let cachegetUint8Memory0 = null;
|
|
28
|
+
function getUint8Memory0() {
|
|
29
|
+
if (cachegetUint8Memory0 === null || cachegetUint8Memory0.buffer !== wasm.memory.buffer) {
|
|
30
|
+
cachegetUint8Memory0 = new Uint8Array(wasm.memory.buffer);
|
|
31
|
+
}
|
|
32
|
+
return cachegetUint8Memory0;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function getStringFromWasm0(ptr, len) {
|
|
36
|
+
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function addHeapObject(obj) {
|
|
40
|
+
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
41
|
+
const idx = heap_next;
|
|
42
|
+
heap_next = heap[idx];
|
|
43
|
+
|
|
44
|
+
heap[idx] = obj;
|
|
45
|
+
return idx;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function debugString(val) {
|
|
49
|
+
// primitive types
|
|
50
|
+
const type = typeof val;
|
|
51
|
+
if (type == 'number' || type == 'boolean' || val == null) {
|
|
52
|
+
return `${val}`;
|
|
53
|
+
}
|
|
54
|
+
if (type == 'string') {
|
|
55
|
+
return `"${val}"`;
|
|
56
|
+
}
|
|
57
|
+
if (type == 'symbol') {
|
|
58
|
+
const description = val.description;
|
|
59
|
+
if (description == null) {
|
|
60
|
+
return 'Symbol';
|
|
61
|
+
} else {
|
|
62
|
+
return `Symbol(${description})`;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
if (type == 'function') {
|
|
66
|
+
const name = val.name;
|
|
67
|
+
if (typeof name == 'string' && name.length > 0) {
|
|
68
|
+
return `Function(${name})`;
|
|
69
|
+
} else {
|
|
70
|
+
return 'Function';
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
// objects
|
|
74
|
+
if (Array.isArray(val)) {
|
|
75
|
+
const length = val.length;
|
|
76
|
+
let debug = '[';
|
|
77
|
+
if (length > 0) {
|
|
78
|
+
debug += debugString(val[0]);
|
|
79
|
+
}
|
|
80
|
+
for(let i = 1; i < length; i++) {
|
|
81
|
+
debug += ', ' + debugString(val[i]);
|
|
82
|
+
}
|
|
83
|
+
debug += ']';
|
|
84
|
+
return debug;
|
|
85
|
+
}
|
|
86
|
+
// Test for built-in
|
|
87
|
+
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
|
|
88
|
+
let className;
|
|
89
|
+
if (builtInMatches.length > 1) {
|
|
90
|
+
className = builtInMatches[1];
|
|
91
|
+
} else {
|
|
92
|
+
// Failed to match the standard '[object ClassName]'
|
|
93
|
+
return toString.call(val);
|
|
94
|
+
}
|
|
95
|
+
if (className == 'Object') {
|
|
96
|
+
// we're a user defined class or Object
|
|
97
|
+
// JSON.stringify avoids problems with cycles, and is generally much
|
|
98
|
+
// easier than looping through ownProperties of `val`.
|
|
99
|
+
try {
|
|
100
|
+
return 'Object(' + JSON.stringify(val) + ')';
|
|
101
|
+
} catch (_) {
|
|
102
|
+
return 'Object';
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
// errors
|
|
106
|
+
if (val instanceof Error) {
|
|
107
|
+
return `${val.name}: ${val.message}\n${val.stack}`;
|
|
108
|
+
}
|
|
109
|
+
// TODO we could test for more things here, like `Set`s and `Map`s.
|
|
110
|
+
return className;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
let WASM_VECTOR_LEN = 0;
|
|
114
|
+
|
|
115
|
+
let cachedTextEncoder = new TextEncoder('utf-8');
|
|
116
|
+
|
|
117
|
+
const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
|
|
118
|
+
? function (arg, view) {
|
|
119
|
+
return cachedTextEncoder.encodeInto(arg, view);
|
|
120
|
+
}
|
|
121
|
+
: function (arg, view) {
|
|
122
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
123
|
+
view.set(buf);
|
|
124
|
+
return {
|
|
125
|
+
read: arg.length,
|
|
126
|
+
written: buf.length
|
|
127
|
+
};
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
131
|
+
|
|
132
|
+
if (realloc === undefined) {
|
|
133
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
134
|
+
const ptr = malloc(buf.length);
|
|
135
|
+
getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
136
|
+
WASM_VECTOR_LEN = buf.length;
|
|
137
|
+
return ptr;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
let len = arg.length;
|
|
141
|
+
let ptr = malloc(len);
|
|
142
|
+
|
|
143
|
+
const mem = getUint8Memory0();
|
|
144
|
+
|
|
145
|
+
let offset = 0;
|
|
146
|
+
|
|
147
|
+
for (; offset < len; offset++) {
|
|
148
|
+
const code = arg.charCodeAt(offset);
|
|
149
|
+
if (code > 0x7F) break;
|
|
150
|
+
mem[ptr + offset] = code;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if (offset !== len) {
|
|
154
|
+
if (offset !== 0) {
|
|
155
|
+
arg = arg.slice(offset);
|
|
156
|
+
}
|
|
157
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3);
|
|
158
|
+
const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
|
|
159
|
+
const ret = encodeString(arg, view);
|
|
160
|
+
|
|
161
|
+
offset += ret.written;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
WASM_VECTOR_LEN = offset;
|
|
165
|
+
return ptr;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
let cachegetInt32Memory0 = null;
|
|
169
|
+
function getInt32Memory0() {
|
|
170
|
+
if (cachegetInt32Memory0 === null || cachegetInt32Memory0.buffer !== wasm.memory.buffer) {
|
|
171
|
+
cachegetInt32Memory0 = new Int32Array(wasm.memory.buffer);
|
|
172
|
+
}
|
|
173
|
+
return cachegetInt32Memory0;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function makeMutClosure(arg0, arg1, dtor, f) {
|
|
177
|
+
const state = { a: arg0, b: arg1, cnt: 1, dtor };
|
|
178
|
+
const real = (...args) => {
|
|
179
|
+
// First up with a closure we increment the internal reference
|
|
180
|
+
// count. This ensures that the Rust closure environment won't
|
|
181
|
+
// be deallocated while we're invoking it.
|
|
182
|
+
state.cnt++;
|
|
183
|
+
const a = state.a;
|
|
184
|
+
state.a = 0;
|
|
185
|
+
try {
|
|
186
|
+
return f(a, state.b, ...args);
|
|
187
|
+
} finally {
|
|
188
|
+
if (--state.cnt === 0) {
|
|
189
|
+
wasm.__wbindgen_export_2.get(state.dtor)(a, state.b);
|
|
190
|
+
|
|
191
|
+
} else {
|
|
192
|
+
state.a = a;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
real.original = state;
|
|
197
|
+
|
|
198
|
+
return real;
|
|
199
|
+
}
|
|
200
|
+
function __wbg_adapter_16(arg0, arg1, arg2) {
|
|
201
|
+
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h2cb5c9e37b253332(arg0, arg1, addHeapObject(arg2));
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
const u32CvtShim = new Uint32Array(2);
|
|
205
|
+
|
|
206
|
+
const uint64CvtShim = new BigUint64Array(u32CvtShim.buffer);
|
|
207
|
+
/**
|
|
208
|
+
* @param {string} json_string
|
|
209
|
+
* @returns {WasmHashResult}
|
|
210
|
+
*/
|
|
211
|
+
function hakuban_json_hash(json_string) {
|
|
212
|
+
var ptr0 = passStringToWasm0(json_string, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
213
|
+
var len0 = WASM_VECTOR_LEN;
|
|
214
|
+
var ret = wasm.hakuban_json_hash(ptr0, len0);
|
|
215
|
+
return WasmHashResult.__wrap(ret);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* @param {string} default_log_level
|
|
220
|
+
* @returns {number}
|
|
221
|
+
*/
|
|
222
|
+
function hakuban_logger_initialize(default_log_level) {
|
|
223
|
+
var ptr0 = passStringToWasm0(default_log_level, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
224
|
+
var len0 = WASM_VECTOR_LEN;
|
|
225
|
+
var ret = wasm.hakuban_logger_initialize(ptr0, len0);
|
|
226
|
+
return ret;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* @param {string} name_str
|
|
231
|
+
* @returns {WasmLocalNodeNewResult}
|
|
232
|
+
*/
|
|
233
|
+
function hakuban_local_node_new(name_str) {
|
|
234
|
+
var ptr0 = passStringToWasm0(name_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
235
|
+
var len0 = WASM_VECTOR_LEN;
|
|
236
|
+
var ret = wasm.hakuban_local_node_new(ptr0, len0);
|
|
237
|
+
return WasmLocalNodeNewResult.__wrap(ret);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* @param {number} local_node
|
|
242
|
+
*/
|
|
243
|
+
function hakuban_local_node_drop(local_node) {
|
|
244
|
+
wasm.hakuban_local_node_drop(local_node);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* @param {number} local_node
|
|
249
|
+
* @param {string} descriptor
|
|
250
|
+
* @returns {WasmObjectObserveResult}
|
|
251
|
+
*/
|
|
252
|
+
function hakuban_object_observe_new(local_node, descriptor) {
|
|
253
|
+
var ptr0 = passStringToWasm0(descriptor, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
254
|
+
var len0 = WASM_VECTOR_LEN;
|
|
255
|
+
var ret = wasm.hakuban_object_observe_new(local_node, ptr0, len0);
|
|
256
|
+
return WasmObjectObserveResult.__wrap(ret);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* @param {number} object_ptr
|
|
261
|
+
*/
|
|
262
|
+
function hakuban_object_observe_drop(object_ptr) {
|
|
263
|
+
wasm.hakuban_object_observe_drop(object_ptr);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* @param {number} object_observe_pointer
|
|
268
|
+
* @returns {number}
|
|
269
|
+
*/
|
|
270
|
+
function hakuban_object_observe_state_borrow(object_observe_pointer) {
|
|
271
|
+
var ret = wasm.hakuban_object_observe_state_borrow(object_observe_pointer);
|
|
272
|
+
return ret;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* @param {number} state_ptr
|
|
277
|
+
*/
|
|
278
|
+
function hakuban_object_observe_state_return(state_ptr) {
|
|
279
|
+
wasm.hakuban_object_observe_state_return(state_ptr);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* @param {number} state_ptr
|
|
284
|
+
* @returns {BigInt}
|
|
285
|
+
*/
|
|
286
|
+
function hakuban_object_observe_state_synchronized(state_ptr) {
|
|
287
|
+
try {
|
|
288
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
289
|
+
wasm.hakuban_object_observe_state_synchronized(retptr, state_ptr);
|
|
290
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
291
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
292
|
+
u32CvtShim[0] = r0;
|
|
293
|
+
u32CvtShim[1] = r1;
|
|
294
|
+
const n0 = uint64CvtShim[0];
|
|
295
|
+
return n0;
|
|
296
|
+
} finally {
|
|
297
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* @param {number} state_ptr
|
|
303
|
+
* @returns {string}
|
|
304
|
+
*/
|
|
305
|
+
function hakuban_object_observe_state_data_version(state_ptr) {
|
|
306
|
+
try {
|
|
307
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
308
|
+
wasm.hakuban_object_observe_state_data_version(retptr, state_ptr);
|
|
309
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
310
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
311
|
+
return getStringFromWasm0(r0, r1);
|
|
312
|
+
} finally {
|
|
313
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
314
|
+
wasm.__wbindgen_free(r0, r1);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* @param {number} state_ptr
|
|
320
|
+
* @returns {string}
|
|
321
|
+
*/
|
|
322
|
+
function hakuban_object_observe_state_data_type(state_ptr) {
|
|
323
|
+
try {
|
|
324
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
325
|
+
wasm.hakuban_object_observe_state_data_type(retptr, state_ptr);
|
|
326
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
327
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
328
|
+
return getStringFromWasm0(r0, r1);
|
|
329
|
+
} finally {
|
|
330
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
331
|
+
wasm.__wbindgen_free(r0, r1);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
336
|
+
return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* @param {number} state_ptr
|
|
340
|
+
* @returns {Uint8Array}
|
|
341
|
+
*/
|
|
342
|
+
function hakuban_object_observe_state_data(state_ptr) {
|
|
343
|
+
try {
|
|
344
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
345
|
+
wasm.hakuban_object_observe_state_data(retptr, state_ptr);
|
|
346
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
347
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
348
|
+
var v0 = getArrayU8FromWasm0(r0, r1).slice();
|
|
349
|
+
wasm.__wbindgen_free(r0, r1 * 1);
|
|
350
|
+
return v0;
|
|
351
|
+
} finally {
|
|
352
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* @param {number} object_observe_ptr
|
|
358
|
+
* @returns {number}
|
|
359
|
+
*/
|
|
360
|
+
function hakuban_object_observe_events_get(object_observe_ptr) {
|
|
361
|
+
var ret = wasm.hakuban_object_observe_events_get(object_observe_ptr);
|
|
362
|
+
return ret;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* @param {number} events_pointer
|
|
367
|
+
*/
|
|
368
|
+
function hakuban_object_descriptor_events_drop(events_pointer) {
|
|
369
|
+
wasm.hakuban_object_descriptor_events_drop(events_pointer);
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
/**
|
|
373
|
+
* @param {number} events_pointer
|
|
374
|
+
* @param {Promise<any>} cancel
|
|
375
|
+
* @returns {Promise<any>}
|
|
376
|
+
*/
|
|
377
|
+
function hakuban_object_descriptor_events_next(events_pointer, cancel) {
|
|
378
|
+
var ret = wasm.hakuban_object_descriptor_events_next(events_pointer, addHeapObject(cancel));
|
|
379
|
+
return takeObject(ret);
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* @param {number} local_node
|
|
384
|
+
* @param {string} descriptor
|
|
385
|
+
* @returns {WasmTagObserveResult}
|
|
386
|
+
*/
|
|
387
|
+
function hakuban_tag_observe_new(local_node, descriptor) {
|
|
388
|
+
var ptr0 = passStringToWasm0(descriptor, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
389
|
+
var len0 = WASM_VECTOR_LEN;
|
|
390
|
+
var ret = wasm.hakuban_tag_observe_new(local_node, ptr0, len0);
|
|
391
|
+
return WasmTagObserveResult.__wrap(ret);
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
/**
|
|
395
|
+
* @param {number} tag_observe_pointer
|
|
396
|
+
*/
|
|
397
|
+
function hakuban_tag_observe_drop(tag_observe_pointer) {
|
|
398
|
+
wasm.hakuban_tag_observe_drop(tag_observe_pointer);
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
/**
|
|
402
|
+
* @param {number} tag_observe_pointer
|
|
403
|
+
* @param {string} object_descriptor
|
|
404
|
+
* @returns {WasmTagObserveObjectStateBorrowResult}
|
|
405
|
+
*/
|
|
406
|
+
function hakuban_tag_observe_object_state_borrow(tag_observe_pointer, object_descriptor) {
|
|
407
|
+
var ptr0 = passStringToWasm0(object_descriptor, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
408
|
+
var len0 = WASM_VECTOR_LEN;
|
|
409
|
+
var ret = wasm.hakuban_tag_observe_object_state_borrow(tag_observe_pointer, ptr0, len0);
|
|
410
|
+
return WasmTagObserveObjectStateBorrowResult.__wrap(ret);
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
/**
|
|
414
|
+
* @param {number} tag_observe_pointer
|
|
415
|
+
* @returns {string}
|
|
416
|
+
*/
|
|
417
|
+
function hakuban_tag_observe_object_descriptors(tag_observe_pointer) {
|
|
418
|
+
try {
|
|
419
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
420
|
+
wasm.hakuban_tag_observe_object_descriptors(retptr, tag_observe_pointer);
|
|
421
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
422
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
423
|
+
return getStringFromWasm0(r0, r1);
|
|
424
|
+
} finally {
|
|
425
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
426
|
+
wasm.__wbindgen_free(r0, r1);
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
/**
|
|
431
|
+
* @param {number} tag_observe_ptr
|
|
432
|
+
* @returns {number}
|
|
433
|
+
*/
|
|
434
|
+
function hakuban_tag_observe_events_get(tag_observe_ptr) {
|
|
435
|
+
var ret = wasm.hakuban_tag_observe_events_get(tag_observe_ptr);
|
|
436
|
+
return ret;
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
function isLikeNone(x) {
|
|
440
|
+
return x === undefined || x === null;
|
|
441
|
+
}
|
|
442
|
+
/**
|
|
443
|
+
* @param {number} local_node_pointer
|
|
444
|
+
* @param {boolean} upstream
|
|
445
|
+
* @param {boolean | undefined} diff_produce
|
|
446
|
+
* @param {boolean | undefined} diff_request
|
|
447
|
+
* @returns {WasmRemoteNodeNewResult}
|
|
448
|
+
*/
|
|
449
|
+
function hakuban_remote_node_new(local_node_pointer, upstream, diff_produce, diff_request) {
|
|
450
|
+
var ret = wasm.hakuban_remote_node_new(local_node_pointer, upstream, isLikeNone(diff_produce) ? 0xFFFFFF : diff_produce ? 1 : 0, isLikeNone(diff_request) ? 0xFFFFFF : diff_request ? 1 : 0);
|
|
451
|
+
return WasmRemoteNodeNewResult.__wrap(ret);
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
/**
|
|
455
|
+
* @param {number} remote_node_pointer
|
|
456
|
+
*/
|
|
457
|
+
function hakuban_remote_node_drop(remote_node_pointer) {
|
|
458
|
+
wasm.hakuban_remote_node_drop(remote_node_pointer);
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
/**
|
|
462
|
+
* @param {number} remote_node_pointer
|
|
463
|
+
* @returns {Uint8Array}
|
|
464
|
+
*/
|
|
465
|
+
function hakuban_remote_node_connected(remote_node_pointer) {
|
|
466
|
+
try {
|
|
467
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
468
|
+
wasm.hakuban_remote_node_connected(retptr, remote_node_pointer);
|
|
469
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
470
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
471
|
+
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
472
|
+
var r3 = getInt32Memory0()[retptr / 4 + 3];
|
|
473
|
+
if (r3) {
|
|
474
|
+
throw takeObject(r2);
|
|
475
|
+
}
|
|
476
|
+
var v0 = getArrayU8FromWasm0(r0, r1).slice();
|
|
477
|
+
wasm.__wbindgen_free(r0, r1 * 1);
|
|
478
|
+
return v0;
|
|
479
|
+
} finally {
|
|
480
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
/**
|
|
485
|
+
* @param {number} remote_node_pointer
|
|
486
|
+
*/
|
|
487
|
+
function hakuban_remote_node_disconnected(remote_node_pointer) {
|
|
488
|
+
wasm.hakuban_remote_node_disconnected(remote_node_pointer);
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
492
|
+
const ptr = malloc(arg.length * 1);
|
|
493
|
+
getUint8Memory0().set(arg, ptr / 1);
|
|
494
|
+
WASM_VECTOR_LEN = arg.length;
|
|
495
|
+
return ptr;
|
|
496
|
+
}
|
|
497
|
+
/**
|
|
498
|
+
* @param {number} remote_node_pointer
|
|
499
|
+
* @param {Uint8Array} data
|
|
500
|
+
* @returns {Uint8Array}
|
|
501
|
+
*/
|
|
502
|
+
function hakuban_remote_node_received_message(remote_node_pointer, data) {
|
|
503
|
+
try {
|
|
504
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
505
|
+
var ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
|
|
506
|
+
var len0 = WASM_VECTOR_LEN;
|
|
507
|
+
wasm.hakuban_remote_node_received_message(retptr, remote_node_pointer, ptr0, len0);
|
|
508
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
509
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
510
|
+
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
511
|
+
var r3 = getInt32Memory0()[retptr / 4 + 3];
|
|
512
|
+
if (r3) {
|
|
513
|
+
throw takeObject(r2);
|
|
514
|
+
}
|
|
515
|
+
var v1 = getArrayU8FromWasm0(r0, r1).slice();
|
|
516
|
+
wasm.__wbindgen_free(r0, r1 * 1);
|
|
517
|
+
return v1;
|
|
518
|
+
} finally {
|
|
519
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
/**
|
|
524
|
+
* @param {number} remote_node_pointer
|
|
525
|
+
* @param {Promise<any>} cancel
|
|
526
|
+
* @returns {Promise<any>}
|
|
527
|
+
*/
|
|
528
|
+
function hakuban_remote_node_next_local_node_event(remote_node_pointer, cancel) {
|
|
529
|
+
var ret = wasm.hakuban_remote_node_next_local_node_event(remote_node_pointer, addHeapObject(cancel));
|
|
530
|
+
return takeObject(ret);
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
/**
|
|
534
|
+
* @param {number} remote_node_pointer
|
|
535
|
+
* @param {string} event
|
|
536
|
+
* @returns {Uint8Array}
|
|
537
|
+
*/
|
|
538
|
+
function hakuban_remote_node_received_local_node_event(remote_node_pointer, event) {
|
|
539
|
+
try {
|
|
540
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
541
|
+
var ptr0 = passStringToWasm0(event, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
542
|
+
var len0 = WASM_VECTOR_LEN;
|
|
543
|
+
wasm.hakuban_remote_node_received_local_node_event(retptr, remote_node_pointer, ptr0, len0);
|
|
544
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
545
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
546
|
+
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
547
|
+
var r3 = getInt32Memory0()[retptr / 4 + 3];
|
|
548
|
+
if (r3) {
|
|
549
|
+
throw takeObject(r2);
|
|
550
|
+
}
|
|
551
|
+
var v1 = getArrayU8FromWasm0(r0, r1).slice();
|
|
552
|
+
wasm.__wbindgen_free(r0, r1 * 1);
|
|
553
|
+
return v1;
|
|
554
|
+
} finally {
|
|
555
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
/**
|
|
560
|
+
* @param {number} remote_node_pointer
|
|
561
|
+
* @returns {Uint8Array}
|
|
562
|
+
*/
|
|
563
|
+
function hakuban_remote_node_ack(remote_node_pointer) {
|
|
564
|
+
try {
|
|
565
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
566
|
+
wasm.hakuban_remote_node_ack(retptr, remote_node_pointer);
|
|
567
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
568
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
569
|
+
var v0 = getArrayU8FromWasm0(r0, r1).slice();
|
|
570
|
+
wasm.__wbindgen_free(r0, r1 * 1);
|
|
571
|
+
return v0;
|
|
572
|
+
} finally {
|
|
573
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
/**
|
|
578
|
+
* @param {number} local_node
|
|
579
|
+
* @param {string} descriptor
|
|
580
|
+
* @returns {WasmTagExposeResult}
|
|
581
|
+
*/
|
|
582
|
+
function hakuban_tag_expose_new(local_node, descriptor) {
|
|
583
|
+
var ptr0 = passStringToWasm0(descriptor, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
584
|
+
var len0 = WASM_VECTOR_LEN;
|
|
585
|
+
var ret = wasm.hakuban_tag_expose_new(local_node, ptr0, len0);
|
|
586
|
+
return WasmTagExposeResult.__wrap(ret);
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
/**
|
|
590
|
+
* @param {number} tag_expose_pointer
|
|
591
|
+
*/
|
|
592
|
+
function hakuban_tag_expose_drop(tag_expose_pointer) {
|
|
593
|
+
wasm.hakuban_tag_expose_drop(tag_expose_pointer);
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
/**
|
|
597
|
+
* @param {number} tag_expose_pointer
|
|
598
|
+
* @returns {string}
|
|
599
|
+
*/
|
|
600
|
+
function hakuban_tag_expose_object_descriptors(tag_expose_pointer) {
|
|
601
|
+
try {
|
|
602
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
603
|
+
wasm.hakuban_tag_expose_object_descriptors(retptr, tag_expose_pointer);
|
|
604
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
605
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
606
|
+
return getStringFromWasm0(r0, r1);
|
|
607
|
+
} finally {
|
|
608
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
609
|
+
wasm.__wbindgen_free(r0, r1);
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
/**
|
|
614
|
+
* @param {number} tag_expose_pointer
|
|
615
|
+
* @param {string} object_descriptor
|
|
616
|
+
* @param {string} data_version
|
|
617
|
+
* @param {string} data_type
|
|
618
|
+
* @param {Uint8Array} data
|
|
619
|
+
* @param {BigInt} assignment_id
|
|
620
|
+
* @returns {WasmTagExposeSetObjectStateResult}
|
|
621
|
+
*/
|
|
622
|
+
function hakuban_tag_expose_set_object_state(tag_expose_pointer, object_descriptor, data_version, data_type, data, assignment_id) {
|
|
623
|
+
var ptr0 = passStringToWasm0(object_descriptor, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
624
|
+
var len0 = WASM_VECTOR_LEN;
|
|
625
|
+
var ptr1 = passStringToWasm0(data_version, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
626
|
+
var len1 = WASM_VECTOR_LEN;
|
|
627
|
+
var ptr2 = passStringToWasm0(data_type, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
628
|
+
var len2 = WASM_VECTOR_LEN;
|
|
629
|
+
var ptr3 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
|
|
630
|
+
var len3 = WASM_VECTOR_LEN;
|
|
631
|
+
uint64CvtShim[0] = assignment_id;
|
|
632
|
+
const low4 = u32CvtShim[0];
|
|
633
|
+
const high4 = u32CvtShim[1];
|
|
634
|
+
var ret = wasm.hakuban_tag_expose_set_object_state(tag_expose_pointer, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, low4, high4);
|
|
635
|
+
return WasmTagExposeSetObjectStateResult.__wrap(ret);
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
/**
|
|
639
|
+
* @param {number} tag_expose_pointer
|
|
640
|
+
* @param {string} object_descriptor
|
|
641
|
+
* @returns {WasmTagExposeAssignmentResult}
|
|
642
|
+
*/
|
|
643
|
+
function hakuban_tag_expose_assignment(tag_expose_pointer, object_descriptor) {
|
|
644
|
+
var ptr0 = passStringToWasm0(object_descriptor, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
645
|
+
var len0 = WASM_VECTOR_LEN;
|
|
646
|
+
var ret = wasm.hakuban_tag_expose_assignment(tag_expose_pointer, ptr0, len0);
|
|
647
|
+
return WasmTagExposeAssignmentResult.__wrap(ret);
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
/**
|
|
651
|
+
* @param {number} tag_expose_pointer
|
|
652
|
+
* @param {string} object_descriptor
|
|
653
|
+
* @param {BigInt} assignment_id
|
|
654
|
+
* @returns {number}
|
|
655
|
+
*/
|
|
656
|
+
function hakuban_tag_expose_desynchronize(tag_expose_pointer, object_descriptor, assignment_id) {
|
|
657
|
+
var ptr0 = passStringToWasm0(object_descriptor, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
658
|
+
var len0 = WASM_VECTOR_LEN;
|
|
659
|
+
uint64CvtShim[0] = assignment_id;
|
|
660
|
+
const low1 = u32CvtShim[0];
|
|
661
|
+
const high1 = u32CvtShim[1];
|
|
662
|
+
var ret = wasm.hakuban_tag_expose_desynchronize(tag_expose_pointer, ptr0, len0, low1, high1);
|
|
663
|
+
return ret >>> 0;
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
/**
|
|
667
|
+
* @param {number} tag_expose_ptr
|
|
668
|
+
* @returns {number}
|
|
669
|
+
*/
|
|
670
|
+
function hakuban_tag_expose_events_get(tag_expose_ptr) {
|
|
671
|
+
var ret = wasm.hakuban_tag_expose_events_get(tag_expose_ptr);
|
|
672
|
+
return ret;
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
/**
|
|
676
|
+
* @param {number} local_node
|
|
677
|
+
* @param {string} descriptor
|
|
678
|
+
* @returns {WasmObjectExposeResult}
|
|
679
|
+
*/
|
|
680
|
+
function hakuban_object_expose_new(local_node, descriptor) {
|
|
681
|
+
var ptr0 = passStringToWasm0(descriptor, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
682
|
+
var len0 = WASM_VECTOR_LEN;
|
|
683
|
+
var ret = wasm.hakuban_object_expose_new(local_node, ptr0, len0);
|
|
684
|
+
return WasmObjectExposeResult.__wrap(ret);
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
/**
|
|
688
|
+
* @param {number} object_expose_pointer
|
|
689
|
+
*/
|
|
690
|
+
function hakuban_object_expose_drop(object_expose_pointer) {
|
|
691
|
+
wasm.hakuban_object_expose_drop(object_expose_pointer);
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
/**
|
|
695
|
+
* @param {number} object_expose_pointer
|
|
696
|
+
* @param {string} data_version
|
|
697
|
+
* @param {string} data_type
|
|
698
|
+
* @param {Uint8Array} data
|
|
699
|
+
* @param {BigInt} assignment_id
|
|
700
|
+
* @returns {WasmObjectExposeStateResult}
|
|
701
|
+
*/
|
|
702
|
+
function hakuban_object_expose_set_state(object_expose_pointer, data_version, data_type, data, assignment_id) {
|
|
703
|
+
var ptr0 = passStringToWasm0(data_version, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
704
|
+
var len0 = WASM_VECTOR_LEN;
|
|
705
|
+
var ptr1 = passStringToWasm0(data_type, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
706
|
+
var len1 = WASM_VECTOR_LEN;
|
|
707
|
+
var ptr2 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
|
|
708
|
+
var len2 = WASM_VECTOR_LEN;
|
|
709
|
+
uint64CvtShim[0] = assignment_id;
|
|
710
|
+
const low3 = u32CvtShim[0];
|
|
711
|
+
const high3 = u32CvtShim[1];
|
|
712
|
+
var ret = wasm.hakuban_object_expose_set_state(object_expose_pointer, ptr0, len0, ptr1, len1, ptr2, len2, low3, high3);
|
|
713
|
+
return WasmObjectExposeStateResult.__wrap(ret);
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
/**
|
|
717
|
+
* @param {number} object_expose_pointer
|
|
718
|
+
* @returns {BigInt}
|
|
719
|
+
*/
|
|
720
|
+
function hakuban_object_expose_assignment(object_expose_pointer) {
|
|
721
|
+
try {
|
|
722
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
723
|
+
wasm.hakuban_object_expose_assignment(retptr, object_expose_pointer);
|
|
724
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
725
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
726
|
+
u32CvtShim[0] = r0;
|
|
727
|
+
u32CvtShim[1] = r1;
|
|
728
|
+
const n0 = uint64CvtShim[0];
|
|
729
|
+
return n0;
|
|
730
|
+
} finally {
|
|
731
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
/**
|
|
736
|
+
* @param {number} object_expose_pointer
|
|
737
|
+
* @param {BigInt} assignment_id
|
|
738
|
+
*/
|
|
739
|
+
function hakuban_object_expose_desynchronize(object_expose_pointer, assignment_id) {
|
|
740
|
+
uint64CvtShim[0] = assignment_id;
|
|
741
|
+
const low0 = u32CvtShim[0];
|
|
742
|
+
const high0 = u32CvtShim[1];
|
|
743
|
+
wasm.hakuban_object_expose_desynchronize(object_expose_pointer, low0, high0);
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
/**
|
|
747
|
+
* @param {number} object_expose_ptr
|
|
748
|
+
* @returns {number}
|
|
749
|
+
*/
|
|
750
|
+
function hakuban_object_expose_events_get(object_expose_ptr) {
|
|
751
|
+
var ret = wasm.hakuban_object_expose_events_get(object_expose_ptr);
|
|
752
|
+
return ret;
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
function handleError(f, args) {
|
|
756
|
+
try {
|
|
757
|
+
return f.apply(this, args);
|
|
758
|
+
} catch (e) {
|
|
759
|
+
wasm.__wbindgen_exn_store(addHeapObject(e));
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
function __wbg_adapter_120(arg0, arg1, arg2, arg3) {
|
|
763
|
+
wasm.wasm_bindgen__convert__closures__invoke2_mut__h3fbc4a767cc461bf(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
/**
|
|
767
|
+
*/
|
|
768
|
+
Object.freeze({ None:0,"0":"None",InvalidString:1,"1":"InvalidString",InvalidJSON:2,"2":"InvalidJSON",InvalidURL:3,"3":"InvalidURL",ObjectNotFound:4,"4":"ObjectNotFound", });
|
|
769
|
+
/**
|
|
770
|
+
*/
|
|
771
|
+
class WasmHashResult {
|
|
772
|
+
|
|
773
|
+
static __wrap(ptr) {
|
|
774
|
+
const obj = Object.create(WasmHashResult.prototype);
|
|
775
|
+
obj.ptr = ptr;
|
|
776
|
+
|
|
777
|
+
return obj;
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
__destroy_into_raw() {
|
|
781
|
+
const ptr = this.ptr;
|
|
782
|
+
this.ptr = 0;
|
|
783
|
+
|
|
784
|
+
return ptr;
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
free() {
|
|
788
|
+
const ptr = this.__destroy_into_raw();
|
|
789
|
+
wasm.__wbg_wasmhashresult_free(ptr);
|
|
790
|
+
}
|
|
791
|
+
/**
|
|
792
|
+
*/
|
|
793
|
+
get error() {
|
|
794
|
+
var ret = wasm.__wbg_get_wasmhashresult_error(this.ptr);
|
|
795
|
+
return ret >>> 0;
|
|
796
|
+
}
|
|
797
|
+
/**
|
|
798
|
+
* @param {number} arg0
|
|
799
|
+
*/
|
|
800
|
+
set error(arg0) {
|
|
801
|
+
wasm.__wbg_set_wasmhashresult_error(this.ptr, arg0);
|
|
802
|
+
}
|
|
803
|
+
/**
|
|
804
|
+
*/
|
|
805
|
+
get hash() {
|
|
806
|
+
try {
|
|
807
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
808
|
+
wasm.__wbg_get_wasmhashresult_hash(retptr, this.ptr);
|
|
809
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
810
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
811
|
+
u32CvtShim[0] = r0;
|
|
812
|
+
u32CvtShim[1] = r1;
|
|
813
|
+
const n0 = uint64CvtShim[0];
|
|
814
|
+
return n0;
|
|
815
|
+
} finally {
|
|
816
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
/**
|
|
820
|
+
* @param {BigInt} arg0
|
|
821
|
+
*/
|
|
822
|
+
set hash(arg0) {
|
|
823
|
+
uint64CvtShim[0] = arg0;
|
|
824
|
+
const low0 = u32CvtShim[0];
|
|
825
|
+
const high0 = u32CvtShim[1];
|
|
826
|
+
wasm.__wbg_set_wasmhashresult_hash(this.ptr, low0, high0);
|
|
827
|
+
}
|
|
828
|
+
}
|
|
829
|
+
/**
|
|
830
|
+
*/
|
|
831
|
+
class WasmLocalNodeNewResult {
|
|
832
|
+
|
|
833
|
+
static __wrap(ptr) {
|
|
834
|
+
const obj = Object.create(WasmLocalNodeNewResult.prototype);
|
|
835
|
+
obj.ptr = ptr;
|
|
836
|
+
|
|
837
|
+
return obj;
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
__destroy_into_raw() {
|
|
841
|
+
const ptr = this.ptr;
|
|
842
|
+
this.ptr = 0;
|
|
843
|
+
|
|
844
|
+
return ptr;
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
free() {
|
|
848
|
+
const ptr = this.__destroy_into_raw();
|
|
849
|
+
wasm.__wbg_wasmlocalnodenewresult_free(ptr);
|
|
850
|
+
}
|
|
851
|
+
/**
|
|
852
|
+
*/
|
|
853
|
+
get error() {
|
|
854
|
+
var ret = wasm.__wbg_get_wasmlocalnodenewresult_error(this.ptr);
|
|
855
|
+
return ret >>> 0;
|
|
856
|
+
}
|
|
857
|
+
/**
|
|
858
|
+
* @param {number} arg0
|
|
859
|
+
*/
|
|
860
|
+
set error(arg0) {
|
|
861
|
+
wasm.__wbg_set_wasmlocalnodenewresult_error(this.ptr, arg0);
|
|
862
|
+
}
|
|
863
|
+
/**
|
|
864
|
+
*/
|
|
865
|
+
get local_node_pointer() {
|
|
866
|
+
var ret = wasm.__wbg_get_wasmlocalnodenewresult_local_node_pointer(this.ptr);
|
|
867
|
+
return ret;
|
|
868
|
+
}
|
|
869
|
+
/**
|
|
870
|
+
* @param {number} arg0
|
|
871
|
+
*/
|
|
872
|
+
set local_node_pointer(arg0) {
|
|
873
|
+
wasm.__wbg_set_wasmlocalnodenewresult_local_node_pointer(this.ptr, arg0);
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
/**
|
|
877
|
+
*/
|
|
878
|
+
class WasmObjectExposeResult {
|
|
879
|
+
|
|
880
|
+
static __wrap(ptr) {
|
|
881
|
+
const obj = Object.create(WasmObjectExposeResult.prototype);
|
|
882
|
+
obj.ptr = ptr;
|
|
883
|
+
|
|
884
|
+
return obj;
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
__destroy_into_raw() {
|
|
888
|
+
const ptr = this.ptr;
|
|
889
|
+
this.ptr = 0;
|
|
890
|
+
|
|
891
|
+
return ptr;
|
|
892
|
+
}
|
|
893
|
+
|
|
894
|
+
free() {
|
|
895
|
+
const ptr = this.__destroy_into_raw();
|
|
896
|
+
wasm.__wbg_wasmobjectexposeresult_free(ptr);
|
|
897
|
+
}
|
|
898
|
+
/**
|
|
899
|
+
*/
|
|
900
|
+
get error() {
|
|
901
|
+
var ret = wasm.__wbg_get_wasmobjectexposeresult_error(this.ptr);
|
|
902
|
+
return ret >>> 0;
|
|
903
|
+
}
|
|
904
|
+
/**
|
|
905
|
+
* @param {number} arg0
|
|
906
|
+
*/
|
|
907
|
+
set error(arg0) {
|
|
908
|
+
wasm.__wbg_set_wasmobjectexposeresult_error(this.ptr, arg0);
|
|
909
|
+
}
|
|
910
|
+
/**
|
|
911
|
+
*/
|
|
912
|
+
get object_expose_pointer() {
|
|
913
|
+
var ret = wasm.__wbg_get_wasmobjectexposeresult_object_expose_pointer(this.ptr);
|
|
914
|
+
return ret;
|
|
915
|
+
}
|
|
916
|
+
/**
|
|
917
|
+
* @param {number} arg0
|
|
918
|
+
*/
|
|
919
|
+
set object_expose_pointer(arg0) {
|
|
920
|
+
wasm.__wbg_set_wasmobjectexposeresult_object_expose_pointer(this.ptr, arg0);
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
/**
|
|
924
|
+
*/
|
|
925
|
+
class WasmObjectExposeStateResult {
|
|
926
|
+
|
|
927
|
+
static __wrap(ptr) {
|
|
928
|
+
const obj = Object.create(WasmObjectExposeStateResult.prototype);
|
|
929
|
+
obj.ptr = ptr;
|
|
930
|
+
|
|
931
|
+
return obj;
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
__destroy_into_raw() {
|
|
935
|
+
const ptr = this.ptr;
|
|
936
|
+
this.ptr = 0;
|
|
937
|
+
|
|
938
|
+
return ptr;
|
|
939
|
+
}
|
|
940
|
+
|
|
941
|
+
free() {
|
|
942
|
+
const ptr = this.__destroy_into_raw();
|
|
943
|
+
wasm.__wbg_wasmobjectexposestateresult_free(ptr);
|
|
944
|
+
}
|
|
945
|
+
/**
|
|
946
|
+
*/
|
|
947
|
+
get error() {
|
|
948
|
+
var ret = wasm.__wbg_get_wasmobjectexposestateresult_error(this.ptr);
|
|
949
|
+
return ret >>> 0;
|
|
950
|
+
}
|
|
951
|
+
/**
|
|
952
|
+
* @param {number} arg0
|
|
953
|
+
*/
|
|
954
|
+
set error(arg0) {
|
|
955
|
+
wasm.__wbg_set_wasmobjectexposestateresult_error(this.ptr, arg0);
|
|
956
|
+
}
|
|
957
|
+
/**
|
|
958
|
+
*/
|
|
959
|
+
get changed() {
|
|
960
|
+
var ret = wasm.__wbg_get_wasmobjectexposestateresult_changed(this.ptr);
|
|
961
|
+
return ret !== 0;
|
|
962
|
+
}
|
|
963
|
+
/**
|
|
964
|
+
* @param {boolean} arg0
|
|
965
|
+
*/
|
|
966
|
+
set changed(arg0) {
|
|
967
|
+
wasm.__wbg_set_wasmobjectexposestateresult_changed(this.ptr, arg0);
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
/**
|
|
971
|
+
*/
|
|
972
|
+
class WasmObjectObserveResult {
|
|
973
|
+
|
|
974
|
+
static __wrap(ptr) {
|
|
975
|
+
const obj = Object.create(WasmObjectObserveResult.prototype);
|
|
976
|
+
obj.ptr = ptr;
|
|
977
|
+
|
|
978
|
+
return obj;
|
|
979
|
+
}
|
|
980
|
+
|
|
981
|
+
__destroy_into_raw() {
|
|
982
|
+
const ptr = this.ptr;
|
|
983
|
+
this.ptr = 0;
|
|
984
|
+
|
|
985
|
+
return ptr;
|
|
986
|
+
}
|
|
987
|
+
|
|
988
|
+
free() {
|
|
989
|
+
const ptr = this.__destroy_into_raw();
|
|
990
|
+
wasm.__wbg_wasmobjectobserveresult_free(ptr);
|
|
991
|
+
}
|
|
992
|
+
/**
|
|
993
|
+
*/
|
|
994
|
+
get error() {
|
|
995
|
+
var ret = wasm.__wbg_get_wasmobjectobserveresult_error(this.ptr);
|
|
996
|
+
return ret >>> 0;
|
|
997
|
+
}
|
|
998
|
+
/**
|
|
999
|
+
* @param {number} arg0
|
|
1000
|
+
*/
|
|
1001
|
+
set error(arg0) {
|
|
1002
|
+
wasm.__wbg_set_wasmobjectobserveresult_error(this.ptr, arg0);
|
|
1003
|
+
}
|
|
1004
|
+
/**
|
|
1005
|
+
*/
|
|
1006
|
+
get object_observe_pointer() {
|
|
1007
|
+
var ret = wasm.__wbg_get_wasmobjectobserveresult_object_observe_pointer(this.ptr);
|
|
1008
|
+
return ret;
|
|
1009
|
+
}
|
|
1010
|
+
/**
|
|
1011
|
+
* @param {number} arg0
|
|
1012
|
+
*/
|
|
1013
|
+
set object_observe_pointer(arg0) {
|
|
1014
|
+
wasm.__wbg_set_wasmobjectobserveresult_object_observe_pointer(this.ptr, arg0);
|
|
1015
|
+
}
|
|
1016
|
+
}
|
|
1017
|
+
/**
|
|
1018
|
+
*/
|
|
1019
|
+
class WasmRemoteNodeNewResult {
|
|
1020
|
+
|
|
1021
|
+
static __wrap(ptr) {
|
|
1022
|
+
const obj = Object.create(WasmRemoteNodeNewResult.prototype);
|
|
1023
|
+
obj.ptr = ptr;
|
|
1024
|
+
|
|
1025
|
+
return obj;
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
__destroy_into_raw() {
|
|
1029
|
+
const ptr = this.ptr;
|
|
1030
|
+
this.ptr = 0;
|
|
1031
|
+
|
|
1032
|
+
return ptr;
|
|
1033
|
+
}
|
|
1034
|
+
|
|
1035
|
+
free() {
|
|
1036
|
+
const ptr = this.__destroy_into_raw();
|
|
1037
|
+
wasm.__wbg_wasmremotenodenewresult_free(ptr);
|
|
1038
|
+
}
|
|
1039
|
+
/**
|
|
1040
|
+
*/
|
|
1041
|
+
get error() {
|
|
1042
|
+
var ret = wasm.__wbg_get_wasmremotenodenewresult_error(this.ptr);
|
|
1043
|
+
return ret >>> 0;
|
|
1044
|
+
}
|
|
1045
|
+
/**
|
|
1046
|
+
* @param {number} arg0
|
|
1047
|
+
*/
|
|
1048
|
+
set error(arg0) {
|
|
1049
|
+
wasm.__wbg_set_wasmremotenodenewresult_error(this.ptr, arg0);
|
|
1050
|
+
}
|
|
1051
|
+
/**
|
|
1052
|
+
*/
|
|
1053
|
+
get remote_node_pointer() {
|
|
1054
|
+
var ret = wasm.__wbg_get_wasmremotenodenewresult_remote_node_pointer(this.ptr);
|
|
1055
|
+
return ret;
|
|
1056
|
+
}
|
|
1057
|
+
/**
|
|
1058
|
+
* @param {number} arg0
|
|
1059
|
+
*/
|
|
1060
|
+
set remote_node_pointer(arg0) {
|
|
1061
|
+
wasm.__wbg_set_wasmremotenodenewresult_remote_node_pointer(this.ptr, arg0);
|
|
1062
|
+
}
|
|
1063
|
+
}
|
|
1064
|
+
/**
|
|
1065
|
+
*/
|
|
1066
|
+
class WasmTagExposeAssignmentResult {
|
|
1067
|
+
|
|
1068
|
+
static __wrap(ptr) {
|
|
1069
|
+
const obj = Object.create(WasmTagExposeAssignmentResult.prototype);
|
|
1070
|
+
obj.ptr = ptr;
|
|
1071
|
+
|
|
1072
|
+
return obj;
|
|
1073
|
+
}
|
|
1074
|
+
|
|
1075
|
+
__destroy_into_raw() {
|
|
1076
|
+
const ptr = this.ptr;
|
|
1077
|
+
this.ptr = 0;
|
|
1078
|
+
|
|
1079
|
+
return ptr;
|
|
1080
|
+
}
|
|
1081
|
+
|
|
1082
|
+
free() {
|
|
1083
|
+
const ptr = this.__destroy_into_raw();
|
|
1084
|
+
wasm.__wbg_wasmtagexposeassignmentresult_free(ptr);
|
|
1085
|
+
}
|
|
1086
|
+
/**
|
|
1087
|
+
*/
|
|
1088
|
+
get error() {
|
|
1089
|
+
var ret = wasm.__wbg_get_wasmtagexposeassignmentresult_error(this.ptr);
|
|
1090
|
+
return ret >>> 0;
|
|
1091
|
+
}
|
|
1092
|
+
/**
|
|
1093
|
+
* @param {number} arg0
|
|
1094
|
+
*/
|
|
1095
|
+
set error(arg0) {
|
|
1096
|
+
wasm.__wbg_set_wasmtagexposeassignmentresult_error(this.ptr, arg0);
|
|
1097
|
+
}
|
|
1098
|
+
/**
|
|
1099
|
+
*/
|
|
1100
|
+
get assignment() {
|
|
1101
|
+
try {
|
|
1102
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1103
|
+
wasm.__wbg_get_wasmtagexposeassignmentresult_assignment(retptr, this.ptr);
|
|
1104
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
1105
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
1106
|
+
u32CvtShim[0] = r0;
|
|
1107
|
+
u32CvtShim[1] = r1;
|
|
1108
|
+
const n0 = uint64CvtShim[0];
|
|
1109
|
+
return n0;
|
|
1110
|
+
} finally {
|
|
1111
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1112
|
+
}
|
|
1113
|
+
}
|
|
1114
|
+
/**
|
|
1115
|
+
* @param {BigInt} arg0
|
|
1116
|
+
*/
|
|
1117
|
+
set assignment(arg0) {
|
|
1118
|
+
uint64CvtShim[0] = arg0;
|
|
1119
|
+
const low0 = u32CvtShim[0];
|
|
1120
|
+
const high0 = u32CvtShim[1];
|
|
1121
|
+
wasm.__wbg_set_wasmtagexposeassignmentresult_assignment(this.ptr, low0, high0);
|
|
1122
|
+
}
|
|
1123
|
+
}
|
|
1124
|
+
/**
|
|
1125
|
+
*/
|
|
1126
|
+
class WasmTagExposeResult {
|
|
1127
|
+
|
|
1128
|
+
static __wrap(ptr) {
|
|
1129
|
+
const obj = Object.create(WasmTagExposeResult.prototype);
|
|
1130
|
+
obj.ptr = ptr;
|
|
1131
|
+
|
|
1132
|
+
return obj;
|
|
1133
|
+
}
|
|
1134
|
+
|
|
1135
|
+
__destroy_into_raw() {
|
|
1136
|
+
const ptr = this.ptr;
|
|
1137
|
+
this.ptr = 0;
|
|
1138
|
+
|
|
1139
|
+
return ptr;
|
|
1140
|
+
}
|
|
1141
|
+
|
|
1142
|
+
free() {
|
|
1143
|
+
const ptr = this.__destroy_into_raw();
|
|
1144
|
+
wasm.__wbg_wasmtagexposeresult_free(ptr);
|
|
1145
|
+
}
|
|
1146
|
+
/**
|
|
1147
|
+
*/
|
|
1148
|
+
get error() {
|
|
1149
|
+
var ret = wasm.__wbg_get_wasmtagexposeresult_error(this.ptr);
|
|
1150
|
+
return ret >>> 0;
|
|
1151
|
+
}
|
|
1152
|
+
/**
|
|
1153
|
+
* @param {number} arg0
|
|
1154
|
+
*/
|
|
1155
|
+
set error(arg0) {
|
|
1156
|
+
wasm.__wbg_set_wasmtagexposeresult_error(this.ptr, arg0);
|
|
1157
|
+
}
|
|
1158
|
+
/**
|
|
1159
|
+
*/
|
|
1160
|
+
get tag_expose_pointer() {
|
|
1161
|
+
var ret = wasm.__wbg_get_wasmtagexposeresult_tag_expose_pointer(this.ptr);
|
|
1162
|
+
return ret;
|
|
1163
|
+
}
|
|
1164
|
+
/**
|
|
1165
|
+
* @param {number} arg0
|
|
1166
|
+
*/
|
|
1167
|
+
set tag_expose_pointer(arg0) {
|
|
1168
|
+
wasm.__wbg_set_wasmtagexposeresult_tag_expose_pointer(this.ptr, arg0);
|
|
1169
|
+
}
|
|
1170
|
+
}
|
|
1171
|
+
/**
|
|
1172
|
+
*/
|
|
1173
|
+
class WasmTagExposeSetObjectStateResult {
|
|
1174
|
+
|
|
1175
|
+
static __wrap(ptr) {
|
|
1176
|
+
const obj = Object.create(WasmTagExposeSetObjectStateResult.prototype);
|
|
1177
|
+
obj.ptr = ptr;
|
|
1178
|
+
|
|
1179
|
+
return obj;
|
|
1180
|
+
}
|
|
1181
|
+
|
|
1182
|
+
__destroy_into_raw() {
|
|
1183
|
+
const ptr = this.ptr;
|
|
1184
|
+
this.ptr = 0;
|
|
1185
|
+
|
|
1186
|
+
return ptr;
|
|
1187
|
+
}
|
|
1188
|
+
|
|
1189
|
+
free() {
|
|
1190
|
+
const ptr = this.__destroy_into_raw();
|
|
1191
|
+
wasm.__wbg_wasmtagexposesetobjectstateresult_free(ptr);
|
|
1192
|
+
}
|
|
1193
|
+
/**
|
|
1194
|
+
*/
|
|
1195
|
+
get error() {
|
|
1196
|
+
var ret = wasm.__wbg_get_wasmtagexposesetobjectstateresult_error(this.ptr);
|
|
1197
|
+
return ret >>> 0;
|
|
1198
|
+
}
|
|
1199
|
+
/**
|
|
1200
|
+
* @param {number} arg0
|
|
1201
|
+
*/
|
|
1202
|
+
set error(arg0) {
|
|
1203
|
+
wasm.__wbg_set_wasmtagexposesetobjectstateresult_error(this.ptr, arg0);
|
|
1204
|
+
}
|
|
1205
|
+
/**
|
|
1206
|
+
*/
|
|
1207
|
+
get changed() {
|
|
1208
|
+
var ret = wasm.__wbg_get_wasmtagexposesetobjectstateresult_changed(this.ptr);
|
|
1209
|
+
return ret !== 0;
|
|
1210
|
+
}
|
|
1211
|
+
/**
|
|
1212
|
+
* @param {boolean} arg0
|
|
1213
|
+
*/
|
|
1214
|
+
set changed(arg0) {
|
|
1215
|
+
wasm.__wbg_set_wasmtagexposesetobjectstateresult_changed(this.ptr, arg0);
|
|
1216
|
+
}
|
|
1217
|
+
}
|
|
1218
|
+
/**
|
|
1219
|
+
*/
|
|
1220
|
+
class WasmTagObserveObjectStateBorrowResult {
|
|
1221
|
+
|
|
1222
|
+
static __wrap(ptr) {
|
|
1223
|
+
const obj = Object.create(WasmTagObserveObjectStateBorrowResult.prototype);
|
|
1224
|
+
obj.ptr = ptr;
|
|
1225
|
+
|
|
1226
|
+
return obj;
|
|
1227
|
+
}
|
|
1228
|
+
|
|
1229
|
+
__destroy_into_raw() {
|
|
1230
|
+
const ptr = this.ptr;
|
|
1231
|
+
this.ptr = 0;
|
|
1232
|
+
|
|
1233
|
+
return ptr;
|
|
1234
|
+
}
|
|
1235
|
+
|
|
1236
|
+
free() {
|
|
1237
|
+
const ptr = this.__destroy_into_raw();
|
|
1238
|
+
wasm.__wbg_wasmtagobserveobjectstateborrowresult_free(ptr);
|
|
1239
|
+
}
|
|
1240
|
+
/**
|
|
1241
|
+
*/
|
|
1242
|
+
get error() {
|
|
1243
|
+
var ret = wasm.__wbg_get_wasmtagobserveobjectstateborrowresult_error(this.ptr);
|
|
1244
|
+
return ret >>> 0;
|
|
1245
|
+
}
|
|
1246
|
+
/**
|
|
1247
|
+
* @param {number} arg0
|
|
1248
|
+
*/
|
|
1249
|
+
set error(arg0) {
|
|
1250
|
+
wasm.__wbg_set_wasmtagobserveobjectstateborrowresult_error(this.ptr, arg0);
|
|
1251
|
+
}
|
|
1252
|
+
/**
|
|
1253
|
+
*/
|
|
1254
|
+
get state_pointer() {
|
|
1255
|
+
var ret = wasm.__wbg_get_wasmtagobserveobjectstateborrowresult_state_pointer(this.ptr);
|
|
1256
|
+
return ret;
|
|
1257
|
+
}
|
|
1258
|
+
/**
|
|
1259
|
+
* @param {number} arg0
|
|
1260
|
+
*/
|
|
1261
|
+
set state_pointer(arg0) {
|
|
1262
|
+
wasm.__wbg_set_wasmtagobserveobjectstateborrowresult_state_pointer(this.ptr, arg0);
|
|
1263
|
+
}
|
|
1264
|
+
}
|
|
1265
|
+
/**
|
|
1266
|
+
*/
|
|
1267
|
+
class WasmTagObserveResult {
|
|
1268
|
+
|
|
1269
|
+
static __wrap(ptr) {
|
|
1270
|
+
const obj = Object.create(WasmTagObserveResult.prototype);
|
|
1271
|
+
obj.ptr = ptr;
|
|
1272
|
+
|
|
1273
|
+
return obj;
|
|
1274
|
+
}
|
|
1275
|
+
|
|
1276
|
+
__destroy_into_raw() {
|
|
1277
|
+
const ptr = this.ptr;
|
|
1278
|
+
this.ptr = 0;
|
|
1279
|
+
|
|
1280
|
+
return ptr;
|
|
1281
|
+
}
|
|
1282
|
+
|
|
1283
|
+
free() {
|
|
1284
|
+
const ptr = this.__destroy_into_raw();
|
|
1285
|
+
wasm.__wbg_wasmtagobserveresult_free(ptr);
|
|
1286
|
+
}
|
|
1287
|
+
/**
|
|
1288
|
+
*/
|
|
1289
|
+
get error() {
|
|
1290
|
+
var ret = wasm.__wbg_get_wasmtagobserveresult_error(this.ptr);
|
|
1291
|
+
return ret >>> 0;
|
|
1292
|
+
}
|
|
1293
|
+
/**
|
|
1294
|
+
* @param {number} arg0
|
|
1295
|
+
*/
|
|
1296
|
+
set error(arg0) {
|
|
1297
|
+
wasm.__wbg_set_wasmtagobserveresult_error(this.ptr, arg0);
|
|
1298
|
+
}
|
|
1299
|
+
/**
|
|
1300
|
+
*/
|
|
1301
|
+
get tag_observe_pointer() {
|
|
1302
|
+
var ret = wasm.__wbg_get_wasmtagobserveresult_tag_observe_pointer(this.ptr);
|
|
1303
|
+
return ret;
|
|
1304
|
+
}
|
|
1305
|
+
/**
|
|
1306
|
+
* @param {number} arg0
|
|
1307
|
+
*/
|
|
1308
|
+
set tag_observe_pointer(arg0) {
|
|
1309
|
+
wasm.__wbg_set_wasmtagobserveresult_tag_observe_pointer(this.ptr, arg0);
|
|
1310
|
+
}
|
|
1311
|
+
}
|
|
1312
|
+
|
|
1313
|
+
async function load(module, imports) {
|
|
1314
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
1315
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
1316
|
+
try {
|
|
1317
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
1318
|
+
|
|
1319
|
+
} catch (e) {
|
|
1320
|
+
if (module.headers.get('Content-Type') != 'application/wasm') {
|
|
1321
|
+
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);
|
|
1322
|
+
|
|
1323
|
+
} else {
|
|
1324
|
+
throw e;
|
|
1325
|
+
}
|
|
1326
|
+
}
|
|
1327
|
+
}
|
|
1328
|
+
|
|
1329
|
+
const bytes = await module.arrayBuffer();
|
|
1330
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
1331
|
+
|
|
1332
|
+
} else {
|
|
1333
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
1334
|
+
|
|
1335
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
1336
|
+
return { instance, module };
|
|
1337
|
+
|
|
1338
|
+
} else {
|
|
1339
|
+
return instance;
|
|
1340
|
+
}
|
|
1341
|
+
}
|
|
1342
|
+
}
|
|
1343
|
+
|
|
1344
|
+
async function init(input) {
|
|
1345
|
+
if (typeof input === 'undefined') {
|
|
1346
|
+
input = new URL('hakuban_bg.wasm', import.meta.url);
|
|
1347
|
+
}
|
|
1348
|
+
const imports = {};
|
|
1349
|
+
imports.wbg = {};
|
|
1350
|
+
imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
|
|
1351
|
+
takeObject(arg0);
|
|
1352
|
+
};
|
|
1353
|
+
imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
|
|
1354
|
+
var ret = getStringFromWasm0(arg0, arg1);
|
|
1355
|
+
return addHeapObject(ret);
|
|
1356
|
+
};
|
|
1357
|
+
imports.wbg.__wbindgen_cb_drop = function(arg0) {
|
|
1358
|
+
const obj = takeObject(arg0).original;
|
|
1359
|
+
if (obj.cnt-- == 1) {
|
|
1360
|
+
obj.a = 0;
|
|
1361
|
+
return true;
|
|
1362
|
+
}
|
|
1363
|
+
var ret = false;
|
|
1364
|
+
return ret;
|
|
1365
|
+
};
|
|
1366
|
+
imports.wbg.__wbg_debug_6e114a5b27d7915d = function(arg0) {
|
|
1367
|
+
console.debug(getObject(arg0));
|
|
1368
|
+
};
|
|
1369
|
+
imports.wbg.__wbg_error_ca520cb687b085a1 = function(arg0) {
|
|
1370
|
+
console.error(getObject(arg0));
|
|
1371
|
+
};
|
|
1372
|
+
imports.wbg.__wbg_info_32ab782ec7072fac = function(arg0) {
|
|
1373
|
+
console.info(getObject(arg0));
|
|
1374
|
+
};
|
|
1375
|
+
imports.wbg.__wbg_log_fbd13631356d44e4 = function(arg0) {
|
|
1376
|
+
console.log(getObject(arg0));
|
|
1377
|
+
};
|
|
1378
|
+
imports.wbg.__wbg_warn_97f10a6b0dbb8c5c = function(arg0) {
|
|
1379
|
+
console.warn(getObject(arg0));
|
|
1380
|
+
};
|
|
1381
|
+
imports.wbg.__wbg_now_5fa0ca001e042f8a = function(arg0) {
|
|
1382
|
+
var ret = getObject(arg0).now();
|
|
1383
|
+
return ret;
|
|
1384
|
+
};
|
|
1385
|
+
imports.wbg.__wbg_newnoargs_f579424187aa1717 = function(arg0, arg1) {
|
|
1386
|
+
var ret = new Function(getStringFromWasm0(arg0, arg1));
|
|
1387
|
+
return addHeapObject(ret);
|
|
1388
|
+
};
|
|
1389
|
+
imports.wbg.__wbg_get_8bbb82393651dd9c = function() { return handleError(function (arg0, arg1) {
|
|
1390
|
+
var ret = Reflect.get(getObject(arg0), getObject(arg1));
|
|
1391
|
+
return addHeapObject(ret);
|
|
1392
|
+
}, arguments) };
|
|
1393
|
+
imports.wbg.__wbg_call_89558c3e96703ca1 = function() { return handleError(function (arg0, arg1) {
|
|
1394
|
+
var ret = getObject(arg0).call(getObject(arg1));
|
|
1395
|
+
return addHeapObject(ret);
|
|
1396
|
+
}, arguments) };
|
|
1397
|
+
imports.wbg.__wbg_call_94697a95cb7e239c = function() { return handleError(function (arg0, arg1, arg2) {
|
|
1398
|
+
var ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
|
|
1399
|
+
return addHeapObject(ret);
|
|
1400
|
+
}, arguments) };
|
|
1401
|
+
imports.wbg.__wbg_new_4beacc9c71572250 = function(arg0, arg1) {
|
|
1402
|
+
try {
|
|
1403
|
+
var state0 = {a: arg0, b: arg1};
|
|
1404
|
+
var cb0 = (arg0, arg1) => {
|
|
1405
|
+
const a = state0.a;
|
|
1406
|
+
state0.a = 0;
|
|
1407
|
+
try {
|
|
1408
|
+
return __wbg_adapter_120(a, state0.b, arg0, arg1);
|
|
1409
|
+
} finally {
|
|
1410
|
+
state0.a = a;
|
|
1411
|
+
}
|
|
1412
|
+
};
|
|
1413
|
+
var ret = new Promise(cb0);
|
|
1414
|
+
return addHeapObject(ret);
|
|
1415
|
+
} finally {
|
|
1416
|
+
state0.a = state0.b = 0;
|
|
1417
|
+
}
|
|
1418
|
+
};
|
|
1419
|
+
imports.wbg.__wbg_resolve_4f8f547f26b30b27 = function(arg0) {
|
|
1420
|
+
var ret = Promise.resolve(getObject(arg0));
|
|
1421
|
+
return addHeapObject(ret);
|
|
1422
|
+
};
|
|
1423
|
+
imports.wbg.__wbg_then_a6860c82b90816ca = function(arg0, arg1) {
|
|
1424
|
+
var ret = getObject(arg0).then(getObject(arg1));
|
|
1425
|
+
return addHeapObject(ret);
|
|
1426
|
+
};
|
|
1427
|
+
imports.wbg.__wbg_then_58a04e42527f52c6 = function(arg0, arg1, arg2) {
|
|
1428
|
+
var ret = getObject(arg0).then(getObject(arg1), getObject(arg2));
|
|
1429
|
+
return addHeapObject(ret);
|
|
1430
|
+
};
|
|
1431
|
+
imports.wbg.__wbg_self_e23d74ae45fb17d1 = function() { return handleError(function () {
|
|
1432
|
+
var ret = self.self;
|
|
1433
|
+
return addHeapObject(ret);
|
|
1434
|
+
}, arguments) };
|
|
1435
|
+
imports.wbg.__wbg_window_b4be7f48b24ac56e = function() { return handleError(function () {
|
|
1436
|
+
var ret = window.window;
|
|
1437
|
+
return addHeapObject(ret);
|
|
1438
|
+
}, arguments) };
|
|
1439
|
+
imports.wbg.__wbg_globalThis_d61b1f48a57191ae = function() { return handleError(function () {
|
|
1440
|
+
var ret = globalThis.globalThis;
|
|
1441
|
+
return addHeapObject(ret);
|
|
1442
|
+
}, arguments) };
|
|
1443
|
+
imports.wbg.__wbg_global_e7669da72fd7f239 = function() { return handleError(function () {
|
|
1444
|
+
var ret = global.global;
|
|
1445
|
+
return addHeapObject(ret);
|
|
1446
|
+
}, arguments) };
|
|
1447
|
+
imports.wbg.__wbindgen_is_undefined = function(arg0) {
|
|
1448
|
+
var ret = getObject(arg0) === undefined;
|
|
1449
|
+
return ret;
|
|
1450
|
+
};
|
|
1451
|
+
imports.wbg.__wbindgen_object_clone_ref = function(arg0) {
|
|
1452
|
+
var ret = getObject(arg0);
|
|
1453
|
+
return addHeapObject(ret);
|
|
1454
|
+
};
|
|
1455
|
+
imports.wbg.__wbg_new_693216e109162396 = function() {
|
|
1456
|
+
var ret = new Error();
|
|
1457
|
+
return addHeapObject(ret);
|
|
1458
|
+
};
|
|
1459
|
+
imports.wbg.__wbg_stack_0ddaca5d1abfb52f = function(arg0, arg1) {
|
|
1460
|
+
var ret = getObject(arg1).stack;
|
|
1461
|
+
var ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1462
|
+
var len0 = WASM_VECTOR_LEN;
|
|
1463
|
+
getInt32Memory0()[arg0 / 4 + 1] = len0;
|
|
1464
|
+
getInt32Memory0()[arg0 / 4 + 0] = ptr0;
|
|
1465
|
+
};
|
|
1466
|
+
imports.wbg.__wbg_error_09919627ac0992f5 = function(arg0, arg1) {
|
|
1467
|
+
try {
|
|
1468
|
+
console.error(getStringFromWasm0(arg0, arg1));
|
|
1469
|
+
} finally {
|
|
1470
|
+
wasm.__wbindgen_free(arg0, arg1);
|
|
1471
|
+
}
|
|
1472
|
+
};
|
|
1473
|
+
imports.wbg.__wbindgen_debug_string = function(arg0, arg1) {
|
|
1474
|
+
var ret = debugString(getObject(arg1));
|
|
1475
|
+
var ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1476
|
+
var len0 = WASM_VECTOR_LEN;
|
|
1477
|
+
getInt32Memory0()[arg0 / 4 + 1] = len0;
|
|
1478
|
+
getInt32Memory0()[arg0 / 4 + 0] = ptr0;
|
|
1479
|
+
};
|
|
1480
|
+
imports.wbg.__wbindgen_throw = function(arg0, arg1) {
|
|
1481
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
1482
|
+
};
|
|
1483
|
+
imports.wbg.__wbindgen_closure_wrapper2024 = function(arg0, arg1, arg2) {
|
|
1484
|
+
var ret = makeMutClosure(arg0, arg1, 490, __wbg_adapter_16);
|
|
1485
|
+
return addHeapObject(ret);
|
|
1486
|
+
};
|
|
1487
|
+
|
|
1488
|
+
if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) {
|
|
1489
|
+
input = fetch(input);
|
|
1490
|
+
}
|
|
1491
|
+
|
|
1492
|
+
|
|
1493
|
+
|
|
1494
|
+
const { instance, module } = await load(await input, imports);
|
|
1495
|
+
|
|
1496
|
+
wasm = instance.exports;
|
|
1497
|
+
init.__wbindgen_wasm_module = module;
|
|
1498
|
+
|
|
1499
|
+
return wasm;
|
|
1500
|
+
}
|
|
1501
|
+
|
|
1502
|
+
var Queue;
|
|
1503
|
+
|
|
1504
|
+
Queue = class Queue {
|
|
1505
|
+
constructor() {
|
|
1506
|
+
this.queue = [];
|
|
1507
|
+
this.wake = null;
|
|
1508
|
+
}
|
|
1509
|
+
|
|
1510
|
+
push(value) {
|
|
1511
|
+
this.queue.push(value);
|
|
1512
|
+
if (this.wake != null) {
|
|
1513
|
+
this.wake();
|
|
1514
|
+
return this.wake = null;
|
|
1515
|
+
}
|
|
1516
|
+
}
|
|
1517
|
+
|
|
1518
|
+
async shift() {
|
|
1519
|
+
var value;
|
|
1520
|
+
while (true) {
|
|
1521
|
+
value = this.queue.shift();
|
|
1522
|
+
if (value != null) {
|
|
1523
|
+
return value;
|
|
1524
|
+
} else {
|
|
1525
|
+
if (this.wake != null) {
|
|
1526
|
+
throw "2 concurrent shifts on a single queue";
|
|
1527
|
+
}
|
|
1528
|
+
await new Promise((wake) => {
|
|
1529
|
+
this.wake = wake;
|
|
1530
|
+
return null;
|
|
1531
|
+
});
|
|
1532
|
+
}
|
|
1533
|
+
}
|
|
1534
|
+
}
|
|
1535
|
+
|
|
1536
|
+
clear() {
|
|
1537
|
+
return this.queue = [];
|
|
1538
|
+
}
|
|
1539
|
+
|
|
1540
|
+
};
|
|
1541
|
+
|
|
1542
|
+
var ObjectManagerBuilder = class ObjectManagerBuilder {
|
|
1543
|
+
constructor(contract, managed_object_class) {
|
|
1544
|
+
this.contract = contract;
|
|
1545
|
+
this.managed_object_class = managed_object_class;
|
|
1546
|
+
this._on_exception_policy = "retry";
|
|
1547
|
+
this._retry_backoff = [0.01, 0.1, 1.0, 10.0];
|
|
1548
|
+
this._terminate_on_deactivation = false;
|
|
1549
|
+
}
|
|
1550
|
+
|
|
1551
|
+
on_exception(policy) {
|
|
1552
|
+
this._on_exception_policy = policy;
|
|
1553
|
+
return this;
|
|
1554
|
+
}
|
|
1555
|
+
|
|
1556
|
+
//terminate_on_deactivation: ()->
|
|
1557
|
+
// @terminate_on_deactivation = true
|
|
1558
|
+
// @
|
|
1559
|
+
retry_backoff(times) {
|
|
1560
|
+
this._retry_backoff = times;
|
|
1561
|
+
return this;
|
|
1562
|
+
}
|
|
1563
|
+
|
|
1564
|
+
with_async(block) {
|
|
1565
|
+
return new ObjectManager(this.contract, this.managed_object_class, block, this._retry_backoff, this._terminate_on_deactivation, this._on_exception_policy);
|
|
1566
|
+
}
|
|
1567
|
+
|
|
1568
|
+
};
|
|
1569
|
+
|
|
1570
|
+
var ObjectManager = class ObjectManager {
|
|
1571
|
+
constructor(contract, object_class, block, retry_backoff, terminate_on_deactivation, on_exception_policy) {
|
|
1572
|
+
var event_loop_stop_requested;
|
|
1573
|
+
this.objects = this.objects.bind(this);
|
|
1574
|
+
this.object = this.object.bind(this);
|
|
1575
|
+
this.drop = this.drop.bind(this);
|
|
1576
|
+
this.contract = contract;
|
|
1577
|
+
this._existing_objects = {};
|
|
1578
|
+
this._active_objects = {};
|
|
1579
|
+
this.event_queue = new Queue();
|
|
1580
|
+
//TODO: make one loop out of following two
|
|
1581
|
+
event_loop_stop_requested = new Promise((event_loop_stop) => {
|
|
1582
|
+
this.event_loop_stop = event_loop_stop;
|
|
1583
|
+
return null;
|
|
1584
|
+
});
|
|
1585
|
+
this.event_loop_stopped = new Promise(async(resolve, reject) => {
|
|
1586
|
+
var event, events;
|
|
1587
|
+
events = this.contract.events();
|
|
1588
|
+
while (event = (await Promise.race([events.next(), event_loop_stop_requested]))) {
|
|
1589
|
+
if (typeof event === "undefined" || event === null) {
|
|
1590
|
+
break;
|
|
1591
|
+
}
|
|
1592
|
+
this.event_queue.push(event);
|
|
1593
|
+
}
|
|
1594
|
+
events.drop();
|
|
1595
|
+
return resolve();
|
|
1596
|
+
});
|
|
1597
|
+
this.async_loop_stopped = new Promise(async(resolve, reject) => {
|
|
1598
|
+
var base, base1, descriptor_for_lambda, error, event, heal_multiplier, i, interval_since_last_exception, key, len, name, name1, object, ref, ref1;
|
|
1599
|
+
while ((event = (await this.event_queue.shift())) != null) {
|
|
1600
|
+
switch (event.action) {
|
|
1601
|
+
case "Insert":
|
|
1602
|
+
case "Change":
|
|
1603
|
+
case "Remove":
|
|
1604
|
+
case "Stopped":
|
|
1605
|
+
case "Timer":
|
|
1606
|
+
object = (base = this._existing_objects)[name = event.descriptor.hash()] || (base[name] = new object_class(this.contract, event.descriptor));
|
|
1607
|
+
if (!object.running && (object.block_result != null)) {
|
|
1608
|
+
error = (await object.block_result);
|
|
1609
|
+
object.block_result = null;
|
|
1610
|
+
if (object.last_exception_at != null) {
|
|
1611
|
+
interval_since_last_exception = Date.now() - object.last_exception_at;
|
|
1612
|
+
heal_multiplier = 10;
|
|
1613
|
+
object.current_delay_index -= Math.floor(interval_since_last_exception / (retry_backoff[retry_backoff.length - 1] * 1000.0 * heal_multiplier));
|
|
1614
|
+
if (object.current_delay_index < 0) {
|
|
1615
|
+
object.current_delay_index = 0;
|
|
1616
|
+
}
|
|
1617
|
+
}
|
|
1618
|
+
if (error != null) {
|
|
1619
|
+
switch (on_exception_policy) {
|
|
1620
|
+
case "throw":
|
|
1621
|
+
case "raise":
|
|
1622
|
+
throw error.exception;
|
|
1623
|
+
case "retry":
|
|
1624
|
+
object.last_exception_at = Date.now();
|
|
1625
|
+
object.earliest_next_run = Date.now() + retry_backoff[object.current_delay_index] * 1000.0;
|
|
1626
|
+
//wrapped to avoid weird capture effects of coffee
|
|
1627
|
+
(function(lambda_sleep_time, lambda_descriptor, lambda_event_queue) {
|
|
1628
|
+
return setTimeout((() => {
|
|
1629
|
+
return lambda_event_queue.push({
|
|
1630
|
+
action: "Timer",
|
|
1631
|
+
descriptor: lambda_descriptor
|
|
1632
|
+
});
|
|
1633
|
+
}), lambda_sleep_time);
|
|
1634
|
+
})(object.earliest_next_run - Date.now(), event.descriptor, this.event_queue);
|
|
1635
|
+
if (object.current_delay_index < retry_backoff.length - 1) {
|
|
1636
|
+
object.current_delay_index += 1;
|
|
1637
|
+
}
|
|
1638
|
+
}
|
|
1639
|
+
}
|
|
1640
|
+
}
|
|
1641
|
+
//when "ignore_failing_descriptor"
|
|
1642
|
+
//when "drop_contract"
|
|
1643
|
+
if (object.check_active()) {
|
|
1644
|
+
if ((block != null) && !object.running && ((object.earliest_next_run == null) || Date.now() >= object.earliest_next_run)) {
|
|
1645
|
+
descriptor_for_lambda = event.descriptor;
|
|
1646
|
+
object.running = true;
|
|
1647
|
+
//wrapped to avoid weird capture effects of coffee
|
|
1648
|
+
object.block_result = (function(descriptor, object, block, event_queue) {
|
|
1649
|
+
return new Promise(async(resolve, reject) => {
|
|
1650
|
+
try {
|
|
1651
|
+
await object.run(block);
|
|
1652
|
+
return resolve(void 0);
|
|
1653
|
+
} catch (error1) {
|
|
1654
|
+
error = error1;
|
|
1655
|
+
console.error("Exception in hakuban manager lambda:", error);
|
|
1656
|
+
return resolve(error);
|
|
1657
|
+
} finally {
|
|
1658
|
+
object.running = false;
|
|
1659
|
+
event_queue.push({
|
|
1660
|
+
action: "Stopped",
|
|
1661
|
+
descriptor: descriptor_for_lambda
|
|
1662
|
+
});
|
|
1663
|
+
}
|
|
1664
|
+
});
|
|
1665
|
+
})(event.descriptor, object, block, this.event_queue);
|
|
1666
|
+
}
|
|
1667
|
+
(base1 = this._active_objects)[name1 = event.descriptor.hash()] || (base1[name1] = object);
|
|
1668
|
+
object.change();
|
|
1669
|
+
} else {
|
|
1670
|
+
delete this._active_objects[event.descriptor.hash()];
|
|
1671
|
+
if (object.running) {
|
|
1672
|
+
object.stop();
|
|
1673
|
+
} else {
|
|
1674
|
+
delete this._existing_objects[event.descriptor.hash()];
|
|
1675
|
+
}
|
|
1676
|
+
}
|
|
1677
|
+
break;
|
|
1678
|
+
case "Drop":
|
|
1679
|
+
this.event_loop_stop();
|
|
1680
|
+
await this.event_loop_stopped;
|
|
1681
|
+
ref = {...this._existing_objects};
|
|
1682
|
+
for (key in ref) {
|
|
1683
|
+
object = ref[key];
|
|
1684
|
+
if (object.running) {
|
|
1685
|
+
object.stop();
|
|
1686
|
+
} else {
|
|
1687
|
+
delete this._existing_objects[key];
|
|
1688
|
+
}
|
|
1689
|
+
}
|
|
1690
|
+
while (Object.keys(this._existing_objects).length > 0) {
|
|
1691
|
+
event = (await this.event_queue.shift());
|
|
1692
|
+
if (event.action === "Stopped") {
|
|
1693
|
+
delete this._existing_objects[event.descriptor.hash()];
|
|
1694
|
+
}
|
|
1695
|
+
}
|
|
1696
|
+
this.event_queue.clear();
|
|
1697
|
+
ref1 = Object.keys(this._active_objects);
|
|
1698
|
+
for (i = 0, len = ref1.length; i < len; i++) {
|
|
1699
|
+
key = ref1[i];
|
|
1700
|
+
delete this._active_objects[key];
|
|
1701
|
+
}
|
|
1702
|
+
this.contract.drop();
|
|
1703
|
+
this.contract = null;
|
|
1704
|
+
this.event_queue = null;
|
|
1705
|
+
resolve();
|
|
1706
|
+
return;
|
|
1707
|
+
default:
|
|
1708
|
+
throw "Unknown action: " + event.action;
|
|
1709
|
+
}
|
|
1710
|
+
}
|
|
1711
|
+
return reject("Queue died unexpectedly");
|
|
1712
|
+
});
|
|
1713
|
+
}
|
|
1714
|
+
|
|
1715
|
+
objects() {
|
|
1716
|
+
return Object.values(this._active_objects);
|
|
1717
|
+
}
|
|
1718
|
+
|
|
1719
|
+
object() {
|
|
1720
|
+
return Object.values(this._active_objects)[0];
|
|
1721
|
+
}
|
|
1722
|
+
|
|
1723
|
+
async drop() {
|
|
1724
|
+
if (this.contract) {
|
|
1725
|
+
this.event_queue.push({
|
|
1726
|
+
action: 'Drop'
|
|
1727
|
+
});
|
|
1728
|
+
return (await this.async_loop_stopped);
|
|
1729
|
+
}
|
|
1730
|
+
}
|
|
1731
|
+
|
|
1732
|
+
};
|
|
1733
|
+
|
|
1734
|
+
var ManagedObject = class ManagedObject {
|
|
1735
|
+
constructor(contract, descriptor1) {
|
|
1736
|
+
this.run = this.run.bind(this);
|
|
1737
|
+
this.next_event = this.next_event.bind(this);
|
|
1738
|
+
this.next_change = this.next_change.bind(this);
|
|
1739
|
+
this.change = this.change.bind(this);
|
|
1740
|
+
this.stop = this.stop.bind(this);
|
|
1741
|
+
this.contract = contract;
|
|
1742
|
+
this.descriptor = descriptor1;
|
|
1743
|
+
this._changes = new Queue();
|
|
1744
|
+
this.current_delay_index = 0;
|
|
1745
|
+
}
|
|
1746
|
+
|
|
1747
|
+
async run(handler) {
|
|
1748
|
+
return (await handler(this));
|
|
1749
|
+
}
|
|
1750
|
+
|
|
1751
|
+
next_event() {
|
|
1752
|
+
return this.next_change();
|
|
1753
|
+
}
|
|
1754
|
+
|
|
1755
|
+
async next_change() {
|
|
1756
|
+
while (true) {
|
|
1757
|
+
switch ((await this._changes.shift())) {
|
|
1758
|
+
case "change":
|
|
1759
|
+
return true;
|
|
1760
|
+
case "stop":
|
|
1761
|
+
return false;
|
|
1762
|
+
}
|
|
1763
|
+
}
|
|
1764
|
+
}
|
|
1765
|
+
|
|
1766
|
+
change() {
|
|
1767
|
+
return this._changes.push("change");
|
|
1768
|
+
}
|
|
1769
|
+
|
|
1770
|
+
stop() {
|
|
1771
|
+
return this._changes.push("stop");
|
|
1772
|
+
}
|
|
1773
|
+
|
|
1774
|
+
};
|
|
1775
|
+
|
|
1776
|
+
var LocalNode_finalization_registry, ObjectBuilder, ObjectDescriptorEvents, ObjectDescriptorEvents_finalization_registry, ObjectExpose, ObjectExpose_finalization_registry, ObjectObserve, ObjectObserve_finalization_registry, TagBuilder, TagExpose, TagExpose_finalization_registry, TagObserve, TagObserve_finalization_registry, WebsocketConnector_finalization_registry, logger_initialized, raise_if_error,
|
|
1777
|
+
boundMethodCheck = function(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new Error('Bound instance method accessed before binding'); } };
|
|
1778
|
+
|
|
1779
|
+
logger_initialized = false;
|
|
1780
|
+
|
|
1781
|
+
var initialize_wasm = async function(wasm) {
|
|
1782
|
+
return (await init(wasm));
|
|
1783
|
+
};
|
|
1784
|
+
|
|
1785
|
+
var logger_initialize = async function(log_level, skip_if_already_initialized = false) {
|
|
1786
|
+
var error;
|
|
1787
|
+
if (logger_initialized && skip_if_already_initialized) {
|
|
1788
|
+
return true;
|
|
1789
|
+
}
|
|
1790
|
+
if (0 === (error = (await hakuban_logger_initialize(log_level)))) {
|
|
1791
|
+
return logger_initialized = true;
|
|
1792
|
+
} else {
|
|
1793
|
+
console.error("Failed to initialize logger, error " + error);
|
|
1794
|
+
return false;
|
|
1795
|
+
}
|
|
1796
|
+
};
|
|
1797
|
+
|
|
1798
|
+
raise_if_error = function(error_code) {
|
|
1799
|
+
if (error_code !== 0) {
|
|
1800
|
+
throw "Hakuban error: " + error_code;
|
|
1801
|
+
}
|
|
1802
|
+
};
|
|
1803
|
+
|
|
1804
|
+
var JSON_serialize = function(data_type, cooked) {
|
|
1805
|
+
return {
|
|
1806
|
+
data_type: ["JSON"].concat(data_type),
|
|
1807
|
+
data: new TextEncoder().encode(JSON.stringify(cooked))
|
|
1808
|
+
};
|
|
1809
|
+
};
|
|
1810
|
+
|
|
1811
|
+
var JSON_deserialize = function(data_type, raw) {
|
|
1812
|
+
if (data_type.length === 0 || data_type[0] !== "JSON") {
|
|
1813
|
+
throw "Expected JSON data_type, got: " + data_type;
|
|
1814
|
+
}
|
|
1815
|
+
return {
|
|
1816
|
+
data_type: data_type.slice(1),
|
|
1817
|
+
data: JSON.parse(new TextDecoder().decode(raw))
|
|
1818
|
+
};
|
|
1819
|
+
};
|
|
1820
|
+
|
|
1821
|
+
var ObjectDescriptor = class ObjectDescriptor {
|
|
1822
|
+
constructor(tags, json1) {
|
|
1823
|
+
var tag;
|
|
1824
|
+
this.json = json1;
|
|
1825
|
+
this.tags = (function() {
|
|
1826
|
+
var i, len, results;
|
|
1827
|
+
results = [];
|
|
1828
|
+
for (i = 0, len = tags.length; i < len; i++) {
|
|
1829
|
+
tag = tags[i];
|
|
1830
|
+
results.push(tag instanceof TagDescriptor ? tag : new TagDescriptor(tag));
|
|
1831
|
+
}
|
|
1832
|
+
return results;
|
|
1833
|
+
})();
|
|
1834
|
+
}
|
|
1835
|
+
|
|
1836
|
+
as_json() {
|
|
1837
|
+
return JSON.stringify({
|
|
1838
|
+
tags: this.tags.map(function(tag) {
|
|
1839
|
+
return tag.json;
|
|
1840
|
+
}),
|
|
1841
|
+
json: this.json
|
|
1842
|
+
});
|
|
1843
|
+
}
|
|
1844
|
+
|
|
1845
|
+
hash() {
|
|
1846
|
+
var ret;
|
|
1847
|
+
if (this._hash == null) {
|
|
1848
|
+
this._hash = this.tags.map(function(tag) {
|
|
1849
|
+
return tag.hash().toString();
|
|
1850
|
+
}).sort().join(",") + "|";
|
|
1851
|
+
ret = hakuban_json_hash(JSON.stringify(this.json));
|
|
1852
|
+
raise_if_error(ret.error);
|
|
1853
|
+
this._hash += ret.hash.toString();
|
|
1854
|
+
}
|
|
1855
|
+
return this._hash;
|
|
1856
|
+
}
|
|
1857
|
+
|
|
1858
|
+
};
|
|
1859
|
+
|
|
1860
|
+
var TagDescriptor = class TagDescriptor {
|
|
1861
|
+
constructor(json1) {
|
|
1862
|
+
this.json = json1;
|
|
1863
|
+
}
|
|
1864
|
+
|
|
1865
|
+
as_json() {
|
|
1866
|
+
return JSON.stringify(this.json);
|
|
1867
|
+
}
|
|
1868
|
+
|
|
1869
|
+
hash() {
|
|
1870
|
+
var ret;
|
|
1871
|
+
if (this._hash == null) {
|
|
1872
|
+
ret = hakuban_json_hash(JSON.stringify(this.json));
|
|
1873
|
+
raise_if_error(ret.error);
|
|
1874
|
+
this._hash = ret.hash;
|
|
1875
|
+
}
|
|
1876
|
+
return this._hash;
|
|
1877
|
+
}
|
|
1878
|
+
|
|
1879
|
+
};
|
|
1880
|
+
|
|
1881
|
+
LocalNode_finalization_registry = new FinalizationRegistry((pointer) => {
|
|
1882
|
+
return hakuban_local_node_drop(pointer);
|
|
1883
|
+
});
|
|
1884
|
+
|
|
1885
|
+
var LocalNode = class LocalNode {
|
|
1886
|
+
constructor(name = "wasm") {
|
|
1887
|
+
var result;
|
|
1888
|
+
this.name = name;
|
|
1889
|
+
logger_initialize("warn", true);
|
|
1890
|
+
result = hakuban_local_node_new(this.name);
|
|
1891
|
+
raise_if_error(result.error);
|
|
1892
|
+
this.pointer = result.local_node_pointer;
|
|
1893
|
+
LocalNode_finalization_registry.register(this, this.pointer, this);
|
|
1894
|
+
this.with_default_serializer(JSON_serialize);
|
|
1895
|
+
this.with_default_deserializer(JSON_deserialize);
|
|
1896
|
+
}
|
|
1897
|
+
|
|
1898
|
+
destroy() {
|
|
1899
|
+
hakuban_local_node_drop(this.pointer);
|
|
1900
|
+
return LocalNode_finalization_registry.unregister(this);
|
|
1901
|
+
}
|
|
1902
|
+
|
|
1903
|
+
object(tags, json) {
|
|
1904
|
+
return new ObjectBuilder(this, this.default_serializer, this.default_deserializer, tags, json);
|
|
1905
|
+
}
|
|
1906
|
+
|
|
1907
|
+
tag(json) {
|
|
1908
|
+
return new TagBuilder(this, this.default_serializer, this.default_deserializer, json);
|
|
1909
|
+
}
|
|
1910
|
+
|
|
1911
|
+
with_default_serializer(default_serializer) {
|
|
1912
|
+
this.default_serializer = default_serializer;
|
|
1913
|
+
return this;
|
|
1914
|
+
}
|
|
1915
|
+
|
|
1916
|
+
with_default_deserializer(default_deserializer) {
|
|
1917
|
+
this.default_deserializer = default_deserializer;
|
|
1918
|
+
return this;
|
|
1919
|
+
}
|
|
1920
|
+
|
|
1921
|
+
};
|
|
1922
|
+
|
|
1923
|
+
ObjectBuilder = class ObjectBuilder {
|
|
1924
|
+
constructor(local_node, serializer, deserializer, tags1, json1) {
|
|
1925
|
+
this.local_node = local_node;
|
|
1926
|
+
this.serializer = serializer;
|
|
1927
|
+
this.deserializer = deserializer;
|
|
1928
|
+
this.tags = tags1;
|
|
1929
|
+
this.json = json1;
|
|
1930
|
+
}
|
|
1931
|
+
|
|
1932
|
+
observe() {
|
|
1933
|
+
return new ObjectObserve(this.local_node, new ObjectDescriptor(this.tags, this.json), this.deserializer);
|
|
1934
|
+
}
|
|
1935
|
+
|
|
1936
|
+
expose() {
|
|
1937
|
+
return new ObjectExpose(this.local_node, new ObjectDescriptor(this.tags, this.json), this.serializer);
|
|
1938
|
+
}
|
|
1939
|
+
|
|
1940
|
+
with_serializer(serializer) {
|
|
1941
|
+
this.serializer = serializer;
|
|
1942
|
+
return this;
|
|
1943
|
+
}
|
|
1944
|
+
|
|
1945
|
+
with_deserializer(deserializer) {
|
|
1946
|
+
this.deserializer = deserializer;
|
|
1947
|
+
return this;
|
|
1948
|
+
}
|
|
1949
|
+
|
|
1950
|
+
};
|
|
1951
|
+
|
|
1952
|
+
TagBuilder = class TagBuilder {
|
|
1953
|
+
constructor(local_node, serializer, deserializer, json1) {
|
|
1954
|
+
this.local_node = local_node;
|
|
1955
|
+
this.serializer = serializer;
|
|
1956
|
+
this.deserializer = deserializer;
|
|
1957
|
+
this.json = json1;
|
|
1958
|
+
}
|
|
1959
|
+
|
|
1960
|
+
observe() {
|
|
1961
|
+
return new TagObserve(this.local_node, new TagDescriptor(this.json), this.deserializer);
|
|
1962
|
+
}
|
|
1963
|
+
|
|
1964
|
+
expose() {
|
|
1965
|
+
return new TagExpose(this.local_node, new TagDescriptor(this.json), this.serializer);
|
|
1966
|
+
}
|
|
1967
|
+
|
|
1968
|
+
with_serializer(serializer) {
|
|
1969
|
+
this.serializer = serializer;
|
|
1970
|
+
return this;
|
|
1971
|
+
}
|
|
1972
|
+
|
|
1973
|
+
with_deserializer(deserializer) {
|
|
1974
|
+
this.deserializer = deserializer;
|
|
1975
|
+
return this;
|
|
1976
|
+
}
|
|
1977
|
+
|
|
1978
|
+
};
|
|
1979
|
+
|
|
1980
|
+
ObjectDescriptorEvents_finalization_registry = new FinalizationRegistry((pointer) => {
|
|
1981
|
+
return hakuban_object_descriptor_events_drop(pointer);
|
|
1982
|
+
});
|
|
1983
|
+
|
|
1984
|
+
ObjectDescriptorEvents = class ObjectDescriptorEvents {
|
|
1985
|
+
constructor(pointer1) {
|
|
1986
|
+
this.wait = this.wait.bind(this);
|
|
1987
|
+
this.next = this.next.bind(this);
|
|
1988
|
+
this.drop = this.drop.bind(this);
|
|
1989
|
+
this.pointer = pointer1;
|
|
1990
|
+
ObjectDescriptorEvents_finalization_registry.register(this, this.pointer, this);
|
|
1991
|
+
}
|
|
1992
|
+
|
|
1993
|
+
wait() {
|
|
1994
|
+
return next();
|
|
1995
|
+
}
|
|
1996
|
+
|
|
1997
|
+
next() {
|
|
1998
|
+
var cancel_waiting_promise, next_event_promise;
|
|
1999
|
+
this.wait_released = new Promise((wait_release) => {
|
|
2000
|
+
this.wait_release = wait_release;
|
|
2001
|
+
return null;
|
|
2002
|
+
});
|
|
2003
|
+
cancel_waiting_promise = new Promise((resolve) => {
|
|
2004
|
+
return this.cancel_waiting_resolve = resolve;
|
|
2005
|
+
});
|
|
2006
|
+
next_event_promise = hakuban_object_descriptor_events_next(this.pointer, cancel_waiting_promise);
|
|
2007
|
+
next_event_promise.cancel = async(value) => {
|
|
2008
|
+
this.cancel_waiting_resolve.resolve(value);
|
|
2009
|
+
return (await next_event_promise);
|
|
2010
|
+
};
|
|
2011
|
+
return next_event_promise.then((value) => {
|
|
2012
|
+
var parsed;
|
|
2013
|
+
this.wait_release();
|
|
2014
|
+
this.wait_released = null;
|
|
2015
|
+
this.cancel_waiting_resolve = null;
|
|
2016
|
+
parsed = JSON.parse(value);
|
|
2017
|
+
return {
|
|
2018
|
+
action: parsed.action,
|
|
2019
|
+
descriptor: new ObjectDescriptor(parsed.key.tags, parsed.key.json)
|
|
2020
|
+
};
|
|
2021
|
+
});
|
|
2022
|
+
}
|
|
2023
|
+
|
|
2024
|
+
async drop() {
|
|
2025
|
+
if (this.cancel_waiting_resolve != null) {
|
|
2026
|
+
this.cancel_waiting_resolve();
|
|
2027
|
+
await this.wait_released;
|
|
2028
|
+
}
|
|
2029
|
+
ObjectDescriptorEvents_finalization_registry.unregister(this);
|
|
2030
|
+
hakuban_object_descriptor_events_drop(this.pointer);
|
|
2031
|
+
return this.pointer = null;
|
|
2032
|
+
}
|
|
2033
|
+
|
|
2034
|
+
};
|
|
2035
|
+
|
|
2036
|
+
ObjectObserve_finalization_registry = new FinalizationRegistry((pointer) => {
|
|
2037
|
+
return hakuban_object_observe_drop(pointer);
|
|
2038
|
+
});
|
|
2039
|
+
|
|
2040
|
+
ObjectObserve = class ObjectObserve {
|
|
2041
|
+
constructor(local_node, descriptor1, deserializer) {
|
|
2042
|
+
var result;
|
|
2043
|
+
this.drop = this.drop.bind(this);
|
|
2044
|
+
this.object_state = this.object_state.bind(this);
|
|
2045
|
+
this.events = this.events.bind(this);
|
|
2046
|
+
this.manage = this.manage.bind(this);
|
|
2047
|
+
this.local_node = local_node;
|
|
2048
|
+
this.descriptor = descriptor1;
|
|
2049
|
+
this.deserializer = deserializer;
|
|
2050
|
+
result = hakuban_object_observe_new(this.local_node.pointer, this.descriptor.as_json());
|
|
2051
|
+
raise_if_error(result.error);
|
|
2052
|
+
this.pointer = result.object_observe_pointer;
|
|
2053
|
+
ObjectObserve_finalization_registry.register(this, this.pointer, this);
|
|
2054
|
+
this.dropped = false;
|
|
2055
|
+
}
|
|
2056
|
+
|
|
2057
|
+
drop() {
|
|
2058
|
+
this.dropped = true;
|
|
2059
|
+
hakuban_object_observe_drop(this.pointer);
|
|
2060
|
+
ObjectObserve_finalization_registry.unregister(this);
|
|
2061
|
+
return this.pointer = null;
|
|
2062
|
+
}
|
|
2063
|
+
|
|
2064
|
+
object_state() {
|
|
2065
|
+
var data_type, deserialized, raw, state_pointer, synchronized, version;
|
|
2066
|
+
if (this.pointer == null) {
|
|
2067
|
+
return null;
|
|
2068
|
+
}
|
|
2069
|
+
state_pointer = hakuban_object_observe_state_borrow(this.pointer);
|
|
2070
|
+
if (state_pointer === 0) {
|
|
2071
|
+
return null;
|
|
2072
|
+
}
|
|
2073
|
+
synchronized = hakuban_object_observe_state_synchronized(state_pointer);
|
|
2074
|
+
version = JSON.parse(hakuban_object_observe_state_data_version(state_pointer));
|
|
2075
|
+
data_type = JSON.parse(hakuban_object_observe_state_data_type(state_pointer));
|
|
2076
|
+
raw = hakuban_object_observe_state_data(state_pointer);
|
|
2077
|
+
hakuban_object_observe_state_return(state_pointer);
|
|
2078
|
+
deserialized = this.deserializer(data_type, raw);
|
|
2079
|
+
return {
|
|
2080
|
+
version: version,
|
|
2081
|
+
data: deserialized.data,
|
|
2082
|
+
data_type: deserialized.data_type,
|
|
2083
|
+
synchronized: synchronized
|
|
2084
|
+
};
|
|
2085
|
+
}
|
|
2086
|
+
|
|
2087
|
+
events() {
|
|
2088
|
+
return new ObjectDescriptorEvents(hakuban_object_observe_events_get(this.pointer));
|
|
2089
|
+
}
|
|
2090
|
+
|
|
2091
|
+
manage() {
|
|
2092
|
+
var ManagedObject$1;
|
|
2093
|
+
ManagedObject$1 = class ManagedObject$1 extends ManagedObject {
|
|
2094
|
+
state() {
|
|
2095
|
+
var ref;
|
|
2096
|
+
return (ref = this.contract) != null ? ref.object_state() : void 0;
|
|
2097
|
+
}
|
|
2098
|
+
|
|
2099
|
+
data() {
|
|
2100
|
+
var ref, ref1;
|
|
2101
|
+
return (ref = this.contract) != null ? (ref1 = ref.object_state()) != null ? ref1.data : void 0 : void 0;
|
|
2102
|
+
}
|
|
2103
|
+
|
|
2104
|
+
check_active() {
|
|
2105
|
+
return !!this.state();
|
|
2106
|
+
}
|
|
2107
|
+
|
|
2108
|
+
};
|
|
2109
|
+
return new ObjectManagerBuilder(this, ManagedObject$1);
|
|
2110
|
+
}
|
|
2111
|
+
|
|
2112
|
+
};
|
|
2113
|
+
|
|
2114
|
+
ObjectExpose_finalization_registry = new FinalizationRegistry((pointer) => {
|
|
2115
|
+
return hakuban_object_expose_drop(pointer);
|
|
2116
|
+
});
|
|
2117
|
+
|
|
2118
|
+
ObjectExpose = class ObjectExpose {
|
|
2119
|
+
constructor(local_node, descriptor1, serializer) {
|
|
2120
|
+
var result;
|
|
2121
|
+
this.drop = this.drop.bind(this);
|
|
2122
|
+
this.set_object_state = this.set_object_state.bind(this);
|
|
2123
|
+
this.assignment = this.assignment.bind(this);
|
|
2124
|
+
this.assigned = this.assigned.bind(this);
|
|
2125
|
+
this.desynchronize = this.desynchronize.bind(this);
|
|
2126
|
+
this.events = this.events.bind(this);
|
|
2127
|
+
this.manage = this.manage.bind(this);
|
|
2128
|
+
this.local_node = local_node;
|
|
2129
|
+
this.descriptor = descriptor1;
|
|
2130
|
+
this.serializer = serializer;
|
|
2131
|
+
result = hakuban_object_expose_new(this.local_node.pointer, this.descriptor.as_json());
|
|
2132
|
+
raise_if_error(result.error);
|
|
2133
|
+
this.pointer = result.object_expose_pointer;
|
|
2134
|
+
ObjectExpose_finalization_registry.register(this, this.pointer, this);
|
|
2135
|
+
this.dropped = false;
|
|
2136
|
+
}
|
|
2137
|
+
|
|
2138
|
+
drop() {
|
|
2139
|
+
this.dropped = true;
|
|
2140
|
+
hakuban_object_expose_drop(this.pointer);
|
|
2141
|
+
return ObjectExpose_finalization_registry.unregister(this);
|
|
2142
|
+
}
|
|
2143
|
+
|
|
2144
|
+
set_object_state(version, cooked_data, data_type = [], assignment = 0) {
|
|
2145
|
+
var result, serialized;
|
|
2146
|
+
serialized = this.serializer(data_type, cooked_data);
|
|
2147
|
+
if (!(typeof assignment === 'bigint')) {
|
|
2148
|
+
assignment = BigInt(assignment);
|
|
2149
|
+
}
|
|
2150
|
+
result = hakuban_object_expose_set_state(this.pointer, JSON.stringify(version), JSON.stringify(serialized.data_type), serialized.data, assignment);
|
|
2151
|
+
raise_if_error(result.error);
|
|
2152
|
+
return result.changed;
|
|
2153
|
+
}
|
|
2154
|
+
|
|
2155
|
+
assignment() {
|
|
2156
|
+
return hakuban_object_expose_assignment(this.pointer);
|
|
2157
|
+
}
|
|
2158
|
+
|
|
2159
|
+
assigned() {
|
|
2160
|
+
return this.assignment() > 0;
|
|
2161
|
+
}
|
|
2162
|
+
|
|
2163
|
+
desynchronize(assignment) {
|
|
2164
|
+
if (!(typeof assignment === 'bigint')) {
|
|
2165
|
+
assignment = BigInt(assignment);
|
|
2166
|
+
}
|
|
2167
|
+
return hakuban_object_expose_desynchronize(this.pointer, assignment);
|
|
2168
|
+
}
|
|
2169
|
+
|
|
2170
|
+
events() {
|
|
2171
|
+
return new ObjectDescriptorEvents(hakuban_object_expose_events_get(this.pointer));
|
|
2172
|
+
}
|
|
2173
|
+
|
|
2174
|
+
manage() {
|
|
2175
|
+
var ManagedObject$1;
|
|
2176
|
+
ManagedObject$1 = class ManagedObject$1 extends ManagedObject {
|
|
2177
|
+
constructor(contract, descriptor) {
|
|
2178
|
+
super(contract, descriptor);
|
|
2179
|
+
this.run = this.run.bind(this);
|
|
2180
|
+
this.do_change = this.do_change.bind(this);
|
|
2181
|
+
this.assignment = this.assignment.bind(this);
|
|
2182
|
+
this.assigned = this.assigned.bind(this);
|
|
2183
|
+
this.set_state = this.set_state.bind(this);
|
|
2184
|
+
this.set_data = this.set_data.bind(this);
|
|
2185
|
+
this._assignment = contract.assignment();
|
|
2186
|
+
}
|
|
2187
|
+
|
|
2188
|
+
async run(handler) {
|
|
2189
|
+
var ref;
|
|
2190
|
+
boundMethodCheck(this, ManagedObject$1);
|
|
2191
|
+
await super.run(handler);
|
|
2192
|
+
return (ref = this.contract) != null ? ref.desynchronize(this._assignment) : void 0;
|
|
2193
|
+
}
|
|
2194
|
+
|
|
2195
|
+
do_change(change) {
|
|
2196
|
+
var ref;
|
|
2197
|
+
boundMethodCheck(this, ManagedObject$1);
|
|
2198
|
+
this._assignment = (ref = this.contract) != null ? ref.assignment() : void 0;
|
|
2199
|
+
return super.do_change(change);
|
|
2200
|
+
}
|
|
2201
|
+
|
|
2202
|
+
assignment() {
|
|
2203
|
+
var ref;
|
|
2204
|
+
boundMethodCheck(this, ManagedObject$1);
|
|
2205
|
+
return (ref = this.contract) != null ? ref.assignment() : void 0;
|
|
2206
|
+
}
|
|
2207
|
+
|
|
2208
|
+
assigned() {
|
|
2209
|
+
var ref;
|
|
2210
|
+
boundMethodCheck(this, ManagedObject$1);
|
|
2211
|
+
return (ref = this.contract) != null ? ref.assigned() : void 0;
|
|
2212
|
+
}
|
|
2213
|
+
|
|
2214
|
+
set_state(version, cooked_data, data_type = []) {
|
|
2215
|
+
var ref;
|
|
2216
|
+
boundMethodCheck(this, ManagedObject$1);
|
|
2217
|
+
return (ref = this.contract) != null ? ref.set_object_state(version, cooked_data, data_type, this._assignment) : void 0;
|
|
2218
|
+
}
|
|
2219
|
+
|
|
2220
|
+
set_data(data) {
|
|
2221
|
+
var timestamp;
|
|
2222
|
+
boundMethodCheck(this, ManagedObject$1);
|
|
2223
|
+
timestamp = new Date().getTime();
|
|
2224
|
+
return this.set_state([1, Math.floor(timestamp / 1000), timestamp - Math.floor(timestamp / 1000) * 1000, 0], data);
|
|
2225
|
+
}
|
|
2226
|
+
|
|
2227
|
+
check_active() {
|
|
2228
|
+
return this.assigned();
|
|
2229
|
+
}
|
|
2230
|
+
|
|
2231
|
+
};
|
|
2232
|
+
return new ObjectManagerBuilder(this, ManagedObject$1);
|
|
2233
|
+
}
|
|
2234
|
+
|
|
2235
|
+
};
|
|
2236
|
+
|
|
2237
|
+
TagObserve_finalization_registry = new FinalizationRegistry((pointer) => {
|
|
2238
|
+
return hakuban_tag_observe_drop(pointer);
|
|
2239
|
+
});
|
|
2240
|
+
|
|
2241
|
+
TagObserve = class TagObserve {
|
|
2242
|
+
constructor(local_node, descriptor1, deserializer) {
|
|
2243
|
+
var result;
|
|
2244
|
+
this.drop = this.drop.bind(this);
|
|
2245
|
+
this.object_descriptors = this.object_descriptors.bind(this);
|
|
2246
|
+
this.object_state = this.object_state.bind(this);
|
|
2247
|
+
this.local_node = local_node;
|
|
2248
|
+
this.descriptor = descriptor1;
|
|
2249
|
+
this.deserializer = deserializer;
|
|
2250
|
+
result = hakuban_tag_observe_new(this.local_node.pointer, this.descriptor.as_json());
|
|
2251
|
+
raise_if_error(result.error);
|
|
2252
|
+
this.pointer = result.tag_observe_pointer;
|
|
2253
|
+
TagObserve_finalization_registry.register(this, this.pointer, this);
|
|
2254
|
+
this.dropped = false;
|
|
2255
|
+
}
|
|
2256
|
+
|
|
2257
|
+
drop() {
|
|
2258
|
+
this.dropped = true;
|
|
2259
|
+
hakuban_tag_observe_drop(this.pointer);
|
|
2260
|
+
return TagObserve_finalization_registry.unregister(this);
|
|
2261
|
+
}
|
|
2262
|
+
|
|
2263
|
+
object_descriptors() {
|
|
2264
|
+
var descriptor_as_json, i, len, ref, result, results;
|
|
2265
|
+
result = hakuban_tag_observe_object_descriptors(this.pointer);
|
|
2266
|
+
ref = JSON.parse(result);
|
|
2267
|
+
results = [];
|
|
2268
|
+
for (i = 0, len = ref.length; i < len; i++) {
|
|
2269
|
+
descriptor_as_json = ref[i];
|
|
2270
|
+
results.push(new ObjectDescriptor(descriptor_as_json.tags, descriptor_as_json.json));
|
|
2271
|
+
}
|
|
2272
|
+
return results;
|
|
2273
|
+
}
|
|
2274
|
+
|
|
2275
|
+
object_state(object_descriptor) {
|
|
2276
|
+
var data_type, deserialized, raw, result, synchronized, version;
|
|
2277
|
+
result = hakuban_tag_observe_object_state_borrow(this.pointer, object_descriptor.as_json());
|
|
2278
|
+
if (result.error === 4) {
|
|
2279
|
+
return null;
|
|
2280
|
+
}
|
|
2281
|
+
if (result.state_pointer === 0) {
|
|
2282
|
+
return null;
|
|
2283
|
+
}
|
|
2284
|
+
synchronized = hakuban_object_observe_state_synchronized(result.state_pointer);
|
|
2285
|
+
version = JSON.parse(hakuban_object_observe_state_data_version(result.state_pointer));
|
|
2286
|
+
data_type = JSON.parse(hakuban_object_observe_state_data_type(result.state_pointer));
|
|
2287
|
+
raw = hakuban_object_observe_state_data(result.state_pointer);
|
|
2288
|
+
hakuban_object_observe_state_return(result.state_pointer);
|
|
2289
|
+
deserialized = this.deserializer(data_type, raw);
|
|
2290
|
+
return {
|
|
2291
|
+
version: version,
|
|
2292
|
+
data: deserialized.data,
|
|
2293
|
+
data_type: deserialized.data_type,
|
|
2294
|
+
synchronized: synchronized
|
|
2295
|
+
};
|
|
2296
|
+
}
|
|
2297
|
+
|
|
2298
|
+
events() {
|
|
2299
|
+
return new ObjectDescriptorEvents(hakuban_tag_observe_events_get(this.pointer));
|
|
2300
|
+
}
|
|
2301
|
+
|
|
2302
|
+
manage() {
|
|
2303
|
+
var ManagedObject$1;
|
|
2304
|
+
ManagedObject$1 = class ManagedObject$1 extends ManagedObject {
|
|
2305
|
+
state() {
|
|
2306
|
+
var ref;
|
|
2307
|
+
return (ref = this.contract) != null ? ref.object_state(this.descriptor) : void 0;
|
|
2308
|
+
}
|
|
2309
|
+
|
|
2310
|
+
data() {
|
|
2311
|
+
var ref, ref1;
|
|
2312
|
+
return (ref = this.contract) != null ? (ref1 = ref.object_state(this.descriptor)) != null ? ref1.data : void 0 : void 0;
|
|
2313
|
+
}
|
|
2314
|
+
|
|
2315
|
+
check_active() {
|
|
2316
|
+
return !!this.state();
|
|
2317
|
+
}
|
|
2318
|
+
|
|
2319
|
+
};
|
|
2320
|
+
return new ObjectManagerBuilder(this, ManagedObject$1);
|
|
2321
|
+
}
|
|
2322
|
+
|
|
2323
|
+
};
|
|
2324
|
+
|
|
2325
|
+
TagExpose_finalization_registry = new FinalizationRegistry((pointer) => {
|
|
2326
|
+
return hakuban_tag_expose_drop(pointer);
|
|
2327
|
+
});
|
|
2328
|
+
|
|
2329
|
+
TagExpose = class TagExpose {
|
|
2330
|
+
constructor(local_node, descriptor1, serializer) {
|
|
2331
|
+
var result;
|
|
2332
|
+
this.drop = this.drop.bind(this);
|
|
2333
|
+
this.object_descriptors = this.object_descriptors.bind(this);
|
|
2334
|
+
this.set_object_state = this.set_object_state.bind(this);
|
|
2335
|
+
this.assignment = this.assignment.bind(this);
|
|
2336
|
+
this.assigned = this.assigned.bind(this);
|
|
2337
|
+
this.desynchronize = this.desynchronize.bind(this);
|
|
2338
|
+
this.events = this.events.bind(this);
|
|
2339
|
+
this.manage = this.manage.bind(this);
|
|
2340
|
+
this.local_node = local_node;
|
|
2341
|
+
this.descriptor = descriptor1;
|
|
2342
|
+
this.serializer = serializer;
|
|
2343
|
+
result = hakuban_tag_expose_new(this.local_node.pointer, this.descriptor.as_json());
|
|
2344
|
+
raise_if_error(result.error);
|
|
2345
|
+
this.pointer = result.tag_expose_pointer;
|
|
2346
|
+
TagExpose_finalization_registry.register(this, this.pointer, this);
|
|
2347
|
+
this.dropped = false;
|
|
2348
|
+
}
|
|
2349
|
+
|
|
2350
|
+
drop() {
|
|
2351
|
+
this.dropped = true;
|
|
2352
|
+
hakuban_tag_expose_drop(this.pointer);
|
|
2353
|
+
return TagExpose_finalization_registry.unregister(this);
|
|
2354
|
+
}
|
|
2355
|
+
|
|
2356
|
+
object_descriptors() {
|
|
2357
|
+
var descriptor_as_json, i, len, ref, result, results;
|
|
2358
|
+
result = hakuban_tag_expose_object_descriptors(this.pointer);
|
|
2359
|
+
ref = JSON.parse(result);
|
|
2360
|
+
results = [];
|
|
2361
|
+
for (i = 0, len = ref.length; i < len; i++) {
|
|
2362
|
+
descriptor_as_json = ref[i];
|
|
2363
|
+
results.push(new ObjectDescriptor(descriptor_as_json.tags, descriptor_as_json.json));
|
|
2364
|
+
}
|
|
2365
|
+
return results;
|
|
2366
|
+
}
|
|
2367
|
+
|
|
2368
|
+
set_object_state(object_descriptor, version, cooked_data, data_type = [], assignment = 0) {
|
|
2369
|
+
var result, serialized;
|
|
2370
|
+
serialized = this.serializer(data_type, cooked_data);
|
|
2371
|
+
if (!(typeof assignment === 'bigint')) {
|
|
2372
|
+
assignment = BigInt(assignment);
|
|
2373
|
+
}
|
|
2374
|
+
result = hakuban_tag_expose_set_object_state(this.pointer, object_descriptor.as_json(), JSON.stringify(version), JSON.stringify(serialized.data_type), serialized.data, assignment);
|
|
2375
|
+
raise_if_error(result.error);
|
|
2376
|
+
return result.changed;
|
|
2377
|
+
}
|
|
2378
|
+
|
|
2379
|
+
assignment(object_descriptor) {
|
|
2380
|
+
var result;
|
|
2381
|
+
result = hakuban_tag_expose_assignment(this.pointer, object_descriptor.as_json());
|
|
2382
|
+
raise_if_error(result.error);
|
|
2383
|
+
return result.assignment;
|
|
2384
|
+
}
|
|
2385
|
+
|
|
2386
|
+
assigned(object_descriptor) {
|
|
2387
|
+
return this.assignment(object_descriptor) > 0;
|
|
2388
|
+
}
|
|
2389
|
+
|
|
2390
|
+
desynchronize(object_descriptor, assignment) {
|
|
2391
|
+
var error;
|
|
2392
|
+
if (!(typeof assignment === 'bigint')) {
|
|
2393
|
+
assignment = BigInt(assignment);
|
|
2394
|
+
}
|
|
2395
|
+
error = hakuban_tag_expose_desynchronize(this.pointer, object_descriptor.as_json(), assignment);
|
|
2396
|
+
return raise_if_error(error);
|
|
2397
|
+
}
|
|
2398
|
+
|
|
2399
|
+
events() {
|
|
2400
|
+
return new ObjectDescriptorEvents(hakuban_tag_expose_events_get(this.pointer));
|
|
2401
|
+
}
|
|
2402
|
+
|
|
2403
|
+
manage() {
|
|
2404
|
+
var ManagedObject$1;
|
|
2405
|
+
ManagedObject$1 = class ManagedObject$1 extends ManagedObject {
|
|
2406
|
+
constructor(contract, descriptor) {
|
|
2407
|
+
super(contract, descriptor);
|
|
2408
|
+
this.run = this.run.bind(this);
|
|
2409
|
+
this.do_change = this.do_change.bind(this);
|
|
2410
|
+
this.assignment = this.assignment.bind(this);
|
|
2411
|
+
this.assigned = this.assigned.bind(this);
|
|
2412
|
+
this.set_state = this.set_state.bind(this);
|
|
2413
|
+
this.set_data = this.set_data.bind(this);
|
|
2414
|
+
this._assignment = contract.assignment(this.descriptor);
|
|
2415
|
+
}
|
|
2416
|
+
|
|
2417
|
+
async run(handler) {
|
|
2418
|
+
var ref;
|
|
2419
|
+
boundMethodCheck(this, ManagedObject$1);
|
|
2420
|
+
await super.run(handler);
|
|
2421
|
+
return (ref = this.contract) != null ? ref.desynchronize(this.descriptor, this._assignment) : void 0;
|
|
2422
|
+
}
|
|
2423
|
+
|
|
2424
|
+
do_change(change) {
|
|
2425
|
+
var ref;
|
|
2426
|
+
boundMethodCheck(this, ManagedObject$1);
|
|
2427
|
+
this._assignment = (ref = this.contract) != null ? ref.assignment(this.descriptor) : void 0;
|
|
2428
|
+
return super.do_change(change);
|
|
2429
|
+
}
|
|
2430
|
+
|
|
2431
|
+
assignment() {
|
|
2432
|
+
var ref;
|
|
2433
|
+
boundMethodCheck(this, ManagedObject$1);
|
|
2434
|
+
return (ref = this.contract) != null ? ref.assignment(this.descriptor) : void 0;
|
|
2435
|
+
}
|
|
2436
|
+
|
|
2437
|
+
assigned() {
|
|
2438
|
+
var ref;
|
|
2439
|
+
boundMethodCheck(this, ManagedObject$1);
|
|
2440
|
+
return (ref = this.contract) != null ? ref.assigned(this.descriptor) : void 0;
|
|
2441
|
+
}
|
|
2442
|
+
|
|
2443
|
+
set_state(version, cooked_data, data_type = []) {
|
|
2444
|
+
var ref;
|
|
2445
|
+
boundMethodCheck(this, ManagedObject$1);
|
|
2446
|
+
return (ref = this.contract) != null ? ref.set_object_state(this.descriptor, version, cooked_data, data_type, this._assignment) : void 0;
|
|
2447
|
+
}
|
|
2448
|
+
|
|
2449
|
+
set_data(data) {
|
|
2450
|
+
var timestamp;
|
|
2451
|
+
boundMethodCheck(this, ManagedObject$1);
|
|
2452
|
+
timestamp = new Date().getTime();
|
|
2453
|
+
return this.set_state([1, Math.floor(timestamp / 1000), timestamp - Math.floor(timestamp / 1000) * 1000, 0], data);
|
|
2454
|
+
}
|
|
2455
|
+
|
|
2456
|
+
check_active() {
|
|
2457
|
+
return this.assigned();
|
|
2458
|
+
}
|
|
2459
|
+
|
|
2460
|
+
};
|
|
2461
|
+
return new ObjectManagerBuilder(this, ManagedObject$1);
|
|
2462
|
+
}
|
|
2463
|
+
|
|
2464
|
+
};
|
|
2465
|
+
|
|
2466
|
+
WebsocketConnector_finalization_registry = new FinalizationRegistry((pointer) => {
|
|
2467
|
+
return hakuban_remote_node_drop(pointer);
|
|
2468
|
+
});
|
|
2469
|
+
|
|
2470
|
+
//TODO: hide private methods
|
|
2471
|
+
//TODO: handle errors somehow
|
|
2472
|
+
var WebsocketConnector = class WebsocketConnector {
|
|
2473
|
+
constructor(local_node, uri, options = {}) {
|
|
2474
|
+
var result;
|
|
2475
|
+
this.connect = this.connect.bind(this);
|
|
2476
|
+
this.ping = this.ping.bind(this);
|
|
2477
|
+
this.send = this.send.bind(this);
|
|
2478
|
+
this.ack = this.ack.bind(this);
|
|
2479
|
+
this.local_node = local_node;
|
|
2480
|
+
this.uri = uri;
|
|
2481
|
+
this.options = options;
|
|
2482
|
+
this.connected = false;
|
|
2483
|
+
this.socket = void 0;
|
|
2484
|
+
this.error = void 0;
|
|
2485
|
+
this.reconnection_timer = void 0;
|
|
2486
|
+
this.reconnect_on_close = true;
|
|
2487
|
+
this.ack_timer = void 0;
|
|
2488
|
+
result = hakuban_remote_node_new(this.local_node.pointer, true, true, true);
|
|
2489
|
+
raise_if_error(result.error);
|
|
2490
|
+
this.remote_node_pointer = result.remote_node_pointer;
|
|
2491
|
+
this.event_loop_stop = new Promise((resolve) => {
|
|
2492
|
+
return this.event_loop_stop_resolve = resolve;
|
|
2493
|
+
});
|
|
2494
|
+
this.event_loop_promise = this.event_loop();
|
|
2495
|
+
WebsocketConnector_finalization_registry.register(this, this.remote_node_pointer, this);
|
|
2496
|
+
this.connect();
|
|
2497
|
+
}
|
|
2498
|
+
|
|
2499
|
+
async destroy() {
|
|
2500
|
+
this.event_loop_stop_resolve(["stop"]);
|
|
2501
|
+
await this.event_loop_promise;
|
|
2502
|
+
this.reconnect_on_close = false;
|
|
2503
|
+
if (this.keep_alive_interval) {
|
|
2504
|
+
clearInterval(this.keep_alive_interval);
|
|
2505
|
+
}
|
|
2506
|
+
if (this.reconnection_timer != null) {
|
|
2507
|
+
clearTimeout(this.reconnection_timer);
|
|
2508
|
+
this.reconnection_timer = null;
|
|
2509
|
+
}
|
|
2510
|
+
if (this.socket != null) {
|
|
2511
|
+
this.socket.onclose = null;
|
|
2512
|
+
this.socket.onerror = null;
|
|
2513
|
+
this.socket.onmessage = null;
|
|
2514
|
+
this.socket.close();
|
|
2515
|
+
this.socket_onclose();
|
|
2516
|
+
}
|
|
2517
|
+
if (this.ack_timer != null) {
|
|
2518
|
+
clearTimeout(this.ack_timer);
|
|
2519
|
+
this.ack_timer = null;
|
|
2520
|
+
}
|
|
2521
|
+
hakuban_remote_node_drop(this.remote_node_pointer);
|
|
2522
|
+
return WebsocketConnector_finalization_registry.unregister(this);
|
|
2523
|
+
}
|
|
2524
|
+
|
|
2525
|
+
connect() {
|
|
2526
|
+
var error;
|
|
2527
|
+
this.reconnection_timer = void 0;
|
|
2528
|
+
try {
|
|
2529
|
+
this.socket = new WebSocket(this.uri);
|
|
2530
|
+
} catch (error1) {
|
|
2531
|
+
error = error1;
|
|
2532
|
+
this.error = {
|
|
2533
|
+
while: "connecting",
|
|
2534
|
+
error: error
|
|
2535
|
+
};
|
|
2536
|
+
if (this.onstatuschange_proc != null) {
|
|
2537
|
+
this.onstatuschange_proc(this);
|
|
2538
|
+
}
|
|
2539
|
+
return false;
|
|
2540
|
+
}
|
|
2541
|
+
this.socket.binaryType = "arraybuffer";
|
|
2542
|
+
this.socket.onopen = () => {
|
|
2543
|
+
var bytes_to_send;
|
|
2544
|
+
if (this.options.debug) {
|
|
2545
|
+
console.debug('Connected to hakuban remote node');
|
|
2546
|
+
}
|
|
2547
|
+
this.connected = true;
|
|
2548
|
+
this.error = void 0;
|
|
2549
|
+
if (this.onstatuschange_proc != null) {
|
|
2550
|
+
this.onstatuschange_proc(this);
|
|
2551
|
+
}
|
|
2552
|
+
bytes_to_send = hakuban_remote_node_connected(this.remote_node_pointer);
|
|
2553
|
+
return this.send(bytes_to_send);
|
|
2554
|
+
};
|
|
2555
|
+
this.socket.onclose = this.socket_onclose = () => {
|
|
2556
|
+
if (this.options.debug) {
|
|
2557
|
+
console.debug('Disconnected from hakuban remote node');
|
|
2558
|
+
}
|
|
2559
|
+
if (this.keep_alive_interval) {
|
|
2560
|
+
clearInterval(this.keep_alive_interval);
|
|
2561
|
+
}
|
|
2562
|
+
this.connected = false;
|
|
2563
|
+
this.socket = void 0;
|
|
2564
|
+
hakuban_remote_node_disconnected(this.remote_node_pointer);
|
|
2565
|
+
if (this.onstatuschange_proc != null) {
|
|
2566
|
+
this.onstatuschange_proc(this);
|
|
2567
|
+
}
|
|
2568
|
+
if (this.reconnection_timer != null) {
|
|
2569
|
+
clearTimeout(this.reconnection_timer);
|
|
2570
|
+
}
|
|
2571
|
+
this.reconnection_timer = null;
|
|
2572
|
+
if (this.reconnect_on_close) {
|
|
2573
|
+
return this.reconnection_timer = setTimeout(this.connect, 1000);
|
|
2574
|
+
}
|
|
2575
|
+
};
|
|
2576
|
+
this.socket.onerror = (error) => {
|
|
2577
|
+
if (this.options.debug) {
|
|
2578
|
+
console.debug('Hakuban socket error', error);
|
|
2579
|
+
}
|
|
2580
|
+
return this.error = {
|
|
2581
|
+
while: "connected",
|
|
2582
|
+
error: error
|
|
2583
|
+
};
|
|
2584
|
+
};
|
|
2585
|
+
return this.socket.onmessage = (event) => {
|
|
2586
|
+
var bytes_to_send;
|
|
2587
|
+
bytes_to_send = hakuban_remote_node_received_message(this.remote_node_pointer, new Uint8Array(event.data));
|
|
2588
|
+
this.send(bytes_to_send);
|
|
2589
|
+
if (this.ack_timer != null) {
|
|
2590
|
+
clearTimeout(this.ack_timer);
|
|
2591
|
+
}
|
|
2592
|
+
this.ack_timer = setTimeout(this.ack, 1000);
|
|
2593
|
+
return null;
|
|
2594
|
+
};
|
|
2595
|
+
}
|
|
2596
|
+
|
|
2597
|
+
ping() {
|
|
2598
|
+
if (this.socket) {
|
|
2599
|
+
return this.socket.send(new Uint8Array());
|
|
2600
|
+
}
|
|
2601
|
+
}
|
|
2602
|
+
|
|
2603
|
+
send(bytes_to_send) {
|
|
2604
|
+
if (bytes_to_send.length > 0) {
|
|
2605
|
+
this.socket.send(bytes_to_send);
|
|
2606
|
+
if (this.keep_alive_interval) {
|
|
2607
|
+
clearInterval(this.keep_alive_interval);
|
|
2608
|
+
}
|
|
2609
|
+
return this.keep_alive_interval = setInterval(this.ping, 10000);
|
|
2610
|
+
}
|
|
2611
|
+
}
|
|
2612
|
+
|
|
2613
|
+
ack() {
|
|
2614
|
+
var bytes_to_send;
|
|
2615
|
+
if (this.socket != null) {
|
|
2616
|
+
bytes_to_send = hakuban_remote_node_ack(this.remote_node_pointer);
|
|
2617
|
+
if (bytes_to_send.length > 0) {
|
|
2618
|
+
return this.send(bytes_to_send);
|
|
2619
|
+
}
|
|
2620
|
+
}
|
|
2621
|
+
}
|
|
2622
|
+
|
|
2623
|
+
async event_loop() {
|
|
2624
|
+
var cancel_waiting_promise, cancel_waiting_resolve, event, next_local_node_event, promise;
|
|
2625
|
+
next_local_node_event = false;
|
|
2626
|
+
cancel_waiting_resolve = null;
|
|
2627
|
+
cancel_waiting_promise = new Promise(function(resolve) {
|
|
2628
|
+
return cancel_waiting_resolve = resolve;
|
|
2629
|
+
});
|
|
2630
|
+
while (true) {
|
|
2631
|
+
if (!next_local_node_event) {
|
|
2632
|
+
next_local_node_event = hakuban_remote_node_next_local_node_event(this.remote_node_pointer, cancel_waiting_promise).then(function(event) {
|
|
2633
|
+
return ["local_node_event", event];
|
|
2634
|
+
});
|
|
2635
|
+
}
|
|
2636
|
+
[promise, event] = (await Promise.any([this.event_loop_stop, next_local_node_event]));
|
|
2637
|
+
if (promise === "local_node_event") {
|
|
2638
|
+
next_local_node_event = false;
|
|
2639
|
+
setTimeout(((event) => {
|
|
2640
|
+
var bytes_to_send;
|
|
2641
|
+
if (this.connected) {
|
|
2642
|
+
bytes_to_send = hakuban_remote_node_received_local_node_event(this.remote_node_pointer, event);
|
|
2643
|
+
return this.send(bytes_to_send);
|
|
2644
|
+
}
|
|
2645
|
+
}), 0, event);
|
|
2646
|
+
} else {
|
|
2647
|
+
break;
|
|
2648
|
+
}
|
|
2649
|
+
}
|
|
2650
|
+
if (next_local_node_event) {
|
|
2651
|
+
cancel_waiting_resolve(true);
|
|
2652
|
+
return (await next_local_node_event);
|
|
2653
|
+
}
|
|
2654
|
+
}
|
|
2655
|
+
|
|
2656
|
+
onstatuschange(proc) {
|
|
2657
|
+
this.onstatuschange_proc = proc;
|
|
2658
|
+
if (this.onstatuschange_proc != null) {
|
|
2659
|
+
this.onstatuschange_proc();
|
|
2660
|
+
}
|
|
2661
|
+
return this;
|
|
2662
|
+
}
|
|
2663
|
+
|
|
2664
|
+
};
|
|
2665
|
+
|
|
2666
|
+
var initialize = async function(wasm) {
|
|
2667
|
+
return (await initialize_wasm(wasm));
|
|
2668
|
+
};
|
|
2669
|
+
|
|
2670
|
+
export { JSON_deserialize, JSON_serialize, LocalNode, ObjectDescriptor, TagDescriptor, WebsocketConnector, initialize, initialize_wasm, logger_initialize };
|
|
2671
|
+
//# sourceMappingURL=hakuban.js.map
|