@e2e-dev/electron 0.1.1 → 0.1.2-nightly-20261205030542

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.
package/dist/cdp/input.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
- * Trusted input over `Input.*`: a keyboard and a mouse for one page, each
3
- * tracking what is held so modifiers apply to the keys and clicks after
4
- * them.
2
+ * Trusted input over `Input.*`: a keyboard and a mouse for one page, sharing
3
+ * what `electron.keyboard.down` and `electron.mouse.down` hold across the
4
+ * app's windows while keeping a gesture's own chords and presses on its page.
5
5
  */
6
6
  import { KEY_LAYOUT, MAC_EDITING_COMMANDS } from './keys.js';
7
7
  const MODIFIERS = ['Alt', 'Control', 'Meta', 'Shift'];
@@ -26,57 +26,160 @@ function platformKey(key) {
26
26
  export function hasKey(key) {
27
27
  return KEY_LAYOUT.has(platformKey(key));
28
28
  }
29
+ /** Records `target` as an owner of `key`. */
30
+ function addOwner(map, key, target) {
31
+ const existing = map.get(key);
32
+ if (existing !== undefined)
33
+ existing.add(target);
34
+ else
35
+ map.set(key, new Set([target]));
36
+ }
37
+ /** Removes `target` from `map.get(key)`, deleting the key once no owner remains. */
38
+ function removeOwner(map, key, target) {
39
+ const owners = map.get(key);
40
+ owners?.delete(target);
41
+ if (owners?.size === 0)
42
+ map.delete(key);
43
+ }
44
+ /** The modifier a key code is (`ShiftRight` is `Shift`), if it is one. */
45
+ function modifierOf(code) {
46
+ const key = KEY_LAYOUT.get(code)?.key;
47
+ return key !== undefined && isModifier(key) ? key : undefined;
48
+ }
49
+ /** Keys and mouse buttons `electron.keyboard.down` and `electron.mouse.down` hold across an app's windows. */
50
+ export class HeldInput {
51
+ modifiers = new Map();
52
+ keys = new Map();
53
+ buttons = new Map();
54
+ #lastButton = 'none';
55
+ #writes = 0;
56
+ /** The button of the newest press, or `none` after a release. */
57
+ get lastButton() {
58
+ return this.#lastButton;
59
+ }
60
+ /** Sets the last button and returns the write's number, which a failed press compares to undo only its own write. */
61
+ setLastButton(button) {
62
+ this.#lastButton = button;
63
+ this.#writes += 1;
64
+ return this.#writes;
65
+ }
66
+ /** Whether no write came after the one numbered `write`. */
67
+ isLastWrite(write) {
68
+ return this.#writes === write;
69
+ }
70
+ }
29
71
  export class Keyboard {
30
72
  target;
31
- heldModifiers = new Set();
32
- heldKeys = new Set();
33
- constructor(target) {
73
+ shared;
74
+ localModifiers = new Set();
75
+ localKeys = new Set();
76
+ pinnedModifiers = new Set();
77
+ constructor(target, shared) {
34
78
  this.target = target;
79
+ this.shared = shared;
35
80
  }
36
- /** The modifiers held now. */
81
+ /** The modifiers held now, across the app and by an in-flight gesture on this page. */
37
82
  modifiers() {
38
- return this.heldModifiers;
83
+ return new Set([...this.shared.modifiers.keys(), ...this.localModifiers, ...this.pinnedModifiers]);
39
84
  }
40
85
  /** Whether a modifier is held now, by any name it is pressed by (`ControlOrMeta` too). */
41
86
  holds(modifier) {
42
87
  const key = platformKey(modifier);
43
- return isModifier(key) && this.heldModifiers.has(key);
88
+ return isModifier(key) && this.modifiers().has(key);
44
89
  }
45
- /** Forgets what is held: the renderer that held it is gone. */
90
+ /** Keeps an already-held modifier active on this page for the duration of a chord, even if another window closes. */
91
+ pinModifier(modifier) {
92
+ const key = platformKey(modifier);
93
+ if (isModifier(key))
94
+ this.pinnedModifiers.add(key);
95
+ }
96
+ /** Releases the chord pin placed by `pinModifier`. */
97
+ unpinModifier(modifier) {
98
+ const key = platformKey(modifier);
99
+ if (isModifier(key))
100
+ this.pinnedModifiers.delete(key);
101
+ }
102
+ /** Forgets the keys held on this page once it closes or its renderer crashes. */
46
103
  reset() {
47
- this.heldModifiers.clear();
48
- this.heldKeys.clear();
104
+ this.localModifiers.clear();
105
+ this.localKeys.clear();
106
+ this.pinnedModifiers.clear();
107
+ for (const modifier of this.shared.modifiers.keys())
108
+ removeOwner(this.shared.modifiers, modifier, this.target);
109
+ for (const code of this.shared.keys.keys())
110
+ removeOwner(this.shared.keys, code, this.target);
49
111
  }
50
- /** Presses a key down and leaves it held; a held modifier applies to the keys and mouse events after it. */
51
- async down(key) {
112
+ /** Presses a key down and leaves it held; `local` keeps a gesture's own press on this page alone. */
113
+ async down(key, options) {
52
114
  const description = this.describe(key);
53
- const autoRepeat = this.heldKeys.has(description.code);
54
- this.heldKeys.add(description.code);
55
- if (isModifier(description.key))
56
- this.heldModifiers.add(description.key);
57
- await this.target.session.send('Input.dispatchKeyEvent', {
58
- type: description.text === '' ? 'rawKeyDown' : 'keyDown',
59
- modifiers: modifiersMask(this.heldModifiers),
60
- windowsVirtualKeyCode: description.keyCodeWithoutLocation,
61
- code: description.code,
62
- commands: this.editingCommands(description.code),
63
- key: description.key,
64
- text: description.text,
65
- unmodifiedText: description.text,
66
- autoRepeat,
67
- location: description.location,
68
- isKeypad: description.location === KEYPAD_LOCATION,
69
- });
115
+ const local = options?.local === true;
116
+ const modifier = isModifier(description.key) ? description.key : undefined;
117
+ const autoRepeat = this.shared.keys.has(description.code) || this.localKeys.has(description.code);
118
+ const hadLocalKey = this.localKeys.has(description.code);
119
+ const hadLocalMod = modifier !== undefined && this.localModifiers.has(modifier);
120
+ const hadSharedKey = this.shared.keys.get(description.code)?.has(this.target) === true;
121
+ const hadSharedMod = modifier !== undefined && this.shared.modifiers.get(modifier)?.has(this.target) === true;
122
+ if (local) {
123
+ this.localKeys.add(description.code);
124
+ if (modifier !== undefined)
125
+ this.localModifiers.add(modifier);
126
+ }
127
+ else {
128
+ addOwner(this.shared.keys, description.code, this.target);
129
+ if (modifier !== undefined)
130
+ addOwner(this.shared.modifiers, modifier, this.target);
131
+ }
132
+ const modifiers = this.modifiers();
133
+ try {
134
+ await this.target.session.send('Input.dispatchKeyEvent', {
135
+ type: description.text === '' ? 'rawKeyDown' : 'keyDown',
136
+ modifiers: modifiersMask(modifiers),
137
+ windowsVirtualKeyCode: description.keyCodeWithoutLocation,
138
+ code: description.code,
139
+ commands: this.editingCommands(description.code, modifiers),
140
+ key: description.key,
141
+ text: description.text,
142
+ unmodifiedText: description.text,
143
+ autoRepeat,
144
+ location: description.location,
145
+ isKeypad: description.location === KEYPAD_LOCATION,
146
+ });
147
+ }
148
+ catch (error) {
149
+ if (local) {
150
+ if (!hadLocalKey)
151
+ this.localKeys.delete(description.code);
152
+ if (modifier !== undefined && !hadLocalMod)
153
+ this.localModifiers.delete(modifier);
154
+ }
155
+ else {
156
+ if (!hadSharedKey)
157
+ removeOwner(this.shared.keys, description.code, this.target);
158
+ if (modifier !== undefined && !hadSharedMod)
159
+ removeOwner(this.shared.modifiers, modifier, this.target);
160
+ }
161
+ throw error;
162
+ }
70
163
  }
71
- /** Releases a key `down` pressed. */
72
- async up(key) {
164
+ /**
165
+ * Releases a key `down` pressed. A shared release commits before its event
166
+ * is sent, as one keyboard's would: a send that fails on a closing window
167
+ * still releases the key everywhere, as a send that lands does.
168
+ */
169
+ async up(key, options) {
73
170
  const description = this.describe(key);
74
- if (isModifier(description.key))
75
- this.heldModifiers.delete(description.key);
76
- this.heldKeys.delete(description.code);
171
+ const modifier = isModifier(description.key) ? description.key : undefined;
172
+ if (options?.local === true) {
173
+ this.localKeys.delete(description.code);
174
+ if (modifier !== undefined)
175
+ this.localModifiers.delete(modifier);
176
+ }
177
+ else {
178
+ this.release(description.code, modifier !== undefined && platformKey(key) === modifier);
179
+ }
77
180
  await this.target.session.send('Input.dispatchKeyEvent', {
78
181
  type: 'keyUp',
79
- modifiers: modifiersMask(this.heldModifiers),
182
+ modifiers: modifiersMask(this.modifiers()),
80
183
  key: description.key,
81
184
  windowsVirtualKeyCode: description.keyCodeWithoutLocation,
82
185
  code: description.code,
@@ -84,9 +187,38 @@ export class Keyboard {
84
187
  isKeypad: description.location === KEYPAD_LOCATION,
85
188
  });
86
189
  }
87
- /** Presses a key down and releases it, under whatever modifiers are held. */
190
+ /**
191
+ * Forgets a shared hold on `code`. A modifier stays held while another key
192
+ * of it is (`ShiftRight` after `ShiftLeft` goes up), except when released
193
+ * by its plain name: `up('Shift')` releases both sides, as on `main`.
194
+ */
195
+ release(code, byModifierName) {
196
+ const modifier = modifierOf(code);
197
+ if (modifier === undefined) {
198
+ this.shared.keys.delete(code);
199
+ return;
200
+ }
201
+ for (const held of this.shared.keys.keys()) {
202
+ if (held === code || (byModifierName && modifierOf(held) === modifier))
203
+ this.shared.keys.delete(held);
204
+ }
205
+ const owners = new Set();
206
+ for (const [held, holders] of this.shared.keys)
207
+ if (modifierOf(held) === modifier)
208
+ for (const owner of holders)
209
+ owners.add(owner);
210
+ if (owners.size > 0)
211
+ this.shared.modifiers.set(modifier, owners);
212
+ else
213
+ this.shared.modifiers.delete(modifier);
214
+ }
215
+ /** Presses a key down and releases it on this page, releasing a shared hold on that key once the press answers. */
88
216
  async press(key) {
89
- await this.down(key);
217
+ await this.down(key, { local: true });
218
+ const description = this.describe(key);
219
+ this.localKeys.delete(description.code);
220
+ if (isModifier(description.key))
221
+ this.localModifiers.delete(description.key);
90
222
  await this.up(key);
91
223
  }
92
224
  /** Types one character: its key when the layout has one, else the character inserted as text. */
@@ -105,17 +237,18 @@ export class Keyboard {
105
237
  let description = KEY_LAYOUT.get(key);
106
238
  if (description === undefined)
107
239
  throw new Error(`the keyboard has no key ${JSON.stringify(key)}`);
108
- if (this.heldModifiers.has('Shift') && description.shifted !== undefined)
240
+ const modifiers = this.modifiers();
241
+ if (modifiers.has('Shift') && description.shifted !== undefined)
109
242
  description = description.shifted;
110
243
  // A key pressed with Control, Alt, or Meta held types nothing.
111
- const onlyShift = this.heldModifiers.size === 1 && this.heldModifiers.has('Shift');
112
- return this.heldModifiers.size > 0 && !onlyShift ? { ...description, text: '' } : description;
244
+ const onlyShift = modifiers.size === 1 && modifiers.has('Shift');
245
+ return modifiers.size > 0 && !onlyShift ? { ...description, text: '' } : description;
113
246
  }
114
247
  /** The editing commands macOS runs for this key with the held modifiers; text insertion is left to the event's `text`. */
115
- editingCommands(code) {
248
+ editingCommands(code, modifiers) {
116
249
  if (!IS_MAC)
117
250
  return [];
118
- const chord = [...['Shift', 'Control', 'Alt', 'Meta'].filter((modifier) => this.heldModifiers.has(modifier)), code].join('+');
251
+ const chord = [...['Shift', 'Control', 'Alt', 'Meta'].filter((modifier) => modifiers.has(modifier)), code].join('+');
119
252
  return (MAC_EDITING_COMMANDS[chord] ?? []).filter((command) => !command.startsWith('insert'));
120
253
  }
121
254
  }
@@ -128,53 +261,101 @@ export class Keyboard {
128
261
  export class Mouse {
129
262
  target;
130
263
  keyboard;
264
+ shared;
131
265
  x = 0;
132
266
  y = 0;
133
- lastButton = 'none';
134
- buttons = new Set();
135
- constructor(target, keyboard) {
267
+ localLastButton = 'none';
268
+ localButtons = new Set();
269
+ constructor(target, keyboard, shared) {
136
270
  this.target = target;
137
271
  this.keyboard = keyboard;
272
+ this.shared = shared;
138
273
  }
139
- /** Forgets the buttons held: the renderer that held them is gone. */
274
+ /** Forgets the buttons held on this page once it closes or its renderer crashes. */
140
275
  reset() {
141
- this.buttons.clear();
142
- this.lastButton = 'none';
276
+ this.localButtons.clear();
277
+ this.localLastButton = 'none';
278
+ for (const button of this.shared.buttons.keys())
279
+ removeOwner(this.shared.buttons, button, this.target);
280
+ if (this.shared.lastButton !== 'none' && !this.shared.buttons.has(this.shared.lastButton))
281
+ this.shared.setLastButton('none');
282
+ }
283
+ heldButtons() {
284
+ return new Set([...this.shared.buttons.keys(), ...this.localButtons]);
143
285
  }
144
286
  async move(x, y) {
145
287
  this.x = x;
146
288
  this.y = y;
289
+ const button = this.localLastButton !== 'none' ? this.localLastButton : this.shared.lastButton;
147
290
  await this.target.session.send('Input.dispatchMouseEvent', {
148
291
  type: 'mouseMoved',
149
- button: this.lastButton,
150
- buttons: buttonsMask(this.buttons),
292
+ button,
293
+ buttons: buttonsMask(this.heldButtons()),
151
294
  x,
152
295
  y,
153
296
  modifiers: modifiersMask(this.keyboard.modifiers()),
154
297
  });
155
298
  }
156
- /** Presses a button where the pointer is. */
157
- async down(button = 'left', clickCount = 1) {
158
- this.lastButton = button;
159
- this.buttons.add(button);
160
- await this.target.session.send('Input.dispatchMouseEvent', {
161
- type: 'mousePressed',
162
- button,
163
- buttons: buttonsMask(this.buttons),
164
- x: this.x,
165
- y: this.y,
166
- modifiers: modifiersMask(this.keyboard.modifiers()),
167
- clickCount,
168
- });
299
+ /** Presses a button where the pointer is; `local` keeps a gesture's own press on this page alone. */
300
+ async down(button = 'left', clickCount = 1, options) {
301
+ const local = options?.local === true;
302
+ const hadLocal = this.localButtons.has(button);
303
+ const previousLocalLast = this.localLastButton;
304
+ const hadShared = this.shared.buttons.get(button)?.has(this.target) === true;
305
+ const previousSharedLast = this.shared.lastButton;
306
+ let write = 0;
307
+ if (local) {
308
+ this.localButtons.add(button);
309
+ this.localLastButton = button;
310
+ }
311
+ else {
312
+ addOwner(this.shared.buttons, button, this.target);
313
+ write = this.shared.setLastButton(button);
314
+ }
315
+ try {
316
+ await this.target.session.send('Input.dispatchMouseEvent', {
317
+ type: 'mousePressed',
318
+ button,
319
+ buttons: buttonsMask(this.heldButtons()),
320
+ x: this.x,
321
+ y: this.y,
322
+ modifiers: modifiersMask(this.keyboard.modifiers()),
323
+ clickCount,
324
+ });
325
+ }
326
+ catch (error) {
327
+ if (local) {
328
+ if (!hadLocal)
329
+ this.localButtons.delete(button);
330
+ this.localLastButton = previousLocalLast;
331
+ }
332
+ else {
333
+ if (!hadShared)
334
+ removeOwner(this.shared.buttons, button, this.target);
335
+ // Only this press's own write is rolled back, and only to a button still held: a later press or release keeps its own.
336
+ if (this.shared.isLastWrite(write)) {
337
+ this.shared.setLastButton(previousSharedLast !== 'none' && this.shared.buttons.has(previousSharedLast) ? previousSharedLast : 'none');
338
+ }
339
+ }
340
+ throw error;
341
+ }
169
342
  }
170
- /** Releases a button where the pointer is. */
171
- async up(button = 'left', clickCount = 1) {
172
- this.lastButton = 'none';
173
- this.buttons.delete(button);
343
+ /**
344
+ * Releases a button where the pointer is. The release commits before its
345
+ * event is sent, and a gesture's own (`local`) release also releases the
346
+ * button the test holds, as a tap does: one mouse serves every window.
347
+ */
348
+ async up(button = 'left', clickCount = 1, options) {
349
+ if (options?.local === true) {
350
+ this.localButtons.delete(button);
351
+ this.localLastButton = 'none';
352
+ }
353
+ this.shared.buttons.delete(button);
354
+ this.shared.setLastButton('none');
174
355
  await this.target.session.send('Input.dispatchMouseEvent', {
175
356
  type: 'mouseReleased',
176
357
  button,
177
- buttons: buttonsMask(this.buttons),
358
+ buttons: buttonsMask(this.heldButtons()),
178
359
  x: this.x,
179
360
  y: this.y,
180
361
  modifiers: modifiersMask(this.keyboard.modifiers()),
@@ -190,6 +371,14 @@ export class Mouse {
190
371
  }
191
372
  /** A wheel event where the pointer is. */
192
373
  async wheel(deltaX, deltaY) {
193
- await this.target.session.send('Input.dispatchMouseEvent', { type: 'mouseWheel', x: this.x, y: this.y, modifiers: modifiersMask(this.keyboard.modifiers()), deltaX, deltaY });
374
+ await this.target.session.send('Input.dispatchMouseEvent', {
375
+ type: 'mouseWheel',
376
+ x: this.x,
377
+ y: this.y,
378
+ buttons: buttonsMask(this.heldButtons()),
379
+ modifiers: modifiersMask(this.keyboard.modifiers()),
380
+ deltaX,
381
+ deltaY,
382
+ });
194
383
  }
195
384
  }
@@ -21,6 +21,12 @@ export declare class DevTools {
21
21
  * the document dropped fails as stale.
22
22
  */
23
23
  callOn<K extends keyof NodeOps>(page: PageTarget, backendNodeId: number, name: K, ...args: Parameters<NodeOps[K]>): Promise<ReturnType<NodeOps[K]>>;
24
+ /**
25
+ * The backend id of the element a field action on the node works on: the
26
+ * node's own, or, for the text of a label, the control the label names
27
+ * (`followLabel` in `NodeOps`).
28
+ */
29
+ followLabel(page: PageTarget, backendNodeId: number): Promise<number>;
24
30
  /**
25
31
  * Whether the element with keyboard focus takes typed text. Page script
26
32
  * stops at the host of a closed shadow root; the DevTools protocol reaches
package/dist/devtools.js CHANGED
@@ -50,6 +50,29 @@ export class DevTools {
50
50
  return result.value;
51
51
  });
52
52
  }
53
+ /**
54
+ * The backend id of the element a field action on the node works on: the
55
+ * node's own, or, for the text of a label, the control the label names
56
+ * (`followLabel` in `NodeOps`).
57
+ */
58
+ followLabel(page, backendNodeId) {
59
+ return this.inWorld(page, async (session, executionContextId, objectGroup) => {
60
+ const { object } = await session.send('DOM.resolveNode', { backendNodeId, executionContextId, objectGroup });
61
+ if (object.objectId === undefined)
62
+ throw stale(`node ${backendNodeId} is no longer in the window`);
63
+ const { result, exceptionDetails } = await session.send('Runtime.callFunctionOn', {
64
+ objectId: object.objectId,
65
+ functionDeclaration: NODE_OP,
66
+ arguments: [{ objectId: object.objectId }, { value: 'followLabel' }, { value: [] }],
67
+ objectGroup,
68
+ });
69
+ if (exceptionDetails !== undefined)
70
+ throw new Error(thrown(exceptionDetails));
71
+ if (result.objectId === undefined)
72
+ return backendNodeId;
73
+ return (await session.send('DOM.describeNode', { objectId: result.objectId })).node.backendNodeId;
74
+ });
75
+ }
53
76
  /**
54
77
  * Whether the element with keyboard focus takes typed text. Page script
55
78
  * stops at the host of a closed shadow root; the DevTools protocol reaches
package/dist/engine.js CHANGED
@@ -41,6 +41,8 @@ export function electron(options = {}) {
41
41
  perform: (ref, action, operation) => surface.perform(ref, action, operation),
42
42
  actions: [...LOCATOR_ACTION_KINDS, 'blur', 'multiTap', 'setInputFilePayloads'],
43
43
  tapModifiers: true,
44
+ // Chromium paints the whole page past the viewport, and the masks with it.
45
+ fullPageScreenshots: true,
44
46
  performAt: (point, action, operation) => surface.performAt(point, action, operation),
45
47
  pointerActions: POINTER_ACTION_KINDS,
46
48
  keyboard: {
@@ -57,7 +59,7 @@ export function electron(options = {}) {
57
59
  closeTab: (index, operation) => surface.closeTab(index, operation),
58
60
  },
59
61
  artifacts: {
60
- screenshot: (label, operation) => surface.screenshot(label, operation),
62
+ screenshot: (label, operation, screenshotOptions) => surface.screenshot(label, operation, screenshotOptions),
61
63
  startVideo: (operation) => surface.startVideo(operation),
62
64
  stopVideo: () => surface.stopVideo(),
63
65
  },
@@ -80,7 +82,7 @@ function validateApp(app, { targetName }, executablePath) {
80
82
  throw new ConfigurationError('INVALID_CONFIG', `${where} declares app.bundleId, which an electron() target cannot launch; name the app with app.appPath`);
81
83
  if (app.permissions !== undefined)
82
84
  throw new ConfigurationError('INVALID_CONFIG', `${where} declares app.permissions, which an electron() target cannot set`);
83
- const owned = app.launchArguments?.map(ownedArgument).find((reason) => reason !== undefined);
85
+ const owned = app.launchArguments?.map((argument) => ownedArgument(argument)).find((reason) => reason !== undefined);
84
86
  if (owned !== undefined)
85
87
  throw new ConfigurationError('INVALID_CONFIG', `${where} app.launchArguments ${owned}`);
86
88
  if (app.appPath === undefined && executablePath === undefined) {
@@ -45,10 +45,25 @@ export interface NodeOps {
45
45
  * change events; null when the value is to be typed instead.
46
46
  */
47
47
  setValue(value: string): Readiness | null;
48
- /** Focuses the element and selects its whole content; false when the app moved focus away. */
49
- selectContents(): boolean;
48
+ /**
49
+ * Focuses the element and selects its whole content: `selected`, or
50
+ * `empty` when an element in an editing host has no content and the
51
+ * selection is a caret (a key that deletes would take what follows it),
52
+ * or `moved` when the app moved focus away.
53
+ */
54
+ selectContents(): 'selected' | 'empty' | 'moved';
55
+ /**
56
+ * The element a field action on the node works on: the node, or the
57
+ * control of the label it is the text of. Returned as an object, never by
58
+ * value: `DevTools.followLabel` reads its backend id.
59
+ */
60
+ followLabel(): Element;
61
+ /** Not disabled, whether or not it shows: the control a label names can be hidden while the label draws it. */
62
+ checkControlEnabled(): Readiness;
50
63
  /** A checkbox's or radio's checked state, or `aria-checked` on a role that has one; null when it has none (a toggle button's `aria-pressed` is not a checked state, as on the web). */
51
64
  readChecked(): boolean | null;
65
+ /** A native checkbox's or radio's checked state, read whether or not it is still in the document; null for any other node. */
66
+ readCheckedAsLeft(): boolean | null;
52
67
  /** A `<select>` that is enabled and holds the option, enabled. */
53
68
  checkSelect(wanted: WantedOption): Readiness;
54
69
  selectOption(wanted: WantedOption): Readiness;
@@ -56,8 +71,16 @@ export interface NodeOps {
56
71
  checkFileInput(): Readiness;
57
72
  /** Whether the file input takes `count` files: more than one needs `multiple`. */
58
73
  takesFiles(count: number): Readiness;
59
- /** Empties a file input, with its input and change events. */
60
- clearFiles(): void;
74
+ /** Whether the file input takes a directory, the files under it, as one with `webkitdirectory` does; whether or not it is still in the document, as a chooser's input need not be. */
75
+ takesDirectory(): boolean;
76
+ /** Empties a file input, with its input and change events; `inDocument` fails it as detached once the document dropped it. */
77
+ clearFiles(inDocument: boolean): void;
78
+ /** Sets a file input's files, made here from their bytes, with its input and change events; `inDocument` as for `clearFiles`. */
79
+ setFiles(files: readonly {
80
+ readonly name: string;
81
+ readonly mimeType: string;
82
+ readonly base64: string;
83
+ }[], inDocument: boolean): void;
61
84
  /** A native radio: one a click never clears. A custom one clears if its app says so. */
62
85
  isNativeRadio(): boolean;
63
86
  /** Whether the node is a file input, which takes files itself. */