@zodiacs/engine 1.0.0 → 2.0.0-rc.2

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 +1244 -0
  2. package/LICENSING.md +172 -27
  3. package/NOTICE +78 -12
  4. package/README.md +344 -59
  5. package/dist/{api-WbxJ4Wj-.d.ts → api-C_SVd9BJ.d.ts} +39 -3
  6. package/dist/{ayanamsa--YQ46fET.d.ts → ayanamsa-Clgkekhh.d.ts} +2 -1
  7. package/dist/calc.d.ts +91 -4
  8. package/dist/calc.js +368 -126
  9. package/dist/chunk-CV53HA7R.js +87 -0
  10. package/dist/chunk-EEW7746S.js +83 -0
  11. package/dist/{chunk-WS3TDSP3.js → chunk-FVGA776A.js} +7 -3
  12. package/dist/chunk-HNVGWN3S.js +852 -0
  13. package/dist/chunk-I3L4POY7.js +18 -0
  14. package/dist/{chunk-FTX3JDJA.js → chunk-IXFUYEUF.js} +65 -29
  15. package/dist/{chunk-7TRLIFFI.js → chunk-LWZS7HI3.js} +1 -1
  16. package/dist/{chunk-CHSYDKBL.js → chunk-N4UQLCBN.js} +3 -3
  17. package/dist/{chunk-YIITY7Q7.js → chunk-NX4PHQBL.js} +34 -22
  18. package/dist/chunk-OVXQQEXL.js +41 -0
  19. package/dist/{chunk-SRXBTP5H.js → chunk-PNXIA7MI.js} +217 -192
  20. package/dist/chunk-RMBWKZI2.js +130 -0
  21. package/dist/{chunk-DMGHYCDI.js → chunk-SCRO6HWB.js} +5 -3
  22. package/dist/{chunk-OG4OYTJJ.js → chunk-T6F4FYYS.js} +1 -129
  23. package/dist/chunk-UXY4RU57.js +48 -0
  24. package/dist/{chunk-PFGUCNOK.js → chunk-WONTOC5W.js} +7 -6
  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-D1lM832F.d.ts +64 -0
  33. package/dist/geo.d.ts +28 -7
  34. package/dist/geo.js +2 -2
  35. package/dist/houses-extra.d.ts +5 -4
  36. package/dist/{houses-CFERsAlK.d.ts → houses-icK01yXi.d.ts} +3 -3
  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-BGX23p4h.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 +156 -67
  52. package/dist/{rulers-Dla6h_Sm.d.ts → rulers-CpS9qkvu.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-BCnyWBQZ.d.ts +352 -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-0XzMGx9V.d.ts} +32 -10
  69. package/package.json +24 -3
  70. package/dist/types-B-yb_tGL.d.ts +0 -240
@@ -1,46 +1,52 @@
1
- import {
2
- readOptions
3
- } from "./chunk-47ERTK5X.js";
4
- import {
5
- resolveLocalToUtc
6
- } from "./chunk-YIITY7Q7.js";
7
- import "./chunk-KFTJMMG7.js";
8
1
  import {
9
2
  natalChart,
10
3
  resolvedChart,
11
4
  utcOf
12
- } from "./chunk-FTX3JDJA.js";
5
+ } from "./chunk-IXFUYEUF.js";
13
6
  import {
14
- dateFrom
15
- } from "./chunk-CPALRSPC.js";
16
- import {
17
- findLongitudeCrossingsWith
18
- } from "./chunk-TSS2SZWQ.js";
19
- import "./chunk-PFGUCNOK.js";
7
+ readOptions
8
+ } from "./chunk-47ERTK5X.js";
20
9
  import {
21
10
  bodyLongitude,
11
+ ephemerisOver,
12
+ fallbacksAt,
22
13
  midpoint
23
- } from "./chunk-SRXBTP5H.js";
14
+ } from "./chunk-PNXIA7MI.js";
15
+ import {
16
+ dateFrom
17
+ } from "./chunk-CPALRSPC.js";
18
+ import {
19
+ ASPECTS,
20
+ ASPECT_BODY_SET,
21
+ matchAspect
22
+ } from "./chunk-T6F4FYYS.js";
23
+ import "./chunk-EEW7746S.js";
24
24
  import {
25
25
  outsideReferenceSpan
26
26
  } from "./chunk-B5LKF437.js";
27
- import "./chunk-BHJXUY67.js";
27
+ import {
28
+ findLongitudeCrossingsWith
29
+ } from "./chunk-TSS2SZWQ.js";
30
+ import "./chunk-UXY4RU57.js";
31
+ import "./chunk-HNVGWN3S.js";
32
+ import "./chunk-CV53HA7R.js";
28
33
  import {
29
34
  HOUSE_SYSTEMS
30
- } from "./chunk-DMGHYCDI.js";
35
+ } from "./chunk-SCRO6HWB.js";
31
36
  import {
32
- ASPECTS,
33
- ASPECT_BODY_SET,
34
37
  SIGNS,
35
38
  SIGN_SLUGS,
36
- matchAspect,
37
39
  normalizeLongitude,
38
40
  signIndexForLongitude
39
- } from "./chunk-OG4OYTJJ.js";
41
+ } from "./chunk-RMBWKZI2.js";
42
+ import "./chunk-BHJXUY67.js";
43
+ import {
44
+ resolveLocalToUtc
45
+ } from "./chunk-NX4PHQBL.js";
46
+ import "./chunk-KFTJMMG7.js";
47
+ import "./chunk-WONTOC5W.js";
40
48
 
41
- // src/techniques/shared.ts
42
- var DAY_MS = 864e5;
43
- var MAX_DATE_MS = 864e13;
49
+ // src/techniques/names.ts
44
50
  var BODY_NAMES = [
45
51
  "Sun",
46
52
  "Moon",
@@ -68,6 +74,10 @@ function finiteDegrees(value, label) {
68
74
  if (typeof value !== "number" || !Number.isFinite(value)) throw new RangeError(`${label} must be a finite number of degrees.`);
69
75
  return value;
70
76
  }
77
+
78
+ // src/techniques/shared.ts
79
+ var DAY_MS = 864e5;
80
+ var MAX_DATE_MS = 864e13;
71
81
  function placeOf(value, label) {
72
82
  const { latitude, longitude } = value ?? {};
73
83
  if (typeof latitude !== "number" || !(Math.abs(latitude) <= 90) || typeof longitude !== "number" || !(Math.abs(longitude) <= 180)) {
@@ -80,7 +90,24 @@ function dateAt(milliseconds, label) {
80
90
  return new Date(milliseconds);
81
91
  }
82
92
  function techniqueFlags(instants) {
83
- return Object.freeze(instants.some((milliseconds) => outsideReferenceSpan(new Date(milliseconds))) ? ["outside-reference-span"] : []);
93
+ const flags = instants.some((milliseconds) => outsideReferenceSpan(new Date(milliseconds))) ? ["outside-reference-span"] : [];
94
+ return Object.freeze([...flags, ...fallbacksAt(instants)]);
95
+ }
96
+ function labelOver(instants) {
97
+ return { ephemeris: Object.freeze(ephemerisOver(instants)), flags: techniqueFlags(instants) };
98
+ }
99
+ function detailed(value, instants) {
100
+ return Object.freeze({ value, ...labelOver(instants) });
101
+ }
102
+ var CHART_FLAGS = ["outside-reference-span", "de440-unavailable", "outside-de440-span"];
103
+ function labelOfCharts(charts) {
104
+ const named = charts.map((chart) => chart.ephemeris ?? null);
105
+ const first = named[0] ?? null;
106
+ const same = first !== null && named.every((one) => one !== null && one.name === first.name && one.version === first.version);
107
+ return {
108
+ ephemeris: same ? Object.freeze({ name: first.name, version: first.version }) : null,
109
+ flags: Object.freeze(CHART_FLAGS.filter((flag) => charts.some((chart) => chart.flags.includes(flag))))
110
+ };
84
111
  }
85
112
 
86
113
  // src/techniques/returns.ts
@@ -91,35 +118,40 @@ var LUNAR_RETURN_HORIZON_DAYS = 40;
91
118
  var LUNAR_RETURN_STEP_DAYS = 0.25;
92
119
  var SELECTIONS = ["nearest", "most-recent"];
93
120
  function solarReturnInstant(natalSunLongitude, near) {
121
+ return solarReturnSearch(natalSunLongitude, near).value;
122
+ }
123
+ function solarReturnInstantDetailed(natalSunLongitude, near) {
124
+ const { value, from, to } = solarReturnSearch(natalSunLongitude, near);
125
+ return detailed(value, [from, to]);
126
+ }
127
+ function solarReturnSearch(natalSunLongitude, near) {
94
128
  const target = finiteDegrees(natalSunLongitude, "natalSunLongitude");
95
129
  const center = dateFrom(near, "near").getTime();
96
- const crossings = findLongitudeCrossingsWith(
97
- bodyLongitude,
98
- "Sun",
99
- target,
100
- dateAt(center - SOLAR_RETURN_WINDOW_DAYS * DAY_MS, "The solar return window"),
101
- dateAt(center + SOLAR_RETURN_WINDOW_DAYS * DAY_MS, "The solar return window"),
102
- SOLAR_RETURN_STEP_DAYS
103
- );
130
+ const lower = dateAt(center - SOLAR_RETURN_WINDOW_DAYS * DAY_MS, "The solar return window");
131
+ const upper = dateAt(center + SOLAR_RETURN_WINDOW_DAYS * DAY_MS, "The solar return window");
132
+ const crossings = findLongitudeCrossingsWith(bodyLongitude, "Sun", target, lower, upper, SOLAR_RETURN_STEP_DAYS);
104
133
  const first = crossings[0];
105
134
  if (first === void 0) throw new RangeError("No solar return found in the scan window.");
106
135
  const closest = crossings.reduce((best, crossing) => Math.abs(crossing.at.getTime() - center) < Math.abs(best.at.getTime() - center) ? crossing : best, first);
107
- return new Date(closest.at.getTime());
136
+ return { value: new Date(closest.at.getTime()), from: lower.getTime(), to: upper.getTime() };
108
137
  }
109
138
  function mostRecentSolarReturnInstant(natalSunLongitude, at) {
139
+ return mostRecentSolarReturnSearch(natalSunLongitude, at).value;
140
+ }
141
+ function mostRecentSolarReturnInstantDetailed(natalSunLongitude, at) {
142
+ const { value, from, to } = mostRecentSolarReturnSearch(natalSunLongitude, at);
143
+ return detailed(value, [from, to]);
144
+ }
145
+ function mostRecentSolarReturnSearch(natalSunLongitude, at) {
110
146
  const target = finiteDegrees(natalSunLongitude, "natalSunLongitude");
111
147
  const end = dateFrom(at, "at").getTime();
112
- const crossings = findLongitudeCrossingsWith(
113
- bodyLongitude,
114
- "Sun",
115
- target,
116
- dateAt(end - SOLAR_RETURN_LOOKBACK_DAYS * DAY_MS, "The solar return window"),
117
- new Date(end),
118
- SOLAR_RETURN_STEP_DAYS
119
- ).filter((crossing) => crossing.at.getTime() <= end);
148
+ const lower = dateAt(end - SOLAR_RETURN_LOOKBACK_DAYS * DAY_MS, "The solar return window");
149
+ const crossings = findLongitudeCrossingsWith(bodyLongitude, "Sun", target, lower, new Date(end), SOLAR_RETURN_STEP_DAYS).filter(
150
+ (crossing) => crossing.at.getTime() <= end
151
+ );
120
152
  const last = crossings[crossings.length - 1];
121
153
  if (last === void 0) throw new RangeError("No previous solar return found in the scan window.");
122
- return new Date(last.at.getTime());
154
+ return { value: new Date(last.at.getTime()), from: lower.getTime(), to: end };
123
155
  }
124
156
  function moonLongitude(date) {
125
157
  const longitude = bodyLongitude("Moon", date);
@@ -127,6 +159,13 @@ function moonLongitude(date) {
127
159
  return longitude;
128
160
  }
129
161
  function lunarReturnInstant(natalMoonLongitude, after) {
162
+ return lunarReturnSearch(natalMoonLongitude, after).value;
163
+ }
164
+ function lunarReturnInstantDetailed(natalMoonLongitude, after) {
165
+ const { value, from, to } = lunarReturnSearch(natalMoonLongitude, after);
166
+ return detailed(value, [from, to]);
167
+ }
168
+ function lunarReturnSearch(natalMoonLongitude, after) {
130
169
  const longitude = finiteDegrees(natalMoonLongitude, "natalMoonLongitude");
131
170
  const start = dateFrom(after, "after").getTime();
132
171
  const upper = start + LUNAR_RETURN_HORIZON_DAYS * DAY_MS;
@@ -145,7 +184,7 @@ function lunarReturnInstant(natalMoonLongitude, after) {
145
184
  const instants = [...new Set(crossings.map((crossing) => crossing.at.getTime()))].filter((instant) => instant > start && instant <= upper).sort((a, b) => a - b);
146
185
  const first = instants[0];
147
186
  if (first === void 0) throw new RangeError("No lunar return was found in the 40-day scan.");
148
- return new Date(first);
187
+ return { value: new Date(first), from: start, to: upper };
149
188
  }
150
189
  function setup(natal, body, options) {
151
190
  const houseSystem = options.houseSystem === void 0 ? void 0 : oneOf(options.houseSystem, HOUSE_SYSTEMS, "whole", "houseSystem");
@@ -195,7 +234,7 @@ function lunarReturn(natal, after, options) {
195
234
  });
196
235
  }
197
236
 
198
- // src/techniques/relationship.ts
237
+ // src/techniques/composite.ts
199
238
  function positions(list, label) {
200
239
  if (!Array.isArray(list)) throw new RangeError(`${label} must be an array of { body, lon }.`);
201
240
  const seen = /* @__PURE__ */ new Set();
@@ -226,9 +265,13 @@ function compositeAspects(points) {
226
265
  });
227
266
  return Object.freeze(out.sort((x, y) => x.orb - y.orb));
228
267
  }
268
+
269
+ // src/techniques/relationship.ts
229
270
  function compositeChart(first, second) {
230
- const bodies = compositeMidpoints(resolvedChart(first).chart.bodies, resolvedChart(second).chart.bodies);
231
- return Object.freeze({ bodies, aspects: compositeAspects(bodies) });
271
+ const a = resolvedChart(first).chart;
272
+ const b = resolvedChart(second).chart;
273
+ const bodies = compositeMidpoints(a.bodies, b.bodies);
274
+ return Object.freeze({ bodies, aspects: compositeAspects(bodies), ...labelOfCharts([a, b]) });
232
275
  }
233
276
  var PLACES = ["coordinates", "great-circle"];
234
277
  var DEG = Math.PI / 180;
@@ -308,6 +351,9 @@ function delta(a, b) {
308
351
  const d = ((b - a) % 360 + 360) % 360;
309
352
  return d > 180 ? d - 360 : d;
310
353
  }
354
+ var INGRESS_STEP_MS = DAY_MS / 4;
355
+ var ASPECT_STEP_MS = DAY_MS / 8;
356
+ var around = (at, half, fromT, toT) => labelOver([Math.max(fromT, at - half), Math.min(toT, at + half)]);
311
357
  function ingresses(fromT, toT) {
312
358
  const out = [];
313
359
  if (!(toT > fromT)) return out;
@@ -333,7 +379,7 @@ function aspects(fromT, toT, bodies) {
333
379
  const cur = delta((bodyLons.get(body) ?? 0) + offset, moonLon);
334
380
  const before = prev[i];
335
381
  if (cur === 0 && before !== 0 && Math.abs(before) < 90) {
336
- out.push({ at: new Date(t), body, aspect: type, moonLon });
382
+ out.push({ at: new Date(t), body, aspect: type, moonLon, ...around(t, ASPECT_STEP_MS, fromT, toT) });
337
383
  } else if (before !== 0 && cur !== 0 && Math.sign(cur) !== Math.sign(before) && Math.abs(cur) < 90 && Math.abs(before) < 90) {
338
384
  let lo = prevT;
339
385
  let hi = t;
@@ -344,7 +390,7 @@ function aspects(fromT, toT, bodies) {
344
390
  else lo = mid;
345
391
  }
346
392
  const at = new Date(hi);
347
- out.push({ at, body, aspect: type, moonLon: bodyLongitude("Moon", at) });
393
+ out.push({ at, body, aspect: type, moonLon: bodyLongitude("Moon", at), ...around(hi, ASPECT_STEP_MS, fromT, toT) });
348
394
  }
349
395
  prev[i] = cur;
350
396
  });
@@ -353,7 +399,8 @@ function aspects(fromT, toT, bodies) {
353
399
  return out.sort((a, b) => a.at.getTime() - b.at.getTime());
354
400
  }
355
401
  function windows(fromT, toT, bodies) {
356
- const list = ingresses(fromT - 4 * DAY_MS, toT);
402
+ const scanFrom = fromT - 4 * DAY_MS;
403
+ const list = ingresses(scanFrom, toT);
357
404
  const out = [];
358
405
  for (let i = 1; i < list.length; i += 1) {
359
406
  const entered = list[i - 1];
@@ -368,14 +415,21 @@ function windows(fromT, toT, bodies) {
368
415
  to: new Date(end),
369
416
  lastAspect: lastAspect && Object.freeze(lastAspect),
370
417
  sign: SIGN_SLUGS[entered.signIndex],
371
- nextSign: SIGN_SLUGS[leaving.signIndex]
418
+ nextSign: SIGN_SLUGS[leaving.signIndex],
419
+ // Its two ingresses and every aspect scanned between them.
420
+ ...labelOver([Math.max(scanFrom, entered.at.getTime() - INGRESS_STEP_MS), Math.min(toT, end + INGRESS_STEP_MS)])
372
421
  })
373
422
  );
374
423
  }
375
424
  return out;
376
425
  }
377
426
  function moonIngresses(from, to) {
378
- return Object.freeze(ingresses(...span(from, to)).map((row) => Object.freeze({ at: row.at, sign: SIGN_SLUGS[row.signIndex] })));
427
+ const [fromT, toT] = span(from, to);
428
+ return Object.freeze(
429
+ ingresses(fromT, toT).map(
430
+ (row) => Object.freeze({ at: row.at, sign: SIGN_SLUGS[row.signIndex], ...around(row.at.getTime(), INGRESS_STEP_MS, fromT, toT) })
431
+ )
432
+ );
379
433
  }
380
434
  function moonAspects(from, to, options) {
381
435
  const bodies = bodiesOf(options);
@@ -388,9 +442,17 @@ function voidOfCourseWindows(from, to, options) {
388
442
  function voidOfCourseAt(at, options) {
389
443
  const bodies = bodiesOf(options);
390
444
  const t = dateFrom(at, "at").getTime();
391
- const list = windows(t - 3 * DAY_MS, t + 6 * DAY_MS, bodies);
445
+ const [fromT, toT] = [t - 3 * DAY_MS, t + 6 * DAY_MS];
446
+ const list = windows(fromT, toT, bodies);
392
447
  const current = list.find((window) => window.from.getTime() <= t && t < window.to.getTime()) ?? null;
393
- return Object.freeze({ at: new Date(t), isVoid: current !== null, current, next: list.find((window) => window.from.getTime() > t) ?? null });
448
+ return Object.freeze({
449
+ at: new Date(t),
450
+ isVoid: current !== null,
451
+ current,
452
+ next: list.find((window) => window.from.getTime() > t) ?? null,
453
+ // Every position the windows read: from four days before their scan to its end.
454
+ ...labelOver([fromT - 4 * DAY_MS, toT])
455
+ });
394
456
  }
395
457
 
396
458
  // src/techniques/aspect-patterns.ts
@@ -533,10 +595,11 @@ function aspectPatterns(points, aspects2) {
533
595
  }
534
596
  function chartAspectPatterns(natal) {
535
597
  const { chart } = resolvedChart(natal);
536
- return aspectPatterns(
598
+ const found = aspectPatterns(
537
599
  chart.bodies.map((row) => ({ body: row.body, lon: row.lon })),
538
600
  chart.aspects.map((row) => ({ a: row.a, b: row.b, type: row.type, orb: row.orb }))
539
601
  );
602
+ return Object.freeze({ ...found, ...labelOfCharts([chart]) });
540
603
  }
541
604
  var KIND_ORDER = ["grand-cross", "kite", "grand-trine", "t-square"];
542
605
  function patternContainment(patterns) {
@@ -725,11 +788,19 @@ function signsOver(fromT, toT) {
725
788
  return Array.from({ length: count + 1 }, (_, step) => SIGN_SLUGS[(first + step) % 12]);
726
789
  }
727
790
  function moonSignsBetween(from, to) {
791
+ const [fromT, toT] = moonSignSpan(from, to);
792
+ return Object.freeze(signsOver(fromT, toT));
793
+ }
794
+ function moonSignsBetweenDetailed(from, to) {
795
+ const [fromT, toT] = moonSignSpan(from, to);
796
+ return detailed(Object.freeze(signsOver(fromT, toT)), [fromT, toT]);
797
+ }
798
+ function moonSignSpan(from, to) {
728
799
  const fromT = dateFrom(from, "from").getTime();
729
800
  const toT = dateFrom(to, "to").getTime();
730
801
  if (fromT > toT) throw new RangeError("from must not be after to.");
731
802
  if (toT - fromT > MOON_SIGN_MAX_SPAN_DAYS * DAY_MS) throw new RangeError(`The span must not exceed ${MOON_SIGN_MAX_SPAN_DAYS} days.`);
732
- return Object.freeze(signsOver(fromT, toT));
803
+ return [fromT, toT];
733
804
  }
734
805
  function civilDate(value) {
735
806
  const match = typeof value === "string" ? /^(\d{4})-(\d{2})-(\d{2})$/u.exec(value) : null;
@@ -809,15 +880,19 @@ export {
809
880
  hasClassicalDignities,
810
881
  lunarReturn,
811
882
  lunarReturnInstant,
883
+ lunarReturnInstantDetailed,
812
884
  moonAspects,
813
885
  moonIngresses,
814
886
  moonSignCandidates,
815
887
  moonSignsBetween,
888
+ moonSignsBetweenDetailed,
816
889
  mostRecentSolarReturnInstant,
890
+ mostRecentSolarReturnInstantDetailed,
817
891
  mutualReceptions,
818
892
  patternContainment,
819
893
  solarReturn,
820
894
  solarReturnInstant,
895
+ solarReturnInstantDetailed,
821
896
  voidOfCourseAt,
822
897
  voidOfCourseWindows
823
898
  };
@@ -0,0 +1,36 @@
1
+ import { DeltaT } from './deltat.js';
2
+ import { T as TimeScale } from './time-scale-DIFNa0gz.js';
3
+
4
+ /**
5
+ * The bands of the time basis (docs/time.md, "The time bands"): from the ΔT
6
+ * band and the UT1 − UTC band an instant records, the 1-σ bands of the TT and
7
+ * the UT1 the engine used, by the scale the instant was given on and the basis
8
+ * that gave UT1 and TT. `@zodiacs/engine/calc` carries them into its results
9
+ * (docs/calc.md, "Bands") and `@zodiacs/engine/time` exports them. This module
10
+ * imports types only, so that the two entries can share it.
11
+ */
12
+
13
+ /** The 1-σ bands, in seconds, of the TT and the UT1 a time basis gave an instant. They are not bounds (docs/time.md, "The time bands"). */
14
+ interface TimeBands {
15
+ readonly tt: number;
16
+ readonly ut1: number;
17
+ }
18
+ /**
19
+ * The bands of a recorded instant, from its `deltaT` and `timeScale`: a
20
+ * `TimeBasis`, a root `Chart`, a calc receipt's instant, or a natal
21
+ * envelope's result from the time-basis conventions set on. With d the ΔT
22
+ * band (`deltaT.sigma`, 0 for a pin) and u the UT1 − UTC band
23
+ * (`timeScale.ut1MinusUtc.sigma`, 0 where there is none), the bands are
24
+ * `{ tt: 0, ut1: d }` on TT input, `{ tt: d, ut1: 0 }` on UT1 input, and on
25
+ * UTC input `{ tt: 0, ut1: u }` on the IERS basis, `{ tt: u, ut1: u }` with a
26
+ * pin, and `{ tt: √(u² + d²), ut1: u }` on the ΔT model, where u is 0 before
27
+ * 1972. It reads those fields only and recomputes no σ. Throws RangeError for
28
+ * a record without a `deltaT` or a `timeScale`, or with a scale, a basis or a
29
+ * band it does not know.
30
+ */
31
+ declare function timeBands(record: {
32
+ readonly deltaT: DeltaT;
33
+ readonly timeScale: TimeScale;
34
+ }): TimeBands;
35
+
36
+ export { type TimeBands as T, timeBands as t };
@@ -0,0 +1,47 @@
1
+ import { DeltaT } from './deltat.js';
2
+
3
+ /** The scale an input instant is on. UTC unless a caller says otherwise. */
4
+ type TimeScaleName = "utc" | "ut1" | "tt";
5
+ declare const TIME_SCALE_NAMES: readonly TimeScaleName[];
6
+ /**
7
+ * The ΔT model name for a value derived from leap seconds and IERS UT1 − UTC:
8
+ * a chart's from 1972 to the end of the IERS UT1 table. DELTA_T_MODEL names
9
+ * the model used at every other instant.
10
+ */
11
+ declare const DELTA_T_IERS_MODEL = "iers-utc/1";
12
+ /** UT1 − UTC as used: IERS observed or predicted, or 0 within 0.9 s outside the table. */
13
+ interface Ut1MinusUtc {
14
+ seconds: number;
15
+ sigma: number;
16
+ source: "observed" | "predicted" | "fallback";
17
+ }
18
+ /** TAI − UTC, s; `listed` is false after the list expires and its last value is carried. */
19
+ interface LeapSeconds {
20
+ taiMinusUtc: number;
21
+ listed: boolean;
22
+ }
23
+ /** How an instant became UT1 and TT: "iers" (leap seconds, IERS UT1 − UTC), "delta-t" (read as UT1, the ΔT model) or "pinned". */
24
+ interface TimeScale {
25
+ input: TimeScaleName;
26
+ basis: "iers" | "delta-t" | "pinned";
27
+ /** Null before 1972. */
28
+ ut1MinusUtc: Ut1MinusUtc | null;
29
+ /** Null where TT did not come from the leap seconds. */
30
+ leapSeconds: LeapSeconds | null;
31
+ }
32
+ /** An instant's UT1 and TT, days since 2000-01-01T12:00 on each scale, with its record. */
33
+ interface TimeBasis {
34
+ /**
35
+ * The UTC instant, ms; where the civil instant is read as UT1, that instant.
36
+ * An instant inside a leap second (23:59:60 on UTC) has no JavaScript
37
+ * timestamp: it gets the one JavaScript gives that reading, the next day's
38
+ * 00:00:00, with the TAI − UTC and UT1 − UTC in force during the leap second.
39
+ */
40
+ utcMs: number;
41
+ ut1Days: number;
42
+ ttDays: number;
43
+ deltaT: DeltaT;
44
+ timeScale: TimeScale;
45
+ }
46
+
47
+ export { DELTA_T_IERS_MODEL as D, type LeapSeconds as L, type TimeScale as T, type Ut1MinusUtc as U, type TimeScaleName as a, type TimeBasis as b, TIME_SCALE_NAMES as c };
package/dist/time.d.ts ADDED
@@ -0,0 +1,81 @@
1
+ import { b as TimeBasis, a as TimeScaleName } from './time-scale-DIFNa0gz.js';
2
+ export { D as DELTA_T_IERS_MODEL, L as LeapSeconds, c as TIME_SCALE_NAMES, T as TimeScale, U as Ut1MinusUtc } from './time-scale-DIFNa0gz.js';
3
+ export { DeltaT, DeltaTSegment } from './deltat.js';
4
+ export { E as EPHEMERIS_SPAN } from './reference-span-CILpclrz.js';
5
+ export { T as TimeBands, t as timeBands } from './time-bands-CZA9AlLg.js';
6
+
7
+ /** The nutation and obliquity of date. */
8
+ interface Tilt {
9
+ /** Nutation in longitude Δψ, arcseconds. */
10
+ readonly dpsi: number;
11
+ /** Nutation in obliquity Δε, arcseconds. */
12
+ readonly deps: number;
13
+ /** Mean obliquity of date εA (IAU 2006), degrees. */
14
+ readonly mobl: number;
15
+ /** True obliquity of date, εA + Δε, degrees. */
16
+ readonly tobl: number;
17
+ /**
18
+ * Equation of the equinoxes, arcseconds: Δψ cos εA plus the two largest
19
+ * complementary terms of IERS Conventions (2010), table 5.2e, 2640.96 µas
20
+ * sin Ω and 63.52 µas sin 2Ω. The rest of that table adds up to at most
21
+ * 44.0 µas from 1800 to 2200.
22
+ */
23
+ readonly ee: number;
24
+ }
25
+
26
+ /** EQJ to the mean ecliptic and equinox of date at a TT instant, and that instant's tilt. */
27
+ interface EclipticFrame {
28
+ /** TT, days from J2000.0. */
29
+ readonly tt: number;
30
+ /**
31
+ * R1(εA) P, row by row: its first row is the mean equinox of date as an EQJ
32
+ * direction, its third the pole of the mean ecliptic.
33
+ */
34
+ readonly rows: readonly number[];
35
+ readonly tilt: Tilt;
36
+ }
37
+
38
+ /**
39
+ * An instant's UT1 and TT, days from 2000-01-01T12:00 on each scale, with the
40
+ * `deltaT` and `timeScale` records a chart carries: the engine's own time
41
+ * basis (docs/time.md). `ms` is the instant on `scale` (UTC unless given), in
42
+ * milliseconds since 1970 as JavaScript counts them, within the range of a
43
+ * `Date`; `pin`, when given, is a ΔT (TT − UT1) in seconds, at most 1e10 in
44
+ * size, which replaces the engine's. Throws `RangeError` for any other value.
45
+ */
46
+ declare function timeBasis(ms: number, scale?: TimeScaleName, pin?: number): TimeBasis;
47
+ /**
48
+ * The time between two samples taken `days` apart on an input's scale, in
49
+ * days: `days` where both lie in one piece of the time basis, and the TT
50
+ * between them where a step of the basis lies between them (a leap second, a
51
+ * change of basis). `before` and `after` are records `timeBasis` gave.
52
+ */
53
+ declare function elapsedDays(before: TimeBasis, after: TimeBasis, days: number): number;
54
+ /**
55
+ * The nutation and obliquity at `tt`, days of TT from J2000.0 (astronomy-engine's
56
+ * `time.tt`): IAU 2000B's Δψ and Δε, the IAU 2006 mean obliquity, the true
57
+ * obliquity and the equation of the equinoxes. The result is frozen.
58
+ */
59
+ declare function tilt(tt: number): Tilt;
60
+ /**
61
+ * The rotation from astronomy-engine's EQJ (the J2000 mean equator and
62
+ * equinox) to the mean ecliptic and equinox of date at `tt`, days of TT from
63
+ * J2000.0, with that instant's tilt. The result, its rows and its tilt are a
64
+ * frozen copy; the frame the engine keeps for its own next call is never
65
+ * handed out.
66
+ */
67
+ declare function eclipticFrame(tt: number): EclipticFrame;
68
+ /** An EQJ vector on the mean ecliptic and equinox of date, [x, y, z], in the frame `eclipticFrame` gave. */
69
+ declare function meanEcliptic(frame: EclipticFrame, x: number, y: number, z: number): [number, number, number];
70
+ /**
71
+ * An EQJ vector's longitude and latitude on the true ecliptic and equinox of
72
+ * date at `tt`, degrees: the mean-ecliptic longitude plus Δψ, and the
73
+ * latitude. A vector with no direction, such as the zero vector, throws
74
+ * `RangeError`.
75
+ */
76
+ declare function eclipticOfDate(x: number, y: number, z: number, tt: number): {
77
+ lon: number;
78
+ lat: number;
79
+ };
80
+
81
+ export { type EclipticFrame, type Tilt, TimeBasis, TimeScaleName, eclipticFrame, eclipticOfDate, elapsedDays, meanEcliptic, tilt, timeBasis };
package/dist/time.js ADDED
@@ -0,0 +1,74 @@
1
+ import {
2
+ timeBands
3
+ } from "./chunk-I3L4POY7.js";
4
+ import {
5
+ eclipticFrame,
6
+ eclipticOfDate,
7
+ meanEcliptic
8
+ } from "./chunk-EEW7746S.js";
9
+ import {
10
+ DELTA_T_IERS_MODEL,
11
+ EPHEMERIS_SPAN,
12
+ TIME_SCALE_NAMES,
13
+ elapsedDays,
14
+ timeBasis
15
+ } from "./chunk-B5LKF437.js";
16
+ import {
17
+ tilt
18
+ } from "./chunk-CV53HA7R.js";
19
+ import "./chunk-SCRO6HWB.js";
20
+ import "./chunk-RMBWKZI2.js";
21
+ import "./chunk-BHJXUY67.js";
22
+
23
+ // src/time.ts
24
+ function finite(value, name) {
25
+ if (typeof value !== "number" || !Number.isFinite(value)) throw new RangeError(`${name} must be a finite number.`);
26
+ }
27
+ function timeBasis2(ms, scale, pin) {
28
+ if (typeof ms !== "number" || !(Math.abs(ms) <= 864e13)) throw new RangeError("ms must be an instant within the range of a Date.");
29
+ if (scale !== void 0 && !TIME_SCALE_NAMES.includes(scale)) throw new RangeError('scale must be "utc", "ut1" or "tt".');
30
+ if (pin !== void 0 && (typeof pin !== "number" || !(Math.abs(pin) <= 1e10))) {
31
+ throw new RangeError("pin must be a finite number of seconds, at most 1e10 in size.");
32
+ }
33
+ return timeBasis(ms, scale, pin);
34
+ }
35
+ function elapsedDays2(before, after, days) {
36
+ finite(days, "days");
37
+ return elapsedDays(before, after, days);
38
+ }
39
+ function tilt2(tt) {
40
+ finite(tt, "tt");
41
+ return Object.freeze(tilt(tt));
42
+ }
43
+ function eclipticFrame2(tt) {
44
+ finite(tt, "tt");
45
+ const frame = eclipticFrame(tt);
46
+ return Object.freeze({ tt: frame.tt, rows: Object.freeze(frame.rows.slice()), tilt: Object.freeze({ ...frame.tilt }) });
47
+ }
48
+ function meanEcliptic2(frame, x, y, z) {
49
+ finite(x, "x");
50
+ finite(y, "y");
51
+ finite(z, "z");
52
+ return meanEcliptic(frame, x, y, z);
53
+ }
54
+ function eclipticOfDate2(x, y, z, tt) {
55
+ finite(x, "x");
56
+ finite(y, "y");
57
+ finite(z, "z");
58
+ finite(tt, "tt");
59
+ const place = eclipticOfDate(x, y, z, tt);
60
+ if (Number.isNaN(place.lat)) throw new RangeError("the vector has no direction.");
61
+ return place;
62
+ }
63
+ export {
64
+ DELTA_T_IERS_MODEL,
65
+ EPHEMERIS_SPAN,
66
+ TIME_SCALE_NAMES,
67
+ eclipticFrame2 as eclipticFrame,
68
+ eclipticOfDate2 as eclipticOfDate,
69
+ elapsedDays2 as elapsedDays,
70
+ meanEcliptic2 as meanEcliptic,
71
+ tilt2 as tilt,
72
+ timeBands,
73
+ timeBasis2 as timeBasis
74
+ };
package/dist/timing.d.ts CHANGED
@@ -1,8 +1,9 @@
1
- import { T as TraditionalPlanet } from './rulers-Dla6h_Sm.js';
2
- export { C as CHALDEAN_ORDER, a as TRADITIONAL_RULERS } from './rulers-Dla6h_Sm.js';
3
- import { B as BodyName, s as PointName, Z as ZodiacSign, b as HouseNumber, D as DateInput, k as Sect } from './types-B-yb_tGL.js';
4
- import { N as NatalSource } from './api-WbxJ4Wj-.js';
1
+ import { T as TraditionalPlanet } from './rulers-CpS9qkvu.js';
2
+ export { C as CHALDEAN_ORDER, a as TRADITIONAL_RULERS } from './rulers-CpS9qkvu.js';
3
+ import { B as BodyName, t as PointName, Z as ZodiacSign, E as EphemerisFallback, b as HouseNumber, e as DateInput, j as Sect } from './types-BCnyWBQZ.js';
4
+ import { N as NatalSource } from './api-C_SVd9BJ.js';
5
5
  import './deltat.js';
6
+ import './time-scale-DIFNa0gz.js';
6
7
  import './crossings.js';
7
8
 
8
9
  /** The four angles of a chart with a birth time and place. */
@@ -27,7 +28,7 @@ interface TimingOrigin {
27
28
  * depends on a sect that the Sun's altitude at birth contradicts, which can
28
29
  * happen only inside the polar circles.
29
30
  */
30
- type TimingFlag = "outside-reference-span" | "sect-contradicts-altitude";
31
+ type TimingFlag = "outside-reference-span" | "sect-contradicts-altitude" | EphemerisFallback;
31
32
 
32
33
  /**
33
34
  * How a profection year is divided into months, each a sign on from the last.