@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.
Files changed (79) hide show
  1. package/backend-contract/dist/.tsbuildinfo +1 -1
  2. package/backend-contract/dist/domains/coords-vectors.d.ts +30 -0
  3. package/backend-contract/dist/domains/coords-vectors.js +2 -0
  4. package/backend-contract/dist/domains/ephemeris.d.ts +8 -0
  5. package/backend-contract/dist/domains/ephemeris.js +2 -0
  6. package/backend-contract/dist/domains/frames.d.ts +33 -0
  7. package/backend-contract/dist/domains/frames.js +2 -0
  8. package/backend-contract/dist/domains/geometry.d.ts +14 -0
  9. package/backend-contract/dist/domains/geometry.js +2 -0
  10. package/backend-contract/dist/domains/ids-names.d.ts +10 -0
  11. package/backend-contract/dist/domains/ids-names.js +2 -0
  12. package/backend-contract/dist/domains/kernels.d.ts +22 -0
  13. package/backend-contract/dist/domains/kernels.js +2 -0
  14. package/backend-contract/dist/domains/time.d.ts +24 -0
  15. package/backend-contract/dist/domains/time.js +2 -0
  16. package/backend-contract/dist/index.d.ts +17 -222
  17. package/backend-contract/dist/index.js +8 -1
  18. package/backend-contract/dist/shared/types.d.ts +108 -0
  19. package/backend-contract/dist/shared/types.js +2 -0
  20. package/backend-fake/dist/.tsbuildinfo +1 -1
  21. package/backend-node/dist/.tsbuildinfo +1 -1
  22. package/backend-node/dist/codec/errors.d.ts +9 -0
  23. package/backend-node/dist/codec/errors.js +14 -0
  24. package/backend-node/dist/domains/coords-vectors.d.ts +4 -0
  25. package/backend-node/dist/domains/coords-vectors.js +62 -0
  26. package/backend-node/dist/domains/ephemeris.d.ts +4 -0
  27. package/backend-node/dist/domains/ephemeris.js +24 -0
  28. package/backend-node/dist/domains/frames.d.ts +4 -0
  29. package/backend-node/dist/domains/frames.js +74 -0
  30. package/backend-node/dist/domains/geometry.d.ts +4 -0
  31. package/backend-node/dist/domains/geometry.js +67 -0
  32. package/backend-node/dist/domains/ids-names.d.ts +4 -0
  33. package/backend-node/dist/domains/ids-names.js +22 -0
  34. package/backend-node/dist/domains/kernels.d.ts +5 -0
  35. package/backend-node/dist/domains/kernels.js +37 -0
  36. package/backend-node/dist/domains/time.d.ts +4 -0
  37. package/backend-node/dist/domains/time.js +36 -0
  38. package/backend-node/dist/index.js +18 -373
  39. package/backend-node/dist/lowlevel/binding.d.ts +3 -0
  40. package/backend-node/dist/lowlevel/binding.js +44 -0
  41. package/backend-node/dist/native.d.ts +2 -111
  42. package/backend-node/dist/native.js +1 -101
  43. package/backend-node/dist/runtime/addon.d.ts +112 -0
  44. package/backend-node/dist/runtime/addon.js +102 -0
  45. package/backend-node/dist/runtime/kernel-staging.d.ts +9 -0
  46. package/backend-node/dist/runtime/kernel-staging.js +75 -0
  47. package/backend-wasm/dist/.tsbuildinfo +1 -1
  48. package/backend-wasm/dist/codec/calls.d.ts +4 -0
  49. package/backend-wasm/dist/codec/calls.js +41 -0
  50. package/backend-wasm/dist/codec/errors.d.ts +3 -0
  51. package/backend-wasm/dist/codec/errors.js +5 -0
  52. package/backend-wasm/dist/codec/found.d.ts +9 -0
  53. package/backend-wasm/dist/codec/found.js +68 -0
  54. package/backend-wasm/dist/codec/strings.d.ts +3 -0
  55. package/backend-wasm/dist/codec/strings.js +12 -0
  56. package/backend-wasm/dist/domains/coords-vectors.d.ts +4 -0
  57. package/backend-wasm/dist/domains/coords-vectors.js +312 -0
  58. package/backend-wasm/dist/domains/ephemeris.d.ts +4 -0
  59. package/backend-wasm/dist/domains/ephemeris.js +81 -0
  60. package/backend-wasm/dist/domains/frames.d.ts +4 -0
  61. package/backend-wasm/dist/domains/frames.js +239 -0
  62. package/backend-wasm/dist/domains/geometry.d.ts +4 -0
  63. package/backend-wasm/dist/domains/geometry.js +240 -0
  64. package/backend-wasm/dist/domains/ids-names.d.ts +4 -0
  65. package/backend-wasm/dist/domains/ids-names.js +18 -0
  66. package/backend-wasm/dist/domains/kernels.d.ts +5 -0
  67. package/backend-wasm/dist/domains/kernels.js +97 -0
  68. package/backend-wasm/dist/domains/time.d.ts +5 -0
  69. package/backend-wasm/dist/domains/time.js +180 -0
  70. package/backend-wasm/dist/index.d.ts +2 -7
  71. package/backend-wasm/dist/index.js +1 -1504
  72. package/backend-wasm/dist/lowlevel/exports.d.ts +49 -0
  73. package/backend-wasm/dist/lowlevel/exports.js +41 -0
  74. package/backend-wasm/dist/runtime/create-backend.d.ts +8 -0
  75. package/backend-wasm/dist/runtime/create-backend.js +81 -0
  76. package/backend-wasm/dist/runtime/fs.d.ts +9 -0
  77. package/backend-wasm/dist/runtime/fs.js +30 -0
  78. package/dist/.tsbuildinfo +1 -1
  79. package/package.json +4 -4
@@ -0,0 +1,312 @@
1
+ import { throwWasmSpiceError } from "../codec/errors.js";
2
+ function tspiceCallReclat(module, rect) {
3
+ const errMaxBytes = 2048;
4
+ const errPtr = module._malloc(errMaxBytes);
5
+ const rectPtr = module._malloc(3 * 8);
6
+ const outRadiusPtr = module._malloc(8);
7
+ const outLonPtr = module._malloc(8);
8
+ const outLatPtr = module._malloc(8);
9
+ if (!errPtr || !rectPtr || !outRadiusPtr || !outLonPtr || !outLatPtr) {
10
+ for (const ptr of [outLatPtr, outLonPtr, outRadiusPtr, rectPtr, errPtr]) {
11
+ if (ptr)
12
+ module._free(ptr);
13
+ }
14
+ throw new Error("WASM malloc failed");
15
+ }
16
+ try {
17
+ module.HEAPF64.set(rect, rectPtr >> 3);
18
+ module.HEAPF64[outRadiusPtr >> 3] = 0;
19
+ module.HEAPF64[outLonPtr >> 3] = 0;
20
+ module.HEAPF64[outLatPtr >> 3] = 0;
21
+ const result = module._tspice_reclat(rectPtr, outRadiusPtr, outLonPtr, outLatPtr, errPtr, errMaxBytes);
22
+ if (result !== 0) {
23
+ throwWasmSpiceError(module, errPtr, errMaxBytes, result);
24
+ }
25
+ return {
26
+ radius: module.HEAPF64[outRadiusPtr >> 3] ?? 0,
27
+ lon: module.HEAPF64[outLonPtr >> 3] ?? 0,
28
+ lat: module.HEAPF64[outLatPtr >> 3] ?? 0,
29
+ };
30
+ }
31
+ finally {
32
+ module._free(outLatPtr);
33
+ module._free(outLonPtr);
34
+ module._free(outRadiusPtr);
35
+ module._free(rectPtr);
36
+ module._free(errPtr);
37
+ }
38
+ }
39
+ function tspiceCallLatrec(module, radius, lon, lat) {
40
+ const errMaxBytes = 2048;
41
+ const errPtr = module._malloc(errMaxBytes);
42
+ const outRectPtr = module._malloc(3 * 8);
43
+ if (!errPtr || !outRectPtr) {
44
+ for (const ptr of [outRectPtr, errPtr]) {
45
+ if (ptr)
46
+ module._free(ptr);
47
+ }
48
+ throw new Error("WASM malloc failed");
49
+ }
50
+ try {
51
+ module.HEAPF64.set([0, 0, 0], outRectPtr >> 3);
52
+ const result = module._tspice_latrec(radius, lon, lat, outRectPtr, errPtr, errMaxBytes);
53
+ if (result !== 0) {
54
+ throwWasmSpiceError(module, errPtr, errMaxBytes, result);
55
+ }
56
+ return Array.from(module.HEAPF64.subarray(outRectPtr >> 3, (outRectPtr >> 3) + 3));
57
+ }
58
+ finally {
59
+ module._free(outRectPtr);
60
+ module._free(errPtr);
61
+ }
62
+ }
63
+ function tspiceCallRecsph(module, rect) {
64
+ const errMaxBytes = 2048;
65
+ const errPtr = module._malloc(errMaxBytes);
66
+ const rectPtr = module._malloc(3 * 8);
67
+ const outRadiusPtr = module._malloc(8);
68
+ const outColatPtr = module._malloc(8);
69
+ const outLonPtr = module._malloc(8);
70
+ if (!errPtr || !rectPtr || !outRadiusPtr || !outColatPtr || !outLonPtr) {
71
+ for (const ptr of [outLonPtr, outColatPtr, outRadiusPtr, rectPtr, errPtr]) {
72
+ if (ptr)
73
+ module._free(ptr);
74
+ }
75
+ throw new Error("WASM malloc failed");
76
+ }
77
+ try {
78
+ module.HEAPF64.set(rect, rectPtr >> 3);
79
+ module.HEAPF64[outRadiusPtr >> 3] = 0;
80
+ module.HEAPF64[outColatPtr >> 3] = 0;
81
+ module.HEAPF64[outLonPtr >> 3] = 0;
82
+ const result = module._tspice_recsph(rectPtr, outRadiusPtr, outColatPtr, outLonPtr, errPtr, errMaxBytes);
83
+ if (result !== 0) {
84
+ throwWasmSpiceError(module, errPtr, errMaxBytes, result);
85
+ }
86
+ return {
87
+ radius: module.HEAPF64[outRadiusPtr >> 3] ?? 0,
88
+ colat: module.HEAPF64[outColatPtr >> 3] ?? 0,
89
+ lon: module.HEAPF64[outLonPtr >> 3] ?? 0,
90
+ };
91
+ }
92
+ finally {
93
+ module._free(outLonPtr);
94
+ module._free(outColatPtr);
95
+ module._free(outRadiusPtr);
96
+ module._free(rectPtr);
97
+ module._free(errPtr);
98
+ }
99
+ }
100
+ function tspiceCallSphrec(module, radius, colat, lon) {
101
+ const errMaxBytes = 2048;
102
+ const errPtr = module._malloc(errMaxBytes);
103
+ const outRectPtr = module._malloc(3 * 8);
104
+ if (!errPtr || !outRectPtr) {
105
+ for (const ptr of [outRectPtr, errPtr]) {
106
+ if (ptr)
107
+ module._free(ptr);
108
+ }
109
+ throw new Error("WASM malloc failed");
110
+ }
111
+ try {
112
+ module.HEAPF64.set([0, 0, 0], outRectPtr >> 3);
113
+ const result = module._tspice_sphrec(radius, colat, lon, outRectPtr, errPtr, errMaxBytes);
114
+ if (result !== 0) {
115
+ throwWasmSpiceError(module, errPtr, errMaxBytes, result);
116
+ }
117
+ return Array.from(module.HEAPF64.subarray(outRectPtr >> 3, (outRectPtr >> 3) + 3));
118
+ }
119
+ finally {
120
+ module._free(outRectPtr);
121
+ module._free(errPtr);
122
+ }
123
+ }
124
+ function tspiceCallVnorm(module, v) {
125
+ const errMaxBytes = 2048;
126
+ const errPtr = module._malloc(errMaxBytes);
127
+ const vPtr = module._malloc(3 * 8);
128
+ const outNormPtr = module._malloc(8);
129
+ if (!errPtr || !vPtr || !outNormPtr) {
130
+ for (const ptr of [outNormPtr, vPtr, errPtr]) {
131
+ if (ptr)
132
+ module._free(ptr);
133
+ }
134
+ throw new Error("WASM malloc failed");
135
+ }
136
+ try {
137
+ module.HEAPF64.set(v, vPtr >> 3);
138
+ module.HEAPF64[outNormPtr >> 3] = 0;
139
+ const result = module._tspice_vnorm(vPtr, outNormPtr, errPtr, errMaxBytes);
140
+ if (result !== 0) {
141
+ throwWasmSpiceError(module, errPtr, errMaxBytes, result);
142
+ }
143
+ return module.HEAPF64[outNormPtr >> 3] ?? 0;
144
+ }
145
+ finally {
146
+ module._free(outNormPtr);
147
+ module._free(vPtr);
148
+ module._free(errPtr);
149
+ }
150
+ }
151
+ function tspiceCallVhat(module, v) {
152
+ const errMaxBytes = 2048;
153
+ const errPtr = module._malloc(errMaxBytes);
154
+ const vPtr = module._malloc(3 * 8);
155
+ const outPtr = module._malloc(3 * 8);
156
+ if (!errPtr || !vPtr || !outPtr) {
157
+ for (const ptr of [outPtr, vPtr, errPtr]) {
158
+ if (ptr)
159
+ module._free(ptr);
160
+ }
161
+ throw new Error("WASM malloc failed");
162
+ }
163
+ try {
164
+ module.HEAPF64.set(v, vPtr >> 3);
165
+ module.HEAPF64.set([0, 0, 0], outPtr >> 3);
166
+ const result = module._tspice_vhat(vPtr, outPtr, errPtr, errMaxBytes);
167
+ if (result !== 0) {
168
+ throwWasmSpiceError(module, errPtr, errMaxBytes, result);
169
+ }
170
+ return Array.from(module.HEAPF64.subarray(outPtr >> 3, (outPtr >> 3) + 3));
171
+ }
172
+ finally {
173
+ module._free(outPtr);
174
+ module._free(vPtr);
175
+ module._free(errPtr);
176
+ }
177
+ }
178
+ function tspiceCallVdot(module, a, b) {
179
+ const errMaxBytes = 2048;
180
+ const errPtr = module._malloc(errMaxBytes);
181
+ const aPtr = module._malloc(3 * 8);
182
+ const bPtr = module._malloc(3 * 8);
183
+ const outDotPtr = module._malloc(8);
184
+ if (!errPtr || !aPtr || !bPtr || !outDotPtr) {
185
+ for (const ptr of [outDotPtr, bPtr, aPtr, errPtr]) {
186
+ if (ptr)
187
+ module._free(ptr);
188
+ }
189
+ throw new Error("WASM malloc failed");
190
+ }
191
+ try {
192
+ module.HEAPF64.set(a, aPtr >> 3);
193
+ module.HEAPF64.set(b, bPtr >> 3);
194
+ module.HEAPF64[outDotPtr >> 3] = 0;
195
+ const result = module._tspice_vdot(aPtr, bPtr, outDotPtr, errPtr, errMaxBytes);
196
+ if (result !== 0) {
197
+ throwWasmSpiceError(module, errPtr, errMaxBytes, result);
198
+ }
199
+ return module.HEAPF64[outDotPtr >> 3] ?? 0;
200
+ }
201
+ finally {
202
+ module._free(outDotPtr);
203
+ module._free(bPtr);
204
+ module._free(aPtr);
205
+ module._free(errPtr);
206
+ }
207
+ }
208
+ function tspiceCallVcrss(module, a, b) {
209
+ const errMaxBytes = 2048;
210
+ const errPtr = module._malloc(errMaxBytes);
211
+ const aPtr = module._malloc(3 * 8);
212
+ const bPtr = module._malloc(3 * 8);
213
+ const outPtr = module._malloc(3 * 8);
214
+ if (!errPtr || !aPtr || !bPtr || !outPtr) {
215
+ for (const ptr of [outPtr, bPtr, aPtr, errPtr]) {
216
+ if (ptr)
217
+ module._free(ptr);
218
+ }
219
+ throw new Error("WASM malloc failed");
220
+ }
221
+ try {
222
+ module.HEAPF64.set(a, aPtr >> 3);
223
+ module.HEAPF64.set(b, bPtr >> 3);
224
+ module.HEAPF64.set([0, 0, 0], outPtr >> 3);
225
+ const result = module._tspice_vcrss(aPtr, bPtr, outPtr, errPtr, errMaxBytes);
226
+ if (result !== 0) {
227
+ throwWasmSpiceError(module, errPtr, errMaxBytes, result);
228
+ }
229
+ return Array.from(module.HEAPF64.subarray(outPtr >> 3, (outPtr >> 3) + 3));
230
+ }
231
+ finally {
232
+ module._free(outPtr);
233
+ module._free(bPtr);
234
+ module._free(aPtr);
235
+ module._free(errPtr);
236
+ }
237
+ }
238
+ function tspiceCallMxv(module, m, v) {
239
+ const errMaxBytes = 2048;
240
+ const errPtr = module._malloc(errMaxBytes);
241
+ const mPtr = module._malloc(9 * 8);
242
+ const vPtr = module._malloc(3 * 8);
243
+ const outPtr = module._malloc(3 * 8);
244
+ if (!errPtr || !mPtr || !vPtr || !outPtr) {
245
+ for (const ptr of [outPtr, vPtr, mPtr, errPtr]) {
246
+ if (ptr)
247
+ module._free(ptr);
248
+ }
249
+ throw new Error("WASM malloc failed");
250
+ }
251
+ try {
252
+ module.HEAPF64.set(m, mPtr >> 3);
253
+ module.HEAPF64.set(v, vPtr >> 3);
254
+ module.HEAPF64.set([0, 0, 0], outPtr >> 3);
255
+ const result = module._tspice_mxv(mPtr, vPtr, outPtr, errPtr, errMaxBytes);
256
+ if (result !== 0) {
257
+ throwWasmSpiceError(module, errPtr, errMaxBytes, result);
258
+ }
259
+ return Array.from(module.HEAPF64.subarray(outPtr >> 3, (outPtr >> 3) + 3));
260
+ }
261
+ finally {
262
+ module._free(outPtr);
263
+ module._free(vPtr);
264
+ module._free(mPtr);
265
+ module._free(errPtr);
266
+ }
267
+ }
268
+ function tspiceCallMtxv(module, m, v) {
269
+ const errMaxBytes = 2048;
270
+ const errPtr = module._malloc(errMaxBytes);
271
+ const mPtr = module._malloc(9 * 8);
272
+ const vPtr = module._malloc(3 * 8);
273
+ const outPtr = module._malloc(3 * 8);
274
+ if (!errPtr || !mPtr || !vPtr || !outPtr) {
275
+ for (const ptr of [outPtr, vPtr, mPtr, errPtr]) {
276
+ if (ptr)
277
+ module._free(ptr);
278
+ }
279
+ throw new Error("WASM malloc failed");
280
+ }
281
+ try {
282
+ module.HEAPF64.set(m, mPtr >> 3);
283
+ module.HEAPF64.set(v, vPtr >> 3);
284
+ module.HEAPF64.set([0, 0, 0], outPtr >> 3);
285
+ const result = module._tspice_mtxv(mPtr, vPtr, outPtr, errPtr, errMaxBytes);
286
+ if (result !== 0) {
287
+ throwWasmSpiceError(module, errPtr, errMaxBytes, result);
288
+ }
289
+ return Array.from(module.HEAPF64.subarray(outPtr >> 3, (outPtr >> 3) + 3));
290
+ }
291
+ finally {
292
+ module._free(outPtr);
293
+ module._free(vPtr);
294
+ module._free(mPtr);
295
+ module._free(errPtr);
296
+ }
297
+ }
298
+ export function createCoordsVectorsApi(module) {
299
+ return {
300
+ reclat: (rect) => tspiceCallReclat(module, rect),
301
+ latrec: (radius, lon, lat) => tspiceCallLatrec(module, radius, lon, lat),
302
+ recsph: (rect) => tspiceCallRecsph(module, rect),
303
+ sphrec: (radius, colat, lon) => tspiceCallSphrec(module, radius, colat, lon),
304
+ vnorm: (v) => tspiceCallVnorm(module, v),
305
+ vhat: (v) => tspiceCallVhat(module, v),
306
+ vdot: (a, b) => tspiceCallVdot(module, a, b),
307
+ vcrss: (a, b) => tspiceCallVcrss(module, a, b),
308
+ mxv: (m, v) => tspiceCallMxv(module, m, v),
309
+ mtxv: (m, v) => tspiceCallMtxv(module, m, v),
310
+ };
311
+ }
312
+ //# sourceMappingURL=coords-vectors.js.map
@@ -0,0 +1,4 @@
1
+ import type { EphemerisApi } from "#backend-contract";
2
+ import type { EmscriptenModule } from "../lowlevel/exports.js";
3
+ export declare function createEphemerisApi(module: EmscriptenModule): EphemerisApi;
4
+ //# sourceMappingURL=ephemeris.d.ts.map
@@ -0,0 +1,81 @@
1
+ import { throwWasmSpiceError } from "../codec/errors.js";
2
+ import { writeUtf8CString } from "../codec/strings.js";
3
+ function tspiceCallSpkezr(module, target, et, ref, abcorr, obs) {
4
+ const errMaxBytes = 2048;
5
+ const errPtr = module._malloc(errMaxBytes);
6
+ const targetPtr = writeUtf8CString(module, target);
7
+ const refPtr = writeUtf8CString(module, ref);
8
+ const abcorrPtr = writeUtf8CString(module, abcorr);
9
+ const obsPtr = writeUtf8CString(module, obs);
10
+ const outStatePtr = module._malloc(6 * 8);
11
+ const outLtPtr = module._malloc(8);
12
+ if (!errPtr || !targetPtr || !refPtr || !abcorrPtr || !obsPtr || !outStatePtr || !outLtPtr) {
13
+ for (const ptr of [outLtPtr, outStatePtr, obsPtr, abcorrPtr, refPtr, targetPtr, errPtr]) {
14
+ if (ptr)
15
+ module._free(ptr);
16
+ }
17
+ throw new Error("WASM malloc failed");
18
+ }
19
+ try {
20
+ module.HEAPF64[outLtPtr >> 3] = 0;
21
+ const result = module._tspice_spkezr(targetPtr, et, refPtr, abcorrPtr, obsPtr, outStatePtr, outLtPtr, errPtr, errMaxBytes);
22
+ if (result !== 0) {
23
+ throwWasmSpiceError(module, errPtr, errMaxBytes, result);
24
+ }
25
+ const state = Array.from(module.HEAPF64.subarray(outStatePtr >> 3, (outStatePtr >> 3) + 6));
26
+ const lt = module.HEAPF64[outLtPtr >> 3] ?? 0;
27
+ return { state, lt };
28
+ }
29
+ finally {
30
+ module._free(outLtPtr);
31
+ module._free(outStatePtr);
32
+ module._free(obsPtr);
33
+ module._free(abcorrPtr);
34
+ module._free(refPtr);
35
+ module._free(targetPtr);
36
+ module._free(errPtr);
37
+ }
38
+ }
39
+ function tspiceCallSpkpos(module, target, et, ref, abcorr, obs) {
40
+ const errMaxBytes = 2048;
41
+ const errPtr = module._malloc(errMaxBytes);
42
+ const targetPtr = writeUtf8CString(module, target);
43
+ const refPtr = writeUtf8CString(module, ref);
44
+ const abcorrPtr = writeUtf8CString(module, abcorr);
45
+ const obsPtr = writeUtf8CString(module, obs);
46
+ const outPosPtr = module._malloc(3 * 8);
47
+ const outLtPtr = module._malloc(8);
48
+ if (!errPtr || !targetPtr || !refPtr || !abcorrPtr || !obsPtr || !outPosPtr || !outLtPtr) {
49
+ for (const ptr of [outLtPtr, outPosPtr, obsPtr, abcorrPtr, refPtr, targetPtr, errPtr]) {
50
+ if (ptr)
51
+ module._free(ptr);
52
+ }
53
+ throw new Error("WASM malloc failed");
54
+ }
55
+ try {
56
+ module.HEAPF64[outLtPtr >> 3] = 0;
57
+ const result = module._tspice_spkpos(targetPtr, et, refPtr, abcorrPtr, obsPtr, outPosPtr, outLtPtr, errPtr, errMaxBytes);
58
+ if (result !== 0) {
59
+ throwWasmSpiceError(module, errPtr, errMaxBytes, result);
60
+ }
61
+ const pos = Array.from(module.HEAPF64.subarray(outPosPtr >> 3, (outPosPtr >> 3) + 3));
62
+ const lt = module.HEAPF64[outLtPtr >> 3] ?? 0;
63
+ return { pos, lt };
64
+ }
65
+ finally {
66
+ module._free(outLtPtr);
67
+ module._free(outPosPtr);
68
+ module._free(obsPtr);
69
+ module._free(abcorrPtr);
70
+ module._free(refPtr);
71
+ module._free(targetPtr);
72
+ module._free(errPtr);
73
+ }
74
+ }
75
+ export function createEphemerisApi(module) {
76
+ return {
77
+ spkezr: (target, et, ref, abcorr, observer) => tspiceCallSpkezr(module, target, et, ref, abcorr, observer),
78
+ spkpos: (target, et, ref, abcorr, observer) => tspiceCallSpkpos(module, target, et, ref, abcorr, observer),
79
+ };
80
+ }
81
+ //# sourceMappingURL=ephemeris.js.map
@@ -0,0 +1,4 @@
1
+ import type { FramesApi } from "#backend-contract";
2
+ import type { EmscriptenModule } from "../lowlevel/exports.js";
3
+ export declare function createFramesApi(module: EmscriptenModule): FramesApi;
4
+ //# sourceMappingURL=frames.d.ts.map
@@ -0,0 +1,239 @@
1
+ import { tspiceCallFoundInt, tspiceCallFoundString } from "../codec/found.js";
2
+ import { throwWasmSpiceError } from "../codec/errors.js";
3
+ import { writeUtf8CString } from "../codec/strings.js";
4
+ function tspiceCallCidfrm(module, fn, center) {
5
+ const errMaxBytes = 2048;
6
+ const errPtr = module._malloc(errMaxBytes);
7
+ const outNameMaxBytes = 256;
8
+ const outNamePtr = module._malloc(outNameMaxBytes);
9
+ const outCodePtr = module._malloc(4);
10
+ const foundPtr = module._malloc(4);
11
+ if (!errPtr || !outNamePtr || !outCodePtr || !foundPtr) {
12
+ for (const ptr of [foundPtr, outCodePtr, outNamePtr, errPtr]) {
13
+ if (ptr)
14
+ module._free(ptr);
15
+ }
16
+ throw new Error("WASM malloc failed");
17
+ }
18
+ try {
19
+ module.HEAPU8[outNamePtr] = 0;
20
+ module.HEAP32[outCodePtr >> 2] = 0;
21
+ module.HEAP32[foundPtr >> 2] = 0;
22
+ const result = fn(center, outCodePtr, outNamePtr, outNameMaxBytes, foundPtr, errPtr, errMaxBytes);
23
+ if (result !== 0) {
24
+ throwWasmSpiceError(module, errPtr, errMaxBytes, result);
25
+ }
26
+ const found = (module.HEAP32[foundPtr >> 2] ?? 0) !== 0;
27
+ if (!found) {
28
+ return { found: false };
29
+ }
30
+ return {
31
+ found: true,
32
+ frcode: module.HEAP32[outCodePtr >> 2] ?? 0,
33
+ frname: module.UTF8ToString(outNamePtr, outNameMaxBytes).trim(),
34
+ };
35
+ }
36
+ finally {
37
+ module._free(foundPtr);
38
+ module._free(outCodePtr);
39
+ module._free(outNamePtr);
40
+ module._free(errPtr);
41
+ }
42
+ }
43
+ function tspiceCallCnmfrm(module, fn, centerName) {
44
+ const errMaxBytes = 2048;
45
+ const errPtr = module._malloc(errMaxBytes);
46
+ const centerNamePtr = writeUtf8CString(module, centerName);
47
+ const outNameMaxBytes = 256;
48
+ const outNamePtr = module._malloc(outNameMaxBytes);
49
+ const outCodePtr = module._malloc(4);
50
+ const foundPtr = module._malloc(4);
51
+ if (!errPtr || !centerNamePtr || !outNamePtr || !outCodePtr || !foundPtr) {
52
+ for (const ptr of [foundPtr, outCodePtr, outNamePtr, centerNamePtr, errPtr]) {
53
+ if (ptr)
54
+ module._free(ptr);
55
+ }
56
+ throw new Error("WASM malloc failed");
57
+ }
58
+ try {
59
+ module.HEAPU8[outNamePtr] = 0;
60
+ module.HEAP32[outCodePtr >> 2] = 0;
61
+ module.HEAP32[foundPtr >> 2] = 0;
62
+ const result = fn(centerNamePtr, outCodePtr, outNamePtr, outNameMaxBytes, foundPtr, errPtr, errMaxBytes);
63
+ if (result !== 0) {
64
+ throwWasmSpiceError(module, errPtr, errMaxBytes, result);
65
+ }
66
+ const found = (module.HEAP32[foundPtr >> 2] ?? 0) !== 0;
67
+ if (!found) {
68
+ return { found: false };
69
+ }
70
+ return {
71
+ found: true,
72
+ frcode: module.HEAP32[outCodePtr >> 2] ?? 0,
73
+ frname: module.UTF8ToString(outNamePtr, outNameMaxBytes).trim(),
74
+ };
75
+ }
76
+ finally {
77
+ module._free(foundPtr);
78
+ module._free(outCodePtr);
79
+ module._free(outNamePtr);
80
+ module._free(centerNamePtr);
81
+ module._free(errPtr);
82
+ }
83
+ }
84
+ function tspiceCallCkgp(module, inst, sclkdp, tol, ref) {
85
+ const errMaxBytes = 2048;
86
+ const errPtr = module._malloc(errMaxBytes);
87
+ const refPtr = writeUtf8CString(module, ref);
88
+ const outCmatPtr = module._malloc(9 * 8);
89
+ const outClkoutPtr = module._malloc(8);
90
+ const foundPtr = module._malloc(4);
91
+ if (!errPtr || !refPtr || !outCmatPtr || !outClkoutPtr || !foundPtr) {
92
+ for (const ptr of [foundPtr, outClkoutPtr, outCmatPtr, refPtr, errPtr]) {
93
+ if (ptr)
94
+ module._free(ptr);
95
+ }
96
+ throw new Error("WASM malloc failed");
97
+ }
98
+ try {
99
+ module.HEAPF64[outClkoutPtr >> 3] = 0;
100
+ module.HEAP32[foundPtr >> 2] = 0;
101
+ const result = module._tspice_ckgp(inst, sclkdp, tol, refPtr, outCmatPtr, outClkoutPtr, foundPtr, errPtr, errMaxBytes);
102
+ if (result !== 0) {
103
+ throwWasmSpiceError(module, errPtr, errMaxBytes, result);
104
+ }
105
+ const found = (module.HEAP32[foundPtr >> 2] ?? 0) !== 0;
106
+ if (!found) {
107
+ return { found: false };
108
+ }
109
+ const cmat = Array.from(module.HEAPF64.subarray(outCmatPtr >> 3, (outCmatPtr >> 3) + 9));
110
+ const clkout = module.HEAPF64[outClkoutPtr >> 3] ?? 0;
111
+ return { found: true, cmat, clkout };
112
+ }
113
+ finally {
114
+ module._free(foundPtr);
115
+ module._free(outClkoutPtr);
116
+ module._free(outCmatPtr);
117
+ module._free(refPtr);
118
+ module._free(errPtr);
119
+ }
120
+ }
121
+ function tspiceCallCkgpav(module, inst, sclkdp, tol, ref) {
122
+ const errMaxBytes = 2048;
123
+ const errPtr = module._malloc(errMaxBytes);
124
+ const refPtr = writeUtf8CString(module, ref);
125
+ const outCmatPtr = module._malloc(9 * 8);
126
+ const outAvPtr = module._malloc(3 * 8);
127
+ const outClkoutPtr = module._malloc(8);
128
+ const foundPtr = module._malloc(4);
129
+ if (!errPtr || !refPtr || !outCmatPtr || !outAvPtr || !outClkoutPtr || !foundPtr) {
130
+ for (const ptr of [foundPtr, outClkoutPtr, outAvPtr, outCmatPtr, refPtr, errPtr]) {
131
+ if (ptr)
132
+ module._free(ptr);
133
+ }
134
+ throw new Error("WASM malloc failed");
135
+ }
136
+ try {
137
+ module.HEAPF64[outClkoutPtr >> 3] = 0;
138
+ module.HEAP32[foundPtr >> 2] = 0;
139
+ const result = module._tspice_ckgpav(inst, sclkdp, tol, refPtr, outCmatPtr, outAvPtr, outClkoutPtr, foundPtr, errPtr, errMaxBytes);
140
+ if (result !== 0) {
141
+ throwWasmSpiceError(module, errPtr, errMaxBytes, result);
142
+ }
143
+ const found = (module.HEAP32[foundPtr >> 2] ?? 0) !== 0;
144
+ if (!found) {
145
+ return { found: false };
146
+ }
147
+ const cmat = Array.from(module.HEAPF64.subarray(outCmatPtr >> 3, (outCmatPtr >> 3) + 9));
148
+ const av = Array.from(module.HEAPF64.subarray(outAvPtr >> 3, (outAvPtr >> 3) + 3));
149
+ const clkout = module.HEAPF64[outClkoutPtr >> 3] ?? 0;
150
+ return { found: true, cmat, av, clkout };
151
+ }
152
+ finally {
153
+ module._free(foundPtr);
154
+ module._free(outClkoutPtr);
155
+ module._free(outAvPtr);
156
+ module._free(outCmatPtr);
157
+ module._free(refPtr);
158
+ module._free(errPtr);
159
+ }
160
+ }
161
+ function tspiceCallPxform(module, from, to, et) {
162
+ const errMaxBytes = 2048;
163
+ const errPtr = module._malloc(errMaxBytes);
164
+ const fromPtr = writeUtf8CString(module, from);
165
+ const toPtr = writeUtf8CString(module, to);
166
+ const outPtr = module._malloc(9 * 8);
167
+ if (!errPtr || !fromPtr || !toPtr || !outPtr) {
168
+ for (const ptr of [outPtr, toPtr, fromPtr, errPtr]) {
169
+ if (ptr)
170
+ module._free(ptr);
171
+ }
172
+ throw new Error("WASM malloc failed");
173
+ }
174
+ try {
175
+ const result = module._tspice_pxform(fromPtr, toPtr, et, outPtr, errPtr, errMaxBytes);
176
+ if (result !== 0) {
177
+ throwWasmSpiceError(module, errPtr, errMaxBytes, result);
178
+ }
179
+ const out = Array.from(module.HEAPF64.subarray(outPtr >> 3, (outPtr >> 3) + 9));
180
+ return out;
181
+ }
182
+ finally {
183
+ module._free(outPtr);
184
+ module._free(toPtr);
185
+ module._free(fromPtr);
186
+ module._free(errPtr);
187
+ }
188
+ }
189
+ function tspiceCallSxform(module, from, to, et) {
190
+ const errMaxBytes = 2048;
191
+ const errPtr = module._malloc(errMaxBytes);
192
+ const fromPtr = writeUtf8CString(module, from);
193
+ const toPtr = writeUtf8CString(module, to);
194
+ const outPtr = module._malloc(36 * 8);
195
+ if (!errPtr || !fromPtr || !toPtr || !outPtr) {
196
+ for (const ptr of [outPtr, toPtr, fromPtr, errPtr]) {
197
+ if (ptr)
198
+ module._free(ptr);
199
+ }
200
+ throw new Error("WASM malloc failed");
201
+ }
202
+ try {
203
+ const result = module._tspice_sxform(fromPtr, toPtr, et, outPtr, errPtr, errMaxBytes);
204
+ if (result !== 0) {
205
+ throwWasmSpiceError(module, errPtr, errMaxBytes, result);
206
+ }
207
+ const out = Array.from(module.HEAPF64.subarray(outPtr >> 3, (outPtr >> 3) + 36));
208
+ return out;
209
+ }
210
+ finally {
211
+ module._free(outPtr);
212
+ module._free(toPtr);
213
+ module._free(fromPtr);
214
+ module._free(errPtr);
215
+ }
216
+ }
217
+ export function createFramesApi(module) {
218
+ return {
219
+ namfrm: (name) => {
220
+ const out = tspiceCallFoundInt(module, module._tspice_namfrm, name);
221
+ if (!out.found)
222
+ return { found: false };
223
+ return { found: true, code: out.value };
224
+ },
225
+ frmnam: (code) => {
226
+ const out = tspiceCallFoundString(module, module._tspice_frmnam, code);
227
+ if (!out.found)
228
+ return { found: false };
229
+ return { found: true, name: out.value };
230
+ },
231
+ cidfrm: (center) => tspiceCallCidfrm(module, module._tspice_cidfrm, center),
232
+ cnmfrm: (centerName) => tspiceCallCnmfrm(module, module._tspice_cnmfrm, centerName),
233
+ ckgp: (inst, sclkdp, tol, ref) => tspiceCallCkgp(module, inst, sclkdp, tol, ref),
234
+ ckgpav: (inst, sclkdp, tol, ref) => tspiceCallCkgpav(module, inst, sclkdp, tol, ref),
235
+ pxform: (from, to, et) => tspiceCallPxform(module, from, to, et),
236
+ sxform: (from, to, et) => tspiceCallSxform(module, from, to, et),
237
+ };
238
+ }
239
+ //# sourceMappingURL=frames.js.map
@@ -0,0 +1,4 @@
1
+ import type { GeometryApi } from "#backend-contract";
2
+ import type { EmscriptenModule } from "../lowlevel/exports.js";
3
+ export declare function createGeometryApi(module: EmscriptenModule): GeometryApi;
4
+ //# sourceMappingURL=geometry.d.ts.map