@rotorsoft/act 1.22.5 → 1.22.6

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/dist/index.js CHANGED
@@ -89,6 +89,15 @@ function deprecated_event_names(names) {
89
89
  const deprecated = /* @__PURE__ */ new Set();
90
90
  for (const list of groups.values()) {
91
91
  if (list.length < 2) continue;
92
+ const by_version = /* @__PURE__ */ new Map();
93
+ for (const { version, name } of list) {
94
+ const clash = by_version.get(version);
95
+ if (clash)
96
+ throw new Error(
97
+ `duplicate event version: ${clash} and ${name} both map to version ${version} \u2014 leading zeros in a \`_v<n>\` suffix are not allowed; use a single canonical spelling`
98
+ );
99
+ by_version.set(version, name);
100
+ }
92
101
  list.sort((a, b) => b.version - a.version);
93
102
  for (let i = 1; i < list.length; i++) deprecated.add(list[i].name);
94
103
  }
@@ -534,18 +543,33 @@ function hour_in_zone(now, timeZone) {
534
543
  }).formatToParts(now);
535
544
  return Number(parts.find((p) => p.type === "hour")?.value);
536
545
  }
546
+ function hour_in_range(hour, start, end) {
547
+ return start < end ? hour >= start && hour < end : hour >= start || hour < end;
548
+ }
549
+ function is_dst_gap_open(now, timeZone, start) {
550
+ const hour = hour_in_zone(now, timeZone);
551
+ if (hour <= start) return false;
552
+ const prev = hour_in_zone(new Date(now.getTime() - 36e5), timeZone);
553
+ return prev === start - 1 && hour === start + 1;
554
+ }
537
555
  function in_autoclose_window(window, now) {
538
556
  if (!window) return true;
539
557
  const hour = hour_in_zone(now, window.timeZone);
540
- return window.start < window.end ? hour >= window.start && hour < window.end : hour >= window.start || hour < window.end;
558
+ return hour_in_range(hour, window.start, window.end) || is_dst_gap_open(now, window.timeZone, window.start);
541
559
  }
542
560
  function next_window_open(window, now) {
561
+ const start_ms = now.getTime();
543
562
  for (let h = 0; h <= 48; h++) {
544
- const candidate = new Date(now.getTime() + h * 36e5);
563
+ const candidate = new Date(start_ms + h * 36e5);
545
564
  if (hour_in_zone(candidate, window.timeZone) === window.start)
546
565
  return candidate;
566
+ const boundary = new Date(
567
+ candidate.getTime() - candidate.getTime() % 36e5
568
+ );
569
+ if (is_dst_gap_open(boundary, window.timeZone, window.start))
570
+ return boundary;
547
571
  }
548
- return new Date(now.getTime() + 864e5);
572
+ return new Date(start_ms + 864e5);
549
573
  }
550
574
 
551
575
  // src/internal/autoclose-policy.ts