@zumer/snapdom-plugins 6.0.0 → 6.0.1

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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # Plugin changes
2
2
 
3
+ ## 6.0.1
4
+
5
+ > 2 December 2026
6
+
7
+ **Fixes**
8
+
9
+ - **core:** a capture of <html> keeps the margins inside it [`#586`](https://github.com/zumerlab/snapdom/pull/586)
10
+
11
+ **Chores**
12
+
13
+ - **plugins:** require SnapDOM 3.9.0 [`9d44fcb`](https://github.com/zumerlab/snapdom/commit/9d44fcb498b1cc0022861de179c046f0f702e408)
14
+
3
15
  ## 6.0.0
4
16
 
5
17
  > 17 November 2026
package/README.md CHANGED
@@ -21,7 +21,7 @@ Install the plugins next to a core supported by their peer dependency:
21
21
  npm install @zumer/snapdom@latest @zumer/snapdom-plugins@latest
22
22
  ```
23
23
 
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.
24
+ Plugins 6.0.1 and later require SnapDOM 3.9.0 or newer within 3.x (the jxl plugin measures a capture of `<html>` as 3.9.0 draws it) 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.
25
25
 
26
26
  ## Usage
27
27
 
package/jxl.js CHANGED
@@ -50,7 +50,7 @@ function create(module, codec, preset, webgpu) {
50
50
  const keep = context.nodeMap ? new Set(context.nodeMap.values()) : undefined;
51
51
  // The measurement serves this plugin's exports only: one that fails rejects a JPEG XL export, never another.
52
52
  try {
53
- context[SNAPSHOT] = element ? { ...measured(measure, element, edges, keep), frame: frameOf(element, context.outerTransforms !== false) } : null;
53
+ context[SNAPSHOT] = element ? { ...measure(element, { edges, keep }), frame: frameOf(element, context.outerTransforms !== false) } : null;
54
54
  } catch (error) {
55
55
  context[SNAPSHOT] = { error };
56
56
  }
@@ -202,60 +202,6 @@ const MODULES = [COMPLETE, 'jpegxl/capture', 'jpegxl/upload'];
202
202
  const door = () => complete ??= import('jpegxl/capture-complete').catch(error => { complete = null; throw needs(error); });
203
203
  const needs = error => new Error('The jxl plugin needs jpegxl 8.4.0 or later: npm install jpegxl', { cause: error });
204
204
 
205
- // SnapDOM draws <html> without the top margins that collapse through its first children (<body>'s
206
- // own included), so what lies in <body>'s flow is drawn higher by that much; a box positioned on the
207
- // page itself is not. Those boxes are measured on their own, and the rest moves up.
208
- function measured(measure, element, edges, keep) {
209
- const lift = keep ? liftOf(element) : 0;
210
- if (!lift) return measure(element, { edges, keep });
211
- const placed = onPage(element.ownerDocument.body), inFlow = new Set(keep);
212
- for (const el of placed) inFlow.delete(el);
213
- const up = r => ({ ...r, top: r.top - lift, bottom: r.bottom - lift });
214
- const shot = measure(element, { edges, keep: inFlow });
215
- shot.text = shot.text.map(t => ({ ...t, r: up(t.r) }));
216
- shot.photos = shot.photos.map(up);
217
- if (shot.edges) shot.edges = shot.edges.map(up);
218
- for (const el of placed) {
219
- if (!keep.has(el)) continue;
220
- const own = measure(el, { edges, keep });
221
- shot.text.push(...own.text);
222
- shot.photos.push(...own.photos);
223
- if (shot.edges) shot.edges.push(...own.edges);
224
- }
225
- return shot;
226
- }
227
-
228
- function liftOf(element) {
229
- const doc = element.ownerDocument, body = doc?.body;
230
- if (element !== doc?.documentElement || !body) return 0;
231
- const s = getComputedStyle(element);
232
- // As SnapDOM decides it: an edge with a border or padding, or a root that starts its own block
233
- // formatting context, keeps the margins.
234
- if (parseFloat(s.borderTopWidth) || parseFloat(s.paddingTop) || /flex|grid|table|inline-block|flow-root/.test(s.display) ||
235
- s.position === 'absolute' || s.position === 'fixed' || s.float !== 'none' || s.overflowX !== 'visible' || s.overflowY !== 'visible' ||
236
- /layout|content|paint|strict/.test(s.contain)) return 0;
237
- // A relatively positioned <body> keeps its offset in the clone.
238
- const b = getComputedStyle(body), moved = b.position === 'relative' ? parseFloat(b.top) || 0 : 0;
239
- return body.getBoundingClientRect().top - moved - element.getBoundingClientRect().top;
240
- }
241
-
242
- // The outermost absolute or fixed boxes in <body> whose containing block is the page.
243
- function onPage(body) {
244
- const placed = [];
245
- const fixedBlock = s => s.transform !== 'none' || s.perspective !== 'none' || s.filter !== 'none' ||
246
- /layout|content|paint|strict/.test(s.contain) || /transform|perspective|filter/.test(s.willChange);
247
- const visit = (el, absolute, fixed) => {
248
- for (const child of el.children) {
249
- const s = getComputedStyle(child);
250
- if (s.position === 'absolute' && absolute || s.position === 'fixed' && fixed) { placed.push(child); continue; }
251
- visit(child, absolute && s.position === 'static' && !fixedBlock(s), fixed && !fixedBlock(s));
252
- }
253
- };
254
- const s = getComputedStyle(body);
255
- visit(body, s.position === 'static' && !fixedBlock(s), !fixedBlock(s));
256
- return placed;
257
- }
258
-
259
205
  // How the page shows the capture root: the viewport point of its layout corner, the scale of the
260
206
  // ancestors and the root's own transform. null where an ancestor rotates or skews it, or a
261
207
  // transform cannot be read: the export then keeps the whole capture exact.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zumer/snapdom-plugins",
3
- "version": "6.0.0",
3
+ "version": "6.0.1",
4
4
  "description": "Official plugin toolbox for SnapDOM: prepare, export and record captures",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -53,7 +53,7 @@
53
53
  "url": "https://github.com/sponsors/tinchox5"
54
54
  },
55
55
  "peerDependencies": {
56
- "@zumer/snapdom": "^3.4.0",
56
+ "@zumer/snapdom": "^3.9.0",
57
57
  "jpegxl": "^8.4.0"
58
58
  },
59
59
  "peerDependenciesMeta": {