@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,240 @@
|
|
|
1
|
+
import { throwWasmSpiceError } from "../codec/errors.js";
|
|
2
|
+
import { writeUtf8CString } from "../codec/strings.js";
|
|
3
|
+
function tspiceCallSubpnt(module, method, target, et, fixref, abcorr, observer) {
|
|
4
|
+
const errMaxBytes = 2048;
|
|
5
|
+
const errPtr = module._malloc(errMaxBytes);
|
|
6
|
+
const methodPtr = writeUtf8CString(module, method);
|
|
7
|
+
const targetPtr = writeUtf8CString(module, target);
|
|
8
|
+
const fixrefPtr = writeUtf8CString(module, fixref);
|
|
9
|
+
const abcorrPtr = writeUtf8CString(module, abcorr);
|
|
10
|
+
const observerPtr = writeUtf8CString(module, observer);
|
|
11
|
+
const outSpointPtr = module._malloc(3 * 8);
|
|
12
|
+
const outTrgepcPtr = module._malloc(8);
|
|
13
|
+
const outSrfvecPtr = module._malloc(3 * 8);
|
|
14
|
+
if (!errPtr || !methodPtr || !targetPtr || !fixrefPtr || !abcorrPtr || !observerPtr || !outSpointPtr || !outTrgepcPtr || !outSrfvecPtr) {
|
|
15
|
+
for (const ptr of [outSrfvecPtr, outTrgepcPtr, outSpointPtr, observerPtr, abcorrPtr, fixrefPtr, targetPtr, methodPtr, errPtr]) {
|
|
16
|
+
if (ptr)
|
|
17
|
+
module._free(ptr);
|
|
18
|
+
}
|
|
19
|
+
throw new Error("WASM malloc failed");
|
|
20
|
+
}
|
|
21
|
+
try {
|
|
22
|
+
module.HEAPF64[outTrgepcPtr >> 3] = 0;
|
|
23
|
+
const result = module._tspice_subpnt(methodPtr, targetPtr, et, fixrefPtr, abcorrPtr, observerPtr, outSpointPtr, outTrgepcPtr, outSrfvecPtr, errPtr, errMaxBytes);
|
|
24
|
+
if (result !== 0) {
|
|
25
|
+
throwWasmSpiceError(module, errPtr, errMaxBytes, result);
|
|
26
|
+
}
|
|
27
|
+
const spoint = Array.from(module.HEAPF64.subarray(outSpointPtr >> 3, (outSpointPtr >> 3) + 3));
|
|
28
|
+
const trgepc = module.HEAPF64[outTrgepcPtr >> 3] ?? 0;
|
|
29
|
+
const srfvec = Array.from(module.HEAPF64.subarray(outSrfvecPtr >> 3, (outSrfvecPtr >> 3) + 3));
|
|
30
|
+
return { spoint, trgepc, srfvec };
|
|
31
|
+
}
|
|
32
|
+
finally {
|
|
33
|
+
module._free(outSrfvecPtr);
|
|
34
|
+
module._free(outTrgepcPtr);
|
|
35
|
+
module._free(outSpointPtr);
|
|
36
|
+
module._free(observerPtr);
|
|
37
|
+
module._free(abcorrPtr);
|
|
38
|
+
module._free(fixrefPtr);
|
|
39
|
+
module._free(targetPtr);
|
|
40
|
+
module._free(methodPtr);
|
|
41
|
+
module._free(errPtr);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function tspiceCallSubslr(module, method, target, et, fixref, abcorr, observer) {
|
|
45
|
+
const errMaxBytes = 2048;
|
|
46
|
+
const errPtr = module._malloc(errMaxBytes);
|
|
47
|
+
const methodPtr = writeUtf8CString(module, method);
|
|
48
|
+
const targetPtr = writeUtf8CString(module, target);
|
|
49
|
+
const fixrefPtr = writeUtf8CString(module, fixref);
|
|
50
|
+
const abcorrPtr = writeUtf8CString(module, abcorr);
|
|
51
|
+
const observerPtr = writeUtf8CString(module, observer);
|
|
52
|
+
const outSpointPtr = module._malloc(3 * 8);
|
|
53
|
+
const outTrgepcPtr = module._malloc(8);
|
|
54
|
+
const outSrfvecPtr = module._malloc(3 * 8);
|
|
55
|
+
if (!errPtr || !methodPtr || !targetPtr || !fixrefPtr || !abcorrPtr || !observerPtr || !outSpointPtr || !outTrgepcPtr || !outSrfvecPtr) {
|
|
56
|
+
for (const ptr of [outSrfvecPtr, outTrgepcPtr, outSpointPtr, observerPtr, abcorrPtr, fixrefPtr, targetPtr, methodPtr, errPtr]) {
|
|
57
|
+
if (ptr)
|
|
58
|
+
module._free(ptr);
|
|
59
|
+
}
|
|
60
|
+
throw new Error("WASM malloc failed");
|
|
61
|
+
}
|
|
62
|
+
try {
|
|
63
|
+
module.HEAPF64[outTrgepcPtr >> 3] = 0;
|
|
64
|
+
const result = module._tspice_subslr(methodPtr, targetPtr, et, fixrefPtr, abcorrPtr, observerPtr, outSpointPtr, outTrgepcPtr, outSrfvecPtr, errPtr, errMaxBytes);
|
|
65
|
+
if (result !== 0) {
|
|
66
|
+
throwWasmSpiceError(module, errPtr, errMaxBytes, result);
|
|
67
|
+
}
|
|
68
|
+
const spoint = Array.from(module.HEAPF64.subarray(outSpointPtr >> 3, (outSpointPtr >> 3) + 3));
|
|
69
|
+
const trgepc = module.HEAPF64[outTrgepcPtr >> 3] ?? 0;
|
|
70
|
+
const srfvec = Array.from(module.HEAPF64.subarray(outSrfvecPtr >> 3, (outSrfvecPtr >> 3) + 3));
|
|
71
|
+
return { spoint, trgepc, srfvec };
|
|
72
|
+
}
|
|
73
|
+
finally {
|
|
74
|
+
module._free(outSrfvecPtr);
|
|
75
|
+
module._free(outTrgepcPtr);
|
|
76
|
+
module._free(outSpointPtr);
|
|
77
|
+
module._free(observerPtr);
|
|
78
|
+
module._free(abcorrPtr);
|
|
79
|
+
module._free(fixrefPtr);
|
|
80
|
+
module._free(targetPtr);
|
|
81
|
+
module._free(methodPtr);
|
|
82
|
+
module._free(errPtr);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
function tspiceCallSincpt(module, method, target, et, fixref, abcorr, observer, dref, dvec) {
|
|
86
|
+
const errMaxBytes = 2048;
|
|
87
|
+
const errPtr = module._malloc(errMaxBytes);
|
|
88
|
+
const methodPtr = writeUtf8CString(module, method);
|
|
89
|
+
const targetPtr = writeUtf8CString(module, target);
|
|
90
|
+
const fixrefPtr = writeUtf8CString(module, fixref);
|
|
91
|
+
const abcorrPtr = writeUtf8CString(module, abcorr);
|
|
92
|
+
const observerPtr = writeUtf8CString(module, observer);
|
|
93
|
+
const drefPtr = writeUtf8CString(module, dref);
|
|
94
|
+
const dvecPtr = module._malloc(3 * 8);
|
|
95
|
+
const outSpointPtr = module._malloc(3 * 8);
|
|
96
|
+
const outTrgepcPtr = module._malloc(8);
|
|
97
|
+
const outSrfvecPtr = module._malloc(3 * 8);
|
|
98
|
+
const outFoundPtr = module._malloc(4);
|
|
99
|
+
if (!errPtr || !methodPtr || !targetPtr || !fixrefPtr || !abcorrPtr || !observerPtr || !drefPtr || !dvecPtr || !outSpointPtr || !outTrgepcPtr || !outSrfvecPtr || !outFoundPtr) {
|
|
100
|
+
for (const ptr of [outFoundPtr, outSrfvecPtr, outTrgepcPtr, outSpointPtr, dvecPtr, drefPtr, observerPtr, abcorrPtr, fixrefPtr, targetPtr, methodPtr, errPtr]) {
|
|
101
|
+
if (ptr)
|
|
102
|
+
module._free(ptr);
|
|
103
|
+
}
|
|
104
|
+
throw new Error("WASM malloc failed");
|
|
105
|
+
}
|
|
106
|
+
try {
|
|
107
|
+
module.HEAPF64.set(dvec, dvecPtr >> 3);
|
|
108
|
+
module.HEAPF64[outTrgepcPtr >> 3] = 0;
|
|
109
|
+
module.HEAP32[outFoundPtr >> 2] = 0;
|
|
110
|
+
const result = module._tspice_sincpt(methodPtr, targetPtr, et, fixrefPtr, abcorrPtr, observerPtr, drefPtr, dvecPtr, outSpointPtr, outTrgepcPtr, outSrfvecPtr, outFoundPtr, errPtr, errMaxBytes);
|
|
111
|
+
if (result !== 0) {
|
|
112
|
+
throwWasmSpiceError(module, errPtr, errMaxBytes, result);
|
|
113
|
+
}
|
|
114
|
+
const found = module.HEAP32[outFoundPtr >> 2] ?? 0;
|
|
115
|
+
if (!found) {
|
|
116
|
+
return { found: false };
|
|
117
|
+
}
|
|
118
|
+
const spoint = Array.from(module.HEAPF64.subarray(outSpointPtr >> 3, (outSpointPtr >> 3) + 3));
|
|
119
|
+
const trgepc = module.HEAPF64[outTrgepcPtr >> 3] ?? 0;
|
|
120
|
+
const srfvec = Array.from(module.HEAPF64.subarray(outSrfvecPtr >> 3, (outSrfvecPtr >> 3) + 3));
|
|
121
|
+
return { found: true, spoint, trgepc, srfvec };
|
|
122
|
+
}
|
|
123
|
+
finally {
|
|
124
|
+
module._free(outFoundPtr);
|
|
125
|
+
module._free(outSrfvecPtr);
|
|
126
|
+
module._free(outTrgepcPtr);
|
|
127
|
+
module._free(outSpointPtr);
|
|
128
|
+
module._free(dvecPtr);
|
|
129
|
+
module._free(drefPtr);
|
|
130
|
+
module._free(observerPtr);
|
|
131
|
+
module._free(abcorrPtr);
|
|
132
|
+
module._free(fixrefPtr);
|
|
133
|
+
module._free(targetPtr);
|
|
134
|
+
module._free(methodPtr);
|
|
135
|
+
module._free(errPtr);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
function tspiceCallIlumin(module, method, target, et, fixref, abcorr, observer, spoint) {
|
|
139
|
+
const errMaxBytes = 2048;
|
|
140
|
+
const errPtr = module._malloc(errMaxBytes);
|
|
141
|
+
const methodPtr = writeUtf8CString(module, method);
|
|
142
|
+
const targetPtr = writeUtf8CString(module, target);
|
|
143
|
+
const fixrefPtr = writeUtf8CString(module, fixref);
|
|
144
|
+
const abcorrPtr = writeUtf8CString(module, abcorr);
|
|
145
|
+
const observerPtr = writeUtf8CString(module, observer);
|
|
146
|
+
const spointPtr = module._malloc(3 * 8);
|
|
147
|
+
const outTrgepcPtr = module._malloc(8);
|
|
148
|
+
const outSrfvecPtr = module._malloc(3 * 8);
|
|
149
|
+
const outPhasePtr = module._malloc(8);
|
|
150
|
+
const outIncdncPtr = module._malloc(8);
|
|
151
|
+
const outEmissnPtr = module._malloc(8);
|
|
152
|
+
if (!errPtr || !methodPtr || !targetPtr || !fixrefPtr || !abcorrPtr || !observerPtr || !spointPtr || !outTrgepcPtr || !outSrfvecPtr || !outPhasePtr || !outIncdncPtr || !outEmissnPtr) {
|
|
153
|
+
for (const ptr of [outEmissnPtr, outIncdncPtr, outPhasePtr, outSrfvecPtr, outTrgepcPtr, spointPtr, observerPtr, abcorrPtr, fixrefPtr, targetPtr, methodPtr, errPtr]) {
|
|
154
|
+
if (ptr)
|
|
155
|
+
module._free(ptr);
|
|
156
|
+
}
|
|
157
|
+
throw new Error("WASM malloc failed");
|
|
158
|
+
}
|
|
159
|
+
try {
|
|
160
|
+
module.HEAPF64.set(spoint, spointPtr >> 3);
|
|
161
|
+
module.HEAPF64[outTrgepcPtr >> 3] = 0;
|
|
162
|
+
module.HEAPF64[outPhasePtr >> 3] = 0;
|
|
163
|
+
module.HEAPF64[outIncdncPtr >> 3] = 0;
|
|
164
|
+
module.HEAPF64[outEmissnPtr >> 3] = 0;
|
|
165
|
+
const result = module._tspice_ilumin(methodPtr, targetPtr, et, fixrefPtr, abcorrPtr, observerPtr, spointPtr, outTrgepcPtr, outSrfvecPtr, outPhasePtr, outIncdncPtr, outEmissnPtr, errPtr, errMaxBytes);
|
|
166
|
+
if (result !== 0) {
|
|
167
|
+
throwWasmSpiceError(module, errPtr, errMaxBytes, result);
|
|
168
|
+
}
|
|
169
|
+
const trgepc = module.HEAPF64[outTrgepcPtr >> 3] ?? 0;
|
|
170
|
+
const srfvec = Array.from(module.HEAPF64.subarray(outSrfvecPtr >> 3, (outSrfvecPtr >> 3) + 3));
|
|
171
|
+
const phase = module.HEAPF64[outPhasePtr >> 3] ?? 0;
|
|
172
|
+
const incdnc = module.HEAPF64[outIncdncPtr >> 3] ?? 0;
|
|
173
|
+
const emissn = module.HEAPF64[outEmissnPtr >> 3] ?? 0;
|
|
174
|
+
return { trgepc, srfvec, phase, incdnc, emissn };
|
|
175
|
+
}
|
|
176
|
+
finally {
|
|
177
|
+
module._free(outEmissnPtr);
|
|
178
|
+
module._free(outIncdncPtr);
|
|
179
|
+
module._free(outPhasePtr);
|
|
180
|
+
module._free(outSrfvecPtr);
|
|
181
|
+
module._free(outTrgepcPtr);
|
|
182
|
+
module._free(spointPtr);
|
|
183
|
+
module._free(observerPtr);
|
|
184
|
+
module._free(abcorrPtr);
|
|
185
|
+
module._free(fixrefPtr);
|
|
186
|
+
module._free(targetPtr);
|
|
187
|
+
module._free(methodPtr);
|
|
188
|
+
module._free(errPtr);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
function tspiceCallOccult(module, targ1, shape1, frame1, targ2, shape2, frame2, abcorr, observer, et) {
|
|
192
|
+
const errMaxBytes = 2048;
|
|
193
|
+
const errPtr = module._malloc(errMaxBytes);
|
|
194
|
+
const targ1Ptr = writeUtf8CString(module, targ1);
|
|
195
|
+
const shape1Ptr = writeUtf8CString(module, shape1);
|
|
196
|
+
const frame1Ptr = writeUtf8CString(module, frame1);
|
|
197
|
+
const targ2Ptr = writeUtf8CString(module, targ2);
|
|
198
|
+
const shape2Ptr = writeUtf8CString(module, shape2);
|
|
199
|
+
const frame2Ptr = writeUtf8CString(module, frame2);
|
|
200
|
+
const abcorrPtr = writeUtf8CString(module, abcorr);
|
|
201
|
+
const observerPtr = writeUtf8CString(module, observer);
|
|
202
|
+
const outOcltidPtr = module._malloc(4);
|
|
203
|
+
if (!errPtr || !targ1Ptr || !shape1Ptr || !frame1Ptr || !targ2Ptr || !shape2Ptr || !frame2Ptr || !abcorrPtr || !observerPtr || !outOcltidPtr) {
|
|
204
|
+
for (const ptr of [outOcltidPtr, observerPtr, abcorrPtr, frame2Ptr, shape2Ptr, targ2Ptr, frame1Ptr, shape1Ptr, targ1Ptr, errPtr]) {
|
|
205
|
+
if (ptr)
|
|
206
|
+
module._free(ptr);
|
|
207
|
+
}
|
|
208
|
+
throw new Error("WASM malloc failed");
|
|
209
|
+
}
|
|
210
|
+
try {
|
|
211
|
+
module.HEAP32[outOcltidPtr >> 2] = 0;
|
|
212
|
+
const result = module._tspice_occult(targ1Ptr, shape1Ptr, frame1Ptr, targ2Ptr, shape2Ptr, frame2Ptr, abcorrPtr, observerPtr, et, outOcltidPtr, errPtr, errMaxBytes);
|
|
213
|
+
if (result !== 0) {
|
|
214
|
+
throwWasmSpiceError(module, errPtr, errMaxBytes, result);
|
|
215
|
+
}
|
|
216
|
+
return module.HEAP32[outOcltidPtr >> 2] ?? 0;
|
|
217
|
+
}
|
|
218
|
+
finally {
|
|
219
|
+
module._free(outOcltidPtr);
|
|
220
|
+
module._free(observerPtr);
|
|
221
|
+
module._free(abcorrPtr);
|
|
222
|
+
module._free(frame2Ptr);
|
|
223
|
+
module._free(shape2Ptr);
|
|
224
|
+
module._free(targ2Ptr);
|
|
225
|
+
module._free(frame1Ptr);
|
|
226
|
+
module._free(shape1Ptr);
|
|
227
|
+
module._free(targ1Ptr);
|
|
228
|
+
module._free(errPtr);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
export function createGeometryApi(module) {
|
|
232
|
+
return {
|
|
233
|
+
subpnt: (method, target, et, fixref, abcorr, observer) => tspiceCallSubpnt(module, method, target, et, fixref, abcorr, observer),
|
|
234
|
+
subslr: (method, target, et, fixref, abcorr, observer) => tspiceCallSubslr(module, method, target, et, fixref, abcorr, observer),
|
|
235
|
+
sincpt: (method, target, et, fixref, abcorr, observer, dref, dvec) => tspiceCallSincpt(module, method, target, et, fixref, abcorr, observer, dref, dvec),
|
|
236
|
+
ilumin: (method, target, et, fixref, abcorr, observer, spoint) => tspiceCallIlumin(module, method, target, et, fixref, abcorr, observer, spoint),
|
|
237
|
+
occult: (targ1, shape1, frame1, targ2, shape2, frame2, abcorr, observer, et) => tspiceCallOccult(module, targ1, shape1, frame1, targ2, shape2, frame2, abcorr, observer, et),
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
//# sourceMappingURL=geometry.js.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { tspiceCallFoundInt, tspiceCallFoundString } from "../codec/found.js";
|
|
2
|
+
export function createIdsNamesApi(module) {
|
|
3
|
+
return {
|
|
4
|
+
bodn2c: (name) => {
|
|
5
|
+
const out = tspiceCallFoundInt(module, module._tspice_bodn2c, name);
|
|
6
|
+
if (!out.found)
|
|
7
|
+
return { found: false };
|
|
8
|
+
return { found: true, code: out.value };
|
|
9
|
+
},
|
|
10
|
+
bodc2n: (code) => {
|
|
11
|
+
const out = tspiceCallFoundString(module, module._tspice_bodc2n, code);
|
|
12
|
+
if (!out.found)
|
|
13
|
+
return { found: false };
|
|
14
|
+
return { found: true, name: out.value };
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=ids-names.js.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { KernelsApi } from "#backend-contract";
|
|
2
|
+
import type { EmscriptenModule } from "../lowlevel/exports.js";
|
|
3
|
+
import type { WasmFsApi } from "../runtime/fs.js";
|
|
4
|
+
export declare function createKernelsApi(module: EmscriptenModule, fs: WasmFsApi): KernelsApi;
|
|
5
|
+
//# sourceMappingURL=kernels.d.ts.map
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { tspiceCall0, tspiceCall1Path } from "../codec/calls.js";
|
|
2
|
+
import { throwWasmSpiceError } from "../codec/errors.js";
|
|
3
|
+
import { writeUtf8CString } from "../codec/strings.js";
|
|
4
|
+
import { writeKernelSource } from "../runtime/fs.js";
|
|
5
|
+
function tspiceCallKtotal(module, kind) {
|
|
6
|
+
const errMaxBytes = 2048;
|
|
7
|
+
const errPtr = module._malloc(errMaxBytes);
|
|
8
|
+
const kindPtr = writeUtf8CString(module, kind);
|
|
9
|
+
const outCountPtr = module._malloc(4);
|
|
10
|
+
if (!errPtr || !kindPtr || !outCountPtr) {
|
|
11
|
+
if (outCountPtr)
|
|
12
|
+
module._free(outCountPtr);
|
|
13
|
+
if (kindPtr)
|
|
14
|
+
module._free(kindPtr);
|
|
15
|
+
if (errPtr)
|
|
16
|
+
module._free(errPtr);
|
|
17
|
+
throw new Error("WASM malloc failed");
|
|
18
|
+
}
|
|
19
|
+
try {
|
|
20
|
+
module.HEAP32[outCountPtr >> 2] = 0;
|
|
21
|
+
const result = module._tspice_ktotal(kindPtr, outCountPtr, errPtr, errMaxBytes);
|
|
22
|
+
if (result !== 0) {
|
|
23
|
+
throwWasmSpiceError(module, errPtr, errMaxBytes, result);
|
|
24
|
+
}
|
|
25
|
+
return module.HEAP32[outCountPtr >> 2] ?? 0;
|
|
26
|
+
}
|
|
27
|
+
finally {
|
|
28
|
+
module._free(outCountPtr);
|
|
29
|
+
module._free(kindPtr);
|
|
30
|
+
module._free(errPtr);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function tspiceCallKdata(module, which, kind) {
|
|
34
|
+
const errMaxBytes = 2048;
|
|
35
|
+
const errPtr = module._malloc(errMaxBytes);
|
|
36
|
+
const kindPtr = writeUtf8CString(module, kind);
|
|
37
|
+
const fileMaxBytes = 2048;
|
|
38
|
+
const filtypMaxBytes = 256;
|
|
39
|
+
const sourceMaxBytes = 2048;
|
|
40
|
+
const filePtr = module._malloc(fileMaxBytes);
|
|
41
|
+
const filtypPtr = module._malloc(filtypMaxBytes);
|
|
42
|
+
const sourcePtr = module._malloc(sourceMaxBytes);
|
|
43
|
+
const handlePtr = module._malloc(4);
|
|
44
|
+
const foundPtr = module._malloc(4);
|
|
45
|
+
if (!errPtr || !kindPtr || !filePtr || !filtypPtr || !sourcePtr || !handlePtr || !foundPtr) {
|
|
46
|
+
for (const ptr of [foundPtr, handlePtr, sourcePtr, filtypPtr, filePtr, kindPtr, errPtr]) {
|
|
47
|
+
if (ptr)
|
|
48
|
+
module._free(ptr);
|
|
49
|
+
}
|
|
50
|
+
throw new Error("WASM malloc failed");
|
|
51
|
+
}
|
|
52
|
+
try {
|
|
53
|
+
module.HEAP32[handlePtr >> 2] = 0;
|
|
54
|
+
module.HEAP32[foundPtr >> 2] = 0;
|
|
55
|
+
const result = module._tspice_kdata(which, kindPtr, filePtr, fileMaxBytes, filtypPtr, filtypMaxBytes, sourcePtr, sourceMaxBytes, handlePtr, foundPtr, errPtr, errMaxBytes);
|
|
56
|
+
if (result !== 0) {
|
|
57
|
+
throwWasmSpiceError(module, errPtr, errMaxBytes, result);
|
|
58
|
+
}
|
|
59
|
+
const found = (module.HEAP32[foundPtr >> 2] ?? 0) !== 0;
|
|
60
|
+
if (!found) {
|
|
61
|
+
return { found: false };
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
found: true,
|
|
65
|
+
file: module.UTF8ToString(filePtr, fileMaxBytes).trim(),
|
|
66
|
+
filtyp: module.UTF8ToString(filtypPtr, filtypMaxBytes).trim(),
|
|
67
|
+
source: module.UTF8ToString(sourcePtr, sourceMaxBytes).trim(),
|
|
68
|
+
handle: module.HEAP32[handlePtr >> 2] ?? 0,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
finally {
|
|
72
|
+
module._free(foundPtr);
|
|
73
|
+
module._free(handlePtr);
|
|
74
|
+
module._free(sourcePtr);
|
|
75
|
+
module._free(filtypPtr);
|
|
76
|
+
module._free(filePtr);
|
|
77
|
+
module._free(kindPtr);
|
|
78
|
+
module._free(errPtr);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
export function createKernelsApi(module, fs) {
|
|
82
|
+
return {
|
|
83
|
+
furnsh: (kernel) => {
|
|
84
|
+
const path = writeKernelSource(module, fs, kernel);
|
|
85
|
+
tspiceCall1Path(module, module._tspice_furnsh, path);
|
|
86
|
+
},
|
|
87
|
+
unload: (path) => {
|
|
88
|
+
tspiceCall1Path(module, module._tspice_unload, path);
|
|
89
|
+
},
|
|
90
|
+
kclear: () => {
|
|
91
|
+
tspiceCall0(module, module._tspice_kclear);
|
|
92
|
+
},
|
|
93
|
+
ktotal: (kind = "ALL") => tspiceCallKtotal(module, kind),
|
|
94
|
+
kdata: (which, kind = "ALL") => tspiceCallKdata(module, which, kind),
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=kernels.js.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { TimeApi } from "#backend-contract";
|
|
2
|
+
import type { EmscriptenModule } from "../lowlevel/exports.js";
|
|
3
|
+
export declare function getToolkitVersion(module: EmscriptenModule): string;
|
|
4
|
+
export declare function createTimeApi(module: EmscriptenModule, toolkitVersion: string): TimeApi;
|
|
5
|
+
//# sourceMappingURL=time.d.ts.map
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { throwWasmSpiceError } from "../codec/errors.js";
|
|
2
|
+
import { writeUtf8CString } from "../codec/strings.js";
|
|
3
|
+
function tspiceCallStr2et(module, utc) {
|
|
4
|
+
const errMaxBytes = 2048;
|
|
5
|
+
const errPtr = module._malloc(errMaxBytes);
|
|
6
|
+
const utcPtr = writeUtf8CString(module, utc);
|
|
7
|
+
const outEtPtr = module._malloc(8);
|
|
8
|
+
if (!errPtr || !utcPtr || !outEtPtr) {
|
|
9
|
+
for (const ptr of [outEtPtr, utcPtr, errPtr]) {
|
|
10
|
+
if (ptr)
|
|
11
|
+
module._free(ptr);
|
|
12
|
+
}
|
|
13
|
+
throw new Error("WASM malloc failed");
|
|
14
|
+
}
|
|
15
|
+
try {
|
|
16
|
+
module.HEAPF64[outEtPtr >> 3] = 0;
|
|
17
|
+
const result = module._tspice_str2et(utcPtr, outEtPtr, errPtr, errMaxBytes);
|
|
18
|
+
if (result !== 0) {
|
|
19
|
+
throwWasmSpiceError(module, errPtr, errMaxBytes, result);
|
|
20
|
+
}
|
|
21
|
+
return module.HEAPF64[outEtPtr >> 3] ?? 0;
|
|
22
|
+
}
|
|
23
|
+
finally {
|
|
24
|
+
module._free(outEtPtr);
|
|
25
|
+
module._free(utcPtr);
|
|
26
|
+
module._free(errPtr);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function tspiceCallEt2utc(module, et, format, prec) {
|
|
30
|
+
const errMaxBytes = 2048;
|
|
31
|
+
const errPtr = module._malloc(errMaxBytes);
|
|
32
|
+
const formatPtr = writeUtf8CString(module, format);
|
|
33
|
+
// Buffer size includes terminating NUL.
|
|
34
|
+
const outMaxBytes = 2048;
|
|
35
|
+
const outPtr = module._malloc(outMaxBytes);
|
|
36
|
+
if (!errPtr || !formatPtr || !outPtr) {
|
|
37
|
+
for (const ptr of [outPtr, formatPtr, errPtr]) {
|
|
38
|
+
if (ptr)
|
|
39
|
+
module._free(ptr);
|
|
40
|
+
}
|
|
41
|
+
throw new Error("WASM malloc failed");
|
|
42
|
+
}
|
|
43
|
+
try {
|
|
44
|
+
module.HEAPU8[outPtr] = 0;
|
|
45
|
+
const result = module._tspice_et2utc(et, formatPtr, prec, outPtr, outMaxBytes, errPtr, errMaxBytes);
|
|
46
|
+
if (result !== 0) {
|
|
47
|
+
throwWasmSpiceError(module, errPtr, errMaxBytes, result);
|
|
48
|
+
}
|
|
49
|
+
return module.UTF8ToString(outPtr, outMaxBytes).trim();
|
|
50
|
+
}
|
|
51
|
+
finally {
|
|
52
|
+
module._free(outPtr);
|
|
53
|
+
module._free(formatPtr);
|
|
54
|
+
module._free(errPtr);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function tspiceCallTimout(module, et, picture) {
|
|
58
|
+
const errMaxBytes = 2048;
|
|
59
|
+
const errPtr = module._malloc(errMaxBytes);
|
|
60
|
+
const picturePtr = writeUtf8CString(module, picture);
|
|
61
|
+
// Buffer size includes terminating NUL.
|
|
62
|
+
const outMaxBytes = 2048;
|
|
63
|
+
const outPtr = module._malloc(outMaxBytes);
|
|
64
|
+
if (!errPtr || !picturePtr || !outPtr) {
|
|
65
|
+
for (const ptr of [outPtr, picturePtr, errPtr]) {
|
|
66
|
+
if (ptr)
|
|
67
|
+
module._free(ptr);
|
|
68
|
+
}
|
|
69
|
+
throw new Error("WASM malloc failed");
|
|
70
|
+
}
|
|
71
|
+
try {
|
|
72
|
+
module.HEAPU8[outPtr] = 0;
|
|
73
|
+
const result = module._tspice_timout(et, picturePtr, outPtr, outMaxBytes, errPtr, errMaxBytes);
|
|
74
|
+
if (result !== 0) {
|
|
75
|
+
throwWasmSpiceError(module, errPtr, errMaxBytes, result);
|
|
76
|
+
}
|
|
77
|
+
return module.UTF8ToString(outPtr, outMaxBytes).trim();
|
|
78
|
+
}
|
|
79
|
+
finally {
|
|
80
|
+
module._free(outPtr);
|
|
81
|
+
module._free(picturePtr);
|
|
82
|
+
module._free(errPtr);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
function tspiceCallScs2e(module, sc, sclkch) {
|
|
86
|
+
const errMaxBytes = 2048;
|
|
87
|
+
const errPtr = module._malloc(errMaxBytes);
|
|
88
|
+
const sclkchPtr = writeUtf8CString(module, sclkch);
|
|
89
|
+
const outEtPtr = module._malloc(8);
|
|
90
|
+
if (!errPtr || !sclkchPtr || !outEtPtr) {
|
|
91
|
+
for (const ptr of [outEtPtr, sclkchPtr, errPtr]) {
|
|
92
|
+
if (ptr)
|
|
93
|
+
module._free(ptr);
|
|
94
|
+
}
|
|
95
|
+
throw new Error("WASM malloc failed");
|
|
96
|
+
}
|
|
97
|
+
try {
|
|
98
|
+
module.HEAPF64[outEtPtr >> 3] = 0;
|
|
99
|
+
const result = module._tspice_scs2e(sc, sclkchPtr, outEtPtr, errPtr, errMaxBytes);
|
|
100
|
+
if (result !== 0) {
|
|
101
|
+
throwWasmSpiceError(module, errPtr, errMaxBytes, result);
|
|
102
|
+
}
|
|
103
|
+
return module.HEAPF64[outEtPtr >> 3] ?? 0;
|
|
104
|
+
}
|
|
105
|
+
finally {
|
|
106
|
+
module._free(outEtPtr);
|
|
107
|
+
module._free(sclkchPtr);
|
|
108
|
+
module._free(errPtr);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
function tspiceCallSce2s(module, sc, et) {
|
|
112
|
+
const errMaxBytes = 2048;
|
|
113
|
+
const errPtr = module._malloc(errMaxBytes);
|
|
114
|
+
// Buffer size includes terminating NUL.
|
|
115
|
+
const outMaxBytes = 2048;
|
|
116
|
+
const outPtr = module._malloc(outMaxBytes);
|
|
117
|
+
if (!errPtr || !outPtr) {
|
|
118
|
+
for (const ptr of [outPtr, errPtr]) {
|
|
119
|
+
if (ptr)
|
|
120
|
+
module._free(ptr);
|
|
121
|
+
}
|
|
122
|
+
throw new Error("WASM malloc failed");
|
|
123
|
+
}
|
|
124
|
+
try {
|
|
125
|
+
module.HEAPU8[outPtr] = 0;
|
|
126
|
+
const result = module._tspice_sce2s(sc, et, outPtr, outMaxBytes, errPtr, errMaxBytes);
|
|
127
|
+
if (result !== 0) {
|
|
128
|
+
throwWasmSpiceError(module, errPtr, errMaxBytes, result);
|
|
129
|
+
}
|
|
130
|
+
return module.UTF8ToString(outPtr, outMaxBytes).trim();
|
|
131
|
+
}
|
|
132
|
+
finally {
|
|
133
|
+
module._free(outPtr);
|
|
134
|
+
module._free(errPtr);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
export function getToolkitVersion(module) {
|
|
138
|
+
const outMaxBytes = 256;
|
|
139
|
+
const errMaxBytes = 2048;
|
|
140
|
+
const outPtr = module._malloc(outMaxBytes);
|
|
141
|
+
const errPtr = module._malloc(errMaxBytes);
|
|
142
|
+
if (!outPtr || !errPtr) {
|
|
143
|
+
if (errPtr) {
|
|
144
|
+
module._free(errPtr);
|
|
145
|
+
}
|
|
146
|
+
if (outPtr) {
|
|
147
|
+
module._free(outPtr);
|
|
148
|
+
}
|
|
149
|
+
throw new Error("WASM malloc failed");
|
|
150
|
+
}
|
|
151
|
+
try {
|
|
152
|
+
const result = module._tspice_tkvrsn_toolkit(outPtr, outMaxBytes, errPtr, errMaxBytes);
|
|
153
|
+
if (result !== 0) {
|
|
154
|
+
const message = module.UTF8ToString(errPtr, errMaxBytes).trim();
|
|
155
|
+
throw new Error(message || `CSPICE call failed with code ${result}`);
|
|
156
|
+
}
|
|
157
|
+
return module.UTF8ToString(outPtr, outMaxBytes);
|
|
158
|
+
}
|
|
159
|
+
finally {
|
|
160
|
+
module._free(errPtr);
|
|
161
|
+
module._free(outPtr);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
export function createTimeApi(module, toolkitVersion) {
|
|
165
|
+
return {
|
|
166
|
+
spiceVersion: () => toolkitVersion,
|
|
167
|
+
tkvrsn: (item) => {
|
|
168
|
+
if (item !== "TOOLKIT") {
|
|
169
|
+
throw new Error(`Unsupported tkvrsn item: ${item}`);
|
|
170
|
+
}
|
|
171
|
+
return toolkitVersion;
|
|
172
|
+
},
|
|
173
|
+
str2et: (utc) => tspiceCallStr2et(module, utc),
|
|
174
|
+
et2utc: (et, format, prec) => tspiceCallEt2utc(module, et, format, prec),
|
|
175
|
+
timout: (et, picture) => tspiceCallTimout(module, et, picture),
|
|
176
|
+
scs2e: (sc, sclkch) => tspiceCallScs2e(module, sc, sclkch),
|
|
177
|
+
sce2s: (sc, et) => tspiceCallSce2s(module, sc, et),
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
//# sourceMappingURL=time.js.map
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
export type CreateWasmBackendOptions
|
|
3
|
-
wasmUrl?: string | URL;
|
|
4
|
-
};
|
|
5
|
-
export declare const WASM_JS_FILENAME: "tspice_backend_wasm.js";
|
|
6
|
-
export declare const WASM_BINARY_FILENAME: "tspice_backend_wasm.wasm";
|
|
7
|
-
export declare function createWasmBackend(options?: CreateWasmBackendOptions): Promise<SpiceBackendWasm>;
|
|
1
|
+
export { WASM_BINARY_FILENAME, WASM_JS_FILENAME, createWasmBackend, } from "./runtime/create-backend.js";
|
|
2
|
+
export type { CreateWasmBackendOptions } from "./runtime/create-backend.js";
|
|
8
3
|
//# sourceMappingURL=index.d.ts.map
|