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.
@@ -46,6 +46,7 @@ declare enum CalcFlag {
46
46
  TOPOCTR = 32768,
47
47
  SIDEREAL = 65536
48
48
  }
49
+ declare const normalizeAngle: (deg: number) => number;
49
50
 
50
51
  /**
51
52
  * Initializes and returns the Swiss Ephemeris instance.
@@ -95,6 +96,7 @@ interface BirthChart {
95
96
  * @returns Birth chart data
96
97
  */
97
98
  declare function getBirthChart(options: BirthChartOptions): Promise<BirthChart>;
99
+ declare const SIGNS: readonly ["Aries", "Taurus", "Gemini", "Cancer", "Leo", "Virgo", "Libra", "Scorpio", "Sagittarius", "Capricorn", "Aquarius", "Pisces"];
98
100
  /**
99
101
  * Convert decimal degrees to degrees and minutes format
100
102
  *
@@ -114,5 +116,12 @@ declare function getZodiacPosition(longitude: number): {
114
116
  traditionalFormat: string;
115
117
  decimal: string;
116
118
  };
119
+ declare function formatHouseCusps(houses360: number[]): {
120
+ house: number;
121
+ sign: string;
122
+ degree: string;
123
+ longitude: number;
124
+ }[];
125
+ declare function findHouseOf(longitude: number, cusps360: number[]): number;
117
126
 
118
- export { type BirthChart, type BirthChartOptions, CalcFlag, HouseSystem, Planet, closeSwissEph, formatDegreeMinutes, getBirthChart, getSwissEph, getZodiacPosition };
127
+ export { type BirthChart, type BirthChartOptions, CalcFlag, HouseSystem, Planet, SIGNS, closeSwissEph, findHouseOf, formatDegreeMinutes, formatHouseCusps, getBirthChart, getSwissEph, getZodiacPosition, normalizeAngle };
@@ -46,6 +46,7 @@ declare enum CalcFlag {
46
46
  TOPOCTR = 32768,
47
47
  SIDEREAL = 65536
48
48
  }
49
+ declare const normalizeAngle: (deg: number) => number;
49
50
 
50
51
  /**
51
52
  * Initializes and returns the Swiss Ephemeris instance.
@@ -95,6 +96,7 @@ interface BirthChart {
95
96
  * @returns Birth chart data
96
97
  */
97
98
  declare function getBirthChart(options: BirthChartOptions): Promise<BirthChart>;
99
+ declare const SIGNS: readonly ["Aries", "Taurus", "Gemini", "Cancer", "Leo", "Virgo", "Libra", "Scorpio", "Sagittarius", "Capricorn", "Aquarius", "Pisces"];
98
100
  /**
99
101
  * Convert decimal degrees to degrees and minutes format
100
102
  *
@@ -114,5 +116,12 @@ declare function getZodiacPosition(longitude: number): {
114
116
  traditionalFormat: string;
115
117
  decimal: string;
116
118
  };
119
+ declare function formatHouseCusps(houses360: number[]): {
120
+ house: number;
121
+ sign: string;
122
+ degree: string;
123
+ longitude: number;
124
+ }[];
125
+ declare function findHouseOf(longitude: number, cusps360: number[]): number;
117
126
 
118
- export { type BirthChart, type BirthChartOptions, CalcFlag, HouseSystem, Planet, closeSwissEph, formatDegreeMinutes, getBirthChart, getSwissEph, getZodiacPosition };
127
+ export { type BirthChart, type BirthChartOptions, CalcFlag, HouseSystem, Planet, SIGNS, closeSwissEph, findHouseOf, formatDegreeMinutes, formatHouseCusps, getBirthChart, getSwissEph, getZodiacPosition, normalizeAngle };
@@ -1,41 +1,57 @@
1
1
  'use strict';
2
2
 
3
- var chunk3JIIZ45K_js = require('../chunk-3JIIZ45K.js');
3
+ var chunkT2JS2IJN_js = require('../chunk-T2JS2IJN.js');
4
4
  require('../chunk-2TUXWMP5.js');
5
5
 
6
6
 
7
7
 
8
8
  Object.defineProperty(exports, "CalcFlag", {
9
9
  enumerable: true,
10
- get: function () { return chunk3JIIZ45K_js.CalcFlag; }
10
+ get: function () { return chunkT2JS2IJN_js.CalcFlag; }
11
11
  });
12
12
  Object.defineProperty(exports, "HouseSystem", {
13
13
  enumerable: true,
14
- get: function () { return chunk3JIIZ45K_js.HouseSystem; }
14
+ get: function () { return chunkT2JS2IJN_js.HouseSystem; }
15
15
  });
16
16
  Object.defineProperty(exports, "Planet", {
17
17
  enumerable: true,
18
- get: function () { return chunk3JIIZ45K_js.Planet; }
18
+ get: function () { return chunkT2JS2IJN_js.Planet; }
19
+ });
20
+ Object.defineProperty(exports, "SIGNS", {
21
+ enumerable: true,
22
+ get: function () { return chunkT2JS2IJN_js.SIGNS; }
19
23
  });
20
24
  Object.defineProperty(exports, "closeSwissEph", {
21
25
  enumerable: true,
22
- get: function () { return chunk3JIIZ45K_js.closeSwissEph; }
26
+ get: function () { return chunkT2JS2IJN_js.closeSwissEph; }
27
+ });
28
+ Object.defineProperty(exports, "findHouseOf", {
29
+ enumerable: true,
30
+ get: function () { return chunkT2JS2IJN_js.findHouseOf; }
23
31
  });
24
32
  Object.defineProperty(exports, "formatDegreeMinutes", {
25
33
  enumerable: true,
26
- get: function () { return chunk3JIIZ45K_js.formatDegreeMinutes; }
34
+ get: function () { return chunkT2JS2IJN_js.formatDegreeMinutes; }
35
+ });
36
+ Object.defineProperty(exports, "formatHouseCusps", {
37
+ enumerable: true,
38
+ get: function () { return chunkT2JS2IJN_js.formatHouseCusps; }
27
39
  });
28
40
  Object.defineProperty(exports, "getBirthChart", {
29
41
  enumerable: true,
30
- get: function () { return chunk3JIIZ45K_js.getBirthChart; }
42
+ get: function () { return chunkT2JS2IJN_js.getBirthChart; }
31
43
  });
32
44
  Object.defineProperty(exports, "getSwissEph", {
33
45
  enumerable: true,
34
- get: function () { return chunk3JIIZ45K_js.getSwissEph; }
46
+ get: function () { return chunkT2JS2IJN_js.getSwissEph; }
35
47
  });
36
48
  Object.defineProperty(exports, "getZodiacPosition", {
37
49
  enumerable: true,
38
- get: function () { return chunk3JIIZ45K_js.getZodiacPosition; }
50
+ get: function () { return chunkT2JS2IJN_js.getZodiacPosition; }
51
+ });
52
+ Object.defineProperty(exports, "normalizeAngle", {
53
+ enumerable: true,
54
+ get: function () { return chunkT2JS2IJN_js.normalizeAngle; }
39
55
  });
40
56
  //# sourceMappingURL=index.js.map
41
57
  //# sourceMappingURL=index.js.map
@@ -1,4 +1,4 @@
1
- export { CalcFlag, HouseSystem, Planet, closeSwissEph, formatDegreeMinutes, getBirthChart, getSwissEph, getZodiacPosition } from '../chunk-O2LE2NXP.mjs';
1
+ export { CalcFlag, HouseSystem, Planet, SIGNS, closeSwissEph, findHouseOf, formatDegreeMinutes, formatHouseCusps, getBirthChart, getSwissEph, getZodiacPosition, normalizeAngle } from '../chunk-S6GM43CR.mjs';
2
2
  import '../chunk-PY5SMMJB.mjs';
3
3
  //# sourceMappingURL=index.mjs.map
4
4
  //# sourceMappingURL=index.mjs.map
@@ -3087,6 +3087,7 @@ var BODY = {
3087
3087
  MEAN_APOGEE: 12,
3088
3088
  // Lilith mean
3089
3089
  OSC_APOGEE: 13};
3090
+ var normalizeAngle = (deg) => (deg % 360 + 360) % 360;
3090
3091
  var SwissEph = class {
3091
3092
  /**
3092
3093
  * Constructor that accepts a pre-initialized Swiss Ephemeris module
@@ -3191,32 +3192,32 @@ var SwissEph = class {
3191
3192
  if (longitude < -180 || longitude > 180) {
3192
3193
  throw new Error("Longitude must be between -180 and 180 degrees");
3193
3194
  }
3194
- const totalBytes = (12 + 10) * 8;
3195
+ const HOUSES_DOUBLES = 13;
3196
+ const ASCMC_DOUBLES = 10;
3197
+ const BYTES_PER_F64 = 8;
3198
+ const totalBytes = (HOUSES_DOUBLES + ASCMC_DOUBLES) * BYTES_PER_F64;
3195
3199
  const memoryPtr = this.module._malloc(totalBytes);
3196
- if (!memoryPtr) {
3197
- throw new Error("Memory allocation failed");
3198
- }
3200
+ if (!memoryPtr) throw new Error("Memory allocation failed");
3199
3201
  const housesPtr = memoryPtr;
3200
- const ascmcPtr = memoryPtr + 12 * 8;
3202
+ const ascmcPtr = memoryPtr + HOUSES_DOUBLES * BYTES_PER_F64;
3201
3203
  try {
3202
3204
  const hsysCode = hsys.charCodeAt(0);
3203
3205
  const ret = this.swe_houses(julday, latitude, longitude, hsysCode, housesPtr, ascmcPtr);
3204
3206
  if (ret < 0) {
3205
3207
  throw new Error(`Houses calculation failed with error code ${ret}`);
3206
3208
  }
3207
- const houses = [];
3208
- for (let i = 0; i < 12; i++) {
3209
- const value = this.module.getValue(housesPtr + i * 8, "double");
3210
- houses.push(value);
3209
+ const houses = new Array(HOUSES_DOUBLES);
3210
+ for (let i = 0; i < HOUSES_DOUBLES; i++) {
3211
+ houses[i] = this.module.getValue(housesPtr + i * BYTES_PER_F64, "double");
3211
3212
  }
3212
- const ascendant = this.module.getValue(ascmcPtr + 0, "double");
3213
- const mc = this.module.getValue(ascmcPtr + 8, "double");
3214
- const armc = this.module.getValue(ascmcPtr + 16, "double");
3215
- const vertex = this.module.getValue(ascmcPtr + 24, "double");
3216
- const equasc = this.module.getValue(ascmcPtr + 32, "double");
3217
- const coasc1 = this.module.getValue(ascmcPtr + 40, "double");
3218
- const coasc2 = this.module.getValue(ascmcPtr + 48, "double");
3219
- const polasc = this.module.getValue(ascmcPtr + 56, "double");
3213
+ const ascendant = this.module.getValue(ascmcPtr + 0 * BYTES_PER_F64, "double");
3214
+ const mc = this.module.getValue(ascmcPtr + 1 * BYTES_PER_F64, "double");
3215
+ const armc = this.module.getValue(ascmcPtr + 2 * BYTES_PER_F64, "double");
3216
+ const vertex = this.module.getValue(ascmcPtr + 3 * BYTES_PER_F64, "double");
3217
+ const equasc = this.module.getValue(ascmcPtr + 4 * BYTES_PER_F64, "double");
3218
+ const coasc1 = this.module.getValue(ascmcPtr + 5 * BYTES_PER_F64, "double");
3219
+ const coasc2 = this.module.getValue(ascmcPtr + 6 * BYTES_PER_F64, "double");
3220
+ const polasc = this.module.getValue(ascmcPtr + 7 * BYTES_PER_F64, "double");
3220
3221
  return {
3221
3222
  ascendant,
3222
3223
  mc,
@@ -3316,11 +3317,11 @@ async function calculatePlanetaryPositions(date) {
3316
3317
  neptune: 8 /* NEPTUNE */,
3317
3318
  pluto: 9 /* PLUTO */,
3318
3319
  meanNode: 10 /* MEAN_NODE */,
3319
- trueNode: 11 /* TRUE_NODE */,
3320
+ // trueNode: Planet.TRUE_NODE,
3320
3321
  // TODO: add chiron through seas_18.se1, seas_18.se2 and seasnam.txt files
3321
3322
  // chiron: Planet.CHIRON,
3322
- lilithMean: 12 /* LILITH_MEAN */,
3323
- lilithTrue: 13 /* LILITH_TRUE */
3323
+ lilithMean: 12 /* LILITH_MEAN */
3324
+ // lilithTrue: Planet.LILITH_TRUE,
3324
3325
  };
3325
3326
  const positions = {};
3326
3327
  for (const [name, id] of Object.entries(planets)) {
@@ -3406,36 +3407,65 @@ async function getBirthChart(options) {
3406
3407
  throw error;
3407
3408
  }
3408
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
+ ];
3409
3424
  function formatDegreeMinutes(decimalDegrees) {
3410
- const degrees = Math.floor(decimalDegrees);
3411
- const minutes = Math.round((decimalDegrees - degrees) * 60);
3412
- 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")}'`;
3413
3432
  }
3414
3433
  function getZodiacPosition(longitude) {
3415
- const signs = [
3416
- "Aries",
3417
- "Taurus",
3418
- "Gemini",
3419
- "Cancer",
3420
- "Leo",
3421
- "Virgo",
3422
- "Libra",
3423
- "Scorpio",
3424
- "Sagittarius",
3425
- "Capricorn",
3426
- "Aquarius",
3427
- "Pisces"
3428
- ];
3429
- const signIndex = Math.floor(longitude / 30) % 12;
3430
- const degrees = longitude % 30;
3434
+ const L = normalizeAngle(longitude);
3435
+ const signIndex = Math.floor(L / 30) % 12;
3436
+ const within = L - signIndex * 30;
3431
3437
  return {
3432
- sign: signs[signIndex],
3433
- decimalDegrees: degrees,
3434
- traditionalFormat: formatDegreeMinutes(degrees),
3435
- decimal: degrees.toFixed(2) + "\xB0"
3438
+ sign: SIGNS[signIndex],
3439
+ decimalDegrees: within,
3440
+ traditionalFormat: formatDegreeMinutes(within),
3441
+ decimal: within.toFixed(2) + "\xB0"
3436
3442
  };
3437
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
+ }
3438
3468
 
3439
- export { CalcFlag, HouseSystem, Planet, closeSwissEph, formatDegreeMinutes, getBirthChart, getSwissEph, getZodiacPosition };
3440
- //# sourceMappingURL=chunk-O2LE2NXP.mjs.map
3441
- //# sourceMappingURL=chunk-O2LE2NXP.mjs.map
3469
+ export { CalcFlag, HouseSystem, Planet, SIGNS, closeSwissEph, findHouseOf, formatDegreeMinutes, formatHouseCusps, getBirthChart, getSwissEph, getZodiacPosition, normalizeAngle };
3470
+ //# sourceMappingURL=chunk-S6GM43CR.mjs.map
3471
+ //# sourceMappingURL=chunk-S6GM43CR.mjs.map