hyperframes 0.7.32 → 0.7.34

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/dist/cli.js CHANGED
@@ -50,7 +50,7 @@ var VERSION;
50
50
  var init_version = __esm({
51
51
  "src/version.ts"() {
52
52
  "use strict";
53
- VERSION = true ? "0.7.32" : "0.0.0-dev";
53
+ VERSION = true ? "0.7.34" : "0.0.0-dev";
54
54
  }
55
55
  });
56
56
 
@@ -60667,8 +60667,54 @@ async function applyDomLayerMask(page, showIds, extraHideIds) {
60667
60667
  (args) => {
60668
60668
  const existing = document.getElementById(args.styleId);
60669
60669
  if (existing) existing.remove();
60670
+ const restoreMaskedElements = () => {
60671
+ const masked = document.querySelectorAll(`[${args.hiddenAttr}="1"]`);
60672
+ for (const node of masked) {
60673
+ if (!(node instanceof HTMLElement)) continue;
60674
+ const prevVisibility = node.getAttribute(args.prevVisibilityAttr);
60675
+ const prevPriority = node.getAttribute(args.prevPriorityAttr);
60676
+ if (prevVisibility === null) {
60677
+ node.style.removeProperty("visibility");
60678
+ } else {
60679
+ node.style.setProperty("visibility", prevVisibility, prevPriority ?? "");
60680
+ }
60681
+ node.removeAttribute(args.hiddenAttr);
60682
+ node.removeAttribute(args.prevVisibilityAttr);
60683
+ node.removeAttribute(args.prevPriorityAttr);
60684
+ }
60685
+ };
60686
+ restoreMaskedElements();
60687
+ const rememberAndHideElement = (el) => {
60688
+ if (el.getAttribute(args.hiddenAttr) !== "1") {
60689
+ const prevVisibility = el.style.getPropertyValue("visibility");
60690
+ const prevPriority = typeof el.style.getPropertyPriority === "function" ? el.style.getPropertyPriority("visibility") : "";
60691
+ if (prevVisibility) {
60692
+ el.setAttribute(args.prevVisibilityAttr, prevVisibility);
60693
+ } else {
60694
+ el.removeAttribute(args.prevVisibilityAttr);
60695
+ }
60696
+ if (prevPriority) {
60697
+ el.setAttribute(args.prevPriorityAttr, prevPriority);
60698
+ } else {
60699
+ el.removeAttribute(args.prevPriorityAttr);
60700
+ }
60701
+ el.setAttribute(args.hiddenAttr, "1");
60702
+ }
60703
+ el.style.setProperty("visibility", "hidden", "important");
60704
+ };
60705
+ const hiddenTimedDescendants = [];
60706
+ const rememberHiddenTimedDescendants = (root) => {
60707
+ for (const node of root.querySelectorAll("[data-start]")) {
60708
+ if (!(node instanceof HTMLElement)) continue;
60709
+ const computed = window.getComputedStyle(node);
60710
+ if (computed.visibility !== "hidden" && computed.display !== "none") continue;
60711
+ hiddenTimedDescendants.push(node);
60712
+ }
60713
+ };
60670
60714
  const showSelectors = [];
60671
60715
  for (const id of args.show) {
60716
+ const el = document.getElementById(id);
60717
+ if (el) rememberHiddenTimedDescendants(el);
60672
60718
  const escaped = CSS.escape(id);
60673
60719
  showSelectors.push(`#${escaped}`, `#${escaped} *`);
60674
60720
  const renderEscaped = CSS.escape(`__render_frame_${id}__`);
@@ -60681,35 +60727,56 @@ async function applyDomLayerMask(page, showIds, extraHideIds) {
60681
60727
  style.textContent = `${massHideRule}
60682
60728
  ${showRule}`;
60683
60729
  document.head.appendChild(style);
60730
+ for (const el of hiddenTimedDescendants) {
60731
+ rememberAndHideElement(el);
60732
+ }
60684
60733
  for (const id of args.hide) {
60685
60734
  const el = document.getElementById(id);
60686
60735
  if (el) {
60687
- el.style.setProperty("visibility", "hidden", "important");
60736
+ rememberAndHideElement(el);
60688
60737
  }
60689
60738
  const img = document.getElementById(`__render_frame_${id}__`);
60690
60739
  if (img) {
60691
- img.style.setProperty("visibility", "hidden", "important");
60740
+ rememberAndHideElement(img);
60692
60741
  }
60693
60742
  }
60694
60743
  },
60695
- { show: showIds, hide: extraHideIds, styleId: DOM_LAYER_MASK_STYLE_ID }
60744
+ {
60745
+ show: showIds,
60746
+ hide: extraHideIds,
60747
+ styleId: DOM_LAYER_MASK_STYLE_ID,
60748
+ hiddenAttr: DOM_LAYER_MASK_HIDDEN_ATTR,
60749
+ prevVisibilityAttr: DOM_LAYER_MASK_PREV_VISIBILITY_ATTR,
60750
+ prevPriorityAttr: DOM_LAYER_MASK_PREV_PRIORITY_ATTR
60751
+ }
60696
60752
  );
60697
60753
  }
60698
- async function removeDomLayerMask(page, extraHideIds) {
60754
+ async function removeDomLayerMask(page, _extraHideIds) {
60699
60755
  await page.evaluate(
60700
60756
  (args) => {
60701
60757
  const style = document.getElementById(args.styleId);
60702
60758
  if (style) style.remove();
60703
- for (const id of args.hide) {
60704
- const el = document.getElementById(id);
60705
- if (el) {
60706
- el.style.removeProperty("visibility");
60759
+ const masked = document.querySelectorAll(`[${args.hiddenAttr}="1"]`);
60760
+ for (const node of masked) {
60761
+ if (!(node instanceof HTMLElement)) continue;
60762
+ const prevVisibility = node.getAttribute(args.prevVisibilityAttr);
60763
+ const prevPriority = node.getAttribute(args.prevPriorityAttr);
60764
+ if (prevVisibility === null) {
60765
+ node.style.removeProperty("visibility");
60766
+ } else {
60767
+ node.style.setProperty("visibility", prevVisibility, prevPriority ?? "");
60707
60768
  }
60708
- const img = document.getElementById(`__render_frame_${id}__`);
60709
- if (img) img.style.removeProperty("visibility");
60769
+ node.removeAttribute(args.hiddenAttr);
60770
+ node.removeAttribute(args.prevVisibilityAttr);
60771
+ node.removeAttribute(args.prevPriorityAttr);
60710
60772
  }
60711
60773
  },
60712
- { hide: extraHideIds, styleId: DOM_LAYER_MASK_STYLE_ID }
60774
+ {
60775
+ styleId: DOM_LAYER_MASK_STYLE_ID,
60776
+ hiddenAttr: DOM_LAYER_MASK_HIDDEN_ATTR,
60777
+ prevVisibilityAttr: DOM_LAYER_MASK_PREV_VISIBILITY_ATTR,
60778
+ prevPriorityAttr: DOM_LAYER_MASK_PREV_PRIORITY_ATTR
60779
+ }
60713
60780
  );
60714
60781
  }
60715
60782
  async function injectVideoFramesBatch(page, updates) {
@@ -60847,7 +60914,7 @@ async function syncVideoFrameVisibility(page, activeVideoIds) {
60847
60914
  }
60848
60915
  }, activeVideoIds);
60849
60916
  }
60850
- var cdpSessionCache, lastFrameCache, PENDING_FRAME_RETRIES, TRANSPARENT_BG_STYLE_ID, DOM_LAYER_MASK_STYLE_ID;
60917
+ var cdpSessionCache, lastFrameCache, PENDING_FRAME_RETRIES, TRANSPARENT_BG_STYLE_ID, DOM_LAYER_MASK_STYLE_ID, DOM_LAYER_MASK_HIDDEN_ATTR, DOM_LAYER_MASK_PREV_VISIBILITY_ATTR, DOM_LAYER_MASK_PREV_PRIORITY_ATTR;
60851
60918
  var init_screenshotService = __esm({
60852
60919
  "../engine/src/services/screenshotService.ts"() {
60853
60920
  "use strict";
@@ -60857,6 +60924,9 @@ var init_screenshotService = __esm({
60857
60924
  PENDING_FRAME_RETRIES = 5;
60858
60925
  TRANSPARENT_BG_STYLE_ID = "__hf_transparent_bg__";
60859
60926
  DOM_LAYER_MASK_STYLE_ID = "__hf_dom_layer_mask__";
60927
+ DOM_LAYER_MASK_HIDDEN_ATTR = "data-hf-dom-layer-mask-hidden";
60928
+ DOM_LAYER_MASK_PREV_VISIBILITY_ATTR = "data-hf-dom-layer-mask-prev-visibility";
60929
+ DOM_LAYER_MASK_PREV_PRIORITY_ATTR = "data-hf-dom-layer-mask-prev-priority";
60860
60930
  }
60861
60931
  });
60862
60932
 
@@ -72764,6 +72834,11 @@ async function queryElementStacking(page, nativeHdrIds) {
72764
72834
  const n2 = parseFloat(value);
72765
72835
  return Number.isFinite(n2) ? n2 : 0;
72766
72836
  }
72837
+ function isElementPaintable(node) {
72838
+ const rect = node.getBoundingClientRect();
72839
+ const style = window.getComputedStyle(node);
72840
+ return style.visibility !== "hidden" && style.display !== "none" && rect.width > 0 && rect.height > 0;
72841
+ }
72767
72842
  for (const el of elements) {
72768
72843
  const id = el.id;
72769
72844
  if (!id) continue;
@@ -72772,7 +72847,9 @@ async function queryElementStacking(page, nativeHdrIds) {
72772
72847
  const zIndex = getEffectiveZIndex(el);
72773
72848
  const isHdrEl = hdrSet.has(id);
72774
72849
  const opacity = getEffectiveOpacity(el);
72775
- const visible = style.visibility !== "hidden" && style.display !== "none" && rect.width > 0 && rect.height > 0;
72850
+ const visible = isElementPaintable(el);
72851
+ const renderFrame = document.getElementById(`__render_frame_${id}__`);
72852
+ const renderFrameVisible = renderFrame ? isElementPaintable(renderFrame) : false;
72776
72853
  const htmlEl = el instanceof HTMLElement ? el : null;
72777
72854
  results.push({
72778
72855
  id,
@@ -72785,6 +72862,7 @@ async function queryElementStacking(page, nativeHdrIds) {
72785
72862
  layoutHeight: htmlEl?.offsetHeight || Math.round(rect.height),
72786
72863
  opacity,
72787
72864
  visible,
72865
+ renderFrameVisible,
72788
72866
  isHdr: hdrSet.has(id),
72789
72867
  // For HDR elements, use the full accumulated viewport matrix so the
72790
72868
  // affine blit can apply rotation/scale/translate properly. For DOM
@@ -104346,6 +104424,13 @@ function shouldUseLayeredComposite(options) {
104346
104424
  function resolveCompositeTransfer(hasHdrContent, effectiveHdr) {
104347
104425
  return hasHdrContent && effectiveHdr ? effectiveHdr.transfer : "srgb";
104348
104426
  }
104427
+ function selectDomLayerShowIds(layerElementIds, fullStacking) {
104428
+ const byId = new Map(fullStacking.map((el) => [el.id, el]));
104429
+ return layerElementIds.filter((id) => {
104430
+ const el = byId.get(id);
104431
+ return !!el && el.opacity > 0 && (el.visible || el.renderFrameVisible === true);
104432
+ });
104433
+ }
104349
104434
  async function compositeHdrFrame(ctx, canvas, time, fullStacking, elementFilter, debugFrameIndex = -1) {
104350
104435
  const {
104351
104436
  log: log2,
@@ -104461,6 +104546,17 @@ async function compositeHdrFrame(ctx, canvas, time, fullStacking, elementFilter,
104461
104546
  }
104462
104547
  } else {
104463
104548
  const layerIds = new Set(layer.elementIds);
104549
+ const showIds = selectDomLayerShowIds(layer.elementIds, fullStacking);
104550
+ if (showIds.length === 0) {
104551
+ if (shouldLog) {
104552
+ log2.info("[diag] dom layer skipped, all elements not paintable", {
104553
+ frame: debugFrameIndex,
104554
+ layerIdx,
104555
+ layerIds: layer.elementIds
104556
+ });
104557
+ }
104558
+ continue;
104559
+ }
104464
104560
  const hideIds = allElementIds.filter((id) => !layerIds.has(id));
104465
104561
  if (hdrPerf) hdrPerf.domLayerCaptures += 1;
104466
104562
  await timeHdrPhaseAsync(
@@ -104480,7 +104576,7 @@ async function compositeHdrFrame(ctx, canvas, time, fullStacking, elementFilter,
104480
104576
  await timeHdrPhaseAsync(
104481
104577
  hdrPerf,
104482
104578
  "domMaskApplyMs",
104483
- () => applyDomLayerMask(domSession.page, layer.elementIds, hideIds)
104579
+ () => applyDomLayerMask(domSession.page, showIds, hideIds)
104484
104580
  );
104485
104581
  const domPng = await timeHdrPhaseAsync(
104486
104582
  hdrPerf,
@@ -104510,6 +104606,7 @@ async function compositeHdrFrame(ctx, canvas, time, fullStacking, elementFilter,
104510
104606
  frame: debugFrameIndex,
104511
104607
  layerIdx,
104512
104608
  layerIds: layer.elementIds,
104609
+ showIds,
104513
104610
  hideCount: hideIds.length,
104514
104611
  pngBytes: domPng.length,
104515
104612
  alphaPixels,
@@ -104655,8 +104752,9 @@ async function captureSceneIntoBuffer(a) {
104655
104752
  );
104656
104753
  }
104657
104754
  }
104658
- const showIds = Array.from(sceneIds);
104755
+ const showIds = selectDomLayerShowIds(Array.from(sceneIds), stackingInfo);
104659
104756
  const hideIds = stackingInfo.map((e3) => e3.id).filter((id) => !sceneIds.has(id) || nativeHdrIds.has(id));
104757
+ if (showIds.length === 0) return;
104660
104758
  if (hdrPerf) hdrPerf.domLayerCaptures += 1;
104661
104759
  await timeHdrPhaseAsync(
104662
104760
  hdrPerf,
@@ -1 +1 @@
1
- import{g as P}from"./index-DsT9OH2w.js";function j(c,d){for(var s=0;s<d.length;s++){const a=d[s];if(typeof a!="string"&&!Array.isArray(a)){for(const i in a)if(i!=="default"&&!(i in c)){const l=Object.getOwnPropertyDescriptor(a,i);l&&Object.defineProperty(c,i,l.get?l:{enumerable:!0,get:()=>a[i]})}}}return Object.freeze(Object.defineProperty(c,Symbol.toStringTag,{value:"Module"}))}var v={},w;function k(){if(w)return v;w=1,Object.defineProperty(v,"__esModule",{value:!0}),v.default=d;var c=window.OfflineAudioContext||window.webkitOfflineAudioContext;function d(e){var r=a(e);return r.start(0),[i,y,O(e.sampleRate),s].reduce(function(t,o){return o(t)},r.buffer.getChannelData(0))}function s(e){return e.sort(function(r,t){return t.count-r.count}).splice(0,5)[0].tempo}function a(e){var r=e.length,t=e.numberOfChannels,o=e.sampleRate,n=new c(t,r,o),u=n.createBufferSource();u.buffer=e;var f=n.createBiquadFilter();return f.type="lowpass",u.connect(f),f.connect(n.destination),u}function i(e){for(var r=[],t=.9,o=.3,n=15;r.length<n&&t>=o;)r=l(e,t),t-=.05;if(r.length<n)throw new Error("Could not find enough samples for a reliable detection.");return r}function l(e,r){for(var t=[],o=0,n=e.length;o<n;o+=1)e[o]>r&&(t.push(o),o+=1e4);return t}function y(e){var r=[];return e.forEach(function(t,o){for(var n=function(x){var g=e[o+x]-t,_=r.some(function(h){if(h.interval===g)return h.count+=1});_||r.push({interval:g,count:1})},u=0;u<10;u+=1)n(u)}),r}function O(e){return function(r){var t=[];return r.forEach(function(o){if(o.interval!==0){for(var n=60/(o.interval/e);n<90;)n*=2;for(;n>180;)n/=2;n=Math.round(n);var u=t.some(function(f){if(f.tempo===n)return f.count+=o.count});u||t.push({tempo:n,count:o.count})}}),t}}return v}var p,b;function q(){return b||(b=1,p=k().default),p}var m=q();const A=P(m),D=j({__proto__:null,default:A},[m]);export{D as i};
1
+ import{g as P}from"./index-DlLW9GH4.js";function j(c,d){for(var s=0;s<d.length;s++){const a=d[s];if(typeof a!="string"&&!Array.isArray(a)){for(const i in a)if(i!=="default"&&!(i in c)){const l=Object.getOwnPropertyDescriptor(a,i);l&&Object.defineProperty(c,i,l.get?l:{enumerable:!0,get:()=>a[i]})}}}return Object.freeze(Object.defineProperty(c,Symbol.toStringTag,{value:"Module"}))}var v={},w;function k(){if(w)return v;w=1,Object.defineProperty(v,"__esModule",{value:!0}),v.default=d;var c=window.OfflineAudioContext||window.webkitOfflineAudioContext;function d(e){var r=a(e);return r.start(0),[i,y,O(e.sampleRate),s].reduce(function(t,o){return o(t)},r.buffer.getChannelData(0))}function s(e){return e.sort(function(r,t){return t.count-r.count}).splice(0,5)[0].tempo}function a(e){var r=e.length,t=e.numberOfChannels,o=e.sampleRate,n=new c(t,r,o),u=n.createBufferSource();u.buffer=e;var f=n.createBiquadFilter();return f.type="lowpass",u.connect(f),f.connect(n.destination),u}function i(e){for(var r=[],t=.9,o=.3,n=15;r.length<n&&t>=o;)r=l(e,t),t-=.05;if(r.length<n)throw new Error("Could not find enough samples for a reliable detection.");return r}function l(e,r){for(var t=[],o=0,n=e.length;o<n;o+=1)e[o]>r&&(t.push(o),o+=1e4);return t}function y(e){var r=[];return e.forEach(function(t,o){for(var n=function(x){var g=e[o+x]-t,_=r.some(function(h){if(h.interval===g)return h.count+=1});_||r.push({interval:g,count:1})},u=0;u<10;u+=1)n(u)}),r}function O(e){return function(r){var t=[];return r.forEach(function(o){if(o.interval!==0){for(var n=60/(o.interval/e);n<90;)n*=2;for(;n>180;)n/=2;n=Math.round(n);var u=t.some(function(f){if(f.tempo===n)return f.count+=o.count});u||t.push({tempo:n,count:o.count})}}),t}}return v}var p,b;function q(){return b||(b=1,p=k().default),p}var m=q();const A=P(m),D=j({__proto__:null,default:A},[m]);export{D as i};
@@ -1,4 +1,4 @@
1
- import{n as Qi}from"./index-DsT9OH2w.js";/*!
1
+ import{n as Qi}from"./index-DlLW9GH4.js";/*!
2
2
  * Copyright (c) 2026-present, Vanilagy and contributors
3
3
  *
4
4
  * This Source Code Form is subject to the terms of the Mozilla Public