celestial-chart 0.8.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.
@@ -0,0 +1,545 @@
1
+ // TypeScript definitions for celestial-chart.
2
+ //
3
+ // The body of Config is GENERATED from the defaults in src/config.js, so that
4
+ // the ~110 settings do not have to be transcribed by hand. A test guards
5
+ // against drift (test/types.test.mjs): every setting name that exists at
6
+ // runtime must appear here, and vice versa.
7
+
8
+ /** The supported projections. Two of them (`cassini`, `quincuncial`) are absent
9
+ * from the shipped upstream build as well — those throw. */
10
+ export type Projection =
11
+ | "airy"
12
+ | "aitoff"
13
+ | "armadillo"
14
+ | "august"
15
+ | "azimuthalEqualArea"
16
+ | "azimuthalEquidistant"
17
+ | "baker"
18
+ | "berghaus"
19
+ | "boggs"
20
+ | "bonne"
21
+ | "bromley"
22
+ | "cassini"
23
+ | "collignon"
24
+ | "craig"
25
+ | "craster"
26
+ | "cylindricalEqualArea"
27
+ | "cylindricalStereographic"
28
+ | "eckert1"
29
+ | "eckert2"
30
+ | "eckert3"
31
+ | "eckert4"
32
+ | "eckert5"
33
+ | "eckert6"
34
+ | "eisenlohr"
35
+ | "equirectangular"
36
+ | "fahey"
37
+ | "mtFlatPolarParabolic"
38
+ | "mtFlatPolarQuartic"
39
+ | "mtFlatPolarSinusoidal"
40
+ | "foucaut"
41
+ | "ginzburg4"
42
+ | "ginzburg5"
43
+ | "ginzburg6"
44
+ | "ginzburg8"
45
+ | "ginzburg9"
46
+ | "homolosine"
47
+ | "hammer"
48
+ | "hatano"
49
+ | "healpix"
50
+ | "hill"
51
+ | "kavrayskiy7"
52
+ | "lagrange"
53
+ | "larrivee"
54
+ | "laskowski"
55
+ | "loximuthal"
56
+ | "mercator"
57
+ | "miller"
58
+ | "mollweide"
59
+ | "naturalEarth"
60
+ | "nellHammer"
61
+ | "orthographic"
62
+ | "patterson"
63
+ | "polyconic"
64
+ | "quincuncial"
65
+ | "rectangularPolyconic"
66
+ | "robinson"
67
+ | "sinusoidal"
68
+ | "stereographic"
69
+ | "times"
70
+ | "twoPointEquidistant"
71
+ | "vanDerGrinten"
72
+ | "vanDerGrinten2"
73
+ | "vanDerGrinten3"
74
+ | "vanDerGrinten4"
75
+ | "wagner4"
76
+ | "wagner6"
77
+ | "wagner7"
78
+ | "wiechel"
79
+ | "winkel3";
80
+
81
+ /** The coordinate system the map is drawn in. */
82
+ export type Transform = "equatorial" | "ecliptic" | "galactic" | "supergalactic";
83
+
84
+ /** Map centre: [longitude, latitude] or [longitude, latitude, orientation].
85
+ * In the equatorial system the longitude is in hours, otherwise in degrees. */
86
+ export type Center = [number, number] | [number, number, number];
87
+
88
+ /** A celestial coordinate in degrees: [longitude, latitude]. */
89
+ export type Coordinate = [number, number];
90
+
91
+ /** A screen coordinate in pixels: [x, y]. */
92
+ export type ScreenPoint = [number, number];
93
+
94
+ export interface Config {
95
+ width?: number;
96
+ projection?: Projection;
97
+ projectionRatio?: number | null;
98
+ transform?: Transform;
99
+ center?: Center | null;
100
+ geopos?: [number, number] | null;
101
+ follow?: "zenith" | "center";
102
+ orientationfixed?: boolean;
103
+ zoomlevel?: number | null;
104
+ zoomextend?: number;
105
+ adaptable?: boolean;
106
+ interactive?: boolean;
107
+ disableAnimations?: boolean;
108
+ form?: boolean;
109
+ location?: boolean;
110
+ formFields?: {
111
+ location?: boolean;
112
+ general?: boolean;
113
+ stars?: boolean;
114
+ dsos?: boolean;
115
+ constellations?: boolean;
116
+ lines?: boolean;
117
+ other?: boolean;
118
+ download?: boolean;
119
+ };
120
+ advanced?: boolean;
121
+ daterange?: Date[];
122
+ settimezone?: boolean;
123
+ /** Your own TimeZoneDB account id. Empty (the default) means no request is
124
+ * made and the UTC offset is estimated from longitude. */
125
+ timezoneid?: string;
126
+ /** Resolve the UTC offset of a position yourself — point it at your own
127
+ * service instead of sending visitor coordinates to a third party.
128
+ * Takes precedence over `timezoneid`. Returns offset in MINUTES. */
129
+ timezoneResolver?: ((lat: number, lon: number, whenSeconds: number)
130
+ => number | Promise<number>) | null;
131
+ controls?: boolean;
132
+ lang?: string;
133
+ culture?: string;
134
+ container?: string;
135
+ datapath?: string;
136
+ stars?: {
137
+ show?: boolean;
138
+ limit?: number;
139
+ colors?: boolean;
140
+ style?: {
141
+ fill?: string;
142
+ opacity?: number;
143
+ };
144
+ designation?: boolean;
145
+ designationType?: string;
146
+ designationStyle?: {
147
+ fill?: string;
148
+ font?: string;
149
+ align?: string;
150
+ baseline?: string;
151
+ };
152
+ designationLimit?: number;
153
+ propername?: boolean;
154
+ propernameType?: string;
155
+ propernameStyle?: {
156
+ fill?: string;
157
+ font?: string;
158
+ align?: string;
159
+ baseline?: string;
160
+ };
161
+ propernameLimit?: number;
162
+ size?: number | null;
163
+ exponent?: number;
164
+ data?: string;
165
+ };
166
+ dsos?: {
167
+ show?: boolean;
168
+ limit?: number;
169
+ colors?: boolean;
170
+ style?: {
171
+ fill?: string;
172
+ stroke?: string;
173
+ width?: number;
174
+ opacity?: number;
175
+ };
176
+ names?: boolean;
177
+ namesType?: string;
178
+ nameStyle?: {
179
+ fill?: string;
180
+ font?: string;
181
+ align?: string;
182
+ baseline?: string;
183
+ };
184
+ nameLimit?: number;
185
+ size?: unknown;
186
+ exponent?: number;
187
+ data?: string;
188
+ symbols?: Record<string, { shape?: string; fill?: string }>;
189
+ };
190
+ constellations?: {
191
+ show?: boolean;
192
+ names?: boolean;
193
+ namesType?: string;
194
+ nameStyle?: {
195
+ fill?: string;
196
+ align?: string;
197
+ baseline?: string;
198
+ opacity?: number;
199
+ font?: string[];
200
+ };
201
+ lines?: boolean;
202
+ lineStyle?: {
203
+ stroke?: string;
204
+ width?: number;
205
+ opacity?: number;
206
+ };
207
+ bounds?: boolean;
208
+ boundStyle?: {
209
+ stroke?: string;
210
+ width?: number;
211
+ opacity?: number;
212
+ dash?: number[];
213
+ };
214
+ };
215
+ mw?: {
216
+ show?: boolean;
217
+ style?: {
218
+ fill?: string;
219
+ opacity?: string;
220
+ };
221
+ };
222
+ lines?: {
223
+ graticule?: {
224
+ show?: boolean;
225
+ stroke?: string;
226
+ width?: number;
227
+ opacity?: number;
228
+ lon?: {
229
+ pos?: Array<number | string>;
230
+ fill?: string;
231
+ font?: string;
232
+ };
233
+ lat?: {
234
+ pos?: Array<number | string>;
235
+ fill?: string;
236
+ font?: string;
237
+ };
238
+ };
239
+ equatorial?: {
240
+ show?: boolean;
241
+ stroke?: string;
242
+ width?: number;
243
+ opacity?: number;
244
+ };
245
+ ecliptic?: {
246
+ show?: boolean;
247
+ stroke?: string;
248
+ width?: number;
249
+ opacity?: number;
250
+ };
251
+ galactic?: {
252
+ show?: boolean;
253
+ stroke?: string;
254
+ width?: number;
255
+ opacity?: number;
256
+ };
257
+ supergalactic?: {
258
+ show?: boolean;
259
+ stroke?: string;
260
+ width?: number;
261
+ opacity?: number;
262
+ };
263
+ };
264
+ background?: {
265
+ fill?: string;
266
+ opacity?: number;
267
+ stroke?: string;
268
+ width?: number;
269
+ };
270
+ horizon?: {
271
+ show?: boolean;
272
+ stroke?: string;
273
+ width?: number;
274
+ fill?: string;
275
+ opacity?: number;
276
+ };
277
+ daylight?: {
278
+ show?: boolean;
279
+ };
280
+ planets?: {
281
+ show?: boolean;
282
+ which?: string[];
283
+ symbols?: {
284
+ sol?: {
285
+ symbol?: string;
286
+ letter?: string;
287
+ fill?: string;
288
+ size?: number;
289
+ };
290
+ mer?: {
291
+ symbol?: string;
292
+ letter?: string;
293
+ fill?: string;
294
+ };
295
+ ven?: {
296
+ symbol?: string;
297
+ letter?: string;
298
+ fill?: string;
299
+ };
300
+ ter?: {
301
+ symbol?: string;
302
+ letter?: string;
303
+ fill?: string;
304
+ };
305
+ lun?: {
306
+ symbol?: string;
307
+ letter?: string;
308
+ fill?: string;
309
+ size?: number;
310
+ };
311
+ mar?: {
312
+ symbol?: string;
313
+ letter?: string;
314
+ fill?: string;
315
+ };
316
+ cer?: {
317
+ symbol?: string;
318
+ letter?: string;
319
+ fill?: string;
320
+ };
321
+ ves?: {
322
+ symbol?: string;
323
+ letter?: string;
324
+ fill?: string;
325
+ };
326
+ jup?: {
327
+ symbol?: string;
328
+ letter?: string;
329
+ fill?: string;
330
+ };
331
+ sat?: {
332
+ symbol?: string;
333
+ letter?: string;
334
+ fill?: string;
335
+ };
336
+ ura?: {
337
+ symbol?: string;
338
+ letter?: string;
339
+ fill?: string;
340
+ };
341
+ nep?: {
342
+ symbol?: string;
343
+ letter?: string;
344
+ fill?: string;
345
+ };
346
+ plu?: {
347
+ symbol?: string;
348
+ letter?: string;
349
+ fill?: string;
350
+ };
351
+ eri?: {
352
+ symbol?: string;
353
+ letter?: string;
354
+ fill?: string;
355
+ };
356
+ };
357
+ symbolStyle?: {
358
+ fill?: string;
359
+ opacity?: number;
360
+ font?: string;
361
+ align?: string;
362
+ baseline?: string;
363
+ };
364
+ symbolType?: string;
365
+ names?: boolean;
366
+ nameStyle?: {
367
+ fill?: string;
368
+ font?: string;
369
+ align?: string;
370
+ baseline?: string;
371
+ };
372
+ namesType?: string;
373
+ };
374
+ /** The moment to render. No default: the current time is used. */
375
+ date?: Date;
376
+ }
377
+
378
+ /** The map's current dimensions. */
379
+ export interface Metrics {
380
+ width: number;
381
+ height: number;
382
+ margin: [number, number];
383
+ scale: number;
384
+ }
385
+
386
+ /** One map's settings form. Separate per instance. */
387
+ export interface SettingsForm {
388
+ /** Field lookup within this map. */
389
+ $form(id: string): HTMLElement | null;
390
+ enable(source: HTMLElement): void;
391
+ fldEnable(field: string, be: boolean): void;
392
+ listConstellations(): void;
393
+ setCenter(centerPoint: Center | null, transform_: Transform): void;
394
+ setLimits(): void;
395
+ setVisibility(config: Config, which_: string): void;
396
+ showAdvanced(visible: boolean): void;
397
+ }
398
+
399
+ /** One constellation's data from the `constellations` list. */
400
+ export interface Constellation {
401
+ id: string;
402
+ properties: Record<string, unknown>;
403
+ [other_: string]: unknown;
404
+ }
405
+
406
+ /**
407
+ * One sky-map instance.
408
+ *
409
+ * This is what several independent maps need, together with
410
+ * `{ standalone: true }` — without it the instance is built on the accumulated
411
+ * global settings, just as `Celestial.display()` is.
412
+ *
413
+ * ```ts
414
+ * const a = new SkyMap({ container: "map-a", projection: "orthographic" }, { standalone: true });
415
+ * ```
416
+ */
417
+ export declare class SkyMap {
418
+ constructor(config?: Config, options?: { standalone?: boolean });
419
+
420
+ /** The map's effective configuration. Updated while drawing. */
421
+ readonly cfg: Config;
422
+ /** The d3-geo projection. A new object after a projection change. */
423
+ readonly mapProjection: (coord: Coordinate) => ScreenPoint | null;
424
+ /** The d3-geo path generator. */
425
+ readonly map: unknown;
426
+ /** The d3 selection of the `<container>` element holding the drawn elements. */
427
+ readonly container: unknown;
428
+ /** CSS selector of the parent element, for example `"#celestial-map"`. */
429
+ readonly parentElement: string;
430
+ /** Star and deep-sky names from the loaded data. */
431
+ readonly starnames: Record<string, Record<string, string>>;
432
+ readonly dsonames: Record<string, Record<string, string>>;
433
+ /** This map's own settings form (only when `form: true`). */
434
+ readonly form: SettingsForm;
435
+ readonly context: CanvasRenderingContext2D;
436
+
437
+ /** Whether the point is visible in the current projection. */
438
+ clip(coord: Coordinate): 0 | 1;
439
+ metrics(): Metrics;
440
+ redraw(): void;
441
+ /** Set a new width; without an argument returns the current one. */
442
+ resize(config?: { width: number } | number): number;
443
+ /** Apply settings and redraw. */
444
+ apply(config: Config): void;
445
+ /** Full reload — for changing projection or coordinate system. */
446
+ reload(config?: Config): void;
447
+ /** Animated projection change. Returns the estimated duration in ms. */
448
+ reproject(config: { projection: Projection; projectionRatio?: number }): number;
449
+ /** Set the centre. Without an argument returns the current one. */
450
+ rotate(config?: { center: Center }): Center | number;
451
+ /** Zoom by a factor. Without an argument returns the current zoom. */
452
+ zoomBy(factor?: number): number;
453
+ /** SVG export. The finished SVG is passed to the callback. */
454
+ exportSVG(done: (svg: string) => void): void;
455
+
456
+ animate(steps: Array<{ param: string; value: unknown; duration?: number; callback?: () => void }>,
457
+ repeat?: boolean): void;
458
+ stop(clear?: boolean): void;
459
+ go(index?: number): void;
460
+
461
+ color(type_?: string): string;
462
+ starColor(star: unknown): string;
463
+ symbol: unknown;
464
+ dsoSymbol(dso: unknown): string;
465
+ setStyle(style_: Record<string, unknown>): void;
466
+ setTextStyle(style_: Record<string, unknown>): void;
467
+ setStyleA(rank: number, style_: Record<string, unknown>): void;
468
+ setConstStyle(rank: number, font: string | string[]): void;
469
+
470
+ /** Csak `location: true` mellett. */
471
+ date?(date_?: Date, tz?: number): Date;
472
+ dateFormat?(date_: Date, tz: number): string;
473
+ zenith?(): Center;
474
+ nadir?(): Center;
475
+ position?(): [number, number];
476
+ location?(be: boolean): void;
477
+ timezone?(): number;
478
+ skyview?(config?: unknown): unknown;
479
+ dtLoc?(): unknown;
480
+
481
+ showConstellation?(id: string): void;
482
+ setLanguage?(language: string): Config;
483
+ updateForm?(): void;
484
+ /** The loaded constellations. Set once the data has arrived. */
485
+ constellations?: Record<string, Constellation>;
486
+ constellation?: string | null;
487
+ }
488
+
489
+ /**
490
+ * The global interface — backwards compatible with the original usage.
491
+ *
492
+ * `display()` creates an instance and spreads that instance's interface onto
493
+ * itself; the returned instance is how several maps can be handled.
494
+ *
495
+ * NOTE: the map methods (`rotate`, `apply`, `zoomBy`, `redraw` and the rest)
496
+ * only exist AFTER the first `display()`. The types present them as always
497
+ * available, because in practice every use starts with `display()`, and marking
498
+ * them optional would force `?.` on every call.
499
+ */
500
+ export interface CelestialGlobal extends SkyMap {
501
+ readonly version: string;
502
+ data: unknown[];
503
+
504
+ /** Render a map. Returns the instance it created. */
505
+ display(config?: Config): SkyMap;
506
+
507
+ /** The effective settings. */
508
+ settings(): {
509
+ set(config?: Config, base?: unknown): Config;
510
+ applyDefaults(config?: Config, base?: unknown): Config;
511
+ [key_: string]: unknown;
512
+ };
513
+ /** Descriptors of the supported projections. */
514
+ projections(): Record<Projection, { n: string; arg: number | null; scale: number; ratio?: number; clip?: boolean }>;
515
+ /** Build a projection from its name. */
516
+ projection(name_: Projection): unknown;
517
+ eulerAngles(): Record<string, [number, number, number]>;
518
+ poles(): Record<string, [number, number]>;
519
+ euler(): Record<string, number[]>;
520
+
521
+ /** Add a custom data layer. */
522
+ add(data_: { type?: string; file?: string; callback: () => void; redraw?: () => void }): void;
523
+ remove(): void;
524
+ clear(): void;
525
+ addCallback(fv: () => void): void;
526
+ runCallback(): void;
527
+
528
+ getData(json: unknown, transform_: Transform): unknown;
529
+ getPlanet(id: string, date_?: Date, sky?: SkyMap): unknown;
530
+ /** Convert a coordinate from equatorial to the given system. */
531
+ getPoint(coord: Coordinate, transform_: Transform): Coordinate;
532
+
533
+ /** Celestial to horizontal coordinates. */
534
+ horizontal: {
535
+ (date_: Date, coord: Coordinate, site: Coordinate): [number, number, number];
536
+ /** Horizontal to celestial. */
537
+ inverse(date_: Date, horizontalCoord: Coordinate, site: Coordinate): [number, number, number];
538
+ };
539
+ /** Hour angle in degrees, [0, 360). */
540
+ ha(date_: Date, longitude: number, rightAscension: number): number;
541
+ }
542
+
543
+ declare const Celestial: CelestialGlobal;
544
+ export { Celestial };
545
+ export default Celestial;