effect-browser 0.2.0-beta.0 → 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.
Files changed (40) hide show
  1. package/README.md +150 -10
  2. package/dist/{Association-zlgInoaj.mjs → Association-BsSfBYVx.mjs} +14 -10
  3. package/dist/Association-BsSfBYVx.mjs.map +1 -0
  4. package/dist/{Bootstrap-Be-2Ddmh.mjs → Bootstrap-CeQOWBy6.mjs} +6 -4
  5. package/dist/Bootstrap-CeQOWBy6.mjs.map +1 -0
  6. package/dist/Bootstrap.mjs +1 -1
  7. package/dist/Browser.d.mts +13 -1
  8. package/dist/Browser.mjs.map +1 -1
  9. package/dist/{BrowserData-DJAnUHoZ.d.mts → BrowserData-CRuxEZcn.d.mts} +90 -10
  10. package/dist/BrowserData.d.mts +2 -2
  11. package/dist/BrowserData.mjs +85 -7
  12. package/dist/BrowserData.mjs.map +1 -1
  13. package/dist/BrowserRuntime-Coz-5DYb.d.mts +143 -0
  14. package/dist/{BrowserRuntime-fZz1b0VI.mjs → BrowserRuntime-DViKNUdD.mjs} +2819 -2206
  15. package/dist/BrowserRuntime-DViKNUdD.mjs.map +1 -0
  16. package/dist/BrowserRuntime.d.mts +3 -139
  17. package/dist/BrowserRuntime.mjs +1 -1
  18. package/dist/Capture.d.mts +15 -1
  19. package/dist/Capture.mjs +58 -22
  20. package/dist/Capture.mjs.map +1 -1
  21. package/dist/{CaptureData-AmqVP_Ba.mjs → CaptureData-B5-mXlyq.mjs} +24 -6
  22. package/dist/CaptureData-B5-mXlyq.mjs.map +1 -0
  23. package/dist/CaptureData.d.mts +11 -2
  24. package/dist/CaptureData.mjs +1 -1
  25. package/dist/Chromium.d.mts +4 -3
  26. package/dist/Chromium.mjs +22 -16
  27. package/dist/Chromium.mjs.map +1 -1
  28. package/dist/Errors.d.mts +2 -2
  29. package/dist/Errors.mjs +1 -0
  30. package/dist/Errors.mjs.map +1 -1
  31. package/dist/PageControl.d.mts +1 -1
  32. package/dist/PageControl.mjs +1 -1
  33. package/dist/Testing.d.mts +437 -0
  34. package/dist/Testing.mjs +1561 -0
  35. package/dist/Testing.mjs.map +1 -0
  36. package/package.json +5 -1
  37. package/dist/Association-zlgInoaj.mjs.map +0 -1
  38. package/dist/Bootstrap-Be-2Ddmh.mjs.map +0 -1
  39. package/dist/BrowserRuntime-fZz1b0VI.mjs.map +0 -1
  40. package/dist/CaptureData-AmqVP_Ba.mjs.map +0 -1
@@ -1,5 +1,5 @@
1
1
  import { BrowserError } from "./Errors.mjs";
2
- import { D as PageInfo, U as Target } from "./BrowserData-DJAnUHoZ.mjs";
2
+ import { N as PageInfo, X as Target } from "./BrowserData-CRuxEZcn.mjs";
3
3
  import { Schema } from "effect";
4
4
  //#region src/CaptureData.d.ts
5
5
  /**
@@ -38,9 +38,15 @@ export type CaptureSize = typeof CaptureSize.Type;
38
38
  export declare const CaptureOptions: Schema.Struct<{
39
39
  /** Pin to a page from `session.pages`; omission preserves selected-page behavior. */
40
40
  readonly target: Schema.optionalKey<typeof PageInfo>;
41
+ /**
42
+ * Frames held until the consumer takes them (4 by default, at most 1024), oldest dropped first
43
+ * and counted as `overflow`. A consumer that delays its output leaves frames here, so this and
44
+ * `maxBufferedBytes` are the delay's memory bound.
45
+ */
41
46
  readonly maxFrames: Schema.optionalKey<Schema.Int>;
42
47
  readonly maxBufferedBytes: Schema.optionalKey<Schema.Int>;
43
48
  readonly maxFrameBytes: Schema.optionalKey<Schema.Int>;
49
+ /** 60 seconds by default, at most six hours: as long as a session may last. */
44
50
  readonly maxDurationMillis: Schema.optionalKey<Schema.Int>;
45
51
  readonly quality: Schema.optionalKey<Schema.Int>;
46
52
  /** Source fit only. Does not resize the viewport or impose an FPS cap. */
@@ -95,7 +101,10 @@ declare const CaptureSummary_base: Schema.Class<CaptureSummary, Schema.Struct<{
95
101
  readonly afterSequence: Schema.NullOr<Schema.Natural>;
96
102
  readonly url: Schema.NullOr<Schema.String>;
97
103
  }>>;
98
- /** More navigations were observed than are recorded above. Frames still count them all. */
104
+ /**
105
+ * More navigations were observed than are recorded above, so the earliest were let go: the
106
+ * record keeps the latest 64. Frames still count them all.
107
+ */
99
108
  readonly documentBoundariesTruncated: Schema.Boolean;
100
109
  readonly nativeStop: Schema.Literals<readonly ["confirmed", "unconfirmed"]>;
101
110
  /** Package accounting cannot measure frames omitted by Chromium, transport, or the provider. */
@@ -1,2 +1,2 @@
1
- import { a as CapturedFrame, i as CaptureSummary, n as CaptureSize, r as CaptureSnapshot, t as CaptureOptions } from "./CaptureData-AmqVP_Ba.mjs";
1
+ import { a as CapturedFrame, i as CaptureSummary, n as CaptureSize, r as CaptureSnapshot, t as CaptureOptions } from "./CaptureData-B5-mXlyq.mjs";
2
2
  export { CaptureOptions, CaptureSize, CaptureSnapshot, CaptureSummary, CapturedFrame };
@@ -1,7 +1,7 @@
1
1
  import { BrowserError, InitializationError } from "./Errors.mjs";
2
- import { a as BrowserPolicy, n as AutomationOptions, q as Viewport } from "./BrowserData-DJAnUHoZ.mjs";
2
+ import { a as BrowserPolicy, et as Viewport, n as AutomationOptions } from "./BrowserData-CRuxEZcn.mjs";
3
3
  import { BrowserSession, OpenOptions } from "./Browser.mjs";
4
- import { Context, Effect, Layer, Option, Redacted, Schema, Scope } from "effect";
4
+ import { Context, Crypto, Effect, Layer, Option, Redacted, Schema, Scope } from "effect";
5
5
  //#region src/internal/chromium/Data.d.ts
6
6
  declare const ChromiumReference_base: Schema.Class<ChromiumReference, Schema.Struct<{
7
7
  readonly provider: Schema.Literal<"chromium">;
@@ -77,7 +77,8 @@ export declare class Chromium extends Chromium_base {
77
77
  static acquire<E = never, R = never>(policy: BrowserPolicy, request?: OpenOptions<E, R>): Effect.Effect<ChromiumAcquisition<E>, BrowserError, Chromium | Scope.Scope | Exclude<R, Scope.Scope>>;
78
78
  /** Borrow a concrete loopback endpoint; cleanup never terminates its external process. */
79
79
  static attach<E = never, R = never>(endpoint: Redacted.Redacted<string>, request: ChromiumAttachRequest<E, R>): Effect.Effect<ChromiumSession<E>, E | BrowserError | InitializationError, Chromium | Scope.Scope | Exclude<R, Scope.Scope>>;
80
- static layer(options?: ChromiumOptions): Layer.Layer<Chromium, BrowserError>;
80
+ /** Chromium references, connection ids and handoff tokens come from the required `Crypto`. */
81
+ static layer(options?: ChromiumOptions): Layer.Layer<Chromium, BrowserError, Crypto.Crypto>;
81
82
  }
82
83
  //#endregion
83
84
  export {};
package/dist/Chromium.mjs CHANGED
@@ -1,7 +1,7 @@
1
- import { Identifier } from "./BrowserData.mjs";
2
1
  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";
2
+ import { Identifier } from "./BrowserData.mjs";
3
+ import { a as cleanupStep, c as checked, i as randomUuid, n as make, s as reported } from "./BrowserRuntime-DViKNUdD.mjs";
4
+ import { Clock, Context, Crypto, Duration, Effect, Exit, Layer, Option, Path, Redacted, Schema } from "effect";
5
5
  import { spawn } from "node:child_process";
6
6
  import { mkdtemp, readFile, rm } from "node:fs/promises";
7
7
  import { tmpdir } from "node:os";
@@ -150,7 +150,7 @@ const launch = Effect.fnUntraced(function* (options) {
150
150
  const path = yield* Path.Path.pipe(Effect.provide(Path.layer));
151
151
  const clock = yield* Clock.Clock;
152
152
  const executable = options.executablePath ?? (yield* Effect.tryPromise({
153
- try: async () => (await import("playwright-core")).chromium.executablePath(),
153
+ try: () => import("playwright-core").then(({ chromium }) => chromium.executablePath()),
154
154
  catch: () => failure("launch", Reasons.Failed.make({}))
155
155
  }));
156
156
  const directory = yield* Effect.tryPromise({
@@ -168,9 +168,11 @@ const launch = Effect.fnUntraced(function* (options) {
168
168
  });
169
169
  let child;
170
170
  return yield* Effect.gen(function* () {
171
- const launched = yield* Effect.tryPromise({
172
- try: () => {
173
- const spawned = spawn(executable, launchArguments(options, directory), {
171
+ const launched = yield* Effect.callback((resume) => {
172
+ const failed = () => resume(Effect.fail(failure("launch", Reasons.Failed.make({}))));
173
+ let spawned;
174
+ try {
175
+ spawned = spawn(executable, launchArguments(options, directory), {
174
176
  cwd: directory,
175
177
  stdio: [
176
178
  "ignore",
@@ -179,13 +181,13 @@ const launch = Effect.fnUntraced(function* (options) {
179
181
  ],
180
182
  detached: true
181
183
  });
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({}))
184
+ } catch {
185
+ failed();
186
+ return;
187
+ }
188
+ child = spawned;
189
+ spawned.once("spawn", () => resume(Effect.succeed(spawned)));
190
+ spawned.once("error", failed);
189
191
  });
190
192
  const pid = launched.pid;
191
193
  if (pid === void 0) return yield* failure("launch", Reasons.Failed.make({}));
@@ -261,10 +263,11 @@ const makeChromiumCleanup = Effect.fnUntraced(function* (reference, local, proce
261
263
  };
262
264
  });
263
265
  const acquireChromium = (endpoint, options, onCleanup) => (local) => Effect.uninterruptible(Effect.gen(function* () {
266
+ const id = yield* randomUuid(yield* Crypto.Crypto);
264
267
  const process = endpoint === void 0 ? yield* launch(options) : void 0;
265
268
  const reference = Object.freeze(ChromiumReference.make({
266
269
  provider: "chromium",
267
- id: globalThis.crypto.randomUUID()
270
+ id
268
271
  }));
269
272
  const cleanup = yield* makeChromiumCleanup(reference, local, process);
270
273
  let closing = false;
@@ -317,6 +320,7 @@ var Chromium = class Chromium extends Context.Service()("effect-browser/Chromium
317
320
  static attach(endpoint, request) {
318
321
  return Effect.flatMap(Chromium, (browser) => browser.attach(endpoint, request));
319
322
  }
323
+ /** Chromium references, connection ids and handoff tokens come from the required `Crypto`. */
320
324
  static layer(options = {}) {
321
325
  return Layer.effect(Chromium, Effect.gen(function* () {
322
326
  const launchInput = yield* checked(ChromiumLaunch, options.launch ?? {}, "configure");
@@ -343,8 +347,10 @@ var Chromium = class Chromium extends Context.Service()("effect-browser/Chromium
343
347
  ...options.pageControl === void 0 ? {} : { pageControl: options.pageControl }
344
348
  }
345
349
  });
350
+ const crypto = yield* Crypto.Crypto;
346
351
  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), {
352
+ const source = attachment === void 0 ? ownedChromium(launch, options.onCleanup) : borrowedChromium(attachment.endpoint, options.onCleanup);
353
+ const acquired = yield* runtime.acquire(policy, (cleanup, deadline) => source(cleanup, deadline).pipe(Effect.provideService(Crypto.Crypto, crypto)), {
348
354
  ...request,
349
355
  ...attachment === void 0 ? {} : { existingTarget: attachment.targetId === void 0 ? {} : { targetId: attachment.targetId } }
350
356
  });
@@ -1 +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,K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AU,YACjB,OAAO,IAAI,aAAa;KACtB,MAAM,UAAU,OAAO,QAAQ,kBAAkB,SAAS,MAAM,QAAQ,GAAG,SAAS;KAEpF,OAAO,QAAQ,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"}
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 // oxlint-disable-next-line eslint/no-control-regex -- NUL is one of the characters it rejects\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: () => import(\"playwright-core\").then(({ chromium }) => 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 // Node reports a spawn's outcome on a later tick, so its listeners attach in the same turn.\n const launched = yield* Effect.callback<ChildProcess, BrowserError>((resume) => {\n const failed = () => resume(Effect.fail(failure(\"launch\", Reasons.Failed.make({}))));\n let spawned: ChildProcess;\n\n try {\n spawned = spawn(executable, launchArguments(options, directory), {\n cwd: directory,\n stdio: [\"ignore\", \"ignore\", \"ignore\"],\n detached: true,\n });\n } catch {\n failed();\n\n return;\n }\n\n child = spawned;\n spawned.once(\"spawn\", () => resume(Effect.succeed(spawned)));\n spawned.once(\"error\", failed);\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 { Crypto, 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 { randomUuid } from \"../browser/Random.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, Crypto.Crypto> =>\n (local) =>\n Effect.uninterruptible(\n Effect.gen(function* () {\n // Drawn first: a draw after the spawn would sit between it and finalizer registration.\n const id = yield* randomUuid(yield* Crypto.Crypto);\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 const reference = Object.freeze(ChromiumReference.make({ provider: \"chromium\", id }));\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, Crypto, 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 /** Chromium references, connection ids and handoff tokens come from the required `Crypto`. */\n static layer(options: ChromiumOptions = {}): Layer.Layer<Chromium, BrowserError, Crypto.Crypto> {\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 crypto = yield* Crypto.Crypto;\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 source =\n attachment === undefined\n ? ownedChromium(launch, options.onCleanup)\n : borrowedChromium(attachment.endpoint, options.onCleanup);\n\n const acquired = yield* runtime.acquire(\n policy,\n (cleanup, deadline) =>\n source(cleanup, deadline).pipe(Effect.provideService(Crypto.Crypto, crypto)),\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,MAA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S;KACpB,cAAc,QAAQ,aAAa,KACjC,OAAO,QAAQ,SAAS,SAAS,YAAY,CAC/C;KACA,OAAO,SAAS;KAChB,eAAe,SAAS,SAAS;IACnC,CAAC,CACH,CACF,CACF;IAEA,OAAO;KACL,WAAW,SAAS;KACpB,SAAS,SAAS;KAClB,OAAO,SAAS;KAChB,SAAS,SAAS,QAAQ,KAAK,OAAO,QAAQ,SAAS,CAAC;IAC1D;GACF,CAAC;GAED,OAAO,SAAS,GAAG;IACjB;IACA,SAAS,QAAQ,YACf,QAAQ,QAAQ,OAAO,CAAC,CAAC,KAAK,OAAO,SAAS,aAAa,SAAS,OAAO,CAAC;IAC9E,SAAS,UAAU,YACjB,OAAO,IAAI,aAAa;KACtB,MAAM,UAAU,OAAO,QAAQ,kBAAkB,SAAS,MAAM,QAAQ,GAAG,SAAS;KAEpF,OAAO,QAAQ,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"}
package/dist/Errors.d.mts CHANGED
@@ -5,7 +5,7 @@ import { Schema } from "effect";
5
5
  * when it admits an operation, so a native step's own name can never become API, and a new
6
6
  * spelling is a deliberate edit here rather than a string that merely compiles.
7
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"]>;
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", "fill-form", "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
9
  export type BrowserOperation = typeof BrowserOperation.Type;
10
10
  /** Dispatch evidence belongs to the operation, independently of its failure reason. */
11
11
  export declare const BrowserOutcome: Schema.Literals<readonly ["undispatched", "rejected", "unknown"]>;
@@ -76,7 +76,7 @@ export declare const BrowserReason: Schema.Union<(Schema.TaggedStruct<"Active",
76
76
  }> | Schema.TaggedStruct<"UnregisteredSession", {}> | Schema.TaggedStruct<"UnsafeUrl", {}> | Schema.TaggedStruct<"Unsupported", {}>)[]>;
77
77
  export type BrowserReason = typeof BrowserReason.Type;
78
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"]>;
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", "fill-form", "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
80
  readonly reason: Schema.Union<(Schema.TaggedStruct<"Active", {}> | Schema.TaggedStruct<"Ambiguous", {}> | Schema.TaggedStruct<"Authorization", {}> | Schema.TaggedStruct<"Busy", {}> | Schema.TaggedStruct<"Closed", {}> | Schema.TaggedStruct<"Configuration", {
81
81
  readonly path: Schema.optionalKey<Schema.String>;
82
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", {
package/dist/Errors.mjs CHANGED
@@ -37,6 +37,7 @@ const BrowserOperation = Schema.Literals([
37
37
  "navigate-stop",
38
38
  "click",
39
39
  "fill",
40
+ "fill-form",
40
41
  "select-option",
41
42
  "scroll",
42
43
  "click-and-wait",
@@ -1 +1 @@
1
- {"version":3,"file":"Errors.mjs","names":[],"sources":["../src/Errors.ts"],"sourcesContent":["import { Schema } from \"effect\";\n\n/**\n * What a caller asked the owned browser to do. The vocabulary is closed: the owner stamps it\n * when it admits an operation, so a native step's own name can never become API, and a new\n * spelling is a deliberate edit here rather than a string that merely compiles.\n */\nexport const BrowserOperation = Schema.Literals([\n // configuration and lifetime\n \"configure\",\n \"launch\",\n \"connect\",\n \"reconnect\",\n \"detach\",\n \"disconnect\",\n \"close\",\n \"handoff\",\n \"resume\",\n \"live-view\",\n // targets\n \"target\",\n \"handle\",\n \"list-pages\",\n \"list-frames\",\n \"select-page\",\n \"select-frame\",\n \"new-page\",\n \"close-page\",\n \"resize\",\n // reading\n \"ready\",\n \"observe\",\n \"checkpoint\",\n \"control-facts\",\n \"revalidate\",\n \"read-text\",\n \"screenshot\",\n \"wait\",\n // input\n \"navigate\",\n \"navigate-stop\",\n \"click\",\n \"fill\",\n \"select-option\",\n \"scroll\",\n \"click-and-wait\",\n \"download-action\",\n \"select-files\",\n \"file-chooser\",\n \"action-result\",\n // native pointer input\n \"pointer-move\",\n \"hover\",\n \"wheel\",\n // native key input\n \"press\",\n \"type\",\n // page control\n \"page-control\",\n \"page-state\",\n \"page-suspend\",\n \"page-resume\",\n // capture\n \"capture\",\n \"capture-start\",\n \"capture-stop\",\n \"capture-consume\",\n]);\n\nexport type BrowserOperation = typeof BrowserOperation.Type;\n\n/** Dispatch evidence belongs to the operation, independently of its failure reason. */\nexport const BrowserOutcome = Schema.Literals([\"undispatched\", \"rejected\", \"unknown\"]);\n\nexport type BrowserOutcome = typeof BrowserOutcome.Type;\n\n/** Limits report measured producer facts; an unavailable measurement is never invented. */\nexport const LimitDimension = Schema.Literals([\n \"actions\",\n \"elapsed\",\n \"returned-bytes\",\n \"pages\",\n \"frames\",\n \"frame-depth\",\n \"buffered-frames\",\n \"buffered-bytes\",\n \"host-reads\",\n \"controls\",\n \"text\",\n \"captures\",\n \"frame-bytes\",\n \"width\",\n \"height\",\n \"pixels\",\n]);\n\nconst SchemaPath = Schema.String.check(Schema.isMaxLength(512));\n\n/** Validated constructors for host reasons. The model receives a separate bounded projection. */\nexport const Reasons = {\n Configuration: Schema.TaggedStruct(\"Configuration\", { path: Schema.optionalKey(SchemaPath) }),\n UnregisteredSession: Schema.TaggedStruct(\"UnregisteredSession\", {}),\n Unsupported: Schema.TaggedStruct(\"Unsupported\", {}),\n Busy: Schema.TaggedStruct(\"Busy\", {}),\n Closed: Schema.TaggedStruct(\"Closed\", {}),\n Stale: Schema.TaggedStruct(\"Stale\", {}),\n NotFound: Schema.TaggedStruct(\"NotFound\", {}),\n Ambiguous: Schema.TaggedStruct(\"Ambiguous\", {}),\n Malformed: Schema.TaggedStruct(\"Malformed\", { path: Schema.optionalKey(SchemaPath) }),\n Limit: Schema.TaggedStruct(\"Limit\", {\n dimension: LimitDimension,\n maximum: Schema.Natural,\n observed: Schema.Natural,\n }),\n Timeout: Schema.TaggedStruct(\"Timeout\", {}),\n Transport: Schema.TaggedStruct(\"Transport\", { status: Schema.optionalKey(Schema.Int) }),\n Provider: Schema.TaggedStruct(\"Provider\", { status: Schema.optionalKey(Schema.Int) }),\n Authorization: Schema.TaggedStruct(\"Authorization\", {}),\n RateLimited: Schema.TaggedStruct(\"RateLimited\", {\n retryAfterMillis: Schema.optionalKey(Schema.Natural),\n }),\n Disconnected: Schema.TaggedStruct(\"Disconnected\", {}),\n Active: Schema.TaggedStruct(\"Active\", {}),\n Disabled: Schema.TaggedStruct(\"Disabled\", {}),\n Expired: Schema.TaggedStruct(\"Expired\", {}),\n Failed: Schema.TaggedStruct(\"Failed\", {}),\n UnsafeUrl: Schema.TaggedStruct(\"UnsafeUrl\", {}),\n ContentType: Schema.TaggedStruct(\"ContentType\", {}),\n Timestamp: Schema.TaggedStruct(\"Timestamp\", {}),\n Resized: Schema.TaggedStruct(\"Resized\", {}),\n TargetChanged: Schema.TaggedStruct(\"TargetChanged\", {}),\n Interrupted: Schema.TaggedStruct(\"Interrupted\", {}),\n ContextLease: Schema.TaggedStruct(\"ContextLease\", {}),\n NotVisible: Schema.TaggedStruct(\"NotVisible\", {}),\n Denied: Schema.TaggedStruct(\"Denied\", {}),\n NotFocused: Schema.TaggedStruct(\"NotFocused\", {}),\n} as const;\n\nexport const BrowserReason = Schema.Union(Object.values(Reasons));\n\nexport type BrowserReason = typeof BrowserReason.Type;\n\nexport class BrowserError extends Schema.TaggedError<BrowserError>()(\"BrowserError\", {\n operation: BrowserOperation,\n reason: BrowserReason,\n outcome: BrowserOutcome,\n}) {}\n\nexport class InitializationError extends Schema.TaggedError<InitializationError>()(\n \"InitializationError\",\n {\n operation: Schema.Literals([\"configure\", \"register\", \"ready\", \"callback\", \"dispose\"]),\n step: Schema.String.check(Schema.isMaxLength(128)),\n reason: Schema.Literals([\n \"configuration\",\n \"unsupported\",\n \"origin\",\n \"stale\",\n \"busy\",\n \"closed\",\n \"timeout\",\n \"input\",\n \"output\",\n \"native\",\n ]),\n },\n) {}\n"],"mappings":";;;;;;;AAOA,MAAa,mBAAmB,OAAO,SAAS;CAE9C;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CAEA;CACA;CAEA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;AACF,CAAC;;AAKD,MAAa,iBAAiB,OAAO,SAAS;CAAC;CAAgB;CAAY;AAAS,CAAC;;AAKrF,MAAa,iBAAiB,OAAO,SAAS;CAC5C;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,MAAM,aAAa,OAAO,OAAO,MAAM,OAAO,YAAY,GAAG,CAAC;;AAG9D,MAAa,UAAU;CACrB,eAAe,OAAO,aAAa,iBAAiB,EAAE,MAAM,OAAO,YAAY,UAAU,EAAE,CAAC;CAC5F,qBAAqB,OAAO,aAAa,uBAAuB,CAAC,CAAC;CAClE,aAAa,OAAO,aAAa,eAAe,CAAC,CAAC;CAClD,MAAM,OAAO,aAAa,QAAQ,CAAC,CAAC;CACpC,QAAQ,OAAO,aAAa,UAAU,CAAC,CAAC;CACxC,OAAO,OAAO,aAAa,SAAS,CAAC,CAAC;CACtC,UAAU,OAAO,aAAa,YAAY,CAAC,CAAC;CAC5C,WAAW,OAAO,aAAa,aAAa,CAAC,CAAC;CAC9C,WAAW,OAAO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,gBAAgB;CACnF,WAAW;CACX,QAAQ;CACR,SAAS;AACX,CAAC,CAAC,CAAC,CAAC;AAEJ,IAAa,sBAAb,cAAyC,OAAO,YAAiC,CAAC,CAChF,uBACA;CACE,WAAW,OAAO,SAAS;EAAC;EAAa;EAAY;EAAS;EAAY;CAAS,CAAC;CACpF,MAAM,OAAO,OAAO,MAAM,OAAO,YAAY,GAAG,CAAC;CACjD,QAAQ,OAAO,SAAS;EACtB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;AACH,CACF,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"Errors.mjs","names":[],"sources":["../src/Errors.ts"],"sourcesContent":["import { Schema } from \"effect\";\n\n/**\n * What a caller asked the owned browser to do. The vocabulary is closed: the owner stamps it\n * when it admits an operation, so a native step's own name can never become API, and a new\n * spelling is a deliberate edit here rather than a string that merely compiles.\n */\nexport const BrowserOperation = Schema.Literals([\n // configuration and lifetime\n \"configure\",\n \"launch\",\n \"connect\",\n \"reconnect\",\n \"detach\",\n \"disconnect\",\n \"close\",\n \"handoff\",\n \"resume\",\n \"live-view\",\n // targets\n \"target\",\n \"handle\",\n \"list-pages\",\n \"list-frames\",\n \"select-page\",\n \"select-frame\",\n \"new-page\",\n \"close-page\",\n \"resize\",\n // reading\n \"ready\",\n \"observe\",\n \"checkpoint\",\n \"control-facts\",\n \"revalidate\",\n \"read-text\",\n \"screenshot\",\n \"wait\",\n // input\n \"navigate\",\n \"navigate-stop\",\n \"click\",\n \"fill\",\n \"fill-form\",\n \"select-option\",\n \"scroll\",\n \"click-and-wait\",\n \"download-action\",\n \"select-files\",\n \"file-chooser\",\n \"action-result\",\n // native pointer input\n \"pointer-move\",\n \"hover\",\n \"wheel\",\n // native key input\n \"press\",\n \"type\",\n // page control\n \"page-control\",\n \"page-state\",\n \"page-suspend\",\n \"page-resume\",\n // capture\n \"capture\",\n \"capture-start\",\n \"capture-stop\",\n \"capture-consume\",\n]);\n\nexport type BrowserOperation = typeof BrowserOperation.Type;\n\n/** Dispatch evidence belongs to the operation, independently of its failure reason. */\nexport const BrowserOutcome = Schema.Literals([\"undispatched\", \"rejected\", \"unknown\"]);\n\nexport type BrowserOutcome = typeof BrowserOutcome.Type;\n\n/** Limits report measured producer facts; an unavailable measurement is never invented. */\nexport const LimitDimension = Schema.Literals([\n \"actions\",\n \"elapsed\",\n \"returned-bytes\",\n \"pages\",\n \"frames\",\n \"frame-depth\",\n \"buffered-frames\",\n \"buffered-bytes\",\n \"host-reads\",\n \"controls\",\n \"text\",\n \"captures\",\n \"frame-bytes\",\n \"width\",\n \"height\",\n \"pixels\",\n]);\n\nconst SchemaPath = Schema.String.check(Schema.isMaxLength(512));\n\n/** Validated constructors for host reasons. The model receives a separate bounded projection. */\nexport const Reasons = {\n Configuration: Schema.TaggedStruct(\"Configuration\", { path: Schema.optionalKey(SchemaPath) }),\n UnregisteredSession: Schema.TaggedStruct(\"UnregisteredSession\", {}),\n Unsupported: Schema.TaggedStruct(\"Unsupported\", {}),\n Busy: Schema.TaggedStruct(\"Busy\", {}),\n Closed: Schema.TaggedStruct(\"Closed\", {}),\n Stale: Schema.TaggedStruct(\"Stale\", {}),\n NotFound: Schema.TaggedStruct(\"NotFound\", {}),\n Ambiguous: Schema.TaggedStruct(\"Ambiguous\", {}),\n Malformed: Schema.TaggedStruct(\"Malformed\", { path: Schema.optionalKey(SchemaPath) }),\n Limit: Schema.TaggedStruct(\"Limit\", {\n dimension: LimitDimension,\n maximum: Schema.Natural,\n observed: Schema.Natural,\n }),\n Timeout: Schema.TaggedStruct(\"Timeout\", {}),\n Transport: Schema.TaggedStruct(\"Transport\", { status: Schema.optionalKey(Schema.Int) }),\n Provider: Schema.TaggedStruct(\"Provider\", { status: Schema.optionalKey(Schema.Int) }),\n Authorization: Schema.TaggedStruct(\"Authorization\", {}),\n RateLimited: Schema.TaggedStruct(\"RateLimited\", {\n retryAfterMillis: Schema.optionalKey(Schema.Natural),\n }),\n Disconnected: Schema.TaggedStruct(\"Disconnected\", {}),\n Active: Schema.TaggedStruct(\"Active\", {}),\n Disabled: Schema.TaggedStruct(\"Disabled\", {}),\n Expired: Schema.TaggedStruct(\"Expired\", {}),\n Failed: Schema.TaggedStruct(\"Failed\", {}),\n UnsafeUrl: Schema.TaggedStruct(\"UnsafeUrl\", {}),\n ContentType: Schema.TaggedStruct(\"ContentType\", {}),\n Timestamp: Schema.TaggedStruct(\"Timestamp\", {}),\n Resized: Schema.TaggedStruct(\"Resized\", {}),\n TargetChanged: Schema.TaggedStruct(\"TargetChanged\", {}),\n Interrupted: Schema.TaggedStruct(\"Interrupted\", {}),\n ContextLease: Schema.TaggedStruct(\"ContextLease\", {}),\n NotVisible: Schema.TaggedStruct(\"NotVisible\", {}),\n Denied: Schema.TaggedStruct(\"Denied\", {}),\n NotFocused: Schema.TaggedStruct(\"NotFocused\", {}),\n} as const;\n\nexport const BrowserReason = Schema.Union(Object.values(Reasons));\n\nexport type BrowserReason = typeof BrowserReason.Type;\n\nexport class BrowserError extends Schema.TaggedError<BrowserError>()(\"BrowserError\", {\n operation: BrowserOperation,\n reason: BrowserReason,\n outcome: BrowserOutcome,\n}) {}\n\nexport class InitializationError extends Schema.TaggedError<InitializationError>()(\n \"InitializationError\",\n {\n operation: Schema.Literals([\"configure\", \"register\", \"ready\", \"callback\", \"dispose\"]),\n step: Schema.String.check(Schema.isMaxLength(128)),\n reason: Schema.Literals([\n \"configuration\",\n \"unsupported\",\n \"origin\",\n \"stale\",\n \"busy\",\n \"closed\",\n \"timeout\",\n \"input\",\n \"output\",\n \"native\",\n ]),\n },\n) {}\n"],"mappings":";;;;;;;AAOA,MAAa,mBAAmB,OAAO,SAAS;CAE9C;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAC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c,OAAO,aAAa,gBAAgB,CAAC,CAAC;CACpD,QAAQ,OAAO,aAAa,UAAU,CAAC,CAAC;CACxC,UAAU,OAAO,aAAa,YAAY,CAAC,CAAC;CAC5C,SAAS,OAAO,aAAa,WAAW,CAAC,CAAC;CAC1C,QAAQ,OAAO,aAAa,UAAU,CAAC,CAAC;CACxC,WAAW,OAAO,aAAa,aAAa,CAAC,CAAC;CAC9C,aAAa,OAAO,aAAa,eAAe,CAAC,CAAC;CAClD,WAAW,OAAO,aAAa,aAAa,CAAC,CAAC;CAC9C,SAAS,OAAO,aAAa,WAAW,CAAC,CAAC;CAC1C,eAAe,OAAO,aAAa,iBAAiB,CAAC,CAAC;CACtD,aAAa,OAAO,aAAa,eAAe,CAAC,CAAC;CAClD,cAAc,OAAO,aAAa,gBAAgB,CAAC,CAAC;CACpD,YAAY,OAAO,aAAa,cAAc,CAAC,CAAC;CAChD,QAAQ,OAAO,aAAa,UAAU,CAAC,CAAC;CACxC,YAAY,OAAO,aAAa,cAAc,CAAC,CAAC;AAClD;AAEA,MAAa,gBAAgB,OAAO,MAAM,OAAO,OAAO,OAAO,CAAC;AAIhE,IAAa,eAAb,cAAkC,OAAO,YAA0B,CAAC,CAAC,gBAAgB;CACnF,WAAW;CACX,QAAQ;CACR,SAAS;AACX,CAAC,CAAC,CAAC,CAAC;AAEJ,IAAa,sBAAb,cAAyC,OAAO,YAAiC,CAAC,CAChF,uBACA;CACE,WAAW,OAAO,SAAS;EAAC;EAAa;EAAY;EAAS;EAAY;CAAS,CAAC;CACpF,MAAM,OAAO,OAAO,MAAM,OAAO,YAAY,GAAG,CAAC;CACjD,QAAQ,OAAO,SAAS;EACtB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;AACH,CACF,CAAC,CAAC,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import { BrowserError } from "./Errors.mjs";
2
- import { D as PageInfo, E as PageExecutionState, O as PageSuspension } from "./BrowserData-DJAnUHoZ.mjs";
2
+ import { M as PageExecutionState, N as PageInfo, P as PageSuspension } from "./BrowserData-CRuxEZcn.mjs";
3
3
  import { BrowserSession } from "./Browser.mjs";
4
4
  import { Effect } from "effect";
5
5
  //#region src/PageControl.d.ts
@@ -1,5 +1,5 @@
1
- import { PageExecutionState, PageInfo, PageSuspension } from "./BrowserData.mjs";
2
1
  import { BrowserError, Reasons } from "./Errors.mjs";
2
+ import { PageExecutionState, PageInfo, PageSuspension } from "./BrowserData.mjs";
3
3
  import { n as pageControl } from "./PageControlAssociation-DabEg5AR.mjs";
4
4
  import { Effect, Schema } from "effect";
5
5
  //#region src/PageControl.ts