@solidtv/solid 1.1.2 → 1.2.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.
Files changed (114) hide show
  1. package/dist/src/core/clickInspector.d.ts +1 -0
  2. package/dist/src/core/clickInspector.js +69 -0
  3. package/dist/src/core/clickInspector.js.map +1 -0
  4. package/dist/src/core/config.d.ts +8 -14
  5. package/dist/src/core/config.js +17 -3
  6. package/dist/src/core/config.js.map +1 -1
  7. package/dist/src/core/dom-renderer/domRenderer.d.ts +6 -1
  8. package/dist/src/core/dom-renderer/domRenderer.js +255 -67
  9. package/dist/src/core/dom-renderer/domRenderer.js.map +1 -1
  10. package/dist/src/core/dom-renderer/domRendererUtils.js +2 -2
  11. package/dist/src/core/dom-renderer/domRendererUtils.js.map +1 -1
  12. package/dist/src/core/elementNode.d.ts +30 -11
  13. package/dist/src/core/elementNode.js +113 -58
  14. package/dist/src/core/elementNode.js.map +1 -1
  15. package/dist/src/core/focusManager.d.ts +3 -9
  16. package/dist/src/core/focusManager.js +111 -101
  17. package/dist/src/core/focusManager.js.map +1 -1
  18. package/dist/src/core/intrinsicTypes.d.ts +2 -0
  19. package/dist/src/core/lightningInit.d.ts +1 -1
  20. package/dist/src/core/lightningInit.js +9 -9
  21. package/dist/src/core/lightningInit.js.map +1 -1
  22. package/dist/src/core/shaders.js +10 -10
  23. package/dist/src/core/shaders.js.map +1 -1
  24. package/dist/src/core/utils.d.ts +0 -1
  25. package/dist/src/core/utils.js +4 -5
  26. package/dist/src/core/utils.js.map +1 -1
  27. package/dist/src/index.d.ts +1 -1
  28. package/dist/src/index.js +1 -1
  29. package/dist/src/index.js.map +1 -1
  30. package/dist/src/primitives/FPSCounter.jsx +5 -5
  31. package/dist/src/primitives/FPSCounter.jsx.map +1 -1
  32. package/dist/src/primitives/Image.jsx +6 -1
  33. package/dist/src/primitives/Image.jsx.map +1 -1
  34. package/dist/src/primitives/KeepAlive.jsx +13 -3
  35. package/dist/src/primitives/KeepAlive.jsx.map +1 -1
  36. package/dist/src/primitives/LazyImport.js +4 -2
  37. package/dist/src/primitives/LazyImport.js.map +1 -1
  38. package/dist/src/primitives/Preserve.jsx +10 -4
  39. package/dist/src/primitives/Preserve.jsx.map +1 -1
  40. package/dist/src/primitives/Suspense.jsx +7 -7
  41. package/dist/src/primitives/Suspense.jsx.map +1 -1
  42. package/dist/src/primitives/Virtual.jsx.map +1 -1
  43. package/dist/src/primitives/announcer/announcer.js +3 -2
  44. package/dist/src/primitives/announcer/announcer.js.map +1 -1
  45. package/dist/src/primitives/announcer/speech.js +2 -2
  46. package/dist/src/primitives/announcer/speech.js.map +1 -1
  47. package/dist/src/primitives/borderBox.jsx +2 -1
  48. package/dist/src/primitives/borderBox.jsx.map +1 -1
  49. package/dist/src/primitives/createTag.jsx +3 -3
  50. package/dist/src/primitives/createTag.jsx.map +1 -1
  51. package/dist/src/primitives/portal.jsx +4 -3
  52. package/dist/src/primitives/portal.jsx.map +1 -1
  53. package/dist/src/primitives/useFocusManager.d.ts +1 -5
  54. package/dist/src/primitives/useFocusManager.js +1 -20
  55. package/dist/src/primitives/useFocusManager.js.map +1 -1
  56. package/dist/src/primitives/useMouse.js +4 -4
  57. package/dist/src/primitives/useMouse.js.map +1 -1
  58. package/dist/src/primitives/utils/chainFunctions.js +35 -9
  59. package/dist/src/primitives/utils/chainFunctions.js.map +1 -1
  60. package/dist/src/primitives/utils/createBlurredImage.js +57 -37
  61. package/dist/src/primitives/utils/createBlurredImage.js.map +1 -1
  62. package/dist/src/primitives/utils/handleNavigation.js +8 -6
  63. package/dist/src/primitives/utils/handleNavigation.js.map +1 -1
  64. package/dist/src/primitives/utils/withScrolling.js +1 -3
  65. package/dist/src/primitives/utils/withScrolling.js.map +1 -1
  66. package/dist/src/render.d.ts +1 -1
  67. package/dist/src/render.js +3 -4
  68. package/dist/src/render.js.map +1 -1
  69. package/dist/src/solidOpts.d.ts +1 -1
  70. package/dist/src/solidOpts.js +8 -25
  71. package/dist/src/solidOpts.js.map +1 -1
  72. package/dist/src/utils.js +10 -5
  73. package/dist/src/utils.js.map +1 -1
  74. package/dist/tsconfig.tsbuildinfo +1 -1
  75. package/docs/README.md +2 -2
  76. package/package.json +28 -29
  77. package/src/core/clickInspector.ts +77 -0
  78. package/src/core/config.ts +15 -22
  79. package/src/core/dom-renderer/domRenderer.ts +308 -89
  80. package/src/core/dom-renderer/domRendererTypes.ts +9 -6
  81. package/src/core/dom-renderer/domRendererUtils.ts +2 -2
  82. package/src/core/elementNode.ts +145 -66
  83. package/src/core/focusManager.ts +171 -145
  84. package/src/core/intrinsicTypes.ts +19 -7
  85. package/src/core/lightningInit.ts +23 -21
  86. package/src/core/shaders.ts +10 -10
  87. package/src/core/utils.ts +4 -7
  88. package/src/index.ts +1 -1
  89. package/src/primitives/FPSCounter.tsx +14 -10
  90. package/src/primitives/Image.tsx +18 -9
  91. package/src/primitives/KeepAlive.tsx +18 -10
  92. package/src/primitives/LazyImport.ts +8 -6
  93. package/src/primitives/Preserve.tsx +13 -8
  94. package/src/primitives/Suspense.tsx +10 -9
  95. package/src/primitives/Virtual.tsx +1 -8
  96. package/src/primitives/announcer/announcer.ts +3 -2
  97. package/src/primitives/announcer/speech.ts +2 -2
  98. package/src/primitives/borderBox.tsx +7 -3
  99. package/src/primitives/createTag.tsx +23 -17
  100. package/src/primitives/portal.tsx +20 -10
  101. package/src/primitives/useFocusManager.ts +5 -44
  102. package/src/primitives/useMouse.ts +4 -4
  103. package/src/primitives/utils/chainFunctions.ts +31 -11
  104. package/src/primitives/utils/createBlurredImage.ts +58 -40
  105. package/src/primitives/utils/handleNavigation.ts +9 -7
  106. package/src/primitives/utils/withScrolling.ts +3 -5
  107. package/src/render.ts +5 -7
  108. package/src/solidOpts.ts +11 -30
  109. package/src/types.ts +0 -1
  110. package/src/utils.ts +12 -10
  111. package/dist/src/activeElement.d.ts +0 -2
  112. package/dist/src/activeElement.js +0 -3
  113. package/dist/src/activeElement.js.map +0 -1
  114. package/src/activeElement.ts +0 -5
@@ -172,46 +172,99 @@ function updateNodeParent(node) {
172
172
  if (parent instanceof DOMNode) {
173
173
  elMap.get(parent).appendChild(node.div);
174
174
  }
175
+ else {
176
+ node.div.parentNode?.removeChild(node.div);
177
+ }
178
+ }
179
+ /**
180
+ * Builds the CSS transform string from node props (x, y, rotation, scale, mount).
181
+ * Returns an empty string if no transform is needed.
182
+ */
183
+ function buildTransformCSS(props) {
184
+ const transforms = [];
185
+ const { x, y } = props;
186
+ const hasMountX = props.mountX != null && props.mountX !== 0;
187
+ const hasMountY = props.mountY != null && props.mountY !== 0;
188
+ if (x !== 0)
189
+ transforms.push(`translateX(${x}px)`);
190
+ if (hasMountX)
191
+ transforms.push(`translateX(${-props.mountX * 100}%)`);
192
+ if (y !== 0)
193
+ transforms.push(`translateY(${y}px)`);
194
+ if (hasMountY)
195
+ transforms.push(`translateY(${-props.mountY * 100}%)`);
196
+ if (props.rotation !== 0)
197
+ transforms.push(`rotate(${props.rotation}rad)`);
198
+ if (props.scale !== 1 && props.scale != null) {
199
+ transforms.push(`scale(${props.scale})`);
200
+ }
201
+ else {
202
+ if (props.scaleX !== 1)
203
+ transforms.push(`scaleX(${props.scaleX})`);
204
+ if (props.scaleY !== 1)
205
+ transforms.push(`scaleY(${props.scaleY})`);
206
+ }
207
+ return transforms.join(' ');
208
+ }
209
+ /**
210
+ * Fast path for transform-only updates (x, y, rotation, scale, mount).
211
+ * Skips full style rebuild but still re-evaluates viewport bounds for nodes
212
+ * with a texture source to drive lazy image load/unload during scroll.
213
+ */
214
+ function updateTransformOnly(node) {
215
+ const transform = buildTransformCSS(node.props);
216
+ const s = node.div.style;
217
+ if (transform.length > 0) {
218
+ s.transform = `${transform}`;
219
+ }
220
+ else {
221
+ s.transform = '';
222
+ }
223
+ updateRenderStateIfNeeded(node);
224
+ }
225
+ /**
226
+ * Recomputes the viewport bounds state for a node with a texture source and,
227
+ * if changed, triggers lazy image load or unload via updateRenderState.
228
+ */
229
+ function updateRenderStateIfNeeded(node) {
230
+ if (!(node instanceof DOMNode) || node === node.stage.root)
231
+ return;
232
+ const hasTextureSrc = nodeHasTextureSource(node);
233
+ if (hasTextureSrc && node.boundsDirty) {
234
+ const next = computeRenderStateForNode(node);
235
+ if (next != null) {
236
+ node.updateRenderState(next);
237
+ }
238
+ node.boundsDirty = false;
239
+ }
240
+ else if (!hasTextureSrc) {
241
+ node.boundsDirty = false;
242
+ }
243
+ }
244
+ function applyLegacyObjectFit(node, img, srcPos) {
245
+ const resizeMode = node.props.textureOptions?.resizeMode;
246
+ const clipX = resizeMode?.type !== 'contain' && resizeMode?.clipX
247
+ ? resizeMode?.clipX
248
+ : 0.5;
249
+ const clipY = resizeMode?.type !== 'contain' && resizeMode?.clipY
250
+ ? resizeMode?.clipY
251
+ : 0.5;
252
+ computeLegacyObjectFit(node, img, resizeMode, clipX, clipY, srcPos, supportsObjectFit, supportsObjectPosition);
175
253
  }
176
254
  function updateNodeStyles(node) {
177
255
  const { props } = node;
178
- let style = `position: absolute; z-index: ${props.zIndex}; opacity: ${props.alpha ?? 1};`;
256
+ let style = `position: absolute; z-index: ${props.zIndex};`;
257
+ if (props.alpha !== 1)
258
+ style += `opacity: ${props.alpha};`;
179
259
  if (props.clipping) {
180
260
  style += `overflow: hidden;`;
181
261
  }
182
262
  // Transform
183
263
  {
184
- let transform = '';
185
- const { x, y } = props;
186
- const hasMountX = props.mountX != null && props.mountX !== 0;
187
- const hasMountY = props.mountY != null && props.mountY !== 0;
188
- if (x !== 0)
189
- transform += `translateX(${x}px)`;
190
- if (hasMountX)
191
- transform += `translateX(${-props.mountX * 100}%)`;
192
- if (y !== 0)
193
- transform += `translateY(${y}px)`;
194
- if (hasMountY)
195
- transform += `translateY(${-props.mountY * 100}%)`;
196
- if (props.rotation !== 0)
197
- transform += `rotate(${props.rotation}rad)`;
198
- if (props.scale !== 1 && props.scale != null) {
199
- transform += `scale(${props.scale})`;
200
- }
201
- else {
202
- if (props.scaleX !== 1)
203
- transform += `scaleX(${props.scaleX})`;
204
- if (props.scaleY !== 1)
205
- transform += `scaleY(${props.scaleY})`;
206
- }
264
+ const transform = buildTransformCSS(props);
207
265
  if (transform.length > 0) {
208
266
  style += `transform: ${transform};`;
209
267
  }
210
- const pivotX = props.pivotX ?? props.pivot ?? 0.5;
211
- const pivotY = props.pivotY ?? props.pivot ?? 0.5;
212
- if (pivotX !== 0.5 || pivotY !== 0.5) {
213
- style += `transform-origin: ${pivotX * 100}% ${pivotY * 100}%;`;
214
- }
215
268
  }
216
269
  // <Text>
217
270
  if (node instanceof DOMText) {
@@ -354,9 +407,9 @@ function updateNodeStyles(node) {
354
407
  let needsBackgroundLayer = false;
355
408
  let imgStyle = '';
356
409
  let hasDivBgTint = false;
410
+ let hasTint = false;
357
411
  if (rawImgSrc) {
358
- needsBackgroundLayer = true;
359
- const hasTint = props.color !== 0xffffffff && props.color !== 0x00000000;
412
+ hasTint = props.color !== 0xffffffff && props.color !== 0x00000000;
360
413
  if (hasTint) {
361
414
  bgStyle += `background-color: ${colorToRgba(props.color)};`;
362
415
  if (srcImg) {
@@ -382,6 +435,8 @@ function updateNodeStyles(node) {
382
435
  'bottom: 0',
383
436
  'display: block',
384
437
  'pointer-events: none',
438
+ `opacity: ${node.imageLoading ? 0 : 1}`,
439
+ 'transition: opacity 100ms linear',
385
440
  ];
386
441
  if (props.textureOptions.resizeMode?.type) {
387
442
  const resizeMode = props.textureOptions.resizeMode;
@@ -417,7 +472,7 @@ function updateNodeStyles(node) {
417
472
  imgStyleParts.push('mix-blend-mode: multiply');
418
473
  }
419
474
  else {
420
- imgStyleParts.push('opacity: 0.9');
475
+ imgStyleParts.push('opacity: 1');
421
476
  }
422
477
  }
423
478
  imgStyle = imgStyleParts.join('; ') + ';';
@@ -596,6 +651,15 @@ function updateNodeStyles(node) {
596
651
  needsBackgroundLayer = true;
597
652
  }
598
653
  }
654
+ // If there's still no reason to use divBg, check out tint/gradient/subtexture/radius/bgStyle
655
+ if (!needsBackgroundLayer && rawImgSrc) {
656
+ needsBackgroundLayer =
657
+ hasTint ||
658
+ !!gradient ||
659
+ srcPos !== null ||
660
+ radiusStyle !== '' ||
661
+ bgStyle !== '';
662
+ }
599
663
  style += radiusStyle;
600
664
  if (needsBackgroundLayer) {
601
665
  if (node.divBg == null) {
@@ -605,13 +669,31 @@ function updateNodeStyles(node) {
605
669
  else if (node.divBg.parentElement !== node.div) {
606
670
  node.div.insertBefore(node.divBg, node.div.firstChild);
607
671
  }
608
- let bgLayerStyle = 'position: absolute; top:0; left:0; right:0; bottom:0; z-index: -1; pointer-events: none; overflow: hidden;';
672
+ const isSyncSubtextureUpdate = rawImgSrc != null &&
673
+ srcPos != null &&
674
+ !!node.imgEl &&
675
+ node.imgEl.complete &&
676
+ node.imgEl.dataset.rawSrc === rawImgSrc;
677
+ if (isSyncSubtextureUpdate) {
678
+ node.imageLoading = true;
679
+ }
680
+ let bgLayerStyle = 'position: absolute; top:0; left:0; right:0; bottom:0; z-index: -1; pointer-events: none;';
681
+ // overflow:hidden clips the transformed imgEl to prevent sprite bleed-through
682
+ // for non-tinted subtextures. NOT applied when hasDivBgTint because
683
+ // overflow:hidden + CSS mask-image causes a 1px white border artifact on WebKit.
684
+ // Tinted nodes use mask-image for visual clipping, so overflow:hidden is unnecessary.
685
+ if (srcPos !== null && !hasDivBgTint) {
686
+ bgLayerStyle += 'overflow: hidden;';
687
+ }
609
688
  if (bgStyle) {
610
689
  bgLayerStyle += bgStyle;
611
690
  }
612
691
  if (maskStyle) {
613
692
  bgLayerStyle += maskStyle;
614
693
  }
694
+ if (hasDivBgTint && srcPos != null && node.imageLoading) {
695
+ bgLayerStyle += 'opacity: 0;';
696
+ }
615
697
  node.divBg.setAttribute('style', bgLayerStyle + radiusStyle);
616
698
  if (rawImgSrc) {
617
699
  if (!node.imgEl) {
@@ -631,13 +713,20 @@ function updateNodeStyles(node) {
631
713
  };
632
714
  node.imgEl.style.display = '';
633
715
  applySubTextureScaling(node, node.imgEl, node.lazyImageSubTextureProps);
634
- const resizeMode = node.props.textureOptions?.resizeMode;
635
- const clipX = resizeMode?.clipX ?? 0.5;
636
- const clipY = resizeMode?.clipY ?? 0.5;
637
- computeLegacyObjectFit(node, node.imgEl, resizeMode, clipX, clipY, node.lazyImageSubTextureProps, supportsObjectFit, supportsObjectPosition);
716
+ if (!node.lazyImageSubTextureProps) {
717
+ applyLegacyObjectFit(node, node.imgEl, null);
718
+ }
719
+ // Reveal only after final fit/positioning is applied
720
+ if (node.imgEl) {
721
+ node.imageLoading = false;
722
+ node.imgEl.style.opacity = '1';
723
+ }
724
+ node.showBackgroundLayer();
638
725
  node.emit('loaded', payload);
639
726
  });
640
727
  node.imgEl.addEventListener('error', () => {
728
+ node.imageLoading = false;
729
+ node.showBackgroundLayer();
641
730
  if (node.imgEl) {
642
731
  node.imgEl.removeAttribute('src');
643
732
  node.imgEl.style.display = 'none';
@@ -657,7 +746,7 @@ function updateNodeStyles(node) {
657
746
  if (node.imgEl.parentElement !== node.divBg) {
658
747
  node.divBg.appendChild(node.imgEl);
659
748
  }
660
- node.imgEl.setAttribute('style', imgStyle);
749
+ node.imgEl.setAttribute('style', imgStyle + radiusStyle);
661
750
  if (hasDivBgTint) {
662
751
  node.imgEl.style.visibility = 'hidden';
663
752
  }
@@ -671,15 +760,17 @@ function updateNodeStyles(node) {
671
760
  node.imgEl.complete &&
672
761
  node.imgEl.dataset.rawSrc === rawImgSrc) {
673
762
  applySubTextureScaling(node, node.imgEl, srcPos);
763
+ if (node.imageLoading) {
764
+ node.imageLoading = false;
765
+ node.imgEl.style.opacity = '1';
766
+ node.showBackgroundLayer();
767
+ }
674
768
  }
675
769
  if (!srcPos &&
676
770
  node.imgEl.complete &&
677
771
  (!supportsObjectFit || !supportsObjectPosition) &&
678
772
  node.imgEl.dataset.rawSrc === rawImgSrc) {
679
- const resizeMode = node.props.textureOptions?.resizeMode;
680
- const clipX = resizeMode?.clipX ?? 0.5;
681
- const clipY = resizeMode?.clipY ?? 0.5;
682
- computeLegacyObjectFit(node, node.imgEl, resizeMode, clipX, clipY, srcPos, supportsObjectFit, supportsObjectPosition);
773
+ applyLegacyObjectFit(node, node.imgEl, srcPos);
683
774
  }
684
775
  }
685
776
  else {
@@ -691,6 +782,90 @@ function updateNodeStyles(node) {
691
782
  }
692
783
  }
693
784
  }
785
+ else if (rawImgSrc) {
786
+ // Image directly in node.div (without divBg) when there is no tint/gradient
787
+ // Cleanup divBg
788
+ if (node.divBg) {
789
+ node.divBg.remove();
790
+ node.divBg = undefined;
791
+ }
792
+ const isSyncSubtextureUpdate = srcPos != null &&
793
+ !!node.imgEl &&
794
+ node.imgEl.complete &&
795
+ node.imgEl.dataset.rawSrc === rawImgSrc;
796
+ if (isSyncSubtextureUpdate) {
797
+ node.imageLoading = true;
798
+ }
799
+ if (!node.imgEl) {
800
+ node.imgEl = document.createElement('img');
801
+ node.imgEl.alt = '';
802
+ node.imgEl.crossOrigin = 'anonymous';
803
+ node.imgEl.setAttribute('aria-hidden', 'true');
804
+ node.imgEl.setAttribute('loading', 'lazy');
805
+ node.imgEl.removeAttribute('src');
806
+ node.imgEl.addEventListener('load', () => {
807
+ const payload = {
808
+ type: 'texture',
809
+ dimensions: {
810
+ w: node.imgEl.naturalWidth,
811
+ h: node.imgEl.naturalHeight,
812
+ },
813
+ };
814
+ node.imgEl.style.display = '';
815
+ applySubTextureScaling(node, node.imgEl, node.lazyImageSubTextureProps);
816
+ if (!node.lazyImageSubTextureProps) {
817
+ applyLegacyObjectFit(node, node.imgEl, null);
818
+ }
819
+ if (node.imgEl) {
820
+ node.imageLoading = false;
821
+ node.imgEl.style.opacity = '1';
822
+ }
823
+ node.emit('loaded', payload);
824
+ });
825
+ node.imgEl.addEventListener('error', () => {
826
+ node.imageLoading = false;
827
+ if (node.imgEl) {
828
+ node.imgEl.removeAttribute('src');
829
+ node.imgEl.style.display = 'none';
830
+ node.imgEl.removeAttribute('data-rawSrc');
831
+ }
832
+ const failedSrc = node.imgEl?.dataset.pendingSrc || node.lazyImagePendingSrc || '';
833
+ const payload = {
834
+ type: 'texture',
835
+ error: new Error(`Failed to load image: ${failedSrc}`),
836
+ };
837
+ node.emit('failed', payload);
838
+ });
839
+ }
840
+ node.lazyImagePendingSrc = rawImgSrc;
841
+ node.lazyImageSubTextureProps = srcPos;
842
+ node.imgEl.dataset.pendingSrc = rawImgSrc;
843
+ if (node.imgEl.parentElement !== node.div) {
844
+ node.div.appendChild(node.imgEl);
845
+ }
846
+ node.imgEl.setAttribute('style', imgStyle + radiusStyle);
847
+ if (isRenderStateInBounds(node.renderState)) {
848
+ node.applyPendingImageSrc();
849
+ }
850
+ else if (!node.imgEl.dataset.rawSrc) {
851
+ node.imgEl.removeAttribute('src');
852
+ }
853
+ if (srcPos &&
854
+ node.imgEl.complete &&
855
+ node.imgEl.dataset.rawSrc === rawImgSrc) {
856
+ applySubTextureScaling(node, node.imgEl, srcPos);
857
+ if (node.imageLoading) {
858
+ node.imageLoading = false;
859
+ node.imgEl.style.opacity = '1';
860
+ }
861
+ }
862
+ if (!srcPos &&
863
+ node.imgEl.complete &&
864
+ (!supportsObjectFit || !supportsObjectPosition) &&
865
+ node.imgEl.dataset.rawSrc === rawImgSrc) {
866
+ applyLegacyObjectFit(node, node.imgEl, srcPos);
867
+ }
868
+ }
694
869
  else {
695
870
  node.lazyImagePendingSrc = null;
696
871
  node.lazyImageSubTextureProps = null;
@@ -724,20 +899,12 @@ function updateNodeStyles(node) {
724
899
  node.divBorder.setAttribute('style', borderLayerStyle + radiusStyle);
725
900
  }
726
901
  }
727
- node.div.setAttribute('style', compactString(style));
728
- if (node instanceof DOMNode && node !== node.stage.root) {
729
- const hasTextureSrc = nodeHasTextureSource(node);
730
- if (hasTextureSrc && node.boundsDirty) {
731
- const next = computeRenderStateForNode(node);
732
- if (next != null) {
733
- node.updateRenderState(next);
734
- }
735
- node.boundsDirty = false;
736
- }
737
- else if (!hasTextureSrc) {
738
- node.boundsDirty = false;
739
- }
902
+ const newStyle = compactString(style);
903
+ if (node._lastStyleStr !== newStyle) {
904
+ node._lastStyleStr = newStyle;
905
+ node.div.setAttribute('style', newStyle);
740
906
  }
907
+ updateRenderStateIfNeeded(node);
741
908
  }
742
909
  const textNodesToMeasure = new Set();
743
910
  const containTextNodes = new Set();
@@ -801,6 +968,7 @@ function updateDOMTextSize(node, emitLoaded = true) {
801
968
  w: node.w,
802
969
  h: node.h,
803
970
  },
971
+ trimmedHeight: node.h,
804
972
  };
805
973
  node.emit('loaded', payload);
806
974
  node.loaded = true;
@@ -857,14 +1025,16 @@ function scheduleUpdateDOMTextMeasurement(node) {
857
1025
  if (fonts.status === 'loaded') {
858
1026
  setTimeout(updateDOMTextMeasurements);
859
1027
  }
860
- else if (fonts.ready && typeof fonts.ready.then === 'function') {
861
- fonts.ready.then(updateDOMTextMeasurements);
1028
+ else if (fonts.ready != null &&
1029
+ typeof fonts.ready.then === 'function') {
1030
+ void fonts.ready.then(updateDOMTextMeasurements);
862
1031
  }
863
1032
  else {
864
1033
  setTimeout(updateDOMTextMeasurements, 500);
865
1034
  }
866
1035
  }
867
1036
  else {
1037
+ // Fallback for devices without FontFaceSet.ready()
868
1038
  setTimeout(updateDOMTextMeasurements, 500);
869
1039
  }
870
1040
  }
@@ -970,10 +1140,13 @@ export class DOMNode extends EventEmitter {
970
1140
  divBg;
971
1141
  divBorder;
972
1142
  imgEl;
1143
+ imageLoading = false;
973
1144
  lazyImagePendingSrc = null;
974
1145
  lazyImageSubTextureProps = null;
975
1146
  boundsDirty = true;
976
1147
  children = new Set();
1148
+ /** Cached result of the last updateNodeStyles call — avoids redundant setAttribute writes. */
1149
+ _lastStyleStr = '';
977
1150
  id = ++lastNodeId;
978
1151
  renderState = 0 /* Init */;
979
1152
  preventCleanup = true;
@@ -999,7 +1172,7 @@ export class DOMNode extends EventEmitter {
999
1172
  if (parent instanceof DOMNode) {
1000
1173
  parent.children.delete(this);
1001
1174
  }
1002
- this.div.parentNode.removeChild(this.div);
1175
+ this.div.parentNode?.removeChild(this.div);
1003
1176
  }
1004
1177
  get parent() {
1005
1178
  return this.props.parent;
@@ -1053,6 +1226,17 @@ export class DOMNode extends EventEmitter {
1053
1226
  this.imgEl.dataset.state = event;
1054
1227
  }
1055
1228
  }
1229
+ showBackgroundLayer() {
1230
+ if (this.divBg) {
1231
+ this.divBg.style.opacity = '1';
1232
+ }
1233
+ }
1234
+ hideMaskedBackgroundLayer() {
1235
+ if (this.divBg &&
1236
+ (this.divBg.style.maskImage || this.divBg.style.webkitMaskImage)) {
1237
+ this.divBg.style.opacity = '0';
1238
+ }
1239
+ }
1056
1240
  applyPendingImageSrc() {
1057
1241
  if (!this.imgEl)
1058
1242
  return;
@@ -1061,6 +1245,10 @@ export class DOMNode extends EventEmitter {
1061
1245
  return;
1062
1246
  if (this.imgEl.dataset.rawSrc === pendingSrc)
1063
1247
  return;
1248
+ // Hide transient frame while source is loading and being fitted.
1249
+ this.imageLoading = true;
1250
+ this.imgEl.style.opacity = '0';
1251
+ this.hideMaskedBackgroundLayer();
1064
1252
  this.imgEl.style.display = '';
1065
1253
  this.imgEl.dataset.pendingSrc = pendingSrc;
1066
1254
  this.imgEl.src = pendingSrc;
@@ -1076,7 +1264,7 @@ export class DOMNode extends EventEmitter {
1076
1264
  this.props.x = v;
1077
1265
  this.boundsDirty = true;
1078
1266
  this.markChildrenBoundsDirty();
1079
- updateNodeStyles(this);
1267
+ updateTransformOnly(this);
1080
1268
  }
1081
1269
  get y() {
1082
1270
  return this.props.y;
@@ -1087,7 +1275,7 @@ export class DOMNode extends EventEmitter {
1087
1275
  this.props.y = v;
1088
1276
  this.boundsDirty = true;
1089
1277
  this.markChildrenBoundsDirty();
1090
- updateNodeStyles(this);
1278
+ updateTransformOnly(this);
1091
1279
  }
1092
1280
  get w() {
1093
1281
  return this.props.w;
@@ -1262,7 +1450,7 @@ export class DOMNode extends EventEmitter {
1262
1450
  this.props.scale = v;
1263
1451
  this.boundsDirty = true;
1264
1452
  this.markChildrenBoundsDirty();
1265
- updateNodeStyles(this);
1453
+ updateTransformOnly(this);
1266
1454
  }
1267
1455
  get scaleX() {
1268
1456
  return this.props.scaleX;
@@ -1273,7 +1461,7 @@ export class DOMNode extends EventEmitter {
1273
1461
  this.props.scaleX = v;
1274
1462
  this.boundsDirty = true;
1275
1463
  this.markChildrenBoundsDirty();
1276
- updateNodeStyles(this);
1464
+ updateTransformOnly(this);
1277
1465
  }
1278
1466
  get scaleY() {
1279
1467
  return this.props.scaleY;
@@ -1284,7 +1472,7 @@ export class DOMNode extends EventEmitter {
1284
1472
  this.props.scaleY = v;
1285
1473
  this.boundsDirty = true;
1286
1474
  this.markChildrenBoundsDirty();
1287
- updateNodeStyles(this);
1475
+ updateTransformOnly(this);
1288
1476
  }
1289
1477
  get mount() {
1290
1478
  return this.props.mount;
@@ -1295,7 +1483,7 @@ export class DOMNode extends EventEmitter {
1295
1483
  this.props.mount = v;
1296
1484
  this.boundsDirty = true;
1297
1485
  this.markChildrenBoundsDirty();
1298
- updateNodeStyles(this);
1486
+ updateTransformOnly(this);
1299
1487
  }
1300
1488
  get mountX() {
1301
1489
  return this.props.mountX;
@@ -1306,7 +1494,7 @@ export class DOMNode extends EventEmitter {
1306
1494
  this.props.mountX = v;
1307
1495
  this.boundsDirty = true;
1308
1496
  this.markChildrenBoundsDirty();
1309
- updateNodeStyles(this);
1497
+ updateTransformOnly(this);
1310
1498
  }
1311
1499
  get mountY() {
1312
1500
  return this.props.mountY;
@@ -1317,7 +1505,7 @@ export class DOMNode extends EventEmitter {
1317
1505
  this.props.mountY = v;
1318
1506
  this.boundsDirty = true;
1319
1507
  this.markChildrenBoundsDirty();
1320
- updateNodeStyles(this);
1508
+ updateTransformOnly(this);
1321
1509
  }
1322
1510
  get pivot() {
1323
1511
  return this.props.pivot;
@@ -1361,7 +1549,7 @@ export class DOMNode extends EventEmitter {
1361
1549
  this.props.rotation = v;
1362
1550
  this.boundsDirty = true;
1363
1551
  this.markChildrenBoundsDirty();
1364
- updateNodeStyles(this);
1552
+ updateTransformOnly(this);
1365
1553
  }
1366
1554
  get rtt() {
1367
1555
  return this.props.rtt;