@johnmorrisdotca/wakusei-planets 0.70.0 → 0.71.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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,15 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [0.71.0] - 2026-11-19
6
+
7
+ - **`<wakusei-moon-pages>`: the moon pages as an element** (`./moon-pages/element`). `<wakusei-moon-pages planet="saturn">` is the demo's moon page in one element: the four tabs (Orbits, Map and portrait, Main moons, Every moon), in English and Japanese (`lang`, or the nearest `lang` up the page, followed as it changes), with the plan, the portrait, the cards' bodies and the planet's looks fetched only when their tab first opens. A change of `planet` draws the other planet. It never writes the page's address: the choices are the attributes `tab`, `view`, `reach`, `colour`, `sort` and `order`, a choice made in it is reflected on them and sent as `wakusei-moon-pages-change` (`detail`: the whole `MoonPagesState`), and a slot named `planets` takes a page's own links to the other planets. `texture-base` and `texture-far-base` are handed to the bodies it draws. `MOON_PAGE_TABS` lists the tabs.
8
+ - **`./moon-pages`: the numbers, at run time.** `moonPage(host)`, `MOON_PAGE_HOSTS` and `MOON_PAGE_TIME` work out everything the pages show from the package's data (what `scripts/moon-pages.ts` baked into the demo's HTML when the site was built, about 124 kB gzipped for Saturn; now a few milliseconds in the browser, and the same planet gives the same object again). Pure: no DOM, no three.js.
9
+ - **Size.** `./moon-pages` is 58,267 B gzipped (212,327 B minified), most of it the moon list. `./moon-pages/element` measures 1,022,424 B gzipped bundled whole, as the budget measures every element, because that counts the plan, the portrait, `<wakusei-body>` and the planet's looks it fetches later; with a bundler that splits, what loads first (the orbits and the table) is about 62 kB gzipped. Both baselines are added to `scripts/size-baseline.json`; no other entry changed.
10
+ - **The demo's moon pages are the element**, with their look, their addresses and `e2e/moons.demo.ts` unchanged. The page writes the address from the element's event and flushes it at once, before a tab's 3D parts hold the page for a moment.
11
+
12
+ - **A page of moons for each giant planet** (MODULES-1678): `jupiter.html`, `saturn.html`, `uranus.html` and `neptune.html` on the demo site, each with a row of the four planets, reached from a card "Giant planets and their moons" on the demo's first page and from each giant planet's name on the plan page, in English and Japanese. Four tabs, each one screen: **Orbits** draws every orbit of `/moon-catalogue` (115 for Jupiter, 292 of Saturn's 293) in SVG, from above the planet's pole, at an angle or from the side, every moon or the inner ones, coloured prograde and retrograde (or by family) with the key from `moonOrbitKey`, a dot where each moon is, and a press that says whose orbit it is; **Map and portrait** is `<wakusei-plan>` and a `<wakusei-portrait>` of the planet and its moons drawn in full; **Main moons** is a card with a picture of each moon drawn in full, its measured shape noted; **Every moon** is the whole list in a table that sorts by name, family, diameter (an estimate from brightness is marked), distance, period, year, place and discoverer, and direction. Every number is worked out from the package's data when the site is built (`scripts/moon-pages.ts`), on the day the irregular moons' osculating orbits were taken (2026-12-01); none is typed. The map, the portrait and the cards are made only when their tab is first opened. The choices are kept in the address and carried to the next planet. On a phone the family header on these pages is one line (the name and the language) and a short count stands for the opening sentence, so the tabs sit near the top and each tab with the tabs fits one screen. `e2e/moons.demo.ts` checks the tabs, the sorting, that nothing scrolls sideways at 390 pixels, and at 390 by 844 that the tabs start in the first half of the screen and that each tab fits one screen from the tabs down. No entry point changes.
13
+
5
14
  ## [0.70.0] - 2026-11-19
6
15
 
7
16
  - **The moons of a planet come a few to a draw** (MODULES-1601, found by CI). A moon's shader is compiled at the first draw it is in, and a rock moon's takes a good part of a second on a software renderer. Saturn has nineteen moons now (it had seven), and all of them in one draw were a pause of about five seconds (2.8 s before 0.70.0, measured with SwiftShader), in which the page answers nothing: `e2e/moon-size.demo.ts` timed out on WebKit waiting for `body` after `goTo("saturn")`. The view now makes at most three moons for the first time in a draw, the ones it had first (the bigger ones) first, the moon looked at at once, and asks for one more draw until they are all there; a view at rest still draws nothing. `e2e/space-moon-makes.demo.ts` holds it.
package/README.md CHANGED
@@ -19,7 +19,7 @@ Wakusei Planets runs in the browser of a phone, a tablet or a computer: nothing
19
19
 
20
20
  <p align="center"><img alt="The demo on a desk: Saturn in the painted look, turning in the big view, with the page's links to the portrait builder, the colouring sheets, the space view, the star page and the size line-up above it, and the choice of body and its moons below" src="https://raw.githubusercontent.com/johnmorrisdotca/wakusei-planets/main/docs/images/home-desk.webp" width="620"> <img alt="The same page on a phone: the same links in rows, and Saturn in the painted look below them" src="https://raw.githubusercontent.com/johnmorrisdotca/wakusei-planets/main/docs/images/home-phone.webp" width="200"></p>
21
21
 
22
- <p align="center"><img alt="Every body at one scale, the Earth among them: each small body has a magnified picture joined by a line, and the Sun shows only its edge" src="https://raw.githubusercontent.com/johnmorrisdotca/wakusei-planets/v0.70.0/docs/images/lineup-desk.png" width="640"></p>
22
+ <p align="center"><img alt="Every body at one scale, the Earth among them: each small body has a magnified picture joined by a line, and the Sun shows only its edge" src="https://raw.githubusercontent.com/johnmorrisdotca/wakusei-planets/v0.71.0/docs/images/lineup-desk.png" width="640"></p>
23
23
 
24
24
  ## Who it is for
25
25
 
@@ -33,7 +33,7 @@ Wakusei Planets runs in the browser of a phone, a tablet or a computer: nothing
33
33
 
34
34
  **Learn:** **[Colouring sheets to print](https://johnmorrisdotca.github.io/wakusei-planets/kids.html)** · **[Saturn's sheet](https://johnmorrisdotca.github.io/wakusei-planets/kids.html?sheet=saturn)** · **[The size line-up, the Sun to the largest stars](https://johnmorrisdotca.github.io/wakusei-planets/lineup.html)**
35
35
 
36
- **Look:** **[Saturn, painted](https://johnmorrisdotca.github.io/wakusei-planets/?body=saturn&look=painted)** · **[Jupiter and its moons now](https://johnmorrisdotca.github.io/wakusei-planets/?body=jupiter&sky=real&moons=1)** · **[The space view](https://johnmorrisdotca.github.io/wakusei-planets/space.html)** · **[A star from its numbers: Vega](https://johnmorrisdotca.github.io/wakusei-planets/star.html?star=vega)**
36
+ **Look:** **[Saturn, painted](https://johnmorrisdotca.github.io/wakusei-planets/?body=saturn&look=painted)** · **[Jupiter and its moons now](https://johnmorrisdotca.github.io/wakusei-planets/?body=jupiter&sky=real&moons=1)** · **[The space view](https://johnmorrisdotca.github.io/wakusei-planets/space.html)** · **[Every moon of Jupiter](https://johnmorrisdotca.github.io/wakusei-planets/jupiter.html)** · **[Every moon of Saturn](https://johnmorrisdotca.github.io/wakusei-planets/saturn.html)** · **[A star from its numbers: Vega](https://johnmorrisdotca.github.io/wakusei-planets/star.html?star=vega)**
37
37
 
38
38
  **Make:** **[The portrait builder](https://johnmorrisdotca.github.io/wakusei-planets/portrait.html)** · **[The code builder](https://johnmorrisdotca.github.io/wakusei-planets/builder.html)**
39
39
 
@@ -163,6 +163,17 @@ const io = planAt(Date.UTC(2026, 10, 11), { system: "jupiter", mark: "io", spaci
163
163
  console.log(io?.distance.toFixed(1), "Jupiter radii from Jupiter");
164
164
  ```
165
165
 
166
+ ## The moon pages of the giant planets
167
+
168
+ `<wakusei-moon-pages planet="saturn">` is one giant planet's moons in four tabs: every orbit of `/moon-catalogue` drawn from above, at an angle or from the side with the prograde and retrograde ones in two colours, `<wakusei-plan>` and a portrait, a card for each moon drawn in full, and every moon in a table that sorts. Its numbers are worked out from the package's data when it is drawn, and its 3D parts load only when their tab opens. It never writes the page's address: a choice is reflected on its attributes (`tab`, `view`, `reach`, `colour`, `sort`, `order`) and sent as `wakusei-moon-pages-change`, for the page to keep. The demo's [Jupiter](https://johnmorrisdotca.github.io/wakusei-planets/jupiter.html), [Saturn](https://johnmorrisdotca.github.io/wakusei-planets/saturn.html), Uranus and Neptune pages are this element. The numbers alone need no browser:
169
+
170
+ ```ts
171
+ import { moonPage } from "@johnmorrisdotca/wakusei-planets/moon-pages";
172
+
173
+ const saturn = moonPage("saturn");
174
+ console.log(saturn.counts.total, "moons,", saturn.counts.retrograde, "going against Saturn's spin");
175
+ ```
176
+
166
177
  ## Flat maps of the Moon and Mars
167
178
 
168
179
  `<wakusei-flat body="moon" track>` is the Moon on a flat map (`body="mars"` is Mars): the body's own painted picture with day and night for the time shown, the landing, rover and crash sites marked, and the spacecraft in orbit as dots that move over it with their coverage circles and ground tracks. It is a canvas with no WebGL, takes `time`, `speed` and `paused`, sends `wakusei-flat-pick` when an orbiter or a mark is pressed, works by keyboard and touch, and has the same attributes and events as chikyu-earth's `<chikyu-flat>`, so one control can swap the Earth, the Moon and Mars. It draws five lunar orbiters (LRO, Chandrayaan-2, Danuri, ARTEMIS P1 and P2) and six Martian ones (MRO, Odyssey, MAVEN, Mars Express, TGO and Hope); CAPSTONE and Tianwen-1 have no public path and are not drawn.
@@ -412,7 +423,7 @@ The tiles of every body share one 48 MB budget, six loads at a time for a source
412
423
 
413
424
  ## The portrait builder
414
425
 
415
- <p align="center"><img alt="The Sun and the planets in an arc, painted, with their names, in the portrait builder" src="https://raw.githubusercontent.com/johnmorrisdotca/wakusei-planets/v0.70.0/docs/images/portrait-family.png" width="640"></p>
426
+ <p align="center"><img alt="The Sun and the planets in an arc, painted, with their names, in the portrait builder" src="https://raw.githubusercontent.com/johnmorrisdotca/wakusei-planets/v0.71.0/docs/images/portrait-family.png" width="640"></p>
416
427
 
417
428
  [The portrait builder](https://johnmorrisdotca.github.io/wakusei-planets/portrait.html) puts any bodies in one picture: drag them, size them, turn them, order them front to back, arrange them in a row, an arc, a grid or at true orbit distance (true or readable sizes, a planet's moons round it in orbit order), light them from one direction, and take the code, a PNG or an SVG. The scene is kept in the address, and every body is drawn in one WebGL scene, so the page holds one WebGL context. [The portrait builder](docs/guides/portrait-builder.md) is its guide.
418
429
 
@@ -471,6 +482,7 @@ The reference is a site, made from the source's own doc comments: every export h
471
482
  | `.../flat` | The flat maps' pure side: `flatSun`, `flatOrbiter`, `shadeNight`, `circleOutline`, `flatTrack`, the geometry and the words. `.../flat/define` is `<wakusei-flat>`, the Moon or Mars on a flat map, in a canvas with no WebGL. |
472
483
  | `.../flat/system` | The flat solar system's pure side: `systemMarks`, `systemBelts`, `systemOrbit`, `craftPath`, `squeezeAu`, the view and the words. `.../flat/system/define` is `<wakusei-flat-system>`, in a canvas with no WebGL. |
473
484
  | `.../plan` | The top-down plan: `planAt`, `planSvg`, `planText`. `.../plan/element` is `<wakusei-plan>`, in SVG with no WebGL. |
485
+ | `.../moon-pages` | A giant planet's moon pages as numbers: `moonPage`, `MOON_PAGE_HOSTS`, `MOON_PAGE_TIME`. `.../moon-pages/element` is `<wakusei-moon-pages>`, the four tabs. |
474
486
  | `.../landing-sites` | The 39 soft landings on the Moon and Mars as plain data: `LANDING_SITES`, `landingSitesOf`, `findLandingSite`, `flagCodeOf`. No browser, no three.js. |
475
487
  | `.../nearest` | The bodies nearest to a body on a date (`nearest`, `within`), when two bodies come closest (`closestApproach`, `conjunctions`) and how far apart they are (`distance`, `distanceRange`). No browser. |
476
488
  | `.../sheets` | Printable colouring sheets for children: the Sun, the planets and the big moons in thick lines with the real colours and three facts, and all the planets at one scale, in English and Japanese (`kidsSvg`, `kidsSheet`, `kidsFacts`). |
@@ -568,7 +580,7 @@ BODIES.pluto.kind; // "dwarf-planet"
568
580
 
569
581
  If this package helps a paper, a talk or a class, please cite it as software. GitHub's "Cite this repository" button reads [CITATION.cff](CITATION.cff) and gives BibTeX and APA; in plain text:
570
582
 
571
- > Morris, J. (2026). *Wakusei Planets* (version 0.70.0) [Computer software]. https://github.com/johnmorrisdotca/wakusei-planets
583
+ > Morris, J. (2026). *Wakusei Planets* (version 0.71.0) [Computer software]. https://github.com/johnmorrisdotca/wakusei-planets
572
584
 
573
585
  Cite the version you used (`npm ls @johnmorrisdotca/wakusei-planets`), and cite the sources of the numbers you use as well: [NOTICE.md](NOTICE.md) names each one, with the paper or the page it was read from (the IAU working group's report for sizes and poles, VSOP87B, ELP2000-82B, L1.2 and TASS1.7 for positions, and NASA's JPL Horizons for the fits and the spacecraft).
574
586
 
@@ -0,0 +1,157 @@
1
+ import { type MoonKeyEntry, type MoonNames } from "../moon-catalogue.ts";
2
+ /**
3
+ * The planets that have moon pages: the four giant planets.
4
+ *
5
+ * @example
6
+ * ```ts
7
+ * import { MOON_PAGE_HOSTS } from "@johnmorrisdotca/wakusei-planets/moon-pages";
8
+ *
9
+ * console.log(MOON_PAGE_HOSTS.join(", "));
10
+ * ```
11
+ */
12
+ export declare const MOON_PAGE_HOSTS: readonly ["jupiter", "saturn", "uranus", "neptune"];
13
+ /**
14
+ * One of the four giant planets: `jupiter`, `saturn`, `uranus` or `neptune`.
15
+ *
16
+ * @example
17
+ * ```ts
18
+ * import type { MoonPageHost } from "@johnmorrisdotca/wakusei-planets/moon-pages";
19
+ *
20
+ * const host: MoonPageHost = "saturn";
21
+ * console.log(host);
22
+ * ```
23
+ */
24
+ export type MoonPageHost = (typeof MOON_PAGE_HOSTS)[number];
25
+ /**
26
+ * The pages' day, in milliseconds since 1970: 2026-12-01, the day the irregular moons' osculating orbits were taken (`MOON_OSCULATING_EPOCH_JD`), where the catalogue places them best.
27
+ *
28
+ * @example
29
+ * ```ts
30
+ * import { MOON_PAGE_TIME } from "@johnmorrisdotca/wakusei-planets/moon-pages";
31
+ *
32
+ * console.log(new Date(MOON_PAGE_TIME).toISOString());
33
+ * ```
34
+ */
35
+ export declare const MOON_PAGE_TIME: number;
36
+ /**
37
+ * One moon of the catalogue as the pages use it: its names, family, radius (`est` when it is worked out from the brightness), semi-major axis and period, direction, discovery, colours, and its orbit and place seen from
38
+ * above the planet's north pole, in the page's `unit` of kilometres, rounded.
39
+ *
40
+ * @example
41
+ * ```ts
42
+ * import { moonPage, type PageMoon } from "@johnmorrisdotca/wakusei-planets/moon-pages";
43
+ *
44
+ * const carme: PageMoon = moonPage("jupiter").moons.find((m) => m.id === "carme")!;
45
+ * console.log(carme.en, carme.retro === 1 ? "retrograde" : "prograde", carme.year);
46
+ * ```
47
+ */
48
+ export interface PageMoon {
49
+ id: string;
50
+ en: string;
51
+ ja: string | null;
52
+ family: string;
53
+ /** Radius in km, or null when no source gives one; `est` when it is worked out from the brightness. */
54
+ r: number | null;
55
+ est: boolean;
56
+ /** Semi-major axis (km) and period (days), or null with no orbit. */
57
+ a: number | null;
58
+ p: number | null;
59
+ /** 1 retrograde, 0 prograde, null with no orbit. */
60
+ retro: 0 | 1 | null;
61
+ year: number | null;
62
+ by: string | null;
63
+ where: string | null;
64
+ full: boolean;
65
+ colour: {
66
+ direction: string;
67
+ group: string;
68
+ };
69
+ /** The orbit seen from above the planet's north pole: x, y, z for each point, in `unit` km. */
70
+ orbit: number[] | null;
71
+ /** Where it is on the page's day, the same way. */
72
+ at: [number, number, number] | null;
73
+ }
74
+ /**
75
+ * A moon the package draws in full, for a card: its names, radius and axes, orbit, discovery and the line about its measured shape (null for a body drawn from its facts).
76
+ *
77
+ * @example
78
+ * ```ts
79
+ * import { moonPage, type PageCard } from "@johnmorrisdotca/wakusei-planets/moon-pages";
80
+ *
81
+ * const first: PageCard = moonPage("saturn").cards[0]!;
82
+ * console.log(first.name.en, first.axesKm?.join(" x "), first.shape?.en);
83
+ * ```
84
+ */
85
+ export interface PageCard {
86
+ id: string;
87
+ name: MoonNames;
88
+ radiusKm: number;
89
+ axesKm: readonly number[] | null;
90
+ a: number | null;
91
+ p: number | null;
92
+ retro: boolean;
93
+ date: string | null;
94
+ where: string | null;
95
+ by: string | null;
96
+ shape: {
97
+ en: string;
98
+ ja: string;
99
+ } | null;
100
+ }
101
+ /**
102
+ * Everything one planet's moon pages show: the planet, the day, the unit of the orbit points, the reach of its regular moons, its families, the colour keys, every catalogue moon, the moons drawn in full and the counts.
103
+ *
104
+ * @example
105
+ * ```ts
106
+ * import { moonPage, type MoonPage } from "@johnmorrisdotca/wakusei-planets/moon-pages";
107
+ *
108
+ * const page: MoonPage = moonPage("neptune");
109
+ * console.log(page.counts.total, "moons,", page.counts.retrograde, "retrograde");
110
+ * ```
111
+ */
112
+ export interface MoonPage {
113
+ host: MoonPageHost;
114
+ name: MoonNames;
115
+ radiusKm: number;
116
+ colour: string;
117
+ time: number;
118
+ fetched: string;
119
+ unit: number;
120
+ /** The reach of the regular moons (the inner view), in `unit` km. */
121
+ inner: number;
122
+ families: {
123
+ id: string;
124
+ names: MoonNames;
125
+ count: number;
126
+ }[];
127
+ key: {
128
+ direction: readonly MoonKeyEntry[];
129
+ group: readonly MoonKeyEntry[];
130
+ };
131
+ moons: PageMoon[];
132
+ cards: PageCard[];
133
+ counts: {
134
+ total: number;
135
+ named: number;
136
+ retrograde: number;
137
+ prograde: number;
138
+ estimated: number;
139
+ featured: number;
140
+ shaped: number;
141
+ };
142
+ }
143
+ /**
144
+ * Work out one giant planet's moon pages from the package's data (`/moon-catalogue`, the discovery records and the facts). It takes a few milliseconds and the same planet gives the same object again.
145
+ *
146
+ * @param host - `jupiter`, `saturn`, `uranus` or `neptune`.
147
+ * @returns The pages' numbers.
148
+ *
149
+ * @example
150
+ * ```ts
151
+ * import { moonPage } from "@johnmorrisdotca/wakusei-planets/moon-pages";
152
+ *
153
+ * const saturn = moonPage("saturn");
154
+ * console.log(saturn.counts.total, "moons of Saturn,", saturn.moons.filter((m) => m.orbit !== null).length, "orbits drawn");
155
+ * ```
156
+ */
157
+ export declare function moonPage(host: MoonPageHost): MoonPage;
@@ -0,0 +1,138 @@
1
+ // The numbers of a giant planet's moon pages, worked out from the package's own data when they are asked for, so nothing is typed by hand: every orbit of /moon-catalogue as points seen from the
2
+ // planet's pole, where each moon is on the pages' day, the key to the orbit colours, every catalogue moon for the table and the moons drawn in full for the cards. Pure: no DOM, no clock reads, no three.js.
3
+ import { discoveryOf } from "../discovery.js";
4
+ import { BODIES, MOONS_OF } from "../facts.js";
5
+ import { catalogueMoonOrbit, catalogueMoonPosition, catalogueMoonsOf, findCatalogueMoon, moonFamilies, moonOrbitColor, moonOrbitKey, MOON_CATALOGUE_FETCHED, MOON_OSCULATING_EPOCH_JD } from "../moon-catalogue.js";
6
+ import { shapeBasis, shapeNote } from "../shape-basis.js";
7
+ import { cross, dot, fromRaDec, toEcliptic } from "../vec.js";
8
+ /**
9
+ * The planets that have moon pages: the four giant planets.
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * import { MOON_PAGE_HOSTS } from "@johnmorrisdotca/wakusei-planets/moon-pages";
14
+ *
15
+ * console.log(MOON_PAGE_HOSTS.join(", "));
16
+ * ```
17
+ */
18
+ export const MOON_PAGE_HOSTS = ["jupiter", "saturn", "uranus", "neptune"];
19
+ /**
20
+ * The pages' day, in milliseconds since 1970: 2026-12-01, the day the irregular moons' osculating orbits were taken (`MOON_OSCULATING_EPOCH_JD`), where the catalogue places them best.
21
+ *
22
+ * @example
23
+ * ```ts
24
+ * import { MOON_PAGE_TIME } from "@johnmorrisdotca/wakusei-planets/moon-pages";
25
+ *
26
+ * console.log(new Date(MOON_PAGE_TIME).toISOString());
27
+ * ```
28
+ */
29
+ export const MOON_PAGE_TIME = (MOON_OSCULATING_EPOCH_JD - 2440587.5) * 86_400_000;
30
+ const POINTS = 48;
31
+ /** The axes of the planet's north pole in the J2000 ecliptic (the plan's own): x along its equator, y a quarter turn on, z up the pole. */
32
+ function poleBasis(host) {
33
+ const { ra, dec } = BODIES[host].pole;
34
+ const z = toEcliptic(fromRaDec(ra, dec));
35
+ const x = toEcliptic(fromRaDec(ra + 90, 0));
36
+ return [x, cross(z, x), z];
37
+ }
38
+ const made = new Map();
39
+ /**
40
+ * Work out one giant planet's moon pages from the package's data (`/moon-catalogue`, the discovery records and the facts). It takes a few milliseconds and the same planet gives the same object again.
41
+ *
42
+ * @param host - `jupiter`, `saturn`, `uranus` or `neptune`.
43
+ * @returns The pages' numbers.
44
+ *
45
+ * @example
46
+ * ```ts
47
+ * import { moonPage } from "@johnmorrisdotca/wakusei-planets/moon-pages";
48
+ *
49
+ * const saturn = moonPage("saturn");
50
+ * console.log(saturn.counts.total, "moons of Saturn,", saturn.moons.filter((m) => m.orbit !== null).length, "orbits drawn");
51
+ * ```
52
+ */
53
+ export function moonPage(host) {
54
+ const held = made.get(host);
55
+ if (held !== undefined)
56
+ return held;
57
+ const catalogue = catalogueMoonsOf(host);
58
+ const basis = poleBasis(host);
59
+ const smallest = Math.min(...catalogue.flatMap((m) => (m.orbit === null ? [] : [m.orbit.a])));
60
+ const unit = 10 ** Math.floor(Math.log10(smallest / 100));
61
+ const turn = (v) => [Math.round(dot(v, basis[0]) / unit), Math.round(dot(v, basis[1]) / unit), Math.round(dot(v, basis[2]) / unit)];
62
+ const families = moonFamilies(host);
63
+ const familyOf = new Map();
64
+ for (const family of families)
65
+ for (const moon of family.moons)
66
+ familyOf.set(moon.id, family.id);
67
+ const moons = catalogue.map((m) => {
68
+ const record = discoveryOf(m.id);
69
+ const orbit = catalogueMoonOrbit(m, MOON_PAGE_TIME, POINTS);
70
+ const at = catalogueMoonPosition(m, MOON_PAGE_TIME);
71
+ return {
72
+ id: m.id,
73
+ en: m.label,
74
+ ja: m.ja,
75
+ family: familyOf.get(m.id) ?? "",
76
+ r: m.radiusKm,
77
+ est: m.radiusFrom === "derived",
78
+ a: m.orbit?.a ?? null,
79
+ p: m.orbit?.periodDays ?? null,
80
+ retro: m.orbit === null ? null : m.retrograde ? 1 : 0,
81
+ year: m.discovery.year,
82
+ by: m.discovery.by,
83
+ where: record?.place?.value ?? null,
84
+ full: m.full,
85
+ colour: { direction: moonOrbitColor(m, "direction"), group: moonOrbitColor(m, "group") },
86
+ orbit: orbit === undefined ? null : orbit.slice(0, POINTS).flatMap(turn),
87
+ at: at === undefined ? null : turn(at),
88
+ };
89
+ });
90
+ const regular = catalogue.filter((m) => m.orbit !== null && ["major", "inner", "regular"].includes(m.group) && m.id !== "phoebe");
91
+ const cards = [...MOONS_OF[host]]
92
+ .map((id) => ({ id, row: findCatalogueMoon(id) }))
93
+ .sort((p, q) => (p.row?.orbit?.a ?? Infinity) - (q.row?.orbit?.a ?? Infinity))
94
+ .map(({ id, row }) => {
95
+ const facts = BODIES[id];
96
+ const record = discoveryOf(id);
97
+ const basisOf = shapeBasis(id);
98
+ return {
99
+ id,
100
+ name: facts.name,
101
+ radiusKm: facts.radiusKm,
102
+ axesKm: "axesKm" in facts ? facts.axesKm : null,
103
+ a: row?.orbit?.a ?? null,
104
+ p: row?.orbit?.periodDays ?? null,
105
+ retro: row?.retrograde ?? false,
106
+ date: record?.date?.value ?? (row?.discovery.year === null || row === undefined ? null : String(row.discovery.year)),
107
+ where: record?.place?.value ?? null,
108
+ by: record?.by?.value.join(", ") ?? row?.discovery.by ?? null,
109
+ shape: basisOf === undefined ? null : { en: shapeNote(id, "en"), ja: shapeNote(id, "ja") },
110
+ };
111
+ });
112
+ const direction = moonOrbitKey("direction", [host]);
113
+ const page = {
114
+ host,
115
+ name: BODIES[host].name,
116
+ radiusKm: BODIES[host].radiusKm,
117
+ colour: BODIES[host].colour,
118
+ time: MOON_PAGE_TIME,
119
+ fetched: MOON_CATALOGUE_FETCHED,
120
+ unit,
121
+ inner: Math.round(Math.max(...regular.map((m) => m.orbit.a * (1 + m.orbit.e))) / unit),
122
+ families: families.map((f) => ({ id: f.id, names: f.names, count: f.count })),
123
+ key: { direction, group: moonOrbitKey("group", [host]) },
124
+ moons,
125
+ cards,
126
+ counts: {
127
+ total: catalogue.length,
128
+ named: catalogue.filter((m) => m.named).length,
129
+ retrograde: direction.find((d) => d.id === "retrograde")?.count ?? 0,
130
+ prograde: direction.find((d) => d.id === "prograde")?.count ?? 0,
131
+ estimated: catalogue.filter((m) => m.radiusFrom === "derived").length,
132
+ featured: cards.length,
133
+ shaped: cards.filter((c) => c.shape !== null).length,
134
+ },
135
+ };
136
+ made.set(host, page);
137
+ return page;
138
+ }
@@ -0,0 +1,82 @@
1
+ import { type MoonPage, type MoonPageHost } from "./data.ts";
2
+ /**
3
+ * The four tabs of `<wakusei-moon-pages>`, in their order: `orbits`, `views` (the map and the portrait), `cards` (the moons drawn in full) and `table` (every moon).
4
+ *
5
+ * @example
6
+ * ```ts no-run
7
+ * import { MOON_PAGE_TABS } from "@johnmorrisdotca/wakusei-planets/moon-pages/element";
8
+ *
9
+ * console.log(MOON_PAGE_TABS.join(", "));
10
+ * ```
11
+ */
12
+ export declare const MOON_PAGE_TABS: readonly ["orbits", "views", "cards", "table"];
13
+ declare const VIEWS: readonly ["above", "tilted", "side"];
14
+ declare const REACHES: readonly ["all", "inner"];
15
+ declare const COLOURS: readonly ["direction", "group"];
16
+ declare const COLUMNS: readonly ["name", "family", "size", "distance", "period", "year", "where", "by", "direction"];
17
+ /**
18
+ * What `<wakusei-moon-pages>` shows, as its attributes say it and as `wakusei-moon-pages-change` sends it: the planet, the tab, how the orbits are seen (`above`, `tilted` or `side`), how far (`all` or `inner`) and
19
+ * coloured (`direction` or `group`), and the table's column and order (`up` or `down`).
20
+ *
21
+ * @example
22
+ * ```ts no-run
23
+ * import type { MoonPagesState } from "@johnmorrisdotca/wakusei-planets/moon-pages/element";
24
+ *
25
+ * const pages = document.querySelector("wakusei-moon-pages")!;
26
+ * pages.addEventListener("wakusei-moon-pages-change", (event) => {
27
+ * const state: MoonPagesState = (event as CustomEvent<MoonPagesState>).detail;
28
+ * console.log(state.planet, state.tab, state.sort, state.order);
29
+ * });
30
+ * ```
31
+ */
32
+ export interface MoonPagesState {
33
+ planet: MoonPageHost;
34
+ tab: (typeof MOON_PAGE_TABS)[number];
35
+ view: (typeof VIEWS)[number];
36
+ reach: (typeof REACHES)[number];
37
+ colour: (typeof COLOURS)[number];
38
+ sort: (typeof COLUMNS)[number];
39
+ order: "up" | "down";
40
+ }
41
+ /**
42
+ * The `<wakusei-moon-pages>` custom element: one giant planet's moons in four tabs, each one screen.
43
+ *
44
+ * - **Orbits**: every orbit of `/moon-catalogue` in SVG, seen from above the planet's pole, at an angle or from the side, every moon or the inner ones, coloured prograde and retrograde or by family, with the key and a dot
45
+ * where each moon is on `MOON_PAGE_TIME`; pointing at an orbit, or a press on it, says whose it is.
46
+ * - **Map and portrait**: `<wakusei-plan>` from above the pole and a `<wakusei-portrait>` of the planet with the moons drawn in full.
47
+ * - **Main moons**: a card with a painted picture for each moon drawn in full, its size (three axes for a shaped one), distance, period, discovery and how its shape is known.
48
+ * - **Every moon**: the whole list in a table that sorts by any column, both ways; a size worked out from brightness is marked ≈, and — is a value no source gives.
49
+ *
50
+ * Attributes: `planet` (`jupiter`, the default, `saturn`, `uranus` or `neptune`; a change draws the other planet), `lang` (`en` or `ja`; the nearest `lang` up the page when left out, and it follows that one),
51
+ * `tab`, `view` (`above`, `tilted` or `side`), `reach` (`all` or `inner`), `colour` (`direction` or `group`), `sort` (`name`, `family`, `size`, `distance`, `period`, `year`, `where`, `by` or `direction`) and `order`
52
+ * (`up` or `down`), and `texture-base` and `texture-far-base`, handed to the bodies it draws. A slot named `planets` sits under the title, for a page's own row of links to the other planets.
53
+ *
54
+ * It never writes the page's address. A choice made in it is reflected on its attribute and sent as `wakusei-moon-pages-change` (bubbling, composed) with `detail` the whole `MoonPagesState`; a page that keeps its
55
+ * address writes the detail there and sets the attributes back from it when it loads. Setting an attribute sends no event. The numbers are `moonPage(planet)`'s, worked out in a few milliseconds. The plan, the
56
+ * portrait, the cards' bodies and the planet's looks are fetched only when their tab is first opened, so a page that shows only the orbits and the table loads no WebGL. Nothing runs on a timer; the orbits are drawn
57
+ * again only when a choice, the language or the element's width changes. `data-state` is `ready` once it has drawn.
58
+ *
59
+ * @example
60
+ * ```ts no-run
61
+ * import "@johnmorrisdotca/wakusei-planets/moon-pages/element";
62
+ * import type { MoonPagesState, WakuseiMoonPages } from "@johnmorrisdotca/wakusei-planets/moon-pages/element";
63
+ *
64
+ * const pages = document.createElement("wakusei-moon-pages") as WakuseiMoonPages;
65
+ * pages.setAttribute("planet", "saturn");
66
+ * pages.setAttribute("tab", "table");
67
+ * pages.addEventListener("wakusei-moon-pages-change", (event) => console.log((event as CustomEvent<MoonPagesState>).detail));
68
+ * document.body.append(pages);
69
+ * ```
70
+ */
71
+ export declare class WakuseiMoonPages extends HTMLElement {
72
+ #private;
73
+ static observedAttributes: string[];
74
+ /** What it shows now. */
75
+ get state(): MoonPagesState;
76
+ /** The numbers it draws: `moonPage(planet)`. */
77
+ get page(): MoonPage;
78
+ connectedCallback(): void;
79
+ disconnectedCallback(): void;
80
+ attributeChangedCallback(name: string, before: string | null, after: string | null): void;
81
+ }
82
+ export {};