@zumer/snapdom-plugins 4.4.1 → 5.1.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/CHANGELOG.md +23 -0
- package/README.md +58 -75
- package/ascii-export.d.ts +0 -7
- package/ascii-export.js +0 -21
- package/index.d.ts +0 -3
- package/index.js +1 -4
- package/jxl.d.ts +98 -0
- package/jxl.js +511 -0
- package/package.json +13 -20
- package/pdf/LICENSE +0 -21
- package/pdf/README.md +0 -22
- package/pdf/REFERENCE.md +0 -520
- package/pdf/src/frontmatter.js +0 -200
- package/pdf/src/furniture.js +0 -398
- package/pdf/src/index.js +0 -2415
- package/pdf/src/mega/README.md +0 -47
- package/pdf/src/mega/diag.js +0 -148
- package/pdf/src/mega/flow.js +0 -56
- package/pdf/src/mega/fonts.js +0 -287
- package/pdf/src/mega/forms.js +0 -479
- package/pdf/src/mega/labels.js +0 -43
- package/pdf/src/mega/meta.js +0 -145
- package/pdf/src/nav.js +0 -357
- package/pdf/src/paginate.js +0 -583
- package/pdf/src/tagged.js +0 -355
- package/pdf/src/text-layer.js +0 -1771
- package/pdf/src/writer/encrypt.js +0 -218
- package/pdf/src/writer/font.js +0 -507
- package/pdf/src/writer/index.js +0 -1135
- package/pdf/src/writer/subset.js +0 -387
- package/pdf.d.ts +0 -294
- package/pdf.js +0 -1
- package/stream/LICENSE +0 -21
- package/stream/README.md +0 -142
- package/stream/src/index.js +0 -41
- package/stream/src/overlays.js +0 -153
- package/stream/src/recorder.js +0 -41
- package/stream/src/stream.js +0 -686
- package/stream/src/webgl.js +0 -58
- package/stream.d.ts +0 -86
- package/stream.js +0 -1
- package/vector/CONTRACT.md +0 -903
- package/vector/LICENSE +0 -21
- package/vector/README.md +0 -35
- package/vector/src/adapters/snapdom.js +0 -795
- package/vector/src/collect/box.js +0 -1676
- package/vector/src/collect/font.js +0 -487
- package/vector/src/collect/image.js +0 -1458
- package/vector/src/collect/mathml.js +0 -272
- package/vector/src/collect/text.js +0 -3027
- package/vector/src/css/color.js +0 -823
- package/vector/src/css/gradient.js +0 -1126
- package/vector/src/css/matrix.js +0 -398
- package/vector/src/css/radius.js +0 -124
- package/vector/src/css/shadow.js +0 -201
- package/vector/src/emit/figma-json.js +0 -1995
- package/vector/src/emit/h2d-vector.js +0 -215
- package/vector/src/emit/h2d.js +0 -1147
- package/vector/src/emit/pdf.js +0 -2571
- package/vector/src/emit/svg-flat.js +0 -4842
- package/vector/src/exclusion.js +0 -13
- package/vector/src/index.js +0 -2910
- package/vector/src/paint.js +0 -2908
- package/vector/src/public.js +0 -57
- package/vector/src/writer/encrypt.js +0 -227
- package/vector/src/writer/font.js +0 -507
- package/vector/src/writer/index.js +0 -1148
- package/vector/src/writer/subset.js +0 -387
- package/vector/svd/index.js +0 -72
- package/vector/svd/schema.js +0 -985
- package/vector.d.ts +0 -28
- package/vector.js +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# Plugin changes
|
|
2
2
|
|
|
3
|
+
## 5.1.0
|
|
4
|
+
|
|
5
|
+
> 10 November 2026
|
|
6
|
+
|
|
7
|
+
**Features**
|
|
8
|
+
|
|
9
|
+
- **plugins:** jxl, JPEG XL exports with exact text [`#556`](https://github.com/zumerlab/snapdom/pull/556)
|
|
10
|
+
|
|
11
|
+
**Docs**
|
|
12
|
+
|
|
13
|
+
- **site:** add the JPEG XL plugin page [`5ceba24`](https://github.com/zumerlab/snapdom/commit/5ceba24c2887996381b402c9927d8b9be3445430)
|
|
14
|
+
|
|
15
|
+
## 5.0.0
|
|
16
|
+
|
|
17
|
+
> 9 November 2026
|
|
18
|
+
|
|
19
|
+
**Breaking changes**
|
|
20
|
+
|
|
21
|
+
- PDF, Vector and Stream are their own packages: [`@zumer/snapdom-pdf`](https://www.npmjs.com/package/@zumer/snapdom-pdf), [`@zumer/snapdom-vector`](https://www.npmjs.com/package/@zumer/snapdom-vector) and [`@zumer/snapdom-stream`](https://www.npmjs.com/package/@zumer/snapdom-stream). The `/pdf`, `/vector` and `/stream` subpaths are gone; change the import and nothing else, the options and behavior are unchanged.
|
|
22
|
+
- `asciiStream` left with the stream. Use the two calls it wrapped: `stream(el, { onFrame: (f) => onText(asciiFromCanvas(f.canvas, options)) })`, with `stream` from `@zumer/snapdom-stream` and `asciiFromCanvas` from `@zumer/snapdom-plugins/ascii-export`. The README's "Migrating from 4.x" table has every import side by side.
|
|
23
|
+
|
|
24
|
+
The package keeps the eleven toolbox plugins and still requires SnapDOM 3.4.0 or newer within 3.x.
|
|
25
|
+
|
|
3
26
|
## 4.4.1
|
|
4
27
|
|
|
5
28
|
> 29 October 2026
|
package/README.md
CHANGED
|
@@ -5,8 +5,10 @@
|
|
|
5
5
|
|
|
6
6
|
Official plugins for [SnapDOM](https://github.com/zumerlab/snapdom), a high-performance DOM engine
|
|
7
7
|
that exports a rendered element as PNG, SVG or canvas in the browser. Core exports images and
|
|
8
|
-
canvases; this package adds HTML, structured context, element maps,
|
|
9
|
-
|
|
8
|
+
canvases; this package adds HTML, structured context, element maps, ASCII, visual transforms,
|
|
9
|
+
redaction, JPEG XL and live GIF/video recording. PDF, Vector and Stream are their own packages:
|
|
10
|
+
[`@zumer/snapdom-pdf`](https://snapdom.dev/plugins/pdf/), [`@zumer/snapdom-vector`](https://snapdom.dev/plugins/vector/)
|
|
11
|
+
and [`@zumer/snapdom-stream`](https://snapdom.dev/plugins/stream/).
|
|
10
12
|
|
|
11
13
|
Image, HTML and structured exports use captured state; GIF and video start a sequence of
|
|
12
14
|
live captures when their export method is called.
|
|
@@ -19,7 +21,7 @@ Install the plugins next to a core supported by their peer dependency:
|
|
|
19
21
|
npm install @zumer/snapdom@latest @zumer/snapdom-plugins@latest
|
|
20
22
|
```
|
|
21
23
|
|
|
22
|
-
Plugins
|
|
24
|
+
Plugins 5.x require SnapDOM 3.4.0 or newer within 3.x and hold the twelve toolbox plugins. PDF, Vector and Stream moved to their own packages in 5.0; see [Migrating from 4.x](#migrating-from-4x). See the [migration guide](https://github.com/zumerlab/snapdom#migrating-from-v2) when upgrading from v2.
|
|
23
25
|
|
|
24
26
|
## Usage
|
|
25
27
|
|
|
@@ -66,7 +68,7 @@ snapdom(el, { plugins: [filter({ preset: 'grayscale' })] });
|
|
|
66
68
|
|
|
67
69
|
| Option | Type | Default | Description |
|
|
68
70
|
|--------|------|---------|-------------|
|
|
69
|
-
| `preset` | `string` |
|
|
71
|
+
| `preset` | `string` | none | `'grayscale'` \| `'sepia'` \| `'blur'` \| `'invert'` \| `'vintage'` \| `'dramatic'` |
|
|
70
72
|
| `filter` | `string` | `''` | Raw CSS filter string, e.g. `'blur(2px) contrast(1.2)'` |
|
|
71
73
|
|
|
72
74
|
---
|
|
@@ -231,49 +233,20 @@ console.log(art);
|
|
|
231
233
|
`toAscii({ width, charset, invert, format, contrast })` overrides any of them per call.
|
|
232
234
|
|
|
233
235
|
The conversion is also exported on its own. `asciiFromCanvas(source, options)` turns any
|
|
234
|
-
drawable (a canvas, an image, a video frame) into ASCII with the same options
|
|
235
|
-
|
|
236
|
+
drawable (a canvas, an image, a video frame) into ASCII with the same options. Run it on every
|
|
237
|
+
frame of a [`@zumer/snapdom-stream`](https://snapdom.dev/plugins/stream/) stream for a live ASCII mirror:
|
|
236
238
|
|
|
237
239
|
```js
|
|
238
|
-
import {
|
|
240
|
+
import { stream } from '@zumer/snapdom-stream';
|
|
241
|
+
import { asciiFromCanvas } from '@zumer/snapdom-plugins/ascii-export';
|
|
239
242
|
|
|
240
|
-
const live =
|
|
243
|
+
const live = stream(el, { fps: 15, onFrame: (frame) => (pre.textContent = asciiFromCanvas(frame.canvas, { width: 100 })) });
|
|
241
244
|
await live.ready;
|
|
242
245
|
live.stop();
|
|
243
246
|
```
|
|
244
247
|
|
|
245
248
|
---
|
|
246
249
|
|
|
247
|
-
### `pdf`
|
|
248
|
-
|
|
249
|
-
Adds `toPdf()`, returning a PDF Blob with the capture's appearance, selectable text,
|
|
250
|
-
links and pagination. MIT licensed.
|
|
251
|
-
It replaces `pdf-image`; there is no second image-only PDF implementation.
|
|
252
|
-
|
|
253
|
-
```js
|
|
254
|
-
import { pdf } from '@zumer/snapdom-plugins/pdf';
|
|
255
|
-
|
|
256
|
-
const result = await snapdom(el, { plugins: [pdf()] });
|
|
257
|
-
const blob = await result.toPdf({ page: 'a4', margin: 36 });
|
|
258
|
-
await result.toPdf({ page: 'letter', download: 'report.pdf' });
|
|
259
|
-
```
|
|
260
|
-
|
|
261
|
-
Configure capture-time measurement on `pdf({ forms, outline, breakAvoid, shadow,
|
|
262
|
-
formValues })`. Configure paper size, orientation, margins, tagging, metadata,
|
|
263
|
-
headers, footers, compression or encryption on `toPdf()`. Downloads are opt-in;
|
|
264
|
-
ordinary exports return a Blob. See [the PDF overview](pdf/README.md) and [full reference](pdf/REFERENCE.md).
|
|
265
|
-
|
|
266
|
-
**Migration:** import `pdf` from `/pdf`, replace `pdfImage()` with `pdf()`, and
|
|
267
|
-
replace `toPdfImage()` with `toPdf({ download: 'capture.pdf' })`. Put orientation
|
|
268
|
-
on the export. The old temporary object-URL return becomes a persistent Blob.
|
|
269
|
-
The default page sizing and pagination differ: choose `page: 'a4'` explicitly.
|
|
270
|
-
|
|
271
|
-
Tagged output alone is not a PDF/UA conformance guarantee. The exporter reports
|
|
272
|
-
eligibility and blockers. Redact source text structurally; covering pixels does
|
|
273
|
-
not remove text from a searchable document.
|
|
274
|
-
|
|
275
|
-
---
|
|
276
|
-
|
|
277
250
|
### `agent-map`
|
|
278
251
|
|
|
279
252
|
Adds `toAgentMap()`: an image with numbered badges on interactive elements and a JSON map
|
|
@@ -423,21 +396,39 @@ The document retains source markup, including event-handler attributes; it is no
|
|
|
423
396
|
|
|
424
397
|
---
|
|
425
398
|
|
|
426
|
-
### `
|
|
399
|
+
### `jxl`
|
|
400
|
+
|
|
401
|
+
Adds `toJxl()`, `toBlob({ format: 'jxl' })` and `download({ format: 'jxl' })`. Text and interface stay
|
|
402
|
+
exact while photos take the quality, in one JPEG XL file. The encoder is [rapier-jxl](https://www.npmjs.com/package/rapier-jxl)
|
|
403
|
+
(MIT), an optional peer: the text measurement loads at the first capture, the encoder at the first export.
|
|
427
404
|
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
405
|
+
```bash
|
|
406
|
+
npm install rapier-jxl
|
|
407
|
+
```
|
|
431
408
|
|
|
432
409
|
```js
|
|
433
|
-
import {
|
|
434
|
-
|
|
435
|
-
const
|
|
436
|
-
await result.
|
|
410
|
+
import { jxl } from '@zumer/snapdom-plugins/jxl';
|
|
411
|
+
|
|
412
|
+
const result = await snapdom(el, { plugins: [jxl()] });
|
|
413
|
+
const img = await result.toJxl({ quality: 0.8 });
|
|
414
|
+
const blob = await result.toBlob({ format: 'jxl' });
|
|
415
|
+
await result.download({ format: 'jxl', filename: 'card' });
|
|
437
416
|
```
|
|
438
417
|
|
|
439
|
-
|
|
440
|
-
|
|
418
|
+
| Option | Type | Default | Description |
|
|
419
|
+
|--------|------|---------|-------------|
|
|
420
|
+
| `module` | `string` | `'rapier-jxl/capture-complete'` | With your `codec`: `'rapier-jxl/capture'` (every pixel exact) or `'rapier-jxl/upload'` (photographic) |
|
|
421
|
+
| `codec` | `object` | none | Your own encoder with `prepare` and `capture` |
|
|
422
|
+
| `decoder` | `object` | none | `createCodec()` from `rapier-jxl/codec/decode`, for `toJxl()` where JPEG XL does not show |
|
|
423
|
+
| `effort` | `number` | `3` | Default effort, 1-9 |
|
|
424
|
+
| `webgpu` | `false \| 'required'` | none | Disable WebGPU, or require a device |
|
|
425
|
+
| `helpers` | `boolean \| object` | none | Helper workers for the encoder the plugin creates |
|
|
426
|
+
|
|
427
|
+
Exports take `toWebp()`'s options, plus `effort`, `signal`, `onProgress` (0 to 1) and `onEncoded` (once).
|
|
428
|
+
`quality: 1` is exact. The plugin's own encoder takes up to 40 megapixels; `plugin.close()` ends its workers.
|
|
429
|
+
|
|
430
|
+
Encoding works in every browser: `toBlob()` and `download()` give `image/jxl`. Where the browser cannot show
|
|
431
|
+
JPEG XL (Edge, for one), `toJxl()` shows the `decoder`'s pixels, or rejects with `JXL_NOT_SHOWN` without one.
|
|
441
432
|
|
|
442
433
|
---
|
|
443
434
|
|
|
@@ -460,14 +451,14 @@ await result.toGif({ download: 'animation.gif' });
|
|
|
460
451
|
|--------|------|---------|-------------|
|
|
461
452
|
| `fps` | `number` | `10` | Frames per second |
|
|
462
453
|
| `duration` | `number` | `2000` | Total duration in ms (ignored if `frames` is set) |
|
|
463
|
-
| `frames` | `number` |
|
|
454
|
+
| `frames` | `number` | none | Explicit frame count (overrides `duration`) |
|
|
464
455
|
| `maxColors` | `number` | `256` | Palette size per frame (2–256) |
|
|
465
456
|
| `background` | `string` | `'#ffffff'` | Color composited under transparent pixels |
|
|
466
457
|
| `scale` | `number` | capture's scale | Capture scale |
|
|
467
458
|
| `repeat` | `number` | `0` | Loop count (`0` = forever, `-1` = play once) |
|
|
468
459
|
| `filename` | `string` | `'capture.gif'` | Download filename |
|
|
469
460
|
|
|
470
|
-
Per-call `opts` override constructor options and accept `download` (`boolean
|
|
461
|
+
Per-call `opts` override constructor options and accept `download` (`boolean | string`).
|
|
471
462
|
Recording starts when `toGif()` runs, including its first frame. It preserves the original
|
|
472
463
|
capture policy, including exclusions and plugins. Frame capture speed limits the sampling rate.
|
|
473
464
|
|
|
@@ -496,36 +487,17 @@ filenames and `download` strings are used as supplied.
|
|
|
496
487
|
|--------|------|---------|-------------|
|
|
497
488
|
| `fps` | `number` | `10` | Frames per second |
|
|
498
489
|
| `duration` | `number` | `2000` | Total duration in ms (ignored if `frames` is set) |
|
|
499
|
-
| `frames` | `number` |
|
|
490
|
+
| `frames` | `number` | none | Explicit frame count (overrides `duration`) |
|
|
500
491
|
| `background` | `string` | `'#ffffff'` | Color composited under transparent pixels |
|
|
501
492
|
| `scale` | `number` | capture's scale | Capture scale |
|
|
502
|
-
| `bitrate` | `number` |
|
|
503
|
-
| `filename` | `string` |
|
|
493
|
+
| `bitrate` | `number` | none | `videoBitsPerSecond` passed to `MediaRecorder` |
|
|
494
|
+
| `filename` | `string` | none | Download filename; the default follows the recorded `.mp4` / `.webm` container |
|
|
504
495
|
|
|
505
496
|
Requires `MediaRecorder` and `canvas.captureStream()`, which may be unavailable in headless
|
|
506
497
|
environments. Per-call `opts` override constructor options and accept `download`
|
|
507
|
-
(`boolean
|
|
498
|
+
(`boolean | string`). Recording starts at the call and preserves capture options as GIF
|
|
508
499
|
recording does. MediaRecorder uses a real-time clock, so slow captures can stretch duration.
|
|
509
500
|
|
|
510
|
-
### `stream`
|
|
511
|
-
|
|
512
|
-
Streams a live element into a canvas that repaints only the boxes that changed, for WebGL
|
|
513
|
-
textures and video overlays. `stream(el, options)` is the entry; `streamExport()` adds the same
|
|
514
|
-
as `toStream()`. Includes `streamTexture(gl)`, which uploads only the changed rects, and
|
|
515
|
-
`recordCanvas(canvas)`.
|
|
516
|
-
|
|
517
|
-
```js
|
|
518
|
-
import { stream, streamTexture } from '@zumer/snapdom-plugins/stream';
|
|
519
|
-
|
|
520
|
-
const tex = streamTexture(gl);
|
|
521
|
-
const live = stream(panel, { scale: 2, onFrame: (frame) => tex.update(frame) });
|
|
522
|
-
```
|
|
523
|
-
|
|
524
|
-
Each patched frame matches a full capture of the same DOM state. Full documentation, options
|
|
525
|
-
and limits: [stream/README.md](stream/README.md).
|
|
526
|
-
|
|
527
|
-
---
|
|
528
|
-
|
|
529
501
|
## Plugin registration
|
|
530
502
|
|
|
531
503
|
**Global** (applies to all captures):
|
|
@@ -564,7 +536,7 @@ See [PLUGIN_SPEC.md](../../PLUGIN_SPEC.md) for the full hook specification and [
|
|
|
564
536
|
|
|
565
537
|
## Live demos
|
|
566
538
|
|
|
567
|
-
Run `npm run compile` and `npm run site` from the monorepo root, then open `/
|
|
539
|
+
Run `npm run compile` and `npm run site` from the monorepo root, then open `/plugins/` (one page per plugin, each with its demo) or `/showcase/` for every demo on one page. The demos generate actual files from editable DOM samples.
|
|
568
540
|
|
|
569
541
|
## Releasing from the repository root
|
|
570
542
|
|
|
@@ -576,7 +548,18 @@ npm run release:plugins
|
|
|
576
548
|
npm run publish:plugins
|
|
577
549
|
```
|
|
578
550
|
|
|
579
|
-
`release:plugins` commits the plugin version, the lockfile and the changelog, then pushes. `publish:plugins` runs the
|
|
551
|
+
`release:plugins` commits the plugin version, the lockfile and the changelog, then pushes. `publish:plugins` runs the packaging check (`scripts/check-pack.mjs`), then publishes only `@zumer/snapdom-plugins` under `latest`. PDF, Vector and Stream have the same scripts under their own suffix (`bump:pdf`, `release:pdf`, `publish:pdf`, `publish:pdf:dev`). `bump:plugins` runs `@zumerbox/bump` followed by `@zumerbox/changelog` inside the plugin workspace, matching the core's tools. The bump command requires a clean Git working tree and prompts for the next version. It updates the plugin version and root lockfile; the changelog command writes `packages/plugins/CHANGELOG.md`. `bump:plugins:dry` previews the bump without updating the version or changelog. Skip the bump if the version has already been prepared.
|
|
552
|
+
|
|
553
|
+
## Migrating from 4.x
|
|
554
|
+
|
|
555
|
+
The `/pdf`, `/vector` and `/stream` subpaths are gone. Install the package you use and change the import; options and behavior are unchanged.
|
|
556
|
+
|
|
557
|
+
| 4.x | 5.x |
|
|
558
|
+
|-----|-----|
|
|
559
|
+
| `import { pdf } from '@zumer/snapdom-plugins/pdf'` | `import { pdf } from '@zumer/snapdom-pdf'` |
|
|
560
|
+
| `import { vector } from '@zumer/snapdom-plugins/vector'` | `import { vector } from '@zumer/snapdom-vector'` |
|
|
561
|
+
| `import { stream } from '@zumer/snapdom-plugins/stream'` | `import { stream } from '@zumer/snapdom-stream'` |
|
|
562
|
+
| `asciiStream(el, options)` | `stream(el, { onFrame: (f) => onText(asciiFromCanvas(f.canvas, options)) })` |
|
|
580
563
|
|
|
581
564
|
## License
|
|
582
565
|
|
package/ascii-export.d.ts
CHANGED
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
* at capture time.
|
|
7
7
|
*/
|
|
8
8
|
import type { SnapdomPlugin } from '@zumer/snapdom';
|
|
9
|
-
import type { Stream, StreamOptions, StreamFrame } from './stream.js';
|
|
10
9
|
|
|
11
10
|
export interface AsciiExportOptions {
|
|
12
11
|
/** Character width of the output. */
|
|
@@ -32,9 +31,3 @@ declare module '@zumer/snapdom' {
|
|
|
32
31
|
toAscii(options?: AsciiExportOptions): Promise<string>;
|
|
33
32
|
}
|
|
34
33
|
}
|
|
35
|
-
|
|
36
|
-
/** `stream()` plus `asciiFromCanvas()` on every frame; `onText` receives the text (or HTML when `format: 'html'`). */
|
|
37
|
-
export declare function asciiStream(
|
|
38
|
-
element: Element,
|
|
39
|
-
options?: AsciiExportOptions & { charset?: string | string[] } & StreamOptions & { onText?: (text: string, frame: StreamFrame) => void }
|
|
40
|
-
): Stream;
|
package/ascii-export.js
CHANGED
|
@@ -12,8 +12,6 @@
|
|
|
12
12
|
* @param {number} [options.contrast=0] - Non-negative luminance contrast boost
|
|
13
13
|
* @returns {Object} SnapDOM plugin
|
|
14
14
|
*/
|
|
15
|
-
import { stream } from './stream.js';
|
|
16
|
-
|
|
17
15
|
export function asciiExport(options = {}) {
|
|
18
16
|
const {
|
|
19
17
|
width: charWidth = 80,
|
|
@@ -102,22 +100,3 @@ export function asciiFromCanvas(source, options = {}) {
|
|
|
102
100
|
}
|
|
103
101
|
return colored ? ascii + '</pre>' : ascii;
|
|
104
102
|
}
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Stream a live element as ASCII: `stream()` keeps a canvas in step with the element and every
|
|
108
|
-
* frame is converted with `asciiFromCanvas()`. Returns the stream handle (`ready`, `stats`, `stop()`).
|
|
109
|
-
* @param {Element} element
|
|
110
|
-
* @param {Object} [options] - ascii options (width, charset, invert, format, contrast) plus stream
|
|
111
|
-
* options (fps, scale, plugins, ...) and `onText(text, frame)`, called after each repaint.
|
|
112
|
-
*/
|
|
113
|
-
export function asciiStream(element, options = {}) {
|
|
114
|
-
const { width, charset, invert, format, contrast, onText, onFrame, ...streamOptions } = options;
|
|
115
|
-
const ascii = { width, charset, invert, format, contrast };
|
|
116
|
-
return stream(element, {
|
|
117
|
-
...streamOptions,
|
|
118
|
-
onFrame(frame) {
|
|
119
|
-
onFrame?.(frame);
|
|
120
|
-
onText?.(asciiFromCanvas(frame.canvas, ascii), frame);
|
|
121
|
-
},
|
|
122
|
-
});
|
|
123
|
-
}
|
package/index.d.ts
CHANGED
|
@@ -11,11 +11,8 @@ export * from './replace-text.js';
|
|
|
11
11
|
export * from './timestamp-overlay.js';
|
|
12
12
|
export * from './redact-inputs.js';
|
|
13
13
|
export * from './ascii-export.js';
|
|
14
|
-
export * from './pdf.js';
|
|
15
14
|
export * from './html-export.js';
|
|
16
15
|
export * from './gif-export.js';
|
|
17
16
|
export * from './video-export.js';
|
|
18
17
|
export * from './agent-map.js';
|
|
19
18
|
export * from './context-export.js';
|
|
20
|
-
export * from './vector.js';
|
|
21
|
-
export * from './stream.js';
|
package/index.js
CHANGED
|
@@ -7,16 +7,13 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
export { timestampOverlay } from './timestamp-overlay.js';
|
|
10
|
-
export { asciiExport, asciiFromCanvas
|
|
10
|
+
export { asciiExport, asciiFromCanvas } from './ascii-export.js';
|
|
11
11
|
export { replaceText } from './replace-text.js';
|
|
12
12
|
export { redactInputs } from './redact-inputs.js';
|
|
13
13
|
export { filter } from './filter.js';
|
|
14
14
|
export { colorTint } from './color-tint.js';
|
|
15
|
-
export { pdf } from './pdf.js';
|
|
16
15
|
export { agentMap } from './agent-map.js';
|
|
17
16
|
export { contextExport } from './context-export.js';
|
|
18
17
|
export { htmlExport } from './html-export.js';
|
|
19
18
|
export { gifExport } from './gif-export.js';
|
|
20
19
|
export { videoExport } from './video-export.js';
|
|
21
|
-
export { vector } from './vector.js';
|
|
22
|
-
export { stream, streamExport, streamTexture, recordCanvas, overlayStage, scoreboard, lowerThird, ticker, liveBadge } from './stream.js';
|
package/jxl.d.ts
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type declarations for `@zumer/snapdom-plugins/jxl`.
|
|
3
|
+
*
|
|
4
|
+
* The plugin instance type comes from the core package: one definition of what a plugin IS,
|
|
5
|
+
* so a plugin that stops matching the host's contract fails to typecheck instead of failing
|
|
6
|
+
* at capture time. Nothing here imports rapier-jxl, an optional peer dependency.
|
|
7
|
+
*/
|
|
8
|
+
import type { SnapdomPlugin } from '@zumer/snapdom';
|
|
9
|
+
|
|
10
|
+
/** Every pixel exact, efforts 1-5. */
|
|
11
|
+
export type ExactCaptureModule = 'rapier-jxl/capture';
|
|
12
|
+
/** Photographic capture, efforts 1-3. */
|
|
13
|
+
export type UploadCaptureModule = 'rapier-jxl/upload';
|
|
14
|
+
/** Exact text and lossy photos in one file, efforts 1-9. The default. */
|
|
15
|
+
export type CompleteCaptureModule = 'rapier-jxl/capture-complete';
|
|
16
|
+
export type JxlCaptureModule = ExactCaptureModule | UploadCaptureModule | CompleteCaptureModule;
|
|
17
|
+
|
|
18
|
+
/** Higher effort takes longer to encode, usually for a smaller file. */
|
|
19
|
+
export type JxlEffort = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
|
|
20
|
+
|
|
21
|
+
/** Reported once for the file the export returns. */
|
|
22
|
+
export interface JxlEncodedRecord {
|
|
23
|
+
/** True when every pixel of the file is exact. */
|
|
24
|
+
exact: boolean;
|
|
25
|
+
bands?: number;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Your own encoder: a rapier-jxl codec (`createCodec`) or a directly imported capture module. */
|
|
29
|
+
export interface JxlEncoder {
|
|
30
|
+
prepare(kind: 'capture'): Promise<void>;
|
|
31
|
+
capture(input: HTMLCanvasElement, options: Record<string, unknown>): Promise<{
|
|
32
|
+
fits: boolean;
|
|
33
|
+
bytes?: Uint8Array;
|
|
34
|
+
reason?: { code?: string; message?: string };
|
|
35
|
+
}>;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** Helper workers for a codec the plugin creates; `count: 0` may omit `memoryBytes`. */
|
|
39
|
+
/** `memoryBytes` bounds the helpers' memory; it is required for a `count` above 0. */
|
|
40
|
+
export type JxlHelpers = boolean | { count: 0; memoryBytes?: number } | { count: number; memoryBytes: number };
|
|
41
|
+
|
|
42
|
+
/** A decoder for `toJxl()` where the browser cannot show JPEG XL: `createCodec()` from `rapier-jxl/codec/decode`. */
|
|
43
|
+
export interface JxlDecoder {
|
|
44
|
+
decode(input: Blob, options: Record<string, unknown>): Promise<{ data: Uint8Array; width: number; height: number }>;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface JxlOptions {
|
|
48
|
+
/** Default `'rapier-jxl/capture-complete'`, which the plugin creates; the others need your `codec`. */
|
|
49
|
+
module?: JxlCaptureModule;
|
|
50
|
+
/** Your own encoder; the plugin then creates none and ignores `helpers`. */
|
|
51
|
+
codec?: JxlEncoder;
|
|
52
|
+
/** Without one, `toJxl()` rejects with `JXL_NOT_SHOWN` where the browser cannot show JPEG XL. */
|
|
53
|
+
decoder?: JxlDecoder;
|
|
54
|
+
/** Default effort for each export (3 when omitted); an export's `effort` wins. */
|
|
55
|
+
effort?: JxlEffort;
|
|
56
|
+
/** `false` disables WebGPU; `'required'` requires a device for work that uses it. */
|
|
57
|
+
webgpu?: false | 'required';
|
|
58
|
+
helpers?: JxlHelpers;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** `toWebp()`'s options with the same defaults, plus effort and the encoding callbacks. */
|
|
62
|
+
export interface JxlExportOptions {
|
|
63
|
+
/** Default 0.92. Below 1, photos take this quality; 1 is exact. */
|
|
64
|
+
quality?: number;
|
|
65
|
+
scale?: number;
|
|
66
|
+
width?: number;
|
|
67
|
+
height?: number;
|
|
68
|
+
dpr?: number;
|
|
69
|
+
/** Default `'#ffffff'`. */
|
|
70
|
+
backgroundColor?: string | null;
|
|
71
|
+
filename?: string;
|
|
72
|
+
format?: string;
|
|
73
|
+
effort?: JxlEffort;
|
|
74
|
+
signal?: AbortSignal;
|
|
75
|
+
/** Encoding progress from 0 to 1, after SnapDOM draws. */
|
|
76
|
+
onProgress?: (fraction: number) => void;
|
|
77
|
+
onEncoded?: (record: JxlEncodedRecord) => void;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Adds `result.toJxl()` (an `<img>`), `toBlob({ format: 'jxl' })` (the file) and
|
|
82
|
+
* `download({ format: 'jxl' })`. Install rapier-jxl next to the plugins.
|
|
83
|
+
*/
|
|
84
|
+
export declare function jxl(options?: JxlOptions): JxlPlugin;
|
|
85
|
+
|
|
86
|
+
export interface JxlPlugin extends SnapdomPlugin {
|
|
87
|
+
/** Ends the encoder the plugin created (never your own `codec` or `decoder`); a later export creates it again. */
|
|
88
|
+
close(): Promise<void>;
|
|
89
|
+
}
|
|
90
|
+
export default jxl;
|
|
91
|
+
|
|
92
|
+
declare module '@zumer/snapdom' {
|
|
93
|
+
interface CaptureResult {
|
|
94
|
+
toJxl(options?: JxlExportOptions): Promise<HTMLImageElement>;
|
|
95
|
+
toBlob(options: JxlExportOptions & { format: 'jxl' }): Promise<Blob>;
|
|
96
|
+
download(options: JxlExportOptions & { format: 'jxl' }): Promise<void>;
|
|
97
|
+
}
|
|
98
|
+
}
|