@johnmorrisdotca/wakusei-planets 0.59.0 → 0.61.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 (43) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/NOTICE.md +9 -0
  3. package/README.md +31 -3
  4. package/dist/bodies/earth.js +22 -1
  5. package/dist/data/places-moon.d.ts +12 -9
  6. package/dist/data/places-moon.js +3 -3
  7. package/dist/element.d.ts +1 -1
  8. package/dist/flat/bodies.d.ts +122 -0
  9. package/dist/flat/bodies.js +115 -0
  10. package/dist/flat/define.d.ts +3 -0
  11. package/dist/flat/define.js +6 -0
  12. package/dist/flat/element.d.ts +145 -0
  13. package/dist/flat/element.js +1614 -0
  14. package/dist/flat/geometry.d.ts +127 -0
  15. package/dist/flat/geometry.js +121 -0
  16. package/dist/flat/index.d.ts +5 -0
  17. package/dist/flat/index.js +6 -0
  18. package/dist/flat/scene.d.ts +152 -0
  19. package/dist/flat/scene.js +195 -0
  20. package/dist/flat/system-define.d.ts +3 -0
  21. package/dist/flat/system-define.js +6 -0
  22. package/dist/flat/system-element.d.ts +133 -0
  23. package/dist/flat/system-element.js +1435 -0
  24. package/dist/flat/system-words.d.ts +28 -0
  25. package/dist/flat/system-words.js +102 -0
  26. package/dist/flat/system.d.ts +440 -0
  27. package/dist/flat/system.js +521 -0
  28. package/dist/flat/words.d.ts +55 -0
  29. package/dist/flat/words.js +133 -0
  30. package/dist/space/travel.js +36 -5
  31. package/dist/surface/drive.d.ts +5 -2
  32. package/dist/surface/drive.js +13 -15
  33. package/dist/surface/element.d.ts +38 -1
  34. package/dist/surface/element.js +144 -14
  35. package/dist/surface/index.d.ts +1 -0
  36. package/dist/surface/index.js +1 -0
  37. package/dist/surface/model.d.ts +54 -0
  38. package/dist/surface/model.js +147 -0
  39. package/dist/surface/rig.d.ts +125 -0
  40. package/dist/surface/rig.js +107 -0
  41. package/dist/surface/scene.d.ts +3 -0
  42. package/dist/surface/scene.js +22 -1
  43. package/package.json +38 -2
@@ -0,0 +1,145 @@
1
+ import { type LandingSite } from "../landing-sites.ts";
2
+ import { type PlaceLayer } from "../place-marks.ts";
3
+ import { type Place, type PlaceKind } from "../places.ts";
4
+ import { type FlatBodyId } from "./bodies.ts";
5
+ import { type FlatLang } from "./words.ts";
6
+ import type { OrbiterStatus } from "../orbiters.ts";
7
+ /**
8
+ * What `wakusei-flat-pick` carries: an orbiter or a place under the pointer, tapped, or reached by the keyboard. A tap on nothing sends `id: null` and clears the choice.
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * import type { FlatPick } from "@johnmorrisdotca/wakusei-planets/flat";
13
+ *
14
+ * const show = (pick: FlatPick): string => (pick.id === null ? "nothing" : `${pick.name} (${pick.kind})`);
15
+ * console.log(typeof show);
16
+ * ```
17
+ */
18
+ export interface FlatPick {
19
+ /** What was chosen: an orbiter or a place on the surface. */
20
+ kind: "orbiter" | "place" | null;
21
+ /** An orbiter's id (`lro`) or a place's (`moon/apollo-11-lunar-module`); null when a tap lands on nothing. */
22
+ id: string | null;
23
+ name: string | null;
24
+ body: FlatBodyId;
25
+ /** Where it is: an orbiter's place on the ground below it at this moment. */
26
+ lat: number | null;
27
+ lon: number | null;
28
+ /** An orbiter's height above the surface in kilometres. */
29
+ altitudeKm: number | null;
30
+ /** Where an orbiter's path comes from at this moment. */
31
+ status: OrbiterStatus | null;
32
+ /** A place's kind (`crewed`, `landing`, `rover`, `crash`, `feature`, ...). */
33
+ placeKind: PlaceKind | null;
34
+ /** For a place: the record of the place tables (the names in both languages, the kind, the mission, the operator, the country, the date, the feature's type and size). Left out for an orbiter and for a tap on nothing. */
35
+ place?: Place;
36
+ /** For a place that is a landing on the Moon or Mars (the lander, or the rover or descent stage on the same spot): the landing site (`/landing-sites`: names, the day, the agency, the country and its flag code, where each number is from). Left out for any other place. */
37
+ site?: LandingSite;
38
+ /** What chose it: a pointer going over it (`hover`), a tap or click (`tap`), or the keyboard (`key`). */
39
+ via: "hover" | "tap" | "key";
40
+ }
41
+ /**
42
+ * The `<wakusei-flat>` custom element: the Moon or Mars on a flat map, with day and night from the Sun's direction for the time shown, the landing, rover and crash sites marked, and the spacecraft in orbit as dots that move over it. Import
43
+ * `@johnmorrisdotca/wakusei-planets/flat/define` to register the tag. It needs no WebGL and no peer: the map is the package's own picture of the body (the same one the 3D views are painted from), fetched from the package's CDN folder unless `texture-base` says where yours are.
44
+ *
45
+ * Attributes (the ones marked "same" are the names and meanings `<chikyu-flat>` has): `body` (`moon`, the default, or `mars`), `center` (same: the longitude in the middle, degrees; 0, the near side or the prime meridian, by default; the map wraps round the body),
46
+ * `home-lon` and `home-lat` (same: the reader's place, a chosen site: a marker, and the "My place" button, which appear only when given),
47
+ * `footprint` and `track` (same: the circle on the ground the orbiter can see, and its ground track for one trip round; the footprint and track of the chosen orbiter, or of every orbiter shown when none is chosen), `footprint-elevation` (same: degrees above the horizon the circle is drawn for; 10 by default),
48
+ * `paused` (same: hold the clock and keep the speed; nothing is drawn while it is held), `time` (same: `now`, an ISO date or milliseconds since 1970; live when absent), `speed` (same: 1 is real time, 0 holds, 86400 is a day a second, negative runs backwards),
49
+ * `selected` (same: the chosen orbiter's id such as `lro`, or a place's id such as `moon/apollo-11-lunar-module`), `shade` (same: `off` for no night), `dot-size` (same: pixels), `controls` (same: `none`, or any of `centre zoom footprint track chips`; all by default), `lang` (same: `en` or `ja`; the page's language by default),
50
+ * `orbiters` (`all`, the default, `off`, or some ids with commas: the orbiters drawn), `places` (the kinds of place marked, from `landing` (crewed, landing and rover sites), `crash` (crashes and impacts), `planned` and `feature` (named craters, seas and mountains); `landing` by default, `all` for every kind, `off` for none),
51
+ * `names` (`off` for no names beside the marks, or the most names to show), `site-flags` (the landing sites carry their country's flag: `<hata-flag>` beside the name on the map and in the tip; the page imports `@johnmorrisdotca/hata`, and without it the name stands alone), `texture-base` and `texture-far-base` (where the body's pictures are: the package's folder on jsDelivr by default).
52
+ *
53
+ * Events (the same names as chikyu's with `wakusei-` for `chikyu-`): `wakusei-flat-pick` (an orbiter, a place of the tables (a landing, a rover, a crash, a crater, a mountain) or a landing site under the pointer, tapped, or reached by the keyboard: a `FlatPick` with `kind`, `id`, `name`, `via` and, for a place, `place` (its record) and `site` (the landing site, where it is one); `detail.id` is null when a tap lands on nothing and clears the choice), `wakusei-flat-filter` (a chip changed what is shown: `{ orbiters, layers }`),
54
+ * `wakusei-flat-view` (the reader panned or zoomed: `{ center, zoom }`) and `wakusei-timechange` (`{ time, running, paused }`, at most four a second while time runs; the name the space view uses).
55
+ * Style it with the custom properties `--wakusei-flat-sea`, `--wakusei-flat-aspect`, `--wakusei-flat-aspect-narrow` and `--wakusei-flat-radius`.
56
+ *
57
+ * @example
58
+ * ```ts no-run
59
+ * import "@johnmorrisdotca/wakusei-planets/flat/define";
60
+ * import type { WakuseiFlat } from "@johnmorrisdotca/wakusei-planets/flat/define";
61
+ *
62
+ * const flat = document.createElement("wakusei-flat") as WakuseiFlat;
63
+ * flat.setAttribute("body", "moon");
64
+ * flat.setAttribute("track", "");
65
+ * document.body.append(flat);
66
+ * flat.addEventListener("wakusei-flat-pick", (event) => console.log((event as CustomEvent).detail.name));
67
+ * ```
68
+ */
69
+ export declare class WakuseiFlat extends HTMLElement {
70
+ #private;
71
+ static observedAttributes: string[];
72
+ /** The body on the map: `moon` or `mars`. */
73
+ get body(): FlatBodyId;
74
+ set body(value: FlatBodyId);
75
+ /** Whether the landing sites carry their country's flag (the attribute `site-flags`): beside the name on the map, and in the tip. The flag is `<hata-flag>` from `@johnmorrisdotca/hata`, which the page imports; where it is not defined the name stands alone. */
76
+ get siteFlags(): boolean;
77
+ set siteFlags(on: boolean);
78
+ /** The id of the chosen orbiter or place, or null. Set it to choose one from code (no `wakusei-flat-pick` is sent), `null` to clear. */
79
+ get selected(): string | null;
80
+ set selected(id: string | null);
81
+ /** The longitude in the middle, degrees. Set it to centre the map there; a reader's pan changes it, and `wakusei-flat-view` tells the page. */
82
+ get center(): number;
83
+ set center(lon: number);
84
+ /** The zoom: 1 shows the whole body, up to 8. */
85
+ get zoom(): number;
86
+ set zoom(value: number);
87
+ /** The moment shown, in milliseconds since the Unix epoch. Set it to a number (or a `Date`) to move the clock, or "now" to go live. */
88
+ get time(): number;
89
+ set time(value: number | Date | "now");
90
+ /** How fast the clock runs: 1 is real time, 0 holds, 86400 is a day a second, negative runs backwards. */
91
+ get speed(): number;
92
+ set speed(value: number);
93
+ /** True while the clock is held with its speed kept (the page's Pause): nothing is drawn but what the reader changes. Setting it false carries on from the moment shown at the same speed. */
94
+ get paused(): boolean;
95
+ set paused(value: boolean);
96
+ /** The language of the words: the `lang` attribute, else the page's. */
97
+ get language(): FlatLang;
98
+ /** The orbiters the map can draw for this body now: their ids, names and colours, and whether each has a path at the moment shown. A craft with no public path (Tianwen-1, CAPSTONE) is not in the list. */
99
+ get orbiters(): readonly {
100
+ id: string;
101
+ name: string;
102
+ colour: string;
103
+ shown: boolean;
104
+ }[];
105
+ /** The places loaded for this body (every kind; the `places` attribute and the chips choose which are marked), or an empty list while they load. */
106
+ get places(): readonly Place[];
107
+ /** The kinds of place marked now: `landing`, `crash`, `planned` and `feature`. */
108
+ get layers(): readonly PlaceLayer[];
109
+ /** Counters for a test or a page: draws of the dots, draws of the map, the orbiters drawn at the last draw, the milliseconds the last draw and the slowest took, the marks drawn, and the canvases' size in pixels. */
110
+ get stats(): {
111
+ draws: number;
112
+ mapDraws: number;
113
+ dots: number;
114
+ marks: number;
115
+ lastDrawMs: number;
116
+ maxDrawMs: number;
117
+ averageDrawMs: number;
118
+ running: boolean;
119
+ paused: boolean;
120
+ fast: boolean;
121
+ mapLoaded: boolean;
122
+ canvases: {
123
+ width: number;
124
+ height: number;
125
+ }[];
126
+ };
127
+ /** Where an orbiter or a place is on the screen as of the last draw, in CSS pixels from the map's top left, or null when it is not drawn (not shown, off the map, or an orbiter with no path). */
128
+ placeOf(id: string): {
129
+ x: number;
130
+ y: number;
131
+ lon: number;
132
+ lat: number;
133
+ altitudeKm: number | null;
134
+ } | null;
135
+ /** Choose an orbiter or a place from code, as a reader's tap would, without sending `wakusei-flat-pick`. An id the map does not hold, or `null`, clears the choice. */
136
+ pick(id: string | null): void;
137
+ connectedCallback(): void;
138
+ disconnectedCallback(): void;
139
+ attributeChangedCallback(name: string, old: string | null, value: string | null): void;
140
+ }
141
+ declare global {
142
+ interface HTMLElementTagNameMap {
143
+ "wakusei-flat": WakuseiFlat;
144
+ }
145
+ }