@johnmorrisdotca/uchusen-rockets 0.3.0 → 0.4.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 (60) hide show
  1. package/CHANGELOG.md +16 -5
  2. package/README.md +241 -4
  3. package/dist/attrs.d.ts +70 -4
  4. package/dist/attrs.js +59 -4
  5. package/dist/build/glb.d.ts +25 -0
  6. package/dist/build/glb.js +14 -0
  7. package/dist/build/index.d.ts +89 -4
  8. package/dist/build/index.js +55 -4
  9. package/dist/build/lineup.d.ts +56 -2
  10. package/dist/build/lineup.js +23 -2
  11. package/dist/builder.d.ts +47 -1
  12. package/dist/builder.js +14 -1
  13. package/dist/crossfade.d.ts +44 -2
  14. package/dist/crossfade.js +44 -2
  15. package/dist/data/credits.d.ts +44 -1
  16. package/dist/data/credits.js +22 -1
  17. package/dist/data/flight-log.d.ts +33 -1
  18. package/dist/data/flight-log.js +22 -1
  19. package/dist/data/flights.d.ts +54 -2
  20. package/dist/data/flights.js +10 -0
  21. package/dist/data/makers.d.ts +21 -0
  22. package/dist/data/makers.js +10 -0
  23. package/dist/data/sources.d.ts +32 -0
  24. package/dist/data/sources.js +10 -0
  25. package/dist/data/types.d.ts +81 -1
  26. package/dist/data/types.js +26 -1
  27. package/dist/element.d.ts +61 -3
  28. package/dist/element.js +50 -3
  29. package/dist/embed.d.ts +110 -5
  30. package/dist/embed.js +88 -5
  31. package/dist/engines.d.ts +86 -4
  32. package/dist/engines.js +75 -4
  33. package/dist/fit.d.ts +68 -0
  34. package/dist/fit.js +13 -0
  35. package/dist/flight.d.ts +134 -9
  36. package/dist/flight.js +122 -9
  37. package/dist/flightbar.d.ts +12 -0
  38. package/dist/flightbar.js +12 -0
  39. package/dist/framing.d.ts +182 -8
  40. package/dist/framing.js +127 -6
  41. package/dist/layout.d.ts +65 -1
  42. package/dist/layout.js +43 -1
  43. package/dist/looks.d.ts +64 -1
  44. package/dist/looks.js +42 -1
  45. package/dist/model/materials.d.ts +32 -0
  46. package/dist/model/materials.js +10 -0
  47. package/dist/model/registry.d.ts +22 -0
  48. package/dist/model/registry.js +22 -0
  49. package/dist/parts.d.ts +33 -1
  50. package/dist/pixels.d.ts +44 -4
  51. package/dist/pixels.js +44 -4
  52. package/dist/react.d.ts +24 -0
  53. package/dist/react.js +13 -0
  54. package/dist/rockets.d.ts +91 -3
  55. package/dist/rockets.js +58 -2
  56. package/dist/spin.d.ts +57 -2
  57. package/dist/spin.js +35 -2
  58. package/dist/tilt.d.ts +48 -4
  59. package/dist/tilt.js +26 -4
  60. package/package.json +10 -5
@@ -1,3 +1,13 @@
1
+ /**
2
+ * The flights this package keeps a record of, each from a named source. Use `flightLogOf` for one rocket.
3
+ *
4
+ * @example
5
+ * ```ts
6
+ * import { FLIGHT_LOG } from "@johnmorrisdotca/uchusen-rockets";
7
+ *
8
+ * console.log(FLIGHT_LOG.length > 0);
9
+ * ```
10
+ */
1
11
  export const FLIGHT_LOG = [
2
12
  { id: "falcon-1-flight-1", name: "Falcon 1, flight 1", rocket: "falcon-1", variant: "falcon-1", date: "2006-03-24", launch: "Failure", outcome: "Engine failure at T+33 seconds, and the vehicle was lost.", source: "wikipedia-falcon-1" },
3
13
  { id: "falcon-1-flight-2", name: "Falcon 1, flight 2", rocket: "falcon-1", variant: "falcon-1", date: "2007-03-21", launch: "Failure", outcome: "Reached 289 km and did not reach orbit: an oscillation of the second stage, and an early engine shutdown.", source: "wikipedia-falcon-1" },
@@ -19,5 +29,16 @@ export const FLIGHT_LOG = [
19
29
  { id: "starship-flight-13", name: "Starship flight 13", rocket: "starship", variant: "v3", date: "2026-07-24", launch: "Success", vehicles: "Booster B20, Ship S40", outcome: "Booster: Failure (gulf). Ship: Controlled (ocean).", source: "wikipedia-launches" },
20
30
  { id: "starship-flight-14", name: "Starship flight 14", rocket: "starship", variant: "v3", date: "2026-09-28", launch: "Success", vehicles: "Booster B21, Ship S41", outcome: "Booster: Controlled (gulf). Ship: Controlled (ocean).", source: "wikipedia-launches" },
21
31
  ];
22
- /** A rocket's flights, in order. */
32
+ /**
33
+ * A rocket's flights, in order.
34
+ *
35
+ * @param rocket A rocket's id, such as `falcon-1`.
36
+ * @returns That rocket's logged flights, in order. It is empty for a rocket with none.
37
+ * @example
38
+ * ```ts
39
+ * import { flightLogOf } from "@johnmorrisdotca/uchusen-rockets";
40
+ *
41
+ * console.log(flightLogOf("falcon-1").map((flight) => flight.name));
42
+ * ```
43
+ */
23
44
  export const flightLogOf = (rocket) => FLIGHT_LOG.filter((flight) => flight.rocket === rocket);
@@ -1,6 +1,16 @@
1
1
  import { type Figure } from "./types.ts";
2
2
  import type { SourceId } from "./sources.ts";
3
- /** How a part stands in the picture at a phase. A picture, not a measurement: `dx` and `dy` are in heights of the whole vehicle. */
3
+ /**
4
+ * How a part stands in the picture at a phase. A picture, not a measurement: `dx` and `dy` are in heights of the whole vehicle.
5
+ *
6
+ * @example
7
+ * ```ts
8
+ * import type { PartPose } from "@johnmorrisdotca/uchusen-rockets";
9
+ *
10
+ * const pose: PartPose = { dx: 0.2, dy: -0.1, pitch: 12 };
11
+ * console.log(pose);
12
+ * ```
13
+ */
4
14
  export interface PartPose {
5
15
  dx?: number;
6
16
  dy?: number;
@@ -11,11 +21,32 @@ export interface PartPose {
11
21
  /** It has left the picture. */
12
22
  gone?: boolean;
13
23
  }
14
- /** How many engines of a part burn. `drawn` says how many flames to draw where no page says how many burned. */
24
+ /**
25
+ * How many engines of a part burn. `drawn` says how many flames to draw where no page says how many burned.
26
+ *
27
+ * @example
28
+ * ```ts
29
+ * import type { FlightBurn } from "@johnmorrisdotca/uchusen-rockets";
30
+ *
31
+ * const burn: FlightBurn = { engines: { value: null, source: null, brief: "not given" }, drawn: 9 };
32
+ * console.log(burn);
33
+ * ```
34
+ */
15
35
  export interface FlightBurn {
16
36
  engines: Figure;
17
37
  drawn?: number;
18
38
  }
39
+ /**
40
+ * One phase of a flight: its id and name, what happens, when (a figure with its source), how many engines burn, how each part stands, and how far the ground has fallen away. The poses and the smoke are a picture, not a measurement.
41
+ *
42
+ * @example
43
+ * ```ts
44
+ * import { FLIGHTS, type FlightPhase } from "@johnmorrisdotca/uchusen-rockets";
45
+ *
46
+ * const phase: FlightPhase | undefined = FLIGHTS[0]?.phases[0];
47
+ * console.log(phase?.name, phase?.what);
48
+ * ```
49
+ */
19
50
  export interface FlightPhase {
20
51
  id: string;
21
52
  name: string;
@@ -34,6 +65,17 @@ export interface FlightPhase {
34
65
  altitude?: Figure<string>;
35
66
  speed?: Figure<string>;
36
67
  }
68
+ /**
69
+ * A flight, from a published timeline: its rocket and variant, whose timing it is, its source and its phases in order.
70
+ *
71
+ * @example
72
+ * ```ts
73
+ * import { FLIGHTS, type Flight } from "@johnmorrisdotca/uchusen-rockets";
74
+ *
75
+ * const flight: Flight | undefined = FLIGHTS[0];
76
+ * console.log(flight?.name, flight?.phases.length);
77
+ * ```
78
+ */
37
79
  export interface Flight {
38
80
  id: string;
39
81
  rocket: string;
@@ -46,4 +88,14 @@ export interface Flight {
46
88
  note?: string;
47
89
  phases: readonly FlightPhase[];
48
90
  }
91
+ /**
92
+ * Every flight the package can play, one for each variant that has a timeline. Use `flightOf` to find one.
93
+ *
94
+ * @example
95
+ * ```ts
96
+ * import { FLIGHTS } from "@johnmorrisdotca/uchusen-rockets";
97
+ *
98
+ * console.log(FLIGHTS.map((flight) => `${flight.rocket}:${flight.variant}`));
99
+ * ```
100
+ */
49
101
  export declare const FLIGHTS: readonly Flight[];
@@ -65,6 +65,16 @@ const FH = "wikipedia-fh-test-flight";
65
65
  const STARLINK = "sfn-starlink-2019";
66
66
  const CRS16 = "sfn-crs-16";
67
67
  const lower = (dy, extra = {}) => ({ dx: -0.26, dy, ...extra });
68
+ /**
69
+ * Every flight the package can play, one for each variant that has a timeline. Use `flightOf` to find one.
70
+ *
71
+ * @example
72
+ * ```ts
73
+ * import { FLIGHTS } from "@johnmorrisdotca/uchusen-rockets";
74
+ *
75
+ * console.log(FLIGHTS.map((flight) => `${flight.rocket}:${flight.variant}`));
76
+ * ```
77
+ */
68
78
  export const FLIGHTS = [
69
79
  starshipFlight({
70
80
  id: "starship-flight-5",
@@ -1,4 +1,14 @@
1
1
  import { type Figure } from "./types.ts";
2
+ /**
3
+ * The groups the demo lists rockets under, by id, with the name shown for each.
4
+ *
5
+ * @example
6
+ * ```ts
7
+ * import { MAKERS } from "@johnmorrisdotca/uchusen-rockets";
8
+ *
9
+ * console.log(MAKERS.spacex, Object.keys(MAKERS).length);
10
+ * ```
11
+ */
2
12
  export declare const MAKERS: {
3
13
  readonly spacex: "SpaceX";
4
14
  readonly nasa: "NASA and partners";
@@ -8,6 +18,17 @@ export declare const MAKERS: {
8
18
  readonly "us-army": "US Army";
9
19
  readonly sites: "Sites";
10
20
  };
21
+ /**
22
+ * The id of a group in `MAKERS`.
23
+ *
24
+ * @example
25
+ * ```ts
26
+ * import type { MakerId } from "@johnmorrisdotca/uchusen-rockets";
27
+ *
28
+ * const maker: MakerId = "nasa";
29
+ * console.log(maker);
30
+ * ```
31
+ */
11
32
  export type MakerId = keyof typeof MAKERS;
12
33
  export interface MadeBy {
13
34
  maker: MakerId;
@@ -1,5 +1,15 @@
1
1
  // Whose each rocket is, as its own article's infobox and first lines say, read 2026-11-02. `maker` is how the demo groups them; `by` says what the source says, with the companies that built it where it names them. The sites have no maker here: a blank, not a guess.
2
2
  import { blank } from "./types.js";
3
+ /**
4
+ * The groups the demo lists rockets under, by id, with the name shown for each.
5
+ *
6
+ * @example
7
+ * ```ts
8
+ * import { MAKERS } from "@johnmorrisdotca/uchusen-rockets";
9
+ *
10
+ * console.log(MAKERS.spacex, Object.keys(MAKERS).length);
11
+ * ```
12
+ */
3
13
  export const MAKERS = { spacex: "SpaceX", nasa: "NASA and partners", "blue-origin": "Blue Origin", "rocket-lab": "Rocket Lab", russia: "Russia", "us-army": "US Army", sites: "Sites" };
4
14
  const SITE = { maker: "sites", madeBy: blank("A place or a ship, not a vehicle: its maker is not read here.") };
5
15
  export const MADE_BY = {
@@ -1,3 +1,14 @@
1
+ /**
2
+ * A source of a figure: its title, publisher and address, the date on it where it has one, how it was read (directly, by search or cited) and its licence.
3
+ *
4
+ * @example
5
+ * ```ts
6
+ * import { SOURCES, type Source } from "@johnmorrisdotca/uchusen-rockets";
7
+ *
8
+ * const source: Source = SOURCES["wikipedia-starship"];
9
+ * console.log(source.publisher, source.read);
10
+ * ```
11
+ */
1
12
  export interface Source {
2
13
  title: string;
3
14
  publisher: string;
@@ -7,6 +18,16 @@ export interface Source {
7
18
  read: "direct" | "search" | "cited";
8
19
  licence?: string;
9
20
  }
21
+ /**
22
+ * Every source a figure can name, by id. A figure carries only an id; look the id up here for the page it came from.
23
+ *
24
+ * @example
25
+ * ```ts
26
+ * import { SOURCES } from "@johnmorrisdotca/uchusen-rockets";
27
+ *
28
+ * console.log(Object.keys(SOURCES).length > 20, SOURCES["wikipedia-starship"].url);
29
+ * ```
30
+ */
10
31
  export declare const SOURCES: {
11
32
  readonly "wikipedia-starship": {
12
33
  readonly title: "SpaceX Starship (the block table and infobox, read as raw wikitext)";
@@ -524,4 +545,15 @@ export declare const SOURCES: {
524
545
  readonly read: "direct";
525
546
  };
526
547
  };
548
+ /**
549
+ * The id of a source in `SOURCES`.
550
+ *
551
+ * @example
552
+ * ```ts
553
+ * import type { SourceId } from "@johnmorrisdotca/uchusen-rockets";
554
+ *
555
+ * const id: SourceId = "wikipedia-starship";
556
+ * console.log(id);
557
+ * ```
558
+ */
527
559
  export type SourceId = keyof typeof SOURCES;
@@ -1,5 +1,15 @@
1
1
  // Every source a figure may name. Plain facts are taken from these, and each figure says which one it came from. `read` is how this project read it: "direct" means the page itself, "search" that only
2
2
  // a search engine's quote of it could be read, and "cited" that it is known through another source's citation.
3
+ /**
4
+ * Every source a figure can name, by id. A figure carries only an id; look the id up here for the page it came from.
5
+ *
6
+ * @example
7
+ * ```ts
8
+ * import { SOURCES } from "@johnmorrisdotca/uchusen-rockets";
9
+ *
10
+ * console.log(Object.keys(SOURCES).length > 20, SOURCES["wikipedia-starship"].url);
11
+ * ```
12
+ */
3
13
  export const SOURCES = {
4
14
  "wikipedia-starship": { title: "SpaceX Starship (the block table and infobox, read as raw wikitext)", publisher: "Wikipedia", url: "https://en.wikipedia.org/wiki/SpaceX_Starship", date: "2026-10-31", read: "direct", licence: "CC BY-SA 4.0" },
5
15
  "wikipedia-super-heavy": { title: "SpaceX Super Heavy", publisher: "Wikipedia", url: "https://en.wikipedia.org/wiki/SpaceX_Super_Heavy", date: "2026-10-31", read: "direct", licence: "CC BY-SA 4.0" },
@@ -1,9 +1,31 @@
1
1
  import type { SourceId } from "./sources.ts";
2
+ /**
3
+ * Another value a source gave for a figure, with the source and the reason it was not the one chosen.
4
+ *
5
+ * @example
6
+ * ```ts
7
+ * import { variantOf, type Disagreement } from "@johnmorrisdotca/uchusen-rockets";
8
+ *
9
+ * const others: readonly Disagreement<number>[] = variantOf("starship", "v3")?.facts.parts.booster?.others ?? [];
10
+ * console.log(others.map((other) => other.value));
11
+ * ```
12
+ */
2
13
  export interface Disagreement<T> {
3
14
  value: T;
4
15
  source: SourceId;
5
16
  note: string;
6
17
  }
18
+ /**
19
+ * A number or a text with where it came from. A figure with no source is blank (`value` is null) and is never estimated. Where sources disagree, the figure keeps the one chosen and `others` holds the rest.
20
+ *
21
+ * @example
22
+ * ```ts
23
+ * import { variantOf, type Figure } from "@johnmorrisdotca/uchusen-rockets";
24
+ *
25
+ * const height: Figure | undefined = variantOf("starship", "v3")?.facts.height;
26
+ * console.log(height?.value, height?.source);
27
+ * ```
28
+ */
7
29
  export interface Figure<T = number> {
8
30
  value: T | null;
9
31
  source: SourceId | null;
@@ -14,10 +36,57 @@ export interface Figure<T = number> {
14
36
  brief?: string;
15
37
  others?: readonly Disagreement<T>[];
16
38
  }
39
+ /**
40
+ * A figure with no value: the shape of "no source gives this".
41
+ *
42
+ * @param note Why there is no value. Optional.
43
+ * @param brief What to say in place of a value wherever it is shown. Optional.
44
+ * @returns A figure whose value and source are null.
45
+ * @example
46
+ * ```ts
47
+ * import { blank } from "@johnmorrisdotca/uchusen-rockets";
48
+ *
49
+ * console.log(blank("No source read gives it.", "not given"));
50
+ * ```
51
+ */
17
52
  export declare const blank: <T = number>(note?: string, brief?: string) => Figure<T>;
18
- /** A figure as words for a table: its value and whatever must stay beside it; a blank says why, or that no source gives it. */
53
+ /**
54
+ * A figure as words for a table: its value and whatever must stay beside it; a blank says why, or that no source gives it.
55
+ *
56
+ * @param figure A figure, or undefined.
57
+ * @param unit Text to put after a number, such as " m". Optional.
58
+ * @returns The figure as words for a table. A blank gives its `brief`, or "No source" when it has none.
59
+ * @example
60
+ * ```ts
61
+ * import { figureWords, variantOf } from "@johnmorrisdotca/uchusen-rockets";
62
+ *
63
+ * console.log(figureWords(variantOf("starship", "v3")?.facts.height, " m"));
64
+ * ```
65
+ */
19
66
  export declare function figureWords(figure: Figure<number | string> | undefined, unit?: string): string;
67
+ /**
68
+ * What kind of thing a variant is: flown, announced (not built), an artist's model, a test vehicle or a support item.
69
+ *
70
+ * @example
71
+ * ```ts
72
+ * import { variantOf, type VariantStatus } from "@johnmorrisdotca/uchusen-rockets";
73
+ *
74
+ * const status: VariantStatus | undefined = variantOf("starship", "v4")?.status;
75
+ * console.log(status);
76
+ * ```
77
+ */
20
78
  export type VariantStatus = "flown" | "announced" | "artist-model" | "test-vehicle" | "support";
79
+ /**
80
+ * The sourced numbers of a variant: its height and diameter, each part's height by slot, its engines, other facts and any sizes that are not a height or a width.
81
+ *
82
+ * @example
83
+ * ```ts
84
+ * import { variantOf, type VariantFacts } from "@johnmorrisdotca/uchusen-rockets";
85
+ *
86
+ * const facts: VariantFacts | undefined = variantOf("falcon-9", "block-5")?.facts;
87
+ * console.log(facts?.height.value, Object.keys(facts?.parts ?? {}));
88
+ * ```
89
+ */
21
90
  export interface VariantFacts {
22
91
  /** Overall height with every part in place, metres. */
23
92
  height: Figure;
@@ -31,6 +100,17 @@ export interface VariantFacts {
31
100
  /** Sizes that are not a height or a width, shown as they are named here: "Deck length". */
32
101
  sizes?: Readonly<Record<string, Figure>>;
33
102
  }
103
+ /**
104
+ * One version of a rocket as data: its id, name, status, first flight, its parts from the bottom up, and the sourced facts about it.
105
+ *
106
+ * @example
107
+ * ```ts
108
+ * import { variantOf, type Variant } from "@johnmorrisdotca/uchusen-rockets";
109
+ *
110
+ * const variant: Variant | undefined = variantOf("starship", "v3");
111
+ * console.log(variant?.name, variant?.slots);
112
+ * ```
113
+ */
34
114
  export interface Variant {
35
115
  /** "v1", "v2" and so on; a label for what is not a numbered version. */
36
116
  id: string;
@@ -1,5 +1,30 @@
1
+ /**
2
+ * A figure with no value: the shape of "no source gives this".
3
+ *
4
+ * @param note Why there is no value. Optional.
5
+ * @param brief What to say in place of a value wherever it is shown. Optional.
6
+ * @returns A figure whose value and source are null.
7
+ * @example
8
+ * ```ts
9
+ * import { blank } from "@johnmorrisdotca/uchusen-rockets";
10
+ *
11
+ * console.log(blank("No source read gives it.", "not given"));
12
+ * ```
13
+ */
1
14
  export const blank = (note, brief) => ({ value: null, source: null, ...(note ? { note } : {}), ...(brief ? { brief } : {}) });
2
- /** A figure as words for a table: its value and whatever must stay beside it; a blank says why, or that no source gives it. */
15
+ /**
16
+ * A figure as words for a table: its value and whatever must stay beside it; a blank says why, or that no source gives it.
17
+ *
18
+ * @param figure A figure, or undefined.
19
+ * @param unit Text to put after a number, such as " m". Optional.
20
+ * @returns The figure as words for a table. A blank gives its `brief`, or "No source" when it has none.
21
+ * @example
22
+ * ```ts
23
+ * import { figureWords, variantOf } from "@johnmorrisdotca/uchusen-rockets";
24
+ *
25
+ * console.log(figureWords(variantOf("starship", "v3")?.facts.height, " m"));
26
+ * ```
27
+ */
3
28
  export function figureWords(figure, unit = "") {
4
29
  if (!figure || figure.value === null)
5
30
  return figure?.brief ?? "No source";
package/dist/element.d.ts CHANGED
@@ -3,10 +3,45 @@ import { UchusenFlight } from "./flightbar.ts";
3
3
  import type { Description, FitReport } from "./fit.ts";
4
4
  import { type Angle, type ViewChoice } from "./framing.ts";
5
5
  import { ROCKETS } from "./rockets.ts";
6
+ /**
7
+ * What a `<uchusen-rocket>` is doing, as its `data-state` attribute says: `picture` (the drawing), `loading` (the 3D view is on its way), `3d`, `fallback` (no WebGL, so the drawing stays) or `error`.
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * import type { RocketState } from "@johnmorrisdotca/uchusen-rockets/element";
12
+ *
13
+ * const states: RocketState[] = ["picture", "loading", "3d", "fallback", "error"];
14
+ * console.log(states.length);
15
+ * ```
16
+ */
6
17
  export type RocketState = "picture" | "loading" | "3d" | "fallback" | "error";
7
18
  declare const HTMLBase: typeof HTMLElement;
8
- /** Where the licensed models are, for every element with no `assets` attribute of its own. Left unset: beside this module, in ./assets/. */
19
+ /**
20
+ * Where the licensed models are, for every element with no `assets` attribute of its own. Left unset: beside this module, in ./assets/.
21
+ *
22
+ * @param url The folder the licensed models are in. A trailing slash is added if it has none.
23
+ * @example
24
+ * ```ts no-run
25
+ * import { setAssetBase } from "@johnmorrisdotca/uchusen-rockets/element";
26
+ *
27
+ * setAssetBase("/static/uchusen-assets/");
28
+ * ```
29
+ */
9
30
  export declare function setAssetBase(url: string): void;
31
+ /**
32
+ * The `<uchusen-rocket>` element: a rocket as a drawing that a 3D view takes over from when the browser can draw WebGL. Its attributes are the words of `RocketOptions`. It exposes its state as `data-state` and loads three.js only for a 3D view.
33
+ *
34
+ * @example
35
+ * ```ts no-run
36
+ * import { UchusenRocket } from "@johnmorrisdotca/uchusen-rockets/element";
37
+ *
38
+ * const rocket: UchusenRocket = document.createElement("uchusen-rocket") as UchusenRocket;
39
+ * rocket.setAttribute("rocket", "starship");
40
+ * rocket.setAttribute("variant", "v3");
41
+ * rocket.setAttribute("look", "painted");
42
+ * document.body.append(rocket);
43
+ * ```
44
+ */
10
45
  export declare class UchusenRocket extends HTMLBase {
11
46
  static readonly observedAttributes: string[];
12
47
  private descriptionValue;
@@ -117,14 +152,37 @@ export declare class UchusenRocket extends HTMLBase {
117
152
  private start;
118
153
  private startTilt;
119
154
  }
120
- /** Rockets side by side on one baseline at one scale: `<uchusen-lineup items="starship:v1,starship:v3,person,building" unit="4" ruler labels>`. */
155
+ /**
156
+ * Rockets side by side on one baseline at one scale: `<uchusen-lineup items="starship:v1,starship:v3,person,building" unit="4" ruler labels>`.
157
+ *
158
+ * @example
159
+ * ```ts no-run
160
+ * import { UchusenLineup } from "@johnmorrisdotca/uchusen-rockets/element";
161
+ *
162
+ * const lineup: UchusenLineup = document.createElement("uchusen-lineup") as UchusenLineup;
163
+ * lineup.setAttribute("items", "starship:v2,starship:v3,person");
164
+ * lineup.setAttribute("unit", "3");
165
+ * lineup.toggleAttribute("ruler", true);
166
+ * document.body.append(lineup);
167
+ * ```
168
+ */
121
169
  export declare class UchusenLineup extends HTMLBase {
122
170
  static readonly observedAttributes: string[];
123
171
  connectedCallback(): void;
124
172
  attributeChangedCallback(name: string, before: string | null, after: string | null): void;
125
173
  private render;
126
174
  }
127
- /** Defines both elements, once. Importing this module does it. */
175
+ /**
176
+ * Defines both elements, once. Importing this module does it.
177
+ *
178
+ * @example
179
+ * ```ts no-run
180
+ * import { defineUchusenRocket } from "@johnmorrisdotca/uchusen-rockets/element";
181
+ *
182
+ * defineUchusenRocket();
183
+ * console.log(customElements.get("uchusen-rocket") !== undefined);
184
+ * ```
185
+ */
128
186
  export declare function defineUchusenRocket(): void;
129
187
  export { ROCKETS, UchusenFlight };
130
188
  declare global {
package/dist/element.js CHANGED
@@ -21,7 +21,17 @@ const RELEASE_MS = 30_000;
21
21
  /** The drawing, followed along a turn, is made again at most this often. */
22
22
  const PLACE_MS = 50;
23
23
  let assetBase = null;
24
- /** Where the licensed models are, for every element with no `assets` attribute of its own. Left unset: beside this module, in ./assets/. */
24
+ /**
25
+ * Where the licensed models are, for every element with no `assets` attribute of its own. Left unset: beside this module, in ./assets/.
26
+ *
27
+ * @param url The folder the licensed models are in. A trailing slash is added if it has none.
28
+ * @example
29
+ * ```ts no-run
30
+ * import { setAssetBase } from "@johnmorrisdotca/uchusen-rockets/element";
31
+ *
32
+ * setAssetBase("/static/uchusen-assets/");
33
+ * ```
34
+ */
25
35
  export function setAssetBase(url) {
26
36
  assetBase = url.endsWith("/") ? url : `${url}/`;
27
37
  }
@@ -86,6 +96,20 @@ function whyNot(mode) {
86
96
  return "no-webgl";
87
97
  return "";
88
98
  }
99
+ /**
100
+ * The `<uchusen-rocket>` element: a rocket as a drawing that a 3D view takes over from when the browser can draw WebGL. Its attributes are the words of `RocketOptions`. It exposes its state as `data-state` and loads three.js only for a 3D view.
101
+ *
102
+ * @example
103
+ * ```ts no-run
104
+ * import { UchusenRocket } from "@johnmorrisdotca/uchusen-rockets/element";
105
+ *
106
+ * const rocket: UchusenRocket = document.createElement("uchusen-rocket") as UchusenRocket;
107
+ * rocket.setAttribute("rocket", "starship");
108
+ * rocket.setAttribute("variant", "v3");
109
+ * rocket.setAttribute("look", "painted");
110
+ * document.body.append(rocket);
111
+ * ```
112
+ */
89
113
  export class UchusenRocket extends HTMLBase {
90
114
  static observedAttributes = ["rocket", "variant", "show", "look", "view", "build", "mode", "assets", "spin", "way", "label", "engines", "phase"];
91
115
  descriptionValue = null;
@@ -715,7 +739,20 @@ const LINEUP_CSS = `
715
739
  :host { display: block; overflow-x: auto; color: inherit; }
716
740
  svg { display: block; }
717
741
  `;
718
- /** Rockets side by side on one baseline at one scale: `<uchusen-lineup items="starship:v1,starship:v3,person,building" unit="4" ruler labels>`. */
742
+ /**
743
+ * Rockets side by side on one baseline at one scale: `<uchusen-lineup items="starship:v1,starship:v3,person,building" unit="4" ruler labels>`.
744
+ *
745
+ * @example
746
+ * ```ts no-run
747
+ * import { UchusenLineup } from "@johnmorrisdotca/uchusen-rockets/element";
748
+ *
749
+ * const lineup: UchusenLineup = document.createElement("uchusen-lineup") as UchusenLineup;
750
+ * lineup.setAttribute("items", "starship:v2,starship:v3,person");
751
+ * lineup.setAttribute("unit", "3");
752
+ * lineup.toggleAttribute("ruler", true);
753
+ * document.body.append(lineup);
754
+ * ```
755
+ */
719
756
  export class UchusenLineup extends HTMLBase {
720
757
  static observedAttributes = ["items", "unit", "look", "view", "show", "ruler", "labels"];
721
758
  connectedCallback() {
@@ -754,7 +791,17 @@ export class UchusenLineup extends HTMLBase {
754
791
  this.dataset.count = String(shown.length);
755
792
  }
756
793
  }
757
- /** Defines both elements, once. Importing this module does it. */
794
+ /**
795
+ * Defines both elements, once. Importing this module does it.
796
+ *
797
+ * @example
798
+ * ```ts no-run
799
+ * import { defineUchusenRocket } from "@johnmorrisdotca/uchusen-rockets/element";
800
+ *
801
+ * defineUchusenRocket();
802
+ * console.log(customElements.get("uchusen-rocket") !== undefined);
803
+ * ```
804
+ */
758
805
  export function defineUchusenRocket() {
759
806
  if (typeof customElements === "undefined")
760
807
  return;