hyperframes 0.7.32 → 0.7.33

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.33" : "0.0.0-dev";
54
54
  }
55
55
  });
56
56
 
@@ -60667,8 +60667,36 @@ 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 restoreMaskedTimedDescendants = () => {
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
+ restoreMaskedTimedDescendants();
60687
+ const hiddenTimedDescendants = [];
60688
+ const rememberHiddenTimedDescendants = (root) => {
60689
+ for (const node of root.querySelectorAll("[data-start]")) {
60690
+ if (!(node instanceof HTMLElement)) continue;
60691
+ const computed = window.getComputedStyle(node);
60692
+ if (computed.visibility !== "hidden" && computed.display !== "none") continue;
60693
+ hiddenTimedDescendants.push(node);
60694
+ }
60695
+ };
60670
60696
  const showSelectors = [];
60671
60697
  for (const id of args.show) {
60698
+ const el = document.getElementById(id);
60699
+ if (el) rememberHiddenTimedDescendants(el);
60672
60700
  const escaped = CSS.escape(id);
60673
60701
  showSelectors.push(`#${escaped}`, `#${escaped} *`);
60674
60702
  const renderEscaped = CSS.escape(`__render_frame_${id}__`);
@@ -60681,6 +60709,23 @@ async function applyDomLayerMask(page, showIds, extraHideIds) {
60681
60709
  style.textContent = `${massHideRule}
60682
60710
  ${showRule}`;
60683
60711
  document.head.appendChild(style);
60712
+ for (const el of hiddenTimedDescendants) {
60713
+ if (el.getAttribute(args.hiddenAttr) === "1") continue;
60714
+ const prevVisibility = el.style.getPropertyValue("visibility");
60715
+ const prevPriority = typeof el.style.getPropertyPriority === "function" ? el.style.getPropertyPriority("visibility") : "";
60716
+ if (prevVisibility) {
60717
+ el.setAttribute(args.prevVisibilityAttr, prevVisibility);
60718
+ } else {
60719
+ el.removeAttribute(args.prevVisibilityAttr);
60720
+ }
60721
+ if (prevPriority) {
60722
+ el.setAttribute(args.prevPriorityAttr, prevPriority);
60723
+ } else {
60724
+ el.removeAttribute(args.prevPriorityAttr);
60725
+ }
60726
+ el.setAttribute(args.hiddenAttr, "1");
60727
+ el.style.setProperty("visibility", "hidden", "important");
60728
+ }
60684
60729
  for (const id of args.hide) {
60685
60730
  const el = document.getElementById(id);
60686
60731
  if (el) {
@@ -60692,7 +60737,14 @@ ${showRule}`;
60692
60737
  }
60693
60738
  }
60694
60739
  },
60695
- { show: showIds, hide: extraHideIds, styleId: DOM_LAYER_MASK_STYLE_ID }
60740
+ {
60741
+ show: showIds,
60742
+ hide: extraHideIds,
60743
+ styleId: DOM_LAYER_MASK_STYLE_ID,
60744
+ hiddenAttr: DOM_LAYER_MASK_HIDDEN_ATTR,
60745
+ prevVisibilityAttr: DOM_LAYER_MASK_PREV_VISIBILITY_ATTR,
60746
+ prevPriorityAttr: DOM_LAYER_MASK_PREV_PRIORITY_ATTR
60747
+ }
60696
60748
  );
60697
60749
  }
60698
60750
  async function removeDomLayerMask(page, extraHideIds) {
@@ -60700,6 +60752,20 @@ async function removeDomLayerMask(page, extraHideIds) {
60700
60752
  (args) => {
60701
60753
  const style = document.getElementById(args.styleId);
60702
60754
  if (style) style.remove();
60755
+ const masked = document.querySelectorAll(`[${args.hiddenAttr}="1"]`);
60756
+ for (const node of masked) {
60757
+ if (!(node instanceof HTMLElement)) continue;
60758
+ const prevVisibility = node.getAttribute(args.prevVisibilityAttr);
60759
+ const prevPriority = node.getAttribute(args.prevPriorityAttr);
60760
+ if (prevVisibility === null) {
60761
+ node.style.removeProperty("visibility");
60762
+ } else {
60763
+ node.style.setProperty("visibility", prevVisibility, prevPriority ?? "");
60764
+ }
60765
+ node.removeAttribute(args.hiddenAttr);
60766
+ node.removeAttribute(args.prevVisibilityAttr);
60767
+ node.removeAttribute(args.prevPriorityAttr);
60768
+ }
60703
60769
  for (const id of args.hide) {
60704
60770
  const el = document.getElementById(id);
60705
60771
  if (el) {
@@ -60709,7 +60775,13 @@ async function removeDomLayerMask(page, extraHideIds) {
60709
60775
  if (img) img.style.removeProperty("visibility");
60710
60776
  }
60711
60777
  },
60712
- { hide: extraHideIds, styleId: DOM_LAYER_MASK_STYLE_ID }
60778
+ {
60779
+ hide: extraHideIds,
60780
+ styleId: DOM_LAYER_MASK_STYLE_ID,
60781
+ hiddenAttr: DOM_LAYER_MASK_HIDDEN_ATTR,
60782
+ prevVisibilityAttr: DOM_LAYER_MASK_PREV_VISIBILITY_ATTR,
60783
+ prevPriorityAttr: DOM_LAYER_MASK_PREV_PRIORITY_ATTR
60784
+ }
60713
60785
  );
60714
60786
  }
60715
60787
  async function injectVideoFramesBatch(page, updates) {
@@ -60847,7 +60919,7 @@ async function syncVideoFrameVisibility(page, activeVideoIds) {
60847
60919
  }
60848
60920
  }, activeVideoIds);
60849
60921
  }
60850
- var cdpSessionCache, lastFrameCache, PENDING_FRAME_RETRIES, TRANSPARENT_BG_STYLE_ID, DOM_LAYER_MASK_STYLE_ID;
60922
+ 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
60923
  var init_screenshotService = __esm({
60852
60924
  "../engine/src/services/screenshotService.ts"() {
60853
60925
  "use strict";
@@ -60857,6 +60929,9 @@ var init_screenshotService = __esm({
60857
60929
  PENDING_FRAME_RETRIES = 5;
60858
60930
  TRANSPARENT_BG_STYLE_ID = "__hf_transparent_bg__";
60859
60931
  DOM_LAYER_MASK_STYLE_ID = "__hf_dom_layer_mask__";
60932
+ DOM_LAYER_MASK_HIDDEN_ATTR = "data-hf-dom-layer-mask-hidden";
60933
+ DOM_LAYER_MASK_PREV_VISIBILITY_ATTR = "data-hf-dom-layer-mask-prev-visibility";
60934
+ DOM_LAYER_MASK_PREV_PRIORITY_ATTR = "data-hf-dom-layer-mask-prev-priority";
60860
60935
  }
60861
60936
  });
60862
60937
 
@@ -72764,6 +72839,11 @@ async function queryElementStacking(page, nativeHdrIds) {
72764
72839
  const n2 = parseFloat(value);
72765
72840
  return Number.isFinite(n2) ? n2 : 0;
72766
72841
  }
72842
+ function isElementPaintable(node) {
72843
+ const rect = node.getBoundingClientRect();
72844
+ const style = window.getComputedStyle(node);
72845
+ return style.visibility !== "hidden" && style.display !== "none" && rect.width > 0 && rect.height > 0;
72846
+ }
72767
72847
  for (const el of elements) {
72768
72848
  const id = el.id;
72769
72849
  if (!id) continue;
@@ -72772,7 +72852,9 @@ async function queryElementStacking(page, nativeHdrIds) {
72772
72852
  const zIndex = getEffectiveZIndex(el);
72773
72853
  const isHdrEl = hdrSet.has(id);
72774
72854
  const opacity = getEffectiveOpacity(el);
72775
- const visible = style.visibility !== "hidden" && style.display !== "none" && rect.width > 0 && rect.height > 0;
72855
+ const visible = isElementPaintable(el);
72856
+ const renderFrame = document.getElementById(`__render_frame_${id}__`);
72857
+ const renderFrameVisible = renderFrame ? isElementPaintable(renderFrame) : false;
72776
72858
  const htmlEl = el instanceof HTMLElement ? el : null;
72777
72859
  results.push({
72778
72860
  id,
@@ -72785,6 +72867,7 @@ async function queryElementStacking(page, nativeHdrIds) {
72785
72867
  layoutHeight: htmlEl?.offsetHeight || Math.round(rect.height),
72786
72868
  opacity,
72787
72869
  visible,
72870
+ renderFrameVisible,
72788
72871
  isHdr: hdrSet.has(id),
72789
72872
  // For HDR elements, use the full accumulated viewport matrix so the
72790
72873
  // affine blit can apply rotation/scale/translate properly. For DOM
@@ -104346,6 +104429,13 @@ function shouldUseLayeredComposite(options) {
104346
104429
  function resolveCompositeTransfer(hasHdrContent, effectiveHdr) {
104347
104430
  return hasHdrContent && effectiveHdr ? effectiveHdr.transfer : "srgb";
104348
104431
  }
104432
+ function selectDomLayerShowIds(layerElementIds, fullStacking) {
104433
+ const byId = new Map(fullStacking.map((el) => [el.id, el]));
104434
+ return layerElementIds.filter((id) => {
104435
+ const el = byId.get(id);
104436
+ return !!el && el.opacity > 0 && (el.visible || el.renderFrameVisible === true);
104437
+ });
104438
+ }
104349
104439
  async function compositeHdrFrame(ctx, canvas, time, fullStacking, elementFilter, debugFrameIndex = -1) {
104350
104440
  const {
104351
104441
  log: log2,
@@ -104461,6 +104551,17 @@ async function compositeHdrFrame(ctx, canvas, time, fullStacking, elementFilter,
104461
104551
  }
104462
104552
  } else {
104463
104553
  const layerIds = new Set(layer.elementIds);
104554
+ const showIds = selectDomLayerShowIds(layer.elementIds, fullStacking);
104555
+ if (showIds.length === 0) {
104556
+ if (shouldLog) {
104557
+ log2.info("[diag] dom layer skipped, all elements not paintable", {
104558
+ frame: debugFrameIndex,
104559
+ layerIdx,
104560
+ layerIds: layer.elementIds
104561
+ });
104562
+ }
104563
+ continue;
104564
+ }
104464
104565
  const hideIds = allElementIds.filter((id) => !layerIds.has(id));
104465
104566
  if (hdrPerf) hdrPerf.domLayerCaptures += 1;
104466
104567
  await timeHdrPhaseAsync(
@@ -104480,7 +104581,7 @@ async function compositeHdrFrame(ctx, canvas, time, fullStacking, elementFilter,
104480
104581
  await timeHdrPhaseAsync(
104481
104582
  hdrPerf,
104482
104583
  "domMaskApplyMs",
104483
- () => applyDomLayerMask(domSession.page, layer.elementIds, hideIds)
104584
+ () => applyDomLayerMask(domSession.page, showIds, hideIds)
104484
104585
  );
104485
104586
  const domPng = await timeHdrPhaseAsync(
104486
104587
  hdrPerf,
@@ -104510,6 +104611,7 @@ async function compositeHdrFrame(ctx, canvas, time, fullStacking, elementFilter,
104510
104611
  frame: debugFrameIndex,
104511
104612
  layerIdx,
104512
104613
  layerIds: layer.elementIds,
104614
+ showIds,
104513
104615
  hideCount: hideIds.length,
104514
104616
  pngBytes: domPng.length,
104515
104617
  alphaPixels,
@@ -104655,8 +104757,9 @@ async function captureSceneIntoBuffer(a) {
104655
104757
  );
104656
104758
  }
104657
104759
  }
104658
- const showIds = Array.from(sceneIds);
104760
+ const showIds = selectDomLayerShowIds(Array.from(sceneIds), stackingInfo);
104659
104761
  const hideIds = stackingInfo.map((e3) => e3.id).filter((id) => !sceneIds.has(id) || nativeHdrIds.has(id));
104762
+ if (showIds.length === 0) return;
104660
104763
  if (hdrPerf) hdrPerf.domLayerCaptures += 1;
104661
104764
  await timeHdrPhaseAsync(
104662
104765
  hdrPerf,