@ricsam/isolate 0.1.10 → 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 +257 -18
- package/dist/cjs/bridge/diagnostics.cjs +37 -2
- package/dist/cjs/bridge/diagnostics.cjs.map +3 -3
- package/dist/cjs/bridge/runtime-bindings.cjs +230 -51
- package/dist/cjs/bridge/runtime-bindings.cjs.map +3 -3
- package/dist/cjs/bridge/sandbox-isolate.cjs +464 -0
- package/dist/cjs/bridge/sandbox-isolate.cjs.map +10 -0
- package/dist/cjs/host/create-isolate-host.cjs +130 -25
- package/dist/cjs/host/create-isolate-host.cjs.map +3 -3
- package/dist/cjs/host/nested-host-controller.cjs +369 -0
- package/dist/cjs/host/nested-host-controller.cjs.map +10 -0
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/internal/browser-source.cjs +102 -0
- package/dist/cjs/internal/browser-source.cjs.map +10 -0
- package/dist/cjs/internal/client/connection.cjs +163 -172
- package/dist/cjs/internal/client/connection.cjs.map +3 -3
- package/dist/cjs/internal/daemon/callback-fs-handler.cjs +3 -3
- package/dist/cjs/internal/daemon/callback-fs-handler.cjs.map +3 -3
- package/dist/cjs/internal/daemon/connection.cjs +156 -13
- package/dist/cjs/internal/daemon/connection.cjs.map +3 -3
- package/dist/cjs/internal/playwright/client.cjs +4 -2
- package/dist/cjs/internal/playwright/client.cjs.map +3 -3
- package/dist/cjs/internal/playwright/handler.cjs +298 -25
- package/dist/cjs/internal/playwright/handler.cjs.map +3 -3
- package/dist/cjs/internal/playwright/index.cjs +54 -8
- package/dist/cjs/internal/playwright/index.cjs.map +3 -3
- package/dist/cjs/internal/playwright/types.cjs +3 -1
- package/dist/cjs/internal/playwright/types.cjs.map +3 -3
- package/dist/cjs/internal/protocol/codec.cjs +16 -5
- package/dist/cjs/internal/protocol/codec.cjs.map +3 -3
- package/dist/cjs/internal/protocol/marshalValue.cjs +37 -6
- package/dist/cjs/internal/protocol/marshalValue.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/runtime/index.cjs +377 -22
- package/dist/cjs/internal/runtime/index.cjs.map +3 -3
- package/dist/cjs/internal/typecheck/index.cjs +2 -1
- package/dist/cjs/internal/typecheck/index.cjs.map +3 -3
- package/dist/cjs/internal/typecheck/isolate-types.cjs +218 -13
- package/dist/cjs/internal/typecheck/isolate-types.cjs.map +3 -3
- package/dist/cjs/internal/typecheck/typecheck.cjs +2 -3
- package/dist/cjs/internal/typecheck/typecheck.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/cjs/runtime/script-runtime.cjs +14 -12
- package/dist/cjs/runtime/script-runtime.cjs.map +3 -3
- package/dist/cjs/runtime/test-runtime.cjs +113 -0
- package/dist/cjs/runtime/test-runtime.cjs.map +10 -0
- package/dist/cjs/server/app-server.cjs +16 -9
- package/dist/cjs/server/app-server.cjs.map +3 -3
- package/dist/cjs/typecheck/index.cjs +2 -1
- package/dist/cjs/typecheck/index.cjs.map +3 -3
- package/dist/mjs/bridge/diagnostics.mjs +37 -2
- package/dist/mjs/bridge/diagnostics.mjs.map +3 -3
- package/dist/mjs/bridge/runtime-bindings.mjs +233 -51
- package/dist/mjs/bridge/runtime-bindings.mjs.map +3 -3
- package/dist/mjs/bridge/sandbox-isolate.mjs +424 -0
- package/dist/mjs/bridge/sandbox-isolate.mjs.map +10 -0
- package/dist/mjs/host/create-isolate-host.mjs +132 -25
- package/dist/mjs/host/create-isolate-host.mjs.map +3 -3
- package/dist/mjs/host/nested-host-controller.mjs +333 -0
- package/dist/mjs/host/nested-host-controller.mjs.map +10 -0
- package/dist/mjs/index.mjs.map +1 -1
- package/dist/mjs/internal/browser-source.mjs +62 -0
- package/dist/mjs/internal/browser-source.mjs.map +10 -0
- package/dist/mjs/internal/client/connection.mjs +165 -173
- package/dist/mjs/internal/client/connection.mjs.map +3 -3
- package/dist/mjs/internal/daemon/callback-fs-handler.mjs +3 -3
- package/dist/mjs/internal/daemon/callback-fs-handler.mjs.map +3 -3
- package/dist/mjs/internal/daemon/connection.mjs +156 -13
- package/dist/mjs/internal/daemon/connection.mjs.map +3 -3
- package/dist/mjs/internal/playwright/client.mjs +7 -3
- package/dist/mjs/internal/playwright/client.mjs.map +3 -3
- package/dist/mjs/internal/playwright/handler.mjs +300 -26
- package/dist/mjs/internal/playwright/handler.mjs.map +3 -3
- package/dist/mjs/internal/playwright/index.mjs +59 -9
- package/dist/mjs/internal/playwright/index.mjs.map +3 -3
- package/dist/mjs/internal/playwright/types.mjs +3 -1
- package/dist/mjs/internal/playwright/types.mjs.map +3 -3
- package/dist/mjs/internal/protocol/codec.mjs +16 -5
- package/dist/mjs/internal/protocol/codec.mjs.map +3 -3
- package/dist/mjs/internal/protocol/marshalValue.mjs +38 -6
- package/dist/mjs/internal/protocol/marshalValue.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/runtime/index.mjs +377 -22
- package/dist/mjs/internal/runtime/index.mjs.map +3 -3
- package/dist/mjs/internal/typecheck/index.mjs +3 -1
- package/dist/mjs/internal/typecheck/index.mjs.map +3 -3
- package/dist/mjs/internal/typecheck/isolate-types.mjs +218 -13
- package/dist/mjs/internal/typecheck/isolate-types.mjs.map +3 -3
- package/dist/mjs/internal/typecheck/typecheck.mjs +2 -3
- package/dist/mjs/internal/typecheck/typecheck.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/mjs/runtime/script-runtime.mjs +16 -12
- package/dist/mjs/runtime/script-runtime.mjs.map +3 -3
- package/dist/mjs/runtime/test-runtime.mjs +78 -0
- package/dist/mjs/runtime/test-runtime.mjs.map +10 -0
- package/dist/mjs/server/app-server.mjs +23 -11
- package/dist/mjs/server/app-server.mjs.map +3 -3
- package/dist/mjs/typecheck/index.mjs +2 -1
- package/dist/mjs/typecheck/index.mjs.map +3 -3
- package/dist/types/bridge/diagnostics.d.ts +6 -1
- package/dist/types/bridge/runtime-bindings.d.ts +5 -1
- package/dist/types/bridge/sandbox-isolate.d.ts +21 -0
- package/dist/types/host/nested-host-controller.d.ts +15 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/internal/browser-source.d.ts +10 -0
- package/dist/types/internal/client/types.d.ts +9 -0
- package/dist/types/internal/daemon/types.d.ts +0 -2
- package/dist/types/internal/playwright/client.d.ts +2 -2
- package/dist/types/internal/playwright/handler.d.ts +27 -4
- package/dist/types/internal/playwright/index.d.ts +2 -2
- package/dist/types/internal/playwright/types.d.ts +33 -1
- package/dist/types/internal/protocol/codec.d.ts +12 -2
- package/dist/types/internal/protocol/marshalValue.d.ts +3 -2
- package/dist/types/internal/protocol/types.d.ts +33 -2
- package/dist/types/internal/runtime/index.d.ts +5 -0
- package/dist/types/internal/typecheck/index.d.ts +1 -1
- package/dist/types/internal/typecheck/isolate-types.d.ts +6 -4
- package/dist/types/internal/typecheck/typecheck.d.ts +1 -1
- package/dist/types/playwright.d.ts +26 -0
- package/dist/types/runtime/namespaced-runtime.d.ts +11 -0
- package/dist/types/runtime/script-runtime.d.ts +2 -1
- package/dist/types/runtime/test-runtime.d.ts +4 -0
- package/dist/types/server/app-server.d.ts +2 -1
- package/dist/types/types.d.ts +75 -33
- package/package.json +8 -3
- package/dist/cjs/browser/browser-runtime.cjs +0 -157
- package/dist/cjs/browser/browser-runtime.cjs.map +0 -10
- package/dist/mjs/browser/browser-runtime.mjs +0 -93
- package/dist/mjs/browser/browser-runtime.mjs.map +0 -10
- package/dist/types/browser/browser-runtime.d.ts +0 -3
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { NestedHostBindings } from "../bridge/sandbox-isolate.ts";
|
|
2
|
+
import { type BrowserSource } from "../internal/browser-source.ts";
|
|
3
|
+
import type { AppServer, CreateAppServerOptions, CreateNamespacedRuntimeOptions, CreateRuntimeOptions, CreateTestRuntimeOptions, NamespacedRuntime, ScriptRuntime, TestRuntime } from "../types.ts";
|
|
4
|
+
interface NestedHostFactory {
|
|
5
|
+
createRuntime(options: CreateRuntimeOptions): Promise<ScriptRuntime>;
|
|
6
|
+
createAppServer(options: CreateAppServerOptions): Promise<AppServer>;
|
|
7
|
+
createTestRuntime(options: CreateTestRuntimeOptions): Promise<TestRuntime>;
|
|
8
|
+
getNamespacedRuntime(key: string, options: CreateNamespacedRuntimeOptions): Promise<NamespacedRuntime>;
|
|
9
|
+
disposeNamespace(key: string, options?: {
|
|
10
|
+
reason?: string;
|
|
11
|
+
}): Promise<void>;
|
|
12
|
+
isConnected(): boolean;
|
|
13
|
+
}
|
|
14
|
+
export declare function createNestedHostBindings(factory: NestedHostFactory, defaultBrowserSource: BrowserSource | undefined): NestedHostBindings;
|
|
15
|
+
export {};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -2,4 +2,4 @@ export { createIsolateHost } from "./host/index.ts";
|
|
|
2
2
|
export { createModuleResolver } from "./modules/index.ts";
|
|
3
3
|
export { createFileBindings } from "./files/index.ts";
|
|
4
4
|
export { getTypeProfile, typecheck, formatTypecheckErrors } from "./typecheck/index.ts";
|
|
5
|
-
export type { AppServer,
|
|
5
|
+
export type { AppServer, BrowserDiagnostics, ConsoleEntry, CreateAppServerOptions, CreateIsolateHostOptions, CreateNamespacedRuntimeOptions, CreateRuntimeOptions, CreateTestRuntimeOptions, FileBindings, HostBindings, HostBrowserBindings, HostBrowserFactoryBindings, HostBrowserHandlerBindings, HostCallContext, IsolateHost, ModuleImporter, ModuleResolveResult, ModuleResolver, NamespacedRuntime, ModuleResolverFallback, ModuleResolverSourceLoader, ModuleSource, PlaywrightEvent, RequestResult, RuntimeResourceDiagnostics, RunResults, ScriptRuntime, TestDiagnostics, TestEvent, TestRuntime, TestRuntimeDiagnostics, ToolBindings, ToolHandler, RuntimeDiagnostics, TypeCapability, TypeProfile, TypeProfileName, TypecheckRequest, WebSocketUpgradeData, } from "./types.ts";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { HostBrowserBindings } from "../types.ts";
|
|
2
|
+
export declare const ISOLATE_BROWSER_DESCRIPTOR_PROPERTY = "__isolateBrowserBinding";
|
|
3
|
+
export declare const ISOLATE_BROWSER_DESCRIPTOR_VALUE = "default";
|
|
4
|
+
export type BrowserSource = HostBrowserBindings;
|
|
5
|
+
export declare function isBrowserBindingLike(value: unknown): value is HostBrowserBindings;
|
|
6
|
+
export declare function isDefaultBrowserDescriptor(value: unknown): boolean;
|
|
7
|
+
export declare function createBrowserSourceFromBindings(browser: HostBrowserBindings | undefined): BrowserSource | undefined;
|
|
8
|
+
export declare function createBrowserSourceFromUnknown(browser: unknown): BrowserSource | undefined;
|
|
9
|
+
export declare function requireBrowserSource(source: BrowserSource | undefined, operation: string): BrowserSource;
|
|
10
|
+
export declare function cloneBrowserDescriptor(): Record<string, string>;
|
|
@@ -47,6 +47,10 @@ export interface DaemonConnection {
|
|
|
47
47
|
createRuntime(options?: RuntimeOptions): Promise<RemoteRuntime>;
|
|
48
48
|
/** Create a namespace for runtime pooling/reuse */
|
|
49
49
|
createNamespace(id: string): Namespace;
|
|
50
|
+
/** Permanently delete the runtime currently associated with a namespace key */
|
|
51
|
+
disposeNamespace(id: string, options?: {
|
|
52
|
+
reason?: string;
|
|
53
|
+
}): Promise<void>;
|
|
50
54
|
/** Close the connection */
|
|
51
55
|
close(): Promise<void>;
|
|
52
56
|
/** Check if connected */
|
|
@@ -193,6 +197,11 @@ export interface RemoteTestEnvironmentHandle {
|
|
|
193
197
|
export interface RemotePlaywrightHandle {
|
|
194
198
|
/** Get collected browser console logs and network data */
|
|
195
199
|
getCollectedData(): CollectedData;
|
|
200
|
+
/** Get tracked browser context/page ids */
|
|
201
|
+
getTrackedResources(): {
|
|
202
|
+
contexts: string[];
|
|
203
|
+
pages: string[];
|
|
204
|
+
};
|
|
196
205
|
/** Clear collected data */
|
|
197
206
|
clearCollectedData(): void;
|
|
198
207
|
}
|
|
@@ -61,8 +61,6 @@ export interface IsolateInstance {
|
|
|
61
61
|
returnedPromises?: Map<number, Promise<unknown>>;
|
|
62
62
|
/** Async iterators returned by custom function calls (iterable from isolate) */
|
|
63
63
|
returnedIterators?: Map<number, AsyncIterator<unknown>>;
|
|
64
|
-
/** Next ID for daemon-local callback registration (starts at high number to avoid conflicts) */
|
|
65
|
-
nextLocalCallbackId?: number;
|
|
66
64
|
/** Namespace ID for pooling/reuse (if set, runtime is cached on dispose) */
|
|
67
65
|
namespaceId?: string;
|
|
68
66
|
/** Whether this runtime is soft-deleted (disposed but cached for reuse) */
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
* Client-safe exports for ./index.ts
|
|
3
3
|
* This module can be imported without loading isolated-vm
|
|
4
4
|
*/
|
|
5
|
-
export type { NetworkRequestInfo, NetworkResponseInfo, BrowserConsoleLogEntry, PageErrorInfo, RequestFailureInfo, DefaultPlaywrightHandler, DefaultPlaywrightHandlerMetadata, DefaultPlaywrightHandlerOptions, PlaywrightSetupOptions, PlaywrightHandle, PlaywrightCallback, } from "./types.ts";
|
|
5
|
+
export type { NetworkRequestInfo, NetworkResponseInfo, BrowserConsoleLogEntry, PageErrorInfo, RequestFailureInfo, DefaultPlaywrightHandler, DefaultPlaywrightHandlerMetadata, DefaultPlaywrightHandlerOptions, PlaywrightCollector, PlaywrightHandlerMetadata, PlaywrightSetupOptions, PlaywrightHandle, PlaywrightCallback, } from "./types.ts";
|
|
6
6
|
export type { PlaywrightOperation, PlaywrightResult, PlaywrightEvent, PlaywrightFileData } from "../protocol/index.ts";
|
|
7
|
-
export { createPlaywrightHandler, defaultPlaywrightHandler, getDefaultPlaywrightHandlerMetadata, } from "./handler.ts";
|
|
7
|
+
export { createPlaywrightHandler, createPlaywrightFactoryHandler, defaultPlaywrightHandler, getDefaultPlaywrightHandlerMetadata, getPlaywrightHandlerMetadata, } from "./handler.ts";
|
|
@@ -3,13 +3,22 @@
|
|
|
3
3
|
* Used by both index.ts (with isolated-vm) and client.ts (without isolated-vm)
|
|
4
4
|
*/
|
|
5
5
|
import type { Page, Locator as PlaywrightLocator, BrowserContext, Response } from "playwright";
|
|
6
|
-
import
|
|
6
|
+
import type { CollectedData, PlaywrightEvent } from "../protocol/index.ts";
|
|
7
|
+
import { type DefaultPlaywrightHandlerMetadata, type DefaultPlaywrightHandlerOptions, type PlaywrightCallback, type PlaywrightHandlerMetadata, type PlaywrightSetupOptions } from "./types.ts";
|
|
7
8
|
type ReadFileCallback = NonNullable<PlaywrightSetupOptions['readFile']>;
|
|
8
9
|
type WriteFileCallback = NonNullable<PlaywrightSetupOptions['writeFile']>;
|
|
9
10
|
export interface FileIOCallbacks {
|
|
10
11
|
readFile?: ReadFileCallback;
|
|
11
12
|
writeFile?: WriteFileCallback;
|
|
12
13
|
}
|
|
14
|
+
interface CollectorContextRecord {
|
|
15
|
+
context: BrowserContext;
|
|
16
|
+
pageIds: Set<string>;
|
|
17
|
+
}
|
|
18
|
+
interface CollectorPageRecord {
|
|
19
|
+
page: Page;
|
|
20
|
+
contextId: string;
|
|
21
|
+
}
|
|
13
22
|
export declare function getLocator(page: Page, selectorType: string, selectorValue: string, optionsJson: string | null): PlaywrightLocator;
|
|
14
23
|
export declare function executeLocatorAction(locator: PlaywrightLocator, action: string, actionArg: unknown, timeout: number, fileIO?: FileIOCallbacks): Promise<unknown>;
|
|
15
24
|
export declare function executeExpectAssertion(locator: PlaywrightLocator, matcher: string, expected: unknown, negated: boolean, timeout: number): Promise<void>;
|
|
@@ -18,25 +27,39 @@ export declare function executePageExpectAssertion(page: Page, matcher: string,
|
|
|
18
27
|
* Registry for tracking multiple pages and contexts.
|
|
19
28
|
*/
|
|
20
29
|
export interface PlaywrightRegistry {
|
|
21
|
-
pages: Map<string,
|
|
22
|
-
contexts: Map<string,
|
|
30
|
+
pages: Map<string, CollectorPageRecord>;
|
|
31
|
+
contexts: Map<string, CollectorContextRecord>;
|
|
32
|
+
pageIdsByObject: WeakMap<Page, string>;
|
|
33
|
+
contextIdsByObject: WeakMap<BrowserContext, string>;
|
|
23
34
|
nextPageId: number;
|
|
24
35
|
nextContextId: number;
|
|
36
|
+
nextRequestId: number;
|
|
25
37
|
pendingResponses: Map<string, Promise<Response>>;
|
|
26
38
|
pendingRequests: Map<string, Promise<import("playwright").Request>>;
|
|
27
39
|
nextListenerId: number;
|
|
40
|
+
requestIds: WeakMap<object, string>;
|
|
41
|
+
pageListenerCleanups: Map<string, () => void>;
|
|
42
|
+
contextListenerCleanups: Map<string, () => void>;
|
|
43
|
+
eventSubscribers: Set<(event: PlaywrightEvent) => void>;
|
|
44
|
+
collectedData: CollectedData;
|
|
28
45
|
}
|
|
29
46
|
/**
|
|
30
47
|
* Create a playwright handler from a Page object.
|
|
31
48
|
* This handler is called by the daemon (via callback) when sandbox needs page operations.
|
|
32
49
|
* Used for remote runtime where the browser runs on the client.
|
|
33
50
|
*/
|
|
34
|
-
export declare function createPlaywrightHandler(page: Page, options?: DefaultPlaywrightHandlerOptions): PlaywrightCallback;
|
|
51
|
+
export declare function createPlaywrightHandler(page: Page | undefined, options?: DefaultPlaywrightHandlerOptions): PlaywrightCallback;
|
|
35
52
|
/**
|
|
36
53
|
* Public helper for handler-first runtime options.
|
|
37
54
|
* Adds metadata used by adapters for local event capture and collected data.
|
|
38
55
|
*/
|
|
39
56
|
export declare function defaultPlaywrightHandler(page: Page, options?: DefaultPlaywrightHandlerOptions): PlaywrightCallback;
|
|
57
|
+
/**
|
|
58
|
+
* Handler-first factory for contexts/pages without a default page.
|
|
59
|
+
* Used by browser bindings that expose only a stable browser object.
|
|
60
|
+
*/
|
|
61
|
+
export declare function createPlaywrightFactoryHandler(options?: DefaultPlaywrightHandlerOptions): PlaywrightCallback;
|
|
62
|
+
export declare function getPlaywrightHandlerMetadata(handler: PlaywrightCallback): PlaywrightHandlerMetadata | undefined;
|
|
40
63
|
/**
|
|
41
64
|
* Extract metadata from handlers created by defaultPlaywrightHandler().
|
|
42
65
|
*/
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import ivm from "@ricsam/isolated-vm";
|
|
2
2
|
import { DEFAULT_PLAYWRIGHT_HANDLER_META } from "./types.ts";
|
|
3
|
-
export { createPlaywrightHandler, defaultPlaywrightHandler, getDefaultPlaywrightHandlerMetadata, } from "./handler.ts";
|
|
3
|
+
export { createPlaywrightHandler, defaultPlaywrightHandler, getDefaultPlaywrightHandlerMetadata, getPlaywrightHandlerMetadata, } from "./handler.ts";
|
|
4
4
|
export type { PlaywrightOperation, PlaywrightResult, PlaywrightEvent, PlaywrightFileData } from "../protocol/index.ts";
|
|
5
5
|
export { DEFAULT_PLAYWRIGHT_HANDLER_META };
|
|
6
|
-
export type { NetworkRequestInfo, NetworkResponseInfo, BrowserConsoleLogEntry, PageErrorInfo, RequestFailureInfo, PlaywrightCallback, PlaywrightSetupOptions, PlaywrightHandle, } from "./types.ts";
|
|
6
|
+
export type { NetworkRequestInfo, NetworkResponseInfo, BrowserConsoleLogEntry, PageErrorInfo, RequestFailureInfo, PlaywrightCallback, PlaywrightHandlerMetadata, PlaywrightSetupOptions, PlaywrightHandle, } from "./types.ts";
|
|
7
7
|
import type { PlaywrightSetupOptions, PlaywrightHandle } from "./types.ts";
|
|
8
8
|
/**
|
|
9
9
|
* Set up playwright in an isolate context.
|
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
* Client-safe types for ./index.ts
|
|
3
3
|
* This module can be imported without loading isolated-vm
|
|
4
4
|
*/
|
|
5
|
-
export type { PlaywrightOperation, PlaywrightResult, PlaywrightEvent, PlaywrightFileData, } from "../protocol/index.ts";
|
|
5
|
+
export type { PlaywrightOperation, PlaywrightResult, PlaywrightEvent, PlaywrightFileData, CollectedData, ConsoleEntry, } from "../protocol/index.ts";
|
|
6
6
|
export interface NetworkRequestInfo {
|
|
7
|
+
contextId: string;
|
|
8
|
+
pageId: string;
|
|
7
9
|
requestId: string;
|
|
8
10
|
url: string;
|
|
9
11
|
method: string;
|
|
@@ -13,6 +15,8 @@ export interface NetworkRequestInfo {
|
|
|
13
15
|
timestamp: number;
|
|
14
16
|
}
|
|
15
17
|
export interface NetworkResponseInfo {
|
|
18
|
+
contextId: string;
|
|
19
|
+
pageId: string;
|
|
16
20
|
requestId: string;
|
|
17
21
|
url: string;
|
|
18
22
|
status: number;
|
|
@@ -25,6 +29,8 @@ export interface NetworkResponseInfo {
|
|
|
25
29
|
* Browser console log entry - logs from the page context (not sandbox).
|
|
26
30
|
*/
|
|
27
31
|
export interface BrowserConsoleLogEntry {
|
|
32
|
+
contextId: string;
|
|
33
|
+
pageId: string;
|
|
28
34
|
level: string;
|
|
29
35
|
stdout: string;
|
|
30
36
|
location?: {
|
|
@@ -35,12 +41,16 @@ export interface BrowserConsoleLogEntry {
|
|
|
35
41
|
timestamp: number;
|
|
36
42
|
}
|
|
37
43
|
export interface PageErrorInfo {
|
|
44
|
+
contextId: string;
|
|
45
|
+
pageId: string;
|
|
38
46
|
name: string;
|
|
39
47
|
message: string;
|
|
40
48
|
stack?: string;
|
|
41
49
|
timestamp: number;
|
|
42
50
|
}
|
|
43
51
|
export interface RequestFailureInfo {
|
|
52
|
+
contextId: string;
|
|
53
|
+
pageId: string;
|
|
44
54
|
requestId: string;
|
|
45
55
|
url: string;
|
|
46
56
|
method: string;
|
|
@@ -83,12 +93,28 @@ export interface DefaultPlaywrightHandlerMetadata {
|
|
|
83
93
|
page: import("playwright").Page;
|
|
84
94
|
options?: DefaultPlaywrightHandlerOptions;
|
|
85
95
|
}
|
|
96
|
+
export interface PlaywrightCollector {
|
|
97
|
+
getCollectedData(): import("../protocol/index.ts").CollectedData;
|
|
98
|
+
getTrackedResources(): {
|
|
99
|
+
contexts: string[];
|
|
100
|
+
pages: string[];
|
|
101
|
+
};
|
|
102
|
+
clearCollectedData(): void;
|
|
103
|
+
onEvent(callback: (event: import("../protocol/index.ts").PlaywrightEvent) => void): () => void;
|
|
104
|
+
}
|
|
105
|
+
export interface PlaywrightHandlerMetadata {
|
|
106
|
+
collector: PlaywrightCollector;
|
|
107
|
+
}
|
|
86
108
|
/**
|
|
87
109
|
* Handler created by defaultPlaywrightHandler().
|
|
88
110
|
*/
|
|
89
111
|
export type DefaultPlaywrightHandler = PlaywrightCallback & {
|
|
90
112
|
[DEFAULT_PLAYWRIGHT_HANDLER_META]?: DefaultPlaywrightHandlerMetadata;
|
|
91
113
|
};
|
|
114
|
+
export declare const PLAYWRIGHT_HANDLER_META: unique symbol;
|
|
115
|
+
export type InstrumentedPlaywrightHandler = PlaywrightCallback & {
|
|
116
|
+
[PLAYWRIGHT_HANDLER_META]?: PlaywrightHandlerMetadata;
|
|
117
|
+
};
|
|
92
118
|
/**
|
|
93
119
|
* Options for setting up playwright in an isolate.
|
|
94
120
|
*/
|
|
@@ -97,6 +123,8 @@ export interface PlaywrightSetupOptions {
|
|
|
97
123
|
page?: import("playwright").Page;
|
|
98
124
|
/** Handler callback (for remote use - daemon invokes this) */
|
|
99
125
|
handler?: PlaywrightCallback;
|
|
126
|
+
/** Whether the isolate should expose default page/context globals. */
|
|
127
|
+
hasDefaultPage?: boolean;
|
|
100
128
|
/** Default timeout for operations */
|
|
101
129
|
timeout?: number;
|
|
102
130
|
/** If true, browser console logs are printed to stdout */
|
|
@@ -141,5 +169,9 @@ export interface PlaywrightHandle {
|
|
|
141
169
|
getNetworkResponses(): NetworkResponseInfo[];
|
|
142
170
|
/** Get network request failures (DNS, abort, connection reset, etc.) */
|
|
143
171
|
getRequestFailures(): RequestFailureInfo[];
|
|
172
|
+
getTrackedResources(): {
|
|
173
|
+
contexts: string[];
|
|
174
|
+
pages: string[];
|
|
175
|
+
};
|
|
144
176
|
clearCollected(): void;
|
|
145
177
|
}
|
|
@@ -55,6 +55,7 @@ export interface IsolateRef {
|
|
|
55
55
|
export interface CallbackRef {
|
|
56
56
|
__type: "CallbackRef";
|
|
57
57
|
callbackId: number;
|
|
58
|
+
callbackKind?: "asyncGenerator";
|
|
58
59
|
}
|
|
59
60
|
/**
|
|
60
61
|
* Represents a reference to a stream.
|
|
@@ -180,12 +181,20 @@ export interface URLRef {
|
|
|
180
181
|
__type: "URLRef";
|
|
181
182
|
href: string;
|
|
182
183
|
}
|
|
184
|
+
/**
|
|
185
|
+
* Represents a serialized AbortSignal snapshot.
|
|
186
|
+
*/
|
|
187
|
+
export interface AbortSignalRef {
|
|
188
|
+
__type: "AbortSignalRef";
|
|
189
|
+
aborted: boolean;
|
|
190
|
+
}
|
|
183
191
|
/**
|
|
184
192
|
* Represents a reference to a pending Promise.
|
|
185
193
|
*/
|
|
186
194
|
export interface PromiseRef {
|
|
187
195
|
__type: "PromiseRef";
|
|
188
196
|
promiseId: number;
|
|
197
|
+
__resolveCallbackId?: number;
|
|
189
198
|
}
|
|
190
199
|
/**
|
|
191
200
|
* Represents a reference to an async iterator.
|
|
@@ -197,7 +206,7 @@ export interface AsyncIteratorRef {
|
|
|
197
206
|
__returnCallbackId?: number;
|
|
198
207
|
__throwCallbackId?: number;
|
|
199
208
|
}
|
|
200
|
-
export type ExtensionType = IsolateRef | CallbackRef | StreamRef | ErrorRef | BlobRef | DateRef | RegExpRef | UndefinedRef | BigIntRef | RequestRef | ResponseRef | HeadersRef | FileRef | FormDataRef | URLRef | PromiseRef | AsyncIteratorRef;
|
|
209
|
+
export type ExtensionType = IsolateRef | CallbackRef | StreamRef | ErrorRef | BlobRef | DateRef | RegExpRef | UndefinedRef | BigIntRef | RequestRef | ResponseRef | HeadersRef | FileRef | FormDataRef | URLRef | AbortSignalRef | PromiseRef | AsyncIteratorRef;
|
|
201
210
|
/**
|
|
202
211
|
* Encode a message to MessagePack bytes.
|
|
203
212
|
*/
|
|
@@ -215,7 +224,7 @@ export declare function encodeValue(value: unknown): Uint8Array;
|
|
|
215
224
|
*/
|
|
216
225
|
export declare function decodeValue(data: Uint8Array): unknown;
|
|
217
226
|
export declare function createIsolateRef(isolateId: string): IsolateRef;
|
|
218
|
-
export declare function createCallbackRef(callbackId: number): CallbackRef;
|
|
227
|
+
export declare function createCallbackRef(callbackId: number, callbackKind?: "asyncGenerator"): CallbackRef;
|
|
219
228
|
export declare function createStreamRef(streamId: number, direction: "upload" | "download"): StreamRef;
|
|
220
229
|
export declare function createErrorRef(name: string, message: string, stack?: string, code?: number): ErrorRef;
|
|
221
230
|
export declare function createBlobRef(blobId: number, size: number, type: string): BlobRef;
|
|
@@ -238,5 +247,6 @@ export declare function createHeadersRef(pairs: [string, string][]): HeadersRef;
|
|
|
238
247
|
export declare function createFileRef(name: string, type: string, lastModified: number, data: number[]): FileRef;
|
|
239
248
|
export declare function createFormDataRef(entries: [string, string | FileRef][]): FormDataRef;
|
|
240
249
|
export declare function createURLRef(href: string): URLRef;
|
|
250
|
+
export declare function createAbortSignalRef(aborted: boolean): AbortSignalRef;
|
|
241
251
|
export declare function createPromiseRef(promiseId: number): PromiseRef;
|
|
242
252
|
export declare function createAsyncIteratorRef(iteratorId: number): AsyncIteratorRef;
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* Provides type-preserving serialization for JavaScript types that would
|
|
5
5
|
* otherwise lose fidelity when JSON stringified.
|
|
6
6
|
*/
|
|
7
|
+
import { type PromiseRef, type AsyncIteratorRef } from "./codec.ts";
|
|
7
8
|
/**
|
|
8
9
|
* Error thrown when a value cannot be marshalled.
|
|
9
10
|
*/
|
|
@@ -30,9 +31,9 @@ export interface UnmarshalContext {
|
|
|
30
31
|
/** Get a callback function by ID */
|
|
31
32
|
getCallback?: (id: number) => ((...args: unknown[]) => unknown) | undefined;
|
|
32
33
|
/** Create a proxy Promise for a PromiseRef */
|
|
33
|
-
createPromiseProxy?: (promiseId: number) => Promise<unknown>;
|
|
34
|
+
createPromiseProxy?: (promiseId: number, ref?: PromiseRef) => Promise<unknown>;
|
|
34
35
|
/** Create a proxy AsyncIterator for an AsyncIteratorRef */
|
|
35
|
-
createIteratorProxy?: (iteratorId: number) => AsyncIterator<unknown>;
|
|
36
|
+
createIteratorProxy?: (iteratorId: number, ref?: AsyncIteratorRef) => AsyncIterator<unknown>;
|
|
36
37
|
/** Get a Blob by ID */
|
|
37
38
|
getBlob?: (blobId: number) => Blob | undefined;
|
|
38
39
|
}
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
export declare const MessageType: {
|
|
11
11
|
readonly CREATE_RUNTIME: 1;
|
|
12
12
|
readonly DISPOSE_RUNTIME: 2;
|
|
13
|
+
readonly DISPOSE_NAMESPACE: 6;
|
|
13
14
|
readonly EVAL: 3;
|
|
14
15
|
readonly DISPATCH_REQUEST: 4;
|
|
15
16
|
readonly DISPATCH_REQUEST_ABORT: 5;
|
|
@@ -105,7 +106,7 @@ export interface CustomFunctionRegistrations {
|
|
|
105
106
|
* The client executes this operation on the real Page object.
|
|
106
107
|
*/
|
|
107
108
|
export interface PlaywrightOperation {
|
|
108
|
-
type: "goto" | "reload" | "url" | "title" | "content" | "waitForSelector" | "waitForTimeout" | "waitForLoadState" | "evaluate" | "locatorAction" | "expectLocator" | "expectPage" | "request" | "goBack" | "goForward" | "waitForURL" | "waitForURLPredicate" | "waitForRequestStart" | "waitForRequestFinish" | "waitForRequestPredicateFinish" | "waitForResponseStart" | "waitForResponseFinish" | "waitForResponsePredicateFinish" | "clearCookies" | "screenshot" | "setViewportSize" | "viewportSize" | "emulateMedia" | "setExtraHTTPHeaders" | "bringToFront" | "close" | "isClosed" | "pdf" | "pause" | "frames" | "mainFrame" | "keyboardType" | "keyboardPress" | "keyboardDown" | "keyboardUp" | "keyboardInsertText" | "mouseMove" | "mouseClick" | "mouseDown" | "mouseUp" | "mouseWheel" | "addCookies" | "cookies" | "newContext" | "newPage" | "closeContext";
|
|
109
|
+
type: "goto" | "reload" | "url" | "title" | "content" | "waitForSelector" | "waitForTimeout" | "waitForLoadState" | "evaluate" | "locatorAction" | "expectLocator" | "expectPage" | "request" | "goBack" | "goForward" | "waitForURL" | "waitForURLPredicate" | "waitForRequestStart" | "waitForRequestFinish" | "waitForRequestPredicateFinish" | "waitForResponseStart" | "waitForResponseFinish" | "waitForResponsePredicateFinish" | "clearCookies" | "screenshot" | "setViewportSize" | "viewportSize" | "emulateMedia" | "setExtraHTTPHeaders" | "bringToFront" | "close" | "isClosed" | "pdf" | "pause" | "frames" | "mainFrame" | "keyboardType" | "keyboardPress" | "keyboardDown" | "keyboardUp" | "keyboardInsertText" | "mouseMove" | "mouseClick" | "mouseDown" | "mouseUp" | "mouseWheel" | "addCookies" | "cookies" | "contexts" | "pages" | "newContext" | "newPage" | "closeContext";
|
|
109
110
|
args: unknown[];
|
|
110
111
|
/** Target page ID (undefined = default page "page_0") */
|
|
111
112
|
pageId?: string;
|
|
@@ -161,6 +162,8 @@ export interface TestEnvironmentOptionsProtocol {
|
|
|
161
162
|
export interface PlaywrightOptionsProtocol {
|
|
162
163
|
/** Default timeout for Playwright operations in ms */
|
|
163
164
|
timeout?: number;
|
|
165
|
+
/** Whether the isolate should expose default page/context globals. */
|
|
166
|
+
hasDefaultPage?: boolean;
|
|
164
167
|
}
|
|
165
168
|
export interface CreateRuntimeRequest extends BaseMessage {
|
|
166
169
|
type: typeof MessageType.CREATE_RUNTIME;
|
|
@@ -186,6 +189,12 @@ export interface DisposeRuntimeRequest extends BaseMessage {
|
|
|
186
189
|
/** Optional caller-supplied reason for disposal, used for diagnostics/logging. */
|
|
187
190
|
reason?: string;
|
|
188
191
|
}
|
|
192
|
+
export interface DisposeNamespaceRequest extends BaseMessage {
|
|
193
|
+
type: typeof MessageType.DISPOSE_NAMESPACE;
|
|
194
|
+
namespaceId: string;
|
|
195
|
+
/** Optional caller-supplied reason for disposal, used for diagnostics/logging. */
|
|
196
|
+
reason?: string;
|
|
197
|
+
}
|
|
189
198
|
export interface EvalRequest extends BaseMessage {
|
|
190
199
|
type: typeof MessageType.EVAL;
|
|
191
200
|
isolateId: string;
|
|
@@ -509,6 +518,8 @@ export interface WsClientErrorPayload {
|
|
|
509
518
|
*/
|
|
510
519
|
export type PlaywrightEvent = {
|
|
511
520
|
type: "browserConsoleLog";
|
|
521
|
+
contextId: string;
|
|
522
|
+
pageId: string;
|
|
512
523
|
level: string;
|
|
513
524
|
stdout: string;
|
|
514
525
|
location?: {
|
|
@@ -519,12 +530,16 @@ export type PlaywrightEvent = {
|
|
|
519
530
|
timestamp: number;
|
|
520
531
|
} | {
|
|
521
532
|
type: "pageError";
|
|
533
|
+
contextId: string;
|
|
534
|
+
pageId: string;
|
|
522
535
|
name: string;
|
|
523
536
|
message: string;
|
|
524
537
|
stack?: string;
|
|
525
538
|
timestamp: number;
|
|
526
539
|
} | {
|
|
527
540
|
type: "networkRequest";
|
|
541
|
+
contextId: string;
|
|
542
|
+
pageId: string;
|
|
528
543
|
requestId: string;
|
|
529
544
|
url: string;
|
|
530
545
|
method: string;
|
|
@@ -534,6 +549,8 @@ export type PlaywrightEvent = {
|
|
|
534
549
|
timestamp: number;
|
|
535
550
|
} | {
|
|
536
551
|
type: "networkResponse";
|
|
552
|
+
contextId: string;
|
|
553
|
+
pageId: string;
|
|
537
554
|
requestId: string;
|
|
538
555
|
url: string;
|
|
539
556
|
status: number;
|
|
@@ -543,6 +560,8 @@ export type PlaywrightEvent = {
|
|
|
543
560
|
timestamp: number;
|
|
544
561
|
} | {
|
|
545
562
|
type: "requestFailure";
|
|
563
|
+
contextId: string;
|
|
564
|
+
pageId: string;
|
|
546
565
|
requestId: string;
|
|
547
566
|
url: string;
|
|
548
567
|
method: string;
|
|
@@ -556,7 +575,7 @@ export interface PingMessage {
|
|
|
556
575
|
export interface PongMessage {
|
|
557
576
|
type: typeof MessageType.PONG;
|
|
558
577
|
}
|
|
559
|
-
export type ClientMessage = CreateRuntimeRequest | DisposeRuntimeRequest | EvalRequest | DispatchRequestRequest | DispatchRequestAbort | WsOpenRequest | WsMessageRequest | WsCloseRequest | FetchGetUpgradeRequestRequest | FetchHasServeHandlerRequest | FetchHasActiveConnectionsRequest | FetchWsErrorRequest | TimersClearAllRequest | ConsoleResetRequest | ConsoleGetTimersRequest | ConsoleGetCountersRequest | ConsoleGetGroupDepthRequest | RunTestsRequest | ResetTestEnvRequest | HasTestsRequest | GetTestCountRequest | GetCollectedDataRequest | ClearCollectedDataRequest | CallbackResponseMsg | CallbackStreamStart | CallbackStreamChunk | CallbackStreamEnd | CallbackStreamCancel | StreamPush | StreamPull | StreamClose | StreamError | ClientEventMessage | PingMessage;
|
|
578
|
+
export type ClientMessage = CreateRuntimeRequest | DisposeRuntimeRequest | DisposeNamespaceRequest | EvalRequest | DispatchRequestRequest | DispatchRequestAbort | WsOpenRequest | WsMessageRequest | WsCloseRequest | FetchGetUpgradeRequestRequest | FetchHasServeHandlerRequest | FetchHasActiveConnectionsRequest | FetchWsErrorRequest | TimersClearAllRequest | ConsoleResetRequest | ConsoleGetTimersRequest | ConsoleGetCountersRequest | ConsoleGetGroupDepthRequest | RunTestsRequest | ResetTestEnvRequest | HasTestsRequest | GetTestCountRequest | GetCollectedDataRequest | ClearCollectedDataRequest | CallbackResponseMsg | CallbackStreamStart | CallbackStreamChunk | CallbackStreamEnd | CallbackStreamCancel | StreamPush | StreamPull | StreamClose | StreamError | ClientEventMessage | PingMessage;
|
|
560
579
|
export type DaemonMessage = ResponseOk | ResponseError | ResponseStreamStart | ResponseStreamChunk | ResponseStreamEnd | CallbackInvoke | CallbackAbort | StreamPush | StreamPull | StreamClose | StreamError | IsolateEventMessage | PongMessage;
|
|
561
580
|
export type Message = ClientMessage | DaemonMessage;
|
|
562
581
|
/**
|
|
@@ -801,6 +820,8 @@ export interface PlaywrightFileData {
|
|
|
801
820
|
export interface PlaywrightOptions {
|
|
802
821
|
/** Handler callback for Playwright operations (required when playwright is enabled) */
|
|
803
822
|
handler: (op: PlaywrightOperation) => Promise<PlaywrightResult>;
|
|
823
|
+
/** Whether the isolate should expose default page/context globals. */
|
|
824
|
+
hasDefaultPage?: boolean;
|
|
804
825
|
/** Default timeout for operations in ms */
|
|
805
826
|
timeout?: number;
|
|
806
827
|
/** If true, browser console logs are routed through console handler (or printed to stdout if no handler) */
|
|
@@ -927,6 +948,8 @@ export interface PlaywrightTestResult {
|
|
|
927
948
|
export interface CollectedData {
|
|
928
949
|
/** Browser console logs (from the page, not sandbox) */
|
|
929
950
|
browserConsoleLogs: {
|
|
951
|
+
contextId: string;
|
|
952
|
+
pageId: string;
|
|
930
953
|
level: string;
|
|
931
954
|
stdout: string;
|
|
932
955
|
location?: {
|
|
@@ -937,12 +960,16 @@ export interface CollectedData {
|
|
|
937
960
|
timestamp: number;
|
|
938
961
|
}[];
|
|
939
962
|
pageErrors: {
|
|
963
|
+
contextId: string;
|
|
964
|
+
pageId: string;
|
|
940
965
|
name: string;
|
|
941
966
|
message: string;
|
|
942
967
|
stack?: string;
|
|
943
968
|
timestamp: number;
|
|
944
969
|
}[];
|
|
945
970
|
networkRequests: {
|
|
971
|
+
contextId: string;
|
|
972
|
+
pageId: string;
|
|
946
973
|
requestId: string;
|
|
947
974
|
url: string;
|
|
948
975
|
method: string;
|
|
@@ -952,6 +979,8 @@ export interface CollectedData {
|
|
|
952
979
|
timestamp: number;
|
|
953
980
|
}[];
|
|
954
981
|
networkResponses: {
|
|
982
|
+
contextId: string;
|
|
983
|
+
pageId: string;
|
|
955
984
|
requestId: string;
|
|
956
985
|
url: string;
|
|
957
986
|
status: number;
|
|
@@ -961,6 +990,8 @@ export interface CollectedData {
|
|
|
961
990
|
timestamp: number;
|
|
962
991
|
}[];
|
|
963
992
|
requestFailures: {
|
|
993
|
+
contextId: string;
|
|
994
|
+
pageId: string;
|
|
964
995
|
requestId: string;
|
|
965
996
|
url: string;
|
|
966
997
|
method: string;
|
|
@@ -115,6 +115,11 @@ export interface RuntimeTestEnvironmentHandle {
|
|
|
115
115
|
export interface RuntimePlaywrightHandle {
|
|
116
116
|
/** Get collected browser data (console logs, network requests/responses) */
|
|
117
117
|
getCollectedData(): CollectedData;
|
|
118
|
+
/** Get tracked browser context/page ids */
|
|
119
|
+
getTrackedResources(): {
|
|
120
|
+
contexts: string[];
|
|
121
|
+
pages: string[];
|
|
122
|
+
};
|
|
118
123
|
/** Clear collected browser data */
|
|
119
124
|
clearCollectedData(): void;
|
|
120
125
|
}
|
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Type definitions and type-checking utilities for isolated-vm V8 sandbox code.
|
|
5
5
|
*/
|
|
6
|
-
export { CORE_TYPES, CONSOLE_TYPES, CRYPTO_TYPES, ENCODING_TYPES, FETCH_TYPES, FS_TYPES, PATH_TYPES, TEST_ENV_TYPES, TIMERS_TYPES, PLAYWRIGHT_TYPES, TYPE_DEFINITIONS, type TypeDefinitionKey, } from "./isolate-types.ts";
|
|
6
|
+
export { CORE_TYPES, CONSOLE_TYPES, CRYPTO_TYPES, ENCODING_TYPES, FETCH_TYPES, FS_TYPES, PATH_TYPES, TEST_ENV_TYPES, TIMERS_TYPES, PLAYWRIGHT_TYPES, SANDBOX_ISOLATE_TYPES, TYPE_DEFINITIONS, type TypeDefinitionKey, } from "./isolate-types.ts";
|
|
7
7
|
export { typecheckIsolateCode, formatTypecheckErrors, type TypecheckResult, type TypecheckError, type TypecheckOptions, type LibraryTypes, type LibraryTypeFile, } from "./typecheck.ts";
|