@vastblast/capnweb 0.7.3 → 0.7.4
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/dist/index-workers.cjs +18 -31
- package/dist/index-workers.cjs.map +1 -1
- package/dist/index-workers.js +18 -31
- package/dist/index-workers.js.map +1 -1
- package/dist/index.cjs +18 -31
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +18 -31
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index-workers.cjs
CHANGED
|
@@ -2472,6 +2472,8 @@ var RpcSessionImpl = class {
|
|
|
2472
2472
|
throw new Error(`bad RPC message: ${JSON.stringify(msg)}`);
|
|
2473
2473
|
}
|
|
2474
2474
|
}
|
|
2475
|
+
// Use a fresh cancellation promise for each read. Reusing one session-long promise here causes
|
|
2476
|
+
// Promise.race() to accumulate reactions until the session is shut down.
|
|
2475
2477
|
receiveOrAbort() {
|
|
2476
2478
|
let readCanceled = Promise.withResolvers();
|
|
2477
2479
|
this.cancelReadLoop = readCanceled.reject;
|
|
@@ -2534,7 +2536,6 @@ var RpcSession = class {
|
|
|
2534
2536
|
};
|
|
2535
2537
|
|
|
2536
2538
|
// src/websocket.ts
|
|
2537
|
-
var RESOLVED_VOID_PROMISE = Promise.resolve();
|
|
2538
2539
|
function newWebSocketRpcSession(webSocket, localMain, options) {
|
|
2539
2540
|
if (typeof webSocket === "string") {
|
|
2540
2541
|
webSocket = new WebSocket(webSocket);
|
|
@@ -2599,23 +2600,18 @@ var WebSocketTransport = class {
|
|
|
2599
2600
|
#receiveRejecter;
|
|
2600
2601
|
#receiveQueue = [];
|
|
2601
2602
|
#error;
|
|
2602
|
-
send(message) {
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
this.#sendQueue.push(message);
|
|
2608
|
-
}
|
|
2609
|
-
return RESOLVED_VOID_PROMISE;
|
|
2610
|
-
} catch (err) {
|
|
2611
|
-
return Promise.reject(err);
|
|
2603
|
+
async send(message) {
|
|
2604
|
+
if (this.#sendQueue === void 0) {
|
|
2605
|
+
this.#webSocket.send(message);
|
|
2606
|
+
} else {
|
|
2607
|
+
this.#sendQueue.push(message);
|
|
2612
2608
|
}
|
|
2613
2609
|
}
|
|
2614
|
-
receive() {
|
|
2610
|
+
async receive() {
|
|
2615
2611
|
if (this.#receiveQueue.length > 0) {
|
|
2616
|
-
return
|
|
2612
|
+
return this.#receiveQueue.shift();
|
|
2617
2613
|
} else if (this.#error) {
|
|
2618
|
-
|
|
2614
|
+
throw this.#error;
|
|
2619
2615
|
} else {
|
|
2620
2616
|
return new Promise((resolve, reject) => {
|
|
2621
2617
|
this.#receiveResolver = resolve;
|
|
@@ -2648,7 +2644,6 @@ var WebSocketTransport = class {
|
|
|
2648
2644
|
};
|
|
2649
2645
|
|
|
2650
2646
|
// src/batch.ts
|
|
2651
|
-
var RESOLVED_VOID_PROMISE2 = Promise.resolve();
|
|
2652
2647
|
var BatchClientTransport = class {
|
|
2653
2648
|
constructor(sendBatch) {
|
|
2654
2649
|
this.#promise = this.#scheduleBatch(sendBatch);
|
|
@@ -2657,11 +2652,10 @@ var BatchClientTransport = class {
|
|
|
2657
2652
|
#aborted;
|
|
2658
2653
|
#batchToSend = [];
|
|
2659
2654
|
#batchToReceive = null;
|
|
2660
|
-
send(message) {
|
|
2655
|
+
async send(message) {
|
|
2661
2656
|
if (this.#batchToSend !== null) {
|
|
2662
2657
|
this.#batchToSend.push(message);
|
|
2663
2658
|
}
|
|
2664
|
-
return RESOLVED_VOID_PROMISE2;
|
|
2665
2659
|
}
|
|
2666
2660
|
async receive() {
|
|
2667
2661
|
if (!this.#batchToReceive) {
|
|
@@ -2711,9 +2705,8 @@ var BatchServerTransport = class {
|
|
|
2711
2705
|
#batchToSend = [];
|
|
2712
2706
|
#batchToReceive;
|
|
2713
2707
|
#allReceived = Promise.withResolvers();
|
|
2714
|
-
send(message) {
|
|
2708
|
+
async send(message) {
|
|
2715
2709
|
this.#batchToSend.push(message);
|
|
2716
|
-
return RESOLVED_VOID_PROMISE2;
|
|
2717
2710
|
}
|
|
2718
2711
|
async receive() {
|
|
2719
2712
|
let msg = this.#batchToReceive.shift();
|
|
@@ -2771,7 +2764,6 @@ async function nodeHttpBatchRpcResponse(request, response, localMain, options) {
|
|
|
2771
2764
|
}
|
|
2772
2765
|
|
|
2773
2766
|
// src/messageport.ts
|
|
2774
|
-
var RESOLVED_VOID_PROMISE3 = Promise.resolve();
|
|
2775
2767
|
function newMessagePortRpcSession(port, localMain, options) {
|
|
2776
2768
|
let transport = new MessagePortTransport(port);
|
|
2777
2769
|
let rpc = new RpcSession(transport, localMain, options);
|
|
@@ -2805,22 +2797,17 @@ var MessagePortTransport = class {
|
|
|
2805
2797
|
#receiveRejecter;
|
|
2806
2798
|
#receiveQueue = [];
|
|
2807
2799
|
#error;
|
|
2808
|
-
send(message) {
|
|
2800
|
+
async send(message) {
|
|
2809
2801
|
if (this.#error) {
|
|
2810
|
-
|
|
2811
|
-
}
|
|
2812
|
-
try {
|
|
2813
|
-
this.#port.postMessage(message);
|
|
2814
|
-
return RESOLVED_VOID_PROMISE3;
|
|
2815
|
-
} catch (err) {
|
|
2816
|
-
return Promise.reject(err);
|
|
2802
|
+
throw this.#error;
|
|
2817
2803
|
}
|
|
2804
|
+
this.#port.postMessage(message);
|
|
2818
2805
|
}
|
|
2819
|
-
receive() {
|
|
2806
|
+
async receive() {
|
|
2820
2807
|
if (this.#receiveQueue.length > 0) {
|
|
2821
|
-
return
|
|
2808
|
+
return this.#receiveQueue.shift();
|
|
2822
2809
|
} else if (this.#error) {
|
|
2823
|
-
|
|
2810
|
+
throw this.#error;
|
|
2824
2811
|
} else {
|
|
2825
2812
|
return new Promise((resolve, reject) => {
|
|
2826
2813
|
this.#receiveResolver = resolve;
|