siderust-js 0.1.0

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 (272) hide show
  1. package/.github/workflows/ci.yml +166 -0
  2. package/.gitmodules +9 -0
  3. package/CHANGELOG.md +26 -0
  4. package/LICENSE +661 -0
  5. package/README.md +138 -0
  6. package/package.json +12 -0
  7. package/qtty-js/.github/workflows/ci.yml +151 -0
  8. package/qtty-js/.gitmodules +3 -0
  9. package/qtty-js/CHANGELOG.md +31 -0
  10. package/qtty-js/LICENSE +661 -0
  11. package/qtty-js/README.md +132 -0
  12. package/qtty-js/package.json +20 -0
  13. package/qtty-js/qtty/.github/workflows/ci.yml +155 -0
  14. package/qtty-js/qtty/CHANGELOG.md +120 -0
  15. package/qtty-js/qtty/Cargo.lock +1462 -0
  16. package/qtty-js/qtty/Cargo.toml +12 -0
  17. package/qtty-js/qtty/LICENSE +661 -0
  18. package/qtty-js/qtty/README.md +9 -0
  19. package/qtty-js/qtty/qtty/Cargo.toml +41 -0
  20. package/qtty-js/qtty/qtty/README.md +8 -0
  21. package/qtty-js/qtty/qtty/examples/angles.rs +14 -0
  22. package/qtty-js/qtty/qtty/examples/astronomy.rs +17 -0
  23. package/qtty-js/qtty/qtty/examples/dimensional_arithmetic.rs +83 -0
  24. package/qtty-js/qtty/qtty/examples/python_integration.rs +61 -0
  25. package/qtty-js/qtty/qtty/examples/quickstart.rs +15 -0
  26. package/qtty-js/qtty/qtty/examples/ratios.rs +12 -0
  27. package/qtty-js/qtty/qtty/examples/serde_with_unit.rs +234 -0
  28. package/qtty-js/qtty/qtty/examples/serialization.rs +141 -0
  29. package/qtty-js/qtty/qtty/examples/serialization_advanced.rs +155 -0
  30. package/qtty-js/qtty/qtty/src/f32.rs +108 -0
  31. package/qtty-js/qtty/qtty/src/f64.rs +30 -0
  32. package/qtty-js/qtty/qtty/src/i128.rs +111 -0
  33. package/qtty-js/qtty/qtty/src/i16.rs +111 -0
  34. package/qtty-js/qtty/qtty/src/i32.rs +111 -0
  35. package/qtty-js/qtty/qtty/src/i64.rs +111 -0
  36. package/qtty-js/qtty/qtty/src/i8.rs +111 -0
  37. package/qtty-js/qtty/qtty/src/lib.rs +238 -0
  38. package/qtty-js/qtty/qtty/tests/fixtures/qtty-vec-no-std/Cargo.lock +83 -0
  39. package/qtty-js/qtty/qtty/tests/fixtures/qtty-vec-no-std/Cargo.toml +10 -0
  40. package/qtty-js/qtty/qtty/tests/fixtures/qtty-vec-no-std/src/lib.rs +7 -0
  41. package/qtty-js/qtty/qtty/tests/fixtures/qtty-vec-no-std-alloc/Cargo.lock +83 -0
  42. package/qtty-js/qtty/qtty/tests/fixtures/qtty-vec-no-std-alloc/Cargo.toml +10 -0
  43. package/qtty-js/qtty/qtty/tests/fixtures/qtty-vec-no-std-alloc/src/lib.rs +7 -0
  44. package/qtty-js/qtty/qtty/tests/fixtures/qtty-vec-std/Cargo.lock +83 -0
  45. package/qtty-js/qtty/qtty/tests/fixtures/qtty-vec-std/Cargo.toml +10 -0
  46. package/qtty-js/qtty/qtty/tests/fixtures/qtty-vec-std/src/lib.rs +5 -0
  47. package/qtty-js/qtty/qtty/tests/integration_tests.rs +529 -0
  48. package/qtty-js/qtty/qtty/tests/qtty_vec_feature_matrix.rs +58 -0
  49. package/qtty-js/qtty/qtty-core/Cargo.toml +41 -0
  50. package/qtty-js/qtty/qtty-core/README.md +8 -0
  51. package/qtty-js/qtty/qtty-core/examples/diesel_integration.rs +145 -0
  52. package/qtty-js/qtty/qtty-core/examples/quantity_db_serde.rs +215 -0
  53. package/qtty-js/qtty/qtty-core/src/dimension.rs +249 -0
  54. package/qtty-js/qtty/qtty-core/src/feature_diesel.rs +318 -0
  55. package/qtty-js/qtty/qtty-core/src/feature_pyo3.rs +27 -0
  56. package/qtty-js/qtty/qtty-core/src/feature_serde.rs +203 -0
  57. package/qtty-js/qtty/qtty-core/src/feature_tiberius.rs +28 -0
  58. package/qtty-js/qtty/qtty-core/src/lib.rs +744 -0
  59. package/qtty-js/qtty/qtty-core/src/macros.rs +93 -0
  60. package/qtty-js/qtty/qtty-core/src/quantity.rs +810 -0
  61. package/qtty-js/qtty/qtty-core/src/scalar.rs +1742 -0
  62. package/qtty-js/qtty/qtty-core/src/unit.rs +332 -0
  63. package/qtty-js/qtty/qtty-core/src/units/angular.rs +1228 -0
  64. package/qtty-js/qtty/qtty-core/src/units/area.rs +243 -0
  65. package/qtty-js/qtty/qtty-core/src/units/frequency.rs +179 -0
  66. package/qtty-js/qtty/qtty-core/src/units/length.rs +1270 -0
  67. package/qtty-js/qtty/qtty-core/src/units/mass.rs +488 -0
  68. package/qtty-js/qtty/qtty-core/src/units/mod.rs +26 -0
  69. package/qtty-js/qtty/qtty-core/src/units/power.rs +324 -0
  70. package/qtty-js/qtty/qtty-core/src/units/time.rs +667 -0
  71. package/qtty-js/qtty/qtty-core/src/units/unitless.rs +212 -0
  72. package/qtty-js/qtty/qtty-core/src/units/velocity.rs +210 -0
  73. package/qtty-js/qtty/qtty-core/src/units/volume.rs +269 -0
  74. package/qtty-js/qtty/qtty-core/tests/core.rs +628 -0
  75. package/qtty-js/qtty/qtty-core/tests/diesel.rs +461 -0
  76. package/qtty-js/qtty/qtty-core/tests/integers.rs +632 -0
  77. package/qtty-js/qtty/qtty-core/tests/no_cross_unit_ops.rs +35 -0
  78. package/qtty-js/qtty/qtty-core/tests/pyo3.rs +334 -0
  79. package/qtty-js/qtty/qtty-core/tests/quantity_f32.rs +276 -0
  80. package/qtty-js/qtty/qtty-core/tests/scalar_decimal.rs +258 -0
  81. package/qtty-js/qtty/qtty-core/tests/scalar_f32.rs +286 -0
  82. package/qtty-js/qtty/qtty-core/tests/scalar_f64_real.rs +287 -0
  83. package/qtty-js/qtty/qtty-core/tests/scalar_rational.rs +260 -0
  84. package/qtty-js/qtty/qtty-core/tests/serde.rs +256 -0
  85. package/qtty-js/qtty/qtty-core/tests/tiberius.rs +208 -0
  86. package/qtty-js/qtty/qtty-derive/Cargo.toml +23 -0
  87. package/qtty-js/qtty/qtty-derive/README.md +8 -0
  88. package/qtty-js/qtty/qtty-derive/src/lib.rs +340 -0
  89. package/qtty-js/qtty/qtty-ffi/ARCHITECTURE.md +3 -0
  90. package/qtty-js/qtty/qtty-ffi/Cargo.toml +31 -0
  91. package/qtty-js/qtty/qtty-ffi/README.md +9 -0
  92. package/qtty-js/qtty/qtty-ffi/build.rs +326 -0
  93. package/qtty-js/qtty/qtty-ffi/cbindgen.toml +105 -0
  94. package/qtty-js/qtty/qtty-ffi/include/qtty_ffi.h +1126 -0
  95. package/qtty-js/qtty/qtty-ffi/src/ffi.rs +1251 -0
  96. package/qtty-js/qtty/qtty-ffi/src/ffi_serde.rs +294 -0
  97. package/qtty-js/qtty/qtty-ffi/src/helpers.rs +310 -0
  98. package/qtty-js/qtty/qtty-ffi/src/lib.rs +229 -0
  99. package/qtty-js/qtty/qtty-ffi/src/macros.rs +121 -0
  100. package/qtty-js/qtty/qtty-ffi/src/registry.rs +274 -0
  101. package/qtty-js/qtty/qtty-ffi/src/types.rs +620 -0
  102. package/qtty-js/qtty/qtty-ffi/tests/integration_tests.rs +842 -0
  103. package/qtty-js/qtty/qtty-ffi/units.csv +156 -0
  104. package/qtty-js/qtty/qtty-ffi/units.csv.md +3 -0
  105. package/qtty-js/qtty-node/.prettierignore +6 -0
  106. package/qtty-js/qtty-node/.prettierrc.json +6 -0
  107. package/qtty-js/qtty-node/README.md +250 -0
  108. package/qtty-js/qtty-node/c8.config.json +11 -0
  109. package/qtty-js/qtty-node/eslint.config.js +31 -0
  110. package/qtty-js/qtty-node/examples/arithmetic.mjs +64 -0
  111. package/qtty-js/qtty-node/examples/astronomy.mjs +90 -0
  112. package/qtty-js/qtty-node/examples/quickstart.mjs +36 -0
  113. package/qtty-js/qtty-node/examples/serialization.mjs +125 -0
  114. package/qtty-js/qtty-node/examples/unit_factories.mjs +74 -0
  115. package/qtty-js/qtty-node/index.d.ts +219 -0
  116. package/qtty-js/qtty-node/index.js +323 -0
  117. package/qtty-js/qtty-node/lib/DerivedQuantity.js +122 -0
  118. package/qtty-js/qtty-node/lib/Quantity.js +151 -0
  119. package/qtty-js/qtty-node/lib/backend.js +25 -0
  120. package/qtty-js/qtty-node/native.cjs +306 -0
  121. package/qtty-js/qtty-node/package-lock.json +3223 -0
  122. package/qtty-js/qtty-node/package.json +70 -0
  123. package/qtty-js/qtty-node/units.d.ts +299 -0
  124. package/qtty-js/qtty-node/units.js +210 -0
  125. package/qtty-js/qtty-web/Cargo.lock +767 -0
  126. package/qtty-js/qtty-web/Cargo.toml +21 -0
  127. package/qtty-js/qtty-web/index.d.ts +140 -0
  128. package/qtty-js/qtty-web/index.js +20 -0
  129. package/qtty-js/qtty-web/lib/DerivedQuantity.js +58 -0
  130. package/qtty-js/qtty-web/lib/Quantity.js +75 -0
  131. package/qtty-js/qtty-web/lib/backend.js +80 -0
  132. package/qtty-js/qtty-web/package.json +45 -0
  133. package/qtty-js/qtty-web/src/lib.rs +111 -0
  134. package/qtty-js/scripts/ci.sh +73 -0
  135. package/scripts/ci.sh +123 -0
  136. package/siderust-core/Cargo.lock +787 -0
  137. package/siderust-core/Cargo.toml +18 -0
  138. package/siderust-core/DEDUPLICATION.md +124 -0
  139. package/siderust-core/src/body.rs +120 -0
  140. package/siderust-core/src/events.rs +184 -0
  141. package/siderust-core/src/lib.rs +20 -0
  142. package/siderust-core/src/observer.rs +55 -0
  143. package/siderust-core/src/position.rs +213 -0
  144. package/siderust-node/.prettierignore +7 -0
  145. package/siderust-node/.prettierrc.json +6 -0
  146. package/siderust-node/Cargo.lock +906 -0
  147. package/siderust-node/Cargo.toml +29 -0
  148. package/siderust-node/README.md +109 -0
  149. package/siderust-node/__test__/index.test.mjs +248 -0
  150. package/siderust-node/build.rs +5 -0
  151. package/siderust-node/c8.config.json +3 -0
  152. package/siderust-node/eslint.config.js +31 -0
  153. package/siderust-node/examples/01_basic_coordinates.mjs +24 -0
  154. package/siderust-node/examples/02_coordinate_transformations.mjs +25 -0
  155. package/siderust-node/examples/03_all_frames_conversions.mjs +26 -0
  156. package/siderust-node/examples/04_all_center_conversions.mjs +24 -0
  157. package/siderust-node/examples/05_target_tracking.mjs +22 -0
  158. package/siderust-node/examples/06_night_events.mjs +18 -0
  159. package/siderust-node/examples/07_moon_properties.mjs +21 -0
  160. package/siderust-node/examples/08_solar_system.mjs +19 -0
  161. package/siderust-node/examples/09_star_observability.mjs +22 -0
  162. package/siderust-node/examples/10_time_periods.mjs +9 -0
  163. package/siderust-node/examples/11_serialization.mjs +31 -0
  164. package/siderust-node/examples/12_runtime_ephemeris.mjs +27 -0
  165. package/siderust-node/examples/13_coordinate_operations.mjs +20 -0
  166. package/siderust-node/index.d.ts +623 -0
  167. package/siderust-node/index.js +79 -0
  168. package/siderust-node/lib/Observer.js +112 -0
  169. package/siderust-node/lib/Star.js +118 -0
  170. package/siderust-node/lib/backend.js +63 -0
  171. package/siderust-node/lib/wrappers.js +566 -0
  172. package/siderust-node/main.js +20 -0
  173. package/siderust-node/native.cjs +360 -0
  174. package/siderust-node/package-lock.json +3261 -0
  175. package/siderust-node/package.json +71 -0
  176. package/siderust-node/src/body.rs +74 -0
  177. package/siderust-node/src/coordinates.rs +372 -0
  178. package/siderust-node/src/ephemeris.rs +462 -0
  179. package/siderust-node/src/events.rs +577 -0
  180. package/siderust-node/src/lib.rs +43 -0
  181. package/siderust-node/src/observer.rs +132 -0
  182. package/siderust-node/src/phase.rs +218 -0
  183. package/siderust-node/src/position.rs +292 -0
  184. package/siderust-node/src/star.rs +200 -0
  185. package/siderust-web/Cargo.lock +855 -0
  186. package/siderust-web/Cargo.toml +34 -0
  187. package/siderust-web/README.md +100 -0
  188. package/siderust-web/__test__/index.test.mjs +118 -0
  189. package/siderust-web/examples/github-pages/README.md +31 -0
  190. package/siderust-web/examples/github-pages/index.html +135 -0
  191. package/siderust-web/index.d.ts +311 -0
  192. package/siderust-web/index.js +66 -0
  193. package/siderust-web/lib/Observer.js +103 -0
  194. package/siderust-web/lib/Star.js +116 -0
  195. package/siderust-web/lib/backend.js +400 -0
  196. package/siderust-web/lib/wrappers.js +512 -0
  197. package/siderust-web/package.json +55 -0
  198. package/siderust-web/src/body.rs +69 -0
  199. package/siderust-web/src/coordinates.rs +302 -0
  200. package/siderust-web/src/ephemeris.rs +456 -0
  201. package/siderust-web/src/events.rs +520 -0
  202. package/siderust-web/src/lib.rs +51 -0
  203. package/siderust-web/src/observer.rs +117 -0
  204. package/siderust-web/src/phase.rs +190 -0
  205. package/siderust-web/src/position.rs +291 -0
  206. package/siderust-web/src/star.rs +178 -0
  207. package/tempoch-js/.github/workflows/ci.yml +142 -0
  208. package/tempoch-js/.gitmodules +3 -0
  209. package/tempoch-js/CHANGELOG.md +25 -0
  210. package/tempoch-js/LICENSE +661 -0
  211. package/tempoch-js/README.md +126 -0
  212. package/tempoch-js/package.json +20 -0
  213. package/tempoch-js/scripts/ci.sh +73 -0
  214. package/tempoch-js/tempoch/.github/workflows/ci.yml +113 -0
  215. package/tempoch-js/tempoch/CHANGELOG.md +82 -0
  216. package/tempoch-js/tempoch/Cargo.lock +947 -0
  217. package/tempoch-js/tempoch/Cargo.toml +3 -0
  218. package/tempoch-js/tempoch/LICENSE +661 -0
  219. package/tempoch-js/tempoch/README.md +76 -0
  220. package/tempoch-js/tempoch/tempoch/Cargo.toml +27 -0
  221. package/tempoch-js/tempoch/tempoch/examples/periods.rs +45 -0
  222. package/tempoch-js/tempoch/tempoch/examples/quickstart.rs +13 -0
  223. package/tempoch-js/tempoch/tempoch/src/lib.rs +49 -0
  224. package/tempoch-js/tempoch/tempoch/tests/integration.rs +57 -0
  225. package/tempoch-js/tempoch/tempoch-core/Cargo.toml +24 -0
  226. package/tempoch-js/tempoch/tempoch-core/src/delta_t.rs +345 -0
  227. package/tempoch-js/tempoch/tempoch-core/src/instant.rs +811 -0
  228. package/tempoch-js/tempoch/tempoch-core/src/julian_date_ext.rs +142 -0
  229. package/tempoch-js/tempoch/tempoch-core/src/lib.rs +81 -0
  230. package/tempoch-js/tempoch/tempoch-core/src/period.rs +1168 -0
  231. package/tempoch-js/tempoch/tempoch-core/src/scales.rs +779 -0
  232. package/tempoch-js/tempoch/tempoch-ffi/Cargo.lock +889 -0
  233. package/tempoch-js/tempoch/tempoch-ffi/Cargo.toml +26 -0
  234. package/tempoch-js/tempoch/tempoch-ffi/build.rs +24 -0
  235. package/tempoch-js/tempoch/tempoch-ffi/cbindgen.toml +30 -0
  236. package/tempoch-js/tempoch/tempoch-ffi/src/error.rs +19 -0
  237. package/tempoch-js/tempoch/tempoch-ffi/src/lib.rs +82 -0
  238. package/tempoch-js/tempoch/tempoch-ffi/src/period.rs +101 -0
  239. package/tempoch-js/tempoch/tempoch-ffi/src/time.rs +711 -0
  240. package/tempoch-js/tempoch/tempoch-ffi/tests/ffi.rs +265 -0
  241. package/tempoch-js/tempoch-node/.prettierignore +6 -0
  242. package/tempoch-js/tempoch-node/.prettierrc.json +6 -0
  243. package/tempoch-js/tempoch-node/Cargo.lock +496 -0
  244. package/tempoch-js/tempoch-node/Cargo.toml +29 -0
  245. package/tempoch-js/tempoch-node/README.md +265 -0
  246. package/tempoch-js/tempoch-node/__test__/index.test.mjs +598 -0
  247. package/tempoch-js/tempoch-node/build.rs +5 -0
  248. package/tempoch-js/tempoch-node/c8.config.json +3 -0
  249. package/tempoch-js/tempoch-node/eslint.config.js +31 -0
  250. package/tempoch-js/tempoch-node/examples/periods.mjs +79 -0
  251. package/tempoch-js/tempoch-node/examples/quickstart.mjs +71 -0
  252. package/tempoch-js/tempoch-node/examples/timescales.mjs +92 -0
  253. package/tempoch-js/tempoch-node/index.d.ts +280 -0
  254. package/tempoch-js/tempoch-node/index.js +32 -0
  255. package/tempoch-js/tempoch-node/lib/JulianDate.js +176 -0
  256. package/tempoch-js/tempoch-node/lib/ModifiedJulianDate.js +156 -0
  257. package/tempoch-js/tempoch-node/lib/Period.js +133 -0
  258. package/tempoch-js/tempoch-node/lib/backend.js +38 -0
  259. package/tempoch-js/tempoch-node/lib/qttyCompat.js +92 -0
  260. package/tempoch-js/tempoch-node/native.cjs +317 -0
  261. package/tempoch-js/tempoch-node/package-lock.json +3223 -0
  262. package/tempoch-js/tempoch-node/package.json +56 -0
  263. package/tempoch-js/tempoch-node/src/lib.rs +573 -0
  264. package/tempoch-js/tempoch-web/Cargo.toml +23 -0
  265. package/tempoch-js/tempoch-web/index.d.ts +95 -0
  266. package/tempoch-js/tempoch-web/index.js +27 -0
  267. package/tempoch-js/tempoch-web/lib/JulianDate.js +170 -0
  268. package/tempoch-js/tempoch-web/lib/ModifiedJulianDate.js +145 -0
  269. package/tempoch-js/tempoch-web/lib/Period.js +121 -0
  270. package/tempoch-js/tempoch-web/lib/backend.js +118 -0
  271. package/tempoch-js/tempoch-web/package.json +46 -0
  272. package/tempoch-js/tempoch-web/src/lib.rs +184 -0
@@ -0,0 +1,34 @@
1
+ [package]
2
+ name = "siderust-web"
3
+ version = "0.1.0"
4
+ edition = "2021"
5
+ authors = ["VPRamon <vallespuigramon@gmail.com>"]
6
+ license = "AGPL-3.0"
7
+ repository = "https://github.com/Siderust/siderust"
8
+ description = "Browser/WASM bindings for siderust — high-precision astronomy in the browser"
9
+ readme = "README.md"
10
+
11
+ [lib]
12
+ crate-type = ["cdylib", "rlib"]
13
+
14
+ [dependencies]
15
+ siderust = { version = "0.6.0", features = [] }
16
+ siderust-binding-core = { path = "../siderust-core" }
17
+ qtty = "0.4.1"
18
+ tempoch = "0.4"
19
+ affn = { version = "0.4.1", features = ["astro"] }
20
+ chrono = "0.4.44"
21
+
22
+ wasm-bindgen = "0.2"
23
+ serde = { version = "1.0", features = ["derive"] }
24
+ serde-wasm-bindgen = "0.6"
25
+ js-sys = "0.3"
26
+ console_error_panic_hook = "0.1"
27
+
28
+ [package.metadata.wasm-pack.profile.release]
29
+ wasm-opt = false
30
+
31
+ [profile.release]
32
+ lto = true
33
+ strip = true
34
+ opt-level = "s"
@@ -0,0 +1,100 @@
1
+ # `@siderust/siderust-web`
2
+
3
+ Browser/WASM bindings for Siderust with the same strict typed API as the
4
+ Node package.
5
+
6
+ Call `init()` before constructing `Quantity`, `JulianDate`, `Observer`, or
7
+ any other typed object used with this package. `init()` bootstraps
8
+ `@siderust/qtty-web`, `@siderust/tempoch-web`, and the main `siderust-web`
9
+ wasm bundle together.
10
+
11
+ ## Install
12
+
13
+ ```bash
14
+ npm install @siderust/siderust-web @siderust/qtty-web @siderust/tempoch-web
15
+ ```
16
+
17
+ ## Example
18
+
19
+ ```js
20
+ import { Quantity } from '@siderust/qtty-web';
21
+ import { JulianDate, ModifiedJulianDate, Period } from '@siderust/tempoch-web';
22
+ import {
23
+ init,
24
+ Observer,
25
+ bodyAltitudeAt,
26
+ bodyCrossings,
27
+ moonPhase,
28
+ vsop87Heliocentric,
29
+ } from '@siderust/siderust-web';
30
+
31
+ await init();
32
+
33
+ const DEG = (value) => new Quantity(value, 'Degree');
34
+ const M = (value) => new Quantity(value, 'Meter');
35
+
36
+ const observer = new Observer(DEG(-17.8925), DEG(28.7543), M(2396));
37
+ const jd = new JulianDate(2_451_545.0);
38
+ const mjd = new ModifiedJulianDate(60_000.0);
39
+ const window = new Period(mjd, new ModifiedJulianDate(60_001.0));
40
+
41
+ console.log(bodyAltitudeAt('Sun', observer, mjd).toString());
42
+ console.log(bodyCrossings('Sun', observer, window, DEG(0)));
43
+ console.log(moonPhase(jd).phaseAngle.toString());
44
+ console.log(vsop87Heliocentric('Mars', jd).x.toString());
45
+ ```
46
+
47
+ ## API shape
48
+
49
+ - `jd` parameters require `JulianDate`.
50
+ - Instant `mjd` parameters require `ModifiedJulianDate`.
51
+ - Search windows use `Period`.
52
+ - Observer/star/domain quantities require `Quantity`.
53
+ - Event timestamps are returned as `ModifiedJulianDate`.
54
+ - Period searches return `Period[]`.
55
+ - Angles, lengths, and other physical outputs return `Quantity`.
56
+
57
+ ## Core exports
58
+
59
+ - `init()`
60
+ - `Observer`
61
+ - `Star`
62
+ - `transformDirection(...)`
63
+ - `directionToHorizontal(...)`
64
+ - `geodeticToEcef(...)`
65
+ - `angularSeparation(...)`
66
+ - `cartesianDistance(...)`
67
+ - `cartesianMagnitude(...)`
68
+ - `directionToCartesian(...)`
69
+ - `vsop87Heliocentric(...)`
70
+ - `vsop87Barycentric(...)`
71
+ - `vsop87SunBarycentric(...)`
72
+ - `vsop87EarthBarycentric(...)`
73
+ - `vsop87EarthHeliocentric(...)`
74
+ - `vsop87MoonGeocentric(...)`
75
+ - `transformPositionCenter(...)`
76
+ - `transformPositionFrame(...)`
77
+ - `orbitalPeriod(...)`
78
+ - `bodyAltitudeAt(...)`
79
+ - `bodyAzimuthAt(...)`
80
+ - `bodyCrossings(...)`
81
+ - `bodyCulminations(...)`
82
+ - `bodyAboveThreshold(...)`
83
+ - `bodyBelowThreshold(...)`
84
+ - `bodyAzimuthCrossings(...)`
85
+ - `bodyAzimuthExtrema(...)`
86
+ - `starAltitudeAt(...)`
87
+ - `starAzimuthAt(...)`
88
+ - `starCrossings(...)`
89
+ - `starCulminations(...)`
90
+ - `starAboveThreshold(...)`
91
+ - `starBelowThreshold(...)`
92
+ - `starAzimuthCrossings(...)`
93
+ - `starAzimuthExtrema(...)`
94
+ - `intersectPeriods(...)`
95
+ - `moonPhase(...)`
96
+ - `moonPhaseTopocentric(...)`
97
+ - `findPhaseEvents(...)`
98
+ - `moonIlluminationAbove(...)`
99
+ - `moonIlluminationBelow(...)`
100
+ - `moonIlluminationRange(...)`
@@ -0,0 +1,118 @@
1
+ import { before, describe, it } from "node:test";
2
+ import assert from "node:assert/strict";
3
+ import { readFile } from "node:fs/promises";
4
+
5
+ import { init as initQtty, Quantity } from "@siderust/qtty-web";
6
+ import {
7
+ init as initTempoch,
8
+ JulianDate,
9
+ ModifiedJulianDate,
10
+ Period,
11
+ } from "@siderust/tempoch-web";
12
+
13
+ import {
14
+ init,
15
+ Observer,
16
+ Star,
17
+ bodyAltitudeAt,
18
+ bodyCrossings,
19
+ moonPhase,
20
+ transformDirection,
21
+ vsop87Heliocentric,
22
+ } from "../index.js";
23
+
24
+ const qttyWasm = new URL(
25
+ "../../../qtty-js/qtty-web/pkg/qtty_web_bg.wasm",
26
+ import.meta.url,
27
+ );
28
+ const tempochWasm = new URL(
29
+ "../../../tempoch-js/tempoch-web/pkg/tempoch_web_bg.wasm",
30
+ import.meta.url,
31
+ );
32
+ const siderustWasm = new URL("../pkg/siderust_web_bg.wasm", import.meta.url);
33
+
34
+ const DEG = (value) => new Quantity(value, "Degree");
35
+ const M = (value) => new Quantity(value, "Meter");
36
+ const LY = (value) => new Quantity(value, "LightYear");
37
+ const SOLAR_MASS = (value) => new Quantity(value, "SolarMass");
38
+ const SOLAR_RADIUS = (value) => new Quantity(value, "NominalSolarRadius");
39
+ const SOLAR_LUMINOSITY = (value) => new Quantity(value, "SolarLuminosity");
40
+
41
+ before(async () => {
42
+ await initQtty(await readFile(qttyWasm));
43
+ await initTempoch(await readFile(tempochWasm));
44
+ await init(await readFile(siderustWasm));
45
+ });
46
+
47
+ describe("@siderust/siderust-web typed API", () => {
48
+ it("constructs typed observer and star objects", () => {
49
+ const observer = new Observer(DEG(-17.8925), DEG(28.7543), M(2396));
50
+ const star = new Star(
51
+ "TypedStar",
52
+ LY(100),
53
+ SOLAR_MASS(2),
54
+ SOLAR_RADIUS(1.5),
55
+ SOLAR_LUMINOSITY(8),
56
+ DEG(180),
57
+ DEG(-45),
58
+ );
59
+
60
+ assert.equal(observer.lon.unit, "Degree");
61
+ assert.equal(observer.height.unit, "Meter");
62
+ assert.equal(star.distance.unit, "LightYear");
63
+ assert.equal(star.ra.unit, "Degree");
64
+ });
65
+
66
+ it("rejects raw numbers", () => {
67
+ assert.throws(
68
+ () => new Observer(-17.8925, 28.7543, 2396),
69
+ /expected a Quantity/,
70
+ );
71
+ assert.throws(
72
+ () => vsop87Heliocentric("Mars", 2_451_545.0),
73
+ /Expected a JulianDate/,
74
+ );
75
+ });
76
+
77
+ it("returns typed direction and position results", () => {
78
+ const direction = transformDirection(
79
+ DEG(38.78),
80
+ DEG(279.23),
81
+ "EquatorialMeanJ2000",
82
+ "EclipticMeanJ2000",
83
+ new JulianDate(2_451_545.0),
84
+ );
85
+ const mars = vsop87Heliocentric("Mars", new JulianDate(2_451_545.0));
86
+
87
+ assert.equal(direction.polar.unit, "Degree");
88
+ assert.equal(direction.azimuth.unit, "Degree");
89
+ assert.equal(mars.x.unit, "AstronomicalUnit");
90
+ assert.equal(mars.center, "Heliocentric");
91
+ });
92
+
93
+ it("returns typed event values", () => {
94
+ const observer = Observer.roqueDeLasMuchachos();
95
+ const window = new Period(
96
+ new ModifiedJulianDate(60_000.0),
97
+ new ModifiedJulianDate(60_001.0),
98
+ );
99
+ const altitude = bodyAltitudeAt(
100
+ "Sun",
101
+ observer,
102
+ new ModifiedJulianDate(60_000.0),
103
+ );
104
+ const crossings = bodyCrossings("Sun", observer, window, DEG(0));
105
+
106
+ assert.equal(altitude.unit, "Degree");
107
+ for (const event of crossings) {
108
+ assert.ok(event.mjd instanceof ModifiedJulianDate);
109
+ }
110
+ });
111
+
112
+ it("returns typed moon phase values", () => {
113
+ const phase = moonPhase(new JulianDate(2_451_545.0));
114
+ assert.equal(phase.phaseAngle.unit, "Degree");
115
+ assert.equal(phase.elongation.unit, "Degree");
116
+ assert.equal(typeof phase.illuminatedFraction, "number");
117
+ });
118
+ });
@@ -0,0 +1,31 @@
1
+ # GitHub Pages Example
2
+
3
+ This demo goes through the public `@siderust/siderust-web` API and uses
4
+ `@siderust/qtty-web` plus `@siderust/tempoch-web` explicitly for typed
5
+ inputs.
6
+
7
+ ## Build the local packages
8
+
9
+ ```bash
10
+ cd ../../../qtty-js/qtty-web
11
+ npm run build
12
+
13
+ cd ../../tempoch-js/tempoch-web
14
+ npm run build
15
+
16
+ cd ../../siderust-js/siderust-web
17
+ npm run build
18
+ ```
19
+
20
+ ## Serve the example
21
+
22
+ From `javascript/siderust-js/siderust-web/examples/github-pages`:
23
+
24
+ ```bash
25
+ python3 -m http.server 8080
26
+ ```
27
+
28
+ Then open <http://localhost:8080/index.html>.
29
+
30
+ The page uses an `importmap` that points at the sibling `qtty-web`,
31
+ `tempoch-web`, and `siderust-web` packages in this workspace.
@@ -0,0 +1,135 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
6
+ <title>Siderust Typed Browser Demo</title>
7
+ <style>
8
+ :root {
9
+ --bg: #f6f3ec;
10
+ --ink: #1f2430;
11
+ --accent: #8b5e34;
12
+ --panel: #fffaf2;
13
+ --line: #dbcdb7;
14
+ }
15
+ * { box-sizing: border-box; }
16
+ body {
17
+ margin: 0;
18
+ font-family: Georgia, "Iowan Old Style", serif;
19
+ background:
20
+ radial-gradient(circle at top left, #fff6e4 0, transparent 32%),
21
+ linear-gradient(180deg, #f0e7d7, var(--bg));
22
+ color: var(--ink);
23
+ min-height: 100vh;
24
+ padding: 2rem;
25
+ }
26
+ main {
27
+ max-width: 900px;
28
+ margin: 0 auto;
29
+ background: rgba(255, 250, 242, 0.92);
30
+ border: 1px solid var(--line);
31
+ border-radius: 18px;
32
+ padding: 1.5rem;
33
+ box-shadow: 0 30px 80px rgba(31, 36, 48, 0.12);
34
+ }
35
+ h1, h2 { margin: 0 0 0.75rem; color: var(--accent); }
36
+ p { line-height: 1.55; }
37
+ .grid {
38
+ display: grid;
39
+ grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
40
+ gap: 1rem;
41
+ margin-top: 1rem;
42
+ }
43
+ .card {
44
+ background: var(--panel);
45
+ border: 1px solid var(--line);
46
+ border-radius: 14px;
47
+ padding: 1rem;
48
+ }
49
+ pre {
50
+ margin: 0;
51
+ white-space: pre-wrap;
52
+ font-family: "SFMono-Regular", Consolas, monospace;
53
+ font-size: 0.88rem;
54
+ }
55
+ .status { margin-bottom: 1rem; }
56
+ </style>
57
+ <script type="importmap">
58
+ {
59
+ "imports": {
60
+ "@siderust/qtty-web": "../../../../qtty-js/qtty-web/index.js",
61
+ "@siderust/tempoch-web": "../../../../tempoch-js/tempoch-web/index.js",
62
+ "@siderust/siderust-web": "../../index.js"
63
+ }
64
+ }
65
+ </script>
66
+ </head>
67
+ <body>
68
+ <main>
69
+ <h1>Siderust Browser Demo</h1>
70
+ <p class="status" id="status">Loading typed wasm packages…</p>
71
+
72
+ <div class="grid">
73
+ <section class="card">
74
+ <h2>Observer</h2>
75
+ <pre id="observer"></pre>
76
+ </section>
77
+ <section class="card">
78
+ <h2>Sun</h2>
79
+ <pre id="sun"></pre>
80
+ </section>
81
+ <section class="card">
82
+ <h2>Moon</h2>
83
+ <pre id="moon"></pre>
84
+ </section>
85
+ <section class="card">
86
+ <h2>Mars</h2>
87
+ <pre id="mars"></pre>
88
+ </section>
89
+ </div>
90
+ </main>
91
+
92
+ <script type="module">
93
+ import { Quantity } from '@siderust/qtty-web';
94
+ import { JulianDate, ModifiedJulianDate, Period } from '@siderust/tempoch-web';
95
+ import {
96
+ init,
97
+ Observer,
98
+ bodyAltitudeAt,
99
+ bodyCrossings,
100
+ moonPhase,
101
+ vsop87Heliocentric,
102
+ } from '@siderust/siderust-web';
103
+
104
+ const DEG = (value) => new Quantity(value, 'Degree');
105
+ const statusEl = document.getElementById('status');
106
+
107
+ try {
108
+ await init(new URL('../../pkg/siderust_web_bg.wasm', import.meta.url));
109
+
110
+ const observer = new Observer(DEG(-17.8925), DEG(28.7543), new Quantity(2396, 'Meter'));
111
+ const jd = new JulianDate(2_451_545.0);
112
+ const mjd = new ModifiedJulianDate(60_000.0);
113
+ const window = new Period(mjd, new ModifiedJulianDate(60_001.0));
114
+
115
+ const sunAltitude = bodyAltitudeAt('Sun', observer, mjd);
116
+ const sunCrossings = bodyCrossings('Sun', observer, window, DEG(0));
117
+ const phase = moonPhase(jd);
118
+ const mars = vsop87Heliocentric('Mars', jd);
119
+
120
+ document.getElementById('observer').textContent = observer.format();
121
+ document.getElementById('sun').textContent =
122
+ `Altitude: ${sunAltitude.toString()}\nCrossings in next day: ${sunCrossings.length}`;
123
+ document.getElementById('moon').textContent =
124
+ `Phase: ${phase.label}\nElongation: ${phase.elongation.toString()}\nIlluminated: ${(phase.illuminatedFraction * 100).toFixed(1)}%`;
125
+ document.getElementById('mars').textContent =
126
+ `X: ${mars.x.toString()}\nY: ${mars.y.toString()}\nZ: ${mars.z.toString()}`;
127
+
128
+ statusEl.textContent = 'Typed browser API loaded successfully.';
129
+ } catch (error) {
130
+ statusEl.textContent = `Failed to initialize: ${error.message}`;
131
+ throw error;
132
+ }
133
+ </script>
134
+ </body>
135
+ </html>