@graphty/webgpu-graph-algorithms 0.0.0 → 0.2.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 (269) hide show
  1. package/README.md +344 -23
  2. package/dist/browser.d.ts +1 -0
  3. package/dist/browser.js +32 -0
  4. package/dist/browser.js.map +1 -0
  5. package/dist/chunks/context-E6iKaeuJ.js +3136 -0
  6. package/dist/chunks/context-E6iKaeuJ.js.map +1 -0
  7. package/dist/node.d.ts +1 -0
  8. package/dist/node.js +131 -0
  9. package/dist/node.js.map +1 -0
  10. package/dist/src/accelerator.d.ts +26 -0
  11. package/dist/src/accelerator.d.ts.map +1 -0
  12. package/dist/src/accelerator.js +101 -0
  13. package/dist/src/accelerator.js.map +1 -0
  14. package/dist/src/algorithms/degree.d.ts +35 -0
  15. package/dist/src/algorithms/degree.d.ts.map +1 -0
  16. package/dist/src/algorithms/degree.js +119 -0
  17. package/dist/src/algorithms/degree.js.map +1 -0
  18. package/dist/src/browser/index.d.ts +23 -0
  19. package/dist/src/browser/index.d.ts.map +1 -0
  20. package/dist/src/browser/index.js +48 -0
  21. package/dist/src/browser/index.js.map +1 -0
  22. package/dist/src/constants.d.ts +92 -0
  23. package/dist/src/constants.d.ts.map +1 -0
  24. package/dist/src/constants.js +92 -0
  25. package/dist/src/constants.js.map +1 -0
  26. package/dist/src/context.d.ts +84 -0
  27. package/dist/src/context.d.ts.map +1 -0
  28. package/dist/src/context.js +304 -0
  29. package/dist/src/context.js.map +1 -0
  30. package/dist/src/device/acquire.d.ts +57 -0
  31. package/dist/src/device/acquire.d.ts.map +1 -0
  32. package/dist/src/device/acquire.js +232 -0
  33. package/dist/src/device/acquire.js.map +1 -0
  34. package/dist/src/device/caps.d.ts +43 -0
  35. package/dist/src/device/caps.d.ts.map +1 -0
  36. package/dist/src/device/caps.js +104 -0
  37. package/dist/src/device/caps.js.map +1 -0
  38. package/dist/src/device/error-scope.d.ts +75 -0
  39. package/dist/src/device/error-scope.d.ts.map +1 -0
  40. package/dist/src/device/error-scope.js +152 -0
  41. package/dist/src/device/error-scope.js.map +1 -0
  42. package/dist/src/device/lost.d.ts +51 -0
  43. package/dist/src/device/lost.d.ts.map +1 -0
  44. package/dist/src/device/lost.js +130 -0
  45. package/dist/src/device/lost.js.map +1 -0
  46. package/dist/src/device/webgpu-constants.d.ts +31 -0
  47. package/dist/src/device/webgpu-constants.d.ts.map +1 -0
  48. package/dist/src/device/webgpu-constants.js +31 -0
  49. package/dist/src/device/webgpu-constants.js.map +1 -0
  50. package/dist/src/errors.d.ts +56 -0
  51. package/dist/src/errors.d.ts.map +1 -0
  52. package/dist/src/errors.js +57 -0
  53. package/dist/src/errors.js.map +1 -0
  54. package/dist/src/index.d.ts +29 -0
  55. package/dist/src/index.d.ts.map +1 -0
  56. package/dist/src/index.js +27 -0
  57. package/dist/src/index.js.map +1 -0
  58. package/dist/src/kernel/batch.d.ts +116 -0
  59. package/dist/src/kernel/batch.d.ts.map +1 -0
  60. package/dist/src/kernel/batch.js +335 -0
  61. package/dist/src/kernel/batch.js.map +1 -0
  62. package/dist/src/kernel/dispatch.d.ts +59 -0
  63. package/dist/src/kernel/dispatch.d.ts.map +1 -0
  64. package/dist/src/kernel/dispatch.js +139 -0
  65. package/dist/src/kernel/dispatch.js.map +1 -0
  66. package/dist/src/kernel/kernel.d.ts +84 -0
  67. package/dist/src/kernel/kernel.d.ts.map +1 -0
  68. package/dist/src/kernel/kernel.js +239 -0
  69. package/dist/src/kernel/kernel.js.map +1 -0
  70. package/dist/src/kernel/pipeline-cache.d.ts +90 -0
  71. package/dist/src/kernel/pipeline-cache.d.ts.map +1 -0
  72. package/dist/src/kernel/pipeline-cache.js +251 -0
  73. package/dist/src/kernel/pipeline-cache.js.map +1 -0
  74. package/dist/src/kernel/prelude.d.ts +35 -0
  75. package/dist/src/kernel/prelude.d.ts.map +1 -0
  76. package/dist/src/kernel/prelude.js +211 -0
  77. package/dist/src/kernel/prelude.js.map +1 -0
  78. package/dist/src/kernel/profiler.d.ts +64 -0
  79. package/dist/src/kernel/profiler.d.ts.map +1 -0
  80. package/dist/src/kernel/profiler.js +120 -0
  81. package/dist/src/kernel/profiler.js.map +1 -0
  82. package/dist/src/kernel/struct-block.d.ts +122 -0
  83. package/dist/src/kernel/struct-block.d.ts.map +1 -0
  84. package/dist/src/kernel/struct-block.js +353 -0
  85. package/dist/src/kernel/struct-block.js.map +1 -0
  86. package/dist/src/kernel/uniform-ring.d.ts +70 -0
  87. package/dist/src/kernel/uniform-ring.d.ts.map +1 -0
  88. package/dist/src/kernel/uniform-ring.js +146 -0
  89. package/dist/src/kernel/uniform-ring.js.map +1 -0
  90. package/dist/src/kernel/wgsl.d.ts +88 -0
  91. package/dist/src/kernel/wgsl.d.ts.map +1 -0
  92. package/dist/src/kernel/wgsl.js +390 -0
  93. package/dist/src/kernel/wgsl.js.map +1 -0
  94. package/dist/src/kernels.d.ts +81 -0
  95. package/dist/src/kernels.d.ts.map +1 -0
  96. package/dist/src/kernels.js +417 -0
  97. package/dist/src/kernels.js.map +1 -0
  98. package/dist/src/layouts/force-simulation.d.ts +498 -0
  99. package/dist/src/layouts/force-simulation.d.ts.map +1 -0
  100. package/dist/src/layouts/force-simulation.js +1650 -0
  101. package/dist/src/layouts/force-simulation.js.map +1 -0
  102. package/dist/src/layouts/forceatlas2.d.ts +210 -0
  103. package/dist/src/layouts/forceatlas2.d.ts.map +1 -0
  104. package/dist/src/layouts/forceatlas2.js +759 -0
  105. package/dist/src/layouts/forceatlas2.js.map +1 -0
  106. package/dist/src/layouts/inputs.d.ts +40 -0
  107. package/dist/src/layouts/inputs.d.ts.map +1 -0
  108. package/dist/src/layouts/inputs.js +185 -0
  109. package/dist/src/layouts/inputs.js.map +1 -0
  110. package/dist/src/layouts/repulsion-exact.d.ts +85 -0
  111. package/dist/src/layouts/repulsion-exact.d.ts.map +1 -0
  112. package/dist/src/layouts/repulsion-exact.js +134 -0
  113. package/dist/src/layouts/repulsion-exact.js.map +1 -0
  114. package/dist/src/layouts/seed.d.ts +56 -0
  115. package/dist/src/layouts/seed.d.ts.map +1 -0
  116. package/dist/src/layouts/seed.js +173 -0
  117. package/dist/src/layouts/seed.js.map +1 -0
  118. package/dist/src/memory/buffer-pool.d.ts +73 -0
  119. package/dist/src/memory/buffer-pool.d.ts.map +1 -0
  120. package/dist/src/memory/buffer-pool.js +170 -0
  121. package/dist/src/memory/buffer-pool.js.map +1 -0
  122. package/dist/src/memory/lease.d.ts +53 -0
  123. package/dist/src/memory/lease.d.ts.map +1 -0
  124. package/dist/src/memory/lease.js +85 -0
  125. package/dist/src/memory/lease.js.map +1 -0
  126. package/dist/src/memory/readback.d.ts +143 -0
  127. package/dist/src/memory/readback.d.ts.map +1 -0
  128. package/dist/src/memory/readback.js +375 -0
  129. package/dist/src/memory/readback.js.map +1 -0
  130. package/dist/src/memory/residency.d.ts +83 -0
  131. package/dist/src/memory/residency.d.ts.map +1 -0
  132. package/dist/src/memory/residency.js +573 -0
  133. package/dist/src/memory/residency.js.map +1 -0
  134. package/dist/src/memory/upload-plan.d.ts +101 -0
  135. package/dist/src/memory/upload-plan.d.ts.map +1 -0
  136. package/dist/src/memory/upload-plan.js +265 -0
  137. package/dist/src/memory/upload-plan.js.map +1 -0
  138. package/dist/src/node/index.d.ts +64 -0
  139. package/dist/src/node/index.d.ts.map +1 -0
  140. package/dist/src/node/index.js +183 -0
  141. package/dist/src/node/index.js.map +1 -0
  142. package/dist/src/primitives/reduce.d.ts +57 -0
  143. package/dist/src/primitives/reduce.d.ts.map +1 -0
  144. package/dist/src/primitives/reduce.js +161 -0
  145. package/dist/src/primitives/reduce.js.map +1 -0
  146. package/dist/src/primitives/segmented-reduce.d.ts +38 -0
  147. package/dist/src/primitives/segmented-reduce.d.ts.map +1 -0
  148. package/dist/src/primitives/segmented-reduce.js +211 -0
  149. package/dist/src/primitives/segmented-reduce.js.map +1 -0
  150. package/dist/src/types/accelerator.d.ts +209 -0
  151. package/dist/src/types/accelerator.d.ts.map +1 -0
  152. package/dist/src/types/accelerator.js +8 -0
  153. package/dist/src/types/accelerator.js.map +1 -0
  154. package/dist/src/types/context.d.ts +114 -0
  155. package/dist/src/types/context.d.ts.map +1 -0
  156. package/dist/src/types/context.js +7 -0
  157. package/dist/src/types/context.js.map +1 -0
  158. package/dist/src/types/layout.d.ts +95 -0
  159. package/dist/src/types/layout.d.ts.map +1 -0
  160. package/dist/src/types/layout.js +6 -0
  161. package/dist/src/types/layout.js.map +1 -0
  162. package/dist/src/types/memory.d.ts +22 -0
  163. package/dist/src/types/memory.d.ts.map +1 -0
  164. package/dist/src/types/memory.js +7 -0
  165. package/dist/src/types/memory.js.map +1 -0
  166. package/dist/src/types/options.d.ts +78 -0
  167. package/dist/src/types/options.d.ts.map +1 -0
  168. package/dist/src/types/options.js +7 -0
  169. package/dist/src/types/options.js.map +1 -0
  170. package/dist/src/types/run.d.ts +13 -0
  171. package/dist/src/types/run.d.ts.map +1 -0
  172. package/dist/src/types/run.js +6 -0
  173. package/dist/src/types/run.js.map +1 -0
  174. package/dist/src/wgsl/degree.wgsl.d.ts +10 -0
  175. package/dist/src/wgsl/degree.wgsl.d.ts.map +1 -0
  176. package/dist/src/wgsl/degree.wgsl.js +25 -0
  177. package/dist/src/wgsl/degree.wgsl.js.map +1 -0
  178. package/dist/src/wgsl/fa2-attraction.wgsl.d.ts +12 -0
  179. package/dist/src/wgsl/fa2-attraction.wgsl.d.ts.map +1 -0
  180. package/dist/src/wgsl/fa2-attraction.wgsl.js +37 -0
  181. package/dist/src/wgsl/fa2-attraction.wgsl.js.map +1 -0
  182. package/dist/src/wgsl/fa2-integrate.wgsl.d.ts +13 -0
  183. package/dist/src/wgsl/fa2-integrate.wgsl.d.ts.map +1 -0
  184. package/dist/src/wgsl/fa2-integrate.wgsl.js +69 -0
  185. package/dist/src/wgsl/fa2-integrate.wgsl.js.map +1 -0
  186. package/dist/src/wgsl/fa2-repulsion-exact.wgsl.d.ts +12 -0
  187. package/dist/src/wgsl/fa2-repulsion-exact.wgsl.d.ts.map +1 -0
  188. package/dist/src/wgsl/fa2-repulsion-exact.wgsl.js +79 -0
  189. package/dist/src/wgsl/fa2-repulsion-exact.wgsl.js.map +1 -0
  190. package/dist/src/wgsl/fa2-speed-finalize.wgsl.d.ts +15 -0
  191. package/dist/src/wgsl/fa2-speed-finalize.wgsl.d.ts.map +1 -0
  192. package/dist/src/wgsl/fa2-speed-finalize.wgsl.js +54 -0
  193. package/dist/src/wgsl/fa2-speed-finalize.wgsl.js.map +1 -0
  194. package/dist/src/wgsl/fa2-stats-finalize.wgsl.d.ts +14 -0
  195. package/dist/src/wgsl/fa2-stats-finalize.wgsl.d.ts.map +1 -0
  196. package/dist/src/wgsl/fa2-stats-finalize.wgsl.js +57 -0
  197. package/dist/src/wgsl/fa2-stats-finalize.wgsl.js.map +1 -0
  198. package/dist/src/wgsl/fa2-to-scene.wgsl.d.ts +11 -0
  199. package/dist/src/wgsl/fa2-to-scene.wgsl.d.ts.map +1 -0
  200. package/dist/src/wgsl/fa2-to-scene.wgsl.js +19 -0
  201. package/dist/src/wgsl/fa2-to-scene.wgsl.js.map +1 -0
  202. package/dist/src/wgsl/fill.wgsl.d.ts +7 -0
  203. package/dist/src/wgsl/fill.wgsl.d.ts.map +1 -0
  204. package/dist/src/wgsl/fill.wgsl.js +14 -0
  205. package/dist/src/wgsl/fill.wgsl.js.map +1 -0
  206. package/dist/src/wgsl/reduce.wgsl.d.ts +10 -0
  207. package/dist/src/wgsl/reduce.wgsl.d.ts.map +1 -0
  208. package/dist/src/wgsl/reduce.wgsl.js +63 -0
  209. package/dist/src/wgsl/reduce.wgsl.js.map +1 -0
  210. package/dist/src/wgsl/segmented-reduce.wgsl.d.ts +13 -0
  211. package/dist/src/wgsl/segmented-reduce.wgsl.d.ts.map +1 -0
  212. package/dist/src/wgsl/segmented-reduce.wgsl.js +35 -0
  213. package/dist/src/wgsl/segmented-reduce.wgsl.js.map +1 -0
  214. package/dist/tsconfig.build.tsbuildinfo +1 -0
  215. package/dist/webgpu-graph-algorithms.d.ts +1 -0
  216. package/dist/webgpu-graph-algorithms.js +4454 -0
  217. package/dist/webgpu-graph-algorithms.js.map +1 -0
  218. package/package.json +108 -17
  219. package/src/accelerator.ts +117 -0
  220. package/src/algorithms/degree.ts +142 -0
  221. package/src/browser/index.ts +57 -0
  222. package/src/constants.ts +116 -0
  223. package/src/context.ts +399 -0
  224. package/src/device/acquire.ts +256 -0
  225. package/src/device/caps.ts +122 -0
  226. package/src/device/error-scope.ts +171 -0
  227. package/src/device/lost.ts +142 -0
  228. package/src/device/webgpu-constants.ts +44 -0
  229. package/src/errors.ts +94 -0
  230. package/src/index.ts +102 -0
  231. package/src/kernel/batch.ts +427 -0
  232. package/src/kernel/dispatch.ts +162 -0
  233. package/src/kernel/kernel.ts +311 -0
  234. package/src/kernel/pipeline-cache.ts +288 -0
  235. package/src/kernel/prelude.ts +229 -0
  236. package/src/kernel/profiler.ts +148 -0
  237. package/src/kernel/struct-block.ts +439 -0
  238. package/src/kernel/uniform-ring.ts +184 -0
  239. package/src/kernel/wgsl.ts +490 -0
  240. package/src/kernels.ts +511 -0
  241. package/src/layouts/force-simulation.ts +2111 -0
  242. package/src/layouts/forceatlas2.ts +942 -0
  243. package/src/layouts/inputs.ts +252 -0
  244. package/src/layouts/repulsion-exact.ts +183 -0
  245. package/src/layouts/seed.ts +198 -0
  246. package/src/memory/buffer-pool.ts +204 -0
  247. package/src/memory/lease.ts +93 -0
  248. package/src/memory/readback.ts +429 -0
  249. package/src/memory/residency.ts +753 -0
  250. package/src/memory/upload-plan.ts +350 -0
  251. package/src/node/index.ts +230 -0
  252. package/src/primitives/reduce.ts +233 -0
  253. package/src/primitives/segmented-reduce.ts +270 -0
  254. package/src/types/accelerator.ts +236 -0
  255. package/src/types/context.ts +135 -0
  256. package/src/types/layout.ts +103 -0
  257. package/src/types/memory.ts +23 -0
  258. package/src/types/options.ts +84 -0
  259. package/src/types/run.ts +13 -0
  260. package/src/wgsl/degree.wgsl.ts +24 -0
  261. package/src/wgsl/fa2-attraction.wgsl.ts +37 -0
  262. package/src/wgsl/fa2-integrate.wgsl.ts +69 -0
  263. package/src/wgsl/fa2-repulsion-exact.wgsl.ts +78 -0
  264. package/src/wgsl/fa2-speed-finalize.wgsl.ts +53 -0
  265. package/src/wgsl/fa2-stats-finalize.wgsl.ts +57 -0
  266. package/src/wgsl/fa2-to-scene.wgsl.ts +19 -0
  267. package/src/wgsl/fill.wgsl.ts +13 -0
  268. package/src/wgsl/reduce.wgsl.ts +62 -0
  269. package/src/wgsl/segmented-reduce.wgsl.ts +35 -0
@@ -0,0 +1,152 @@
1
+ /**
2
+ * Error scopes (spec 5.7; contract 3.4): a validation scope that turns a captured GPUValidationError into
3
+ * E_VALIDATION { label, message }, the compilation-info formatter with body-relative line numbers, and the
4
+ * AllocationTracker that wraps large createBuffer calls in an out-of-memory scope and keeps the resident-byte
5
+ * bookkeeping the residency, the pool and the staging ring share (it is owned by the context).
6
+ */
7
+ import { OOM_SCOPE_THRESHOLD_BYTES } from "../constants.js";
8
+ import { WebGpuGraphError } from "../errors.js";
9
+ /**
10
+ * Runs `fn` inside pushErrorScope("validation"); a captured error becomes E_VALIDATION { label, message }
11
+ * thrown from the returned promise (spec 5.7). An error `fn` itself throws is rethrown unchanged after the
12
+ * scope is popped, so the device's scope stack stays balanced.
13
+ * @param device - the device
14
+ * @param label - names the operation in the error (every object the package creates is labelled)
15
+ * @param fn - the work; may return a promise
16
+ * @returns the value of `fn`
17
+ */
18
+ export async function withValidationScope(device, label, fn) {
19
+ device.pushErrorScope("validation");
20
+ let result;
21
+ try {
22
+ result = await fn();
23
+ }
24
+ catch (err) {
25
+ await device.popErrorScope().catch(() => null);
26
+ throw err;
27
+ }
28
+ const error = await device.popErrorScope();
29
+ if (error !== null) {
30
+ throw new WebGpuGraphError("E_VALIDATION", `${label}: ${error.message}`, { label, message: error.message });
31
+ }
32
+ return result;
33
+ }
34
+ /**
35
+ * Formats GPUCompilationInfo messages with line numbers relative to the kernel BODY: `preludeLines` (the
36
+ * lines the composer emitted before the body) is subtracted, a message located inside those lines is
37
+ * reported as `prelude:<line>`, and a message without a location (lineNum 0) carries no position (spec 5.1).
38
+ * @param info - the compilation info of the shader module
39
+ * @param preludeLines - the number of emitted lines before the body's first line
40
+ * @returns one string per message: `<type> <line>:<column> <message>`
41
+ */
42
+ export function formatCompilationInfo(info, preludeLines) {
43
+ return info.messages.map((m) => {
44
+ if (m.lineNum === 0) {
45
+ return `${m.type} ${m.message}`;
46
+ }
47
+ const line = m.lineNum - preludeLines;
48
+ if (line >= 1) {
49
+ return `${m.type} ${line}:${m.linePos} ${m.message}`;
50
+ }
51
+ return `${m.type} prelude:${m.lineNum}:${m.linePos} ${m.message}`;
52
+ });
53
+ }
54
+ /**
55
+ * Creates buffers, wrapping sizes >= OOM_SCOPE_THRESHOLD_BYTES in an "out-of-memory" scope whose pop is
56
+ * collected; `check()` surfaces the first OOM (spec 4.4, 5.7). Owned by the context, shared by the
57
+ * residency and the pool.
58
+ */
59
+ export class AllocationTracker {
60
+ /**
61
+ * Creates a tracker over one device.
62
+ * @param device - the device buffers are created on
63
+ * @param thresholdBytes - the byte size from which createBuffer runs inside an out-of-memory scope (default OOM_SCOPE_THRESHOLD_BYTES)
64
+ */
65
+ constructor(device, thresholdBytes) {
66
+ this.live = new Map();
67
+ this.residentBytes = 0;
68
+ this.pending = [];
69
+ this.failure = null;
70
+ this.serial = 0;
71
+ this.device = device;
72
+ this.threshold = thresholdBytes ?? OOM_SCOPE_THRESHOLD_BYTES;
73
+ }
74
+ /**
75
+ * createBuffer with the scope rule; every buffer is labelled (an unlabelled descriptor becomes `buffer-<n>`).
76
+ * @param descriptor - the buffer descriptor
77
+ * @returns the buffer
78
+ */
79
+ createBuffer(descriptor) {
80
+ this.serial += 1;
81
+ const label = descriptor.label === undefined || descriptor.label === "" ? `buffer-${this.serial}` : descriptor.label;
82
+ const { size } = descriptor;
83
+ const scoped = size >= this.threshold;
84
+ if (scoped) {
85
+ this.device.pushErrorScope("out-of-memory");
86
+ }
87
+ const buffer = this.device.createBuffer({ ...descriptor, label });
88
+ this.live.set(buffer, size);
89
+ this.residentBytes += size;
90
+ if (scoped) {
91
+ const pop = this.device.popErrorScope().then((error) => {
92
+ if (error === null) {
93
+ return;
94
+ }
95
+ if (this.live.has(buffer)) {
96
+ this.live.delete(buffer);
97
+ this.residentBytes -= size;
98
+ }
99
+ if (this.failure === null) {
100
+ this.failure = new WebGpuGraphError("E_OUT_OF_MEMORY", `out of memory creating "${label}" (${size} bytes, ${this.residentBytes} resident): ${error.message}`, { requested: size, resident: this.residentBytes, label });
101
+ }
102
+ }, () => undefined);
103
+ this.pending.push(pop);
104
+ }
105
+ return buffer;
106
+ }
107
+ /**
108
+ * Destroys a buffer created here and decrements `resident`; a buffer the tracker does not know is destroyed
109
+ * without touching the bookkeeping, so destroying twice is harmless.
110
+ * @param buffer - the buffer to destroy
111
+ */
112
+ destroy(buffer) {
113
+ const size = this.live.get(buffer);
114
+ if (size !== undefined) {
115
+ this.live.delete(buffer);
116
+ this.residentBytes -= size;
117
+ }
118
+ buffer.destroy();
119
+ }
120
+ /**
121
+ * Awaits every outstanding scope pop; the first OOM -> E_OUT_OF_MEMORY { requested, resident, label }; later
122
+ * calls after a failure throw the same error again until `reset()`.
123
+ */
124
+ async check() {
125
+ while (this.pending.length > 0) {
126
+ const batch = this.pending.splice(0);
127
+ await Promise.all(batch);
128
+ }
129
+ if (this.failure !== null) {
130
+ throw this.failure;
131
+ }
132
+ }
133
+ /** Forgets a recorded OOM after the caller released what it allocated. */
134
+ reset() {
135
+ this.failure = null;
136
+ }
137
+ /**
138
+ * Bytes of live buffers created through this tracker.
139
+ * @returns the resident byte count
140
+ */
141
+ get resident() {
142
+ return this.residentBytes;
143
+ }
144
+ /**
145
+ * Number of live buffers created through this tracker.
146
+ * @returns the live buffer count
147
+ */
148
+ get liveBuffers() {
149
+ return this.live.size;
150
+ }
151
+ }
152
+ //# sourceMappingURL=error-scope.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-scope.js","sourceRoot":"","sources":["../../../src/device/error-scope.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAI,MAAiB,EAAE,KAAa,EAAE,EAAwB;IACnG,MAAM,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC;IACpC,IAAI,MAAS,CAAC;IACd,IAAI,CAAC;QACD,MAAM,GAAG,MAAM,EAAE,EAAE,CAAC;IACxB,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACX,MAAM,MAAM,CAAC,aAAa,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;QAC/C,MAAM,GAAG,CAAC;IACd,CAAC;IACD,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC,aAAa,EAAE,CAAC;IAC3C,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QACjB,MAAM,IAAI,gBAAgB,CAAC,cAAc,EAAE,GAAG,KAAK,KAAK,KAAK,CAAC,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;IAChH,CAAC;IACD,OAAO,MAAM,CAAC;AAClB,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,qBAAqB,CAAC,IAAwB,EAAE,YAAoB;IAChF,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;QAC3B,IAAI,CAAC,CAAC,OAAO,KAAK,CAAC,EAAE,CAAC;YAClB,OAAO,GAAG,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC;QACpC,CAAC;QACD,MAAM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AAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YACzB,IAAI,CAAC,aAAa,IAAI,IAAI,CAAC;QAC/B,CAAC;QACD,MAAM,CAAC,OAAO,EAAE,CAAC;IACrB,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,KAAK;QACP,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC7B,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;YACrC,MAAM,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAC7B,CAAC;QACD,IAAI,IAAI,CAAC,OAAO,KAAK,IAAI,EAAE,CAAC;YACxB,MAAM,IAAI,CAAC,OAAO,CAAC;QACvB,CAAC;IACL,CAAC;IAED,0EAA0E;IAC1E,KAAK;QACD,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;IACxB,CAAC;IAED;;;OAGG;IACH,IAAI,QAAQ;QACR,OAAO,IAAI,CAAC,aAAa,CAAC;IAC9B,CAAC;IAED;;;OAGG;IACH,IAAI,WAAW;QACX,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;IAC1B,CAAC;CACJ"}
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Device-loss and uncaptured-error plumbing (spec 5.7, 2.2 step 5; contract 3.4): the pending-error slot a
3
+ * context throws from its next public call, the uncapturederror listener that routes each event to the
4
+ * caller's sink or to the slot, the device.lost watcher and the E_DEVICE_LOST constructor. Nothing here
5
+ * throws; errors are constructed and handed on.
6
+ */
7
+ import { WebGpuGraphError } from "../errors.js";
8
+ /** The context's pending-error slot (spec 5.7): the last uncaptured error not yet delivered; `take()` clears it. */
9
+ export declare class PendingErrorSlot {
10
+ private readonly queue;
11
+ /**
12
+ * Stores an error; a second error before `take()` is kept as `details.next` of the first.
13
+ * @param error - the error to hold until the next public call
14
+ */
15
+ set(error: WebGpuGraphError): void;
16
+ /**
17
+ * Returns and clears the pending error, or null. With several errors queued the FIRST is returned and
18
+ * each later one is chained as `details.next` of its predecessor (a copy: `details` is frozen).
19
+ * @returns the first pending error with the chain attached, or null
20
+ */
21
+ take(): WebGpuGraphError | null;
22
+ /**
23
+ * True when an error is pending.
24
+ * @returns whether `take()` would return an error
25
+ */
26
+ get pending(): boolean;
27
+ }
28
+ /**
29
+ * Installs the uncapturederror listener: each event becomes E_VALIDATION { label, message } (or
30
+ * E_OUT_OF_MEMORY for GPUOutOfMemoryError) routed to `onError`, else stored in `slot`. Returns the
31
+ * uninstaller. `label` is the device's label (the descriptor label create() gave it).
32
+ * @param device - the device to listen on
33
+ * @param slot - where errors go when no sink is given
34
+ * @param onError - the caller's sink, or null
35
+ * @returns a function that removes the listener
36
+ */
37
+ export declare function installUncapturedErrorSink(device: GPUDevice, slot: PendingErrorSlot, onError: ((error: WebGpuGraphError) => void) | null): () => void;
38
+ /**
39
+ * Chains device.lost into `onLost` exactly once; returns the promise the context exposes as `ctx.lost`.
40
+ * @param device - the device whose loss is watched
41
+ * @param onLost - called once with the lost info
42
+ * @returns the lost info, after `onLost` ran
43
+ */
44
+ export declare function watchDeviceLost(device: GPUDevice, onLost: (info: GPUDeviceLostInfo) => void): Promise<GPUDeviceLostInfo>;
45
+ /**
46
+ * The E_DEVICE_LOST error for a lost-info record.
47
+ * @param info - the device.lost result
48
+ * @returns E_DEVICE_LOST { reason, message }
49
+ */
50
+ export declare function deviceLostError(info: GPUDeviceLostInfo): WebGpuGraphError;
51
+ //# sourceMappingURL=lost.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lost.d.ts","sourceRoot":"","sources":["../../../src/device/lost.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD,oHAAoH;AACpH,qBAAa,gBAAgB;IACzB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAA0B;IAEhD;;;OAGG;IACH,GAAG,CAAC,KAAK,EAAE,gBAAgB,GAAG,IAAI;IAIlC;;;;OAIG;IACH,IAAI,IAAI,gBAAgB,GAAG,IAAI;IAgB/B;;;OAGG;IACH,IAAI,OAAO,IAAI,OAAO,CAErB;CACJ;AA0BD;;;;;;;;GAQG;AACH,wBAAgB,0BAA0B,CACtC,MAAM,EAAE,SAAS,EACjB,IAAI,EAAE,gBAAgB,EACtB,OAAO,EAAE,CAAC,CAAC,KAAK,EAAE,gBAAgB,KAAK,IAAI,CAAC,GAAG,IAAI,GACpD,MAAM,IAAI,CAqBZ;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAC3B,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,CAAC,IAAI,EAAE,iBAAiB,KAAK,IAAI,GAC1C,OAAO,CAAC,iBAAiB,CAAC,CAS5B;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,iBAAiB,GAAG,gBAAgB,CAKzE"}
@@ -0,0 +1,130 @@
1
+ /**
2
+ * Device-loss and uncaptured-error plumbing (spec 5.7, 2.2 step 5; contract 3.4): the pending-error slot a
3
+ * context throws from its next public call, the uncapturederror listener that routes each event to the
4
+ * caller's sink or to the slot, the device.lost watcher and the E_DEVICE_LOST constructor. Nothing here
5
+ * throws; errors are constructed and handed on.
6
+ */
7
+ import { WebGpuGraphError } from "../errors.js";
8
+ /** The context's pending-error slot (spec 5.7): the last uncaptured error not yet delivered; `take()` clears it. */
9
+ export class PendingErrorSlot {
10
+ constructor() {
11
+ this.queue = [];
12
+ }
13
+ /**
14
+ * Stores an error; a second error before `take()` is kept as `details.next` of the first.
15
+ * @param error - the error to hold until the next public call
16
+ */
17
+ set(error) {
18
+ this.queue.push(error);
19
+ }
20
+ /**
21
+ * Returns and clears the pending error, or null. With several errors queued the FIRST is returned and
22
+ * each later one is chained as `details.next` of its predecessor (a copy: `details` is frozen).
23
+ * @returns the first pending error with the chain attached, or null
24
+ */
25
+ take() {
26
+ if (this.queue.length === 0) {
27
+ return null;
28
+ }
29
+ const errors = this.queue.splice(0);
30
+ let chained = null;
31
+ for (let i = errors.length - 1; i >= 0; i -= 1) {
32
+ const error = errors[i];
33
+ chained =
34
+ chained === null
35
+ ? error
36
+ : new WebGpuGraphError(error.code, error.message, { ...error.details, next: chained });
37
+ }
38
+ return chained;
39
+ }
40
+ /**
41
+ * True when an error is pending.
42
+ * @returns whether `take()` would return an error
43
+ */
44
+ get pending() {
45
+ return this.queue.length > 0;
46
+ }
47
+ }
48
+ /**
49
+ * The WebGpuGraphError for one uncaptured GPUError: E_OUT_OF_MEMORY for a GPUOutOfMemoryError (recognised
50
+ * by its class name so no global is read, spec 2.1 rule 1), E_VALIDATION otherwise.
51
+ * @param error - the event's error
52
+ * @param label - the device label the error is attributed to
53
+ * @returns the wrapped error
54
+ */
55
+ function uncapturedError(error, label) {
56
+ const { message } = error;
57
+ if (error.constructor.name === "GPUOutOfMemoryError") {
58
+ // the documented shape is { requested, resident, label } (contract 3.1); the event names no size and the
59
+ // sink tracks no residency, so both are 0 and the runtime's text lives in the message only
60
+ return new WebGpuGraphError("E_OUT_OF_MEMORY", `uncaptured out-of-memory error on "${label}": ${message}`, {
61
+ requested: 0,
62
+ resident: 0,
63
+ label,
64
+ });
65
+ }
66
+ return new WebGpuGraphError("E_VALIDATION", `uncaptured validation error on "${label}": ${message}`, {
67
+ label,
68
+ message,
69
+ });
70
+ }
71
+ /**
72
+ * Installs the uncapturederror listener: each event becomes E_VALIDATION { label, message } (or
73
+ * E_OUT_OF_MEMORY for GPUOutOfMemoryError) routed to `onError`, else stored in `slot`. Returns the
74
+ * uninstaller. `label` is the device's label (the descriptor label create() gave it).
75
+ * @param device - the device to listen on
76
+ * @param slot - where errors go when no sink is given
77
+ * @param onError - the caller's sink, or null
78
+ * @returns a function that removes the listener
79
+ */
80
+ export function installUncapturedErrorSink(device, slot, onError) {
81
+ let installed = true;
82
+ const label = device.label ?? "";
83
+ const listener = (event) => {
84
+ if (!installed) {
85
+ return;
86
+ }
87
+ const wrapped = uncapturedError(event.error, label);
88
+ if (onError !== null) {
89
+ onError(wrapped);
90
+ }
91
+ else {
92
+ slot.set(wrapped);
93
+ }
94
+ };
95
+ device.addEventListener("uncapturederror", listener);
96
+ return () => {
97
+ installed = false;
98
+ if (typeof device.removeEventListener === "function") {
99
+ device.removeEventListener("uncapturederror", listener);
100
+ }
101
+ };
102
+ }
103
+ /**
104
+ * Chains device.lost into `onLost` exactly once; returns the promise the context exposes as `ctx.lost`.
105
+ * @param device - the device whose loss is watched
106
+ * @param onLost - called once with the lost info
107
+ * @returns the lost info, after `onLost` ran
108
+ */
109
+ export function watchDeviceLost(device, onLost) {
110
+ let delivered = false;
111
+ return device.lost.then((info) => {
112
+ if (!delivered) {
113
+ delivered = true;
114
+ onLost(info);
115
+ }
116
+ return info;
117
+ });
118
+ }
119
+ /**
120
+ * The E_DEVICE_LOST error for a lost-info record.
121
+ * @param info - the device.lost result
122
+ * @returns E_DEVICE_LOST { reason, message }
123
+ */
124
+ export function deviceLostError(info) {
125
+ return new WebGpuGraphError("E_DEVICE_LOST", `device lost (${info.reason}): ${info.message}`, {
126
+ reason: info.reason,
127
+ message: info.message,
128
+ });
129
+ }
130
+ //# sourceMappingURL=lost.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lost.js","sourceRoot":"","sources":["../../../src/device/lost.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD,oHAAoH;AACpH,MAAM,OAAO,gBAAgB;IAA7B;QACqB,UAAK,GAAuB,EAAE,CAAC;IAsCpD,CAAC;IApCG;;;OAGG;IACH,GAAG,CAAC,KAAuB;QACvB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC3B,CAAC;IAED;;;;OAIG;IACH,IAAI;QACA,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC1B,OAAO,IAAI,CA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EAAE,gBAAgB,IAAI,CAAC,MAAM,MAAM,IAAI,CAAC,OAAO,EAAE,EAAE;QAC1F,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,OAAO,EAAE,IAAI,CAAC,OAAO;KACxB,CAAC,CAAC;AACP,CAAC"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * GPUBufferUsage / GPUMapMode / GPUShaderStage as numbers (spec 2.1 rule 1; contract 3.4): under Dawn-node the
3
+ * global namespaces do not exist until `Object.assign(globalThis, dawn.globals)` has run, so the core never reads
4
+ * them at module top level and keeps its own copies here. Each field names the WebGPU spec constant it mirrors;
5
+ * test/device/constants.test.ts compares every field with the runtime globals so a drift is caught.
6
+ */
7
+ /** GPUBufferUsage bits as numbers so the core never reads the global at module top level (spec 2.1 rule 1). */
8
+ export declare const BufferUsage: Readonly<{
9
+ MAP_READ: 0x0001;
10
+ MAP_WRITE: 0x0002;
11
+ COPY_SRC: 0x0004;
12
+ COPY_DST: 0x0008;
13
+ INDEX: 0x0010;
14
+ VERTEX: 0x0020;
15
+ UNIFORM: 0x0040;
16
+ STORAGE: 0x0080;
17
+ INDIRECT: 0x0100;
18
+ QUERY_RESOLVE: 0x0200;
19
+ }>;
20
+ /** GPUMapMode bits. */
21
+ export declare const MapMode: Readonly<{
22
+ READ: 0x0001;
23
+ WRITE: 0x0002;
24
+ }>;
25
+ /** GPUShaderStage bits. */
26
+ export declare const ShaderStage: Readonly<{
27
+ VERTEX: 0x1;
28
+ FRAGMENT: 0x2;
29
+ COMPUTE: 0x4;
30
+ }>;
31
+ //# sourceMappingURL=webgpu-constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webgpu-constants.d.ts","sourceRoot":"","sources":["../../../src/device/webgpu-constants.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,+GAA+G;AAC/G,eAAO,MAAM,WAAW,EAAE,QAAQ,CAAC;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;CACzB,CAWC,CAAC;AAEH,uBAAuB;AACvB,eAAO,MAAM,OAAO,EAAE,QAAQ,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAG5D,CAAC;AAEH,2BAA2B;AAC3B,eAAO,MAAM,WAAW,EAAE,QAAQ,CAAC;IAAE,MAAM,EAAE,GAAG,CAAC;IAAC,QAAQ,EAAE,GAAG,CAAC;IAAC,OAAO,EAAE,GAAG,CAAA;CAAE,CAI7E,CAAC"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * GPUBufferUsage / GPUMapMode / GPUShaderStage as numbers (spec 2.1 rule 1; contract 3.4): under Dawn-node the
3
+ * global namespaces do not exist until `Object.assign(globalThis, dawn.globals)` has run, so the core never reads
4
+ * them at module top level and keeps its own copies here. Each field names the WebGPU spec constant it mirrors;
5
+ * test/device/constants.test.ts compares every field with the runtime globals so a drift is caught.
6
+ */
7
+ /** GPUBufferUsage bits as numbers so the core never reads the global at module top level (spec 2.1 rule 1). */
8
+ export const BufferUsage = Object.freeze({
9
+ MAP_READ: 0x0001, // GPUBufferUsage.MAP_READ
10
+ MAP_WRITE: 0x0002, // GPUBufferUsage.MAP_WRITE
11
+ COPY_SRC: 0x0004, // GPUBufferUsage.COPY_SRC
12
+ COPY_DST: 0x0008, // GPUBufferUsage.COPY_DST
13
+ INDEX: 0x0010, // GPUBufferUsage.INDEX
14
+ VERTEX: 0x0020, // GPUBufferUsage.VERTEX
15
+ UNIFORM: 0x0040, // GPUBufferUsage.UNIFORM
16
+ STORAGE: 0x0080, // GPUBufferUsage.STORAGE
17
+ INDIRECT: 0x0100, // GPUBufferUsage.INDIRECT
18
+ QUERY_RESOLVE: 0x0200, // GPUBufferUsage.QUERY_RESOLVE
19
+ });
20
+ /** GPUMapMode bits. */
21
+ export const MapMode = Object.freeze({
22
+ READ: 0x0001, // GPUMapMode.READ
23
+ WRITE: 0x0002, // GPUMapMode.WRITE
24
+ });
25
+ /** GPUShaderStage bits. */
26
+ export const ShaderStage = Object.freeze({
27
+ VERTEX: 0x1, // GPUShaderStage.VERTEX
28
+ FRAGMENT: 0x2, // GPUShaderStage.FRAGMENT
29
+ COMPUTE: 0x4, // GPUShaderStage.COMPUTE
30
+ });
31
+ //# sourceMappingURL=webgpu-constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webgpu-constants.js","sourceRoot":"","sources":["../../../src/device/webgpu-constants.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,+GAA+G;AAC/G,MAAM,CAAC,MAAM,WAAW,GAWnB,MAAM,CAAC,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,EAAE,0BAA0B;IAC5C,SAAS,EAAE,MAAM,EAAE,2BAA2B;IAC9C,QAAQ,EAAE,MAAM,EAAE,0BAA0B;IAC5C,QAAQ,EAAE,MAAM,EAAE,0BAA0B;IAC5C,KAAK,EAAE,MAAM,EAAE,uBAAuB;IACtC,MAAM,EAAE,MAAM,EAAE,wBAAwB;IACxC,OAAO,EAAE,MAAM,EAAE,yBAAyB;IAC1C,OAAO,EAAE,MAAM,EAAE,yBAAyB;IAC1C,QAAQ,EAAE,MAAM,EAAE,0BAA0B;IAC5C,aAAa,EAAE,MAAM,EAAE,+BAA+B;CACzD,CAAC,CAAC;AAEH,uBAAuB;AACvB,MAAM,CAAC,MAAM,OAAO,GAA8C,MAAM,CAAC,MAAM,CAAC;IAC5E,IAAI,EAAE,MAAM,EAAE,kBAAkB;IAChC,KAAK,EAAE,MAAM,EAAE,mBAAmB;CACrC,CAAC,CAAC;AAEH,2BAA2B;AAC3B,MAAM,CAAC,MAAM,WAAW,GAA2D,MAAM,CAAC,MAAM,CAAC;IAC7F,MAAM,EAAE,GAAG,EAAE,wBAAwB;IACrC,QAAQ,EAAE,GAAG,EAAE,0BAA0B;IACzC,OAAO,EAAE,GAAG,EAAE,yBAAyB;CAC1C,CAAC,CAAC"}
@@ -0,0 +1,56 @@
1
+ /**
2
+ * The error class and the closed code set of @graphty/webgpu-graph-algorithms (spec 3.3, 5.7; contract 3.1).
3
+ *
4
+ * Every condition the package detects itself is thrown as a WebGpuGraphError carrying a stable `code` and a
5
+ * frozen shallow copy of the `details` the thrower supplied. Errors raised by @graphty/graph-format accessors
6
+ * the package calls on the caller's behalf pass through unchanged (D12); PASSTHROUGH_FORMAT_CODES lists the
7
+ * codes a public call may let escape. Constructors never throw. Messages are plain ASCII.
8
+ *
9
+ * `details` keys per code (contract 3.1, so tests can assert them): E_NO_WEBGPU { reason, hint };
10
+ * E_NO_ADAPTER { reason }; E_NO_DEVICE { reason, adapter, limit?, requested?, available? } (reason "consumed" |
11
+ * "requestDevice" | "limit" | "feature" | "maxComputeWorkgroupsPerDimension"); E_SOFTWARE_ONLY { adapter };
12
+ * E_DEVICE_LOST { reason, message }; E_DISPOSED { label }; E_VALIDATION { label, message, batchId? };
13
+ * E_SHADER_COMPILE { id, stage: "compose" | "compile", slot?, messages? }; E_OUT_OF_MEMORY { requested, resident,
14
+ * label }; E_TOO_LARGE { needed, limit, path, algorithm }; E_UNSUPPORTED { feature? | option?, hint? } (exactly
15
+ * one of feature / option); E_INVALID_ARGUMENT { argument, value, expected? }; E_SNAPSHOT { reason, serial };
16
+ * E_RELEASED { serial }; E_NOT_LOADED { state }; E_ABORTED { batchId? }.
17
+ */
18
+ /** Every condition the package detects itself carries one of these codes (spec 3.3). */
19
+ export type WebGpuGraphErrorCode = "E_NO_WEBGPU" | "E_NO_ADAPTER" | "E_NO_DEVICE" | "E_SOFTWARE_ONLY" | "E_DEVICE_LOST" | "E_DISPOSED" | "E_VALIDATION" | "E_SHADER_COMPILE" | "E_OUT_OF_MEMORY" | "E_TOO_LARGE" | "E_UNSUPPORTED" | "E_INVALID_ARGUMENT" | "E_SNAPSHOT" | "E_RELEASED" | "E_NOT_LOADED" | "E_ABORTED";
20
+ /** The graph-format error codes a public call lets propagate unchanged (D12, spec 5.7): raised by accessors the package calls on the caller's behalf. */
21
+ export declare const PASSTHROUGH_FORMAT_CODES: readonly [
22
+ "E_GPU_INELIGIBLE",
23
+ "E_UNKNOWN_NODE",
24
+ "E_UNKNOWN_COLUMN",
25
+ "E_COLUMN_LENGTH"
26
+ ];
27
+ /** The one error class the package throws for conditions it detects itself: a stable `code` and frozen `details` (spec 3.3). */
28
+ export declare class WebGpuGraphError extends Error {
29
+ /** The stable code. */
30
+ readonly code: WebGpuGraphErrorCode;
31
+ /** Frozen shallow copy of the details given to the constructor (`{}` when none). */
32
+ readonly details: Readonly<Record<string, unknown>>;
33
+ /** `name` is always "WebGpuGraphError". */
34
+ readonly name: "WebGpuGraphError";
35
+ /**
36
+ * Create a WebGpuGraphError.
37
+ * @param code - the stable code the caller can branch on
38
+ * @param message - a plain-ASCII human-readable message naming the offending label, limit or value
39
+ * @param details - optional machine-readable context; copied shallowly and frozen
40
+ */
41
+ constructor(code: WebGpuGraphErrorCode, message: string, details?: Record<string, unknown>);
42
+ }
43
+ /**
44
+ * Brand check that survives two package copies: `name === "WebGpuGraphError"` and a string `code`.
45
+ * @param x - anything, typically a caught value
46
+ * @returns true when `x` is structurally a WebGpuGraphError (instanceof is NOT required)
47
+ */
48
+ export declare function isWebGpuGraphError(x: unknown): x is WebGpuGraphError;
49
+ /**
50
+ * Brand check that survives two package copies: `code === x.code` for an `isWebGpuGraphError(x)`.
51
+ * @param x - anything, typically a caught value
52
+ * @param code - the code to test for
53
+ * @returns true when `x` is a WebGpuGraphError carrying `code`
54
+ */
55
+ export declare function hasErrorCode(x: unknown, code: WebGpuGraphErrorCode): boolean;
56
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,wFAAwF;AACxF,MAAM,MAAM,oBAAoB,GAC1B,aAAa,GACb,cAAc,GACd,aAAa,GACb,iBAAiB,GACjB,eAAe,GACf,YAAY,GACZ,cAAc,GACd,kBAAkB,GAClB,iBAAiB,GACjB,aAAa,GACb,eAAe,GACf,oBAAoB,GACpB,YAAY,GACZ,YAAY,GACZ,cAAc,GACd,WAAW,CAAC;AAElB,yJAAyJ;AACzJ,eAAO,MAAM,wBAAwB,EAAE,SAAS;IAC5C,kBAAkB;IAClB,gBAAgB;IAChB,kBAAkB;IAClB,iBAAiB;CACoF,CAAC;AAI1G,gIAAgI;AAChI,qBAAa,gBAAiB,SAAQ,KAAK;IACvC,uBAAuB;IACvB,QAAQ,CAAC,IAAI,EAAE,oBAAoB,CAAC;IAEpC,oFAAoF;IACpF,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAEpD,2CAA2C;IAC3C,SAAkB,IAAI,EAAE,kBAAkB,CAAC;IAE3C;;;;;OAKG;gBACS,IAAI,EAAE,oBAAoB,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAM7F;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,gBAAgB,CAMpE;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,oBAAoB,GAAG,OAAO,CAE5E"}
@@ -0,0 +1,57 @@
1
+ /**
2
+ * The error class and the closed code set of @graphty/webgpu-graph-algorithms (spec 3.3, 5.7; contract 3.1).
3
+ *
4
+ * Every condition the package detects itself is thrown as a WebGpuGraphError carrying a stable `code` and a
5
+ * frozen shallow copy of the `details` the thrower supplied. Errors raised by @graphty/graph-format accessors
6
+ * the package calls on the caller's behalf pass through unchanged (D12); PASSTHROUGH_FORMAT_CODES lists the
7
+ * codes a public call may let escape. Constructors never throw. Messages are plain ASCII.
8
+ *
9
+ * `details` keys per code (contract 3.1, so tests can assert them): E_NO_WEBGPU { reason, hint };
10
+ * E_NO_ADAPTER { reason }; E_NO_DEVICE { reason, adapter, limit?, requested?, available? } (reason "consumed" |
11
+ * "requestDevice" | "limit" | "feature" | "maxComputeWorkgroupsPerDimension"); E_SOFTWARE_ONLY { adapter };
12
+ * E_DEVICE_LOST { reason, message }; E_DISPOSED { label }; E_VALIDATION { label, message, batchId? };
13
+ * E_SHADER_COMPILE { id, stage: "compose" | "compile", slot?, messages? }; E_OUT_OF_MEMORY { requested, resident,
14
+ * label }; E_TOO_LARGE { needed, limit, path, algorithm }; E_UNSUPPORTED { feature? | option?, hint? } (exactly
15
+ * one of feature / option); E_INVALID_ARGUMENT { argument, value, expected? }; E_SNAPSHOT { reason, serial };
16
+ * E_RELEASED { serial }; E_NOT_LOADED { state }; E_ABORTED { batchId? }.
17
+ */
18
+ /** The graph-format error codes a public call lets propagate unchanged (D12, spec 5.7): raised by accessors the package calls on the caller's behalf. */
19
+ export const PASSTHROUGH_FORMAT_CODES = Object.freeze(["E_GPU_INELIGIBLE", "E_UNKNOWN_NODE", "E_UNKNOWN_COLUMN", "E_COLUMN_LENGTH"]);
20
+ const EMPTY_DETAILS = Object.freeze({});
21
+ /** The one error class the package throws for conditions it detects itself: a stable `code` and frozen `details` (spec 3.3). */
22
+ export class WebGpuGraphError extends Error {
23
+ /**
24
+ * Create a WebGpuGraphError.
25
+ * @param code - the stable code the caller can branch on
26
+ * @param message - a plain-ASCII human-readable message naming the offending label, limit or value
27
+ * @param details - optional machine-readable context; copied shallowly and frozen
28
+ */
29
+ constructor(code, message, details) {
30
+ super(message);
31
+ this.name = "WebGpuGraphError";
32
+ this.code = code;
33
+ this.details = details === undefined ? EMPTY_DETAILS : Object.freeze({ ...details });
34
+ }
35
+ }
36
+ /**
37
+ * Brand check that survives two package copies: `name === "WebGpuGraphError"` and a string `code`.
38
+ * @param x - anything, typically a caught value
39
+ * @returns true when `x` is structurally a WebGpuGraphError (instanceof is NOT required)
40
+ */
41
+ export function isWebGpuGraphError(x) {
42
+ if (typeof x !== "object" || x === null) {
43
+ return false;
44
+ }
45
+ const candidate = x;
46
+ return candidate.name === "WebGpuGraphError" && typeof candidate.code === "string";
47
+ }
48
+ /**
49
+ * Brand check that survives two package copies: `code === x.code` for an `isWebGpuGraphError(x)`.
50
+ * @param x - anything, typically a caught value
51
+ * @param code - the code to test for
52
+ * @returns true when `x` is a WebGpuGraphError carrying `code`
53
+ */
54
+ export function hasErrorCode(x, code) {
55
+ return isWebGpuGraphError(x) && x.code === code;
56
+ }
57
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAqBH,yJAAyJ;AACzJ,MAAM,CAAC,MAAM,wBAAwB,GAKjC,MAAM,CAAC,MAAM,CAAC,CAAC,kBAAkB,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,iBAAiB,CAAU,CAAC,CAAC;AAE1G,MAAM,aAAa,GAAsC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AAE3E,gIAAgI;AAChI,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IAUvC;;;;;OAKG;IACH,YAAY,IAA0B,EAAE,OAAe,EAAE,OAAiC;QACtF,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;QAC/B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,OAAO,GAAG,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACzF,CAAC;CACJ;AAED;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,CAAU;IACzC,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC;QACtC,OAAO,KAAK,CAAC;IACjB,CAAC;IACD,MAAM,SAAS,GAAG,CAAyD,CAAC;IAC5E,OAAO,SAAS,CAAC,IAAI,KAAK,kBAAkB,IAAI,OAAO,SAAS,CAAC,IAAI,KAAK,QAAQ,CAAC;AACvF,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,CAAU,EAAE,IAA0B;IAC/D,OAAO,kBAAkB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC;AACpD,CAAC"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * The public barrel of @graphty/webgpu-graph-algorithms (spec 2.5, 3.3; contract 3.15): explicit named exports only,
3
+ * values and `export type`, no star re-exports, no default export, nothing from src/browser/** or src/node/** (their
4
+ * own entries; imported by nothing else in src/, 2.4) and nothing of the internal surface (GraphResidency,
5
+ * BufferPool, Readback, Lease, PipelineCache, Kernel, CommandBatch, UniformRing, UniformBlock, composeWgsl, KERNELS,
6
+ * ForceSimulation, ForceAtlas2Model: tests import them from their files). P0: the error class, the constants and
7
+ * isSoftwareAdapter. P1 adds GpuContext and degree (values) and the context / run / profiler types. P2 adds nothing
8
+ * (Lease, CommandBatch, UniformRing are internal). P3 adds the layout factory, the accelerator, the two default
9
+ * tables, the seeder and the layout / accelerator types. test/index.test.ts pins the value list and
10
+ * test/types/public-api.test-d.ts the type list; P4+ extends both. This comment must never spell the internal
11
+ * JSDoc tag: it is the leading comment of the first export statement, and stripInternal would drop that statement
12
+ * from the emitted declarations.
13
+ */
14
+ /// <reference types="@webgpu/types" preserve="true" />
15
+ export { ARC_WINDOW_ALIGN, EXACT_MAX_NODES, FA2_DEFAULTS, LAYOUT_TUNING_DEFAULTS, MAX_1D_ITEMS, MAX_WORKGROUPS_PER_DIM, STORAGE_ALIGN, WORKGROUP_SIZE, } from "./constants.js";
16
+ export { hasErrorCode, isWebGpuGraphError, PASSTHROUGH_FORMAT_CODES, WebGpuGraphError, type WebGpuGraphErrorCode, } from "./errors.js";
17
+ export { GpuContext } from "./context.js";
18
+ export { isSoftwareAdapter } from "./device/acquire.js";
19
+ export type { PassTiming, Profiler } from "./kernel/profiler.js";
20
+ export { degree } from "./algorithms/degree.js";
21
+ export { createAccelerator } from "./accelerator.js";
22
+ export { createForceAtlas2 } from "./layouts/forceatlas2.js";
23
+ export { seedPositions } from "./layouts/seed.js";
24
+ export type { AcceleratorOptions, AlgorithmAccelerator, ApspResultLike, BellmanFordResultLike, BfsResultLike, CommunityResultLike, CorenessResultLike, CpuAlgorithmOptions, EdgeScoresResultLike, GpuAccelerator, HitsResultLike, LabelResultLike, LayoutAccelerator, LayoutSimulation, MstResultLike, PageRankResultLike, ScoresResultLike, SsspResultLike, } from "./types/accelerator.js";
25
+ export type { AdapterInfoLike, AdapterSummary, GpuCaps, GpuContextOptions, LimitPolicy, PlanCaps, PlanLimits, ProbeOptions, ProbeResult, RaisableLimit, } from "./types/context.js";
26
+ export type { ForceAtlas2Stats, ForceAtlas2TraceRecord, GpuLayoutSimulation, GpuLayoutTuning, LayoutStatsBase, RunOptions, } from "./types/layout.js";
27
+ export type { CommonLayoutOptions, ForceAtlas2Options, FruchtermanReingoldOptions, SimulationOptions, SpringElectricalOptions, } from "./types/options.js";
28
+ export type { GpuRunOptions } from "./types/run.js";
29
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;GAYG;;AAGH,OAAO,EACH,gBAAgB,EAChB,eAAe,EACf,YAAY,EACZ,sBAAsB,EACtB,YAAY,E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,EAAE,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,27 @@
1
+ /// <reference types="@webgpu/types" preserve="true" />
2
+ /**
3
+ * The public barrel of @graphty/webgpu-graph-algorithms (spec 2.5, 3.3; contract 3.15): explicit named exports only,
4
+ * values and `export type`, no star re-exports, no default export, nothing from src/browser/** or src/node/** (their
5
+ * own entries; imported by nothing else in src/, 2.4) and nothing of the internal surface (GraphResidency,
6
+ * BufferPool, Readback, Lease, PipelineCache, Kernel, CommandBatch, UniformRing, UniformBlock, composeWgsl, KERNELS,
7
+ * ForceSimulation, ForceAtlas2Model: tests import them from their files). P0: the error class, the constants and
8
+ * isSoftwareAdapter. P1 adds GpuContext and degree (values) and the context / run / profiler types. P2 adds nothing
9
+ * (Lease, CommandBatch, UniformRing are internal). P3 adds the layout factory, the accelerator, the two default
10
+ * tables, the seeder and the layout / accelerator types. test/index.test.ts pins the value list and
11
+ * test/types/public-api.test-d.ts the type list; P4+ extends both. This comment must never spell the internal
12
+ * JSDoc tag: it is the leading comment of the first export statement, and stripInternal would drop that statement
13
+ * from the emitted declarations.
14
+ */
15
+ // ==================== constants and errors (P0; FA2_DEFAULTS / LAYOUT_TUNING_DEFAULTS public from P3)
16
+ export { ARC_WINDOW_ALIGN, EXACT_MAX_NODES, FA2_DEFAULTS, LAYOUT_TUNING_DEFAULTS, MAX_1D_ITEMS, MAX_WORKGROUPS_PER_DIM, STORAGE_ALIGN, WORKGROUP_SIZE, } from "./constants.js";
17
+ export { hasErrorCode, isWebGpuGraphError, PASSTHROUGH_FORMAT_CODES, WebGpuGraphError, } from "./errors.js";
18
+ // ==================== context, adapter classifier, profiler (P0 / P1)
19
+ export { GpuContext } from "./context.js";
20
+ export { isSoftwareAdapter } from "./device/acquire.js";
21
+ // ==================== algorithms (P1: the walking-skeleton diagnostic, spec 3.3)
22
+ export { degree } from "./algorithms/degree.js";
23
+ // ==================== layouts and the accelerator (P3)
24
+ export { createAccelerator } from "./accelerator.js";
25
+ export { createForceAtlas2 } from "./layouts/forceatlas2.js";
26
+ export { seedPositions } from "./layouts/seed.js";
27
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD;;;;;;;;;;;;GAYG;AAEH,uGAAuG;AACvG,OAAO,EACH,gBAAgB,EAChB,eAAe,EACf,YAAY,EACZ,sBAAsB,EACtB,YAAY,EACZ,sBAAsB,EACtB,aAAa,EACb,cAAc,GACjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACH,YAAY,EACZ,kBAAkB,EAClB,wBAAwB,EACxB,gBAAgB,GAEnB,MAAM,aAAa,CAAC;AAErB,uEAAuE;AACvE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAGxD,kFAAkF;AAClF,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAEhD,wDAAwD;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC"}