@wix/himalaya-cli 0.2024.0 → 0.2026.0

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.
@@ -4361,6 +4361,12 @@ export interface WidgetSnapshot {
4361
4361
  * PRESENTATION axis. Each region is drawn with the same family allowlist as `payload`.
4362
4362
  */
4363
4363
  regions?: Record<string, Component>;
4364
+ /**
4365
+ * How much this widget matters right now, so iOS can rotate it to the top of a Smart Stack
4366
+ * (`TimelineEntryRelevance`). A frame's own `relevance` wins while that frame is current.
4367
+ * Android has no equivalent and ignores it.
4368
+ */
4369
+ relevance?: WidgetRelevance;
4364
4370
  }
4365
4371
  /** One frame of a produce-time widget timeline (Lever A). */
4366
4372
  export interface WidgetFrame {
@@ -4368,6 +4374,20 @@ export interface WidgetFrame {
4368
4374
  startsAt: number;
4369
4375
  /** The frozen component tree for this frame — literals only, like `payload`. */
4370
4376
  payload: Component;
4377
+ /**
4378
+ * The size trees for this frame (`small` / `medium` / `circular` / …), drawn instead of the
4379
+ * snapshot's `regions` while the frame is current. Absent → the frame draws `payload` at every
4380
+ * size. Each is drawn with the same family allowlist as `payload`.
4381
+ */
4382
+ regions?: Record<string, Component>;
4383
+ /** How much this frame matters while it is current; absent → the snapshot's `relevance`. */
4384
+ relevance?: WidgetRelevance;
4385
+ }
4386
+ /** Smart Stack relevance (iOS `TimelineEntryRelevance`): a 0–100 score on the producer's own
4387
+ * scale, held for `durationSeconds` (0 → for as long as the entry is shown). */
4388
+ export interface WidgetRelevance {
4389
+ score: number;
4390
+ durationSeconds: number;
4371
4391
  }
4372
4392
  /**
4373
4393
  * Lever E — an interactive widget action reference on a widget-safe `Button`. Names a
@@ -2031,6 +2031,44 @@ export declare const widgetSnapshotSchema: {
2031
2031
  readonly payload: {
2032
2032
  readonly $ref: "#/$defs/component";
2033
2033
  };
2034
+ readonly regions: {
2035
+ readonly type: "object";
2036
+ readonly additionalProperties: {
2037
+ readonly $ref: "#/$defs/component";
2038
+ };
2039
+ };
2040
+ readonly relevance: {
2041
+ readonly type: "object";
2042
+ readonly additionalProperties: false;
2043
+ readonly required: readonly ["score", "durationSeconds"];
2044
+ readonly properties: {
2045
+ readonly score: {
2046
+ readonly type: "integer";
2047
+ readonly minimum: 0;
2048
+ readonly maximum: 100;
2049
+ };
2050
+ readonly durationSeconds: {
2051
+ readonly type: "integer";
2052
+ readonly minimum: 0;
2053
+ };
2054
+ };
2055
+ };
2056
+ };
2057
+ };
2058
+ };
2059
+ readonly relevance: {
2060
+ readonly type: "object";
2061
+ readonly additionalProperties: false;
2062
+ readonly required: readonly ["score", "durationSeconds"];
2063
+ readonly properties: {
2064
+ readonly score: {
2065
+ readonly type: "integer";
2066
+ readonly minimum: 0;
2067
+ readonly maximum: 100;
2068
+ };
2069
+ readonly durationSeconds: {
2070
+ readonly type: "integer";
2071
+ readonly minimum: 0;
2034
2072
  };
2035
2073
  };
2036
2074
  };
@@ -10353,6 +10353,15 @@ var CORE_COMPONENTS = /* @__PURE__ */ new Set([
10353
10353
  "himalaya.Lottie",
10354
10354
  "himalaya.Rive"
10355
10355
  ]);
10356
+ var WIDGET_RELEVANCE_SCHEMA = {
10357
+ type: "object",
10358
+ additionalProperties: false,
10359
+ required: ["score", "durationSeconds"],
10360
+ properties: {
10361
+ score: { type: "integer", minimum: 0, maximum: 100 },
10362
+ durationSeconds: { type: "integer", minimum: 0 }
10363
+ }
10364
+ };
10356
10365
  var widgetSnapshotSchema = {
10357
10366
  $id: "https://himalaya.dev/schema/widget-snapshot.json",
10358
10367
  type: "object",
@@ -10409,10 +10418,17 @@ var widgetSnapshotSchema = {
10409
10418
  required: ["startsAt", "payload"],
10410
10419
  properties: {
10411
10420
  startsAt: { type: "integer", minimum: 0 },
10412
- payload: { $ref: "#/$defs/component" }
10421
+ payload: { $ref: "#/$defs/component" },
10422
+ // The frame's own size trees, scanned below like the snapshot's.
10423
+ regions: {
10424
+ type: "object",
10425
+ additionalProperties: { $ref: "#/$defs/component" }
10426
+ },
10427
+ relevance: WIDGET_RELEVANCE_SCHEMA
10413
10428
  }
10414
10429
  }
10415
10430
  },
10431
+ relevance: WIDGET_RELEVANCE_SCHEMA,
10416
10432
  // RFC 0047 — named presentation regions: each value is a frozen component tree
10417
10433
  // (compact/minimal/expanded, list/grid/nowPlaying, …). Scanned for the frozen
10418
10434
  // guarantee + family allowlist below, exactly like `payload` and `frames`.
@@ -10569,8 +10585,13 @@ function validateWidget(snapshot) {
10569
10585
  }
10570
10586
  if (Array.isArray(snap.frames)) {
10571
10587
  snap.frames.forEach((frame, i) => {
10572
- const p = frame?.payload;
10573
- scanWidgetPayload(p, family, `$.frames[${i}].payload`, bindingViolations, disallowedComponents, timeRefViolations, intentViolations, actionSites);
10588
+ const f = frame;
10589
+ scanWidgetPayload(f?.payload, family, `$.frames[${i}].payload`, bindingViolations, disallowedComponents, timeRefViolations, intentViolations, actionSites);
10590
+ if (f?.regions && typeof f.regions === "object" && !Array.isArray(f.regions)) {
10591
+ for (const [key, region] of Object.entries(f.regions)) {
10592
+ scanWidgetPayload(region, family, `$.frames[${i}].regions.${key}`, bindingViolations, disallowedComponents, timeRefViolations, intentViolations, actionSites);
10593
+ }
10594
+ }
10574
10595
  });
10575
10596
  }
10576
10597
  if (snap.regions && typeof snap.regions === "object" && !Array.isArray(snap.regions)) {
@@ -8043,6 +8043,15 @@ var screenDescriptorSchema = {
8043
8043
  }
8044
8044
  }
8045
8045
  };
8046
+ var WIDGET_RELEVANCE_SCHEMA = {
8047
+ type: "object",
8048
+ additionalProperties: false,
8049
+ required: ["score", "durationSeconds"],
8050
+ properties: {
8051
+ score: { type: "integer", minimum: 0, maximum: 100 },
8052
+ durationSeconds: { type: "integer", minimum: 0 }
8053
+ }
8054
+ };
8046
8055
  var widgetSnapshotSchema = {
8047
8056
  $id: "https://himalaya.dev/schema/widget-snapshot.json",
8048
8057
  type: "object",
@@ -8099,10 +8108,17 @@ var widgetSnapshotSchema = {
8099
8108
  required: ["startsAt", "payload"],
8100
8109
  properties: {
8101
8110
  startsAt: { type: "integer", minimum: 0 },
8102
- payload: { $ref: "#/$defs/component" }
8111
+ payload: { $ref: "#/$defs/component" },
8112
+ // The frame's own size trees, scanned below like the snapshot's.
8113
+ regions: {
8114
+ type: "object",
8115
+ additionalProperties: { $ref: "#/$defs/component" }
8116
+ },
8117
+ relevance: WIDGET_RELEVANCE_SCHEMA
8103
8118
  }
8104
8119
  }
8105
8120
  },
8121
+ relevance: WIDGET_RELEVANCE_SCHEMA,
8106
8122
  // RFC 0047 — named presentation regions: each value is a frozen component tree
8107
8123
  // (compact/minimal/expanded, list/grid/nowPlaying, …). Scanned for the frozen
8108
8124
  // guarantee + family allowlist below, exactly like `payload` and `frames`.
package/dist/cli.mjs CHANGED
@@ -20411,8 +20411,13 @@ function validateWidget(snapshot4) {
20411
20411
  }
20412
20412
  if (Array.isArray(snap.frames)) {
20413
20413
  snap.frames.forEach((frame, i2) => {
20414
- const p2 = frame?.payload;
20415
- scanWidgetPayload(p2, family, `$.frames[${i2}].payload`, bindingViolations, disallowedComponents, timeRefViolations, intentViolations, actionSites2);
20414
+ const f2 = frame;
20415
+ scanWidgetPayload(f2?.payload, family, `$.frames[${i2}].payload`, bindingViolations, disallowedComponents, timeRefViolations, intentViolations, actionSites2);
20416
+ if (f2?.regions && typeof f2.regions === "object" && !Array.isArray(f2.regions)) {
20417
+ for (const [key4, region] of Object.entries(f2.regions)) {
20418
+ scanWidgetPayload(region, family, `$.frames[${i2}].regions.${key4}`, bindingViolations, disallowedComponents, timeRefViolations, intentViolations, actionSites2);
20419
+ }
20420
+ }
20416
20421
  });
20417
20422
  }
20418
20423
  if (snap.regions && typeof snap.regions === "object" && !Array.isArray(snap.regions)) {
@@ -20451,7 +20456,7 @@ function validateWidget(snapshot4) {
20451
20456
  intentViolations
20452
20457
  };
20453
20458
  }
20454
- var screenDescriptorSchema, screenValidateFn, FixtureValidator, CORE_COMPONENTS, widgetSnapshotSchema, WIDGET_BINDING, VALID_TIMEREF_STYLES, utf8ByteLength, WIDGET_ACTION_IDENTIFIER, MAX_WIDGET_ACTION_TTL_SECONDS, WIDGET_INTENT_RULES, widgetValidateFn;
20459
+ var screenDescriptorSchema, screenValidateFn, FixtureValidator, CORE_COMPONENTS, WIDGET_RELEVANCE_SCHEMA, widgetSnapshotSchema, WIDGET_BINDING, VALID_TIMEREF_STYLES, utf8ByteLength, WIDGET_ACTION_IDENTIFIER, MAX_WIDGET_ACTION_TTL_SECONDS, WIDGET_INTENT_RULES, widgetValidateFn;
20455
20460
  var init_validator = __esm({
20456
20461
  "../../core/ts/src/validator.ts"() {
20457
20462
  init_define_HHP_CATALOG();
@@ -21685,6 +21690,15 @@ var init_validator = __esm({
21685
21690
  "himalaya.Lottie",
21686
21691
  "himalaya.Rive"
21687
21692
  ]);
21693
+ WIDGET_RELEVANCE_SCHEMA = {
21694
+ type: "object",
21695
+ additionalProperties: false,
21696
+ required: ["score", "durationSeconds"],
21697
+ properties: {
21698
+ score: { type: "integer", minimum: 0, maximum: 100 },
21699
+ durationSeconds: { type: "integer", minimum: 0 }
21700
+ }
21701
+ };
21688
21702
  widgetSnapshotSchema = {
21689
21703
  $id: "https://himalaya.dev/schema/widget-snapshot.json",
21690
21704
  type: "object",
@@ -21741,10 +21755,17 @@ var init_validator = __esm({
21741
21755
  required: ["startsAt", "payload"],
21742
21756
  properties: {
21743
21757
  startsAt: { type: "integer", minimum: 0 },
21744
- payload: { $ref: "#/$defs/component" }
21758
+ payload: { $ref: "#/$defs/component" },
21759
+ // The frame's own size trees, scanned below like the snapshot's.
21760
+ regions: {
21761
+ type: "object",
21762
+ additionalProperties: { $ref: "#/$defs/component" }
21763
+ },
21764
+ relevance: WIDGET_RELEVANCE_SCHEMA
21745
21765
  }
21746
21766
  }
21747
21767
  },
21768
+ relevance: WIDGET_RELEVANCE_SCHEMA,
21748
21769
  // RFC 0047 — named presentation regions: each value is a frozen component tree
21749
21770
  // (compact/minimal/expanded, list/grid/nowPlaying, …). Scanned for the frozen
21750
21771
  // guarantee + family allowlist below, exactly like `payload` and `frames`.
@@ -45929,6 +45950,7 @@ function resolveIdiom(tokens2, ctx = {}) {
45929
45950
  var IDIOM_CONTEXTS, UNSAFE_KEYS;
45930
45951
  var init_idiom = __esm({
45931
45952
  "../../core/ts/src/idiom.ts"() {
45953
+ "use strict";
45932
45954
  init_define_HHP_CATALOG();
45933
45955
  IDIOM_CONTEXTS = {
45934
45956
  ios: { native: ["ios"] },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/himalaya-cli",
3
- "version": "0.2024.0",
3
+ "version": "0.2026.0",
4
4
  "type": "module",
5
5
  "description": "himi — the Himalaya authoring CLI. Build a Tier-5 content package on your own machine, push it to the production serve as a draft, preview it on web + Himi Player, and read worker logs back — the remote dev loop. Wraps @himalaya/serve-cli for transport.",
6
6
  "keywords": [
@@ -82,5 +82,5 @@
82
82
  "artifactId": "himalaya-cli"
83
83
  }
84
84
  },
85
- "falconPackageHash": "1563ebdd984e490852d85903a2ab8cb0ef9ac4c9138e91832ead2480"
85
+ "falconPackageHash": "f9650f9f54d006ec5ef583c2b237eccc6eb00c474c9e4670c068cb4c"
86
86
  }
@@ -23,7 +23,7 @@ import { queryEvents } from "@himalaya/wix-events";
23
23
  import { queryDraftPosts } from "@himalaya/wix-blog";
24
24
  import {
25
25
  str, hhmm, sameLocalDay, dayLabel, rankItems, glanceFields, bookingItems, orderItems, eventItems, blogItems, shownUntil,
26
- GLANCE_COPY, focusFields, focusList, type GlanceFields, type GlanceFocus, type GlanceFocusOption,
26
+ GLANCE_COPY, focusFields, focusList, type GlanceFields, type GlanceFocus, type GlanceFocusOption, type GlanceItem,
27
27
  } from "./glance.js";
28
28
 
29
29
  export { isSectionUnavailable, isSignedOut, dayLabel };
@@ -45,9 +45,24 @@ export interface TodayBooking {
45
45
 
46
46
  /** The glance ("what matters now", glance.ts) rides on the same state: the existing fields stay
47
47
  * for the embedding hosts that bind them (the embedding guide), the glance fields are added. */
48
+ /** One future frame of a focus's timeline: the glance as it will read from `startsAt` (epoch
49
+ * SECONDS), re-ranked at that moment, with the score of what it headlines. */
50
+ export type GlanceFrame = GlanceFields & { startsAt: number; score: number; durationSeconds: number };
51
+
52
+ /** One focus's glance now, and the frames that follow it. */
53
+ export type FocusGlance = GlanceFields & {
54
+ validUntil: number;
55
+ /** The headline's score (0 when nothing is waiting): the widget's Smart Stack relevance. */
56
+ score: number;
57
+ /** Future frames, ascending, at most `MAX_FRAMES - 1` within 24 h; each differs from the one before. */
58
+ frames: GlanceFrame[];
59
+ /** Epoch SECONDS the last frame stops being true; equals `validUntil` without frames. */
60
+ timelineUntil: number;
61
+ };
62
+
48
63
  export interface TodayState extends GlanceFields {
49
64
  /** The glance for each focus a widget may be set to ("now" + the provisioned areas). */
50
- focuses: Record<GlanceFocus, GlanceFields & { validUntil: number }>;
65
+ focuses: Record<GlanceFocus, FocusGlance>;
51
66
  /** Those focuses with owner-facing titles, in order — the widget picker's list. */
52
67
  focusList: GlanceFocusOption[];
53
68
  eventsReady: boolean;
@@ -150,8 +165,46 @@ function upcoming(rows: Rec[] | null, statuses: string[], now: Date): Rec[] {
150
165
  .sort((a, b) => Date.parse(startOf(a)) - Date.parse(startOf(b)) || str(a, "id").localeCompare(str(b, "id")));
151
166
  }
152
167
 
168
+ /** A widget timeline is small: WidgetKit budgets its reloads, and a frame is a whole tree. */
169
+ export const MAX_FRAMES = 8;
170
+ export const TIMELINE_HOURS = 24;
171
+ /** A count read now is not vouched for past this: a later frame drops it. */
172
+ export const COUNTS_FRESH_MS = 3 * 60 * 60 * 1000;
173
+ const HOUR_MS = 60 * 60 * 1000;
174
+
175
+ interface ShapeOptions {
176
+ /** Compute the future frames (off for the frames themselves). */
177
+ timeline?: boolean;
178
+ /** This frame is far enough from the read that its counts are dropped. */
179
+ countsStale?: boolean;
180
+ }
181
+
182
+ /** The moments a glance changes on its own, with no new read: a booking enters its last hour
183
+ * and starts, an event enters its last 3 h and starts, a post goes live, the day turns, and the
184
+ * counts stop being fresh. Ascending, after `now`, within 24 h. Only the `MAX_FRAMES` soonest
185
+ * starts of each source: no focus keeps more frames than that, and every moment costs a full
186
+ * `shape`, so a day of 50 bookings must not mean 100 of them on every publish. */
187
+ function frameTimes(sources: Sources, now: Date): number[] {
188
+ const t0 = now.getTime();
189
+ const at = (s: string) => Date.parse(s);
190
+ // A second past a start: an item is still upcoming AT its start (`start >= now`).
191
+ const started = (s: number) => s + 1000;
192
+ const soonest = (starts: number[]) =>
193
+ starts.filter((s) => Number.isFinite(s) && started(s) > t0).sort((a, b) => a - b).slice(0, MAX_FRAMES);
194
+ const times = [
195
+ ...soonest((sources.bookings ?? []).map((b) => at(startOf(b)))).flatMap((s) => [s - HOUR_MS, started(s)]),
196
+ ...soonest((sources.events ?? []).map((e) => at(str(e, "dateAndTimeSettings.startDate")))).flatMap((s) => [s - 3 * HOUR_MS, started(s)]),
197
+ ...soonest((sources.drafts ?? []).map((d) => at(str(d, "scheduledPublishDate")))).map(started),
198
+ new Date(now.getFullYear(), now.getMonth(), now.getDate() + 1).getTime(),
199
+ t0 + COUNTS_FRESH_MS,
200
+ ];
201
+ return [...new Set(times.filter((t) => Number.isFinite(t) && t > t0 && t <= t0 + TIMELINE_HOURS * HOUR_MS))]
202
+ .sort((a, b) => a - b);
203
+ }
204
+
153
205
  /** Pure: shape what was read into the widget state. `now` is injectable for tests. */
154
- export function shape(sources: Sources, now: Date, siteName: string, provisioned: Verticals = buildVerticals()): TodayState {
206
+ export function shape(sources: Sources, now: Date, siteName: string, provisioned: Verticals = buildVerticals(),
207
+ options: ShapeOptions = { timeline: true }): TodayState {
155
208
  const bookingsReady = sources.bookings !== null && sources.requests !== null;
156
209
  const ordersReady = sources.orders !== null;
157
210
  // Re-filtered even though the queries filter: a server (or a fixture) that returns a
@@ -176,7 +229,7 @@ export function shape(sources: Sources, now: Date, siteName: string, provisioned
176
229
  const midnight = new Date(now.getFullYear(), now.getMonth(), now.getDate() + 1).getTime();
177
230
  const nextStart = next ? Date.parse(startOf(next)) : Infinity;
178
231
  const nextShown = next ? booking(next, now) : undefined;
179
- const ranked = rankItems([
232
+ const allRanked = rankItems([
180
233
  ...(bookingsReady ? bookingItems(
181
234
  nextShown && { start: new Date(startOf(next!)), service: nextShown.service, firstName: str(next, "contactDetails.firstName") },
182
235
  requestCount, requestsCapped, now, LIMIT) : []),
@@ -184,14 +237,18 @@ export function shape(sources: Sources, now: Date, siteName: string, provisioned
184
237
  ...(eventsReady ? eventItems(sources.events ?? [], now) : []),
185
238
  ...(blogReady ? blogItems(sources.drafts ?? [], now, LIMIT) : []),
186
239
  ]);
240
+ // A frame far from the read keeps what is true by the clock (a booking, an event, a post) and
241
+ // drops the counts, which may have changed since: it never shows a morning's "3 orders" at night.
242
+ const ranked = options.countsStale ? allRanked.filter((i) => i.count === undefined) : allRanked;
243
+ const dropped = options.countsStale ? allRanked.filter((i) => i.count !== undefined) : [];
187
244
  // A shown item stops being true when it starts (a booking or event is no longer "next"), as
188
245
  // the next booking already did: the frame's lifetime ends at the first of them.
189
246
  const headAt = shownUntil(ranked);
190
247
  // Nothing could be read at all: the glance shows the degrade line, never "All clear".
191
- const glance = nothing ? degradeGlance(COPY.nothing) : glanceFields(ranked, GLANCE_COPY);
248
+ const glance = nothing ? degradeGlance(COPY.nothing) : withDropped(glanceFields(ranked, GLANCE_COPY), ranked, dropped);
192
249
  // One glance per focus a widget may be set to (PR 2): "now" is the glance above, an area keeps
193
250
  // only its own items. The phone publishes one frame per focus from the same descriptors.
194
- const options = focusList(provisioned);
251
+ const focusOptions = focusList(provisioned);
195
252
  // Each focus's frame ends when an item IT shows starts — an Events widget headlines an event
196
253
  // that may be 4th in "now" — so it carries its own `validUntil`, laid over the state's.
197
254
  const ownEnd = (f: GlanceFocus) => f === "now"
@@ -202,16 +259,21 @@ export function shape(sources: Sources, now: Date, siteName: string, provisioned
202
259
  const areaReady: Record<GlanceFocus, boolean> = {
203
260
  now: !nothing, bookings: bookingsReady, store: ordersReady, events: eventsReady, blog: blogReady,
204
261
  };
205
- const focuses = Object.fromEntries(options.map((f) => [f.id, {
262
+ const own = (items: GlanceItem[], f: GlanceFocus) => f === "now" ? items : items.filter((i) => i.area === f);
263
+ const nowFocuses = Object.fromEntries(focusOptions.map((f) => [f.id, {
206
264
  ...(!areaReady[f.id]
207
265
  ? { ...degradeGlance(COPY.nothing), glanceLabel: focusFields([], f.id, GLANCE_COPY).glanceLabel }
208
- : focusFields(ranked, f.id, GLANCE_COPY)),
266
+ : withDropped(focusFields(ranked, f.id, GLANCE_COPY), own(ranked, f.id), own(dropped, f.id))),
209
267
  validUntil: ownEnd(f.id),
210
- }])) as Record<GlanceFocus, GlanceFields & { validUntil: number }>;
268
+ score: areaReady[f.id] ? own(ranked, f.id)[0]?.score ?? 0 : 0,
269
+ frames: [] as GlanceFrame[],
270
+ timelineUntil: ownEnd(f.id),
271
+ }])) as Record<GlanceFocus, FocusGlance>;
272
+ const focuses = options.timeline ? withTimeline(nowFocuses, sources, now, siteName, provisioned) : nowFocuses;
211
273
  return {
212
274
  ...glance,
213
275
  focuses,
214
- focusList: options,
276
+ focusList: focusOptions,
215
277
  eventsReady,
216
278
  blogReady,
217
279
  validUntil: Math.floor(Math.min(midnight, nextStart, headAt) / 1000),
@@ -243,7 +305,9 @@ export function degraded(status: "error" | "signedOut" | "loading", siteName: st
243
305
  // A FIXED instant, not the clock: a degrade frame has no rows, so nothing in it depends on
244
306
  // the time — and the initial state must be deterministic (template contract: no worker's
245
307
  // initial state may read the clock).
246
- const base = shape({ bookings: null, requests: null, orders: null }, new Date(0), siteName);
308
+ // No timeline: a degrade frame stays what it is until the next read, and frame times would
309
+ // read the build machine's local midnight.
310
+ const base = shape({ bookings: null, requests: null, orders: null }, new Date(0), siteName, buildVerticals(), { timeline: false });
247
311
  const message = status === "signedOut" ? COPY.signedOut : status === "error" ? COPY.error : "";
248
312
  // validUntil pinned too: shape() derives it from LOCAL midnight, so even at a fixed instant it
249
313
  // would vary with the build machine's timezone and change the baked services hash.
@@ -254,11 +318,80 @@ export function degraded(status: "error" | "signedOut" | "loading", siteName: st
254
318
  ...base, status, message, hideMessage: !message, validUntil: 0,
255
319
  ...line,
256
320
  // Each focus keeps its own header ("Orders"), only the line is the degrade one.
257
- focuses: Object.fromEntries(base.focusList.map((f) => [f.id,
258
- { ...line, glanceLabel: focusFields([], f.id, GLANCE_COPY).glanceLabel, validUntil: 0 }])) as Record<GlanceFocus, GlanceFields & { validUntil: number }>,
321
+ focuses: Object.fromEntries(base.focusList.map((f): [GlanceFocus, FocusGlance] => [f.id,
322
+ { ...line, glanceLabel: focusFields([], f.id, GLANCE_COPY).glanceLabel, validUntil: 0, score: 0, frames: [], timelineUntil: 0 }])) as Record<GlanceFocus, FocusGlance>,
259
323
  };
260
324
  }
261
325
 
326
+ /** The glance of a frame whose counts were dropped (`ShapeOptions.countsStale`): where a count
327
+ * would be, "Open Owner to refresh". With nothing left by the clock it says only that, never
328
+ * "All clear" — the counts it dropped may still be waiting. */
329
+ function withDropped(fields: GlanceFields, kept: GlanceItem[], dropped: GlanceItem[]): GlanceFields {
330
+ if (!dropped.length) return fields;
331
+ if (!kept.length) return { ...degradeGlance(COPY.error), glanceLabel: fields.glanceLabel };
332
+ const secondary = [...kept.slice(1, 2).map((i) => i.short), COPY.error].filter(Boolean).join(" · ");
333
+ return {
334
+ ...fields,
335
+ glanceSecondary: secondary, hideGlanceSecondary: false,
336
+ lockRectSecondary: COPY.error, lockHideSecondary: false,
337
+ // Every surface that carried a count says so, the one-line Lock Screen slot included.
338
+ lockInline: `${kept[0].lockTitle} · ${COPY.error}`,
339
+ };
340
+ }
341
+
342
+ const GLANCE_KEYS: (keyof GlanceFields)[] = [
343
+ "glanceHeadline", "glanceDetail", "glanceTime", "hideGlanceTime", "glanceSymbol", "glanceSecondary",
344
+ "hideGlanceSecondary", "glanceAllClear", "glanceLabel", "lockInline", "lockCircValue", "lockCircLabel",
345
+ "lockRectTitle", "lockRectDetail", "lockRectSecondary", "lockHideSecondary",
346
+ ];
347
+
348
+ function glanceOnly(f: GlanceFields): GlanceFields {
349
+ return Object.fromEntries(GLANCE_KEYS.map((k) => [k, f[k]])) as unknown as GlanceFields;
350
+ }
351
+
352
+ function sameGlance(a: GlanceFields, b: GlanceFields): boolean {
353
+ return GLANCE_KEYS.every((k) => a[k] === b[k]);
354
+ }
355
+
356
+ /** Lay each focus's future frames over its glance now: the state re-shaped at each moment the
357
+ * glance changes by itself (`frameTimes`), keeping only a frame that reads differently from the
358
+ * one before it, at most `MAX_FRAMES` in all (the now frame counts). A focus whose area could not
359
+ * be read reads the same degrade line at every moment, so it gets none. */
360
+ function withTimeline(
361
+ focuses: Record<GlanceFocus, FocusGlance>, sources: Sources, now: Date, siteName: string, provisioned: Verticals,
362
+ ): Record<GlanceFocus, FocusGlance> {
363
+ const t0 = now.getTime();
364
+ const later = frameTimes(sources, now).map((t) => ({
365
+ t, state: shape(sources, new Date(t), siteName, provisioned, { countsStale: t - t0 >= COUNTS_FRESH_MS }),
366
+ }));
367
+ return Object.fromEntries(Object.entries(focuses).map(([id, focus]) => {
368
+ const frames: GlanceFrame[] = [];
369
+ let previous: GlanceFields & { score: number } = focus;
370
+ let until = focus.validUntil;
371
+ for (const { t, state } of later) {
372
+ if (frames.length >= MAX_FRAMES - 1) break;
373
+ const at = state.focuses[id as GlanceFocus];
374
+ // A frame that reads the same but matters more (a booking entering its last hour) is kept:
375
+ // its relevance is what lifts the widget to the top of a Smart Stack.
376
+ if (!at) continue;
377
+ if (sameGlance(previous, at) && previous.score === at.score) {
378
+ // Still reads the same at this moment, so what is showing holds for as long as it does here.
379
+ until = Math.max(until, at.validUntil);
380
+ continue;
381
+ }
382
+ frames.push({ ...glanceOnly(at), startsAt: Math.floor(t / 1000), score: at.score, durationSeconds: 0 });
383
+ previous = at;
384
+ until = at.validUntil;
385
+ }
386
+ // Each frame holds until the next one starts; the last until it stops being true, or the
387
+ // timeline's 24 h end if that comes first.
388
+ const end = Math.min(Math.floor((t0 + TIMELINE_HOURS * HOUR_MS) / 1000), until);
389
+ const starts = [...frames.map((f) => f.startsAt), end];
390
+ frames.forEach((f, i) => { f.durationSeconds = Math.max(0, starts[i + 1] - f.startsAt); });
391
+ return [id, { ...focus, frames, timelineUntil: frames.length ? end : focus.validUntil }];
392
+ })) as Record<GlanceFocus, FocusGlance>;
393
+ }
394
+
262
395
  /** The glance of a frame that could not read the business: its one line in every slot, never
263
396
  * "All clear", and never an empty Lock Screen circle. */
264
397
  function degradeGlance(message: string): GlanceFields {