@ricsam/isolate 0.1.11 → 0.1.12
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 +86 -1
- package/dist/cjs/bridge/runtime-bindings.cjs +28 -1
- package/dist/cjs/bridge/runtime-bindings.cjs.map +3 -3
- package/dist/cjs/bridge/sandbox-isolate.cjs +100 -1
- package/dist/cjs/bridge/sandbox-isolate.cjs.map +3 -3
- package/dist/cjs/host/create-isolate-host.cjs +80 -1
- package/dist/cjs/host/create-isolate-host.cjs.map +3 -3
- package/dist/cjs/host/nested-host-controller.cjs +61 -3
- package/dist/cjs/host/nested-host-controller.cjs.map +3 -3
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/internal/browser-source.cjs +16 -5
- package/dist/cjs/internal/browser-source.cjs.map +3 -3
- package/dist/cjs/internal/client/connection.cjs +12 -1
- package/dist/cjs/internal/client/connection.cjs.map +3 -3
- package/dist/cjs/internal/daemon/connection.cjs +28 -10
- package/dist/cjs/internal/daemon/connection.cjs.map +3 -3
- package/dist/cjs/internal/protocol/types.cjs +2 -1
- package/dist/cjs/internal/protocol/types.cjs.map +3 -3
- package/dist/cjs/internal/typecheck/isolate-types.cjs +33 -1
- package/dist/cjs/internal/typecheck/isolate-types.cjs.map +3 -3
- package/dist/cjs/package.json +1 -1
- package/dist/cjs/playwright.cjs +76 -0
- package/dist/cjs/playwright.cjs.map +10 -0
- package/dist/cjs/runtime/namespaced-runtime.cjs +181 -0
- package/dist/cjs/runtime/namespaced-runtime.cjs.map +10 -0
- package/dist/mjs/bridge/runtime-bindings.mjs +28 -1
- package/dist/mjs/bridge/runtime-bindings.mjs.map +3 -3
- package/dist/mjs/bridge/sandbox-isolate.mjs +100 -1
- package/dist/mjs/bridge/sandbox-isolate.mjs.map +3 -3
- package/dist/mjs/host/create-isolate-host.mjs +80 -1
- package/dist/mjs/host/create-isolate-host.mjs.map +3 -3
- package/dist/mjs/host/nested-host-controller.mjs +61 -3
- package/dist/mjs/host/nested-host-controller.mjs.map +3 -3
- package/dist/mjs/index.mjs.map +1 -1
- package/dist/mjs/internal/browser-source.mjs +16 -5
- package/dist/mjs/internal/browser-source.mjs.map +3 -3
- package/dist/mjs/internal/client/connection.mjs +12 -1
- package/dist/mjs/internal/client/connection.mjs.map +3 -3
- package/dist/mjs/internal/daemon/connection.mjs +28 -10
- package/dist/mjs/internal/daemon/connection.mjs.map +3 -3
- package/dist/mjs/internal/protocol/types.mjs +2 -1
- package/dist/mjs/internal/protocol/types.mjs.map +3 -3
- package/dist/mjs/internal/typecheck/isolate-types.mjs +33 -1
- package/dist/mjs/internal/typecheck/isolate-types.mjs.map +3 -3
- package/dist/mjs/package.json +1 -1
- package/dist/mjs/playwright.mjs +47 -0
- package/dist/mjs/playwright.mjs.map +10 -0
- package/dist/mjs/runtime/namespaced-runtime.mjs +143 -0
- package/dist/mjs/runtime/namespaced-runtime.mjs.map +10 -0
- package/dist/types/bridge/sandbox-isolate.d.ts +9 -3
- package/dist/types/host/nested-host-controller.d.ts +5 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/internal/browser-source.d.ts +1 -2
- package/dist/types/internal/client/types.d.ts +4 -0
- package/dist/types/internal/protocol/types.d.ts +8 -1
- package/dist/types/internal/typecheck/isolate-types.d.ts +2 -2
- package/dist/types/playwright.d.ts +26 -0
- package/dist/types/runtime/namespaced-runtime.d.ts +11 -0
- package/dist/types/types.d.ts +45 -3
- package/package.json +6 -1
|
@@ -205,6 +205,9 @@ async function handleMessage(message, connection, state) {
|
|
|
205
205
|
case import_protocol.MessageType.DISPOSE_RUNTIME:
|
|
206
206
|
await handleDisposeRuntime(message, connection, state);
|
|
207
207
|
break;
|
|
208
|
+
case import_protocol.MessageType.DISPOSE_NAMESPACE:
|
|
209
|
+
await handleDisposeNamespace(message, connection, state);
|
|
210
|
+
break;
|
|
208
211
|
case import_protocol.MessageType.EVAL:
|
|
209
212
|
await handleEval(message, connection, state);
|
|
210
213
|
break;
|
|
@@ -358,6 +361,7 @@ async function hardDeleteRuntime(instance, state, reason) {
|
|
|
358
361
|
}
|
|
359
362
|
await instance.runtime.dispose();
|
|
360
363
|
} finally {
|
|
364
|
+
detachRuntimeFromOwningConnection(instance, state);
|
|
361
365
|
state.isolates.delete(instance.isolateId);
|
|
362
366
|
if (instance.namespaceId != null) {
|
|
363
367
|
const indexed = state.namespacedRuntimes.get(instance.namespaceId);
|
|
@@ -380,6 +384,12 @@ async function hardDeleteRuntime(instance, state, reason) {
|
|
|
380
384
|
logRuntimeLifecycle(state, wasPooled ? "evicted pooled" : "hard-disposed", instance, reason);
|
|
381
385
|
}
|
|
382
386
|
}
|
|
387
|
+
function detachRuntimeFromOwningConnection(instance, state) {
|
|
388
|
+
if (!instance.ownerConnection) {
|
|
389
|
+
return;
|
|
390
|
+
}
|
|
391
|
+
state.connections.get(instance.ownerConnection)?.isolates.delete(instance.isolateId);
|
|
392
|
+
}
|
|
383
393
|
var RECONNECTION_TIMEOUT_MS = 30000;
|
|
384
394
|
function softDeleteRuntime(instance, state, reason) {
|
|
385
395
|
const runtimeAbortWasAborted = instance.runtimeAbortController?.signal.aborted ?? false;
|
|
@@ -607,14 +617,7 @@ async function handleCreateRuntime(message, connection, state) {
|
|
|
607
617
|
const existing = state.namespacedRuntimes.get(namespaceId);
|
|
608
618
|
if (existing) {
|
|
609
619
|
if (!existing.isDisposed) {
|
|
610
|
-
|
|
611
|
-
sendOk(connection.socket, message.requestId, {
|
|
612
|
-
isolateId: existing.isolateId,
|
|
613
|
-
reused: true
|
|
614
|
-
});
|
|
615
|
-
return;
|
|
616
|
-
}
|
|
617
|
-
sendError(connection.socket, message.requestId, import_protocol.ErrorCode.SCRIPT_ERROR, `Namespace "${namespaceId}" already has an active runtime`);
|
|
620
|
+
sendError(connection.socket, message.requestId, import_protocol.ErrorCode.SCRIPT_ERROR, `Namespace "${namespaceId}" already has an active runtime`, { name: "NamespaceInUseError" });
|
|
618
621
|
return;
|
|
619
622
|
}
|
|
620
623
|
reuseNamespacedRuntime(existing, connection, message, state);
|
|
@@ -625,7 +628,7 @@ async function handleCreateRuntime(message, connection, state) {
|
|
|
625
628
|
return;
|
|
626
629
|
}
|
|
627
630
|
if (state.namespacedCreatesInFlight.has(namespaceId)) {
|
|
628
|
-
sendError(connection.socket, message.requestId, import_protocol.ErrorCode.SCRIPT_ERROR, `Namespace "${namespaceId}" creation already in progress
|
|
631
|
+
sendError(connection.socket, message.requestId, import_protocol.ErrorCode.SCRIPT_ERROR, `Namespace "${namespaceId}" creation already in progress`, { name: "NamespaceInUseError" });
|
|
629
632
|
return;
|
|
630
633
|
}
|
|
631
634
|
state.namespacedCreatesInFlight.add(namespaceId);
|
|
@@ -1189,6 +1192,21 @@ async function handleDisposeRuntime(message, connection, state) {
|
|
|
1189
1192
|
sendError(connection.socket, message.requestId, import_protocol.ErrorCode.SCRIPT_ERROR, error.message, { name: error.name, stack: error.stack });
|
|
1190
1193
|
}
|
|
1191
1194
|
}
|
|
1195
|
+
async function handleDisposeNamespace(message, connection, state) {
|
|
1196
|
+
const instance = state.namespacedRuntimes.get(message.namespaceId);
|
|
1197
|
+
if (!instance) {
|
|
1198
|
+
sendOk(connection.socket, message.requestId);
|
|
1199
|
+
return;
|
|
1200
|
+
}
|
|
1201
|
+
const requestReason = typeof message.reason === "string" && message.reason.length > 0 ? message.reason : "client requested namespace dispose";
|
|
1202
|
+
try {
|
|
1203
|
+
await hardDeleteRuntime(instance, state, requestReason);
|
|
1204
|
+
sendOk(connection.socket, message.requestId);
|
|
1205
|
+
} catch (err) {
|
|
1206
|
+
const error = err;
|
|
1207
|
+
sendError(connection.socket, message.requestId, import_protocol.ErrorCode.SCRIPT_ERROR, error.message, { name: error.name, stack: error.stack });
|
|
1208
|
+
}
|
|
1209
|
+
}
|
|
1192
1210
|
async function handleEval(message, connection, state) {
|
|
1193
1211
|
const instance = state.isolates.get(message.isolateId);
|
|
1194
1212
|
if (!instance) {
|
|
@@ -2233,4 +2251,4 @@ async function handleClearCollectedData(message, connection, state) {
|
|
|
2233
2251
|
}
|
|
2234
2252
|
}
|
|
2235
2253
|
|
|
2236
|
-
//# debugId=
|
|
2254
|
+
//# debugId=B94406A814BB763964756E2164756E21
|