@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,8 @@
1
+ /**
2
+ * Contract conventions:
3
+ * - Inputs are assumed validated at the backend boundary; the contract itself is primarily type-level.
4
+ * - Methods throw on invalid arguments or SPICE errors.
5
+ * - Lookups that may legitimately miss return `Found<T>` (`{ found: false }`) instead of throwing.
6
+ */
7
+ export {};
8
+ //# sourceMappingURL=file-io.js.map
@@ -1,19 +1,47 @@
1
+ /**
2
+ * Contract conventions:
3
+ * - Inputs are assumed validated at the backend boundary; the contract itself is primarily type-level.
4
+ * - Methods throw on invalid arguments or SPICE errors.
5
+ * - Lookups that may legitimately miss return `Found<T>` (`{ found: false }`) instead of throwing.
6
+ */
1
7
  import type { Found, Mat3RowMajor, SpiceMatrix6x6, SpiceVector3 } from "../shared/types.js";
8
+ import type { SpiceIntCell, SpiceWindow } from "./cells-windows.js";
9
+ /** Coverage detail level returned by {@link FramesApi.ckcov}. */
10
+ export type CkCoverageLevel = "SEGMENT" | "INTERVAL";
11
+ /** Time system used for coverage windows returned by {@link FramesApi.ckcov}. */
12
+ export type CkCoverageTimeSystem = "SCLK" | "TDB";
13
+ /** Backend contract for frame/name lookups, CK access, and frame transformations. */
2
14
  export interface FramesApi {
15
+ /** SPICE `namfrm_c`: look up a frame code by frame name. */
3
16
  namfrm(name: string): Found<{
4
17
  code: number;
5
18
  }>;
19
+ /** SPICE `frmnam_c`: look up a frame name by frame code. */
6
20
  frmnam(code: number): Found<{
7
21
  name: string;
8
22
  }>;
23
+ /** SPICE `cidfrm_c`: look up frame information for a center body ID. */
9
24
  cidfrm(center: number): Found<{
10
25
  frcode: number;
11
26
  frname: string;
12
27
  }>;
28
+ /** SPICE `cnmfrm_c`: look up frame information for a center body name. */
13
29
  cnmfrm(centerName: string): Found<{
14
30
  frcode: number;
15
31
  frname: string;
16
32
  }>;
33
+ /** SPICE `frinfo_c`: get center + frame class info for a frame ID. */
34
+ frinfo(frameId: number): Found<{
35
+ center: number;
36
+ frameClass: number;
37
+ classId: number;
38
+ }>;
39
+ /** SPICE `ccifrm_c`: map frame class + class ID to a frame code/name/center triple. */
40
+ ccifrm(frameClass: number, classId: number): Found<{
41
+ frcode: number;
42
+ frname: string;
43
+ center: number;
44
+ }>;
17
45
  /** Get pointing (attitude) for a CK instrument at a given encoded spacecraft clock time. */
18
46
  ckgp(inst: number, sclkdp: number, tol: number, ref: string): Found<{
19
47
  cmat: Mat3RowMajor;
@@ -25,6 +53,18 @@ export interface FramesApi {
25
53
  av: SpiceVector3;
26
54
  clkout: number;
27
55
  }>;
56
+ /**
57
+ * Load a CK file for access by pointing routines (`cklpf_c`).
58
+ *
59
+ * Returns a CK file handle suitable for {@link FramesApi.ckupf}.
60
+ */
61
+ cklpf(ck: string): number;
62
+ /** Unload a CK file previously loaded by {@link FramesApi.cklpf} (`ckupf_c`). */
63
+ ckupf(handle: number): void;
64
+ /** Return the set of instrument/object IDs for which the specified CK has segments (`ckobj_c`). */
65
+ ckobj(ck: string, ids: SpiceIntCell): void;
66
+ /** Return coverage for an instrument/object in a CK file (`ckcov_c`). */
67
+ ckcov(ck: string, idcode: number, needav: boolean, level: CkCoverageLevel, tol: number, timsys: CkCoverageTimeSystem, cover: SpiceWindow): void;
28
68
  /** Compute a 3x3 frame transformation matrix (row-major). */
29
69
  pxform(from: string, to: string, et: number): Mat3RowMajor;
30
70
  /** Compute a 6x6 state transformation matrix (row-major). */
@@ -0,0 +1,44 @@
1
+ /**
2
+ * GF (Geometry Finder) event finding.
3
+ *
4
+ * Tranche 1 scope:
5
+ * - "Plumbing" utilities (`gfsstp/gfstep`, `gfstol`, `gfrefn`, `gfrepi/gfrepf`).
6
+ * - A couple high-level, callback-free searches: `gfsep` and `gfdist`.
7
+ *
8
+ * Notes:
9
+ * - The CSPICE GF subsystem has some **global mutable state** (e.g. `gfsstp`,
10
+ * `gfstol`). Callers should treat these as process-global knobs.
11
+ * - Confinement/result windows use Group 2 `SpiceWindow` opaque handles.
12
+ */
13
+ import type { AbCorr } from "../shared/types.js";
14
+ import type { SpiceWindow } from "./cells-windows.js";
15
+ /** Relation operators accepted by many high-level GF searches. */
16
+ export type GfRelate = ">" | "<" | "=" | "ABSMAX" | "ABSMIN" | "LOCMAX" | "LOCMIN";
17
+ /** Backend contract for Geometry Finder (GF) event-finding routines. */
18
+ export interface GeometryGfApi {
19
+ /** Set the constant step size used by {@link GeometryGfApi.gfstep} (`gfsstp_c`). */
20
+ gfsstp(step: number): void;
21
+ /** Return the constant step size set by {@link GeometryGfApi.gfsstp} (`gfstep_c`). */
22
+ gfstep(time: number): number;
23
+ /** Override the GF convergence tolerance (`gfstol_c`). */
24
+ gfstol(value: number): void;
25
+ /** Default refinement estimator used by the GF subsystem (`gfrefn_c`). */
26
+ gfrefn(t1: number, t2: number, s1: boolean, s2: boolean): number;
27
+ /** Initialize the default console progress reporter (`gfrepi_c`). */
28
+ gfrepi(window: SpiceWindow, begmss: string, endmss: string): void;
29
+ /** Finalize the default console progress reporter (`gfrepf_c`). */
30
+ gfrepf(): void;
31
+ /**
32
+ * Angular separation search (`gfsep_c`).
33
+ *
34
+ * `refval` and `adjust` are in **radians**.
35
+ */
36
+ gfsep(targ1: string, shape1: string, frame1: string, targ2: string, shape2: string, frame2: string, abcorr: AbCorr | string, obsrvr: string, relate: GfRelate | string, refval: number, adjust: number, step: number, nintvls: number, cnfine: SpiceWindow, result: SpiceWindow): void;
37
+ /**
38
+ * Observer-target distance search (`gfdist_c`).
39
+ *
40
+ * `refval` and `adjust` are in **km**.
41
+ */
42
+ gfdist(target: string, abcorr: AbCorr | string, obsrvr: string, relate: GfRelate | string, refval: number, adjust: number, step: number, nintvls: number, cnfine: SpiceWindow, result: SpiceWindow): void;
43
+ }
44
+ //# sourceMappingURL=geometry-gf.d.ts.map
@@ -0,0 +1,14 @@
1
+ /**
2
+ * GF (Geometry Finder) event finding.
3
+ *
4
+ * Tranche 1 scope:
5
+ * - "Plumbing" utilities (`gfsstp/gfstep`, `gfstol`, `gfrefn`, `gfrepi/gfrepf`).
6
+ * - A couple high-level, callback-free searches: `gfsep` and `gfdist`.
7
+ *
8
+ * Notes:
9
+ * - The CSPICE GF subsystem has some **global mutable state** (e.g. `gfsstp`,
10
+ * `gfstol`). Callers should treat these as process-global knobs.
11
+ * - Confinement/result windows use Group 2 `SpiceWindow` opaque handles.
12
+ */
13
+ export {};
14
+ //# sourceMappingURL=geometry-gf.js.map
@@ -1,4 +1,11 @@
1
- import type { AbCorr, Found, IluminResult, SubPointResult, SpiceVector3 } from "../shared/types.js";
1
+ /**
2
+ * Contract conventions:
3
+ * - Inputs are assumed validated at the backend boundary; the contract itself is primarily type-level.
4
+ * - Methods throw on invalid arguments or SPICE errors.
5
+ * - Lookups that may legitimately miss return `Found<T>` (`{ found: false }`) instead of throwing.
6
+ */
7
+ import type { AbCorr, Found, IllumfResult, IllumgResult, IluminResult, Pl2nvcResult, SpicePlane, SubPointResult, SpiceVector3 } from "../shared/types.js";
8
+ /** Backend contract for common SPICE geometry computations (subpoints, intercepts, illumination, etc). */
2
9
  export interface GeometryApi {
3
10
  /** Compute the sub-observer point on a target body's surface. */
4
11
  subpnt(method: string, target: string, et: number, fixref: string, abcorr: AbCorr | string, observer: string): SubPointResult;
@@ -8,7 +15,20 @@ export interface GeometryApi {
8
15
  sincpt(method: string, target: string, et: number, fixref: string, abcorr: AbCorr | string, observer: string, dref: string, dvec: SpiceVector3): Found<SubPointResult>;
9
16
  /** Compute illumination angles at a surface point. */
10
17
  ilumin(method: string, target: string, et: number, fixref: string, abcorr: AbCorr | string, observer: string, spoint: SpiceVector3): IluminResult;
18
+ /**
19
+ * Compute illumination angles at a surface point, with a caller-specified
20
+ * illumination source body.
21
+ */
22
+ illumg(method: string, target: string, ilusrc: string, et: number, fixref: string, abcorr: AbCorr | string, observer: string, spoint: SpiceVector3): IllumgResult;
23
+ /**
24
+ * Compute illumination angles + visibility/lighting flags at a surface point.
25
+ */
26
+ illumf(method: string, target: string, ilusrc: string, et: number, fixref: string, abcorr: AbCorr | string, observer: string, spoint: SpiceVector3): IllumfResult;
11
27
  /** Determine the occultation condition code for one target vs another. */
12
28
  occult(targ1: string, shape1: string, frame1: string, targ2: string, shape2: string, frame2: string, abcorr: AbCorr | string, observer: string, et: number): number;
29
+ /** Convert a normal vector + constant to a plane. */
30
+ nvc2pl(normal: SpiceVector3, konst: number): SpicePlane;
31
+ /** Convert a plane to a unit normal vector + constant. */
32
+ pl2nvc(plane: SpicePlane): Pl2nvcResult;
13
33
  }
14
34
  //# sourceMappingURL=geometry.d.ts.map
@@ -0,0 +1,3 @@
1
+ /** Normalize a body-constant item name for `bodfnd` / `bodvar` lookups. */
2
+ export declare function normalizeBodItem(item: string): string;
3
+ //# sourceMappingURL=ids-names-normalize.d.ts.map
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Normalize a body-constant item name for `bodfnd` / `bodvar` lookups.
3
+ *
4
+ * Body-constant item names are treated as case-insensitive by CSPICE, but CSPICE's
5
+ * casing behavior is ASCII-based. We intentionally avoid `String.prototype.toUpperCase()`
6
+ * here because it applies Unicode case mappings (e.g. `"ß" -> "SS"`), which can
7
+ * change lookup keys in surprising ways.
8
+ *
9
+ * We intentionally trim **ASCII whitespace only** (space/tab/newline/etc.) to match
10
+ * CSPICE behavior and keep native + WASM backends consistent.
11
+ */
12
+ const MAX_BOD_ITEM_CHARS = 1024;
13
+ /** Normalize a body-constant item name for `bodfnd` / `bodvar` lookups. */
14
+ export function normalizeBodItem(item) {
15
+ // Defensive guardrail: kernel pool item names are expected to be short.
16
+ // If a pathological string makes it here (e.g. a multi-megabyte user input),
17
+ // uppercasing it can cause large allocations and unnecessary CPU work.
18
+ //
19
+ // This limit is intentionally *far* above any realistic item name.
20
+ if (item.length > MAX_BOD_ITEM_CHARS) {
21
+ throw new RangeError(`Kernel pool item name is too long: ${item.length} characters (max ${MAX_BOD_ITEM_CHARS})`);
22
+ }
23
+ return toAsciiUppercase(trimAsciiWhitespace(item));
24
+ }
25
+ function isAsciiWhitespace(code) {
26
+ // Keep this consistent with the native backend implementation.
27
+ return (code === 32 /* ' ' */ ||
28
+ code === 9 /* '\t' */ ||
29
+ code === 10 /* '\n' */ ||
30
+ code === 13 /* '\\r' */ ||
31
+ code === 12 /* '\f' */ ||
32
+ code === 11 /* '\\v' */);
33
+ }
34
+ function trimAsciiWhitespace(s) {
35
+ let start = 0;
36
+ while (start < s.length && isAsciiWhitespace(s.charCodeAt(start))) {
37
+ start++;
38
+ }
39
+ let end = s.length;
40
+ while (end > start && isAsciiWhitespace(s.charCodeAt(end - 1))) {
41
+ end--;
42
+ }
43
+ if (start === 0 && end === s.length) {
44
+ return s;
45
+ }
46
+ return s.slice(start, end);
47
+ }
48
+ function toAsciiUppercase(s) {
49
+ // JS `toUpperCase()` applies Unicode case mappings (e.g. "ß" -> "SS").
50
+ // For kernel pool item names, we only want to uppercase ASCII a-z.
51
+ //
52
+ // Performance: avoid allocating a new string if no changes are needed.
53
+ //
54
+ // Implementation note: we do a single pass over the string and only start
55
+ // constructing an output string after seeing the first lowercase ASCII letter.
56
+ let out;
57
+ for (let i = 0; i < s.length; i++) {
58
+ const code = s.charCodeAt(i);
59
+ const isAsciiLower = code >= 97 /* 'a' */ && code <= 122 /* 'z' */;
60
+ if (out === undefined) {
61
+ if (!isAsciiLower)
62
+ continue;
63
+ // We found at least one lowercase ASCII letter; build the output string.
64
+ //
65
+ // Note: `normalizeBodItem()` enforces a max input length, so a simple
66
+ // per-code-unit loop is safe and keeps allocation behavior predictable.
67
+ out = s.slice(0, i) + String.fromCharCode(code - 32);
68
+ continue;
69
+ }
70
+ out += String.fromCharCode(isAsciiLower ? code - 32 : code);
71
+ }
72
+ return out ?? s;
73
+ }
74
+ //# sourceMappingURL=ids-names-normalize.js.map
@@ -1,10 +1,47 @@
1
+ /**
2
+ * Contract conventions:
3
+ * - Inputs are assumed validated at the backend boundary; the contract itself is primarily type-level.
4
+ * - Methods throw on invalid arguments or SPICE errors.
5
+ * - Lookups that may legitimately miss return `Found<T>` (`{ found: false }`) instead of throwing.
6
+ */
1
7
  import type { Found } from "../shared/types.js";
8
+ /** Backend contract for NAIF ID/name and body-constant lookups. */
2
9
  export interface IdsNamesApi {
10
+ /** SPICE `bodn2c_c`: look up a NAIF body ID code by name. */
3
11
  bodn2c(name: string): Found<{
4
12
  code: number;
5
13
  }>;
14
+ /** SPICE `bodc2n_c`: look up a body name by NAIF ID code. */
6
15
  bodc2n(code: number): Found<{
7
16
  name: string;
8
17
  }>;
18
+ /** Map a NAIF body ID code to a name (or decimal string if unknown). */
19
+ bodc2s(code: number): string;
20
+ /** Map a body name or numeric string to a NAIF body ID code. */
21
+ bods2c(name: string): Found<{
22
+ code: number;
23
+ }>;
24
+ /** Define a body name/code mapping (side effect). */
25
+ boddef(name: string, code: number): void;
26
+ /**
27
+ * Return true if a body constant exists in the kernel pool.
28
+ *
29
+ * Normalization:
30
+ * - `item` is normalized as `normalizeBodItem(item)` (trim ASCII whitespace + ASCII-only uppercase)
31
+ * before lookup.
32
+ */
33
+ bodfnd(body: number, item: string): boolean;
34
+ /**
35
+ * Return values of a body constant from the kernel pool.
36
+ *
37
+ * Normalization:
38
+ * - `item` is normalized as `normalizeBodItem(item)` (trim ASCII whitespace + ASCII-only uppercase)
39
+ * before lookup.
40
+ *
41
+ * Missing-item semantics:
42
+ * - If `item` is not found for `body` (or is non-numeric), returns `[]`.
43
+ * - Call `bodfnd(body, item)` if you need a strict presence check.
44
+ */
45
+ bodvar(body: number, item: string): number[];
9
46
  }
10
47
  //# sourceMappingURL=ids-names.d.ts.map
@@ -0,0 +1,134 @@
1
+ /**
2
+ * Kernel pool API contract.
3
+ *
4
+ * Contract conventions:
5
+ * - Backends MUST validate inputs as described below and throw on invalid arguments or SPICE errors.
6
+ * - Lookups that may legitimately miss return `Found<T>` (`{ found: false }`) instead of throwing.
7
+ *
8
+ * Terminology used in validation semantics:
9
+ * - "not empty or whitespace-only" means `value.trim().length > 0`.
10
+ * - "finite integer" means `Number.isFinite(value) && Number.isInteger(value)`.
11
+ *
12
+ * Empty arrays:
13
+ * - `pdpool`/`pipool`/`pcpool` accept `values: []` and set the variable to an empty list (size 0).
14
+ * - `swpool` accepts `names: []` and watches nothing (but still arms the agent so the next
15
+ * `cvpool(agent)` returns `true`).
16
+ */
17
+ import type { Found } from "../shared/types.js";
18
+ export type KernelPoolVarType = "C" | "N";
19
+ /** Backend contract for reading/writing kernel pool variables. */
20
+ export interface KernelPoolApi {
21
+ /**
22
+ * Get numeric (double) kernel pool values.
23
+ *
24
+ * Validation semantics:
25
+ * - `name` must not be empty or whitespace-only.
26
+ * - `start` must be a finite integer >= 0 (0-based).
27
+ * - `room` must be a finite integer > 0.
28
+ */
29
+ gdpool(name: string, start: number, room: number): Found<{
30
+ values: number[];
31
+ }>;
32
+ /**
33
+ * Get numeric (integer) kernel pool values.
34
+ *
35
+ * Validation semantics:
36
+ * - `name` must not be empty or whitespace-only.
37
+ * - `start` must be a finite integer >= 0 (0-based).
38
+ * - `room` must be a finite integer > 0.
39
+ */
40
+ gipool(name: string, start: number, room: number): Found<{
41
+ values: number[];
42
+ }>;
43
+ /**
44
+ * Get character kernel pool values.
45
+ *
46
+ * Validation semantics:
47
+ * - `name` must not be empty or whitespace-only.
48
+ * - `start` must be a finite integer >= 0 (0-based).
49
+ * - `room` must be a finite integer > 0.
50
+ */
51
+ gcpool(name: string, start: number, room: number): Found<{
52
+ values: string[];
53
+ }>;
54
+ /**
55
+ * Get the names of kernel pool variables matching a template.
56
+ *
57
+ * Wildcards:
58
+ * - `*` matches any substring
59
+ * - `%` matches any single character
60
+ *
61
+ * Validation semantics:
62
+ * - `template` must not be empty or whitespace-only.
63
+ * - `start` must be a finite integer >= 0 (0-based).
64
+ * - `room` must be a finite integer > 0.
65
+ */
66
+ gnpool(template: string, start: number, room: number): Found<{
67
+ values: string[];
68
+ }>;
69
+ /**
70
+ * Get kernel pool variable type (`C` or `N`) and size.
71
+ *
72
+ * Validation semantics:
73
+ * - `name` must not be empty or whitespace-only.
74
+ */
75
+ dtpool(name: string): Found<{
76
+ n: number;
77
+ type: KernelPoolVarType;
78
+ }>;
79
+ /**
80
+ * Put numeric (double) values into the kernel pool.
81
+ *
82
+ * Validation semantics:
83
+ * - `name` must not be empty or whitespace-only.
84
+ * - `values` may be empty (sets an empty value list).
85
+ * - Each value must be finite (no `NaN` / `±Infinity`).
86
+ */
87
+ pdpool(name: string, values: readonly number[]): void;
88
+ /**
89
+ * Put numeric (integer) values into the kernel pool.
90
+ *
91
+ * Validation semantics:
92
+ * - `name` must not be empty or whitespace-only.
93
+ * - `values` may be empty (sets an empty value list).
94
+ * - Each value must be a safe integer in the signed 32-bit range
95
+ * [-2147483648, 2147483647].
96
+ */
97
+ pipool(name: string, values: readonly number[]): void;
98
+ /**
99
+ * Put character values into the kernel pool.
100
+ *
101
+ * Validation semantics:
102
+ * - `name` must not be empty or whitespace-only.
103
+ * - `values` may be empty (sets an empty value list).
104
+ */
105
+ pcpool(name: string, values: readonly string[]): void;
106
+ /**
107
+ * Set up a kernel pool "watch" for `agent`.
108
+ *
109
+ * After calling `swpool`, the next `cvpool(agent)` call will return `true`.
110
+ *
111
+ * Validation semantics:
112
+ * - `agent` must not be empty or whitespace-only.
113
+ * - `names` may be empty (watch nothing).
114
+ */
115
+ swpool(agent: string, names: readonly string[]): void;
116
+ /**
117
+ * Check whether watched variables for `agent` have been updated since the last call.
118
+ *
119
+ * Validation semantics:
120
+ * - `agent` must not be empty or whitespace-only.
121
+ */
122
+ cvpool(agent: string): boolean;
123
+ /**
124
+ * Check existence of a *numeric* kernel pool variable.
125
+ *
126
+ * NOTE: This does not detect character-valued variables; use `dtpool` if you need a
127
+ * general existence/type check.
128
+ *
129
+ * Validation semantics:
130
+ * - `name` must not be empty or whitespace-only.
131
+ */
132
+ expool(name: string): boolean;
133
+ }
134
+ //# sourceMappingURL=kernel-pool.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=kernel-pool.js.map
@@ -0,0 +1,44 @@
1
+ import type { Found, KernelData, KernelKind } from "../shared/types.js";
2
+ import type { KernelKindInput } from "./kernels.js";
3
+ /** Normalize a `ktotal/kdata` kind input into a canonical, non-empty kernel kind list. */
4
+ export declare function normalizeKindInput(kind: KernelKindInput | undefined): readonly KernelKind[];
5
+ /**
6
+ * Returns a representable native kind-query string (e.g. `"SPK CK"`) or null.
7
+ *
8
+ * This is used by backends to decide whether they can forward a kind filter to
9
+ * their underlying CSPICE implementation, or whether they must fall back to
10
+ * querying `ALL` and filtering in JS.
11
+ *
12
+ * NOTE: `kinds` is expected to be normalized (via {@link normalizeKindInput}).
13
+ * If non-normalized input slips through (e.g. empty arrays or `ALL` mixed with
14
+ * other tokens), this function is defensive and returns null.
15
+ */
16
+ export declare function nativeKindQueryOrNull(kinds: readonly KernelKind[]): string | null;
17
+ /**
18
+ * Return whether a kernel matches the requested kind filter.
19
+ *
20
+ * Requested kind tokens are treated as trim + case-insensitive. Empty tokens are ignored.
21
+ *
22
+ * NOTE: Unlike {@link normalizeKindInput}, this helper is intentionally lenient:
23
+ * unknown requested tokens are treated as non-matching (and do not throw).
24
+ * Unknown/unsupported `kernel.filtyp` values never match (unless `requested` includes `ALL`).
25
+ *
26
+ * TEXT-kernel subtypes (LSK/FK/IK/SCLK): SPICE reports these as `filtyp: "TEXT"`.
27
+ * When callers request a subtype, we infer it from the `kernel.file` identifier's
28
+ * filename extension (best-effort). If the identifier is virtual or extension-less,
29
+ * subtype matching may fall back to "TEXT".
30
+ */
31
+ export declare function matchesKernelKind(requestedRaw: ReadonlySet<string>, kernel: Pick<KernelData, "file" | "filtyp">): boolean;
32
+ /**
33
+ * JS implementation of CSPICE `kxtrct`.
34
+ *
35
+ * Notes on return values:
36
+ * - `substr` is right-trimmed (`trimEnd()`).
37
+ * - `wordsq` has the extracted words removed, but otherwise preserves whitespace
38
+ * from the original input (so it may start with blanks).
39
+ */
40
+ export declare function kxtrctJs(keywd: string, terms: readonly string[], wordsq: string): Found<{
41
+ wordsq: string;
42
+ substr: string;
43
+ }>;
44
+ //# sourceMappingURL=kernels-utils.d.ts.map