kaabalah 3.1.0 → 3.3.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.
@@ -3048,6 +3048,8 @@ var Planet = /* @__PURE__ */ ((Planet2) => {
3048
3048
  Planet2[Planet2["PLUTO"] = 9] = "PLUTO";
3049
3049
  Planet2[Planet2["MEAN_NODE"] = 10] = "MEAN_NODE";
3050
3050
  Planet2[Planet2["TRUE_NODE"] = 11] = "TRUE_NODE";
3051
+ Planet2[Planet2["LILITH_MEAN"] = 12] = "LILITH_MEAN";
3052
+ Planet2[Planet2["LILITH_TRUE"] = 13] = "LILITH_TRUE";
3051
3053
  Planet2[Planet2["CHIRON"] = 15] = "CHIRON";
3052
3054
  return Planet2;
3053
3055
  })(Planet || {});
@@ -3066,13 +3068,26 @@ var HouseSystem = /* @__PURE__ */ ((HouseSystem2) => {
3066
3068
  return HouseSystem2;
3067
3069
  })(HouseSystem || {});
3068
3070
  var CalcFlag = /* @__PURE__ */ ((CalcFlag2) => {
3071
+ CalcFlag2[CalcFlag2["JPL_EPH"] = 1] = "JPL_EPH";
3069
3072
  CalcFlag2[CalcFlag2["SWISS_EPH"] = 2] = "SWISS_EPH";
3070
3073
  CalcFlag2[CalcFlag2["MOSHIER"] = 4] = "MOSHIER";
3071
3074
  CalcFlag2[CalcFlag2["HELIOCENTRIC"] = 8] = "HELIOCENTRIC";
3072
3075
  CalcFlag2[CalcFlag2["TRUE_POS"] = 16] = "TRUE_POS";
3073
- CalcFlag2[CalcFlag2["SPEED"] = 32] = "SPEED";
3076
+ CalcFlag2[CalcFlag2["J2000"] = 32] = "J2000";
3077
+ CalcFlag2[CalcFlag2["NONUT"] = 64] = "NONUT";
3078
+ CalcFlag2[CalcFlag2["SPEED3"] = 128] = "SPEED3";
3079
+ CalcFlag2[CalcFlag2["SPEED"] = 256] = "SPEED";
3080
+ CalcFlag2[CalcFlag2["EQUATORIAL"] = 2048] = "EQUATORIAL";
3081
+ CalcFlag2[CalcFlag2["TOPOCTR"] = 32768] = "TOPOCTR";
3082
+ CalcFlag2[CalcFlag2["SIDEREAL"] = 65536] = "SIDEREAL";
3074
3083
  return CalcFlag2;
3075
3084
  })(CalcFlag || {});
3085
+ var SE_AST_OFFSET = 1e4;
3086
+ var BODY = {
3087
+ MEAN_APOGEE: 12,
3088
+ // Lilith mean
3089
+ OSC_APOGEE: 13};
3090
+ var normalizeAngle = (deg) => (deg % 360 + 360) % 360;
3076
3091
  var SwissEph = class {
3077
3092
  /**
3078
3093
  * Constructor that accepts a pre-initialized Swiss Ephemeris module
@@ -3084,13 +3099,17 @@ var SwissEph = class {
3084
3099
  this.swe_house_pos = null;
3085
3100
  this.swe_set_ephe_path = null;
3086
3101
  this.swe_close = null;
3102
+ this.swe_set_topo = null;
3103
+ this.swe_set_sid_mode = null;
3087
3104
  this.module = module;
3088
3105
  this.swe_julday = this.module.cwrap("swe_julday", "number", ["number", "number", "number", "number", "number"]);
3089
3106
  this.swe_calc_ut = this.module.cwrap("swe_calc_ut", "number", ["number", "number", "number", "number"]);
3090
- this.swe_houses = this.module.cwrap("swe_houses", "number", ["number", "number", "number", "string", "number", "number"]);
3107
+ this.swe_houses = this.module.cwrap("swe_houses", "number", ["number", "number", "number", "number", "number", "number"]);
3091
3108
  this.swe_house_pos = this.module.cwrap("swe_house_pos", "number", ["number", "number", "number", "string", "number", "number"]);
3092
3109
  this.swe_set_ephe_path = this.module.cwrap("swe_set_ephe_path", null, ["number"]);
3093
3110
  this.swe_close = this.module.cwrap("swe_close", null, []);
3111
+ this.swe_set_topo = this.module.cwrap("swe_set_topo", null, ["number", "number", "number"]);
3112
+ this.swe_set_sid_mode = this.module.cwrap("swe_set_sid_mode", null, ["number", "number", "number"]);
3094
3113
  }
3095
3114
  checkInitialized() {
3096
3115
  if (!this.module) {
@@ -3149,7 +3168,7 @@ var SwissEph = class {
3149
3168
  latitude: this.module.getValue(resultPtr + 8, "double"),
3150
3169
  distance: this.module.getValue(resultPtr + 16, "double")
3151
3170
  };
3152
- if (flags & 32 /* SPEED */) {
3171
+ if (flags & 256 /* SPEED */) {
3153
3172
  position.longitudeSpeed = this.module.getValue(resultPtr + 24, "double");
3154
3173
  position.latitudeSpeed = this.module.getValue(resultPtr + 32, "double");
3155
3174
  position.distanceSpeed = this.module.getValue(resultPtr + 40, "double");
@@ -3181,7 +3200,8 @@ var SwissEph = class {
3181
3200
  const housesPtr = memoryPtr;
3182
3201
  const ascmcPtr = memoryPtr + 12 * 8;
3183
3202
  try {
3184
- const ret = this.swe_houses(julday, latitude, longitude, hsys.toString(), housesPtr, ascmcPtr);
3203
+ const hsysCode = hsys.charCodeAt(0);
3204
+ const ret = this.swe_houses(julday, latitude, longitude, hsysCode, housesPtr, ascmcPtr);
3185
3205
  if (ret < 0) {
3186
3206
  throw new Error(`Houses calculation failed with error code ${ret}`);
3187
3207
  }
@@ -3190,9 +3210,27 @@ var SwissEph = class {
3190
3210
  const value = this.module.getValue(housesPtr + i * 8, "double");
3191
3211
  houses.push(value);
3192
3212
  }
3193
- const ascendant = this.module.getValue(ascmcPtr, "double");
3213
+ const ascendant = this.module.getValue(ascmcPtr + 0, "double");
3194
3214
  const mc = this.module.getValue(ascmcPtr + 8, "double");
3195
- return { ascendant, mc, houses };
3215
+ const armc = this.module.getValue(ascmcPtr + 16, "double");
3216
+ const vertex = this.module.getValue(ascmcPtr + 24, "double");
3217
+ const equasc = this.module.getValue(ascmcPtr + 32, "double");
3218
+ const coasc1 = this.module.getValue(ascmcPtr + 40, "double");
3219
+ const coasc2 = this.module.getValue(ascmcPtr + 48, "double");
3220
+ const polasc = this.module.getValue(ascmcPtr + 56, "double");
3221
+ return {
3222
+ ascendant,
3223
+ mc,
3224
+ houses,
3225
+ ascmc: {
3226
+ armc,
3227
+ vertex,
3228
+ equasc,
3229
+ coasc1,
3230
+ coasc2,
3231
+ polasc
3232
+ }
3233
+ };
3196
3234
  } finally {
3197
3235
  this.module._free(memoryPtr);
3198
3236
  }
@@ -3206,10 +3244,42 @@ var SwissEph = class {
3206
3244
  this.swe_close();
3207
3245
  }
3208
3246
  }
3247
+ /**
3248
+ * Set topocentric observer
3249
+ */
3250
+ setTopocentric(longitude, latitude, altitudeMeters = 0) {
3251
+ this.checkInitialized();
3252
+ if (!this.swe_set_topo) {
3253
+ throw new Error("Topocentric calculation function not available");
3254
+ }
3255
+ this.swe_set_topo(longitude, latitude, altitudeMeters);
3256
+ }
3257
+ /**
3258
+ * Set sidereal mode
3259
+ * Ex.: mode=1 (Lahiri). See Swiss Ephemeris mode table.
3260
+ */
3261
+ setSiderealMode(mode, t0 = 0, ayan_t0 = 0) {
3262
+ this.checkInitialized();
3263
+ this.swe_set_sid_mode?.(mode, t0, ayan_t0);
3264
+ }
3265
+ /**
3266
+ * Asteroid by MPC number
3267
+ */
3268
+ calculateAsteroidPosition(julday, mpcNumber, flags = 2 /* SWISS_EPH */) {
3269
+ return this.calculatePlanetPosition(julday, SE_AST_OFFSET + mpcNumber, flags);
3270
+ }
3271
+ /**
3272
+ * Lilith mean (12) and true (13)
3273
+ */
3274
+ calculateLilith(julday, kind = "mean", flags = 2 /* SWISS_EPH */) {
3275
+ const id = kind === "mean" ? BODY.MEAN_APOGEE : BODY.OSC_APOGEE;
3276
+ return this.calculatePlanetPosition(julday, id, flags);
3277
+ }
3209
3278
  };
3210
3279
 
3211
3280
  // src/astrology/swisseph.ts
3212
3281
  var swissEph = null;
3282
+ var DEFAULT_FLAGS = 2 /* SWISS_EPH */ | 256 /* SPEED */;
3213
3283
  async function getSwissEph(options = {}) {
3214
3284
  if (swissEph) {
3215
3285
  return;
@@ -3234,6 +3304,7 @@ async function calculatePlanetaryPositions(date) {
3234
3304
  try {
3235
3305
  checkInitialization();
3236
3306
  const julday = swissEph.getJulianDay(date);
3307
+ const flags = DEFAULT_FLAGS;
3237
3308
  const planets = {
3238
3309
  sun: 0 /* SUN */,
3239
3310
  moon: 1 /* MOON */,
@@ -3241,12 +3312,21 @@ async function calculatePlanetaryPositions(date) {
3241
3312
  venus: 3 /* VENUS */,
3242
3313
  mars: 4 /* MARS */,
3243
3314
  jupiter: 5 /* JUPITER */,
3244
- saturn: 6 /* SATURN */
3315
+ saturn: 6 /* SATURN */,
3316
+ uranus: 7 /* URANUS */,
3317
+ neptune: 8 /* NEPTUNE */,
3318
+ pluto: 9 /* PLUTO */,
3319
+ meanNode: 10 /* MEAN_NODE */,
3320
+ // trueNode: Planet.TRUE_NODE,
3321
+ // TODO: add chiron through seas_18.se1, seas_18.se2 and seasnam.txt files
3322
+ // chiron: Planet.CHIRON,
3323
+ lilithMean: 12 /* LILITH_MEAN */
3324
+ // lilithTrue: Planet.LILITH_TRUE,
3245
3325
  };
3246
3326
  const positions = {};
3247
3327
  for (const [name, id] of Object.entries(planets)) {
3248
3328
  try {
3249
- positions[name] = swissEph.calculatePlanetPosition(julday, id);
3329
+ positions[name] = swissEph.calculatePlanetPosition(julday, id, flags);
3250
3330
  } catch (error) {
3251
3331
  throw new Error(`Failed to calculate position for ${name}: ${error}`);
3252
3332
  }
@@ -3327,36 +3407,65 @@ async function getBirthChart(options) {
3327
3407
  throw error;
3328
3408
  }
3329
3409
  }
3410
+ var SIGNS = [
3411
+ "Aries",
3412
+ "Taurus",
3413
+ "Gemini",
3414
+ "Cancer",
3415
+ "Leo",
3416
+ "Virgo",
3417
+ "Libra",
3418
+ "Scorpio",
3419
+ "Sagittarius",
3420
+ "Capricorn",
3421
+ "Aquarius",
3422
+ "Pisces"
3423
+ ];
3330
3424
  function formatDegreeMinutes(decimalDegrees) {
3331
- const degrees = Math.floor(decimalDegrees);
3332
- const minutes = Math.round((decimalDegrees - degrees) * 60);
3333
- return `${degrees}\xB0${minutes.toString().padStart(2, "0")}'`;
3425
+ let deg = Math.floor(decimalDegrees);
3426
+ let min = Math.round((decimalDegrees - deg) * 60);
3427
+ if (min === 60) {
3428
+ min = 0;
3429
+ deg += 1;
3430
+ }
3431
+ return `${deg}\xB0${String(min).padStart(2, "0")}'`;
3334
3432
  }
3335
3433
  function getZodiacPosition(longitude) {
3336
- const signs = [
3337
- "Aries",
3338
- "Taurus",
3339
- "Gemini",
3340
- "Cancer",
3341
- "Leo",
3342
- "Virgo",
3343
- "Libra",
3344
- "Scorpio",
3345
- "Sagittarius",
3346
- "Capricorn",
3347
- "Aquarius",
3348
- "Pisces"
3349
- ];
3350
- const signIndex = Math.floor(longitude / 30) % 12;
3351
- const degrees = longitude % 30;
3434
+ const L = normalizeAngle(longitude);
3435
+ const signIndex = Math.floor(L / 30) % 12;
3436
+ const within = L - signIndex * 30;
3352
3437
  return {
3353
- sign: signs[signIndex],
3354
- decimalDegrees: degrees,
3355
- traditionalFormat: formatDegreeMinutes(degrees),
3356
- decimal: degrees.toFixed(2) + "\xB0"
3438
+ sign: SIGNS[signIndex],
3439
+ decimalDegrees: within,
3440
+ traditionalFormat: formatDegreeMinutes(within),
3441
+ decimal: within.toFixed(2) + "\xB0"
3357
3442
  };
3358
3443
  }
3444
+ function formatHouseCusps(houses360) {
3445
+ return houses360.map((lon, i) => {
3446
+ const z = getZodiacPosition(lon);
3447
+ return {
3448
+ house: i + 1,
3449
+ sign: z.sign,
3450
+ degree: z.traditionalFormat,
3451
+ longitude: normalizeAngle(lon)
3452
+ };
3453
+ });
3454
+ }
3455
+ function findHouseOf(longitude, cusps360) {
3456
+ const L = normalizeAngle(longitude);
3457
+ const H = cusps360.map((c, i) => ({ i: i + 1, L: normalizeAngle(c) })).sort((a, b) => a.L - b.L);
3458
+ for (let k = 0; k < H.length; k++) {
3459
+ const cur = H[k], nxt = H[(k + 1) % H.length];
3460
+ if (nxt.L < cur.L) {
3461
+ if (L >= cur.L || L < nxt.L) return cur.i;
3462
+ } else {
3463
+ if (L >= cur.L && L < nxt.L) return cur.i;
3464
+ }
3465
+ }
3466
+ return 1;
3467
+ }
3359
3468
 
3360
- export { CalcFlag, HouseSystem, Planet, closeSwissEph, formatDegreeMinutes, getBirthChart, getSwissEph, getZodiacPosition };
3361
- //# sourceMappingURL=chunk-AV7WBVPS.mjs.map
3362
- //# sourceMappingURL=chunk-AV7WBVPS.mjs.map
3469
+ export { CalcFlag, HouseSystem, Planet, SIGNS, closeSwissEph, findHouseOf, formatDegreeMinutes, formatHouseCusps, getBirthChart, getSwissEph, getZodiacPosition, normalizeAngle };
3470
+ //# sourceMappingURL=chunk-T7D3HPJZ.mjs.map
3471
+ //# sourceMappingURL=chunk-T7D3HPJZ.mjs.map