@onlyworlds/sdk 4.42.1 → 4.42.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.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,14 @@ earlier history lives in git log only.
5
5
 
6
6
  ## [Unreleased]
7
7
 
8
+ ## [4.42.2] - 2026-10-20
9
+
10
+ Two calendar reading fixes, found writing the `atlas_calendar` profile's conformance fixture (OW Council h58 #8943, #8946).
11
+
12
+ ### Fixed
13
+ - **A down era has no year zero, even when its pivot falls mid-year.** Its year is now counted from the year holding the step just before the pivot, which reads `year_base` (1 by default). With the pivot mid-year, the earlier steps of the pivot's own year read year 0 ("0 BG") and every year before it one lower; with the pivot on a year's first step, nothing changes. The mirror of an up era, whose first partial year is year 1.
14
+ - **Equal-start eras resolve by a stated rule:** an up era over a down one, then the later era in the list. The comparator returned `-1` for any pair led by an up era, so two eras of one direction came out in the sort's order rather than the list's.
15
+
8
16
  ## [4.42.1] - 2026-10-20
9
17
 
10
18
  The calendar reader refuses what the `atlas_calendar` profile refuses (schema-dist `profiles/calendar.md`; Quillon's Unity read, OW Council h58 #8917).
package/dist/index.d.ts CHANGED
@@ -3999,7 +3999,12 @@ interface EraDomain {
3999
3999
  hi: number;
4000
4000
  }
4001
4001
  declare function resolveEraDomains(eras: CalendarEra[]): EraDomain[];
4002
- /** The era owning a step: domain containment; wild overlaps resolve to latest start (up wins ties). */
4002
+ /**
4003
+ * The era owning a step: domain containment; overlaps resolve to the latest start, then an
4004
+ * up era over a down one, then the later era in the list (the profile, calendar.md). The
4005
+ * comparator was `up ? -1 : 1` before 4.42.2: inconsistent for two eras of one direction,
4006
+ * so their order was the sort's, not the list's.
4007
+ */
4003
4008
  declare function eraForStep(cfg: CalendarConfig, step: number): CalendarEra | null;
4004
4009
  /** The display year for a step under an era (or the absolute year without one). */
4005
4010
  declare function displayYear(cfg: CalendarConfig, step: number, era: CalendarEra | null): number;
package/dist/index.js CHANGED
@@ -3078,7 +3078,9 @@ function eraForStep(cfg, step) {
3078
3078
  if (eras.length === 0) return null;
3079
3079
  const holding = resolveEraDomains(eras).filter((d) => step >= d.lo && step < d.hi);
3080
3080
  if (holding.length === 0) return null;
3081
- holding.sort((a, b) => b.era.start - a.era.start || ((a.era.direction ?? "up") === "up" ? -1 : 1));
3081
+ const place = new Map(eras.map((e, i) => [e, i]));
3082
+ const down = (e) => (e.direction ?? "up") === "down" ? 1 : 0;
3083
+ holding.sort((a, b) => b.era.start - a.era.start || down(a.era) - down(b.era) || (place.get(b.era) ?? 0) - (place.get(a.era) ?? 0));
3082
3084
  return holding[0].era;
3083
3085
  }
3084
3086
  function displayYear(cfg, step, era) {
@@ -3086,7 +3088,7 @@ function displayYear(cfg, step, era) {
3086
3088
  if (!era || era.restart === false) return abs;
3087
3089
  const base = era.year_base ?? 1;
3088
3090
  if ((era.direction ?? "up") === "down") {
3089
- return absoluteYear(cfg, era.start) - abs + base - 1;
3091
+ return absoluteYear(cfg, era.start - 1) - abs + base;
3090
3092
  }
3091
3093
  return abs - absoluteYear(cfg, era.start) + base;
3092
3094
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onlyworlds/sdk",
3
- "version": "4.42.1",
3
+ "version": "4.42.2",
4
4
  "description": "TypeScript SDK for the OnlyWorlds API - build world-building applications with type safety",
5
5
  "type": "module",
6
6
  "exports": {