@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.
Files changed (64) hide show
  1. package/CHANGELOG.md +797 -6
  2. package/LICENSING.md +354 -21
  3. package/NOTICE +166 -9
  4. package/README.md +327 -84
  5. package/dist/api-VOW6Umy5.d.ts +197 -0
  6. package/dist/calc.d.ts +279 -0
  7. package/dist/calc.js +853 -0
  8. package/dist/{chunk-NAJ735VN.js → chunk-2OWGBT3O.js} +1 -1
  9. package/dist/{chunk-4OSOCZY2.js → chunk-4NV4ZEFZ.js} +21 -6
  10. package/dist/chunk-A3U2ZS2W.js +29 -0
  11. package/dist/chunk-I7O5EGFV.js +25 -0
  12. package/dist/chunk-KFTJMMG7.js +61 -0
  13. package/dist/chunk-KHBLFXFG.js +227 -0
  14. package/dist/chunk-L6ZHWJZ6.js +355 -0
  15. package/dist/chunk-N4B5JNMA.js +473 -0
  16. package/dist/chunk-O3NJRGJ2.js +56 -0
  17. package/dist/{chunk-RETEVD4F.js → chunk-WOU7JVD3.js} +293 -154
  18. package/dist/crossings.d.ts +1 -1
  19. package/dist/deltat.d.ts +8 -8
  20. package/dist/geo.d.ts +137 -8
  21. package/dist/geo.js +28 -166
  22. package/dist/houses-extra.d.ts +81 -0
  23. package/dist/houses-extra.js +337 -0
  24. package/dist/houses-q1O2GGp4.d.ts +128 -0
  25. package/dist/index.d.ts +8 -201
  26. package/dist/index.js +38 -315
  27. package/dist/internal-math-CmJ9xtaW.d.ts +160 -0
  28. package/dist/internal-math.d.ts +3 -2
  29. package/dist/internal-math.js +2 -2
  30. package/dist/internal.d.ts +2 -1
  31. package/dist/internal.js +4 -4
  32. package/dist/receipt.d.ts +74 -29
  33. package/dist/receipt.js +194 -33
  34. package/dist/rulers-9wljfVaO.d.ts +10 -0
  35. package/dist/sky.d.ts +158 -0
  36. package/dist/sky.js +377 -0
  37. package/dist/techniques.d.ts +410 -0
  38. package/dist/techniques.js +830 -0
  39. package/dist/timing.d.ts +473 -0
  40. package/dist/timing.js +904 -0
  41. package/dist/{types-CeafogFp.d.ts → types-B4MCoCCS.d.ts} +35 -4
  42. package/dist/tzdb-2025c-00-6GVG6RYL.js +6 -0
  43. package/dist/tzdb-2025c-01-CEYMG3LE.js +6 -0
  44. package/dist/tzdb-2025c-02-NWQJCVUU.js +6 -0
  45. package/dist/tzdb-2025c-03-PLHP6VH4.js +6 -0
  46. package/dist/tzdb-2025c-04-MEKUJA6M.js +6 -0
  47. package/dist/tzdb-2025c-05-3K5YKZBL.js +6 -0
  48. package/dist/tzdb-2025c-06-L2VV5XJV.js +6 -0
  49. package/dist/tzdb-2025c-07-H3GLGJGY.js +6 -0
  50. package/dist/tzdb-2025c-08-DA7QQIGD.js +6 -0
  51. package/dist/tzdb-2025c-09-MTXIO3QL.js +6 -0
  52. package/dist/tzdb-2025c-10-ASL4UW5C.js +6 -0
  53. package/dist/tzdb-2025c-11-EQEOANYB.js +6 -0
  54. package/dist/tzdb-2025c-12-NKCCXJ5G.js +6 -0
  55. package/dist/tzdb-2025c-13-DYTF3UC7.js +6 -0
  56. package/dist/tzdb-2025c-14-C25H45R5.js +6 -0
  57. package/dist/tzdb-2025c-15-7OYYZWRY.js +6 -0
  58. package/dist/vedic.d.ts +393 -0
  59. package/dist/vedic.js +930 -0
  60. package/dist/window.d.ts +178 -0
  61. package/dist/window.js +961 -0
  62. package/package.json +31 -3
  63. package/dist/chunk-GFT24GFR.js +0 -25
  64. package/dist/internal-math-BE2hcSHd.d.ts +0 -271
package/dist/receipt.js CHANGED
@@ -1,9 +1,17 @@
1
+ import {
2
+ julianToGregorian,
3
+ parseCalendarDate
4
+ } from "./chunk-KFTJMMG7.js";
1
5
  import {
2
6
  dateFrom
3
7
  } from "./chunk-CPALRSPC.js";
4
8
  import {
5
- outsideReferenceSpan
6
- } from "./chunk-GFT24GFR.js";
9
+ DELTA_T_IERS_MODEL,
10
+ TIME_SCALE_NAMES,
11
+ UT1_DATA,
12
+ outsideReferenceSpan,
13
+ timeBasis
14
+ } from "./chunk-KHBLFXFG.js";
7
15
  import {
8
16
  DELTA_T_MODEL,
9
17
  DELTA_T_TABLE,
@@ -16,7 +24,7 @@ import {
16
24
  EPHEMERIS,
17
25
  SIGNS,
18
26
  aspectMotion
19
- } from "./chunk-NAJ735VN.js";
27
+ } from "./chunk-2OWGBT3O.js";
20
28
 
21
29
  // src/receipt-json.ts
22
30
  function parseReceiptJson(json, limits) {
@@ -117,6 +125,36 @@ function parseReceiptJson(json, limits) {
117
125
  }
118
126
  }
119
127
 
128
+ // src/semver.ts
129
+ var SEMVER = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/;
130
+ var DIGITS = /^\d+$/;
131
+ function isVersion(value) {
132
+ return SEMVER.test(value);
133
+ }
134
+ function compareNumbers(a, b) {
135
+ if (a.length !== b.length) return a.length < b.length ? -1 : 1;
136
+ return a < b ? -1 : a > b ? 1 : 0;
137
+ }
138
+ function compareVersions(a, b) {
139
+ const x = SEMVER.exec(a);
140
+ const y = SEMVER.exec(b);
141
+ if (!x || !y) throw new RangeError("compareVersions takes SemVer 2.0.0 versions.");
142
+ for (let part = 1; part <= 3; part += 1) {
143
+ const order = compareNumbers(x[part], y[part]);
144
+ if (order !== 0) return order;
145
+ }
146
+ if (x[4] === void 0 || y[4] === void 0) return x[4] === y[4] ? 0 : x[4] === void 0 ? 1 : -1;
147
+ const p = x[4].split(".");
148
+ const q = y[4].split(".");
149
+ for (let k = 0; k < p.length && k < q.length; k += 1) {
150
+ const numeric = DIGITS.test(p[k]);
151
+ if (numeric !== DIGITS.test(q[k])) return numeric ? -1 : 1;
152
+ const order = numeric ? compareNumbers(p[k], q[k]) : p[k] < q[k] ? -1 : p[k] > q[k] ? 1 : 0;
153
+ if (order !== 0) return order;
154
+ }
155
+ return p.length === q.length ? 0 : p.length < q.length ? -1 : 1;
156
+ }
157
+
120
158
  // src/receipt.ts
121
159
  var NATAL_ENVELOPE_SCHEMA = "zodiacs.natal-envelope.draft-v1";
122
160
  var NATAL_RECEIPT_SCHEMA = "zodiacs.calculation-receipt.draft-v1";
@@ -161,22 +199,32 @@ var CONVENTIONS_RC7 = Object.freeze({
161
199
  speed: "degrees-per-day;central-difference-plus-minus-0.001-day;nodes-plus-minus-0.25-day",
162
200
  aspects: "major-aspects;sun-moon-eight-planets;no-nodes;applying-instantaneous-orb-rate"
163
201
  });
164
- var CONVENTIONS = Object.freeze({
202
+ var CONVENTIONS_RC8 = Object.freeze({
165
203
  ...CONVENTIONS_RC7,
166
204
  planetPositions: "aberrated-geocentric-ecliptic-of-date;no-deflection",
167
205
  moonPosition: "astronomy-engine-ecliptic-geo-moon;no-light-time;no-aberration",
168
206
  deltaT: "tt-minus-ut1;ut1-read-as-utc;value-in-result"
169
207
  });
170
- var NATAL_RECEIPT_CONVENTION_SETS = Object.freeze([
171
- CONVENTIONS,
172
- CONVENTIONS_RC7,
173
- CONVENTIONS_RC3
174
- ]);
208
+ var CONVENTIONS_RC15 = Object.freeze({
209
+ ...CONVENTIONS_RC8,
210
+ deltaT: "tt-minus-ut1;value-in-result",
211
+ timeScale: "tt-from-leap-seconds-and-ut1-from-iers-1972-to-table-end;delta-t-model-otherwise;in-result",
212
+ localTime: "tzdb-shards-before-1970;host-intl-from-1970;flags-from-transition-record"
213
+ });
214
+ var CONVENTIONS = Object.freeze({
215
+ ...CONVENTIONS_RC15,
216
+ moonPosition: "astronomy-engine-geo-moon;no-light-time;no-aberration",
217
+ nutation: "iau2000b;equation-of-equinoxes-with-two-complementary-terms"
218
+ });
219
+ var NATAL_RECEIPT_CONVENTION_SETS = Object.freeze([CONVENTIONS, CONVENTIONS_RC15, CONVENTIONS_RC8, CONVENTIONS_RC7, CONVENTIONS_RC3]);
175
220
  var RC3_TO_RC6 = /^0\.1\.1-rc\.[3-6](?:\+[A-Za-z0-9.-]+)?$/;
176
221
  var RC7 = /^0\.1\.1-rc\.7(?:\+[A-Za-z0-9.-]+)?$/;
177
- var BEFORE_RC9 = /^0\.(?:0\.\d+(?:-[A-Za-z0-9.-]+)?|1\.0(?:-[A-Za-z0-9.-]+)?|1\.1-rc\.[0-8])(?:\+[A-Za-z0-9.-]+)?$/;
178
- var BEFORE_RC10 = /^0\.(?:0\.\d+(?:-[A-Za-z0-9.-]+)?|1\.0(?:-[A-Za-z0-9.-]+)?|1\.1-rc\.[0-9])(?:\+[A-Za-z0-9.-]+)?$/;
179
- var BEFORE_RC8 = /^0\.(?:0\.\d+(?:-[A-Za-z0-9.-]+)?|1\.0(?:-[A-Za-z0-9.-]+)?|1\.1-rc\.[0-7])(?:\+[A-Za-z0-9.-]+)?$/;
222
+ var RC8_TO_RC14 = /^0\.1\.1-rc\.(?:[89]|1[0-4])(?:\+[A-Za-z0-9.-]+)?$/;
223
+ var RC15 = /^0\.1\.1-rc\.15(?:\+[A-Za-z0-9.-]+)?$/;
224
+ var before = (version2, release) => compareVersions(version2, release) < 0;
225
+ var NUTATION_RELEASE = "0.1.1-rc.16";
226
+ var RC9_RELEASE = "0.1.1-rc.9";
227
+ var RC10_RELEASE = "0.1.1-rc.10";
180
228
  var COVERAGE = Object.freeze({
181
229
  assessment: "finite-reference-cases-only",
182
230
  broadDateRange: "not-certified",
@@ -323,8 +371,7 @@ function text(value, maximum = 128) {
323
371
  }
324
372
  function version(value) {
325
373
  const parsed = text(value, 64);
326
- if (!/^\d+\.\d+\.\d+(?:-[A-Za-z0-9.-]+)?(?:\+[A-Za-z0-9.-]+)?$/.test(parsed))
327
- fail("invalid_value");
374
+ if (!isVersion(parsed)) fail("invalid_value");
328
375
  return parsed;
329
376
  }
330
377
  function canonicalInstant(value) {
@@ -381,32 +428,77 @@ var DELTA_T_SEGMENTS = [
381
428
  "extrapolated"
382
429
  ];
383
430
  var J2000_MS = Date.UTC(2e3, 0, 1, 12);
384
- function validateDeltaT(value, instant) {
431
+ var IERS_SEGMENTS = ["observed", "predicted", "fallback"];
432
+ function validateDeltaT(value, instant, timeBasis2) {
385
433
  const deltaT = record(value);
386
434
  fields(deltaT, ["seconds", "sigma", "model", "table", "tableDigest", "segment"]);
387
435
  const seconds = number(deltaT.seconds, -1e10, 1e10);
388
436
  if (deltaT.model === "pinned") {
389
437
  if (deltaT.sigma !== null || deltaT.table !== null || deltaT.tableDigest !== null || deltaT.segment !== "pinned")
390
438
  fail("inconsistent_result");
391
- return;
439
+ return deltaT;
392
440
  }
393
- if (deltaT.model !== DELTA_T_MODEL) fail("unsupported_feature");
441
+ const iers = timeBasis2 && deltaT.model === DELTA_T_IERS_MODEL;
442
+ if (!iers && deltaT.model !== DELTA_T_MODEL) fail("unsupported_feature");
394
443
  number(deltaT.sigma, 0, 1e10);
395
444
  if (typeof deltaT.table !== "string" || !/^\d{4}-\d{2}-\d{2}$/.test(deltaT.table))
396
445
  fail("invalid_value");
397
446
  if (typeof deltaT.tableDigest !== "string" || !/^[a-f0-9]{16}$/.test(deltaT.tableDigest))
398
447
  fail("invalid_value");
399
- const segment = choice(deltaT.segment, DELTA_T_SEGMENTS);
400
- if (deltaT.tableDigest === DELTA_T_TABLE.digest) {
448
+ const segment = choice(deltaT.segment, iers ? IERS_SEGMENTS : DELTA_T_SEGMENTS);
449
+ if (!timeBasis2 && deltaT.tableDigest === DELTA_T_TABLE.digest) {
401
450
  const expected = deltaTAt((Date.parse(instant) - J2000_MS) / 864e5);
402
451
  if (deltaT.table !== expected.table || segment !== expected.segment || Math.abs(seconds - expected.seconds) > 1e-9 || Math.abs(deltaT.sigma - expected.sigma) > 1e-9)
403
452
  fail("inconsistent_result");
404
453
  }
454
+ return deltaT;
455
+ }
456
+ function same(actual, expected) {
457
+ if (typeof expected === "number") return typeof actual === "number" && Math.abs(actual - expected) <= 1e-9;
458
+ if (!expected || typeof expected !== "object") return actual === expected;
459
+ const keys = Object.keys(expected);
460
+ return !!actual && typeof actual === "object" && keys.length === Object.keys(actual).length && keys.every((key) => same(actual[key], expected[key]));
461
+ }
462
+ function validateTimeScale(value, deltaT, instant, scale) {
463
+ const timeScale = record(value);
464
+ fields(timeScale, ["input", "basis", "ut1MinusUtc", "leapSeconds"]);
465
+ const basis = choice(timeScale.basis, ["iers", "delta-t", "pinned"]);
466
+ const { ut1MinusUtc, leapSeconds } = timeScale;
467
+ if (ut1MinusUtc !== null) {
468
+ const ut1 = record(ut1MinusUtc);
469
+ fields(ut1, ["seconds", "sigma", "source"]);
470
+ number(ut1.seconds, -1, 1);
471
+ number(ut1.sigma, 0, 1);
472
+ choice(ut1.source, IERS_SEGMENTS);
473
+ }
474
+ if (leapSeconds !== null) {
475
+ const leap = record(leapSeconds);
476
+ fields(leap, ["taiMinusUtc", "listed"]);
477
+ if (!Number.isInteger(number(leap.taiMinusUtc, 10, 100))) fail("invalid_value");
478
+ bool(leap.listed);
479
+ }
480
+ const iers = deltaT.model === DELTA_T_IERS_MODEL;
481
+ if (timeScale.input !== scale || basis === "pinned" !== (deltaT.model === "pinned") || basis === "iers" !== iers || iers && (ut1MinusUtc === null || leapSeconds === null))
482
+ fail("inconsistent_result");
483
+ if (deltaT.tableDigest === UT1_DATA.digest || deltaT.tableDigest === DELTA_T_TABLE.digest) {
484
+ const expected = timeBasis(Date.parse(instant), scale);
485
+ if (!same(deltaT, expected.deltaT) || !same(timeScale, expected.timeScale)) fail("inconsistent_result");
486
+ }
405
487
  }
406
- function validateResult(value, instantaneousApplying, instant) {
488
+ function validateResult(value, instantaneousApplying, instant, scale) {
407
489
  const result = record(value);
408
- fields(result, ["bodies", "angles", "houses", "aspects", ...instant === null ? [] : ["deltaT"]]);
409
- if (instant !== null) validateDeltaT(result.deltaT, instant);
490
+ fields(result, [
491
+ "bodies",
492
+ "angles",
493
+ "houses",
494
+ "aspects",
495
+ ...instant === null ? [] : ["deltaT"],
496
+ ...scale === null ? [] : ["timeScale"]
497
+ ]);
498
+ if (instant !== null) {
499
+ const deltaT = validateDeltaT(result.deltaT, instant, scale !== null);
500
+ if (scale !== null) validateTimeScale(result.timeScale, deltaT, instant, scale);
501
+ }
410
502
  if (!Array.isArray(result.bodies) || result.bodies.length !== 12) fail("invalid_shape");
411
503
  const names = /* @__PURE__ */ new Set();
412
504
  const longitudes = /* @__PURE__ */ new Map();
@@ -509,13 +601,28 @@ function validateResult(value, instantaneousApplying, instant) {
509
601
  }
510
602
  return result;
511
603
  }
512
- function validateLocal(value, receipt) {
604
+ var LOCAL_FIELDS = ["date", "time", "timeZone", "offsetMinutes", "gapShiftMinutes", "policy"];
605
+ var LOCAL_TIME_BASIS_FIELDS = [
606
+ "calendar",
607
+ "writtenDate",
608
+ "tzdbVersion",
609
+ "dataForm",
610
+ "clock",
611
+ "transition",
612
+ "localMeanTime"
613
+ ];
614
+ function offsetMinutes(value) {
615
+ const minutes = number(value, -1440, 1440);
616
+ if (Math.abs(minutes * 6e4 - Math.round(minutes * 6e4)) > 1e-6) fail("invalid_context");
617
+ return minutes;
618
+ }
619
+ function validateLocal(value, receipt, timeBasis2) {
513
620
  if (value === null) {
514
621
  if (receipt.reference === "local-noon") fail("invalid_context");
515
622
  return;
516
623
  }
517
624
  const local = record(value);
518
- fields(local, ["date", "time", "timeZone", "offsetMinutes", "gapShiftMinutes", "policy"]);
625
+ fields(local, LOCAL_FIELDS, timeBasis2 ? LOCAL_TIME_BASIS_FIELDS : []);
519
626
  const date = text(local.date, 10), time = text(local.time, 5);
520
627
  if (!/^\d{4}-\d{2}-\d{2}$/.test(date) || !/^(?:[01]\d|2[0-3]):[0-5]\d$/.test(time))
521
628
  fail("invalid_context");
@@ -535,9 +642,55 @@ function validateLocal(value, receipt) {
535
642
  if (wall + Math.round(shiftMs) - Math.round(offsetMs) !== dateFrom(receipt.instant, "instant").getTime())
536
643
  fail("invalid_context");
537
644
  fixedFields(local.policy, { fold: "earlier", gap: "shift-forward" });
538
- if (receipt.inputFlags.includes("dst-gap") !== shift > 0 || receipt.inputFlags.includes("lmt") !== Math.abs(offset % 1) > 1e-9)
539
- fail("invalid_context");
645
+ if (receipt.inputFlags.includes("dst-gap") !== shift > 0) fail("invalid_context");
540
646
  if (receipt.reference === "local-noon" && time !== "12:00") fail("invalid_context");
647
+ if (!timeBasis2) {
648
+ if (receipt.inputFlags.includes("lmt") !== Math.abs(offset % 1) > 1e-9) fail("invalid_context");
649
+ return;
650
+ }
651
+ validateLocalRecord(local, receipt, date, offset, shift);
652
+ }
653
+ function validateLocalRecord(local, receipt, date, offset, shift) {
654
+ const has = (key) => Object.hasOwn(local, key);
655
+ const calendar = has("calendar") ? choice(local.calendar, ["gregorian", "julian"]) : "gregorian";
656
+ const written = has("writtenDate") ? text(local.writtenDate, 10) : null;
657
+ const version2 = has("tzdbVersion") ? local.tzdbVersion : void 0;
658
+ if (version2 !== void 0 && version2 !== null && (typeof version2 !== "string" || !/^\d{4}[a-z]$/.test(version2)))
659
+ fail("invalid_value");
660
+ const form = has("dataForm") ? choice(local.dataForm, ["main+backzone", "main", "host"]) : void 0;
661
+ const flags = receipt.inputFlags;
662
+ const lmt = has("clock") ? choice(local.clock, ["local-mean-time", "legal"]) === "local-mean-time" : flags.includes("lmt");
663
+ const gap = flags.includes("dst-gap");
664
+ const fold = flags.includes("dst-fold");
665
+ if (
666
+ // A local time resolves to UTC.
667
+ receipt.timeScale !== "utc" || written !== null && (!parseCalendarDate(written, calendar) || (calendar === "gregorian" ? written : julianToGregorian(written)) !== date) || form !== void 0 && form !== "host" && version2 === null || flags.includes("lmt") !== lmt || local.transition === null && (gap || fold)
668
+ )
669
+ fail("invalid_context");
670
+ let before2 = null;
671
+ if (has("transition") && local.transition !== null) {
672
+ const transition = record(local.transition);
673
+ fields(transition, ["at", "offsetBeforeMinutes", "offsetAfterMinutes", "cause"]);
674
+ const at = Date.parse(canonicalInstant(transition.at));
675
+ const instant = Date.parse(receipt.instant);
676
+ before2 = offsetMinutes(transition.offsetBeforeMinutes);
677
+ const after = offsetMinutes(transition.offsetAfterMinutes);
678
+ const near = (a, b) => Math.abs(a - b) <= 1e-9;
679
+ if (
680
+ // A change of half a day or more moves the date: a move across the date line.
681
+ choice(transition.cause, ["dst", "legal-change", "date-line"]) === "date-line" !== Math.abs(after - before2) >= 720 || !(gap ? after > before2 && near(after - before2, shift) && near(offset, after) && at <= instant : fold ? after < before2 && near(offset, before2) && at > instant : near(offset, after) && at <= instant)
682
+ )
683
+ fail("invalid_context");
684
+ }
685
+ if (has("localMeanTime") && local.localMeanTime !== null) {
686
+ const mean = record(local.localMeanTime);
687
+ fields(mean, ["longitude", "zoneOffsetMinutes"]);
688
+ const seconds = Math.round(number(mean.longitude, -180, 180) * 240);
689
+ offsetMinutes(mean.zoneOffsetMinutes);
690
+ const read = lmt ? offset : gap ? before2 : null;
691
+ if (read === null ? !(gap && !has("transition")) : (Math.round(read * 60) - seconds) % 86400 !== 0)
692
+ fail("invalid_context");
693
+ }
541
694
  }
542
695
  function repository(value) {
543
696
  const input = text(value, 256);
@@ -617,7 +770,7 @@ function validateEnvelope(input) {
617
770
  "provenance",
618
771
  "conventions",
619
772
  "coverage"
620
- ]);
773
+ ], ["timeScale"]);
621
774
  canonicalInstant(receipt.instant);
622
775
  if (receipt.sourceInstant !== null) {
623
776
  if (typeof receipt.sourceInstant !== "string" || receipt.sourceInstant.length > 40)
@@ -642,10 +795,15 @@ function validateEnvelope(input) {
642
795
  if (timeKnown && Math.abs(coords.latitude) === 90) fail("unsupported_feature");
643
796
  }
644
797
  const conventions = conventionSet(receipt.conventions);
798
+ const timeBasis2 = conventions === CONVENTIONS || conventions === CONVENTIONS_RC15;
799
+ const current = timeBasis2 || conventions === CONVENTIONS_RC8;
800
+ if (timeBasis2 !== Object.hasOwn(receipt, "timeScale")) fail("invalid_shape");
801
+ const scale = timeBasis2 ? choice(receipt.timeScale, TIME_SCALE_NAMES) : null;
645
802
  const result = validateResult(
646
803
  envelope.result,
647
804
  conventions !== CONVENTIONS_RC3,
648
- conventions === CONVENTIONS ? receipt.instant : null
805
+ current ? receipt.instant : null,
806
+ scale
649
807
  );
650
808
  const house = record(receipt.houses);
651
809
  fields(house, ["requested", "actual", "absenceReason"]);
@@ -659,7 +817,6 @@ function validateEnvelope(input) {
659
817
  if (result.houses && result.angles && TURNING_WITH_ASCENDANT.includes(result.houses.system) && !angularClose(result.houses.cusps[9], result.angles.mc) && Math.abs(receipt.coordinates.latitude) < 65)
660
818
  fail("inconsistent_result");
661
819
  const inputFlags = flagList(receipt.inputFlags, TIME_FLAGS);
662
- const current = conventions === CONVENTIONS;
663
820
  const resultFlags = flagList(receipt.resultFlags, current ? FLAGS : FLAGS_RC7);
664
821
  const expected = [...inputFlags];
665
822
  if (!timeKnown) expected.push("no-time");
@@ -679,8 +836,8 @@ function validateEnvelope(input) {
679
836
  version(ephemeris.version);
680
837
  }
681
838
  validateProvenance(receipt.provenance, engineVersion);
682
- validateLocal(receipt.localResolution, receipt);
683
- if (conventions === CONVENTIONS_RC3 && !RC3_TO_RC6.test(engineVersion) || conventions === CONVENTIONS_RC7 && !RC7.test(engineVersion) || current && BEFORE_RC8.test(engineVersion) || !HOUSE_SYSTEMS_BEFORE_RC9.includes(requested) && BEFORE_RC9.test(engineVersion) || !HOUSE_SYSTEMS_BEFORE_RC10.includes(requested) && BEFORE_RC10.test(engineVersion))
839
+ validateLocal(receipt.localResolution, receipt, timeBasis2);
840
+ if (conventions === CONVENTIONS_RC3 && !RC3_TO_RC6.test(engineVersion) || conventions === CONVENTIONS_RC7 && !RC7.test(engineVersion) || conventions === CONVENTIONS_RC8 && !RC8_TO_RC14.test(engineVersion) || conventions === CONVENTIONS_RC15 && !RC15.test(engineVersion) || conventions === CONVENTIONS && before(engineVersion, NUTATION_RELEASE) || !HOUSE_SYSTEMS_BEFORE_RC9.includes(requested) && before(engineVersion, RC9_RELEASE) || !HOUSE_SYSTEMS_BEFORE_RC10.includes(requested) && before(engineVersion, RC10_RELEASE))
684
841
  fail("inconsistent_result");
685
842
  fixedFields(receipt.coverage, COVERAGE);
686
843
  if (envelope.extensions !== void 0) record(envelope.extensions);
@@ -707,13 +864,14 @@ function createNatalEnvelope(chart, context = {}) {
707
864
  "aspects",
708
865
  "flags",
709
866
  "deltaT",
867
+ "timeScale",
710
868
  "engineVersion"
711
869
  ]);
712
870
  const input = record(source.input);
713
871
  fields(
714
872
  input,
715
873
  ["utc", "houseSystem", "timeKnown"],
716
- ["latitude", "longitude", "flags", "deltaT"]
874
+ ["latitude", "longitude", "flags", "deltaT", "timeScale"]
717
875
  );
718
876
  if (!(input.utc instanceof Date)) fail("invalid_value");
719
877
  const supplied = record(cloneData(context));
@@ -732,6 +890,7 @@ function createNatalEnvelope(chart, context = {}) {
732
890
  receipt: {
733
891
  schema: NATAL_RECEIPT_SCHEMA,
734
892
  instant: Date.prototype.toISOString.call(input.utc),
893
+ timeScale: input.timeScale ?? "utc",
735
894
  sourceInstant: supplied.sourceInstant === void 0 ? null : supplied.sourceInstant,
736
895
  timeKnown: input.timeKnown,
737
896
  reference: supplied.reference === void 0 ? "supplied-instant" : supplied.reference,
@@ -758,7 +917,8 @@ function createNatalEnvelope(chart, context = {}) {
758
917
  angles: source.angles,
759
918
  houses: source.houses,
760
919
  aspects: source.aspects,
761
- deltaT: source.deltaT
920
+ deltaT: source.deltaT,
921
+ timeScale: source.timeScale
762
922
  },
763
923
  ...supplied.extensions === void 0 ? {} : { extensions: supplied.extensions }
764
924
  };
@@ -788,6 +948,7 @@ function natalReplayInput(envelope) {
788
948
  const { receipt, result } = checked(envelope);
789
949
  return {
790
950
  utc: receipt.instant,
951
+ ...receipt.timeScale === void 0 || receipt.timeScale === "utc" ? {} : { timeScale: receipt.timeScale },
791
952
  houseSystem: receipt.houses.requested,
792
953
  timeKnown: receipt.timeKnown,
793
954
  flags: [...receipt.inputFlags],
@@ -0,0 +1,10 @@
1
+ import { Z as ZodiacSign } from './types-B4MCoCCS.js';
2
+
3
+ /** The seven visible planets of the traditional rulership scheme. */
4
+ type TraditionalPlanet = "Sun" | "Moon" | "Mercury" | "Venus" | "Mars" | "Jupiter" | "Saturn";
5
+ /** The traditional domicile ruler of each sign; the outer planets rule none. */
6
+ declare const TRADITIONAL_RULERS: Readonly<Record<ZodiacSign, TraditionalPlanet>>;
7
+ /** The seven planets in descending order of their spheres, Saturn to the Moon. */
8
+ declare const CHALDEAN_ORDER: readonly TraditionalPlanet[];
9
+
10
+ export { CHALDEAN_ORDER as C, type TraditionalPlanet as T, TRADITIONAL_RULERS as a };
package/dist/sky.d.ts ADDED
@@ -0,0 +1,158 @@
1
+ import { B as BodyName, D as DateInput } from './types-B4MCoCCS.js';
2
+ import { T as TraditionalPlanet } from './rulers-9wljfVaO.js';
3
+ export { C as CHALDEAN_ORDER } from './rulers-9wljfVaO.js';
4
+ import './deltat.js';
5
+
6
+ /** A body the sky functions accept: the Sun, the Moon and the planets. */
7
+ type SkyBody = Exclude<BodyName, "North Node" | "South Node">;
8
+ /** A place: geodetic latitude and longitude in degrees (east positive) and height in metres. */
9
+ interface Observer {
10
+ latitude: number;
11
+ longitude: number;
12
+ /** Metres above the WGS84 ellipsoid, from −10,000 to 100,000; 0 when absent. */
13
+ height?: number;
14
+ }
15
+ /** The point of the disc that meets the horizon. Planets are always taken at their centre. */
16
+ type Limb = "upper" | "centre" | "lower";
17
+ /** `"standard"`: 34′ of refraction at the horizon. `"none"`: the geometric horizon. */
18
+ type Refraction = "standard" | "none";
19
+ interface SkyOptions {
20
+ /** `"upper"` for the Sun and Moon unless given; the planets accept only `"centre"`. */
21
+ limb?: Limb;
22
+ /** `"standard"` unless given. */
23
+ refraction?: Refraction;
24
+ /** Most position evaluations the searches may make: a positive integer or `Infinity` (default). */
25
+ maxSamples?: number;
26
+ }
27
+ interface SkyDayOptions extends SkyOptions {
28
+ /** The clock that defines the day, minutes east of UTC. Default: the observer's local mean time, longitude × 4. */
29
+ utcOffsetMinutes?: number;
30
+ }
31
+ type SkyEventKind = "rise" | "set" | "upper-transit" | "lower-transit";
32
+ interface SkyEvent {
33
+ readonly kind: SkyEventKind;
34
+ readonly at: Date;
35
+ /** Geometric (unrefracted) topocentric altitude of the body's centre, degrees. */
36
+ readonly altitude: number;
37
+ /** Topocentric azimuth of the centre, degrees from north through east, in [0, 360). */
38
+ readonly azimuth: number;
39
+ }
40
+ /**
41
+ * `"never-rises"` and `"never-sets"`: the window holds no rise and no set, and
42
+ * the body stayed below (polar night, for the Sun) or above (polar day) the
43
+ * horizon of the conventions throughout. `"outside-reference-span"`: the
44
+ * window reaches outside `REFERENCE_SPAN`.
45
+ */
46
+ type SkyFlag = "never-rises" | "never-sets" | "outside-reference-span";
47
+ interface SkyConventions {
48
+ readonly limb: Limb;
49
+ readonly refraction: Refraction;
50
+ /** The refraction at the horizon, arcminutes: 34 or 0. */
51
+ readonly refractionArcmin: number;
52
+ }
53
+ interface SkyWindow {
54
+ readonly body: SkyBody;
55
+ readonly observer: Readonly<Required<Observer>>;
56
+ readonly from: Date;
57
+ readonly to: Date;
58
+ readonly conventions: SkyConventions;
59
+ readonly flags: readonly SkyFlag[];
60
+ /** Position evaluations the searches made. */
61
+ readonly samples: number;
62
+ }
63
+ /** A search either completes, with every event in the window, or is refused whole. */
64
+ type SkyEvents = (SkyWindow & {
65
+ readonly status: "complete";
66
+ readonly events: readonly SkyEvent[];
67
+ }) | (SkyWindow & {
68
+ readonly status: "refused";
69
+ readonly reason: "sample-budget";
70
+ readonly events: readonly [];
71
+ });
72
+ /** Refraction at the horizon, arcminutes (USNO, Rise, Set, and Twilight Definitions). */
73
+ declare const STANDARD_REFRACTION_ARCMIN = 34;
74
+ /** Radii for the semi-diameter, km: the Sun's (959.64″ at 1 au), the Moon's IAU mean radius. */
75
+ declare const SKY_RADII_KM: Readonly<{
76
+ Sun: 696000;
77
+ Moon: 1737.4;
78
+ }>;
79
+ /**
80
+ * Every rise, set, upper transit and lower transit of `body` in [from, to),
81
+ * for `observer`, in time order.
82
+ *
83
+ * A rise or set is the instant the geometric topocentric altitude of the
84
+ * body's centre equals −(refraction) − (semi-diameter) for the upper limb
85
+ * (+ for the lower, 0 for the centre). A transit is the instant the
86
+ * topocentric hour angle is 0° (upper) or 180° (lower). Throws RangeError for
87
+ * an unknown body, observer field or option, an invalid window, or an instant
88
+ * outside `EPHEMERIS_SPAN`.
89
+ */
90
+ declare function skyEvents(body: SkyBody, observer: Observer, from: DateInput, to: DateInput, options?: SkyOptions): SkyEvents;
91
+ /**
92
+ * The events of one calendar day on a clock `utcOffsetMinutes` east of UTC
93
+ * (by default the observer's local mean time): `skyEvents` over that day.
94
+ */
95
+ declare function skyEventsOn(body: SkyBody, observer: Observer, date: string, options?: SkyDayOptions): SkyEvents;
96
+
97
+ /** The ruler of each weekday, Sunday first (Cassius Dio 37.18–19). */
98
+ declare const PLANETARY_DAY_RULERS: readonly TraditionalPlanet[];
99
+ interface PlanetaryHour {
100
+ /** 1 to 24: hours 1–12 are the day's, 13–24 the night's. */
101
+ readonly number: number;
102
+ readonly period: "day" | "night";
103
+ readonly ruler: TraditionalPlanet;
104
+ readonly start: Date;
105
+ /** Exclusive; the next hour's start. */
106
+ readonly end: Date;
107
+ }
108
+ interface PlanetaryDayBase {
109
+ /** The calendar date whose sunrise begins the day, on the clock of `utcOffsetMinutes`. */
110
+ readonly date: string;
111
+ readonly utcOffsetMinutes: number;
112
+ /** 0 for Sunday to 6 for Saturday. */
113
+ readonly weekday: number;
114
+ /** The weekday's ruler, which rules the first hour. */
115
+ readonly ruler: TraditionalPlanet;
116
+ readonly conventions: SkyConventions;
117
+ readonly flags: readonly SkyFlag[];
118
+ readonly samples: number;
119
+ }
120
+ /**
121
+ * `"complete"`: the Sun rose on the date, set, and rose again, and the 24
122
+ * hours are given. `"no-sunrise"`: the date's 24 hours on the chosen clock
123
+ * hold no sunrise, in polar day or night (`flags` says which) or when the
124
+ * clock's midnight falls next to sunrise. `"no-sunset"`: the Sun rose but did
125
+ * not set within three days of the date's start, as polar day begins.
126
+ * `"no-next-sunrise"`: it rose and set but did not rise again within those
127
+ * three days, as polar night begins. `"refused"`: the sample budget ran out.
128
+ */
129
+ type PlanetaryDay = (PlanetaryDayBase & {
130
+ readonly status: "complete";
131
+ readonly sunrise: Date;
132
+ readonly sunset: Date;
133
+ readonly nextSunrise: Date;
134
+ readonly hours: readonly PlanetaryHour[];
135
+ }) | (PlanetaryDayBase & {
136
+ readonly status: "no-sunrise" | "no-sunset" | "no-next-sunrise" | "refused";
137
+ readonly sunrise: null;
138
+ readonly sunset: null;
139
+ readonly nextSunrise: null;
140
+ readonly hours: readonly [];
141
+ });
142
+ /**
143
+ * The planetary day that begins at the Sun's first rise on `date` (YYYY-MM-DD
144
+ * on the clock `utcOffsetMinutes` east of UTC, by default the observer's local
145
+ * mean time): the day's ruler, sunrise, sunset, the next sunrise and the 24
146
+ * hours. Rise and set follow the options of `skyEvents` for the Sun.
147
+ */
148
+ declare function planetaryHours(observer: Observer, date: string, options?: SkyDayOptions): PlanetaryDay;
149
+ /**
150
+ * The planetary hour running at `at`, with its day: the day whose sunrise is
151
+ * the last at or before `at`. `hour` is null when that day is not complete.
152
+ */
153
+ declare function planetaryHourAt(observer: Observer, at: DateInput, options?: SkyDayOptions): {
154
+ readonly day: PlanetaryDay;
155
+ readonly hour: PlanetaryHour | null;
156
+ };
157
+
158
+ export { type Limb, type Observer, PLANETARY_DAY_RULERS, type PlanetaryDay, type PlanetaryHour, type Refraction, SKY_RADII_KM, STANDARD_REFRACTION_ARCMIN, type SkyBody, type SkyConventions, type SkyDayOptions, type SkyEvent, type SkyEventKind, type SkyEvents, type SkyFlag, type SkyOptions, TraditionalPlanet, planetaryHourAt, planetaryHours, skyEvents, skyEventsOn };