swisseph 0.5.1 copy "swisseph: ^0.5.1" to clipboard
swisseph: ^0.5.1 copied to clipboard

Isolate-safe Dart FFI bindings to the Swiss Ephemeris C library.

0.5.1 #

  • Fix: sincos() shim in csrc/compat.c caused stack overflow on Android. At -O2, Clang folds sin(x) + cos(x) back into a sincos() call, creating infinite recursion when the caller is sincos. Add __attribute__((optnone)) to prevent the optimization. Also mark the symbol weak so the linker prefers Bionic's native sincos() when available (API 21+), using the shim only as a fallback.

0.5.0 #

  • Web: SE1 ephemeris file loading. The WASM build now includes Emscripten's MEMFS virtual filesystem (FILESYSTEM=1). New loadEpheFile(filename, bytes) method writes .se1 files into MEMFS from Dart; call setEphePath('/ephe') afterward to use them. This enables Swiss Ephemeris precision (~0.001 arcsecond) on web — previously web was locked to Moshier (~1 arcminute).
  • Fix: WASM module name case mismatch. DynamicLibrary.open() now passes explicit moduleName: 'SwissEph' so wasm_ffi finds the Emscripten factory at globalThis.SwissEph (PascalCase) instead of deriving swisseph (lowercase) from the URL path. Apps no longer need the window.swisseph = SwissEph alias workaround in index.html.
  • WASM assets rebuilt. JS glue grows from 31KB to 81KB (MEMFS implementation); WASM binary unchanged at 539KB.
  • Add browser test (dart test -p chrome) covering Moshier fallback and SE1 file loading with precision assertions.

0.4.7 #

  • Fix: getLibraryPath() could be overrun by one byte. The C function unconditionally writes a NUL at index AS_MAXCH (256) on its long-path branch, but the Dart wrapper only allocated 256 bytes. Allocate 257 to absorb the trailing NUL.
  • Fix: Android native builds now compile csrc/compat.c, which provides a sincos() shim required by Bionic. Previously the file existed but was not in the build hook's source list, so an Android build that needed the shim could fail at link/runtime. The shim no-ops outside __ANDROID__, so it is included unconditionally.
  • API: SwissEph.load([String? pathOrModule]) now accepts an optional path/module argument, plumbed through to both the native and web loaders. Web consumers can serve the WASM module under any URL; native consumers can override the .dart_tool/ scan.
  • API: CalcResult gains an optional warning field. When the C library populates serr on a non-fatal path (e.g. silent fallback from Swiss/JPL to Moshier when ephemeris files are missing), the message is now exposed instead of being discarded. Fully backwards compatible: existing callers see warning == null for clean calls.
  • Doc: README clarifies that the Dart native-assets pipeline is the supported production loading path; SwissEph.find() and the .dart_tool/ scan are dev-only conveniences.
  • Bind 5 additional Swiss Ephemeris C functions, raising coverage from 89/106 to 94/106:
    • cotransSp (swe_cotrans_sp) — coordinate transform with speed.
    • heliacalAngle (swe_heliacal_angle) — optimal arcus visionis.
    • topoArcusVisionis (swe_topo_arcus_visionis) — topocentric arc of vision for a body of given magnitude/position.
    • setAstroModels / getAstroModels (swe_set_astro_models / swe_get_astro_models) — override precession/nutation/Delta T model selection. Accompanied by seModelDeltat..seModelSidt index constants.
  • Adds CoTransSpResult, HeliacalAngleResult, and AstroModelsResult return types.
  • wasm/exports.txt updated with the 5 new symbols (and swe_calc_pctr, which was missing from the export list since 0.4.4). Pre-built assets/swisseph.{js,wasm} rebuilt via the Docker/Emscripten workflow so the new functions and calc_pctr are now callable on web as well as native.
  • The remaining 12 unbound C functions are deliberately skipped: 8 centiseconds utilities (degree equivalents are already exposed), 3 deprecated swe_fixstar* functions superseded by swe_fixstar2*, and the trivial swe_d2l cast.

0.4.6 #

  • Add optional starName parameter to riseTrans and riseTransTrueHor. When provided, writes the star name into the FFI buffer so the underlying swe_rise_trans computes rise/set times for fixed stars (pass body: 0).

0.4.5 #

  • Expand sefstars.txt from ~1,100 to ~2,900 star entries. The new catalog was generated from SIMBAD data via make_swe_stars.py and includes multiple name aliases per star (traditional name, Bayer designation, Flamsteed number, HIP number), ICRS coordinates with higher precision, and all constellation boundary stars needed for 13-sign true-sidereal zodiac systems. The original catalog is preserved as sefstars-original.txt.

0.4.4 #

  • Add calcPctr — planetocentric position calculation (swe_calc_pctr). Computes a body's position as seen from any other body (e.g. Jupiter-centric ephemerides, or asteroid-to-asteroid observations). Takes ET; signature matches calc with an additional centerBody parameter.

0.4.3 #

  • Fix Windows symbol exports: define MAKE_DLL during compilation so that swephexp.h decorates functions with __declspec(dllexport). Without this, the built DLL has no exported symbols and DynamicLibrary.lookup() fails at runtime.

0.4.2 #

  • Fix Windows build: skip -lm linker flag on Windows where math functions are part of the C runtime (ucrt). The m.lib file does not exist on Windows, causing LNK1181 fatal link errors during native asset compilation.

0.4.1 #

  • Rebuild WASM assets with correct file ownership for pub.dev publishing.

0.4.0 #

Cross-platform FFI architecture for native + web support.

New #

  • SwissEph.load() — async factory constructor, works on both native and web
  • WASM build infrastructure (wasm/) — Emscripten Docker build for web targets
  • Pre-built assets/swisseph.{js,wasm} — 88 exported functions, 512 KB

Changed #

  • All FFI types routed through conditional import barrel (ffi_types.dart)
  • Library loading extracted to conditional barrel (ffi_loader.dart)
  • swiss_eph.dart no longer imports dart:io — fully platform-agnostic
  • CharUint8 throughout all 88 bindings (web compatibility)
  • All methods migrated from calloc/free/try/finally to Arena-scoped using()
  • Custom UTF-8 string extensions (utf8_compat.dart) replacing package:ffi Utf8
  • Added wasm_ffi dependency for web platform support

Migration #

  • SwissEph(path) and SwissEph.find() still work on native (no changes needed)
  • For cross-platform code, use final swe = await SwissEph.load();

0.3.0 #

Breaking: All constants renamed to consistent camelCase.

  • Flag prefixes now properly capitalize sub-words: seflgSwiephseFlgSwiEph, seflgSpeedseFlgSpeed, etc.
  • Node/apsides: seNodbit*seNodBit*
  • Heliacal flags: seHelflag*seHelFlag*
  • Sidereal bits: seSidbit*seSidBit*
  • Eclipse visibility: seEclPartbegVisibleseEclPartBegVisible, etc.
  • Rise/set: seCalcMtransitseCalcMTransit, seBitGeoctrNoEclLatseBitGeoCtrNoEclLat
  • Stress tests excluded from default dart test run (use dart test -t stress)

0.2.0 #

Major API expansion — 15 methods to ~88 methods, covering nearly the full Swiss Ephemeris C API surface.

New methods #

Planetary calculations:

  • calc (ET variant of calcUt)
  • nodApsUt, nodAps — planetary nodes and apsides
  • getOrbitalElements — osculating orbital elements
  • orbitMaxMinTrueDistance — orbital distance extremes
  • phenoUt, pheno — phase angle, elongation, magnitude

Fixed stars:

  • fixstar2Ut, fixstar2 — fixed star positions
  • fixstar2Mag — visual magnitude lookup

Houses (expanded):

  • housesEx — house cusps with extra flags
  • housesEx2 — house cusps with speeds
  • housesArmc — houses from ARMC (no date needed)
  • housesArmcEx2 — houses from ARMC with speeds
  • housePos — house position of a body
  • gauquelinSector — Gauquelin sector position

Eclipses:

  • solEclipseWhenLoc, solEclipseWhenGlob — find solar eclipses
  • solEclipseHow — solar eclipse attributes at a location
  • solEclipseWhere — geographic location of greatest eclipse
  • lunEclipseWhen, lunEclipseWhenLoc — find lunar eclipses
  • lunEclipseHow — lunar eclipse attributes
  • lunOccultWhenLoc, lunOccultWhenGlob — planetary occultations
  • lunOccultWhere — geographic location of greatest occultation

Crossings:

  • solCrossUt, solCross — Sun crossing a longitude
  • moonCrossUt, moonCross — Moon crossing a longitude
  • moonCrossNodeUt, moonCrossNode — Moon crossing its own node
  • helioCrossUt, helioCross — heliocentric longitude crossing

Date/time (expanded):

  • utcToJd, jdToUtc, jdetToUtc — UTC/JD conversions
  • utcTimeZone — UTC to local time zone
  • dayOfWeek — day of week for a Julian Day
  • deltat, deltatEx — Delta T (ET minus UT)
  • timeEqu — equation of time
  • sidTime, sidTime0 — sidereal time
  • lmtToLat, latToLmt — local mean/apparent time conversion

Coordinate transforms:

  • azAlt — ecliptic/equatorial to horizon
  • azAltRev — horizon to ecliptic/equatorial
  • cotrans — ecliptic/equatorial coordinate transform
  • refrac, refracExtended — atmospheric refraction
  • splitDeg — decimal degrees to d/m/s
  • radNorm, degMidp, radMidp, difDegn, difDeg2n — degree/radian math

Rise/set (expanded):

  • riseTransTrueHor — rise/set with true horizon

Heliacal:

  • heliacalUt — heliacal rising/setting
  • heliacalPhenoUt — heliacal phenomenon data
  • visLimitMag — limiting visual magnitude

Configuration (expanded):

  • setJplFile — set JPL ephemeris file
  • getLibraryPath — path to loaded shared library
  • getCurrentFileData — loaded data file info
  • setInterpolateNut — nutation interpolation toggle
  • setLapseRate — atmospheric lapse rate
  • setDeltaTUserdef — override Delta T
  • setTidAcc, getTidAcc — tidal acceleration
  • getAyanamsa, getAyanamsaEx — ET ayanamsa variants

Bug fixes (from external code review) #

  • Gauquelin cusp truncation — house methods now return all 37 cusps for Gauquelin sectors (hsys='G'), not just 13. Affected: houses, housesEx, housesEx2, housesArmc, housesArmcEx2.
  • Crossing function error detectionsolCross*, moonCross*, and moonCrossNode* now check result < jdStart (matching the C error sentinel) instead of result < 0, which was a no-op for modern dates.
  • Missing error throwshouses(), housesEx(), housesArmc() now throw SweException on failure (consistent with housesEx2).
  • FixstarResult returnFlagfixstar2Ut and fixstar2 now populate the returnFlag field.
  • gauquelinSector starName — added optional starName parameter for fixed-star sector calculations.
  • Constant and doc fixes — added hsysGauquelin constant, clarified seEcl2hor/seHor2ecl docs (direction comes from function, not flag), documented SplitDegResult.sign zodiacal behavior, documented RiseTransResult circumpolar behavior (returnFlag -2).

New types #

HouseResultEx, FixstarResult, MoonNodeCrossResult, JulianDayPair, DateTimeResult, FileDataResult, NodeApsResult, OrbitalElementsResult, OrbitDistanceResult, PhenoResult, SolarEclipseLocalResult, SolarEclipseGlobalResult, SolarEclipseAttrResult, EclipseWhereResult, LunarEclipseGlobalResult, LunarEclipseLocalResult, LunarEclipseAttrResult, AzAltResult, AzAltRevResult, CoTransResult, RefracResult, HeliacalResult, HeliacalPhenoResult, VisLimitResult, AtmoConditions, ObserverConditions.

Other #

  • FFI bindings expanded from 16 to 75.
  • Constants expanded with eclipse flags, node/apsides flags, heliacal event types, sidereal mode bits, split degree flags, and refraction flags.

0.1.2 #

  • Fix Android/NDK linking: link libm explicitly via libraries: ['m'] in the build hook. Desktop glibc links libm implicitly; Android's Bionic does not, causing dlopen failures for math symbols (sin, cos, sincos, etc.).
  • Document ephemeris file discovery for package consumers: use Isolate.resolvePackageUri to locate the bundled ephe/ directory at runtime.

0.1.1 #

  • Bundle Swiss Ephemeris data files in ephe/ — sub-arcsecond precision out of the box with no extra downloads.
  • Included: planets, Moon, main asteroids (Ceres, Pallas, Juno, Vesta, Chiron, Pholus), fixed stars, and Hygiea.
  • Coverage: ~5400 BC – 5400 AD (~10,800 years).

0.1.0 #

  • Initial release.
  • 15 methods: calcUt, houses, julday, revjul, riseTrans, getAyanamsaUt, getAyanamsaExUt, getAyanamsaName, setSidMode, setEphePath, setTopo, getPlanetName, houseName, degnorm, close, version.
  • All 47 standard ayanamsa modes.
  • 11 house systems.
  • Moshier, Swiss Ephemeris, and JPL ephemeris support.
  • Tropical, sidereal, heliocentric, barycentric, and equatorial coordinates.
  • Native asset build hook — C source compiles automatically on dart pub get.
  • Isolate-safe via unique .so copies per isolate.
  • 26 unit tests + 545-value cross-validation against pyswisseph.
0
likes
150
points
415
downloads

Documentation

API reference

Publisher

verified publisherninthhouse.studio

Weekly Downloads

Isolate-safe Dart FFI bindings to the Swiss Ephemeris C library.

Repository (GitLab)
View/report issues

License

AGPL-3.0 (license)

Dependencies

code_assets, ffi, hooks, logging, native_toolchain_c, wasm_ffi

More

Packages that depend on swisseph