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

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 (248) hide show
  1. package/README.md +130 -159
  2. package/dist/Action-24sLOubi.d.mts +110 -0
  3. package/dist/Action.d.mts +2 -0
  4. package/dist/Action.mjs +141 -0
  5. package/dist/Action.mjs.map +1 -0
  6. package/dist/ActionPort.d.mts +15 -0
  7. package/dist/ActionPort.mjs +101 -0
  8. package/dist/ActionPort.mjs.map +1 -0
  9. package/dist/Browser-Cq2K1FEA.mjs +4075 -0
  10. package/dist/Browser-Cq2K1FEA.mjs.map +1 -0
  11. package/dist/{Browser-CiXHT1yO.d.mts → Browser-wZhwZSlG.d.mts} +51 -13
  12. package/dist/Browser.d.mts +2 -2
  13. package/dist/Browser.mjs +1 -1
  14. package/dist/{BrowserError-Coy7EW1N.d.mts → BrowserError-BlcmLVzn.d.mts} +22 -7
  15. package/dist/BrowserError.d.mts +2 -2
  16. package/dist/BrowserError.mjs +46 -9
  17. package/dist/BrowserError.mjs.map +1 -1
  18. package/dist/{BrowserEvent-dq6FRT8w.d.mts → BrowserEvent-lLqJ3GJS.d.mts} +93 -37
  19. package/dist/BrowserEvent.d.mts +2 -2
  20. package/dist/BrowserEvent.mjs +29 -24
  21. package/dist/BrowserEvent.mjs.map +1 -1
  22. package/dist/{Change-DqING3tr.d.mts → Change-Ba7INmay.d.mts} +4 -6
  23. package/dist/Change.d.mts +2 -2
  24. package/dist/Change.mjs +97 -2
  25. package/dist/Change.mjs.map +1 -0
  26. package/dist/Clock.d.mts +57 -0
  27. package/dist/Clock.mjs +80 -0
  28. package/dist/Clock.mjs.map +1 -0
  29. package/dist/{Frame-DkNdjjjr.d.mts → Frame-UEH2hO5T.d.mts} +10 -3
  30. package/dist/Frame.d.mts +2 -2
  31. package/dist/Frame.mjs +10 -2
  32. package/dist/Frame.mjs.map +1 -1
  33. package/dist/{Motion-DND6I-64.d.mts → Geometry-DJx9qrYy.d.mts} +7 -10
  34. package/dist/Geometry.d.mts +2 -0
  35. package/dist/Geometry.mjs +32 -0
  36. package/dist/Geometry.mjs.map +1 -0
  37. package/dist/Matching.d.mts +37 -0
  38. package/dist/Matching.mjs +72 -0
  39. package/dist/Matching.mjs.map +1 -0
  40. package/dist/Page-BF5izr8R.mjs +795 -0
  41. package/dist/Page-BF5izr8R.mjs.map +1 -0
  42. package/dist/{Page-ku6j5t-v.d.mts → Page-CvsOEorc.d.mts} +158 -185
  43. package/dist/Page.d.mts +2 -2
  44. package/dist/Page.mjs +1 -1
  45. package/dist/Released-tURbFmal.d.mts +15 -0
  46. package/dist/{Snapshot-B34hZ4Jl.d.mts → Snapshot-CtBVOtuu.d.mts} +6 -1
  47. package/dist/Snapshot.d.mts +1 -1
  48. package/dist/Snapshot.mjs.map +1 -1
  49. package/dist/Stillness-CNlvayIo.mjs +136 -0
  50. package/dist/Stillness-CNlvayIo.mjs.map +1 -0
  51. package/dist/Style-AO4V7Czt.mjs +357 -0
  52. package/dist/Style-AO4V7Czt.mjs.map +1 -0
  53. package/dist/Style.d.mts +72 -0
  54. package/dist/Style.mjs +2 -0
  55. package/dist/Url.d.mts +26 -0
  56. package/dist/Url.mjs +74 -0
  57. package/dist/Url.mjs.map +1 -0
  58. package/dist/Window-CMddGMt1.d.mts +34 -0
  59. package/dist/Window.d.mts +2 -0
  60. package/dist/Window.mjs +35 -0
  61. package/dist/Window.mjs.map +1 -0
  62. package/dist/{cdp-DL7XfEj5.d.mts → connection-2KHI4_KN.d.mts} +4 -4
  63. package/dist/{cdp-BMpYMWYe.mjs → connection-BTeO0Hiz.mjs} +5 -6
  64. package/dist/connection-BTeO0Hiz.mjs.map +1 -0
  65. package/dist/index.d.mts +15 -18
  66. package/dist/index.mjs +11 -15
  67. package/dist/moment/Moment.d.mts +86 -0
  68. package/dist/{Moment.mjs → moment/Moment.mjs} +44 -38
  69. package/dist/moment/Moment.mjs.map +1 -0
  70. package/dist/{Plan-DJ4hEEna.d.mts → plan/index.d.mts} +169 -64
  71. package/dist/{Plan-BG1WifW2.mjs → plan/index.mjs} +122 -199
  72. package/dist/plan/index.mjs.map +1 -0
  73. package/dist/{Policy-BGWjbqCl.d.mts → policy/Policy.d.mts} +16 -20
  74. package/dist/{Policy.mjs → policy/Policy.mjs} +11 -21
  75. package/dist/policy/Policy.mjs.map +1 -0
  76. package/dist/presentation/Motion.d.mts +12 -0
  77. package/dist/{Motion.mjs → presentation/Motion.mjs} +4 -27
  78. package/dist/presentation/Motion.mjs.map +1 -0
  79. package/dist/presentation/Presentation.d.mts +30 -0
  80. package/dist/presentation/Presentation.mjs +105 -0
  81. package/dist/presentation/Presentation.mjs.map +1 -0
  82. package/dist/{Stage-NHp8N81k.d.mts → presentation/Stage.d.mts} +12 -15
  83. package/dist/{Stage.mjs → presentation/Stage.mjs} +68 -76
  84. package/dist/presentation/Stage.mjs.map +1 -0
  85. package/dist/presentation/feed.d.mts +20 -0
  86. package/dist/presentation/feed.mjs +18 -0
  87. package/dist/presentation/feed.mjs.map +1 -0
  88. package/dist/providers/Cdp.d.mts +9 -0
  89. package/dist/{Cdp.mjs → providers/Cdp.mjs} +3 -8
  90. package/dist/providers/Cdp.mjs.map +1 -0
  91. package/dist/{Chromium.d.mts → providers/Chromium.d.mts} +6 -7
  92. package/dist/{Chromium.mjs → providers/Chromium.mjs} +6 -15
  93. package/dist/providers/Chromium.mjs.map +1 -0
  94. package/dist/providers/Released.d.mts +2 -0
  95. package/dist/providers/Released.mjs +12 -0
  96. package/dist/providers/Released.mjs.map +1 -0
  97. package/dist/stillness/Stillness.d.mts +12 -0
  98. package/dist/stillness/Stillness.mjs +2 -0
  99. package/dist/supervisor/Supervisor.d.mts +104 -0
  100. package/dist/supervisor/Supervisor.mjs +513 -0
  101. package/dist/supervisor/Supervisor.mjs.map +1 -0
  102. package/dist/testing/index.d.mts +337 -0
  103. package/dist/testing/index.mjs +515 -0
  104. package/dist/testing/index.mjs.map +1 -0
  105. package/dist/workerd/Cdp.d.mts +8 -3
  106. package/dist/workerd/Cdp.mjs +2 -7
  107. package/dist/workerd/Cdp.mjs.map +1 -1
  108. package/package.json +86 -36
  109. package/src/Action.ts +127 -0
  110. package/src/ActionPort.ts +128 -0
  111. package/src/Browser.ts +352 -201
  112. package/src/BrowserError.ts +63 -6
  113. package/src/BrowserEvent.ts +26 -25
  114. package/src/Change.ts +0 -2
  115. package/src/{internal/pictures/clock.ts → Clock.ts} +17 -6
  116. package/src/Frame.ts +14 -0
  117. package/src/Geometry.ts +48 -0
  118. package/src/{internal/reading/match.inpage.ts → Matching.ts} +34 -4
  119. package/src/Page.ts +111 -92
  120. package/src/Snapshot.ts +5 -0
  121. package/src/{internal/input/style.ts → Style.ts} +121 -14
  122. package/src/Window.ts +30 -0
  123. package/src/index.ts +15 -6
  124. package/src/internal/input/actions.ts +61 -119
  125. package/src/internal/input/dispatch.ts +3 -3
  126. package/src/internal/input/gate.ts +21 -18
  127. package/src/internal/input/guard.inpage.ts +25 -58
  128. package/src/internal/input/guard.ts +11 -20
  129. package/src/internal/input/keyboard.ts +12 -3
  130. package/src/internal/input/perform.ts +78 -60
  131. package/src/internal/input/pointer.ts +4 -2
  132. package/src/internal/input/settle.ts +7 -5
  133. package/src/internal/input/targets.inpage.ts +1 -1
  134. package/src/internal/input/targets.ts +4 -9
  135. package/src/internal/page/bridge.ts +209 -113
  136. package/src/internal/page/context.ts +12 -59
  137. package/src/internal/page/dialogs.ts +58 -0
  138. package/src/internal/page/lane.ts +14 -15
  139. package/src/internal/page/navigation.ts +50 -42
  140. package/src/internal/page/openings.ts +11 -5
  141. package/src/internal/page/page.ts +44 -81
  142. package/src/internal/page/port.ts +125 -0
  143. package/src/internal/{input → page}/replies.ts +1 -1
  144. package/src/internal/page/request-owner.ts +269 -0
  145. package/src/internal/page/requests.ts +357 -0
  146. package/src/internal/page/scripts.ts +124 -0
  147. package/src/internal/pictures/capture.ts +255 -332
  148. package/src/internal/pictures/dimensions.ts +162 -0
  149. package/src/internal/pictures/frame.ts +68 -0
  150. package/src/internal/pictures/pictures.ts +57 -23
  151. package/src/internal/pictures/quiescence.ts +1 -1
  152. package/src/internal/pictures/state.ts +26 -0
  153. package/src/internal/pictures/transport.ts +21 -4
  154. package/src/internal/reading/controls.inpage.ts +5 -70
  155. package/src/internal/reading/expect.inpage.ts +13 -17
  156. package/src/internal/reading/names.inpage.ts +89 -45
  157. package/src/internal/reading/outline.inpage.ts +6 -7
  158. package/src/internal/reading/reading.ts +144 -176
  159. package/src/internal/reading/ready.inpage.ts +6 -17
  160. package/src/internal/reading/ready.ts +13 -135
  161. package/src/internal/reading/subjects.inpage.ts +83 -43
  162. package/src/internal/reading/walk.inpage.ts +33 -13
  163. package/src/internal/timeline/changes.ts +55 -6
  164. package/src/internal/timeline/events.ts +15 -5
  165. package/src/internal/timeline/history.inpage.ts +1 -1
  166. package/src/internal/timeline/record.inpage.ts +4 -1
  167. package/src/internal/timeline/window.ts +2 -1
  168. package/src/{Moment.ts → moment/Moment.ts} +13 -31
  169. package/src/{internal/timeline → moment}/words.ts +2 -2
  170. package/src/{internal/reading → plan}/choose.ts +3 -3
  171. package/src/plan/data.ts +117 -0
  172. package/src/plan/execute.ts +411 -0
  173. package/src/plan/index.ts +36 -0
  174. package/src/plan/record.ts +71 -0
  175. package/src/plan/targets.ts +71 -0
  176. package/src/{Policy.ts → policy/Policy.ts} +13 -10
  177. package/src/{Motion.ts → presentation/Motion.ts} +12 -46
  178. package/src/presentation/Presentation.ts +176 -0
  179. package/src/{Stage.ts → presentation/Stage.ts} +147 -112
  180. package/src/presentation/feed.ts +21 -0
  181. package/src/{Cdp.ts → providers/Cdp.ts} +2 -2
  182. package/src/{Chromium.ts → providers/Chromium.ts} +7 -10
  183. package/src/providers/Released.ts +13 -0
  184. package/src/{internal/cdp.ts → providers/connection.ts} +2 -2
  185. package/src/{internal/pictures/motion.ts → stillness/Pixels.ts} +1 -1
  186. package/src/stillness/Stillness.ts +166 -0
  187. package/src/supervisor/Supervisor.ts +170 -0
  188. package/src/supervisor/contract.ts +105 -0
  189. package/src/supervisor/lifecycle.ts +272 -0
  190. package/src/supervisor/runtime.ts +234 -0
  191. package/src/testing/TestBrowser.ts +115 -0
  192. package/src/testing/TestPage.ts +10 -0
  193. package/src/testing/evidence.ts +154 -0
  194. package/src/testing/index.ts +3 -0
  195. package/src/testing/model.ts +222 -0
  196. package/src/testing/page.ts +360 -0
  197. package/src/workerd/Cdp.ts +2 -2
  198. package/dist/Browser-CxXUjxOp.mjs +0 -619
  199. package/dist/Browser-CxXUjxOp.mjs.map +0 -1
  200. package/dist/Cdp-CzCRnMlM.d.mts +0 -10
  201. package/dist/Cdp.d.mts +0 -11
  202. package/dist/Cdp.mjs.map +0 -1
  203. package/dist/Change-DNvztNLu.mjs +0 -138
  204. package/dist/Change-DNvztNLu.mjs.map +0 -1
  205. package/dist/Chromium.mjs.map +0 -1
  206. package/dist/Expect-u3P_ENLX.d.mts +0 -62
  207. package/dist/Expect.d.mts +0 -2
  208. package/dist/Expect.mjs +0 -114
  209. package/dist/Expect.mjs.map +0 -1
  210. package/dist/Moment.d.mts +0 -2
  211. package/dist/Moment.mjs.map +0 -1
  212. package/dist/Motion.d.mts +0 -2
  213. package/dist/Motion.mjs.map +0 -1
  214. package/dist/Page-BP02bmNv.mjs +0 -264
  215. package/dist/Page-BP02bmNv.mjs.map +0 -1
  216. package/dist/Plan-BG1WifW2.mjs.map +0 -1
  217. package/dist/Plan.d.mts +0 -2
  218. package/dist/Plan.mjs +0 -2
  219. package/dist/Policy.d.mts +0 -2
  220. package/dist/Policy.mjs.map +0 -1
  221. package/dist/Presentation-DxVikn9_.d.mts +0 -48
  222. package/dist/Presentation.d.mts +0 -2
  223. package/dist/Presentation.mjs +0 -118
  224. package/dist/Presentation.mjs.map +0 -1
  225. package/dist/Stage.d.mts +0 -2
  226. package/dist/Stage.mjs.map +0 -1
  227. package/dist/Supervisor-2mPjIYYs.mjs +0 -676
  228. package/dist/Supervisor-2mPjIYYs.mjs.map +0 -1
  229. package/dist/Supervisor-CfRxbaso.d.mts +0 -317
  230. package/dist/Supervisor.d.mts +0 -2
  231. package/dist/Supervisor.mjs +0 -2
  232. package/dist/cdp-BMpYMWYe.mjs.map +0 -1
  233. package/dist/context-EGhOqjNN.mjs +0 -335
  234. package/dist/context-EGhOqjNN.mjs.map +0 -1
  235. package/dist/page-PTM8m5wC.mjs +0 -4057
  236. package/dist/page-PTM8m5wC.mjs.map +0 -1
  237. package/dist/url-Bsp2y55M.mjs +0 -264
  238. package/dist/url-Bsp2y55M.mjs.map +0 -1
  239. package/dist/workerd/index.d.mts +0 -16
  240. package/dist/workerd/index.mjs +0 -17
  241. package/src/Expect.ts +0 -180
  242. package/src/Plan.ts +0 -674
  243. package/src/Presentation.ts +0 -196
  244. package/src/Supervisor.ts +0 -632
  245. package/src/internal/supervisor/lifecycle.ts +0 -484
  246. package/src/workerd/index.ts +0 -17
  247. /package/src/{internal/page/url.ts → Url.ts} +0 -0
  248. /package/src/{internal/pictures → stillness}/utilsBundle.d.ts +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Page-BF5izr8R.mjs","names":["Fact","Motion.Point","Guard.Fact","Url.withheld"],"sources":["../src/internal/input/evidence.inpage.ts","../src/internal/input/guard.inpage.ts","../src/internal/page/lane.ts","../src/Page.ts"],"sourcesContent":["/**\n * In the page: what the page says about an input's first target, for a judge, and which fields a\n * form would send. It never reads what a field holds. See `reading/names.inpage.ts` for what a page-side part may use.\n */\nimport { Schema } from \"effect\";\n\nimport type { ContextReader } from \"../reading/context.inpage.ts\";\nimport type { Names } from \"../reading/names.inpage.ts\";\n\n/** Page text about the first target. It never includes what a field holds. */\nexport type Evidence = typeof EvidenceSchema.Encoded;\n\ntype Field = HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement;\n\nexport const evidence = (names: Names, placing: ContextReader) => {\n const { clean, isDocument, isInput, isSelect, isTextArea, nameOf, parentOf, roleOf, textOf } =\n names;\n\n const { groups, headingBefore, textBeside, treeOf } = placing;\n\n /** A field a submission would send. */\n const isField = (element: Element): element is Field =>\n ((isInput(element) && ![\"button\", \"submit\", \"reset\", \"image\"].includes(element.type)) ||\n isSelect(element) ||\n isTextArea(element)) &&\n !element.matches(\":disabled\");\n\n const isFilled = (field: Field): boolean =>\n isInput(field) && (field.type === \"checkbox\" || field.type === \"radio\")\n ? field.checked\n : isInput(field) && field.type === \"file\"\n ? (field.files?.length ?? 0) > 0\n : field.value !== \"\";\n\n const dialogOf = (element: Element): Element | undefined => {\n for (let node: Element | null = element; node !== null; node = parentOf(node))\n if (node.tagName === \"DIALOG\" || /^(?:alert)?dialog$/.test(node.getAttribute(\"role\") ?? \"\"))\n return node;\n\n return undefined;\n };\n\n /** What the page says about an input's first target, for a judge. Never a field's value. */\n const evidenceOf = (\n element: Element,\n form: HTMLFormElement | null,\n method: string | undefined,\n action: string | undefined,\n ): Evidence => {\n const name = nameOf(element, roleOf(element));\n const ids = element.getAttribute(\"aria-describedby\");\n\n const description = clean(\n ids === null\n ? (element.getAttribute(\"aria-description\") ?? element.getAttribute(\"title\"))\n : ids\n .split(/\\s+/)\n .map((id) => element.ownerDocument.getElementById(id)?.textContent ?? \"\")\n .join(\" \"),\n 120,\n );\n\n const dialog = dialogOf(element);\n\n const title = dialog?.querySelector(\"h1,h2,h3,h4,h5,h6,[role=heading]\");\n\n const dialogName =\n dialog === undefined\n ? \"\"\n : clean(nameOf(dialog, \"dialog\"), 120) ||\n (title === null || title === undefined ? \"\" : clean(textOf(title), 120));\n\n // Each scope stays in the target's own tree: a walker cannot leave a shadow root.\n const root = element.getRootNode();\n const top = isDocument(root) ? (root.body ?? root) : root;\n const inTree = element.closest(\"dialog,[role=dialog],[role=alertdialog]\");\n let nearby = \"\";\n\n for (const scope of new Set([element.closest(groups), inTree, top]))\n if (scope !== null && nearby === \"\")\n nearby = textBeside(element, scope, true) || textBeside(element, scope, false);\n\n const heading = headingBefore(element, treeOf(element));\n\n const fields =\n form === null\n ? []\n : Array.from(form.elements)\n .filter(isField)\n .slice(0, 16)\n .map((field) => {\n const autocomplete = clean(field.getAttribute(\"autocomplete\"), 40);\n\n return {\n type: isInput(field) ? field.type : field.tagName.toLowerCase(),\n name: clean(\n isInput(field) && field.type === \"hidden\"\n ? field.getAttribute(\"name\")\n : nameOf(field, roleOf(field)),\n 40,\n ),\n ...(autocomplete === \"\" ? {} : { autocomplete }),\n filled: isFilled(field),\n };\n });\n\n return {\n title: clean(document.title, 120),\n ...(description === \"\" || description === name ? {} : { description }),\n ...(dialogName === \"\" ? {} : { dialog: dialogName }),\n ...(heading === undefined ? {} : { heading }),\n ...(nearby === \"\" ? {} : { nearby }),\n ...(form === null\n ? {}\n : { form: { method: method ?? form.method, action: action ?? form.action, fields } }),\n };\n };\n\n return { evidenceOf, isField, isFilled };\n};\n\nexport type EvidenceReader = ReturnType<typeof evidence>;\n\nexport const FormFieldSchema = Schema.Struct({\n type: Schema.String,\n name: Schema.String,\n autocomplete: Schema.optional(Schema.String),\n filled: Schema.Boolean,\n});\n\nexport const EvidenceSchema = Schema.Struct({\n title: Schema.String,\n description: Schema.optional(Schema.String),\n dialog: Schema.optional(Schema.String),\n heading: Schema.optional(Schema.String),\n nearby: Schema.optional(Schema.String),\n form: Schema.optional(\n Schema.Struct({\n method: Schema.String,\n action: Schema.String,\n fields: Schema.Array(FormFieldSchema),\n }),\n ),\n});\n","/**\n * In the page: what the input guard decides on. It inspects an input's targets for the facts a\n * policy weighs, such as a form submission or a secret field, binds an approval to them, and\n * 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.\n */\nimport { Schema } from \"effect\";\n\nimport type { Point } from \"../../Geometry.ts\";\nimport type { Names } from \"../reading/names.inpage.ts\";\nimport { type Evidence, type EvidenceReader, EvidenceSchema } from \"./evidence.inpage.ts\";\nimport type { Targets } from \"./targets.inpage.ts\";\n\nexport const Fact = Schema.Literals([\n \"form-submit\",\n \"cross-origin\",\n \"download\",\n \"upload\",\n \"secret\",\n \"scripted\",\n \"opaque\",\n]);\n\nexport type Fact = typeof Fact.Type;\n\nexport interface InputPlan {\n readonly action: string;\n readonly targets: ReadonlyArray<string | Point | null>;\n readonly submit: boolean;\n readonly keys: string | null;\n readonly destination: string | null;\n}\n\nexport type InspectedTarget = NonNullable<PreparedInput[\"targets\"][number]>;\n\nexport type PreparedInput = Exclude<PreparedInputResult, InputFailure>;\n\n/** A refusal; a stale target is named by its index in the plan. */\nexport type InputFailure = typeof InputPreparationError.Encoded;\n\nexport type PreparedInputResult = typeof PreparedInputResultSchema.Encoded;\n\nexport type ValidatedInputResult = typeof ValidatedInputResultSchema.Encoded;\n\n/** A point where a target, by its index in the plan, is about to receive a press. */\nexport interface Press extends Point {\n readonly index: number;\n}\n\nexport interface ValidationOptions {\n /** Require focus on the first target. */\n readonly focused?: boolean;\n /** After the pointer's own events have run, each target must still receive its press. */\n readonly presses?: ReadonlyArray<Press>;\n}\n\nexport const guard = (names: Names, targets: Targets, evidence: EvidenceReader) => {\n const {\n activeElement,\n textEntry,\n clean,\n describe,\n inCurrentDocument,\n interactiveRoles,\n isButton,\n isDisabled,\n isHtml,\n isInput,\n isLabel,\n isRoot,\n isSecret,\n isSelect,\n isTextArea,\n lookup,\n parentOf,\n refFor,\n roleOf,\n } = names;\n\n const { controlOf, details, hitAt, hrefAttribute, linkOf, receives, within } = targets;\n const { evidenceOf, isField, isFilled } = evidence;\n\n const nativeActivation = (element: Element) =>\n hrefAttribute(element) !== null ||\n element.tagName === \"BUTTON\" ||\n element.tagName === \"SUMMARY\" ||\n (isInput(element) && element.type !== \"hidden\");\n\n /**\n * The element whose activation behaviour a click or key on `element` runs, as the browser\n * resolves it along the composed path: a link, button, input, summary or a label's control.\n */\n const activationTarget = (element: Element): Element | undefined => {\n for (let node: Element | null = element; node !== null; node = parentOf(node)) {\n if (nativeActivation(node)) return node;\n if (isLabel(node) && node.control !== null) return node.control;\n }\n\n return undefined;\n };\n\n /**\n * A control between a press's hit and the approved target that is not the target's own\n * activation, such as a link or button a hover handler nested into it. The approval inspected\n * the target, so that control would act unapproved.\n */\n const nestedControl = (element: Element, hit: Element): Element | undefined => {\n // A container of the target is covered by the target's own facts.\n if (!within(element, hit)) return undefined;\n const own = activationTarget(element);\n\n for (\n let node: Element | null = hit;\n node !== null && node !== element;\n node = parentOf(node) ?? node.ownerDocument.defaultView?.frameElement ?? null\n )\n if (\n node !== own &&\n (nativeActivation(node) ||\n isSelect(node) ||\n isTextArea(node) ||\n (isLabel(node) && node.control !== null && node.control !== own) ||\n activatingRoles.has(roleOf(node) ?? \"\"))\n )\n return node;\n\n return undefined;\n };\n\n const activatingRoles = new Set([\n \"button\",\n \"link\",\n \"checkbox\",\n \"radio\",\n \"switch\",\n \"tab\",\n \"menuitem\",\n \"menuitemcheckbox\",\n \"menuitemradio\",\n \"option\",\n \"treeitem\",\n ]);\n\n // Typed text goes wherever focus is, and a typed space or letter can press a focused button,\n // toggle a box, follow a link or change a select. Only fields, or elements that are none of\n // these (a page or a canvas game), may receive text.\n const typingRefusal = (element: Element, explicit: boolean): string | undefined =>\n textEntry(element)\n ? undefined\n : explicit\n ? `${describe(element)} is not a text field`\n : activationTarget(element) !== undefined ||\n isSelect(element) ||\n activatingRoles.has(roleOf(element) ?? \"\")\n ? `focus is on ${describe(element)}, which typed text could activate or change; type into a text field by ref, or use press for keys`\n : undefined;\n\n const isSubmitter = (element: Element): element is HTMLButtonElement | HTMLInputElement =>\n (isButton(element) && element.type === \"submit\") ||\n (isInput(element) && (element.type === \"submit\" || element.type === \"image\"));\n\n // form.elements omits image submitters. Walk the whole root in tree order so an Enter\n // submission uses the real default button, including controls associated from outside the form.\n const defaultSubmitter = (form: HTMLFormElement) => {\n const root = form.getRootNode();\n\n return isRoot(root)\n ? Array.from(root.querySelectorAll(\"button,input\")).find(\n (candidate): candidate is HTMLButtonElement | HTMLInputElement =>\n isSubmitter(candidate) && candidate.form === form,\n )\n : undefined;\n };\n\n // Attributes that say what a field is for. They bind an approval.\n const purpose = (control: Element, form: HTMLFormElement | null) => [\n control.getAttribute(\"id\"),\n control.getAttribute(\"name\"),\n control.getAttribute(\"inputmode\"),\n control.getAttribute(\"autocomplete\"),\n control.getAttribute(\"aria-label\"),\n form?.getAttribute(\"id\"),\n form?.getAttribute(\"name\"),\n form?.getAttribute(\"aria-label\"),\n ];\n\n // What an approval binds of a URL. A fragment that names a place on the page, which scroll-spy\n // and feed pages rewrite as they scroll, is left out. A hash route (#/… or #!…) stays: it\n // selects what the page's controls act on.\n const boundUrl = (url: string): string => {\n const hash = url.indexOf(\"#\");\n\n return hash === -1 || /^#[/!]/.test(url.slice(hash)) ? url : url.slice(0, hash);\n };\n\n const inspectInput = (element: Element, plan: InputPlan) => {\n const metadata = details(element, element, 0, 0);\n // Facts are about what the input activates, such as the submit button around a painted label.\n const control = activationTarget(element) ?? element;\n\n const form =\n isInput(control) || isButton(control) || isTextArea(control) || isSelect(control)\n ? control.form\n : null;\n\n // The chord's last key, which may be the plus key itself: Control++.\n const key = plan.keys === null ? undefined : /(?:^|\\+)(\\+|[^+]+)$/.exec(plan.keys)?.[1];\n const enter = key === \"Enter\";\n\n const activation =\n plan.action === \"click\" || (plan.action === \"press\" && (enter || key === \"Space\"));\n\n // Enter submits a form from any input but buttons, file and color pickers, including\n // checkboxes, radios and ranges.\n const fieldEnter =\n isInput(control) &&\n ![\"button\", \"reset\", \"submit\", \"image\", \"file\", \"color\", \"hidden\"].includes(control.type) &&\n ((plan.action === \"press\" && enter) || (plan.action === \"type\" && plan.submit));\n\n const submits = form !== null && ((activation && isSubmitter(control)) || fieldEnter);\n\n const submitter = isSubmitter(control)\n ? control\n : form === null\n ? undefined\n : defaultSubmitter(form);\n\n const formValue = (\n attribute: \"action\" | \"method\" | \"target\",\n property: \"formAction\" | \"formMethod\" | \"formTarget\",\n ) =>\n form === null\n ? undefined\n : submitter?.hasAttribute(`form${attribute}`) === true\n ? submitter[property]\n : form[attribute];\n\n const formDestination = formValue(\"action\", \"formAction\");\n const formMethod = formValue(\"method\", \"formMethod\");\n const formTarget = formValue(\"target\", \"formTarget\");\n\n const link = linkOf(element);\n const href = link === undefined ? null : hrefAttribute(link);\n // A dialog form only closes its dialog; the page's script decides what that means.\n const sends = submits && formMethod !== \"dialog\";\n // Only activation follows a link or opens a file chooser; hovering or scrolling over a\n // control does neither.\n const destination = sends ? formDestination : activation ? metadata.href : undefined;\n const acts = plan.action !== \"hover\" && plan.action !== \"scroll\";\n\n // What the browser itself does on activation: follow a link, submit or reset a form, choose\n // a file or a value, toggle a box or a disclosure, or focus a field. Anything else is the\n // page's script.\n const builtIn =\n sends ||\n (href !== null && !/^\\s*(?:#\\s*|javascript:[^]*)$/i.test(href)) ||\n (isInput(control) && ![\"button\", \"submit\", \"image\", \"reset\"].includes(control.type)) ||\n ((isInput(control) || isButton(control)) && control.type === \"reset\" && form !== null) ||\n control.tagName === \"SUMMARY\" ||\n control.closest(\"select\") !== null ||\n textEntry(control);\n\n const facts: Array<Fact> = [];\n\n // Facts come from structure only. What a name or the text around it says is evidence for a\n // judge, never a fact: words change meaning with context and language.\n if (sends) facts.push(\"form-submit\");\n if (activation && link?.hasAttribute(\"download\") === true) facts.push(\"download\");\n if (activation && isInput(control) && control.type === \"file\") facts.push(\"upload\");\n if (\n (plan.action === \"type\" && isSecret(control)) ||\n (sends &&\n form !== null &&\n Array.from(form.elements).some(\n (field) => isField(field) && isSecret(field) && isFilled(field),\n ))\n )\n facts.push(\"secret\");\n if (activation && !builtIn) facts.push(\"scripted\");\n if (acts && (metadata.role === \"canvas\" || metadata.role === \"iframe\" || metadata.name === \"\"))\n facts.push(\"opaque\");\n\n // Bind what decides the consequence and the control's identity. Names bind interactive\n // controls only: other text, such as a live price or a page's own text, may change freely.\n const role = metadata.role;\n\n const boundName =\n role !== null &&\n (interactiveRoles.has(role) || role === \"canvas\" || role === \"iframe\") &&\n !(isHtml(element) && element.isContentEditable)\n ? metadata.name\n : null;\n\n // A focus or scroll handler changing these attributes must not leave an old permission behind.\n const fingerprint = JSON.stringify([\n purpose(control, form),\n element.tagName,\n element.id,\n role,\n boundName,\n metadata.href,\n control === element ? null : refFor(control),\n isInput(control) || isButton(control) ? control.type : control.tagName,\n isDisabled(control),\n control.getAttribute(\"readonly\"),\n control.getAttribute(\"aria-readonly\"),\n isHtml(control) && control.isContentEditable,\n control.getAttribute(\"name\"),\n control.getAttribute(\"accept\"),\n control.hasAttribute(\"multiple\"),\n link?.getAttribute(\"download\"),\n form === null ? null : refFor(form),\n form === null ? null : boundUrl(form.action),\n form?.method,\n form?.target,\n submitter === undefined ? null : refFor(submitter),\n formDestination === undefined ? undefined : boundUrl(formDestination),\n formMethod,\n formTarget,\n submitter?.formNoValidate,\n form?.noValidate,\n ]);\n\n const inspected: InspectedTarget = {\n ref: refFor(element),\n element: metadata.element,\n role: metadata.role,\n name: metadata.name,\n cursor: metadata.cursor,\n ...(metadata.href === undefined ? {} : { href: metadata.href }),\n secret: isSecret(control),\n fingerprint,\n };\n\n return {\n inspected,\n facts,\n destination,\n explain: () => evidenceOf(element, form, formMethod, formDestination),\n };\n };\n\n // Approval preparation only reads the DOM. In particular, an offscreen ref must not scroll\n // before the policy has had a chance to deny it.\n const inspect = (\n plan: InputPlan,\n ): (Omit<PreparedInput, \"evidence\"> & { readonly explain: () => Evidence }) | InputFailure => {\n const targets: Array<InspectedTarget | null> = [];\n const facts = new Set<Fact>();\n let destination = plan.destination ?? undefined;\n let explain = (): Evidence => ({ title: clean(document.title, 120) });\n\n for (const [index, target] of plan.targets.entries()) {\n let element: Element | null | undefined;\n\n if (target === null) {\n element = activeElement();\n } else if (typeof target === \"string\") {\n element = lookup(target);\n if (element === undefined)\n return { error: \"stale\", detail: target + \" is not on the page any more\", index };\n } else {\n if (\n !Number.isFinite(target.x) ||\n !Number.isFinite(target.y) ||\n target.x < 0 ||\n target.y < 0 ||\n target.x >= window.innerWidth ||\n target.y >= window.innerHeight\n )\n return { error: \"outside\", detail: \"the point is outside the viewport\" };\n const hit = hitAt(document, target.x, target.y);\n\n element = hit === null ? null : controlOf(hit);\n if (element === null)\n return { error: \"offscreen\", detail: \"nothing is painted at the point\" };\n }\n\n if (element === null) {\n targets.push(null);\n continue;\n }\n if (!inCurrentDocument(element))\n return { error: \"stale\", detail: \"the input target belongs to a replaced document\", index };\n const refusal = plan.action === \"type\" ? typingRefusal(element, target !== null) : undefined;\n\n if (refusal !== undefined) return { error: \"untypeable\", detail: refusal };\n const inspected = inspectInput(element, plan);\n\n if (index === 0) explain = inspected.explain;\n targets.push(inspected.inspected);\n for (const fact of inspected.facts) facts.add(fact);\n destination ??= inspected.destination;\n if (inspected.destination !== undefined) {\n try {\n if (new URL(inspected.destination, location.href).origin !== location.origin)\n facts.add(\"cross-origin\");\n } catch {\n return { error: \"outside\", detail: \"the input destination is not a valid URL\" };\n }\n }\n }\n\n if (destination !== undefined) {\n try {\n destination = new URL(destination, location.href).href;\n if (new URL(destination).origin !== location.origin) facts.add(\"cross-origin\");\n } catch {\n return { error: \"outside\", detail: \"the input destination is not a valid URL\" };\n }\n }\n\n return {\n url: boundUrl(location.href),\n targets,\n facts: [...facts],\n ...(destination === undefined ? {} : { destination }),\n explain,\n };\n };\n\n // Evidence is read once, for the policy. Validation binds the facts and the targets, not the\n // text around them, which live pages change freely.\n const prepareInput = (plan: InputPlan): PreparedInputResult => {\n const inspected = inspect(plan);\n\n if (\"error\" in inspected) return inspected;\n const { explain, ...prepared } = inspected;\n\n return { ...prepared, evidence: explain() };\n };\n\n const bindings = (targets: PreparedInput[\"targets\"]) =>\n targets.map((target) => (target === null ? null : [target.ref, target.fingerprint]));\n\n const validate = (\n plan: InputPlan,\n prepared: PreparedInput,\n options: ValidationOptions,\n ): ValidatedInputResult => {\n const current = inspect(plan);\n\n if (\"error\" in current)\n return current.error === \"stale\" ? current : { error: \"changed\", detail: current.detail };\n if (\n current.url !== prepared.url ||\n (current.destination === undefined || prepared.destination === undefined\n ? current.destination !== prepared.destination\n : boundUrl(current.destination) !== boundUrl(prepared.destination)) ||\n JSON.stringify(current.facts) !== JSON.stringify(prepared.facts) ||\n JSON.stringify(bindings(current.targets)) !== JSON.stringify(bindings(prepared.targets))\n )\n return {\n error: \"changed\",\n detail: \"the page or input target changed while the policy was deciding\",\n };\n\n if (options.focused === true) {\n const active = activeElement();\n const expected = prepared.targets[0];\n\n if (\n active === null ||\n expected === null ||\n expected === undefined ||\n refFor(active) !== expected.ref\n )\n return { error: \"changed\", detail: \"focus moved away from the approved element\" };\n }\n\n for (const press of options.presses ?? []) {\n const expected = prepared.targets[press.index];\n\n const element =\n expected === null || expected === undefined ? undefined : lookup(expected.ref);\n\n const hit = hitAt(document, press.x, press.y);\n\n if (element === undefined || hit === null || !receives(element, hit))\n return {\n error: \"changed\",\n detail: `the approved target is no longer under the pointer at (${press.x}, ${press.y})`,\n };\n\n const nested = nestedControl(element, hit);\n\n if (nested !== undefined)\n return {\n error: \"changed\",\n detail: `${describe(nested)} inside the approved target would receive the press at (${press.x}, ${press.y})`,\n };\n }\n\n return { ok: true };\n };\n\n // Chromium delivers pointer moves with the next frame. A press check waits until the frame\n // after it, so it sees what the page did when the pointer arrived, such as a menu opened over\n // the target. A hidden document draws no frames, and its moves wait for the press instead.\n const validateInput = (\n plan: InputPlan,\n prepared: PreparedInput,\n options: ValidationOptions = {},\n ): ValidatedInputResult | Promise<ValidatedInputResult> => {\n if ((options.presses ?? []).length === 0) return validate(plan, prepared, options);\n const { promise, resolve } = Promise.withResolvers<void>();\n\n if (document.visibilityState === \"hidden\") resolve();\n else requestAnimationFrame(() => requestAnimationFrame(() => resolve()));\n\n return promise.then(() => validate(plan, prepared, options));\n };\n\n return { prepareInput, textEntry, typingRefusal, validateInput };\n};\n\nexport type Guard = ReturnType<typeof guard>;\n\nconst InputPreparationError = Schema.Struct({\n error: Schema.String,\n detail: Schema.String,\n index: Schema.optional(Schema.Finite),\n});\n\nexport const PreparedInputResultSchema = Schema.Union([\n Schema.Struct({\n url: Schema.String,\n targets: Schema.Array(\n Schema.NullOr(\n Schema.Struct({\n ref: Schema.String,\n element: Schema.String,\n role: Schema.NullOr(Schema.String),\n name: Schema.String,\n cursor: Schema.String,\n href: Schema.optional(Schema.String),\n /** A field the DOM marks as holding a password, a one-time code or a card's details. */\n secret: Schema.Boolean,\n fingerprint: Schema.String,\n }),\n ),\n ),\n facts: Schema.Array(Fact),\n destination: Schema.optional(Schema.String),\n evidence: EvidenceSchema,\n }),\n InputPreparationError,\n]);\n\nexport const ValidatedInputResultSchema = Schema.Union([\n Schema.Struct({ ok: Schema.Literal(true) }),\n InputPreparationError,\n]);\n","/**\n * A page's admission: the one lane every operation on the page takes its turn in, so a page waits\n * only for itself. A write, an action that sends input or navigates, holds the lane alone, in the\n * order writes asked; reads share it, after the write in flight and every write asked before them,\n * so a read describes the page an action left, never one an action is still changing. Each write\n * starts a new epoch as it asks. A turn not given in time fails `Busy`, never `Timeout`, and a\n * caller under `FailFast` gets it at once.\n *\n * Reads keep their work. An identical read asked in the same epoch and document joins the one in\n * flight, which runs in the page's scope under the action timeout whoever gives up; one that ends\n * after all its callers gave up serves the next to ask the same, within 250 milliseconds. A write\n * stops the reads nobody awaits, since no caller after it could use them.\n *\n * Effect's `Semaphore` is not fair to a writer that needs every permit, so the rule is this\n * module's own: one state, changed by `step` alone, which the model test drives.\n */\nimport { Context, Deferred, type Duration, Effect, Exit, type Fiber, type Scope } from \"effect\";\n\nimport { undispatched, type BrowserError, Busy } from \"../../BrowserError.ts\";\n\nexport type Kind = \"read\" | \"write\";\n\nexport interface Ticket {\n readonly id: number;\n readonly kind: Kind;\n}\n\n/** Who holds the lane: no one, reads together, or one write. */\nexport type Turn =\n | { readonly _tag: \"Free\" }\n | { readonly _tag: \"Reading\"; readonly count: number }\n | { readonly _tag: \"Writing\" };\n\nexport interface State {\n readonly turn: Turn;\n /** The tickets waiting, in the order they asked. */\n readonly queue: ReadonlyArray<Ticket>;\n /** The writes asked so far: two reads in one epoch follow the same writes. */\n readonly epoch: number;\n}\n\nexport type Input =\n | { readonly _tag: \"Ask\"; readonly ticket: Ticket }\n /** The ticket gave up waiting, or ended its turn. */\n | { readonly _tag: \"Leave\"; readonly ticket: Ticket };\n\nexport const initial: State = { turn: { _tag: \"Free\" }, queue: [], epoch: 0 };\n\nconst holders = (turn: Turn) =>\n turn._tag === \"Reading\" ? turn.count : turn._tag === \"Writing\" ? 1 : 0;\n\n/** Whether a ticket of `kind` asking now would hold the lane at once. */\nexport const admitsNow = ({ turn, queue }: State, kind: Kind) =>\n queue.length === 0 && (kind === \"read\" ? turn._tag !== \"Writing\" : turn._tag === \"Free\");\n\n/**\n * The operations ahead of a waiting ticket: those holding the lane and those asked before it, or\n * all that are queued for a ticket not in the queue.\n */\nexport const ahead = ({ turn, queue }: State, id?: number) => {\n const at = queue.findIndex((ticket) => ticket.id === id);\n\n return holders(turn) + (at === -1 ? queue.length : at);\n};\n\n/**\n * The lane after `input`, and the tickets it lets in. Tickets go in from the head of the queue\n * only: a write once the lane is free, reads while no write holds it, so reads asked before a\n * write go before it, and reads asked after it wait for it.\n */\nexport const step = (\n state: State,\n input: Input,\n): { readonly state: State; readonly admitted: ReadonlyArray<Ticket> } => {\n let { turn, queue, epoch } = state;\n\n if (input._tag === \"Ask\") {\n queue = [...queue, input.ticket];\n if (input.ticket.kind === \"write\") epoch += 1;\n } else {\n const at = queue.findIndex((ticket) => ticket.id === input.ticket.id);\n\n if (at !== -1) queue = queue.toSpliced(at, 1);\n else\n turn =\n turn._tag === \"Reading\" && turn.count > 1\n ? { _tag: \"Reading\", count: turn.count - 1 }\n : { _tag: \"Free\" };\n }\n\n const admitted: Array<Ticket> = [];\n\n for (const ticket of queue) {\n if (ticket.kind === \"write\" ? turn._tag !== \"Free\" : turn._tag === \"Writing\") break;\n admitted.push(ticket);\n turn =\n ticket.kind === \"write\" ? { _tag: \"Writing\" } : { _tag: \"Reading\", count: holders(turn) + 1 };\n }\n\n return { state: { turn, queue: queue.slice(admitted.length), epoch }, admitted };\n};\n\n/** Whether operations on a busy page fail `Busy` at once rather than wait their turn. */\nexport const FailFast = Context.Reference<boolean>(\"effect-browser/internal/page/FailFast\", {\n defaultValue: () => false,\n});\n\n/** The id a caller gives the actions it asks for, which each records as its `correlation`. */\nexport const Correlation = Context.Reference<string | undefined>(\n \"effect-browser/internal/page/Correlation\",\n { defaultValue: () => undefined },\n);\n\n/** A shared read in flight: its epoch, its result once it ends, and how many callers await it. */\ninterface Flight<A> {\n readonly epoch: number;\n readonly result: Deferred.Deferred<A, BrowserError>;\n waiting: number;\n fiber: Fiber.Fiber<A, BrowserError> | undefined;\n}\n\nexport const make = (options: {\n readonly now: () => number;\n readonly actionTimeout: Duration.Duration;\n /** When the page's current document began: a read is shared only within one. */\n readonly documentAt: () => number;\n /** The failure of a read still awaited as the page closes. */\n readonly gone: (operation: string) => BrowserError;\n /** The page's scope, which shared reads run in. */\n readonly scope: Scope.Scope;\n readonly beforeWrite?: ((operation: string) => Effect.Effect<void, BrowserError>) | undefined;\n readonly refusal?: ((operation: string) => Effect.Effect<never, BrowserError>) | undefined;\n}) => {\n const { now, actionTimeout } = options;\n let state = initial;\n let tickets = 0;\n const admissions = new Map<number, Deferred.Deferred<void>>();\n // Each shared read's sweep, which a write runs as it asks.\n const sweeps: Array<() => void> = [];\n\n const apply = (input: Input) => {\n const next = step(state, input);\n\n state = next.state;\n if (input._tag === \"Leave\") admissions.delete(input.ticket.id);\n for (const ticket of next.admitted) {\n const admitted = admissions.get(ticket.id);\n\n admissions.delete(ticket.id);\n if (admitted !== undefined) Deferred.doneUnsafe(admitted, Exit.void);\n }\n if (input._tag === \"Ask\" && input.ticket.kind === \"write\") for (const sweep of sweeps) sweep();\n };\n\n const busy = (operation: string, askedAt: number, id?: number) =>\n undispatched(\n operation,\n new Busy({ waitedMillis: Math.round(now() - askedAt), ahead: ahead(state, id) }),\n );\n\n /**\n * Run `effect` in a turn of `kind`, waiting at most `wait` for it, or failing `Busy`. The turn\n * ends with `effect`, however it ends.\n */\n const turn =\n (kind: Kind, operation: string, wait: Duration.Duration) =>\n <A, E, R>(effect: Effect.Effect<A, E, R>): Effect.Effect<A, E | BrowserError, R> =>\n Effect.uninterruptibleMask((restore) =>\n Effect.gen(function* () {\n const ticket: Ticket = { id: ++tickets, kind };\n const askedAt = now();\n\n if (kind === \"write\" && options.beforeWrite !== undefined)\n yield* options.beforeWrite(operation);\n\n if ((yield* FailFast) && !admitsNow(state, kind)) return yield* busy(operation, askedAt);\n const admitted = Deferred.makeUnsafe<void>();\n\n admissions.set(ticket.id, admitted);\n apply({ _tag: \"Ask\", ticket });\n\n const waiting = Deferred.await(admitted).pipe(\n Effect.timeoutOrElse({\n duration: wait,\n orElse: () =>\n Deferred.isDoneUnsafe(admitted)\n ? Effect.void\n : Effect.fail(busy(operation, askedAt, ticket.id)),\n }),\n );\n\n const given = yield* Effect.exit(\n restore(\n kind === \"write\" && options.beforeWrite !== undefined\n ? Effect.raceFirst(waiting, options.refusal?.(operation) ?? Effect.never)\n : waiting,\n ),\n );\n\n if (Exit.isFailure(given)) {\n apply({ _tag: \"Leave\", ticket });\n\n return yield* Effect.failCause(given.cause);\n }\n\n return yield* restore(effect).pipe(\n Effect.ensuring(Effect.sync(() => apply({ _tag: \"Leave\", ticket }))),\n );\n }),\n );\n\n /**\n * A read whose identical calls share their work: `work` runs once per epoch and document while\n * calls await it, and with `keep` its result serves the next call after all of them gave up,\n * within 250 milliseconds of its end. Pictures, whose callers say how old they may be, only\n * join.\n */\n const shared = <A>(operation: string, keep: boolean) => {\n const flights = new Map<string, Flight<A>>();\n const kept = new Map<string, { readonly value: A; readonly until: number }>();\n\n sweeps.push(() => {\n kept.clear();\n for (const flight of flights.values())\n if (flight.waiting === 0) flight.fiber?.interruptUnsafe();\n });\n\n // A read in flight, its first caller waiting. However its fiber ends, even before it began,\n // as when the page closes, its callers hear.\n const start = (id: string, work: Effect.Effect<A, BrowserError>) =>\n Effect.gen(function* () {\n const flight: Flight<A> = {\n epoch: state.epoch,\n result: Deferred.makeUnsafe(),\n waiting: 1,\n fiber: undefined,\n };\n\n flights.set(id, flight);\n flight.fiber = yield* turn(\n \"read\",\n operation,\n actionTimeout,\n )(work).pipe(\n // The caller chose whether to wait; the work it started serves others too.\n Effect.provideService(FailFast, false),\n Effect.forkIn(options.scope),\n );\n flight.fiber.addObserver((exit) => {\n flights.delete(id);\n if (keep && Exit.isSuccess(exit) && flight.waiting === 0 && flight.epoch === state.epoch)\n kept.set(id, { value: exit.value, until: now() + 250 });\n Deferred.doneUnsafe(\n flight.result,\n Exit.hasInterrupts(exit) ? Effect.fail(options.gone(operation)) : exit,\n );\n });\n\n return flight;\n });\n\n const join = (id: string, work: Effect.Effect<A, BrowserError>) =>\n Effect.acquireUseRelease(\n Effect.suspend(() => {\n const flying = flights.get(id);\n\n if (flying === undefined) return start(id, work);\n flying.waiting += 1;\n\n return Effect.as(Effect.annotateCurrentSpan(\"shared\", \"joined\"), flying);\n }),\n (flight) => Deferred.await(flight.result),\n (flight) =>\n Effect.sync(() => {\n flight.waiting -= 1;\n if (flight.waiting === 0 && flight.epoch < state.epoch) flight.fiber?.interruptUnsafe();\n }),\n );\n\n return (key: string, work: Effect.Effect<A, BrowserError>): Effect.Effect<A, BrowserError> =>\n Effect.gen(function* () {\n const id = `${state.epoch} ${options.documentAt()} ${key}`;\n const at = now();\n\n for (const [old, { until }] of kept) if (until < at) kept.delete(old);\n const hit = kept.get(id);\n\n if (hit !== undefined) {\n kept.delete(id);\n yield* Effect.annotateCurrentSpan(\"shared\", \"kept\");\n\n return hit.value;\n }\n if ((yield* FailFast) && !admitsNow(state, \"read\")) return yield* busy(operation, at);\n\n return yield* join(id, work);\n });\n };\n\n return {\n /** A turn alone, for an action: `wait` bounds the wait for it. */\n write: (operation: string, wait: Duration.Duration) => turn(\"write\", operation, wait),\n /** A turn beside other reads, waited for within the action timeout. */\n read: (operation: string, wait: Duration.Duration = actionTimeout) =>\n turn(\"read\", operation, wait),\n shared,\n };\n};\n\nexport type Lane = ReturnType<typeof make>;\n","/**\n * One browser tab: navigation, snapshots, pictures and input.\n *\n * A page waits only for itself: its operations take turns in one lane of its own. An action, which\n * sends input or navigates, has the page to itself, in the order admitted after policy approval; reads share\n * it, after the action in flight and every action asked before them, so a read describes the page\n * an action left. A wait for a turn ends at the operation's deadline as `Busy`, never `Timeout`,\n * and a full deadline then bounds the operation itself; `failFast` fails it at once instead.\n * Identical reads asked between the same actions share one call to the page, and one whose\n * callers gave up finishes for the next caller to ask it within 250 ms. A policy holds outside the lane while\n * other operations continue; its target is revalidated before dispatch. Element targets are refs\n * from a snapshot; point targets are viewport coordinates in CSS pixels, the same coordinates as a\n * screenshot's pixels. Mouse and keyboard input share a bounded pipeline, so pacing does not wait\n * for each protocol reply. Target lookup happens before the input is sent.\n *\n * @since 0.3.0\n */\nimport { type Clock, type Duration, Effect, Schema, type Scope, type Stream } from \"effect\";\n\nimport {\n Action,\n type ClickOptions as ClickOptionsSchema,\n type TypeOptions as TypeOptionsSchema,\n type PressOptions as PressOptionsSchema,\n type ScrollOptions as ScrollOptionsSchema,\n} from \"./Action.ts\";\nimport { type BrowserError, type PolicyDenied } from \"./BrowserError.ts\";\nimport { Box, type BrowserEvent, PageLoaded, Subject } from \"./BrowserEvent.ts\";\nimport type { Changes } from \"./Change.ts\";\nimport { type CaptureStats, Frame, Image, type ScreencastOptions } from \"./Frame.ts\";\nimport * as Motion from \"./Geometry.ts\";\nimport { FormFieldSchema } from \"./internal/input/evidence.inpage.ts\";\nimport * as Guard from \"./internal/input/guard.inpage.ts\";\nimport { Correlation, FailFast } from \"./internal/page/lane.ts\";\nimport { type Snapshot, type SnapshotOptions } from \"./Snapshot.ts\";\nimport * as Url from \"./Url.ts\";\nimport type { Window } from \"./Window.ts\";\n\nexport type Point = Motion.Point;\n\n/** A ref from a snapshot, such as `\"e12\"`, or a viewport point. */\nexport type Target = string | Point;\n\n/** An integer rectangle in viewport CSS pixels. */\nexport class Region extends Schema.Class<Region>(\"effect-browser/Region\")({\n x: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)),\n y: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)),\n width: Schema.Int.check(Schema.isGreaterThan(0)),\n height: Schema.Int.check(Schema.isGreaterThan(0)),\n}) {}\n\n/** A crop and its viewport origin: add that origin to a point read from the crop. */\nexport class Zoom extends Schema.Class<Zoom>(\"effect-browser/Zoom\")({\n page: Schema.String,\n region: Region,\n image: Image,\n}) {}\n\n/** The target as it read before input. Point coordinates are never snapped to another position. */\nexport class ResolvedTarget extends Schema.Class<ResolvedTarget>(\"effect-browser/ResolvedTarget\")({\n point: Motion.Point,\n ...Subject.fields,\n element: Schema.String,\n /** For a point target, the box of what it found there. */\n box: Schema.optional(Box),\n cursor: Schema.String,\n href: Schema.optional(Schema.String),\n}) {}\n\n/** Action options share the execution codec. */\nexport type ClickOptions = typeof ClickOptionsSchema.Type;\nexport type TypeOptions = typeof TypeOptionsSchema.Type;\nexport type PressOptions = typeof PressOptionsSchema.Type;\nexport type ScrollOptions = typeof ScrollOptionsSchema.Type;\n\n/**\n * How current a picture must be. The newest screencast frame serves when it qualifies, at no cost;\n * otherwise a new screenshot is taken.\n */\nexport interface FrameOptions {\n /**\n * The oldest a reused frame may be, from its paint, at the earliest its timing allows, to now.\n * Defaults to 250 milliseconds; 0 always takes a new screenshot.\n */\n readonly maxAge?: Duration.Input | undefined;\n /**\n * `\"input\"`: reuse only a frame painted after this page's latest input, including input of an\n * interrupted action, and never while an action is changing the page. For a caller that has\n * just acted on the page.\n */\n readonly after?: \"input\" | undefined;\n}\n\n/** A screenshot reuses only a frame painted after the page's latest input, as `after: \"input\"`. */\nexport interface ScreenshotOptions {\n /** The oldest a reused frame may be, as for `frame`. Defaults to 250 milliseconds. */\n readonly maxAge?: Duration.Input | undefined;\n /** A region of the viewport, captured in CSS pixels at the viewport's own scale; always new. */\n readonly clip?: Box | undefined;\n /** JPEG quality, 0 to 100. Defaults to 80. */\n readonly quality?: number | undefined;\n /** `\"jpeg\"`, the default, or `\"png\"`, which is always a new picture. */\n readonly format?: \"jpeg\" | \"png\" | undefined;\n /**\n * `\"css\"`, the default, a picture pixel per CSS pixel; `\"device\"`, the screen's own pixels, as\n * many to a CSS pixel as its device scale factor, which is always a new picture.\n */\n readonly scale?: \"css\" | \"device\" | undefined;\n}\n\n/**\n * What `find` looks for. Every rule given must hold; with none, it finds every element in scope\n * that has a role or is a control.\n */\nexport interface FindQuery {\n /** Narrow matching to this CSS selector. Invalid CSS fails InvalidRequest. */\n readonly selector?: string | undefined;\n /** Require a visible match, optionally enabled. */\n readonly state?: \"visible\" | \"enabled\" | undefined;\n /** An ARIA role, such as `\"button\"` or `\"heading\"`, ignoring case. */\n readonly role?: string | undefined;\n /**\n * The accessible name: a string that reads the same once spaces are collapsed and case folded,\n * or a pattern found in it.\n */\n readonly name?: string | RegExp | undefined;\n /**\n * Text it shows, ignoring case and spacing, or a pattern. Text inside a control or a heading is\n * that control's or heading's, and only the smallest element showing it matches, not every\n * element around it.\n */\n readonly text?: string | RegExp | undefined;\n /** Whole words in its context (row, column, label or heading), ignoring case and spacing. */\n readonly near?: string | undefined;\n /** Only what a point action at this viewport point would reach: the control there, or else what is painted there. */\n readonly at?: Point | undefined;\n /** The viewport (the default), or the whole document. */\n readonly scope?: \"viewport\" | \"document\" | undefined;\n}\n\n/**\n * An element's state as its markup gives it: `checked` for what can be checked, `expanded`,\n * `selected` and `pressed` where the page says either way, and `level` for headings.\n */\nexport const ElementState = Schema.Struct({\n disabled: Schema.Boolean,\n focused: Schema.Boolean,\n checked: Schema.optional(Schema.Boolean),\n expanded: Schema.optional(Schema.Boolean),\n selected: Schema.optional(Schema.Boolean),\n pressed: Schema.optional(Schema.Boolean),\n level: Schema.optional(Schema.Int),\n});\n\nexport type ElementState = typeof ElementState.Type;\n\n/** An element `find` found: a ref for the actions, what it is, where it is and its state. */\nexport class Found extends Schema.Class<Found>(\"effect-browser/Found\")({\n ref: Schema.String,\n subject: Subject,\n /** Its box, rounded. Reading the document, it may be out of view. */\n box: Box,\n inViewport: Schema.Boolean,\n state: ElementState,\n}) {}\n\nexport interface TextOptions {\n /** `\"viewport\"` (the default) reads what the viewport shows; a ref reads that element whole. */\n readonly scope?: string | undefined;\n /** Bound on the text's length, cut at a line. Defaults to 12,000 characters. */\n readonly maxChars?: number | undefined;\n /** Show what fields hold; a secret field still reads `••••`. Defaults to false. */\n readonly unmask?: boolean | undefined;\n}\n\n/** What a page showed as text: a line per block, with table cells apart by tabs. */\nexport class Text extends Schema.Class<Text>(\"effect-browser/Text\")({\n url: Schema.String,\n title: Schema.String,\n text: Schema.String,\n /** True when `text` was cut at `maxChars`. */\n truncated: Schema.Boolean,\n /** Host monotonic milliseconds from the browser's captured Effect Clock. */\n at: Schema.Finite,\n}) {}\n\nexport interface ReadyOptions {\n /** How long recorded content must stay unchanged. Screen stillness is a separate feature. */\n readonly quietMillis?: number | undefined;\n readonly timeout?: Duration.Input | undefined;\n}\n\n/** The window `changes` reads, and whether to show what fields hold. */\nexport interface ChangesOptions {\n /**\n * Where the window starts: the changes a previous read returned, to continue exactly where they\n * ended; a frame, at its paint; or host monotonic milliseconds, which mapped to the page's clock\n * may miss or repeat changes near the start if the browser's clock mapping changed since. Defaults\n * to the start of the record.\n */\n readonly since?: Changes | Frame | number | undefined;\n /**\n * Where it ends: a frame, at its paint, so a delayed frame's window holds nothing it does not\n * show; or host monotonic milliseconds. Defaults to now, and is never later.\n */\n readonly until?: Frame | number | undefined;\n /** Show what fields hold; a secret field still reads `••••`. Defaults to false. */\n readonly unmask?: boolean | undefined;\n}\n\n/** The window `window` reads, and whether to show what fields hold. */\nexport interface WindowOptions {\n /**\n * Where the window starts: a previous window, to continue exactly where it ended; a frame, at its\n * paint; host monotonic milliseconds; or a `Duration` back from `until`. A start after `until`\n * leaves the window empty there.\n */\n readonly since: Window | Frame | Duration.Duration | number;\n /**\n * Where it ends: a frame, at its paint, such as one a delayed consumer airs now; or host\n * monotonic milliseconds. Defaults to now, and is never later.\n */\n readonly until?: Frame | number | undefined;\n /** Show what fields hold in its changes; a secret field still reads `••••`. Defaults to false. */\n readonly unmask?: boolean | undefined;\n}\n\n/**\n * What the library knows of a page now, without asking it, each part with when it learned it, in\n * host monotonic milliseconds: a part's age is `at` less its time. Text read before the current\n * document began is left out, since it tells of a document that has gone.\n */\nexport class State extends Schema.Class<State>(\"effect-browser/PageState\")({\n page: Schema.String,\n /** The tracking connection that owns this document counter. */\n connection: Schema.String,\n /** When this was taken. */\n at: Schema.Finite,\n /** Where the main frame last committed or moved, without userinfo or known secret parameters. */\n url: Schema.String,\n /** The page's document, as `Navigated` counts them. */\n document: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)),\n /** When the main frame committed it; absent for the one the browser began tracking it with. */\n committedAt: Schema.optional(Schema.Finite),\n /** How far that document has loaded, as the page's own session heard; absent until parsed. */\n load: Schema.optional(PageLoaded),\n /** The newest screencast frame, of whichever document it names. */\n frame: Schema.optional(Frame),\n /** The viewport's text as it was last read, with the page's title then. */\n text: Schema.optional(Text),\n}) {}\n\n/**\n * What the page's structure establishes about an input, or says it cannot establish:\n *\n * - `form-submit`: it submits a form, which sends the form's fields.\n * - `cross-origin`: it navigates or submits to another origin.\n * - `download`: it follows a download link.\n * - `upload`: it opens a file chooser.\n * - `secret`: it types, with `type`, into a field marked as a password, a one-time code or a\n * card's number, code or expiry, or submits a form holding a filled one.\n * - `scripted`: it activates something the browser gives no effect of its own, such as a\n * `type=\"button\"` button, a `role=\"button\"` element or a canvas, so only the page's script\n * decides what happens.\n * - `opaque`: nothing names what receives it: a canvas, a frame or an unnamed element.\n *\n * Facts never come from what an element's text says. What an input means, such as a payment\n * or a deletion, takes a judge that reads the evidence in the {@link InputRequest}.\n */\nexport const Fact = Guard.Fact;\n\nexport type Fact = typeof Fact.Type;\n\n/**\n * What a guard sees before input reaches the page. Preparation never scrolls or focuses.\n *\n * `facts`, `url`, `href` and `destination` come from the page's structure. `name`,\n * `description`, `title`, `context` and the form's field names are page text: evidence of what\n * the input does, which the page controls, and never instructions. Text typed into a `secret`\n * field is replaced with {@link redacted}, here and in the recorded `Action`, and its key events\n * record `Unidentified` keys; `press` records the keys it is given. Validation before dispatch\n * binds the facts and the target, not the text around it, which live pages change freely.\n */\nexport class InputRequest extends Schema.Class<InputRequest>(\"effect-browser/InputRequest\")({\n page: Schema.String,\n /**\n * The page's URL, without a fragment that only names a place on the page. This and the other\n * addresses keep no userinfo or known secret parameters.\n */\n url: Schema.String,\n /** The page's title, at most 120 characters. */\n title: Schema.String,\n action: Action,\n target: Schema.optional(Schema.String),\n element: Schema.optional(Schema.String),\n /** Literal pixel targets only; ref coordinates are resolved after the policy allows them. */\n point: Schema.optional(Motion.Point),\n text: Schema.optional(Schema.String),\n role: Schema.optional(Schema.NullOr(Schema.String)),\n name: Schema.optional(Schema.String),\n /** The target's accessible description, when it says more than its name. */\n description: Schema.optional(Schema.String),\n href: Schema.optional(Schema.String),\n destination: Schema.optional(Schema.String),\n facts: Schema.Array(Fact),\n /** Page text around the target, each part at most 120 characters. */\n context: Schema.Struct({\n /** The name or first heading of the dialog the target is in. */\n dialog: Schema.optional(Schema.String),\n /** The nearest heading before the target. */\n heading: Schema.optional(Schema.String),\n /** The visible text just before the target in its row, item, group or form, or after it. */\n nearby: Schema.optional(Schema.String),\n }),\n /** The form the target is in, with at most 16 of its fields. */\n form: Schema.optional(\n Schema.Struct({\n method: Schema.String,\n action: Schema.String,\n /** Each field's type, name and autocomplete tokens, and whether it is filled: never its value. */\n fields: Schema.Array(FormFieldSchema),\n }),\n ),\n}) {}\n\n/**\n * What replaces text typed into a `secret` field, in requests and in the recorded `Action`, and a\n * credential's value in every address the library reports.\n */\nexport const redacted = Url.withheld;\n\n/**\n * Run page operations without waiting their turn: on a page busy with other operations, each fails\n * `Busy` at once, and `Browser.newPage` on a browser with `maxPages` open fails `Limit` at once.\n */\nexport const failFast = <A, E, R>(effect: Effect.Effect<A, E, R>): Effect.Effect<A, E, R> =>\n Effect.provideService(effect, FailFast, true);\n\n/**\n * Give every action `effect` performs a caller's id, such as a model's tool call id, which its\n * recorded `Action` carries as `correlation`.\n */\nexport const correlate =\n (id: string) =>\n <A, E, R>(effect: Effect.Effect<A, E, R>): Effect.Effect<A, E, R> =>\n Effect.provideService(effect, Correlation, id);\n\n/** Succeed to allow, fail to deny, or await an external signal to hold the input. */\nexport type InputGuard = (request: InputRequest) => Effect.Effect<void, PolicyDenied>;\n\n/** What a wait requires of the query's matches. */\nexport type UntilWant = \"some\" | \"none\" | { readonly other: string };\n\nexport interface UntilResult {\n readonly met: boolean;\n readonly mark: string;\n}\n\n/** Scoped access to one page's shared capture and its current-document evidence. */\nexport interface Capture {\n readonly stream: Stream.Stream<Frame, BrowserError>;\n readonly current: Frame | undefined;\n readonly isCurrent: (frame: Frame) => boolean;\n readonly confirm: (frame: Frame) => Effect.Effect<boolean, BrowserError>;\n readonly sync: Effect.Effect<void, BrowserError>;\n readonly stats: (options?: {\n readonly window?: Duration.Input | undefined;\n }) => Effect.Effect<CaptureStats, BrowserError>;\n}\n\n/** Script values cross the page boundary through the caller's Schema. A bundler may rewrite functions. */\nexport interface ScriptOptions<A, Arg> {\n readonly arg: Arg;\n readonly result: Schema.Codec<A, unknown>;\n}\n\nexport interface ActOptions<A, Arg> extends ScriptOptions<A, Arg> {\n readonly document: number;\n /** Supplying the read's connection also refuses a document counter from another connection. */\n readonly connection?: string | undefined;\n}\n\nexport interface Page {\n /** Decode and perform a data action through the same policy and lane as the named methods. */\n readonly perform: (action: Action) => Effect.Effect<ResolvedTarget | string | void, BrowserError>;\n /** Read declared side-effect-free code in the main world, retrying one replaced document. */\n readonly read: <A, Arg>(\n script: (arg: Arg) => unknown,\n options: ScriptOptions<A, Arg>,\n ) => Effect.Effect<\n { readonly value: A; readonly document: number; readonly connection: string },\n BrowserError\n >;\n /**\n * Run code as a guarded, recorded action bound to the caller's document.\n * A timeout or cancellation cannot stop JavaScript already running: later input waits for its\n * actual reply. Close the page and open a replacement if the script never settles.\n */\n readonly act: <A, Arg>(\n script: (arg: Arg) => unknown,\n options: ActOptions<A, Arg>,\n ) => Effect.Effect<A, BrowserError>;\n /** Owning browser clock: deadlines and all frame/event timestamps use this clock. */\n readonly clock: Clock.Clock;\n /** Wait for admitted input and retain a bounded read turn through effect. */\n readonly afterInput: <A, E, R>(\n effect: Effect.Effect<A, E, R>,\n ) => Effect.Effect<A, E | BrowserError, R>;\n /** A scoped lease starts capture immediately, independently of its first frame. */\n readonly capture: (\n options?: ScreencastOptions,\n ) => Effect.Effect<Capture, BrowserError, Scope.Scope>;\n /** One page-side wait; replaced documents share one deadline. Unmet is met:false; an empty mark means no stable document could be sampled. */\n readonly until: (\n query: FindQuery,\n want: UntilWant,\n millis: number,\n ) => Effect.Effect<UntilResult, BrowserError>;\n /** The page's CDP target id: the same page has it again after a reconnect to its browser. */\n readonly id: string;\n /** The page's address, without its userinfo or known secret parameters. */\n readonly url: Effect.Effect<string>;\n /**\n * The document's title as the page last set it, empty for an untitled page. The browser answers\n * it, in one call, so a page busy with a script cannot hold it up.\n */\n readonly title: Effect.Effect<string, BrowserError>;\n\n readonly goto: (url: string) => Effect.Effect<void, BrowserError>;\n /** The previous history entry, including one only a frame created; `NotFound` when none. */\n readonly back: Effect.Effect<void, BrowserError>;\n readonly reload: Effect.Effect<void, BrowserError>;\n /** Make this the visible tab. Background tabs paint rarely and send few screencast frames. */\n readonly bringToFront: Effect.Effect<void, BrowserError>;\n /** Close the tab, succeeding once it has closed, or at once when it already had. */\n readonly close: Effect.Effect<void, BrowserError>;\n\n readonly snapshot: (options?: SnapshotOptions) => Effect.Effect<Snapshot, BrowserError>;\n /**\n * A picture of the viewport, in CSS pixels: a screencast frame painted since the page's latest\n * input, if one qualifies, or a new one. A caller that has just acted sees what its action did.\n */\n readonly screenshot: (options?: ScreenshotOptions) => Effect.Effect<Image, BrowserError>;\n /**\n * The viewport with its timing: the newest screencast frame if it qualifies, else a new\n * screenshot timed by the host interval in which it was taken.\n */\n readonly frame: (options?: FrameOptions) => Effect.Effect<Frame, BrowserError>;\n /**\n * A crop in CSS pixels, unmagnified, with the origin that keeps later input in viewport pixels.\n * With `scale: \"device\"` its picture has the screen's own pixels, as a screenshot's would.\n */\n readonly zoom: (\n region: Region,\n options?: Pick<ScreenshotOptions, \"scale\">,\n ) => Effect.Effect<Zoom, BrowserError>;\n /**\n * The viewport's size in CSS pixels, the space of points, crops and page scrolls. Over CDP the\n * page reports it, within the action timeout.\n */\n readonly viewport: Effect.Effect<\n { readonly width: number; readonly height: number },\n BrowserError\n >;\n /**\n * The elements that match a query, in tree order, with refs the actions take, in one call to the\n * page. All that match are returned, so a caller tells them apart by their context; none is an\n * empty result, not a failure.\n */\n readonly find: (query?: FindQuery) => Effect.Effect<ReadonlyArray<Found>, BrowserError>;\n /**\n * The text the viewport shows, or one element whole, in one call to the page. Field values read\n * `••••` unless `unmask`, and a secret field's always do, as does one that was secret when the\n * library saw it.\n */\n readonly text: (options?: TextOptions) => Effect.Effect<Text, BrowserError>;\n /**\n * What visibly changed over a window, in one call to the page. The first read starts the page's\n * record, so it finds none; from then the page records, and from the start of each later\n * document, until nobody has read it for two minutes. See `Change`.\n */\n readonly changes: (options?: ChangesOptions) => Effect.Effect<Changes, BrowserError>;\n /**\n * The page's events, changes and frames over a window: the frames and events it keeps, at no\n * call, and its changes, in one call, the first starting its record as `changes` does. A part\n * that cannot be read is missing, with why; the window fails only for bounds that are not finite.\n */\n readonly window: (options: WindowOptions) => Effect.Effect<Window, BrowserError>;\n /**\n * What the library knows of the page now, at no call and with no wait for its turn: where it is,\n * its document and how far it has loaded, its newest frame, and its text and title as last read.\n */\n readonly state: Effect.Effect<State>;\n\n readonly click: (\n target: Target,\n options?: ClickOptions,\n ) => Effect.Effect<ResolvedTarget, BrowserError>;\n readonly hover: (target: Target) => Effect.Effect<void, BrowserError>;\n readonly drag: (from: Target, to: Target) => Effect.Effect<void, BrowserError>;\n /** Type into a text field, or to whatever has focus unless a typed key could activate it. */\n readonly type: (text: string, options?: TypeOptions) => Effect.Effect<void, BrowserError>;\n /** Keys such as `\"Enter\"`, `\"Space\"`, `\"ArrowLeft\"` or `\"Control+A\"`. */\n readonly press: (keys: string, options?: PressOptions) => Effect.Effect<void, BrowserError>;\n readonly scroll: (options?: ScrollOptions) => Effect.Effect<void, BrowserError>;\n /**\n * Choose options of a `<select>` by value or label; returns the chosen labels. A refusal, such\n * as no matching option, is undispatched.\n */\n readonly select: (\n ref: string,\n values: ReadonlyArray<string>,\n ) => Effect.Effect<string, BrowserError>;\n\n /**\n * Wait for document evidence, polling every 50 ms: parsed, painted, visible, fonts and visible\n * images loaded, and finite animations finished. Optional quietMillis requires recorded content\n * to stay unchanged. Screen or foreground stillness belongs to the Stillness feature.\n * Fails Timeout after timeout, 15 seconds by default.\n */\n readonly ready: (options?: ReadyOptions) => Effect.Effect<void, BrowserError>;\n\n /**\n * Screencast frames for as long as the stream runs. Concurrent streams share one screencast and\n * its settings; explicit options that differ from a running screencast's fail with InvalidRequest.\n */\n readonly screencast: (options?: ScreencastOptions) => Stream.Stream<Frame, BrowserError>;\n /**\n * What this page's captures received, delivered and dropped, over its life or the latest\n * `window`, which reaches back at most a minute; a longer one is an `InvalidRequest`.\n */\n readonly captureStats: (options?: {\n readonly window?: Duration.Input | undefined;\n }) => Effect.Effect<CaptureStats, BrowserError>;\n /** Screencast frames painted within `frameHistory` of the newest, oldest first. */\n readonly recentFrames: Effect.Effect<ReadonlyArray<Frame>>;\n /** This page's events among the browser's latest `eventHistory`, oldest first. */\n readonly recentEvents: Effect.Effect<ReadonlyArray<BrowserEvent>>;\n}\n"],"mappings":";;;;;;;;;;;;;AAcA,MAAa,YAAY,OAAc,YAA2B;CAChE,MAAM,EAAE,OAAO,YAAY,SAAS,UAAU,YAAY,QAAQ,UAAU,QAAQ,WAClF;CAEF,MAAM,EAAE,QAAQ,eAAe,YAAY,WAAW;;CAGtD,MAAM,WAAW,aACb,QAAQ,OAAO,KAAK,CAAC;EAAC;EAAU;EAAU;EAAS;C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MAAM;CACnC,MAAM,OAAO,SAAS,OAAO,OAAO,OAAO,MAAM,CAAC;CAClD,MAAM,OAAO,SAAS,OAAO,MAAM;;CAEnC,aAAa,OAAO,SAAS,OAAO,MAAM;CAC1C,MAAM,OAAO,SAAS,OAAO,MAAM;CACnC,aAAa,OAAO,SAAS,OAAO,MAAM;CAC1C,OAAO,OAAO,MAAM,IAAI;;CAExB,SAAS,OAAO,OAAO;;EAErB,QAAQ,OAAO,SAAS,OAAO,MAAM;;EAErC,SAAS,OAAO,SAAS,OAAO,MAAM;;EAEtC,QAAQ,OAAO,SAAS,OAAO,MAAM;CACvC,CAAC;;CAED,MAAM,OAAO,SACX,OAAO,OAAO;EACZ,QAAQ,OAAO;EACf,QAAQ,OAAO;;EAEf,QAAQ,OAAO,MAAM,eAAe;CACtC,CAAC,CACH;AACF,CAAC,CAAC,CAAC,CAAC;;;;;AAMJ,MAAa,WAAWE;;;;;AAMxB,MAAa,YAAqB,WAChC,OAAO,eAAe,QAAQ,UAAU,IAAI;;;;;AAM9C,MAAa,aACV,QACS,WACR,OAAO,eAAe,QAAQ,aAAa,EAAE"}
@@ -1,109 +1,14 @@
1
- import { p as PolicyDenied, t as BrowserError } from "./BrowserError-Coy7EW1N.mjs";
2
- import { E as WheelScrolled, S as TextInserted, T as TrackPlanned, _ as PointerReleased, b as Subject, d as Navigated, f as PageClosed, g as PointerPressed, h as PageUntracked, i as BrowserEvent, l as Disconnected, m as PageOpened, o as CursorChanged, p as PageLoaded, r as Box, s as DialogShown, t as Action, u as KeyChanged, w as TrackPerformed, y as SessionEnding } from "./BrowserEvent-dq6FRT8w.mjs";
3
- import { r as Changes, t as Change } from "./Change-DqING3tr.mjs";
4
- import { a as Image, n as CaptureStats, o as ScreencastOptions, r as Frame } from "./Frame-DkNdjjjr.mjs";
5
- import { n as Snapshot, r as SnapshotOptions } from "./Snapshot-B34hZ4Jl.mjs";
6
- import { r as Point$1, t as Motion_d_exports } from "./Motion-DND6I-64.mjs";
7
- import { Duration, Effect, Schema, Stream } from "effect";
8
- import { Prompt } from "effect/ai";
9
- import { Page } from "playwright-core";
10
- declare namespace Moment_d_exports {
11
- export { Account, CaptureOptions, Moment, Window, account, capture, toPrompt };
12
- }
13
- declare const Window_base: Schema.Class<Window, Schema.Struct<{
14
- readonly page: Schema.String;
15
- /** Where the window starts, in host monotonic milliseconds on the owning browser’s clock. */
16
- readonly since: Schema.Finite;
17
- /** Where it ends, never after it was taken. */
18
- readonly until: Schema.Finite;
19
- /** The page's events after `since`, up to `until`, oldest first, without the input presentation track. */
20
- readonly events: Schema.$Array<Schema.Union<readonly [typeof PageOpened, typeof PageClosed, typeof PageUntracked, typeof Navigated, typeof PageLoaded, typeof Action, typeof TrackPlanned, typeof TrackPerformed, typeof PointerPressed, typeof PointerReleased, typeof WheelScrolled, typeof KeyChanged, typeof TextInserted, typeof CursorChanged, typeof DialogShown, typeof Disconnected, typeof SessionEnding]>>;
21
- /**
22
- * What visibly changed after `since`, up to `until`; absent where `missing` says why. A page's
23
- * first window starts its record, so the record sees none of it.
24
- */
25
- readonly changes: Schema.optional<typeof Changes>;
26
- /** Screencast frames painted from `since` to `until`, oldest first, as far back as kept. */
27
- readonly frames: Schema.$Array<typeof Frame>;
28
- /**
29
- * Why each part that could not be read is missing: the read of its changes, by whatever
30
- * operation failed there, or a moment's picture (`frame`) or outline (`snapshot`).
31
- */
32
- readonly missing: Schema.$Array<typeof BrowserError>;
33
- }>, {}>;
34
- /** A page's events, changes and frames over one window of its browser's host clock. */
35
- declare class Window extends Window_base {}
36
- declare const Moment_base: Schema.Class<Moment, Schema.Struct<{
37
- readonly page: Schema.String;
38
- readonly since: Schema.Finite;
39
- readonly until: Schema.Finite;
40
- readonly events: Schema.$Array<Schema.Union<readonly [typeof PageOpened, typeof PageClosed, typeof PageUntracked, typeof Navigated, typeof PageLoaded, typeof Action, typeof TrackPlanned, typeof TrackPerformed, typeof PointerPressed, typeof PointerReleased, typeof WheelScrolled, typeof KeyChanged, typeof TextInserted, typeof CursorChanged, typeof DialogShown, typeof Disconnected, typeof SessionEnding]>>;
41
- readonly changes: Schema.optional<typeof Changes>;
42
- readonly frames: Schema.$Array<typeof Frame>;
43
- readonly missing: Schema.$Array<typeof BrowserError>;
44
- snapshot: Schema.optional<typeof Snapshot>;
45
- }>, Window> & Pick<{}, never>;
46
- /**
47
- * A window that ends at a picture of the page, its last frame, unless `missing` says why it has
48
- * none. Its frames are a few, spread over the window, so that it still begins where it starts.
49
- */
50
- declare class Moment extends Moment_base {}
51
- interface CaptureOptions {
52
- /**
53
- * Where the window starts, as for `Page.window`: a previous window or moment, so that consecutive
54
- * ones neither repeat nor miss an event or a change, or a `Duration` back from the picture.
55
- * Defaults to 5 seconds.
56
- */
57
- readonly since?: WindowOptions["since"] | undefined;
58
- /** Frames to keep, at least 1, spread over the window and ending with the picture. Defaults to 2. */
59
- readonly frames?: number | undefined;
60
- /**
61
- * Whether to take the page's outline at the end, or its options; `true` means 4,000 characters.
62
- * Defaults to `false`: the frames and the timeline carry most moments, while an outline costs a
63
- * round trip to the page and can double a moment's tokens.
64
- */
65
- readonly snapshot?: SnapshotOptions | boolean | undefined;
66
- /** Show what fields hold in the moment's changes; a secret field still reads `••••`. */
67
- readonly unmask?: boolean | undefined;
68
- }
69
- declare const capture: (page: Page$1, options?: CaptureOptions | undefined) => Effect.Effect<Moment, BrowserError, never>;
70
- /** What a window says of its page at its end: what was still in flux, and what had settled. */
71
- interface Account {
72
- /**
73
- * How long, in milliseconds, the page had been still at the end: since the last change in view
74
- * its record shows, or the last paint its screencast frames show, or else since the window, or
75
- * its record, began. Undefined where neither could tell, with no record of the window and no
76
- * painted frame: a screenshot shows the page, not when it last changed. Frames show paint only
77
- * while a capture runs, and the record does not see a canvas, so a canvas that keeps drawing
78
- * with no capture running reads as still.
79
- */
80
- readonly stillFor: number | undefined;
81
- /**
82
- * The changes still under way at the end: what kept changing, more than once in the window or
83
- * already before it, and changed again within twice its own pace before the end.
84
- */
85
- readonly changing: ReadonlyArray<Change>;
86
- /** Every other change, which shows what it settled at. */
87
- readonly settled: ReadonlyArray<Change>;
88
- }
89
- /**
90
- * An account of the window's page at its end: how long it had been still, and which of its
91
- * changes were still under way and which had settled. A window whose record saw none of it has
92
- * neither.
93
- */
94
- declare const account: (window: Window) => Account;
95
- /**
96
- * The moment as one user message: the page's outline when the moment has one, what changed, most
97
- * notable first, what kept changing told as still changing at the moment or settled since when, by
98
- * its account, with the actions that the changes followed, that changes followed though none
99
- * names them, or that drew what only the screenshots show, what could not be read and why, and its
100
- * frames captioned with their times, the last one "the moment" where it is the picture at its end.
101
- * Give a model its task with `Prompt.setSystem`, and add what the caller knows about the page as
102
- * more text.
103
- */
104
- declare const toPrompt: (moment: Moment) => Prompt.Prompt;
1
+ import { a as PressOptions$1, o as ScrollOptions$1, r as ClickOptions$1, s as TypeOptions$1, t as Action } from "./Action-24sLOubi.mjs";
2
+ import { p as PolicyDenied, t as BrowserError } from "./BrowserError-BlcmLVzn.mjs";
3
+ import { b as Subject, f as PageLoaded, n as Box, r as BrowserEvent } from "./BrowserEvent-lLqJ3GJS.mjs";
4
+ import { r as Changes } from "./Change-Ba7INmay.mjs";
5
+ import { a as Image, n as CaptureStats, o as ScreencastOptions, r as Frame } from "./Frame-UEH2hO5T.mjs";
6
+ import { i as Point$1, t as Geometry_d_exports } from "./Geometry-DJx9qrYy.mjs";
7
+ import { n as Snapshot, r as SnapshotOptions } from "./Snapshot-CtBVOtuu.mjs";
8
+ import { t as Window } from "./Window-CMddGMt1.mjs";
9
+ import { Clock, Duration, Effect, Schema, Scope, Stream } from "effect";
105
10
  declare namespace Page_d_exports {
106
- export { ChangesOptions, ClickOptions, ElementState, Fact, FindQuery, Found, FrameOptions, InputGuard, InputRequest, Page$1 as Page, Point, PressOptions, ReadyOptions, Region, ResolvedTarget, ScreenshotOptions, ScrollOptions, State, Target, Text, TextOptions, TypeOptions, WaitCondition, WindowOptions, Zoom, correlate, failFast, redacted };
11
+ export { ActOptions, Capture, ChangesOptions, ClickOptions, ElementState, Fact, FindQuery, Found, FrameOptions, InputGuard, InputRequest, Page, Point, PressOptions, ReadyOptions, Region, ResolvedTarget, ScreenshotOptions, ScriptOptions, ScrollOptions, State, Target, Text, TextOptions, TypeOptions, UntilResult, UntilWant, WindowOptions, Zoom, correlate, failFast, redacted };
107
12
  }
108
13
  type Point = Point$1;
109
14
  /** A ref from a snapshot, such as `"e12"`, or a viewport point. */
@@ -150,43 +55,11 @@ declare const ResolvedTarget_base: Schema.Class<ResolvedTarget, Schema.Struct<{
150
55
  }>, {}>;
151
56
  /** The target as it read before input. Point coordinates are never snapped to another position. */
152
57
  declare class ResolvedTarget extends ResolvedTarget_base {}
153
- interface ClickOptions {
154
- readonly button?: "left" | "right" | "middle" | undefined;
155
- /** 2 for a double click. */
156
- readonly clickCount?: number | undefined;
157
- /** Hold the button down this long before releasing it. */
158
- readonly holdMillis?: number | undefined;
159
- }
160
- interface TypeOptions {
161
- /** Type into this text field: it is focused first, and its content replaced unless `replace` is false. */
162
- readonly into?: string | undefined;
163
- readonly replace?: boolean | undefined;
164
- /** Press Enter afterwards. */
165
- readonly submit?: boolean | undefined;
166
- /**
167
- * The text is a secret: type it only into a field the page marks secret, such as a password,
168
- * and otherwise refuse with `NotActionable` before any input. A replayed password asks this.
169
- */
170
- readonly secret?: boolean | undefined;
171
- }
172
- interface PressOptions {
173
- /**
174
- * Focus this element, by ref, before the first press: a link, a button or a field. The keys go to
175
- * whatever has focus otherwise.
176
- */
177
- readonly on?: string | undefined;
178
- /** Press the keys this many times. */
179
- readonly times?: number | undefined;
180
- /** Hold the keys down this long before releasing them, as a game control might need. */
181
- readonly holdMillis?: number | undefined;
182
- }
183
- interface ScrollOptions {
184
- readonly dx?: number | undefined;
185
- /** Pixels to scroll down; negative scrolls up. Defaults to most of a viewport. */
186
- readonly dy?: number | undefined;
187
- /** Scroll whatever is under this point or element. Defaults to the middle of the viewport. */
188
- readonly at?: Target | undefined;
189
- }
58
+ /** Action options share the execution codec. */
59
+ type ClickOptions = typeof ClickOptions$1.Type;
60
+ type TypeOptions = typeof TypeOptions$1.Type;
61
+ type PressOptions = typeof PressOptions$1.Type;
62
+ type ScrollOptions = typeof ScrollOptions$1.Type;
190
63
  /**
191
64
  * How current a picture must be. The newest screencast frame serves when it qualifies, at no cost;
192
65
  * otherwise a new screenshot is taken.
@@ -214,12 +87,21 @@ interface ScreenshotOptions {
214
87
  readonly quality?: number | undefined;
215
88
  /** `"jpeg"`, the default, or `"png"`, which is always a new picture. */
216
89
  readonly format?: "jpeg" | "png" | undefined;
90
+ /**
91
+ * `"css"`, the default, a picture pixel per CSS pixel; `"device"`, the screen's own pixels, as
92
+ * many to a CSS pixel as its device scale factor, which is always a new picture.
93
+ */
94
+ readonly scale?: "css" | "device" | undefined;
217
95
  }
218
96
  /**
219
97
  * What `find` looks for. Every rule given must hold; with none, it finds every element in scope
220
98
  * that has a role or is a control.
221
99
  */
222
100
  interface FindQuery {
101
+ /** Narrow matching to this CSS selector. Invalid CSS fails InvalidRequest. */
102
+ readonly selector?: string | undefined;
103
+ /** Require a visible match, optionally enabled. */
104
+ readonly state?: "visible" | "enabled" | undefined;
223
105
  /** An ARIA role, such as `"button"` or `"heading"`, ignoring case. */
224
106
  readonly role?: string | undefined;
225
107
  /**
@@ -296,25 +178,8 @@ declare const Text_base: Schema.Class<Text, Schema.Struct<{
296
178
  }>, {}>;
297
179
  /** What a page showed as text: a line per block, with table cells apart by tabs. */
298
180
  declare class Text extends Text_base {}
299
- /** What `waitFor` waits for. */
300
- interface WaitCondition {
301
- /** A CSS selector for what to watch; the document's body without one. */
302
- readonly selector?: string | undefined;
303
- /**
304
- * `"visible"` (the default): something it matches shows; `"hidden"`: nothing it matches shows;
305
- * `"enabled"`: something it matches shows and is not disabled.
306
- */
307
- readonly state?: "visible" | "hidden" | "enabled" | undefined;
308
- /** Only what shows this text counts, case and all, with runs of spaces read as one. */
309
- readonly text?: string | undefined;
310
- }
311
181
  interface ReadyOptions {
312
- /**
313
- * What must stay still during quietMillis: screen paint (default); recorded content; or the
314
- * `"foreground"`, the screen but for what was already moving before the page's latest input.
315
- */
316
- readonly still?: "screen" | "content" | "foreground" | undefined;
317
- /** How long the selected evidence must stay still; screen paint by default. */
182
+ /** How long recorded content must stay unchanged. Screen stillness is a separate feature. */
318
183
  readonly quietMillis?: number | undefined;
319
184
  readonly timeout?: Duration.Input | undefined;
320
185
  }
@@ -353,6 +218,8 @@ interface WindowOptions {
353
218
  }
354
219
  declare const State_base: Schema.Class<State, Schema.Struct<{
355
220
  readonly page: Schema.String;
221
+ /** The tracking connection that owns this document counter. */
222
+ readonly connection: Schema.String;
356
223
  /** When this was taken. */
357
224
  readonly at: Schema.Finite;
358
225
  /** Where the main frame last committed or moved, without userinfo or known secret parameters. */
@@ -402,7 +269,74 @@ declare const InputRequest_base: Schema.Class<InputRequest, Schema.Struct<{
402
269
  readonly url: Schema.String;
403
270
  /** The page's title, at most 120 characters. */
404
271
  readonly title: Schema.String;
405
- readonly action: Schema.String;
272
+ readonly action: Schema.TaggedUnion<{
273
+ readonly Act: Schema.TaggedStruct<"Act", {
274
+ readonly document: Schema.Int;
275
+ }>;
276
+ readonly Back: Schema.TaggedStruct<"Back", {}>;
277
+ readonly Click: Schema.TaggedStruct<"Click", {
278
+ readonly target: Schema.Union<readonly [Schema.String, Schema.Struct<{
279
+ readonly x: Schema.Finite;
280
+ readonly y: Schema.Finite;
281
+ }>]>;
282
+ readonly options: Schema.optional<Schema.Struct<{
283
+ readonly button: Schema.optional<Schema.Literals<readonly ["left", "right", "middle"]>>;
284
+ readonly clickCount: Schema.optional<Schema.Finite>;
285
+ readonly holdMillis: Schema.optional<Schema.Finite>;
286
+ }>>;
287
+ }>;
288
+ readonly Drag: Schema.TaggedStruct<"Drag", {
289
+ readonly from: Schema.Union<readonly [Schema.String, Schema.Struct<{
290
+ readonly x: Schema.Finite;
291
+ readonly y: Schema.Finite;
292
+ }>]>;
293
+ readonly to: Schema.Union<readonly [Schema.String, Schema.Struct<{
294
+ readonly x: Schema.Finite;
295
+ readonly y: Schema.Finite;
296
+ }>]>;
297
+ }>;
298
+ readonly Goto: Schema.TaggedStruct<"Goto", {
299
+ readonly url: Schema.String;
300
+ }>;
301
+ readonly Hover: Schema.TaggedStruct<"Hover", {
302
+ readonly target: Schema.Union<readonly [Schema.String, Schema.Struct<{
303
+ readonly x: Schema.Finite;
304
+ readonly y: Schema.Finite;
305
+ }>]>;
306
+ }>;
307
+ readonly Press: Schema.TaggedStruct<"Press", {
308
+ readonly keys: Schema.String;
309
+ readonly options: Schema.optional<Schema.Struct<{
310
+ readonly on: Schema.optional<Schema.String>;
311
+ readonly times: Schema.optional<Schema.Finite>;
312
+ readonly holdMillis: Schema.optional<Schema.Finite>;
313
+ }>>;
314
+ }>;
315
+ readonly Reload: Schema.TaggedStruct<"Reload", {}>;
316
+ readonly Scroll: Schema.TaggedStruct<"Scroll", {
317
+ readonly options: Schema.optional<Schema.Struct<{
318
+ readonly at: Schema.optional<Schema.Union<readonly [Schema.String, Schema.Struct<{
319
+ readonly x: Schema.Finite;
320
+ readonly y: Schema.Finite;
321
+ }>]>>;
322
+ readonly dx: Schema.optional<Schema.Finite>;
323
+ readonly dy: Schema.optional<Schema.Finite>;
324
+ }>>;
325
+ }>;
326
+ readonly Select: Schema.TaggedStruct<"Select", {
327
+ readonly ref: Schema.String;
328
+ readonly values: Schema.$Array<Schema.String>;
329
+ }>;
330
+ readonly Type: Schema.TaggedStruct<"Type", {
331
+ readonly text: Schema.String;
332
+ readonly options: Schema.optional<Schema.Struct<{
333
+ readonly into: Schema.optional<Schema.String>;
334
+ readonly replace: Schema.optional<Schema.Boolean>;
335
+ readonly submit: Schema.optional<Schema.Boolean>;
336
+ readonly secret: Schema.optional<Schema.Boolean>;
337
+ }>>;
338
+ }>;
339
+ }>;
406
340
  readonly target: Schema.optional<Schema.String>;
407
341
  readonly element: Schema.optional<Schema.String>;
408
342
  /** Literal pixel targets only; ref coordinates are resolved after the policy allows them. */
@@ -468,11 +402,60 @@ declare const failFast: <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effe
468
402
  declare const correlate: (id: string) => <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>;
469
403
  /** Succeed to allow, fail to deny, or await an external signal to hold the input. */
470
404
  type InputGuard = (request: InputRequest) => Effect.Effect<void, PolicyDenied>;
471
- interface Page$1 {
405
+ /** What a wait requires of the query's matches. */
406
+ type UntilWant = "some" | "none" | {
407
+ readonly other: string;
408
+ };
409
+ interface UntilResult {
410
+ readonly met: boolean;
411
+ readonly mark: string;
412
+ }
413
+ /** Scoped access to one page's shared capture and its current-document evidence. */
414
+ interface Capture {
415
+ readonly stream: Stream.Stream<Frame, BrowserError>;
416
+ readonly current: Frame | undefined;
417
+ readonly isCurrent: (frame: Frame) => boolean;
418
+ readonly confirm: (frame: Frame) => Effect.Effect<boolean, BrowserError>;
419
+ readonly sync: Effect.Effect<void, BrowserError>;
420
+ readonly stats: (options?: {
421
+ readonly window?: Duration.Input | undefined;
422
+ }) => Effect.Effect<CaptureStats, BrowserError>;
423
+ }
424
+ /** Script values cross the page boundary through the caller's Schema. A bundler may rewrite functions. */
425
+ interface ScriptOptions<A, Arg> {
426
+ readonly arg: Arg;
427
+ readonly result: Schema.Codec<A, unknown>;
428
+ }
429
+ interface ActOptions<A, Arg> extends ScriptOptions<A, Arg> {
430
+ readonly document: number;
431
+ /** Supplying the read's connection also refuses a document counter from another connection. */
432
+ readonly connection?: string | undefined;
433
+ }
434
+ interface Page {
435
+ /** Decode and perform a data action through the same policy and lane as the named methods. */
436
+ readonly perform: (action: Action) => Effect.Effect<ResolvedTarget | string | void, BrowserError>;
437
+ /** Read declared side-effect-free code in the main world, retrying one replaced document. */
438
+ readonly read: <A, Arg>(script: (arg: Arg) => unknown, options: ScriptOptions<A, Arg>) => Effect.Effect<{
439
+ readonly value: A;
440
+ readonly document: number;
441
+ readonly connection: string;
442
+ }, BrowserError>;
443
+ /**
444
+ * Run code as a guarded, recorded action bound to the caller's document.
445
+ * A timeout or cancellation cannot stop JavaScript already running: later input waits for its
446
+ * actual reply. Close the page and open a replacement if the script never settles.
447
+ */
448
+ readonly act: <A, Arg>(script: (arg: Arg) => unknown, options: ActOptions<A, Arg>) => Effect.Effect<A, BrowserError>;
449
+ /** Owning browser clock: deadlines and all frame/event timestamps use this clock. */
450
+ readonly clock: Clock.Clock;
451
+ /** Wait for admitted input and retain a bounded read turn through effect. */
452
+ readonly afterInput: <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E | BrowserError, R>;
453
+ /** A scoped lease starts capture immediately, independently of its first frame. */
454
+ readonly capture: (options?: ScreencastOptions) => Effect.Effect<Capture, BrowserError, Scope.Scope>;
455
+ /** One page-side wait; replaced documents share one deadline. Unmet is met:false; an empty mark means no stable document could be sampled. */
456
+ readonly until: (query: FindQuery, want: UntilWant, millis: number) => Effect.Effect<UntilResult, BrowserError>;
472
457
  /** The page's CDP target id: the same page has it again after a reconnect to its browser. */
473
458
  readonly id: string;
474
- /** The Playwright page, for anything this API does not cover. Never give it to a model. */
475
- readonly playwright: Page;
476
459
  /** The page's address, without its userinfo or known secret parameters. */
477
460
  readonly url: Effect.Effect<string>;
478
461
  /**
@@ -499,8 +482,11 @@ interface Page$1 {
499
482
  * screenshot timed by the host interval in which it was taken.
500
483
  */
501
484
  readonly frame: (options?: FrameOptions) => Effect.Effect<Frame, BrowserError>;
502
- /** A crop in CSS pixels, unmagnified, with the origin that keeps later input in viewport pixels. */
503
- readonly zoom: (region: Region) => Effect.Effect<Zoom, BrowserError>;
485
+ /**
486
+ * A crop in CSS pixels, unmagnified, with the origin that keeps later input in viewport pixels.
487
+ * With `scale: "device"` its picture has the screen's own pixels, as a screenshot's would.
488
+ */
489
+ readonly zoom: (region: Region, options?: Pick<ScreenshotOptions, "scale">) => Effect.Effect<Zoom, BrowserError>;
504
490
  /**
505
491
  * The viewport's size in CSS pixels, the space of points, crops and page scrolls. Over CDP the
506
492
  * page reports it, within the action timeout.
@@ -552,23 +538,10 @@ interface Page$1 {
552
538
  */
553
539
  readonly select: (ref: string, values: ReadonlyArray<string>) => Effect.Effect<string, BrowserError>;
554
540
  /**
555
- * Wait until a condition holds, in one call that the page answers as it comes, looking every
556
- * 100 ms, or `Timeout` after `timeout`, 10 seconds by default. A selector that is not CSS is an
557
- * `InvalidRequest`.
558
- */
559
- readonly waitFor: (condition: WaitCondition, timeout?: Duration.Input) => Effect.Effect<void, BrowserError>;
560
- /**
561
- * Wait until the page is ready to be shown, asking the page every 100 ms: its document is parsed
562
- * and has painted since, nothing that ends is animating in view, its fonts and the images in
563
- * view have loaded, and the viewport shows something. With `quietMillis`, the screen must then
564
- * also stay still that long: nothing in view changed, where the page's changes are recorded, and
565
- * no frame comes, counted from the first frame of a capture the wait starts itself. A canvas
566
- * that keeps drawing, such as a live chart, is never still. With `still: "foreground"`, frames
567
- * may keep coming, but nothing may move in them outside what moved in the frames of the 1.5 s
568
- * before the page's latest input, such as an idle animation; reels set spinning, or a counter
569
- * set rolling, by the input keep the wait going. Without those frames, as where they are older
570
- * than the browser's `frameHistory`, nothing may move at all. A page is never ready without a
571
- * painted frame, as a hidden tab may be. `Timeout` after `timeout`, 15 seconds by default.
541
+ * Wait for document evidence, polling every 50 ms: parsed, painted, visible, fonts and visible
542
+ * images loaded, and finite animations finished. Optional quietMillis requires recorded content
543
+ * to stay unchanged. Screen or foreground stillness belongs to the Stillness feature.
544
+ * Fails Timeout after timeout, 15 seconds by default.
572
545
  */
573
546
  readonly ready: (options?: ReadyOptions) => Effect.Effect<void, BrowserError>;
574
547
  /**
@@ -589,5 +562,5 @@ interface Page$1 {
589
562
  readonly recentEvents: Effect.Effect<ReadonlyArray<BrowserEvent>>;
590
563
  }
591
564
  //#endregion
592
- export { Account as A, TypeOptions as C, correlate as D, Zoom as E, account as F, capture as I, toPrompt as L, Moment as M, Moment_d_exports as N, failFast as O, Window as P, TextOptions as S, WindowOptions as T, ScreenshotOptions as _, FindQuery as a, Target as b, InputGuard as c, Page_d_exports as d, Point as f, ResolvedTarget as g, Region as h, Fact as i, CaptureOptions as j, redacted as k, InputRequest as l, ReadyOptions as m, ClickOptions as n, Found as o, PressOptions as p, ElementState as r, FrameOptions as s, ChangesOptions as t, Page$1 as u, ScrollOptions as v, WaitCondition as w, Text as x, State as y };
593
- //# sourceMappingURL=Page-ku6j5t-v.d.mts.map
565
+ export { Zoom as A, Target as C, UntilResult as D, TypeOptions as E, failFast as M, redacted as N, UntilWant as O, State as S, TextOptions as T, Region as _, ElementState as a, ScriptOptions as b, Found as c, InputRequest as d, Page as f, ReadyOptions as g, PressOptions as h, ClickOptions as i, correlate as j, WindowOptions as k, FrameOptions as l, Point as m, Capture as n, Fact as o, Page_d_exports as p, ChangesOptions as r, FindQuery as s, ActOptions as t, InputGuard as u, ResolvedTarget as v, Text as w, ScrollOptions as x, ScreenshotOptions as y };
566
+ //# sourceMappingURL=Page-CvsOEorc.d.mts.map
package/dist/Page.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { C as TypeOptions, D as correlate, E as Zoom, O as failFast, S as TextOptions, T as WindowOptions, _ as ScreenshotOptions, a as FindQuery, b as Target, c as InputGuard, f as Point, g as ResolvedTarget, h as Region, i as Fact, k as redacted, l as InputRequest, m as ReadyOptions, n as ClickOptions, o as Found, p as PressOptions, r as ElementState, s as FrameOptions, t as ChangesOptions, u as Page, v as ScrollOptions, w as WaitCondition, x as Text, y as State } from "./Page-ku6j5t-v.mjs";
2
- export { ChangesOptions, ClickOptions, ElementState, Fact, FindQuery, Found, FrameOptions, InputGuard, InputRequest, Page, Point, PressOptions, ReadyOptions, Region, ResolvedTarget, ScreenshotOptions, ScrollOptions, State, Target, Text, TextOptions, TypeOptions, WaitCondition, WindowOptions, Zoom, correlate, failFast, redacted };
1
+ import { A as Zoom, C as Target, D as UntilResult, E as TypeOptions, M as failFast, N as redacted, O as UntilWant, S as State, T as TextOptions, _ as Region, a as ElementState, b as ScriptOptions, c as Found, d as InputRequest, f as Page, g as ReadyOptions, h as PressOptions, i as ClickOptions, j as correlate, k as WindowOptions, l as FrameOptions, m as Point, n as Capture, o as Fact, r as ChangesOptions, s as FindQuery, t as ActOptions, u as InputGuard, v as ResolvedTarget, w as Text, x as ScrollOptions, y as ScreenshotOptions } from "./Page-CvsOEorc.mjs";
2
+ export { ActOptions, Capture, ChangesOptions, ClickOptions, ElementState, Fact, FindQuery, Found, FrameOptions, InputGuard, InputRequest, Page, Point, PressOptions, ReadyOptions, Region, ResolvedTarget, ScreenshotOptions, ScriptOptions, ScrollOptions, State, Target, Text, TextOptions, TypeOptions, UntilResult, UntilWant, WindowOptions, Zoom, correlate, failFast, redacted };