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
package/dist/Site.mjs ADDED
@@ -0,0 +1,102 @@
1
+ import { addresses } from "./Url.mjs";
2
+ import { match, pickRequests, request } from "./Matching.mjs";
3
+ import { S as context, _ as elements, a as sight, b as expectations, c as history, d as walk, f as text, g as outline, h as ready, i as compose, l as fold, m as subjects, n as poseRequest, o as record, p as states, r as overlay, s as marks, t as pose, u as changes, v as names, x as controls, y as layout } from "./pose.inpage-CLq7Mfdr.mjs";
4
+ //#region src/Site.ts
5
+ /**
6
+ * The library's readers for a site that owns its page, called in the site's own bundle on its own
7
+ * document, with no protocol in it. It is the composition the library installs in a page over the
8
+ * protocol, so a site reads the same refs, subjects, outline, text, layout and changes as an agent
9
+ * does, draws in the same overlay, and poses elements the same way.
10
+ *
11
+ * What needs the protocol stays out:
12
+ *
13
+ * - trusted input and the checks that make it safe;
14
+ * - pictures;
15
+ * - held page time;
16
+ * - a record that starts before the page's own scripts.
17
+ *
18
+ * Instead, the site acts through its own app and `note`s each act, so the changes it brings name it
19
+ * as their cause. Time is real, so a pose or a drawing is set again on each animation frame. The
20
+ * record starts when the site calls `record`.
21
+ *
22
+ * Requests and results are the page script's own plain data. Boxes are in viewport CSS pixels, and
23
+ * a change's times are epoch milliseconds, as `performance.timeOrigin + performance.now()`. A
24
+ * request the page cannot serve answers `{ invalid }`, and a ref it no longer has `{ stale }`,
25
+ * rather than throwing. `Layout`, `Change` and `Snapshot` hold their schemas. The script runs in
26
+ * the site's own world, so it shares the globals the site's code may patch.
27
+ */
28
+ /**
29
+ * The readers, the change record, the overlay and poses for the current document. Make one for
30
+ * each document the site shows, and `stopRecord` the last one's.
31
+ */
32
+ const make = () => {
33
+ const { named, recorder, url, reads } = compose({
34
+ elements,
35
+ names,
36
+ walk,
37
+ match,
38
+ context,
39
+ subjects,
40
+ states,
41
+ expectations,
42
+ text,
43
+ layout,
44
+ controls,
45
+ fold,
46
+ history,
47
+ sight,
48
+ marks,
49
+ record,
50
+ changes,
51
+ ready,
52
+ outline,
53
+ overlay,
54
+ pose,
55
+ addresses
56
+ });
57
+ const own = overlay(named);
58
+ return {
59
+ /** What a query finds in the viewport: each element's ref, subject, box and state. */
60
+ find: (query) => reads.find(request(query, "viewport")),
61
+ /** Where each pick is, unrounded, with a box for each of the words it asks for. */
62
+ layout: (picks) => reads.layout(pickRequests(picks)),
63
+ /** Wait up to `millis` until what a query finds in the document is as wanted. */
64
+ until: (query, want, millis) => reads.until(request(query, "document"), want, millis),
65
+ /** The page as an outline of its subjects, each control with a ref. */
66
+ snapshot: reads.snapshot,
67
+ /** The text the viewport shows, or one element's. */
68
+ text: reads.text,
69
+ /** Wait up to `millis` for what the page is still loading, quiet for `quietMillis`. */
70
+ ready: (millis, quietMillis) => reads.ready(millis, quietMillis),
71
+ /** One task, then a frame; says whether the page painted. */
72
+ settle: reads.settle,
73
+ /** Record what changes from now, until `stopRecord`, or two minutes with no `changes`. */
74
+ record: reads.record,
75
+ stopRecord: reads.stopRecord,
76
+ /** Keep an act the site did through its app at `target` now, for changes to name as cause. */
77
+ note: recorder.note,
78
+ /** What changed in a window of the record, each change with its box. */
79
+ changes: reads.changes,
80
+ /** Draw an SVG document over the viewport, or take it away with null; says where its parts are. */
81
+ draw: reads.overlay,
82
+ /**
83
+ * A layer of the site's own over the viewport, which no reader reads and the record leaves
84
+ * out: a closed shadow root to render into. It takes no pointer, except parts that set
85
+ * `pointer-events: auto`.
86
+ */
87
+ layer: own.mount,
88
+ /** Pose these elements and take the pose off every other. */
89
+ pose: (poses) => reads.pose(poses.map(poseRequest)),
90
+ unpose: reads.unpose,
91
+ /** An element's ref, which `pose` and a read's `ref` take. */
92
+ ref: named.refFor,
93
+ /** The element a ref names, while it is in the document. */
94
+ element: named.lookup,
95
+ /** An address without its userinfo or the parameters known to carry secrets. */
96
+ redact: url.redact
97
+ };
98
+ };
99
+ //#endregion
100
+ export { make };
101
+
102
+ //# sourceMappingURL=Site.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Site.mjs","names":[],"sources":["../src/Site.ts"],"sourcesContent":["/**\n * The library's readers for a site that owns its page, called in the site's own bundle on its own\n * document, with no protocol in it. It is the composition the library installs in a page over the\n * protocol, so a site reads the same refs, subjects, outline, text, layout and changes as an agent\n * does, draws in the same overlay, and poses elements the same way.\n *\n * What needs the protocol stays out:\n *\n * - trusted input and the checks that make it safe;\n * - pictures;\n * - held page time;\n * - a record that starts before the page's own scripts.\n *\n * Instead, the site acts through its own app and `note`s each act, so the changes it brings name it\n * as their cause. Time is real, so a pose or a drawing is set again on each animation frame. The\n * record starts when the site calls `record`.\n *\n * Requests and results are the page script's own plain data. Boxes are in viewport CSS pixels, and\n * a change's times are epoch milliseconds, as `performance.timeOrigin + performance.now()`. A\n * request the page cannot serve answers `{ invalid }`, and a ref it no longer has `{ stale }`,\n * rather than throwing. `Layout`, `Change` and `Snapshot` hold their schemas. The script runs in\n * the site's own world, so it shares the globals the site's code may patch.\n */\nimport { compose } from \"./internal/page/compose.inpage.ts\";\nimport { overlay } from \"./internal/page/overlay.inpage.ts\";\nimport { pose, poseRequest } from \"./internal/page/pose.inpage.ts\";\nimport { context } from \"./internal/reading/context.inpage.ts\";\nimport { controls } from \"./internal/reading/controls.inpage.ts\";\nimport { expectations, type Want } from \"./internal/reading/expect.inpage.ts\";\nimport { layout } from \"./internal/reading/layout.inpage.ts\";\nimport { elements, names } from \"./internal/reading/names.inpage.ts\";\nimport { outline } from \"./internal/reading/outline.inpage.ts\";\nimport { ready } from \"./internal/reading/ready.inpage.ts\";\nimport { states, subjects } from \"./internal/reading/subjects.inpage.ts\";\nimport { text } from \"./internal/reading/text.inpage.ts\";\nimport { walk } from \"./internal/reading/walk.inpage.ts\";\nimport { changes } from \"./internal/timeline/changes.inpage.ts\";\nimport { fold } from \"./internal/timeline/fold.inpage.ts\";\nimport { history } from \"./internal/timeline/history.inpage.ts\";\nimport { marks } from \"./internal/timeline/marks.inpage.ts\";\nimport { record } from \"./internal/timeline/record.inpage.ts\";\nimport { sight } from \"./internal/timeline/sight.inpage.ts\";\nimport type { Picks } from \"./Layout.ts\";\nimport { match, pickRequests, request } from \"./Matching.ts\";\nimport type { FindQuery } from \"./Page.ts\";\nimport type { Pose } from \"./Pose.ts\";\nimport { addresses } from \"./Url.ts\";\n\n/**\n * The readers, the change record, the overlay and poses for the current document. Make one for\n * each document the site shows, and `stopRecord` the last one's.\n */\nexport const make = () => {\n const { named, recorder, url, reads } = compose({\n elements,\n names,\n walk,\n match,\n context,\n subjects,\n states,\n expectations,\n text,\n layout,\n controls,\n fold,\n history,\n sight,\n marks,\n record,\n changes,\n ready,\n outline,\n overlay,\n pose,\n addresses,\n });\n\n const own = overlay(named);\n\n return {\n /** What a query finds in the viewport: each element's ref, subject, box and state. */\n find: (query: FindQuery) => reads.find(request(query, \"viewport\")),\n /** Where each pick is, unrounded, with a box for each of the words it asks for. */\n layout: (picks: Picks) => reads.layout(pickRequests(picks)),\n /** Wait up to `millis` until what a query finds in the document is as wanted. */\n until: (query: FindQuery, want: Want, millis: number) =>\n reads.until(request(query, \"document\"), want, millis),\n /** The page as an outline of its subjects, each control with a ref. */\n snapshot: reads.snapshot,\n /** The text the viewport shows, or one element's. */\n text: reads.text,\n /** Wait up to `millis` for what the page is still loading, quiet for `quietMillis`. */\n ready: (millis: number, quietMillis?: number) => reads.ready(millis, quietMillis),\n /** One task, then a frame; says whether the page painted. */\n settle: reads.settle,\n /** Record what changes from now, until `stopRecord`, or two minutes with no `changes`. */\n record: reads.record,\n stopRecord: reads.stopRecord,\n /** Keep an act the site did through its app at `target` now, for changes to name as cause. */\n note: recorder.note,\n /** What changed in a window of the record, each change with its box. */\n changes: reads.changes,\n /** Draw an SVG document over the viewport, or take it away with null; says where its parts are. */\n draw: reads.overlay,\n /**\n * A layer of the site's own over the viewport, which no reader reads and the record leaves\n * out: a closed shadow root to render into. It takes no pointer, except parts that set\n * `pointer-events: auto`.\n */\n layer: own.mount,\n /** Pose these elements and take the pose off every other. */\n pose: (poses: ReadonlyArray<Pose>) => reads.pose(poses.map(poseRequest)),\n unpose: reads.unpose,\n /** An element's ref, which `pose` and a read's `ref` take. */\n ref: named.refFor,\n /** The element a ref names, while it is in the document. */\n element: named.lookup,\n /** An address without its userinfo or the parameters known to carry secrets. */\n redact: url.redact,\n };\n};\n\nexport type Site = ReturnType<typeof make>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoDA,MAAa,aAAa;CACxB,MAAM,EAAE,OAAO,UAAU,KAAK,UAAU,QAAQ;EAC9C;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;CAED,MAAM,MAAM,QAAQ,KAAK;CAEzB,OAAO;;EAEL,OAAO,UAAqB,MAAM,KAAK,QAAQ,OAAO,UAAU,CAAC;;EAEjE,SAAS,UAAiB,MAAM,OAAO,aAAa,KAAK,CAAC;;EAE1D,QAAQ,OAAkB,MAAY,WACpC,MAAM,MAAM,QAAQ,OAAO,UAAU,GAAG,MAAM,MAAM;;EAEtD,UAAU,MAAM;;EAEhB,MAAM,MAAM;;EAEZ,QAAQ,QAAgB,gBAAyB,MAAM,MAAM,QAAQ,WAAW;;EAEhF,QAAQ,MAAM;;EAEd,QAAQ,MAAM;EACd,YAAY,MAAM;;EAElB,MAAM,SAAS;;EAEf,SAAS,MAAM;;EAEf,MAAM,MAAM;;;;;;EAMZ,OAAO,IAAI;;EAEX,OAAO,UAA+B,MAAM,KAAK,MAAM,IAAI,WAAW,CAAC;EACvE,QAAQ,MAAM;;EAEd,KAAK,MAAM;;EAEX,SAAS,MAAM;;EAEf,QAAQ,IAAI;CACd;AACF"}
@@ -44,6 +44,18 @@ const background = (pictures) => {
44
44
  ].filter((step) => block >= 0 && block % columns + step >= 0).filter((step) => block % columns + step < columns).map((step) => block + row * columns + step));
45
45
  return new Set(pictures.flatMap((to, index) => moved(pictures[index - 1] ?? to, to).flatMap(around)));
46
46
  };
47
+ /**
48
+ * The blocks a picture's boxes cover, and those around them, for boxes in CSS pixels and `scale`
49
+ * picture pixels to a CSS pixel: where an overlay draws, which is not the page's motion.
50
+ */
51
+ const covering = (boxes, scale, picture) => {
52
+ const columns = Math.ceil(picture.width / 16);
53
+ const rows = Math.ceil(picture.height / 16);
54
+ const blocks = /* @__PURE__ */ new Set();
55
+ const block = (at, count) => Math.min(count - 1, Math.max(0, Math.floor(at / 16)));
56
+ for (const { x, y, width, height } of boxes) for (let row = block(y * scale, rows) - 1; row <= block((y + height) * scale, rows) + 1; row++) for (let column = block(x * scale, columns) - 1; column <= block((x + width) * scale, columns) + 1; column++) if (row >= 0 && row < rows && column >= 0 && column < columns) blocks.add(row * columns + column);
57
+ return blocks;
58
+ };
47
59
  /** Whether anything moved from one picture to another outside the background. */
48
60
  const stirs = (from, to, mask) => moved(from, to).some((block) => !mask.has(block));
49
61
  //#endregion
@@ -71,20 +83,29 @@ const observe = (page, options, timeout) => Effect.gen(function* () {
71
83
  const before = (foreground ? yield* page.recentFrames : []).filter((frame) => frame.hostTime < inputAt && frame.hostTime >= inputAt - 1500 && frame.document === document);
72
84
  const sampled = before.filter((_, index) => index % Math.ceil(before.length / 8) === 0);
73
85
  const mask = background(yield* Effect.forEach(sampled, decoded));
86
+ let width;
87
+ const covered = new Set(mask);
88
+ const outside = (seen, overlay) => Effect.gen(function* () {
89
+ if (overlay === void 0) return covered;
90
+ width ??= (yield* page.viewport).width;
91
+ for (const block of covering(overlay, seen.width / width, seen)) covered.add(block);
92
+ return covered;
93
+ });
74
94
  const look = Effect.gen(function* () {
75
95
  const stats = yield* capture.stats();
76
- const latest = (yield* page.state).frame;
96
+ const { frame: latest, overlay } = yield* page.state;
97
+ const comparing = foreground || overlay !== void 0;
77
98
  const arrived = stats.received !== counts.received;
78
99
  const unseen = stats.accepted - counts.accepted;
79
100
  counts = stats;
80
101
  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)) {
102
+ else if (!comparing ? arrived || stats.ackBacklog > 0 : !arrived && stats.ackBacklog > 0) stirred = now();
103
+ else if (comparing && (unseen > 0 || reference === void 0)) {
83
104
  const frames = (yield* page.recentFrames).slice(-Math.max(1, Math.min(8, unseen)));
84
105
  if (unseen > frames.length) stirred = now();
85
106
  for (const frame of frames) {
86
107
  const seen = yield* decoded(frame);
87
- if (reference === void 0 || stirs(reference, seen, mask)) {
108
+ if (reference === void 0 || stirs(reference, seen, yield* outside(seen, overlay))) {
88
109
  reference = seen;
89
110
  stirred = now();
90
111
  }
@@ -104,7 +125,7 @@ const observe = (page, options, timeout) => Effect.gen(function* () {
104
125
  concurrency: 2,
105
126
  discard: true
106
127
  });
107
- if ((yield* look) >= millis && (foreground || counts.received === before)) return;
128
+ if ((yield* look) >= millis && (foreground || (yield* page.state).overlay !== void 0 || counts.received === before)) return;
108
129
  }
109
130
  });
110
131
  return yield* Effect.raceFirst(capture.stream.pipe(Stream.runDrain, Effect.andThen(Effect.never)), still);
@@ -133,4 +154,4 @@ const wait = (page, options) => Effect.gen(function* () {
133
154
  //#endregion
134
155
  export { wait as t };
135
156
 
136
- //# sourceMappingURL=Stillness-CNlvayIo.mjs.map
157
+ //# sourceMappingURL=Stillness-BwP0RdI4.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Stillness-BwP0RdI4.mjs","names":["Motion.picture","Motion.background","Motion.covering","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 { Box } from \"../BrowserEvent.ts\";\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/**\n * The blocks a picture's boxes cover, and those around them, for boxes in CSS pixels and `scale`\n * picture pixels to a CSS pixel: where an overlay draws, which is not the page's motion.\n */\nexport const covering = (boxes: ReadonlyArray<Box>, scale: number, picture: Picture) => {\n const columns = Math.ceil(picture.width / 16);\n const rows = Math.ceil(picture.height / 16);\n const blocks = new Set<number>();\n\n const block = (at: number, count: number) =>\n Math.min(count - 1, Math.max(0, Math.floor(at / 16)));\n\n for (const { x, y, width, height } of boxes)\n for (let row = block(y * scale, rows) - 1; row <= block((y + height) * scale, rows) + 1; row++)\n for (\n let column = block(x * scale, columns) - 1;\n column <= block((x + width) * scale, columns) + 1;\n column++\n )\n if (row >= 0 && row < rows && column >= 0 && column < columns)\n blocks.add(row * columns + column);\n\n return blocks;\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 type { Box } from \"../BrowserEvent.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 // Where the page's overlay draws is not the page's motion: while it shows, frames are\n // compared, as in the foreground, outside everywhere it has drawn during the wait.\n let width: number | undefined;\n const covered = new Set(mask);\n\n const outside = (seen: Motion.Picture, overlay: ReadonlyArray<Box> | undefined) =>\n Effect.gen(function* () {\n if (overlay === undefined) return covered;\n width ??= (yield* page.viewport).width;\n for (const block of Motion.covering(overlay, seen.width / width, seen))\n covered.add(block);\n\n return covered;\n });\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 { frame: latest, overlay } = yield* page.state;\n const comparing = foreground || overlay !== undefined;\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 (!comparing ? arrived || stats.ackBacklog > 0 : !arrived && stats.ackBacklog > 0)\n stirred = now();\n else if (comparing && (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 (\n reference === undefined ||\n Motion.stirs(reference, seen, yield* outside(seen, overlay))\n ) {\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 (\n (yield* look) >= millis &&\n (foreground ||\n (yield* page.state).overlay !== undefined ||\n counts.received === before)\n )\n 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":";;;;;;;;;;;;;;;;AAqBA,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,OA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,OAAO,aAAa,4CAA4C;CAChF,MAAM,QAAQ,QAAQ,WAAW,SAAS,QAAQ,EAAE;CAEpD,MAAM,aACJ,OAAO,UAAU,WACb,CAAC,KAAK,IACN,OAAO,UAAU,YAAY,CAAC,SAAS,WAAW,KAAK,IACrD,OAAO,OAAO,KAAK,IACnB,CAAC;CAET,MAAM,UAAU,SAAS,UAAU,KAAK;CAExC,IACE,WAAW,MAAM,UAAU,OAAO,UAAU,YAAY,CAAC,OAAO,SAAS,KAAK,CAAC,KAC/E,OAAO,OAAO,OAAO,KACrB,CAAC,SAAS,SAAS,QAAQ,KAAK,KAChC,SAAS,WAAW,QAAQ,KAAK,GAEjC,OAAO,OAAO,OAAO,aAAa,+CAA+C;CACnF,MAAM,WAAW,QAAQ;CAEzB,OAAO,OAAO,QAAQ,MAAM,SAAS,QAAQ,CAAC,CAAC,KAC7C,OAAO,cAAc;EACnB;EACA,cACE,OAAO,KACL,aAAa,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"}
@@ -175,6 +175,7 @@ const description = (character) => {
175
175
  */
176
176
  var Style_exports = /* @__PURE__ */ __exportAll({
177
177
  Current: () => Current,
178
+ eased: () => eased,
178
179
  keyGap: () => keyGap,
179
180
  maximumDurationMillis: () => maximumDurationMillis,
180
181
  pause: () => pause,
@@ -334,6 +335,28 @@ const bursts = Effect.fnUntraced(function* (dx, dy) {
334
335
  }
335
336
  return steps;
336
337
  });
338
+ /**
339
+ * A wheel that eases over `durationMillis`: a step each frame, sixty a second, slow at first and
340
+ * last, so a scroll that viewers watch glides to where it goes. A style takes it as its `wheel`;
341
+ * a film scrolls on its own time instead.
342
+ */
343
+ const eased = (durationMillis) => (dx, dy) => {
344
+ if (!Number.isFinite(durationMillis) || durationMillis < 0) return refuse("scroll", "an eased scroll lasts a finite, nonnegative time");
345
+ if (durationMillis > 1e4) return Effect.fail(overBudget("scroll"));
346
+ const count = Math.max(1, Math.round(durationMillis * 60 / 1e3));
347
+ const along = (index) => {
348
+ const x = index / count;
349
+ return x * x * (3 - 2 * x);
350
+ };
351
+ return Effect.succeed(Array.from({ length: count }, (_, index) => {
352
+ const share = along(index + 1) - along(index);
353
+ return {
354
+ dx: dx * share,
355
+ dy: dy * share,
356
+ afterMillis: index * durationMillis / count
357
+ };
358
+ }));
359
+ };
337
360
  /** Input performed for viewers, with this pointer and pace. */
338
361
  const performed = (options) => {
339
362
  const gap = keyGap(options.wordsPerMinute);
@@ -352,6 +375,6 @@ const Current = Context.Reference("effect-browser/Style", { defaultValue: () =>
352
375
  /** Apply a style through page input, including pages selected later by a browser adapter. */
353
376
  const provide = (style) => (effect) => Effect.provideService(effect, Current, style);
354
377
  //#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 };
378
+ export { maximumDurationMillis as a, plain as c, description as d, parts as f, keyGap as i, provide as l, Style_exports as n, pause as o, eased as r, performed as s, Current as t, validated as u };
356
379
 
357
- //# sourceMappingURL=Style-AO4V7Czt.mjs.map
380
+ //# sourceMappingURL=Style-T3ezDYLI.mjs.map
@@ -1 +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;EACpB,WAAW;CACb,OAAO,YAAY;CAErB,OAAO,KAAK,QAAQ;CACpB,IAAI,OAAO,SAAS,GAAG,OAAO,KAAA;CAC9B,MAAM,MAAqB,CAAC;CAE5B,KAAK,MAAM,SAAS,QAAQ;EAC1B,MAAM,OAAO,UAAU,MAAM,UAAU,MAAM,KAAK;EAClD,MAAM,QAAQ,KAAK,YAAY;EAC/B,MAAM,QAAQ,OAAO,OAAO,SAAS,KAAK,IAAI,QAAQ,SAAS,KAAA;EAE/D,IAAI,UAAU,KAAA,GAAW,IAAI,KAAK,KAAK;OAClC,IACH,MAAM,IAAI,IAAI,KACd,oBAAoB,KAAK,IAAI,KAC7B,sCAAsC,KAAK,IAAI,KAC/C,YAAY,IAAI,MAAM,KAAA,GAEtB,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YLI.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 { ActionAnnounced } from \"./BrowserEvent.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 * Wait for this once an action has announced its target, before its pointer travels there. It\n * holds the page's turn and spends the action's deadline, which bounds it; the target is not\n * found again after it.\n */\n readonly lead?: ((announced: ActionAnnounced) => Effect.Effect<void>) | 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/**\n * A wheel that eases over `durationMillis`: a step each frame, sixty a second, slow at first and\n * last, so a scroll that viewers watch glides to where it goes. A style takes it as its `wheel`;\n * a film scrolls on its own time instead.\n */\nexport const eased =\n (durationMillis: number): Style[\"wheel\"] =>\n (dx, dy) => {\n if (!Number.isFinite(durationMillis) || durationMillis < 0)\n return refuse(\"scroll\", \"an eased scroll lasts a finite, nonnegative time\");\n if (durationMillis > maximumDurationMillis) return Effect.fail(overBudget(\"scroll\"));\n const count = Math.max(1, Math.round((durationMillis * 60) / 1000));\n\n // How far along the scroll is at the end of `index` steps, smoothly in and out.\n const along = (index: number) => {\n const x = index / count;\n\n return x * x * (3 - 2 * x);\n };\n\n return Effect.succeed(\n Array.from({ length: count }, (_, index) => {\n const share = along(index + 1) - along(index);\n\n return { dx: dx * share, dy: dy * share, afterMillis: (index * durationMillis) / count };\n }),\n );\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;C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Aa,YAIb;CACX,MAAM,MAAM,OAAO,QAAQ,cAAc;CAEzC,OAAO;EACL,OAAO;EACP,SAAS,QAAQ;EACjB,QAAQ,MAAM,OAAO,QAAQ,OAAO,KAAK,MAAM,EAAE;EACjD,MAAM;EACN,SAAS,SAAS,OAAO,MAAM,GAAG;EAClC,QAAQ,OAAO,YAAY,MAAM,GAAI,MAAM,IAAK,CAAC;EACjD,OAAO;CACT;AACF;;AAGA,MAAa,UAAU,QAAQ,UAAiB,wBAAwB,EACtE,oBAAoB,MACtB,CAAC;;AAGD,MAAa,WACV,WACS,WACR,OAAO,eAAe,QAAQ,SAAS,KAAK"}
package/dist/Style.d.mts CHANGED
@@ -1,9 +1,10 @@
1
1
  import { t as BrowserError } from "./BrowserError-BlcmLVzn.mjs";
2
+ import { n as ActionAnnounced } from "./BrowserEvent-C2p-NwuU.mjs";
2
3
  import { a as Sample, r as Planner, t as Geometry_d_exports } from "./Geometry-DJx9qrYy.mjs";
3
- import { m as Point } from "./Page-CvsOEorc.mjs";
4
+ import { h as Point } from "./Page-CLzh5E9w.mjs";
4
5
  import { Context, Duration, Effect, MutableRef, Option } from "effect";
5
6
  declare namespace Style_d_exports {
6
- export { Current, Style, TypingEvent, WheelStep, keyGap, maximumDurationMillis, pause, performed, plain, provide, validated };
7
+ export { Current, Style, TypingEvent, WheelStep, eased, keyGap, maximumDurationMillis, pause, performed, plain, provide, validated };
7
8
  }
8
9
  export interface TypingEvent {
9
10
  /** From the start of the typing. */
@@ -24,6 +25,12 @@ export interface Style {
24
25
  readonly wait: Duration.Duration;
25
26
  readonly failFast: boolean;
26
27
  }) => <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E | BrowserError, R>) | undefined;
28
+ /**
29
+ * Wait for this once an action has announced its target, before its pointer travels there. It
30
+ * holds the page's turn and spends the action's deadline, which bounds it; the target is not
31
+ * found again after it.
32
+ */
33
+ readonly lead?: ((announced: ActionAnnounced) => Effect.Effect<void>) | undefined;
27
34
  /**
28
35
  * Whether viewers watch the input: then the pointer clicks into a field before typing, finds
29
36
  * what lies under it as it scrolls, and scrolls to a target out of view with the wheel.
@@ -57,6 +64,12 @@ export declare const maximumDurationMillis = 10000;
57
64
  export declare const validated: (style: Style) => Style;
58
65
  /** A word is five characters; the gap leaves room for each word's later start. */
59
66
  export declare const keyGap: (wordsPerMinute: number) => number;
67
+ /**
68
+ * A wheel that eases over `durationMillis`: a step each frame, sixty a second, slow at first and
69
+ * last, so a scroll that viewers watch glides to where it goes. A style takes it as its `wheel`;
70
+ * a film scrolls on its own time instead.
71
+ */
72
+ export declare const eased: (durationMillis: number) => Style["wheel"];
60
73
  /** Input performed for viewers, with this pointer and pace. */
61
74
  export declare const performed: (options: {
62
75
  readonly pointer: MutableRef.MutableRef<Option.Option<Point>>;
package/dist/Style.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { a as pause, c as provide, i as maximumDurationMillis, l as validated, o as performed, r as keyGap, s as plain, t as Current } from "./Style-AO4V7Czt.mjs";
2
- export { Current, keyGap, maximumDurationMillis, pause, performed, plain, provide, validated };
1
+ import { a as maximumDurationMillis, c as plain, i as keyGap, l as provide, o as pause, r as eased, s as performed, t as Current, u as validated } from "./Style-T3ezDYLI.mjs";
2
+ export { Current, eased, keyGap, maximumDurationMillis, pause, performed, plain, provide, validated };
@@ -0,0 +1,26 @@
1
+ declare namespace Url_d_exports {
2
+ export { addresses, parse, quoted, redact, redactWithin, withheld };
3
+ }
4
+ /**
5
+ * Addresses: reading one the way a person types it, for `Page.goto` and the browser tools alike,
6
+ * and reporting one without the values that are credentials, by one rule that the page script runs
7
+ * too, for the outline's links.
8
+ */
9
+ /** The URL `input` names. Without a scheme it is a web address: HTTPS, or HTTP on loopback. */
10
+ declare const parse: (input: string) => URL | null;
11
+ /**
12
+ * The rule that reports an address without its credentials. The page script runs it too, so it
13
+ * stays self-contained, as `names.inpage.ts` says a page-side part must.
14
+ */
15
+ declare const addresses: () => {
16
+ withheld: "••••••••";
17
+ redact: (url: string) => string;
18
+ };
19
+ declare const withheld: "••••••••", redact: (url: string) => string;
20
+ /** An address inside text, as a failure's message quotes one. */
21
+ declare const quoted: RegExp;
22
+ /** `text` with each address in it redacted. */
23
+ declare const redactWithin: (text: string) => string;
24
+ //#endregion
25
+ export { redact as a, quoted as i, addresses as n, redactWithin as o, parse as r, withheld as s, Url_d_exports as t };
26
+ //# sourceMappingURL=Url-B7P-TWwL.d.mts.map
package/dist/Url.d.mts CHANGED
@@ -1,26 +1,2 @@
1
- declare namespace Url_d_exports {
2
- export { addresses, parse, quoted, redact, redactWithin, withheld };
3
- }
4
- /**
5
- * Addresses: reading one the way a person types it, for `Page.goto` and the browser tools alike,
6
- * and reporting one without the values that are credentials, by one rule that the page script runs
7
- * too, for the outline's links.
8
- */
9
- /** The URL `input` names. Without a scheme it is a web address: HTTPS, or HTTP on loopback. */
10
- export declare const parse: (input: string) => URL | null;
11
- /**
12
- * The rule that reports an address without its credentials. The page script runs it too, so it
13
- * stays self-contained, as `names.inpage.ts` says a page-side part must.
14
- */
15
- export declare const addresses: () => {
16
- withheld: "••••••••";
17
- redact: (url: string) => string;
18
- };
19
- export declare const withheld: "••••••••", redact: (url: string) => string;
20
- /** An address inside text, as a failure's message quotes one. */
21
- export declare const quoted: RegExp;
22
- /** `text` with each address in it redacted. */
23
- export declare const redactWithin: (text: string) => string;
24
- //#endregion
25
- export { Url_d_exports as t };
26
- //# sourceMappingURL=Url.d.mts.map
1
+ import { a as redact, i as quoted, n as addresses, o as redactWithin, r as parse, s as withheld } from "./Url-B7P-TWwL.mjs";
2
+ export { addresses, parse, quoted, redact, redactWithin, withheld };
@@ -1,6 +1,6 @@
1
1
  import { t as BrowserError } from "./BrowserError-BlcmLVzn.mjs";
2
- import { E as WheelScrolled, S as TextInserted, T as TrackPlanned, a as CursorChanged, c as Disconnected, d as PageClosed, f as PageLoaded, g as PointerReleased, h as PointerPressed, l as KeyChanged, m as PageUntracked, o as DialogShown, p as PageOpened, t as Action, u as Navigated, v as RequestRefused, w as TrackPerformed, y as SessionEnding } from "./BrowserEvent-lLqJ3GJS.mjs";
3
- import { r as Changes } from "./Change-Ba7INmay.mjs";
2
+ import { C as TextInserted, D as WheelScrolled, E as TrackPlanned, T as TrackPerformed, _ as PointerReleased, b as SessionEnding, d as Navigated, f as PageClosed, g as PointerPressed, h as PageUntracked, l as Disconnected, m as PageOpened, n as ActionAnnounced, o as CursorChanged, p as PageLoaded, s as DialogShown, t as Action, u as KeyChanged, y as RequestRefused } from "./BrowserEvent-C2p-NwuU.mjs";
3
+ import { r as Changes } from "./Change-CxT1mp2e.mjs";
4
4
  import { r as Frame } from "./Frame-UEH2hO5T.mjs";
5
5
  import { Schema } from "effect";
6
6
  declare namespace Window_d_exports {
@@ -13,7 +13,7 @@ declare const Window_base: Schema.Class<Window, Schema.Struct<{
13
13
  /** Where it ends, never after it was taken. */
14
14
  readonly until: Schema.Finite;
15
15
  /** The page's events after `since`, up to `until`, oldest first, without the input presentation track. */
16
- readonly events: Schema.$Array<Schema.Union<readonly [typeof RequestRefused, typeof PageOpened, typeof PageClosed, typeof PageUntracked, typeof Navigated, typeof PageLoaded, typeof Action, typeof TrackPlanned, typeof TrackPerformed, typeof PointerPressed, typeof PointerReleased, typeof WheelScrolled, typeof KeyChanged, typeof TextInserted, typeof CursorChanged, typeof DialogShown, typeof Disconnected, typeof SessionEnding]>>;
16
+ readonly events: Schema.$Array<Schema.Union<readonly [typeof RequestRefused, typeof PageOpened, typeof PageClosed, typeof PageUntracked, typeof Navigated, typeof PageLoaded, typeof Action, typeof ActionAnnounced, typeof TrackPlanned, typeof TrackPerformed, typeof PointerPressed, typeof PointerReleased, typeof WheelScrolled, typeof KeyChanged, typeof TextInserted, typeof CursorChanged, typeof DialogShown, typeof Disconnected, typeof SessionEnding]>>;
17
17
  /**
18
18
  * What visibly changed after `since`, up to `until`; absent where `missing` says why. A page's
19
19
  * first window starts its record, so the record sees none of it.
@@ -31,4 +31,4 @@ declare const Window_base: Schema.Class<Window, Schema.Struct<{
31
31
  declare class Window extends Window_base {}
32
32
  //#endregion
33
33
  export { Window_d_exports as n, Window as t };
34
- //# sourceMappingURL=Window-CMddGMt1.d.mts.map
34
+ //# sourceMappingURL=Window-BDa8MtNP.d.mts.map
package/dist/Window.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { t as Window } from "./Window-CMddGMt1.mjs";
1
+ import { t as Window } from "./Window-BDa8MtNP.mjs";
2
2
  export { Window };
@@ -1,6 +1,6 @@
1
1
  import { quoted } from "./Url.mjs";
2
2
  import { InvalidRequest, Timeout, reasonOf, undispatched } from "./BrowserError.mjs";
3
- import { i as make$1, t as Browser } from "./Browser-BKPAbyys.mjs";
3
+ import { i as make$1, t as Browser } from "./Browser-CAQFhTkM.mjs";
4
4
  import { Effect, Layer, Redacted } from "effect";
5
5
  //#region src/providers/connection.ts
6
6
  /**
@@ -65,4 +65,4 @@ const make = (defaultConnect) => {
65
65
  //#endregion
66
66
  export { make as t };
67
67
 
68
- //# sourceMappingURL=connection-CK83pvqP.mjs.map
68
+ //# sourceMappingURL=connection-C_jWYIwe.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"connection-CK83pvqP.mjs","names":["Errors.InvalidRequest","Url.quoted","Errors.Timeout","Browser.make","Browser.Browser"],"sources":["../src/providers/connection.ts"],"sourcesContent":["/**\n * A browser reached over the Chrome DevTools Protocol: a Chrome started with\n * `--remote-debugging-port`, or any provider that hands out a CDP WebSocket URL.\n *\n * Closing the scope disconnects. It does not close the remote browser; its owner does that.\n *\n * @since 0.3.0\n */\nimport { type DateTime, Effect, Layer, Redacted } from \"effect\";\nimport type { Browser as PlaywrightBrowser } from \"playwright-core\";\n\nimport * as Browser from \"../Browser.ts\";\nimport * as Errors from \"../BrowserError.ts\";\nimport { reasonOf, undispatched } from \"../BrowserError.ts\";\nimport * as Url from \"../Url.ts\";\n\n/** The runtime connector receives the bound and cancellation signal owned by the opening scope. */\nexport interface ConnectOptions {\n readonly timeout: number;\n readonly headers?: Readonly<Record<string, string>> | undefined;\n readonly signal: AbortSignal;\n}\n\n/**\n * Return a real Playwright CDP browser whose `close()` disconnects without ending the remote\n * browser. Honor `signal` to cancel work; a browser returned after cancellation is disconnected.\n * The endpoint and headers may contain credentials and must not be logged.\n */\nexport type Connector = (endpoint: string, options: ConnectOptions) => Promise<PlaywrightBrowser>;\n\nexport interface Options extends Browser.Options, Pick<ConnectOptions, \"headers\"> {\n /**\n * `ws://`, `wss://` or `http://` DevTools endpoint. Often a credential, so it may be redacted;\n * connect failures never include its userinfo, path or query.\n */\n readonly endpoint: string | Redacted.Redacted<string>;\n /** Runtime-supplied Playwright connection. Required by the `workerd` entry. */\n readonly connect?: Connector | undefined;\n /** Identifies the session in `Browser.id`. Defaults to `\"cdp\"`. */\n readonly id?: string | undefined;\n readonly provider?: string | undefined;\n /** Bound on connecting. Defaults to 30 seconds. */\n readonly connectTimeoutMillis?: number | undefined;\n /** When the provider ends the session on its own, as a hosted session's timeout does. */\n readonly expiresAt?: DateTime.Utc | undefined;\n /**\n * A connection apart from this one for the pages' screencasts, as a hosted provider supplies.\n * Without one, each page's capture runs on its own session.\n */\n readonly capture?: Browser.CaptureSource | undefined;\n}\n\n/** Runtime facades supply the default transport; the shared lifetime imports no Node transport. */\nexport const make = (defaultConnect?: Connector) => {\n const open = Effect.fn(\"Cdp.open\")(function* (options: Options) {\n const endpoint = Redacted.isRedacted(options.endpoint)\n ? Redacted.value(options.endpoint)\n : options.endpoint;\n\n const timeout = options.connectTimeoutMillis ?? 30_000;\n const connector = options.connect ?? defaultConnect;\n const headers = options.headers === undefined ? undefined : { ...options.headers };\n\n const invalid = (detail: string) =>\n undispatched(\"connect\", new Errors.InvalidRequest({ detail }));\n\n if (!Number.isFinite(timeout) || timeout <= 0)\n return yield* invalid(\"connectTimeoutMillis must be finite and greater than zero\");\n if (connector === undefined)\n return yield* invalid(\"This runtime requires a CDP connect callback\");\n\n // Inspect before URL normalization or truncation. Withhold an echoed diagnostic entirely so\n // overlapping header values cannot leave fragments; other URLs keep only their scheme and host.\n const redact = (message: string) => {\n if (Object.values(headers ?? {}).some((value) => value !== \"\" && message.includes(value)))\n return \"CDP diagnostic withheld\";\n\n const origins = message.replace(Url.quoted, (url) => {\n const parsed = URL.parse(url);\n\n return parsed?.host ? `${parsed.protocol}//${parsed.host}` : \"<url>\";\n });\n\n return endpoint === \"\" ? origins : origins.replaceAll(endpoint, \"<endpoint>\");\n };\n\n const failed = (cause: unknown, timeoutMillis?: number) =>\n undispatched(\"connect\", reasonOf(cause, timeoutMillis, \"connection\", redact));\n\n // The endpoint is often a credential, so the connect span names no part of it.\n const connected = yield* Effect.acquireRelease(\n Effect.tryPromise({\n try: (signal) =>\n connector(endpoint, {\n timeout,\n signal,\n ...(headers === undefined ? {} : { headers: { ...headers } }),\n }).then(async (browser) => {\n // Cancellation can precede a connector that ignores its signal. Its late browser still\n // belongs to this acquisition, so disconnect it before dropping the promise result.\n if (signal.aborted) await browser.close().catch(() => undefined);\n\n return browser;\n }),\n catch: (cause) => failed(cause, timeout),\n }).pipe(\n Effect.timeoutOrElse({\n duration: timeout,\n orElse: () =>\n Effect.fail(undispatched(\"connect\", new Errors.Timeout({ millis: timeout }))),\n }),\n Effect.withSpan(\"Cdp.connect\", {}, { captureStackTrace: false }),\n ),\n (browser) => Effect.tryPromise(() => browser.close()).pipe(Effect.ignore),\n { interruptible: true },\n );\n\n const context =\n connected.contexts()[0] ??\n (yield* Effect.tryPromise({\n try: () => connected.newContext(),\n catch: (cause) => failed(cause),\n }));\n\n const { id = \"cdp\", provider = \"cdp\", expiresAt, capture } = options;\n\n return yield* Browser.make(context, { id, provider, expiresAt, capture }, options);\n });\n\n const layer = (options: Options): Layer.Layer<Browser.Browser, Errors.BrowserError> =>\n Layer.effect(Browser.Browser, open(options));\n\n return { open, layer };\n};\n"],"mappings":";;;;;;;;;;;;;;AAqDA,MAAa,QAAQ,mBAA+B;CAClD,MAAM,OAAO,OAAO,GAAG,UAAU,CAAC,CAA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AQ,UAAU,OAAO,OAAO,OAAO;EACzC,CAAC,CAAC,CAAC,KACD,OAAO,cAAc;GACnB,UAAU;GACV,cACE,OAAO,KAAK,aAAa,WAAW,IAAIC,QAAe,EAAE,QAAQ,QAAQ,CAAC,CAAC,CAAC;EAChF,CAAC,GACD,OAAO,SAAS,eAAe,CAAC,GAAG,EAAE,mBAAmB,MAAM,CAAC,CACjE,IACC,YAAY,OAAO,iBAAiB,QAAQ,MAAM,CAAC,CAAC,CAAC,KAAK,OAAO,MAAM,GACxE,EAAE,eAAe,KAAK,CACxB;EAEA,MAAM,UACJ,UAAU,SAAS,CAAC,CAAC,OACpB,OAAO,OAAO,WAAW;GACxB,WAAW,UAAU,WAAW;GAChC,QAAQ,UAAU,OAAO,KAAK;EAChC,CAAC;EAEH,MAAM,EAAE,KAAK,OAAO,WAAW,OAAO,WAAW,YAAY;EAE7D,OAAO,OAAOC,OAAa,SAAS;GAAE;GAAI;GAAU;GAAW;EAAQ,GAAG,OAAO;CACnF,CAAC;CAED,MAAM,SAAS,YACb,MAAM,OAAOC,SAAiB,KAAK,OAAO,CAAC;CAE7C,OAAO;EAAE;EAAM;CAAM;AACvB"}
1
+ {"version":3,"file":"connection-C_jWYIwe.mjs","names":["Errors.InvalidRequest","Url.quoted","Errors.Timeout","Browser.make","Browser.Browser"],"sources":["../src/providers/connection.ts"],"sourcesContent":["/**\n * A browser reached over the Chrome DevTools Protocol: a Chrome started with\n * `--remote-debugging-port`, or any provider that hands out a CDP WebSocket URL.\n *\n * Closing the scope disconnects. It does not close the remote browser; its owner does that.\n *\n * @since 0.3.0\n */\nimport { type DateTime, Effect, Layer, Redacted } from \"effect\";\nimport type { Browser as PlaywrightBrowser } from \"playwright-core\";\n\nimport * as Browser from \"../Browser.ts\";\nimport * as Errors from \"../BrowserError.ts\";\nimport { reasonOf, undispatched } from \"../BrowserError.ts\";\nimport * as Url from \"../Url.ts\";\n\n/** The runtime connector receives the bound and cancellation signal owned by the opening scope. */\nexport interface ConnectOptions {\n readonly timeout: number;\n readonly headers?: Readonly<Record<string, string>> | undefined;\n readonly signal: AbortSignal;\n}\n\n/**\n * Return a real Playwright CDP browser whose `close()` disconnects without ending the remote\n * browser. Honor `signal` to cancel work; a browser returned after cancellation is disconnected.\n * The endpoint and headers may contain credentials and must not be logged.\n */\nexport type Connector = (endpoint: string, options: ConnectOptions) => Promise<PlaywrightBrowser>;\n\nexport interface Options extends Browser.Options, Pick<ConnectOptions, \"headers\"> {\n /**\n * `ws://`, `wss://` or `http://` DevTools endpoint. Often a credential, so it may be redacted;\n * connect failures never include its userinfo, path or query.\n */\n readonly endpoint: string | Redacted.Redacted<string>;\n /** Runtime-supplied Playwright connection. Required by the `workerd` entry. */\n readonly connect?: Connector | undefined;\n /** Identifies the session in `Browser.id`. Defaults to `\"cdp\"`. */\n readonly id?: string | undefined;\n readonly provider?: string | undefined;\n /** Bound on connecting. Defaults to 30 seconds. */\n readonly connectTimeoutMillis?: number | undefined;\n /** When the provider ends the session on its own, as a hosted session's timeout does. */\n readonly expiresAt?: DateTime.Utc | undefined;\n /**\n * A connection apart from this one for the pages' screencasts, as a hosted provider supplies.\n * Without one, each page's capture runs on its own session.\n */\n readonly capture?: Browser.CaptureSource | undefined;\n}\n\n/** Runtime facades supply the default transport; the shared lifetime imports no Node transport. */\nexport const make = (defaultConnect?: Connector) => {\n const open = Effect.fn(\"Cdp.open\")(function* (options: Options) {\n const endpoint = Redacted.isRedacted(options.endpoint)\n ? Redacted.value(options.endpoint)\n : options.endpoint;\n\n const timeout = options.connectTimeoutMillis ?? 30_000;\n const connector = options.connect ?? defaultConnect;\n const headers = options.headers === undefined ? undefined : { ...options.headers };\n\n const invalid = (detail: string) =>\n undispatched(\"connect\", new Errors.InvalidRequest({ detail }));\n\n if (!Number.isFinite(timeout) || timeout <= 0)\n return yield* invalid(\"connectTimeoutMillis must be finite and greater than zero\");\n if (connector === undefined)\n return yield* invalid(\"This runtime requires a CDP connect callback\");\n\n // Inspect before URL normalization or truncation. Withhold an echoed diagnostic entirely so\n // overlapping header values cannot leave fragments; other URLs keep only their scheme and host.\n const redact = (message: string) => {\n if (Object.values(headers ?? {}).some((value) => value !== \"\" && message.includes(value)))\n return \"CDP diagnostic withheld\";\n\n const origins = message.replace(Url.quoted, (url) => {\n const parsed = URL.parse(url);\n\n return parsed?.host ? `${parsed.protocol}//${parsed.host}` : \"<url>\";\n });\n\n return endpoint === \"\" ? origins : origins.replaceAll(endpoint, \"<endpoint>\");\n };\n\n const failed = (cause: unknown, timeoutMillis?: number) =>\n undispatched(\"connect\", reasonOf(cause, timeoutMillis, \"connection\", redact));\n\n // The endpoint is often a credential, so the connect span names no part of it.\n const connected = yield* Effect.acquireRelease(\n Effect.tryPromise({\n try: (signal) =>\n connector(endpoint, {\n timeout,\n signal,\n ...(headers === undefined ? {} : { headers: { ...headers } }),\n }).then(async (browser) => {\n // Cancellation can precede a connector that ignores its signal. Its late browser still\n // belongs to this acquisition, so disconnect it before dropping the promise result.\n if (signal.aborted) await browser.close().catch(() => undefined);\n\n return browser;\n }),\n catch: (cause) => failed(cause, timeout),\n }).pipe(\n Effect.timeoutOrElse({\n duration: timeout,\n orElse: () =>\n Effect.fail(undispatched(\"connect\", new Errors.Timeout({ millis: timeout }))),\n }),\n Effect.withSpan(\"Cdp.connect\", {}, { captureStackTrace: false }),\n ),\n (browser) => Effect.tryPromise(() => browser.close()).pipe(Effect.ignore),\n { interruptible: true },\n );\n\n const context =\n connected.contexts()[0] ??\n (yield* Effect.tryPromise({\n try: () => connected.newContext(),\n catch: (cause) => failed(cause),\n }));\n\n const { id = \"cdp\", provider = \"cdp\", expiresAt, capture } = options;\n\n return yield* Browser.make(context, { id, provider, expiresAt, capture }, options);\n });\n\n const layer = (options: Options): Layer.Layer<Browser.Browser, Errors.BrowserError> =>\n Layer.effect(Browser.Browser, open(options));\n\n return { open, layer };\n};\n"],"mappings":";;;;;;;;;;;;;;AAqDA,MAAa,QAAQ,mBAA+B;CAClD,MAAM,OAAO,O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D,OAAO;GACT,CAAC;GACH,QAAQ,UAAU,OAAO,OAAO,OAAO;EACzC,CAAC,CAAC,CAAC,KACD,OAAO,cAAc;GACnB,UAAU;GACV,cACE,OAAO,KAAK,aAAa,WAAW,IAAIC,QAAe,EAAE,QAAQ,QAAQ,CAAC,CAAC,CAAC;EAChF,CAAC,GACD,OAAO,SAAS,eAAe,CAAC,GAAG,EAAE,mBAAmB,MAAM,CAAC,CACjE,IACC,YAAY,OAAO,iBAAiB,QAAQ,MAAM,CAAC,CAAC,CAAC,KAAK,OAAO,MAAM,GACxE,EAAE,eAAe,KAAK,CACxB;EAEA,MAAM,UACJ,UAAU,SAAS,CAAC,CAAC,OACpB,OAAO,OAAO,WAAW;GACxB,WAAW,UAAU,WAAW;GAChC,QAAQ,UAAU,OAAO,KAAK;EAChC,CAAC;EAEH,MAAM,EAAE,KAAK,OAAO,WAAW,OAAO,WAAW,YAAY;EAE7D,OAAO,OAAOC,OAAa,SAAS;GAAE;GAAI;GAAU;GAAW;EAAQ,GAAG,OAAO;CACnF,CAAC;CAED,MAAM,SAAS,YACb,MAAM,OAAOC,SAAiB,KAAK,OAAO,CAAC;CAE7C,OAAO;EAAE;EAAM;CAAM;AACvB"}
@@ -1,5 +1,5 @@
1
1
  import "./BrowserError-BlcmLVzn.mjs";
2
- import { n as Browser_d_exports, o as Options$1, r as CaptureSource } from "./Browser-wZhwZSlG.mjs";
2
+ import { n as Browser_d_exports, o as Options$1, r as CaptureSource } from "./Browser-DGR6ZEYo.mjs";
3
3
  import { DateTime, Effect, Layer, Redacted } from "effect";
4
4
  import { Browser } from "playwright-core";
5
5
  //#region src/providers/connection.d.ts
@@ -38,4 +38,4 @@ interface Options extends Options$1, Pick<ConnectOptions, "headers"> {
38
38
  }
39
39
  //#endregion
40
40
  export { Connector as n, Options as r, ConnectOptions as t };
41
- //# sourceMappingURL=connection-2KHI4_KN.d.mts.map
41
+ //# sourceMappingURL=connection-Db-YtlbE.d.mts.map