@zodiacs/engine 0.1.1-rc.14 → 0.1.1-rc.16
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.
- package/CHANGELOG.md +797 -6
- package/LICENSING.md +354 -21
- package/NOTICE +166 -9
- package/README.md +327 -84
- package/dist/api-VOW6Umy5.d.ts +197 -0
- package/dist/calc.d.ts +279 -0
- package/dist/calc.js +853 -0
- package/dist/{chunk-NAJ735VN.js → chunk-2OWGBT3O.js} +1 -1
- package/dist/{chunk-4OSOCZY2.js → chunk-4NV4ZEFZ.js} +21 -6
- package/dist/chunk-A3U2ZS2W.js +29 -0
- package/dist/chunk-I7O5EGFV.js +25 -0
- package/dist/chunk-KFTJMMG7.js +61 -0
- package/dist/chunk-KHBLFXFG.js +227 -0
- package/dist/chunk-L6ZHWJZ6.js +355 -0
- package/dist/chunk-N4B5JNMA.js +473 -0
- package/dist/chunk-O3NJRGJ2.js +56 -0
- package/dist/{chunk-RETEVD4F.js → chunk-WOU7JVD3.js} +293 -154
- package/dist/crossings.d.ts +1 -1
- package/dist/deltat.d.ts +8 -8
- package/dist/geo.d.ts +137 -8
- package/dist/geo.js +28 -166
- package/dist/houses-extra.d.ts +81 -0
- package/dist/houses-extra.js +337 -0
- package/dist/houses-q1O2GGp4.d.ts +128 -0
- package/dist/index.d.ts +8 -201
- package/dist/index.js +38 -315
- package/dist/internal-math-CmJ9xtaW.d.ts +160 -0
- package/dist/internal-math.d.ts +3 -2
- package/dist/internal-math.js +2 -2
- package/dist/internal.d.ts +2 -1
- package/dist/internal.js +4 -4
- package/dist/receipt.d.ts +74 -29
- package/dist/receipt.js +194 -33
- package/dist/rulers-9wljfVaO.d.ts +10 -0
- package/dist/sky.d.ts +158 -0
- package/dist/sky.js +377 -0
- package/dist/techniques.d.ts +410 -0
- package/dist/techniques.js +830 -0
- package/dist/timing.d.ts +473 -0
- package/dist/timing.js +904 -0
- package/dist/{types-CeafogFp.d.ts → types-B4MCoCCS.d.ts} +35 -4
- package/dist/tzdb-2025c-00-6GVG6RYL.js +6 -0
- package/dist/tzdb-2025c-01-CEYMG3LE.js +6 -0
- package/dist/tzdb-2025c-02-NWQJCVUU.js +6 -0
- package/dist/tzdb-2025c-03-PLHP6VH4.js +6 -0
- package/dist/tzdb-2025c-04-MEKUJA6M.js +6 -0
- package/dist/tzdb-2025c-05-3K5YKZBL.js +6 -0
- package/dist/tzdb-2025c-06-L2VV5XJV.js +6 -0
- package/dist/tzdb-2025c-07-H3GLGJGY.js +6 -0
- package/dist/tzdb-2025c-08-DA7QQIGD.js +6 -0
- package/dist/tzdb-2025c-09-MTXIO3QL.js +6 -0
- package/dist/tzdb-2025c-10-ASL4UW5C.js +6 -0
- package/dist/tzdb-2025c-11-EQEOANYB.js +6 -0
- package/dist/tzdb-2025c-12-NKCCXJ5G.js +6 -0
- package/dist/tzdb-2025c-13-DYTF3UC7.js +6 -0
- package/dist/tzdb-2025c-14-C25H45R5.js +6 -0
- package/dist/tzdb-2025c-15-7OYYZWRY.js +6 -0
- package/dist/vedic.d.ts +393 -0
- package/dist/vedic.js +930 -0
- package/dist/window.d.ts +178 -0
- package/dist/window.js +961 -0
- package/package.json +31 -3
- package/dist/chunk-GFT24GFR.js +0 -25
- package/dist/internal-math-BE2hcSHd.d.ts +0 -271
|
@@ -0,0 +1,355 @@
|
|
|
1
|
+
import {
|
|
2
|
+
dateFrom
|
|
3
|
+
} from "./chunk-CPALRSPC.js";
|
|
4
|
+
import {
|
|
5
|
+
findLongitudeCrossingsWith,
|
|
6
|
+
searchLongitudeCrossingsWith
|
|
7
|
+
} from "./chunk-AECKV73C.js";
|
|
8
|
+
import {
|
|
9
|
+
assertDerivedFlags,
|
|
10
|
+
snapshotFlags,
|
|
11
|
+
timeFlags,
|
|
12
|
+
validateBirthSettings
|
|
13
|
+
} from "./chunk-PFGUCNOK.js";
|
|
14
|
+
import {
|
|
15
|
+
SPEED_STEP_DAYS,
|
|
16
|
+
bodyLongitude,
|
|
17
|
+
computeBodies,
|
|
18
|
+
computeChart,
|
|
19
|
+
computeChartDeclinations,
|
|
20
|
+
computePoints,
|
|
21
|
+
longitudeSpeed
|
|
22
|
+
} from "./chunk-WOU7JVD3.js";
|
|
23
|
+
import {
|
|
24
|
+
TIME_SCALE_NAMES,
|
|
25
|
+
outsideReferenceSpan,
|
|
26
|
+
timeBasis
|
|
27
|
+
} from "./chunk-KHBLFXFG.js";
|
|
28
|
+
import {
|
|
29
|
+
POLAR_FALLBACK,
|
|
30
|
+
isPolarUndefinedHouseSystem
|
|
31
|
+
} from "./chunk-4NV4ZEFZ.js";
|
|
32
|
+
import {
|
|
33
|
+
ASPECT_BODIES,
|
|
34
|
+
matchAspect,
|
|
35
|
+
normalizeLongitude,
|
|
36
|
+
signForLongitude
|
|
37
|
+
} from "./chunk-2OWGBT3O.js";
|
|
38
|
+
|
|
39
|
+
// src/returns.ts
|
|
40
|
+
var DAY = 864e5;
|
|
41
|
+
function validMilliseconds(date, label) {
|
|
42
|
+
if (!(date instanceof Date)) throw new RangeError(`${label} must be a valid Date.`);
|
|
43
|
+
const milliseconds = Date.prototype.getTime.call(date);
|
|
44
|
+
if (!Number.isFinite(milliseconds)) throw new RangeError(`${label} must be a valid Date.`);
|
|
45
|
+
return milliseconds;
|
|
46
|
+
}
|
|
47
|
+
function findLongitudeCrossings(body, targetLongitude, from, to, stepDays = 5) {
|
|
48
|
+
return findLongitudeCrossingsWith(bodyLongitude, body, targetLongitude, from, to, stepDays);
|
|
49
|
+
}
|
|
50
|
+
function searchLongitudeCrossings(body, targetLongitude, from, to, options) {
|
|
51
|
+
return searchLongitudeCrossingsWith(bodyLongitude, body, targetLongitude, from, to, options);
|
|
52
|
+
}
|
|
53
|
+
function groupIntoSeasons(crossings, gapDays = 400) {
|
|
54
|
+
if (!Number.isFinite(gapDays) || gapDays <= 0) {
|
|
55
|
+
throw new RangeError("gapDays must be positive.");
|
|
56
|
+
}
|
|
57
|
+
const seasons = [];
|
|
58
|
+
for (const crossing of crossings) {
|
|
59
|
+
const current = seasons.at(-1);
|
|
60
|
+
if (current && crossing.at.getTime() - current.last.getTime() <= gapDays * DAY) {
|
|
61
|
+
current.crossings.push(crossing);
|
|
62
|
+
current.last = crossing.at;
|
|
63
|
+
} else {
|
|
64
|
+
seasons.push({
|
|
65
|
+
index: seasons.length + 1,
|
|
66
|
+
crossings: [crossing],
|
|
67
|
+
first: crossing.at,
|
|
68
|
+
last: crossing.at
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return seasons;
|
|
73
|
+
}
|
|
74
|
+
function computeSaturnReturns(birthUtc) {
|
|
75
|
+
const birthTime = validMilliseconds(birthUtc, "Birth date");
|
|
76
|
+
const before = new Date(birthTime - SPEED_STEP_DAYS * DAY);
|
|
77
|
+
const after = new Date(birthTime + SPEED_STEP_DAYS * DAY);
|
|
78
|
+
const from = new Date(birthTime + 26 * 365.25 * DAY);
|
|
79
|
+
const to = new Date(birthTime + 92 * 365.25 * DAY);
|
|
80
|
+
validMilliseconds(before, "Natal speed window start");
|
|
81
|
+
validMilliseconds(after, "Natal speed window end");
|
|
82
|
+
validMilliseconds(from, "Saturn return window start");
|
|
83
|
+
validMilliseconds(to, "Saturn return window end");
|
|
84
|
+
const natalLon = bodyLongitude("Saturn", birthUtc);
|
|
85
|
+
const speed = longitudeSpeed("Saturn", birthUtc);
|
|
86
|
+
return {
|
|
87
|
+
natalLon,
|
|
88
|
+
natalRetrograde: speed < 0,
|
|
89
|
+
seasons: groupIntoSeasons(findLongitudeCrossings("Saturn", natalLon, from, to))
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// src/synastry.ts
|
|
94
|
+
function findInterAspects(first, second) {
|
|
95
|
+
const aBodies = first.filter((body) => ASPECT_BODIES.has(body.body));
|
|
96
|
+
const bBodies = second.filter((body) => ASPECT_BODIES.has(body.body));
|
|
97
|
+
const aspects = [];
|
|
98
|
+
for (const a of aBodies) {
|
|
99
|
+
for (const b of bBodies) {
|
|
100
|
+
const match = matchAspect(a.body, a.lon, b.body, b.lon);
|
|
101
|
+
if (!match) continue;
|
|
102
|
+
aspects.push({
|
|
103
|
+
a: a.body,
|
|
104
|
+
aLon: a.lon,
|
|
105
|
+
b: b.body,
|
|
106
|
+
bLon: b.lon,
|
|
107
|
+
type: match.definition.type,
|
|
108
|
+
orb: match.orb
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return aspects.sort((a, b) => a.orb - b.orb);
|
|
113
|
+
}
|
|
114
|
+
function elementBalance(bodies) {
|
|
115
|
+
const balance = {
|
|
116
|
+
fire: 0,
|
|
117
|
+
earth: 0,
|
|
118
|
+
air: 0,
|
|
119
|
+
water: 0
|
|
120
|
+
};
|
|
121
|
+
for (const body of bodies) {
|
|
122
|
+
if (!ASPECT_BODIES.has(body.body)) continue;
|
|
123
|
+
balance[signForLongitude(body.lon).element] += 1;
|
|
124
|
+
}
|
|
125
|
+
return balance;
|
|
126
|
+
}
|
|
127
|
+
function modalityBalance(bodies) {
|
|
128
|
+
const balance = {
|
|
129
|
+
cardinal: 0,
|
|
130
|
+
fixed: 0,
|
|
131
|
+
mutable: 0
|
|
132
|
+
};
|
|
133
|
+
for (const body of bodies) {
|
|
134
|
+
if (!ASPECT_BODIES.has(body.body)) continue;
|
|
135
|
+
balance[signForLongitude(body.lon).modality] += 1;
|
|
136
|
+
}
|
|
137
|
+
return balance;
|
|
138
|
+
}
|
|
139
|
+
function summarizePair(first, second, topCount = 8) {
|
|
140
|
+
if (!Number.isInteger(topCount) || topCount < 0) {
|
|
141
|
+
throw new RangeError("topCount must be a non-negative integer.");
|
|
142
|
+
}
|
|
143
|
+
const aspects = findInterAspects(first, second);
|
|
144
|
+
const counts = {
|
|
145
|
+
conjunction: 0,
|
|
146
|
+
sextile: 0,
|
|
147
|
+
square: 0,
|
|
148
|
+
trine: 0,
|
|
149
|
+
opposition: 0
|
|
150
|
+
};
|
|
151
|
+
for (const aspect of aspects) counts[aspect.type] += 1;
|
|
152
|
+
return {
|
|
153
|
+
aspects,
|
|
154
|
+
top: aspects.slice(0, topCount),
|
|
155
|
+
counts,
|
|
156
|
+
easeful: counts.trine + counts.sextile,
|
|
157
|
+
charged: counts.square + counts.opposition,
|
|
158
|
+
elements: {
|
|
159
|
+
a: elementBalance(first),
|
|
160
|
+
b: elementBalance(second)
|
|
161
|
+
},
|
|
162
|
+
modalities: {
|
|
163
|
+
a: modalityBalance(first),
|
|
164
|
+
b: modalityBalance(second)
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// src/api.ts
|
|
170
|
+
function isChart(value) {
|
|
171
|
+
if (!value || typeof value !== "object") return false;
|
|
172
|
+
const candidate = value;
|
|
173
|
+
return Array.isArray(candidate.bodies) && Array.isArray(candidate.aspects) && candidate.input?.utc instanceof Date;
|
|
174
|
+
}
|
|
175
|
+
function isBirth(value) {
|
|
176
|
+
return Boolean(value && typeof value === "object" && "utc" in value);
|
|
177
|
+
}
|
|
178
|
+
function resolvedChart(source) {
|
|
179
|
+
if (!isChart(source)) {
|
|
180
|
+
const chart = natalChart(source);
|
|
181
|
+
return { chart, utc: chart.input.utc };
|
|
182
|
+
}
|
|
183
|
+
const sourceInput = source.input;
|
|
184
|
+
const { input, flags: inputFlags } = validateBirth(sourceInput);
|
|
185
|
+
const resultFlags = snapshotFlags(source.flags);
|
|
186
|
+
const expected = timeFlags(inputFlags?.values ?? []);
|
|
187
|
+
const hasHouses = input.timeKnown && input.latitude !== void 0;
|
|
188
|
+
const houses = source.houses;
|
|
189
|
+
const angles = source.angles;
|
|
190
|
+
const actualHouseSystem = houses?.system;
|
|
191
|
+
if ((hasHouses ? !angles || typeof angles !== "object" || Array.isArray(angles) || !houses || typeof houses !== "object" || Array.isArray(houses) : angles !== null || houses !== null) || houses !== null && actualHouseSystem !== input.houseSystem && !(isPolarUndefinedHouseSystem(input.houseSystem) && actualHouseSystem === POLAR_FALLBACK)) {
|
|
192
|
+
throw new RangeError("chart flags must agree with its input and supplied house result.");
|
|
193
|
+
}
|
|
194
|
+
if (!input.timeKnown) expected.push("no-time");
|
|
195
|
+
if (isPolarUndefinedHouseSystem(input.houseSystem) && actualHouseSystem === POLAR_FALLBACK) {
|
|
196
|
+
expected.push("polar-fallback");
|
|
197
|
+
}
|
|
198
|
+
if (outsideReferenceSpan(input.utc)) expected.push("outside-reference-span");
|
|
199
|
+
assertDerivedFlags(inputFlags?.values ?? [], expected);
|
|
200
|
+
if (resultFlags.values.length !== expected.length || !expected.every((flag) => resultFlags.values.includes(flag))) {
|
|
201
|
+
throw new RangeError("chart flags must agree with its input and supplied house result.");
|
|
202
|
+
}
|
|
203
|
+
const canonicalInputFlags = input.flags ?? [];
|
|
204
|
+
const inputChanged = inputFlags !== void 0 && (inputFlags.hasDuplicates || inputFlags.values.length !== canonicalInputFlags.length);
|
|
205
|
+
const resultChanged = resultFlags.hasDuplicates || !expected.every((flag, index) => flag === resultFlags.values[index]);
|
|
206
|
+
if (!inputChanged && !resultChanged) return { chart: source, utc: input.utc };
|
|
207
|
+
return {
|
|
208
|
+
chart: {
|
|
209
|
+
...source,
|
|
210
|
+
input: inputChanged ? input : sourceInput,
|
|
211
|
+
flags: expected
|
|
212
|
+
},
|
|
213
|
+
utc: input.utc
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
var BIRTH_FIELDS = [
|
|
217
|
+
"utc",
|
|
218
|
+
"timeScale",
|
|
219
|
+
"latitude",
|
|
220
|
+
"longitude",
|
|
221
|
+
"houseSystem",
|
|
222
|
+
"timeKnown",
|
|
223
|
+
"flags",
|
|
224
|
+
"deltaT"
|
|
225
|
+
];
|
|
226
|
+
function validateBirth(birth) {
|
|
227
|
+
if (!birth || typeof birth !== "object" || Array.isArray(birth)) {
|
|
228
|
+
throw new RangeError("birth must be an object containing a resolved utc instant.");
|
|
229
|
+
}
|
|
230
|
+
for (const key of Object.keys(birth)) {
|
|
231
|
+
const field = BIRTH_FIELDS.find((name) => name !== key && name.toLowerCase() === key.toLowerCase());
|
|
232
|
+
if (field) throw new RangeError(`birth has no field "${key}"; field names are case-sensitive: "${field}".`);
|
|
233
|
+
}
|
|
234
|
+
const settings = validateBirthSettings(birth);
|
|
235
|
+
const supplied = birth.flags;
|
|
236
|
+
const flags = supplied === void 0 ? void 0 : snapshotFlags(supplied);
|
|
237
|
+
const utc = dateFrom(birth.utc, "birth.utc");
|
|
238
|
+
const pin = birth.deltaT;
|
|
239
|
+
if (pin !== void 0 && (typeof pin !== "number" || !Number.isFinite(pin) || Math.abs(pin) > 1e10)) {
|
|
240
|
+
throw new RangeError("deltaT must be a finite number of seconds, at most 1e10 in size.");
|
|
241
|
+
}
|
|
242
|
+
const scale = birth.timeScale;
|
|
243
|
+
if (scale !== void 0 && !TIME_SCALE_NAMES.includes(scale)) {
|
|
244
|
+
throw new RangeError('timeScale must be "utc", "ut1" or "tt".');
|
|
245
|
+
}
|
|
246
|
+
const possible = [];
|
|
247
|
+
if (settings.timeKnown === false) possible.push("no-time");
|
|
248
|
+
else if (settings.houseSystem !== void 0 && isPolarUndefinedHouseSystem(settings.houseSystem) && settings.latitude !== void 0) {
|
|
249
|
+
possible.push("polar-fallback");
|
|
250
|
+
}
|
|
251
|
+
if (outsideReferenceSpan(utc)) possible.push("outside-reference-span");
|
|
252
|
+
assertDerivedFlags(flags?.values ?? [], possible);
|
|
253
|
+
const input = {
|
|
254
|
+
utc,
|
|
255
|
+
houseSystem: settings.houseSystem ?? "whole",
|
|
256
|
+
timeKnown: settings.timeKnown ?? true,
|
|
257
|
+
...settings.latitude === void 0 ? {} : { latitude: settings.latitude, longitude: settings.longitude },
|
|
258
|
+
...flags === void 0 ? {} : { flags: timeFlags(flags.values) },
|
|
259
|
+
...pin === void 0 ? {} : { deltaT: pin },
|
|
260
|
+
...scale === void 0 || scale === "utc" ? {} : { timeScale: scale }
|
|
261
|
+
};
|
|
262
|
+
return { input, flags };
|
|
263
|
+
}
|
|
264
|
+
function computedBirth({ input, flags }) {
|
|
265
|
+
const chart = computeChart(input);
|
|
266
|
+
assertDerivedFlags(flags?.values ?? [], chart.flags);
|
|
267
|
+
return chart;
|
|
268
|
+
}
|
|
269
|
+
function positions(date) {
|
|
270
|
+
return computeBodies(dateFrom(date, "date"));
|
|
271
|
+
}
|
|
272
|
+
function natalChart(birth) {
|
|
273
|
+
return computedBirth(validateBirth(birth));
|
|
274
|
+
}
|
|
275
|
+
function chartDeclinations(natal) {
|
|
276
|
+
return computeChartDeclinations(resolvedChart(natal).chart);
|
|
277
|
+
}
|
|
278
|
+
function chartPoints(natal) {
|
|
279
|
+
const { chart } = resolvedChart(natal);
|
|
280
|
+
return computePoints(chart);
|
|
281
|
+
}
|
|
282
|
+
function transits(natal, date) {
|
|
283
|
+
const { chart } = resolvedChart(natal);
|
|
284
|
+
const at = dateFrom(date, "date");
|
|
285
|
+
const current = computeBodies(at);
|
|
286
|
+
return {
|
|
287
|
+
natal: chart,
|
|
288
|
+
at,
|
|
289
|
+
positions: current,
|
|
290
|
+
aspects: findInterAspects(current, chart.bodies)
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
function synastry(first, second) {
|
|
294
|
+
const { chart: a } = resolvedChart(first);
|
|
295
|
+
const { chart: b } = resolvedChart(second);
|
|
296
|
+
return { a, b, ...summarizePair(a.bodies, b.bodies) };
|
|
297
|
+
}
|
|
298
|
+
function phaseName(angle) {
|
|
299
|
+
if (angle < 22.5 || angle >= 337.5) return "New Moon";
|
|
300
|
+
if (angle < 67.5) return "Waxing Crescent";
|
|
301
|
+
if (angle < 112.5) return "First Quarter";
|
|
302
|
+
if (angle < 157.5) return "Waxing Gibbous";
|
|
303
|
+
if (angle < 202.5) return "Full Moon";
|
|
304
|
+
if (angle < 247.5) return "Waning Gibbous";
|
|
305
|
+
if (angle < 292.5) return "Last Quarter";
|
|
306
|
+
return "Waning Crescent";
|
|
307
|
+
}
|
|
308
|
+
function moonPhase(date) {
|
|
309
|
+
const at = dateFrom(date, "date");
|
|
310
|
+
const angle = normalizeLongitude(bodyLongitude("Moon", at) - bodyLongitude("Sun", at));
|
|
311
|
+
return {
|
|
312
|
+
at,
|
|
313
|
+
angle,
|
|
314
|
+
illumination: (1 - Math.cos(angle * Math.PI / 180)) / 2,
|
|
315
|
+
name: phaseName(angle),
|
|
316
|
+
waxing: angle < 180
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
function utcOf(input) {
|
|
320
|
+
if (input.timeScale === void 0) return input.utc;
|
|
321
|
+
return new Date(Math.round(timeBasis(input.utc.getTime(), input.timeScale, input.deltaT).utcMs));
|
|
322
|
+
}
|
|
323
|
+
function saturnReturn(birth) {
|
|
324
|
+
let utc;
|
|
325
|
+
if (isChart(birth)) {
|
|
326
|
+
const { chart } = resolvedChart(birth);
|
|
327
|
+
utc = utcOf(chart.input);
|
|
328
|
+
} else if (isBirth(birth)) {
|
|
329
|
+
const validated = validateBirth(birth);
|
|
330
|
+
utc = utcOf(
|
|
331
|
+
validated.flags?.values.includes("polar-fallback") ? computedBirth(validated).input : validated.input
|
|
332
|
+
);
|
|
333
|
+
} else utc = dateFrom(birth, "birth");
|
|
334
|
+
return computeSaturnReturns(utc);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
export {
|
|
338
|
+
findLongitudeCrossings,
|
|
339
|
+
searchLongitudeCrossings,
|
|
340
|
+
groupIntoSeasons,
|
|
341
|
+
findInterAspects,
|
|
342
|
+
elementBalance,
|
|
343
|
+
modalityBalance,
|
|
344
|
+
summarizePair,
|
|
345
|
+
resolvedChart,
|
|
346
|
+
positions,
|
|
347
|
+
natalChart,
|
|
348
|
+
chartDeclinations,
|
|
349
|
+
chartPoints,
|
|
350
|
+
transits,
|
|
351
|
+
synastry,
|
|
352
|
+
moonPhase,
|
|
353
|
+
utcOf,
|
|
354
|
+
saturnReturn
|
|
355
|
+
};
|