@ricsam/isolate-playwright 0.1.12 → 0.1.14

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,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;
@@ -23,7 +23,7 @@ export interface NetworkResponseInfo {
23
23
  */
24
24
  export interface BrowserConsoleLogEntry {
25
25
  level: string;
26
- args: string[];
26
+ stdout: string;
27
27
  timestamp: number;
28
28
  }
29
29
  /**
@@ -31,6 +31,42 @@ 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
+ /** Callback to evaluate a predicate function inside the isolate (used by waitForURL/Request/Response with function predicates) */
55
+ evaluatePredicate?: (predicateId: number, data: unknown) => boolean;
56
+ }
57
+ /**
58
+ * Metadata attached to handlers created by defaultPlaywrightHandler().
59
+ */
60
+ export interface DefaultPlaywrightHandlerMetadata {
61
+ page: import("playwright").Page;
62
+ options?: DefaultPlaywrightHandlerOptions;
63
+ }
64
+ /**
65
+ * Handler created by defaultPlaywrightHandler().
66
+ */
67
+ export type DefaultPlaywrightHandler = PlaywrightCallback & {
68
+ [DEFAULT_PLAYWRIGHT_HANDLER_META]?: DefaultPlaywrightHandlerMetadata;
69
+ };
34
70
  /**
35
71
  * Options for setting up playwright in an isolate.
36
72
  */
@@ -45,15 +81,33 @@ export interface PlaywrightSetupOptions {
45
81
  console?: boolean;
46
82
  /** Unified event callback for all playwright events */
47
83
  onEvent?: (event: import("@ricsam/isolate-protocol").PlaywrightEvent) => void;
48
- }
49
- /**
50
- * @deprecated Use PlaywrightSetupOptions instead
51
- */
52
- export interface PlaywrightOptions {
53
- page: import("playwright").Page;
54
- timeout?: number;
55
- onNetworkRequest?: (info: NetworkRequestInfo) => void;
56
- onNetworkResponse?: (info: NetworkResponseInfo) => void;
84
+ /**
85
+ * Callback to read files for setInputFiles() operations.
86
+ * This allows the host to control which files the isolate can access.
87
+ * If not provided, setInputFiles() with file paths will throw an error.
88
+ */
89
+ readFile?: (filePath: string) => Promise<import("@ricsam/isolate-protocol").PlaywrightFileData> | import("@ricsam/isolate-protocol").PlaywrightFileData;
90
+ /**
91
+ * Callback to write files for screenshot() and pdf() operations with path option.
92
+ * This allows the host to control where files are written.
93
+ * If not provided, screenshot()/pdf() with path option will throw an error.
94
+ */
95
+ writeFile?: (filePath: string, data: Buffer) => Promise<void> | void;
96
+ /**
97
+ * Callback invoked when context.newPage() is called from within the isolate.
98
+ * Host creates/configures the new page. If not provided, newPage() will throw an error.
99
+ * Receives the BrowserContext so you can call context.newPage().
100
+ * @param context - The BrowserContext that requested the new page
101
+ * @returns The new Page object
102
+ */
103
+ createPage?: (context: import("playwright").BrowserContext) => Promise<import("playwright").Page> | import("playwright").Page;
104
+ /**
105
+ * Callback invoked when browser.newContext() is called from within the isolate.
106
+ * Host creates/configures the new context. If not provided, newContext() will throw an error.
107
+ * @param options - Browser context options passed from the isolate
108
+ * @returns The new BrowserContext object
109
+ */
110
+ createContext?: (options?: import("playwright").BrowserContextOptions) => Promise<import("playwright").BrowserContext> | import("playwright").BrowserContext;
57
111
  }
58
112
  export interface PlaywrightHandle {
59
113
  dispose(): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ricsam/isolate-playwright",
3
- "version": "0.1.12",
3
+ "version": "0.1.14",
4
4
  "main": "./dist/cjs/index.cjs",
5
5
  "types": "./dist/types/index.d.ts",
6
6
  "exports": {