@motioncomplex/cosmos-lib 1.0.9
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/README.md +125 -0
- package/dist/api.d.ts +246 -0
- package/dist/cache.d.ts +11 -0
- package/dist/clock.d.ts +181 -0
- package/dist/constants.d.ts +43 -0
- package/dist/data/constellations.d.ts +58 -0
- package/dist/data/cutouts.d.ts +70 -0
- package/dist/data/deep-sky.d.ts +27 -0
- package/dist/data/images.d.ts +147 -0
- package/dist/data/index.d.ts +422 -0
- package/dist/data/messier.d.ts +61 -0
- package/dist/data/ps1-files.d.ts +11 -0
- package/dist/data/showers.d.ts +62 -0
- package/dist/data/solar-system.d.ts +34 -0
- package/dist/data/stars.d.ts +57 -0
- package/dist/data/textures.d.ts +67 -0
- package/dist/eclipse.d.ts +176 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +237 -0
- package/dist/index.js +713 -0
- package/dist/math.d.ts +532 -0
- package/dist/media-DVOcIMa1.js +252 -0
- package/dist/media-DlE7RKBL.cjs +1 -0
- package/dist/media.d.ts +217 -0
- package/dist/moon.d.ts +170 -0
- package/dist/planner.d.ts +224 -0
- package/dist/react/index.cjs +1 -0
- package/dist/react/index.d.ts +167 -0
- package/dist/react/index.js +163 -0
- package/dist/skymap-hittest.d.ts +69 -0
- package/dist/skymap-interactive-CLg6FA0X.js +6377 -0
- package/dist/skymap-interactive-D2OZFwJ7.cjs +1 -0
- package/dist/skymap-interactive.d.ts +153 -0
- package/dist/skymap.d.ts +172 -0
- package/dist/sun.d.ts +119 -0
- package/dist/three/factories.d.ts +160 -0
- package/dist/three/flight.d.ts +116 -0
- package/dist/three/index.cjs +20 -0
- package/dist/three/index.d.ts +21 -0
- package/dist/three/index.js +404 -0
- package/dist/three/lod.d.ts +100 -0
- package/dist/three/shaders.d.ts +22 -0
- package/dist/three/types.d.ts +169 -0
- package/dist/transitions.d.ts +246 -0
- package/dist/types.d.ts +730 -0
- package/dist/units.d.ts +132 -0
- package/package.json +93 -0
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime coordinate-based image cutout functions.
|
|
3
|
+
*
|
|
4
|
+
* These query Pan-STARRS DR2 and DSS by exact RA/Dec coordinates,
|
|
5
|
+
* guaranteeing the returned image is the correct object. The precomputed
|
|
6
|
+
* file list in {@link PS1_FILES} eliminates the first of Pan-STARRS'
|
|
7
|
+
* two-step request flow, cutting latency roughly in half.
|
|
8
|
+
*
|
|
9
|
+
* @module
|
|
10
|
+
*/
|
|
11
|
+
/** Result from a coordinate-based cutout request. */
|
|
12
|
+
export interface CutoutResult {
|
|
13
|
+
/** Direct image URL. */
|
|
14
|
+
url: string;
|
|
15
|
+
/** Image format. */
|
|
16
|
+
format: 'jpg' | 'gif';
|
|
17
|
+
/** Attribution string. */
|
|
18
|
+
credit: string;
|
|
19
|
+
/** Source identifier. */
|
|
20
|
+
source: 'panstarrs' | 'dss';
|
|
21
|
+
}
|
|
22
|
+
/** Options controlling cutout generation. */
|
|
23
|
+
export interface CutoutOptions {
|
|
24
|
+
/** Desired output width in pixels. @defaultValue `1024` */
|
|
25
|
+
outputSize?: number;
|
|
26
|
+
/** FOV multiplier around object angular size. @defaultValue `1.6` */
|
|
27
|
+
padding?: number;
|
|
28
|
+
/** Minimum FOV floor in arcminutes. @defaultValue `4` */
|
|
29
|
+
minFov?: number;
|
|
30
|
+
/** Maximum FOV ceiling in arcminutes. @defaultValue `120` */
|
|
31
|
+
maxFov?: number;
|
|
32
|
+
/** Timeout in milliseconds for each API call. @defaultValue `15000` */
|
|
33
|
+
timeout?: number;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Compute the field-of-view in arcminutes for a given object.
|
|
37
|
+
*
|
|
38
|
+
* Uses the object's angular size with padding when known, or a
|
|
39
|
+
* type-based default. Clamped to `[minFov, maxFov]`.
|
|
40
|
+
*
|
|
41
|
+
* @param sizeArcmin - Angular diameter in arcminutes, or `undefined`.
|
|
42
|
+
* @param objectType - Object type string (e.g. `'nebula'`, `'star'`).
|
|
43
|
+
* @param opts - Padding and clamping overrides.
|
|
44
|
+
*/
|
|
45
|
+
export declare function computeFov(sizeArcmin: number | undefined, objectType: string, opts?: Pick<CutoutOptions, 'padding' | 'minFov' | 'maxFov'>): number;
|
|
46
|
+
/**
|
|
47
|
+
* Build a Pan-STARRS DR2 color cutout URL using the precomputed file list.
|
|
48
|
+
*
|
|
49
|
+
* Returns `null` if dec < -30 (below coverage), no precomputed file list
|
|
50
|
+
* exists for this object, or the HEAD check fails.
|
|
51
|
+
*
|
|
52
|
+
* @param id - Object identifier for the precomputed lookup.
|
|
53
|
+
* @param ra - Right Ascension in degrees (J2000).
|
|
54
|
+
* @param dec - Declination in degrees (J2000).
|
|
55
|
+
* @param fovArcmin - Desired field of view in arcminutes.
|
|
56
|
+
* @param opts - Output size and timeout options.
|
|
57
|
+
*/
|
|
58
|
+
export declare function tryPanSTARRS(id: string, ra: number, dec: number, fovArcmin: number, opts?: CutoutOptions): Promise<CutoutResult | null>;
|
|
59
|
+
/**
|
|
60
|
+
* Build a DSS cutout URL via MAST and verify it exists.
|
|
61
|
+
*
|
|
62
|
+
* Full-sky grayscale coverage. Uses POSS2/UKSTU Red for dec > -40,
|
|
63
|
+
* DSS1 Red for the extreme south.
|
|
64
|
+
*
|
|
65
|
+
* @param ra - Right Ascension in degrees (J2000).
|
|
66
|
+
* @param dec - Declination in degrees (J2000).
|
|
67
|
+
* @param fovArcmin - Desired field of view in arcminutes.
|
|
68
|
+
* @param opts - Timeout options.
|
|
69
|
+
*/
|
|
70
|
+
export declare function tryDSS(ra: number, dec: number, fovArcmin: number, opts?: CutoutOptions): Promise<CutoutResult | null>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { CelestialObject } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Notable deep-sky objects not covered by the Messier catalog.
|
|
4
|
+
*
|
|
5
|
+
* Includes prominent non-Messier objects such as the Helix Nebula,
|
|
6
|
+
* the Milky Way itself, Omega Centauri, and supermassive black holes
|
|
7
|
+
* (Sgr A* and M87's black hole). These are merged into the unified
|
|
8
|
+
* catalog by {@link Data}.
|
|
9
|
+
*
|
|
10
|
+
* @remarks
|
|
11
|
+
* This collection is intentionally small and curated. It supplements
|
|
12
|
+
* the Messier catalog with objects that are either too famous to omit
|
|
13
|
+
* (e.g. the Milky Way, Sgr A*) or are among the finest deep-sky objects
|
|
14
|
+
* in the southern sky (e.g. Omega Centauri, Helix Nebula).
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* import { DEEP_SKY_EXTRAS } from '@motioncomplex/cosmos-lib'
|
|
19
|
+
*
|
|
20
|
+
* const helix = DEEP_SKY_EXTRAS.find(o => o.id === 'ngc7293')
|
|
21
|
+
* console.log(helix?.name) // 'Helix Nebula'
|
|
22
|
+
*
|
|
23
|
+
* const sgrA = DEEP_SKY_EXTRAS.find(o => o.id === 'sgr-a-star')
|
|
24
|
+
* console.log(sgrA?.aliases) // ['Sgr A*', 'SgrA*']
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare const DEEP_SKY_EXTRAS: readonly CelestialObject[];
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import type { ImageRef, ObjectImageResult, GetImageOptions, ProximityResult, EquatorialCoord } from '../types.js';
|
|
2
|
+
interface CatalogInfo {
|
|
3
|
+
id: string;
|
|
4
|
+
ra: number | null;
|
|
5
|
+
dec: number | null;
|
|
6
|
+
size_arcmin?: number | undefined;
|
|
7
|
+
type: string;
|
|
8
|
+
name: string;
|
|
9
|
+
aliases: string[];
|
|
10
|
+
}
|
|
11
|
+
type CatalogLookupFn = (id: string) => CatalogInfo | null;
|
|
12
|
+
type NearbyFn = (center: EquatorialCoord, radiusDeg: number) => ProximityResult[];
|
|
13
|
+
/** @internal Wire the catalog lookup. Called once from index.ts. */
|
|
14
|
+
export declare function _setCatalogLookup(fn: CatalogLookupFn): void;
|
|
15
|
+
/** @internal Wire the nearby-search function. Called once from index.ts. */
|
|
16
|
+
export declare function _setNearbyFn(fn: NearbyFn): void;
|
|
17
|
+
/**
|
|
18
|
+
* Curated Wikimedia Commons image entries for the most iconic celestial objects.
|
|
19
|
+
*
|
|
20
|
+
* Each key is an object ID (e.g. `'m42'`) mapping to an array of
|
|
21
|
+
* {@link ImageRef} records with a Wikimedia `filename` and `credit` string.
|
|
22
|
+
* These are guaranteed-available with no API call needed, making them
|
|
23
|
+
* ideal for offline fallbacks and static site generation.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```ts
|
|
27
|
+
* import { IMAGE_FALLBACKS } from '@motioncomplex/cosmos-lib'
|
|
28
|
+
*
|
|
29
|
+
* const orionImages = IMAGE_FALLBACKS['m42']
|
|
30
|
+
* console.log(orionImages?.[0].filename)
|
|
31
|
+
* // => 'Orion_Nebula_-_Hubble_2006_mosaic_18000.jpg'
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export declare const IMAGE_FALLBACKS: Readonly<Record<string, ImageRef[]>>;
|
|
35
|
+
/**
|
|
36
|
+
* A resolved image result from NASA or ESA image APIs.
|
|
37
|
+
*
|
|
38
|
+
* Contains multiple resolution URLs (highest quality first), a thumbnail
|
|
39
|
+
* preview, and attribution metadata. Suitable for progressive loading,
|
|
40
|
+
* fallback chains, or Three.js texture inputs.
|
|
41
|
+
*/
|
|
42
|
+
export interface ResolvedImage {
|
|
43
|
+
/** Multiple resolution URLs, highest quality first. */
|
|
44
|
+
urls: string[];
|
|
45
|
+
/** Preview/thumbnail URL, or `null` if unavailable. */
|
|
46
|
+
previewUrl: string | null;
|
|
47
|
+
/** Image title from the source API. */
|
|
48
|
+
title: string;
|
|
49
|
+
/** Attribution/credit string. */
|
|
50
|
+
credit: string;
|
|
51
|
+
/** Which API the image came from. */
|
|
52
|
+
source: 'nasa' | 'esa';
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Options for the {@link resolveImages} function.
|
|
56
|
+
*/
|
|
57
|
+
export interface ResolveImageOptions {
|
|
58
|
+
/** Which API source to search. Defaults to `'nasa'`. */
|
|
59
|
+
source?: 'nasa' | 'esa' | 'all';
|
|
60
|
+
/** Maximum number of results. Defaults to `5`. */
|
|
61
|
+
limit?: number;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Search NASA and/or ESA APIs for images of a celestial object by name.
|
|
65
|
+
*
|
|
66
|
+
* Returns multi-resolution image results that can feed directly into
|
|
67
|
+
* `Media.chainLoad()`, `Media.progressive()`, or `createNebula({ textureUrls })`.
|
|
68
|
+
* Works for any object -- not limited to the static {@link IMAGE_FALLBACKS} registry.
|
|
69
|
+
*
|
|
70
|
+
* @param name - Object name to search (e.g. `'Orion Nebula'`, `'M42'`, `'Sirius'`).
|
|
71
|
+
* @param opts - Search options controlling source and result count.
|
|
72
|
+
* @returns A promise resolving to an array of {@link ResolvedImage} results.
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```ts
|
|
76
|
+
* import { resolveImages } from '@motioncomplex/cosmos-lib'
|
|
77
|
+
*
|
|
78
|
+
* // Search NASA for Orion Nebula images
|
|
79
|
+
* const images = await resolveImages('Orion Nebula', { limit: 3 })
|
|
80
|
+
* console.log(images[0].title, images[0].urls[0])
|
|
81
|
+
*
|
|
82
|
+
* // Search both NASA and ESA
|
|
83
|
+
* const all = await resolveImages('Crab Nebula', { source: 'all' })
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
export declare function resolveImages(name: string, opts?: ResolveImageOptions): Promise<ResolvedImage[]>;
|
|
87
|
+
/**
|
|
88
|
+
* Prefetch images for a list of object IDs in the background.
|
|
89
|
+
*
|
|
90
|
+
* Fires off `getObjectImage` for each ID concurrently (with `prefetch: false`
|
|
91
|
+
* to avoid recursive expansion). Results are stored in the in-memory cache
|
|
92
|
+
* so subsequent `Data.getImage()` calls for these objects resolve instantly.
|
|
93
|
+
*
|
|
94
|
+
* Call this when you know which objects the user is likely to view next —
|
|
95
|
+
* e.g. when a list of objects renders or when filtering narrows the results.
|
|
96
|
+
*
|
|
97
|
+
* @param ids - Object IDs to prefetch (e.g. `['m1', 'm2', 'm3']`).
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* ```ts
|
|
101
|
+
* // Prefetch when a filtered list renders
|
|
102
|
+
* Data.prefetchImages(filteredObjects.map(o => o.id))
|
|
103
|
+
*
|
|
104
|
+
* // Later, when user taps M2:
|
|
105
|
+
* const img = await Data.getImage('m2', 'M2') // instant from cache
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
108
|
+
export declare function prefetchImages(ids: string[]): void;
|
|
109
|
+
/**
|
|
110
|
+
* Unified image pipeline that resolves the best available image for any
|
|
111
|
+
* celestial object, with built-in auto-prefetching of nearby objects.
|
|
112
|
+
*
|
|
113
|
+
* The pipeline runs a cascade of sources in priority order:
|
|
114
|
+
* 1. **In-memory cache** — instant (0ms) for previously resolved images.
|
|
115
|
+
* 2. **Curated Wikimedia static registry** — hand-picked iconic images
|
|
116
|
+
* served via Wikimedia's thumbnail API with responsive `srcset`.
|
|
117
|
+
* No network validation — URLs are trusted for zero-latency resolution.
|
|
118
|
+
* 3. **NASA / ESA text search** — high-quality press release imagery.
|
|
119
|
+
* 4. **Pan-STARRS DR2 cutout** *(opt-in, `skipCutouts: false`)* —
|
|
120
|
+
* coordinate-based color composite. Accurate but raw survey data.
|
|
121
|
+
* 5. **DSS cutout** *(opt-in)* — full-sky grayscale fallback.
|
|
122
|
+
*
|
|
123
|
+
* After resolving, the pipeline automatically prefetches images for nearby
|
|
124
|
+
* objects in the background, so spatial browsing feels instant.
|
|
125
|
+
*
|
|
126
|
+
* @param id - Object ID (e.g. `'mars'`, `'m42'`, `'sirius'`).
|
|
127
|
+
* @param name - Object display name used for API searches when no
|
|
128
|
+
* coordinate-based source is available.
|
|
129
|
+
* @param opts - Width, srcset, cutout, and prefetch options.
|
|
130
|
+
* @returns The best available image, or `null` if no image could be found.
|
|
131
|
+
*
|
|
132
|
+
* @example
|
|
133
|
+
* ```ts
|
|
134
|
+
* // Just works — auto-prefetches nearby objects
|
|
135
|
+
* const img = await Data.getImage('m42', 'Orion Nebula', { width: 1200 })
|
|
136
|
+
* if (img) {
|
|
137
|
+
* heroEl.src = img.src
|
|
138
|
+
* heroEl.srcset = img.srcset ?? ''
|
|
139
|
+
* creditEl.textContent = img.credit
|
|
140
|
+
* }
|
|
141
|
+
*
|
|
142
|
+
* // Disable auto-prefetch
|
|
143
|
+
* const img2 = await Data.getImage('m42', 'Orion Nebula', { prefetch: false })
|
|
144
|
+
* ```
|
|
145
|
+
*/
|
|
146
|
+
export declare function getObjectImage(id: string, name: string, opts?: GetImageOptions): Promise<ObjectImageResult | null>;
|
|
147
|
+
export {};
|
|
@@ -0,0 +1,422 @@
|
|
|
1
|
+
import { resolveImages, getObjectImage, prefetchImages } from './images.js';
|
|
2
|
+
import type { CelestialObject, ObjectType, ProximityResult, EquatorialCoord, ProgressiveImageOptions } from '../types.js';
|
|
3
|
+
import type { BrightStar } from './stars.js';
|
|
4
|
+
import type { Constellation } from './constellations.js';
|
|
5
|
+
import type { MessierObject } from './messier.js';
|
|
6
|
+
import type { MeteorShower } from './showers.js';
|
|
7
|
+
export type { BrightStar } from './stars.js';
|
|
8
|
+
export type { Constellation } from './constellations.js';
|
|
9
|
+
export type { MessierObject } from './messier.js';
|
|
10
|
+
export type { MeteorShower } from './showers.js';
|
|
11
|
+
export type { SolarSystemBody } from './solar-system.js';
|
|
12
|
+
export type { ResolvedImage, ResolveImageOptions } from './images.js';
|
|
13
|
+
export { SOLAR_SYSTEM } from './solar-system.js';
|
|
14
|
+
export { DEEP_SKY_EXTRAS } from './deep-sky.js';
|
|
15
|
+
export { BRIGHT_STARS } from './stars.js';
|
|
16
|
+
export { CONSTELLATIONS } from './constellations.js';
|
|
17
|
+
export { MESSIER_CATALOG } from './messier.js';
|
|
18
|
+
export { METEOR_SHOWERS } from './showers.js';
|
|
19
|
+
export { IMAGE_FALLBACKS, resolveImages, getObjectImage, prefetchImages } from './images.js';
|
|
20
|
+
export { computeFov, tryPanSTARRS, tryDSS } from './cutouts.js';
|
|
21
|
+
export type { CutoutResult, CutoutOptions } from './cutouts.js';
|
|
22
|
+
/**
|
|
23
|
+
* Unified data-access facade for all built-in astronomical catalogs.
|
|
24
|
+
*
|
|
25
|
+
* Merges solar-system bodies, bright stars, Messier objects, and deep-sky
|
|
26
|
+
* extras into a single searchable collection. Also exposes typed accessors
|
|
27
|
+
* for individual catalogs (stars, constellations, Messier, meteor showers)
|
|
28
|
+
* and image-resolution helpers.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```ts
|
|
32
|
+
* import { Data } from '@motioncomplex/cosmos-lib'
|
|
33
|
+
*
|
|
34
|
+
* const orion = Data.search('orion')
|
|
35
|
+
* const sirius = Data.getByName('Sirius')
|
|
36
|
+
* const m42 = Data.getMessier(42)
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export declare const Data: {
|
|
40
|
+
/**
|
|
41
|
+
* Look up a celestial object by its exact identifier.
|
|
42
|
+
*
|
|
43
|
+
* @param id - The unique object ID (e.g. `'mars'`, `'m42'`, `'sirius'`).
|
|
44
|
+
* @returns The matching {@link CelestialObject}, or `null` if not found.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```ts
|
|
48
|
+
* const mars = Data.get('mars')
|
|
49
|
+
* // => { id: 'mars', name: 'Mars', type: 'planet', ... }
|
|
50
|
+
*
|
|
51
|
+
* const missing = Data.get('nonexistent')
|
|
52
|
+
* // => null
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
get(id: string): CelestialObject | null;
|
|
56
|
+
/**
|
|
57
|
+
* Look up a celestial object by name or any known alias (case-insensitive).
|
|
58
|
+
*
|
|
59
|
+
* @param name - The common name or alias (e.g. `'Sirius'`, `'Morning Star'`, `'NGC 1976'`).
|
|
60
|
+
* @returns The matching {@link CelestialObject}, or `null` if no match.
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```ts
|
|
64
|
+
* const sirius = Data.getByName('Sirius')
|
|
65
|
+
* // => { id: 'sirius', name: 'Sirius', type: 'star', ... }
|
|
66
|
+
*
|
|
67
|
+
* const venus = Data.getByName('morning star')
|
|
68
|
+
* // => { id: 'venus', name: 'Venus', ... }
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
getByName(name: string): CelestialObject | null;
|
|
72
|
+
/**
|
|
73
|
+
* Return a shallow copy of the full unified catalog.
|
|
74
|
+
*
|
|
75
|
+
* The returned array is a new instance on every call, so it is safe to
|
|
76
|
+
* sort, filter, or mutate without affecting the internal data.
|
|
77
|
+
*
|
|
78
|
+
* @returns A new array containing every {@link CelestialObject} in the catalog.
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* ```ts
|
|
82
|
+
* const catalog = Data.all()
|
|
83
|
+
* console.log(catalog.length) // ~420+ objects
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
all(): CelestialObject[];
|
|
87
|
+
/**
|
|
88
|
+
* Filter the unified catalog by object type.
|
|
89
|
+
*
|
|
90
|
+
* @param type - The {@link ObjectType} to filter on (e.g. `'planet'`, `'nebula'`, `'galaxy'`).
|
|
91
|
+
* @returns All objects matching the given type.
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* ```ts
|
|
95
|
+
* const nebulae = Data.getByType('nebula')
|
|
96
|
+
* // => [{ id: 'm1', name: 'Crab Nebula', ... }, ...]
|
|
97
|
+
*
|
|
98
|
+
* const planets = Data.getByType('planet')
|
|
99
|
+
* // => [{ id: 'mercury', ... }, { id: 'venus', ... }, ...]
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
getByType(type: ObjectType): CelestialObject[];
|
|
103
|
+
/**
|
|
104
|
+
* Filter the unified catalog by a tag string.
|
|
105
|
+
*
|
|
106
|
+
* @param tag - A tag to match (e.g. `'messier'`, `'solar-system'`, `'globular'`).
|
|
107
|
+
* @returns All objects whose `tags` array includes the given string.
|
|
108
|
+
*
|
|
109
|
+
* @example
|
|
110
|
+
* ```ts
|
|
111
|
+
* const messierObjects = Data.getByTag('messier')
|
|
112
|
+
* // => all 110 Messier catalog entries
|
|
113
|
+
*
|
|
114
|
+
* const solarSystem = Data.getByTag('solar-system')
|
|
115
|
+
* // => Sun, planets, and Moon
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
getByTag(tag: string): CelestialObject[];
|
|
119
|
+
/**
|
|
120
|
+
* Fuzzy search across name, aliases, description, and tags.
|
|
121
|
+
*
|
|
122
|
+
* Results are ranked by a weighted relevance score: exact ID and name
|
|
123
|
+
* matches rank highest, followed by alias matches, partial name matches,
|
|
124
|
+
* description hits, and tag hits. Results are sorted highest-score first.
|
|
125
|
+
*
|
|
126
|
+
* @param query - The search term (case-insensitive). An empty string returns `[]`.
|
|
127
|
+
* @returns Matching {@link CelestialObject CelestialObjects} sorted by relevance.
|
|
128
|
+
*
|
|
129
|
+
* @example
|
|
130
|
+
* ```ts
|
|
131
|
+
* const results = Data.search('orion')
|
|
132
|
+
* // => [Orion Nebula (M42), De Mairan's Nebula (M43), Betelgeuse, ...]
|
|
133
|
+
*
|
|
134
|
+
* const galaxies = Data.search('spiral')
|
|
135
|
+
* // => all objects with 'spiral' in name, subtype, description, or tags
|
|
136
|
+
* ```
|
|
137
|
+
*/
|
|
138
|
+
search(query: string): CelestialObject[];
|
|
139
|
+
/**
|
|
140
|
+
* Find all objects within a given angular radius of a sky position.
|
|
141
|
+
*
|
|
142
|
+
* Only considers objects with known RA/Dec coordinates (solar-system
|
|
143
|
+
* bodies with `null` RA/Dec are excluded). Results are sorted by
|
|
144
|
+
* angular separation, nearest first.
|
|
145
|
+
*
|
|
146
|
+
* @param center - The sky position to search around, in J2000 equatorial coordinates.
|
|
147
|
+
* @param radiusDeg - Search radius in degrees.
|
|
148
|
+
* @returns An array of {@link ProximityResult} objects, each containing the
|
|
149
|
+
* matched object and its angular separation from the center.
|
|
150
|
+
*
|
|
151
|
+
* @example
|
|
152
|
+
* ```ts
|
|
153
|
+
* // Find objects within 5 degrees of the Orion Nebula
|
|
154
|
+
* const nearby = Data.nearby({ ra: 83.82, dec: -5.39 }, 5)
|
|
155
|
+
* nearby.forEach(r =>
|
|
156
|
+
* console.log(`${r.object.name}: ${r.separation.toFixed(2)}deg`)
|
|
157
|
+
* )
|
|
158
|
+
* ```
|
|
159
|
+
*/
|
|
160
|
+
nearby(center: EquatorialCoord, radiusDeg: number): ProximityResult[];
|
|
161
|
+
/**
|
|
162
|
+
* Get static Wikimedia image URLs for an object from the fallback registry.
|
|
163
|
+
*
|
|
164
|
+
* Uses the curated {@link IMAGE_FALLBACKS} registry (no API call needed).
|
|
165
|
+
* Returns an empty array if the object has no static images registered.
|
|
166
|
+
*
|
|
167
|
+
* @param id - The object ID (e.g. `'m42'`, `'m31'`).
|
|
168
|
+
* @param width - Optional pixel width for Wikimedia thumbnail resizing.
|
|
169
|
+
* @returns An array of Wikimedia Commons thumbnail URLs.
|
|
170
|
+
*
|
|
171
|
+
* @example
|
|
172
|
+
* ```ts
|
|
173
|
+
* const urls = Data.imageUrls('m42', 1280)
|
|
174
|
+
* // => ['https://upload.wikimedia.org/...Orion_Nebula.../1280px-...']
|
|
175
|
+
*
|
|
176
|
+
* const empty = Data.imageUrls('mercury')
|
|
177
|
+
* // => []
|
|
178
|
+
* ```
|
|
179
|
+
*/
|
|
180
|
+
imageUrls(id: string, width?: number): string[];
|
|
181
|
+
/**
|
|
182
|
+
* Build a {@link ProgressiveImageOptions} config from the static fallback registry.
|
|
183
|
+
*
|
|
184
|
+
* Produces a tiny 64 px placeholder, a standard-resolution source, and a
|
|
185
|
+
* 2x HD source -- ready to feed into `Media.progressive()`.
|
|
186
|
+
* Returns `null` if the object has no static images registered.
|
|
187
|
+
*
|
|
188
|
+
* @param id - The object ID (e.g. `'m42'`, `'m51'`).
|
|
189
|
+
* @param width - Target width in pixels for the standard source. Defaults to `800`.
|
|
190
|
+
* @returns A {@link ProgressiveImageOptions} object, or `null`.
|
|
191
|
+
*
|
|
192
|
+
* @example
|
|
193
|
+
* ```ts
|
|
194
|
+
* const prog = Data.progressiveImage('m42', 1024)
|
|
195
|
+
* // => { placeholder: '...64px...', src: '...1024px...', srcHD: '...2048px...' }
|
|
196
|
+
* ```
|
|
197
|
+
*/
|
|
198
|
+
progressiveImage(id: string, width?: number): ProgressiveImageOptions | null;
|
|
199
|
+
/**
|
|
200
|
+
* Generate an HTML `srcset` string from the static fallback registry.
|
|
201
|
+
*
|
|
202
|
+
* Produces a comma-separated list of `<url> <width>w` entries suitable
|
|
203
|
+
* for the `srcset` attribute of an `<img>` element.
|
|
204
|
+
* Returns `null` if the object has no static images registered.
|
|
205
|
+
*
|
|
206
|
+
* @param id - The object ID (e.g. `'m31'`).
|
|
207
|
+
* @param widths - Array of pixel widths to include. Defaults to `[640, 1280, 1920]`.
|
|
208
|
+
* @returns A `srcset`-formatted string, or `null`.
|
|
209
|
+
*
|
|
210
|
+
* @example
|
|
211
|
+
* ```ts
|
|
212
|
+
* const srcset = Data.imageSrcset('m31')
|
|
213
|
+
* // => '...640px-... 640w, ...1280px-... 1280w, ...1920px-... 1920w'
|
|
214
|
+
* ```
|
|
215
|
+
*/
|
|
216
|
+
imageSrcset(id: string, widths?: number[]): string | null;
|
|
217
|
+
/**
|
|
218
|
+
* Search NASA and/or ESA APIs for images of any celestial object by name.
|
|
219
|
+
*
|
|
220
|
+
* Returns multi-resolution {@link ResolvedImage} results suitable for
|
|
221
|
+
* progressive loading, fallback chains, or Three.js textures.
|
|
222
|
+
* Unlike the static `imageUrls` / `imageSrcset` helpers, this method
|
|
223
|
+
* works for **any** object -- it is not limited to the curated fallback registry.
|
|
224
|
+
*
|
|
225
|
+
* @param name - Object name to search (e.g. `'Orion Nebula'`, `'M42'`, `'Sirius'`).
|
|
226
|
+
* @param opts - Optional {@link ResolveImageOptions} to control source and limit.
|
|
227
|
+
* @returns A promise resolving to an array of {@link ResolvedImage} results.
|
|
228
|
+
*
|
|
229
|
+
* @example
|
|
230
|
+
* ```ts
|
|
231
|
+
* const images = await Data.resolveImages('Crab Nebula', { source: 'all', limit: 3 })
|
|
232
|
+
* images.forEach(img => console.log(img.title, img.urls[0]))
|
|
233
|
+
* ```
|
|
234
|
+
*/
|
|
235
|
+
resolveImages: typeof resolveImages;
|
|
236
|
+
/**
|
|
237
|
+
* Unified image pipeline — resolves the best available image for any
|
|
238
|
+
* celestial object and returns it in an optimized, ready-to-render format.
|
|
239
|
+
*
|
|
240
|
+
* Runs a cascading lookup: static registry (instant) → NASA → ESA.
|
|
241
|
+
* Results from API sources are cached in memory. The consumer only needs
|
|
242
|
+
* to provide the object ID and name — the pipeline handles source selection,
|
|
243
|
+
* URL construction, and responsive `srcset` generation.
|
|
244
|
+
*
|
|
245
|
+
* @param id - Object ID (e.g. `'mars'`, `'m42'`, `'sirius'`).
|
|
246
|
+
* @param name - Display name for API search fallback (e.g. `'Mars'`).
|
|
247
|
+
* @param opts - Width, srcset, and source preferences.
|
|
248
|
+
* @returns The best available image, or `null` if nothing was found.
|
|
249
|
+
*
|
|
250
|
+
* @example
|
|
251
|
+
* ```ts
|
|
252
|
+
* const img = await Data.getImage('mars', 'Mars')
|
|
253
|
+
* if (img) {
|
|
254
|
+
* heroEl.src = img.src
|
|
255
|
+
* heroEl.srcset = img.srcset ?? ''
|
|
256
|
+
* creditEl.textContent = img.credit
|
|
257
|
+
* }
|
|
258
|
+
* ```
|
|
259
|
+
*/
|
|
260
|
+
getImage: typeof getObjectImage;
|
|
261
|
+
/**
|
|
262
|
+
* Prefetch images for a list of object IDs in the background.
|
|
263
|
+
*
|
|
264
|
+
* Results are stored in the in-memory cache so subsequent
|
|
265
|
+
* {@link Data.getImage} calls resolve instantly.
|
|
266
|
+
*
|
|
267
|
+
* @param ids - Object IDs to prefetch.
|
|
268
|
+
*
|
|
269
|
+
* @example
|
|
270
|
+
* ```ts
|
|
271
|
+
* Data.prefetchImages(filteredObjects.map(o => o.id))
|
|
272
|
+
* ```
|
|
273
|
+
*/
|
|
274
|
+
prefetchImages: typeof prefetchImages;
|
|
275
|
+
/**
|
|
276
|
+
* Get all bright stars in the catalog (~200 IAU named stars).
|
|
277
|
+
*
|
|
278
|
+
* @returns The full {@link BRIGHT_STARS} array (readonly).
|
|
279
|
+
*
|
|
280
|
+
* @example
|
|
281
|
+
* ```ts
|
|
282
|
+
* const stars = Data.stars()
|
|
283
|
+
* console.log(stars[0].name) // 'Sirius'
|
|
284
|
+
* ```
|
|
285
|
+
*/
|
|
286
|
+
stars(): readonly BrightStar[];
|
|
287
|
+
/**
|
|
288
|
+
* Look up a bright star by its IAU proper name (case-insensitive).
|
|
289
|
+
*
|
|
290
|
+
* @param name - The IAU proper name (e.g. `'Sirius'`, `'Betelgeuse'`, `'Polaris'`).
|
|
291
|
+
* @returns The matching {@link BrightStar}, or `null` if not found.
|
|
292
|
+
*
|
|
293
|
+
* @example
|
|
294
|
+
* ```ts
|
|
295
|
+
* const sirius = Data.getStarByName('Sirius')
|
|
296
|
+
* // => { id: 'sirius', name: 'Sirius', con: 'CMa', mag: -1.46, ... }
|
|
297
|
+
* ```
|
|
298
|
+
*/
|
|
299
|
+
getStarByName(name: string): BrightStar | null;
|
|
300
|
+
/**
|
|
301
|
+
* Get all bright stars belonging to a given constellation.
|
|
302
|
+
*
|
|
303
|
+
* @param con - The 3-letter IAU constellation abbreviation (case-insensitive),
|
|
304
|
+
* e.g. `'Ori'`, `'CMa'`, `'UMa'`.
|
|
305
|
+
* @returns All {@link BrightStar BrightStars} in that constellation.
|
|
306
|
+
*
|
|
307
|
+
* @example
|
|
308
|
+
* ```ts
|
|
309
|
+
* const orionStars = Data.getStarsByConstellation('Ori')
|
|
310
|
+
* // => [Rigel, Betelgeuse, Bellatrix, Alnilam, Alnitak, Mintaka, Saiph]
|
|
311
|
+
* ```
|
|
312
|
+
*/
|
|
313
|
+
getStarsByConstellation(con: string): BrightStar[];
|
|
314
|
+
/**
|
|
315
|
+
* Find bright stars within a given angular radius of a sky position.
|
|
316
|
+
*
|
|
317
|
+
* Results are sorted by angular separation (nearest first).
|
|
318
|
+
*
|
|
319
|
+
* @param center - The sky position to search around, in J2000 equatorial coordinates.
|
|
320
|
+
* @param radiusDeg - Search radius in degrees.
|
|
321
|
+
* @returns An array of objects, each containing the matched {@link BrightStar}
|
|
322
|
+
* and its angular `separation` in degrees from the center.
|
|
323
|
+
*
|
|
324
|
+
* @example
|
|
325
|
+
* ```ts
|
|
326
|
+
* // Find bright stars within 10 degrees of Sirius
|
|
327
|
+
* const nearby = Data.nearbyStars({ ra: 101.287, dec: -16.716 }, 10)
|
|
328
|
+
* nearby.forEach(r =>
|
|
329
|
+
* console.log(`${r.star.name}: ${r.separation.toFixed(2)}deg`)
|
|
330
|
+
* )
|
|
331
|
+
* ```
|
|
332
|
+
*/
|
|
333
|
+
nearbyStars(center: EquatorialCoord, radiusDeg: number): Array<{
|
|
334
|
+
star: BrightStar;
|
|
335
|
+
separation: number;
|
|
336
|
+
}>;
|
|
337
|
+
/**
|
|
338
|
+
* Get all 88 IAU constellations.
|
|
339
|
+
*
|
|
340
|
+
* @returns The full {@link CONSTELLATIONS} array (readonly).
|
|
341
|
+
*
|
|
342
|
+
* @example
|
|
343
|
+
* ```ts
|
|
344
|
+
* const all = Data.constellations()
|
|
345
|
+
* console.log(all.length) // 88
|
|
346
|
+
* ```
|
|
347
|
+
*/
|
|
348
|
+
constellations(): readonly Constellation[];
|
|
349
|
+
/**
|
|
350
|
+
* Look up a constellation by its 3-letter IAU abbreviation (case-insensitive).
|
|
351
|
+
*
|
|
352
|
+
* @param abbr - The abbreviation (e.g. `'Ori'`, `'UMa'`, `'Sco'`).
|
|
353
|
+
* @returns The matching {@link Constellation}, or `null` if not found.
|
|
354
|
+
*
|
|
355
|
+
* @example
|
|
356
|
+
* ```ts
|
|
357
|
+
* const orion = Data.getConstellation('Ori')
|
|
358
|
+
* // => { abbr: 'Ori', name: 'Orion', genitive: 'Orionis', area: 594, ... }
|
|
359
|
+
* ```
|
|
360
|
+
*/
|
|
361
|
+
getConstellation(abbr: string): Constellation | null;
|
|
362
|
+
/**
|
|
363
|
+
* Get all 110 Messier objects.
|
|
364
|
+
*
|
|
365
|
+
* @returns The full {@link MESSIER_CATALOG} array (readonly).
|
|
366
|
+
*
|
|
367
|
+
* @example
|
|
368
|
+
* ```ts
|
|
369
|
+
* const catalog = Data.messier()
|
|
370
|
+
* console.log(catalog.length) // 110
|
|
371
|
+
* ```
|
|
372
|
+
*/
|
|
373
|
+
messier(): readonly MessierObject[];
|
|
374
|
+
/**
|
|
375
|
+
* Look up a Messier object by its catalog number.
|
|
376
|
+
*
|
|
377
|
+
* @param number - The Messier number, from 1 to 110.
|
|
378
|
+
* @returns The matching {@link MessierObject}, or `null` if out of range.
|
|
379
|
+
*
|
|
380
|
+
* @example
|
|
381
|
+
* ```ts
|
|
382
|
+
* const m42 = Data.getMessier(42)
|
|
383
|
+
* // => { messier: 42, name: 'Orion Nebula', type: 'nebula', mag: 4.0, ... }
|
|
384
|
+
*
|
|
385
|
+
* const m1 = Data.getMessier(1)
|
|
386
|
+
* // => { messier: 1, name: 'Crab Nebula', ... }
|
|
387
|
+
* ```
|
|
388
|
+
*/
|
|
389
|
+
getMessier(number: number): MessierObject | null;
|
|
390
|
+
/**
|
|
391
|
+
* Get all meteor showers in the catalog (~23 significant annual showers).
|
|
392
|
+
*
|
|
393
|
+
* @returns The full {@link METEOR_SHOWERS} array (readonly).
|
|
394
|
+
*
|
|
395
|
+
* @example
|
|
396
|
+
* ```ts
|
|
397
|
+
* const showers = Data.showers()
|
|
398
|
+
* const perseids = showers.find(s => s.id === 'perseids')
|
|
399
|
+
* console.log(perseids?.zhr) // 100
|
|
400
|
+
* ```
|
|
401
|
+
*/
|
|
402
|
+
showers(): readonly MeteorShower[];
|
|
403
|
+
/**
|
|
404
|
+
* Get meteor showers that are active on a given date.
|
|
405
|
+
*
|
|
406
|
+
* Computes the Sun's ecliptic longitude for the date and compares it
|
|
407
|
+
* against each shower's peak solar longitude, returning those within
|
|
408
|
+
* a +/-20 degree activity window.
|
|
409
|
+
*
|
|
410
|
+
* @param date - The date to check for active showers.
|
|
411
|
+
* @returns An array of {@link MeteorShower MeteorShowers} active on the given date.
|
|
412
|
+
*
|
|
413
|
+
* @example
|
|
414
|
+
* ```ts
|
|
415
|
+
* // Check for active showers on August 12 (Perseid peak)
|
|
416
|
+
* const active = Data.getActiveShowers(new Date('2025-08-12'))
|
|
417
|
+
* console.log(active.map(s => s.name))
|
|
418
|
+
* // => ['Perseids', 'Kappa Cygnids', ...]
|
|
419
|
+
* ```
|
|
420
|
+
*/
|
|
421
|
+
getActiveShowers(date: Date): MeteorShower[];
|
|
422
|
+
};
|