@zodiacs/engine 1.0.0 → 1.1.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.
Files changed (70) hide show
  1. package/CHANGELOG.md +1020 -0
  2. package/LICENSING.md +168 -27
  3. package/NOTICE +78 -12
  4. package/README.md +288 -44
  5. package/dist/{api-WbxJ4Wj-.d.ts → api-ChL1N2Sr.d.ts} +33 -2
  6. package/dist/{ayanamsa--YQ46fET.d.ts → ayanamsa-ClFzkKmV.d.ts} +2 -1
  7. package/dist/calc.d.ts +90 -4
  8. package/dist/calc.js +360 -126
  9. package/dist/chunk-2PZYJQV5.js +83 -0
  10. package/dist/{chunk-7TRLIFFI.js → chunk-4XOYTBLS.js} +1 -1
  11. package/dist/chunk-767FTO7O.js +48 -0
  12. package/dist/{chunk-YIITY7Q7.js → chunk-7Y2F2IWN.js} +19 -17
  13. package/dist/{chunk-OG4OYTJJ.js → chunk-B4M2Y7FT.js} +1 -129
  14. package/dist/{chunk-PFGUCNOK.js → chunk-BMDASNPB.js} +6 -6
  15. package/dist/chunk-I3L4POY7.js +18 -0
  16. package/dist/{chunk-CHSYDKBL.js → chunk-LNGURVNH.js} +3 -3
  17. package/dist/{chunk-DMGHYCDI.js → chunk-NNOSOOWS.js} +1 -1
  18. package/dist/chunk-OVXQQEXL.js +41 -0
  19. package/dist/{chunk-SRXBTP5H.js → chunk-QLIEEICB.js} +201 -190
  20. package/dist/chunk-RMBWKZI2.js +130 -0
  21. package/dist/{chunk-FTX3JDJA.js → chunk-TZVPZHZM.js} +42 -23
  22. package/dist/{chunk-WS3TDSP3.js → chunk-WBTWY2OB.js} +7 -3
  23. package/dist/chunk-Y4E3WJU5.js +87 -0
  24. package/dist/chunk-YPU3MDNI.js +852 -0
  25. package/dist/conventions.d.ts +70 -0
  26. package/dist/conventions.js +26 -0
  27. package/dist/crossings.d.ts +15 -4
  28. package/dist/de440-pack.d.ts +43 -0
  29. package/dist/de440-pack.js +16 -0
  30. package/dist/de440.d.ts +113 -0
  31. package/dist/de440.js +19 -0
  32. package/dist/ephemeris-exTSqBgb.d.ts +60 -0
  33. package/dist/geo.d.ts +16 -4
  34. package/dist/geo.js +2 -2
  35. package/dist/{houses-CFERsAlK.d.ts → houses-Bh7GCnPi.d.ts} +3 -3
  36. package/dist/houses-extra.d.ts +5 -4
  37. package/dist/index.d.ts +8 -6
  38. package/dist/index.js +40 -28
  39. package/dist/{internal-math-DJJ8BYex.d.ts → internal-math-CxenuGfm.d.ts} +2 -2
  40. package/dist/internal-math.d.ts +4 -3
  41. package/dist/internal-math.js +14 -12
  42. package/dist/internal.d.ts +16 -7
  43. package/dist/internal.js +25 -4
  44. package/dist/lite-composite.js +114 -0
  45. package/dist/lite-declinations.js +253 -0
  46. package/dist/lite-dignities.js +333 -0
  47. package/dist/lite-sect.js +72 -0
  48. package/dist/lite.d.ts +82 -0
  49. package/dist/lite.js +4 -0
  50. package/dist/receipt.d.ts +3 -2
  51. package/dist/receipt.js +143 -65
  52. package/dist/{rulers-Dla6h_Sm.d.ts → rulers-CSSWtiWF.d.ts} +1 -1
  53. package/dist/sky.d.ts +4 -3
  54. package/dist/sky.js +17 -10
  55. package/dist/techniques.d.ts +102 -6
  56. package/dist/techniques.js +131 -56
  57. package/dist/time-bands-CZA9AlLg.d.ts +36 -0
  58. package/dist/time-scale-DIFNa0gz.d.ts +47 -0
  59. package/dist/time.d.ts +81 -0
  60. package/dist/time.js +74 -0
  61. package/dist/timing.d.ts +6 -5
  62. package/dist/timing.js +24 -17
  63. package/dist/types-DpPdtXgO.d.ts +335 -0
  64. package/dist/vedic.d.ts +112 -4
  65. package/dist/vedic.js +369 -14
  66. package/dist/window.d.ts +22 -2
  67. package/dist/window.js +86 -28
  68. package/dist/{zone-history-ghdyO0Sc.d.ts → zone-history-BxmDCcTK.d.ts} +32 -10
  69. package/package.json +24 -3
  70. package/dist/types-B-yb_tGL.d.ts +0 -240
@@ -6,7 +6,7 @@ import {
6
6
  } from "./chunk-KFTJMMG7.js";
7
7
  import {
8
8
  validateBirthSettings
9
- } from "./chunk-PFGUCNOK.js";
9
+ } from "./chunk-BMDASNPB.js";
10
10
 
11
11
  // src/geo/calendar.ts
12
12
  var GREGORIAN_ADOPTION_SOURCES = /* @__PURE__ */ Object.freeze({
@@ -243,7 +243,7 @@ function firstChange(clockAt, lo, hi) {
243
243
  }
244
244
  return hi;
245
245
  }
246
- function readClock(wallMs, clockAt, samples) {
246
+ function readClock(wallMs, clockAt, samples, fold) {
247
247
  const readings = [];
248
248
  for (const offset of new Set(samples.map(clockAt))) {
249
249
  const utcMs2 = wallMs - offset * 1e3;
@@ -253,7 +253,7 @@ function readClock(wallMs, clockAt, samples) {
253
253
  }
254
254
  const [first, second] = readings.sort((a, b) => a.utcMs - b.utcMs);
255
255
  if (first) {
256
- return second ? { chosen: first, kind: "fold", at: firstChange(clockAt, first.utcMs, second.utcMs) } : { chosen: first, kind: null, at: null };
256
+ return second ? { chosen: fold === "later" ? second : first, kind: "fold", at: firstChange(clockAt, first.utcMs, second.utcMs) } : { chosen: first, kind: null, at: null };
257
257
  }
258
258
  let lo = wallMs - PROBE - DAY;
259
259
  let hi = wallMs + PROBE + DAY;
@@ -290,15 +290,14 @@ function birthplaceClock(history, wallMs, longitude, zoneAt) {
290
290
  lineEnds: era.slice(0, -1).map(([until]) => until)
291
291
  };
292
292
  }
293
- function readOptions(options) {
294
- if (options === void 0) return { calendar: "gregorian" };
293
+ function readOptions(options = {}) {
295
294
  if (!options || typeof options !== "object" || Array.isArray(options)) {
296
295
  throw new RangeError("options must be an object.");
297
296
  }
298
297
  for (const key of Object.getOwnPropertyNames(options)) {
299
- if (!["longitude", "calendar", "country"].includes(key)) throw new RangeError(`Unknown local time option "${key}".`);
298
+ if (!["longitude", "calendar", "country", "fold"].includes(key)) throw new RangeError(`Unknown local time option "${key}".`);
300
299
  }
301
- const { longitude, calendar = "gregorian", country } = options;
300
+ const { longitude, calendar = "gregorian", country, fold = "earlier" } = options;
302
301
  if (longitude !== void 0 && !(typeof longitude === "number" && Math.abs(longitude) <= 180)) {
303
302
  throw new RangeError("longitude must be between -180 and 180 degrees.");
304
303
  }
@@ -306,12 +305,13 @@ function readOptions(options) {
306
305
  if (country !== void 0 && (typeof country !== "string" || !country.trim())) {
307
306
  throw new RangeError("country must be a nonempty string.");
308
307
  }
309
- return { longitude, calendar, country };
308
+ if (fold !== "earlier" && fold !== "later") throw new RangeError('fold must be "earlier" or "later".');
309
+ return { longitude, calendar, country, fold };
310
310
  }
311
311
  var pad = (value, width = 2) => String(value).padStart(width, "0");
312
312
  function resolveLocalToUtc(date, time, timeZone, options) {
313
313
  offsetFormatter(timeZone);
314
- const { longitude, calendar, country } = readOptions(options);
314
+ const { longitude, calendar, country, fold } = readOptions(options);
315
315
  const written = parseCalendarDate(date, calendar);
316
316
  const hhmm = typeof time === "string" ? /^([01]\d|2[0-3]):([0-5]\d)$/u.exec(time) : null;
317
317
  if (!written || !hhmm) {
@@ -330,8 +330,8 @@ function resolveLocalToUtc(date, time, timeZone, options) {
330
330
  const place = longitude !== void 0 && history ? birthplaceClock(history, wallMs, longitude, zoneAt) : null;
331
331
  const samples = [wallMs - PROBE, wallMs, wallMs + PROBE, ...place ? [place.endMs - 1, place.endMs, place.legalFrom] : []];
332
332
  const clockAt = place ? place.clockAt : zoneAt;
333
- const zoneReading = readClock(wallMs, zoneAt, samples);
334
- const reading = place ? readClock(wallMs, clockAt, samples) : zoneReading;
333
+ const zoneReading = readClock(wallMs, zoneAt, samples, fold);
334
+ const reading = place ? readClock(wallMs, clockAt, samples, fold) : zoneReading;
335
335
  const { chosen, kind } = reading;
336
336
  const inEra = !!place && chosen.utcMs < place.endMs;
337
337
  const count = history && chosen.utcMs < 0 ? typeIndexAt(history, chosen.utcMs) : -1;
@@ -358,7 +358,7 @@ function resolveLocalToUtc(date, time, timeZone, options) {
358
358
  };
359
359
  }
360
360
  const lmt = inEra || !place && history?.zoneEraEnd != null && chosen.utcMs < history.zoneEraEnd;
361
- const flags = kind ? [kind === "gap" ? "dst-gap" : "dst-fold"] : [];
361
+ const flags = kind ? [`dst-${kind}`] : [];
362
362
  if (lmt) flags.push("lmt");
363
363
  const localMeanTime = longitude !== void 0 && place && (inEra || kind === "gap" && reading.at === place.endMs) ? { longitude, zoneOffsetMinutes: zoneReading.chosen.offset / 60 } : null;
364
364
  const zone = shipped ? {
@@ -388,7 +388,7 @@ function resolveLocalToUtc(date, time, timeZone, options) {
388
388
  timeZone,
389
389
  offsetMinutes,
390
390
  gapShiftMinutes: kind === "gap" && transition ? transition.offsetAfterMinutes - transition.offsetBeforeMinutes : 0,
391
- policy: { fold: "earlier", gap: "shift-forward" },
391
+ policy: { fold: kind === "fold" ? fold : "earlier", gap: "shift-forward" },
392
392
  calendar,
393
393
  writtenDate: date,
394
394
  tzdbVersion: zone.tzdbVersion,
@@ -430,7 +430,8 @@ var LOCAL_BIRTH_KEYS = [
430
430
  "houseSystem",
431
431
  "timeKnown",
432
432
  "calendar",
433
- "country"
433
+ "country",
434
+ "fold"
434
435
  ];
435
436
  function resolveLocalBirth(input) {
436
437
  if (!input || typeof input !== "object" || Array.isArray(input)) {
@@ -441,15 +442,16 @@ function resolveLocalBirth(input) {
441
442
  }
442
443
  const fields = Object.fromEntries(LOCAL_BIRTH_KEYS.map((key) => [key, input[key]]));
443
444
  const settings = validateBirthSettings(fields);
444
- const time = fields.time;
445
+ const { time, calendar, country, fold } = fields;
445
446
  const timeKnown = settings.timeKnown ?? time !== void 0;
446
447
  if (timeKnown && time === void 0) {
447
448
  throw new RangeError("time is required when timeKnown is true.");
448
449
  }
449
450
  const resolution = resolveLocalToUtc(fields.date, time === void 0 ? "12:00" : time, fields.timeZone, {
450
451
  longitude: settings.longitude,
451
- calendar: fields.calendar,
452
- country: fields.country
452
+ calendar,
453
+ country,
454
+ fold
453
455
  });
454
456
  return {
455
457
  birth: {
@@ -77,127 +77,8 @@ function findAspects(bodies) {
77
77
  return aspects.sort((a, b) => a.orb - b.orb);
78
78
  }
79
79
 
80
- // src/signs.ts
81
- var ELEMENTS = /* @__PURE__ */ Object.freeze(["fire", "earth", "air", "water"]);
82
- var MODALITIES = /* @__PURE__ */ Object.freeze(["cardinal", "fixed", "mutable"]);
83
- var SIGNS = /* @__PURE__ */ Object.freeze([
84
- /* @__PURE__ */ Object.freeze({
85
- slug: "aries",
86
- name: "Aries",
87
- element: "fire",
88
- modality: "cardinal",
89
- polarity: "day",
90
- naturalHouse: 1
91
- }),
92
- /* @__PURE__ */ Object.freeze({
93
- slug: "taurus",
94
- name: "Taurus",
95
- element: "earth",
96
- modality: "fixed",
97
- polarity: "night",
98
- naturalHouse: 2
99
- }),
100
- /* @__PURE__ */ Object.freeze({
101
- slug: "gemini",
102
- name: "Gemini",
103
- element: "air",
104
- modality: "mutable",
105
- polarity: "day",
106
- naturalHouse: 3
107
- }),
108
- /* @__PURE__ */ Object.freeze({
109
- slug: "cancer",
110
- name: "Cancer",
111
- element: "water",
112
- modality: "cardinal",
113
- polarity: "night",
114
- naturalHouse: 4
115
- }),
116
- /* @__PURE__ */ Object.freeze({
117
- slug: "leo",
118
- name: "Leo",
119
- element: "fire",
120
- modality: "fixed",
121
- polarity: "day",
122
- naturalHouse: 5
123
- }),
124
- /* @__PURE__ */ Object.freeze({
125
- slug: "virgo",
126
- name: "Virgo",
127
- element: "earth",
128
- modality: "mutable",
129
- polarity: "night",
130
- naturalHouse: 6
131
- }),
132
- /* @__PURE__ */ Object.freeze({
133
- slug: "libra",
134
- name: "Libra",
135
- element: "air",
136
- modality: "cardinal",
137
- polarity: "day",
138
- naturalHouse: 7
139
- }),
140
- /* @__PURE__ */ Object.freeze({
141
- slug: "scorpio",
142
- name: "Scorpio",
143
- element: "water",
144
- modality: "fixed",
145
- polarity: "night",
146
- naturalHouse: 8
147
- }),
148
- /* @__PURE__ */ Object.freeze({
149
- slug: "sagittarius",
150
- name: "Sagittarius",
151
- element: "fire",
152
- modality: "mutable",
153
- polarity: "day",
154
- naturalHouse: 9
155
- }),
156
- /* @__PURE__ */ Object.freeze({
157
- slug: "capricorn",
158
- name: "Capricorn",
159
- element: "earth",
160
- modality: "cardinal",
161
- polarity: "night",
162
- naturalHouse: 10
163
- }),
164
- /* @__PURE__ */ Object.freeze({
165
- slug: "aquarius",
166
- name: "Aquarius",
167
- element: "air",
168
- modality: "fixed",
169
- polarity: "day",
170
- naturalHouse: 11
171
- }),
172
- /* @__PURE__ */ Object.freeze({
173
- slug: "pisces",
174
- name: "Pisces",
175
- element: "water",
176
- modality: "mutable",
177
- polarity: "night",
178
- naturalHouse: 12
179
- })
180
- ]);
181
- var SIGN_SLUGS = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ SIGNS.map((sign) => sign.slug));
182
- var SIGN_NAMES = SIGN_SLUGS;
183
- function normalizeLongitude(lon) {
184
- if (!Number.isFinite(lon)) throw new RangeError("Longitude must be finite.");
185
- return (lon % 360 + 360) % 360;
186
- }
187
- function signIndexForLongitude(lon) {
188
- return Math.floor(normalizeLongitude(lon) / 30);
189
- }
190
- function signForLongitude(lon) {
191
- const sign = SIGNS[signIndexForLongitude(lon)];
192
- if (!sign) throw new RangeError("Could not resolve zodiac sign.");
193
- return sign;
194
- }
195
- function degreeInSign(lon) {
196
- return normalizeLongitude(lon) % 30;
197
- }
198
-
199
80
  // src/types.ts
200
- var ENGINE_VERSION = "1.0.0";
81
+ var ENGINE_VERSION = "1.1.0";
201
82
  var EPHEMERIS = /* @__PURE__ */ Object.freeze({ name: "astronomy-engine", version: "2.1.19" });
202
83
 
203
84
  export {
@@ -210,15 +91,6 @@ export {
210
91
  separation,
211
92
  matchAspect,
212
93
  findAspects,
213
- ELEMENTS,
214
- MODALITIES,
215
- SIGNS,
216
- SIGN_SLUGS,
217
- SIGN_NAMES,
218
- normalizeLongitude,
219
- signIndexForLongitude,
220
- signForLongitude,
221
- degreeInSign,
222
94
  ENGINE_VERSION,
223
95
  EPHEMERIS
224
96
  };
@@ -41,15 +41,15 @@ function validateBirthSettings(birth) {
41
41
  ...latitude === void 0 ? {} : { latitude, longitude }
42
42
  };
43
43
  }
44
- var FLAGS = [
45
- "dst-gap",
46
- "dst-fold",
47
- "lmt",
44
+ var DERIVED_FLAGS = [
48
45
  "no-time",
49
46
  "polar-fallback",
50
- "outside-reference-span"
47
+ "outside-reference-span",
48
+ "delta-t-extrapolated",
49
+ "de440-unavailable",
50
+ "outside-de440-span"
51
51
  ];
52
- var DERIVED_FLAGS = ["no-time", "polar-fallback", "outside-reference-span"];
52
+ var FLAGS = ["dst-gap", "dst-fold", "lmt", ...DERIVED_FLAGS];
53
53
  function snapshotFlags(value) {
54
54
  const length = Array.isArray(value) ? Object.getOwnPropertyDescriptor(value, "length")?.value : void 0;
55
55
  if (typeof length !== "number" || !Number.isInteger(length) || length < 0 || length > 64) {
@@ -0,0 +1,18 @@
1
+ // src/time-bands.ts
2
+ var isBand = (value) => typeof value === "number" && value >= 0 && value <= 1e10;
3
+ function timeBands(record) {
4
+ const { deltaT, timeScale } = Object(record);
5
+ const { input, basis, ut1MinusUtc } = Object(timeScale);
6
+ const d = deltaT?.sigma === null ? 0 : deltaT?.sigma;
7
+ const u = ut1MinusUtc === null ? 0 : ut1MinusUtc?.sigma;
8
+ if (!isBand(d) || !isBand(u) || !["utc", "ut1", "tt"].includes(input) || !["iers", "delta-t", "pinned"].includes(basis)) {
9
+ throw new RangeError("timeBands takes the deltaT and timeScale that a time basis, a chart or a calc instant records.");
10
+ }
11
+ if (input === "tt") return { tt: 0, ut1: d };
12
+ if (input === "ut1") return { tt: d, ut1: 0 };
13
+ return { tt: basis === "iers" ? 0 : basis === "pinned" ? u : Math.hypot(u, d), ut1: u };
14
+ }
15
+
16
+ export {
17
+ timeBands
18
+ };
@@ -1,9 +1,9 @@
1
+ import {
2
+ computeBodies
3
+ } from "./chunk-QLIEEICB.js";
1
4
  import {
2
5
  dateFrom
3
6
  } from "./chunk-CPALRSPC.js";
4
- import {
5
- computeBodies
6
- } from "./chunk-SRXBTP5H.js";
7
7
 
8
8
  // src/progressions.ts
9
9
  var PROGRESSION_DAYS_PER_YEAR = 365.2422;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  normalizeLongitude
3
- } from "./chunk-OG4OYTJJ.js";
3
+ } from "./chunk-RMBWKZI2.js";
4
4
 
5
5
  // src/houses.ts
6
6
  var DEG = Math.PI / 180;
@@ -0,0 +1,41 @@
1
+ // src/convention-ids.ts
2
+ var NAMESPACE = /^[A-Za-z][A-Za-z0-9-]*$/u;
3
+ var VALUE = /^[^\s\p{Cc}\p{Cf}\p{Cs}]+$/u;
4
+ function conventionId(namespace, value) {
5
+ if (typeof namespace !== "string" || !NAMESPACE.test(namespace))
6
+ throw new RangeError("A convention namespace is a letter, then letters, digits or hyphens.");
7
+ if (typeof value !== "string" || !VALUE.test(value))
8
+ throw new RangeError("A convention value is not empty and has no white space, control character or lone surrogate.");
9
+ return `${namespace}:${value}`;
10
+ }
11
+ function natalConventionIds(envelope) {
12
+ const { receipt, result } = envelope;
13
+ const ids = /* @__PURE__ */ new Set();
14
+ for (const fields of [receipt.conventions, receipt.coverage])
15
+ for (const [key, value] of Object.entries(fields)) ids.add(conventionId(key, value));
16
+ const { requested, actual, absenceReason } = receipt.houses;
17
+ for (const system of [requested, actual]) if (system !== null) ids.add(conventionId("house", system));
18
+ if (absenceReason !== null) ids.add(conventionId("house-absence", absenceReason));
19
+ for (const flag of [...receipt.inputFlags, ...receipt.resultFlags]) ids.add(conventionId("flag", flag));
20
+ ids.add(conventionId("reference", receipt.reference));
21
+ if (receipt.timeScale !== void 0) ids.add(conventionId("time-scale", receipt.timeScale));
22
+ const ephemeris = receipt.engine.ephemeris;
23
+ if (ephemeris !== void 0)
24
+ ids.add(conventionId("ephemeris", `${ephemeris.name}@${ephemeris.version}`));
25
+ if (result.deltaT !== void 0) {
26
+ ids.add(conventionId("deltat-model", result.deltaT.model));
27
+ ids.add(conventionId("deltat-segment", result.deltaT.segment));
28
+ }
29
+ if (result.timeScale !== void 0) {
30
+ ids.add(conventionId("time-scale", result.timeScale.input));
31
+ ids.add(conventionId("time-basis", result.timeScale.basis));
32
+ if (result.timeScale.ut1MinusUtc !== null)
33
+ ids.add(conventionId("ut1-source", result.timeScale.ut1MinusUtc.source));
34
+ }
35
+ return [...ids].sort();
36
+ }
37
+
38
+ export {
39
+ conventionId,
40
+ natalConventionIds
41
+ };