nothing-browser 0.1.0 → 0.1.1

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.
@@ -12,74 +12,36 @@ export interface ElementDescriptor {
12
12
  value: string;
13
13
  attrs: Record<string, string>;
14
14
  }
15
- export interface FindByTextOptions {
16
- text: string;
17
- /** Narrow the search to descendants of this CSS selector. */
18
- selector?: string;
19
- /** If true, innerText must match exactly (trimmed). Default: false. */
20
- exact?: boolean;
21
- }
22
- export interface FindByAttrOptions {
23
- attr: string;
24
- /** If omitted, matches any element that has the attribute at all. */
25
- value?: string;
26
- /** Optionally scope to a parent selector. */
27
- selector?: string;
28
- }
29
- export interface FindByRoleOptions {
30
- role: string;
31
- /** Filter by aria-label or innerText containing this string. */
32
- name?: string;
33
- }
34
- export interface FindClosestOptions {
35
- /** CSS selector for the starting element. */
36
- selector: string;
37
- /** CSS selector for the ancestor to climb to. */
38
- ancestor: string;
39
- }
40
- export interface FindFilterOptions {
41
- selector: string;
42
- attr: string;
43
- value: string;
44
- }
45
15
  export declare class FindClient {
46
16
  private client;
47
17
  constructor(client: PiggyClient);
48
18
  /** querySelectorAll — returns all matching elements. */
49
19
  css(selector: string, tabId?: string): Promise<ElementDescriptor[]>;
50
- /** Alias for css() — querySelectorAll. */
20
+ /** Alias for css(). */
51
21
  all(selector: string, tabId?: string): Promise<ElementDescriptor[]>;
52
22
  /** querySelector — returns a single-element array or []. */
53
23
  first(selector: string, tabId?: string): Promise<ElementDescriptor[]>;
54
- /** Find elements whose innerText contains (or exactly matches) the given text. */
55
- byText(opts: FindByTextOptions, tabId?: string): Promise<ElementDescriptor[]>;
56
- /** Find elements by attribute name and optional value. */
57
- byAttr(opts: FindByAttrOptions, tabId?: string): Promise<ElementDescriptor[]>;
24
+ /** Find elements whose innerText contains the given text. */
25
+ byText(text: string, tabId?: string): Promise<ElementDescriptor[]>;
26
+ /** Find elements by attribute name (and optional value). */
27
+ byAttr(attr: string, value?: string, tabId?: string): Promise<ElementDescriptor[]>;
58
28
  /** getElementsByTagName. */
59
29
  byTag(tag: string, tabId?: string): Promise<ElementDescriptor[]>;
60
30
  /** Find inputs/textareas whose placeholder contains the given text. */
61
31
  byPlaceholder(text: string, tabId?: string): Promise<ElementDescriptor[]>;
62
- /** Find elements by ARIA role, optionally filtered by aria-label / innerText. */
63
- byRole(opts: FindByRoleOptions, tabId?: string): Promise<ElementDescriptor[]>;
32
+ /** Find elements by ARIA role, optionally filtered by accessible name. */
33
+ byRole(role: string, name?: string, tabId?: string): Promise<ElementDescriptor[]>;
64
34
  /** Direct children of the matched element. */
65
35
  children(selector: string, tabId?: string): Promise<ElementDescriptor[]>;
66
- /**
67
- * Filter querySelectorAll results by attribute value substring.
68
- * Equivalent to: querySelectorAll(selector).filter(el => el.attr.includes(value))
69
- */
70
- filter(opts: FindFilterOptions, tabId?: string): Promise<ElementDescriptor[]>;
71
- /** Walk up the DOM from selector until ancestor matches. */
72
- closest(opts: FindClosestOptions, tabId?: string): Promise<ElementDescriptor[]>;
73
36
  /** parentElement of the matched element. */
74
37
  parent(selector: string, tabId?: string): Promise<ElementDescriptor[]>;
38
+ /** Walk up the DOM from selector until ancestor matches. */
39
+ closest(selector: string, ancestor: string, tabId?: string): Promise<ElementDescriptor[]>;
75
40
  /** Number of elements matching the selector. */
76
41
  count(selector: string, tabId?: string): Promise<number>;
77
- /** True if at least one element matches the selector. */
42
+ /** True if at least one element matches. */
78
43
  exists(selector: string, tabId?: string): Promise<boolean>;
79
- /**
80
- * True if the first matched element is visible
81
- * (display !== none, visibility !== hidden, opacity !== 0).
82
- */
44
+ /** True if the first matched element is visible. */
83
45
  visible(selector: string, tabId?: string): Promise<boolean>;
84
46
  /** True if the first matched element is not disabled. */
85
47
  enabled(selector: string, tabId?: string): Promise<boolean>;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../piggy/find/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAA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GAAG,OAAO,CAAC,MAAM,CAAC;IAI3D,4CAA4C;IAC5C,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,SAAY,GAAG,OAAO,CAAC,OAAO,CAAC;IAI7D,oDAAoD;IACpD,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,SAAY,GAAG,OAAO,CAAC,OAAO,CAAC;IAI9D,yDAAyD;IACzD,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,SAAY,GAAG,OAAO,CAAC,OAAO,CAAC;IAI9D,2DAA2D;IAC3D,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,SAAY,GAAG,OAAO,CAAC,OAAO,CAAC;CAG/D;AAID,wBAAgB,aAAa,CAAC,MAAM,EAAE,WAAW,GAAG,UAAU,CAE7D"}
@@ -1,4 +1,21 @@
1
1
  import { PiggyClient } from "../client";
2
+ export interface ProvideOptions {
3
+ /** CSS selector for the target element(s). */
4
+ selector: string;
5
+ /**
6
+ * Optional parent selector to scope the query under.
7
+ * Equivalent to: parent.querySelector(selector)
8
+ */
9
+ parent?: string;
10
+ }
11
+ export interface ProvideAttrOptions extends ProvideOptions {
12
+ /** The attribute name to extract. */
13
+ attr: string;
14
+ }
15
+ export interface ProvideListOptions extends ProvideOptions {
16
+ /** Optional child selector to scope list items. */
17
+ itemSel?: string;
18
+ }
2
19
  export interface ProvideTable {
3
20
  headers: string[];
4
21
  rows: string[][];
@@ -44,38 +61,38 @@ export declare class ProvideClient {
44
61
  private client;
45
62
  constructor(client: PiggyClient);
46
63
  /** innerText of the first matched element. */
47
- text(selector: string, tabId?: string): Promise<string>;
64
+ text(opts: ProvideOptions, tabId?: string): Promise<string>;
48
65
  /** innerText of all matched elements. */
49
- textAll(selector: string, tabId?: string): Promise<string[]>;
66
+ textAll(opts: ProvideOptions, tabId?: string): Promise<string[]>;
50
67
  /** Single attribute value from the first matched element. */
51
- attr(selector: string, attr: string, tabId?: string): Promise<string>;
68
+ attr(opts: ProvideAttrOptions, tabId?: string): Promise<string>;
52
69
  /** Attribute value from all matched elements. */
53
- attrAll(selector: string, attr: string, tabId?: string): Promise<string[]>;
70
+ attrAll(opts: ProvideAttrOptions, tabId?: string): Promise<string[]>;
54
71
  /** innerHTML of the first matched element. */
55
- html(selector: string, tabId?: string): Promise<string>;
72
+ html(opts: ProvideOptions, tabId?: string): Promise<string>;
56
73
  /** Extract a table into headers + rows. */
57
- table(selector: string, tabId?: string): Promise<ProvideTable>;
58
- /** Extract a list of text items. Optionally scope items with itemSel. */
59
- list(selector: string, itemSel?: string, tabId?: string): Promise<string[]>;
60
- /** All links inside an optional selector. */
61
- links(selector?: string, tabId?: string): Promise<ProvideLink[]>;
62
- /** All images inside an optional selector. */
63
- images(selector?: string, tabId?: string): Promise<ProvideImage[]>;
74
+ table(opts: ProvideOptions, tabId?: string): Promise<ProvideTable>;
75
+ /** Extract a list of text items, optionally scoped to child items. */
76
+ list(opts: ProvideListOptions, tabId?: string): Promise<string[]>;
77
+ /** All links inside the matched selector. */
78
+ links(opts: ProvideOptions, tabId?: string): Promise<ProvideLink[]>;
79
+ /** All images inside the matched selector. */
80
+ images(opts: ProvideOptions, tabId?: string): Promise<ProvideImage[]>;
64
81
  /** Form field name→value map. */
65
- form(selector: string, tabId?: string): Promise<ProvideForm>;
66
- /** Full page info: title, url, html, text. */
82
+ form(opts: ProvideOptions, tabId?: string): Promise<ProvideForm>;
83
+ /** Full page info: title, url, html, text. No selector needed. */
67
84
  page(tabId?: string): Promise<ProvidePage>;
68
- /** Structured div: tag, id, cls, text, html, children[]. */
69
- div(selector: string, tabId?: string): Promise<ProvideDiv>;
70
- /** All <meta> name→content pairs. */
85
+ /** Structured div tree: tag, id, cls, text, html, children[]. */
86
+ div(opts: ProvideOptions, tabId?: string): Promise<ProvideDiv>;
87
+ /** All <meta> name→content pairs. No selector needed. */
71
88
  meta(tabId?: string): Promise<ProvideMeta>;
72
89
  /** <select> current value + all options. */
73
- select(selector: string, tabId?: string): Promise<ProvideSelect>;
90
+ select(opts: ProvideOptions, tabId?: string): Promise<ProvideSelect>;
74
91
  /**
75
92
  * Parse JSON from element innerText or script[type=application/json].
76
93
  * selector is optional — defaults to the first matching JSON script tag.
77
94
  */
78
- json(selector?: string, tabId?: string): Promise<unknown>;
95
+ json(opts?: Partial<ProvideOptions>, tabId?: string): Promise<unknown>;
79
96
  }
80
97
  export declare function createProvideAPI(client: PiggyClient): ProvideClient;
81
98
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../piggy/provide/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAIxC,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,IAAI,EAAK,MAAM,EAAE,EAAE,CAAC;CACrB;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,WAAW;IAC1B,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAI,MAAM,CAAC;IACd,IAAI,EAAG,MAAM,CAAC;IACd,IAAI,EAAG,MAAM,CAAC;CACf;AAED,MAAM,WAAW,UAAU;IACzB,GAAG,EAAO,MAAM,CAAC;IACjB,EAAE,EAAQ,MAAM,CAAC;IACjB,GAAG,EAAO,MAAM,CAAC;IACjB,IAAI,EAAM,MAAM,CAAC;IACjB,IAAI,EAAM,MAAM,CAAC;IACjB,QAAQ,EAAE,UAAU,EAAE,CAAC;CACxB;AAED,MAAM,WAAW,WAAW;IAC1B,CAAC,IAAI,EAAE,MAAM,GAAG,M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C,IAAI,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,EAAE,KAAK,SAAY,GAAG,OAAO,CAAC,OAAO,CAAC;CAG1E;AAID,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,WAAW,GAAG,aAAa,CAEnE"}
package/dist/piggy.js CHANGED
@@ -29333,11 +29333,11 @@ class FindClient {
29333
29333
  first(selector, tabId = "default") {
29334
29334
  return this.client.send("find.first", { selector, tabId });
29335
29335
  }
29336
- byText(opts, tabId = "default") {
29337
- return this.client.send("find.byText", { ...opts, tabId });
29336
+ byText(text, tabId = "default") {
29337
+ return this.client.send("find.byText", { text, tabId });
29338
29338
  }
29339
- byAttr(opts, tabId = "default") {
29340
- return this.client.send("find.byAttr", { ...opts, tabId });
29339
+ byAttr(attr, value, tabId = "default") {
29340
+ return this.client.send("find.byAttr", { attr, value, tabId });
29341
29341
  }
29342
29342
  byTag(tag, tabId = "default") {
29343
29343
  return this.client.send("find.byTag", { tag, tabId });
@@ -29345,21 +29345,18 @@ class FindClient {
29345
29345
  byPlaceholder(text, tabId = "default") {
29346
29346
  return this.client.send("find.byPlaceholder", { text, tabId });
29347
29347
  }
29348
- byRole(opts, tabId = "default") {
29349
- return this.client.send("find.byRole", { ...opts, tabId });
29348
+ byRole(role, name, tabId = "default") {
29349
+ return this.client.send("find.byRole", { role, name, tabId });
29350
29350
  }
29351
29351
  children(selector, tabId = "default") {
29352
29352
  return this.client.send("find.children", { selector, tabId });
29353
29353
  }
29354
- filter(opts, tabId = "default") {
29355
- return this.client.send("find.filter", { ...opts, tabId });
29356
- }
29357
- closest(opts, tabId = "default") {
29358
- return this.client.send("find.closest", { ...opts, tabId });
29359
- }
29360
29354
  parent(selector, tabId = "default") {
29361
29355
  return this.client.send("find.parent", { selector, tabId });
29362
29356
  }
29357
+ closest(selector, ancestor, tabId = "default") {
29358
+ return this.client.send("find.closest", { selector, ancestor, tabId });
29359
+ }
29363
29360
  count(selector, tabId = "default") {
29364
29361
  return this.client.send("find.count", { selector, tabId });
29365
29362
  }
@@ -29544,50 +29541,50 @@ class ProvideClient {
29544
29541
  constructor(client) {
29545
29542
  this.client = client;
29546
29543
  }
29547
- text(selector, tabId = "default") {
29548
- return this.client.send("provide.text", { selector, tabId });
29544
+ text(opts, tabId = "default") {
29545
+ return this.client.send("provide.text", { ...opts, tabId });
29549
29546
  }
29550
- textAll(selector, tabId = "default") {
29551
- return this.client.send("provide.textAll", { selector, tabId });
29547
+ textAll(opts, tabId = "default") {
29548
+ return this.client.send("provide.textAll", { ...opts, tabId });
29552
29549
  }
29553
- attr(selector, attr, tabId = "default") {
29554
- return this.client.send("provide.attr", { selector, attr, tabId });
29550
+ attr(opts, tabId = "default") {
29551
+ return this.client.send("provide.attr", { ...opts, tabId });
29555
29552
  }
29556
- attrAll(selector, attr, tabId = "default") {
29557
- return this.client.send("provide.attrAll", { selector, attr, tabId });
29553
+ attrAll(opts, tabId = "default") {
29554
+ return this.client.send("provide.attrAll", { ...opts, tabId });
29558
29555
  }
29559
- html(selector, tabId = "default") {
29560
- return this.client.send("provide.html", { selector, tabId });
29556
+ html(opts, tabId = "default") {
29557
+ return this.client.send("provide.html", { ...opts, tabId });
29561
29558
  }
29562
- table(selector, tabId = "default") {
29563
- return this.client.send("provide.table", { selector, tabId });
29559
+ table(opts, tabId = "default") {
29560
+ return this.client.send("provide.table", { ...opts, tabId });
29564
29561
  }
29565
- list(selector, itemSel, tabId = "default") {
29566
- return this.client.send("provide.list", { selector, itemSel, tabId });
29562
+ list(opts, tabId = "default") {
29563
+ return this.client.send("provide.list", { ...opts, tabId });
29567
29564
  }
29568
- links(selector, tabId = "default") {
29569
- return this.client.send("provide.links", { selector, tabId });
29565
+ links(opts, tabId = "default") {
29566
+ return this.client.send("provide.links", { ...opts, tabId });
29570
29567
  }
29571
- images(selector, tabId = "default") {
29572
- return this.client.send("provide.images", { selector, tabId });
29568
+ images(opts, tabId = "default") {
29569
+ return this.client.send("provide.images", { ...opts, tabId });
29573
29570
  }
29574
- form(selector, tabId = "default") {
29575
- return this.client.send("provide.form", { selector, tabId });
29571
+ form(opts, tabId = "default") {
29572
+ return this.client.send("provide.form", { ...opts, tabId });
29576
29573
  }
29577
29574
  page(tabId = "default") {
29578
29575
  return this.client.send("provide.page", { tabId });
29579
29576
  }
29580
- div(selector, tabId = "default") {
29581
- return this.client.send("provide.div", { selector, tabId });
29577
+ div(opts, tabId = "default") {
29578
+ return this.client.send("provide.div", { ...opts, tabId });
29582
29579
  }
29583
29580
  meta(tabId = "default") {
29584
29581
  return this.client.send("provide.meta", { tabId });
29585
29582
  }
29586
- select(selector, tabId = "default") {
29587
- return this.client.send("provide.select", { selector, tabId });
29583
+ select(opts, tabId = "default") {
29584
+ return this.client.send("provide.select", { ...opts, tabId });
29588
29585
  }
29589
- json(selector, tabId = "default") {
29590
- return this.client.send("provide.json", { selector, tabId });
29586
+ json(opts, tabId = "default") {
29587
+ return this.client.send("provide.json", { ...opts, tabId });
29591
29588
  }
29592
29589
  }
29593
29590
  function createProvideAPI(client) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nothing-browser",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Browser automation library powered by Nothing Browser",
5
5
  "homepage": "https://github.com/ernest-tech-house-co-operation/nothing-browser#readme",
6
6
  "repository": {
@@ -5,69 +5,35 @@ import { PiggyClient } from "../client";
5
5
  // Mirrors __nb_serialize() in PiggyFind.cpp
6
6
 
7
7
  export interface ElementDescriptor {
8
- tag: string;
9
- id: string;
10
- cls: string;
8
+ tag: string;
9
+ id: string;
10
+ cls: string;
11
11
  /** First 400 chars of innerText */
12
- text: string;
12
+ text: string;
13
13
  /** First 800 chars of innerHTML */
14
- html: string;
15
- href: string;
16
- src: string;
14
+ html: string;
15
+ href: string;
16
+ src: string;
17
17
  value: string;
18
18
  attrs: Record<string, string>;
19
19
  }
20
20
 
21
- // ─── Option types ─────────────────────────────────────────────────────────────
22
-
23
- export interface FindByTextOptions {
24
- text: string;
25
- /** Narrow the search to descendants of this CSS selector. */
26
- selector?: string;
27
- /** If true, innerText must match exactly (trimmed). Default: false. */
28
- exact?: boolean;
29
- }
30
-
31
- export interface FindByAttrOptions {
32
- attr: string;
33
- /** If omitted, matches any element that has the attribute at all. */
34
- value?: string;
35
- /** Optionally scope to a parent selector. */
36
- selector?: string;
37
- }
38
-
39
- export interface FindByRoleOptions {
40
- role: string;
41
- /** Filter by aria-label or innerText containing this string. */
42
- name?: string;
43
- }
44
-
45
- export interface FindClosestOptions {
46
- /** CSS selector for the starting element. */
47
- selector: string;
48
- /** CSS selector for the ancestor to climb to. */
49
- ancestor: string;
50
- }
51
-
52
- export interface FindFilterOptions {
53
- selector: string;
54
- attr: string;
55
- value: string;
56
- }
57
-
58
21
  // ─── FindClient ───────────────────────────────────────────────────────────────
22
+ // find answers ONE question: "is this thing here, and where?"
23
+ // All methods take plain selector strings — no option objects, no parent scoping.
24
+ // If you need a value out of an element, use provide instead.
59
25
 
60
26
  export class FindClient {
61
27
  constructor(private client: PiggyClient) {}
62
28
 
63
- // ── Multi-result queries ─────────────────────────────────────────────────────
29
+ // ── Multi-result ─────────────────────────────────────────────────────────────
64
30
 
65
31
  /** querySelectorAll — returns all matching elements. */
66
32
  css(selector: string, tabId = "default"): Promise<ElementDescriptor[]> {
67
33
  return this.client.send("find.css", { selector, tabId });
68
34
  }
69
35
 
70
- /** Alias for css() — querySelectorAll. */
36
+ /** Alias for css(). */
71
37
  all(selector: string, tabId = "default"): Promise<ElementDescriptor[]> {
72
38
  return this.client.send("find.all", { selector, tabId });
73
39
  }
@@ -77,14 +43,14 @@ export class FindClient {
77
43
  return this.client.send("find.first", { selector, tabId });
78
44
  }
79
45
 
80
- /** Find elements whose innerText contains (or exactly matches) the given text. */
81
- byText(opts: FindByTextOptions, tabId = "default"): Promise<ElementDescriptor[]> {
82
- return this.client.send("find.byText", { ...opts, tabId });
46
+ /** Find elements whose innerText contains the given text. */
47
+ byText(text: string, tabId = "default"): Promise<ElementDescriptor[]> {
48
+ return this.client.send("find.byText", { text, tabId });
83
49
  }
84
50
 
85
- /** Find elements by attribute name and optional value. */
86
- byAttr(opts: FindByAttrOptions, tabId = "default"): Promise<ElementDescriptor[]> {
87
- return this.client.send("find.byAttr", { ...opts, tabId });
51
+ /** Find elements by attribute name (and optional value). */
52
+ byAttr(attr: string, value?: string, tabId = "default"): Promise<ElementDescriptor[]> {
53
+ return this.client.send("find.byAttr", { attr, value, tabId });
88
54
  }
89
55
 
90
56
  /** getElementsByTagName. */
@@ -97,9 +63,9 @@ export class FindClient {
97
63
  return this.client.send("find.byPlaceholder", { text, tabId });
98
64
  }
99
65
 
100
- /** Find elements by ARIA role, optionally filtered by aria-label / innerText. */
101
- byRole(opts: FindByRoleOptions, tabId = "default"): Promise<ElementDescriptor[]> {
102
- return this.client.send("find.byRole", { ...opts, tabId });
66
+ /** Find elements by ARIA role, optionally filtered by accessible name. */
67
+ byRole(role: string, name?: string, tabId = "default"): Promise<ElementDescriptor[]> {
68
+ return this.client.send("find.byRole", { role, name, tabId });
103
69
  }
104
70
 
105
71
  /** Direct children of the matched element. */
@@ -107,42 +73,29 @@ export class FindClient {
107
73
  return this.client.send("find.children", { selector, tabId });
108
74
  }
109
75
 
110
- /**
111
- * Filter querySelectorAll results by attribute value substring.
112
- * Equivalent to: querySelectorAll(selector).filter(el => el.attr.includes(value))
113
- */
114
- filter(opts: FindFilterOptions, tabId = "default"): Promise<ElementDescriptor[]> {
115
- return this.client.send("find.filter", { ...opts, tabId });
116
- }
117
-
118
- // ── Single-element traversal ──────────────────────────────────────────────
119
-
120
- /** Walk up the DOM from selector until ancestor matches. */
121
- closest(opts: FindClosestOptions, tabId = "default"): Promise<ElementDescriptor[]> {
122
- return this.client.send("find.closest", { ...opts, tabId });
123
- }
124
-
125
76
  /** parentElement of the matched element. */
126
77
  parent(selector: string, tabId = "default"): Promise<ElementDescriptor[]> {
127
78
  return this.client.send("find.parent", { selector, tabId });
128
79
  }
129
80
 
130
- // ── Boolean / numeric queries ─────────────────────────────────────────────
81
+ /** Walk up the DOM from selector until ancestor matches. */
82
+ closest(selector: string, ancestor: string, tabId = "default"): Promise<ElementDescriptor[]> {
83
+ return this.client.send("find.closest", { selector, ancestor, tabId });
84
+ }
85
+
86
+ // ── Boolean / numeric ────────────────────────────────────────────────────────
131
87
 
132
88
  /** Number of elements matching the selector. */
133
89
  count(selector: string, tabId = "default"): Promise<number> {
134
90
  return this.client.send("find.count", { selector, tabId });
135
91
  }
136
92
 
137
- /** True if at least one element matches the selector. */
93
+ /** True if at least one element matches. */
138
94
  exists(selector: string, tabId = "default"): Promise<boolean> {
139
95
  return this.client.send("find.exists", { selector, tabId });
140
96
  }
141
97
 
142
- /**
143
- * True if the first matched element is visible
144
- * (display !== none, visibility !== hidden, opacity !== 0).
145
- */
98
+ /** True if the first matched element is visible. */
146
99
  visible(selector: string, tabId = "default"): Promise<boolean> {
147
100
  return this.client.send("find.visible", { selector, tabId });
148
101
  }
@@ -158,7 +111,7 @@ export class FindClient {
158
111
  }
159
112
  }
160
113
 
161
- // ── Factory helper ────────────────────────────────────────────────────────────
114
+ // ─── Factory helper ───────────────────────────────────────────────────────────
162
115
 
163
116
  export function createFindAPI(client: PiggyClient): FindClient {
164
117
  return new FindClient(client);
@@ -1,6 +1,29 @@
1
1
  // piggy/provide/index.ts
2
2
  import { PiggyClient } from "../client";
3
3
 
4
+ // ─── Shared base option ───────────────────────────────────────────────────────
5
+ // Every provide method targets a selector, and optionally scopes under a parent.
6
+
7
+ export interface ProvideOptions {
8
+ /** CSS selector for the target element(s). */
9
+ selector: string;
10
+ /**
11
+ * Optional parent selector to scope the query under.
12
+ * Equivalent to: parent.querySelector(selector)
13
+ */
14
+ parent?: string;
15
+ }
16
+
17
+ export interface ProvideAttrOptions extends ProvideOptions {
18
+ /** The attribute name to extract. */
19
+ attr: string;
20
+ }
21
+
22
+ export interface ProvideListOptions extends ProvideOptions {
23
+ /** Optional child selector to scope list items. */
24
+ itemSel?: string;
25
+ }
26
+
4
27
  // ─── Return types ─────────────────────────────────────────────────────────────
5
28
 
6
29
  export interface ProvideTable {
@@ -54,86 +77,89 @@ export interface ProvideSelect {
54
77
  }
55
78
 
56
79
  // ─── ProvideClient ────────────────────────────────────────────────────────────
80
+ // provide answers ONE question: "give me the actual value from this element."
81
+ // All methods take an options object { selector, parent? } so scoping is consistent.
82
+ // If you just want to know if something exists, use find instead.
57
83
 
58
84
  export class ProvideClient {
59
85
  constructor(private client: PiggyClient) {}
60
86
 
61
87
  /** innerText of the first matched element. */
62
- text(selector: string, tabId = "default"): Promise<string> {
63
- return this.client.send("provide.text", { selector, tabId });
88
+ text(opts: ProvideOptions, tabId = "default"): Promise<string> {
89
+ return this.client.send("provide.text", { ...opts, tabId });
64
90
  }
65
91
 
66
92
  /** innerText of all matched elements. */
67
- textAll(selector: string, tabId = "default"): Promise<string[]> {
68
- return this.client.send("provide.textAll", { selector, tabId });
93
+ textAll(opts: ProvideOptions, tabId = "default"): Promise<string[]> {
94
+ return this.client.send("provide.textAll", { ...opts, tabId });
69
95
  }
70
96
 
71
97
  /** Single attribute value from the first matched element. */
72
- attr(selector: string, attr: string, tabId = "default"): Promise<string> {
73
- return this.client.send("provide.attr", { selector, attr, tabId });
98
+ attr(opts: ProvideAttrOptions, tabId = "default"): Promise<string> {
99
+ return this.client.send("provide.attr", { ...opts, tabId });
74
100
  }
75
101
 
76
102
  /** Attribute value from all matched elements. */
77
- attrAll(selector: string, attr: string, tabId = "default"): Promise<string[]> {
78
- return this.client.send("provide.attrAll", { selector, attr, tabId });
103
+ attrAll(opts: ProvideAttrOptions, tabId = "default"): Promise<string[]> {
104
+ return this.client.send("provide.attrAll", { ...opts, tabId });
79
105
  }
80
106
 
81
107
  /** innerHTML of the first matched element. */
82
- html(selector: string, tabId = "default"): Promise<string> {
83
- return this.client.send("provide.html", { selector, tabId });
108
+ html(opts: ProvideOptions, tabId = "default"): Promise<string> {
109
+ return this.client.send("provide.html", { ...opts, tabId });
84
110
  }
85
111
 
86
112
  /** Extract a table into headers + rows. */
87
- table(selector: string, tabId = "default"): Promise<ProvideTable> {
88
- return this.client.send("provide.table", { selector, tabId });
113
+ table(opts: ProvideOptions, tabId = "default"): Promise<ProvideTable> {
114
+ return this.client.send("provide.table", { ...opts, tabId });
89
115
  }
90
116
 
91
- /** Extract a list of text items. Optionally scope items with itemSel. */
92
- list(selector: string, itemSel?: string, tabId = "default"): Promise<string[]> {
93
- return this.client.send("provide.list", { selector, itemSel, tabId });
117
+ /** Extract a list of text items, optionally scoped to child items. */
118
+ list(opts: ProvideListOptions, tabId = "default"): Promise<string[]> {
119
+ return this.client.send("provide.list", { ...opts, tabId });
94
120
  }
95
121
 
96
- /** All links inside an optional selector. */
97
- links(selector?: string, tabId = "default"): Promise<ProvideLink[]> {
98
- return this.client.send("provide.links", { selector, tabId });
122
+ /** All links inside the matched selector. */
123
+ links(opts: ProvideOptions, tabId = "default"): Promise<ProvideLink[]> {
124
+ return this.client.send("provide.links", { ...opts, tabId });
99
125
  }
100
126
 
101
- /** All images inside an optional selector. */
102
- images(selector?: string, tabId = "default"): Promise<ProvideImage[]> {
103
- return this.client.send("provide.images", { selector, tabId });
127
+ /** All images inside the matched selector. */
128
+ images(opts: ProvideOptions, tabId = "default"): Promise<ProvideImage[]> {
129
+ return this.client.send("provide.images", { ...opts, tabId });
104
130
  }
105
131
 
106
132
  /** Form field name→value map. */
107
- form(selector: string, tabId = "default"): Promise<ProvideForm> {
108
- return this.client.send("provide.form", { selector, tabId });
133
+ form(opts: ProvideOptions, tabId = "default"): Promise<ProvideForm> {
134
+ return this.client.send("provide.form", { ...opts, tabId });
109
135
  }
110
136
 
111
- /** Full page info: title, url, html, text. */
137
+ /** Full page info: title, url, html, text. No selector needed. */
112
138
  page(tabId = "default"): Promise<ProvidePage> {
113
139
  return this.client.send("provide.page", { tabId });
114
140
  }
115
141
 
116
- /** Structured div: tag, id, cls, text, html, children[]. */
117
- div(selector: string, tabId = "default"): Promise<ProvideDiv> {
118
- return this.client.send("provide.div", { selector, tabId });
142
+ /** Structured div tree: tag, id, cls, text, html, children[]. */
143
+ div(opts: ProvideOptions, tabId = "default"): Promise<ProvideDiv> {
144
+ return this.client.send("provide.div", { ...opts, tabId });
119
145
  }
120
146
 
121
- /** All <meta> name→content pairs. */
147
+ /** All <meta> name→content pairs. No selector needed. */
122
148
  meta(tabId = "default"): Promise<ProvideMeta> {
123
149
  return this.client.send("provide.meta", { tabId });
124
150
  }
125
151
 
126
152
  /** <select> current value + all options. */
127
- select(selector: string, tabId = "default"): Promise<ProvideSelect> {
128
- return this.client.send("provide.select", { selector, tabId });
153
+ select(opts: ProvideOptions, tabId = "default"): Promise<ProvideSelect> {
154
+ return this.client.send("provide.select", { ...opts, tabId });
129
155
  }
130
156
 
131
157
  /**
132
158
  * Parse JSON from element innerText or script[type=application/json].
133
159
  * selector is optional — defaults to the first matching JSON script tag.
134
160
  */
135
- json(selector?: string, tabId = "default"): Promise<unknown> {
136
- return this.client.send("provide.json", { selector, tabId });
161
+ json(opts?: Partial<ProvideOptions>, tabId = "default"): Promise<unknown> {
162
+ return this.client.send("provide.json", { ...opts, tabId });
137
163
  }
138
164
  }
139
165
 
@@ -1,79 +0,0 @@
1
- // piggy/find/index.d.ts
2
- import { PiggyClient } from "../client";
3
-
4
- // ─── Element descriptor ───────────────────────────────────────────────────────
5
-
6
- export interface ElementDescriptor {
7
- tag: string;
8
- id: string;
9
- cls: string;
10
- /** First 400 chars of innerText */
11
- text: string;
12
- /** First 800 chars of innerHTML */
13
- html: string;
14
- href: string;
15
- src: string;
16
- value: string;
17
- attrs: Record<string, string>;
18
- }
19
-
20
- // ─── Option types ─────────────────────────────────────────────────────────────
21
-
22
- export interface FindByTextOptions {
23
- text: string;
24
- selector?: string;
25
- exact?: boolean;
26
- }
27
-
28
- export interface FindByAttrOptions {
29
- attr: string;
30
- value?: string;
31
- selector?: string;
32
- }
33
-
34
- export interface FindByRoleOptions {
35
- role: string;
36
- name?: string;
37
- }
38
-
39
- export interface FindClosestOptions {
40
- selector: string;
41
- ancestor: string;
42
- }
43
-
44
- export interface FindFilterOptions {
45
- selector: string;
46
- attr: string;
47
- value: string;
48
- }
49
-
50
- // ─── FindClient ───────────────────────────────────────────────────────────────
51
-
52
- export declare class FindClient {
53
- constructor(client: PiggyClient);
54
-
55
- // Multi-result
56
- css(selector: string, tabId?: string): Promise<ElementDescriptor[]>;
57
- all(selector: string, tabId?: string): Promise<ElementDescriptor[]>;
58
- first(selector: string, tabId?: string): Promise<ElementDescriptor[]>;
59
- byText(opts: FindByTextOptions, tabId?: string): Promise<ElementDescriptor[]>;
60
- byAttr(opts: FindByAttrOptions, tabId?: string): Promise<ElementDescriptor[]>;
61
- byTag(tag: string, tabId?: string): Promise<ElementDescriptor[]>;
62
- byPlaceholder(text: string, tabId?: string): Promise<ElementDescriptor[]>;
63
- byRole(opts: FindByRoleOptions, tabId?: string): Promise<ElementDescriptor[]>;
64
- children(selector: string, tabId?: string): Promise<ElementDescriptor[]>;
65
- filter(opts: FindFilterOptions, tabId?: string): Promise<ElementDescriptor[]>;
66
-
67
- // Traversal
68
- closest(opts: FindClosestOptions, tabId?: string): Promise<ElementDescriptor[]>;
69
- parent(selector: string, tabId?: string): Promise<ElementDescriptor[]>;
70
-
71
- // Boolean / numeric
72
- count(selector: string, tabId?: string): Promise<number>;
73
- exists(selector: string, tabId?: string): Promise<boolean>;
74
- visible(selector: string, tabId?: string): Promise<boolean>;
75
- enabled(selector: string, tabId?: string): Promise<boolean>;
76
- checked(selector: string, tabId?: string): Promise<boolean>;
77
- }
78
-
79
- export declare function createFindAPI(client: PiggyClient): FindClient;