Skip to content

Commit 8a31c8f

Browse files
committed
fix: polish helper subpath typings
1 parent aeeb35b commit 8a31c8f

5 files changed

Lines changed: 22 additions & 9 deletions

File tree

src/__tests__/finders-public.test.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { test } from 'vitest';
21
import assert from 'node:assert/strict';
2+
import { test } from 'vitest';
33
import {
44
findBestMatchesByLocator,
55
normalizeRole,
@@ -21,10 +21,16 @@ test('public finders entrypoint re-exports pure helpers', () => {
2121
const nodes: SnapshotNode[] = [makeNode('e1', 'Continue')];
2222

2323
const parsed = parseFindArgs(['label', 'Continue', 'click']);
24-
const best = findBestMatchesByLocator(nodes, 'label', 'Continue', true);
24+
const best = findBestMatchesByLocator(nodes, 'label', 'Continue');
25+
const requireRectLegacy = findBestMatchesByLocator(nodes, 'label', 'Continue', true);
26+
const requireRectOptions = findBestMatchesByLocator(nodes, 'label', 'Continue', {
27+
requireRect: true,
28+
});
2529

2630
assert.equal(normalizeText(' Continue\nNow '), 'continue now');
2731
assert.equal(normalizeRole('XCUIElementTypeApplication.XCUIElementTypeButton'), 'button');
2832
assert.equal(parsed.action, 'click');
29-
assert.equal(best.matches.length, 0);
33+
assert.equal(best.matches.length, 1);
34+
assert.equal(requireRectLegacy.matches.length, 0);
35+
assert.equal(requireRectOptions.matches.length, 0);
3036
});

src/__tests__/selectors-public.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { test } from 'vitest';
21
import assert from 'node:assert/strict';
2+
import { test } from 'vitest';
33
import {
44
findSelectorChainMatch,
55
formatSelectorFailure,

src/finders.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export type { FindLocator } from './utils/finders.ts';
2+
export type { SnapshotNode } from './utils/snapshot.ts';
23
export { normalizeRole, normalizeText, parseFindArgs } from './utils/finders.ts';
34

45
import {
@@ -7,11 +8,16 @@ import {
78
} from './utils/finders.ts';
89
import type { SnapshotNode } from './utils/snapshot.ts';
910

11+
export type FindMatchOptions = {
12+
requireRect?: boolean;
13+
};
14+
1015
export function findBestMatchesByLocator(
1116
nodes: SnapshotNode[],
1217
locator: FindLocator,
1318
query: string,
14-
requireRect?: boolean,
19+
options?: boolean | FindMatchOptions,
1520
) {
16-
return findBestMatchesByLocatorInternal(nodes, locator, query, { requireRect });
21+
const matchOptions = typeof options === 'boolean' ? { requireRect: options } : options;
22+
return findBestMatchesByLocatorInternal(nodes, locator, query, matchOptions);
1723
}

src/selectors.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export type {
44
SelectorDiagnostics,
55
SelectorResolution,
66
} from './daemon/selectors.ts';
7+
export type { SnapshotNode } from './utils/snapshot.ts';
78

89
export {
910
findSelectorChainMatch,

website/docs/docs/client-api.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ Public subpath API exposed for Node consumers:
3232
- `isNodeVisible(node)`
3333
- `isSelectorToken(token)`
3434
- `isNodeEditable(node, platform)`
35-
- types: `Selector`, `SelectorChain`, `SelectorDiagnostics`, `SelectorResolution`
35+
- types: `Selector`, `SelectorChain`, `SelectorDiagnostics`, `SelectorResolution`, `SnapshotNode`
3636
- `agent-device/finders`
37-
- `findBestMatchesByLocator(nodes, locator, query, requireRect)`
37+
- `findBestMatchesByLocator(nodes, locator, query, requireRectOrOptions)`
3838
- `normalizeRole(value)`
3939
- `normalizeText(value)`
4040
- `parseFindArgs(args)`
41-
- types: `FindLocator`
41+
- types: `FindLocator`, `FindMatchOptions`, `SnapshotNode`
4242
- `agent-device/install-source`
4343
- `ARCHIVE_EXTENSIONS`
4444
- `isBlockedIpAddress(address)`

0 commit comments

Comments
 (0)