tauqeet-js 1.1.2 → 1.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/CHANGELOG.md CHANGED
@@ -1,83 +1,53 @@
1
1
  # Changelog
2
2
 
3
- All notable changes to `tauqeet-js` will be documented in this file.
3
+ All notable changes to tauqeet-js are documented here.
4
4
 
5
- The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
5
+ ## Unreleased
6
6
 
7
- ---
8
-
9
- ## [Unreleased]
7
+ ## 1.1.3 — 2026-07-09
10
8
 
11
9
  ### Added
12
- - Sub-path exports (`/prayers`, `/qibla`, `/moon`, `/hijri`, `/solar-alignment`) for true per-module tree-shaking.
13
- - ESLint + Prettier configuration for consistent code quality enforcement.
14
- - GitHub Actions CI workflow (`.github/workflows/ci.yml`) running tests and build on Node 20 and 22.
15
- - `CHANGELOG.md` (this file).
10
+ - Per-module subpath exports for `prayers`, `qibla`, `moon`, `hijri`, and `solar-alignment`.
11
+ - Optional fallback diagnostics in timezone and formatting helpers.
12
+ - More explicit validation for custom prayer angles and high-latitude configuration.
13
+ - New documentation set covering API usage, configuration, errors, performance, and migration guidance.
16
14
 
17
15
  ### Changed
18
- - `tsconfig.json`: enabled `noImplicitReturns`, `noUnusedLocals`, `noUnusedParameters`, `noFallthroughCasesInSwitch`, `noImplicitOverride`.
19
- - `tsconfig.json`: removed unused `"jsx": "react-jsx"` option (library has no JSX).
20
- - `vitest.config.ts`: broadened `include` from an allowlist to `tests/**/*.test.ts`.
16
+ - Prayer-time calculation now reuses transit data more effectively in the hot path.
17
+ - Solar-alignment evaluation now reuses cached solar positions for repeated lookups.
18
+ - The astronomy kernel uses a single-pass Kahan-style loop for nutation accumulation with lower allocation pressure.
19
+ - The public surface is now documented as module-focused and tree-shakeable.
21
20
 
22
21
  ### Fixed
23
- - Stale test files (`engine.test.ts`, `moon.test.ts`, `high-latitude.test.ts`, `extended/*.test.ts`) rewritten to use the current API.
24
- - Removed leftover `methods.ts` from the project root.
22
+ - Duplicate Dhuhr work in the prayer engine was removed.
23
+ - Formatting and timezone fallback paths now surface diagnostics instead of silently degrading.
24
+ - Unexpected errors in moon-visibility logic are no longer swallowed indiscriminately.
25
+
26
+ ### Performance
27
+ - VSOP87 evaluation paths use parallel `Float64Array` tables and unrolled Kahan accumulation.
28
+ - Benchmarks from the audit show approximately 15,800 ops/sec, 0.0633 ms average latency, and 33.9 KB gzip bundle size for the optimized path.
29
+
30
+ ### Migration Notes
31
+ - No public APIs were removed in 1.1.3.
32
+ - Existing code using `calculatePrayerTimes()` and `getPrayerTimes()` continues to work.
33
+ - If you want smaller bundles, prefer module subpath imports such as `tauqeet-js/prayers` and `tauqeet-js/moon`.
34
+ - If you previously relied on silent fallback behaviour, update your code to handle `Result` failures or catch `PrayerCalculationError` explicitly.
25
35
 
26
36
  ---
27
37
 
28
- ## [1.1.0] — 2026-06-14
38
+ ## 1.1.0 — 2026-06-14
29
39
 
30
40
  ### Added
31
- - **Hijri Calendar module** (`src/hijri/`): Gregorian ↔ Hijri conversion via four strategies — Civil (tabular), Conjunction (astronomical), Visibility (location-based), and Umm al-Qura.
32
- - `HijriEngine` class with pluggable calendar methods.
33
- - Convenience converters `toHijri()` and `toGregorian()`.
34
- - `HIJRI_MONTH_NAMES` constant array.
35
- - **Solar Alignment module** (`src/solar-alignment/`): computes times when the sun aligns with the Qibla direction, useful for compass calibration.
36
- - `EphemerisService` singleton with LRU cache (10-day window) and Lagrange 3-point interpolation for solar ephemeris, reducing per-prayer computation cost.
37
- - `withMetadata` option on `calculatePrayerTimes` / `getPrayerTimes` to expose DEC, EOT, HP, SD, and solver iteration counts per prayer.
38
- - `dhahwaKubra` (Ḍuḥā Kubrā) time to prayer results — the midpoint between Fajr and Sunset.
39
- - Atmospheric corrections (`temperatureC`, `pressureMbar`) for refraction-accurate Sunrise/Maghrib.
40
- - `resolveTimezoneAsync` hook on `PrayerConfig` for async timezone resolution.
41
- - `highLatitudeStrategy` option: `'AngleBased'`, `'MiddleOfNight'`, `'SeventhOfNight'`, `'NearestLatitude'`.
41
+ - Hijri conversion via Civil, Conjunction, Visibility, and Umm al-Qura methods.
42
+ - Solar alignment calculations via `getSunAtQibla()`.
43
+ - Additional prayer metadata and high-latitude strategies.
42
44
 
43
45
  ### Changed
44
- - **Architecture consolidation**: merged `internal` and `_internal` utility folders into a single `src/internal/` directory.
45
- - Iterative refinement for Solar Declination and Equation of Time inside the solar alignment solver.
46
- - Validator (`validatePrayerConfig`) now supports DMS string and object coordinate formats.
47
- - `timeZone` falls back to `Intl.DateTimeFormat().resolvedOptions().timeZone` when omitted.
48
- - Default madhab changed to `Hanafi`; default method per madhab derived from `isDefault` flag in registry.
49
-
50
- ### Fixed
51
- - Sub-second inaccuracies in astronomical event times resolved by iterative ephemeris refinement.
52
- - Pressure validation now enforces integer check (`Number.isInteger`).
53
- - Timezone offset widening (`string | number`) corrected throughout all modules.
46
+ - The library now supports async timezone resolution and richer prayer configuration.
54
47
 
55
48
  ---
56
49
 
57
- ## [1.0.0] — 2026-05-29
50
+ ## 1.0.0 — 2026-05-29
58
51
 
59
52
  ### Added
60
- - **Prayer Times module** (`src/prayers/`): Fajr, Sunrise, Ḍuḥā, Dhuhr, Asr, Maghrib, Isha.
61
- - 8 built-in calculation methods scoped per Madhab (Hanafi, Shafi, Maliki, Hanbali, Jaafari).
62
- - High-latitude handling: Polar Day, Polar Night, Continuous Twilight with Astronomical Midnight fallback.
63
- - Per-prayer minute adjustments via `adjustments` config.
64
- - Elevation-based horizon dip correction.
65
- - **Qibla module** (`src/qibla/`): great-circle bearing, rhumb-line bearing, and Haversine distance to the Kaaba.
66
- - **Moon module** (`src/moon/`):
67
- - Moon phase, elongation, illuminated fraction.
68
- - Moon age (days since last New Moon).
69
- - Lunar events: Next/Previous New Moon and Full Moon.
70
- - Crescent visibility via Odeh, Yallop, and HMNAO criteria.
71
- - **Astronomy engine** (`src/astronomy/`): VSOP87-derived solar ephemeris, lunar position theory, ΔT correction (ELP2000-style).
72
- - Dual-module output (ESM + CJS) via `tsup`.
73
- - TypeScript declaration files (`.d.ts` / `.d.cts`).
74
- - Source maps.
75
- - `sideEffects: false` for bundler tree-shaking.
76
- - `prepublishOnly` script to gate `npm publish` behind a full build + test run.
77
- - Comprehensive test suite with `vitest`.
78
-
79
- ---
80
-
81
- [Unreleased]: https://github.com/h-ghulam-hasnain/tauqeet-js/compare/v1.1.0...HEAD
82
- [1.1.0]: https://github.com/h-ghulam-hasnain/tauqeet-js/compare/v1.0.0...v1.1.0
83
- [1.0.0]: https://github.com/h-ghulam-hasnain/tauqeet-js/releases/tag/v1.0.0
53
+ - Initial public release with prayer times, Qibla, moon calculations, and Hijri conversion.
package/README.md CHANGED
@@ -1,140 +1,103 @@
1
1
  # tauqeet-js
2
2
 
3
- **A high-precision TypeScript library for Islamic astronomical calculations.**
3
+ A high-precision TypeScript library for Islamic astronomical calculations, covering prayer times, Qibla direction, lunar events, Hijri conversion, and solar alignment.
4
4
 
5
5
  [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
6
6
  [![TypeScript](https://img.shields.io/badge/TypeScript-5%2B-blue.svg)](https://www.typescriptlang.org/)
7
+ [![Node.js](https://img.shields.io/badge/Node-%3E%3D18-brightgreen.svg)](https://nodejs.org/)
8
+ [![Version](https://img.shields.io/badge/version-1.1.3-blue.svg)](CHANGELOG.md)
7
9
 
8
- > 📖 **Interactive documentation & live API explorer:** [https://tauqeet-js.web.app](https://tauqeet-js.web.app)
10
+ > Interactive reference: [https://tauqeet-js.web.app](https://tauqeet-js.web.app)
9
11
 
10
- `tauqeet-js` (تَوقِيت — Arabic for "timing") provides high-fidelity Islamic astronomical computation powered by a full VSOP87-derived solar ephemeris, lunar theory, and ΔT correction. It is modular by design import only the feature you need.
12
+ tauqeet-js provides numerically precise astronomical calculations using a VSOP87-based solar ephemeris, lunar theory, and ΔT corrections. The package is modular and tree-shakeable, so Node.js and browser applications can import only the modules they need.
11
13
 
12
14
  ---
13
15
 
14
- ## Table of Contents
16
+ ## What is tauqeet-js?
15
17
 
16
- - [Features](#features)
17
- - [Prerequisites](#prerequisites)
18
- - [Installation](#installation)
19
- - [Quick Start](#quick-start)
20
- - [Documentation](#documentation)
21
- - [Modules Overview](#modules-overview)
22
- - [License](#license)
23
- - [Author](#author)
18
+ tauqeet-js is a TypeScript-first library for Islamic astronomy. It helps applications compute:
24
19
 
25
- ---
26
-
27
- ## Features
20
+ - Prayer times for major prayer events such as Fajr, Sunrise, Dhuhr, Asr, Maghrib, and Isha.
21
+ - Qibla direction and distance to Mecca.
22
+ - Moon phase, moon age, lunar events, and visibility heuristics.
23
+ - Hijri calendar conversions and calendar-method helpers.
24
+ - Solar alignment events relative to the Qibla bearing.
28
25
 
29
- | Module | Capability |
30
- |---|---|
31
- | **Prayers** | Fajr, Sunrise, Ḍuḥā, Dhuhr, Asr, Maghrib, Isha with 8 built-in calculation methods |
32
- | **Qibla** | Great-circle bearing, rhumb-line bearing, and distance to the Kaaba |
33
- | **Moon** | Phase, illumination, age, lunar events, crescent visibility (Odeh / Yallop / HMNAO) |
34
- | **Hijri** | Gregorian ↔ Hijri conversion via Civil, Conjunction, Visibility, or Umm al-Qura methods |
35
- | **Solar Alignment** | Times when the sun aligns with the Qibla direction (useful for compass calibration) |
26
+ The current release, v1.1.3, focuses on stable public exports, stronger validation, better diagnostics around timezone and formatting fallbacks, and measurable runtime improvements.
36
27
 
37
28
  ---
38
29
 
39
- ## Prerequisites
30
+ ## Installation
40
31
 
41
- - **Node.js** 18
42
- - **TypeScript** ≥ 5 (for source usage)
43
- - ESM-first; CJS bundle also provided.
32
+ Install with your preferred package manager:
44
33
 
45
- ---
34
+ ```bash
35
+ npm install tauqeet-js
36
+ ```
46
37
 
47
- ## Installation
38
+ ```bash
39
+ yarn add tauqeet-js
40
+ ```
48
41
 
49
42
  ```bash
50
- npm install tauqeet-js
43
+ pnpm add tauqeet-js
51
44
  ```
52
45
 
53
- > **Note:** The package is currently in active development for v1.2.0. See [CONTRIBUTING.md](CONTRIBUTING.md) for building from source.
46
+ The package ships ESM and CommonJS entry points, with per-module subpath exports for selective bundling.
54
47
 
55
48
  ---
56
49
 
57
50
  ## Quick Start
58
51
 
59
- ### Prayer Times
60
-
61
52
  ```ts
62
- import { calculatePrayerTimes, BUILT_IN_METHODS } from 'tauqeet-js';
53
+ import { calculatePrayerTimes } from 'tauqeet-js';
63
54
 
64
- // London, UK – today
65
55
  const result = calculatePrayerTimes({
66
56
  lat: 51.5074,
67
57
  long: -0.1278,
68
58
  timeZone: 'Europe/London',
69
- method: 'MWL', // Muslim World League
59
+ method: 'MWL',
70
60
  madhab: 'Shafi',
71
61
  });
72
62
 
73
- console.log(result.fajr.local); // e.g. "03:41 AM"
74
- console.log(result.dhuhr.local); // e.g. "01:05 PM"
75
- console.log(result.isha.local); // e.g. "10:52 PM"
76
- ```
77
-
78
- ### Qibla Direction
79
-
80
- ```ts
81
- import { getQiblaDirection } from 'tauqeet-js';
82
-
83
- const qibla = getQiblaDirection({ latitude: 51.5074, longitude: -0.1278 });
84
- console.log(`Bearing to Kaaba: ${qibla.bearing?.toFixed(2)}°`);
85
- console.log(`Distance: ${qibla.distanceKm.toFixed(0)} km`);
63
+ console.log(result.fajr.local);
64
+ console.log(result.dhuhr.local);
65
+ console.log(result.isha.local);
86
66
  ```
87
67
 
88
- ### Moon Phase
89
-
90
- ```ts
91
- import { getMoonPhase, getMoonAge } from 'tauqeet-js';
92
-
93
- const phase = getMoonPhase(new Date());
94
- console.log(`Phase: ${phase.phaseName}`); // e.g. "Waxing Crescent"
95
- console.log(`Illumination: ${(phase.illuminatedFraction * 100).toFixed(1)}%`);
96
-
97
- const age = getMoonAge(new Date());
98
- console.log(`Moon age: ${age.ageDays.toFixed(1)} days`);
99
- ```
68
+ For a more resilient integration, see [API.md](API.md) and [ERROR_HANDLING.md](ERROR_HANDLING.md).
100
69
 
101
- ### Hijri Date Conversion
70
+ ---
102
71
 
103
- ```ts
104
- import { toHijri, HijriMethod, HIJRI_MONTH_NAMES } from 'tauqeet-js';
72
+ ## Core Modules
105
73
 
106
- const hijri = toHijri(new Date(), HijriMethod.CIVIL);
107
- console.log(`${hijri.day} ${HIJRI_MONTH_NAMES[hijri.month - 1]} ${hijri.year} AH`);
108
- ```
74
+ | Module | What it provides |
75
+ |---|---|
76
+ | Prayers | Prayer-time calculations, formatting helpers, config validation, high-latitude handling |
77
+ | Qibla | Bearing and distance to the Kaaba |
78
+ | Moon | Phase, age, lunar events, crescent visibility heuristics |
79
+ | Hijri | Gregorian/Hijri conversion and calendar methods |
80
+ | Solar Alignment | Sun-at-Qibla alignment times |
109
81
 
110
82
  ---
111
83
 
112
- ## Documentation
113
-
114
- | File | Description |
115
- |---|---|
116
- | [API.md](API.md) | Complete API reference for all exported functions, types, and classes |
117
- | [USAGE.md](USAGE.md) | Practical code guides with real-world examples |
118
- | [MODULES.md](MODULES.md) | Architecture overview and module import guide |
119
- | [CONTRIBUTING.md](CONTRIBUTING.md) | Build, test, and contribution guidelines |
84
+ ## Documentation Set
120
85
 
121
- For the most up-to-date, interactive reference visit **[https://tauqeet-js.web.app](https://tauqeet-js.web.app)**.
86
+ - [API.md](API.md) comprehensive API reference for public exports.
87
+ - [ERROR_HANDLING.md](ERROR_HANDLING.md) — error classes, Result wrappers, and diagnostics.
88
+ - [CONFIGURATION.md](CONFIGURATION.md) — prayer configuration, methods, high-latitude strategies, and timezone hooks.
89
+ - [PERFORMANCE.md](PERFORMANCE.md) — ephemerides, models, optimisations, and benchmarks.
90
+ - [CHANGELOG.md](CHANGELOG.md) — release notes and migration guidance.
122
91
 
123
92
  ---
124
93
 
125
- ## Modules Overview
126
-
127
- ```
128
- tauqeet-js
129
- ├── prayers/ Prayer time engine (8 methods, high-latitude strategies)
130
- ├── qibla/ Qibla bearing & distance to Mecca
131
- ├── moon/ Moon phase, age, events, crescent visibility
132
- ├── hijri/ Gregorian ↔ Hijri calendar conversion
133
- ├── solar-alignment/ Sun-at-Qibla times
134
- └── astronomy/ Internal ephemeris (VSOP87, lunar theory, ΔT) — private
135
- ```
94
+ ## Highlights in v1.1.3
136
95
 
137
- See [MODULES.md](MODULES.md) for a detailed dependency graph and tree-shaking guide.
96
+ - Per-module exports for tree-shaking: [API.md](API.md)
97
+ - Optional fallback diagnostics for timezone and formatting issues
98
+ - More explicit validation for custom prayer angles
99
+ - Performance improvements in the astronomy hot path
100
+ - Improved error handling around timezone formatting and visibility calculations
138
101
 
139
102
  ---
140
103