@push.rocks/smartpuppeteer 2.4.0 → 2.6.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 +21 -1
- package/dist_ts/smartpuppeteer.classes.livebrowsersession.js +611 -86
- package/dist_ts/smartpuppeteer.interfaces.livebrowser.d.ts +8 -5
- package/package.json +1 -1
- package/readme.hints.md +3 -0
- package/readme.md +5 -4
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/smartpuppeteer.classes.livebrowsersession.ts +840 -103
- package/ts/smartpuppeteer.interfaces.livebrowser.ts +9 -6
|
@@ -17,6 +17,7 @@ export interface ILiveBrowserScreencastOptions {
|
|
|
17
17
|
maxHeight?: number;
|
|
18
18
|
everyNthFrame?: number;
|
|
19
19
|
maxOutstandingFrames?: number;
|
|
20
|
+
firstFrameTimeoutMs?: number;
|
|
20
21
|
}
|
|
21
22
|
export interface ILiveBrowserSecurityOptions {
|
|
22
23
|
denyDownloads?: boolean;
|
|
@@ -117,6 +118,12 @@ export interface ILiveBrowserFrame {
|
|
|
117
118
|
metadata: ILiveBrowserScreencastMetadata;
|
|
118
119
|
data: Uint8Array;
|
|
119
120
|
}
|
|
121
|
+
export interface ILiveBrowserFrameIdentity {
|
|
122
|
+
tabId: string;
|
|
123
|
+
sequence: number;
|
|
124
|
+
generation: number;
|
|
125
|
+
viewportRevision: number;
|
|
126
|
+
}
|
|
120
127
|
export interface ILiveBrowserSnapshot {
|
|
121
128
|
tabId: string;
|
|
122
129
|
viewportRevision: number;
|
|
@@ -144,11 +151,7 @@ export type TLiveBrowserEventListener = (event: TLiveBrowserEvent) => void;
|
|
|
144
151
|
export interface ILiveBrowserFrameAcknowledgement {
|
|
145
152
|
accepted: boolean;
|
|
146
153
|
}
|
|
147
|
-
export interface ILiveBrowserFrameAcknowledgementRequest {
|
|
148
|
-
tabId: string;
|
|
149
|
-
sequence: number;
|
|
150
|
-
generation: number;
|
|
151
|
-
viewportRevision: number;
|
|
154
|
+
export interface ILiveBrowserFrameAcknowledgementRequest extends ILiveBrowserFrameIdentity {
|
|
152
155
|
}
|
|
153
156
|
export interface ILiveBrowserCreateTabOptions {
|
|
154
157
|
url?: string;
|
package/package.json
CHANGED
package/readme.hints.md
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
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
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.
|
|
@@ -12,4 +13,6 @@
|
|
|
12
13
|
- New-page registration and navigation are transactional: validate before creating a page where possible and restore page, listener, tab-map, active-tab, viewport, and screencast ownership on failure. Keep listeners attached during `page.close()` so a failed close remains observed and recoverable.
|
|
13
14
|
- Browser disconnect is runtime-fatal. Page crash or current CDP-session loss is tab-scoped: activate another usable tab, trying all candidates, or stop cleanly when none remains.
|
|
14
15
|
- Every popup is either registered, closed, or escalated to browser-wide shutdown. Queue saturation and startup-time popup events must never leave an untracked live page.
|
|
16
|
+
- Authenticated proxy coverage owns a filtered browser-target auto-attach scope for service workers. Configure Fetch and Network before resuming each owned worker, use the hidden page-target lifecycle observer to release stopped or request-drained redundant workers, bound every security command and detach wait, and keep Puppeteer's target sessions independent.
|
|
17
|
+
- A navigation metadata refresh failure must not consume screencast restoration ownership. Restore the active stream first, preserve newer navigation revisions, and report the metadata failure separately.
|
|
15
18
|
- Verify Puppeteer behavior against the installed Puppeteer 25 declarations and implementation. Do not add a direct `devtools-protocol` dependency; Puppeteer's public protocol typing is sufficient for private CDP calls.
|
package/readme.md
CHANGED
|
@@ -122,6 +122,7 @@ const session = new LiveBrowserSession({
|
|
|
122
122
|
maxHeight: 720,
|
|
123
123
|
everyNthFrame: 1,
|
|
124
124
|
maxOutstandingFrames: 3,
|
|
125
|
+
firstFrameTimeoutMs: 5000,
|
|
125
126
|
},
|
|
126
127
|
launchOptions: {
|
|
127
128
|
headless: true,
|
|
@@ -172,11 +173,11 @@ try {
|
|
|
172
173
|
|
|
173
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.
|
|
174
175
|
|
|
175
|
-
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. 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.
|
|
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.
|
|
176
177
|
|
|
177
178
|
The live API includes:
|
|
178
179
|
|
|
179
|
-
- Lifecycle and state: `start()`, `stop()`, `terminate()`, `getProcessState()`, `onEvent()`, and `getState()`
|
|
180
|
+
- Lifecycle and state: `start()`, `stop()`, `terminate()`, `refreshScreencast()`, `getProcessState()`, `onEvent()`, and `getState()`
|
|
180
181
|
- Tabs and navigation: `createTab()`, `activateTab()`, `closeTab()`, `navigate()`, `back()`, `forward()`, and `reload()`
|
|
181
182
|
- Viewport and raw input: `setViewport()`, `dispatchMouse()`, `dispatchWheel()`, `dispatchKey()`, and `insertText()`
|
|
182
183
|
- Agent-oriented actions: `click()`, `fill()`, and `press()` with bounded selectors and timeouts
|
|
@@ -185,7 +186,7 @@ The live API includes:
|
|
|
185
186
|
|
|
186
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.
|
|
187
188
|
|
|
188
|
-
`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.
|
|
189
190
|
|
|
190
191
|
Optional browser guards can be enabled when composing a higher-level runtime:
|
|
191
192
|
|
|
@@ -213,7 +214,7 @@ const guardedSession = new LiveBrowserSession({
|
|
|
213
214
|
|
|
214
215
|
`denyDownloads` installs a default-context download denial at launch. `denyPermissions` applies an empty browser-wide permission grant before the first page is exposed, causing unlisted permissions to be denied. `denyFileChoosers` installs persistent CDP cancellation on each registered page. `httpNavigationOnly` limits URLs passed to `createTab()` and `navigate()` to `http:` and `https:`; it does not inspect or rewrite renderer-initiated navigation.
|
|
215
216
|
|
|
216
|
-
`proxyCredentials` handles authenticated-proxy challenges for existing and future page and
|
|
217
|
+
`proxyCredentials` handles authenticated-proxy challenges for existing and future page, dedicated-worker, and service-worker traffic. SmartPuppeteer supplies credentials only when CDP identifies the challenge source as `Proxy`; origin-server and unknown challenges are cancelled without credentials, and a repeated challenge for the same request is cancelled. Page and dedicated-worker setup is queued from Puppeteer's public CDP session-attachment event. Service workers use an independent, filtered browser-target attachment scope that enables Fetch and Network before resuming each worker. A hidden lifecycle target releases stopped workers and redundant workers after their tracked requests drain so Chromium can destroy them normally; later restarts are paused and protected again before execution. Setup failure rejects `start()` and closes the browser. During a running session, an unexpected browser security-session detach, a live target without a protected replacement session, or a proxy protocol failure is fatal and requests termination; Linux termination is confirmed only when `terminate()` resolves. The caller still owns proxy selection, Chromium proxy arguments, bypass rules, DNS behavior, egress policy, and proxy trust. Credentials remain in process memory for the session lifetime.
|
|
217
218
|
|
|
218
219
|
On Linux, Puppeteer launches Chromium as a dedicated process-group and session leader. `getProcessState()` reports the generation, root PID, process-group ID, and Node.js exit state. `terminate({ gracefulTimeoutMs, forceTimeoutMs })` is idempotent for concurrent callers, first requests normal shutdown, then freezes and kills the owned process group if the graceful deadline expires. It resolves with `confirmedDead: true` only after `/proc` contains no member of that owned process group, the Node.js child exit is observed, and session shutdown settles. PID reuse, permission failures, surviving members, or an unsettled shutdown reject confirmation and keep restart blocked. Confirmed process-group termination is Linux-only; use `stop()` for portable best-effort lifecycle cleanup.
|
|
219
220
|
|