@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,189 @@
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 2023 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
+ * Note that, within the createImageWorker function, we must only use ES5 code to keep it ES5-valid after babelifying, as
21
+ * the converted code of this section is converted to a blob and used as the js of the web worker thread.
22
+ *
23
+ * The createImageWorker function is a web worker that fetches an image from a URL and returns an ImageBitmap object.
24
+ * The eslint @typescript rule is disabled for the entire function because the function is converted to a blob and used as the
25
+ * js of the web worker thread, so the typescript syntax is not valid in this context.
26
+ */
27
+ /* eslint-disable */
28
+ function createImageWorker() {
29
+ function hasAlphaChannel(mimeType) {
30
+ return mimeType.indexOf('image/png') !== -1;
31
+ }
32
+ function getImage(src, premultiplyAlpha, x, y, width, height) {
33
+ return new Promise(function (resolve, reject) {
34
+ var xhr = new XMLHttpRequest();
35
+ xhr.open('GET', src, true);
36
+ xhr.responseType = 'blob';
37
+ xhr.onload = function () {
38
+ // On most devices like WebOS and Tizen, the file protocol returns 0 while http(s) protocol returns 200
39
+ if (xhr.status !== 200 && xhr.status !== 0) {
40
+ return reject(new Error(`Image loading failed. HTTP status code: ${xhr.status || 'N/A'}. URL: ${src}`));
41
+ }
42
+ var blob = xhr.response;
43
+ var withAlphaChannel = premultiplyAlpha !== undefined
44
+ ? premultiplyAlpha
45
+ : hasAlphaChannel(blob.type);
46
+ // createImageBitmap with crop and options
47
+ if (width !== null && height !== null) {
48
+ createImageBitmap(blob, x || 0, y || 0, width, height, {
49
+ premultiplyAlpha: withAlphaChannel ? 'premultiply' : 'none',
50
+ colorSpaceConversion: 'none',
51
+ imageOrientation: 'none',
52
+ })
53
+ .then(function (data) {
54
+ resolve({ data, premultiplyAlpha: premultiplyAlpha });
55
+ })
56
+ .catch(function (error) {
57
+ reject(error);
58
+ });
59
+ return;
60
+ }
61
+ else {
62
+ createImageBitmap(blob, {
63
+ premultiplyAlpha: withAlphaChannel ? 'premultiply' : 'none',
64
+ colorSpaceConversion: 'none',
65
+ imageOrientation: 'none',
66
+ })
67
+ .then(function (data) {
68
+ resolve({ data, premultiplyAlpha: premultiplyAlpha });
69
+ })
70
+ .catch(function (error) {
71
+ reject(error);
72
+ });
73
+ }
74
+ };
75
+ xhr.onerror = function () {
76
+ reject(new Error('Network error occurred while trying to fetch the image.'));
77
+ };
78
+ xhr.send();
79
+ });
80
+ }
81
+ self.onmessage = (event) => {
82
+ var src = event.data.src;
83
+ var id = event.data.id;
84
+ var premultiplyAlpha = event.data.premultiplyAlpha;
85
+ var x = event.data.sx;
86
+ var y = event.data.sy;
87
+ var width = event.data.sw;
88
+ var height = event.data.sh;
89
+ getImage(src, premultiplyAlpha, x, y, width, height)
90
+ .then(function (data) {
91
+ // @ts-ignore ts has wrong postMessage signature
92
+ self.postMessage({ id: id, src: src, data: data }, [data.data]);
93
+ })
94
+ .catch(function (error) {
95
+ self.postMessage({ id: id, src: src, error: error.message });
96
+ });
97
+ };
98
+ }
99
+ /* eslint-enable */
100
+ export class ImageWorkerManager {
101
+ imageWorkersEnabled = true;
102
+ messageManager = {};
103
+ workers = [];
104
+ workerLoad = [];
105
+ nextId = 0;
106
+ constructor(numImageWorkers) {
107
+ this.workers = this.createWorkers(numImageWorkers);
108
+ this.workers.forEach((worker, index) => {
109
+ worker.onmessage = (event) => this.handleMessage(event, index);
110
+ });
111
+ }
112
+ handleMessage(event, workerIndex) {
113
+ const { id, data, error } = event.data;
114
+ const msg = this.messageManager[id];
115
+ if (this.workerLoad[workerIndex]) {
116
+ this.workerLoad[workerIndex]--;
117
+ }
118
+ if (msg) {
119
+ const [resolve, reject] = msg;
120
+ delete this.messageManager[id];
121
+ if (error) {
122
+ reject(new Error(error));
123
+ }
124
+ else {
125
+ resolve(data);
126
+ }
127
+ }
128
+ }
129
+ createWorkers(numWorkers = 1) {
130
+ let workerCode = `(${createImageWorker.toString()})()`;
131
+ workerCode = workerCode.replace('"use strict";', '');
132
+ const blob = new Blob([workerCode], {
133
+ type: 'application/javascript',
134
+ });
135
+ const blobURL = (self.URL ? URL : webkitURL).createObjectURL(blob);
136
+ const workers = [];
137
+ for (let i = 0; i < numWorkers; i++) {
138
+ workers.push(new Worker(blobURL));
139
+ this.workerLoad.push(0);
140
+ }
141
+ return workers;
142
+ }
143
+ getNextWorkerIndex() {
144
+ if (this.workers.length === 0)
145
+ return -1;
146
+ let minLoad = 99;
147
+ let workerIndex = 0;
148
+ for (let i = 0; i < this.workers.length; i++) {
149
+ const load = this.workerLoad[i] || 0;
150
+ if (load === 0) {
151
+ return i;
152
+ }
153
+ if (load < minLoad) {
154
+ minLoad = load;
155
+ workerIndex = i;
156
+ }
157
+ }
158
+ return workerIndex;
159
+ }
160
+ getImage(src, premultiplyAlpha, sx, sy, sw, sh) {
161
+ return new Promise((resolve, reject) => {
162
+ try {
163
+ if (this.workers) {
164
+ const id = this.nextId++;
165
+ this.messageManager[id] = [resolve, reject];
166
+ const nextWorkerIndex = this.getNextWorkerIndex();
167
+ if (nextWorkerIndex !== -1) {
168
+ const worker = this.workers[nextWorkerIndex];
169
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
170
+ this.workerLoad[nextWorkerIndex]++;
171
+ worker.postMessage({
172
+ id,
173
+ src: src,
174
+ premultiplyAlpha,
175
+ sx,
176
+ sy,
177
+ sw,
178
+ sh,
179
+ });
180
+ }
181
+ }
182
+ }
183
+ catch (error) {
184
+ reject(error);
185
+ }
186
+ });
187
+ }
188
+ }
189
+ //# sourceMappingURL=ImageWorker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ImageWorker.js","sourceRoot":"","sources":["../../../../../../src/core/platforms/web/lib/ImageWorker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAiBH;;;;;;;GAOG;AAEH,oBAAoB;AACpB,SAAS,iBAAiB;IACxB,SAAS,eAAe,CAAC,QAAgB;QACvC,OAAO,QAAQ,CAAC,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC;IAC9C,CAAC;IAED,SAAS,QAAQ,CACf,GAAW,EACX,gBAAgC,EAChC,CAAgB,EAChB,CAAgB,EAChB,KAAoB,EACpB,MAAqB;QAErB,OAAO,IAAI,OAAO,CAAC,UAAU,OAAO,EAAE,MAAM;YAC1C,IAAI,GAAG,GAAG,IAAI,cAAc,EAAE,CAAC;YAC/B,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;YAC3B,GAAG,CAAC,YAAY,GAAG,MAAM,CAAC;YAE1B,GAAG,CAAC,MAAM,GAAG;gBACX,uGAAuG;gBACvG,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;oBAC3C,OAAO,MAAM,CACX,IAAI,KAAK,CACP,2CACE,GAAG,CAAC,MAAM,IAAI,KAChB,UAAU,GAAG,EAAE,CAChB,CACF,CAAC;gBACJ,CAAC;gBAED,IAAI,IAAI,GAAG,GAAG,CAAC,QAAQ,CAAC;gBACxB,IAAI,gBAAgB,GAClB,gBAAgB,KAAK,SAAS;oBAC5B,CAAC,CAAC,gBAAgB;oBAClB,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,EAAE,EAAE;YACrC,IAAI,CAAC;gBACH,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;oBACjB,MAAM,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;oBACzB,IAAI,CAAC,cAAc,CAAC,EAAE,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;oBAC5C,MAAM,eAAe,GAAG,IAAI,CAAC,kBAAkB,EAAE,CAAC;oBAElD,IAAI,eAAe,KAAK,CAAC,CAAC,EAAE,CAAC;wBAC3B,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;wBAC7C,oEAAoE;wBACpE,IAAI,CAAC,UAAU,CAAC,eAAe,CAAE,EAAE,CAAC;wBACpC,MAAO,CAAC,WAAW,CAAC;4BAClB,EAAE;4BACF,GAAG,EAAE,GAAG;4BACR,gBAAgB;4BAChB,EAAE;4BACF,EAAE;4BACF,EAAE;4BACF,EAAE;yBACH,CAAC,CAAC;oBACL,CAAC;gBACH,CAAC;YACH,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,MAAM,CAAC,KAAK,CAAC,CAAC;YAChB,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -0,0 +1 @@
1
+ export declare const createImageBitmap: (blob: ImageBitmapSource, sxOrOptions?: number | ImageBitmapOptions, sy?: number, sw?: number, sh?: number, options?: ImageBitmapOptions) => Promise<ImageBitmap>;
@@ -0,0 +1,27 @@
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
+ export const createImageBitmap = (blob, sxOrOptions, sy, sw, sh, options) => {
20
+ if (typeof sxOrOptions === 'number') {
21
+ return createImageBitmap(blob, sxOrOptions, sy ?? 0, sw ?? 0, sh ?? 0, options);
22
+ }
23
+ else {
24
+ return createImageBitmap(blob, sxOrOptions);
25
+ }
26
+ };
27
+ //# sourceMappingURL=createImageBitmap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createImageBitmap.js","sourceRoot":"","sources":["../../../../../../src/core/platforms/web/lib/createImageBitmap.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,IAAuB,EACvB,WAAyC,EACzC,EAAW,EACX,EAAW,EACX,EAAW,EACX,OAA4B,EACN,EAAE;IACxB,IAAI,OAAO,WAAW,KAAK,QAAQ,EAAE,CAAC;QACpC,OAAO,iBAAiB,CACtB,IAAI,EACJ,WAAW,EACX,EAAE,IAAI,CAAC,EACP,EAAE,IAAI,CAAC,EACP,EAAE,IAAI,CAAC,EACP,OAAO,CACR,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,OAAO,iBAAiB,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;IAC9C,CAAC;AACH,CAAC,CAAC"}
@@ -0,0 +1,26 @@
1
+ import { type CompressedData } from '../../../textures/Texture.js';
2
+ import type { ImageResponse } from '../../../textures/ImageTexture.js';
3
+ import type { WebGlContextWrapper } from '../WebGlContextWrapper.js';
4
+ export type UploadCompressedTextureFunction = (glw: WebGlContextWrapper, texture: WebGLTexture, data: CompressedData) => void;
5
+ /**
6
+ * Loads a compressed texture container
7
+ * @param url
8
+ * @returns
9
+ */
10
+ export declare const loadCompressedTexture: (url: string) => Promise<ImageResponse>;
11
+ export interface CompressedImageData {
12
+ blockInfo: BlockInfo;
13
+ glInternalFormat: number;
14
+ mipmaps: ArrayBuffer[];
15
+ w: number;
16
+ h: number;
17
+ type: 'PVR' | 'KTX' | 'ASTC';
18
+ }
19
+ export type BlockInfo = {
20
+ width: number;
21
+ height: number;
22
+ bytes: number;
23
+ };
24
+ export declare const blockInfoMap: {
25
+ [key: number]: BlockInfo;
26
+ };
@@ -0,0 +1,301 @@
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 2023 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
+ import {} from '../../../textures/Texture.js';
20
+ const PVR_MAGIC = 0x03525650; // 'PVR3' in little-endian
21
+ const PVR_TO_GL_INTERNAL_FORMAT = {
22
+ 0: 0x8c01,
23
+ 1: 0x8c03,
24
+ 2: 0x8c00,
25
+ 3: 0x8c02, // PVRTC1
26
+ 6: 0x8d64, // ETC1
27
+ 7: 0x83f0,
28
+ 8: 0x83f2,
29
+ 9: 0x83f2,
30
+ 10: 0x83f3,
31
+ 11: 0x83f3, // DXT variants
32
+ };
33
+ const ASTC_MAGIC = 0x5ca1ab13;
34
+ const ASTC_TO_GL_INTERNAL_FORMAT = {
35
+ '4x4': 0x93b0, // COMPRESSED_RGBA_ASTC_4x4_KHR
36
+ '5x5': 0x93b1, // COMPRESSED_RGBA_ASTC_5x5_KHR
37
+ '6x6': 0x93b2, // COMPRESSED_RGBA_ASTC_6x6_KHR
38
+ '8x8': 0x93b3, // COMPRESSED_RGBA_ASTC_8x8_KHR
39
+ '10x10': 0x93b4, // COMPRESSED_RGBA_ASTC_10x10_KHR
40
+ '12x12': 0x93b5, // COMPRESSED_RGBA_ASTC_12x12_KHR
41
+ };
42
+ // KTX file identifier
43
+ const KTX_IDENTIFIER = [
44
+ 0xab, 0x4b, 0x54, 0x58, 0x20, 0x31, 0x31, 0xbb, 0x0d, 0x0a, 0x1a, 0x0a,
45
+ ];
46
+ /**
47
+ * Loads a compressed texture container
48
+ * @param url
49
+ * @returns
50
+ */
51
+ export const loadCompressedTexture = async (url) => {
52
+ try {
53
+ const response = await fetch(url);
54
+ if (!response.ok) {
55
+ throw new Error(`Failed to fetch compressed texture: ${response.status} ${response.statusText}`);
56
+ }
57
+ const arrayBuffer = await response.arrayBuffer();
58
+ // Ensure we have enough data to check magic numbers
59
+ if (arrayBuffer.byteLength < 16) {
60
+ throw new Error(`File too small to be a valid compressed texture (${arrayBuffer.byteLength} bytes). Expected at least 16 bytes for header inspection.`);
61
+ }
62
+ const view = new DataView(arrayBuffer);
63
+ const magic = view.getUint32(0, true);
64
+ if (magic === PVR_MAGIC) {
65
+ return loadPVR(view);
66
+ }
67
+ if (magic === ASTC_MAGIC) {
68
+ return loadASTC(view);
69
+ }
70
+ let isKTX = true;
71
+ for (let i = 0; i < KTX_IDENTIFIER.length; i++) {
72
+ if (view.getUint8(i) !== KTX_IDENTIFIER[i]) {
73
+ isKTX = false;
74
+ break;
75
+ }
76
+ }
77
+ if (isKTX === true) {
78
+ return loadKTX(view);
79
+ }
80
+ else {
81
+ throw new Error('Unrecognized compressed texture format');
82
+ }
83
+ }
84
+ catch (error) {
85
+ throw new Error(`Failed to load compressed texture from ${url}: ${error}`);
86
+ }
87
+ };
88
+ function readUint24(view, offset) {
89
+ return (view.getUint8(offset) +
90
+ (view.getUint8(offset + 1) << 8) +
91
+ (view.getUint8(offset + 2) << 16));
92
+ }
93
+ /**
94
+ * Loads an ASTC texture container and returns the texture data
95
+ * @param view
96
+ * @returns
97
+ */
98
+ const loadASTC = async function (view) {
99
+ const blockX = view.getUint8(4);
100
+ const blockY = view.getUint8(5);
101
+ const sizeX = readUint24(view, 7);
102
+ const sizeY = readUint24(view, 10);
103
+ if (sizeX === 0 || sizeY === 0) {
104
+ throw new Error(`Invalid ASTC texture dimensions: ${sizeX}x${sizeY}`);
105
+ }
106
+ const expected = Math.ceil(sizeX / blockX) * Math.ceil(sizeY / blockY) * 16;
107
+ const dataSize = view.byteLength - 16;
108
+ if (expected !== dataSize) {
109
+ throw new Error(`Invalid ASTC texture data size: expected ${expected}, got ${dataSize}`);
110
+ }
111
+ const internalFormat = ASTC_TO_GL_INTERNAL_FORMAT[`${blockX}x${blockY}`];
112
+ if (internalFormat === undefined) {
113
+ throw new Error(`Unsupported ASTC block size: ${blockX}x${blockY}`);
114
+ }
115
+ const buffer = view.buffer;
116
+ const mipmaps = [];
117
+ mipmaps.push(buffer.slice(16));
118
+ return {
119
+ data: {
120
+ blockInfo: blockInfoMap[internalFormat],
121
+ glInternalFormat: internalFormat,
122
+ mipmaps,
123
+ w: sizeX,
124
+ h: sizeY,
125
+ type: 'ASTC',
126
+ },
127
+ premultiplyAlpha: false,
128
+ };
129
+ };
130
+ /**
131
+ * Loads a KTX texture container and returns the texture data
132
+ * @param view
133
+ * @returns
134
+ */
135
+ const loadKTX = async function (view) {
136
+ const endianness = view.getUint32(12, true);
137
+ const littleEndian = endianness === 0x04030201;
138
+ if (littleEndian === false && endianness !== 0x01020304) {
139
+ throw new Error('Invalid KTX endianness value');
140
+ }
141
+ const glType = view.getUint32(16, littleEndian);
142
+ const glFormat = view.getUint32(24, littleEndian);
143
+ if (glType !== 0 || glFormat !== 0) {
144
+ throw new Error(`KTX texture is not compressed (glType: ${glType}, glFormat: ${glFormat})`);
145
+ }
146
+ const glInternalFormat = view.getUint32(28, littleEndian);
147
+ if (blockInfoMap[glInternalFormat] === undefined) {
148
+ throw new Error(`Unsupported KTX compressed texture format: 0x${glInternalFormat.toString(16)}`);
149
+ }
150
+ const width = view.getUint32(36, littleEndian);
151
+ const height = view.getUint32(40, littleEndian);
152
+ if (width === 0 || height === 0) {
153
+ throw new Error(`Invalid KTX texture dimensions: ${width}x${height}`);
154
+ }
155
+ const mipmapLevels = view.getUint32(56, littleEndian);
156
+ if (mipmapLevels === 0) {
157
+ throw new Error('KTX texture has no mipmap levels');
158
+ }
159
+ const bytesOfKeyValueData = view.getUint32(60, littleEndian);
160
+ const mipmaps = [];
161
+ const buffer = view.buffer;
162
+ let offset = 64 + bytesOfKeyValueData;
163
+ if (offset > view.byteLength) {
164
+ throw new Error('Invalid KTX file: key/value data exceeds file size');
165
+ }
166
+ for (let i = 0; i < mipmapLevels; i++) {
167
+ const imageSize = view.getUint32(offset, littleEndian);
168
+ offset += 4;
169
+ const end = offset + imageSize;
170
+ mipmaps.push(buffer.slice(offset, end));
171
+ offset = end;
172
+ if (offset % 4 !== 0) {
173
+ offset += 4 - (offset % 4);
174
+ }
175
+ }
176
+ return {
177
+ data: {
178
+ blockInfo: blockInfoMap[glInternalFormat],
179
+ glInternalFormat: glInternalFormat,
180
+ mipmaps,
181
+ w: width,
182
+ h: height,
183
+ type: 'KTX',
184
+ },
185
+ premultiplyAlpha: false,
186
+ };
187
+ };
188
+ function pvrtcMipSize(width, height, bpp) {
189
+ const minW = bpp === 2 ? 16 : 8;
190
+ const minH = 8;
191
+ const w = Math.max(width, minW);
192
+ const h = Math.max(height, minH);
193
+ return (w * h * bpp) / 8;
194
+ }
195
+ const loadPVR = async function (view) {
196
+ const pixelFormatLow = view.getUint32(8, true);
197
+ const internalFormat = PVR_TO_GL_INTERNAL_FORMAT[pixelFormatLow];
198
+ if (internalFormat === undefined) {
199
+ throw new Error(`Unsupported PVR pixel format: 0x${pixelFormatLow.toString(16)}`);
200
+ }
201
+ const height = view.getInt32(24, true);
202
+ const width = view.getInt32(28, true);
203
+ // validate dimensions
204
+ if (width === 0 || height === 0) {
205
+ throw new Error(`Invalid PVR texture dimensions: ${width}x${height}`);
206
+ }
207
+ const mipmapLevels = view.getInt32(44, true);
208
+ const metadataSize = view.getUint32(48, true);
209
+ const buffer = view.buffer;
210
+ let offset = 52 + metadataSize;
211
+ if (offset > buffer.byteLength) {
212
+ throw new Error('Invalid PVR file: metadata exceeds file size');
213
+ }
214
+ const mipmaps = [];
215
+ const block = blockInfoMap[internalFormat];
216
+ for (let i = 0; i < mipmapLevels; i++) {
217
+ const declaredSize = view.getUint32(offset, true);
218
+ const max = buffer.byteLength - (offset + 4);
219
+ if (declaredSize > 0 && declaredSize <= max) {
220
+ offset += 4;
221
+ const start = offset;
222
+ const end = offset + declaredSize;
223
+ mipmaps.push(buffer.slice(start, end));
224
+ offset = end;
225
+ offset = (offset + 3) & ~3; // align to 4 bytes
226
+ continue;
227
+ }
228
+ if (pixelFormatLow === 0 ||
229
+ pixelFormatLow === 1 ||
230
+ pixelFormatLow === 2 ||
231
+ pixelFormatLow === 3) {
232
+ const bpp = pixelFormatLow === 0 || pixelFormatLow === 1 ? 2 : 4;
233
+ const computed = pvrtcMipSize(width >> i, height >> i, bpp);
234
+ mipmaps.push(buffer.slice(offset, offset + computed));
235
+ offset += computed;
236
+ offset = (offset + 3) & ~3; // align to 4 bytes
237
+ continue;
238
+ }
239
+ if (block !== undefined) {
240
+ const blockW = Math.ceil((width >> i) / block.width);
241
+ const blockH = Math.ceil((height >> i) / block.height);
242
+ const computed = blockW * blockH * block.bytes;
243
+ mipmaps.push(buffer.slice(offset, offset + computed));
244
+ offset += computed;
245
+ offset = (offset + 3) & ~3;
246
+ }
247
+ }
248
+ return {
249
+ data: {
250
+ blockInfo: blockInfoMap[internalFormat],
251
+ glInternalFormat: internalFormat,
252
+ mipmaps,
253
+ w: width,
254
+ h: height,
255
+ type: 'PVR',
256
+ },
257
+ premultiplyAlpha: false,
258
+ };
259
+ };
260
+ // Predefined block info for common compressed texture formats
261
+ const BLOCK_4x4x8 = { width: 4, height: 4, bytes: 8 };
262
+ const BLOCK_4x4x16 = { width: 4, height: 4, bytes: 16 };
263
+ const BLOCK_5x5x16 = { width: 5, height: 5, bytes: 16 };
264
+ const BLOCK_6x6x16 = { width: 6, height: 6, bytes: 16 };
265
+ const BLOCK_8x4x8 = { width: 8, height: 4, bytes: 8 };
266
+ const BLOCK_8x8x16 = { width: 8, height: 8, bytes: 16 };
267
+ const BLOCK_10x10x16 = { width: 10, height: 10, bytes: 16 };
268
+ const BLOCK_12x12x16 = { width: 12, height: 12, bytes: 16 };
269
+ // Map of GL internal formats to their corresponding block info
270
+ export const blockInfoMap = {
271
+ // S3TC / DXTn (WEBGL_compressed_texture_s3tc, sRGB variants)
272
+ 0x83f0: BLOCK_4x4x8, // COMPRESSED_RGB_S3TC_DXT1_EXT
273
+ 0x83f1: BLOCK_4x4x8, // COMPRESSED_RGBA_S3TC_DXT1_EXT
274
+ 0x83f2: BLOCK_4x4x16, // COMPRESSED_RGBA_S3TC_DXT3_EXT
275
+ 0x83f3: BLOCK_4x4x16, // COMPRESSED_RGBA_S3TC_DXT5_EXT
276
+ // ETC1 / ETC2 / EAC
277
+ 0x8d64: BLOCK_4x4x8, // COMPRESSED_RGB_ETC1_WEBGL
278
+ 0x9274: BLOCK_4x4x8, // COMPRESSED_RGB8_ETC2
279
+ 0x9275: BLOCK_4x4x8, // COMPRESSED_SRGB8_ETC2
280
+ 0x9278: BLOCK_4x4x16, // COMPRESSED_RGBA8_ETC2_EAC
281
+ 0x9279: BLOCK_4x4x16, // COMPRESSED_SRGB8_ALPHA8_ETC2_EAC
282
+ // PVRTC (WEBGL_compressed_texture_pvrtc)
283
+ 0x8c00: BLOCK_4x4x8, // COMPRESSED_RGB_PVRTC_4BPPV1_IMG
284
+ 0x8c02: BLOCK_4x4x8, // COMPRESSED_RGBA_PVRTC_4BPPV1_IMG
285
+ 0x8c01: BLOCK_8x4x8, // COMPRESSED_RGB_PVRTC_2BPPV1_IMG
286
+ 0x8c03: BLOCK_8x4x8,
287
+ // ASTC (WEBGL_compressed_texture_astc)
288
+ 0x93b0: BLOCK_4x4x16, // COMPRESSED_RGBA_ASTC_4x4_KHR
289
+ 0x93d0: BLOCK_4x4x16, // COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR
290
+ 0x93b1: BLOCK_5x5x16, // 5x5
291
+ 0x93d1: BLOCK_5x5x16,
292
+ 0x93b2: BLOCK_6x6x16, // 6x6
293
+ 0x93d2: BLOCK_6x6x16,
294
+ 0x93b3: BLOCK_8x8x16, // 8x8
295
+ 0x93d3: BLOCK_8x8x16,
296
+ 0x93b4: BLOCK_10x10x16, // 10x10
297
+ 0x93d4: BLOCK_10x10x16,
298
+ 0x93b5: BLOCK_12x12x16, // 12x12
299
+ 0x93d5: BLOCK_12x12x16,
300
+ };
301
+ //# sourceMappingURL=textureCompression.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"textureCompression.js","sourceRoot":"","sources":["../../../../../../src/core/platforms/web/lib/textureCompression.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAuB,MAAM,8BAA8B,CAAC;AAUnE,MAAM,SAAS,GAAG,UAAU,CAAC,CAAC,0BAA0B;AACxD,MAAM,yBAAyB,GAA2B;IACxD,CAAC,EAAE,MAAM;IACT,CAAC,EAAE,MAAM;IACT,CAAC,EAAE,MAAM;IACT,CAAC,EAAE,MAAM,EAAE,SAAS;IACpB,CAAC,EAAE,MAAM,EAAE,OAAO;IAClB,CAAC,EAAE,MAAM;IACT,CAAC,EAAE,MAAM;IACT,CAAC,EAAE,MAAM;IACT,EAAE,EAAE,MAAM;IACV,EAAE,EAAE,MAAM,EAAE,eAAe;CAC5B,CAAC;AACF,MAAM,UAAU,GAAG,UAAU,CAAC;AAE9B,MAAM,0BAA0B,GAA2B;IACzD,KAAK,EAAE,MAAM,EAAE,+BAA+B;IAC9C,KAAK,EAAE,MAAM,EAAE,+BAA+B;IAC9C,KAAK,EAAE,MAAM,EAAE,+BAA+B;IAC9C,KAAK,EAAE,MAAM,EAAE,+BAA+B;IAC9C,OAAO,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AE,uCAAuC;IAC7D,MAAM,EAAE,YAAY,EAAE,MAAM;IAC5B,MAAM,EAAE,YAAY;IACpB,MAAM,EAAE,YAAY,EAAE,MAAM;IAC5B,MAAM,EAAE,YAAY;IACpB,MAAM,EAAE,YAAY,EAAE,MAAM;IAC5B,MAAM,EAAE,YAAY;IACpB,MAAM,EAAE,cAAc,EAAE,QAAQ;IAChC,MAAM,EAAE,cAAc;IACtB,MAAM,EAAE,cAAc,EAAE,QAAQ;IAChC,MAAM,EAAE,cAAc;CACvB,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { ImageResponse } from '../../../textures/ImageTexture.js';
2
+ /**
3
+ * Loads a SVG image
4
+ * @param url
5
+ * @returns
6
+ */
7
+ export declare const loadSvg: (url: string, width: number | null, height: number | null, sx: number | null, sy: number | null, sw: number | null, sh: number | null) => Promise<ImageResponse>;
@@ -0,0 +1,51 @@
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 2023 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
+ import { assertTruthy } from '../../../../utils.js';
20
+ /**
21
+ * Loads a SVG image
22
+ * @param url
23
+ * @returns
24
+ */
25
+ export const loadSvg = (url, width, height, sx, sy, sw, sh) => {
26
+ return new Promise((resolve, reject) => {
27
+ const canvas = document.createElement('canvas');
28
+ const ctx = canvas.getContext('2d');
29
+ assertTruthy(ctx);
30
+ ctx.imageSmoothingEnabled = true;
31
+ const img = new Image();
32
+ img.onload = () => {
33
+ const x = sx ?? 0;
34
+ const y = sy ?? 0;
35
+ const w = width || img.width;
36
+ const h = height || img.height;
37
+ canvas.width = w;
38
+ canvas.height = h;
39
+ ctx.drawImage(img, 0, 0, w, h);
40
+ resolve({
41
+ data: ctx.getImageData(x, y, sw ?? w, sh ?? h),
42
+ premultiplyAlpha: false,
43
+ });
44
+ };
45
+ img.onerror = (err) => {
46
+ reject(err);
47
+ };
48
+ img.src = url;
49
+ });
50
+ };
51
+ //# sourceMappingURL=textureSvg.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"textureSvg.js","sourceRoot":"","sources":["../../../../../../src/core/platforms/web/lib/textureSvg.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAGpD;;;;GAIG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,CACrB,GAAW,EACX,KAAoB,EACpB,MAAqB,EACrB,EAAiB,EACjB,EAAiB,EACjB,EAAiB,EACjB,EAAiB,EACO,EAAE;IAC1B,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;QAChD,MAAM,GAAG,GAAG,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QACpC,YAAY,CAAC,GAAG,CAAC,CAAC;QAElB,GAAG,CAAC,qBAAqB,GAAG,IAAI,CAAC;QACjC,MAAM,GAAG,GAAG,IAAI,KAAK,EAAE,CAAC;QACxB,GAAG,CAAC,MAAM,GAAG,GAAG,EAAE;YAChB,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;YAClB,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;YAClB,MAAM,CAAC,GAAG,KAAK,IAAI,GAAG,CAAC,KAAK,CAAC;YAC7B,MAAM,CAAC,GAAG,MAAM,IAAI,GAAG,CAAC,MAAM,CAAC;YAE/B,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC;YACjB,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;YAClB,GAAG,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;YAE/B,OAAO,CAAC;gBACN,IAAI,EAAE,GAAG,CAAC,YAAY,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;gBAC9C,gBAAgB,EAAE,KAAK;aACxB,CAAC,CAAC;QACL,CAAC,CAAC;QAEF,GAAG,CAAC,OAAO,GAAG,CAAC,GAAG,EAAE,EAAE;YACpB,MAAM,CAAC,GAAG,CAAC,CAAC;QACd,CAAC,CAAC;QAEF,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC;IAChB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}
@@ -0,0 +1,5 @@
1
+ export declare const PROTOCOL_REGEX: RegExp;
2
+ export declare function isBase64Image(src: string): boolean;
3
+ export declare function dataURIToBlob(dataURI: string): Blob;
4
+ export declare function convertUrlToAbsolute(url: string): string;
5
+ export declare function createWebGLContext(canvas: HTMLCanvasElement | OffscreenCanvas, forceWebGL2?: boolean): WebGLRenderingContext;