@wix/himalaya-cli 0.2018.0 → 0.2020.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 +104 -19
- 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
|
@@ -45492,6 +45492,7 @@ function resolveIdiom(tokens2, ctx = {}) {
|
|
|
45492
45492
|
var IDIOM_CONTEXTS, UNSAFE_KEYS;
|
|
45493
45493
|
var init_idiom = __esm({
|
|
45494
45494
|
"../../core/ts/src/idiom.ts"() {
|
|
45495
|
+
"use strict";
|
|
45495
45496
|
init_define_HHP_CATALOG();
|
|
45496
45497
|
IDIOM_CONTEXTS = {
|
|
45497
45498
|
ios: { native: ["ios"] },
|
|
@@ -47261,7 +47262,6 @@ function shouldRevealError(args) {
|
|
|
47261
47262
|
var EMAIL_RE, URL_HOST_RE, INTEGER_RE, NUMBER_RE, AUTHORED_PATTERN_LIMIT, authoredPatterns;
|
|
47262
47263
|
var init_validation = __esm({
|
|
47263
47264
|
"../../core/ts/src/validation.ts"() {
|
|
47264
|
-
"use strict";
|
|
47265
47265
|
init_define_HHP_CATALOG();
|
|
47266
47266
|
EMAIL_RE = /^[A-Za-z0-9._%+-]+@[A-Za-z0-9-]+(\.[A-Za-z0-9-]+)*\.[A-Za-z]{2,}$/;
|
|
47267
47267
|
URL_HOST_RE = /^[A-Za-z0-9-]+(\.[A-Za-z0-9-]+)*(:[0-9]+)?$/;
|
|
@@ -193473,7 +193473,7 @@ var init_watch_companion = __esm({
|
|
|
193473
193473
|
});
|
|
193474
193474
|
|
|
193475
193475
|
// ../native-config/live-activity.ts
|
|
193476
|
-
function liveWidgetSource(deferredActions) {
|
|
193476
|
+
function liveWidgetSource(deferredActions, focusPrefix, focusDefaultTitle = "Default") {
|
|
193477
193477
|
const supportedIds = deferredActions ? "[.refresh, .markRead]" : "[.refresh]";
|
|
193478
193478
|
const performBody = deferredActions ? ` // The DOMAIN adapters this extension registers (#2340). They defer rather than execute:
|
|
193479
193479
|
// this process holds no domain credential \u2014 the WidgetActionSession it receives carries
|
|
@@ -193499,7 +193499,26 @@ function liveWidgetSource(deferredActions) {
|
|
|
193499
193499
|
// extension can only queue, and with no WidgetActionRelay.drain() in the app nothing
|
|
193500
193500
|
// would ever apply them. Add the drain and this arm becomes the deferring one (#2340).
|
|
193501
193501
|
try await WidgetActionRuntime.perform(try WidgetActionEnvelope.decodeIntent(encodedEnvelope))`;
|
|
193502
|
-
|
|
193502
|
+
const widgetArgs = (indent) => [
|
|
193503
|
+
`appGroupId: (Bundle.main.object(forInfoDictionaryKey: "HimalayaWidgetAppGroup") as? String) ?? "",`,
|
|
193504
|
+
...focusPrefix ? [`focusPrefix: ${JSON.stringify(focusPrefix)},`] : [],
|
|
193505
|
+
`displayName: (Bundle.main.object(forInfoDictionaryKey: "CFBundleDisplayName") as? String)`,
|
|
193506
|
+
` ?? (Bundle.main.object(forInfoDictionaryKey: "CFBundleName") as? String) ?? "",`,
|
|
193507
|
+
`description: SystemCopy.extensionText("runtime.system.widget.description"),`,
|
|
193508
|
+
`fallbackURL: (Bundle.main.object(forInfoDictionaryKey: "HimalayaLaunchURL") as? String).flatMap(URL.init(string:)),`,
|
|
193509
|
+
`supportedActionIds: ${supportedIds},`,
|
|
193510
|
+
`actionButtonFactory: widgetActionButton`
|
|
193511
|
+
].map((line) => indent + line).join("\n");
|
|
193512
|
+
const snapshotWidget = focusPrefix ? ` if #available(iOS 17.0, *) {
|
|
193513
|
+
HimalayaFocusWidget<HimalayaFocusIntent>(
|
|
193514
|
+
${widgetArgs(" ")}
|
|
193515
|
+
)
|
|
193516
|
+
}` : ` if #available(iOS 16.0, *) {
|
|
193517
|
+
HimalayaSnapshotWidget(
|
|
193518
|
+
${widgetArgs(" ")}
|
|
193519
|
+
)
|
|
193520
|
+
}`;
|
|
193521
|
+
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);
|
|
193503
193522
|
}
|
|
193504
193523
|
function hostFromProject(project) {
|
|
193505
193524
|
const blocks = project.split(/(?=^ [A-Za-z0-9_]+:\s*$)/m);
|
|
@@ -193521,7 +193540,7 @@ function hostFromProject(project) {
|
|
|
193521
193540
|
build: scalar4("CFBundleVersion", 8) ?? scalar4("CURRENT_PROJECT_VERSION", 8) ?? "1"
|
|
193522
193541
|
};
|
|
193523
193542
|
}
|
|
193524
|
-
function liveActivityPlan(project, enabled2, deferredActions = false) {
|
|
193543
|
+
function liveActivityPlan(project, enabled2, deferredActions = false, focus = {}) {
|
|
193525
193544
|
if (!enabled2) return { target: [], embed: [], source: void 0, entitlements: void 0 };
|
|
193526
193545
|
const host = hostFromProject(project);
|
|
193527
193546
|
const name = `${host.name}LiveActivities`;
|
|
@@ -193574,9 +193593,9 @@ function liveActivityPlan(project, enabled2, deferredActions = false) {
|
|
|
193574
193593
|
</dict>
|
|
193575
193594
|
</plist>
|
|
193576
193595
|
`;
|
|
193577
|
-
return { target, embed: [`- target: ${name}`, " embed: true"], source: liveWidgetSource(deferredActions), entitlements, appGroupId };
|
|
193596
|
+
return { target, embed: [`- target: ${name}`, " embed: true"], source: liveWidgetSource(deferredActions, focus.focusPrefix, focus.defaultTitle), entitlements, appGroupId };
|
|
193578
193597
|
}
|
|
193579
|
-
var LABEL_LIVE_TARGET, LABEL_LIVE_EMBED, LIVE_SOURCE_PATH, LIVE_ENTITLEMENTS_PATH, LIVE_PRIVACY_MANIFEST_PATH, LIVE_WIDGET_SOURCE_TEMPLATE;
|
|
193598
|
+
var LABEL_LIVE_TARGET, LABEL_LIVE_EMBED, LIVE_SOURCE_PATH, LIVE_ENTITLEMENTS_PATH, LIVE_PRIVACY_MANIFEST_PATH, FOCUS_TYPES, LIVE_WIDGET_SOURCE_TEMPLATE;
|
|
193580
193599
|
var init_live_activity = __esm({
|
|
193581
193600
|
"../native-config/live-activity.ts"() {
|
|
193582
193601
|
init_define_HHP_CATALOG();
|
|
@@ -193585,6 +193604,54 @@ var init_live_activity = __esm({
|
|
|
193585
193604
|
LIVE_SOURCE_PATH = "GeneratedLiveActivity/WidgetBundle.swift";
|
|
193586
193605
|
LIVE_ENTITLEMENTS_PATH = "GeneratedLiveActivity/HimalayaLiveActivity.entitlements";
|
|
193587
193606
|
LIVE_PRIVACY_MANIFEST_PATH = "GeneratedLiveActivity/PrivacyInfo.xcprivacy";
|
|
193607
|
+
FOCUS_TYPES = `// One focus a widget can be set to, listed from what the app last published beside its snapshots.
|
|
193608
|
+
@available(iOS 17.0, *)
|
|
193609
|
+
struct HimalayaFocusEntity: AppEntity {
|
|
193610
|
+
static var typeDisplayRepresentation: TypeDisplayRepresentation { "Show" }
|
|
193611
|
+
static var defaultQuery = HimalayaFocusQuery()
|
|
193612
|
+
let id: String
|
|
193613
|
+
let title: String
|
|
193614
|
+
var displayRepresentation: DisplayRepresentation { DisplayRepresentation(title: "\\(title)") }
|
|
193615
|
+
}
|
|
193616
|
+
|
|
193617
|
+
@available(iOS 17.0, *)
|
|
193618
|
+
struct HimalayaFocusQuery: EntityQuery {
|
|
193619
|
+
private var appGroupId: String { (Bundle.main.object(forInfoDictionaryKey: "HimalayaWidgetAppGroup") as? String) ?? "" }
|
|
193620
|
+
|
|
193621
|
+
/// Every requested id answers, offered or not: a focus the app stopped offering must stay
|
|
193622
|
+
/// picked (and draw the data-free placeholder), never turn into nil, which is the default.
|
|
193623
|
+
func entities(for identifiers: [String]) async throws -> [HimalayaFocusEntity] {
|
|
193624
|
+
let known = try await suggestedEntities()
|
|
193625
|
+
return identifiers.map { id in known.first { $0.id == id } ?? HimalayaFocusEntity(id: id, title: id) }
|
|
193626
|
+
}
|
|
193627
|
+
|
|
193628
|
+
/// The published focuses; before the app's first publish, the default alone.
|
|
193629
|
+
func suggestedEntities() async throws -> [HimalayaFocusEntity] {
|
|
193630
|
+
let published = WidgetSharedStore(appGroupId: appGroupId).readFocuses().map { HimalayaFocusEntity(id: $0.id, title: $0.title) }
|
|
193631
|
+
return published.isEmpty
|
|
193632
|
+
? [HimalayaFocusEntity(id: HimalayaFocusWidgetSelection.defaultFocus, title: __FOCUS_DEFAULT_TITLE__)]
|
|
193633
|
+
: published
|
|
193634
|
+
}
|
|
193635
|
+
|
|
193636
|
+
func defaultResult() async -> HimalayaFocusEntity? {
|
|
193637
|
+
try? await suggestedEntities().first
|
|
193638
|
+
}
|
|
193639
|
+
}
|
|
193640
|
+
|
|
193641
|
+
@available(iOS 17.0, *)
|
|
193642
|
+
struct HimalayaFocusIntent: HimalayaFocusWidgetIntent {
|
|
193643
|
+
static var title: LocalizedStringResource { "Show" }
|
|
193644
|
+
static var description: IntentDescription { IntentDescription("Choose what this widget shows.") }
|
|
193645
|
+
|
|
193646
|
+
@Parameter(title: "Show")
|
|
193647
|
+
var focus: HimalayaFocusEntity?
|
|
193648
|
+
|
|
193649
|
+
init() {}
|
|
193650
|
+
|
|
193651
|
+
var himalayaFocusId: String? { focus?.id }
|
|
193652
|
+
}
|
|
193653
|
+
|
|
193654
|
+
`;
|
|
193588
193655
|
LIVE_WIDGET_SOURCE_TEMPLATE = `// Generated by tools/native-config. Do not edit.
|
|
193589
193656
|
import SwiftUI
|
|
193590
193657
|
import WidgetKit
|
|
@@ -193629,20 +193696,10 @@ private func widgetActionButton(envelope: WidgetActionEnvelope, title: String) -
|
|
|
193629
193696
|
return AnyView(Button(intent: intent) { Text(title) }.buttonStyle(.plain))
|
|
193630
193697
|
}
|
|
193631
193698
|
|
|
193632
|
-
@main
|
|
193699
|
+
__FOCUS_TYPES__@main
|
|
193633
193700
|
struct GeneratedLiveActivityBundle: WidgetBundle {
|
|
193634
193701
|
var body: some Widget {
|
|
193635
|
-
|
|
193636
|
-
HimalayaSnapshotWidget(
|
|
193637
|
-
appGroupId: (Bundle.main.object(forInfoDictionaryKey: "HimalayaWidgetAppGroup") as? String) ?? "",
|
|
193638
|
-
displayName: (Bundle.main.object(forInfoDictionaryKey: "CFBundleDisplayName") as? String)
|
|
193639
|
-
?? (Bundle.main.object(forInfoDictionaryKey: "CFBundleName") as? String) ?? "",
|
|
193640
|
-
description: SystemCopy.extensionText("runtime.system.widget.description"),
|
|
193641
|
-
fallbackURL: (Bundle.main.object(forInfoDictionaryKey: "HimalayaLaunchURL") as? String).flatMap(URL.init(string:)),
|
|
193642
|
-
supportedActionIds: __SUPPORTED_ACTION_IDS__,
|
|
193643
|
-
actionButtonFactory: widgetActionButton
|
|
193644
|
-
)
|
|
193645
|
-
}
|
|
193702
|
+
__SNAPSHOT_WIDGET__
|
|
193646
193703
|
if #available(iOS 16.2, *) {
|
|
193647
193704
|
HimalayaLiveActivityWidget(fallbackURL: (Bundle.main.object(forInfoDictionaryKey: "HimalayaLaunchURL") as? String).flatMap(URL.init(string:)))
|
|
193648
193705
|
}
|
|
@@ -193652,6 +193709,33 @@ struct GeneratedLiveActivityBundle: WidgetBundle {
|
|
|
193652
193709
|
}
|
|
193653
193710
|
});
|
|
193654
193711
|
|
|
193712
|
+
// ../native-config/widget-focus.ts
|
|
193713
|
+
function parseWidgetFocusConfig(configTs) {
|
|
193714
|
+
const { text: text32, inString } = scanConfig(configTs);
|
|
193715
|
+
let code3 = "";
|
|
193716
|
+
for (let i2 = 0; i2 < text32.length; i2++) code3 += inString[i2] && !`"'\``.includes(text32[i2]) ? " " : text32[i2];
|
|
193717
|
+
for (const m2 of code3.matchAll(/(?:^|\n)\s*export\s+const\s+widget\s*=\s*\{([^}]*)\}/g)) {
|
|
193718
|
+
const at2 = m2.index + m2[0].indexOf("export");
|
|
193719
|
+
if (inString[at2]) continue;
|
|
193720
|
+
const end2 = m2.index + m2[0].length;
|
|
193721
|
+
const scanned = code3.slice(at2, end2);
|
|
193722
|
+
const body = configTs.slice(at2, end2);
|
|
193723
|
+
const key4 = /(?<![\w$])focusPrefix\s*:\s*["']/.exec(scanned);
|
|
193724
|
+
const prefix = key4 ? /^focusPrefix\s*:\s*["']([A-Za-z0-9_.-]+)["']/.exec(body.slice(key4.index))?.[1] : void 0;
|
|
193725
|
+
if (!prefix) continue;
|
|
193726
|
+
const titleKey = /(?<![\w$])defaultTitle\s*:\s*["']/.exec(scanned);
|
|
193727
|
+
const title = titleKey ? /^defaultTitle\s*:\s*["']([^"'\\]{1,60})["']/.exec(body.slice(titleKey.index))?.[1] : void 0;
|
|
193728
|
+
return title ? { focusPrefix: prefix, defaultTitle: title } : { focusPrefix: prefix };
|
|
193729
|
+
}
|
|
193730
|
+
return {};
|
|
193731
|
+
}
|
|
193732
|
+
var init_widget_focus = __esm({
|
|
193733
|
+
"../native-config/widget-focus.ts"() {
|
|
193734
|
+
init_define_HHP_CATALOG();
|
|
193735
|
+
init_car();
|
|
193736
|
+
}
|
|
193737
|
+
});
|
|
193738
|
+
|
|
193655
193739
|
// ../../node_modules/js-yaml/dist/js-yaml.mjs
|
|
193656
193740
|
function getDefaultExportFromCjs(x2) {
|
|
193657
193741
|
return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2;
|
|
@@ -200445,7 +200529,7 @@ function genNativeConfig(app2, opts = {}) {
|
|
|
200445
200529
|
const embedManaged = hasMarkers(project, "yaml", LABEL_LIVE_EMBED);
|
|
200446
200530
|
if (targetManaged !== embedManaged) throw new Error(`${app2}: Live Activity target and embedding markers must be installed together`);
|
|
200447
200531
|
const drainsWidgetActions = hostAppliesDeferredWidgetActions(app2);
|
|
200448
|
-
const live4 = targetManaged ? liveActivityPlan(project, ids2.includes("live_activity"), drainsWidgetActions) : void 0;
|
|
200532
|
+
const live4 = targetManaged ? liveActivityPlan(project, ids2.includes("live_activity"), drainsWidgetActions, parseWidgetFocusConfig(configTs)) : void 0;
|
|
200449
200533
|
if (live4?.appGroupId) {
|
|
200450
200534
|
const key4 = "com.apple.security.application-groups";
|
|
200451
200535
|
const existing = ios.entitlements[key4];
|
|
@@ -200634,6 +200718,7 @@ var init_gen_native_config = __esm({
|
|
|
200634
200718
|
init_icon2();
|
|
200635
200719
|
init_watch_companion();
|
|
200636
200720
|
init_live_activity();
|
|
200721
|
+
init_widget_focus();
|
|
200637
200722
|
init_js_yaml();
|
|
200638
200723
|
init_gen_privacy();
|
|
200639
200724
|
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.2020.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": "58af06ecc61a854d31fec9e29d880e7b1f4f77f29810d589ac36dafd"
|
|
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,
|