You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,10 @@
2
2
3
3
## Unreleased
4
4
5
+
### Features
6
+
7
+
***browser** — add `page.evaluate(fn, ...args)` for type-safe browser-context evaluation with JSON-serialized arguments. String evaluation remains supported, but new adapter code should use function form to avoid implicit `wrapForEval` auto-IIFE magic.
8
+
5
9
### ⚠ BREAKING CHANGES
6
10
7
11
***browser** — replace the `--session <name>` flag with a `<session>` positional argument that immediately follows `browser`. `opencli browser work click 12` instead of `opencli browser --session work click 12`; `opencli browser work bind` instead of `opencli browser bind --session work`. Required-flag semantics are now encoded structurally as a positional, matching the Docker/git convention for required operation-target identifiers. The internal `--session` flag is preserved for the daemon protocol and for direct `program.parseAsync` callers but is no longer part of the user-facing surface.
Copy file name to clipboardExpand all lines: docs/developer/ts-adapter.md
+8-9Lines changed: 8 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,14 +28,12 @@ cli({
28
28
// Navigate and extract data
29
29
awaitpage.goto('https://www.mysite.com');
30
30
31
-
const data =awaitpage.evaluate(`
32
-
(async () => {
33
-
const res = await fetch('/api/search?q=${encodeURIComponent(String(query))}', {
34
-
credentials: 'include'
35
-
});
36
-
return (await res.json()).results;
37
-
})()
38
-
`);
31
+
const data =awaitpage.evaluate(async (q:string) => {
32
+
const res =awaitfetch(`/api/search?q=${encodeURIComponent(q)}`, {
33
+
credentials: 'include',
34
+
});
35
+
return (awaitres.json()).results;
36
+
}, String(query));
39
37
40
38
if (!Array.isArray(data)) thrownewCommandExecutionError('MySite returned an unexpected response');
41
39
if (!data.length) thrownewEmptyResultError('mysite search', 'Try a different keyword');
@@ -112,7 +110,8 @@ persistence with `--site-session persistent`.
112
110
The `page` parameter provides browser interaction methods:
113
111
114
112
-`page.goto(url)` — Navigate to a URL
115
-
-`page.evaluate(script)` — Execute JavaScript in the page context
113
+
-`page.evaluate(fn, ...args)` — Execute a serializable function in the page context. Pass Node-side values through JSON-serializable args; the function cannot close over local variables.
114
+
-`page.evaluate(script)` — Execute a raw JavaScript string in the page context. Prefer function form for new adapter code.
116
115
-`page.waitForSelector(selector)` — Wait for an element
117
116
-`page.click(selector)` — Click an element
118
117
-`page.type(selector, text)` — Type text into an input
0 commit comments