@motion-core/motion-gpu 0.4.1 → 0.4.2

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 (205) hide show
  1. package/dist/advanced.d.ts +1 -0
  2. package/dist/advanced.d.ts.map +1 -0
  3. package/dist/advanced.js +12 -6
  4. package/dist/core/advanced.d.ts +1 -0
  5. package/dist/core/advanced.d.ts.map +1 -0
  6. package/dist/core/advanced.js +12 -5
  7. package/dist/core/current-value.d.ts +1 -0
  8. package/dist/core/current-value.d.ts.map +1 -0
  9. package/dist/core/current-value.js +35 -34
  10. package/dist/core/current-value.js.map +1 -0
  11. package/dist/core/error-diagnostics.d.ts +1 -0
  12. package/dist/core/error-diagnostics.d.ts.map +1 -0
  13. package/dist/core/error-diagnostics.js +70 -137
  14. package/dist/core/error-diagnostics.js.map +1 -0
  15. package/dist/core/error-report.d.ts +1 -0
  16. package/dist/core/error-report.d.ts.map +1 -0
  17. package/dist/core/error-report.js +184 -233
  18. package/dist/core/error-report.js.map +1 -0
  19. package/dist/core/frame-registry.d.ts +1 -0
  20. package/dist/core/frame-registry.d.ts.map +1 -0
  21. package/dist/core/frame-registry.js +546 -662
  22. package/dist/core/frame-registry.js.map +1 -0
  23. package/dist/core/index.d.ts +1 -0
  24. package/dist/core/index.d.ts.map +1 -0
  25. package/dist/core/index.js +11 -12
  26. package/dist/core/material-preprocess.d.ts +1 -0
  27. package/dist/core/material-preprocess.d.ts.map +1 -0
  28. package/dist/core/material-preprocess.js +128 -151
  29. package/dist/core/material-preprocess.js.map +1 -0
  30. package/dist/core/material.d.ts +1 -0
  31. package/dist/core/material.d.ts.map +1 -0
  32. package/dist/core/material.js +263 -317
  33. package/dist/core/material.js.map +1 -0
  34. package/dist/core/recompile-policy.d.ts +1 -0
  35. package/dist/core/recompile-policy.d.ts.map +1 -0
  36. package/dist/core/recompile-policy.js +18 -13
  37. package/dist/core/recompile-policy.js.map +1 -0
  38. package/dist/core/render-graph.d.ts +1 -0
  39. package/dist/core/render-graph.d.ts.map +1 -0
  40. package/dist/core/render-graph.js +61 -68
  41. package/dist/core/render-graph.js.map +1 -0
  42. package/dist/core/render-targets.d.ts +1 -0
  43. package/dist/core/render-targets.d.ts.map +1 -0
  44. package/dist/core/render-targets.js +52 -53
  45. package/dist/core/render-targets.js.map +1 -0
  46. package/dist/core/renderer.d.ts +1 -0
  47. package/dist/core/renderer.d.ts.map +1 -0
  48. package/dist/core/renderer.js +942 -1081
  49. package/dist/core/renderer.js.map +1 -0
  50. package/dist/core/runtime-loop.d.ts +1 -0
  51. package/dist/core/runtime-loop.d.ts.map +1 -0
  52. package/dist/core/runtime-loop.js +305 -362
  53. package/dist/core/runtime-loop.js.map +1 -0
  54. package/dist/core/scheduler-helpers.d.ts +1 -0
  55. package/dist/core/scheduler-helpers.d.ts.map +1 -0
  56. package/dist/core/scheduler-helpers.js +52 -51
  57. package/dist/core/scheduler-helpers.js.map +1 -0
  58. package/dist/core/shader.d.ts +1 -0
  59. package/dist/core/shader.d.ts.map +1 -0
  60. package/dist/core/shader.js +92 -117
  61. package/dist/core/shader.js.map +1 -0
  62. package/dist/core/texture-loader.d.ts +1 -0
  63. package/dist/core/texture-loader.d.ts.map +1 -0
  64. package/dist/core/texture-loader.js +205 -273
  65. package/dist/core/texture-loader.js.map +1 -0
  66. package/dist/core/textures.d.ts +1 -0
  67. package/dist/core/textures.d.ts.map +1 -0
  68. package/dist/core/textures.js +106 -116
  69. package/dist/core/textures.js.map +1 -0
  70. package/dist/core/types.d.ts +1 -0
  71. package/dist/core/types.d.ts.map +1 -0
  72. package/dist/core/types.js +0 -4
  73. package/dist/core/uniforms.d.ts +1 -0
  74. package/dist/core/uniforms.d.ts.map +1 -0
  75. package/dist/core/uniforms.js +170 -191
  76. package/dist/core/uniforms.js.map +1 -0
  77. package/dist/index.d.ts +1 -0
  78. package/dist/index.d.ts.map +1 -0
  79. package/dist/index.js +11 -6
  80. package/dist/passes/BlitPass.d.ts +1 -0
  81. package/dist/passes/BlitPass.d.ts.map +1 -0
  82. package/dist/passes/BlitPass.js +23 -18
  83. package/dist/passes/BlitPass.js.map +1 -0
  84. package/dist/passes/CopyPass.d.ts +1 -0
  85. package/dist/passes/CopyPass.d.ts.map +1 -0
  86. package/dist/passes/CopyPass.js +58 -52
  87. package/dist/passes/CopyPass.js.map +1 -0
  88. package/dist/passes/FullscreenPass.d.ts +1 -0
  89. package/dist/passes/FullscreenPass.d.ts.map +1 -0
  90. package/dist/passes/FullscreenPass.js +127 -130
  91. package/dist/passes/FullscreenPass.js.map +1 -0
  92. package/dist/passes/ShaderPass.d.ts +1 -0
  93. package/dist/passes/ShaderPass.d.ts.map +1 -0
  94. package/dist/passes/ShaderPass.js +40 -37
  95. package/dist/passes/ShaderPass.js.map +1 -0
  96. package/dist/passes/index.d.ts +1 -0
  97. package/dist/passes/index.d.ts.map +1 -0
  98. package/dist/passes/index.js +4 -3
  99. package/dist/react/FragCanvas.d.ts +1 -0
  100. package/dist/react/FragCanvas.d.ts.map +1 -0
  101. package/dist/react/FragCanvas.js +234 -211
  102. package/dist/react/FragCanvas.js.map +1 -0
  103. package/dist/react/MotionGPUErrorOverlay.d.ts +1 -0
  104. package/dist/react/MotionGPUErrorOverlay.d.ts.map +1 -0
  105. package/dist/react/MotionGPUErrorOverlay.js +96 -13
  106. package/dist/react/MotionGPUErrorOverlay.js.map +1 -0
  107. package/dist/react/Portal.d.ts +1 -0
  108. package/dist/react/Portal.d.ts.map +1 -0
  109. package/dist/react/Portal.js +18 -21
  110. package/dist/react/Portal.js.map +1 -0
  111. package/dist/react/advanced.d.ts +1 -0
  112. package/dist/react/advanced.d.ts.map +1 -0
  113. package/dist/react/advanced.js +12 -6
  114. package/dist/react/frame-context.d.ts +1 -0
  115. package/dist/react/frame-context.d.ts.map +1 -0
  116. package/dist/react/frame-context.js +88 -94
  117. package/dist/react/frame-context.js.map +1 -0
  118. package/dist/react/index.d.ts +1 -0
  119. package/dist/react/index.d.ts.map +1 -0
  120. package/dist/react/index.js +10 -9
  121. package/dist/react/motiongpu-context.d.ts +1 -0
  122. package/dist/react/motiongpu-context.d.ts.map +1 -0
  123. package/dist/react/motiongpu-context.js +18 -15
  124. package/dist/react/motiongpu-context.js.map +1 -0
  125. package/dist/react/use-motiongpu-user-context.d.ts +1 -0
  126. package/dist/react/use-motiongpu-user-context.d.ts.map +1 -0
  127. package/dist/react/use-motiongpu-user-context.js +83 -82
  128. package/dist/react/use-motiongpu-user-context.js.map +1 -0
  129. package/dist/react/use-texture.d.ts +1 -0
  130. package/dist/react/use-texture.d.ts.map +1 -0
  131. package/dist/react/use-texture.js +132 -152
  132. package/dist/react/use-texture.js.map +1 -0
  133. package/dist/svelte/FragCanvas.svelte.d.ts +1 -0
  134. package/dist/svelte/FragCanvas.svelte.d.ts.map +1 -0
  135. package/dist/svelte/MotionGPUErrorOverlay.svelte.d.ts +1 -0
  136. package/dist/svelte/MotionGPUErrorOverlay.svelte.d.ts.map +1 -0
  137. package/dist/svelte/Portal.svelte.d.ts +1 -0
  138. package/dist/svelte/Portal.svelte.d.ts.map +1 -0
  139. package/dist/svelte/advanced.d.ts +1 -0
  140. package/dist/svelte/advanced.d.ts.map +1 -0
  141. package/dist/svelte/advanced.js +11 -6
  142. package/dist/svelte/frame-context.d.ts +1 -0
  143. package/dist/svelte/frame-context.d.ts.map +1 -0
  144. package/dist/svelte/frame-context.js +27 -27
  145. package/dist/svelte/frame-context.js.map +1 -0
  146. package/dist/svelte/index.d.ts +1 -0
  147. package/dist/svelte/index.d.ts.map +1 -0
  148. package/dist/svelte/index.js +10 -9
  149. package/dist/svelte/motiongpu-context.d.ts +1 -0
  150. package/dist/svelte/motiongpu-context.d.ts.map +1 -0
  151. package/dist/svelte/motiongpu-context.js +24 -21
  152. package/dist/svelte/motiongpu-context.js.map +1 -0
  153. package/dist/svelte/use-motiongpu-user-context.d.ts +1 -0
  154. package/dist/svelte/use-motiongpu-user-context.d.ts.map +1 -0
  155. package/dist/svelte/use-motiongpu-user-context.js +69 -70
  156. package/dist/svelte/use-motiongpu-user-context.js.map +1 -0
  157. package/dist/svelte/use-texture.d.ts +1 -0
  158. package/dist/svelte/use-texture.d.ts.map +1 -0
  159. package/dist/svelte/use-texture.js +125 -147
  160. package/dist/svelte/use-texture.js.map +1 -0
  161. package/package.json +12 -7
  162. package/src/lib/advanced.ts +6 -0
  163. package/src/lib/core/advanced.ts +12 -0
  164. package/src/lib/core/current-value.ts +64 -0
  165. package/src/lib/core/error-diagnostics.ts +236 -0
  166. package/src/lib/core/error-report.ts +406 -0
  167. package/src/lib/core/frame-registry.ts +1189 -0
  168. package/src/lib/core/index.ts +77 -0
  169. package/src/lib/core/material-preprocess.ts +284 -0
  170. package/src/lib/core/material.ts +667 -0
  171. package/src/lib/core/recompile-policy.ts +31 -0
  172. package/src/lib/core/render-graph.ts +143 -0
  173. package/src/lib/core/render-targets.ts +107 -0
  174. package/src/lib/core/renderer.ts +1547 -0
  175. package/src/lib/core/runtime-loop.ts +458 -0
  176. package/src/lib/core/scheduler-helpers.ts +136 -0
  177. package/src/lib/core/shader.ts +258 -0
  178. package/src/lib/core/texture-loader.ts +476 -0
  179. package/src/lib/core/textures.ts +235 -0
  180. package/src/lib/core/types.ts +582 -0
  181. package/src/lib/core/uniforms.ts +282 -0
  182. package/src/lib/index.ts +6 -0
  183. package/src/lib/passes/BlitPass.ts +54 -0
  184. package/src/lib/passes/CopyPass.ts +80 -0
  185. package/src/lib/passes/FullscreenPass.ts +173 -0
  186. package/src/lib/passes/ShaderPass.ts +88 -0
  187. package/src/lib/passes/index.ts +3 -0
  188. package/src/lib/react/FragCanvas.tsx +345 -0
  189. package/src/lib/react/MotionGPUErrorOverlay.tsx +392 -0
  190. package/src/lib/react/Portal.tsx +34 -0
  191. package/src/lib/react/advanced.ts +36 -0
  192. package/src/lib/react/frame-context.ts +169 -0
  193. package/src/lib/react/index.ts +51 -0
  194. package/src/lib/react/motiongpu-context.ts +88 -0
  195. package/src/lib/react/use-motiongpu-user-context.ts +186 -0
  196. package/src/lib/react/use-texture.ts +233 -0
  197. package/src/lib/svelte/FragCanvas.svelte +249 -0
  198. package/src/lib/svelte/MotionGPUErrorOverlay.svelte +382 -0
  199. package/src/lib/svelte/Portal.svelte +31 -0
  200. package/src/lib/svelte/advanced.ts +32 -0
  201. package/src/lib/svelte/frame-context.ts +87 -0
  202. package/src/lib/svelte/index.ts +51 -0
  203. package/src/lib/svelte/motiongpu-context.ts +97 -0
  204. package/src/lib/svelte/use-motiongpu-user-context.ts +145 -0
  205. package/src/lib/svelte/use-texture.ts +232 -0
@@ -1,295 +1,227 @@
1
- const resourceCache = new Map();
1
+ //#region src/lib/core/texture-loader.ts
2
+ var resourceCache = /* @__PURE__ */ new Map();
2
3
  function createAbortError() {
3
- try {
4
- return new DOMException('Texture request was aborted', 'AbortError');
5
- }
6
- catch {
7
- const error = new Error('Texture request was aborted');
8
- error.name = 'AbortError';
9
- return error;
10
- }
4
+ try {
5
+ return new DOMException("Texture request was aborted", "AbortError");
6
+ } catch {
7
+ const error = /* @__PURE__ */ new Error("Texture request was aborted");
8
+ error.name = "AbortError";
9
+ return error;
10
+ }
11
11
  }
12
12
  /**
13
- * Checks whether error represents abort cancellation.
14
- */
15
- export function isAbortError(error) {
16
- return (error instanceof Error &&
17
- (error.name === 'AbortError' || error.message.toLowerCase().includes('aborted')));
13
+ * Checks whether error represents abort cancellation.
14
+ */
15
+ function isAbortError(error) {
16
+ return error instanceof Error && (error.name === "AbortError" || error.message.toLowerCase().includes("aborted"));
18
17
  }
19
18
  function toBodyFingerprint(body) {
20
- if (body == null) {
21
- return null;
22
- }
23
- if (typeof body === 'string') {
24
- return `string:${body}`;
25
- }
26
- if (body instanceof URLSearchParams) {
27
- return `urlsearchparams:${body.toString()}`;
28
- }
29
- if (typeof FormData !== 'undefined' && body instanceof FormData) {
30
- const entries = Array.from(body.entries()).map(([key, value]) => `${key}:${String(value)}`);
31
- return `formdata:${entries.join('&')}`;
32
- }
33
- if (body instanceof Blob) {
34
- return `blob:${body.type}:${body.size}`;
35
- }
36
- if (body instanceof ArrayBuffer) {
37
- return `arraybuffer:${body.byteLength}`;
38
- }
39
- if (ArrayBuffer.isView(body)) {
40
- return `view:${body.byteLength}`;
41
- }
42
- return `opaque:${Object.prototype.toString.call(body)}`;
19
+ if (body == null) return null;
20
+ if (typeof body === "string") return `string:${body}`;
21
+ if (body instanceof URLSearchParams) return `urlsearchparams:${body.toString()}`;
22
+ if (typeof FormData !== "undefined" && body instanceof FormData) return `formdata:${Array.from(body.entries()).map(([key, value]) => `${key}:${String(value)}`).join("&")}`;
23
+ if (body instanceof Blob) return `blob:${body.type}:${body.size}`;
24
+ if (body instanceof ArrayBuffer) return `arraybuffer:${body.byteLength}`;
25
+ if (ArrayBuffer.isView(body)) return `view:${body.byteLength}`;
26
+ return `opaque:${Object.prototype.toString.call(body)}`;
43
27
  }
44
28
  function normalizeRequestInit(requestInit) {
45
- if (!requestInit) {
46
- return {};
47
- }
48
- const headers = new Headers(requestInit.headers);
49
- const headerEntries = Array.from(headers.entries()).sort(([a], [b]) => a.localeCompare(b));
50
- const normalized = {};
51
- normalized.method = (requestInit.method ?? 'GET').toUpperCase();
52
- normalized.mode = requestInit.mode ?? null;
53
- normalized.cache = requestInit.cache ?? null;
54
- normalized.credentials = requestInit.credentials ?? null;
55
- normalized.redirect = requestInit.redirect ?? null;
56
- normalized.referrer = requestInit.referrer ?? null;
57
- normalized.referrerPolicy = requestInit.referrerPolicy ?? null;
58
- normalized.integrity = requestInit.integrity ?? null;
59
- normalized.keepalive = requestInit.keepalive ?? false;
60
- normalized.priority = requestInit.priority ?? null;
61
- normalized.headers = headerEntries;
62
- normalized.body = toBodyFingerprint(requestInit.body);
63
- return normalized;
29
+ if (!requestInit) return {};
30
+ const headers = new Headers(requestInit.headers);
31
+ const headerEntries = Array.from(headers.entries()).sort(([a], [b]) => a.localeCompare(b));
32
+ const normalized = {};
33
+ normalized.method = (requestInit.method ?? "GET").toUpperCase();
34
+ normalized.mode = requestInit.mode ?? null;
35
+ normalized.cache = requestInit.cache ?? null;
36
+ normalized.credentials = requestInit.credentials ?? null;
37
+ normalized.redirect = requestInit.redirect ?? null;
38
+ normalized.referrer = requestInit.referrer ?? null;
39
+ normalized.referrerPolicy = requestInit.referrerPolicy ?? null;
40
+ normalized.integrity = requestInit.integrity ?? null;
41
+ normalized.keepalive = requestInit.keepalive ?? false;
42
+ normalized.priority = requestInit.priority ?? null;
43
+ normalized.headers = headerEntries;
44
+ normalized.body = toBodyFingerprint(requestInit.body);
45
+ return normalized;
64
46
  }
65
47
  function normalizeTextureLoadOptions(options) {
66
- const colorSpace = options.colorSpace ?? 'srgb';
67
- const normalized = {
68
- colorSpace,
69
- decode: {
70
- colorSpaceConversion: options.decode?.colorSpaceConversion ?? (colorSpace === 'linear' ? 'none' : 'default'),
71
- premultiplyAlpha: options.decode?.premultiplyAlpha ?? 'default',
72
- imageOrientation: options.decode?.imageOrientation ?? 'none'
73
- }
74
- };
75
- if (options.requestInit !== undefined) {
76
- normalized.requestInit = options.requestInit;
77
- }
78
- if (options.signal !== undefined) {
79
- normalized.signal = options.signal;
80
- }
81
- if (options.update !== undefined) {
82
- normalized.update = options.update;
83
- }
84
- if (options.flipY !== undefined) {
85
- normalized.flipY = options.flipY;
86
- }
87
- if (options.premultipliedAlpha !== undefined) {
88
- normalized.premultipliedAlpha = options.premultipliedAlpha;
89
- }
90
- if (options.generateMipmaps !== undefined) {
91
- normalized.generateMipmaps = options.generateMipmaps;
92
- }
93
- return normalized;
48
+ const colorSpace = options.colorSpace ?? "srgb";
49
+ const normalized = {
50
+ colorSpace,
51
+ decode: {
52
+ colorSpaceConversion: options.decode?.colorSpaceConversion ?? (colorSpace === "linear" ? "none" : "default"),
53
+ premultiplyAlpha: options.decode?.premultiplyAlpha ?? "default",
54
+ imageOrientation: options.decode?.imageOrientation ?? "none"
55
+ }
56
+ };
57
+ if (options.requestInit !== void 0) normalized.requestInit = options.requestInit;
58
+ if (options.signal !== void 0) normalized.signal = options.signal;
59
+ if (options.update !== void 0) normalized.update = options.update;
60
+ if (options.flipY !== void 0) normalized.flipY = options.flipY;
61
+ if (options.premultipliedAlpha !== void 0) normalized.premultipliedAlpha = options.premultipliedAlpha;
62
+ if (options.generateMipmaps !== void 0) normalized.generateMipmaps = options.generateMipmaps;
63
+ return normalized;
94
64
  }
95
65
  /**
96
- * Builds deterministic resource cache key from full URL IO config.
97
- */
98
- export function buildTextureResourceCacheKey(url, options = {}) {
99
- const normalized = normalizeTextureLoadOptions(options);
100
- return JSON.stringify({
101
- url,
102
- colorSpace: normalized.colorSpace,
103
- requestInit: normalizeRequestInit(normalized.requestInit),
104
- decode: normalized.decode
105
- });
66
+ * Builds deterministic resource cache key from full URL IO config.
67
+ */
68
+ function buildTextureResourceCacheKey(url, options = {}) {
69
+ const normalized = normalizeTextureLoadOptions(options);
70
+ return JSON.stringify({
71
+ url,
72
+ colorSpace: normalized.colorSpace,
73
+ requestInit: normalizeRequestInit(normalized.requestInit),
74
+ decode: normalized.decode
75
+ });
106
76
  }
107
77
  /**
108
- * Clears the internal texture resource cache.
109
- */
110
- export function clearTextureBlobCache() {
111
- for (const entry of resourceCache.values()) {
112
- if (!entry.settled) {
113
- entry.controller.abort();
114
- }
115
- }
116
- resourceCache.clear();
78
+ * Clears the internal texture resource cache.
79
+ */
80
+ function clearTextureBlobCache() {
81
+ for (const entry of resourceCache.values()) if (!entry.settled) entry.controller.abort();
82
+ resourceCache.clear();
117
83
  }
118
84
  function acquireTextureBlob(url, options) {
119
- const key = buildTextureResourceCacheKey(url, options);
120
- const existing = resourceCache.get(key);
121
- if (existing) {
122
- existing.refs += 1;
123
- let released = false;
124
- return {
125
- entry: existing,
126
- release: () => {
127
- if (released) {
128
- return;
129
- }
130
- released = true;
131
- existing.refs = Math.max(0, existing.refs - 1);
132
- if (existing.refs === 0) {
133
- if (!existing.settled) {
134
- existing.controller.abort();
135
- }
136
- resourceCache.delete(key);
137
- }
138
- }
139
- };
140
- }
141
- const normalized = normalizeTextureLoadOptions(options);
142
- const controller = new AbortController();
143
- const requestInit = {
144
- ...(normalized.requestInit ?? {}),
145
- signal: controller.signal
146
- };
147
- const entry = {
148
- key,
149
- refs: 1,
150
- controller,
151
- settled: false,
152
- blobPromise: fetch(url, requestInit)
153
- .then(async (response) => {
154
- if (!response.ok) {
155
- throw new Error(`Texture request failed (${response.status}) for ${url}`);
156
- }
157
- return response.blob();
158
- })
159
- .then((blob) => {
160
- entry.settled = true;
161
- return blob;
162
- })
163
- .catch((error) => {
164
- resourceCache.delete(key);
165
- throw error;
166
- })
167
- };
168
- resourceCache.set(key, entry);
169
- let released = false;
170
- return {
171
- entry,
172
- release: () => {
173
- if (released) {
174
- return;
175
- }
176
- released = true;
177
- entry.refs = Math.max(0, entry.refs - 1);
178
- if (entry.refs === 0) {
179
- if (!entry.settled) {
180
- entry.controller.abort();
181
- }
182
- resourceCache.delete(key);
183
- }
184
- }
185
- };
85
+ const key = buildTextureResourceCacheKey(url, options);
86
+ const existing = resourceCache.get(key);
87
+ if (existing) {
88
+ existing.refs += 1;
89
+ let released = false;
90
+ return {
91
+ entry: existing,
92
+ release: () => {
93
+ if (released) return;
94
+ released = true;
95
+ existing.refs = Math.max(0, existing.refs - 1);
96
+ if (existing.refs === 0) {
97
+ if (!existing.settled) existing.controller.abort();
98
+ resourceCache.delete(key);
99
+ }
100
+ }
101
+ };
102
+ }
103
+ const normalized = normalizeTextureLoadOptions(options);
104
+ const controller = new AbortController();
105
+ const requestInit = {
106
+ ...normalized.requestInit ?? {},
107
+ signal: controller.signal
108
+ };
109
+ const entry = {
110
+ key,
111
+ refs: 1,
112
+ controller,
113
+ settled: false,
114
+ blobPromise: fetch(url, requestInit).then(async (response) => {
115
+ if (!response.ok) throw new Error(`Texture request failed (${response.status}) for ${url}`);
116
+ return response.blob();
117
+ }).then((blob) => {
118
+ entry.settled = true;
119
+ return blob;
120
+ }).catch((error) => {
121
+ resourceCache.delete(key);
122
+ throw error;
123
+ })
124
+ };
125
+ resourceCache.set(key, entry);
126
+ let released = false;
127
+ return {
128
+ entry,
129
+ release: () => {
130
+ if (released) return;
131
+ released = true;
132
+ entry.refs = Math.max(0, entry.refs - 1);
133
+ if (entry.refs === 0) {
134
+ if (!entry.settled) entry.controller.abort();
135
+ resourceCache.delete(key);
136
+ }
137
+ }
138
+ };
186
139
  }
187
140
  async function awaitWithAbort(promise, signal) {
188
- if (!signal) {
189
- return promise;
190
- }
191
- if (signal.aborted) {
192
- throw createAbortError();
193
- }
194
- return new Promise((resolve, reject) => {
195
- const onAbort = () => {
196
- reject(createAbortError());
197
- };
198
- signal.addEventListener('abort', onAbort, { once: true });
199
- promise.then(resolve, reject).finally(() => {
200
- signal.removeEventListener('abort', onAbort);
201
- });
202
- });
141
+ if (!signal) return promise;
142
+ if (signal.aborted) throw createAbortError();
143
+ return new Promise((resolve, reject) => {
144
+ const onAbort = () => {
145
+ reject(createAbortError());
146
+ };
147
+ signal.addEventListener("abort", onAbort, { once: true });
148
+ promise.then(resolve, reject).finally(() => {
149
+ signal.removeEventListener("abort", onAbort);
150
+ });
151
+ });
203
152
  }
204
153
  /**
205
- * Loads a single texture from URL and converts it to an `ImageBitmap`.
206
- *
207
- * @param url - Texture URL.
208
- * @param options - Loading options.
209
- * @returns Loaded texture object.
210
- * @throws {Error} When runtime does not support `createImageBitmap` or request fails.
211
- */
212
- export async function loadTextureFromUrl(url, options = {}) {
213
- if (typeof createImageBitmap !== 'function') {
214
- throw new Error('createImageBitmap is not available in this runtime');
215
- }
216
- const normalized = normalizeTextureLoadOptions(options);
217
- const { entry, release } = acquireTextureBlob(url, options);
218
- let bitmap = null;
219
- try {
220
- const blob = await awaitWithAbort(entry.blobPromise, normalized.signal);
221
- const bitmapOptions = {
222
- colorSpaceConversion: normalized.decode.colorSpaceConversion,
223
- premultiplyAlpha: normalized.decode.premultiplyAlpha,
224
- imageOrientation: normalized.decode.imageOrientation
225
- };
226
- const allDefaults = bitmapOptions.colorSpaceConversion === 'default' &&
227
- bitmapOptions.premultiplyAlpha === 'default' &&
228
- bitmapOptions.imageOrientation === 'none';
229
- bitmap = allDefaults
230
- ? await createImageBitmap(blob)
231
- : await createImageBitmap(blob, bitmapOptions);
232
- if (normalized.signal?.aborted) {
233
- bitmap.close();
234
- throw createAbortError();
235
- }
236
- const loaded = {
237
- url,
238
- source: bitmap,
239
- width: bitmap.width,
240
- height: bitmap.height,
241
- colorSpace: normalized.colorSpace,
242
- dispose: () => {
243
- bitmap?.close();
244
- }
245
- };
246
- if (normalized.update !== undefined) {
247
- loaded.update = normalized.update;
248
- }
249
- if (normalized.flipY !== undefined) {
250
- loaded.flipY = normalized.flipY;
251
- }
252
- if (normalized.premultipliedAlpha !== undefined) {
253
- loaded.premultipliedAlpha = normalized.premultipliedAlpha;
254
- }
255
- if (normalized.generateMipmaps !== undefined) {
256
- loaded.generateMipmaps = normalized.generateMipmaps;
257
- }
258
- return loaded;
259
- }
260
- catch (error) {
261
- if (bitmap) {
262
- bitmap.close();
263
- }
264
- throw error;
265
- }
266
- finally {
267
- release();
268
- }
154
+ * Loads a single texture from URL and converts it to an `ImageBitmap`.
155
+ *
156
+ * @param url - Texture URL.
157
+ * @param options - Loading options.
158
+ * @returns Loaded texture object.
159
+ * @throws {Error} When runtime does not support `createImageBitmap` or request fails.
160
+ */
161
+ async function loadTextureFromUrl(url, options = {}) {
162
+ if (typeof createImageBitmap !== "function") throw new Error("createImageBitmap is not available in this runtime");
163
+ const normalized = normalizeTextureLoadOptions(options);
164
+ const { entry, release } = acquireTextureBlob(url, options);
165
+ let bitmap = null;
166
+ try {
167
+ const blob = await awaitWithAbort(entry.blobPromise, normalized.signal);
168
+ const bitmapOptions = {
169
+ colorSpaceConversion: normalized.decode.colorSpaceConversion,
170
+ premultiplyAlpha: normalized.decode.premultiplyAlpha,
171
+ imageOrientation: normalized.decode.imageOrientation
172
+ };
173
+ bitmap = bitmapOptions.colorSpaceConversion === "default" && bitmapOptions.premultiplyAlpha === "default" && bitmapOptions.imageOrientation === "none" ? await createImageBitmap(blob) : await createImageBitmap(blob, bitmapOptions);
174
+ if (normalized.signal?.aborted) {
175
+ bitmap.close();
176
+ throw createAbortError();
177
+ }
178
+ const loaded = {
179
+ url,
180
+ source: bitmap,
181
+ width: bitmap.width,
182
+ height: bitmap.height,
183
+ colorSpace: normalized.colorSpace,
184
+ dispose: () => {
185
+ bitmap?.close();
186
+ }
187
+ };
188
+ if (normalized.update !== void 0) loaded.update = normalized.update;
189
+ if (normalized.flipY !== void 0) loaded.flipY = normalized.flipY;
190
+ if (normalized.premultipliedAlpha !== void 0) loaded.premultipliedAlpha = normalized.premultipliedAlpha;
191
+ if (normalized.generateMipmaps !== void 0) loaded.generateMipmaps = normalized.generateMipmaps;
192
+ return loaded;
193
+ } catch (error) {
194
+ if (bitmap) bitmap.close();
195
+ throw error;
196
+ } finally {
197
+ release();
198
+ }
269
199
  }
270
200
  /**
271
- * Loads many textures in parallel from URLs.
272
- *
273
- * @param urls - Texture URLs.
274
- * @param options - Shared loading options.
275
- * @returns Promise resolving to loaded textures in input order.
276
- */
277
- export async function loadTexturesFromUrls(urls, options = {}) {
278
- const settled = await Promise.allSettled(urls.map((url) => loadTextureFromUrl(url, options)));
279
- const loaded = [];
280
- let firstError = null;
281
- for (const entry of settled) {
282
- if (entry.status === 'fulfilled') {
283
- loaded.push(entry.value);
284
- continue;
285
- }
286
- firstError ??= entry.reason;
287
- }
288
- if (firstError) {
289
- for (const texture of loaded) {
290
- texture.dispose();
291
- }
292
- throw firstError;
293
- }
294
- return loaded;
201
+ * Loads many textures in parallel from URLs.
202
+ *
203
+ * @param urls - Texture URLs.
204
+ * @param options - Shared loading options.
205
+ * @returns Promise resolving to loaded textures in input order.
206
+ */
207
+ async function loadTexturesFromUrls(urls, options = {}) {
208
+ const settled = await Promise.allSettled(urls.map((url) => loadTextureFromUrl(url, options)));
209
+ const loaded = [];
210
+ let firstError = null;
211
+ for (const entry of settled) {
212
+ if (entry.status === "fulfilled") {
213
+ loaded.push(entry.value);
214
+ continue;
215
+ }
216
+ firstError ??= entry.reason;
217
+ }
218
+ if (firstError) {
219
+ for (const texture of loaded) texture.dispose();
220
+ throw firstError;
221
+ }
222
+ return loaded;
295
223
  }
224
+ //#endregion
225
+ export { buildTextureResourceCacheKey, clearTextureBlobCache, isAbortError, loadTextureFromUrl, loadTexturesFromUrls };
226
+
227
+ //# sourceMappingURL=texture-loader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"texture-loader.js","names":[],"sources":["../../src/lib/core/texture-loader.ts"],"sourcesContent":["import type { TextureUpdateMode } from './types.js';\n\n/**\n * Options controlling bitmap decode behavior.\n */\nexport interface TextureDecodeOptions {\n\t/**\n\t * Controls color-space conversion during decode.\n\t */\n\tcolorSpaceConversion?: 'default' | 'none';\n\t/**\n\t * Controls alpha premultiplication during decode.\n\t */\n\tpremultiplyAlpha?: 'default' | 'none' | 'premultiply';\n\t/**\n\t * Controls bitmap orientation during decode.\n\t */\n\timageOrientation?: 'none' | 'flipY';\n}\n\n/**\n * Options controlling URL-based texture loading and decode behavior.\n */\nexport interface TextureLoadOptions {\n\t/**\n\t * Desired texture color space.\n\t */\n\tcolorSpace?: 'srgb' | 'linear';\n\t/**\n\t * Fetch options forwarded to `fetch`.\n\t */\n\trequestInit?: RequestInit;\n\t/**\n\t * Decode options forwarded to `createImageBitmap`.\n\t */\n\tdecode?: TextureDecodeOptions;\n\t/**\n\t * Optional cancellation signal for this request.\n\t */\n\tsignal?: AbortSignal;\n\t/**\n\t * Optional runtime update strategy metadata attached to loaded textures.\n\t */\n\tupdate?: TextureUpdateMode;\n\t/**\n\t * Optional runtime flip-y metadata attached to loaded textures.\n\t */\n\tflipY?: boolean;\n\t/**\n\t * Optional runtime premultiplied-alpha metadata attached to loaded textures.\n\t */\n\tpremultipliedAlpha?: boolean;\n\t/**\n\t * Optional runtime mipmap metadata attached to loaded textures.\n\t */\n\tgenerateMipmaps?: boolean;\n}\n\n/**\n * Loaded texture payload returned by URL loaders.\n */\nexport interface LoadedTexture {\n\t/**\n\t * Source URL.\n\t */\n\turl: string;\n\t/**\n\t * Decoded bitmap source.\n\t */\n\tsource: ImageBitmap;\n\t/**\n\t * Bitmap width in pixels.\n\t */\n\twidth: number;\n\t/**\n\t * Bitmap height in pixels.\n\t */\n\theight: number;\n\t/**\n\t * Effective color space.\n\t */\n\tcolorSpace: 'srgb' | 'linear';\n\t/**\n\t * Effective runtime update strategy.\n\t */\n\tupdate?: TextureUpdateMode;\n\t/**\n\t * Effective runtime flip-y metadata.\n\t */\n\tflipY?: boolean;\n\t/**\n\t * Effective runtime premultiplied-alpha metadata.\n\t */\n\tpremultipliedAlpha?: boolean;\n\t/**\n\t * Effective runtime mipmap metadata.\n\t */\n\tgenerateMipmaps?: boolean;\n\t/**\n\t * Releases bitmap resources.\n\t */\n\tdispose: () => void;\n}\n\ninterface NormalizedTextureLoadOptions {\n\tcolorSpace: 'srgb' | 'linear';\n\trequestInit?: RequestInit;\n\tdecode: Required<TextureDecodeOptions>;\n\tsignal?: AbortSignal;\n\tupdate?: TextureUpdateMode;\n\tflipY?: boolean;\n\tpremultipliedAlpha?: boolean;\n\tgenerateMipmaps?: boolean;\n}\n\ninterface TextureResourceCacheEntry {\n\tkey: string;\n\trefs: number;\n\tcontroller: AbortController;\n\tsettled: boolean;\n\tblobPromise: Promise<Blob>;\n}\n\nconst resourceCache = new Map<string, TextureResourceCacheEntry>();\n\nfunction createAbortError(): Error {\n\ttry {\n\t\treturn new DOMException('Texture request was aborted', 'AbortError');\n\t} catch {\n\t\tconst error = new Error('Texture request was aborted');\n\t\t(error as Error & { name: string }).name = 'AbortError';\n\t\treturn error;\n\t}\n}\n\n/**\n * Checks whether error represents abort cancellation.\n */\nexport function isAbortError(error: unknown): boolean {\n\treturn (\n\t\terror instanceof Error &&\n\t\t(error.name === 'AbortError' || error.message.toLowerCase().includes('aborted'))\n\t);\n}\n\nfunction toBodyFingerprint(body: BodyInit | null | undefined): string | null {\n\tif (body == null) {\n\t\treturn null;\n\t}\n\n\tif (typeof body === 'string') {\n\t\treturn `string:${body}`;\n\t}\n\n\tif (body instanceof URLSearchParams) {\n\t\treturn `urlsearchparams:${body.toString()}`;\n\t}\n\n\tif (typeof FormData !== 'undefined' && body instanceof FormData) {\n\t\tconst entries = Array.from(body.entries()).map(([key, value]) => `${key}:${String(value)}`);\n\t\treturn `formdata:${entries.join('&')}`;\n\t}\n\n\tif (body instanceof Blob) {\n\t\treturn `blob:${body.type}:${body.size}`;\n\t}\n\n\tif (body instanceof ArrayBuffer) {\n\t\treturn `arraybuffer:${body.byteLength}`;\n\t}\n\n\tif (ArrayBuffer.isView(body)) {\n\t\treturn `view:${body.byteLength}`;\n\t}\n\n\treturn `opaque:${Object.prototype.toString.call(body)}`;\n}\n\nfunction normalizeRequestInit(requestInit: RequestInit | undefined): Record<string, unknown> {\n\tif (!requestInit) {\n\t\treturn {};\n\t}\n\n\tconst headers = new Headers(requestInit.headers);\n\tconst headerEntries = Array.from(headers.entries()).sort(([a], [b]) => a.localeCompare(b));\n\tconst normalized: Record<string, unknown> = {};\n\n\tnormalized.method = (requestInit.method ?? 'GET').toUpperCase();\n\tnormalized.mode = requestInit.mode ?? null;\n\tnormalized.cache = requestInit.cache ?? null;\n\tnormalized.credentials = requestInit.credentials ?? null;\n\tnormalized.redirect = requestInit.redirect ?? null;\n\tnormalized.referrer = requestInit.referrer ?? null;\n\tnormalized.referrerPolicy = requestInit.referrerPolicy ?? null;\n\tnormalized.integrity = requestInit.integrity ?? null;\n\tnormalized.keepalive = requestInit.keepalive ?? false;\n\tnormalized.priority = requestInit.priority ?? null;\n\tnormalized.headers = headerEntries;\n\tnormalized.body = toBodyFingerprint(requestInit.body);\n\n\treturn normalized;\n}\n\nfunction normalizeTextureLoadOptions(options: TextureLoadOptions): NormalizedTextureLoadOptions {\n\tconst colorSpace = options.colorSpace ?? 'srgb';\n\n\tconst normalized: NormalizedTextureLoadOptions = {\n\t\tcolorSpace,\n\t\tdecode: {\n\t\t\tcolorSpaceConversion:\n\t\t\t\toptions.decode?.colorSpaceConversion ?? (colorSpace === 'linear' ? 'none' : 'default'),\n\t\t\tpremultiplyAlpha: options.decode?.premultiplyAlpha ?? 'default',\n\t\t\timageOrientation: options.decode?.imageOrientation ?? 'none'\n\t\t}\n\t};\n\n\tif (options.requestInit !== undefined) {\n\t\tnormalized.requestInit = options.requestInit;\n\t}\n\tif (options.signal !== undefined) {\n\t\tnormalized.signal = options.signal;\n\t}\n\tif (options.update !== undefined) {\n\t\tnormalized.update = options.update;\n\t}\n\tif (options.flipY !== undefined) {\n\t\tnormalized.flipY = options.flipY;\n\t}\n\tif (options.premultipliedAlpha !== undefined) {\n\t\tnormalized.premultipliedAlpha = options.premultipliedAlpha;\n\t}\n\tif (options.generateMipmaps !== undefined) {\n\t\tnormalized.generateMipmaps = options.generateMipmaps;\n\t}\n\n\treturn normalized;\n}\n\n/**\n * Builds deterministic resource cache key from full URL IO config.\n */\nexport function buildTextureResourceCacheKey(\n\turl: string,\n\toptions: TextureLoadOptions = {}\n): string {\n\tconst normalized = normalizeTextureLoadOptions(options);\n\treturn JSON.stringify({\n\t\turl,\n\t\tcolorSpace: normalized.colorSpace,\n\t\trequestInit: normalizeRequestInit(normalized.requestInit),\n\t\tdecode: normalized.decode\n\t});\n}\n\n/**\n * Clears the internal texture resource cache.\n */\nexport function clearTextureBlobCache(): void {\n\tfor (const entry of resourceCache.values()) {\n\t\tif (!entry.settled) {\n\t\t\tentry.controller.abort();\n\t\t}\n\t}\n\tresourceCache.clear();\n}\n\nfunction acquireTextureBlob(\n\turl: string,\n\toptions: TextureLoadOptions\n): {\n\tentry: TextureResourceCacheEntry;\n\trelease: () => void;\n} {\n\tconst key = buildTextureResourceCacheKey(url, options);\n\tconst existing = resourceCache.get(key);\n\tif (existing) {\n\t\texisting.refs += 1;\n\t\tlet released = false;\n\t\treturn {\n\t\t\tentry: existing,\n\t\t\trelease: () => {\n\t\t\t\tif (released) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\treleased = true;\n\t\t\t\texisting.refs = Math.max(0, existing.refs - 1);\n\t\t\t\tif (existing.refs === 0) {\n\t\t\t\t\tif (!existing.settled) {\n\t\t\t\t\t\texisting.controller.abort();\n\t\t\t\t\t}\n\t\t\t\t\tresourceCache.delete(key);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t}\n\n\tconst normalized = normalizeTextureLoadOptions(options);\n\tconst controller = new AbortController();\n\tconst requestInit = {\n\t\t...(normalized.requestInit ?? {}),\n\t\tsignal: controller.signal\n\t} satisfies RequestInit;\n\tconst entry: TextureResourceCacheEntry = {\n\t\tkey,\n\t\trefs: 1,\n\t\tcontroller,\n\t\tsettled: false,\n\t\tblobPromise: fetch(url, requestInit)\n\t\t\t.then(async (response) => {\n\t\t\t\tif (!response.ok) {\n\t\t\t\t\tthrow new Error(`Texture request failed (${response.status}) for ${url}`);\n\t\t\t\t}\n\t\t\t\treturn response.blob();\n\t\t\t})\n\t\t\t.then((blob) => {\n\t\t\t\tentry.settled = true;\n\t\t\t\treturn blob;\n\t\t\t})\n\t\t\t.catch((error) => {\n\t\t\t\tresourceCache.delete(key);\n\t\t\t\tthrow error;\n\t\t\t})\n\t};\n\n\tresourceCache.set(key, entry);\n\tlet released = false;\n\treturn {\n\t\tentry,\n\t\trelease: () => {\n\t\t\tif (released) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\treleased = true;\n\t\t\tentry.refs = Math.max(0, entry.refs - 1);\n\t\t\tif (entry.refs === 0) {\n\t\t\t\tif (!entry.settled) {\n\t\t\t\t\tentry.controller.abort();\n\t\t\t\t}\n\t\t\t\tresourceCache.delete(key);\n\t\t\t}\n\t\t}\n\t};\n}\n\nasync function awaitWithAbort<T>(promise: Promise<T>, signal: AbortSignal | undefined): Promise<T> {\n\tif (!signal) {\n\t\treturn promise;\n\t}\n\n\tif (signal.aborted) {\n\t\tthrow createAbortError();\n\t}\n\n\treturn new Promise<T>((resolve, reject) => {\n\t\tconst onAbort = (): void => {\n\t\t\treject(createAbortError());\n\t\t};\n\n\t\tsignal.addEventListener('abort', onAbort, { once: true });\n\n\t\tpromise.then(resolve, reject).finally(() => {\n\t\t\tsignal.removeEventListener('abort', onAbort);\n\t\t});\n\t});\n}\n\n/**\n * Loads a single texture from URL and converts it to an `ImageBitmap`.\n *\n * @param url - Texture URL.\n * @param options - Loading options.\n * @returns Loaded texture object.\n * @throws {Error} When runtime does not support `createImageBitmap` or request fails.\n */\nexport async function loadTextureFromUrl(\n\turl: string,\n\toptions: TextureLoadOptions = {}\n): Promise<LoadedTexture> {\n\tif (typeof createImageBitmap !== 'function') {\n\t\tthrow new Error('createImageBitmap is not available in this runtime');\n\t}\n\n\tconst normalized = normalizeTextureLoadOptions(options);\n\tconst { entry, release } = acquireTextureBlob(url, options);\n\tlet bitmap: ImageBitmap | null = null;\n\n\ttry {\n\t\tconst blob = await awaitWithAbort(entry.blobPromise, normalized.signal);\n\n\t\tconst bitmapOptions: ImageBitmapOptions = {\n\t\t\tcolorSpaceConversion: normalized.decode.colorSpaceConversion,\n\t\t\tpremultiplyAlpha: normalized.decode.premultiplyAlpha,\n\t\t\timageOrientation: normalized.decode.imageOrientation\n\t\t};\n\t\tconst allDefaults =\n\t\t\tbitmapOptions.colorSpaceConversion === 'default' &&\n\t\t\tbitmapOptions.premultiplyAlpha === 'default' &&\n\t\t\tbitmapOptions.imageOrientation === 'none';\n\n\t\tbitmap = allDefaults\n\t\t\t? await createImageBitmap(blob)\n\t\t\t: await createImageBitmap(blob, bitmapOptions);\n\n\t\tif (normalized.signal?.aborted) {\n\t\t\tbitmap.close();\n\t\t\tthrow createAbortError();\n\t\t}\n\n\t\tconst loaded: LoadedTexture = {\n\t\t\turl,\n\t\t\tsource: bitmap,\n\t\t\twidth: bitmap.width,\n\t\t\theight: bitmap.height,\n\t\t\tcolorSpace: normalized.colorSpace,\n\t\t\tdispose: () => {\n\t\t\t\tbitmap?.close();\n\t\t\t}\n\t\t};\n\n\t\tif (normalized.update !== undefined) {\n\t\t\tloaded.update = normalized.update;\n\t\t}\n\t\tif (normalized.flipY !== undefined) {\n\t\t\tloaded.flipY = normalized.flipY;\n\t\t}\n\t\tif (normalized.premultipliedAlpha !== undefined) {\n\t\t\tloaded.premultipliedAlpha = normalized.premultipliedAlpha;\n\t\t}\n\t\tif (normalized.generateMipmaps !== undefined) {\n\t\t\tloaded.generateMipmaps = normalized.generateMipmaps;\n\t\t}\n\n\t\treturn loaded;\n\t} catch (error) {\n\t\tif (bitmap) {\n\t\t\tbitmap.close();\n\t\t}\n\t\tthrow error;\n\t} finally {\n\t\trelease();\n\t}\n}\n\n/**\n * Loads many textures in parallel from URLs.\n *\n * @param urls - Texture URLs.\n * @param options - Shared loading options.\n * @returns Promise resolving to loaded textures in input order.\n */\nexport async function loadTexturesFromUrls(\n\turls: string[],\n\toptions: TextureLoadOptions = {}\n): Promise<LoadedTexture[]> {\n\tconst settled = await Promise.allSettled(urls.map((url) => loadTextureFromUrl(url, options)));\n\tconst loaded: LoadedTexture[] = [];\n\tlet firstError: unknown = null;\n\n\tfor (const entry of settled) {\n\t\tif (entry.status === 'fulfilled') {\n\t\t\tloaded.push(entry.value);\n\t\t\tcontinue;\n\t\t}\n\n\t\tfirstError ??= entry.reason;\n\t}\n\n\tif (firstError) {\n\t\tfor (const texture of loaded) {\n\t\t\ttexture.dispose();\n\t\t}\n\t\tthrow firstError;\n\t}\n\n\treturn loaded;\n}\n"],"mappings":";AA2HA,IAAM,gCAAgB,IAAI,KAAwC;AAElE,SAAS,mBAA0B;AAClC,KAAI;AACH,SAAO,IAAI,aAAa,+BAA+B,aAAa;SAC7D;EACP,MAAM,wBAAQ,IAAI,MAAM,8BAA8B;AACrD,QAAmC,OAAO;AAC3C,SAAO;;;;;;AAOT,SAAgB,aAAa,OAAyB;AACrD,QACC,iBAAiB,UAChB,MAAM,SAAS,gBAAgB,MAAM,QAAQ,aAAa,CAAC,SAAS,UAAU;;AAIjF,SAAS,kBAA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;AAGP,QAAO"}
@@ -113,3 +113,4 @@ export declare function getTextureMipLevelCount(width: number, height: number):
113
113
  * Checks whether the source is an `HTMLVideoElement`.
114
114
  */
115
115
  export declare function isVideoTextureSource(source: TextureData['source']): source is HTMLVideoElement;
116
+ //# sourceMappingURL=textures.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"textures.d.ts","sourceRoot":"","sources":["../../src/lib/core/textures.ts"],"names":[],"mappings":";AACA,OAAO,KAAK,EACX,WAAW,EACX,iBAAiB,EACjB,oBAAoB,EACpB,iBAAiB,EACjB,YAAY,EACZ,MAAM,YAAY,CAAC;AAEpB;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC3C;;OAEG;IACH,MAAM,EAAE,YAAY,CAAC;IACrB;;OAEG;IACH,UAAU,EAAE,MAAM,GAAG,QAAQ,CAAC;IAC9B;;OAEG;IACH,MAAM,EAAE,gBAAgB,CAAC;IACzB;;OAEG;IACH,KAAK,EAAE,OAAO,CAAC;IACf;;OAEG;IACH,eAAe,EAAE,OAAO,CAAC;IACzB;;OAEG;IACH,kBAAkB,EAAE,OAAO,CAAC;IAC5B;;OAEG;IACH,MAAM,CAAC,EAAE,iBAAiB,CAAC;IAC3B;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,MAAM,EAAE,aAAa,CAAC;IACtB;;OAEG;IACH,YAAY,EAAE,cAAc,CAAC;IAC7B;;OAEG;IACH,YAAY,EAAE,cAAc,CAAC;CAC7B;AAYD;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,oBAAoB,GAAG,MAAM,EAAE,CAM3E;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CACzC,UAAU,EAAE,iBAAiB,GAAG,SAAS,GACvC,2BAA2B,CAmB7B;AAED;;;;;;GAMG;AACH,wBAAgB,2BAA2B,CAC1C,QAAQ,EAAE,oBAAoB,EAC9B,WAAW,EAAE,MAAM,EAAE,GACnB,MAAM,CAAC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