@johnmorrisdotca/wakusei-planets 0.20.0 → 0.21.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 (83) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/NOTICE.md +9 -0
  3. package/README.md +34 -4
  4. package/dist/bodies/earth.js +13 -5
  5. package/dist/calendar.js +7 -6
  6. package/dist/clock.js +5 -6
  7. package/dist/coordinates.d.ts +7 -12
  8. package/dist/coordinates.js +19 -18
  9. package/dist/craft/cassini.d.ts +1 -0
  10. package/dist/craft/cassini.js +1131 -0
  11. package/dist/craft/galileo.d.ts +1 -0
  12. package/dist/craft/galileo.js +224 -0
  13. package/dist/craft/juno.d.ts +1 -0
  14. package/dist/craft/juno.js +640 -0
  15. package/dist/craft/newhorizons.d.ts +1 -0
  16. package/dist/craft/newhorizons.js +18 -0
  17. package/dist/craft/parker.d.ts +1 -0
  18. package/dist/craft/parker.js +221 -0
  19. package/dist/craft/pioneer10.d.ts +1 -0
  20. package/dist/craft/pioneer10.js +24 -0
  21. package/dist/craft/pioneer11.d.ts +1 -0
  22. package/dist/craft/pioneer11.js +34 -0
  23. package/dist/craft/voyager1.d.ts +1 -0
  24. package/dist/craft/voyager1.js +28 -0
  25. package/dist/craft/voyager2.d.ts +1 -0
  26. package/dist/craft/voyager2.js +43 -0
  27. package/dist/craft/webb.d.ts +1 -0
  28. package/dist/craft/webb.js +28 -0
  29. package/dist/data/craft.d.ts +23 -0
  30. package/dist/data/craft.js +53 -0
  31. package/dist/data/stars.d.ts +4 -0
  32. package/dist/data/stars.js +5088 -0
  33. package/dist/element.d.ts +1 -23
  34. package/dist/element.js +74 -110
  35. package/dist/ephemeris.d.ts +20 -0
  36. package/dist/ephemeris.js +51 -20
  37. package/dist/index.d.ts +1 -1
  38. package/dist/index.js +1 -1
  39. package/dist/portrait/element.d.ts +1 -0
  40. package/dist/portrait/element.js +27 -39
  41. package/dist/scene/basis.d.ts +3 -0
  42. package/dist/scene/basis.js +4 -0
  43. package/dist/scene/body.d.ts +2 -4
  44. package/dist/scene/body.js +55 -67
  45. package/dist/scene/fallback.d.ts +4 -0
  46. package/dist/scene/fallback.js +5 -0
  47. package/dist/scene/painter.js +10 -23
  48. package/dist/scene/store.d.ts +2 -2
  49. package/dist/scene/textures.d.ts +30 -0
  50. package/dist/scene/textures.js +47 -0
  51. package/dist/sidereal.d.ts +4 -0
  52. package/dist/sidereal.js +15 -9
  53. package/dist/sky/engine.d.ts +6 -15
  54. package/dist/sky/engine.js +9 -38
  55. package/dist/sky/frames.d.ts +3 -0
  56. package/dist/sky/frames.js +26 -0
  57. package/dist/sky/types.d.ts +20 -0
  58. package/dist/sky/types.js +1 -0
  59. package/dist/space/aim.d.ts +18 -0
  60. package/dist/space/aim.js +28 -0
  61. package/dist/space/element.d.ts +212 -0
  62. package/dist/space/element.js +524 -0
  63. package/dist/space/frame.d.ts +152 -0
  64. package/dist/space/frame.js +169 -0
  65. package/dist/space/index.d.ts +4 -0
  66. package/dist/space/index.js +5 -0
  67. package/dist/space/ride.d.ts +89 -0
  68. package/dist/space/ride.js +58 -0
  69. package/dist/space/scale.d.ts +126 -0
  70. package/dist/space/scale.js +139 -0
  71. package/dist/space/scene.d.ts +189 -0
  72. package/dist/space/scene.js +422 -0
  73. package/dist/spacecraft-facts.d.ts +114 -0
  74. package/dist/spacecraft-facts.js +215 -0
  75. package/dist/spacecraft.d.ts +134 -0
  76. package/dist/spacecraft.js +198 -0
  77. package/dist/stars.d.ts +160 -0
  78. package/dist/stars.js +193 -0
  79. package/dist/suncalc.js +4 -10
  80. package/dist/version.d.ts +1 -1
  81. package/dist/version.js +1 -1
  82. package/dist/when.js +6 -11
  83. package/package.json +53 -4
@@ -0,0 +1,160 @@
1
+ import { type When } from "./when.ts";
2
+ /**
3
+ * One star, as the Yale Bright Star Catalogue gives it. Positions are J2000 (equator and equinox of 2000, the FK5 frame, which is the ICRS to a fraction of an arc-second).
4
+ *
5
+ * @example
6
+ * ```ts
7
+ * import { starByName, type Star } from "@johnmorrisdotca/wakusei-planets/stars";
8
+ *
9
+ * const sirius: Star = starByName("Sirius")!;
10
+ * console.log(sirius.designation, sirius.magnitude);
11
+ * ```
12
+ */
13
+ export interface Star {
14
+ /** The Bright Star Catalogue (Harvard Revised) number: stable, and the key for `starByHr`. */
15
+ hr: number;
16
+ /** The common name where the star has one (the IAU Working Group on Star Names' spelling), else `undefined`. */
17
+ name: string | undefined;
18
+ /** The Bayer letter and constellation (`α CMa`), else the Flamsteed number and constellation (`9 CMa`), else `undefined`. */
19
+ designation: string | undefined;
20
+ /** The IAU three-letter constellation abbreviation (`CMa`) where the star has a Bayer or Flamsteed name, else `undefined`. */
21
+ constellation: string | undefined;
22
+ /** Right ascension in degrees at J2000, 0 up to 360. The catalogue gives it to a tenth of a second of time (1.5 arc-seconds at the equator). */
23
+ rightAscension: number;
24
+ /** Declination in degrees at J2000, -90 to 90. The catalogue gives it to an arc-second. */
25
+ declination: number;
26
+ /** Visual magnitude: smaller is brighter, and Sirius is -1.46. */
27
+ magnitude: number;
28
+ /** The colour index B-V in magnitudes, or `undefined` where the catalogue has none. Hot blue stars are about -0.3, the Sun 0.65, cool red stars above 1.5. */
29
+ colourIndex: number | undefined;
30
+ /** The spectral class and subclass (`A1`, `K1`), or an empty string where the catalogue gives none we read. */
31
+ spectralClass: string;
32
+ /** Proper motion in right ascension, in milliarcseconds a year, already multiplied by cos(declination) (a true angle on the sky). */
33
+ properMotionRaMas: number;
34
+ /** Proper motion in declination, in milliarcseconds a year. */
35
+ properMotionDecMas: number;
36
+ /** The annual parallax in milliarcseconds; 0 where the catalogue has none (the distance is then unknown). */
37
+ parallaxMas: number;
38
+ }
39
+ /**
40
+ * The stars to a magnitude, brightest first. The catalogue stops at magnitude 6.0, so the default is all 5,080.
41
+ *
42
+ * @param options - `magnitude`: the faintest to include (a star of exactly that magnitude is in). Brighter limits give shorter lists: 1.5 is 15 stars, 4 is 518, 5 is 1,630.
43
+ * @returns A fresh array of the shared, frozen stars.
44
+ *
45
+ * @example
46
+ * ```ts
47
+ * import { stars } from "@johnmorrisdotca/wakusei-planets/stars";
48
+ *
49
+ * console.log(stars().length, stars({ magnitude: 2 }).map((s) => s.name ?? s.designation).slice(0, 3));
50
+ * ```
51
+ */
52
+ export declare function stars(options?: {
53
+ magnitude?: number;
54
+ }): Star[];
55
+ /**
56
+ * A star by its Bright Star Catalogue number.
57
+ *
58
+ * @param hr - The HR number (Sirius is 2491).
59
+ * @returns The star, or `undefined` if that number is not in this table (the table holds the stars to magnitude 6.0 only).
60
+ *
61
+ * @example
62
+ * ```ts
63
+ * import { starByHr } from "@johnmorrisdotca/wakusei-planets/stars";
64
+ *
65
+ * console.log(starByHr(2491)?.name);
66
+ * ```
67
+ */
68
+ export declare function starByHr(hr: number): Star | undefined;
69
+ /**
70
+ * A star by its common name (`Sirius`) or its designation (`α CMa`, `9 CMa`), ignoring case.
71
+ *
72
+ * @param text - The name or designation.
73
+ * @returns The star, or `undefined`.
74
+ *
75
+ * @example
76
+ * ```ts
77
+ * import { starByName } from "@johnmorrisdotca/wakusei-planets/stars";
78
+ *
79
+ * console.log(starByName("betelgeuse")?.designation, starByName("α Lyr")?.name);
80
+ * ```
81
+ */
82
+ export declare function starByName(text: string): Star | undefined;
83
+ /**
84
+ * Where a star is at a moment: its J2000 position carried forward (or back) by its proper motion in a straight line. The frame stays J2000, so precession to the date is not applied: use
85
+ * the result with J2000 coordinates, or convert it to the date with `/coordinates`. A straight line is good to a fraction of an arc-second for centuries for nearly every star here; it is
86
+ * not good for the few with large motion over millennia.
87
+ *
88
+ * @param star - A star.
89
+ * @param when - The moment as a `Date` or milliseconds since 1970 (UTC); J2000 when left out.
90
+ * @returns Right ascension and declination in degrees, J2000 frame, at that moment.
91
+ *
92
+ * @example
93
+ * ```ts
94
+ * import { starByName, starPosition } from "@johnmorrisdotca/wakusei-planets/stars";
95
+ *
96
+ * const now = starPosition(starByName("Arcturus")!, Date.UTC(2026, 10, 7));
97
+ * console.log(now.declination.toFixed(3));
98
+ * ```
99
+ */
100
+ export declare function starPosition(star: Star, when?: When): {
101
+ rightAscension: number;
102
+ declination: number;
103
+ };
104
+ /**
105
+ * A star's distance from its parallax, in light-years.
106
+ *
107
+ * @param star - A star.
108
+ * @returns Light-years, or `undefined` where the catalogue has no parallax (or a non-positive one).
109
+ *
110
+ * @example
111
+ * ```ts
112
+ * import { starByName, starDistanceLightYears } from "@johnmorrisdotca/wakusei-planets/stars";
113
+ *
114
+ * console.log(starDistanceLightYears(starByName("Sirius")!)?.toFixed(1));
115
+ * ```
116
+ */
117
+ export declare function starDistanceLightYears(star: Star): number | undefined;
118
+ /**
119
+ * The surface temperature a colour index implies, in kelvin, by Ballesteros's relation between B-V and a black body. It is an estimate to a few hundred kelvin for most stars, and it runs cool for the hottest (about 16,600 K at -0.3).
120
+ *
121
+ * @param colourIndex - B-V in magnitudes.
122
+ * @returns Kelvin.
123
+ *
124
+ * @example
125
+ * ```ts
126
+ * import { starTemperatureK } from "@johnmorrisdotca/wakusei-planets/stars";
127
+ *
128
+ * console.log(Math.round(starTemperatureK(0.65)));
129
+ * ```
130
+ */
131
+ export declare function starTemperatureK(colourIndex: number): number;
132
+ /**
133
+ * The colour of a black body at a temperature, as a `#rrggbb` string, for drawing a star. It is the colour a camera would show, not a measurement, and it uses an approximation of the
134
+ * black-body locus (good to a few percent between 1,000 and 40,000 K).
135
+ *
136
+ * @param kelvin - Temperature in kelvin.
137
+ * @returns A colour like `#a4bdff`.
138
+ *
139
+ * @example
140
+ * ```ts
141
+ * import { blackBodyColour } from "@johnmorrisdotca/wakusei-planets/stars";
142
+ *
143
+ * console.log(blackBodyColour(10000), blackBodyColour(3500));
144
+ * ```
145
+ */
146
+ export declare function blackBodyColour(kelvin: number): string;
147
+ /**
148
+ * The colour to draw a star: from its B-V index, or a plain white where the catalogue has none.
149
+ *
150
+ * @param star - A star.
151
+ * @returns A `#rrggbb` string.
152
+ *
153
+ * @example
154
+ * ```ts
155
+ * import { starByName, starColour } from "@johnmorrisdotca/wakusei-planets/stars";
156
+ *
157
+ * console.log(starColour(starByName("Betelgeuse")!), starColour(starByName("Rigel")!));
158
+ * ```
159
+ */
160
+ export declare function starColour(star: Star): string;
package/dist/stars.js ADDED
@@ -0,0 +1,193 @@
1
+ // The stars you can see without a telescope: the 5,080 of the Yale Bright Star Catalogue to visual magnitude 6.0, with their names, positions, proper motion, brightness and colour.
2
+ // An opt-in entry point (`@johnmorrisdotca/wakusei-planets/stars`): the table is about 100 kB gzipped and nothing else imports it. Pure: no DOM, no three.js, no state beyond the parsed table.
3
+ import { J2000_MS } from "./clock.js";
4
+ import { STAR_NAMES, STAR_ROWS } from "./data/stars.js";
5
+ import { moment } from "./when.js";
6
+ const stored = [];
7
+ const byHr = new Map();
8
+ const byText = new Map();
9
+ function load() {
10
+ if (stored.length > 0)
11
+ return;
12
+ for (const row of STAR_ROWS.split("\n")) {
13
+ const p = row.split("|");
14
+ const hr = Number(p[0]);
15
+ const letter = p[1];
16
+ const flamsteed = p[2];
17
+ const constellation = p[3];
18
+ const designation = constellation === "" ? undefined : `${letter !== "" ? letter : flamsteed} ${constellation}`;
19
+ const star = Object.freeze({
20
+ hr,
21
+ name: STAR_NAMES[hr],
22
+ designation: letter === "" && flamsteed === "" ? undefined : designation,
23
+ constellation: constellation === "" ? undefined : constellation,
24
+ rightAscension: (Number(p[4]) / 2400),
25
+ declination: Number(p[5]) / 3600,
26
+ magnitude: Number(p[8]) / 100,
27
+ colourIndex: p[9] === "" ? undefined : Number(p[9]) / 100,
28
+ spectralClass: p[10],
29
+ properMotionRaMas: Number(p[6]),
30
+ properMotionDecMas: Number(p[7]),
31
+ parallaxMas: Number(p[11]),
32
+ });
33
+ stored.push(star);
34
+ byHr.set(hr, star);
35
+ for (const text of [star.name, star.designation])
36
+ if (text !== undefined)
37
+ byText.set(text.toLowerCase(), star);
38
+ }
39
+ }
40
+ /**
41
+ * The stars to a magnitude, brightest first. The catalogue stops at magnitude 6.0, so the default is all 5,080.
42
+ *
43
+ * @param options - `magnitude`: the faintest to include (a star of exactly that magnitude is in). Brighter limits give shorter lists: 1.5 is 15 stars, 4 is 518, 5 is 1,630.
44
+ * @returns A fresh array of the shared, frozen stars.
45
+ *
46
+ * @example
47
+ * ```ts
48
+ * import { stars } from "@johnmorrisdotca/wakusei-planets/stars";
49
+ *
50
+ * console.log(stars().length, stars({ magnitude: 2 }).map((s) => s.name ?? s.designation).slice(0, 3));
51
+ * ```
52
+ */
53
+ export function stars(options = {}) {
54
+ load();
55
+ const limit = options.magnitude ?? Number.POSITIVE_INFINITY;
56
+ if (typeof limit !== "number" || Number.isNaN(limit))
57
+ throw new TypeError(`magnitude must be a number, got ${String(limit)}`);
58
+ return stored.filter((star) => star.magnitude <= limit);
59
+ }
60
+ /**
61
+ * A star by its Bright Star Catalogue number.
62
+ *
63
+ * @param hr - The HR number (Sirius is 2491).
64
+ * @returns The star, or `undefined` if that number is not in this table (the table holds the stars to magnitude 6.0 only).
65
+ *
66
+ * @example
67
+ * ```ts
68
+ * import { starByHr } from "@johnmorrisdotca/wakusei-planets/stars";
69
+ *
70
+ * console.log(starByHr(2491)?.name);
71
+ * ```
72
+ */
73
+ export function starByHr(hr) {
74
+ load();
75
+ return byHr.get(hr);
76
+ }
77
+ /**
78
+ * A star by its common name (`Sirius`) or its designation (`α CMa`, `9 CMa`), ignoring case.
79
+ *
80
+ * @param text - The name or designation.
81
+ * @returns The star, or `undefined`.
82
+ *
83
+ * @example
84
+ * ```ts
85
+ * import { starByName } from "@johnmorrisdotca/wakusei-planets/stars";
86
+ *
87
+ * console.log(starByName("betelgeuse")?.designation, starByName("α Lyr")?.name);
88
+ * ```
89
+ */
90
+ export function starByName(text) {
91
+ load();
92
+ return byText.get(text.trim().toLowerCase());
93
+ }
94
+ const JULIAN_YEAR_MS = 365.25 * 86_400_000;
95
+ /**
96
+ * Where a star is at a moment: its J2000 position carried forward (or back) by its proper motion in a straight line. The frame stays J2000, so precession to the date is not applied: use
97
+ * the result with J2000 coordinates, or convert it to the date with `/coordinates`. A straight line is good to a fraction of an arc-second for centuries for nearly every star here; it is
98
+ * not good for the few with large motion over millennia.
99
+ *
100
+ * @param star - A star.
101
+ * @param when - The moment as a `Date` or milliseconds since 1970 (UTC); J2000 when left out.
102
+ * @returns Right ascension and declination in degrees, J2000 frame, at that moment.
103
+ *
104
+ * @example
105
+ * ```ts
106
+ * import { starByName, starPosition } from "@johnmorrisdotca/wakusei-planets/stars";
107
+ *
108
+ * const now = starPosition(starByName("Arcturus")!, Date.UTC(2026, 10, 7));
109
+ * console.log(now.declination.toFixed(3));
110
+ * ```
111
+ */
112
+ export function starPosition(star, when) {
113
+ const years = (moment(when ?? J2000_MS) - J2000_MS) / JULIAN_YEAR_MS;
114
+ const declination = star.declination + (star.properMotionDecMas * years) / 3_600_000;
115
+ const cosine = Math.cos((star.declination * Math.PI) / 180);
116
+ // The motion is a true angle on the sky: it stretches by 1 / cos(declination) in right ascension. At the poles the division is kept finite.
117
+ const rightAscension = star.rightAscension + (star.properMotionRaMas * years) / 3_600_000 / Math.max(Math.abs(cosine), 1e-6);
118
+ return { rightAscension: ((rightAscension % 360) + 360) % 360, declination: Math.max(-90, Math.min(90, declination)) };
119
+ }
120
+ /**
121
+ * A star's distance from its parallax, in light-years.
122
+ *
123
+ * @param star - A star.
124
+ * @returns Light-years, or `undefined` where the catalogue has no parallax (or a non-positive one).
125
+ *
126
+ * @example
127
+ * ```ts
128
+ * import { starByName, starDistanceLightYears } from "@johnmorrisdotca/wakusei-planets/stars";
129
+ *
130
+ * console.log(starDistanceLightYears(starByName("Sirius")!)?.toFixed(1));
131
+ * ```
132
+ */
133
+ export function starDistanceLightYears(star) {
134
+ return star.parallaxMas > 0 ? 3261.563777 / star.parallaxMas : undefined;
135
+ }
136
+ /**
137
+ * The surface temperature a colour index implies, in kelvin, by Ballesteros's relation between B-V and a black body. It is an estimate to a few hundred kelvin for most stars, and it runs cool for the hottest (about 16,600 K at -0.3).
138
+ *
139
+ * @param colourIndex - B-V in magnitudes.
140
+ * @returns Kelvin.
141
+ *
142
+ * @example
143
+ * ```ts
144
+ * import { starTemperatureK } from "@johnmorrisdotca/wakusei-planets/stars";
145
+ *
146
+ * console.log(Math.round(starTemperatureK(0.65)));
147
+ * ```
148
+ */
149
+ export function starTemperatureK(colourIndex) {
150
+ if (!Number.isFinite(colourIndex))
151
+ throw new RangeError(`colourIndex must be a finite number, got ${colourIndex}`);
152
+ return 4600 * (1 / (0.92 * colourIndex + 1.7) + 1 / (0.92 * colourIndex + 0.62));
153
+ }
154
+ /**
155
+ * The colour of a black body at a temperature, as a `#rrggbb` string, for drawing a star. It is the colour a camera would show, not a measurement, and it uses an approximation of the
156
+ * black-body locus (good to a few percent between 1,000 and 40,000 K).
157
+ *
158
+ * @param kelvin - Temperature in kelvin.
159
+ * @returns A colour like `#a4bdff`.
160
+ *
161
+ * @example
162
+ * ```ts
163
+ * import { blackBodyColour } from "@johnmorrisdotca/wakusei-planets/stars";
164
+ *
165
+ * console.log(blackBodyColour(10000), blackBodyColour(3500));
166
+ * ```
167
+ */
168
+ export function blackBodyColour(kelvin) {
169
+ if (!Number.isFinite(kelvin) || kelvin <= 0)
170
+ throw new RangeError(`kelvin must be a positive number, got ${kelvin}`);
171
+ const t = Math.min(40_000, Math.max(1_000, kelvin)) / 100;
172
+ const red = t <= 66 ? 255 : 329.698727446 * (t - 60) ** -0.1332047592;
173
+ const green = t <= 66 ? 99.4708025861 * Math.log(t) - 161.1195681661 : 288.1221695283 * (t - 60) ** -0.0755148492;
174
+ const blue = t >= 66 ? 255 : t <= 19 ? 0 : 138.5177312231 * Math.log(t - 10) - 305.0447927307;
175
+ const byte = (v) => Math.round(Math.min(255, Math.max(0, v))).toString(16).padStart(2, "0");
176
+ return `#${byte(red)}${byte(green)}${byte(blue)}`;
177
+ }
178
+ /**
179
+ * The colour to draw a star: from its B-V index, or a plain white where the catalogue has none.
180
+ *
181
+ * @param star - A star.
182
+ * @returns A `#rrggbb` string.
183
+ *
184
+ * @example
185
+ * ```ts
186
+ * import { starByName, starColour } from "@johnmorrisdotca/wakusei-planets/stars";
187
+ *
188
+ * console.log(starColour(starByName("Betelgeuse")!), starColour(starByName("Rigel")!));
189
+ * ```
190
+ */
191
+ export function starColour(star) {
192
+ return star.colourIndex === undefined ? "#ffffff" : blackBodyColour(starTemperatureK(star.colourIndex));
193
+ }
package/dist/suncalc.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // The sun and moon from a place, with the names, arguments and results of suncalc 2 (degrees, azimuth clockwise from north), written from the public methods on this package's own positions:
2
- // the Sun from VSOP87B, the Moon from ELP2000-82B, with parallax, refraction and the Earth's turn. It is accurate to seconds of time for the Sun and about ten seconds for the Moon, where
3
- // suncalc is accurate to a minute or two. Pure: no DOM, no three.js. `import { getTimes } from "@johnmorrisdotca/wakusei-planets/suncalc"` instead of from "suncalc" changes nothing else.
2
+ // the Sun from VSOP87B, the Moon from ELP2000-82B, with parallax, refraction and the Earth's turn. Its rise and set times are within half a second of JPL Horizons for both,
3
+ // where suncalc 2.1.2 is within 5 to 7 seconds (scripts/compare/rise-set.mjs). Pure: no DOM, no three.js. `import { getTimes } from "@johnmorrisdotca/wakusei-planets/suncalc"` instead of from "suncalc" changes nothing else.
4
4
  import { horizontalOf, moonEquatorial, moonPhase, refraction, sunEquatorial } from "./sky/engine.js";
5
5
  import { dayWindow, moment, moonDay, place, sunDay } from "./sky/events.js";
6
6
  /**
@@ -118,7 +118,7 @@ export function getMoonIllumination(date = new Date()) {
118
118
  * ```
119
119
  */
120
120
  export function getTimes(date, lat, lng, height = 0, utcOffset) {
121
- const day = sunDay(moment(date), place(lat, lng, height), checkOffset(utcOffset), times);
121
+ const day = sunDay(moment(date), place(lat, lng, height), utcOffset, times);
122
122
  const result = { solarNoon: new Date(day.noon), nadir: new Date(day.nadir) };
123
123
  for (const [name, at] of day.events)
124
124
  result[name] = at === null ? null : new Date(at);
@@ -148,7 +148,7 @@ export function getTimes(date, lat, lng, height = 0, utcOffset) {
148
148
  export function getMoonTimes(date, lat, lng, utcOffset) {
149
149
  const ms = moment(date);
150
150
  const observer = place(lat, lng);
151
- const [start, end] = dayWindow(ms, observer, checkOffset(utcOffset));
151
+ const [start, end] = dayWindow(ms, observer, utcOffset);
152
152
  const day = moonDay(start, end, observer);
153
153
  const result = {};
154
154
  if (day.rise !== null)
@@ -165,9 +165,3 @@ export function getMoonTimes(date, lat, lng, utcOffset) {
165
165
  result.alwaysDown = true;
166
166
  return result;
167
167
  }
168
- /** A UTC offset in minutes, or undefined, throwing on anything else. */
169
- function checkOffset(utcOffset) {
170
- if (utcOffset !== undefined && !Number.isFinite(utcOffset))
171
- throw new RangeError(`utcOffset must be a finite number of minutes east of UTC, got ${utcOffset}`);
172
- return utcOffset;
173
- }
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const VERSION = "0.20.0";
1
+ export declare const VERSION = "0.21.0";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const VERSION = "0.20.0";
1
+ export const VERSION = "0.21.0";
package/dist/when.js CHANGED
@@ -3,16 +3,11 @@
3
3
  * A moment as milliseconds since 1970. A `Date` is never changed. An invalid `Date`, a number that is not finite or anything else throws, naming the argument and the value.
4
4
  */
5
5
  export function moment(when, name = "when") {
6
- if (typeof when === "number") {
7
- if (Number.isFinite(when))
8
- return when;
9
- }
10
- else if (typeof when?.getTime === "function") {
11
- const ms = when.getTime();
12
- if (Number.isFinite(ms))
13
- return ms;
14
- }
15
- else
6
+ if (typeof when !== "number" && typeof when?.getTime !== "function") {
16
7
  throw new TypeError(`${name} must be a Date or a number of milliseconds since 1970, got ${typeof when}`);
17
- throw new RangeError(`${name} must be a valid Date or a finite number of milliseconds since 1970, got ${String(when)}`);
8
+ }
9
+ const ms = typeof when === "number" ? when : when.getTime();
10
+ if (!Number.isFinite(ms))
11
+ throw new RangeError(`${name} must be a valid Date or a finite number of milliseconds since 1970, got ${String(when)}`);
12
+ return ms;
18
13
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@johnmorrisdotca/wakusei-planets",
3
- "version": "0.20.0",
3
+ "version": "0.21.0",
4
4
  "description": "Wakusei Planets 惑星 — The Sun, planets and moons for the web: each as a clean line drawing, a shaded realistic drawing or a painted surface map, with real sizes, axial tilt and rotation as data, and positions of the moons for any date and time. SVG for the lines, three.js (optional) for the rest.",
5
5
  "keywords": [
6
6
  "planets",
@@ -44,7 +44,32 @@
44
44
  "epoch",
45
45
  "time-scales",
46
46
  "leap-seconds",
47
- "sidereal-time"
47
+ "sidereal-time",
48
+ "spaceprogramx",
49
+ "spx",
50
+ "suncalc",
51
+ "sunrise",
52
+ "sunset",
53
+ "twilight",
54
+ "dawn",
55
+ "dusk",
56
+ "moonrise",
57
+ "moonset",
58
+ "rise-set",
59
+ "moon-phase",
60
+ "lunar",
61
+ "illumination",
62
+ "solar-position",
63
+ "sun-position",
64
+ "planet-position",
65
+ "meeus",
66
+ "horizons",
67
+ "calculation",
68
+ "geolocation",
69
+ "coordinates",
70
+ "spacecraft",
71
+ "voyager",
72
+ "trajectory"
48
73
  ],
49
74
  "homepage": "https://johnmorrisdotca.github.io/wakusei-planets/",
50
75
  "repository": {
@@ -60,12 +85,16 @@
60
85
  "sideEffects": [
61
86
  "./dist/element.js",
62
87
  "./dist/portrait/element.js",
88
+ "./dist/space/element.js",
63
89
  "./dist/bodies/*.js",
64
90
  "./dist/tables/*.js",
91
+ "./dist/craft/*.js",
65
92
  "./src/element.ts",
66
93
  "./src/portrait/element.ts",
94
+ "./src/space/element.ts",
67
95
  "./src/bodies/*.ts",
68
- "./src/tables/*.ts"
96
+ "./src/tables/*.ts",
97
+ "./src/craft/*.ts"
69
98
  ],
70
99
  "main": "./dist/index.js",
71
100
  "module": "./dist/index.js",
@@ -86,11 +115,31 @@
86
115
  "import": "./dist/portrait/element.js",
87
116
  "default": "./dist/portrait/element.js"
88
117
  },
118
+ "./space": {
119
+ "types": "./dist/space/index.d.ts",
120
+ "import": "./dist/space/index.js",
121
+ "default": "./dist/space/index.js"
122
+ },
123
+ "./space/element": {
124
+ "types": "./dist/space/element.d.ts",
125
+ "import": "./dist/space/element.js",
126
+ "default": "./dist/space/element.js"
127
+ },
89
128
  "./time": {
90
129
  "types": "./dist/time.d.ts",
91
130
  "import": "./dist/time.js",
92
131
  "default": "./dist/time.js"
93
132
  },
133
+ "./stars": {
134
+ "types": "./dist/stars.d.ts",
135
+ "import": "./dist/stars.js",
136
+ "default": "./dist/stars.js"
137
+ },
138
+ "./spacecraft": {
139
+ "types": "./dist/spacecraft.d.ts",
140
+ "import": "./dist/spacecraft.js",
141
+ "default": "./dist/spacecraft.js"
142
+ },
94
143
  "./suncalc": {
95
144
  "types": "./dist/suncalc.d.ts",
96
145
  "import": "./dist/suncalc.js",
@@ -306,7 +355,7 @@
306
355
  },
307
356
  "packageManager": "pnpm@10.28.0",
308
357
  "dependencies": {
309
- "@johnmorrisdotca/kazoku-ui": "^0.19.0"
358
+ "@johnmorrisdotca/kazoku-ui": "^0.20.0"
310
359
  },
311
360
  "peerDependencies": {
312
361
  "@johnmorrisdotca/chikyu-earth": ">=0.10.0",