effect-browser 0.0.0-reserved.0 → 0.2.0-beta.0

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.
Files changed (41) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +664 -3
  3. package/dist/Association-zlgInoaj.mjs +134 -0
  4. package/dist/Association-zlgInoaj.mjs.map +1 -0
  5. package/dist/Bootstrap-B9UUXsvF.d.mts +183 -0
  6. package/dist/Bootstrap-Be-2Ddmh.mjs +187 -0
  7. package/dist/Bootstrap-Be-2Ddmh.mjs.map +1 -0
  8. package/dist/Bootstrap.d.mts +3 -0
  9. package/dist/Bootstrap.mjs +2 -0
  10. package/dist/Browser.d.mts +177 -0
  11. package/dist/Browser.mjs +14 -0
  12. package/dist/Browser.mjs.map +1 -0
  13. package/dist/BrowserData-DJAnUHoZ.d.mts +412 -0
  14. package/dist/BrowserData.d.mts +3 -0
  15. package/dist/BrowserData.mjs +494 -0
  16. package/dist/BrowserData.mjs.map +1 -0
  17. package/dist/BrowserRuntime-fZz1b0VI.mjs +5169 -0
  18. package/dist/BrowserRuntime-fZz1b0VI.mjs.map +1 -0
  19. package/dist/BrowserRuntime.d.mts +139 -0
  20. package/dist/BrowserRuntime.mjs +2 -0
  21. package/dist/Capture.d.mts +40 -0
  22. package/dist/Capture.mjs +476 -0
  23. package/dist/Capture.mjs.map +1 -0
  24. package/dist/CaptureData-AmqVP_Ba.mjs +162 -0
  25. package/dist/CaptureData-AmqVP_Ba.mjs.map +1 -0
  26. package/dist/CaptureData.d.mts +148 -0
  27. package/dist/CaptureData.mjs +2 -0
  28. package/dist/Chromium.d.mts +84 -0
  29. package/dist/Chromium.mjs +381 -0
  30. package/dist/Chromium.mjs.map +1 -0
  31. package/dist/Errors.d.mts +106 -0
  32. package/dist/Errors.mjs +155 -0
  33. package/dist/Errors.mjs.map +1 -0
  34. package/dist/PageControl.d.mts +15 -0
  35. package/dist/PageControl.mjs +28 -0
  36. package/dist/PageControl.mjs.map +1 -0
  37. package/dist/PageControlAssociation-DabEg5AR.mjs +10 -0
  38. package/dist/PageControlAssociation-DabEg5AR.mjs.map +1 -0
  39. package/dist/index.d.mts +10 -0
  40. package/dist/index.mjs +9 -0
  41. package/package.json +67 -5
@@ -0,0 +1,381 @@
1
+ import { Identifier } from "./BrowserData.mjs";
2
+ import { BrowserError, Reasons } from "./Errors.mjs";
3
+ import { i as cleanupStep, n as make, o as reported, s as checked } from "./BrowserRuntime-fZz1b0VI.mjs";
4
+ import { Clock, Context, Duration, Effect, Exit, Layer, Option, Path, Redacted, Schema } from "effect";
5
+ import { spawn } from "node:child_process";
6
+ import { mkdtemp, readFile, rm } from "node:fs/promises";
7
+ import { tmpdir } from "node:os";
8
+ //#region src/internal/chromium/Data.ts
9
+ /** Identifies this Chromium ownership lifetime, not a reusable endpoint. */
10
+ var ChromiumReference = class extends Schema.Class("ChromiumReference")({
11
+ provider: Schema.Literal("chromium"),
12
+ id: Identifier
13
+ }) {};
14
+ var ChromiumCleanupIssue = class extends Schema.Class("ChromiumCleanupIssue")({
15
+ step: Schema.Literals([
16
+ "fence",
17
+ "capture",
18
+ "initialization",
19
+ "disconnect",
20
+ "terminate",
21
+ "profile"
22
+ ]),
23
+ reason: Schema.Literals([
24
+ "timeout",
25
+ "failed",
26
+ "interrupted"
27
+ ])
28
+ }) {};
29
+ /** Connection teardown and observed process exit are separate facts; no provider status exists. */
30
+ var ChromiumCleanupResult = class extends Schema.Class("ChromiumCleanupResult")({
31
+ reference: ChromiumReference,
32
+ ownership: Schema.Literals(["owned", "borrowed"]),
33
+ connection: Schema.Literals([
34
+ "closed",
35
+ "failed",
36
+ "not-connected",
37
+ "pending"
38
+ ]),
39
+ process: Schema.Literals([
40
+ "terminated",
41
+ "unknown",
42
+ "not-owned"
43
+ ]),
44
+ issues: Schema.Array(ChromiumCleanupIssue).check(Schema.isMaxLength(16))
45
+ }) {};
46
+ const Text = Schema.NonEmptyString.check(Schema.isMaxLength(4096), Schema.isPattern(/^[^\u0000\r\n]+$/u));
47
+ const Port = Schema.Int.check(Schema.isBetween({
48
+ minimum: 1,
49
+ maximum: 65535
50
+ }));
51
+ /** Only a concrete loopback WebSocket is admitted: no HTTP discovery redirects or remote DNS. */
52
+ const ChromiumEndpoint = Text.check(Schema.makeFilter((value) => {
53
+ try {
54
+ const url = new URL(value);
55
+ 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);
56
+ } catch {
57
+ return false;
58
+ }
59
+ }));
60
+ const ProxyServer = Text.check(Schema.makeFilter((value) => {
61
+ try {
62
+ const url = new URL(value);
63
+ return [
64
+ "http:",
65
+ "https:",
66
+ "socks5:"
67
+ ].includes(url.protocol) && url.hostname.length > 0 && !url.username && !url.password && !url.search && !url.hash && ["", "/"].includes(url.pathname);
68
+ } catch {
69
+ return false;
70
+ }
71
+ }));
72
+ /** These arguments belong to the launcher; silently overriding them would change ownership. */
73
+ 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)));
74
+ const ChromiumLaunch = Schema.Struct({
75
+ executablePath: Schema.optionalKey(Text),
76
+ headless: Schema.optionalKey(Schema.Boolean),
77
+ /** Enabled by default; a trusted host must explicitly choose a sandbox exception. */
78
+ chromiumSandbox: Schema.optionalKey(Schema.Boolean),
79
+ args: Schema.optionalKey(Schema.Array(Argument).check(Schema.isMaxLength(64))),
80
+ proxy: Schema.optionalKey(Schema.Struct({
81
+ server: ProxyServer,
82
+ bypass: Schema.optionalKey(Text)
83
+ })),
84
+ startupTimeoutMillis: Schema.optionalKey(Schema.Int.check(Schema.isBetween({
85
+ minimum: 1,
86
+ maximum: 6e4
87
+ })))
88
+ });
89
+ //#endregion
90
+ //#region src/internal/chromium/Process.ts
91
+ /** Explicit host sandbox/proxy choices; the owned profile and debugger endpoint cannot be replaced. */
92
+ const launchArguments = (options, directory) => [
93
+ "--no-first-run",
94
+ "--no-default-browser-check",
95
+ "--remote-debugging-address=127.0.0.1",
96
+ "--remote-debugging-port=0",
97
+ `--user-data-dir=${directory}`,
98
+ ...options.headless === false ? [] : ["--headless=new"],
99
+ ...options.chromiumSandbox === false ? ["--no-sandbox"] : [],
100
+ ...options.proxy === void 0 ? [] : [`--proxy-server=${options.proxy.server}`, `--proxy-bypass-list=${options.proxy.bypass ?? "<-loopback>"}`],
101
+ ...options.args ?? [],
102
+ "about:blank"
103
+ ];
104
+ const failure = (operation, reason) => BrowserError.make({
105
+ operation,
106
+ reason,
107
+ outcome: operation === "close" ? "unknown" : "undispatched"
108
+ });
109
+ const exited = (child) => child.exitCode !== null || child.signalCode !== null;
110
+ /** POSIX groups keep Chromium's helpers inside the same owned termination boundary. */
111
+ const alive = (pid) => {
112
+ try {
113
+ process.kill(-pid, 0);
114
+ return true;
115
+ } catch (error) {
116
+ if (error instanceof Error && "code" in error && error.code === "ESRCH") return false;
117
+ throw error;
118
+ }
119
+ };
120
+ const signalGroup = (pid, signal) => {
121
+ try {
122
+ process.kill(-pid, signal);
123
+ } catch (error) {
124
+ if (!(error instanceof Error && "code" in error && error.code === "ESRCH")) throw error;
125
+ }
126
+ };
127
+ /** Called once; observes parent and helper exit, rather than treating a sent signal as cleanup. */
128
+ const terminate = Effect.fnUntraced(function* (child, pid, clock) {
129
+ const stopped = Effect.try({
130
+ try: () => exited(child) && !alive(pid),
131
+ catch: () => failure("close", Reasons.Failed.make({}))
132
+ });
133
+ const signal = (value) => Effect.try({
134
+ try: () => signalGroup(pid, value),
135
+ catch: () => failure("close", Reasons.Failed.make({}))
136
+ });
137
+ const pause = clock.sleep(Duration.millis(20));
138
+ yield* signal("SIGTERM");
139
+ const graceful = clock.monotonicTimeNanosUnsafe() + 1500000000n;
140
+ while (!(yield* stopped) && clock.monotonicTimeNanosUnsafe() < graceful) yield* pause;
141
+ if (yield* stopped) return;
142
+ yield* signal("SIGKILL");
143
+ const forced = clock.monotonicTimeNanosUnsafe() + 1000000000n;
144
+ while (!(yield* stopped) && clock.monotonicTimeNanosUnsafe() < forced) yield* pause;
145
+ if (!(yield* stopped)) return yield* failure("close", Reasons.Timeout.make({}));
146
+ });
147
+ /** Start only Chromium's process. The shared owner later opens its sole CDP connection. */
148
+ const launch = Effect.fnUntraced(function* (options) {
149
+ if (process.platform === "win32") return yield* failure("launch", Reasons.Unsupported.make({}));
150
+ const path = yield* Path.Path.pipe(Effect.provide(Path.layer));
151
+ const clock = yield* Clock.Clock;
152
+ const executable = options.executablePath ?? (yield* Effect.tryPromise({
153
+ try: async () => (await import("playwright-core")).chromium.executablePath(),
154
+ catch: () => failure("launch", Reasons.Failed.make({}))
155
+ }));
156
+ const directory = yield* Effect.tryPromise({
157
+ try: () => mkdtemp(path.join(tmpdir(), "effect-browser-chromium-")),
158
+ catch: () => failure("launch", Reasons.Failed.make({}))
159
+ });
160
+ const removeProfile = Effect.tryPromise({
161
+ try: () => rm(directory, {
162
+ recursive: true,
163
+ force: true,
164
+ maxRetries: 5,
165
+ retryDelay: 50
166
+ }),
167
+ catch: () => failure("close", Reasons.Failed.make({}))
168
+ });
169
+ let child;
170
+ return yield* Effect.gen(function* () {
171
+ const launched = yield* Effect.tryPromise({
172
+ try: () => {
173
+ const spawned = spawn(executable, launchArguments(options, directory), {
174
+ cwd: directory,
175
+ stdio: [
176
+ "ignore",
177
+ "ignore",
178
+ "ignore"
179
+ ],
180
+ detached: true
181
+ });
182
+ child = spawned;
183
+ return new Promise((resolve, reject) => {
184
+ spawned.once("spawn", () => resolve(spawned));
185
+ spawned.once("error", reject);
186
+ });
187
+ },
188
+ catch: () => failure("launch", Reasons.Failed.make({}))
189
+ });
190
+ const pid = launched.pid;
191
+ if (pid === void 0) return yield* failure("launch", Reasons.Failed.make({}));
192
+ return {
193
+ connection: (timeoutMillis) => Effect.gen(function* () {
194
+ const deadline = clock.monotonicTimeNanosUnsafe() + BigInt(Math.ceil(Math.min(timeoutMillis, options.startupTimeoutMillis ?? 15e3))) * 1000000n;
195
+ while (clock.monotonicTimeNanosUnsafe() < deadline) {
196
+ if (exited(launched)) return yield* failure("connect", Reasons.Closed.make({}));
197
+ const portFile = yield* Effect.tryPromise({
198
+ try: (signal) => readFile(path.join(directory, "DevToolsActivePort"), {
199
+ encoding: "utf8",
200
+ signal
201
+ }).catch((error) => {
202
+ if (error instanceof Error && "code" in error && error.code === "ENOENT") return void 0;
203
+ throw error;
204
+ }),
205
+ catch: () => failure("connect", Reasons.Transport.make({}))
206
+ });
207
+ const lines = portFile === void 0 ? [] : portFile.trim().split("\n");
208
+ if (lines.length >= 2) {
209
+ const endpoint = `ws://127.0.0.1:${lines[0]}${lines[1]}`;
210
+ if (!Schema.is(ChromiumEndpoint)(endpoint)) return yield* failure("connect", Reasons.Malformed.make({}));
211
+ return Redacted.make(endpoint);
212
+ }
213
+ yield* clock.sleep(Duration.millis(20));
214
+ }
215
+ return yield* failure("connect", Reasons.Timeout.make({}));
216
+ }),
217
+ terminate: yield* Effect.cached(terminate(launched, pid, clock).pipe(Effect.uninterruptible)),
218
+ removeProfile
219
+ };
220
+ }).pipe(Effect.onExit((exit) => Exit.isSuccess(exit) ? Effect.void : Effect.gen(function* () {
221
+ if (child?.pid === void 0) {
222
+ yield* removeProfile.pipe(Effect.ignore);
223
+ return;
224
+ }
225
+ const stopped = yield* terminate(child, child.pid, clock).pipe(Effect.exit);
226
+ if (Exit.isSuccess(stopped)) yield* removeProfile.pipe(Effect.ignore);
227
+ })));
228
+ });
229
+ //#endregion
230
+ //#region src/internal/chromium/Session.ts
231
+ /** Each teardown step runs even when a preceding step fails. Only observed exit permits profile removal. */
232
+ const makeChromiumCleanup = Effect.fnUntraced(function* (reference, local, process) {
233
+ let latest;
234
+ return {
235
+ close: yield* Effect.cached(Effect.uninterruptible(Effect.gen(function* () {
236
+ const issues = [];
237
+ const step = (name, action) => cleanupStep(action, 3e3).pipe(Effect.tap((result) => Effect.sync(() => {
238
+ if (result._tag === "Failure") issues.push(ChromiumCleanupIssue.make({
239
+ step: name,
240
+ reason: result.reason
241
+ }));
242
+ })));
243
+ yield* step("fence", local.fence);
244
+ yield* step("capture", local.capture);
245
+ yield* step("initialization", local.initialization);
246
+ const disconnected = yield* step("disconnect", local.disconnect);
247
+ const terminated = process === void 0 ? void 0 : yield* step("terminate", process.terminate);
248
+ if (process !== void 0 && terminated !== void 0 && terminated._tag === "Success") yield* step("profile", process.removeProfile);
249
+ const result = ChromiumCleanupResult.make({
250
+ reference,
251
+ ownership: process === void 0 ? "borrowed" : "owned",
252
+ connection: disconnected._tag === "Success" ? disconnected.value : "failed",
253
+ process: terminated === void 0 ? "not-owned" : terminated._tag === "Success" ? "terminated" : "unknown",
254
+ issues
255
+ });
256
+ Object.freeze(result.issues);
257
+ latest = Object.freeze(result);
258
+ return latest;
259
+ }))),
260
+ result: Effect.sync(() => Option.fromNullishOr(latest))
261
+ };
262
+ });
263
+ const acquireChromium = (endpoint, options, onCleanup) => (local) => Effect.uninterruptible(Effect.gen(function* () {
264
+ const process = endpoint === void 0 ? yield* launch(options) : void 0;
265
+ const reference = Object.freeze(ChromiumReference.make({
266
+ provider: "chromium",
267
+ id: globalThis.crypto.randomUUID()
268
+ }));
269
+ const cleanup = yield* makeChromiumCleanup(reference, local, process);
270
+ let closing = false;
271
+ const release = yield* Effect.cached(Effect.gen(function* () {
272
+ closing = true;
273
+ const result = yield* cleanup.close;
274
+ if (onCleanup !== void 0) yield* reported(Effect.suspend(() => onCleanup(result)));
275
+ return result;
276
+ }).pipe(Effect.uninterruptible));
277
+ yield* Effect.addFinalizer(() => release.pipe(Effect.asVoid));
278
+ return {
279
+ reference,
280
+ connection: (timeoutMillis) => Effect.suspend(() => {
281
+ if (closing) return Effect.fail(BrowserError.make({
282
+ operation: "connect",
283
+ reason: Reasons.Closed.make({}),
284
+ outcome: "undispatched"
285
+ }));
286
+ if (process !== void 0) return process.connection(timeoutMillis);
287
+ return endpoint === void 0 ? Effect.fail(BrowserError.make({
288
+ operation: "connect",
289
+ reason: Reasons.Configuration.make({}),
290
+ outcome: "undispatched"
291
+ })) : checked(ChromiumEndpoint, Redacted.value(endpoint), "connect").pipe(Effect.map(Redacted.make));
292
+ }),
293
+ release,
294
+ closeChecked: release.pipe(Effect.filterOrFail((result) => result.connection === "closed" && result.issues.length === 0 && (result.ownership === "borrowed" ? result.process === "not-owned" : result.process === "terminated"), () => BrowserError.make({
295
+ operation: "close",
296
+ reason: Reasons.Failed.make({}),
297
+ outcome: "unknown"
298
+ }))),
299
+ cleanupResult: cleanup.result,
300
+ controlRetired: cleanup.result.pipe(Effect.map((result) => Option.isSome(result) && result.value.ownership === "owned" && result.value.process === "terminated"))
301
+ };
302
+ }));
303
+ const ownedChromium = (options, onCleanup) => acquireChromium(void 0, options, onCleanup);
304
+ const borrowedChromium = (endpoint, onCleanup) => acquireChromium(endpoint, {}, onCleanup);
305
+ //#endregion
306
+ //#region src/Chromium.ts
307
+ var Chromium = class Chromium extends Context.Service()("effect-browser/Chromium") {
308
+ /** Launch through the configured service; compose with Browser.scoped for supervised ownership. */
309
+ static launch(policy, request) {
310
+ return Effect.flatMap(Chromium, (browser) => browser.launch(policy, request));
311
+ }
312
+ /** Acquire the process lifetime before connecting, using the caller's scope. */
313
+ static acquire(policy, request) {
314
+ return Effect.flatMap(Chromium, (browser) => browser.acquire(policy, request));
315
+ }
316
+ /** Borrow a concrete loopback endpoint; cleanup never terminates its external process. */
317
+ static attach(endpoint, request) {
318
+ return Effect.flatMap(Chromium, (browser) => browser.attach(endpoint, request));
319
+ }
320
+ static layer(options = {}) {
321
+ return Layer.effect(Chromium, Effect.gen(function* () {
322
+ const launchInput = yield* checked(ChromiumLaunch, options.launch ?? {}, "configure");
323
+ const launch = Object.freeze({
324
+ ...launchInput,
325
+ ...launchInput.args === void 0 ? {} : { args: Object.freeze([...launchInput.args]) },
326
+ ...launchInput.proxy === void 0 ? {} : { proxy: Object.freeze({ ...launchInput.proxy }) }
327
+ });
328
+ if (Object.prototype.hasOwnProperty.call(options, "bootstrap")) return yield* BrowserError.make({
329
+ operation: "configure",
330
+ reason: Reasons.Configuration.make({}),
331
+ outcome: "undispatched"
332
+ });
333
+ const runtime = yield* make({
334
+ implementation: "chromium-playwright-cdp",
335
+ ...options.viewport === void 0 ? {} : { viewport: options.viewport },
336
+ automation: {
337
+ ...options.actionTimeoutMillis === void 0 ? {} : { actionTimeoutMillis: options.actionTimeoutMillis },
338
+ ...options.maxPages === void 0 ? {} : { maxPages: options.maxPages },
339
+ ...options.maxHostReads === void 0 ? {} : { maxHostReads: options.maxHostReads },
340
+ ...options.initialPage === void 0 ? {} : { initialPage: options.initialPage },
341
+ ...options.popupPolicy === void 0 ? {} : { popupPolicy: options.popupPolicy },
342
+ ...options.dialogPolicy === void 0 ? {} : { dialogPolicy: options.dialogPolicy },
343
+ ...options.pageControl === void 0 ? {} : { pageControl: options.pageControl }
344
+ }
345
+ });
346
+ const acquire = Effect.fnUntraced(function* (policy, request = {}, attachment) {
347
+ const acquired = yield* runtime.acquire(policy, attachment === void 0 ? ownedChromium(launch, options.onCleanup) : borrowedChromium(attachment.endpoint, options.onCleanup), {
348
+ ...request,
349
+ ...attachment === void 0 ? {} : { existingTarget: attachment.targetId === void 0 ? {} : { targetId: attachment.targetId } }
350
+ });
351
+ const connected = yield* Effect.cached(acquired.connect.pipe(Effect.map(({ session }) => Object.assign(session, {
352
+ reference: acquired.reference,
353
+ closeChecked: session.closeChecked.pipe(Effect.andThen(acquired.lifetime.closeChecked)),
354
+ close: acquired.close,
355
+ cleanupResult: acquired.lifetime.cleanupResult
356
+ }))));
357
+ return {
358
+ reference: acquired.reference,
359
+ failure: acquired.failure,
360
+ close: acquired.close,
361
+ connect: acquired.connect.pipe(Effect.andThen(connected))
362
+ };
363
+ });
364
+ return Chromium.of({
365
+ acquire,
366
+ launch: (policy, request) => acquire(policy, request).pipe(Effect.flatMap((acquired) => acquired.connect)),
367
+ attach: (endpoint, request) => Effect.gen(function* () {
368
+ const address = yield* checked(ChromiumEndpoint, Redacted.value(endpoint), "connect");
369
+ return yield* (yield* acquire(request.policy, request, {
370
+ endpoint: Redacted.make(address),
371
+ ...request.target === void 0 ? {} : { targetId: request.target.targetId }
372
+ })).connect;
373
+ })
374
+ });
375
+ }));
376
+ }
377
+ };
378
+ //#endregion
379
+ export { Chromium, ChromiumCleanupIssue, ChromiumCleanupResult, ChromiumLaunch, ChromiumReference };
380
+
381
+ //# sourceMappingURL=Chromium.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Chromium.mjs","names":["BrowserRuntime.make"],"sources":["../src/internal/chromium/Data.ts","../src/internal/chromium/Process.ts","../src/internal/chromium/Session.ts","../src/Chromium.ts"],"sourcesContent":["import { Schema } from \"effect\";\n\nimport { Identifier } from \"../../BrowserData.ts\";\n\n/** Identifies this Chromium ownership lifetime, not a reusable endpoint. */\nexport class ChromiumReference extends Schema.Class<ChromiumReference>(\"ChromiumReference\")({\n provider: Schema.Literal(\"chromium\"),\n id: Identifier,\n}) {}\n\nexport class ChromiumCleanupIssue extends Schema.Class<ChromiumCleanupIssue>(\n \"ChromiumCleanupIssue\",\n)({\n step: Schema.Literals([\n \"fence\",\n \"capture\",\n \"initialization\",\n \"disconnect\",\n \"terminate\",\n \"profile\",\n ]),\n reason: Schema.Literals([\"timeout\", \"failed\", \"interrupted\"]),\n}) {}\n\n/** Connection teardown and observed process exit are separate facts; no provider status exists. */\nexport class ChromiumCleanupResult extends Schema.Class<ChromiumCleanupResult>(\n \"ChromiumCleanupResult\",\n)({\n reference: ChromiumReference,\n ownership: Schema.Literals([\"owned\", \"borrowed\"]),\n connection: Schema.Literals([\"closed\", \"failed\", \"not-connected\", \"pending\"]),\n process: Schema.Literals([\"terminated\", \"unknown\", \"not-owned\"]),\n issues: Schema.Array(ChromiumCleanupIssue).check(Schema.isMaxLength(16)),\n}) {}\n\nconst Text = Schema.NonEmptyString.check(\n Schema.isMaxLength(4096),\n Schema.isPattern(/^[^\\u0000\\r\\n]+$/u),\n);\n\nconst Port = Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 65535 }));\n\n/** Only a concrete loopback WebSocket is admitted: no HTTP discovery redirects or remote DNS. */\nexport const ChromiumEndpoint = Text.check(\n Schema.makeFilter((value) => {\n try {\n const url = new URL(value);\n\n return (\n url.protocol === \"ws:\" &&\n [\"127.0.0.1\", \"[::1]\"].includes(url.hostname) &&\n Schema.is(Port)(Number(url.port)) &&\n !url.username &&\n !url.password &&\n !url.search &&\n !url.hash &&\n /^\\/devtools\\/browser\\/[A-Za-z0-9_-]+$/u.test(url.pathname)\n );\n } catch {\n return false;\n }\n }),\n);\n\nconst ProxyServer = Text.check(\n Schema.makeFilter((value) => {\n try {\n const url = new URL(value);\n\n return (\n [\"http:\", \"https:\", \"socks5:\"].includes(url.protocol) &&\n url.hostname.length > 0 &&\n !url.username &&\n !url.password &&\n !url.search &&\n !url.hash &&\n [\"\", \"/\"].includes(url.pathname)\n );\n } catch {\n return false;\n }\n }),\n);\n\n/** These arguments belong to the launcher; silently overriding them would change ownership. */\nconst Argument = Text.check(\n Schema.makeFilter(\n (value) =>\n value.startsWith(\"--\") &&\n !/^--(?:user-data-dir|remote-debugging[^=]*|headless|no-sandbox|disable-setuid-sandbox|single-process|proxy-server|proxy-bypass-list)(?:=|$)/u.test(\n value,\n ),\n ),\n);\n\nexport const ChromiumLaunch = Schema.Struct({\n executablePath: Schema.optionalKey(Text),\n headless: Schema.optionalKey(Schema.Boolean),\n /** Enabled by default; a trusted host must explicitly choose a sandbox exception. */\n chromiumSandbox: Schema.optionalKey(Schema.Boolean),\n args: Schema.optionalKey(Schema.Array(Argument).check(Schema.isMaxLength(64))),\n proxy: Schema.optionalKey(\n Schema.Struct({\n server: ProxyServer,\n bypass: Schema.optionalKey(Text),\n }),\n ),\n startupTimeoutMillis: Schema.optionalKey(\n Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 60000 })),\n ),\n});\n\nexport type ChromiumLaunch = typeof ChromiumLaunch.Type;\n","// rc.115's NodeChildProcessSpawner exposes leader exit, but its bounded group wait can\n// succeed with surviving members. This boundary must observe the leader AND group gone.\n// @effect-diagnostics-next-line nodeBuiltinImport:off\nimport { spawn, type ChildProcess } from \"node:child_process\";\n// FileSystem.remove exposes recursive/force only, not rm's per-entry OS-error retries.\n// Keep native profile creation/read/removal together; removal follows confirmed group exit.\n// @effect-diagnostics-next-line nodeBuiltinImport:off\nimport { mkdtemp, readFile, rm } from \"node:fs/promises\";\nimport { tmpdir } from \"node:os\";\n\nimport { Clock, Duration, Effect, Exit, Path, Redacted, Schema } from \"effect\";\n\nimport { Reasons, BrowserError } from \"../../Errors.ts\";\nimport { ChromiumEndpoint, type ChromiumLaunch } from \"./Data.ts\";\n\nexport interface ChromiumProcess {\n readonly connection: (\n timeoutMillis: number,\n ) => Effect.Effect<Redacted.Redacted<string>, BrowserError>;\n readonly terminate: Effect.Effect<void, BrowserError>;\n readonly removeProfile: Effect.Effect<void, BrowserError>;\n}\n\n/** Explicit host sandbox/proxy choices; the owned profile and debugger endpoint cannot be replaced. */\nexport const launchArguments = (options: ChromiumLaunch, directory: string): string[] => [\n \"--no-first-run\",\n \"--no-default-browser-check\",\n \"--remote-debugging-address=127.0.0.1\",\n \"--remote-debugging-port=0\",\n `--user-data-dir=${directory}`,\n ...(options.headless === false ? [] : [\"--headless=new\"]),\n ...(options.chromiumSandbox === false ? [\"--no-sandbox\"] : []),\n ...(options.proxy === undefined\n ? []\n : [\n `--proxy-server=${options.proxy.server}`,\n // Chromium otherwise bypasses proxies for loopback. The host may deliberately override it.\n `--proxy-bypass-list=${options.proxy.bypass ?? \"<-loopback>\"}`,\n ]),\n ...(options.args ?? []),\n \"about:blank\",\n];\n\nconst failure = (operation: \"launch\" | \"connect\" | \"close\", reason: BrowserError[\"reason\"]) =>\n BrowserError.make({\n operation,\n reason,\n outcome: operation === \"close\" ? \"unknown\" : \"undispatched\",\n });\n\nconst exited = (child: ChildProcess) => child.exitCode !== null || child.signalCode !== null;\n\n/** POSIX groups keep Chromium's helpers inside the same owned termination boundary. */\nconst alive = (pid: number): boolean => {\n try {\n process.kill(-pid, 0);\n\n return true;\n } catch (error) {\n if (error instanceof Error && \"code\" in error && error.code === \"ESRCH\") return false;\n throw error;\n }\n};\n\nconst signalGroup = (pid: number, signal: NodeJS.Signals) => {\n try {\n process.kill(-pid, signal);\n } catch (error) {\n if (!(error instanceof Error && \"code\" in error && error.code === \"ESRCH\")) throw error;\n }\n};\n\n/** Called once; observes parent and helper exit, rather than treating a sent signal as cleanup. */\nconst terminate = Effect.fnUntraced(function* (\n child: ChildProcess,\n pid: number,\n clock: Clock.Clock,\n): Effect.fn.Return<void, BrowserError> {\n const stopped = Effect.try({\n try: () => exited(child) && !alive(pid),\n catch: () => failure(\"close\", Reasons.Failed.make({})),\n });\n\n const signal = (value: NodeJS.Signals) =>\n Effect.try({\n try: () => signalGroup(pid, value),\n catch: () => failure(\"close\", Reasons.Failed.make({})),\n });\n\n const pause = clock.sleep(Duration.millis(20));\n\n yield* signal(\"SIGTERM\");\n const graceful = clock.monotonicTimeNanosUnsafe() + 1_500_000_000n;\n\n while (!(yield* stopped) && clock.monotonicTimeNanosUnsafe() < graceful) yield* pause;\n if (yield* stopped) return;\n yield* signal(\"SIGKILL\");\n const forced = clock.monotonicTimeNanosUnsafe() + 1_000_000_000n;\n\n while (!(yield* stopped) && clock.monotonicTimeNanosUnsafe() < forced) yield* pause;\n if (!(yield* stopped)) return yield* failure(\"close\", Reasons.Timeout.make({}));\n});\n\n/** Start only Chromium's process. The shared owner later opens its sole CDP connection. */\nexport const launch = Effect.fnUntraced(function* (\n options: ChromiumLaunch,\n): Effect.fn.Return<ChromiumProcess, BrowserError> {\n if (process.platform === \"win32\") return yield* failure(\"launch\", Reasons.Unsupported.make({}));\n const path = yield* Path.Path.pipe(Effect.provide(Path.layer));\n const clock = yield* Clock.Clock;\n\n const executable =\n options.executablePath ??\n (yield* Effect.tryPromise({\n try: async () => (await import(\"playwright-core\")).chromium.executablePath(),\n catch: () => failure(\"launch\", Reasons.Failed.make({})),\n }));\n\n const directory = yield* Effect.tryPromise({\n try: () => mkdtemp(path.join(tmpdir(), \"effect-browser-chromium-\")),\n catch: () => failure(\"launch\", Reasons.Failed.make({})),\n });\n\n const removeProfile = Effect.tryPromise({\n try: () => rm(directory, { recursive: true, force: true, maxRetries: 5, retryDelay: 50 }),\n catch: () => failure(\"close\", Reasons.Failed.make({})),\n });\n\n let child: ChildProcess | undefined;\n\n return yield* Effect.gen(function* () {\n const launched = yield* Effect.tryPromise({\n try: () => {\n const spawned = spawn(executable, launchArguments(options, directory), {\n cwd: directory,\n stdio: [\"ignore\", \"ignore\", \"ignore\"],\n detached: true,\n });\n\n child = spawned;\n\n return new Promise<ChildProcess>((resolve, reject) => {\n spawned.once(\"spawn\", () => resolve(spawned));\n spawned.once(\"error\", reject);\n });\n },\n catch: () => failure(\"launch\", Reasons.Failed.make({})),\n });\n\n const pid = launched.pid;\n\n if (pid === undefined) return yield* failure(\"launch\", Reasons.Failed.make({}));\n\n // One termination continues to its own bounded group-exit decision even if a waiter cancels.\n const closing = yield* Effect.cached(\n terminate(launched, pid, clock).pipe(Effect.uninterruptible),\n );\n\n return {\n connection: (timeoutMillis) =>\n Effect.gen(function* () {\n const deadline =\n clock.monotonicTimeNanosUnsafe() +\n BigInt(Math.ceil(Math.min(timeoutMillis, options.startupTimeoutMillis ?? 15000))) *\n 1_000_000n;\n\n while (clock.monotonicTimeNanosUnsafe() < deadline) {\n if (exited(launched)) return yield* failure(\"connect\", Reasons.Closed.make({}));\n\n const portFile = yield* Effect.tryPromise({\n try: (signal) =>\n readFile(path.join(directory, \"DevToolsActivePort\"), {\n encoding: \"utf8\",\n signal,\n }).catch((error: unknown) => {\n if (error instanceof Error && \"code\" in error && error.code === \"ENOENT\")\n return undefined;\n throw error;\n }),\n catch: () => failure(\"connect\", Reasons.Transport.make({})),\n });\n\n // Chromium creates DevToolsActivePort before it writes the port and path into it. A\n // file without both lines is startup still in progress, not an endpoint; only a\n // complete file that is not a loopback DevTools endpoint is malformed.\n const lines = portFile === undefined ? [] : portFile.trim().split(\"\\n\");\n\n if (lines.length >= 2) {\n const endpoint = `ws://127.0.0.1:${lines[0]}${lines[1]}`;\n\n if (!Schema.is(ChromiumEndpoint)(endpoint))\n return yield* failure(\"connect\", Reasons.Malformed.make({}));\n\n return Redacted.make(endpoint);\n }\n yield* clock.sleep(Duration.millis(20));\n }\n\n return yield* failure(\"connect\", Reasons.Timeout.make({}));\n }),\n terminate: closing,\n removeProfile,\n } satisfies ChromiumProcess;\n }).pipe(\n Effect.onExit((exit) =>\n Exit.isSuccess(exit)\n ? Effect.void\n : Effect.gen(function* () {\n if (child?.pid === undefined) {\n yield* removeProfile.pipe(Effect.ignore);\n\n return;\n }\n const stopped = yield* terminate(child, child.pid, clock).pipe(Effect.exit);\n\n if (Exit.isSuccess(stopped)) yield* removeProfile.pipe(Effect.ignore);\n }),\n ),\n );\n});\n","import { Effect, Option, Redacted } from \"effect\";\n\nimport type { Lifetime, Source } from \"../../BrowserRuntime.ts\";\nimport { BrowserError, Reasons } from \"../../Errors.ts\";\nimport { cleanupStep, reported, type ConnectionCleanup } from \"../browser/ConnectionCleanup.ts\";\nimport { checked } from \"../browser/PublicSession.ts\";\nimport {\n ChromiumCleanupIssue,\n ChromiumCleanupResult,\n ChromiumEndpoint,\n ChromiumReference,\n type ChromiumLaunch,\n} from \"./Data.ts\";\nimport { launch, type ChromiumProcess } from \"./Process.ts\";\n\nexport interface ChromiumLease extends Lifetime {\n readonly reference: ChromiumReference;\n readonly closeChecked: Effect.Effect<ChromiumCleanupResult, BrowserError>;\n readonly release: Effect.Effect<ChromiumCleanupResult>;\n readonly cleanupResult: Effect.Effect<Option.Option<ChromiumCleanupResult>>;\n}\n\n/** Each teardown step runs even when a preceding step fails. Only observed exit permits profile removal. */\nexport const makeChromiumCleanup = Effect.fnUntraced(function* (\n reference: ChromiumReference,\n local: ConnectionCleanup,\n process: ChromiumProcess | undefined,\n) {\n let latest: ChromiumCleanupResult | undefined;\n\n const close = yield* Effect.cached(\n Effect.uninterruptible(\n Effect.gen(function* () {\n const issues: ChromiumCleanupIssue[] = [];\n\n const step = <A, E>(name: ChromiumCleanupIssue[\"step\"], action: Effect.Effect<A, E>) =>\n cleanupStep(action, 3000).pipe(\n Effect.tap((result) =>\n Effect.sync(() => {\n if (result._tag === \"Failure\")\n issues.push(ChromiumCleanupIssue.make({ step: name, reason: result.reason }));\n }),\n ),\n );\n\n yield* step(\"fence\", local.fence);\n yield* step(\"capture\", local.capture);\n yield* step(\"initialization\", local.initialization);\n const disconnected = yield* step(\"disconnect\", local.disconnect);\n\n const terminated =\n process === undefined ? undefined : yield* step(\"terminate\", process.terminate);\n\n if (process !== undefined && terminated !== undefined && terminated._tag === \"Success\")\n yield* step(\"profile\", process.removeProfile);\n\n const result = ChromiumCleanupResult.make({\n reference,\n ownership: process === undefined ? \"borrowed\" : \"owned\",\n connection: disconnected._tag === \"Success\" ? disconnected.value : \"failed\",\n process:\n terminated === undefined\n ? \"not-owned\"\n : terminated._tag === \"Success\"\n ? \"terminated\"\n : \"unknown\",\n issues,\n });\n\n Object.freeze(result.issues);\n latest = Object.freeze(result);\n\n return latest;\n }),\n ),\n );\n\n return { close, result: Effect.sync(() => Option.fromNullishOr(latest)) };\n});\n\nconst acquireChromium =\n (\n endpoint: Redacted.Redacted<string> | undefined,\n options: ChromiumLaunch,\n onCleanup?: (result: ChromiumCleanupResult) => Effect.Effect<void>,\n ): Source<ChromiumLease, BrowserError, never> =>\n (local) =>\n Effect.uninterruptible(\n Effect.gen(function* () {\n // The process cannot escape between spawn and finalizer registration. Startup waiting happens\n // later in connect, where it is interruptible and the owning finalizer is already installed.\n const process = endpoint === undefined ? yield* launch(options) : undefined;\n\n const reference = Object.freeze(\n ChromiumReference.make({ provider: \"chromium\", id: globalThis.crypto.randomUUID() }),\n );\n\n const cleanup = yield* makeChromiumCleanup(reference, local, process);\n let closing = false;\n\n const release = yield* Effect.cached(\n Effect.gen(function* () {\n closing = true;\n const result = yield* cleanup.close;\n\n if (onCleanup !== undefined) yield* reported(Effect.suspend(() => onCleanup(result)));\n\n return result;\n }).pipe(Effect.uninterruptible),\n );\n\n yield* Effect.addFinalizer(() => release.pipe(Effect.asVoid));\n\n return {\n reference,\n connection: (timeoutMillis) =>\n Effect.suspend(() => {\n if (closing)\n return Effect.fail(\n BrowserError.make({\n operation: \"connect\",\n reason: Reasons.Closed.make({}),\n outcome: \"undispatched\",\n }),\n );\n if (process !== undefined) return process.connection(timeoutMillis);\n\n return endpoint === undefined\n ? Effect.fail(\n BrowserError.make({\n operation: \"connect\",\n reason: Reasons.Configuration.make({}),\n outcome: \"undispatched\",\n }),\n )\n : checked(ChromiumEndpoint, Redacted.value(endpoint), \"connect\").pipe(\n Effect.map(Redacted.make),\n );\n }),\n release,\n closeChecked: release.pipe(\n Effect.filterOrFail(\n (result) =>\n result.connection === \"closed\" &&\n result.issues.length === 0 &&\n (result.ownership === \"borrowed\"\n ? result.process === \"not-owned\"\n : result.process === \"terminated\"),\n () =>\n BrowserError.make({\n operation: \"close\",\n reason: Reasons.Failed.make({}),\n outcome: \"unknown\",\n }),\n ),\n ),\n cleanupResult: cleanup.result,\n controlRetired: cleanup.result.pipe(\n Effect.map(\n (result) =>\n Option.isSome(result) &&\n result.value.ownership === \"owned\" &&\n result.value.process === \"terminated\",\n ),\n ),\n } satisfies ChromiumLease;\n }),\n );\n\nexport const ownedChromium = (\n options: ChromiumLaunch,\n onCleanup?: (result: ChromiumCleanupResult) => Effect.Effect<void>,\n) => acquireChromium(undefined, options, onCleanup);\n\nexport const borrowedChromium = (\n endpoint: Redacted.Redacted<string>,\n onCleanup?: (result: ChromiumCleanupResult) => Effect.Effect<void>,\n) => acquireChromium(endpoint, {}, onCleanup);\n","import { Context, Effect, Layer, type Option, Redacted, type Scope } from \"effect\";\n\nimport type { BrowserSession, OpenOptions } from \"./Browser.ts\";\nimport type { AutomationOptions, BrowserPolicy, Viewport } from \"./BrowserData.ts\";\nimport * as BrowserRuntime from \"./BrowserRuntime.ts\";\nimport { BrowserError, Reasons, type InitializationError } from \"./Errors.ts\";\nimport { checked } from \"./internal/browser/PublicSession.ts\";\nimport {\n ChromiumEndpoint,\n ChromiumLaunch,\n type ChromiumCleanupResult,\n type ChromiumReference,\n} from \"./internal/chromium/Data.ts\";\nimport { borrowedChromium, ownedChromium } from \"./internal/chromium/Session.ts\";\n\nexport {\n ChromiumCleanupIssue,\n ChromiumCleanupResult,\n ChromiumLaunch,\n ChromiumReference,\n} from \"./internal/chromium/Data.ts\";\n\n/** Host-only process configuration. Building this layer neither loads Playwright nor starts Chromium. */\nexport interface ChromiumOptions extends AutomationOptions {\n readonly launch?: ChromiumLaunch;\n readonly viewport?: Viewport;\n readonly onCleanup?: (result: ChromiumCleanupResult) => Effect.Effect<void>;\n}\n\n/** An owned or borrowed Chromium lifetime with one modeled browser connection. */\nexport interface ChromiumSession<E = never> extends BrowserSession<E> {\n readonly reference: ChromiumReference;\n readonly closeChecked: Effect.Effect<ChromiumCleanupResult, BrowserError>;\n readonly close: Effect.Effect<ChromiumCleanupResult>;\n readonly cleanupResult: Effect.Effect<Option.Option<ChromiumCleanupResult>>;\n}\n\nexport interface ChromiumAcquisition<E = never> {\n readonly reference: ChromiumReference;\n readonly failure: Effect.Effect<never, E | InitializationError>;\n readonly connect: Effect.Effect<ChromiumSession<E>, BrowserError | InitializationError | E>;\n readonly close: Effect.Effect<ChromiumCleanupResult>;\n}\n\nexport interface ChromiumAttachRequest<E = never, R = never> extends OpenOptions<E, R> {\n readonly policy: BrowserPolicy;\n /** Resolve this exact target; without it, multiple open pages are an ambiguity error. */\n readonly target?: { readonly targetId: string };\n}\n\nexport class Chromium extends Context.Service<\n Chromium,\n {\n readonly acquire: <E = never, R = never>(\n policy: BrowserPolicy,\n request?: OpenOptions<E, R>,\n ) => Effect.Effect<ChromiumAcquisition<E>, BrowserError, Scope.Scope | Exclude<R, Scope.Scope>>;\n readonly launch: <E = never, R = never>(\n policy: BrowserPolicy,\n request?: OpenOptions<E, R>,\n ) => Effect.Effect<\n ChromiumSession<E>,\n BrowserError | InitializationError | E,\n Scope.Scope | Exclude<R, Scope.Scope>\n >;\n /** A concrete loopback ws://.../devtools/browser/... endpoint; this scope owns only its connection. */\n readonly attach: <E = never, R = never>(\n endpoint: Redacted.Redacted<string>,\n request: ChromiumAttachRequest<E, R>,\n ) => Effect.Effect<\n ChromiumSession<E>,\n BrowserError | InitializationError | E,\n Scope.Scope | Exclude<R, Scope.Scope>\n >;\n }\n>()(\"effect-browser/Chromium\") {\n /** Launch through the configured service; compose with Browser.scoped for supervised ownership. */\n static launch<E = never, R = never>(policy: BrowserPolicy, request?: OpenOptions<E, R>) {\n return Effect.flatMap(Chromium, (browser) => browser.launch(policy, request));\n }\n\n /** Acquire the process lifetime before connecting, using the caller's scope. */\n static acquire<E = never, R = never>(policy: BrowserPolicy, request?: OpenOptions<E, R>) {\n return Effect.flatMap(Chromium, (browser) => browser.acquire(policy, request));\n }\n\n /** Borrow a concrete loopback endpoint; cleanup never terminates its external process. */\n static attach<E = never, R = never>(\n endpoint: Redacted.Redacted<string>,\n request: ChromiumAttachRequest<E, R>,\n ) {\n return Effect.flatMap(Chromium, (browser) => browser.attach(endpoint, request));\n }\n\n static layer(options: ChromiumOptions = {}): Layer.Layer<Chromium, BrowserError> {\n return Layer.effect(\n Chromium,\n Effect.gen(function* () {\n const launchInput = yield* checked(ChromiumLaunch, options.launch ?? {}, \"configure\");\n\n const launch = Object.freeze({\n ...launchInput,\n ...(launchInput.args === undefined ? {} : { args: Object.freeze([...launchInput.args]) }),\n ...(launchInput.proxy === undefined\n ? {}\n : { proxy: Object.freeze({ ...launchInput.proxy }) }),\n });\n\n if (Object.prototype.hasOwnProperty.call(options, \"bootstrap\"))\n return yield* BrowserError.make({\n operation: \"configure\",\n reason: Reasons.Configuration.make({}),\n outcome: \"undispatched\",\n });\n\n const runtime = yield* BrowserRuntime.make({\n implementation: \"chromium-playwright-cdp\",\n ...(options.viewport === undefined ? {} : { viewport: options.viewport }),\n automation: {\n ...(options.actionTimeoutMillis === undefined\n ? {}\n : { actionTimeoutMillis: options.actionTimeoutMillis }),\n ...(options.maxPages === undefined ? {} : { maxPages: options.maxPages }),\n ...(options.maxHostReads === undefined ? {} : { maxHostReads: options.maxHostReads }),\n ...(options.initialPage === undefined ? {} : { initialPage: options.initialPage }),\n ...(options.popupPolicy === undefined ? {} : { popupPolicy: options.popupPolicy }),\n ...(options.dialogPolicy === undefined ? {} : { dialogPolicy: options.dialogPolicy }),\n ...(options.pageControl === undefined ? {} : { pageControl: options.pageControl }),\n },\n });\n\n const acquire = Effect.fnUntraced(function* <E = never, R = never>(\n policy: BrowserPolicy,\n request: OpenOptions<E, R> = {},\n attachment?: { readonly endpoint: Redacted.Redacted<string>; readonly targetId?: string },\n ) {\n const acquired = yield* runtime.acquire(\n policy,\n attachment === undefined\n ? ownedChromium(launch, options.onCleanup)\n : borrowedChromium(attachment.endpoint, options.onCleanup),\n {\n ...request,\n ...(attachment === undefined\n ? {}\n : {\n existingTarget:\n attachment.targetId === undefined ? {} : { targetId: attachment.targetId },\n }),\n },\n );\n\n const connected = yield* Effect.cached(\n acquired.connect.pipe(\n Effect.map(({ session }): ChromiumSession<E> =>\n Object.assign(session, {\n reference: acquired.reference,\n closeChecked: session.closeChecked.pipe(\n Effect.andThen(acquired.lifetime.closeChecked),\n ),\n close: acquired.close,\n cleanupResult: acquired.lifetime.cleanupResult,\n }),\n ),\n ),\n );\n\n return {\n reference: acquired.reference,\n failure: acquired.failure,\n close: acquired.close,\n connect: acquired.connect.pipe(Effect.andThen(connected)),\n } satisfies ChromiumAcquisition<E>;\n });\n\n return Chromium.of({\n acquire,\n launch: (policy, request) =>\n acquire(policy, request).pipe(Effect.flatMap((acquired) => acquired.connect)),\n attach: (endpoint, request) =>\n Effect.gen(function* () {\n const address = yield* checked(ChromiumEndpoint, Redacted.value(endpoint), \"connect\");\n\n return yield* (yield* acquire(request.policy, request, {\n endpoint: Redacted.make(address),\n ...(request.target === undefined ? {} : { targetId: request.target.targetId }),\n })).connect;\n }),\n });\n }),\n );\n }\n}\n"],"mappings":";;;;;;;;;AAKA,IAAa,oBAAb,cAAuC,OAAO,MAAyB,mBAAmB,CAAC,CAAC;CAC1F,UAAU,OAAO,QAAQ,UAAU;CACnC,IAAI;AACN,CAAC,CAAC,CAAC,CAAC;AAEJ,IAAa,uBAAb,cAA0C,OAAO,MAC/C,sBACF,CAAC,CAAC;CACA,MAAM,OAAO,SAAS;EACpB;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;CACD,QAAQ,OAAO,SAAS;EAAC;EAAW;EAAU;CAAa,CAAC;AAC9D,CAAC,CAAC,CAAC,CAAC;;AAGJ,IAAa,wBAAb,cAA2C,OAAO,MAChD,uBACF,CAAC,CAAC;CACA,WAAW;CACX,WAAW,OAAO,SAAS,CAAC,SAAS,UAAU,CAAC;CAChD,YAAY,OAAO,SAAS;EAAC;EAAU;EAAU;EAAiB;CAAS,CAAC;CAC5E,SAAS,OAAO,SAAS;EAAC;EAAc;EAAW;CAAW,CAAC;CAC/D,QAAQ,OAAO,MAAM,oBAAoB,CAAC,CAAC,MAAM,OAAO,YAAY,EAAE,CAAC;AACzE,CAAC,CAAC,CAAC,CAAC;AAEJ,MAAM,OAAO,OAAO,eAAe,MACjC,OAAO,YAAY,IAAI,GACvB,OAAO,UAAU,mBAAmB,CACtC;AAEA,MAAM,OAAO,OAAO,IAAI,MAAM,OAAO,UAAU;CAAE,SAAS;CAAG,SAAS;AAAM,CAAC,CAAC;;AAG9E,MAAa,mBAAmB,KAAK,MACnC,OAAO,YAAY,UAAU;CAC3B,IAAI;EACF,MAAM,MAAM,IAAI,IAAI,KAAK;EAEzB,OACE,IAAI,aAAa,SACjB,CAAC,aAAa,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OAAO,QAAQ,QAAQ,QAAQ,SAAS;MACrD,UAAU,SAAS,KAAK,OAAO;MAC/B,GAAI,QAAQ,WAAW,KAAA,IAAY,CAAC,IAAI,EAAE,UAAU,QAAQ,OAAO,SAAS;KAC9E,CAAC,EAAA,CAAG;IACN,CAAC;GACL,CAAC;EACH,CAAC,CACH;CACF;AACF"}
@@ -0,0 +1,106 @@
1
+ import { Schema } from "effect";
2
+ //#region src/Errors.d.ts
3
+ /**
4
+ * What a caller asked the owned browser to do. The vocabulary is closed: the owner stamps it
5
+ * when it admits an operation, so a native step's own name can never become API, and a new
6
+ * spelling is a deliberate edit here rather than a string that merely compiles.
7
+ */
8
+ export declare const BrowserOperation: Schema.Literals<readonly ["configure", "launch", "connect", "reconnect", "detach", "disconnect", "close", "handoff", "resume", "live-view", "target", "handle", "list-pages", "list-frames", "select-page", "select-frame", "new-page", "close-page", "resize", "ready", "observe", "checkpoint", "control-facts", "revalidate", "read-text", "screenshot", "wait", "navigate", "navigate-stop", "click", "fill", "select-option", "scroll", "click-and-wait", "download-action", "select-files", "file-chooser", "action-result", "pointer-move", "hover", "wheel", "press", "type", "page-control", "page-state", "page-suspend", "page-resume", "capture", "capture-start", "capture-stop", "capture-consume"]>;
9
+ export type BrowserOperation = typeof BrowserOperation.Type;
10
+ /** Dispatch evidence belongs to the operation, independently of its failure reason. */
11
+ export declare const BrowserOutcome: Schema.Literals<readonly ["undispatched", "rejected", "unknown"]>;
12
+ export type BrowserOutcome = typeof BrowserOutcome.Type;
13
+ /** Limits report measured producer facts; an unavailable measurement is never invented. */
14
+ export declare const LimitDimension: Schema.Literals<readonly ["actions", "elapsed", "returned-bytes", "pages", "frames", "frame-depth", "buffered-frames", "buffered-bytes", "host-reads", "controls", "text", "captures", "frame-bytes", "width", "height", "pixels"]>;
15
+ /** Validated constructors for host reasons. The model receives a separate bounded projection. */
16
+ export declare const Reasons: {
17
+ readonly Configuration: Schema.TaggedStruct<"Configuration", {
18
+ readonly path: Schema.optionalKey<Schema.String>;
19
+ }>;
20
+ readonly UnregisteredSession: Schema.TaggedStruct<"UnregisteredSession", {}>;
21
+ readonly Unsupported: Schema.TaggedStruct<"Unsupported", {}>;
22
+ readonly Busy: Schema.TaggedStruct<"Busy", {}>;
23
+ readonly Closed: Schema.TaggedStruct<"Closed", {}>;
24
+ readonly Stale: Schema.TaggedStruct<"Stale", {}>;
25
+ readonly NotFound: Schema.TaggedStruct<"NotFound", {}>;
26
+ readonly Ambiguous: Schema.TaggedStruct<"Ambiguous", {}>;
27
+ readonly Malformed: Schema.TaggedStruct<"Malformed", {
28
+ readonly path: Schema.optionalKey<Schema.String>;
29
+ }>;
30
+ readonly Limit: Schema.TaggedStruct<"Limit", {
31
+ readonly dimension: Schema.Literals<readonly ["actions", "elapsed", "returned-bytes", "pages", "frames", "frame-depth", "buffered-frames", "buffered-bytes", "host-reads", "controls", "text", "captures", "frame-bytes", "width", "height", "pixels"]>;
32
+ readonly maximum: Schema.Natural;
33
+ readonly observed: Schema.Natural;
34
+ }>;
35
+ readonly Timeout: Schema.TaggedStruct<"Timeout", {}>;
36
+ readonly Transport: Schema.TaggedStruct<"Transport", {
37
+ readonly status: Schema.optionalKey<Schema.Int>;
38
+ }>;
39
+ readonly Provider: Schema.TaggedStruct<"Provider", {
40
+ readonly status: Schema.optionalKey<Schema.Int>;
41
+ }>;
42
+ readonly Authorization: Schema.TaggedStruct<"Authorization", {}>;
43
+ readonly RateLimited: Schema.TaggedStruct<"RateLimited", {
44
+ readonly retryAfterMillis: Schema.optionalKey<Schema.Natural>;
45
+ }>;
46
+ readonly Disconnected: Schema.TaggedStruct<"Disconnected", {}>;
47
+ readonly Active: Schema.TaggedStruct<"Active", {}>;
48
+ readonly Disabled: Schema.TaggedStruct<"Disabled", {}>;
49
+ readonly Expired: Schema.TaggedStruct<"Expired", {}>;
50
+ readonly Failed: Schema.TaggedStruct<"Failed", {}>;
51
+ readonly UnsafeUrl: Schema.TaggedStruct<"UnsafeUrl", {}>;
52
+ readonly ContentType: Schema.TaggedStruct<"ContentType", {}>;
53
+ readonly Timestamp: Schema.TaggedStruct<"Timestamp", {}>;
54
+ readonly Resized: Schema.TaggedStruct<"Resized", {}>;
55
+ readonly TargetChanged: Schema.TaggedStruct<"TargetChanged", {}>;
56
+ readonly Interrupted: Schema.TaggedStruct<"Interrupted", {}>;
57
+ readonly ContextLease: Schema.TaggedStruct<"ContextLease", {}>;
58
+ readonly NotVisible: Schema.TaggedStruct<"NotVisible", {}>;
59
+ readonly Denied: Schema.TaggedStruct<"Denied", {}>;
60
+ readonly NotFocused: Schema.TaggedStruct<"NotFocused", {}>;
61
+ };
62
+ export declare const BrowserReason: Schema.Union<(Schema.TaggedStruct<"Active", {}> | Schema.TaggedStruct<"Ambiguous", {}> | Schema.TaggedStruct<"Authorization", {}> | Schema.TaggedStruct<"Busy", {}> | Schema.TaggedStruct<"Closed", {}> | Schema.TaggedStruct<"Configuration", {
63
+ readonly path: Schema.optionalKey<Schema.String>;
64
+ }> | Schema.TaggedStruct<"ContentType", {}> | Schema.TaggedStruct<"ContextLease", {}> | Schema.TaggedStruct<"Denied", {}> | Schema.TaggedStruct<"Disabled", {}> | Schema.TaggedStruct<"Disconnected", {}> | Schema.TaggedStruct<"Expired", {}> | Schema.TaggedStruct<"Failed", {}> | Schema.TaggedStruct<"Interrupted", {}> | Schema.TaggedStruct<"Limit", {
65
+ readonly dimension: Schema.Literals<readonly ["actions", "elapsed", "returned-bytes", "pages", "frames", "frame-depth", "buffered-frames", "buffered-bytes", "host-reads", "controls", "text", "captures", "frame-bytes", "width", "height", "pixels"]>;
66
+ readonly maximum: Schema.Natural;
67
+ readonly observed: Schema.Natural;
68
+ }> | Schema.TaggedStruct<"Malformed", {
69
+ readonly path: Schema.optionalKey<Schema.String>;
70
+ }> | Schema.TaggedStruct<"NotFocused", {}> | Schema.TaggedStruct<"NotFound", {}> | Schema.TaggedStruct<"NotVisible", {}> | Schema.TaggedStruct<"Provider", {
71
+ readonly status: Schema.optionalKey<Schema.Int>;
72
+ }> | Schema.TaggedStruct<"RateLimited", {
73
+ readonly retryAfterMillis: Schema.optionalKey<Schema.Natural>;
74
+ }> | Schema.TaggedStruct<"Resized", {}> | Schema.TaggedStruct<"Stale", {}> | Schema.TaggedStruct<"TargetChanged", {}> | Schema.TaggedStruct<"Timeout", {}> | Schema.TaggedStruct<"Timestamp", {}> | Schema.TaggedStruct<"Transport", {
75
+ readonly status: Schema.optionalKey<Schema.Int>;
76
+ }> | Schema.TaggedStruct<"UnregisteredSession", {}> | Schema.TaggedStruct<"UnsafeUrl", {}> | Schema.TaggedStruct<"Unsupported", {}>)[]>;
77
+ export type BrowserReason = typeof BrowserReason.Type;
78
+ declare const BrowserError_base: Schema.Class<BrowserError, Schema.TaggedStruct<"BrowserError", {
79
+ readonly operation: Schema.Literals<readonly ["configure", "launch", "connect", "reconnect", "detach", "disconnect", "close", "handoff", "resume", "live-view", "target", "handle", "list-pages", "list-frames", "select-page", "select-frame", "new-page", "close-page", "resize", "ready", "observe", "checkpoint", "control-facts", "revalidate", "read-text", "screenshot", "wait", "navigate", "navigate-stop", "click", "fill", "select-option", "scroll", "click-and-wait", "download-action", "select-files", "file-chooser", "action-result", "pointer-move", "hover", "wheel", "press", "type", "page-control", "page-state", "page-suspend", "page-resume", "capture", "capture-start", "capture-stop", "capture-consume"]>;
80
+ readonly reason: Schema.Union<(Schema.TaggedStruct<"Active", {}> | Schema.TaggedStruct<"Ambiguous", {}> | Schema.TaggedStruct<"Authorization", {}> | Schema.TaggedStruct<"Busy", {}> | Schema.TaggedStruct<"Closed", {}> | Schema.TaggedStruct<"Configuration", {
81
+ readonly path: Schema.optionalKey<Schema.String>;
82
+ }> | Schema.TaggedStruct<"ContentType", {}> | Schema.TaggedStruct<"ContextLease", {}> | Schema.TaggedStruct<"Denied", {}> | Schema.TaggedStruct<"Disabled", {}> | Schema.TaggedStruct<"Disconnected", {}> | Schema.TaggedStruct<"Expired", {}> | Schema.TaggedStruct<"Failed", {}> | Schema.TaggedStruct<"Interrupted", {}> | Schema.TaggedStruct<"Limit", {
83
+ readonly dimension: Schema.Literals<readonly ["actions", "elapsed", "returned-bytes", "pages", "frames", "frame-depth", "buffered-frames", "buffered-bytes", "host-reads", "controls", "text", "captures", "frame-bytes", "width", "height", "pixels"]>;
84
+ readonly maximum: Schema.Natural;
85
+ readonly observed: Schema.Natural;
86
+ }> | Schema.TaggedStruct<"Malformed", {
87
+ readonly path: Schema.optionalKey<Schema.String>;
88
+ }> | Schema.TaggedStruct<"NotFocused", {}> | Schema.TaggedStruct<"NotFound", {}> | Schema.TaggedStruct<"NotVisible", {}> | Schema.TaggedStruct<"Provider", {
89
+ readonly status: Schema.optionalKey<Schema.Int>;
90
+ }> | Schema.TaggedStruct<"RateLimited", {
91
+ readonly retryAfterMillis: Schema.optionalKey<Schema.Natural>;
92
+ }> | Schema.TaggedStruct<"Resized", {}> | Schema.TaggedStruct<"Stale", {}> | Schema.TaggedStruct<"TargetChanged", {}> | Schema.TaggedStruct<"Timeout", {}> | Schema.TaggedStruct<"Timestamp", {}> | Schema.TaggedStruct<"Transport", {
93
+ readonly status: Schema.optionalKey<Schema.Int>;
94
+ }> | Schema.TaggedStruct<"UnregisteredSession", {}> | Schema.TaggedStruct<"UnsafeUrl", {}> | Schema.TaggedStruct<"Unsupported", {}>)[]>;
95
+ readonly outcome: Schema.Literals<readonly ["undispatched", "rejected", "unknown"]>;
96
+ }>, import("effect/Cause").YieldableError>;
97
+ export declare class BrowserError extends BrowserError_base {}
98
+ declare const InitializationError_base: Schema.Class<InitializationError, Schema.TaggedStruct<"InitializationError", {
99
+ readonly operation: Schema.Literals<readonly ["configure", "register", "ready", "callback", "dispose"]>;
100
+ readonly step: Schema.String;
101
+ readonly reason: Schema.Literals<readonly ["configuration", "unsupported", "origin", "stale", "busy", "closed", "timeout", "input", "output", "native"]>;
102
+ }>, import("effect/Cause").YieldableError>;
103
+ export declare class InitializationError extends InitializationError_base {}
104
+ //#endregion
105
+ export {};
106
+ //# sourceMappingURL=Errors.d.mts.map