@burdenoff/ui-engine 2026.1127.5 → 2026.1129.2

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 (59) hide show
  1. package/README.md +53 -4
  2. package/dist/analyze/messages.d.ts +7 -0
  3. package/dist/analyze/rules/heal-consequential.d.ts +2 -0
  4. package/dist/analyze/rules/popup-handler-loop.d.ts +2 -0
  5. package/dist/analyze/types.d.ts +24 -1
  6. package/dist/analyze.js +1 -1
  7. package/dist/dom-runtime.iife.js +1 -1
  8. package/dist/dom-runtime.js +2 -2
  9. package/dist/drivers.js +9 -7
  10. package/dist/heal/answer.d.ts +26 -0
  11. package/dist/heal/consequence.d.ts +74 -0
  12. package/dist/heal/index.d.ts +19 -0
  13. package/dist/heal/modes.d.ts +25 -0
  14. package/dist/heal/popup-limits.d.ts +11 -0
  15. package/dist/heal/popup.d.ts +48 -0
  16. package/dist/heal/question.d.ts +41 -0
  17. package/dist/heal/target-from-node.d.ts +9 -0
  18. package/dist/heal/types.d.ts +134 -0
  19. package/dist/heal/verify-rules.d.ts +19 -0
  20. package/dist/heal/verify.d.ts +52 -0
  21. package/dist/heal.d.ts +2 -0
  22. package/dist/heal.js +106 -0
  23. package/dist/index-20bbwwc9.js +37 -0
  24. package/dist/{index-xner4tgb.js → index-5cffktzd.js} +481 -3
  25. package/dist/index-6h7ah1dw.js +328 -0
  26. package/dist/{index-8w0f6rsz.js → index-6kva2gvd.js} +3 -3
  27. package/dist/{index-ct2xctrq.js → index-70vm0qz8.js} +2 -2
  28. package/dist/{index-21hvbvx1.js → index-8w31tpfq.js} +21 -8
  29. package/dist/{index-r2a9rftv.js → index-eff47v1g.js} +424 -17
  30. package/dist/{index-9s5nphx0.js → index-hw5npwsv.js} +1 -37
  31. package/dist/{index-ycs2bz1a.js → index-mhv6a02p.js} +11 -166
  32. package/dist/index-p5823rpv.js +0 -0
  33. package/dist/{index-5k26keah.js → index-qg9yfr7r.js} +16 -67
  34. package/dist/{index-c88tvyj1.js → index-qmv3ar39.js} +1 -1
  35. package/dist/index-t55wvhvh.js +229 -0
  36. package/dist/{index-77pcz6n3.js → index-vnv9tp11.js} +4 -2
  37. package/dist/index-w9jc25y9.js +306 -0
  38. package/dist/{index-s7qdecev.js → index-xdtanv9b.js} +358 -4
  39. package/dist/{index-vg8r40y7.js → index-yc0jgph6.js} +7 -0
  40. package/dist/index-zhbwhdya.js +407 -0
  41. package/dist/index.d.ts +1 -0
  42. package/dist/index.js +142 -24
  43. package/dist/interpret/driver.d.ts +14 -0
  44. package/dist/interpret/errors.d.ts +11 -2
  45. package/dist/interpret/events.d.ts +4 -0
  46. package/dist/interpret/run.d.ts +33 -0
  47. package/dist/interpret.js +5 -4
  48. package/dist/script/adapters/from-computer-use.d.ts +124 -0
  49. package/dist/script/index.d.ts +1 -0
  50. package/dist/script.js +28 -9
  51. package/dist/target/index.d.ts +2 -0
  52. package/dist/target/roles.d.ts +11 -0
  53. package/dist/target/snapshot-mask.d.ts +49 -0
  54. package/dist/target/snapshot-tree.d.ts +65 -0
  55. package/dist/target/snapshot-url.d.ts +6 -0
  56. package/dist/target/snapshot.d.ts +1 -6
  57. package/dist/target.js +55 -13
  58. package/dist/testing.js +2 -2
  59. package/package.json +7 -3
@@ -0,0 +1,407 @@
1
+ import {
2
+ SENSITIVE_MARKERS2,
3
+ INPUT_ROLES,
4
+ TAG_ROLES,
5
+ NAME_FROM_CONTENT,
6
+ clip2,
7
+ snapshotUrl2
8
+ } from "./index-t55wvhvh.js";
9
+
10
+ // src/target/snapshot-tree.ts
11
+ var SNAPSHOT_ROOT_PATH2 = "/";
12
+ var MAX_SNAPSHOT_PATH_LENGTH2 = 1024;
13
+ var MAX_SNAPSHOT_WALK2 = 1e5;
14
+ var MAX_SNAPSHOT_NAME2 = 200;
15
+ function collapse(value) {
16
+ return value.normalize("NFKC").replace(/\s+/g, " ").trim();
17
+ }
18
+ var SEGMENT = /^(?:[cs](?:0|[1-9]\d{0,4})|f)$/;
19
+ function isSnapshotPath2(path) {
20
+ if (typeof path !== "string" || path.length === 0 || path.length > MAX_SNAPSHOT_PATH_LENGTH2)
21
+ return false;
22
+ if (path === SNAPSHOT_ROOT_PATH2)
23
+ return true;
24
+ if (!path.startsWith("/"))
25
+ return false;
26
+ return path.slice(1).split("/").every((segment) => SEGMENT.test(segment));
27
+ }
28
+ function childPath(parent, segment) {
29
+ return parent === SNAPSHOT_ROOT_PATH2 ? `/${segment}` : `${parent}/${segment}`;
30
+ }
31
+ function scopeOf(edge, parent, path) {
32
+ if (!parent)
33
+ return SNAPSHOT_ROOT_PATH2;
34
+ if (edge === "f")
35
+ return path;
36
+ if (edge === "s")
37
+ return `${parent.path}#shadow`;
38
+ return parent.scope;
39
+ }
40
+ function walkSnapshot2(snapshot) {
41
+ const entries = [];
42
+ const visit = (node, path, edge, parent) => {
43
+ if (entries.length >= MAX_SNAPSHOT_WALK2)
44
+ return;
45
+ const entry = {
46
+ node,
47
+ path,
48
+ edge,
49
+ parent,
50
+ scope: scopeOf(edge, parent, path),
51
+ order: entries.length
52
+ };
53
+ entries.push(entry);
54
+ for (const [index, child] of (node.c ?? []).entries()) {
55
+ if (typeof child !== "string")
56
+ visit(child, childPath(path, `c${index}`), "c", entry);
57
+ }
58
+ for (const [index, child] of (node.s ?? []).entries()) {
59
+ if (typeof child !== "string")
60
+ visit(child, childPath(path, `s${index}`), "s", entry);
61
+ }
62
+ if (node.f)
63
+ visit(node.f, childPath(path, "f"), "f", entry);
64
+ };
65
+ visit(snapshot.root, SNAPSHOT_ROOT_PATH2, "root", undefined);
66
+ return entries;
67
+ }
68
+ function snapshotNodeAt2(snapshot, path) {
69
+ if (!isSnapshotPath2(path))
70
+ return;
71
+ let node = snapshot.root;
72
+ if (path === SNAPSHOT_ROOT_PATH2)
73
+ return node;
74
+ for (const segment of path.slice(1).split("/")) {
75
+ if (segment === "f") {
76
+ if (!node.f)
77
+ return;
78
+ node = node.f;
79
+ continue;
80
+ }
81
+ const list = segment.startsWith("c") ? node.c : node.s;
82
+ const child = list?.[Number(segment.slice(1))];
83
+ if (child === undefined || typeof child === "string")
84
+ return;
85
+ node = child;
86
+ }
87
+ return node;
88
+ }
89
+ function attributeOf2(node, name) {
90
+ const attributes = node.a;
91
+ return attributes && Object.hasOwn(attributes, name) ? attributes[name] : undefined;
92
+ }
93
+ function hasSnapshotMarker(node) {
94
+ return SENSITIVE_MARKERS2.some((marker) => attributeOf2(node, marker) !== undefined);
95
+ }
96
+ var SECRET_FIELD = /password|passcode|passwd|\bpin\b|otp|one[\s-]?time|verification|security code|auth(?:entication)? code|\bcvv\b|\bcvc\b|card number|secret|token|recovery/i;
97
+ var SECRET_AUTOCOMPLETE = /password|one-time-code|^cc-/i;
98
+ var FIELD_TAGS = new Set(["input", "textarea", "select"]);
99
+ function isSnapshotEditingHost2(node) {
100
+ return isEditingHost(node);
101
+ }
102
+ function isEditingHost(node) {
103
+ const value = attributeOf2(node, "contenteditable");
104
+ return value !== undefined && value.trim().toLowerCase() !== "false";
105
+ }
106
+ function isSecretField(node) {
107
+ if (!FIELD_TAGS.has(node.t) && !isEditingHost(node))
108
+ return false;
109
+ if (attributeOf2(node, "type")?.toLowerCase() === "password")
110
+ return true;
111
+ const tokens = (attributeOf2(node, "autocomplete") ?? "").trim().split(/\s+/).filter(Boolean);
112
+ if (tokens.some((token) => SECRET_AUTOCOMPLETE.test(token)))
113
+ return true;
114
+ return ["name", "id", "aria-label", "placeholder", "title"].map((name) => attributeOf2(node, name) ?? "").some((hint) => hint.length > 0 && SECRET_FIELD.test(hint.replace(/[-_]/g, " ")));
115
+ }
116
+ function isSensitiveSnapshotEntry2(entry) {
117
+ for (let current = entry;current; current = current.parent) {
118
+ if (hasSnapshotMarker(current.node) || isSecretField(current.node))
119
+ return true;
120
+ }
121
+ return false;
122
+ }
123
+ function snapshotText2(node, max = MAX_SNAPSHOT_NAME2) {
124
+ const parts = [];
125
+ let length = 0;
126
+ const visit = (current) => {
127
+ for (const child of [...current.c ?? [], ...current.s ?? []]) {
128
+ if (length > max)
129
+ return;
130
+ if (typeof child === "string") {
131
+ parts.push(child);
132
+ length += child.length;
133
+ } else if (!child.h)
134
+ visit(child);
135
+ }
136
+ };
137
+ if (!node.h)
138
+ visit(node);
139
+ return clip2(collapse(parts.join(" ")), max);
140
+ }
141
+ function hasSectioningAncestor(entry) {
142
+ for (let current = entry.parent;current; current = current.parent) {
143
+ if (current.scope !== entry.scope)
144
+ return false;
145
+ if (["article", "aside", "main", "nav", "section"].includes(current.node.t))
146
+ return true;
147
+ }
148
+ return false;
149
+ }
150
+ function snapshotRole2(entry) {
151
+ const node = entry.node;
152
+ const explicit = attributeOf2(node, "role")?.trim().split(/\s+/)[0];
153
+ if (explicit)
154
+ return explicit.toLowerCase();
155
+ const tag = node.t;
156
+ switch (tag) {
157
+ case "a":
158
+ case "area":
159
+ return attributeOf2(node, "href") === undefined ? "" : "link";
160
+ case "input": {
161
+ const type = (attributeOf2(node, "type") ?? "text").toLowerCase();
162
+ if (type === "hidden")
163
+ return "";
164
+ if (attributeOf2(node, "list") !== undefined && ["text", "search", "email", "tel", "url"].includes(type)) {
165
+ return "combobox";
166
+ }
167
+ return INPUT_ROLES[type] ?? "textbox";
168
+ }
169
+ case "select": {
170
+ const size = Number(attributeOf2(node, "size") ?? "0");
171
+ return attributeOf2(node, "multiple") !== undefined || size > 1 ? "listbox" : "combobox";
172
+ }
173
+ case "img":
174
+ return attributeOf2(node, "alt") === "" ? "presentation" : "img";
175
+ case "th":
176
+ return attributeOf2(node, "scope") === "row" ? "rowheader" : "columnheader";
177
+ case "header":
178
+ return hasSectioningAncestor(entry) ? "" : "banner";
179
+ case "footer":
180
+ return hasSectioningAncestor(entry) ? "" : "contentinfo";
181
+ case "section":
182
+ case "form":
183
+ return attributeOf2(node, "aria-label") !== undefined || attributeOf2(node, "aria-labelledby") !== undefined ? tag === "form" ? "form" : "region" : "";
184
+ default:
185
+ return TAG_ROLES[tag] ?? "";
186
+ }
187
+ }
188
+ function indexSnapshot2(snapshot) {
189
+ const entries = walkSnapshot2(snapshot);
190
+ const byPath = new Map;
191
+ const byScope = new Map;
192
+ for (const entry of entries) {
193
+ byPath.set(entry.path, entry);
194
+ const list = byScope.get(entry.scope);
195
+ if (list)
196
+ list.push(entry);
197
+ else
198
+ byScope.set(entry.scope, [entry]);
199
+ }
200
+ return { entries, byPath, byScope };
201
+ }
202
+ function byIdInScope(index, scope, id) {
203
+ return index.byScope.get(scope)?.find((entry) => attributeOf2(entry.node, "id") === id);
204
+ }
205
+ var LABELABLE = new Set(["button", "input", "meter", "output", "progress", "select", "textarea"]);
206
+ var BUTTON_INPUTS = new Set(["button", "submit", "reset"]);
207
+ function snapshotName2(entry, index, max = MAX_SNAPSHOT_NAME2) {
208
+ if (isSensitiveSnapshotEntry2(entry))
209
+ return "";
210
+ const node = entry.node;
211
+ const done = (value) => {
212
+ const text = clip2(collapse(value ?? ""), max);
213
+ return text === "" ? undefined : text;
214
+ };
215
+ const labelledBy = attributeOf2(node, "aria-labelledby");
216
+ if (labelledBy) {
217
+ const text = labelledBy.split(/\s+/).filter(Boolean).map((id) => {
218
+ const target = byIdInScope(index, entry.scope, id);
219
+ return target ? attributeOf2(target.node, "aria-label") ?? snapshotText2(target.node, max) : "";
220
+ }).join(" ");
221
+ const name = done(text);
222
+ if (name)
223
+ return name;
224
+ }
225
+ const label = done(attributeOf2(node, "aria-label"));
226
+ if (label)
227
+ return label;
228
+ const tag = node.t;
229
+ if (LABELABLE.has(tag)) {
230
+ const id = attributeOf2(node, "id");
231
+ const labels = (index.byScope.get(entry.scope) ?? []).filter((candidate) => candidate.node.t === "label" && id !== undefined && attributeOf2(candidate.node, "for") === id);
232
+ for (let current = entry.parent;current && current.scope === entry.scope; current = current.parent) {
233
+ if (current.node.t === "label" && attributeOf2(current.node, "for") === undefined)
234
+ labels.push(current);
235
+ }
236
+ const name = done(labels.map((item) => snapshotText2(item.node, max)).join(" "));
237
+ if (name)
238
+ return name;
239
+ }
240
+ if (tag === "img" || tag === "input" && attributeOf2(node, "type")?.toLowerCase() === "image") {
241
+ const alt = done(attributeOf2(node, "alt"));
242
+ if (alt)
243
+ return alt;
244
+ }
245
+ if (tag === "input" && BUTTON_INPUTS.has((attributeOf2(node, "type") ?? "").toLowerCase())) {
246
+ const value = done(attributeOf2(node, "value"));
247
+ if (value)
248
+ return value;
249
+ }
250
+ if (NAME_FROM_CONTENT.has(snapshotRole2(entry))) {
251
+ const text = done(snapshotText2(node, max));
252
+ if (text)
253
+ return text;
254
+ }
255
+ return done(attributeOf2(node, "title")) ?? done(attributeOf2(node, "placeholder")) ?? "";
256
+ }
257
+ function snapshotHosts2(entry) {
258
+ const hosts = [];
259
+ for (let current = entry;current?.parent; current = current.parent) {
260
+ if (current.edge === "f" || current.edge === "s") {
261
+ const host = current.parent;
262
+ if (hosts[0] !== host)
263
+ hosts.unshift(host);
264
+ }
265
+ }
266
+ return hosts;
267
+ }
268
+ function snapshotFrameDepth2(entry) {
269
+ let depth = 0;
270
+ for (let current = entry;current; current = current.parent) {
271
+ if (current.edge === "f")
272
+ depth += 1;
273
+ }
274
+ return depth;
275
+ }
276
+
277
+ // src/target/snapshot-mask.ts
278
+ var MASKED_MARKER2 = "data-fg-sensitive";
279
+ var MAX_MASKED_PATHS2 = 1000;
280
+ var KEPT_WHEN_MASKED = new Set([
281
+ "role",
282
+ "type",
283
+ "id",
284
+ "name",
285
+ "autocomplete",
286
+ "tabindex",
287
+ "disabled",
288
+ "readonly",
289
+ "hidden",
290
+ "inert",
291
+ "contenteditable",
292
+ "data-testid",
293
+ "data-test",
294
+ "data-test-id",
295
+ "data-qa",
296
+ "data-cy",
297
+ "data-automation-id",
298
+ "data-fg-sensitive",
299
+ "data-sensitive",
300
+ "data-private",
301
+ "aria-hidden",
302
+ "aria-disabled",
303
+ "aria-expanded",
304
+ "aria-haspopup",
305
+ "aria-required",
306
+ "aria-invalid",
307
+ "aria-readonly",
308
+ "aria-modal"
309
+ ]);
310
+ function maskAttributes(attributes) {
311
+ const kept = {};
312
+ for (const [name, value] of Object.entries(attributes ?? {})) {
313
+ if (KEPT_WHEN_MASKED.has(name))
314
+ kept[name] = value;
315
+ }
316
+ kept[MASKED_MARKER2] = "";
317
+ return kept;
318
+ }
319
+ function maskChildren(list) {
320
+ if (!list || list.length === 0)
321
+ return;
322
+ return list.map((child) => typeof child === "string" ? "" : maskNode(child));
323
+ }
324
+ function maskNode(node) {
325
+ const masked = { t: node.t, a: maskAttributes(node.a) };
326
+ const children = maskChildren(node.c);
327
+ if (children)
328
+ masked.c = children;
329
+ const shadow = maskChildren(node.s);
330
+ if (shadow)
331
+ masked.s = shadow;
332
+ if (node.f)
333
+ masked.f = maskNode(node.f);
334
+ if (node.r)
335
+ masked.r = [...node.r];
336
+ if (node.h)
337
+ masked.h = 1;
338
+ return masked;
339
+ }
340
+ function countNodes(node) {
341
+ let count = 1;
342
+ for (const child of [...node.c ?? [], ...node.s ?? []]) {
343
+ count += typeof child === "string" ? 1 : countNodes(child);
344
+ }
345
+ if (node.f)
346
+ count += countNodes(node.f);
347
+ return count;
348
+ }
349
+ function maskSnapshot2(snapshot, options = {}) {
350
+ const sensitive = options.sensitive !== false;
351
+ const named = new Set((options.maskedPaths ?? []).slice(0, MAX_MASKED_PATHS2).filter((path) => isSnapshotPath2(path)));
352
+ const toMask = new Set;
353
+ for (const entry of walkSnapshot2(snapshot)) {
354
+ if (named.has(entry.path) || sensitive && isSensitiveSnapshotEntry2(entry))
355
+ toMask.add(entry.path);
356
+ }
357
+ const maskedPaths = [];
358
+ const screenshotMask = [];
359
+ const copy = (node, entryPath, offset) => {
360
+ if (toMask.has(entryPath)) {
361
+ maskedPaths.push(entryPath);
362
+ if (node.r) {
363
+ screenshotMask.push({
364
+ x: node.r[0] + offset[0],
365
+ y: node.r[1] + offset[1],
366
+ width: node.r[2],
367
+ height: node.r[3]
368
+ });
369
+ }
370
+ return maskNode(node);
371
+ }
372
+ const result = { t: node.t };
373
+ if (node.a)
374
+ result.a = { ...node.a };
375
+ const mapChildren = (list, prefix) => list.map((child, index) => typeof child === "string" ? child : copy(child, joinPath(entryPath, `${prefix}${index}`), offset));
376
+ if (node.c)
377
+ result.c = mapChildren(node.c, "c");
378
+ if (node.s)
379
+ result.s = mapChildren(node.s, "s");
380
+ if (node.f) {
381
+ const inner = node.r ? [offset[0] + node.r[0], offset[1] + node.r[1]] : [offset[0], offset[1]];
382
+ result.f = copy(node.f, joinPath(entryPath, "f"), inner);
383
+ }
384
+ if (node.r)
385
+ result.r = [...node.r];
386
+ if (node.h)
387
+ result.h = 1;
388
+ return result;
389
+ };
390
+ const root = copy(snapshot.root, "/", [0, 0]);
391
+ return {
392
+ snapshot: {
393
+ ...snapshot,
394
+ url: snapshotUrl2(snapshot.url ?? "") ?? "",
395
+ viewport: { ...snapshot.viewport },
396
+ root,
397
+ nodeCount: countNodes(root)
398
+ },
399
+ maskedPaths,
400
+ screenshotMask
401
+ };
402
+ }
403
+ function joinPath(parent, segment) {
404
+ return parent === "/" ? `/${segment}` : `${parent}/${segment}`;
405
+ }
406
+
407
+ export { SNAPSHOT_ROOT_PATH2, MAX_SNAPSHOT_PATH_LENGTH2, MAX_SNAPSHOT_WALK2, MAX_SNAPSHOT_NAME2, isSnapshotPath2, walkSnapshot2, snapshotNodeAt2, attributeOf2, isSnapshotEditingHost2, isSensitiveSnapshotEntry2, snapshotText2, snapshotRole2, indexSnapshot2, snapshotName2, snapshotHosts2, snapshotFrameDepth2, MASKED_MARKER2, MAX_MASKED_PATHS2, maskSnapshot2 };
package/dist/index.d.ts CHANGED
@@ -11,3 +11,4 @@ export { type FallbackReason, type ReplayCallKind, type ReplayCallOutcome, type
11
11
  export * from './script.js';
12
12
  export * from './interpret.js';
13
13
  export * from './analyze.js';
14
+ export * from './heal.js';