Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 48 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@

Swiss Ephemeris library for Vedic astrology calculations with pre-built native binaries.

**✅ Vercel Compatible** - Works in serverless environments without native compilation.

## Features

- 🌟 **Vedic Astrology Focus** - Calculate all 9 Vedic planets (Navagraha)
- 🚀 **Pre-built Binaries** - No native compilation required
- ☁️ **Vercel Ready** - Works in serverless environments out of the box
- 📦 **Pre-compiled Distribution** - Ready-to-use dist files included
- 🌍 **Cross-Platform** - Works on macOS, Linux, and Windows
- 🌍 **Cross-Platform** - Works on macOS (Intel & ARM), Linux, and Windows
- 📦 **Simple API** - Clean, TypeScript-first interface
- ⚡ **Fast** - Native Swiss Ephemeris performance

Expand Down Expand Up @@ -572,26 +575,66 @@ const moon = calculateSinglePlanet(1, date);
| Linux | ARM64 | ✅ |
| Windows | x64 | ✅ |

## Vercel Deployment

This library is designed to work seamlessly on Vercel's serverless environment:

- ✅ **No native compilation** - Pre-built binaries for linux-x64 included
- ✅ **Zero configuration** - Works out of the box
- ✅ **Optimized for serverless** - Fast cold starts with minimal bundle impact

### Usage in Next.js API Routes

```typescript
// app/api/calculate/route.ts
import { calculatePlanets, calculateLagna } from '@af/sweph';

export async function GET() {
const planets = calculatePlanets(new Date());
return Response.json({ planets });
}
```

### Debug Platform Info

```typescript
import { getPlatformInfo, hasPrebuilds } from '@af/sweph';

// Check platform detection
console.log(getPlatformInfo());
// { platform: 'linux', arch: 'x64', key: 'linux-x64', isSupported: true, ... }

console.log('Has prebuilds:', hasPrebuilds());
// true
```

## Troubleshooting

### Common Issues

1. **"Failed to load Swiss Ephemeris native module"**
- Ensure `swisseph-v2` is installed: `npm install swisseph-v2`
- Ensure package version is >= 0.2.0 for Vercel compatibility
- Check that prebuilt binaries are available for your platform
- For development: `pnpm add swisseph-v2` (optional fallback)

2. **"Ephemeris files not found"**
2. **Vercel deployment fails with "Cannot find module swisseph.node"**
- Upgrade to `@af/sweph@0.2.0` or later
- Clear Vercel build cache and redeploy
- Verify `node_modules/@af/sweph/prebuilds/linux-x64/swisseph.node` exists.

3. **"Ephemeris files not found"**
- Ensure `ephe/` directory exists with `.se1` files
- Or set custom path: `setEphemerisPath('/path/to/ephe')`

3. **Incorrect times**
4. **Incorrect times**
- Verify timezone offset is correct (e.g., 5.5 for IST, -5 for EST)
- Ensure input dates are in local time

4. **Null rise/set times**
5. **Null rise/set times**
- Normal for polar regions during certain seasons
- Moon may not rise/set on some days near equator


## Contributing

1. Fork the repository
Expand Down
1 change: 1 addition & 0 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export { calculateLagna, calculateHouses, } from './houses';
export { calculateSunTimes, calculateSolarNoon, calculateSunPath, } from './sun';
export { calculateMoonData, calculateMoonPhase, calculateNextMoonPhases, } from './moon';
export { getAyanamsa, setEphemerisPath, getJulianDay, dateToJulian, julianToDate, getNativeModule, } from './utils';
export { getPlatformInfo, hasPrebuilds, getSupportedPlatforms, } from './native-loader';
export { PLANETS, AYANAMSA, HOUSE_SYSTEMS, RASHIS, NAKSHATRAS, VEDIC_PLANET_ORDER, } from './constants';
export { createSwephCalculator, createPlanetaryCalculator, createSwephAdapter, createNodeAdapter, initializeSweph, registerAdapter, calculateKundaliPageData, type PlanetaryCalculationProvider, type SwephAdapter, type SunTimesResult, type MoonTimesResult, type LegacyPlanet, type LegacyLagnaInfo, } from './legacy';
//# sourceMappingURL=index.d.ts.map
2 changes: 1 addition & 1 deletion dist/index.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions dist/legacy.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/legacy.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions dist/native-loader.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* Load the Swiss Ephemeris native module from pre-built binaries
* Falls back to swisseph-v2 if prebuilds are not available
*
* @returns Swiss Ephemeris native module instance
* @throws Error if no compatible native module can be loaded
*/
export declare function loadNativeBinary(): any;
/**
* Get information about the current platform
* Useful for debugging deployment issues
*/
export declare function getPlatformInfo(): {
platform: string;
arch: string;
key: string;
isSupported: boolean;
prebuildPaths: string[];
};
/**
* Check if prebuilds are available for the current platform
*/
export declare function hasPrebuilds(): boolean;
/**
* Get the list of supported platforms
*/
export declare function getSupportedPlatforms(): readonly string[];
//# sourceMappingURL=native-loader.d.ts.map
1 change: 1 addition & 0 deletions dist/native-loader.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading