space-data-module-sdk 0.8.6 → 0.8.8
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/README.md +13 -0
- package/docs/AGENTS.md +5 -0
- package/docs/browser-wasmedge-isomorphic.md +65 -1
- package/docs/language-runtime-matrix.md +2 -2
- package/docs/provider-access-abi.md +600 -0
- package/package.json +15 -6
- package/schemas/orbpro/Propagator.fbs +19 -3
- package/src/browser.js +14 -4
- package/src/bundle/artifactBytes.js +44 -0
- package/src/bundle/index.js +1 -0
- package/src/compiler/compileModule.js +24 -1
- package/src/flow/flowCompiler.js +141 -2
- package/src/flow/flowRuntimeHost.js +7 -1
- package/src/flow/isomorphicFlowHost.js +1 -1
- package/src/flow/vendor/sdn-flow/MethodRegistry.js +6 -1
- package/src/generated/orbpro/propagator/propagator-source-description.js +2 -2
- package/src/generated/orbpro/propagator/propagator-source-description.ts +2 -2
- package/src/generated/orbpro/propagator/propagator-source-kind.js +13 -2
- package/src/generated/orbpro/propagator/propagator-source-kind.ts +13 -2
- package/src/generated/spacedatastandards/plg/pluginCategory.d.ts +18 -1
- package/src/generated/spacedatastandards/plg/pluginCategory.d.ts.map +1 -1
- package/src/generated/spacedatastandards/plg/pluginCategory.js +17 -0
- package/src/generated/spacedatastandards/plg/pluginCategory.ts +21 -1
- package/src/{testing → host}/browserModuleHarness.js +69 -34
- package/src/host/index.js +6 -0
- package/src/host/isomorphicLoader.js +17 -45
- package/src/host/isomorphicLoaderBrowser.js +47 -0
- package/src/host/isomorphicLoaderCore.js +58 -0
- package/src/host/nodeBuiltinSpecifier.js +43 -0
- package/src/host/providerAccess.js +727 -0
- package/src/host/providerAccessAbi.js +403 -0
- package/src/host/providerAccessEngineAdapter.js +338 -0
- package/src/host/providerAccessFixtureAdapter.js +444 -0
- package/src/host/providerAccessTileStoreAdapter.js +366 -0
- package/src/host/sabHostcallChannel.js +1 -1
- package/src/host/terrainSourceSeam.js +205 -0
- package/src/host/wasiThreadHost.js +11 -1
- package/src/{testing → host}/workerModuleHarness.js +45 -12
- package/src/{testing → host}/workerModuleHarnessWorker.js +6 -5
- package/src/index.d.ts +29 -2
- package/src/standards/browser.js +95 -0
- package/src/standards/catalogCore.js +290 -0
- package/src/standards/index.js +27 -251
- package/src/testing/AGENTS.md +25 -2
- package/src/testing/browser.js +32 -0
- package/src/testing/index.d.ts +12 -1
- package/src/testing/index.js +3 -3
- package/src/testing/parityBrowserRunner.js +9 -2
- package/src/testing/parityHarness.js +1 -1
- package/templates/provider-access-module/include/space_data_provider_abi.h +227 -0
- /package/src/{testing → host}/moduleFlatbufferStreamPump.js +0 -0
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Provider Access ABI — guest header.
|
|
3
|
+
*
|
|
4
|
+
* One generalized port for imagery/terrain providers. Identical import names
|
|
5
|
+
* and signatures in the browser, in native WasmEdge and in Docker WasmEdge.
|
|
6
|
+
*
|
|
7
|
+
* Build: clang --target=wasm32-wasip1-threads (never emcc -pthread).
|
|
8
|
+
* The module is EH-free and there is exactly one dist/isomorphic/module.wasm.
|
|
9
|
+
*
|
|
10
|
+
* NOTE ON TYPES: every parameter and every result below is int32_t. No int64_t
|
|
11
|
+
* appears anywhere in a boundary signature. This is deliberate — a 64-bit
|
|
12
|
+
* import parameter legalizes differently depending on how the host
|
|
13
|
+
* instantiates the module, and the mismatch shows up as a link failure or a
|
|
14
|
+
* silently truncated argument in exactly one runtime. Every 64-bit quantity in
|
|
15
|
+
* this ABI travels inside the descriptor struct below, in guest memory, as
|
|
16
|
+
* plain little-endian IEEE-754 that you read with a normal load.
|
|
17
|
+
*
|
|
18
|
+
* See docs/provider-access-abi.md for the normative contract.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
#ifndef SPACE_DATA_PROVIDER_ABI_H
|
|
22
|
+
#define SPACE_DATA_PROVIDER_ABI_H
|
|
23
|
+
|
|
24
|
+
#include <stdint.h>
|
|
25
|
+
|
|
26
|
+
#ifdef __cplusplus
|
|
27
|
+
extern "C" {
|
|
28
|
+
#endif
|
|
29
|
+
|
|
30
|
+
#define SDM_PROVIDER_IMPORT_MODULE "space_data_provider"
|
|
31
|
+
#define SDM_PROVIDER_ABI_VERSION 1
|
|
32
|
+
#define SDM_PROVIDER_TILE_DESC_MAGIC 0x53445054u /* 'SDPT' */
|
|
33
|
+
#define SDM_PROVIDER_TILE_DESC_BYTES 128
|
|
34
|
+
|
|
35
|
+
/* ---- kinds ------------------------------------------------------------- */
|
|
36
|
+
#define SDM_PROVIDER_KIND_TERRAIN 1u
|
|
37
|
+
#define SDM_PROVIDER_KIND_IMAGERY 2u
|
|
38
|
+
|
|
39
|
+
/* ---- encodings --------------------------------------------------------- */
|
|
40
|
+
#define SDM_PROVIDER_ENC_HEIGHT_F32 1u /* float, metres above the ellipsoid */
|
|
41
|
+
#define SDM_PROVIDER_ENC_HEIGHT_F64 2u /* double, metres above the ellipsoid */
|
|
42
|
+
#define SDM_PROVIDER_ENC_RGBA8 16u
|
|
43
|
+
#define SDM_PROVIDER_ENC_RGB8 17u
|
|
44
|
+
#define SDM_PROVIDER_ENC_GRAY8 18u
|
|
45
|
+
#define SDM_PROVIDER_ENC_GRAY16 19u
|
|
46
|
+
#define SDM_PROVIDER_ENC_RGBA_F32 20u
|
|
47
|
+
|
|
48
|
+
/* ---- flags ------------------------------------------------------------- */
|
|
49
|
+
#define SDM_PROVIDER_FLAG_INTERPOLATED (1u << 0)
|
|
50
|
+
#define SDM_PROVIDER_FLAG_STAGED (1u << 1)
|
|
51
|
+
#define SDM_PROVIDER_FLAG_PARTIAL (1u << 2)
|
|
52
|
+
#define SDM_PROVIDER_FLAG_DERIVED (1u << 3)
|
|
53
|
+
#define SDM_PROVIDER_FLAG_FIXTURE (1u << 4)
|
|
54
|
+
|
|
55
|
+
/* ---- cost classes ------------------------------------------------------ *
|
|
56
|
+
* "maxCost" in the acquire request defaults to DEQUANTIZE. That default IS
|
|
57
|
+
* the "never re-fetch, never re-parse" rule, enforced by the ABI rather than
|
|
58
|
+
* by discipline. Raising it is how a caller says out loud that it accepts a
|
|
59
|
+
* cost.
|
|
60
|
+
*/
|
|
61
|
+
#define SDM_PROVIDER_COST_RESIDENT 0u
|
|
62
|
+
#define SDM_PROVIDER_COST_DEQUANTIZE 1u
|
|
63
|
+
#define SDM_PROVIDER_COST_REDECODE 2u
|
|
64
|
+
#define SDM_PROVIDER_COST_REFETCH 3u
|
|
65
|
+
#define SDM_PROVIDER_COST_READBACK 4u
|
|
66
|
+
|
|
67
|
+
/* ---- level-selection provenance ---------------------------------------- *
|
|
68
|
+
* A consumer that cannot see which level answered cannot tell a solve that
|
|
69
|
+
* resolved the ridges from one that interpolated them away. Names mirror the
|
|
70
|
+
* engine consumer's existing vocabulary.
|
|
71
|
+
*/
|
|
72
|
+
#define SDM_PROVIDER_STRATEGY_DEFAULT 0u
|
|
73
|
+
#define SDM_PROVIDER_STRATEGY_GRID_MATCHED_LEVEL 1u
|
|
74
|
+
#define SDM_PROVIDER_STRATEGY_MOST_DETAILED 2u
|
|
75
|
+
#define SDM_PROVIDER_STRATEGY_FIXED_LEVEL 3u
|
|
76
|
+
|
|
77
|
+
/* ---- error codes ------------------------------------------------------- *
|
|
78
|
+
* Negative results from acquire/read/release. Identical value, identical
|
|
79
|
+
* meaning and identical trap class (none — these are VALUES) in every runtime.
|
|
80
|
+
*/
|
|
81
|
+
#define SDM_PROVIDER_E_INVALID_REQUEST (-1)
|
|
82
|
+
#define SDM_PROVIDER_E_NO_CAPABILITY (-2)
|
|
83
|
+
#define SDM_PROVIDER_E_NO_PROVIDER (-3)
|
|
84
|
+
#define SDM_PROVIDER_E_NOT_READY (-4)
|
|
85
|
+
#define SDM_PROVIDER_E_NOT_AVAILABLE (-5)
|
|
86
|
+
#define SDM_PROVIDER_E_BOUNDS (-6)
|
|
87
|
+
#define SDM_PROVIDER_E_BAD_HANDLE (-7)
|
|
88
|
+
#define SDM_PROVIDER_E_BAD_PLANE (-8)
|
|
89
|
+
#define SDM_PROVIDER_E_UNSUPPORTED (-9)
|
|
90
|
+
#define SDM_PROVIDER_E_TIMEOUT (-10)
|
|
91
|
+
#define SDM_PROVIDER_E_HOST (-11)
|
|
92
|
+
#define SDM_PROVIDER_E_PORT_UNAVAILABLE (-12)
|
|
93
|
+
|
|
94
|
+
/* ---- no-data sentinel -------------------------------------------------- *
|
|
95
|
+
* NOT NaN. WebAssembly does not canonicalize NaN payloads across every
|
|
96
|
+
* producing operation, so two runtimes can hold different bits for "a NaN" and
|
|
97
|
+
* a byte-identical-output assertion would fail on semantically equal values.
|
|
98
|
+
* These have exactly one encoding each and are never a real terrain height.
|
|
99
|
+
*/
|
|
100
|
+
#define SDM_PROVIDER_NO_DATA_F32_BITS 0xFF7FFFFFu
|
|
101
|
+
#define SDM_PROVIDER_NO_DATA_F64_BITS 0xFFEFFFFFFFFFFFFFull
|
|
102
|
+
|
|
103
|
+
static inline int sdm_provider_is_no_data_f64(double value) {
|
|
104
|
+
uint64_t bits;
|
|
105
|
+
__builtin_memcpy(&bits, &value, sizeof bits);
|
|
106
|
+
return bits == SDM_PROVIDER_NO_DATA_F64_BITS;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
static inline int sdm_provider_is_no_data_f32(float value) {
|
|
110
|
+
uint32_t bits;
|
|
111
|
+
__builtin_memcpy(&bits, &value, sizeof bits);
|
|
112
|
+
return bits == SDM_PROVIDER_NO_DATA_F32_BITS;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/* ---- tile descriptor --------------------------------------------------- *
|
|
116
|
+
* 128 bytes, little-endian. All f64 fields are 8-byte aligned, so this struct
|
|
117
|
+
* is read with ordinary aligned loads on every target.
|
|
118
|
+
*/
|
|
119
|
+
typedef struct sdm_provider_tile_desc {
|
|
120
|
+
uint32_t magic; /* 0 SDM_PROVIDER_TILE_DESC_MAGIC */
|
|
121
|
+
uint32_t version; /* 4 SDM_PROVIDER_ABI_VERSION */
|
|
122
|
+
uint32_t kind; /* 8 */
|
|
123
|
+
uint32_t encoding; /* 12 */
|
|
124
|
+
uint32_t width; /* 16 elements per row */
|
|
125
|
+
uint32_t height; /* 20 rows */
|
|
126
|
+
uint32_t plane_count; /* 24 */
|
|
127
|
+
uint32_t bytes_per_element; /* 28 */
|
|
128
|
+
uint32_t row_stride_bytes; /* 32 */
|
|
129
|
+
uint32_t byte_length; /* 36 plane 0 */
|
|
130
|
+
uint32_t flags; /* 40 */
|
|
131
|
+
uint32_t level; /* 44 0xFFFFFFFF for derived tiles */
|
|
132
|
+
double west; /* 48 radians */
|
|
133
|
+
double south; /* 56 */
|
|
134
|
+
double east; /* 64 */
|
|
135
|
+
double north; /* 72 */
|
|
136
|
+
double min_value; /* 80 terrain: min height, metres */
|
|
137
|
+
double max_value; /* 88 terrain: max height, metres */
|
|
138
|
+
uint32_t tile_x; /* 96 */
|
|
139
|
+
uint32_t tile_y; /* 100 */
|
|
140
|
+
uint32_t host_copies; /* 104 host->guest copies per whole-plane read */
|
|
141
|
+
uint32_t source_id; /* 108 FNV-1a 32 of the provider id */
|
|
142
|
+
uint32_t cost_class; /* 112 what this acquire actually cost */
|
|
143
|
+
uint32_t strategy; /* 116 how the level was chosen */
|
|
144
|
+
uint32_t reserved[2]; /* 120 */
|
|
145
|
+
} sdm_provider_tile_desc_t;
|
|
146
|
+
|
|
147
|
+
_Static_assert(sizeof(sdm_provider_tile_desc_t) == SDM_PROVIDER_TILE_DESC_BYTES,
|
|
148
|
+
"sdm_provider_tile_desc_t must be exactly 128 bytes");
|
|
149
|
+
|
|
150
|
+
/* ---- imports ----------------------------------------------------------- *
|
|
151
|
+
* Open, read, close. Three doors.
|
|
152
|
+
*/
|
|
153
|
+
|
|
154
|
+
/*
|
|
155
|
+
* Acquire pins a provider's decoded buffer host-side and fills `desc`.
|
|
156
|
+
* `request` is UTF-8 JSON:
|
|
157
|
+
*
|
|
158
|
+
* {"op":"tile","providerId":"...","level":9,"x":1,"y":2}
|
|
159
|
+
* {"op":"profile","providerId":"...","start":[lon,lat],"end":[lon,lat],
|
|
160
|
+
* "samples":256,"level":"mostDetailed"}
|
|
161
|
+
* {"op":"profile","providerId":"...","positionsPtr":P,"positionsCount":N}
|
|
162
|
+
* {"op":"region","providerId":"...","rectangle":[w,s,e,n],
|
|
163
|
+
* "width":256,"height":256,"level":9}
|
|
164
|
+
*
|
|
165
|
+
* plus optional "maxCost" (default 1), "plane", and "spacing" (the target
|
|
166
|
+
* sample spacing in METRES — preferred over "level": you know your own march
|
|
167
|
+
* stride, you do not know a provider's level scheme).
|
|
168
|
+
*
|
|
169
|
+
* RASTER IN: a coverage field is commonly 512x512 = 262,144 positions.
|
|
170
|
+
* Encoding those as JSON would be a multi-megabyte request string parsed on
|
|
171
|
+
* every call — a worse cost than the read it is asking for. Pass
|
|
172
|
+
* "positionsPtr"/"positionsCount" instead and the host reads interleaved f64
|
|
173
|
+
* lon/lat pairs straight out of guest memory with ONE copy, symmetric with the
|
|
174
|
+
* way results come back.
|
|
175
|
+
*
|
|
176
|
+
* Returns a handle > 0, or a negative SDM_PROVIDER_E_* code. `desc` is left
|
|
177
|
+
* untouched on failure. The call blocks until the tile is resident.
|
|
178
|
+
*/
|
|
179
|
+
__attribute__((import_module(SDM_PROVIDER_IMPORT_MODULE),
|
|
180
|
+
import_name("acquire"))) extern int32_t
|
|
181
|
+
sdm_provider_acquire_raw(int32_t request_ptr, int32_t request_len,
|
|
182
|
+
int32_t desc_ptr);
|
|
183
|
+
|
|
184
|
+
/*
|
|
185
|
+
* Copies at most `dst_len` bytes of `plane`, starting `src_offset` bytes into
|
|
186
|
+
* that plane, into guest memory at `dst_ptr`. Returns bytes written (which may
|
|
187
|
+
* legally be less than dst_len at the tail), or a negative error code.
|
|
188
|
+
*
|
|
189
|
+
* Reading a plane in several chunks yields exactly the same bytes as one
|
|
190
|
+
* whole-plane read.
|
|
191
|
+
*/
|
|
192
|
+
__attribute__((import_module(SDM_PROVIDER_IMPORT_MODULE),
|
|
193
|
+
import_name("read"))) extern int32_t
|
|
194
|
+
sdm_provider_read_raw(int32_t handle, int32_t plane, int32_t src_offset,
|
|
195
|
+
int32_t dst_ptr, int32_t dst_len);
|
|
196
|
+
|
|
197
|
+
/* Unpins. Releasing an already-released handle returns E_BAD_HANDLE. */
|
|
198
|
+
__attribute__((import_module(SDM_PROVIDER_IMPORT_MODULE),
|
|
199
|
+
import_name("release"))) extern int32_t
|
|
200
|
+
sdm_provider_release(int32_t handle);
|
|
201
|
+
|
|
202
|
+
/* ---- pointer-friendly wrappers ---------------------------------------- */
|
|
203
|
+
|
|
204
|
+
static inline int32_t sdm_provider_acquire(const char *request,
|
|
205
|
+
int32_t request_len,
|
|
206
|
+
sdm_provider_tile_desc_t *desc) {
|
|
207
|
+
return sdm_provider_acquire_raw((int32_t)(uintptr_t)request, request_len,
|
|
208
|
+
(int32_t)(uintptr_t)desc);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
static inline int32_t sdm_provider_read(int32_t handle, int32_t plane,
|
|
212
|
+
int32_t src_offset, void *dst,
|
|
213
|
+
int32_t dst_len) {
|
|
214
|
+
return sdm_provider_read_raw(handle, plane, src_offset,
|
|
215
|
+
(int32_t)(uintptr_t)dst, dst_len);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
static inline int sdm_provider_desc_valid(const sdm_provider_tile_desc_t *desc) {
|
|
219
|
+
return desc != 0 && desc->magic == SDM_PROVIDER_TILE_DESC_MAGIC &&
|
|
220
|
+
desc->version == SDM_PROVIDER_ABI_VERSION;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
#ifdef __cplusplus
|
|
224
|
+
} /* extern "C" */
|
|
225
|
+
#endif
|
|
226
|
+
|
|
227
|
+
#endif /* SPACE_DATA_PROVIDER_ABI_H */
|
|
File without changes
|