@motion-core/motion-gpu 0.4.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (228) hide show
  1. package/README.md +99 -0
  2. package/dist/advanced.d.ts +1 -0
  3. package/dist/advanced.d.ts.map +1 -0
  4. package/dist/advanced.js +14 -6
  5. package/dist/core/advanced.d.ts +1 -0
  6. package/dist/core/advanced.d.ts.map +1 -0
  7. package/dist/core/advanced.js +14 -5
  8. package/dist/core/compute-shader.d.ts +87 -0
  9. package/dist/core/compute-shader.d.ts.map +1 -0
  10. package/dist/core/compute-shader.js +205 -0
  11. package/dist/core/compute-shader.js.map +1 -0
  12. package/dist/core/current-value.d.ts +1 -0
  13. package/dist/core/current-value.d.ts.map +1 -0
  14. package/dist/core/current-value.js +35 -34
  15. package/dist/core/current-value.js.map +1 -0
  16. package/dist/core/error-diagnostics.d.ts +1 -0
  17. package/dist/core/error-diagnostics.d.ts.map +1 -0
  18. package/dist/core/error-diagnostics.js +70 -137
  19. package/dist/core/error-diagnostics.js.map +1 -0
  20. package/dist/core/error-report.d.ts +2 -1
  21. package/dist/core/error-report.d.ts.map +1 -0
  22. package/dist/core/error-report.js +247 -233
  23. package/dist/core/error-report.js.map +1 -0
  24. package/dist/core/frame-registry.d.ts +1 -0
  25. package/dist/core/frame-registry.d.ts.map +1 -0
  26. package/dist/core/frame-registry.js +546 -662
  27. package/dist/core/frame-registry.js.map +1 -0
  28. package/dist/core/index.d.ts +6 -2
  29. package/dist/core/index.d.ts.map +1 -0
  30. package/dist/core/index.js +13 -12
  31. package/dist/core/material-preprocess.d.ts +1 -0
  32. package/dist/core/material-preprocess.d.ts.map +1 -0
  33. package/dist/core/material-preprocess.js +131 -152
  34. package/dist/core/material-preprocess.js.map +1 -0
  35. package/dist/core/material.d.ts +23 -6
  36. package/dist/core/material.d.ts.map +1 -0
  37. package/dist/core/material.js +290 -317
  38. package/dist/core/material.js.map +1 -0
  39. package/dist/core/recompile-policy.d.ts +1 -0
  40. package/dist/core/recompile-policy.d.ts.map +1 -0
  41. package/dist/core/recompile-policy.js +18 -13
  42. package/dist/core/recompile-policy.js.map +1 -0
  43. package/dist/core/render-graph.d.ts +8 -3
  44. package/dist/core/render-graph.d.ts.map +1 -0
  45. package/dist/core/render-graph.js +77 -68
  46. package/dist/core/render-graph.js.map +1 -0
  47. package/dist/core/render-targets.d.ts +1 -0
  48. package/dist/core/render-targets.d.ts.map +1 -0
  49. package/dist/core/render-targets.js +52 -53
  50. package/dist/core/render-targets.js.map +1 -0
  51. package/dist/core/renderer.d.ts +1 -0
  52. package/dist/core/renderer.d.ts.map +1 -0
  53. package/dist/core/renderer.js +1337 -1081
  54. package/dist/core/renderer.js.map +1 -0
  55. package/dist/core/runtime-loop.d.ts +3 -2
  56. package/dist/core/runtime-loop.d.ts.map +1 -0
  57. package/dist/core/runtime-loop.js +353 -362
  58. package/dist/core/runtime-loop.js.map +1 -0
  59. package/dist/core/scheduler-helpers.d.ts +1 -0
  60. package/dist/core/scheduler-helpers.d.ts.map +1 -0
  61. package/dist/core/scheduler-helpers.js +52 -51
  62. package/dist/core/scheduler-helpers.js.map +1 -0
  63. package/dist/core/shader.d.ts +10 -1
  64. package/dist/core/shader.d.ts.map +1 -0
  65. package/dist/core/shader.js +109 -115
  66. package/dist/core/shader.js.map +1 -0
  67. package/dist/core/storage-buffers.d.ts +37 -0
  68. package/dist/core/storage-buffers.d.ts.map +1 -0
  69. package/dist/core/storage-buffers.js +95 -0
  70. package/dist/core/storage-buffers.js.map +1 -0
  71. package/dist/core/texture-loader.d.ts +1 -0
  72. package/dist/core/texture-loader.d.ts.map +1 -0
  73. package/dist/core/texture-loader.js +209 -273
  74. package/dist/core/texture-loader.js.map +1 -0
  75. package/dist/core/textures.d.ts +13 -0
  76. package/dist/core/textures.d.ts.map +1 -0
  77. package/dist/core/textures.js +111 -116
  78. package/dist/core/textures.js.map +1 -0
  79. package/dist/core/types.d.ts +147 -4
  80. package/dist/core/types.d.ts.map +1 -0
  81. package/dist/core/types.js +0 -4
  82. package/dist/core/uniforms.d.ts +1 -0
  83. package/dist/core/uniforms.d.ts.map +1 -0
  84. package/dist/core/uniforms.js +170 -191
  85. package/dist/core/uniforms.js.map +1 -0
  86. package/dist/index.d.ts +1 -0
  87. package/dist/index.d.ts.map +1 -0
  88. package/dist/index.js +13 -6
  89. package/dist/passes/BlitPass.d.ts +1 -0
  90. package/dist/passes/BlitPass.d.ts.map +1 -0
  91. package/dist/passes/BlitPass.js +23 -18
  92. package/dist/passes/BlitPass.js.map +1 -0
  93. package/dist/passes/ComputePass.d.ts +83 -0
  94. package/dist/passes/ComputePass.d.ts.map +1 -0
  95. package/dist/passes/ComputePass.js +92 -0
  96. package/dist/passes/ComputePass.js.map +1 -0
  97. package/dist/passes/CopyPass.d.ts +1 -0
  98. package/dist/passes/CopyPass.d.ts.map +1 -0
  99. package/dist/passes/CopyPass.js +58 -52
  100. package/dist/passes/CopyPass.js.map +1 -0
  101. package/dist/passes/FullscreenPass.d.ts +1 -0
  102. package/dist/passes/FullscreenPass.d.ts.map +1 -0
  103. package/dist/passes/FullscreenPass.js +127 -130
  104. package/dist/passes/FullscreenPass.js.map +1 -0
  105. package/dist/passes/PingPongComputePass.d.ts +104 -0
  106. package/dist/passes/PingPongComputePass.d.ts.map +1 -0
  107. package/dist/passes/PingPongComputePass.js +132 -0
  108. package/dist/passes/PingPongComputePass.js.map +1 -0
  109. package/dist/passes/ShaderPass.d.ts +1 -0
  110. package/dist/passes/ShaderPass.d.ts.map +1 -0
  111. package/dist/passes/ShaderPass.js +41 -37
  112. package/dist/passes/ShaderPass.js.map +1 -0
  113. package/dist/passes/index.d.ts +3 -0
  114. package/dist/passes/index.d.ts.map +1 -0
  115. package/dist/passes/index.js +6 -3
  116. package/dist/react/FragCanvas.d.ts +3 -2
  117. package/dist/react/FragCanvas.d.ts.map +1 -0
  118. package/dist/react/FragCanvas.js +234 -211
  119. package/dist/react/FragCanvas.js.map +1 -0
  120. package/dist/react/MotionGPUErrorOverlay.d.ts +1 -0
  121. package/dist/react/MotionGPUErrorOverlay.d.ts.map +1 -0
  122. package/dist/react/MotionGPUErrorOverlay.js +200 -14
  123. package/dist/react/MotionGPUErrorOverlay.js.map +1 -0
  124. package/dist/react/Portal.d.ts +1 -0
  125. package/dist/react/Portal.d.ts.map +1 -0
  126. package/dist/react/Portal.js +18 -21
  127. package/dist/react/Portal.js.map +1 -0
  128. package/dist/react/advanced.d.ts +1 -0
  129. package/dist/react/advanced.d.ts.map +1 -0
  130. package/dist/react/advanced.js +14 -6
  131. package/dist/react/frame-context.d.ts +1 -0
  132. package/dist/react/frame-context.d.ts.map +1 -0
  133. package/dist/react/frame-context.js +88 -94
  134. package/dist/react/frame-context.js.map +1 -0
  135. package/dist/react/index.d.ts +6 -2
  136. package/dist/react/index.d.ts.map +1 -0
  137. package/dist/react/index.js +12 -9
  138. package/dist/react/motiongpu-context.d.ts +1 -0
  139. package/dist/react/motiongpu-context.d.ts.map +1 -0
  140. package/dist/react/motiongpu-context.js +18 -15
  141. package/dist/react/motiongpu-context.js.map +1 -0
  142. package/dist/react/use-motiongpu-user-context.d.ts +1 -0
  143. package/dist/react/use-motiongpu-user-context.d.ts.map +1 -0
  144. package/dist/react/use-motiongpu-user-context.js +83 -82
  145. package/dist/react/use-motiongpu-user-context.js.map +1 -0
  146. package/dist/react/use-texture.d.ts +1 -0
  147. package/dist/react/use-texture.d.ts.map +1 -0
  148. package/dist/react/use-texture.js +132 -152
  149. package/dist/react/use-texture.js.map +1 -0
  150. package/dist/svelte/FragCanvas.svelte +2 -2
  151. package/dist/svelte/FragCanvas.svelte.d.ts +3 -2
  152. package/dist/svelte/FragCanvas.svelte.d.ts.map +1 -0
  153. package/dist/svelte/MotionGPUErrorOverlay.svelte +137 -7
  154. package/dist/svelte/MotionGPUErrorOverlay.svelte.d.ts +1 -0
  155. package/dist/svelte/MotionGPUErrorOverlay.svelte.d.ts.map +1 -0
  156. package/dist/svelte/Portal.svelte.d.ts +1 -0
  157. package/dist/svelte/Portal.svelte.d.ts.map +1 -0
  158. package/dist/svelte/advanced.d.ts +1 -0
  159. package/dist/svelte/advanced.d.ts.map +1 -0
  160. package/dist/svelte/advanced.js +13 -6
  161. package/dist/svelte/frame-context.d.ts +1 -0
  162. package/dist/svelte/frame-context.d.ts.map +1 -0
  163. package/dist/svelte/frame-context.js +27 -27
  164. package/dist/svelte/frame-context.js.map +1 -0
  165. package/dist/svelte/index.d.ts +6 -2
  166. package/dist/svelte/index.d.ts.map +1 -0
  167. package/dist/svelte/index.js +12 -9
  168. package/dist/svelte/motiongpu-context.d.ts +1 -0
  169. package/dist/svelte/motiongpu-context.d.ts.map +1 -0
  170. package/dist/svelte/motiongpu-context.js +24 -21
  171. package/dist/svelte/motiongpu-context.js.map +1 -0
  172. package/dist/svelte/use-motiongpu-user-context.d.ts +1 -0
  173. package/dist/svelte/use-motiongpu-user-context.d.ts.map +1 -0
  174. package/dist/svelte/use-motiongpu-user-context.js +69 -70
  175. package/dist/svelte/use-motiongpu-user-context.js.map +1 -0
  176. package/dist/svelte/use-texture.d.ts +1 -0
  177. package/dist/svelte/use-texture.d.ts.map +1 -0
  178. package/dist/svelte/use-texture.js +125 -147
  179. package/dist/svelte/use-texture.js.map +1 -0
  180. package/package.json +12 -7
  181. package/src/lib/advanced.ts +6 -0
  182. package/src/lib/core/advanced.ts +12 -0
  183. package/src/lib/core/compute-shader.ts +326 -0
  184. package/src/lib/core/current-value.ts +64 -0
  185. package/src/lib/core/error-diagnostics.ts +236 -0
  186. package/src/lib/core/error-report.ts +535 -0
  187. package/src/lib/core/frame-registry.ts +1190 -0
  188. package/src/lib/core/index.ts +94 -0
  189. package/src/lib/core/material-preprocess.ts +295 -0
  190. package/src/lib/core/material.ts +748 -0
  191. package/src/lib/core/recompile-policy.ts +31 -0
  192. package/src/lib/core/render-graph.ts +173 -0
  193. package/src/lib/core/render-targets.ts +107 -0
  194. package/src/lib/core/renderer.ts +2161 -0
  195. package/src/lib/core/runtime-loop.ts +537 -0
  196. package/src/lib/core/scheduler-helpers.ts +136 -0
  197. package/src/lib/core/shader.ts +301 -0
  198. package/src/lib/core/storage-buffers.ts +142 -0
  199. package/src/lib/core/texture-loader.ts +482 -0
  200. package/src/lib/core/textures.ts +257 -0
  201. package/src/lib/core/types.ts +743 -0
  202. package/src/lib/core/uniforms.ts +282 -0
  203. package/src/lib/index.ts +6 -0
  204. package/src/lib/passes/BlitPass.ts +54 -0
  205. package/src/lib/passes/ComputePass.ts +136 -0
  206. package/src/lib/passes/CopyPass.ts +80 -0
  207. package/src/lib/passes/FullscreenPass.ts +173 -0
  208. package/src/lib/passes/PingPongComputePass.ts +180 -0
  209. package/src/lib/passes/ShaderPass.ts +89 -0
  210. package/src/lib/passes/index.ts +9 -0
  211. package/src/lib/react/FragCanvas.tsx +345 -0
  212. package/src/lib/react/MotionGPUErrorOverlay.tsx +524 -0
  213. package/src/lib/react/Portal.tsx +34 -0
  214. package/src/lib/react/advanced.ts +36 -0
  215. package/src/lib/react/frame-context.ts +169 -0
  216. package/src/lib/react/index.ts +68 -0
  217. package/src/lib/react/motiongpu-context.ts +88 -0
  218. package/src/lib/react/use-motiongpu-user-context.ts +186 -0
  219. package/src/lib/react/use-texture.ts +233 -0
  220. package/src/lib/svelte/FragCanvas.svelte +249 -0
  221. package/src/lib/svelte/MotionGPUErrorOverlay.svelte +512 -0
  222. package/src/lib/svelte/Portal.svelte +31 -0
  223. package/src/lib/svelte/advanced.ts +32 -0
  224. package/src/lib/svelte/frame-context.ts +87 -0
  225. package/src/lib/svelte/index.ts +68 -0
  226. package/src/lib/svelte/motiongpu-context.ts +97 -0
  227. package/src/lib/svelte/use-motiongpu-user-context.ts +145 -0
  228. package/src/lib/svelte/use-texture.ts +232 -0
@@ -1,151 +1,84 @@
1
+ //#region src/lib/core/error-diagnostics.ts
1
2
  function isMaterialSourceMetadata(value) {
2
- if (value === null || typeof value !== 'object') {
3
- return false;
4
- }
5
- const record = value;
6
- if (record.component !== undefined && typeof record.component !== 'string') {
7
- return false;
8
- }
9
- if (record.file !== undefined && typeof record.file !== 'string') {
10
- return false;
11
- }
12
- if (record.functionName !== undefined && typeof record.functionName !== 'string') {
13
- return false;
14
- }
15
- if (record.line !== undefined && typeof record.line !== 'number') {
16
- return false;
17
- }
18
- if (record.column !== undefined && typeof record.column !== 'number') {
19
- return false;
20
- }
21
- return true;
3
+ if (value === null || typeof value !== "object") return false;
4
+ const record = value;
5
+ if (record.component !== void 0 && typeof record.component !== "string") return false;
6
+ if (record.file !== void 0 && typeof record.file !== "string") return false;
7
+ if (record.functionName !== void 0 && typeof record.functionName !== "string") return false;
8
+ if (record.line !== void 0 && typeof record.line !== "number") return false;
9
+ if (record.column !== void 0 && typeof record.column !== "number") return false;
10
+ return true;
22
11
  }
23
12
  function isMaterialSourceLocation(value) {
24
- if (value === null) {
25
- return true;
26
- }
27
- if (typeof value !== 'object') {
28
- return false;
29
- }
30
- const record = value;
31
- const kind = record.kind;
32
- if (kind !== 'fragment' && kind !== 'include' && kind !== 'define') {
33
- return false;
34
- }
35
- return typeof record.line === 'number';
13
+ if (value === null) return true;
14
+ if (typeof value !== "object") return false;
15
+ const record = value;
16
+ const kind = record.kind;
17
+ if (kind !== "fragment" && kind !== "include" && kind !== "define") return false;
18
+ return typeof record.line === "number";
36
19
  }
37
20
  function isShaderCompilationDiagnostic(value) {
38
- if (value === null || typeof value !== 'object') {
39
- return false;
40
- }
41
- const record = value;
42
- if (typeof record.generatedLine !== 'number') {
43
- return false;
44
- }
45
- if (typeof record.message !== 'string') {
46
- return false;
47
- }
48
- if (record.linePos !== undefined && typeof record.linePos !== 'number') {
49
- return false;
50
- }
51
- if (record.lineLength !== undefined && typeof record.lineLength !== 'number') {
52
- return false;
53
- }
54
- if (!isMaterialSourceLocation(record.sourceLocation)) {
55
- return false;
56
- }
57
- return true;
21
+ if (value === null || typeof value !== "object") return false;
22
+ const record = value;
23
+ if (typeof record.generatedLine !== "number") return false;
24
+ if (typeof record.message !== "string") return false;
25
+ if (record.linePos !== void 0 && typeof record.linePos !== "number") return false;
26
+ if (record.lineLength !== void 0 && typeof record.lineLength !== "number") return false;
27
+ if (!isMaterialSourceLocation(record.sourceLocation)) return false;
28
+ return true;
58
29
  }
59
30
  function isStringArray(value) {
60
- return Array.isArray(value) && value.every((entry) => typeof entry === 'string');
31
+ return Array.isArray(value) && value.every((entry) => typeof entry === "string");
61
32
  }
62
33
  function isShaderCompilationRuntimeContext(value) {
63
- if (value === null || typeof value !== 'object') {
64
- return false;
65
- }
66
- const record = value;
67
- if (record.materialSignature !== undefined && typeof record.materialSignature !== 'string') {
68
- return false;
69
- }
70
- if (!isStringArray(record.activeRenderTargets)) {
71
- return false;
72
- }
73
- const passGraph = record.passGraph;
74
- if (passGraph === undefined) {
75
- return true;
76
- }
77
- if (passGraph === null || typeof passGraph !== 'object') {
78
- return false;
79
- }
80
- const passGraphRecord = passGraph;
81
- if (typeof passGraphRecord.passCount !== 'number') {
82
- return false;
83
- }
84
- if (typeof passGraphRecord.enabledPassCount !== 'number') {
85
- return false;
86
- }
87
- if (!isStringArray(passGraphRecord.inputs) || !isStringArray(passGraphRecord.outputs)) {
88
- return false;
89
- }
90
- return true;
34
+ if (value === null || typeof value !== "object") return false;
35
+ const record = value;
36
+ if (record.materialSignature !== void 0 && typeof record.materialSignature !== "string") return false;
37
+ if (!isStringArray(record.activeRenderTargets)) return false;
38
+ const passGraph = record.passGraph;
39
+ if (passGraph === void 0) return true;
40
+ if (passGraph === null || typeof passGraph !== "object") return false;
41
+ const passGraphRecord = passGraph;
42
+ if (typeof passGraphRecord.passCount !== "number") return false;
43
+ if (typeof passGraphRecord.enabledPassCount !== "number") return false;
44
+ if (!isStringArray(passGraphRecord.inputs) || !isStringArray(passGraphRecord.outputs)) return false;
45
+ return true;
91
46
  }
92
47
  /**
93
- * Attaches structured diagnostics payload to an Error.
94
- */
95
- export function attachShaderCompilationDiagnostics(error, payload) {
96
- error.motiongpuDiagnostics = payload;
97
- return error;
48
+ * Attaches structured diagnostics payload to an Error.
49
+ */
50
+ function attachShaderCompilationDiagnostics(error, payload) {
51
+ error.motiongpuDiagnostics = payload;
52
+ return error;
98
53
  }
99
54
  /**
100
- * Extracts structured diagnostics payload from unknown error value.
101
- */
102
- export function getShaderCompilationDiagnostics(error) {
103
- if (!(error instanceof Error)) {
104
- return null;
105
- }
106
- const payload = error.motiongpuDiagnostics;
107
- if (payload === null || typeof payload !== 'object') {
108
- return null;
109
- }
110
- const record = payload;
111
- if (record.kind !== 'shader-compilation') {
112
- return null;
113
- }
114
- if (!Array.isArray(record.diagnostics) ||
115
- !record.diagnostics.every(isShaderCompilationDiagnostic)) {
116
- return null;
117
- }
118
- if (typeof record.fragmentSource !== 'string') {
119
- return null;
120
- }
121
- if (record.defineBlockSource !== undefined && typeof record.defineBlockSource !== 'string') {
122
- return null;
123
- }
124
- if (record.includeSources === null || typeof record.includeSources !== 'object') {
125
- return null;
126
- }
127
- const includeSources = record.includeSources;
128
- if (Object.values(includeSources).some((value) => typeof value !== 'string')) {
129
- return null;
130
- }
131
- if (record.materialSource !== null && !isMaterialSourceMetadata(record.materialSource)) {
132
- return null;
133
- }
134
- if (record.runtimeContext !== undefined &&
135
- !isShaderCompilationRuntimeContext(record.runtimeContext)) {
136
- return null;
137
- }
138
- return {
139
- kind: 'shader-compilation',
140
- diagnostics: record.diagnostics,
141
- fragmentSource: record.fragmentSource,
142
- includeSources: includeSources,
143
- ...(record.defineBlockSource !== undefined
144
- ? { defineBlockSource: record.defineBlockSource }
145
- : {}),
146
- materialSource: (record.materialSource ?? null),
147
- ...(record.runtimeContext !== undefined
148
- ? { runtimeContext: record.runtimeContext }
149
- : {})
150
- };
55
+ * Extracts structured diagnostics payload from unknown error value.
56
+ */
57
+ function getShaderCompilationDiagnostics(error) {
58
+ if (!(error instanceof Error)) return null;
59
+ const payload = error.motiongpuDiagnostics;
60
+ if (payload === null || typeof payload !== "object") return null;
61
+ const record = payload;
62
+ if (record.kind !== "shader-compilation") return null;
63
+ if (!Array.isArray(record.diagnostics) || !record.diagnostics.every(isShaderCompilationDiagnostic)) return null;
64
+ if (typeof record.fragmentSource !== "string") return null;
65
+ if (record.defineBlockSource !== void 0 && typeof record.defineBlockSource !== "string") return null;
66
+ if (record.includeSources === null || typeof record.includeSources !== "object") return null;
67
+ const includeSources = record.includeSources;
68
+ if (Object.values(includeSources).some((value) => typeof value !== "string")) return null;
69
+ if (record.materialSource !== null && !isMaterialSourceMetadata(record.materialSource)) return null;
70
+ if (record.runtimeContext !== void 0 && !isShaderCompilationRuntimeContext(record.runtimeContext)) return null;
71
+ return {
72
+ kind: "shader-compilation",
73
+ diagnostics: record.diagnostics,
74
+ fragmentSource: record.fragmentSource,
75
+ includeSources,
76
+ ...record.defineBlockSource !== void 0 ? { defineBlockSource: record.defineBlockSource } : {},
77
+ materialSource: record.materialSource ?? null,
78
+ ...record.runtimeContext !== void 0 ? { runtimeContext: record.runtimeContext } : {}
79
+ };
151
80
  }
81
+ //#endregion
82
+ export { attachShaderCompilationDiagnostics, getShaderCompilationDiagnostics };
83
+
84
+ //# sourceMappingURL=error-diagnostics.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-diagnostics.js","names":[],"sources":["../../src/lib/core/error-diagnostics.ts"],"sourcesContent":["import type { MaterialSourceLocation } from './material-preprocess.js';\n\n/**\n * Source metadata for material declaration callsite.\n */\nexport interface MaterialSourceMetadata {\n\tcomponent?: string;\n\tfile?: string;\n\tline?: number;\n\tcolumn?: number;\n\tfunctionName?: string;\n}\n\n/**\n * One WGSL compiler diagnostic enriched with source-location metadata.\n */\nexport interface ShaderCompilationDiagnostic {\n\tgeneratedLine: number;\n\tmessage: string;\n\tlinePos?: number;\n\tlineLength?: number;\n\tsourceLocation: MaterialSourceLocation | null;\n}\n\n/**\n * Runtime context snapshot captured for shader compilation diagnostics.\n */\nexport interface ShaderCompilationRuntimeContext {\n\tmaterialSignature?: string;\n\tpassGraph?: {\n\t\tpassCount: number;\n\t\tenabledPassCount: number;\n\t\tinputs: string[];\n\t\toutputs: string[];\n\t};\n\tactiveRenderTargets: string[];\n}\n\n/**\n * Structured payload attached to WGSL compilation errors.\n */\nexport interface ShaderCompilationDiagnosticsPayload {\n\tkind: 'shader-compilation';\n\tdiagnostics: ShaderCompilationDiagnostic[];\n\tfragmentSource: string;\n\tincludeSources: Record<string, string>;\n\tdefineBlockSource?: string;\n\tmaterialSource: MaterialSourceMetadata | null;\n\truntimeContext?: ShaderCompilationRuntimeContext;\n}\n\ntype MotionGPUErrorWithDiagnostics = Error & {\n\tmotiongpuDiagnostics?: unknown;\n};\n\nfunction isMaterialSourceMetadata(value: unknown): value is MaterialSourceMetadata {\n\tif (value === null || typeof value !== 'object') {\n\t\treturn false;\n\t}\n\n\tconst record = value as Record<string, unknown>;\n\tif (record.component !== undefined && typeof record.component !== 'string') {\n\t\treturn false;\n\t}\n\tif (record.file !== undefined && typeof record.file !== 'string') {\n\t\treturn false;\n\t}\n\tif (record.functionName !== undefined && typeof record.functionName !== 'string') {\n\t\treturn false;\n\t}\n\tif (record.line !== undefined && typeof record.line !== 'number') {\n\t\treturn false;\n\t}\n\tif (record.column !== undefined && typeof record.column !== 'number') {\n\t\treturn false;\n\t}\n\n\treturn true;\n}\n\nfunction isMaterialSourceLocation(value: unknown): value is MaterialSourceLocation | null {\n\tif (value === null) {\n\t\treturn true;\n\t}\n\n\tif (typeof value !== 'object') {\n\t\treturn false;\n\t}\n\n\tconst record = value as Record<string, unknown>;\n\tconst kind = record.kind;\n\tif (kind !== 'fragment' && kind !== 'include' && kind !== 'define') {\n\t\treturn false;\n\t}\n\n\treturn typeof record.line === 'number';\n}\n\nfunction isShaderCompilationDiagnostic(value: unknown): value is ShaderCompilationDiagnostic {\n\tif (value === null || typeof value !== 'object') {\n\t\treturn false;\n\t}\n\n\tconst record = value as Record<string, unknown>;\n\tif (typeof record.generatedLine !== 'number') {\n\t\treturn false;\n\t}\n\tif (typeof record.message !== 'string') {\n\t\treturn false;\n\t}\n\tif (record.linePos !== undefined && typeof record.linePos !== 'number') {\n\t\treturn false;\n\t}\n\tif (record.lineLength !== undefined && typeof record.lineLength !== 'number') {\n\t\treturn false;\n\t}\n\tif (!isMaterialSourceLocation(record.sourceLocation)) {\n\t\treturn false;\n\t}\n\n\treturn true;\n}\n\nfunction isStringArray(value: unknown): value is string[] {\n\treturn Array.isArray(value) && value.every((entry) => typeof entry === 'string');\n}\n\nfunction isShaderCompilationRuntimeContext(\n\tvalue: unknown\n): value is ShaderCompilationRuntimeContext {\n\tif (value === null || typeof value !== 'object') {\n\t\treturn false;\n\t}\n\n\tconst record = value as Record<string, unknown>;\n\tif (record.materialSignature !== undefined && typeof record.materialSignature !== 'string') {\n\t\treturn false;\n\t}\n\tif (!isStringArray(record.activeRenderTargets)) {\n\t\treturn false;\n\t}\n\tconst passGraph = record.passGraph;\n\tif (passGraph === undefined) {\n\t\treturn true;\n\t}\n\tif (passGraph === null || typeof passGraph !== 'object') {\n\t\treturn false;\n\t}\n\n\tconst passGraphRecord = passGraph as Record<string, unknown>;\n\tif (typeof passGraphRecord.passCount !== 'number') {\n\t\treturn false;\n\t}\n\tif (typeof passGraphRecord.enabledPassCount !== 'number') {\n\t\treturn false;\n\t}\n\tif (!isStringArray(passGraphRecord.inputs) || !isStringArray(passGraphRecord.outputs)) {\n\t\treturn false;\n\t}\n\n\treturn true;\n}\n\n/**\n * Attaches structured diagnostics payload to an Error.\n */\nexport function attachShaderCompilationDiagnostics(\n\terror: Error,\n\tpayload: ShaderCompilationDiagnosticsPayload\n): Error {\n\t(error as MotionGPUErrorWithDiagnostics).motiongpuDiagnostics = payload;\n\treturn error;\n}\n\n/**\n * Extracts structured diagnostics payload from unknown error value.\n */\nexport function getShaderCompilationDiagnostics(\n\terror: unknown\n): ShaderCompilationDiagnosticsPayload | null {\n\tif (!(error instanceof Error)) {\n\t\treturn null;\n\t}\n\n\tconst payload = (error as MotionGPUErrorWithDiagnostics).motiongpuDiagnostics;\n\tif (payload === null || typeof payload !== 'object') {\n\t\treturn null;\n\t}\n\n\tconst record = payload as Record<string, unknown>;\n\tif (record.kind !== 'shader-compilation') {\n\t\treturn null;\n\t}\n\tif (\n\t\t!Array.isArray(record.diagnostics) ||\n\t\t!record.diagnostics.every(isShaderCompilationDiagnostic)\n\t) {\n\t\treturn null;\n\t}\n\tif (typeof record.fragmentSource !== 'string') {\n\t\treturn null;\n\t}\n\tif (record.defineBlockSource !== undefined && typeof record.defineBlockSource !== 'string') {\n\t\treturn null;\n\t}\n\tif (record.includeSources === null || typeof record.includeSources !== 'object') {\n\t\treturn null;\n\t}\n\tconst includeSources = record.includeSources as Record<string, unknown>;\n\tif (Object.values(includeSources).some((value) => typeof value !== 'string')) {\n\t\treturn null;\n\t}\n\tif (record.materialSource !== null && !isMaterialSourceMetadata(record.materialSource)) {\n\t\treturn null;\n\t}\n\tif (\n\t\trecord.runtimeContext !== undefined &&\n\t\t!isShaderCompilationRuntimeContext(record.runtimeContext)\n\t) {\n\t\treturn null;\n\t}\n\n\treturn {\n\t\tkind: 'shader-compilation',\n\t\tdiagnostics: record.diagnostics as ShaderCompilationDiagnostic[],\n\t\tfragmentSource: record.fragmentSource,\n\t\tincludeSources: includeSources as Record<string, string>,\n\t\t...(record.defineBlockSource !== undefined\n\t\t\t? { defineBlockSource: record.defineBlockSource as string }\n\t\t\t: {}),\n\t\tmaterialSource: (record.materialSource ?? null) as MaterialSourceMetadata | null,\n\t\t...(record.runtimeContext !== undefined\n\t\t\t? { runtimeContext: record.runtimeContext as ShaderCompilationRuntimeContext }\n\t\t\t: {})\n\t};\n}\n"],"mappings":";AAuDA,SAAS,yBAAyB,OAAiD;AAClF,KAAI,UAAU,QAAQ,OAAO,UAAU,SACtC,QAAO;CAGR,MAAM,SAAS;AACf,KAAI,OAAO,cAAc,UAAa,OAAO,OAAO,cAAc,SACjE,QAAO;AAER,KAAI,OAAO,SAAS,UAAa,OAAO,OAAO,SAAS,SACvD,QAAO;A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= 'initialization' | 'render';
5
5
  /**
6
6
  * Stable machine-readable error category code.
7
7
  */
8
- export type MotionGPUErrorCode = 'WEBGPU_UNAVAILABLE' | 'WEBGPU_ADAPTER_UNAVAILABLE' | 'WEBGPU_CONTEXT_UNAVAILABLE' | 'WGSL_COMPILATION_FAILED' | 'WEBGPU_DEVICE_LOST' | 'WEBGPU_UNCAPTURED_ERROR' | 'BIND_GROUP_MISMATCH' | 'TEXTURE_USAGE_INVALID' | 'TEXTURE_REQUEST_FAILED' | 'TEXTURE_DECODE_UNAVAILABLE' | 'TEXTURE_REQUEST_ABORTED' | 'MOTIONGPU_RUNTIME_ERROR';
8
+ export type MotionGPUErrorCode = 'WEBGPU_UNAVAILABLE' | 'WEBGPU_ADAPTER_UNAVAILABLE' | 'WEBGPU_CONTEXT_UNAVAILABLE' | 'WGSL_COMPILATION_FAILED' | 'MATERIAL_PREPROCESS_FAILED' | 'WEBGPU_DEVICE_LOST' | 'WEBGPU_UNCAPTURED_ERROR' | 'BIND_GROUP_MISMATCH' | 'RUNTIME_RESOURCE_MISSING' | 'UNIFORM_VALUE_INVALID' | 'STORAGE_BUFFER_OUT_OF_BOUNDS' | 'STORAGE_BUFFER_READ_FAILED' | 'RENDER_GRAPH_INVALID' | 'PINGPONG_CONFIGURATION_INVALID' | 'TEXTURE_USAGE_INVALID' | 'TEXTURE_REQUEST_FAILED' | 'TEXTURE_DECODE_UNAVAILABLE' | 'TEXTURE_REQUEST_ABORTED' | 'COMPUTE_COMPILATION_FAILED' | 'COMPUTE_CONTRACT_INVALID' | 'MOTIONGPU_RUNTIME_ERROR';
9
9
  /**
10
10
  * Severity level for user-facing diagnostics.
11
11
  */
@@ -102,3 +102,4 @@ export interface MotionGPUErrorReport {
102
102
  * @returns Normalized error report.
103
103
  */
104
104
  export declare function toMotionGPUErrorReport(error: unknown, phase: MotionGPUErrorPhase): MotionGPUErrorReport;
105
+ //# sourceMappingURL=error-report.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,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