@wix/himalaya-cli 0.1637.0 → 0.1639.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 (49) hide show
  1. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/dev-server/src/app-module.d.ts +8 -0
  2. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/sdui.mjs +25 -0
  3. package/dist/browser-plane/assets.json +5 -5
  4. package/dist/browser-plane/preview-deferred/{289b89dc660fa050af31f8ce5f22ffd7332a60c7b80b8ffd2b141ec074fb2e22.bin → 3361f61ce6b490c8b7b252658ea67f733d88c6e9f95906d0e31eea4827141df3.bin} +1 -1
  5. package/dist/browser-plane/sw.js +8 -8
  6. package/dist/cli.mjs +1259 -914
  7. package/dist/preview-assets.generated.bin +0 -0
  8. package/guides/android-ux.md +6 -3
  9. package/guides/himi-json-output.md +40 -0
  10. package/guides/himi-test.md +8 -0
  11. package/guides/ios-ux.md +4 -2
  12. package/package.json +2 -2
  13. package/templates/beauty-salon/tier5-src/_shared/member-screen.ts +99 -0
  14. package/templates/beauty-salon/tier5-src/himi-booking-service/index.ts +10 -0
  15. package/templates/beauty-salon/tier5-src/himi-booking-time/index.ts +20 -5
  16. package/templates/beauty-salon/tier5-src/himi-store-account/index.ts +71 -4
  17. package/templates/branded-lite/tier5-src/_shared/member-screen.ts +99 -0
  18. package/templates/branded-lite/tier5-src/himi-booking-service/index.ts +10 -0
  19. package/templates/branded-lite/tier5-src/himi-booking-time/index.ts +20 -5
  20. package/templates/branded-lite/tier5-src/himi-store-account/index.ts +71 -4
  21. package/templates/community-club/tier5-src/_shared/member-screen.ts +99 -0
  22. package/templates/community-club/tier5-src/himi-store-account/index.ts +71 -4
  23. package/templates/events-meetups/tier5-src/_shared/member-screen.ts +99 -0
  24. package/templates/events-meetups/tier5-src/himi-store-account/index.ts +71 -4
  25. package/templates/gym-fitness/tier5-src/_shared/member-screen.ts +99 -0
  26. package/templates/gym-fitness/tier5-src/himi-booking-service/index.ts +10 -0
  27. package/templates/gym-fitness/tier5-src/himi-booking-time/index.ts +20 -5
  28. package/templates/gym-fitness/tier5-src/himi-store-account/index.ts +71 -4
  29. package/templates/nonprofit-cause/tier5-src/_shared/member-screen.ts +99 -0
  30. package/templates/nonprofit-cause/tier5-src/himi-store-account/index.ts +71 -4
  31. package/templates/podcast-creator/tier5-src/_shared/member-screen.ts +99 -0
  32. package/templates/podcast-creator/tier5-src/himi-store-account/index.ts +71 -4
  33. package/templates/portfolio-creative/tier5-src/_shared/member-screen.ts +99 -0
  34. package/templates/portfolio-creative/tier5-src/himi-store-account/index.ts +71 -4
  35. package/templates/restaurant/tier5-src/_shared/member-screen.ts +99 -0
  36. package/templates/restaurant/tier5-src/himi-store-account/index.ts +71 -4
  37. package/templates/retail-store/tier5-src/_shared/member-screen.ts +99 -0
  38. package/templates/retail-store/tier5-src/himi-store-account/index.ts +71 -4
  39. package/templates/salon-spa/dev/index.ts +16 -12
  40. package/templates/salon-spa/tier5-src/_shared/member-screen.ts +99 -0
  41. package/templates/salon-spa/tier5-src/himi-booking-account/index.ts +12 -1
  42. package/templates/salon-spa/tier5-src/himi-booking-service/index.ts +10 -0
  43. package/templates/salon-spa/tier5-src/himi-booking-time/index.ts +20 -5
  44. package/templates/salon-spa/tier5-src/himi-salon-home/index.ts +17 -27
  45. package/templates/salon-spa/tier5-src/himi-store-account/index.ts +71 -4
  46. package/templates/yoga-studio/tier5-src/_shared/member-screen.ts +99 -0
  47. package/templates/yoga-studio/tier5-src/himi-booking-service/index.ts +10 -0
  48. package/templates/yoga-studio/tier5-src/himi-booking-time/index.ts +20 -5
  49. package/templates/yoga-studio/tier5-src/himi-store-account/index.ts +71 -4
@@ -16,6 +16,7 @@ import { guestProfile, loadMemberProfile, signedInEmail, strOf, fmtDate, titleCa
16
16
  import { stashCopy, copyParam, copyTemplate } from "../_shared/himi-copy.js";
17
17
  import { signInPageStyle, signInSheetStyle } from "../_shared/sign-in-sheet.js";
18
18
  import { memberAccountRoutes } from "../_shared/member-account-routes.js";
19
+ import { CONTINUATION_BUDGET_MS, memberScreenTarget, within } from "../_shared/member-screen.js";
19
20
  import { createIapCommerce, onlineProgramOrders, pricingPlanOrders, storesAppleSalesEnabled, storesProductOrders } from "@himalaya/iap-checkout";
20
21
  import { IAP_RESTORE_KEYS, NO_IAP_RESTORE, createIapRestore, resetUnhydratedKeysOnOlderRuntime, type IapRestoreFields } from "../_shared/iap-worker.js";
21
22
 
@@ -99,12 +100,24 @@ function resumeTarget(s: Pick<S, "returnScreenId" | "returnId" | "returnChannelI
99
100
  * all, so the modal is also dismissed directly: it always closes, and the row opens where
100
101
  * the tab exists. With no `returnTab` it only closes, and the screen under it loads again —
101
102
  * the screen that opened the modal is the return target. */
102
- function resumeAfterAuth(next: S): S {
103
+ async function resumeAfterAuth(next: S): Promise<S> {
103
104
  const target = resumeTarget(next);
104
105
  if (!next.isMember) return next;
105
106
  const tab = routeInput().modal === "1" ? routeInput().returnTab ?? "" : "";
106
107
  if (target && tab && next.standalone) {
107
108
  routeInputConsumed = true;
109
+ // The opener's continuation is spent first, so a later form replacement cannot resume it too.
110
+ // "refused" means another form already spent it, or it expired. A host may replace this form
111
+ // when the account changes yet let this sign-in finish (Android Himi Player parks the old
112
+ // worker alive): the replacement opened the screen, so this form only closes. A continuation
113
+ // lives 5 min from the tap, and a guest can take longer (Forgot your password?): a form shown
114
+ // about that long resumes, so an expiry never costs them the screen.
115
+ if (routeInput().authContinuation) {
116
+ const answer = await within(consumeContinuation(target.screenId), CONTINUATION_BUDGET_MS, "unsupported" as const);
117
+ if (answer === "refused" && Date.now() - formShownAt < CONTINUATION_LIFETIME_MS - CONTINUATION_MARGIN_MS) {
118
+ return navigate(derive({ ...next, ...NO_VISIT }), { presentation: leaveNav() });
119
+ }
120
+ }
108
121
  void dispatch("himi.open", { presentation: "dismiss" });
109
122
  const cleared = derive({ ...next, authIntent: "", authContextName: "", returnScreenId: "", returnId: "", returnChannelId: "" });
110
123
  return navigate(cleared, target.args ? { tab, screenId: target.screenId, args: target.args } : { tab, screenId: target.screenId });
@@ -115,6 +128,59 @@ function resumeAfterAuth(next: S): S {
115
128
  return navigate(cleared, target);
116
129
  }
117
130
 
131
+ /** How long a host keeps a continuation: 300 s in all three (web authContinuation.ts, iOS and Android
132
+ * AuthProvider). A form shown that long has outlived the one it was opened with. The margin covers
133
+ * the time between the tap and the form's appear. */
134
+ const CONTINUATION_LIFETIME_MS = 300_000;
135
+ const CONTINUATION_MARGIN_MS = 15_000;
136
+ /** When this visit's form appeared (`appearConfig`), for the continuation's lifetime above. */
137
+ let formShownAt = Date.now();
138
+
139
+ /** Spend the host-held continuation an opener began for `screenId` (_shared/member-screen.ts).
140
+ * "confirmed" once, and only after a sign-in made on this form confirmed it for the member signed
141
+ * in now; "refused" otherwise (spent, cancelled, expired, forged); "unsupported" on a host without
142
+ * the contract. */
143
+ async function consumeContinuation(screenId: string): Promise<"confirmed" | "refused" | "unsupported"> {
144
+ try {
145
+ const value = await dispatch("himi.wix.authContinuation", { operation: "consume", target: memberScreenTarget(screenId) }) as
146
+ { supported?: unknown; confirmed?: unknown; payload?: { supported?: unknown; confirmed?: unknown } } | null;
147
+ const fields = value?.payload ?? value;
148
+ if (fields?.supported !== true) return "unsupported";
149
+ return fields.confirmed === true ? "confirmed" : "refused";
150
+ } catch {
151
+ return "unsupported";
152
+ }
153
+ }
154
+
155
+ /** A modal form whose sign-in replaced this worker. On Android the account change of a sign-in
156
+ * boots a new worker for the open form before `authenticate` returns, so resumeAfterAuth never
157
+ * runs, and this worker sees only a member on the form, which settle sends back. The return
158
+ * path resumes here only with the opener's continuation, which the sign-in on this form
159
+ * confirmed and the host spends once; a route alone never opens it (see settle). */
160
+ async function resumeFromContinuation(next: S, arg: unknown): Promise<S | null> {
161
+ const route = routeInput();
162
+ // Not gated on `routeInputConsumed`: the replacement's boot load settles first and marks the
163
+ // route used. The host's consume is the one-shot authority.
164
+ if (!next.standalone || !next.isMember || strField(arg, "standalone") !== "1") return null;
165
+ if (route.modal !== "1" || !route.returnTab || !route.authContinuation) return null;
166
+ const returnPath = { returnScreenId: route.returnScreenId ?? "", returnId: route.returnId ?? "", returnChannelId: route.returnChannelId ?? "" };
167
+ const target = resumeTarget(returnPath);
168
+ if (!target || await within(consumeContinuation(target.screenId), CONTINUATION_BUDGET_MS, "unsupported" as const) !== "confirmed") return null;
169
+ routeInputConsumed = true;
170
+ void dispatch("himi.open", { presentation: "dismiss" });
171
+ const cleared = derive({ ...next, ...NO_VISIT });
172
+ return navigate(cleared, target.args ? { tab: route.returnTab, screenId: target.screenId, args: target.args } : { tab: route.returnTab, screenId: target.screenId });
173
+ }
174
+
175
+ /** After a probe: a form a sign-in replaced resumes its return path; anything else settles. */
176
+ async function afterProbe(r: { next: S; latest: boolean } | { kept: S; latest: boolean }, arg: unknown): Promise<S> {
177
+ if ("next" in r && r.latest) {
178
+ const resumed = await resumeFromContinuation(r.next, arg);
179
+ if (resumed) return resumed;
180
+ }
181
+ return "next" in r ? settle(r.next, arg, r.latest) : r.latest ? settle(r.kept, arg, true) : r.kept;
182
+ }
183
+
118
184
  /** Account with a standalone sign-in screen (`signInScreen` appear param): a guest who
119
185
  * arrives with a sign-in intent or a return path — a member gate, an old deep link — is
120
186
  * sent on to that screen with the same params, once. */
@@ -265,6 +331,7 @@ function appearConfig(s: S, arg: unknown): AppearConfig {
265
331
  // later visit with the same params, after an earlier visit consumed the route.
266
332
  if (appearing) {
267
333
  routeInputConsumed = false;
334
+ formShownAt = Date.now();
268
335
  // A pooled worker serves the next visitor too: the fields mount empty, so the last
269
336
  // visit's draft must not be what Sign in submits.
270
337
  passwordDraft = "";
@@ -374,7 +441,7 @@ async function authenticate(s: S, operation: "signIn" | "register"): Promise<S |
374
441
  if (revision !== editRevision) return derive({ ...svc.getState(), authBusy: false });
375
442
  if (!next.isMember) throw { code: "unknown" };
376
443
  passwordDraft = "";
377
- return resumeAfterAuth(completedAuth(next));
444
+ return await resumeAfterAuth(completedAuth(next));
378
445
  } catch (error) {
379
446
  return derive({ ...svc.getState(), authBusy: false,
380
447
  message: revision === editRevision ? authFailure(error, operation, translated).reason : "" });
@@ -810,8 +877,8 @@ const svc = defineService<S, {
810
877
  actions: {
811
878
  submit: (s): Promise<S | undefined> => s.isRecovering ? svc.resetPassword() : authenticate(s, s.isRegistering ? "register" : "signIn"),
812
879
  beginAuth: (s) => derive({ ...s, authBusy: true, message: "", emailError: "", passwordError: "" }),
813
- load: async (s, arg): Promise<S> => { stashScreenCopy(arg); const r = await freshProbe(s, arg); return "next" in r ? settle(r.next, arg, r.latest) : r.latest ? settle(r.kept, arg, true) : r.kept; },
814
- refresh: async (s, arg): Promise<S> => { stashScreenCopy(arg); const r = await freshProbe(s, arg); return "next" in r ? settle(r.next, arg, r.latest) : r.latest ? settle(r.kept, arg, true) : r.kept; },
880
+ load: async (s, arg): Promise<S> => { stashScreenCopy(arg); return afterProbe(await freshProbe(s, arg), arg); },
881
+ refresh: async (s, arg): Promise<S> => { stashScreenCopy(arg); return afterProbe(await freshProbe(s, arg), arg); },
815
882
  // Idle ticks return undefined, so an unchanged session costs no re-render.
816
883
  sync: async (s): Promise<S | undefined> => {
817
884
  if (authInFlight) return undefined;