@e2e-dev/electron 0.0.0-stage → 0.0.0

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 (75) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +5 -0
  3. package/README.md +91 -2
  4. package/dist/.build.json +1 -0
  5. package/dist/actionability.d.ts +41 -0
  6. package/dist/actionability.js +121 -0
  7. package/dist/actions.d.ts +52 -0
  8. package/dist/actions.js +418 -0
  9. package/dist/app-process.d.ts +114 -0
  10. package/dist/app-process.js +610 -0
  11. package/dist/budget.d.ts +33 -0
  12. package/dist/budget.js +64 -0
  13. package/dist/capture.d.ts +21 -0
  14. package/dist/capture.js +137 -0
  15. package/dist/cdp/connection.d.ts +68 -0
  16. package/dist/cdp/connection.js +232 -0
  17. package/dist/cdp/input.d.ts +67 -0
  18. package/dist/cdp/input.js +195 -0
  19. package/dist/cdp/keys.d.ts +21 -0
  20. package/dist/cdp/keys.js +114 -0
  21. package/dist/console-text.d.ts +4 -0
  22. package/dist/console-text.js +27 -0
  23. package/dist/devtools.d.ts +36 -0
  24. package/dist/devtools.js +111 -0
  25. package/dist/dialogs.d.ts +38 -0
  26. package/dist/dialogs.js +81 -0
  27. package/dist/electron.d.ts +9 -0
  28. package/dist/electron.js +174 -0
  29. package/dist/engine-entry.d.ts +13 -0
  30. package/dist/engine-entry.js +9 -0
  31. package/dist/engine.d.ts +27 -0
  32. package/dist/engine.js +98 -0
  33. package/dist/errors.d.ts +17 -0
  34. package/dist/errors.js +54 -0
  35. package/dist/evaluate.d.ts +40 -0
  36. package/dist/evaluate.js +115 -0
  37. package/dist/executable.d.ts +29 -0
  38. package/dist/executable.js +249 -0
  39. package/dist/ffmpeg.d.ts +12 -0
  40. package/dist/ffmpeg.js +100 -0
  41. package/dist/fields.d.ts +93 -0
  42. package/dist/fields.js +254 -0
  43. package/dist/file-bound.d.ts +31 -0
  44. package/dist/file-bound.js +104 -0
  45. package/dist/fixtures.d.ts +168 -0
  46. package/dist/fixtures.js +6 -0
  47. package/dist/in-page/masks.d.ts +25 -0
  48. package/dist/in-page/masks.js +140 -0
  49. package/dist/in-page/node-ops.d.ts +96 -0
  50. package/dist/in-page/node-ops.js +406 -0
  51. package/dist/index.d.ts +18 -0
  52. package/dist/index.js +18 -0
  53. package/dist/launcher.d.ts +45 -0
  54. package/dist/launcher.js +167 -0
  55. package/dist/locate.d.ts +46 -0
  56. package/dist/locate.js +103 -0
  57. package/dist/main-process.d.ts +25 -0
  58. package/dist/main-process.js +60 -0
  59. package/dist/options.d.ts +65 -0
  60. package/dist/options.js +120 -0
  61. package/dist/page.d.ts +100 -0
  62. package/dist/page.js +229 -0
  63. package/dist/runner-test.d.ts +15 -0
  64. package/dist/runner-test.js +45 -0
  65. package/dist/snapshot.d.ts +143 -0
  66. package/dist/snapshot.js +260 -0
  67. package/dist/surface.d.ts +158 -0
  68. package/dist/surface.js +602 -0
  69. package/dist/tree.d.ts +51 -0
  70. package/dist/tree.js +406 -0
  71. package/dist/video.d.ts +42 -0
  72. package/dist/video.js +253 -0
  73. package/dist/windows.d.ts +81 -0
  74. package/dist/windows.js +200 -0
  75. package/package.json +72 -3
package/dist/tree.js ADDED
@@ -0,0 +1,406 @@
1
+ /**
2
+ * Projects one window's Chromium accessibility tree onto the engine
3
+ * contract's semantic tree. The roles, names, values, and states are what
4
+ * Chromium computed (`Accessibility.getFullAXTree`); the boxes, attributes,
5
+ * and input values come from one DOM snapshot of the same document
6
+ * (`snapshot.ts`), joined on each node's backend DOM node id. `fields.ts`
7
+ * reads one element; this walks the tree and folds its text.
8
+ * Nothing runs in the page, so an app's content security policy, its frozen
9
+ * globals, and its mutation observers never see a read.
10
+ *
11
+ * Pure: the surface reads the two documents, this turns them into nodes.
12
+ */
13
+ import { OBSERVED_NAME_LIMIT, OBSERVED_TEXT_LIMIT } from '@e2e-dev/core/engine';
14
+ import { elementFields, isButtonInput, isCheckable, isFocusable, isHiddenSubtree, isSecure, isTextField, roleOf, stringOf } from './fields.js';
15
+ import { collapse } from './snapshot.js';
16
+ /** Controls that are their text wherever it is drawn: a text query answers with the control, and its state. */
17
+ const TEXT_IS_THE_NODE = new Set([
18
+ 'button', 'link', 'heading', 'tab', 'menuitem', 'menuitemcheckbox', 'menuitemradio', 'option', 'checkbox', 'radio', 'switch', 'treeitem', 'textbox', 'searchbox', 'combobox',
19
+ ]);
20
+ /** An icon font's glyphs: private-use code points Chromium puts in a name from CSS generated content. */
21
+ const ICON_GLYPHS = /\p{Co}/gu;
22
+ /**
23
+ * A name as a person reads it: an icon font's glyph is a picture, not a
24
+ * character, so a button drawn as an icon and "Scan" is named "Scan". A name
25
+ * of glyphs alone is kept as it is, the only name the node has.
26
+ */
27
+ function spokenName(name) {
28
+ const spoken = collapse(name.replace(ICON_GLYPHS, ' '));
29
+ return spoken === '' ? collapse(name) : spoken;
30
+ }
31
+ const POLICIES = {
32
+ tree: {
33
+ textLimit: OBSERVED_TEXT_LIMIT,
34
+ nameLimit: OBSERVED_NAME_LIMIT,
35
+ maxNodes: 5000,
36
+ attributes: new Set(['type', 'autocomplete', 'href', 'role', 'placeholder']),
37
+ redactHref: true,
38
+ editingHostRole: true,
39
+ checkableValue: false,
40
+ emptyState: false,
41
+ descendantText: false,
42
+ hiddenTestIds: false,
43
+ },
44
+ node: {
45
+ textLimit: Number.POSITIVE_INFINITY,
46
+ nameLimit: Number.POSITIVE_INFINITY,
47
+ maxNodes: Number.POSITIVE_INFINITY,
48
+ attributes: null,
49
+ redactHref: false,
50
+ editingHostRole: false,
51
+ checkableValue: true,
52
+ emptyState: true,
53
+ descendantText: true,
54
+ hiddenTestIds: true,
55
+ },
56
+ };
57
+ /** Roles whose node never reaches the tree: text runs, list bullets, line breaks. */
58
+ const DROPPED_ROLES = new Set(['InlineTextBox', 'ListMarker', 'LineBreak']);
59
+ function cut(value, limit) {
60
+ return value.length > limit ? value.slice(0, limit) : value;
61
+ }
62
+ /** Whether `next` starts below `previous`, which with no white space between them means a block boundary, not inline markup. */
63
+ function startsNewLine(previous, next) {
64
+ const { rect: above } = previous;
65
+ const { rect: below } = next;
66
+ return above !== undefined && below !== undefined && below.y >= above.y + above.height - 0.5;
67
+ }
68
+ /**
69
+ * The text a node reads as: its text runs, and with `deep` its descendants'
70
+ * too. Runs join as the source has them: with white space where the source had
71
+ * some or where a block boundary falls, and with none between inline markup
72
+ * (`<span>$</span><span>10</span>` reads `$10`). Two table cells side by side
73
+ * read with a space between them.
74
+ */
75
+ function textOf(draft, deep, snapshot) {
76
+ const parts = [];
77
+ const walk = (node) => {
78
+ for (const child of node.children) {
79
+ if (child.isText)
80
+ parts.push(child);
81
+ else if (deep) {
82
+ if (child.children.length === 0 && child.text !== undefined)
83
+ parts.push(child);
84
+ else
85
+ walk(child);
86
+ }
87
+ }
88
+ };
89
+ walk(draft);
90
+ let joined = '';
91
+ parts.forEach((part, at) => {
92
+ const previous = parts[at - 1];
93
+ if (previous !== undefined && separated(previous, part, snapshot))
94
+ joined += ' ';
95
+ joined += part.text ?? '';
96
+ });
97
+ return collapse(joined);
98
+ }
99
+ function separated(previous, part, snapshot) {
100
+ if (previous.spaceAfter === true || part.spaceBefore === true)
101
+ return true;
102
+ if (snapshot.cellOf(previous.order) !== snapshot.cellOf(part.order))
103
+ return true;
104
+ return snapshot.gap(previous.order, part.order) || startsNewLine(previous, part);
105
+ }
106
+ /** One projection: the walk over the accessibility tree, and the state it keeps (the node count, the drafts by backend id). */
107
+ class TreeProjector {
108
+ truncated = false;
109
+ kept = 0;
110
+ drafted = new Map();
111
+ nodes;
112
+ snapshot;
113
+ geometry;
114
+ options;
115
+ policy;
116
+ context;
117
+ testIdAttribute;
118
+ constructor(axNodes, snapshot, geometry, options) {
119
+ this.nodes = new Map(axNodes.map((node) => [node.nodeId, node]));
120
+ this.snapshot = snapshot;
121
+ this.geometry = geometry;
122
+ this.options = options;
123
+ this.policy = options.maxNodes === undefined ? POLICIES[options.mode] : { ...POLICIES[options.mode], maxNodes: options.maxNodes };
124
+ this.context = { policy: this.policy, testIdAttribute: options.testIdAttribute, baseUrl: options.baseUrl };
125
+ this.testIdAttribute = options.testIdAttribute.toLowerCase();
126
+ }
127
+ children(node) {
128
+ return (node.childIds ?? []).flatMap((id) => {
129
+ const child = this.nodes.get(id);
130
+ return child === undefined ? [] : this.build(child);
131
+ });
132
+ }
133
+ /**
134
+ * An element a locator asks for that the tree leaves out (`hidden`,
135
+ * `display: none`) is still there to count, as on the web: one a CSS
136
+ * selector matched, and on a locator's read one with a test id. It joins
137
+ * the tree at its place in the document, under its nearest ancestor that is
138
+ * in the tree, read by the same field rules as any other element.
139
+ */
140
+ placeAbsent(roots) {
141
+ const wanted = new Set(this.options.keep ?? []);
142
+ if (this.policy.hiddenTestIds) {
143
+ // Content under aria-hidden or inert is out of the accessibility tree and on screen all the same: a text query
144
+ // finds it, as on the web, on the element that holds the text, each one under the element that hides them. It
145
+ // has no role, so a role query still does not.
146
+ const hides = (facts) => facts.attributes['aria-hidden']?.toLowerCase() === 'true' || facts.attributes['inert'] !== undefined;
147
+ const hiding = new Set();
148
+ for (const [backend, facts] of this.snapshot.elements())
149
+ if (hides(facts))
150
+ hiding.add(backend);
151
+ /** Whether the element hides itself or sits under one that does; a page that hides nothing is not walked. */
152
+ const hidden = (backend, index) => {
153
+ if (hiding.size === 0)
154
+ return false;
155
+ if (hiding.has(backend))
156
+ return true;
157
+ for (const ancestor of this.snapshot.ancestors(index))
158
+ if (hiding.has(ancestor))
159
+ return true;
160
+ return false;
161
+ };
162
+ for (const [backend, facts] of this.snapshot.elements()) {
163
+ // Elements only: their text runs fold into them, so a locator answers with the element that holds the text.
164
+ const offTree = !facts.nodeName.startsWith('#') && facts.bounds !== undefined && hidden(backend, facts.index);
165
+ if (facts.attributes[this.testIdAttribute] !== undefined || offTree)
166
+ wanted.add(backend);
167
+ }
168
+ }
169
+ const absent = [...wanted].flatMap((backend) => {
170
+ const facts = this.drafted.has(backend) ? undefined : this.snapshot.element(backend);
171
+ return facts === undefined ? [] : [{ backend, facts }];
172
+ });
173
+ for (const { backend, facts } of absent.toSorted((a, b) => a.facts.index - b.facts.index)) {
174
+ const draft = this.element(backend, undefined, facts, 'generic');
175
+ const siblings = this.parentOf(facts.index)?.children ?? roots;
176
+ if (!isSecure(facts) && !isTextField(facts))
177
+ this.adoptText(draft, siblings);
178
+ const at = siblings.findIndex((sibling) => sibling.order > draft.order);
179
+ siblings.splice(at < 0 ? siblings.length : at, 0, draft);
180
+ }
181
+ }
182
+ build(node) {
183
+ const chromium = stringOf(node.role) ?? '';
184
+ if (isHiddenSubtree(node) || DROPPED_ROLES.has(chromium))
185
+ return [];
186
+ const backend = node.backendDOMNodeId;
187
+ const facts = backend === undefined ? undefined : this.snapshot.element(backend);
188
+ // The text as rendered, `text-transform` applied, as the web's innerText reads it.
189
+ if (chromium === 'StaticText')
190
+ return backend === undefined ? [] : this.textRun(backend, facts, stringOf(node.name) ?? '');
191
+ // Chromium leaves the text of a label out once the label names a checkbox or radio, though it is on screen: such
192
+ // a text node reads from the DOM, so the label has text to find and to tap.
193
+ const unnamed = node.ignored && facts?.bounds !== undefined ? this.snapshot.sourceText(facts.index) : undefined;
194
+ if (backend !== undefined && unnamed !== undefined)
195
+ return this.textRun(backend, facts, unnamed);
196
+ const { role, silent } = roleOf(node, facts, this.policy);
197
+ const name = spokenName(stringOf(node.name) ?? '');
198
+ // A container Chromium leaves out, or one that says nothing, gives its place to its children: unless a test id,
199
+ // a name, a locator's selector, or taking focus makes it addressable, so an action reaches it rather than the
200
+ // container its text would fold into.
201
+ const addressable = facts?.attributes[this.testIdAttribute] !== undefined ||
202
+ (backend !== undefined && this.options.keep?.has(backend) === true) ||
203
+ isFocusable(node) ||
204
+ (!node.ignored && name !== '');
205
+ if (backend === undefined)
206
+ return this.children(node);
207
+ let children;
208
+ if (silent && !addressable) {
209
+ children = this.children(node);
210
+ // Inline markup splits a sentence into parts (`Order <strong>ABC123</strong>`). A locator finds the sentence
211
+ // on the container that holds all of it, as on the web: a container with text of its own beside other
212
+ // content stays, with its parts under it.
213
+ const sentence = this.policy.descendantText && children.length > 1 && children.some((child) => child.isText);
214
+ if (!sentence)
215
+ return children;
216
+ }
217
+ if (!this.take())
218
+ return children ?? [];
219
+ const draft = this.element(backend, node, facts, silent ? 'generic' : role);
220
+ if (name !== '')
221
+ draft.name = cut(name, this.policy.nameLimit);
222
+ if (isSecure(facts))
223
+ return [draft];
224
+ // A native field's inner editor repeats its value as text, which says nothing new. An editing host
225
+ // (contenteditable) keeps its content, which is its text.
226
+ if (!isTextField(facts))
227
+ draft.children = children ?? this.children(node);
228
+ this.foldText(draft);
229
+ // A closed select's option has no text run: its text is its label, which Chromium names it by.
230
+ if (draft.text === undefined && facts?.nodeName === 'OPTION' && name !== '')
231
+ draft.text = cut(name, this.policy.textLimit);
232
+ return [draft];
233
+ }
234
+ /** Counts one more node against the cap; false once the cap is reached. */
235
+ take() {
236
+ if (this.kept >= this.policy.maxNodes) {
237
+ this.truncated = true;
238
+ return false;
239
+ }
240
+ this.kept += 1;
241
+ return true;
242
+ }
243
+ textRun(backend, facts, rendered) {
244
+ const text = collapse(rendered);
245
+ if (text === '' || !this.take())
246
+ return [];
247
+ const rect = this.rectOf(facts);
248
+ // The white space comes from the text node's own source: Chromium's name for a run trims what the next element's run follows.
249
+ const source = (facts === undefined ? undefined : this.snapshot.sourceText(facts.index)) ?? rendered;
250
+ const run = {
251
+ id: this.options.idOf(backend),
252
+ text: cut(text, this.policy.textLimit),
253
+ states: this.isHidden(facts, rect) ? { hidden: true } : {},
254
+ ...(rect === undefined ? {} : { rect }),
255
+ children: [],
256
+ isText: true,
257
+ spaceBefore: /^\s/.test(source),
258
+ spaceAfter: /\s$/.test(source),
259
+ order: facts?.index ?? -1,
260
+ };
261
+ this.drafted.set(backend, run);
262
+ return [run];
263
+ }
264
+ /** An element's node, without its name, children, or text. `node` is undefined for one the accessibility tree leaves out. */
265
+ element(backend, node, facts, role) {
266
+ const { value, ...fields } = elementFields(node, facts, role, this.context);
267
+ const rect = this.rectOf(facts);
268
+ const draft = {
269
+ id: this.options.idOf(backend),
270
+ role,
271
+ ...fields,
272
+ ...(value === undefined ? {} : { value: cut(value, this.policy.textLimit) }),
273
+ ...(rect === undefined ? {} : { rect }),
274
+ children: [],
275
+ isText: false,
276
+ order: facts?.index ?? -1,
277
+ };
278
+ if (this.isHidden(facts, rect))
279
+ draft.states['hidden'] = true;
280
+ if (isButtonInput(facts) && draft.value !== undefined && draft.value !== '')
281
+ draft.text = draft.value;
282
+ // What toBeEmpty reads, never on a secure field: a field by its value, anything else by its text content, as the
283
+ // web engine reads it (a select's option text counts, and so does hidden text).
284
+ if (this.policy.emptyState && !isSecure(facts))
285
+ draft.states['empty'] = isTextField(facts) ? (value ?? '') === '' : facts?.hasText !== true;
286
+ this.drafted.set(backend, draft);
287
+ return draft;
288
+ }
289
+ /**
290
+ * Text runs that are the node's only content are the node's text, not nodes
291
+ * of their own. Beside other children they stay nodes, and an observation
292
+ * does not repeat them on the node; a locator reads all of it, and keeps
293
+ * several runs as nodes so an exact text query finds each one
294
+ * (`<span>Price</span> <span>$10</span>`).
295
+ */
296
+ foldText(draft) {
297
+ const onlyText = draft.children.length > 0 && draft.children.every((child) => child.isText);
298
+ if (this.policy.descendantText || onlyText) {
299
+ const text = textOf(draft, this.policy.descendantText, this.snapshot);
300
+ if (text !== '')
301
+ draft.text = cut(text, this.policy.textLimit);
302
+ }
303
+ if (!onlyText)
304
+ return;
305
+ if (!this.policy.descendantText)
306
+ draft.children = [];
307
+ else if (draft.children.length === 1 && !this.runStandsApart(draft, draft.children[0]))
308
+ draft.children = [];
309
+ }
310
+ /**
311
+ * Whether a node's lone text run stays a node of its own for a locator:
312
+ * the run sits inside elements the tree leaves out
313
+ * (`<div role="toolbar"><span>Unselect All</span></div>`), so the text has
314
+ * a box of its own, which is where a tap on the text belongs and what a
315
+ * text query on the web answers with. Decided by the document's structure
316
+ * alone, never by where things are drawn.
317
+ */
318
+ runStandsApart(draft, run) {
319
+ if (draft.role !== undefined && TEXT_IS_THE_NODE.has(draft.role))
320
+ return false;
321
+ return this.snapshot.parentOf(run.order) !== draft.order;
322
+ }
323
+ /**
324
+ * The text of an element the tree left out. The text runs the tree already
325
+ * holds for it move under it, so its text is not read twice; with none
326
+ * (nothing rendered), the text comes from the DOM.
327
+ */
328
+ adoptText(draft, siblings) {
329
+ const inside = this.snapshot.subtree(draft.order);
330
+ const runs = siblings.filter((sibling) => sibling.isText && inside.has(sibling.order));
331
+ if (runs.length === 0) {
332
+ const text = this.snapshot.textContent(draft.order);
333
+ if (text !== '')
334
+ draft.text = cut(text, this.policy.textLimit);
335
+ return;
336
+ }
337
+ for (const run of runs)
338
+ siblings.splice(siblings.indexOf(run), 1);
339
+ draft.children = runs;
340
+ this.foldText(draft);
341
+ }
342
+ /** The nearest DOM ancestor of the node at `index` that is an element in the tree; undefined when it sits under the root. */
343
+ parentOf(index) {
344
+ for (const backend of this.snapshot.ancestors(index)) {
345
+ const draft = this.drafted.get(backend);
346
+ if (draft !== undefined && !draft.isText)
347
+ return draft;
348
+ }
349
+ return undefined;
350
+ }
351
+ rectOf(facts) {
352
+ const box = facts?.bounds;
353
+ if (box === undefined || box.length < 4)
354
+ return undefined;
355
+ const [x = 0, y = 0, width = 0, height = 0] = box;
356
+ const { scale, scrollX, scrollY } = this.geometry;
357
+ return { x: x / scale - scrollX, y: y / scale - scrollY, width: width / scale, height: height / scale };
358
+ }
359
+ /**
360
+ * Hidden as the web reads it: by its `visibility`, else by its box. An
361
+ * element with no box of its own (`display: contents`) is shown while
362
+ * something inside it is rendered, and a checkbox or radio with none
363
+ * while its label draws it.
364
+ */
365
+ isHidden(facts, rect) {
366
+ if (facts === undefined || facts.invisible)
367
+ return true;
368
+ const sized = rect !== undefined && rect.width > 0 && rect.height > 0;
369
+ if (sized || (rect === undefined && this.snapshot.rendersContent(facts.index)))
370
+ return false;
371
+ return !(isCheckable(facts) && this.snapshot.drawnByLabel(facts.index));
372
+ }
373
+ }
374
+ /** Projects the window's accessibility tree onto the contract's semantic tree. */
375
+ export function projectTree(axNodes, snapshot, geometry, options) {
376
+ const projector = new TreeProjector(axNodes, snapshot, geometry, options);
377
+ const rootNode = axNodes.find((node) => node.parentId === undefined) ?? axNodes[0];
378
+ const children = rootNode === undefined ? [] : projector.children(rootNode);
379
+ projector.placeAbsent(children);
380
+ const rootName = options.title ?? stringOf(rootNode?.name);
381
+ const root = {
382
+ ref: { id: options.rootId, revision: '' },
383
+ role: 'document',
384
+ ...(rootName === undefined || rootName === '' ? {} : { name: cut(rootName, POLICIES[options.mode].nameLimit) }),
385
+ rect: { x: 0, y: 0, width: geometry.width, height: geometry.height },
386
+ ...(children.length === 0 ? {} : { children: children.map(finish) }),
387
+ };
388
+ return { root, truncated: projector.truncated };
389
+ }
390
+ /** A draft as a contract node, empty fields left out. */
391
+ function finish(draft) {
392
+ return {
393
+ ref: { id: draft.id, revision: '' },
394
+ ...(draft.role === undefined ? {} : { role: draft.role }),
395
+ ...(draft.name === undefined ? {} : { name: draft.name }),
396
+ ...(draft.text === undefined ? {} : { text: draft.text }),
397
+ ...(draft.value === undefined ? {} : { value: draft.value }),
398
+ ...(draft.testId === undefined ? {} : { testId: draft.testId }),
399
+ ...(draft.inputPurpose === undefined ? {} : { inputPurpose: draft.inputPurpose }),
400
+ ...(Object.keys(draft.states).length === 0 ? {} : { states: draft.states }),
401
+ ...(draft.level === undefined ? {} : { level: draft.level }),
402
+ ...(draft.attributes === undefined ? {} : { attributes: draft.attributes }),
403
+ ...(draft.rect === undefined ? {} : { rect: draft.rect }),
404
+ ...(draft.children.length === 0 ? {} : { children: draft.children.map(finish) }),
405
+ };
406
+ }
@@ -0,0 +1,42 @@
1
+ /**
2
+ * A recording of the app: the DevTools screencast of whichever window is
3
+ * shown, its JPEG frames encoded to one VP9 webm by ffmpeg. The file outlives
4
+ * a window: switching windows, or relaunching the app, moves the screencast
5
+ * to the window shown next, and the gap holds the last frame.
6
+ */
7
+ import { type VideoFile } from '@e2e-dev/core/engine';
8
+ import type { PageTarget } from './page.ts';
9
+ export declare class Recorder {
10
+ private readonly ffmpeg;
11
+ private readonly relative;
12
+ private readonly allowed;
13
+ private encoder;
14
+ private startedAt;
15
+ private source;
16
+ /** Source switches run one at a time, in the order the windows were shown. */
17
+ private switching;
18
+ private stopped;
19
+ private readonly absolute;
20
+ /**
21
+ * `relative` is the file under the attempt's artifacts. `allowed` says
22
+ * whether a window's pixels may be kept: frames of one that may not are
23
+ * dropped, and the video holds the frame before.
24
+ */
25
+ constructor(ffmpeg: string, artifactsDir: string, relative: string, allowed: (page: PageTarget) => boolean);
26
+ /** Records `page` from now on, or nothing when the app shows no window. */
27
+ follow(page: PageTarget | undefined): void;
28
+ private switchTo;
29
+ /**
30
+ * Ends the recording and returns its file, or nothing when no window was
31
+ * ever shown.
32
+ */
33
+ stop(): Promise<readonly VideoFile[]>;
34
+ /**
35
+ * Adds the shown window as it stands to the video. A screencast sends a
36
+ * frame only when the window repaints, so a still window is captured here:
37
+ * once the app has launched, and when the recording ends.
38
+ */
39
+ snap(): Promise<void>;
40
+ /** Ends a recording nobody collects: the file it wrote is removed. */
41
+ abandon(): Promise<void>;
42
+ }