space-data-module-sdk 0.5.22 → 0.6.1
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 +22 -2
- package/package.json +2 -2
- package/schemas/orbpro/BaseTypes.fbs +7 -0
- package/schemas/orbpro/CatalogQueryBase.fbs +8 -0
- package/schemas/orbpro/CatalogQueryRequest.fbs +14 -0
- package/schemas/orbpro/CatalogQueryResult.fbs +17 -0
- package/schemas/orbpro/EntityMetadata.fbs +53 -0
- package/schemas/orbpro/EntityStandardsLink.fbs +18 -0
- package/schemas/orbpro/Plugin.fbs +8 -0
- package/schemas/orbpro/Propagator.fbs +89 -0
- package/schemas/orbpro/StandardsRecordIndex.fbs +15 -0
- package/src/generated/orbpro/entity/entity-kind.js +15 -0
- package/src/generated/orbpro/entity/entity-kind.ts +15 -0
- package/src/generated/orbpro/entity/entity-metadata.js +322 -0
- package/src/generated/orbpro/entity/entity-metadata.ts +426 -0
- package/src/generated/orbpro/entity/entity-standards-link.js +143 -0
- package/src/generated/orbpro/entity/entity-standards-link.ts +183 -0
- package/src/generated/orbpro/entity/standards-record-index.js +115 -0
- package/src/generated/orbpro/entity/standards-record-index.ts +147 -0
- package/src/generated/orbpro/entity.js +10 -0
- package/src/generated/orbpro/entity.ts +5 -0
- package/src/generated/orbpro/plugin/raw-data-payload.js +79 -0
- package/src/generated/orbpro/plugin/raw-data-payload.ts +92 -0
- package/src/generated/orbpro/plugin.js +4 -0
- package/src/generated/orbpro/plugin.ts +5 -0
- package/src/generated/orbpro/propagator/propagator-describe-sources-batch-request.js +79 -0
- package/src/generated/orbpro/propagator/propagator-describe-sources-batch-request.ts +95 -0
- package/src/generated/orbpro/propagator/propagator-describe-sources-batch-result.js +70 -0
- package/src/generated/orbpro/propagator/propagator-describe-sources-batch-result.ts +78 -0
- package/src/generated/orbpro/propagator/propagator-sample-trajectory-states-request.js +97 -0
- package/src/generated/orbpro/propagator/propagator-sample-trajectory-states-request.ts +117 -0
- package/src/generated/orbpro/propagator/propagator-sample-trajectory-states-result.js +140 -0
- package/src/generated/orbpro/propagator/propagator-sample-trajectory-states-result.ts +175 -0
- package/src/generated/orbpro/propagator/propagator-source-description.js +208 -0
- package/src/generated/orbpro/propagator/propagator-source-description.ts +257 -0
- package/src/generated/orbpro/propagator/propagator-source-kind.js +8 -0
- package/src/generated/orbpro/propagator/propagator-source-kind.ts +8 -0
- package/src/generated/orbpro/propagator/reference-frame.js +12 -0
- package/src/generated/orbpro/propagator/reference-frame.ts +12 -0
- package/src/generated/orbpro/propagator/state-flags.js +13 -0
- package/src/generated/orbpro/propagator/state-flags.ts +13 -0
- package/src/generated/orbpro/propagator/state-vector.js +55 -0
- package/src/generated/orbpro/propagator/state-vector.ts +61 -0
- package/src/generated/orbpro/propagator.js +20 -0
- package/src/generated/orbpro/propagator.ts +13 -0
- package/src/generated/orbpro/query/catalog-query-kind.js +10 -0
- package/src/generated/orbpro/query/catalog-query-kind.ts +10 -0
- package/src/generated/orbpro/query/catalog-query-request.js +89 -0
- package/src/generated/orbpro/query/catalog-query-request.ts +105 -0
- package/src/generated/orbpro/query/catalog-query-result.js +145 -0
- package/src/generated/orbpro/query/catalog-query-result.ts +179 -0
- package/src/generated/orbpro/query.js +8 -0
- package/src/generated/orbpro/query.ts +4 -0
- package/src/generated/orbpro/vec3.js +39 -0
- package/src/generated/orbpro/vec3.ts +40 -0
- package/src/host/abi.js +189 -3
- package/src/host/browserEdgeShims.js +17 -0
- package/src/host/browserHost.js +486 -40
- package/src/host/isomorphicLoader.js +44 -20
- package/src/host/nodeHost.js +337 -63
- package/src/index.d.ts +99 -3
- package/src/runtime-host/index.js +90 -0
- package/src/testing/browserModuleHarness.js +22 -3
- package/src/testing/index.d.ts +1 -0
- package/src/testing/index.js +39 -1
package/src/index.d.ts
CHANGED
|
@@ -409,6 +409,18 @@ export interface RuntimeHost {
|
|
|
409
409
|
rows: FlatSqlRuntimeStore;
|
|
410
410
|
regions: RuntimeRegionStore;
|
|
411
411
|
moduleRegistry: RuntimeModuleRegistry;
|
|
412
|
+
listCapabilities(): string[];
|
|
413
|
+
listSupportedCapabilities(): string[];
|
|
414
|
+
listOperations(): string[];
|
|
415
|
+
hasCapability(capability: string): boolean;
|
|
416
|
+
getCapability(capability: string): Record<string, (...args: any[]) => unknown> | null;
|
|
417
|
+
registerCapability(
|
|
418
|
+
capability: string,
|
|
419
|
+
adapter: Record<string, (...args: any[]) => unknown>,
|
|
420
|
+
): Record<string, (...args: any[]) => unknown>;
|
|
421
|
+
unregisterCapability(capability: string): boolean;
|
|
422
|
+
invokeCapability(operation: string, params?: Record<string, any>): Promise<unknown>;
|
|
423
|
+
invoke(operation: string, params?: Record<string, any>): Promise<unknown>;
|
|
412
424
|
}
|
|
413
425
|
|
|
414
426
|
export function createFlatBufferStreamIngestor(options?: {
|
|
@@ -1117,13 +1129,21 @@ export interface BrowserEdgeShims {
|
|
|
1117
1129
|
now(): number;
|
|
1118
1130
|
timeOrigin: number;
|
|
1119
1131
|
};
|
|
1132
|
+
network?: Record<string, (...args: any[]) => unknown> | null;
|
|
1133
|
+
ipfs?: Record<string, (...args: any[]) => unknown> | null;
|
|
1134
|
+
walletSign?: Record<string, (...args: any[]) => unknown> | null;
|
|
1135
|
+
protocolHandle?: Record<string, (...args: any[]) => unknown> | null;
|
|
1136
|
+
protocolDial?: Record<string, (...args: any[]) => unknown> | null;
|
|
1120
1137
|
filesystem?: BrowserFilesystemShim;
|
|
1138
|
+
filesystemRoot?: string;
|
|
1139
|
+
capabilityAdapters?: Record<string, Record<string, (...args: any[]) => unknown>>;
|
|
1121
1140
|
}
|
|
1122
1141
|
|
|
1123
1142
|
export interface BrowserHostOptions {
|
|
1124
1143
|
capabilities?: string[];
|
|
1125
1144
|
edgeShims?: BrowserEdgeShims;
|
|
1126
1145
|
contextStore?: Map<string, Map<string, unknown>>;
|
|
1146
|
+
wasmWallet?: unknown;
|
|
1127
1147
|
fetch?: (...args: any[]) => Promise<any>;
|
|
1128
1148
|
WebSocket?: any;
|
|
1129
1149
|
crypto?: any;
|
|
@@ -1133,6 +1153,12 @@ export interface BrowserHostOptions {
|
|
|
1133
1153
|
};
|
|
1134
1154
|
filesystem?: BrowserFilesystemShim;
|
|
1135
1155
|
filesystemRoot?: string;
|
|
1156
|
+
network?: Record<string, (...args: any[]) => unknown> | null;
|
|
1157
|
+
ipfs?: Record<string, (...args: any[]) => unknown> | null;
|
|
1158
|
+
walletSign?: Record<string, (...args: any[]) => unknown> | null;
|
|
1159
|
+
protocolHandle?: Record<string, (...args: any[]) => unknown> | null;
|
|
1160
|
+
protocolDial?: Record<string, (...args: any[]) => unknown> | null;
|
|
1161
|
+
capabilityAdapters?: Record<string, Record<string, (...args: any[]) => unknown>>;
|
|
1136
1162
|
}
|
|
1137
1163
|
|
|
1138
1164
|
export interface NodeHostOptions {
|
|
@@ -1156,6 +1182,40 @@ export interface NodeHostOptions {
|
|
|
1156
1182
|
contextStore?: NodeHostContextStore;
|
|
1157
1183
|
fetch?: (...args: any[]) => Promise<any>;
|
|
1158
1184
|
WebSocket?: any;
|
|
1185
|
+
filesystem?: {
|
|
1186
|
+
resolvePath(path: string): string;
|
|
1187
|
+
readFile(
|
|
1188
|
+
path: string,
|
|
1189
|
+
options?: { encoding?: string | null },
|
|
1190
|
+
): Promise<string | Uint8Array>;
|
|
1191
|
+
writeFile(
|
|
1192
|
+
path: string,
|
|
1193
|
+
value: Uint8Array | ArrayBuffer | ArrayBufferView | string,
|
|
1194
|
+
options?: { encoding?: string | null },
|
|
1195
|
+
): Promise<{ path: string }>;
|
|
1196
|
+
appendFile(
|
|
1197
|
+
path: string,
|
|
1198
|
+
value: Uint8Array | ArrayBuffer | ArrayBufferView | string,
|
|
1199
|
+
options?: { encoding?: string | null },
|
|
1200
|
+
): Promise<{ path: string }>;
|
|
1201
|
+
deleteFile(path: string): Promise<{ path: string }>;
|
|
1202
|
+
mkdir(
|
|
1203
|
+
path: string,
|
|
1204
|
+
options?: { recursive?: boolean },
|
|
1205
|
+
): Promise<{ path: string }>;
|
|
1206
|
+
readdir(path?: string): Promise<NodeHostFilesystemEntry[]>;
|
|
1207
|
+
stat(path: string): Promise<NodeHostFilesystemStat>;
|
|
1208
|
+
rename(
|
|
1209
|
+
fromPath: string,
|
|
1210
|
+
toPath: string,
|
|
1211
|
+
): Promise<{ from: string; to: string }>;
|
|
1212
|
+
} | null;
|
|
1213
|
+
network?: Record<string, (...args: any[]) => unknown> | null;
|
|
1214
|
+
ipfs?: Record<string, (...args: any[]) => unknown> | null;
|
|
1215
|
+
walletSign?: Record<string, (...args: any[]) => unknown> | null;
|
|
1216
|
+
protocolHandle?: Record<string, (...args: any[]) => unknown> | null;
|
|
1217
|
+
protocolDial?: Record<string, (...args: any[]) => unknown> | null;
|
|
1218
|
+
capabilityAdapters?: Record<string, Record<string, (...args: any[]) => unknown>>;
|
|
1159
1219
|
}
|
|
1160
1220
|
|
|
1161
1221
|
export class HostCapabilityError extends Error {
|
|
@@ -1468,16 +1528,51 @@ export class BrowserHost {
|
|
|
1468
1528
|
crypto: {
|
|
1469
1529
|
sha256(data: Uint8Array | ArrayBuffer | ArrayBufferView | string): Promise<Uint8Array>;
|
|
1470
1530
|
sha512(data: Uint8Array | ArrayBuffer | ArrayBufferView | string): Promise<Uint8Array>;
|
|
1531
|
+
hkdf(options: {
|
|
1532
|
+
ikm: Uint8Array | ArrayBuffer | ArrayBufferView | number[];
|
|
1533
|
+
salt: Uint8Array | ArrayBuffer | ArrayBufferView | number[];
|
|
1534
|
+
info?: Uint8Array | ArrayBuffer | ArrayBufferView | number[];
|
|
1535
|
+
length: number;
|
|
1536
|
+
}): Promise<Uint8Array>;
|
|
1471
1537
|
aesGcmEncrypt(options: {
|
|
1472
1538
|
key: Uint8Array | ArrayBuffer | ArrayBufferView;
|
|
1473
1539
|
plaintext: Uint8Array | ArrayBuffer | ArrayBufferView;
|
|
1474
1540
|
iv?: Uint8Array | ArrayBuffer | ArrayBufferView;
|
|
1475
|
-
|
|
1541
|
+
aad?: Uint8Array | ArrayBuffer | ArrayBufferView | number[] | null;
|
|
1542
|
+
}): Promise<{
|
|
1543
|
+
ciphertext: Uint8Array;
|
|
1544
|
+
tag: Uint8Array;
|
|
1545
|
+
iv: Uint8Array | ArrayBuffer | ArrayBufferView;
|
|
1546
|
+
}>;
|
|
1476
1547
|
aesGcmDecrypt(options: {
|
|
1477
1548
|
key: Uint8Array | ArrayBuffer | ArrayBufferView;
|
|
1478
1549
|
ciphertext: Uint8Array | ArrayBuffer | ArrayBufferView;
|
|
1550
|
+
tag: Uint8Array | ArrayBuffer | ArrayBufferView;
|
|
1479
1551
|
iv: Uint8Array | ArrayBuffer | ArrayBufferView;
|
|
1552
|
+
aad?: Uint8Array | ArrayBuffer | ArrayBufferView | number[] | null;
|
|
1480
1553
|
}): Promise<Uint8Array>;
|
|
1554
|
+
generateX25519Keypair(): Promise<X25519Keypair>;
|
|
1555
|
+
x25519PublicKey(
|
|
1556
|
+
privateKey: Uint8Array | ArrayBuffer | ArrayBufferView | number[],
|
|
1557
|
+
): Promise<Uint8Array>;
|
|
1558
|
+
x25519SharedSecret(
|
|
1559
|
+
privateKey: Uint8Array | ArrayBuffer | ArrayBufferView | number[],
|
|
1560
|
+
publicKey: Uint8Array | ArrayBuffer | ArrayBufferView | number[],
|
|
1561
|
+
): Promise<Uint8Array>;
|
|
1562
|
+
ed25519: {
|
|
1563
|
+
publicKeyFromSeed(
|
|
1564
|
+
seed: Uint8Array | ArrayBuffer | ArrayBufferView | number[],
|
|
1565
|
+
): Promise<Uint8Array>;
|
|
1566
|
+
sign(
|
|
1567
|
+
message: Uint8Array | ArrayBuffer | ArrayBufferView | number[],
|
|
1568
|
+
seed: Uint8Array | ArrayBuffer | ArrayBufferView | number[],
|
|
1569
|
+
): Promise<Uint8Array>;
|
|
1570
|
+
verify(
|
|
1571
|
+
message: Uint8Array | ArrayBuffer | ArrayBufferView | number[],
|
|
1572
|
+
signature: Uint8Array | ArrayBuffer | ArrayBufferView | number[],
|
|
1573
|
+
publicKey: Uint8Array | ArrayBuffer | ArrayBufferView | number[],
|
|
1574
|
+
): Promise<boolean>;
|
|
1575
|
+
};
|
|
1481
1576
|
};
|
|
1482
1577
|
filesystem: BrowserFilesystemShim;
|
|
1483
1578
|
constructor(options?: BrowserHostOptions);
|
|
@@ -1576,6 +1671,7 @@ export interface BrowserModuleHarness {
|
|
|
1576
1671
|
host: BrowserHost;
|
|
1577
1672
|
bridge: HostcallBridge | null;
|
|
1578
1673
|
wasi: BrowserWasiShim;
|
|
1674
|
+
callHost(operation: string, params?: Record<string, any>): Promise<unknown>;
|
|
1579
1675
|
invokeRaw(
|
|
1580
1676
|
requestBytes: Uint8Array | ArrayBuffer | ArrayBufferView,
|
|
1581
1677
|
): Promise<Uint8Array>;
|
|
@@ -1594,7 +1690,7 @@ export interface BrowserModuleHarness {
|
|
|
1594
1690
|
export function detectArtifactProfile(wasmModule: WebAssembly.Module): string;
|
|
1595
1691
|
export function createBrowserModuleHarness(options?: {
|
|
1596
1692
|
wasmSource: Uint8Array | ArrayBuffer | string | WebAssembly.Module | unknown;
|
|
1597
|
-
host?: BrowserHost
|
|
1693
|
+
host?: BrowserHost | RuntimeHost | Record<string, unknown>;
|
|
1598
1694
|
hostOptions?: BrowserHostOptions;
|
|
1599
1695
|
args?: string[];
|
|
1600
1696
|
env?: Record<string, string>;
|
|
@@ -1665,7 +1761,7 @@ export function createModuleFlatBufferStreamPump(options: {
|
|
|
1665
1761
|
}): ModuleFlatBufferStreamPump;
|
|
1666
1762
|
export function loadModule(options?: {
|
|
1667
1763
|
wasmSource: Uint8Array | ArrayBuffer | string | WebAssembly.Module | unknown;
|
|
1668
|
-
host?: BrowserHost
|
|
1764
|
+
host?: BrowserHost | RuntimeHost | Record<string, unknown>;
|
|
1669
1765
|
hostOptions?: BrowserHostOptions;
|
|
1670
1766
|
args?: string[];
|
|
1671
1767
|
env?: Record<string, string | undefined>;
|
|
@@ -3,15 +3,105 @@ import { createFlatBufferStreamIngestor } from "./flatbufferStreamIngestor.js";
|
|
|
3
3
|
import { createRuntimeRegionStore } from "./runtimeRegionStore.js";
|
|
4
4
|
import { createModuleRegistry } from "./moduleRegistry.js";
|
|
5
5
|
|
|
6
|
+
function normalizeCapabilityId(capability) {
|
|
7
|
+
const normalized = String(capability ?? "").trim();
|
|
8
|
+
if (!normalized) {
|
|
9
|
+
throw new TypeError("Capability id is required.");
|
|
10
|
+
}
|
|
11
|
+
return normalized;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function createCapabilityRegistry(capabilities = {}) {
|
|
15
|
+
const entries =
|
|
16
|
+
capabilities instanceof Map
|
|
17
|
+
? capabilities.entries()
|
|
18
|
+
: Object.entries(capabilities ?? {});
|
|
19
|
+
const registry = new Map();
|
|
20
|
+
for (const [capability, adapter] of entries) {
|
|
21
|
+
registry.set(normalizeCapabilityId(capability), adapter);
|
|
22
|
+
}
|
|
23
|
+
return registry;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function listCapabilityOperations(capabilities) {
|
|
27
|
+
const operations = new Set();
|
|
28
|
+
for (const [capabilityId, adapter] of capabilities.entries()) {
|
|
29
|
+
if (!adapter || typeof adapter !== "object") {
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
const methodIds = Object.keys(adapter).filter(
|
|
33
|
+
(methodId) => typeof adapter[methodId] === "function" && methodId !== "invoke",
|
|
34
|
+
);
|
|
35
|
+
if (methodIds.length > 0) {
|
|
36
|
+
for (const methodId of methodIds) {
|
|
37
|
+
operations.add(`${capabilityId}.${methodId}`);
|
|
38
|
+
}
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
if (typeof adapter.invoke === "function") {
|
|
42
|
+
operations.add(`${capabilityId}.invoke`);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return Array.from(operations).sort();
|
|
46
|
+
}
|
|
47
|
+
|
|
6
48
|
export function createRuntimeHost(options = {}) {
|
|
7
49
|
const rows = options.rows ?? createFlatSqlRuntimeStore();
|
|
8
50
|
const regions = options.regions ?? createRuntimeRegionStore();
|
|
9
51
|
const moduleRegistry = options.moduleRegistry ?? createModuleRegistry();
|
|
52
|
+
const capabilities = createCapabilityRegistry(options.capabilities);
|
|
10
53
|
|
|
11
54
|
return {
|
|
12
55
|
rows,
|
|
13
56
|
regions,
|
|
14
57
|
moduleRegistry,
|
|
58
|
+
listCapabilities() {
|
|
59
|
+
return Array.from(capabilities.keys()).sort();
|
|
60
|
+
},
|
|
61
|
+
listSupportedCapabilities() {
|
|
62
|
+
return Array.from(capabilities.keys()).sort();
|
|
63
|
+
},
|
|
64
|
+
listOperations() {
|
|
65
|
+
return listCapabilityOperations(capabilities);
|
|
66
|
+
},
|
|
67
|
+
hasCapability(capability) {
|
|
68
|
+
return capabilities.has(normalizeCapabilityId(capability));
|
|
69
|
+
},
|
|
70
|
+
getCapability(capability) {
|
|
71
|
+
return capabilities.get(normalizeCapabilityId(capability)) ?? null;
|
|
72
|
+
},
|
|
73
|
+
registerCapability(capability, adapter) {
|
|
74
|
+
const normalized = normalizeCapabilityId(capability);
|
|
75
|
+
capabilities.set(normalized, adapter);
|
|
76
|
+
return adapter;
|
|
77
|
+
},
|
|
78
|
+
unregisterCapability(capability) {
|
|
79
|
+
return capabilities.delete(normalizeCapabilityId(capability));
|
|
80
|
+
},
|
|
81
|
+
async invokeCapability(operation, params = {}) {
|
|
82
|
+
const normalized = normalizeCapabilityId(operation);
|
|
83
|
+
const separator = normalized.indexOf(".");
|
|
84
|
+
const capabilityId =
|
|
85
|
+
separator >= 0 ? normalized.slice(0, separator) : normalized;
|
|
86
|
+
const methodId =
|
|
87
|
+
separator >= 0 ? normalized.slice(separator + 1) : "invoke";
|
|
88
|
+
const adapter = capabilities.get(capabilityId);
|
|
89
|
+
if (!adapter || typeof adapter !== "object") {
|
|
90
|
+
throw new Error(`Runtime host capability "${capabilityId}" is not registered.`);
|
|
91
|
+
}
|
|
92
|
+
if (typeof adapter[methodId] === "function") {
|
|
93
|
+
return adapter[methodId](params);
|
|
94
|
+
}
|
|
95
|
+
if (typeof adapter.invoke === "function") {
|
|
96
|
+
return adapter.invoke(methodId, params);
|
|
97
|
+
}
|
|
98
|
+
throw new Error(
|
|
99
|
+
`Runtime host capability "${capabilityId}" does not implement "${methodId}" or invoke().`,
|
|
100
|
+
);
|
|
101
|
+
},
|
|
102
|
+
async invoke(operation, params = {}) {
|
|
103
|
+
return this.invokeCapability(operation, params);
|
|
104
|
+
},
|
|
15
105
|
};
|
|
16
106
|
}
|
|
17
107
|
|
|
@@ -14,9 +14,11 @@
|
|
|
14
14
|
|
|
15
15
|
import { createBrowserWasiShim, WasiExitError } from "../host/wasiShim.js";
|
|
16
16
|
import { createBrowserHost } from "../host/browserHost.js";
|
|
17
|
+
import { getWasmWallet } from "../utils/wasmCrypto.js";
|
|
17
18
|
import {
|
|
18
19
|
createJsonHostcallBridge,
|
|
19
|
-
|
|
20
|
+
createAsyncHostDispatcher,
|
|
21
|
+
createHostSyncDispatcher,
|
|
20
22
|
DEFAULT_HOSTCALL_IMPORT_MODULE,
|
|
21
23
|
} from "../host/abi.js";
|
|
22
24
|
import {
|
|
@@ -90,7 +92,7 @@ async function instantiateBrowserModule(options = {}) {
|
|
|
90
92
|
let instance = null;
|
|
91
93
|
let bridge = null;
|
|
92
94
|
if (needsHostBridge) {
|
|
93
|
-
const dispatch =
|
|
95
|
+
const dispatch = createHostSyncDispatcher(options.host);
|
|
94
96
|
bridge = createJsonHostcallBridge({
|
|
95
97
|
dispatch,
|
|
96
98
|
getMemory: () => instance.exports.memory,
|
|
@@ -125,8 +127,20 @@ async function instantiateBrowserModule(options = {}) {
|
|
|
125
127
|
* @param {string} [options.surface] - "direct" or "command" (default: auto-detect).
|
|
126
128
|
*/
|
|
127
129
|
export async function createBrowserModuleHarness(options = {}) {
|
|
128
|
-
const host = options.host ?? createBrowserHost(options.hostOptions);
|
|
129
130
|
const wasmModule = await compileWasmModule(options.wasmSource);
|
|
131
|
+
const moduleImports = WebAssembly.Module.imports(wasmModule);
|
|
132
|
+
const needsHostBridge = moduleImports.some(
|
|
133
|
+
(entry) => entry.module === DEFAULT_HOSTCALL_IMPORT_MODULE,
|
|
134
|
+
);
|
|
135
|
+
const hostOptions =
|
|
136
|
+
!options.host && needsHostBridge && !options.hostOptions?.wasmWallet
|
|
137
|
+
? {
|
|
138
|
+
...options.hostOptions,
|
|
139
|
+
wasmWallet: await getWasmWallet(),
|
|
140
|
+
}
|
|
141
|
+
: options.hostOptions;
|
|
142
|
+
const host = options.host ?? createBrowserHost(hostOptions);
|
|
143
|
+
const dispatchHost = createAsyncHostDispatcher(host);
|
|
130
144
|
|
|
131
145
|
const profile = detectArtifactProfile(wasmModule);
|
|
132
146
|
const moduleExports = WebAssembly.Module.exports(wasmModule);
|
|
@@ -238,6 +252,10 @@ export async function createBrowserModuleHarness(options = {}) {
|
|
|
238
252
|
return decodePluginInvokeResponse(responseBytes);
|
|
239
253
|
}
|
|
240
254
|
|
|
255
|
+
async function callHost(operation, params = {}) {
|
|
256
|
+
return dispatchHost(operation, params);
|
|
257
|
+
}
|
|
258
|
+
|
|
241
259
|
function readManifest() {
|
|
242
260
|
const getBytesExport =
|
|
243
261
|
instance.exports[DefaultManifestExports.pluginBytesSymbol];
|
|
@@ -267,6 +285,7 @@ export async function createBrowserModuleHarness(options = {}) {
|
|
|
267
285
|
host,
|
|
268
286
|
bridge,
|
|
269
287
|
wasi,
|
|
288
|
+
callHost,
|
|
270
289
|
invoke,
|
|
271
290
|
invokeRaw,
|
|
272
291
|
readManifest,
|
package/src/testing/index.d.ts
CHANGED
|
@@ -335,6 +335,7 @@ export interface BrowserModuleHarness {
|
|
|
335
335
|
stdout: Uint8Array;
|
|
336
336
|
stderr: Uint8Array;
|
|
337
337
|
};
|
|
338
|
+
callHost(operation: string, params?: Record<string, any>): Promise<unknown>;
|
|
338
339
|
invokeRaw(
|
|
339
340
|
requestBytes: Uint8Array | ArrayBuffer | ArrayBufferView,
|
|
340
341
|
): Promise<Uint8Array>;
|
package/src/testing/index.js
CHANGED
|
@@ -98,6 +98,7 @@ const CapabilitySurfaceMatrix = Object.freeze({
|
|
|
98
98
|
notes: [
|
|
99
99
|
"WASI preopens are the preferred cross-runtime filesystem surface.",
|
|
100
100
|
"The sync hostcall ABI currently exposes filesystem.resolvePath only.",
|
|
101
|
+
"Awaited filesystem reads and writes live on the generic async host boundary shared by NodeHost, BrowserHost, runtime-host capability registries, and harness callHost dispatch.",
|
|
101
102
|
],
|
|
102
103
|
}),
|
|
103
104
|
pipe: Object.freeze({
|
|
@@ -120,7 +121,8 @@ const CapabilitySurfaceMatrix = Object.freeze({
|
|
|
120
121
|
syncHostcall: false,
|
|
121
122
|
nodeHostApi: true,
|
|
122
123
|
notes: [
|
|
123
|
-
"The coarse network capability maps to host-side HTTP/TCP/UDP/TLS/WebSocket services
|
|
124
|
+
"The coarse network capability maps to async host-side HTTP/TCP/UDP/TLS/WebSocket services.",
|
|
125
|
+
"Browser and Node harnesses can await the same capability surface through BrowserHost.invoke(), loadModule(...).callHost(...), and createBrowserModuleHarness(...).callHost(...).",
|
|
124
126
|
"Pure WASI guests cannot reach that surface through the current sync hostcall ABI.",
|
|
125
127
|
"WasmEdge provides non-blocking socket-oriented extensions that can serve as the standard server-side max-WASI target.",
|
|
126
128
|
],
|
|
@@ -198,6 +200,42 @@ const CapabilitySurfaceMatrix = Object.freeze({
|
|
|
198
200
|
"WasmEdge TLS support provides a practical no-wrapper server-side target for guest HTTPS/TLS logic.",
|
|
199
201
|
],
|
|
200
202
|
}),
|
|
203
|
+
ipfs: Object.freeze({
|
|
204
|
+
capability: "ipfs",
|
|
205
|
+
wasi: false,
|
|
206
|
+
standaloneWasi: false,
|
|
207
|
+
wasmedge: false,
|
|
208
|
+
syncHostcall: false,
|
|
209
|
+
nodeHostApi: true,
|
|
210
|
+
notes: [
|
|
211
|
+
"IPFS access is available through the generic async host boundary and browser/module harness dispatch.",
|
|
212
|
+
"Pure WASM guests cannot reach that surface through the current sync hostcall ABI.",
|
|
213
|
+
],
|
|
214
|
+
}),
|
|
215
|
+
protocol_handle: Object.freeze({
|
|
216
|
+
capability: "protocol_handle",
|
|
217
|
+
wasi: false,
|
|
218
|
+
standaloneWasi: false,
|
|
219
|
+
wasmedge: false,
|
|
220
|
+
syncHostcall: false,
|
|
221
|
+
nodeHostApi: true,
|
|
222
|
+
notes: [
|
|
223
|
+
"Protocol registration is available through the generic async host boundary and browser/module harness dispatch.",
|
|
224
|
+
"Pure WASM guests cannot reach that surface through the current sync hostcall ABI.",
|
|
225
|
+
],
|
|
226
|
+
}),
|
|
227
|
+
protocol_dial: Object.freeze({
|
|
228
|
+
capability: "protocol_dial",
|
|
229
|
+
wasi: false,
|
|
230
|
+
standaloneWasi: false,
|
|
231
|
+
wasmedge: false,
|
|
232
|
+
syncHostcall: false,
|
|
233
|
+
nodeHostApi: true,
|
|
234
|
+
notes: [
|
|
235
|
+
"Protocol dialing is available through the generic async host boundary and browser/module harness dispatch.",
|
|
236
|
+
"Pure WASM guests cannot reach that surface through the current sync hostcall ABI.",
|
|
237
|
+
],
|
|
238
|
+
}),
|
|
201
239
|
context_read: Object.freeze({
|
|
202
240
|
capability: "context_read",
|
|
203
241
|
wasi: false,
|