@wix/himalaya-cli 0.1776.0 → 0.1777.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/cli.mjs +62 -8
- package/guides/himi-json-output.md +4 -1
- package/guides/one-app-to-himi-app.md +8 -3
- package/package.json +2 -2
- package/templates/beauty-salon/dev/index.ts +2 -2
- package/templates/beauty-salon/tier5-src/himi-store-account/index.ts +55 -3
- package/templates/branded-lite/dev/index.ts +2 -2
- package/templates/branded-lite/tier5-src/himi-store-account/index.ts +55 -3
- package/templates/brandy/tier5-src/himi-store-account/index.ts +55 -3
- package/templates/community-club/dev/index.ts +2 -2
- package/templates/community-club/tier5-src/himi-store-account/index.ts +55 -3
- package/templates/conference/tier5-src/himi-store-account/index.ts +55 -3
- package/templates/events-meetups/dev/index.ts +2 -2
- package/templates/events-meetups/tier5-src/himi-store-account/index.ts +55 -3
- package/templates/fitness-gym/tier5-src/himi-store-account/index.ts +55 -3
- package/templates/gym-fitness/dev/index.ts +2 -2
- package/templates/gym-fitness/tier5-src/himi-store-account/index.ts +55 -3
- package/templates/medical-services/tier5-src/himi-store-account/index.ts +55 -3
- package/templates/nonprofit-cause/dev/index.ts +2 -2
- package/templates/nonprofit-cause/tier5-src/himi-store-account/index.ts +55 -3
- package/templates/personal-fitness-trainer/dev/index.ts +2 -2
- package/templates/personal-fitness-trainer/tier5-src/himi-store-account/index.ts +55 -3
- package/templates/podcast-creator/dev/index.ts +2 -2
- package/templates/podcast-creator/tier5-src/himi-store-account/index.ts +55 -3
- package/templates/portfolio-creative/dev/index.ts +2 -2
- package/templates/portfolio-creative/tier5-src/himi-store-account/index.ts +55 -3
- package/templates/restaurant/dev/index.ts +2 -2
- package/templates/restaurant/tier5-src/himi-store-account/index.ts +55 -3
- package/templates/retail-store/dev/index.ts +2 -2
- package/templates/retail-store/tier5-src/himi-store-account/index.ts +55 -3
- package/templates/salon-spa/tier5-src/himi-store-account/index.ts +55 -3
- package/templates/wholesale-store/tier5-src/himi-store-account/index.ts +55 -3
- package/templates/yoga-studio/dev/index.ts +2 -2
- package/templates/yoga-studio/tier5-src/himi-store-account/index.ts +55 -3
|
@@ -278,7 +278,7 @@ const NO_VISIT = {
|
|
|
278
278
|
const VISIT_KEYS = Object.keys(NO_VISIT) as (keyof typeof NO_VISIT)[];
|
|
279
279
|
/** What derive() computes from the visit keys. Hydration copies keys without re-deriving,
|
|
280
280
|
* so these stay out of the snapshot with them, or the first paint mixes two visits. */
|
|
281
|
-
const VISIT_DERIVED_KEYS = ["notRegistering", "notRecovering", "hideSignInChoices", "authTitle", "authBody",
|
|
281
|
+
const VISIT_DERIVED_KEYS = ["notRegistering", "notRecovering", "hideSignInChoices", "hideShowRegister", "hideShowRecovery", "authTitle", "authBody",
|
|
282
282
|
"hasReturnPath", "noReturnPath", "returnCta"] as const;
|
|
283
283
|
|
|
284
284
|
// Actions are not serialized: two quick Sign in taps both run against the pre-tap
|
|
@@ -321,7 +321,7 @@ function appearBase(): Partial<S> {
|
|
|
321
321
|
pollIdentity: pollIdentityRequested,
|
|
322
322
|
restorePurchases: restorePurchasesRequested,
|
|
323
323
|
// One `_poll` per state: Account polls identity and never shows the social block.
|
|
324
|
-
...(pollIdentityRequested ? { _poll: { ...IDENTITY_POLL } } : socialRetriesLeft > 0 ? { _poll: { ...SOCIAL_POLL } } : {}),
|
|
324
|
+
...(pollIdentityRequested ? { _poll: { ...IDENTITY_POLL } } : socialRetriesLeft > 0 || flowsRetriesLeft > 0 ? { _poll: { ...SOCIAL_POLL } } : {}),
|
|
325
325
|
};
|
|
326
326
|
}
|
|
327
327
|
|
|
@@ -433,12 +433,46 @@ function applySocialProviders(read: SocialProvidersRead): void {
|
|
|
433
433
|
if (read.ok) socialProviders = read.providers;
|
|
434
434
|
}
|
|
435
435
|
|
|
436
|
+
// Which member flows this binding can run (the host's `himi.wix.memberFlows`). A One App binding with no Headless OAuth client
|
|
437
|
+
// signs members in with email and password only, so Create account and Forgot password would fail: the form hides them. Module
|
|
438
|
+
// state like the providers above. A host without the action (web, an older binary) never answers, and the form keeps both,
|
|
439
|
+
// exactly what it showed before.
|
|
440
|
+
let signUpAvailable = true;
|
|
441
|
+
let passwordResetAvailable = true;
|
|
442
|
+
|
|
443
|
+
/** `notReady`: the host said `unavailable` (its auth boot has not wired the provider yet), so the answer is worth asking for again. */
|
|
444
|
+
type MemberFlowsRead = { ok: true; signUp: boolean; passwordReset: boolean } | { ok: false; notReady: boolean };
|
|
445
|
+
|
|
446
|
+
async function readMemberFlows(): Promise<MemberFlowsRead> {
|
|
447
|
+
try {
|
|
448
|
+
const raw = await dispatch("himi.wix.memberFlows") as { status?: unknown; payload?: Record<string, unknown>; signUp?: unknown; passwordReset?: unknown } | null;
|
|
449
|
+
const answer = raw?.payload ?? raw;
|
|
450
|
+
return typeof answer?.signUp === "boolean" && typeof answer?.passwordReset === "boolean"
|
|
451
|
+
? { ok: true, signUp: answer.signUp, passwordReset: answer.passwordReset }
|
|
452
|
+
: { ok: false, notReady: raw?.status === "unavailable" };
|
|
453
|
+
} catch {
|
|
454
|
+
return { ok: false, notReady: false };
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
/** A failed or missing read keeps what the last read showed (both flows until a host says otherwise). */
|
|
459
|
+
function applyMemberFlows(read: MemberFlowsRead): void {
|
|
460
|
+
if (read.ok) { signUpAvailable = read.signUp; passwordResetAvailable = read.passwordReset; }
|
|
461
|
+
}
|
|
462
|
+
|
|
436
463
|
// An empty list is also what the host answers before its auth boot has wired the provider (a
|
|
437
464
|
// cold launch straight onto the form), so it is re-read on a short poll; a site with no social
|
|
438
465
|
// login stops after a few reads.
|
|
439
466
|
const SOCIAL_POLL = { id: "himi-account-social", intervalMs: 1500, action: "himiStoreAccount.refreshSocial" };
|
|
440
467
|
const SOCIAL_RETRIES = 4;
|
|
441
468
|
let socialRetriesLeft = 0;
|
|
469
|
+
// The member flows are read on the same short poll: before the host's auth boot has wired the provider (a cold launch straight
|
|
470
|
+
// onto the gate screen) it answers `unavailable` and is asked again; a host that does not know the verb (web, an older binary) is not.
|
|
471
|
+
let flowsRetriesLeft = 0;
|
|
472
|
+
|
|
473
|
+
function armFlowsRetry(read: MemberFlowsRead): void {
|
|
474
|
+
flowsRetriesLeft = !read.ok && read.notReady ? SOCIAL_RETRIES : 0;
|
|
475
|
+
}
|
|
442
476
|
|
|
443
477
|
function armSocialRetry(read: SocialProvidersRead): void {
|
|
444
478
|
if (read.ok) socialRetriesLeft = read.providers.length ? 0 : SOCIAL_RETRIES;
|
|
@@ -450,8 +484,14 @@ async function refreshSocial(): Promise<S> {
|
|
|
450
484
|
applySocialProviders(await readSocialProviders());
|
|
451
485
|
if (socialProviders.length) socialRetriesLeft = 0;
|
|
452
486
|
}
|
|
487
|
+
if (flowsRetriesLeft > 0) {
|
|
488
|
+
flowsRetriesLeft -= 1;
|
|
489
|
+
const flows = await readMemberFlows();
|
|
490
|
+
applyMemberFlows(flows);
|
|
491
|
+
if (flows.ok || !flows.notReady) flowsRetriesLeft = 0;
|
|
492
|
+
}
|
|
453
493
|
const current = svc.getState();
|
|
454
|
-
return derive({ ...current, ...(socialRetriesLeft > 0 ? {} : { _poll: { id: SOCIAL_POLL.id, stop: true } }) });
|
|
494
|
+
return derive({ ...current, ...(socialRetriesLeft > 0 || flowsRetriesLeft > 0 ? {} : { _poll: { id: SOCIAL_POLL.id, stop: true } }) });
|
|
455
495
|
}
|
|
456
496
|
|
|
457
497
|
function socialCancelled(raw: unknown): boolean {
|
|
@@ -664,6 +704,10 @@ interface S extends IapRestoreFields {
|
|
|
664
704
|
isRecovering: boolean;
|
|
665
705
|
notRecovering: boolean;
|
|
666
706
|
hideSignInChoices: boolean;
|
|
707
|
+
/** The form's Create account / Forgot password links: hidden while registering or recovering, and when the binding
|
|
708
|
+
* cannot run the flow (`himi.wix.memberFlows`). */
|
|
709
|
+
hideShowRegister: boolean;
|
|
710
|
+
hideShowRecovery: boolean;
|
|
667
711
|
hideAppleSignIn: boolean;
|
|
668
712
|
hideGoogleSignIn: boolean;
|
|
669
713
|
/** The social block and its "or" divider: no provider to show, or resetting a password. */
|
|
@@ -755,6 +799,8 @@ function derive(s: S): S {
|
|
|
755
799
|
isRecovering,
|
|
756
800
|
notRecovering: !isRecovering,
|
|
757
801
|
hideSignInChoices: isRegistering || isRecovering,
|
|
802
|
+
hideShowRegister: isRegistering || isRecovering || !signUpAvailable,
|
|
803
|
+
hideShowRecovery: isRegistering || isRecovering || !passwordResetAvailable,
|
|
758
804
|
hideAppleSignIn: !socialProviders.includes("apple"),
|
|
759
805
|
hideGoogleSignIn: !socialProviders.includes("google"),
|
|
760
806
|
hideSocialSignIn: isRecovering || socialProviders.length === 0,
|
|
@@ -833,9 +879,13 @@ async function probe(s: S, arg?: unknown, config: AppearConfig = appearConfig(s,
|
|
|
833
879
|
// snapshot restored, not a 0 that would empty the badge until the appear refresh lands.
|
|
834
880
|
const cartCountRead = cartCountRequested ? cartItemCount(s.cartCount ?? 0) : Promise.resolve(s.cartCount ?? 0);
|
|
835
881
|
const socialRead: Promise<SocialProvidersRead> = standaloneRequested ? readSocialProviders() : Promise.resolve({ ok: false });
|
|
882
|
+
const flowsRead: Promise<MemberFlowsRead> = standaloneRequested ? readMemberFlows() : Promise.resolve({ ok: false, notReady: false });
|
|
836
883
|
const profile = await loadMemberProfile(copyParam("storeAccount.guestDetail", "Sign in to keep your cart and orders connected."));
|
|
837
884
|
const social = await socialRead;
|
|
838
885
|
applySocialProviders(social);
|
|
886
|
+
const flows = await flowsRead;
|
|
887
|
+
applyMemberFlows(flows);
|
|
888
|
+
armFlowsRetry(flows);
|
|
839
889
|
armSocialRetry(social);
|
|
840
890
|
// Not the boot load: it never carries the copy, and the appear refresh that does is coming.
|
|
841
891
|
if (strField(arg, "boot") !== "1") headingReady = true;
|
|
@@ -965,6 +1015,8 @@ const svc = defineService<S, {
|
|
|
965
1015
|
isRecovering: false,
|
|
966
1016
|
notRecovering: true,
|
|
967
1017
|
hideSignInChoices: false,
|
|
1018
|
+
hideShowRegister: false,
|
|
1019
|
+
hideShowRecovery: false,
|
|
968
1020
|
hideAppleSignIn: true,
|
|
969
1021
|
hideGoogleSignIn: true,
|
|
970
1022
|
hideSocialSignIn: true,
|
|
@@ -5883,7 +5883,7 @@ const SCREENS = runtimeSetting({
|
|
|
5883
5883
|
}
|
|
5884
5884
|
},
|
|
5885
5885
|
"modifiers": {
|
|
5886
|
-
"hiddenPath": "$service:himiStoreAccount.
|
|
5886
|
+
"hiddenPath": "$service:himiStoreAccount.hideShowRegister"
|
|
5887
5887
|
}
|
|
5888
5888
|
},
|
|
5889
5889
|
{
|
|
@@ -5940,7 +5940,7 @@ const SCREENS = runtimeSetting({
|
|
|
5940
5940
|
}
|
|
5941
5941
|
},
|
|
5942
5942
|
"modifiers": {
|
|
5943
|
-
"hiddenPath": "$service:himiStoreAccount.
|
|
5943
|
+
"hiddenPath": "$service:himiStoreAccount.hideShowRecovery"
|
|
5944
5944
|
}
|
|
5945
5945
|
}
|
|
5946
5946
|
]
|
|
@@ -278,7 +278,7 @@ const NO_VISIT = {
|
|
|
278
278
|
const VISIT_KEYS = Object.keys(NO_VISIT) as (keyof typeof NO_VISIT)[];
|
|
279
279
|
/** What derive() computes from the visit keys. Hydration copies keys without re-deriving,
|
|
280
280
|
* so these stay out of the snapshot with them, or the first paint mixes two visits. */
|
|
281
|
-
const VISIT_DERIVED_KEYS = ["notRegistering", "notRecovering", "hideSignInChoices", "authTitle", "authBody",
|
|
281
|
+
const VISIT_DERIVED_KEYS = ["notRegistering", "notRecovering", "hideSignInChoices", "hideShowRegister", "hideShowRecovery", "authTitle", "authBody",
|
|
282
282
|
"hasReturnPath", "noReturnPath", "returnCta"] as const;
|
|
283
283
|
|
|
284
284
|
// Actions are not serialized: two quick Sign in taps both run against the pre-tap
|
|
@@ -321,7 +321,7 @@ function appearBase(): Partial<S> {
|
|
|
321
321
|
pollIdentity: pollIdentityRequested,
|
|
322
322
|
restorePurchases: restorePurchasesRequested,
|
|
323
323
|
// One `_poll` per state: Account polls identity and never shows the social block.
|
|
324
|
-
...(pollIdentityRequested ? { _poll: { ...IDENTITY_POLL } } : socialRetriesLeft > 0 ? { _poll: { ...SOCIAL_POLL } } : {}),
|
|
324
|
+
...(pollIdentityRequested ? { _poll: { ...IDENTITY_POLL } } : socialRetriesLeft > 0 || flowsRetriesLeft > 0 ? { _poll: { ...SOCIAL_POLL } } : {}),
|
|
325
325
|
};
|
|
326
326
|
}
|
|
327
327
|
|
|
@@ -433,12 +433,46 @@ function applySocialProviders(read: SocialProvidersRead): void {
|
|
|
433
433
|
if (read.ok) socialProviders = read.providers;
|
|
434
434
|
}
|
|
435
435
|
|
|
436
|
+
// Which member flows this binding can run (the host's `himi.wix.memberFlows`). A One App binding with no Headless OAuth client
|
|
437
|
+
// signs members in with email and password only, so Create account and Forgot password would fail: the form hides them. Module
|
|
438
|
+
// state like the providers above. A host without the action (web, an older binary) never answers, and the form keeps both,
|
|
439
|
+
// exactly what it showed before.
|
|
440
|
+
let signUpAvailable = true;
|
|
441
|
+
let passwordResetAvailable = true;
|
|
442
|
+
|
|
443
|
+
/** `notReady`: the host said `unavailable` (its auth boot has not wired the provider yet), so the answer is worth asking for again. */
|
|
444
|
+
type MemberFlowsRead = { ok: true; signUp: boolean; passwordReset: boolean } | { ok: false; notReady: boolean };
|
|
445
|
+
|
|
446
|
+
async function readMemberFlows(): Promise<MemberFlowsRead> {
|
|
447
|
+
try {
|
|
448
|
+
const raw = await dispatch("himi.wix.memberFlows") as { status?: unknown; payload?: Record<string, unknown>; signUp?: unknown; passwordReset?: unknown } | null;
|
|
449
|
+
const answer = raw?.payload ?? raw;
|
|
450
|
+
return typeof answer?.signUp === "boolean" && typeof answer?.passwordReset === "boolean"
|
|
451
|
+
? { ok: true, signUp: answer.signUp, passwordReset: answer.passwordReset }
|
|
452
|
+
: { ok: false, notReady: raw?.status === "unavailable" };
|
|
453
|
+
} catch {
|
|
454
|
+
return { ok: false, notReady: false };
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
/** A failed or missing read keeps what the last read showed (both flows until a host says otherwise). */
|
|
459
|
+
function applyMemberFlows(read: MemberFlowsRead): void {
|
|
460
|
+
if (read.ok) { signUpAvailable = read.signUp; passwordResetAvailable = read.passwordReset; }
|
|
461
|
+
}
|
|
462
|
+
|
|
436
463
|
// An empty list is also what the host answers before its auth boot has wired the provider (a
|
|
437
464
|
// cold launch straight onto the form), so it is re-read on a short poll; a site with no social
|
|
438
465
|
// login stops after a few reads.
|
|
439
466
|
const SOCIAL_POLL = { id: "himi-account-social", intervalMs: 1500, action: "himiStoreAccount.refreshSocial" };
|
|
440
467
|
const SOCIAL_RETRIES = 4;
|
|
441
468
|
let socialRetriesLeft = 0;
|
|
469
|
+
// The member flows are read on the same short poll: before the host's auth boot has wired the provider (a cold launch straight
|
|
470
|
+
// onto the gate screen) it answers `unavailable` and is asked again; a host that does not know the verb (web, an older binary) is not.
|
|
471
|
+
let flowsRetriesLeft = 0;
|
|
472
|
+
|
|
473
|
+
function armFlowsRetry(read: MemberFlowsRead): void {
|
|
474
|
+
flowsRetriesLeft = !read.ok && read.notReady ? SOCIAL_RETRIES : 0;
|
|
475
|
+
}
|
|
442
476
|
|
|
443
477
|
function armSocialRetry(read: SocialProvidersRead): void {
|
|
444
478
|
if (read.ok) socialRetriesLeft = read.providers.length ? 0 : SOCIAL_RETRIES;
|
|
@@ -450,8 +484,14 @@ async function refreshSocial(): Promise<S> {
|
|
|
450
484
|
applySocialProviders(await readSocialProviders());
|
|
451
485
|
if (socialProviders.length) socialRetriesLeft = 0;
|
|
452
486
|
}
|
|
487
|
+
if (flowsRetriesLeft > 0) {
|
|
488
|
+
flowsRetriesLeft -= 1;
|
|
489
|
+
const flows = await readMemberFlows();
|
|
490
|
+
applyMemberFlows(flows);
|
|
491
|
+
if (flows.ok || !flows.notReady) flowsRetriesLeft = 0;
|
|
492
|
+
}
|
|
453
493
|
const current = svc.getState();
|
|
454
|
-
return derive({ ...current, ...(socialRetriesLeft > 0 ? {} : { _poll: { id: SOCIAL_POLL.id, stop: true } }) });
|
|
494
|
+
return derive({ ...current, ...(socialRetriesLeft > 0 || flowsRetriesLeft > 0 ? {} : { _poll: { id: SOCIAL_POLL.id, stop: true } }) });
|
|
455
495
|
}
|
|
456
496
|
|
|
457
497
|
function socialCancelled(raw: unknown): boolean {
|
|
@@ -664,6 +704,10 @@ interface S extends IapRestoreFields {
|
|
|
664
704
|
isRecovering: boolean;
|
|
665
705
|
notRecovering: boolean;
|
|
666
706
|
hideSignInChoices: boolean;
|
|
707
|
+
/** The form's Create account / Forgot password links: hidden while registering or recovering, and when the binding
|
|
708
|
+
* cannot run the flow (`himi.wix.memberFlows`). */
|
|
709
|
+
hideShowRegister: boolean;
|
|
710
|
+
hideShowRecovery: boolean;
|
|
667
711
|
hideAppleSignIn: boolean;
|
|
668
712
|
hideGoogleSignIn: boolean;
|
|
669
713
|
/** The social block and its "or" divider: no provider to show, or resetting a password. */
|
|
@@ -755,6 +799,8 @@ function derive(s: S): S {
|
|
|
755
799
|
isRecovering,
|
|
756
800
|
notRecovering: !isRecovering,
|
|
757
801
|
hideSignInChoices: isRegistering || isRecovering,
|
|
802
|
+
hideShowRegister: isRegistering || isRecovering || !signUpAvailable,
|
|
803
|
+
hideShowRecovery: isRegistering || isRecovering || !passwordResetAvailable,
|
|
758
804
|
hideAppleSignIn: !socialProviders.includes("apple"),
|
|
759
805
|
hideGoogleSignIn: !socialProviders.includes("google"),
|
|
760
806
|
hideSocialSignIn: isRecovering || socialProviders.length === 0,
|
|
@@ -833,9 +879,13 @@ async function probe(s: S, arg?: unknown, config: AppearConfig = appearConfig(s,
|
|
|
833
879
|
// snapshot restored, not a 0 that would empty the badge until the appear refresh lands.
|
|
834
880
|
const cartCountRead = cartCountRequested ? cartItemCount(s.cartCount ?? 0) : Promise.resolve(s.cartCount ?? 0);
|
|
835
881
|
const socialRead: Promise<SocialProvidersRead> = standaloneRequested ? readSocialProviders() : Promise.resolve({ ok: false });
|
|
882
|
+
const flowsRead: Promise<MemberFlowsRead> = standaloneRequested ? readMemberFlows() : Promise.resolve({ ok: false, notReady: false });
|
|
836
883
|
const profile = await loadMemberProfile(copyParam("storeAccount.guestDetail", "Sign in to keep your cart and orders connected."));
|
|
837
884
|
const social = await socialRead;
|
|
838
885
|
applySocialProviders(social);
|
|
886
|
+
const flows = await flowsRead;
|
|
887
|
+
applyMemberFlows(flows);
|
|
888
|
+
armFlowsRetry(flows);
|
|
839
889
|
armSocialRetry(social);
|
|
840
890
|
// Not the boot load: it never carries the copy, and the appear refresh that does is coming.
|
|
841
891
|
if (strField(arg, "boot") !== "1") headingReady = true;
|
|
@@ -965,6 +1015,8 @@ const svc = defineService<S, {
|
|
|
965
1015
|
isRecovering: false,
|
|
966
1016
|
notRecovering: true,
|
|
967
1017
|
hideSignInChoices: false,
|
|
1018
|
+
hideShowRegister: false,
|
|
1019
|
+
hideShowRecovery: false,
|
|
968
1020
|
hideAppleSignIn: true,
|
|
969
1021
|
hideGoogleSignIn: true,
|
|
970
1022
|
hideSocialSignIn: true,
|
|
@@ -10644,7 +10644,7 @@ const SCREENS = runtimeSetting({
|
|
|
10644
10644
|
}
|
|
10645
10645
|
},
|
|
10646
10646
|
"modifiers": {
|
|
10647
|
-
"hiddenPath": "$service:himiStoreAccount.
|
|
10647
|
+
"hiddenPath": "$service:himiStoreAccount.hideShowRegister"
|
|
10648
10648
|
}
|
|
10649
10649
|
},
|
|
10650
10650
|
{
|
|
@@ -10701,7 +10701,7 @@ const SCREENS = runtimeSetting({
|
|
|
10701
10701
|
}
|
|
10702
10702
|
},
|
|
10703
10703
|
"modifiers": {
|
|
10704
|
-
"hiddenPath": "$service:himiStoreAccount.
|
|
10704
|
+
"hiddenPath": "$service:himiStoreAccount.hideShowRecovery"
|
|
10705
10705
|
}
|
|
10706
10706
|
}
|
|
10707
10707
|
]
|
|
@@ -278,7 +278,7 @@ const NO_VISIT = {
|
|
|
278
278
|
const VISIT_KEYS = Object.keys(NO_VISIT) as (keyof typeof NO_VISIT)[];
|
|
279
279
|
/** What derive() computes from the visit keys. Hydration copies keys without re-deriving,
|
|
280
280
|
* so these stay out of the snapshot with them, or the first paint mixes two visits. */
|
|
281
|
-
const VISIT_DERIVED_KEYS = ["notRegistering", "notRecovering", "hideSignInChoices", "authTitle", "authBody",
|
|
281
|
+
const VISIT_DERIVED_KEYS = ["notRegistering", "notRecovering", "hideSignInChoices", "hideShowRegister", "hideShowRecovery", "authTitle", "authBody",
|
|
282
282
|
"hasReturnPath", "noReturnPath", "returnCta"] as const;
|
|
283
283
|
|
|
284
284
|
// Actions are not serialized: two quick Sign in taps both run against the pre-tap
|
|
@@ -321,7 +321,7 @@ function appearBase(): Partial<S> {
|
|
|
321
321
|
pollIdentity: pollIdentityRequested,
|
|
322
322
|
restorePurchases: restorePurchasesRequested,
|
|
323
323
|
// One `_poll` per state: Account polls identity and never shows the social block.
|
|
324
|
-
...(pollIdentityRequested ? { _poll: { ...IDENTITY_POLL } } : socialRetriesLeft > 0 ? { _poll: { ...SOCIAL_POLL } } : {}),
|
|
324
|
+
...(pollIdentityRequested ? { _poll: { ...IDENTITY_POLL } } : socialRetriesLeft > 0 || flowsRetriesLeft > 0 ? { _poll: { ...SOCIAL_POLL } } : {}),
|
|
325
325
|
};
|
|
326
326
|
}
|
|
327
327
|
|
|
@@ -433,12 +433,46 @@ function applySocialProviders(read: SocialProvidersRead): void {
|
|
|
433
433
|
if (read.ok) socialProviders = read.providers;
|
|
434
434
|
}
|
|
435
435
|
|
|
436
|
+
// Which member flows this binding can run (the host's `himi.wix.memberFlows`). A One App binding with no Headless OAuth client
|
|
437
|
+
// signs members in with email and password only, so Create account and Forgot password would fail: the form hides them. Module
|
|
438
|
+
// state like the providers above. A host without the action (web, an older binary) never answers, and the form keeps both,
|
|
439
|
+
// exactly what it showed before.
|
|
440
|
+
let signUpAvailable = true;
|
|
441
|
+
let passwordResetAvailable = true;
|
|
442
|
+
|
|
443
|
+
/** `notReady`: the host said `unavailable` (its auth boot has not wired the provider yet), so the answer is worth asking for again. */
|
|
444
|
+
type MemberFlowsRead = { ok: true; signUp: boolean; passwordReset: boolean } | { ok: false; notReady: boolean };
|
|
445
|
+
|
|
446
|
+
async function readMemberFlows(): Promise<MemberFlowsRead> {
|
|
447
|
+
try {
|
|
448
|
+
const raw = await dispatch("himi.wix.memberFlows") as { status?: unknown; payload?: Record<string, unknown>; signUp?: unknown; passwordReset?: unknown } | null;
|
|
449
|
+
const answer = raw?.payload ?? raw;
|
|
450
|
+
return typeof answer?.signUp === "boolean" && typeof answer?.passwordReset === "boolean"
|
|
451
|
+
? { ok: true, signUp: answer.signUp, passwordReset: answer.passwordReset }
|
|
452
|
+
: { ok: false, notReady: raw?.status === "unavailable" };
|
|
453
|
+
} catch {
|
|
454
|
+
return { ok: false, notReady: false };
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
/** A failed or missing read keeps what the last read showed (both flows until a host says otherwise). */
|
|
459
|
+
function applyMemberFlows(read: MemberFlowsRead): void {
|
|
460
|
+
if (read.ok) { signUpAvailable = read.signUp; passwordResetAvailable = read.passwordReset; }
|
|
461
|
+
}
|
|
462
|
+
|
|
436
463
|
// An empty list is also what the host answers before its auth boot has wired the provider (a
|
|
437
464
|
// cold launch straight onto the form), so it is re-read on a short poll; a site with no social
|
|
438
465
|
// login stops after a few reads.
|
|
439
466
|
const SOCIAL_POLL = { id: "himi-account-social", intervalMs: 1500, action: "himiStoreAccount.refreshSocial" };
|
|
440
467
|
const SOCIAL_RETRIES = 4;
|
|
441
468
|
let socialRetriesLeft = 0;
|
|
469
|
+
// The member flows are read on the same short poll: before the host's auth boot has wired the provider (a cold launch straight
|
|
470
|
+
// onto the gate screen) it answers `unavailable` and is asked again; a host that does not know the verb (web, an older binary) is not.
|
|
471
|
+
let flowsRetriesLeft = 0;
|
|
472
|
+
|
|
473
|
+
function armFlowsRetry(read: MemberFlowsRead): void {
|
|
474
|
+
flowsRetriesLeft = !read.ok && read.notReady ? SOCIAL_RETRIES : 0;
|
|
475
|
+
}
|
|
442
476
|
|
|
443
477
|
function armSocialRetry(read: SocialProvidersRead): void {
|
|
444
478
|
if (read.ok) socialRetriesLeft = read.providers.length ? 0 : SOCIAL_RETRIES;
|
|
@@ -450,8 +484,14 @@ async function refreshSocial(): Promise<S> {
|
|
|
450
484
|
applySocialProviders(await readSocialProviders());
|
|
451
485
|
if (socialProviders.length) socialRetriesLeft = 0;
|
|
452
486
|
}
|
|
487
|
+
if (flowsRetriesLeft > 0) {
|
|
488
|
+
flowsRetriesLeft -= 1;
|
|
489
|
+
const flows = await readMemberFlows();
|
|
490
|
+
applyMemberFlows(flows);
|
|
491
|
+
if (flows.ok || !flows.notReady) flowsRetriesLeft = 0;
|
|
492
|
+
}
|
|
453
493
|
const current = svc.getState();
|
|
454
|
-
return derive({ ...current, ...(socialRetriesLeft > 0 ? {} : { _poll: { id: SOCIAL_POLL.id, stop: true } }) });
|
|
494
|
+
return derive({ ...current, ...(socialRetriesLeft > 0 || flowsRetriesLeft > 0 ? {} : { _poll: { id: SOCIAL_POLL.id, stop: true } }) });
|
|
455
495
|
}
|
|
456
496
|
|
|
457
497
|
function socialCancelled(raw: unknown): boolean {
|
|
@@ -664,6 +704,10 @@ interface S extends IapRestoreFields {
|
|
|
664
704
|
isRecovering: boolean;
|
|
665
705
|
notRecovering: boolean;
|
|
666
706
|
hideSignInChoices: boolean;
|
|
707
|
+
/** The form's Create account / Forgot password links: hidden while registering or recovering, and when the binding
|
|
708
|
+
* cannot run the flow (`himi.wix.memberFlows`). */
|
|
709
|
+
hideShowRegister: boolean;
|
|
710
|
+
hideShowRecovery: boolean;
|
|
667
711
|
hideAppleSignIn: boolean;
|
|
668
712
|
hideGoogleSignIn: boolean;
|
|
669
713
|
/** The social block and its "or" divider: no provider to show, or resetting a password. */
|
|
@@ -755,6 +799,8 @@ function derive(s: S): S {
|
|
|
755
799
|
isRecovering,
|
|
756
800
|
notRecovering: !isRecovering,
|
|
757
801
|
hideSignInChoices: isRegistering || isRecovering,
|
|
802
|
+
hideShowRegister: isRegistering || isRecovering || !signUpAvailable,
|
|
803
|
+
hideShowRecovery: isRegistering || isRecovering || !passwordResetAvailable,
|
|
758
804
|
hideAppleSignIn: !socialProviders.includes("apple"),
|
|
759
805
|
hideGoogleSignIn: !socialProviders.includes("google"),
|
|
760
806
|
hideSocialSignIn: isRecovering || socialProviders.length === 0,
|
|
@@ -833,9 +879,13 @@ async function probe(s: S, arg?: unknown, config: AppearConfig = appearConfig(s,
|
|
|
833
879
|
// snapshot restored, not a 0 that would empty the badge until the appear refresh lands.
|
|
834
880
|
const cartCountRead = cartCountRequested ? cartItemCount(s.cartCount ?? 0) : Promise.resolve(s.cartCount ?? 0);
|
|
835
881
|
const socialRead: Promise<SocialProvidersRead> = standaloneRequested ? readSocialProviders() : Promise.resolve({ ok: false });
|
|
882
|
+
const flowsRead: Promise<MemberFlowsRead> = standaloneRequested ? readMemberFlows() : Promise.resolve({ ok: false, notReady: false });
|
|
836
883
|
const profile = await loadMemberProfile(copyParam("storeAccount.guestDetail", "Sign in to keep your cart and orders connected."));
|
|
837
884
|
const social = await socialRead;
|
|
838
885
|
applySocialProviders(social);
|
|
886
|
+
const flows = await flowsRead;
|
|
887
|
+
applyMemberFlows(flows);
|
|
888
|
+
armFlowsRetry(flows);
|
|
839
889
|
armSocialRetry(social);
|
|
840
890
|
// Not the boot load: it never carries the copy, and the appear refresh that does is coming.
|
|
841
891
|
if (strField(arg, "boot") !== "1") headingReady = true;
|
|
@@ -965,6 +1015,8 @@ const svc = defineService<S, {
|
|
|
965
1015
|
isRecovering: false,
|
|
966
1016
|
notRecovering: true,
|
|
967
1017
|
hideSignInChoices: false,
|
|
1018
|
+
hideShowRegister: false,
|
|
1019
|
+
hideShowRecovery: false,
|
|
968
1020
|
hideAppleSignIn: true,
|
|
969
1021
|
hideGoogleSignIn: true,
|
|
970
1022
|
hideSocialSignIn: true,
|
|
@@ -5821,7 +5821,7 @@ const SCREENS = runtimeSetting({
|
|
|
5821
5821
|
}
|
|
5822
5822
|
},
|
|
5823
5823
|
"modifiers": {
|
|
5824
|
-
"hiddenPath": "$service:himiStoreAccount.
|
|
5824
|
+
"hiddenPath": "$service:himiStoreAccount.hideShowRegister"
|
|
5825
5825
|
}
|
|
5826
5826
|
},
|
|
5827
5827
|
{
|
|
@@ -5878,7 +5878,7 @@ const SCREENS = runtimeSetting({
|
|
|
5878
5878
|
}
|
|
5879
5879
|
},
|
|
5880
5880
|
"modifiers": {
|
|
5881
|
-
"hiddenPath": "$service:himiStoreAccount.
|
|
5881
|
+
"hiddenPath": "$service:himiStoreAccount.hideShowRecovery"
|
|
5882
5882
|
}
|
|
5883
5883
|
}
|
|
5884
5884
|
]
|
|
@@ -278,7 +278,7 @@ const NO_VISIT = {
|
|
|
278
278
|
const VISIT_KEYS = Object.keys(NO_VISIT) as (keyof typeof NO_VISIT)[];
|
|
279
279
|
/** What derive() computes from the visit keys. Hydration copies keys without re-deriving,
|
|
280
280
|
* so these stay out of the snapshot with them, or the first paint mixes two visits. */
|
|
281
|
-
const VISIT_DERIVED_KEYS = ["notRegistering", "notRecovering", "hideSignInChoices", "authTitle", "authBody",
|
|
281
|
+
const VISIT_DERIVED_KEYS = ["notRegistering", "notRecovering", "hideSignInChoices", "hideShowRegister", "hideShowRecovery", "authTitle", "authBody",
|
|
282
282
|
"hasReturnPath", "noReturnPath", "returnCta"] as const;
|
|
283
283
|
|
|
284
284
|
// Actions are not serialized: two quick Sign in taps both run against the pre-tap
|
|
@@ -321,7 +321,7 @@ function appearBase(): Partial<S> {
|
|
|
321
321
|
pollIdentity: pollIdentityRequested,
|
|
322
322
|
restorePurchases: restorePurchasesRequested,
|
|
323
323
|
// One `_poll` per state: Account polls identity and never shows the social block.
|
|
324
|
-
...(pollIdentityRequested ? { _poll: { ...IDENTITY_POLL } } : socialRetriesLeft > 0 ? { _poll: { ...SOCIAL_POLL } } : {}),
|
|
324
|
+
...(pollIdentityRequested ? { _poll: { ...IDENTITY_POLL } } : socialRetriesLeft > 0 || flowsRetriesLeft > 0 ? { _poll: { ...SOCIAL_POLL } } : {}),
|
|
325
325
|
};
|
|
326
326
|
}
|
|
327
327
|
|
|
@@ -433,12 +433,46 @@ function applySocialProviders(read: SocialProvidersRead): void {
|
|
|
433
433
|
if (read.ok) socialProviders = read.providers;
|
|
434
434
|
}
|
|
435
435
|
|
|
436
|
+
// Which member flows this binding can run (the host's `himi.wix.memberFlows`). A One App binding with no Headless OAuth client
|
|
437
|
+
// signs members in with email and password only, so Create account and Forgot password would fail: the form hides them. Module
|
|
438
|
+
// state like the providers above. A host without the action (web, an older binary) never answers, and the form keeps both,
|
|
439
|
+
// exactly what it showed before.
|
|
440
|
+
let signUpAvailable = true;
|
|
441
|
+
let passwordResetAvailable = true;
|
|
442
|
+
|
|
443
|
+
/** `notReady`: the host said `unavailable` (its auth boot has not wired the provider yet), so the answer is worth asking for again. */
|
|
444
|
+
type MemberFlowsRead = { ok: true; signUp: boolean; passwordReset: boolean } | { ok: false; notReady: boolean };
|
|
445
|
+
|
|
446
|
+
async function readMemberFlows(): Promise<MemberFlowsRead> {
|
|
447
|
+
try {
|
|
448
|
+
const raw = await dispatch("himi.wix.memberFlows") as { status?: unknown; payload?: Record<string, unknown>; signUp?: unknown; passwordReset?: unknown } | null;
|
|
449
|
+
const answer = raw?.payload ?? raw;
|
|
450
|
+
return typeof answer?.signUp === "boolean" && typeof answer?.passwordReset === "boolean"
|
|
451
|
+
? { ok: true, signUp: answer.signUp, passwordReset: answer.passwordReset }
|
|
452
|
+
: { ok: false, notReady: raw?.status === "unavailable" };
|
|
453
|
+
} catch {
|
|
454
|
+
return { ok: false, notReady: false };
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
/** A failed or missing read keeps what the last read showed (both flows until a host says otherwise). */
|
|
459
|
+
function applyMemberFlows(read: MemberFlowsRead): void {
|
|
460
|
+
if (read.ok) { signUpAvailable = read.signUp; passwordResetAvailable = read.passwordReset; }
|
|
461
|
+
}
|
|
462
|
+
|
|
436
463
|
// An empty list is also what the host answers before its auth boot has wired the provider (a
|
|
437
464
|
// cold launch straight onto the form), so it is re-read on a short poll; a site with no social
|
|
438
465
|
// login stops after a few reads.
|
|
439
466
|
const SOCIAL_POLL = { id: "himi-account-social", intervalMs: 1500, action: "himiStoreAccount.refreshSocial" };
|
|
440
467
|
const SOCIAL_RETRIES = 4;
|
|
441
468
|
let socialRetriesLeft = 0;
|
|
469
|
+
// The member flows are read on the same short poll: before the host's auth boot has wired the provider (a cold launch straight
|
|
470
|
+
// onto the gate screen) it answers `unavailable` and is asked again; a host that does not know the verb (web, an older binary) is not.
|
|
471
|
+
let flowsRetriesLeft = 0;
|
|
472
|
+
|
|
473
|
+
function armFlowsRetry(read: MemberFlowsRead): void {
|
|
474
|
+
flowsRetriesLeft = !read.ok && read.notReady ? SOCIAL_RETRIES : 0;
|
|
475
|
+
}
|
|
442
476
|
|
|
443
477
|
function armSocialRetry(read: SocialProvidersRead): void {
|
|
444
478
|
if (read.ok) socialRetriesLeft = read.providers.length ? 0 : SOCIAL_RETRIES;
|
|
@@ -450,8 +484,14 @@ async function refreshSocial(): Promise<S> {
|
|
|
450
484
|
applySocialProviders(await readSocialProviders());
|
|
451
485
|
if (socialProviders.length) socialRetriesLeft = 0;
|
|
452
486
|
}
|
|
487
|
+
if (flowsRetriesLeft > 0) {
|
|
488
|
+
flowsRetriesLeft -= 1;
|
|
489
|
+
const flows = await readMemberFlows();
|
|
490
|
+
applyMemberFlows(flows);
|
|
491
|
+
if (flows.ok || !flows.notReady) flowsRetriesLeft = 0;
|
|
492
|
+
}
|
|
453
493
|
const current = svc.getState();
|
|
454
|
-
return derive({ ...current, ...(socialRetriesLeft > 0 ? {} : { _poll: { id: SOCIAL_POLL.id, stop: true } }) });
|
|
494
|
+
return derive({ ...current, ...(socialRetriesLeft > 0 || flowsRetriesLeft > 0 ? {} : { _poll: { id: SOCIAL_POLL.id, stop: true } }) });
|
|
455
495
|
}
|
|
456
496
|
|
|
457
497
|
function socialCancelled(raw: unknown): boolean {
|
|
@@ -664,6 +704,10 @@ interface S extends IapRestoreFields {
|
|
|
664
704
|
isRecovering: boolean;
|
|
665
705
|
notRecovering: boolean;
|
|
666
706
|
hideSignInChoices: boolean;
|
|
707
|
+
/** The form's Create account / Forgot password links: hidden while registering or recovering, and when the binding
|
|
708
|
+
* cannot run the flow (`himi.wix.memberFlows`). */
|
|
709
|
+
hideShowRegister: boolean;
|
|
710
|
+
hideShowRecovery: boolean;
|
|
667
711
|
hideAppleSignIn: boolean;
|
|
668
712
|
hideGoogleSignIn: boolean;
|
|
669
713
|
/** The social block and its "or" divider: no provider to show, or resetting a password. */
|
|
@@ -755,6 +799,8 @@ function derive(s: S): S {
|
|
|
755
799
|
isRecovering,
|
|
756
800
|
notRecovering: !isRecovering,
|
|
757
801
|
hideSignInChoices: isRegistering || isRecovering,
|
|
802
|
+
hideShowRegister: isRegistering || isRecovering || !signUpAvailable,
|
|
803
|
+
hideShowRecovery: isRegistering || isRecovering || !passwordResetAvailable,
|
|
758
804
|
hideAppleSignIn: !socialProviders.includes("apple"),
|
|
759
805
|
hideGoogleSignIn: !socialProviders.includes("google"),
|
|
760
806
|
hideSocialSignIn: isRecovering || socialProviders.length === 0,
|
|
@@ -833,9 +879,13 @@ async function probe(s: S, arg?: unknown, config: AppearConfig = appearConfig(s,
|
|
|
833
879
|
// snapshot restored, not a 0 that would empty the badge until the appear refresh lands.
|
|
834
880
|
const cartCountRead = cartCountRequested ? cartItemCount(s.cartCount ?? 0) : Promise.resolve(s.cartCount ?? 0);
|
|
835
881
|
const socialRead: Promise<SocialProvidersRead> = standaloneRequested ? readSocialProviders() : Promise.resolve({ ok: false });
|
|
882
|
+
const flowsRead: Promise<MemberFlowsRead> = standaloneRequested ? readMemberFlows() : Promise.resolve({ ok: false, notReady: false });
|
|
836
883
|
const profile = await loadMemberProfile(copyParam("storeAccount.guestDetail", "Sign in to keep your cart and orders connected."));
|
|
837
884
|
const social = await socialRead;
|
|
838
885
|
applySocialProviders(social);
|
|
886
|
+
const flows = await flowsRead;
|
|
887
|
+
applyMemberFlows(flows);
|
|
888
|
+
armFlowsRetry(flows);
|
|
839
889
|
armSocialRetry(social);
|
|
840
890
|
// Not the boot load: it never carries the copy, and the appear refresh that does is coming.
|
|
841
891
|
if (strField(arg, "boot") !== "1") headingReady = true;
|
|
@@ -965,6 +1015,8 @@ const svc = defineService<S, {
|
|
|
965
1015
|
isRecovering: false,
|
|
966
1016
|
notRecovering: true,
|
|
967
1017
|
hideSignInChoices: false,
|
|
1018
|
+
hideShowRegister: false,
|
|
1019
|
+
hideShowRecovery: false,
|
|
968
1020
|
hideAppleSignIn: true,
|
|
969
1021
|
hideGoogleSignIn: true,
|
|
970
1022
|
hideSocialSignIn: true,
|
|
@@ -5938,7 +5938,7 @@ const SCREENS = runtimeSetting({
|
|
|
5938
5938
|
}
|
|
5939
5939
|
},
|
|
5940
5940
|
"modifiers": {
|
|
5941
|
-
"hiddenPath": "$service:himiStoreAccount.
|
|
5941
|
+
"hiddenPath": "$service:himiStoreAccount.hideShowRegister"
|
|
5942
5942
|
}
|
|
5943
5943
|
},
|
|
5944
5944
|
{
|
|
@@ -5995,7 +5995,7 @@ const SCREENS = runtimeSetting({
|
|
|
5995
5995
|
}
|
|
5996
5996
|
},
|
|
5997
5997
|
"modifiers": {
|
|
5998
|
-
"hiddenPath": "$service:himiStoreAccount.
|
|
5998
|
+
"hiddenPath": "$service:himiStoreAccount.hideShowRecovery"
|
|
5999
5999
|
}
|
|
6000
6000
|
}
|
|
6001
6001
|
]
|