@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.
Files changed (221) hide show
  1. package/README.md +145 -84
  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 +53 -3
  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 +44 -4
  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 +34 -15
  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 +52 -0
  33. package/backend-contract/dist/shared/mat3.js +150 -0
  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 +136 -5
  41. package/backend-contract/dist/shared/types.js +1 -1
  42. package/backend-contract/dist/shared/vec.d.ts +54 -0
  43. package/backend-contract/dist/shared/vec.js +162 -0
  44. package/backend-fake/dist/.tsbuildinfo +1 -1
  45. package/backend-fake/dist/index.d.ts +21 -1
  46. package/backend-fake/dist/index.js +1112 -33
  47. package/backend-node/dist/.tsbuildinfo +1 -1
  48. package/backend-node/dist/codec/arrays.d.ts +9 -0
  49. package/backend-node/dist/codec/arrays.js +36 -0
  50. package/backend-node/dist/codec/errors.d.ts +6 -6
  51. package/backend-node/dist/codec/errors.js +6 -6
  52. package/backend-node/dist/domains/cells-windows.d.ts +5 -0
  53. package/backend-node/dist/domains/cells-windows.js +112 -0
  54. package/backend-node/dist/domains/coords-vectors.d.ts +1 -0
  55. package/backend-node/dist/domains/coords-vectors.js +66 -0
  56. package/backend-node/dist/domains/dsk.d.ts +6 -0
  57. package/backend-node/dist/domains/dsk.js +108 -0
  58. package/backend-node/dist/domains/ek.d.ts +10 -0
  59. package/backend-node/dist/domains/ek.js +100 -0
  60. package/backend-node/dist/domains/ephemeris.d.ts +5 -1
  61. package/backend-node/dist/domains/ephemeris.js +150 -1
  62. package/backend-node/dist/domains/error.d.ts +5 -0
  63. package/backend-node/dist/domains/error.js +34 -0
  64. package/backend-node/dist/domains/file-io.d.ts +7 -0
  65. package/backend-node/dist/domains/file-io.js +105 -0
  66. package/backend-node/dist/domains/frames.d.ts +1 -0
  67. package/backend-node/dist/domains/frames.js +58 -6
  68. package/backend-node/dist/domains/geometry-gf.d.ts +5 -0
  69. package/backend-node/dist/domains/geometry-gf.js +74 -0
  70. package/backend-node/dist/domains/geometry.d.ts +1 -0
  71. package/backend-node/dist/domains/geometry.js +62 -0
  72. package/backend-node/dist/domains/ids-names.d.ts +2 -1
  73. package/backend-node/dist/domains/ids-names.js +30 -0
  74. package/backend-node/dist/domains/kernel-pool.d.ts +5 -0
  75. package/backend-node/dist/domains/kernel-pool.js +74 -0
  76. package/backend-node/dist/domains/kernels.d.ts +1 -0
  77. package/backend-node/dist/domains/kernels.js +100 -13
  78. package/backend-node/dist/domains/time.d.ts +1 -0
  79. package/backend-node/dist/domains/time.js +75 -1
  80. package/backend-node/dist/index.d.ts +5 -1
  81. package/backend-node/dist/index.js +62 -1
  82. package/backend-node/dist/lowlevel/binding.d.ts +3 -0
  83. package/backend-node/dist/lowlevel/binding.js +115 -0
  84. package/backend-node/dist/runtime/addon.d.ts +273 -2
  85. package/backend-node/dist/runtime/addon.js +3 -0
  86. package/backend-node/dist/runtime/kernel-staging.d.ts +17 -0
  87. package/backend-node/dist/runtime/kernel-staging.js +80 -7
  88. package/backend-node/dist/runtime/spice-handles.d.ts +3 -0
  89. package/backend-node/dist/runtime/spice-handles.js +2 -0
  90. package/backend-node/dist/runtime/virtual-output-staging.d.ts +16 -0
  91. package/backend-node/dist/runtime/virtual-output-staging.js +148 -0
  92. package/backend-wasm/dist/.tsbuildinfo +1 -1
  93. package/backend-wasm/dist/codec/alloc.d.ts +19 -0
  94. package/backend-wasm/dist/codec/alloc.js +64 -0
  95. package/backend-wasm/dist/codec/calls.d.ts +2 -0
  96. package/backend-wasm/dist/codec/calls.js +13 -24
  97. package/backend-wasm/dist/codec/errors.d.ts +6 -0
  98. package/backend-wasm/dist/codec/errors.js +34 -2
  99. package/backend-wasm/dist/codec/found.d.ts +2 -0
  100. package/backend-wasm/dist/codec/found.js +20 -43
  101. package/backend-wasm/dist/codec/strings.d.ts +31 -1
  102. package/backend-wasm/dist/codec/strings.js +93 -6
  103. package/backend-wasm/dist/domains/cells-windows.d.ts +9 -0
  104. package/backend-wasm/dist/domains/cells-windows.js +392 -0
  105. package/backend-wasm/dist/domains/coords-vectors.d.ts +1 -0
  106. package/backend-wasm/dist/domains/coords-vectors.js +377 -184
  107. package/backend-wasm/dist/domains/dsk.d.ts +6 -0
  108. package/backend-wasm/dist/domains/dsk.js +179 -0
  109. package/backend-wasm/dist/domains/ek.d.ts +6 -0
  110. package/backend-wasm/dist/domains/ek.js +543 -0
  111. package/backend-wasm/dist/domains/ephemeris.d.ts +4 -1
  112. package/backend-wasm/dist/domains/ephemeris.js +405 -46
  113. package/backend-wasm/dist/domains/error.d.ts +5 -0
  114. package/backend-wasm/dist/domains/error.js +109 -0
  115. package/backend-wasm/dist/domains/file-io.d.ts +7 -0
  116. package/backend-wasm/dist/domains/file-io.js +462 -0
  117. package/backend-wasm/dist/domains/frames.d.ts +1 -0
  118. package/backend-wasm/dist/domains/frames.js +139 -6
  119. package/backend-wasm/dist/domains/geometry-gf.d.ts +5 -0
  120. package/backend-wasm/dist/domains/geometry-gf.js +178 -0
  121. package/backend-wasm/dist/domains/geometry.d.ts +1 -0
  122. package/backend-wasm/dist/domains/geometry.js +210 -0
  123. package/backend-wasm/dist/domains/ids-names.d.ts +2 -1
  124. package/backend-wasm/dist/domains/ids-names.js +89 -0
  125. package/backend-wasm/dist/domains/kernel-pool.d.ts +5 -0
  126. package/backend-wasm/dist/domains/kernel-pool.js +357 -0
  127. package/backend-wasm/dist/domains/kernels.d.ts +1 -0
  128. package/backend-wasm/dist/domains/kernels.js +108 -4
  129. package/backend-wasm/dist/domains/time.d.ts +2 -0
  130. package/backend-wasm/dist/domains/time.js +235 -133
  131. package/backend-wasm/dist/index.d.ts +4 -2
  132. package/backend-wasm/dist/lowlevel/exports.d.ts +215 -1
  133. package/backend-wasm/dist/lowlevel/exports.js +217 -38
  134. package/backend-wasm/dist/runtime/create-backend-options.d.ts +21 -0
  135. package/backend-wasm/dist/runtime/create-backend.node.d.ts +11 -2
  136. package/backend-wasm/dist/runtime/create-backend.node.js +283 -14
  137. package/backend-wasm/dist/runtime/create-backend.web.d.ts +5 -2
  138. package/backend-wasm/dist/runtime/create-backend.web.js +40 -6
  139. package/backend-wasm/dist/runtime/fs.d.ts +6 -0
  140. package/backend-wasm/dist/runtime/fs.js +29 -3
  141. package/backend-wasm/dist/runtime/spice-handles.d.ts +3 -0
  142. package/backend-wasm/dist/runtime/spice-handles.js +2 -0
  143. package/backend-wasm/dist/runtime/virtual-outputs.d.ts +16 -0
  144. package/backend-wasm/dist/runtime/virtual-outputs.js +35 -0
  145. package/backend-wasm/dist/tspice_backend_wasm.node.js +3 -3
  146. package/backend-wasm/dist/tspice_backend_wasm.wasm +0 -0
  147. package/backend-wasm/dist/tspice_backend_wasm.web.js +1 -1
  148. package/core/dist/.tsbuildinfo +1 -1
  149. package/core/dist/index.d.ts +21 -0
  150. package/core/dist/index.js +57 -0
  151. package/dist/.tsbuildinfo +1 -1
  152. package/dist/backend.d.ts +15 -6
  153. package/dist/backend.js +3 -6
  154. package/dist/clients/createSpiceAsyncFromTransport.d.ts +5 -0
  155. package/dist/clients/createSpiceAsyncFromTransport.js +90 -0
  156. package/dist/clients/createSpiceSyncFromTransport.d.ts +5 -0
  157. package/dist/clients/createSpiceSyncFromTransport.js +88 -0
  158. package/dist/clients/spiceClients.d.ts +59 -0
  159. package/dist/clients/spiceClients.js +292 -0
  160. package/dist/errors.d.ts +4 -0
  161. package/dist/errors.js +4 -0
  162. package/dist/index.d.ts +12 -7
  163. package/dist/index.js +5 -2
  164. package/dist/kernels/defaultKernelPathFromUrl.d.ts +8 -0
  165. package/dist/kernels/defaultKernelPathFromUrl.js +32 -0
  166. package/dist/kernels/kernelPack.d.ts +88 -0
  167. package/dist/kernels/kernelPack.js +122 -0
  168. package/dist/kernels/kernels.d.ts +98 -0
  169. package/dist/kernels/kernels.js +217 -0
  170. package/dist/kernels/naifKernelId.d.ts +2 -0
  171. package/dist/kernels/naifKernelId.js +2 -0
  172. package/dist/kit/index.d.ts +4 -0
  173. package/dist/kit/index.js +3 -0
  174. package/dist/kit/math/mat3.d.ts +31 -0
  175. package/dist/kit/math/mat3.js +82 -0
  176. package/dist/kit/spice/create-kit.d.ts +12 -0
  177. package/dist/kit/spice/create-kit.js +23 -0
  178. package/dist/kit/spice/frames.d.ts +8 -0
  179. package/dist/kit/spice/frames.js +16 -0
  180. package/dist/kit/spice/kernels.d.ts +14 -0
  181. package/dist/kit/spice/kernels.js +39 -0
  182. package/dist/kit/spice/state.d.ts +7 -0
  183. package/dist/kit/spice/state.js +36 -0
  184. package/dist/kit/spice/time.d.ts +9 -0
  185. package/dist/kit/spice/time.js +31 -0
  186. package/dist/kit/types/spice-types.d.ts +51 -0
  187. package/dist/spice.d.ts +10 -1
  188. package/dist/spice.js +84 -72
  189. package/dist/transport/caching/policy.d.ts +16 -0
  190. package/dist/transport/caching/policy.js +77 -0
  191. package/dist/transport/caching/withCaching.d.ts +125 -0
  192. package/dist/transport/caching/withCaching.js +335 -0
  193. package/dist/transport/caching/withCachingSync.d.ts +24 -0
  194. package/dist/transport/caching/withCachingSync.js +161 -0
  195. package/dist/transport/rpc/protocol.d.ts +35 -0
  196. package/dist/transport/rpc/protocol.js +56 -0
  197. package/dist/transport/rpc/taskScheduling.d.ts +20 -0
  198. package/dist/transport/rpc/taskScheduling.js +98 -0
  199. package/dist/transport/rpc/valueCodec.d.ts +5 -0
  200. package/dist/transport/rpc/valueCodec.js +106 -0
  201. package/dist/transport/types.d.ts +7 -0
  202. package/dist/transport/types.js +2 -0
  203. package/dist/types.d.ts +8 -17
  204. package/dist/types.js +2 -1
  205. package/dist/worker/browser/createSpiceWorker.d.ts +22 -0
  206. package/dist/worker/browser/createSpiceWorker.js +41 -0
  207. package/dist/worker/browser/createSpiceWorkerClient.d.ts +40 -0
  208. package/dist/worker/browser/createSpiceWorkerClient.js +99 -0
  209. package/dist/worker/browser/spiceWorkerEntry.d.ts +2 -0
  210. package/dist/worker/browser/spiceWorkerEntry.js +129 -0
  211. package/dist/worker/browser/spiceWorkerInlineSource.d.ts +2 -0
  212. package/dist/worker/browser/spiceWorkerInlineSource.js +4 -0
  213. package/dist/worker/index.d.ts +10 -0
  214. package/dist/worker/index.js +7 -0
  215. package/dist/worker/transport/createWorkerTransport.d.ts +69 -0
  216. package/dist/worker/transport/createWorkerTransport.js +398 -0
  217. package/dist/worker/transport/exposeTransportToWorker.d.ts +51 -0
  218. package/dist/worker/transport/exposeTransportToWorker.js +196 -0
  219. package/package.json +4 -4
  220. package/dist/spice-types.d.ts +0 -36
  221. /package/dist/{spice-types.js → kit/types/spice-types.js} +0 -0
@@ -1,5 +1,8 @@
1
1
  import { invariant } from "#core";
2
2
  import { getNativeAddon } from "../runtime/addon.js";
3
+ /**
4
+ * Get the loaded native addon binding and assert it provides the expected entrypoints.
5
+ */
3
6
  export function getNodeBinding() {
4
7
  const native = getNativeAddon();
5
8
  invariant(typeof native.furnsh === "function", "Expected native addon to export furnsh(path)");
@@ -7,9 +10,69 @@ export function getNodeBinding() {
7
10
  invariant(typeof native.kclear === "function", "Expected native addon to export kclear()");
8
11
  invariant(typeof native.ktotal === "function", "Expected native addon to export ktotal(kind?)");
9
12
  invariant(typeof native.kdata === "function", "Expected native addon to export kdata(which, kind?)");
13
+ invariant(typeof native.gdpool === "function", "Expected native addon to export gdpool(name, start, room)");
14
+ invariant(typeof native.gipool === "function", "Expected native addon to export gipool(name, start, room)");
15
+ invariant(typeof native.gcpool === "function", "Expected native addon to export gcpool(name, start, room)");
16
+ invariant(typeof native.gnpool === "function", "Expected native addon to export gnpool(template, start, room)");
17
+ invariant(typeof native.dtpool === "function", "Expected native addon to export dtpool(name)");
18
+ invariant(typeof native.pdpool === "function", "Expected native addon to export pdpool(name, values)");
19
+ invariant(typeof native.pipool === "function", "Expected native addon to export pipool(name, values)");
20
+ invariant(typeof native.pcpool === "function", "Expected native addon to export pcpool(name, values)");
21
+ invariant(typeof native.swpool === "function", "Expected native addon to export swpool(agent, names)");
22
+ invariant(typeof native.cvpool === "function", "Expected native addon to export cvpool(agent)");
23
+ invariant(typeof native.expool === "function", "Expected native addon to export expool(name)");
10
24
  invariant(typeof native.str2et === "function", "Expected native addon to export str2et(time)");
11
25
  invariant(typeof native.et2utc === "function", "Expected native addon to export et2utc(et, format, prec)");
12
26
  invariant(typeof native.timout === "function", "Expected native addon to export timout(et, picture)");
27
+ invariant(typeof native.deltet === "function", "Expected native addon to export deltet(epoch, eptype)");
28
+ invariant(typeof native.unitim === "function", "Expected native addon to export unitim(epoch, insys, outsys)");
29
+ invariant(typeof native.tparse === "function", "Expected native addon to export tparse(timstr)");
30
+ invariant(typeof native.tpictr === "function", "Expected native addon to export tpictr(sample, pictur)");
31
+ invariant(typeof native.timdefGet === "function", "Expected native addon to export timdefGet(item)");
32
+ invariant(typeof native.timdefSet === "function", "Expected native addon to export timdefSet(item, value)");
33
+ invariant(typeof native.failed === "function", "Expected native addon to export failed()");
34
+ invariant(typeof native.reset === "function", "Expected native addon to export reset()");
35
+ invariant(typeof native.getmsg === "function", "Expected native addon to export getmsg(which)");
36
+ invariant(typeof native.setmsg === "function", "Expected native addon to export setmsg(message)");
37
+ invariant(typeof native.sigerr === "function", "Expected native addon to export sigerr(short)");
38
+ invariant(typeof native.chkin === "function", "Expected native addon to export chkin(name)");
39
+ invariant(typeof native.chkout === "function", "Expected native addon to export chkout(name)");
40
+ invariant(typeof native.exists === "function", "Expected native addon to export exists(path)");
41
+ invariant(typeof native.getfat === "function", "Expected native addon to export getfat(path)");
42
+ invariant(typeof native.dafopr === "function", "Expected native addon to export dafopr(path)");
43
+ invariant(typeof native.dafcls === "function", "Expected native addon to export dafcls(handle)");
44
+ invariant(typeof native.dafbfs === "function", "Expected native addon to export dafbfs(handle)");
45
+ invariant(typeof native.daffna === "function", "Expected native addon to export daffna(handle)");
46
+ invariant(typeof native.dasopr === "function", "Expected native addon to export dasopr(path)");
47
+ invariant(typeof native.dascls === "function", "Expected native addon to export dascls(handle)");
48
+ invariant(typeof native.dlaopn === "function", "Expected native addon to export dlaopn(path, ftype, ifname, ncomch)");
49
+ invariant(typeof native.dlabfs === "function", "Expected native addon to export dlabfs(handle)");
50
+ invariant(typeof native.dlafns === "function", "Expected native addon to export dlafns(handle, descr)");
51
+ // --- EK ---
52
+ invariant(typeof native.ekopr === "function", "Expected native addon to export ekopr(path)");
53
+ invariant(typeof native.ekopw === "function", "Expected native addon to export ekopw(path)");
54
+ invariant(typeof native.ekopn === "function", "Expected native addon to export ekopn(path, ifname, ncomch)");
55
+ invariant(typeof native.ekcls === "function", "Expected native addon to export ekcls(handle)");
56
+ invariant(typeof native.ekntab === "function", "Expected native addon to export ekntab()");
57
+ invariant(typeof native.ektnam === "function", "Expected native addon to export ektnam(n)");
58
+ invariant(typeof native.eknseg === "function", "Expected native addon to export eknseg(handle)");
59
+ invariant(typeof native.ekfind === "function", "Expected native addon to export ekfind(query)");
60
+ invariant(typeof native.ekgc === "function", "Expected native addon to export ekgc(selidx, row, elment)");
61
+ invariant(typeof native.ekgd === "function", "Expected native addon to export ekgd(selidx, row, elment)");
62
+ invariant(typeof native.ekgi === "function", "Expected native addon to export ekgi(selidx, row, elment)");
63
+ invariant(typeof native.ekifld === "function", "Expected native addon to export ekifld(handle, tabnam, nrows, cnames, decls)");
64
+ invariant(typeof native.ekacli === "function", "Expected native addon to export ekacli(handle, segno, column, ivals, entszs, nlflgs, rcptrs)");
65
+ invariant(typeof native.ekacld === "function", "Expected native addon to export ekacld(handle, segno, column, dvals, entszs, nlflgs, rcptrs)");
66
+ invariant(typeof native.ekaclc === "function", "Expected native addon to export ekaclc(handle, segno, column, cvals, entszs, nlflgs, rcptrs)");
67
+ invariant(typeof native.ekffld === "function", "Expected native addon to export ekffld(handle, segno, rcptrs)");
68
+ // --- DSK writer ---
69
+ invariant(typeof native.dskopn === "function", "Expected native addon to export dskopn(path, ifname, ncomch)");
70
+ invariant(typeof native.dskmi2 === "function", "Expected native addon to export dskmi2(nv, vrtces, np, plates, finscl, corscl, worksz, voxpsz, voxlsz, makvtl, spxisz)");
71
+ invariant(typeof native.dskw02 === "function", "Expected native addon to export dskw02(handle, center, surfid, dclass, frame, corsys, corpar, mncor1, mxcor1, mncor2, mxcor2, mncor3, mxcor3, first, last, nv, vrtces, np, plates, spaixd, spaixi)");
72
+ invariant(typeof native.dskobj === "function", "Expected native addon to export dskobj(dsk, bodids)");
73
+ invariant(typeof native.dsksrf === "function", "Expected native addon to export dsksrf(dsk, bodyid, srfids)");
74
+ invariant(typeof native.dskgd === "function", "Expected native addon to export dskgd(handle, dladsc)");
75
+ invariant(typeof native.dskb02 === "function", "Expected native addon to export dskb02(handle, dladsc)");
13
76
  invariant(typeof native.bodn2c === "function", "Expected native addon to export bodn2c(name)");
14
77
  invariant(typeof native.bodc2n === "function", "Expected native addon to export bodc2n(code)");
15
78
  invariant(typeof native.namfrm === "function", "Expected native addon to export namfrm(name)");
@@ -18,6 +81,10 @@ export function getNodeBinding() {
18
81
  invariant(typeof native.cnmfrm === "function", "Expected native addon to export cnmfrm(centerName)");
19
82
  invariant(typeof native.scs2e === "function", "Expected native addon to export scs2e(sc, sclkch)");
20
83
  invariant(typeof native.sce2s === "function", "Expected native addon to export sce2s(sc, et)");
84
+ invariant(typeof native.scencd === "function", "Expected native addon to export scencd(sc, sclkch)");
85
+ invariant(typeof native.scdecd === "function", "Expected native addon to export scdecd(sc, sclkdp)");
86
+ invariant(typeof native.sct2e === "function", "Expected native addon to export sct2e(sc, sclkdp)");
87
+ invariant(typeof native.sce2c === "function", "Expected native addon to export sce2c(sc, et)");
21
88
  invariant(typeof native.ckgp === "function", "Expected native addon to export ckgp(inst, sclkdp, tol, ref)");
22
89
  invariant(typeof native.ckgpav === "function", "Expected native addon to export ckgpav(inst, sclkdp, tol, ref)");
23
90
  invariant(typeof native.pxform === "function", "Expected native addon to export pxform(from, to, et)");
@@ -32,13 +99,61 @@ export function getNodeBinding() {
32
99
  invariant(typeof native.vcrss === "function", "Expected native addon to export vcrss(a, b)");
33
100
  invariant(typeof native.mxv === "function", "Expected native addon to export mxv(m, v)");
34
101
  invariant(typeof native.mtxv === "function", "Expected native addon to export mtxv(m, v)");
102
+ invariant(typeof native.vadd === "function", "Expected native addon to export vadd(a, b)");
103
+ invariant(typeof native.vsub === "function", "Expected native addon to export vsub(a, b)");
104
+ invariant(typeof native.vminus === "function", "Expected native addon to export vminus(v)");
105
+ invariant(typeof native.vscl === "function", "Expected native addon to export vscl(s, v)");
106
+ invariant(typeof native.mxm === "function", "Expected native addon to export mxm(a, b)");
107
+ invariant(typeof native.rotate === "function", "Expected native addon to export rotate(angle, axis)");
108
+ invariant(typeof native.rotmat === "function", "Expected native addon to export rotmat(m, angle, axis)");
109
+ invariant(typeof native.axisar === "function", "Expected native addon to export axisar(axis, angle)");
110
+ invariant(typeof native.georec === "function", "Expected native addon to export georec(lon, lat, alt, re, f)");
111
+ invariant(typeof native.recgeo === "function", "Expected native addon to export recgeo(rect, re, f)");
112
+ invariant(typeof native.newIntCell === "function", "Expected native addon to export newIntCell(size)");
113
+ invariant(typeof native.newDoubleCell === "function", "Expected native addon to export newDoubleCell(size)");
114
+ invariant(typeof native.newCharCell === "function", "Expected native addon to export newCharCell(size, length)");
115
+ invariant(typeof native.newWindow === "function", "Expected native addon to export newWindow(maxIntervals)");
116
+ invariant(typeof native.freeCell === "function", "Expected native addon to export freeCell(cell)");
117
+ invariant(typeof native.freeWindow === "function", "Expected native addon to export freeWindow(window)");
118
+ invariant(typeof native.ssize === "function", "Expected native addon to export ssize(size, cell)");
119
+ invariant(typeof native.scard === "function", "Expected native addon to export scard(card, cell)");
120
+ invariant(typeof native.card === "function", "Expected native addon to export card(cell)");
121
+ invariant(typeof native.size === "function", "Expected native addon to export size(cell)");
122
+ invariant(typeof native.valid === "function", "Expected native addon to export valid(size, n, cell)");
123
+ invariant(typeof native.insrti === "function", "Expected native addon to export insrti(item, cell)");
124
+ invariant(typeof native.insrtd === "function", "Expected native addon to export insrtd(item, cell)");
125
+ invariant(typeof native.insrtc === "function", "Expected native addon to export insrtc(item, cell)");
126
+ invariant(typeof native.cellGeti === "function", "Expected native addon to export cellGeti(cell, index)");
127
+ invariant(typeof native.cellGetd === "function", "Expected native addon to export cellGetd(cell, index)");
128
+ invariant(typeof native.cellGetc === "function", "Expected native addon to export cellGetc(cell, index)");
129
+ invariant(typeof native.wninsd === "function", "Expected native addon to export wninsd(left, right, window)");
130
+ invariant(typeof native.wncard === "function", "Expected native addon to export wncard(window)");
131
+ invariant(typeof native.wnfetd === "function", "Expected native addon to export wnfetd(window, index)");
132
+ invariant(typeof native.wnvald === "function", "Expected native addon to export wnvald(size, n, window)");
35
133
  invariant(typeof native.spkezr === "function", "Expected native addon to export spkezr(target, et, ref, abcorr, observer)");
36
134
  invariant(typeof native.spkpos === "function", "Expected native addon to export spkpos(target, et, ref, abcorr, observer)");
135
+ invariant(typeof native.spkopn === "function", "Expected native addon to export spkopn(path, ifname, ncomch)");
136
+ invariant(typeof native.spkopa === "function", "Expected native addon to export spkopa(path)");
137
+ invariant(typeof native.spkw08 === "function", "Expected native addon to export spkw08(handle, body, center, frame, first, last, segid, degree, states, epoch1, step)");
138
+ invariant(typeof native.spkcls === "function", "Expected native addon to export spkcls(handle)");
37
139
  invariant(typeof native.subpnt === "function", "Expected native addon to export subpnt(method, target, et, fixref, abcorr, observer)");
38
140
  invariant(typeof native.subslr === "function", "Expected native addon to export subslr(method, target, et, fixref, abcorr, observer)");
141
+ invariant(typeof native.illumg === "function", "Expected native addon to export illumg(method, target, ilusrc, et, fixref, abcorr, observer, spoint)");
142
+ invariant(typeof native.illumf === "function", "Expected native addon to export illumf(method, target, ilusrc, et, fixref, abcorr, observer, spoint)");
143
+ invariant(typeof native.nvc2pl === "function", "Expected native addon to export nvc2pl(normal, konst)");
144
+ invariant(typeof native.pl2nvc === "function", "Expected native addon to export pl2nvc(plane)");
39
145
  invariant(typeof native.sincpt === "function", "Expected native addon to export sincpt(method, target, et, fixref, abcorr, observer, dref, dvec)");
40
146
  invariant(typeof native.ilumin === "function", "Expected native addon to export ilumin(method, target, et, fixref, abcorr, observer, spoint)");
41
147
  invariant(typeof native.occult === "function", "Expected native addon to export occult(targ1, shape1, frame1, targ2, shape2, frame2, abcorr, observer, et)");
148
+ // --- GF (Geometry Finder) ---
149
+ invariant(typeof native.gfsstp === "function", "Expected native addon to export gfsstp(step)");
150
+ invariant(typeof native.gfstep === "function", "Expected native addon to export gfstep(time)");
151
+ invariant(typeof native.gfstol === "function", "Expected native addon to export gfstol(value)");
152
+ invariant(typeof native.gfrefn === "function", "Expected native addon to export gfrefn(t1, t2, s1, s2)");
153
+ invariant(typeof native.gfrepi === "function", "Expected native addon to export gfrepi(window, begmss, endmss)");
154
+ invariant(typeof native.gfrepf === "function", "Expected native addon to export gfrepf()");
155
+ invariant(typeof native.gfsep === "function", "Expected native addon to export gfsep(targ1, shape1, frame1, targ2, shape2, frame2, abcorr, obsrvr, relate, refval, adjust, step, nintvls, cnfine, result)");
156
+ invariant(typeof native.gfdist === "function", "Expected native addon to export gfdist(target, abcorr, obsrvr, relate, refval, adjust, step, nintvls, cnfine, result)");
42
157
  return native;
43
158
  }
44
159
  //# sourceMappingURL=binding.js.map
@@ -1,5 +1,13 @@
1
+ import type { SpiceIntCell, SpiceWindow } from "#backend-contract";
1
2
  export type NativeAddon = {
2
3
  spiceVersion(): string;
4
+ failed(): boolean;
5
+ reset(): void;
6
+ getmsg(which: "SHORT" | "LONG" | "EXPLAIN"): string;
7
+ setmsg(message: string): void;
8
+ sigerr(short: string): void;
9
+ chkin(name: string): void;
10
+ chkout(name: string): void;
3
11
  furnsh(path: string): void;
4
12
  unload(path: string): void;
5
13
  kclear(): void;
@@ -11,9 +19,137 @@ export type NativeAddon = {
11
19
  source?: string;
12
20
  handle?: number;
13
21
  };
22
+ kinfo(path: string): {
23
+ found: boolean;
24
+ filtyp?: string;
25
+ source?: string;
26
+ handle?: number;
27
+ };
28
+ kxtrct(keywd: string, terms: readonly string[], wordsq: string): {
29
+ found: boolean;
30
+ wordsq?: string;
31
+ substr?: string;
32
+ };
33
+ kplfrm(frmcls: number, idset: number): void;
34
+ gdpool(name: string, start: number, room: number): {
35
+ found: boolean;
36
+ values?: number[];
37
+ };
38
+ gipool(name: string, start: number, room: number): {
39
+ found: boolean;
40
+ values?: number[];
41
+ };
42
+ gcpool(name: string, start: number, room: number): {
43
+ found: boolean;
44
+ values?: string[];
45
+ };
46
+ gnpool(template: string, start: number, room: number): {
47
+ found: boolean;
48
+ values?: string[];
49
+ };
50
+ dtpool(name: string): {
51
+ found: boolean;
52
+ n?: number;
53
+ type?: string;
54
+ };
55
+ pdpool(name: string, values: readonly number[]): void;
56
+ pipool(name: string, values: readonly number[]): void;
57
+ pcpool(name: string, values: readonly string[]): void;
58
+ swpool(agent: string, names: readonly string[]): void;
59
+ cvpool(agent: string): boolean;
60
+ expool(name: string): boolean;
14
61
  str2et(utc: string): number;
15
62
  et2utc(et: number, format: string, prec: number): string;
16
63
  timout(et: number, picture: string): string;
64
+ deltet(epoch: number, eptype: string): number;
65
+ unitim(epoch: number, insys: string, outsys: string): number;
66
+ tparse(timstr: string): number;
67
+ tpictr(sample: string, pictur: string): string;
68
+ timdefGet(item: string): string;
69
+ timdefSet(item: string, value: string): void;
70
+ exists(path: string): boolean;
71
+ getfat(path: string): {
72
+ arch: string;
73
+ type: string;
74
+ };
75
+ dafopr(path: string): number;
76
+ dafcls(handle: number): void;
77
+ dafbfs(handle: number): void;
78
+ daffna(handle: number): boolean;
79
+ dasopr(path: string): number;
80
+ dascls(handle: number): void;
81
+ dlaopn(path: string, ftype: string, ifname: string, ncomch: number): number;
82
+ dlabfs(handle: number): {
83
+ found: boolean;
84
+ descr?: Record<string, unknown>;
85
+ };
86
+ dlafns(handle: number, descr: Record<string, unknown>): {
87
+ found: boolean;
88
+ descr?: Record<string, unknown>;
89
+ };
90
+ dlacls(handle: number): void;
91
+ ekopr(path: string): number;
92
+ ekopw(path: string): number;
93
+ ekopn(path: string, ifname: string, ncomch: number): number;
94
+ ekcls(handle: number): void;
95
+ ekntab(): number;
96
+ ektnam(n: number): string;
97
+ eknseg(handle: number): number;
98
+ ekfind(query: string): {
99
+ ok: true;
100
+ nmrows: number;
101
+ } | {
102
+ ok: false;
103
+ errmsg: string;
104
+ };
105
+ ekgc(selidx: number, row: number, elment: number): {
106
+ found: false;
107
+ } | {
108
+ found: true;
109
+ isNull: true;
110
+ } | {
111
+ found: true;
112
+ isNull: false;
113
+ value: string;
114
+ };
115
+ ekgd(selidx: number, row: number, elment: number): {
116
+ found: false;
117
+ } | {
118
+ found: true;
119
+ isNull: true;
120
+ } | {
121
+ found: true;
122
+ isNull: false;
123
+ value: number;
124
+ };
125
+ ekgi(selidx: number, row: number, elment: number): {
126
+ found: false;
127
+ } | {
128
+ found: true;
129
+ isNull: true;
130
+ } | {
131
+ found: true;
132
+ isNull: false;
133
+ value: number;
134
+ };
135
+ ekifld(handle: number, tabnam: string, nrows: number, cnames: readonly string[], decls: readonly string[]): {
136
+ segno: number;
137
+ rcptrs: number[];
138
+ };
139
+ ekacli(handle: number, segno: number, column: string, ivals: readonly number[], entszs: readonly number[], nlflgs: readonly boolean[], rcptrs: readonly number[]): void;
140
+ ekacld(handle: number, segno: number, column: string, dvals: readonly number[], entszs: readonly number[], nlflgs: readonly boolean[], rcptrs: readonly number[]): void;
141
+ ekaclc(handle: number, segno: number, column: string, cvals: readonly string[], entszs: readonly number[], nlflgs: readonly boolean[], rcptrs: readonly number[]): void;
142
+ ekffld(handle: number, segno: number, rcptrs: readonly number[]): void;
143
+ dskopn(path: string, ifname: string, ncomch: number): number;
144
+ dskmi2(nv: number, vrtces: readonly number[], np: number, plates: readonly number[], finscl: number, corscl: number, worksz: number, voxpsz: number, voxlsz: number, makvtl: boolean, spxisz: number): {
145
+ spaixd: number[];
146
+ spaixi: number[];
147
+ };
148
+ dskw02(handle: number, center: number, surfid: number, dclass: number, frame: string, corsys: number, corpar: readonly number[], mncor1: number, mxcor1: number, mncor2: number, mxcor2: number, mncor3: number, mxcor3: number, first: number, last: number, nv: number, vrtces: readonly number[], np: number, plates: readonly number[], spaixd: readonly number[], spaixi: readonly number[]): void;
149
+ dskobj(dsk: string, bodidsCellHandle: number): void;
150
+ dsksrf(dsk: string, bodyid: number, srfidsCellHandle: number): void;
151
+ dskgd(handle: number, dladsc: Record<string, unknown>): Record<string, unknown>;
152
+ dskb02(handle: number, dladsc: Record<string, unknown>): Record<string, unknown>;
17
153
  bodn2c(name: string): {
18
154
  found: boolean;
19
155
  code?: number;
@@ -22,6 +158,14 @@ export type NativeAddon = {
22
158
  found: boolean;
23
159
  name?: string;
24
160
  };
161
+ bodc2s(code: number): string;
162
+ bods2c(name: string): {
163
+ found: boolean;
164
+ code?: number;
165
+ };
166
+ boddef(name: string, code: number): void;
167
+ bodfnd(body: number, item: string): boolean;
168
+ bodvar(body: number, item: string): number[];
25
169
  namfrm(name: string): {
26
170
  found: boolean;
27
171
  code?: number;
@@ -40,8 +184,24 @@ export type NativeAddon = {
40
184
  frcode?: number;
41
185
  frname?: string;
42
186
  };
187
+ frinfo(frameId: number): {
188
+ found: boolean;
189
+ center?: number;
190
+ frameClass?: number;
191
+ classId?: number;
192
+ };
193
+ ccifrm(frameClass: number, classId: number): {
194
+ found: boolean;
195
+ frcode?: number;
196
+ frname?: string;
197
+ center?: number;
198
+ };
43
199
  scs2e(sc: number, sclkch: string): number;
44
200
  sce2s(sc: number, et: number): string;
201
+ scencd(sc: number, sclkch: string): number;
202
+ scdecd(sc: number, sclkdp: number): string;
203
+ sct2e(sc: number, sclkdp: number): number;
204
+ sce2c(sc: number, et: number): number;
45
205
  ckgp(inst: number, sclkdp: number, tol: number, ref: string): {
46
206
  found: boolean;
47
207
  cmat?: number[];
@@ -53,6 +213,10 @@ export type NativeAddon = {
53
213
  av?: number[];
54
214
  clkout?: number;
55
215
  };
216
+ cklpf(ck: string): number;
217
+ ckupf(handle: number): void;
218
+ ckobj(ck: string, idsCellHandle: number): void;
219
+ ckcov(ck: string, idcode: number, needav: boolean, level: string, tol: number, timsys: string, coverWindowHandle: number): void;
56
220
  spkezr(target: string, et: number, ref: string, abcorr: string, obs: string): {
57
221
  state: number[];
58
222
  lt: number;
@@ -61,6 +225,67 @@ export type NativeAddon = {
61
225
  pos: number[];
62
226
  lt: number;
63
227
  };
228
+ spkez(target: number, et: number, ref: string, abcorr: string, obs: number): {
229
+ state: number[];
230
+ lt: number;
231
+ };
232
+ spkezp(target: number, et: number, ref: string, abcorr: string, obs: number): {
233
+ pos: number[];
234
+ lt: number;
235
+ };
236
+ spkgeo(target: number, et: number, ref: string, obs: number): {
237
+ state: number[];
238
+ lt: number;
239
+ };
240
+ spkgps(target: number, et: number, ref: string, obs: number): {
241
+ pos: number[];
242
+ lt: number;
243
+ };
244
+ illumg(method: string, target: string, ilusrc: string, et: number, fixref: string, abcorr: string, observer: string, spoint: number[]): {
245
+ trgepc: number;
246
+ srfvec: number[];
247
+ phase: number;
248
+ incdnc: number;
249
+ emissn: number;
250
+ };
251
+ illumf(method: string, target: string, ilusrc: string, et: number, fixref: string, abcorr: string, observer: string, spoint: number[]): {
252
+ trgepc: number;
253
+ srfvec: number[];
254
+ phase: number;
255
+ incdnc: number;
256
+ emissn: number;
257
+ visibl: boolean;
258
+ lit: boolean;
259
+ };
260
+ spkssb(target: number, et: number, ref: string): number[];
261
+ spkcov(spk: string, idcode: number, cover: SpiceWindow): void;
262
+ nvc2pl(normal: number[], konst: number): number[];
263
+ pl2nvc(plane: number[]): {
264
+ normal: number[];
265
+ konst: number;
266
+ };
267
+ spkobj(spk: string, ids: SpiceIntCell): void;
268
+ spksfs(body: number, et: number): {
269
+ found: boolean;
270
+ handle?: number;
271
+ descr?: number[];
272
+ ident?: string;
273
+ };
274
+ spkpds(body: number, center: number, frame: string, type: number, first: number, last: number): number[];
275
+ spkuds(descr: ReadonlyArray<number>): {
276
+ body: number;
277
+ center: number;
278
+ frame: number;
279
+ type: number;
280
+ first: number;
281
+ last: number;
282
+ baddr: number;
283
+ eaddr: number;
284
+ };
285
+ spkopn(path: string, ifname: string, ncomch: number): number;
286
+ spkopa(path: string): number;
287
+ spkcls(handle: number): void;
288
+ spkw08(handle: number, body: number, center: number, frame: string, first: number, last: number, segid: string, degree: number, states: readonly number[] | Float64Array, epoch1: number, step: number): void;
64
289
  subpnt(method: string, target: string, et: number, fixref: string, abcorr: string, observer: string): {
65
290
  spoint: number[];
66
291
  trgepc: number;
@@ -85,6 +310,14 @@ export type NativeAddon = {
85
310
  emissn: number;
86
311
  };
87
312
  occult(targ1: string, shape1: string, frame1: string, targ2: string, shape2: string, frame2: string, abcorr: string, observer: string, et: number): number;
313
+ gfsstp(step: number): void;
314
+ gfstep(time: number): number;
315
+ gfstol(value: number): void;
316
+ gfrefn(t1: number, t2: number, s1: boolean, s2: boolean): number;
317
+ gfrepi(window: SpiceWindow, begmss: string, endmss: string): void;
318
+ gfrepf(): void;
319
+ gfsep(targ1: string, shape1: string, frame1: string, targ2: string, shape2: string, frame2: string, abcorr: string, obsrvr: string, relate: string, refval: number, adjust: number, step: number, nintvls: number, cnfine: SpiceWindow, result: SpiceWindow): void;
320
+ gfdist(target: string, abcorr: string, obsrvr: string, relate: string, refval: number, adjust: number, step: number, nintvls: number, cnfine: SpiceWindow, result: SpiceWindow): void;
88
321
  pxform(from: string, to: string, et: number): number[];
89
322
  sxform(from: string, to: string, et: number): number[];
90
323
  reclat(rect: number[]): {
@@ -103,10 +336,48 @@ export type NativeAddon = {
103
336
  vhat(v: number[]): number[];
104
337
  vdot(a: number[], b: number[]): number;
105
338
  vcrss(a: number[], b: number[]): number[];
106
- mxv(m: number[], v: number[]): number[];
107
- mtxv(m: number[], v: number[]): number[];
339
+ mxv(m: readonly number[], v: readonly number[]): number[];
340
+ mtxv(m: readonly number[], v: readonly number[]): number[];
341
+ vadd(a: readonly number[], b: readonly number[]): number[];
342
+ vsub(a: readonly number[], b: readonly number[]): number[];
343
+ vminus(v: readonly number[]): number[];
344
+ vscl(s: number, v: readonly number[]): number[];
345
+ mxm(a: readonly number[], b: readonly number[]): number[];
346
+ rotate(angle: number, axis: number): number[];
347
+ rotmat(m: readonly number[], angle: number, axis: number): number[];
348
+ axisar(axis: readonly number[], angle: number): number[];
349
+ georec(lon: number, lat: number, alt: number, re: number, f: number): number[];
350
+ recgeo(rect: readonly number[], re: number, f: number): {
351
+ lon: number;
352
+ lat: number;
353
+ alt: number;
354
+ };
355
+ newIntCell(size: number): number;
356
+ newDoubleCell(size: number): number;
357
+ newCharCell(size: number, length: number): number;
358
+ newWindow(maxIntervals: number): number;
359
+ freeCell(cell: number): void;
360
+ freeWindow(window: number): void;
361
+ ssize(size: number, cell: number): void;
362
+ scard(card: number, cell: number): void;
363
+ card(cell: number): number;
364
+ size(cell: number): number;
365
+ valid(size: number, n: number, cell: number): void;
366
+ insrti(item: number, cell: number): void;
367
+ insrtd(item: number, cell: number): void;
368
+ insrtc(item: string, cell: number): void;
369
+ cellGeti(cell: number, index: number): number;
370
+ cellGetd(cell: number, index: number): number;
371
+ cellGetc(cell: number, index: number): string;
372
+ wninsd(left: number, right: number, window: number): void;
373
+ wncard(window: number): number;
374
+ wnfetd(window: number, index: number): number[];
375
+ wnvald(size: number, n: number, window: number): void;
108
376
  /** Internal test helper (not part of the backend contract). */
109
377
  __ktotalAll(): number;
110
378
  };
379
+ /**
380
+ * Lazily load (and cache) the native Node addon implementing the SPICE backend.
381
+ */
111
382
  export declare function getNativeAddon(): NativeAddon;
112
383
  //# sourceMappingURL=addon.d.ts.map
@@ -64,6 +64,9 @@ function tryGetPlatformBindingPath(require) {
64
64
  throw error;
65
65
  }
66
66
  }
67
+ /**
68
+ * Lazily load (and cache) the native Node addon implementing the SPICE backend.
69
+ */
67
70
  export function getNativeAddon() {
68
71
  if (cachedAddon) {
69
72
  return cachedAddon;
@@ -4,6 +4,23 @@ export type KernelStager = {
4
4
  furnsh(kernel: KernelSource, native: NativeAddon): void;
5
5
  unload(path: string, native: NativeAddon): void;
6
6
  kclear(native: NativeAddon): void;
7
+ /**
8
+ * If `path` matches a byte-staged kernel, returns the resolved OS temp-file
9
+ * path. Otherwise returns a canonicalized virtual kernel identifier (or the
10
+ * original OS path).
11
+ */
12
+ resolvePath(path: string): string;
13
+ /**
14
+ * Map an input path to the path string CSPICE expects.
15
+ *
16
+ * - OS paths pass through unchanged.
17
+ * - virtual kernel ids canonicalize to `/kernels/...` and, if byte-staged,
18
+ * resolve to a temp path.
19
+ */
20
+ resolvePathForSpice(path: string): string;
21
+ /** Map a staged temp path back to its virtual id (or passthrough). */
22
+ virtualizePathFromSpice(path: string): string;
7
23
  };
24
+ /** Create a staging helper that maps virtual kernel IDs to OS temp files for the native backend. */
8
25
  export declare function createKernelStager(): KernelStager;
9
26
  //# sourceMappingURL=kernel-staging.d.ts.map
@@ -2,9 +2,62 @@ import fs from "node:fs";
2
2
  import os from "node:os";
3
3
  import path from "node:path";
4
4
  import { randomUUID } from "node:crypto";
5
+ import { normalizeVirtualKernelPath } from "#core";
6
+ /** Create a staging helper that maps virtual kernel IDs to OS temp files for the native backend. */
5
7
  export function createKernelStager() {
6
8
  const tempByVirtualPath = new Map();
9
+ const virtualByTempPath = new Map();
7
10
  let tempKernelRootDir;
11
+ const VIRTUAL_KERNEL_ROOT = "/kernels/";
12
+ /**
13
+ * Canonicalize a virtual kernel identifier to the shared `/kernels/...` form.
14
+ *
15
+ * This is intentionally strict (no `..`) to keep byte-backed kernel staging
16
+ * safe and consistent with the WASM backend.
17
+ */
18
+ function canonicalVirtualKernelPath(input) {
19
+ return `/kernels/${normalizeVirtualKernelPath(input)}`;
20
+ }
21
+ function isVirtualKernelId(input) {
22
+ // Virtual kernel identifiers are explicit and POSIX-style.
23
+ //
24
+ // We *do not* treat arbitrary relative OS paths as virtual identifiers,
25
+ // since that would be surprising for Node consumers (e.g. `./naif0012.tls`).
26
+ return input.startsWith(VIRTUAL_KERNEL_ROOT) || input.startsWith("kernels/");
27
+ }
28
+ function tryCanonicalVirtualKernelPath(input) {
29
+ // Treat absolute OS paths as OS paths unless the caller explicitly opted
30
+ // into the virtual namespace.
31
+ if (path.isAbsolute(input) && !input.startsWith(VIRTUAL_KERNEL_ROOT)) {
32
+ return undefined;
33
+ }
34
+ // If this is a real on-disk absolute path, treat it as an OS path.
35
+ //
36
+ // This matters on POSIX because `/kernels/...` is a valid absolute path and
37
+ // could exist on disk; we only want to treat it as a virtual identifier
38
+ // when it doesn't resolve to a real file.
39
+ if (path.isAbsolute(input) && fs.existsSync(input)) {
40
+ return undefined;
41
+ }
42
+ try {
43
+ // Explicit virtual identifiers always participate.
44
+ if (isVirtualKernelId(input)) {
45
+ return canonicalVirtualKernelPath(input);
46
+ }
47
+ // For non-explicit relative paths, only treat as virtual if we already
48
+ // staged bytes for that id. This preserves `unload("naif0012.tls")` for
49
+ // byte-backed kernels without hijacking arbitrary on-disk relative paths.
50
+ if (!path.isAbsolute(input)) {
51
+ const canonical = canonicalVirtualKernelPath(input);
52
+ return tempByVirtualPath.has(canonical) ? canonical : undefined;
53
+ }
54
+ return undefined;
55
+ }
56
+ catch {
57
+ // Only treat as virtual if it normalizes successfully.
58
+ return undefined;
59
+ }
60
+ }
8
61
  function ensureTempKernelRootDir() {
9
62
  if (tempKernelRootDir) {
10
63
  return tempKernelRootDir;
@@ -23,24 +76,37 @@ export function createKernelStager() {
23
76
  }
24
77
  }
25
78
  }
79
+ function resolvePathForSpice(input) {
80
+ const canonical = tryCanonicalVirtualKernelPath(input);
81
+ if (!canonical) {
82
+ return input;
83
+ }
84
+ // If this is a valid virtual kernel path but it's not staged, return the
85
+ // canonical virtual identifier. This keeps the backend behavior stable
86
+ // regardless of whether callers use `kernels/foo.tm`, `/kernels/foo.tm`,
87
+ // or other equivalent virtual spellings.
88
+ return tempByVirtualPath.get(canonical) ?? canonical;
89
+ }
26
90
  return {
27
91
  furnsh: (_kernel, native) => {
28
92
  const kernel = _kernel;
29
93
  if (typeof kernel === "string") {
30
- native.furnsh(kernel);
94
+ native.furnsh(resolvePathForSpice(kernel));
31
95
  return;
32
96
  }
97
+ const virtualPath = canonicalVirtualKernelPath(kernel.path);
33
98
  // For byte-backed kernels, we write to a temp file and load via CSPICE.
34
99
  // We then remember the resolved temp path so `unload(kernel.path)` unloads
35
100
  // the correct file.
36
- const existingTemp = tempByVirtualPath.get(kernel.path);
101
+ const existingTemp = tempByVirtualPath.get(virtualPath);
37
102
  if (existingTemp) {
38
103
  native.unload(existingTemp);
39
- tempByVirtualPath.delete(kernel.path);
104
+ tempByVirtualPath.delete(virtualPath);
105
+ virtualByTempPath.delete(existingTemp);
40
106
  safeUnlink(existingTemp);
41
107
  }
42
108
  const rootDir = ensureTempKernelRootDir();
43
- const fileName = path.basename(kernel.path) || "kernel";
109
+ const fileName = path.basename(virtualPath) || "kernel";
44
110
  const tempPath = path.join(rootDir, `${randomUUID()}-${fileName}`);
45
111
  fs.writeFileSync(tempPath, kernel.bytes);
46
112
  try {
@@ -50,13 +116,16 @@ export function createKernelStager() {
50
116
  safeUnlink(tempPath);
51
117
  throw error;
52
118
  }
53
- tempByVirtualPath.set(kernel.path, tempPath);
119
+ tempByVirtualPath.set(virtualPath, tempPath);
120
+ virtualByTempPath.set(tempPath, virtualPath);
54
121
  },
55
122
  unload: (_path, native) => {
56
- const resolved = tempByVirtualPath.get(_path);
123
+ const canonical = tryCanonicalVirtualKernelPath(_path);
124
+ const resolved = canonical ? tempByVirtualPath.get(canonical) : undefined;
57
125
  if (resolved) {
58
126
  native.unload(resolved);
59
- tempByVirtualPath.delete(_path);
127
+ tempByVirtualPath.delete(canonical);
128
+ virtualByTempPath.delete(resolved);
60
129
  safeUnlink(resolved);
61
130
  return;
62
131
  }
@@ -69,7 +138,11 @@ export function createKernelStager() {
69
138
  safeUnlink(tempPath);
70
139
  }
71
140
  tempByVirtualPath.clear();
141
+ virtualByTempPath.clear();
72
142
  },
143
+ resolvePath: resolvePathForSpice,
144
+ resolvePathForSpice,
145
+ virtualizePathFromSpice: (p) => virtualByTempPath.get(p) ?? p,
73
146
  };
74
147
  }
75
148
  //# sourceMappingURL=kernel-staging.js.map
@@ -0,0 +1,3 @@
1
+ export type { SpiceHandleEntry, SpiceHandleKind, SpiceHandleRegistry, } from "#backend-contract";
2
+ export { createSpiceHandleRegistry } from "#backend-contract";
3
+ //# sourceMappingURL=spice-handles.d.ts.map