@zumer/snapdom-plugins 4.3.0 → 4.4.1-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/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Plugin changes
2
2
 
3
+ ## 4.4.0
4
+
5
+ > 27 October 2026
6
+
7
+ **Features**
8
+
9
+ - **stream:** add animations: false to stop following running animations [`932df5e`](https://github.com/zumerlab/snapdom/commit/932df5e7620ebcd9d5206d16fbd683383d77e0b3)
10
+
3
11
  ## 4.3.0
4
12
 
5
13
  > 25 October 2026
package/README.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # @zumer/snapdom-plugins
2
2
 
3
+ [![NPM version](https://img.shields.io/npm/v/@zumer/snapdom-plugins?style=flat-square&label=Plugins)](https://www.npmjs.com/package/@zumer/snapdom-plugins)
4
+ [![Core version](https://img.shields.io/npm/v/@zumer/snapdom?style=flat-square&label=SnapDOM)](https://www.npmjs.com/package/@zumer/snapdom)
5
+
3
6
  Official plugins for [SnapDOM](https://github.com/zumerlab/snapdom), a high-performance DOM engine
4
7
  that exports a rendered element as PNG, SVG or canvas in the browser. Core exports images and
5
8
  canvases; this package adds HTML, structured context, element maps, PDF, editable vectors, ASCII,
@@ -178,9 +181,9 @@ The built-in mask without custom selectors permits reuse of unchanged captures.
178
181
  masks and nonempty `selector`, `blocks` or `attributes` rules run on every capture. Changed
179
182
  content runs the full pipeline so no field skips redaction.
180
183
 
181
- Nonempty `blocks` or `attributes` rules add a final `beforeRender` pass. In builds with the
182
- experimental `engine: 'html-in-canvas'` enabled, that pass makes the capture use the SVG
183
- renderer. Field-only redaction does not add this pass.
184
+ Nonempty `blocks` or `attributes` rules add a final `beforeRender` pass, which makes a capture
185
+ requested with `engine: 'html-in-canvas'` use the SVG renderer. Field-only redaction does not
186
+ add this pass.
184
187
 
185
188
  `agent-map` and `context-export` omit sensitive values and mask other typed values in their
186
189
  structured state fields. Ordinary page text and labels remain. An attached image still
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zumer/snapdom-plugins",
3
- "version": "4.3.0",
3
+ "version": "4.4.1-dev.0",
4
4
  "description": "Official plugins for SnapDOM",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -38,6 +38,6 @@ export interface RedactInputsOptions {
38
38
  * Optional blocks exclude whole subtrees; attribute rules remove named attributes. The live DOM is unchanged.
39
39
  * These rules do not search captured text or images for sensitive content.
40
40
  * The default mask without selectors permits unchanged-repeat memoization; custom masks and selectors run every capture.
41
- * Nonempty blocks/attribute rules add a beforeRender pass, so experimental html-in-canvas captures use SVG.
41
+ * Nonempty blocks/attribute rules add a beforeRender pass, so html-in-canvas captures use SVG.
42
42
  */
43
43
  export declare function redactInputs(options?: RedactInputsOptions): SnapdomPlugin;
package/stream/README.md CHANGED
@@ -21,8 +21,11 @@ live.stop();
21
21
 
22
22
  The first frame is a full capture. After that, every change (mutations, typing, focus, hover,
23
23
  running animations) is traced to the nearest box that can be repainted on its own, and only
24
- that subtree is captured and drawn into its rect. A frame that cannot be patched exactly is a
25
- full frame, and `frame.reason` says why (`'root resized'`, `'no host for <div.x>'`, ...).
24
+ that subtree is captured and drawn into its rect. A change in a box that cannot (a value on a
25
+ translucent card, a row under a badge) repaints a window of the element instead: a `clip`
26
+ capture of that box, with everything that paints there. The pointer repaints only what a
27
+ `:hover` rule restyles. A frame that cannot be patched exactly is a full frame, and
28
+ `frame.reason` says why (`'root resized'`, `'no host for <div.x>'`, ...).
26
29
  A keyframe in idle time heals anything the change tracking could not see, at most every 2 s
27
30
  and never more than 2% of the main thread.
28
31
 
@@ -46,6 +49,7 @@ All [capture options](https://snapdom.dev/) apply (`scale`, `dpr`, `embedFonts`,
46
49
  | `onFrame(frame)` | | called after each repaint: `{ full, reason, rects, ms, canvas }` |
47
50
  | `fps` | every animation frame | upper bound on repaints per second |
48
51
  | `patches` | `true` | `false` repaints full frames only, for comparison |
52
+ | `animations` | `true` | `false` stops following running animations and transitions: an animated box keeps the pixels it was last drawn with until a patch over it, a full frame or the keyframe. For a still of the page, where a spinner's angle does not matter but its full frames would |
49
53
 
50
54
  `stream()` returns `{ canvas, ready, stats, stop() }`.
51
55
 
@@ -10,8 +10,11 @@
10
10
  * was restyled hands the change to the enclosing box that did not; an absolutely positioned
11
11
  * box over a solid or clear backdrop may move and resize itself, since it pushes nothing.
12
12
  * Only that subtree is captured, laid out at its subpixel phase, and drawn over its backdrop
13
- * or where it is fully opaque. Anything this cannot prove is a full frame, with the reason
14
- * on the frame.
13
+ * or where it is fully opaque. A change with no such box (a value on a glass card, a row
14
+ * under a badge) repaints a window of the root: a `clip` capture of the box the change stayed
15
+ * inside, which has everything that paints there. Anything this cannot prove is a full
16
+ * frame, with the reason on the frame. The pointer counts only through `:hover` rules: a move
17
+ * repaints the elements whose match it changed.
15
18
  *
16
19
  * Measured 2026-10-23, 1000px grid, one card's text changed per frame, median ms per frame
17
20
  * (full / patch): 400 cards Chromium 11.7 / 4.2, Firefox 28 / 4, WebKit 20 / 4; 2000 cards
@@ -34,6 +37,13 @@ const WEBKIT = typeof navigator !== 'undefined' && (/ipad|iphone|ipod/i.test(nav
34
37
  (/applewebkit/i.test(navigator.userAgent) && !/chrome|chromium|crios|edg|opr|android/i.test(navigator.userAgent)))
35
38
 
36
39
  const EVENTS = ['input', 'change', 'focusin', 'focusout', 'pointerover', 'pointerout', 'scroll', 'toggle']
40
+ const HOVER_EVENTS = new Set(['pointerover', 'pointerout'])
41
+ /** :hover selectors x nodes one hover query may cost. A query is linear in both: 200 x 1400
42
+ * took 1.5 to 1.75 ms on all three engines, 2000 x 1400 took 13 to 30. Past it the pointer
43
+ * repaints whatever it crosses, as it did before the query. */
44
+ const HOVER_BUDGET = 300_000
45
+ /** Cut from a :hover selector, so it matches the box the pseudo-element hangs from. */
46
+ const PSEUDO_ELEMENT = /::?(?:before|after|first-line|first-letter)\b|::[\w-]+(?:\([^)]*\))?/g
37
47
  /** A patch larger than this share of the frame costs about what a full frame does. */
38
48
  const MAX_PATCH_AREA = 0.5
39
49
  /** Self-healing keyframe: anything the heuristics missed lasts at most this long, or 50
@@ -57,10 +67,48 @@ function hasEffect(cs) {
57
67
  cs.clipPath !== 'none' || (cs.backdropFilter && cs.backdropFilter !== 'none')
58
68
  }
59
69
 
70
+ /** A filter that carries a change past the box it happened in. */
71
+ function spreads(cs) {
72
+ return /blur|drop-shadow|url\(/.test(cs.filter)
73
+ }
74
+
60
75
  function clips(cs) {
61
76
  return cs.overflowX !== 'visible' || cs.overflowY !== 'visible'
62
77
  }
63
78
 
79
+ /** Visible overflow paints outside the box. */
80
+ function overflows(el, cs) {
81
+ return !clips(cs) && (el.scrollWidth > el.clientWidth + 1 || el.scrollHeight > el.clientHeight + 1)
82
+ }
83
+
84
+ /** A shadow or outline paints outside the box. */
85
+ function outerInk(cs) {
86
+ return cs.boxShadow !== 'none' || (cs.outlineStyle !== 'none' && parseFloat(cs.outlineWidth) > 0)
87
+ }
88
+
89
+ /** Every selector that names :hover; null when a sheet cannot be read (cross origin) or a
90
+ * nested `&` rule cannot be queried, and then any hover may restyle. Pseudo-elements are
91
+ * cut: `.dot:hover::after` repaints with `.dot`. */
92
+ function hoverSelectors(root) {
93
+ const list = []
94
+ const walk = (rules) => {
95
+ for (const rule of rules) {
96
+ const sel = rule.selectorText
97
+ if (sel?.includes(':hover')) {
98
+ if (sel.includes('&')) throw new Error('nested')
99
+ list.push(sel.replace(PSEUDO_ELEMENT, ''))
100
+ }
101
+ if (rule.cssRules) walk(rule.cssRules)
102
+ if (rule.styleSheet) walk(rule.styleSheet.cssRules)
103
+ }
104
+ }
105
+ const scope = root.getRootNode()
106
+ try {
107
+ for (const sheet of [...scope.styleSheets, ...(scope.adoptedStyleSheets || [])]) walk(sheet.cssRules)
108
+ } catch { return null }
109
+ return list
110
+ }
111
+
64
112
  function inside(a, b) {
65
113
  return a.left >= b.left - 0.5 && a.top >= b.top - 0.5 && a.right <= b.right + 0.5 && a.bottom <= b.bottom + 0.5
66
114
  }
@@ -137,10 +185,15 @@ async function decode(url) {
137
185
  * @param {(frame: {full: boolean, reason: string|null, rects: {x:number,y:number,width:number,height:number}[], ms: number, canvas: HTMLCanvasElement}) => void} [options.onFrame]
138
186
  * @param {number} [options.fps] - cap on frames per second; default every animation frame.
139
187
  * @param {boolean} [options.patches=true] - false repaints full frames only (the baseline).
188
+ * @param {boolean} [options.animations=true] - false stops following running animations and
189
+ * transitions: an animated box keeps its last drawn pixels until a patch, a full frame or the
190
+ * keyframe repaints it. A transparent spinner has no host and turns its own box, so by default
191
+ * nearly every tick is a full frame (Zumly views at dpr 2, fps 5: 109 ms a frame, against
192
+ * 9-13 ms patches without it).
140
193
  * @returns {{canvas: HTMLCanvasElement, stop: () => void, ready: Promise<void>, stats: object}}
141
194
  */
142
195
  export function stream(element, options = {}) {
143
- const { onFrame, fps, patches = true, ...rest } = options
196
+ const { onFrame, fps, patches = true, animations = true, ...rest } = options
144
197
  const opts = { ...rest, outerShadows: false, dpr: rest.dpr ?? (globalThis.devicePixelRatio || 1) }
145
198
  const k = (opts.scale ?? 1) * opts.dpr
146
199
  const canvas = document.createElement('canvas')
@@ -150,8 +203,14 @@ export function stream(element, options = {}) {
150
203
  const rects = new WeakMap() // element -> rect at the last paint that covered it
151
204
  const backdrops = new Map() // this frame's hosts that draw over a solid colour
152
205
  const movedFrom = new Map() // this frame's out-of-flow hosts that moved -> their old rect
206
+ const regions = new Set() // this frame's hosts repainted as a window of the root
153
207
  const stats = { full: 0, patch: 0, skipped: 0, lastMs: 0 }
154
208
  let floaters = []
209
+ let glass = [] // backdrop-filter boxes: a change under one shows through its blur
210
+ let hoverList = null // the :hover selectors at the last full frame, null if unreadable
211
+ let hovered = new Set() // what they matched at the last look
212
+ let hoverMoved = false
213
+ let nodes = 0 // in the root at the last full frame, the root included
155
214
  let forceFull = true
156
215
  let lastKeyframe = 0
157
216
  let keyframeDue = false // set from idle time once the keyframe interval has passed
@@ -167,6 +226,13 @@ export function stream(element, options = {}) {
167
226
  const observer = new MutationObserver(records => netTargets(records, dirty, restyled))
168
227
  observer.observe(element, { subtree: true, childList: true, attributes: true, characterData: true, attributeOldValue: true, characterDataOldValue: true })
169
228
  const onEvent = (e) => {
229
+ // A pointer that crosses boxes no :hover rule matches changes no pixel. Moving over the
230
+ // gaps of a 48-tile board made its root dirty, and every move a 300 ms full frame (Zumly,
231
+ // dpr 2). A shadow tree's event arrives at its host, and its sheets were not read.
232
+ if (hoverList !== null && HOVER_EVENTS.has(e.type) && e.composedPath()[0] === e.target) {
233
+ hoverMoved = true
234
+ return
235
+ }
170
236
  dirty.add(e.target)
171
237
  if (e.relatedTarget && element.contains(e.relatedTarget)) dirty.add(e.relatedTarget)
172
238
  }
@@ -203,14 +269,26 @@ export function stream(element, options = {}) {
203
269
  function snapshotLayout() {
204
270
  rootRect = element.getBoundingClientRect()
205
271
  floaters = []
206
- for (const el of element.querySelectorAll('*')) {
272
+ glass = []
273
+ const all = element.querySelectorAll('*')
274
+ nodes = all.length + 1
275
+ for (const el of all) {
207
276
  rects.set(el, rectOf(el))
208
277
  const cs = getComputedStyle(el)
209
278
  if (cs.position === 'absolute' || cs.position === 'fixed' || cs.position === 'sticky' ||
210
279
  (cs.position === 'relative' && cs.zIndex !== 'auto') || cs.transform !== 'none') floaters.push(el)
280
+ if (cs.backdropFilter && cs.backdropFilter !== 'none') glass.push(el)
211
281
  }
212
282
  }
213
283
 
284
+ /** The elements the :hover rules match now, the root included. */
285
+ function hoverMatches() {
286
+ if (!hoverList) return new Set()
287
+ const out = new Set(element.querySelectorAll(hoverList))
288
+ if (element.matches(hoverList)) out.add(element)
289
+ return out
290
+ }
291
+
214
292
  /** The box a change to `node` can be repainted through, or null for a full frame. */
215
293
  function hostFor(node) {
216
294
  let el = node?.nodeType === 1 ? node : node?.parentElement
@@ -223,8 +301,8 @@ export function stream(element, options = {}) {
223
301
  for (let i = start; i < chain.length; i++) {
224
302
  const cs = styles[i]
225
303
  if (!opaqueColor(cs.backgroundColor)) continue
226
- // Visible overflow paints outside the box, over pixels the patch does not repaint.
227
- if (!clips(cs) && (chain[i].scrollWidth > chain[i].clientWidth + 1 || chain[i].scrollHeight > chain[i].clientHeight + 1)) continue
304
+ // Over pixels the patch does not repaint.
305
+ if (overflows(chain[i], cs)) continue
228
306
  // A box a clipping ancestor cuts, past its edges or into a rounded corner, would be
229
307
  // drawn whole: a row half out of a 40px scroller painted its hidden half (19200 px
230
308
  // off). The host is the box itself, so the test is on its rect, not on the changed
@@ -238,6 +316,24 @@ export function stream(element, options = {}) {
238
316
  return null
239
317
  }
240
318
 
319
+ /** The box a change to `node` stayed inside, to repaint as a window of the root, or null.
320
+ * The window has everything that paints in it, so the box needs no backdrop and may sit
321
+ * under positioned boxes; it must keep its rect, paint nothing new outside itself, and
322
+ * have no blur spread the change past it: a blurring ancestor, or a glass box over it. */
323
+ function regionFor(node) {
324
+ let el = node?.nodeType === 1 ? node : node?.parentElement
325
+ for (let a = el; a; a = a === element ? null : a.parentElement) if (spreads(getComputedStyle(a))) return null
326
+ for (; el && el !== element; el = el.parentElement) {
327
+ const r = rectOf(el)
328
+ const cs = getComputedStyle(el)
329
+ if (!r.width || !r.height || !sameRect(rects.get(el) || {}, r) || overflows(el, cs)) continue
330
+ if (restyled.has(el) && outerInk(cs)) continue
331
+ for (const g of glass) if (!g.contains(el) && !el.contains(g) && intersects(rectOf(g), r)) return null
332
+ return el
333
+ }
334
+ return null
335
+ }
336
+
241
337
  async function full() {
242
338
  const t0 = performance.now()
243
339
  // A full frame is the one long task of a stream; 'auto' lets a long clone yield (#503).
@@ -253,6 +349,10 @@ export function stream(element, options = {}) {
253
349
  ox = contentX * k
254
350
  oy = contentY * k
255
351
  snapshotLayout()
352
+ // Read again at every full frame, so a sheet added later counts from the next keyframe.
353
+ const sels = hoverSelectors(element)
354
+ hoverList = sels && sels.length * nodes <= HOVER_BUDGET ? sels.join(',') : null
355
+ try { hovered = hoverMatches() } catch { hoverList = null }
256
356
  lastKeyframe = performance.now()
257
357
  keyframeDue = false
258
358
  fullMs = lastKeyframe - t0
@@ -267,8 +367,7 @@ export function stream(element, options = {}) {
267
367
  * other box on the whole-pixel rect around the host, or around `old`, where a moved host
268
368
  * was. */
269
369
  function backdropOf(host, old) {
270
- const cs = getComputedStyle(host)
271
- if (cs.boxShadow !== 'none' || (cs.outlineStyle !== 'none' && parseFloat(cs.outlineWidth) > 0)) return null
370
+ if (outerInk(getComputedStyle(host))) return null
272
371
  let color = null
273
372
  for (let a = host.parentElement; a && !color; a = a === element ? null : a.parentElement) {
274
373
  const s = getComputedStyle(a)
@@ -321,7 +420,7 @@ export function stream(element, options = {}) {
321
420
  lctx.fillRect(0, 0, w, h)
322
421
  }
323
422
  lctx.drawImage(src, 0, 0, w, h)
324
- return { layer, x, y, w, h, backdrop, host, drawnAt: r }
423
+ return { layer, x, y, w, h, replace: true, host, drawnAt: r }
325
424
  }
326
425
  // Otherwise keep only the pixels the box covers fully. Inside an opaque box that is
327
426
  // everything; what is left are its antialiased edges and rounded corners, which did not
@@ -336,11 +435,33 @@ export function stream(element, options = {}) {
336
435
  return { layer, x, y, w, h, host, drawnAt: r }
337
436
  }
338
437
 
438
+ /** Capture the root clipped to `host`'s box on whole canvas pixels: the full frame's
439
+ * pixels for that window. A value on a glass tile of the Zumly board (48 tiles, dpr 2):
440
+ * 9 ms against 323 for the full frame, identical to it. A window over the tile's rounded
441
+ * corners differed on the antialiased arc, by up to 28 levels on 45 pixels (cause not
442
+ * found). Sixteen windows at once cost 101 ms; one window per row of them cost 149, since a
443
+ * row keeps every tile in it. */
444
+ async function renderRegion(host) {
445
+ const drawnAt = rectOf(host)
446
+ const r = pixelRect(drawnAt)
447
+ const res = await capture(element, { ...opts, clip: { x: rootRect.left + scrollX + r.left, y: rootRect.top + scrollY + r.top, width: r.right - r.left, height: r.bottom - r.top } })
448
+ const { vbW, vbH, contentX = 0, contentY = 0, clip } = res.meta
449
+ const src = WEBKIT ? await res.toCanvas() : await decode(res.url)
450
+ const x = Math.round(ox + r.left * k), y = Math.round(oy + r.top * k)
451
+ const w = Math.round(ox + r.right * k) - x, h = Math.round(oy + r.bottom * k) - y
452
+ // The image starts contentX before the window, over pixels the clip culled: keep the window.
453
+ const layer = document.createElement('canvas')
454
+ layer.width = w
455
+ layer.height = h
456
+ layer.getContext('2d').drawImage(src, Math.round(ox + (clip.x - contentX) * k) - x, Math.round(oy + (clip.y - contentY) * k) - y, Math.round(vbW * k), Math.round(vbH * k))
457
+ return { layer, x, y, w, h, replace: true, host, drawnAt }
458
+ }
459
+
339
460
  async function patch(hosts) {
340
461
  // Captures and decodes overlap; the draws then land in one synchronous pass, so the
341
462
  // canvas never shows half a frame. Three hosts a frame (clock, KPI, list row) in
342
463
  // demos/stream-webgl.html: 11.9 ms one after another.
343
- const layers = await Promise.all(hosts.map(renderPatch))
464
+ const layers = await Promise.all(hosts.map((h) => regions.has(h) ? renderRegion(h) : renderPatch(h)))
344
465
  const out = []
345
466
  // The canvas clips draws past its edge; a reported rect must be clipped too, or a box
346
467
  // sliding off the stage (the lower third hides to left:-720px) hands texSubImage2D a
@@ -357,9 +478,9 @@ export function stream(element, options = {}) {
357
478
  paintBackdrop(backdrops.get(host), x, y, w, h)
358
479
  report(x, y, w, h)
359
480
  }
360
- for (const { layer, x, y, w, h, backdrop } of layers) {
361
- // A backdrop layer is the full frame's pixels for its whole rect: replace, not blend.
362
- if (backdrop) ctx.clearRect(x, y, w, h)
481
+ for (const { layer, x, y, w, h, replace } of layers) {
482
+ // A backdrop or window layer is the full frame's pixels for its whole rect: replace, not blend.
483
+ if (replace) ctx.clearRect(x, y, w, h)
363
484
  ctx.drawImage(layer, x, y)
364
485
  report(x, y, w, h)
365
486
  }
@@ -383,6 +504,7 @@ export function stream(element, options = {}) {
383
504
  if (!sameRect({ left: 0, top: 0, width: now.width, height: now.height }, { left: 0, top: 0, width: rootRect.width, height: rootRect.height })) return 'root resized'
384
505
  rootRect = now
385
506
  const hosts = new Set()
507
+ regions.clear()
386
508
  for (const node of dirty) {
387
509
  if (!node?.isConnected) return 'node removed'
388
510
  let host = hostFor(node)
@@ -402,6 +524,7 @@ export function stream(element, options = {}) {
402
524
  movedFrom.set(p, old)
403
525
  }
404
526
  }
527
+ if (!host && (host = regionFor(node))) regions.add(host)
405
528
  if (!host) return `no host for ${describe(node)}`
406
529
  hosts.add(host)
407
530
  }
@@ -413,14 +536,18 @@ export function stream(element, options = {}) {
413
536
  backdrops.clear()
414
537
  for (const h of movedFrom.keys()) if (!hosts.has(h)) movedFrom.delete(h)
415
538
  for (const h of hosts) {
416
- const backdrop = backdropOf(h)
417
- if (backdrop) backdrops.set(h, backdrop)
418
539
  const after = rectOf(h)
419
540
  area += after.width * after.height
420
- for (const f of floaters) {
421
- if (f === h || h.contains(f) || f.contains(h)) continue
422
- if (intersects(rectOf(f), after)) return `${describe(f)} overlaps ${describe(h)}`
541
+ if (regions.has(h)) continue
542
+ const over = floaters.find((f) => f !== h && !h.contains(f) && !f.contains(h) && intersects(rectOf(f), after))
543
+ if (over) {
544
+ // The window has the positioned box in it too.
545
+ if (movedFrom.has(h) || regionFor(h) !== h) return `${describe(over)} overlaps ${describe(h)}`
546
+ regions.add(h)
547
+ continue
423
548
  }
549
+ const backdrop = backdropOf(h)
550
+ if (backdrop) backdrops.set(h, backdrop)
424
551
  }
425
552
  if (area > MAX_PATCH_AREA * rootRect.width * rootRect.height) return 'patch area too large'
426
553
  return [...hosts]
@@ -433,13 +560,22 @@ export function stream(element, options = {}) {
433
560
  if (busy || (fps && now - lastTick < 1000 / fps)) return
434
561
  // A running animation repaints its target every frame, and once more when it stops: the
435
562
  // frame before a pause or the end of a transition is not where it came to rest.
436
- const running = new Set()
437
- for (const a of element.getAnimations?.({ subtree: true }) || []) {
438
- if (a.playState === 'running') running.add(a.effect?.target || element)
563
+ if (animations) {
564
+ const running = new Set()
565
+ for (const a of element.getAnimations?.({ subtree: true }) || []) {
566
+ if (a.playState === 'running') running.add(a.effect?.target || element)
567
+ }
568
+ for (const target of running) dirty.add(target)
569
+ for (const target of animating) if (!running.has(target)) dirty.add(target)
570
+ animating = running
571
+ }
572
+ if (hoverMoved) {
573
+ hoverMoved = false
574
+ const now = hoverMatches()
575
+ for (const el of now) if (!hovered.has(el)) dirty.add(el)
576
+ for (const el of hovered) if (!now.has(el) && el.isConnected) dirty.add(el)
577
+ hovered = now
439
578
  }
440
- for (const target of running) dirty.add(target)
441
- for (const target of animating) if (!running.has(target)) dirty.add(target)
442
- animating = running
443
579
  netTargets(observer.takeRecords(), dirty, restyled)
444
580
  // The keyframe waits for idle time, so it never lands on top of a burst of edits.
445
581
  if (!keyframeDue && !idleAsked && now - lastKeyframe > Math.max(KEYFRAME_MS, fullMs * KEYFRAME_COST)) {
package/stream.d.ts CHANGED
@@ -16,6 +16,8 @@ export interface StreamOptions extends SnapdomOptions {
16
16
  fps?: number
17
17
  /** false repaints full frames only. Default true. */
18
18
  patches?: boolean
19
+ /** false stops following running animations and transitions: an animated box keeps its last drawn pixels until something else repaints it. Default true. */
20
+ animations?: boolean
19
21
  }
20
22
 
21
23
  export interface Stream {