@thorprovider/storefront 0.4.0-mvp.2 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. package/README.md +13 -13
  2. package/assets/templates/app/app/[[...slug]]/page.tsx +32 -1
  3. package/assets/templates/app/app/[[...slug]]/renderer.tsx +43 -12
  4. package/assets/templates/app/lib/__STOREFRONT__/account-boundary.client.tsx +76 -0
  5. package/assets/templates/app/lib/__STOREFRONT__/account-lifecycle.client.tsx +461 -0
  6. package/assets/templates/app/lib/__STOREFRONT__/account-mutation.client.ts +46 -0
  7. package/assets/templates/app/lib/__STOREFRONT__/account-private.core.ts +103 -0
  8. package/assets/templates/app/lib/__STOREFRONT__/account-reconcile.client.ts +465 -0
  9. package/assets/templates/app/lib/__STOREFRONT__/account-session.core.ts +177 -0
  10. package/assets/templates/app/lib/__STOREFRONT__/account-session.ts +44 -0
  11. package/assets/templates/app/lib/__STOREFRONT__/account-user.core.ts +65 -0
  12. package/assets/templates/app/lib/__STOREFRONT__/actions.ts +76 -27
  13. package/assets/templates/app/lib/__STOREFRONT__/catalog.ts +4 -4
  14. package/assets/templates/app/lib/__STOREFRONT__/commerce.ts +0 -10
  15. package/assets/templates/app/lib/__STOREFRONT__/composition.ts +1 -1
  16. package/assets/templates/app/lib/__STOREFRONT__/handlers.core.ts +3 -3
  17. package/assets/templates/app/lib/__STOREFRONT__/mappers.ts +17 -18
  18. package/assets/templates/app/lib/__STOREFRONT__/projection-ownership.client.tsx +209 -0
  19. package/assets/templates/app/lib/__STOREFRONT__/projection-ownership.ts +247 -0
  20. package/assets/templates/app/lib/__STOREFRONT__/registry.tsx +60 -29
  21. package/assets/templates/app/lib/__STOREFRONT__/schema.ts +83 -15
  22. package/assets/templates/app/lib/__STOREFRONT__/section-sources.ts +3 -5
  23. package/assets/templates/app/lib/__STOREFRONT__/shell/props.ts +1 -1
  24. package/assets/templates/app/lib/__STOREFRONT__/spec/index.ts +25 -0
  25. package/assets/templates/app/lib/__STOREFRONT__/state.core.ts +7 -10
  26. package/assets/templates/app/lib/__STOREFRONT__/views/sections/cta.client.tsx +1 -1
  27. package/assets/templates/app/lib/__STOREFRONT__/views/sections/faq.client.tsx +1 -1
  28. package/assets/templates/app/lib/__STOREFRONT__/views/sections/logoCloud.tsx +1 -1
  29. package/assets/templates/app/lib/__STOREFRONT__/views/sections/pricing.tsx +1 -1
  30. package/assets/templates/app/lib/__STOREFRONT__/views/sections/products.client.tsx +16 -16
  31. package/assets/templates/app/lib/__STOREFRONT__/views/sections/schema.products.ts +1 -1
  32. package/assets/templates/app/lib/__STOREFRONT__/views/sections/statistics.tsx +1 -1
  33. package/assets/templates/app/lib/__STOREFRONT__/views/sections/testimonials.tsx +26 -19
  34. package/assets/templates/features/checkout/state.ts +0 -5
  35. package/assets/templates/features/customer-auth/handlers.ts +19 -23
  36. package/assets/templates/features/customer-auth/state.ts +21 -0
  37. package/assets/templates/views/account/index.tsx +19 -7
  38. package/assets/templates/views/account/registry.tsx +263 -155
  39. package/assets/templates/views/account/schema.ts +1 -1
  40. package/assets/templates/views/cart/data.ts +7 -7
  41. package/assets/templates/views/cart/registry.tsx +4 -3
  42. package/assets/templates/views/category/assembly/assembly.json +2 -2
  43. package/assets/templates/views/category/assembly/index.skeleton.tsx +11 -7
  44. package/assets/templates/views/category/assembly/registry.skeleton.tsx +9 -9
  45. package/assets/templates/views/category/assembly/slots/breadcrumb/Breadcrumb/binding.json +1 -1
  46. package/assets/templates/views/category/assembly/slots/filter/CategoryListing/catalog.part +5 -0
  47. package/assets/templates/views/category/assembly/slots/filter/{CategoryFilter2 → CategoryListing}/element.part +5 -3
  48. package/assets/templates/views/category/assembly/slots/filter/{CategoryFilter2 → CategoryListing}/registry.part +9 -5
  49. package/assets/templates/views/category/content.ts +2 -1
  50. package/assets/templates/views/category/index.tsx +19 -13
  51. package/assets/templates/views/category/props.ts +1 -1
  52. package/assets/templates/views/category/registry.tsx +19 -15
  53. package/assets/templates/views/category/schema.ts +48 -21
  54. package/assets/templates/views/checkout/content.ts +60 -0
  55. package/assets/templates/views/checkout/props.ts +4 -5
  56. package/assets/templates/views/checkout/registry.tsx +12 -10
  57. package/assets/templates/views/checkout/schema.ts +10 -16
  58. package/assets/templates/views/home/assembly/assembly.json +4 -4
  59. package/assets/templates/views/home/assembly/index.skeleton.tsx +2 -3
  60. package/assets/templates/views/home/assembly/registry.skeleton.tsx +4 -1
  61. package/assets/templates/views/home/assembly/slots/benefits/cards/binding.json +5 -0
  62. package/assets/templates/views/home/assembly/slots/benefits/cards/registry.part +17 -0
  63. package/assets/templates/views/home/assembly/slots/benefits/split/binding.json +5 -0
  64. package/assets/templates/views/home/assembly/slots/benefits/{Feature1 → split}/registry.part +6 -2
  65. package/assets/templates/views/home/assembly/slots/categories/CategoryGrid/binding.json +5 -0
  66. package/assets/templates/views/home/assembly/slots/categories/CategoryGrid/catalog.part +8 -0
  67. package/assets/templates/views/home/assembly/slots/categories/{ProductCategory2 → CategoryGrid}/element.part +1 -1
  68. package/assets/templates/views/home/assembly/slots/categories/CategoryGrid/registry.part +31 -0
  69. package/assets/templates/views/home/assembly/slots/hero/StorefrontHero/binding.json +5 -0
  70. package/assets/templates/views/home/assembly/slots/hero/StorefrontHero/catalog.part +4 -0
  71. package/assets/templates/views/home/assembly/slots/hero/{StorefrontHero1 → StorefrontHero}/registry.part +3 -1
  72. package/assets/templates/views/home/content.ts +22 -0
  73. package/assets/templates/views/home/index.tsx +11 -8
  74. package/assets/templates/views/home/props.ts +1 -0
  75. package/assets/templates/views/home/registry.tsx +39 -15
  76. package/assets/templates/views/home/schema.ts +141 -24
  77. package/assets/templates/views/product/data.ts +1 -1
  78. package/assets/templates/views/product/registry.tsx +10 -6
  79. package/assets/templates/views/product/schema.ts +36 -1
  80. package/examples/merchandising/category-led.json +1 -1
  81. package/examples/merchandising/collection-led.json +1 -1
  82. package/package.json +4 -5
  83. package/recipes/archetypes.json +39 -43
  84. package/recipes/catalog.json +212 -202
  85. package/recipes/catalog.mjs +10 -0
  86. package/recipes/catalog.schema.json +4 -0
  87. package/recipes/features.json +5 -5
  88. package/recipes/recipes.json +137 -43
  89. package/recipes/sections.json +4 -4
  90. package/recipes/validate.mjs +21 -4
  91. package/scripts/candidate.mjs +2 -2
  92. package/scripts/composers.mjs +2 -2
  93. package/scripts/file-classes.mjs +10 -0
  94. package/scripts/logical-controls.mjs +4 -4
  95. package/scripts/operation-registry.mjs +1 -1
  96. package/scripts/ownership-conflict.mjs +5 -2
  97. package/scripts/view-assembly.mjs +12 -4
  98. package/scripts/view-selection.mjs +1 -1
  99. package/skills/sf-view-gen/assets/recipes/archetypes.json +39 -43
  100. package/skills/sf-view-gen/assets/recipes/catalog.json +212 -202
  101. package/skills/sf-view-gen/assets/recipes/catalog.schema.json +4 -0
  102. package/skills/sf-view-gen/assets/recipes/features.json +5 -5
  103. package/skills/sf-view-gen/assets/recipes/recipes.json +137 -43
  104. package/skills/sf-view-gen/assets/recipes/sections.json +4 -4
  105. package/skills/sf-view-gen/assets/templates/views/sections/cta.client.tsx +1 -1
  106. package/skills/sf-view-gen/assets/templates/views/sections/faq.client.tsx +1 -1
  107. package/skills/sf-view-gen/assets/templates/views/sections/logoCloud.client.tsx +1 -1
  108. package/skills/sf-view-gen/assets/templates/views/sections/pricing.client.tsx +1 -1
  109. package/skills/sf-view-gen/assets/templates/views/sections/products.client.tsx +16 -16
  110. package/skills/sf-view-gen/assets/templates/views/sections/schema.products.ts +1 -1
  111. package/skills/sf-view-gen/assets/templates/views/sections/schema.testimonials.ts +21 -11
  112. package/skills/sf-view-gen/assets/templates/views/sections/statistics.client.tsx +1 -1
  113. package/skills/sf-view-gen/assets/templates/views/sections/testimonials.client.tsx +2 -8
  114. package/skills/sf-view-gen/scripts/catalog.mjs +10 -0
  115. package/skills/sf-view-gen/scripts/validate.mjs +21 -4
  116. package/assets/templates/views/category/assembly/slots/filter/CategoryFilter2/catalog.part +0 -5
  117. package/assets/templates/views/home/assembly/slots/benefits/Feature1/binding.json +0 -5
  118. package/assets/templates/views/home/assembly/slots/benefits/Feature2/binding.json +0 -5
  119. package/assets/templates/views/home/assembly/slots/benefits/Feature2/registry.part +0 -10
  120. package/assets/templates/views/home/assembly/slots/categories/ProductCategory2/binding.json +0 -5
  121. package/assets/templates/views/home/assembly/slots/categories/ProductCategory2/catalog.part +0 -4
  122. package/assets/templates/views/home/assembly/slots/categories/ProductCategory2/registry.part +0 -16
  123. package/assets/templates/views/home/assembly/slots/hero/StorefrontHero1/binding.json +0 -5
  124. package/assets/templates/views/home/assembly/slots/hero/StorefrontHero1/catalog.part +0 -4
  125. /package/assets/templates/views/home/assembly/slots/benefits/{Feature1 → cards}/catalog.part +0 -0
  126. /package/assets/templates/views/home/assembly/slots/benefits/{Feature1 → cards}/element.part +0 -0
  127. /package/assets/templates/views/home/assembly/slots/benefits/{Feature2 → split}/catalog.part +0 -0
  128. /package/assets/templates/views/home/assembly/slots/benefits/{Feature2 → split}/element.part +0 -0
  129. /package/assets/templates/views/home/assembly/slots/hero/{StorefrontHero1 → StorefrontHero}/element.part +0 -0
package/README.md CHANGED
@@ -297,15 +297,11 @@ held post-MVP and rejected before any write. `create` seeds `home` and `cart`;
297
297
  `--starter` seeds every curated view and feature. Home editorial (`faq`, `cta`) and
298
298
  data-bound `products` sections: see [Product sections](docs/product-sections.md).
299
299
 
300
- **Cart lifecycle and checkout independence.** The cart review is a normal view,
301
- not a shell element: `view add cart` installs it, `view remove cart` drops it
302
- (which also hides the lateral's "View cart" action and leaves `/cart` unrouted;
303
- the navbar icon still opens the compact lateral). `sync` never silently adds it
304
- to an existing store — upgrading is an explicit `view add cart`. Cart and
305
- checkout are independent: review works without checkout (its action is hidden),
306
- and adding `checkout` never adds the cart view. The CLI derives
307
- `cartViewAvailable`/`checkoutAvailable` from the installed views/features into
308
- `composition.ts`, which the generated wiring reads.
300
+ **Cart lifecycle and checkout independence.** The cart review is a normal view, not a shell element: `view add cart` installs it, `view remove cart` drops it (which also hides the lateral's "View cart" action and leaves `/cart` unrouted; the navbar icon still opens the compact lateral). `sync` never silently adds it to an existing store — upgrading is an explicit `view add cart`.
301
+ Cart and checkout are independent: review works without checkout (its action is hidden), and adding `checkout` never adds the cart view. The CLI derives `cartViewAvailable`/`checkoutAvailable` from the installed views/features into `composition.ts`, which the generated wiring reads.
302
+
303
+ **Account lifecycle (customer-auth).** The `customer-auth` feature owns the `/account` route, the request-scoped session read, cross-tab/foreground reconciliation, and the navbar account chrome, toggled together by `storefront feature add|remove customer-auth`; the account chrome follows the scaffold's user-owned/derived split.
304
+ See [Account lifecycle](docs/account-lifecycle.md) — the single canonical source — for the reader, the shared client lifecycle, the real panel scope, and sync behaviour.
309
305
 
310
306
  **Prerequisites and pinning.** Node `>=20.9.0`, `node-modules` linker, and the
311
307
  canonical Yarn pinned in the generated `package.json` as
@@ -358,7 +354,9 @@ different `formatVersion` → `E_INVALID_ENVELOPE`). Operation names are
358
354
  `section add|remove|move`/`sections [<view>]` over `section.add|remove|reorder` (see [Product sections](docs/product-sections.md)).
359
355
 
360
356
  **What E1 proves.** The only executable non-default swap is `home.benefits`
361
- `Feature1 → Feature2` (identical `BenefitsItem[]` data shape, no bridge); every bridged
357
+ `cards → split` (the canonical `Feature` presentations; identical `BenefitsItem[]`
358
+ data shape, no bridge; the retired `Feature1`/`Feature2` names resolve as legacy
359
+ aliases); every bridged
362
360
  variant is `held`. A feature may declare a `config` and `mounts`; the bounded `benefits`
363
361
  feature mounts at `home.benefits` with `{ "presentation": "compact" | "detailed" }`,
364
362
  claims the slot exactly once, and preserves user-owned content on removal. Checkout
@@ -415,8 +413,8 @@ model adds value and make the rest a reliable script.
415
413
  - **Truthful output**: a versioned recipe/catalog exposes every slot and variant with an
416
414
  `executable` or `held` status and a reason. Only executable variants render; a held
417
415
  variant is rejected before any write, so a site is never presented with a choice that
418
- silently does nothing. E1 ships a small proven set (`home.benefits` `Feature1`↔
419
- `Feature2`); bridged variants and optional sections stay held.
416
+ silently does nothing. E1 ships a small proven set (`home.benefits`
417
+ `cards`↔`split`); bridged variants and optional sections stay held.
420
418
 
421
419
  ## Generated project structure
422
420
 
@@ -455,6 +453,8 @@ surface and footer copy are configured without touching derived files. Configure
455
453
  and the scaffold ships no submit callback, so a content-only newsletter renders no form
456
454
  — never a fake form. `shippingNote` defaults to `''`: while it is empty (and there are
457
455
  no utility links) the navbar renders no utility strip, so no placeholder note is shown.
456
+ The generated footer uses canonical `FooterSection` with `brand-columns` and
457
+ native link behavior; numbered footer adapters are no longer part of the Blocks API.
458
458
 
459
459
  A view's derived `index.tsx` imports the user-owned `content.ts`/`props.ts`/
460
460
  `data.ts`, so a customization changes real spec/loader output and survives `sync`.
@@ -499,4 +499,4 @@ of the contract with consumers: revisit them whenever the CLI surface changes
499
499
  (flags, actions, validation) or the scaffold's preconditions change (target-directory
500
500
  rules, linker, backend variables), and update the corresponding entry in
501
501
  `packages/storefront/README.md`. The packaging test suite asserts these
502
- sections and that every failure-mode entry carries a remedy.
502
+ sections and that every failure-mode entry carries a remedy.
@@ -2,8 +2,12 @@
2
2
 
3
3
  import { notFound } from 'next/navigation'
4
4
  import { buildBreadcrumbListJsonLd, serializeJsonLd } from '@thorprovider/runtime/contracts'
5
+ import { getCatalog } from '@thorprovider/runtime/commerce'
5
6
  import { __STOREFRONT_CAMEL__App } from '@/lib/__STOREFRONT__/runtime'
6
7
  import { readCartStateForRender } from '@/lib/__STOREFRONT__/cart-state'
8
+ import { readAccountSession } from '@/lib/__STOREFRONT__/account-session'
9
+ import { toAccountInitialState } from '@/lib/__STOREFRONT__/account-session.core'
10
+ import { mountedFeatureNames } from '@/lib/__STOREFRONT__/composition'
7
11
  import { StorefrontRenderer } from './renderer'
8
12
 
9
13
  export const { generateMetadata, generateStaticParams } = __STOREFRONT_CAMEL__App
@@ -20,10 +24,37 @@ export default async function Page({
20
24
  const data = await __STOREFRONT_CAMEL__App.getPageData({ params, searchParams })
21
25
  if (!data) return notFound()
22
26
 
27
+ // The shared shell is rendered for every route, so resolve its category links
28
+ // here rather than relying on a particular view loader. `getCatalog()` is
29
+ // request-cached by the commerce bridge and is shared with the view loader.
30
+ let navCategories: { label: string; href: string }[] = []
31
+ try {
32
+ navCategories = (await getCatalog()).categories.map(({ label, href }) => ({ label, href }))
33
+ } catch (error) {
34
+ // A failed catalog read must not invent links or take down otherwise usable
35
+ // page content; keep the shell empty and leave a diagnostic for operators.
36
+ console.error('[storefront] Failed to resolve shared navigation categories', error)
37
+ }
38
+
23
39
  // Read the signed cookie and load the backend cart for the initial render.
24
40
  // This never creates a cart; a guest identity is issued by a Server Action.
25
41
  const cartState = await readCartStateForRender()
26
- const initialState = { ...(data.initialState ?? {}), ...cartState }
42
+
43
+ // Seed the request-scoped account identity BEFORE the shell renders, and only
44
+ // when the customer-auth capability is mounted: an unmounted feature performs
45
+ // no auth resolution. The reader is render-safe and request-scoped (no shared
46
+ // cache, so concurrent requests and store contexts stay isolated); only the
47
+ // allowlisted display identity enters the initial state, never a token.
48
+ const accountState = mountedFeatureNames.includes('customer-auth')
49
+ ? toAccountInitialState(await readAccountSession())
50
+ : {}
51
+
52
+ const initialState = {
53
+ ...(data.initialState ?? {}),
54
+ navCategories,
55
+ ...cartState,
56
+ ...accountState,
57
+ }
27
58
 
28
59
  // Entity structured data is server-rendered from the real loaded entity and
29
60
  // sanitized so entity text cannot terminate the script element.
@@ -5,17 +5,48 @@
5
5
  import { useRef } from 'react'
6
6
  import { PageRenderer } from '@json-render/next'
7
7
  import type { PageData } from '@json-render/next'
8
+ import {
9
+ arbitrateProjection,
10
+ createProjectionOwnership,
11
+ stabilizeProjection,
12
+ type ProjectionOwnership,
13
+ type StabilizedProjection,
14
+ } from '@/lib/__STOREFRONT__/projection-ownership'
15
+ import { ProjectionOwnershipProvider } from '@/lib/__STOREFRONT__/projection-ownership.client'
8
16
 
9
- export function StorefrontRenderer({ initialState, ...data }: PageData) {
10
- // The server recomputes `initialState` on every render, and a Server Action
11
- // triggers an RSC refresh — so the prop is a fresh object each time even when
12
- // its content is unchanged. `@json-render/react`'s StateProvider resets the
13
- // client store whenever the `initialState` reference changes, which would wipe
14
- // client-owned state (for example the account order history) after an action.
15
- // Keep a STABLE reference while the serialized content is unchanged; a genuine
16
- // server-side change (for example the cart) still propagates a new value.
17
- const key = JSON.stringify(initialState ?? {})
18
- const stable = useRef({ key, value: initialState })
19
- if (stable.current.key !== key) stable.current = { key, value: initialState }
20
- return <PageRenderer {...data} initialState={stable.current.value} />
17
+ export interface StorefrontRendererProps extends PageData {
18
+ /**
19
+ * The per-tab ownership ledger, injected for composition/tests. The renderer
20
+ * creates and keeps one internally when omitted.
21
+ */
22
+ ownership?: ProjectionOwnership
23
+ }
24
+
25
+ export function StorefrontRenderer({ initialState, ownership: injected, ...data }: StorefrontRendererProps) {
26
+ const ownershipRef = useRef<ProjectionOwnership | null>(null)
27
+ if (ownershipRef.current === null) {
28
+ ownershipRef.current = injected ?? createProjectionOwnership()
29
+ }
30
+ const ownership = ownershipRef.current
31
+
32
+ // The server recomputes `initialState` on every render and a Server Action
33
+ // triggers an RSC refresh, so the prop is a fresh object each time even when
34
+ // its content is unchanged. Capture the first client-owned (account + cart)
35
+ // values so a later or older projection cannot overwrite a live cart or a
36
+ // newer local auth result, then arbitrate (a claim overrides the seed) and
37
+ // keep a STABLE reference while the serialized content is unchanged so
38
+ // `@json-render/react`'s StateProvider does not re-apply identical values and
39
+ // reset client-owned state. Server-owned keys always propagate, so navigation
40
+ // keeps working.
41
+ ownership.seed(initialState)
42
+ const projection = arbitrateProjection(ownership, initialState)
43
+ const stableRef = useRef<StabilizedProjection | null>(null)
44
+ const stable = stabilizeProjection(stableRef.current, projection)
45
+ stableRef.current = stable
46
+
47
+ return (
48
+ <ProjectionOwnershipProvider ownership={ownership}>
49
+ <PageRenderer {...data} initialState={stable.value} />
50
+ </ProjectionOwnershipProvider>
51
+ )
21
52
  }
@@ -0,0 +1,76 @@
1
+ 'use client'
2
+
3
+ // Generated by Thor Commerce storefront (template: assets/templates/app/lib/__STOREFRONT__/account-boundary.client.tsx)
4
+ //
5
+ // The `/account` route's passive account boundary. It reads the shared account
6
+ // state and renders ONE thing: an accessible, retryable "unavailable" status —
7
+ // and only when the server resolution could not establish the session. It NEVER
8
+ // fetches or owns identity on mount (the retired `AccountBoot` behaviour), so
9
+ // visiting or navigating to `/account` introduces no competing identity
10
+ // bootstrap; the identity always comes from the shared lifecycle/SSR seed.
11
+ //
12
+ // The retry is a bound action (`retryAccountSession`, registered by the globally
13
+ // mounted lifecycle): the boundary is presentational and dependency-free, and
14
+ // the recovery edge lives in the one shared lifecycle, not in a route fetch.
15
+
16
+ import { useStateStore } from '@json-render/react'
17
+ import type { BaseComponentProps } from '@json-render/react'
18
+
19
+ export function AccountBoundary({ emit }: Pick<BaseComponentProps, 'emit'>) {
20
+ const { state } = useStateStore() as { state: Record<string, unknown> }
21
+ const resolution =
22
+ typeof state.accountResolution === 'string' ? state.accountResolution : 'unresolved'
23
+ // A cross-tab/foreground reconciliation is in flight (task 4.2): present a
24
+ // neutral pending surface instead of the sign-in form (which would fake a
25
+ // signed-out state before the server confirms it) or a stale unavailable
26
+ // status. The authenticated region handles its own pending surface, so this
27
+ // branch is only for the non-authenticated case.
28
+ if (state.accountReconciling === true && state.accountAuthenticated !== true) {
29
+ return (
30
+ <p
31
+ role="status"
32
+ aria-live="polite"
33
+ data-account-reconciling="1"
34
+ className="text-muted-foreground mx-auto max-w-md px-4 py-12 text-center text-sm"
35
+ >
36
+ Actualizando tu cuenta…
37
+ </p>
38
+ )
39
+ }
40
+ // Resolved (authenticated/anonymous) or pre-projection: nothing to show. Only
41
+ // an unavailable resolution (a transport/server outage, never a fake
42
+ // sign-out) surfaces the retryable status.
43
+ if (resolution !== 'unavailable') return null
44
+
45
+ const pending = state.accountPending === true
46
+ const error = typeof state.accountError === 'string' ? state.accountError : null
47
+ // The message is the announced live status region; the retry control is a
48
+ // sibling (a native button, so it is keyboard-operable) that references the
49
+ // message as its accessible description. Keeping the interactive control OUT
50
+ // of the live region avoids re-announcing the button on every status update
51
+ // (task 4.3).
52
+ return (
53
+ <div
54
+ data-account-boundary="unavailable"
55
+ className="mx-auto flex max-w-md flex-col items-center gap-3 px-4 py-12 text-center"
56
+ >
57
+ <p
58
+ id="account-unavailable-message"
59
+ role="status"
60
+ aria-live="polite"
61
+ className="text-muted-foreground text-sm"
62
+ >
63
+ {error ?? 'No pudimos verificar tu sesión. Revisa tu conexión e inténtalo de nuevo.'}
64
+ </p>
65
+ <button
66
+ type="button"
67
+ disabled={pending}
68
+ aria-describedby="account-unavailable-message"
69
+ onClick={() => emit?.('retry')}
70
+ className="bg-primary text-primary-foreground focus-visible:ring-ring rounded-md px-4 py-2 text-sm font-medium transition-colors hover:opacity-90 focus-visible:ring-2 focus-visible:outline-none disabled:pointer-events-none disabled:opacity-60"
71
+ >
72
+ {pending ? 'Reintentando…' : 'Reintentar'}
73
+ </button>
74
+ </div>
75
+ )
76
+ }