@enricai/barnacle 1.12.70 → 1.12.71

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 (32) hide show
  1. package/dist/scraper/browser-click-expr.d.ts +3 -4
  2. package/dist/scraper/browser-click-expr.d.ts.map +1 -1
  3. package/dist/scraper/browser-click-expr.js +3 -4
  4. package/dist/scraper/browser-click-expr.js.map +1 -1
  5. package/dist/scraper/flow-runner.d.ts +27 -6
  6. package/dist/scraper/flow-runner.d.ts.map +1 -1
  7. package/dist/scraper/flow-runner.js +332 -61
  8. package/dist/scraper/flow-runner.js.map +1 -1
  9. package/dist/scraper/frame-target.d.ts +12 -0
  10. package/dist/scraper/frame-target.d.ts.map +1 -1
  11. package/dist/scraper/frame-target.js +1 -0
  12. package/dist/scraper/frame-target.js.map +1 -1
  13. package/dist/scraper/submit-control.d.ts +30 -2
  14. package/dist/scraper/submit-control.d.ts.map +1 -1
  15. package/dist/scraper/submit-control.js +79 -20
  16. package/dist/scraper/submit-control.js.map +1 -1
  17. package/dist/scraper/target-resolution-diagnostic.d.ts +53 -0
  18. package/dist/scraper/target-resolution-diagnostic.d.ts.map +1 -0
  19. package/dist/scraper/target-resolution-diagnostic.js +153 -0
  20. package/dist/scraper/target-resolution-diagnostic.js.map +1 -0
  21. package/dist/scripts/recon-browser.d.ts +32 -2
  22. package/dist/scripts/recon-browser.d.ts.map +1 -1
  23. package/dist/scripts/recon-browser.js +2 -0
  24. package/dist/scripts/recon-browser.js.map +1 -1
  25. package/dist/scripts/recon-generate.d.ts.map +1 -1
  26. package/dist/scripts/recon-generate.js +84 -27
  27. package/dist/scripts/recon-generate.js.map +1 -1
  28. package/package.json +1 -1
  29. package/dist/scraper/deep-query.d.ts +0 -44
  30. package/dist/scraper/deep-query.d.ts.map +0 -1
  31. package/dist/scraper/deep-query.js +0 -93
  32. package/dist/scraper/deep-query.js.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enricai/barnacle",
3
- "version": "1.12.70",
3
+ "version": "1.12.71",
4
4
  "description": "Barnacle turns any website into an API. POST a structured payload to a typed endpoint and Barnacle drives a browser session through the target site, returning a structured result.",
5
5
  "license": "MIT",
6
6
  "author": "Enricai",
@@ -1,44 +0,0 @@
1
- /**
2
- * Shadow-DOM-piercing element resolver. Every other primitive in
3
- * flow-runner.ts locates elements via `document.querySelectorAll` /
4
- * `document.evaluate`, which cannot see inside a shadow root — so a
5
- * submit-shaped control rendered by a web component (Angular Elements,
6
- * Stencil, etc.) is invisible to the engine even though it's live on the
7
- * page. This module composes a `page.evaluate` expression string (the
8
- * repo's established interpolation pattern — see `INVALID_MARKER_EL_EXPR`
9
- * in flow-runner.ts) that recurses through `el.shadowRoot` for OPEN roots
10
- * to find and click such a control. Closed roots are unreachable from page
11
- * script by design; the traversal treats them as a dead end rather than
12
- * throwing.
13
- */
14
- /**
15
- * Builds a self-contained `page.evaluate` expression string that locates
16
- * the first submit-shaped control anywhere in the document — piercing open
17
- * shadow roots — clicks it via the shared {@link clickActivationExpr} snippet
18
- * (a real `PointerEvent`/`MouseEvent` sequence plus native `click()`, not a
19
- * bare `new Event(...)` that a React/design-system handler would ignore; see
20
- * that module's docblock), and returns a structured result so the caller can
21
- * verify what happened without a second round-trip.
22
- *
23
- * Locate-only mode (`{ clickIfFound: false }`) is exposed for callers that
24
- * want to probe for a deep submit control before deciding whether to act
25
- * on it (e.g. to distinguish "no candidate anywhere" from "found but the
26
- * click cascade should try a different technique first").
27
- *
28
- * `options.root` overrides the traversal root expression (default
29
- * `"document"`). The string is interpolated verbatim into the generated
30
- * code, so a caller evaluating this expression via `Frame.evaluate` can
31
- * still pass `"document"` to root the walk in that frame's own document —
32
- * there is no captured outer `document` reference anywhere in this
33
- * expression, only the identifier resolved at evaluation time.
34
- */
35
- export declare function buildDeepSubmitClickExpr(options?: {
36
- clickIfFound?: boolean;
37
- root?: string;
38
- }): string;
39
- /** Structured result of {@link buildDeepSubmitClickExpr}'s `page.evaluate` call. */
40
- export interface DeepSubmitClickResult {
41
- found: boolean;
42
- clicked: boolean;
43
- }
44
- //# sourceMappingURL=deep-query.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"deep-query.d.ts","sourceRoot":"","sources":["../../src/scraper/deep-query.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AA8CH;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,CAAC,EAAE;IACjD,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,GAAG,MAAM,CAaT;AAED,oFAAoF;AACpF,MAAM,WAAW,qBAAqB;IACpC,KAAK,EAAE,OAAO,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;CAClB"}
@@ -1,93 +0,0 @@
1
- "use strict";
2
- /**
3
- * Shadow-DOM-piercing element resolver. Every other primitive in
4
- * flow-runner.ts locates elements via `document.querySelectorAll` /
5
- * `document.evaluate`, which cannot see inside a shadow root — so a
6
- * submit-shaped control rendered by a web component (Angular Elements,
7
- * Stencil, etc.) is invisible to the engine even though it's live on the
8
- * page. This module composes a `page.evaluate` expression string (the
9
- * repo's established interpolation pattern — see `INVALID_MARKER_EL_EXPR`
10
- * in flow-runner.ts) that recurses through `el.shadowRoot` for OPEN roots
11
- * to find and click such a control. Closed roots are unreachable from page
12
- * script by design; the traversal treats them as a dead end rather than
13
- * throwing.
14
- */
15
- Object.defineProperty(exports, "__esModule", { value: true });
16
- exports.buildDeepSubmitClickExpr = buildDeepSubmitClickExpr;
17
- const browser_click_expr_1 = require("./browser-click-expr");
18
- /**
19
- * Text/attribute predicate for "this element is submit-shaped": a native
20
- * `type="submit"` control, a `<button>` with no explicit `type` inside a
21
- * `<form>` (the HTML default is submit), or a button-role element whose
22
- * visible text/aria-label contains "submit". Kept as a standalone
23
- * expression (not a RegExp) so it can be interpolated into a browser-
24
- * context `page.evaluate` string, paralleling `INVALID_MARKER_EL_EXPR`.
25
- */
26
- const SUBMIT_SHAPED_EL_EXPR = `((el) => {
27
- const tag = (el.tagName || "").toLowerCase();
28
- const type = (el.getAttribute("type") || "").toLowerCase();
29
- if ((tag === "button" || tag === "input") && type === "submit") return true;
30
- if (tag === "button" && !el.getAttribute("type") && el.closest("form")) return true;
31
- const role = (el.getAttribute("role") || "").toLowerCase();
32
- const isButtonLike = tag === "button" || role === "button";
33
- if (!isButtonLike) return false;
34
- const norm = (s) => (s || "").replace(/\\s+/g, " ").trim().toLowerCase();
35
- const text = norm(el.getAttribute("aria-label") || el.textContent || "");
36
- return /\\bsubmit\\b/.test(text);
37
- })`;
38
- /**
39
- * Recursive open-shadow-root walker: returns every element in `root`
40
- * (light DOM or a shadow root) plus, for each child with an OPEN
41
- * `shadowRoot`, every element inside that shadow tree, arbitrarily deep.
42
- * A closed shadow root (`element.shadowRoot === null` from page script's
43
- * perspective) is simply not descended into — it contributes no elements,
44
- * it does not throw.
45
- */
46
- const DEEP_ELEMENTS_EXPR = `((root) => {
47
- const out = [];
48
- const walk = (node) => {
49
- const kids = node.querySelectorAll ? Array.from(node.querySelectorAll("*")) : [];
50
- for (const el of kids) {
51
- out.push(el);
52
- if (el.shadowRoot) walk(el.shadowRoot);
53
- }
54
- };
55
- walk(root);
56
- return out;
57
- })`;
58
- /**
59
- * Builds a self-contained `page.evaluate` expression string that locates
60
- * the first submit-shaped control anywhere in the document — piercing open
61
- * shadow roots — clicks it via the shared {@link clickActivationExpr} snippet
62
- * (a real `PointerEvent`/`MouseEvent` sequence plus native `click()`, not a
63
- * bare `new Event(...)` that a React/design-system handler would ignore; see
64
- * that module's docblock), and returns a structured result so the caller can
65
- * verify what happened without a second round-trip.
66
- *
67
- * Locate-only mode (`{ clickIfFound: false }`) is exposed for callers that
68
- * want to probe for a deep submit control before deciding whether to act
69
- * on it (e.g. to distinguish "no candidate anywhere" from "found but the
70
- * click cascade should try a different technique first").
71
- *
72
- * `options.root` overrides the traversal root expression (default
73
- * `"document"`). The string is interpolated verbatim into the generated
74
- * code, so a caller evaluating this expression via `Frame.evaluate` can
75
- * still pass `"document"` to root the walk in that frame's own document —
76
- * there is no captured outer `document` reference anywhere in this
77
- * expression, only the identifier resolved at evaluation time.
78
- */
79
- function buildDeepSubmitClickExpr(options) {
80
- const clickIfFound = options?.clickIfFound ?? true;
81
- const root = options?.root ?? "document";
82
- return `(() => {
83
- const isSubmitShaped = ${SUBMIT_SHAPED_EL_EXPR};
84
- const deepElements = ${DEEP_ELEMENTS_EXPR};
85
- const candidates = deepElements(${root}).filter(isSubmitShaped);
86
- if (candidates.length === 0) return { found: false, clicked: false };
87
- const el = candidates[0];
88
- if (!${JSON.stringify(clickIfFound)}) return { found: true, clicked: false };
89
- ${(0, browser_click_expr_1.clickActivationExpr)("el")}
90
- return { found: true, clicked: true };
91
- })()`;
92
- }
93
- //# sourceMappingURL=deep-query.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"deep-query.js","sourceRoot":"","sources":["../../src/scraper/deep-query.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;;;AAEH,qEAAmE;AAEnE;;;;;;;GAOG;AACH,MAAM,qBAAqB,GAAG;;;;;;;;;;;GAW3B,CAAC;AAEJ;;;;;;;GAOG;AACH,MAAM,kBAAkB,GAAG;;;;;;;;;;;GAWxB,CAAC;AAEJ;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,kCAAyC,OAGxC;IACC,MAAM,YAAY,GAAG,OAAO,EAAE,YAAY,IAAI,IAAI,CAAC;IACnD,MAAM,IAAI,GAAG,OAAO,EAAE,IAAI,IAAI,UAAU,CAAC;IACzC,OAAO;6BACoB,qBAAqB;2BACvB,kBAAkB;sCACP,IAAI;;;WAG/B,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC;MACjC,IAAA,wCAAmB,EAAC,IAAI,CAAC;;OAExB,CAAC;AACR,CAAC"}