effect-browser 0.2.0-beta.7 → 0.2.0-beta.9

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 (68) hide show
  1. package/README.md +504 -152
  2. package/dist/Browser-BF9_sORP.d.mts +388 -0
  3. package/dist/Browser.d.mts +3 -200
  4. package/dist/Browser.mjs +9 -1
  5. package/dist/Browser.mjs.map +1 -1
  6. package/dist/{BrowserData-KHk4o__c.d.mts → BrowserData-CPIIIHol.d.mts} +81 -7
  7. package/dist/BrowserData.d.mts +2 -2
  8. package/dist/BrowserData.mjs +104 -6
  9. package/dist/BrowserData.mjs.map +1 -1
  10. package/dist/{BrowserRuntime-hxkTNlRa.d.mts → BrowserRuntime-B6nT1G4X.d.mts} +16 -11
  11. package/dist/{BrowserRuntime-Cr76CN4I.mjs → BrowserRuntime-C1r2aSRK.mjs} +5065 -4305
  12. package/dist/BrowserRuntime-C1r2aSRK.mjs.map +1 -0
  13. package/dist/BrowserRuntime.d.mts +2 -2
  14. package/dist/BrowserRuntime.mjs +2 -1
  15. package/dist/Capture.d.mts +9 -7
  16. package/dist/Capture.mjs +157 -32
  17. package/dist/Capture.mjs.map +1 -1
  18. package/dist/{CaptureData-Dys0Ko9d.mjs → CaptureData-CYriZHX1.mjs} +25 -6
  19. package/dist/CaptureData-CYriZHX1.mjs.map +1 -0
  20. package/dist/CaptureData.d.mts +62 -3
  21. package/dist/CaptureData.mjs +2 -2
  22. package/dist/Chromium.d.mts +2 -2
  23. package/dist/Chromium.mjs +19 -10
  24. package/dist/Chromium.mjs.map +1 -1
  25. package/dist/Errors.d.mts +66 -17
  26. package/dist/Errors.mjs +47 -5
  27. package/dist/Errors.mjs.map +1 -1
  28. package/dist/Images-yCG9BmRU.mjs +76 -0
  29. package/dist/Images-yCG9BmRU.mjs.map +1 -0
  30. package/dist/OperationOptions-DAeRS6O9.mjs +55 -0
  31. package/dist/OperationOptions-DAeRS6O9.mjs.map +1 -0
  32. package/dist/PageControl.d.mts +6 -6
  33. package/dist/PageControl.mjs +16 -10
  34. package/dist/PageControl.mjs.map +1 -1
  35. package/dist/PageRegistry-B3q9DS3g.mjs +164 -0
  36. package/dist/PageRegistry-B3q9DS3g.mjs.map +1 -0
  37. package/dist/Plan-Dyxu2q8C.mjs +543 -0
  38. package/dist/Plan-Dyxu2q8C.mjs.map +1 -0
  39. package/dist/Plan.d.mts +3 -0
  40. package/dist/Plan.mjs +2 -0
  41. package/dist/PlanData-B668RxbQ.d.mts +4831 -0
  42. package/dist/PlanData.d.mts +3 -0
  43. package/dist/PlanData.mjs +268 -0
  44. package/dist/PlanData.mjs.map +1 -0
  45. package/dist/PlanInput-BJcPPncs.mjs +75 -0
  46. package/dist/PlanInput-BJcPPncs.mjs.map +1 -0
  47. package/dist/PublicSession-DCSMMqOj.mjs +5602 -0
  48. package/dist/PublicSession-DCSMMqOj.mjs.map +1 -0
  49. package/dist/Testing.d.mts +48 -6
  50. package/dist/Testing.mjs +651 -113
  51. package/dist/Testing.mjs.map +1 -1
  52. package/dist/Timeline-fV22Xk-S.d.mts +29 -0
  53. package/dist/Timeline.d.mts +4 -0
  54. package/dist/Timeline.mjs +20 -0
  55. package/dist/Timeline.mjs.map +1 -0
  56. package/dist/TimelineData-BsOn-YGZ.d.mts +3818 -0
  57. package/dist/TimelineData.d.mts +3 -0
  58. package/dist/TimelineData.mjs +482 -0
  59. package/dist/TimelineData.mjs.map +1 -0
  60. package/dist/index.d.mts +5 -1
  61. package/dist/index.mjs +5 -1
  62. package/package.json +18 -2
  63. package/dist/Association-CH3kPHXE.mjs +0 -167
  64. package/dist/Association-CH3kPHXE.mjs.map +0 -1
  65. package/dist/BrowserRuntime-Cr76CN4I.mjs.map +0 -1
  66. package/dist/CaptureData-Dys0Ko9d.mjs.map +0 -1
  67. package/dist/PageControlAssociation-DabEg5AR.mjs +0 -10
  68. package/dist/PageControlAssociation-DabEg5AR.mjs.map +0 -1
@@ -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 // 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 \"--remote-debugging-pipe\",\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 // Chromium watches fd 3 for EOF and closes the browser when the host dies, including\n // SIGKILL before connect. Keep its fd 3/4 pipe pair owned by this ChildProcess; send no\n // commands on it. The shared Playwright driver still controls the loopback endpoint.\n stdio: [\"ignore\", \"ignore\", \"ignore\", \"pipe\", \"pipe\"],\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,MAAM,OAAO,OAAO,eAAe,MACjC,OAAO,YAAY,IAAI,GAEvB,OAAO,UAAU,mBAAmB,CACtC;AAEA,MAAM,OAAO,OAAO,IAAI,MAAM,OAAO,UAAU;CAAE,SAAS;CAAG,SAAS;AAAM,CAAC,CAAC;;AAG9E,MAAa,mBAAmB,KAA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AS,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"}
1
+ {"version":3,"file":"Chromium.mjs","names":["Trace.span","Trace.span","Trace.annotate","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|no-startup-window)(?:=|$)/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 * as Trace from \"../Trace.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 \"--remote-debugging-pipe\",\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 // The shared driver creates its initial Page on the sole connection. Chromium's launch\n // Page can arrive after the debugger endpoint and race that creation.\n \"--no-startup-window\",\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}, Trace.span(\"Chromium.terminate\"));\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 // Chromium watches fd 3 for EOF and closes the browser when the host dies, including\n // SIGKILL before connect. Keep its fd 3/4 pipe pair owned by this ChildProcess; send no\n // commands on it. The shared Playwright driver still controls the loopback endpoint.\n stdio: [\"ignore\", \"ignore\", \"ignore\", \"pipe\", \"pipe\"],\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 }).pipe(Trace.span(\"Chromium.ready\")),\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}, Trace.span(\"Chromium.launch\"));\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 * as Trace from \"../Trace.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.pipe(Trace.span(`Chromium.cleanup.${name}`)), 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 yield* Trace.annotate({\n \"browser.cleanup.connection\": result.connection,\n \"browser.cleanup.process\": result.process,\n \"browser.cleanup.issues\": issues.length,\n });\n\n return latest;\n }).pipe(Trace.span(\"Chromium.cleanup\")),\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(Trace.span(\"Chromium.release\"), 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 Trace.span(\"Chromium.close\"),\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.timelineLimits === undefined\n ? {}\n : { timelineLimits: options.timelineLimits }),\n ...(options.admissionLimits === undefined\n ? {}\n : { admissionLimits: options.admissionLimits }),\n ...(options.observationLimits === undefined\n ? {}\n : { observationLimits: options.observationLimits }),\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,MAAM,OAAO,OAAO,eAAe,MACjC,OAAO,YAAY,IAAI,GAEvB,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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,CAAC,CAAC,KAAK,OAAO,eAAe,OAAO,QAAQ,MAAM,CAAC,GAC7E;KACE,GAAG;KACH,GAAI,eAAe,KAAA,IACf,CAAC,IACD,EACE,gBACE,WAAW,aAAa,KAAA,IAAY,CAAC,IAAI,EAAE,UAAU,WAAW,SAAS,EAC7E;IACN,CACF;IAEA,MAAM,YAAY,OAAO,OAAO,OAC9B,SAAS,QAAQ,KACf,OAAO,KAAK,EAAE,cACZ,OAAO,OAAO,SAAS;KACrB,WAAW,SAAS;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,13 +5,13 @@ 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", "describe-page", "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"]>;
8
+ export declare const BrowserOperation: Schema.Literals<readonly ["configure", "launch", "connect", "reconnect", "detach", "disconnect", "close", "handoff", "resume", "live-view", "target", "handle", "list-pages", "describe-page", "list-frames", "select-page", "new-page", "close-page", "resize", "ready", "observe", "checkpoint", "control-facts", "revalidate", "read-text", "screenshot", "wait", "resolve", "run", "settled", "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
- export declare const BrowserOutcome: Schema.Literals<readonly ["undispatched", "rejected", "unknown"]>;
11
+ export declare const BrowserOutcome: Schema.Literals<readonly ["undispatched", "rejected", "performed", "unknown"]>;
12
12
  export type BrowserOutcome = typeof BrowserOutcome.Type;
13
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"]>;
14
+ export declare const LimitDimension: Schema.Literals<readonly ["runs", "actions", "elapsed", "returned-bytes", "pages", "frames", "frame-depth", "buffered-frames", "buffered-bytes", "host-reads", "controls", "text", "code-points", "captures", "frame-bytes", "width", "height", "pixels", "observation-snapshots", "observation-handles", "observation-bytes", "native-operations"]>;
15
15
  /** Validated constructors for host reasons. The model receives a separate bounded projection. */
16
16
  export declare const Reasons: {
17
17
  readonly Configuration: Schema.TaggedStruct<"Configuration", {
@@ -20,19 +20,32 @@ export declare const Reasons: {
20
20
  readonly UnregisteredSession: Schema.TaggedStruct<"UnregisteredSession", {}>;
21
21
  readonly Unsupported: Schema.TaggedStruct<"Unsupported", {}>;
22
22
  readonly Busy: Schema.TaggedStruct<"Busy", {}>;
23
+ readonly QueueFull: Schema.TaggedStruct<"QueueFull", {
24
+ readonly scope: Schema.Literals<readonly ["page", "session", "registry"]>;
25
+ readonly maximum: Schema.Natural;
26
+ readonly observed: Schema.Natural;
27
+ }>;
28
+ readonly QueueExpired: Schema.TaggedStruct<"QueueExpired", {}>;
23
29
  readonly Closed: Schema.TaggedStruct<"Closed", {}>;
24
30
  readonly Stale: Schema.TaggedStruct<"Stale", {}>;
25
31
  readonly NotFound: Schema.TaggedStruct<"NotFound", {}>;
26
- readonly Ambiguous: Schema.TaggedStruct<"Ambiguous", {}>;
32
+ readonly Missing: Schema.TaggedStruct<"Missing", {}>;
33
+ readonly Ambiguous: Schema.TaggedStruct<"Ambiguous", {
34
+ readonly count: Schema.optionalKey<Schema.Natural>;
35
+ }>;
36
+ readonly Incomplete: Schema.TaggedStruct<"Incomplete", {}>;
37
+ readonly Drifted: Schema.TaggedStruct<"Drifted", {}>;
27
38
  readonly Malformed: Schema.TaggedStruct<"Malformed", {
28
39
  readonly path: Schema.optionalKey<Schema.String>;
29
40
  }>;
30
41
  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"]>;
42
+ readonly dimension: Schema.Literals<readonly ["runs", "actions", "elapsed", "returned-bytes", "pages", "frames", "frame-depth", "buffered-frames", "buffered-bytes", "host-reads", "controls", "text", "code-points", "captures", "frame-bytes", "width", "height", "pixels", "observation-snapshots", "observation-handles", "observation-bytes", "native-operations"]>;
32
43
  readonly maximum: Schema.Natural;
33
44
  readonly observed: Schema.Natural;
34
45
  }>;
35
46
  readonly Timeout: Schema.TaggedStruct<"Timeout", {}>;
47
+ readonly ScheduleMissed: Schema.TaggedStruct<"ScheduleMissed", {}>;
48
+ readonly TimingBudgetExceeded: Schema.TaggedStruct<"TimingBudgetExceeded", {}>;
36
49
  readonly Transport: Schema.TaggedStruct<"Transport", {
37
50
  readonly status: Schema.optionalKey<Schema.Int>;
38
51
  }>;
@@ -60,42 +73,78 @@ export declare const Reasons: {
60
73
  readonly Denied: Schema.TaggedStruct<"Denied", {}>;
61
74
  readonly NotFocused: Schema.TaggedStruct<"NotFocused", {}>;
62
75
  };
63
- export declare const BrowserReason: Schema.Union<(Schema.TaggedStruct<"Active", {}> | Schema.TaggedStruct<"Ambiguous", {}> | Schema.TaggedStruct<"Authorization", {}> | Schema.TaggedStruct<"Busy", {}> | Schema.TaggedStruct<"Closed", {}> | Schema.TaggedStruct<"Configuration", {
76
+ export declare const BrowserReason: Schema.Union<(Schema.TaggedStruct<"Active", {}> | Schema.TaggedStruct<"Ambiguous", {
77
+ readonly count: Schema.optionalKey<Schema.Natural>;
78
+ }> | Schema.TaggedStruct<"Authorization", {}> | Schema.TaggedStruct<"Busy", {}> | Schema.TaggedStruct<"Closed", {}> | Schema.TaggedStruct<"Configuration", {
64
79
  readonly path: Schema.optionalKey<Schema.String>;
65
- }> | 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", {
66
- 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"]>;
80
+ }> | Schema.TaggedStruct<"ContentType", {}> | Schema.TaggedStruct<"ContextLease", {}> | Schema.TaggedStruct<"Denied", {}> | Schema.TaggedStruct<"Disabled", {}> | Schema.TaggedStruct<"Disconnected", {}> | Schema.TaggedStruct<"Drifted", {}> | Schema.TaggedStruct<"Expired", {}> | Schema.TaggedStruct<"Failed", {}> | Schema.TaggedStruct<"Incomplete", {}> | Schema.TaggedStruct<"Interrupted", {}> | Schema.TaggedStruct<"Limit", {
81
+ readonly dimension: Schema.Literals<readonly ["runs", "actions", "elapsed", "returned-bytes", "pages", "frames", "frame-depth", "buffered-frames", "buffered-bytes", "host-reads", "controls", "text", "code-points", "captures", "frame-bytes", "width", "height", "pixels", "observation-snapshots", "observation-handles", "observation-bytes", "native-operations"]>;
67
82
  readonly maximum: Schema.Natural;
68
83
  readonly observed: Schema.Natural;
69
84
  }> | Schema.TaggedStruct<"Malformed", {
70
85
  readonly path: Schema.optionalKey<Schema.String>;
71
- }> | Schema.TaggedStruct<"NotFocused", {}> | Schema.TaggedStruct<"NotFound", {}> | Schema.TaggedStruct<"NotVisible", {}> | Schema.TaggedStruct<"Provider", {
86
+ }> | Schema.TaggedStruct<"Missing", {}> | Schema.TaggedStruct<"NotFocused", {}> | Schema.TaggedStruct<"NotFound", {}> | Schema.TaggedStruct<"NotVisible", {}> | Schema.TaggedStruct<"Provider", {
72
87
  readonly status: Schema.optionalKey<Schema.Int>;
73
88
  readonly detail: Schema.optionalKey<Schema.String>;
89
+ }> | Schema.TaggedStruct<"QueueExpired", {}> | Schema.TaggedStruct<"QueueFull", {
90
+ readonly scope: Schema.Literals<readonly ["page", "session", "registry"]>;
91
+ readonly maximum: Schema.Natural;
92
+ readonly observed: Schema.Natural;
74
93
  }> | Schema.TaggedStruct<"RateLimited", {
75
94
  readonly retryAfterMillis: Schema.optionalKey<Schema.Natural>;
76
- }> | Schema.TaggedStruct<"Resized", {}> | Schema.TaggedStruct<"Stale", {}> | Schema.TaggedStruct<"TargetChanged", {}> | Schema.TaggedStruct<"Timeout", {}> | Schema.TaggedStruct<"Timestamp", {}> | Schema.TaggedStruct<"Transport", {
95
+ }> | Schema.TaggedStruct<"Resized", {}> | Schema.TaggedStruct<"ScheduleMissed", {}> | Schema.TaggedStruct<"Stale", {}> | Schema.TaggedStruct<"TargetChanged", {}> | Schema.TaggedStruct<"Timeout", {}> | Schema.TaggedStruct<"Timestamp", {}> | Schema.TaggedStruct<"TimingBudgetExceeded", {}> | Schema.TaggedStruct<"Transport", {
77
96
  readonly status: Schema.optionalKey<Schema.Int>;
78
97
  }> | Schema.TaggedStruct<"UnregisteredSession", {}> | Schema.TaggedStruct<"UnsafeUrl", {}> | Schema.TaggedStruct<"Unsupported", {}>)[]>;
79
98
  export type BrowserReason = typeof BrowserReason.Type;
99
+ /**
100
+ * Containment never changes an uncertain mutation into a known action outcome. `PagePaused` is
101
+ * a page's own popup/dialog-policy quarantine: the page stays open for an operator and refuses
102
+ * automation until a drained handoff and explicit release.
103
+ */
104
+ export declare const Containment: Schema.Union<readonly [Schema.TaggedStruct<"NotRequired", {}>, Schema.TaggedStruct<"PageClosed", {
105
+ readonly pageId: Schema.String;
106
+ readonly generation: Schema.Natural;
107
+ }>, Schema.TaggedStruct<"PagePaused", {
108
+ readonly pageId: Schema.String;
109
+ readonly generation: Schema.Natural;
110
+ }>, Schema.TaggedStruct<"SessionFenced", {
111
+ readonly generation: Schema.Natural;
112
+ }>]>;
113
+ export type Containment = typeof Containment.Type;
80
114
  declare const BrowserError_base: Schema.Class<BrowserError, Schema.TaggedStruct<"BrowserError", {
81
- readonly operation: Schema.Literals<readonly ["configure", "launch", "connect", "reconnect", "detach", "disconnect", "close", "handoff", "resume", "live-view", "target", "handle", "list-pages", "describe-page", "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"]>;
82
- readonly reason: Schema.Union<(Schema.TaggedStruct<"Active", {}> | Schema.TaggedStruct<"Ambiguous", {}> | Schema.TaggedStruct<"Authorization", {}> | Schema.TaggedStruct<"Busy", {}> | Schema.TaggedStruct<"Closed", {}> | Schema.TaggedStruct<"Configuration", {
115
+ readonly operation: Schema.Literals<readonly ["configure", "launch", "connect", "reconnect", "detach", "disconnect", "close", "handoff", "resume", "live-view", "target", "handle", "list-pages", "describe-page", "list-frames", "select-page", "new-page", "close-page", "resize", "ready", "observe", "checkpoint", "control-facts", "revalidate", "read-text", "screenshot", "wait", "resolve", "run", "settled", "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"]>;
116
+ readonly reason: Schema.Union<(Schema.TaggedStruct<"Active", {}> | Schema.TaggedStruct<"Ambiguous", {
117
+ readonly count: Schema.optionalKey<Schema.Natural>;
118
+ }> | Schema.TaggedStruct<"Authorization", {}> | Schema.TaggedStruct<"Busy", {}> | Schema.TaggedStruct<"Closed", {}> | Schema.TaggedStruct<"Configuration", {
83
119
  readonly path: Schema.optionalKey<Schema.String>;
84
- }> | 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", {
85
- 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"]>;
120
+ }> | Schema.TaggedStruct<"ContentType", {}> | Schema.TaggedStruct<"ContextLease", {}> | Schema.TaggedStruct<"Denied", {}> | Schema.TaggedStruct<"Disabled", {}> | Schema.TaggedStruct<"Disconnected", {}> | Schema.TaggedStruct<"Drifted", {}> | Schema.TaggedStruct<"Expired", {}> | Schema.TaggedStruct<"Failed", {}> | Schema.TaggedStruct<"Incomplete", {}> | Schema.TaggedStruct<"Interrupted", {}> | Schema.TaggedStruct<"Limit", {
121
+ readonly dimension: Schema.Literals<readonly ["runs", "actions", "elapsed", "returned-bytes", "pages", "frames", "frame-depth", "buffered-frames", "buffered-bytes", "host-reads", "controls", "text", "code-points", "captures", "frame-bytes", "width", "height", "pixels", "observation-snapshots", "observation-handles", "observation-bytes", "native-operations"]>;
86
122
  readonly maximum: Schema.Natural;
87
123
  readonly observed: Schema.Natural;
88
124
  }> | Schema.TaggedStruct<"Malformed", {
89
125
  readonly path: Schema.optionalKey<Schema.String>;
90
- }> | Schema.TaggedStruct<"NotFocused", {}> | Schema.TaggedStruct<"NotFound", {}> | Schema.TaggedStruct<"NotVisible", {}> | Schema.TaggedStruct<"Provider", {
126
+ }> | Schema.TaggedStruct<"Missing", {}> | Schema.TaggedStruct<"NotFocused", {}> | Schema.TaggedStruct<"NotFound", {}> | Schema.TaggedStruct<"NotVisible", {}> | Schema.TaggedStruct<"Provider", {
91
127
  readonly status: Schema.optionalKey<Schema.Int>;
92
128
  readonly detail: Schema.optionalKey<Schema.String>;
129
+ }> | Schema.TaggedStruct<"QueueExpired", {}> | Schema.TaggedStruct<"QueueFull", {
130
+ readonly scope: Schema.Literals<readonly ["page", "session", "registry"]>;
131
+ readonly maximum: Schema.Natural;
132
+ readonly observed: Schema.Natural;
93
133
  }> | Schema.TaggedStruct<"RateLimited", {
94
134
  readonly retryAfterMillis: Schema.optionalKey<Schema.Natural>;
95
- }> | Schema.TaggedStruct<"Resized", {}> | Schema.TaggedStruct<"Stale", {}> | Schema.TaggedStruct<"TargetChanged", {}> | Schema.TaggedStruct<"Timeout", {}> | Schema.TaggedStruct<"Timestamp", {}> | Schema.TaggedStruct<"Transport", {
135
+ }> | Schema.TaggedStruct<"Resized", {}> | Schema.TaggedStruct<"ScheduleMissed", {}> | Schema.TaggedStruct<"Stale", {}> | Schema.TaggedStruct<"TargetChanged", {}> | Schema.TaggedStruct<"Timeout", {}> | Schema.TaggedStruct<"Timestamp", {}> | Schema.TaggedStruct<"TimingBudgetExceeded", {}> | Schema.TaggedStruct<"Transport", {
96
136
  readonly status: Schema.optionalKey<Schema.Int>;
97
137
  }> | Schema.TaggedStruct<"UnregisteredSession", {}> | Schema.TaggedStruct<"UnsafeUrl", {}> | Schema.TaggedStruct<"Unsupported", {}>)[]>;
98
- readonly outcome: Schema.Literals<readonly ["undispatched", "rejected", "unknown"]>;
138
+ readonly outcome: Schema.Literals<readonly ["undispatched", "rejected", "performed", "unknown"]>;
139
+ readonly containment: Schema.optionalKey<Schema.Union<readonly [Schema.TaggedStruct<"NotRequired", {}>, Schema.TaggedStruct<"PageClosed", {
140
+ readonly pageId: Schema.String;
141
+ readonly generation: Schema.Natural;
142
+ }>, Schema.TaggedStruct<"PagePaused", {
143
+ readonly pageId: Schema.String;
144
+ readonly generation: Schema.Natural;
145
+ }>, Schema.TaggedStruct<"SessionFenced", {
146
+ readonly generation: Schema.Natural;
147
+ }>]>>;
99
148
  }>, import("effect/Cause").YieldableError>;
100
149
  export declare class BrowserError extends BrowserError_base {}
101
150
  declare const InitializationError_base: Schema.Class<InitializationError, Schema.TaggedStruct<"InitializationError", {
package/dist/Errors.mjs CHANGED
@@ -22,7 +22,6 @@ const BrowserOperation = Schema.Literals([
22
22
  "describe-page",
23
23
  "list-frames",
24
24
  "select-page",
25
- "select-frame",
26
25
  "new-page",
27
26
  "close-page",
28
27
  "resize",
@@ -34,6 +33,9 @@ const BrowserOperation = Schema.Literals([
34
33
  "read-text",
35
34
  "screenshot",
36
35
  "wait",
36
+ "resolve",
37
+ "run",
38
+ "settled",
37
39
  "navigate",
38
40
  "navigate-stop",
39
41
  "click",
@@ -64,10 +66,12 @@ const BrowserOperation = Schema.Literals([
64
66
  const BrowserOutcome = Schema.Literals([
65
67
  "undispatched",
66
68
  "rejected",
69
+ "performed",
67
70
  "unknown"
68
71
  ]);
69
72
  /** Limits report measured producer facts; an unavailable measurement is never invented. */
70
73
  const LimitDimension = Schema.Literals([
74
+ "runs",
71
75
  "actions",
72
76
  "elapsed",
73
77
  "returned-bytes",
@@ -79,11 +83,16 @@ const LimitDimension = Schema.Literals([
79
83
  "host-reads",
80
84
  "controls",
81
85
  "text",
86
+ "code-points",
82
87
  "captures",
83
88
  "frame-bytes",
84
89
  "width",
85
90
  "height",
86
- "pixels"
91
+ "pixels",
92
+ "observation-snapshots",
93
+ "observation-handles",
94
+ "observation-bytes",
95
+ "native-operations"
87
96
  ]);
88
97
  const SchemaPath = Schema.String.check(Schema.isMaxLength(512));
89
98
  /**
@@ -97,10 +106,23 @@ const Reasons = {
97
106
  UnregisteredSession: Schema.TaggedStruct("UnregisteredSession", {}),
98
107
  Unsupported: Schema.TaggedStruct("Unsupported", {}),
99
108
  Busy: Schema.TaggedStruct("Busy", {}),
109
+ QueueFull: Schema.TaggedStruct("QueueFull", {
110
+ scope: Schema.Literals([
111
+ "page",
112
+ "session",
113
+ "registry"
114
+ ]),
115
+ maximum: Schema.Natural,
116
+ observed: Schema.Natural
117
+ }),
118
+ QueueExpired: Schema.TaggedStruct("QueueExpired", {}),
100
119
  Closed: Schema.TaggedStruct("Closed", {}),
101
120
  Stale: Schema.TaggedStruct("Stale", {}),
102
121
  NotFound: Schema.TaggedStruct("NotFound", {}),
103
- Ambiguous: Schema.TaggedStruct("Ambiguous", {}),
122
+ Missing: Schema.TaggedStruct("Missing", {}),
123
+ Ambiguous: Schema.TaggedStruct("Ambiguous", { count: Schema.optionalKey(Schema.Natural) }),
124
+ Incomplete: Schema.TaggedStruct("Incomplete", {}),
125
+ Drifted: Schema.TaggedStruct("Drifted", {}),
104
126
  Malformed: Schema.TaggedStruct("Malformed", { path: Schema.optionalKey(SchemaPath) }),
105
127
  Limit: Schema.TaggedStruct("Limit", {
106
128
  dimension: LimitDimension,
@@ -108,6 +130,8 @@ const Reasons = {
108
130
  observed: Schema.Natural
109
131
  }),
110
132
  Timeout: Schema.TaggedStruct("Timeout", {}),
133
+ ScheduleMissed: Schema.TaggedStruct("ScheduleMissed", {}),
134
+ TimingBudgetExceeded: Schema.TaggedStruct("TimingBudgetExceeded", {}),
111
135
  Transport: Schema.TaggedStruct("Transport", { status: Schema.optionalKey(Schema.Int) }),
112
136
  Provider: Schema.TaggedStruct("Provider", {
113
137
  status: Schema.optionalKey(Schema.Int),
@@ -132,10 +156,28 @@ const Reasons = {
132
156
  NotFocused: Schema.TaggedStruct("NotFocused", {})
133
157
  };
134
158
  const BrowserReason = Schema.Union(Object.values(Reasons));
159
+ /**
160
+ * Containment never changes an uncertain mutation into a known action outcome. `PagePaused` is
161
+ * a page's own popup/dialog-policy quarantine: the page stays open for an operator and refuses
162
+ * automation until a drained handoff and explicit release.
163
+ */
164
+ const Containment = Schema.Union([
165
+ Schema.TaggedStruct("NotRequired", {}),
166
+ Schema.TaggedStruct("PageClosed", {
167
+ pageId: Schema.String,
168
+ generation: Schema.Natural
169
+ }),
170
+ Schema.TaggedStruct("PagePaused", {
171
+ pageId: Schema.String,
172
+ generation: Schema.Natural
173
+ }),
174
+ Schema.TaggedStruct("SessionFenced", { generation: Schema.Natural })
175
+ ]);
135
176
  var BrowserError = class extends Schema.TaggedError()("BrowserError", {
136
177
  operation: BrowserOperation,
137
178
  reason: BrowserReason,
138
- outcome: BrowserOutcome
179
+ outcome: BrowserOutcome,
180
+ containment: Schema.optionalKey(Containment)
139
181
  }) {};
140
182
  var InitializationError = class extends Schema.TaggedError()("InitializationError", {
141
183
  operation: Schema.Literals([
@@ -160,6 +202,6 @@ var InitializationError = class extends Schema.TaggedError()("InitializationErro
160
202
  ])
161
203
  }) {};
162
204
  //#endregion
163
- export { BrowserError, BrowserOperation, BrowserOutcome, BrowserReason, InitializationError, LimitDimension, Reasons };
205
+ export { BrowserError, BrowserOperation, BrowserOutcome, BrowserReason, Containment, InitializationError, LimitDimension, Reasons };
164
206
 
165
207
  //# sourceMappingURL=Errors.mjs.map
@@ -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 \"describe-page\",\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/**\n * What the native engine said about a failure it raised: its first line, without escape codes,\n * with every address cut to its origin. A host diagnostic, never part of the model projection.\n */\nconst NativeDetail = 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\", {\n status: Schema.optionalKey(Schema.Int),\n detail: Schema.optionalKey(NativeDetail),\n }),\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;CAC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AAO,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 \"describe-page\",\n \"list-frames\",\n \"select-page\",\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 \"resolve\",\n \"run\",\n \"settled\",\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\", \"performed\", \"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 \"runs\",\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 \"code-points\",\n \"captures\",\n \"frame-bytes\",\n \"width\",\n \"height\",\n \"pixels\",\n \"observation-snapshots\",\n \"observation-handles\",\n \"observation-bytes\",\n \"native-operations\",\n]);\n\nconst SchemaPath = Schema.String.check(Schema.isMaxLength(512));\n\n/**\n * What the native engine said about a failure it raised: its first line, without escape codes,\n * with every address cut to its origin. A host diagnostic, never part of the model projection.\n */\nconst NativeDetail = 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 QueueFull: Schema.TaggedStruct(\"QueueFull\", {\n scope: Schema.Literals([\"page\", \"session\", \"registry\"]),\n maximum: Schema.Natural,\n observed: Schema.Natural,\n }),\n QueueExpired: Schema.TaggedStruct(\"QueueExpired\", {}),\n Closed: Schema.TaggedStruct(\"Closed\", {}),\n Stale: Schema.TaggedStruct(\"Stale\", {}),\n NotFound: Schema.TaggedStruct(\"NotFound\", {}),\n Missing: Schema.TaggedStruct(\"Missing\", {}),\n Ambiguous: Schema.TaggedStruct(\"Ambiguous\", { count: Schema.optionalKey(Schema.Natural) }),\n Incomplete: Schema.TaggedStruct(\"Incomplete\", {}),\n Drifted: Schema.TaggedStruct(\"Drifted\", {}),\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 ScheduleMissed: Schema.TaggedStruct(\"ScheduleMissed\", {}),\n TimingBudgetExceeded: Schema.TaggedStruct(\"TimingBudgetExceeded\", {}),\n Transport: Schema.TaggedStruct(\"Transport\", { status: Schema.optionalKey(Schema.Int) }),\n Provider: Schema.TaggedStruct(\"Provider\", {\n status: Schema.optionalKey(Schema.Int),\n detail: Schema.optionalKey(NativeDetail),\n }),\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\n/**\n * Containment never changes an uncertain mutation into a known action outcome. `PagePaused` is\n * a page's own popup/dialog-policy quarantine: the page stays open for an operator and refuses\n * automation until a drained handoff and explicit release.\n */\nexport const Containment = Schema.Union([\n Schema.TaggedStruct(\"NotRequired\", {}),\n Schema.TaggedStruct(\"PageClosed\", { pageId: Schema.String, generation: Schema.Natural }),\n Schema.TaggedStruct(\"PagePaused\", { pageId: Schema.String, generation: Schema.Natural }),\n Schema.TaggedStruct(\"SessionFenced\", { generation: Schema.Natural }),\n]);\n\nexport type Containment = typeof Containment.Type;\n\nexport class BrowserError extends Schema.TaggedError<BrowserError>()(\"BrowserError\", {\n operation: BrowserOperation,\n reason: BrowserReason,\n outcome: BrowserOutcome,\n containment: Schema.optionalKey(Containment),\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;CACA;CACA;CACA;CAEA;CACA;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;CAAa;AAAS,CAAC;;AAKlG,MAAa,iBAAiB,OAAO,SAAS;CAC5C;CACA;CACA;CACA;CACA;CACA;CACA;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;;;;;AAM9D,MAAM,eAAe,OAAO,OAAO,MAAM,OAAO,YA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S;CACT,aAAa,OAAO,YAAY,WAAW;AAC7C,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"}
@@ -0,0 +1,76 @@
1
+ import { Reasons } from "./Errors.mjs";
2
+ import { y as failure } from "./PublicSession-DCSMMqOj.mjs";
3
+ //#region src/internal/browser/Images.ts
4
+ const malformed = () => failure(Reasons.Malformed.make({}));
5
+ /** A checked read: a truncated segment is malformed framing, never `undefined` arithmetic. */
6
+ const byteAt = (bytes, index) => {
7
+ const byte = bytes[index];
8
+ if (byte === void 0) throw malformed();
9
+ return byte;
10
+ };
11
+ /** Parse framing only; a caller decoding media must still validate its complete bitstream. */
12
+ const pngGeometry = (bytes) => {
13
+ if (bytes.length < 33 || [
14
+ 137,
15
+ 80,
16
+ 78,
17
+ 71,
18
+ 13,
19
+ 10,
20
+ 26,
21
+ 10
22
+ ].some((b, i) => bytes[i] !== b) || bytes[12] !== 73 || bytes[13] !== 72 || bytes[14] !== 68 || bytes[15] !== 82) throw malformed();
23
+ const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
24
+ if (view.getUint32(8) !== 13) throw malformed();
25
+ const width = view.getUint32(16), height = view.getUint32(20);
26
+ if (width === 0 || height === 0) throw malformed();
27
+ return {
28
+ width,
29
+ height
30
+ };
31
+ };
32
+ /** JPEG SOF dimensions avoid trusting the requested size or CSS viewport dimensions. */
33
+ const jpegGeometry = (bytes) => {
34
+ if (bytes.length < 4 || bytes[0] !== 255 || bytes[1] !== 216) throw malformed();
35
+ let offset = 2;
36
+ while (offset + 3 < bytes.length) {
37
+ if (bytes[offset++] !== 255) throw malformed();
38
+ while (bytes[offset] === 255) offset++;
39
+ const marker = bytes[offset++];
40
+ if (marker === void 0 || marker === 217 || marker === 218) break;
41
+ if (marker === 1 || marker >= 208 && marker <= 215) continue;
42
+ if (offset + 1 >= bytes.length) throw malformed();
43
+ const size = byteAt(bytes, offset) * 256 + byteAt(bytes, offset + 1);
44
+ if (size < 2 || offset + size > bytes.length) throw malformed();
45
+ if ([
46
+ 192,
47
+ 193,
48
+ 194,
49
+ 195,
50
+ 197,
51
+ 198,
52
+ 199,
53
+ 201,
54
+ 202,
55
+ 203,
56
+ 205,
57
+ 206,
58
+ 207
59
+ ].includes(marker)) {
60
+ if (size < 8) throw malformed();
61
+ const height = byteAt(bytes, offset + 3) * 256 + byteAt(bytes, offset + 4);
62
+ const width = byteAt(bytes, offset + 5) * 256 + byteAt(bytes, offset + 6);
63
+ if (width === 0 || height === 0) throw malformed();
64
+ return {
65
+ width,
66
+ height
67
+ };
68
+ }
69
+ offset += size;
70
+ }
71
+ throw malformed();
72
+ };
73
+ //#endregion
74
+ export { pngGeometry as n, jpegGeometry as t };
75
+
76
+ //# sourceMappingURL=Images-yCG9BmRU.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Images-yCG9BmRU.mjs","names":[],"sources":["../src/internal/browser/Images.ts"],"sourcesContent":["import { Reasons } from \"../../Errors.ts\";\nimport { failure } from \"./NativeCalls.ts\";\n\nconst malformed = () => failure(Reasons.Malformed.make({}));\n\n/** A checked read: a truncated segment is malformed framing, never `undefined` arithmetic. */\nconst byteAt = (bytes: Uint8Array, index: number): number => {\n const byte = bytes[index];\n\n if (byte === undefined) throw malformed();\n\n return byte;\n};\n\n/** Parse framing only; a caller decoding media must still validate its complete bitstream. */\nexport const pngGeometry = (bytes: Uint8Array): { width: number; height: number } => {\n const signature = [137, 80, 78, 71, 13, 10, 26, 10];\n\n if (\n bytes.length < 33 ||\n signature.some((b, i) => bytes[i] !== b) ||\n bytes[12] !== 73 ||\n bytes[13] !== 72 ||\n bytes[14] !== 68 ||\n bytes[15] !== 82\n )\n throw malformed();\n const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);\n\n if (view.getUint32(8) !== 13) throw malformed();\n\n const width = view.getUint32(16),\n height = view.getUint32(20);\n\n if (width === 0 || height === 0) throw malformed();\n\n return { width, height };\n};\n\n/** JPEG SOF dimensions avoid trusting the requested size or CSS viewport dimensions. */\nexport const jpegGeometry = (bytes: Uint8Array): { width: number; height: number } => {\n if (bytes.length < 4 || bytes[0] !== 255 || bytes[1] !== 216) throw malformed();\n let offset = 2;\n\n while (offset + 3 < bytes.length) {\n if (bytes[offset++] !== 255) throw malformed();\n while (bytes[offset] === 255) offset++;\n const marker = bytes[offset++];\n\n if (marker === undefined || marker === 217 || marker === 218) break;\n if (marker === 1 || (marker >= 208 && marker <= 215)) continue;\n if (offset + 1 >= bytes.length) throw malformed();\n const size = byteAt(bytes, offset) * 256 + byteAt(bytes, offset + 1);\n\n if (size < 2 || offset + size > bytes.length) throw malformed();\n if ([192, 193, 194, 195, 197, 198, 199, 201, 202, 203, 205, 206, 207].includes(marker)) {\n if (size < 8) throw malformed();\n const height = byteAt(bytes, offset + 3) * 256 + byteAt(bytes, offset + 4);\n const width = byteAt(bytes, offset + 5) * 256 + byteAt(bytes, offset + 6);\n\n if (width === 0 || height === 0) throw malformed();\n\n return { width, height };\n }\n offset += size;\n }\n throw malformed();\n};\n"],"mappings":";;;AAGA,MAAM,kBAAkB,QAAQ,QAAQ,UAAU,KAAK,CAAC,CAAC,CAAC;;AAG1D,MAAM,UAAU,OAAmB,UAA0B;CAC3D,MAAM,OAAO,MAAM;CAEnB,IAAI,SAAS,KAAA,GAAW,MAAM,UAAU;CAExC,OAAO;AACT;;AAGA,MAAa,eAAe,UAAyD;CAGnF,IACE,MAAM,SAAS,MACf;EAJiB;EAAK;EAAI;EAAI;EAAI;EAAI;EAAI;EAAI;CAItC,CAAC,CAAC,MAAM,G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