@lightningjs/renderer 3.0.0-beta22 → 3.0.0-beta24

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 (190) hide show
  1. package/README.md +93 -0
  2. package/dist/exports/index.d.ts +3 -1
  3. package/dist/exports/index.js +2 -0
  4. package/dist/exports/index.js.map +1 -1
  5. package/dist/exports/platform.d.ts +7 -0
  6. package/dist/exports/platform.js +27 -0
  7. package/dist/exports/platform.js.map +1 -0
  8. package/dist/src/core/AutosizeManager.d.ts +29 -0
  9. package/dist/src/core/AutosizeManager.js +169 -0
  10. package/dist/src/core/AutosizeManager.js.map +1 -0
  11. package/dist/src/core/CoreNode.d.ts +0 -1
  12. package/dist/src/core/CoreNode.js +47 -41
  13. package/dist/src/core/CoreNode.js.map +1 -1
  14. package/dist/src/core/CoreTextureManager.d.ts +0 -13
  15. package/dist/src/core/CoreTextureManager.js +4 -78
  16. package/dist/src/core/CoreTextureManager.js.map +1 -1
  17. package/dist/src/core/Stage.js +2 -12
  18. package/dist/src/core/Stage.js.map +1 -1
  19. package/dist/src/core/animations/Animation.d.ts +21 -0
  20. package/dist/src/core/animations/Animation.js +194 -0
  21. package/dist/src/core/animations/Animation.js.map +1 -0
  22. package/dist/src/core/animations/CoreAnimationController.d.ts +1 -1
  23. package/dist/src/core/animations/CoreAnimationController.js +4 -2
  24. package/dist/src/core/animations/CoreAnimationController.js.map +1 -1
  25. package/dist/src/core/animations/Playback.d.ts +64 -0
  26. package/dist/src/core/animations/Playback.js +169 -0
  27. package/dist/src/core/animations/Playback.js.map +1 -0
  28. package/dist/src/core/animations/Transition.d.ts +27 -0
  29. package/dist/src/core/animations/Transition.js +52 -0
  30. package/dist/src/core/animations/Transition.js.map +1 -0
  31. package/dist/src/core/animations/utils.d.ts +2 -0
  32. package/dist/src/core/animations/utils.js +136 -0
  33. package/dist/src/core/animations/utils.js.map +1 -0
  34. package/dist/src/core/lib/collectionUtils.d.ts +0 -1
  35. package/dist/src/core/lib/collectionUtils.js +0 -28
  36. package/dist/src/core/lib/collectionUtils.js.map +1 -1
  37. package/dist/src/core/lib/utils.d.ts +0 -5
  38. package/dist/src/core/lib/utils.js +0 -63
  39. package/dist/src/core/lib/utils.js.map +1 -1
  40. package/dist/src/core/platforms/GlContextWrapper.d.ts +136 -0
  41. package/dist/src/core/platforms/GlContextWrapper.js +32 -0
  42. package/dist/src/core/platforms/GlContextWrapper.js.map +1 -0
  43. package/dist/src/core/platforms/Platform.d.ts +74 -13
  44. package/dist/src/core/platforms/Platform.js +18 -0
  45. package/dist/src/core/platforms/Platform.js.map +1 -1
  46. package/dist/src/core/platforms/web/WebGlContextWrapper.d.ts +776 -0
  47. package/dist/src/core/platforms/web/WebGlContextWrapper.js +1208 -0
  48. package/dist/src/core/platforms/web/WebGlContextWrapper.js.map +1 -0
  49. package/dist/src/core/platforms/web/WebPlatform.d.ts +13 -2
  50. package/dist/src/core/platforms/web/WebPlatform.js +109 -8
  51. package/dist/src/core/platforms/web/WebPlatform.js.map +1 -1
  52. package/dist/src/core/platforms/web/WebPlatformChrome50.d.ts +17 -0
  53. package/dist/src/core/platforms/web/WebPlatformChrome50.js +50 -0
  54. package/dist/src/core/platforms/web/WebPlatformChrome50.js.map +1 -0
  55. package/dist/src/core/platforms/web/WebPlatformLegacy.d.ts +18 -0
  56. package/dist/src/core/platforms/web/WebPlatformLegacy.js +99 -0
  57. package/dist/src/core/platforms/web/WebPlatformLegacy.js.map +1 -0
  58. package/dist/src/core/platforms/web/WebPlatformNext.d.ts +21 -0
  59. package/dist/src/core/platforms/web/WebPlatformNext.js +52 -0
  60. package/dist/src/core/platforms/web/WebPlatformNext.js.map +1 -0
  61. package/dist/src/core/platforms/web/lib/ImageWorker.d.ts +15 -0
  62. package/dist/src/core/platforms/web/lib/ImageWorker.js +189 -0
  63. package/dist/src/core/platforms/web/lib/ImageWorker.js.map +1 -0
  64. package/dist/src/core/platforms/web/lib/createImageBitmap.d.ts +1 -0
  65. package/dist/src/core/platforms/web/lib/createImageBitmap.js +27 -0
  66. package/dist/src/core/platforms/web/lib/createImageBitmap.js.map +1 -0
  67. package/dist/src/core/platforms/web/lib/textureCompression.d.ts +26 -0
  68. package/dist/src/core/platforms/web/lib/textureCompression.js +301 -0
  69. package/dist/src/core/platforms/web/lib/textureCompression.js.map +1 -0
  70. package/dist/src/core/platforms/web/lib/textureSvg.d.ts +7 -0
  71. package/dist/src/core/platforms/web/lib/textureSvg.js +51 -0
  72. package/dist/src/core/platforms/web/lib/textureSvg.js.map +1 -0
  73. package/dist/src/core/platforms/web/lib/utils.d.ts +5 -0
  74. package/dist/src/core/platforms/web/lib/utils.js +86 -0
  75. package/dist/src/core/platforms/web/lib/utils.js.map +1 -0
  76. package/dist/src/core/renderers/CoreRenderer.d.ts +1 -9
  77. package/dist/src/core/renderers/CoreRenderer.js +2 -4
  78. package/dist/src/core/renderers/CoreRenderer.js.map +1 -1
  79. package/dist/src/core/renderers/canvas/CanvasRenderer.d.ts +3 -2
  80. package/dist/src/core/renderers/canvas/CanvasRenderer.js +6 -5
  81. package/dist/src/core/renderers/canvas/CanvasRenderer.js.map +1 -1
  82. package/dist/src/core/renderers/canvas/CanvasShaderNode.js +3 -3
  83. package/dist/src/core/renderers/canvas/CanvasShaderNode.js.map +1 -1
  84. package/dist/src/core/renderers/webgl/SdfRenderOp.js +3 -2
  85. package/dist/src/core/renderers/webgl/SdfRenderOp.js.map +1 -1
  86. package/dist/src/core/renderers/webgl/WebGlCtxRenderTexture.d.ts +2 -2
  87. package/dist/src/core/renderers/webgl/WebGlCtxRenderTexture.js.map +1 -1
  88. package/dist/src/core/renderers/webgl/WebGlCtxSubTexture.d.ts +2 -2
  89. package/dist/src/core/renderers/webgl/WebGlCtxSubTexture.js.map +1 -1
  90. package/dist/src/core/renderers/webgl/WebGlCtxTexture.d.ts +3 -3
  91. package/dist/src/core/renderers/webgl/WebGlCtxTexture.js +1 -2
  92. package/dist/src/core/renderers/webgl/WebGlCtxTexture.js.map +1 -1
  93. package/dist/src/core/renderers/webgl/WebGlRenderer.d.ts +5 -5
  94. package/dist/src/core/renderers/webgl/WebGlRenderer.js +10 -11
  95. package/dist/src/core/renderers/webgl/WebGlRenderer.js.map +1 -1
  96. package/dist/src/core/renderers/webgl/WebGlShaderNode.d.ts +2 -2
  97. package/dist/src/core/renderers/webgl/WebGlShaderNode.js +3 -3
  98. package/dist/src/core/renderers/webgl/WebGlShaderNode.js.map +1 -1
  99. package/dist/src/core/renderers/webgl/WebGlShaderProgram.d.ts +2 -2
  100. package/dist/src/core/renderers/webgl/WebGlShaderProgram.js +0 -3
  101. package/dist/src/core/renderers/webgl/WebGlShaderProgram.js.map +1 -1
  102. package/dist/src/core/renderers/webgl/internal/RendererUtils.d.ts +4 -4
  103. package/dist/src/core/renderers/webgl/internal/RendererUtils.js.map +1 -1
  104. package/dist/src/core/renderers/webgl/internal/ShaderUtils.d.ts +3 -3
  105. package/dist/src/core/renderers/webgl/internal/ShaderUtils.js +3 -2
  106. package/dist/src/core/renderers/webgl/internal/ShaderUtils.js.map +1 -1
  107. package/dist/src/core/renderers/webgl/shaders/effects/LinearGradientEffect.js +24 -8
  108. package/dist/src/core/renderers/webgl/shaders/effects/LinearGradientEffect.js.map +1 -1
  109. package/dist/src/core/renderers/webgl/shaders/effects/RadialGradientEffect.js +25 -8
  110. package/dist/src/core/renderers/webgl/shaders/effects/RadialGradientEffect.js.map +1 -1
  111. package/dist/src/core/shaders/webgl/Border.js +6 -4
  112. package/dist/src/core/shaders/webgl/Border.js.map +1 -1
  113. package/dist/src/core/shaders/webgl/RoundedWithBorder.js +16 -17
  114. package/dist/src/core/shaders/webgl/RoundedWithBorder.js.map +1 -1
  115. package/dist/src/core/shaders/webgl/RoundedWithBorderAndShadow.js +19 -21
  116. package/dist/src/core/shaders/webgl/RoundedWithBorderAndShadow.js.map +1 -1
  117. package/dist/src/core/shaders/webgl/SdfShadowShader.d.ts +9 -0
  118. package/dist/src/core/shaders/webgl/SdfShadowShader.js +100 -0
  119. package/dist/src/core/shaders/webgl/SdfShadowShader.js.map +1 -0
  120. package/dist/src/core/text-rendering/CanvasFont.d.ts +1 -1
  121. package/dist/src/core/text-rendering/CanvasFont.js +2 -6
  122. package/dist/src/core/text-rendering/CanvasFont.js.map +1 -1
  123. package/dist/src/core/text-rendering/CoreFont.d.ts +1 -1
  124. package/dist/src/core/text-rendering/CoreFont.js +1 -1
  125. package/dist/src/core/text-rendering/CoreFont.js.map +1 -1
  126. package/dist/src/core/text-rendering/FontManager.js +2 -1
  127. package/dist/src/core/text-rendering/FontManager.js.map +1 -1
  128. package/dist/src/core/text-rendering/SdfFontHandler.js +10 -20
  129. package/dist/src/core/text-rendering/SdfFontHandler.js.map +1 -1
  130. package/dist/src/core/text-rendering/SdfTextRenderer.js +10 -12
  131. package/dist/src/core/text-rendering/SdfTextRenderer.js.map +1 -1
  132. package/dist/src/core/textures/ImageTexture.d.ts +24 -11
  133. package/dist/src/core/textures/ImageTexture.js +32 -95
  134. package/dist/src/core/textures/ImageTexture.js.map +1 -1
  135. package/dist/src/core/textures/SubTexture.js +3 -3
  136. package/dist/src/core/textures/SubTexture.js.map +1 -1
  137. package/dist/src/core/textures/Texture.d.ts +1 -1
  138. package/dist/src/core/textures/Texture.js +1 -1
  139. package/dist/src/core/textures/Texture.js.map +1 -1
  140. package/dist/src/main-api/Renderer.js +18 -21
  141. package/dist/src/main-api/Renderer.js.map +1 -1
  142. package/dist/src/utils.d.ts +0 -2
  143. package/dist/src/utils.js +0 -36
  144. package/dist/src/utils.js.map +1 -1
  145. package/dist/tsconfig.dist.tsbuildinfo +1 -1
  146. package/dist/tsconfig.tsbuildinfo +1 -0
  147. package/exports/index.ts +3 -1
  148. package/exports/platform.ts +31 -0
  149. package/package.json +3 -2
  150. package/src/core/CoreNode.ts +52 -49
  151. package/src/core/CoreTextureManager.ts +10 -103
  152. package/src/core/Stage.ts +1 -14
  153. package/src/core/animations/CoreAnimationController.ts +5 -2
  154. package/src/core/lib/collectionUtils.ts +0 -35
  155. package/src/core/lib/utils.ts +0 -78
  156. package/src/core/platforms/GlContextWrapper.ts +291 -0
  157. package/src/core/platforms/Platform.ts +121 -28
  158. package/src/core/{lib → platforms/web}/WebGlContextWrapper.ts +129 -4
  159. package/src/core/platforms/web/WebPlatform.ts +171 -22
  160. package/src/core/platforms/web/WebPlatformChrome50.ts +57 -0
  161. package/src/core/platforms/web/WebPlatformLegacy.ts +140 -0
  162. package/src/core/platforms/web/WebPlatformNext.ts +57 -0
  163. package/src/core/{lib → platforms/web/lib}/ImageWorker.ts +10 -74
  164. package/src/core/platforms/web/lib/createImageBitmap.ts +40 -0
  165. package/src/core/{lib → platforms/web/lib}/textureCompression.ts +19 -138
  166. package/src/core/{lib → platforms/web/lib}/textureSvg.ts +3 -15
  167. package/src/core/platforms/web/lib/utils.ts +105 -0
  168. package/src/core/renderers/CoreRenderer.ts +2 -11
  169. package/src/core/renderers/canvas/CanvasRenderer.ts +8 -6
  170. package/src/core/renderers/canvas/CanvasShaderNode.ts +3 -3
  171. package/src/core/renderers/webgl/SdfRenderOp.ts +3 -2
  172. package/src/core/renderers/webgl/WebGlCtxRenderTexture.ts +2 -2
  173. package/src/core/renderers/webgl/WebGlCtxSubTexture.ts +2 -2
  174. package/src/core/renderers/webgl/WebGlCtxTexture.ts +3 -4
  175. package/src/core/renderers/webgl/WebGlRenderer.ts +15 -22
  176. package/src/core/renderers/webgl/WebGlShaderNode.ts +5 -5
  177. package/src/core/renderers/webgl/WebGlShaderProgram.ts +2 -6
  178. package/src/core/renderers/webgl/internal/RendererUtils.ts +4 -8
  179. package/src/core/renderers/webgl/internal/ShaderUtils.ts +7 -5
  180. package/src/core/shaders/webgl/Border.ts +6 -4
  181. package/src/core/shaders/webgl/RoundedWithBorder.ts +16 -17
  182. package/src/core/shaders/webgl/RoundedWithBorderAndShadow.ts +19 -21
  183. package/src/core/text-rendering/SdfFontHandler.ts +10 -17
  184. package/src/core/text-rendering/SdfTextRenderer.ts +11 -16
  185. package/src/core/textures/ImageTexture.ts +42 -161
  186. package/src/core/textures/SubTexture.ts +3 -3
  187. package/src/core/textures/Texture.ts +2 -2
  188. package/src/main-api/Renderer.ts +24 -22
  189. package/src/utils.ts +0 -47
  190. package/src/core/lib/validateImageBitmap.ts +0 -87
@@ -0,0 +1,31 @@
1
+ /*
2
+ * If not stated otherwise in this file or this component's LICENSE file the
3
+ * following copyright and licenses apply:
4
+ *
5
+ * Copyright 2026 Comcast Cable Communications Management, LLC.
6
+ *
7
+ * Licensed under the Apache License, Version 2.0 (the License);
8
+ * you may not use this file except in compliance with the License.
9
+ * You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
18
+ */
19
+
20
+ export {
21
+ Platform,
22
+ type PlatformSettings,
23
+ } from '../src/core/platforms/Platform.js';
24
+ export { WebPlatform } from '../src/core/platforms/web/WebPlatform.js';
25
+ export { WebPlatformNext } from '../src/core/platforms/web/WebPlatformNext.js';
26
+ export { WebPlatformChrome50 } from '../src/core/platforms/web/WebPlatformChrome50.js';
27
+ export { WebPlatformLegacy } from '../src/core/platforms/web/WebPlatformLegacy.js';
28
+
29
+ // GL Context Wrappers
30
+ export { GlContextWrapper } from '../src/core/platforms/GlContextWrapper.js';
31
+ export { WebGlContextWrapper } from '../src/core/platforms/web/WebGlContextWrapper.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightningjs/renderer",
3
- "version": "3.0.0-beta22",
3
+ "version": "3.0.0-beta24",
4
4
  "description": "Lightning 3 Renderer",
5
5
  "type": "module",
6
6
  "main": "./dist/exports/index.js",
@@ -11,7 +11,8 @@
11
11
  "./canvas/shaders": "./dist/exports/canvas-shaders.js",
12
12
  "./webgl": "./dist/exports/webgl.js",
13
13
  "./webgl/shaders": "./dist/exports/webgl-shaders.js",
14
- "./inspector": "./dist/exports/inspector.js"
14
+ "./inspector": "./dist/exports/inspector.js",
15
+ "./platforms": "./dist/exports/platform.js"
15
16
  },
16
17
  "repository": {
17
18
  "type": "git",
@@ -61,11 +61,7 @@ import { CoreAnimation } from './animations/CoreAnimation.js';
61
61
  import { CoreAnimationController } from './animations/CoreAnimationController.js';
62
62
  import type { CoreShaderNode } from './renderers/CoreShaderNode.js';
63
63
  import { AutosizeMode, Autosizer } from './Autosizer.js';
64
- import {
65
- bucketSortByZIndex,
66
- incrementalRepositionByZIndex,
67
- removeChild,
68
- } from './lib/collectionUtils.js';
64
+ import { bucketSortByZIndex, removeChild } from './lib/collectionUtils.js';
69
65
 
70
66
  export enum CoreNodeRenderState {
71
67
  Init = 0,
@@ -755,7 +751,6 @@ export class CoreNode extends EventEmitter {
755
751
  private zIndexMax = 0;
756
752
 
757
753
  public previousZIndex = -1;
758
- public zIndexSortList: CoreNode[] = [];
759
754
 
760
755
  public updateType = UpdateType.All;
761
756
  public childUpdateType = UpdateType.None;
@@ -900,7 +895,7 @@ export class CoreNode extends EventEmitter {
900
895
 
901
896
  // if the default texture isn't loaded yet, wait for it to load
902
897
  // this only happens when the node is created before the stage is ready
903
- const dt = this.stage.defaultTexture;
898
+ const dt = stage.defaultTexture;
904
899
  if (dt !== null && dt.state !== 'loaded') {
905
900
  dt.once('loaded', () => this.setUpdateType(UpdateType.IsRenderable));
906
901
  }
@@ -940,16 +935,6 @@ export class CoreNode extends EventEmitter {
940
935
  texture.on('failed', this.onTextureFailed);
941
936
  texture.on('freed', this.onTextureFreed);
942
937
 
943
- // If the parent is a render texture, the initial texture status
944
- // will be set to freed until the texture is processed by the
945
- // Render RTT nodes. So we only need to listen fo changes and
946
- // no need to check the texture.state until we restructure how
947
- // textures are being processed.
948
- if (this.parentHasRenderTexture) {
949
- this.notifyParentRTTOfUpdate();
950
- return;
951
- }
952
-
953
938
  if (texture.state === 'loaded') {
954
939
  this.onTextureLoaded(texture, texture.dimensions!);
955
940
  } else if (texture.state === 'failed') {
@@ -1844,22 +1829,32 @@ export class CoreNode extends EventEmitter {
1844
1829
  }
1845
1830
 
1846
1831
  sortChildren() {
1847
- const changedCount = this.zIndexSortList.length;
1848
- if (changedCount === 0) {
1832
+ const children = this.children;
1833
+ const n = children.length;
1834
+
1835
+ if (n === 0) {
1836
+ this.zIndexMin = 0;
1837
+ this.zIndexMax = 0;
1849
1838
  return;
1850
1839
  }
1851
- const children = this.children;
1852
- let min = Infinity;
1853
- let max = -Infinity;
1854
- // find min and max zIndex
1855
- for (let i = 0; i < children.length; i++) {
1840
+
1841
+ let firstZIndex = children[0]!.props.zIndex;
1842
+ let min = firstZIndex;
1843
+ let max = firstZIndex;
1844
+ let prevZIndex = firstZIndex;
1845
+ let isSorted = true;
1846
+
1847
+ for (let i = 1; i < n; i++) {
1856
1848
  const zIndex = children[i]!.props.zIndex;
1857
1849
  if (zIndex < min) {
1858
1850
  min = zIndex;
1859
- }
1860
- if (zIndex > max) {
1851
+ } else if (zIndex > max) {
1861
1852
  max = zIndex;
1862
1853
  }
1854
+ if (prevZIndex > zIndex) {
1855
+ isSorted = false;
1856
+ }
1857
+ prevZIndex = zIndex;
1863
1858
  }
1864
1859
 
1865
1860
  // update min and max zIndex
@@ -1867,23 +1862,10 @@ export class CoreNode extends EventEmitter {
1867
1862
  this.zIndexMax = max;
1868
1863
 
1869
1864
  // if min and max are the same, no need to sort
1870
- if (min === max) {
1865
+ if (min === max || isSorted === true) {
1871
1866
  return;
1872
1867
  }
1873
-
1874
- const n = children.length;
1875
- // decide whether to use incremental sort or bucket sort
1876
- const useIncremental = changedCount <= 2 || changedCount < n * 0.05;
1877
-
1878
- // when changed count is less than 2 or 5% of total children, use incremental sort
1879
- if (useIncremental === true) {
1880
- incrementalRepositionByZIndex(this.zIndexSortList, children);
1881
- } else {
1882
- bucketSortByZIndex(children, min);
1883
- }
1884
-
1885
- this.zIndexSortList.length = 0;
1886
- this.zIndexSortList = [];
1868
+ bucketSortByZIndex(children, min);
1887
1869
  }
1888
1870
 
1889
1871
  removeChild(node: CoreNode, targetParent: CoreNode | null = null) {
@@ -1896,15 +1878,25 @@ export class CoreNode extends EventEmitter {
1896
1878
  autosizeTarget.detach(node);
1897
1879
  }
1898
1880
  }
1899
- removeChild(node, this.children);
1881
+ const children = this.children;
1882
+ removeChild(node, children);
1883
+
1884
+ if (children.length === 0) {
1885
+ this.zIndexMin = 0;
1886
+ this.zIndexMax = 0;
1887
+ return;
1888
+ }
1889
+
1890
+ const removedZIndex = node.zIndex;
1891
+ if (removedZIndex === this.zIndexMin || removedZIndex === this.zIndexMax) {
1892
+ this.setUpdateType(UpdateType.SortZIndexChildren);
1893
+ }
1900
1894
  }
1901
1895
 
1902
1896
  addChild(node: CoreNode, previousParent: CoreNode | null = null) {
1903
1897
  const inRttCluster =
1904
1898
  this.props.rtt === true || this.parentHasRenderTexture === true;
1905
1899
  const children = this.children;
1906
- const min = this.zIndexMin;
1907
- const max = this.zIndexMax;
1908
1900
  const zIndex = node.zIndex;
1909
1901
  const autosizeTarget = this.autosizer || this.parentAutosizer;
1910
1902
  let attachToAutosizer = autosizeTarget !== null;
@@ -1942,8 +1934,19 @@ export class CoreNode extends EventEmitter {
1942
1934
 
1943
1935
  children.push(node);
1944
1936
 
1945
- if (min !== max || (zIndex !== min && zIndex !== max)) {
1946
- this.zIndexSortList.push(node);
1937
+ if (children.length === 1) {
1938
+ this.zIndexMin = zIndex;
1939
+ this.zIndexMax = zIndex;
1940
+ } else {
1941
+ if (zIndex < this.zIndexMin) {
1942
+ this.zIndexMin = zIndex;
1943
+ }
1944
+ if (zIndex > this.zIndexMax) {
1945
+ this.zIndexMax = zIndex;
1946
+ }
1947
+ }
1948
+
1949
+ if (this.zIndexMax !== this.zIndexMin) {
1947
1950
  this.setUpdateType(UpdateType.SortZIndexChildren);
1948
1951
  }
1949
1952
  this.setUpdateType(UpdateType.Children);
@@ -2402,7 +2405,6 @@ export class CoreNode extends EventEmitter {
2402
2405
  const min = parent.zIndexMin;
2403
2406
  const max = parent.zIndexMax;
2404
2407
  if (min !== max || sanitizedValue < min || sanitizedValue > max) {
2405
- parent.zIndexSortList.push(this);
2406
2408
  parent.setUpdateType(UpdateType.SortZIndexChildren);
2407
2409
  }
2408
2410
  }
@@ -2737,7 +2739,8 @@ export class CoreNode extends EventEmitter {
2737
2739
  }
2738
2740
 
2739
2741
  draw(renderer: WebGlRenderer) {
2740
- const { glw, options, stage } = renderer;
2742
+ const { glw, stage } = renderer;
2743
+ const canvas = stage.platform!.canvas!;
2741
2744
  const shader = this.props.shader as any;
2742
2745
 
2743
2746
  stage.shManager.useShader(shader.program);
@@ -2751,7 +2754,7 @@ export class CoreNode extends EventEmitter {
2751
2754
  const clipWidth = Math.round(this.clippingRect.w * pixelRatio);
2752
2755
  const clipHeight = Math.round(this.clippingRect.h * pixelRatio);
2753
2756
  let clipY = Math.round(
2754
- options.canvas.height - clipHeight - this.clippingRect.y * pixelRatio,
2757
+ canvas.height - clipHeight - this.clippingRect.y * pixelRatio,
2755
2758
  );
2756
2759
  // if parent has render texture, we need to adjust the scissor rect
2757
2760
  // to be relative to the parent's framebuffer
@@ -17,7 +17,6 @@
17
17
  * limitations under the License.
18
18
  */
19
19
 
20
- import { ImageWorkerManager } from './lib/ImageWorker.js';
21
20
  import type { CoreRenderer } from './renderers/CoreRenderer.js';
22
21
  import { ColorTexture } from './textures/ColorTexture.js';
23
22
  import { ImageTexture } from './textures/ImageTexture.js';
@@ -27,10 +26,6 @@ import { RenderTexture } from './textures/RenderTexture.js';
27
26
  import { Texture, TextureType } from './textures/Texture.js';
28
27
  import { EventEmitter } from '../common/EventEmitter.js';
29
28
  import type { Stage } from './Stage.js';
30
- import {
31
- validateCreateImageBitmap,
32
- type CreateImageBitmapSupport,
33
- } from './lib/validateImageBitmap.js';
34
29
  import type { Platform } from './platforms/Platform.js';
35
30
  import { TextureError, TextureErrorCode } from './TextureError.js';
36
31
 
@@ -195,23 +190,11 @@ export class CoreTextureManager extends EventEmitter {
195
190
  txConstructors: Partial<TextureMap> = {};
196
191
 
197
192
  public maxRetryCount: number;
198
- private priorityQueue: Array<Texture> = [];
199
193
  private uploadTextureQueue: Array<Texture> = [];
200
- private initialized = false;
201
194
  private stage: Stage;
202
- private numImageWorkers: number;
203
195
 
204
196
  public platform: Platform;
205
197
 
206
- imageWorkerManager: ImageWorkerManager | null = null;
207
- hasCreateImageBitmap = false;
208
- imageBitmapSupported = {
209
- basic: false,
210
- options: false,
211
- full: false,
212
- };
213
-
214
- hasWorker = !!self.Worker;
215
198
  /**
216
199
  * Renderer that this texture manager is associated with
217
200
  *
@@ -235,35 +218,9 @@ export class CoreTextureManager extends EventEmitter {
235
218
  constructor(stage: Stage, settings: TextureManagerSettings) {
236
219
  super();
237
220
 
238
- const { numImageWorkers, createImageBitmapSupport, maxRetryCount } =
239
- settings;
240
-
241
221
  this.stage = stage;
242
222
  this.platform = stage.platform;
243
- this.numImageWorkers = numImageWorkers;
244
- this.maxRetryCount = maxRetryCount;
245
-
246
- if (createImageBitmapSupport === 'auto') {
247
- validateCreateImageBitmap(this.platform)
248
- .then((result) => {
249
- this.initialize(result);
250
- })
251
- .catch(() => {
252
- console.warn(
253
- '[Lightning] createImageBitmap is not supported on this browser. ImageTexture will be slower.',
254
- );
255
-
256
- // initialized without image worker manager and createImageBitmap
257
- this.initialized = true;
258
- this.emit('initialized');
259
- });
260
- } else {
261
- this.initialize({
262
- basic: createImageBitmapSupport === 'basic',
263
- options: createImageBitmapSupport === 'options',
264
- full: createImageBitmapSupport === 'full',
265
- });
266
- }
223
+ this.maxRetryCount = settings.maxRetryCount;
267
224
 
268
225
  this.registerTextureType('ImageTexture', ImageTexture);
269
226
  this.registerTextureType('ColorTexture', ColorTexture);
@@ -279,36 +236,6 @@ export class CoreTextureManager extends EventEmitter {
279
236
  this.txConstructors[textureType] = textureClass;
280
237
  }
281
238
 
282
- private initialize(support: CreateImageBitmapSupport) {
283
- this.hasCreateImageBitmap =
284
- support.basic || support.options || support.full;
285
- this.imageBitmapSupported = support;
286
-
287
- if (this.hasCreateImageBitmap === false) {
288
- console.warn(
289
- '[Lightning] createImageBitmap is not supported on this browser. ImageTexture will be slower.',
290
- );
291
- }
292
-
293
- if (
294
- this.hasCreateImageBitmap === true &&
295
- this.hasWorker === true &&
296
- this.numImageWorkers > 0
297
- ) {
298
- this.imageWorkerManager = new ImageWorkerManager(
299
- this.numImageWorkers,
300
- support,
301
- );
302
- } else {
303
- console.warn(
304
- '[Lightning] Imageworker is 0 or not supported on this browser. Image loading will be slower.',
305
- );
306
- }
307
-
308
- this.initialized = true;
309
- this.emit('initialized');
310
- }
311
-
312
239
  /**
313
240
  * Enqueue a texture for uploading to the GPU.
314
241
  *
@@ -333,7 +260,10 @@ export class CoreTextureManager extends EventEmitter {
333
260
  let texture: Texture | undefined;
334
261
  const TextureClass = this.txConstructors[textureType];
335
262
  if (!TextureClass) {
336
- throw new Error(`Texture type "${textureType}" is not registered`);
263
+ throw new TextureError(
264
+ TextureErrorCode.TEXTURE_TYPE_NOT_REGISTERED,
265
+ `Texture type "${textureType}" is not registered`,
266
+ );
337
267
  }
338
268
  const resolvedProps = TextureClass.resolveDefaults(props as any);
339
269
  const cacheKey = TextureClass.makeCacheKey(resolvedProps as any);
@@ -371,12 +301,6 @@ export class CoreTextureManager extends EventEmitter {
371
301
  return;
372
302
  }
373
303
 
374
- // if we're not initialized, just queue the texture into the priority queue
375
- if (this.initialized === false) {
376
- this.priorityQueue.push(texture);
377
- return;
378
- }
379
-
380
304
  texture.setState('loading');
381
305
 
382
306
  // Get texture data - early return on failure
@@ -418,7 +342,10 @@ export class CoreTextureManager extends EventEmitter {
418
342
  this.stage.txMemManager.criticalCleanupRequested === true
419
343
  ) {
420
344
  // we're at a critical memory threshold, don't upload textures
421
- texture.setState('failed');
345
+ texture.setState(
346
+ 'failed',
347
+ new TextureError(TextureErrorCode.MEMORY_THRESHOLD_EXCEEDED),
348
+ );
422
349
  return;
423
350
  }
424
351
 
@@ -465,29 +392,9 @@ export class CoreTextureManager extends EventEmitter {
465
392
  * @param maxProcessingTime - The maximum processing time in milliseconds
466
393
  */
467
394
  async processSome(maxProcessingTime: number): Promise<void> {
468
- if (this.initialized === false) {
469
- return;
470
- }
471
-
472
395
  const platform = this.platform;
473
396
  const startTime = platform.getTimeStamp();
474
397
 
475
- // Process priority queue
476
- while (
477
- this.priorityQueue.length > 0 &&
478
- platform.getTimeStamp() - startTime < maxProcessingTime
479
- ) {
480
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
481
- const texture = this.priorityQueue.pop()!;
482
- try {
483
- await texture.getTextureData();
484
- await this.uploadTexture(texture);
485
- } catch (error) {
486
- console.error('Failed to process priority texture:', error);
487
- // Continue with next texture instead of stopping entire queue
488
- }
489
- }
490
-
491
398
  // Process uploads - await each upload to prevent GPU overload
492
399
  while (
493
400
  this.uploadTextureQueue.length > 0 &&
@@ -505,7 +412,7 @@ export class CoreTextureManager extends EventEmitter {
505
412
  }
506
413
 
507
414
  public hasUpdates(): boolean {
508
- return this.uploadTextureQueue.length > 0 || this.priorityQueue.length > 0;
415
+ return this.uploadTextureQueue.length > 0;
509
416
  }
510
417
 
511
418
  /**
package/src/core/Stage.ts CHANGED
@@ -159,13 +159,11 @@ export class Stage {
159
159
  */
160
160
  constructor(public options: StageOptions) {
161
161
  const {
162
- canvas,
163
162
  clearColor,
164
163
  appWidth,
165
164
  appHeight,
166
165
  boundsMargin,
167
166
  enableContextSpy,
168
- forceWebGL2,
169
167
  numImageWorkers,
170
168
  textureMemory,
171
169
  renderEngine,
@@ -195,12 +193,6 @@ export class Stage {
195
193
  maxRetryCount,
196
194
  });
197
195
 
198
- // Wait for the Texture Manager to initialize
199
- // once it does, request a render
200
- this.txManager.on('initialized', () => {
201
- this.requestRender();
202
- });
203
-
204
196
  this.txMemManager = new TextureMemoryManager(this, textureMemory);
205
197
 
206
198
  this.animationManager = new AnimationManager();
@@ -223,12 +215,7 @@ export class Stage {
223
215
  this.pixelRatio =
224
216
  options.devicePhysicalPixelRatio * options.deviceLogicalPixelRatio;
225
217
 
226
- this.renderer = new renderEngine({
227
- stage: this,
228
- canvas,
229
- contextSpy: this.contextSpy,
230
- forceWebGL2,
231
- });
218
+ this.renderer = new renderEngine(this);
232
219
 
233
220
  this.shManager = new CoreShaderManager(this);
234
221
 
@@ -63,14 +63,17 @@ export class CoreAnimationController
63
63
  return this;
64
64
  }
65
65
 
66
- stop(): IAnimationController {
66
+ stop(reset = true): IAnimationController {
67
67
  this.unregisterAnimation();
68
68
  if (this.stoppedResolve !== null) {
69
69
  this.stoppedResolve();
70
70
  this.stoppedResolve = null;
71
71
  this.emit('stopped', this);
72
72
  }
73
- this.animation.reset();
73
+ if (reset === true) {
74
+ this.animation.reset();
75
+ }
76
+
74
77
  this.state = 'stopped';
75
78
  return this;
76
79
  }
@@ -60,41 +60,6 @@ export const bucketSortByZIndex = (nodes: CoreNode[], min: number): void => {
60
60
  bucketIndices.length = 0;
61
61
  };
62
62
 
63
- export const incrementalRepositionByZIndex = (
64
- changedNodes: CoreNode[],
65
- nodes: CoreNode[],
66
- ): void => {
67
- for (let i = 0; i < changedNodes.length; i++) {
68
- const node = changedNodes[i]!;
69
- const currentIndex = findChildIndexById(node, nodes);
70
- if (currentIndex === -1) continue;
71
-
72
- const targetZIndex = node.props.zIndex;
73
-
74
- //binary search for correct insertion position
75
- let left = 0;
76
- let right = nodes.length;
77
-
78
- while (left < right) {
79
- const mid = (left + right) >>> 1;
80
- if (nodes[mid]!.props.zIndex <= targetZIndex) {
81
- left = mid + 1;
82
- } else {
83
- right = mid;
84
- }
85
- }
86
-
87
- //adjust target position if it's after the current position
88
- const targetIndex = left > currentIndex ? left - 1 : left;
89
-
90
- //only reposition if target is different from current
91
- if (targetIndex !== currentIndex) {
92
- nodes.splice(currentIndex, 1);
93
- nodes.splice(targetIndex, 0, node);
94
- }
95
- }
96
- };
97
-
98
63
  export const findChildIndexById = (
99
64
  node: CoreNode,
100
65
  children: CoreNode[],
@@ -19,8 +19,6 @@
19
19
 
20
20
  import type { Vec4 } from '../renderers/webgl/internal/ShaderUtils.js';
21
21
 
22
- export const PROTOCOL_REGEX = /^(data|ftps?|https?):/;
23
-
24
22
  export type RGBA = [r: number, g: number, b: number, a: number];
25
23
 
26
24
  export const getNormalizedRgbaComponents = (rgba: number): RGBA => {
@@ -289,35 +287,6 @@ export function createPreloadBounds(
289
287
  );
290
288
  }
291
289
 
292
- export function convertUrlToAbsolute(url: string): string {
293
- // handle local file imports if the url isn't remote resource or data blob
294
- if (self.location.protocol === 'file:' && !PROTOCOL_REGEX.test(url)) {
295
- const path = self.location.pathname.split('/');
296
- path.pop();
297
- const basePath = path.join('/');
298
- const baseUrl = self.location.protocol + '//' + basePath;
299
-
300
- // check if url has a leading dot
301
- if (url.charAt(0) === '.') {
302
- url = url.slice(1);
303
- }
304
-
305
- // check if url has a leading slash
306
- if (url.charAt(0) === '/') {
307
- url = url.slice(1);
308
- }
309
-
310
- return baseUrl + '/' + url;
311
- }
312
-
313
- const absoluteUrl = new URL(url, self.location.href);
314
- return absoluteUrl.href;
315
- }
316
-
317
- export function isBase64Image(src: string) {
318
- return src.startsWith('data:') === true;
319
- }
320
-
321
290
  export function calcFactoredRadius(
322
291
  radius: number,
323
292
  width: number,
@@ -366,50 +335,3 @@ export function calcFactoredRadiusArray(
366
335
  result[3] *= factor;
367
336
  return result;
368
337
  }
369
-
370
- export function dataURIToBlob(dataURI: string): Blob {
371
- dataURI = dataURI.replace(/^data:/, '');
372
-
373
- const type = dataURI.match(/image\/[^;]+/)?.[0] || '';
374
- const base64 = dataURI.replace(/^[^,]+,/, '');
375
-
376
- const sliceSize = 1024;
377
- const byteCharacters = atob(base64);
378
- const bytesLength = byteCharacters.length;
379
- const slicesCount = Math.ceil(bytesLength / sliceSize);
380
- const byteArrays = new Array(slicesCount);
381
-
382
- for (let sliceIndex = 0; sliceIndex < slicesCount; ++sliceIndex) {
383
- const begin = sliceIndex * sliceSize;
384
- const end = Math.min(begin + sliceSize, bytesLength);
385
-
386
- const bytes = new Array(end - begin);
387
- for (let offset = begin, i = 0; offset < end; ++i, ++offset) {
388
- bytes[i] = byteCharacters[offset]?.charCodeAt(0);
389
- }
390
- byteArrays[sliceIndex] = new Uint8Array(bytes);
391
- }
392
- return new Blob(byteArrays, { type });
393
- }
394
-
395
- export function fetchJson(
396
- url: string,
397
- responseType: XMLHttpRequestResponseType = '',
398
- ): Promise<unknown> {
399
- return new Promise((resolve, reject) => {
400
- const xhr = new XMLHttpRequest();
401
- xhr.responseType = responseType;
402
- xhr.onreadystatechange = function () {
403
- if (xhr.readyState == XMLHttpRequest.DONE) {
404
- // On most devices like WebOS and Tizen, the file protocol returns 0 while http(s) protocol returns 200
405
- if (xhr.status === 0 || xhr.status === 200) {
406
- resolve(xhr.response);
407
- } else {
408
- reject(xhr.statusText);
409
- }
410
- }
411
- };
412
- xhr.open('GET', url, true);
413
- xhr.send(null);
414
- });
415
- }