space-data-module-sdk 0.11.0 → 0.13.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.
- package/docs/gpu-module-abi.html +19 -9
- package/docs/gpu-module-abi.md +34 -10
- package/docs/isomorphic-pthreads.html +10 -0
- package/package.json +3 -2
- package/src/index.d.ts +406 -0
- package/src/runtime-host/ephemerisGridStore.js +1688 -0
- package/src/runtime-host/gpuComputeContext.js +394 -0
- package/src/runtime-host/index.js +115 -1
- package/src/runtime-host/runtimeRegionStore.js +382 -3
- package/templates/gpu-module/include/space_data_gpu_abi.h +71 -5
- package/templates/gpu-module/manifest.json +2 -2
package/docs/gpu-module-abi.html
CHANGED
|
@@ -109,11 +109,11 @@
|
|
|
109
109
|
<p>GPU-capable modules declare the coarse capability id:</p>
|
|
110
110
|
<div class="codeblock"><div class="codeblock-head">json</div><pre><code>{
|
|
111
111
|
"capability": "gpu_compute",
|
|
112
|
-
"scope": "webgpu.
|
|
112
|
+
"scope": "webgpu.v2",
|
|
113
113
|
"required": false,
|
|
114
|
-
"description": "Optional WebGPU/Dawn compute acceleration."
|
|
114
|
+
"description": "Optional WebGPU/Dawn compute acceleration with shared host-owned device and buffer handles."
|
|
115
115
|
}</code></pre></div>
|
|
116
|
-
<p>Use <code>required: false</code> unless the module has no correct CPU path. A missing GPU adapter must degrade to the module's CPU implementation, not to an incomplete result.</p>
|
|
116
|
+
<p>Use <code>scope: "webgpu.v1"</code> for single-module byte-returning dispatch or <code>scope: "webgpu.v2"</code> when exchanging opaque shared <code>GPUBuffer</code> handles on a host-owned <code>GPUDevice</code>. Use <code>required: false</code> unless the module has no correct CPU path. A missing GPU adapter must degrade to the module's CPU implementation, not to an incomplete result.</p>
|
|
117
117
|
<p>The <code>gpu_compute</code> id is part of the SDK recommended capability vocabulary. The typed PLG <code>HOST_CAPABILITIES</code> enum cannot carry a dedicated GPU enum value until the canonical standards schema adds one. Until that SDS change lands, module manifests should use the string/object capability form above and avoid claiming a typed PLG host capability enum for GPU.</p>
|
|
118
118
|
<h2 id="artifact-layout"><a class="anchor" href="#artifact-layout" aria-hidden="true">#</a>Artifact Layout</h2>
|
|
119
119
|
<p>The canonical portable artifact remains:</p>
|
|
@@ -137,10 +137,17 @@ dist/wasmedge/gpu-host.{so,dylib,dll}</code></pre></div>
|
|
|
137
137
|
<li>packed dispatch/result descriptors</li>
|
|
138
138
|
</ul>
|
|
139
139
|
<p>All multi-byte fields are little-endian in serialized buffers. Structs in the header are fixed-width and intentionally avoid owning pointers. Pointers are runtime-local implementation details and must not appear in durable manifests, publication metadata, or cross-process descriptors.</p>
|
|
140
|
-
<h3 id="2-host-dispatch-abi"><a class="anchor" href="#2-host-dispatch-abi" aria-hidden="true">#</a>2. Host Dispatch ABI</h3>
|
|
141
|
-
<p>The canonical
|
|
142
|
-
<div class="codeblock"><div class="codeblock-head">text</div><pre><code>gpu_compute.
|
|
143
|
-
|
|
140
|
+
<h3 id="2-host-dispatch-shared-buffer-abi-v2"><a class="anchor" href="#2-host-dispatch-shared-buffer-abi-v2" aria-hidden="true">#</a>2. Host Dispatch & Shared Buffer ABI (v2)</h3>
|
|
141
|
+
<p>The canonical operations are:</p>
|
|
142
|
+
<div class="codeblock"><div class="codeblock-head">text</div><pre><code>gpu_compute.device.info.v1
|
|
143
|
+
gpu_compute.buffer.create.v1
|
|
144
|
+
gpu_compute.buffer.describe.v1
|
|
145
|
+
gpu_compute.buffer.read.v1
|
|
146
|
+
gpu_compute.buffer.release.v1
|
|
147
|
+
gpu_compute.dispatch.v1</code></pre></div>
|
|
148
|
+
<p>In ABI v2 (<code>SDN_GPU_ABI_VERSION = 2</code>, scope <code>webgpu.v2</code>), the host owns ONE shared <code>GPUDevice</code> (<code>createSharedGpuContext</code> in <code>space-data-module-sdk/runtime-host</code>) and assigns opaque integer buffer handles (<code>SdnGpuBufferHandle { handle_id, device_id, byte_length, role, scalar_format, record_stride, flags }</code>). Independent modules (for example a propagator such as <code>propagator/sdn-ap</code> and a screener such as <code>analysis/conjunction-assessment</code>) pass handles on the same <code>device_id</code> directly into compute bind groups without copying buffers back through CPU memory.</p>
|
|
149
|
+
<p><code>detectWebGpu()</code> probes host GPU availability without throwing and returns <code>backendKind: "cpu-fallback"</code> when no WebGPU/Dawn adapter is present.</p>
|
|
150
|
+
<p>The host dispatch adapter receives:</p>
|
|
144
151
|
<ul>
|
|
145
152
|
<li>an ABI version</li>
|
|
146
153
|
<li>a stable kernel id</li>
|
|
@@ -174,7 +181,10 @@ dist/wasmedge/gpu-host.{so,dylib,dll}</code></pre></div>
|
|
|
174
181
|
<p>WasmEdge deployments that need GPU acceleration should use a native host extension linked against Dawn. The native host implements the same <code>gpu_compute.dispatch.v1</code> operation and uses the same C/C++ layout header.</p>
|
|
175
182
|
<p>The shared module artifact should still be loadable without that extension. A pure <code>["wasmedge"]</code> artifact may choose a higher-capability native host profile, but a <code>["browser", "wasmedge"]</code> artifact must retain the portable fallback contract documented in <code>docs/browser-wasmedge-isomorphic.md</code>.</p>
|
|
176
183
|
<h2 id="numerical-rules"><a class="anchor" href="#numerical-rules" aria-hidden="true">#</a>Numerical Rules</h2>
|
|
177
|
-
<p>GPU kernels that need
|
|
184
|
+
<p>GPU kernels that need full 64-bit IEEE-754 precision (bit-for-bit identical to WASM <code>f64</code>, 0 ULP) MUST use <code>SDN_GPU_SCALAR_FORMAT_IEEE754_F64_U32X2</code> (<code>vec2<u32></code> little-endian <code>(lo, hi)</code> pairs) with exact IEEE-754 round-to-nearest-even software arithmetic in WGSL:</p>
|
|
185
|
+
<div class="codeblock"><div class="codeblock-head">c</div><pre><code>SdnGpuF64Bits x = sdn_gpu_pack_f64(value);
|
|
186
|
+
double back = sdn_gpu_unpack_f64(x);</code></pre></div>
|
|
187
|
+
<p>GPU broadphase kernels that only need ~48-bit position precision may continue to use split high/low <code>f32</code> values (<code>SDN_GPU_SCALAR_FORMAT_SPLIT_F64</code>):</p>
|
|
178
188
|
<div class="codeblock"><div class="codeblock-head">c</div><pre><code>SdnGpuSplitF64 x = sdn_gpu_split_f64(x_km);</code></pre></div>
|
|
179
189
|
<p>For orbital screening, store position components in kilometers unless a module contract states otherwise. The high component is the nearest <code>f32</code>; the low component is the residual:</p>
|
|
180
190
|
<div class="codeblock"><div class="codeblock-head">text</div><pre><code>hi = f32(value)
|
|
@@ -202,7 +212,7 @@ lo = f32(value - f64(hi))</code></pre></div>
|
|
|
202
212
|
<li><a class="depth-2" href="#artifact-layout">Artifact Layout</a></li>
|
|
203
213
|
<li><a class="depth-2" href="#abi-layers">ABI Layers</a></li>
|
|
204
214
|
<li><a class="depth-3" href="#1-data-layout-abi">1. Data Layout ABI</a></li>
|
|
205
|
-
<li><a class="depth-3" href="#2-host-dispatch-abi">2. Host Dispatch ABI</a></li>
|
|
215
|
+
<li><a class="depth-3" href="#2-host-dispatch-shared-buffer-abi-v2">2. Host Dispatch & Shared Buffer ABI (v2)</a></li>
|
|
206
216
|
<li><a class="depth-3" href="#3-module-level-api">3. Module-Level API</a></li>
|
|
207
217
|
<li><a class="depth-2" href="#browser-backend">Browser Backend</a></li>
|
|
208
218
|
<li><a class="depth-2" href="#wasmedge-backend">WasmEdge Backend</a></li>
|
package/docs/gpu-module-abi.md
CHANGED
|
@@ -25,15 +25,13 @@ GPU-capable modules declare the coarse capability id:
|
|
|
25
25
|
```json
|
|
26
26
|
{
|
|
27
27
|
"capability": "gpu_compute",
|
|
28
|
-
"scope": "webgpu.
|
|
28
|
+
"scope": "webgpu.v2",
|
|
29
29
|
"required": false,
|
|
30
|
-
"description": "Optional WebGPU/Dawn compute acceleration."
|
|
30
|
+
"description": "Optional WebGPU/Dawn compute acceleration with shared host-owned device and buffer handles."
|
|
31
31
|
}
|
|
32
32
|
```
|
|
33
33
|
|
|
34
|
-
Use `required: false` unless the module has no correct CPU path. A missing GPU
|
|
35
|
-
adapter must degrade to the module's CPU implementation, not to an incomplete
|
|
36
|
-
result.
|
|
34
|
+
Use `scope: "webgpu.v1"` for single-module byte-returning dispatch or `scope: "webgpu.v2"` when exchanging opaque shared `GPUBuffer` handles on a host-owned `GPUDevice`. Use `required: false` unless the module has no correct CPU path. A missing GPU adapter must degrade to the module's CPU implementation, not to an incomplete result.
|
|
37
35
|
|
|
38
36
|
The `gpu_compute` id is part of the SDK recommended capability vocabulary. The
|
|
39
37
|
typed PLG `HOST_CAPABILITIES` enum cannot carry a dedicated GPU enum value
|
|
@@ -86,15 +84,31 @@ header are fixed-width and intentionally avoid owning pointers. Pointers are
|
|
|
86
84
|
runtime-local implementation details and must not appear in durable manifests,
|
|
87
85
|
publication metadata, or cross-process descriptors.
|
|
88
86
|
|
|
89
|
-
### 2. Host Dispatch ABI
|
|
87
|
+
### 2. Host Dispatch & Shared Buffer ABI (v2)
|
|
90
88
|
|
|
91
|
-
The canonical
|
|
89
|
+
The canonical operations are:
|
|
92
90
|
|
|
93
91
|
```text
|
|
92
|
+
gpu_compute.device.info.v1
|
|
93
|
+
gpu_compute.buffer.create.v1
|
|
94
|
+
gpu_compute.buffer.describe.v1
|
|
95
|
+
gpu_compute.buffer.read.v1
|
|
96
|
+
gpu_compute.buffer.release.v1
|
|
94
97
|
gpu_compute.dispatch.v1
|
|
95
98
|
```
|
|
96
99
|
|
|
97
|
-
|
|
100
|
+
In ABI v2 (`SDN_GPU_ABI_VERSION = 2`, scope `webgpu.v2`), the host owns ONE shared
|
|
101
|
+
`GPUDevice` (`createSharedGpuContext` in `space-data-module-sdk/runtime-host`) and
|
|
102
|
+
assigns opaque integer buffer handles (`SdnGpuBufferHandle { handle_id, device_id,
|
|
103
|
+
byte_length, role, scalar_format, record_stride, flags }`). Independent modules
|
|
104
|
+
(for example a propagator such as `propagator/sdn-ap` and a screener such as
|
|
105
|
+
`analysis/conjunction-assessment`) pass handles on the same `device_id` directly
|
|
106
|
+
into compute bind groups without copying buffers back through CPU memory.
|
|
107
|
+
|
|
108
|
+
`detectWebGpu()` probes host GPU availability without throwing and returns
|
|
109
|
+
`backendKind: "cpu-fallback"` when no WebGPU/Dawn adapter is present.
|
|
110
|
+
|
|
111
|
+
The host dispatch adapter receives:
|
|
98
112
|
|
|
99
113
|
- an ABI version
|
|
100
114
|
- a stable kernel id
|
|
@@ -153,8 +167,18 @@ contract documented in `docs/browser-wasmedge-isomorphic.md`.
|
|
|
153
167
|
|
|
154
168
|
## Numerical Rules
|
|
155
169
|
|
|
156
|
-
GPU kernels that need
|
|
157
|
-
`
|
|
170
|
+
GPU kernels that need full 64-bit IEEE-754 precision (bit-for-bit identical to
|
|
171
|
+
WASM `f64`, 0 ULP) MUST use `SDN_GPU_SCALAR_FORMAT_IEEE754_F64_U32X2` (`vec2<u32>`
|
|
172
|
+
little-endian `(lo, hi)` pairs) with exact IEEE-754 round-to-nearest-even software
|
|
173
|
+
arithmetic in WGSL:
|
|
174
|
+
|
|
175
|
+
```c
|
|
176
|
+
SdnGpuF64Bits x = sdn_gpu_pack_f64(value);
|
|
177
|
+
double back = sdn_gpu_unpack_f64(x);
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
GPU broadphase kernels that only need ~48-bit position precision may continue to
|
|
181
|
+
use split high/low `f32` values (`SDN_GPU_SCALAR_FORMAT_SPLIT_F64`):
|
|
158
182
|
|
|
159
183
|
```c
|
|
160
184
|
SdnGpuSplitF64 x = sdn_gpu_split_f64(x_km);
|
|
@@ -216,6 +216,16 @@ setBrowserWasiThreadWorkerBase("js/vendor/space-data-module-sdk/src/host/&q
|
|
|
216
216
|
<h2 id="5-flatsql-partition-store-host-io-sdk-0822"><a class="anchor" href="#5-flatsql-partition-store-host-io-sdk-0822" aria-hidden="true">#</a>5. FlatSQL partition store host I/O (SDK 0.8.22)</h2>
|
|
217
217
|
<p>The FlatSQL partition store (stack design <code>docs/architecture/flatsql-partition-store.md</code>, §5.5, §5.6, §18 T9, A7, A36, A38, A39) runs one wasi-threads artifact as a writer instance and reader instances, each with guest threads that call FlatSQL's seven <code>env.flatsql_io_*</code> imports. This section is the SDK half: the thread pool, the I/O channel and workers, the Node provider, link shim v2, the worker bundles and the browser capability probe.</p>
|
|
218
218
|
<h3 id="explicit-pool-size-partial-spawns-supervision-hooks"><a class="anchor" href="#explicit-pool-size-partial-spawns-supervision-hooks" aria-hidden="true">#</a>Explicit pool size, partial spawns, supervision hooks</h3>
|
|
219
|
+
<p><code>createBrowserModuleHarness</code> accepts <code>wasiThreadProbeTimeoutMs</code>, the browser pool arming deadline in milliseconds. It forwards the value as <code>createWasiThreadSpawn</code>'s <code>probeTimeoutMs</code>. The default is 1500. An explicit value must be a positive finite number; invalid values throw an <code>Error</code> before the artifact is loaded. The option applies to the initial context and each fresh command invocation. It has no effect on Node's on-demand pool startup.</p>
|
|
220
|
+
<p>After harness creation, the read-only <code>harness.wasiThreadPoolReport</code> property returns a frozen <code>{ requested, armed }</code> snapshot. Counts refer to pool workers and exclude the calling thread. With <code>wasiThreadPoolSize</code>, <code>requested</code> is that explicit size, including when threading is unavailable. Without an explicit size, it is the browser's selected pool size. Non-threaded artifacts return <code>null</code>. Node reports its explicit cap (or <code>null</code> without one) and the number of workers started on demand.</p>
|
|
221
|
+
<p>For an explicit browser pool, fewer armed workers do not throw. Workers that miss the deadline are terminated before the harness returns; successfully armed workers remain available. The host uses the report to decide whether the capacity meets its needs. A guest must handle declined spawns to execute successfully with fewer workers. After a command invocation, the property reports that invocation's arming counts, even though its pool is terminated. These are startup counts, not a live-worker health report.</p>
|
|
222
|
+
<div class="codeblock"><div class="codeblock-head">js</div><pre><code>const harness = await createBrowserModuleHarness({
|
|
223
|
+
wasmSource,
|
|
224
|
+
enableBrowserWasiThreads: true,
|
|
225
|
+
wasiThreadPoolSize: 8,
|
|
226
|
+
wasiThreadProbeTimeoutMs: 10000,
|
|
227
|
+
});
|
|
228
|
+
const { requested, armed } = harness.wasiThreadPoolReport;</code></pre></div>
|
|
219
229
|
<p><code>createWasiThreadSpawn</code> options added in 0.8.22:</p>
|
|
220
230
|
<div class="table-wrap"><table><thead><tr><th>Option</th><th>Effect</th></tr></thead><tbody><tr><td><code>poolSize</code></td><td>Browser: pre-start exactly this many workers, independent of <code>hardwareConcurrency - 1</code> (pools are sized for isolation: writers + lanes). Node: cap on live guest threads (the pool grows to it on demand; without it, to 1024). Arming is partial: workers that fail to start are dropped, the rest serve.</td></tr><tr><td><code>extraImports</code></td><td>Per-worker import objects, as structured-cloneable descriptors (below). Factories run once per worker.</td></tr><tr><td><code>instanceId</code>, <code>onGuestError(instanceId, tid, error)</code></td><td>Called when a guest thread traps or its worker dies (A36). A dead pooled worker leaves the pool. In Node, for workers the owning thread started.</td></tr><tr><td><code>onSpawnDeclined({ reason, poolSize, declined })</code></td><td>Called for every spawn from the owning thread that returns -1. Reasons: <code>pool-exhausted</code>, <code>pool-not-armed</code>, <code>threads-unavailable</code>, <code>pool-empty</code>, <code>worker-create-failed</code>, <code>dispatch-failed</code>, <code>hostcall-channel-missing</code>, <code>terminated</code>.</td></tr><tr><td><code>probeTimeoutMs</code></td><td>Browser warm-pool probe deadline.</td></tr><tr><td><code>spawnWaitMs</code></td><td>How long a spawn that finds every pool thread busy waits for one to finish before it returns -1 (default 250; 0 never waits). Added in 0.8.25; see "one pool protocol" in §3.</td></tr><tr><td><code>browserWorkerType: "classic"</code></td><td>Spawn classic workers, for the blob bundles below.</td></tr></tbody></table></div>
|
|
221
231
|
<p>The returned host adds <code>spawnReport()</code>: <code>{ poolSize, armed, failedToArm, spawned, waited, declined, declinedByReason, lastDeclineReason, active, idle }</code> (Node adds <code>workers</code>). The counts cover spawns from every thread of the process. The implicit (no <code>poolSize</code>) path keeps its all-or-nothing arming.</p>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "space-data-module-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "Module SDK for building, validating, signing, and deploying WebAssembly modules on the Space Data Network.",
|
|
6
6
|
"type": "module",
|
|
@@ -122,6 +122,7 @@
|
|
|
122
122
|
"generate:propagator-abi": "node scripts/generate-propagator-abi.mjs",
|
|
123
123
|
"generate:vectors": "node ./examples/single-file-bundle/generate-vectors.mjs",
|
|
124
124
|
"prepublishOnly": "npm test && npm run check:compliance && npm run check:generated-bindings",
|
|
125
|
+
"e2e:shared-ephemeris-grid": "node scripts/e2e/shared-ephemeris-grid.mjs",
|
|
125
126
|
"playground:build": "node ./playground/build.mjs",
|
|
126
127
|
"playground:serve": "node ./playground/build.mjs && node ./playground/server.mjs",
|
|
127
128
|
"playground:gate": "node ./playground/build.mjs && node ./playground/test/browser-gate.mjs",
|
|
@@ -133,7 +134,7 @@
|
|
|
133
134
|
"flatsql": "3.12.1",
|
|
134
135
|
"hd-wallet-wasm": "2.2.2",
|
|
135
136
|
"sdn-emception": "1.0.0",
|
|
136
|
-
"spacedatastandards.org": "1.
|
|
137
|
+
"spacedatastandards.org": "1.312.0"
|
|
137
138
|
},
|
|
138
139
|
"devDependencies": {
|
|
139
140
|
"esbuild": "^0.28.0",
|
package/src/index.d.ts
CHANGED
|
@@ -461,6 +461,38 @@ export interface RuntimeRegionDescriptor {
|
|
|
461
461
|
recordByteLength: number;
|
|
462
462
|
alignment: number;
|
|
463
463
|
recordCount: number;
|
|
464
|
+
kind?: "owned" | "external" | "contiguous";
|
|
465
|
+
shared?: boolean;
|
|
466
|
+
generation?: number;
|
|
467
|
+
byteLength?: number;
|
|
468
|
+
activeConsumers?: number;
|
|
469
|
+
invalidated?: boolean;
|
|
470
|
+
metadata?: unknown;
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
export interface RuntimeRegionArena {
|
|
474
|
+
regionId: number;
|
|
475
|
+
buffer: ArrayBufferLike;
|
|
476
|
+
byteOffset: number;
|
|
477
|
+
byteLength: number;
|
|
478
|
+
bytes: Uint8Array;
|
|
479
|
+
shared: boolean;
|
|
480
|
+
alignment: number;
|
|
481
|
+
generation: number;
|
|
482
|
+
recordCount: number;
|
|
483
|
+
recordByteLength: number;
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
export interface RuntimeRegionConsumerLease {
|
|
487
|
+
readonly leaseId: number;
|
|
488
|
+
readonly regionId: number;
|
|
489
|
+
readonly consumerId: string;
|
|
490
|
+
readonly mode: "read-only";
|
|
491
|
+
readonly roleMask: number | null;
|
|
492
|
+
readonly generation: number;
|
|
493
|
+
isCurrent(): boolean;
|
|
494
|
+
assertCurrent(): boolean;
|
|
495
|
+
detach(): boolean;
|
|
464
496
|
}
|
|
465
497
|
|
|
466
498
|
export interface RuntimeRegionRecord {
|
|
@@ -481,6 +513,9 @@ export interface RuntimeRegionExternalRecordView {
|
|
|
481
513
|
alignment: number;
|
|
482
514
|
byteOffset?: number;
|
|
483
515
|
buffer?: ArrayBufferLike;
|
|
516
|
+
shared?: boolean;
|
|
517
|
+
generation?: number;
|
|
518
|
+
bytes?: Uint8Array;
|
|
484
519
|
elementType?: string;
|
|
485
520
|
elementCount?: number;
|
|
486
521
|
strideElements?: number;
|
|
@@ -499,6 +534,15 @@ export interface RuntimeRegionStore {
|
|
|
499
534
|
alignment?: number;
|
|
500
535
|
initialRecords?: Array<Uint8Array | ArrayBuffer | ArrayBufferView | null | undefined>;
|
|
501
536
|
}): RuntimeRegionDescriptor;
|
|
537
|
+
allocateContiguousRegion(options: {
|
|
538
|
+
layoutId: string;
|
|
539
|
+
recordByteLength: number;
|
|
540
|
+
alignment?: number;
|
|
541
|
+
recordCount?: number;
|
|
542
|
+
shared?: boolean;
|
|
543
|
+
initialBytes?: Uint8Array | ArrayBuffer | ArrayBufferView | null;
|
|
544
|
+
metadata?: unknown;
|
|
545
|
+
}): RuntimeRegionDescriptor;
|
|
502
546
|
registerExternalRegion(options: {
|
|
503
547
|
layoutId: string;
|
|
504
548
|
recordByteLength: number;
|
|
@@ -521,12 +565,342 @@ export interface RuntimeRegionStore {
|
|
|
521
565
|
}): RuntimeRegionDescriptor;
|
|
522
566
|
setRegionRecordCount(regionId: number, recordCount: number): RuntimeRegionDescriptor | null;
|
|
523
567
|
describeRegion(regionId: number): RuntimeRegionDescriptor | null;
|
|
568
|
+
getRegionArena(regionId: number): RuntimeRegionArena | null;
|
|
569
|
+
updateContiguousRecord(options: {
|
|
570
|
+
regionId: number;
|
|
571
|
+
recordIndex: number;
|
|
572
|
+
bytes: Uint8Array | ArrayBuffer | ArrayBufferView | null | undefined;
|
|
573
|
+
bumpGeneration?: boolean;
|
|
574
|
+
}): {
|
|
575
|
+
regionId: number;
|
|
576
|
+
recordIndex: number;
|
|
577
|
+
generation: number;
|
|
578
|
+
byteLength: number;
|
|
579
|
+
};
|
|
580
|
+
resizeContiguousRegion(
|
|
581
|
+
regionId: number,
|
|
582
|
+
newRecordCount: number,
|
|
583
|
+
options?: { shared?: boolean },
|
|
584
|
+
): RuntimeRegionDescriptor | null;
|
|
585
|
+
bumpRegionGeneration(regionId: number): number | null;
|
|
586
|
+
invalidateRegion(regionId: number): boolean;
|
|
587
|
+
attachRegionConsumer(
|
|
588
|
+
regionId: number,
|
|
589
|
+
options: {
|
|
590
|
+
consumerId: string;
|
|
591
|
+
mode?: "read-only";
|
|
592
|
+
roleMask?: number | null;
|
|
593
|
+
},
|
|
594
|
+
): RuntimeRegionConsumerLease;
|
|
595
|
+
detachRegionConsumer(regionId: number, leaseId: number): boolean;
|
|
596
|
+
listRegionConsumers(regionId: number): Array<{
|
|
597
|
+
leaseId: number;
|
|
598
|
+
regionId: number;
|
|
599
|
+
consumerId: string;
|
|
600
|
+
mode: "read-only";
|
|
601
|
+
roleMask: number | null;
|
|
602
|
+
generation: number;
|
|
603
|
+
attachedAt: number;
|
|
604
|
+
}>;
|
|
524
605
|
resolveRecord(options: RuntimeRegionRecordViewRequest): RuntimeRegionRecord | null;
|
|
525
606
|
resolveRecordView(
|
|
526
607
|
options: RuntimeRegionRecordViewRequest,
|
|
527
608
|
): RuntimeRegionRecord | RuntimeRegionExternalRecordView | null;
|
|
528
609
|
}
|
|
529
610
|
|
|
611
|
+
export type DeclaredOrbitTheory = "SGP4" | "SGP4XP" | "AP";
|
|
612
|
+
|
|
613
|
+
export interface EphemerisCatalogRecord {
|
|
614
|
+
id?: string | number;
|
|
615
|
+
ID?: string | number;
|
|
616
|
+
OBJECT_ID?: string;
|
|
617
|
+
NORAD_CAT_ID?: number;
|
|
618
|
+
declaredTheory?: DeclaredOrbitTheory | string;
|
|
619
|
+
MEAN_ELEMENT_THEORY?: DeclaredOrbitTheory | string;
|
|
620
|
+
theory?: DeclaredOrbitTheory | string;
|
|
621
|
+
propagatorId?: string;
|
|
622
|
+
[key: string]: unknown;
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
export interface RoutedCatalogRecord {
|
|
626
|
+
index: number;
|
|
627
|
+
recordId: string;
|
|
628
|
+
declaredTheory: DeclaredOrbitTheory;
|
|
629
|
+
propagatorId: string;
|
|
630
|
+
record: EphemerisCatalogRecord;
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
export interface PropagatorGridContext {
|
|
634
|
+
records: EphemerisCatalogRecord[];
|
|
635
|
+
routedRecords: RoutedCatalogRecord[];
|
|
636
|
+
updatedIndices?: number[];
|
|
637
|
+
statesView: Float32Array;
|
|
638
|
+
bandsView: Float32Array;
|
|
639
|
+
firstStep: number;
|
|
640
|
+
stepCount: number;
|
|
641
|
+
objectCount: number;
|
|
642
|
+
windowStart: number;
|
|
643
|
+
windowEnd: number;
|
|
644
|
+
stepS: number;
|
|
645
|
+
frame: string;
|
|
646
|
+
propagatorId: string;
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
export interface PropagatorRecordContext {
|
|
650
|
+
record: EphemerisCatalogRecord;
|
|
651
|
+
objectIndex: number;
|
|
652
|
+
declaredTheory: DeclaredOrbitTheory;
|
|
653
|
+
propagatorId: string;
|
|
654
|
+
statesView: Float32Array;
|
|
655
|
+
bandsView: Float32Array;
|
|
656
|
+
firstStep: number;
|
|
657
|
+
stepCount: number;
|
|
658
|
+
objectCount: number;
|
|
659
|
+
windowStart: number;
|
|
660
|
+
windowEnd: number;
|
|
661
|
+
stepS: number;
|
|
662
|
+
frame: string;
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
export interface PropagatorAdapter {
|
|
666
|
+
supportedTheories?: Iterable<DeclaredOrbitTheory | string>;
|
|
667
|
+
strict?: boolean;
|
|
668
|
+
supportsTheory?: (theory: DeclaredOrbitTheory) => boolean;
|
|
669
|
+
propagateGrid?: (
|
|
670
|
+
context: PropagatorGridContext,
|
|
671
|
+
) => { excludedIndices?: number[] } | void;
|
|
672
|
+
propagateRecord?: (
|
|
673
|
+
context: PropagatorRecordContext,
|
|
674
|
+
) => { excluded?: boolean } | void;
|
|
675
|
+
[key: string]: unknown;
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
export interface RegisteredPropagatorAdapter extends PropagatorAdapter {
|
|
679
|
+
propagatorId: string;
|
|
680
|
+
supportedTheories: Set<DeclaredOrbitTheory> | null;
|
|
681
|
+
supportsTheory(theory: DeclaredOrbitTheory | string): boolean;
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
export interface PropagatorRegistry {
|
|
685
|
+
defaultPropagatorId: string;
|
|
686
|
+
supportedPropagatorIds: readonly string[];
|
|
687
|
+
registerPropagator(id: string, adapter: PropagatorAdapter): RegisteredPropagatorAdapter;
|
|
688
|
+
getPropagator(id?: string): RegisteredPropagatorAdapter | null;
|
|
689
|
+
hasPropagator(id?: string): boolean;
|
|
690
|
+
listPropagators(): string[];
|
|
691
|
+
unregisterPropagator(id: string): boolean;
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
export interface EphemerisGridDescriptor {
|
|
695
|
+
readonly regionId: number;
|
|
696
|
+
readonly roleMask: number;
|
|
697
|
+
readonly propagatorId: string;
|
|
698
|
+
readonly catalogRevision: string;
|
|
699
|
+
readonly windowStart: number;
|
|
700
|
+
readonly windowEnd: number;
|
|
701
|
+
readonly stepS: number;
|
|
702
|
+
readonly frame: string;
|
|
703
|
+
readonly firstStep: number;
|
|
704
|
+
readonly stepCount: number;
|
|
705
|
+
readonly objectCount: number;
|
|
706
|
+
readonly generation: number;
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
export interface PopulateEphemerisGridSpec {
|
|
710
|
+
propagatorId?: string;
|
|
711
|
+
catalogRevision: string | number;
|
|
712
|
+
windowStart: number;
|
|
713
|
+
windowEnd: number;
|
|
714
|
+
stepS: number;
|
|
715
|
+
frame?: string;
|
|
716
|
+
firstStep?: number;
|
|
717
|
+
stepCount?: number;
|
|
718
|
+
roleMask?: number;
|
|
719
|
+
roles?: Uint8Array | number[] | null;
|
|
720
|
+
records?: EphemerisCatalogRecord[];
|
|
721
|
+
objectCount?: number;
|
|
722
|
+
shared?: boolean;
|
|
723
|
+
allowMixedRouting?: boolean;
|
|
724
|
+
populateFn?: (
|
|
725
|
+
context: PropagatorGridContext,
|
|
726
|
+
) => { excludedIndices?: number[] } | void;
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
export interface PopulateEphemerisGridResult {
|
|
730
|
+
descriptor: EphemerisGridDescriptor;
|
|
731
|
+
regionId: number;
|
|
732
|
+
cacheHit: boolean;
|
|
733
|
+
propagationCount: number;
|
|
734
|
+
propagatedObjectCount: number;
|
|
735
|
+
excludedIndices: number[];
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
export interface EphemerisGridStatus {
|
|
739
|
+
descriptor: EphemerisGridDescriptor;
|
|
740
|
+
regionId: number;
|
|
741
|
+
shared: boolean;
|
|
742
|
+
generation: number;
|
|
743
|
+
byteLength: number;
|
|
744
|
+
statesByteLength: number;
|
|
745
|
+
bandsByteLength: number;
|
|
746
|
+
propagationCount: number;
|
|
747
|
+
propagatedObjectCount: number;
|
|
748
|
+
spliceCount: number;
|
|
749
|
+
activeConsumers: number;
|
|
750
|
+
invalidated: boolean;
|
|
751
|
+
excludedIndices: number[];
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
export interface GridAttachLease {
|
|
755
|
+
readonly leaseId: number;
|
|
756
|
+
readonly regionId: number;
|
|
757
|
+
readonly moduleId: string;
|
|
758
|
+
readonly mode: "read-only";
|
|
759
|
+
readonly shared: boolean;
|
|
760
|
+
readonly generation: number;
|
|
761
|
+
readonly descriptor: EphemerisGridDescriptor;
|
|
762
|
+
readonly arenaBytes: Uint8Array;
|
|
763
|
+
getStatesView(): Float32Array;
|
|
764
|
+
getBandsView(): Float32Array;
|
|
765
|
+
getRolesView(): Uint8Array;
|
|
766
|
+
encodeAlignedExternalFrame(options?: {
|
|
767
|
+
portId?: string;
|
|
768
|
+
typeRef?: PayloadTypeRef;
|
|
769
|
+
}): InvokeFrame & { shared: boolean; regionId: number };
|
|
770
|
+
encodeScrGridFrame(): Uint8Array;
|
|
771
|
+
isCurrent(): boolean;
|
|
772
|
+
assertCurrent(): boolean;
|
|
773
|
+
detach(): boolean;
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
export interface SpliceEphemerisGridSpec {
|
|
777
|
+
regionId: number;
|
|
778
|
+
newCatalogRevision: string | number;
|
|
779
|
+
updatedIndices: number[];
|
|
780
|
+
records?: EphemerisCatalogRecord[];
|
|
781
|
+
excludedIndices?: number[];
|
|
782
|
+
allowMixedRouting?: boolean;
|
|
783
|
+
populateFn?: (
|
|
784
|
+
context: PropagatorGridContext & { updatedIndices: number[] },
|
|
785
|
+
) => { excludedIndices?: number[] } | void;
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
export interface InvalidateEphemerisGridFilter {
|
|
789
|
+
regionId?: number;
|
|
790
|
+
propagatorId?: string;
|
|
791
|
+
catalogRevision?: string | number;
|
|
792
|
+
windowStart?: number;
|
|
793
|
+
windowEnd?: number;
|
|
794
|
+
stepS?: number;
|
|
795
|
+
frame?: string;
|
|
796
|
+
all?: boolean;
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
export interface SharedEphemerisGridManager {
|
|
800
|
+
populateGrid(spec: PopulateEphemerisGridSpec): PopulateEphemerisGridResult;
|
|
801
|
+
getGrid(regionId: number): EphemerisGridStatus | null;
|
|
802
|
+
attachGridModule(
|
|
803
|
+
regionId: number,
|
|
804
|
+
options: {
|
|
805
|
+
moduleId: string;
|
|
806
|
+
roleMask?: number;
|
|
807
|
+
roles?: Uint8Array | number[] | null;
|
|
808
|
+
mode?: "read-only";
|
|
809
|
+
},
|
|
810
|
+
): GridAttachLease;
|
|
811
|
+
spliceGridObjects(spec: SpliceEphemerisGridSpec): {
|
|
812
|
+
descriptor: EphemerisGridDescriptor;
|
|
813
|
+
regionId: number;
|
|
814
|
+
generation: number;
|
|
815
|
+
updatedIndices: number[];
|
|
816
|
+
propagatedObjectCount: number;
|
|
817
|
+
};
|
|
818
|
+
invalidateGrid(filter: number | InvalidateEphemerisGridFilter): {
|
|
819
|
+
invalidatedRegionIds: number[];
|
|
820
|
+
count: number;
|
|
821
|
+
};
|
|
822
|
+
}
|
|
823
|
+
|
|
824
|
+
export const SCR_GRID_STATE_FLOATS: number;
|
|
825
|
+
export const SCR_GRID_STATE_BYTES: number;
|
|
826
|
+
export const SCR_RADIUS_BAND_FLOATS: number;
|
|
827
|
+
export const SCR_RADIUS_BAND_BYTES: number;
|
|
828
|
+
export const SCR_ROLE: Readonly<{ SECONDARY: 0; PRIMARY: 1; SKIP: 2 }>;
|
|
829
|
+
export const SCR_ROLE_MASK_ALL: number;
|
|
830
|
+
export const SCR_GRID_LAYOUT_ID: string;
|
|
831
|
+
export const DEFAULT_PROPAGATOR_ID: string;
|
|
832
|
+
export const SUPPORTED_PROPAGATOR_IDS: readonly string[];
|
|
833
|
+
export const DECLARED_ORBIT_THEORIES: readonly DeclaredOrbitTheory[];
|
|
834
|
+
|
|
835
|
+
export class TheoryMismatchError extends Error {
|
|
836
|
+
code: string;
|
|
837
|
+
recordId: string | null;
|
|
838
|
+
declaredTheory: string | null;
|
|
839
|
+
propagatorId: string | null;
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
export class StaleGridLeaseError extends Error {
|
|
843
|
+
code: string;
|
|
844
|
+
regionId: number | null;
|
|
845
|
+
moduleId: string | null;
|
|
846
|
+
attachedGeneration: number | null;
|
|
847
|
+
currentGeneration: number | null;
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
export function isSharedBuffer(buffer: unknown): buffer is SharedArrayBuffer;
|
|
851
|
+
export function createArenaBuffer(
|
|
852
|
+
byteLength: number,
|
|
853
|
+
options?: { shared?: boolean },
|
|
854
|
+
): ArrayBuffer | SharedArrayBuffer;
|
|
855
|
+
export function resolvePropagatorId(id?: string): string;
|
|
856
|
+
export function normalizeDeclaredTheory(
|
|
857
|
+
value: unknown,
|
|
858
|
+
recordLabel?: string,
|
|
859
|
+
): DeclaredOrbitTheory;
|
|
860
|
+
export function createPropagatorRegistry(
|
|
861
|
+
initialAdapters?:
|
|
862
|
+
| Map<string, PropagatorAdapter>
|
|
863
|
+
| Record<string, PropagatorAdapter>,
|
|
864
|
+
): PropagatorRegistry;
|
|
865
|
+
export function routeCatalogRecordsByTheory(
|
|
866
|
+
records: EphemerisCatalogRecord[],
|
|
867
|
+
options?: {
|
|
868
|
+
propagatorId?: string;
|
|
869
|
+
registry?: PropagatorRegistry | null;
|
|
870
|
+
allowMixedRouting?: boolean;
|
|
871
|
+
},
|
|
872
|
+
): RoutedCatalogRecord[];
|
|
873
|
+
export function gridCacheKey(spec: {
|
|
874
|
+
propagatorId?: string;
|
|
875
|
+
catalogRevision: string | number;
|
|
876
|
+
windowStart: number;
|
|
877
|
+
windowEnd: number;
|
|
878
|
+
stepS: number;
|
|
879
|
+
frame?: string;
|
|
880
|
+
}): string;
|
|
881
|
+
export function encodeScrGridFlatBuffer(spec: {
|
|
882
|
+
firstStep?: number;
|
|
883
|
+
stepCount: number;
|
|
884
|
+
objectCount: number;
|
|
885
|
+
frame?: string;
|
|
886
|
+
stepS?: number;
|
|
887
|
+
statesView: Float32Array;
|
|
888
|
+
bandsView: Float32Array;
|
|
889
|
+
}): Uint8Array;
|
|
890
|
+
export function decodeScrGridFlatBuffer(bytes: Uint8Array): {
|
|
891
|
+
firstStep: number;
|
|
892
|
+
stepCount: number;
|
|
893
|
+
objectCount: number;
|
|
894
|
+
frame: string;
|
|
895
|
+
stepS: number;
|
|
896
|
+
statesView: Float32Array;
|
|
897
|
+
bandsView: Float32Array;
|
|
898
|
+
};
|
|
899
|
+
export function createSharedEphemerisGridManager(options?: {
|
|
900
|
+
regions?: RuntimeRegionStore;
|
|
901
|
+
propagators?: PropagatorRegistry;
|
|
902
|
+
}): SharedEphemerisGridManager;
|
|
903
|
+
|
|
530
904
|
export interface InstalledRuntimeModule {
|
|
531
905
|
moduleId: string;
|
|
532
906
|
metadata: unknown;
|
|
@@ -557,6 +931,33 @@ export interface RuntimeHost {
|
|
|
557
931
|
rows: FlatSqlRuntimeStore;
|
|
558
932
|
regions: RuntimeRegionStore;
|
|
559
933
|
moduleRegistry: RuntimeModuleRegistry;
|
|
934
|
+
propagators: PropagatorRegistry;
|
|
935
|
+
ephemerisGrids: SharedEphemerisGridManager;
|
|
936
|
+
registerPropagator(id: string, adapter: PropagatorAdapter): RegisteredPropagatorAdapter;
|
|
937
|
+
listPropagators(): string[];
|
|
938
|
+
populateEphemerisGrid(spec: PopulateEphemerisGridSpec): PopulateEphemerisGridResult;
|
|
939
|
+
getEphemerisGrid(regionId: number): EphemerisGridStatus | null;
|
|
940
|
+
attachEphemerisGrid(
|
|
941
|
+
regionId: number,
|
|
942
|
+
options: {
|
|
943
|
+
moduleId: string;
|
|
944
|
+
roleMask?: number;
|
|
945
|
+
roles?: Uint8Array | number[] | null;
|
|
946
|
+
mode?: "read-only";
|
|
947
|
+
},
|
|
948
|
+
): GridAttachLease;
|
|
949
|
+
detachEphemerisGrid(lease: GridAttachLease): boolean;
|
|
950
|
+
spliceEphemerisGrid(spec: SpliceEphemerisGridSpec): {
|
|
951
|
+
descriptor: EphemerisGridDescriptor;
|
|
952
|
+
regionId: number;
|
|
953
|
+
generation: number;
|
|
954
|
+
updatedIndices: number[];
|
|
955
|
+
propagatedObjectCount: number;
|
|
956
|
+
};
|
|
957
|
+
invalidateEphemerisGrid(filter: number | InvalidateEphemerisGridFilter): {
|
|
958
|
+
invalidatedRegionIds: number[];
|
|
959
|
+
count: number;
|
|
960
|
+
};
|
|
560
961
|
listCapabilities(): string[];
|
|
561
962
|
listSupportedCapabilities(): string[];
|
|
562
963
|
listOperations(): string[];
|
|
@@ -600,6 +1001,11 @@ export function createRuntimeHost(options?: {
|
|
|
600
1001
|
rows?: FlatSqlRuntimeStore;
|
|
601
1002
|
regions?: RuntimeRegionStore;
|
|
602
1003
|
moduleRegistry?: RuntimeModuleRegistry;
|
|
1004
|
+
propagators?: PropagatorRegistry;
|
|
1005
|
+
propagatorAdapters?:
|
|
1006
|
+
| Map<string, PropagatorAdapter>
|
|
1007
|
+
| Record<string, PropagatorAdapter>;
|
|
1008
|
+
ephemerisGrids?: SharedEphemerisGridManager;
|
|
603
1009
|
}): RuntimeHost;
|
|
604
1010
|
export function getWasmExportNamesFromFile(wasmPath: string): Promise<string[]>;
|
|
605
1011
|
|