@johnmorrisdotca/wakusei-planets 0.31.0 → 0.33.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 (73) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/NOTICE.md +16 -1
  3. package/README.md +60 -5
  4. package/dist/bodies/all.d.ts +1 -0
  5. package/dist/bodies/all.js +1 -0
  6. package/dist/bodies/minor.d.ts +1 -0
  7. package/dist/bodies/minor.js +16 -0
  8. package/dist/data/minor.d.ts +3 -0
  9. package/dist/data/minor.js +7 -0
  10. package/dist/data/tables.d.ts +4 -2
  11. package/dist/data/tables.js +1 -1
  12. package/dist/data-door.d.ts +357 -0
  13. package/dist/data-door.js +393 -0
  14. package/dist/door/book.d.ts +133 -0
  15. package/dist/door/book.js +256 -0
  16. package/dist/door/host.d.ts +30 -0
  17. package/dist/door/host.js +44 -0
  18. package/dist/door/index.d.ts +6 -0
  19. package/dist/door/index.js +10 -0
  20. package/dist/door/map.d.ts +152 -0
  21. package/dist/door/map.js +162 -0
  22. package/dist/door/own.d.ts +36 -0
  23. package/dist/door/own.js +86 -0
  24. package/dist/door/points.d.ts +61 -0
  25. package/dist/door/points.js +175 -0
  26. package/dist/door/small-bodies.d.ts +157 -0
  27. package/dist/door/small-bodies.js +148 -0
  28. package/dist/element.d.ts +21 -0
  29. package/dist/element.js +85 -6
  30. package/dist/embed.d.ts +1 -1
  31. package/dist/embed.js +3 -3
  32. package/dist/ephemeris.d.ts +7 -7
  33. package/dist/ephemeris.js +36 -13
  34. package/dist/facts.d.ts +28 -4
  35. package/dist/facts.js +24 -2
  36. package/dist/index.d.ts +1 -1
  37. package/dist/index.js +1 -1
  38. package/dist/nearest.js +6 -4
  39. package/dist/scene/body.d.ts +4 -1
  40. package/dist/scene/body.js +2 -1
  41. package/dist/scene/detail.d.ts +29 -12
  42. package/dist/scene/detail.js +217 -135
  43. package/dist/scene/painter.d.ts +3 -0
  44. package/dist/scene/painter.js +7 -4
  45. package/dist/scene/textures.d.ts +9 -2
  46. package/dist/scene/textures.js +17 -0
  47. package/dist/space/arrows.d.ts +29 -3
  48. package/dist/space/arrows.js +38 -6
  49. package/dist/space/bodies.d.ts +6 -6
  50. package/dist/space/bodies.js +6 -6
  51. package/dist/space/element.d.ts +28 -0
  52. package/dist/space/element.js +74 -6
  53. package/dist/space/frame.d.ts +28 -3
  54. package/dist/space/frame.js +40 -4
  55. package/dist/space/index.d.ts +2 -2
  56. package/dist/space/index.js +2 -2
  57. package/dist/space/scale.d.ts +4 -4
  58. package/dist/space/scale.js +8 -2
  59. package/dist/space/scene.d.ts +12 -2
  60. package/dist/space/scene.js +43 -14
  61. package/dist/stops.d.ts +1 -1
  62. package/dist/stops.js +4 -1
  63. package/dist/tables/all.d.ts +1 -0
  64. package/dist/tables/all.js +1 -0
  65. package/dist/tables/lazy.d.ts +5 -0
  66. package/dist/tables/lazy.js +12 -0
  67. package/dist/tables/minor.d.ts +1 -0
  68. package/dist/tables/minor.js +317 -0
  69. package/dist/textures/vesta-1024.webp +0 -0
  70. package/dist/textures/vesta-512.webp +0 -0
  71. package/dist/version.d.ts +1 -1
  72. package/dist/version.js +1 -1
  73. package/package.json +17 -2
@@ -0,0 +1,357 @@
1
+ /**
2
+ * A licence: its name and a link are always shown beside the credit. *
3
+ * @example
4
+ * ```ts no-check
5
+ * import type { Licence } from "./data-door.ts";
6
+ *
7
+ * const licence: Licence = { name: "CC BY 4.0", url: "https://creativecommons.org/licenses/by/4.0/", spdx: "CC-BY-4.0" };
8
+ * ```
9
+ */
10
+ export interface Licence {
11
+ name: string;
12
+ url: string;
13
+ /** An SPDX identifier, when there is one. */
14
+ spdx?: string;
15
+ nonCommercial?: boolean;
16
+ shareAlike?: boolean;
17
+ }
18
+ /**
19
+ * What a source says about itself. *
20
+ * @example
21
+ * ```ts no-check
22
+ * import type { SourceInfo } from "./data-door.ts";
23
+ *
24
+ * const info: SourceInfo = {
25
+ * id: "my-catalogue",
26
+ * name: { en: "My catalogue", ja: "私のカタログ" },
27
+ * credit: { en: "My catalogue, A. Person (2026)", ja: "私のカタログ(A. Person、2026年)" },
28
+ * licence: { name: "CC BY 4.0", url: "https://creativecommons.org/licenses/by/4.0/" },
29
+ * url: "https://example.org/my-catalogue",
30
+ * retrieved: "2026-11-10",
31
+ * };
32
+ * ```
33
+ */
34
+ export interface SourceInfo {
35
+ /** Unique in a view: lower-case letters, digits and hyphens ("ucac4", "my-catalogue"). */
36
+ id: string;
37
+ name: {
38
+ en: string;
39
+ ja: string;
40
+ };
41
+ /** The line shown on screen. Never empty, in both languages. */
42
+ credit: {
43
+ en: string;
44
+ ja: string;
45
+ };
46
+ /** The licence: its name and link are always shown with the credit. */
47
+ licence: Licence;
48
+ /** The source's own page. */
49
+ url: string;
50
+ /** The day it was retrieved, yyyy-mm-dd, as NOTICE.md writes it. */
51
+ retrieved: string;
52
+ }
53
+ /**
54
+ * The most records a record source may hold. Bigger data must be tiles. *
55
+ * @example
56
+ * ```ts no-check
57
+ * import { MAX_RECORDS } from "./data-door.ts";
58
+ *
59
+ * console.log(MAX_RECORDS); // 200000
60
+ * ```
61
+ */
62
+ export declare const MAX_RECORDS = 200000;
63
+ /**
64
+ * The default budget for decoded tiles in a view, all sources together: 48 MB (a picture counts with its mipmaps, 4/3 of its bytes). *
65
+ * @example
66
+ * ```ts no-check
67
+ * import { TILE_BUDGET_BYTES } from "./data-door.ts";
68
+ *
69
+ * console.log(TILE_BUDGET_BYTES / 1024 / 1024); // 48
70
+ * ```
71
+ */
72
+ export declare const TILE_BUDGET_BYTES: number;
73
+ /**
74
+ * The most loads in flight at once for one source. *
75
+ * @example
76
+ * ```ts no-check
77
+ * import { MAX_IN_FLIGHT } from "./data-door.ts";
78
+ *
79
+ * console.log(MAX_IN_FLIGHT); // 6
80
+ * ```
81
+ */
82
+ export declare const MAX_IN_FLIGHT = 6;
83
+ /**
84
+ * A list that fits in memory (at most `MAX_RECORDS` records; bigger data must be tiles). It is read once, when the source is added. *
85
+ * @example
86
+ * ```ts no-check
87
+ * import type { RecordSource } from "./data-door.ts";
88
+ *
89
+ * declare const info: import("./data-door.ts").SourceInfo;
90
+ * const source: RecordSource<{ id: string }> = { kind: "records", info, records: () => [{ id: "a" }] };
91
+ * ```
92
+ */
93
+ export interface RecordSource<R> {
94
+ kind: "records";
95
+ info: SourceInfo;
96
+ records(signal: AbortSignal): R[] | Promise<R[]>;
97
+ }
98
+ /**
99
+ * Data cut by place and by detail. `Place` and `Detail` are the package's own types. *
100
+ * @example
101
+ * ```ts no-check
102
+ * import type { TileSource } from "./data-door.ts";
103
+ *
104
+ * declare const info: import("./data-door.ts").SourceInfo;
105
+ * const source: TileSource<string, number, Uint8Array> = {
106
+ * kind: "tiles",
107
+ * info,
108
+ * need: (place, detail) => [`${place}/${detail}`],
109
+ * load: async () => new Uint8Array(16),
110
+ * bytes: (tile) => tile.byteLength,
111
+ * };
112
+ * ```
113
+ */
114
+ export interface TileSource<Place, Detail, Tile> {
115
+ kind: "tiles";
116
+ info: SourceInfo;
117
+ /** The keys of the tiles a place needs at a detail. Pure: no fetching. */
118
+ need(place: Place, detail: Detail): readonly string[];
119
+ /** Loads one tile. The source may use the network or not; it must stop when the signal aborts. */
120
+ load(key: string, signal: AbortSignal): Promise<Tile>;
121
+ /** The tile's size in memory, in bytes, for the budget. */
122
+ bytes(tile: Tile): number;
123
+ }
124
+ /**
125
+ * Either kind of source. *
126
+ * @example
127
+ * ```ts no-check
128
+ * import type { DataSource } from "./data-door.ts";
129
+ *
130
+ * const kinds = (sources: DataSource[]): string[] => sources.map((source) => source.kind);
131
+ * ```
132
+ */
133
+ export type DataSource = RecordSource<unknown> | TileSource<unknown, unknown, unknown>;
134
+ /**
135
+ * A piece of a map, in degrees: longitude and latitude (right ascension and declination for the sky). One shape in every package. *
136
+ * @example
137
+ * ```ts no-check
138
+ * import type { MapPlace } from "./data-door.ts";
139
+ *
140
+ * const wholeSky: MapPlace = { lonMin: 0, lonMax: 360, latMin: -90, latMax: 90 };
141
+ * ```
142
+ */
143
+ export interface MapPlace {
144
+ lonMin: number;
145
+ lonMax: number;
146
+ latMin: number;
147
+ latMax: number;
148
+ }
149
+ /**
150
+ * What a picture needs of its bitmap: an `ImageBitmap` fits. *
151
+ * @example
152
+ * ```ts no-check
153
+ * import type { BitmapLike } from "./data-door.ts";
154
+ *
155
+ * const size = (bitmap: BitmapLike): number => bitmap.width * bitmap.height;
156
+ * ```
157
+ */
158
+ export interface BitmapLike {
159
+ readonly width: number;
160
+ readonly height: number;
161
+ close?(): void;
162
+ }
163
+ /**
164
+ * A map tile: its size in pixels and its picture. A map source's detail is the pixels across the whole circumference (not a level number, because the packages number their pyramids differently),
165
+ * and each source maps a width to its own nearest level.
166
+ *
167
+ * @example
168
+ * ```ts no-check
169
+ * import type { ImageTile } from "./data-door.ts";
170
+ *
171
+ * const tile: ImageTile = { width: 512, height: 256, image: await createImageBitmap(blob) };
172
+ * ```
173
+ */
174
+ export interface ImageTile {
175
+ width: number;
176
+ height: number;
177
+ image: BitmapLike;
178
+ }
179
+ /**
180
+ * One source's part in the last drawn frame. *
181
+ * @example
182
+ * ```ts no-check
183
+ * import type { Credit } from "./data-door.ts";
184
+ *
185
+ * declare const info: import("./data-door.ts").SourceInfo;
186
+ * const credit: Credit = { source: info, own: false, used: 12 };
187
+ * ```
188
+ */
189
+ export interface Credit {
190
+ source: SourceInfo;
191
+ /** True for the package's own (bundled) data. */
192
+ own: boolean;
193
+ /** The marks or tiles drawn from it. */
194
+ used: number;
195
+ }
196
+ /**
197
+ * Refuses a source that cannot be shown honestly: it throws a `TypeError` at once, when a source is added, not at the first draw. An empty credit (either language), a licence with no name or no
198
+ * link, a bad or already used id, a missing name, page or day, or a missing function is refused.
199
+ * @param source What the caller handed in.
200
+ * @param taken The ids already in the view, so that a clash is refused.
201
+ * @example
202
+ * ```ts no-check
203
+ * import { validateSource } from "./data-door.ts";
204
+ *
205
+ * validateSource(mySource, view.sources.map((one) => one.info.id)); // throws TypeError: source "mine": the credit is empty (en)
206
+ * ```
207
+ */
208
+ export declare function validateSource(source: unknown, taken?: Iterable<string>): asserts source is DataSource;
209
+ /**
210
+ * The credit line for what a view drew: each source's credit with its licence name, and "non-commercial" or "share-alike" whenever the source says so, so a page cannot hide the terms of the data it
211
+ * uses. The package's own sources come first, then the rest, each group in the order given; a source listed twice is written once. English: joined with semicolons, ending in a full stop. Japanese: the
212
+ * licence in full-width parentheses, joined with /, no full stop. An empty list is an empty string.
213
+ * @param credits What the view drew, from its `credits()`.
214
+ * @param language `"en"` or `"ja"`.
215
+ * @returns The line, or an empty string for no credits.
216
+ * @example
217
+ * ```ts no-check
218
+ * import { creditLine } from "./data-door.ts";
219
+ *
220
+ * creditLine(view.credits(), "en"); // "Yale Bright Star Catalogue (Public domain); UCAC4 (CC0 1.0)."
221
+ * creditLine(view.credits(), "ja"); // "イェール輝星カタログ(パブリックドメイン)/UCAC4(CC0 1.0)"
222
+ * ```
223
+ */
224
+ export declare function creditLine(credits: readonly Credit[], language: "en" | "ja"): string;
225
+ /**
226
+ * What `loadRecords` found. `skipped` counts the records dropped for a non-finite number; a failed read has no records and says why.
227
+ *
228
+ * @example
229
+ * ```ts no-check
230
+ * import type { RecordsRead } from "./data-door.ts";
231
+ *
232
+ * const say = (read: RecordsRead<unknown>): string => `${read.status}: ${read.records.length} kept, ${read.skipped} skipped`;
233
+ * ```
234
+ */
235
+ export interface RecordsRead<R> {
236
+ status: "ok" | "failed" | "aborted";
237
+ /** Frozen. Empty unless the read succeeded. */
238
+ records: readonly R[];
239
+ skipped: number;
240
+ /** Why a read failed. */
241
+ reason?: string;
242
+ }
243
+ /**
244
+ * Reads a record source once, when it is added: the list is frozen, a record with a non-finite number (a `NaN` or an infinity in any number `finite` names) is skipped and counted, and a list over
245
+ * `MAX_RECORDS` is refused whole (bigger data must be tiles). It never throws: a source that throws or rejects is a failed read, and a read the signal aborted is `aborted`.
246
+ * @param source The record source.
247
+ * @param signal Aborts the read (the source is removed or switched off).
248
+ * @param finite The numbers of one record that must be finite, if any: `(star) => [star.ra, star.dec, star.mag]`.
249
+ * @returns What was found: the status, the frozen records, how many were skipped and, for a failed read, why.
250
+ * @example
251
+ * ```ts no-check
252
+ * import { loadRecords } from "./data-door.ts";
253
+ *
254
+ * const read = await loadRecords(source, controller.signal, (star) => [star.ra, star.dec]); // read.records is frozen; read.skipped counts the NaNs
255
+ * ```
256
+ */
257
+ export declare function loadRecords<R>(source: RecordSource<R>, signal: AbortSignal, finite?: (record: R) => readonly number[]): Promise<RecordsRead<R>>;
258
+ /**
259
+ * The part of a tile source the store uses.
260
+ *
261
+ * @example
262
+ * ```ts no-check
263
+ * import type { TileLoader } from "./data-door.ts";
264
+ *
265
+ * const loader: TileLoader<Uint8Array> = { info, load: async () => new Uint8Array(8), bytes: (tile) => tile.byteLength };
266
+ * ```
267
+ */
268
+ export type TileLoader<Tile> = Pick<TileSource<unknown, unknown, Tile>, "info" | "load" | "bytes">;
269
+ /**
270
+ * Options for `createTileStore`.
271
+ *
272
+ * @example
273
+ * ```ts no-check
274
+ * import type { TileStoreOptions } from "./data-door.ts";
275
+ *
276
+ * const options: TileStoreOptions = { budgetBytes: 24 * 1024 * 1024, maxTiles: 256, onChange: () => draw() };
277
+ * ```
278
+ */
279
+ export interface TileStoreOptions {
280
+ /** The bytes of decoded tiles held, all sources together. Default `TILE_BUDGET_BYTES`. */
281
+ budgetBytes?: number;
282
+ /** The most loads in flight for one source. Default `MAX_IN_FLIGHT`. */
283
+ maxInFlight?: number;
284
+ /** The most tiles held, all sources together, as well as the byte budget. Default: no limit. */
285
+ maxTiles?: number;
286
+ /** Called when a tile has arrived, failed or been refused, so the view can redraw. */
287
+ onChange?: () => void;
288
+ }
289
+ /**
290
+ * What a tile store has done.
291
+ *
292
+ * @example
293
+ * ```ts no-check
294
+ * import type { TileStats } from "./data-door.ts";
295
+ *
296
+ * const full = (stats: TileStats): boolean => stats.refused > 0;
297
+ * ```
298
+ */
299
+ export interface TileStats {
300
+ /** Tiles held, and their bytes: `heldBytes` is never over the budget. */
301
+ held: number;
302
+ heldBytes: number;
303
+ /** Loads running now, and loads waiting for a free place. */
304
+ inFlight: number;
305
+ queued: number;
306
+ /** Loads started since the store was made: the number a test reads to prove nothing is sent at rest. */
307
+ requested: number;
308
+ /** Tiles that failed to load, came back empty, or reported a size that is not a number. They are never held or drawn. */
309
+ failed: number;
310
+ /** Tiles that arrived and did not fit, because every tile held was needed by the view. They are not held; the view draws what it holds. */
311
+ refused: number;
312
+ /** Tiles let go to make room. */
313
+ evicted: number;
314
+ }
315
+ /**
316
+ * A tile store: tiles by source and key, under one byte budget.
317
+ *
318
+ * @example
319
+ * ```ts no-check
320
+ * import type { TileStore } from "./data-door.ts";
321
+ *
322
+ * const held = (store: TileStore<Uint8Array>): number => store.stats().held;
323
+ * ```
324
+ */
325
+ export interface TileStore<Tile> {
326
+ /**
327
+ * Tells the store which tiles `source` needs now, and returns the ones it holds. When the keys are the same as the last call it does nothing, so a view that asks again at rest sends nothing;
328
+ * when they changed, the missing ones load (a tile that failed is tried again only now), the loads of tiles no longer needed are aborted, and the held ones are marked used.
329
+ * `again: true` is for a caller that means "try what is missing once more" with the same keys: it starts the missing tiles that are not already loading or waiting, and nothing else changes.
330
+ */
331
+ want(source: TileLoader<Tile>, keys: readonly string[], again?: boolean): ReadonlyMap<string, Tile>;
332
+ /** One held tile, or `undefined`. */
333
+ get(sourceId: string, key: string): Tile | undefined;
334
+ /** Forgets a source: aborts its loads, frees its tiles. The source is switched off. */
335
+ drop(sourceId: string): void;
336
+ stats(): TileStats;
337
+ /** Resolves when no load is running or waiting. */
338
+ idle(): Promise<void>;
339
+ }
340
+ /**
341
+ * A tile store for a view: loads the tiles of every source by key and keeps them under one budget of bytes (default 48 MB, all sources together).
342
+ * - At most `maxInFlight` loads (6) run at once for a source, and a load starts only because the keys changed: at rest the store sends nothing, and a tile that failed waits for the next change.
343
+ * - The least recently used tile goes first when room is needed, and never a tile the view needs now. If a new tile does not fit even so, it is refused and counted: the held bytes never pass the budget (nor the count, if `maxTiles` is set).
344
+ * - A tile that throws, comes back empty or reports a size that is not a finite number is counted in `failed` and never held, so it is never drawn.
345
+ * - `drop(sourceId)` aborts the source's loads and frees its tiles.
346
+ * @param options Budget, loads in flight, and a callback for a redraw.
347
+ * @returns The store.
348
+ * @example
349
+ * ```ts no-check
350
+ * import { createTileStore } from "./data-door.ts";
351
+ *
352
+ * const store = createTileStore<Tile>({ onChange: draw });
353
+ * const held = store.want(source, source.need(place, detail)); // draws what is held now; the rest arrives through onChange
354
+ * store.drop(source.info.id); // the layer is switched off
355
+ * ```
356
+ */
357
+ export declare function createTileStore<Tile>(options?: TileStoreOptions): TileStore<Tile>;