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
@@ -0,0 +1,265 @@
1
+ import { t as BrowserError } from "../BrowserError-BlcmLVzn.mjs";
2
+ import { a as Image } from "../Frame-UEH2hO5T.mjs";
3
+ import { F as Layout, R as Picks, b as ScreenshotOptions, f as Page, y as ResolvedTarget } from "../Page-CLzh5E9w.mjs";
4
+ import { n as Overlay } from "../Overlay-CoGw5tL_.mjs";
5
+ import { r as Step, t as Held } from "../PageTime-68UPUZpZ.mjs";
6
+ import { Effect, Schema, Stream } from "effect";
7
+ //#region src/film/Film.d.ts
8
+ /**
9
+ * What a frame shows over the page, and, on held time, where the page is scrolled to then and how
10
+ * its elements are posed, with the page's poses open.
11
+ */
12
+ export type At = Step;
13
+ /** Frames at `fps` from `from` (0 by default) until before `to`, or at these times, in ms. */
14
+ export type Times = {
15
+ readonly fps: number;
16
+ readonly from?: number | undefined;
17
+ readonly to: number;
18
+ } | ReadonlyArray<number>;
19
+ /**
20
+ * Where film time comes from: a held page, stepped to each frame; a page's own seek, given each
21
+ * frame's time; or real time from the film's start, each frame taken when its time comes.
22
+ */
23
+ export type Time = Held | {
24
+ readonly seek: (t: number) => Effect.Effect<void, BrowserError>;
25
+ } | "real";
26
+ export interface Options<E = never> {
27
+ readonly times: Times;
28
+ readonly time: Time;
29
+ /** What the page shows at a film time, each frame's and each input's, from the passages so far. */
30
+ readonly at?: ((t: number, film: {
31
+ readonly passages: ReadonlyArray<Passage>;
32
+ }) => Effect.Effect<At, E>) | undefined;
33
+ /** What to measure in each new document the film arrives in. */
34
+ readonly picks?: Picks | undefined;
35
+ /**
36
+ * Inputs sent at their film times, in time order, each before the first frame at or after it:
37
+ * the page is moved to its time, and on held time it answers as its time is stepped on. One that
38
+ * fails fails the film.
39
+ */
40
+ readonly inputs?: ReadonlyArray<Contact> | undefined;
41
+ /** The page's overlay, open, that `at`'s drawings go to. */
42
+ readonly overlay?: Overlay | undefined;
43
+ /**
44
+ * How each frame is taken. For frames with more pixels than the layout, paint the page first
45
+ * (`Page.paint`) and take them at `scale: "device"`.
46
+ */
47
+ readonly image?: Pick<ScreenshotOptions, "format" | "quality" | "scale"> | undefined;
48
+ /** How many times a frame's screenshot is taken again after it times out. Defaults to 2. */
49
+ readonly retries?: number | undefined;
50
+ }
51
+ /** An input to send at film time `t`, in ms, with the caller's name for it. */
52
+ export declare const Contact: Schema.Struct<{
53
+ readonly t: Schema.Finite;
54
+ readonly action: Schema.TaggedUnion<{
55
+ readonly Act: Schema.TaggedStruct<"Act", {
56
+ readonly document: Schema.Int;
57
+ }>;
58
+ readonly Back: Schema.TaggedStruct<"Back", {}>;
59
+ readonly Click: Schema.TaggedStruct<"Click", {
60
+ readonly target: Schema.Union<readonly [Schema.String, Schema.Struct<{
61
+ readonly x: Schema.Finite;
62
+ readonly y: Schema.Finite;
63
+ }>]>;
64
+ readonly options: Schema.optional<Schema.Struct<{
65
+ readonly button: Schema.optional<Schema.Literals<readonly ["left", "right", "middle"]>>;
66
+ readonly clickCount: Schema.optional<Schema.Finite>;
67
+ readonly holdMillis: Schema.optional<Schema.Finite>;
68
+ }>>;
69
+ }>;
70
+ readonly Drag: Schema.TaggedStruct<"Drag", {
71
+ readonly from: Schema.Union<readonly [Schema.String, Schema.Struct<{
72
+ readonly x: Schema.Finite;
73
+ readonly y: Schema.Finite;
74
+ }>]>;
75
+ readonly to: Schema.Union<readonly [Schema.String, Schema.Struct<{
76
+ readonly x: Schema.Finite;
77
+ readonly y: Schema.Finite;
78
+ }>]>;
79
+ }>;
80
+ readonly Goto: Schema.TaggedStruct<"Goto", {
81
+ readonly url: Schema.String;
82
+ }>;
83
+ readonly Hover: Schema.TaggedStruct<"Hover", {
84
+ readonly target: Schema.Union<readonly [Schema.String, Schema.Struct<{
85
+ readonly x: Schema.Finite;
86
+ readonly y: Schema.Finite;
87
+ }>]>;
88
+ }>;
89
+ readonly Press: Schema.TaggedStruct<"Press", {
90
+ readonly keys: Schema.String;
91
+ readonly options: Schema.optional<Schema.Struct<{
92
+ readonly on: Schema.optional<Schema.String>;
93
+ readonly times: Schema.optional<Schema.Finite>;
94
+ readonly holdMillis: Schema.optional<Schema.Finite>;
95
+ }>>;
96
+ }>;
97
+ readonly Reload: Schema.TaggedStruct<"Reload", {}>;
98
+ readonly Scroll: Schema.TaggedStruct<"Scroll", {
99
+ readonly options: Schema.optional<Schema.Struct<{
100
+ readonly at: Schema.optional<Schema.Union<readonly [Schema.String, Schema.Struct<{
101
+ readonly x: Schema.Finite;
102
+ readonly y: Schema.Finite;
103
+ }>]>>;
104
+ readonly dx: Schema.optional<Schema.Finite>;
105
+ readonly dy: Schema.optional<Schema.Finite>;
106
+ }>>;
107
+ }>;
108
+ readonly Select: Schema.TaggedStruct<"Select", {
109
+ readonly ref: Schema.String;
110
+ readonly values: Schema.$Array<Schema.String>;
111
+ }>;
112
+ readonly Type: Schema.TaggedStruct<"Type", {
113
+ readonly text: Schema.String;
114
+ readonly options: Schema.optional<Schema.Struct<{
115
+ readonly into: Schema.optional<Schema.String>;
116
+ readonly replace: Schema.optional<Schema.Boolean>;
117
+ readonly submit: Schema.optional<Schema.Boolean>;
118
+ readonly secret: Schema.optional<Schema.Boolean>;
119
+ }>>;
120
+ }>;
121
+ }>;
122
+ readonly label: Schema.optional<Schema.String>;
123
+ }>;
124
+ export type Contact = typeof Contact.Type;
125
+ declare const Sent_base: Schema.Class<Sent, Schema.Struct<{
126
+ readonly t: Schema.Finite;
127
+ readonly label: Schema.optional<Schema.String>;
128
+ readonly action: Schema.TaggedUnion<{
129
+ readonly Act: Schema.TaggedStruct<"Act", {
130
+ readonly document: Schema.Int;
131
+ }>;
132
+ readonly Back: Schema.TaggedStruct<"Back", {}>;
133
+ readonly Click: Schema.TaggedStruct<"Click", {
134
+ readonly target: Schema.Union<readonly [Schema.String, Schema.Struct<{
135
+ readonly x: Schema.Finite;
136
+ readonly y: Schema.Finite;
137
+ }>]>;
138
+ readonly options: Schema.optional<Schema.Struct<{
139
+ readonly button: Schema.optional<Schema.Literals<readonly ["left", "right", "middle"]>>;
140
+ readonly clickCount: Schema.optional<Schema.Finite>;
141
+ readonly holdMillis: Schema.optional<Schema.Finite>;
142
+ }>>;
143
+ }>;
144
+ readonly Drag: Schema.TaggedStruct<"Drag", {
145
+ readonly from: Schema.Union<readonly [Schema.String, Schema.Struct<{
146
+ readonly x: Schema.Finite;
147
+ readonly y: Schema.Finite;
148
+ }>]>;
149
+ readonly to: Schema.Union<readonly [Schema.String, Schema.Struct<{
150
+ readonly x: Schema.Finite;
151
+ readonly y: Schema.Finite;
152
+ }>]>;
153
+ }>;
154
+ readonly Goto: Schema.TaggedStruct<"Goto", {
155
+ readonly url: Schema.String;
156
+ }>;
157
+ readonly Hover: Schema.TaggedStruct<"Hover", {
158
+ readonly target: Schema.Union<readonly [Schema.String, Schema.Struct<{
159
+ readonly x: Schema.Finite;
160
+ readonly y: Schema.Finite;
161
+ }>]>;
162
+ }>;
163
+ readonly Press: Schema.TaggedStruct<"Press", {
164
+ readonly keys: Schema.String;
165
+ readonly options: Schema.optional<Schema.Struct<{
166
+ readonly on: Schema.optional<Schema.String>;
167
+ readonly times: Schema.optional<Schema.Finite>;
168
+ readonly holdMillis: Schema.optional<Schema.Finite>;
169
+ }>>;
170
+ }>;
171
+ readonly Reload: Schema.TaggedStruct<"Reload", {}>;
172
+ readonly Scroll: Schema.TaggedStruct<"Scroll", {
173
+ readonly options: Schema.optional<Schema.Struct<{
174
+ readonly at: Schema.optional<Schema.Union<readonly [Schema.String, Schema.Struct<{
175
+ readonly x: Schema.Finite;
176
+ readonly y: Schema.Finite;
177
+ }>]>>;
178
+ readonly dx: Schema.optional<Schema.Finite>;
179
+ readonly dy: Schema.optional<Schema.Finite>;
180
+ }>>;
181
+ }>;
182
+ readonly Select: Schema.TaggedStruct<"Select", {
183
+ readonly ref: Schema.String;
184
+ readonly values: Schema.$Array<Schema.String>;
185
+ }>;
186
+ readonly Type: Schema.TaggedStruct<"Type", {
187
+ readonly text: Schema.String;
188
+ readonly options: Schema.optional<Schema.Struct<{
189
+ readonly into: Schema.optional<Schema.String>;
190
+ readonly replace: Schema.optional<Schema.Boolean>;
191
+ readonly submit: Schema.optional<Schema.Boolean>;
192
+ readonly secret: Schema.optional<Schema.Boolean>;
193
+ }>>;
194
+ }>;
195
+ }>;
196
+ /** What a click resolved its target to, before its input. */
197
+ readonly target: Schema.optional<typeof ResolvedTarget>;
198
+ /** The page's document after it. */
199
+ readonly document: Schema.Int;
200
+ }>, {}>;
201
+ /** An input as it was sent, at its film time. */
202
+ export declare class Sent extends Sent_base {}
203
+ declare const Passage_base: Schema.Class<Passage, Schema.Struct<{
204
+ readonly t: Schema.Finite;
205
+ /** The address of the document it left. */
206
+ readonly left: Schema.String;
207
+ readonly document: Schema.Int;
208
+ readonly url: Schema.String;
209
+ /** Real milliseconds from the film's last step on the page before to the document's being ready. */
210
+ readonly loadedAfter: Schema.Finite;
211
+ /** The new document's layout, ready, with the film's `picks`. */
212
+ readonly layout: typeof Layout;
213
+ }>, {}>;
214
+ /** The page's move to a new document, at the film time of the first frame that found it. */
215
+ export declare class Passage extends Passage_base {}
216
+ declare const Shot_base: Schema.Class<Shot, Schema.Struct<{
217
+ readonly index: Schema.Int;
218
+ readonly t: Schema.Finite;
219
+ readonly image: typeof Image;
220
+ /** The page's document and address after the picture, as `Page.state` gives them. */
221
+ readonly document: Schema.Int;
222
+ readonly url: Schema.String;
223
+ /** Where the document was scrolled to, in CSS pixels, on held time. */
224
+ readonly scroll: Schema.optional<Schema.Struct<{
225
+ readonly x: Schema.Finite;
226
+ readonly y: Schema.Finite;
227
+ }>>;
228
+ /** The inputs sent since the frame before. */
229
+ readonly sent: Schema.$Array<typeof Sent>;
230
+ /** The new document this frame was the first to find. */
231
+ readonly passage: Schema.optional<typeof Passage>;
232
+ /** Screenshots that timed out before this one. */
233
+ readonly retries: Schema.Int;
234
+ /** Real milliseconds from the frame's start to its picture. */
235
+ readonly took: Schema.Finite;
236
+ /**
237
+ * When its picture was taken, in host monotonic milliseconds on the browser's clock, as a
238
+ * `Change`'s times are. On held time, the first shot at or after a change's `at` is the first
239
+ * that shows it; on real time, the page may change while it is pictured.
240
+ */
241
+ readonly at: Schema.Finite;
242
+ }>, {}>;
243
+ /** One frame: its picture at film time `t`, in ms, and what taking it cost in real time. */
244
+ export declare class Shot extends Shot_base {}
245
+ declare const Summary_base: Schema.Class<Summary, Schema.Struct<{
246
+ readonly frames: Schema.Int;
247
+ readonly retries: Schema.Int;
248
+ /** Real milliseconds, all frames' and the slowest one's. */
249
+ readonly took: Schema.Finite;
250
+ readonly slowest: Schema.Finite;
251
+ /** Every input sent, and every passage, in order. */
252
+ readonly sent: Schema.$Array<typeof Sent>;
253
+ readonly passages: Schema.$Array<typeof Passage>;
254
+ }>, {}>;
255
+ /** What a film cost, from its shots. */
256
+ export declare class Summary extends Summary_base {}
257
+ /**
258
+ * Frames of `page` at `times`, one at a time: each moves the page to its film time, draws what
259
+ * `at` gives there when it changed, and takes a new screenshot, again after one that times out.
260
+ */
261
+ export declare const frames: <E = never>(page: Page, options: Options<E>) => Stream.Stream<Shot, BrowserError | E>;
262
+ /** Run a film's shots, which a caller has usually written out on the way, to what they cost. */
263
+ export declare const summary: <E, R>(shots: Stream.Stream<Shot, E, R>) => Effect.Effect<Summary, E, R>;
264
+ //#endregion
265
+ //# sourceMappingURL=Film.d.mts.map
@@ -0,0 +1,246 @@
1
+ import { Point } from "../Geometry.mjs";
2
+ import { Action } from "../Action.mjs";
3
+ import { refuse } from "../BrowserError.mjs";
4
+ import { Image } from "../Frame.mjs";
5
+ import { s as ResolvedTarget } from "../Page-BaAOshxo.mjs";
6
+ import { monotonicMillis } from "../Clock.mjs";
7
+ import { Layout } from "../Layout.mjs";
8
+ import { Clock, Duration, Effect, Schema, Stream } from "effect";
9
+ //#region src/film/Film.ts
10
+ /**
11
+ * Filming a page as a function of time: a new screenshot at each time a caller asks for, of the
12
+ * page as it is at that film time, with what the caller draws over it then. Film time comes from
13
+ * a held page (`Page.hold`), which steps to each frame however long the last one took, so a
14
+ * frame costs one call to step the page and one screenshot; from a page that seeks itself; or
15
+ * from real time. The frames are pictures; encoding them is the caller's.
16
+ *
17
+ * Loading takes real time, so a film holds its time while the page loads a new document: the
18
+ * first frame that finds one waits for it to be ready, measures its layout, and says so as a
19
+ * `Passage`, which `at` sees from then on. On real time the film's start moves on by the wait.
20
+ *
21
+ * @since 0.3.0
22
+ */
23
+ const Count = Schema.Int.check(Schema.isGreaterThanOrEqualTo(0));
24
+ const Millis = Schema.Finite.check(Schema.isGreaterThanOrEqualTo(0));
25
+ /** An input to send at film time `t`, in ms, with the caller's name for it. */
26
+ const Contact = Schema.Struct({
27
+ t: Millis,
28
+ action: Action,
29
+ label: Schema.optional(Schema.String)
30
+ });
31
+ /** An input as it was sent, at its film time. */
32
+ var Sent = class extends Schema.Class("effect-browser/Sent")({
33
+ t: Millis,
34
+ label: Schema.optional(Schema.String),
35
+ action: Action,
36
+ /** What a click resolved its target to, before its input. */
37
+ target: Schema.optional(ResolvedTarget),
38
+ /** The page's document after it. */
39
+ document: Count
40
+ }) {};
41
+ /** The page's move to a new document, at the film time of the first frame that found it. */
42
+ var Passage = class extends Schema.Class("effect-browser/Passage")({
43
+ t: Millis,
44
+ /** The address of the document it left. */
45
+ left: Schema.String,
46
+ document: Count,
47
+ url: Schema.String,
48
+ /** Real milliseconds from the film's last step on the page before to the document's being ready. */
49
+ loadedAfter: Millis,
50
+ /** The new document's layout, ready, with the film's `picks`. */
51
+ layout: Layout
52
+ }) {};
53
+ /** One frame: its picture at film time `t`, in ms, and what taking it cost in real time. */
54
+ var Shot = class extends Schema.Class("effect-browser/Shot")({
55
+ index: Count,
56
+ t: Millis,
57
+ image: Image,
58
+ /** The page's document and address after the picture, as `Page.state` gives them. */
59
+ document: Count,
60
+ url: Schema.String,
61
+ /** Where the document was scrolled to, in CSS pixels, on held time. */
62
+ scroll: Schema.optional(Point),
63
+ /** The inputs sent since the frame before. */
64
+ sent: Schema.Array(Sent),
65
+ /** The new document this frame was the first to find. */
66
+ passage: Schema.optional(Passage),
67
+ /** Screenshots that timed out before this one. */
68
+ retries: Count,
69
+ /** Real milliseconds from the frame's start to its picture. */
70
+ took: Millis,
71
+ /**
72
+ * When its picture was taken, in host monotonic milliseconds on the browser's clock, as a
73
+ * `Change`'s times are. On held time, the first shot at or after a change's `at` is the first
74
+ * that shows it; on real time, the page may change while it is pictured.
75
+ */
76
+ at: Schema.Finite
77
+ }) {};
78
+ /** What a film cost, from its shots. */
79
+ var Summary = class extends Schema.Class("effect-browser/FilmSummary")({
80
+ frames: Count,
81
+ retries: Count,
82
+ /** Real milliseconds, all frames' and the slowest one's. */
83
+ took: Millis,
84
+ slowest: Millis,
85
+ /** Every input sent, and every passage, in order. */
86
+ sent: Schema.Array(Sent),
87
+ passages: Schema.Array(Passage)
88
+ }) {};
89
+ const operation = "Film.frames";
90
+ function* rated(fps, from, to) {
91
+ const count = Math.round((to - from) * fps / 1e3);
92
+ for (let index = 0; index < count; index++) yield from + index * 1e3 / fps;
93
+ }
94
+ const timesOf = (times) => {
95
+ if ("fps" in times) {
96
+ const { fps, from = 0, to } = times;
97
+ return [
98
+ fps,
99
+ from,
100
+ to
101
+ ].every(Number.isFinite) && fps > 0 && from >= 0 && to >= from ? Effect.succeed(rated(fps, from, to)) : refuse(operation, "a film's rate is positive and runs from a nonnegative time to a later one");
102
+ }
103
+ return times.every((t, index) => Number.isFinite(t) && t >= 0 && (index === 0 || t >= (times[index - 1] ?? t))) ? Effect.succeed(times) : refuse(operation, "a film's times are finite, nonnegative and in order");
104
+ };
105
+ const mover = (page, time, overlay) => {
106
+ if (typeof time === "object" && "advance" in time) {
107
+ let now = 0;
108
+ const move = (t, { scroll, poses, overlay: content }, drawn) => time.advance(Duration.millis(t - now), {
109
+ scroll,
110
+ poses,
111
+ overlay: drawn ? content : void 0
112
+ }).pipe(Effect.tap(() => Effect.sync(() => {
113
+ now = t;
114
+ })));
115
+ return {
116
+ move,
117
+ skip: () => void 0
118
+ };
119
+ }
120
+ let start;
121
+ const arrive = time === "real" ? (t) => Effect.suspend(() => {
122
+ const now = monotonicMillis(page.clock);
123
+ start ??= now;
124
+ return Effect.sleep(Duration.millis(Math.max(0, start + t - now))).pipe(Effect.provideService(Clock.Clock, page.clock));
125
+ }) : time.seek;
126
+ const move = (t, at, drawn) => at.scroll === void 0 && at.poses === void 0 ? arrive(t).pipe(Effect.andThen(drawn && at.overlay !== void 0 && overlay !== void 0 ? overlay.draw(at.overlay) : Effect.void), Effect.as(void 0)) : refuse(operation, "a film scrolls and poses the page only on held time");
127
+ return {
128
+ move,
129
+ skip: (millis) => {
130
+ if (start !== void 0) start += millis;
131
+ }
132
+ };
133
+ };
134
+ const picture = (page, image, retries) => Effect.gen(function* () {
135
+ let timedOut = 0;
136
+ return {
137
+ image: yield* page.screenshot({
138
+ ...image,
139
+ maxAge: 0
140
+ }).pipe(Effect.tapError((error) => Effect.sync(() => timedOut += error.reason._tag === "Timeout" ? 1 : 0)), Effect.retry({
141
+ times: retries,
142
+ while: (error) => error.reason._tag === "Timeout"
143
+ })),
144
+ retries: timedOut
145
+ };
146
+ });
147
+ const keyOf = (content) => content === void 0 ? void 0 : content._tag === "Svg" ? `svg:${content.markup}` : "empty";
148
+ /**
149
+ * Frames of `page` at `times`, one at a time: each moves the page to its film time, draws what
150
+ * `at` gives there when it changed, and takes a new screenshot, again after one that times out.
151
+ */
152
+ const frames = (page, options) => Stream.unwrap(Effect.gen(function* () {
153
+ const times = yield* timesOf(options.times);
154
+ const retries = options.retries ?? 2;
155
+ if (!Number.isSafeInteger(retries) || retries < 0) return yield* refuse(operation, "retries must be a nonnegative safe integer");
156
+ const inputs = (options.inputs ?? []).toSorted((one, other) => one.t - other.t);
157
+ if (!inputs.every(({ t }) => Number.isFinite(t) && t >= 0)) return yield* refuse(operation, "an input's time is finite and nonnegative");
158
+ let next = 0;
159
+ const { move, skip } = mover(page, options.time, options.overlay);
160
+ const now = () => monotonicMillis(page.clock);
161
+ const passages = [];
162
+ const at = (t) => options.at === void 0 ? Effect.succeed({}) : options.at(t, { passages });
163
+ let shown;
164
+ let { document: seen, url: was } = yield* page.state;
165
+ let stepped = now();
166
+ const step = (t, showing, drawn) => Effect.tap(move(t, showing, drawn), () => Effect.sync(() => stepped = now()));
167
+ const arrival = (t) => Effect.gen(function* () {
168
+ const { document, url } = yield* page.state;
169
+ if (document === seen) return void 0;
170
+ yield* page.ready();
171
+ const layout = yield* page.layout(options.picks ?? {});
172
+ const loadedAfter = now() - stepped;
173
+ skip(loadedAfter);
174
+ const passage = new Passage({
175
+ t,
176
+ left: was,
177
+ document,
178
+ url,
179
+ loadedAfter,
180
+ layout
181
+ });
182
+ [seen, was] = [document, url];
183
+ passages.push(passage);
184
+ return passage;
185
+ });
186
+ const send = ({ t, action, label }) => Effect.gen(function* () {
187
+ yield* step(t, yield* at(t), false);
188
+ const done = yield* page.perform(action);
189
+ const { document } = yield* page.state;
190
+ return new Sent({
191
+ t,
192
+ label,
193
+ action,
194
+ target: Schema.is(ResolvedTarget)(done) ? done : void 0,
195
+ document
196
+ });
197
+ });
198
+ const shoot = (t, index) => Effect.gen(function* () {
199
+ const started = now();
200
+ const sent = [];
201
+ for (let input = inputs[next]; input !== void 0 && input.t <= t; input = inputs[++next]) sent.push(yield* send(input));
202
+ const passage = yield* arrival(t);
203
+ const showing = yield* at(t);
204
+ const key = keyOf(showing.overlay);
205
+ if (key !== void 0 && options.overlay === void 0) return yield* refuse(operation, "drawing needs the page's overlay, open, in `overlay`");
206
+ const scroll = yield* step(t, showing, key !== void 0 && key !== shown);
207
+ shown = key ?? shown;
208
+ const taken = yield* picture(page, options.image, retries);
209
+ const pictured = now();
210
+ const { document, url } = yield* page.state;
211
+ return new Shot({
212
+ index,
213
+ t,
214
+ image: taken.image,
215
+ document,
216
+ url,
217
+ scroll,
218
+ sent,
219
+ passage,
220
+ retries: taken.retries,
221
+ took: pictured - started,
222
+ at: pictured
223
+ });
224
+ });
225
+ return Stream.fromIterable(times).pipe(Stream.zipWithIndex, Stream.mapEffect(([t, index]) => shoot(t, index)));
226
+ }));
227
+ /** Run a film's shots, which a caller has usually written out on the way, to what they cost. */
228
+ const summary = (shots) => Stream.runFold(shots, () => new Summary({
229
+ frames: 0,
230
+ retries: 0,
231
+ took: 0,
232
+ slowest: 0,
233
+ sent: [],
234
+ passages: []
235
+ }), (sum, shot) => new Summary({
236
+ frames: sum.frames + 1,
237
+ retries: sum.retries + shot.retries,
238
+ took: sum.took + shot.took,
239
+ slowest: Math.max(sum.slowest, shot.took),
240
+ sent: [...sum.sent, ...shot.sent],
241
+ passages: shot.passage === void 0 ? sum.passages : [...sum.passages, shot.passage]
242
+ }));
243
+ //#endregion
244
+ export { Contact, Passage, Sent, Shot, Summary, frames, summary };
245
+
246
+ //# sourceMappingURL=Film.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Film.mjs","names":[],"sources":["../../src/film/Film.ts"],"sourcesContent":["/**\n * Filming a page as a function of time: a new screenshot at each time a caller asks for, of the\n * page as it is at that film time, with what the caller draws over it then. Film time comes from\n * a held page (`Page.hold`), which steps to each frame however long the last one took, so a\n * frame costs one call to step the page and one screenshot; from a page that seeks itself; or\n * from real time. The frames are pictures; encoding them is the caller's.\n *\n * Loading takes real time, so a film holds its time while the page loads a new document: the\n * first frame that finds one waits for it to be ready, measures its layout, and says so as a\n * `Passage`, which `at` sees from then on. On real time the film's start moves on by the wait.\n *\n * @since 0.3.0\n */\nimport { Clock, Duration, Effect, Schema, Stream } from \"effect\";\n\nimport { Action } from \"../Action.ts\";\nimport { type BrowserError, refuse } from \"../BrowserError.ts\";\nimport { monotonicMillis } from \"../Clock.ts\";\nimport { Image } from \"../Frame.ts\";\nimport { Point } from \"../Geometry.ts\";\nimport { Layout, type Picks } from \"../Layout.ts\";\nimport type { Content, Overlay } from \"../Overlay.ts\";\nimport { type Page, ResolvedTarget, type ScreenshotOptions } from \"../Page.ts\";\nimport type { Held, Step } from \"../PageTime.ts\";\n\n/**\n * What a frame shows over the page, and, on held time, where the page is scrolled to then and how\n * its elements are posed, with the page's poses open.\n */\nexport type At = Step;\n\n/** Frames at `fps` from `from` (0 by default) until before `to`, or at these times, in ms. */\nexport type Times =\n | { readonly fps: number; readonly from?: number | undefined; readonly to: number }\n | ReadonlyArray<number>;\n\n/**\n * Where film time comes from: a held page, stepped to each frame; a page's own seek, given each\n * frame's time; or real time from the film's start, each frame taken when its time comes.\n */\nexport type Time =\n | Held\n | { readonly seek: (t: number) => Effect.Effect<void, BrowserError> }\n | \"real\";\n\nexport interface Options<E = never> {\n readonly times: Times;\n readonly time: Time;\n /** What the page shows at a film time, each frame's and each input's, from the passages so far. */\n readonly at?:\n | ((t: number, film: { readonly passages: ReadonlyArray<Passage> }) => Effect.Effect<At, E>)\n | undefined;\n /** What to measure in each new document the film arrives in. */\n readonly picks?: Picks | undefined;\n /**\n * Inputs sent at their film times, in time order, each before the first frame at or after it:\n * the page is moved to its time, and on held time it answers as its time is stepped on. One that\n * fails fails the film.\n */\n readonly inputs?: ReadonlyArray<Contact> | undefined;\n /** The page's overlay, open, that `at`'s drawings go to. */\n readonly overlay?: Overlay | undefined;\n /**\n * How each frame is taken. For frames with more pixels than the layout, paint the page first\n * (`Page.paint`) and take them at `scale: \"device\"`.\n */\n readonly image?: Pick<ScreenshotOptions, \"format\" | \"quality\" | \"scale\"> | undefined;\n /** How many times a frame's screenshot is taken again after it times out. Defaults to 2. */\n readonly retries?: number | undefined;\n}\n\nconst Count = Schema.Int.check(Schema.isGreaterThanOrEqualTo(0));\nconst Millis = Schema.Finite.check(Schema.isGreaterThanOrEqualTo(0));\n\n/** An input to send at film time `t`, in ms, with the caller's name for it. */\nexport const Contact = Schema.Struct({\n t: Millis,\n action: Action,\n label: Schema.optional(Schema.String),\n});\n\nexport type Contact = typeof Contact.Type;\n\n/** An input as it was sent, at its film time. */\nexport class Sent extends Schema.Class<Sent>(\"effect-browser/Sent\")({\n t: Millis,\n label: Schema.optional(Schema.String),\n action: Action,\n /** What a click resolved its target to, before its input. */\n target: Schema.optional(ResolvedTarget),\n /** The page's document after it. */\n document: Count,\n}) {}\n\n/** The page's move to a new document, at the film time of the first frame that found it. */\nexport class Passage extends Schema.Class<Passage>(\"effect-browser/Passage\")({\n t: Millis,\n /** The address of the document it left. */\n left: Schema.String,\n document: Count,\n url: Schema.String,\n /** Real milliseconds from the film's last step on the page before to the document's being ready. */\n loadedAfter: Millis,\n /** The new document's layout, ready, with the film's `picks`. */\n layout: Layout,\n}) {}\n\n/** One frame: its picture at film time `t`, in ms, and what taking it cost in real time. */\nexport class Shot extends Schema.Class<Shot>(\"effect-browser/Shot\")({\n index: Count,\n t: Millis,\n image: Image,\n /** The page's document and address after the picture, as `Page.state` gives them. */\n document: Count,\n url: Schema.String,\n /** Where the document was scrolled to, in CSS pixels, on held time. */\n scroll: Schema.optional(Point),\n /** The inputs sent since the frame before. */\n sent: Schema.Array(Sent),\n /** The new document this frame was the first to find. */\n passage: Schema.optional(Passage),\n /** Screenshots that timed out before this one. */\n retries: Count,\n /** Real milliseconds from the frame's start to its picture. */\n took: Millis,\n /**\n * When its picture was taken, in host monotonic milliseconds on the browser's clock, as a\n * `Change`'s times are. On held time, the first shot at or after a change's `at` is the first\n * that shows it; on real time, the page may change while it is pictured.\n */\n at: Schema.Finite,\n}) {}\n\n/** What a film cost, from its shots. */\nexport class Summary extends Schema.Class<Summary>(\"effect-browser/FilmSummary\")({\n frames: Count,\n retries: Count,\n /** Real milliseconds, all frames' and the slowest one's. */\n took: Millis,\n slowest: Millis,\n /** Every input sent, and every passage, in order. */\n sent: Schema.Array(Sent),\n passages: Schema.Array(Passage),\n}) {}\n\nconst operation = \"Film.frames\";\n\nfunction* rated(fps: number, from: number, to: number) {\n const count = Math.round(((to - from) * fps) / 1000);\n\n for (let index = 0; index < count; index++) yield from + (index * 1000) / fps;\n}\n\nconst timesOf = (times: Times): Effect.Effect<Iterable<number>, BrowserError> => {\n if (\"fps\" in times) {\n const { fps, from = 0, to } = times;\n\n return [fps, from, to].every(Number.isFinite) && fps > 0 && from >= 0 && to >= from\n ? Effect.succeed(rated(fps, from, to))\n : refuse(\n operation,\n \"a film's rate is positive and runs from a nonnegative time to a later one\",\n );\n }\n\n return times.every(\n (t, index) => Number.isFinite(t) && t >= 0 && (index === 0 || t >= (times[index - 1] ?? t)),\n )\n ? Effect.succeed(times)\n : refuse(operation, \"a film's times are finite, nonnegative and in order\");\n};\n\n// `move` takes the page to film time `t`, showing `at` there; `drawn` says whether to draw its\n// overlay. On held time, it says where the document is scrolled to. `skip` leaves real time that\n// film time does not count.\ninterface Mover {\n readonly move: (\n t: number,\n at: At,\n drawn: boolean,\n ) => Effect.Effect<Point | undefined, BrowserError>;\n readonly skip: (millis: number) => void;\n}\n\nconst mover = (page: Page, time: Time, overlay: Overlay | undefined): Mover => {\n if (typeof time === \"object\" && \"advance\" in time) {\n let now = 0;\n\n const move: Mover[\"move\"] = (t, { scroll, poses, overlay: content }, drawn) =>\n time\n .advance(Duration.millis(t - now), {\n scroll,\n poses,\n overlay: drawn ? content : undefined,\n })\n .pipe(\n Effect.tap(() =>\n Effect.sync(() => {\n now = t;\n }),\n ),\n );\n\n return { move, skip: () => undefined };\n }\n let start: number | undefined;\n\n const arrive =\n time === \"real\"\n ? (t: number) =>\n Effect.suspend(() => {\n const now = monotonicMillis(page.clock);\n\n start ??= now;\n\n return Effect.sleep(Duration.millis(Math.max(0, start + t - now))).pipe(\n Effect.provideService(Clock.Clock, page.clock),\n );\n })\n : time.seek;\n\n const move: Mover[\"move\"] = (t, at, drawn) =>\n at.scroll === undefined && at.poses === undefined\n ? arrive(t).pipe(\n Effect.andThen(\n drawn && at.overlay !== undefined && overlay !== undefined\n ? overlay.draw(at.overlay)\n : Effect.void,\n ),\n Effect.as(undefined),\n )\n : refuse(operation, \"a film scrolls and poses the page only on held time\");\n\n return {\n move,\n skip: (millis) => {\n if (start !== undefined) start += millis;\n },\n };\n};\n\n// A new screenshot, taken again after one that times out, with how many did.\nconst picture = (page: Page, image: Options[\"image\"], retries: number) =>\n Effect.gen(function* () {\n let timedOut = 0;\n\n const taken = yield* page.screenshot({ ...image, maxAge: 0 }).pipe(\n Effect.tapError((error) =>\n Effect.sync(() => (timedOut += error.reason._tag === \"Timeout\" ? 1 : 0)),\n ),\n Effect.retry({ times: retries, while: (error) => error.reason._tag === \"Timeout\" }),\n );\n\n return { image: taken, retries: timedOut };\n });\n\nconst keyOf = (content: Content | undefined) =>\n content === undefined ? undefined : content._tag === \"Svg\" ? `svg:${content.markup}` : \"empty\";\n\n/**\n * Frames of `page` at `times`, one at a time: each moves the page to its film time, draws what\n * `at` gives there when it changed, and takes a new screenshot, again after one that times out.\n */\nexport const frames = <E = never>(\n page: Page,\n options: Options<E>,\n): Stream.Stream<Shot, BrowserError | E> =>\n Stream.unwrap(\n Effect.gen(function* () {\n const times = yield* timesOf(options.times);\n const retries = options.retries ?? 2;\n\n if (!Number.isSafeInteger(retries) || retries < 0)\n return yield* refuse(operation, \"retries must be a nonnegative safe integer\");\n const inputs = (options.inputs ?? []).toSorted((one, other) => one.t - other.t);\n\n if (!inputs.every(({ t }) => Number.isFinite(t) && t >= 0))\n return yield* refuse(operation, \"an input's time is finite and nonnegative\");\n let next = 0;\n const { move, skip } = mover(page, options.time, options.overlay);\n const now = () => monotonicMillis(page.clock);\n const passages: Array<Passage> = [];\n\n const at = (t: number) =>\n options.at === undefined ? Effect.succeed<At>({}) : options.at(t, { passages });\n\n let shown: string | undefined;\n let { document: seen, url: was } = yield* page.state;\n let stepped = now();\n\n // Take the page to film time `t`, and note when, as a passage's wait counts from it.\n const step = (t: number, showing: At, drawn: boolean) =>\n Effect.tap(move(t, showing, drawn), () => Effect.sync(() => (stepped = now())));\n\n // A document the page moved to since the last frame, once it is ready.\n const arrival = (t: number) =>\n Effect.gen(function* () {\n const { document, url } = yield* page.state;\n\n if (document === seen) return undefined;\n yield* page.ready();\n const layout = yield* page.layout(options.picks ?? {});\n const loadedAfter = now() - stepped;\n\n skip(loadedAfter);\n const passage = new Passage({ t, left: was, document, url, loadedAfter, layout });\n\n [seen, was] = [document, url];\n passages.push(passage);\n\n return passage;\n });\n\n const send = ({ t, action, label }: Contact) =>\n Effect.gen(function* () {\n yield* step(t, yield* at(t), false);\n const done = yield* page.perform(action);\n const { document } = yield* page.state;\n const target = Schema.is(ResolvedTarget)(done) ? done : undefined;\n\n return new Sent({ t, label, action, target, document });\n });\n\n const shoot = (t: number, index: number) =>\n Effect.gen(function* () {\n const started = now();\n const sent: Array<Sent> = [];\n\n for (\n let input = inputs[next];\n input !== undefined && input.t <= t;\n input = inputs[++next]\n )\n sent.push(yield* send(input));\n const passage = yield* arrival(t);\n const showing = yield* at(t);\n const key = keyOf(showing.overlay);\n\n if (key !== undefined && options.overlay === undefined)\n return yield* refuse(operation, \"drawing needs the page's overlay, open, in `overlay`\");\n const scroll = yield* step(t, showing, key !== undefined && key !== shown);\n\n shown = key ?? shown;\n const taken = yield* picture(page, options.image, retries);\n const pictured = now();\n const { document, url } = yield* page.state;\n\n return new Shot({\n index,\n t,\n image: taken.image,\n document,\n url,\n scroll,\n sent,\n passage,\n retries: taken.retries,\n took: pictured - started,\n at: pictured,\n });\n });\n\n return Stream.fromIterable(times).pipe(\n Stream.zipWithIndex,\n Stream.mapEffect(([t, index]) => shoot(t, index)),\n );\n }),\n );\n\n/** Run a film's shots, which a caller has usually written out on the way, to what they cost. */\nexport const summary = <E, R>(shots: Stream.Stream<Shot, E, R>): Effect.Effect<Summary, E, R> =>\n Stream.runFold(\n shots,\n () => new Summary({ frames: 0, retries: 0, took: 0, slowest: 0, sent: [], passages: [] }),\n (sum, shot) =>\n new Summary({\n frames: sum.frames + 1,\n retries: sum.retries + shot.retries,\n took: sum.took + shot.took,\n slowest: Math.max(sum.slowest, shot.took),\n sent: [...sum.sent, ...shot.sent],\n passages: shot.passage === undefined ? sum.passages : [...sum.passages, shot.passage],\n }),\n );\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAuEA,MAAM,QAAQ,OAAO,IAAI,MAAM,OAAO,uBAAuB,CAAC,CAAC;AAC/D,MAAM,SAAS,OAAO,OAAO,MAAM,OAAO,uBAAuB,CAAC,CAAC;;AAGnE,MAAa,UAAU,OAAO,OAAO;CACnC,GAAG;CACH,QAAQ;CACR,OAAO,OAAO,SAAS,OAAO,MAAM;AACtC,CAAC;;AAKD,IAAa,OAAb,cAA0B,OAAO,MAAY,qBAAqB,CAAC,CAAC;CAClE,GAAG;CACH,OAAO,OAAO,SAAS,OAAO,MAAM;CACpC,QAAQ;;CAER,QAAQ,OAAO,SAAS,cAAc;;CAEtC,UAAU;AACZ,CAAC,CAAC,CAAC,CAAC;;AAGJ,IAAa,UAAb,cAA6B,OAAO,MAAe,wBAAwB,CAAC,CAAC;CAC3E,GAAG;;CAEH,MAAM,OAAO;CACb,UAAU;CACV,KAAK,OAAO;;CAEZ,aA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Q,MAAM,QAAQ,OAAO,OAAO;EACzD,MAAM,WAAW,IAAI;EACrB,MAAM,EAAE,UAAU,QAAQ,OAAO,KAAK;EAEtC,OAAO,IAAI,KAAK;GACd;GACA;GACA,OAAO,MAAM;GACb;GACA;GACA;GACA;GACA;GACA,SAAS,MAAM;GACf,MAAM,WAAW;GACjB,IAAI;EACN,CAAC;CACH,CAAC;CAEH,OAAO,OAAO,aAAa,KAAK,CAAC,CAAC,KAChC,OAAO,cACP,OAAO,WAAW,CAAC,GAAG,WAAW,MAAM,GAAG,KAAK,CAAC,CAClD;AACF,CAAC,CACH;;AAGF,MAAa,WAAiB,UAC5B,OAAO,QACL,aACM,IAAI,QAAQ;CAAE,QAAQ;CAAG,SAAS;CAAG,MAAM;CAAG,SAAS;CAAG,MAAM,CAAC;CAAG,UAAU,CAAC;AAAE,CAAC,IACvF,KAAK,SACJ,IAAI,QAAQ;CACV,QAAQ,IAAI,SAAS;CACrB,SAAS,IAAI,UAAU,KAAK;CAC5B,MAAM,IAAI,OAAO,KAAK;CACtB,SAAS,KAAK,IAAI,IAAI,SAAS,KAAK,IAAI;CACxC,MAAM,CAAC,GAAG,IAAI,MAAM,GAAG,KAAK,IAAI;CAChC,UAAU,KAAK,YAAY,KAAA,IAAY,IAAI,WAAW,CAAC,GAAG,IAAI,UAAU,KAAK,OAAO;AACtF,CAAC,CACL"}
@@ -0,0 +1,49 @@
1
+ //#region src/internal/timeline/fold.inpage.d.ts
2
+ /**
3
+ * In the page: one element's history in the change record, and its fold over a window. A fold gives
4
+ * what the element showed at the window's start and at its end, how often that changed between,
5
+ * the lowest and highest of a number that changed more than once, and when it last changed before
6
+ * the window. Only what was seen in view as it changed is told. It touches no DOM, so it also runs
7
+ * outside a page. See `names.inpage.ts` for what a page-side part may use.
8
+ */
9
+ /** What an element shows: its words, `null` while it shows nothing, `undefined` until judged. */
10
+ type Shown = string | null | undefined;
11
+ interface Sample {
12
+ readonly at: number;
13
+ shown: Shown;
14
+ /** Whether it was in view as the page rendered it; undefined until then. */
15
+ seen: boolean | undefined;
16
+ }
17
+ /** One element's history, oldest change first. */
18
+ interface Track {
19
+ key: object;
20
+ readonly kind: "content" | "value" | "title";
21
+ /** What it showed before its oldest kept change; undefined when that is unknown. */
22
+ initial: Shown;
23
+ /** Before this, the record let some of its changes go. */
24
+ known: number;
25
+ readonly samples: Array<Sample>;
26
+ }
27
+ type Kind = "text" | "appeared" | "disappeared" | "brief" | "value" | "title";
28
+ /** One element's changes over a window, before the page names the element. */
29
+ interface Folded {
30
+ readonly track: Track;
31
+ readonly kind: Kind;
32
+ readonly startedAt: number;
33
+ readonly at: number;
34
+ readonly before: string | undefined;
35
+ readonly after: string | undefined;
36
+ readonly count: number;
37
+ readonly lowest: string | undefined;
38
+ readonly highest: string | undefined;
39
+ readonly earlier: number | undefined;
40
+ }
41
+ declare const fold: () => {
42
+ number: (words: string) => ReadonlyArray<number>;
43
+ over: (track: Track, since: number, until: number) => Folded | undefined;
44
+ rank: ({ samples: [only, ...more] }: Track) => number;
45
+ };
46
+ type Fold = ReturnType<typeof fold>;
47
+ //#endregion
48
+ export { Track as a, Shown as i, Folded as n, Sample as r, Fold as t };
49
+ //# sourceMappingURL=fold.inpage-CyVZQHZL.d.mts.map
package/dist/index.d.mts CHANGED
@@ -1,15 +1,18 @@
1
1
  import { n as Action_d_exports } from "./Action-24sLOubi.mjs";
2
2
  import { n as BrowserError_d_exports } from "./BrowserError-BlcmLVzn.mjs";
3
- import { i as BrowserEvent_d_exports } from "./BrowserEvent-lLqJ3GJS.mjs";
4
- import { n as Change_d_exports } from "./Change-Ba7INmay.mjs";
3
+ import { a as BrowserEvent_d_exports } from "./BrowserEvent-C2p-NwuU.mjs";
4
+ import { n as Change_d_exports } from "./Change-CxT1mp2e.mjs";
5
5
  import { i as Frame_d_exports } from "./Frame-UEH2hO5T.mjs";
6
6
  import { t as Geometry_d_exports } from "./Geometry-DJx9qrYy.mjs";
7
+ import { I as Layout_d_exports, p as Page_d_exports } from "./Page-CLzh5E9w.mjs";
8
+ import { r as Overlay_d_exports } from "./Overlay-CoGw5tL_.mjs";
9
+ import { n as Pose_d_exports } from "./Pose-2qqGzPvb.mjs";
10
+ import { n as PageTime_d_exports } from "./PageTime-68UPUZpZ.mjs";
7
11
  import { i as Snapshot_d_exports } from "./Snapshot-CtBVOtuu.mjs";
8
- import { n as Window_d_exports } from "./Window-CMddGMt1.mjs";
9
- import { p as Page_d_exports } from "./Page-CvsOEorc.mjs";
12
+ import { n as Window_d_exports } from "./Window-BDa8MtNP.mjs";
10
13
  import { t as ActionPort_d_exports } from "./ActionPort.mjs";
11
- import { n as Browser_d_exports } from "./Browser-wZhwZSlG.mjs";
12
- import { t as Clock_d_exports } from "./Clock.mjs";
14
+ import { n as Browser_d_exports } from "./Browser-DGR6ZEYo.mjs";
15
+ import { t as Clock_d_exports } from "./Clock-Du5nP-nK.mjs";
16
+ import { t as Url_d_exports } from "./Url-B7P-TWwL.mjs";
13
17
  import { t as Style_d_exports } from "./Style.mjs";
14
- import { t as Url_d_exports } from "./Url.mjs";
15
- export { Action_d_exports as Action, ActionPort_d_exports as ActionPort, Browser_d_exports as Browser, BrowserError_d_exports as BrowserError, BrowserEvent_d_exports as BrowserEvent, Change_d_exports as Change, Clock_d_exports as Clock, Frame_d_exports as Frame, Geometry_d_exports as Geometry, Page_d_exports as Page, Snapshot_d_exports as Snapshot, Style_d_exports as Style, Url_d_exports as Url, Window_d_exports as Window };
18
+ export { Action_d_exports as Action, ActionPort_d_exports as ActionPort, Browser_d_exports as Browser, BrowserError_d_exports as BrowserError, BrowserEvent_d_exports as BrowserEvent, Change_d_exports as Change, Clock_d_exports as Clock, Frame_d_exports as Frame, Geometry_d_exports as Geometry, Layout_d_exports as Layout, Overlay_d_exports as Overlay, Page_d_exports as Page, PageTime_d_exports as PageTime, Pose_d_exports as Pose, Snapshot_d_exports as Snapshot, Style_d_exports as Style, Url_d_exports as Url, Window_d_exports as Window };
package/dist/index.mjs CHANGED
@@ -4,12 +4,16 @@ import { t as Action_exports } from "./Action.mjs";
4
4
  import { t as BrowserEvent_exports } from "./BrowserEvent.mjs";
5
5
  import { t as BrowserError_exports } from "./BrowserError.mjs";
6
6
  import { t as Frame_exports } from "./Frame.mjs";
7
- import { a as Page_exports } from "./Page-BF5izr8R.mjs";
7
+ import { a as Page_exports } from "./Page-BaAOshxo.mjs";
8
8
  import { t as Snapshot_exports } from "./Snapshot.mjs";
9
9
  import { t as ActionPort_exports } from "./ActionPort.mjs";
10
10
  import { t as Clock_exports } from "./Clock.mjs";
11
- import { n as Browser_exports } from "./Browser-BKPAbyys.mjs";
12
- import { n as Style_exports } from "./Style-AO4V7Czt.mjs";
11
+ import { n as Browser_exports } from "./Browser-CAQFhTkM.mjs";
12
+ import { n as Style_exports } from "./Style-T3ezDYLI.mjs";
13
+ import { t as Layout_exports } from "./Layout.mjs";
13
14
  import { t as Change_exports } from "./Change.mjs";
14
15
  import { t as Window_exports } from "./Window.mjs";
15
- export { Action_exports as Action, ActionPort_exports as ActionPort, Browser_exports as Browser, BrowserError_exports as BrowserError, BrowserEvent_exports as BrowserEvent, Change_exports as Change, Clock_exports as Clock, Frame_exports as Frame, Geometry_exports as Geometry, Page_exports as Page, Snapshot_exports as Snapshot, Style_exports as Style, Url_exports as Url, Window_exports as Window };
16
+ import { t as Pose_exports } from "./Pose.mjs";
17
+ import { t as Overlay_exports } from "./Overlay.mjs";
18
+ import { t as PageTime_exports } from "./PageTime.mjs";
19
+ export { Action_exports as Action, ActionPort_exports as ActionPort, Browser_exports as Browser, BrowserError_exports as BrowserError, BrowserEvent_exports as BrowserEvent, Change_exports as Change, Clock_exports as Clock, Frame_exports as Frame, Geometry_exports as Geometry, Layout_exports as Layout, Overlay_exports as Overlay, Page_exports as Page, PageTime_exports as PageTime, Pose_exports as Pose, Snapshot_exports as Snapshot, Style_exports as Style, Url_exports as Url, Window_exports as Window };