@rybosome/tspice 0.0.3 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +145 -84
- package/backend-contract/dist/.tsbuildinfo +1 -1
- package/backend-contract/dist/domains/cells-windows.d.ts +94 -0
- package/backend-contract/dist/domains/cells-windows.js +10 -0
- package/backend-contract/dist/domains/coords-vectors.d.ts +53 -3
- package/backend-contract/dist/domains/dsk.d.ts +49 -0
- package/backend-contract/dist/domains/dsk.js +2 -0
- package/backend-contract/dist/domains/ek.d.ts +186 -0
- package/backend-contract/dist/domains/ek.js +8 -0
- package/backend-contract/dist/domains/ephemeris.d.ts +141 -3
- package/backend-contract/dist/domains/error.d.ts +42 -0
- package/backend-contract/dist/domains/error.js +33 -0
- package/backend-contract/dist/domains/file-io.d.ts +114 -0
- package/backend-contract/dist/domains/file-io.js +8 -0
- package/backend-contract/dist/domains/frames.d.ts +44 -4
- package/backend-contract/dist/domains/geometry-gf.d.ts +44 -0
- package/backend-contract/dist/domains/geometry-gf.js +14 -0
- package/backend-contract/dist/domains/geometry.d.ts +21 -1
- package/backend-contract/dist/domains/ids-names-normalize.d.ts +3 -0
- package/backend-contract/dist/domains/ids-names-normalize.js +74 -0
- package/backend-contract/dist/domains/ids-names.d.ts +37 -0
- package/backend-contract/dist/domains/kernel-pool.d.ts +134 -0
- package/backend-contract/dist/domains/kernel-pool.js +2 -0
- package/backend-contract/dist/domains/kernels-utils.d.ts +44 -0
- package/backend-contract/dist/domains/kernels-utils.js +265 -0
- package/backend-contract/dist/domains/kernels.d.ts +39 -3
- package/backend-contract/dist/domains/time.d.ts +102 -0
- package/backend-contract/dist/index.d.ts +34 -15
- package/backend-contract/dist/index.js +15 -1
- package/backend-contract/dist/shared/errors.d.ts +6 -0
- package/backend-contract/dist/shared/errors.js +8 -0
- package/backend-contract/dist/shared/mat3.d.ts +52 -0
- package/backend-contract/dist/shared/mat3.js +150 -0
- package/backend-contract/dist/shared/mat6.d.ts +34 -0
- package/backend-contract/dist/shared/mat6.js +116 -0
- package/backend-contract/dist/shared/spice-handles.d.ts +20 -0
- package/backend-contract/dist/shared/spice-handles.js +82 -0
- package/backend-contract/dist/shared/spice-int.d.ts +32 -0
- package/backend-contract/dist/shared/spice-int.js +41 -0
- package/backend-contract/dist/shared/types.d.ts +136 -5
- package/backend-contract/dist/shared/types.js +1 -1
- package/backend-contract/dist/shared/vec.d.ts +54 -0
- package/backend-contract/dist/shared/vec.js +162 -0
- package/backend-fake/dist/.tsbuildinfo +1 -1
- package/backend-fake/dist/index.d.ts +21 -1
- package/backend-fake/dist/index.js +1112 -33
- package/backend-node/dist/.tsbuildinfo +1 -1
- package/backend-node/dist/codec/arrays.d.ts +9 -0
- package/backend-node/dist/codec/arrays.js +36 -0
- package/backend-node/dist/codec/errors.d.ts +6 -6
- package/backend-node/dist/codec/errors.js +6 -6
- package/backend-node/dist/domains/cells-windows.d.ts +5 -0
- package/backend-node/dist/domains/cells-windows.js +112 -0
- package/backend-node/dist/domains/coords-vectors.d.ts +1 -0
- package/backend-node/dist/domains/coords-vectors.js +66 -0
- package/backend-node/dist/domains/dsk.d.ts +6 -0
- package/backend-node/dist/domains/dsk.js +108 -0
- package/backend-node/dist/domains/ek.d.ts +10 -0
- package/backend-node/dist/domains/ek.js +100 -0
- package/backend-node/dist/domains/ephemeris.d.ts +5 -1
- package/backend-node/dist/domains/ephemeris.js +150 -1
- package/backend-node/dist/domains/error.d.ts +5 -0
- package/backend-node/dist/domains/error.js +34 -0
- package/backend-node/dist/domains/file-io.d.ts +7 -0
- package/backend-node/dist/domains/file-io.js +105 -0
- package/backend-node/dist/domains/frames.d.ts +1 -0
- package/backend-node/dist/domains/frames.js +58 -6
- package/backend-node/dist/domains/geometry-gf.d.ts +5 -0
- package/backend-node/dist/domains/geometry-gf.js +74 -0
- package/backend-node/dist/domains/geometry.d.ts +1 -0
- package/backend-node/dist/domains/geometry.js +62 -0
- package/backend-node/dist/domains/ids-names.d.ts +2 -1
- package/backend-node/dist/domains/ids-names.js +30 -0
- package/backend-node/dist/domains/kernel-pool.d.ts +5 -0
- package/backend-node/dist/domains/kernel-pool.js +74 -0
- package/backend-node/dist/domains/kernels.d.ts +1 -0
- package/backend-node/dist/domains/kernels.js +100 -13
- package/backend-node/dist/domains/time.d.ts +1 -0
- package/backend-node/dist/domains/time.js +75 -1
- package/backend-node/dist/index.d.ts +5 -1
- package/backend-node/dist/index.js +62 -1
- package/backend-node/dist/lowlevel/binding.d.ts +3 -0
- package/backend-node/dist/lowlevel/binding.js +115 -0
- package/backend-node/dist/runtime/addon.d.ts +273 -2
- package/backend-node/dist/runtime/addon.js +3 -0
- package/backend-node/dist/runtime/kernel-staging.d.ts +17 -0
- package/backend-node/dist/runtime/kernel-staging.js +80 -7
- package/backend-node/dist/runtime/spice-handles.d.ts +3 -0
- package/backend-node/dist/runtime/spice-handles.js +2 -0
- package/backend-node/dist/runtime/virtual-output-staging.d.ts +16 -0
- package/backend-node/dist/runtime/virtual-output-staging.js +148 -0
- package/backend-wasm/dist/.tsbuildinfo +1 -1
- package/backend-wasm/dist/codec/alloc.d.ts +19 -0
- package/backend-wasm/dist/codec/alloc.js +64 -0
- package/backend-wasm/dist/codec/calls.d.ts +2 -0
- package/backend-wasm/dist/codec/calls.js +13 -24
- package/backend-wasm/dist/codec/errors.d.ts +6 -0
- package/backend-wasm/dist/codec/errors.js +34 -2
- package/backend-wasm/dist/codec/found.d.ts +2 -0
- package/backend-wasm/dist/codec/found.js +20 -43
- package/backend-wasm/dist/codec/strings.d.ts +31 -1
- package/backend-wasm/dist/codec/strings.js +93 -6
- package/backend-wasm/dist/domains/cells-windows.d.ts +9 -0
- package/backend-wasm/dist/domains/cells-windows.js +392 -0
- package/backend-wasm/dist/domains/coords-vectors.d.ts +1 -0
- package/backend-wasm/dist/domains/coords-vectors.js +377 -184
- package/backend-wasm/dist/domains/dsk.d.ts +6 -0
- package/backend-wasm/dist/domains/dsk.js +179 -0
- package/backend-wasm/dist/domains/ek.d.ts +6 -0
- package/backend-wasm/dist/domains/ek.js +543 -0
- package/backend-wasm/dist/domains/ephemeris.d.ts +4 -1
- package/backend-wasm/dist/domains/ephemeris.js +405 -46
- package/backend-wasm/dist/domains/error.d.ts +5 -0
- package/backend-wasm/dist/domains/error.js +109 -0
- package/backend-wasm/dist/domains/file-io.d.ts +7 -0
- package/backend-wasm/dist/domains/file-io.js +462 -0
- package/backend-wasm/dist/domains/frames.d.ts +1 -0
- package/backend-wasm/dist/domains/frames.js +139 -6
- package/backend-wasm/dist/domains/geometry-gf.d.ts +5 -0
- package/backend-wasm/dist/domains/geometry-gf.js +178 -0
- package/backend-wasm/dist/domains/geometry.d.ts +1 -0
- package/backend-wasm/dist/domains/geometry.js +210 -0
- package/backend-wasm/dist/domains/ids-names.d.ts +2 -1
- package/backend-wasm/dist/domains/ids-names.js +89 -0
- package/backend-wasm/dist/domains/kernel-pool.d.ts +5 -0
- package/backend-wasm/dist/domains/kernel-pool.js +357 -0
- package/backend-wasm/dist/domains/kernels.d.ts +1 -0
- package/backend-wasm/dist/domains/kernels.js +108 -4
- package/backend-wasm/dist/domains/time.d.ts +2 -0
- package/backend-wasm/dist/domains/time.js +235 -133
- package/backend-wasm/dist/index.d.ts +4 -2
- package/backend-wasm/dist/lowlevel/exports.d.ts +215 -1
- package/backend-wasm/dist/lowlevel/exports.js +217 -38
- package/backend-wasm/dist/runtime/create-backend-options.d.ts +21 -0
- package/backend-wasm/dist/runtime/create-backend.node.d.ts +11 -2
- package/backend-wasm/dist/runtime/create-backend.node.js +283 -14
- package/backend-wasm/dist/runtime/create-backend.web.d.ts +5 -2
- package/backend-wasm/dist/runtime/create-backend.web.js +40 -6
- package/backend-wasm/dist/runtime/fs.d.ts +6 -0
- package/backend-wasm/dist/runtime/fs.js +29 -3
- package/backend-wasm/dist/runtime/spice-handles.d.ts +3 -0
- package/backend-wasm/dist/runtime/spice-handles.js +2 -0
- package/backend-wasm/dist/runtime/virtual-outputs.d.ts +16 -0
- package/backend-wasm/dist/runtime/virtual-outputs.js +35 -0
- package/backend-wasm/dist/tspice_backend_wasm.node.js +3 -3
- package/backend-wasm/dist/tspice_backend_wasm.wasm +0 -0
- package/backend-wasm/dist/tspice_backend_wasm.web.js +1 -1
- package/core/dist/.tsbuildinfo +1 -1
- package/core/dist/index.d.ts +21 -0
- package/core/dist/index.js +57 -0
- package/dist/.tsbuildinfo +1 -1
- package/dist/backend.d.ts +15 -6
- package/dist/backend.js +3 -6
- package/dist/clients/createSpiceAsyncFromTransport.d.ts +5 -0
- package/dist/clients/createSpiceAsyncFromTransport.js +90 -0
- package/dist/clients/createSpiceSyncFromTransport.d.ts +5 -0
- package/dist/clients/createSpiceSyncFromTransport.js +88 -0
- package/dist/clients/spiceClients.d.ts +59 -0
- package/dist/clients/spiceClients.js +292 -0
- package/dist/errors.d.ts +4 -0
- package/dist/errors.js +4 -0
- package/dist/index.d.ts +12 -7
- package/dist/index.js +5 -2
- package/dist/kernels/defaultKernelPathFromUrl.d.ts +8 -0
- package/dist/kernels/defaultKernelPathFromUrl.js +32 -0
- package/dist/kernels/kernelPack.d.ts +88 -0
- package/dist/kernels/kernelPack.js +122 -0
- package/dist/kernels/kernels.d.ts +98 -0
- package/dist/kernels/kernels.js +217 -0
- package/dist/kernels/naifKernelId.d.ts +2 -0
- package/dist/kernels/naifKernelId.js +2 -0
- package/dist/kit/index.d.ts +4 -0
- package/dist/kit/index.js +3 -0
- package/dist/kit/math/mat3.d.ts +31 -0
- package/dist/kit/math/mat3.js +82 -0
- package/dist/kit/spice/create-kit.d.ts +12 -0
- package/dist/kit/spice/create-kit.js +23 -0
- package/dist/kit/spice/frames.d.ts +8 -0
- package/dist/kit/spice/frames.js +16 -0
- package/dist/kit/spice/kernels.d.ts +14 -0
- package/dist/kit/spice/kernels.js +39 -0
- package/dist/kit/spice/state.d.ts +7 -0
- package/dist/kit/spice/state.js +36 -0
- package/dist/kit/spice/time.d.ts +9 -0
- package/dist/kit/spice/time.js +31 -0
- package/dist/kit/types/spice-types.d.ts +51 -0
- package/dist/spice.d.ts +10 -1
- package/dist/spice.js +84 -72
- package/dist/transport/caching/policy.d.ts +16 -0
- package/dist/transport/caching/policy.js +77 -0
- package/dist/transport/caching/withCaching.d.ts +125 -0
- package/dist/transport/caching/withCaching.js +335 -0
- package/dist/transport/caching/withCachingSync.d.ts +24 -0
- package/dist/transport/caching/withCachingSync.js +161 -0
- package/dist/transport/rpc/protocol.d.ts +35 -0
- package/dist/transport/rpc/protocol.js +56 -0
- package/dist/transport/rpc/taskScheduling.d.ts +20 -0
- package/dist/transport/rpc/taskScheduling.js +98 -0
- package/dist/transport/rpc/valueCodec.d.ts +5 -0
- package/dist/transport/rpc/valueCodec.js +106 -0
- package/dist/transport/types.d.ts +7 -0
- package/dist/transport/types.js +2 -0
- package/dist/types.d.ts +8 -17
- package/dist/types.js +2 -1
- package/dist/worker/browser/createSpiceWorker.d.ts +22 -0
- package/dist/worker/browser/createSpiceWorker.js +41 -0
- package/dist/worker/browser/createSpiceWorkerClient.d.ts +40 -0
- package/dist/worker/browser/createSpiceWorkerClient.js +99 -0
- package/dist/worker/browser/spiceWorkerEntry.d.ts +2 -0
- package/dist/worker/browser/spiceWorkerEntry.js +129 -0
- package/dist/worker/browser/spiceWorkerInlineSource.d.ts +2 -0
- package/dist/worker/browser/spiceWorkerInlineSource.js +4 -0
- package/dist/worker/index.d.ts +10 -0
- package/dist/worker/index.js +7 -0
- package/dist/worker/transport/createWorkerTransport.d.ts +69 -0
- package/dist/worker/transport/createWorkerTransport.js +398 -0
- package/dist/worker/transport/exposeTransportToWorker.d.ts +51 -0
- package/dist/worker/transport/exposeTransportToWorker.js +196 -0
- package/package.json +4 -4
- package/dist/spice-types.d.ts +0 -36
- /package/dist/{spice-types.js → kit/types/spice-types.js} +0 -0
|
@@ -1,166 +1,222 @@
|
|
|
1
|
+
import { assertNever } from "#core";
|
|
2
|
+
import { WASM_ERR_MAX_BYTES, withAllocs, withMalloc } from "../codec/alloc.js";
|
|
1
3
|
import { throwWasmSpiceError } from "../codec/errors.js";
|
|
2
|
-
import { writeUtf8CString } from "../codec/strings.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
4
|
+
import { readFixedWidthCString, writeUtf8CString } from "../codec/strings.js";
|
|
5
|
+
/**
|
|
6
|
+
* Max byte size for string outputs from CSPICE time calls (`et2utc_c`, `timout_c`).
|
|
7
|
+
*
|
|
8
|
+
* This intentionally differs from `WASM_ERR_MAX_BYTES`:
|
|
9
|
+
* - time formatting outputs can be much larger than error messages (esp. with long TIMOUT pictures)
|
|
10
|
+
* - we want a stable, explicit cap for output allocations
|
|
11
|
+
*/
|
|
12
|
+
const WASM_TIME_OUT_MAX_BYTES = 16 * 1024; // 16 KiB
|
|
13
|
+
const WASM_TIME_SMALL_OUT_MAX_BYTES = 2048;
|
|
14
|
+
/** Max byte size for SCLK string outputs (sce2s/scdecd). */
|
|
15
|
+
const WASM_SCLK_OUT_MAX_BYTES = 2048;
|
|
16
|
+
function withUtf8CString(module, value, fn) {
|
|
17
|
+
const ptr = writeUtf8CString(module, value);
|
|
15
18
|
try {
|
|
16
|
-
|
|
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;
|
|
19
|
+
return fn(ptr);
|
|
22
20
|
}
|
|
23
21
|
finally {
|
|
24
|
-
module._free(
|
|
25
|
-
module._free(utcPtr);
|
|
26
|
-
module._free(errPtr);
|
|
22
|
+
module._free(ptr);
|
|
27
23
|
}
|
|
28
24
|
}
|
|
25
|
+
function tspiceCallStr2et(module, utc) {
|
|
26
|
+
return withUtf8CString(module, utc, (utcPtr) => {
|
|
27
|
+
return withAllocs(module, [WASM_ERR_MAX_BYTES, 8], (errPtr, outEtPtr) => {
|
|
28
|
+
module.HEAPF64[outEtPtr >> 3] = 0;
|
|
29
|
+
const result = module._tspice_str2et(utcPtr, outEtPtr, errPtr, WASM_ERR_MAX_BYTES);
|
|
30
|
+
if (result !== 0) {
|
|
31
|
+
throwWasmSpiceError(module, errPtr, WASM_ERR_MAX_BYTES, result);
|
|
32
|
+
}
|
|
33
|
+
return module.HEAPF64[outEtPtr >> 3] ?? 0;
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
}
|
|
29
37
|
function tspiceCallEt2utc(module, et, format, prec) {
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
38
|
+
const outMaxBytes = WASM_TIME_OUT_MAX_BYTES;
|
|
39
|
+
return withUtf8CString(module, format, (formatPtr) => {
|
|
40
|
+
return withAllocs(module, [WASM_ERR_MAX_BYTES, outMaxBytes], (errPtr, outPtr) => {
|
|
41
|
+
module.HEAPU8[outPtr] = 0;
|
|
42
|
+
const result = module._tspice_et2utc(et, formatPtr, prec, outPtr, outMaxBytes, errPtr, WASM_ERR_MAX_BYTES);
|
|
43
|
+
if (result !== 0) {
|
|
44
|
+
throwWasmSpiceError(module, errPtr, WASM_ERR_MAX_BYTES, result);
|
|
45
|
+
}
|
|
46
|
+
return readFixedWidthCString(module, outPtr, outMaxBytes);
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
function tspiceCallTimout(module, et, picture) {
|
|
51
|
+
const outMaxBytes = WASM_TIME_OUT_MAX_BYTES;
|
|
52
|
+
return withUtf8CString(module, picture, (picturePtr) => {
|
|
53
|
+
return withAllocs(module, [WASM_ERR_MAX_BYTES, outMaxBytes], (errPtr, outPtr) => {
|
|
54
|
+
module.HEAPU8[outPtr] = 0;
|
|
55
|
+
const result = module._tspice_timout(et, picturePtr, outPtr, outMaxBytes, errPtr, WASM_ERR_MAX_BYTES);
|
|
56
|
+
if (result !== 0) {
|
|
57
|
+
throwWasmSpiceError(module, errPtr, WASM_ERR_MAX_BYTES, result);
|
|
58
|
+
}
|
|
59
|
+
return readFixedWidthCString(module, outPtr, outMaxBytes);
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
function tspiceCallDeltet(module, epoch, eptype) {
|
|
64
|
+
return withUtf8CString(module, eptype, (eptypePtr) => {
|
|
65
|
+
return withAllocs(module, [WASM_ERR_MAX_BYTES, 8], (errPtr, outDeltaPtr) => {
|
|
66
|
+
module.HEAPF64[outDeltaPtr >> 3] = 0;
|
|
67
|
+
const result = module._tspice_deltet(epoch, eptypePtr, outDeltaPtr, errPtr, WASM_ERR_MAX_BYTES);
|
|
68
|
+
if (result !== 0) {
|
|
69
|
+
throwWasmSpiceError(module, errPtr, WASM_ERR_MAX_BYTES, result);
|
|
70
|
+
}
|
|
71
|
+
return module.HEAPF64[outDeltaPtr >> 3] ?? 0;
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
function tspiceCallUnitim(module, epoch, insys, outsys) {
|
|
76
|
+
return withUtf8CString(module, insys, (insysPtr) => {
|
|
77
|
+
return withUtf8CString(module, outsys, (outsysPtr) => {
|
|
78
|
+
return withAllocs(module, [WASM_ERR_MAX_BYTES, 8], (errPtr, outEpochPtr) => {
|
|
79
|
+
module.HEAPF64[outEpochPtr >> 3] = 0;
|
|
80
|
+
const result = module._tspice_unitim(epoch, insysPtr, outsysPtr, outEpochPtr, errPtr, WASM_ERR_MAX_BYTES);
|
|
81
|
+
if (result !== 0) {
|
|
82
|
+
throwWasmSpiceError(module, errPtr, WASM_ERR_MAX_BYTES, result);
|
|
83
|
+
}
|
|
84
|
+
return module.HEAPF64[outEpochPtr >> 3] ?? 0;
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
function tspiceCallTparse(module, timstr) {
|
|
90
|
+
return withUtf8CString(module, timstr, (timstrPtr) => {
|
|
91
|
+
return withAllocs(module, [WASM_ERR_MAX_BYTES, 8], (errPtr, outEtPtr) => {
|
|
92
|
+
module.HEAPF64[outEtPtr >> 3] = 0;
|
|
93
|
+
const result = module._tspice_tparse(timstrPtr, outEtPtr, errPtr, WASM_ERR_MAX_BYTES);
|
|
94
|
+
if (result !== 0) {
|
|
95
|
+
throwWasmSpiceError(module, errPtr, WASM_ERR_MAX_BYTES, result);
|
|
96
|
+
}
|
|
97
|
+
return module.HEAPF64[outEtPtr >> 3] ?? 0;
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
function tspiceCallTpictr(module, sample, picturIn) {
|
|
102
|
+
const outMaxBytes = WASM_TIME_OUT_MAX_BYTES;
|
|
103
|
+
return withUtf8CString(module, sample, (samplePtr) => {
|
|
104
|
+
return withUtf8CString(module, picturIn, (picturInPtr) => {
|
|
105
|
+
return withAllocs(module, [WASM_ERR_MAX_BYTES, outMaxBytes], (errPtr, outPtr) => {
|
|
106
|
+
module.HEAPU8[outPtr] = 0;
|
|
107
|
+
const result = module._tspice_tpictr(samplePtr, picturInPtr, outPtr, outMaxBytes, errPtr, WASM_ERR_MAX_BYTES);
|
|
108
|
+
if (result !== 0) {
|
|
109
|
+
throwWasmSpiceError(module, errPtr, WASM_ERR_MAX_BYTES, result);
|
|
110
|
+
}
|
|
111
|
+
return readFixedWidthCString(module, outPtr, outMaxBytes);
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
function tspiceCallTimdefGet(module, item) {
|
|
117
|
+
const outMaxBytes = WASM_TIME_SMALL_OUT_MAX_BYTES;
|
|
118
|
+
return withUtf8CString(module, item, (itemPtr) => {
|
|
119
|
+
return withAllocs(module, [WASM_ERR_MAX_BYTES, outMaxBytes], (errPtr, outPtr) => {
|
|
120
|
+
module.HEAPU8[outPtr] = 0;
|
|
121
|
+
const result = module._tspice_timdef_get(itemPtr, outPtr, outMaxBytes, errPtr, WASM_ERR_MAX_BYTES);
|
|
122
|
+
if (result !== 0) {
|
|
123
|
+
throwWasmSpiceError(module, errPtr, WASM_ERR_MAX_BYTES, result);
|
|
124
|
+
}
|
|
125
|
+
return readFixedWidthCString(module, outPtr, outMaxBytes);
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
function tspiceCallTimdefSet(module, item, value) {
|
|
130
|
+
withUtf8CString(module, item, (itemPtr) => {
|
|
131
|
+
withUtf8CString(module, value, (valuePtr) => {
|
|
132
|
+
withMalloc(module, WASM_ERR_MAX_BYTES, (errPtr) => {
|
|
133
|
+
const result = module._tspice_timdef_set(itemPtr, valuePtr, errPtr, WASM_ERR_MAX_BYTES);
|
|
134
|
+
if (result !== 0) {
|
|
135
|
+
throwWasmSpiceError(module, errPtr, WASM_ERR_MAX_BYTES, result);
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
function tspiceCallScs2e(module, sc, sclkch) {
|
|
142
|
+
return withUtf8CString(module, sclkch, (sclkchPtr) => {
|
|
143
|
+
return withAllocs(module, [WASM_ERR_MAX_BYTES, 8], (errPtr, outEtPtr) => {
|
|
144
|
+
module.HEAPF64[outEtPtr >> 3] = 0;
|
|
145
|
+
const result = module._tspice_scs2e(sc, sclkchPtr, outEtPtr, errPtr, WASM_ERR_MAX_BYTES);
|
|
146
|
+
if (result !== 0) {
|
|
147
|
+
throwWasmSpiceError(module, errPtr, WASM_ERR_MAX_BYTES, result);
|
|
148
|
+
}
|
|
149
|
+
return module.HEAPF64[outEtPtr >> 3] ?? 0;
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
function tspiceCallSce2s(module, sc, et) {
|
|
154
|
+
const outMaxBytes = WASM_SCLK_OUT_MAX_BYTES;
|
|
155
|
+
return withAllocs(module, [WASM_ERR_MAX_BYTES, outMaxBytes], (errPtr, outPtr) => {
|
|
44
156
|
module.HEAPU8[outPtr] = 0;
|
|
45
|
-
const result = module.
|
|
157
|
+
const result = module._tspice_sce2s(sc, et, outPtr, outMaxBytes, errPtr, WASM_ERR_MAX_BYTES);
|
|
46
158
|
if (result !== 0) {
|
|
47
|
-
throwWasmSpiceError(module, errPtr,
|
|
159
|
+
throwWasmSpiceError(module, errPtr, WASM_ERR_MAX_BYTES, result);
|
|
48
160
|
}
|
|
49
|
-
return module
|
|
50
|
-
}
|
|
51
|
-
finally {
|
|
52
|
-
module._free(outPtr);
|
|
53
|
-
module._free(formatPtr);
|
|
54
|
-
module._free(errPtr);
|
|
55
|
-
}
|
|
161
|
+
return readFixedWidthCString(module, outPtr, outMaxBytes);
|
|
162
|
+
});
|
|
56
163
|
}
|
|
57
|
-
function
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
164
|
+
function tspiceCallScencd(module, sc, sclkch) {
|
|
165
|
+
return withUtf8CString(module, sclkch, (sclkchPtr) => {
|
|
166
|
+
return withAllocs(module, [WASM_ERR_MAX_BYTES, 8], (errPtr, outSclkdpPtr) => {
|
|
167
|
+
module.HEAPF64[outSclkdpPtr >> 3] = 0;
|
|
168
|
+
const result = module._tspice_scencd(sc, sclkchPtr, outSclkdpPtr, errPtr, WASM_ERR_MAX_BYTES);
|
|
169
|
+
if (result !== 0) {
|
|
170
|
+
throwWasmSpiceError(module, errPtr, WASM_ERR_MAX_BYTES, result);
|
|
171
|
+
}
|
|
172
|
+
return module.HEAPF64[outSclkdpPtr >> 3] ?? 0;
|
|
173
|
+
});
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
function tspiceCallScdecd(module, sc, sclkdp) {
|
|
177
|
+
const outMaxBytes = WASM_SCLK_OUT_MAX_BYTES;
|
|
178
|
+
return withAllocs(module, [WASM_ERR_MAX_BYTES, outMaxBytes], (errPtr, outPtr) => {
|
|
72
179
|
module.HEAPU8[outPtr] = 0;
|
|
73
|
-
const result = module.
|
|
180
|
+
const result = module._tspice_scdecd(sc, sclkdp, outPtr, outMaxBytes, errPtr, WASM_ERR_MAX_BYTES);
|
|
74
181
|
if (result !== 0) {
|
|
75
|
-
throwWasmSpiceError(module, errPtr,
|
|
182
|
+
throwWasmSpiceError(module, errPtr, WASM_ERR_MAX_BYTES, result);
|
|
76
183
|
}
|
|
77
|
-
return module
|
|
78
|
-
}
|
|
79
|
-
finally {
|
|
80
|
-
module._free(outPtr);
|
|
81
|
-
module._free(picturePtr);
|
|
82
|
-
module._free(errPtr);
|
|
83
|
-
}
|
|
184
|
+
return readFixedWidthCString(module, outPtr, outMaxBytes);
|
|
185
|
+
});
|
|
84
186
|
}
|
|
85
|
-
function
|
|
86
|
-
|
|
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 {
|
|
187
|
+
function tspiceCallSct2e(module, sc, sclkdp) {
|
|
188
|
+
return withAllocs(module, [WASM_ERR_MAX_BYTES, 8], (errPtr, outEtPtr) => {
|
|
98
189
|
module.HEAPF64[outEtPtr >> 3] = 0;
|
|
99
|
-
const result = module.
|
|
190
|
+
const result = module._tspice_sct2e(sc, sclkdp, outEtPtr, errPtr, WASM_ERR_MAX_BYTES);
|
|
100
191
|
if (result !== 0) {
|
|
101
|
-
throwWasmSpiceError(module, errPtr,
|
|
192
|
+
throwWasmSpiceError(module, errPtr, WASM_ERR_MAX_BYTES, result);
|
|
102
193
|
}
|
|
103
194
|
return module.HEAPF64[outEtPtr >> 3] ?? 0;
|
|
104
|
-
}
|
|
105
|
-
finally {
|
|
106
|
-
module._free(outEtPtr);
|
|
107
|
-
module._free(sclkchPtr);
|
|
108
|
-
module._free(errPtr);
|
|
109
|
-
}
|
|
195
|
+
});
|
|
110
196
|
}
|
|
111
|
-
function
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
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);
|
|
197
|
+
function tspiceCallSce2c(module, sc, et) {
|
|
198
|
+
return withAllocs(module, [WASM_ERR_MAX_BYTES, 8], (errPtr, outSclkdpPtr) => {
|
|
199
|
+
module.HEAPF64[outSclkdpPtr >> 3] = 0;
|
|
200
|
+
const result = module._tspice_sce2c(sc, et, outSclkdpPtr, errPtr, WASM_ERR_MAX_BYTES);
|
|
127
201
|
if (result !== 0) {
|
|
128
|
-
throwWasmSpiceError(module, errPtr,
|
|
202
|
+
throwWasmSpiceError(module, errPtr, WASM_ERR_MAX_BYTES, result);
|
|
129
203
|
}
|
|
130
|
-
return module.
|
|
131
|
-
}
|
|
132
|
-
finally {
|
|
133
|
-
module._free(outPtr);
|
|
134
|
-
module._free(errPtr);
|
|
135
|
-
}
|
|
204
|
+
return module.HEAPF64[outSclkdpPtr >> 3] ?? 0;
|
|
205
|
+
});
|
|
136
206
|
}
|
|
207
|
+
/** Read the embedded CSPICE toolkit version string from the WASM module. */
|
|
137
208
|
export function getToolkitVersion(module) {
|
|
138
209
|
const outMaxBytes = 256;
|
|
139
|
-
|
|
140
|
-
|
|
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);
|
|
210
|
+
return withAllocs(module, [outMaxBytes, WASM_ERR_MAX_BYTES], (outPtr, errPtr) => {
|
|
211
|
+
const result = module._tspice_tkvrsn_toolkit(outPtr, outMaxBytes, errPtr, WASM_ERR_MAX_BYTES);
|
|
153
212
|
if (result !== 0) {
|
|
154
|
-
const message = module.UTF8ToString(errPtr,
|
|
213
|
+
const message = module.UTF8ToString(errPtr, WASM_ERR_MAX_BYTES).trim();
|
|
155
214
|
throw new Error(message || `CSPICE call failed with code ${result}`);
|
|
156
215
|
}
|
|
157
216
|
return module.UTF8ToString(outPtr, outMaxBytes);
|
|
158
|
-
}
|
|
159
|
-
finally {
|
|
160
|
-
module._free(errPtr);
|
|
161
|
-
module._free(outPtr);
|
|
162
|
-
}
|
|
217
|
+
});
|
|
163
218
|
}
|
|
219
|
+
/** Create a {@link TimeApi} implementation backed by a WASM Emscripten module. */
|
|
164
220
|
export function createTimeApi(module, toolkitVersion) {
|
|
165
221
|
return {
|
|
166
222
|
spiceVersion: () => toolkitVersion,
|
|
@@ -170,11 +226,57 @@ export function createTimeApi(module, toolkitVersion) {
|
|
|
170
226
|
}
|
|
171
227
|
return toolkitVersion;
|
|
172
228
|
},
|
|
229
|
+
timdef: (() => {
|
|
230
|
+
function timdef(action, item, value) {
|
|
231
|
+
if (item.length === 0) {
|
|
232
|
+
throw new RangeError("timdef(): item must be a non-empty string");
|
|
233
|
+
}
|
|
234
|
+
switch (action) {
|
|
235
|
+
case "GET": {
|
|
236
|
+
return tspiceCallTimdefGet(module, item);
|
|
237
|
+
}
|
|
238
|
+
case "SET": {
|
|
239
|
+
if (typeof value !== "string") {
|
|
240
|
+
throw new TypeError("timdef(SET) requires a string value");
|
|
241
|
+
}
|
|
242
|
+
if (value.length === 0) {
|
|
243
|
+
throw new RangeError("timdef(SET)(): value must be a non-empty string");
|
|
244
|
+
}
|
|
245
|
+
tspiceCallTimdefSet(module, item, value);
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
default:
|
|
249
|
+
return assertNever(action, "Unsupported timdef action");
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
return timdef;
|
|
253
|
+
})(),
|
|
173
254
|
str2et: (utc) => tspiceCallStr2et(module, utc),
|
|
174
255
|
et2utc: (et, format, prec) => tspiceCallEt2utc(module, et, format, prec),
|
|
175
256
|
timout: (et, picture) => tspiceCallTimout(module, et, picture),
|
|
257
|
+
deltet: (epoch, eptype) => tspiceCallDeltet(module, epoch, eptype),
|
|
258
|
+
unitim: (epoch, insys, outsys) => tspiceCallUnitim(module, epoch, insys, outsys),
|
|
259
|
+
tparse: (timstr) => {
|
|
260
|
+
if (timstr.length === 0) {
|
|
261
|
+
throw new RangeError("tparse(): timstr must be a non-empty string");
|
|
262
|
+
}
|
|
263
|
+
return tspiceCallTparse(module, timstr);
|
|
264
|
+
},
|
|
265
|
+
tpictr: (sample, pictur) => {
|
|
266
|
+
if (sample.length === 0) {
|
|
267
|
+
throw new RangeError("tpictr(): sample must be a non-empty string");
|
|
268
|
+
}
|
|
269
|
+
if (pictur.length === 0) {
|
|
270
|
+
throw new RangeError("tpictr(): pictur must be a non-empty string");
|
|
271
|
+
}
|
|
272
|
+
return tspiceCallTpictr(module, sample, pictur);
|
|
273
|
+
},
|
|
176
274
|
scs2e: (sc, sclkch) => tspiceCallScs2e(module, sc, sclkch),
|
|
177
275
|
sce2s: (sc, et) => tspiceCallSce2s(module, sc, et),
|
|
276
|
+
scencd: (sc, sclkch) => tspiceCallScencd(module, sc, sclkch),
|
|
277
|
+
scdecd: (sc, sclkdp) => tspiceCallScdecd(module, sc, sclkdp),
|
|
278
|
+
sct2e: (sc, sclkdp) => tspiceCallSct2e(module, sc, sclkdp),
|
|
279
|
+
sce2c: (sc, et) => tspiceCallSce2c(module, sc, et),
|
|
178
280
|
};
|
|
179
281
|
}
|
|
180
282
|
//# sourceMappingURL=time.js.map
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { SpiceBackend } from "#backend-contract";
|
|
2
2
|
export type { CreateWasmBackendOptions } from "./runtime/create-backend-options.js";
|
|
3
3
|
import type { CreateWasmBackendOptions } from "./runtime/create-backend-options.js";
|
|
4
4
|
export declare const WASM_BINARY_FILENAME: "tspice_backend_wasm.wasm";
|
|
5
5
|
export declare const WASM_JS_FILENAME: string;
|
|
6
|
-
export declare function createWasmBackend(options?: CreateWasmBackendOptions): Promise<
|
|
6
|
+
export declare function createWasmBackend(options?: CreateWasmBackendOptions): Promise<SpiceBackend & {
|
|
7
|
+
kind: "wasm";
|
|
8
|
+
}>;
|
|
7
9
|
//# sourceMappingURL=index.d.ts.map
|