@ricsam/isolate-client 0.1.25 → 0.1.27
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/cjs/connection.cjs +75 -5
- package/dist/cjs/connection.cjs.map +3 -3
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/package.json +1 -1
- package/dist/mjs/connection.mjs +75 -5
- package/dist/mjs/connection.mjs.map +3 -3
- package/dist/mjs/index.mjs.map +1 -1
- package/dist/mjs/package.json +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/types.d.ts +7 -1
- package/package.json +3 -3
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
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"
|
|
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 DisposeRuntimeOptions,\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
7
|
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAO8C,IAA9C;",
|
|
8
8
|
"debugId": "DCD79312172BA81064756E2164756E21",
|
package/dist/cjs/package.json
CHANGED
package/dist/mjs/connection.mjs
CHANGED
|
@@ -551,8 +551,10 @@ async function createRuntime(state, options = {}, namespaceId) {
|
|
|
551
551
|
}
|
|
552
552
|
let playwrightHandler;
|
|
553
553
|
const browserConsoleLogs = [];
|
|
554
|
+
const pageErrors = [];
|
|
554
555
|
const networkRequests = [];
|
|
555
556
|
const networkResponses = [];
|
|
557
|
+
const requestFailures = [];
|
|
556
558
|
const pageListenerCleanups = [];
|
|
557
559
|
if (normalizedPlaywrightOptions) {
|
|
558
560
|
playwrightHandler = normalizedPlaywrightOptions.handler;
|
|
@@ -567,10 +569,31 @@ async function createRuntime(state, options = {}, namespaceId) {
|
|
|
567
569
|
return JSON.stringify(result2);
|
|
568
570
|
});
|
|
569
571
|
if (page) {
|
|
572
|
+
const requestIds = new WeakMap;
|
|
573
|
+
let nextRequestId = 1;
|
|
574
|
+
const getRequestId = (request2) => {
|
|
575
|
+
let requestId2 = requestIds.get(request2);
|
|
576
|
+
if (!requestId2) {
|
|
577
|
+
requestId2 = `req_${nextRequestId++}`;
|
|
578
|
+
requestIds.set(request2, requestId2);
|
|
579
|
+
}
|
|
580
|
+
return requestId2;
|
|
581
|
+
};
|
|
582
|
+
const toLocation = (location) => {
|
|
583
|
+
if (!location || !location.url && location.lineNumber == null && location.columnNumber == null) {
|
|
584
|
+
return;
|
|
585
|
+
}
|
|
586
|
+
return {
|
|
587
|
+
url: location.url || undefined,
|
|
588
|
+
lineNumber: location.lineNumber != null ? location.lineNumber + 1 : undefined,
|
|
589
|
+
columnNumber: location.columnNumber != null ? location.columnNumber + 1 : undefined
|
|
590
|
+
};
|
|
591
|
+
};
|
|
570
592
|
const onConsole = (msg) => {
|
|
571
593
|
const entry = {
|
|
572
594
|
level: msg.type(),
|
|
573
595
|
stdout: msg.text(),
|
|
596
|
+
location: toLocation(msg.location()),
|
|
574
597
|
timestamp: Date.now()
|
|
575
598
|
};
|
|
576
599
|
browserConsoleLogs.push(entry);
|
|
@@ -592,9 +615,12 @@ async function createRuntime(state, options = {}, namespaceId) {
|
|
|
592
615
|
};
|
|
593
616
|
const onRequest = (request2) => {
|
|
594
617
|
const info = {
|
|
618
|
+
requestId: getRequestId(request2),
|
|
595
619
|
url: request2.url(),
|
|
596
620
|
method: request2.method(),
|
|
597
621
|
headers: request2.headers(),
|
|
622
|
+
postData: request2.postData() ?? undefined,
|
|
623
|
+
resourceType: request2.resourceType(),
|
|
598
624
|
timestamp: Date.now()
|
|
599
625
|
};
|
|
600
626
|
networkRequests.push(info);
|
|
@@ -606,10 +632,14 @@ async function createRuntime(state, options = {}, namespaceId) {
|
|
|
606
632
|
}
|
|
607
633
|
};
|
|
608
634
|
const onResponse = (response) => {
|
|
635
|
+
const request2 = response.request();
|
|
609
636
|
const info = {
|
|
637
|
+
requestId: getRequestId(request2),
|
|
610
638
|
url: response.url(),
|
|
611
639
|
status: response.status(),
|
|
640
|
+
statusText: response.statusText(),
|
|
612
641
|
headers: response.headers(),
|
|
642
|
+
resourceType: request2.resourceType(),
|
|
613
643
|
timestamp: Date.now()
|
|
614
644
|
};
|
|
615
645
|
networkResponses.push(info);
|
|
@@ -620,10 +650,44 @@ async function createRuntime(state, options = {}, namespaceId) {
|
|
|
620
650
|
});
|
|
621
651
|
}
|
|
622
652
|
};
|
|
653
|
+
const onRequestFailed = (request2) => {
|
|
654
|
+
const info = {
|
|
655
|
+
requestId: getRequestId(request2),
|
|
656
|
+
url: request2.url(),
|
|
657
|
+
method: request2.method(),
|
|
658
|
+
failureText: request2.failure()?.errorText || "request failed",
|
|
659
|
+
resourceType: request2.resourceType(),
|
|
660
|
+
timestamp: Date.now()
|
|
661
|
+
};
|
|
662
|
+
requestFailures.push(info);
|
|
663
|
+
if (normalizedPlaywrightOptions.onEvent) {
|
|
664
|
+
normalizedPlaywrightOptions.onEvent({
|
|
665
|
+
type: "requestFailure",
|
|
666
|
+
...info
|
|
667
|
+
});
|
|
668
|
+
}
|
|
669
|
+
};
|
|
670
|
+
const onPageError = (error) => {
|
|
671
|
+
const entry = {
|
|
672
|
+
name: error.name,
|
|
673
|
+
message: error.message,
|
|
674
|
+
stack: error.stack,
|
|
675
|
+
timestamp: Date.now()
|
|
676
|
+
};
|
|
677
|
+
pageErrors.push(entry);
|
|
678
|
+
if (normalizedPlaywrightOptions.onEvent) {
|
|
679
|
+
normalizedPlaywrightOptions.onEvent({
|
|
680
|
+
type: "pageError",
|
|
681
|
+
...entry
|
|
682
|
+
});
|
|
683
|
+
}
|
|
684
|
+
};
|
|
623
685
|
page.on("console", onConsole);
|
|
624
686
|
page.on("request", onRequest);
|
|
625
687
|
page.on("response", onResponse);
|
|
626
|
-
|
|
688
|
+
page.on("requestfailed", onRequestFailed);
|
|
689
|
+
page.on("pageerror", onPageError);
|
|
690
|
+
pageListenerCleanups.push(() => page.removeListener("console", onConsole), () => page.removeListener("request", onRequest), () => page.removeListener("response", onResponse), () => page.removeListener("requestfailed", onRequestFailed), () => page.removeListener("pageerror", onPageError));
|
|
627
691
|
}
|
|
628
692
|
callbacks.playwright = {
|
|
629
693
|
handlerCallbackId,
|
|
@@ -963,8 +1027,10 @@ async function createRuntime(state, options = {}, namespaceId) {
|
|
|
963
1027
|
}
|
|
964
1028
|
return {
|
|
965
1029
|
browserConsoleLogs: [...browserConsoleLogs],
|
|
1030
|
+
pageErrors: [...pageErrors],
|
|
966
1031
|
networkRequests: [...networkRequests],
|
|
967
|
-
networkResponses: [...networkResponses]
|
|
1032
|
+
networkResponses: [...networkResponses],
|
|
1033
|
+
requestFailures: [...requestFailures]
|
|
968
1034
|
};
|
|
969
1035
|
},
|
|
970
1036
|
clearCollectedData() {
|
|
@@ -972,8 +1038,10 @@ async function createRuntime(state, options = {}, namespaceId) {
|
|
|
972
1038
|
throw new Error("Playwright not configured. Provide playwright.handler in createRuntime options.");
|
|
973
1039
|
}
|
|
974
1040
|
browserConsoleLogs.length = 0;
|
|
1041
|
+
pageErrors.length = 0;
|
|
975
1042
|
networkRequests.length = 0;
|
|
976
1043
|
networkResponses.length = 0;
|
|
1044
|
+
requestFailures.length = 0;
|
|
977
1045
|
}
|
|
978
1046
|
};
|
|
979
1047
|
return {
|
|
@@ -1027,7 +1095,7 @@ async function createRuntime(state, options = {}, namespaceId) {
|
|
|
1027
1095
|
payload
|
|
1028
1096
|
});
|
|
1029
1097
|
},
|
|
1030
|
-
dispose: async () => {
|
|
1098
|
+
dispose: async (options2) => {
|
|
1031
1099
|
for (const cleanup of pageListenerCleanups) {
|
|
1032
1100
|
cleanup();
|
|
1033
1101
|
}
|
|
@@ -1050,7 +1118,9 @@ async function createRuntime(state, options = {}, namespaceId) {
|
|
|
1050
1118
|
const req = {
|
|
1051
1119
|
type: MessageType.DISPOSE_RUNTIME,
|
|
1052
1120
|
requestId: reqId,
|
|
1053
|
-
isolateId
|
|
1121
|
+
isolateId,
|
|
1122
|
+
hard: options2?.hard === true ? true : undefined,
|
|
1123
|
+
reason: typeof options2?.reason === "string" && options2.reason.length > 0 ? options2.reason : undefined
|
|
1054
1124
|
};
|
|
1055
1125
|
try {
|
|
1056
1126
|
await sendRequest(state, req);
|
|
@@ -1740,4 +1810,4 @@ export {
|
|
|
1740
1810
|
connect
|
|
1741
1811
|
};
|
|
1742
1812
|
|
|
1743
|
-
//# debugId=
|
|
1813
|
+
//# debugId=80B56E46F0C9D9FF64756E2164756E21
|