@burdenoff/ui-engine 2026.1127.3 → 2026.1127.5

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 (65) hide show
  1. package/README.md +71 -5
  2. package/dist/analyze/analyze.d.ts +19 -0
  3. package/dist/analyze/context.d.ts +40 -0
  4. package/dist/analyze/index.d.ts +10 -0
  5. package/dist/analyze/messages.d.ts +39 -0
  6. package/dist/analyze/rules/fixed-wait.d.ts +6 -0
  7. package/dist/analyze/rules/hardware-input.d.ts +2 -0
  8. package/dist/analyze/rules/index.d.ts +3 -0
  9. package/dist/analyze/rules/inline-target.d.ts +2 -0
  10. package/dist/analyze/rules/masked-value.d.ts +8 -0
  11. package/dist/analyze/rules/no-cleanup.d.ts +2 -0
  12. package/dist/analyze/rules/plain-text-secret.d.ts +2 -0
  13. package/dist/analyze/rules/rule.d.ts +15 -0
  14. package/dist/analyze/rules/secret-origin.d.ts +7 -0
  15. package/dist/analyze/rules/sensitive-screenshot.d.ts +2 -0
  16. package/dist/analyze/rules/single-method-target.d.ts +2 -0
  17. package/dist/analyze/rules/unknown-variable.d.ts +2 -0
  18. package/dist/analyze/rules/unused-value.d.ts +2 -0
  19. package/dist/analyze/sensitive.d.ts +14 -0
  20. package/dist/analyze/types.d.ts +66 -0
  21. package/dist/analyze.d.ts +2 -0
  22. package/dist/analyze.js +26 -0
  23. package/dist/dom-runtime.iife.js +1 -1
  24. package/dist/dom-runtime.js +27 -532
  25. package/dist/drivers/dom-driver.d.ts +44 -0
  26. package/dist/drivers/index.d.ts +7 -0
  27. package/dist/drivers/snapshot-driver.d.ts +59 -0
  28. package/dist/drivers.d.ts +2 -0
  29. package/dist/drivers.js +172 -0
  30. package/dist/index-21hvbvx1.js +340 -0
  31. package/dist/{index-q1b0j9yr.js → index-5k26keah.js} +58 -592
  32. package/dist/index-77pcz6n3.js +303 -0
  33. package/dist/index-8w0f6rsz.js +402 -0
  34. package/dist/index-9s5nphx0.js +99 -0
  35. package/dist/index-c88tvyj1.js +743 -0
  36. package/dist/index-ct2xctrq.js +229 -0
  37. package/dist/index-g7724awk.js +224 -0
  38. package/dist/index-gvavb597.js +195 -0
  39. package/dist/index-r2a9rftv.js +1740 -0
  40. package/dist/index-s7qdecev.js +489 -0
  41. package/dist/index-vg8r40y7.js +220 -0
  42. package/dist/index-xner4tgb.js +810 -0
  43. package/dist/index-ycs2bz1a.js +589 -0
  44. package/dist/index.d.ts +2 -0
  45. package/dist/index.js +163 -49
  46. package/dist/interpret/compile.d.ts +58 -0
  47. package/dist/interpret/driver.d.ts +171 -0
  48. package/dist/interpret/errors.d.ts +194 -0
  49. package/dist/interpret/events.d.ts +73 -0
  50. package/dist/interpret/expr.d.ts +35 -0
  51. package/dist/interpret/index.d.ts +13 -0
  52. package/dist/interpret/run.d.ts +77 -0
  53. package/dist/interpret.d.ts +2 -0
  54. package/dist/interpret.js +84 -0
  55. package/dist/script/adapters/browser-action-contract.d.ts +5 -2
  56. package/dist/script/limits.d.ts +2 -0
  57. package/dist/script.js +60 -50
  58. package/dist/target/index.d.ts +1 -1
  59. package/dist/target/resolve.d.ts +18 -1
  60. package/dist/target.js +23 -19
  61. package/dist/testing/fake-web-driver.d.ts +28 -0
  62. package/dist/testing/index.d.ts +3 -2
  63. package/dist/testing.js +55 -0
  64. package/package.json +15 -3
  65. package/dist/index-zwrxw3zp.js +0 -1988
@@ -0,0 +1,172 @@
1
+ import"./index-cs6acyjn.js";
2
+ import {
3
+ parseUiScript2
4
+ } from "./index-c88tvyj1.js";
5
+ import {
6
+ DOM_DRIVER_CAPABILITIES2,
7
+ safePageText2,
8
+ safePageHtml2,
9
+ createDomDriver2
10
+ } from "./index-21hvbvx1.js";
11
+ import {
12
+ runUiScript2
13
+ } from "./index-r2a9rftv.js";
14
+ import {
15
+ UiDriverError2,
16
+ createVirtualClock2
17
+ } from "./index-vg8r40y7.js";
18
+ import {
19
+ CAPABILITY_IDS2
20
+ } from "./index-9s5nphx0.js";
21
+ import {
22
+ walkSteps2,
23
+ stepTargets2
24
+ } from "./index-g7724awk.js";
25
+ import {
26
+ hydrateTreeSnapshot2
27
+ } from "./index-5k26keah.js";
28
+ // src/drivers/snapshot-driver.ts
29
+ var SNAPSHOT_DRIVER_CAPABILITIES = CAPABILITY_IDS2.filter((id) => id !== "action:focusWindow");
30
+ var ignore = () => {
31
+ return;
32
+ };
33
+ function uncheckedFound(target) {
34
+ const method = target.methods.find((item) => item.enabled !== false) ?? target.methods[0];
35
+ const kind = method?.kind ?? "css";
36
+ return {
37
+ status: "found",
38
+ method: kind,
39
+ methodIndex: Math.max(0, method ? target.methods.indexOf(method) : 0),
40
+ fallback: false,
41
+ candidate: { role: "", name: "", bounds: { x: 0, y: 0, width: 0, height: 0 }, method: kind, methodIndex: 0 },
42
+ attempts: []
43
+ };
44
+ }
45
+ function createSnapshotDriver(options) {
46
+ const { probe } = hydrateTreeSnapshot2(options.document, options.snapshot);
47
+ const inner = createDomDriver2({
48
+ document: options.document,
49
+ ...probe,
50
+ capabilities: SNAPSHOT_DRIVER_CAPABILITIES,
51
+ clock: createVirtualClock2(0),
52
+ staticPage: true,
53
+ replay: true,
54
+ dryRun: true,
55
+ navigation: {
56
+ navigate: ignore,
57
+ goBack: ignore,
58
+ reload: ignore,
59
+ closeTab: ignore,
60
+ currentUrl: () => options.snapshot.url ?? ""
61
+ },
62
+ screenshot: () => null
63
+ });
64
+ const checkedPaths = new Set;
65
+ const checks = (context) => {
66
+ const checked = options.check ? options.check(context) : true;
67
+ if (checked)
68
+ checkedPaths.add(context.path);
69
+ return checked;
70
+ };
71
+ return {
72
+ ...inner,
73
+ checkedPaths,
74
+ resolve: async (target, options, context) => {
75
+ if (checks(context))
76
+ return inner.resolve(target, options, context);
77
+ if (context.action === "waitFor")
78
+ return uncheckedFound(target);
79
+ const resolution = await inner.resolve(target, options, context);
80
+ return resolution.status === "failed" && resolution.code === "ELEMENT_AMBIGUOUS" ? { ...resolution, code: "ELEMENT_NOT_FOUND", candidates: [], candidateCount: 0 } : resolution;
81
+ },
82
+ act: async (target, action, state, context) => target && checks(context) ? inner.act(target, action, state, context) : { ok: true },
83
+ read: async (target, read, context) => checks(context) ? inner.read(target, read, context) : { ok: true, value: null },
84
+ readAll: async (target, read, context) => checks(context) ? inner.readAll(target, read, context) : { ok: true, items: [] },
85
+ listItems: async (item, fields, maxItems, context) => checks(context) ? inner.listItems(item, fields, maxItems, context) : { ok: true, items: [] },
86
+ pressKeys: async (target, keys, context) => target && checks(context) ? inner.pressKeys(target, keys, context) : { ok: true },
87
+ typeSecret: async (target, _secret, context) => checks(context) ? inner.act(target, { kind: "focus" }, { state: "interactable" }, context) : { ok: true },
88
+ login: async (targets, _options, context) => {
89
+ if (!checks(context))
90
+ return;
91
+ for (const target of [targets.username, targets.password, targets.submit]) {
92
+ if (!target)
93
+ continue;
94
+ const resolution = await inner.resolve(target, { state: "interactable" }, context);
95
+ if (resolution.status !== "found") {
96
+ throw new UiDriverError2(resolution.code, "A sign-in field did not resolve on the snapshot", {
97
+ attempts: resolution.attempts
98
+ });
99
+ }
100
+ }
101
+ }
102
+ };
103
+ }
104
+ async function replayUiScriptOnSnapshot(script, options) {
105
+ let checkedSteps;
106
+ if (options.stepPath === undefined && options.elementKeys) {
107
+ let parsed;
108
+ try {
109
+ parsed = parseUiScript2(script, { resolved: true });
110
+ } catch {
111
+ parsed = undefined;
112
+ }
113
+ const keys = new Set(options.elementKeys);
114
+ checkedSteps = new Set(parsed ? Array.from(walkSteps2(parsed)).filter(({ step }) => stepTargets2(step).some(([, ref]) => ("element" in ref) && keys.has(ref.element))).map(({ path }) => path) : []);
115
+ }
116
+ const stepPath = options.stepPath;
117
+ const driver = createSnapshotDriver({
118
+ document: options.document,
119
+ snapshot: options.snapshot,
120
+ check: (context) => stepPath !== undefined ? context.path === stepPath : checkedSteps ? checkedSteps.has(context.path) : true
121
+ });
122
+ const events = [];
123
+ const result = await runUiScript2(script, driver, {
124
+ ...options.inputs ? { inputs: options.inputs } : {},
125
+ ...options.startAt ? { startAt: options.startAt } : {},
126
+ ...options.stopAfter ? { stopAfter: options.stopAfter } : {},
127
+ maxEvents: 1e5,
128
+ onEvent: (event) => {
129
+ events.push(event);
130
+ }
131
+ });
132
+ const steps = [];
133
+ for (const event of events) {
134
+ if (event.stepPath === undefined)
135
+ continue;
136
+ if (event.kind === "STEP_PASSED") {
137
+ const checked = driver.checkedPaths.has(event.stepPath);
138
+ steps.push({
139
+ stepPath: event.stepPath,
140
+ verdict: checked ? "passed" : "unchecked",
141
+ ...checked && event.resolvedBy ? { resolvedBy: event.resolvedBy } : {}
142
+ });
143
+ } else if (event.kind === "STEP_FAILED") {
144
+ steps.push({
145
+ stepPath: event.stepPath,
146
+ verdict: "failed",
147
+ ...event.errorCode ? { errorCode: event.errorCode } : {}
148
+ });
149
+ } else if (event.kind === "STEP_SKIPPED") {
150
+ steps.push({ stepPath: event.stepPath, verdict: "skipped" });
151
+ }
152
+ }
153
+ const failed = steps.find((step) => step.verdict === "failed");
154
+ const passed = result.status === "succeeded" && !failed;
155
+ const failedStepPath = result.error?.stepPath ?? failed?.stepPath;
156
+ const errorCode = result.error?.code ?? failed?.errorCode;
157
+ return {
158
+ passed,
159
+ ...passed || failedStepPath === undefined ? {} : { failedStepPath },
160
+ ...passed || errorCode === undefined ? {} : { errorCode },
161
+ steps
162
+ };
163
+ }
164
+ export {
165
+ DOM_DRIVER_CAPABILITIES2 as DOM_DRIVER_CAPABILITIES,
166
+ SNAPSHOT_DRIVER_CAPABILITIES,
167
+ createDomDriver2 as createDomDriver,
168
+ createSnapshotDriver,
169
+ replayUiScriptOnSnapshot,
170
+ safePageHtml2 as safePageHtml,
171
+ safePageText2 as safePageText
172
+ };
@@ -0,0 +1,340 @@
1
+ import {
2
+ UiDriverError2
3
+ } from "./index-vg8r40y7.js";
4
+ import {
5
+ MAX_LIST_ITEMS2,
6
+ CAPABILITY_IDS2
7
+ } from "./index-9s5nphx0.js";
8
+ import {
9
+ createDomRuntime2
10
+ } from "./index-ct2xctrq.js";
11
+ import {
12
+ MAX_READ_TEXT2,
13
+ performDomAction2
14
+ } from "./index-77pcz6n3.js";
15
+ import {
16
+ describeCandidate2,
17
+ resolveWebTarget2,
18
+ resolveAllWebTargets2
19
+ } from "./index-5k26keah.js";
20
+ import {
21
+ isElementVisible2,
22
+ isSensitiveElement2
23
+ } from "./index-ycs2bz1a.js";
24
+ import {
25
+ redactCredentials2
26
+ } from "./index-mgztm37r.js";
27
+
28
+ // src/drivers/dom-driver.ts
29
+ var DOM_DRIVER_UNSUPPORTED = new Set([
30
+ "action:focusWindow",
31
+ "action:typeSecret",
32
+ "action:login",
33
+ "action:screenshot",
34
+ "input:hardware"
35
+ ]);
36
+ var DOM_DRIVER_CAPABILITIES2 = CAPABILITY_IDS2.filter((id) => !DOM_DRIVER_UNSUPPORTED.has(id));
37
+ var FORM_CONTROLS = new Set(["input", "textarea", "select"]);
38
+ var SKIPPED_TAGS = new Set(["script", "style", "noscript", "template"]);
39
+ var MODIFIERS = {
40
+ Control: "ctrlKey",
41
+ Shift: "shiftKey",
42
+ Alt: "altKey",
43
+ Meta: "metaKey"
44
+ };
45
+ function foundWithoutElement(found) {
46
+ return {
47
+ status: found.status,
48
+ method: found.method,
49
+ methodIndex: found.methodIndex,
50
+ fallback: found.fallback,
51
+ candidate: found.candidate,
52
+ attempts: found.attempts
53
+ };
54
+ }
55
+ function focusedElement(document) {
56
+ let active = document.activeElement;
57
+ for (let hop = 0;active && hop < 32; hop += 1) {
58
+ const inner = active.shadowRoot?.activeElement ?? (active.localName === "iframe" ? safeFrameDocument(active)?.activeElement : null) ?? null;
59
+ if (!inner || inner === active)
60
+ break;
61
+ active = inner;
62
+ }
63
+ return active;
64
+ }
65
+ function safeFrameDocument(element) {
66
+ try {
67
+ return element.contentDocument;
68
+ } catch {
69
+ return null;
70
+ }
71
+ }
72
+ function safePageText2(root, probe) {
73
+ if (!root)
74
+ return "";
75
+ const parts = [];
76
+ let length = 0;
77
+ const visit = (element) => {
78
+ if (length >= MAX_READ_TEXT2 * 16)
79
+ return;
80
+ if (SKIPPED_TAGS.has(element.localName) || isSensitiveElement2(element) || !isElementVisible2(element, probe))
81
+ return;
82
+ for (const child of Array.from(element.childNodes)) {
83
+ if (child.nodeType === 3) {
84
+ const text = (child.textContent ?? "").replace(/\s+/g, " ").trim();
85
+ if (text) {
86
+ parts.push(text);
87
+ length += text.length + 1;
88
+ }
89
+ } else if (child.nodeType === 1)
90
+ visit(child);
91
+ }
92
+ if (element.shadowRoot)
93
+ for (const child of Array.from(element.shadowRoot.children))
94
+ visit(child);
95
+ };
96
+ visit(root);
97
+ return redactCredentials2(parts.join(" "));
98
+ }
99
+ function safePageHtml2(root) {
100
+ if (!root)
101
+ return "";
102
+ const clone = root.cloneNode(true);
103
+ const originals = Array.from(root.querySelectorAll("*"));
104
+ const copies = Array.from(clone.querySelectorAll("*"));
105
+ copies.forEach((copy, index) => {
106
+ const original = originals[index];
107
+ if (SKIPPED_TAGS.has(copy.localName)) {
108
+ copy.remove();
109
+ return;
110
+ }
111
+ for (const attribute of Array.from(copy.attributes)) {
112
+ if (attribute.name.startsWith("on") || attribute.name === "value" || attribute.name === "srcdoc") {
113
+ copy.removeAttribute(attribute.name);
114
+ }
115
+ }
116
+ if (original && isSensitiveElement2(original))
117
+ copy.textContent = "";
118
+ });
119
+ return redactCredentials2(clone.innerHTML);
120
+ }
121
+ function createDomDriver2(options) {
122
+ const { document } = options;
123
+ const probe = {
124
+ ...options.rectOf ? { rectOf: options.rectOf } : {},
125
+ ...options.isVisible ? { isVisible: options.isVisible } : {}
126
+ };
127
+ const runtime = createDomRuntime2(document, probe);
128
+ const capabilities = options.capabilities ?? (options.screenshot ? [...DOM_DRIVER_CAPABILITIES2, "action:screenshot"].sort() : DOM_DRIVER_CAPABILITIES2);
129
+ const listResolution = (target, matches) => {
130
+ const first = matches.elements[0];
131
+ const method = target.methods[matches.methodIndex];
132
+ if (!first || !method)
133
+ return;
134
+ return {
135
+ status: "found",
136
+ method: matches.method,
137
+ methodIndex: matches.methodIndex,
138
+ fallback: matches.methodIndex !== target.methods.findIndex((item) => item.enabled !== false),
139
+ candidate: describeCandidate2(first, method, matches.methodIndex, { x: 0, y: 0, width: 0, height: 0 }, probe),
140
+ attempts: matches.attempts
141
+ };
142
+ };
143
+ const fromOutcome = (outcome) => outcome.ok ? { ok: true, value: outcome.value ?? null } : { ok: false, problem: outcome.problem };
144
+ const readElement = (element, read) => {
145
+ if (isSensitiveElement2(element))
146
+ return { ok: false, problem: "SENSITIVE_ELEMENT" };
147
+ switch (read.kind) {
148
+ case "html": {
149
+ if (Array.from(element.querySelectorAll("*")).some(isSensitiveElement2)) {
150
+ return { ok: false, problem: "SENSITIVE_ELEMENT" };
151
+ }
152
+ return { ok: true, value: safePageHtml2(element).slice(0, MAX_READ_TEXT2) };
153
+ }
154
+ case "auto":
155
+ return readElement(element, { kind: FORM_CONTROLS.has(element.localName) ? "value" : "text" });
156
+ case "text":
157
+ return fromOutcome(performDomAction2(element, { kind: "getText" }));
158
+ case "value":
159
+ return fromOutcome(performDomAction2(element, { kind: "getValue" }));
160
+ case "attribute":
161
+ return fromOutcome(performDomAction2(element, { kind: "getAttribute", name: read.name }));
162
+ }
163
+ };
164
+ const resolveVisible = (root, target) => resolveWebTarget2(root, target, { ...probe, state: "visible" });
165
+ const onFocused = (action) => {
166
+ const element = focusedElement(document) ?? document.body;
167
+ if (!element)
168
+ return { ok: false, code: "NOT_EDITABLE" };
169
+ if (options.dryRun)
170
+ return { ok: true };
171
+ const outcome = performDomAction2(element, action);
172
+ if (!outcome.ok)
173
+ return { ok: false, code: outcome.problem };
174
+ return outcome.value === undefined ? { ok: true } : { ok: true, value: outcome.value };
175
+ };
176
+ const pressOn = (element, keys) => {
177
+ const [only] = keys;
178
+ if (keys.length === 1 && only !== undefined) {
179
+ const outcome = performDomAction2(element, { kind: "pressKey", key: only });
180
+ return outcome.ok ? { ok: true } : { ok: false, code: outcome.problem };
181
+ }
182
+ const view = element.ownerDocument.defaultView;
183
+ if (!view || keys.length === 0)
184
+ return { ok: false, code: "INVALID_ACTION" };
185
+ const flags = { ctrlKey: false, shiftKey: false, altKey: false, metaKey: false };
186
+ for (const key of keys.slice(0, -1)) {
187
+ const flag = MODIFIERS[key];
188
+ if (!flag)
189
+ return { ok: false, code: "INVALID_ACTION" };
190
+ flags[flag] = true;
191
+ }
192
+ const last = keys[keys.length - 1] ?? "";
193
+ const init = { key: last, bubbles: true, cancelable: true, composed: true, ...flags };
194
+ if (element instanceof view.HTMLElement)
195
+ element.focus();
196
+ element.dispatchEvent(new view.KeyboardEvent("keydown", init));
197
+ element.dispatchEvent(new view.KeyboardEvent("keyup", init));
198
+ return { ok: true };
199
+ };
200
+ const navigation = options.navigation;
201
+ const noNavigation = () => {
202
+ throw new UiDriverError2("NAVIGATION_FAILED", "This desk cannot navigate");
203
+ };
204
+ const driver = {
205
+ capabilities,
206
+ ...options.clock ? { clock: options.clock } : {},
207
+ ...options.staticPage ? { staticPage: true } : {},
208
+ ...options.replay ? { replay: true } : {},
209
+ resolve: async (target, { state }) => runtime.resolve(target, { state }),
210
+ act: async (target, action, { state }) => {
211
+ if (!target)
212
+ return onFocused(action);
213
+ if (options.dryRun) {
214
+ const resolution = runtime.resolve(target, { state: state ?? "interactable" });
215
+ return resolution.status === "found" ? { ok: true, resolution } : { ok: false, code: resolution.code, resolution };
216
+ }
217
+ return runtime.act(target, action, state ? { state } : {});
218
+ },
219
+ read: async (target, read) => {
220
+ const found = resolveVisible(document, target);
221
+ if (found.status !== "found")
222
+ return { ok: false, code: found.code, resolution: found };
223
+ const resolution = foundWithoutElement(found);
224
+ const value = readElement(found.element, read);
225
+ return value.ok ? { ok: true, value: value.value, resolution } : { ok: false, code: value.problem, resolution };
226
+ },
227
+ readAll: async (target, read) => {
228
+ const matches = resolveAllWebTargets2(document, target, { ...probe, state: "visible" });
229
+ if (matches.status !== "found")
230
+ return { ok: false, code: matches.code, resolution: matches };
231
+ if (!("elements" in matches))
232
+ return { ok: false, code: "ELEMENT_NOT_FOUND" };
233
+ const items = [];
234
+ for (const element of matches.elements.slice(0, MAX_LIST_ITEMS2)) {
235
+ const value = readElement(element, read);
236
+ if (!value.ok)
237
+ return { ok: false, code: value.problem };
238
+ items.push(value.value);
239
+ }
240
+ const resolution = listResolution(target, matches);
241
+ return { ok: true, items, ...resolution ? { resolution } : {} };
242
+ },
243
+ listItems: async (item, fields, maxItems) => {
244
+ const matches = resolveAllWebTargets2(document, item, { ...probe, state: "visible" });
245
+ if (matches.status !== "found")
246
+ return { ok: false, code: matches.code, resolution: matches };
247
+ if (!("elements" in matches))
248
+ return { ok: false, code: "ELEMENT_NOT_FOUND" };
249
+ const rows = [];
250
+ for (const element of matches.elements.slice(0, Math.min(maxItems, MAX_LIST_ITEMS2))) {
251
+ const row = {};
252
+ for (const field of fields) {
253
+ if (field.all) {
254
+ const inner = resolveAllWebTargets2(element, field.target, { ...probe, state: "visible" });
255
+ const values = [];
256
+ if (inner.status === "found" && "elements" in inner) {
257
+ for (const match of inner.elements) {
258
+ const value = readElement(match, field.read);
259
+ if (!value.ok)
260
+ return { ok: false, code: value.problem };
261
+ values.push(value.value);
262
+ }
263
+ }
264
+ row[field.name] = values;
265
+ } else {
266
+ const inner = resolveVisible(element, field.target);
267
+ if (inner.status !== "found") {
268
+ row[field.name] = null;
269
+ continue;
270
+ }
271
+ const value = readElement(inner.element, field.read);
272
+ if (!value.ok)
273
+ return { ok: false, code: value.problem };
274
+ row[field.name] = value.value;
275
+ }
276
+ }
277
+ rows.push(row);
278
+ }
279
+ const resolution = listResolution(item, matches);
280
+ return { ok: true, items: rows, ...resolution ? { resolution } : {} };
281
+ },
282
+ pressKeys: async (target, keys) => {
283
+ if (!target) {
284
+ const element = focusedElement(document) ?? document.body;
285
+ if (!element)
286
+ return { ok: false, code: "INVALID_ACTION" };
287
+ return options.dryRun ? { ok: true } : pressOn(element, keys);
288
+ }
289
+ const found = resolveWebTarget2(document, target, { ...probe, state: "interactable" });
290
+ if (found.status !== "found")
291
+ return { ok: false, code: found.code, resolution: found };
292
+ const resolution = foundWithoutElement(found);
293
+ if (options.dryRun)
294
+ return { ok: true, resolution };
295
+ const result = pressOn(found.element, keys);
296
+ return result.ok ? { ok: true, resolution } : { ...result, resolution };
297
+ },
298
+ navigate: async (url, { waitUntil, timeoutMs }) => {
299
+ if (!navigation)
300
+ return noNavigation();
301
+ await navigation.navigate(url, { waitUntil, timeoutMs });
302
+ },
303
+ goBack: async ({ timeoutMs }) => {
304
+ if (!navigation)
305
+ return noNavigation();
306
+ await navigation.goBack({ timeoutMs });
307
+ },
308
+ reload: async ({ timeoutMs }) => {
309
+ if (!navigation)
310
+ return noNavigation();
311
+ await navigation.reload({ timeoutMs });
312
+ },
313
+ closeTab: async () => {
314
+ if (!navigation)
315
+ return noNavigation();
316
+ await navigation.closeTab();
317
+ },
318
+ currentUrl: async () => navigation ? navigation.currentUrl() : document.URL,
319
+ pageText: async () => safePageText2(document.body, probe),
320
+ pageHtml: async () => safePageHtml2(document.body),
321
+ scrollPage: async ({ dx, dy, to }) => {
322
+ if (options.dryRun)
323
+ return;
324
+ const view = document.defaultView;
325
+ if (!view)
326
+ return;
327
+ if (to)
328
+ view.scrollTo?.({ top: to === "top" ? 0 : document.documentElement.scrollHeight });
329
+ else
330
+ view.scrollBy?.({ left: dx ?? 0, top: dy ?? 0 });
331
+ }
332
+ };
333
+ const screenshot = options.screenshot;
334
+ if (screenshot) {
335
+ driver.screenshot = async (shot) => await screenshot(shot) ?? null;
336
+ }
337
+ return driver;
338
+ }
339
+
340
+ export { DOM_DRIVER_CAPABILITIES2, safePageText2, safePageHtml2, createDomDriver2 };