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
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
// automatically generated by the FlatBuffers compiler, do not modify
|
|
2
|
+
|
|
3
|
+
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
|
|
4
|
+
|
|
5
|
+
import * as flatbuffers from 'flatbuffers';
|
|
6
|
+
|
|
7
|
+
import { EntityMetadata } from '../../orbpro/entity/entity-metadata.js';
|
|
8
|
+
import { CatalogQueryKind } from '../../orbpro/query/catalog-query-kind.js';
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
export class CatalogQueryResult {
|
|
12
|
+
bb: flatbuffers.ByteBuffer|null = null;
|
|
13
|
+
bb_pos = 0;
|
|
14
|
+
__init(i:number, bb:flatbuffers.ByteBuffer):CatalogQueryResult {
|
|
15
|
+
this.bb_pos = i;
|
|
16
|
+
this.bb = bb;
|
|
17
|
+
return this;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
static getRootAsCatalogQueryResult(bb:flatbuffers.ByteBuffer, obj?:CatalogQueryResult):CatalogQueryResult {
|
|
21
|
+
return (obj || new CatalogQueryResult()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
static getSizePrefixedRootAsCatalogQueryResult(bb:flatbuffers.ByteBuffer, obj?:CatalogQueryResult):CatalogQueryResult {
|
|
25
|
+
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
|
|
26
|
+
return (obj || new CatalogQueryResult()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
static bufferHasIdentifier(bb:flatbuffers.ByteBuffer):boolean {
|
|
30
|
+
return bb.__has_identifier('CQRS');
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
queryKind():CatalogQueryKind {
|
|
34
|
+
const offset = this.bb!.__offset(this.bb_pos, 4);
|
|
35
|
+
return offset ? this.bb!.readUint8(this.bb_pos + offset) : CatalogQueryKind.ROWS;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
rows(index: number, obj?:EntityMetadata):EntityMetadata|null {
|
|
39
|
+
const offset = this.bb!.__offset(this.bb_pos, 6);
|
|
40
|
+
return offset ? (obj || new EntityMetadata()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
rowsLength():number {
|
|
44
|
+
const offset = this.bb!.__offset(this.bb_pos, 6);
|
|
45
|
+
return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
entityIndices(index: number):number|null {
|
|
49
|
+
const offset = this.bb!.__offset(this.bb_pos, 8);
|
|
50
|
+
return offset ? this.bb!.readUint32(this.bb!.__vector(this.bb_pos + offset) + index * 4) : 0;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
entityIndicesLength():number {
|
|
54
|
+
const offset = this.bb!.__offset(this.bb_pos, 8);
|
|
55
|
+
return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
entityIndicesArray():Uint32Array|null {
|
|
59
|
+
const offset = this.bb!.__offset(this.bb_pos, 8);
|
|
60
|
+
return offset ? new Uint32Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
mask(index: number):number|null {
|
|
64
|
+
const offset = this.bb!.__offset(this.bb_pos, 10);
|
|
65
|
+
return offset ? this.bb!.readUint8(this.bb!.__vector(this.bb_pos + offset) + index) : 0;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
maskLength():number {
|
|
69
|
+
const offset = this.bb!.__offset(this.bb_pos, 10);
|
|
70
|
+
return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
maskArray():Uint8Array|null {
|
|
74
|
+
const offset = this.bb!.__offset(this.bb_pos, 10);
|
|
75
|
+
return offset ? new Uint8Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
visibleCount():number {
|
|
79
|
+
const offset = this.bb!.__offset(this.bb_pos, 12);
|
|
80
|
+
return offset ? this.bb!.readUint32(this.bb_pos + offset) : 0;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
entityIndex():number {
|
|
84
|
+
const offset = this.bb!.__offset(this.bb_pos, 14);
|
|
85
|
+
return offset ? this.bb!.readUint32(this.bb_pos + offset) : 0;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
row(obj?:EntityMetadata):EntityMetadata|null {
|
|
89
|
+
const offset = this.bb!.__offset(this.bb_pos, 16);
|
|
90
|
+
return offset ? (obj || new EntityMetadata()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
static startCatalogQueryResult(builder:flatbuffers.Builder) {
|
|
94
|
+
builder.startObject(7);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
static addQueryKind(builder:flatbuffers.Builder, queryKind:CatalogQueryKind) {
|
|
98
|
+
builder.addFieldInt8(0, queryKind, CatalogQueryKind.ROWS);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
static addRows(builder:flatbuffers.Builder, rowsOffset:flatbuffers.Offset) {
|
|
102
|
+
builder.addFieldOffset(1, rowsOffset, 0);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
static createRowsVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
|
|
106
|
+
builder.startVector(4, data.length, 4);
|
|
107
|
+
for (let i = data.length - 1; i >= 0; i--) {
|
|
108
|
+
builder.addOffset(data[i]!);
|
|
109
|
+
}
|
|
110
|
+
return builder.endVector();
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
static startRowsVector(builder:flatbuffers.Builder, numElems:number) {
|
|
114
|
+
builder.startVector(4, numElems, 4);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
static addEntityIndices(builder:flatbuffers.Builder, entityIndicesOffset:flatbuffers.Offset) {
|
|
118
|
+
builder.addFieldOffset(2, entityIndicesOffset, 0);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
static createEntityIndicesVector(builder:flatbuffers.Builder, data:number[]|Uint32Array):flatbuffers.Offset;
|
|
122
|
+
/**
|
|
123
|
+
* @deprecated This Uint8Array overload will be removed in the future.
|
|
124
|
+
*/
|
|
125
|
+
static createEntityIndicesVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset;
|
|
126
|
+
static createEntityIndicesVector(builder:flatbuffers.Builder, data:number[]|Uint32Array|Uint8Array):flatbuffers.Offset {
|
|
127
|
+
builder.startVector(4, data.length, 4);
|
|
128
|
+
for (let i = data.length - 1; i >= 0; i--) {
|
|
129
|
+
builder.addInt32(data[i]!);
|
|
130
|
+
}
|
|
131
|
+
return builder.endVector();
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
static startEntityIndicesVector(builder:flatbuffers.Builder, numElems:number) {
|
|
135
|
+
builder.startVector(4, numElems, 4);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
static addMask(builder:flatbuffers.Builder, maskOffset:flatbuffers.Offset) {
|
|
139
|
+
builder.addFieldOffset(3, maskOffset, 0);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
static createMaskVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset {
|
|
143
|
+
builder.startVector(1, data.length, 1);
|
|
144
|
+
for (let i = data.length - 1; i >= 0; i--) {
|
|
145
|
+
builder.addInt8(data[i]!);
|
|
146
|
+
}
|
|
147
|
+
return builder.endVector();
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
static startMaskVector(builder:flatbuffers.Builder, numElems:number) {
|
|
151
|
+
builder.startVector(1, numElems, 1);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
static addVisibleCount(builder:flatbuffers.Builder, visibleCount:number) {
|
|
155
|
+
builder.addFieldInt32(4, visibleCount, 0);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
static addEntityIndex(builder:flatbuffers.Builder, entityIndex:number) {
|
|
159
|
+
builder.addFieldInt32(5, entityIndex, 0);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
static addRow(builder:flatbuffers.Builder, rowOffset:flatbuffers.Offset) {
|
|
163
|
+
builder.addFieldOffset(6, rowOffset, 0);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
static endCatalogQueryResult(builder:flatbuffers.Builder):flatbuffers.Offset {
|
|
167
|
+
const offset = builder.endObject();
|
|
168
|
+
return offset;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
static finishCatalogQueryResultBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) {
|
|
172
|
+
builder.finish(offset, 'CQRS');
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
static finishSizePrefixedCatalogQueryResultBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) {
|
|
176
|
+
builder.finish(offset, 'CQRS', true);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { CatalogQueryKind } from "./query/catalog-query-kind.js";
|
|
2
|
+
import { CatalogQueryRequest } from "./query/catalog-query-request.js";
|
|
3
|
+
import { CatalogQueryResult } from "./query/catalog-query-result.js";
|
|
4
|
+
export {
|
|
5
|
+
CatalogQueryKind,
|
|
6
|
+
CatalogQueryRequest,
|
|
7
|
+
CatalogQueryResult
|
|
8
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => {
|
|
4
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
+
return value;
|
|
6
|
+
};
|
|
7
|
+
class Vec3 {
|
|
8
|
+
constructor() {
|
|
9
|
+
__publicField(this, "bb", null);
|
|
10
|
+
__publicField(this, "bb_pos", 0);
|
|
11
|
+
}
|
|
12
|
+
__init(i, bb) {
|
|
13
|
+
this.bb_pos = i;
|
|
14
|
+
this.bb = bb;
|
|
15
|
+
return this;
|
|
16
|
+
}
|
|
17
|
+
x() {
|
|
18
|
+
return this.bb.readFloat64(this.bb_pos);
|
|
19
|
+
}
|
|
20
|
+
y() {
|
|
21
|
+
return this.bb.readFloat64(this.bb_pos + 8);
|
|
22
|
+
}
|
|
23
|
+
z() {
|
|
24
|
+
return this.bb.readFloat64(this.bb_pos + 16);
|
|
25
|
+
}
|
|
26
|
+
static sizeOf() {
|
|
27
|
+
return 24;
|
|
28
|
+
}
|
|
29
|
+
static createVec3(builder, x, y, z) {
|
|
30
|
+
builder.prep(8, 24);
|
|
31
|
+
builder.writeFloat64(z);
|
|
32
|
+
builder.writeFloat64(y);
|
|
33
|
+
builder.writeFloat64(x);
|
|
34
|
+
return builder.offset();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
export {
|
|
38
|
+
Vec3
|
|
39
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// automatically generated by the FlatBuffers compiler, do not modify
|
|
2
|
+
|
|
3
|
+
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
|
|
4
|
+
|
|
5
|
+
import * as flatbuffers from 'flatbuffers';
|
|
6
|
+
|
|
7
|
+
export class Vec3 {
|
|
8
|
+
bb: flatbuffers.ByteBuffer|null = null;
|
|
9
|
+
bb_pos = 0;
|
|
10
|
+
__init(i:number, bb:flatbuffers.ByteBuffer):Vec3 {
|
|
11
|
+
this.bb_pos = i;
|
|
12
|
+
this.bb = bb;
|
|
13
|
+
return this;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
x():number {
|
|
17
|
+
return this.bb!.readFloat64(this.bb_pos);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
y():number {
|
|
21
|
+
return this.bb!.readFloat64(this.bb_pos + 8);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
z():number {
|
|
25
|
+
return this.bb!.readFloat64(this.bb_pos + 16);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
static sizeOf():number {
|
|
29
|
+
return 24;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
static createVec3(builder:flatbuffers.Builder, x: number, y: number, z: number):flatbuffers.Offset {
|
|
33
|
+
builder.prep(8, 24);
|
|
34
|
+
builder.writeFloat64(z);
|
|
35
|
+
builder.writeFloat64(y);
|
|
36
|
+
builder.writeFloat64(x);
|
|
37
|
+
return builder.offset();
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
}
|
package/src/host/abi.js
CHANGED
|
@@ -7,7 +7,7 @@ export const DEFAULT_HOSTCALL_IMPORT_MODULE = "sdn_host";
|
|
|
7
7
|
export const HOSTCALL_STATUS_OK = 0;
|
|
8
8
|
export const HOSTCALL_STATUS_ERROR = 1;
|
|
9
9
|
|
|
10
|
-
export const
|
|
10
|
+
export const SyncHostcallOperations = Object.freeze([
|
|
11
11
|
"host.runtimeTarget",
|
|
12
12
|
"host.listCapabilities",
|
|
13
13
|
"host.listSupportedCapabilities",
|
|
@@ -22,6 +22,79 @@ export const NodeHostSyncHostcallOperations = Object.freeze([
|
|
|
22
22
|
"schedule.next",
|
|
23
23
|
"filesystem.resolvePath",
|
|
24
24
|
]);
|
|
25
|
+
export const NodeHostSyncHostcallOperations = SyncHostcallOperations;
|
|
26
|
+
|
|
27
|
+
function normalizeCapabilityOperation(operation) {
|
|
28
|
+
const normalized = assertNonEmptyString(operation, "Host operation");
|
|
29
|
+
const separator = normalized.indexOf(".");
|
|
30
|
+
if (separator <= 0 || separator === normalized.length - 1) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
capabilityId: normalized.slice(0, separator),
|
|
35
|
+
methodId: normalized.slice(separator + 1),
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function getHostCapabilityAdapter(host, capabilityId) {
|
|
40
|
+
if (!host || typeof host !== "object") {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
if (typeof host.getCapability === "function") {
|
|
44
|
+
const adapter = host.getCapability(capabilityId);
|
|
45
|
+
if (adapter) {
|
|
46
|
+
return adapter;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
const capabilityRegistry = host.capabilities;
|
|
50
|
+
if (capabilityRegistry instanceof Map) {
|
|
51
|
+
const adapter = capabilityRegistry.get(capabilityId);
|
|
52
|
+
if (adapter) {
|
|
53
|
+
return adapter;
|
|
54
|
+
}
|
|
55
|
+
} else if (capabilityRegistry && typeof capabilityRegistry === "object") {
|
|
56
|
+
const adapter = capabilityRegistry[capabilityId];
|
|
57
|
+
if (adapter) {
|
|
58
|
+
return adapter;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const directAdapter = host[capabilityId];
|
|
63
|
+
if (directAdapter && typeof directAdapter === "object") {
|
|
64
|
+
return directAdapter;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const camelCapabilityId = capabilityId.replace(/_([a-z])/g, (_, letter) =>
|
|
68
|
+
letter.toUpperCase(),
|
|
69
|
+
);
|
|
70
|
+
const camelAdapter = host[camelCapabilityId];
|
|
71
|
+
if (camelAdapter && typeof camelAdapter === "object") {
|
|
72
|
+
return camelAdapter;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
async function dispatchHostCapabilityOperation(host, operation, params = null) {
|
|
79
|
+
const normalized = normalizeCapabilityOperation(operation);
|
|
80
|
+
if (!normalized) {
|
|
81
|
+
return undefined;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const adapter = getHostCapabilityAdapter(host, normalized.capabilityId);
|
|
85
|
+
if (!adapter || typeof adapter !== "object") {
|
|
86
|
+
return undefined;
|
|
87
|
+
}
|
|
88
|
+
if (typeof adapter[normalized.methodId] === "function") {
|
|
89
|
+
return adapter[normalized.methodId](params);
|
|
90
|
+
}
|
|
91
|
+
if (typeof adapter.invoke === "function") {
|
|
92
|
+
return adapter.invoke(normalized.methodId, params);
|
|
93
|
+
}
|
|
94
|
+
throw new Error(
|
|
95
|
+
`Host capability "${normalized.capabilityId}" does not implement "${normalized.methodId}" or invoke().`,
|
|
96
|
+
);
|
|
97
|
+
}
|
|
25
98
|
|
|
26
99
|
function assertNonEmptyString(value, label) {
|
|
27
100
|
const normalized = String(value ?? "").trim();
|
|
@@ -108,6 +181,15 @@ function isPromiseLike(value) {
|
|
|
108
181
|
);
|
|
109
182
|
}
|
|
110
183
|
|
|
184
|
+
function assertSyncHostcallResult(value, operation) {
|
|
185
|
+
if (isPromiseLike(value)) {
|
|
186
|
+
throw new Error(
|
|
187
|
+
`Operation "${operation}" is not available in the synchronous hostcall ABI.`,
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
return value;
|
|
191
|
+
}
|
|
192
|
+
|
|
111
193
|
function encodeHostcallValue(value) {
|
|
112
194
|
if (value === undefined) {
|
|
113
195
|
return undefined;
|
|
@@ -149,7 +231,7 @@ function encodeHostcallValue(value) {
|
|
|
149
231
|
return value;
|
|
150
232
|
}
|
|
151
233
|
|
|
152
|
-
export function
|
|
234
|
+
export function dispatchHostSyncOperation(host, operation, params = null) {
|
|
153
235
|
const normalized = assertNonEmptyString(operation, "Hostcall operation");
|
|
154
236
|
switch (normalized) {
|
|
155
237
|
case "host.runtimeTarget":
|
|
@@ -178,6 +260,65 @@ export function dispatchNodeHostSyncOperation(host, operation, params = null) {
|
|
|
178
260
|
return host.schedule.next(params?.expression, params?.from);
|
|
179
261
|
case "filesystem.resolvePath":
|
|
180
262
|
return host.filesystem.resolvePath(params?.path);
|
|
263
|
+
case "crypto.sha256":
|
|
264
|
+
return assertSyncHostcallResult(
|
|
265
|
+
host.crypto.sha256(params?.value ?? params?.bytes),
|
|
266
|
+
normalized,
|
|
267
|
+
);
|
|
268
|
+
case "crypto.sha512":
|
|
269
|
+
return assertSyncHostcallResult(
|
|
270
|
+
host.crypto.sha512(params?.value ?? params?.bytes),
|
|
271
|
+
normalized,
|
|
272
|
+
);
|
|
273
|
+
case "crypto.hkdf":
|
|
274
|
+
return assertSyncHostcallResult(host.crypto.hkdf(params), normalized);
|
|
275
|
+
case "crypto.aesGcmEncrypt":
|
|
276
|
+
return assertSyncHostcallResult(
|
|
277
|
+
host.crypto.aesGcmEncrypt(params),
|
|
278
|
+
normalized,
|
|
279
|
+
);
|
|
280
|
+
case "crypto.aesGcmDecrypt":
|
|
281
|
+
return assertSyncHostcallResult(
|
|
282
|
+
host.crypto.aesGcmDecrypt(params),
|
|
283
|
+
normalized,
|
|
284
|
+
);
|
|
285
|
+
case "crypto.x25519.generateKeypair":
|
|
286
|
+
return assertSyncHostcallResult(
|
|
287
|
+
host.crypto.generateX25519Keypair(),
|
|
288
|
+
normalized,
|
|
289
|
+
);
|
|
290
|
+
case "crypto.x25519.publicKey":
|
|
291
|
+
return assertSyncHostcallResult(
|
|
292
|
+
host.crypto.x25519PublicKey(params?.privateKey),
|
|
293
|
+
normalized,
|
|
294
|
+
);
|
|
295
|
+
case "crypto.x25519.sharedSecret":
|
|
296
|
+
return assertSyncHostcallResult(
|
|
297
|
+
host.crypto.x25519SharedSecret(
|
|
298
|
+
params?.privateKey,
|
|
299
|
+
params?.publicKey,
|
|
300
|
+
),
|
|
301
|
+
normalized,
|
|
302
|
+
);
|
|
303
|
+
case "crypto.ed25519.publicKeyFromSeed":
|
|
304
|
+
return assertSyncHostcallResult(
|
|
305
|
+
host.crypto.ed25519.publicKeyFromSeed(params?.seed),
|
|
306
|
+
normalized,
|
|
307
|
+
);
|
|
308
|
+
case "crypto.ed25519.sign":
|
|
309
|
+
return assertSyncHostcallResult(
|
|
310
|
+
host.crypto.ed25519.sign(params?.message, params?.seed),
|
|
311
|
+
normalized,
|
|
312
|
+
);
|
|
313
|
+
case "crypto.ed25519.verify":
|
|
314
|
+
return assertSyncHostcallResult(
|
|
315
|
+
host.crypto.ed25519.verify(
|
|
316
|
+
params?.message,
|
|
317
|
+
params?.signature,
|
|
318
|
+
params?.publicKey,
|
|
319
|
+
),
|
|
320
|
+
normalized,
|
|
321
|
+
);
|
|
181
322
|
default:
|
|
182
323
|
throw new Error(
|
|
183
324
|
`Operation "${normalized}" is not available in the synchronous hostcall ABI.`,
|
|
@@ -185,12 +326,57 @@ export function dispatchNodeHostSyncOperation(host, operation, params = null) {
|
|
|
185
326
|
}
|
|
186
327
|
}
|
|
187
328
|
|
|
329
|
+
export function dispatchNodeHostSyncOperation(host, operation, params = null) {
|
|
330
|
+
return dispatchHostSyncOperation(host, operation, params);
|
|
331
|
+
}
|
|
332
|
+
|
|
188
333
|
export function createNodeHostSyncDispatcher(host) {
|
|
189
334
|
if (!host || typeof host !== "object") {
|
|
190
335
|
throw new TypeError("createNodeHostSyncDispatcher requires a host object.");
|
|
191
336
|
}
|
|
192
337
|
return (operation, params = null) =>
|
|
193
|
-
|
|
338
|
+
dispatchHostSyncOperation(host, operation, params);
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
export function createHostSyncDispatcher(host) {
|
|
342
|
+
return createNodeHostSyncDispatcher(host);
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
export async function dispatchHostOperation(host, operation, params = null) {
|
|
346
|
+
if (!host || typeof host !== "object") {
|
|
347
|
+
throw new TypeError("dispatchHostOperation requires a host object.");
|
|
348
|
+
}
|
|
349
|
+
const normalized = assertNonEmptyString(operation, "Host operation");
|
|
350
|
+
if (typeof host.invoke === "function") {
|
|
351
|
+
return host.invoke(normalized, params);
|
|
352
|
+
}
|
|
353
|
+
if (typeof host.invokeCapability === "function") {
|
|
354
|
+
try {
|
|
355
|
+
return host.invokeCapability(normalized, params);
|
|
356
|
+
} catch (error) {
|
|
357
|
+
if (SyncHostcallOperations.includes(normalized)) {
|
|
358
|
+
return dispatchHostSyncOperation(host, normalized, params);
|
|
359
|
+
}
|
|
360
|
+
throw error;
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
const genericResult = await dispatchHostCapabilityOperation(
|
|
364
|
+
host,
|
|
365
|
+
normalized,
|
|
366
|
+
params,
|
|
367
|
+
);
|
|
368
|
+
if (genericResult !== undefined) {
|
|
369
|
+
return genericResult;
|
|
370
|
+
}
|
|
371
|
+
return dispatchHostSyncOperation(host, normalized, params);
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
export function createAsyncHostDispatcher(host) {
|
|
375
|
+
if (!host || typeof host !== "object") {
|
|
376
|
+
throw new TypeError("createAsyncHostDispatcher requires a host object.");
|
|
377
|
+
}
|
|
378
|
+
return (operation, params = null) =>
|
|
379
|
+
dispatchHostOperation(host, operation, params);
|
|
194
380
|
}
|
|
195
381
|
|
|
196
382
|
export function createJsonHostcallBridge(options = {}) {
|
|
@@ -341,13 +341,30 @@ export function createMemoryFilesystemEdgeShim(options = {}) {
|
|
|
341
341
|
}
|
|
342
342
|
|
|
343
343
|
export function createBrowserEdgeShims(options = {}) {
|
|
344
|
+
const capabilityAdapters =
|
|
345
|
+
options.capabilityAdapters && typeof options.capabilityAdapters === "object"
|
|
346
|
+
? options.capabilityAdapters
|
|
347
|
+
: {};
|
|
344
348
|
return Object.freeze({
|
|
345
349
|
fetch: options.fetch ?? globalThis.fetch?.bind(globalThis),
|
|
346
350
|
WebSocket: options.WebSocket ?? globalThis.WebSocket,
|
|
347
351
|
crypto: options.crypto ?? globalThis.crypto,
|
|
348
352
|
performance: options.performance ?? globalThis.performance,
|
|
353
|
+
network: options.network ?? capabilityAdapters.network ?? null,
|
|
354
|
+
ipfs: options.ipfs ?? capabilityAdapters.ipfs ?? null,
|
|
355
|
+
protocolHandle:
|
|
356
|
+
options.protocolHandle ??
|
|
357
|
+
capabilityAdapters.protocolHandle ??
|
|
358
|
+
capabilityAdapters.protocol_handle ??
|
|
359
|
+
null,
|
|
360
|
+
protocolDial:
|
|
361
|
+
options.protocolDial ??
|
|
362
|
+
capabilityAdapters.protocolDial ??
|
|
363
|
+
capabilityAdapters.protocol_dial ??
|
|
364
|
+
null,
|
|
349
365
|
filesystem:
|
|
350
366
|
options.filesystem ??
|
|
367
|
+
capabilityAdapters.filesystem ??
|
|
351
368
|
createMemoryFilesystemEdgeShim({
|
|
352
369
|
filesystemRoot: options.filesystemRoot ?? "/",
|
|
353
370
|
}),
|