@zodiacs/engine 0.1.1-rc.14

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.
@@ -0,0 +1,219 @@
1
+ // src/aspects.ts
2
+ var ASPECT_TYPES = [
3
+ "conjunction",
4
+ "sextile",
5
+ "square",
6
+ "trine",
7
+ "opposition"
8
+ ];
9
+ var ASPECTS = [
10
+ { type: "conjunction", angle: 0, orb: 8, luminaryOrb: 10 },
11
+ { type: "sextile", angle: 60, orb: 4, luminaryOrb: 5 },
12
+ { type: "square", angle: 90, orb: 7, luminaryOrb: 8 },
13
+ { type: "trine", angle: 120, orb: 7, luminaryOrb: 8 },
14
+ { type: "opposition", angle: 180, orb: 8, luminaryOrb: 10 }
15
+ ];
16
+ var LUMINARIES = /* @__PURE__ */ new Set(["Sun", "Moon"]);
17
+ var ASPECT_BODIES = /* @__PURE__ */ new Set([
18
+ "Sun",
19
+ "Moon",
20
+ "Mercury",
21
+ "Venus",
22
+ "Mars",
23
+ "Jupiter",
24
+ "Saturn",
25
+ "Uranus",
26
+ "Neptune",
27
+ "Pluto"
28
+ ]);
29
+ var STATIONARY_RELATIVE_SPEED = 1e-9;
30
+ function aspectMotion(a, b, angle) {
31
+ const relative = a.speed - b.speed;
32
+ if (!(Math.abs(relative) >= STATIONARY_RELATIVE_SPEED)) return "stationary";
33
+ const wrapped = ((a.lon - b.lon) % 360 + 360) % 360;
34
+ const signed = wrapped > 180 ? wrapped - 360 : wrapped;
35
+ const deviation = Math.abs(signed) - angle;
36
+ if (deviation === 0) return "separating";
37
+ return Math.sign(deviation) * Math.sign(signed) * relative < 0 ? "applying" : "separating";
38
+ }
39
+ function separation(a, b) {
40
+ const difference = Math.abs(((a - b) % 360 + 360) % 360);
41
+ return difference > 180 ? 360 - difference : difference;
42
+ }
43
+ function matchAspect(aBody, aLongitude, bBody, bLongitude) {
44
+ const distance = separation(aLongitude, bLongitude);
45
+ const hasLuminary = LUMINARIES.has(aBody) || LUMINARIES.has(bBody);
46
+ let best = null;
47
+ for (const definition of ASPECTS) {
48
+ const orb = Math.abs(distance - definition.angle);
49
+ const maximum = hasLuminary ? definition.luminaryOrb : definition.orb;
50
+ if (orb <= maximum && (!best || orb < best.orb)) {
51
+ best = { definition, orb };
52
+ }
53
+ }
54
+ return best;
55
+ }
56
+ function findAspects(bodies) {
57
+ const candidates = bodies.filter((body) => ASPECT_BODIES.has(body.body));
58
+ const aspects = [];
59
+ for (let first = 0; first < candidates.length; first += 1) {
60
+ for (let second = first + 1; second < candidates.length; second += 1) {
61
+ const a = candidates[first];
62
+ const b = candidates[second];
63
+ if (!a || !b) continue;
64
+ const match = matchAspect(a.body, a.lon, b.body, b.lon);
65
+ if (!match) continue;
66
+ aspects.push({
67
+ a: a.body,
68
+ b: b.body,
69
+ type: match.definition.type,
70
+ orb: match.orb,
71
+ applying: aspectMotion(a, b, match.definition.angle) === "applying"
72
+ });
73
+ }
74
+ }
75
+ return aspects.sort((a, b) => a.orb - b.orb);
76
+ }
77
+
78
+ // src/signs.ts
79
+ var ELEMENTS = ["fire", "earth", "air", "water"];
80
+ var MODALITIES = ["cardinal", "fixed", "mutable"];
81
+ var SIGNS = [
82
+ {
83
+ slug: "aries",
84
+ name: "Aries",
85
+ element: "fire",
86
+ modality: "cardinal",
87
+ polarity: "day",
88
+ naturalHouse: 1
89
+ },
90
+ {
91
+ slug: "taurus",
92
+ name: "Taurus",
93
+ element: "earth",
94
+ modality: "fixed",
95
+ polarity: "night",
96
+ naturalHouse: 2
97
+ },
98
+ {
99
+ slug: "gemini",
100
+ name: "Gemini",
101
+ element: "air",
102
+ modality: "mutable",
103
+ polarity: "day",
104
+ naturalHouse: 3
105
+ },
106
+ {
107
+ slug: "cancer",
108
+ name: "Cancer",
109
+ element: "water",
110
+ modality: "cardinal",
111
+ polarity: "night",
112
+ naturalHouse: 4
113
+ },
114
+ {
115
+ slug: "leo",
116
+ name: "Leo",
117
+ element: "fire",
118
+ modality: "fixed",
119
+ polarity: "day",
120
+ naturalHouse: 5
121
+ },
122
+ {
123
+ slug: "virgo",
124
+ name: "Virgo",
125
+ element: "earth",
126
+ modality: "mutable",
127
+ polarity: "night",
128
+ naturalHouse: 6
129
+ },
130
+ {
131
+ slug: "libra",
132
+ name: "Libra",
133
+ element: "air",
134
+ modality: "cardinal",
135
+ polarity: "day",
136
+ naturalHouse: 7
137
+ },
138
+ {
139
+ slug: "scorpio",
140
+ name: "Scorpio",
141
+ element: "water",
142
+ modality: "fixed",
143
+ polarity: "night",
144
+ naturalHouse: 8
145
+ },
146
+ {
147
+ slug: "sagittarius",
148
+ name: "Sagittarius",
149
+ element: "fire",
150
+ modality: "mutable",
151
+ polarity: "day",
152
+ naturalHouse: 9
153
+ },
154
+ {
155
+ slug: "capricorn",
156
+ name: "Capricorn",
157
+ element: "earth",
158
+ modality: "cardinal",
159
+ polarity: "night",
160
+ naturalHouse: 10
161
+ },
162
+ {
163
+ slug: "aquarius",
164
+ name: "Aquarius",
165
+ element: "air",
166
+ modality: "fixed",
167
+ polarity: "day",
168
+ naturalHouse: 11
169
+ },
170
+ {
171
+ slug: "pisces",
172
+ name: "Pisces",
173
+ element: "water",
174
+ modality: "mutable",
175
+ polarity: "night",
176
+ naturalHouse: 12
177
+ }
178
+ ];
179
+ var SIGN_NAMES = SIGNS.map((sign) => sign.slug);
180
+ function normalizeLongitude(lon) {
181
+ if (!Number.isFinite(lon)) throw new RangeError("Longitude must be finite.");
182
+ return (lon % 360 + 360) % 360;
183
+ }
184
+ function signIndexForLongitude(lon) {
185
+ return Math.floor(normalizeLongitude(lon) / 30);
186
+ }
187
+ function signForLongitude(lon) {
188
+ const sign = SIGNS[signIndexForLongitude(lon)];
189
+ if (!sign) throw new RangeError("Could not resolve zodiac sign.");
190
+ return sign;
191
+ }
192
+ function degreeInSign(lon) {
193
+ return normalizeLongitude(lon) % 30;
194
+ }
195
+
196
+ // src/types.ts
197
+ var ENGINE_VERSION = "0.1.1-rc.14";
198
+ var EPHEMERIS = Object.freeze({ name: "astronomy-engine", version: "2.1.19" });
199
+
200
+ export {
201
+ ASPECT_TYPES,
202
+ ASPECTS,
203
+ ASPECT_BODIES,
204
+ STATIONARY_RELATIVE_SPEED,
205
+ aspectMotion,
206
+ separation,
207
+ matchAspect,
208
+ findAspects,
209
+ ELEMENTS,
210
+ MODALITIES,
211
+ SIGNS,
212
+ SIGN_NAMES,
213
+ normalizeLongitude,
214
+ signIndexForLongitude,
215
+ signForLongitude,
216
+ degreeInSign,
217
+ ENGINE_VERSION,
218
+ EPHEMERIS
219
+ };
@@ -0,0 +1,285 @@
1
+ // src/deltat.ts
2
+ var DELTA_T_MODEL = "zodiacs-deltat/1";
3
+ var DELTA_T_TABLE = Object.freeze({
4
+ version: "2026-09-24",
5
+ digest: "6371988c510a1c6c",
6
+ from: 1941,
7
+ observedTo: 61307,
8
+ predictedTo: 61680,
9
+ knots: Object.freeze([
10
+ 2482,
11
+ 48,
12
+ 47,
13
+ 50,
14
+ 49,
15
+ 51,
16
+ 50,
17
+ 48,
18
+ 45,
19
+ 45,
20
+ 42,
21
+ 40,
22
+ 39,
23
+ 36,
24
+ 35,
25
+ 28,
26
+ 33,
27
+ 49,
28
+ 50,
29
+ 48,
30
+ 43,
31
+ 42,
32
+ 47,
33
+ 56,
34
+ 71,
35
+ 80,
36
+ 89,
37
+ 87,
38
+ 90,
39
+ 98,
40
+ 99,
41
+ 106,
42
+ 114,
43
+ 111,
44
+ 100,
45
+ 98,
46
+ 106,
47
+ 101,
48
+ 106,
49
+ 95,
50
+ 84,
51
+ 79,
52
+ 79,
53
+ 83,
54
+ 55,
55
+ 53,
56
+ 45,
57
+ 50,
58
+ 48,
59
+ 56,
60
+ 71,
61
+ 74,
62
+ 81,
63
+ 86,
64
+ 81,
65
+ 84,
66
+ 66,
67
+ 68,
68
+ 50,
69
+ 36,
70
+ 26,
71
+ 21,
72
+ 17,
73
+ 10,
74
+ 12,
75
+ 16,
76
+ 30,
77
+ 31,
78
+ 32,
79
+ 29,
80
+ 25,
81
+ 28,
82
+ 31,
83
+ 37,
84
+ 36,
85
+ 46,
86
+ 49,
87
+ 38,
88
+ 25,
89
+ 14,
90
+ 0,
91
+ -7,
92
+ -9,
93
+ -2,
94
+ -4,
95
+ -3,
96
+ 9,
97
+ 10,
98
+ 7,
99
+ 1,
100
+ -5
101
+ ])
102
+ });
103
+ var SX = [-720, 400, 1e3, 1500, 1600, 1650, 1720, 1800, 1810, 1820, 1830, 1840];
104
+ var SY = [
105
+ 2055059,
106
+ 660440,
107
+ 146765,
108
+ 29264,
109
+ 8938,
110
+ 4374,
111
+ 1073,
112
+ 1871,
113
+ 1526,
114
+ 1668,
115
+ 1076,
116
+ 767,
117
+ 932,
118
+ 1038,
119
+ 904,
120
+ 826,
121
+ 237,
122
+ -113,
123
+ -321,
124
+ -439,
125
+ -388,
126
+ -502,
127
+ -198,
128
+ 492,
129
+ 1114,
130
+ 1748,
131
+ 2162,
132
+ 2379,
133
+ 2442,
134
+ 2416,
135
+ 2443,
136
+ 2705
137
+ ];
138
+ var SIG = [
139
+ 640,
140
+ 83,
141
+ 900,
142
+ 230,
143
+ 1240,
144
+ 120,
145
+ 1400,
146
+ 15,
147
+ 1420,
148
+ 7.5,
149
+ 1440,
150
+ 4.2,
151
+ 1500,
152
+ 5.6,
153
+ 1560,
154
+ 27,
155
+ 1670,
156
+ 15,
157
+ 1710,
158
+ 3.3,
159
+ 1720,
160
+ 3.3,
161
+ 1760,
162
+ 1.5,
163
+ 1800,
164
+ 1.5,
165
+ 1810,
166
+ 0.55,
167
+ 1820,
168
+ 0.55,
169
+ 1840,
170
+ 0.46,
171
+ 1956,
172
+ 0.46
173
+ ];
174
+ var X;
175
+ var Y;
176
+ var M;
177
+ var KX;
178
+ var KV;
179
+ var OBS;
180
+ var PRED;
181
+ var SLOPE;
182
+ var yearOfMjd = (mjd) => 2e3 + (mjd - 51544.5) / 365.25;
183
+ var longTerm = (y) => {
184
+ const t = (y - 1825) / 100;
185
+ return 36.525 * (0.89 * t * t + 30 / Math.PI * Math.cos(Math.PI * t / 7.5));
186
+ };
187
+ var longTermRate = (y) => {
188
+ const t = (y - 1825) / 100;
189
+ return 0.36525 * (1.78 * t - 4 * Math.sin(Math.PI * t / 7.5));
190
+ };
191
+ function init() {
192
+ const x = SX.slice();
193
+ for (let year = 1850; year <= 1945; year += 5) x.push(year);
194
+ const y = SY.map((v) => v / 100);
195
+ const n = x.length - 1;
196
+ const m = [0.018915];
197
+ const c = [0];
198
+ const r = [0.018915];
199
+ for (let i = 1; i < n; i++) {
200
+ const a = x[i] - x[i - 1];
201
+ const b = x[i + 1] - x[i];
202
+ const p = 2 * (a + b) - a * c[i - 1];
203
+ c[i] = b / p;
204
+ r[i] = (6 * ((y[i + 1] - y[i]) / b - (y[i] - y[i - 1]) / a) - a * r[i - 1]) / p;
205
+ }
206
+ m[n] = -0.09856;
207
+ for (let i = n - 1; i > 0; i--) m[i] = r[i] - c[i] * m[i + 1];
208
+ const T = DELTA_T_TABLE;
209
+ const obs = yearOfMjd(T.observedTo);
210
+ const pred = yearOfMjd(T.predictedTo);
211
+ const kv = [];
212
+ let total = 0;
213
+ for (const step of T.knots) kv.push((total += step) / 100);
214
+ const years = kv.length - 5;
215
+ const kx = [];
216
+ for (let i = 0; i < years; i++) kx.push(T.from + i);
217
+ for (let k = 0; k < 5; k++) kx.push(obs + k * (pred - obs) / 4);
218
+ X = x;
219
+ Y = y;
220
+ M = m;
221
+ KX = kx;
222
+ KV = kv;
223
+ OBS = obs;
224
+ PRED = pred;
225
+ SLOPE = (kv[years + 4] - kv[years]) / (pred - obs);
226
+ }
227
+ function seconds(t) {
228
+ const x = X;
229
+ const y = Y;
230
+ const m = M;
231
+ const kx = KX;
232
+ const kv = KV;
233
+ if (t < -720) return y[0] + longTerm(t) - longTerm(-720);
234
+ if (t < 1941) {
235
+ let i = x.length - 2;
236
+ while (t < x[i]) i--;
237
+ const h = x[i + 1] - x[i];
238
+ const a = x[i + 1] - t;
239
+ const b = t - x[i];
240
+ return (m[i] * a ** 3 + m[i + 1] * b ** 3) / (6 * h) + (y[i] / h - m[i] * h / 6) * a + (y[i + 1] / h - m[i + 1] * h / 6) * b;
241
+ }
242
+ const n = kx.length - 1;
243
+ if (t <= kx[n]) {
244
+ const i = t < OBS ? Math.floor(t - 1941) : n - 4 + Math.min(3, Math.floor(4 * (t - OBS) / (PRED - OBS)));
245
+ return kv[i] + (t - kx[i]) * (kv[i + 1] - kv[i]) / (kx[i + 1] - kx[i]);
246
+ }
247
+ const g = t - PRED;
248
+ return kv[n] + SLOPE * 15 * (1 - Math.exp(-g / 15)) + longTerm(t) - longTerm(PRED) - longTermRate(PRED) * g;
249
+ }
250
+ function sigma(t) {
251
+ const h = t - OBS;
252
+ if (h > 0) return h <= 1 ? 0.03 + 0.09 * h ** 0.75 : h <= 10 ? 0.12 * h ** 1.5 : 0.61 * h - 2.3052668;
253
+ if (t >= 1956) return 0.03;
254
+ const c = (t - 1825) / 100;
255
+ let v = t < 1620 ? 0.6 * c * c : 0;
256
+ if (t >= 640) {
257
+ let i = 0;
258
+ while (t >= SIG[i + 2]) i += 2;
259
+ v = Math.max(v, SIG[i + 1] + (t - SIG[i]) * (SIG[i + 3] - SIG[i + 1]) / (SIG[i + 2] - SIG[i]));
260
+ }
261
+ return v;
262
+ }
263
+ function deltaTAt(ut) {
264
+ const t = 2e3 + ut / 365.25;
265
+ if (!X) init();
266
+ return {
267
+ seconds: seconds(t),
268
+ sigma: sigma(t),
269
+ model: DELTA_T_MODEL,
270
+ table: DELTA_T_TABLE.version,
271
+ tableDigest: DELTA_T_TABLE.digest,
272
+ segment: t < -720 ? "long-term" : t < 1956 ? "reconstructed" : t <= OBS ? "observed" : t <= PRED ? "predicted" : "extrapolated"
273
+ };
274
+ }
275
+ function deltaT(ut) {
276
+ if (!X) init();
277
+ return seconds(2e3 + ut / 365.25);
278
+ }
279
+
280
+ export {
281
+ DELTA_T_MODEL,
282
+ DELTA_T_TABLE,
283
+ deltaTAt,
284
+ deltaT
285
+ };
@@ -0,0 +1,87 @@
1
+ // src/birth-input.ts
2
+ var HOUSE_SYSTEM_NAMES = [
3
+ "whole",
4
+ "placidus",
5
+ "porphyry",
6
+ "equal",
7
+ "equal-mc",
8
+ "vehlow",
9
+ "koch",
10
+ "regiomontanus",
11
+ "campanus",
12
+ "topocentric",
13
+ "alcabitius",
14
+ "morinus",
15
+ "meridian"
16
+ ];
17
+ function validateBirthSettings(birth) {
18
+ const { houseSystem, timeKnown, latitude, longitude } = birth;
19
+ if (houseSystem !== void 0 && !HOUSE_SYSTEM_NAMES.includes(houseSystem)) {
20
+ throw new RangeError(
21
+ `houseSystem must be one of ${HOUSE_SYSTEM_NAMES.map((name) => `"${name}"`).join(", ")}.`
22
+ );
23
+ }
24
+ if (timeKnown !== void 0 && typeof timeKnown !== "boolean") {
25
+ throw new RangeError("timeKnown must be a boolean.");
26
+ }
27
+ const hasLatitude = latitude !== void 0;
28
+ const hasLongitude = longitude !== void 0;
29
+ if (hasLatitude !== hasLongitude) {
30
+ throw new RangeError("latitude and longitude must be supplied together.");
31
+ }
32
+ if (latitude !== void 0 && (!Number.isFinite(latitude) || latitude < -90 || latitude > 90)) {
33
+ throw new RangeError("latitude must be between -90 and 90 degrees.");
34
+ }
35
+ if (longitude !== void 0 && (!Number.isFinite(longitude) || longitude < -180 || longitude > 180)) {
36
+ throw new RangeError("longitude must be between -180 and 180 degrees.");
37
+ }
38
+ return {
39
+ ...houseSystem === void 0 ? {} : { houseSystem },
40
+ ...timeKnown === void 0 ? {} : { timeKnown },
41
+ ...latitude === void 0 ? {} : { latitude, longitude }
42
+ };
43
+ }
44
+ var FLAGS = [
45
+ "dst-gap",
46
+ "dst-fold",
47
+ "lmt",
48
+ "no-time",
49
+ "polar-fallback",
50
+ "outside-reference-span"
51
+ ];
52
+ var DERIVED_FLAGS = ["no-time", "polar-fallback", "outside-reference-span"];
53
+ function snapshotFlags(value) {
54
+ const length = Array.isArray(value) ? Object.getOwnPropertyDescriptor(value, "length")?.value : void 0;
55
+ if (typeof length !== "number" || !Number.isInteger(length) || length < 0 || length > 64) {
56
+ throw new RangeError("flags must be an array of at most 64 supported chart flags.");
57
+ }
58
+ const values = [];
59
+ for (let index = 0; index < length; index += 1) {
60
+ const flag = Object.getOwnPropertyDescriptor(value, String(index))?.value;
61
+ if (typeof flag !== "string" || !FLAGS.includes(flag)) {
62
+ throw new RangeError("flags must contain only supported chart flag strings.");
63
+ }
64
+ if (!values.includes(flag)) values.push(flag);
65
+ }
66
+ if (values.includes("dst-gap") && values.includes("dst-fold")) {
67
+ throw new RangeError('flags cannot contain both "dst-gap" and "dst-fold".');
68
+ }
69
+ return { values, hasDuplicates: values.length !== length };
70
+ }
71
+ function timeFlags(flags) {
72
+ return flags.filter((flag) => !DERIVED_FLAGS.includes(flag));
73
+ }
74
+ function assertDerivedFlags(supplied, actual) {
75
+ for (const flag of DERIVED_FLAGS) {
76
+ if (supplied.includes(flag) && !actual.includes(flag)) {
77
+ throw new RangeError("flags contradict the birth time or house result.");
78
+ }
79
+ }
80
+ }
81
+
82
+ export {
83
+ validateBirthSettings,
84
+ snapshotFlags,
85
+ timeFlags,
86
+ assertDerivedFlags
87
+ };