effect-browserbase 0.1.0-beta.104 → 0.2.0-beta.1
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 +106 -307
- package/dist/Account.d.mts +17 -19
- package/dist/Account.mjs +4 -9
- package/dist/Account.mjs.map +1 -1
- package/dist/{Acquisition-WBafHwXH.mjs → Acquisition-CAsTTXp4.mjs} +25 -70
- package/dist/Acquisition-CAsTTXp4.mjs.map +1 -0
- package/dist/Agents-5HpTp9YE.d.mts +155 -0
- package/dist/Agents.d.mts +3 -156
- package/dist/Agents.mjs +4 -20
- package/dist/Agents.mjs.map +1 -1
- package/dist/Allocation.d.mts +9 -11
- package/dist/Allocation.mjs +2 -4
- package/dist/Allocation.mjs.map +1 -1
- package/dist/Browser-DpSajNai.mjs +270 -0
- package/dist/Browser-DpSajNai.mjs.map +1 -0
- package/dist/Browser.d.mts +26 -143
- package/dist/Browser.mjs +3 -223
- package/dist/BrowserBinding.d.mts +7 -34
- package/dist/BrowserBinding.mjs +30 -1
- package/dist/BrowserBinding.mjs.map +1 -0
- package/dist/Certificates-D4NQmyeA.d.mts +34 -0
- package/dist/Certificates.d.mts +3 -35
- package/dist/Certificates.mjs +2 -7
- package/dist/Certificates.mjs.map +1 -1
- package/dist/{Cleanup-G2YpTCuU.d.mts → Cleanup-DMTDBir8.d.mts} +5 -6
- package/dist/Cleanup.d.mts +3 -2
- package/dist/Cleanup.mjs +1 -6
- package/dist/Cleanup.mjs.map +1 -1
- package/dist/{Client-D1_xYM9o.mjs → Client-4RMKIpL2.mjs} +12 -12
- package/dist/Client-4RMKIpL2.mjs.map +1 -0
- package/dist/{Client-Ca0zSg1n.d.mts → Client-B_f6bBLT.d.mts} +4 -5
- package/dist/Client.d.mts +3 -2
- package/dist/Client.mjs +1 -1
- package/dist/Connection-sxyxtwlk.mjs +56 -0
- package/dist/Connection-sxyxtwlk.mjs.map +1 -0
- package/dist/ContextCoordination.d.mts +5 -6
- package/dist/ContextCoordination.mjs +2 -9
- package/dist/ContextCoordination.mjs.map +1 -1
- package/dist/{ContextWriter-BrQmoXRg.mjs → ContextWriter-oKWFLHuP.mjs} +8 -12
- package/dist/ContextWriter-oKWFLHuP.mjs.map +1 -0
- package/dist/Contexts-DqdL7cyX.d.mts +31 -0
- package/dist/Contexts.d.mts +3 -32
- package/dist/Contexts.mjs +3 -9
- package/dist/Contexts.mjs.map +1 -1
- package/dist/Downloads-CdhiCO5X.d.mts +43 -0
- package/dist/Downloads.d.mts +3 -44
- package/dist/Downloads.mjs +3 -8
- package/dist/Downloads.mjs.map +1 -1
- package/dist/Errors.d.mts +3 -26
- package/dist/Errors.mjs +1 -137
- package/dist/Errors.mjs.map +1 -1
- package/dist/Extensions-DBXuVM1f.d.mts +43 -0
- package/dist/{Extensions-ClZbYb1H.mjs → Extensions-Dg3jHOf0.mjs} +3 -9
- package/dist/Extensions-Dg3jHOf0.mjs.map +1 -0
- package/dist/Extensions.d.mts +3 -44
- package/dist/Extensions.mjs +1 -1
- package/dist/Functions-CsKMMUuZ.d.mts +226 -0
- package/dist/Functions.d.mts +3 -227
- package/dist/Functions.mjs +4 -18
- package/dist/Functions.mjs.map +1 -1
- package/dist/{Launch-BHcAEq05.mjs → Launch-cAdE2rrZ.mjs} +16 -12
- package/dist/Launch-cAdE2rrZ.mjs.map +1 -0
- package/dist/Launch.d.mts +127 -2
- package/dist/Launch.mjs +5 -13
- package/dist/Launch.mjs.map +1 -1
- package/dist/PageFetch-CAMqb5m8.d.mts +39 -0
- package/dist/PageFetch.d.mts +3 -40
- package/dist/PageFetch.mjs +2 -8
- package/dist/PageFetch.mjs.map +1 -1
- package/dist/Projects-tm5bTDH0.d.mts +38 -0
- package/dist/Projects.d.mts +3 -39
- package/dist/Projects.mjs +2 -8
- package/dist/Projects.mjs.map +1 -1
- package/dist/Recordings-bVI33sTq.d.mts +27 -0
- package/dist/Recordings.d.mts +3 -28
- package/dist/Recordings.mjs +3 -5
- package/dist/Recordings.mjs.map +1 -1
- package/dist/{References-URDAtapt.d.mts → References-DOH3Wu44.d.mts} +5 -6
- package/dist/References.d.mts +3 -2
- package/dist/References.mjs +10 -18
- package/dist/References.mjs.map +1 -1
- package/dist/Replays-Bo-9xeLz.d.mts +27 -0
- package/dist/Replays.d.mts +3 -28
- package/dist/Replays.mjs +3 -5
- package/dist/Replays.mjs.map +1 -1
- package/dist/Search-1g6TUem7.d.mts +37 -0
- package/dist/Search.d.mts +3 -38
- package/dist/Search.mjs +2 -9
- package/dist/Search.mjs.map +1 -1
- package/dist/{SessionData-DRKcKCqw.d.mts → SessionData-5xYZDshJ.d.mts} +5 -6
- package/dist/SessionData.d.mts +3 -2
- package/dist/SessionData.mjs +1 -8
- package/dist/SessionData.mjs.map +1 -1
- package/dist/{Sessions-B8E4kMxo.d.mts → Sessions-BpZgjteE.d.mts} +8 -8
- package/dist/{Sessions-CtbseWEh.mjs → Sessions-suOLSym9.mjs} +34 -18
- package/dist/Sessions-suOLSym9.mjs.map +1 -0
- package/dist/Sessions.d.mts +4 -3
- package/dist/Sessions.mjs +1 -1
- package/dist/Testing.d.mts +119 -0
- package/dist/Testing.mjs +206 -0
- package/dist/Testing.mjs.map +1 -0
- package/dist/{Transfers-Czv5IZzJ.d.mts → Transfers-GVqzrDWl.d.mts} +22 -9
- package/dist/Transfers.d.mts +3 -2
- package/dist/Transfers.mjs +12 -28
- package/dist/Transfers.mjs.map +1 -1
- package/dist/Uploads-C2neBEpj.d.mts +28 -0
- package/dist/Uploads.d.mts +3 -29
- package/dist/Uploads.mjs +3 -5
- package/dist/Uploads.mjs.map +1 -1
- package/dist/Webhooks-BoeRAxzG.d.mts +59 -0
- package/dist/Webhooks.d.mts +3 -60
- package/dist/Webhooks.mjs +2 -11
- package/dist/Webhooks.mjs.map +1 -1
- package/dist/{WriterFacts-osvYAsIx.d.mts → WriterFacts-BBJRDZYY.d.mts} +8 -15
- package/dist/index.d.mts +27 -31
- package/dist/index.mjs +26 -31
- package/package.json +7 -28
- package/dist/Acquisition-WBafHwXH.mjs.map +0 -1
- package/dist/Association-CEps4hYP.mjs +0 -10
- package/dist/Association-CEps4hYP.mjs.map +0 -1
- package/dist/Bootstrap-BXuzZojd.mjs +0 -194
- package/dist/Bootstrap-BXuzZojd.mjs.map +0 -1
- package/dist/Bootstrap-m7lHgj0D.d.mts +0 -177
- package/dist/Bootstrap.d.mts +0 -2
- package/dist/Bootstrap.mjs +0 -2
- package/dist/Browser.mjs.map +0 -1
- package/dist/BrowserBinding-DlJTGYZL.mjs +0 -2508
- package/dist/BrowserBinding-DlJTGYZL.mjs.map +0 -1
- package/dist/BrowserData-LpcAuAub.d.mts +0 -369
- package/dist/BrowserData.d.mts +0 -2
- package/dist/BrowserData.mjs +0 -442
- package/dist/BrowserData.mjs.map +0 -1
- package/dist/Capture-Bc0z9IAi.mjs +0 -571
- package/dist/Capture-Bc0z9IAi.mjs.map +0 -1
- package/dist/Capture-BvWI-l1A.d.mts +0 -168
- package/dist/Capture.d.mts +0 -2
- package/dist/Capture.mjs +0 -2
- package/dist/Client-D1_xYM9o.mjs.map +0 -1
- package/dist/ContextWriter-BrQmoXRg.mjs.map +0 -1
- package/dist/Extensions-ClZbYb1H.mjs.map +0 -1
- package/dist/Images-DgscEfSf.mjs +0 -127
- package/dist/Images-DgscEfSf.mjs.map +0 -1
- package/dist/Launch-BHcAEq05.mjs.map +0 -1
- package/dist/Launch-C8CfaYxb.d.mts +0 -132
- package/dist/LocalBrowser-BLancJ3R.d.mts +0 -79
- package/dist/LocalBrowser-DsQLWNL1.mjs +0 -439
- package/dist/LocalBrowser-DsQLWNL1.mjs.map +0 -1
- package/dist/LocalBrowser.d.mts +0 -2
- package/dist/LocalBrowser.mjs +0 -2
- package/dist/PageControl.d.mts +0 -16
- package/dist/PageControl.mjs +0 -36
- package/dist/PageControl.mjs.map +0 -1
- package/dist/PageControlAssociation-DabEg5AR.mjs +0 -10
- package/dist/PageControlAssociation-DabEg5AR.mjs.map +0 -1
- package/dist/Session-D4nT9hOO.mjs +0 -1379
- package/dist/Session-D4nT9hOO.mjs.map +0 -1
- package/dist/Sessions-CtbseWEh.mjs.map +0 -1
- package/dist/rolldown-runtime-D7D4PA-g.mjs +0 -13
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
import { n as ContextReference, r as ExtensionReference } from "./References-URDAtapt.mjs";
|
|
2
|
-
import { Schema } from "effect";
|
|
3
|
-
declare namespace Launch_d_exports {
|
|
4
|
-
export { LaunchRecipe, ProviderLaunchOptions, ProxyRule, recipe };
|
|
5
|
-
}
|
|
6
|
-
declare const ProxyRule: Schema.Union<readonly [Schema.Struct<{
|
|
7
|
-
readonly type: Schema.Literal<"browserbase">;
|
|
8
|
-
readonly domainPattern: Schema.optionalKey<Schema.NonEmptyString>;
|
|
9
|
-
readonly geolocation: Schema.optionalKey<Schema.Struct<{
|
|
10
|
-
readonly country: Schema.String;
|
|
11
|
-
readonly state: Schema.optionalKey<Schema.String>;
|
|
12
|
-
readonly city: Schema.optionalKey<Schema.NonEmptyString>;
|
|
13
|
-
}>>;
|
|
14
|
-
}>, Schema.Struct<{
|
|
15
|
-
readonly type: Schema.Literal<"external">;
|
|
16
|
-
readonly server: Schema.NonEmptyString;
|
|
17
|
-
readonly domainPattern: Schema.optionalKey<Schema.NonEmptyString>;
|
|
18
|
-
readonly username: Schema.optionalKey<Schema.Redacted<Schema.String>>;
|
|
19
|
-
readonly password: Schema.optionalKey<Schema.Redacted<Schema.String>>;
|
|
20
|
-
}>, Schema.Struct<{
|
|
21
|
-
readonly type: Schema.Literal<"none">;
|
|
22
|
-
readonly domainPattern: Schema.optionalKey<Schema.NonEmptyString>;
|
|
23
|
-
}>]>;
|
|
24
|
-
type ProxyRule = typeof ProxyRule.Type;
|
|
25
|
-
/** SDK 2.20 browser subset. Names follow Browserbase; ownership-managed fields are excluded. */
|
|
26
|
-
declare const ProviderLaunchOptions: Schema.Struct<{
|
|
27
|
-
readonly region: Schema.optionalKey<Schema.Literals<readonly ["us-west-2", "us-east-1", "eu-central-1", "ap-southeast-1"]>>;
|
|
28
|
-
readonly proxies: Schema.optionalKey<Schema.Union<readonly [Schema.Boolean, Schema.$Array<Schema.Union<readonly [Schema.Struct<{
|
|
29
|
-
readonly type: Schema.Literal<"browserbase">;
|
|
30
|
-
readonly domainPattern: Schema.optionalKey<Schema.NonEmptyString>;
|
|
31
|
-
readonly geolocation: Schema.optionalKey<Schema.Struct<{
|
|
32
|
-
readonly country: Schema.String;
|
|
33
|
-
readonly state: Schema.optionalKey<Schema.String>;
|
|
34
|
-
readonly city: Schema.optionalKey<Schema.NonEmptyString>;
|
|
35
|
-
}>>;
|
|
36
|
-
}>, Schema.Struct<{
|
|
37
|
-
readonly type: Schema.Literal<"external">;
|
|
38
|
-
readonly server: Schema.NonEmptyString;
|
|
39
|
-
readonly domainPattern: Schema.optionalKey<Schema.NonEmptyString>;
|
|
40
|
-
readonly username: Schema.optionalKey<Schema.Redacted<Schema.String>>;
|
|
41
|
-
readonly password: Schema.optionalKey<Schema.Redacted<Schema.String>>;
|
|
42
|
-
}>, Schema.Struct<{
|
|
43
|
-
readonly type: Schema.Literal<"none">;
|
|
44
|
-
readonly domainPattern: Schema.optionalKey<Schema.NonEmptyString>;
|
|
45
|
-
}>]>>]>>;
|
|
46
|
-
readonly proxySettings: Schema.optionalKey<Schema.Struct<{
|
|
47
|
-
readonly caCertificates: Schema.optionalKey<Schema.$Array<Schema.NonEmptyString>>;
|
|
48
|
-
}>>;
|
|
49
|
-
readonly browserSettings: Schema.optionalKey<Schema.Struct<{
|
|
50
|
-
readonly verified: Schema.optionalKey<Schema.Boolean>;
|
|
51
|
-
readonly os: Schema.optionalKey<Schema.Literals<readonly ["windows", "mac", "linux", "mobile", "tablet"]>>;
|
|
52
|
-
readonly allowedDomains: Schema.optionalKey<Schema.$Array<Schema.NonEmptyString>>;
|
|
53
|
-
readonly blockAds: Schema.optionalKey<Schema.Boolean>;
|
|
54
|
-
readonly captchaImageSelector: Schema.optionalKey<Schema.NonEmptyString>;
|
|
55
|
-
readonly captchaInputSelector: Schema.optionalKey<Schema.NonEmptyString>;
|
|
56
|
-
readonly ignoreCertificateErrors: Schema.optionalKey<Schema.Boolean>;
|
|
57
|
-
readonly logSession: Schema.optionalKey<Schema.Boolean>;
|
|
58
|
-
readonly recordSession: Schema.optionalKey<Schema.Boolean>;
|
|
59
|
-
readonly solveCaptchas: Schema.optionalKey<Schema.Boolean>;
|
|
60
|
-
}>>;
|
|
61
|
-
readonly userMetadata: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>>;
|
|
62
|
-
}>;
|
|
63
|
-
type ProviderLaunchOptions = typeof ProviderLaunchOptions.Type;
|
|
64
|
-
/** Connection behavior and business budgets are not provider session lifetime. */
|
|
65
|
-
declare const LaunchRecipe: Schema.Struct<{
|
|
66
|
-
readonly remoteTimeoutSeconds: Schema.Int;
|
|
67
|
-
readonly keepAlive: Schema.optionalKey<Schema.Boolean>;
|
|
68
|
-
readonly context: Schema.optionalKey<Schema.Struct<{
|
|
69
|
-
readonly reference: typeof ContextReference;
|
|
70
|
-
readonly persist: Schema.Boolean;
|
|
71
|
-
}>>;
|
|
72
|
-
/**
|
|
73
|
-
* Project-qualified selection of an already provisioned extension, never an upload. It is
|
|
74
|
-
* the only spelling: the compiler alone projects it to the provider's `extensionId`, so an
|
|
75
|
-
* unqualified identifier cannot reach the provider unchecked.
|
|
76
|
-
*/
|
|
77
|
-
readonly extension: Schema.optionalKey<typeof ExtensionReference>;
|
|
78
|
-
readonly viewport: Schema.Union<readonly [Schema.Struct<{
|
|
79
|
-
readonly _tag: Schema.Literal<"ProviderManaged">;
|
|
80
|
-
}>, Schema.Struct<{
|
|
81
|
-
readonly _tag: Schema.Literal<"Fixed">;
|
|
82
|
-
readonly width: Schema.Int;
|
|
83
|
-
readonly height: Schema.Int;
|
|
84
|
-
}>]>;
|
|
85
|
-
readonly provider: Schema.Struct<{
|
|
86
|
-
readonly region: Schema.optionalKey<Schema.Literals<readonly ["us-west-2", "us-east-1", "eu-central-1", "ap-southeast-1"]>>;
|
|
87
|
-
readonly proxies: Schema.optionalKey<Schema.Union<readonly [Schema.Boolean, Schema.$Array<Schema.Union<readonly [Schema.Struct<{
|
|
88
|
-
readonly type: Schema.Literal<"browserbase">;
|
|
89
|
-
readonly domainPattern: Schema.optionalKey<Schema.NonEmptyString>;
|
|
90
|
-
readonly geolocation: Schema.optionalKey<Schema.Struct<{
|
|
91
|
-
readonly country: Schema.String;
|
|
92
|
-
readonly state: Schema.optionalKey<Schema.String>;
|
|
93
|
-
readonly city: Schema.optionalKey<Schema.NonEmptyString>;
|
|
94
|
-
}>>;
|
|
95
|
-
}>, Schema.Struct<{
|
|
96
|
-
readonly type: Schema.Literal<"external">;
|
|
97
|
-
readonly server: Schema.NonEmptyString;
|
|
98
|
-
readonly domainPattern: Schema.optionalKey<Schema.NonEmptyString>;
|
|
99
|
-
readonly username: Schema.optionalKey<Schema.Redacted<Schema.String>>;
|
|
100
|
-
readonly password: Schema.optionalKey<Schema.Redacted<Schema.String>>;
|
|
101
|
-
}>, Schema.Struct<{
|
|
102
|
-
readonly type: Schema.Literal<"none">;
|
|
103
|
-
readonly domainPattern: Schema.optionalKey<Schema.NonEmptyString>;
|
|
104
|
-
}>]>>]>>;
|
|
105
|
-
readonly proxySettings: Schema.optionalKey<Schema.Struct<{
|
|
106
|
-
readonly caCertificates: Schema.optionalKey<Schema.$Array<Schema.NonEmptyString>>;
|
|
107
|
-
}>>;
|
|
108
|
-
readonly browserSettings: Schema.optionalKey<Schema.Struct<{
|
|
109
|
-
readonly verified: Schema.optionalKey<Schema.Boolean>;
|
|
110
|
-
readonly os: Schema.optionalKey<Schema.Literals<readonly ["windows", "mac", "linux", "mobile", "tablet"]>>;
|
|
111
|
-
readonly allowedDomains: Schema.optionalKey<Schema.$Array<Schema.NonEmptyString>>;
|
|
112
|
-
readonly blockAds: Schema.optionalKey<Schema.Boolean>;
|
|
113
|
-
readonly captchaImageSelector: Schema.optionalKey<Schema.NonEmptyString>;
|
|
114
|
-
readonly captchaInputSelector: Schema.optionalKey<Schema.NonEmptyString>;
|
|
115
|
-
readonly ignoreCertificateErrors: Schema.optionalKey<Schema.Boolean>;
|
|
116
|
-
readonly logSession: Schema.optionalKey<Schema.Boolean>;
|
|
117
|
-
readonly recordSession: Schema.optionalKey<Schema.Boolean>;
|
|
118
|
-
readonly solveCaptchas: Schema.optionalKey<Schema.Boolean>;
|
|
119
|
-
}>>;
|
|
120
|
-
readonly userMetadata: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>>;
|
|
121
|
-
}>;
|
|
122
|
-
}>;
|
|
123
|
-
type LaunchRecipe = typeof LaunchRecipe.Type;
|
|
124
|
-
/**
|
|
125
|
-
* A recipe with the smallest reasonable choices filled in: a five-minute provider lifetime,
|
|
126
|
-
* a provider-managed viewport (which Verified requires) and no provider options. Privacy
|
|
127
|
-
* defaults are unchanged: recording, logging and captcha solving stay off unless requested.
|
|
128
|
-
*/
|
|
129
|
-
declare const recipe: (options?: Partial<LaunchRecipe>) => LaunchRecipe;
|
|
130
|
-
//#endregion
|
|
131
|
-
export { recipe as a, ProxyRule as i, Launch_d_exports as n, ProviderLaunchOptions as r, LaunchRecipe as t };
|
|
132
|
-
//# sourceMappingURL=Launch-C8CfaYxb.d.mts.map
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { BrowserError, InitializationError } from "./Errors.mjs";
|
|
2
|
-
import { V as Viewport, i as BrowserPolicy, n as AutomationOptions } from "./BrowserData-LpcAuAub.mjs";
|
|
3
|
-
import { BrowserSession, OpenOptions } from "./Browser.mjs";
|
|
4
|
-
import { Context, Effect, Layer, Option, Redacted, Schema, Scope } from "effect";
|
|
5
|
-
//#region src/internal/browser/LocalData.d.ts
|
|
6
|
-
declare const LocalReference_base: Schema.Class<LocalReference, Schema.Struct<{
|
|
7
|
-
readonly provider: Schema.Literal<"local">;
|
|
8
|
-
readonly id: Schema.NonEmptyString;
|
|
9
|
-
}>, {}>;
|
|
10
|
-
/** Identifies this local ownership lifetime, not a Browserbase resource or a reusable endpoint. */
|
|
11
|
-
declare class LocalReference extends LocalReference_base {}
|
|
12
|
-
declare const LocalCleanupIssue_base: Schema.Class<LocalCleanupIssue, Schema.Struct<{
|
|
13
|
-
readonly step: Schema.Literals<readonly ["fence", "capture", "initialization", "disconnect", "terminate", "profile"]>;
|
|
14
|
-
readonly reason: Schema.Literals<readonly ["timeout", "failed", "interrupted"]>;
|
|
15
|
-
}>, {}>;
|
|
16
|
-
declare class LocalCleanupIssue extends LocalCleanupIssue_base {}
|
|
17
|
-
declare const LocalCleanupResult_base: Schema.Class<LocalCleanupResult, Schema.Struct<{
|
|
18
|
-
readonly reference: typeof LocalReference;
|
|
19
|
-
readonly ownership: Schema.Literals<readonly ["owned", "borrowed"]>;
|
|
20
|
-
readonly connection: Schema.Literals<readonly ["closed", "failed", "not-connected", "pending"]>;
|
|
21
|
-
readonly process: Schema.Literals<readonly ["terminated", "unknown", "not-owned"]>;
|
|
22
|
-
readonly issues: Schema.$Array<typeof LocalCleanupIssue>;
|
|
23
|
-
}>, {}>;
|
|
24
|
-
/** Connection teardown and observed process exit are separate facts; no provider status exists. */
|
|
25
|
-
declare class LocalCleanupResult extends LocalCleanupResult_base {}
|
|
26
|
-
declare const LocalLaunch: Schema.Struct<{
|
|
27
|
-
readonly executablePath: Schema.optionalKey<Schema.NonEmptyString>;
|
|
28
|
-
readonly headless: Schema.optionalKey<Schema.Boolean>;
|
|
29
|
-
/** Enabled by default; a trusted host must explicitly choose a sandbox exception. */
|
|
30
|
-
readonly chromiumSandbox: Schema.optionalKey<Schema.Boolean>;
|
|
31
|
-
readonly args: Schema.optionalKey<Schema.$Array<Schema.NonEmptyString>>;
|
|
32
|
-
readonly proxy: Schema.optionalKey<Schema.Struct<{
|
|
33
|
-
readonly server: Schema.NonEmptyString;
|
|
34
|
-
readonly bypass: Schema.optionalKey<Schema.NonEmptyString>;
|
|
35
|
-
}>>;
|
|
36
|
-
readonly startupTimeoutMillis: Schema.optionalKey<Schema.Int>;
|
|
37
|
-
}>;
|
|
38
|
-
type LocalLaunch = typeof LocalLaunch.Type;
|
|
39
|
-
declare namespace LocalBrowser_d_exports {
|
|
40
|
-
export { LocalAcquisition, LocalAttachRequest, LocalBrowser, LocalBrowserOptions, LocalCleanupIssue, LocalCleanupResult, LocalLaunch, LocalReference, LocalSession };
|
|
41
|
-
}
|
|
42
|
-
/** Host-only process configuration. Building this layer neither loads Playwright nor starts Chromium. */
|
|
43
|
-
interface LocalBrowserOptions extends AutomationOptions {
|
|
44
|
-
readonly launch?: LocalLaunch;
|
|
45
|
-
readonly viewport?: Viewport;
|
|
46
|
-
readonly onCleanup?: (result: LocalCleanupResult) => Effect.Effect<void>;
|
|
47
|
-
}
|
|
48
|
-
/** A local lifetime has modeled browser authority, never Browserbase resource or release authority. */
|
|
49
|
-
interface LocalSession<E = never> extends BrowserSession<E> {
|
|
50
|
-
readonly reference: LocalReference;
|
|
51
|
-
readonly close: Effect.Effect<LocalCleanupResult>;
|
|
52
|
-
readonly cleanupResult: Effect.Effect<Option.Option<LocalCleanupResult>>;
|
|
53
|
-
}
|
|
54
|
-
interface LocalAcquisition<E = never> {
|
|
55
|
-
readonly reference: LocalReference;
|
|
56
|
-
readonly failure: Effect.Effect<never, E | InitializationError>;
|
|
57
|
-
readonly connect: Effect.Effect<LocalSession<E>, BrowserError | InitializationError | E>;
|
|
58
|
-
readonly close: Effect.Effect<LocalCleanupResult>;
|
|
59
|
-
}
|
|
60
|
-
interface LocalAttachRequest<E = never, R = never> extends OpenOptions<E, R> {
|
|
61
|
-
readonly policy: BrowserPolicy;
|
|
62
|
-
/** Resolve this exact target; without it, multiple open pages are an ambiguity error. */
|
|
63
|
-
readonly target?: {
|
|
64
|
-
readonly targetId: string;
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
declare const LocalBrowser_base: Context.ServiceClass<LocalBrowser, "effect-browserbase/LocalBrowser", {
|
|
68
|
-
readonly acquire: <E = never, R = never>(policy: BrowserPolicy, request?: OpenOptions<E, R>) => Effect.Effect<LocalAcquisition<E>, BrowserError, Scope.Scope | Exclude<R, Scope.Scope>>;
|
|
69
|
-
readonly open: <E = never, R = never>(policy: BrowserPolicy, request?: OpenOptions<E, R>) => Effect.Effect<LocalSession<E>, BrowserError | InitializationError | E, Scope.Scope | Exclude<R, Scope.Scope>>;
|
|
70
|
-
/** A concrete loopback ws://.../devtools/browser/... endpoint; this scope owns only its connection. */
|
|
71
|
-
readonly attach: <E = never, R = never>(endpoint: Redacted.Redacted<string>, request: LocalAttachRequest<E, R>) => Effect.Effect<LocalSession<E>, BrowserError | InitializationError | E, Scope.Scope | Exclude<R, Scope.Scope>>;
|
|
72
|
-
readonly withBrowser: <E, R, A, E2, R2>(policy: BrowserPolicy, request: OpenOptions<E, R>, use: (session: LocalSession<E>) => Effect.Effect<A, E2, R2>) => Effect.Effect<A, BrowserError | InitializationError | E | E2, Exclude<R | R2, Scope.Scope>>;
|
|
73
|
-
}>;
|
|
74
|
-
declare class LocalBrowser extends LocalBrowser_base {
|
|
75
|
-
static layer(options?: LocalBrowserOptions): Layer.Layer<LocalBrowser, BrowserError>;
|
|
76
|
-
}
|
|
77
|
-
//#endregion
|
|
78
|
-
export { LocalBrowser_d_exports as a, LocalCleanupResult as c, LocalBrowserOptions as i, LocalLaunch as l, LocalAttachRequest as n, LocalSession as o, LocalBrowser as r, LocalCleanupIssue as s, LocalAcquisition as t, LocalReference as u };
|
|
79
|
-
//# sourceMappingURL=LocalBrowser-BLancJ3R.d.mts.map
|
|
@@ -1,439 +0,0 @@
|
|
|
1
|
-
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
|
|
2
|
-
import { Identifier } from "./References.mjs";
|
|
3
|
-
import { BrowserError } from "./Errors.mjs";
|
|
4
|
-
import { AutomationOptions, BrowserPolicy, Viewport } from "./BrowserData.mjs";
|
|
5
|
-
import { a as reported } from "./Acquisition-WBafHwXH.mjs";
|
|
6
|
-
import { d as empty } from "./Bootstrap-BXuzZojd.mjs";
|
|
7
|
-
import { a as connectPlaywrightEndpoint, s as fromNativeAttempt } from "./BrowserBinding-DlJTGYZL.mjs";
|
|
8
|
-
import { c as preparePlan, i as checked, l as compileBootstrap, o as makeSession, s as makeBindings, t as acquireSession } from "./Session-D4nT9hOO.mjs";
|
|
9
|
-
import { Cause, Clock, Context, Duration, Effect, Exit, Layer, Option, Path, Redacted, Schema, Scope } from "effect";
|
|
10
|
-
import { spawn } from "node:child_process";
|
|
11
|
-
import { mkdtemp, readFile, rm } from "node:fs/promises";
|
|
12
|
-
import { tmpdir } from "node:os";
|
|
13
|
-
//#region src/internal/browser/LocalData.ts
|
|
14
|
-
/** Identifies this local ownership lifetime, not a Browserbase resource or a reusable endpoint. */
|
|
15
|
-
var LocalReference = class extends Schema.Class("LocalBrowserReference")({
|
|
16
|
-
provider: Schema.Literal("local"),
|
|
17
|
-
id: Identifier
|
|
18
|
-
}) {};
|
|
19
|
-
var LocalCleanupIssue = class extends Schema.Class("LocalBrowserCleanupIssue")({
|
|
20
|
-
step: Schema.Literals([
|
|
21
|
-
"fence",
|
|
22
|
-
"capture",
|
|
23
|
-
"initialization",
|
|
24
|
-
"disconnect",
|
|
25
|
-
"terminate",
|
|
26
|
-
"profile"
|
|
27
|
-
]),
|
|
28
|
-
reason: Schema.Literals([
|
|
29
|
-
"timeout",
|
|
30
|
-
"failed",
|
|
31
|
-
"interrupted"
|
|
32
|
-
])
|
|
33
|
-
}) {};
|
|
34
|
-
/** Connection teardown and observed process exit are separate facts; no provider status exists. */
|
|
35
|
-
var LocalCleanupResult = class extends Schema.Class("LocalBrowserCleanupResult")({
|
|
36
|
-
reference: LocalReference,
|
|
37
|
-
ownership: Schema.Literals(["owned", "borrowed"]),
|
|
38
|
-
connection: Schema.Literals([
|
|
39
|
-
"closed",
|
|
40
|
-
"failed",
|
|
41
|
-
"not-connected",
|
|
42
|
-
"pending"
|
|
43
|
-
]),
|
|
44
|
-
process: Schema.Literals([
|
|
45
|
-
"terminated",
|
|
46
|
-
"unknown",
|
|
47
|
-
"not-owned"
|
|
48
|
-
]),
|
|
49
|
-
issues: Schema.Array(LocalCleanupIssue).check(Schema.isMaxLength(16))
|
|
50
|
-
}) {};
|
|
51
|
-
const Text = Schema.NonEmptyString.check(Schema.isMaxLength(4096), Schema.isPattern(/^[^\u0000\r\n]+$/u));
|
|
52
|
-
const Port = Schema.Int.check(Schema.isBetween({
|
|
53
|
-
minimum: 1,
|
|
54
|
-
maximum: 65535
|
|
55
|
-
}));
|
|
56
|
-
/** Only a concrete loopback WebSocket is admitted: no HTTP discovery redirects or remote DNS. */
|
|
57
|
-
const LocalEndpoint = Text.check(Schema.makeFilter((value) => {
|
|
58
|
-
try {
|
|
59
|
-
const url = new URL(value);
|
|
60
|
-
return url.protocol === "ws:" && ["127.0.0.1", "[::1]"].includes(url.hostname) && Schema.is(Port)(Number(url.port)) && !url.username && !url.password && !url.search && !url.hash && /^\/devtools\/browser\/[A-Za-z0-9_-]+$/u.test(url.pathname);
|
|
61
|
-
} catch {
|
|
62
|
-
return false;
|
|
63
|
-
}
|
|
64
|
-
}));
|
|
65
|
-
const ProxyServer = Text.check(Schema.makeFilter((value) => {
|
|
66
|
-
try {
|
|
67
|
-
const url = new URL(value);
|
|
68
|
-
return [
|
|
69
|
-
"http:",
|
|
70
|
-
"https:",
|
|
71
|
-
"socks5:"
|
|
72
|
-
].includes(url.protocol) && url.hostname.length > 0 && !url.username && !url.password && !url.search && !url.hash && ["", "/"].includes(url.pathname);
|
|
73
|
-
} catch {
|
|
74
|
-
return false;
|
|
75
|
-
}
|
|
76
|
-
}));
|
|
77
|
-
/** These arguments belong to the launcher; silently overriding them would change ownership. */
|
|
78
|
-
const Argument = Text.check(Schema.makeFilter((value) => value.startsWith("--") && !/^--(?:user-data-dir|remote-debugging[^=]*|headless|no-sandbox|disable-setuid-sandbox|single-process|proxy-server|proxy-bypass-list)(?:=|$)/u.test(value)));
|
|
79
|
-
const LocalLaunch = Schema.Struct({
|
|
80
|
-
executablePath: Schema.optionalKey(Text),
|
|
81
|
-
headless: Schema.optionalKey(Schema.Boolean),
|
|
82
|
-
/** Enabled by default; a trusted host must explicitly choose a sandbox exception. */
|
|
83
|
-
chromiumSandbox: Schema.optionalKey(Schema.Boolean),
|
|
84
|
-
args: Schema.optionalKey(Schema.Array(Argument).check(Schema.isMaxLength(64))),
|
|
85
|
-
proxy: Schema.optionalKey(Schema.Struct({
|
|
86
|
-
server: ProxyServer,
|
|
87
|
-
bypass: Schema.optionalKey(Text)
|
|
88
|
-
})),
|
|
89
|
-
startupTimeoutMillis: Schema.optionalKey(Schema.Int.check(Schema.isBetween({
|
|
90
|
-
minimum: 1,
|
|
91
|
-
maximum: 6e4
|
|
92
|
-
})))
|
|
93
|
-
});
|
|
94
|
-
//#endregion
|
|
95
|
-
//#region src/internal/browser/LocalProcess.ts
|
|
96
|
-
/** Explicit host sandbox/proxy choices; the owned profile and debugger endpoint cannot be replaced. */
|
|
97
|
-
const launchArguments = (options, directory) => [
|
|
98
|
-
"--no-first-run",
|
|
99
|
-
"--no-default-browser-check",
|
|
100
|
-
"--remote-debugging-address=127.0.0.1",
|
|
101
|
-
"--remote-debugging-port=0",
|
|
102
|
-
`--user-data-dir=${directory}`,
|
|
103
|
-
...options.headless === false ? [] : ["--headless=new"],
|
|
104
|
-
...options.chromiumSandbox === false ? ["--no-sandbox"] : [],
|
|
105
|
-
...options.proxy === void 0 ? [] : [`--proxy-server=${options.proxy.server}`, `--proxy-bypass-list=${options.proxy.bypass ?? "<-loopback>"}`],
|
|
106
|
-
...options.args ?? [],
|
|
107
|
-
"about:blank"
|
|
108
|
-
];
|
|
109
|
-
const failure = (operation, reason) => BrowserError.make({
|
|
110
|
-
operation,
|
|
111
|
-
reason,
|
|
112
|
-
outcome: operation === "close" ? "unknown" : "undispatched"
|
|
113
|
-
});
|
|
114
|
-
const exited = (child) => child.exitCode !== null || child.signalCode !== null;
|
|
115
|
-
/** POSIX groups keep Chromium's helpers inside the same owned termination boundary. */
|
|
116
|
-
const alive = (pid) => {
|
|
117
|
-
try {
|
|
118
|
-
process.kill(-pid, 0);
|
|
119
|
-
return true;
|
|
120
|
-
} catch (error) {
|
|
121
|
-
if (error instanceof Error && "code" in error && error.code === "ESRCH") return false;
|
|
122
|
-
throw error;
|
|
123
|
-
}
|
|
124
|
-
};
|
|
125
|
-
const signalGroup = (pid, signal) => {
|
|
126
|
-
try {
|
|
127
|
-
process.kill(-pid, signal);
|
|
128
|
-
} catch (error) {
|
|
129
|
-
if (!(error instanceof Error && "code" in error && error.code === "ESRCH")) throw error;
|
|
130
|
-
}
|
|
131
|
-
};
|
|
132
|
-
/** Called once; observes parent and helper exit, rather than treating a sent signal as cleanup. */
|
|
133
|
-
const terminate = Effect.fnUntraced(function* (child, pid, clock) {
|
|
134
|
-
const stopped = Effect.try({
|
|
135
|
-
try: () => exited(child) && !alive(pid),
|
|
136
|
-
catch: () => failure("close", "failed")
|
|
137
|
-
});
|
|
138
|
-
const signal = (value) => Effect.try({
|
|
139
|
-
try: () => signalGroup(pid, value),
|
|
140
|
-
catch: () => failure("close", "failed")
|
|
141
|
-
});
|
|
142
|
-
const pause = clock.sleep(Duration.millis(20));
|
|
143
|
-
yield* signal("SIGTERM");
|
|
144
|
-
const graceful = clock.monotonicTimeNanosUnsafe() + 1500000000n;
|
|
145
|
-
while (!(yield* stopped) && clock.monotonicTimeNanosUnsafe() < graceful) yield* pause;
|
|
146
|
-
if (yield* stopped) return;
|
|
147
|
-
yield* signal("SIGKILL");
|
|
148
|
-
const forced = clock.monotonicTimeNanosUnsafe() + 1000000000n;
|
|
149
|
-
while (!(yield* stopped) && clock.monotonicTimeNanosUnsafe() < forced) yield* pause;
|
|
150
|
-
if (!(yield* stopped)) return yield* failure("close", "timeout");
|
|
151
|
-
});
|
|
152
|
-
/** Start only Chromium's process. The shared owner later opens its sole CDP connection. */
|
|
153
|
-
const launch = Effect.fnUntraced(function* (options) {
|
|
154
|
-
if (process.platform === "win32") return yield* failure("launch", "unsupported");
|
|
155
|
-
const path = yield* Path.Path.pipe(Effect.provide(Path.layer));
|
|
156
|
-
const clock = yield* Clock.Clock;
|
|
157
|
-
const executable = options.executablePath ?? (yield* Effect.tryPromise({
|
|
158
|
-
try: async () => (await import("playwright-core")).chromium.executablePath(),
|
|
159
|
-
catch: () => failure("launch", "failed")
|
|
160
|
-
}));
|
|
161
|
-
const directory = yield* Effect.tryPromise({
|
|
162
|
-
try: () => mkdtemp(path.join(tmpdir(), "effect-local-browser-")),
|
|
163
|
-
catch: () => failure("launch", "failed")
|
|
164
|
-
});
|
|
165
|
-
const removeProfile = Effect.tryPromise({
|
|
166
|
-
try: () => rm(directory, {
|
|
167
|
-
recursive: true,
|
|
168
|
-
force: true,
|
|
169
|
-
maxRetries: 5,
|
|
170
|
-
retryDelay: 50
|
|
171
|
-
}),
|
|
172
|
-
catch: () => failure("close", "failed")
|
|
173
|
-
});
|
|
174
|
-
let child;
|
|
175
|
-
return yield* Effect.gen(function* () {
|
|
176
|
-
const launched = yield* Effect.tryPromise({
|
|
177
|
-
try: () => {
|
|
178
|
-
const spawned = spawn(executable, launchArguments(options, directory), {
|
|
179
|
-
cwd: directory,
|
|
180
|
-
stdio: [
|
|
181
|
-
"ignore",
|
|
182
|
-
"ignore",
|
|
183
|
-
"ignore"
|
|
184
|
-
],
|
|
185
|
-
detached: true
|
|
186
|
-
});
|
|
187
|
-
child = spawned;
|
|
188
|
-
return new Promise((resolve, reject) => {
|
|
189
|
-
spawned.once("spawn", () => resolve(spawned));
|
|
190
|
-
spawned.once("error", reject);
|
|
191
|
-
});
|
|
192
|
-
},
|
|
193
|
-
catch: () => failure("launch", "failed")
|
|
194
|
-
});
|
|
195
|
-
const pid = launched.pid;
|
|
196
|
-
if (pid === void 0) return yield* failure("launch", "failed");
|
|
197
|
-
return {
|
|
198
|
-
connection: (timeoutMillis) => Effect.gen(function* () {
|
|
199
|
-
const deadline = clock.monotonicTimeNanosUnsafe() + BigInt(Math.ceil(Math.min(timeoutMillis, options.startupTimeoutMillis ?? 15e3))) * 1000000n;
|
|
200
|
-
while (clock.monotonicTimeNanosUnsafe() < deadline) {
|
|
201
|
-
if (exited(launched)) return yield* failure("connect", "closed");
|
|
202
|
-
const portFile = yield* Effect.tryPromise({
|
|
203
|
-
try: (signal) => readFile(path.join(directory, "DevToolsActivePort"), {
|
|
204
|
-
encoding: "utf8",
|
|
205
|
-
signal
|
|
206
|
-
}).catch((error) => {
|
|
207
|
-
if (error instanceof Error && "code" in error && error.code === "ENOENT") return void 0;
|
|
208
|
-
throw error;
|
|
209
|
-
}),
|
|
210
|
-
catch: () => failure("connect", "transport")
|
|
211
|
-
});
|
|
212
|
-
const lines = portFile === void 0 ? [] : portFile.trim().split("\n");
|
|
213
|
-
if (lines.length >= 2) {
|
|
214
|
-
const endpoint = `ws://127.0.0.1:${lines[0]}${lines[1]}`;
|
|
215
|
-
if (!Schema.is(LocalEndpoint)(endpoint)) return yield* failure("connect", "malformed");
|
|
216
|
-
return Redacted.make(endpoint);
|
|
217
|
-
}
|
|
218
|
-
yield* clock.sleep(Duration.millis(20));
|
|
219
|
-
}
|
|
220
|
-
return yield* failure("connect", "timeout");
|
|
221
|
-
}),
|
|
222
|
-
terminate: yield* Effect.cached(terminate(launched, pid, clock).pipe(Effect.uninterruptible)),
|
|
223
|
-
removeProfile
|
|
224
|
-
};
|
|
225
|
-
}).pipe(Effect.onExit((exit) => Exit.isSuccess(exit) ? Effect.void : Effect.gen(function* () {
|
|
226
|
-
if (child?.pid === void 0) {
|
|
227
|
-
yield* removeProfile.pipe(Effect.ignore);
|
|
228
|
-
return;
|
|
229
|
-
}
|
|
230
|
-
const stopped = yield* terminate(child, child.pid, clock).pipe(Effect.exit);
|
|
231
|
-
if (Exit.isSuccess(stopped)) yield* removeProfile.pipe(Effect.ignore);
|
|
232
|
-
})));
|
|
233
|
-
});
|
|
234
|
-
//#endregion
|
|
235
|
-
//#region src/internal/browser/LocalSession.ts
|
|
236
|
-
/** Same maintained driver, with a separately validated host endpoint and no provider identity. */
|
|
237
|
-
const localEngine = fromNativeAttempt(async (request, signal) => {
|
|
238
|
-
if (!Schema.is(LocalEndpoint)(request.connection)) throw BrowserError.make({
|
|
239
|
-
operation: "connect",
|
|
240
|
-
reason: "configuration",
|
|
241
|
-
outcome: "undispatched"
|
|
242
|
-
});
|
|
243
|
-
return connectPlaywrightEndpoint(request.connection, signal, request.options, request.events);
|
|
244
|
-
});
|
|
245
|
-
/** Each teardown step runs even when a preceding step fails. Only observed exit permits profile removal. */
|
|
246
|
-
const makeLocalCleanup = Effect.fnUntraced(function* (reference, local, process) {
|
|
247
|
-
let latest;
|
|
248
|
-
return {
|
|
249
|
-
close: yield* Effect.cached(Effect.uninterruptible(Effect.gen(function* () {
|
|
250
|
-
const issues = [];
|
|
251
|
-
const step = (name, action) => action.pipe(Effect.interruptible, Effect.timeoutOrElse({
|
|
252
|
-
duration: 3e3,
|
|
253
|
-
orElse: () => Effect.fail(LocalCleanupIssue.make({
|
|
254
|
-
step: name,
|
|
255
|
-
reason: "timeout"
|
|
256
|
-
}))
|
|
257
|
-
}), Effect.exit, Effect.tap((exit) => Effect.sync(() => {
|
|
258
|
-
if (Exit.isSuccess(exit)) return;
|
|
259
|
-
const error = Cause.findErrorOption(exit.cause);
|
|
260
|
-
issues.push(LocalCleanupIssue.make({
|
|
261
|
-
step: name,
|
|
262
|
-
reason: Option.isSome(error) && error.value instanceof LocalCleanupIssue ? error.value.reason : Cause.hasInterrupts(exit.cause) ? "interrupted" : "failed"
|
|
263
|
-
}));
|
|
264
|
-
})));
|
|
265
|
-
yield* step("fence", local.fence);
|
|
266
|
-
yield* step("capture", local.capture);
|
|
267
|
-
yield* step("initialization", local.initialization);
|
|
268
|
-
const disconnected = yield* step("disconnect", local.disconnect);
|
|
269
|
-
const terminated = process === void 0 ? void 0 : yield* step("terminate", process.terminate);
|
|
270
|
-
if (process !== void 0 && terminated !== void 0 && Exit.isSuccess(terminated)) yield* step("profile", process.removeProfile);
|
|
271
|
-
const result = LocalCleanupResult.make({
|
|
272
|
-
reference,
|
|
273
|
-
ownership: process === void 0 ? "borrowed" : "owned",
|
|
274
|
-
connection: Exit.isSuccess(disconnected) ? disconnected.value : "failed",
|
|
275
|
-
process: terminated === void 0 ? "not-owned" : Exit.isSuccess(terminated) ? "terminated" : "unknown",
|
|
276
|
-
issues
|
|
277
|
-
});
|
|
278
|
-
Object.freeze(result.issues);
|
|
279
|
-
latest = Object.freeze(result);
|
|
280
|
-
return latest;
|
|
281
|
-
}))),
|
|
282
|
-
result: Effect.sync(() => Option.fromNullishOr(latest))
|
|
283
|
-
};
|
|
284
|
-
});
|
|
285
|
-
const acquireLocal = (endpoint, options, onCleanup) => (local) => Effect.uninterruptible(Effect.gen(function* () {
|
|
286
|
-
const process = endpoint === void 0 ? yield* launch(options) : void 0;
|
|
287
|
-
const reference = Object.freeze(LocalReference.make({
|
|
288
|
-
provider: "local",
|
|
289
|
-
id: globalThis.crypto.randomUUID()
|
|
290
|
-
}));
|
|
291
|
-
const cleanup = yield* makeLocalCleanup(reference, local, process);
|
|
292
|
-
let closing = false;
|
|
293
|
-
const release = yield* Effect.cached(Effect.gen(function* () {
|
|
294
|
-
closing = true;
|
|
295
|
-
const result = yield* cleanup.close;
|
|
296
|
-
if (onCleanup !== void 0) yield* reported(onCleanup(result));
|
|
297
|
-
return result;
|
|
298
|
-
}).pipe(Effect.uninterruptible));
|
|
299
|
-
yield* Effect.addFinalizer(() => release.pipe(Effect.asVoid));
|
|
300
|
-
return {
|
|
301
|
-
reference,
|
|
302
|
-
connection: (timeoutMillis) => Effect.suspend(() => {
|
|
303
|
-
if (closing) return Effect.fail(BrowserError.make({
|
|
304
|
-
operation: "connect",
|
|
305
|
-
reason: "closed",
|
|
306
|
-
outcome: "undispatched"
|
|
307
|
-
}));
|
|
308
|
-
if (process !== void 0) return process.connection(timeoutMillis);
|
|
309
|
-
return endpoint === void 0 ? Effect.fail(BrowserError.make({
|
|
310
|
-
operation: "connect",
|
|
311
|
-
reason: "configuration",
|
|
312
|
-
outcome: "undispatched"
|
|
313
|
-
})) : checked(LocalEndpoint, Redacted.value(endpoint), "connect").pipe(Effect.map(Redacted.make));
|
|
314
|
-
}),
|
|
315
|
-
release,
|
|
316
|
-
cleanupResult: cleanup.result
|
|
317
|
-
};
|
|
318
|
-
}));
|
|
319
|
-
const ownedLocal = (options, onCleanup) => acquireLocal(void 0, options, onCleanup);
|
|
320
|
-
const borrowedLocal = (endpoint, onCleanup) => acquireLocal(endpoint, {}, onCleanup);
|
|
321
|
-
//#endregion
|
|
322
|
-
//#region src/LocalBrowser.ts
|
|
323
|
-
var LocalBrowser_exports = /* @__PURE__ */ __exportAll({
|
|
324
|
-
LocalBrowser: () => LocalBrowser,
|
|
325
|
-
LocalCleanupIssue: () => LocalCleanupIssue,
|
|
326
|
-
LocalCleanupResult: () => LocalCleanupResult,
|
|
327
|
-
LocalLaunch: () => LocalLaunch,
|
|
328
|
-
LocalReference: () => LocalReference
|
|
329
|
-
});
|
|
330
|
-
var LocalBrowser = class LocalBrowser extends Context.Service()("effect-browserbase/LocalBrowser") {
|
|
331
|
-
static layer(options = {}) {
|
|
332
|
-
return Layer.effect(LocalBrowser, Effect.gen(function* () {
|
|
333
|
-
const automation = yield* checked(AutomationOptions, {
|
|
334
|
-
...options.actionTimeoutMillis === void 0 ? {} : { actionTimeoutMillis: options.actionTimeoutMillis },
|
|
335
|
-
...options.maxPages === void 0 ? {} : { maxPages: options.maxPages },
|
|
336
|
-
...options.initialPage === void 0 ? {} : { initialPage: options.initialPage },
|
|
337
|
-
...options.popupPolicy === void 0 ? {} : { popupPolicy: options.popupPolicy },
|
|
338
|
-
...options.dialogPolicy === void 0 ? {} : { dialogPolicy: options.dialogPolicy },
|
|
339
|
-
...options.pageControl === void 0 ? {} : { pageControl: options.pageControl }
|
|
340
|
-
}, "configure");
|
|
341
|
-
const launchInput = yield* checked(LocalLaunch, options.launch ?? {}, "configure");
|
|
342
|
-
const launch = Object.freeze({
|
|
343
|
-
...launchInput,
|
|
344
|
-
...launchInput.args === void 0 ? {} : { args: Object.freeze([...launchInput.args]) },
|
|
345
|
-
...launchInput.proxy === void 0 ? {} : { proxy: Object.freeze({ ...launchInput.proxy }) }
|
|
346
|
-
});
|
|
347
|
-
const viewport = yield* checked(Viewport, options.viewport ?? {
|
|
348
|
-
width: 1280,
|
|
349
|
-
height: 720
|
|
350
|
-
}, "configure");
|
|
351
|
-
const pageControl = automation.pageControl ?? false;
|
|
352
|
-
const popupPolicy = automation.popupPolicy ?? "retain";
|
|
353
|
-
const dialogPolicy = automation.dialogPolicy ?? "dismiss";
|
|
354
|
-
if (pageControl && (popupPolicy === "pause" || dialogPolicy === "pause")) return yield* BrowserError.make({
|
|
355
|
-
operation: "configure",
|
|
356
|
-
reason: "unsupported",
|
|
357
|
-
outcome: "undispatched"
|
|
358
|
-
});
|
|
359
|
-
if (Object.prototype.hasOwnProperty.call(options, "bootstrap")) return yield* BrowserError.make({
|
|
360
|
-
operation: "configure",
|
|
361
|
-
reason: "configuration",
|
|
362
|
-
outcome: "undispatched"
|
|
363
|
-
});
|
|
364
|
-
const driver = {
|
|
365
|
-
viewport,
|
|
366
|
-
pageControl,
|
|
367
|
-
popupPolicy,
|
|
368
|
-
dialogPolicy,
|
|
369
|
-
maxPages: automation.maxPages ?? 10
|
|
370
|
-
};
|
|
371
|
-
const acquire = Effect.fnUntraced(function* (policy, request = {}, attachment) {
|
|
372
|
-
const fixed = yield* checked(BrowserPolicy, policy, "configure");
|
|
373
|
-
const plan = yield* preparePlan(request.bootstrap ?? empty);
|
|
374
|
-
const scope = yield* Scope.fork(yield* Scope.Scope, "sequential");
|
|
375
|
-
const bindings = yield* makeBindings(plan).pipe(Scope.provide(scope));
|
|
376
|
-
const bootstrap = compileBootstrap(plan);
|
|
377
|
-
const selection = attachment !== void 0 ? {
|
|
378
|
-
newPage: false,
|
|
379
|
-
preserveViewport: true,
|
|
380
|
-
...attachment.targetId === void 0 ? {} : { initialTargetId: attachment.targetId }
|
|
381
|
-
} : automation.initialPage === void 0 ? {} : "targetId" in automation.initialPage ? { initialTargetId: automation.initialPage.targetId } : { newPage: true };
|
|
382
|
-
const acquired = yield* acquireSession({
|
|
383
|
-
maxActions: fixed.maxActions,
|
|
384
|
-
maxElapsedMillis: fixed.maxElapsedMillis,
|
|
385
|
-
actionTimeoutMillis: automation.actionTimeoutMillis ?? 1e4
|
|
386
|
-
}, {
|
|
387
|
-
remote: attachment === void 0 ? ownedLocal(launch, options.onCleanup) : borrowedLocal(attachment.endpoint, options.onCleanup),
|
|
388
|
-
engine: localEngine,
|
|
389
|
-
keepAlive: false,
|
|
390
|
-
driver: {
|
|
391
|
-
...driver,
|
|
392
|
-
...selection,
|
|
393
|
-
...bootstrap === void 0 ? {} : { bootstrap }
|
|
394
|
-
},
|
|
395
|
-
connectBindings: bindings.connect,
|
|
396
|
-
maxReturnedBytes: fixed.maxReturnedBytes
|
|
397
|
-
}).pipe(Scope.provide(scope));
|
|
398
|
-
const connected = yield* Effect.cached(acquired.connect.pipe(Effect.map((controls) => Object.assign(makeSession(controls, bindings), {
|
|
399
|
-
reference: controls.reference,
|
|
400
|
-
close: controls.close,
|
|
401
|
-
cleanupResult: controls.cleanupResult
|
|
402
|
-
}))));
|
|
403
|
-
return {
|
|
404
|
-
reference: acquired.reference,
|
|
405
|
-
failure: bindings.failure,
|
|
406
|
-
close: acquired.close,
|
|
407
|
-
connect: Effect.raceFirst(bindings.failure, acquired.connect.pipe(Effect.andThen(connected))).pipe(Effect.onError(() => acquired.close.pipe(Effect.asVoid)))
|
|
408
|
-
};
|
|
409
|
-
});
|
|
410
|
-
return LocalBrowser.of({
|
|
411
|
-
acquire,
|
|
412
|
-
open: (policy, request) => acquire(policy, request).pipe(Effect.flatMap((acquired) => acquired.connect)),
|
|
413
|
-
attach: (endpoint, request) => Effect.gen(function* () {
|
|
414
|
-
const address = yield* checked(LocalEndpoint, Redacted.value(endpoint), "connect");
|
|
415
|
-
const targetId = request.target === void 0 ? void 0 : yield* checked(Identifier, request.target.targetId, "configure");
|
|
416
|
-
return yield* (yield* acquire(request.policy, request, {
|
|
417
|
-
endpoint: Redacted.make(address),
|
|
418
|
-
...targetId === void 0 ? {} : { targetId }
|
|
419
|
-
})).connect;
|
|
420
|
-
}),
|
|
421
|
-
withBrowser: (policy, request, use) => Effect.scoped(Effect.gen(function* () {
|
|
422
|
-
const session = yield* (yield* acquire(policy, request)).connect;
|
|
423
|
-
const result = yield* Effect.raceFirst(session.failure, Effect.suspend(() => use(session)));
|
|
424
|
-
const cleanup = yield* session.close;
|
|
425
|
-
if (cleanup.connection !== "closed" || cleanup.process !== "terminated" || cleanup.issues.length > 0) return yield* BrowserError.make({
|
|
426
|
-
operation: "close",
|
|
427
|
-
reason: "failed",
|
|
428
|
-
outcome: "unknown"
|
|
429
|
-
});
|
|
430
|
-
return result;
|
|
431
|
-
}))
|
|
432
|
-
});
|
|
433
|
-
}));
|
|
434
|
-
}
|
|
435
|
-
};
|
|
436
|
-
//#endregion
|
|
437
|
-
export { LocalLaunch as a, LocalCleanupResult as i, LocalBrowser_exports as n, LocalReference as o, LocalCleanupIssue as r, LocalBrowser as t };
|
|
438
|
-
|
|
439
|
-
//# sourceMappingURL=LocalBrowser-DsQLWNL1.mjs.map
|