@volter-ai-dev/supercode-browser-playwright 0.2.0 → 0.2.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.
- package/README.md +39 -28
- package/dist/executor.d.ts +42 -3
- package/dist/executor.mjs +397 -64
- package/dist/executor.mjs.map +4 -4
- package/dist/guard.d.ts +63 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +397 -64
- package/dist/index.mjs.map +4 -4
- package/dist/script-scope.d.ts +27 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -130,34 +130,45 @@ Two entry points use no Node API:
|
|
|
130
130
|
`@volter/almostcdp/playwright`, and answers the operations against an
|
|
131
131
|
AlmostCDP surface with no Node process.
|
|
132
132
|
|
|
133
|
-
A host's `actionGuard(action)` is asked before
|
|
134
|
-
each `browser.script` (`{action: "script", source,
|
|
135
|
-
`BrowserActionRefusal` answers the call with its code, such as
|
|
136
|
-
`APPROVAL_REQUIRED`.
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
the
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
133
|
+
A host's `actionGuard(action)` is asked before every action that can change the
|
|
134
|
+
page or send it input, and before each `browser.script` (`{action: "script", source,
|
|
135
|
+
args}`); throwing a `BrowserActionRefusal` answers the call with its code, such as
|
|
136
|
+
`APPROVAL_REQUIRED`. Reading (status, snapshot, query, wait, box) is not asked;
|
|
137
|
+
`hover` is asked like any element action, and moving the mouse is not.
|
|
138
|
+
|
|
139
|
+
- Element actions (`click`, `fill`, `press`, `hover`, `focus`, `check`, `uncheck`,
|
|
140
|
+
`select`) carry a `target` described from the browser side. The locator is
|
|
141
|
+
resolved once (waiting up to 5 s) and the action runs on that same element
|
|
142
|
+
handle. The handle must be in the page's main frame and must be one of the
|
|
143
|
+
elements found at its box in an isolated world (a one-off marker attribute on
|
|
144
|
+
the handle confirms it); each is described over CDP (`DOM.describeNode` for tag
|
|
145
|
+
and attributes, `Accessibility.getPartialAXTree` for role, name and ancestors,
|
|
146
|
+
plus its form membership and, when unnamed, its own text). An element in a
|
|
147
|
+
`<label>` brings the control the label forwards to. A locator that resolves in
|
|
148
|
+
another frame, to a frame, or to a box more than eight elements share is refused.
|
|
149
|
+
A `select` carries the chosen options' labels and values.
|
|
150
|
+
- A locator `press` focuses its element and is refused unless focus is then on or
|
|
151
|
+
inside it; a press without a locator is described from the focused element and
|
|
152
|
+
refused inside a frame or a closed shadow root.
|
|
153
|
+
- Raw pointer input (`browser.mouse` click/down/up, `browser.wheel`,
|
|
154
|
+
`browser.drag`) carries `pointer: true` and the element at the point as best
|
|
155
|
+
known (`target.unidentified` says why when it cannot be told); a drag carries
|
|
156
|
+
both points and the element at the drop point. The mouse is moved to the point
|
|
157
|
+
before every down, up and wheel. After a locator action the position is that
|
|
158
|
+
element's box centre, or unknown, and a press then needs coordinates.
|
|
159
|
+
- `back`, `forward`, `reload` and `scroll` are page actions (`{action, url}`).
|
|
160
|
+
- Just before any input is dispatched, the executor confirms the page's main frame
|
|
161
|
+
still holds the document the action was checked on (its `loaderId` and URL) with
|
|
162
|
+
no navigation requested or loading (a navigation counts as settled once its
|
|
163
|
+
document commits, it moves within the document, loading stops, as for a 204
|
|
164
|
+
answer, or it becomes a download), then calls the host's `beforeInput({url})`;
|
|
165
|
+
a change refuses the action with `STALE_PAGE` and nothing is sent. A pointer
|
|
166
|
+
action on a locator first waits for its element in a trial run, so the
|
|
167
|
+
confirmation comes as late as it can.
|
|
168
|
+
|
|
169
|
+
A script gets the page through a membrane. When the script ends or its time runs
|
|
170
|
+
out, every later call through it throws, and the routes, exposed bindings and
|
|
171
|
+
functions, init scripts and listeners it installed are removed.
|
|
161
172
|
|
|
162
173
|
A host's `snapshotExclude` is a CSS selector for its own elements in the page
|
|
163
174
|
(an overlay, a launcher): `browser.snapshot` leaves out the nodes of every
|
package/dist/executor.d.ts
CHANGED
|
@@ -41,9 +41,26 @@ export interface PlaywrightOperationExecutorOptions {
|
|
|
41
41
|
* same.
|
|
42
42
|
*/
|
|
43
43
|
snapshotExclude?: string;
|
|
44
|
+
/**
|
|
45
|
+
* The host's last check just before input is dispatched to the page, after
|
|
46
|
+
* the executor has confirmed the main frame still holds the checked
|
|
47
|
+
* document with no navigation in flight. `url` is the page URL the action
|
|
48
|
+
* was checked on. Throwing a `BrowserActionRefusal` refuses the action; no
|
|
49
|
+
* input has been sent.
|
|
50
|
+
*/
|
|
51
|
+
beforeInput?: (checked: {
|
|
52
|
+
url: string;
|
|
53
|
+
}) => void | Promise<void>;
|
|
44
54
|
}
|
|
45
55
|
/** One action an operation is about to perform. */
|
|
46
|
-
export type PlaywrightAction = PlaywrightElementAction | PlaywrightScriptAction;
|
|
56
|
+
export type PlaywrightAction = PlaywrightElementAction | PlaywrightPageAction | PlaywrightScriptAction;
|
|
57
|
+
/** An action on the page as a whole: history navigation, reload, scrolling. */
|
|
58
|
+
export interface PlaywrightPageAction {
|
|
59
|
+
action: "back" | "forward" | "reload" | "scroll";
|
|
60
|
+
/** The page's URL when the action was asked about. */
|
|
61
|
+
url: string;
|
|
62
|
+
value?: unknown;
|
|
63
|
+
}
|
|
47
64
|
export type { GuardedNode, GuardedTarget } from "./guard.js";
|
|
48
65
|
/** An action that lands on an element: by locator, or at a viewport point. */
|
|
49
66
|
export interface PlaywrightElementAction {
|
|
@@ -51,6 +68,12 @@ export interface PlaywrightElementAction {
|
|
|
51
68
|
/** What the action lands on, described from the browser side. */
|
|
52
69
|
target: GuardedTarget;
|
|
53
70
|
value?: unknown;
|
|
71
|
+
/**
|
|
72
|
+
* Raw pointer input (`browser.mouse` down/up/click, `browser.wheel`,
|
|
73
|
+
* `browser.drag`): the target is the element at `target.point` as best
|
|
74
|
+
* known, which a page can change between the look and the press.
|
|
75
|
+
*/
|
|
76
|
+
pointer?: boolean;
|
|
54
77
|
}
|
|
55
78
|
export interface PlaywrightScriptAction {
|
|
56
79
|
/** `browser.script`: the author's source, run with the real `page`. */
|
|
@@ -71,7 +94,12 @@ export declare class PlaywrightOperationExecutor {
|
|
|
71
94
|
private readonly options;
|
|
72
95
|
private readonly ready;
|
|
73
96
|
private readonly targets;
|
|
74
|
-
/**
|
|
97
|
+
/**
|
|
98
|
+
* Where the mouse is: `page.mouse` keeps it, but does not report it. A
|
|
99
|
+
* locator action moves it to the element's clickable point; it is then the
|
|
100
|
+
* centre of that element's box as measured after the action, or unknown
|
|
101
|
+
* (null) when that cannot be measured, and a press needs coordinates.
|
|
102
|
+
*/
|
|
75
103
|
private mouse;
|
|
76
104
|
constructor(page: Page, options: PlaywrightOperationExecutorOptions);
|
|
77
105
|
execute(raw: unknown): Promise<BrowserOperationResult>;
|
|
@@ -95,7 +123,18 @@ export declare class PlaywrightOperationExecutor {
|
|
|
95
123
|
* action runs on the locator. Resolution or description failing refuses.
|
|
96
124
|
*/
|
|
97
125
|
private guarded;
|
|
98
|
-
/**
|
|
126
|
+
/** The document an action is checked on; input later goes only to it. */
|
|
127
|
+
private checkpoint;
|
|
128
|
+
/** Just before input: the same document, no navigation in flight, and the host's own last check. */
|
|
129
|
+
private dispatching;
|
|
130
|
+
/** The page-level action's guard. */
|
|
131
|
+
private guardPage;
|
|
132
|
+
/** The pointer's position for a press that names none; unknown after a locator action. */
|
|
133
|
+
private pointer;
|
|
134
|
+
/**
|
|
135
|
+
* Asks the host's policy about raw pointer input at a viewport point; the
|
|
136
|
+
* target is the element there as best known (`unidentified` when not).
|
|
137
|
+
*/
|
|
99
138
|
private guardPoint;
|
|
100
139
|
/** A browser-side description, or the refusal that replaces the action. */
|
|
101
140
|
private describe;
|