hakuban 0.8.0 → 0.8.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/hakuban-with-wasm.js +82 -73
- package/hakuban-with-wasm.js.map +1 -1
- package/hakuban-with-wasm.min.js +1 -1
- package/hakuban-with-wasm.min.js.map +1 -1
- package/hakuban.js +82 -73
- package/hakuban.js.map +1 -1
- package/hakuban.min.js +1 -1
- package/hakuban.min.js.map +1 -1
- package/hakuban_bg.wasm +0 -0
- package/package.json +8 -6
- package/hakuban.wasm +0 -0
package/hakuban.js
CHANGED
|
@@ -101,16 +101,44 @@ function isLikeNone(x) {
|
|
|
101
101
|
return x === undefined || x === null;
|
|
102
102
|
}
|
|
103
103
|
/**
|
|
104
|
-
* @param {string} default_log_level
|
|
105
104
|
* @returns {WasmResult}
|
|
106
105
|
*/
|
|
107
|
-
function
|
|
108
|
-
const
|
|
109
|
-
const len0 = WASM_VECTOR_LEN;
|
|
110
|
-
const ret = wasm.hakuban_logger_initialize(ptr0, len0);
|
|
106
|
+
function hakuban_exchange_new() {
|
|
107
|
+
const ret = wasm.hakuban_exchange_new();
|
|
111
108
|
return WasmResult.__wrap(ret);
|
|
112
109
|
}
|
|
113
110
|
|
|
111
|
+
/**
|
|
112
|
+
* @param {number} exchange
|
|
113
|
+
*/
|
|
114
|
+
function hakuban_exchange_drop(exchange) {
|
|
115
|
+
wasm.hakuban_exchange_drop(exchange);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
let cachedBigUint64ArrayMemory0 = null;
|
|
119
|
+
|
|
120
|
+
function getBigUint64ArrayMemory0() {
|
|
121
|
+
if (cachedBigUint64ArrayMemory0 === null || cachedBigUint64ArrayMemory0.byteLength === 0) {
|
|
122
|
+
cachedBigUint64ArrayMemory0 = new BigUint64Array(wasm.memory.buffer);
|
|
123
|
+
}
|
|
124
|
+
return cachedBigUint64ArrayMemory0;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function getArrayU64FromWasm0(ptr, len) {
|
|
128
|
+
ptr = ptr >>> 0;
|
|
129
|
+
return getBigUint64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* @param {number} exchange
|
|
133
|
+
* @returns {BigUint64Array}
|
|
134
|
+
*/
|
|
135
|
+
function hakuban_exchange_notified(exchange) {
|
|
136
|
+
const ret = wasm.hakuban_exchange_notified(exchange);
|
|
137
|
+
var v1 = getArrayU64FromWasm0(ret[0], ret[1]).slice();
|
|
138
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
139
|
+
return v1;
|
|
140
|
+
}
|
|
141
|
+
|
|
114
142
|
/**
|
|
115
143
|
* @param {number} exchange
|
|
116
144
|
* @param {number} descriptor
|
|
@@ -321,13 +349,22 @@ function hakuban_upstream_connection_send_message_from_network(wasm_upstream_con
|
|
|
321
349
|
return ret >>> 0;
|
|
322
350
|
}
|
|
323
351
|
|
|
324
|
-
|
|
352
|
+
/**
|
|
353
|
+
* @param {number} exchange_pointer
|
|
354
|
+
* @param {number} future_pointer
|
|
355
|
+
* @param {bigint} waker_id
|
|
356
|
+
* @returns {WasmResult}
|
|
357
|
+
*/
|
|
358
|
+
function hakuban_future_poll(exchange_pointer, future_pointer, waker_id) {
|
|
359
|
+
const ret = wasm.hakuban_future_poll(exchange_pointer, future_pointer, waker_id);
|
|
360
|
+
return WasmResult.__wrap(ret);
|
|
361
|
+
}
|
|
325
362
|
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
363
|
+
/**
|
|
364
|
+
* @param {number} future
|
|
365
|
+
*/
|
|
366
|
+
function hakuban_future_drop(future) {
|
|
367
|
+
wasm.hakuban_future_drop(future);
|
|
331
368
|
}
|
|
332
369
|
|
|
333
370
|
function passArray64ToWasm0(arg, malloc) {
|
|
@@ -436,6 +473,17 @@ function hakuban_object_state_data(object_state_pointer) {
|
|
|
436
473
|
return v1;
|
|
437
474
|
}
|
|
438
475
|
|
|
476
|
+
/**
|
|
477
|
+
* @param {string} default_log_level
|
|
478
|
+
* @returns {WasmResult}
|
|
479
|
+
*/
|
|
480
|
+
function hakuban_logger_initialize(default_log_level) {
|
|
481
|
+
const ptr0 = passStringToWasm0(default_log_level, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
482
|
+
const len0 = WASM_VECTOR_LEN;
|
|
483
|
+
const ret = wasm.hakuban_logger_initialize(ptr0, len0);
|
|
484
|
+
return WasmResult.__wrap(ret);
|
|
485
|
+
}
|
|
486
|
+
|
|
439
487
|
/**
|
|
440
488
|
* @param {string} json_string
|
|
441
489
|
* @returns {WasmResult}
|
|
@@ -549,54 +597,6 @@ function hakuban_tag_expose_contract_next(tag_expose_pointer) {
|
|
|
549
597
|
return ret >>> 0;
|
|
550
598
|
}
|
|
551
599
|
|
|
552
|
-
/**
|
|
553
|
-
* @returns {WasmResult}
|
|
554
|
-
*/
|
|
555
|
-
function hakuban_exchange_new() {
|
|
556
|
-
const ret = wasm.hakuban_exchange_new();
|
|
557
|
-
return WasmResult.__wrap(ret);
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
/**
|
|
561
|
-
* @param {number} exchange
|
|
562
|
-
*/
|
|
563
|
-
function hakuban_exchange_drop(exchange) {
|
|
564
|
-
wasm.hakuban_exchange_drop(exchange);
|
|
565
|
-
}
|
|
566
|
-
|
|
567
|
-
function getArrayU64FromWasm0(ptr, len) {
|
|
568
|
-
ptr = ptr >>> 0;
|
|
569
|
-
return getBigUint64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
|
|
570
|
-
}
|
|
571
|
-
/**
|
|
572
|
-
* @param {number} exchange
|
|
573
|
-
* @returns {BigUint64Array}
|
|
574
|
-
*/
|
|
575
|
-
function hakuban_exchange_notified(exchange) {
|
|
576
|
-
const ret = wasm.hakuban_exchange_notified(exchange);
|
|
577
|
-
var v1 = getArrayU64FromWasm0(ret[0], ret[1]).slice();
|
|
578
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
579
|
-
return v1;
|
|
580
|
-
}
|
|
581
|
-
|
|
582
|
-
/**
|
|
583
|
-
* @param {number} exchange_pointer
|
|
584
|
-
* @param {number} future_pointer
|
|
585
|
-
* @param {bigint} waker_id
|
|
586
|
-
* @returns {WasmResult}
|
|
587
|
-
*/
|
|
588
|
-
function hakuban_future_poll(exchange_pointer, future_pointer, waker_id) {
|
|
589
|
-
const ret = wasm.hakuban_future_poll(exchange_pointer, future_pointer, waker_id);
|
|
590
|
-
return WasmResult.__wrap(ret);
|
|
591
|
-
}
|
|
592
|
-
|
|
593
|
-
/**
|
|
594
|
-
* @param {number} future
|
|
595
|
-
*/
|
|
596
|
-
function hakuban_future_drop(future) {
|
|
597
|
-
wasm.hakuban_future_drop(future);
|
|
598
|
-
}
|
|
599
|
-
|
|
600
600
|
/**
|
|
601
601
|
* @enum {0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9}
|
|
602
602
|
*/
|
|
@@ -1616,9 +1616,9 @@ var UpstreamConnection = class UpstreamConnection extends FFIObject {
|
|
|
1616
1616
|
//TODO: implement timeout
|
|
1617
1617
|
//TODO: make timeout and keep-alive interval configurable
|
|
1618
1618
|
var WebsocketConnector = class WebsocketConnector {
|
|
1619
|
-
constructor(exchange, uri) {
|
|
1619
|
+
constructor(exchange, uri, options = {}) {
|
|
1620
1620
|
this.connect = this.connect.bind(this);
|
|
1621
|
-
this.
|
|
1621
|
+
this.heartbeat = this.heartbeat.bind(this);
|
|
1622
1622
|
this.send = this.send.bind(this);
|
|
1623
1623
|
this.exchange = exchange;
|
|
1624
1624
|
this.uri = uri;
|
|
@@ -1628,6 +1628,7 @@ var WebsocketConnector = class WebsocketConnector {
|
|
|
1628
1628
|
this.socket = void 0;
|
|
1629
1629
|
this.reconnection_timer = void 0;
|
|
1630
1630
|
this.reconnect_on_close = true;
|
|
1631
|
+
this.heartbeat_interval = options.heartbeat_interval || 60000;
|
|
1631
1632
|
this.connect();
|
|
1632
1633
|
}
|
|
1633
1634
|
|
|
@@ -1698,17 +1699,20 @@ var WebsocketConnector = class WebsocketConnector {
|
|
|
1698
1699
|
};
|
|
1699
1700
|
// this may fire even if onopen never did
|
|
1700
1701
|
this.socket.onclose = async(event) => {
|
|
1701
|
-
|
|
1702
|
-
|
|
1702
|
+
if (this.upstream_connection != null) {
|
|
1703
|
+
console.debug('Disconnected from remote exchange');
|
|
1704
|
+
} else {
|
|
1705
|
+
console.debug('Failed to connect to remote exchange');
|
|
1706
|
+
}
|
|
1703
1707
|
this._status_change({
|
|
1704
1708
|
connected: false,
|
|
1705
1709
|
disconnect_reason: event.reason,
|
|
1706
1710
|
clean_disconnect: event.wasClean
|
|
1707
1711
|
});
|
|
1708
1712
|
this.socket = void 0;
|
|
1709
|
-
if (this.
|
|
1710
|
-
|
|
1711
|
-
this.
|
|
1713
|
+
if (this.heartbeat_timeout != null) {
|
|
1714
|
+
clearTimeout(this.heartbeat_timeout);
|
|
1715
|
+
this.heartbeat_timeout = null;
|
|
1712
1716
|
}
|
|
1713
1717
|
if (this.reconnection_timer != null) {
|
|
1714
1718
|
clearTimeout(this.reconnection_timer);
|
|
@@ -1743,25 +1747,30 @@ var WebsocketConnector = class WebsocketConnector {
|
|
|
1743
1747
|
};
|
|
1744
1748
|
}
|
|
1745
1749
|
|
|
1746
|
-
|
|
1750
|
+
heartbeat() {
|
|
1747
1751
|
if (this.socket != null) {
|
|
1748
|
-
|
|
1752
|
+
this.socket.send(".");
|
|
1753
|
+
return this.heartbeat_timeout = setTimeout(this.heartbeat, this.heartbeat_interval);
|
|
1754
|
+
} else {
|
|
1755
|
+
return this.heartbeat_timeout = null;
|
|
1749
1756
|
}
|
|
1750
1757
|
}
|
|
1751
1758
|
|
|
1752
1759
|
send(bytes_to_send) {
|
|
1753
1760
|
this.socket.send(bytes_to_send);
|
|
1754
|
-
if (this.
|
|
1755
|
-
|
|
1761
|
+
if (this.heartbeat_timeout != null) {
|
|
1762
|
+
clearTimeout(this.heartbeat_timeout);
|
|
1756
1763
|
}
|
|
1757
|
-
return this.
|
|
1764
|
+
return this.heartbeat_timeout = setTimeout(this.heartbeat, this.heartbeat_interval);
|
|
1758
1765
|
}
|
|
1759
1766
|
|
|
1760
1767
|
};
|
|
1761
1768
|
|
|
1762
|
-
var initialize = async function(
|
|
1769
|
+
var initialize = async function(wasm_module_or_path, log_level) {
|
|
1763
1770
|
var result;
|
|
1764
|
-
result = (await __wbg_init(
|
|
1771
|
+
result = (await __wbg_init({
|
|
1772
|
+
module_or_path: wasm_module_or_path
|
|
1773
|
+
}));
|
|
1765
1774
|
logger_initialize(log_level);
|
|
1766
1775
|
return result;
|
|
1767
1776
|
};
|