@push.rocks/smartpuppeteer 2.3.0 → 2.5.0
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/dist_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/smartpuppeteer.classes.livebrowsersession.d.ts +12 -1
- package/dist_ts/smartpuppeteer.classes.livebrowsersession.js +338 -68
- package/dist_ts/smartpuppeteer.interfaces.livebrowser.d.ts +11 -5
- package/dist_ts/smartpuppeteer.interfaces.livebrowser.js +3 -2
- package/package.json +1 -1
- package/readme.hints.md +2 -1
- package/readme.md +8 -3
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/smartpuppeteer.classes.livebrowsersession.ts +433 -89
- package/ts/smartpuppeteer.interfaces.livebrowser.ts +13 -6
|
@@ -3,6 +3,8 @@ export type TLiveBrowserStatus = 'stopped' | 'starting' | 'running' | 'stopping'
|
|
|
3
3
|
export type TLiveBrowserImageFormat = 'jpeg' | 'png';
|
|
4
4
|
export type TLiveBrowserTabStatus = 'open' | 'crashed';
|
|
5
5
|
export type TLiveBrowserWaitUntil = 'load' | 'domcontentloaded' | 'networkidle0' | 'networkidle2';
|
|
6
|
+
export declare const liveBrowserDefaultMaxOutstandingFrames = 3;
|
|
7
|
+
export declare const liveBrowserMaxOutstandingFrames = 64;
|
|
6
8
|
export interface ILiveBrowserViewport {
|
|
7
9
|
width: number;
|
|
8
10
|
height: number;
|
|
@@ -14,6 +16,8 @@ export interface ILiveBrowserScreencastOptions {
|
|
|
14
16
|
maxWidth?: number;
|
|
15
17
|
maxHeight?: number;
|
|
16
18
|
everyNthFrame?: number;
|
|
19
|
+
maxOutstandingFrames?: number;
|
|
20
|
+
firstFrameTimeoutMs?: number;
|
|
17
21
|
}
|
|
18
22
|
export interface ILiveBrowserSecurityOptions {
|
|
19
23
|
denyDownloads?: boolean;
|
|
@@ -114,6 +118,12 @@ export interface ILiveBrowserFrame {
|
|
|
114
118
|
metadata: ILiveBrowserScreencastMetadata;
|
|
115
119
|
data: Uint8Array;
|
|
116
120
|
}
|
|
121
|
+
export interface ILiveBrowserFrameIdentity {
|
|
122
|
+
tabId: string;
|
|
123
|
+
sequence: number;
|
|
124
|
+
generation: number;
|
|
125
|
+
viewportRevision: number;
|
|
126
|
+
}
|
|
117
127
|
export interface ILiveBrowserSnapshot {
|
|
118
128
|
tabId: string;
|
|
119
129
|
viewportRevision: number;
|
|
@@ -141,11 +151,7 @@ export type TLiveBrowserEventListener = (event: TLiveBrowserEvent) => void;
|
|
|
141
151
|
export interface ILiveBrowserFrameAcknowledgement {
|
|
142
152
|
accepted: boolean;
|
|
143
153
|
}
|
|
144
|
-
export interface ILiveBrowserFrameAcknowledgementRequest {
|
|
145
|
-
tabId: string;
|
|
146
|
-
sequence: number;
|
|
147
|
-
generation: number;
|
|
148
|
-
viewportRevision: number;
|
|
154
|
+
export interface ILiveBrowserFrameAcknowledgementRequest extends ILiveBrowserFrameIdentity {
|
|
149
155
|
}
|
|
150
156
|
export interface ILiveBrowserCreateTabOptions {
|
|
151
157
|
url?: string;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
1
|
+
export const liveBrowserDefaultMaxOutstandingFrames = 3;
|
|
2
|
+
export const liveBrowserMaxOutstandingFrames = 64;
|
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRwdXBwZXRlZXIuaW50ZXJmYWNlcy5saXZlYnJvd3Nlci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0cHVwcGV0ZWVyLmludGVyZmFjZXMubGl2ZWJyb3dzZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBV0EsTUFBTSxDQUFDLE1BQU0sc0NBQXNDLEdBQUcsQ0FBQyxDQUFDO0FBQ3hELE1BQU0sQ0FBQyxNQUFNLCtCQUErQixHQUFHLEVBQUUsQ0FBQyJ9
|
package/package.json
CHANGED
package/readme.hints.md
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
- `getEnvAwareBrowserInstance()` is the only Chromium launch path. Merge caller arguments before adding environment-required sandbox arguments, retain the pipe default, and do not run executable discovery when the caller selected a browser, channel, or executable.
|
|
4
4
|
- `LiveBrowserSession` uses the browser's default context so all tabs and popups share one profile. Omitting both `launchOptions.userDataDir` and a `--user-data-dir` argument intentionally relies on Puppeteer's ephemeral profile lifecycle.
|
|
5
5
|
- CDP is private to the live runtime. Public contracts contain transport-neutral values and `Uint8Array` image data, never `CDPSession`, raw CDP frame IDs, or base64 image strings.
|
|
6
|
-
- Every published screencast frame has one private sequence-to-CDP acknowledgement entry. Public acknowledgement requires matching tab ID, sequence, generation, and viewport revision.
|
|
6
|
+
- Every published screencast frame has one private sequence-to-CDP acknowledgement entry. Public acknowledgement requires matching tab ID, sequence, generation, and viewport revision. `screencast.maxOutstandingFrames` bounds those entries independently of any application transport window; overflow retires oldest-first. Drops and all stream invalidation paths must issue each CDP acknowledgement at most once and await in-flight acknowledgements before detaching the CDP session.
|
|
7
|
+
- `refreshScreencast()` installs its exact-generation waiter before starting CDP, retires the previous stream, and resolves only after the first validated frame is published. Pre-aborted and queued calls reject without changing the stream. Active caller cancellation settles only after restorative restart; shutdown, tab replacement, crash, or closure revokes restart authority and must never resurrect the stream.
|
|
7
8
|
- Activation, viewport changes, navigation, tab closure, snapshots, observations, semantic actions, and shutdown share one bounded operation scheduler. Raw input and frame acknowledgement remain direct, but must validate active tab, generation, and viewport revision. Repeated internal navigation/load state updates are coalesced per tab, and shutdown cancels queued work.
|
|
8
9
|
- Retain the scheduler-owned launch `AbortController` for the full browser lifetime. Shutdown aborts both the active operation and Chromium itself so a non-signal-aware Puppeteer command or disabled protocol timeout cannot retain the browser ahead of queued cleanup.
|
|
9
10
|
- Viewport revision starts at 1 and advances only after `Page.setViewport()` succeeds. Stop and flush the active screencast before applying a viewport or navigation mutation, then restart it with a new generation.
|
package/readme.md
CHANGED
|
@@ -120,6 +120,9 @@ const session = new LiveBrowserSession({
|
|
|
120
120
|
quality: 80,
|
|
121
121
|
maxWidth: 1280,
|
|
122
122
|
maxHeight: 720,
|
|
123
|
+
everyNthFrame: 1,
|
|
124
|
+
maxOutstandingFrames: 3,
|
|
125
|
+
firstFrameTimeoutMs: 5000,
|
|
123
126
|
},
|
|
124
127
|
launchOptions: {
|
|
125
128
|
headless: true,
|
|
@@ -168,11 +171,13 @@ try {
|
|
|
168
171
|
}
|
|
169
172
|
```
|
|
170
173
|
|
|
171
|
-
Only the active tab is streamed. Frames carry a session-monotonic sequence, tab/CDP generation, viewport revision, viewport, MIME type, encoded dimensions, screencast metadata, and binary `Uint8Array` data. Every delivered frame must be acknowledged with all four identity fields. A delivered frame remains pending until it is acknowledged, dropped, or retired by the runtime; mismatched, duplicate, stale, retired, or operationally failed acknowledgements return `{ accepted: false }`. Operational acknowledgement failures also emit an `error` event whose code is `frame_acknowledgement_failed`.
|
|
174
|
+
Only the active tab is streamed. Frames carry a session-monotonic sequence, tab/CDP generation, viewport revision, viewport, MIME type, encoded dimensions, screencast metadata, and binary `Uint8Array` data. Every delivered frame must be acknowledged with all four identity fields. A delivered frame remains pending until it is acknowledged, dropped, or retired by the runtime; mismatched, duplicate, stale, retired, or operationally failed acknowledgements return `{ accepted: false }`. Operational acknowledgement failures also emit an `error` event whose code is `frame_acknowledgement_failed`. `screencast.maxOutstandingFrames` is an integer from 1 through `liveBrowserMaxOutstandingFrames` (64) and defaults to `liveBrowserDefaultMaxOutstandingFrames` (3). At capacity, SmartPuppeteer retires and CDP-acknowledges the oldest pending frame before publishing the next one. Tab switches, navigation, resize, page cleanup, disconnect, and shutdown also retire pending frames and await their single CDP acknowledgement attempt before detaching the screencast session.
|
|
175
|
+
|
|
176
|
+
The SmartPuppeteer outstanding-frame bound covers only the private frame-to-`Page.screencastFrameAck` lifecycle. It is not a binary transport window, and `acknowledgeFrame()` is not an application transport acknowledgement. A higher-level runtime must maintain and bound its application frame window separately. `refreshScreencast()` retires the active stream and resolves with an `ILiveBrowserFrameIdentity` for the exact first validated frame from a new generation. Its `tabId`, `sequence`, `generation`, and `viewportRevision` fields can be passed directly to `acknowledgeFrame()`. `screencast.firstFrameTimeoutMs` bounds both the CDP restart and first-frame arrival, accepts integers from 100 through 60,000, and defaults to 5,000; timeout or another refresh failure emits fatal `screencast_refresh_failed` and shuts the session down. Screencast `format` accepts `jpeg` or `png`, `quality` accepts integers from 0 through 100, `maxWidth` and `maxHeight` accept integers from 1 through 4096 subject to an 8,294,400-pixel combined ceiling, and `everyNthFrame` accepts integers from 1 through 100.
|
|
172
177
|
|
|
173
178
|
The live API includes:
|
|
174
179
|
|
|
175
|
-
- Lifecycle and state: `start()`, `stop()`, `terminate()`, `getProcessState()`, `onEvent()`, and `getState()`
|
|
180
|
+
- Lifecycle and state: `start()`, `stop()`, `terminate()`, `refreshScreencast()`, `getProcessState()`, `onEvent()`, and `getState()`
|
|
176
181
|
- Tabs and navigation: `createTab()`, `activateTab()`, `closeTab()`, `navigate()`, `back()`, `forward()`, and `reload()`
|
|
177
182
|
- Viewport and raw input: `setViewport()`, `dispatchMouse()`, `dispatchWheel()`, `dispatchKey()`, and `insertText()`
|
|
178
183
|
- Agent-oriented actions: `click()`, `fill()`, and `press()` with bounded selectors and timeouts
|
|
@@ -181,7 +186,7 @@ The live API includes:
|
|
|
181
186
|
|
|
182
187
|
Coordinate, keyboard, text, and semantic input messages include `tabId`, `generation`, and `viewportRevision`. This rejects input derived from an old stream generation, resize, or tab state. Snapshot, observation, and semantic operations are serialized with lifecycle mutations; inactive tabs receive the current session viewport before use. `viewport` takes precedence over `launchOptions.defaultViewport`; `null` falls back to 800x600. The runtime canonicalizes every page to a desktop, non-touch viewport because mobile emulation flags are outside the public viewport contract. Viewport dimensions, device scale factor, and physical pixel area are bounded, and full-page snapshots are intentionally unsupported. CDP sessions and CDP frame identifiers remain private implementation details. `LiveBrowserSession` owns launch cancellation, so callers cannot supply `launchOptions.signal`. It supports only Chromium over CDP and rejects Firefox or WebDriver BiDi launch selections.
|
|
183
188
|
|
|
184
|
-
`start()`, tab and navigation methods, `setViewport()`, `captureSnapshot()`, `observe()`, semantic actions, and `evaluate()` accept a trailing `{ signal }` operation argument. A pre-aborted operation is never admitted. An operation aborted while queued is removed immediately. An active operation receives cancellation when its Puppeteer or CDP primitive supports it; otherwise its promise rejects only after the underlying work settles, and it continues to occupy the serialized queue until then. Cancellation therefore does not promise that an already-started browser side effect did not occur. `stop()`, frame acknowledgement, event/state access, and direct raw input are intentionally not caller-cancellable.
|
|
189
|
+
`start()`, `refreshScreencast()`, tab and navigation methods, `setViewport()`, `captureSnapshot()`, `observe()`, semantic actions, and `evaluate()` accept a trailing `{ signal }` operation argument. A pre-aborted operation is never admitted. An operation aborted while queued is removed immediately. An active operation receives cancellation when its Puppeteer or CDP primitive supports it; otherwise its promise rejects only after the underlying work settles, and it continues to occupy the serialized queue until then. An active `refreshScreencast()` completes the restorative restart before settling caller cancellation, unless session shutdown or page invalidation revokes that restart. Cancellation therefore does not promise that an already-started browser side effect did not occur. `stop()`, frame acknowledgement, event/state access, and direct raw input are intentionally not caller-cancellable.
|
|
185
190
|
|
|
186
191
|
Optional browser guards can be enabled when composing a higher-level runtime:
|
|
187
192
|
|