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/README.md CHANGED
@@ -3,8 +3,10 @@
3
3
  Browser automation for [Effect](https://effect.website) agents, over Playwright: page control, a
4
4
  compact page outline for models, screencast frames, a record of what visibly changed on a page,
5
5
  windows over a page's events, changes and frames, and moments, an account in pictures and words of
6
- what a page showed and what changed on it. An agent drives its pages through
7
- [`effect-agent-browser`](../agent-browser), with Yielded Agent's browser tools.
6
+ what a page showed and what changed on it. It films pages on their own held time, with layout as
7
+ data, an overlay, element poses and input on its frame, and gives its in-page readers to a site that
8
+ owns its page. An agent drives its pages through [`effect-agent-browser`](../agent-browser), with
9
+ Yielded Agent's browser tools.
8
10
 
9
11
  ```sh
10
12
  npm install effect-browser@beta effect playwright-core
@@ -34,6 +36,12 @@ with it, since its pipe closes, but leaves Playwright's temporary profile behind
34
36
  | `Motion` | A bounded pointer planner, as a value, and the tuned sigma-lognormal one |
35
37
  | `Presentation` | Input performed for viewers: a presenter, and its views of pages |
36
38
  | `Stage` | The source of a live output, switched between pages and stamped |
39
+ | `Layout` | Where picked things and their words are on a page, as data, and rehearsals |
40
+ | `Overlay` | A layer over a page that the library draws a caller's SVG into and never reads |
41
+ | `PageTime` | A page's own time, held and stepped, with its scroll, poses and overlay |
42
+ | `Pose` | A page's own elements moved, turned and scaled about a point |
43
+ | `Film` | A page filmed as a function of time: frames, inputs on their frames, passages |
44
+ | `Site` | The readers, change record, overlay and poses, run by a site on its own page |
37
45
  | `BrowserError` | Typed failures, whether input reached the page first, and what each leaves |
38
46
  | `Policy` | Judges that read what an input means, and a guard that acts on them unattended |
39
47
  | `Change` | What visibly changed on a page over a window, element by element |
@@ -261,7 +269,8 @@ the page, element by element, as a `Change`: text that changed, appeared, disapp
261
269
  went (`brief`), a field's value, or the title. Each says what it showed at the window's start and
262
270
  end, how often that changed, the lowest and highest of a number that changed more than once, when
263
271
  it last changed before the window, so news stands apart from what keeps changing, and its
264
- `subject` with the context that binds it: a price under its row and column. A field's value reads
272
+ `subject` with the context that binds it: a price under its row and column, and its `box`, where it
273
+ is as the changes are read, or for what went, where what it sat in is. A field's value reads
265
274
  `••••` unless `unmask` is set, and a secret field's always does. A change names its `cause`, the
266
275
  trusted input it followed, only where it was that input's doing. It must not have been in flux: in
267
276
  the 10 s before the input it had not changed, and nothing had come into or left what it sits in, so
@@ -529,6 +538,24 @@ At most 2,112 input commands and reservations are owned at once; ordinary input
529
538
  64-command admission limit. Actions still await their replies before succeeding, and interruption
530
539
  stops the unsent suffix and releases held input.
531
540
 
541
+ An action announces its target before its pointer travels there. Once it has found the target, it
542
+ publishes `ActionAnnounced`, with the action's name and `correlation`, the target's `subject` and
543
+ `box`, and the point the pointer goes to. A glide that only scrolls a target into view comes
544
+ before the target is found, so it is not announced. Input with no pointer travel announces
545
+ nothing, for example keys, or typing into the focused field.
546
+
547
+ A presenter's `lead` runs after the announcement and before the glide:
548
+
549
+ ```ts
550
+ const presenter = yield * Presentation.make({ lead: (announced) => performer.arrive(announced) });
551
+ ```
552
+
553
+ Use it to give whatever is shown performing the input, such as a character, time to arrive. It
554
+ runs after the reaction's wait. It holds the page's turn, and it counts against the action's
555
+ deadline: a lead that has not finished by then fails the action with `Timeout`, and no input is
556
+ sent. The target is not found again after the lead, so a page that moves meanwhile is pressed
557
+ where the target was.
558
+
532
559
  Typing sends key pairs for printable US characters, plainly and in a view; other text uses
533
560
  Unicode insertion. A typed space or letter can press a focused button, toggle a box, follow a
534
561
  link or change a select, so `type` refuses before any input when its `into` ref is not a text field
@@ -851,8 +878,8 @@ event has expired fails with `EventHistoryExpired`; it never skips events silent
851
878
  stream promptly and size retention for the consumer’s delay. Closing the browser scope wakes and
852
879
  ends idle readers.
853
880
 
854
- The presentation track uses the same channel. `TrackPlanned` publishes a whole glide before
855
- input, with `from` and samples whose `afterMillis` are offsets from `at`. Its sequence identifies
881
+ The presentation track uses the same channel. `ActionAnnounced` comes first, as above.
882
+ `TrackPlanned` publishes a whole glide before input, with `from` and samples whose `afterMillis` are offsets from `at`. Its sequence identifies
856
883
  the plan. `TrackPerformed` ends that plan, names it in `plan`, and records the number of samples
857
884
  actually submitted plus the last submitted point. The consumer must trim the planned suffix to
858
885
  that count after interruption or failure. `complete` means all samples were submitted; it does
@@ -929,6 +956,98 @@ its first glide starts mid-viewport, and each later one where the one before end
929
956
  input on another tab does meanwhile. Every sent move updates the position, including a partially
930
957
  cancelled glide. A later viewport clamps the starting point to its bounds if necessary.
931
958
 
959
+ ## Filming a page
960
+
961
+ A browser opened with `pageTime` can film a page frame by frame, each frame showing the page at its
962
+ film time however long the last one took to picture. Each part is a module of its own:
963
+
964
+ - `page.layout(picks)` reads where things are, as data: a box for each pick in the viewport and the
965
+ document, the boxes of its words, and the viewport, scroll and scale, in one call.
966
+ `Layout.rehearse` measures what exists only after an interaction, such as an open menu, and puts
967
+ the page back.
968
+ - `page.overlay` is a layer over the page for a scope that shows a caller's SVG. Screenshots and
969
+ live views show it; `find`, `layout`, `changes`, `ready` and stillness never read it.
970
+ - `page.hold` holds the page's timers, animation frames, clocks and animations for a scope.
971
+ `advance(by, { scroll, poses, overlay })` steps them and, in the same call, scrolls, poses and
972
+ draws.
973
+ - `page.poses` moves, turns and scales the page's own elements about a point, as data, through
974
+ CSS `translate`, `rotate` and `scale`. Readers and clicks see a posed element where it is drawn,
975
+ and the change record does not report a pose. The scope's end takes every pose off.
976
+ - `page.paint({ scale, scrollbars })` sets an attached browser's device pixels to each CSS pixel,
977
+ and hides scrollbars from the next document on. `Chromium.layer` takes its `deviceScaleFactor`
978
+ at launch.
979
+ - `Film.frames(page, options)` is a stream of `Shot`s. At each film time it asks `at` for the
980
+ scroll, poses and overlay, sends the `inputs` due on that frame, and takes a screenshot. A
981
+ document that replaces the page is a `Passage`: the film holds its time while it loads, measures
982
+ its layout with the film's `picks`, and passes it to `at` from then on.
983
+
984
+ ```ts
985
+ const film = Effect.gen(function* () {
986
+ const time = yield* page.hold;
987
+ const overlay = yield* page.overlay;
988
+
989
+ yield* page.poses;
990
+
991
+ return yield* Film.frames(page, {
992
+ times: { fps: 30, to: 8000 },
993
+ time,
994
+ overlay,
995
+ image: { format: "png" },
996
+ inputs: [{ t: 1200, label: "tab", action: { _tag: "Click", target: usage.ref } }],
997
+ at: (t) =>
998
+ Effect.succeed({
999
+ scroll: scrollAt(t),
1000
+ poses: squashAt(t),
1001
+ overlay: { _tag: "Svg", markup: ringAt(t) },
1002
+ }),
1003
+ }).pipe(Stream.tap(write), Film.summary);
1004
+ });
1005
+ ```
1006
+
1007
+ The frames are pictures; encoding them is the caller's. What an input changed is
1008
+ `page.changes({ since })` read after it. Each `Change` has the `box` to frame it by, and `at`, on
1009
+ the same clock as a `Shot`'s `at`, so on held time the first shot at or after it is the first to
1010
+ show it. To lift an element off the page, take its picture with a clipped screenshot at
1011
+ `scale: "device"`, then pose it to `sx: 0, sy: 0`, which hides it and leaves the page laid out as
1012
+ it was. `examples/film.ts` films a small site this way: a hover, a tab, a selected word, a copy,
1013
+ a search typed a key at a time, an eased scroll, a row selected by a drag and a link to the next
1014
+ page, with what changed framed after each. It serves the site through the browser's request
1015
+ policy (`Browser.Options.requests`), so a hosted browser films it as a local one does.
1016
+
1017
+ ## A site that owns its page
1018
+
1019
+ `effect-browser/Site` is the same composition the library installs in a page over the protocol,
1020
+ for a site to call in its own bundle on its own document. It holds no protocol and loads no
1021
+ `effect`: about 16 KB gzipped, minified. A site reads the same refs, subjects, outline, text,
1022
+ layout and changes as an agent does, draws in the same overlay, and poses its elements the same
1023
+ way.
1024
+
1025
+ ```ts
1026
+ import * as Site from "effect-browser/Site";
1027
+
1028
+ const site = Site.make();
1029
+ const read = site.layout({
1030
+ save: { role: "button", name: "Save" },
1031
+ lede: { selector: "p", words: "postal" },
1032
+ });
1033
+
1034
+ site.record();
1035
+ site.note(saveButton); // the site acts through its own app, and says so
1036
+ app.dispatch(Save());
1037
+ await site.settle();
1038
+ const { records } = site.changes({ since: null, until: null, unmask: false }); // each with its box and cause
1039
+ site.layer().append(character); // a closed shadow root no reader reads
1040
+ ```
1041
+
1042
+ What needs the protocol stays out: trusted input and its checks, screenshots and `Film`, held page
1043
+ time, and a record that starts before the page's own scripts. In their place, the site acts through
1044
+ its own app and `note`s each act, so the changes it brings name it as their `cause`, as a trusted
1045
+ input's would. Time is real, so a pose or a drawing is set again on each animation frame. The
1046
+ record starts when the site calls `record`. Requests and results are the page script's plain data,
1047
+ with boxes in viewport CSS pixels and times in epoch milliseconds, and an unservable request
1048
+ answers `{ invalid }` rather than throwing. The parts run in the site's own world, so they share
1049
+ any globals the site's code patches.
1050
+
932
1051
  ## Supervising resource generations
933
1052
 
934
1053
  `effect-browser/Supervisor` owns a scoped resource through acquisition failures, loss and rotation.
@@ -1,5 +1,5 @@
1
1
  import { t as Action } from "./Action-24sLOubi.mjs";
2
- import { f as Page } from "./Page-CvsOEorc.mjs";
2
+ import { f as Page } from "./Page-CLzh5E9w.mjs";
3
3
  declare namespace ActionPort_d_exports {
4
4
  export { checked, execute, methods };
5
5
  }
@@ -1,7 +1,7 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
2
2
  import { Action, nameOf } from "./Action.mjs";
3
3
  import { InvalidRequest, undispatched } from "./BrowserError.mjs";
4
- import { s as ResolvedTarget } from "./Page-BF5izr8R.mjs";
4
+ import { s as ResolvedTarget } from "./Page-BaAOshxo.mjs";
5
5
  import { Effect, Schema } from "effect";
6
6
  //#region src/ActionPort.ts
7
7
  /** Assemble named Page methods and canonical action execution over one concrete input port. */