@ricsam/isolate-playwright 0.1.12 → 0.1.13
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 +209 -15
- package/dist/cjs/client.cjs +801 -24
- package/dist/cjs/client.cjs.map +3 -3
- package/dist/cjs/index.cjs +1094 -173
- package/dist/cjs/index.cjs.map +3 -3
- package/dist/cjs/package.json +1 -1
- package/dist/cjs/types.cjs +14 -1
- package/dist/cjs/types.cjs.map +4 -3
- package/dist/mjs/client.mjs +803 -24
- package/dist/mjs/client.mjs.map +3 -3
- package/dist/mjs/index.mjs +1096 -173
- package/dist/mjs/index.mjs.map +3 -3
- package/dist/mjs/package.json +1 -1
- package/dist/mjs/types.mjs +6 -1
- package/dist/mjs/types.mjs.map +4 -3
- package/dist/types/client.d.ts +13 -6
- package/dist/types/index.d.ts +33 -16
- package/dist/types/types.d.ts +62 -10
- package/package.json +1 -1
package/dist/types/index.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import ivm from "isolated-vm";
|
|
2
|
-
import type { Page } from "playwright";
|
|
3
|
-
import type { PlaywrightOperation, PlaywrightResult, PlaywrightEvent } from "@ricsam/isolate-protocol";
|
|
4
|
-
|
|
2
|
+
import type { Page, BrowserContext, BrowserContextOptions } from "playwright";
|
|
3
|
+
import type { PlaywrightOperation, PlaywrightResult, PlaywrightEvent, PlaywrightFileData } from "@ricsam/isolate-protocol";
|
|
4
|
+
import { DEFAULT_PLAYWRIGHT_HANDLER_META, type DefaultPlaywrightHandlerMetadata, type DefaultPlaywrightHandlerOptions } from "./types.ts";
|
|
5
|
+
export type { PlaywrightOperation, PlaywrightResult, PlaywrightEvent, PlaywrightFileData } from "@ricsam/isolate-protocol";
|
|
6
|
+
export { DEFAULT_PLAYWRIGHT_HANDLER_META };
|
|
7
|
+
export type ReadFileCallback = (filePath: string) => Promise<PlaywrightFileData> | PlaywrightFileData;
|
|
8
|
+
export type WriteFileCallback = (filePath: string, data: Buffer) => Promise<void> | void;
|
|
5
9
|
export interface NetworkRequestInfo {
|
|
6
10
|
url: string;
|
|
7
11
|
method: string;
|
|
@@ -44,15 +48,21 @@ export interface PlaywrightSetupOptions {
|
|
|
44
48
|
console?: boolean;
|
|
45
49
|
/** Unified event callback for all playwright events */
|
|
46
50
|
onEvent?: (event: PlaywrightEvent) => void;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
51
|
+
/**
|
|
52
|
+
* Callback invoked when context.newPage() is called from within the isolate.
|
|
53
|
+
* Host creates/configures the new page. If not provided, newPage() will throw an error.
|
|
54
|
+
* Receives the BrowserContext so you can call context.newPage().
|
|
55
|
+
* @param context - The BrowserContext that requested the new page
|
|
56
|
+
* @returns The new Page object
|
|
57
|
+
*/
|
|
58
|
+
createPage?: (context: BrowserContext) => Promise<Page> | Page;
|
|
59
|
+
/**
|
|
60
|
+
* Callback invoked when browser.newContext() is called from within the isolate.
|
|
61
|
+
* Host creates/configures the new context. If not provided, newContext() will throw an error.
|
|
62
|
+
* @param options - Browser context options passed from the isolate
|
|
63
|
+
* @returns The new BrowserContext object
|
|
64
|
+
*/
|
|
65
|
+
createContext?: (options?: BrowserContextOptions) => Promise<BrowserContext> | BrowserContext;
|
|
56
66
|
}
|
|
57
67
|
export interface PlaywrightHandle {
|
|
58
68
|
dispose(): void;
|
|
@@ -67,13 +77,20 @@ export interface PlaywrightHandle {
|
|
|
67
77
|
* This handler is called by the daemon (via callback) when sandbox needs page operations.
|
|
68
78
|
* Used for remote runtime where the browser runs on the client.
|
|
69
79
|
*/
|
|
70
|
-
export declare function createPlaywrightHandler(page: Page, options?:
|
|
71
|
-
|
|
72
|
-
|
|
80
|
+
export declare function createPlaywrightHandler(page: Page, options?: DefaultPlaywrightHandlerOptions): PlaywrightCallback;
|
|
81
|
+
/**
|
|
82
|
+
* Public helper for handler-first runtime options.
|
|
83
|
+
* Adds metadata used by adapter layers for local event capture.
|
|
84
|
+
*/
|
|
85
|
+
export declare function defaultPlaywrightHandler(page: Page, options?: DefaultPlaywrightHandlerOptions): PlaywrightCallback;
|
|
86
|
+
/**
|
|
87
|
+
* Extract metadata from handlers created by defaultPlaywrightHandler().
|
|
88
|
+
*/
|
|
89
|
+
export declare function getDefaultPlaywrightHandlerMetadata(handler: PlaywrightCallback): DefaultPlaywrightHandlerMetadata | undefined;
|
|
73
90
|
/**
|
|
74
91
|
* Set up playwright in an isolate context.
|
|
75
92
|
*
|
|
76
93
|
* For local use: provide `page` option (direct page access)
|
|
77
94
|
* For remote use: provide `handler` option (callback pattern)
|
|
78
95
|
*/
|
|
79
|
-
export declare function setupPlaywright(context: ivm.Context, options: PlaywrightSetupOptions
|
|
96
|
+
export declare function setupPlaywright(context: ivm.Context, options: PlaywrightSetupOptions): Promise<PlaywrightHandle>;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Client-safe types for @ricsam/isolate-playwright
|
|
3
3
|
* This module can be imported without loading isolated-vm
|
|
4
4
|
*/
|
|
5
|
-
export type { PlaywrightOperation, PlaywrightResult, PlaywrightEvent, } from "@ricsam/isolate-protocol";
|
|
5
|
+
export type { PlaywrightOperation, PlaywrightResult, PlaywrightEvent, PlaywrightFileData, } from "@ricsam/isolate-protocol";
|
|
6
6
|
export interface NetworkRequestInfo {
|
|
7
7
|
url: string;
|
|
8
8
|
method: string;
|
|
@@ -31,6 +31,40 @@ export interface BrowserConsoleLogEntry {
|
|
|
31
31
|
* Used for remote execution where the page lives on the client.
|
|
32
32
|
*/
|
|
33
33
|
export type PlaywrightCallback = (op: import("@ricsam/isolate-protocol").PlaywrightOperation) => Promise<import("@ricsam/isolate-protocol").PlaywrightResult>;
|
|
34
|
+
/**
|
|
35
|
+
* Symbol key used to attach metadata to handlers created by
|
|
36
|
+
* defaultPlaywrightHandler(). Enables adapter layers to keep local ergonomics
|
|
37
|
+
* (event capture, collected data) without exposing page-mode in runtime options.
|
|
38
|
+
*/
|
|
39
|
+
export declare const DEFAULT_PLAYWRIGHT_HANDLER_META: unique symbol;
|
|
40
|
+
/**
|
|
41
|
+
* Options for defaultPlaywrightHandler(page, options).
|
|
42
|
+
*/
|
|
43
|
+
export interface DefaultPlaywrightHandlerOptions {
|
|
44
|
+
/** Default timeout for operations */
|
|
45
|
+
timeout?: number;
|
|
46
|
+
/** Callback to read files for setInputFiles() with file paths */
|
|
47
|
+
readFile?: (filePath: string) => Promise<import("@ricsam/isolate-protocol").PlaywrightFileData> | import("@ricsam/isolate-protocol").PlaywrightFileData;
|
|
48
|
+
/** Callback to write files for screenshot()/pdf() with path option */
|
|
49
|
+
writeFile?: (filePath: string, data: Buffer) => Promise<void> | void;
|
|
50
|
+
/** Callback to create new pages when context.newPage() is called */
|
|
51
|
+
createPage?: (context: import("playwright").BrowserContext) => Promise<import("playwright").Page> | import("playwright").Page;
|
|
52
|
+
/** Callback to create new contexts when browser.newContext() is called */
|
|
53
|
+
createContext?: (options?: import("playwright").BrowserContextOptions) => Promise<import("playwright").BrowserContext> | import("playwright").BrowserContext;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Metadata attached to handlers created by defaultPlaywrightHandler().
|
|
57
|
+
*/
|
|
58
|
+
export interface DefaultPlaywrightHandlerMetadata {
|
|
59
|
+
page: import("playwright").Page;
|
|
60
|
+
options?: DefaultPlaywrightHandlerOptions;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Handler created by defaultPlaywrightHandler().
|
|
64
|
+
*/
|
|
65
|
+
export type DefaultPlaywrightHandler = PlaywrightCallback & {
|
|
66
|
+
[DEFAULT_PLAYWRIGHT_HANDLER_META]?: DefaultPlaywrightHandlerMetadata;
|
|
67
|
+
};
|
|
34
68
|
/**
|
|
35
69
|
* Options for setting up playwright in an isolate.
|
|
36
70
|
*/
|
|
@@ -45,15 +79,33 @@ export interface PlaywrightSetupOptions {
|
|
|
45
79
|
console?: boolean;
|
|
46
80
|
/** Unified event callback for all playwright events */
|
|
47
81
|
onEvent?: (event: import("@ricsam/isolate-protocol").PlaywrightEvent) => void;
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
82
|
+
/**
|
|
83
|
+
* Callback to read files for setInputFiles() operations.
|
|
84
|
+
* This allows the host to control which files the isolate can access.
|
|
85
|
+
* If not provided, setInputFiles() with file paths will throw an error.
|
|
86
|
+
*/
|
|
87
|
+
readFile?: (filePath: string) => Promise<import("@ricsam/isolate-protocol").PlaywrightFileData> | import("@ricsam/isolate-protocol").PlaywrightFileData;
|
|
88
|
+
/**
|
|
89
|
+
* Callback to write files for screenshot() and pdf() operations with path option.
|
|
90
|
+
* This allows the host to control where files are written.
|
|
91
|
+
* If not provided, screenshot()/pdf() with path option will throw an error.
|
|
92
|
+
*/
|
|
93
|
+
writeFile?: (filePath: string, data: Buffer) => Promise<void> | void;
|
|
94
|
+
/**
|
|
95
|
+
* Callback invoked when context.newPage() is called from within the isolate.
|
|
96
|
+
* Host creates/configures the new page. If not provided, newPage() will throw an error.
|
|
97
|
+
* Receives the BrowserContext so you can call context.newPage().
|
|
98
|
+
* @param context - The BrowserContext that requested the new page
|
|
99
|
+
* @returns The new Page object
|
|
100
|
+
*/
|
|
101
|
+
createPage?: (context: import("playwright").BrowserContext) => Promise<import("playwright").Page> | import("playwright").Page;
|
|
102
|
+
/**
|
|
103
|
+
* Callback invoked when browser.newContext() is called from within the isolate.
|
|
104
|
+
* Host creates/configures the new context. If not provided, newContext() will throw an error.
|
|
105
|
+
* @param options - Browser context options passed from the isolate
|
|
106
|
+
* @returns The new BrowserContext object
|
|
107
|
+
*/
|
|
108
|
+
createContext?: (options?: import("playwright").BrowserContextOptions) => Promise<import("playwright").BrowserContext> | import("playwright").BrowserContext;
|
|
57
109
|
}
|
|
58
110
|
export interface PlaywrightHandle {
|
|
59
111
|
dispose(): void;
|