@rybosome/tspice 0.0.1 → 0.0.2-alpha
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/backend-contract/dist/.tsbuildinfo +1 -1
- package/backend-contract/dist/domains/coords-vectors.d.ts +30 -0
- package/backend-contract/dist/domains/coords-vectors.js +2 -0
- package/backend-contract/dist/domains/ephemeris.d.ts +8 -0
- package/backend-contract/dist/domains/ephemeris.js +2 -0
- package/backend-contract/dist/domains/frames.d.ts +33 -0
- package/backend-contract/dist/domains/frames.js +2 -0
- package/backend-contract/dist/domains/geometry.d.ts +14 -0
- package/backend-contract/dist/domains/geometry.js +2 -0
- package/backend-contract/dist/domains/ids-names.d.ts +10 -0
- package/backend-contract/dist/domains/ids-names.js +2 -0
- package/backend-contract/dist/domains/kernels.d.ts +22 -0
- package/backend-contract/dist/domains/kernels.js +2 -0
- package/backend-contract/dist/domains/time.d.ts +24 -0
- package/backend-contract/dist/domains/time.js +2 -0
- package/backend-contract/dist/index.d.ts +17 -222
- package/backend-contract/dist/index.js +8 -1
- package/backend-contract/dist/shared/types.d.ts +108 -0
- package/backend-contract/dist/shared/types.js +2 -0
- package/backend-fake/dist/.tsbuildinfo +1 -1
- package/backend-node/dist/.tsbuildinfo +1 -1
- package/backend-node/dist/codec/errors.d.ts +9 -0
- package/backend-node/dist/codec/errors.js +14 -0
- package/backend-node/dist/domains/coords-vectors.d.ts +4 -0
- package/backend-node/dist/domains/coords-vectors.js +62 -0
- package/backend-node/dist/domains/ephemeris.d.ts +4 -0
- package/backend-node/dist/domains/ephemeris.js +24 -0
- package/backend-node/dist/domains/frames.d.ts +4 -0
- package/backend-node/dist/domains/frames.js +74 -0
- package/backend-node/dist/domains/geometry.d.ts +4 -0
- package/backend-node/dist/domains/geometry.js +67 -0
- package/backend-node/dist/domains/ids-names.d.ts +4 -0
- package/backend-node/dist/domains/ids-names.js +22 -0
- package/backend-node/dist/domains/kernels.d.ts +5 -0
- package/backend-node/dist/domains/kernels.js +37 -0
- package/backend-node/dist/domains/time.d.ts +4 -0
- package/backend-node/dist/domains/time.js +36 -0
- package/backend-node/dist/index.js +18 -373
- package/backend-node/dist/lowlevel/binding.d.ts +3 -0
- package/backend-node/dist/lowlevel/binding.js +44 -0
- package/backend-node/dist/native.d.ts +2 -111
- package/backend-node/dist/native.js +1 -101
- package/backend-node/dist/runtime/addon.d.ts +112 -0
- package/backend-node/dist/runtime/addon.js +102 -0
- package/backend-node/dist/runtime/kernel-staging.d.ts +9 -0
- package/backend-node/dist/runtime/kernel-staging.js +75 -0
- package/backend-wasm/dist/.tsbuildinfo +1 -1
- package/backend-wasm/dist/codec/calls.d.ts +4 -0
- package/backend-wasm/dist/codec/calls.js +41 -0
- package/backend-wasm/dist/codec/errors.d.ts +3 -0
- package/backend-wasm/dist/codec/errors.js +5 -0
- package/backend-wasm/dist/codec/found.d.ts +9 -0
- package/backend-wasm/dist/codec/found.js +68 -0
- package/backend-wasm/dist/codec/strings.d.ts +3 -0
- package/backend-wasm/dist/codec/strings.js +12 -0
- package/backend-wasm/dist/domains/coords-vectors.d.ts +4 -0
- package/backend-wasm/dist/domains/coords-vectors.js +312 -0
- package/backend-wasm/dist/domains/ephemeris.d.ts +4 -0
- package/backend-wasm/dist/domains/ephemeris.js +81 -0
- package/backend-wasm/dist/domains/frames.d.ts +4 -0
- package/backend-wasm/dist/domains/frames.js +239 -0
- package/backend-wasm/dist/domains/geometry.d.ts +4 -0
- package/backend-wasm/dist/domains/geometry.js +240 -0
- package/backend-wasm/dist/domains/ids-names.d.ts +4 -0
- package/backend-wasm/dist/domains/ids-names.js +18 -0
- package/backend-wasm/dist/domains/kernels.d.ts +5 -0
- package/backend-wasm/dist/domains/kernels.js +97 -0
- package/backend-wasm/dist/domains/time.d.ts +5 -0
- package/backend-wasm/dist/domains/time.js +180 -0
- package/backend-wasm/dist/index.d.ts +2 -7
- package/backend-wasm/dist/index.js +1 -1504
- package/backend-wasm/dist/lowlevel/exports.d.ts +49 -0
- package/backend-wasm/dist/lowlevel/exports.js +41 -0
- package/backend-wasm/dist/runtime/create-backend.d.ts +8 -0
- package/backend-wasm/dist/runtime/create-backend.js +81 -0
- package/backend-wasm/dist/runtime/fs.d.ts +9 -0
- package/backend-wasm/dist/runtime/fs.js +30 -0
- package/dist/.tsbuildinfo +1 -1
- package/package.json +4 -4
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { invariant } from "#core";
|
|
2
|
+
export function createTimeApi(native) {
|
|
3
|
+
return {
|
|
4
|
+
spiceVersion: () => {
|
|
5
|
+
const version = native.spiceVersion();
|
|
6
|
+
invariant(typeof version === "string", "Expected native backend spiceVersion() to return a string");
|
|
7
|
+
return version;
|
|
8
|
+
},
|
|
9
|
+
tkvrsn: (item) => {
|
|
10
|
+
invariant(item === "TOOLKIT", `Unsupported tkvrsn item: ${item}`);
|
|
11
|
+
const version = native.spiceVersion();
|
|
12
|
+
invariant(typeof version === "string", "Expected native backend spiceVersion() to return a string");
|
|
13
|
+
return version;
|
|
14
|
+
},
|
|
15
|
+
str2et: (time) => {
|
|
16
|
+
return native.str2et(time);
|
|
17
|
+
},
|
|
18
|
+
et2utc: (et, format, prec) => {
|
|
19
|
+
return native.et2utc(et, format, prec);
|
|
20
|
+
},
|
|
21
|
+
timout: (et, picture) => {
|
|
22
|
+
return native.timout(et, picture);
|
|
23
|
+
},
|
|
24
|
+
scs2e: (sc, sclkch) => {
|
|
25
|
+
const et = native.scs2e(sc, sclkch);
|
|
26
|
+
invariant(typeof et === "number", "Expected scs2e() to return a number");
|
|
27
|
+
return et;
|
|
28
|
+
},
|
|
29
|
+
sce2s: (sc, et) => {
|
|
30
|
+
const out = native.sce2s(sc, et);
|
|
31
|
+
invariant(typeof out === "string", "Expected sce2s() to return a string");
|
|
32
|
+
return out;
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=time.js.map
|
|
@@ -1,386 +1,31 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
import os from "node:os";
|
|
3
|
-
import path from "node:path";
|
|
4
|
-
import { randomUUID } from "node:crypto";
|
|
5
1
|
import { invariant } from "#core";
|
|
6
2
|
import { getNativeAddon } from "./native.js";
|
|
3
|
+
import { getNodeBinding } from "./lowlevel/binding.js";
|
|
4
|
+
import { createKernelStager } from "./runtime/kernel-staging.js";
|
|
5
|
+
import { createCoordsVectorsApi } from "./domains/coords-vectors.js";
|
|
6
|
+
import { createEphemerisApi } from "./domains/ephemeris.js";
|
|
7
|
+
import { createFramesApi } from "./domains/frames.js";
|
|
8
|
+
import { createGeometryApi } from "./domains/geometry.js";
|
|
9
|
+
import { createIdsNamesApi } from "./domains/ids-names.js";
|
|
10
|
+
import { createKernelsApi } from "./domains/kernels.js";
|
|
11
|
+
import { createTimeApi } from "./domains/time.js";
|
|
7
12
|
export function spiceVersion() {
|
|
8
13
|
const version = getNativeAddon().spiceVersion();
|
|
9
14
|
invariant(typeof version === "string", "Expected native backend spiceVersion() to return a string");
|
|
10
15
|
return version;
|
|
11
16
|
}
|
|
12
17
|
export function createNodeBackend() {
|
|
13
|
-
const native =
|
|
14
|
-
|
|
15
|
-
invariant(typeof native.unload === "function", "Expected native addon to export unload(path)");
|
|
16
|
-
invariant(typeof native.kclear === "function", "Expected native addon to export kclear()");
|
|
17
|
-
invariant(typeof native.ktotal === "function", "Expected native addon to export ktotal(kind?)");
|
|
18
|
-
invariant(typeof native.kdata === "function", "Expected native addon to export kdata(which, kind?)");
|
|
19
|
-
invariant(typeof native.str2et === "function", "Expected native addon to export str2et(time)");
|
|
20
|
-
invariant(typeof native.et2utc === "function", "Expected native addon to export et2utc(et, format, prec)");
|
|
21
|
-
invariant(typeof native.timout === "function", "Expected native addon to export timout(et, picture)");
|
|
22
|
-
invariant(typeof native.bodn2c === "function", "Expected native addon to export bodn2c(name)");
|
|
23
|
-
invariant(typeof native.bodc2n === "function", "Expected native addon to export bodc2n(code)");
|
|
24
|
-
invariant(typeof native.namfrm === "function", "Expected native addon to export namfrm(name)");
|
|
25
|
-
invariant(typeof native.frmnam === "function", "Expected native addon to export frmnam(code)");
|
|
26
|
-
invariant(typeof native.cidfrm === "function", "Expected native addon to export cidfrm(center)");
|
|
27
|
-
invariant(typeof native.cnmfrm === "function", "Expected native addon to export cnmfrm(centerName)");
|
|
28
|
-
invariant(typeof native.scs2e === "function", "Expected native addon to export scs2e(sc, sclkch)");
|
|
29
|
-
invariant(typeof native.sce2s === "function", "Expected native addon to export sce2s(sc, et)");
|
|
30
|
-
invariant(typeof native.ckgp === "function", "Expected native addon to export ckgp(inst, sclkdp, tol, ref)");
|
|
31
|
-
invariant(typeof native.ckgpav === "function", "Expected native addon to export ckgpav(inst, sclkdp, tol, ref)");
|
|
32
|
-
invariant(typeof native.pxform === "function", "Expected native addon to export pxform(from, to, et)");
|
|
33
|
-
invariant(typeof native.sxform === "function", "Expected native addon to export sxform(from, to, et)");
|
|
34
|
-
invariant(typeof native.reclat === "function", "Expected native addon to export reclat(rect)");
|
|
35
|
-
invariant(typeof native.latrec === "function", "Expected native addon to export latrec(radius, lon, lat)");
|
|
36
|
-
invariant(typeof native.recsph === "function", "Expected native addon to export recsph(rect)");
|
|
37
|
-
invariant(typeof native.sphrec === "function", "Expected native addon to export sphrec(radius, colat, lon)");
|
|
38
|
-
invariant(typeof native.vnorm === "function", "Expected native addon to export vnorm(v)");
|
|
39
|
-
invariant(typeof native.vhat === "function", "Expected native addon to export vhat(v)");
|
|
40
|
-
invariant(typeof native.vdot === "function", "Expected native addon to export vdot(a, b)");
|
|
41
|
-
invariant(typeof native.vcrss === "function", "Expected native addon to export vcrss(a, b)");
|
|
42
|
-
invariant(typeof native.mxv === "function", "Expected native addon to export mxv(m, v)");
|
|
43
|
-
invariant(typeof native.mtxv === "function", "Expected native addon to export mtxv(m, v)");
|
|
44
|
-
invariant(typeof native.spkezr === "function", "Expected native addon to export spkezr(target, et, ref, abcorr, observer)");
|
|
45
|
-
invariant(typeof native.spkpos === "function", "Expected native addon to export spkpos(target, et, ref, abcorr, observer)");
|
|
46
|
-
invariant(typeof native.subpnt === "function", "Expected native addon to export subpnt(method, target, et, fixref, abcorr, observer)");
|
|
47
|
-
invariant(typeof native.subslr === "function", "Expected native addon to export subslr(method, target, et, fixref, abcorr, observer)");
|
|
48
|
-
invariant(typeof native.sincpt === "function", "Expected native addon to export sincpt(method, target, et, fixref, abcorr, observer, dref, dvec)");
|
|
49
|
-
invariant(typeof native.ilumin === "function", "Expected native addon to export ilumin(method, target, et, fixref, abcorr, observer, spoint)");
|
|
50
|
-
invariant(typeof native.occult === "function", "Expected native addon to export occult(targ1, shape1, frame1, targ2, shape2, frame2, abcorr, observer, et)");
|
|
51
|
-
const tempByVirtualPath = new Map();
|
|
52
|
-
let tempKernelRootDir;
|
|
53
|
-
function ensureTempKernelRootDir() {
|
|
54
|
-
if (tempKernelRootDir) {
|
|
55
|
-
return tempKernelRootDir;
|
|
56
|
-
}
|
|
57
|
-
tempKernelRootDir = fs.mkdtempSync(path.join(os.tmpdir(), "tspice-kernels-"));
|
|
58
|
-
return tempKernelRootDir;
|
|
59
|
-
}
|
|
60
|
-
function safeUnlink(filePath) {
|
|
61
|
-
try {
|
|
62
|
-
fs.unlinkSync(filePath);
|
|
63
|
-
}
|
|
64
|
-
catch (error) {
|
|
65
|
-
// Best-effort cleanup.
|
|
66
|
-
if (error?.code !== "ENOENT") {
|
|
67
|
-
throw error;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
18
|
+
const native = getNodeBinding();
|
|
19
|
+
const stager = createKernelStager();
|
|
71
20
|
const backend = {
|
|
72
21
|
kind: "node",
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
// For byte-backed kernels, we write to a temp file and load via CSPICE.
|
|
81
|
-
// We then remember the resolved temp path so `unload(kernel.path)` unloads
|
|
82
|
-
// the correct file.
|
|
83
|
-
const existingTemp = tempByVirtualPath.get(kernel.path);
|
|
84
|
-
if (existingTemp) {
|
|
85
|
-
native.unload(existingTemp);
|
|
86
|
-
tempByVirtualPath.delete(kernel.path);
|
|
87
|
-
safeUnlink(existingTemp);
|
|
88
|
-
}
|
|
89
|
-
const rootDir = ensureTempKernelRootDir();
|
|
90
|
-
const fileName = path.basename(kernel.path) || "kernel";
|
|
91
|
-
const tempPath = path.join(rootDir, `${randomUUID()}-${fileName}`);
|
|
92
|
-
fs.writeFileSync(tempPath, kernel.bytes);
|
|
93
|
-
try {
|
|
94
|
-
native.furnsh(tempPath);
|
|
95
|
-
}
|
|
96
|
-
catch (error) {
|
|
97
|
-
safeUnlink(tempPath);
|
|
98
|
-
throw error;
|
|
99
|
-
}
|
|
100
|
-
tempByVirtualPath.set(kernel.path, tempPath);
|
|
101
|
-
},
|
|
102
|
-
unload: (_path) => {
|
|
103
|
-
const resolved = tempByVirtualPath.get(_path);
|
|
104
|
-
if (resolved) {
|
|
105
|
-
native.unload(resolved);
|
|
106
|
-
tempByVirtualPath.delete(_path);
|
|
107
|
-
safeUnlink(resolved);
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
native.unload(_path);
|
|
111
|
-
},
|
|
112
|
-
kclear: () => {
|
|
113
|
-
native.kclear();
|
|
114
|
-
// Clear any byte-backed kernels we staged to temp files.
|
|
115
|
-
for (const tempPath of tempByVirtualPath.values()) {
|
|
116
|
-
safeUnlink(tempPath);
|
|
117
|
-
}
|
|
118
|
-
tempByVirtualPath.clear();
|
|
119
|
-
},
|
|
120
|
-
ktotal: (kind = "ALL") => {
|
|
121
|
-
const total = native.ktotal(kind);
|
|
122
|
-
invariant(typeof total === "number", "Expected native backend ktotal() to return a number");
|
|
123
|
-
return total;
|
|
124
|
-
},
|
|
125
|
-
kdata: (which, kind = "ALL") => {
|
|
126
|
-
const result = native.kdata(which, kind);
|
|
127
|
-
if (!result.found) {
|
|
128
|
-
return { found: false };
|
|
129
|
-
}
|
|
130
|
-
invariant(typeof result.file === "string", "Expected kdata().file to be a string");
|
|
131
|
-
invariant(typeof result.filtyp === "string", "Expected kdata().filtyp to be a string");
|
|
132
|
-
invariant(typeof result.source === "string", "Expected kdata().source to be a string");
|
|
133
|
-
invariant(typeof result.handle === "number", "Expected kdata().handle to be a number");
|
|
134
|
-
return {
|
|
135
|
-
found: true,
|
|
136
|
-
file: result.file,
|
|
137
|
-
filtyp: result.filtyp,
|
|
138
|
-
source: result.source,
|
|
139
|
-
handle: result.handle,
|
|
140
|
-
};
|
|
141
|
-
},
|
|
142
|
-
tkvrsn: (item) => {
|
|
143
|
-
invariant(item === "TOOLKIT", `Unsupported tkvrsn item: ${item}`);
|
|
144
|
-
return spiceVersion();
|
|
145
|
-
},
|
|
146
|
-
str2et: (time) => {
|
|
147
|
-
return native.str2et(time);
|
|
148
|
-
},
|
|
149
|
-
et2utc: (et, format, prec) => {
|
|
150
|
-
return native.et2utc(et, format, prec);
|
|
151
|
-
},
|
|
152
|
-
timout: (et, picture) => {
|
|
153
|
-
return native.timout(et, picture);
|
|
154
|
-
},
|
|
155
|
-
bodn2c: (name) => {
|
|
156
|
-
const out = native.bodn2c(name);
|
|
157
|
-
if (!out.found) {
|
|
158
|
-
return { found: false };
|
|
159
|
-
}
|
|
160
|
-
invariant(typeof out.code === "number", "Expected bodn2c().code to be a number");
|
|
161
|
-
return { found: true, code: out.code };
|
|
162
|
-
},
|
|
163
|
-
bodc2n: (code) => {
|
|
164
|
-
const out = native.bodc2n(code);
|
|
165
|
-
if (!out.found) {
|
|
166
|
-
return { found: false };
|
|
167
|
-
}
|
|
168
|
-
invariant(typeof out.name === "string", "Expected bodc2n().name to be a string");
|
|
169
|
-
return { found: true, name: out.name };
|
|
170
|
-
},
|
|
171
|
-
namfrm: (name) => {
|
|
172
|
-
const out = native.namfrm(name);
|
|
173
|
-
if (!out.found) {
|
|
174
|
-
return { found: false };
|
|
175
|
-
}
|
|
176
|
-
invariant(typeof out.code === "number", "Expected namfrm().code to be a number");
|
|
177
|
-
return { found: true, code: out.code };
|
|
178
|
-
},
|
|
179
|
-
frmnam: (code) => {
|
|
180
|
-
const out = native.frmnam(code);
|
|
181
|
-
if (!out.found) {
|
|
182
|
-
return { found: false };
|
|
183
|
-
}
|
|
184
|
-
invariant(typeof out.name === "string", "Expected frmnam().name to be a string");
|
|
185
|
-
return { found: true, name: out.name };
|
|
186
|
-
},
|
|
187
|
-
cidfrm: (center) => {
|
|
188
|
-
const out = native.cidfrm(center);
|
|
189
|
-
if (!out.found) {
|
|
190
|
-
return { found: false };
|
|
191
|
-
}
|
|
192
|
-
invariant(typeof out.frcode === "number", "Expected cidfrm().frcode to be a number");
|
|
193
|
-
invariant(typeof out.frname === "string", "Expected cidfrm().frname to be a string");
|
|
194
|
-
return { found: true, frcode: out.frcode, frname: out.frname };
|
|
195
|
-
},
|
|
196
|
-
cnmfrm: (centerName) => {
|
|
197
|
-
const out = native.cnmfrm(centerName);
|
|
198
|
-
if (!out.found) {
|
|
199
|
-
return { found: false };
|
|
200
|
-
}
|
|
201
|
-
invariant(typeof out.frcode === "number", "Expected cnmfrm().frcode to be a number");
|
|
202
|
-
invariant(typeof out.frname === "string", "Expected cnmfrm().frname to be a string");
|
|
203
|
-
return { found: true, frcode: out.frcode, frname: out.frname };
|
|
204
|
-
},
|
|
205
|
-
scs2e: (sc, sclkch) => {
|
|
206
|
-
const et = native.scs2e(sc, sclkch);
|
|
207
|
-
invariant(typeof et === "number", "Expected scs2e() to return a number");
|
|
208
|
-
return et;
|
|
209
|
-
},
|
|
210
|
-
sce2s: (sc, et) => {
|
|
211
|
-
const out = native.sce2s(sc, et);
|
|
212
|
-
invariant(typeof out === "string", "Expected sce2s() to return a string");
|
|
213
|
-
return out;
|
|
214
|
-
},
|
|
215
|
-
ckgp: (inst, sclkdp, tol, ref) => {
|
|
216
|
-
const out = native.ckgp(inst, sclkdp, tol, ref);
|
|
217
|
-
if (!out.found) {
|
|
218
|
-
return { found: false };
|
|
219
|
-
}
|
|
220
|
-
invariant(Array.isArray(out.cmat) && out.cmat.length === 9, "Expected ckgp().cmat to be a length-9 array");
|
|
221
|
-
invariant(typeof out.clkout === "number", "Expected ckgp().clkout to be a number");
|
|
222
|
-
return { found: true, cmat: out.cmat, clkout: out.clkout };
|
|
223
|
-
},
|
|
224
|
-
ckgpav: (inst, sclkdp, tol, ref) => {
|
|
225
|
-
const out = native.ckgpav(inst, sclkdp, tol, ref);
|
|
226
|
-
if (!out.found) {
|
|
227
|
-
return { found: false };
|
|
228
|
-
}
|
|
229
|
-
invariant(Array.isArray(out.cmat) && out.cmat.length === 9, "Expected ckgpav().cmat to be a length-9 array");
|
|
230
|
-
invariant(Array.isArray(out.av) && out.av.length === 3, "Expected ckgpav().av to be a length-3 array");
|
|
231
|
-
invariant(typeof out.clkout === "number", "Expected ckgpav().clkout to be a number");
|
|
232
|
-
return {
|
|
233
|
-
found: true,
|
|
234
|
-
cmat: out.cmat,
|
|
235
|
-
av: out.av,
|
|
236
|
-
clkout: out.clkout,
|
|
237
|
-
};
|
|
238
|
-
},
|
|
239
|
-
pxform: (from, to, et) => {
|
|
240
|
-
const m = native.pxform(from, to, et);
|
|
241
|
-
invariant(Array.isArray(m) && m.length === 9, "Expected pxform() to return a length-9 array");
|
|
242
|
-
return m;
|
|
243
|
-
},
|
|
244
|
-
sxform: (from, to, et) => {
|
|
245
|
-
const m = native.sxform(from, to, et);
|
|
246
|
-
invariant(Array.isArray(m) && m.length === 36, "Expected sxform() to return a length-36 array");
|
|
247
|
-
return m;
|
|
248
|
-
},
|
|
249
|
-
spkezr: (target, et, ref, abcorr, observer) => {
|
|
250
|
-
const out = native.spkezr(target, et, ref, abcorr, observer);
|
|
251
|
-
invariant(out && typeof out === "object", "Expected spkezr() to return an object");
|
|
252
|
-
invariant(Array.isArray(out.state) && out.state.length === 6, "Expected spkezr().state to be a length-6 array");
|
|
253
|
-
invariant(typeof out.lt === "number", "Expected spkezr().lt to be a number");
|
|
254
|
-
const state = out.state;
|
|
255
|
-
const result = { state, lt: out.lt };
|
|
256
|
-
return result;
|
|
257
|
-
},
|
|
258
|
-
spkpos: (target, et, ref, abcorr, observer) => {
|
|
259
|
-
const out = native.spkpos(target, et, ref, abcorr, observer);
|
|
260
|
-
invariant(out && typeof out === "object", "Expected spkpos() to return an object");
|
|
261
|
-
invariant(Array.isArray(out.pos) && out.pos.length === 3, "Expected spkpos().pos to be a length-3 array");
|
|
262
|
-
invariant(typeof out.lt === "number", "Expected spkpos().lt to be a number");
|
|
263
|
-
const pos = out.pos;
|
|
264
|
-
const result = { pos, lt: out.lt };
|
|
265
|
-
return result;
|
|
266
|
-
},
|
|
267
|
-
reclat: (rect) => {
|
|
268
|
-
const out = native.reclat(rect);
|
|
269
|
-
invariant(out && typeof out === "object", "Expected reclat() to return an object");
|
|
270
|
-
invariant(typeof out.radius === "number", "Expected reclat().radius to be a number");
|
|
271
|
-
invariant(typeof out.lon === "number", "Expected reclat().lon to be a number");
|
|
272
|
-
invariant(typeof out.lat === "number", "Expected reclat().lat to be a number");
|
|
273
|
-
return { radius: out.radius, lon: out.lon, lat: out.lat };
|
|
274
|
-
},
|
|
275
|
-
latrec: (radius, lon, lat) => {
|
|
276
|
-
const out = native.latrec(radius, lon, lat);
|
|
277
|
-
invariant(Array.isArray(out) && out.length === 3, "Expected latrec() to return a length-3 array");
|
|
278
|
-
return out;
|
|
279
|
-
},
|
|
280
|
-
recsph: (rect) => {
|
|
281
|
-
const out = native.recsph(rect);
|
|
282
|
-
invariant(out && typeof out === "object", "Expected recsph() to return an object");
|
|
283
|
-
invariant(typeof out.radius === "number", "Expected recsph().radius to be a number");
|
|
284
|
-
invariant(typeof out.colat === "number", "Expected recsph().colat to be a number");
|
|
285
|
-
invariant(typeof out.lon === "number", "Expected recsph().lon to be a number");
|
|
286
|
-
return { radius: out.radius, colat: out.colat, lon: out.lon };
|
|
287
|
-
},
|
|
288
|
-
sphrec: (radius, colat, lon) => {
|
|
289
|
-
const out = native.sphrec(radius, colat, lon);
|
|
290
|
-
invariant(Array.isArray(out) && out.length === 3, "Expected sphrec() to return a length-3 array");
|
|
291
|
-
return out;
|
|
292
|
-
},
|
|
293
|
-
vnorm: (v) => {
|
|
294
|
-
const out = native.vnorm(v);
|
|
295
|
-
invariant(typeof out === "number", "Expected vnorm() to return a number");
|
|
296
|
-
return out;
|
|
297
|
-
},
|
|
298
|
-
vhat: (v) => {
|
|
299
|
-
const out = native.vhat(v);
|
|
300
|
-
invariant(Array.isArray(out) && out.length === 3, "Expected vhat() to return a length-3 array");
|
|
301
|
-
return out;
|
|
302
|
-
},
|
|
303
|
-
vdot: (a, b) => {
|
|
304
|
-
const out = native.vdot(a, b);
|
|
305
|
-
invariant(typeof out === "number", "Expected vdot() to return a number");
|
|
306
|
-
return out;
|
|
307
|
-
},
|
|
308
|
-
vcrss: (a, b) => {
|
|
309
|
-
const out = native.vcrss(a, b);
|
|
310
|
-
invariant(Array.isArray(out) && out.length === 3, "Expected vcrss() to return a length-3 array");
|
|
311
|
-
return out;
|
|
312
|
-
},
|
|
313
|
-
mxv: (m, v) => {
|
|
314
|
-
const out = native.mxv(m, v);
|
|
315
|
-
invariant(Array.isArray(out) && out.length === 3, "Expected mxv() to return a length-3 array");
|
|
316
|
-
return out;
|
|
317
|
-
},
|
|
318
|
-
mtxv: (m, v) => {
|
|
319
|
-
const out = native.mtxv(m, v);
|
|
320
|
-
invariant(Array.isArray(out) && out.length === 3, "Expected mtxv() to return a length-3 array");
|
|
321
|
-
return out;
|
|
322
|
-
},
|
|
323
|
-
subpnt: (method, target, et, fixref, abcorr, observer) => {
|
|
324
|
-
const out = native.subpnt(method, target, et, fixref, abcorr, observer);
|
|
325
|
-
invariant(out && typeof out === "object", "Expected subpnt() to return an object");
|
|
326
|
-
invariant(Array.isArray(out.spoint) && out.spoint.length === 3, "Expected subpnt().spoint to be a length-3 array");
|
|
327
|
-
invariant(typeof out.trgepc === "number", "Expected subpnt().trgepc to be a number");
|
|
328
|
-
invariant(Array.isArray(out.srfvec) && out.srfvec.length === 3, "Expected subpnt().srfvec to be a length-3 array");
|
|
329
|
-
return {
|
|
330
|
-
spoint: out.spoint,
|
|
331
|
-
trgepc: out.trgepc,
|
|
332
|
-
srfvec: out.srfvec,
|
|
333
|
-
};
|
|
334
|
-
},
|
|
335
|
-
subslr: (method, target, et, fixref, abcorr, observer) => {
|
|
336
|
-
const out = native.subslr(method, target, et, fixref, abcorr, observer);
|
|
337
|
-
invariant(out && typeof out === "object", "Expected subslr() to return an object");
|
|
338
|
-
invariant(Array.isArray(out.spoint) && out.spoint.length === 3, "Expected subslr().spoint to be a length-3 array");
|
|
339
|
-
invariant(typeof out.trgepc === "number", "Expected subslr().trgepc to be a number");
|
|
340
|
-
invariant(Array.isArray(out.srfvec) && out.srfvec.length === 3, "Expected subslr().srfvec to be a length-3 array");
|
|
341
|
-
return {
|
|
342
|
-
spoint: out.spoint,
|
|
343
|
-
trgepc: out.trgepc,
|
|
344
|
-
srfvec: out.srfvec,
|
|
345
|
-
};
|
|
346
|
-
},
|
|
347
|
-
sincpt: (method, target, et, fixref, abcorr, observer, dref, dvec) => {
|
|
348
|
-
const out = native.sincpt(method, target, et, fixref, abcorr, observer, dref, dvec);
|
|
349
|
-
if (!out.found) {
|
|
350
|
-
return { found: false };
|
|
351
|
-
}
|
|
352
|
-
invariant(out && typeof out === "object", "Expected sincpt() to return an object");
|
|
353
|
-
invariant(Array.isArray(out.spoint) && out.spoint.length === 3, "Expected sincpt().spoint to be a length-3 array");
|
|
354
|
-
invariant(typeof out.trgepc === "number", "Expected sincpt().trgepc to be a number");
|
|
355
|
-
invariant(Array.isArray(out.srfvec) && out.srfvec.length === 3, "Expected sincpt().srfvec to be a length-3 array");
|
|
356
|
-
return {
|
|
357
|
-
found: true,
|
|
358
|
-
spoint: out.spoint,
|
|
359
|
-
trgepc: out.trgepc,
|
|
360
|
-
srfvec: out.srfvec,
|
|
361
|
-
};
|
|
362
|
-
},
|
|
363
|
-
ilumin: (method, target, et, fixref, abcorr, observer, spoint) => {
|
|
364
|
-
const out = native.ilumin(method, target, et, fixref, abcorr, observer, spoint);
|
|
365
|
-
invariant(out && typeof out === "object", "Expected ilumin() to return an object");
|
|
366
|
-
invariant(typeof out.trgepc === "number", "Expected ilumin().trgepc to be a number");
|
|
367
|
-
invariant(Array.isArray(out.srfvec) && out.srfvec.length === 3, "Expected ilumin().srfvec to be a length-3 array");
|
|
368
|
-
invariant(typeof out.phase === "number", "Expected ilumin().phase to be a number");
|
|
369
|
-
invariant(typeof out.incdnc === "number", "Expected ilumin().incdnc to be a number");
|
|
370
|
-
invariant(typeof out.emissn === "number", "Expected ilumin().emissn to be a number");
|
|
371
|
-
return {
|
|
372
|
-
trgepc: out.trgepc,
|
|
373
|
-
srfvec: out.srfvec,
|
|
374
|
-
phase: out.phase,
|
|
375
|
-
incdnc: out.incdnc,
|
|
376
|
-
emissn: out.emissn,
|
|
377
|
-
};
|
|
378
|
-
},
|
|
379
|
-
occult: (targ1, shape1, frame1, targ2, shape2, frame2, abcorr, observer, et) => {
|
|
380
|
-
const out = native.occult(targ1, shape1, frame1, targ2, shape2, frame2, abcorr, observer, et);
|
|
381
|
-
invariant(typeof out === "number", "Expected occult() to return a number");
|
|
382
|
-
return out;
|
|
383
|
-
},
|
|
22
|
+
...createTimeApi(native),
|
|
23
|
+
...createKernelsApi(native, stager),
|
|
24
|
+
...createIdsNamesApi(native),
|
|
25
|
+
...createFramesApi(native),
|
|
26
|
+
...createEphemerisApi(native),
|
|
27
|
+
...createGeometryApi(native),
|
|
28
|
+
...createCoordsVectorsApi(native),
|
|
384
29
|
};
|
|
385
30
|
// Internal testing hook (not part of the public backend contract).
|
|
386
31
|
backend.__ktotalAll = () => native.__ktotalAll();
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { invariant } from "#core";
|
|
2
|
+
import { getNativeAddon } from "../runtime/addon.js";
|
|
3
|
+
export function getNodeBinding() {
|
|
4
|
+
const native = getNativeAddon();
|
|
5
|
+
invariant(typeof native.furnsh === "function", "Expected native addon to export furnsh(path)");
|
|
6
|
+
invariant(typeof native.unload === "function", "Expected native addon to export unload(path)");
|
|
7
|
+
invariant(typeof native.kclear === "function", "Expected native addon to export kclear()");
|
|
8
|
+
invariant(typeof native.ktotal === "function", "Expected native addon to export ktotal(kind?)");
|
|
9
|
+
invariant(typeof native.kdata === "function", "Expected native addon to export kdata(which, kind?)");
|
|
10
|
+
invariant(typeof native.str2et === "function", "Expected native addon to export str2et(time)");
|
|
11
|
+
invariant(typeof native.et2utc === "function", "Expected native addon to export et2utc(et, format, prec)");
|
|
12
|
+
invariant(typeof native.timout === "function", "Expected native addon to export timout(et, picture)");
|
|
13
|
+
invariant(typeof native.bodn2c === "function", "Expected native addon to export bodn2c(name)");
|
|
14
|
+
invariant(typeof native.bodc2n === "function", "Expected native addon to export bodc2n(code)");
|
|
15
|
+
invariant(typeof native.namfrm === "function", "Expected native addon to export namfrm(name)");
|
|
16
|
+
invariant(typeof native.frmnam === "function", "Expected native addon to export frmnam(code)");
|
|
17
|
+
invariant(typeof native.cidfrm === "function", "Expected native addon to export cidfrm(center)");
|
|
18
|
+
invariant(typeof native.cnmfrm === "function", "Expected native addon to export cnmfrm(centerName)");
|
|
19
|
+
invariant(typeof native.scs2e === "function", "Expected native addon to export scs2e(sc, sclkch)");
|
|
20
|
+
invariant(typeof native.sce2s === "function", "Expected native addon to export sce2s(sc, et)");
|
|
21
|
+
invariant(typeof native.ckgp === "function", "Expected native addon to export ckgp(inst, sclkdp, tol, ref)");
|
|
22
|
+
invariant(typeof native.ckgpav === "function", "Expected native addon to export ckgpav(inst, sclkdp, tol, ref)");
|
|
23
|
+
invariant(typeof native.pxform === "function", "Expected native addon to export pxform(from, to, et)");
|
|
24
|
+
invariant(typeof native.sxform === "function", "Expected native addon to export sxform(from, to, et)");
|
|
25
|
+
invariant(typeof native.reclat === "function", "Expected native addon to export reclat(rect)");
|
|
26
|
+
invariant(typeof native.latrec === "function", "Expected native addon to export latrec(radius, lon, lat)");
|
|
27
|
+
invariant(typeof native.recsph === "function", "Expected native addon to export recsph(rect)");
|
|
28
|
+
invariant(typeof native.sphrec === "function", "Expected native addon to export sphrec(radius, colat, lon)");
|
|
29
|
+
invariant(typeof native.vnorm === "function", "Expected native addon to export vnorm(v)");
|
|
30
|
+
invariant(typeof native.vhat === "function", "Expected native addon to export vhat(v)");
|
|
31
|
+
invariant(typeof native.vdot === "function", "Expected native addon to export vdot(a, b)");
|
|
32
|
+
invariant(typeof native.vcrss === "function", "Expected native addon to export vcrss(a, b)");
|
|
33
|
+
invariant(typeof native.mxv === "function", "Expected native addon to export mxv(m, v)");
|
|
34
|
+
invariant(typeof native.mtxv === "function", "Expected native addon to export mtxv(m, v)");
|
|
35
|
+
invariant(typeof native.spkezr === "function", "Expected native addon to export spkezr(target, et, ref, abcorr, observer)");
|
|
36
|
+
invariant(typeof native.spkpos === "function", "Expected native addon to export spkpos(target, et, ref, abcorr, observer)");
|
|
37
|
+
invariant(typeof native.subpnt === "function", "Expected native addon to export subpnt(method, target, et, fixref, abcorr, observer)");
|
|
38
|
+
invariant(typeof native.subslr === "function", "Expected native addon to export subslr(method, target, et, fixref, abcorr, observer)");
|
|
39
|
+
invariant(typeof native.sincpt === "function", "Expected native addon to export sincpt(method, target, et, fixref, abcorr, observer, dref, dvec)");
|
|
40
|
+
invariant(typeof native.ilumin === "function", "Expected native addon to export ilumin(method, target, et, fixref, abcorr, observer, spoint)");
|
|
41
|
+
invariant(typeof native.occult === "function", "Expected native addon to export occult(targ1, shape1, frame1, targ2, shape2, frame2, abcorr, observer, et)");
|
|
42
|
+
return native;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=binding.js.map
|
|
@@ -1,112 +1,3 @@
|
|
|
1
|
-
export type NativeAddon
|
|
2
|
-
|
|
3
|
-
furnsh(path: string): void;
|
|
4
|
-
unload(path: string): void;
|
|
5
|
-
kclear(): void;
|
|
6
|
-
ktotal(kind?: string): number;
|
|
7
|
-
kdata(which: number, kind?: string): {
|
|
8
|
-
found: boolean;
|
|
9
|
-
file?: string;
|
|
10
|
-
filtyp?: string;
|
|
11
|
-
source?: string;
|
|
12
|
-
handle?: number;
|
|
13
|
-
};
|
|
14
|
-
str2et(utc: string): number;
|
|
15
|
-
et2utc(et: number, format: string, prec: number): string;
|
|
16
|
-
timout(et: number, picture: string): string;
|
|
17
|
-
bodn2c(name: string): {
|
|
18
|
-
found: boolean;
|
|
19
|
-
code?: number;
|
|
20
|
-
};
|
|
21
|
-
bodc2n(code: number): {
|
|
22
|
-
found: boolean;
|
|
23
|
-
name?: string;
|
|
24
|
-
};
|
|
25
|
-
namfrm(name: string): {
|
|
26
|
-
found: boolean;
|
|
27
|
-
code?: number;
|
|
28
|
-
};
|
|
29
|
-
frmnam(code: number): {
|
|
30
|
-
found: boolean;
|
|
31
|
-
name?: string;
|
|
32
|
-
};
|
|
33
|
-
cidfrm(center: number): {
|
|
34
|
-
found: boolean;
|
|
35
|
-
frcode?: number;
|
|
36
|
-
frname?: string;
|
|
37
|
-
};
|
|
38
|
-
cnmfrm(centerName: string): {
|
|
39
|
-
found: boolean;
|
|
40
|
-
frcode?: number;
|
|
41
|
-
frname?: string;
|
|
42
|
-
};
|
|
43
|
-
scs2e(sc: number, sclkch: string): number;
|
|
44
|
-
sce2s(sc: number, et: number): string;
|
|
45
|
-
ckgp(inst: number, sclkdp: number, tol: number, ref: string): {
|
|
46
|
-
found: boolean;
|
|
47
|
-
cmat?: number[];
|
|
48
|
-
clkout?: number;
|
|
49
|
-
};
|
|
50
|
-
ckgpav(inst: number, sclkdp: number, tol: number, ref: string): {
|
|
51
|
-
found: boolean;
|
|
52
|
-
cmat?: number[];
|
|
53
|
-
av?: number[];
|
|
54
|
-
clkout?: number;
|
|
55
|
-
};
|
|
56
|
-
spkezr(target: string, et: number, ref: string, abcorr: string, obs: string): {
|
|
57
|
-
state: number[];
|
|
58
|
-
lt: number;
|
|
59
|
-
};
|
|
60
|
-
spkpos(target: string, et: number, ref: string, abcorr: string, obs: string): {
|
|
61
|
-
pos: number[];
|
|
62
|
-
lt: number;
|
|
63
|
-
};
|
|
64
|
-
subpnt(method: string, target: string, et: number, fixref: string, abcorr: string, observer: string): {
|
|
65
|
-
spoint: number[];
|
|
66
|
-
trgepc: number;
|
|
67
|
-
srfvec: number[];
|
|
68
|
-
};
|
|
69
|
-
subslr(method: string, target: string, et: number, fixref: string, abcorr: string, observer: string): {
|
|
70
|
-
spoint: number[];
|
|
71
|
-
trgepc: number;
|
|
72
|
-
srfvec: number[];
|
|
73
|
-
};
|
|
74
|
-
sincpt(method: string, target: string, et: number, fixref: string, abcorr: string, observer: string, dref: string, dvec: number[]): {
|
|
75
|
-
found: boolean;
|
|
76
|
-
spoint?: number[];
|
|
77
|
-
trgepc?: number;
|
|
78
|
-
srfvec?: number[];
|
|
79
|
-
};
|
|
80
|
-
ilumin(method: string, target: string, et: number, fixref: string, abcorr: string, observer: string, spoint: number[]): {
|
|
81
|
-
trgepc: number;
|
|
82
|
-
srfvec: number[];
|
|
83
|
-
phase: number;
|
|
84
|
-
incdnc: number;
|
|
85
|
-
emissn: number;
|
|
86
|
-
};
|
|
87
|
-
occult(targ1: string, shape1: string, frame1: string, targ2: string, shape2: string, frame2: string, abcorr: string, observer: string, et: number): number;
|
|
88
|
-
pxform(from: string, to: string, et: number): number[];
|
|
89
|
-
sxform(from: string, to: string, et: number): number[];
|
|
90
|
-
reclat(rect: number[]): {
|
|
91
|
-
radius: number;
|
|
92
|
-
lon: number;
|
|
93
|
-
lat: number;
|
|
94
|
-
};
|
|
95
|
-
latrec(radius: number, lon: number, lat: number): number[];
|
|
96
|
-
recsph(rect: number[]): {
|
|
97
|
-
radius: number;
|
|
98
|
-
colat: number;
|
|
99
|
-
lon: number;
|
|
100
|
-
};
|
|
101
|
-
sphrec(radius: number, colat: number, lon: number): number[];
|
|
102
|
-
vnorm(v: number[]): number;
|
|
103
|
-
vhat(v: number[]): number[];
|
|
104
|
-
vdot(a: number[], b: number[]): number;
|
|
105
|
-
vcrss(a: number[], b: number[]): number[];
|
|
106
|
-
mxv(m: number[], v: number[]): number[];
|
|
107
|
-
mtxv(m: number[], v: number[]): number[];
|
|
108
|
-
/** Internal test helper (not part of the backend contract). */
|
|
109
|
-
__ktotalAll(): number;
|
|
110
|
-
};
|
|
111
|
-
export declare function getNativeAddon(): NativeAddon;
|
|
1
|
+
export type { NativeAddon } from "./runtime/addon.js";
|
|
2
|
+
export { getNativeAddon } from "./runtime/addon.js";
|
|
112
3
|
//# sourceMappingURL=native.d.ts.map
|