Refactor: use nrel_spa package instead of bundled SPA

Replace the 1280-line bundled SPA implementation with a dependency on
the nrel_spa package. SpaResult and SpaAnglesResult are now re-exported
from nrel_spa for backwards compatibility. All 24 tests pass unchanged.
This commit is contained in:
Aric Camarata 2026-03-08 13:10:16 -04:00
parent 9167d86c7b
commit 971022734e
7 changed files with 19 additions and 1322 deletions

View file

@ -2,6 +2,13 @@
All notable changes to this project will be documented in this file.
## [Unreleased]
### Changed
- Replaced bundled SPA implementation with the `nrel_spa` package dependency
- Removed `SpaResult` and `SpaAnglesResult` from local types (now re-exported from `nrel_spa`)
## [1.0.0] - 2026-03-08
### Added

View file

@ -4,7 +4,7 @@
[![CI](https://github.com/acamarata/pray-calc-dart/actions/workflows/ci.yml/badge.svg)](https://github.com/acamarata/pray-calc-dart/actions/workflows/ci.yml)
[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
Islamic prayer times for Dart and Flutter. Pure Dart port of [pray-calc](https://github.com/acamarata/pray-calc), implementing the NREL Solar Position Algorithm, MCW seasonal model, and dynamic twilight angles. Zero dependencies.
Islamic prayer times for Dart and Flutter. Pure Dart port of [pray-calc](https://github.com/acamarata/pray-calc), implementing the MCW seasonal model and dynamic twilight angles. Uses [nrel_spa](https://github.com/acamarata/nrel-spa-dart) for the NREL Solar Position Algorithm.
## Installation
@ -87,7 +87,7 @@ Result: approximately 18 degrees at the equator, approximately 12-14 degrees at
## Compatibility
Dart SDK 3.7.0+. Works in Flutter (iOS, Android, Web, Desktop), Dart CLI, and server-side Dart. Zero external dependencies.
Dart SDK 3.7.0+. Works in Flutter (iOS, Android, Web, Desktop), Dart CLI, and server-side Dart. Single dependency: [nrel_spa](https://pub.dev/packages/nrel_spa).
## Related

View file

@ -12,4 +12,4 @@ export 'src/solar_ephemeris.dart';
export 'src/msc.dart';
export 'src/asr.dart';
export 'src/qiyam.dart';
export 'src/spa.dart' show getSpa;
export 'package:nrel_spa/nrel_spa.dart' show getSpa, SpaResult, SpaAnglesResult;

View file

@ -4,8 +4,9 @@
/// angle algorithm. Times are in local time as determined by the UTC offset.
library;
import 'package:nrel_spa/nrel_spa.dart';
import 'types.dart';
import 'spa.dart';
import 'solar_ephemeris.dart';
import 'angles.dart';
import 'asr.dart';

File diff suppressed because it is too large Load diff

View file

@ -103,40 +103,4 @@ class SolarEphemeris {
});
}
/// SPA result from the NREL Solar Position Algorithm.
class SpaResult {
/// Topocentric zenith angle in degrees.
final double zenith;
/// Topocentric azimuth angle, eastward from north, in degrees.
final double azimuth;
/// Local sunrise time as fractional hours (NaN if polar).
final double sunrise;
/// Local sun transit time (solar noon) as fractional hours.
final double solarNoon;
/// Local sunset time as fractional hours (NaN if polar).
final double sunset;
/// Custom zenith angle results (one per angle in the input list).
final List<SpaAnglesResult> angles;
const SpaResult({
required this.zenith,
required this.azimuth,
required this.sunrise,
required this.solarNoon,
required this.sunset,
this.angles = const [],
});
}
/// Sunrise/sunset pair for a custom zenith angle.
class SpaAnglesResult {
final double sunrise;
final double sunset;
const SpaAnglesResult({required this.sunrise, required this.sunset});
}
// SpaResult and SpaAnglesResult are provided by the nrel_spa package.

View file

@ -1,8 +1,8 @@
name: pray_calc_dart
description: >
Islamic prayer times for Dart and Flutter. Pure Dart port of the pray-calc
library implementing the NREL Solar Position Algorithm, MCW seasonal model,
and dynamic twilight angles. Zero dependencies.
library implementing the MCW seasonal model and dynamic twilight angles.
Uses nrel_spa for the NREL Solar Position Algorithm.
version: 1.0.0
repository: https://github.com/acamarata/pray-calc-dart
issue_tracker: https://github.com/acamarata/pray-calc-dart/issues
@ -16,6 +16,10 @@ topics:
environment:
sdk: ^3.7.0
dependencies:
nrel_spa:
path: ../nrel-spa-dart
dev_dependencies:
lints: ^5.0.0
test: ^1.25.8