@wix/himalaya-cli 0.1613.0 → 0.1615.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 (130) hide show
  1. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/sdk/ui/src/index.d.ts +53 -13
  2. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/schema.d.ts +3 -0
  3. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/ui.mjs +31 -5
  4. package/dist/cli.mjs +1638 -1330
  5. package/dist/preview-assets.generated.bin +0 -0
  6. package/fixtures/wix-canned.json +4 -0
  7. package/guides/component-reference.json +1 -1
  8. package/guides/component-reference.md +3 -0
  9. package/guides/designing-himi-screens.md +4 -1
  10. package/guides/hhp.md +2 -2
  11. package/guides/sdk-reference.json +28 -4
  12. package/package.json +2 -2
  13. package/template-icons/salon-spa.png +0 -0
  14. package/templates/beauty-salon/tier5-src/_shared/branded-load-state.ts +5 -2
  15. package/templates/beauty-salon/tier5-src/_shared/himi-account.ts +31 -0
  16. package/templates/beauty-salon/tier5-src/_shared/himi-booking-saved.ts +88 -0
  17. package/templates/beauty-salon/tier5-src/himi-booking-service/index.ts +50 -3
  18. package/templates/beauty-salon/tier5-src/himi-booking-services/index.ts +70 -3
  19. package/templates/beauty-salon/tier5-src/himi-booking-time/index.ts +40 -8
  20. package/templates/beauty-salon/tier5-src/himi-branded-lite-agenda/index.ts +7 -2
  21. package/templates/beauty-salon/tier5-src/himi-branded-lite-home/index.ts +178 -12
  22. package/templates/branded-lite/dev/index.ts +192 -0
  23. package/templates/branded-lite/l10n/en.json +1 -1
  24. package/templates/branded-lite/tier5-src/_shared/branded-load-state.ts +5 -2
  25. package/templates/branded-lite/tier5-src/_shared/himi-account.ts +31 -0
  26. package/templates/branded-lite/tier5-src/_shared/himi-booking-saved.ts +88 -0
  27. package/templates/branded-lite/tier5-src/himi-booking-service/index.ts +50 -3
  28. package/templates/branded-lite/tier5-src/himi-booking-services/index.ts +70 -3
  29. package/templates/branded-lite/tier5-src/himi-booking-time/index.ts +40 -8
  30. package/templates/branded-lite/tier5-src/himi-branded-lite-agenda/index.ts +7 -2
  31. package/templates/branded-lite/tier5-src/himi-branded-lite-galleries/index.ts +104 -12
  32. package/templates/branded-lite/tier5-src/himi-branded-lite-home/index.ts +178 -12
  33. package/templates/community-club/tier5-src/_shared/branded-load-state.ts +5 -2
  34. package/templates/community-club/tier5-src/_shared/himi-account.ts +31 -0
  35. package/templates/community-club/tier5-src/himi-branded-lite-home/index.ts +178 -12
  36. package/templates/events-meetups/tier5-src/_shared/branded-load-state.ts +5 -2
  37. package/templates/events-meetups/tier5-src/_shared/himi-account.ts +31 -0
  38. package/templates/events-meetups/tier5-src/himi-branded-lite-home/index.ts +178 -12
  39. package/templates/gym-fitness/tier5-src/_shared/branded-load-state.ts +5 -2
  40. package/templates/gym-fitness/tier5-src/_shared/himi-account.ts +31 -0
  41. package/templates/gym-fitness/tier5-src/_shared/himi-booking-saved.ts +88 -0
  42. package/templates/gym-fitness/tier5-src/himi-booking-service/index.ts +50 -3
  43. package/templates/gym-fitness/tier5-src/himi-booking-services/index.ts +70 -3
  44. package/templates/gym-fitness/tier5-src/himi-booking-time/index.ts +40 -8
  45. package/templates/gym-fitness/tier5-src/himi-branded-lite-agenda/index.ts +7 -2
  46. package/templates/gym-fitness/tier5-src/himi-branded-lite-home/index.ts +178 -12
  47. package/templates/nonprofit-cause/tier5-src/_shared/branded-load-state.ts +5 -2
  48. package/templates/nonprofit-cause/tier5-src/_shared/himi-account.ts +31 -0
  49. package/templates/nonprofit-cause/tier5-src/himi-branded-lite-home/index.ts +178 -12
  50. package/templates/podcast-creator/tier5-src/_shared/branded-load-state.ts +5 -2
  51. package/templates/podcast-creator/tier5-src/_shared/himi-account.ts +31 -0
  52. package/templates/podcast-creator/tier5-src/himi-branded-lite-home/index.ts +178 -12
  53. package/templates/portfolio-creative/tier5-src/_shared/branded-load-state.ts +5 -2
  54. package/templates/portfolio-creative/tier5-src/_shared/himi-account.ts +31 -0
  55. package/templates/portfolio-creative/tier5-src/himi-branded-lite-home/index.ts +178 -12
  56. package/templates/restaurant/tier5-src/_shared/branded-load-state.ts +5 -2
  57. package/templates/restaurant/tier5-src/_shared/himi-account.ts +31 -0
  58. package/templates/restaurant/tier5-src/himi-branded-lite-home/index.ts +178 -12
  59. package/templates/retail-store/tier5-src/_shared/branded-load-state.ts +5 -2
  60. package/templates/retail-store/tier5-src/_shared/himi-account.ts +31 -0
  61. package/templates/retail-store/tier5-src/himi-branded-lite-home/index.ts +178 -12
  62. package/templates/salon-spa/README.md +53 -0
  63. package/templates/salon-spa/config.ts +272 -0
  64. package/templates/salon-spa/dev/index.ts +19893 -0
  65. package/templates/salon-spa/himalaya.content.json +49 -0
  66. package/templates/salon-spa/himalaya.template.json +14 -0
  67. package/templates/salon-spa/icon.png +0 -0
  68. package/templates/salon-spa/platforms.json +1 -0
  69. package/templates/salon-spa/tier5-src/_shared/app-locale.ts +61 -0
  70. package/templates/salon-spa/tier5-src/_shared/booking-location.ts +147 -0
  71. package/templates/salon-spa/tier5-src/_shared/booking-session.ts +222 -0
  72. package/templates/salon-spa/tier5-src/_shared/branded-lite-hosted.ts +278 -0
  73. package/templates/salon-spa/tier5-src/_shared/branded-load-state.ts +109 -0
  74. package/templates/salon-spa/tier5-src/_shared/business-chat-copy.ts +40 -0
  75. package/templates/salon-spa/tier5-src/_shared/business-chat-history.ts +48 -0
  76. package/templates/salon-spa/tier5-src/_shared/business-chat-message-model.ts +177 -0
  77. package/templates/salon-spa/tier5-src/_shared/business-chat-model.ts +56 -0
  78. package/templates/salon-spa/tier5-src/_shared/business-chat-presenter.ts +581 -0
  79. package/templates/salon-spa/tier5-src/_shared/business-chat-transport.ts +148 -0
  80. package/templates/salon-spa/tier5-src/_shared/collection-contract.ts +230 -0
  81. package/templates/salon-spa/tier5-src/_shared/collection-query.ts +193 -0
  82. package/templates/salon-spa/tier5-src/_shared/collection-service.ts +400 -0
  83. package/templates/salon-spa/tier5-src/_shared/detail-presence.ts +51 -0
  84. package/templates/salon-spa/tier5-src/_shared/empty-flags.ts +33 -0
  85. package/templates/salon-spa/tier5-src/_shared/engine-intl.ts +508 -0
  86. package/templates/salon-spa/tier5-src/_shared/himi-account.ts +164 -0
  87. package/templates/salon-spa/tier5-src/_shared/himi-booking-saved.ts +88 -0
  88. package/templates/salon-spa/tier5-src/_shared/himi-bookings.ts +318 -0
  89. package/templates/salon-spa/tier5-src/_shared/himi-copy.ts +89 -0
  90. package/templates/salon-spa/tier5-src/_shared/himi-store.ts +7 -0
  91. package/templates/salon-spa/tier5-src/_shared/himi-text.ts +24 -0
  92. package/templates/salon-spa/tier5-src/_shared/host-events.ts +66 -0
  93. package/templates/salon-spa/tier5-src/_shared/hosted-checkout.ts +70 -0
  94. package/templates/salon-spa/tier5-src/_shared/iap-attendance-form.ts +106 -0
  95. package/templates/salon-spa/tier5-src/_shared/iap-attendance-purchase.ts +211 -0
  96. package/templates/salon-spa/tier5-src/_shared/iap-attendance.ts +38 -0
  97. package/templates/salon-spa/tier5-src/_shared/iap-worker.ts +125 -0
  98. package/templates/salon-spa/tier5-src/_shared/local-preferences.ts +38 -0
  99. package/templates/salon-spa/tier5-src/_shared/member-access.ts +52 -0
  100. package/templates/salon-spa/tier5-src/_shared/member-account-routes.ts +52 -0
  101. package/templates/salon-spa/tier5-src/_shared/member-bookings.ts +94 -0
  102. package/templates/salon-spa/tier5-src/_shared/offset-page.ts +10 -0
  103. package/templates/salon-spa/tier5-src/_shared/online-actions.ts +76 -0
  104. package/templates/salon-spa/tier5-src/_shared/owner-load-error.ts +348 -0
  105. package/templates/salon-spa/tier5-src/_shared/payment-setup.ts +6 -0
  106. package/templates/salon-spa/tier5-src/_shared/rich-body.ts +78 -0
  107. package/templates/salon-spa/tier5-src/_shared/rich-content-link.ts +34 -0
  108. package/templates/salon-spa/tier5-src/_shared/weekly-goal.ts +107 -0
  109. package/templates/salon-spa/tier5-src/_shared/wix-service-price.ts +146 -0
  110. package/templates/salon-spa/tier5-src/business-chat/index.ts +669 -0
  111. package/templates/salon-spa/tier5-src/himi-booking-account/index.ts +241 -0
  112. package/templates/salon-spa/tier5-src/himi-booking-bookings/index.ts +466 -0
  113. package/templates/salon-spa/tier5-src/himi-booking-saved/index.ts +103 -0
  114. package/templates/salon-spa/tier5-src/himi-booking-service/index.ts +1170 -0
  115. package/templates/salon-spa/tier5-src/himi-booking-services/index.ts +791 -0
  116. package/templates/salon-spa/tier5-src/himi-booking-time/index.ts +1712 -0
  117. package/templates/salon-spa/tier5-src/himi-branded-lite-agenda/index.ts +950 -0
  118. package/templates/salon-spa/tier5-src/himi-branded-lite-galleries/index.ts +282 -0
  119. package/templates/salon-spa/tier5-src/himi-salon-home/index.ts +544 -0
  120. package/templates/salon-spa/tier5-src/himi-store-account/index.ts +925 -0
  121. package/templates/salon-spa/tokens.json +341 -0
  122. package/templates/yoga-studio/dev/index.ts +192 -0
  123. package/templates/yoga-studio/tier5-src/_shared/branded-load-state.ts +5 -2
  124. package/templates/yoga-studio/tier5-src/_shared/himi-account.ts +31 -0
  125. package/templates/yoga-studio/tier5-src/_shared/himi-booking-saved.ts +88 -0
  126. package/templates/yoga-studio/tier5-src/himi-booking-service/index.ts +50 -3
  127. package/templates/yoga-studio/tier5-src/himi-booking-services/index.ts +70 -3
  128. package/templates/yoga-studio/tier5-src/himi-booking-time/index.ts +40 -8
  129. package/templates/yoga-studio/tier5-src/himi-branded-lite-agenda/index.ts +7 -2
  130. package/templates/yoga-studio/tier5-src/himi-branded-lite-home/index.ts +178 -12
@@ -326,6 +326,9 @@ function inputId(): string {
326
326
  * not just the first, because the boot load and the screen's own `load` can overlap. */
327
327
  /** Counts the customer's picks. A load that sees it move ran while they picked a time. */
328
328
  let selectionRevision = 0;
329
+ // Each guest tap that asks the session first: only the newest answers, so two quick taps whose
330
+ // reads come back out of order never pick the older time or open a second sign-in.
331
+ let sessionTaps = 0;
329
332
 
330
333
  let pendingStart = (() => {
331
334
  const start = (globalThis as { himalaya?: { input?: { start?: unknown } } }).himalaya?.input?.start;
@@ -958,12 +961,13 @@ let dayRevision = 0;
958
961
  /** True while "Check Next Availability" searches; a second tap waits for the first. */
959
962
  let checkingNextLock = false;
960
963
 
961
- /** `{ slotId, signInScreenId }` from a pill tap (or a bare slot id). */
962
- function tapped(arg: unknown): { slotId: string; signInScreenId: string } {
963
- if (typeof arg === "string") return { slotId: arg, signInScreenId: "" };
964
- const a = (arg ?? {}) as { slotId?: unknown; id?: unknown; signInScreenId?: unknown };
964
+ /** `{ slotId, signInScreenId, signInPresentation }` from a pill tap (or a bare slot id). */
965
+ function tapped(arg: unknown): { slotId: string; signInScreenId: string; signInPresentation: "" | "sheet" | "full_screen" } {
966
+ if (typeof arg === "string") return { slotId: arg, signInScreenId: "", signInPresentation: "" };
967
+ const a = (arg ?? {}) as { slotId?: unknown; id?: unknown; signInScreenId?: unknown; signInPresentation?: unknown };
965
968
  const slotId = typeof a.slotId === "string" ? a.slotId : typeof a.id === "string" ? a.id : "";
966
- return { slotId, signInScreenId: typeof a.signInScreenId === "string" ? a.signInScreenId : "" };
969
+ const presentation = a.signInPresentation === "sheet" || a.signInPresentation === "full_screen" ? a.signInPresentation : "";
970
+ return { slotId, signInScreenId: typeof a.signInScreenId === "string" ? a.signInScreenId : "", signInPresentation: presentation };
967
971
  }
968
972
 
969
973
  /** Select a bookable time, as a tap does: the pick-storage rules and the selection revision. */
@@ -1304,12 +1308,40 @@ const svc = defineService<S, {
1304
1308
  // taps it again. Where the regular checkout is not allowed, the tap selects the time for the
1305
1309
  // in-app purchase button.
1306
1310
  pickSlot: async (s, arg): Promise<S | undefined> => {
1307
- const { slotId, signInScreenId } = tapped(arg);
1311
+ const { slotId, signInScreenId, signInPresentation } = tapped(arg);
1308
1312
  if (bookingLock || s.bookingInFlight || !allRows.some((row) => row.id === slotId && row.selectable)) return derive(s);
1309
1313
  const selected = selectSlotIn(s, slotId);
1310
- if (!s.isMember) {
1314
+ // A modal sign-in leaves this screen in place: a host need not run its onAppear when the
1315
+ // sheet closes, and the reload that refreshes `isMember` can still be running. So ask the
1316
+ // session before opening the sheet again, or a member's tap would only reopen it. Only the
1317
+ // session's own identity counts here, never getMyData: that can still answer with a stale
1318
+ // site or owner profile for a visitor. A member found here gets the pick and the "tap again"
1319
+ // note, as after a reload, and books on the next tap: that tap passes the booking lock and
1320
+ // the offline guard with the member state, which this await would let a second tap skip.
1321
+ if (!selected.isMember && signInScreenId && signInPresentation) {
1322
+ const mine = ++sessionTaps;
1323
+ const email = await signedInEmail();
1324
+ if (mine !== sessionTaps) return undefined;
1325
+ // From the state as it is NOW: a reload may have landed during the await. The pick
1326
+ // stays only while that time is still bookable.
1327
+ const now = svc.getState?.() ?? s;
1328
+ const open = allRows.some((row) => row.id === slotId && row.selectable);
1329
+ if (email) {
1330
+ return derive({ ...(open ? selectSlotIn(now, slotId) : now), isMember: true, identityLine: email, email,
1331
+ message: open ? copyParam("time.signedInTapAgain", "Signed in. Tap the time again to book it.") : "" });
1332
+ }
1333
+ // Still a guest: the sign-in opens over the newest state; a time gone meanwhile opens nothing.
1334
+ if (!open) return derive(now);
1335
+ return navigate(selectSlotIn(now, slotId), { screenId: signInScreenId, presentation: signInPresentation, args: { mode: "signin", intent: "book", modal: "1" } });
1336
+ }
1337
+ if (!selected.isMember) {
1311
1338
  // Branded Lite opens its sign-in screen; other apps show the sign-in card on this screen.
1312
- return signInScreenId ? navigate(selected, { screenId: signInScreenId, args: { mode: "signin", intent: "book" } }) : selected;
1339
+ // With a presentation it opens as a modal (`modal`: the sign-in worker closes it after a
1340
+ // sign-in), and this screen loads again under it with the guest's pick kept.
1341
+ if (!signInScreenId) return selected;
1342
+ return navigate(selected, signInPresentation
1343
+ ? { screenId: signInScreenId, presentation: signInPresentation, args: { mode: "signin", intent: "book", modal: "1" } }
1344
+ : { screenId: signInScreenId, args: { mode: "signin", intent: "book" } });
1313
1345
  }
1314
1346
  const regular = regularCheckoutAllowed || applePurchase.usesRegularPlatform();
1315
1347
  if (!regular && !waitlistIds.has(slotId)) {
@@ -650,6 +650,9 @@ async function settled(next: S | undefined): Promise<S | undefined> {
650
650
 
651
651
  /** How the app opens its sign-in screen, from the appear params ("" = push). */
652
652
  let signInPresentation: "" | "sheet" | "full_screen" = "";
653
+ /** The app's sign-in screen (`signInScreenId` appear param): Branded Lite's `himi_sign_in` by
654
+ * default; an app with no such screen names its own (salon-spa: the Profile tab, `himi_account`). */
655
+ let signInScreenId = "himi_sign_in";
653
656
 
654
657
  const svc = defineService<S, {
655
658
  load: (s: S, p?: unknown) => Promise<S | undefined>;
@@ -678,6 +681,8 @@ const svc = defineService<S, {
678
681
  stashCopy(p);
679
682
  const presentation = argOf(p, "signInPresentation");
680
683
  if (presentation === "sheet" || presentation === "full_screen") signInPresentation = presentation;
684
+ const signInScreen = argOf(p, "signInScreenId");
685
+ if (/^[a-z][a-z0-9_]{0,63}$/.test(signInScreen)) signInScreenId = signInScreen;
681
686
  const fw = Number(argOf(p, "firstWeekday") || s.firstWeekday);
682
687
  const today = dayKey(new Date());
683
688
  // First appearance: open on this week. A re-appearance keeps the member's place and
@@ -878,8 +883,8 @@ const svc = defineService<S, {
878
883
  busy = false;
879
884
  // As a modal it only closes, and this screen loads again (its re-appearance reload).
880
885
  return navigate(s, signInPresentation
881
- ? { screenId: "himi_sign_in", presentation: signInPresentation, args: { mode: "signin", modal: "1" } }
882
- : { screenId: "himi_sign_in", args: { mode: "signin", returnScreenId: "himi_agenda" } });
886
+ ? { screenId: signInScreenId, presentation: signInPresentation, args: { mode: "signin", modal: "1" } }
887
+ : { screenId: signInScreenId, args: { mode: "signin", returnScreenId: "himi_agenda" } });
883
888
  }
884
889
  const name = await memberName();
885
890
  const current = await memberAccess().catch(() => undefined);
@@ -9,7 +9,14 @@ import { withIapPresentation } from "../_shared/iap-presentation.js";
9
9
  import { queryServices, type WixService } from "@himalaya/wix-bookings";
10
10
  import { getPost, queryPosts, type WixPost } from "@himalaya/wix-blog";
11
11
  import { queryGroups, type WixGroup } from "@himalaya/wix-groups";
12
- import { queryPrograms, type WixProgram } from "@himalaya/wix-online-programs";
12
+ import {
13
+ listMyParticipations,
14
+ participationsByProgram,
15
+ queryJoinApplications,
16
+ queryPrograms,
17
+ type WixProgram,
18
+ } from "@himalaya/wix-online-programs";
19
+ import { getMyMember } from "@himalaya/wix-members";
13
20
  import { listFeedItems, type WixFeedItem, type WixFeedProfile } from "@himalaya/wix-social-feed";
14
21
  import { queryItems as queryMenuItems, querySections as queryMenuSections } from "@himalaya/wix-restaurants";
15
22
  import { normalizeEvent, queryEvents } from "../_shared/himi-events.js";
@@ -166,6 +173,13 @@ interface ProgramCard {
166
173
  noImage: boolean;
167
174
  }
168
175
 
176
+ /** A member's own program state, kept separate from the visitor catalog cards. */
177
+ interface MemberProgramCard extends ProgramCard {
178
+ stateLabel: string;
179
+ progressFraction: number;
180
+ hideProgress: boolean;
181
+ }
182
+
169
183
  /** A communityPulse latest-activity Carousel card (design §4.5). */
170
184
  interface FeedHighlight {
171
185
  id: string;
@@ -308,6 +322,8 @@ interface State {
308
322
  noNextEvent: boolean;
309
323
  homePrograms: ProgramCard[];
310
324
  noHomePrograms: boolean;
325
+ memberPrograms: MemberProgramCard[];
326
+ noMemberPrograms: boolean;
311
327
  /** The videos module's carousel — the newest ready Wix Video videos, the channels
312
328
  * taking turns. Guarded on `videos`; same silent-fail contract. */
313
329
  homeVideos: (WixVideoCard & CaptionFlags)[];
@@ -549,6 +565,7 @@ interface ExtrasSignal {
549
565
  upcomingEvents: EventEntry[];
550
566
  nextEventCards: NextEventCard[];
551
567
  homePrograms: ProgramCard[];
568
+ memberPrograms: MemberProgramCard[];
552
569
  homeVideos: (WixVideoCard & CaptionFlags)[];
553
570
  feedHighlights: FeedHighlight[];
554
571
  memberAvatars: CoachAvatar[];
@@ -559,8 +576,17 @@ interface ExtrasSignal {
559
576
  menuCategories: MenuCategory[];
560
577
  }
561
578
 
579
+ let homeProgramCandidates: { generation: number; programs: WixProgram[] } = { generation: 0, programs: [] };
580
+ /** A finite number from a progress field, or `fallback` when the read left it out or sent junk. */
581
+ function finiteOr(value: unknown, fallback: number): number {
582
+ return typeof value === "number" && Number.isFinite(value) ? value : fallback;
583
+ }
584
+
585
+ /** How many microtask turns `memberProgramsLoaded` waits for refresh's own result to land (see the action). */
586
+ const MEMBER_PROGRAMS_APPLY_RETRIES = 50;
587
+
562
588
  function emptyExtrasSignal(): ExtrasSignal {
563
- return { upcomingEvents: [], nextEventCards: [], homePrograms: [], homeVideos: [], feedHighlights: [], memberAvatars: [], groupCards: [], announcementTitle: "", postCards: [], popularDishes: [], menuCategories: [] };
589
+ return { upcomingEvents: [], nextEventCards: [], homePrograms: [], memberPrograms: [], homeVideos: [], feedHighlights: [], memberAvatars: [], groupCards: [], announcementTitle: "", postCards: [], popularDishes: [], menuCategories: [] };
564
590
  }
565
591
 
566
592
  /** Cover URL probe for a blog post — the himi-blog-feed imageUrl fallbacks
@@ -670,13 +696,13 @@ async function fetchUpcomingEvents(): Promise<{ entries: EventEntry[]; nextEvent
670
696
  }
671
697
  }
672
698
 
673
- async function fetchHomePrograms(): Promise<ProgramCard[]> {
699
+ async function fetchHomePrograms(): Promise<{ cards: ProgramCard[]; programs: WixProgram[] }> {
674
700
  try {
675
701
  const response = await queryPrograms({ cursorPaging: { limit: 12 } });
676
- return (response.programs ?? [])
702
+ const programs = (response.programs ?? [])
677
703
  .filter((p: WixProgram) => ((p.state ?? p.status ?? "").toUpperCase()) !== "DRAFT")
678
- .slice(0, 6)
679
- .map((p: WixProgram) => {
704
+ .slice(0, 12);
705
+ const cards = programs.slice(0, 6).map((p: WixProgram) => {
680
706
  const desc = (p as { description?: unknown }).description;
681
707
  const nestedTitle = desc && typeof desc === "object" ? (desc as { title?: string }).title : undefined;
682
708
  const name = cleanTitle(p.settings?.title ?? nestedTitle ?? p.title) || copyParam("home.programFallbackName", "Program");
@@ -692,7 +718,112 @@ async function fetchHomePrograms(): Promise<ProgramCard[]> {
692
718
  noImage: !image,
693
719
  };
694
720
  });
721
+ return { cards, programs };
695
722
  } catch {
723
+ return { cards: [], programs: [] };
724
+ }
725
+ }
726
+
727
+ /** Member state is best-effort Home enrichment: visitors and unsupported member sessions
728
+ * collapse the rail, while the public Programs section remains available. */
729
+ async function fetchMemberProgramCards(programs: WixProgram[]): Promise<MemberProgramCard[]> {
730
+ try {
731
+ const member = await memberAccess();
732
+ if (!member.email) return [];
733
+ const memberId = (await getMyMember()).member?.id;
734
+ if (!memberId) return [];
735
+
736
+ const [participantResult, applicationResult] = await Promise.allSettled([
737
+ listMyParticipations(memberId, { maxPages: 2 }),
738
+ queryJoinApplications({ memberId, limit: 100 }),
739
+ ]);
740
+ // These are independent member reads. An unverified participant-query permission
741
+ // must not also hide applications that the member-scoped endpoint can return.
742
+ const participants = participantResult.status === "fulfilled" ? participantResult.value : [];
743
+ const applications = applicationResult.status === "fulfilled" ? applicationResult.value : { joinApplications: [] };
744
+ const participation = participationsByProgram(participants);
745
+ // An application that already became a participant keeps its status and carries `participantId`
746
+ // (the SDK's PENDING_JOIN_APPLICATION_STATUSES note): the participation is the standing, and a member
747
+ // who later left must not read as "Approved" from the application that once admitted them. Newest
748
+ // first, one per program, and only programs with no participation of their own — so the admitted
749
+ // rows a joined member accumulates never take the lookup slots of a real pending request.
750
+ const applicationByProgram = new Map<string, { status?: string }>();
751
+ for (const application of applications.joinApplications ?? []) {
752
+ if (!application.programId || application.participantId || participation.has(application.programId)) continue;
753
+ if (!applicationByProgram.has(application.programId)) applicationByProgram.set(application.programId, application);
754
+ }
755
+ // The public catalog preview is intentionally capped at 12. Resolve the
756
+ // member's six most recent enrolled programs and six open applications
757
+ // outside that window in one filtered query so both remain visible.
758
+ const knownIds = new Set(programs.map((program) => program.id).filter((id): id is string => !!id));
759
+ const participantProgramIds = [...participation.keys()].slice(0, 6);
760
+ const applicationProgramIds = [...applicationByProgram.keys()].filter((id) => !participantProgramIds.includes(id)).slice(0, 6);
761
+ const candidateIds = [...participantProgramIds, ...applicationProgramIds].slice(0, 12);
762
+ const missingIds = candidateIds.filter((id) => !knownIds.has(id));
763
+ const extraPrograms = missingIds.length
764
+ ? await queryPrograms({ filter: { id: { $in: missingIds } }, cursorPaging: { limit: missingIds.length } })
765
+ .then((response) => response.programs ?? []).catch(() => [])
766
+ : [];
767
+ const memberPrograms = [...programs, ...extraPrograms.filter((program) => !!program.id && !knownIds.has(program.id))];
768
+ await assertMemberAccess(member);
769
+
770
+ return memberPrograms.flatMap((program) => {
771
+ if (!program.id) return [];
772
+ const participant = participation.get(program.id);
773
+ const application = applicationByProgram.get(program.id);
774
+ if (!participant && !application) return [];
775
+ const desc = (program as { description?: unknown }).description;
776
+ const nestedTitle = desc && typeof desc === "object" ? (desc as { title?: string }).title : undefined;
777
+ const name = cleanTitle(program.settings?.title ?? nestedTitle ?? program.title) || copyParam("home.programFallbackName", "Program");
778
+ const image = programImage(program);
779
+ // Progress may be absent (a `fields` the read did not ask for, or a program with no steps): the
780
+ // bar then sits at 0 and the label comes from `progressStatus`, never from NaN arithmetic.
781
+ const available = finiteOr(participant?.progress?.totalStepsAvailable, 0);
782
+ const completed = finiteOr(participant?.progress?.totalStepsCompleted, 0);
783
+ const percentage = finiteOr(participant?.progress?.completionPercentage, Number.NaN);
784
+ const hasProgress = available > 0 || Number.isFinite(percentage);
785
+ const rawFraction = available > 0 ? completed / available : Number.isFinite(percentage) ? percentage / 100 : 0;
786
+ const progressFraction = Math.max(0, Math.min(1, rawFraction));
787
+ let stateLabel: string;
788
+ if (participant) {
789
+ const enrollmentStatus = (participant.enrollmentStatus ?? "").toUpperCase();
790
+ const progressStatus = (participant.progressStatus ?? "").toUpperCase();
791
+ stateLabel = enrollmentStatus === "SUSPENDED"
792
+ ? copyParam("home.memberProgramSuspended", "Access paused")
793
+ : progressStatus === "COMPLETED" || enrollmentStatus === "COMPLETED"
794
+ ? copyParam("home.memberProgramCompleted", "Completed")
795
+ : progressStatus === "FAILED"
796
+ ? copyParam("home.memberProgramFailed", "Failed")
797
+ : progressStatus === "IN_PROGRESS" || (progressStatus !== "NOT_STARTED" && progressFraction > 0)
798
+ ? copyParam("home.memberProgramInProgress", "In progress")
799
+ : copyParam("home.memberProgramNotStarted", "Not started");
800
+ } else {
801
+ const status = (application?.status ?? "").toUpperCase();
802
+ stateLabel = status === "INVITED"
803
+ ? copyParam("home.memberProgramInvited", "Invitation")
804
+ : status === "APPROVED"
805
+ ? copyParam("home.memberProgramApproved", "Approved")
806
+ : status === "SUSPENDED"
807
+ ? copyParam("home.memberProgramSuspended", "Access paused")
808
+ : copyParam("home.memberProgramPending", "Request pending");
809
+ }
810
+ return [{
811
+ id: program.id,
812
+ name,
813
+ description: "",
814
+ image,
815
+ initial: initials(name),
816
+ hasImage: !!image,
817
+ noImage: !image,
818
+ stateLabel,
819
+ progressFraction,
820
+ hideProgress: !hasProgress || !participant || (participant.enrollmentStatus ?? "").toUpperCase() === "SUSPENDED",
821
+ }];
822
+ });
823
+ } catch (error) {
824
+ // The member rail is optional; never let a member-state refusal blank public Home.
825
+ const status = (error as { status?: unknown } | null)?.status ?? /\bHTTP (\d{3})\b/.exec(String(error))?.[1];
826
+ console.warn("[home.member-programs] member state unavailable", status !== undefined ? `HTTP ${String(status)}` : (error as { name?: string } | null)?.name ?? "unknown");
696
827
  return [];
697
828
  }
698
829
  }
@@ -747,7 +878,7 @@ function groupCard(group: WixGroup): GroupCard {
747
878
  };
748
879
  }
749
880
 
750
- async function fetchExtrasSignal(arg: unknown): Promise<ExtrasSignal> {
881
+ async function fetchExtrasSignal(arg: unknown, generation: number): Promise<ExtrasSignal> {
751
882
  const verticals = parseVerticals(arg);
752
883
  const extras = emptyExtrasSignal();
753
884
  const jobs: Promise<void>[] = [];
@@ -758,7 +889,12 @@ async function fetchExtrasSignal(arg: unknown): Promise<ExtrasSignal> {
758
889
  }));
759
890
  }
760
891
  if (verticals.includes("programs")) {
761
- jobs.push(fetchHomePrograms().then((cards) => { extras.homePrograms = cards; }));
892
+ jobs.push(fetchHomePrograms().then(({ cards, programs }) => {
893
+ extras.homePrograms = cards;
894
+ // An older refresh can finish this query after a newer one. Keep its
895
+ // candidates from replacing the current generation's member-read input.
896
+ if (generation === refreshGen) homeProgramCandidates = { generation, programs };
897
+ }));
762
898
  }
763
899
  if (verticals.includes("videos") && !videoSurfaceRefused) {
764
900
  const caption = videoCaptionOf(paramValue(arg, "videoCaption"));
@@ -883,6 +1019,7 @@ function derive(state: State): State {
883
1019
  noUpcomingEvents: state.upcomingEvents.length === 0,
884
1020
  noNextEvent: state.nextEventCards.length === 0,
885
1021
  noHomePrograms: state.homePrograms.length === 0,
1022
+ noMemberPrograms: state.memberPrograms.length === 0,
886
1023
  noHomeVideos: state.homeVideos.length === 0,
887
1024
  noFeedHighlights: state.feedHighlights.length === 0,
888
1025
  noMemberAvatars: state.memberAvatars.length === 0,
@@ -977,6 +1114,8 @@ function baseState(): State {
977
1114
  noNextEvent: true,
978
1115
  homePrograms: [],
979
1116
  noHomePrograms: true,
1117
+ memberPrograms: [],
1118
+ noMemberPrograms: true,
980
1119
  homeVideos: [],
981
1120
  noHomeVideos: true,
982
1121
  feedHighlights: [],
@@ -1026,7 +1165,7 @@ async function refreshPublic(state: State, arg?: unknown): Promise<State | undef
1026
1165
  // failure just collapses their blocks), so a store outage cannot blank them
1027
1166
  // and vice versa. paramValue() stashes the appear params on first read, so the
1028
1167
  // arg-less fallback below still resolves the stashed verticals.
1029
- const [bookings, extras, saved] = await Promise.all([fetchBookingsSignal(arg), fetchExtrasSignal(arg), fetchSavedSignal(arg)]);
1168
+ const [bookings, extras, saved] = await Promise.all([fetchBookingsSignal(arg), fetchExtrasSignal(arg, gen), fetchSavedSignal(arg)]);
1030
1169
  if (gen !== refreshGen) return undefined;
1031
1170
  // A screen that declares no "store" vertical renders no products rail, so there is
1032
1171
  // nothing to fetch and nothing that could be "not loaded" — skip the call outright
@@ -1186,8 +1325,17 @@ async function refresh(state: State, arg?: unknown): Promise<State | undefined>
1186
1325
  void refreshPersonal(generation, arg);
1187
1326
  const publicState = await refreshPublic(state, arg);
1188
1327
  if (!publicState || generation !== personalGeneration) return undefined;
1328
+ // The member-only read runs after public Home has landed. It is deliberately not awaited:
1329
+ // a slow member endpoint must not hold the public catalog or hero behind authentication.
1330
+ const programCandidates = homeProgramCandidates;
1331
+ if (programCandidates.generation === refreshGen && parseVerticals(arg).includes("programs")) {
1332
+ void fetchMemberProgramCards(programCandidates.programs).then((rows) => {
1333
+ void svc.memberProgramsLoaded({ generation: programCandidates.generation, rows });
1334
+ });
1335
+ }
1189
1336
  const current = svc.getState();
1190
- return derive({ ...publicState, nextBooking: current.nextBooking, hideNextBooking: current.hideNextBooking,
1337
+ return derive({ ...publicState, memberPrograms: current.memberPrograms, noMemberPrograms: current.noMemberPrograms,
1338
+ nextBooking: current.nextBooking, hideNextBooking: current.hideNextBooking,
1191
1339
  memberProgressLabel: current.memberProgressLabel, memberProgressFraction: current.memberProgressFraction,
1192
1340
  hideMemberProgress: current.hideMemberProgress, personalError: current.personalError, hidePersonalError: current.hidePersonalError,
1193
1341
  // The weekly goal is PERSONAL (member bookings); the public refresh resets it, so keep it.
@@ -1214,6 +1362,7 @@ const svc = defineService<State, {
1214
1362
  refresh: (state: State, arg?: unknown) => Promise<State | undefined>;
1215
1363
  dismissOnboarding: (state: State) => State;
1216
1364
  clearPersonal: (state: State) => State;
1365
+ memberProgramsLoaded: (state: State, arg: { generation: number; rows: MemberProgramCard[]; attempt?: number }) => State | undefined;
1217
1366
  openShopCategory: (state: State, arg?: unknown) => State;
1218
1367
  personalLoaded: (state: State, arg: { generation: number; rows: MemberBookingRow[]; progress: { label: string; fraction: number }; error: boolean; weekly: { count: number; fraction: number; label: string } | null }) => State;
1219
1368
  categoriesLoaded: (state: State, arg: { generation: number; categories: StoreCategoryCard[] }) => State | undefined;
@@ -1221,10 +1370,27 @@ const svc = defineService<State, {
1221
1370
  state: baseState(),
1222
1371
  // The host's site is read fresh at every boot: a snapshot of the last session's site must not
1223
1372
  // decide this one's verticals or name (an owner installs or removes one; another site opens).
1224
- notHydrated: ["hosted", "hostedName", "hostedCards", "homeCategories", "noHomeCategories"],
1373
+ notHydrated: ["hosted", "hostedName", "hostedCards", "homeCategories", "noHomeCategories", "memberPrograms", "noMemberPrograms"],
1374
+ // A member's standing never reaches the on-device snapshot either: the next boot may be another member's.
1375
+ notPersisted: ["memberPrograms", "noMemberPrograms"],
1225
1376
  actions: {
1226
- clearPersonal: state => derive({ ...state, nextBooking: [], hideNextBooking: true, memberProgressLabel: "", memberProgressFraction: 0, hideMemberProgress: true, personalError: false, hidePersonalError: true,
1377
+ clearPersonal: state => derive({ ...state, nextBooking: [], hideNextBooking: true, memberProgressLabel: "", memberProgressFraction: 0, hideMemberProgress: true, memberPrograms: [], noMemberPrograms: true, personalError: false, hidePersonalError: true,
1227
1378
  weeklyClassCount: 0, weeklyClassGoalFraction: 0, weeklyGoalLabel: "" }),
1379
+ // The member read starts inside `refresh` and, for a visitor (identity answers synchronously),
1380
+ // resolves within the same microtask turn — BEFORE the runtime has applied refresh's own result.
1381
+ // The `state` handed here is then refresh's PRE-state (status "loading", every rail empty), and
1382
+ // spreading it wrote a loading home over the ready one; the description-projection test caught
1383
+ // exactly that. So an early arrival re-queues itself (a microtask at a time, bounded) until the
1384
+ // state it would spread is the applied one. A stale generation keeps the current state
1385
+ // (`undefined`), never its own stale snapshot.
1386
+ memberProgramsLoaded: (state, arg) => {
1387
+ if (arg.generation !== refreshGen) return undefined;
1388
+ if (state.status === "loading" && (arg.attempt ?? 0) < MEMBER_PROGRAMS_APPLY_RETRIES) {
1389
+ void Promise.resolve().then(() => svc.memberProgramsLoaded({ ...arg, attempt: (arg.attempt ?? 0) + 1 }));
1390
+ return undefined;
1391
+ }
1392
+ return derive({ ...state, memberPrograms: arg.rows, noMemberPrograms: arg.rows.length === 0 });
1393
+ },
1228
1394
  openShopCategory: (state, arg) => {
1229
1395
  const category = String((arg as { category?: unknown } | undefined)?.category ?? "");
1230
1396
  if (!category) return state;
@@ -2973,6 +2973,198 @@ const SCREENS = runtimeSetting({
2973
2973
  "hiddenPath": "$service:himiBrandedHome.noHomeCategories"
2974
2974
  }
2975
2975
  },
2976
+ {
2977
+ "id": "himi_branded_home.member_programs_section",
2978
+ "body": {
2979
+ "package": "himalaya",
2980
+ "type": "VStack",
2981
+ "props": {
2982
+ "spacing": 10,
2983
+ "alignment": "leading",
2984
+ "children": [
2985
+ {
2986
+ "id": "",
2987
+ "body": {
2988
+ "package": "himalaya",
2989
+ "type": "VStack",
2990
+ "props": {
2991
+ "spacing": 3,
2992
+ "alignment": "leading",
2993
+ "children": [
2994
+ {
2995
+ "id": "",
2996
+ "body": {
2997
+ "package": "himalaya",
2998
+ "type": "Text",
2999
+ "props": {
3000
+ "text": "Your programs",
3001
+ "style": "title3"
3002
+ }
3003
+ }
3004
+ }
3005
+ ]
3006
+ }
3007
+ }
3008
+ },
3009
+ {
3010
+ "id": "himi_branded_home.member_programs",
3011
+ "body": {
3012
+ "package": "himalaya",
3013
+ "type": "Carousel",
3014
+ "props": {
3015
+ "itemsPath": "$service:himiBrandedHome.memberPrograms",
3016
+ "items": [
3017
+ {
3018
+ "id": "",
3019
+ "body": {
3020
+ "package": "himalaya",
3021
+ "type": "VStack",
3022
+ "props": {
3023
+ "spacing": 8,
3024
+ "alignment": "leading",
3025
+ "children": [
3026
+ {
3027
+ "id": "",
3028
+ "body": {
3029
+ "package": "himalaya",
3030
+ "type": "Image",
3031
+ "props": {
3032
+ "url": "$item.image",
3033
+ "fillWidth": true,
3034
+ "height": 108,
3035
+ "contentMode": "fill",
3036
+ "contentDescription": "$item.name"
3037
+ }
3038
+ },
3039
+ "modifiers": {
3040
+ "cornerRadius": 8,
3041
+ "fillMaxWidth": true,
3042
+ "hiddenPath": "$item.noImage"
3043
+ }
3044
+ },
3045
+ {
3046
+ "id": "himi_branded_home.member_program.initial",
3047
+ "body": {
3048
+ "package": "himalaya",
3049
+ "type": "ZStack",
3050
+ "props": {
3051
+ "alignment": "center",
3052
+ "children": [
3053
+ {
3054
+ "id": "",
3055
+ "body": {
3056
+ "package": "himalaya",
3057
+ "type": "Icon",
3058
+ "props": {
3059
+ "name": "photo",
3060
+ "size": 28,
3061
+ "tint": "accentPrimary"
3062
+ }
3063
+ },
3064
+ "modifiers": {
3065
+ "accessibilityRole": "decorative"
3066
+ }
3067
+ }
3068
+ ]
3069
+ }
3070
+ },
3071
+ "modifiers": {
3072
+ "width": 108,
3073
+ "height": 108,
3074
+ "background": {
3075
+ "token": "accentSurface"
3076
+ },
3077
+ "cornerRadius": 16,
3078
+ "hiddenPath": "$item.hasImage"
3079
+ }
3080
+ },
3081
+ {
3082
+ "id": "",
3083
+ "body": {
3084
+ "package": "himalaya",
3085
+ "type": "Text",
3086
+ "props": {
3087
+ "text": "$item.name",
3088
+ "style": "bodyEmphasis",
3089
+ "maxLines": 2
3090
+ }
3091
+ }
3092
+ },
3093
+ {
3094
+ "id": "",
3095
+ "body": {
3096
+ "package": "himalaya",
3097
+ "type": "Text",
3098
+ "props": {
3099
+ "text": "$item.stateLabel",
3100
+ "style": "footnote",
3101
+ "color": "textSecondary",
3102
+ "maxLines": 1
3103
+ }
3104
+ }
3105
+ },
3106
+ {
3107
+ "id": "",
3108
+ "body": {
3109
+ "package": "himalaya",
3110
+ "type": "ProgressBar",
3111
+ "props": {
3112
+ "progress": 0,
3113
+ "progressPath": "$item.progressFraction",
3114
+ "tint": "accentPrimary",
3115
+ "trackColor": "surfaceTertiary"
3116
+ }
3117
+ },
3118
+ "modifiers": {
3119
+ "accessibilityLabel": "$item.name",
3120
+ "accessibilityValue": "$item.stateLabel",
3121
+ "hiddenPath": "$item.hideProgress"
3122
+ }
3123
+ }
3124
+ ]
3125
+ }
3126
+ },
3127
+ "modifiers": {
3128
+ "background": {
3129
+ "token": "surfaceElevated"
3130
+ },
3131
+ "border": {
3132
+ "width": 1,
3133
+ "color": {
3134
+ "token": "border"
3135
+ }
3136
+ },
3137
+ "cornerRadius": 8,
3138
+ "padding": {
3139
+ "leading": 10,
3140
+ "trailing": 10,
3141
+ "top": 10,
3142
+ "bottom": 10
3143
+ },
3144
+ "width": 200,
3145
+ "onTap": {
3146
+ "actionId": "himi.open",
3147
+ "params": {
3148
+ "screenId": "himi_program",
3149
+ "id": "$item.id"
3150
+ }
3151
+ },
3152
+ "pressFeedback": "scale",
3153
+ "haptic": "light",
3154
+ "accessibilityLabel": "$item.name"
3155
+ }
3156
+ }
3157
+ ]
3158
+ }
3159
+ }
3160
+ }
3161
+ ]
3162
+ }
3163
+ },
3164
+ "modifiers": {
3165
+ "hiddenPath": "$service:himiBrandedHome.noMemberPrograms"
3166
+ }
3167
+ },
2976
3168
  {
2977
3169
  "id": "himi_branded_home.videos_section",
2978
3170
  "body": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$source": "en",
3
- "$generated": "2026-11-07T23:50:41.996Z",
3
+ "$generated": "2026-11-08T10:51:06.119Z",
4
4
  "messages": {
5
5
  "h_042c862e4467": {
6
6
  "source": "Try again",