@orkestrel/browser 0.0.5 → 0.0.7
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 +12 -3
- package/dist/src/core/index.cjs +6602 -629
- package/dist/src/core/index.cjs.map +1 -1
- package/dist/src/core/index.d.cts +2906 -309
- package/dist/src/core/index.d.ts +2906 -309
- package/dist/src/core/index.js +6452 -631
- package/dist/src/core/index.js.map +1 -1
- package/dist/src/server/index.cjs +261 -75
- package/dist/src/server/index.cjs.map +1 -1
- package/dist/src/server/index.d.cts +53 -5
- package/dist/src/server/index.d.ts +53 -5
- package/dist/src/server/index.js +261 -78
- package/dist/src/server/index.js.map +1 -1
- package/package.json +16 -16
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { BrowserContextInterface } from '../core/index.ts';
|
|
2
|
+
import { BrowserContextOptions } from '../core/index.ts';
|
|
2
3
|
import { BrowserError } from '../core/index.ts';
|
|
3
4
|
import { BrowserPageInterface } from '../core/index.ts';
|
|
4
5
|
import { BrowserPageOptions } from '../core/index.ts';
|
|
@@ -14,6 +15,9 @@ import { EmitterHooks } from '@orkestrel/emitter';
|
|
|
14
15
|
import { EmitterInterface } from '@orkestrel/emitter';
|
|
15
16
|
import { ScreenshotWriterInterface } from '../core/index.ts';
|
|
16
17
|
|
|
18
|
+
/**
|
|
19
|
+
* Discovers, launches, connects to, and owns Chromium-family browser sessions.
|
|
20
|
+
*/
|
|
17
21
|
export declare class Browser implements BrowserInterface {
|
|
18
22
|
#private;
|
|
19
23
|
constructor(options?: BrowserOptions);
|
|
@@ -30,6 +34,7 @@ export declare class Browser implements BrowserInterface {
|
|
|
30
34
|
disconnect(): Promise<void>;
|
|
31
35
|
context(index?: number): BrowserContextInterface | undefined;
|
|
32
36
|
contexts(): readonly BrowserContextInterface[];
|
|
37
|
+
isolate(options?: BrowserContextOptions): Promise<BrowserContextInterface>;
|
|
33
38
|
create(options?: BrowserPageOptions): Promise<BrowserPageInterface>;
|
|
34
39
|
destroy(): Promise<void>;
|
|
35
40
|
close(): Promise<void>;
|
|
@@ -68,7 +73,7 @@ export declare const BROWSER_EXECUTABLE_PATHS: Readonly<Record<string, readonly
|
|
|
68
73
|
/** Flag enabling headless mode on a launched browser process. */
|
|
69
74
|
export declare const BROWSER_HEADLESS_ARG = "--headless=new";
|
|
70
75
|
|
|
71
|
-
/**
|
|
76
|
+
/** Bound for each launched-process exit window during TERM-to-KILL teardown. */
|
|
72
77
|
export declare const BROWSER_KILL_GRACE_MS = 3000;
|
|
73
78
|
|
|
74
79
|
/** Flags always passed to a launched browser process, alongside the caller's own. */
|
|
@@ -80,6 +85,9 @@ export declare const BROWSER_PORT_PROBE_TIMEOUT_MS = 200;
|
|
|
80
85
|
/** Machine-readable error-context cause for an owned browser process exiting. */
|
|
81
86
|
export declare const BROWSER_PROCESS_EXIT_CAUSE = "process-exit";
|
|
82
87
|
|
|
88
|
+
/** Prefix for isolated browser profiles created beneath the operating-system temp directory. */
|
|
89
|
+
export declare const BROWSER_PROFILE_PREFIX = "orkestrel-browser-";
|
|
90
|
+
|
|
83
91
|
/** Per-OS default Playwright browser cache directory, relative to the home directory (win32 uses `LOCALAPPDATA` directly). */
|
|
84
92
|
export declare const BROWSER_STORE_CACHE_DIRS: Readonly<Record<string, string>>;
|
|
85
93
|
|
|
@@ -190,6 +198,7 @@ export declare type BrowserEventMap = {
|
|
|
190
198
|
readonly disconnect: readonly [];
|
|
191
199
|
readonly launch: readonly [engine: BrowserEngine];
|
|
192
200
|
readonly page: readonly [page: BrowserPageInterface];
|
|
201
|
+
readonly context: readonly [context: BrowserContextInterface];
|
|
193
202
|
readonly error: readonly [error: unknown];
|
|
194
203
|
readonly destroy: readonly [];
|
|
195
204
|
};
|
|
@@ -222,12 +231,13 @@ export declare type BrowserEventMap = {
|
|
|
222
231
|
* process exiting on its own) drives the disconnected state, preceded by
|
|
223
232
|
* a coded `error` — `connect()` on the same instance can reattach afterward.
|
|
224
233
|
* - `destroy` — release local resources. On a launched browser this closes
|
|
225
|
-
* pages/contexts, then kills and awaits the process
|
|
226
|
-
* it sends `Browser.close`. On a merely
|
|
227
|
-
* DETACH ONLY because other clients may
|
|
234
|
+
* pages/contexts, then kills and awaits the process plus its POSIX process
|
|
235
|
+
* group. On an adopted browser it sends `Browser.close`. On a merely
|
|
236
|
+
* attached browser this is a LOCAL DETACH ONLY because other clients may
|
|
237
|
+
* share its targets. Idempotent.
|
|
228
238
|
* - `close` — graceful REMOTE shutdown: best-effort sends CDP `Browser.close`
|
|
229
239
|
* (works whether attached or owned), and when owned also awaits the
|
|
230
|
-
* process's exit (escalating to a kill only if
|
|
240
|
+
* process's exit and POSIX group drain (escalating to a kill only if needed),
|
|
231
241
|
* then performs the same local cleanup as `destroy()`. Use this to shut
|
|
232
242
|
* down a browser this instance doesn't own but wants to terminate anyway.
|
|
233
243
|
*
|
|
@@ -266,6 +276,7 @@ export declare interface BrowserInterface {
|
|
|
266
276
|
disconnect(): Promise<void>;
|
|
267
277
|
context(index?: number): BrowserContextInterface | undefined;
|
|
268
278
|
contexts(): readonly BrowserContextInterface[];
|
|
279
|
+
isolate(options?: BrowserContextOptions): Promise<BrowserContextInterface>;
|
|
269
280
|
create(options?: BrowserPageOptions): Promise<BrowserPageInterface>;
|
|
270
281
|
destroy(): Promise<void>;
|
|
271
282
|
close(): Promise<void>;
|
|
@@ -315,6 +326,19 @@ export declare interface BrowserOptions {
|
|
|
315
326
|
readonly browsers?: SystemBrowserOptions;
|
|
316
327
|
}
|
|
317
328
|
|
|
329
|
+
/**
|
|
330
|
+
* Resolved browser profile directory used for a Chromium-family launch.
|
|
331
|
+
*
|
|
332
|
+
* @remarks
|
|
333
|
+
* `temporary` is true only for an isolated profile created by
|
|
334
|
+
* {@link createBrowserProfile}; caller-supplied persistent profiles are
|
|
335
|
+
* never removed by the library.
|
|
336
|
+
*/
|
|
337
|
+
export declare interface BrowserProfileResult {
|
|
338
|
+
readonly path: string;
|
|
339
|
+
readonly temporary: boolean;
|
|
340
|
+
}
|
|
341
|
+
|
|
318
342
|
/** Lifecycle status of a browser wrapper. */
|
|
319
343
|
export declare type BrowserStatus = 'idle' | 'connecting' | 'connected' | 'disconnected' | 'error';
|
|
320
344
|
|
|
@@ -337,6 +361,14 @@ export declare function browserToEngine(browser?: string): BrowserEngine;
|
|
|
337
361
|
*/
|
|
338
362
|
export declare function createBrowser(options?: BrowserOptions): BrowserInterface;
|
|
339
363
|
|
|
364
|
+
/**
|
|
365
|
+
* Resolve a persistent caller profile or create an isolated temporary one.
|
|
366
|
+
*
|
|
367
|
+
* @param path - Optional caller-owned persistent user-data directory
|
|
368
|
+
* @returns The resolved profile and whether the library owns its lifecycle
|
|
369
|
+
*/
|
|
370
|
+
export declare function createBrowserProfile(path?: string): Promise<BrowserProfileResult>;
|
|
371
|
+
|
|
340
372
|
/**
|
|
341
373
|
* Create a Node `WebSocket`-backed CDP transport.
|
|
342
374
|
*
|
|
@@ -446,6 +478,10 @@ export declare function isBrowserNotConnectedError(value: unknown): value is Bro
|
|
|
446
478
|
/**
|
|
447
479
|
* Launch a browser process with raw-CDP debugging flags.
|
|
448
480
|
*
|
|
481
|
+
* @remarks
|
|
482
|
+
* POSIX launches own an isolated process group so lifecycle teardown can
|
|
483
|
+
* signal and await every Chromium subprocess without affecting the caller.
|
|
484
|
+
*
|
|
449
485
|
* @param executable - Absolute path to the browser executable
|
|
450
486
|
* @param port - Port the browser exposes its CDP endpoint on
|
|
451
487
|
* @param headless - Whether to launch in headless mode
|
|
@@ -473,6 +509,18 @@ export declare function probeAllPathNames(names: readonly string[], platform: st
|
|
|
473
509
|
/** Probe PATH (`which`/`where`) for the first resolvable command name. */
|
|
474
510
|
export declare function probePathNames(names: readonly string[], platform: string): string | undefined;
|
|
475
511
|
|
|
512
|
+
/**
|
|
513
|
+
* Remove a library-owned isolated browser profile.
|
|
514
|
+
*
|
|
515
|
+
* @remarks
|
|
516
|
+
* The path must remain a direct child of the operating-system temp directory
|
|
517
|
+
* with {@link BROWSER_PROFILE_PREFIX}; this defensive check prevents a
|
|
518
|
+
* malformed profile value from widening recursive deletion.
|
|
519
|
+
*
|
|
520
|
+
* @param profile - Resolved profile lifecycle result
|
|
521
|
+
*/
|
|
522
|
+
export declare function removeBrowserProfile(profile: BrowserProfileResult): Promise<void>;
|
|
523
|
+
|
|
476
524
|
/**
|
|
477
525
|
* One discovered browser executable on this machine.
|
|
478
526
|
*
|