@wix/himalaya-cli 0.2019.0 → 0.2021.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.
- package/dist/cli.mjs +103 -18
- package/guides/widgets.md +7 -1
- package/package.json +2 -2
- package/templates/beauty-salon-owner/dev/index.ts +1 -1
- package/templates/beauty-salon-owner/tier5-src/himi-owner-lite-today/glance.ts +36 -1
- package/templates/beauty-salon-owner/tier5-src/himi-owner-lite-today/index.ts +44 -10
- package/templates/community-club-owner/dev/index.ts +1 -1
- package/templates/community-club-owner/tier5-src/himi-owner-lite-today/glance.ts +36 -1
- package/templates/community-club-owner/tier5-src/himi-owner-lite-today/index.ts +44 -10
- package/templates/events-meetups-owner/dev/index.ts +1 -1
- package/templates/events-meetups-owner/tier5-src/himi-owner-lite-today/glance.ts +36 -1
- package/templates/events-meetups-owner/tier5-src/himi-owner-lite-today/index.ts +44 -10
- package/templates/gym-fitness-owner/dev/index.ts +1 -1
- package/templates/gym-fitness-owner/tier5-src/himi-owner-lite-today/glance.ts +36 -1
- package/templates/gym-fitness-owner/tier5-src/himi-owner-lite-today/index.ts +44 -10
- package/templates/nonprofit-cause-owner/dev/index.ts +1 -1
- package/templates/nonprofit-cause-owner/tier5-src/himi-owner-lite-today/glance.ts +36 -1
- package/templates/nonprofit-cause-owner/tier5-src/himi-owner-lite-today/index.ts +44 -10
- package/templates/owner-lite/dev/index.ts +1 -1
- package/templates/owner-lite/tier5-src/himi-owner-lite-today/glance.ts +36 -1
- package/templates/owner-lite/tier5-src/himi-owner-lite-today/index.ts +44 -10
- package/templates/podcast-creator-owner/dev/index.ts +1 -1
- package/templates/podcast-creator-owner/tier5-src/himi-owner-lite-today/glance.ts +36 -1
- package/templates/podcast-creator-owner/tier5-src/himi-owner-lite-today/index.ts +44 -10
- package/templates/portfolio-creative-owner/dev/index.ts +1 -1
- package/templates/portfolio-creative-owner/tier5-src/himi-owner-lite-today/glance.ts +36 -1
- package/templates/portfolio-creative-owner/tier5-src/himi-owner-lite-today/index.ts +44 -10
- package/templates/restaurant-owner/dev/index.ts +1 -1
- package/templates/restaurant-owner/tier5-src/himi-owner-lite-today/glance.ts +36 -1
- package/templates/restaurant-owner/tier5-src/himi-owner-lite-today/index.ts +44 -10
- package/templates/retail-store-owner/dev/index.ts +1 -1
- package/templates/retail-store-owner/tier5-src/himi-owner-lite-today/glance.ts +36 -1
- package/templates/retail-store-owner/tier5-src/himi-owner-lite-today/index.ts +44 -10
- package/templates/yoga-studio-owner/dev/index.ts +1 -1
- package/templates/yoga-studio-owner/tier5-src/himi-owner-lite-today/glance.ts +36 -1
- package/templates/yoga-studio-owner/tier5-src/himi-owner-lite-today/index.ts +44 -10
package/dist/cli.mjs
CHANGED
|
@@ -193474,7 +193474,7 @@ var init_watch_companion = __esm({
|
|
|
193474
193474
|
});
|
|
193475
193475
|
|
|
193476
193476
|
// ../native-config/live-activity.ts
|
|
193477
|
-
function liveWidgetSource(deferredActions) {
|
|
193477
|
+
function liveWidgetSource(deferredActions, focusPrefix, focusDefaultTitle = "Default") {
|
|
193478
193478
|
const supportedIds = deferredActions ? "[.refresh, .markRead]" : "[.refresh]";
|
|
193479
193479
|
const performBody = deferredActions ? ` // The DOMAIN adapters this extension registers (#2340). They defer rather than execute:
|
|
193480
193480
|
// this process holds no domain credential \u2014 the WidgetActionSession it receives carries
|
|
@@ -193500,7 +193500,26 @@ function liveWidgetSource(deferredActions) {
|
|
|
193500
193500
|
// extension can only queue, and with no WidgetActionRelay.drain() in the app nothing
|
|
193501
193501
|
// would ever apply them. Add the drain and this arm becomes the deferring one (#2340).
|
|
193502
193502
|
try await WidgetActionRuntime.perform(try WidgetActionEnvelope.decodeIntent(encodedEnvelope))`;
|
|
193503
|
-
|
|
193503
|
+
const widgetArgs = (indent) => [
|
|
193504
|
+
`appGroupId: (Bundle.main.object(forInfoDictionaryKey: "HimalayaWidgetAppGroup") as? String) ?? "",`,
|
|
193505
|
+
...focusPrefix ? [`focusPrefix: ${JSON.stringify(focusPrefix)},`] : [],
|
|
193506
|
+
`displayName: (Bundle.main.object(forInfoDictionaryKey: "CFBundleDisplayName") as? String)`,
|
|
193507
|
+
` ?? (Bundle.main.object(forInfoDictionaryKey: "CFBundleName") as? String) ?? "",`,
|
|
193508
|
+
`description: SystemCopy.extensionText("runtime.system.widget.description"),`,
|
|
193509
|
+
`fallbackURL: (Bundle.main.object(forInfoDictionaryKey: "HimalayaLaunchURL") as? String).flatMap(URL.init(string:)),`,
|
|
193510
|
+
`supportedActionIds: ${supportedIds},`,
|
|
193511
|
+
`actionButtonFactory: widgetActionButton`
|
|
193512
|
+
].map((line) => indent + line).join("\n");
|
|
193513
|
+
const snapshotWidget = focusPrefix ? ` if #available(iOS 17.0, *) {
|
|
193514
|
+
HimalayaFocusWidget<HimalayaFocusIntent>(
|
|
193515
|
+
${widgetArgs(" ")}
|
|
193516
|
+
)
|
|
193517
|
+
}` : ` if #available(iOS 16.0, *) {
|
|
193518
|
+
HimalayaSnapshotWidget(
|
|
193519
|
+
${widgetArgs(" ")}
|
|
193520
|
+
)
|
|
193521
|
+
}`;
|
|
193522
|
+
return LIVE_WIDGET_SOURCE_TEMPLATE.replace("__PERFORM_BODY__", performBody).replace("__FOCUS_TYPES__", focusPrefix ? FOCUS_TYPES.replace("__FOCUS_DEFAULT_TITLE__", JSON.stringify(focusDefaultTitle)) : "").replace("__SNAPSHOT_WIDGET__", snapshotWidget);
|
|
193504
193523
|
}
|
|
193505
193524
|
function hostFromProject(project) {
|
|
193506
193525
|
const blocks = project.split(/(?=^ [A-Za-z0-9_]+:\s*$)/m);
|
|
@@ -193522,7 +193541,7 @@ function hostFromProject(project) {
|
|
|
193522
193541
|
build: scalar4("CFBundleVersion", 8) ?? scalar4("CURRENT_PROJECT_VERSION", 8) ?? "1"
|
|
193523
193542
|
};
|
|
193524
193543
|
}
|
|
193525
|
-
function liveActivityPlan(project, enabled2, deferredActions = false) {
|
|
193544
|
+
function liveActivityPlan(project, enabled2, deferredActions = false, focus = {}) {
|
|
193526
193545
|
if (!enabled2) return { target: [], embed: [], source: void 0, entitlements: void 0 };
|
|
193527
193546
|
const host = hostFromProject(project);
|
|
193528
193547
|
const name = `${host.name}LiveActivities`;
|
|
@@ -193575,9 +193594,9 @@ function liveActivityPlan(project, enabled2, deferredActions = false) {
|
|
|
193575
193594
|
</dict>
|
|
193576
193595
|
</plist>
|
|
193577
193596
|
`;
|
|
193578
|
-
return { target, embed: [`- target: ${name}`, " embed: true"], source: liveWidgetSource(deferredActions), entitlements, appGroupId };
|
|
193597
|
+
return { target, embed: [`- target: ${name}`, " embed: true"], source: liveWidgetSource(deferredActions, focus.focusPrefix, focus.defaultTitle), entitlements, appGroupId };
|
|
193579
193598
|
}
|
|
193580
|
-
var LABEL_LIVE_TARGET, LABEL_LIVE_EMBED, LIVE_SOURCE_PATH, LIVE_ENTITLEMENTS_PATH, LIVE_PRIVACY_MANIFEST_PATH, LIVE_WIDGET_SOURCE_TEMPLATE;
|
|
193599
|
+
var LABEL_LIVE_TARGET, LABEL_LIVE_EMBED, LIVE_SOURCE_PATH, LIVE_ENTITLEMENTS_PATH, LIVE_PRIVACY_MANIFEST_PATH, FOCUS_TYPES, LIVE_WIDGET_SOURCE_TEMPLATE;
|
|
193581
193600
|
var init_live_activity = __esm({
|
|
193582
193601
|
"../native-config/live-activity.ts"() {
|
|
193583
193602
|
init_define_HHP_CATALOG();
|
|
@@ -193586,6 +193605,54 @@ var init_live_activity = __esm({
|
|
|
193586
193605
|
LIVE_SOURCE_PATH = "GeneratedLiveActivity/WidgetBundle.swift";
|
|
193587
193606
|
LIVE_ENTITLEMENTS_PATH = "GeneratedLiveActivity/HimalayaLiveActivity.entitlements";
|
|
193588
193607
|
LIVE_PRIVACY_MANIFEST_PATH = "GeneratedLiveActivity/PrivacyInfo.xcprivacy";
|
|
193608
|
+
FOCUS_TYPES = `// One focus a widget can be set to, listed from what the app last published beside its snapshots.
|
|
193609
|
+
@available(iOS 17.0, *)
|
|
193610
|
+
struct HimalayaFocusEntity: AppEntity {
|
|
193611
|
+
static var typeDisplayRepresentation: TypeDisplayRepresentation { "Show" }
|
|
193612
|
+
static var defaultQuery = HimalayaFocusQuery()
|
|
193613
|
+
let id: String
|
|
193614
|
+
let title: String
|
|
193615
|
+
var displayRepresentation: DisplayRepresentation { DisplayRepresentation(title: "\\(title)") }
|
|
193616
|
+
}
|
|
193617
|
+
|
|
193618
|
+
@available(iOS 17.0, *)
|
|
193619
|
+
struct HimalayaFocusQuery: EntityQuery {
|
|
193620
|
+
private var appGroupId: String { (Bundle.main.object(forInfoDictionaryKey: "HimalayaWidgetAppGroup") as? String) ?? "" }
|
|
193621
|
+
|
|
193622
|
+
/// Every requested id answers, offered or not: a focus the app stopped offering must stay
|
|
193623
|
+
/// picked (and draw the data-free placeholder), never turn into nil, which is the default.
|
|
193624
|
+
func entities(for identifiers: [String]) async throws -> [HimalayaFocusEntity] {
|
|
193625
|
+
let known = try await suggestedEntities()
|
|
193626
|
+
return identifiers.map { id in known.first { $0.id == id } ?? HimalayaFocusEntity(id: id, title: id) }
|
|
193627
|
+
}
|
|
193628
|
+
|
|
193629
|
+
/// The published focuses; before the app's first publish, the default alone.
|
|
193630
|
+
func suggestedEntities() async throws -> [HimalayaFocusEntity] {
|
|
193631
|
+
let published = WidgetSharedStore(appGroupId: appGroupId).readFocuses().map { HimalayaFocusEntity(id: $0.id, title: $0.title) }
|
|
193632
|
+
return published.isEmpty
|
|
193633
|
+
? [HimalayaFocusEntity(id: HimalayaFocusWidgetSelection.defaultFocus, title: __FOCUS_DEFAULT_TITLE__)]
|
|
193634
|
+
: published
|
|
193635
|
+
}
|
|
193636
|
+
|
|
193637
|
+
func defaultResult() async -> HimalayaFocusEntity? {
|
|
193638
|
+
try? await suggestedEntities().first
|
|
193639
|
+
}
|
|
193640
|
+
}
|
|
193641
|
+
|
|
193642
|
+
@available(iOS 17.0, *)
|
|
193643
|
+
struct HimalayaFocusIntent: HimalayaFocusWidgetIntent {
|
|
193644
|
+
static var title: LocalizedStringResource { "Show" }
|
|
193645
|
+
static var description: IntentDescription { IntentDescription("Choose what this widget shows.") }
|
|
193646
|
+
|
|
193647
|
+
@Parameter(title: "Show")
|
|
193648
|
+
var focus: HimalayaFocusEntity?
|
|
193649
|
+
|
|
193650
|
+
init() {}
|
|
193651
|
+
|
|
193652
|
+
var himalayaFocusId: String? { focus?.id }
|
|
193653
|
+
}
|
|
193654
|
+
|
|
193655
|
+
`;
|
|
193589
193656
|
LIVE_WIDGET_SOURCE_TEMPLATE = `// Generated by tools/native-config. Do not edit.
|
|
193590
193657
|
import SwiftUI
|
|
193591
193658
|
import WidgetKit
|
|
@@ -193630,20 +193697,10 @@ private func widgetActionButton(envelope: WidgetActionEnvelope, title: String) -
|
|
|
193630
193697
|
return AnyView(Button(intent: intent) { Text(title) }.buttonStyle(.plain))
|
|
193631
193698
|
}
|
|
193632
193699
|
|
|
193633
|
-
@main
|
|
193700
|
+
__FOCUS_TYPES__@main
|
|
193634
193701
|
struct GeneratedLiveActivityBundle: WidgetBundle {
|
|
193635
193702
|
var body: some Widget {
|
|
193636
|
-
|
|
193637
|
-
HimalayaSnapshotWidget(
|
|
193638
|
-
appGroupId: (Bundle.main.object(forInfoDictionaryKey: "HimalayaWidgetAppGroup") as? String) ?? "",
|
|
193639
|
-
displayName: (Bundle.main.object(forInfoDictionaryKey: "CFBundleDisplayName") as? String)
|
|
193640
|
-
?? (Bundle.main.object(forInfoDictionaryKey: "CFBundleName") as? String) ?? "",
|
|
193641
|
-
description: SystemCopy.extensionText("runtime.system.widget.description"),
|
|
193642
|
-
fallbackURL: (Bundle.main.object(forInfoDictionaryKey: "HimalayaLaunchURL") as? String).flatMap(URL.init(string:)),
|
|
193643
|
-
supportedActionIds: __SUPPORTED_ACTION_IDS__,
|
|
193644
|
-
actionButtonFactory: widgetActionButton
|
|
193645
|
-
)
|
|
193646
|
-
}
|
|
193703
|
+
__SNAPSHOT_WIDGET__
|
|
193647
193704
|
if #available(iOS 16.2, *) {
|
|
193648
193705
|
HimalayaLiveActivityWidget(fallbackURL: (Bundle.main.object(forInfoDictionaryKey: "HimalayaLaunchURL") as? String).flatMap(URL.init(string:)))
|
|
193649
193706
|
}
|
|
@@ -193653,6 +193710,33 @@ struct GeneratedLiveActivityBundle: WidgetBundle {
|
|
|
193653
193710
|
}
|
|
193654
193711
|
});
|
|
193655
193712
|
|
|
193713
|
+
// ../native-config/widget-focus.ts
|
|
193714
|
+
function parseWidgetFocusConfig(configTs) {
|
|
193715
|
+
const { text: text32, inString } = scanConfig(configTs);
|
|
193716
|
+
let code3 = "";
|
|
193717
|
+
for (let i2 = 0; i2 < text32.length; i2++) code3 += inString[i2] && !`"'\``.includes(text32[i2]) ? " " : text32[i2];
|
|
193718
|
+
for (const m2 of code3.matchAll(/(?:^|\n)\s*export\s+const\s+widget\s*=\s*\{([^}]*)\}/g)) {
|
|
193719
|
+
const at2 = m2.index + m2[0].indexOf("export");
|
|
193720
|
+
if (inString[at2]) continue;
|
|
193721
|
+
const end2 = m2.index + m2[0].length;
|
|
193722
|
+
const scanned = code3.slice(at2, end2);
|
|
193723
|
+
const body = configTs.slice(at2, end2);
|
|
193724
|
+
const key4 = /(?<![\w$])focusPrefix\s*:\s*["']/.exec(scanned);
|
|
193725
|
+
const prefix = key4 ? /^focusPrefix\s*:\s*["']([A-Za-z0-9_.-]+)["']/.exec(body.slice(key4.index))?.[1] : void 0;
|
|
193726
|
+
if (!prefix) continue;
|
|
193727
|
+
const titleKey = /(?<![\w$])defaultTitle\s*:\s*["']/.exec(scanned);
|
|
193728
|
+
const title = titleKey ? /^defaultTitle\s*:\s*["']([^"'\\]{1,60})["']/.exec(body.slice(titleKey.index))?.[1] : void 0;
|
|
193729
|
+
return title ? { focusPrefix: prefix, defaultTitle: title } : { focusPrefix: prefix };
|
|
193730
|
+
}
|
|
193731
|
+
return {};
|
|
193732
|
+
}
|
|
193733
|
+
var init_widget_focus = __esm({
|
|
193734
|
+
"../native-config/widget-focus.ts"() {
|
|
193735
|
+
init_define_HHP_CATALOG();
|
|
193736
|
+
init_car();
|
|
193737
|
+
}
|
|
193738
|
+
});
|
|
193739
|
+
|
|
193656
193740
|
// ../../node_modules/js-yaml/dist/js-yaml.mjs
|
|
193657
193741
|
function getDefaultExportFromCjs(x2) {
|
|
193658
193742
|
return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2;
|
|
@@ -200446,7 +200530,7 @@ function genNativeConfig(app2, opts = {}) {
|
|
|
200446
200530
|
const embedManaged = hasMarkers(project, "yaml", LABEL_LIVE_EMBED);
|
|
200447
200531
|
if (targetManaged !== embedManaged) throw new Error(`${app2}: Live Activity target and embedding markers must be installed together`);
|
|
200448
200532
|
const drainsWidgetActions = hostAppliesDeferredWidgetActions(app2);
|
|
200449
|
-
const live4 = targetManaged ? liveActivityPlan(project, ids2.includes("live_activity"), drainsWidgetActions) : void 0;
|
|
200533
|
+
const live4 = targetManaged ? liveActivityPlan(project, ids2.includes("live_activity"), drainsWidgetActions, parseWidgetFocusConfig(configTs)) : void 0;
|
|
200450
200534
|
if (live4?.appGroupId) {
|
|
200451
200535
|
const key4 = "com.apple.security.application-groups";
|
|
200452
200536
|
const existing = ios.entitlements[key4];
|
|
@@ -200635,6 +200719,7 @@ var init_gen_native_config = __esm({
|
|
|
200635
200719
|
init_icon2();
|
|
200636
200720
|
init_watch_companion();
|
|
200637
200721
|
init_live_activity();
|
|
200722
|
+
init_widget_focus();
|
|
200638
200723
|
init_js_yaml();
|
|
200639
200724
|
init_gen_privacy();
|
|
200640
200725
|
init_car();
|
package/guides/widgets.md
CHANGED
|
@@ -56,7 +56,13 @@ widget's descriptors, runs their worker **headlessly** with the signed-in sessio
|
|
|
56
56
|
Owner Lite's Today widget works this way (`OwnerLiteHomeWidget`): it ranks what matters now across
|
|
57
57
|
bookings, store, events and blog, publishes an `ios_home` frame (small, medium) and an `ios_lock`
|
|
58
58
|
frame (circular, rectangular, inline — built only from name-free, money-free fields), and refreshes
|
|
59
|
-
when the app runs, never on its own.
|
|
59
|
+
when the app runs, never on its own. Each placed widget can be set to one focus — "What matters
|
|
60
|
+
now", Bookings, Orders, Events or Blog: the app publishes one frame per focus, and the widget's
|
|
61
|
+
settings (on iOS, long-press → Edit Widget; on Android, the launcher's widget settings) pick which
|
|
62
|
+
one it draws. A widget nobody configured shows "What matters now". An app opts into the same
|
|
63
|
+
picker by declaring `export const widget = { focusPrefix: "<prefix>", defaultTitle: "…" }` in
|
|
64
|
+
`config.ts` and publishing its frames as `<prefix>.<focus>` with the focus list beside them
|
|
65
|
+
(`WidgetSharedStore.writeFocuses` on iOS, `WidgetFocusStore.writeFocuses` on Android). An app that embeds Himalaya apps gets the same
|
|
60
66
|
produce from `HimalayaEmbedSurfaces.publishWidgets` (see
|
|
61
67
|
[embedding → widgets](embedding-sdk.md#home-and-lock-screen-widgets)).
|
|
62
68
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wix/himalaya-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2021.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": "
|
|
85
|
+
"falconPackageHash": "ee659fc0ef5ad3463395f9bd8458ec1fff2bd3f7d78969b818b2e6a4"
|
|
86
86
|
}
|
|
@@ -69186,7 +69186,7 @@ const SCREENS = runtimeSetting({
|
|
|
69186
69186
|
"package": "himalaya",
|
|
69187
69187
|
"type": "Text",
|
|
69188
69188
|
"props": {
|
|
69189
|
-
"text": "
|
|
69189
|
+
"text": "$service:ownerToday.glanceLabel",
|
|
69190
69190
|
"style": "caption",
|
|
69191
69191
|
"color": "textSecondary",
|
|
69192
69192
|
"maxLines": 1
|
|
@@ -67,6 +67,8 @@ export interface GlanceFields {
|
|
|
67
67
|
glanceSecondary: string;
|
|
68
68
|
hideGlanceSecondary: boolean;
|
|
69
69
|
glanceAllClear: boolean;
|
|
70
|
+
/** The widget header: "Now" for the ranking, the area's name for a pinned focus. */
|
|
71
|
+
glanceLabel: string;
|
|
70
72
|
lockInline: string;
|
|
71
73
|
lockCircValue: string;
|
|
72
74
|
lockCircLabel: string;
|
|
@@ -234,6 +236,38 @@ export function rankItems(items: GlanceItem[]): GlanceItem[] {
|
|
|
234
236
|
|| AREA_ORDER.indexOf(a.area) - AREA_ORDER.indexOf(b.area));
|
|
235
237
|
}
|
|
236
238
|
|
|
239
|
+
/** What one placed widget shows: everything ranked ("now"), or one area only. */
|
|
240
|
+
export type GlanceFocus = "now" | GlanceArea;
|
|
241
|
+
|
|
242
|
+
export interface GlanceFocusOption {
|
|
243
|
+
id: GlanceFocus;
|
|
244
|
+
title: string;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/** The small widget's header for the ranking: short, because it sits beside an icon in 2×2. */
|
|
248
|
+
const NOW_LABEL = "Now";
|
|
249
|
+
|
|
250
|
+
const FOCUS_TITLES: Record<GlanceFocus, string> = {
|
|
251
|
+
now: "What matters now",
|
|
252
|
+
bookings: "Bookings",
|
|
253
|
+
store: "Orders",
|
|
254
|
+
events: "Events",
|
|
255
|
+
blog: "Blog",
|
|
256
|
+
};
|
|
257
|
+
|
|
258
|
+
/** The focuses a widget may be set to: "now", then the areas this build provisions, in the
|
|
259
|
+
* canonical order. Stable from first launch: it follows the build, not what a read returned. */
|
|
260
|
+
export function focusList(provisioned: Record<GlanceArea, boolean>): GlanceFocusOption[] {
|
|
261
|
+
return (["now", ...AREA_ORDER.filter((a) => provisioned[a])] as GlanceFocus[]).map((id) => ({ id, title: FOCUS_TITLES[id] }));
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/** The glance for one focus: "now" is the whole ranking; an area keeps only its own items, so a
|
|
265
|
+
* widget pinned to Orders never shows a booking. An area with nothing is its own All clear. */
|
|
266
|
+
export function focusFields(ranked: GlanceItem[], focus: GlanceFocus, copy: GlanceCopy): GlanceFields {
|
|
267
|
+
const fields = glanceFields(focus === "now" ? ranked : ranked.filter((i) => i.area === focus), copy);
|
|
268
|
+
return { ...fields, glanceLabel: focus === "now" ? NOW_LABEL : FOCUS_TITLES[focus] };
|
|
269
|
+
}
|
|
270
|
+
|
|
237
271
|
/** When the frame stops being true: the earliest moment among the items it SHOWS (the headline
|
|
238
272
|
* and the two on the secondary line). A started booking, event or post is no longer "next". */
|
|
239
273
|
export function shownUntil(ranked: GlanceItem[]): number {
|
|
@@ -247,7 +281,7 @@ export function glanceFields(ranked: GlanceItem[], copy: GlanceCopy): GlanceFiel
|
|
|
247
281
|
if (!head) {
|
|
248
282
|
return {
|
|
249
283
|
glanceHeadline: copy.allClear, glanceDetail: copy.nothingWaiting, glanceTime: "", hideGlanceTime: true,
|
|
250
|
-
glanceSymbol: "checkmark", glanceSecondary: "", hideGlanceSecondary: true, glanceAllClear: true,
|
|
284
|
+
glanceSymbol: "checkmark", glanceSecondary: "", hideGlanceSecondary: true, glanceAllClear: true, glanceLabel: NOW_LABEL,
|
|
251
285
|
lockInline: copy.allClear, lockCircValue: "0", lockCircLabel: "waiting",
|
|
252
286
|
lockRectTitle: copy.allClear, lockRectDetail: copy.nothingWaiting, lockRectSecondary: "", lockHideSecondary: true,
|
|
253
287
|
};
|
|
@@ -263,6 +297,7 @@ export function glanceFields(ranked: GlanceItem[], copy: GlanceCopy): GlanceFiel
|
|
|
263
297
|
glanceSecondary: secondary,
|
|
264
298
|
hideGlanceSecondary: !secondary,
|
|
265
299
|
glanceAllClear: false,
|
|
300
|
+
glanceLabel: NOW_LABEL,
|
|
266
301
|
lockInline: rest[0] ? `${head.lockTitle} · ${rest[0]}` : head.lockTitle,
|
|
267
302
|
lockCircValue: head.circValue,
|
|
268
303
|
lockCircLabel: head.circLabel,
|
|
@@ -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, type GlanceFields,
|
|
26
|
+
GLANCE_COPY, focusFields, focusList, type GlanceFields, type GlanceFocus, type GlanceFocusOption,
|
|
27
27
|
} from "./glance.js";
|
|
28
28
|
|
|
29
29
|
export { isSectionUnavailable, isSignedOut, dayLabel };
|
|
@@ -46,6 +46,10 @@ export interface TodayBooking {
|
|
|
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
48
|
export interface TodayState extends GlanceFields {
|
|
49
|
+
/** The glance for each focus a widget may be set to ("now" + the provisioned areas). */
|
|
50
|
+
focuses: Record<GlanceFocus, GlanceFields & { validUntil: number }>;
|
|
51
|
+
/** Those focuses with owner-facing titles, in order — the widget picker's list. */
|
|
52
|
+
focusList: GlanceFocusOption[];
|
|
49
53
|
eventsReady: boolean;
|
|
50
54
|
blogReady: boolean;
|
|
51
55
|
status: "loading" | "ready" | "error" | "signedOut";
|
|
@@ -147,7 +151,7 @@ function upcoming(rows: Rec[] | null, statuses: string[], now: Date): Rec[] {
|
|
|
147
151
|
}
|
|
148
152
|
|
|
149
153
|
/** Pure: shape what was read into the widget state. `now` is injectable for tests. */
|
|
150
|
-
export function shape(sources: Sources, now: Date, siteName: string): TodayState {
|
|
154
|
+
export function shape(sources: Sources, now: Date, siteName: string, provisioned: Verticals = buildVerticals()): TodayState {
|
|
151
155
|
const bookingsReady = sources.bookings !== null && sources.requests !== null;
|
|
152
156
|
const ordersReady = sources.orders !== null;
|
|
153
157
|
// Re-filtered even though the queries filter: a server (or a fixture) that returns a
|
|
@@ -184,14 +188,30 @@ export function shape(sources: Sources, now: Date, siteName: string): TodayState
|
|
|
184
188
|
// the next booking already did: the frame's lifetime ends at the first of them.
|
|
185
189
|
const headAt = shownUntil(ranked);
|
|
186
190
|
// Nothing could be read at all: the glance shows the degrade line, never "All clear".
|
|
187
|
-
const glance = nothing
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
191
|
+
const glance = nothing ? degradeGlance(COPY.nothing) : glanceFields(ranked, GLANCE_COPY);
|
|
192
|
+
// One glance per focus a widget may be set to (PR 2): "now" is the glance above, an area keeps
|
|
193
|
+
// only its own items. The phone publishes one frame per focus from the same descriptors.
|
|
194
|
+
const options = focusList(provisioned);
|
|
195
|
+
// Each focus's frame ends when an item IT shows starts — an Events widget headlines an event
|
|
196
|
+
// that may be 4th in "now" — so it carries its own `validUntil`, laid over the state's.
|
|
197
|
+
const ownEnd = (f: GlanceFocus) => f === "now"
|
|
198
|
+
? Math.floor(Math.min(midnight, nextStart, headAt) / 1000)
|
|
199
|
+
: Math.floor(Math.min(midnight, shownUntil(ranked.filter((i) => i.area === f))) / 1000);
|
|
200
|
+
// An area focus stands only on its own read: when that read failed (428/404/403, a network
|
|
201
|
+
// error) the widget pinned to it shows the degrade line, never an All clear it cannot vouch for.
|
|
202
|
+
const areaReady: Record<GlanceFocus, boolean> = {
|
|
203
|
+
now: !nothing, bookings: bookingsReady, store: ordersReady, events: eventsReady, blog: blogReady,
|
|
204
|
+
};
|
|
205
|
+
const focuses = Object.fromEntries(options.map((f) => [f.id, {
|
|
206
|
+
...(!areaReady[f.id]
|
|
207
|
+
? { ...degradeGlance(COPY.nothing), glanceLabel: focusFields([], f.id, GLANCE_COPY).glanceLabel }
|
|
208
|
+
: focusFields(ranked, f.id, GLANCE_COPY)),
|
|
209
|
+
validUntil: ownEnd(f.id),
|
|
210
|
+
}])) as Record<GlanceFocus, GlanceFields & { validUntil: number }>;
|
|
193
211
|
return {
|
|
194
212
|
...glance,
|
|
213
|
+
focuses,
|
|
214
|
+
focusList: options,
|
|
195
215
|
eventsReady,
|
|
196
216
|
blogReady,
|
|
197
217
|
validUntil: Math.floor(Math.min(midnight, nextStart, headAt) / 1000),
|
|
@@ -228,11 +248,25 @@ export function degraded(status: "error" | "signedOut" | "loading", siteName: st
|
|
|
228
248
|
// validUntil pinned too: shape() derives it from LOCAL midnight, so even at a fixed instant it
|
|
229
249
|
// would vary with the build machine's timezone and change the baked services hash.
|
|
230
250
|
// The glance shows the degrade line too, never "All clear": a frame that could not read the
|
|
231
|
-
// business must not tell the owner nothing is waiting.
|
|
251
|
+
// business must not tell the owner nothing is waiting. Every focus says the same line.
|
|
252
|
+
const line = degradeGlance(message);
|
|
232
253
|
return {
|
|
233
254
|
...base, status, message, hideMessage: !message, validUntil: 0,
|
|
255
|
+
...line,
|
|
256
|
+
// 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 }>,
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/** The glance of a frame that could not read the business: its one line in every slot, never
|
|
263
|
+
* "All clear", and never an empty Lock Screen circle. */
|
|
264
|
+
function degradeGlance(message: string): GlanceFields {
|
|
265
|
+
return {
|
|
266
|
+
...glanceFields([], GLANCE_COPY),
|
|
234
267
|
glanceHeadline: message, glanceDetail: "", glanceAllClear: false, glanceSymbol: "",
|
|
235
|
-
lockInline: message, lockRectTitle: message, lockRectDetail: "",
|
|
268
|
+
lockInline: message, lockRectTitle: message, lockRectDetail: "",
|
|
269
|
+
lockCircValue: message ? "—" : "", lockCircLabel: message ? "Owner" : "",
|
|
236
270
|
};
|
|
237
271
|
}
|
|
238
272
|
|
|
@@ -69186,7 +69186,7 @@ const SCREENS = runtimeSetting({
|
|
|
69186
69186
|
"package": "himalaya",
|
|
69187
69187
|
"type": "Text",
|
|
69188
69188
|
"props": {
|
|
69189
|
-
"text": "
|
|
69189
|
+
"text": "$service:ownerToday.glanceLabel",
|
|
69190
69190
|
"style": "caption",
|
|
69191
69191
|
"color": "textSecondary",
|
|
69192
69192
|
"maxLines": 1
|
|
@@ -67,6 +67,8 @@ export interface GlanceFields {
|
|
|
67
67
|
glanceSecondary: string;
|
|
68
68
|
hideGlanceSecondary: boolean;
|
|
69
69
|
glanceAllClear: boolean;
|
|
70
|
+
/** The widget header: "Now" for the ranking, the area's name for a pinned focus. */
|
|
71
|
+
glanceLabel: string;
|
|
70
72
|
lockInline: string;
|
|
71
73
|
lockCircValue: string;
|
|
72
74
|
lockCircLabel: string;
|
|
@@ -234,6 +236,38 @@ export function rankItems(items: GlanceItem[]): GlanceItem[] {
|
|
|
234
236
|
|| AREA_ORDER.indexOf(a.area) - AREA_ORDER.indexOf(b.area));
|
|
235
237
|
}
|
|
236
238
|
|
|
239
|
+
/** What one placed widget shows: everything ranked ("now"), or one area only. */
|
|
240
|
+
export type GlanceFocus = "now" | GlanceArea;
|
|
241
|
+
|
|
242
|
+
export interface GlanceFocusOption {
|
|
243
|
+
id: GlanceFocus;
|
|
244
|
+
title: string;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/** The small widget's header for the ranking: short, because it sits beside an icon in 2×2. */
|
|
248
|
+
const NOW_LABEL = "Now";
|
|
249
|
+
|
|
250
|
+
const FOCUS_TITLES: Record<GlanceFocus, string> = {
|
|
251
|
+
now: "What matters now",
|
|
252
|
+
bookings: "Bookings",
|
|
253
|
+
store: "Orders",
|
|
254
|
+
events: "Events",
|
|
255
|
+
blog: "Blog",
|
|
256
|
+
};
|
|
257
|
+
|
|
258
|
+
/** The focuses a widget may be set to: "now", then the areas this build provisions, in the
|
|
259
|
+
* canonical order. Stable from first launch: it follows the build, not what a read returned. */
|
|
260
|
+
export function focusList(provisioned: Record<GlanceArea, boolean>): GlanceFocusOption[] {
|
|
261
|
+
return (["now", ...AREA_ORDER.filter((a) => provisioned[a])] as GlanceFocus[]).map((id) => ({ id, title: FOCUS_TITLES[id] }));
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/** The glance for one focus: "now" is the whole ranking; an area keeps only its own items, so a
|
|
265
|
+
* widget pinned to Orders never shows a booking. An area with nothing is its own All clear. */
|
|
266
|
+
export function focusFields(ranked: GlanceItem[], focus: GlanceFocus, copy: GlanceCopy): GlanceFields {
|
|
267
|
+
const fields = glanceFields(focus === "now" ? ranked : ranked.filter((i) => i.area === focus), copy);
|
|
268
|
+
return { ...fields, glanceLabel: focus === "now" ? NOW_LABEL : FOCUS_TITLES[focus] };
|
|
269
|
+
}
|
|
270
|
+
|
|
237
271
|
/** When the frame stops being true: the earliest moment among the items it SHOWS (the headline
|
|
238
272
|
* and the two on the secondary line). A started booking, event or post is no longer "next". */
|
|
239
273
|
export function shownUntil(ranked: GlanceItem[]): number {
|
|
@@ -247,7 +281,7 @@ export function glanceFields(ranked: GlanceItem[], copy: GlanceCopy): GlanceFiel
|
|
|
247
281
|
if (!head) {
|
|
248
282
|
return {
|
|
249
283
|
glanceHeadline: copy.allClear, glanceDetail: copy.nothingWaiting, glanceTime: "", hideGlanceTime: true,
|
|
250
|
-
glanceSymbol: "checkmark", glanceSecondary: "", hideGlanceSecondary: true, glanceAllClear: true,
|
|
284
|
+
glanceSymbol: "checkmark", glanceSecondary: "", hideGlanceSecondary: true, glanceAllClear: true, glanceLabel: NOW_LABEL,
|
|
251
285
|
lockInline: copy.allClear, lockCircValue: "0", lockCircLabel: "waiting",
|
|
252
286
|
lockRectTitle: copy.allClear, lockRectDetail: copy.nothingWaiting, lockRectSecondary: "", lockHideSecondary: true,
|
|
253
287
|
};
|
|
@@ -263,6 +297,7 @@ export function glanceFields(ranked: GlanceItem[], copy: GlanceCopy): GlanceFiel
|
|
|
263
297
|
glanceSecondary: secondary,
|
|
264
298
|
hideGlanceSecondary: !secondary,
|
|
265
299
|
glanceAllClear: false,
|
|
300
|
+
glanceLabel: NOW_LABEL,
|
|
266
301
|
lockInline: rest[0] ? `${head.lockTitle} · ${rest[0]}` : head.lockTitle,
|
|
267
302
|
lockCircValue: head.circValue,
|
|
268
303
|
lockCircLabel: head.circLabel,
|
|
@@ -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, type GlanceFields,
|
|
26
|
+
GLANCE_COPY, focusFields, focusList, type GlanceFields, type GlanceFocus, type GlanceFocusOption,
|
|
27
27
|
} from "./glance.js";
|
|
28
28
|
|
|
29
29
|
export { isSectionUnavailable, isSignedOut, dayLabel };
|
|
@@ -46,6 +46,10 @@ export interface TodayBooking {
|
|
|
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
48
|
export interface TodayState extends GlanceFields {
|
|
49
|
+
/** The glance for each focus a widget may be set to ("now" + the provisioned areas). */
|
|
50
|
+
focuses: Record<GlanceFocus, GlanceFields & { validUntil: number }>;
|
|
51
|
+
/** Those focuses with owner-facing titles, in order — the widget picker's list. */
|
|
52
|
+
focusList: GlanceFocusOption[];
|
|
49
53
|
eventsReady: boolean;
|
|
50
54
|
blogReady: boolean;
|
|
51
55
|
status: "loading" | "ready" | "error" | "signedOut";
|
|
@@ -147,7 +151,7 @@ function upcoming(rows: Rec[] | null, statuses: string[], now: Date): Rec[] {
|
|
|
147
151
|
}
|
|
148
152
|
|
|
149
153
|
/** Pure: shape what was read into the widget state. `now` is injectable for tests. */
|
|
150
|
-
export function shape(sources: Sources, now: Date, siteName: string): TodayState {
|
|
154
|
+
export function shape(sources: Sources, now: Date, siteName: string, provisioned: Verticals = buildVerticals()): TodayState {
|
|
151
155
|
const bookingsReady = sources.bookings !== null && sources.requests !== null;
|
|
152
156
|
const ordersReady = sources.orders !== null;
|
|
153
157
|
// Re-filtered even though the queries filter: a server (or a fixture) that returns a
|
|
@@ -184,14 +188,30 @@ export function shape(sources: Sources, now: Date, siteName: string): TodayState
|
|
|
184
188
|
// the next booking already did: the frame's lifetime ends at the first of them.
|
|
185
189
|
const headAt = shownUntil(ranked);
|
|
186
190
|
// Nothing could be read at all: the glance shows the degrade line, never "All clear".
|
|
187
|
-
const glance = nothing
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
191
|
+
const glance = nothing ? degradeGlance(COPY.nothing) : glanceFields(ranked, GLANCE_COPY);
|
|
192
|
+
// One glance per focus a widget may be set to (PR 2): "now" is the glance above, an area keeps
|
|
193
|
+
// only its own items. The phone publishes one frame per focus from the same descriptors.
|
|
194
|
+
const options = focusList(provisioned);
|
|
195
|
+
// Each focus's frame ends when an item IT shows starts — an Events widget headlines an event
|
|
196
|
+
// that may be 4th in "now" — so it carries its own `validUntil`, laid over the state's.
|
|
197
|
+
const ownEnd = (f: GlanceFocus) => f === "now"
|
|
198
|
+
? Math.floor(Math.min(midnight, nextStart, headAt) / 1000)
|
|
199
|
+
: Math.floor(Math.min(midnight, shownUntil(ranked.filter((i) => i.area === f))) / 1000);
|
|
200
|
+
// An area focus stands only on its own read: when that read failed (428/404/403, a network
|
|
201
|
+
// error) the widget pinned to it shows the degrade line, never an All clear it cannot vouch for.
|
|
202
|
+
const areaReady: Record<GlanceFocus, boolean> = {
|
|
203
|
+
now: !nothing, bookings: bookingsReady, store: ordersReady, events: eventsReady, blog: blogReady,
|
|
204
|
+
};
|
|
205
|
+
const focuses = Object.fromEntries(options.map((f) => [f.id, {
|
|
206
|
+
...(!areaReady[f.id]
|
|
207
|
+
? { ...degradeGlance(COPY.nothing), glanceLabel: focusFields([], f.id, GLANCE_COPY).glanceLabel }
|
|
208
|
+
: focusFields(ranked, f.id, GLANCE_COPY)),
|
|
209
|
+
validUntil: ownEnd(f.id),
|
|
210
|
+
}])) as Record<GlanceFocus, GlanceFields & { validUntil: number }>;
|
|
193
211
|
return {
|
|
194
212
|
...glance,
|
|
213
|
+
focuses,
|
|
214
|
+
focusList: options,
|
|
195
215
|
eventsReady,
|
|
196
216
|
blogReady,
|
|
197
217
|
validUntil: Math.floor(Math.min(midnight, nextStart, headAt) / 1000),
|
|
@@ -228,11 +248,25 @@ export function degraded(status: "error" | "signedOut" | "loading", siteName: st
|
|
|
228
248
|
// validUntil pinned too: shape() derives it from LOCAL midnight, so even at a fixed instant it
|
|
229
249
|
// would vary with the build machine's timezone and change the baked services hash.
|
|
230
250
|
// The glance shows the degrade line too, never "All clear": a frame that could not read the
|
|
231
|
-
// business must not tell the owner nothing is waiting.
|
|
251
|
+
// business must not tell the owner nothing is waiting. Every focus says the same line.
|
|
252
|
+
const line = degradeGlance(message);
|
|
232
253
|
return {
|
|
233
254
|
...base, status, message, hideMessage: !message, validUntil: 0,
|
|
255
|
+
...line,
|
|
256
|
+
// 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 }>,
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/** The glance of a frame that could not read the business: its one line in every slot, never
|
|
263
|
+
* "All clear", and never an empty Lock Screen circle. */
|
|
264
|
+
function degradeGlance(message: string): GlanceFields {
|
|
265
|
+
return {
|
|
266
|
+
...glanceFields([], GLANCE_COPY),
|
|
234
267
|
glanceHeadline: message, glanceDetail: "", glanceAllClear: false, glanceSymbol: "",
|
|
235
|
-
lockInline: message, lockRectTitle: message, lockRectDetail: "",
|
|
268
|
+
lockInline: message, lockRectTitle: message, lockRectDetail: "",
|
|
269
|
+
lockCircValue: message ? "—" : "", lockCircLabel: message ? "Owner" : "",
|
|
236
270
|
};
|
|
237
271
|
}
|
|
238
272
|
|
|
@@ -68803,7 +68803,7 @@ const SCREENS = runtimeSetting({
|
|
|
68803
68803
|
"package": "himalaya",
|
|
68804
68804
|
"type": "Text",
|
|
68805
68805
|
"props": {
|
|
68806
|
-
"text": "
|
|
68806
|
+
"text": "$service:ownerToday.glanceLabel",
|
|
68807
68807
|
"style": "caption",
|
|
68808
68808
|
"color": "textSecondary",
|
|
68809
68809
|
"maxLines": 1
|
|
@@ -67,6 +67,8 @@ export interface GlanceFields {
|
|
|
67
67
|
glanceSecondary: string;
|
|
68
68
|
hideGlanceSecondary: boolean;
|
|
69
69
|
glanceAllClear: boolean;
|
|
70
|
+
/** The widget header: "Now" for the ranking, the area's name for a pinned focus. */
|
|
71
|
+
glanceLabel: string;
|
|
70
72
|
lockInline: string;
|
|
71
73
|
lockCircValue: string;
|
|
72
74
|
lockCircLabel: string;
|
|
@@ -234,6 +236,38 @@ export function rankItems(items: GlanceItem[]): GlanceItem[] {
|
|
|
234
236
|
|| AREA_ORDER.indexOf(a.area) - AREA_ORDER.indexOf(b.area));
|
|
235
237
|
}
|
|
236
238
|
|
|
239
|
+
/** What one placed widget shows: everything ranked ("now"), or one area only. */
|
|
240
|
+
export type GlanceFocus = "now" | GlanceArea;
|
|
241
|
+
|
|
242
|
+
export interface GlanceFocusOption {
|
|
243
|
+
id: GlanceFocus;
|
|
244
|
+
title: string;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/** The small widget's header for the ranking: short, because it sits beside an icon in 2×2. */
|
|
248
|
+
const NOW_LABEL = "Now";
|
|
249
|
+
|
|
250
|
+
const FOCUS_TITLES: Record<GlanceFocus, string> = {
|
|
251
|
+
now: "What matters now",
|
|
252
|
+
bookings: "Bookings",
|
|
253
|
+
store: "Orders",
|
|
254
|
+
events: "Events",
|
|
255
|
+
blog: "Blog",
|
|
256
|
+
};
|
|
257
|
+
|
|
258
|
+
/** The focuses a widget may be set to: "now", then the areas this build provisions, in the
|
|
259
|
+
* canonical order. Stable from first launch: it follows the build, not what a read returned. */
|
|
260
|
+
export function focusList(provisioned: Record<GlanceArea, boolean>): GlanceFocusOption[] {
|
|
261
|
+
return (["now", ...AREA_ORDER.filter((a) => provisioned[a])] as GlanceFocus[]).map((id) => ({ id, title: FOCUS_TITLES[id] }));
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/** The glance for one focus: "now" is the whole ranking; an area keeps only its own items, so a
|
|
265
|
+
* widget pinned to Orders never shows a booking. An area with nothing is its own All clear. */
|
|
266
|
+
export function focusFields(ranked: GlanceItem[], focus: GlanceFocus, copy: GlanceCopy): GlanceFields {
|
|
267
|
+
const fields = glanceFields(focus === "now" ? ranked : ranked.filter((i) => i.area === focus), copy);
|
|
268
|
+
return { ...fields, glanceLabel: focus === "now" ? NOW_LABEL : FOCUS_TITLES[focus] };
|
|
269
|
+
}
|
|
270
|
+
|
|
237
271
|
/** When the frame stops being true: the earliest moment among the items it SHOWS (the headline
|
|
238
272
|
* and the two on the secondary line). A started booking, event or post is no longer "next". */
|
|
239
273
|
export function shownUntil(ranked: GlanceItem[]): number {
|
|
@@ -247,7 +281,7 @@ export function glanceFields(ranked: GlanceItem[], copy: GlanceCopy): GlanceFiel
|
|
|
247
281
|
if (!head) {
|
|
248
282
|
return {
|
|
249
283
|
glanceHeadline: copy.allClear, glanceDetail: copy.nothingWaiting, glanceTime: "", hideGlanceTime: true,
|
|
250
|
-
glanceSymbol: "checkmark", glanceSecondary: "", hideGlanceSecondary: true, glanceAllClear: true,
|
|
284
|
+
glanceSymbol: "checkmark", glanceSecondary: "", hideGlanceSecondary: true, glanceAllClear: true, glanceLabel: NOW_LABEL,
|
|
251
285
|
lockInline: copy.allClear, lockCircValue: "0", lockCircLabel: "waiting",
|
|
252
286
|
lockRectTitle: copy.allClear, lockRectDetail: copy.nothingWaiting, lockRectSecondary: "", lockHideSecondary: true,
|
|
253
287
|
};
|
|
@@ -263,6 +297,7 @@ export function glanceFields(ranked: GlanceItem[], copy: GlanceCopy): GlanceFiel
|
|
|
263
297
|
glanceSecondary: secondary,
|
|
264
298
|
hideGlanceSecondary: !secondary,
|
|
265
299
|
glanceAllClear: false,
|
|
300
|
+
glanceLabel: NOW_LABEL,
|
|
266
301
|
lockInline: rest[0] ? `${head.lockTitle} · ${rest[0]}` : head.lockTitle,
|
|
267
302
|
lockCircValue: head.circValue,
|
|
268
303
|
lockCircLabel: head.circLabel,
|