kaabalah 3.1.0 → 3.2.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,25 @@ 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};
3076
3090
  var SwissEph = class {
3077
3091
  /**
3078
3092
  * Constructor that accepts a pre-initialized Swiss Ephemeris module
@@ -3084,13 +3098,17 @@ var SwissEph = class {
3084
3098
  this.swe_house_pos = null;
3085
3099
  this.swe_set_ephe_path = null;
3086
3100
  this.swe_close = null;
3101
+ this.swe_set_topo = null;
3102
+ this.swe_set_sid_mode = null;
3087
3103
  this.module = module;
3088
3104
  this.swe_julday = this.module.cwrap("swe_julday", "number", ["number", "number", "number", "number", "number"]);
3089
3105
  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"]);
3106
+ this.swe_houses = this.module.cwrap("swe_houses", "number", ["number", "number", "number", "number", "number", "number"]);
3091
3107
  this.swe_house_pos = this.module.cwrap("swe_house_pos", "number", ["number", "number", "number", "string", "number", "number"]);
3092
3108
  this.swe_set_ephe_path = this.module.cwrap("swe_set_ephe_path", null, ["number"]);
3093
3109
  this.swe_close = this.module.cwrap("swe_close", null, []);
3110
+ this.swe_set_topo = this.module.cwrap("swe_set_topo", null, ["number", "number", "number"]);
3111
+ this.swe_set_sid_mode = this.module.cwrap("swe_set_sid_mode", null, ["number", "number", "number"]);
3094
3112
  }
3095
3113
  checkInitialized() {
3096
3114
  if (!this.module) {
@@ -3149,7 +3167,7 @@ var SwissEph = class {
3149
3167
  latitude: this.module.getValue(resultPtr + 8, "double"),
3150
3168
  distance: this.module.getValue(resultPtr + 16, "double")
3151
3169
  };
3152
- if (flags & 32 /* SPEED */) {
3170
+ if (flags & 256 /* SPEED */) {
3153
3171
  position.longitudeSpeed = this.module.getValue(resultPtr + 24, "double");
3154
3172
  position.latitudeSpeed = this.module.getValue(resultPtr + 32, "double");
3155
3173
  position.distanceSpeed = this.module.getValue(resultPtr + 40, "double");
@@ -3181,7 +3199,8 @@ var SwissEph = class {
3181
3199
  const housesPtr = memoryPtr;
3182
3200
  const ascmcPtr = memoryPtr + 12 * 8;
3183
3201
  try {
3184
- const ret = this.swe_houses(julday, latitude, longitude, hsys.toString(), housesPtr, ascmcPtr);
3202
+ const hsysCode = hsys.charCodeAt(0);
3203
+ const ret = this.swe_houses(julday, latitude, longitude, hsysCode, housesPtr, ascmcPtr);
3185
3204
  if (ret < 0) {
3186
3205
  throw new Error(`Houses calculation failed with error code ${ret}`);
3187
3206
  }
@@ -3190,9 +3209,27 @@ var SwissEph = class {
3190
3209
  const value = this.module.getValue(housesPtr + i * 8, "double");
3191
3210
  houses.push(value);
3192
3211
  }
3193
- const ascendant = this.module.getValue(ascmcPtr, "double");
3212
+ const ascendant = this.module.getValue(ascmcPtr + 0, "double");
3194
3213
  const mc = this.module.getValue(ascmcPtr + 8, "double");
3195
- return { ascendant, mc, houses };
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");
3220
+ return {
3221
+ ascendant,
3222
+ mc,
3223
+ houses,
3224
+ ascmc: {
3225
+ armc,
3226
+ vertex,
3227
+ equasc,
3228
+ coasc1,
3229
+ coasc2,
3230
+ polasc
3231
+ }
3232
+ };
3196
3233
  } finally {
3197
3234
  this.module._free(memoryPtr);
3198
3235
  }
@@ -3206,10 +3243,42 @@ var SwissEph = class {
3206
3243
  this.swe_close();
3207
3244
  }
3208
3245
  }
3246
+ /**
3247
+ * Set topocentric observer
3248
+ */
3249
+ setTopocentric(longitude, latitude, altitudeMeters = 0) {
3250
+ this.checkInitialized();
3251
+ if (!this.swe_set_topo) {
3252
+ throw new Error("Topocentric calculation function not available");
3253
+ }
3254
+ this.swe_set_topo(longitude, latitude, altitudeMeters);
3255
+ }
3256
+ /**
3257
+ * Set sidereal mode
3258
+ * Ex.: mode=1 (Lahiri). See Swiss Ephemeris mode table.
3259
+ */
3260
+ setSiderealMode(mode, t0 = 0, ayan_t0 = 0) {
3261
+ this.checkInitialized();
3262
+ this.swe_set_sid_mode?.(mode, t0, ayan_t0);
3263
+ }
3264
+ /**
3265
+ * Asteroid by MPC number
3266
+ */
3267
+ calculateAsteroidPosition(julday, mpcNumber, flags = 2 /* SWISS_EPH */) {
3268
+ return this.calculatePlanetPosition(julday, SE_AST_OFFSET + mpcNumber, flags);
3269
+ }
3270
+ /**
3271
+ * Lilith mean (12) and true (13)
3272
+ */
3273
+ calculateLilith(julday, kind = "mean", flags = 2 /* SWISS_EPH */) {
3274
+ const id = kind === "mean" ? BODY.MEAN_APOGEE : BODY.OSC_APOGEE;
3275
+ return this.calculatePlanetPosition(julday, id, flags);
3276
+ }
3209
3277
  };
3210
3278
 
3211
3279
  // src/astrology/swisseph.ts
3212
3280
  var swissEph = null;
3281
+ var DEFAULT_FLAGS = 2 /* SWISS_EPH */ | 256 /* SPEED */;
3213
3282
  async function getSwissEph(options = {}) {
3214
3283
  if (swissEph) {
3215
3284
  return;
@@ -3234,6 +3303,7 @@ async function calculatePlanetaryPositions(date) {
3234
3303
  try {
3235
3304
  checkInitialization();
3236
3305
  const julday = swissEph.getJulianDay(date);
3306
+ const flags = DEFAULT_FLAGS;
3237
3307
  const planets = {
3238
3308
  sun: 0 /* SUN */,
3239
3309
  moon: 1 /* MOON */,
@@ -3241,12 +3311,21 @@ async function calculatePlanetaryPositions(date) {
3241
3311
  venus: 3 /* VENUS */,
3242
3312
  mars: 4 /* MARS */,
3243
3313
  jupiter: 5 /* JUPITER */,
3244
- saturn: 6 /* SATURN */
3314
+ saturn: 6 /* SATURN */,
3315
+ uranus: 7 /* URANUS */,
3316
+ neptune: 8 /* NEPTUNE */,
3317
+ pluto: 9 /* PLUTO */,
3318
+ meanNode: 10 /* MEAN_NODE */,
3319
+ trueNode: 11 /* TRUE_NODE */,
3320
+ // TODO: add chiron through seas_18.se1, seas_18.se2 and seasnam.txt files
3321
+ // chiron: Planet.CHIRON,
3322
+ lilithMean: 12 /* LILITH_MEAN */,
3323
+ lilithTrue: 13 /* LILITH_TRUE */
3245
3324
  };
3246
3325
  const positions = {};
3247
3326
  for (const [name, id] of Object.entries(planets)) {
3248
3327
  try {
3249
- positions[name] = swissEph.calculatePlanetPosition(julday, id);
3328
+ positions[name] = swissEph.calculatePlanetPosition(julday, id, flags);
3250
3329
  } catch (error) {
3251
3330
  throw new Error(`Failed to calculate position for ${name}: ${error}`);
3252
3331
  }
@@ -3358,5 +3437,5 @@ function getZodiacPosition(longitude) {
3358
3437
  }
3359
3438
 
3360
3439
  export { CalcFlag, HouseSystem, Planet, closeSwissEph, formatDegreeMinutes, getBirthChart, getSwissEph, getZodiacPosition };
3361
- //# sourceMappingURL=chunk-AV7WBVPS.mjs.map
3362
- //# sourceMappingURL=chunk-AV7WBVPS.mjs.map
3440
+ //# sourceMappingURL=chunk-O2LE2NXP.mjs.map
3441
+ //# sourceMappingURL=chunk-O2LE2NXP.mjs.map