@rind-ui/testing 0.0.0-stage → 0.2.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.
@@ -0,0 +1,526 @@
1
+ import { o as poll, r as describeBy, t as composeInPage } from "./compose-DPLnCCnJ.mjs";
2
+ //#region src/adapters/chromium-tree.ts
3
+ const toNode = (n) => ({
4
+ role: n.role?.value ?? "",
5
+ name: n.name?.value ?? "",
6
+ description: n.description?.value ?? "",
7
+ ignored: n.ignored === true,
8
+ ignoredReasons: (n.ignoredReasons ?? []).map((r) => r.name)
9
+ });
10
+ const sessions = /* @__PURE__ */ new WeakMap();
11
+ function session(page) {
12
+ let s = sessions.get(page);
13
+ if (!s) {
14
+ s = (async () => {
15
+ if (page.context().browser()?.browserType().name() !== "chromium") return null;
16
+ const cdp = await page.context().newCDPSession(page);
17
+ await cdp.send("Accessibility.enable");
18
+ await cdp.send("DOM.enable");
19
+ return cdp;
20
+ })().catch(() => null);
21
+ sessions.set(page, s);
22
+ }
23
+ return s;
24
+ }
25
+ /**
26
+ * Chromium's full accessibility tree, retried until it satisfies `until` (the tree updates
27
+ * after the DOM, so a fresh change may not be in it yet); `{ unavailable: true }` in other
28
+ * engines. Throws when `until` still fails after `timeout` ms.
29
+ */
30
+ async function chromiumTree(page, { until = (nodes) => nodes.length > 0, timeout = 5e3 } = {}) {
31
+ const cdp = await session(page);
32
+ if (!cdp) return { unavailable: true };
33
+ const start = Date.now();
34
+ for (;;) {
35
+ const { nodes } = await cdp.send("Accessibility.getFullAXTree").catch(() => ({ nodes: [] }));
36
+ const tree = nodes.map(toNode);
37
+ if (until(tree)) return tree;
38
+ if (Date.now() - start >= timeout) throw new Error(`chromiumTree: the accessibility tree did not match within ${timeout} ms`);
39
+ await new Promise((resolve) => setTimeout(resolve, 20));
40
+ }
41
+ }
42
+ /** The accessibility node of the element a page expression evaluates to. */
43
+ async function axNodeOf(page, expression) {
44
+ const cdp = await session(page);
45
+ if (!cdp) return { unavailable: true };
46
+ await cdp.send("DOM.getDocument", { depth: 0 });
47
+ const { result } = await cdp.send("Runtime.evaluate", { expression });
48
+ if (!result.objectId) return null;
49
+ const { nodeId } = await cdp.send("DOM.requestNode", { objectId: result.objectId });
50
+ const { nodes } = await cdp.send("Accessibility.getPartialAXTree", {
51
+ nodeId,
52
+ fetchRelatives: false
53
+ });
54
+ const first = nodes[0];
55
+ return first ? toNode(first) : null;
56
+ }
57
+ //#endregion
58
+ //#region src/adapters/playwright.ts
59
+ const PW_KEYS = {
60
+ Enter: "Enter",
61
+ Escape: "Escape",
62
+ Space: " ",
63
+ Tab: "Tab",
64
+ Home: "Home",
65
+ End: "End",
66
+ PageUp: "PageUp",
67
+ PageDown: "PageDown",
68
+ ArrowUp: "ArrowUp",
69
+ ArrowDown: "ArrowDown",
70
+ ArrowLeft: "ArrowLeft",
71
+ ArrowRight: "ArrowRight",
72
+ Backspace: "Backspace",
73
+ Delete: "Delete",
74
+ F10: "F10",
75
+ ContextMenu: "ContextMenu",
76
+ A: "a"
77
+ };
78
+ const keyName = (key, o = {}, apple) => [
79
+ o.shift && "Shift",
80
+ o.alt && "Alt",
81
+ o.mod && (apple === void 0 ? "ControlOrMeta" : apple ? "Meta" : "Control"),
82
+ PW_KEYS[key]
83
+ ].filter(Boolean).join("+");
84
+ /** In the page: keydown and keyup with isComposing and keyCode 229 on `el`. */
85
+ const composingKeys = (el, init) => {
86
+ for (const type of ["keydown", "keyup"]) {
87
+ const e = new KeyboardEvent(type, {
88
+ bubbles: true,
89
+ cancelable: true,
90
+ isComposing: true,
91
+ ...init
92
+ });
93
+ Object.defineProperty(e, "keyCode", { value: 229 });
94
+ el.dispatchEvent(e);
95
+ }
96
+ };
97
+ let inpageSource;
98
+ /** The in-page bundle, read once from next to this module (dist) or from the built package. */
99
+ function loadInPage() {
100
+ inpageSource ??= (async () => {
101
+ const fs = await import("node:fs/promises");
102
+ for (const candidate of ["./inpage.iife.js", "../../dist/inpage.iife.js"]) try {
103
+ return await fs.readFile(new URL(candidate, import.meta.url), "utf8");
104
+ } catch {}
105
+ throw new Error("rind-ui: dist/inpage.iife.js is missing; build @rind-ui/testing");
106
+ })();
107
+ return inpageSource;
108
+ }
109
+ async function ensureInPage(root) {
110
+ if (!await root.evaluate(() => "__rindTesting" in globalThis)) await root.evaluate(await loadInPage());
111
+ }
112
+ /** A Playwright Page, by duck typing (no runtime import). */
113
+ const isPage = (t) => typeof t === "object" && t !== null && "mainFrame" in t && "on" in t;
114
+ async function baseOf(target) {
115
+ if (isPage(target)) return {
116
+ page: target,
117
+ root: target,
118
+ anchorRoot: target
119
+ };
120
+ if ("page" in target) {
121
+ const locator = target;
122
+ const frame = await (await locator.elementHandle())?.ownerFrame() ?? locator.page().mainFrame();
123
+ return {
124
+ page: frame.page(),
125
+ root: frame,
126
+ anchorRoot: locator
127
+ };
128
+ }
129
+ const frame = await (await target.owner().elementHandle())?.contentFrame();
130
+ if (!frame) throw new Error("rind-ui: the FrameLocator's frame is not attached");
131
+ return {
132
+ page: frame.page(),
133
+ root: frame,
134
+ anchorRoot: frame
135
+ };
136
+ }
137
+ const logged = /* @__PURE__ */ new WeakSet();
138
+ /** Records every announcement in the page, from its first script on (and on the current page). */
139
+ async function installPageAnnouncementLog(page) {
140
+ if (logged.has(page)) return;
141
+ logged.add(page);
142
+ const install = () => {
143
+ const key = Symbol.for("rind-ui.announcements");
144
+ if (!Reflect.get(globalThis, key)) Reflect.set(globalThis, key, []);
145
+ };
146
+ await page.addInitScript(install);
147
+ await page.evaluate(install).catch(() => {});
148
+ }
149
+ const errorLogs = /* @__PURE__ */ new WeakMap();
150
+ /** Records the page's uncaught errors and console.error calls; installed once per page. */
151
+ function watchPageErrors(page) {
152
+ let log = errorLogs.get(page);
153
+ if (!log) {
154
+ const entries = [];
155
+ page.on("pageerror", (e) => entries.push(String(e)));
156
+ page.on("console", (m) => {
157
+ if (m.type() === "error") entries.push(m.text());
158
+ });
159
+ errorLogs.set(page, entries);
160
+ log = entries;
161
+ }
162
+ return log;
163
+ }
164
+ /** The Playwright adapter. */
165
+ function playwrightEnv(target, options = {}) {
166
+ let base;
167
+ const getBase = () => {
168
+ base ??= baseOf(target).then(async (b) => {
169
+ watchPageErrors(b.page);
170
+ await installPageAnnouncementLog(b.page);
171
+ return b;
172
+ });
173
+ return base;
174
+ };
175
+ if (isPage(target)) {
176
+ watchPageErrors(target);
177
+ installPageAnnouncementLog(target);
178
+ }
179
+ return {
180
+ "~rindEnvFactory": true,
181
+ create: (envOptions) => createPlaywrightEnv(getBase, envOptions, options)
182
+ };
183
+ }
184
+ function createPlaywrightEnv(getBase, { scope, anchor, modality, platform }, options) {
185
+ const apple = platform?.apple;
186
+ const composingInit = (key, o = {}) => ({
187
+ key: key === "Space" ? " " : key,
188
+ shiftKey: o.shift === true,
189
+ altKey: o.alt === true,
190
+ ctrlKey: o.mod === true && apple !== true,
191
+ metaKey: o.mod === true && apple === true
192
+ });
193
+ const timeout = options.timeout ?? 5e3;
194
+ const wait = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
195
+ const until = (read, accept) => poll(read, accept, {
196
+ timeout,
197
+ wait
198
+ });
199
+ const byLocator = (root, by) => "role" in by ? root.getByRole(by.role, { ...by.name === void 0 ? {} : {
200
+ name: by.name,
201
+ exact: true
202
+ } }) : "part" in by ? root.locator(`[data-scope="${scope}"][data-part="${by.part}"]`) : root.getByText(by.text, { exact: true });
203
+ const describeAll = (l) => l.evaluateAll((els) => els.map((el) => el.outerHTML.slice(0, 160)).join("\n"));
204
+ /** What tells a navigation: the URL, the open pages, and the in-page log (fakeRouter). */
205
+ const navigationState = async () => {
206
+ const { page, root } = await getBase();
207
+ const log = await root.evaluate(() => (Reflect.get(globalThis, Symbol.for("rind-ui.navigations")) ?? []).map((n) => n.newTab)).catch(() => []);
208
+ return {
209
+ url: page.url(),
210
+ pages: page.context().pages().length,
211
+ log
212
+ };
213
+ };
214
+ let navigationsFrom;
215
+ const anchorLocator = async () => byLocator((await getBase()).anchorRoot, anchor);
216
+ const instance = async () => {
217
+ const a = await anchorLocator();
218
+ const n = await a.count();
219
+ if (n === 0) throw new Error(`${scope}: no element matches the anchor (${describeBy(anchor)})`);
220
+ if (n > 1) throw new Error(`${scope}: ${n} elements match the anchor (${describeBy(anchor)}):\n${await describeAll(a)}`);
221
+ const id = await a.evaluate((el) => el.closest("[data-instance]")?.getAttribute("data-instance"));
222
+ if (!id) throw new Error(`${scope}: the anchor has no data-instance`);
223
+ return id;
224
+ };
225
+ /** A lazy handle. Reads never wait; actions wait for the element to exist. */
226
+ const handle = (label, locate) => {
227
+ const single = async (l) => {
228
+ const n = await l.count();
229
+ if (n === 0) throw new Error(`${label}: not found`);
230
+ if (n > 1) throw new Error(`${label}: ${n} elements match:\n${await describeAll(l)}`);
231
+ return l;
232
+ };
233
+ const now = async () => single(await locate());
234
+ const waitFor = async () => {
235
+ const l = await locate();
236
+ await until(() => l.count(), (n) => n > 0).catch(() => 0);
237
+ return single(l);
238
+ };
239
+ const activate = async (touch, o = {}) => {
240
+ const l = await waitFor();
241
+ const mods = [o.shift ? "Shift" : null, o.mod ? apple === void 0 ? "ControlOrMeta" : apple ? "Meta" : "Control" : null].filter((m) => m !== null);
242
+ if (modality === "virtual") return l.dispatchEvent("click", {
243
+ detail: 0,
244
+ shiftKey: o.shift === true,
245
+ ctrlKey: o.mod === true && !apple,
246
+ metaKey: o.mod === true && apple
247
+ });
248
+ const force = await l.getAttribute("aria-disabled") === "true";
249
+ if (o.button === "middle") return l.click({
250
+ button: "middle",
251
+ modifiers: mods,
252
+ force
253
+ });
254
+ return touch ? l.tap({
255
+ modifiers: mods,
256
+ force
257
+ }) : l.click({
258
+ modifiers: mods,
259
+ force
260
+ });
261
+ };
262
+ const part = {
263
+ click: (options) => activate(false, options),
264
+ tap: () => activate(true),
265
+ hover: async (hoverOptions) => {
266
+ const l = await waitFor();
267
+ if (hoverOptions?.pointerType !== "touch") return l.hover();
268
+ await l.dispatchEvent("pointerover", {
269
+ pointerType: "touch",
270
+ bubbles: true
271
+ });
272
+ await l.dispatchEvent("pointerenter", { pointerType: "touch" });
273
+ },
274
+ focus: async () => (await waitFor()).focus(),
275
+ async press(key, keyOptions) {
276
+ const l = await waitFor();
277
+ if (!await l.evaluate((el) => el === document.activeElement)) await l.focus();
278
+ if (keyOptions?.composing) {
279
+ await l.evaluate(composingKeys, composingInit(key, keyOptions));
280
+ return;
281
+ }
282
+ await l.press(keyName(key, keyOptions, apple));
283
+ },
284
+ async type(text) {
285
+ const l = await waitFor();
286
+ await l.evaluate((el) => {
287
+ if (el instanceof HTMLInputElement || el instanceof HTMLTextAreaElement) {
288
+ if (el.ownerDocument.activeElement !== el) el.focus();
289
+ const end = el.value.length;
290
+ try {
291
+ el.setSelectionRange(end, end);
292
+ } catch {}
293
+ } else if (el instanceof HTMLElement && el.isContentEditable) {
294
+ el.focus();
295
+ const range = el.ownerDocument.createRange();
296
+ range.selectNodeContents(el);
297
+ range.collapse(false);
298
+ el.ownerDocument.getSelection()?.removeAllRanges();
299
+ el.ownerDocument.getSelection()?.addRange(range);
300
+ }
301
+ });
302
+ await l.pressSequentially(text);
303
+ },
304
+ async compose(updates, commit) {
305
+ const l = await waitFor();
306
+ if (!await l.evaluate((el) => el === document.activeElement)) await l.focus();
307
+ const { page } = await getBase();
308
+ if (page.context().browser()?.browserType().name() === "chromium") {
309
+ const cdp = await page.context().newCDPSession(page);
310
+ const imeKey = (type) => cdp.send("Input.dispatchKeyEvent", {
311
+ type,
312
+ key: "Process",
313
+ code: "",
314
+ windowsVirtualKeyCode: 229,
315
+ nativeVirtualKeyCode: 229
316
+ });
317
+ for (const text of updates) {
318
+ await imeKey("rawKeyDown");
319
+ await cdp.send("Input.imeSetComposition", {
320
+ text,
321
+ selectionStart: text.length,
322
+ selectionEnd: text.length
323
+ });
324
+ await imeKey("keyUp");
325
+ }
326
+ if (commit !== void 0) await cdp.send("Input.insertText", { text: commit });
327
+ await cdp.detach();
328
+ return;
329
+ }
330
+ await l.evaluate(composeInPage, commit === void 0 ? { updates } : {
331
+ updates,
332
+ commit
333
+ });
334
+ },
335
+ async pressAtPosition() {
336
+ const box = await (await waitFor()).boundingBox();
337
+ if (!box) throw new Error("pressAtPosition: the part has no box");
338
+ const { page } = await getBase();
339
+ await page.mouse.click(box.x + box.width / 2, box.y + box.height / 2);
340
+ },
341
+ waitForDetach: async () => {
342
+ await until(async () => (await locate()).count(), (n) => n === 0);
343
+ },
344
+ isInert: async () => (await now()).evaluate((el) => el.closest("[inert]") !== null),
345
+ attr: async (name) => (await now()).getAttribute(name),
346
+ tagName: async () => (await now()).evaluate((el) => el.tagName.toLowerCase()),
347
+ scoped: (scope, partName) => handle(`${scope}.${partName} in ${label}`, async () => (await now()).locator(`[data-scope="${scope}"][data-part="${partName}"]`)),
348
+ withAttr: (name, value) => handle(`[${name}] in ${label}`, async () => (await now()).locator(value === void 0 ? `[${name}]` : `[${name}="${value.replace(/["\\]/g, "\\$&")}"]`)),
349
+ accessibleName: async () => {
350
+ const { root } = await getBase();
351
+ await ensureInPage(root);
352
+ return (await now()).evaluate((el) => globalThis.__rindTesting?.accessibleName(el) ?? "");
353
+ },
354
+ accessibleDescription: async () => {
355
+ const { root } = await getBase();
356
+ await ensureInPage(root);
357
+ return (await now()).evaluate((el) => globalThis.__rindTesting?.accessibleDescription(el) ?? "");
358
+ },
359
+ labelled: () => handle(`the control of ${label}`, async () => {
360
+ const text = (await (await now()).textContent() ?? "").replace(/\s+/g, " ").trim();
361
+ return (await getBase()).root.getByLabel(text, { exact: true });
362
+ }),
363
+ doubleClick: async () => (await waitFor()).dblclick(),
364
+ text: async () => (await (await now()).textContent() ?? "").replace(/\s+/g, " ").trim(),
365
+ value: async () => (await now()).inputValue(),
366
+ checked: async () => (await now()).evaluate((el) => el.checked === true),
367
+ indeterminate: async () => (await now()).evaluate((el) => el.indeterminate === true),
368
+ exists: async () => {
369
+ await ensureInPage((await getBase()).root);
370
+ return (await locate()).evaluateAll((els) => els.some((el) => globalThis.__rindTesting?.isVisible(el) === true));
371
+ },
372
+ isFocused: async () => (await now()).evaluate((el) => {
373
+ const active = document.activeElement;
374
+ return active === el || el.id !== "" && active?.getAttribute("aria-activedescendant") === el.id;
375
+ }),
376
+ count: async () => (await locate()).count(),
377
+ nth: (index) => handle(`${label}[${index}]`, async () => (await locate()).nth(index)),
378
+ all: async () => {
379
+ const n = await (await locate()).count();
380
+ return Array.from({ length: n }, (_, i) => part.nth(i));
381
+ }
382
+ };
383
+ return part;
384
+ };
385
+ const partLocator = async (name, by) => {
386
+ const { root } = await getBase();
387
+ const id = await instance();
388
+ const parts = root.locator(`[data-scope="${scope}"][data-part="${name}"][data-instance="${id}"]`);
389
+ return by ? parts.and(byLocator(root, by)) : parts;
390
+ };
391
+ return {
392
+ modality,
393
+ part: (name, by) => handle(`${scope}.${name}${by ? ` (${describeBy(by)})` : ""}`, () => partLocator(name, by)),
394
+ find: (by) => handle(describeBy(by), async () => byLocator((await getBase()).root, by)),
395
+ focused: () => handle("the focused element", async () => (await getBase()).root.locator("*:focus:not(body)")),
396
+ async keyboard(key, keyOptions) {
397
+ if (keyOptions?.composing) {
398
+ await (await getBase()).root.locator("*:focus").evaluate(composingKeys, composingInit(key, keyOptions));
399
+ return;
400
+ }
401
+ await (await getBase()).page.keyboard.press(keyName(key, keyOptions, apple));
402
+ },
403
+ async pointerOutside() {
404
+ await (await getBase()).root.locator("body").click({
405
+ position: {
406
+ x: 1,
407
+ y: 1
408
+ },
409
+ force: true
410
+ });
411
+ },
412
+ until,
413
+ advance: async (ms) => {
414
+ if (options.advanceTimers) await options.advanceTimers(ms);
415
+ else await (await getBase()).page.waitForTimeout(Math.max(ms, 16));
416
+ },
417
+ instance,
418
+ anchorCount: async () => (await anchorLocator()).count(),
419
+ selectedText: async () => (await getBase()).root.evaluate(() => globalThis.getSelection()?.toString() ?? ""),
420
+ markNavigations: async () => {
421
+ navigationsFrom = await navigationState();
422
+ },
423
+ navigated: async (o) => {
424
+ const now = await navigationState();
425
+ const from = navigationsFrom ?? {
426
+ ...now,
427
+ log: []
428
+ };
429
+ const newTab = o?.newTab === true;
430
+ if (now.log.slice(from.log.length).some((t) => t === newTab)) return true;
431
+ return newTab ? now.pages > from.pages : now.url !== from.url;
432
+ },
433
+ collectDocument: async () => {
434
+ const { root } = await getBase();
435
+ await ensureInPage(root);
436
+ return root.evaluate((a) => globalThis.__rindTesting?.collectDom(a), {
437
+ scope,
438
+ instance: "\0unmounted"
439
+ });
440
+ },
441
+ collect: async () => {
442
+ const { root } = await getBase();
443
+ await ensureInPage(root);
444
+ const arg = {
445
+ scope,
446
+ instance: await instance()
447
+ };
448
+ return root.evaluate((a) => globalThis.__rindTesting?.collectDom(a), arg);
449
+ },
450
+ announcements: async () => {
451
+ const { root } = await getBase();
452
+ await poll(() => root.evaluate(() => Reflect.get(globalThis, Symbol.for("rind-ui.announcements.pending")) ?? 0), (n) => n === 0, {
453
+ timeout: 1e3,
454
+ wait: (ms) => new Promise((r) => setTimeout(r, ms))
455
+ }).catch(() => {});
456
+ return root.evaluate(() => [...Reflect.get(globalThis, Symbol.for("rind-ui.announcements")) ?? []]);
457
+ },
458
+ takeErrors: async () => watchPageErrors((await getBase()).page).splice(0),
459
+ chromiumChecks: async () => {
460
+ const { page, root } = await getBase();
461
+ /**
462
+ * The node, polled until it exists and shows no issue (the tree updates after the DOM),
463
+ * then read once more: null when it never existed within the timeout.
464
+ */
465
+ const settledNode = async (expression, issues) => {
466
+ const read = () => axNodeOf(page, expression);
467
+ const last = await until(read, (n) => n !== null && ("unavailable" in n || issues(n).length === 0)).catch(read);
468
+ if (last === null) return null;
469
+ return "unavailable" in last ? "unavailable" : last;
470
+ };
471
+ if (root !== page) return "unavailable";
472
+ await ensureInPage(page);
473
+ const id = await instance();
474
+ const snap = await page.evaluate((a) => globalThis.__rindTesting?.collectDom(a), {
475
+ scope,
476
+ instance: id
477
+ });
478
+ const partsSelector = JSON.stringify(`[data-scope="${scope}"][data-instance="${id}"][data-part]`);
479
+ const problems = [];
480
+ const exposedNow = (el) => !el.hidden && !el.inAriaHidden && !el.inInert;
481
+ for (const [i, el] of snap.parts.entries()) {
482
+ if (!exposedNow(el)) continue;
483
+ const expression = `document.querySelectorAll(${partsSelector})[${i}]`;
484
+ const labelled = el.attrs["aria-labelledby"] !== void 0 && el.name !== "";
485
+ const described = el.attrs["aria-describedby"] !== void 0 && el.description !== "";
486
+ const popup = [
487
+ "dialog",
488
+ "alertdialog",
489
+ "menu",
490
+ "listbox",
491
+ "tree",
492
+ "grid"
493
+ ].includes(el.role ?? "");
494
+ if (!labelled && !described && !popup) continue;
495
+ const issues = (node) => [
496
+ ...labelled && node.name === "" ? [`${el.describe}: Chromium computes no name (aria-labelledby target inert or ignored? RA#9737); in-page name "${el.name}"`] : [],
497
+ ...described && node.description === "" ? [`${el.describe}: Chromium drops the description (target ignored? RA#8915)`] : [],
498
+ ...popup && node.ignored ? [`${el.describe}: open popup is ignored by Chromium (${node.ignoredReasons.join(", ")}; RX#4115)`] : []
499
+ ];
500
+ const node = await settledNode(expression, issues);
501
+ if (node === "unavailable") return "unavailable";
502
+ if (node === null) {
503
+ problems.push(`${el.describe}: Chromium's accessibility node never became available`);
504
+ continue;
505
+ }
506
+ problems.push(...issues(node));
507
+ }
508
+ if (snap.focus.element) {
509
+ const focused = snap.focus.element;
510
+ const issues = (node) => node.ignored ? [`the focused ${focused.describe} is ignored by Chromium (${node.ignoredReasons.join(", ")})`] : [];
511
+ const node = await settledNode("document.activeElement", issues);
512
+ if (node === null) problems.push(`the focused ${focused.describe}: Chromium's node never became available`);
513
+ else if (node !== "unavailable") problems.push(...issues(node));
514
+ }
515
+ return problems;
516
+ },
517
+ setDirection: async (direction) => {
518
+ await (await getBase()).root.evaluate((dir) => {
519
+ if (dir === null) document.documentElement.removeAttribute("dir");
520
+ else document.documentElement.dir = dir;
521
+ }, direction);
522
+ }
523
+ };
524
+ }
525
+ //#endregion
526
+ export { chromiumTree as a, axNodeOf as i, playwrightEnv as n, watchPageErrors as r, isPage as t };
@@ -0,0 +1,14 @@
1
+ import { r as EnvFactory } from "./adapter-UPhu17S6.mjs";
2
+ import { FrameLocator, Locator, Page } from "playwright";
3
+ //#region src/adapters/playwright.d.ts
4
+ type PlaywrightTarget = Page | Locator | FrameLocator;
5
+ interface PlaywrightAdapterOptions {
6
+ /** `until` timeout in ms (default 5000, Playwright's expect timeout). */
7
+ readonly timeout?: number;
8
+ /** Advances time when the page uses `page.clock`; defaults to waiting. */
9
+ readonly advanceTimers?: (ms: number) => Promise<unknown>;
10
+ }
11
+ /** The Playwright adapter. */
12
+ declare function playwrightEnv(target: PlaywrightTarget, options?: PlaywrightAdapterOptions): EnvFactory;
13
+ //#endregion
14
+ export { PlaywrightTarget as n, playwrightEnv as r, PlaywrightAdapterOptions as t };
@@ -0,0 +1,29 @@
1
+ import { n as PlaywrightTarget, r as playwrightEnv, t as PlaywrightAdapterOptions } from "./playwright-CtIxjMKr.mjs";
2
+ import { Page } from "playwright";
3
+ //#region src/adapters/chromium-tree.d.ts
4
+ interface AxNode {
5
+ readonly role: string;
6
+ readonly name: string;
7
+ readonly description: string;
8
+ readonly ignored: boolean;
9
+ readonly ignoredReasons: readonly string[];
10
+ }
11
+ interface Unavailable {
12
+ readonly unavailable: true;
13
+ }
14
+ interface ChromiumTreeOptions {
15
+ /** Retry until the tree satisfies this (default: Chromium returned a tree). */
16
+ readonly until?: (nodes: readonly AxNode[]) => boolean;
17
+ /** Default 5000 ms. */
18
+ readonly timeout?: number;
19
+ }
20
+ /**
21
+ * Chromium's full accessibility tree, retried until it satisfies `until` (the tree updates
22
+ * after the DOM, so a fresh change may not be in it yet); `{ unavailable: true }` in other
23
+ * engines. Throws when `until` still fails after `timeout` ms.
24
+ */
25
+ export declare function chromiumTree(page: Page, { until, timeout }?: ChromiumTreeOptions): Promise<readonly AxNode[] | Unavailable>;
26
+ /** The accessibility node of the element a page expression evaluates to. */
27
+ export declare function axNodeOf(page: Page, expression: string): Promise<AxNode | Unavailable | null>;
28
+ //#endregion
29
+ export { type AxNode, type ChromiumTreeOptions, type PlaywrightAdapterOptions, type PlaywrightTarget, type Unavailable, playwrightEnv };
@@ -0,0 +1 @@
1
+ export { i as axNodeOf, a as chromiumTree, n as playwrightEnv } from "./playwright-C2LKzGS_.mjs";
@@ -0,0 +1,9 @@
1
+ //#region src/setup.d.ts
2
+ /**
3
+ * Where rind-ui modules that keep document-level state (layer stack, scroll lock, focus
4
+ * trap stack, tooltip group) register how to reset it.
5
+ */
6
+ export declare const RESETS: unique symbol;
7
+ /** Clears every piece of rind-ui document-level state. Call after each test. */
8
+ export declare function resetRindGlobals(): void;
9
+ //#endregion