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

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 (249) 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-BKPAbyys.mjs +4076 -0
  10. package/dist/Browser-BKPAbyys.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-CK83pvqP.mjs} +5 -6
  64. package/dist/connection-CK83pvqP.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 +515 -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 +89 -39
  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/identity.ts +6 -5
  139. package/src/internal/page/lane.ts +14 -15
  140. package/src/internal/page/navigation.ts +50 -42
  141. package/src/internal/page/openings.ts +11 -5
  142. package/src/internal/page/page.ts +44 -81
  143. package/src/internal/page/port.ts +125 -0
  144. package/src/internal/{input → page}/replies.ts +1 -1
  145. package/src/internal/page/request-owner.ts +269 -0
  146. package/src/internal/page/requests.ts +357 -0
  147. package/src/internal/page/scripts.ts +124 -0
  148. package/src/internal/pictures/capture.ts +255 -332
  149. package/src/internal/pictures/dimensions.ts +162 -0
  150. package/src/internal/pictures/frame.ts +68 -0
  151. package/src/internal/pictures/pictures.ts +57 -23
  152. package/src/internal/pictures/quiescence.ts +1 -1
  153. package/src/internal/pictures/state.ts +26 -0
  154. package/src/internal/pictures/transport.ts +21 -4
  155. package/src/internal/reading/controls.inpage.ts +5 -70
  156. package/src/internal/reading/expect.inpage.ts +13 -17
  157. package/src/internal/reading/names.inpage.ts +89 -45
  158. package/src/internal/reading/outline.inpage.ts +6 -7
  159. package/src/internal/reading/reading.ts +144 -176
  160. package/src/internal/reading/ready.inpage.ts +6 -17
  161. package/src/internal/reading/ready.ts +13 -135
  162. package/src/internal/reading/subjects.inpage.ts +83 -43
  163. package/src/internal/reading/walk.inpage.ts +33 -13
  164. package/src/internal/timeline/changes.ts +55 -6
  165. package/src/internal/timeline/events.ts +15 -5
  166. package/src/internal/timeline/history.inpage.ts +1 -1
  167. package/src/internal/timeline/record.inpage.ts +4 -1
  168. package/src/internal/timeline/window.ts +2 -1
  169. package/src/{Moment.ts → moment/Moment.ts} +13 -31
  170. package/src/{internal/timeline → moment}/words.ts +2 -2
  171. package/src/{internal/reading → plan}/choose.ts +3 -3
  172. package/src/plan/data.ts +117 -0
  173. package/src/plan/execute.ts +411 -0
  174. package/src/plan/index.ts +36 -0
  175. package/src/plan/record.ts +71 -0
  176. package/src/plan/targets.ts +71 -0
  177. package/src/{Policy.ts → policy/Policy.ts} +13 -10
  178. package/src/{Motion.ts → presentation/Motion.ts} +12 -46
  179. package/src/presentation/Presentation.ts +176 -0
  180. package/src/{Stage.ts → presentation/Stage.ts} +147 -112
  181. package/src/presentation/feed.ts +21 -0
  182. package/src/{Cdp.ts → providers/Cdp.ts} +2 -2
  183. package/src/{Chromium.ts → providers/Chromium.ts} +7 -10
  184. package/src/providers/Released.ts +13 -0
  185. package/src/{internal/cdp.ts → providers/connection.ts} +2 -2
  186. package/src/{internal/pictures/motion.ts → stillness/Pixels.ts} +1 -1
  187. package/src/stillness/Stillness.ts +166 -0
  188. package/src/supervisor/Supervisor.ts +170 -0
  189. package/src/supervisor/contract.ts +105 -0
  190. package/src/supervisor/lifecycle.ts +272 -0
  191. package/src/supervisor/runtime.ts +238 -0
  192. package/src/testing/TestBrowser.ts +115 -0
  193. package/src/testing/TestPage.ts +10 -0
  194. package/src/testing/evidence.ts +154 -0
  195. package/src/testing/index.ts +3 -0
  196. package/src/testing/model.ts +222 -0
  197. package/src/testing/page.ts +360 -0
  198. package/src/workerd/Cdp.ts +2 -2
  199. package/dist/Browser-CxXUjxOp.mjs +0 -619
  200. package/dist/Browser-CxXUjxOp.mjs.map +0 -1
  201. package/dist/Cdp-CzCRnMlM.d.mts +0 -10
  202. package/dist/Cdp.d.mts +0 -11
  203. package/dist/Cdp.mjs.map +0 -1
  204. package/dist/Change-DNvztNLu.mjs +0 -138
  205. package/dist/Change-DNvztNLu.mjs.map +0 -1
  206. package/dist/Chromium.mjs.map +0 -1
  207. package/dist/Expect-u3P_ENLX.d.mts +0 -62
  208. package/dist/Expect.d.mts +0 -2
  209. package/dist/Expect.mjs +0 -114
  210. package/dist/Expect.mjs.map +0 -1
  211. package/dist/Moment.d.mts +0 -2
  212. package/dist/Moment.mjs.map +0 -1
  213. package/dist/Motion.d.mts +0 -2
  214. package/dist/Motion.mjs.map +0 -1
  215. package/dist/Page-BP02bmNv.mjs +0 -264
  216. package/dist/Page-BP02bmNv.mjs.map +0 -1
  217. package/dist/Plan-BG1WifW2.mjs.map +0 -1
  218. package/dist/Plan.d.mts +0 -2
  219. package/dist/Plan.mjs +0 -2
  220. package/dist/Policy.d.mts +0 -2
  221. package/dist/Policy.mjs.map +0 -1
  222. package/dist/Presentation-DxVikn9_.d.mts +0 -48
  223. package/dist/Presentation.d.mts +0 -2
  224. package/dist/Presentation.mjs +0 -118
  225. package/dist/Presentation.mjs.map +0 -1
  226. package/dist/Stage.d.mts +0 -2
  227. package/dist/Stage.mjs.map +0 -1
  228. package/dist/Supervisor-2mPjIYYs.mjs +0 -676
  229. package/dist/Supervisor-2mPjIYYs.mjs.map +0 -1
  230. package/dist/Supervisor-CfRxbaso.d.mts +0 -317
  231. package/dist/Supervisor.d.mts +0 -2
  232. package/dist/Supervisor.mjs +0 -2
  233. package/dist/cdp-BMpYMWYe.mjs.map +0 -1
  234. package/dist/context-EGhOqjNN.mjs +0 -335
  235. package/dist/context-EGhOqjNN.mjs.map +0 -1
  236. package/dist/page-PTM8m5wC.mjs +0 -4057
  237. package/dist/page-PTM8m5wC.mjs.map +0 -1
  238. package/dist/url-Bsp2y55M.mjs +0 -264
  239. package/dist/url-Bsp2y55M.mjs.map +0 -1
  240. package/dist/workerd/index.d.mts +0 -16
  241. package/dist/workerd/index.mjs +0 -17
  242. package/src/Expect.ts +0 -180
  243. package/src/Plan.ts +0 -674
  244. package/src/Presentation.ts +0 -196
  245. package/src/Supervisor.ts +0 -632
  246. package/src/internal/supervisor/lifecycle.ts +0 -484
  247. package/src/workerd/index.ts +0 -17
  248. /package/src/{internal/page/url.ts → Url.ts} +0 -0
  249. /package/src/{internal/pictures → stillness}/utilsBundle.d.ts +0 -0
package/dist/Page.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { c as State, d as correlate, f as failFast, i as InputRequest, l as Text, n as Fact, o as Region, p as redacted, r as Found, s as ResolvedTarget, t as ElementState, u as Zoom } from "./Page-BP02bmNv.mjs";
1
+ import { c as State, d as correlate, f as failFast, i as InputRequest, l as Text, n as Fact, o as Region, p as redacted, r as Found, s as ResolvedTarget, t as ElementState, u as Zoom } from "./Page-BF5izr8R.mjs";
2
2
  export { ElementState, Fact, Found, InputRequest, Region, ResolvedTarget, State, Text, Zoom, correlate, failFast, redacted };
@@ -0,0 +1,15 @@
1
+ import { Schema } from "effect";
2
+ //#region src/providers/Released.d.ts
3
+ declare const Settled_base: Schema.Class<Settled, Schema.TaggedStruct<"Settled", {}>, {}>;
4
+ /** The provider confirmed the resource ended. */
5
+ declare class Settled extends Settled_base {}
6
+ declare const Unconfirmed_base: Schema.Class<Unconfirmed, Schema.TaggedStruct<"Unconfirmed", {
7
+ readonly detail: Schema.String;
8
+ }>, {}>;
9
+ /** The resource may still run, and bill, because its end could not be confirmed. */
10
+ declare class Unconfirmed extends Unconfirmed_base {}
11
+ declare const Released: Schema.Union<readonly [typeof Settled, typeof Unconfirmed]>;
12
+ type Released = typeof Released.Type;
13
+ //#endregion
14
+ export { Settled as n, Unconfirmed as r, Released as t };
15
+ //# sourceMappingURL=Released-tURbFmal.d.mts.map
@@ -62,7 +62,12 @@ interface SnapshotOptions {
62
62
  readonly within?: string | undefined;
63
63
  /** Bound on the outline's length. Defaults to 12,000 characters. */
64
64
  readonly maxChars?: number | undefined;
65
+ /**
66
+ * Give every control's box, as `WxH at (x,y)` in viewport CSS pixels, as a canvas's or a frame's
67
+ * always has. Defaults to false.
68
+ */
69
+ readonly boxes?: boolean | undefined;
65
70
  }
66
71
  //#endregion
67
72
  export { Snapshot_d_exports as i, Snapshot as n, SnapshotOptions as r, Control as t };
68
- //# sourceMappingURL=Snapshot-B34hZ4Jl.d.mts.map
73
+ //# sourceMappingURL=Snapshot-CtBVOtuu.d.mts.map
@@ -1,2 +1,2 @@
1
- import { n as Snapshot, r as SnapshotOptions, t as Control } from "./Snapshot-B34hZ4Jl.mjs";
1
+ import { n as Snapshot, r as SnapshotOptions, t as Control } from "./Snapshot-CtBVOtuu.mjs";
2
2
  export { Control, Snapshot, SnapshotOptions };
@@ -1 +1 @@
1
- {"version":3,"file":"Snapshot.mjs","names":[],"sources":["../src/Snapshot.ts"],"sourcesContent":["/**\n * A compact, model-readable outline of what a page shows.\n *\n * Each control gets a ref such as `e12`. A ref stays valid while its element is on the page, and\n * refs are never reused within a page, so a ref from an old snapshot fails as stale rather than\n * naming a different element.\n *\n * @since 0.3.0\n */\nimport { Schema } from \"effect\";\n\n/** A control the outline shows, as a value: its ref, what it is and what it holds. */\nexport class Control extends Schema.Class<Control>(\"effect-browser/Control\")({\n ref: Schema.String,\n /** Its role, such as `button` or `textbox`, or `clickable` for an element without one. */\n kind: Schema.String,\n /** Its accessible name. */\n name: Schema.String,\n /** What it holds: a field's text, `••••` for a secret one, or a select's chosen labels. */\n value: Schema.String,\n /** A select's option labels, at most 64. */\n options: Schema.optional(Schema.Array(Schema.String)),\n /** How many options a select has, when it has options. */\n optionCount: Schema.optional(Schema.Int),\n disabled: Schema.optional(Schema.Boolean),\n /** Whether it is checked, for what can be checked. */\n checked: Schema.optional(Schema.Boolean),\n /** True for a field that takes typed text. */\n editable: Schema.optional(Schema.Boolean),\n}) {}\n\nexport class Snapshot extends Schema.Class<Snapshot>(\"effect-browser/Snapshot\")({\n url: Schema.String,\n title: Schema.String,\n /** One line per control, heading or text block, indented by landmark. */\n text: Schema.String,\n /** True when `text` was cut at `maxChars`. */\n truncated: Schema.Boolean,\n /**\n * Parts of the page left out because they lie above or below the viewport, each an element out\n * of view with all it holds (viewport snapshots only).\n */\n above: Schema.Finite,\n below: Schema.Finite,\n viewport: Schema.Struct({ width: Schema.Finite, height: Schema.Finite }),\n scroll: Schema.Struct({ y: Schema.Finite, height: Schema.Finite }),\n /** The controls the outline shows, in its order. */\n controls: Schema.Array(Control),\n}) {\n /** The snapshot as one block of text for a model: header, outline and what was left out. */\n get rendered(): string {\n const position =\n this.scroll.height > this.viewport.height\n ? `, scrolled to ${this.scroll.y} of ${this.scroll.height - this.viewport.height}px`\n : \"\";\n\n const omitted: Array<string> = [];\n\n if (this.above > 0) omitted.push(`${this.above} parts above`);\n if (this.below > 0) omitted.push(`${this.below} parts below`);\n\n const footer = [\n ...(omitted.length > 0 ? [`(${omitted.join(\", \")} the viewport)`] : []),\n ...(this.truncated ? [\"(cut short: narrow it with query)\"] : []),\n ];\n\n return [\n `Page: ${this.title === \"\" ? \"(untitled)\" : this.title}`,\n `URL: ${this.url}`,\n `Viewport: ${this.viewport.width}x${this.viewport.height}${position}`,\n this.text === \"\" ? \"(nothing readable in view)\" : this.text,\n ...footer,\n ].join(\"\\n\");\n }\n}\n\nexport interface SnapshotOptions {\n /** Read the whole page instead of the viewport. Defaults to false. */\n readonly full?: boolean | undefined;\n /** Keep only lines containing this text (case-insensitive). */\n readonly query?: string | undefined;\n /**\n * Read only inside the elements this CSS selector matches, such as `form` or `#results`. A\n * selector that matches nothing reads nothing; one that is not CSS is an `InvalidRequest`.\n */\n readonly within?: string | undefined;\n /** Bound on the outline's length. Defaults to 12,000 characters. */\n readonly maxChars?: number | undefined;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAYA,IAAa,UAAb,cAA6B,OAAO,MAAe,wBAAwB,CAAC,CAAC;CAC3E,KAAK,OAAO;;CAEZ,MAAM,OAAO;;CAEb,MAAM,OAAO;;CAEb,OAAO,OAAO;;CAEd,SAAS,OAAO,SAAS,OAAO,MAAM,OAAO,MAAM,CAAC;;CAEpD,aAAa,OAAO,SAAS,OAAO,GAAG;CACvC,UAAU,OAAO,SAAS,OAAO,OAAO;;CAExC,SAAS,OAAO,SAAS,OAAO,OAAO;;CAEvC,UAAU,OAAO,SAAS,OAAO,OAAO;AAC1C,CAAC,CAAC,CAAC,CAAC;AAEJ,IAAa,WAAb,cAA8B,OAAO,MAAgB,yBAAyB,CAAC,CAAC;CAC9E,KAAK,OAAO;CACZ,OAAO,OAAO;;CAEd,MAAM,OAAO;;CAEb,WAAW,OAAO;;;;;CAKlB,OAAO,OAAO;CACd,OAAO,OAAO;CACd,UAAU,OAAO,OAAO;EAAE,OAAO,OAAO;EAAQ,QAAQ,OAAO;CAAO,CAAC;CACvE,QAAQ,OAAO,OAAO;EAAE,GAAG,OAAO;EAAQ,QAAQ,OAAO;CAAO,CAAC;;CAEjE,UAAU,OAAO,MAAM,OAAO;AAChC,CAAC,CAAC,CAAC;;CAED,IAAI,WAAmB;EACrB,MAAM,WACJ,KAAK,OAAO,SAAS,KAAK,SAAS,SAC/B,iBAAiB,KAAK,OAAO,EAAE,MAAM,KAAK,OAAO,SAAS,KAAK,SAAS,OAAO,MAC/E;EAEN,MAAM,UAAyB,CAAC;EAEhC,IAAI,KAAK,QAAQ,GAAG,QAAQ,KAAK,GAAG,KAAK,MAAM,aAAa;EAC5D,IAAI,KAAK,QAAQ,GAAG,QAAQ,KAAK,GAAG,KAAK,MAAM,aAAa;EAE5D,MAAM,SAAS,CACb,GAAI,QAAQ,SAAS,IAAI,CAAC,IAAI,QAAQ,KAAK,IAAI,EAAE,eAAe,IAAI,CAAC,GACrE,GAAI,KAAK,YAAY,CAAC,mCAAmC,IAAI,CAAC,CAChE;EAEA,OAAO;GACL,SAAS,KAAK,UAAU,KAAK,eAAe,KAAK;GACjD,QAAQ,KAAK;GACb,aAAa,KAAK,SAAS,MAAM,GAAG,KAAK,SAAS,SAAS;GAC3D,KAAK,SAAS,KAAK,+BAA+B,KAAK;GACvD,GAAG;EACL,CAAC,CAAC,KAAK,IAAI;CACb;AACF"}
1
+ {"version":3,"file":"Snapshot.mjs","names":[],"sources":["../src/Snapshot.ts"],"sourcesContent":["/**\n * A compact, model-readable outline of what a page shows.\n *\n * Each control gets a ref such as `e12`. A ref stays valid while its element is on the page, and\n * refs are never reused within a page, so a ref from an old snapshot fails as stale rather than\n * naming a different element.\n *\n * @since 0.3.0\n */\nimport { Schema } from \"effect\";\n\n/** A control the outline shows, as a value: its ref, what it is and what it holds. */\nexport class Control extends Schema.Class<Control>(\"effect-browser/Control\")({\n ref: Schema.String,\n /** Its role, such as `button` or `textbox`, or `clickable` for an element without one. */\n kind: Schema.String,\n /** Its accessible name. */\n name: Schema.String,\n /** What it holds: a field's text, `••••` for a secret one, or a select's chosen labels. */\n value: Schema.String,\n /** A select's option labels, at most 64. */\n options: Schema.optional(Schema.Array(Schema.String)),\n /** How many options a select has, when it has options. */\n optionCount: Schema.optional(Schema.Int),\n disabled: Schema.optional(Schema.Boolean),\n /** Whether it is checked, for what can be checked. */\n checked: Schema.optional(Schema.Boolean),\n /** True for a field that takes typed text. */\n editable: Schema.optional(Schema.Boolean),\n}) {}\n\nexport class Snapshot extends Schema.Class<Snapshot>(\"effect-browser/Snapshot\")({\n url: Schema.String,\n title: Schema.String,\n /** One line per control, heading or text block, indented by landmark. */\n text: Schema.String,\n /** True when `text` was cut at `maxChars`. */\n truncated: Schema.Boolean,\n /**\n * Parts of the page left out because they lie above or below the viewport, each an element out\n * of view with all it holds (viewport snapshots only).\n */\n above: Schema.Finite,\n below: Schema.Finite,\n viewport: Schema.Struct({ width: Schema.Finite, height: Schema.Finite }),\n scroll: Schema.Struct({ y: Schema.Finite, height: Schema.Finite }),\n /** The controls the outline shows, in its order. */\n controls: Schema.Array(Control),\n}) {\n /** The snapshot as one block of text for a model: header, outline and what was left out. */\n get rendered(): string {\n const position =\n this.scroll.height > this.viewport.height\n ? `, scrolled to ${this.scroll.y} of ${this.scroll.height - this.viewport.height}px`\n : \"\";\n\n const omitted: Array<string> = [];\n\n if (this.above > 0) omitted.push(`${this.above} parts above`);\n if (this.below > 0) omitted.push(`${this.below} parts below`);\n\n const footer = [\n ...(omitted.length > 0 ? [`(${omitted.join(\", \")} the viewport)`] : []),\n ...(this.truncated ? [\"(cut short: narrow it with query)\"] : []),\n ];\n\n return [\n `Page: ${this.title === \"\" ? \"(untitled)\" : this.title}`,\n `URL: ${this.url}`,\n `Viewport: ${this.viewport.width}x${this.viewport.height}${position}`,\n this.text === \"\" ? \"(nothing readable in view)\" : this.text,\n ...footer,\n ].join(\"\\n\");\n }\n}\n\nexport interface SnapshotOptions {\n /** Read the whole page instead of the viewport. Defaults to false. */\n readonly full?: boolean | undefined;\n /** Keep only lines containing this text (case-insensitive). */\n readonly query?: string | undefined;\n /**\n * Read only inside the elements this CSS selector matches, such as `form` or `#results`. A\n * selector that matches nothing reads nothing; one that is not CSS is an `InvalidRequest`.\n */\n readonly within?: string | undefined;\n /** Bound on the outline's length. Defaults to 12,000 characters. */\n readonly maxChars?: number | undefined;\n /**\n * Give every control's box, as `WxH at (x,y)` in viewport CSS pixels, as a canvas's or a frame's\n * always has. Defaults to false.\n */\n readonly boxes?: boolean | undefined;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Y,CAAC,mCAAmC,IAAI,CAAC,CAChE;EAEA,OAAO;GACL,SAAS,KAAK,UAAU,KAAK,eAAe,KAAK;GACjD,QAAQ,KAAK;GACb,aAAa,KAAK,SAAS,MAAM,GAAG,KAAK,SAAS,SAAS;GAC3D,KAAK,SAAS,KAAK,+BAA+B,KAAK;GACvD,GAAG;EACL,CAAC,CAAC,KAAK,IAAI;CACb;AACF"}
@@ -0,0 +1,136 @@
1
+ import { Failed, Timeout, refuse, undispatched } from "./BrowserError.mjs";
2
+ import { monotonicMillis } from "./Clock.mjs";
3
+ import { Clock, Duration, Effect, Option, Schedule, Stream } from "effect";
4
+ import { jpegjs } from "playwright-core/lib/utilsBundle";
5
+ //#region src/stillness/Pixels.ts
6
+ /**
7
+ * Where a page's screen moves, from its screencast frames: each frame decoded and cut into
8
+ * 16-pixel blocks, a block moving where a few of its pixels, sampled every other one, changed by
9
+ * more than JPEG's noise in any color channel.
10
+ * What moved among the frames before an input is the page's background, such as an idle
11
+ * animation; foreground stillness ignores it.
12
+ *
13
+ * Frames use Playwright's bundled JPEG decoder. The package build ships that exact decoder
14
+ * alone, keeping its Node utility bundle out of Workers. Source runs use its native export,
15
+ * whose untyped entry point is declared by `utilsBundle.d.ts`.
16
+ */
17
+ const picture = (frame) => jpegjs.decode(frame.data, { useTArray: true });
18
+ /** A sample changed where any color channel moved more than this, beyond JPEG's noise. */
19
+ const noise = 32;
20
+ /** The blocks where two pictures differ, by `row * columns + column`; -1 for different sizes. */
21
+ const moved = (from, to) => {
22
+ if (from.width !== to.width || from.height !== to.height) return [-1];
23
+ const columns = Math.ceil(from.width / 16);
24
+ const counts = /* @__PURE__ */ new Map();
25
+ const differs = (at) => Math.abs((from.data[at] ?? 0) - (to.data[at] ?? 0)) > noise;
26
+ for (let y = 0; y < from.height; y += 2) for (let x = 0; x < from.width; x += 2) {
27
+ const at = (y * from.width + x) * 4;
28
+ const block = Math.floor(y / 16) * columns + Math.floor(x / 16);
29
+ if (differs(at) || differs(at + 1) || differs(at + 2)) counts.set(block, (counts.get(block) ?? 0) + 1);
30
+ }
31
+ return [...counts].flatMap(([block, count]) => count >= 3 ? [block] : []);
32
+ };
33
+ /** The blocks that moved from one picture to the next and their neighbours; none past a resize. */
34
+ const background = (pictures) => {
35
+ const columns = Math.ceil((pictures[0]?.width ?? 0) / 16);
36
+ const around = (block) => [
37
+ -1,
38
+ 0,
39
+ 1
40
+ ].flatMap((row) => [
41
+ -1,
42
+ 0,
43
+ 1
44
+ ].filter((step) => block >= 0 && block % columns + step >= 0).filter((step) => block % columns + step < columns).map((step) => block + row * columns + step));
45
+ return new Set(pictures.flatMap((to, index) => moved(pictures[index - 1] ?? to, to).flatMap(around)));
46
+ };
47
+ /** Whether anything moved from one picture to another outside the background. */
48
+ const stirs = (from, to, mask) => moved(from, to).some((block) => !mask.has(block));
49
+ //#endregion
50
+ //#region src/stillness/Stillness.ts
51
+ /** Screen and foreground stillness over the public page capture and owning clock. */
52
+ const observe = (page, options, timeout) => Effect.gen(function* () {
53
+ const now = () => monotonicMillis(page.clock);
54
+ const deadline = now() + Duration.toMillis(timeout);
55
+ const settled = () => page.ready({
56
+ quietMillis: options.quietMillis,
57
+ timeout: Duration.millis(Math.max(0, deadline - now()))
58
+ });
59
+ const quiet = (millis) => Effect.gen(function* () {
60
+ const capture = yield* page.capture();
61
+ const foreground = options.still === "foreground";
62
+ let counts = yield* capture.stats();
63
+ let stirred = now();
64
+ let reference;
65
+ const decoded = (frame) => Effect.try({
66
+ try: () => picture(frame),
67
+ catch: (error) => undispatched("ready", new Failed({ detail: `no picture: ${String(error)}` }))
68
+ });
69
+ const inputAt = (yield* page.recentEvents).findLast((event) => event._tag === "Action")?.startedAt ?? Number.NEGATIVE_INFINITY;
70
+ const document = (yield* page.state).document;
71
+ const before = (foreground ? yield* page.recentFrames : []).filter((frame) => frame.hostTime < inputAt && frame.hostTime >= inputAt - 1500 && frame.document === document);
72
+ const sampled = before.filter((_, index) => index % Math.ceil(before.length / 8) === 0);
73
+ const mask = background(yield* Effect.forEach(sampled, decoded));
74
+ const look = Effect.gen(function* () {
75
+ const stats = yield* capture.stats();
76
+ const latest = (yield* page.state).frame;
77
+ const arrived = stats.received !== counts.received;
78
+ const unseen = stats.accepted - counts.accepted;
79
+ counts = stats;
80
+ if (latest === void 0 || !capture.isCurrent(latest)) stirred = now();
81
+ else if (!foreground ? arrived || stats.ackBacklog > 0 : !arrived && stats.ackBacklog > 0) stirred = now();
82
+ else if (foreground && (unseen > 0 || reference === void 0)) {
83
+ const frames = (yield* page.recentFrames).slice(-Math.max(1, Math.min(8, unseen)));
84
+ if (unseen > frames.length) stirred = now();
85
+ for (const frame of frames) {
86
+ const seen = yield* decoded(frame);
87
+ if (reference === void 0 || stirs(reference, seen, mask)) {
88
+ reference = seen;
89
+ stirred = now();
90
+ }
91
+ }
92
+ }
93
+ return now() - stirred;
94
+ });
95
+ const spell = Effect.repeat(look, {
96
+ schedule: Schedule.fixed(Duration.millis(foreground ? 100 : 25)),
97
+ until: (still) => still >= millis
98
+ });
99
+ const still = Effect.gen(function* () {
100
+ for (;;) {
101
+ yield* spell;
102
+ const before = counts.received;
103
+ yield* Effect.all([settled(), capture.sync], {
104
+ concurrency: 2,
105
+ discard: true
106
+ });
107
+ if ((yield* look) >= millis && (foreground || counts.received === before)) return;
108
+ }
109
+ });
110
+ return yield* Effect.raceFirst(capture.stream.pipe(Stream.runDrain, Effect.andThen(Effect.never)), still);
111
+ });
112
+ yield* page.afterInput(Effect.void);
113
+ if (options.still === "content") {
114
+ yield* page.changes();
115
+ yield* Effect.sleep(Duration.millis(options.quietMillis));
116
+ return yield* settled();
117
+ }
118
+ yield* settled();
119
+ yield* quiet(options.quietMillis);
120
+ });
121
+ const wait = (page, options) => Effect.gen(function* () {
122
+ if (!Number.isFinite(options.quietMillis) || options.quietMillis < 0) return yield* refuse("stillness", "quietMillis must be finite and nonnegative");
123
+ const input = options.timeout ?? Duration.seconds(15);
124
+ const components = typeof input === "number" ? [input] : typeof input === "object" && !Duration.isDuration(input) ? Object.values(input) : [];
125
+ const timeout = Duration.fromInput(input);
126
+ if (components.some((value) => typeof value === "number" && !Number.isFinite(value)) || Option.isNone(timeout) || !Duration.isFinite(timeout.value) || Duration.isNegative(timeout.value)) return yield* refuse("stillness", "timeout must be a finite nonnegative duration");
127
+ const duration = timeout.value;
128
+ return yield* observe(page, options, duration).pipe(Effect.timeoutOrElse({
129
+ duration,
130
+ orElse: () => Effect.fail(undispatched("stillness", new Timeout({ millis: Duration.toMillis(duration) })))
131
+ }));
132
+ }).pipe(Effect.scoped, Effect.provideService(Clock.Clock, page.clock), Effect.withSpan("Stillness.wait"));
133
+ //#endregion
134
+ export { wait as t };
135
+
136
+ //# sourceMappingURL=Stillness-CNlvayIo.mjs.map
@@ -0,0 +1 @@
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,CAAC,SAAS,CAAC,OAAO,WAAY,SAAS,IAAI,CAAC,KAAK,IAAI,CAAC,CAAE;AAC5E;;AAGA,MAAa,cAAc,aAA0D;CACnF,MAAM,UAAU,KAAK,MAAM,SAAS,EAAE,EAAE,SAAS,KAAK,EAAE;CAExD,MAAM,UAAU,UACd;EAAC;EAAI;EAAG;CAAC,CAAC,CAAC,SAAS,QAClB;EAAC;EAAI;EAAG;CAAC,CA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AAa,aAAa,IAAI,QAAQ,EAAE,QAAQ,SAAS,SAAS,QAAQ,EAAE,CAAC,CAAC,CAChF;CACJ,CAAC,CACH;AACF,CAAC,CAAC,CAAC,KACD,OAAO,QACP,OAAO,eAAe,MAAM,OAAO,KAAK,KAAK,GAC7C,OAAO,SAAS,gBAAgB,CAClC"}
@@ -0,0 +1,357 @@
1
+ import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
2
+ import { normal } from "./Geometry.mjs";
3
+ import { InvalidRequest, refuse, undispatched } from "./BrowserError.mjs";
4
+ import { Context, Effect, Random, Schema } from "effect";
5
+ //#region src/internal/input/keys.ts
6
+ /**
7
+ * Key aliases for Playwright and printable US key descriptions for pipelined Chromium typing.
8
+ */
9
+ const aliases = {
10
+ ctrl: "Control",
11
+ control: "Control",
12
+ cmd: "Meta",
13
+ command: "Meta",
14
+ meta: "Meta",
15
+ win: "Meta",
16
+ super: "Meta",
17
+ mod: "ControlOrMeta",
18
+ alt: "Alt",
19
+ option: "Alt",
20
+ shift: "Shift",
21
+ enter: "Enter",
22
+ return: "Enter",
23
+ esc: "Escape",
24
+ escape: "Escape",
25
+ tab: "Tab",
26
+ space: "Space",
27
+ spacebar: "Space",
28
+ " ": "Space",
29
+ backspace: "Backspace",
30
+ delete: "Delete",
31
+ del: "Delete",
32
+ insert: "Insert",
33
+ home: "Home",
34
+ end: "End",
35
+ pageup: "PageUp",
36
+ pagedown: "PageDown",
37
+ up: "ArrowUp",
38
+ down: "ArrowDown",
39
+ left: "ArrowLeft",
40
+ right: "ArrowRight",
41
+ arrowup: "ArrowUp",
42
+ arrowdown: "ArrowDown",
43
+ arrowleft: "ArrowLeft",
44
+ arrowright: "ArrowRight"
45
+ };
46
+ const named = new Set(Object.values(aliases));
47
+ /** Parse and validate the whole chord before sending any down events. */
48
+ const parts = (keys) => {
49
+ const tokens = [];
50
+ let building = "";
51
+ for (const character of keys) if (character === "+" && building.trim() !== "") {
52
+ tokens.push(building);
53
+ building = "";
54
+ } else building += character;
55
+ tokens.push(building);
56
+ if (tokens.length > 4) return void 0;
57
+ const out = [];
58
+ for (const token of tokens) {
59
+ const part = token === " " ? "Space" : token.trim();
60
+ const lower = part.toLowerCase();
61
+ const alias = Object.hasOwn(aliases, lower) ? aliases[lower] : void 0;
62
+ if (alias !== void 0) out.push(alias);
63
+ else if (named.has(part) || /^F([1-9]|1[0-2])$/.test(part) || /^(Key[A-Z]|Digit[0-9]|Numpad[0-9])$/.test(part) || description(part) !== void 0) out.push(part);
64
+ else return void 0;
65
+ }
66
+ return out;
67
+ };
68
+ const punctuation = [
69
+ [
70
+ "`~",
71
+ "Backquote",
72
+ 192
73
+ ],
74
+ [
75
+ "-_",
76
+ "Minus",
77
+ 189
78
+ ],
79
+ [
80
+ "=+",
81
+ "Equal",
82
+ 187
83
+ ],
84
+ [
85
+ "\\|",
86
+ "Backslash",
87
+ 220
88
+ ],
89
+ [
90
+ "[{",
91
+ "BracketLeft",
92
+ 219
93
+ ],
94
+ [
95
+ "]}",
96
+ "BracketRight",
97
+ 221
98
+ ],
99
+ [
100
+ ";:",
101
+ "Semicolon",
102
+ 186
103
+ ],
104
+ [
105
+ "'\"",
106
+ "Quote",
107
+ 222
108
+ ],
109
+ [
110
+ ",<",
111
+ "Comma",
112
+ 188
113
+ ],
114
+ [
115
+ ".>",
116
+ "Period",
117
+ 190
118
+ ],
119
+ [
120
+ "/?",
121
+ "Slash",
122
+ 191
123
+ ],
124
+ [
125
+ " ",
126
+ "Space",
127
+ 32
128
+ ]
129
+ ];
130
+ /**
131
+ * Match Playwright's pinned US layout for literal typing. Uppercase and shifted punctuation
132
+ * carry their literal text without synthesizing Shift. Newlines also use insertText so a text
133
+ * payload cannot submit a form; only an explicit Enter or submit option may do that.
134
+ */
135
+ const description = (character) => {
136
+ if (character === "Backspace") return {
137
+ code: "Backspace",
138
+ keyCode: 8,
139
+ key: "Backspace",
140
+ text: ""
141
+ };
142
+ if (character.length !== 1) return void 0;
143
+ if (/^[A-Za-z]$/.test(character)) {
144
+ const upper = character.toUpperCase();
145
+ return {
146
+ code: `Key${upper}`,
147
+ keyCode: upper.charCodeAt(0),
148
+ key: character,
149
+ text: character
150
+ };
151
+ }
152
+ const digit = "0123456789".indexOf(character);
153
+ const number = digit === -1 ? ")!@#$%^&*(".indexOf(character) : digit;
154
+ if (number !== -1) return {
155
+ code: `Digit${number}`,
156
+ keyCode: 48 + number,
157
+ key: character,
158
+ text: character
159
+ };
160
+ const symbol = punctuation.find(([characters]) => characters.includes(character));
161
+ return symbol === void 0 ? void 0 : {
162
+ code: symbol[1],
163
+ keyCode: symbol[2],
164
+ key: character,
165
+ text: character
166
+ };
167
+ };
168
+ //#endregion
169
+ //#region src/Style.ts
170
+ /**
171
+ * How input is sent: plainly, as fast as the page takes it, or performed for viewers, with a
172
+ * pointer that glides, keys typed at a person's pace, held buttons and wheels in bursts. A page's
173
+ * actions take one, and the input reaches the same controls either way; only its timing, and
174
+ * what viewers see of it, differ. A presenter builds the performed one.
175
+ */
176
+ var Style_exports = /* @__PURE__ */ __exportAll({
177
+ Current: () => Current,
178
+ keyGap: () => keyGap,
179
+ maximumDurationMillis: () => maximumDurationMillis,
180
+ pause: () => pause,
181
+ performed: () => performed,
182
+ plain: () => plain,
183
+ provide: () => provide,
184
+ validated: () => validated
185
+ });
186
+ /** Each key as it comes, with no pause; a drag moves in eight short steps so its target sees it. */
187
+ const plain = {
188
+ shown: false,
189
+ pointer: void 0,
190
+ glide: (from, to, dragging) => Effect.succeed(dragging ? Array.from({ length: 8 }, (_, index) => ({
191
+ x: index === 7 ? to.x : from.x + (to.x - from.x) * (index + 1) / 8,
192
+ y: index === 7 ? to.y : from.y + (to.y - from.y) * (index + 1) / 8,
193
+ afterMillis: (index + 1) * 8
194
+ })) : [{
195
+ ...to,
196
+ afterMillis: 0
197
+ }]),
198
+ hold: Effect.succeed(0),
199
+ typing: (text, guarded) => Effect.succeed(guarded && text !== "" ? [{
200
+ afterMillis: 0,
201
+ phase: "insert",
202
+ key: text
203
+ }] : [...text].flatMap((key) => description(key) === void 0 ? [{
204
+ afterMillis: 0,
205
+ phase: "insert",
206
+ key
207
+ }] : [{
208
+ afterMillis: 0,
209
+ phase: "down",
210
+ key
211
+ }, {
212
+ afterMillis: 0,
213
+ phase: "up",
214
+ key
215
+ }])),
216
+ keyGap: Effect.succeed(0),
217
+ wheel: (dx, dy) => Effect.succeed([{
218
+ dx,
219
+ dy,
220
+ afterMillis: 0
221
+ }])
222
+ };
223
+ const lognormal = Effect.fnUntraced(function* (median, sigma, minimum, maximum) {
224
+ return Math.max(minimum, Math.min(maximum, median * Math.exp(sigma * (yield* normal))));
225
+ });
226
+ /** A pause around `median`, as the research measured reactions: at most four times it. */
227
+ const pause = (median, sigma) => median <= 0 ? Effect.succeed(0) : lognormal(median, sigma, 0, median * 4);
228
+ const pressHold = lognormal(75.2, .35, 35, 200);
229
+ const keyHold = lognormal(107.8, .2, 60, 220);
230
+ const eventOrder = {
231
+ up: 0,
232
+ insert: 1,
233
+ down: 2
234
+ };
235
+ /**
236
+ * Plan the whole text before any key goes, so holds overlap without waiting on the network. A
237
+ * physical key is never held twice, as with A and a, or ! and 1. The first key waits for the hand
238
+ * to reach the keys, each later one follows the last by a gap drawn around `gap`, and a word's
239
+ * first key comes 60 ms later.
240
+ */
241
+ const maximumDurationMillis = 1e4;
242
+ const Delay = Schema.Finite.check(Schema.isBetween({
243
+ minimum: 0,
244
+ maximum: maximumDurationMillis
245
+ }));
246
+ const ordered = (sample) => Schema.Array(sample).check(Schema.makeFilter((samples) => samples.every((event, index) => event.afterMillis >= (samples[index - 1]?.afterMillis ?? 0)), { expected: "nondecreasing input offsets" }));
247
+ const Typing = ordered(Schema.Struct({
248
+ afterMillis: Delay,
249
+ phase: Schema.Literals([
250
+ "down",
251
+ "up",
252
+ "insert"
253
+ ]),
254
+ key: Schema.String
255
+ })).check(Schema.makeFilter((events) => {
256
+ const held = /* @__PURE__ */ new Set();
257
+ for (const event of events) {
258
+ if (event.phase === "insert") continue;
259
+ const code = description(event.key)?.code;
260
+ if (code === void 0 || event.phase === "down" === held.has(code)) return false;
261
+ if (event.phase === "down") held.add(code);
262
+ else held.delete(code);
263
+ }
264
+ return held.size === 0;
265
+ }, { expected: "matched key holds" }));
266
+ const Wheel = ordered(Schema.Struct({
267
+ afterMillis: Delay,
268
+ dx: Schema.Finite,
269
+ dy: Schema.Finite
270
+ }));
271
+ const decode = (schema, operation) => (value) => Schema.decodeUnknownEffect(schema)(value).pipe(Effect.catch(() => refuse(operation, "style must provide a finite bounded ordered input schedule")));
272
+ /** Copy and validate custom schedules before their first input; planning uses the action bound. */
273
+ const validated = (style) => ({
274
+ ...style,
275
+ hold: style.hold.pipe(Effect.flatMap(decode(Delay, "click"))),
276
+ keyGap: style.keyGap.pipe(Effect.flatMap(decode(Delay, "press"))),
277
+ typing: (text, guarded) => style.typing(text, guarded).pipe(Effect.flatMap(decode(Typing, "type"))),
278
+ wheel: (dx, dy) => style.wheel(dx, dy).pipe(Effect.flatMap(decode(Wheel, "scroll")))
279
+ });
280
+ const overBudget = (operation) => undispatched(operation, new InvalidRequest({ detail: `presentation must take at most ${maximumDurationMillis} milliseconds` }));
281
+ const typing = Effect.fnUntraced(function* (text, gap) {
282
+ const events = [];
283
+ const releases = /* @__PURE__ */ new Map();
284
+ let due = text === "" ? 0 : yield* Random.nextBetween(150, 400);
285
+ let previous = "";
286
+ for (const character of text) {
287
+ if (due > 1e4) return yield* overBudget("type");
288
+ if (/\s/u.test(previous) && /[\p{L}\p{N}]/u.test(character)) due += 60;
289
+ const description$1 = description(character);
290
+ if (description$1 === void 0) events.push({
291
+ afterMillis: due,
292
+ phase: "insert",
293
+ key: character
294
+ });
295
+ else {
296
+ due = Math.max(due, (releases.get(description$1.code) ?? -1) + 1);
297
+ const released = due + (yield* keyHold);
298
+ events.push({
299
+ afterMillis: due,
300
+ phase: "down",
301
+ key: character
302
+ }, {
303
+ afterMillis: released,
304
+ phase: "up",
305
+ key: character
306
+ });
307
+ releases.set(description$1.code, released);
308
+ }
309
+ due += yield* Random.nextBetween(gap / 2, gap * 3 / 2);
310
+ previous = character;
311
+ }
312
+ if (events.some((event) => event.afterMillis > 1e4)) return yield* overBudget("type");
313
+ return events.toSorted((left, right) => left.afterMillis - right.afterMillis || eventOrder[left.phase] - eventOrder[right.phase]);
314
+ });
315
+ /** A word is five characters; the gap leaves room for each word's later start. */
316
+ const keyGap = (wordsPerMinute) => 12e3 / wordsPerMinute - 10;
317
+ /**
318
+ * The wheel in 100 px notches, 30 to 140 ms apart, in bursts of at most nine, with 0.6 to 2.6 s
319
+ * between bursts, as people scroll.
320
+ */
321
+ const bursts = Effect.fnUntraced(function* (dx, dy) {
322
+ const notches = Math.max(1, Math.ceil(Math.hypot(dx, dy) / 100));
323
+ if (notches > 334.3333333333333) return yield* overBudget("scroll");
324
+ const steps = [];
325
+ let due = 0;
326
+ for (let index = 0; index < notches; index++) {
327
+ if (index > 0) due += yield* index % 9 === 0 ? Random.nextBetween(600, 2600) : Random.nextBetween(30, 140);
328
+ if (due > 1e4) return yield* overBudget("scroll");
329
+ steps.push({
330
+ dx: dx / notches,
331
+ dy: dy / notches,
332
+ afterMillis: due
333
+ });
334
+ }
335
+ return steps;
336
+ });
337
+ /** Input performed for viewers, with this pointer and pace. */
338
+ const performed = (options) => {
339
+ const gap = keyGap(options.wordsPerMinute);
340
+ return {
341
+ shown: true,
342
+ pointer: options.pointer,
343
+ glide: (from, to) => options.motion.plan(from, to),
344
+ hold: pressHold,
345
+ typing: (text) => typing(text, gap),
346
+ keyGap: Random.nextBetween(gap / 2, gap * 3 / 2),
347
+ wheel: bursts
348
+ };
349
+ };
350
+ /** Input style in this fiber; plain input is the default. */
351
+ const Current = Context.Reference("effect-browser/Style", { defaultValue: () => plain });
352
+ /** Apply a style through page input, including pages selected later by a browser adapter. */
353
+ const provide = (style) => (effect) => Effect.provideService(effect, Current, style);
354
+ //#endregion
355
+ export { pause as a, provide as c, parts as d, maximumDurationMillis as i, validated as l, Style_exports as n, performed as o, keyGap as r, plain as s, Current as t, description as u };
356
+
357
+ //# sourceMappingURL=Style-AO4V7Czt.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Style-AO4V7Czt.mjs","names":["Keys.description","description"],"sources":["../src/internal/input/keys.ts","../src/Style.ts"],"sourcesContent":["/**\n * Key aliases for Playwright and printable US key descriptions for pipelined Chromium typing.\n */\n\nconst aliases: Record<string, string> = {\n ctrl: \"Control\",\n control: \"Control\",\n cmd: \"Meta\",\n command: \"Meta\",\n meta: \"Meta\",\n win: \"Meta\",\n super: \"Meta\",\n mod: \"ControlOrMeta\",\n alt: \"Alt\",\n option: \"Alt\",\n shift: \"Shift\",\n enter: \"Enter\",\n return: \"Enter\",\n esc: \"Escape\",\n escape: \"Escape\",\n tab: \"Tab\",\n space: \"Space\",\n spacebar: \"Space\",\n \" \": \"Space\",\n backspace: \"Backspace\",\n delete: \"Delete\",\n del: \"Delete\",\n insert: \"Insert\",\n home: \"Home\",\n end: \"End\",\n pageup: \"PageUp\",\n pagedown: \"PageDown\",\n up: \"ArrowUp\",\n down: \"ArrowDown\",\n left: \"ArrowLeft\",\n right: \"ArrowRight\",\n arrowup: \"ArrowUp\",\n arrowdown: \"ArrowDown\",\n arrowleft: \"ArrowLeft\",\n arrowright: \"ArrowRight\",\n};\n\nconst named = new Set(Object.values(aliases));\n\n/** Parse and validate the whole chord before sending any down events. */\nexport const parts = (keys: string): ReadonlyArray<string> | undefined => {\n const tokens: Array<string> = [];\n let building = \"\";\n\n // Like Playwright, a plus without a preceding token is the literal plus key: Control++.\n for (const character of keys) {\n if (character === \"+\" && building.trim() !== \"\") {\n tokens.push(building);\n building = \"\";\n } else building += character;\n }\n tokens.push(building);\n if (tokens.length > 4) return undefined;\n const out: Array<string> = [];\n\n for (const token of tokens) {\n const part = token === \" \" ? \"Space\" : token.trim();\n const lower = part.toLowerCase();\n const alias = Object.hasOwn(aliases, lower) ? aliases[lower] : undefined;\n\n if (alias !== undefined) out.push(alias);\n else if (\n named.has(part) ||\n /^F([1-9]|1[0-2])$/.test(part) ||\n /^(Key[A-Z]|Digit[0-9]|Numpad[0-9])$/.test(part) ||\n description(part) !== undefined\n )\n out.push(part);\n else return undefined;\n }\n\n return out;\n};\n\ninterface Description {\n readonly code: string;\n readonly keyCode: number;\n readonly key: string;\n readonly text: string;\n}\n\nconst punctuation: ReadonlyArray<readonly [string, string, number]> = [\n [\"`~\", \"Backquote\", 192],\n [\"-_\", \"Minus\", 189],\n [\"=+\", \"Equal\", 187],\n [\"\\\\|\", \"Backslash\", 220],\n [\"[{\", \"BracketLeft\", 219],\n [\"]}\", \"BracketRight\", 221],\n [\";:\", \"Semicolon\", 186],\n [\"'\\\"\", \"Quote\", 222],\n [\",<\", \"Comma\", 188],\n [\".>\", \"Period\", 190],\n [\"/?\", \"Slash\", 191],\n [\" \", \"Space\", 32],\n];\n\n/**\n * Match Playwright's pinned US layout for literal typing. Uppercase and shifted punctuation\n * carry their literal text without synthesizing Shift. Newlines also use insertText so a text\n * payload cannot submit a form; only an explicit Enter or submit option may do that.\n */\nexport const description = (character: string): Description | undefined => {\n // Prose correction uses the same raw key path so its deletion has a matched release.\n if (character === \"Backspace\")\n return { code: \"Backspace\", keyCode: 8, key: \"Backspace\", text: \"\" };\n if (character.length !== 1) return undefined;\n if (/^[A-Za-z]$/.test(character)) {\n const upper = character.toUpperCase();\n\n return { code: `Key${upper}`, keyCode: upper.charCodeAt(0), key: character, text: character };\n }\n const digit = \"0123456789\".indexOf(character);\n const number = digit === -1 ? \")!@#$%^&*(\".indexOf(character) : digit;\n\n if (number !== -1)\n return { code: `Digit${number}`, keyCode: 48 + number, key: character, text: character };\n const symbol = punctuation.find(([characters]) => characters.includes(character));\n\n return symbol === undefined\n ? undefined\n : { code: symbol[1], keyCode: symbol[2], key: character, text: character };\n};\n","/**\n * How input is sent: plainly, as fast as the page takes it, or performed for viewers, with a\n * pointer that glides, keys typed at a person's pace, held buttons and wheels in bursts. A page's\n * actions take one, and the input reaches the same controls either way; only its timing, and\n * what viewers see of it, differ. A presenter builds the performed one.\n */\nimport {\n Context,\n type Duration,\n Effect,\n type MutableRef,\n type Option,\n Random,\n Schema,\n} from \"effect\";\n\nimport { undispatched, type BrowserError, InvalidRequest, refuse } from \"./BrowserError.ts\";\nimport type * as Motion from \"./Geometry.ts\";\nimport { normal } from \"./Geometry.ts\";\nimport * as Keys from \"./internal/input/keys.ts\";\nimport type { Point } from \"./Page.ts\";\n\nexport interface TypingEvent {\n /** From the start of the typing. */\n readonly afterMillis: number;\n readonly phase: \"down\" | \"up\" | \"insert\";\n readonly key: string;\n}\n\nexport interface WheelStep {\n readonly dx: number;\n readonly dy: number;\n /** From the first step. */\n readonly afterMillis: number;\n}\n\nexport interface Style {\n /** Own presentation only after policy allows input; wait options belong to the page. */\n readonly withInput?:\n | ((options: {\n readonly operation: string;\n readonly wait: Duration.Duration;\n readonly failFast: boolean;\n }) => <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E | BrowserError, R>)\n | undefined;\n /**\n * Whether viewers watch the input: then the pointer clicks into a field before typing, finds\n * what lies under it as it scrolls, and scrolls to a target out of view with the wheel.\n */\n readonly shown: boolean;\n /** Where viewers last saw the pointer, which the next glide starts from; else the page's own. */\n readonly pointer: MutableRef.MutableRef<Option.Option<Point>> | undefined;\n /** The pointer's path to `to`, ending exactly there. */\n readonly glide: (\n from: Point,\n to: Point,\n dragging: boolean,\n ) => Effect.Effect<ReadonlyArray<Motion.Sample>>;\n /** How long a button stays down when a click does not say. */\n readonly hold: Effect.Effect<number, BrowserError>;\n /** The key events that type `text`, or one insertion of it under a guard, timed from the start. */\n readonly typing: (\n text: string,\n guarded: boolean,\n ) => Effect.Effect<ReadonlyArray<TypingEvent>, BrowserError>;\n /** The pause between repeated presses of the same keys. */\n readonly keyGap: Effect.Effect<number, BrowserError>;\n /** A wheel scroll as the wheel turns: in one step, or in notches and bursts. */\n readonly wheel: (dx: number, dy: number) => Effect.Effect<ReadonlyArray<WheelStep>, BrowserError>;\n}\n\n/** Each key as it comes, with no pause; a drag moves in eight short steps so its target sees it. */\nexport const plain: Style = {\n shown: false,\n pointer: undefined,\n glide: (from, to, dragging) =>\n Effect.succeed(\n dragging\n ? Array.from({ length: 8 }, (_, index) => ({\n x: index === 7 ? to.x : from.x + ((to.x - from.x) * (index + 1)) / 8,\n y: index === 7 ? to.y : from.y + ((to.y - from.y) * (index + 1)) / 8,\n afterMillis: (index + 1) * 8,\n }))\n : [{ ...to, afterMillis: 0 }],\n ),\n hold: Effect.succeed(0),\n typing: (text, guarded) =>\n Effect.succeed(\n guarded && text !== \"\"\n ? [{ afterMillis: 0, phase: \"insert\", key: text }]\n : [...text].flatMap((key): ReadonlyArray<TypingEvent> =>\n Keys.description(key) === undefined\n ? [{ afterMillis: 0, phase: \"insert\", key }]\n : [\n { afterMillis: 0, phase: \"down\", key },\n { afterMillis: 0, phase: \"up\", key },\n ],\n ),\n ),\n keyGap: Effect.succeed(0),\n wheel: (dx, dy) => Effect.succeed([{ dx, dy, afterMillis: 0 }]),\n};\n\n// A right-skewed draw, clamped so that cleanup and deadlines stay predictable; 1 - U keeps the\n// logarithm defined when Random returns zero.\nconst lognormal = Effect.fnUntraced(function* (\n median: number,\n sigma: number,\n minimum: number,\n maximum: number,\n) {\n return Math.max(minimum, Math.min(maximum, median * Math.exp(sigma * (yield* normal))));\n});\n\n/** A pause around `median`, as the research measured reactions: at most four times it. */\nexport const pause = (median: number, sigma: number) =>\n median <= 0 ? Effect.succeed(0) : lognormal(median, sigma, 0, median * 4);\n\n// A mouse press about 80 ms long on average, a key about 110 ms, each now and then longer: their\n// medians are the means times exp(-sigma^2 / 2).\nconst pressHold = lognormal(75.2, 0.35, 35, 200);\nconst keyHold = lognormal(107.8, 0.2, 60, 220);\nconst eventOrder = { up: 0, insert: 1, down: 2 };\n\n/**\n * Plan the whole text before any key goes, so holds overlap without waiting on the network. A\n * physical key is never held twice, as with A and a, or ! and 1. The first key waits for the hand\n * to reach the keys, each later one follows the last by a gap drawn around `gap`, and a word's\n * first key comes 60 ms later.\n */\nexport const maximumDurationMillis = 10_000;\n\nconst Delay = Schema.Finite.check(Schema.isBetween({ minimum: 0, maximum: maximumDurationMillis }));\n\nconst ordered = <A extends { readonly afterMillis: number }>(sample: Schema.Codec<A>) =>\n Schema.Array(sample).check(\n Schema.makeFilter(\n (samples) =>\n samples.every(\n (event, index) => event.afterMillis >= (samples[index - 1]?.afterMillis ?? 0),\n ),\n { expected: \"nondecreasing input offsets\" },\n ),\n );\n\nconst Typing = ordered(\n Schema.Struct({\n afterMillis: Delay,\n phase: Schema.Literals([\"down\", \"up\", \"insert\"]),\n key: Schema.String,\n }),\n).check(\n Schema.makeFilter(\n (events) => {\n const held = new Set<string>();\n\n for (const event of events) {\n if (event.phase === \"insert\") continue;\n const code = Keys.description(event.key)?.code;\n\n if (code === undefined || (event.phase === \"down\") === held.has(code)) return false;\n if (event.phase === \"down\") held.add(code);\n else held.delete(code);\n }\n\n return held.size === 0;\n },\n { expected: \"matched key holds\" },\n ),\n);\n\nconst Wheel = ordered(Schema.Struct({ afterMillis: Delay, dx: Schema.Finite, dy: Schema.Finite }));\n\nconst decode =\n <A>(schema: Schema.Codec<A>, operation: string) =>\n (value: unknown) =>\n Schema.decodeUnknownEffect(schema)(value).pipe(\n Effect.catch(() =>\n refuse(operation, \"style must provide a finite bounded ordered input schedule\"),\n ),\n );\n\n/** Copy and validate custom schedules before their first input; planning uses the action bound. */\nexport const validated = (style: Style): Style => ({\n ...style,\n hold: style.hold.pipe(Effect.flatMap(decode(Delay, \"click\"))),\n keyGap: style.keyGap.pipe(Effect.flatMap(decode(Delay, \"press\"))),\n typing: (text, guarded) =>\n style.typing(text, guarded).pipe(Effect.flatMap(decode(Typing, \"type\"))),\n wheel: (dx, dy) => style.wheel(dx, dy).pipe(Effect.flatMap(decode(Wheel, \"scroll\"))),\n});\n\nconst overBudget = (operation: string) =>\n undispatched(\n operation,\n new InvalidRequest({\n detail: `presentation must take at most ${maximumDurationMillis} milliseconds`,\n }),\n );\n\nconst typing = Effect.fnUntraced(function* (\n text: string,\n gap: number,\n): Effect.fn.Return<ReadonlyArray<TypingEvent>, BrowserError> {\n const events: Array<TypingEvent> = [];\n const releases = new Map<string, number>();\n let due = text === \"\" ? 0 : yield* Random.nextBetween(150, 400);\n let previous = \"\";\n\n for (const character of text) {\n if (due > maximumDurationMillis) return yield* overBudget(\"type\");\n if (/\\s/u.test(previous) && /[\\p{L}\\p{N}]/u.test(character)) due += 60;\n const description = Keys.description(character);\n\n if (description === undefined)\n events.push({ afterMillis: due, phase: \"insert\", key: character });\n else {\n due = Math.max(due, (releases.get(description.code) ?? -1) + 1);\n const released = due + (yield* keyHold);\n\n events.push(\n { afterMillis: due, phase: \"down\", key: character },\n { afterMillis: released, phase: \"up\", key: character },\n );\n releases.set(description.code, released);\n }\n due += yield* Random.nextBetween(gap / 2, (gap * 3) / 2);\n previous = character;\n }\n\n if (events.some((event) => event.afterMillis > maximumDurationMillis))\n return yield* overBudget(\"type\");\n\n return events.toSorted(\n (left, right) =>\n left.afterMillis - right.afterMillis || eventOrder[left.phase] - eventOrder[right.phase],\n );\n});\n\n/** A word is five characters; the gap leaves room for each word's later start. */\nexport const keyGap = (wordsPerMinute: number) => 12_000 / wordsPerMinute - 10;\n\n/**\n * The wheel in 100 px notches, 30 to 140 ms apart, in bursts of at most nine, with 0.6 to 2.6 s\n * between bursts, as people scroll.\n */\nconst bursts = Effect.fnUntraced(function* (dx: number, dy: number) {\n const notches = Math.max(1, Math.ceil(Math.hypot(dx, dy) / 100));\n\n // Even the shortest possible schedule exceeds the cap; refuse before allocating it.\n if (notches > 1 + maximumDurationMillis / 30) return yield* overBudget(\"scroll\");\n const steps: Array<WheelStep> = [];\n let due = 0;\n\n for (let index = 0; index < notches; index++) {\n if (index > 0)\n due += yield* index % 9 === 0 ? Random.nextBetween(600, 2600) : Random.nextBetween(30, 140);\n if (due > maximumDurationMillis) return yield* overBudget(\"scroll\");\n steps.push({ dx: dx / notches, dy: dy / notches, afterMillis: due });\n }\n\n return steps;\n});\n\n/** Input performed for viewers, with this pointer and pace. */\nexport const performed = (options: {\n readonly pointer: MutableRef.MutableRef<Option.Option<Point>>;\n readonly motion: Motion.Planner;\n readonly wordsPerMinute: number;\n}): Style => {\n const gap = keyGap(options.wordsPerMinute);\n\n return {\n shown: true,\n pointer: options.pointer,\n glide: (from, to) => options.motion.plan(from, to),\n hold: pressHold,\n typing: (text) => typing(text, gap),\n keyGap: Random.nextBetween(gap / 2, (gap * 3) / 2),\n wheel: bursts,\n };\n};\n\n/** Input style in this fiber; plain input is the default. */\nexport const Current = Context.Reference<Style>(\"effect-browser/Style\", {\n defaultValue: () => plain,\n});\n\n/** Apply a style through page input, including pages selected later by a browser adapter. */\nexport const provide =\n (style: Style) =>\n <A, E, R>(effect: Effect.Effect<A, E, R>) =>\n Effect.provideService(effect, Current, style);\n"],"mappings":";;;;;;;;AAIA,MAAM,UAAkC;CACtC,MAAM;CACN,SAAS;CACT,KAAK;CACL,SAAS;CACT,MAAM;CACN,KAAK;CACL,OAAO;CACP,KAAK;CACL,KAAK;CACL,QAAQ;CACR,OAAO;CACP,OAAO;CACP,QAAQ;CACR,KAAK;CACL,QAAQ;CACR,KAAK;CACL,OAAO;CACP,UAAU;CACV,KAAK;CACL,WAAW;CACX,QAAQ;CACR,KAAK;CACL,QAAQ;CACR,MAAM;CACN,KAAK;CACL,QAAQ;CACR,UAAU;CACV,IAAI;CACJ,MAAM;CACN,MAAM;CACN,OAAO;CACP,SAAS;CACT,WAAW;CACX,WAAW;CACX,YAAY;AACd;AAEA,MAAM,QAAQ,IAAI,IAAI,OAAO,OAAO,OAAO,CAAC;;AAG5C,MAAa,SAAS,SAAoD;CACxE,MAAM,SAAwB,CAAC;CAC/B,IAAI,WAAW;CAGf,KAAK,MAAM,aAAa,MACtB,IAAI,cAAc,OAAO,SAAS,KAAK,MAAM,IAAI;EAC/C,OAAO,KAAK,QAAQ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