@rybosome/tspice 0.0.7 → 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.
Files changed (214) hide show
  1. package/README.md +140 -78
  2. package/backend-contract/dist/.tsbuildinfo +1 -1
  3. package/backend-contract/dist/domains/cells-windows.d.ts +94 -0
  4. package/backend-contract/dist/domains/cells-windows.js +10 -0
  5. package/backend-contract/dist/domains/coords-vectors.d.ts +50 -0
  6. package/backend-contract/dist/domains/dsk.d.ts +49 -0
  7. package/backend-contract/dist/domains/dsk.js +2 -0
  8. package/backend-contract/dist/domains/ek.d.ts +186 -0
  9. package/backend-contract/dist/domains/ek.js +8 -0
  10. package/backend-contract/dist/domains/ephemeris.d.ts +141 -3
  11. package/backend-contract/dist/domains/error.d.ts +42 -0
  12. package/backend-contract/dist/domains/error.js +33 -0
  13. package/backend-contract/dist/domains/file-io.d.ts +114 -0
  14. package/backend-contract/dist/domains/file-io.js +8 -0
  15. package/backend-contract/dist/domains/frames.d.ts +40 -0
  16. package/backend-contract/dist/domains/geometry-gf.d.ts +44 -0
  17. package/backend-contract/dist/domains/geometry-gf.js +14 -0
  18. package/backend-contract/dist/domains/geometry.d.ts +21 -1
  19. package/backend-contract/dist/domains/ids-names-normalize.d.ts +3 -0
  20. package/backend-contract/dist/domains/ids-names-normalize.js +74 -0
  21. package/backend-contract/dist/domains/ids-names.d.ts +37 -0
  22. package/backend-contract/dist/domains/kernel-pool.d.ts +134 -0
  23. package/backend-contract/dist/domains/kernel-pool.js +2 -0
  24. package/backend-contract/dist/domains/kernels-utils.d.ts +44 -0
  25. package/backend-contract/dist/domains/kernels-utils.js +265 -0
  26. package/backend-contract/dist/domains/kernels.d.ts +39 -3
  27. package/backend-contract/dist/domains/time.d.ts +102 -0
  28. package/backend-contract/dist/index.d.ts +31 -3
  29. package/backend-contract/dist/index.js +15 -1
  30. package/backend-contract/dist/shared/errors.d.ts +6 -0
  31. package/backend-contract/dist/shared/errors.js +8 -0
  32. package/backend-contract/dist/shared/mat3.d.ts +26 -14
  33. package/backend-contract/dist/shared/mat3.js +46 -17
  34. package/backend-contract/dist/shared/mat6.d.ts +34 -0
  35. package/backend-contract/dist/shared/mat6.js +116 -0
  36. package/backend-contract/dist/shared/spice-handles.d.ts +20 -0
  37. package/backend-contract/dist/shared/spice-handles.js +82 -0
  38. package/backend-contract/dist/shared/spice-int.d.ts +32 -0
  39. package/backend-contract/dist/shared/spice-int.js +41 -0
  40. package/backend-contract/dist/shared/types.d.ts +106 -1
  41. package/backend-contract/dist/shared/vec.d.ts +54 -0
  42. package/backend-contract/dist/shared/vec.js +162 -0
  43. package/backend-fake/dist/.tsbuildinfo +1 -1
  44. package/backend-fake/dist/index.d.ts +19 -1
  45. package/backend-fake/dist/index.js +1103 -18
  46. package/backend-node/dist/.tsbuildinfo +1 -1
  47. package/backend-node/dist/codec/arrays.d.ts +9 -0
  48. package/backend-node/dist/codec/arrays.js +36 -0
  49. package/backend-node/dist/codec/errors.d.ts +6 -6
  50. package/backend-node/dist/codec/errors.js +6 -6
  51. package/backend-node/dist/domains/cells-windows.d.ts +5 -0
  52. package/backend-node/dist/domains/cells-windows.js +112 -0
  53. package/backend-node/dist/domains/coords-vectors.d.ts +1 -0
  54. package/backend-node/dist/domains/coords-vectors.js +64 -1
  55. package/backend-node/dist/domains/dsk.d.ts +6 -0
  56. package/backend-node/dist/domains/dsk.js +108 -0
  57. package/backend-node/dist/domains/ek.d.ts +10 -0
  58. package/backend-node/dist/domains/ek.js +100 -0
  59. package/backend-node/dist/domains/ephemeris.d.ts +5 -1
  60. package/backend-node/dist/domains/ephemeris.js +150 -1
  61. package/backend-node/dist/domains/error.d.ts +5 -0
  62. package/backend-node/dist/domains/error.js +34 -0
  63. package/backend-node/dist/domains/file-io.d.ts +7 -0
  64. package/backend-node/dist/domains/file-io.js +105 -0
  65. package/backend-node/dist/domains/frames.d.ts +1 -0
  66. package/backend-node/dist/domains/frames.js +52 -0
  67. package/backend-node/dist/domains/geometry-gf.d.ts +5 -0
  68. package/backend-node/dist/domains/geometry-gf.js +74 -0
  69. package/backend-node/dist/domains/geometry.d.ts +1 -0
  70. package/backend-node/dist/domains/geometry.js +62 -0
  71. package/backend-node/dist/domains/ids-names.d.ts +2 -1
  72. package/backend-node/dist/domains/ids-names.js +30 -0
  73. package/backend-node/dist/domains/kernel-pool.d.ts +5 -0
  74. package/backend-node/dist/domains/kernel-pool.js +74 -0
  75. package/backend-node/dist/domains/kernels.d.ts +1 -0
  76. package/backend-node/dist/domains/kernels.js +100 -13
  77. package/backend-node/dist/domains/time.d.ts +1 -0
  78. package/backend-node/dist/domains/time.js +75 -1
  79. package/backend-node/dist/index.d.ts +2 -0
  80. package/backend-node/dist/index.js +62 -1
  81. package/backend-node/dist/lowlevel/binding.d.ts +3 -0
  82. package/backend-node/dist/lowlevel/binding.js +115 -0
  83. package/backend-node/dist/runtime/addon.d.ts +271 -0
  84. package/backend-node/dist/runtime/addon.js +3 -0
  85. package/backend-node/dist/runtime/kernel-staging.d.ts +17 -0
  86. package/backend-node/dist/runtime/kernel-staging.js +80 -7
  87. package/backend-node/dist/runtime/spice-handles.d.ts +3 -0
  88. package/backend-node/dist/runtime/spice-handles.js +2 -0
  89. package/backend-node/dist/runtime/virtual-output-staging.d.ts +16 -0
  90. package/backend-node/dist/runtime/virtual-output-staging.js +148 -0
  91. package/backend-wasm/dist/.tsbuildinfo +1 -1
  92. package/backend-wasm/dist/codec/alloc.d.ts +19 -0
  93. package/backend-wasm/dist/codec/alloc.js +64 -0
  94. package/backend-wasm/dist/codec/calls.d.ts +2 -0
  95. package/backend-wasm/dist/codec/calls.js +13 -24
  96. package/backend-wasm/dist/codec/errors.d.ts +6 -0
  97. package/backend-wasm/dist/codec/errors.js +34 -2
  98. package/backend-wasm/dist/codec/found.d.ts +2 -0
  99. package/backend-wasm/dist/codec/found.js +20 -43
  100. package/backend-wasm/dist/codec/strings.d.ts +31 -1
  101. package/backend-wasm/dist/codec/strings.js +93 -6
  102. package/backend-wasm/dist/domains/cells-windows.d.ts +9 -0
  103. package/backend-wasm/dist/domains/cells-windows.js +392 -0
  104. package/backend-wasm/dist/domains/coords-vectors.d.ts +1 -0
  105. package/backend-wasm/dist/domains/coords-vectors.js +377 -187
  106. package/backend-wasm/dist/domains/dsk.d.ts +6 -0
  107. package/backend-wasm/dist/domains/dsk.js +179 -0
  108. package/backend-wasm/dist/domains/ek.d.ts +6 -0
  109. package/backend-wasm/dist/domains/ek.js +543 -0
  110. package/backend-wasm/dist/domains/ephemeris.d.ts +4 -1
  111. package/backend-wasm/dist/domains/ephemeris.js +405 -46
  112. package/backend-wasm/dist/domains/error.d.ts +5 -0
  113. package/backend-wasm/dist/domains/error.js +109 -0
  114. package/backend-wasm/dist/domains/file-io.d.ts +7 -0
  115. package/backend-wasm/dist/domains/file-io.js +462 -0
  116. package/backend-wasm/dist/domains/frames.d.ts +1 -0
  117. package/backend-wasm/dist/domains/frames.js +136 -4
  118. package/backend-wasm/dist/domains/geometry-gf.d.ts +5 -0
  119. package/backend-wasm/dist/domains/geometry-gf.js +178 -0
  120. package/backend-wasm/dist/domains/geometry.d.ts +1 -0
  121. package/backend-wasm/dist/domains/geometry.js +210 -0
  122. package/backend-wasm/dist/domains/ids-names.d.ts +2 -1
  123. package/backend-wasm/dist/domains/ids-names.js +89 -0
  124. package/backend-wasm/dist/domains/kernel-pool.d.ts +5 -0
  125. package/backend-wasm/dist/domains/kernel-pool.js +357 -0
  126. package/backend-wasm/dist/domains/kernels.d.ts +1 -0
  127. package/backend-wasm/dist/domains/kernels.js +91 -2
  128. package/backend-wasm/dist/domains/time.d.ts +2 -0
  129. package/backend-wasm/dist/domains/time.js +235 -133
  130. package/backend-wasm/dist/lowlevel/exports.d.ts +215 -1
  131. package/backend-wasm/dist/lowlevel/exports.js +217 -38
  132. package/backend-wasm/dist/runtime/create-backend-options.d.ts +21 -0
  133. package/backend-wasm/dist/runtime/create-backend.node.d.ts +7 -0
  134. package/backend-wasm/dist/runtime/create-backend.node.js +283 -12
  135. package/backend-wasm/dist/runtime/create-backend.web.d.ts +1 -0
  136. package/backend-wasm/dist/runtime/create-backend.web.js +40 -4
  137. package/backend-wasm/dist/runtime/fs.d.ts +5 -0
  138. package/backend-wasm/dist/runtime/fs.js +5 -0
  139. package/backend-wasm/dist/runtime/spice-handles.d.ts +3 -0
  140. package/backend-wasm/dist/runtime/spice-handles.js +2 -0
  141. package/backend-wasm/dist/runtime/virtual-outputs.d.ts +16 -0
  142. package/backend-wasm/dist/runtime/virtual-outputs.js +35 -0
  143. package/backend-wasm/dist/tspice_backend_wasm.node.js +3 -3
  144. package/backend-wasm/dist/tspice_backend_wasm.wasm +0 -0
  145. package/backend-wasm/dist/tspice_backend_wasm.web.js +1 -1
  146. package/core/dist/.tsbuildinfo +1 -1
  147. package/core/dist/index.d.ts +19 -8
  148. package/core/dist/index.js +19 -8
  149. package/dist/.tsbuildinfo +1 -1
  150. package/dist/backend.d.ts +5 -0
  151. package/dist/clients/createSpiceAsyncFromTransport.d.ts +5 -0
  152. package/dist/clients/createSpiceAsyncFromTransport.js +90 -0
  153. package/dist/clients/createSpiceSyncFromTransport.d.ts +5 -0
  154. package/dist/clients/createSpiceSyncFromTransport.js +88 -0
  155. package/dist/clients/spiceClients.d.ts +59 -0
  156. package/dist/clients/spiceClients.js +292 -0
  157. package/dist/errors.d.ts +4 -0
  158. package/dist/errors.js +4 -0
  159. package/dist/index.d.ts +10 -7
  160. package/dist/index.js +4 -3
  161. package/dist/kernels/defaultKernelPathFromUrl.d.ts +8 -0
  162. package/dist/kernels/defaultKernelPathFromUrl.js +32 -0
  163. package/dist/kernels/kernelPack.d.ts +88 -0
  164. package/dist/kernels/kernelPack.js +122 -0
  165. package/dist/kernels/kernels.d.ts +98 -0
  166. package/dist/kernels/kernels.js +217 -0
  167. package/dist/kernels/naifKernelId.d.ts +2 -0
  168. package/dist/kernels/naifKernelId.js +2 -0
  169. package/dist/kit/math/mat3.d.ts +9 -1
  170. package/dist/kit/math/mat3.js +9 -1
  171. package/dist/kit/spice/create-kit.d.ts +1 -0
  172. package/dist/kit/spice/create-kit.js +1 -0
  173. package/dist/kit/spice/frames.d.ts +1 -0
  174. package/dist/kit/spice/frames.js +1 -0
  175. package/dist/kit/spice/kernels.d.ts +1 -0
  176. package/dist/kit/spice/kernels.js +1 -0
  177. package/dist/kit/spice/state.d.ts +2 -1
  178. package/dist/kit/spice/state.js +8 -4
  179. package/dist/kit/spice/time.d.ts +1 -0
  180. package/dist/kit/spice/time.js +1 -0
  181. package/dist/kit/types/spice-types.d.ts +18 -1
  182. package/dist/spice.d.ts +10 -1
  183. package/dist/spice.js +41 -0
  184. package/dist/transport/caching/policy.d.ts +16 -0
  185. package/dist/transport/caching/policy.js +77 -0
  186. package/dist/transport/caching/withCaching.d.ts +125 -0
  187. package/dist/transport/caching/withCaching.js +335 -0
  188. package/dist/transport/caching/withCachingSync.d.ts +24 -0
  189. package/dist/transport/caching/withCachingSync.js +161 -0
  190. package/dist/transport/rpc/protocol.d.ts +35 -0
  191. package/dist/transport/rpc/protocol.js +56 -0
  192. package/dist/transport/rpc/taskScheduling.d.ts +20 -0
  193. package/dist/transport/rpc/taskScheduling.js +98 -0
  194. package/dist/transport/rpc/valueCodec.d.ts +5 -0
  195. package/dist/transport/rpc/valueCodec.js +106 -0
  196. package/dist/transport/types.d.ts +7 -0
  197. package/dist/transport/types.js +2 -0
  198. package/dist/types.d.ts +8 -5
  199. package/dist/types.js +2 -1
  200. package/dist/worker/browser/createSpiceWorker.d.ts +22 -0
  201. package/dist/worker/browser/createSpiceWorker.js +41 -0
  202. package/dist/worker/browser/createSpiceWorkerClient.d.ts +40 -0
  203. package/dist/worker/browser/createSpiceWorkerClient.js +99 -0
  204. package/dist/worker/browser/spiceWorkerEntry.d.ts +2 -0
  205. package/dist/worker/browser/spiceWorkerEntry.js +129 -0
  206. package/dist/worker/browser/spiceWorkerInlineSource.d.ts +2 -0
  207. package/dist/worker/browser/spiceWorkerInlineSource.js +4 -0
  208. package/dist/worker/index.d.ts +10 -0
  209. package/dist/worker/index.js +7 -0
  210. package/dist/worker/transport/createWorkerTransport.d.ts +69 -0
  211. package/dist/worker/transport/createWorkerTransport.js +398 -0
  212. package/dist/worker/transport/exposeTransportToWorker.d.ts +51 -0
  213. package/dist/worker/transport/exposeTransportToWorker.js +196 -0
  214. package/package.json +4 -4
@@ -0,0 +1,462 @@
1
+ import { assertSpiceInt32, assertSpiceInt32NonNegative } from "#backend-contract";
2
+ import { WASM_ERR_MAX_BYTES, withAllocs, withMalloc } from "../codec/alloc.js";
3
+ import { throwWasmSpiceError } from "../codec/errors.js";
4
+ import { writeUtf8CString } from "../codec/strings.js";
5
+ import { resolveKernelPath } from "../runtime/fs.js";
6
+ const DAS_BACKED = ["DAS", "DLA"];
7
+ const I32_MIN = -2147483648;
8
+ const I32_MAX = 2147483647;
9
+ // Fixed-size portion of the DSK type 2 spatial index double component.
10
+ //
11
+ // CSPICE: `SPICE_DSK02_IXDFIX` (and `SPICE_DSK02_SPADSZ`).
12
+ const DSK02_IXDFIX = 10;
13
+ // Hard cap for DSK spatial index scratch sizes (worksz/spxisz).
14
+ // Matches native-addon validation.
15
+ const DSKMI2_MAX_SIZE = 5_000_000;
16
+ const DESCR_KEYS = [
17
+ "bwdptr",
18
+ "fwdptr",
19
+ "ibase",
20
+ "isize",
21
+ "dbase",
22
+ "dsize",
23
+ "cbase",
24
+ "csize",
25
+ ];
26
+ function readHeapI32(module, idx, context) {
27
+ const heap = module.HEAP32;
28
+ const v = heap[idx];
29
+ // Typed array OOB reads return `undefined`. We should treat that as a bug
30
+ // rather than silently fabricating a `0` value.
31
+ if (v === undefined) {
32
+ throw new RangeError(`${context}: out-of-bounds HEAP32 read (idx=${idx}, heapLen=${heap.length})`);
33
+ }
34
+ return v;
35
+ }
36
+ function heap32IndexFromPtr(ptr, context) {
37
+ if (!Number.isFinite(ptr) || !Number.isInteger(ptr)) {
38
+ throw new TypeError(`${context}: expected ptr to be a finite integer (got ${ptr})`);
39
+ }
40
+ if (ptr < 0) {
41
+ throw new RangeError(`${context}: expected ptr to be >= 0 (got ${ptr})`);
42
+ }
43
+ if (ptr % 4 !== 0) {
44
+ throw new RangeError(`${context}: expected ptr to be 4-byte aligned (got ${ptr})`);
45
+ }
46
+ return ptr / 4;
47
+ }
48
+ function writeDlaDescr8(module, ptr, descr) {
49
+ const base = heap32IndexFromPtr(ptr, "writeDlaDescr8(ptr)");
50
+ const heap = module.HEAP32;
51
+ // Typed array out-of-bounds writes are ignored, which can mask bugs and
52
+ // lead to silently-corrupted descriptors. Fail fast instead.
53
+ if (base < 0 || base + 7 >= heap.length) {
54
+ throw new RangeError(`writeDlaDescr8: descriptor pointer out of bounds (ptr=${ptr}, base=${base}, heapLen=${heap.length})`);
55
+ }
56
+ heap[base + 0] = descr.bwdptr | 0;
57
+ heap[base + 1] = descr.fwdptr | 0;
58
+ heap[base + 2] = descr.ibase | 0;
59
+ heap[base + 3] = descr.isize | 0;
60
+ heap[base + 4] = descr.dbase | 0;
61
+ heap[base + 5] = descr.dsize | 0;
62
+ heap[base + 6] = descr.cbase | 0;
63
+ heap[base + 7] = descr.csize | 0;
64
+ }
65
+ function readDlaDescr8(module, ptr) {
66
+ const base = heap32IndexFromPtr(ptr, "readDlaDescr8(ptr)");
67
+ const heap = module.HEAP32;
68
+ // HEAP32 returns `undefined` for out-of-bounds reads. That can mask bugs and
69
+ // lead to silently-corrupted DLA descriptors, so fail fast instead.
70
+ if (base < 0 || base + 7 >= heap.length) {
71
+ throw new RangeError(`readDlaDescr8: descriptor pointer out of bounds (ptr=${ptr}, base=${base}, heapLen=${heap.length})`);
72
+ }
73
+ return {
74
+ bwdptr: heap[base + 0],
75
+ fwdptr: heap[base + 1],
76
+ ibase: heap[base + 2],
77
+ isize: heap[base + 3],
78
+ dbase: heap[base + 4],
79
+ dsize: heap[base + 5],
80
+ cbase: heap[base + 6],
81
+ csize: heap[base + 7],
82
+ };
83
+ }
84
+ function assertDlaDescriptor(value, context) {
85
+ if (typeof value !== "object" || value === null) {
86
+ throw new Error(`${context}: expected an object`);
87
+ }
88
+ const obj = value;
89
+ for (const key of DESCR_KEYS) {
90
+ const v = obj[key];
91
+ if (typeof v !== "number" ||
92
+ !Number.isInteger(v) ||
93
+ v < I32_MIN ||
94
+ v > I32_MAX) {
95
+ throw new Error(`${context}: expected ${key} to be a 32-bit signed integer`);
96
+ }
97
+ const min = key === "bwdptr" || key === "fwdptr" ? -1 : 0;
98
+ if (v < min) {
99
+ throw new Error(`${context}: expected ${key} to be >= ${min}`);
100
+ }
101
+ }
102
+ }
103
+ function callVoidHandle(module, fn, handle) {
104
+ withMalloc(module, WASM_ERR_MAX_BYTES, (errPtr) => {
105
+ const code = fn(handle, errPtr, WASM_ERR_MAX_BYTES);
106
+ if (code !== 0) {
107
+ throwWasmSpiceError(module, errPtr, WASM_ERR_MAX_BYTES, code);
108
+ }
109
+ });
110
+ }
111
+ /** Create a {@link FileIoApi} implementation backed by a WASM Emscripten module. */
112
+ export function createFileIoApi(module, handles, virtualOutputs) {
113
+ function closeDasBacked(handle, context) {
114
+ handles.close(handle, DAS_BACKED, (entry) => {
115
+ // In CSPICE, `dascls_c` closes both DAS and DLA handles, and `dlacls_c`
116
+ // is just an alias.
117
+ callVoidHandle(module, module._tspice_dascls, entry.nativeHandle);
118
+ }, context);
119
+ }
120
+ return {
121
+ exists: (path) => {
122
+ const resolved = resolveKernelPath(path);
123
+ const pathPtr = writeUtf8CString(module, resolved);
124
+ try {
125
+ return withAllocs(module, [4, WASM_ERR_MAX_BYTES], (outExistsPtr, errPtr) => {
126
+ module.HEAP32[outExistsPtr >> 2] = 0;
127
+ const code = module._tspice_exists(pathPtr, outExistsPtr, errPtr, WASM_ERR_MAX_BYTES);
128
+ if (code !== 0) {
129
+ throwWasmSpiceError(module, errPtr, WASM_ERR_MAX_BYTES, code);
130
+ }
131
+ return readHeapI32(module, outExistsPtr >> 2, "exists(outExistsPtr)") !== 0;
132
+ });
133
+ }
134
+ finally {
135
+ module._free(pathPtr);
136
+ }
137
+ },
138
+ getfat: (path) => {
139
+ const resolved = resolveKernelPath(path);
140
+ const pathPtr = writeUtf8CString(module, resolved);
141
+ const archMaxBytes = 64;
142
+ const typeMaxBytes = 64;
143
+ try {
144
+ return withAllocs(module, [archMaxBytes, typeMaxBytes, WASM_ERR_MAX_BYTES], (archPtr, typePtr, errPtr) => {
145
+ const code = module._tspice_getfat(pathPtr, archPtr, archMaxBytes, typePtr, typeMaxBytes, errPtr, WASM_ERR_MAX_BYTES);
146
+ if (code !== 0) {
147
+ throwWasmSpiceError(module, errPtr, WASM_ERR_MAX_BYTES, code);
148
+ }
149
+ return {
150
+ arch: module.UTF8ToString(archPtr, archMaxBytes).trim(),
151
+ type: module.UTF8ToString(typePtr, typeMaxBytes).trim(),
152
+ };
153
+ });
154
+ }
155
+ finally {
156
+ module._free(pathPtr);
157
+ }
158
+ },
159
+ readVirtualOutput: (output) => {
160
+ if (typeof output !== "object" || output === null) {
161
+ throw new Error("readVirtualOutput(output): expected an object");
162
+ }
163
+ const obj = output;
164
+ if (obj.kind !== "virtual-output") {
165
+ throw new Error("readVirtualOutput(output): expected kind='virtual-output'");
166
+ }
167
+ if (typeof obj.path !== "string") {
168
+ throw new Error("readVirtualOutput(output): expected path to be a string");
169
+ }
170
+ const resolved = resolveKernelPath(obj.path);
171
+ // Namespace/lifecycle restriction: `readVirtualOutput()` should not be a
172
+ // generic WASM-FS read primitive.
173
+ virtualOutputs.assertReadable(resolved, obj.path);
174
+ // Emscripten returns a Uint8Array for binary reads.
175
+ try {
176
+ return module.FS.readFile(resolved, { encoding: "binary" });
177
+ }
178
+ catch (error) {
179
+ // Emscripten FS errors use Node-style codes in the message, but don't
180
+ // reliably surface a typed `code` property.
181
+ throw new Error(`readVirtualOutput(): failed to read VirtualOutput ${JSON.stringify(obj.path)} at ${resolved}. ` +
182
+ "Make sure the writer handle was closed successfully before reading.", { cause: error });
183
+ }
184
+ },
185
+ dafopr: (path) => {
186
+ const resolved = resolveKernelPath(path);
187
+ const pathPtr = writeUtf8CString(module, resolved);
188
+ try {
189
+ const nativeHandle = withAllocs(module, [4, WASM_ERR_MAX_BYTES], (outHandlePtr, errPtr) => {
190
+ module.HEAP32[outHandlePtr >> 2] = 0;
191
+ const code = module._tspice_dafopr(pathPtr, outHandlePtr, errPtr, WASM_ERR_MAX_BYTES);
192
+ if (code !== 0) {
193
+ throwWasmSpiceError(module, errPtr, WASM_ERR_MAX_BYTES, code);
194
+ }
195
+ return readHeapI32(module, outHandlePtr >> 2, "dafopr(outHandlePtr)");
196
+ });
197
+ return handles.register("DAF", nativeHandle);
198
+ }
199
+ finally {
200
+ module._free(pathPtr);
201
+ }
202
+ },
203
+ dafcls: (handle) => handles.close(handle, ["DAF"], (entry) => callVoidHandle(module, module._tspice_dafcls, entry.nativeHandle), "dafcls"),
204
+ dafbfs: (handle) => callVoidHandle(module, module._tspice_dafbfs, handles.lookup(handle, ["DAF"], "dafbfs").nativeHandle),
205
+ daffna: (handle) => {
206
+ const nativeHandle = handles.lookup(handle, ["DAF"], "daffna").nativeHandle;
207
+ return withAllocs(module, [4, WASM_ERR_MAX_BYTES], (outFoundPtr, errPtr) => {
208
+ module.HEAP32[outFoundPtr >> 2] = 0;
209
+ const code = module._tspice_daffna(nativeHandle, outFoundPtr, errPtr, WASM_ERR_MAX_BYTES);
210
+ if (code !== 0) {
211
+ throwWasmSpiceError(module, errPtr, WASM_ERR_MAX_BYTES, code);
212
+ }
213
+ return readHeapI32(module, outFoundPtr >> 2, "daffna(outFoundPtr)") !== 0;
214
+ });
215
+ },
216
+ dasopr: (path) => {
217
+ const resolved = resolveKernelPath(path);
218
+ const pathPtr = writeUtf8CString(module, resolved);
219
+ try {
220
+ const nativeHandle = withAllocs(module, [4, WASM_ERR_MAX_BYTES], (outHandlePtr, errPtr) => {
221
+ module.HEAP32[outHandlePtr >> 2] = 0;
222
+ const code = module._tspice_dasopr(pathPtr, outHandlePtr, errPtr, WASM_ERR_MAX_BYTES);
223
+ if (code !== 0) {
224
+ throwWasmSpiceError(module, errPtr, WASM_ERR_MAX_BYTES, code);
225
+ }
226
+ return readHeapI32(module, outHandlePtr >> 2, "dasopr(outHandlePtr)");
227
+ });
228
+ return handles.register("DAS", nativeHandle);
229
+ }
230
+ finally {
231
+ module._free(pathPtr);
232
+ }
233
+ },
234
+ dascls: (handle) => closeDasBacked(handle, "dascls"),
235
+ dlaopn: (path, ftype, ifname, ncomch) => {
236
+ assertSpiceInt32NonNegative(ncomch, "dlaopn(ncomch)");
237
+ const resolved = resolveKernelPath(path);
238
+ // `dlaopn_c` creates the output file via C stdio, so we must ensure the
239
+ // directory exists in the Emscripten FS.
240
+ const dir = resolved.split("/").slice(0, -1).join("/") || "/";
241
+ if (dir && dir !== "/") {
242
+ module.FS.mkdirTree(dir);
243
+ }
244
+ const pathPtr = writeUtf8CString(module, resolved);
245
+ const ftypePtr = writeUtf8CString(module, ftype);
246
+ const ifnamePtr = writeUtf8CString(module, ifname);
247
+ try {
248
+ const nativeHandle = withAllocs(module, [4, WASM_ERR_MAX_BYTES], (outHandlePtr, errPtr) => {
249
+ module.HEAP32[outHandlePtr >> 2] = 0;
250
+ const code = module._tspice_dlaopn(pathPtr, ftypePtr, ifnamePtr, ncomch, outHandlePtr, errPtr, WASM_ERR_MAX_BYTES);
251
+ if (code !== 0) {
252
+ throwWasmSpiceError(module, errPtr, WASM_ERR_MAX_BYTES, code);
253
+ }
254
+ return readHeapI32(module, outHandlePtr >> 2, "dlaopn(outHandlePtr)");
255
+ });
256
+ return handles.register("DLA", nativeHandle);
257
+ }
258
+ finally {
259
+ module._free(ifnamePtr);
260
+ module._free(ftypePtr);
261
+ module._free(pathPtr);
262
+ }
263
+ },
264
+ dlabfs: (handle) => {
265
+ const nativeHandle = handles.lookup(handle, DAS_BACKED, "dlabfs").nativeHandle;
266
+ return withAllocs(module, [32, 4, WASM_ERR_MAX_BYTES], (outDescr8Ptr, outFoundPtr, errPtr) => {
267
+ module.HEAP32[outFoundPtr >> 2] = 0;
268
+ const code = module._tspice_dlabfs(nativeHandle, outDescr8Ptr, outFoundPtr, errPtr, WASM_ERR_MAX_BYTES);
269
+ if (code !== 0) {
270
+ throwWasmSpiceError(module, errPtr, WASM_ERR_MAX_BYTES, code);
271
+ }
272
+ const found = readHeapI32(module, outFoundPtr >> 2, "dlabfs(outFoundPtr)") !== 0;
273
+ if (!found) {
274
+ return { found: false };
275
+ }
276
+ return { found: true, descr: readDlaDescr8(module, outDescr8Ptr) };
277
+ });
278
+ },
279
+ dlafns: (handle, descr) => {
280
+ assertDlaDescriptor(descr, "dlafns(descr)");
281
+ const nativeHandle = handles.lookup(handle, DAS_BACKED, "dlafns").nativeHandle;
282
+ return withAllocs(module, [32, 32, 4, WASM_ERR_MAX_BYTES], (inDescr8Ptr, outNextDescr8Ptr, outFoundPtr, errPtr) => {
283
+ writeDlaDescr8(module, inDescr8Ptr, descr);
284
+ module.HEAP32[outFoundPtr >> 2] = 0;
285
+ const code = module._tspice_dlafns(nativeHandle, inDescr8Ptr, outNextDescr8Ptr, outFoundPtr, errPtr, WASM_ERR_MAX_BYTES);
286
+ if (code !== 0) {
287
+ throwWasmSpiceError(module, errPtr, WASM_ERR_MAX_BYTES, code);
288
+ }
289
+ const found = readHeapI32(module, outFoundPtr >> 2, "dlafns(outFoundPtr)") !== 0;
290
+ if (!found) {
291
+ return { found: false };
292
+ }
293
+ return { found: true, descr: readDlaDescr8(module, outNextDescr8Ptr) };
294
+ });
295
+ },
296
+ dlacls: (handle) => closeDasBacked(handle, "dlacls"),
297
+ dskopn: (path, ifname, ncomch) => {
298
+ assertSpiceInt32NonNegative(ncomch, "dskopn(ncomch)");
299
+ const resolved = resolveKernelPath(path);
300
+ // `dskopn_c` creates the output file via C stdio, so we must ensure the
301
+ // directory exists in the Emscripten FS.
302
+ const dir = resolved.split("/").slice(0, -1).join("/") || "/";
303
+ if (dir && dir !== "/") {
304
+ module.FS.mkdirTree(dir);
305
+ }
306
+ const pathPtr = writeUtf8CString(module, resolved);
307
+ const ifnamePtr = writeUtf8CString(module, ifname);
308
+ try {
309
+ const nativeHandle = withAllocs(module, [4, WASM_ERR_MAX_BYTES], (outHandlePtr, errPtr) => {
310
+ module.HEAP32[outHandlePtr >> 2] = 0;
311
+ const code = module._tspice_dskopn(pathPtr, ifnamePtr, ncomch, outHandlePtr, errPtr, WASM_ERR_MAX_BYTES);
312
+ if (code !== 0) {
313
+ throwWasmSpiceError(module, errPtr, WASM_ERR_MAX_BYTES, code);
314
+ }
315
+ return readHeapI32(module, outHandlePtr >> 2, "dskopn(outHandlePtr)");
316
+ });
317
+ // DSKs are DAS-backed; register as DAS so `dascls` can close it.
318
+ return handles.register("DAS", nativeHandle);
319
+ }
320
+ finally {
321
+ module._free(ifnamePtr);
322
+ module._free(pathPtr);
323
+ }
324
+ },
325
+ dskmi2: (nv, vrtces, np, plates, finscl, corscl, worksz, voxpsz, voxlsz, makvtl, spxisz) => {
326
+ assertSpiceInt32NonNegative(nv, "dskmi2(nv)");
327
+ assertSpiceInt32NonNegative(np, "dskmi2(np)");
328
+ assertSpiceInt32(corscl, "dskmi2(corscl)");
329
+ assertSpiceInt32NonNegative(worksz, "dskmi2(worksz)");
330
+ assertSpiceInt32NonNegative(voxpsz, "dskmi2(voxpsz)");
331
+ assertSpiceInt32NonNegative(voxlsz, "dskmi2(voxlsz)");
332
+ assertSpiceInt32NonNegative(spxisz, "dskmi2(spxisz)");
333
+ const expectedVrtcesLen = nv * 3;
334
+ if (expectedVrtcesLen <= 0) {
335
+ throw new RangeError("dskmi2(nv): expected nv > 0");
336
+ }
337
+ if (vrtces.length !== expectedVrtcesLen) {
338
+ throw new RangeError(`dskmi2(vrtces): expected length ${expectedVrtcesLen}, got ${vrtces.length}`);
339
+ }
340
+ const expectedPlatesLen = np * 3;
341
+ if (expectedPlatesLen <= 0) {
342
+ throw new RangeError("dskmi2(np): expected np > 0");
343
+ }
344
+ if (plates.length !== expectedPlatesLen) {
345
+ throw new RangeError(`dskmi2(plates): expected length ${expectedPlatesLen}, got ${plates.length}`);
346
+ }
347
+ for (let i = 0; i < plates.length; i++) {
348
+ const v = plates[i];
349
+ if (v === undefined) {
350
+ throw new RangeError(`dskmi2(plates[${i}]): expected a value, got undefined`);
351
+ }
352
+ assertSpiceInt32(v, `dskmi2(plates[${i}])`);
353
+ if (v < 1 || v > nv) {
354
+ throw new RangeError(`dskmi2(plates[${i}]): expected value in [1, nv] (nv=${nv}), got ${v}`);
355
+ }
356
+ }
357
+ if (worksz <= 0) {
358
+ throw new RangeError("dskmi2(worksz): expected worksz > 0");
359
+ }
360
+ if (worksz > DSKMI2_MAX_SIZE) {
361
+ throw new RangeError(`dskmi2(worksz): expected worksz <= ${DSKMI2_MAX_SIZE}, got ${worksz}`);
362
+ }
363
+ if (spxisz <= 0) {
364
+ throw new RangeError("dskmi2(spxisz): expected spxisz > 0");
365
+ }
366
+ if (spxisz > DSKMI2_MAX_SIZE) {
367
+ throw new RangeError(`dskmi2(spxisz): expected spxisz <= ${DSKMI2_MAX_SIZE}, got ${spxisz}`);
368
+ }
369
+ const vrtcesBytes = expectedVrtcesLen * 8;
370
+ const platesBytes = expectedPlatesLen * 4;
371
+ const spaixdBytes = DSK02_IXDFIX * 8;
372
+ const spaixiBytes = spxisz * 4;
373
+ return withAllocs(module, [vrtcesBytes, platesBytes, spaixdBytes, spaixiBytes, WASM_ERR_MAX_BYTES], (vrtcesPtr, platesPtr, outSpaixdPtr, outSpaixiPtr, errPtr) => {
374
+ module.HEAPF64.set(vrtces, vrtcesPtr >> 3);
375
+ module.HEAP32.set(plates, platesPtr >> 2);
376
+ module.HEAPF64.fill(0, outSpaixdPtr >> 3, (outSpaixdPtr >> 3) + DSK02_IXDFIX);
377
+ module.HEAP32.fill(0, outSpaixiPtr >> 2, (outSpaixiPtr >> 2) + spxisz);
378
+ const code = module._tspice_dskmi2(nv, vrtcesPtr, np, platesPtr, finscl, corscl, worksz, voxpsz, voxlsz, makvtl ? 1 : 0, spxisz, outSpaixdPtr, DSK02_IXDFIX, outSpaixiPtr, spxisz, errPtr, WASM_ERR_MAX_BYTES);
379
+ if (code !== 0) {
380
+ throwWasmSpiceError(module, errPtr, WASM_ERR_MAX_BYTES, code);
381
+ }
382
+ const spaixd = Array.from(module.HEAPF64.subarray(outSpaixdPtr >> 3, (outSpaixdPtr >> 3) + DSK02_IXDFIX));
383
+ const spaixi = Array.from(module.HEAP32.subarray(outSpaixiPtr >> 2, (outSpaixiPtr >> 2) + spxisz));
384
+ return { spaixd, spaixi };
385
+ });
386
+ },
387
+ dskw02: (handle, center, surfid, dclass, frame, corsys, corpar, mncor1, mxcor1, mncor2, mxcor2, mncor3, mxcor3, first, last, nv, vrtces, np, plates, spaixd, spaixi) => {
388
+ assertSpiceInt32(center, "dskw02(center)");
389
+ assertSpiceInt32(surfid, "dskw02(surfid)");
390
+ assertSpiceInt32(dclass, "dskw02(dclass)");
391
+ assertSpiceInt32(corsys, "dskw02(corsys)");
392
+ assertSpiceInt32NonNegative(nv, "dskw02(nv)");
393
+ assertSpiceInt32NonNegative(np, "dskw02(np)");
394
+ const expectedVrtcesLen = nv * 3;
395
+ if (expectedVrtcesLen <= 0) {
396
+ throw new RangeError("dskw02(nv): expected nv > 0");
397
+ }
398
+ if (vrtces.length !== expectedVrtcesLen) {
399
+ throw new RangeError(`dskw02(vrtces): expected length ${expectedVrtcesLen}, got ${vrtces.length}`);
400
+ }
401
+ const expectedPlatesLen = np * 3;
402
+ if (expectedPlatesLen <= 0) {
403
+ throw new RangeError("dskw02(np): expected np > 0");
404
+ }
405
+ if (plates.length !== expectedPlatesLen) {
406
+ throw new RangeError(`dskw02(plates): expected length ${expectedPlatesLen}, got ${plates.length}`);
407
+ }
408
+ for (let i = 0; i < plates.length; i++) {
409
+ const v = plates[i];
410
+ if (v === undefined) {
411
+ throw new RangeError(`dskw02(plates[${i}]): expected a value, got undefined`);
412
+ }
413
+ assertSpiceInt32(v, `dskw02(plates[${i}])`);
414
+ if (v < 1 || v > nv) {
415
+ throw new RangeError(`dskw02(plates[${i}]): expected value in [1, nv] (nv=${nv}), got ${v}`);
416
+ }
417
+ }
418
+ if (corpar.length !== 10) {
419
+ throw new RangeError(`dskw02(corpar): expected length 10, got ${corpar.length}`);
420
+ }
421
+ if (spaixd.length !== DSK02_IXDFIX) {
422
+ throw new RangeError(`dskw02(spaixd): expected length ${DSK02_IXDFIX}, got ${spaixd.length}`);
423
+ }
424
+ const spaixiLen = spaixi.length;
425
+ assertSpiceInt32NonNegative(spaixiLen, "dskw02(spaixi.length)");
426
+ if (spaixiLen <= 0) {
427
+ throw new RangeError("dskw02(spaixi): expected a non-empty array");
428
+ }
429
+ for (let i = 0; i < spaixiLen; i++) {
430
+ const v = spaixi[i];
431
+ if (v === undefined) {
432
+ throw new RangeError(`dskw02(spaixi[${i}]): expected a value, got undefined`);
433
+ }
434
+ assertSpiceInt32(v, `dskw02(spaixi[${i}])`);
435
+ }
436
+ const nativeHandle = handles.lookup(handle, ["DAS"], "dskw02").nativeHandle;
437
+ const framePtr = writeUtf8CString(module, frame);
438
+ try {
439
+ const corparBytes = 10 * 8;
440
+ const vrtcesBytes = expectedVrtcesLen * 8;
441
+ const platesBytes = expectedPlatesLen * 4;
442
+ const spaixdBytes = DSK02_IXDFIX * 8;
443
+ const spaixiBytes = spaixiLen * 4;
444
+ withAllocs(module, [corparBytes, vrtcesBytes, platesBytes, spaixdBytes, spaixiBytes, WASM_ERR_MAX_BYTES], (corparPtr, vrtcesPtr, platesPtr, spaixdPtr, spaixiPtr, errPtr) => {
445
+ module.HEAPF64.set(corpar, corparPtr >> 3);
446
+ module.HEAPF64.set(vrtces, vrtcesPtr >> 3);
447
+ module.HEAP32.set(plates, platesPtr >> 2);
448
+ module.HEAPF64.set(spaixd, spaixdPtr >> 3);
449
+ module.HEAP32.set(spaixi, spaixiPtr >> 2);
450
+ const code = module._tspice_dskw02(nativeHandle, center, surfid, dclass, framePtr, corsys, corparPtr, mncor1, mxcor1, mncor2, mxcor2, mncor3, mxcor3, first, last, nv, vrtcesPtr, np, platesPtr, spaixdPtr, DSK02_IXDFIX, spaixiPtr, spaixiLen, errPtr, WASM_ERR_MAX_BYTES);
451
+ if (code !== 0) {
452
+ throwWasmSpiceError(module, errPtr, WASM_ERR_MAX_BYTES, code);
453
+ }
454
+ });
455
+ }
456
+ finally {
457
+ module._free(framePtr);
458
+ }
459
+ },
460
+ };
461
+ }
462
+ //# sourceMappingURL=file-io.js.map
@@ -1,4 +1,5 @@
1
1
  import type { FramesApi } from "#backend-contract";
2
2
  import type { EmscriptenModule } from "../lowlevel/exports.js";
3
+ /** Create a {@link FramesApi} implementation backed by a WASM Emscripten module. */
3
4
  export declare function createFramesApi(module: EmscriptenModule): FramesApi;
4
5
  //# sourceMappingURL=frames.d.ts.map
@@ -1,7 +1,10 @@
1
- import { brandMat3RowMajor } from "#backend-contract";
1
+ import { assertSpiceInt32NonNegative, brandMat3RowMajor } from "#backend-contract";
2
+ import { WASM_ERR_MAX_BYTES, withAllocs } from "../codec/alloc.js";
2
3
  import { tspiceCallFoundInt, tspiceCallFoundString } from "../codec/found.js";
3
4
  import { throwWasmSpiceError } from "../codec/errors.js";
4
- import { writeUtf8CString } from "../codec/strings.js";
5
+ import { readFixedWidthCString, writeUtf8CString } from "../codec/strings.js";
6
+ import { resolveKernelPath } from "../runtime/fs.js";
7
+ import { assertWasmOwnedCellHandle, assertWasmOwnedWindowHandle } from "./cells-windows.js";
5
8
  function tspiceCallCidfrm(module, fn, center) {
6
9
  const errMaxBytes = 2048;
7
10
  const errPtr = module._malloc(errMaxBytes);
@@ -31,7 +34,7 @@ function tspiceCallCidfrm(module, fn, center) {
31
34
  return {
32
35
  found: true,
33
36
  frcode: module.HEAP32[outCodePtr >> 2] ?? 0,
34
- frname: module.UTF8ToString(outNamePtr, outNameMaxBytes).trim(),
37
+ frname: readFixedWidthCString(module, outNamePtr, outNameMaxBytes),
35
38
  };
36
39
  }
37
40
  finally {
@@ -71,7 +74,7 @@ function tspiceCallCnmfrm(module, fn, centerName) {
71
74
  return {
72
75
  found: true,
73
76
  frcode: module.HEAP32[outCodePtr >> 2] ?? 0,
74
- frname: module.UTF8ToString(outNamePtr, outNameMaxBytes).trim(),
77
+ frname: readFixedWidthCString(module, outNamePtr, outNameMaxBytes),
75
78
  };
76
79
  }
77
80
  finally {
@@ -82,6 +85,51 @@ function tspiceCallCnmfrm(module, fn, centerName) {
82
85
  module._free(errPtr);
83
86
  }
84
87
  }
88
+ function tspiceCallFrinfo(module, frameId) {
89
+ return withAllocs(module, [WASM_ERR_MAX_BYTES, 4, 4, 4, 4], (errPtr, outCenterPtr, outFrameClassPtr, outClassIdPtr, foundPtr) => {
90
+ module.HEAP32[outCenterPtr >> 2] = 0;
91
+ module.HEAP32[outFrameClassPtr >> 2] = 0;
92
+ module.HEAP32[outClassIdPtr >> 2] = 0;
93
+ module.HEAP32[foundPtr >> 2] = 0;
94
+ const result = module._tspice_frinfo(frameId, outCenterPtr, outFrameClassPtr, outClassIdPtr, foundPtr, errPtr, WASM_ERR_MAX_BYTES);
95
+ if (result !== 0) {
96
+ throwWasmSpiceError(module, errPtr, WASM_ERR_MAX_BYTES, result);
97
+ }
98
+ const found = (module.HEAP32[foundPtr >> 2] ?? 0) !== 0;
99
+ if (!found) {
100
+ return { found: false };
101
+ }
102
+ return {
103
+ found: true,
104
+ center: module.HEAP32[outCenterPtr >> 2] ?? 0,
105
+ frameClass: module.HEAP32[outFrameClassPtr >> 2] ?? 0,
106
+ classId: module.HEAP32[outClassIdPtr >> 2] ?? 0,
107
+ };
108
+ });
109
+ }
110
+ function tspiceCallCcifrm(module, frameClass, classId) {
111
+ const outNameMaxBytes = 256;
112
+ return withAllocs(module, [WASM_ERR_MAX_BYTES, outNameMaxBytes, 4, 4, 4], (errPtr, outNamePtr, outFrcodePtr, outCenterPtr, foundPtr) => {
113
+ module.HEAPU8[outNamePtr] = 0;
114
+ module.HEAP32[outFrcodePtr >> 2] = 0;
115
+ module.HEAP32[outCenterPtr >> 2] = 0;
116
+ module.HEAP32[foundPtr >> 2] = 0;
117
+ const result = module._tspice_ccifrm(frameClass, classId, outFrcodePtr, outNamePtr, outNameMaxBytes, outCenterPtr, foundPtr, errPtr, WASM_ERR_MAX_BYTES);
118
+ if (result !== 0) {
119
+ throwWasmSpiceError(module, errPtr, WASM_ERR_MAX_BYTES, result);
120
+ }
121
+ const found = (module.HEAP32[foundPtr >> 2] ?? 0) !== 0;
122
+ if (!found) {
123
+ return { found: false };
124
+ }
125
+ return {
126
+ found: true,
127
+ frcode: module.HEAP32[outFrcodePtr >> 2] ?? 0,
128
+ frname: readFixedWidthCString(module, outNamePtr, outNameMaxBytes),
129
+ center: module.HEAP32[outCenterPtr >> 2] ?? 0,
130
+ };
131
+ });
132
+ }
85
133
  function tspiceCallCkgp(module, inst, sclkdp, tol, ref) {
86
134
  const errMaxBytes = 2048;
87
135
  const errPtr = module._malloc(errMaxBytes);
@@ -159,6 +207,77 @@ function tspiceCallCkgpav(module, inst, sclkdp, tol, ref) {
159
207
  module._free(errPtr);
160
208
  }
161
209
  }
210
+ // --- CK file query / management (read-only) --------------------------------
211
+ function tspiceCallCklpf(module, ck) {
212
+ return withAllocs(module, [WASM_ERR_MAX_BYTES, 4], (errPtr, outHandlePtr) => {
213
+ const ckPathPtr = writeUtf8CString(module, resolveKernelPath(ck));
214
+ if (!ckPathPtr) {
215
+ throw new Error("WASM malloc failed");
216
+ }
217
+ try {
218
+ module.HEAP32[outHandlePtr >> 2] = 0;
219
+ const code = module._tspice_cklpf(ckPathPtr, outHandlePtr, errPtr, WASM_ERR_MAX_BYTES);
220
+ if (code !== 0) {
221
+ throwWasmSpiceError(module, errPtr, WASM_ERR_MAX_BYTES, code);
222
+ }
223
+ return module.HEAP32[outHandlePtr >> 2] ?? 0;
224
+ }
225
+ finally {
226
+ module._free(ckPathPtr);
227
+ }
228
+ });
229
+ }
230
+ function tspiceCallCkupf(module, handle) {
231
+ assertSpiceInt32NonNegative(handle, "ckupf(handle)");
232
+ return withAllocs(module, [WASM_ERR_MAX_BYTES], (errPtr) => {
233
+ const code = module._tspice_ckupf(handle, errPtr, WASM_ERR_MAX_BYTES);
234
+ if (code !== 0) {
235
+ throwWasmSpiceError(module, errPtr, WASM_ERR_MAX_BYTES, code);
236
+ }
237
+ });
238
+ }
239
+ function tspiceCallCkobj(module, ck, ids) {
240
+ return withAllocs(module, [WASM_ERR_MAX_BYTES], (errPtr) => {
241
+ const ckPathPtr = writeUtf8CString(module, resolveKernelPath(ck));
242
+ if (!ckPathPtr) {
243
+ throw new Error("WASM malloc failed");
244
+ }
245
+ try {
246
+ const code = module._tspice_ckobj(ckPathPtr, ids, errPtr, WASM_ERR_MAX_BYTES);
247
+ if (code !== 0) {
248
+ throwWasmSpiceError(module, errPtr, WASM_ERR_MAX_BYTES, code);
249
+ }
250
+ }
251
+ finally {
252
+ module._free(ckPathPtr);
253
+ }
254
+ });
255
+ }
256
+ function tspiceCallCkcov(module, ck, idcode, needav, level, tol, timsys, cover) {
257
+ return withAllocs(module, [WASM_ERR_MAX_BYTES], (errPtr) => {
258
+ const ckPathPtr = writeUtf8CString(module, resolveKernelPath(ck));
259
+ const levelPtr = writeUtf8CString(module, level);
260
+ const timsysPtr = writeUtf8CString(module, timsys);
261
+ if (!ckPathPtr || !levelPtr || !timsysPtr) {
262
+ for (const ptr of [timsysPtr, levelPtr, ckPathPtr]) {
263
+ if (ptr)
264
+ module._free(ptr);
265
+ }
266
+ throw new Error("WASM malloc failed");
267
+ }
268
+ try {
269
+ const code = module._tspice_ckcov(ckPathPtr, idcode, needav ? 1 : 0, levelPtr, tol, timsysPtr, cover, errPtr, WASM_ERR_MAX_BYTES);
270
+ if (code !== 0) {
271
+ throwWasmSpiceError(module, errPtr, WASM_ERR_MAX_BYTES, code);
272
+ }
273
+ }
274
+ finally {
275
+ module._free(timsysPtr);
276
+ module._free(levelPtr);
277
+ module._free(ckPathPtr);
278
+ }
279
+ });
280
+ }
162
281
  function tspiceCallPxform(module, from, to, et) {
163
282
  const errMaxBytes = 2048;
164
283
  const errPtr = module._malloc(errMaxBytes);
@@ -215,6 +334,7 @@ function tspiceCallSxform(module, from, to, et) {
215
334
  module._free(errPtr);
216
335
  }
217
336
  }
337
+ /** Create a {@link FramesApi} implementation backed by a WASM Emscripten module. */
218
338
  export function createFramesApi(module) {
219
339
  return {
220
340
  namfrm: (name) => {
@@ -231,8 +351,20 @@ export function createFramesApi(module) {
231
351
  },
232
352
  cidfrm: (center) => tspiceCallCidfrm(module, module._tspice_cidfrm, center),
233
353
  cnmfrm: (centerName) => tspiceCallCnmfrm(module, module._tspice_cnmfrm, centerName),
354
+ frinfo: (frameId) => tspiceCallFrinfo(module, frameId),
355
+ ccifrm: (frameClass, classId) => tspiceCallCcifrm(module, frameClass, classId),
234
356
  ckgp: (inst, sclkdp, tol, ref) => tspiceCallCkgp(module, inst, sclkdp, tol, ref),
235
357
  ckgpav: (inst, sclkdp, tol, ref) => tspiceCallCkgpav(module, inst, sclkdp, tol, ref),
358
+ cklpf: (ck) => tspiceCallCklpf(module, ck),
359
+ ckupf: (handle) => tspiceCallCkupf(module, handle),
360
+ ckobj: (ck, ids) => {
361
+ assertWasmOwnedCellHandle(module, ids, "ckobj(ids)");
362
+ tspiceCallCkobj(module, ck, ids);
363
+ },
364
+ ckcov: (ck, idcode, needav, level, tol, timsys, cover) => {
365
+ assertWasmOwnedWindowHandle(module, cover, "ckcov(cover)");
366
+ tspiceCallCkcov(module, ck, idcode, needav, level, tol, timsys, cover);
367
+ },
236
368
  pxform: (from, to, et) => tspiceCallPxform(module, from, to, et),
237
369
  sxform: (from, to, et) => tspiceCallSxform(module, from, to, et),
238
370
  };
@@ -0,0 +1,5 @@
1
+ import type { GeometryGfApi } from "#backend-contract";
2
+ import type { EmscriptenModule } from "../lowlevel/exports.js";
3
+ /** Create a {@link GeometryGfApi} implementation backed by a WASM Emscripten module. */
4
+ export declare function createGeometryGfApi(module: EmscriptenModule): GeometryGfApi;
5
+ //# sourceMappingURL=geometry-gf.d.ts.map