@wix/himalaya-cli 0.1744.0 → 0.1745.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/ts/src/icon-catalog.generated.d.ts +1 -1
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/core.mjs +21 -0
- package/dist/browser-plane/assets.json +5 -5
- package/dist/browser-plane/preview-deferred/{b583b2879dbf6318c5d5bc0aaca78a34b84f76b51a8f79dc824e05521f2a5a7a.bin → d432d189310d8d819b56251c53dd82a9e166a4a73936749f08c355c11083e8e0.bin} +1 -1
- package/dist/browser-plane/sw.js +5 -5
- package/dist/cli.mjs +60 -40
- package/dist/preview-assets.generated.bin +0 -0
- package/guides/android-ux.md +1 -1
- package/guides/designing-himi-screens.md +23 -14
- package/guides/headless-loop.md +1 -1
- package/guides/ios-ux.md +1 -1
- package/package.json +2 -2
- package/templates/beauty-salon/tier5-src/_shared/himi-account.ts +37 -8
- package/templates/branded-lite/tier5-src/_shared/himi-account.ts +37 -8
- package/templates/community-club/tier5-src/_shared/himi-account.ts +37 -8
- package/templates/conference/tier5-src/_shared/himi-account.ts +37 -8
- package/templates/events-meetups/tier5-src/_shared/himi-account.ts +37 -8
- package/templates/gym-fitness/tier5-src/_shared/himi-account.ts +37 -8
- package/templates/nonprofit-cause/tier5-src/_shared/himi-account.ts +37 -8
- package/templates/podcast-creator/tier5-src/_shared/himi-account.ts +37 -8
- package/templates/portfolio-creative/tier5-src/_shared/himi-account.ts +37 -8
- package/templates/restaurant/tier5-src/_shared/himi-account.ts +37 -8
- package/templates/retail-store/tier5-src/_shared/himi-account.ts +37 -8
- package/templates/salon-spa/tier5-src/_shared/himi-account.ts +37 -8
- package/templates/wholesale-store/tier5-src/_shared/himi-account.ts +37 -8
- package/templates/yoga-studio/tier5-src/_shared/himi-account.ts +37 -8
|
@@ -124,24 +124,53 @@ export function guestProfile(detailLine: string): AccountProfile {
|
|
|
124
124
|
};
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
-
|
|
127
|
+
/** `himi.wix.memberIdentity`: the member's email ("" when none is known) and whether a member is
|
|
128
|
+
* signed in. `signedIn` is true only when the host says so explicitly — native hosts answer it
|
|
129
|
+
* for a member whose email is not known yet (an injected or hosted session before `members/my`
|
|
130
|
+
* answers); hosts that predate it answer the email alone. */
|
|
131
|
+
export async function memberIdentity(): Promise<{ email: string; signedIn: boolean }> {
|
|
128
132
|
try {
|
|
129
133
|
const identity = await dispatch("himi.wix.memberIdentity") as unknown;
|
|
130
|
-
const direct = identity as { email?: unknown } | null;
|
|
131
|
-
const wrapped = identity as { payload?: { email?: unknown } } | null;
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
+
const direct = identity as { email?: unknown; signedIn?: unknown } | null;
|
|
135
|
+
const wrapped = identity as { payload?: { email?: unknown; signedIn?: unknown } } | null;
|
|
136
|
+
const raw = direct?.email ?? wrapped?.payload?.email;
|
|
137
|
+
const email = typeof raw === "string" ? raw : "";
|
|
138
|
+
const signedIn = (direct?.signedIn ?? wrapped?.payload?.signedIn) === true;
|
|
139
|
+
return { email, signedIn: signedIn || !!email };
|
|
134
140
|
} catch {
|
|
135
|
-
return "";
|
|
141
|
+
return { email: "", signedIn: false };
|
|
136
142
|
}
|
|
137
143
|
}
|
|
138
144
|
|
|
145
|
+
export async function signedInEmail(): Promise<string> {
|
|
146
|
+
return (await memberIdentity()).email;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/** A signed-in member nothing names yet: signed in, with a neutral label rather than another
|
|
150
|
+
* member's name or the sign-in form. */
|
|
151
|
+
function neutralMemberProfile(): AccountProfile {
|
|
152
|
+
const name = copyParam("account.member", "Member");
|
|
153
|
+
return {
|
|
154
|
+
isMember: true,
|
|
155
|
+
identityLine: copyParam("account.signedIn", "Signed in"),
|
|
156
|
+
detailLine: name,
|
|
157
|
+
memberName: name,
|
|
158
|
+
memberEmail: "",
|
|
159
|
+
memberImage: "",
|
|
160
|
+
memberInitials: "M",
|
|
161
|
+
hasMemberImage: false,
|
|
162
|
+
noMemberImage: true,
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
|
|
139
166
|
export async function loadMemberProfile(guestDetailLine: string): Promise<AccountProfile> {
|
|
140
167
|
// `himi.wix.memberIdentity` is the session source of truth. Visitor-scoped
|
|
141
168
|
// getMyData can still return a site/account nickname (e.g. apptestercoowner)
|
|
142
169
|
// after sign-out or for anonymous — never treat that as a signed-in member.
|
|
143
|
-
const
|
|
144
|
-
if (!
|
|
170
|
+
const identity = await memberIdentity();
|
|
171
|
+
if (!identity.signedIn) return guestProfile(guestDetailLine);
|
|
172
|
+
const storedEmail = identity.email;
|
|
173
|
+
if (!storedEmail) return (await siteMemberProfile("")) ?? neutralMemberProfile();
|
|
145
174
|
try {
|
|
146
175
|
const data = await getMyData();
|
|
147
176
|
return profileFromData(data, storedEmail);
|
|
@@ -124,24 +124,53 @@ export function guestProfile(detailLine: string): AccountProfile {
|
|
|
124
124
|
};
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
-
|
|
127
|
+
/** `himi.wix.memberIdentity`: the member's email ("" when none is known) and whether a member is
|
|
128
|
+
* signed in. `signedIn` is true only when the host says so explicitly — native hosts answer it
|
|
129
|
+
* for a member whose email is not known yet (an injected or hosted session before `members/my`
|
|
130
|
+
* answers); hosts that predate it answer the email alone. */
|
|
131
|
+
export async function memberIdentity(): Promise<{ email: string; signedIn: boolean }> {
|
|
128
132
|
try {
|
|
129
133
|
const identity = await dispatch("himi.wix.memberIdentity") as unknown;
|
|
130
|
-
const direct = identity as { email?: unknown } | null;
|
|
131
|
-
const wrapped = identity as { payload?: { email?: unknown } } | null;
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
+
const direct = identity as { email?: unknown; signedIn?: unknown } | null;
|
|
135
|
+
const wrapped = identity as { payload?: { email?: unknown; signedIn?: unknown } } | null;
|
|
136
|
+
const raw = direct?.email ?? wrapped?.payload?.email;
|
|
137
|
+
const email = typeof raw === "string" ? raw : "";
|
|
138
|
+
const signedIn = (direct?.signedIn ?? wrapped?.payload?.signedIn) === true;
|
|
139
|
+
return { email, signedIn: signedIn || !!email };
|
|
134
140
|
} catch {
|
|
135
|
-
return "";
|
|
141
|
+
return { email: "", signedIn: false };
|
|
136
142
|
}
|
|
137
143
|
}
|
|
138
144
|
|
|
145
|
+
export async function signedInEmail(): Promise<string> {
|
|
146
|
+
return (await memberIdentity()).email;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/** A signed-in member nothing names yet: signed in, with a neutral label rather than another
|
|
150
|
+
* member's name or the sign-in form. */
|
|
151
|
+
function neutralMemberProfile(): AccountProfile {
|
|
152
|
+
const name = copyParam("account.member", "Member");
|
|
153
|
+
return {
|
|
154
|
+
isMember: true,
|
|
155
|
+
identityLine: copyParam("account.signedIn", "Signed in"),
|
|
156
|
+
detailLine: name,
|
|
157
|
+
memberName: name,
|
|
158
|
+
memberEmail: "",
|
|
159
|
+
memberImage: "",
|
|
160
|
+
memberInitials: "M",
|
|
161
|
+
hasMemberImage: false,
|
|
162
|
+
noMemberImage: true,
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
|
|
139
166
|
export async function loadMemberProfile(guestDetailLine: string): Promise<AccountProfile> {
|
|
140
167
|
// `himi.wix.memberIdentity` is the session source of truth. Visitor-scoped
|
|
141
168
|
// getMyData can still return a site/account nickname (e.g. apptestercoowner)
|
|
142
169
|
// after sign-out or for anonymous — never treat that as a signed-in member.
|
|
143
|
-
const
|
|
144
|
-
if (!
|
|
170
|
+
const identity = await memberIdentity();
|
|
171
|
+
if (!identity.signedIn) return guestProfile(guestDetailLine);
|
|
172
|
+
const storedEmail = identity.email;
|
|
173
|
+
if (!storedEmail) return (await siteMemberProfile("")) ?? neutralMemberProfile();
|
|
145
174
|
try {
|
|
146
175
|
const data = await getMyData();
|
|
147
176
|
return profileFromData(data, storedEmail);
|
|
@@ -124,24 +124,53 @@ export function guestProfile(detailLine: string): AccountProfile {
|
|
|
124
124
|
};
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
-
|
|
127
|
+
/** `himi.wix.memberIdentity`: the member's email ("" when none is known) and whether a member is
|
|
128
|
+
* signed in. `signedIn` is true only when the host says so explicitly — native hosts answer it
|
|
129
|
+
* for a member whose email is not known yet (an injected or hosted session before `members/my`
|
|
130
|
+
* answers); hosts that predate it answer the email alone. */
|
|
131
|
+
export async function memberIdentity(): Promise<{ email: string; signedIn: boolean }> {
|
|
128
132
|
try {
|
|
129
133
|
const identity = await dispatch("himi.wix.memberIdentity") as unknown;
|
|
130
|
-
const direct = identity as { email?: unknown } | null;
|
|
131
|
-
const wrapped = identity as { payload?: { email?: unknown } } | null;
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
+
const direct = identity as { email?: unknown; signedIn?: unknown } | null;
|
|
135
|
+
const wrapped = identity as { payload?: { email?: unknown; signedIn?: unknown } } | null;
|
|
136
|
+
const raw = direct?.email ?? wrapped?.payload?.email;
|
|
137
|
+
const email = typeof raw === "string" ? raw : "";
|
|
138
|
+
const signedIn = (direct?.signedIn ?? wrapped?.payload?.signedIn) === true;
|
|
139
|
+
return { email, signedIn: signedIn || !!email };
|
|
134
140
|
} catch {
|
|
135
|
-
return "";
|
|
141
|
+
return { email: "", signedIn: false };
|
|
136
142
|
}
|
|
137
143
|
}
|
|
138
144
|
|
|
145
|
+
export async function signedInEmail(): Promise<string> {
|
|
146
|
+
return (await memberIdentity()).email;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/** A signed-in member nothing names yet: signed in, with a neutral label rather than another
|
|
150
|
+
* member's name or the sign-in form. */
|
|
151
|
+
function neutralMemberProfile(): AccountProfile {
|
|
152
|
+
const name = copyParam("account.member", "Member");
|
|
153
|
+
return {
|
|
154
|
+
isMember: true,
|
|
155
|
+
identityLine: copyParam("account.signedIn", "Signed in"),
|
|
156
|
+
detailLine: name,
|
|
157
|
+
memberName: name,
|
|
158
|
+
memberEmail: "",
|
|
159
|
+
memberImage: "",
|
|
160
|
+
memberInitials: "M",
|
|
161
|
+
hasMemberImage: false,
|
|
162
|
+
noMemberImage: true,
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
|
|
139
166
|
export async function loadMemberProfile(guestDetailLine: string): Promise<AccountProfile> {
|
|
140
167
|
// `himi.wix.memberIdentity` is the session source of truth. Visitor-scoped
|
|
141
168
|
// getMyData can still return a site/account nickname (e.g. apptestercoowner)
|
|
142
169
|
// after sign-out or for anonymous — never treat that as a signed-in member.
|
|
143
|
-
const
|
|
144
|
-
if (!
|
|
170
|
+
const identity = await memberIdentity();
|
|
171
|
+
if (!identity.signedIn) return guestProfile(guestDetailLine);
|
|
172
|
+
const storedEmail = identity.email;
|
|
173
|
+
if (!storedEmail) return (await siteMemberProfile("")) ?? neutralMemberProfile();
|
|
145
174
|
try {
|
|
146
175
|
const data = await getMyData();
|
|
147
176
|
return profileFromData(data, storedEmail);
|
|
@@ -124,24 +124,53 @@ export function guestProfile(detailLine: string): AccountProfile {
|
|
|
124
124
|
};
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
-
|
|
127
|
+
/** `himi.wix.memberIdentity`: the member's email ("" when none is known) and whether a member is
|
|
128
|
+
* signed in. `signedIn` is true only when the host says so explicitly — native hosts answer it
|
|
129
|
+
* for a member whose email is not known yet (an injected or hosted session before `members/my`
|
|
130
|
+
* answers); hosts that predate it answer the email alone. */
|
|
131
|
+
export async function memberIdentity(): Promise<{ email: string; signedIn: boolean }> {
|
|
128
132
|
try {
|
|
129
133
|
const identity = await dispatch("himi.wix.memberIdentity") as unknown;
|
|
130
|
-
const direct = identity as { email?: unknown } | null;
|
|
131
|
-
const wrapped = identity as { payload?: { email?: unknown } } | null;
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
+
const direct = identity as { email?: unknown; signedIn?: unknown } | null;
|
|
135
|
+
const wrapped = identity as { payload?: { email?: unknown; signedIn?: unknown } } | null;
|
|
136
|
+
const raw = direct?.email ?? wrapped?.payload?.email;
|
|
137
|
+
const email = typeof raw === "string" ? raw : "";
|
|
138
|
+
const signedIn = (direct?.signedIn ?? wrapped?.payload?.signedIn) === true;
|
|
139
|
+
return { email, signedIn: signedIn || !!email };
|
|
134
140
|
} catch {
|
|
135
|
-
return "";
|
|
141
|
+
return { email: "", signedIn: false };
|
|
136
142
|
}
|
|
137
143
|
}
|
|
138
144
|
|
|
145
|
+
export async function signedInEmail(): Promise<string> {
|
|
146
|
+
return (await memberIdentity()).email;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/** A signed-in member nothing names yet: signed in, with a neutral label rather than another
|
|
150
|
+
* member's name or the sign-in form. */
|
|
151
|
+
function neutralMemberProfile(): AccountProfile {
|
|
152
|
+
const name = copyParam("account.member", "Member");
|
|
153
|
+
return {
|
|
154
|
+
isMember: true,
|
|
155
|
+
identityLine: copyParam("account.signedIn", "Signed in"),
|
|
156
|
+
detailLine: name,
|
|
157
|
+
memberName: name,
|
|
158
|
+
memberEmail: "",
|
|
159
|
+
memberImage: "",
|
|
160
|
+
memberInitials: "M",
|
|
161
|
+
hasMemberImage: false,
|
|
162
|
+
noMemberImage: true,
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
|
|
139
166
|
export async function loadMemberProfile(guestDetailLine: string): Promise<AccountProfile> {
|
|
140
167
|
// `himi.wix.memberIdentity` is the session source of truth. Visitor-scoped
|
|
141
168
|
// getMyData can still return a site/account nickname (e.g. apptestercoowner)
|
|
142
169
|
// after sign-out or for anonymous — never treat that as a signed-in member.
|
|
143
|
-
const
|
|
144
|
-
if (!
|
|
170
|
+
const identity = await memberIdentity();
|
|
171
|
+
if (!identity.signedIn) return guestProfile(guestDetailLine);
|
|
172
|
+
const storedEmail = identity.email;
|
|
173
|
+
if (!storedEmail) return (await siteMemberProfile("")) ?? neutralMemberProfile();
|
|
145
174
|
try {
|
|
146
175
|
const data = await getMyData();
|
|
147
176
|
return profileFromData(data, storedEmail);
|
|
@@ -124,24 +124,53 @@ export function guestProfile(detailLine: string): AccountProfile {
|
|
|
124
124
|
};
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
-
|
|
127
|
+
/** `himi.wix.memberIdentity`: the member's email ("" when none is known) and whether a member is
|
|
128
|
+
* signed in. `signedIn` is true only when the host says so explicitly — native hosts answer it
|
|
129
|
+
* for a member whose email is not known yet (an injected or hosted session before `members/my`
|
|
130
|
+
* answers); hosts that predate it answer the email alone. */
|
|
131
|
+
export async function memberIdentity(): Promise<{ email: string; signedIn: boolean }> {
|
|
128
132
|
try {
|
|
129
133
|
const identity = await dispatch("himi.wix.memberIdentity") as unknown;
|
|
130
|
-
const direct = identity as { email?: unknown } | null;
|
|
131
|
-
const wrapped = identity as { payload?: { email?: unknown } } | null;
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
+
const direct = identity as { email?: unknown; signedIn?: unknown } | null;
|
|
135
|
+
const wrapped = identity as { payload?: { email?: unknown; signedIn?: unknown } } | null;
|
|
136
|
+
const raw = direct?.email ?? wrapped?.payload?.email;
|
|
137
|
+
const email = typeof raw === "string" ? raw : "";
|
|
138
|
+
const signedIn = (direct?.signedIn ?? wrapped?.payload?.signedIn) === true;
|
|
139
|
+
return { email, signedIn: signedIn || !!email };
|
|
134
140
|
} catch {
|
|
135
|
-
return "";
|
|
141
|
+
return { email: "", signedIn: false };
|
|
136
142
|
}
|
|
137
143
|
}
|
|
138
144
|
|
|
145
|
+
export async function signedInEmail(): Promise<string> {
|
|
146
|
+
return (await memberIdentity()).email;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/** A signed-in member nothing names yet: signed in, with a neutral label rather than another
|
|
150
|
+
* member's name or the sign-in form. */
|
|
151
|
+
function neutralMemberProfile(): AccountProfile {
|
|
152
|
+
const name = copyParam("account.member", "Member");
|
|
153
|
+
return {
|
|
154
|
+
isMember: true,
|
|
155
|
+
identityLine: copyParam("account.signedIn", "Signed in"),
|
|
156
|
+
detailLine: name,
|
|
157
|
+
memberName: name,
|
|
158
|
+
memberEmail: "",
|
|
159
|
+
memberImage: "",
|
|
160
|
+
memberInitials: "M",
|
|
161
|
+
hasMemberImage: false,
|
|
162
|
+
noMemberImage: true,
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
|
|
139
166
|
export async function loadMemberProfile(guestDetailLine: string): Promise<AccountProfile> {
|
|
140
167
|
// `himi.wix.memberIdentity` is the session source of truth. Visitor-scoped
|
|
141
168
|
// getMyData can still return a site/account nickname (e.g. apptestercoowner)
|
|
142
169
|
// after sign-out or for anonymous — never treat that as a signed-in member.
|
|
143
|
-
const
|
|
144
|
-
if (!
|
|
170
|
+
const identity = await memberIdentity();
|
|
171
|
+
if (!identity.signedIn) return guestProfile(guestDetailLine);
|
|
172
|
+
const storedEmail = identity.email;
|
|
173
|
+
if (!storedEmail) return (await siteMemberProfile("")) ?? neutralMemberProfile();
|
|
145
174
|
try {
|
|
146
175
|
const data = await getMyData();
|
|
147
176
|
return profileFromData(data, storedEmail);
|
|
@@ -124,24 +124,53 @@ export function guestProfile(detailLine: string): AccountProfile {
|
|
|
124
124
|
};
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
-
|
|
127
|
+
/** `himi.wix.memberIdentity`: the member's email ("" when none is known) and whether a member is
|
|
128
|
+
* signed in. `signedIn` is true only when the host says so explicitly — native hosts answer it
|
|
129
|
+
* for a member whose email is not known yet (an injected or hosted session before `members/my`
|
|
130
|
+
* answers); hosts that predate it answer the email alone. */
|
|
131
|
+
export async function memberIdentity(): Promise<{ email: string; signedIn: boolean }> {
|
|
128
132
|
try {
|
|
129
133
|
const identity = await dispatch("himi.wix.memberIdentity") as unknown;
|
|
130
|
-
const direct = identity as { email?: unknown } | null;
|
|
131
|
-
const wrapped = identity as { payload?: { email?: unknown } } | null;
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
+
const direct = identity as { email?: unknown; signedIn?: unknown } | null;
|
|
135
|
+
const wrapped = identity as { payload?: { email?: unknown; signedIn?: unknown } } | null;
|
|
136
|
+
const raw = direct?.email ?? wrapped?.payload?.email;
|
|
137
|
+
const email = typeof raw === "string" ? raw : "";
|
|
138
|
+
const signedIn = (direct?.signedIn ?? wrapped?.payload?.signedIn) === true;
|
|
139
|
+
return { email, signedIn: signedIn || !!email };
|
|
134
140
|
} catch {
|
|
135
|
-
return "";
|
|
141
|
+
return { email: "", signedIn: false };
|
|
136
142
|
}
|
|
137
143
|
}
|
|
138
144
|
|
|
145
|
+
export async function signedInEmail(): Promise<string> {
|
|
146
|
+
return (await memberIdentity()).email;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/** A signed-in member nothing names yet: signed in, with a neutral label rather than another
|
|
150
|
+
* member's name or the sign-in form. */
|
|
151
|
+
function neutralMemberProfile(): AccountProfile {
|
|
152
|
+
const name = copyParam("account.member", "Member");
|
|
153
|
+
return {
|
|
154
|
+
isMember: true,
|
|
155
|
+
identityLine: copyParam("account.signedIn", "Signed in"),
|
|
156
|
+
detailLine: name,
|
|
157
|
+
memberName: name,
|
|
158
|
+
memberEmail: "",
|
|
159
|
+
memberImage: "",
|
|
160
|
+
memberInitials: "M",
|
|
161
|
+
hasMemberImage: false,
|
|
162
|
+
noMemberImage: true,
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
|
|
139
166
|
export async function loadMemberProfile(guestDetailLine: string): Promise<AccountProfile> {
|
|
140
167
|
// `himi.wix.memberIdentity` is the session source of truth. Visitor-scoped
|
|
141
168
|
// getMyData can still return a site/account nickname (e.g. apptestercoowner)
|
|
142
169
|
// after sign-out or for anonymous — never treat that as a signed-in member.
|
|
143
|
-
const
|
|
144
|
-
if (!
|
|
170
|
+
const identity = await memberIdentity();
|
|
171
|
+
if (!identity.signedIn) return guestProfile(guestDetailLine);
|
|
172
|
+
const storedEmail = identity.email;
|
|
173
|
+
if (!storedEmail) return (await siteMemberProfile("")) ?? neutralMemberProfile();
|
|
145
174
|
try {
|
|
146
175
|
const data = await getMyData();
|
|
147
176
|
return profileFromData(data, storedEmail);
|
|
@@ -124,24 +124,53 @@ export function guestProfile(detailLine: string): AccountProfile {
|
|
|
124
124
|
};
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
-
|
|
127
|
+
/** `himi.wix.memberIdentity`: the member's email ("" when none is known) and whether a member is
|
|
128
|
+
* signed in. `signedIn` is true only when the host says so explicitly — native hosts answer it
|
|
129
|
+
* for a member whose email is not known yet (an injected or hosted session before `members/my`
|
|
130
|
+
* answers); hosts that predate it answer the email alone. */
|
|
131
|
+
export async function memberIdentity(): Promise<{ email: string; signedIn: boolean }> {
|
|
128
132
|
try {
|
|
129
133
|
const identity = await dispatch("himi.wix.memberIdentity") as unknown;
|
|
130
|
-
const direct = identity as { email?: unknown } | null;
|
|
131
|
-
const wrapped = identity as { payload?: { email?: unknown } } | null;
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
+
const direct = identity as { email?: unknown; signedIn?: unknown } | null;
|
|
135
|
+
const wrapped = identity as { payload?: { email?: unknown; signedIn?: unknown } } | null;
|
|
136
|
+
const raw = direct?.email ?? wrapped?.payload?.email;
|
|
137
|
+
const email = typeof raw === "string" ? raw : "";
|
|
138
|
+
const signedIn = (direct?.signedIn ?? wrapped?.payload?.signedIn) === true;
|
|
139
|
+
return { email, signedIn: signedIn || !!email };
|
|
134
140
|
} catch {
|
|
135
|
-
return "";
|
|
141
|
+
return { email: "", signedIn: false };
|
|
136
142
|
}
|
|
137
143
|
}
|
|
138
144
|
|
|
145
|
+
export async function signedInEmail(): Promise<string> {
|
|
146
|
+
return (await memberIdentity()).email;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/** A signed-in member nothing names yet: signed in, with a neutral label rather than another
|
|
150
|
+
* member's name or the sign-in form. */
|
|
151
|
+
function neutralMemberProfile(): AccountProfile {
|
|
152
|
+
const name = copyParam("account.member", "Member");
|
|
153
|
+
return {
|
|
154
|
+
isMember: true,
|
|
155
|
+
identityLine: copyParam("account.signedIn", "Signed in"),
|
|
156
|
+
detailLine: name,
|
|
157
|
+
memberName: name,
|
|
158
|
+
memberEmail: "",
|
|
159
|
+
memberImage: "",
|
|
160
|
+
memberInitials: "M",
|
|
161
|
+
hasMemberImage: false,
|
|
162
|
+
noMemberImage: true,
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
|
|
139
166
|
export async function loadMemberProfile(guestDetailLine: string): Promise<AccountProfile> {
|
|
140
167
|
// `himi.wix.memberIdentity` is the session source of truth. Visitor-scoped
|
|
141
168
|
// getMyData can still return a site/account nickname (e.g. apptestercoowner)
|
|
142
169
|
// after sign-out or for anonymous — never treat that as a signed-in member.
|
|
143
|
-
const
|
|
144
|
-
if (!
|
|
170
|
+
const identity = await memberIdentity();
|
|
171
|
+
if (!identity.signedIn) return guestProfile(guestDetailLine);
|
|
172
|
+
const storedEmail = identity.email;
|
|
173
|
+
if (!storedEmail) return (await siteMemberProfile("")) ?? neutralMemberProfile();
|
|
145
174
|
try {
|
|
146
175
|
const data = await getMyData();
|
|
147
176
|
return profileFromData(data, storedEmail);
|
|
@@ -124,24 +124,53 @@ export function guestProfile(detailLine: string): AccountProfile {
|
|
|
124
124
|
};
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
-
|
|
127
|
+
/** `himi.wix.memberIdentity`: the member's email ("" when none is known) and whether a member is
|
|
128
|
+
* signed in. `signedIn` is true only when the host says so explicitly — native hosts answer it
|
|
129
|
+
* for a member whose email is not known yet (an injected or hosted session before `members/my`
|
|
130
|
+
* answers); hosts that predate it answer the email alone. */
|
|
131
|
+
export async function memberIdentity(): Promise<{ email: string; signedIn: boolean }> {
|
|
128
132
|
try {
|
|
129
133
|
const identity = await dispatch("himi.wix.memberIdentity") as unknown;
|
|
130
|
-
const direct = identity as { email?: unknown } | null;
|
|
131
|
-
const wrapped = identity as { payload?: { email?: unknown } } | null;
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
+
const direct = identity as { email?: unknown; signedIn?: unknown } | null;
|
|
135
|
+
const wrapped = identity as { payload?: { email?: unknown; signedIn?: unknown } } | null;
|
|
136
|
+
const raw = direct?.email ?? wrapped?.payload?.email;
|
|
137
|
+
const email = typeof raw === "string" ? raw : "";
|
|
138
|
+
const signedIn = (direct?.signedIn ?? wrapped?.payload?.signedIn) === true;
|
|
139
|
+
return { email, signedIn: signedIn || !!email };
|
|
134
140
|
} catch {
|
|
135
|
-
return "";
|
|
141
|
+
return { email: "", signedIn: false };
|
|
136
142
|
}
|
|
137
143
|
}
|
|
138
144
|
|
|
145
|
+
export async function signedInEmail(): Promise<string> {
|
|
146
|
+
return (await memberIdentity()).email;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/** A signed-in member nothing names yet: signed in, with a neutral label rather than another
|
|
150
|
+
* member's name or the sign-in form. */
|
|
151
|
+
function neutralMemberProfile(): AccountProfile {
|
|
152
|
+
const name = copyParam("account.member", "Member");
|
|
153
|
+
return {
|
|
154
|
+
isMember: true,
|
|
155
|
+
identityLine: copyParam("account.signedIn", "Signed in"),
|
|
156
|
+
detailLine: name,
|
|
157
|
+
memberName: name,
|
|
158
|
+
memberEmail: "",
|
|
159
|
+
memberImage: "",
|
|
160
|
+
memberInitials: "M",
|
|
161
|
+
hasMemberImage: false,
|
|
162
|
+
noMemberImage: true,
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
|
|
139
166
|
export async function loadMemberProfile(guestDetailLine: string): Promise<AccountProfile> {
|
|
140
167
|
// `himi.wix.memberIdentity` is the session source of truth. Visitor-scoped
|
|
141
168
|
// getMyData can still return a site/account nickname (e.g. apptestercoowner)
|
|
142
169
|
// after sign-out or for anonymous — never treat that as a signed-in member.
|
|
143
|
-
const
|
|
144
|
-
if (!
|
|
170
|
+
const identity = await memberIdentity();
|
|
171
|
+
if (!identity.signedIn) return guestProfile(guestDetailLine);
|
|
172
|
+
const storedEmail = identity.email;
|
|
173
|
+
if (!storedEmail) return (await siteMemberProfile("")) ?? neutralMemberProfile();
|
|
145
174
|
try {
|
|
146
175
|
const data = await getMyData();
|
|
147
176
|
return profileFromData(data, storedEmail);
|
|
@@ -124,24 +124,53 @@ export function guestProfile(detailLine: string): AccountProfile {
|
|
|
124
124
|
};
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
-
|
|
127
|
+
/** `himi.wix.memberIdentity`: the member's email ("" when none is known) and whether a member is
|
|
128
|
+
* signed in. `signedIn` is true only when the host says so explicitly — native hosts answer it
|
|
129
|
+
* for a member whose email is not known yet (an injected or hosted session before `members/my`
|
|
130
|
+
* answers); hosts that predate it answer the email alone. */
|
|
131
|
+
export async function memberIdentity(): Promise<{ email: string; signedIn: boolean }> {
|
|
128
132
|
try {
|
|
129
133
|
const identity = await dispatch("himi.wix.memberIdentity") as unknown;
|
|
130
|
-
const direct = identity as { email?: unknown } | null;
|
|
131
|
-
const wrapped = identity as { payload?: { email?: unknown } } | null;
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
+
const direct = identity as { email?: unknown; signedIn?: unknown } | null;
|
|
135
|
+
const wrapped = identity as { payload?: { email?: unknown; signedIn?: unknown } } | null;
|
|
136
|
+
const raw = direct?.email ?? wrapped?.payload?.email;
|
|
137
|
+
const email = typeof raw === "string" ? raw : "";
|
|
138
|
+
const signedIn = (direct?.signedIn ?? wrapped?.payload?.signedIn) === true;
|
|
139
|
+
return { email, signedIn: signedIn || !!email };
|
|
134
140
|
} catch {
|
|
135
|
-
return "";
|
|
141
|
+
return { email: "", signedIn: false };
|
|
136
142
|
}
|
|
137
143
|
}
|
|
138
144
|
|
|
145
|
+
export async function signedInEmail(): Promise<string> {
|
|
146
|
+
return (await memberIdentity()).email;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/** A signed-in member nothing names yet: signed in, with a neutral label rather than another
|
|
150
|
+
* member's name or the sign-in form. */
|
|
151
|
+
function neutralMemberProfile(): AccountProfile {
|
|
152
|
+
const name = copyParam("account.member", "Member");
|
|
153
|
+
return {
|
|
154
|
+
isMember: true,
|
|
155
|
+
identityLine: copyParam("account.signedIn", "Signed in"),
|
|
156
|
+
detailLine: name,
|
|
157
|
+
memberName: name,
|
|
158
|
+
memberEmail: "",
|
|
159
|
+
memberImage: "",
|
|
160
|
+
memberInitials: "M",
|
|
161
|
+
hasMemberImage: false,
|
|
162
|
+
noMemberImage: true,
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
|
|
139
166
|
export async function loadMemberProfile(guestDetailLine: string): Promise<AccountProfile> {
|
|
140
167
|
// `himi.wix.memberIdentity` is the session source of truth. Visitor-scoped
|
|
141
168
|
// getMyData can still return a site/account nickname (e.g. apptestercoowner)
|
|
142
169
|
// after sign-out or for anonymous — never treat that as a signed-in member.
|
|
143
|
-
const
|
|
144
|
-
if (!
|
|
170
|
+
const identity = await memberIdentity();
|
|
171
|
+
if (!identity.signedIn) return guestProfile(guestDetailLine);
|
|
172
|
+
const storedEmail = identity.email;
|
|
173
|
+
if (!storedEmail) return (await siteMemberProfile("")) ?? neutralMemberProfile();
|
|
145
174
|
try {
|
|
146
175
|
const data = await getMyData();
|
|
147
176
|
return profileFromData(data, storedEmail);
|