effect-browser 0.3.0-beta.23 → 0.3.0-beta.24

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 (134) hide show
  1. package/README.md +124 -5
  2. package/dist/ActionPort.d.mts +1 -1
  3. package/dist/ActionPort.mjs +1 -1
  4. package/dist/{Browser-BKPAbyys.mjs → Browser-CAQFhTkM.mjs} +559 -333
  5. package/dist/Browser-CAQFhTkM.mjs.map +1 -0
  6. package/dist/{Browser-wZhwZSlG.d.mts → Browser-DGR6ZEYo.d.mts} +9 -3
  7. package/dist/Browser.d.mts +1 -1
  8. package/dist/Browser.mjs +1 -1
  9. package/dist/{BrowserEvent-lLqJ3GJS.d.mts → BrowserEvent-C2p-NwuU.d.mts} +30 -6
  10. package/dist/BrowserEvent.d.mts +2 -2
  11. package/dist/BrowserEvent.mjs +20 -1
  12. package/dist/BrowserEvent.mjs.map +1 -1
  13. package/dist/{Change-Ba7INmay.d.mts → Change-CxT1mp2e.d.mts} +13 -2
  14. package/dist/Change.d.mts +1 -1
  15. package/dist/Change.mjs +7 -1
  16. package/dist/Change.mjs.map +1 -1
  17. package/dist/Clock-Du5nP-nK.d.mts +57 -0
  18. package/dist/Clock.d.mts +2 -57
  19. package/dist/Layout.d.mts +2 -0
  20. package/dist/Layout.mjs +81 -0
  21. package/dist/Layout.mjs.map +1 -0
  22. package/dist/Matching-MtcWZ_hA.d.mts +266 -0
  23. package/dist/Matching.d.mts +2 -37
  24. package/dist/Matching.mjs +22 -17
  25. package/dist/Matching.mjs.map +1 -1
  26. package/dist/Overlay-CoGw5tL_.d.mts +27 -0
  27. package/dist/Overlay.d.mts +2 -0
  28. package/dist/Overlay.mjs +30 -0
  29. package/dist/Overlay.mjs.map +1 -0
  30. package/dist/{Page-BF5izr8R.mjs → Page-BaAOshxo.mjs} +3 -1
  31. package/dist/Page-BaAOshxo.mjs.map +1 -0
  32. package/dist/{Page-CvsOEorc.d.mts → Page-CLzh5E9w.d.mts} +158 -6
  33. package/dist/Page.d.mts +2 -2
  34. package/dist/Page.mjs +1 -1
  35. package/dist/PageTime-68UPUZpZ.d.mts +29 -0
  36. package/dist/PageTime.d.mts +2 -0
  37. package/dist/PageTime.mjs +7 -0
  38. package/dist/PageTime.mjs.map +1 -0
  39. package/dist/Pose-2qqGzPvb.d.mts +32 -0
  40. package/dist/Pose.d.mts +2 -0
  41. package/dist/Pose.mjs +44 -0
  42. package/dist/Pose.mjs.map +1 -0
  43. package/dist/Site.d.mts +714 -0
  44. package/dist/Site.mjs +102 -0
  45. package/dist/Site.mjs.map +1 -0
  46. package/dist/{Stillness-CNlvayIo.mjs → Stillness-BwP0RdI4.mjs} +27 -6
  47. package/dist/Stillness-BwP0RdI4.mjs.map +1 -0
  48. package/dist/{Style-AO4V7Czt.mjs → Style-T3ezDYLI.mjs} +25 -2
  49. package/dist/{Style-AO4V7Czt.mjs.map → Style-T3ezDYLI.mjs.map} +1 -1
  50. package/dist/Style.d.mts +15 -2
  51. package/dist/Style.mjs +2 -2
  52. package/dist/Url-B7P-TWwL.d.mts +26 -0
  53. package/dist/Url.d.mts +2 -26
  54. package/dist/{Window-CMddGMt1.d.mts → Window-BDa8MtNP.d.mts} +4 -4
  55. package/dist/Window.d.mts +1 -1
  56. package/dist/{connection-CK83pvqP.mjs → connection-C_jWYIwe.mjs} +2 -2
  57. package/dist/{connection-CK83pvqP.mjs.map → connection-C_jWYIwe.mjs.map} +1 -1
  58. package/dist/{connection-2KHI4_KN.d.mts → connection-Db-YtlbE.d.mts} +2 -2
  59. package/dist/film/Film.d.mts +265 -0
  60. package/dist/film/Film.mjs +246 -0
  61. package/dist/film/Film.mjs.map +1 -0
  62. package/dist/fold.inpage-CyVZQHZL.d.mts +49 -0
  63. package/dist/index.d.mts +11 -8
  64. package/dist/index.mjs +8 -4
  65. package/dist/moment/Moment.d.mts +5 -5
  66. package/dist/plan/index.d.mts +2 -2
  67. package/dist/plan/index.mjs +2 -2
  68. package/dist/policy/Policy.d.mts +1 -1
  69. package/dist/policy/Policy.mjs +1 -1
  70. package/dist/pose.inpage-CLq7Mfdr.mjs +2042 -0
  71. package/dist/pose.inpage-CLq7Mfdr.mjs.map +1 -0
  72. package/dist/presentation/Presentation.d.mts +8 -1
  73. package/dist/presentation/Presentation.mjs +3 -1
  74. package/dist/presentation/Presentation.mjs.map +1 -1
  75. package/dist/presentation/Stage.d.mts +1 -1
  76. package/dist/providers/Cdp.d.mts +2 -2
  77. package/dist/providers/Cdp.mjs +1 -1
  78. package/dist/providers/Chromium.d.mts +1 -1
  79. package/dist/providers/Chromium.mjs +1 -1
  80. package/dist/stillness/Stillness.d.mts +1 -1
  81. package/dist/stillness/Stillness.mjs +1 -1
  82. package/dist/testing/index.d.mts +4 -30
  83. package/dist/testing/index.mjs +8 -2
  84. package/dist/testing/index.mjs.map +1 -1
  85. package/dist/workerd/Cdp.d.mts +2 -2
  86. package/dist/workerd/Cdp.mjs +1 -1
  87. package/package.json +32 -2
  88. package/src/Browser.ts +11 -6
  89. package/src/BrowserEvent.ts +19 -0
  90. package/src/Change.ts +7 -1
  91. package/src/Layout.ts +116 -0
  92. package/src/Matching.ts +24 -15
  93. package/src/Overlay.ts +37 -0
  94. package/src/Page.ts +45 -0
  95. package/src/PageTime.ts +47 -0
  96. package/src/Pose.ts +50 -0
  97. package/src/Site.ts +124 -0
  98. package/src/Style.ts +36 -0
  99. package/src/film/Film.ts +384 -0
  100. package/src/index.ts +4 -0
  101. package/src/internal/input/perform.ts +31 -3
  102. package/src/internal/input/pointer.ts +7 -4
  103. package/src/internal/input/targets.ts +1 -1
  104. package/src/internal/page/bridge.ts +65 -33
  105. package/src/internal/page/clock.inpage.ts +306 -0
  106. package/src/internal/page/compose.inpage.ts +101 -0
  107. package/src/internal/page/context.ts +2 -0
  108. package/src/internal/page/overlay.inpage.ts +96 -0
  109. package/src/internal/page/overlay.ts +89 -0
  110. package/src/internal/page/page.ts +12 -0
  111. package/src/internal/page/pose.inpage.ts +200 -0
  112. package/src/internal/page/pose.ts +80 -0
  113. package/src/internal/page/time.inpage.ts +49 -0
  114. package/src/internal/page/time.ts +122 -0
  115. package/src/internal/page/viewport.ts +3 -2
  116. package/src/internal/pictures/pictures.ts +93 -32
  117. package/src/internal/reading/layout.inpage.ts +193 -0
  118. package/src/internal/reading/layout.ts +101 -0
  119. package/src/internal/reading/names.inpage.ts +15 -0
  120. package/src/internal/reading/outline.inpage.ts +2 -18
  121. package/src/internal/reading/reading.ts +22 -2
  122. package/src/internal/reading/ready.inpage.ts +18 -23
  123. package/src/internal/reading/ready.ts +23 -3
  124. package/src/internal/reading/text.inpage.ts +1 -14
  125. package/src/internal/timeline/changes.inpage.ts +7 -15
  126. package/src/internal/timeline/changes.ts +14 -1
  127. package/src/internal/timeline/record.inpage.ts +15 -6
  128. package/src/presentation/Presentation.ts +13 -0
  129. package/src/stillness/Pixels.ts +26 -0
  130. package/src/stillness/Stillness.ts +30 -5
  131. package/src/testing/page.ts +5 -0
  132. package/dist/Browser-BKPAbyys.mjs.map +0 -1
  133. package/dist/Page-BF5izr8R.mjs.map +0 -1
  134. package/dist/Stillness-CNlvayIo.mjs.map +0 -1
@@ -1 +0,0 @@
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,Q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,OAAO,SAASD,KAAY;CACnC,MAAM,OAAO,SAAS,OAAO,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 +0,0 @@
1
- {"version":3,"file":"Stillness-CNlvayIo.mjs","names":["Motion.picture","Motion.background","Motion.stirs"],"sources":["../src/stillness/Pixels.ts","../src/stillness/Stillness.ts"],"sourcesContent":["/**\n * Where a page's screen moves, from its screencast frames: each frame decoded and cut into\n * 16-pixel blocks, a block moving where a few of its pixels, sampled every other one, changed by\n * more than JPEG's noise in any color channel.\n * What moved among the frames before an input is the page's background, such as an idle\n * animation; foreground stillness ignores it.\n *\n * Frames use Playwright's bundled JPEG decoder. The package build ships that exact decoder\n * alone, keeping its Node utility bundle out of Workers. Source runs use its native export,\n * whose untyped entry point is declared by `utilsBundle.d.ts`.\n */\n// oxlint-disable-next-line typescript/triple-slash-reference -- a declaration of an untyped module cannot be imported, and every program that compiles this source needs it\n/// <reference path=\"./utilsBundle.d.ts\" />\nimport { jpegjs } from \"playwright-core/lib/utilsBundle\";\n\nimport type { Frame } from \"../Frame.ts\";\n\n/** A decoded frame: RGBA, `width` pixels a row. */\nexport type Picture = ReturnType<typeof jpegjs.decode>;\n\nexport const picture = (frame: Frame): Picture => jpegjs.decode(frame.data, { useTArray: true });\n\n/** A sample changed where any color channel moved more than this, beyond JPEG's noise. */\nconst noise = 32;\n\n/** The blocks where two pictures differ, by `row * columns + column`; -1 for different sizes. */\nconst moved = (from: Picture, to: Picture): ReadonlyArray<number> => {\n if (from.width !== to.width || from.height !== to.height) return [-1];\n const columns = Math.ceil(from.width / 16);\n const counts = new Map<number, number>();\n const differs = (at: number) => Math.abs((from.data[at] ?? 0) - (to.data[at] ?? 0)) > noise;\n\n for (let y = 0; y < from.height; y += 2)\n for (let x = 0; x < from.width; x += 2) {\n const at = (y * from.width + x) * 4;\n const block = Math.floor(y / 16) * columns + Math.floor(x / 16);\n\n if (differs(at) || differs(at + 1) || differs(at + 2))\n counts.set(block, (counts.get(block) ?? 0) + 1);\n }\n\n // At least three changed samples, so a stray one is no motion.\n return [...counts].flatMap(([block, count]) => (count >= 3 ? [block] : []));\n};\n\n/** The blocks that moved from one picture to the next and their neighbours; none past a resize. */\nexport const background = (pictures: ReadonlyArray<Picture>): ReadonlySet<number> => {\n const columns = Math.ceil((pictures[0]?.width ?? 0) / 16);\n\n const around = (block: number) =>\n [-1, 0, 1].flatMap((row) =>\n [-1, 0, 1]\n .filter((step) => block >= 0 && (block % columns) + step >= 0)\n .filter((step) => (block % columns) + step < columns)\n .map((step) => block + row * columns + step),\n );\n\n return new Set(\n pictures.flatMap((to, index) => moved(pictures[index - 1] ?? to, to).flatMap(around)),\n );\n};\n\n/** Whether anything moved from one picture to another outside the background. */\nexport const stirs = (from: Picture, to: Picture, mask: ReadonlySet<number>) =>\n moved(from, to).some((block) => !mask.has(block));\n","/** Screen and foreground stillness over the public page capture and owning clock. */\nimport { Clock, Duration, Effect, Option, Schedule, Stream } from \"effect\";\n\nimport { Failed, refuse, Timeout, undispatched } from \"../BrowserError.ts\";\nimport { monotonicMillis } from \"../Clock.ts\";\nimport type { Frame } from \"../Frame.ts\";\nimport type { Page } from \"../Page.ts\";\nimport * as Motion from \"./Pixels.ts\";\n\nexport interface Options {\n readonly still?: \"screen\" | \"content\" | \"foreground\" | undefined;\n readonly quietMillis: number;\n readonly timeout?: Duration.Input | undefined;\n}\n\nconst observe = (page: Page, options: Options, timeout: Duration.Duration) =>\n Effect.gen(function* () {\n const now = () => monotonicMillis(page.clock);\n const deadline = now() + Duration.toMillis(timeout);\n\n const settled = () =>\n page.ready({\n quietMillis: options.quietMillis,\n timeout: Duration.millis(Math.max(0, deadline - now())),\n });\n\n // A capture the wait starts sends its first frame late, over half a second from a hosted\n // browser, so the spell counts from that frame (#202); Chrome sends one as a capture starts,\n // even of a still page.\n const quiet = (millis: number) =>\n Effect.gen(function* () {\n const capture = yield* page.capture();\n\n const foreground = options.still === \"foreground\";\n let counts = yield* capture.stats();\n let stirred = now();\n let reference: Motion.Picture | undefined;\n\n const decoded = (frame: Frame) =>\n Effect.try({\n try: () => Motion.picture(frame),\n catch: (error) =>\n undispatched(\"ready\", new Failed({ detail: `no picture: ${String(error)}` })),\n });\n\n // The background: what moved in up to eight frames of the document's 1.5 s before its\n // latest input, as far back as the capture keeps them.\n const inputAt =\n (yield* page.recentEvents).findLast((event) => event._tag === \"Action\")?.startedAt ??\n Number.NEGATIVE_INFINITY;\n\n const document = (yield* page.state).document;\n\n const before = (foreground ? yield* page.recentFrames : []).filter(\n (frame) =>\n frame.hostTime < inputAt &&\n frame.hostTime >= inputAt - 1500 &&\n frame.document === document,\n );\n\n const sampled = before.filter((_, index) => index % Math.ceil(before.length / 8) === 0);\n const mask = Motion.background(yield* Effect.forEach(sampled, decoded));\n\n // How long the screen has been still: since a frame, or an unanswered acknowledgement. In\n // the foreground, since a frame moved outside the background, or acknowledgements went\n // unanswered with no frame coming.\n const look = Effect.gen(function* () {\n const stats = yield* capture.stats();\n const latest = (yield* page.state).frame;\n const arrived = stats.received !== counts.received;\n const unseen = stats.accepted - counts.accepted;\n\n counts = stats;\n if (latest === undefined || !capture.isCurrent(latest)) stirred = now();\n else if (!foreground ? arrived || stats.ackBacklog > 0 : !arrived && stats.ackBacklog > 0)\n stirred = now();\n else if (foreground && (unseen > 0 || reference === undefined)) {\n // A move and its return between looks both count. Bound decoding; any frames lost\n // from history, or beyond this batch, deny a quiet spell rather than hiding motion.\n const frames = (yield* page.recentFrames).slice(-Math.max(1, Math.min(8, unseen)));\n\n if (unseen > frames.length) stirred = now();\n for (const frame of frames) {\n const seen = yield* decoded(frame);\n\n if (reference === undefined || Motion.stirs(reference, seen, mask)) {\n reference = seen;\n stirred = now();\n }\n }\n }\n\n return now() - stirred;\n });\n\n // Decode at a fixed cadence: adding a delay after a full batch lets its backlog grow.\n const spell = Effect.repeat(look, {\n schedule: Schedule.fixed(Duration.millis(foreground ? 100 : 25)),\n until: (still) => still >= millis,\n });\n\n const still = Effect.gen(function* () {\n for (;;) {\n yield* spell;\n const before = counts.received;\n\n yield* Effect.all([settled(), capture.sync], { concurrency: 2, discard: true });\n if ((yield* look) >= millis && (foreground || counts.received === before)) return;\n }\n });\n\n return yield* Effect.raceFirst(\n capture.stream.pipe(Stream.runDrain, Effect.andThen(Effect.never)),\n still,\n );\n });\n\n yield* page.afterInput(Effect.void);\n if (options.still === \"content\") {\n yield* page.changes();\n yield* Effect.sleep(Duration.millis(options.quietMillis));\n\n return yield* settled();\n }\n yield* settled();\n yield* quiet(options.quietMillis);\n });\n\nexport const wait = (page: Page, options: Options) =>\n Effect.gen(function* () {\n if (!Number.isFinite(options.quietMillis) || options.quietMillis < 0)\n return yield* refuse(\"stillness\", \"quietMillis must be finite and nonnegative\");\n const input = options.timeout ?? Duration.seconds(15);\n\n const components =\n typeof input === \"number\"\n ? [input]\n : typeof input === \"object\" && !Duration.isDuration(input)\n ? Object.values(input)\n : [];\n\n const timeout = Duration.fromInput(input);\n\n if (\n components.some((value) => typeof value === \"number\" && !Number.isFinite(value)) ||\n Option.isNone(timeout) ||\n !Duration.isFinite(timeout.value) ||\n Duration.isNegative(timeout.value)\n )\n return yield* refuse(\"stillness\", \"timeout must be a finite nonnegative duration\");\n const duration = timeout.value;\n\n return yield* observe(page, options, duration).pipe(\n Effect.timeoutOrElse({\n duration,\n orElse: () =>\n Effect.fail(\n undispatched(\"stillness\", new Timeout({ millis: Duration.toMillis(duration) })),\n ),\n }),\n );\n }).pipe(\n Effect.scoped,\n Effect.provideService(Clock.Clock, page.clock),\n Effect.withSpan(\"Stillness.wait\"),\n );\n"],"mappings":";;;;;;;;;;;;;;;;AAoBA,MAAa,WAAW,UAA0B,OAAO,OAAO,MAAM,MAAM,EAAE,WAAW,KAAK,CAAC;;AAG/F,MAAM,QAAQ;;AAGd,MAAM,SAAS,MAAe,OAAuC;CACnE,IAAI,KAAK,UAAU,GAAG,SAAS,KAAK,WAAW,GAAG,QAAQ,OAAO,CAAC,EAAE;CACpE,MAAM,UAAU,KAAK,KAAK,KAAK,QAAQ,EAAE;CACzC,MAAM,yBAAS,IAAI,IAAoB;CACvC,MAAM,WAAW,OAAe,KAAK,KAAK,KAAK,KAAK,OAAO,MAAM,GAAG,KAAK,OAAO,EAAE,IAAI;CAEtF,KAAK,IAAI,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK,GACpC,KAAK,IAAI,IAAI,GAAG,IAAI,KAAK,OAAO,KAAK,GAAG;EACtC,MAAM,MAAM,IAAI,KAAK,QAAQ,KAAK;EAClC,MAAM,QAAQ,KAAK,MAAM,IAAI,EAAE,IAAI,UAAU,KAAK,MAAM,IAAI,EAAE;EAE9D,IAAI,QAAQ,EAAE,KAAK,QAAQ,KAAK,CAAC,KAAK,QAAQ,KAAK,CAAC,GAClD,OAAO,IAAI,QAAQ,OAAO,IAAI,KAAK,KAAK,KAAK,CAAC;CAClD;CAGF,OAAO,CAAC,GAAG,MAAM,CAAC,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