@wix/himalaya-cli 0.1652.0 → 0.1654.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.
Files changed (137) hide show
  1. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/dev-server/src/l10n.d.ts +3 -0
  2. package/dist/browser-plane/assets.json +5 -5
  3. package/dist/browser-plane/preview-deferred/{6ba3f2eb2ac29f4f9eeebd1294a8003820cd260274c5400149d76833b3171555.bin → 3912fa5f6ddb60106c630fb5e48edbf12ebfd57c616d8b7aee0d32088cd3bbdf.bin} +1 -1
  4. package/dist/browser-plane/sw.js +7 -7
  5. package/dist/cli.mjs +2270 -1858
  6. package/dist/preview-assets.generated.bin +0 -0
  7. package/guides/getting-started.md +3 -3
  8. package/guides/himi-json-output.md +2 -2
  9. package/guides/himi-skill.md +3 -3
  10. package/guides/one-app-to-himi-app.md +13 -4
  11. package/guides/skill.md +1 -1
  12. package/guides/templates.md +5 -3
  13. package/package.json +2 -2
  14. package/templates/beauty-salon/dev/index.ts +263 -204
  15. package/templates/beauty-salon/l10n/en.json +2653 -0
  16. package/templates/beauty-salon/l10n/es.json +33 -0
  17. package/templates/beauty-salon/l10n/he.json +3756 -0
  18. package/templates/beauty-salon/tier5-src/_shared/engine-intl.ts +18 -10
  19. package/templates/beauty-salon/tier5-src/_shared/himi-account.ts +5 -4
  20. package/templates/beauty-salon/tier5-src/_shared/himi-bookings.ts +1 -1
  21. package/templates/beauty-salon/tier5-src/_shared/himi-copy.ts +30 -3
  22. package/templates/beauty-salon/tier5-src/himi-booking-bookings/index.ts +2 -4
  23. package/templates/beauty-salon/tier5-src/himi-booking-service/index.ts +2 -2
  24. package/templates/beauty-salon/tier5-src/himi-booking-time/index.ts +1 -1
  25. package/templates/beauty-salon-owner/tier5-src/_shared/engine-intl.ts +18 -10
  26. package/templates/beauty-salon-owner/tier5-src/_shared/himi-copy.ts +30 -3
  27. package/templates/branded-lite/dev/index.ts +263 -204
  28. package/templates/branded-lite/l10n/en.json +5024 -478
  29. package/templates/branded-lite/l10n/es.json +33 -0
  30. package/templates/branded-lite/l10n/he.json +6652 -0
  31. package/templates/branded-lite/tier5-src/_shared/engine-intl.ts +18 -10
  32. package/templates/branded-lite/tier5-src/_shared/himi-account.ts +5 -4
  33. package/templates/branded-lite/tier5-src/_shared/himi-bookings.ts +1 -1
  34. package/templates/branded-lite/tier5-src/_shared/himi-copy.ts +30 -3
  35. package/templates/branded-lite/tier5-src/himi-booking-bookings/index.ts +2 -4
  36. package/templates/branded-lite/tier5-src/himi-booking-service/index.ts +2 -2
  37. package/templates/branded-lite/tier5-src/himi-booking-time/index.ts +1 -1
  38. package/templates/brandy/tier5-src/_shared/himi-copy.ts +30 -3
  39. package/templates/community-club/l10n/en.json +1788 -0
  40. package/templates/community-club/l10n/es.json +10 -0
  41. package/templates/community-club/l10n/he.json +2397 -0
  42. package/templates/community-club/tier5-src/_shared/engine-intl.ts +18 -10
  43. package/templates/community-club/tier5-src/_shared/himi-account.ts +5 -4
  44. package/templates/community-club/tier5-src/_shared/himi-copy.ts +30 -3
  45. package/templates/community-club-owner/tier5-src/_shared/engine-intl.ts +18 -10
  46. package/templates/community-club-owner/tier5-src/_shared/himi-copy.ts +30 -3
  47. package/templates/conference/tier5-src/_shared/engine-intl.ts +18 -10
  48. package/templates/conference/tier5-src/_shared/himi-account.ts +5 -4
  49. package/templates/conference/tier5-src/_shared/himi-copy.ts +30 -3
  50. package/templates/events-meetups/l10n/en.json +1739 -0
  51. package/templates/events-meetups/l10n/es.json +10 -0
  52. package/templates/events-meetups/l10n/he.json +2326 -0
  53. package/templates/events-meetups/tier5-src/_shared/engine-intl.ts +18 -10
  54. package/templates/events-meetups/tier5-src/_shared/himi-account.ts +5 -4
  55. package/templates/events-meetups/tier5-src/_shared/himi-copy.ts +30 -3
  56. package/templates/events-meetups-owner/tier5-src/_shared/engine-intl.ts +18 -10
  57. package/templates/events-meetups-owner/tier5-src/_shared/himi-copy.ts +30 -3
  58. package/templates/gym-fitness/dev/index.ts +263 -204
  59. package/templates/gym-fitness/l10n/en.json +2964 -0
  60. package/templates/gym-fitness/l10n/es.json +33 -0
  61. package/templates/gym-fitness/l10n/he.json +4170 -0
  62. package/templates/gym-fitness/tier5-src/_shared/engine-intl.ts +18 -10
  63. package/templates/gym-fitness/tier5-src/_shared/himi-account.ts +5 -4
  64. package/templates/gym-fitness/tier5-src/_shared/himi-bookings.ts +1 -1
  65. package/templates/gym-fitness/tier5-src/_shared/himi-copy.ts +30 -3
  66. package/templates/gym-fitness/tier5-src/himi-booking-bookings/index.ts +2 -4
  67. package/templates/gym-fitness/tier5-src/himi-booking-service/index.ts +2 -2
  68. package/templates/gym-fitness/tier5-src/himi-booking-time/index.ts +1 -1
  69. package/templates/gym-fitness-owner/tier5-src/_shared/engine-intl.ts +18 -10
  70. package/templates/gym-fitness-owner/tier5-src/_shared/himi-copy.ts +30 -3
  71. package/templates/himi-chat/tier5-src/_shared/himi-copy.ts +30 -3
  72. package/templates/nonprofit-cause/l10n/en.json +1926 -0
  73. package/templates/nonprofit-cause/l10n/es.json +10 -0
  74. package/templates/nonprofit-cause/l10n/he.json +2577 -0
  75. package/templates/nonprofit-cause/tier5-src/_shared/engine-intl.ts +18 -10
  76. package/templates/nonprofit-cause/tier5-src/_shared/himi-account.ts +5 -4
  77. package/templates/nonprofit-cause/tier5-src/_shared/himi-copy.ts +30 -3
  78. package/templates/nonprofit-cause-owner/tier5-src/_shared/engine-intl.ts +18 -10
  79. package/templates/nonprofit-cause-owner/tier5-src/_shared/himi-copy.ts +30 -3
  80. package/templates/owner-lite/tier5-src/_shared/engine-intl.ts +18 -10
  81. package/templates/owner-lite/tier5-src/_shared/himi-copy.ts +30 -3
  82. package/templates/podcast-creator/l10n/en.json +1840 -0
  83. package/templates/podcast-creator/l10n/es.json +10 -0
  84. package/templates/podcast-creator/l10n/he.json +2444 -0
  85. package/templates/podcast-creator/tier5-src/_shared/engine-intl.ts +18 -10
  86. package/templates/podcast-creator/tier5-src/_shared/himi-account.ts +5 -4
  87. package/templates/podcast-creator/tier5-src/_shared/himi-copy.ts +30 -3
  88. package/templates/podcast-creator-owner/tier5-src/_shared/engine-intl.ts +18 -10
  89. package/templates/podcast-creator-owner/tier5-src/_shared/himi-copy.ts +30 -3
  90. package/templates/portfolio-creative/dev/index.ts +263 -204
  91. package/templates/portfolio-creative/l10n/en.json +2426 -0
  92. package/templates/portfolio-creative/l10n/es.json +33 -0
  93. package/templates/portfolio-creative/l10n/he.json +3149 -0
  94. package/templates/portfolio-creative/tier5-src/_shared/engine-intl.ts +18 -10
  95. package/templates/portfolio-creative/tier5-src/_shared/himi-account.ts +5 -4
  96. package/templates/portfolio-creative/tier5-src/_shared/himi-copy.ts +30 -3
  97. package/templates/portfolio-creative-owner/tier5-src/_shared/engine-intl.ts +18 -10
  98. package/templates/portfolio-creative-owner/tier5-src/_shared/himi-copy.ts +30 -3
  99. package/templates/restaurant/l10n/en.json +2204 -0
  100. package/templates/restaurant/l10n/es.json +10 -0
  101. package/templates/restaurant/l10n/he.json +2862 -0
  102. package/templates/restaurant/tier5-src/_shared/engine-intl.ts +18 -10
  103. package/templates/restaurant/tier5-src/_shared/himi-account.ts +5 -4
  104. package/templates/restaurant/tier5-src/_shared/himi-copy.ts +30 -3
  105. package/templates/restaurant-owner/tier5-src/_shared/engine-intl.ts +18 -10
  106. package/templates/restaurant-owner/tier5-src/_shared/himi-copy.ts +30 -3
  107. package/templates/retail-store/dev/index.ts +263 -204
  108. package/templates/retail-store/l10n/en.json +2029 -0
  109. package/templates/retail-store/l10n/es.json +33 -0
  110. package/templates/retail-store/l10n/he.json +2660 -0
  111. package/templates/retail-store/tier5-src/_shared/engine-intl.ts +18 -10
  112. package/templates/retail-store/tier5-src/_shared/himi-account.ts +5 -4
  113. package/templates/retail-store/tier5-src/_shared/himi-copy.ts +30 -3
  114. package/templates/retail-store-owner/tier5-src/_shared/engine-intl.ts +18 -10
  115. package/templates/retail-store-owner/tier5-src/_shared/himi-copy.ts +30 -3
  116. package/templates/salon-spa/tier5-src/_shared/engine-intl.ts +18 -10
  117. package/templates/salon-spa/tier5-src/_shared/himi-account.ts +5 -4
  118. package/templates/salon-spa/tier5-src/_shared/himi-bookings.ts +1 -1
  119. package/templates/salon-spa/tier5-src/_shared/himi-copy.ts +30 -3
  120. package/templates/salon-spa/tier5-src/himi-booking-bookings/index.ts +2 -4
  121. package/templates/salon-spa/tier5-src/himi-booking-service/index.ts +2 -2
  122. package/templates/salon-spa/tier5-src/himi-booking-time/index.ts +1 -1
  123. package/templates/wholesale-store/tier5-src/_shared/engine-intl.ts +18 -10
  124. package/templates/wholesale-store/tier5-src/_shared/himi-account.ts +5 -4
  125. package/templates/wholesale-store/tier5-src/_shared/himi-copy.ts +30 -3
  126. package/templates/yoga-studio/l10n/en.json +2213 -0
  127. package/templates/yoga-studio/l10n/es.json +10 -0
  128. package/templates/yoga-studio/l10n/he.json +3405 -0
  129. package/templates/yoga-studio/tier5-src/_shared/engine-intl.ts +18 -10
  130. package/templates/yoga-studio/tier5-src/_shared/himi-account.ts +5 -4
  131. package/templates/yoga-studio/tier5-src/_shared/himi-bookings.ts +1 -1
  132. package/templates/yoga-studio/tier5-src/_shared/himi-copy.ts +30 -3
  133. package/templates/yoga-studio/tier5-src/himi-booking-bookings/index.ts +2 -4
  134. package/templates/yoga-studio/tier5-src/himi-booking-service/index.ts +2 -2
  135. package/templates/yoga-studio/tier5-src/himi-booking-time/index.ts +1 -1
  136. package/templates/yoga-studio-owner/tier5-src/_shared/engine-intl.ts +18 -10
  137. package/templates/yoga-studio-owner/tier5-src/_shared/himi-copy.ts +30 -3
@@ -87,7 +87,7 @@ function dateFormat(locale: string, options: Intl.DateTimeFormatOptions, timeZon
87
87
  // ECMA-402 in engine-intl-fallback.test.ts.
88
88
 
89
89
  /** `{ month: "short", day: "numeric", year: "numeric" }` — "Jan 5, 2026". */
90
- export function formatDateMedium(date: Date, locale = "en-US", timeZone?: string): string {
90
+ export function formatDateMedium(date: Date, locale = appLocale(), timeZone?: string): string {
91
91
  if (hasIntl()) {
92
92
  return dateFormat(locale, { month: "short", day: "numeric", year: "numeric" }, timeZone).format(date);
93
93
  }
@@ -95,7 +95,7 @@ export function formatDateMedium(date: Date, locale = "en-US", timeZone?: string
95
95
  }
96
96
 
97
97
  /** `{ month: "short", day: "numeric" }` — "Jan 5". */
98
- export function formatMonthDay(date: Date, locale = "en-US", timeZone?: string): string {
98
+ export function formatMonthDay(date: Date, locale = appLocale(), timeZone?: string): string {
99
99
  if (hasIntl()) {
100
100
  return dateFormat(locale, { month: "short", day: "numeric" }, timeZone).format(date);
101
101
  }
@@ -103,7 +103,7 @@ export function formatMonthDay(date: Date, locale = "en-US", timeZone?: string):
103
103
  }
104
104
 
105
105
  /** `{ month: "long", day: "numeric" }` — "January 5". */
106
- export function formatMonthDayLong(date: Date, locale = "en-US", timeZone?: string): string {
106
+ export function formatMonthDayLong(date: Date, locale = appLocale(), timeZone?: string): string {
107
107
  if (hasIntl()) {
108
108
  return dateFormat(locale, { month: "long", day: "numeric" }, timeZone).format(date);
109
109
  }
@@ -113,7 +113,7 @@ export function formatMonthDayLong(date: Date, locale = "en-US", timeZone?: stri
113
113
  const WEEKDAYS_LONG = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] as const;
114
114
 
115
115
  /** `{ weekday: "short", month: "short", day: "numeric" }` — "Mon, Jan 5". */
116
- export function formatWeekdayMonthDay(date: Date, locale = "en-US", timeZone?: string): string {
116
+ export function formatWeekdayMonthDay(date: Date, locale = appLocale(), timeZone?: string): string {
117
117
  if (hasIntl()) {
118
118
  return dateFormat(locale, { weekday: "short", month: "short", day: "numeric" }, timeZone).format(date);
119
119
  }
@@ -121,7 +121,7 @@ export function formatWeekdayMonthDay(date: Date, locale = "en-US", timeZone?: s
121
121
  }
122
122
 
123
123
  /** `{ weekday: "long", month: "long", day: "numeric" }` — "Monday, January 5". */
124
- export function formatWeekdayMonthDayLong(date: Date, locale = "en-US", timeZone?: string): string {
124
+ export function formatWeekdayMonthDayLong(date: Date, locale = appLocale(), timeZone?: string): string {
125
125
  if (hasIntl()) {
126
126
  return dateFormat(locale, { weekday: "long", month: "long", day: "numeric" }, timeZone).format(date);
127
127
  }
@@ -130,7 +130,7 @@ export function formatWeekdayMonthDayLong(date: Date, locale = "en-US", timeZone
130
130
 
131
131
  /** `{ weekday: "short", month: "short", day: "numeric", hour: "numeric", minute: "2-digit" }`
132
132
  * — "Mon, Jan 5, 3:07 PM". */
133
- export function formatWeekdayDateTime(date: Date, locale = "en-US", timeZone?: string): string {
133
+ export function formatWeekdayDateTime(date: Date, locale = appLocale(), timeZone?: string): string {
134
134
  if (hasIntl()) {
135
135
  return dateFormat(locale, {
136
136
  weekday: "short", month: "short", day: "numeric", hour: "numeric", minute: "2-digit",
@@ -140,7 +140,7 @@ export function formatWeekdayDateTime(date: Date, locale = "en-US", timeZone?: s
140
140
  }
141
141
 
142
142
  /** `{ month: "short", day: "numeric", hour: "numeric", minute: "2-digit" }` — "Jan 5, 3:07 PM". */
143
- export function formatMonthDayTime(date: Date, locale = "en-US", timeZone?: string): string {
143
+ export function formatMonthDayTime(date: Date, locale = appLocale(), timeZone?: string): string {
144
144
  if (hasIntl()) {
145
145
  return dateFormat(locale, {
146
146
  month: "short", day: "numeric", hour: "numeric", minute: "2-digit",
@@ -154,7 +154,7 @@ export function formatMonthDayTime(date: Date, locale = "en-US", timeZone?: stri
154
154
  * Falls back to the same SHAPE (not a different one) so a screen does not visibly change
155
155
  * character between a phone and a watch.
156
156
  */
157
- export function formatDateTimeMedium(date: Date, locale = "en"): string {
157
+ export function formatDateTimeMedium(date: Date, locale = appLocale()): string {
158
158
  if (hasIntl()) {
159
159
  return new Intl.DateTimeFormat(locale, { dateStyle: "medium", timeStyle: "short" }).format(date);
160
160
  }
@@ -439,16 +439,24 @@ function clockParts(d: Date, locale: string, timeZone?: string): { time: string;
439
439
  : clock12(d);
440
440
  // ICU puts a narrow no-break space before the meridiem; normalize so callers can split on it.
441
441
  const clean = full.replace(/[  ]/g, " ");
442
- const m = /^(.*?)\s*([AP]\.?M\.?)$/i.exec(clean);
442
+ const m = /^(.*?)\s*([AP]\.?\s?M\.?)$/i.exec(clean);
443
443
  return m ? { time: m[1], meridiem: m[2] } : { time: clean, meridiem: "" };
444
444
  }
445
445
 
446
446
  /** "8:00 PM" — the one clock every customer screen uses (12-hour, en-US shape). */
447
- export function formatClock(date: Date, locale = "en-US", timeZone?: string): string {
447
+ export function formatClock(date: Date, locale = appLocale(), timeZone?: string): string {
448
448
  const { time, meridiem } = clockParts(date, locale, timeZone);
449
449
  return meridiem ? `${time} ${meridiem}` : time;
450
450
  }
451
451
 
452
+ /** "10:00 – 11:15 AM" when both ends share the meridiem, "11:30 AM – 12:45 PM" otherwise. The meridiem is whatever the
453
+ * locale writes (`AM`, `p. m.`), so it is compared as a whole, never as the last word of the text. */
454
+ export function formatClockRange(start: Date, end: Date, locale = appLocale(), timeZone?: string): string {
455
+ const a = clockParts(start, locale, timeZone), b = clockParts(end, locale, timeZone);
456
+ if (a.meridiem && a.meridiem === b.meridiem) return `${a.time} – ${b.time} ${b.meridiem}`;
457
+ return `${formatClock(start, locale, timeZone)} – ${formatClock(end, locale, timeZone)}`;
458
+ }
459
+
452
460
  /** Is this ISO instant before `now`? A missing or unparseable value is NOT past — "no expiry"
453
461
  * must never classify an offer as expired. */
454
462
  export function isPastDate(iso: string | undefined | null, now: number = Date.now()): boolean {
@@ -4,6 +4,7 @@ import { displayName, getMyData, initials, type WixMyData } from "@himalaya/wix-
4
4
  import { getMyMember } from "@himalaya/wix-members";
5
5
  import { wixMediaUrl } from "@himalaya/wix-media";
6
6
  import { formatDateMedium, formatWeekdayDateTime } from "../_shared/engine-intl.js";
7
+ import { copyParam } from "./himi-copy.js";
7
8
 
8
9
  export interface AccountProfile {
9
10
  isMember: boolean;
@@ -73,7 +74,7 @@ function profileFromData(data: WixMyData, fallbackEmail = ""): AccountProfile {
73
74
  const image = profileImage(data);
74
75
  return {
75
76
  isMember: true,
76
- identityLine: "Signed in",
77
+ identityLine: copyParam("account.signedIn", "Signed in"),
77
78
  detailLine: email || name,
78
79
  memberName: name,
79
80
  memberEmail: email,
@@ -95,7 +96,7 @@ async function siteMemberProfile(email: string): Promise<AccountProfile | undefi
95
96
  const image = wixMediaUrl(member?.profile?.photo?.url) || wixMediaUrl(member?.profile?.photo?.id) || "";
96
97
  return {
97
98
  isMember: true,
98
- identityLine: "Signed in",
99
+ identityLine: copyParam("account.signedIn", "Signed in"),
99
100
  detailLine: email || name,
100
101
  memberName: name,
101
102
  memberEmail: email || member?.loginEmail || "",
@@ -112,7 +113,7 @@ async function siteMemberProfile(email: string): Promise<AccountProfile | undefi
112
113
  export function guestProfile(detailLine: string): AccountProfile {
113
114
  return {
114
115
  isMember: false,
115
- identityLine: "Browsing as a guest",
116
+ identityLine: copyParam("account.guestIdentity", "Browsing as a guest"),
116
117
  detailLine,
117
118
  memberName: "",
118
119
  memberEmail: "",
@@ -151,7 +152,7 @@ export async function loadMemberProfile(guestDetailLine: string): Promise<Accoun
151
152
  if (member) return member;
152
153
  return {
153
154
  isMember: true,
154
- identityLine: "Signed in",
155
+ identityLine: copyParam("account.signedIn", "Signed in"),
155
156
  detailLine: storedEmail,
156
157
  memberName: storedEmail,
157
158
  memberEmail: storedEmail,
@@ -305,7 +305,7 @@ function validDate(value: string | undefined): Date | undefined {
305
305
  }
306
306
 
307
307
  function shortDate(date: Date, year: boolean): string {
308
- return year ? formatDateMedium(date, "en") : formatMonthDay(date, "en");
308
+ return year ? formatDateMedium(date) : formatMonthDay(date);
309
309
  }
310
310
 
311
311
  /** A course's dates, "Nov 3 – Dec 15, 2026" (the year on the first date only when the two
@@ -23,6 +23,10 @@ import { isSingular, setAppLocale, setBusinessTimeZone } from "./app-locale.js";
23
23
  export type CopyPackValue = string | { source: string; translation: string };
24
24
 
25
25
  let stashedCopy: Record<string, CopyPackValue> = Object.create(null);
26
+ /** Stock translations by the English text they replace, from the `textCopy` param. A pinned app's bake
27
+ * names each worker fallback its catalog translates by its text, because a catalog row for worker copy
28
+ * is often keyless. A key's own `copy` entry always wins over this. */
29
+ let stashedByText = new Map<string, string>();
26
30
  let copyReceived = false;
27
31
 
28
32
  /** Absorb the `copy` onAppear param (customer strings or stock translation records)
@@ -37,6 +41,11 @@ export function stashCopy(arg: unknown): void {
37
41
  setAppLocale((arg as Record<string, unknown>).locale);
38
42
  setBusinessTimeZone((arg as Record<string, unknown>).businessTimeZone);
39
43
  }
44
+ const text = (arg as Record<string, unknown>).textCopy;
45
+ if (typeof text === "string" && text) {
46
+ const parsed = parseTextCopy(text);
47
+ if (parsed) { stashedByText = parsed; copyReceived = true; }
48
+ }
40
49
  const raw = (arg as Record<string, unknown>).copy;
41
50
  if (typeof raw !== "string" || !raw) return;
42
51
  try {
@@ -59,15 +68,33 @@ export function stashCopy(arg: unknown): void {
59
68
  }
60
69
  }
61
70
 
71
+ /** `textCopy`: a JSON object from English text to its translation. A malformed one is ignored (the
72
+ * stock copy keeps rendering); an entry that is not a non-empty string is dropped. */
73
+ function parseTextCopy(text: string): Map<string, string> | undefined {
74
+ try {
75
+ const parsed = JSON.parse(text) as unknown;
76
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return undefined;
77
+ const out = new Map<string, string>();
78
+ for (const [source, translation] of Object.entries(parsed as Record<string, unknown>)) {
79
+ if (typeof translation === "string" && translation !== "") out.set(source, translation);
80
+ }
81
+ return out;
82
+ } catch {
83
+ return undefined;
84
+ }
85
+ }
86
+
62
87
  /** The provisioned override for `key`, or `fallback` (the stock copy). An optional
63
88
  * restored label survives only until a current copy pack arrives. */
64
89
  export function copyParam(key: string, fallback: string, restoredFallback = fallback): string {
65
90
  const value = stashedCopy[key];
66
91
  // A disk-restored row may paint before onAppear supplies its copy pack. Keep its
67
92
  // last label only before a pack arrives; even an empty current pack selects stock copy.
68
- if (value === undefined) return copyReceived ? fallback : restoredFallback;
69
- if (typeof value === "string") return value !== "" ? value : fallback;
70
- return value?.source === fallback && value.translation !== "" ? value.translation : fallback;
93
+ if (value === undefined) return stashedByText.get(fallback) ?? (copyReceived ? fallback : restoredFallback);
94
+ // A key can serve two messages: a row for another source text, or an empty one, must not hide the stock translation
95
+ // the app's catalog has for the fallback actually passed.
96
+ if (typeof value === "string") return value !== "" ? value : stashedByText.get(fallback) ?? fallback;
97
+ return value?.source === fallback && value.translation !== "" ? value.translation : stashedByText.get(fallback) ?? fallback;
71
98
  }
72
99
 
73
100
  /** Interpolate `{name}` placeholders in a (possibly overridden) template:
@@ -8,7 +8,7 @@ import { copyParam, copyTemplate } from "../_shared/himi-copy.js";
8
8
  import { memberAccess, assertMemberAccess, memberAccessChanged, memberAccessDenied, type MemberAccess } from "../_shared/member-access.js";
9
9
  import { fetchMemberBookings, CANCELLED_STATUSES, type MemberBookingRow } from "../_shared/member-bookings.js";
10
10
  import { emitHostEvent } from "../_shared/host-events.js";
11
- import { formatClock, formatDateMedium, formatMonthDay, formatWeekdayMonthDay, formatWeekdayMonthDayLong } from "../_shared/engine-intl.js";
11
+ import { formatClock, formatClockRange, formatDateMedium, formatMonthDay, formatWeekdayMonthDay, formatWeekdayMonthDayLong } from "../_shared/engine-intl.js";
12
12
  import { parseWeeklyGoal, weeklyGoalProgress, weeklySessionsFromPages } from "../_shared/weekly-goal.js";
13
13
 
14
14
  // My Bookings: Upcoming / Past / Canceled tabs over the member's own bookings, a booking sheet with
@@ -157,9 +157,7 @@ function staffLine(row: MemberBookingRow): string {
157
157
 
158
158
  /** "10:00 – 11:15 AM" (one meridiem when both share it), "11:30 AM – 12:45 PM" otherwise. */
159
159
  function timeRange(start: Date, end: Date): string {
160
- const a = formatClock(start), b = formatClock(end);
161
- const ma = /\s(\S+)$/.exec(a)?.[1], mb = /\s(\S+)$/.exec(b)?.[1];
162
- return ma && ma === mb ? `${a.slice(0, -ma.length).trim()} – ${b}` : `${a} – ${b}`;
160
+ return formatClockRange(start, end);
163
161
  }
164
162
 
165
163
  function durationText(minutes: number): string {
@@ -503,7 +503,7 @@ function validDate(value: string | undefined): Date | undefined {
503
503
  }
504
504
 
505
505
  function shortDate(date: Date, year: boolean): string {
506
- return year ? formatDateMedium(date, "en") : formatMonthDay(date, "en");
506
+ return year ? formatDateMedium(date) : formatMonthDay(date);
507
507
  }
508
508
 
509
509
  function courseDates(service: WixService): string {
@@ -523,7 +523,7 @@ function sessionTime(start: string, end: string | undefined): string {
523
523
  const from = validDate(start);
524
524
  const to = validDate(end);
525
525
  if (!from) return "";
526
- return to ? `${formatClock(from, "en")} – ${formatClock(to, "en")}` : formatClock(from, "en");
526
+ return to ? `${formatClock(from)} – ${formatClock(to)}` : formatClock(from);
527
527
  }
528
528
 
529
529
  /** V1 availability is the same visitor-readable call used by the time screen. Ask
@@ -382,7 +382,7 @@ function isoDate(date: Date): string {
382
382
 
383
383
  function fmtRange(start?: string, end?: string): { day: string; title: string; subtitle: string } {
384
384
  const s = toDate(start);
385
- if (!s) return { day: "", title: "Available time", subtitle: "" };
385
+ if (!s) return { day: "", title: copyParam("time.availableTime", "Available time"), subtitle: "" };
386
386
  const endTime = timeLabel(end);
387
387
  return {
388
388
  // "Today" / "Tomorrow" / "Mon, Jun 9" — the shared relative window, so this
@@ -23,6 +23,10 @@ import { isSingular, setAppLocale, setBusinessTimeZone } from "./app-locale.js";
23
23
  export type CopyPackValue = string | { source: string; translation: string };
24
24
 
25
25
  let stashedCopy: Record<string, CopyPackValue> = Object.create(null);
26
+ /** Stock translations by the English text they replace, from the `textCopy` param. A pinned app's bake
27
+ * names each worker fallback its catalog translates by its text, because a catalog row for worker copy
28
+ * is often keyless. A key's own `copy` entry always wins over this. */
29
+ let stashedByText = new Map<string, string>();
26
30
  let copyReceived = false;
27
31
 
28
32
  /** Absorb the `copy` onAppear param (customer strings or stock translation records)
@@ -37,6 +41,11 @@ export function stashCopy(arg: unknown): void {
37
41
  setAppLocale((arg as Record<string, unknown>).locale);
38
42
  setBusinessTimeZone((arg as Record<string, unknown>).businessTimeZone);
39
43
  }
44
+ const text = (arg as Record<string, unknown>).textCopy;
45
+ if (typeof text === "string" && text) {
46
+ const parsed = parseTextCopy(text);
47
+ if (parsed) { stashedByText = parsed; copyReceived = true; }
48
+ }
40
49
  const raw = (arg as Record<string, unknown>).copy;
41
50
  if (typeof raw !== "string" || !raw) return;
42
51
  try {
@@ -59,15 +68,33 @@ export function stashCopy(arg: unknown): void {
59
68
  }
60
69
  }
61
70
 
71
+ /** `textCopy`: a JSON object from English text to its translation. A malformed one is ignored (the
72
+ * stock copy keeps rendering); an entry that is not a non-empty string is dropped. */
73
+ function parseTextCopy(text: string): Map<string, string> | undefined {
74
+ try {
75
+ const parsed = JSON.parse(text) as unknown;
76
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return undefined;
77
+ const out = new Map<string, string>();
78
+ for (const [source, translation] of Object.entries(parsed as Record<string, unknown>)) {
79
+ if (typeof translation === "string" && translation !== "") out.set(source, translation);
80
+ }
81
+ return out;
82
+ } catch {
83
+ return undefined;
84
+ }
85
+ }
86
+
62
87
  /** The provisioned override for `key`, or `fallback` (the stock copy). An optional
63
88
  * restored label survives only until a current copy pack arrives. */
64
89
  export function copyParam(key: string, fallback: string, restoredFallback = fallback): string {
65
90
  const value = stashedCopy[key];
66
91
  // A disk-restored row may paint before onAppear supplies its copy pack. Keep its
67
92
  // last label only before a pack arrives; even an empty current pack selects stock copy.
68
- if (value === undefined) return copyReceived ? fallback : restoredFallback;
69
- if (typeof value === "string") return value !== "" ? value : fallback;
70
- return value?.source === fallback && value.translation !== "" ? value.translation : fallback;
93
+ if (value === undefined) return stashedByText.get(fallback) ?? (copyReceived ? fallback : restoredFallback);
94
+ // A key can serve two messages: a row for another source text, or an empty one, must not hide the stock translation
95
+ // the app's catalog has for the fallback actually passed.
96
+ if (typeof value === "string") return value !== "" ? value : stashedByText.get(fallback) ?? fallback;
97
+ return value?.source === fallback && value.translation !== "" ? value.translation : stashedByText.get(fallback) ?? fallback;
71
98
  }
72
99
 
73
100
  /** Interpolate `{name}` placeholders in a (possibly overridden) template: