@vtex/faststore 0.0.3 → 0.0.5

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 (97) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/README.md +7 -3
  3. package/dist/catalog.json +337 -1
  4. package/dist/components.d.ts +5 -1
  5. package/dist/components.js +8 -4
  6. package/dist/content-types.json +73 -0
  7. package/dist/docs/account-access-gate.md +153 -0
  8. package/dist/docs/account-entry-point.md +1 -2
  9. package/dist/docs/account-menu.md +164 -0
  10. package/dist/docs/buy-button.md +1 -1
  11. package/dist/docs/cart.md +1 -1
  12. package/dist/docs/my-account-profile.md +208 -0
  13. package/dist/docs/session.md +1 -1
  14. package/dist/docs/sign-in-redirect.md +1 -1
  15. package/dist/matter/account-access-gate/account-access-gate.d.ts +86 -0
  16. package/dist/matter/account-access-gate/account-access-gate.js +283 -0
  17. package/dist/matter/account-access-gate/account-access-gate.js.map +1 -0
  18. package/dist/matter/account-access-gate/sign-out-intent.d.ts +17 -0
  19. package/dist/matter/account-access-gate/sign-out-intent.js +62 -0
  20. package/dist/matter/account-access-gate/sign-out-intent.js.map +1 -0
  21. package/dist/matter/account-entry-point/account-entry-point.js +2 -2
  22. package/dist/matter/account-entry-point/account-entry-point.js.map +1 -1
  23. package/dist/matter/account-menu/account-menu.d.ts +88 -0
  24. package/dist/matter/account-menu/account-menu.js +246 -0
  25. package/dist/matter/account-menu/account-menu.js.map +1 -0
  26. package/dist/matter/cart/cart.d.ts +1 -1
  27. package/dist/matter/cart/cart.js +2 -2
  28. package/dist/matter/cart/cart.js.map +1 -1
  29. package/dist/matter/delivery-options/delivery-options.js.map +1 -1
  30. package/dist/matter/my-account-profile/my-account-profile.d.ts +291 -0
  31. package/dist/matter/my-account-profile/my-account-profile.js +856 -0
  32. package/dist/matter/my-account-profile/my-account-profile.js.map +1 -0
  33. package/dist/matter/shipping-address/shipping-address.js +2 -2
  34. package/dist/matter/shipping-address/shipping-address.js.map +1 -1
  35. package/dist/matter/shipping-simulator/shipping-simulator.js.map +1 -1
  36. package/dist/particles/footer-social/footer-social.js +1 -1
  37. package/dist/particles/incentives/incentives.js +1 -1
  38. package/dist/sdk/actions/cart-action-provider.d.ts +1 -1
  39. package/dist/sdk/actions/cart-action-provider.js +1 -1
  40. package/dist/sdk/actions/cart-action-provider.js.map +1 -1
  41. package/dist/sdk/actions/session-action-provider.d.ts +1 -1
  42. package/dist/sdk/actions/session-action-provider.js +1 -1
  43. package/dist/sdk/actions/session-action-provider.js.map +1 -1
  44. package/dist/sdk/actions/shipping-action-provider.d.ts +1 -1
  45. package/dist/sdk/actions/shipping-action-provider.js +1 -1
  46. package/dist/sdk/actions/shipping-action-provider.js.map +1 -1
  47. package/dist/sdk/cache/storefront-cache.js +1 -1
  48. package/dist/sdk/cache/storefront-cache.js.map +1 -1
  49. package/dist/sdk/cart/operations.d.ts +4 -4
  50. package/dist/sdk/cart/operations.js +1 -1
  51. package/dist/sdk/cart/operations.js.map +1 -1
  52. package/dist/sdk/cart/optimistic.js +1 -1
  53. package/dist/sdk/cart/optimistic.js.map +1 -1
  54. package/dist/sdk/cart/use-cart-actions.d.ts +1 -1
  55. package/dist/sdk/cart/use-cart-actions.js +3 -3
  56. package/dist/sdk/cart/use-cart-actions.js.map +1 -1
  57. package/dist/sdk/cart/use-cart-validate-on-open.js +1 -1
  58. package/dist/sdk/cart/use-cart-validate-on-open.js.map +1 -1
  59. package/dist/sdk/cart/write-gate.js +1 -1
  60. package/dist/sdk/cart/write-gate.js.map +1 -1
  61. package/dist/sdk/data/page-reactive-data-root.d.ts +2 -2
  62. package/dist/sdk/data/page-reactive-data-root.js.map +1 -1
  63. package/dist/sdk/data/reactive-data-provider.d.ts +1 -1
  64. package/dist/sdk/data/reactive-data-provider.js +1 -1
  65. package/dist/sdk/data/reactive-data-provider.js.map +1 -1
  66. package/dist/sdk/data/reactive-list-item-data-provider.d.ts +1 -1
  67. package/dist/sdk/data/reactive-list-item-data-provider.js +1 -1
  68. package/dist/sdk/data/reactive-list-item-data-provider.js.map +1 -1
  69. package/dist/sdk/data/use-reactive-entity.js +1 -1
  70. package/dist/sdk/data/use-reactive-entity.js.map +1 -1
  71. package/dist/sdk/generated/gql.js +2 -1
  72. package/dist/sdk/generated/gql.js.map +1 -1
  73. package/dist/sdk/generated/graphql.js +85 -1
  74. package/dist/sdk/generated/graphql.js.map +1 -1
  75. package/dist/sdk/identity/operations.js.map +1 -1
  76. package/dist/sdk/identity/use-identity-actions.d.ts +1 -1
  77. package/dist/sdk/identity/use-identity-actions.js.map +1 -1
  78. package/dist/sdk/session/auth-operations.d.ts +1 -1
  79. package/dist/sdk/session/auth-operations.js.map +1 -1
  80. package/dist/sdk/session/use-session-actions.d.ts +1 -1
  81. package/dist/sdk/session/use-session-actions.js.map +1 -1
  82. package/dist/sdk/session/use-session-revalidation.js +65 -0
  83. package/dist/sdk/session/use-session-revalidation.js.map +1 -0
  84. package/dist/sdk/shipping/option-select-operations.d.ts +1 -1
  85. package/dist/sdk/shipping/option-select-operations.js.map +1 -1
  86. package/dist/sdk/shipping/request-timeout.js +1 -1
  87. package/dist/sdk/shipping/request-timeout.js.map +1 -1
  88. package/dist/sdk/shipping/shipping-operations.d.ts +1 -1
  89. package/dist/sdk/shipping/shipping-operations.js.map +1 -1
  90. package/dist/sdk/shipping/use-shipping-actions.d.ts +2 -2
  91. package/dist/sdk/shipping/use-shipping-actions.js.map +1 -1
  92. package/dist/sdk/state/cart.d.ts +3 -4
  93. package/dist/sdk/state/cart.js +6 -7
  94. package/dist/sdk/state/cart.js.map +1 -1
  95. package/dist/utils/safe-href.js +3 -3
  96. package/dist/utils/safe-href.js.map +1 -1
  97. package/package.json +1 -18
@@ -0,0 +1,283 @@
1
+ "use client";
2
+ import { defineComponent } from "../../core/dist/define-component.js";
3
+ import { defineContentType } from "../../core/dist/define-content-type.js";
4
+ import "../../core/dist/index.js";
5
+ import { useSession } from "../session/session.js";
6
+ import { resolveSignInHref } from "../../utils/safe-href.js";
7
+ import { NavigationLink } from "../../particles/navigation-link/navigation-link.js";
8
+ import { useSessionRevalidation } from "../../sdk/session/use-session-revalidation.js";
9
+ import { useSignOutIntent, withdrawSignOutIntent } from "./sign-out-intent.js";
10
+ import { useEffect, useRef, useState } from "react";
11
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
12
+ import { usePathname, useRouter } from "next/navigation";
13
+ import { flushSync } from "react-dom";
14
+ //#region src/matter/account-access-gate/account-access-gate.tsx
15
+ const AccountAccessGateContent = defineContentType({
16
+ id: "account-access-gate",
17
+ title: "Account Access Gate",
18
+ description: "What the shopper is told while the account resolves and when it will not open for them.",
19
+ schema: {
20
+ type: "object",
21
+ additionalProperties: false,
22
+ properties: {
23
+ loadingLabel: {
24
+ type: "string",
25
+ minLength: 1,
26
+ title: "Loading announcement"
27
+ },
28
+ expiredMessage: {
29
+ type: "string",
30
+ minLength: 1,
31
+ title: "Session ended message"
32
+ },
33
+ signInIncompleteMessage: {
34
+ type: "string",
35
+ minLength: 1,
36
+ title: "Sign-in did not complete message"
37
+ },
38
+ signInLabel: {
39
+ type: "string",
40
+ minLength: 1,
41
+ title: "Sign-in link label"
42
+ }
43
+ }
44
+ }
45
+ });
46
+ const AccountAccessGateDefinition = defineComponent({
47
+ name: "AccountAccessGate",
48
+ importPath: "@vtex/faststore/components",
49
+ component: AccountAccessGate,
50
+ content: AccountAccessGateContent,
51
+ editor: {
52
+ label: "Account Access Gate",
53
+ category: "identity"
54
+ },
55
+ requiresContext: "session",
56
+ schema: {
57
+ loadingLabel: {
58
+ type: "string",
59
+ label: "Loading Announcement"
60
+ },
61
+ expiredMessage: {
62
+ type: "string",
63
+ label: "Session Ended Message"
64
+ },
65
+ signInIncompleteMessage: {
66
+ type: "string",
67
+ label: "Sign-in Did Not Complete Message"
68
+ },
69
+ signInLabel: {
70
+ type: "string",
71
+ label: "Sign-in Link Label"
72
+ }
73
+ },
74
+ guideline: "The account's single access decision: place it once in the account layout, wrapping the body, and every page that declares that layout inherits it — never restate it per section. It renders its children only for a logged-in shopper; it shows a composed loading look while the session resolves, replaces the current history entry with the sign-in destination for a visitor who arrived signed out (identified counts as signed out), tells a shopper whose session ended mid-visit rather than bouncing them, and stands down while AccountMenuSignOut navigates. It redirects at most once per visit: a shopper who comes back from sign-in still signed out gets a message and a link rather than a second hop. Must be inside SessionRoot, which the same layout hosts. Never place the /login route under it — the gate redirects there, and a gated /login would redirect to itself."
75
+ });
76
+ /** The one automatic hop the gate has already spent, surviving the full document load out to the
77
+ * platform and back, and no further than this tab. */
78
+ const SIGN_IN_ATTEMPT_KEY = "fs::account-access-gate::sign-in-attempt";
79
+ function AccountAccessGate({ loadingLabel, expiredMessage, signInIncompleteMessage, signInLabel, $content, children }) {
80
+ const { state, loading } = useSession();
81
+ const signingOut = useSignOutIntent();
82
+ const pathname = usePathname();
83
+ const router = useRouter();
84
+ const revalidate = useSessionRevalidation();
85
+ const [wasSignedIn, setWasSignedIn] = useState(false);
86
+ const [unconfirmed, setUnconfirmed] = useState(false);
87
+ const [revalidating, setRevalidating] = useState(false);
88
+ const restoreGeneration = useRef(0);
89
+ const [hopSpent, setHopSpent] = useState(null);
90
+ const [search, setSearch] = useState(null);
91
+ useEffect(() => {
92
+ setSearch(globalThis.location.search);
93
+ });
94
+ const returnPath = pathname === null ? null : `${pathname}${search ?? ""}`;
95
+ const outcome = resolveOutcome({
96
+ signingOut,
97
+ unconfirmed,
98
+ revalidating,
99
+ loading,
100
+ state,
101
+ wasSignedIn,
102
+ hopSpent
103
+ });
104
+ useEffect(() => {
105
+ switch (outcome) {
106
+ case "account":
107
+ setWasSignedIn(true);
108
+ setUnconfirmed(false);
109
+ clearSignInAttempt();
110
+ return;
111
+ case "expired":
112
+ case "sign-in-incomplete":
113
+ clearSignInAttempt();
114
+ return;
115
+ case "signing-in": {
116
+ if (hopSpent !== null || search === null) return;
117
+ if (readSignInAttempt() !== null) {
118
+ setHopSpent(true);
119
+ return;
120
+ }
121
+ const destination = resolveSignInHref(returnPath);
122
+ recordSignInAttempt(destination);
123
+ setHopSpent(false);
124
+ router.replace(destination);
125
+ return;
126
+ }
127
+ case "stand-down":
128
+ case "loading": return;
129
+ default: assertUnreachable(outcome);
130
+ }
131
+ }, [
132
+ outcome,
133
+ hopSpent,
134
+ search,
135
+ returnPath,
136
+ router
137
+ ]);
138
+ useEffect(() => {
139
+ function handlePageHide(event) {
140
+ if (!event.persisted) return;
141
+ flushSync(() => {
142
+ setRevalidating(true);
143
+ });
144
+ }
145
+ function handlePageShow(event) {
146
+ if (!event.persisted) return;
147
+ const generation = restoreGeneration.current + 1;
148
+ restoreGeneration.current = generation;
149
+ withdrawSignOutIntent();
150
+ setUnconfirmed(false);
151
+ setRevalidating(true);
152
+ revalidate().then((result) => {
153
+ if (generation !== restoreGeneration.current) return;
154
+ setRevalidating(false);
155
+ switch (result) {
156
+ case "failed":
157
+ setUnconfirmed(true);
158
+ return;
159
+ case "revalidated":
160
+ case "unavailable": return;
161
+ default: assertUnreachable(result);
162
+ }
163
+ });
164
+ }
165
+ globalThis.addEventListener("pagehide", handlePageHide);
166
+ globalThis.addEventListener("pageshow", handlePageShow);
167
+ return () => {
168
+ globalThis.removeEventListener("pagehide", handlePageHide);
169
+ globalThis.removeEventListener("pageshow", handlePageShow);
170
+ };
171
+ }, [revalidate]);
172
+ useEffect(() => withdrawSignOutIntent, []);
173
+ const entryLoadingLabel = $content?.loadingLabel?.trim() ? $content.loadingLabel : loadingLabel;
174
+ const entryExpiredMessage = $content?.expiredMessage?.trim() ? $content.expiredMessage : expiredMessage;
175
+ const entryIncompleteMessage = $content?.signInIncompleteMessage?.trim() ? $content.signInIncompleteMessage : signInIncompleteMessage;
176
+ const entrySignInLabel = $content?.signInLabel?.trim() ? $content.signInLabel : signInLabel;
177
+ switch (outcome) {
178
+ case "stand-down":
179
+ case "signing-in": return null;
180
+ case "loading": return /* @__PURE__ */ jsx(AccountAccessGateLoading, {
181
+ "data-fs-account-access-gate": "",
182
+ children: entryLoadingLabel
183
+ });
184
+ case "account": return /* @__PURE__ */ jsx(Fragment, { children });
185
+ case "expired":
186
+ case "sign-in-incomplete": return /* @__PURE__ */ jsx(AccountAccessGateNotice, {
187
+ "data-fs-account-access-gate": "",
188
+ reason: outcome === "expired" ? "expired" : "sign-in-incomplete",
189
+ message: outcome === "expired" ? entryExpiredMessage : entryIncompleteMessage,
190
+ signInHref: resolveSignInHref(returnPath),
191
+ signInLabel: entrySignInLabel
192
+ });
193
+ default: return assertUnreachable(outcome);
194
+ }
195
+ }
196
+ /**
197
+ * The whole decision, as one ordered read of the gate's inputs.
198
+ *
199
+ * `signingOut` outranks everything, including a session still reading `loggedIn`: the sign-out records
200
+ * its intent before it awaits the mutation, and the frame between the payload landing and the document
201
+ * load starting is exactly the one this ordering protects.
202
+ *
203
+ * `loading` outranks the tri-state for the reason `AccountEntryPoint` gives: an unresolved session
204
+ * reports `anonymous`, so reading the state first would bounce a shopper who is signed in. A re-read
205
+ * in flight reads as the same wait: the session it is checking is one the gate has stopped believing.
206
+ */
207
+ function resolveOutcome({ signingOut, unconfirmed, revalidating, loading, state, wasSignedIn, hopSpent }) {
208
+ if (signingOut) return "stand-down";
209
+ if (unconfirmed) return wasSignedIn ? "expired" : "sign-in-incomplete";
210
+ if (revalidating || loading) return "loading";
211
+ if (state === "loggedIn") return "account";
212
+ if (wasSignedIn) return "expired";
213
+ return hopSpent === true ? "sign-in-incomplete" : "signing-in";
214
+ }
215
+ function assertUnreachable(outcome) {
216
+ throw new Error(`[AccountAccessGate] unhandled outcome: ${String(outcome)}`);
217
+ }
218
+ /**
219
+ * The look of a session that has not answered yet. A real part with its own hook rather than an ad hoc
220
+ * spinner, so a store can style it and a story can render it.
221
+ */
222
+ function AccountAccessGateLoading({ className, children, ...props }) {
223
+ return /* @__PURE__ */ jsx("output", {
224
+ ...props,
225
+ "aria-live": "polite",
226
+ className,
227
+ "data-fs-account-access-gate-loading": "",
228
+ children
229
+ });
230
+ }
231
+ /**
232
+ * What renders in the account's place when it will not open: the message for this reason, and a link
233
+ * the shopper may take back into sign-in.
234
+ *
235
+ * The link is the whole of the escape from a sign-in loop. The gate stops redirecting after one
236
+ * automatic hop, so the next attempt is a click rather than a bounce — and a shopper who keeps landing
237
+ * here at least lands on a page that says so.
238
+ */
239
+ function AccountAccessGateNotice({ reason, message, signInHref, signInLabel, className, ...props }) {
240
+ return /* @__PURE__ */ jsxs("output", {
241
+ ...props,
242
+ "aria-live": "polite",
243
+ className,
244
+ "data-fs-account-access-gate-notice": "",
245
+ "data-fs-account-access-gate-notice-reason": reason,
246
+ children: [message ? /* @__PURE__ */ jsx("span", {
247
+ "data-fs-account-access-gate-notice-message": "",
248
+ children: message
249
+ }) : null, signInLabel?.trim() ? /* @__PURE__ */ jsx(NavigationLink, {
250
+ href: signInHref,
251
+ prefetch: false,
252
+ "data-fs-account-access-gate-notice-action": "",
253
+ children: signInLabel
254
+ }) : null]
255
+ });
256
+ }
257
+ /**
258
+ * Session storage, guarded at every access. A browser that refuses it — a shopper blocking site data —
259
+ * throws rather than returning null, and a gate that cannot read its own record still has a shopper to
260
+ * get to sign-in. A refusal therefore reads as "no record", which spends the hop; the cost is that the
261
+ * loop protection is absent in that browser, which is the lesser of the two failures.
262
+ */
263
+ function readSignInAttempt() {
264
+ try {
265
+ return globalThis.sessionStorage.getItem(SIGN_IN_ATTEMPT_KEY);
266
+ } catch {
267
+ return null;
268
+ }
269
+ }
270
+ function recordSignInAttempt(destination) {
271
+ try {
272
+ globalThis.sessionStorage.setItem(SIGN_IN_ATTEMPT_KEY, destination);
273
+ } catch {}
274
+ }
275
+ function clearSignInAttempt() {
276
+ try {
277
+ globalThis.sessionStorage.removeItem(SIGN_IN_ATTEMPT_KEY);
278
+ } catch {}
279
+ }
280
+ //#endregion
281
+ export { AccountAccessGate, AccountAccessGateContent, AccountAccessGateDefinition, AccountAccessGateLoading, AccountAccessGateNotice };
282
+
283
+ //# sourceMappingURL=account-access-gate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"account-access-gate.js","names":[],"sources":["../../../src/matter/account-access-gate/account-access-gate.tsx"],"sourcesContent":["'use client';\n\nimport { type ContentValue, defineComponent, defineContentType } from '@vtex/fs-core';\nimport { usePathname, useRouter } from 'next/navigation';\nimport { type ComponentPropsWithRef, type ReactNode, useEffect, useRef, useState } from 'react';\nimport { flushSync } from 'react-dom';\nimport { NavigationLink } from '../../particles/navigation-link/navigation-link.js';\nimport { useSessionRevalidation } from '../../sdk/session/use-session-revalidation.js';\nimport { resolveSignInHref } from '../../utils/safe-href.js';\nimport { type SessionState, useSession } from '../session/session.js';\nimport { useSignOutIntent, withdrawSignOutIntent } from './sign-out-intent.js';\n\n// Nothing is required, following the shipped identity components: an entry may author any subset, and\n// a slice missing a required property is shape-invalid, which drops the whole element rather than the\n// one field.\nexport const AccountAccessGateContent = defineContentType({\n id: 'account-access-gate',\n title: 'Account Access Gate',\n description: 'What the shopper is told while the account resolves and when it will not open for them.',\n schema: {\n type: 'object',\n additionalProperties: false,\n properties: {\n loadingLabel: { type: 'string', minLength: 1, title: 'Loading announcement' },\n expiredMessage: { type: 'string', minLength: 1, title: 'Session ended message' },\n signInIncompleteMessage: { type: 'string', minLength: 1, title: 'Sign-in did not complete message' },\n signInLabel: { type: 'string', minLength: 1, title: 'Sign-in link label' },\n },\n },\n});\n\n/** Why the account will not open, as a bounded value: a style target and the choice of message. */\nexport type AccountAccessGateNoticeReason = 'expired' | 'sign-in-incomplete';\n\n/** Props for {@link AccountAccessGate}. It renders a different element per outcome and forwards no\n * element props of its own; each rendered part carries its own. */\nexport type AccountAccessGateProps = {\n /** Text announced while the session resolves. */\n loadingLabel?: string;\n /** What a shopper whose session ended mid-visit is told. */\n expiredMessage?: string;\n /** What a shopper who came back from sign-in still signed out is told. */\n signInIncompleteMessage?: string;\n /** Label of the link out of either notice. Without it no link renders — a focusable link a screen\n * reader announces as its bare URL is worse than no control at all. */\n signInLabel?: string;\n /** Merchant-authored fields, sliced from the layout content entry; win over the props field by field\n * when present. Absent in a non-CMS store — the props are the fallback. */\n $content?: ContentValue<typeof AccountAccessGateContent>;\n /** The account. Rendered only for a signed-in shopper. */\n children?: ReactNode;\n};\n\n/** Props for {@link AccountAccessGateLoading}. Extends native `<output>` attributes. */\nexport type AccountAccessGateLoadingProps = ComponentPropsWithRef<'output'>;\n\n/** Props for {@link AccountAccessGateNotice}. Extends native `<output>` attributes. */\nexport type AccountAccessGateNoticeProps = Omit<ComponentPropsWithRef<'output'>, 'children'> & {\n reason: AccountAccessGateNoticeReason;\n /** The message for this reason. Nothing renders in its place when unauthored. */\n message?: string;\n /** Where the link out leads, built by the gate from the page the shopper is on. */\n signInHref: string;\n /** Label of the link out. No label, no link. */\n signInLabel?: string;\n};\n\nexport const AccountAccessGateDefinition = defineComponent<AccountAccessGateProps>({\n name: 'AccountAccessGate',\n importPath: '@vtex/faststore/components',\n component: AccountAccessGate,\n content: AccountAccessGateContent,\n editor: { label: 'Account Access Gate', category: 'identity' },\n requiresContext: 'session',\n schema: {\n // Mirrored from the content model on purpose, as every content-bearing component in the library\n // does: the entry wins when published, and this is what a store without a CMS authors.\n loadingLabel: { type: 'string', label: 'Loading Announcement' },\n expiredMessage: { type: 'string', label: 'Session Ended Message' },\n signInIncompleteMessage: { type: 'string', label: 'Sign-in Did Not Complete Message' },\n signInLabel: { type: 'string', label: 'Sign-in Link Label' },\n },\n guideline:\n \"The account's single access decision: place it once in the account layout, wrapping the body, and every page that declares that layout inherits it — never restate it per section. It renders its children only for a logged-in shopper; it shows a composed loading look while the session resolves, replaces the current history entry with the sign-in destination for a visitor who arrived signed out (identified counts as signed out), tells a shopper whose session ended mid-visit rather than bouncing them, and stands down while AccountMenuSignOut navigates. It redirects at most once per visit: a shopper who comes back from sign-in still signed out gets a message and a link rather than a second hop. Must be inside SessionRoot, which the same layout hosts. Never place the /login route under it — the gate redirects there, and a gated /login would redirect to itself.\",\n});\n\n/** The one automatic hop the gate has already spent, surviving the full document load out to the\n * platform and back, and no further than this tab. */\nconst SIGN_IN_ATTEMPT_KEY = 'fs::account-access-gate::sign-in-attempt';\n\n/**\n * What the gate renders, in precedence order. `signing-in` covers both the frame that decides whether\n * the hop is still available and the frame after the replace is issued: they render the same nothing,\n * and only the effect tells them apart.\n */\ntype AccountAccessGateOutcome = 'stand-down' | 'expired' | 'loading' | 'account' | 'sign-in-incomplete' | 'signing-in';\n\nexport function AccountAccessGate({\n loadingLabel,\n expiredMessage,\n signInIncompleteMessage,\n signInLabel,\n $content,\n children,\n}: Readonly<AccountAccessGateProps>) {\n const { state, loading } = useSession();\n const signingOut = useSignOutIntent();\n const pathname = usePathname();\n const router = useRouter();\n const revalidate = useSessionRevalidation();\n\n // Whether this gate has ever resolved to a signed-in shopper. It is what separates a session that\n // ended from a visitor who arrived signed out — the tri-state spells both `anonymous`.\n const [wasSignedIn, setWasSignedIn] = useState(false);\n // A revalidation that could not answer. It outranks `loading` because the discard that preceded it\n // is what leaves the session unresolved, so nothing else is coming to end that wait.\n const [unconfirmed, setUnconfirmed] = useState(false);\n // A re-read in flight. The gate withholds the account for itself rather than waiting to be told:\n // discarding the cached session leaves the data layer unresolved, but it reaches the gate only once\n // the watched query has re-read, and the account must be gone in the frame the restore arrives.\n const [revalidating, setRevalidating] = useState(false);\n // Which re-read the gate is still listening to. Two restores in a row put two answers in flight, and\n // the older one may land last.\n const restoreGeneration = useRef(0);\n // `null` until the arrival path has read the record. Read from an effect rather than from the render\n // body: session storage does not exist on the server, and a value that appeared between the server\n // pass and hydration would change what renders underneath it.\n const [hopSpent, setHopSpent] = useState<boolean | null>(null);\n // `null` until the document has been read, for the same two reasons, and read from the document\n // rather than through `useSearchParams()`, which would require a `Suspense` boundary the generator\n // does not emit on a prerendered route — the reason `SignInRedirect` gives for reading it this way.\n const [search, setSearch] = useState<string | null>(null);\n\n // Deliberately on every commit rather than on mount: `usePathname()` re-renders the gate when the\n // path changes but says nothing about the query, and a shopper who pages through their orders\n // changes only the query. Setting the same string is a bail-out, so this does not loop.\n useEffect(() => {\n setSearch(globalThis.location.search);\n });\n\n // Where the shopper comes back to. `usePathname()` yields the path alone, so a gate that stopped\n // there would return someone reading `/account/orders?page=2` to the first page of it.\n const returnPath = pathname === null ? null : `${pathname}${search ?? ''}`;\n\n const outcome = resolveOutcome({ signingOut, unconfirmed, revalidating, loading, state, wasSignedIn, hopSpent });\n\n useEffect(() => {\n switch (outcome) {\n case 'account':\n setWasSignedIn(true);\n setUnconfirmed(false);\n clearSignInAttempt();\n return;\n case 'expired':\n case 'sign-in-incomplete':\n // Every outcome that is not the hop returns it: a shopper who signs in, browses, and comes\n // back later arrives fresh rather than carrying a spent attempt from an earlier one.\n clearSignInAttempt();\n return;\n case 'signing-in': {\n // One more frame before deciding, until the document has been read: a hop recorded against the\n // bare path is the one the shopper comes back to, and there is no second chance at it.\n if (hopSpent !== null || search === null) {\n return;\n }\n if (readSignInAttempt() !== null) {\n setHopSpent(true);\n return;\n }\n const destination = resolveSignInHref(returnPath);\n recordSignInAttempt(destination);\n setHopSpent(false);\n // Replace rather than push: back from the platform's login should reach the page the shopper\n // came from, not the account that threw them at it.\n // react-doctor-disable-next-line nextjs-no-client-side-redirect -- the session resolves on the client, so the server has nothing to decide with\n router.replace(destination);\n return;\n }\n case 'stand-down':\n case 'loading':\n return;\n default:\n assertUnreachable(outcome);\n }\n }, [outcome, hopSpent, search, returnPath, router]);\n\n useEffect(() => {\n function handlePageHide(event: PageTransitionEvent): void {\n if (!event.persisted) {\n return;\n }\n // What the browser freezes is the DOM, and a restore puts that same DOM back before any script\n // runs. Standing the account down on the way out rather than on the way back is what keeps the\n // restored document from showing it in the frames before `pageshow` can decide again.\n flushSync(() => {\n setRevalidating(true);\n });\n }\n\n function handlePageShow(event: PageTransitionEvent): void {\n // An ordinary load re-decides by mounting. Only a restore resumes a heap that already holds an\n // answer, and `persisted` is the browser's own word for it.\n if (!event.persisted) {\n return;\n }\n const generation = restoreGeneration.current + 1;\n restoreGeneration.current = generation;\n // The navigation this authorized has already happened; a restored document holding it would\n // stand down forever. Withdrawn before the re-read so the gate is deciding again by the time\n // the answer lands.\n withdrawSignOutIntent();\n setUnconfirmed(false);\n setRevalidating(true);\n void revalidate().then((result) => {\n // A later restore has already asked the same question, and its answer is the one that counts.\n // This one describes a session the gate has since discarded a second time.\n if (generation !== restoreGeneration.current) {\n return;\n }\n setRevalidating(false);\n switch (result) {\n case 'failed':\n setUnconfirmed(true);\n return;\n case 'revalidated':\n case 'unavailable':\n // Nothing left to distrust: either the session was re-read, or there was no cached\n // session to discard in the first place and the one in the tree came from a prop.\n return;\n default:\n assertUnreachable(result);\n }\n });\n }\n\n globalThis.addEventListener('pagehide', handlePageHide);\n globalThis.addEventListener('pageshow', handlePageShow);\n return () => {\n globalThis.removeEventListener('pagehide', handlePageHide);\n globalThis.removeEventListener('pageshow', handlePageShow);\n };\n }, [revalidate]);\n\n // The intent authorizes one transition and this gate is its only reader, so it must not survive the\n // gate. A sign-out that navigates client-side takes the account layout down without reloading the\n // document, and nothing else would ever take the flag back: the next account page the shopper opens\n // would mount into a standing intent and render nothing at all, with no error to explain it.\n useEffect(() => withdrawSignOutIntent, []);\n\n // Blank entry fields fall through, so clearing one in the Admin reads as unauthored.\n const entryLoadingLabel = $content?.loadingLabel?.trim() ? $content.loadingLabel : loadingLabel;\n const entryExpiredMessage = $content?.expiredMessage?.trim() ? $content.expiredMessage : expiredMessage;\n const entryIncompleteMessage = $content?.signInIncompleteMessage?.trim()\n ? $content.signInIncompleteMessage\n : signInIncompleteMessage;\n const entrySignInLabel = $content?.signInLabel?.trim() ? $content.signInLabel : signInLabel;\n\n switch (outcome) {\n case 'stand-down':\n case 'signing-in':\n return null;\n case 'loading':\n return (\n // The part carries its own hook; the component's identity travels from here, which is how a\n // store targets it by name the way every other component is targeted.\n <AccountAccessGateLoading data-fs-account-access-gate=\"\">{entryLoadingLabel}</AccountAccessGateLoading>\n );\n case 'account':\n return <>{children}</>;\n case 'expired':\n case 'sign-in-incomplete':\n return (\n <AccountAccessGateNotice\n data-fs-account-access-gate=\"\"\n reason={outcome === 'expired' ? 'expired' : 'sign-in-incomplete'}\n message={outcome === 'expired' ? entryExpiredMessage : entryIncompleteMessage}\n signInHref={resolveSignInHref(returnPath)}\n signInLabel={entrySignInLabel}\n />\n );\n default:\n return assertUnreachable(outcome);\n }\n}\n\n/**\n * The whole decision, as one ordered read of the gate's inputs.\n *\n * `signingOut` outranks everything, including a session still reading `loggedIn`: the sign-out records\n * its intent before it awaits the mutation, and the frame between the payload landing and the document\n * load starting is exactly the one this ordering protects.\n *\n * `loading` outranks the tri-state for the reason `AccountEntryPoint` gives: an unresolved session\n * reports `anonymous`, so reading the state first would bounce a shopper who is signed in. A re-read\n * in flight reads as the same wait: the session it is checking is one the gate has stopped believing.\n */\nfunction resolveOutcome({\n signingOut,\n unconfirmed,\n revalidating,\n loading,\n state,\n wasSignedIn,\n hopSpent,\n}: {\n signingOut: boolean;\n unconfirmed: boolean;\n revalidating: boolean;\n loading: boolean;\n state: SessionState;\n wasSignedIn: boolean;\n hopSpent: boolean | null;\n}): AccountAccessGateOutcome {\n if (signingOut) {\n return 'stand-down';\n }\n // A re-read that could not answer says nothing about how the shopper got here, so the notice keeps\n // the history the gate already has. Telling someone who never reached the account that their session\n // ended names an event that never happened; the incomplete sign-in is the one they actually had.\n if (unconfirmed) {\n return wasSignedIn ? 'expired' : 'sign-in-incomplete';\n }\n if (revalidating || loading) {\n return 'loading';\n }\n if (state === 'loggedIn') {\n return 'account';\n }\n if (wasSignedIn) {\n return 'expired';\n }\n return hopSpent === true ? 'sign-in-incomplete' : 'signing-in';\n}\n\nfunction assertUnreachable(outcome: never): never {\n throw new Error(`[AccountAccessGate] unhandled outcome: ${String(outcome)}`);\n}\n\n/**\n * The look of a session that has not answered yet. A real part with its own hook rather than an ad hoc\n * spinner, so a store can style it and a story can render it.\n */\nexport function AccountAccessGateLoading({ className, children, ...props }: AccountAccessGateLoadingProps) {\n return (\n <output {...props} aria-live=\"polite\" className={className} data-fs-account-access-gate-loading=\"\">\n {children}\n </output>\n );\n}\n\n/**\n * What renders in the account's place when it will not open: the message for this reason, and a link\n * the shopper may take back into sign-in.\n *\n * The link is the whole of the escape from a sign-in loop. The gate stops redirecting after one\n * automatic hop, so the next attempt is a click rather than a bounce — and a shopper who keeps landing\n * here at least lands on a page that says so.\n */\nexport function AccountAccessGateNotice({\n reason,\n message,\n signInHref,\n signInLabel,\n className,\n ...props\n}: AccountAccessGateNoticeProps) {\n return (\n <output\n {...props}\n aria-live=\"polite\"\n className={className}\n data-fs-account-access-gate-notice=\"\"\n data-fs-account-access-gate-notice-reason={reason}\n >\n {message ? <span data-fs-account-access-gate-notice-message=\"\">{message}</span> : null}\n {signInLabel?.trim() ? (\n <NavigationLink\n href={signInHref}\n // The destination is a trampoline that redirects on mount, so the default prefetch would\n // fire that GET from a page the shopper may never leave.\n prefetch={false}\n data-fs-account-access-gate-notice-action=\"\"\n >\n {signInLabel}\n </NavigationLink>\n ) : null}\n </output>\n );\n}\n\n/**\n * Session storage, guarded at every access. A browser that refuses it — a shopper blocking site data —\n * throws rather than returning null, and a gate that cannot read its own record still has a shopper to\n * get to sign-in. A refusal therefore reads as \"no record\", which spends the hop; the cost is that the\n * loop protection is absent in that browser, which is the lesser of the two failures.\n */\nfunction readSignInAttempt(): string | null {\n try {\n return globalThis.sessionStorage.getItem(SIGN_IN_ATTEMPT_KEY);\n } catch {\n return null;\n }\n}\n\nfunction recordSignInAttempt(destination: string): void {\n try {\n globalThis.sessionStorage.setItem(SIGN_IN_ATTEMPT_KEY, destination);\n } catch {\n // Nothing to fall back to: the record is the only thing that outlives the hop.\n }\n}\n\nfunction clearSignInAttempt(): void {\n try {\n globalThis.sessionStorage.removeItem(SIGN_IN_ATTEMPT_KEY);\n } catch {\n // Nothing was written either, so there is nothing to undo.\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAeA,MAAa,2BAA2B,kBAAkB;CACxD,IAAI;CACJ,OAAO;CACP,aAAa;CACb,QAA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A,WACA,GAAG,SAC4B;CAC/B,OACE,qBAAC,UAAD;EACE,GAAI;EACJ,aAAU;EACC;EACX,sCAAmC;EACnC,6CAA2C;EAL7C,UAAA,CAOG,UAAU,oBAAC,QAAD;GAAM,8CAA2C;GAAI,UAAA;EAAc,CAAA,IAAI,MACjF,aAAa,KAAK,IACjB,oBAAC,gBAAD;GACE,MAAM;GAGN,UAAU;GACV,6CAA0C;GAEzC,UAAA;EACa,CAAA,IACd,IACE;;AAEZ;;;;;;;AAQA,SAAS,oBAAmC;CAC1C,IAAI;EACF,OAAO,WAAW,eAAe,QAAQ,mBAAmB;CAC9D,QAAQ;EACN,OAAO;CACT;AACF;AAEA,SAAS,oBAAoB,aAA2B;CACtD,IAAI;EACF,WAAW,eAAe,QAAQ,qBAAqB,WAAW;CACpE,QAAQ,CAER;AACF;AAEA,SAAS,qBAA2B;CAClC,IAAI;EACF,WAAW,eAAe,WAAW,mBAAmB;CAC1D,QAAQ,CAER;AACF"}
@@ -0,0 +1,17 @@
1
+ //#region src/matter/account-access-gate/sign-out-intent.d.ts
2
+ /**
3
+ * Records that a sign-out is under way. Declared **before** the logout is awaited: the payload
4
+ * refreshes the session in place, and a gate that got its turn between the response landing and the
5
+ * navigation starting would redirect out from under the sign-out.
6
+ */
7
+ export declare function declareSignOutIntent(): void;
8
+ /**
9
+ * Takes the intent back. Called when the logout resolves with user errors — the shopper is still
10
+ * signed in and stays on the account page with the failure surfaced — and by the gate on a restored
11
+ * document, where the navigation the intent authorized has already happened.
12
+ */
13
+ export declare function withdrawSignOutIntent(): void;
14
+ /** Whether a sign-out is under way, re-rendering the caller when that changes. */
15
+ export declare function useSignOutIntent(): boolean;
16
+ //#endregion
17
+ //# sourceMappingURL=sign-out-intent.d.ts.map
@@ -0,0 +1,62 @@
1
+ "use client";
2
+ import { useSyncExternalStore } from "react";
3
+ //#region src/matter/account-access-gate/sign-out-intent.ts
4
+ /**
5
+ * The signal that tells `AccountAccessGate` a signed-out session is the shopper's own doing.
6
+ *
7
+ * Without it the two fight each other: `$actions.session.logout` resolves with the refreshed session
8
+ * in its payload, so the tri-state flips to anonymous *in place*, while the shopper is still standing
9
+ * on an account page. The gate would read that as any other signed-out shopper and redirect to
10
+ * sign-in, carrying a return to the account they just left — racing the sign-out's own navigation.
11
+ *
12
+ * Deliberately not persisted. The intent authorizes exactly one transition and dies with the document
13
+ * that authorized it, which is why the full load to `/` needs no cleanup. The one case where the
14
+ * document comes back with the flag still standing is a back-forward cache restore, and the gate
15
+ * withdraws it there.
16
+ */
17
+ let intended = false;
18
+ const subscribers = /* @__PURE__ */ new Set();
19
+ function notify() {
20
+ for (const subscriber of subscribers) subscriber();
21
+ }
22
+ /**
23
+ * Records that a sign-out is under way. Declared **before** the logout is awaited: the payload
24
+ * refreshes the session in place, and a gate that got its turn between the response landing and the
25
+ * navigation starting would redirect out from under the sign-out.
26
+ */
27
+ function declareSignOutIntent() {
28
+ if (intended) return;
29
+ intended = true;
30
+ notify();
31
+ }
32
+ /**
33
+ * Takes the intent back. Called when the logout resolves with user errors — the shopper is still
34
+ * signed in and stays on the account page with the failure surfaced — and by the gate on a restored
35
+ * document, where the navigation the intent authorized has already happened.
36
+ */
37
+ function withdrawSignOutIntent() {
38
+ if (!intended) return;
39
+ intended = false;
40
+ notify();
41
+ }
42
+ function subscribe(onStoreChange) {
43
+ subscribers.add(onStoreChange);
44
+ return () => {
45
+ subscribers.delete(onStoreChange);
46
+ };
47
+ }
48
+ function getSnapshot() {
49
+ return intended;
50
+ }
51
+ /** Server renders never carry an intent: nothing has been able to click sign out yet. */
52
+ function getServerSnapshot() {
53
+ return false;
54
+ }
55
+ /** Whether a sign-out is under way, re-rendering the caller when that changes. */
56
+ function useSignOutIntent() {
57
+ return useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
58
+ }
59
+ //#endregion
60
+ export { declareSignOutIntent, useSignOutIntent, withdrawSignOutIntent };
61
+
62
+ //# sourceMappingURL=sign-out-intent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sign-out-intent.js","names":[],"sources":["../../../src/matter/account-access-gate/sign-out-intent.ts"],"sourcesContent":["'use client';\n\nimport { useSyncExternalStore } from 'react';\n\n/**\n * The signal that tells `AccountAccessGate` a signed-out session is the shopper's own doing.\n *\n * Without it the two fight each other: `$actions.session.logout` resolves with the refreshed session\n * in its payload, so the tri-state flips to anonymous *in place*, while the shopper is still standing\n * on an account page. The gate would read that as any other signed-out shopper and redirect to\n * sign-in, carrying a return to the account they just left — racing the sign-out's own navigation.\n *\n * Deliberately not persisted. The intent authorizes exactly one transition and dies with the document\n * that authorized it, which is why the full load to `/` needs no cleanup. The one case where the\n * document comes back with the flag still standing is a back-forward cache restore, and the gate\n * withdraws it there.\n */\nlet intended = false;\n\nconst subscribers = new Set<() => void>();\n\nfunction notify(): void {\n for (const subscriber of subscribers) {\n subscriber();\n }\n}\n\n/**\n * Records that a sign-out is under way. Declared **before** the logout is awaited: the payload\n * refreshes the session in place, and a gate that got its turn between the response landing and the\n * navigation starting would redirect out from under the sign-out.\n */\nexport function declareSignOutIntent(): void {\n if (intended) {\n return;\n }\n intended = true;\n notify();\n}\n\n/**\n * Takes the intent back. Called when the logout resolves with user errors — the shopper is still\n * signed in and stays on the account page with the failure surfaced — and by the gate on a restored\n * document, where the navigation the intent authorized has already happened.\n */\nexport function withdrawSignOutIntent(): void {\n if (!intended) {\n return;\n }\n intended = false;\n notify();\n}\n\nfunction subscribe(onStoreChange: () => void): () => void {\n subscribers.add(onStoreChange);\n return () => {\n subscribers.delete(onStoreChange);\n };\n}\n\nfunction getSnapshot(): boolean {\n return intended;\n}\n\n/** Server renders never carry an intent: nothing has been able to click sign out yet. */\nfunction getServerSnapshot(): boolean {\n return false;\n}\n\n/** Whether a sign-out is under way, re-rendering the caller when that changes. */\nexport function useSignOutIntent(): boolean {\n return useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAiBA,IAAI,WAAW;AAEf,MAAM,8BAAc,IAAI,IAAgB;AAExC,SAAS,SAAe;CACtB,KAAK,MAAM,cAAc,aACvB,WAAW;AAEf;;;;;;AAOA,SAAgB,uBAA6B;CAC3C,IAAI,UACF;CAEF,WAAW;CACX,OAAO;AACT;;;;;;AAOA,SAAgB,wBAA8B;CAC5C,IAAI,CAAC,UACH;CAEF,WAAW;CACX,OAAO;AACT;AAEA,SAAS,UAAU,eAAuC;CACxD,YAAY,IAAI,aAAa;CAC7B,aAAa;EACX,YAAY,OAAO,aAAa;CAClC;AACF;AAEA,SAAS,cAAuB;CAC9B,OAAO;AACT;;AAGA,SAAS,oBAA6B;CACpC,OAAO;AACT;;AAGA,SAAgB,mBAA4B;CAC1C,OAAO,qBAAqB,WAAW,aAAa,iBAAiB;AACvE"}
@@ -3,9 +3,9 @@ import { defineComponent } from "../../core/dist/define-component.js";
3
3
  import { defineContentType } from "../../core/dist/define-content-type.js";
4
4
  import "../../core/dist/index.js";
5
5
  import { useSession } from "../session/session.js";
6
- import { Icon } from "../../particles/icon/icon.js";
7
6
  import { resolveSignInHref } from "../../utils/safe-href.js";
8
7
  import { NavigationLink } from "../../particles/navigation-link/navigation-link.js";
8
+ import { Icon } from "../../particles/icon/icon.js";
9
9
  import { useEffect, useState } from "react";
10
10
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
11
11
  import { usePathname } from "next/navigation";
@@ -72,7 +72,7 @@ const AccountEntryPointDefinition = defineComponent({
72
72
  label: "Loading Announcement"
73
73
  }
74
74
  },
75
- guideline: "Session-aware header control rendering one link: the signed-out label toward /login for anonymous and identified shoppers, the signed-in label toward the account route for logged-in ones, and a politely announced placeholder while the session resolves. Both destinations are fixed conventions, not props, so no authored value can misroute the auth flow. Must be inside a SessionRoot, normally the one hosted by the shared layout — a page-hosted provider resolves the session server-side without the shopper cookie and sticks on the signed-out label. Author the label for a state or that state renders nothing; the labels are optional in the type only because a CMS entry may supply them, and an entry overrides all four fields at runtime. Style it through data-fs-account-entry-point and switch on data-fs-account-entry-point-state."
75
+ guideline: "Session-aware header control rendering one link: the signed-out label toward /login for anonymous and identified shoppers, the signed-in label toward the account route for logged-in ones, and a politely announced placeholder while the session resolves. Both destinations are fixed conventions, not props, so no authored value can misroute the auth flow. Must be inside a SessionRoot, normally the one hosted by the shared layout; a page-hosted provider also works, since the server-side session fetch forwards the shopper cookie. Author the label for a state or that state renders nothing; the labels are optional in the type only because a CMS entry may supply them, and an entry overrides all four fields at runtime. Style it through data-fs-account-entry-point and switch on data-fs-account-entry-point-state."
76
76
  });
77
77
  function AccountEntryPoint({ signedOutLabel, signedInLabel, icon, loadingLabel, $content, className, ref, ...props }) {
78
78
  const { state, loading } = useSession();
@@ -1 +1 @@
1
- {"version":3,"file":"account-entry-point.js","names":[],"sources":["../../../src/matter/account-entry-point/account-entry-point.tsx"],"sourcesContent":["'use client';\n\nimport { type ContentValue, defineComponent, defineContentType } from '@vtex/fs-core';\nimport { usePathname } from 'next/navigation';\nimport { type ComponentPropsWithRef, useEffect, useState } from 'react';\nimport { Icon } from '../../particles/icon/icon.js';\nimport { NavigationLink } from '../../particles/navigation-link/navigation-link.js';\nimport { resolveSignInHref } from '../../utils/safe-href.js';\nimport { useSession } from '../session/session.js';\n\n/** The account's root. A fixed convention, never an authored value: an authored destination could\n * misroute the entry into the account. */\nconst ACCOUNT_ROUTE = '/account';\n\n// Nothing is required: an entry may author any subset, and a slice missing a required property is\n// shape-invalid, which drops the whole element rather than the one field.\nexport const AccountEntryPointContent = defineContentType({\n id: 'account-entry-point',\n title: 'Account Entry Point',\n description: 'Labels and icon for the header sign-in / account control.',\n schema: {\n type: 'object',\n additionalProperties: false,\n properties: {\n signedOutLabel: { type: 'string', minLength: 1, title: 'Signed-out label' },\n signedInLabel: { type: 'string', minLength: 1, title: 'Signed-in label' },\n icon: { type: 'string', minLength: 1, title: 'Icon' },\n loadingLabel: { type: 'string', minLength: 1, title: 'Loading announcement' },\n },\n },\n});\n\n/** Props for {@link AccountEntryPoint}. Extends native `<a>` attributes (the rendered root). */\nexport type AccountEntryPointProps = Omit<ComponentPropsWithRef<'a'>, 'href' | 'children'> & {\n /** Label for anonymous and identified shoppers. Optional: the render gate, not the type,\n * requires a resolved value. */\n signedOutLabel?: string;\n /** Label for logged-in shoppers. Same gate. */\n signedInLabel?: string;\n /** Icon reference for the glyph. Never gated: a control with no glyph is a valid configuration. */\n icon?: string;\n /** Text the live region announces while the session resolves. */\n loadingLabel?: string;\n /** Merchant-authored fields, sliced from the page/layout content entry; win over the props field\n * by field when present. Absent in a non-CMS store — the props are the fallback. */\n $content?: ContentValue<typeof AccountEntryPointContent>;\n};\n\n/** Props for {@link AccountEntryPointLoading}. Extends native `<span>` attributes. */\nexport type AccountEntryPointLoadingProps = Omit<ComponentPropsWithRef<'span'>, 'children'>;\n\nexport const AccountEntryPointDefinition = defineComponent<AccountEntryPointProps>({\n name: 'AccountEntryPoint',\n importPath: '@vtex/faststore/components',\n component: AccountEntryPoint,\n content: AccountEntryPointContent,\n editor: { label: 'Account Entry Point', category: 'identity' },\n requiresContext: 'session',\n schema: {\n signedOutLabel: { type: 'string', label: 'Signed-out Label' },\n signedInLabel: { type: 'string', label: 'Signed-in Label' },\n icon: { type: 'icon', label: 'Icon' },\n loadingLabel: { type: 'string', label: 'Loading Announcement' },\n },\n guideline:\n 'Session-aware header control rendering one link: the signed-out label toward /login for anonymous and identified shoppers, the signed-in label toward the account route for logged-in ones, and a politely announced placeholder while the session resolves. Both destinations are fixed conventions, not props, so no authored value can misroute the auth flow. Must be inside a SessionRoot, normally the one hosted by the shared layout — a page-hosted provider resolves the session server-side without the shopper cookie and sticks on the signed-out label. Author the label for a state or that state renders nothing; the labels are optional in the type only because a CMS entry may supply them, and an entry overrides all four fields at runtime. Style it through data-fs-account-entry-point and switch on data-fs-account-entry-point-state.',\n});\n\nexport function AccountEntryPoint({\n signedOutLabel,\n signedInLabel,\n icon,\n loadingLabel,\n $content,\n className,\n ref,\n ...props\n}: AccountEntryPointProps) {\n const { state, loading } = useSession();\n const pathname = usePathname();\n\n // Blank entry fields fall through, so clearing one in the Admin reads as unauthored.\n const entrySignedOutLabel = $content?.signedOutLabel?.trim() ? $content.signedOutLabel : signedOutLabel;\n const entrySignedInLabel = $content?.signedInLabel?.trim() ? $content.signedInLabel : signedInLabel;\n const entryIcon = $content?.icon?.trim() ? $content.icon : icon;\n const entryLoadingLabel = $content?.loadingLabel?.trim() ? $content.loadingLabel : loadingLabel;\n\n // Assistive technology only reports a change inside a region that was already in the tree, so a\n // region mounted together with its text announces nothing. The region therefore holds the same\n // position in both branches — React keeps it mounted across the swap — and starts empty, with the\n // label written on the pass after mount and cleared again once the session resolves.\n //\n // It trails the branch content rather than leading it so the authored swatch, which lands on\n // whichever element leads, can still reach the region through a following-sibling selector.\n const [announcement, setAnnouncement] = useState('');\n const resolvingLabel = loading ? entryLoadingLabel : undefined;\n useEffect(() => {\n setAnnouncement(resolvingLabel ?? '');\n }, [resolvingLabel]);\n\n // Gate on `loading` before `state`: an unresolved session reports `anonymous`, so reading the\n // tri-state first would flash \"Sign In\" at a shopper who is already signed in.\n if (loading) {\n return (\n <>\n <AccountEntryPointLoading {...props} className={className} />\n <AccountEntryPointAnnouncement>{announcement}</AccountEntryPointAnnouncement>\n </>\n );\n }\n\n // `identified` stays on the signed-out link: an identified but unauthenticated shopper cannot\n // reach their account yet.\n const signedIn = state === 'loggedIn';\n const label = signedIn ? entrySignedInLabel : entrySignedOutLabel;\n\n // A focusable link a screen reader announces as its bare URL is worse than no control at all.\n if (!label?.trim()) {\n return null;\n }\n\n return (\n <>\n <NavigationLink\n {...props}\n ref={ref}\n href={signedIn ? ACCOUNT_ROUTE : resolveSignInHref(pathname)}\n // The signed-out destination is a deferred auth proxy that may set a cookie or redirect, and\n // a header control is always in the viewport — the default prefetch would fire that GET on\n // every page view. The account route is an ordinary page, so it keeps the default.\n prefetch={signedIn ? undefined : false}\n className={className}\n data-fs-account-entry-point=\"\"\n data-fs-account-entry-point-state={signedIn ? 'signed-in' : 'signed-out'}\n >\n {entryIcon ? <Icon name={entryIcon} /> : null}\n <span data-fs-account-entry-point-label=\"\">{label}</span>\n </NavigationLink>\n <AccountEntryPointAnnouncement>{announcement}</AccountEntryPointAnnouncement>\n </>\n );\n}\n\n/**\n * The live region that carries the control across the wait. Separate from the visual placeholder\n * because it has to outlive it: the placeholder is only in the tree while the session resolves,\n * while the region has to be there before the text lands for the text to be announced at all.\n */\nfunction AccountEntryPointAnnouncement({ children }: { children: string }) {\n return (\n <output aria-live=\"polite\" data-fs-account-entry-point-announcement=\"\">\n {children}\n </output>\n );\n}\n\n/**\n * The visual stand-in occupying the control's slot while the session resolves. Purely visual: the\n * wait is spoken by the sibling live region, so this is hidden from assistive technology rather\n * than announced twice. Named for the state it represents, as `ShippingSimulatorLoading` is, not\n * for the bar it draws.\n */\nexport function AccountEntryPointLoading({ className, ...props }: AccountEntryPointLoadingProps) {\n return <span {...props} aria-hidden=\"true\" className={className} data-fs-account-entry-point-loading=\"\" />;\n}\n"],"mappings":";;;;;;;;;;;;;;AAYA,MAAM,gBAAgB;AAItB,MAAa,2BAA2B,kBAAkB;CACxD,IAAI;CACJ,OAAO;CACP,aAAa;CACb,QAAQ;EACN,MAAM;EACN,sBAAsB;EACtB,YAAY;GACV,gBAAgB;IAAE,MAAM;IAAU,WAAW;IAAG,OAAO;GAAmB;GAC1E,eAAe;IAAE,MAAM;IAAU,WAAW;IAAG,OAAO;GAAkB;GACxE,MAAM;IAAE,MAAM;IAAU,WAAW;IAAG,OAAO;GAAO;GACpD,cAAc;IAAE,MAAM;IAAU,WAAW;IAAG,OAAO;GAAuB;EAC9E;CACF;AACF,CAAC;AAqBD,MAAa,8BAA8B,gBAAwC;CACjF,MAAM;CACN,YAAY;CACZ,WAAW;CACX,SAAS;CACT,QAAQ;EAAE,OAAO;EAAuB,UAAU;CAAW;CAC7D,iBAAiB;CACjB,QAAQ;EACN,gBAAgB;GAAE,MAAM;GAAU,OAAO;EAAmB;EAC5D,eAAe;GAAE,M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AA;EAAY,CAAA,CAC1C;CAChB,CAAA,GAAA,oBAAC,+BAAD,EAAA,UAAgC,aAA4C,CAAA,CAC5E,EAAA,CAAA;AAEN;;;;;;AAOA,SAAS,8BAA8B,EAAE,YAAkC;CACzE,OACE,oBAAC,UAAD;EAAQ,aAAU;EAAS,4CAAyC;EACjE;CACK,CAAA;AAEZ;;;;;;;AAQA,SAAgB,yBAAyB,EAAE,WAAW,GAAG,SAAwC;CAC/F,OAAO,oBAAC,QAAD;EAAM,GAAI;EAAO,eAAY;EAAkB;EAAW,uCAAoC;CAAI,CAAA;AAC3G"}
1
+ {"version":3,"file":"account-entry-point.js","names":[],"sources":["../../../src/matter/account-entry-point/account-entry-point.tsx"],"sourcesContent":["'use client';\n\nimport { type ContentValue, defineComponent, defineContentType } from '@vtex/fs-core';\nimport { usePathname } from 'next/navigation';\nimport { type ComponentPropsWithRef, useEffect, useState } from 'react';\nimport { Icon } from '../../particles/icon/icon.js';\nimport { NavigationLink } from '../../particles/navigation-link/navigation-link.js';\nimport { resolveSignInHref } from '../../utils/safe-href.js';\nimport { useSession } from '../session/session.js';\n\n/** The account's root. A fixed convention, never an authored value: an authored destination could\n * misroute the entry into the account. */\nconst ACCOUNT_ROUTE = '/account';\n\n// Nothing is required: an entry may author any subset, and a slice missing a required property is\n// shape-invalid, which drops the whole element rather than the one field.\nexport const AccountEntryPointContent = defineContentType({\n id: 'account-entry-point',\n title: 'Account Entry Point',\n description: 'Labels and icon for the header sign-in / account control.',\n schema: {\n type: 'object',\n additionalProperties: false,\n properties: {\n signedOutLabel: { type: 'string', minLength: 1, title: 'Signed-out label' },\n signedInLabel: { type: 'string', minLength: 1, title: 'Signed-in label' },\n icon: { type: 'string', minLength: 1, title: 'Icon' },\n loadingLabel: { type: 'string', minLength: 1, title: 'Loading announcement' },\n },\n },\n});\n\n/** Props for {@link AccountEntryPoint}. Extends native `<a>` attributes (the rendered root). */\nexport type AccountEntryPointProps = Omit<ComponentPropsWithRef<'a'>, 'href' | 'children'> & {\n /** Label for anonymous and identified shoppers. Optional: the render gate, not the type,\n * requires a resolved value. */\n signedOutLabel?: string;\n /** Label for logged-in shoppers. Same gate. */\n signedInLabel?: string;\n /** Icon reference for the glyph. Never gated: a control with no glyph is a valid configuration. */\n icon?: string;\n /** Text the live region announces while the session resolves. */\n loadingLabel?: string;\n /** Merchant-authored fields, sliced from the page/layout content entry; win over the props field\n * by field when present. Absent in a non-CMS store — the props are the fallback. */\n $content?: ContentValue<typeof AccountEntryPointContent>;\n};\n\n/** Props for {@link AccountEntryPointLoading}. Extends native `<span>` attributes. */\nexport type AccountEntryPointLoadingProps = Omit<ComponentPropsWithRef<'span'>, 'children'>;\n\nexport const AccountEntryPointDefinition = defineComponent<AccountEntryPointProps>({\n name: 'AccountEntryPoint',\n importPath: '@vtex/faststore/components',\n component: AccountEntryPoint,\n content: AccountEntryPointContent,\n editor: { label: 'Account Entry Point', category: 'identity' },\n requiresContext: 'session',\n schema: {\n signedOutLabel: { type: 'string', label: 'Signed-out Label' },\n signedInLabel: { type: 'string', label: 'Signed-in Label' },\n icon: { type: 'icon', label: 'Icon' },\n loadingLabel: { type: 'string', label: 'Loading Announcement' },\n },\n guideline:\n 'Session-aware header control rendering one link: the signed-out label toward /login for anonymous and identified shoppers, the signed-in label toward the account route for logged-in ones, and a politely announced placeholder while the session resolves. Both destinations are fixed conventions, not props, so no authored value can misroute the auth flow. Must be inside a SessionRoot, normally the one hosted by the shared layout; a page-hosted provider also works, since the server-side session fetch forwards the shopper cookie. Author the label for a state or that state renders nothing; the labels are optional in the type only because a CMS entry may supply them, and an entry overrides all four fields at runtime. Style it through data-fs-account-entry-point and switch on data-fs-account-entry-point-state.',\n});\n\nexport function AccountEntryPoint({\n signedOutLabel,\n signedInLabel,\n icon,\n loadingLabel,\n $content,\n className,\n ref,\n ...props\n}: AccountEntryPointProps) {\n const { state, loading } = useSession();\n const pathname = usePathname();\n\n // Blank entry fields fall through, so clearing one in the Admin reads as unauthored.\n const entrySignedOutLabel = $content?.signedOutLabel?.trim() ? $content.signedOutLabel : signedOutLabel;\n const entrySignedInLabel = $content?.signedInLabel?.trim() ? $content.signedInLabel : signedInLabel;\n const entryIcon = $content?.icon?.trim() ? $content.icon : icon;\n const entryLoadingLabel = $content?.loadingLabel?.trim() ? $content.loadingLabel : loadingLabel;\n\n // Assistive technology only reports a change inside a region that was already in the tree, so a\n // region mounted together with its text announces nothing. The region therefore holds the same\n // position in both branches — React keeps it mounted across the swap — and starts empty, with the\n // label written on the pass after mount and cleared again once the session resolves.\n //\n // It trails the branch content rather than leading it so the authored swatch, which lands on\n // whichever element leads, can still reach the region through a following-sibling selector.\n const [announcement, setAnnouncement] = useState('');\n const resolvingLabel = loading ? entryLoadingLabel : undefined;\n useEffect(() => {\n setAnnouncement(resolvingLabel ?? '');\n }, [resolvingLabel]);\n\n // Gate on `loading` before `state`: an unresolved session reports `anonymous`, so reading the\n // tri-state first would flash \"Sign In\" at a shopper who is already signed in.\n if (loading) {\n return (\n <>\n <AccountEntryPointLoading {...props} className={className} />\n <AccountEntryPointAnnouncement>{announcement}</AccountEntryPointAnnouncement>\n </>\n );\n }\n\n // `identified` stays on the signed-out link: an identified but unauthenticated shopper cannot\n // reach their account yet.\n const signedIn = state === 'loggedIn';\n const label = signedIn ? entrySignedInLabel : entrySignedOutLabel;\n\n // A focusable link a screen reader announces as its bare URL is worse than no control at all.\n if (!label?.trim()) {\n return null;\n }\n\n return (\n <>\n <NavigationLink\n {...props}\n ref={ref}\n href={signedIn ? ACCOUNT_ROUTE : resolveSignInHref(pathname)}\n // The signed-out destination is a deferred auth proxy that may set a cookie or redirect, and\n // a header control is always in the viewport — the default prefetch would fire that GET on\n // every page view. The account route is an ordinary page, so it keeps the default.\n prefetch={signedIn ? undefined : false}\n className={className}\n data-fs-account-entry-point=\"\"\n data-fs-account-entry-point-state={signedIn ? 'signed-in' : 'signed-out'}\n >\n {entryIcon ? <Icon name={entryIcon} /> : null}\n <span data-fs-account-entry-point-label=\"\">{label}</span>\n </NavigationLink>\n <AccountEntryPointAnnouncement>{announcement}</AccountEntryPointAnnouncement>\n </>\n );\n}\n\n/**\n * The live region that carries the control across the wait. Separate from the visual placeholder\n * because it has to outlive it: the placeholder is only in the tree while the session resolves,\n * while the region has to be there before the text lands for the text to be announced at all.\n */\nfunction AccountEntryPointAnnouncement({ children }: { children: string }) {\n return (\n <output aria-live=\"polite\" data-fs-account-entry-point-announcement=\"\">\n {children}\n </output>\n );\n}\n\n/**\n * The visual stand-in occupying the control's slot while the session resolves. Purely visual: the\n * wait is spoken by the sibling live region, so this is hidden from assistive technology rather\n * than announced twice. Named for the state it represents, as `ShippingSimulatorLoading` is, not\n * for the bar it draws.\n */\nexport function AccountEntryPointLoading({ className, ...props }: AccountEntryPointLoadingProps) {\n return <span {...props} aria-hidden=\"true\" className={className} data-fs-account-entry-point-loading=\"\" />;\n}\n"],"mappings":";;;;;;;;;;;;;;AAYA,MAAM,gBAAgB;AAItB,MAAa,2BAA2B,kBAAkB;CACxD,IAAI;CACJ,OAAO;CACP,aAAa;CACb,QAAQ;EACN,MAAM;EACN,sBAAsB;EACtB,YAAY;GACV,gBAAgB;IAAE,MAAM;IAAU,WAAW;IAAG,OAAO;GAAmB;GAC1E,eAAe;IAAE,MAAM;IAAU,WAAW;IAAG,OAAO;GAAkB;GACxE,MAAM;IAAE,MAAM;IAAU,WAAW;IAAG,OAAO;GAAO;GACpD,cAAc;IAAE,MAAM;IAAU,WAAW;IAAG,OAAO;GAAuB;EAC9E;CACF;AACF,CAAC;AAqBD,MAAa,8BAA8B,gBAAwC;CACjF,MAAM;CACN,YAAY;CACZ,WAAW;CACX,SAAS;CACT,QAAQ;EAAE,OAAO;EAAuB,UAAU;CAAW;CAC7D,iBAAiB;CACjB,QAAQ;EACN,gBAAgB;GAAE,MAAM;GAAU,OAAO;EAAmB;EAC5D,eAAe;GAAE,MAAM;GAAU,OAAO;EAAkB;EAC1D,MAAM;GAAE,MAAM;GAAQ,OAAO;EAAO;EAC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A4C,CAAA,CAC5E,EAAA,CAAA;AAEN;;;;;;AAOA,SAAS,8BAA8B,EAAE,YAAkC;CACzE,OACE,oBAAC,UAAD;EAAQ,aAAU;EAAS,4CAAyC;EACjE;CACK,CAAA;AAEZ;;;;;;;AAQA,SAAgB,yBAAyB,EAAE,WAAW,GAAG,SAAwC;CAC/F,OAAO,oBAAC,QAAD;EAAM,GAAI;EAAO,eAAY;EAAkB;EAAW,uCAAoC;CAAI,CAAA;AAC3G"}
@@ -0,0 +1,88 @@
1
+ import { ContentValue } from "../../core/dist/define-content-type.js";
2
+ import { ComponentDefinition } from "../../core/dist/define-component.js";
3
+ import "../../core/dist/index.js";
4
+ import { ComponentPropsWithRef } from "react";
5
+ //#region src/matter/account-menu/account-menu.d.ts
6
+ export declare const AccountMenuContent: {
7
+ readonly id: "account-menu";
8
+ readonly title: "Account Menu";
9
+ readonly description: "The ordered list of the account's sections, editable without a deployment.";
10
+ readonly schema: {
11
+ readonly type: "object";
12
+ readonly additionalProperties: false;
13
+ readonly properties: {
14
+ readonly items: {
15
+ readonly type: "array";
16
+ readonly title: "Sections";
17
+ readonly minItems: 1;
18
+ readonly items: {
19
+ readonly type: "object";
20
+ readonly additionalProperties: false;
21
+ readonly required: readonly ["label", "href"];
22
+ readonly properties: {
23
+ readonly label: {
24
+ readonly type: "string";
25
+ readonly minLength: 1;
26
+ readonly title: "Label";
27
+ };
28
+ readonly href: {
29
+ readonly type: "string";
30
+ readonly minLength: 1;
31
+ readonly title: "URL";
32
+ readonly format: "uri-reference";
33
+ readonly pattern: "^(?:https?://.*|mailto:.+|tel:.+|/(?:[^/].*)?)$";
34
+ };
35
+ readonly external: {
36
+ readonly type: "boolean";
37
+ readonly title: "Leaves the account";
38
+ };
39
+ };
40
+ };
41
+ };
42
+ };
43
+ };
44
+ };
45
+ type AccountMenuContentValue = ContentValue<typeof AccountMenuContent>;
46
+ /** One authored section. Derived from the model so the prop and content channels cannot drift. */
47
+ export type AccountMenuSection = NonNullable<AccountMenuContentValue['items']>[number];
48
+ /** A section resolved for render. A null `href` is a destination the allowlist refused. */
49
+ export type AccountMenuResolvedSection = {
50
+ label: string;
51
+ href: string | null;
52
+ external: boolean;
53
+ };
54
+ export type AccountMenuCurrent = {
55
+ /** Index into the resolved list. */
56
+ index: number;
57
+ /** `exact` when the path is the section; `ancestor` when the shopper is inside it. */
58
+ match: 'exact' | 'ancestor';
59
+ };
60
+ export type AccountMenuContextValue = {
61
+ /** Resolved, in the merchant's order, with blank-label sections dropped. */
62
+ items: readonly AccountMenuResolvedSection[];
63
+ /** The current section, or null when the path matches none. */
64
+ current: AccountMenuCurrent | null;
65
+ };
66
+ export type AccountMenuRootProps = ComponentPropsWithRef<'div'> & {
67
+ /** Authored fallback for the section list, used when no CMS entry supplies one. */
68
+ items?: readonly AccountMenuSection[];
69
+ /** Injected by the compiler, sliced from the page's or layout's composite content entry. */
70
+ $content?: AccountMenuContentValue;
71
+ };
72
+ /** The landmark renders one item per section, so it takes no children. */
73
+ export type AccountMenuListProps = Omit<ComponentPropsWithRef<'nav'>, 'children'> & {
74
+ /** Accessible name of the navigation landmark. */
75
+ label?: string;
76
+ };
77
+ export declare const AccountMenuRootDefinition: ComponentDefinition<AccountMenuRootProps>;
78
+ export declare const AccountMenuListDefinition: ComponentDefinition<AccountMenuListProps>;
79
+ /** The resolved section list and the current section. */
80
+ export declare function useAccountMenu(): AccountMenuContextValue;
81
+ export declare function AccountMenuRoot({ items, $content, className, children, ...props }: AccountMenuRootProps): import("react/jsx-runtime").JSX.Element;
82
+ export declare function AccountMenuList({ label, className, ...props }: AccountMenuListProps): import("react/jsx-runtime").JSX.Element | null;
83
+ export declare const AccountMenu: {
84
+ Root: typeof AccountMenuRoot;
85
+ List: typeof AccountMenuList;
86
+ };
87
+ //#endregion
88
+ //# sourceMappingURL=account-menu.d.ts.map