browser-use 0.0.1 → 0.0.2
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/LICENSE +21 -0
- package/README.md +761 -0
- package/dist/agent/cloud-events.d.ts +264 -0
- package/dist/agent/cloud-events.js +318 -0
- package/dist/agent/gif.d.ts +15 -0
- package/dist/agent/gif.js +215 -0
- package/dist/agent/index.d.ts +8 -0
- package/dist/agent/index.js +8 -0
- package/dist/agent/message-manager/service.d.ts +30 -0
- package/dist/agent/message-manager/service.js +208 -0
- package/dist/agent/message-manager/utils.d.ts +2 -0
- package/dist/agent/message-manager/utils.js +41 -0
- package/dist/agent/message-manager/views.d.ts +26 -0
- package/dist/agent/message-manager/views.js +73 -0
- package/dist/agent/prompts.d.ts +52 -0
- package/dist/agent/prompts.js +259 -0
- package/dist/agent/service.d.ts +290 -0
- package/dist/agent/service.js +2200 -0
- package/dist/agent/views.d.ts +741 -0
- package/dist/agent/views.js +537 -0
- package/dist/browser/browser.d.ts +7 -0
- package/dist/browser/browser.js +5 -0
- package/dist/browser/context.d.ts +8 -0
- package/dist/browser/context.js +4 -0
- package/dist/browser/dvd-screensaver.d.ts +101 -0
- package/dist/browser/dvd-screensaver.js +270 -0
- package/dist/browser/extensions.d.ts +63 -0
- package/dist/browser/extensions.js +359 -0
- package/dist/browser/index.d.ts +10 -0
- package/dist/browser/index.js +9 -0
- package/dist/browser/playwright-manager.d.ts +47 -0
- package/dist/browser/playwright-manager.js +146 -0
- package/dist/browser/profile.d.ts +196 -0
- package/dist/browser/profile.js +815 -0
- package/dist/browser/session.d.ts +505 -0
- package/dist/browser/session.js +3409 -0
- package/dist/browser/types.d.ts +1184 -0
- package/dist/browser/types.js +1 -0
- package/dist/browser/utils.d.ts +1 -0
- package/dist/browser/utils.js +19 -0
- package/dist/browser/views.d.ts +78 -0
- package/dist/browser/views.js +72 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +44 -0
- package/dist/config.d.ts +108 -0
- package/dist/config.js +430 -0
- package/dist/controller/index.d.ts +3 -0
- package/dist/controller/index.js +3 -0
- package/dist/controller/registry/index.d.ts +2 -0
- package/dist/controller/registry/index.js +2 -0
- package/dist/controller/registry/service.d.ts +45 -0
- package/dist/controller/registry/service.js +184 -0
- package/dist/controller/registry/views.d.ts +55 -0
- package/dist/controller/registry/views.js +174 -0
- package/dist/controller/service.d.ts +49 -0
- package/dist/controller/service.js +1176 -0
- package/dist/controller/views.d.ts +241 -0
- package/dist/controller/views.js +88 -0
- package/dist/dom/clickable-element-processor/service.d.ts +11 -0
- package/dist/dom/clickable-element-processor/service.js +60 -0
- package/dist/dom/dom_tree/index.js +1400 -0
- package/dist/dom/history-tree-processor/service.d.ts +14 -0
- package/dist/dom/history-tree-processor/service.js +75 -0
- package/dist/dom/history-tree-processor/view.d.ts +54 -0
- package/dist/dom/history-tree-processor/view.js +56 -0
- package/dist/dom/playground/extraction.d.ts +19 -0
- package/dist/dom/playground/extraction.js +187 -0
- package/dist/dom/playground/process-dom.d.ts +1 -0
- package/dist/dom/playground/process-dom.js +5 -0
- package/dist/dom/playground/test-accessibility.d.ts +44 -0
- package/dist/dom/playground/test-accessibility.js +111 -0
- package/dist/dom/service.d.ts +19 -0
- package/dist/dom/service.js +227 -0
- package/dist/dom/utils.d.ts +1 -0
- package/dist/dom/utils.js +6 -0
- package/dist/dom/views.d.ts +61 -0
- package/dist/dom/views.js +247 -0
- package/dist/event-bus.d.ts +11 -0
- package/dist/event-bus.js +19 -0
- package/dist/exceptions.d.ts +10 -0
- package/dist/exceptions.js +22 -0
- package/dist/filesystem/file-system.d.ts +68 -0
- package/dist/filesystem/file-system.js +412 -0
- package/dist/filesystem/index.d.ts +1 -0
- package/dist/filesystem/index.js +1 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.js +33 -0
- package/dist/integrations/gmail/actions.d.ts +12 -0
- package/dist/integrations/gmail/actions.js +113 -0
- package/dist/integrations/gmail/index.d.ts +2 -0
- package/dist/integrations/gmail/index.js +2 -0
- package/dist/integrations/gmail/service.d.ts +61 -0
- package/dist/integrations/gmail/service.js +260 -0
- package/dist/llm/anthropic/chat.d.ts +28 -0
- package/dist/llm/anthropic/chat.js +126 -0
- package/dist/llm/anthropic/index.d.ts +2 -0
- package/dist/llm/anthropic/index.js +2 -0
- package/dist/llm/anthropic/serializer.d.ts +68 -0
- package/dist/llm/anthropic/serializer.js +285 -0
- package/dist/llm/aws/chat-anthropic.d.ts +61 -0
- package/dist/llm/aws/chat-anthropic.js +176 -0
- package/dist/llm/aws/chat-bedrock.d.ts +15 -0
- package/dist/llm/aws/chat-bedrock.js +80 -0
- package/dist/llm/aws/index.d.ts +3 -0
- package/dist/llm/aws/index.js +3 -0
- package/dist/llm/aws/serializer.d.ts +5 -0
- package/dist/llm/aws/serializer.js +68 -0
- package/dist/llm/azure/chat.d.ts +15 -0
- package/dist/llm/azure/chat.js +83 -0
- package/dist/llm/azure/index.d.ts +1 -0
- package/dist/llm/azure/index.js +1 -0
- package/dist/llm/base.d.ts +16 -0
- package/dist/llm/base.js +1 -0
- package/dist/llm/deepseek/chat.d.ts +15 -0
- package/dist/llm/deepseek/chat.js +51 -0
- package/dist/llm/deepseek/index.d.ts +2 -0
- package/dist/llm/deepseek/index.js +2 -0
- package/dist/llm/deepseek/serializer.d.ts +6 -0
- package/dist/llm/deepseek/serializer.js +57 -0
- package/dist/llm/exceptions.d.ts +10 -0
- package/dist/llm/exceptions.js +18 -0
- package/dist/llm/google/chat.d.ts +20 -0
- package/dist/llm/google/chat.js +144 -0
- package/dist/llm/google/index.d.ts +2 -0
- package/dist/llm/google/index.js +2 -0
- package/dist/llm/google/serializer.d.ts +6 -0
- package/dist/llm/google/serializer.js +64 -0
- package/dist/llm/groq/chat.d.ts +15 -0
- package/dist/llm/groq/chat.js +52 -0
- package/dist/llm/groq/index.d.ts +3 -0
- package/dist/llm/groq/index.js +3 -0
- package/dist/llm/groq/parser.d.ts +32 -0
- package/dist/llm/groq/parser.js +189 -0
- package/dist/llm/groq/serializer.d.ts +6 -0
- package/dist/llm/groq/serializer.js +56 -0
- package/dist/llm/messages.d.ts +77 -0
- package/dist/llm/messages.js +157 -0
- package/dist/llm/ollama/chat.d.ts +15 -0
- package/dist/llm/ollama/chat.js +77 -0
- package/dist/llm/ollama/index.d.ts +2 -0
- package/dist/llm/ollama/index.js +2 -0
- package/dist/llm/ollama/serializer.d.ts +6 -0
- package/dist/llm/ollama/serializer.js +53 -0
- package/dist/llm/openai/chat.d.ts +38 -0
- package/dist/llm/openai/chat.js +174 -0
- package/dist/llm/openai/index.d.ts +3 -0
- package/dist/llm/openai/index.js +3 -0
- package/dist/llm/openai/like.d.ts +17 -0
- package/dist/llm/openai/like.js +19 -0
- package/dist/llm/openai/serializer.d.ts +6 -0
- package/dist/llm/openai/serializer.js +57 -0
- package/dist/llm/openrouter/chat.d.ts +15 -0
- package/dist/llm/openrouter/chat.js +74 -0
- package/dist/llm/openrouter/index.d.ts +2 -0
- package/dist/llm/openrouter/index.js +2 -0
- package/dist/llm/openrouter/serializer.d.ts +3 -0
- package/dist/llm/openrouter/serializer.js +3 -0
- package/dist/llm/schema.d.ts +6 -0
- package/dist/llm/schema.js +77 -0
- package/dist/llm/views.d.ts +15 -0
- package/dist/llm/views.js +12 -0
- package/dist/logging-config.d.ts +25 -0
- package/dist/logging-config.js +89 -0
- package/dist/mcp/client.d.ts +142 -0
- package/dist/mcp/client.js +638 -0
- package/dist/mcp/controller.d.ts +6 -0
- package/dist/mcp/controller.js +38 -0
- package/dist/mcp/index.d.ts +3 -0
- package/dist/mcp/index.js +3 -0
- package/dist/mcp/server.d.ts +134 -0
- package/dist/mcp/server.js +759 -0
- package/dist/observability-decorators.d.ts +158 -0
- package/dist/observability-decorators.js +286 -0
- package/dist/observability.d.ts +23 -0
- package/dist/observability.js +58 -0
- package/dist/screenshots/index.d.ts +1 -0
- package/dist/screenshots/index.js +1 -0
- package/dist/screenshots/service.d.ts +6 -0
- package/dist/screenshots/service.js +28 -0
- package/dist/sync/auth.d.ts +27 -0
- package/dist/sync/auth.js +205 -0
- package/dist/sync/index.d.ts +2 -0
- package/dist/sync/index.js +2 -0
- package/dist/sync/service.d.ts +21 -0
- package/dist/sync/service.js +146 -0
- package/dist/telemetry/index.d.ts +2 -0
- package/dist/telemetry/index.js +2 -0
- package/dist/telemetry/service.d.ts +12 -0
- package/dist/telemetry/service.js +85 -0
- package/dist/telemetry/views.d.ts +112 -0
- package/dist/telemetry/views.js +112 -0
- package/dist/tokens/index.d.ts +2 -0
- package/dist/tokens/index.js +2 -0
- package/dist/tokens/service.d.ts +35 -0
- package/dist/tokens/service.js +423 -0
- package/dist/tokens/views.d.ts +58 -0
- package/dist/tokens/views.js +1 -0
- package/dist/utils.d.ts +128 -0
- package/dist/utils.js +529 -0
- package/package.json +94 -5
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './profile.js';
|
|
2
|
+
export * from './views.js';
|
|
3
|
+
export * from './utils.js';
|
|
4
|
+
export * from './session.js';
|
|
5
|
+
export * from './extensions.js';
|
|
6
|
+
export * from './dvd-screensaver.js';
|
|
7
|
+
export * from './playwright-manager.js';
|
|
8
|
+
// Re-export the async playwright loader
|
|
9
|
+
export { async_playwright } from './types.js';
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Playwright Global Singleton Manager
|
|
3
|
+
*
|
|
4
|
+
* Manages Playwright instances at the event loop level to prevent
|
|
5
|
+
* duplicate instantiation and ensure proper resource cleanup.
|
|
6
|
+
*
|
|
7
|
+
* This is important because:
|
|
8
|
+
* 1. Playwright instances are heavy and should be reused
|
|
9
|
+
* 2. Multiple instances can cause port conflicts
|
|
10
|
+
* 3. Proper cleanup prevents resource leaks
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Get or create a Playwright instance for the current event loop
|
|
14
|
+
* Uses singleton pattern to prevent duplicate instances
|
|
15
|
+
*/
|
|
16
|
+
export declare function getPlaywrightInstance(options?: {
|
|
17
|
+
browserType?: 'chromium' | 'firefox' | 'webkit';
|
|
18
|
+
forceNew?: boolean;
|
|
19
|
+
}): Promise<any>;
|
|
20
|
+
/**
|
|
21
|
+
* Release a Playwright instance reference
|
|
22
|
+
* Decrements reference count and cleans up if no more references
|
|
23
|
+
*/
|
|
24
|
+
export declare function releasePlaywrightInstance(browserType?: 'chromium' | 'firefox' | 'webkit'): Promise<void>;
|
|
25
|
+
/**
|
|
26
|
+
* Force cleanup of all Playwright instances
|
|
27
|
+
* Should be called on process exit
|
|
28
|
+
*/
|
|
29
|
+
export declare function cleanupAllPlaywrightInstances(): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* Register a cleanup handler to be called on shutdown
|
|
32
|
+
*/
|
|
33
|
+
export declare function registerCleanupHandler(handler: () => Promise<void>): void;
|
|
34
|
+
/**
|
|
35
|
+
* Unregister a cleanup handler
|
|
36
|
+
*/
|
|
37
|
+
export declare function unregisterCleanupHandler(handler: () => Promise<void>): void;
|
|
38
|
+
/**
|
|
39
|
+
* Get statistics about Playwright instances
|
|
40
|
+
*/
|
|
41
|
+
export declare function getPlaywrightStats(): {
|
|
42
|
+
totalInstances: number;
|
|
43
|
+
instances: Array<{
|
|
44
|
+
key: string;
|
|
45
|
+
refs: number;
|
|
46
|
+
}>;
|
|
47
|
+
};
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Playwright Global Singleton Manager
|
|
3
|
+
*
|
|
4
|
+
* Manages Playwright instances at the event loop level to prevent
|
|
5
|
+
* duplicate instantiation and ensure proper resource cleanup.
|
|
6
|
+
*
|
|
7
|
+
* This is important because:
|
|
8
|
+
* 1. Playwright instances are heavy and should be reused
|
|
9
|
+
* 2. Multiple instances can cause port conflicts
|
|
10
|
+
* 3. Proper cleanup prevents resource leaks
|
|
11
|
+
*/
|
|
12
|
+
import { createLogger } from '../logging-config.js';
|
|
13
|
+
const logger = createLogger('browser_use.playwright_manager');
|
|
14
|
+
// Global registry of Playwright instances keyed by event loop/process
|
|
15
|
+
const playwrightInstances = new Map();
|
|
16
|
+
const instanceRefCounts = new Map();
|
|
17
|
+
// Track cleanup handlers
|
|
18
|
+
const cleanupHandlers = new Set();
|
|
19
|
+
/**
|
|
20
|
+
* Get or create a Playwright instance for the current event loop
|
|
21
|
+
* Uses singleton pattern to prevent duplicate instances
|
|
22
|
+
*/
|
|
23
|
+
export async function getPlaywrightInstance(options = {}) {
|
|
24
|
+
const { browserType = 'chromium', forceNew = false } = options;
|
|
25
|
+
// Use process ID as key for singleton (Node.js is single event loop per process)
|
|
26
|
+
const instanceKey = `${process.pid}-${browserType}`;
|
|
27
|
+
// Return existing instance if available and not forcing new
|
|
28
|
+
if (!forceNew && playwrightInstances.has(instanceKey)) {
|
|
29
|
+
const instance = playwrightInstances.get(instanceKey);
|
|
30
|
+
// Increment reference count
|
|
31
|
+
instanceRefCounts.set(instanceKey, (instanceRefCounts.get(instanceKey) || 0) + 1);
|
|
32
|
+
logger.debug(`Reusing Playwright ${browserType} instance (refs: ${instanceRefCounts.get(instanceKey)})`);
|
|
33
|
+
return instance;
|
|
34
|
+
}
|
|
35
|
+
// Create new instance
|
|
36
|
+
logger.info(`Creating new Playwright ${browserType} instance`);
|
|
37
|
+
try {
|
|
38
|
+
const playwright = await import('playwright');
|
|
39
|
+
const instance = playwright[browserType];
|
|
40
|
+
// Store instance
|
|
41
|
+
playwrightInstances.set(instanceKey, instance);
|
|
42
|
+
instanceRefCounts.set(instanceKey, 1);
|
|
43
|
+
logger.debug(`Playwright ${browserType} instance created successfully`);
|
|
44
|
+
return instance;
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
logger.error(`Failed to create Playwright instance: ${error.message}`);
|
|
48
|
+
throw error;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Release a Playwright instance reference
|
|
53
|
+
* Decrements reference count and cleans up if no more references
|
|
54
|
+
*/
|
|
55
|
+
export async function releasePlaywrightInstance(browserType = 'chromium') {
|
|
56
|
+
const instanceKey = `${process.pid}-${browserType}`;
|
|
57
|
+
if (!playwrightInstances.has(instanceKey)) {
|
|
58
|
+
logger.warning(`Attempted to release non-existent Playwright instance: ${instanceKey}`);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
// Decrement reference count
|
|
62
|
+
const currentRefs = instanceRefCounts.get(instanceKey) || 0;
|
|
63
|
+
const newRefs = Math.max(0, currentRefs - 1);
|
|
64
|
+
instanceRefCounts.set(instanceKey, newRefs);
|
|
65
|
+
logger.debug(`Released Playwright ${browserType} instance reference (refs: ${newRefs})`);
|
|
66
|
+
// If no more references, we could clean up, but Playwright itself doesn't need cleanup
|
|
67
|
+
// The actual browser instances are cleaned up separately
|
|
68
|
+
if (newRefs === 0) {
|
|
69
|
+
logger.debug(`No more references to Playwright ${browserType} instance, keeping for reuse`);
|
|
70
|
+
// We keep the instance for potential reuse rather than deleting it
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Force cleanup of all Playwright instances
|
|
75
|
+
* Should be called on process exit
|
|
76
|
+
*/
|
|
77
|
+
export async function cleanupAllPlaywrightInstances() {
|
|
78
|
+
logger.info(`Cleaning up ${playwrightInstances.size} Playwright instances`);
|
|
79
|
+
// Execute all registered cleanup handlers
|
|
80
|
+
const cleanupPromises = Array.from(cleanupHandlers).map((handler) => handler().catch((error) => {
|
|
81
|
+
logger.error(`Cleanup handler failed: ${error.message}`);
|
|
82
|
+
}));
|
|
83
|
+
await Promise.all(cleanupPromises);
|
|
84
|
+
// Clear registries
|
|
85
|
+
playwrightInstances.clear();
|
|
86
|
+
instanceRefCounts.clear();
|
|
87
|
+
cleanupHandlers.clear();
|
|
88
|
+
logger.info('All Playwright instances cleaned up');
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Register a cleanup handler to be called on shutdown
|
|
92
|
+
*/
|
|
93
|
+
export function registerCleanupHandler(handler) {
|
|
94
|
+
cleanupHandlers.add(handler);
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Unregister a cleanup handler
|
|
98
|
+
*/
|
|
99
|
+
export function unregisterCleanupHandler(handler) {
|
|
100
|
+
cleanupHandlers.delete(handler);
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Get statistics about Playwright instances
|
|
104
|
+
*/
|
|
105
|
+
export function getPlaywrightStats() {
|
|
106
|
+
return {
|
|
107
|
+
totalInstances: playwrightInstances.size,
|
|
108
|
+
instances: Array.from(playwrightInstances.keys()).map((key) => ({
|
|
109
|
+
key,
|
|
110
|
+
refs: instanceRefCounts.get(key) || 0,
|
|
111
|
+
})),
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
// Setup process exit handlers
|
|
115
|
+
let exitHandlersRegistered = false;
|
|
116
|
+
function registerExitHandlers() {
|
|
117
|
+
if (exitHandlersRegistered) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
exitHandlersRegistered = true;
|
|
121
|
+
const exitHandler = async (signal) => {
|
|
122
|
+
logger.debug(`Received ${signal}, cleaning up Playwright instances...`);
|
|
123
|
+
await cleanupAllPlaywrightInstances();
|
|
124
|
+
process.exit(0);
|
|
125
|
+
};
|
|
126
|
+
// Register handlers for various exit signals
|
|
127
|
+
process.on('SIGINT', () => exitHandler('SIGINT'));
|
|
128
|
+
process.on('SIGTERM', () => exitHandler('SIGTERM'));
|
|
129
|
+
process.on('exit', () => {
|
|
130
|
+
// Synchronous cleanup on exit
|
|
131
|
+
logger.debug('Process exiting, Playwright cleanup complete');
|
|
132
|
+
});
|
|
133
|
+
// Handle uncaught exceptions
|
|
134
|
+
process.on('uncaughtException', async (error) => {
|
|
135
|
+
logger.error(`Uncaught exception: ${error.message}`);
|
|
136
|
+
await cleanupAllPlaywrightInstances();
|
|
137
|
+
process.exit(1);
|
|
138
|
+
});
|
|
139
|
+
process.on('unhandledRejection', async (reason) => {
|
|
140
|
+
logger.error(`Unhandled rejection: ${reason}`);
|
|
141
|
+
await cleanupAllPlaywrightInstances();
|
|
142
|
+
process.exit(1);
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
// Auto-register exit handlers on module load
|
|
146
|
+
registerExitHandlers();
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import type { ClientCertificate, Geolocation, HttpCredentials, ProxySettings, ViewportSize, StorageState } from './types.js';
|
|
2
|
+
export declare const CHROME_DEBUG_PORT = 9242;
|
|
3
|
+
export declare const CHROME_DISABLED_COMPONENTS: string[];
|
|
4
|
+
export declare const CHROME_HEADLESS_ARGS: string[];
|
|
5
|
+
export declare const CHROME_DOCKER_ARGS: string[];
|
|
6
|
+
export declare const CHROME_DISABLE_SECURITY_ARGS: string[];
|
|
7
|
+
export declare const CHROME_DETERMINISTIC_RENDERING_ARGS: string[];
|
|
8
|
+
export declare const CHROME_DEFAULT_ARGS: string[];
|
|
9
|
+
export declare const get_display_size: () => ViewportSize | null;
|
|
10
|
+
export declare const get_window_adjustments: () => [number, number];
|
|
11
|
+
export declare enum ColorScheme {
|
|
12
|
+
LIGHT = "light",
|
|
13
|
+
DARK = "dark",
|
|
14
|
+
NO_PREFERENCE = "no-preference",
|
|
15
|
+
NULL = "null"
|
|
16
|
+
}
|
|
17
|
+
export declare enum Contrast {
|
|
18
|
+
NO_PREFERENCE = "no-preference",
|
|
19
|
+
MORE = "more",
|
|
20
|
+
NULL = "null"
|
|
21
|
+
}
|
|
22
|
+
export declare enum ReducedMotion {
|
|
23
|
+
REDUCE = "reduce",
|
|
24
|
+
NO_PREFERENCE = "no-preference",
|
|
25
|
+
NULL = "null"
|
|
26
|
+
}
|
|
27
|
+
export declare enum ForcedColors {
|
|
28
|
+
ACTIVE = "active",
|
|
29
|
+
NONE = "none",
|
|
30
|
+
NULL = "null"
|
|
31
|
+
}
|
|
32
|
+
export declare enum ServiceWorkers {
|
|
33
|
+
ALLOW = "allow",
|
|
34
|
+
BLOCK = "block"
|
|
35
|
+
}
|
|
36
|
+
export declare enum RecordHarContent {
|
|
37
|
+
OMIT = "omit",
|
|
38
|
+
EMBED = "embed",
|
|
39
|
+
ATTACH = "attach"
|
|
40
|
+
}
|
|
41
|
+
export declare enum RecordHarMode {
|
|
42
|
+
FULL = "full",
|
|
43
|
+
MINIMAL = "minimal"
|
|
44
|
+
}
|
|
45
|
+
export declare enum BrowserChannel {
|
|
46
|
+
CHROMIUM = "chromium",
|
|
47
|
+
CHROME = "chrome",
|
|
48
|
+
CHROME_BETA = "chrome-beta",
|
|
49
|
+
CHROME_DEV = "chrome-dev",
|
|
50
|
+
CHROME_CANARY = "chrome-canary",
|
|
51
|
+
MSEDGE = "msedge",
|
|
52
|
+
MSEDGE_BETA = "msedge-beta",
|
|
53
|
+
MSEDGE_DEV = "msedge-dev",
|
|
54
|
+
MSEDGE_CANARY = "msedge-canary"
|
|
55
|
+
}
|
|
56
|
+
export declare const BROWSERUSE_DEFAULT_CHANNEL = BrowserChannel.CHROMIUM;
|
|
57
|
+
type Nullable<T> = T | null;
|
|
58
|
+
type WindowRect = {
|
|
59
|
+
width: number;
|
|
60
|
+
height: number;
|
|
61
|
+
};
|
|
62
|
+
export interface BrowserContextArgs {
|
|
63
|
+
accept_downloads: boolean;
|
|
64
|
+
offline: boolean;
|
|
65
|
+
strict_selectors: boolean;
|
|
66
|
+
proxy: Nullable<ProxySettings>;
|
|
67
|
+
permissions: string[];
|
|
68
|
+
bypass_csp: boolean;
|
|
69
|
+
client_certificates: ClientCertificate[];
|
|
70
|
+
extra_http_headers: Record<string, string>;
|
|
71
|
+
http_credentials: Nullable<HttpCredentials>;
|
|
72
|
+
ignore_https_errors: boolean;
|
|
73
|
+
java_script_enabled: boolean;
|
|
74
|
+
base_url: Nullable<string>;
|
|
75
|
+
service_workers: ServiceWorkers;
|
|
76
|
+
user_agent: Nullable<string>;
|
|
77
|
+
screen: Nullable<ViewportSize>;
|
|
78
|
+
viewport: Nullable<ViewportSize>;
|
|
79
|
+
no_viewport: Nullable<boolean>;
|
|
80
|
+
device_scale_factor: Nullable<number>;
|
|
81
|
+
is_mobile: boolean;
|
|
82
|
+
has_touch: boolean;
|
|
83
|
+
locale: Nullable<string>;
|
|
84
|
+
geolocation: Nullable<Geolocation>;
|
|
85
|
+
timezone_id: Nullable<string>;
|
|
86
|
+
color_scheme: ColorScheme;
|
|
87
|
+
contrast: Contrast;
|
|
88
|
+
reduced_motion: ReducedMotion;
|
|
89
|
+
forced_colors: ForcedColors;
|
|
90
|
+
record_har_content: RecordHarContent;
|
|
91
|
+
record_har_mode: RecordHarMode;
|
|
92
|
+
record_har_omit_content: boolean;
|
|
93
|
+
record_har_path: Nullable<string>;
|
|
94
|
+
record_har_url_filter: Nullable<string | RegExp>;
|
|
95
|
+
record_video_dir: Nullable<string>;
|
|
96
|
+
record_video_size: Nullable<ViewportSize>;
|
|
97
|
+
}
|
|
98
|
+
export interface BrowserConnectArgs {
|
|
99
|
+
headers: Nullable<Record<string, string>>;
|
|
100
|
+
slow_mo: number;
|
|
101
|
+
timeout: number;
|
|
102
|
+
}
|
|
103
|
+
export interface BrowserLaunchArgs {
|
|
104
|
+
env: Nullable<Record<string, string | number | boolean>>;
|
|
105
|
+
executable_path: Nullable<string>;
|
|
106
|
+
headless: Nullable<boolean>;
|
|
107
|
+
args: string[];
|
|
108
|
+
ignore_default_args: string[] | true;
|
|
109
|
+
channel: Nullable<BrowserChannel>;
|
|
110
|
+
chromium_sandbox: boolean;
|
|
111
|
+
devtools: boolean;
|
|
112
|
+
slow_mo: number;
|
|
113
|
+
timeout: number;
|
|
114
|
+
proxy: Nullable<ProxySettings>;
|
|
115
|
+
downloads_path: Nullable<string>;
|
|
116
|
+
traces_dir: Nullable<string>;
|
|
117
|
+
handle_sighup: boolean;
|
|
118
|
+
handle_sigint: boolean;
|
|
119
|
+
handle_sigterm: boolean;
|
|
120
|
+
}
|
|
121
|
+
export type BrowserNewContextArgs = BrowserContextArgs & {
|
|
122
|
+
storage_state: Nullable<string | StorageState | Record<string, unknown>>;
|
|
123
|
+
};
|
|
124
|
+
export type BrowserLaunchPersistentContextArgs = BrowserContextArgs & BrowserLaunchArgs & {
|
|
125
|
+
user_data_dir: Nullable<string>;
|
|
126
|
+
};
|
|
127
|
+
export interface BrowserProfileSpecificOptions {
|
|
128
|
+
id: string;
|
|
129
|
+
user_data_dir: Nullable<string>;
|
|
130
|
+
storage_state: Nullable<string | StorageState | Record<string, unknown>>;
|
|
131
|
+
stealth: boolean;
|
|
132
|
+
disable_security: boolean;
|
|
133
|
+
deterministic_rendering: boolean;
|
|
134
|
+
allowed_domains: Nullable<string[]>;
|
|
135
|
+
keep_alive: Nullable<boolean>;
|
|
136
|
+
enable_default_extensions: boolean;
|
|
137
|
+
window_size: Nullable<ViewportSize>;
|
|
138
|
+
window_height: Nullable<number>;
|
|
139
|
+
window_width: Nullable<number>;
|
|
140
|
+
window_position: Nullable<WindowRect>;
|
|
141
|
+
default_navigation_timeout: Nullable<number>;
|
|
142
|
+
default_timeout: Nullable<number>;
|
|
143
|
+
minimum_wait_page_load_time: number;
|
|
144
|
+
wait_for_network_idle_page_load_time: number;
|
|
145
|
+
maximum_wait_page_load_time: number;
|
|
146
|
+
wait_between_actions: number;
|
|
147
|
+
include_dynamic_attributes: boolean;
|
|
148
|
+
highlight_elements: boolean;
|
|
149
|
+
viewport_expansion: number;
|
|
150
|
+
profile_directory: string;
|
|
151
|
+
cookies_file: Nullable<string>;
|
|
152
|
+
}
|
|
153
|
+
export type BrowserProfileOptions = BrowserContextArgs & BrowserLaunchArgs & BrowserConnectArgs & BrowserProfileSpecificOptions;
|
|
154
|
+
export declare class BrowserProfile {
|
|
155
|
+
private options;
|
|
156
|
+
constructor(init?: Partial<BrowserProfileOptions>);
|
|
157
|
+
toString(): string;
|
|
158
|
+
describe(): string;
|
|
159
|
+
get config(): BrowserProfileOptions;
|
|
160
|
+
get allowed_domains(): Nullable<string[]>;
|
|
161
|
+
get cookies_file(): Nullable<string>;
|
|
162
|
+
get default_navigation_timeout(): Nullable<number>;
|
|
163
|
+
get downloads_path(): Nullable<string>;
|
|
164
|
+
get highlight_elements(): boolean;
|
|
165
|
+
get keep_alive(): boolean | null;
|
|
166
|
+
set keep_alive(value: boolean | null);
|
|
167
|
+
get maximum_wait_page_load_time(): number;
|
|
168
|
+
get traces_dir(): Nullable<string>;
|
|
169
|
+
get user_data_dir(): Nullable<string>;
|
|
170
|
+
get viewport_expansion(): number;
|
|
171
|
+
get viewport(): Nullable<import("playwright-core").ViewportSize>;
|
|
172
|
+
get wait_for_network_idle_page_load_time(): number;
|
|
173
|
+
get window_size(): Nullable<import("playwright-core").ViewportSize>;
|
|
174
|
+
private applyLegacyWindowSize;
|
|
175
|
+
private warnStorageStateUserDataDirConflict;
|
|
176
|
+
private warnUserDataDirNonDefault;
|
|
177
|
+
private warnDeterministicRenderingWeirdness;
|
|
178
|
+
private getDefaultArgsList;
|
|
179
|
+
private getWindowSizeArgs;
|
|
180
|
+
private getWindowPositionArgs;
|
|
181
|
+
private getExtensionArgs;
|
|
182
|
+
private ensureDefaultExtensionsDownloaded;
|
|
183
|
+
private downloadExtension;
|
|
184
|
+
private extractExtension;
|
|
185
|
+
private stripCrxHeader;
|
|
186
|
+
getArgs(): Promise<string[]>;
|
|
187
|
+
detect_display_configuration(): Promise<any>;
|
|
188
|
+
private cloneContextArgs;
|
|
189
|
+
private cloneLaunchArgs;
|
|
190
|
+
kwargs_for_new_context(): BrowserNewContextArgs;
|
|
191
|
+
kwargs_for_connect(): BrowserConnectArgs;
|
|
192
|
+
kwargs_for_launch(): Promise<BrowserLaunchArgs>;
|
|
193
|
+
kwargs_for_launch_persistent_context(): Promise<BrowserLaunchPersistentContextArgs>;
|
|
194
|
+
}
|
|
195
|
+
export declare const DEFAULT_BROWSER_PROFILE: BrowserProfile;
|
|
196
|
+
export {};
|