@tempo-kit/plugin-celestial 0.0.0-stage → 2.0.0-rc.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.
- package/CHANGELOG.md +110 -0
- package/LICENSE +21 -0
- package/README.md +209 -2
- package/dist/astro.d.ts +37 -0
- package/dist/index.d.ts +145 -0
- package/dist/index.global.min.js +1 -0
- package/dist/index.js +823 -0
- package/dist/install.d.ts +2 -0
- package/dist/install.global.min.js +1 -0
- package/dist/install.js +826 -0
- package/dist/lunar.d.ts +143 -0
- package/dist/solar.d.ts +244 -0
- package/dist/tidal.d.ts +90 -0
- package/dist/util.d.ts +74 -0
- package/package.json +70 -4
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [2.0.0] - 2026-11-27
|
|
9
|
+
|
|
10
|
+
### Breaking Changes
|
|
11
|
+
- Migrated package namespace from `@magmacomputing/tempo-plugin-celestial` to `@tempo-kit/plugin-celestial`.
|
|
12
|
+
- Updated `peerDependencies` to `tempo-kit@^5.0.0`.
|
|
13
|
+
|
|
14
|
+
## [2.0.0] - 2026-11-27
|
|
15
|
+
|
|
16
|
+
### Breaking Changes
|
|
17
|
+
- Migrated package namespace from `@magmacomputing/tempo-plugin-celestial` to `@tempo-kit/plugin-celestial`.
|
|
18
|
+
- Updated `peerDependencies` to `tempo-kit@^5.0.0`.
|
|
19
|
+
|
|
20
|
+
## [1.3.1] - 2026-11-08
|
|
21
|
+
|
|
22
|
+
### Maintenance
|
|
23
|
+
- **Tempo v5.0.0 Alignment**:
|
|
24
|
+
- Removed unused `isDefined` import in `src/util.ts`.
|
|
25
|
+
- Expanded `@magmacomputing/tempo` peer and dev dependencies to support `^4.6.0 || ^5.0.0`.
|
|
26
|
+
|
|
27
|
+
## [1.3.0] - 2026-10-10
|
|
28
|
+
|
|
29
|
+
### Added
|
|
30
|
+
- **Complete TermHooks Lifecycle Integration (`TermHook`)**:
|
|
31
|
+
- Implemented `[TermHook.bound]`, `[TermHook.step]`, `[TermHook.diff]`, and `[TermHook.format]` on `LunarTerm` (`#moon`, `#lunar`) for phase boundary snapping (`t.set('#moon.start')`, `t.set('#moon.mid')`, `t.set('#moon.end')`), synodic lunation stepping (~29.53 days, `t.add('#moon')`), lunation span measurements (`t1.until(t2, '#moon')`, `t2.since(t1, '#moon')`), and emoji/phase format tokens (`{#moon.emoji}`, `{#moon.phase}`, `{#moon.illumination}`).
|
|
32
|
+
- Implemented `[TermHook.bound]`, `[TermHook.parse]`, and `[TermHook.format]` on `SolarTerm` (`#solar`, `#sun`) for diurnal sunrise/noon/sunset snapping (`t.set('#solar.start')`, `t.set('#solar.mid')`, `t.set('#solar.end')`), semantic parsing (`#solar.sunrise`, `#solar.sunset`, `#solar.noon`), and solar state format tokens (`{#solar.phase}`, `{#solar.elevation}`, `{#solar.azimuth}`).
|
|
33
|
+
- Implemented `[TermHook.step]`, `[TermHook.bound]`, `[TermHook.diff]`, and `[TermHook.format]` on `TidalTerm` (`#tide`, `#tides`) for semidiurnal M2 tidal cycle stepping (~745 min, `t.add('#tide')`), high/low tide snapping (`t.set('#tide.start')`, `t.set('#tide.end')`), tidal span measurements (`t1.until(t2, '#tide')`), and tidal state format tokens (`{#tide.state}`, `{#tide.alignment}`).
|
|
34
|
+
- Implemented `[TermHook.ordinal]`, `[TermHook.parse]`, `[TermHook.bound]`, and `[TermHook.format]` on `AstroTerm` (`#astro`, `#astronomy`, `#equinox`, `#solstice`) for natural language ordinal queries (`"1st day of #equinox"`, `"2nd day of #solstice"`, `"last day of #equinox"`), semantic parsing (`#equinox.vernal`, `#solstice.summer`), astronomical season boundary snapping (`t.set('#astro.start')`, `t.set('#astro.mid')`, `t.set('#astro.end')`), and season/event format tokens (`{#astro.season}`, `{#astro.event}`).
|
|
35
|
+
|
|
36
|
+
## [1.2.1] - 2026-10-06
|
|
37
|
+
|
|
38
|
+
### Fixed
|
|
39
|
+
- **Standardized Diagnostic Logging & Silent Mode**:
|
|
40
|
+
- Routed missing geographic coordinates warnings through [`logWarn`](../../tempo/src/plugin/plugin.sdk.ts) from `@magmacomputing/tempo/plugin/sdk`.
|
|
41
|
+
- Added support for `{ silent: true }` configuration to suppress missing coordinate warnings when evaluating fallback properties.
|
|
42
|
+
|
|
43
|
+
## [1.2.0] - 2026-10-04
|
|
44
|
+
|
|
45
|
+
### Added
|
|
46
|
+
- **Astronomical Solar Quarters & Equinox/Solstice Resolution (`AstroTerm`)**:
|
|
47
|
+
- Integrated `AstroTerm` (aliases: `'astro'`, `'astronomy'`) directly into `CelestialPlugin`, merging the capabilities of `@magmacomputing/tempo-plugin-astro`.
|
|
48
|
+
- Exposes astronomical solar quarters (`vernal`, `summer`, `autumnal`, `winter`), equinox and solstice event timestamps (`vernalEquinox`, `summerSolstice`, `autumnalEquinox`, `winterSolstice`), daylight trends (`isDaylightIncreasing`, `isDaylightDecreasing`), and hemisphere season awareness.
|
|
49
|
+
- **Dedicated Documentation & Modular Architecture**:
|
|
50
|
+
- Added [`doc/astro.md`](doc/astro.md) guide and refactored internal implementation into modular components (`solar.ts`, `lunar.ts`, `tidal.ts`, `astro.ts`).
|
|
51
|
+
|
|
52
|
+
## [1.1.1] - 2026-09-29
|
|
53
|
+
|
|
54
|
+
### Performance & Memory
|
|
55
|
+
- **WeakCache Memoization**:
|
|
56
|
+
- Integrated `WeakCache` across solar twilight computations (`getSunriseSunset`, `getSolarPosition`), lunar ephemeris/phase ranges (`getLunarPhase`, `getLunarPhaseRange`, `getLunarPosition`, `getMoonriseMoonset`), and tidal state calculations (`getTidalState`).
|
|
57
|
+
- Enables zero-overhead ephemeral caching of repeated topocentric lookups with automatic garbage collection reclamation under memory pressure.
|
|
58
|
+
|
|
59
|
+
## [1.1.0] - 2026-09-25
|
|
60
|
+
|
|
61
|
+
### Added
|
|
62
|
+
- **Real-Time Horizontal Solar Coordinates & Photometric Lighting**:
|
|
63
|
+
- Exposes `t.term.solar.altitude` (-90°..+90° topocentric elevation), `t.term.solar.azimuth` (0°..360° compass bearing), `t.term.solar.zenith` (`90° - altitude`), `t.term.solar.isGoldenHour` (altitude between -4° and +6°), `t.term.solar.isBlueHour` (altitude between -6° and -4°), and `t.term.solar.shadowRatio` (vertical shadow multiplier `cot(altitude)`).
|
|
64
|
+
- **Polar Regions Handling (`isMidnightSun`, `isPolarNight`)**:
|
|
65
|
+
- Added continuous polar daylight (`t.term.solar.isMidnightSun`) and continuous polar night (`t.term.solar.isPolarNight`) flags with graceful `null` handling for non-occurring sunrise/sunset times in high latitudes (|lat| > 66.5°).
|
|
66
|
+
- **Local Coastal Tide Predictions & Port Calibration**:
|
|
67
|
+
- Exposes `t.term.tides.nextHighTide` and `t.term.tides.nextLowTide` as local `Tempo` instances calculated from observer meridian transits, with port hydrodynamic offset calibration via `geo.lunitidalIntervalMin` and regime classification (`t.term.tides.regime`).
|
|
68
|
+
- **Topocentric Real-Time Ephemeris (`t.term.lunar.altitude`, `t.term.lunar.azimuth`, `t.term.lunar.isAboveHorizon`)**:
|
|
69
|
+
- Computes observer-specific lunar altitude angle (corrected for horizontal parallax and atmospheric refraction), compass azimuth bearing (0°..360° True North), and real-time horizon visibility flag.
|
|
70
|
+
- **Local Meridian Transit (`t.term.lunar.transit`)**:
|
|
71
|
+
- Resolves exact `Tempo` instance for the Moon's upper culmination (highest sky altitude) within the observer's local 24-hour calendar day.
|
|
72
|
+
- **Bright Limb Crescent Tilt (`t.term.lunar.crescentTiltDeg`)**:
|
|
73
|
+
- Calculates apparent crescent tilt angle relative to local zenith (0°..360°), enabling accurate rendering of tropical "Wet Moon" / Cheshire Cat crescent orientations.
|
|
74
|
+
- **Lunar Distance, Parallax & Supermoon/Micromoon**:
|
|
75
|
+
- Exposes `t.term.lunar.distanceKm`, `t.term.lunar.angularDiameterArcmin`, `t.term.lunar.isSupermoon`, and `t.term.lunar.isMicromoon` to identify close orbital approaches during New/Full Moon.
|
|
76
|
+
- **Local Solar & Lunar Eclipse Detection (`t.term.lunar.eclipse`, `t.term.lunar.obscuration`)**:
|
|
77
|
+
- Provides observer-specific eclipse classification (`'total-solar'`, `'annular-solar'`, `'partial-solar'`, `'total-lunar'`, `'partial-lunar'`, `'penumbral-lunar'`) and fraction of disk obscured (0.0..1.0) on both `t.term.lunar` and `t.term.solar`.
|
|
78
|
+
- **Hemisphere-Aware Emojis**:
|
|
79
|
+
- Dynamically renders Northern or Southern hemisphere lunar crescent emojis based on observer latitude / `sphere` configuration.
|
|
80
|
+
- **Local Apparent Solar Time (`t.term.solar.solarTime`)**:
|
|
81
|
+
- Added `solarTime` to `t.term.solar` ([`TempoTermRegistry['solar']`](src/index.ts)). Returns a `Tempo` instance representing exact local apparent solar time (AST) factoring in longitudinal displacement (Δλ × 4 min/deg) and the Equation of Time (EoT).
|
|
82
|
+
- Evaluates to `null` when geographic coordinates are omitted in adherence to the location-dependent null contract.
|
|
83
|
+
- **Solar Noon Precision Verification**:
|
|
84
|
+
- Fully verified `t.term.solar.noon` meridian transit calculations with comprehensive test coverage.
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
## [1.0.0] - 2026-09-18
|
|
88
|
+
|
|
89
|
+
### Added
|
|
90
|
+
- **Production GA Release**:
|
|
91
|
+
- Promoted `@tempo-kit/plugin-celestial` from experimental status to official `v1.0.0` production release.
|
|
92
|
+
- **`/install` Subpath Side-Effect Entry Point**:
|
|
93
|
+
- Added dedicated `@tempo-kit/plugin-celestial/install` subpath for one-line side-effect installation (`import '@tempo-kit/plugin-celestial/install'`).
|
|
94
|
+
- Automatically registers `CelestialPlugin` (`SolarTerm`, `LunarTerm`, `TidalTerm`) onto `Tempo` upon side-effect import while preserving 100% tree-shakeability for the main package entry point.
|
|
95
|
+
|
|
96
|
+
## [0.2.0] - 2026-09-09
|
|
97
|
+
|
|
98
|
+
### Added
|
|
99
|
+
- **Elevation Support on Solar Term**: Exposed `elevation: number | null` on `t.term.solar` ([`TempoTermRegistry['solar']`](src/index.ts)).
|
|
100
|
+
- **Atmospheric Horizon Dip**: Factored `t.geo.elevation` into solar sunrise, sunset, and daylight duration calculations via `@magmacomputing/tempo-fns`. Observers at high elevations experience earlier sunrise and later sunset due to geometric horizon dip.
|
|
101
|
+
|
|
102
|
+
## [0.1.0] - 2026-09-02
|
|
103
|
+
|
|
104
|
+
### Added
|
|
105
|
+
- **Experimental Initial Release**: Launch of `@tempo-kit/plugin-celestial` (`v0.1.0`), bringing location-aware solar day state calculations (`t.term.sun`, `t.term.solar`) and lunar phase/ephemeris calculations (`t.term.moon`, `t.term.lunar`) to Tempo.
|
|
106
|
+
- **Tidal Term Resolution (`TidalTerm`)**: Introduced `TidalTerm` (`key: 'tide'`, `aliases: ['tides', 'tidal']`) for astronomical tide state resolution (`t.term.tide`, `t.term.tides`).
|
|
107
|
+
- **Astronomical Tidal Snap Anchors**: Enables boundary snapping for Spring (`#tide.spring`), Neap (`#tide.neap`), and King (`#tide.king`) tides based on solar-lunar alignment and orbital perigee proximity.
|
|
108
|
+
- **Location-Aware Moonrise & Moonset**: Added `t.term.lunar.moonrise` and `t.term.lunar.moonset` event resolution.
|
|
109
|
+
- **Solar Ephemeris Data**: Provides `t.term.solar.sunrise`, `t.term.solar.noon`, and `t.term.solar.sunset` along with twilight phases.
|
|
110
|
+
- **Universal Geolocation Integration**: Updated documentation and usage guides to feature `@magmacomputing/library`'s `geoLookup()` for automatic browser hardware and server IP geolocation mapping.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Magma Computing
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,210 @@
|
|
|
1
|
-
|
|
1
|
+

|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
# @tempo-kit/plugin-celestial
|
|
4
|
+
|
|
5
|
+
<p align="center">
|
|
6
|
+
<a href="https://www.npmjs.com/package/@tempo-kit/plugin-celestial"><img src="https://img.shields.io/npm/v/@tempo-kit/plugin-celestial?style=flat-square" alt="npm version" style="display: inline-block; margin: 0 4px;"></a> <a href="https://www.npmjs.com/package/tempo-kit"><img src="https://img.shields.io/npm/dependency-version/@tempo-kit/plugin-celestial/peer/tempo-kit?style=flat-square" alt="npm peer dependency version" style="display: inline-block; margin: 0 4px;"></a> <a href="https://www.npmjs.com/package/@tempo-kit/plugin-celestial"><img src="https://img.shields.io/npm/l/@tempo-kit/plugin-celestial?style=flat-square" alt="License" style="display: inline-block; margin: 0 4px;"></a> <a href="https://www.typescriptlang.org/"><img src="https://img.shields.io/badge/TypeScript-Ready-blue?logo=typescript&style=flat-square" alt="TypeScript Ready" style="display: inline-block; margin: 0 4px;"></a> <a href="https://magmacomputing.github.io/magma/doc/9-plugins/celestial.index.html"><img src="https://img.shields.io/badge/Docs-VitePress-brightgreen?logo=vitepress&style=flat-square" alt="Documentation" style="display: inline-block; margin: 0 4px;"></a>
|
|
7
|
+
</p>
|
|
8
|
+
|
|
9
|
+
Tempo plugin for location-aware solar twilight events (`sun`/`solar`), lunar phase tracking (`moon`/`lunar`), and astronomical tidal mechanics (`tide`/`tides`).
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install @tempo-kit/plugin-celestial
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Features
|
|
18
|
+
|
|
19
|
+
- **Astronomical Seasons & Solar Events**: Calculates precise astronomical equinoxes (Vernal, Autumnal) and solstices (Summer, Winter) with sub-minute precision, hemisphere awareness (`sphere: 'north' | 'south'`), and standard Tempo terms (`t.term.astro`, `t.term.equinox`, `t.term.solstice`, `t.term.astronomy`).
|
|
20
|
+
- **Solar Day Cycles**: Calculates `daylight`, `night`, `civil-twilight`, `nautical-twilight`, and `astronomical-twilight`.
|
|
21
|
+
- **Ephemeris Data**: Returns `sunrise`, `sunset`, `noon`, `solarTime` (Local Apparent Solar Time), total `daylightDurationMs`, and explicit `latitude`/`longitude` for given coordinates.
|
|
22
|
+
- **Lunar Phase & Ephemeris**: Calculates 8 discrete lunar phase states (`new-moon`, `waxing-crescent`, etc.), illumination 0.0–1.0 fraction, age in days, hemisphere-aware emoji indicators, and location-aware `moonrise` and `moonset` events.
|
|
23
|
+
- **Astronomical Tidal Mechanics**: Provides pure astronomical solar/lunar alignment calculations (`t.term.tide`, `t.term.tides`) for `spring`, `neap`, and `normal` tides, alongside `isKingTide` perigee indicators.
|
|
24
|
+
|
|
25
|
+
> [!NOTE]
|
|
26
|
+
> **Pure Astronomical Calculations**:
|
|
27
|
+
> Tidal state resolution relies exclusively on deterministic celestial mechanics (solar-lunar ecliptic longitude alignment (Δλ) and anomalistic lunar perigee proximity) for reproducible, offset-independent math across all time zones and locations.
|
|
28
|
+
|
|
29
|
+
## Geographic Coordinates & Null Contract
|
|
30
|
+
|
|
31
|
+
> [!IMPORTANT]
|
|
32
|
+
> **Location-Dependent Null Contract**:
|
|
33
|
+
> - **Global Astronomical Properties** (`t.term.moon`, `t.term.lunar.phase`, `t.term.tides.isSpringTide`, `t.term.tides.alignmentDeg`) resolve location-independently and are always computed.
|
|
34
|
+
> - **Geo-Dependent Properties** (`t.term.sun`, `solar.sunrise`, `solar.sunset`, `solar.noon`, `solar.solarTime`, `lunar.moonrise`, `lunar.moonset`, `tides.lunarTideMinute`) evaluate to `null` when geographic coordinates (`geo: { lat, lng }`) are omitted.
|
|
35
|
+
> - **Distinction**: Property access on `t.term` evaluates to `undefined` if `CelestialPlugin` is not loaded, and to `null` if the plugin is active but location coordinates were not supplied. When `debug >= 1` is enabled in `Tempo` configuration, a developer warning is logged when evaluating geo-dependent keys without coordinates.
|
|
36
|
+
|
|
37
|
+
### Obtaining Coordinates
|
|
38
|
+
|
|
39
|
+
Use `geoLookup()` from `@tempo-kit/plugin-geo` to automatically resolve location coordinates across both browser and server environments:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
npm install @tempo-kit/plugin-geo
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
> [!WARNING]
|
|
46
|
+
> **Geolocation Behavior**:
|
|
47
|
+
> - **Browser**: On first invocation, `geoLookup()` will prompt the user for permission to access hardware location services.
|
|
48
|
+
> - **Server**: In Node.js or server environments without GPS hardware, coordinates are resolved via IP geolocation representing the physical server/datacenter network location.
|
|
49
|
+
|
|
50
|
+
```typescript
|
|
51
|
+
import { Tempo } from 'tempo-kit';
|
|
52
|
+
import { CelestialPlugin } from '@tempo-kit/plugin-celestial';
|
|
53
|
+
import { geoLookup } from '@tempo-kit/plugin-geo';
|
|
54
|
+
|
|
55
|
+
Tempo.use(CelestialPlugin);
|
|
56
|
+
|
|
57
|
+
// Automatically resolves location coordinates via browser hardware or server IP
|
|
58
|
+
const geo = await geoLookup();
|
|
59
|
+
const t = new Tempo({ geo });
|
|
60
|
+
|
|
61
|
+
console.log(t.term.sun); // 'daylight' or 'night'
|
|
62
|
+
console.log(t.term.lunar.moonrise); // Tempo instance for local moonrise
|
|
63
|
+
console.log(t.term.tide); // 'spring', 'neap', or 'normal'
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Auto-Installation (Side-Effect Import)
|
|
67
|
+
|
|
68
|
+
```typescript
|
|
69
|
+
import { Tempo } from 'tempo-kit';
|
|
70
|
+
import { geoLookup } from '@tempo-kit/plugin-geo';
|
|
71
|
+
import '@tempo-kit/plugin-celestial/install';
|
|
72
|
+
|
|
73
|
+
const geo = await geoLookup();
|
|
74
|
+
const t = new Tempo({ geo });
|
|
75
|
+
console.log(t.term.sun);
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Usage
|
|
79
|
+
|
|
80
|
+
```typescript
|
|
81
|
+
import { Tempo } from 'tempo-kit';
|
|
82
|
+
import { CelestialPlugin } from '@tempo-kit/plugin-celestial';
|
|
83
|
+
|
|
84
|
+
Tempo.use(CelestialPlugin);
|
|
85
|
+
|
|
86
|
+
const t = new Tempo('2026-06-21T12:00:00Z', { geo: { lat: 40.7128, lng: -74.006 } });
|
|
87
|
+
|
|
88
|
+
// --- Astronomical Seasons & Solar Events ---
|
|
89
|
+
console.log(t.term.astro); // 'Summer' (or 'Winter' if sphere: 'south')
|
|
90
|
+
console.log(t.term.astronomy.season); // 'Summer'
|
|
91
|
+
console.log(t.term.astronomy.event); // 'Solstice'
|
|
92
|
+
console.log(t.term.solstice); // 'Summer'
|
|
93
|
+
|
|
94
|
+
// --- Solar Day State & Phase Querying ---
|
|
95
|
+
console.log(t.term.sun); // 'daylight'
|
|
96
|
+
console.log(t.term.solar.key); // 'daylight'
|
|
97
|
+
console.log(t.term.solar.phase); // 'Daylight'
|
|
98
|
+
console.log(t.term.solar.phases); // ['night', 'astronomical-twilight', 'nautical-twilight', 'civil-twilight', 'daylight']
|
|
99
|
+
console.log(t.term.solar.sunrise); // Tempo instance for local sunrise
|
|
100
|
+
console.log(t.term.solar.noon); // Tempo instance for local solar noon (upper culmination)
|
|
101
|
+
console.log(t.term.solar.nadir); // Tempo instance for local solar midnight (lower culmination)
|
|
102
|
+
console.log(t.term.solar.zenith); // Zenith angle in degrees (90° - altitude)
|
|
103
|
+
console.log(t.term.solar.solarTime); // Tempo instance for local apparent solar time
|
|
104
|
+
console.log(t.term.solar.geo); // { latitude: 40.7128, longitude: -74.006 }
|
|
105
|
+
|
|
106
|
+
// --- Lunar Phase & Ephemeris ---
|
|
107
|
+
console.log(t.term.moon); // 'waxing-crescent'
|
|
108
|
+
console.log(t.term.lunar.phase); // 'Waxing Crescent'
|
|
109
|
+
console.log(t.term.lunar.phases); // ['new-moon', 'waxing-crescent', 'first-quarter', 'waxing-gibbous', 'full-moon', 'waning-gibbous', 'third-quarter', 'waning-crescent']
|
|
110
|
+
console.log(t.term.lunar.illumination); // 0.45
|
|
111
|
+
console.log(t.term.lunar.moonrise); // Tempo instance for local moonrise (or null)
|
|
112
|
+
console.log(t.term.lunar.transit); // Tempo instance for upper meridian culmination (or null)
|
|
113
|
+
console.log(t.term.lunar.nadir); // Tempo instance for lower culmination / anti-transit (or null)
|
|
114
|
+
console.log(t.term.lunar.zenith); // Lunar zenith distance angle in degrees (90° - altitude)
|
|
115
|
+
|
|
116
|
+
// --- Astronomical Tidal Mechanics ---
|
|
117
|
+
console.log(t.term.tide); // 'spring', 'neap', or 'normal'
|
|
118
|
+
console.log(t.term.tides.alignmentDeg); // Solar-lunar alignment angle (0..360°)
|
|
119
|
+
console.log(t.term.tides.isSpringTide); // true during Syzygy (New or Full Moon)
|
|
120
|
+
console.log(t.term.tides.isNeapTide); // true during Quadrature (1st or 3rd Quarter)
|
|
121
|
+
console.log(t.term.tides.isKingTide); // true when Spring Tide aligns with Lunar Perigee
|
|
122
|
+
|
|
123
|
+
// --- Programmatic Navigation ---
|
|
124
|
+
// Use .phases to dynamically navigate to the next lunar phase
|
|
125
|
+
const nextPhaseKey = t.term.lunar.phases[t.term.lunar.index % 8];
|
|
126
|
+
const nextMoonTempo = t.set(`#lunar.${nextPhaseKey}`);
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
> ⚡ **[Try this live in the interactive Tempo Sandbox ↗](https://magmacomputing.github.io/magma/repl/index.html?plugin=celestial)**
|
|
130
|
+
|
|
131
|
+
## Term Lifecycle Hooks (Showcase)
|
|
132
|
+
|
|
133
|
+
`CelestialPlugin` showcases Tempo's core `TermHook` lifecycle system across all four terms:
|
|
134
|
+
|
|
135
|
+
### 1. Stepping, Difference & Boundary Snapping (`[TermHook.step]`, `[TermHook.diff]`, `[TermHook.bound]`)
|
|
136
|
+
```typescript
|
|
137
|
+
// Lunar phase navigation & synodic lunation stepping (~29.53 days)
|
|
138
|
+
t.set('#moon.start'); // Snap to start of active lunar phase
|
|
139
|
+
t.set('#moon.end'); // Snap to end of active lunar phase
|
|
140
|
+
t.add('#moon'); // Advance by 1 full synodic lunation (~29.53 days)
|
|
141
|
+
t1.until(t2, '#moon'); // Count elapsed synodic lunations (or t2.since(t1, '#moon'))
|
|
142
|
+
|
|
143
|
+
// Solar cycle snapping
|
|
144
|
+
t.set('#solar.start'); // Snap to local sunrise
|
|
145
|
+
t.set('#solar.mid'); // Snap to local solar noon
|
|
146
|
+
t.set('#solar.end'); // Snap to local sunset
|
|
147
|
+
|
|
148
|
+
// Astronomical season snapping
|
|
149
|
+
t.set('#astro.start'); // Start of current astronomical season
|
|
150
|
+
t.set('#astro.mid'); // Midpoint of current astronomical season
|
|
151
|
+
t.set('#astro.end'); // End of current astronomical season
|
|
152
|
+
|
|
153
|
+
// Semidiurnal tidal cycle stepping (745 min) & high/low tide snapping
|
|
154
|
+
t.add('#tide'); // Step by 1 tidal cycle (12h 25m)
|
|
155
|
+
t.set('#tide.start'); // Snap to next high tide
|
|
156
|
+
t.set('#tide.end'); // Snap to next low tide
|
|
157
|
+
t1.until(t2, '#tide'); // Count elapsed tidal cycles
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### 2. Semantic Parsing & Natural Language Ordinals (`[TermHook.parse]`, `[TermHook.ordinal]`)
|
|
161
|
+
```typescript
|
|
162
|
+
// Direct solar & astronomical parse targets
|
|
163
|
+
Tempo.from('#solar.sunrise', { anchor }); // Next sunrise from anchor
|
|
164
|
+
Tempo.from('#solar.sunset', { anchor }); // Next sunset from anchor
|
|
165
|
+
Tempo.from('#solar.noon', { anchor }); // Next solar noon from anchor
|
|
166
|
+
Tempo.from('#equinox.vernal', { anchor }); // Vernal equinox for anchor year
|
|
167
|
+
Tempo.from('#solstice.summer', { anchor }); // Summer solstice for anchor year
|
|
168
|
+
|
|
169
|
+
// Natural language astronomical ordinals
|
|
170
|
+
Tempo.from('1st day of #equinox', { anchor });
|
|
171
|
+
Tempo.from('2nd day of #solstice', { anchor });
|
|
172
|
+
Tempo.from('last day of #equinox', { anchor });
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### 3. Dynamic Format Token Interpolation (`[TermHook.format]`)
|
|
176
|
+
```typescript
|
|
177
|
+
// Format templates resolve contextual celestial tokens
|
|
178
|
+
t.format('Current Moon: {#moon.emoji} {#moon.phase} ({#moon.illumination})');
|
|
179
|
+
// => "Current Moon: 🌔 Waxing Gibbous (78%)"
|
|
180
|
+
|
|
181
|
+
t.format('Sun: {#solar.phase} | Alt: {#solar.altitude} | Azimuth: {#solar.azimuth}');
|
|
182
|
+
// => "Sun: Daylight | Alt: 42.5° | Azimuth: 180.2°"
|
|
183
|
+
|
|
184
|
+
t.format('Tide: {#tide.state} | Season: {#astro.season}');
|
|
185
|
+
// => "Tide: spring | Season: Summer"
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
## Phase & State Discovery Metadata
|
|
189
|
+
|
|
190
|
+
`LunarTerm`, `SolarTerm`, and `TidalTerm` expose immutable, frozen array references (`Object.freeze`) containing all valid identifiers for terms resolution:
|
|
191
|
+
|
|
192
|
+
- **Static Term References**: `LunarTerm.phases`, `SolarTerm.phases`, and `TidalTerm.phases` are available on the plugin definitions without instantiating a `Tempo` object.
|
|
193
|
+
- **Instance Scope References**: `t.term.lunar.phases`, `t.term.solar.phases`, and `t.term.tides.states` share the exact same frozen array references (`t.term.lunar.phases === LunarTerm.phases`), adding zero memory or GC overhead.
|
|
194
|
+
|
|
195
|
+
> [!TIP]
|
|
196
|
+
> **Indexing Tip**: Following ISO calendar standards that drive Temporal and Tempo, `.index` is 1-based (`1..8`), while `.phases` is a standard 0-indexed JavaScript array (`0..7`).
|
|
197
|
+
> - **Current Phase**: Use `lunar.key` or `lunar.phases[lunar.index - 1]`.
|
|
198
|
+
> - **Next Phase**: Use `lunar.phases[lunar.index % 8]` (1-based index modulo 8 seamlessly targets the next phase index with automatic wrap-around).
|
|
199
|
+
|
|
200
|
+
## Documentation
|
|
201
|
+
|
|
202
|
+
For full documentation and live examples, visit the [Celestial Plugin Documentation](https://magmacomputing.github.io/magma/doc/9-plugins/celestial.index.html).
|
|
203
|
+
|
|
204
|
+
## Licensing
|
|
205
|
+
|
|
206
|
+
This is a **Community** plugin. It is completely free and open-source for personal and commercial use.
|
|
207
|
+
|
|
208
|
+
## License
|
|
209
|
+
|
|
210
|
+
MIT
|
package/dist/astro.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Tempo } from 'tempo-kit';
|
|
2
|
+
import { type TermSpan } from 'tempo-kit/plugin/sdk';
|
|
3
|
+
export declare const ASTRO_KEYS: readonly ["Vernal", "Summer", "Autumnal", "Winter"];
|
|
4
|
+
export type AstroKey = (typeof ASTRO_KEYS)[number];
|
|
5
|
+
export interface AstronomyScope {
|
|
6
|
+
key: AstroKey;
|
|
7
|
+
strict: AstroKey;
|
|
8
|
+
season: 'Spring' | 'Summer' | 'Autumn' | 'Winter';
|
|
9
|
+
sphere: Tempo.COMPASS;
|
|
10
|
+
event: 'Equinox' | 'Solstice';
|
|
11
|
+
keys: readonly AstroKey[];
|
|
12
|
+
group: 'astronomy';
|
|
13
|
+
span: TermSpan;
|
|
14
|
+
}
|
|
15
|
+
export type AstroScope = AstronomyScope;
|
|
16
|
+
/**
|
|
17
|
+
* Options for configuring the Astronomical Term plugin.
|
|
18
|
+
*/
|
|
19
|
+
export interface AstroTermOptions {
|
|
20
|
+
sphere?: 'north' | 'south';
|
|
21
|
+
hemisphere?: 'north' | 'south';
|
|
22
|
+
precision?: 'standard' | 'high';
|
|
23
|
+
[key: string]: any;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Exposes precise astronomical calculations (equinoxes and solstices)
|
|
27
|
+
* as a standard Tempo scope (`t.term.astro` & `t.term.astronomy`).
|
|
28
|
+
*/
|
|
29
|
+
export declare const AstroTerm: any;
|
|
30
|
+
declare module 'tempo-kit' {
|
|
31
|
+
interface TempoTermRegistry {
|
|
32
|
+
astro: AstroKey;
|
|
33
|
+
equinox: 'Vernal' | 'Autumnal';
|
|
34
|
+
solstice: 'Summer' | 'Winter';
|
|
35
|
+
astronomy: AstronomyScope;
|
|
36
|
+
}
|
|
37
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { Tempo } from 'tempo-kit';
|
|
2
|
+
import { LUNAR_PHASE_KEYS, SOLAR_PHASE_STATES, SOLAR_PHASE_NAMES, TIDAL_PHASE_STATES, HALF_DAY_MS, DAY_MS, getEclipse, getSolarPosition } from 'tempo-fns';
|
|
3
|
+
import type { LunarPhaseKey, LunarPhaseName, SolarPhaseName, TidalState, TidalRegime, TidalOptions, TidalResult, LunarPositionResult, LunarDistanceResult, CrescentTiltResult, SolarPositionResult, EclipseType, EclipseResult } from 'tempo-fns';
|
|
4
|
+
import { LunarTerm, type LunarPhaseOptions, type LunarPhaseResult } from './lunar.js';
|
|
5
|
+
import { SolarTerm, type SolarPhaseState } from './solar.js';
|
|
6
|
+
import { TidalTerm } from './tidal.js';
|
|
7
|
+
import { AstroTerm, ASTRO_KEYS, type AstroKey, type AstroTermOptions, type AstronomyScope, type AstroScope } from './astro.js';
|
|
8
|
+
export type { LunarPhaseKey, LunarPhaseName, SolarPhaseName, TidalState, TidalRegime, TidalOptions, TidalResult, LunarPositionResult, LunarDistanceResult, CrescentTiltResult, SolarPositionResult, EclipseType, EclipseResult, LunarPhaseOptions, LunarPhaseResult, SolarPhaseState, AstroKey, AstroTermOptions, AstronomyScope, AstroScope, };
|
|
9
|
+
export { LUNAR_PHASE_KEYS, SOLAR_PHASE_STATES, SOLAR_PHASE_NAMES, TIDAL_PHASE_STATES, ASTRO_KEYS, HALF_DAY_MS, DAY_MS, getEclipse, getSolarPosition, LunarTerm, SolarTerm, TidalTerm, AstroTerm, };
|
|
10
|
+
declare module 'tempo-kit' {
|
|
11
|
+
interface TempoTermRegistry {
|
|
12
|
+
moon: LunarPhaseKey;
|
|
13
|
+
lunar: {
|
|
14
|
+
key: LunarPhaseKey;
|
|
15
|
+
phase: LunarPhaseName;
|
|
16
|
+
index: number;
|
|
17
|
+
illumination: number;
|
|
18
|
+
ageDays: number;
|
|
19
|
+
isWaxing: boolean;
|
|
20
|
+
emoji?: string | undefined;
|
|
21
|
+
phases: readonly LunarPhaseKey[];
|
|
22
|
+
keys: readonly LunarPhaseKey[];
|
|
23
|
+
moonrise: Tempo | null;
|
|
24
|
+
moonset: Tempo | null;
|
|
25
|
+
transit: Tempo | null;
|
|
26
|
+
nadir: Tempo | null;
|
|
27
|
+
altitude: number | null;
|
|
28
|
+
azimuth: number | null;
|
|
29
|
+
zenith: number | null;
|
|
30
|
+
isAboveHorizon: boolean | null;
|
|
31
|
+
crescentTiltDeg: number | null;
|
|
32
|
+
distanceKm: number | null;
|
|
33
|
+
angularDiameterArcmin: number | null;
|
|
34
|
+
isSupermoon: boolean | null;
|
|
35
|
+
isMicromoon: boolean | null;
|
|
36
|
+
eclipse: EclipseType | null;
|
|
37
|
+
obscuration: number | null;
|
|
38
|
+
group: 'lunar';
|
|
39
|
+
geo?: any;
|
|
40
|
+
year: number;
|
|
41
|
+
month: number;
|
|
42
|
+
day: number;
|
|
43
|
+
hour: number;
|
|
44
|
+
minute: number;
|
|
45
|
+
second: number;
|
|
46
|
+
millisecond: number;
|
|
47
|
+
microsecond: number;
|
|
48
|
+
nanosecond: number;
|
|
49
|
+
start: Tempo;
|
|
50
|
+
end: Tempo;
|
|
51
|
+
};
|
|
52
|
+
sun: SolarPhaseState | null;
|
|
53
|
+
solar: {
|
|
54
|
+
key: SolarPhaseState | null;
|
|
55
|
+
phase: SolarPhaseName | null;
|
|
56
|
+
phases: readonly SolarPhaseState[];
|
|
57
|
+
keys: readonly SolarPhaseState[];
|
|
58
|
+
index: number | null;
|
|
59
|
+
group: 'solar';
|
|
60
|
+
geo?: any;
|
|
61
|
+
year: number;
|
|
62
|
+
month: number;
|
|
63
|
+
day: number;
|
|
64
|
+
hour: number;
|
|
65
|
+
minute: number;
|
|
66
|
+
second: number;
|
|
67
|
+
millisecond: number;
|
|
68
|
+
microsecond: number;
|
|
69
|
+
nanosecond: number;
|
|
70
|
+
elevation: number | null;
|
|
71
|
+
sunrise: Tempo | null;
|
|
72
|
+
sunset: Tempo | null;
|
|
73
|
+
noon: Tempo | null;
|
|
74
|
+
nadir: Tempo | null;
|
|
75
|
+
solarTime: Tempo | null;
|
|
76
|
+
altitude: number | null;
|
|
77
|
+
azimuth: number | null;
|
|
78
|
+
zenith: number | null;
|
|
79
|
+
isGoldenHour: boolean | null;
|
|
80
|
+
isBlueHour: boolean | null;
|
|
81
|
+
shadowRatio: number | null;
|
|
82
|
+
isMidnightSun: boolean | null;
|
|
83
|
+
isPolarNight: boolean | null;
|
|
84
|
+
daylightDurationMs: number | null;
|
|
85
|
+
isDaylight: boolean | null;
|
|
86
|
+
civil: {
|
|
87
|
+
sunrise: Tempo | null;
|
|
88
|
+
sunset: Tempo | null;
|
|
89
|
+
};
|
|
90
|
+
nautical: {
|
|
91
|
+
sunrise: Tempo | null;
|
|
92
|
+
sunset: Tempo | null;
|
|
93
|
+
};
|
|
94
|
+
astronomical: {
|
|
95
|
+
sunrise: Tempo | null;
|
|
96
|
+
sunset: Tempo | null;
|
|
97
|
+
};
|
|
98
|
+
eclipse: EclipseType | null;
|
|
99
|
+
obscuration: number | null;
|
|
100
|
+
start: Tempo;
|
|
101
|
+
end: Tempo;
|
|
102
|
+
};
|
|
103
|
+
tide: TidalState;
|
|
104
|
+
tides: {
|
|
105
|
+
key: TidalState;
|
|
106
|
+
state: TidalState;
|
|
107
|
+
group: 'tide';
|
|
108
|
+
alignmentDeg: number;
|
|
109
|
+
isSpringTide: boolean;
|
|
110
|
+
isNeapTide: boolean;
|
|
111
|
+
isKingTide: boolean | null;
|
|
112
|
+
perigeeFactor: number;
|
|
113
|
+
lunarTideMinute: number | null;
|
|
114
|
+
nextHighTide: Tempo | null;
|
|
115
|
+
nextLowTide: Tempo | null;
|
|
116
|
+
lunitidalIntervalMin: number | null;
|
|
117
|
+
regime: TidalRegime | null;
|
|
118
|
+
states: readonly TidalState[];
|
|
119
|
+
phases: readonly TidalState[];
|
|
120
|
+
keys: readonly TidalState[];
|
|
121
|
+
geo?: any;
|
|
122
|
+
year: number;
|
|
123
|
+
month: number;
|
|
124
|
+
day: number;
|
|
125
|
+
hour: number;
|
|
126
|
+
minute: number;
|
|
127
|
+
second: number;
|
|
128
|
+
millisecond: number;
|
|
129
|
+
microsecond: number;
|
|
130
|
+
nanosecond: number;
|
|
131
|
+
start: Tempo;
|
|
132
|
+
end: Tempo;
|
|
133
|
+
};
|
|
134
|
+
astro: AstroKey;
|
|
135
|
+
equinox: 'Vernal' | 'Autumnal';
|
|
136
|
+
solstice: 'Summer' | 'Winter';
|
|
137
|
+
astronomy: AstronomyScope;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* ## CelestialPlugin
|
|
142
|
+
* Plugin bundling SolarTerm (`sun`/`solar`), LunarTerm (`moon`/`lunar`), TidalTerm (`tide`/`tides`), and AstroTerm (`astro`/`equinox`/`solstice`).
|
|
143
|
+
*/
|
|
144
|
+
export declare const CelestialPlugin: any[];
|
|
145
|
+
export default CelestialPlugin;
|