@ricsam/isolate-client 0.1.17 → 0.1.19

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.
@@ -2,27 +2,37 @@ var __defProp = Object.defineProperty;
2
2
  var __getOwnPropNames = Object.getOwnPropertyNames;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __moduleCache = /* @__PURE__ */ new WeakMap;
5
+ function __accessProp(key) {
6
+ return this[key];
7
+ }
6
8
  var __toCommonJS = (from) => {
7
- var entry = __moduleCache.get(from), desc;
9
+ var entry = (__moduleCache ??= new WeakMap).get(from), desc;
8
10
  if (entry)
9
11
  return entry;
10
12
  entry = __defProp({}, "__esModule", { value: true });
11
- if (from && typeof from === "object" || typeof from === "function")
12
- __getOwnPropNames(from).map((key) => !__hasOwnProp.call(entry, key) && __defProp(entry, key, {
13
- get: () => from[key],
14
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
- }));
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (var key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(entry, key))
16
+ __defProp(entry, key, {
17
+ get: __accessProp.bind(from, key),
18
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
+ });
20
+ }
16
21
  __moduleCache.set(from, entry);
17
22
  return entry;
18
23
  };
24
+ var __moduleCache;
25
+ var __returnValue = (v) => v;
26
+ function __exportSetter(name, newValue) {
27
+ this[name] = __returnValue.bind(null, newValue);
28
+ }
19
29
  var __export = (target, all) => {
20
30
  for (var name in all)
21
31
  __defProp(target, name, {
22
32
  get: all[name],
23
33
  enumerable: true,
24
34
  configurable: true,
25
- set: (newValue) => all[name] = () => newValue
35
+ set: __exportSetter.bind(all, name)
26
36
  });
27
37
  };
28
38
 
@@ -35,4 +45,4 @@ __export(exports_src, {
35
45
  module.exports = __toCommonJS(exports_src);
36
46
  var import_connection = require("./connection.cjs");
37
47
 
38
- //# debugId=5E8155664B21FED264756E2164756E21
48
+ //# debugId=DCD79312172BA81064756E2164756E21
@@ -4,7 +4,7 @@
4
4
  "sourcesContent": [
5
5
  "/**\n * @ricsam/isolate-client\n *\n * Client library for connecting to the isolate daemon.\n * Works with Bun, Node.js, and other JavaScript runtimes.\n */\n\nexport { connect, isBenignDisposeError } from \"./connection.cjs\";\nexport type {\n ConnectOptions,\n DaemonConnection,\n Namespace,\n RuntimeOptions,\n RemoteRuntime,\n RemoteFetchHandle,\n RemoteTimersHandle,\n RemoteConsoleHandle,\n RemoteTestEnvironmentHandle,\n RemotePlaywrightHandle,\n DispatchOptions,\n ConsoleCallbacks,\n FetchCallback,\n FileSystemCallbacks,\n PlaywrightOptions,\n PlaywrightEvent,\n TestEnvironmentOptions,\n RunResults,\n TestResult,\n TestInfo,\n TestError,\n TestEvent,\n SuiteInfo,\n SuiteResult,\n CollectedData,\n ConsoleEntry,\n CustomFunctions,\n UpgradeRequest,\n WebSocketCommand,\n} from \"./types.cjs\";\n"
6
6
  ],
7
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAO8C,IAA9C;",
8
- "debugId": "5E8155664B21FED264756E2164756E21",
7
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAO8C,IAA9C;",
8
+ "debugId": "DCD79312172BA81064756E2164756E21",
9
9
  "names": []
10
10
  }
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@ricsam/isolate-client",
3
- "version": "0.1.17",
3
+ "version": "0.1.19",
4
4
  "type": "commonjs"
5
5
  }
@@ -2,23 +2,29 @@ var __defProp = Object.defineProperty;
2
2
  var __getOwnPropNames = Object.getOwnPropertyNames;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __moduleCache = /* @__PURE__ */ new WeakMap;
5
+ function __accessProp(key) {
6
+ return this[key];
7
+ }
6
8
  var __toCommonJS = (from) => {
7
- var entry = __moduleCache.get(from), desc;
9
+ var entry = (__moduleCache ??= new WeakMap).get(from), desc;
8
10
  if (entry)
9
11
  return entry;
10
12
  entry = __defProp({}, "__esModule", { value: true });
11
- if (from && typeof from === "object" || typeof from === "function")
12
- __getOwnPropNames(from).map((key) => !__hasOwnProp.call(entry, key) && __defProp(entry, key, {
13
- get: () => from[key],
14
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
- }));
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (var key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(entry, key))
16
+ __defProp(entry, key, {
17
+ get: __accessProp.bind(from, key),
18
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
+ });
20
+ }
16
21
  __moduleCache.set(from, entry);
17
22
  return entry;
18
23
  };
24
+ var __moduleCache;
19
25
 
20
26
  // packages/isolate-client/src/types.ts
21
27
  var exports_types = {};
22
28
  module.exports = __toCommonJS(exports_types);
23
29
 
24
- //# debugId=9DC1E15BCB751C9464756E2164756E21
30
+ //# debugId=8F53E249AA4D540C64756E2164756E21
@@ -4,6 +4,6 @@
4
4
  "sourcesContent": [
5
5
  ],
6
6
  "mappings": "",
7
- "debugId": "9DC1E15BCB751C9464756E2164756E21",
7
+ "debugId": "8F53E249AA4D540C64756E2164756E21",
8
8
  "names": []
9
9
  }
@@ -629,6 +629,8 @@ async function createRuntime(state, options = {}, namespaceId) {
629
629
  if (signal?.aborted) {
630
630
  throw new DOMException("The operation was aborted", "AbortError");
631
631
  }
632
+ const requestSignal = req.signal;
633
+ const requestSignalInitiallyAborted = requestSignal?.aborted ?? false;
632
634
  const reqId = state.nextRequestId++;
633
635
  const serialized = await serializeRequestWithStreaming(state, req);
634
636
  const { bodyStream, ...serializableRequest } = serialized;
@@ -655,6 +657,23 @@ async function createRuntime(state, options = {}, namespaceId) {
655
657
  };
656
658
  signal.addEventListener("abort", onAbort, { once: true });
657
659
  }
660
+ let onRequestAbort;
661
+ if (requestSignal && !requestSignalInitiallyAborted) {
662
+ onRequestAbort = () => {
663
+ const abortMessage = {
664
+ type: MessageType.DISPATCH_REQUEST_ABORT,
665
+ isolateId,
666
+ targetRequestId: reqId
667
+ };
668
+ if (state.connected) {
669
+ sendMessage(state.socket, abortMessage);
670
+ }
671
+ };
672
+ requestSignal.addEventListener("abort", onRequestAbort, { once: true });
673
+ if (requestSignal.aborted) {
674
+ onRequestAbort();
675
+ }
676
+ }
658
677
  try {
659
678
  if (serialized.bodyStreamId !== undefined && bodyStream) {
660
679
  const streamId = serialized.bodyStreamId;
@@ -670,6 +689,9 @@ async function createRuntime(state, options = {}, namespaceId) {
670
689
  if (signal && onAbort) {
671
690
  signal.removeEventListener("abort", onAbort);
672
691
  }
692
+ if (requestSignal && onRequestAbort) {
693
+ requestSignal.removeEventListener("abort", onRequestAbort);
694
+ }
673
695
  }
674
696
  },
675
697
  async getUpgradeRequest() {
@@ -1000,12 +1022,16 @@ function registerFetchCallback(state, callback) {
1000
1022
  state.callbacksNeedingRequestId.add(callbackId);
1001
1023
  state.callbacks.set(callbackId, async (serialized, requestId) => {
1002
1024
  const data = serialized;
1025
+ const signalController = new AbortController;
1026
+ if (data.signalAborted) {
1027
+ signalController.abort();
1028
+ }
1003
1029
  const init = {
1004
1030
  method: data.method,
1005
1031
  headers: data.headers,
1006
1032
  rawBody: data.body ?? null,
1007
1033
  body: data.body ?? null,
1008
- signal: new AbortController().signal
1034
+ signal: signalController.signal
1009
1035
  };
1010
1036
  const response = await callback(data.url, init);
1011
1037
  const contentLength = response.headers.get("content-length");
@@ -1376,7 +1402,8 @@ async function serializeRequestWithStreaming(state, request) {
1376
1402
  method: request.method,
1377
1403
  url: request.url,
1378
1404
  headers,
1379
- body
1405
+ body,
1406
+ signalAborted: request.signal?.aborted ?? false
1380
1407
  };
1381
1408
  if (bodyStreamId !== undefined) {
1382
1409
  result.bodyStreamId = bodyStreamId;
@@ -1637,4 +1664,4 @@ export {
1637
1664
  connect
1638
1665
  };
1639
1666
 
1640
- //# debugId=C1D8CA9472E6C2F664756E2164756E21
1667
+ //# debugId=7EA890CF5E7314ED64756E2164756E21