@parcha/pi-browser 0.1.0-beta.34 → 0.1.0-beta.340

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 (78) hide show
  1. package/CHANGELOG.md +170 -0
  2. package/NOTICE +6 -1
  3. package/README.md +70 -60
  4. package/dist/core/contract.d.ts +9 -6
  5. package/dist/core/contract.js +12 -30
  6. package/dist/core/custody.d.ts +6 -0
  7. package/dist/core/custody.js +15 -3
  8. package/dist/core/downloads.d.ts +37 -3
  9. package/dist/core/downloads.js +81 -57
  10. package/dist/core/driving-guard.d.ts +1 -1
  11. package/dist/core/driving-guard.js +1 -1
  12. package/dist/core/evidence.d.ts +1 -1
  13. package/dist/core/files.d.ts +20 -2
  14. package/dist/core/files.js +161 -10
  15. package/dist/core/host.d.ts +18 -75
  16. package/dist/core/images.d.ts +32 -4
  17. package/dist/core/images.js +81 -16
  18. package/dist/core/lease.d.ts +2 -1
  19. package/dist/core/page-scan.d.ts +81 -2
  20. package/dist/core/page-scan.js +487 -13
  21. package/dist/core/public-fetch.d.ts +70 -9
  22. package/dist/core/public-fetch.js +348 -51
  23. package/dist/core/read-page-worker.js +5 -4
  24. package/dist/core/read-page.d.ts +23 -8
  25. package/dist/core/read-page.js +64 -20
  26. package/dist/core/redact.d.ts +0 -2
  27. package/dist/core/redact.js +0 -32
  28. package/dist/core/session-control.d.ts +0 -2
  29. package/dist/core/session-control.js +0 -5
  30. package/dist/core/tools.d.ts +23 -1
  31. package/dist/core/tools.js +46 -4
  32. package/dist/core/usage.d.ts +4 -3
  33. package/dist/core/usage.js +5 -4
  34. package/dist/core/vault.d.ts +0 -10
  35. package/dist/core/vault.js +0 -13
  36. package/dist/core/web.d.ts +2 -111
  37. package/dist/core/web.js +0 -443
  38. package/dist/driver/cdp.js +3 -3
  39. package/dist/driver/page-driver.js +7 -3
  40. package/dist/driver/stagehand.d.ts +3 -1
  41. package/dist/driver/stagehand.js +4 -2
  42. package/dist/durable/store.d.ts +14 -3
  43. package/dist/durable/store.js +204 -51
  44. package/dist/durable.d.ts +32 -16
  45. package/dist/durable.js +68 -95
  46. package/dist/index.d.ts +3 -3
  47. package/dist/index.js +5 -3
  48. package/dist/live-view/index.d.ts +3 -1
  49. package/dist/live-view/index.js +4 -0
  50. package/dist/live-view/protocol.d.ts +1 -1
  51. package/dist/live-view/server.d.ts +30 -0
  52. package/dist/live-view/server.js +152 -25
  53. package/dist/providers/cdp.js +2 -2
  54. package/dist/providers/profiles.d.ts +1 -15
  55. package/dist/providers/profiles.js +1 -64
  56. package/dist/providers/shared.d.ts +1 -47
  57. package/dist/providers/shared.js +1 -82
  58. package/dist/providers/worker-extension.d.ts +14 -1
  59. package/dist/providers/worker-extension.js +69 -3
  60. package/dist/testing/backend.d.ts +6 -24
  61. package/dist/testing/backend.js +7 -30
  62. package/dist/vault-session.d.ts +4 -7
  63. package/dist/vault-session.js +26 -81
  64. package/dist/vendor/browser-use-pi/page.d.ts +3 -12
  65. package/dist/vendor/browser-use-pi/page.js +6 -19
  66. package/package.json +9 -22
  67. package/dist/core/sites.d.ts +0 -33
  68. package/dist/core/sites.js +0 -104
  69. package/dist/durable/web.d.ts +0 -47
  70. package/dist/durable/web.js +0 -41
  71. package/dist/providers/browserbase-net.d.ts +0 -12
  72. package/dist/providers/browserbase-net.js +0 -95
  73. package/dist/providers/browserbase.d.ts +0 -169
  74. package/dist/providers/browserbase.js +0 -319
  75. package/dist/providers/kernel.d.ts +0 -58
  76. package/dist/providers/kernel.js +0 -291
  77. /package/dist/{providers → core}/cdp-call.d.ts +0 -0
  78. /package/dist/{providers → core}/cdp-call.js +0 -0
@@ -1,6 +1,11 @@
1
1
  /** An entity decoder for a run of text or an attribute value: node-html-parser's in the worker, entities.ts's on the
2
2
  * event loop. */
3
3
  export type Decode = (text: string) => string;
4
+ /** A style element of a page: what its start tag holds between its name and its ">" (insideOf), and its text. */
5
+ export type Style = {
6
+ inside: string;
7
+ css: string;
8
+ };
4
9
  /** A page without its script, style, svg, noscript and template elements and its comments, in steps so a caller on the
5
10
  * event loop can yield between them (dropInert, all at once). One whose end is missing runs to the end of the page, as
6
11
  * a browser reads it; but an svg's start tag goes alone, since a browser lets the HTML that follows out of an unclosed
@@ -19,9 +24,72 @@ export declare class InertDrop {
19
24
  step(chars: number): boolean;
20
25
  /** The page as dropped so far (the whole of it once step has answered true). */
21
26
  result(): string;
27
+ /** The page's own style elements dropped so far, in page order: what each start tag holds (insideOf) and its text. */
28
+ styles(): readonly Style[];
22
29
  }
23
30
  /** `html` without its inert blocks, all at once (see InertDrop). */
24
31
  export declare function dropInert(html: string): string;
32
+ /**
33
+ * The classes common frameworks hide an element from everyone with, whatever the page's own style says (it is often an
34
+ * external stylesheet a page read never fetches): mfp-hide (Magnific Popup: a pop-up's content until it opens, as on
35
+ * Canada.ca's record pages), modal (Bootstrap: a modal until it opens), d-none (Bootstrap 4+), hidden (Tailwind, Bootstrap
36
+ * 3), hide (Bootstrap 2), invisible (Tailwind, Bootstrap: visibility), is-hidden (Bulma), u-hidden (SUIT utilities). The
37
+ * classes that hide text from the screen only (sr-only, visually-hidden, wb-inv, screen-reader-text) are not here: a
38
+ * screen reader reads them, and they are often a record's field labels and table captions, the words its values hang
39
+ * on. aria-hidden is read for the same reason the other way: it hides from a screen reader only, and is usually shown.
40
+ */
41
+ export declare const HIDING_CLASSES: ReadonlySet<string>;
42
+ /** The two properties that hide an element from everyone. */
43
+ type Showing = "display" | "visibility";
44
+ /** What a property comes to: "hide" (display none, visibility hidden or collapse), "show" (any other value that
45
+ * decides it), or "doubt" (a value that hands it elsewhere, or declarations whose winner is unclear). */
46
+ type Outcome = "hide" | "show" | "doubt";
47
+ /** A property's last declaration: its outcome, and whether it was !important. */
48
+ type Declared = {
49
+ outcome: Outcome;
50
+ important: boolean;
51
+ };
52
+ /** What a declaration list, a class or an element declares of each property it sets. */
53
+ export type Declarations = Partial<Record<Showing, Declared>>;
54
+ /** What a page's own live styles declare of each class, by its one-class rules in page order. */
55
+ export type PageHiding = ReadonlyMap<string, Declarations>;
56
+ /**
57
+ * What `styles` (a page's own live style elements, InertDrop's styles) declare of each class's display and visibility:
58
+ * a rule at the top level whose selector is that one class (`.x` in `.x, .y { … }`) declares for it, a later rule's
59
+ * declaration after an earlier one's (after); a class a selector names otherwise (`.open .x`, `.x:hover`, `div.x`) is in
60
+ * doubt for each property that rule sets, since when it applies is not known here. A rule inside an at-rule (`@media`)
61
+ * is passed, and a style element not for the screen (forScreen) counts for nothing. Its style text is read once, at
62
+ * most STYLE_READ_CHARS of it, each character a bounded number of times.
63
+ */
64
+ export declare function pageHidingOf(styles: readonly Style[]): PageHiding;
65
+ /**
66
+ * A page without the elements it hides from everyone (hides), in steps so a caller on the event loop can yield between
67
+ * them (dropHidden, all at once). Run on a page its inert blocks are dropped from (InertDrop), with what its own live
68
+ * styles declare (pageHidingOf). A hidden element goes from its start tag to the end tag that closes it, a same-name
69
+ * element inside it counted; one that no end tag closes hides nothing, since where it ends is not known without a full
70
+ * tree. A hidden element that holds no content (VOID) goes alone. Visibility is inherited and a descendant can set it
71
+ * back: an element hidden by visibility alone goes only if nothing inside it shows itself again (hides' `shows`), and is
72
+ * kept whole otherwise. Only a descendant that is shown counts: one display-hidden itself, or inside a display-hidden
73
+ * element within the visibility-hidden one, shows nothing. display:none is not undone by a descendant, so its element
74
+ * always goes. Linear: one pass pairs each start tag with its end tag (an open-tag stack per name), marking the
75
+ * innermost open visibility-hidden element when a shown start tag inside it shows itself, and handing the mark to the
76
+ * element around it (its `outer`) as each closes; each tag costs a bounded amount of work, however the page nests or
77
+ * fails to (an element closed out of order is kept, and its stack entry left to be popped when it reaches the top).
78
+ * Then the hidden ranges are cut, the outermost of each nest.
79
+ */
80
+ export declare class HiddenDrop {
81
+ #private;
82
+ readonly html: string;
83
+ readonly page: PageHiding;
84
+ readonly decode: Decode;
85
+ constructor(html: string, page: PageHiding, decode: Decode);
86
+ /** Pairs the tags found in the next `chars` characters or so; true once the whole page is read. */
87
+ step(chars: number): boolean;
88
+ /** The page without its hidden ranges (once step has answered true; the page as it is before that). */
89
+ result(): string;
90
+ }
91
+ /** `html` without the elements it hides from everyone, all at once (see HiddenDrop); `page` and `decode` as there. */
92
+ export declare function dropHidden(html: string, page: PageHiding, decode: Decode): string;
25
93
  /** `html` cut to at most `max` characters, after the last tag that ends before the cut, so no tag is left half; at
26
94
  * `max` itself when that tag ends more than 64 KiB before it (a page of one long text), or one before it when `max`
27
95
  * falls between the two halves of a character written as a surrogate pair, so no half of one is left. */
@@ -71,9 +139,17 @@ export declare class FrameScan {
71
139
  base: string | null;
72
140
  };
73
141
  }
142
+ /** The most links one page's read gives: a page's links past them are not resolved (`links_truncated`). */
143
+ export declare const READ_LINKS_MAX = 20000;
144
+ /** The most characters one page's links are resolved from: each href read, kept or not, costs its own length and its
145
+ * base's. A relative href resolves to its base and itself, so without a bound a long base and many short hrefs (a
146
+ * `<base href>` of 100,000 characters and 50,000 anchors, in under a million characters of HTML) resolve to billions
147
+ * of characters. The links held stay within a small multiple of it (percent-encoding grows a character to at most 9). */
148
+ export declare const READ_LINKS_MAX_CHARS = 4000000;
74
149
  /** One pass over a page's tags, in steps so a caller on the event loop can yield between them: its title (the first
75
150
  * title element's), the http(s) URLs its `a` elements link to (each resolved against the page's first `<base href>`,
76
- * or `url`, without its fragment, once, in page order) and, when asked for, its plain text: the text between its tags,
151
+ * or `url`, without its fragment, once, in page order, within READ_LINKS_MAX and READ_LINKS_MAX_CHARS, `linksCut` when
152
+ * they stopped the resolution) and, when asked for, its plain text: the text between its tags,
77
153
  * entities decoded and whitespace collapsed, a block's start and end a paragraph, a row's start or a `br` a line, and a
78
154
  * row's cells joined with " | ". A "<" that starts no tag is text (tagsOf); one with no ">" after it ends the page. */
79
155
  export declare class PageScan {
@@ -86,10 +162,13 @@ export declare class PageScan {
86
162
  get done(): boolean;
87
163
  /** Scans the tags that start in the next `chars` characters (a tag that starts in them is read whole). */
88
164
  step(chars: number): boolean;
89
- /** The title, the links and the plain text ("" when it was not asked for) of what was scanned. */
165
+ /** The title, the links and the plain text ("" when it was not asked for) of what was scanned; `linksCut` when
166
+ * READ_LINKS_MAX or READ_LINKS_MAX_CHARS stopped the links' resolution before the last href. */
90
167
  result(): {
91
168
  title: string;
92
169
  links: string[];
93
170
  text: string;
171
+ linksCut?: true;
94
172
  };
95
173
  }
174
+ export {};