effect-browser 0.3.0-beta.19 → 0.3.0-beta.21

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 (70) hide show
  1. package/README.md +94 -3
  2. package/dist/Browser-CiXHT1yO.d.mts +129 -0
  3. package/dist/{Browser-H63wiekr.mjs → Browser-CxXUjxOp.mjs} +10 -19
  4. package/dist/Browser-CxXUjxOp.mjs.map +1 -0
  5. package/dist/Browser.d.mts +2 -129
  6. package/dist/Browser.mjs +1 -1
  7. package/dist/Cdp-CzCRnMlM.d.mts +10 -0
  8. package/dist/Cdp.d.mts +5 -26
  9. package/dist/Cdp.mjs +4 -45
  10. package/dist/Cdp.mjs.map +1 -1
  11. package/dist/Chromium.d.mts +1 -1
  12. package/dist/Chromium.mjs +3 -3
  13. package/dist/Chromium.mjs.map +1 -1
  14. package/dist/Expect-u3P_ENLX.d.mts +62 -0
  15. package/dist/Expect.d.mts +2 -62
  16. package/dist/Expect.mjs +2 -2
  17. package/dist/LICENSE-jpeg-js +28 -0
  18. package/dist/Moment.mjs +1 -1
  19. package/dist/Page-BP02bmNv.mjs +264 -0
  20. package/dist/{Page-CfB6Zn1p.mjs.map → Page-BP02bmNv.mjs.map} +1 -1
  21. package/dist/Page.mjs +1 -1
  22. package/dist/{Plan-C-d5QYS8.mjs → Plan-BG1WifW2.mjs} +48 -4
  23. package/dist/Plan-BG1WifW2.mjs.map +1 -0
  24. package/dist/Plan.mjs +1 -1
  25. package/dist/Policy-BGWjbqCl.d.mts +76 -0
  26. package/dist/Policy.d.mts +2 -76
  27. package/dist/Policy.mjs +1 -1
  28. package/dist/Presentation-DxVikn9_.d.mts +48 -0
  29. package/dist/Presentation.d.mts +2 -48
  30. package/dist/Presentation.mjs +2 -2
  31. package/dist/Stage-NHp8N81k.d.mts +65 -0
  32. package/dist/Stage.d.mts +2 -65
  33. package/dist/Stage.mjs +2 -2
  34. package/dist/{Supervisor-mVPeEUp8.d.mts → Supervisor-CfRxbaso.d.mts} +2 -2
  35. package/dist/Supervisor.d.mts +1 -1
  36. package/dist/cdp-BMpYMWYe.mjs +69 -0
  37. package/dist/cdp-BMpYMWYe.mjs.map +1 -0
  38. package/dist/cdp-DL7XfEj5.d.mts +41 -0
  39. package/dist/{context-w3NJPRLo.mjs → context-EGhOqjNN.mjs} +5 -5
  40. package/dist/context-EGhOqjNN.mjs.map +1 -0
  41. package/dist/index.d.mts +7 -6
  42. package/dist/index.mjs +4 -3
  43. package/dist/page-PTM8m5wC.mjs +4057 -0
  44. package/dist/page-PTM8m5wC.mjs.map +1 -0
  45. package/dist/{url-Cd04Okid.mjs → url-Bsp2y55M.mjs} +2 -2
  46. package/dist/{url-Cd04Okid.mjs.map → url-Bsp2y55M.mjs.map} +1 -1
  47. package/dist/workerd/Cdp.d.mts +3 -0
  48. package/dist/workerd/Cdp.mjs +18 -0
  49. package/dist/workerd/Cdp.mjs.map +1 -0
  50. package/dist/workerd/index.d.mts +16 -0
  51. package/dist/workerd/index.mjs +17 -0
  52. package/package.json +15 -4
  53. package/src/Browser.ts +20 -30
  54. package/src/Cdp.ts +7 -92
  55. package/src/index.ts +1 -15
  56. package/src/internal/cdp.ts +134 -0
  57. package/src/internal/page/bridge.ts +2 -2
  58. package/src/internal/page/context.ts +21 -24
  59. package/src/internal/page/identity.ts +6 -25
  60. package/src/internal/pictures/motion.ts +3 -3
  61. package/src/workerd/Cdp.ts +11 -0
  62. package/src/workerd/index.ts +17 -0
  63. package/dist/Browser-H63wiekr.mjs.map +0 -1
  64. package/dist/Page-CfB6Zn1p.mjs +0 -610
  65. package/dist/Plan-C-d5QYS8.mjs.map +0 -1
  66. package/dist/context-w3NJPRLo.mjs.map +0 -1
  67. package/dist/match.inpage-xOe9LNO0.mjs +0 -48
  68. package/dist/match.inpage-xOe9LNO0.mjs.map +0 -1
  69. package/dist/page-BKwfF6z-.mjs +0 -5099
  70. package/dist/page-BKwfF6z-.mjs.map +0 -1
package/dist/Cdp.mjs CHANGED
@@ -1,16 +1,10 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
2
- import { Failed } from "./BrowserError.mjs";
3
- import { i as make, t as Browser } from "./Browser-H63wiekr.mjs";
4
- import { c as undispatched, o as reasonOf } from "./context-w3NJPRLo.mjs";
5
- import { r as quoted } from "./url-Cd04Okid.mjs";
6
- import { Effect, Layer, Redacted } from "effect";
2
+ import { t as make } from "./cdp-BMpYMWYe.mjs";
7
3
  import { chromium } from "playwright-core";
8
4
  //#region src/Cdp.ts
9
5
  /**
10
- * A browser reached over the Chrome DevTools Protocol: a Chrome started with
11
- * `--remote-debugging-port`, or any provider that hands out a CDP WebSocket URL.
12
- *
13
- * Closing the scope disconnects. It does not close the remote browser; its owner does that.
6
+ * A browser reached over Chrome DevTools Protocol. Node defaults to Playwright's transport;
7
+ * `connect` supplies another runtime's real Playwright browser. Closing the scope disconnects.
14
8
  *
15
9
  * @since 0.3.0
16
10
  */
@@ -18,43 +12,8 @@ var Cdp_exports = /* @__PURE__ */ __exportAll({
18
12
  layer: () => layer,
19
13
  open: () => open
20
14
  });
21
- /**
22
- * Playwright can echo the endpoint, or a URL derived from it with its query, userinfo or path, in
23
- * a connect failure. Those parts are often the credential, so a URL keeps its scheme, host and
24
- * port, and any other echo of the endpoint is replaced.
25
- */
26
- const withoutEndpoint = (endpoint, reason) => {
27
- if (reason._tag !== "Failed") return reason;
28
- const origins = reason.detail.replace(quoted, (url) => {
29
- const parsed = URL.parse(url);
30
- return parsed === null || parsed.host === "" ? "<url>" : `${parsed.protocol}//${parsed.host}`;
31
- });
32
- return new Failed({ detail: endpoint === "" ? origins : origins.replaceAll(endpoint, "<endpoint>") });
33
- };
34
15
  /** Connect and open a `Browser` over the endpoint's first context. */
35
- const open = Effect.fn("Cdp.open")(function* (options) {
36
- const endpoint = Redacted.isRedacted(options.endpoint) ? Redacted.value(options.endpoint) : options.endpoint;
37
- const timeout = options.connectTimeoutMillis ?? 3e4;
38
- const failed = (cause, timeoutMillis) => undispatched("connect", withoutEndpoint(endpoint, reasonOf(cause, timeoutMillis)));
39
- const connected = yield* Effect.acquireRelease(Effect.tryPromise({
40
- try: () => chromium.connectOverCDP(endpoint, {
41
- timeout,
42
- ...options.headers === void 0 ? {} : { headers: { ...options.headers } }
43
- }),
44
- catch: (cause) => failed(cause, timeout)
45
- }).pipe(Effect.withSpan("Cdp.connect", {}, { captureStackTrace: false })), (browser) => Effect.tryPromise(() => browser.close()).pipe(Effect.ignore));
46
- const context = connected.contexts()[0] ?? (yield* Effect.tryPromise({
47
- try: () => connected.newContext(),
48
- catch: (cause) => failed(cause)
49
- }));
50
- return yield* make(context, {
51
- id: options.id ?? "cdp",
52
- provider: options.provider ?? "cdp",
53
- expiresAt: options.expiresAt,
54
- capture: options.capture
55
- }, options);
56
- });
57
- const layer = (options) => Layer.effect(Browser, open(options));
16
+ const { open, layer } = make((endpoint, options) => chromium.connectOverCDP(endpoint, options));
58
17
  //#endregion
59
18
  export { layer, open, Cdp_exports as t };
60
19
 
package/dist/Cdp.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Cdp.mjs","names":["Url.quoted","Browser.make","Browser.Browser"],"sources":["../src/Cdp.ts"],"sourcesContent":["/**\n * A browser reached over the Chrome DevTools Protocol: a Chrome started with\n * `--remote-debugging-port`, or any provider that hands out a CDP WebSocket URL.\n *\n * Closing the scope disconnects. It does not close the remote browser; its owner does that.\n *\n * @since 0.3.0\n */\nimport { type DateTime, Effect, Layer, Redacted } from \"effect\";\nimport { chromium } from \"playwright-core\";\n\nimport * as Browser from \"./Browser.ts\";\nimport { type BrowserError, Failed, type Reason } from \"./BrowserError.ts\";\nimport { reasonOf, undispatched } from \"./internal/page/context.ts\";\nimport * as Url from \"./internal/page/url.ts\";\n\nexport interface Options extends Browser.Options {\n /**\n * `ws://`, `wss://` or `http://` DevTools endpoint. Often a credential, so it may be redacted;\n * connect failures never include its userinfo, path or query.\n */\n readonly endpoint: string | Redacted.Redacted<string>;\n readonly headers?: Readonly<Record<string, string>> | undefined;\n /** Identifies the session in `Browser.id`. Defaults to `\"cdp\"`. */\n readonly id?: string | undefined;\n readonly provider?: string | undefined;\n /** Bound on connecting. Defaults to 30 seconds. */\n readonly connectTimeoutMillis?: number | undefined;\n /** When the provider ends the session on its own, as a hosted session's timeout does. */\n readonly expiresAt?: DateTime.Utc | undefined;\n /**\n * A connection apart from this one for the pages' screencasts, as a hosted provider supplies.\n * Without one, each page's capture runs on its own session.\n */\n readonly capture?: Browser.CaptureSource | undefined;\n}\n\n/**\n * Playwright can echo the endpoint, or a URL derived from it with its query, userinfo or path, in\n * a connect failure. Those parts are often the credential, so a URL keeps its scheme, host and\n * port, and any other echo of the endpoint is replaced.\n */\nconst withoutEndpoint = (endpoint: string, reason: Reason): Reason => {\n if (reason._tag !== \"Failed\") return reason;\n\n const origins = reason.detail.replace(Url.quoted, (url) => {\n const parsed = URL.parse(url);\n\n return parsed === null || parsed.host === \"\" ? \"<url>\" : `${parsed.protocol}//${parsed.host}`;\n });\n\n return new Failed({\n detail: endpoint === \"\" ? origins : origins.replaceAll(endpoint, \"<endpoint>\"),\n });\n};\n\n/** Connect and open a `Browser` over the endpoint's first context. */\nexport const open = Effect.fn(\"Cdp.open\")(function* (options: Options) {\n const endpoint = Redacted.isRedacted(options.endpoint)\n ? Redacted.value(options.endpoint)\n : options.endpoint;\n\n const timeout = options.connectTimeoutMillis ?? 30_000;\n\n const failed = (cause: unknown, timeoutMillis?: number) =>\n undispatched(\"connect\", withoutEndpoint(endpoint, reasonOf(cause, timeoutMillis)));\n\n // The endpoint is often a credential, so the connect span names no part of it.\n const connected = yield* Effect.acquireRelease(\n Effect.tryPromise({\n try: () =>\n chromium.connectOverCDP(endpoint, {\n timeout,\n ...(options.headers === undefined ? {} : { headers: { ...options.headers } }),\n }),\n catch: (cause) => failed(cause, timeout),\n }).pipe(Effect.withSpan(\"Cdp.connect\", {}, { captureStackTrace: false })),\n (browser) => Effect.tryPromise(() => browser.close()).pipe(Effect.ignore),\n );\n\n const context =\n connected.contexts()[0] ??\n (yield* Effect.tryPromise({\n try: () => connected.newContext(),\n catch: (cause) => failed(cause),\n }));\n\n return yield* Browser.make(\n context,\n {\n id: options.id ?? \"cdp\",\n provider: options.provider ?? \"cdp\",\n expiresAt: options.expiresAt,\n capture: options.capture,\n },\n options,\n );\n});\n\nexport const layer = (options: Options): Layer.Layer<Browser.Browser, BrowserError> =>\n Layer.effect(Browser.Browser, open(options));\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA0CA,MAAM,mBAAmB,UAAkB,WAA2B;CACpE,IAAI,OAAO,SAAS,UAAU,OAAO;CAErC,MAAM,UAAU,OAAO,OAAO,QAAQA,SAAa,QAAQ;EACzD,MAAM,SAAS,IAAI,MAAM,GAAG;EAE5B,OAAO,WAAW,QAAQ,OAAO,SAAS,KAAK,UAAU,GAAG,OAAO,SAAS,IAAI,OAAO;CACzF,CAAC;CAED,OAAO,IAAI,OAAO,EAChB,QAAQ,aAAa,KAAK,UAAU,QAAQ,WAAW,UAAU,YAAY,EAC/E,CAAC;AACH;;AAGA,MAAa,OAAO,OAAO,GAAG,UAAU,CAAC,CAAC,WAAW,SAAkB;CACrE,MAAM,WAAW,SAAS,WAAW,QAAQ,QAAQ,IACjD,SAAS,MAAM,QAAQ,QAAQ,IAC/B,QAAQ;CAEZ,MAAM,UAAU,QAAQ,wBAAwB;CAEhD,MAAM,UAAU,OAAgB,kBAC9B,aAAa,WAAW,gBAAgB,UAAU,SAAS,OAAO,aAAa,CAAC,CAAC;CAGnF,MAAM,YAAY,OAAO,OAAO,eAC9B,OAAO,WAAW;EAChB,WACE,SAAS,eAAe,UAAU;GAChC;GACA,GAAI,QAAQ,YAAY,KAAA,IAAY,CAAC,IAAI,EAAE,SAAS,EAAE,GAAG,QAAQ,QAAQ,EAAE;EAC7E,CAAC;EACH,QAAQ,UAAU,OAAO,OAAO,OAAO;CACzC,CAAC,CAAC,CAAC,KAAK,OAAO,SAAS,eAAe,CAAC,GAAG,EAAE,mBAAmB,MAAM,CAAC,CAAC,IACvE,YAAY,OAAO,iBAAiB,QAAQ,MAAM,CAAC,CAAC,CAAC,KAAK,OAAO,MAAM,CAC1E;CAEA,MAAM,UACJ,UAAU,SAAS,CAAC,CAAC,OACpB,OAAO,OAAO,WAAW;EACxB,WAAW,UAAU,WAAW;EAChC,QAAQ,UAAU,OAAO,KAAK;CAChC,CAAC;CAEH,OAAO,OAAOC,KACZ,SACA;EACE,IAAI,QAAQ,MAAM;EAClB,UAAU,QAAQ,YAAY;EAC9B,WAAW,QAAQ;EACnB,SAAS,QAAQ;CACnB,GACA,OACF;AACF,CAAC;AAED,MAAa,SAAS,YACpB,MAAM,OAAOC,SAAiB,KAAK,OAAO,CAAC"}
1
+ {"version":3,"file":"Cdp.mjs","names":[],"sources":["../src/Cdp.ts"],"sourcesContent":["/**\n * A browser reached over Chrome DevTools Protocol. Node defaults to Playwright's transport;\n * `connect` supplies another runtime's real Playwright browser. Closing the scope disconnects.\n *\n * @since 0.3.0\n */\nimport { chromium } from \"playwright-core\";\n\nimport { make } from \"./internal/cdp.ts\";\n\nexport type { Connector, ConnectOptions, Options } from \"./internal/cdp.ts\";\n\n/** Connect and open a `Browser` over the endpoint's first context. */\nexport const { open, layer } = make((endpoint, options) =>\n chromium.connectOverCDP(endpoint, options),\n);\n"],"mappings":";;;;;;;;;;;;;;;AAaA,MAAa,EAAE,MAAM,UAAU,MAAM,UAAU,YAC7C,SAAS,eAAe,UAAU,OAAO,CAC3C"}
@@ -1,5 +1,5 @@
1
1
  import { t as BrowserError } from "./BrowserError-Coy7EW1N.mjs";
2
- import { Browser, Options as Options$1, Service, t as Browser_d_exports } from "./Browser.mjs";
2
+ import { n as Browser_d_exports, o as Options$1, s as Service, t as Browser } from "./Browser-CiXHT1yO.mjs";
3
3
  import { Effect, Layer } from "effect";
4
4
  declare namespace Chromium_d_exports {
5
5
  export { Options, layer, open };
package/dist/Chromium.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
2
2
  import { Failed } from "./BrowserError.mjs";
3
- import { i as make, t as Browser } from "./Browser-H63wiekr.mjs";
4
- import { c as undispatched, o as reasonOf } from "./context-w3NJPRLo.mjs";
3
+ import { i as make, t as Browser$1 } from "./Browser-CxXUjxOp.mjs";
4
+ import { c as undispatched, o as reasonOf } from "./context-EGhOqjNN.mjs";
5
5
  import { Effect, Layer } from "effect";
6
6
  import { chromium } from "playwright-core";
7
7
  //#region src/Chromium.ts
@@ -57,7 +57,7 @@ const open = Effect.fn("Chromium.open")(function* (options = {}) {
57
57
  }, options);
58
58
  });
59
59
  /** A `Browser` Layer that launches Chromium when built and closes it when released. */
60
- const layer = (options = {}) => Layer.effect(Browser, open(options));
60
+ const layer = (options = {}) => Layer.effect(Browser$1, open(options));
61
61
  //#endregion
62
62
  export { layer, open, Chromium_exports as t };
63
63
 
@@ -1 +1 @@
1
- {"version":3,"file":"Chromium.mjs","names":["Browser.make","Browser.Browser"],"sources":["../src/Chromium.ts"],"sourcesContent":["/**\n * A local Chromium, launched for the scope and closed with it.\n *\n * It uses the Chromium build that `playwright-core` installs\n * (`npx playwright-core install chromium`), unless `executablePath` names another.\n *\n * Signals are the program's to handle: run it with `NodeRuntime.runMain`, which interrupts it on\n * SIGINT and SIGTERM, so the browser closes with its scope.\n *\n * @since 0.3.0\n */\nimport { Effect, Layer } from \"effect\";\nimport { chromium } from \"playwright-core\";\n\nimport * as Browser from \"./Browser.ts\";\nimport { type BrowserError, Failed } from \"./BrowserError.ts\";\nimport { reasonOf, undispatched } from \"./internal/page/context.ts\";\n\nexport interface Options extends Browser.Options {\n /** Defaults to true. */\n readonly headless?: boolean | undefined;\n /**\n * Run Chromium's sandbox. Defaults to false, as in Playwright, so an exploit in a page's renderer\n * runs with this process's privileges. Hosts that don't allow unprivileged user namespaces, such\n * as many containers and Ubuntu 23.10 or later by default, can't start the sandbox; opening then\n * fails and says so.\n */\n readonly sandbox?: boolean | undefined;\n /** Defaults to 1280x720 CSS pixels at a device scale factor of 1. */\n readonly viewport?: { readonly width: number; readonly height: number } | undefined;\n readonly executablePath?: string | undefined;\n readonly args?: ReadonlyArray<string> | undefined;\n readonly userAgent?: string | undefined;\n readonly locale?: string | undefined;\n}\n\n// Playwright's own default, stated so that a launch timeout reports the bound it exceeded.\nconst launchTimeoutMillis = 180_000;\n\nconst failed = (operation: string, timeoutMillis?: number) => (cause: unknown) =>\n undispatched(operation, reasonOf(cause, timeoutMillis));\n\n// Playwright puts this in place of Chromium's startup log when the sandbox could not start, in an\n// error that otherwise reads as a closed browser.\nconst sandboxFailed = /Chromium sandboxing failed|No usable sandbox/;\n\nconst launchFailed = (cause: unknown) =>\n sandboxFailed.test(String(cause))\n ? undispatched(\n \"launch\",\n new Failed({\n detail:\n \"Chromium's sandbox could not start on this host: it needs unprivileged user namespaces, and a user other than root\",\n }),\n )\n : failed(\"launch\", launchTimeoutMillis)(cause);\n\n/** Launch Chromium and open a `Browser` over a fresh context. */\nexport const open = Effect.fn(\"Chromium.open\")(function* (options: Options = {}) {\n const launched = yield* Effect.acquireRelease(\n Effect.tryPromise({\n try: () =>\n chromium.launch({\n headless: options.headless ?? true,\n chromiumSandbox: options.sandbox ?? false,\n timeout: launchTimeoutMillis,\n // The program owns its signals. Playwright's handlers close every browser on any of\n // these, and on SIGINT then exit the process, so no finalizer would run.\n handleSIGINT: false,\n handleSIGTERM: false,\n handleSIGHUP: false,\n ...(options.executablePath === undefined\n ? {}\n : { executablePath: options.executablePath }),\n ...(options.args === undefined ? {} : { args: [...options.args] }),\n }),\n catch: launchFailed,\n }).pipe(Effect.withSpan(\"Chromium.launch\", {}, { captureStackTrace: false })),\n (browser) => Effect.tryPromise(() => browser.close()).pipe(Effect.ignore),\n );\n\n const context = yield* Effect.tryPromise({\n try: () =>\n launched.newContext({\n viewport: options.viewport ?? { width: 1280, height: 720 },\n deviceScaleFactor: 1,\n ...(options.userAgent === undefined ? {} : { userAgent: options.userAgent }),\n ...(options.locale === undefined ? {} : { locale: options.locale }),\n }),\n catch: failed(\"launch\"),\n });\n\n return yield* Browser.make(\n context,\n { id: `chromium-${launched.version()}`, provider: \"chromium\" },\n options,\n );\n});\n\n/** A `Browser` Layer that launches Chromium when built and closes it when released. */\nexport const layer = (options: Options = {}): Layer.Layer<Browser.Browser, BrowserError> =>\n Layer.effect(Browser.Browser, open(options));\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAqCA,MAAM,sBAAsB;AAE5B,MAAM,UAAU,WAAmB,mBAA4B,UAC7D,aAAa,WAAW,SAAS,OAAO,aAAa,CAAC;AAIxD,MAAM,gBAAgB;AAEtB,MAAM,gBAAgB,UACpB,cAAc,KAAK,OAAO,KAAK,CAAC,IAC5B,aACE,UACA,IAAI,OAAO,EACT,QACE,qHACJ,CAAC,CACH,IACA,OAAO,UAAU,mBAAmB,CAAC,CAAC,KAAK;;AAGjD,MAAa,OAAO,OAAO,GAAG,eAAe,CAAC,CAAC,WAAW,UAAmB,CAAC,GAAG;CAC/E,MAAM,WAAW,OAAO,OAAO,eAC7B,OAAO,WAAW;EAChB,WACE,SAAS,OAAO;GACd,UAAU,QAAQ,YAAY;GAC9B,iBAAiB,QAAQ,WAAW;GACpC,SAAS;GAGT,cAAc;GACd,eAAe;GACf,cAAc;GACd,GAAI,QAAQ,mBAAmB,KAAA,IAC3B,CAAC,IACD,EAAE,gBAAgB,QAAQ,eAAe;GAC7C,GAAI,QAAQ,SAAS,KAAA,IAAY,CAAC,IAAI,EAAE,MAAM,CAAC,GAAG,QAAQ,IAAI,EAAE;EAClE,CAAC;EACH,OAAO;CACT,CAAC,CAAC,CAAC,KAAK,OAAO,SAAS,mBAAmB,CAAC,GAAG,EAAE,mBAAmB,MAAM,CAAC,CAAC,IAC3E,YAAY,OAAO,iBAAiB,QAAQ,MAAM,CAAC,CAAC,CAAC,KAAK,OAAO,MAAM,CAC1E;CAEA,MAAM,UAAU,OAAO,OAAO,WAAW;EACvC,WACE,SAAS,WAAW;GAClB,UAAU,QAAQ,YAAY;IAAE,OAAO;IAAM,QAAQ;GAAI;GACzD,mBAAmB;GACnB,GAAI,QAAQ,cAAc,KAAA,IAAY,CAAC,IAAI,EAAE,WAAW,QAAQ,UAAU;GAC1E,GAAI,QAAQ,WAAW,KAAA,IAAY,CAAC,IAAI,EAAE,QAAQ,QAAQ,OAAO;EACnE,CAAC;EACH,OAAO,OAAO,QAAQ;CACxB,CAAC;CAED,OAAO,OAAOA,KACZ,SACA;EAAE,IAAI,YAAY,SAAS,QAAQ;EAAK,UAAU;CAAW,GAC7D,OACF;AACF,CAAC;;AAGD,MAAa,SAAS,UAAmB,CAAC,MACxC,MAAM,OAAOC,SAAiB,KAAK,OAAO,CAAC"}
1
+ {"version":3,"file":"Chromium.mjs","names":["Browser.make","Browser.Browser"],"sources":["../src/Chromium.ts"],"sourcesContent":["/**\n * A local Chromium, launched for the scope and closed with it.\n *\n * It uses the Chromium build that `playwright-core` installs\n * (`npx playwright-core install chromium`), unless `executablePath` names another.\n *\n * Signals are the program's to handle: run it with `NodeRuntime.runMain`, which interrupts it on\n * SIGINT and SIGTERM, so the browser closes with its scope.\n *\n * @since 0.3.0\n */\nimport { Effect, Layer } from \"effect\";\nimport { chromium } from \"playwright-core\";\n\nimport * as Browser from \"./Browser.ts\";\nimport { type BrowserError, Failed } from \"./BrowserError.ts\";\nimport { reasonOf, undispatched } from \"./internal/page/context.ts\";\n\nexport interface Options extends Browser.Options {\n /** Defaults to true. */\n readonly headless?: boolean | undefined;\n /**\n * Run Chromium's sandbox. Defaults to false, as in Playwright, so an exploit in a page's renderer\n * runs with this process's privileges. Hosts that don't allow unprivileged user namespaces, such\n * as many containers and Ubuntu 23.10 or later by default, can't start the sandbox; opening then\n * fails and says so.\n */\n readonly sandbox?: boolean | undefined;\n /** Defaults to 1280x720 CSS pixels at a device scale factor of 1. */\n readonly viewport?: { readonly width: number; readonly height: number } | undefined;\n readonly executablePath?: string | undefined;\n readonly args?: ReadonlyArray<string> | undefined;\n readonly userAgent?: string | undefined;\n readonly locale?: string | undefined;\n}\n\n// Playwright's own default, stated so that a launch timeout reports the bound it exceeded.\nconst launchTimeoutMillis = 180_000;\n\nconst failed = (operation: string, timeoutMillis?: number) => (cause: unknown) =>\n undispatched(operation, reasonOf(cause, timeoutMillis));\n\n// Playwright puts this in place of Chromium's startup log when the sandbox could not start, in an\n// error that otherwise reads as a closed browser.\nconst sandboxFailed = /Chromium sandboxing failed|No usable sandbox/;\n\nconst launchFailed = (cause: unknown) =>\n sandboxFailed.test(String(cause))\n ? undispatched(\n \"launch\",\n new Failed({\n detail:\n \"Chromium's sandbox could not start on this host: it needs unprivileged user namespaces, and a user other than root\",\n }),\n )\n : failed(\"launch\", launchTimeoutMillis)(cause);\n\n/** Launch Chromium and open a `Browser` over a fresh context. */\nexport const open = Effect.fn(\"Chromium.open\")(function* (options: Options = {}) {\n const launched = yield* Effect.acquireRelease(\n Effect.tryPromise({\n try: () =>\n chromium.launch({\n headless: options.headless ?? true,\n chromiumSandbox: options.sandbox ?? false,\n timeout: launchTimeoutMillis,\n // The program owns its signals. Playwright's handlers close every browser on any of\n // these, and on SIGINT then exit the process, so no finalizer would run.\n handleSIGINT: false,\n handleSIGTERM: false,\n handleSIGHUP: false,\n ...(options.executablePath === undefined\n ? {}\n : { executablePath: options.executablePath }),\n ...(options.args === undefined ? {} : { args: [...options.args] }),\n }),\n catch: launchFailed,\n }).pipe(Effect.withSpan(\"Chromium.launch\", {}, { captureStackTrace: false })),\n (browser) => Effect.tryPromise(() => browser.close()).pipe(Effect.ignore),\n );\n\n const context = yield* Effect.tryPromise({\n try: () =>\n launched.newContext({\n viewport: options.viewport ?? { width: 1280, height: 720 },\n deviceScaleFactor: 1,\n ...(options.userAgent === undefined ? {} : { userAgent: options.userAgent }),\n ...(options.locale === undefined ? {} : { locale: options.locale }),\n }),\n catch: failed(\"launch\"),\n });\n\n return yield* Browser.make(\n context,\n { id: `chromium-${launched.version()}`, provider: \"chromium\" },\n options,\n );\n});\n\n/** A `Browser` Layer that launches Chromium when built and closes it when released. */\nexport const layer = (options: Options = {}): Layer.Layer<Browser.Browser, BrowserError> =>\n Layer.effect(Browser.Browser, open(options));\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAqCA,MAAM,sBAAsB;AAE5B,MAAM,UAAU,WAAmB,mBAA4B,UAC7D,aAAa,WAAW,SAAS,OAAO,aAAa,CAAC;AAIxD,MAAM,gBAAgB;AAEtB,MAAM,gBAAgB,UACpB,cAAc,KAAK,OAAO,KAAK,CAAC,IAC5B,aACE,UACA,IAAI,OAAO,EACT,QACE,qHACJ,CAAC,CACH,IACA,OAAO,UAAU,mBAAmB,CAAC,CAAC,KAAK;;AAGjD,MAAa,OAAO,OAAO,GAAG,eAAe,CAAC,CAAC,WAAW,UAAmB,CAAC,GAAG;CAC/E,MAAM,WAAW,OAAO,OAAO,eAC7B,OAAO,WAAW;EAChB,WACE,SAAS,OAAO;GACd,UAAU,QAAQ,YAAY;GAC9B,iBAAiB,QAAQ,WAAW;GACpC,SAAS;GAGT,cAAc;GACd,eAAe;GACf,cAAc;GACd,GAAI,QAAQ,mBAAmB,KAAA,IAC3B,CAAC,IACD,EAAE,gBAAgB,QAAQ,eAAe;GAC7C,GAAI,QAAQ,SAAS,KAAA,IAAY,CAAC,IAAI,EAAE,MAAM,CAAC,GAAG,QAAQ,IAAI,EAAE;EAClE,CAAC;EACH,OAAO;CACT,CAAC,CAAC,CAAC,KAAK,OAAO,SAAS,mBAAmB,CAAC,GAAG,EAAE,mBAAmB,MAAM,CAAC,CAAC,IAC3E,YAAY,OAAO,iBAAiB,QAAQ,MAAM,CAAC,CAAC,CAAC,KAAK,OAAO,MAAM,CAC1E;CAEA,MAAM,UAAU,OAAO,OAAO,WAAW;EACvC,WACE,SAAS,WAAW;GAClB,UAAU,QAAQ,YAAY;IAAE,OAAO;IAAM,QAAQ;GAAI;GACzD,mBAAmB;GACnB,GAAI,QAAQ,cAAc,KAAA,IAAY,CAAC,IAAI,EAAE,WAAW,QAAQ,UAAU;GAC1E,GAAI,QAAQ,WAAW,KAAA,IAAY,CAAC,IAAI,EAAE,QAAQ,QAAQ,OAAO;EACnE,CAAC;EACH,OAAO,OAAO,QAAQ;CACxB,CAAC;CAED,OAAO,OAAOA,KACZ,SACA;EAAE,IAAI,YAAY,SAAS,QAAQ;EAAK,UAAU;CAAW,GAC7D,OACF;AACF,CAAC;;AAGD,MAAa,SAAS,UAAmB,CAAC,MACxC,MAAM,OAAOC,WAAiB,KAAK,OAAO,CAAC"}
@@ -0,0 +1,62 @@
1
+ import { t as BrowserError } from "./BrowserError-Coy7EW1N.mjs";
2
+ import { a as FindQuery, u as Page } from "./Page-ku6j5t-v.mjs";
3
+ import { Duration, Effect } from "effect";
4
+ declare namespace Expect_d_exports {
5
+ export { Attempt, Expectation, Options, Outcome, appeared, attempt, changed, gone, navigated };
6
+ }
7
+ /** What an action is for, as the page can tell it. */
8
+ type Expectation = {
9
+ readonly _tag: "Appeared";
10
+ readonly query: FindQuery;
11
+ } | {
12
+ readonly _tag: "Gone";
13
+ readonly query: FindQuery;
14
+ } | {
15
+ readonly _tag: "Changed";
16
+ readonly query: FindQuery;
17
+ } | {
18
+ readonly _tag: "Navigated";
19
+ readonly url: string | RegExp | undefined;
20
+ };
21
+ /** Something the query finds. */
22
+ declare const appeared: (query: FindQuery) => Expectation;
23
+ /** Nothing the query finds. */
24
+ declare const gone: (query: FindQuery) => Expectation;
25
+ /**
26
+ * What the query finds shows something other than it did as the attempt began: other elements, or
27
+ * their text, values or states.
28
+ */
29
+ declare const changed: (query: FindQuery) => Expectation;
30
+ /**
31
+ * The page is at `url`, the whole address or a pattern; without one, at an address or in a
32
+ * document other than the attempt's first.
33
+ */
34
+ declare const navigated: (url?: string | RegExp) => Expectation;
35
+ /**
36
+ * `Done`: the action ran, and what it was for came. `AlreadyDone`: it held before the action was
37
+ * sent, so it was not. `NotDone`: the action ran, and it did not come within the attempt's wait.
38
+ */
39
+ type Outcome = "Done" | "AlreadyDone" | "NotDone";
40
+ interface Options {
41
+ /** How long an action's effect may take to show. Defaults to 5 seconds. */
42
+ readonly wait?: Duration.Input | undefined;
43
+ }
44
+ interface Attempt {
45
+ readonly expectation: Expectation;
46
+ /** Whether the expectation holds on `page` now. */
47
+ readonly holds: (page: Page) => Effect.Effect<boolean, BrowserError>;
48
+ /**
49
+ * `act` on `page`, unless the expectation holds there already: see the module's comment. A
50
+ * failure before its input went is the action's own, and nothing is checked.
51
+ */
52
+ readonly run: (page: Page, act: (page: Page) => Effect.Effect<unknown, BrowserError>) => Effect.Effect<Outcome, BrowserError>;
53
+ }
54
+ /** Begin an attempt at `expectation` on `page`, which takes its baseline from the page now. */
55
+ declare const attempt: (page: Page, expectation: Expectation, options?: Options | undefined) => Effect.Effect<{
56
+ expectation: Expectation;
57
+ holds: (target: Page) => Effect.Effect<boolean, BrowserError, never>;
58
+ run: (target: Page, act: (page: Page) => Effect.Effect<unknown, BrowserError>) => Effect.Effect<"AlreadyDone" | "Done" | "NotDone", BrowserError, never>;
59
+ }, BrowserError, never>;
60
+ //#endregion
61
+ export { Outcome as a, changed as c, Options as i, gone as l, Expect_d_exports as n, appeared as o, Expectation as r, attempt as s, Attempt as t, navigated as u };
62
+ //# sourceMappingURL=Expect-u3P_ENLX.d.mts.map
package/dist/Expect.d.mts CHANGED
@@ -1,62 +1,2 @@
1
- import { t as BrowserError } from "./BrowserError-Coy7EW1N.mjs";
2
- import { a as FindQuery, u as Page } from "./Page-ku6j5t-v.mjs";
3
- import { Duration, Effect } from "effect";
4
- declare namespace Expect_d_exports {
5
- export { Attempt, Expectation, Options, Outcome, appeared, attempt, changed, gone, navigated };
6
- }
7
- /** What an action is for, as the page can tell it. */
8
- export type Expectation = {
9
- readonly _tag: "Appeared";
10
- readonly query: FindQuery;
11
- } | {
12
- readonly _tag: "Gone";
13
- readonly query: FindQuery;
14
- } | {
15
- readonly _tag: "Changed";
16
- readonly query: FindQuery;
17
- } | {
18
- readonly _tag: "Navigated";
19
- readonly url: string | RegExp | undefined;
20
- };
21
- /** Something the query finds. */
22
- export declare const appeared: (query: FindQuery) => Expectation;
23
- /** Nothing the query finds. */
24
- export declare const gone: (query: FindQuery) => Expectation;
25
- /**
26
- * What the query finds shows something other than it did as the attempt began: other elements, or
27
- * their text, values or states.
28
- */
29
- export declare const changed: (query: FindQuery) => Expectation;
30
- /**
31
- * The page is at `url`, the whole address or a pattern; without one, at an address or in a
32
- * document other than the attempt's first.
33
- */
34
- export declare const navigated: (url?: string | RegExp) => Expectation;
35
- /**
36
- * `Done`: the action ran, and what it was for came. `AlreadyDone`: it held before the action was
37
- * sent, so it was not. `NotDone`: the action ran, and it did not come within the attempt's wait.
38
- */
39
- export type Outcome = "Done" | "AlreadyDone" | "NotDone";
40
- export interface Options {
41
- /** How long an action's effect may take to show. Defaults to 5 seconds. */
42
- readonly wait?: Duration.Input | undefined;
43
- }
44
- export interface Attempt {
45
- readonly expectation: Expectation;
46
- /** Whether the expectation holds on `page` now. */
47
- readonly holds: (page: Page) => Effect.Effect<boolean, BrowserError>;
48
- /**
49
- * `act` on `page`, unless the expectation holds there already: see the module's comment. A
50
- * failure before its input went is the action's own, and nothing is checked.
51
- */
52
- readonly run: (page: Page, act: (page: Page) => Effect.Effect<unknown, BrowserError>) => Effect.Effect<Outcome, BrowserError>;
53
- }
54
- /** Begin an attempt at `expectation` on `page`, which takes its baseline from the page now. */
55
- export declare const attempt: (page: Page, expectation: Expectation, options?: Options | undefined) => Effect.Effect<{
56
- expectation: Expectation;
57
- holds: (target: Page) => Effect.Effect<boolean, BrowserError, never>;
58
- run: (target: Page, act: (page: Page) => Effect.Effect<unknown, BrowserError>) => Effect.Effect<"AlreadyDone" | "Done" | "NotDone", BrowserError, never>;
59
- }, BrowserError, never>;
60
- //#endregion
61
- export { Expect_d_exports as t };
62
- //# sourceMappingURL=Expect.d.mts.map
1
+ import { a as Outcome, c as changed, i as Options, l as gone, o as appeared, r as Expectation, s as attempt, t as Attempt, u as navigated } from "./Expect-u3P_ENLX.mjs";
2
+ export { Attempt, Expectation, Options, Outcome, appeared, attempt, changed, gone, navigated };
package/dist/Expect.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
2
2
  import { InvalidRequest } from "./BrowserError.mjs";
3
- import { c as undispatched } from "./context-w3NJPRLo.mjs";
4
- import { t as internalsOf } from "./page-BKwfF6z-.mjs";
3
+ import { c as undispatched } from "./context-EGhOqjNN.mjs";
4
+ import { t as internalsOf } from "./page-PTM8m5wC.mjs";
5
5
  import { Cause, Duration, Effect, Exit, Option, Schedule } from "effect";
6
6
  //#region src/Expect.ts
7
7
  /**
@@ -0,0 +1,28 @@
1
+ %% jpeg-js@0.4.4 NOTICES AND INFORMATION BEGIN HERE
2
+ =========================================
3
+ Copyright (c) 2014, Eugene Ware
4
+ All rights reserved.
5
+
6
+ Redistribution and use in source and binary forms, with or without
7
+ modification, are permitted provided that the following conditions are met:
8
+
9
+ 1. Redistributions of source code must retain the above copyright
10
+ notice, this list of conditions and the following disclaimer.
11
+ 2. Redistributions in binary form must reproduce the above copyright
12
+ notice, this list of conditions and the following disclaimer in the
13
+ documentation and/or other materials provided with the distribution.
14
+ 3. Neither the name of Eugene Ware nor the names of its contributors
15
+ may be used to endorse or promote products derived from this software
16
+ without specific prior written permission.
17
+
18
+ THIS SOFTWARE IS PROVIDED BY EUGENE WARE ''AS IS'' AND ANY
19
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
+ DISCLAIMED. IN NO EVENT SHALL EUGENE WARE BE LIABLE FOR ANY
22
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
+ =========================================
package/dist/Moment.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
2
2
  import { BrowserEvent } from "./BrowserEvent.mjs";
3
3
  import { BrowserError } from "./BrowserError.mjs";
4
- import { s as refuse } from "./context-w3NJPRLo.mjs";
4
+ import { s as refuse } from "./context-EGhOqjNN.mjs";
5
5
  import { Frame } from "./Frame.mjs";
6
6
  import { Snapshot } from "./Snapshot.mjs";
7
7
  import { c as quoted, l as where, o as describe, r as Changes, s as named } from "./Change-DNvztNLu.mjs";
@@ -0,0 +1,264 @@
1
+ import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
2
+ import { Point } from "./Motion.mjs";
3
+ import { Box, PageLoaded, Subject } from "./BrowserEvent.mjs";
4
+ import { a as withheld, o as Correlation, s as FailFast } from "./url-Bsp2y55M.mjs";
5
+ import { Frame, Image } from "./Frame.mjs";
6
+ import { Effect, Schema } from "effect";
7
+ //#region src/internal/input/evidence.inpage.ts
8
+ /**
9
+ * In the page: what the page says about an input's first target, for a judge, and which fields a
10
+ * form would send. It never reads what a field holds. See `reading/names.inpage.ts` for what a page-side part may use.
11
+ */
12
+ const FormFieldSchema = Schema.Struct({
13
+ type: Schema.String,
14
+ name: Schema.String,
15
+ autocomplete: Schema.optional(Schema.String),
16
+ filled: Schema.Boolean
17
+ });
18
+ const EvidenceSchema = Schema.Struct({
19
+ title: Schema.String,
20
+ description: Schema.optional(Schema.String),
21
+ dialog: Schema.optional(Schema.String),
22
+ heading: Schema.optional(Schema.String),
23
+ nearby: Schema.optional(Schema.String),
24
+ form: Schema.optional(Schema.Struct({
25
+ method: Schema.String,
26
+ action: Schema.String,
27
+ fields: Schema.Array(FormFieldSchema)
28
+ }))
29
+ });
30
+ //#endregion
31
+ //#region src/internal/input/guard.inpage.ts
32
+ /**
33
+ * In the page: what the input guard decides on. It inspects an input's targets for the facts a
34
+ * policy weighs, such as a form submission or a secret field, binds an approval to them, and
35
+ * checks before each press that the approved target would still receive it. See `reading/names.inpage.ts` for what a page-side part may use.
36
+ */
37
+ const Fact$1 = Schema.Literals([
38
+ "form-submit",
39
+ "cross-origin",
40
+ "download",
41
+ "upload",
42
+ "secret",
43
+ "scripted",
44
+ "opaque"
45
+ ]);
46
+ const InputPreparationError = Schema.Struct({
47
+ error: Schema.String,
48
+ detail: Schema.String,
49
+ index: Schema.optional(Schema.Finite)
50
+ });
51
+ const PreparedInputResultSchema = Schema.Union([Schema.Struct({
52
+ url: Schema.String,
53
+ targets: Schema.Array(Schema.NullOr(Schema.Struct({
54
+ ref: Schema.String,
55
+ element: Schema.String,
56
+ role: Schema.NullOr(Schema.String),
57
+ name: Schema.String,
58
+ cursor: Schema.String,
59
+ href: Schema.optional(Schema.String),
60
+ /** A field the DOM marks as holding a password, a one-time code or a card's details. */
61
+ secret: Schema.Boolean,
62
+ fingerprint: Schema.String
63
+ }))),
64
+ facts: Schema.Array(Fact$1),
65
+ destination: Schema.optional(Schema.String),
66
+ evidence: EvidenceSchema
67
+ }), InputPreparationError]);
68
+ const ValidatedInputResultSchema = Schema.Union([Schema.Struct({ ok: Schema.Literal(true) }), InputPreparationError]);
69
+ //#endregion
70
+ //#region src/Page.ts
71
+ /**
72
+ * One browser tab: navigation, snapshots, pictures and input.
73
+ *
74
+ * A page waits only for itself: its operations take turns in one lane of its own. An action, which
75
+ * sends input or navigates, has the page to itself, in the order actions were asked; reads share
76
+ * it, after the action in flight and every action asked before them, so a read describes the page
77
+ * an action left. A wait for a turn ends at the operation's deadline as `Busy`, never `Timeout`,
78
+ * and a full deadline then bounds the operation itself; `failFast` fails it at once instead.
79
+ * Identical reads asked between the same actions share one call to the page, and one whose
80
+ * callers gave up finishes for the next caller to ask it. A policy holds outside the lane while
81
+ * other operations continue; its target is revalidated before dispatch. Element targets are refs
82
+ * from a snapshot; point targets are viewport coordinates in CSS pixels, the same coordinates as a
83
+ * screenshot's pixels. Mouse and keyboard input share a bounded pipeline, so pacing does not wait
84
+ * for each protocol reply. Target lookup happens before the input is sent.
85
+ *
86
+ * @since 0.3.0
87
+ */
88
+ var Page_exports = /* @__PURE__ */ __exportAll({
89
+ ElementState: () => ElementState,
90
+ Fact: () => Fact,
91
+ Found: () => Found,
92
+ InputRequest: () => InputRequest,
93
+ Region: () => Region,
94
+ ResolvedTarget: () => ResolvedTarget,
95
+ State: () => State,
96
+ Text: () => Text,
97
+ Zoom: () => Zoom,
98
+ correlate: () => correlate,
99
+ failFast: () => failFast,
100
+ redacted: () => redacted
101
+ });
102
+ /** An integer rectangle in viewport CSS pixels. */
103
+ var Region = class extends Schema.Class("effect-browser/Region")({
104
+ x: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)),
105
+ y: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)),
106
+ width: Schema.Int.check(Schema.isGreaterThan(0)),
107
+ height: Schema.Int.check(Schema.isGreaterThan(0))
108
+ }) {};
109
+ /** A crop and its viewport origin: add that origin to a point read from the crop. */
110
+ var Zoom = class extends Schema.Class("effect-browser/Zoom")({
111
+ page: Schema.String,
112
+ region: Region,
113
+ image: Image
114
+ }) {};
115
+ /** The target as it read before input. Point coordinates are never snapped to another position. */
116
+ var ResolvedTarget = class extends Schema.Class("effect-browser/ResolvedTarget")({
117
+ point: Point,
118
+ ...Subject.fields,
119
+ element: Schema.String,
120
+ /** For a point target, the box of what it found there. */
121
+ box: Schema.optional(Box),
122
+ cursor: Schema.String,
123
+ href: Schema.optional(Schema.String)
124
+ }) {};
125
+ /**
126
+ * An element's state as its markup gives it: `checked` for what can be checked, `expanded`,
127
+ * `selected` and `pressed` where the page says either way, and `level` for headings.
128
+ */
129
+ const ElementState = Schema.Struct({
130
+ disabled: Schema.Boolean,
131
+ focused: Schema.Boolean,
132
+ checked: Schema.optional(Schema.Boolean),
133
+ expanded: Schema.optional(Schema.Boolean),
134
+ selected: Schema.optional(Schema.Boolean),
135
+ pressed: Schema.optional(Schema.Boolean),
136
+ level: Schema.optional(Schema.Int)
137
+ });
138
+ /** An element `find` found: a ref for the actions, what it is, where it is and its state. */
139
+ var Found = class extends Schema.Class("effect-browser/Found")({
140
+ ref: Schema.String,
141
+ subject: Subject,
142
+ /** Its box, rounded. Reading the document, it may be out of view. */
143
+ box: Box,
144
+ inViewport: Schema.Boolean,
145
+ state: ElementState
146
+ }) {};
147
+ /** What a page showed as text: a line per block, with table cells apart by tabs. */
148
+ var Text = class extends Schema.Class("effect-browser/Text")({
149
+ url: Schema.String,
150
+ title: Schema.String,
151
+ text: Schema.String,
152
+ /** True when `text` was cut at `maxChars`. */
153
+ truncated: Schema.Boolean,
154
+ /** Host monotonic milliseconds from the browser's captured Effect Clock. */
155
+ at: Schema.Finite
156
+ }) {};
157
+ /**
158
+ * What the library knows of a page now, without asking it, each part with when it learned it, in
159
+ * host monotonic milliseconds: a part's age is `at` less its time. Text read before the current
160
+ * document began is left out, since it tells of a document that has gone.
161
+ */
162
+ var State = class extends Schema.Class("effect-browser/PageState")({
163
+ page: Schema.String,
164
+ /** When this was taken. */
165
+ at: Schema.Finite,
166
+ /** Where the main frame last committed or moved, without userinfo or known secret parameters. */
167
+ url: Schema.String,
168
+ /** The page's document, as `Navigated` counts them. */
169
+ document: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)),
170
+ /** When the main frame committed it; absent for the one the browser began tracking it with. */
171
+ committedAt: Schema.optional(Schema.Finite),
172
+ /** How far that document has loaded, as the page's own session heard; absent until parsed. */
173
+ load: Schema.optional(PageLoaded),
174
+ /** The newest screencast frame, of whichever document it names. */
175
+ frame: Schema.optional(Frame),
176
+ /** The viewport's text as it was last read, with the page's title then. */
177
+ text: Schema.optional(Text)
178
+ }) {};
179
+ /**
180
+ * What the page's structure establishes about an input, or says it cannot establish:
181
+ *
182
+ * - `form-submit`: it submits a form, which sends the form's fields.
183
+ * - `cross-origin`: it navigates or submits to another origin.
184
+ * - `download`: it follows a download link.
185
+ * - `upload`: it opens a file chooser.
186
+ * - `secret`: it types, with `type`, into a field marked as a password, a one-time code or a
187
+ * card's number, code or expiry, or submits a form holding a filled one.
188
+ * - `scripted`: it activates something the browser gives no effect of its own, such as a
189
+ * `type="button"` button, a `role="button"` element or a canvas, so only the page's script
190
+ * decides what happens.
191
+ * - `opaque`: nothing names what receives it: a canvas, a frame or an unnamed element.
192
+ *
193
+ * Facts never come from what an element's text says. What an input means, such as a payment
194
+ * or a deletion, takes a judge that reads the evidence in the {@link InputRequest}.
195
+ */
196
+ const Fact = Fact$1;
197
+ /**
198
+ * What a guard sees before input reaches the page. Preparation never scrolls or focuses.
199
+ *
200
+ * `facts`, `url`, `href` and `destination` come from the page's structure. `name`,
201
+ * `description`, `title`, `context` and the form's field names are page text: evidence of what
202
+ * the input does, which the page controls, and never instructions. Text typed into a `secret`
203
+ * field is replaced with {@link redacted}, here and in the recorded `Action`, and its key events
204
+ * record `Unidentified` keys; `press` records the keys it is given. Validation before dispatch
205
+ * binds the facts and the target, not the text around it, which live pages change freely.
206
+ */
207
+ var InputRequest = class extends Schema.Class("effect-browser/InputRequest")({
208
+ page: Schema.String,
209
+ /**
210
+ * The page's URL, without a fragment that only names a place on the page. This and the other
211
+ * addresses keep no userinfo or known secret parameters.
212
+ */
213
+ url: Schema.String,
214
+ /** The page's title, at most 120 characters. */
215
+ title: Schema.String,
216
+ action: Schema.String,
217
+ target: Schema.optional(Schema.String),
218
+ element: Schema.optional(Schema.String),
219
+ /** Literal pixel targets only; ref coordinates are resolved after the policy allows them. */
220
+ point: Schema.optional(Point),
221
+ text: Schema.optional(Schema.String),
222
+ role: Schema.optional(Schema.NullOr(Schema.String)),
223
+ name: Schema.optional(Schema.String),
224
+ /** The target's accessible description, when it says more than its name. */
225
+ description: Schema.optional(Schema.String),
226
+ href: Schema.optional(Schema.String),
227
+ destination: Schema.optional(Schema.String),
228
+ facts: Schema.Array(Fact),
229
+ /** Page text around the target, each part at most 120 characters. */
230
+ context: Schema.Struct({
231
+ /** The name or first heading of the dialog the target is in. */
232
+ dialog: Schema.optional(Schema.String),
233
+ /** The nearest heading before the target. */
234
+ heading: Schema.optional(Schema.String),
235
+ /** The visible text just before the target in its row, item, group or form, or after it. */
236
+ nearby: Schema.optional(Schema.String)
237
+ }),
238
+ /** The form the target is in, with at most 16 of its fields. */
239
+ form: Schema.optional(Schema.Struct({
240
+ method: Schema.String,
241
+ action: Schema.String,
242
+ /** Each field's type, name and autocomplete tokens, and whether it is filled: never its value. */
243
+ fields: Schema.Array(FormFieldSchema)
244
+ }))
245
+ }) {};
246
+ /**
247
+ * What replaces text typed into a `secret` field, in requests and in the recorded `Action`, and a
248
+ * credential's value in every address the library reports.
249
+ */
250
+ const redacted = withheld;
251
+ /**
252
+ * Run page operations without waiting their turn: on a page busy with other operations, each fails
253
+ * `Busy` at once, and `Browser.newPage` on a browser with `maxPages` open fails `Limit` at once.
254
+ */
255
+ const failFast = (effect) => Effect.provideService(effect, FailFast, true);
256
+ /**
257
+ * Give every action `effect` performs a caller's id, such as a model's tool call id, which its
258
+ * recorded `Action` carries as `correlation`.
259
+ */
260
+ const correlate = (id) => (effect) => Effect.provideService(effect, Correlation, id);
261
+ //#endregion
262
+ export { Page_exports as a, State as c, correlate as d, failFast as f, ValidatedInputResultSchema as h, InputRequest as i, Text as l, PreparedInputResultSchema as m, Fact as n, Region as o, redacted as p, Found as r, ResolvedTarget as s, ElementState as t, Zoom as u };
263
+
264
+ //# sourceMappingURL=Page-BP02bmNv.mjs.map