@wix/himalaya-cli 0.1750.0 → 0.1751.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 (170) hide show
  1. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/dev-server/src/builder.d.ts +3 -0
  2. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/himi-package.d.ts +478 -0
  3. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/host-compatibility.d.ts +56 -0
  4. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/icon-catalog.generated.d.ts +1 -1
  5. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/schema.d.ts +4 -0
  6. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/site-shell.d.ts +154 -7
  7. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/validator.d.ts +3 -0
  8. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/flows/screens/src/index.d.ts +2 -0
  9. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/flows/screens/src/podcast-service.d.ts +105 -0
  10. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/flows/screens/src/podcast.d.ts +116 -0
  11. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/core.mjs +326 -13
  12. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/screens.mjs +730 -81
  13. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/sdui.mjs +155 -0
  14. package/dist/browser-plane/assets.json +5 -5
  15. package/dist/browser-plane/preview-deferred/{b40ea5d0d6251898ff5617139fde8be008dd11e99a70b14c1052093685401700.bin → 21f35a12bd94f4ab97a9a75453c4adcadc438daf024a4b1950d5c356c123bd01.bin} +1 -1
  16. package/dist/browser-plane/sw.js +7 -7
  17. package/dist/cli.mjs +34995 -31326
  18. package/dist/preview-assets.generated.bin +0 -0
  19. package/guides/component-reference.json +1 -1
  20. package/guides/component-reference.md +4 -0
  21. package/guides/designing-himi-screens.md +7 -0
  22. package/guides/getting-started.md +2 -0
  23. package/guides/headless-loop.md +1 -1
  24. package/guides/himi-skill.md +2 -0
  25. package/guides/index.json +6 -0
  26. package/guides/qa-builds.md +12 -1
  27. package/guides/recipe-podcast.md +149 -0
  28. package/guides/tier-5-add-a-screen.md +16 -2
  29. package/guides/wix-business-context.md +29 -0
  30. package/guides/wix-platform-usage.md +7 -2
  31. package/package.json +10 -10
  32. package/template-icons/fitness-gym.png +0 -0
  33. package/templates/beauty-salon/dev/index.ts +1 -1
  34. package/templates/beauty-salon/l10n/en.json +1 -1
  35. package/templates/beauty-salon/tier5-src/_shared/program-fields.ts +16 -0
  36. package/templates/beauty-salon/tier5-src/_shared/programs-section.ts +5 -8
  37. package/templates/beauty-salon/tier5-src/himi-branded-lite-agenda/index.ts +37 -4
  38. package/templates/branded-lite/dev/index.ts +101 -1
  39. package/templates/branded-lite/l10n/en.json +22 -1
  40. package/templates/branded-lite/l10n/es.json +22 -0
  41. package/templates/branded-lite/l10n/fr.json +18 -0
  42. package/templates/branded-lite/l10n/he.json +15 -0
  43. package/templates/branded-lite/tier5-src/_shared/program-fields.ts +16 -0
  44. package/templates/branded-lite/tier5-src/_shared/programs-section.ts +5 -8
  45. package/templates/branded-lite/tier5-src/himi-branded-lite-agenda/index.ts +37 -4
  46. package/templates/branded-lite/tier5-src/himi-branded-lite-podcasts/index.ts +14 -234
  47. package/templates/brandy/README.md +33 -0
  48. package/templates/brandy/config.ts +51 -7
  49. package/templates/brandy/dev/index.ts +23 -9
  50. package/templates/community-club/l10n/en.json +1 -1
  51. package/templates/community-club/tier5-src/_shared/program-fields.ts +16 -0
  52. package/templates/community-club/tier5-src/_shared/programs-section.ts +5 -8
  53. package/templates/events-meetups/l10n/en.json +1 -1
  54. package/templates/events-meetups/tier5-src/_shared/program-fields.ts +16 -0
  55. package/templates/events-meetups/tier5-src/_shared/programs-section.ts +5 -8
  56. package/templates/fitness-gym/README.md +53 -0
  57. package/templates/fitness-gym/config.ts +560 -0
  58. package/templates/fitness-gym/dev/index.ts +25787 -0
  59. package/templates/fitness-gym/himalaya.content.json +64 -0
  60. package/templates/fitness-gym/himalaya.template.json +15 -0
  61. package/templates/fitness-gym/icon.png +0 -0
  62. package/templates/fitness-gym/platforms.json +1 -0
  63. package/templates/fitness-gym/tier5-src/_shared/app-locale.ts +61 -0
  64. package/templates/fitness-gym/tier5-src/_shared/booking-location.ts +147 -0
  65. package/templates/fitness-gym/tier5-src/_shared/booking-session.ts +224 -0
  66. package/templates/fitness-gym/tier5-src/_shared/branded-lite-hosted.ts +280 -0
  67. package/templates/fitness-gym/tier5-src/_shared/branded-load-state.ts +109 -0
  68. package/templates/fitness-gym/tier5-src/_shared/business-chat-copy.ts +40 -0
  69. package/templates/fitness-gym/tier5-src/_shared/business-chat-history.ts +51 -0
  70. package/templates/fitness-gym/tier5-src/_shared/business-chat-message-model.ts +177 -0
  71. package/templates/fitness-gym/tier5-src/_shared/business-chat-model.ts +56 -0
  72. package/templates/fitness-gym/tier5-src/_shared/business-chat-presenter.ts +576 -0
  73. package/templates/fitness-gym/tier5-src/_shared/business-chat-transport.ts +148 -0
  74. package/templates/fitness-gym/tier5-src/_shared/collection-contract.ts +228 -0
  75. package/templates/fitness-gym/tier5-src/_shared/collection-query.ts +193 -0
  76. package/templates/fitness-gym/tier5-src/_shared/collection-service.ts +400 -0
  77. package/templates/fitness-gym/tier5-src/_shared/detail-presence.ts +51 -0
  78. package/templates/fitness-gym/tier5-src/_shared/engine-intl.ts +523 -0
  79. package/templates/fitness-gym/tier5-src/_shared/himi-account.ts +194 -0
  80. package/templates/fitness-gym/tier5-src/_shared/himi-booking-saved.ts +88 -0
  81. package/templates/fitness-gym/tier5-src/_shared/himi-bookings.ts +318 -0
  82. package/templates/fitness-gym/tier5-src/_shared/himi-copy.ts +116 -0
  83. package/templates/fitness-gym/tier5-src/_shared/himi-media.ts +29 -0
  84. package/templates/fitness-gym/tier5-src/_shared/himi-store.ts +7 -0
  85. package/templates/fitness-gym/tier5-src/_shared/himi-text.ts +24 -0
  86. package/templates/fitness-gym/tier5-src/_shared/host-events.ts +66 -0
  87. package/templates/fitness-gym/tier5-src/_shared/hosted-checkout.ts +70 -0
  88. package/templates/fitness-gym/tier5-src/_shared/iap-attendance-form.ts +106 -0
  89. package/templates/fitness-gym/tier5-src/_shared/iap-attendance-purchase.ts +216 -0
  90. package/templates/fitness-gym/tier5-src/_shared/iap-attendance.ts +38 -0
  91. package/templates/fitness-gym/tier5-src/_shared/iap-worker.ts +127 -0
  92. package/templates/fitness-gym/tier5-src/_shared/inbox-rooms.ts +68 -0
  93. package/templates/fitness-gym/tier5-src/_shared/local-preferences.ts +38 -0
  94. package/templates/fitness-gym/tier5-src/_shared/member-access.ts +63 -0
  95. package/templates/fitness-gym/tier5-src/_shared/member-account-routes.ts +52 -0
  96. package/templates/fitness-gym/tier5-src/_shared/member-bookings.ts +107 -0
  97. package/templates/fitness-gym/tier5-src/_shared/member-screen.ts +99 -0
  98. package/templates/fitness-gym/tier5-src/_shared/notification-target.ts +141 -0
  99. package/templates/fitness-gym/tier5-src/_shared/offset-page.ts +10 -0
  100. package/templates/fitness-gym/tier5-src/_shared/online-actions.ts +76 -0
  101. package/templates/fitness-gym/tier5-src/_shared/owner-load-error.ts +348 -0
  102. package/templates/fitness-gym/tier5-src/_shared/payment-setup.ts +6 -0
  103. package/templates/fitness-gym/tier5-src/_shared/pricing-plan-display.ts +64 -0
  104. package/templates/fitness-gym/tier5-src/_shared/program-description.ts +11 -0
  105. package/templates/fitness-gym/tier5-src/_shared/program-fields.ts +16 -0
  106. package/templates/fitness-gym/tier5-src/_shared/program-standing.ts +46 -0
  107. package/templates/fitness-gym/tier5-src/_shared/rich-body.ts +78 -0
  108. package/templates/fitness-gym/tier5-src/_shared/rich-content-link.ts +34 -0
  109. package/templates/fitness-gym/tier5-src/_shared/sign-in-sheet.ts +18 -0
  110. package/templates/fitness-gym/tier5-src/_shared/staff-name.ts +18 -0
  111. package/templates/fitness-gym/tier5-src/_shared/weekly-goal.ts +107 -0
  112. package/templates/fitness-gym/tier5-src/_shared/wix-bi.ts +85 -0
  113. package/templates/fitness-gym/tier5-src/_shared/wix-member-links.ts +114 -0
  114. package/templates/fitness-gym/tier5-src/_shared/wix-service-price.ts +146 -0
  115. package/templates/fitness-gym/tier5-src/business-chat/index.ts +732 -0
  116. package/templates/fitness-gym/tier5-src/business-contact/index.ts +6 -0
  117. package/templates/fitness-gym/tier5-src/himi-booking-account/index.ts +267 -0
  118. package/templates/fitness-gym/tier5-src/himi-booking-bookings/index.ts +468 -0
  119. package/templates/fitness-gym/tier5-src/himi-booking-service/index.ts +1190 -0
  120. package/templates/fitness-gym/tier5-src/himi-booking-services/index.ts +791 -0
  121. package/templates/fitness-gym/tier5-src/himi-booking-time/index.ts +1729 -0
  122. package/templates/fitness-gym/tier5-src/himi-branded-lite-agenda/index.ts +988 -0
  123. package/templates/fitness-gym/tier5-src/himi-branded-lite-member-programs/index.ts +656 -0
  124. package/templates/fitness-gym/tier5-src/himi-branded-lite-notifications/index.ts +256 -0
  125. package/templates/fitness-gym/tier5-src/himi-branded-lite-plans/index.ts +495 -0
  126. package/templates/fitness-gym/tier5-src/himi-branded-lite-program/facts.ts +52 -0
  127. package/templates/fitness-gym/tier5-src/himi-branded-lite-program/index.ts +845 -0
  128. package/templates/fitness-gym/tier5-src/himi-fitcoach-goal/index.ts +191 -0
  129. package/templates/fitness-gym/tier5-src/himi-fitcoach-home/index.ts +619 -0
  130. package/templates/fitness-gym/tier5-src/himi-store-account/index.ts +1007 -0
  131. package/templates/fitness-gym/tier5-src/wix-spaces-my-subscriptions/index.ts +84 -0
  132. package/templates/fitness-gym/tier5-src/wix-spaces-subscription-detail/index.ts +139 -0
  133. package/templates/fitness-gym/tokens.json +414 -0
  134. package/templates/gym-fitness/dev/index.ts +1 -1
  135. package/templates/gym-fitness/l10n/en.json +1 -1
  136. package/templates/gym-fitness/tier5-src/_shared/program-fields.ts +16 -0
  137. package/templates/gym-fitness/tier5-src/_shared/programs-section.ts +5 -8
  138. package/templates/gym-fitness/tier5-src/himi-branded-lite-agenda/index.ts +37 -4
  139. package/templates/medical-services/dev/index.ts +2 -1
  140. package/templates/medical-services/tier5-src/himi-booking-account/index.ts +16 -1
  141. package/templates/nonprofit-cause/l10n/en.json +1 -1
  142. package/templates/nonprofit-cause/tier5-src/_shared/program-fields.ts +16 -0
  143. package/templates/nonprofit-cause/tier5-src/_shared/programs-section.ts +5 -8
  144. package/templates/personal-fitness-trainer/dev/index.ts +2 -2
  145. package/templates/personal-fitness-trainer/tier5-src/himi-branded-lite-agenda/index.ts +37 -4
  146. package/templates/podcast-creator/dev/index.ts +100 -0
  147. package/templates/podcast-creator/l10n/en.json +22 -1
  148. package/templates/podcast-creator/l10n/es.json +22 -0
  149. package/templates/podcast-creator/l10n/fr.json +18 -0
  150. package/templates/podcast-creator/l10n/he.json +15 -0
  151. package/templates/podcast-creator/tier5-src/_shared/program-fields.ts +16 -0
  152. package/templates/podcast-creator/tier5-src/_shared/programs-section.ts +5 -8
  153. package/templates/podcast-creator/tier5-src/himi-branded-lite-podcasts/index.ts +14 -234
  154. package/templates/portfolio-creative/l10n/en.json +1 -1
  155. package/templates/portfolio-creative/tier5-src/_shared/program-fields.ts +16 -0
  156. package/templates/portfolio-creative/tier5-src/_shared/programs-section.ts +5 -8
  157. package/templates/restaurant/l10n/en.json +1 -1
  158. package/templates/restaurant/tier5-src/_shared/program-fields.ts +16 -0
  159. package/templates/restaurant/tier5-src/_shared/programs-section.ts +5 -8
  160. package/templates/retail-store/l10n/en.json +1 -1
  161. package/templates/retail-store/tier5-src/_shared/program-fields.ts +16 -0
  162. package/templates/retail-store/tier5-src/_shared/programs-section.ts +5 -8
  163. package/templates/salon-spa/dev/index.ts +1 -1
  164. package/templates/salon-spa/tier5-src/himi-booking-account/index.ts +16 -1
  165. package/templates/salon-spa/tier5-src/himi-branded-lite-agenda/index.ts +37 -4
  166. package/templates/yoga-studio/dev/index.ts +1 -1
  167. package/templates/yoga-studio/l10n/en.json +1 -1
  168. package/templates/yoga-studio/tier5-src/_shared/program-fields.ts +16 -0
  169. package/templates/yoga-studio/tier5-src/_shared/programs-section.ts +5 -8
  170. package/templates/yoga-studio/tier5-src/himi-branded-lite-agenda/index.ts +37 -4
@@ -0,0 +1,16 @@
1
+ // How a worker reads an Online Program's lifecycle and name. Wix returns them in more than one
2
+ // shape (v3 `status` or `state`; `description.title`, `settings.title`, a flat `title` or
3
+ // `details.title`), so every screen that lists programs reads them here, the same way.
4
+ import type { WixProgram } from "@himalaya/wix-online-programs";
5
+ import { cleanTitle } from "./himi-text.js";
6
+
7
+ export function programStatus(p: WixProgram): string {
8
+ return (p.status ?? p.state ?? "").toUpperCase();
9
+ }
10
+ export const isProgramEnded = (p: WixProgram): boolean => programStatus(p) === "ENDED" || programStatus(p) === "FINISHED";
11
+ export const isProgramDraft = (p: WixProgram): boolean => programStatus(p) === "DRAFT";
12
+
13
+ /** The program's own name, cleaned; "" when it has none (the caller picks its own fallback word). */
14
+ export function programName(p: WixProgram): string {
15
+ return cleanTitle(p.description?.title ?? p.settings?.title ?? p.title ?? p.details?.title);
16
+ }
@@ -22,7 +22,8 @@ import { iapPriceFields, onlineProgramItem, type IapPollDirective } from "@himal
22
22
  import { createIapCommerce } from "@himalaya/iap-checkout";
23
23
  import { createCollectionQuery, type CollectionPage, type CollectionQueryState } from "./collection-query.js";
24
24
  import { memberAccess, memberAccessChanged, memberAccessDenied, type MemberAccess } from "./member-access.js";
25
- import { cleanTitle, initials } from "./himi-text.js";
25
+ import { initials } from "./himi-text.js";
26
+ import { isProgramDraft, isProgramEnded, programName } from "./program-fields.js";
26
27
  import { programImage } from "./himi-media.js";
27
28
  import { descriptionBody } from "./rich-body.js";
28
29
  import { programDescription } from "./program-description.js";
@@ -125,19 +126,15 @@ export interface State {
125
126
  const full = (p: WixProgram): WixProgramFull => p as WixProgramFull;
126
127
 
127
128
  function programTitle(p: WixProgram): string {
128
- return cleanTitle(p.description?.title ?? p.settings?.title ?? p.title ?? p.details?.title)
129
- || copyParam("memberPrograms.programFallbackName", "Program");
129
+ return programName(p) || copyParam("memberPrograms.programFallbackName", "Program");
130
130
  }
131
131
  function programDetails(p: WixProgram): string {
132
132
  // The body may be a Ricos document or serialized text: read it the way the catalog and detail do.
133
133
  const raw = descriptionBody(programDescription(p)).bodyText.replace(/\s+/g, " ").trim();
134
134
  return raw.length > 140 ? `${raw.slice(0, 139).trimEnd()}…` : raw;
135
135
  }
136
- function programStatus(p: WixProgram): string {
137
- return (p.status ?? p.state ?? "").toUpperCase();
138
- }
139
- const isEnded = (p: WixProgram) => programStatus(p) === "ENDED" || programStatus(p) === "FINISHED";
140
- const isDraft = (p: WixProgram) => programStatus(p) === "DRAFT";
136
+ const isEnded = isProgramEnded;
137
+ const isDraft = isProgramDraft;
141
138
  function accessType(p: WixProgram): string {
142
139
  return (full(p).restrictions?.accessType ?? "PUBLIC").toUpperCase();
143
140
  }
@@ -1,246 +1,26 @@
1
- import { descriptionBody } from "../_shared/rich-body.js";
2
- // himi-branded-lite-podcasts — live RSS episodes with a persistent queue and
3
- // the shared native/web media playback transport.
1
+ // himi-branded-lite-podcasts — live RSS episodes played in the app. The loader and the player
2
+ // are the shared `createPodcastService` (`@wix/himalaya/screens`), the same code a generated app
3
+ // imports; this worker only adds Branded Lite's collection chrome and per-account persistence.
4
+ import { createPodcastService } from "@himalaya/screens";
4
5
  import { defineService } from "../_shared/collection-service.js";
6
+ import { copyParam } from "../_shared/himi-copy.js";
7
+ import { descriptionBody } from "../_shared/rich-body.js";
5
8
  import { localPreferences, type PreferenceRuntime } from "../_shared/local-preferences.js";
6
- import { pause, play, setQueue, skip, status as playbackStatus, subscribeStatus, type MediaPlaybackStatus, type MediaQueueItem } from "@himalaya/media-playback";
7
-
8
- const PODCASTS_FEED_GRAPHQL = "https://podcasts.wix.com/api/feed/graphql";
9
- const EPISODES_QUERY = `
10
- query PodcastEpisodes($url: String!, $limit: Int) {
11
- episodes(url: $url, limit: $limit) {
12
- id title date duration image descriptionExcerpt(length: 220) playback { url type length }
13
- }
14
- }
15
- `;
16
-
17
- type WixApi = { call: (method: string, path: string, body?: unknown, headers?: Record<string, string>) => Promise<unknown> };
18
- interface Episode {
19
- id?: string;
20
- title?: string;
21
- date?: string;
22
- duration?: string;
23
- image?: string;
24
- descriptionExcerpt?: string;
25
- playback?: { url?: string; type?: string; length?: number };
26
- }
27
- interface FeedResponse {
28
- data?: { episodes?: Episode[] | null } | null;
29
- episodes?: Episode[] | null;
30
- errors?: Array<{ message?: string }>;
31
- }
32
- interface Row {
33
- id: string;
34
- title: string;
35
- subtitle: string;
36
- image: string;
37
- description: string;
38
- audioUrl: string;
39
- durationMs: number;
40
- progressLabel: string;
41
- }
42
- interface S {
43
- status: "loading" | "ready" | "error";
44
- episodes: Row[];
45
- emptyText: string;
46
- isMock: boolean;
47
- notMock: boolean;
48
- mockBanner: string;
49
- queue: string[];
50
- queueLabel: string;
51
- nowId: string;
52
- nowTitle: string;
53
- nowSubtitle: string;
54
- isPlaying: boolean;
55
- playLabel: string;
56
- playIcon: string;
57
- positionMs: number;
58
- durationMs: number;
59
- progress: number;
60
- progressLabel: string;
61
- hidePlayer: boolean;
62
- }
63
9
 
64
- function host(): PreferenceRuntime & { wixApi?: WixApi } {
65
- return (globalThis as { himalaya?: PreferenceRuntime & { wixApi?: WixApi } }).himalaya ?? {};
10
+ function host(): PreferenceRuntime {
11
+ return (globalThis as { himalaya?: PreferenceRuntime }).himalaya ?? {};
66
12
  }
67
- const queuePreference = localPreferences("podcast.queue", (value): string[] => Array.isArray(value)
13
+ const queue = localPreferences("podcast.queue", (value): string[] => Array.isArray(value)
68
14
  ? [...new Set(value.filter((id): id is string => typeof id === "string" && id.length > 0 && id.length <= 512))].slice(0, 100)
69
15
  : [], host());
70
- const progressPreference = localPreferences("podcast.progress", (value): Record<string, number> => {
16
+ const progress = localPreferences("podcast.progress", (value): Record<string, number> => {
71
17
  if (!value || typeof value !== "object" || Array.isArray(value)) return {};
72
18
  return Object.fromEntries(Object.entries(value).filter(([id, position]) => id.length > 0 && id.length <= 512 && typeof position === "number" && Number.isFinite(position) && position >= 1_000));
73
19
  }, host());
74
- let savedQueue = queuePreference.read();
75
- let savedProgress = progressPreference.read();
76
- function persistQueue(value: string[]): void { savedQueue = value; queuePreference.write(value); }
77
- function persistProgress(value: Record<string, number>): void { savedProgress = value; progressPreference.write(value); }
78
- function dateLabel(iso?: string): string {
79
- const parsed = iso ? Date.parse(iso) : NaN;
80
- return Number.isFinite(parsed) ? new Date(parsed).toLocaleDateString(undefined, { month: "short", day: "numeric" }) : "";
81
- }
82
- function durationMs(value?: string): number {
83
- const raw = (value || "").trim();
84
- if (/^\d+$/.test(raw)) return Number(raw) * 1000;
85
- const pieces = raw.split(":").map(Number);
86
- if (pieces.length >= 2 && pieces.every(Number.isFinite)) return pieces.reduce((total, piece) => total * 60 + piece, 0) * 1000;
87
- return 0;
88
- }
89
- function clock(ms: number): string {
90
- const seconds = Math.max(0, Math.round(ms / 1000));
91
- const minutes = Math.floor(seconds / 60);
92
- return `${minutes}:${String(seconds % 60).padStart(2, "0")}`;
93
- }
94
- function norm(episode: Episode): Row | null {
95
- const audioUrl = episode.playback?.url?.trim() || "";
96
- if (!audioUrl) return null;
97
- const duration = durationMs(episode.duration);
98
- return {
99
- id: episode.id || audioUrl,
100
- title: (episode.title || "Episode").trim() || "Episode",
101
- subtitle: [dateLabel(episode.date), duration ? clock(duration) : ""].filter(Boolean).join(" · "),
102
- image: (episode.image || "").trim(),
103
- description: descriptionBody(episode.descriptionExcerpt).bodyText,
104
- audioUrl,
105
- durationMs: duration,
106
- progressLabel: "",
107
- };
108
- }
109
- function queueItems(rows: Row[], ids: string[]): MediaQueueItem[] {
110
- const byId = new Map(rows.map((row) => [row.id, row]));
111
- return ids.flatMap((id) => {
112
- const row = byId.get(id);
113
- return row ? [{ id: row.id, episodeId: row.id, url: row.audioUrl, title: row.title, subtitle: row.subtitle, artworkUrl: row.image, durationMs: row.durationMs }] : [];
114
- });
115
- }
116
- function derive(state: S): S {
117
- const now = state.episodes.find((episode) => episode.id === state.nowId);
118
- const duration = state.durationMs || now?.durationMs || 0;
119
- const episodes = state.episodes.map((episode) => {
120
- const position = savedProgress[episode.id] ?? 0;
121
- const resumable = position >= 1_000 && (!episode.durationMs || position < episode.durationMs - 1_000);
122
- return { ...episode, progressLabel: resumable ? `Continue at ${clock(position)}` : "" };
123
- });
124
- return {
125
- ...state,
126
- episodes,
127
- queueLabel: state.queue.length ? `${state.queue.length} ${state.queue.length === 1 ? "episode" : "episodes"} in queue` : "Queue is empty",
128
- nowTitle: now?.title ?? "",
129
- nowSubtitle: now?.subtitle ?? "",
130
- playLabel: state.isPlaying ? "Pause" : "Play",
131
- playIcon: state.isPlaying ? "pause" : "play",
132
- durationMs: duration,
133
- progress: duration > 0 ? Math.min(1, state.positionMs / duration) : 0,
134
- progressLabel: state.nowId ? `${clock(state.positionMs)} / ${clock(duration)}` : "",
135
- hidePlayer: !state.nowId,
136
- };
137
- }
138
- function idOf(arg: unknown): string {
139
- if (typeof arg === "string") return arg;
140
- return String((arg as { id?: unknown } | undefined)?.id ?? "");
141
- }
142
20
 
143
- const svc = defineService<S, {
144
- load: (s: S, arg?: unknown) => Promise<S>;
145
- playEpisode: (s: S, arg?: unknown) => S;
146
- queueEpisode: (s: S, arg?: unknown) => Promise<S>;
147
- togglePlay: (s: S) => S;
148
- nextEpisode: (s: S) => S;
149
- mediaStatus: (s: S, arg?: MediaPlaybackStatus) => Promise<S>;
150
- }>("himiBrandedPodcasts", {
151
- state: derive({ status: "loading", episodes: [], emptyText: "", isMock: false, notMock: true, mockBanner: "",
152
- queue: savedQueue, queueLabel: "Queue is empty", nowId: "", nowTitle: "", nowSubtitle: "",
153
- isPlaying: false, playLabel: "Play", playIcon: "play", positionMs: 0, durationMs: 0, progress: 0, progressLabel: "", hidePlayer: true }),
154
- actions: {
155
- load: async (s, arg) => {
156
- const configured = typeof (arg as { feedUrl?: unknown } | undefined)?.feedUrl === "string" ? String((arg as { feedUrl: string }).feedUrl).trim() : "";
157
- if (!configured) {
158
- return derive({ ...s, status: "ready", episodes: [], emptyText: "No episodes yet — check back soon.", isMock: false, notMock: true, mockBanner: "" });
159
- }
160
- try {
161
- const api = host().wixApi;
162
- if (!api) throw new Error("Podcast bridge unavailable");
163
- const response = await api.call("POST", PODCASTS_FEED_GRAPHQL, { query: EPISODES_QUERY, variables: { url: configured, limit: 40 } }) as FeedResponse;
164
- if (response.errors?.length) throw new Error(response.errors[0]?.message || "Podcast feed query failed");
165
- const raw = response.data?.episodes ?? response.episodes;
166
- if (!Array.isArray(raw)) throw new Error("Podcast feed returned no episode collection");
167
- const episodes = raw.map(norm).filter((episode): episode is Row => episode !== null);
168
- const persisted = savedQueue.filter((id) => episodes.some((episode) => episode.id === id));
169
- const queue = persisted.length ? persisted : [];
170
- persistQueue(queue);
171
- let snapshot = await playbackStatus().catch(() => undefined);
172
- if (!snapshot?.currentItem && queue.length) {
173
- snapshot = await setQueue(queueItems(episodes, queue), {
174
- startIndex: 0,
175
- startPositionMs: savedProgress[queue[0]!] ?? 0,
176
- autoplay: false,
177
- onStatus: "himiBrandedPodcasts.mediaStatus",
178
- }).catch(() => undefined);
179
- }
180
- return derive({ ...s, status: "ready", episodes, queue, nowId: snapshot?.currentItem?.episodeId ?? snapshot?.currentItem?.id ?? "",
181
- isPlaying: snapshot?.state === "playing", positionMs: snapshot?.positionMs ?? 0, durationMs: snapshot?.durationMs ?? 0,
182
- emptyText: episodes.length ? "" : "No playable episodes are available in this feed.", isMock: false, notMock: true, mockBanner: "" });
183
- } catch {
184
- return derive({ ...s, status: "error", episodes: [], emptyText: "Podcast episodes could not be loaded. Try again.", isMock: false, notMock: true, mockBanner: "" });
185
- }
186
- },
187
- playEpisode: (s, arg) => {
188
- const id = idOf(arg);
189
- const selected = s.episodes.find((episode) => episode.id === id);
190
- if (!selected) return s;
191
- const queue = [id, ...s.queue.filter((queued) => queued !== id)];
192
- persistQueue(queue);
193
- const position = savedProgress[id] ?? 0;
194
- void setQueue(queueItems(s.episodes, queue), { startIndex: 0, startPositionMs: position, autoplay: true, onStatus: "himiBrandedPodcasts.mediaStatus" })
195
- .then((snapshot) => svc.mediaStatus(snapshot)).catch(() => {});
196
- return derive({ ...s, queue, nowId: id, isPlaying: true, positionMs: position, durationMs: selected.durationMs });
197
- },
198
- queueEpisode: async (s, arg) => {
199
- const id = idOf(arg);
200
- if (!s.episodes.some((episode) => episode.id === id) || s.queue.includes(id)) return s;
201
- const queue = [...s.queue, id];
202
- persistQueue(queue);
203
- // Keep the native queue in sync when playback is already active. Preserve
204
- // the current item, position and play/pause state while appending.
205
- const snapshot = await playbackStatus().catch(() => undefined);
206
- const activeId = snapshot?.currentItem?.episodeId ?? snapshot?.currentItem?.id ?? s.nowId;
207
- if (activeId) {
208
- const startIndex = Math.max(0, queue.indexOf(activeId));
209
- const next = await setQueue(queueItems(s.episodes, queue), {
210
- startIndex,
211
- startPositionMs: snapshot?.positionMs ?? s.positionMs,
212
- autoplay: snapshot?.state === "playing" || (!snapshot && s.isPlaying),
213
- onStatus: "himiBrandedPodcasts.mediaStatus",
214
- }).catch(() => undefined);
215
- if (next) return derive({ ...s, queue, nowId: next.currentItem?.episodeId ?? next.currentItem?.id ?? activeId,
216
- isPlaying: next.state === "playing", positionMs: next.positionMs, durationMs: next.durationMs || s.durationMs });
217
- }
218
- return derive({ ...s, queue });
219
- },
220
- togglePlay: (s) => {
221
- if (!s.nowId) return s;
222
- void (s.isPlaying ? pause() : play()).then((snapshot) => svc.mediaStatus(snapshot)).catch(() => {});
223
- return derive({ ...s, isPlaying: !s.isPlaying });
224
- },
225
- nextEpisode: (s) => {
226
- void skip(1).then((snapshot) => svc.mediaStatus(snapshot)).catch(() => {});
227
- return s;
228
- },
229
- mediaStatus: async (s, arg) => {
230
- const snapshot = arg?.state ? arg : await playbackStatus().catch(() => undefined);
231
- if (!snapshot) return s;
232
- const id = snapshot.currentItem?.episodeId ?? snapshot.currentItem?.id ?? s.nowId;
233
- if (id) {
234
- const progress = { ...savedProgress };
235
- if (snapshot.state === "ended" || (snapshot.durationMs > 0 && snapshot.positionMs >= snapshot.durationMs - 1_000)) delete progress[id];
236
- else if (snapshot.positionMs >= 1_000) progress[id] = snapshot.positionMs;
237
- persistProgress(progress);
238
- }
239
- return derive({ ...s, nowId: id, isPlaying: snapshot.state === "playing", positionMs: snapshot.positionMs, durationMs: snapshot.durationMs || s.durationMs });
240
- },
241
- },
21
+ const svc = createPodcastService({
22
+ service: "himiBrandedPodcasts", defineService, queue, progress,
23
+ text: (key, fallback) => copyParam(`podcasts.${key}`, fallback),
24
+ describe: (excerpt) => descriptionBody(excerpt).bodyText,
242
25
  });
243
- // A reopened podcast screen owns a fresh worker. Subscribe at module boot so
244
- // the host immediately replays the active session and continues pushing state.
245
- subscribeStatus("himiBrandedPodcasts.mediaStatus").catch(() => {});
246
26
  export { svc };
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$source": "en",
3
- "$generated": "2026-11-15T09:24:42.792Z",
3
+ "$generated": "2026-11-17T08:26:59.985Z",
4
4
  "messages": {
5
5
  "h_0028d743eb44": {
6
6
  "source": "Sale",
@@ -0,0 +1,16 @@
1
+ // How a worker reads an Online Program's lifecycle and name. Wix returns them in more than one
2
+ // shape (v3 `status` or `state`; `description.title`, `settings.title`, a flat `title` or
3
+ // `details.title`), so every screen that lists programs reads them here, the same way.
4
+ import type { WixProgram } from "@himalaya/wix-online-programs";
5
+ import { cleanTitle } from "./himi-text.js";
6
+
7
+ export function programStatus(p: WixProgram): string {
8
+ return (p.status ?? p.state ?? "").toUpperCase();
9
+ }
10
+ export const isProgramEnded = (p: WixProgram): boolean => programStatus(p) === "ENDED" || programStatus(p) === "FINISHED";
11
+ export const isProgramDraft = (p: WixProgram): boolean => programStatus(p) === "DRAFT";
12
+
13
+ /** The program's own name, cleaned; "" when it has none (the caller picks its own fallback word). */
14
+ export function programName(p: WixProgram): string {
15
+ return cleanTitle(p.description?.title ?? p.settings?.title ?? p.title ?? p.details?.title);
16
+ }
@@ -22,7 +22,8 @@ import { iapPriceFields, onlineProgramItem, type IapPollDirective } from "@himal
22
22
  import { createIapCommerce } from "@himalaya/iap-checkout";
23
23
  import { createCollectionQuery, type CollectionPage, type CollectionQueryState } from "./collection-query.js";
24
24
  import { memberAccess, memberAccessChanged, memberAccessDenied, type MemberAccess } from "./member-access.js";
25
- import { cleanTitle, initials } from "./himi-text.js";
25
+ import { initials } from "./himi-text.js";
26
+ import { isProgramDraft, isProgramEnded, programName } from "./program-fields.js";
26
27
  import { programImage } from "./himi-media.js";
27
28
  import { descriptionBody } from "./rich-body.js";
28
29
  import { programDescription } from "./program-description.js";
@@ -125,19 +126,15 @@ export interface State {
125
126
  const full = (p: WixProgram): WixProgramFull => p as WixProgramFull;
126
127
 
127
128
  function programTitle(p: WixProgram): string {
128
- return cleanTitle(p.description?.title ?? p.settings?.title ?? p.title ?? p.details?.title)
129
- || copyParam("memberPrograms.programFallbackName", "Program");
129
+ return programName(p) || copyParam("memberPrograms.programFallbackName", "Program");
130
130
  }
131
131
  function programDetails(p: WixProgram): string {
132
132
  // The body may be a Ricos document or serialized text: read it the way the catalog and detail do.
133
133
  const raw = descriptionBody(programDescription(p)).bodyText.replace(/\s+/g, " ").trim();
134
134
  return raw.length > 140 ? `${raw.slice(0, 139).trimEnd()}…` : raw;
135
135
  }
136
- function programStatus(p: WixProgram): string {
137
- return (p.status ?? p.state ?? "").toUpperCase();
138
- }
139
- const isEnded = (p: WixProgram) => programStatus(p) === "ENDED" || programStatus(p) === "FINISHED";
140
- const isDraft = (p: WixProgram) => programStatus(p) === "DRAFT";
136
+ const isEnded = isProgramEnded;
137
+ const isDraft = isProgramDraft;
141
138
  function accessType(p: WixProgram): string {
142
139
  return (full(p).restrictions?.accessType ?? "PUBLIC").toUpperCase();
143
140
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$source": "en",
3
- "$generated": "2026-11-15T09:24:42.792Z",
3
+ "$generated": "2026-11-17T08:26:59.985Z",
4
4
  "messages": {
5
5
  "h_01e1787a9e5b": {
6
6
  "source": "App language",
@@ -0,0 +1,16 @@
1
+ // How a worker reads an Online Program's lifecycle and name. Wix returns them in more than one
2
+ // shape (v3 `status` or `state`; `description.title`, `settings.title`, a flat `title` or
3
+ // `details.title`), so every screen that lists programs reads them here, the same way.
4
+ import type { WixProgram } from "@himalaya/wix-online-programs";
5
+ import { cleanTitle } from "./himi-text.js";
6
+
7
+ export function programStatus(p: WixProgram): string {
8
+ return (p.status ?? p.state ?? "").toUpperCase();
9
+ }
10
+ export const isProgramEnded = (p: WixProgram): boolean => programStatus(p) === "ENDED" || programStatus(p) === "FINISHED";
11
+ export const isProgramDraft = (p: WixProgram): boolean => programStatus(p) === "DRAFT";
12
+
13
+ /** The program's own name, cleaned; "" when it has none (the caller picks its own fallback word). */
14
+ export function programName(p: WixProgram): string {
15
+ return cleanTitle(p.description?.title ?? p.settings?.title ?? p.title ?? p.details?.title);
16
+ }
@@ -22,7 +22,8 @@ import { iapPriceFields, onlineProgramItem, type IapPollDirective } from "@himal
22
22
  import { createIapCommerce } from "@himalaya/iap-checkout";
23
23
  import { createCollectionQuery, type CollectionPage, type CollectionQueryState } from "./collection-query.js";
24
24
  import { memberAccess, memberAccessChanged, memberAccessDenied, type MemberAccess } from "./member-access.js";
25
- import { cleanTitle, initials } from "./himi-text.js";
25
+ import { initials } from "./himi-text.js";
26
+ import { isProgramDraft, isProgramEnded, programName } from "./program-fields.js";
26
27
  import { programImage } from "./himi-media.js";
27
28
  import { descriptionBody } from "./rich-body.js";
28
29
  import { programDescription } from "./program-description.js";
@@ -125,19 +126,15 @@ export interface State {
125
126
  const full = (p: WixProgram): WixProgramFull => p as WixProgramFull;
126
127
 
127
128
  function programTitle(p: WixProgram): string {
128
- return cleanTitle(p.description?.title ?? p.settings?.title ?? p.title ?? p.details?.title)
129
- || copyParam("memberPrograms.programFallbackName", "Program");
129
+ return programName(p) || copyParam("memberPrograms.programFallbackName", "Program");
130
130
  }
131
131
  function programDetails(p: WixProgram): string {
132
132
  // The body may be a Ricos document or serialized text: read it the way the catalog and detail do.
133
133
  const raw = descriptionBody(programDescription(p)).bodyText.replace(/\s+/g, " ").trim();
134
134
  return raw.length > 140 ? `${raw.slice(0, 139).trimEnd()}…` : raw;
135
135
  }
136
- function programStatus(p: WixProgram): string {
137
- return (p.status ?? p.state ?? "").toUpperCase();
138
- }
139
- const isEnded = (p: WixProgram) => programStatus(p) === "ENDED" || programStatus(p) === "FINISHED";
140
- const isDraft = (p: WixProgram) => programStatus(p) === "DRAFT";
136
+ const isEnded = isProgramEnded;
137
+ const isDraft = isProgramDraft;
141
138
  function accessType(p: WixProgram): string {
142
139
  return (full(p).restrictions?.accessType ?? "PUBLIC").toUpperCase();
143
140
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$source": "en",
3
- "$generated": "2026-11-15T09:24:42.792Z",
3
+ "$generated": "2026-11-17T08:26:59.985Z",
4
4
  "messages": {
5
5
  "h_0028d743eb44": {
6
6
  "source": "Sale",
@@ -0,0 +1,16 @@
1
+ // How a worker reads an Online Program's lifecycle and name. Wix returns them in more than one
2
+ // shape (v3 `status` or `state`; `description.title`, `settings.title`, a flat `title` or
3
+ // `details.title`), so every screen that lists programs reads them here, the same way.
4
+ import type { WixProgram } from "@himalaya/wix-online-programs";
5
+ import { cleanTitle } from "./himi-text.js";
6
+
7
+ export function programStatus(p: WixProgram): string {
8
+ return (p.status ?? p.state ?? "").toUpperCase();
9
+ }
10
+ export const isProgramEnded = (p: WixProgram): boolean => programStatus(p) === "ENDED" || programStatus(p) === "FINISHED";
11
+ export const isProgramDraft = (p: WixProgram): boolean => programStatus(p) === "DRAFT";
12
+
13
+ /** The program's own name, cleaned; "" when it has none (the caller picks its own fallback word). */
14
+ export function programName(p: WixProgram): string {
15
+ return cleanTitle(p.description?.title ?? p.settings?.title ?? p.title ?? p.details?.title);
16
+ }
@@ -22,7 +22,8 @@ import { iapPriceFields, onlineProgramItem, type IapPollDirective } from "@himal
22
22
  import { createIapCommerce } from "@himalaya/iap-checkout";
23
23
  import { createCollectionQuery, type CollectionPage, type CollectionQueryState } from "./collection-query.js";
24
24
  import { memberAccess, memberAccessChanged, memberAccessDenied, type MemberAccess } from "./member-access.js";
25
- import { cleanTitle, initials } from "./himi-text.js";
25
+ import { initials } from "./himi-text.js";
26
+ import { isProgramDraft, isProgramEnded, programName } from "./program-fields.js";
26
27
  import { programImage } from "./himi-media.js";
27
28
  import { descriptionBody } from "./rich-body.js";
28
29
  import { programDescription } from "./program-description.js";
@@ -125,19 +126,15 @@ export interface State {
125
126
  const full = (p: WixProgram): WixProgramFull => p as WixProgramFull;
126
127
 
127
128
  function programTitle(p: WixProgram): string {
128
- return cleanTitle(p.description?.title ?? p.settings?.title ?? p.title ?? p.details?.title)
129
- || copyParam("memberPrograms.programFallbackName", "Program");
129
+ return programName(p) || copyParam("memberPrograms.programFallbackName", "Program");
130
130
  }
131
131
  function programDetails(p: WixProgram): string {
132
132
  // The body may be a Ricos document or serialized text: read it the way the catalog and detail do.
133
133
  const raw = descriptionBody(programDescription(p)).bodyText.replace(/\s+/g, " ").trim();
134
134
  return raw.length > 140 ? `${raw.slice(0, 139).trimEnd()}…` : raw;
135
135
  }
136
- function programStatus(p: WixProgram): string {
137
- return (p.status ?? p.state ?? "").toUpperCase();
138
- }
139
- const isEnded = (p: WixProgram) => programStatus(p) === "ENDED" || programStatus(p) === "FINISHED";
140
- const isDraft = (p: WixProgram) => programStatus(p) === "DRAFT";
136
+ const isEnded = isProgramEnded;
137
+ const isDraft = isProgramDraft;
141
138
  function accessType(p: WixProgram): string {
142
139
  return (full(p).restrictions?.accessType ?? "PUBLIC").toUpperCase();
143
140
  }
@@ -7669,7 +7669,7 @@ const SCREENS = runtimeSetting({
7669
7669
  }
7670
7670
  },
7671
7671
  "modifiers": {
7672
- "width": 64
7672
+ "width": 80
7673
7673
  }
7674
7674
  },
7675
7675
  {
@@ -39,6 +39,10 @@ interface S {
39
39
  noActivity: boolean;
40
40
  servicesScreenId: string;
41
41
  bookingsScreenId: string;
42
+ /** Sign out asks first on a screen that binds the confirm step (askSignOut → signOut, or
43
+ * cancelSignOut). A screen that calls signOut directly signs out at once, as before. */
44
+ confirmingSignOut?: boolean;
45
+ notConfirmingSignOut?: boolean;
42
46
  }
43
47
 
44
48
  function derive(s: S): S {
@@ -46,6 +50,8 @@ function derive(s: S): S {
46
50
  const hasActivity = s.activityRows.length > 0;
47
51
  return {
48
52
  ...s,
53
+ confirmingSignOut: !!s.confirmingSignOut && s.isMember,
54
+ notConfirmingSignOut: !(s.confirmingSignOut && s.isMember),
49
55
  isLoading: s.status === "loading",
50
56
  notLoading: s.status !== "loading",
51
57
  notMember: !s.isMember,
@@ -167,8 +173,14 @@ const svc = defineService<S, {
167
173
  signIn: (s: S) => Promise<S>;
168
174
  register: (s: S) => Promise<S>;
169
175
  signOut: (s: S) => Promise<S>;
176
+ askSignOut: (s: S) => S;
177
+ cancelSignOut: (s: S) => S;
170
178
  openForMember: (s: S, arg?: unknown) => Promise<S>;
171
179
  }>("himiBookingAccount", {
180
+ // An open sign-out confirm is this run's: a cold start never re-opens the dialog, and the flag
181
+ // is never written to the device.
182
+ notHydrated: ["confirmingSignOut", "notConfirmingSignOut"],
183
+ notPersisted: ["confirmingSignOut", "notConfirmingSignOut"],
172
184
  state: derive({
173
185
  status: "loading",
174
186
  isMember: false,
@@ -244,8 +256,11 @@ const svc = defineService<S, {
244
256
  },
245
257
  signOut: async (s) => {
246
258
  try { await dispatch("himi.wix.signOut"); } catch { /* ignore */ }
247
- return probe({ ...s, isMember: false, isRegistering: false, message: "" });
259
+ return probe({ ...s, isMember: false, isRegistering: false, message: "", confirmingSignOut: false });
248
260
  },
261
+ // The confirm step before a sign-out (a destructive action always confirms).
262
+ askSignOut: (s) => derive({ ...s, confirmingSignOut: true }),
263
+ cancelSignOut: (s) => derive({ ...s, confirmingSignOut: false }),
249
264
  },
250
265
  });
251
266
  svc.load();