@zumer/snapdom 3.1.1-dev.1 → 3.1.2-dev.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 +22 -1
- package/dist/snapdom.js +9 -9
- package/dist/snapdom.mjs +9 -9
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -175,6 +175,27 @@ const result = await snapdom(card, {
|
|
|
175
175
|
|
|
176
176
|
[All options](https://snapdom.dev/docs/options/) include shadows, transforms, fonts, CORS, fallbacks and layout reconciliation.
|
|
177
177
|
|
|
178
|
+
### Export a long page in pieces
|
|
179
|
+
|
|
180
|
+
A canvas cannot be taller than 16,384px in Safari or 32,767px in Chrome and Firefox. Past that, a single image is scaled down to fit. To keep full resolution, capture once and export it in pieces with `crop`:
|
|
181
|
+
|
|
182
|
+
```js
|
|
183
|
+
const capture = await snapdom(article);
|
|
184
|
+
const { contentX, contentY, w0, h0 } = capture.meta;
|
|
185
|
+
const pieceHeight = 4000; // CSS px
|
|
186
|
+
|
|
187
|
+
for (let y = 0; y < h0; y += pieceHeight) {
|
|
188
|
+
const canvas = await capture.toCanvas({
|
|
189
|
+
scale: 2,
|
|
190
|
+
dpr: 1,
|
|
191
|
+
crop: { x: contentX, y: contentY + y, width: w0, height: Math.min(pieceHeight, h0 - y) }
|
|
192
|
+
});
|
|
193
|
+
// save or upload this piece, then move on
|
|
194
|
+
}
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
`crop` is a rectangle, not a switch. It is in the coordinates of `capture.meta`, and each call returns one canvas. The capture runs once; only the rasterization repeats. Keep `pieceHeight × scale × dpr` under the limit, and set `dpr` yourself, since it defaults to the device pixel ratio. [How tiling works](https://snapdom.dev/blog/huge-page-mosaic/).
|
|
198
|
+
|
|
178
199
|
### Export HTML or structured context
|
|
179
200
|
|
|
180
201
|
Official plugins are published separately as `@zumer/snapdom-plugins` and must match the core major version; they declare a peer dependency on a v3 core. Their sources live in `packages/plugins/` in this checkout.
|
|
@@ -297,7 +318,7 @@ Capture-affecting plugins suspend memoization unless they declare `pure: true`.
|
|
|
297
318
|
- SnapDOM needs a browser DOM. A server-side Node.js process needs a browser environment to run it.
|
|
298
319
|
- Cross-origin images, fonts and stylesheets need readable resources or an appropriate proxy. `crossorigin` does not grant access unless the server also allows it. Cross-origin iframes use placeholders.
|
|
299
320
|
- SVG output includes HTML inside `<foreignObject>`. It is suitable for browsers; support varies in other SVG viewers and document tools.
|
|
300
|
-
- Output depends on browser rendering and canvas limits. Safari may fall back to PNG when WebP encoding is unavailable.
|
|
321
|
+
- Output depends on browser rendering and canvas limits; for tall pages see [Export a long page in pieces](#export-a-long-page-in-pieces). Safari may fall back to PNG when WebP encoding is unavailable.
|
|
301
322
|
- Canvas, video and other changing surfaces are captured fresh. JavaScript CSSOM edits are not observable automatically; use `invalidate: true` after them.
|
|
302
323
|
- Core captures visible input values. Semantic plugins redact sensitive field values in their text/map output, but their attached image needs `redactInputs` or `exclude` if you want those pixels hidden too.
|
|
303
324
|
|