@e2edev/web 0.11.0-canary-20260921180210

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 (101) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +5 -0
  3. package/README.md +112 -0
  4. package/dist/.build.json +1 -0
  5. package/dist/actions.d.ts +23 -0
  6. package/dist/actions.d.ts.map +1 -0
  7. package/dist/actions.js +174 -0
  8. package/dist/actions.js.map +1 -0
  9. package/dist/attempt-session.d.ts +76 -0
  10. package/dist/attempt-session.d.ts.map +1 -0
  11. package/dist/attempt-session.js +290 -0
  12. package/dist/attempt-session.js.map +1 -0
  13. package/dist/browser-connection.d.ts +34 -0
  14. package/dist/browser-connection.d.ts.map +1 -0
  15. package/dist/browser-connection.js +87 -0
  16. package/dist/browser-connection.js.map +1 -0
  17. package/dist/capture-scope.d.ts +21 -0
  18. package/dist/capture-scope.d.ts.map +1 -0
  19. package/dist/capture-scope.js +61 -0
  20. package/dist/capture-scope.js.map +1 -0
  21. package/dist/cdp-recovery.d.ts +29 -0
  22. package/dist/cdp-recovery.d.ts.map +1 -0
  23. package/dist/cdp-recovery.js +84 -0
  24. package/dist/cdp-recovery.js.map +1 -0
  25. package/dist/cdp-selectors.d.ts +14 -0
  26. package/dist/cdp-selectors.d.ts.map +1 -0
  27. package/dist/cdp-selectors.js +48 -0
  28. package/dist/cdp-selectors.js.map +1 -0
  29. package/dist/dialogs.d.ts +37 -0
  30. package/dist/dialogs.d.ts.map +1 -0
  31. package/dist/dialogs.js +78 -0
  32. package/dist/dialogs.js.map +1 -0
  33. package/dist/engine.d.ts +26 -0
  34. package/dist/engine.d.ts.map +1 -0
  35. package/dist/engine.js +166 -0
  36. package/dist/engine.js.map +1 -0
  37. package/dist/evaluation.d.ts +11 -0
  38. package/dist/evaluation.d.ts.map +1 -0
  39. package/dist/evaluation.js +27 -0
  40. package/dist/evaluation.js.map +1 -0
  41. package/dist/index.d.ts +21 -0
  42. package/dist/index.d.ts.map +1 -0
  43. package/dist/index.js +14 -0
  44. package/dist/index.js.map +1 -0
  45. package/dist/install.d.ts +40 -0
  46. package/dist/install.d.ts.map +1 -0
  47. package/dist/install.js +117 -0
  48. package/dist/install.js.map +1 -0
  49. package/dist/locators.d.ts +74 -0
  50. package/dist/locators.d.ts.map +1 -0
  51. package/dist/locators.js +260 -0
  52. package/dist/locators.js.map +1 -0
  53. package/dist/observation-capture.d.ts +12 -0
  54. package/dist/observation-capture.d.ts.map +1 -0
  55. package/dist/observation-capture.js +93 -0
  56. package/dist/observation-capture.js.map +1 -0
  57. package/dist/observation.d.ts +63 -0
  58. package/dist/observation.d.ts.map +1 -0
  59. package/dist/observation.js +262 -0
  60. package/dist/observation.js.map +1 -0
  61. package/dist/observe.d.ts +51 -0
  62. package/dist/observe.d.ts.map +1 -0
  63. package/dist/observe.js +104 -0
  64. package/dist/observe.js.map +1 -0
  65. package/dist/operation-budget.d.ts +11 -0
  66. package/dist/operation-budget.d.ts.map +1 -0
  67. package/dist/operation-budget.js +40 -0
  68. package/dist/operation-budget.js.map +1 -0
  69. package/dist/protected-app.d.ts +32 -0
  70. package/dist/protected-app.d.ts.map +1 -0
  71. package/dist/protected-app.js +39 -0
  72. package/dist/protected-app.js.map +1 -0
  73. package/dist/read-node.d.ts +170 -0
  74. package/dist/read-node.d.ts.map +1 -0
  75. package/dist/read-node.js +823 -0
  76. package/dist/read-node.js.map +1 -0
  77. package/dist/refs.d.ts +43 -0
  78. package/dist/refs.d.ts.map +1 -0
  79. package/dist/refs.js +85 -0
  80. package/dist/refs.js.map +1 -0
  81. package/dist/route-pattern.d.ts +15 -0
  82. package/dist/route-pattern.d.ts.map +1 -0
  83. package/dist/route-pattern.js +68 -0
  84. package/dist/route-pattern.js.map +1 -0
  85. package/dist/support.d.ts +119 -0
  86. package/dist/support.d.ts.map +1 -0
  87. package/dist/support.js +299 -0
  88. package/dist/support.js.map +1 -0
  89. package/dist/surface.d.ts +257 -0
  90. package/dist/surface.d.ts.map +1 -0
  91. package/dist/surface.js +587 -0
  92. package/dist/surface.js.map +1 -0
  93. package/dist/video.d.ts +59 -0
  94. package/dist/video.d.ts.map +1 -0
  95. package/dist/video.js +115 -0
  96. package/dist/video.js.map +1 -0
  97. package/dist/web.d.ts +191 -0
  98. package/dist/web.d.ts.map +1 -0
  99. package/dist/web.js +354 -0
  100. package/dist/web.js.map +1 -0
  101. package/package.json +67 -0
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Protected-preview access, scoped to the app's site: the configured headers
3
+ * ride only requests bound for the site, and basic-auth credentials answer
4
+ * a challenge wherever one is issued. The surface calls these on every
5
+ * context it creates; nothing here holds state.
6
+ */
7
+ import { sameSite } from 'e2e/engine';
8
+ /** Header names lowercased, as Playwright reports a request's own headers. */
9
+ export function lowercaseNames(headers) {
10
+ return Object.fromEntries(Object.entries(headers).map(([name, value]) => [name.toLowerCase(), value]));
11
+ }
12
+ /**
13
+ * Adds the configured headers to every request bound for the app's site,
14
+ * via a context route that falls back to the network. A request for any
15
+ * other site is not routed at all; without a site there is no policy and
16
+ * nothing is routed. Nothing awaits a route handler, so a fallback that
17
+ * fails (the page closed under the request) is dropped rather than left to
18
+ * surface as an unhandled rejection.
19
+ */
20
+ export async function installSiteHeaders(context, site, headers) {
21
+ if (headers === undefined || site === undefined)
22
+ return;
23
+ await context.route((url) => sameSite(url, site), async (route) => {
24
+ await route.fallback({ headers: { ...route.request().headers(), ...headers } }).catch(() => undefined);
25
+ });
26
+ }
27
+ /**
28
+ * The basic-auth credentials a context answers a challenge with, as
29
+ * Playwright's own `httpCredentials` does: on a 401 from any origin. A site
30
+ * cannot be enumerated into the exact origins Playwright scopes by, and a
31
+ * challenge is answered only where one is issued.
32
+ */
33
+ export function httpCredentials(basicAuth) {
34
+ if (basicAuth === undefined)
35
+ return undefined;
36
+ const { username, password } = basicAuth;
37
+ return { username, password };
38
+ }
39
+ //# sourceMappingURL=protected-app.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protected-app.js","sourceRoot":"","sources":["../src/protected-app.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAStC,8EAA8E;AAC9E,MAAM,UAAU,cAAc,CAAC,OAAyC;IACtE,OAAO,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;AACzG,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,OAAuB,EACvB,IAAwB,EACxB,OAAqD;IAErD,IAAI,OAAO,KAAK,SAAS,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO;IACxD,MAAM,OAAO,CAAC,KAAK,CACjB,CAAC,GAAG,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,EAC5B,KAAK,EAAE,KAAK,EAAE,EAAE;QACd,MAAM,KAAK,CAAC,QAAQ,CAAC,EAAE,OAAO,EAAE,EAAE,GAAG,KAAK,CAAC,OAAO,EAAE,CAAC,OAAO,EAAE,EAAE,GAAG,OAAO,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;IACzG,CAAC,CACF,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAC,SAAmC;IACjE,IAAI,SAAS,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC9C,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,SAAS,CAAC;IACzC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC;AAChC,CAAC"}
@@ -0,0 +1,170 @@
1
+ /**
2
+ * In-page semantic reader executed via locator.evaluate, locator.evaluateAll,
3
+ * and locator.evaluateHandle. Everything below the exported functions is
4
+ * serialized into the page, so it must stay self-contained: no imports, no
5
+ * module-scope references, every constant inside the function body.
6
+ */
7
+ /**
8
+ * The one definition of a secure field.
9
+ *
10
+ * It is a selector rather than a predicate because it has to be applied from
11
+ * two sides that cannot share code: the in-page reader matches elements
12
+ * against it to mark nodes `secure`, and the engine hands the same string to
13
+ * the screenshot masker. One string means the tree's redaction and the image's
14
+ * redaction cannot describe different sets of elements, which is what the
15
+ * runner's pixel-clearance check relies on.
16
+ */
17
+ export declare const SECURE_FIELD_SELECTOR = "input[type=\"password\" i]";
18
+ /**
19
+ * Where the init script below records closed shadow roots, keyed by host, and
20
+ * where the in-page reader looks for them. The reader is serialized into the
21
+ * page and cannot import this constant, so the literal is repeated inside it;
22
+ * the two must agree, like `SECURE_FIELD_SELECTOR` on both sides of masking.
23
+ */
24
+ export declare const CLOSED_SHADOW_ROOTS_KEY = "e2e.closedShadowRoots";
25
+ /**
26
+ * Context init script that keeps every closed shadow root reachable for the
27
+ * reader. A closed root hides its tree from `element.shadowRoot`, so a checkout
28
+ * button a third-party widget renders that way is on screen for a person yet
29
+ * absent from the walk. `attachShadow` is the one way a script creates such a
30
+ * root; wrapping it before any page script runs records host and root in a
31
+ * WeakMap under a well-known symbol, which the reader consults where it reads
32
+ * `shadowRoot`. The map is keyed by the host element and never enumerated, so
33
+ * it holds nothing alive and changes nothing the page can observe about the
34
+ * root itself. Declarative `<template shadowrootmode="closed">` roots are
35
+ * parsed rather than attached and stay out of reach.
36
+ */
37
+ export declare const CLOSED_SHADOW_ROOTS_INIT_SCRIPT: string;
38
+ /** Playwright selector engine name; `e2e-closed=<css>` matches inside recorded closed shadow roots. */
39
+ export declare const CLOSED_SHADOW_SELECTOR_ENGINE = "e2e-closed";
40
+ /**
41
+ * The engine behind `e2e-closed=<css>`: every element matching the CSS
42
+ * selector inside a closed shadow root the init script recorded, reached from
43
+ * the query root through light DOM and open roots, and through roots of either
44
+ * kind nested below a closed one. Playwright's own selectors stop at a closed
45
+ * root, so this is what lets a screenshot mask cover a secure field the reader
46
+ * now reports there. It runs in the page's main world (not as a content
47
+ * script) because that is where the record lives.
48
+ */
49
+ export declare const CLOSED_SHADOW_SELECTOR_ENGINE_SOURCE: string;
50
+ export interface RawNodeData {
51
+ role: string | null;
52
+ name: string | null;
53
+ /**
54
+ * Every label a person or a tool may call this control by: its `aria-label`,
55
+ * each `aria-labelledby` target, and each associated `<label>`, read as an
56
+ * accessible name (aria-hidden dropped). Null for a node with none. An exact
57
+ * label query matches any one of them, as Playwright's `getByLabel` does,
58
+ * rather than the combined or overridden `name`.
59
+ */
60
+ labels: string[] | null;
61
+ text: string | null;
62
+ value: string | null;
63
+ inputPurpose: 'username' | 'password' | 'one-time-code' | 'generic-secret' | 'none';
64
+ states: {
65
+ checked: boolean | null;
66
+ disabled: boolean;
67
+ selected: boolean | null;
68
+ expanded: boolean | null;
69
+ pressed: boolean | null;
70
+ focused: boolean;
71
+ hidden: boolean;
72
+ secure: boolean;
73
+ };
74
+ /** Heading level of a heading: `aria-level`, else the digit of `h1` through `h6`; null for anything else. */
75
+ level: number | null;
76
+ attributes: Record<string, string>;
77
+ /** Value of the project's test-id attribute, when the element carries one. */
78
+ testId: string | null;
79
+ rect: {
80
+ x: number;
81
+ y: number;
82
+ width: number;
83
+ height: number;
84
+ };
85
+ }
86
+ /** One observed node plus its position in the flattened depth-first tree. */
87
+ export interface RawObservedNode extends RawNodeData {
88
+ /** Index of the nearest included ancestor, or -1 for the root. */
89
+ parent: number;
90
+ /** Unique CSS selector of this `<iframe>` element; set only for iframes. */
91
+ frameSelector?: string;
92
+ }
93
+ /** One walked document. */
94
+ interface RawObservation {
95
+ nodes: RawObservedNode[];
96
+ /** True when the node budget stopped the walk before the document was read whole. */
97
+ truncated: boolean;
98
+ /** Live element handles positionally aligned with `nodes`. */
99
+ elements: Element[];
100
+ /**
101
+ * Node ids positionally aligned with `nodes`. An id is stamped on the element
102
+ * the first time an observation includes it and read back on every later
103
+ * one, so the same element keeps the same id for as long as it lives in the
104
+ * document: two looks at an unchanged screen name its nodes identically, and
105
+ * an update can list exactly what changed. A re-created element (a framework
106
+ * re-mount, a new document) is a new node and gets a fresh id.
107
+ */
108
+ ids: string[];
109
+ }
110
+ type SemanticMode = {
111
+ kind: 'node';
112
+ } | {
113
+ kind: 'tree';
114
+ maxNodes: number;
115
+ /**
116
+ * First numeric id available to nodes seen for the first time. The caller
117
+ * reserves maxNodes ids before execution, so an abandoned reader cannot
118
+ * collide with later captures or locator resolution.
119
+ */
120
+ idSeed: number;
121
+ /** Cuts each node's name at this length; the caller owns the contract value. */
122
+ nameLimit: number;
123
+ /** Cuts each node's text at this length; the caller owns the contract value. */
124
+ textLimit: number;
125
+ };
126
+ /** Options for a single-node read, shared by `evaluate` and `evaluateAll` callers. */
127
+ interface NodeReadOptions {
128
+ readonly testIdAttribute: string;
129
+ readonly secureFieldSelector: string;
130
+ readonly mode: {
131
+ readonly kind: 'node';
132
+ };
133
+ }
134
+ /** Options for one document's tree walk. */
135
+ interface TreeReadOptions {
136
+ readonly testIdAttribute: string;
137
+ readonly secureFieldSelector: string;
138
+ readonly mode: Extract<SemanticMode, {
139
+ kind: 'tree';
140
+ }>;
141
+ }
142
+ /**
143
+ * Walks a whole document from its root element in one in-page call. Built
144
+ * from the reader's source like the batch reader below, so the caller
145
+ * evaluates it directly on a page or frame instead of first resolving a
146
+ * `:root` locator - one fewer protocol round trip per document per capture.
147
+ */
148
+ export declare const readDocumentSemanticsFunction: (options: TreeReadOptions) => RawObservation;
149
+ /**
150
+ * Reads every matched element in one in-page round trip. A page function
151
+ * cannot close over module scope, so the batch function is assembled from the
152
+ * reader's own source (the same source `evaluate` sends) and is a
153
+ * self-contained function Playwright serializes and calls with the elements.
154
+ */
155
+ export declare const readManySemanticsFunction: (elements: Element[], options: NodeReadOptions) => RawNodeData[];
156
+ /**
157
+ * The batch reader for `page.evaluate`, which takes one argument: the element
158
+ * handles the caller already holds, so what is read and what is later acted
159
+ * on are the same elements by construction rather than by a second lookup.
160
+ */
161
+ /**
162
+ * Reads every handle in one round trip. Evaluated on the first handle so the read runs in the
163
+ * frame the handles belong to; `page.evaluate` would reject handles taken inside an iframe.
164
+ */
165
+ export declare const readHandlesSemanticsFunction: (first: Element, arg: {
166
+ elements: Element[];
167
+ options: NodeReadOptions;
168
+ }) => RawNodeData[];
169
+ export {};
170
+ //# sourceMappingURL=read-node.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read-node.d.ts","sourceRoot":"","sources":["../src/read-node.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;;;;;GASG;AACH,eAAO,MAAM,qBAAqB,+BAA6B,CAAC;AAEhE;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,0BAA0B,CAAC;AAE/D;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,+BAA+B,QAWtC,CAAC;AAEP,uGAAuG;AACvG,eAAO,MAAM,6BAA6B,eAAe,CAAC;AAE1D;;;;;;;;GAQG;AACH,eAAO,MAAM,oCAAoC,QAyB/C,CAAC;AAEH,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB;;;;;;OAMG;IACH,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IACxB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,YAAY,EAAE,UAAU,GAAG,UAAU,GAAG,eAAe,GAAG,gBAAgB,GAAG,MAAM,CAAC;IACpF,MAAM,EAAE;QACN,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;QACxB,QAAQ,EAAE,OAAO,CAAC;QAClB,QAAQ,EAAE,OAAO,GAAG,IAAI,CAAC;QACzB,QAAQ,EAAE,OAAO,GAAG,IAAI,CAAC;QACzB,OAAO,EAAE,OAAO,GAAG,IAA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