@e2e-dev/web 0.11.0-canary-20260928184528

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 (121) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +5 -0
  3. package/README.md +138 -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 +77 -0
  10. package/dist/attempt-session.d.ts.map +1 -0
  11. package/dist/attempt-session.js +293 -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 +86 -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 +15 -0
  26. package/dist/cdp-selectors.d.ts.map +1 -0
  27. package/dist/cdp-selectors.js +52 -0
  28. package/dist/cdp-selectors.js.map +1 -0
  29. package/dist/closed-shadow.d.ts +64 -0
  30. package/dist/closed-shadow.d.ts.map +1 -0
  31. package/dist/closed-shadow.js +142 -0
  32. package/dist/closed-shadow.js.map +1 -0
  33. package/dist/dialogs.d.ts +38 -0
  34. package/dist/dialogs.d.ts.map +1 -0
  35. package/dist/dialogs.js +87 -0
  36. package/dist/dialogs.js.map +1 -0
  37. package/dist/engine.d.ts +26 -0
  38. package/dist/engine.d.ts.map +1 -0
  39. package/dist/engine.js +176 -0
  40. package/dist/engine.js.map +1 -0
  41. package/dist/evaluation.d.ts +18 -0
  42. package/dist/evaluation.d.ts.map +1 -0
  43. package/dist/evaluation.js +35 -0
  44. package/dist/evaluation.js.map +1 -0
  45. package/dist/in-page/read-semantics.d.ts +28 -0
  46. package/dist/in-page/read-semantics.d.ts.map +1 -0
  47. package/dist/in-page/read-semantics.js +1178 -0
  48. package/dist/in-page/read-semantics.js.map +1 -0
  49. package/dist/index.d.ts +22 -0
  50. package/dist/index.d.ts.map +1 -0
  51. package/dist/index.js +14 -0
  52. package/dist/index.js.map +1 -0
  53. package/dist/install.d.ts +40 -0
  54. package/dist/install.d.ts.map +1 -0
  55. package/dist/install.js +117 -0
  56. package/dist/install.js.map +1 -0
  57. package/dist/label-selector.d.ts +37 -0
  58. package/dist/label-selector.d.ts.map +1 -0
  59. package/dist/label-selector.js +53 -0
  60. package/dist/label-selector.js.map +1 -0
  61. package/dist/locators.d.ts +76 -0
  62. package/dist/locators.d.ts.map +1 -0
  63. package/dist/locators.js +289 -0
  64. package/dist/locators.js.map +1 -0
  65. package/dist/observation-capture.d.ts +12 -0
  66. package/dist/observation-capture.d.ts.map +1 -0
  67. package/dist/observation-capture.js +93 -0
  68. package/dist/observation-capture.js.map +1 -0
  69. package/dist/observation.d.ts +63 -0
  70. package/dist/observation.d.ts.map +1 -0
  71. package/dist/observation.js +280 -0
  72. package/dist/observation.js.map +1 -0
  73. package/dist/observe.d.ts +51 -0
  74. package/dist/observe.d.ts.map +1 -0
  75. package/dist/observe.js +105 -0
  76. package/dist/observe.js.map +1 -0
  77. package/dist/operation-budget.d.ts +11 -0
  78. package/dist/operation-budget.d.ts.map +1 -0
  79. package/dist/operation-budget.js +40 -0
  80. package/dist/operation-budget.js.map +1 -0
  81. package/dist/protected-app.d.ts +32 -0
  82. package/dist/protected-app.d.ts.map +1 -0
  83. package/dist/protected-app.js +39 -0
  84. package/dist/protected-app.js.map +1 -0
  85. package/dist/provider.d.ts +158 -0
  86. package/dist/provider.d.ts.map +1 -0
  87. package/dist/provider.js +311 -0
  88. package/dist/provider.js.map +1 -0
  89. package/dist/read-node.d.ts +152 -0
  90. package/dist/read-node.d.ts.map +1 -0
  91. package/dist/read-node.js +42 -0
  92. package/dist/read-node.js.map +1 -0
  93. package/dist/refs.d.ts +43 -0
  94. package/dist/refs.d.ts.map +1 -0
  95. package/dist/refs.js +85 -0
  96. package/dist/refs.js.map +1 -0
  97. package/dist/route-pattern.d.ts +13 -0
  98. package/dist/route-pattern.d.ts.map +1 -0
  99. package/dist/route-pattern.js +55 -0
  100. package/dist/route-pattern.js.map +1 -0
  101. package/dist/selector-engines.d.ts +6 -0
  102. package/dist/selector-engines.d.ts.map +1 -0
  103. package/dist/selector-engines.js +8 -0
  104. package/dist/selector-engines.js.map +1 -0
  105. package/dist/support.d.ts +147 -0
  106. package/dist/support.d.ts.map +1 -0
  107. package/dist/support.js +366 -0
  108. package/dist/support.js.map +1 -0
  109. package/dist/surface.d.ts +313 -0
  110. package/dist/surface.d.ts.map +1 -0
  111. package/dist/surface.js +691 -0
  112. package/dist/surface.js.map +1 -0
  113. package/dist/video.d.ts +59 -0
  114. package/dist/video.d.ts.map +1 -0
  115. package/dist/video.js +116 -0
  116. package/dist/video.js.map +1 -0
  117. package/dist/web.d.ts +191 -0
  118. package/dist/web.d.ts.map +1 -0
  119. package/dist/web.js +382 -0
  120. package/dist/web.js.map +1 -0
  121. package/package.json +67 -0
@@ -0,0 +1,42 @@
1
+ /**
2
+ * The wire types of the in-page semantic reader and the page functions
3
+ * assembled from its source for locator.evaluate, locator.evaluateAll, and
4
+ * page.evaluate. The reader itself lives in `in-page/read-semantics.ts`; it is
5
+ * serialized into the page, so every page function here is built from its
6
+ * source with `new Function` and stays free of module-scope captures.
7
+ */
8
+ import { readSemanticsFunction } from './in-page/read-semantics.js';
9
+ /**
10
+ * The one definition of a secure field.
11
+ *
12
+ * It is a selector rather than a predicate because it has to be applied from
13
+ * two sides that cannot share code: the in-page reader matches elements
14
+ * against it to mark nodes `secure`, and the engine hands the same string to
15
+ * the screenshot masker. One string means the tree's redaction and the image's
16
+ * redaction cannot describe different sets of elements, which is what the
17
+ * runner's pixel-clearance check relies on.
18
+ */
19
+ export const SECURE_FIELD_SELECTOR = 'input[type="password" i]';
20
+ /**
21
+ * Walks a whole document from its root element in one in-page call. Built
22
+ * from the reader's source like the batch reader below, so the caller
23
+ * evaluates it directly on a page or frame instead of first resolving a
24
+ * `:root` locator - one fewer protocol round trip per document per capture.
25
+ */
26
+ export const readDocumentSemanticsFunction = new Function('options', `return (${readSemanticsFunction.toString()})(document.documentElement, options);`);
27
+ /**
28
+ * Reads every matched element in one in-page round trip. A page function
29
+ * cannot close over module scope, so the batch function is assembled from the
30
+ * reader's own source (the same source `evaluate` sends) and is a
31
+ * self-contained function Playwright serializes and calls with the elements.
32
+ */
33
+ export const readManySemanticsFunction = new Function('elements', 'options', `return elements.map((element) => (${readSemanticsFunction.toString()})(element, options));`);
34
+ /**
35
+ * Reads every handle the caller already holds in one round trip, so what is
36
+ * read and what is later acted on are the same elements by construction rather
37
+ * than by a second lookup. Evaluated on the first handle so the read runs in
38
+ * the frame the handles belong to; `page.evaluate` would reject handles taken
39
+ * inside an iframe.
40
+ */
41
+ export const readHandlesSemanticsFunction = new Function('_first', 'arg', `return arg.elements.map((element) => (${readSemanticsFunction.toString()})(element, arg.options));`);
42
+ //# sourceMappingURL=read-node.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read-node.js","sourceRoot":"","sources":["../src/read-node.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAEpE;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,0BAA0B,CAAC;AA4GhE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG,IAAI,QAAQ,CACvD,SAAS,EACT,WAAW,qBAAqB,CAAC,QAAQ,EAAE,uCAAuC,CACnC,CAAC;AAElD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,IAAI,QAAQ,CACnD,UAAU,EACV,SAAS,EACT,qCAAqC,qBAAqB,CAAC,QAAQ,EAAE,uBAAuB,CACJ,CAAC;AAE3F;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,IAAI,QAAQ,CACtD,QAAQ,EACR,KAAK,EACL,yCAAyC,qBAAqB,CAAC,QAAQ,EAAE,2BAA2B,CACa,CAAC"}
package/dist/refs.d.ts ADDED
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Node reference registry for one attempt: the ids the engine mints for
3
+ * located and observed nodes and the Playwright targets behind them.
4
+ *
5
+ * Two populations with different lifetimes live here. Locator-backed refs
6
+ * from `locate` hold no live handles and are pruned oldest-first past a
7
+ * bound. Handle-backed refs from `observe` form one generation per
8
+ * observation: the whole generation is swapped atomically and the superseded
9
+ * one disposed in a sweep, so locator-ref eviction can never destroy a handle
10
+ * an in-flight observation still references.
11
+ */
12
+ import { type EngineSnapshot, type NodeRef } from 'e2e/engine';
13
+ import type { ActionTarget } from './support.ts';
14
+ /** A complete observation and the private handles that back its semantic refs. */
15
+ export interface CapturedObservation {
16
+ readonly snapshot: EngineSnapshot;
17
+ readonly generation: Map<string, ActionTarget>;
18
+ }
19
+ export declare class RefRegistry {
20
+ private counter;
21
+ private capture;
22
+ private readonly located;
23
+ private observation;
24
+ mintId(): string;
25
+ /** Reserves ids before a document can stamp them, even if its response never arrives. */
26
+ reserveIds(count: number): number;
27
+ /** Stores one located target under a fresh id, pruning the oldest past the bound. */
28
+ storeLocated(target: ActionTarget): string;
29
+ /**
30
+ * Ids are the engine's; revisions are the harness's. The adapter already
31
+ * rejected a ref from a superseded resolution, so lookup is by id alone.
32
+ */
33
+ lookup(ref: NodeRef): ActionTarget;
34
+ /** Starts a capture, preventing older in-flight observations from publishing afterward. */
35
+ beginCapture(): number;
36
+ /** Publishes only the current capture; pixel-only recovery also retires located refs. */
37
+ publish(capture: number, { snapshot, generation }: CapturedObservation): void;
38
+ /** Releases every ref of the attempt: located and observed alike. */
39
+ clear(): void;
40
+ /** Disposes every element handle in one observation generation. */
41
+ static dispose(generation: ReadonlyMap<string, ActionTarget>): void;
42
+ }
43
+ //# sourceMappingURL=refs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"refs.d.ts","sourceRoot":"","sources":["../src/refs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAe,KAAK,cAAc,EAAE,KAAK,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAKjD,kFAAkF;AAClF,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC;IAClC,QAAQ,CAAC,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;CAChD;AAED,qBAAa,WAAW;IACtB,OAAO,CAAC,OAAO,CAAK;IACpB,OAAO,CAAC,OAAO,CAAK;IACpB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAmC;IAC3D,OAAO,CAAC,WAAW,CAAmC;IAEtD,MAAM,IAAI,MAAM,CAGf;IAED,yFAAyF;IACzF,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAIhC;IAED,qFAAqF;IACrF,YAAY,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CASzC;IAED;;;OAGG;IACH,MAAM,CAAC,GAAG,EAAE,OAAO,GAAG,YAAY,CAMjC;IAED,2FAA2F;IAC3F,YAAY,IAAI,MAAM,CAGrB;IAED,yFAAyF;IACzF,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,mBAAmB,GAAG,IAAI,CAO5E;IAED,qEAAqE;IACrE,KAAK,IAAI,IAAI,CAMZ;IAED,mEAAmE;IACnE,MAAM,CAAC,OAAO,CAAC,UAAU,EAAE,WAAW,CAAC,MAAM,EAAE,YAAY,CAAC,GAAG,IAAI,CAIlE;CACF"}
package/dist/refs.js ADDED
@@ -0,0 +1,85 @@
1
+ /**
2
+ * Node reference registry for one attempt: the ids the engine mints for
3
+ * located and observed nodes and the Playwright targets behind them.
4
+ *
5
+ * Two populations with different lifetimes live here. Locator-backed refs
6
+ * from `locate` hold no live handles and are pruned oldest-first past a
7
+ * bound. Handle-backed refs from `observe` form one generation per
8
+ * observation: the whole generation is swapped atomically and the superseded
9
+ * one disposed in a sweep, so locator-ref eviction can never destroy a handle
10
+ * an in-flight observation still references.
11
+ */
12
+ import { EngineError } from 'e2e/engine';
13
+ /** Located refs are pruned oldest-first past this bound so the map cannot grow unboundedly. */
14
+ const MAX_STORED_REFS = 2048;
15
+ export class RefRegistry {
16
+ counter = 0;
17
+ capture = 0;
18
+ located = new Map();
19
+ observation = new Map();
20
+ mintId() {
21
+ this.counter += 1;
22
+ return `n${this.counter}`;
23
+ }
24
+ /** Reserves ids before a document can stamp them, even if its response never arrives. */
25
+ reserveIds(count) {
26
+ const first = this.counter + 1;
27
+ this.counter += count;
28
+ return first;
29
+ }
30
+ /** Stores one located target under a fresh id, pruning the oldest past the bound. */
31
+ storeLocated(target) {
32
+ const id = this.mintId();
33
+ this.located.set(id, target);
34
+ for (const [oldest, evicted] of this.located) {
35
+ if (this.located.size <= MAX_STORED_REFS)
36
+ break;
37
+ this.located.delete(oldest);
38
+ if (evicted.kind === 'element')
39
+ void evicted.element.dispose().catch(() => undefined);
40
+ }
41
+ return id;
42
+ }
43
+ /**
44
+ * Ids are the engine's; revisions are the harness's. The adapter already
45
+ * rejected a ref from a superseded resolution, so lookup is by id alone.
46
+ */
47
+ lookup(ref) {
48
+ const target = this.located.get(ref.id) ?? this.observation.get(ref.id);
49
+ if (target === undefined) {
50
+ throw new EngineError('NODE_STALE', `node reference ${ref.id} is stale`, { retryable: true });
51
+ }
52
+ return target;
53
+ }
54
+ /** Starts a capture, preventing older in-flight observations from publishing afterward. */
55
+ beginCapture() {
56
+ this.capture += 1;
57
+ return this.capture;
58
+ }
59
+ /** Publishes only the current capture; pixel-only recovery also retires located refs. */
60
+ publish(capture, { snapshot, generation }) {
61
+ if (capture !== this.capture) {
62
+ throw new EngineError('NODE_STALE', 'observation capture was superseded', { retryable: true });
63
+ }
64
+ if (snapshot.treeUnavailable === true)
65
+ this.clear();
66
+ RefRegistry.dispose(this.observation);
67
+ this.observation = generation;
68
+ }
69
+ /** Releases every ref of the attempt: located and observed alike. */
70
+ clear() {
71
+ this.capture += 1;
72
+ RefRegistry.dispose(this.observation);
73
+ this.observation = new Map();
74
+ RefRegistry.dispose(this.located);
75
+ this.located.clear();
76
+ }
77
+ /** Disposes every element handle in one observation generation. */
78
+ static dispose(generation) {
79
+ for (const target of generation.values()) {
80
+ if (target.kind === 'element')
81
+ void target.element.dispose().catch(() => undefined);
82
+ }
83
+ }
84
+ }
85
+ //# sourceMappingURL=refs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"refs.js","sourceRoot":"","sources":["../src/refs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,WAAW,EAAqC,MAAM,YAAY,CAAC;AAG5E,+FAA+F;AAC/F,MAAM,eAAe,GAAG,IAAI,CAAC;AAQ7B,MAAM,OAAO,WAAW;IACd,OAAO,GAAG,CAAC,CAAC;IACZ,OAAO,GAAG,CAAC,CAAC;IACH,OAAO,GAAG,IAAI,GAAG,EAAwB,CAAC;IACnD,WAAW,GAAG,IAAI,GAAG,EAAwB,CAAC;IAEtD,MAAM;QACJ,IAAI,CAAC,OAAO,IAAI,CAAC,CAAC;QAClB,OAAO,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;IAC5B,CAAC;IAED,yFAAyF;IACzF,UAAU,CAAC,KAAa;QACtB,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC;QAC/B,IAAI,CAAC,OAAO,IAAI,KAAK,CAAC;QACtB,OAAO,KAAK,CAAC;IACf,CAAC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MAAM,IAAI,WAAW,CAAC,YAAY,EAAE,oCAAoC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACjG,CAAC;QACD,IAAI,QAAQ,CAAC,eAAe,KAAK,IAAI;YAAE,IAAI,CAAC,KAAK,EAAE,CAAC;QACpD,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACtC,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;IAChC,CAAC;IAED,qEAAqE;IACrE,KAAK;QACH,IAAI,CAAC,OAAO,IAAI,CAAC,CAAC;QAClB,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACtC,IAAI,CAAC,WAAW,GAAG,IAAI,GAAG,EAAE,CAAC;QAC7B,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAClC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;IACvB,CAAC;IAED,mEAAmE;IACnE,MAAM,CAAC,OAAO,CAAC,UAA6C;QAC1D,KAAK,MAAM,MAAM,IAAI,UAAU,CAAC,MAAM,EAAE,EAAE,CAAC;YACzC,IAAI,MAAM,CAAC,IAAI,KAAK,SAAS;gBAAE,KAAK,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QACtF,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,13 @@
1
+ /** Route URL pattern grammar. */
2
+ import type { TextPattern } from 'e2e/engine';
3
+ /**
4
+ * Compiles a string route pattern: `*` matches within one path segment, `**`
5
+ * crosses `/`, `?` matches one character, `\` escapes the next character;
6
+ * everything else is literal. Matches against the complete URL.
7
+ */
8
+ export declare function compileRoutePattern(pattern: string): RegExp;
9
+ /** Matches a URL against a wire TextPattern (string grammar or ECMAScript regexp). */
10
+ export declare function routePatternMatches(pattern: TextPattern, url: string): boolean;
11
+ /** Structural equality for route patterns, used by unroute. */
12
+ export declare function routePatternsEqual(a: TextPattern, b: TextPattern): boolean;
13
+ //# sourceMappingURL=route-pattern.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"route-pattern.d.ts","sourceRoot":"","sources":["../src/route-pattern.ts"],"names":[],"mappings":"AAAA,iCAAiC;AAEjC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAO9C;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CA0B3D;AAED,sFAAsF;AACtF,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAK9E;AAED,+DAA+D;AAC/D,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,WAAW,GAAG,OAAO,CAI1E"}
@@ -0,0 +1,55 @@
1
+ /** Route URL pattern grammar. */
2
+ /** Escapes one character for literal use inside a regexp source. */
3
+ function escapeRegexpChar(ch) {
4
+ return /[a-zA-Z0-9_-]/.test(ch) ? ch : `\\${ch}`;
5
+ }
6
+ /**
7
+ * Compiles a string route pattern: `*` matches within one path segment, `**`
8
+ * crosses `/`, `?` matches one character, `\` escapes the next character;
9
+ * everything else is literal. Matches against the complete URL.
10
+ */
11
+ export function compileRoutePattern(pattern) {
12
+ let source = '^';
13
+ for (let i = 0; i < pattern.length; i += 1) {
14
+ const ch = pattern[i];
15
+ if (ch === '\\') {
16
+ i += 1;
17
+ const next = pattern[i];
18
+ if (next !== undefined)
19
+ source += escapeRegexpChar(next);
20
+ continue;
21
+ }
22
+ if (ch === '*') {
23
+ if (pattern[i + 1] === '*') {
24
+ i += 1;
25
+ source += '.*';
26
+ }
27
+ else {
28
+ source += '[^/]*';
29
+ }
30
+ continue;
31
+ }
32
+ if (ch === '?') {
33
+ source += '.';
34
+ continue;
35
+ }
36
+ source += escapeRegexpChar(ch);
37
+ }
38
+ return new RegExp(`${source}$`);
39
+ }
40
+ /** Matches a URL against a wire TextPattern (string grammar or ECMAScript regexp). */
41
+ export function routePatternMatches(pattern, url) {
42
+ if (pattern.kind === 'string') {
43
+ return compileRoutePattern(pattern.value).test(url);
44
+ }
45
+ return new RegExp(pattern.source, pattern.flags).test(url);
46
+ }
47
+ /** Structural equality for route patterns, used by unroute. */
48
+ export function routePatternsEqual(a, b) {
49
+ if (a.kind === 'string' && b.kind === 'string')
50
+ return a.value === b.value;
51
+ if (a.kind === 'regexp' && b.kind === 'regexp')
52
+ return a.source === b.source && a.flags === b.flags;
53
+ return false;
54
+ }
55
+ //# sourceMappingURL=route-pattern.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"route-pattern.js","sourceRoot":"","sources":["../src/route-pattern.ts"],"names":[],"mappings":"AAAA,iCAAiC;AAIjC,oEAAoE;AACpE,SAAS,gBAAgB,CAAC,EAAU;IAClC,OAAO,eAAe,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC;AACnD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAAe;IACjD,IAAI,MAAM,GAAG,GAAG,CAAC;IACjB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;QAC3C,MAAM,EAAE,GAAG,OAAO,CAAC,CAAC,CAAE,CAAC;QACvB,IAAI,EAAE,KAAK,IAAI,EAAE,CAAC;YAChB,CAAC,IAAI,CAAC,CAAC;YACP,MAAM,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;YACxB,IAAI,IAAI,KAAK,SAAS;gBAAE,MAAM,IAAI,gBAAgB,CAAC,IAAI,CAAC,CAAC;YACzD,SAAS;QACX,CAAC;QACD,IAAI,EAAE,KAAK,GAAG,EAAE,CAAC;YACf,IAAI,OAAO,CAAC,CAAC,GAAG,CAAC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launched browser and in a CDP context alike. */
2
+ export declare const SELECTOR_ENGINES: readonly {
3
+ readonly name: string;
4
+ readonly source: string;
5
+ }[];
6
+ //# sourceMappingURL=selector-engines.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"selector-engines.d.ts","sourceRoot":"","sources":["../src/selector-engines.ts"],"names":[],"mappings":"AAAA,wGAAwG;AAKxG,eAAO,MAAM,gBAAgB,EAAE,SAAS;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,EAGzF,CAAC"}
@@ -0,0 +1,8 @@
1
+ /** Every selector engine the web engine registers, in a launched browser and in a CDP context alike. */
2
+ import { CLOSED_SHADOW_SELECTOR_ENGINES } from './closed-shadow.js';
3
+ import { EXACT_LABEL_SELECTOR_ENGINE, EXACT_LABEL_SELECTOR_ENGINE_SOURCE } from './label-selector.js';
4
+ export const SELECTOR_ENGINES = [
5
+ ...CLOSED_SHADOW_SELECTOR_ENGINES,
6
+ { name: EXACT_LABEL_SELECTOR_ENGINE, source: EXACT_LABEL_SELECTOR_ENGINE_SOURCE },
7
+ ];
8
+ //# sourceMappingURL=selector-engines.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"selector-engines.js","sourceRoot":"","sources":["../src/selector-engines.ts"],"names":[],"mappings":"AAAA,wGAAwG;AAExG,OAAO,EAAE,8BAA8B,EAAE,MAAM,oBAAoB,CAAC;AACpE,OAAO,EAAE,2BAA2B,EAAE,kCAAkC,EAAE,MAAM,qBAAqB,CAAC;AAEtG,MAAM,CAAC,MAAM,gBAAgB,GAAkE;IAC7F,GAAG,8BAA8B;IACjC,EAAE,IAAI,EAAE,2BAA2B,EAAE,MAAM,EAAE,kCAAkC,EAAE;CAClF,CAAC"}
@@ -0,0 +1,147 @@
1
+ /** Shared error translation, filename, and swipe helpers for the Playwright engine. */
2
+ import type { ElementHandle, Locator as PwLocator, Mouse, Page } from 'playwright';
3
+ import { EngineError, type EngineCleanupContext, type Momentum, type ScrollDirection, type ViewportPoint, type ViewportSize } from 'e2e/engine';
4
+ export declare const DEFAULT_VIEWPORT: {
5
+ readonly width: 1280;
6
+ readonly height: 720;
7
+ };
8
+ /**
9
+ * The page's viewport in CSS pixels: the emulated size when one is set, else
10
+ * the window's, measured in the page, since `viewport: null` follows the
11
+ * window and Playwright then reports no size of its own.
12
+ */
13
+ export declare function currentViewport(page: Page): Promise<ViewportSize>;
14
+ /**
15
+ * A resolved node is addressed either by a deterministic locator expression or
16
+ * by a live element handle captured during one agent observation. Handles are
17
+ * always elements: the in-page observation walk records `Element` nodes only.
18
+ */
19
+ export type ActionTarget = {
20
+ readonly kind: 'locator';
21
+ readonly locator: PwLocator;
22
+ } | {
23
+ readonly kind: 'element';
24
+ readonly element: ElementHandle<Element>;
25
+ };
26
+ /**
27
+ * Action surface Locator and ElementHandle share with identical signatures.
28
+ * Operations whose behavior diverges between the two kinds (bounding box,
29
+ * evaluate, page ownership, drag) have explicit helpers below so every fork is
30
+ * visible at its call site instead of hidden behind a uniform interface.
31
+ */
32
+ type Actionable = Pick<PwLocator, 'click' | 'dblclick' | 'fill' | 'press' | 'check' | 'uncheck' | 'hover' | 'scrollIntoViewIfNeeded' | 'selectOption' | 'setInputFiles'>;
33
+ /** Narrows one action target to the shared Playwright action surface. */
34
+ export declare function asActionable(target: ActionTarget): Actionable;
35
+ /**
36
+ * Drags one target onto another with the pointer.
37
+ *
38
+ * `Locator.dragTo` exists but takes a locator on both sides, and a node the
39
+ * agent reached through its observed reference is an element handle — which used
40
+ * to make the whole verb unavailable for exactly the elements that have no
41
+ * locator: an unlabelled thumbnail, an empty drop zone. Driving the pointer
42
+ * works for both kinds because a handle has a bounding box like anything else.
43
+ *
44
+ */
45
+ export declare function performPointerDrag(source: ActionTarget, destination: ActionTarget, timeout: number): Promise<void>;
46
+ /** A failure's message with terminal control sequences removed. */
47
+ export declare function message(cause: unknown): string;
48
+ /** Constrains a caller-supplied artifact label to a safe filename. */
49
+ export declare function sanitizeFilename(name: string): string;
50
+ export declare function isPwTimeout(cause: unknown): boolean;
51
+ export declare function invalidState(text: string): EngineError;
52
+ export declare function cancelled(text: string): EngineError;
53
+ /**
54
+ * Holds one error raised on a path nobody awaits - a native dialog nobody
55
+ * handled, a route handler that broke its contract - until the next step
56
+ * enters the surface, which then fails with the real cause, or until the
57
+ * attempt settles when no step follows. Rethrows once: the failure belongs
58
+ * to the step that observes it, not to every later one.
59
+ */
60
+ export declare class ErrorLatch {
61
+ private pending;
62
+ private readonly running;
63
+ private abandoned;
64
+ /** Latches an error; the first one wins until it is thrown. Dropped once `settle` gave up on a handler. */
65
+ latch(error: Error): void;
66
+ /** Tracks one unawaited `kind` of path (a route or dialog handler) until it settles, so `settle` can wait for it. Its own rejection is the caller's to latch. */
67
+ track(kind: string, work: Promise<void>): void;
68
+ /**
69
+ * Rethrows the latched error once; with none latched yet, first waits,
70
+ * within the budget, for the tracked paths running when it was called. One
71
+ * of those that outlives the budget fails closed: `CLEANUP_TIMEOUT` naming
72
+ * it, and whatever it throws afterwards is dropped here on purpose rather
73
+ * than landing on a verdict already reached. A path that starts during the
74
+ * wait is left to the next settle.
75
+ */
76
+ settle(budget: EngineCleanupContext): Promise<void>;
77
+ /** Rethrows the latched error once, if any. */
78
+ throwPending(): void;
79
+ }
80
+ /**
81
+ * True for an error that already carries its classification: an `EngineError`
82
+ * or a runner error (policy, validation, timeout) from any module copy. Those
83
+ * must cross the boundary untouched; re-wrapping one would turn a
84
+ * `POLICY_DENIED` into an infrastructure failure.
85
+ */
86
+ export declare function isClassified(cause: unknown): cause is Error;
87
+ /**
88
+ * True for a `TestError` carrying `code`, from this module copy or another.
89
+ * A matcher that reads a node it may be early for asks this before deciding
90
+ * whether the miss is one more poll or the assertion's failure.
91
+ */
92
+ export declare function isTestErrorCode(cause: unknown, code: string): cause is Error & {
93
+ readonly code: string;
94
+ };
95
+ /**
96
+ * How a Playwright failure maps onto the error contract. Every translator in
97
+ * this package and in `actions.ts` follows this table:
98
+ *
99
+ * | Playwright failure | Code |
100
+ * | --------------------------------------------------------------- | ------------------------- |
101
+ * | already an EngineError / runner error | passed through untouched |
102
+ * | `TimeoutError` on a read, navigation, or artifact call | OPERATION_TIMEOUT |
103
+ * | `TimeoutError` on an action, log ends before the input dispatch | NOT_ACTIONABLE |
104
+ * | `TimeoutError` on an action, log shows the dispatch started | ACTION_MAY_HAVE_COMMITTED |
105
+ * | element detached / not attached / no element / resolved hidden | NODE_STALE (retryable) |
106
+ * | execution context destroyed / frame detached by a navigation | NODE_STALE (retryable) |
107
+ * | not an input / not editable / not checkable | NOT_ACTIONABLE |
108
+ * | strict mode violation, anything else | ENGINE_FAILURE |
109
+ *
110
+ * The action split is read from the call log Playwright appends to a timeout
111
+ * message: `performing <x> action`, `<x> action done`, and `waiting for
112
+ * scheduled navigations to finish` are only logged once the input is being (or
113
+ * has been) dispatched, so a timeout whose log reaches them is uncertain and
114
+ * the harness must not blindly repeat it. Every earlier line (`waiting for
115
+ * element to be visible, enabled and stable`, `scrolling into view if
116
+ * needed`, `retrying <x> action`) precedes dispatch and is a plain
117
+ * actionability miss.
118
+ */
119
+ export declare const POST_DISPATCH_PATTERN: RegExp;
120
+ /** Translates an unexpected Playwright error at the contract boundary. */
121
+ export declare function translatePwError(cause: unknown, operation: string): Error;
122
+ /**
123
+ * Like translatePwError, but a read that lost its document to a navigation
124
+ * becomes retryable NODE_STALE so the runner re-reads the new document instead
125
+ * of failing the call. Timeouts keep their meaning: an observation that cannot
126
+ * be captured in time is not a race.
127
+ */
128
+ export declare function navigationStaleOr(cause: unknown, operation: string): Error;
129
+ /**
130
+ * Like translatePwError, but detachment/miss failures become retryable
131
+ * NODE_STALE. A timeout stays a timeout: `locate` resolves once and never
132
+ * waits, so a `TimeoutError` there is a budget that ran out, not a miss.
133
+ */
134
+ export declare function staleOr(cause: unknown, operation: string): Error;
135
+ export declare function performViewportSwipe(page: Page, direction: ScrollDirection, momentum: Momentum): Promise<void>;
136
+ /**
137
+ * The browser truncates a fractional pointer coordinate, so a point composed
138
+ * from a fractional box (`tap({ position })` on a node at y 148.875) would
139
+ * land on the pixel before the one asked for; it is rounded to the nearest
140
+ * CSS pixel instead.
141
+ */
142
+ export declare function nearestPixel(point: ViewportPoint): ViewportPoint;
143
+ /** A pointer drag from one viewport point to another, on whole pixels, with an intermediate move so drag handlers see motion. */
144
+ export declare function performPointDrag(mouse: Mouse, start: ViewportPoint, end: ViewportPoint): Promise<void>;
145
+ export declare function performElementSwipe(target: ActionTarget, direction: ScrollDirection, momentum: Momentum, timeout: number): Promise<void>;
146
+ export {};
147
+ //# sourceMappingURL=support.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"support.d.ts","sourceRoot":"","sources":["../src/support.ts"],"names":[],"mappings":"AAAA,uFAAuF;AAEvF,OAAO,KAAK,EAAE,aAAa,EAAE,OAAO,IAAI,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AACnF,OAAO,EAAE,WAAW,EAAuB,KAAK,oBAAoB,EAAE,KAAK,QAAQ,EAAE,KAAK,eAAe,EAAE,KAAK,aAAa,EAAE,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC;AAGrK,eAAO,MAAM,gBAAgB;aAAK,KAAK,EAAE,IAAI;aAAE,MAAM,EAAE,GAAG;CAAW,CAAC;AAEtE;;;;GAIG;AACH,wBAAsB,eAAe,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,YAAY,CAAC,CAIvE;AAeD;;;;GAIG;AACH,MAAM,MAAM,YAAY,GACpB;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAA;CAAE,GACzD;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC,OAAO,CAAC,CAAA;CAAE,CAAC;AAS3E;;;;;GAKG;AACH,KAAK,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