@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.
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/dev-server/src/builder.d.ts +3 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/himi-package.d.ts +478 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/host-compatibility.d.ts +56 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/icon-catalog.generated.d.ts +1 -1
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/schema.d.ts +4 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/site-shell.d.ts +154 -7
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/validator.d.ts +3 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/flows/screens/src/index.d.ts +2 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/flows/screens/src/podcast-service.d.ts +105 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/flows/screens/src/podcast.d.ts +116 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/core.mjs +326 -13
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/screens.mjs +730 -81
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/sdui.mjs +155 -0
- package/dist/browser-plane/assets.json +5 -5
- package/dist/browser-plane/preview-deferred/{b40ea5d0d6251898ff5617139fde8be008dd11e99a70b14c1052093685401700.bin → 21f35a12bd94f4ab97a9a75453c4adcadc438daf024a4b1950d5c356c123bd01.bin} +1 -1
- package/dist/browser-plane/sw.js +7 -7
- package/dist/cli.mjs +34995 -31326
- package/dist/preview-assets.generated.bin +0 -0
- package/guides/component-reference.json +1 -1
- package/guides/component-reference.md +4 -0
- package/guides/designing-himi-screens.md +7 -0
- package/guides/getting-started.md +2 -0
- package/guides/headless-loop.md +1 -1
- package/guides/himi-skill.md +2 -0
- package/guides/index.json +6 -0
- package/guides/qa-builds.md +12 -1
- package/guides/recipe-podcast.md +149 -0
- package/guides/tier-5-add-a-screen.md +16 -2
- package/guides/wix-business-context.md +29 -0
- package/guides/wix-platform-usage.md +7 -2
- package/package.json +10 -10
- package/template-icons/fitness-gym.png +0 -0
- package/templates/beauty-salon/dev/index.ts +1 -1
- package/templates/beauty-salon/l10n/en.json +1 -1
- package/templates/beauty-salon/tier5-src/_shared/program-fields.ts +16 -0
- package/templates/beauty-salon/tier5-src/_shared/programs-section.ts +5 -8
- package/templates/beauty-salon/tier5-src/himi-branded-lite-agenda/index.ts +37 -4
- package/templates/branded-lite/dev/index.ts +101 -1
- package/templates/branded-lite/l10n/en.json +22 -1
- package/templates/branded-lite/l10n/es.json +22 -0
- package/templates/branded-lite/l10n/fr.json +18 -0
- package/templates/branded-lite/l10n/he.json +15 -0
- package/templates/branded-lite/tier5-src/_shared/program-fields.ts +16 -0
- package/templates/branded-lite/tier5-src/_shared/programs-section.ts +5 -8
- package/templates/branded-lite/tier5-src/himi-branded-lite-agenda/index.ts +37 -4
- package/templates/branded-lite/tier5-src/himi-branded-lite-podcasts/index.ts +14 -234
- package/templates/brandy/README.md +33 -0
- package/templates/brandy/config.ts +51 -7
- package/templates/brandy/dev/index.ts +23 -9
- package/templates/community-club/l10n/en.json +1 -1
- package/templates/community-club/tier5-src/_shared/program-fields.ts +16 -0
- package/templates/community-club/tier5-src/_shared/programs-section.ts +5 -8
- package/templates/events-meetups/l10n/en.json +1 -1
- package/templates/events-meetups/tier5-src/_shared/program-fields.ts +16 -0
- package/templates/events-meetups/tier5-src/_shared/programs-section.ts +5 -8
- package/templates/fitness-gym/README.md +53 -0
- package/templates/fitness-gym/config.ts +560 -0
- package/templates/fitness-gym/dev/index.ts +25787 -0
- package/templates/fitness-gym/himalaya.content.json +64 -0
- package/templates/fitness-gym/himalaya.template.json +15 -0
- package/templates/fitness-gym/icon.png +0 -0
- package/templates/fitness-gym/platforms.json +1 -0
- package/templates/fitness-gym/tier5-src/_shared/app-locale.ts +61 -0
- package/templates/fitness-gym/tier5-src/_shared/booking-location.ts +147 -0
- package/templates/fitness-gym/tier5-src/_shared/booking-session.ts +224 -0
- package/templates/fitness-gym/tier5-src/_shared/branded-lite-hosted.ts +280 -0
- package/templates/fitness-gym/tier5-src/_shared/branded-load-state.ts +109 -0
- package/templates/fitness-gym/tier5-src/_shared/business-chat-copy.ts +40 -0
- package/templates/fitness-gym/tier5-src/_shared/business-chat-history.ts +51 -0
- package/templates/fitness-gym/tier5-src/_shared/business-chat-message-model.ts +177 -0
- package/templates/fitness-gym/tier5-src/_shared/business-chat-model.ts +56 -0
- package/templates/fitness-gym/tier5-src/_shared/business-chat-presenter.ts +576 -0
- package/templates/fitness-gym/tier5-src/_shared/business-chat-transport.ts +148 -0
- package/templates/fitness-gym/tier5-src/_shared/collection-contract.ts +228 -0
- package/templates/fitness-gym/tier5-src/_shared/collection-query.ts +193 -0
- package/templates/fitness-gym/tier5-src/_shared/collection-service.ts +400 -0
- package/templates/fitness-gym/tier5-src/_shared/detail-presence.ts +51 -0
- package/templates/fitness-gym/tier5-src/_shared/engine-intl.ts +523 -0
- package/templates/fitness-gym/tier5-src/_shared/himi-account.ts +194 -0
- package/templates/fitness-gym/tier5-src/_shared/himi-booking-saved.ts +88 -0
- package/templates/fitness-gym/tier5-src/_shared/himi-bookings.ts +318 -0
- package/templates/fitness-gym/tier5-src/_shared/himi-copy.ts +116 -0
- package/templates/fitness-gym/tier5-src/_shared/himi-media.ts +29 -0
- package/templates/fitness-gym/tier5-src/_shared/himi-store.ts +7 -0
- package/templates/fitness-gym/tier5-src/_shared/himi-text.ts +24 -0
- package/templates/fitness-gym/tier5-src/_shared/host-events.ts +66 -0
- package/templates/fitness-gym/tier5-src/_shared/hosted-checkout.ts +70 -0
- package/templates/fitness-gym/tier5-src/_shared/iap-attendance-form.ts +106 -0
- package/templates/fitness-gym/tier5-src/_shared/iap-attendance-purchase.ts +216 -0
- package/templates/fitness-gym/tier5-src/_shared/iap-attendance.ts +38 -0
- package/templates/fitness-gym/tier5-src/_shared/iap-worker.ts +127 -0
- package/templates/fitness-gym/tier5-src/_shared/inbox-rooms.ts +68 -0
- package/templates/fitness-gym/tier5-src/_shared/local-preferences.ts +38 -0
- package/templates/fitness-gym/tier5-src/_shared/member-access.ts +63 -0
- package/templates/fitness-gym/tier5-src/_shared/member-account-routes.ts +52 -0
- package/templates/fitness-gym/tier5-src/_shared/member-bookings.ts +107 -0
- package/templates/fitness-gym/tier5-src/_shared/member-screen.ts +99 -0
- package/templates/fitness-gym/tier5-src/_shared/notification-target.ts +141 -0
- package/templates/fitness-gym/tier5-src/_shared/offset-page.ts +10 -0
- package/templates/fitness-gym/tier5-src/_shared/online-actions.ts +76 -0
- package/templates/fitness-gym/tier5-src/_shared/owner-load-error.ts +348 -0
- package/templates/fitness-gym/tier5-src/_shared/payment-setup.ts +6 -0
- package/templates/fitness-gym/tier5-src/_shared/pricing-plan-display.ts +64 -0
- package/templates/fitness-gym/tier5-src/_shared/program-description.ts +11 -0
- package/templates/fitness-gym/tier5-src/_shared/program-fields.ts +16 -0
- package/templates/fitness-gym/tier5-src/_shared/program-standing.ts +46 -0
- package/templates/fitness-gym/tier5-src/_shared/rich-body.ts +78 -0
- package/templates/fitness-gym/tier5-src/_shared/rich-content-link.ts +34 -0
- package/templates/fitness-gym/tier5-src/_shared/sign-in-sheet.ts +18 -0
- package/templates/fitness-gym/tier5-src/_shared/staff-name.ts +18 -0
- package/templates/fitness-gym/tier5-src/_shared/weekly-goal.ts +107 -0
- package/templates/fitness-gym/tier5-src/_shared/wix-bi.ts +85 -0
- package/templates/fitness-gym/tier5-src/_shared/wix-member-links.ts +114 -0
- package/templates/fitness-gym/tier5-src/_shared/wix-service-price.ts +146 -0
- package/templates/fitness-gym/tier5-src/business-chat/index.ts +732 -0
- package/templates/fitness-gym/tier5-src/business-contact/index.ts +6 -0
- package/templates/fitness-gym/tier5-src/himi-booking-account/index.ts +267 -0
- package/templates/fitness-gym/tier5-src/himi-booking-bookings/index.ts +468 -0
- package/templates/fitness-gym/tier5-src/himi-booking-service/index.ts +1190 -0
- package/templates/fitness-gym/tier5-src/himi-booking-services/index.ts +791 -0
- package/templates/fitness-gym/tier5-src/himi-booking-time/index.ts +1729 -0
- package/templates/fitness-gym/tier5-src/himi-branded-lite-agenda/index.ts +988 -0
- package/templates/fitness-gym/tier5-src/himi-branded-lite-member-programs/index.ts +656 -0
- package/templates/fitness-gym/tier5-src/himi-branded-lite-notifications/index.ts +256 -0
- package/templates/fitness-gym/tier5-src/himi-branded-lite-plans/index.ts +495 -0
- package/templates/fitness-gym/tier5-src/himi-branded-lite-program/facts.ts +52 -0
- package/templates/fitness-gym/tier5-src/himi-branded-lite-program/index.ts +845 -0
- package/templates/fitness-gym/tier5-src/himi-fitcoach-goal/index.ts +191 -0
- package/templates/fitness-gym/tier5-src/himi-fitcoach-home/index.ts +619 -0
- package/templates/fitness-gym/tier5-src/himi-store-account/index.ts +1007 -0
- package/templates/fitness-gym/tier5-src/wix-spaces-my-subscriptions/index.ts +84 -0
- package/templates/fitness-gym/tier5-src/wix-spaces-subscription-detail/index.ts +139 -0
- package/templates/fitness-gym/tokens.json +414 -0
- package/templates/gym-fitness/dev/index.ts +1 -1
- package/templates/gym-fitness/l10n/en.json +1 -1
- package/templates/gym-fitness/tier5-src/_shared/program-fields.ts +16 -0
- package/templates/gym-fitness/tier5-src/_shared/programs-section.ts +5 -8
- package/templates/gym-fitness/tier5-src/himi-branded-lite-agenda/index.ts +37 -4
- package/templates/medical-services/dev/index.ts +2 -1
- package/templates/medical-services/tier5-src/himi-booking-account/index.ts +16 -1
- package/templates/nonprofit-cause/l10n/en.json +1 -1
- package/templates/nonprofit-cause/tier5-src/_shared/program-fields.ts +16 -0
- package/templates/nonprofit-cause/tier5-src/_shared/programs-section.ts +5 -8
- package/templates/personal-fitness-trainer/dev/index.ts +2 -2
- package/templates/personal-fitness-trainer/tier5-src/himi-branded-lite-agenda/index.ts +37 -4
- package/templates/podcast-creator/dev/index.ts +100 -0
- package/templates/podcast-creator/l10n/en.json +22 -1
- package/templates/podcast-creator/l10n/es.json +22 -0
- package/templates/podcast-creator/l10n/fr.json +18 -0
- package/templates/podcast-creator/l10n/he.json +15 -0
- package/templates/podcast-creator/tier5-src/_shared/program-fields.ts +16 -0
- package/templates/podcast-creator/tier5-src/_shared/programs-section.ts +5 -8
- package/templates/podcast-creator/tier5-src/himi-branded-lite-podcasts/index.ts +14 -234
- package/templates/portfolio-creative/l10n/en.json +1 -1
- package/templates/portfolio-creative/tier5-src/_shared/program-fields.ts +16 -0
- package/templates/portfolio-creative/tier5-src/_shared/programs-section.ts +5 -8
- package/templates/restaurant/l10n/en.json +1 -1
- package/templates/restaurant/tier5-src/_shared/program-fields.ts +16 -0
- package/templates/restaurant/tier5-src/_shared/programs-section.ts +5 -8
- package/templates/retail-store/l10n/en.json +1 -1
- package/templates/retail-store/tier5-src/_shared/program-fields.ts +16 -0
- package/templates/retail-store/tier5-src/_shared/programs-section.ts +5 -8
- package/templates/salon-spa/dev/index.ts +1 -1
- package/templates/salon-spa/tier5-src/himi-booking-account/index.ts +16 -1
- package/templates/salon-spa/tier5-src/himi-branded-lite-agenda/index.ts +37 -4
- package/templates/yoga-studio/dev/index.ts +1 -1
- package/templates/yoga-studio/l10n/en.json +1 -1
- package/templates/yoga-studio/tier5-src/_shared/program-fields.ts +16 -0
- package/templates/yoga-studio/tier5-src/_shared/programs-section.ts +5 -8
- package/templates/yoga-studio/tier5-src/himi-branded-lite-agenda/index.ts +37 -4
|
@@ -1,246 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
//
|
|
3
|
-
//
|
|
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
|
|
65
|
-
return (globalThis as { himalaya?: PreferenceRuntime
|
|
10
|
+
function host(): PreferenceRuntime {
|
|
11
|
+
return (globalThis as { himalaya?: PreferenceRuntime }).himalaya ?? {};
|
|
66
12
|
}
|
|
67
|
-
const
|
|
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
|
|
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 =
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
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 };
|
|
@@ -53,6 +53,39 @@ To review the map first, leave out `--apply`: the block is then only written to
|
|
|
53
53
|
`config.ts` validates the block whenever the app loads, so an `http` origin, a duplicate id or a map
|
|
54
54
|
with no tab fails `himi validate`, `himi render` and `himi push` rather than shipping.
|
|
55
55
|
|
|
56
|
+
## Top-bar icons and your own native screens
|
|
57
|
+
|
|
58
|
+
Optional parts of the `site` block add or trim native chrome, with no code:
|
|
59
|
+
|
|
60
|
+
```json
|
|
61
|
+
"topBar": { "actions": [
|
|
62
|
+
{ "id": "alerts", "icon": "bell", "label": "Notifications", "target": { "screen": "himi_notification_settings" } },
|
|
63
|
+
{ "id": "insta", "icon": "photo", "label": "Instagram", "target": { "url": "https://instagram.com/yourshop" } }
|
|
64
|
+
] },
|
|
65
|
+
"nativePages": [
|
|
66
|
+
{ "id": "rewards", "screenId": "rewards", "title": "Rewards", "icon": "star", "placement": "tab", "after": "home" }
|
|
67
|
+
]
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
- **`topBar.actions`** puts up to three icons at the trailing end of every screen's top bar. `label` is
|
|
71
|
+
what a screen reader says. A `target` is one of `page` (one of your site's pages, `overflow` ones
|
|
72
|
+
included, such as a cart page), `screen` (a native page's screen, or `himi_notification_settings`), or
|
|
73
|
+
`url` (a page off your site, which opens in the browser after an "Open in browser?" prompt).
|
|
74
|
+
- **`nativePages`** adds your own Tier-5 screens as a `tab`, a `drawer` row or `overflow` (no row, but
|
|
75
|
+
linkable). They sit among your site's pages after the page named in `after`, or after all of them
|
|
76
|
+
when `after` is not set. Tabs count toward the four-tab limit. Add each screen to `dev/index.ts`
|
|
77
|
+
(`screens.exact`), with its worker in `tier5-src/` (`himi docs tier-5-add-a-screen`). `himi validate`
|
|
78
|
+
refuses a native page whose screen is missing. A link to `<scheme>://screen/<screenId>` from outside the
|
|
79
|
+
app, including one on your website, opens the screen only when the page sets `"public": true`. Use
|
|
80
|
+
`"requiresAuth": true` (it implies public) to have a signed-out user sign in first. It needs a sign-in
|
|
81
|
+
that gates links, which this template does not have yet (a Base44 sign-in does not count), so
|
|
82
|
+
`himi validate` refuses it. Notifications is public unless its native page sets
|
|
83
|
+
`"public": false`.
|
|
84
|
+
- **`pageTitle`** (`"auto"`, `"always"` or `"never"`) decides where a page shows its title in the top
|
|
85
|
+
bar. `auto`, the default, hides it on a page that a tab, sidebar or drawer row opens, because the
|
|
86
|
+
row already names it, and shows it on `overflow` pages and pages opened from a link. Set
|
|
87
|
+
`"showTitle": true` or `false` on a page to override the rule for that page.
|
|
88
|
+
|
|
56
89
|
## Wrap any website (not on Wix)
|
|
57
90
|
|
|
58
91
|
The same app wraps any https website. Set `"kind": "web"`:
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
// which derives it from your site's own menu. Inspect the live values any time with
|
|
8
8
|
// `himi context`; see `himi docs app-config`.
|
|
9
9
|
import {
|
|
10
|
+
assertSiteNativePagesAuth,
|
|
10
11
|
assertSiteShellConfig,
|
|
11
12
|
defineApp,
|
|
12
13
|
siteLinkableScreens,
|
|
@@ -14,6 +15,7 @@ import {
|
|
|
14
15
|
siteNavKind,
|
|
15
16
|
siteSidebar,
|
|
16
17
|
siteNavConfig,
|
|
18
|
+
siteTopBarDefault,
|
|
17
19
|
siteWebSdkCompanion,
|
|
18
20
|
type SiteShellConfig,
|
|
19
21
|
type SiteWebSdk,
|
|
@@ -23,7 +25,29 @@ import provisioning from "./provisioning.json" with { type: "json" };
|
|
|
23
25
|
|
|
24
26
|
/** Your website and its page map. Validated here, so a mistake in provisioning.json (an http
|
|
25
27
|
* origin, a duplicate page id, no tab) fails `himi validate`, `render` and `push` instead of
|
|
26
|
-
* shipping a broken app.
|
|
28
|
+
* shipping a broken app.
|
|
29
|
+
*
|
|
30
|
+
* Two optional parts of the block add native chrome, with no code here:
|
|
31
|
+
*
|
|
32
|
+
* "topBar": { "actions": [
|
|
33
|
+
* { "id": "cart", "icon": "cart", "label": "Cart", "target": { "page": "cart" } },
|
|
34
|
+
* { "id": "alerts", "icon": "bell", "label": "Notifications", "target": { "screen": "himi_notification_settings" } },
|
|
35
|
+
* { "id": "insta", "icon": "photo", "label": "Instagram", "target": { "url": "https://instagram.com/yourshop" } }
|
|
36
|
+
* ] },
|
|
37
|
+
* "nativePages": [
|
|
38
|
+
* { "id": "rewards", "screenId": "rewards", "title": "Rewards", "icon": "star", "placement": "tab", "after": "home" }
|
|
39
|
+
* ]
|
|
40
|
+
*
|
|
41
|
+
* `topBar.actions` — up to three trailing icons on every screen. A target opens a site page (`page`,
|
|
42
|
+
* any placement — an `overflow` page has no row), a native screen (`screen`: a native page's screen or
|
|
43
|
+
* `himi_notification_settings`), or an off-site https page in the browser after an "Open in browser?"
|
|
44
|
+
* prompt (`url`).
|
|
45
|
+
* `nativePages` — your own Tier-5 screens as tabs, drawer rows or `overflow` (linkable only), mixed with
|
|
46
|
+
* the site's pages (`after` names the page it follows; absent ⇒ after them all). The screen itself is
|
|
47
|
+
* yours: add it to dev/index.ts. Tabs count toward the four-tab limit together with the site's. A
|
|
48
|
+
* native page is linkable from outside the app (`<scheme>://screen/<screenId>`) only with "public": true.
|
|
49
|
+
* `pageTitle` — "auto" (default: no title on a page a tab, sidebar or drawer row opens; a title on
|
|
50
|
+
* overflow and link-opened pages), "always" or "never"; a page's `showTitle` overrides it. */
|
|
27
51
|
export const site = provisioning.site as SiteShellConfig;
|
|
28
52
|
assertSiteShellConfig(site);
|
|
29
53
|
const nav = siteNav(site);
|
|
@@ -89,18 +113,32 @@ const base44Config = base44 === undefined ? undefined
|
|
|
89
113
|
/** The native Base44 Account screen's id (shared by every site shell; never `himi_account`). */
|
|
90
114
|
export const BASE44_ACCOUNT_SCREEN_ID = "himi_base44_account";
|
|
91
115
|
const notificationsRow = { id: "drawer_notifications", screenId: "himi_notification_settings", label: "Notifications", icon: "bell" as const };
|
|
92
|
-
|
|
116
|
+
/** Screens a native page (`site.nativePages`) already places — Notifications as a tab, say. Its row
|
|
117
|
+
* replaces the app's own: one screen is never listed twice in the drawer, the rail or the links. */
|
|
118
|
+
const placedScreens = new Set((site.nativePages ?? []).map((page) => page.screenId));
|
|
119
|
+
/** …of those, the ones with a row (an `overflow` native page has none, so the app's own row stays). */
|
|
120
|
+
const rowedScreens = new Set((site.nativePages ?? []).filter((page) => (page.placement ?? "tab") !== "overflow").map((page) => page.screenId));
|
|
121
|
+
const nativeRows = (base44
|
|
93
122
|
? [{ id: "drawer_account", screenId: BASE44_ACCOUNT_SCREEN_ID, label: "Account", icon: "person" as const }, notificationsRow]
|
|
94
|
-
: [notificationsRow];
|
|
123
|
+
: [notificationsRow]).filter((row) => !rowedScreens.has(row.screenId));
|
|
95
124
|
// The native rows' ids are reserved — the same rule as the Brandy shell's contract parser: a site page
|
|
96
125
|
// that is not `overflow` gets a row, and one called `notifications` (or `account`, beside the Account
|
|
97
126
|
// row) would share its row id with the app's own, while navigation finds a destination by row id.
|
|
98
127
|
const reservedPageIds = base44 ? ["notifications", "account"] : ["notifications"];
|
|
99
|
-
for (const page of site.pages) {
|
|
128
|
+
for (const page of [...site.pages, ...(site.nativePages ?? [])]) {
|
|
100
129
|
if ((page.placement ?? "tab") !== "overflow" && reservedPageIds.includes(page.id)) {
|
|
101
130
|
throw new Error(`provisioning.json: site page id "${page.id}" is reserved for the app's native ${page.id} screen — rename the page or make it an overflow page`);
|
|
102
131
|
}
|
|
103
132
|
}
|
|
133
|
+
/** The native screens this app serves itself, which a top-bar `{ screen }` target may name beside your
|
|
134
|
+
* native pages: Notifications, and a Base44 site's Account. */
|
|
135
|
+
const builtInScreens = ["himi_notification_settings", ...(base44 ? [BASE44_ACCOUNT_SCREEN_ID] : [])];
|
|
136
|
+
/** `site.topBar` as the app-wide top bar (every screen without one of its own). */
|
|
137
|
+
const topBarDefault = siteTopBarDefault(site, { nativeScreens: builtInScreens });
|
|
138
|
+
// A native page's `requiresAuth` needs a sign-in that gates deep links. This app has none (a Wix site is
|
|
139
|
+
// visitor-only, and a Base44 sign-in does not gate links yet), so it refuses the flag rather than open
|
|
140
|
+
// the screen signed out.
|
|
141
|
+
assertSiteNativePagesAuth(site, false);
|
|
104
142
|
|
|
105
143
|
export default defineApp({
|
|
106
144
|
id: "__HIMI_APP_DOTID__",
|
|
@@ -152,15 +190,21 @@ export default defineApp({
|
|
|
152
190
|
navKind: siteNavKind(site),
|
|
153
191
|
scheme: "himalaya-__HIMI_APP_SLUG__",
|
|
154
192
|
deepLinkPatterns: [],
|
|
193
|
+
// Every page and native page, so a link to <scheme>://screen/<screenId> — from your website too —
|
|
194
|
+
// opens it (its tab, when it has one).
|
|
155
195
|
linkableScreens: [
|
|
156
196
|
...siteLinkableScreens(site),
|
|
157
|
-
|
|
158
|
-
|
|
197
|
+
...builtInScreens
|
|
198
|
+
.filter((screenId) => !placedScreens.has(screenId))
|
|
199
|
+
.map((screenId) => ({ screenId, isPublic: true, paramKeys: [], parentScreenId: "" })),
|
|
159
200
|
],
|
|
201
|
+
// Your `site.topBar` icons, on every screen that has no top bar of its own.
|
|
202
|
+
topBarDefault,
|
|
160
203
|
// A notification or app link carrying one of your site's URLs opens that page's tab.
|
|
161
204
|
site: siteNavConfig(site),
|
|
162
205
|
tabBar: { items: nav.tabs },
|
|
163
|
-
// Your site's drawer pages, then the
|
|
206
|
+
// Your site's drawer pages and native pages, then the app's own screens: Account (a Base44 site)
|
|
207
|
+
// and Notifications.
|
|
164
208
|
drawer: { items: [...nav.drawer, ...nativeRows] },
|
|
165
209
|
// The rail (tablet, or `layout: "sidebar"`) replaces the drawer, so it lists the same rows.
|
|
166
210
|
sidebar: { items: [...siteSidebar(site), ...nativeRows] },
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// `site` block of ../provisioning.json — so this file holds no screen of its own. Change the
|
|
3
3
|
// pages by changing that block, never this file. When provisioning.json enables page
|
|
4
4
|
// capabilities (`webSdk`), every page gets the worker that answers them (`withSiteWebSdk`).
|
|
5
|
-
import { siteScreens, withSiteWebSdk } from "@himalaya/core";
|
|
5
|
+
import { assertSiteNativePagesBuilt, siteScreens, withSiteNativeScreenTopBarBuilder, withSiteWebSdk } from "@himalaya/core";
|
|
6
6
|
import config, { base44, BASE44_ACCOUNT_SCREEN_ID, site, webSdk } from "../config.js";
|
|
7
7
|
|
|
8
8
|
const SCREENS = siteScreens(site);
|
|
@@ -854,18 +854,32 @@ const ACCOUNT = base44 ? { [BASE44_ACCOUNT_SCREEN_ID]: base44Account(base44.dele
|
|
|
854
854
|
// and the agent tooling read `homeScreenId` from this file as written; config.ts refuses a map
|
|
855
855
|
// whose first tab is anything else, so the literal and the tab bar cannot disagree.
|
|
856
856
|
|
|
857
|
+
// A fresh copy per build: descriptors are pure functions of the site block (withSiteWebSdk
|
|
858
|
+
// copies, and attaches the page worker when `webSdk` enables capabilities). A JSON round trip,
|
|
859
|
+
// not structuredClone: `himi test` builds screens in the contained realm, which withholds it.
|
|
860
|
+
const exact: Record<string, (ctx: Parameters<typeof withSiteWebSdk>[1]) => unknown> = {
|
|
861
|
+
...Object.fromEntries(Object.keys(SCREENS).map((id) => [id, (ctx: Parameters<typeof withSiteWebSdk>[1]) => withSiteWebSdk(SCREENS[id]!, ctx, webSdk)])),
|
|
862
|
+
himi_notification_settings: () => JSON.parse(JSON.stringify(NOTIFICATIONS)),
|
|
863
|
+
...Object.fromEntries(Object.entries(ACCOUNT).map(([id, screen]) => [id, () => JSON.parse(JSON.stringify(screen))])),
|
|
864
|
+
// Your own native screens go here, keyed by screen id, and `site.nativePages` in
|
|
865
|
+
// ../provisioning.json places them as tabs, drawer rows or overflow screens, e.g.
|
|
866
|
+
// rewards: () => ({ screenId: "rewards", renderer: "sdui_intent", title: "Rewards", schemaVersion: 1, payload: { … } }),
|
|
867
|
+
// with its worker in tier5-src/ (`himi docs tier-5-add-a-screen`).
|
|
868
|
+
};
|
|
869
|
+
// A native page only PLACES a screen, so it must be one built above — or its row would open nothing.
|
|
870
|
+
assertSiteNativePagesBuilt(site, Object.keys(exact));
|
|
871
|
+
// A top-bar icon that opens one of your native screens is left out of that screen's own bar (on the
|
|
872
|
+
// screen itself it would open a second copy), the way a website page's bar leaves out its own icon.
|
|
873
|
+
for (const [screenId, build] of Object.entries(exact)) {
|
|
874
|
+
// A builder may return its screen directly or as a promise; the wrapper awaits it first.
|
|
875
|
+
if (!screenId.startsWith("site_")) exact[screenId] = withSiteNativeScreenTopBarBuilder(site, build);
|
|
876
|
+
}
|
|
877
|
+
|
|
857
878
|
export default {
|
|
858
879
|
config,
|
|
859
880
|
homeScreenId: "site_home",
|
|
860
881
|
screens: {
|
|
861
|
-
|
|
862
|
-
// copies, and attaches the page worker when `webSdk` enables capabilities). A JSON round trip,
|
|
863
|
-
// not structuredClone: `himi test` builds screens in the contained realm, which withholds it.
|
|
864
|
-
exact: {
|
|
865
|
-
...Object.fromEntries(Object.keys(SCREENS).map((id) => [id, (ctx: Parameters<typeof withSiteWebSdk>[1]) => withSiteWebSdk(SCREENS[id]!, ctx, webSdk)])),
|
|
866
|
-
himi_notification_settings: () => JSON.parse(JSON.stringify(NOTIFICATIONS)),
|
|
867
|
-
...Object.fromEntries(Object.entries(ACCOUNT).map(([id, screen]) => [id, () => JSON.parse(JSON.stringify(screen))])),
|
|
868
|
-
},
|
|
882
|
+
exact,
|
|
869
883
|
templated: [],
|
|
870
884
|
},
|
|
871
885
|
actions: [],
|
|
@@ -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 {
|
|
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
|
|
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
|
-
|
|
137
|
-
|
|
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
|
}
|
|
@@ -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 {
|
|
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
|
|
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
|
-
|
|
137
|
-
|
|
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
|
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# __HIMI_APP_NAME__ — from the `fitness-gym` template
|
|
2
|
+
|
|
3
|
+
An online fitness coach / gym app over a real Wix site, dark with one lime accent: a Home that answers a member (next session, challenge progress ring, this week's bookings, plan, quick actions) and a visitor (a photo hero with one CTA); workout goals that explain the goal and book its first personal session; the class schedule in a month calendar with an All · Booked filter; Workouts — the shared Branded Lite booking flow; Challenges (Online Programs) with progress; Membership (Pricing Plans) and My plans; Chat with the coach (the Wix Inbox chat); About and Profile. Boots as a VISITOR; booking, joining, buying a plan and the chat open Branded Lite's sign-in form as a sheet.
|
|
4
|
+
|
|
5
|
+
Everything here is now yours to edit — screens in `dev/`, logic in `tier5-src/`,
|
|
6
|
+
identity and navigation in `config.ts`, look and feel in `tokens.json`.
|
|
7
|
+
|
|
8
|
+
## Point at your Wix site
|
|
9
|
+
|
|
10
|
+
Your **Wix Headless `clientId` binds the data** — the visitor token minted from it already
|
|
11
|
+
names your site, so reads need nothing else. Set these before `himi build` / preview so calls
|
|
12
|
+
hit YOUR site (the placeholders are not a real backend):
|
|
13
|
+
|
|
14
|
+
export WIX_CLIENT_ID="<headless-oauth-client-id>"
|
|
15
|
+
export WIX_SITE_URL="https://your-site.wixsite.com/…"
|
|
16
|
+
export WIX_SITE_ID="<metasite-id>"
|
|
17
|
+
|
|
18
|
+
`WIX_SITE_ID` is the site that client belongs to. The member login takes it from the environment
|
|
19
|
+
while `WIX_CLIENT_ID` is the client the config uses. A native build needs it for member sign-up on
|
|
20
|
+
a CAPTCHA-protected site, push registration and in-app purchases.
|
|
21
|
+
|
|
22
|
+
Full details, including how to ship a binary a customer can install against their own
|
|
23
|
+
site: `himi docs branded-lite-site-binding`.
|
|
24
|
+
|
|
25
|
+
## The loop
|
|
26
|
+
|
|
27
|
+
himi build # compile tier5-src/* -> dist/bundles
|
|
28
|
+
himi validate # screens, bindings and worker boot
|
|
29
|
+
himi render <screenId> --tree # render a screen right here, no device needed
|
|
30
|
+
himi test # exercise every action your screens declare
|
|
31
|
+
himi login --browser --target wix # sign in with your Wix account (once)
|
|
32
|
+
# no browser? export WIX_API_KEY, then himi login --wix --target wix
|
|
33
|
+
himi push --draft # publish a DRAFT release + get preview links
|
|
34
|
+
|
|
35
|
+
Build, validate, render and test run entirely on your machine. Only `login` and
|
|
36
|
+
`push` reach Wix. No per-app install is needed: the CLI ships the `@wix/himalaya`
|
|
37
|
+
runtime it compiles against.
|
|
38
|
+
|
|
39
|
+
## Pattern index — where to look for each recipe
|
|
40
|
+
|
|
41
|
+
| Pattern | Screens |
|
|
42
|
+
|---|---|
|
|
43
|
+
| One Home for a member and a visitor (sections that collapse fully) | himi_fit_home |
|
|
44
|
+
| A progress ring from real data (Gauge) | himi_fit_home your progress |
|
|
45
|
+
| A photo hero with a gradient scrim (Shape fillGradient) | himi_fit_home hero, coach |
|
|
46
|
+
| App-owned CMS content with sample rows (workout goals) | himi_fit_home goals, himi_fit_goal |
|
|
47
|
+
| A shared screen restyled by node id (month calendar, filter) | himi_agenda |
|
|
48
|
+
| Reusing a shared screen in your own words (stock-string copy rewrite) | himi_services, himi_service, himi_time, himi_bookings |
|
|
49
|
+
| Your own design over a shared worker | himi_plans, himi_member_programs, himi_program, himi_account |
|
|
50
|
+
| Member chat with the business (Wix Inbox) | himi_business_chat |
|
|
51
|
+
|
|
52
|
+
Guides: `himi docs recipe-dynamic-list`, `himi docs tier-5-add-a-screen`,
|
|
53
|
+
`himi docs designing-himi-screens`. Seed references: `himi agent-init`.
|