spacemap 0.1.3 → 0.1.5

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/index.d.ts CHANGED
@@ -289,6 +289,18 @@ export declare interface CoreMessages {
289
289
  cooperative_wheel: () => string;
290
290
  cooperative_wheel_mac: () => string;
291
291
  cooperative_touch: () => string;
292
+ planetary_system_primary: () => string;
293
+ planetary_system_retrograde: () => string;
294
+ planetary_system_axis_unit: () => string;
295
+ tab_rings: () => string;
296
+ system_map_solar_system: () => string;
297
+ system_map_moons: (inputs: {
298
+ count: number;
299
+ }) => string;
300
+ system_map_zone_inner: () => string;
301
+ system_map_zone_outer: () => string;
302
+ unit_symbol_astronomical_unit: () => string;
303
+ system_map_axis_au: () => string;
292
304
  }
293
305
 
294
306
  /**
@@ -340,6 +352,15 @@ export declare function createPanorama(options: PanoramaCreateOptions): Promise<
340
352
  * the extent sampling. */
341
353
  export declare function createProjection(id: ProjectionId, options?: ProjectionOptions): Projection;
342
354
 
355
+ /** Mount a system map and resolve once its first view is drawn. It is as wide
356
+ * as its container and three times as wide as it is tall. A click reports
357
+ * what was picked and goes nowhere: following it is {@link SystemMap.setView},
358
+ * which the page calls or does not.
359
+ *
360
+ * Rejects when the data does not load, or the opening view is a `system`
361
+ * named for a body with no moons. */
362
+ export declare function createSystemMap(options: SystemMapCreateOptions): Promise<SystemMap>;
363
+
343
364
  /** Convert a JS Date to Julian Date. */
344
365
  export declare function dateToJD(date: Date): number;
345
366
 
@@ -393,9 +414,9 @@ export declare interface FeatureTarget extends CameraTarget {
393
414
  * joins the page's own load rather than starting a second one. */
394
415
  export declare function fetchPanoramaIndex(fetcher?: (url: string) => Promise<Response>): Promise<PanoramaBodySummary[]>;
395
416
 
396
- /** Every panorama taken on a body, mission by mission in time order. The view
397
- * reads the same list when it opens; a page that decides which panorama to
398
- * open reads it first. Empty when the body has none. */
417
+ /** Every panorama taken on a body, mission by mission in time order: the list
418
+ * the view reads when it opens, before it drops the stops it cannot show
419
+ * ({@link isViewable}). Empty when the body has none. */
399
420
  export declare function fetchPanoramas(bodyId: string): Promise<PanoramaEntry[]>;
400
421
 
401
422
  export declare function findPanorama(entries: PanoramaEntry[], at: string | null): PanoramaEntry | null;
@@ -937,6 +958,10 @@ export declare type Interpolation =
937
958
  * track means by a straight line. */
938
959
  | 'geodesic';
939
960
 
961
+ /** Whether a stop has a sphere to open, as against a place on the traverse:
962
+ * one exists, and this host's terms reach it. */
963
+ export declare function isViewable(entry: PanoramaEntry): boolean;
964
+
940
965
  /** Convert a Julian Date to a JS Date. */
941
966
  export declare function jdToDate(jd: number): Date;
942
967
 
@@ -1562,6 +1587,9 @@ export declare interface PolylineOptions {
1562
1587
  widthPx?: number;
1563
1588
  /** 0 to 1. */
1564
1589
  opacity?: number;
1590
+ /** A dash and a gap in screen pixels, written as the flat map takes them:
1591
+ * `"4 3"`. Solid when left out. */
1592
+ dash?: string;
1565
1593
  /** Fade the line toward its last point, the way an orbit trail fades
1566
1594
  * behind a body. */
1567
1595
  fade?: boolean;
@@ -1855,6 +1883,23 @@ export declare class SpaceMap {
1855
1883
  /** Ids of the objects orbiting `id` that this map has loaded. Loading is
1856
1884
  * driven by focus and by the clock, so the list grows as the reader moves. */
1857
1885
  getChildren(id: string): string[];
1886
+ /** The date the measures answer for: the one the bodies are placed at,
1887
+ * which the clock runs ahead of while no frame is drawn. */
1888
+ private get placedJd();
1889
+ /** Kilometres between two places, as the last frame drew them: a body's
1890
+ * centre, a point on its surface, anything an anchor names. Null while
1891
+ * either end is on a body this map has not loaded, or one that is nowhere
1892
+ * at that date. */
1893
+ distanceKm(from: Anchor, to: Anchor): number | null;
1894
+ /** The same measure with its direction kept: from one place to the other,
1895
+ * in kilometres on ecliptic J2000 axes. What a held camera's `up` is made
1896
+ * from, when up is a way along a body's surface. */
1897
+ offsetKm(from: Anchor, to: Anchor): OffsetKm | null;
1898
+ /** Where on `id` the Sun is overhead, as the last frame drew it: the middle
1899
+ * of the lit half, in the frame a surface anchor is placed in. Null for a
1900
+ * body not loaded, and until the map has read how it spins, which it does
1901
+ * once the camera is on the body or its system. */
1902
+ getSubsolarPoint(id: string): LonLat | null;
1858
1903
  /* Excluded from this release type: load */
1859
1904
  /* Excluded from this release type: open */
1860
1905
  /* Excluded from this release type: applyInitialView */
@@ -1993,6 +2038,17 @@ export declare class SpaceMap {
1993
2038
  * is nothing to choose once a host has said what it looks like.
1994
2039
  */
1995
2040
  setBodyAppearance(id: string, appearance: BodyAppearance): this;
2041
+ /**
2042
+ * Keep these bodies in sight from however far: named, with their orbits,
2043
+ * where the map would let a small or distant one drop out and would give
2044
+ * its name up to a bigger neighbour's. A hidden layer does not take them
2045
+ * either. An id the map has not loaded yet is pinned once it has. Each call
2046
+ * replaces the last; an empty list gives the map its own judgement back.
2047
+ *
2048
+ * A moon is only drawn inside the system the camera is in, pinned or not:
2049
+ * pin its planet to mark it from outside.
2050
+ */
2051
+ setPinnedBodies(ids: readonly string[]): this;
1996
2052
  /** A cap's radius as an angle, from whichever of the two ways the host gave
1997
2053
  * it. A radius in kilometres needs the body's own radius, which an
1998
2054
  * unloaded body has not published yet. */
@@ -2072,6 +2128,9 @@ export declare interface SurfacePolygonOptions extends SurfaceShapeOptions {
2072
2128
  export declare interface SurfacePolylineOptions extends SurfaceShapeOptions {
2073
2129
  /** Join the last place back to the first. */
2074
2130
  closed?: boolean;
2131
+ /** A dash and a gap in screen pixels, written as the flat map takes them:
2132
+ * `"4 3"`. Solid when left out. */
2133
+ dash?: string;
2075
2134
  }
2076
2135
 
2077
2136
  /** A shape on a body's surface, for as long as the host keeps it. */
@@ -2100,6 +2159,153 @@ export declare interface SurfaceShapeOptions extends ShapeStyle {
2100
2159
  altitudeKm?: number;
2101
2160
  }
2102
2161
 
2162
+ /** The diagram and what it shows. It follows no click: `select` says what was
2163
+ * picked and {@link SystemMap.setView} is the page's to call. */
2164
+ export declare class SystemMap {
2165
+ private readonly chart;
2166
+ private readonly listeners;
2167
+ private view;
2168
+ private bodies;
2169
+ private readonly names;
2170
+ private readonly grouping;
2171
+ private readonly zones;
2172
+ private readonly places;
2173
+ private targets;
2174
+ /** Bundles read for the bodies no map file places, by id; null where the
2175
+ * bundle has no orbit to place it by. */
2176
+ private readonly extras;
2177
+ /** Draws run one after another, so a later one neither lands under an
2178
+ * earlier nor takes it off the map by failing. */
2179
+ private queue;
2180
+ private disposed;
2181
+ constructor(options?: SystemMapOptions);
2182
+ /* Excluded from this release type: mount */
2183
+ /** Take the map back out of its container. It is finished afterwards; open
2184
+ * another with {@link createSystemMap}. */
2185
+ remove(): void;
2186
+ /* Excluded from this release type: load */
2187
+ /** Draw another view. Resolves once it is on screen; rejects, leaving the
2188
+ * map as it was, when the view cannot be loaded — a `system` named for a
2189
+ * body with no moons has no map. */
2190
+ setView(view: SystemMapView): Promise<void>;
2191
+ getView(): SystemMapView;
2192
+ /** Change which bodies are worth drawing; null for all of them. The view
2193
+ * stays, redrawn: resolves once it is, and `error` says when it could not be. */
2194
+ setBodies(ids: readonly string[] | null): Promise<void>;
2195
+ /** Everything a click on the current view can pick. */
2196
+ getTargets(): SystemMapTarget[];
2197
+ /** Draw `view`, or the one on the map, in its turn. `bodies` is taken up
2198
+ * at that turn too, so it never changes under a draw that is under way. */
2199
+ private draw;
2200
+ private drawNow;
2201
+ private build;
2202
+ /** One body's own bundle, read once. A body that cannot be read is left
2203
+ * off the map and reported, rather than taking the view down with it. */
2204
+ private extra;
2205
+ /** The primary's and its notable moons' names as the export has them, in
2206
+ * the reading language where it has them in it. Empty when the bundle does not load: the map then
2207
+ * falls back to ids rather than failing over a label. */
2208
+ private exportedNames;
2209
+ /** Listen for `event`. The returned function stops listening, which is the
2210
+ * same thing {@link off} does. */
2211
+ on<K extends keyof SystemMapEvents>(event: K, listener: SystemMapEvents[K]): () => void;
2212
+ /** Listen for the next `event` only. */
2213
+ once<K extends keyof SystemMapEvents>(event: K, listener: SystemMapEvents[K]): () => void;
2214
+ off<K extends keyof SystemMapEvents>(event: K, listener: SystemMapEvents[K]): void;
2215
+ private emit;
2216
+ }
2217
+
2218
+ export declare interface SystemMapCreateOptions extends CommonOptions, SystemMapOptions {
2219
+ /** Listeners attached before the first load, so a failed one is observable
2220
+ * while it runs. Later ones go through {@link SystemMap.on}. */
2221
+ events?: {
2222
+ [K in keyof SystemMapEvents]?: SystemMapEvents[K];
2223
+ };
2224
+ }
2225
+
2226
+ export declare interface SystemMapEvents {
2227
+ /** Something was picked. The map does not follow it: {@link SystemMap.setView}
2228
+ * is the host's to call. */
2229
+ select: (target: SystemMapTarget) => void;
2230
+ viewchange: (view: SystemMapView) => void;
2231
+ /** A view could not be loaded, or a body named in `bodies` could not be read. */
2232
+ error: (error: Error) => void;
2233
+ }
2234
+
2235
+ export declare interface SystemMapOptions {
2236
+ /** What to draw first; the Solar System when omitted. */
2237
+ view?: SystemMapView;
2238
+ /** The ids worth drawing, for a map that offers part of the catalogue. A
2239
+ * primary outside them is still drawn while a moon of it is in, as the
2240
+ * thing the moon is found by. Everything the export lists when omitted. */
2241
+ bodies?: readonly string[];
2242
+ /** Names by id, over the export's own. */
2243
+ names?: Record<string, string>;
2244
+ /** Bodies neither map file places, described by the page so the map need
2245
+ * not read each one's bundle to draw it in its zone. */
2246
+ places?: readonly SystemMapPlace[];
2247
+ /** `systems` makes a primary and the moons stacked on it one target, a
2248
+ * `system`; `bodies` leaves the dot and the stack a target each. */
2249
+ grouping?: 'bodies' | 'systems';
2250
+ /** `inner-outer` turns the two belts into the doors of the two zones of
2251
+ * small bodies; `belts` leaves them the scenery they are. */
2252
+ zones?: 'belts' | 'inner-outer';
2253
+ }
2254
+
2255
+ /**
2256
+ * A body the map files name no place for, as a page that already knows it
2257
+ * describes it. The map otherwise reads the body's own bundle to place it,
2258
+ * which is a few hundred kilobytes a body.
2259
+ */
2260
+ export declare interface SystemMapPlace {
2261
+ id: string;
2262
+ /** The id when left out, unless `names` has one. */
2263
+ name?: string;
2264
+ /** A moon rides in the stack over `parent` rather than on the axis. */
2265
+ moon?: boolean;
2266
+ /** Semi-major axis about the Sun in AU, or the perihelion of an orbit that
2267
+ * has none. A moon needs none. */
2268
+ aAu?: number;
2269
+ /** Inclination to the ecliptic. */
2270
+ tiltDeg?: number;
2271
+ radiusKm?: number;
2272
+ /** `#rrggbb`. */
2273
+ color?: string;
2274
+ /** What a moon orbits. */
2275
+ parent?: string;
2276
+ }
2277
+
2278
+ /** What a click picked. A `system` is a primary drawn with satellites, named
2279
+ * by the primary's id. */
2280
+ export declare type SystemMapTarget = {
2281
+ kind: 'body';
2282
+ id: string;
2283
+ name: string;
2284
+ } | {
2285
+ kind: 'system';
2286
+ id: string;
2287
+ name: string;
2288
+ } | {
2289
+ kind: 'zone';
2290
+ zone: SystemMapZone;
2291
+ name: string;
2292
+ };
2293
+
2294
+ export declare type SystemMapView = {
2295
+ kind: 'solar-system';
2296
+ }
2297
+ /** One planetary system, named by its primary: `naif-699`, `naif-999`. */
2298
+ | {
2299
+ kind: 'system';
2300
+ id: string;
2301
+ } | {
2302
+ kind: 'zone';
2303
+ zone: SystemMapZone;
2304
+ };
2305
+
2306
+ /** Small bodies inside Jupiter's orbit, or from it outward. */
2307
+ export declare type SystemMapZone = 'inner' | 'outer';
2308
+
2103
2309
  /** Who may serve a surface map, widest first. A body whose map this embed may
2104
2310
  * not draw renders in its fallback colour, as an untextured body does. */
2105
2311
  declare type TextureDistribution = 'open' | 'non-commercial' | 'site-only';