kaabalah 3.2.0 → 3.3.1

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.
@@ -3089,6 +3089,7 @@ var BODY = {
3089
3089
  MEAN_APOGEE: 12,
3090
3090
  // Lilith mean
3091
3091
  OSC_APOGEE: 13};
3092
+ var normalizeAngle = (deg) => (deg % 360 + 360) % 360;
3092
3093
  var SwissEph = class {
3093
3094
  /**
3094
3095
  * Constructor that accepts a pre-initialized Swiss Ephemeris module
@@ -3193,32 +3194,32 @@ var SwissEph = class {
3193
3194
  if (longitude < -180 || longitude > 180) {
3194
3195
  throw new Error("Longitude must be between -180 and 180 degrees");
3195
3196
  }
3196
- const totalBytes = (12 + 10) * 8;
3197
+ const HOUSES_DOUBLES = 13;
3198
+ const ASCMC_DOUBLES = 10;
3199
+ const BYTES_PER_F64 = 8;
3200
+ const totalBytes = (HOUSES_DOUBLES + ASCMC_DOUBLES) * BYTES_PER_F64;
3197
3201
  const memoryPtr = this.module._malloc(totalBytes);
3198
- if (!memoryPtr) {
3199
- throw new Error("Memory allocation failed");
3200
- }
3202
+ if (!memoryPtr) throw new Error("Memory allocation failed");
3201
3203
  const housesPtr = memoryPtr;
3202
- const ascmcPtr = memoryPtr + 12 * 8;
3204
+ const ascmcPtr = memoryPtr + HOUSES_DOUBLES * BYTES_PER_F64;
3203
3205
  try {
3204
3206
  const hsysCode = hsys.charCodeAt(0);
3205
3207
  const ret = this.swe_houses(julday, latitude, longitude, hsysCode, housesPtr, ascmcPtr);
3206
3208
  if (ret < 0) {
3207
3209
  throw new Error(`Houses calculation failed with error code ${ret}`);
3208
3210
  }
3209
- const houses = [];
3210
- for (let i = 0; i < 12; i++) {
3211
- const value = this.module.getValue(housesPtr + i * 8, "double");
3212
- houses.push(value);
3211
+ const houses = new Array(HOUSES_DOUBLES);
3212
+ for (let i = 0; i < HOUSES_DOUBLES; i++) {
3213
+ houses[i] = this.module.getValue(housesPtr + i * BYTES_PER_F64, "double");
3213
3214
  }
3214
- const ascendant = this.module.getValue(ascmcPtr + 0, "double");
3215
- const mc = this.module.getValue(ascmcPtr + 8, "double");
3216
- const armc = this.module.getValue(ascmcPtr + 16, "double");
3217
- const vertex = this.module.getValue(ascmcPtr + 24, "double");
3218
- const equasc = this.module.getValue(ascmcPtr + 32, "double");
3219
- const coasc1 = this.module.getValue(ascmcPtr + 40, "double");
3220
- const coasc2 = this.module.getValue(ascmcPtr + 48, "double");
3221
- const polasc = this.module.getValue(ascmcPtr + 56, "double");
3215
+ const ascendant = this.module.getValue(ascmcPtr + 0 * BYTES_PER_F64, "double");
3216
+ const mc = this.module.getValue(ascmcPtr + 1 * BYTES_PER_F64, "double");
3217
+ const armc = this.module.getValue(ascmcPtr + 2 * BYTES_PER_F64, "double");
3218
+ const vertex = this.module.getValue(ascmcPtr + 3 * BYTES_PER_F64, "double");
3219
+ const equasc = this.module.getValue(ascmcPtr + 4 * BYTES_PER_F64, "double");
3220
+ const coasc1 = this.module.getValue(ascmcPtr + 5 * BYTES_PER_F64, "double");
3221
+ const coasc2 = this.module.getValue(ascmcPtr + 6 * BYTES_PER_F64, "double");
3222
+ const polasc = this.module.getValue(ascmcPtr + 7 * BYTES_PER_F64, "double");
3222
3223
  return {
3223
3224
  ascendant,
3224
3225
  mc,
@@ -3318,11 +3319,11 @@ async function calculatePlanetaryPositions(date) {
3318
3319
  neptune: 8 /* NEPTUNE */,
3319
3320
  pluto: 9 /* PLUTO */,
3320
3321
  meanNode: 10 /* MEAN_NODE */,
3321
- trueNode: 11 /* TRUE_NODE */,
3322
+ // trueNode: Planet.TRUE_NODE,
3322
3323
  // TODO: add chiron through seas_18.se1, seas_18.se2 and seasnam.txt files
3323
3324
  // chiron: Planet.CHIRON,
3324
- lilithMean: 12 /* LILITH_MEAN */,
3325
- lilithTrue: 13 /* LILITH_TRUE */
3325
+ lilithMean: 12 /* LILITH_MEAN */
3326
+ // lilithTrue: Planet.LILITH_TRUE,
3326
3327
  };
3327
3328
  const positions = {};
3328
3329
  for (const [name, id] of Object.entries(planets)) {
@@ -3408,43 +3409,76 @@ async function getBirthChart(options) {
3408
3409
  throw error;
3409
3410
  }
3410
3411
  }
3412
+ var SIGNS = [
3413
+ "Aries",
3414
+ "Taurus",
3415
+ "Gemini",
3416
+ "Cancer",
3417
+ "Leo",
3418
+ "Virgo",
3419
+ "Libra",
3420
+ "Scorpio",
3421
+ "Sagittarius",
3422
+ "Capricorn",
3423
+ "Aquarius",
3424
+ "Pisces"
3425
+ ];
3411
3426
  function formatDegreeMinutes(decimalDegrees) {
3412
- const degrees = Math.floor(decimalDegrees);
3413
- const minutes = Math.round((decimalDegrees - degrees) * 60);
3414
- return `${degrees}\xB0${minutes.toString().padStart(2, "0")}'`;
3427
+ let deg = Math.floor(decimalDegrees);
3428
+ let min = Math.round((decimalDegrees - deg) * 60);
3429
+ if (min === 60) {
3430
+ min = 0;
3431
+ deg += 1;
3432
+ }
3433
+ return `${deg}\xB0${String(min).padStart(2, "0")}'`;
3415
3434
  }
3416
3435
  function getZodiacPosition(longitude) {
3417
- const signs = [
3418
- "Aries",
3419
- "Taurus",
3420
- "Gemini",
3421
- "Cancer",
3422
- "Leo",
3423
- "Virgo",
3424
- "Libra",
3425
- "Scorpio",
3426
- "Sagittarius",
3427
- "Capricorn",
3428
- "Aquarius",
3429
- "Pisces"
3430
- ];
3431
- const signIndex = Math.floor(longitude / 30) % 12;
3432
- const degrees = longitude % 30;
3436
+ const L = normalizeAngle(longitude);
3437
+ const signIndex = Math.floor(L / 30) % 12;
3438
+ const within = L - signIndex * 30;
3433
3439
  return {
3434
- sign: signs[signIndex],
3435
- decimalDegrees: degrees,
3436
- traditionalFormat: formatDegreeMinutes(degrees),
3437
- decimal: degrees.toFixed(2) + "\xB0"
3440
+ sign: SIGNS[signIndex],
3441
+ decimalDegrees: within,
3442
+ traditionalFormat: formatDegreeMinutes(within),
3443
+ decimal: within.toFixed(2) + "\xB0"
3438
3444
  };
3439
3445
  }
3446
+ function formatHouseCusps(houses360) {
3447
+ return houses360.map((lon, i) => {
3448
+ const z = getZodiacPosition(lon);
3449
+ return {
3450
+ house: i + 1,
3451
+ sign: z.sign,
3452
+ degree: z.traditionalFormat,
3453
+ longitude: normalizeAngle(lon)
3454
+ };
3455
+ });
3456
+ }
3457
+ function findHouseOf(longitude, cusps360) {
3458
+ const L = normalizeAngle(longitude);
3459
+ const H = cusps360.map((c, i) => ({ i: i + 1, L: normalizeAngle(c) })).sort((a, b) => a.L - b.L);
3460
+ for (let k = 0; k < H.length; k++) {
3461
+ const cur = H[k], nxt = H[(k + 1) % H.length];
3462
+ if (nxt.L < cur.L) {
3463
+ if (L >= cur.L || L < nxt.L) return cur.i;
3464
+ } else {
3465
+ if (L >= cur.L && L < nxt.L) return cur.i;
3466
+ }
3467
+ }
3468
+ return 1;
3469
+ }
3440
3470
 
3441
3471
  exports.CalcFlag = CalcFlag;
3442
3472
  exports.HouseSystem = HouseSystem;
3443
3473
  exports.Planet = Planet;
3474
+ exports.SIGNS = SIGNS;
3444
3475
  exports.closeSwissEph = closeSwissEph;
3476
+ exports.findHouseOf = findHouseOf;
3445
3477
  exports.formatDegreeMinutes = formatDegreeMinutes;
3478
+ exports.formatHouseCusps = formatHouseCusps;
3446
3479
  exports.getBirthChart = getBirthChart;
3447
3480
  exports.getSwissEph = getSwissEph;
3448
3481
  exports.getZodiacPosition = getZodiacPosition;
3449
- //# sourceMappingURL=chunk-3JIIZ45K.js.map
3450
- //# sourceMappingURL=chunk-3JIIZ45K.js.map
3482
+ exports.normalizeAngle = normalizeAngle;
3483
+ //# sourceMappingURL=chunk-T2JS2IJN.js.map
3484
+ //# sourceMappingURL=chunk-T2JS2IJN.js.map