@solidtv/solid 1.1.1 → 1.1.3

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 (99) 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 +1 -13
  5. package/dist/src/core/config.js +10 -2
  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 +254 -67
  9. package/dist/src/core/dom-renderer/domRenderer.js.map +1 -1
  10. package/dist/src/core/elementNode.d.ts +20 -7
  11. package/dist/src/core/elementNode.js +54 -14
  12. package/dist/src/core/elementNode.js.map +1 -1
  13. package/dist/src/core/focusManager.js +5 -3
  14. package/dist/src/core/focusManager.js.map +1 -1
  15. package/dist/src/core/intrinsicTypes.d.ts +2 -0
  16. package/dist/src/core/lightningInit.d.ts +1 -1
  17. package/dist/src/core/lightningInit.js +6 -6
  18. package/dist/src/core/lightningInit.js.map +1 -1
  19. package/dist/src/core/utils.js +4 -4
  20. package/dist/src/core/utils.js.map +1 -1
  21. package/dist/src/primitives/Column.jsx +1 -1
  22. package/dist/src/primitives/Column.jsx.map +1 -1
  23. package/dist/src/primitives/FPSCounter.jsx +5 -5
  24. package/dist/src/primitives/FPSCounter.jsx.map +1 -1
  25. package/dist/src/primitives/Image.jsx +6 -1
  26. package/dist/src/primitives/Image.jsx.map +1 -1
  27. package/dist/src/primitives/KeepAlive.d.ts +4 -3
  28. package/dist/src/primitives/KeepAlive.jsx +60 -23
  29. package/dist/src/primitives/KeepAlive.jsx.map +1 -1
  30. package/dist/src/primitives/LazyImport.js +4 -2
  31. package/dist/src/primitives/LazyImport.js.map +1 -1
  32. package/dist/src/primitives/Preserve.jsx +10 -4
  33. package/dist/src/primitives/Preserve.jsx.map +1 -1
  34. package/dist/src/primitives/Row.jsx +1 -1
  35. package/dist/src/primitives/Row.jsx.map +1 -1
  36. package/dist/src/primitives/Suspense.jsx +7 -7
  37. package/dist/src/primitives/Suspense.jsx.map +1 -1
  38. package/dist/src/primitives/Virtual.jsx +1 -1
  39. package/dist/src/primitives/Virtual.jsx.map +1 -1
  40. package/dist/src/primitives/announcer/announcer.js +3 -2
  41. package/dist/src/primitives/announcer/announcer.js.map +1 -1
  42. package/dist/src/primitives/announcer/speech.js +2 -2
  43. package/dist/src/primitives/announcer/speech.js.map +1 -1
  44. package/dist/src/primitives/borderBox.jsx +2 -1
  45. package/dist/src/primitives/borderBox.jsx.map +1 -1
  46. package/dist/src/primitives/createTag.jsx +3 -3
  47. package/dist/src/primitives/createTag.jsx.map +1 -1
  48. package/dist/src/primitives/portal.jsx +4 -3
  49. package/dist/src/primitives/portal.jsx.map +1 -1
  50. package/dist/src/primitives/utils/chainFunctions.js +35 -9
  51. package/dist/src/primitives/utils/chainFunctions.js.map +1 -1
  52. package/dist/src/primitives/utils/createBlurredImage.js +57 -37
  53. package/dist/src/primitives/utils/createBlurredImage.js.map +1 -1
  54. package/dist/src/primitives/utils/handleNavigation.js +21 -16
  55. package/dist/src/primitives/utils/handleNavigation.js.map +1 -1
  56. package/dist/src/primitives/utils/withScrolling.js +1 -3
  57. package/dist/src/primitives/utils/withScrolling.js.map +1 -1
  58. package/dist/src/render.d.ts +1 -1
  59. package/dist/src/render.js +2 -1
  60. package/dist/src/render.js.map +1 -1
  61. package/dist/src/solidOpts.d.ts +1 -1
  62. package/dist/src/solidOpts.js +4 -2
  63. package/dist/src/solidOpts.js.map +1 -1
  64. package/dist/src/utils.js +10 -5
  65. package/dist/src/utils.js.map +1 -1
  66. package/dist/tsconfig.tsbuildinfo +1 -1
  67. package/docs/README.md +2 -2
  68. package/package.json +28 -29
  69. package/src/core/clickInspector.ts +77 -0
  70. package/src/core/config.ts +6 -20
  71. package/src/core/dom-renderer/domRenderer.ts +307 -89
  72. package/src/core/dom-renderer/domRendererTypes.ts +9 -6
  73. package/src/core/elementNode.ts +80 -26
  74. package/src/core/focusManager.ts +16 -8
  75. package/src/core/intrinsicTypes.ts +19 -7
  76. package/src/core/lightningInit.ts +20 -18
  77. package/src/core/utils.ts +4 -4
  78. package/src/primitives/Column.tsx +0 -1
  79. package/src/primitives/FPSCounter.tsx +14 -10
  80. package/src/primitives/Image.tsx +18 -9
  81. package/src/primitives/KeepAlive.tsx +88 -44
  82. package/src/primitives/LazyImport.ts +8 -6
  83. package/src/primitives/Preserve.tsx +13 -8
  84. package/src/primitives/Row.tsx +0 -1
  85. package/src/primitives/Suspense.tsx +10 -9
  86. package/src/primitives/Virtual.tsx +1 -9
  87. package/src/primitives/announcer/announcer.ts +3 -2
  88. package/src/primitives/announcer/speech.ts +2 -2
  89. package/src/primitives/borderBox.tsx +7 -3
  90. package/src/primitives/createTag.tsx +23 -17
  91. package/src/primitives/portal.tsx +20 -10
  92. package/src/primitives/utils/chainFunctions.ts +31 -11
  93. package/src/primitives/utils/createBlurredImage.ts +58 -40
  94. package/src/primitives/utils/handleNavigation.ts +29 -18
  95. package/src/primitives/utils/withScrolling.ts +3 -5
  96. package/src/render.ts +4 -4
  97. package/src/solidOpts.ts +9 -7
  98. package/src/types.ts +0 -1
  99. package/src/utils.ts +12 -10
@@ -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();
@@ -857,14 +1024,16 @@ function scheduleUpdateDOMTextMeasurement(node) {
857
1024
  if (fonts.status === 'loaded') {
858
1025
  setTimeout(updateDOMTextMeasurements);
859
1026
  }
860
- else if (fonts.ready && typeof fonts.ready.then === 'function') {
861
- fonts.ready.then(updateDOMTextMeasurements);
1027
+ else if (fonts.ready != null &&
1028
+ typeof fonts.ready.then === 'function') {
1029
+ void fonts.ready.then(updateDOMTextMeasurements);
862
1030
  }
863
1031
  else {
864
1032
  setTimeout(updateDOMTextMeasurements, 500);
865
1033
  }
866
1034
  }
867
1035
  else {
1036
+ // Fallback for devices without FontFaceSet.ready()
868
1037
  setTimeout(updateDOMTextMeasurements, 500);
869
1038
  }
870
1039
  }
@@ -970,10 +1139,13 @@ export class DOMNode extends EventEmitter {
970
1139
  divBg;
971
1140
  divBorder;
972
1141
  imgEl;
1142
+ imageLoading = false;
973
1143
  lazyImagePendingSrc = null;
974
1144
  lazyImageSubTextureProps = null;
975
1145
  boundsDirty = true;
976
1146
  children = new Set();
1147
+ /** Cached result of the last updateNodeStyles call — avoids redundant setAttribute writes. */
1148
+ _lastStyleStr = '';
977
1149
  id = ++lastNodeId;
978
1150
  renderState = 0 /* Init */;
979
1151
  preventCleanup = true;
@@ -999,7 +1171,7 @@ export class DOMNode extends EventEmitter {
999
1171
  if (parent instanceof DOMNode) {
1000
1172
  parent.children.delete(this);
1001
1173
  }
1002
- this.div.parentNode.removeChild(this.div);
1174
+ this.div.parentNode?.removeChild(this.div);
1003
1175
  }
1004
1176
  get parent() {
1005
1177
  return this.props.parent;
@@ -1053,6 +1225,17 @@ export class DOMNode extends EventEmitter {
1053
1225
  this.imgEl.dataset.state = event;
1054
1226
  }
1055
1227
  }
1228
+ showBackgroundLayer() {
1229
+ if (this.divBg) {
1230
+ this.divBg.style.opacity = '1';
1231
+ }
1232
+ }
1233
+ hideMaskedBackgroundLayer() {
1234
+ if (this.divBg &&
1235
+ (this.divBg.style.maskImage || this.divBg.style.webkitMaskImage)) {
1236
+ this.divBg.style.opacity = '0';
1237
+ }
1238
+ }
1056
1239
  applyPendingImageSrc() {
1057
1240
  if (!this.imgEl)
1058
1241
  return;
@@ -1061,6 +1244,10 @@ export class DOMNode extends EventEmitter {
1061
1244
  return;
1062
1245
  if (this.imgEl.dataset.rawSrc === pendingSrc)
1063
1246
  return;
1247
+ // Hide transient frame while source is loading and being fitted.
1248
+ this.imageLoading = true;
1249
+ this.imgEl.style.opacity = '0';
1250
+ this.hideMaskedBackgroundLayer();
1064
1251
  this.imgEl.style.display = '';
1065
1252
  this.imgEl.dataset.pendingSrc = pendingSrc;
1066
1253
  this.imgEl.src = pendingSrc;
@@ -1076,7 +1263,7 @@ export class DOMNode extends EventEmitter {
1076
1263
  this.props.x = v;
1077
1264
  this.boundsDirty = true;
1078
1265
  this.markChildrenBoundsDirty();
1079
- updateNodeStyles(this);
1266
+ updateTransformOnly(this);
1080
1267
  }
1081
1268
  get y() {
1082
1269
  return this.props.y;
@@ -1087,7 +1274,7 @@ export class DOMNode extends EventEmitter {
1087
1274
  this.props.y = v;
1088
1275
  this.boundsDirty = true;
1089
1276
  this.markChildrenBoundsDirty();
1090
- updateNodeStyles(this);
1277
+ updateTransformOnly(this);
1091
1278
  }
1092
1279
  get w() {
1093
1280
  return this.props.w;
@@ -1262,7 +1449,7 @@ export class DOMNode extends EventEmitter {
1262
1449
  this.props.scale = v;
1263
1450
  this.boundsDirty = true;
1264
1451
  this.markChildrenBoundsDirty();
1265
- updateNodeStyles(this);
1452
+ updateTransformOnly(this);
1266
1453
  }
1267
1454
  get scaleX() {
1268
1455
  return this.props.scaleX;
@@ -1273,7 +1460,7 @@ export class DOMNode extends EventEmitter {
1273
1460
  this.props.scaleX = v;
1274
1461
  this.boundsDirty = true;
1275
1462
  this.markChildrenBoundsDirty();
1276
- updateNodeStyles(this);
1463
+ updateTransformOnly(this);
1277
1464
  }
1278
1465
  get scaleY() {
1279
1466
  return this.props.scaleY;
@@ -1284,7 +1471,7 @@ export class DOMNode extends EventEmitter {
1284
1471
  this.props.scaleY = v;
1285
1472
  this.boundsDirty = true;
1286
1473
  this.markChildrenBoundsDirty();
1287
- updateNodeStyles(this);
1474
+ updateTransformOnly(this);
1288
1475
  }
1289
1476
  get mount() {
1290
1477
  return this.props.mount;
@@ -1295,7 +1482,7 @@ export class DOMNode extends EventEmitter {
1295
1482
  this.props.mount = v;
1296
1483
  this.boundsDirty = true;
1297
1484
  this.markChildrenBoundsDirty();
1298
- updateNodeStyles(this);
1485
+ updateTransformOnly(this);
1299
1486
  }
1300
1487
  get mountX() {
1301
1488
  return this.props.mountX;
@@ -1306,7 +1493,7 @@ export class DOMNode extends EventEmitter {
1306
1493
  this.props.mountX = v;
1307
1494
  this.boundsDirty = true;
1308
1495
  this.markChildrenBoundsDirty();
1309
- updateNodeStyles(this);
1496
+ updateTransformOnly(this);
1310
1497
  }
1311
1498
  get mountY() {
1312
1499
  return this.props.mountY;
@@ -1317,7 +1504,7 @@ export class DOMNode extends EventEmitter {
1317
1504
  this.props.mountY = v;
1318
1505
  this.boundsDirty = true;
1319
1506
  this.markChildrenBoundsDirty();
1320
- updateNodeStyles(this);
1507
+ updateTransformOnly(this);
1321
1508
  }
1322
1509
  get pivot() {
1323
1510
  return this.props.pivot;
@@ -1361,7 +1548,7 @@ export class DOMNode extends EventEmitter {
1361
1548
  this.props.rotation = v;
1362
1549
  this.boundsDirty = true;
1363
1550
  this.markChildrenBoundsDirty();
1364
- updateNodeStyles(this);
1551
+ updateTransformOnly(this);
1365
1552
  }
1366
1553
  get rtt() {
1367
1554
  return this.props.rtt;