exoagent 0.0.1 → 0.0.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 +109 -30
- package/dist/capnweb/index-workers.cjs +2811 -0
- package/dist/capnweb/index-workers.cjs.map +1 -0
- package/dist/capnweb/index-workers.d.cts +2 -0
- package/dist/capnweb/index-workers.d.ts +2 -0
- package/dist/capnweb/index-workers.js +2774 -0
- package/dist/capnweb/index-workers.js.map +1 -0
- package/dist/capnweb/index.cjs +2788 -0
- package/dist/capnweb/index.cjs.map +1 -0
- package/dist/capnweb/index.d.cts +383 -0
- package/dist/capnweb/index.d.ts +383 -0
- package/dist/{code-mode-runtime.mjs → capnweb/index.js} +342 -90
- package/dist/capnweb/index.js.map +1 -0
- package/dist/capnweb-test-helpers.d.ts +25 -0
- package/dist/code-mode-deno.d.ts +13 -0
- package/dist/code-mode-runtime.d.ts +1 -0
- package/dist/code-mode.d.ts +39 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.mjs +97 -3391
- package/dist/rpc-toolset-BnC2BXPq.js +146 -0
- package/dist/rpc-toolset-test-helpers.d.mts +11 -2
- package/dist/rpc-toolset-test-helpers.d.ts +45 -0
- package/dist/rpc-toolset-test-helpers.mjs +12 -1371
- package/dist/rpc-toolset.d.ts +34 -0
- package/dist/sql/builder.d.ts +127 -0
- package/dist/sql/expression.d.ts +69 -0
- package/dist/sql/sql.d.ts +4 -0
- package/dist/sql/test-helpers.d.ts +9 -0
- package/dist/sql.d.ts +2 -0
- package/dist/sql.mjs +553 -0
- package/dist/stream-transport.d.ts +11 -0
- package/dist/tool-wrapper.d.ts +16 -0
- package/package.json +26 -12
- package/dist/index.d.mts +0 -426
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
//
|
|
1
|
+
// src/symbols.ts
|
|
2
2
|
var WORKERS_MODULE_SYMBOL = /* @__PURE__ */ Symbol("workers-module");
|
|
3
|
+
|
|
4
|
+
// src/core.ts
|
|
3
5
|
if (!Symbol.dispose) {
|
|
4
6
|
Symbol.dispose = /* @__PURE__ */ Symbol.for("dispose");
|
|
5
7
|
}
|
|
@@ -23,6 +25,9 @@ var RpcTarget = workersModule ? workersModule.RpcTarget : class {
|
|
|
23
25
|
var AsyncFunction = (async function() {
|
|
24
26
|
}).constructor;
|
|
25
27
|
var getGlobalRpcSessionOptions = () => ({});
|
|
28
|
+
var setGlobalRpcSessionOptions = (options) => {
|
|
29
|
+
getGlobalRpcSessionOptions = options;
|
|
30
|
+
};
|
|
26
31
|
var CALLBACK_CLEANUP = /* @__PURE__ */ Symbol("callback-cleanup");
|
|
27
32
|
function typeForRpc(value) {
|
|
28
33
|
switch (typeof value) {
|
|
@@ -292,6 +297,17 @@ function unwrapStubNoProperties(stub) {
|
|
|
292
297
|
}
|
|
293
298
|
return hook;
|
|
294
299
|
}
|
|
300
|
+
function takeOwnership(fn) {
|
|
301
|
+
const cleanup = fn[CALLBACK_CLEANUP];
|
|
302
|
+
if (cleanup) {
|
|
303
|
+
fn[Symbol.dispose] = cleanup;
|
|
304
|
+
delete fn[CALLBACK_CLEANUP];
|
|
305
|
+
} else if (!fn[Symbol.dispose]) {
|
|
306
|
+
fn[Symbol.dispose] = () => {
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
return fn;
|
|
310
|
+
}
|
|
295
311
|
function unwrapStubOrParent(stub) {
|
|
296
312
|
return stub[RAW_STUB].hook;
|
|
297
313
|
}
|
|
@@ -1097,6 +1113,8 @@ var PromiseStubHook = class _PromiseStubHook extends StubHook {
|
|
|
1097
1113
|
}
|
|
1098
1114
|
}
|
|
1099
1115
|
};
|
|
1116
|
+
|
|
1117
|
+
// src/map.ts
|
|
1100
1118
|
var currentMapBuilder;
|
|
1101
1119
|
var MapBuilder = class {
|
|
1102
1120
|
context;
|
|
@@ -1361,9 +1379,15 @@ mapImpl.applyMap = (input, parent, owner, captures, instructions) => {
|
|
|
1361
1379
|
}
|
|
1362
1380
|
}
|
|
1363
1381
|
};
|
|
1382
|
+
|
|
1383
|
+
// src/serialize.ts
|
|
1364
1384
|
var isExplicitCallback = (arg) => {
|
|
1365
1385
|
return typeof arg === "function" && "serializationMode" in arg;
|
|
1366
1386
|
};
|
|
1387
|
+
var explicitCallback = (fn, serializationMode) => {
|
|
1388
|
+
fn.serializationMode = serializationMode;
|
|
1389
|
+
return fn;
|
|
1390
|
+
};
|
|
1367
1391
|
var NullExporter = class {
|
|
1368
1392
|
exportStub(stub) {
|
|
1369
1393
|
throw new Error("Cannot serialize RPC stubs without an RPC session.");
|
|
@@ -1575,6 +1599,9 @@ var Devaluator = class _Devaluator {
|
|
|
1575
1599
|
return [type, exportId];
|
|
1576
1600
|
}
|
|
1577
1601
|
};
|
|
1602
|
+
function serialize(value) {
|
|
1603
|
+
return JSON.stringify(Devaluator.devaluate(value));
|
|
1604
|
+
}
|
|
1578
1605
|
var NullImporter = class {
|
|
1579
1606
|
importStub(idx) {
|
|
1580
1607
|
throw new Error("Cannot deserialize RPC stubs without an RPC session.");
|
|
@@ -1832,6 +1859,11 @@ var Evaluator = class _Evaluator {
|
|
|
1832
1859
|
}
|
|
1833
1860
|
}
|
|
1834
1861
|
};
|
|
1862
|
+
function deserialize(value) {
|
|
1863
|
+
let payload = new Evaluator(NULL_IMPORTER).evaluate(JSON.parse(value));
|
|
1864
|
+
payload.dispose();
|
|
1865
|
+
return payload.value;
|
|
1866
|
+
}
|
|
1835
1867
|
var maybeUnwrapStubHook = (hook) => {
|
|
1836
1868
|
if (!(hook instanceof PayloadStubHook)) {
|
|
1837
1869
|
return void 0;
|
|
@@ -1847,6 +1879,8 @@ var maybeUnwrapStubHook = (hook) => {
|
|
|
1847
1879
|
}
|
|
1848
1880
|
return void 0;
|
|
1849
1881
|
};
|
|
1882
|
+
|
|
1883
|
+
// src/rpc.ts
|
|
1850
1884
|
var ImportTableEntry = class {
|
|
1851
1885
|
constructor(session, importId, pulling) {
|
|
1852
1886
|
this.session = session;
|
|
@@ -2411,109 +2445,327 @@ var RpcSession = class {
|
|
|
2411
2445
|
return this.#session.drain();
|
|
2412
2446
|
}
|
|
2413
2447
|
};
|
|
2414
|
-
var RpcSession2 = RpcSession;
|
|
2415
2448
|
|
|
2416
|
-
// src/
|
|
2417
|
-
function
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2449
|
+
// src/websocket.ts
|
|
2450
|
+
function newWebSocketRpcSession(webSocket, localMain, options) {
|
|
2451
|
+
if (typeof webSocket === "string") {
|
|
2452
|
+
webSocket = new WebSocket(webSocket);
|
|
2453
|
+
}
|
|
2454
|
+
let transport = new WebSocketTransport(webSocket);
|
|
2455
|
+
let rpc = new RpcSession(transport, localMain, options);
|
|
2456
|
+
return rpc.getRemoteMain();
|
|
2422
2457
|
}
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2458
|
+
function newWorkersWebSocketRpcResponse(request, localMain, options) {
|
|
2459
|
+
if (request.headers.get("Upgrade")?.toLowerCase() !== "websocket") {
|
|
2460
|
+
return new Response("This endpoint only accepts WebSocket requests.", { status: 400 });
|
|
2461
|
+
}
|
|
2462
|
+
let pair = new WebSocketPair();
|
|
2463
|
+
let server = pair[0];
|
|
2464
|
+
server.accept();
|
|
2465
|
+
newWebSocketRpcSession(server, localMain, options);
|
|
2466
|
+
return new Response(null, {
|
|
2467
|
+
status: 101,
|
|
2468
|
+
webSocket: pair[1]
|
|
2469
|
+
});
|
|
2470
|
+
}
|
|
2471
|
+
var WebSocketTransport = class {
|
|
2472
|
+
constructor(webSocket) {
|
|
2473
|
+
this.#webSocket = webSocket;
|
|
2474
|
+
if (webSocket.readyState === WebSocket.CONNECTING) {
|
|
2475
|
+
this.#sendQueue = [];
|
|
2476
|
+
webSocket.addEventListener("open", (event) => {
|
|
2477
|
+
try {
|
|
2478
|
+
for (let message of this.#sendQueue) {
|
|
2479
|
+
webSocket.send(message);
|
|
2480
|
+
}
|
|
2481
|
+
} catch (err) {
|
|
2482
|
+
this.#receivedError(err);
|
|
2483
|
+
}
|
|
2484
|
+
this.#sendQueue = void 0;
|
|
2485
|
+
});
|
|
2486
|
+
}
|
|
2487
|
+
webSocket.addEventListener("message", (event) => {
|
|
2488
|
+
if (this.#error) ; else if (typeof event.data === "string") {
|
|
2489
|
+
if (this.#receiveResolver) {
|
|
2490
|
+
this.#receiveResolver(event.data);
|
|
2491
|
+
this.#receiveResolver = void 0;
|
|
2492
|
+
this.#receiveRejecter = void 0;
|
|
2493
|
+
} else {
|
|
2494
|
+
this.#receiveQueue.push(event.data);
|
|
2495
|
+
}
|
|
2496
|
+
} else {
|
|
2497
|
+
this.#receivedError(new TypeError("Received non-string message from WebSocket."));
|
|
2498
|
+
}
|
|
2499
|
+
});
|
|
2500
|
+
webSocket.addEventListener("close", (event) => {
|
|
2501
|
+
this.#receivedError(new Error(`Peer closed WebSocket: ${event.code} ${event.reason}`));
|
|
2502
|
+
});
|
|
2503
|
+
webSocket.addEventListener("error", (event) => {
|
|
2504
|
+
this.#receivedError(new Error(`WebSocket connection failed.`));
|
|
2505
|
+
});
|
|
2506
|
+
}
|
|
2507
|
+
#webSocket;
|
|
2508
|
+
#sendQueue;
|
|
2509
|
+
// only if not opened yet
|
|
2510
|
+
#receiveResolver;
|
|
2511
|
+
#receiveRejecter;
|
|
2512
|
+
#receiveQueue = [];
|
|
2513
|
+
#error;
|
|
2514
|
+
async send(message) {
|
|
2515
|
+
if (this.#sendQueue === void 0) {
|
|
2516
|
+
this.#webSocket.send(message);
|
|
2517
|
+
} else {
|
|
2518
|
+
this.#sendQueue.push(message);
|
|
2519
|
+
}
|
|
2520
|
+
}
|
|
2521
|
+
async receive() {
|
|
2522
|
+
if (this.#receiveQueue.length > 0) {
|
|
2523
|
+
return this.#receiveQueue.shift();
|
|
2524
|
+
} else if (this.#error) {
|
|
2525
|
+
throw this.#error;
|
|
2526
|
+
} else {
|
|
2527
|
+
return new Promise((resolve, reject) => {
|
|
2528
|
+
this.#receiveResolver = resolve;
|
|
2529
|
+
this.#receiveRejecter = reject;
|
|
2530
|
+
});
|
|
2531
|
+
}
|
|
2532
|
+
}
|
|
2533
|
+
abort(reason) {
|
|
2534
|
+
let message;
|
|
2535
|
+
if (reason instanceof Error) {
|
|
2536
|
+
message = reason.message;
|
|
2537
|
+
} else {
|
|
2538
|
+
message = `${reason}`;
|
|
2539
|
+
}
|
|
2540
|
+
this.#webSocket.close(3e3, message);
|
|
2541
|
+
if (!this.#error) {
|
|
2542
|
+
this.#error = reason;
|
|
2543
|
+
}
|
|
2544
|
+
}
|
|
2545
|
+
#receivedError(reason) {
|
|
2546
|
+
if (!this.#error) {
|
|
2547
|
+
this.#error = reason;
|
|
2548
|
+
if (this.#receiveRejecter) {
|
|
2549
|
+
this.#receiveRejecter(reason);
|
|
2550
|
+
this.#receiveResolver = void 0;
|
|
2551
|
+
this.#receiveRejecter = void 0;
|
|
2552
|
+
}
|
|
2553
|
+
}
|
|
2444
2554
|
}
|
|
2445
2555
|
};
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
this
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2556
|
+
|
|
2557
|
+
// src/batch.ts
|
|
2558
|
+
var BatchClientTransport = class {
|
|
2559
|
+
constructor(sendBatch) {
|
|
2560
|
+
this.#promise = this.#scheduleBatch(sendBatch);
|
|
2561
|
+
}
|
|
2562
|
+
#promise;
|
|
2563
|
+
#aborted;
|
|
2564
|
+
#batchToSend = [];
|
|
2565
|
+
#batchToReceive = null;
|
|
2455
2566
|
async send(message) {
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
if (length > 4294967295) {
|
|
2460
|
-
throw new Error("Message length exceeds maximum allowed size (4GB)");
|
|
2461
|
-
}
|
|
2462
|
-
const lengthBytes = new Uint8Array(4);
|
|
2463
|
-
const view = new DataView(lengthBytes.buffer);
|
|
2464
|
-
view.setUint32(0, length, true);
|
|
2465
|
-
const combined = new Uint8Array(4 + length);
|
|
2466
|
-
combined.set(lengthBytes, 0);
|
|
2467
|
-
combined.set(messageBytes, 4);
|
|
2468
|
-
await this.writer.write(combined);
|
|
2567
|
+
if (this.#batchToSend !== null) {
|
|
2568
|
+
this.#batchToSend.push(message);
|
|
2569
|
+
}
|
|
2469
2570
|
}
|
|
2470
2571
|
async receive() {
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
const length = new DataView(lengthBuffer).getUint32(0, true);
|
|
2474
|
-
if (length > 100 * 1024 * 1024) {
|
|
2475
|
-
throw new Error("Message length exceeds maximum allowed size");
|
|
2572
|
+
if (!this.#batchToReceive) {
|
|
2573
|
+
await this.#promise;
|
|
2476
2574
|
}
|
|
2477
|
-
|
|
2478
|
-
|
|
2575
|
+
let msg = this.#batchToReceive.shift();
|
|
2576
|
+
if (msg !== void 0) {
|
|
2577
|
+
return msg;
|
|
2578
|
+
} else {
|
|
2579
|
+
throw new Error("Batch RPC request ended.");
|
|
2479
2580
|
}
|
|
2480
|
-
const messageBytes = await this.bufferReader.read(length);
|
|
2481
|
-
const decoder = new TextDecoder();
|
|
2482
|
-
return decoder.decode(messageBytes);
|
|
2483
2581
|
}
|
|
2484
2582
|
abort(reason) {
|
|
2485
|
-
this
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2583
|
+
this.#aborted = reason;
|
|
2584
|
+
}
|
|
2585
|
+
async #scheduleBatch(sendBatch) {
|
|
2586
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
2587
|
+
if (this.#aborted !== void 0) {
|
|
2588
|
+
throw this.#aborted;
|
|
2589
|
+
}
|
|
2590
|
+
let batch = this.#batchToSend;
|
|
2591
|
+
this.#batchToSend = null;
|
|
2592
|
+
this.#batchToReceive = await sendBatch(batch);
|
|
2489
2593
|
}
|
|
2490
2594
|
};
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
await
|
|
2502
|
-
|
|
2503
|
-
|
|
2595
|
+
function newHttpBatchRpcSession(urlOrRequest, options) {
|
|
2596
|
+
let sendBatch = async (batch) => {
|
|
2597
|
+
let response = await fetch(urlOrRequest, {
|
|
2598
|
+
method: "POST",
|
|
2599
|
+
body: batch.join("\n")
|
|
2600
|
+
});
|
|
2601
|
+
if (!response.ok) {
|
|
2602
|
+
response.body?.cancel();
|
|
2603
|
+
throw new Error(`RPC request failed: ${response.status} ${response.statusText}`);
|
|
2604
|
+
}
|
|
2605
|
+
let body = await response.text();
|
|
2606
|
+
return body == "" ? [] : body.split("\n");
|
|
2607
|
+
};
|
|
2608
|
+
let transport = new BatchClientTransport(sendBatch);
|
|
2609
|
+
let rpc = new RpcSession(transport, void 0, options);
|
|
2610
|
+
return rpc.getRemoteMain();
|
|
2611
|
+
}
|
|
2612
|
+
var BatchServerTransport = class {
|
|
2613
|
+
constructor(batch) {
|
|
2614
|
+
this.#batchToReceive = batch;
|
|
2615
|
+
}
|
|
2616
|
+
#batchToSend = [];
|
|
2617
|
+
#batchToReceive;
|
|
2618
|
+
#allReceived = Promise.withResolvers();
|
|
2619
|
+
async send(message) {
|
|
2620
|
+
this.#batchToSend.push(message);
|
|
2621
|
+
}
|
|
2622
|
+
async receive() {
|
|
2623
|
+
let msg = this.#batchToReceive.shift();
|
|
2624
|
+
if (msg !== void 0) {
|
|
2625
|
+
return msg;
|
|
2626
|
+
} else {
|
|
2627
|
+
this.#allReceived.resolve();
|
|
2628
|
+
return new Promise((r) => {
|
|
2629
|
+
});
|
|
2630
|
+
}
|
|
2504
2631
|
}
|
|
2632
|
+
abort(reason) {
|
|
2633
|
+
this.#allReceived.reject(reason);
|
|
2634
|
+
}
|
|
2635
|
+
whenAllReceived() {
|
|
2636
|
+
return this.#allReceived.promise;
|
|
2637
|
+
}
|
|
2638
|
+
getResponseBody() {
|
|
2639
|
+
return this.#batchToSend.join("\n");
|
|
2640
|
+
}
|
|
2641
|
+
};
|
|
2642
|
+
async function newHttpBatchRpcResponse(request, localMain, options) {
|
|
2643
|
+
if (request.method !== "POST") {
|
|
2644
|
+
return new Response("This endpoint only accepts POST requests.", { status: 405 });
|
|
2645
|
+
}
|
|
2646
|
+
let body = await request.text();
|
|
2647
|
+
let batch = body === "" ? [] : body.split("\n");
|
|
2648
|
+
let transport = new BatchServerTransport(batch);
|
|
2649
|
+
let rpc = new RpcSession(transport, localMain, options);
|
|
2650
|
+
await transport.whenAllReceived();
|
|
2651
|
+
await rpc.drain();
|
|
2652
|
+
return new Response(transport.getResponseBody());
|
|
2505
2653
|
}
|
|
2506
|
-
async function
|
|
2507
|
-
if (
|
|
2508
|
-
|
|
2509
|
-
}
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2654
|
+
async function nodeHttpBatchRpcResponse(request, response, localMain, options) {
|
|
2655
|
+
if (request.method !== "POST") {
|
|
2656
|
+
response.writeHead(405, "This endpoint only accepts POST requests.");
|
|
2657
|
+
}
|
|
2658
|
+
let body = await new Promise((resolve, reject) => {
|
|
2659
|
+
let chunks = [];
|
|
2660
|
+
request.on("data", (chunk) => {
|
|
2661
|
+
chunks.push(chunk);
|
|
2662
|
+
});
|
|
2663
|
+
request.on("end", () => {
|
|
2664
|
+
resolve(Buffer.concat(chunks).toString());
|
|
2665
|
+
});
|
|
2666
|
+
request.on("error", reject);
|
|
2517
2667
|
});
|
|
2668
|
+
let batch = body === "" ? [] : body.split("\n");
|
|
2669
|
+
let transport = new BatchServerTransport(batch);
|
|
2670
|
+
let rpc = new RpcSession(transport, localMain, options);
|
|
2671
|
+
await transport.whenAllReceived();
|
|
2672
|
+
await rpc.drain();
|
|
2673
|
+
response.writeHead(200, options?.headers);
|
|
2674
|
+
response.end(transport.getResponseBody());
|
|
2675
|
+
}
|
|
2676
|
+
|
|
2677
|
+
// src/messageport.ts
|
|
2678
|
+
function newMessagePortRpcSession(port, localMain, options) {
|
|
2679
|
+
let transport = new MessagePortTransport(port);
|
|
2680
|
+
let rpc = new RpcSession(transport, localMain, options);
|
|
2681
|
+
return rpc.getRemoteMain();
|
|
2682
|
+
}
|
|
2683
|
+
var MessagePortTransport = class {
|
|
2684
|
+
constructor(port) {
|
|
2685
|
+
this.#port = port;
|
|
2686
|
+
port.start();
|
|
2687
|
+
port.addEventListener("message", (event) => {
|
|
2688
|
+
if (this.#error) ; else if (event.data === null) {
|
|
2689
|
+
this.#receivedError(new Error("Peer closed MessagePort connection."));
|
|
2690
|
+
} else if (typeof event.data === "string") {
|
|
2691
|
+
if (this.#receiveResolver) {
|
|
2692
|
+
this.#receiveResolver(event.data);
|
|
2693
|
+
this.#receiveResolver = void 0;
|
|
2694
|
+
this.#receiveRejecter = void 0;
|
|
2695
|
+
} else {
|
|
2696
|
+
this.#receiveQueue.push(event.data);
|
|
2697
|
+
}
|
|
2698
|
+
} else {
|
|
2699
|
+
this.#receivedError(new TypeError("Received non-string message from MessagePort."));
|
|
2700
|
+
}
|
|
2701
|
+
});
|
|
2702
|
+
port.addEventListener("messageerror", (event) => {
|
|
2703
|
+
this.#receivedError(new Error("MessagePort message error."));
|
|
2704
|
+
});
|
|
2705
|
+
}
|
|
2706
|
+
#port;
|
|
2707
|
+
#receiveResolver;
|
|
2708
|
+
#receiveRejecter;
|
|
2709
|
+
#receiveQueue = [];
|
|
2710
|
+
#error;
|
|
2711
|
+
async send(message) {
|
|
2712
|
+
if (this.#error) {
|
|
2713
|
+
throw this.#error;
|
|
2714
|
+
}
|
|
2715
|
+
this.#port.postMessage(message);
|
|
2716
|
+
}
|
|
2717
|
+
async receive() {
|
|
2718
|
+
if (this.#receiveQueue.length > 0) {
|
|
2719
|
+
return this.#receiveQueue.shift();
|
|
2720
|
+
} else if (this.#error) {
|
|
2721
|
+
throw this.#error;
|
|
2722
|
+
} else {
|
|
2723
|
+
return new Promise((resolve, reject) => {
|
|
2724
|
+
this.#receiveResolver = resolve;
|
|
2725
|
+
this.#receiveRejecter = reject;
|
|
2726
|
+
});
|
|
2727
|
+
}
|
|
2728
|
+
}
|
|
2729
|
+
abort(reason) {
|
|
2730
|
+
try {
|
|
2731
|
+
this.#port.postMessage(null);
|
|
2732
|
+
} catch (err) {
|
|
2733
|
+
}
|
|
2734
|
+
this.#port.close();
|
|
2735
|
+
if (!this.#error) {
|
|
2736
|
+
this.#error = reason;
|
|
2737
|
+
}
|
|
2738
|
+
}
|
|
2739
|
+
#receivedError(reason) {
|
|
2740
|
+
if (!this.#error) {
|
|
2741
|
+
this.#error = reason;
|
|
2742
|
+
if (this.#receiveRejecter) {
|
|
2743
|
+
this.#receiveRejecter(reason);
|
|
2744
|
+
this.#receiveResolver = void 0;
|
|
2745
|
+
this.#receiveRejecter = void 0;
|
|
2746
|
+
}
|
|
2747
|
+
}
|
|
2748
|
+
}
|
|
2749
|
+
};
|
|
2750
|
+
var RpcStub2 = RpcStub;
|
|
2751
|
+
var RpcPromise2 = RpcPromise;
|
|
2752
|
+
var RpcSession2 = RpcSession;
|
|
2753
|
+
var RpcTarget4 = RpcTarget;
|
|
2754
|
+
var newWebSocketRpcSession2 = newWebSocketRpcSession;
|
|
2755
|
+
var newHttpBatchRpcSession2 = newHttpBatchRpcSession;
|
|
2756
|
+
var newMessagePortRpcSession2 = newMessagePortRpcSession;
|
|
2757
|
+
async function newWorkersRpcResponse(request, localMain) {
|
|
2758
|
+
if (request.method === "POST") {
|
|
2759
|
+
let response = await newHttpBatchRpcResponse(request, localMain);
|
|
2760
|
+
response.headers.set("Access-Control-Allow-Origin", "*");
|
|
2761
|
+
return response;
|
|
2762
|
+
} else if (request.headers.get("Upgrade")?.toLowerCase() === "websocket") {
|
|
2763
|
+
return newWorkersWebSocketRpcResponse(request, localMain);
|
|
2764
|
+
} else {
|
|
2765
|
+
return new Response("This endpoint only accepts POST or WebSocket requests.", { status: 400 });
|
|
2766
|
+
}
|
|
2518
2767
|
}
|
|
2519
|
-
|
|
2768
|
+
|
|
2769
|
+
export { RpcPromise2 as RpcPromise, RpcSession2 as RpcSession, RpcStub2 as RpcStub, RpcTarget4 as RpcTarget, deserialize, explicitCallback, newHttpBatchRpcResponse, newHttpBatchRpcSession2 as newHttpBatchRpcSession, newMessagePortRpcSession2 as newMessagePortRpcSession, newWebSocketRpcSession2 as newWebSocketRpcSession, newWorkersRpcResponse, newWorkersWebSocketRpcResponse, nodeHttpBatchRpcResponse, serialize, setGlobalRpcSessionOptions, takeOwnership };
|
|
2770
|
+
//# sourceMappingURL=index.js.map
|
|
2771
|
+
//# sourceMappingURL=index.js.map
|