@swisseph/node 1.0.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,193 @@
1
+ /**
2
+ * Swiss Ephemeris for Node.js - Modern TypeScript API
3
+ *
4
+ * This module provides a modern, type-safe API for Swiss Ephemeris astronomical calculations.
5
+ * It wraps the native C library with developer-friendly TypeScript interfaces.
6
+ */
7
+ import { CalendarType, CelestialBody, HouseSystem, CalculationFlagInput, EclipseTypeFlagInput, PlanetaryPosition, HouseData, LunarEclipse, SolarEclipse, ExtendedDateTime } from '@swisseph/core';
8
+ /**
9
+ * Set the directory path for ephemeris files
10
+ *
11
+ * By default, @swisseph/node uses bundled ephemeris files included with the package.
12
+ * Call this function only if you want to use custom ephemeris files.
13
+ *
14
+ * @param path - Directory path containing ephemeris files, or null/undefined for bundled files
15
+ *
16
+ * @example
17
+ * // Use custom ephemeris files
18
+ * setEphemerisPath('/path/to/custom/ephemeris');
19
+ *
20
+ * // Revert to bundled files
21
+ * setEphemerisPath(null);
22
+ */
23
+ export declare function setEphemerisPath(path?: string | null): void;
24
+ /**
25
+ * Calculate Julian day number from calendar date
26
+ *
27
+ * The Julian day number is a continuous count of days since the beginning
28
+ * of the Julian period (January 1, 4713 BCE, proleptic Julian calendar).
29
+ *
30
+ * @param year - Year (negative for BCE)
31
+ * @param month - Month (1-12)
32
+ * @param day - Day (1-31)
33
+ * @param hour - Hour as decimal (0.0-23.999...)
34
+ * @param calendarType - Calendar system (default: Gregorian)
35
+ * @returns Julian day number
36
+ *
37
+ * @example
38
+ * const jd = julianDay(2007, 3, 3);
39
+ * console.log(jd); // 2454162.5
40
+ *
41
+ * const jdWithTime = julianDay(2007, 3, 3, 14.5);
42
+ * console.log(jdWithTime); // 2454163.104166667
43
+ */
44
+ export declare function julianDay(year: number, month: number, day: number, hour?: number, calendarType?: CalendarType): number;
45
+ /**
46
+ * Convert Julian day number to calendar date
47
+ *
48
+ * @param jd - Julian day number
49
+ * @param calendarType - Calendar system (default: Gregorian)
50
+ * @returns DateTime object with year, month, day, and hour
51
+ *
52
+ * @example
53
+ * const date = julianDayToDate(2454162.5);
54
+ * console.log(date);
55
+ * // { year: 2007, month: 3, day: 3, hour: 0, calendarType: CalendarType.Gregorian }
56
+ *
57
+ * console.log(date.toString());
58
+ * // "2007-03-03 0.000000 hours (Gregorian)"
59
+ */
60
+ export declare function julianDayToDate(jd: number, calendarType?: CalendarType): ExtendedDateTime;
61
+ /**
62
+ * Calculate planetary positions
63
+ *
64
+ * This is the main function for calculating positions of planets, asteroids,
65
+ * and other celestial bodies.
66
+ *
67
+ * @param julianDay - Julian day number in Universal Time
68
+ * @param body - Celestial body to calculate (use Planet, Asteroid, etc. enums)
69
+ * @param flags - Calculation flags (default: SwissEphemeris with speed)
70
+ * @returns PlanetaryPosition object with longitude, latitude, distance, and speeds
71
+ *
72
+ * @example
73
+ * // Calculate Sun position
74
+ * const sun = calculatePosition(jd, Planet.Sun);
75
+ * console.log(`Sun longitude: ${sun.longitude}°`);
76
+ *
77
+ * // Calculate with specific flags
78
+ * const moon = calculatePosition(
79
+ * jd,
80
+ * Planet.Moon,
81
+ * CalculationFlag.MoshierEphemeris | CalculationFlag.Speed
82
+ * );
83
+ *
84
+ * // Using flag builder
85
+ * import { CalculationFlags } from 'swisseph';
86
+ * const flags = CalculationFlags.from(
87
+ * CalculationFlag.SwissEphemeris,
88
+ * CalculationFlag.Speed,
89
+ * CalculationFlag.Equatorial
90
+ * );
91
+ * const mars = calculatePosition(jd, Planet.Mars, flags);
92
+ */
93
+ export declare function calculatePosition(julianDay: number, body: CelestialBody, flags?: CalculationFlagInput): PlanetaryPosition;
94
+ /**
95
+ * Calculate house cusps and angles
96
+ *
97
+ * Houses divide the ecliptic into 12 sections based on the observer's
98
+ * location and the time of day.
99
+ *
100
+ * @param julianDay - Julian day number in Universal Time
101
+ * @param latitude - Geographic latitude (positive = north, negative = south)
102
+ * @param longitude - Geographic longitude (positive = east, negative = west)
103
+ * @param houseSystem - House system to use (default: Placidus)
104
+ * @returns HouseData object with cusps and angles
105
+ *
106
+ * @example
107
+ * // Calculate houses for New York
108
+ * const houses = calculateHouses(jd, 40.7128, -74.0060, HouseSystem.Placidus);
109
+ * console.log(`Ascendant: ${houses.ascendant}°`);
110
+ * console.log(`MC: ${houses.mc}°`);
111
+ *
112
+ * // Access house cusps
113
+ * for (let i = 1; i <= 12; i++) {
114
+ * console.log(`House ${i}: ${houses.cusps[i]}°`);
115
+ * }
116
+ *
117
+ * // Try different house system
118
+ * const wholeSigns = calculateHouses(jd, 40.7128, -74.0060, HouseSystem.WholeSign);
119
+ */
120
+ export declare function calculateHouses(julianDay: number, latitude: number, longitude: number, houseSystem?: HouseSystem): HouseData;
121
+ /**
122
+ * Find the next lunar eclipse
123
+ *
124
+ * Searches for the next lunar eclipse after the given Julian day.
125
+ *
126
+ * @param startJulianDay - Julian day to start search from
127
+ * @param flags - Calculation flags (default: SwissEphemeris)
128
+ * @param eclipseType - Filter by eclipse type (0 = all types)
129
+ * @param backward - Search backward in time if true
130
+ * @returns LunarEclipse object with times and convenience methods
131
+ *
132
+ * @example
133
+ * // Find next lunar eclipse
134
+ * const jd = julianDay(2025, 1, 1);
135
+ * const eclipse = findNextLunarEclipse(jd);
136
+ *
137
+ * console.log(`Eclipse maximum: ${julianDayToDate(eclipse.maximum)}`);
138
+ * console.log(`Is total: ${eclipse.isTotal()}`);
139
+ * console.log(`Totality duration: ${eclipse.getTotalityDuration()} hours`);
140
+ *
141
+ * // Find previous lunar eclipse
142
+ * const previousEclipse = findNextLunarEclipse(jd, undefined, 0, true);
143
+ */
144
+ export declare function findNextLunarEclipse(startJulianDay: number, flags?: CalculationFlagInput, eclipseType?: EclipseTypeFlagInput, backward?: boolean): LunarEclipse;
145
+ /**
146
+ * Find the next solar eclipse globally
147
+ *
148
+ * Searches for the next solar eclipse visible anywhere on Earth.
149
+ *
150
+ * @param startJulianDay - Julian day to start search from
151
+ * @param flags - Calculation flags (default: SwissEphemeris)
152
+ * @param eclipseType - Filter by eclipse type (0 = all types)
153
+ * @param backward - Search backward in time if true
154
+ * @returns SolarEclipse object with times and convenience methods
155
+ *
156
+ * @example
157
+ * // Find next solar eclipse
158
+ * const jd = julianDay(2025, 1, 1);
159
+ * const eclipse = findNextSolarEclipse(jd);
160
+ *
161
+ * console.log(`Eclipse maximum: ${julianDayToDate(eclipse.maximum)}`);
162
+ * console.log(`Is total: ${eclipse.isTotal()}`);
163
+ * console.log(`Is annular: ${eclipse.isAnnular()}`);
164
+ * console.log(`Is central: ${eclipse.isCentral()}`);
165
+ */
166
+ export declare function findNextSolarEclipse(startJulianDay: number, flags?: CalculationFlagInput, eclipseType?: EclipseTypeFlagInput, backward?: boolean): SolarEclipse;
167
+ /**
168
+ * Get the name of a celestial body
169
+ *
170
+ * @param body - Celestial body identifier
171
+ * @returns Name of the body as a string
172
+ *
173
+ * @example
174
+ * const name = getCelestialBodyName(Planet.Mars);
175
+ * console.log(name); // "Mars"
176
+ *
177
+ * const sunName = getCelestialBodyName(Planet.Sun);
178
+ * console.log(sunName); // "Sun"
179
+ */
180
+ export declare function getCelestialBodyName(body: CelestialBody): string;
181
+ /**
182
+ * Close Swiss Ephemeris and free resources
183
+ *
184
+ * Call this function when you're done using Swiss Ephemeris to free
185
+ * allocated resources.
186
+ *
187
+ * @example
188
+ * // After all calculations are done
189
+ * close();
190
+ */
191
+ export declare function close(): void;
192
+ export * from '@swisseph/core';
193
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,YAAY,EAEZ,aAAa,EACb,WAAW,EAEX,oBAAoB,EACpB,oBAAoB,EACpB,iBAAiB,EACjB,SAAS,EACT,YAAY,EACZ,YAAY,EAEZ,gBAAgB,EAQjB,MAAM,gBAAgB,CAAC;AAkCxB;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAU3D;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,SAAS,CACvB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,EACX,IAAI,GAAE,MAAU,EAChB,YAAY,GAAE,YAAqC,GAClD,MAAM,CAER;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,eAAe,CAC7B,EAAE,EAAE,MAAM,EACV,YAAY,GAAE,YAAqC,GAClD,gBAAgB,CAGlB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,aAAa,EACnB,KAAK,GAAE,oBAAmE,GACzE,iBAAiB,CAenB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,eAAe,CAC7B,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,WAAW,GAAE,WAAkC,GAC9C,SAAS,CAmBX;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,oBAAoB,CAClC,cAAc,EAAE,MAAM,EACtB,KAAK,GAAE,oBAAqD,EAC5D,WAAW,GAAE,oBAAwB,EACrC,QAAQ,GAAE,OAAe,GACxB,YAAY,CAwBd;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,oBAAoB,CAClC,cAAc,EAAE,MAAM,EACtB,KAAK,GAAE,oBAAqD,EAC5D,WAAW,GAAE,oBAAwB,EACrC,QAAQ,GAAE,OAAe,GACxB,YAAY,CAwBd;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,aAAa,GAAG,MAAM,CAEhE;AAED;;;;;;;;;GASG;AACH,wBAAgB,KAAK,IAAI,IAAI,CAE5B;AAGD,cAAc,gBAAgB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,343 @@
1
+ "use strict";
2
+ /**
3
+ * Swiss Ephemeris for Node.js - Modern TypeScript API
4
+ *
5
+ * This module provides a modern, type-safe API for Swiss Ephemeris astronomical calculations.
6
+ * It wraps the native C library with developer-friendly TypeScript interfaces.
7
+ */
8
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
+ if (k2 === undefined) k2 = k;
10
+ var desc = Object.getOwnPropertyDescriptor(m, k);
11
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
12
+ desc = { enumerable: true, get: function() { return m[k]; } };
13
+ }
14
+ Object.defineProperty(o, k2, desc);
15
+ }) : (function(o, m, k, k2) {
16
+ if (k2 === undefined) k2 = k;
17
+ o[k2] = m[k];
18
+ }));
19
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
20
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
21
+ }) : function(o, v) {
22
+ o["default"] = v;
23
+ });
24
+ var __importStar = (this && this.__importStar) || (function () {
25
+ var ownKeys = function(o) {
26
+ ownKeys = Object.getOwnPropertyNames || function (o) {
27
+ var ar = [];
28
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
29
+ return ar;
30
+ };
31
+ return ownKeys(o);
32
+ };
33
+ return function (mod) {
34
+ if (mod && mod.__esModule) return mod;
35
+ var result = {};
36
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
37
+ __setModuleDefault(result, mod);
38
+ return result;
39
+ };
40
+ })();
41
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
42
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
43
+ };
44
+ Object.defineProperty(exports, "__esModule", { value: true });
45
+ exports.setEphemerisPath = setEphemerisPath;
46
+ exports.julianDay = julianDay;
47
+ exports.julianDayToDate = julianDayToDate;
48
+ exports.calculatePosition = calculatePosition;
49
+ exports.calculateHouses = calculateHouses;
50
+ exports.findNextLunarEclipse = findNextLunarEclipse;
51
+ exports.findNextSolarEclipse = findNextSolarEclipse;
52
+ exports.getCelestialBodyName = getCelestialBodyName;
53
+ exports.close = close;
54
+ const core_1 = require("@swisseph/core");
55
+ const path = __importStar(require("path"));
56
+ // Import the native addon
57
+ const binding = require('../build/Release/swisseph.node');
58
+ // Track if ephemeris path has been explicitly set
59
+ let ephemerisPathSet = false;
60
+ /**
61
+ * Get the path to bundled ephemeris files
62
+ * @internal
63
+ */
64
+ function getBundledEphemerisPath() {
65
+ // The ephemeris files are bundled in the package at ../ephemeris
66
+ return path.join(__dirname, '..', 'ephemeris');
67
+ }
68
+ /**
69
+ * Initialize ephemeris with bundled files if not already set and using Swiss Ephemeris
70
+ * @internal
71
+ */
72
+ function ensureEphemerisInitialized(flags) {
73
+ // Only auto-load if using Swiss Ephemeris (not Moshier) and path not explicitly set
74
+ const usingMoshier = (flags & core_1.CalculationFlag.MoshierEphemeris) !== 0;
75
+ if (!ephemerisPathSet && !usingMoshier) {
76
+ const bundledPath = getBundledEphemerisPath();
77
+ binding.set_ephe_path(bundledPath);
78
+ ephemerisPathSet = true;
79
+ }
80
+ }
81
+ /**
82
+ * Set the directory path for ephemeris files
83
+ *
84
+ * By default, @swisseph/node uses bundled ephemeris files included with the package.
85
+ * Call this function only if you want to use custom ephemeris files.
86
+ *
87
+ * @param path - Directory path containing ephemeris files, or null/undefined for bundled files
88
+ *
89
+ * @example
90
+ * // Use custom ephemeris files
91
+ * setEphemerisPath('/path/to/custom/ephemeris');
92
+ *
93
+ * // Revert to bundled files
94
+ * setEphemerisPath(null);
95
+ */
96
+ function setEphemerisPath(path) {
97
+ if (path === null || path === undefined) {
98
+ // Use bundled ephemeris
99
+ const bundledPath = getBundledEphemerisPath();
100
+ binding.set_ephe_path(bundledPath);
101
+ }
102
+ else {
103
+ // Use custom path
104
+ binding.set_ephe_path(path);
105
+ }
106
+ ephemerisPathSet = true;
107
+ }
108
+ /**
109
+ * Calculate Julian day number from calendar date
110
+ *
111
+ * The Julian day number is a continuous count of days since the beginning
112
+ * of the Julian period (January 1, 4713 BCE, proleptic Julian calendar).
113
+ *
114
+ * @param year - Year (negative for BCE)
115
+ * @param month - Month (1-12)
116
+ * @param day - Day (1-31)
117
+ * @param hour - Hour as decimal (0.0-23.999...)
118
+ * @param calendarType - Calendar system (default: Gregorian)
119
+ * @returns Julian day number
120
+ *
121
+ * @example
122
+ * const jd = julianDay(2007, 3, 3);
123
+ * console.log(jd); // 2454162.5
124
+ *
125
+ * const jdWithTime = julianDay(2007, 3, 3, 14.5);
126
+ * console.log(jdWithTime); // 2454163.104166667
127
+ */
128
+ function julianDay(year, month, day, hour = 0, calendarType = core_1.CalendarType.Gregorian) {
129
+ return binding.julday(year, month, day, hour, calendarType);
130
+ }
131
+ /**
132
+ * Convert Julian day number to calendar date
133
+ *
134
+ * @param jd - Julian day number
135
+ * @param calendarType - Calendar system (default: Gregorian)
136
+ * @returns DateTime object with year, month, day, and hour
137
+ *
138
+ * @example
139
+ * const date = julianDayToDate(2454162.5);
140
+ * console.log(date);
141
+ * // { year: 2007, month: 3, day: 3, hour: 0, calendarType: CalendarType.Gregorian }
142
+ *
143
+ * console.log(date.toString());
144
+ * // "2007-03-03 0.000000 hours (Gregorian)"
145
+ */
146
+ function julianDayToDate(jd, calendarType = core_1.CalendarType.Gregorian) {
147
+ const result = binding.revjul(jd, calendarType);
148
+ return new core_1.DateTimeImpl(result[0], result[1], result[2], result[3], calendarType);
149
+ }
150
+ /**
151
+ * Calculate planetary positions
152
+ *
153
+ * This is the main function for calculating positions of planets, asteroids,
154
+ * and other celestial bodies.
155
+ *
156
+ * @param julianDay - Julian day number in Universal Time
157
+ * @param body - Celestial body to calculate (use Planet, Asteroid, etc. enums)
158
+ * @param flags - Calculation flags (default: SwissEphemeris with speed)
159
+ * @returns PlanetaryPosition object with longitude, latitude, distance, and speeds
160
+ *
161
+ * @example
162
+ * // Calculate Sun position
163
+ * const sun = calculatePosition(jd, Planet.Sun);
164
+ * console.log(`Sun longitude: ${sun.longitude}°`);
165
+ *
166
+ * // Calculate with specific flags
167
+ * const moon = calculatePosition(
168
+ * jd,
169
+ * Planet.Moon,
170
+ * CalculationFlag.MoshierEphemeris | CalculationFlag.Speed
171
+ * );
172
+ *
173
+ * // Using flag builder
174
+ * import { CalculationFlags } from 'swisseph';
175
+ * const flags = CalculationFlags.from(
176
+ * CalculationFlag.SwissEphemeris,
177
+ * CalculationFlag.Speed,
178
+ * CalculationFlag.Equatorial
179
+ * );
180
+ * const mars = calculatePosition(jd, Planet.Mars, flags);
181
+ */
182
+ function calculatePosition(julianDay, body, flags = core_1.CommonCalculationFlags.DefaultSwissEphemeris) {
183
+ const normalizedFlags = (0, core_1.normalizeFlags)(flags);
184
+ ensureEphemerisInitialized(normalizedFlags);
185
+ const result = binding.calc_ut(julianDay, body, normalizedFlags);
186
+ const [xx, retFlags] = result;
187
+ return {
188
+ longitude: xx[0],
189
+ latitude: xx[1],
190
+ distance: xx[2],
191
+ longitudeSpeed: xx[3],
192
+ latitudeSpeed: xx[4],
193
+ distanceSpeed: xx[5],
194
+ flags: retFlags,
195
+ };
196
+ }
197
+ /**
198
+ * Calculate house cusps and angles
199
+ *
200
+ * Houses divide the ecliptic into 12 sections based on the observer's
201
+ * location and the time of day.
202
+ *
203
+ * @param julianDay - Julian day number in Universal Time
204
+ * @param latitude - Geographic latitude (positive = north, negative = south)
205
+ * @param longitude - Geographic longitude (positive = east, negative = west)
206
+ * @param houseSystem - House system to use (default: Placidus)
207
+ * @returns HouseData object with cusps and angles
208
+ *
209
+ * @example
210
+ * // Calculate houses for New York
211
+ * const houses = calculateHouses(jd, 40.7128, -74.0060, HouseSystem.Placidus);
212
+ * console.log(`Ascendant: ${houses.ascendant}°`);
213
+ * console.log(`MC: ${houses.mc}°`);
214
+ *
215
+ * // Access house cusps
216
+ * for (let i = 1; i <= 12; i++) {
217
+ * console.log(`House ${i}: ${houses.cusps[i]}°`);
218
+ * }
219
+ *
220
+ * // Try different house system
221
+ * const wholeSigns = calculateHouses(jd, 40.7128, -74.0060, HouseSystem.WholeSign);
222
+ */
223
+ function calculateHouses(julianDay, latitude, longitude, houseSystem = core_1.HouseSystem.Placidus) {
224
+ const result = binding.houses(julianDay, latitude, longitude, houseSystem);
225
+ const [cusps, ascmc] = result;
226
+ return {
227
+ cusps,
228
+ ascendant: ascmc[core_1.HousePoint.Ascendant],
229
+ mc: ascmc[core_1.HousePoint.MC],
230
+ armc: ascmc[core_1.HousePoint.ARMC],
231
+ vertex: ascmc[core_1.HousePoint.Vertex],
232
+ equatorialAscendant: ascmc[core_1.HousePoint.EquatorialAscendant],
233
+ coAscendant1: ascmc[core_1.HousePoint.CoAscendant1],
234
+ coAscendant2: ascmc[core_1.HousePoint.CoAscendant2],
235
+ polarAscendant: ascmc[core_1.HousePoint.PolarAscendant],
236
+ houseSystem,
237
+ };
238
+ }
239
+ /**
240
+ * Find the next lunar eclipse
241
+ *
242
+ * Searches for the next lunar eclipse after the given Julian day.
243
+ *
244
+ * @param startJulianDay - Julian day to start search from
245
+ * @param flags - Calculation flags (default: SwissEphemeris)
246
+ * @param eclipseType - Filter by eclipse type (0 = all types)
247
+ * @param backward - Search backward in time if true
248
+ * @returns LunarEclipse object with times and convenience methods
249
+ *
250
+ * @example
251
+ * // Find next lunar eclipse
252
+ * const jd = julianDay(2025, 1, 1);
253
+ * const eclipse = findNextLunarEclipse(jd);
254
+ *
255
+ * console.log(`Eclipse maximum: ${julianDayToDate(eclipse.maximum)}`);
256
+ * console.log(`Is total: ${eclipse.isTotal()}`);
257
+ * console.log(`Totality duration: ${eclipse.getTotalityDuration()} hours`);
258
+ *
259
+ * // Find previous lunar eclipse
260
+ * const previousEclipse = findNextLunarEclipse(jd, undefined, 0, true);
261
+ */
262
+ function findNextLunarEclipse(startJulianDay, flags = core_1.CalculationFlag.SwissEphemeris, eclipseType = 0, backward = false) {
263
+ const normalizedFlags = (0, core_1.normalizeFlags)(flags);
264
+ ensureEphemerisInitialized(normalizedFlags);
265
+ const normalizedEclipseType = (0, core_1.normalizeEclipseTypes)(eclipseType);
266
+ const result = binding.lun_eclipse_when(startJulianDay, normalizedFlags, normalizedEclipseType, backward ? 1 : 0);
267
+ const [retFlag, tret] = result;
268
+ return new core_1.LunarEclipseImpl(retFlag, tret[0], // maximum
269
+ tret[1], // partial begin
270
+ tret[2], // partial end
271
+ tret[3], // total begin
272
+ tret[4], // total end
273
+ tret[5], // penumbral begin
274
+ tret[6] // penumbral end
275
+ );
276
+ }
277
+ /**
278
+ * Find the next solar eclipse globally
279
+ *
280
+ * Searches for the next solar eclipse visible anywhere on Earth.
281
+ *
282
+ * @param startJulianDay - Julian day to start search from
283
+ * @param flags - Calculation flags (default: SwissEphemeris)
284
+ * @param eclipseType - Filter by eclipse type (0 = all types)
285
+ * @param backward - Search backward in time if true
286
+ * @returns SolarEclipse object with times and convenience methods
287
+ *
288
+ * @example
289
+ * // Find next solar eclipse
290
+ * const jd = julianDay(2025, 1, 1);
291
+ * const eclipse = findNextSolarEclipse(jd);
292
+ *
293
+ * console.log(`Eclipse maximum: ${julianDayToDate(eclipse.maximum)}`);
294
+ * console.log(`Is total: ${eclipse.isTotal()}`);
295
+ * console.log(`Is annular: ${eclipse.isAnnular()}`);
296
+ * console.log(`Is central: ${eclipse.isCentral()}`);
297
+ */
298
+ function findNextSolarEclipse(startJulianDay, flags = core_1.CalculationFlag.SwissEphemeris, eclipseType = 0, backward = false) {
299
+ const normalizedFlags = (0, core_1.normalizeFlags)(flags);
300
+ ensureEphemerisInitialized(normalizedFlags);
301
+ const normalizedEclipseType = (0, core_1.normalizeEclipseTypes)(eclipseType);
302
+ const result = binding.sol_eclipse_when_glob(startJulianDay, normalizedFlags, normalizedEclipseType, backward ? 1 : 0);
303
+ const [retFlag, tret] = result;
304
+ return new core_1.SolarEclipseImpl(retFlag, tret[0], // maximum
305
+ tret[1], // partial begin
306
+ tret[2], // partial end
307
+ tret[3], // central begin
308
+ tret[4], // central end
309
+ tret[5], // center line begin
310
+ tret[6] // center line end
311
+ );
312
+ }
313
+ /**
314
+ * Get the name of a celestial body
315
+ *
316
+ * @param body - Celestial body identifier
317
+ * @returns Name of the body as a string
318
+ *
319
+ * @example
320
+ * const name = getCelestialBodyName(Planet.Mars);
321
+ * console.log(name); // "Mars"
322
+ *
323
+ * const sunName = getCelestialBodyName(Planet.Sun);
324
+ * console.log(sunName); // "Sun"
325
+ */
326
+ function getCelestialBodyName(body) {
327
+ return binding.get_planet_name(body);
328
+ }
329
+ /**
330
+ * Close Swiss Ephemeris and free resources
331
+ *
332
+ * Call this function when you're done using Swiss Ephemeris to free
333
+ * allocated resources.
334
+ *
335
+ * @example
336
+ * // After all calculations are done
337
+ * close();
338
+ */
339
+ function close() {
340
+ binding.close();
341
+ }
342
+ // Re-export all types for convenience
343
+ __exportStar(require("@swisseph/core"), exports);
Binary file