@wix/himalaya-cli 0.1278.0 → 0.1280.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 (41) hide show
  1. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/schema.d.ts +33 -0
  2. package/dist/cli.mjs +52 -2
  3. package/guides/component-reference.json +3 -2
  4. package/guides/component-reference.md +28 -1
  5. package/package.json +4 -3
  6. package/templates/beauty-salon/config.ts +2 -1
  7. package/templates/beauty-salon/dev/index.ts +2 -1
  8. package/templates/beauty-salon/tier5-src/himi-store-account/index.ts +12 -4
  9. package/templates/branded-lite/config.ts +13 -2
  10. package/templates/branded-lite/dev/index.ts +520 -170
  11. package/templates/branded-lite/tier5-src/_shared/vod.ts +71 -0
  12. package/templates/branded-lite/tier5-src/himi-branded-lite-video/index.ts +98 -0
  13. package/templates/branded-lite/tier5-src/himi-branded-lite-videos/index.ts +11 -20
  14. package/templates/branded-lite/tier5-src/himi-store-account/index.ts +12 -4
  15. package/templates/community-club/config.ts +2 -1
  16. package/templates/community-club/dev/index.ts +2 -1
  17. package/templates/community-club/tier5-src/himi-store-account/index.ts +12 -4
  18. package/templates/events-meetups/config.ts +2 -1
  19. package/templates/events-meetups/dev/index.ts +2 -1
  20. package/templates/events-meetups/tier5-src/himi-store-account/index.ts +12 -4
  21. package/templates/gym-fitness/config.ts +2 -1
  22. package/templates/gym-fitness/dev/index.ts +2 -1
  23. package/templates/gym-fitness/tier5-src/himi-store-account/index.ts +12 -4
  24. package/templates/nonprofit-cause/config.ts +2 -1
  25. package/templates/nonprofit-cause/dev/index.ts +2 -1
  26. package/templates/nonprofit-cause/tier5-src/himi-store-account/index.ts +12 -4
  27. package/templates/podcast-creator/config.ts +2 -1
  28. package/templates/podcast-creator/dev/index.ts +2 -1
  29. package/templates/podcast-creator/tier5-src/himi-store-account/index.ts +12 -4
  30. package/templates/portfolio-creative/config.ts +2 -1
  31. package/templates/portfolio-creative/dev/index.ts +2 -1
  32. package/templates/portfolio-creative/tier5-src/himi-store-account/index.ts +12 -4
  33. package/templates/restaurant/config.ts +2 -1
  34. package/templates/restaurant/dev/index.ts +2 -1
  35. package/templates/restaurant/tier5-src/himi-store-account/index.ts +12 -4
  36. package/templates/retail-store/config.ts +2 -1
  37. package/templates/retail-store/dev/index.ts +2 -1
  38. package/templates/retail-store/tier5-src/himi-store-account/index.ts +12 -4
  39. package/templates/yoga-studio/config.ts +2 -1
  40. package/templates/yoga-studio/dev/index.ts +2 -1
  41. package/templates/yoga-studio/tier5-src/himi-store-account/index.ts +12 -4
@@ -0,0 +1,71 @@
1
+ // VOD's public GraphQL contract: wix-one-app-vod/src/api/v3/{Channel,Video}Fetch.ts.
2
+ // Always use the host's visitor/member bridge; never use owner credentials here.
3
+ export const VOD_PUBLIC_GRAPHQL = "https://manage.wix.com/_api/vod/public/graphql";
4
+ export interface VodVideo {
5
+ id: string; title?: string; description?: string; source?: string; status?: string;
6
+ content?: { status?: string; externalUrl?: string; externalId?: string };
7
+ pricing?: { type: string; enabled: boolean }[];
8
+ purchase?: { status?: string }; rent_purchase?: { status?: string };
9
+ }
10
+ export interface VodChannel {
11
+ id: string; title?: string;
12
+ pricing?: { type: string; enabled: boolean; required?: boolean }[];
13
+ purchase?: { status?: string; expiresAt?: string };
14
+ }
15
+ export function vodError(message: string, denied = false, signInRequired = false): Error & { denied: boolean; signInRequired: boolean } {
16
+ return Object.assign(new Error(message), { denied, signInRequired });
17
+ }
18
+ export async function vodQuery<T>(query: string, variables: Record<string, unknown>): Promise<T> {
19
+ const api = (globalThis as { himalaya?: { wixApi?: { call: (m: string, p: string, b: unknown) => Promise<unknown> } } }).himalaya?.wixApi;
20
+ if (!api) throw vodError("Wix bridge unavailable");
21
+ const response = await api.call("POST", VOD_PUBLIC_GRAPHQL, { query, variables }) as
22
+ { data?: T | null; errors?: { message?: string; extensions?: { code?: string } }[] };
23
+ if (response?.errors?.length) {
24
+ const signInRequired = response.errors.some(e => /^UNAUTHENTICATED$|^UNAUTHORIZED$/i.test(e.extensions?.code ?? ""));
25
+ const denied = response.errors.some(e => /FORBIDDEN|UNAUTH|ACCESS_DENIED|PERMISSION_DENIED/i.test(e.extensions?.code ?? ""));
26
+ throw vodError(signInRequired ? "Video unauthenticated" : denied ? "Video access denied" : "VOD query failed", denied, signInRequired);
27
+ }
28
+ const data = response && Object.prototype.hasOwnProperty.call(response, "data") ? response.data : response as T;
29
+ if (!data || typeof data !== "object") throw vodError("Invalid VOD response");
30
+ return data;
31
+ }
32
+
33
+ export async function vodPages<T extends { id: string }>(fetchPage: (cursor: string | null) => Promise<{ entities: T[]; cursor?: string | null }>): Promise<T[]> {
34
+ const rows = new Map<string, T>();
35
+ const cursors = new Set<string>();
36
+ let cursor: string | null = null;
37
+ for (let page = 0; page < 200; page++) {
38
+ const result = await fetchPage(cursor);
39
+ if (!result || !Array.isArray(result.entities)) throw vodError("Invalid VOD page");
40
+ for (const row of result.entities) if (row?.id) rows.set(row.id, row);
41
+ if (!result.cursor) return [...rows.values()];
42
+ if (typeof result.cursor !== "string" || cursors.has(result.cursor)) throw vodError("Invalid VOD cursor");
43
+ cursor = result.cursor;
44
+ cursors.add(cursor);
45
+ }
46
+ throw vodError("VOD pagination limit exceeded");
47
+ }
48
+
49
+ export const CHANNEL_ACCESS_FIELDS = `id title pricing { type enabled required } purchase(filter: {type: SUBSCRIPTION}) { status expiresAt }`;
50
+ export const VIDEO_FIELDS = `id title description source status content { status externalUrl externalId } pricing { type enabled } purchase(filter: {type: SALE}) { status } rent_purchase: purchase(filter: {type: RENT}) { status }`;
51
+
52
+ /** External embeds expose their URL without a play authorization. Fail closed when
53
+ * metadata is missing or a plan's entitlement cannot be established. Hosted videos
54
+ * must ALSO obtain their media URL through play(type: CONTENT). */
55
+ export function videoAccess(channel: VodChannel, video: VodVideo): boolean {
56
+ if (!Array.isArray(channel.pricing) || !Array.isArray(video.pricing)) return false;
57
+ const subscription = channel.purchase;
58
+ const expires = subscription?.expiresAt ? Date.parse(subscription.expiresAt) : undefined;
59
+ const subscribed = subscription?.status === "ACTIVE" && (expires === undefined || expires > Date.now()) ||
60
+ subscription?.status === "CANCELED" && expires !== undefined && expires > Date.now();
61
+ const channelOptions = channel.pricing.filter(p => p.enabled);
62
+ if (channelOptions.some(p => p.required || p.type === "PRICING_PLAN") && !subscribed) return false;
63
+ const paid = video.pricing.some(p => p.enabled);
64
+ return !paid || subscribed || video.purchase?.status === "ACTIVE" || video.rent_purchase?.status === "ACTIVE";
65
+ }
66
+
67
+ export function youtubeId(video: VodVideo): string {
68
+ // Treat the embed URL as data, not arbitrary WebView HTML or a navigable URL.
69
+ const match = /^https:\/\/(?:(?:www\.|m\.)?youtube\.com|www\.youtube-nocookie\.com)\/embed\/([A-Za-z0-9_-]{11})(?:[?/#]|$)/.exec(video.content?.externalUrl ?? "");
70
+ return match?.[1] ?? (/^[A-Za-z0-9_-]{11}$/.test(video.content?.externalId ?? "") ? video.content!.externalId! : "");
71
+ }
@@ -0,0 +1,98 @@
1
+ import { defineService } from "@himalaya/state";
2
+ import { LOADING, loaded, loadFailed, needsSignIn, type LoadFlags } from "../_shared/branded-load-state.js";
3
+ import { copyParam, stashCopy } from "../_shared/himi-copy.js";
4
+ import { CHANNEL_ACCESS_FIELDS, VIDEO_FIELDS, vodError, vodQuery, vodPages, videoAccess, youtubeId, type VodChannel, type VodVideo } from "../_shared/vod.js";
5
+ import type { MediaItem } from "@himalaya/core";
6
+
7
+ interface S extends LoadFlags {
8
+ id: string; channelId: string;
9
+ title: string; description: string; videos: { id: string; channelId: string; title: string; subtitle: string }[];
10
+ items: MediaItem[]; hidePlayer: boolean; hideNotFound: boolean; noEntity: boolean; hideRefresh: boolean; emptyText: string; message: string;
11
+ playbackState: "loading" | "ready" | "processing" | "denied" | "unavailable" | "error";
12
+ }
13
+ const COPY = { prefix: "video", empty: "No videos in this channel yet.", error: "Videos couldn't be loaded.", signIn: "Sign in to watch videos.", sample: () => [] };
14
+ function input(key: string): string {
15
+ const value = (globalThis as { himalaya?: { input?: Record<string, unknown> } }).himalaya?.input?.[key];
16
+ return typeof value === "string" ? value : "";
17
+ }
18
+ const CHANNEL_QUERY = `query VodChannelVideos($channelId: ID!, $cursor: String) {
19
+ channel(filter: {id: $channelId}) { ${CHANNEL_ACCESS_FIELDS}
20
+ videos(sort: CUSTOM_DESC, cursor: $cursor) { cursor entities { ${VIDEO_FIELDS} } }
21
+ }
22
+ }`;
23
+ const VIDEO_QUERY = `query VodVideo($channelId: ID!, $videoId: ID!) {
24
+ channel(filter: {id: $channelId}) { ${CHANNEL_ACCESS_FIELDS} video(filter: {id: $videoId}) { ${VIDEO_FIELDS} } }
25
+ }`;
26
+ const PLAY_QUERY = `query VodVideoPlay($channelId: ID!, $videoId: ID!) {
27
+ channel(filter: {id: $channelId}) { video(filter: {id: $videoId}) { play(type: CONTENT) { entity { hls } } } }
28
+ }`;
29
+ let generation = 0;
30
+ const initial: S = { ...LOADING, id: "", channelId: "", title: "", description: "", videos: [], items: [], hidePlayer: true, hideNotFound: true, noEntity: false, hideRefresh: false, emptyText: "", message: "", playbackState: "loading" };
31
+ function unavailable(s: S, kind: S["playbackState"], message: string): S {
32
+ return { ...s, ...loaded("videos", [], { ...COPY, empty: "" }), items: [], hidePlayer: true, hideNotFound: kind !== "unavailable", noEntity: kind === "unavailable", hideRefresh: kind === "unavailable", emptyText: "", message, playbackState: kind };
33
+ }
34
+ const svc = defineService<S, { reset: (s: S) => S; load: (s: S, arg?: unknown) => Promise<S | undefined> }>("himiBrandedVideo", {
35
+ state: initial,
36
+ notHydrated: Object.keys(initial) as (keyof S & string)[],
37
+ actions: {
38
+ reset: () => ({ ...initial }),
39
+ load: async (_s, arg) => {
40
+ stashCopy(arg);
41
+ const request = ++generation;
42
+ // Revoke the previous item immediately while current access is rechecked.
43
+ await svc.reset();
44
+ let next: S = { ...initial, id: input("id"), channelId: input("channelId") };
45
+ try {
46
+ const { id, channelId } = next;
47
+ const channelScreen = input("screenId") === "himi_video_channel";
48
+ if (!id || (!channelScreen && !channelId)) next = unavailable(next, "unavailable", copyParam("video.unavailableText", "This video or channel is unavailable."));
49
+ else if (channelScreen) {
50
+ const videos = await vodPages(async cursor => {
51
+ const data = await vodQuery<{ channel: (VodChannel & { videos: { cursor?: string; entities: VodVideo[] } }) | null }>(CHANNEL_QUERY, { channelId: id, cursor });
52
+ if (!data.channel) throw Object.assign(vodError("Channel unavailable"), { notFound: true });
53
+ next.title = data.channel.title ?? "";
54
+ return data.channel.videos;
55
+ });
56
+ next = { ...next, ...loaded("videos", videos.map(v => ({ id: v.id, channelId: id, title: v.title?.trim() || copyParam("video.untitled", "Video"), subtitle:
57
+ v.content?.status !== "READY" ? copyParam("video.processingText", "Video is processing.") : "" })), COPY), playbackState: "ready" };
58
+ } else {
59
+ const data = await vodQuery<{ channel: (VodChannel & { video: VodVideo | null }) | null }>(VIDEO_QUERY, { channelId, videoId: id });
60
+ const channel = data.channel;
61
+ const video = channel?.video;
62
+ if (!video || video.status !== "VISIBLE") next = unavailable(next, "unavailable", copyParam("video.unavailableText", "This video is unavailable."));
63
+ else {
64
+ next.title = video.title ?? "";
65
+ next.description = video.description ?? "";
66
+ if (video.content?.status !== "READY") next = /PROCESS|PENDING|TRANSCOD|UPLOAD|CONVERT/.test(video.content?.status ?? "") ?
67
+ unavailable(next, "processing", copyParam("video.processingText", "Video is processing. Try again later.")) :
68
+ unavailable(next, "unavailable", copyParam("video.unavailableText", "This video is unavailable."));
69
+ else if (!videoAccess(channel!, video)) next = unavailable(next, "denied", copyParam("video.deniedText", "Your current membership or purchase does not allow this video."));
70
+ else {
71
+ let item: MediaItem | undefined;
72
+ if (video.source === "YOUTUBE") {
73
+ const providerId = youtubeId(video);
74
+ if (providerId) item = { id, kind: "video", provider: "youtube", providerId, title: next.title };
75
+ } else if (["COMPUTER", "GOOGLE_DRIVE", "DROPBOX"].includes(video.source ?? "")) {
76
+ const play = await vodQuery<{ channel: { video: { play?: { entity?: { hls?: string } } } } }>(PLAY_QUERY, { channelId, videoId: id });
77
+ const url = play.channel?.video?.play?.entity?.hls;
78
+ if (typeof url === "string" && /^https:\/\//.test(url)) item = { id, kind: "video", provider: "direct", url, streamType: "hls", title: next.title };
79
+ }
80
+ next = item ? { ...next, ...loaded("videos", [], { ...COPY, empty: "" }), emptyText: "", items: [item], hidePlayer: false, playbackState: "ready" } :
81
+ unavailable(next, "unavailable", copyParam("video.unavailableText", "This video is unavailable."));
82
+ }
83
+ }
84
+ }
85
+ } catch (error) {
86
+ const denied = (error as { denied?: boolean })?.denied || /^HTTP\s+403\b/.test(String((error as Error)?.message));
87
+ next = (error as { notFound?: boolean })?.notFound ? unavailable(next, "unavailable", copyParam("video.unavailableText", "This video or channel is unavailable.")) :
88
+ needsSignIn(error) ? { ...next, ...loadFailed("videos", error, COPY), playbackState: "denied", items: [], hidePlayer: true, hideRefresh: true } :
89
+ denied ? unavailable(next, "denied", copyParam("video.deniedText", "Your current membership or purchase does not allow this video.")) :
90
+ { ...next, ...loadFailed("videos", error, COPY), playbackState: "error", items: [], hidePlayer: true };
91
+ }
92
+ if (request === generation) return next;
93
+ return undefined;
94
+ },
95
+ },
96
+ });
97
+ svc.load();
98
+ export { svc };
@@ -13,8 +13,8 @@
13
13
  // Endpoint + query verbatim from wix-one-app-vod/src/api/v3 (env.ts + ChannelFetch.ts).
14
14
  import { defineService } from "../_shared/collection-service.js";
15
15
  import { LOADING, loaded, loadFailed, type LoadCopy, type LoadFlags } from "../_shared/branded-load-state.js";
16
+ import { vodQuery, vodPages } from "../_shared/vod.js";
16
17
 
17
- const VOD_PUBLIC_GRAPHQL = "https://manage.wix.com/_api/vod/public/graphql";
18
18
  const CHANNEL_LIST_QUERY = `
19
19
  query VodChannelList($cursor: String) {
20
20
  channels(sort: CUSTOM_ASC, cursor: $cursor) {
@@ -25,13 +25,6 @@ const CHANNEL_LIST_QUERY = `
25
25
  }
26
26
  `;
27
27
 
28
- // Direct bridge handle — the typed @himalaya/wix-* SDKs are REST-only; VOD is GraphQL,
29
- // so we go through the raw chokepoint (same shape wix-spaces-dashboard uses).
30
- type WixApi = { call: (m: string, p: string, b?: unknown, h?: Record<string, string>) => Promise<unknown> };
31
- function wixApi(): WixApi | null {
32
- return (globalThis as { himalaya?: { wixApi?: WixApi } }).himalaya?.wixApi ?? null;
33
- }
34
-
35
28
  interface VodChannel { id?: string; title?: string; description?: string; videos?: { total?: number }; hasPaidVideos?: boolean }
36
29
  interface Row { id: string; title: string; subtitle: string }
37
30
  interface S extends LoadFlags {
@@ -66,25 +59,23 @@ const COPY: LoadCopy<Row> = {
66
59
  sample: () => MOCK.map((r) => ({ ...r })),
67
60
  };
68
61
 
69
- const svc = defineService<S, { load: (s: S) => Promise<S> }>("himiBrandedVideos", {
62
+ let generation = 0;
63
+ const svc = defineService<S, { load: (s: S) => Promise<S | undefined> }>("himiBrandedVideos", {
70
64
  state: { ...LOADING, channels: [], emptyText: "" },
71
65
  actions: {
72
66
  load: async (s) => {
67
+ const request = ++generation;
73
68
  try {
74
- const api = wixApi();
75
- if (!api) return { ...s, ...loadFailed("channels", new Error("Wix bridge unavailable"), COPY) };
76
- const res = (await api.call("POST", VOD_PUBLIC_GRAPHQL, { query: CHANNEL_LIST_QUERY, variables: {} })) as
77
- { data?: { channels?: { entities?: VodChannel[] } } } | { channels?: { entities?: VodChannel[] } };
78
- // The gateway may return the GraphQL envelope ({data:{...}}) or the bridge may
79
- // unwrap it — accept both.
80
- const entities =
81
- (res as { data?: { channels?: { entities?: VodChannel[] } } })?.data?.channels?.entities ??
82
- (res as { channels?: { entities?: VodChannel[] } })?.channels?.entities ?? [];
69
+ const entities = await vodPages(async cursor => {
70
+ const data = await vodQuery<{ channels: { entities: (VodChannel & { id: string })[]; cursor?: string } }>(CHANNEL_LIST_QUERY, { cursor });
71
+ return data.channels;
72
+ });
83
73
  const channels = entities.map(norm);
84
- return { ...s, ...loaded("channels", channels, COPY) };
74
+ if (request === generation) return { ...s, ...loaded("channels", channels, COPY) };
85
75
  } catch (err) {
86
- return { ...s, ...loadFailed("channels", err, COPY) };
76
+ if (request === generation) return { ...s, ...loadFailed("channels", err, COPY) };
87
77
  }
78
+ return undefined;
88
79
  },
89
80
  },
90
81
  });
@@ -19,6 +19,7 @@ interface AuthRouteInput {
19
19
  contextName?: string;
20
20
  returnScreenId?: string;
21
21
  returnId?: string;
22
+ returnChannelId?: string;
22
23
  }
23
24
 
24
25
  // The screen's boot input survives refresh; consuming it must survive too.
@@ -37,21 +38,25 @@ function strField(arg: unknown, key: string): string {
37
38
  }
38
39
 
39
40
  /** Mid-flow auth (UX F3): intent + return path from himi.open / himalaya.input. */
40
- function authIntentFromArg(arg: unknown, prev: Pick<S, "authIntent" | "authContextName" | "returnScreenId" | "returnId">): Pick<S, "authIntent" | "authContextName" | "returnScreenId" | "returnId"> {
41
+ function authIntentFromArg(arg: unknown, prev: Pick<S, "authIntent" | "authContextName" | "returnScreenId" | "returnId" | "returnChannelId">): Pick<S, "authIntent" | "authContextName" | "returnScreenId" | "returnId" | "returnChannelId"> {
41
42
  const route = routeInputConsumed ? {} : routeInput();
42
43
  return {
43
44
  authIntent: strField(arg, "intent") || route.intent || prev.authIntent || "",
44
45
  authContextName: strField(arg, "contextName") || route.contextName || prev.authContextName || "",
45
46
  returnScreenId: strField(arg, "returnScreenId") || route.returnScreenId || prev.returnScreenId || "",
46
47
  returnId: strField(arg, "returnId") || route.returnId || prev.returnId || "",
48
+ returnChannelId: strField(arg, "returnChannelId") || route.returnChannelId || prev.returnChannelId || "",
47
49
  };
48
50
  }
49
51
 
50
52
  /** Where a successful sign-in returns to, or null. Never Account itself — that would
51
53
  * only push a second copy of the screen the member is already on. */
52
- function resumeTarget(s: Pick<S, "returnScreenId" | "returnId">): NavDirective | null {
54
+ function resumeTarget(s: Pick<S, "returnScreenId" | "returnId" | "returnChannelId">): NavDirective | null {
53
55
  if (!s.returnScreenId || s.returnScreenId === "himi_account") return null;
54
- return s.returnId ? { screenId: s.returnScreenId, args: { id: s.returnId } } : { screenId: s.returnScreenId };
56
+ return s.returnId || s.returnChannelId ? {
57
+ screenId: s.returnScreenId,
58
+ args: { ...(s.returnId ? { id: s.returnId } : {}), ...(s.returnChannelId ? { channelId: s.returnChannelId } : {}) },
59
+ } : { screenId: s.returnScreenId };
55
60
  }
56
61
 
57
62
  /** Resume the member-only screen that sent the visitor here, once. The return path is
@@ -61,7 +66,7 @@ function resumeAfterAuth(next: S): S {
61
66
  const target = resumeTarget(next);
62
67
  if (!next.isMember || !target) return next;
63
68
  routeInputConsumed = true;
64
- return navigate(derive({ ...next, authIntent: "", authContextName: "", returnScreenId: "", returnId: "" }), target);
69
+ return navigate(derive({ ...next, authIntent: "", authContextName: "", returnScreenId: "", returnId: "", returnChannelId: "" }), target);
65
70
  }
66
71
 
67
72
  // Actions are not serialized: two quick Sign in taps both run against the pre-tap
@@ -165,6 +170,7 @@ interface S {
165
170
  authContextName: string;
166
171
  returnScreenId: string;
167
172
  returnId: string;
173
+ returnChannelId: string;
168
174
  /** Show Continue when an already-signed-in member opens Account with a return path.
169
175
  * A sign-in made here resumes on its own (resumeAfterAuth). */
170
176
  hasReturnPath: boolean;
@@ -364,6 +370,7 @@ const svc = defineService<S, {
364
370
  authContextName: "",
365
371
  returnScreenId: "",
366
372
  returnId: "",
373
+ returnChannelId: "",
367
374
  hasReturnPath: false,
368
375
  noReturnPath: true,
369
376
  returnCta: "Continue",
@@ -475,6 +482,7 @@ const svc = defineService<S, {
475
482
  authContextName: "",
476
483
  returnScreenId: "",
477
484
  returnId: "",
485
+ returnChannelId: "",
478
486
  };
479
487
  return derive(cleared);
480
488
  },
@@ -208,7 +208,8 @@ export default defineApp({
208
208
  "intent",
209
209
  "contextName",
210
210
  "returnScreenId",
211
- "returnId"
211
+ "returnId",
212
+ "returnChannelId"
212
213
  ],
213
214
  "parentScreenId": "",
214
215
  "tabId": "profile"
@@ -2757,7 +2757,8 @@ const SCREENS = runtimeSetting({
2757
2757
  "actionId": "himi.open",
2758
2758
  "params": {
2759
2759
  "screenId": "$service:himiStoreAccount.returnScreenId",
2760
- "id": "$service:himiStoreAccount.returnId"
2760
+ "id": "$service:himiStoreAccount.returnId",
2761
+ "channelId": "$service:himiStoreAccount.returnChannelId"
2761
2762
  }
2762
2763
  }
2763
2764
  }
@@ -19,6 +19,7 @@ interface AuthRouteInput {
19
19
  contextName?: string;
20
20
  returnScreenId?: string;
21
21
  returnId?: string;
22
+ returnChannelId?: string;
22
23
  }
23
24
 
24
25
  // The screen's boot input survives refresh; consuming it must survive too.
@@ -37,21 +38,25 @@ function strField(arg: unknown, key: string): string {
37
38
  }
38
39
 
39
40
  /** Mid-flow auth (UX F3): intent + return path from himi.open / himalaya.input. */
40
- function authIntentFromArg(arg: unknown, prev: Pick<S, "authIntent" | "authContextName" | "returnScreenId" | "returnId">): Pick<S, "authIntent" | "authContextName" | "returnScreenId" | "returnId"> {
41
+ function authIntentFromArg(arg: unknown, prev: Pick<S, "authIntent" | "authContextName" | "returnScreenId" | "returnId" | "returnChannelId">): Pick<S, "authIntent" | "authContextName" | "returnScreenId" | "returnId" | "returnChannelId"> {
41
42
  const route = routeInputConsumed ? {} : routeInput();
42
43
  return {
43
44
  authIntent: strField(arg, "intent") || route.intent || prev.authIntent || "",
44
45
  authContextName: strField(arg, "contextName") || route.contextName || prev.authContextName || "",
45
46
  returnScreenId: strField(arg, "returnScreenId") || route.returnScreenId || prev.returnScreenId || "",
46
47
  returnId: strField(arg, "returnId") || route.returnId || prev.returnId || "",
48
+ returnChannelId: strField(arg, "returnChannelId") || route.returnChannelId || prev.returnChannelId || "",
47
49
  };
48
50
  }
49
51
 
50
52
  /** Where a successful sign-in returns to, or null. Never Account itself — that would
51
53
  * only push a second copy of the screen the member is already on. */
52
- function resumeTarget(s: Pick<S, "returnScreenId" | "returnId">): NavDirective | null {
54
+ function resumeTarget(s: Pick<S, "returnScreenId" | "returnId" | "returnChannelId">): NavDirective | null {
53
55
  if (!s.returnScreenId || s.returnScreenId === "himi_account") return null;
54
- return s.returnId ? { screenId: s.returnScreenId, args: { id: s.returnId } } : { screenId: s.returnScreenId };
56
+ return s.returnId || s.returnChannelId ? {
57
+ screenId: s.returnScreenId,
58
+ args: { ...(s.returnId ? { id: s.returnId } : {}), ...(s.returnChannelId ? { channelId: s.returnChannelId } : {}) },
59
+ } : { screenId: s.returnScreenId };
55
60
  }
56
61
 
57
62
  /** Resume the member-only screen that sent the visitor here, once. The return path is
@@ -61,7 +66,7 @@ function resumeAfterAuth(next: S): S {
61
66
  const target = resumeTarget(next);
62
67
  if (!next.isMember || !target) return next;
63
68
  routeInputConsumed = true;
64
- return navigate(derive({ ...next, authIntent: "", authContextName: "", returnScreenId: "", returnId: "" }), target);
69
+ return navigate(derive({ ...next, authIntent: "", authContextName: "", returnScreenId: "", returnId: "", returnChannelId: "" }), target);
65
70
  }
66
71
 
67
72
  // Actions are not serialized: two quick Sign in taps both run against the pre-tap
@@ -165,6 +170,7 @@ interface S {
165
170
  authContextName: string;
166
171
  returnScreenId: string;
167
172
  returnId: string;
173
+ returnChannelId: string;
168
174
  /** Show Continue when an already-signed-in member opens Account with a return path.
169
175
  * A sign-in made here resumes on its own (resumeAfterAuth). */
170
176
  hasReturnPath: boolean;
@@ -364,6 +370,7 @@ const svc = defineService<S, {
364
370
  authContextName: "",
365
371
  returnScreenId: "",
366
372
  returnId: "",
373
+ returnChannelId: "",
367
374
  hasReturnPath: false,
368
375
  noReturnPath: true,
369
376
  returnCta: "Continue",
@@ -475,6 +482,7 @@ const svc = defineService<S, {
475
482
  authContextName: "",
476
483
  returnScreenId: "",
477
484
  returnId: "",
485
+ returnChannelId: "",
478
486
  };
479
487
  return derive(cleared);
480
488
  },
@@ -192,7 +192,8 @@ export default defineApp({
192
192
  "intent",
193
193
  "contextName",
194
194
  "returnScreenId",
195
- "returnId"
195
+ "returnId",
196
+ "returnChannelId"
196
197
  ],
197
198
  "parentScreenId": "",
198
199
  "tabId": "profile"
@@ -2941,7 +2941,8 @@ const SCREENS = runtimeSetting({
2941
2941
  "actionId": "himi.open",
2942
2942
  "params": {
2943
2943
  "screenId": "$service:himiStoreAccount.returnScreenId",
2944
- "id": "$service:himiStoreAccount.returnId"
2944
+ "id": "$service:himiStoreAccount.returnId",
2945
+ "channelId": "$service:himiStoreAccount.returnChannelId"
2945
2946
  }
2946
2947
  }
2947
2948
  }
@@ -19,6 +19,7 @@ interface AuthRouteInput {
19
19
  contextName?: string;
20
20
  returnScreenId?: string;
21
21
  returnId?: string;
22
+ returnChannelId?: string;
22
23
  }
23
24
 
24
25
  // The screen's boot input survives refresh; consuming it must survive too.
@@ -37,21 +38,25 @@ function strField(arg: unknown, key: string): string {
37
38
  }
38
39
 
39
40
  /** Mid-flow auth (UX F3): intent + return path from himi.open / himalaya.input. */
40
- function authIntentFromArg(arg: unknown, prev: Pick<S, "authIntent" | "authContextName" | "returnScreenId" | "returnId">): Pick<S, "authIntent" | "authContextName" | "returnScreenId" | "returnId"> {
41
+ function authIntentFromArg(arg: unknown, prev: Pick<S, "authIntent" | "authContextName" | "returnScreenId" | "returnId" | "returnChannelId">): Pick<S, "authIntent" | "authContextName" | "returnScreenId" | "returnId" | "returnChannelId"> {
41
42
  const route = routeInputConsumed ? {} : routeInput();
42
43
  return {
43
44
  authIntent: strField(arg, "intent") || route.intent || prev.authIntent || "",
44
45
  authContextName: strField(arg, "contextName") || route.contextName || prev.authContextName || "",
45
46
  returnScreenId: strField(arg, "returnScreenId") || route.returnScreenId || prev.returnScreenId || "",
46
47
  returnId: strField(arg, "returnId") || route.returnId || prev.returnId || "",
48
+ returnChannelId: strField(arg, "returnChannelId") || route.returnChannelId || prev.returnChannelId || "",
47
49
  };
48
50
  }
49
51
 
50
52
  /** Where a successful sign-in returns to, or null. Never Account itself — that would
51
53
  * only push a second copy of the screen the member is already on. */
52
- function resumeTarget(s: Pick<S, "returnScreenId" | "returnId">): NavDirective | null {
54
+ function resumeTarget(s: Pick<S, "returnScreenId" | "returnId" | "returnChannelId">): NavDirective | null {
53
55
  if (!s.returnScreenId || s.returnScreenId === "himi_account") return null;
54
- return s.returnId ? { screenId: s.returnScreenId, args: { id: s.returnId } } : { screenId: s.returnScreenId };
56
+ return s.returnId || s.returnChannelId ? {
57
+ screenId: s.returnScreenId,
58
+ args: { ...(s.returnId ? { id: s.returnId } : {}), ...(s.returnChannelId ? { channelId: s.returnChannelId } : {}) },
59
+ } : { screenId: s.returnScreenId };
55
60
  }
56
61
 
57
62
  /** Resume the member-only screen that sent the visitor here, once. The return path is
@@ -61,7 +66,7 @@ function resumeAfterAuth(next: S): S {
61
66
  const target = resumeTarget(next);
62
67
  if (!next.isMember || !target) return next;
63
68
  routeInputConsumed = true;
64
- return navigate(derive({ ...next, authIntent: "", authContextName: "", returnScreenId: "", returnId: "" }), target);
69
+ return navigate(derive({ ...next, authIntent: "", authContextName: "", returnScreenId: "", returnId: "", returnChannelId: "" }), target);
65
70
  }
66
71
 
67
72
  // Actions are not serialized: two quick Sign in taps both run against the pre-tap
@@ -165,6 +170,7 @@ interface S {
165
170
  authContextName: string;
166
171
  returnScreenId: string;
167
172
  returnId: string;
173
+ returnChannelId: string;
168
174
  /** Show Continue when an already-signed-in member opens Account with a return path.
169
175
  * A sign-in made here resumes on its own (resumeAfterAuth). */
170
176
  hasReturnPath: boolean;
@@ -364,6 +370,7 @@ const svc = defineService<S, {
364
370
  authContextName: "",
365
371
  returnScreenId: "",
366
372
  returnId: "",
373
+ returnChannelId: "",
367
374
  hasReturnPath: false,
368
375
  noReturnPath: true,
369
376
  returnCta: "Continue",
@@ -475,6 +482,7 @@ const svc = defineService<S, {
475
482
  authContextName: "",
476
483
  returnScreenId: "",
477
484
  returnId: "",
485
+ returnChannelId: "",
478
486
  };
479
487
  return derive(cleared);
480
488
  },
@@ -295,7 +295,8 @@ export default defineApp({
295
295
  "intent",
296
296
  "contextName",
297
297
  "returnScreenId",
298
- "returnId"
298
+ "returnId",
299
+ "returnChannelId"
299
300
  ],
300
301
  "parentScreenId": "",
301
302
  "tabId": "profile"
@@ -3576,7 +3576,8 @@ const SCREENS = runtimeSetting({
3576
3576
  "actionId": "himi.open",
3577
3577
  "params": {
3578
3578
  "screenId": "$service:himiStoreAccount.returnScreenId",
3579
- "id": "$service:himiStoreAccount.returnId"
3579
+ "id": "$service:himiStoreAccount.returnId",
3580
+ "channelId": "$service:himiStoreAccount.returnChannelId"
3580
3581
  }
3581
3582
  }
3582
3583
  }
@@ -19,6 +19,7 @@ interface AuthRouteInput {
19
19
  contextName?: string;
20
20
  returnScreenId?: string;
21
21
  returnId?: string;
22
+ returnChannelId?: string;
22
23
  }
23
24
 
24
25
  // The screen's boot input survives refresh; consuming it must survive too.
@@ -37,21 +38,25 @@ function strField(arg: unknown, key: string): string {
37
38
  }
38
39
 
39
40
  /** Mid-flow auth (UX F3): intent + return path from himi.open / himalaya.input. */
40
- function authIntentFromArg(arg: unknown, prev: Pick<S, "authIntent" | "authContextName" | "returnScreenId" | "returnId">): Pick<S, "authIntent" | "authContextName" | "returnScreenId" | "returnId"> {
41
+ function authIntentFromArg(arg: unknown, prev: Pick<S, "authIntent" | "authContextName" | "returnScreenId" | "returnId" | "returnChannelId">): Pick<S, "authIntent" | "authContextName" | "returnScreenId" | "returnId" | "returnChannelId"> {
41
42
  const route = routeInputConsumed ? {} : routeInput();
42
43
  return {
43
44
  authIntent: strField(arg, "intent") || route.intent || prev.authIntent || "",
44
45
  authContextName: strField(arg, "contextName") || route.contextName || prev.authContextName || "",
45
46
  returnScreenId: strField(arg, "returnScreenId") || route.returnScreenId || prev.returnScreenId || "",
46
47
  returnId: strField(arg, "returnId") || route.returnId || prev.returnId || "",
48
+ returnChannelId: strField(arg, "returnChannelId") || route.returnChannelId || prev.returnChannelId || "",
47
49
  };
48
50
  }
49
51
 
50
52
  /** Where a successful sign-in returns to, or null. Never Account itself — that would
51
53
  * only push a second copy of the screen the member is already on. */
52
- function resumeTarget(s: Pick<S, "returnScreenId" | "returnId">): NavDirective | null {
54
+ function resumeTarget(s: Pick<S, "returnScreenId" | "returnId" | "returnChannelId">): NavDirective | null {
53
55
  if (!s.returnScreenId || s.returnScreenId === "himi_account") return null;
54
- return s.returnId ? { screenId: s.returnScreenId, args: { id: s.returnId } } : { screenId: s.returnScreenId };
56
+ return s.returnId || s.returnChannelId ? {
57
+ screenId: s.returnScreenId,
58
+ args: { ...(s.returnId ? { id: s.returnId } : {}), ...(s.returnChannelId ? { channelId: s.returnChannelId } : {}) },
59
+ } : { screenId: s.returnScreenId };
55
60
  }
56
61
 
57
62
  /** Resume the member-only screen that sent the visitor here, once. The return path is
@@ -61,7 +66,7 @@ function resumeAfterAuth(next: S): S {
61
66
  const target = resumeTarget(next);
62
67
  if (!next.isMember || !target) return next;
63
68
  routeInputConsumed = true;
64
- return navigate(derive({ ...next, authIntent: "", authContextName: "", returnScreenId: "", returnId: "" }), target);
69
+ return navigate(derive({ ...next, authIntent: "", authContextName: "", returnScreenId: "", returnId: "", returnChannelId: "" }), target);
65
70
  }
66
71
 
67
72
  // Actions are not serialized: two quick Sign in taps both run against the pre-tap
@@ -165,6 +170,7 @@ interface S {
165
170
  authContextName: string;
166
171
  returnScreenId: string;
167
172
  returnId: string;
173
+ returnChannelId: string;
168
174
  /** Show Continue when an already-signed-in member opens Account with a return path.
169
175
  * A sign-in made here resumes on its own (resumeAfterAuth). */
170
176
  hasReturnPath: boolean;
@@ -364,6 +370,7 @@ const svc = defineService<S, {
364
370
  authContextName: "",
365
371
  returnScreenId: "",
366
372
  returnId: "",
373
+ returnChannelId: "",
367
374
  hasReturnPath: false,
368
375
  noReturnPath: true,
369
376
  returnCta: "Continue",
@@ -475,6 +482,7 @@ const svc = defineService<S, {
475
482
  authContextName: "",
476
483
  returnScreenId: "",
477
484
  returnId: "",
485
+ returnChannelId: "",
478
486
  };
479
487
  return derive(cleared);
480
488
  },
@@ -224,7 +224,8 @@ export default defineApp({
224
224
  "intent",
225
225
  "contextName",
226
226
  "returnScreenId",
227
- "returnId"
227
+ "returnId",
228
+ "returnChannelId"
228
229
  ],
229
230
  "parentScreenId": "",
230
231
  "tabId": "profile"
@@ -2965,7 +2965,8 @@ const SCREENS = runtimeSetting({
2965
2965
  "actionId": "himi.open",
2966
2966
  "params": {
2967
2967
  "screenId": "$service:himiStoreAccount.returnScreenId",
2968
- "id": "$service:himiStoreAccount.returnId"
2968
+ "id": "$service:himiStoreAccount.returnId",
2969
+ "channelId": "$service:himiStoreAccount.returnChannelId"
2969
2970
  }
2970
2971
  }
2971
2972
  }