polotno-node 3.8.1 → 3.9.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/README.md +79 -0
- package/dist/assets/{index-Bc1WTi4k.js → index-DMNDOkTi.js} +117 -117
- package/dist/assets/{index.es-Dg88tupA.js → index.es-BGauYEGb.js} +1 -1
- package/dist/assets/{jspdf.es.min-CTt99xrZ.js → jspdf.es.min-7Xedaaef.js} +3 -3
- package/dist/assets/lib-B5Aq9qTO.js +1 -0
- package/dist/index.html +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/instance.d.ts +12 -9
- package/lib/instance.js +363 -190
- package/lib/types.d.ts +23 -1
- package/lib/video-status.d.ts +7 -0
- package/lib/video-status.js +107 -0
- package/package.json +5 -5
- package/dist/assets/lib-C3mnf1jX.js +0 -1
package/README.md
CHANGED
|
@@ -252,6 +252,85 @@ const base64 = await instance.jsonToVideoBase64(json, {
|
|
|
252
252
|
fs.writeFileSync('out.mp4', base64, 'base64');
|
|
253
253
|
```
|
|
254
254
|
|
|
255
|
+
### Video status and inactivity detection
|
|
256
|
+
|
|
257
|
+
Video export methods report status through the third argument of `onProgress(fraction, frameTime, status)`.
|
|
258
|
+
The first argument remains a number between 0 and 1. Existing handlers can ignore the third argument.
|
|
259
|
+
Monitoring runs only when you provide `onProgress`. It does not cancel an export, close a browser, or retry a job.
|
|
260
|
+
|
|
261
|
+
```js
|
|
262
|
+
await instance.jsonToVideoFile(json, 'out.mp4', {
|
|
263
|
+
onProgress: (fraction, frameTime, status) => {
|
|
264
|
+
console.log('Progress:', fraction, status);
|
|
265
|
+
if (status?.state === 'stalled') {
|
|
266
|
+
console.warn('No recent work progress:', status.stage, status.idleMs);
|
|
267
|
+
}
|
|
268
|
+
},
|
|
269
|
+
// Example advisory budgets. Tune these from healthy exports on your hosts.
|
|
270
|
+
stallTimeoutMs: {
|
|
271
|
+
frames: 60_000,
|
|
272
|
+
'audio-render': 180_000,
|
|
273
|
+
finalize: 180_000,
|
|
274
|
+
},
|
|
275
|
+
});
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
The third argument contains:
|
|
279
|
+
|
|
280
|
+
| Field | Meaning |
|
|
281
|
+
| -------------------- | ---------------------------------------------------------------------------- |
|
|
282
|
+
| `state` | `running`, `stalled`, `completed`, or `failed` |
|
|
283
|
+
| `stage` | The last reported operation, listed in the next table |
|
|
284
|
+
| `completed`, `total` | Work counters within the stage, when available |
|
|
285
|
+
| `elapsedMs` | Time since the export passed design validation |
|
|
286
|
+
| `idleMs` | Time since the last stage change, counter increase, or fraction increase |
|
|
287
|
+
| `heartbeatAgeMs` | Time since the last tab heartbeat. Absent until the first heartbeat arrives. |
|
|
288
|
+
|
|
289
|
+
Stages describe these operations:
|
|
290
|
+
|
|
291
|
+
| Stage | Operation and counter unit |
|
|
292
|
+
| --------------- | ----------------------------------------------------------------------------------------------------- |
|
|
293
|
+
| `prepare-media` | Download and prepare remote media. Counts prepared sources. |
|
|
294
|
+
| `load-client` | Open and configure the renderer page. |
|
|
295
|
+
| `load-design` | Load the design and wait for its pages. Counts pages. |
|
|
296
|
+
| `setup` | Initialize the video exporter and codecs. |
|
|
297
|
+
| `frames` | Render and encode video frames. Counts frames. |
|
|
298
|
+
| `audio-decode` | Load and decode audio. Counts processed sources, including sources the exporter skips after an error. |
|
|
299
|
+
| `audio-render` | Mix audio through the native audio renderer. |
|
|
300
|
+
| `audio-encode` | Send the mixed audio to the encoder. |
|
|
301
|
+
| `finalize` | Finish the video container. |
|
|
302
|
+
| `transfer` | Transfer the video to Node. Counts bytes written to the output file. |
|
|
303
|
+
| `postprocess` | Inspect the output file and convert its audio codec when necessary. |
|
|
304
|
+
| `read-output` | Read the file for a base64 or data-URL result. |
|
|
305
|
+
|
|
306
|
+
`stallTimeoutMs` accepts one number for every stage, or an object with overrides per stage.
|
|
307
|
+
The default is 60000 ms, including stages without an override. A value of `0` disables stall notifications for that budget.
|
|
308
|
+
The threshold is advisory. It is not a measured limit for healthy renders.
|
|
309
|
+
|
|
310
|
+
The monitor emits one `stalled` notification per inactivity period.
|
|
311
|
+
A new stage, counter increase, or fraction increase emits `running` and starts a new inactivity period.
|
|
312
|
+
Repeated counters, repeated fractions, and tab heartbeats do not reset the inactivity clock.
|
|
313
|
+
Stage changes and stall notifications can repeat the last fraction. Successful completion reports `1`.
|
|
314
|
+
The last notification is `completed` or `failed`. Monitoring then stops, including after temporary-file cleanup.
|
|
315
|
+
Callback errors are logged. Callback promises do not delay the export.
|
|
316
|
+
|
|
317
|
+
The tab sends a heartbeat approximately once per second during the browser export.
|
|
318
|
+
A recent heartbeat means that the tab could run JavaScript, even if the export made no visible progress.
|
|
319
|
+
A missing heartbeat can indicate blocked JavaScript or host contention. It does not prove a permanent stall.
|
|
320
|
+
Native audio processing and finalization can also take time without intermediate work counters.
|
|
321
|
+
Custom clients with older video exporters can report fewer stages.
|
|
322
|
+
|
|
323
|
+
The inactivity timer runs in Node, so it can report a blocked renderer without another CDP request.
|
|
324
|
+
It cannot fire while Node itself is blocked, including during synchronous media conversion or base64 conversion.
|
|
325
|
+
An independent parent-process monitor is necessary to detect that condition during the block.
|
|
326
|
+
Existing `protocolTimeout` and navigation timeouts still apply.
|
|
327
|
+
|
|
328
|
+
A confirmed renderer crash rejects the active render without waiting for its CDP timeout.
|
|
329
|
+
Protocol failures skip further renderer diagnostics, which could otherwise consume another full timeout.
|
|
330
|
+
Failed-page cleanup does not delay rejection or replace the original error. It does not terminate the browser.
|
|
331
|
+
With the default `useParallelPages: true`, a later export opens a new page if the browser remains connected.
|
|
332
|
+
Retries remain the caller's decision; inactivity notifications alone do not trigger them.
|
|
333
|
+
|
|
255
334
|
### `attrs` usage
|
|
256
335
|
|
|
257
336
|
**NOTE: all export API will pass `attrs` object into relevant export function from `store`.**
|