@thorprovider/storefront 0.15.2 → 0.15.3

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 (31) hide show
  1. package/README.md +1 -1
  2. package/assets/templates/app/lib/__STOREFRONT__/header-universal.ts +28 -18
  3. package/assets/templates/app/lib/__STOREFRONT__/registry.tsx +116 -22
  4. package/assets/templates/app/lib/__STOREFRONT__/spec/index.ts +10 -1
  5. package/assets/templates/app/lib/__STOREFRONT__/views/sections/schema.universal-banner.ts +1 -0
  6. package/assets/templates/app/lib/__STOREFRONT__/views/sections/universal-banner.client.tsx +4 -1
  7. package/assets/templates/app/public/demo/accessories.svg +7 -0
  8. package/assets/templates/app/public/demo/dresses.svg +6 -0
  9. package/assets/templates/app/public/demo/furniture.svg +9 -0
  10. package/assets/templates/app/public/demo/home.svg +8 -0
  11. package/assets/templates/app/public/demo/jackets.svg +11 -0
  12. package/assets/templates/app/public/demo/promo-invierno.svg +8 -0
  13. package/assets/templates/features/checkout/state.ts +2 -0
  14. package/assets/templates/views/category/assembly/slots/filter/CategoryListing/element.part +1 -0
  15. package/assets/templates/views/category/assembly/slots/filter/CategoryListing/registry.part +2 -0
  16. package/assets/templates/views/category/content.ts +1 -0
  17. package/assets/templates/views/category/index.tsx +1 -0
  18. package/assets/templates/views/category/registry.tsx +2 -0
  19. package/assets/templates/views/category/schema.ts +2 -0
  20. package/assets/templates/views/checkout/checkout-commerce-hosted.tsx +19 -0
  21. package/assets/templates/views/checkout/registry.tsx +22 -5
  22. package/assets/templates/views/home/assembly/slots/hero/UniversalBanner/registry.part +6 -1
  23. package/assets/templates/views/home/content.ts +2 -0
  24. package/assets/templates/views/home/props.ts +8 -1
  25. package/assets/templates/views/home/registry.tsx +6 -1
  26. package/assets/templates/views/home/schema.ts +1 -0
  27. package/package.json +1 -1
  28. package/scripts/candidate.mjs +2 -2
  29. package/scripts/env-file.mjs +5 -0
  30. package/scripts/reconcile.mjs +4 -1
  31. package/scripts/render-templates.mjs +106 -1
package/README.md CHANGED
@@ -144,7 +144,7 @@ yarn dev
144
144
  ```
145
145
 
146
146
  A fresh `create` seeds `home` + `cart` (home hero/benefits/category sections, a
147
- navbar-owned cart sheet, a standalone `/cart` review route). Pass `--starter` to
147
+ header-owned cart sheet, a standalone `/cart` review route). Pass `--starter` to
148
148
  seed the full curated composition instead — every curated view and feature, read
149
149
  from the registry, held units excluded. Everything renders with only
150
150
  `@thorprovider/blocks` (UI) and `@thorprovider/adapters` (data). Then grow it by asking
@@ -29,12 +29,12 @@ import type { UniversalMainMenuData, UniversalMainMenuItem } from '@thorprovider
29
29
  import type { ProductCategory } from '@thorprovider/types'
30
30
 
31
31
  /**
32
- * The starter header. The demo feeds the commerce surface the starter can
33
- * honestly render: the announcement, the search field, the account/wishlist/
34
- * cart accesses and the main menu. The horizontal category strip (`navigation`)
35
- * and the region/language/support accesses stay off — the starter feeds no data
36
- * for them, and the support module's default `/help` action is a route the
37
- * scaffold does not serve.
32
+ * The starter header. The storefront feeds the commerce surface it can
33
+ * honestly render: the announcement, search field, account/wishlist/cart
34
+ * accesses and main menu. The cart count and action bind to the live cart in
35
+ * the shell registry. The horizontal category strip (`navigation`) and the
36
+ * region/language/support accesses stay off because the starter feeds no data
37
+ * for them and `/help` is not a served route.
38
38
  */
39
39
  export function createStorefrontHeaderConfig(): HeaderConfig {
40
40
  const base = createDefaultConfig()
@@ -64,6 +64,12 @@ export function createStorefrontHeaderConfig(): HeaderConfig {
64
64
  ...base.modules
65
65
  .filter((module) => kept.has(module.id))
66
66
  .map((module) => {
67
+ if (module.id === 'cart') {
68
+ return {
69
+ ...module,
70
+ actions: { ...module.actions, click: { name: 'openCart' } },
71
+ }
72
+ }
67
73
  if (module.id !== 'search') return module
68
74
  // The demo search is always a bar (never the icon fallback): the block
69
75
  // measures its container client-side, so the server render would
@@ -241,11 +247,12 @@ const DEMO_MENU_CATEGORIES: UniversalMainMenuItem[] = [
241
247
  href: '/categories/jackets',
242
248
  description: 'Outerwear and layering pieces.',
243
249
  count: 12,
250
+ image: { src: '/demo/jackets.svg', alt: 'Jackets' },
244
251
  badge: { label: 'Nuevo', tone: 'accent' },
245
252
  children: [
246
- { id: 'demo-jackets-quilted', label: 'Quilted', href: '/categories/jackets', count: 6 },
247
- { id: 'demo-jackets-coats', label: 'Coats', href: '/categories/dresses', count: 4 },
248
- { id: 'demo-jackets-layers', label: 'Light layers', href: '/categories/accessories', count: 2 },
253
+ { id: 'demo-jackets-quilted', label: 'Quilted', href: '/categories/jackets', count: 6, image: { src: '/demo/jackets.svg', alt: 'Quilted' } },
254
+ { id: 'demo-jackets-coats', label: 'Coats', href: '/categories/dresses', count: 4, image: { src: '/demo/jackets.svg', alt: 'Coats' } },
255
+ { id: 'demo-jackets-layers', label: 'Light layers', href: '/categories/accessories', count: 2, image: { src: '/demo/jackets.svg', alt: 'Light layers' } },
249
256
  ],
250
257
  },
251
258
  {
@@ -254,6 +261,7 @@ const DEMO_MENU_CATEGORIES: UniversalMainMenuItem[] = [
254
261
  href: '/categories/dresses',
255
262
  description: 'Editorial silhouettes for seasonal collections.',
256
263
  count: 9,
264
+ image: { src: '/demo/dresses.svg', alt: 'Dresses' },
257
265
  },
258
266
  {
259
267
  id: 'demo-home',
@@ -261,6 +269,7 @@ const DEMO_MENU_CATEGORIES: UniversalMainMenuItem[] = [
261
269
  href: '/categories/home',
262
270
  description: 'Decor and living objects for lifestyle layouts.',
263
271
  count: 14,
272
+ image: { src: '/demo/home.svg', alt: 'Home' },
264
273
  },
265
274
  {
266
275
  id: 'demo-accessories',
@@ -268,6 +277,7 @@ const DEMO_MENU_CATEGORIES: UniversalMainMenuItem[] = [
268
277
  href: '/categories/accessories',
269
278
  description: 'Complementary products for cart and bundle flows.',
270
279
  count: 7,
280
+ image: { src: '/demo/accessories.svg', alt: 'Accessories' },
271
281
  },
272
282
  {
273
283
  id: 'demo-furniture',
@@ -275,6 +285,7 @@ const DEMO_MENU_CATEGORIES: UniversalMainMenuItem[] = [
275
285
  href: '/categories/furniture',
276
286
  description: 'Statement pieces for the home, including oversized and fragile deliveries.',
277
287
  count: 5,
288
+ image: { src: '/demo/furniture.svg', alt: 'Furniture' },
278
289
  badge: { label: '-30%', tone: 'promo' },
279
290
  },
280
291
  ]
@@ -287,6 +298,7 @@ const DEMO_PROMOTION: UniversalMainMenuData['promotion'] = {
287
298
  description: 'Lana virgen y lino lavado, tejidos en talleres locales.',
288
299
  href: '/categories/home',
289
300
  ctaLabel: 'Ver la colección',
301
+ image: { src: '/demo/promo-invierno.svg', alt: 'Textiles que abrigan la casa' },
290
302
  }
291
303
 
292
304
  /**
@@ -305,27 +317,25 @@ export function buildDemoHeaderMenu(): UniversalMainMenuData {
305
317
  }
306
318
 
307
319
  /**
308
- * The runtime context the shell feeds the header. This is the clearly-labelled
309
- * DEMO state: the announcement, cart badge (3), wishlist count (4) and account
310
- * access are demo copy fed so the full design-B header renders in the starter —
311
- * never a real commerce read. Region/language stay empty (their modules are
312
- * removed from the config, so nothing reads them). The live catalog/menu seam
313
- * is the `menu` argument (built by the host from the real taxonomy or the demo
314
- * taxonomy above).
320
+ * Runtime context the shell feeds the header. The cart quantity comes from the
321
+ * live storefront state; announcement and wishlist remain clearly-labelled
322
+ * demonstration content. Region/language stay empty (their modules are removed
323
+ * from the config, so nothing reads them). The live catalog/menu seam is the
324
+ * `menu` argument (built from the real taxonomy or the demo taxonomy above).
315
325
  */
316
326
  export function buildHeaderContext(
317
327
  siteName: string,
318
328
  menu?: UniversalMainMenuData,
319
329
  accent?: string,
330
+ cartQuantity = 0,
320
331
  ): HeaderContext {
321
332
  return {
322
333
  brand: { name: siteName, href: '/', ...(accent ? { accent } : {}) },
323
334
  menu,
324
335
  cart: {
325
336
  state: 'ready',
326
- // Demo badge count only: no real cart lines are fabricated.
327
337
  lines: [],
328
- quantity: 3,
338
+ quantity: cartQuantity,
329
339
  lineCount: 0,
330
340
  currency: 'EUR',
331
341
  shippingGroups: 0,
@@ -3,11 +3,10 @@
3
3
  // Generated by Thor Commerce storefront (template: assets/templates/app/lib/__STOREFRONT__/registry.tsx)
4
4
  // Base registry for the app shell plus every registered view's registry fragment.
5
5
  //
6
- // The shell renders the live backend cart: the StorefrontNavbar mini-cart and the cart
7
- // drawer read the authoritative cart state and dispatch cart mutations to the
8
- // Server Actions. A listing card's add-to-cart adds the product's first
9
- // purchasable variant (the card shortcut); opening a product from a listing
10
- // navigates to the detail, where a variant is chosen explicitly.
6
+ // The universal header's cart access and its adjacent sheet share the live cart
7
+ // state and dispatch mutations to the Server Actions. A listing card's
8
+ // add-to-cart adds the product's first purchasable variant (the card shortcut);
9
+ // opening a product from a listing navigates to the detail for explicit choice.
11
10
 
12
11
  import { defineRegistry, useStateStore } from '@json-render/react'
13
12
  import { useNextApp } from '@json-render/next'
@@ -16,9 +15,11 @@ import { usePathname } from 'next/navigation'
16
15
  import { BackToTop as BackToTopBlock } from '@thorprovider/blocks/blocks/e-commerce/navigation/back-to-top'
17
16
  import { MobileBottomNav as MobileBottomNavBlock } from '@thorprovider/blocks/blocks/e-commerce/navigation/mobile-bottom-nav'
18
17
  import { SkipToContent as SkipToContentBlock } from '@thorprovider/blocks/blocks/e-commerce/navigation/skip-to-content'
18
+ import { StorefrontNavbarCartSheet } from '@thorprovider/blocks/blocks/e-commerce/navigation/storefront-navbar-cart-sheet'
19
19
  import Banner1 from '@thorprovider/blocks/blocks/marketing/banners/banner-1'
20
20
  import { HeaderUniversal, Navbar, StorefrontNavbar, UniversalFooter } from '@thorprovider/blocks'
21
21
  import { ProductGrid as ProductGridBlock } from '@thorprovider/blocks/blocks/e-commerce/product-list/product-grid'
22
+ import { Sheet, SheetContent, SheetHeader, SheetTitle } from '@thorprovider/blocks/ui/sheet'
22
23
  import type { BackToTopProps } from '@thorprovider/blocks/blocks/e-commerce/navigation/back-to-top'
23
24
  import type { MobileBottomNavProps } from '@thorprovider/blocks/blocks/e-commerce/navigation/mobile-bottom-nav'
24
25
  import type { SkipToContentProps } from '@thorprovider/blocks/blocks/e-commerce/navigation/skip-to-content'
@@ -32,6 +33,7 @@ import { cartViewAvailable, checkoutAvailable, mountedFeatureNames } from './com
32
33
  import { accountStoreUser } from './account-user.core'
33
34
  import { toUniversalFooterProps } from './footer-content'
34
35
  import { buildHeaderContext, createStorefrontHeaderConfig, storefrontHeaderLabels } from './header-universal'
36
+ import { navbarLabels } from './shell/content'
35
37
  import type { AccountIdentity, AccountResolution } from './account-session.core'
36
38
  import {
37
39
  bannerPropsSchema,
@@ -43,8 +45,8 @@ import {
43
45
  } from './schema'
44
46
  import { viewRegistries } from './views/registry'
45
47
 
46
- // StorefrontNavbar accepts its own mini-cart line shape (`qty`), distinct from the block
47
- // `CartItem` contract (`quantity`). Types are local so the asymmetry is explicit.
48
+ // The cart sheet accepts `qty`, distinct from the backend line shape's
49
+ // `quantity`. Types are local so the mapping stays explicit.
48
50
  interface NavCartItem {
49
51
  id: string
50
52
  name: string
@@ -55,7 +57,7 @@ interface NavCartItem {
55
57
  lineTotal?: Money
56
58
  }
57
59
 
58
- /** CartLineState -> StorefrontNavbar cart line. `price` is legacy; the authoritative
60
+ /** CartLineState -> cart-sheet line. `price` is legacy; the authoritative
59
61
  * subtotal and per-line total are passed separately, so neither is computed
60
62
  * from the line. */
61
63
  function toNavCartItems(cart: CartLineState[]): NavCartItem[] {
@@ -70,6 +72,81 @@ function toNavCartItems(cart: CartLineState[]): NavCartItem[] {
70
72
  }))
71
73
  }
72
74
 
75
+ function StorefrontCartSheet({ emit }: { emit: (event: string) => void }) {
76
+ const { state, set } = useStateStore()
77
+ const cart = (state.cart ?? []) as CartLineState[]
78
+ const totals = state.cartTotals as CartTotalsState | null
79
+ const cartQuantity = cart.reduce((quantity, line) => quantity + line.quantity, 0)
80
+ const storeLocale =
81
+ typeof state.storeLocale === 'string' && state.storeLocale.trim() !== ''
82
+ ? state.storeLocale
83
+ : DEFAULT_STORE_LOCALE
84
+ const formatMoney = createStoreMoneyFormatter(storeLocale)
85
+ const cartError = typeof state.cartError === 'string' ? state.cartError : undefined
86
+ const readError = typeof state.cartReadError === 'string' ? state.cartReadError : undefined
87
+ const errorLabel = cartError ?? readError
88
+ const cartState = state.cartPending ? 'pending' : errorLabel ? 'error' : 'idle'
89
+ const amountsValid =
90
+ cart.every((line) => isAvailableMoney(line.lineTotal)) &&
91
+ totals !== null &&
92
+ isAvailableMoney(totals.subtotal) &&
93
+ isAvailableMoney(totals.total)
94
+
95
+ return (
96
+ <Sheet
97
+ open={state.cartOpen === true}
98
+ onOpenChange={(open) => set('/cartOpen', open)}
99
+ >
100
+ <SheetContent
101
+ side='right'
102
+ className='flex w-full max-w-sm flex-col gap-0 p-0'
103
+ closeLabel={navbarLabels.cartClose}
104
+ >
105
+ <SheetHeader className='border-border border-b'>
106
+ <SheetTitle className='text-left text-base'>
107
+ {cartQuantity > 0
108
+ ? `${navbarLabels.cartTitle} (${cartQuantity})`
109
+ : navbarLabels.cartTitle}
110
+ </SheetTitle>
111
+ </SheetHeader>
112
+ <StorefrontNavbarCartSheet
113
+ items={toNavCartItems(cart)}
114
+ onQtyChange={(id, delta) => {
115
+ set('/qtyDelta', { id, delta })
116
+ emit('applyQuantityDelta')
117
+ }}
118
+ onRemove={(id) => {
119
+ set('/lastRemoved', id)
120
+ emit('removeFromCart')
121
+ }}
122
+ subtotal={totals?.subtotal}
123
+ formatMoney={formatMoney}
124
+ onCheckout={() => emit('goToCheckout')}
125
+ onViewCart={() => emit('goToCart')}
126
+ canonical
127
+ state={cartState}
128
+ errorLabel={errorLabel}
129
+ onRetry={() => emit('refreshCart')}
130
+ checkoutUnavailable={!checkoutAvailable}
131
+ checkoutDisabled={cartState !== 'idle' || cart.length === 0 || !amountsValid}
132
+ viewCartUnavailable={!cartViewAvailable}
133
+ decreaseLabel={navbarLabels.decreaseQuantity}
134
+ increaseLabel={navbarLabels.increaseQuantity}
135
+ removeLabel={navbarLabels.remove}
136
+ removeItemLabel={navbarLabels.removeItem}
137
+ emptyTitleLabel={navbarLabels.emptyTitle}
138
+ emptyDescriptionLabel={navbarLabels.emptyDescription}
139
+ continueShoppingLabel={navbarLabels.continueShopping}
140
+ subtotalLabel={navbarLabels.subtotal}
141
+ shippingTaxesLabel={navbarLabels.shippingTaxes}
142
+ checkoutLabel={navbarLabels.checkout}
143
+ viewCartLabel={navbarLabels.viewCart}
144
+ />
145
+ </SheetContent>
146
+ </Sheet>
147
+ )
148
+ }
149
+
73
150
  const baseComponents = {
74
151
  Layout: ({ children, slots }: { children?: React.ReactNode; slots?: Record<string, React.ReactNode> }) => {
75
152
  useStorefrontHandlers()
@@ -257,35 +334,52 @@ const baseComponents = {
257
334
  />
258
335
  )
259
336
  },
260
- HeaderUniversal: ({ props }: { props: Record<string, unknown> }) => {
337
+ HeaderUniversal: ({
338
+ props,
339
+ emit,
340
+ }: {
341
+ props: Record<string, unknown>
342
+ emit: (event: string) => void
343
+ }) => {
261
344
  const parsed = universalHeaderShellPropsSchema.parse(props)
262
345
  const { navigate } = useNextApp()
346
+ const { state } = useStateStore()
347
+ const cart = (state.cart ?? []) as CartLineState[]
348
+ const cartQuantity = cart.reduce((quantity, line) => quantity + line.quantity, 0)
263
349
  const config = createStorefrontHeaderConfig()
264
350
  const context = buildHeaderContext(
265
351
  parsed.siteName,
266
352
  parsed.menu,
267
353
  parsed.logoAccent?.text.trim() || undefined,
354
+ cartQuantity,
268
355
  )
269
- // The block prevents the default anchor navigation and emits `navigate`
270
- // instead, so the host resolves it to client navigation (the logo and every
271
- // menu destination). Any other action name is intentionally unhandled: the
272
- // starter header has no cart/account/search surface.
356
+ const cartLabel = (
357
+ cartQuantity === 1 ? navbarLabels.cartCountOne : navbarLabels.cartCount
358
+ ).replace('{count}', String(cartQuantity))
359
+ const labels = { ...storefrontHeaderLabels, cart: { label: cartLabel } }
360
+ // Header navigation stays client-side. The commerce action opens the shared
361
+ // cart state, which is rendered by the sheet mounted beside this header.
273
362
  const handleAction = (action: {
274
363
  name: string
275
364
  payload?: Record<string, string | number | boolean>
276
365
  }) => {
277
366
  if (action.name === 'navigate' && typeof action.payload?.href === 'string') {
278
367
  navigate(action.payload.href)
368
+ } else if (action.name === 'openCart') {
369
+ emit('openCart')
279
370
  }
280
371
  }
281
372
  return (
282
- <HeaderUniversal
283
- config={config}
284
- context={context}
285
- labels={storefrontHeaderLabels}
286
- className={parsed.className}
287
- onAction={handleAction}
288
- />
373
+ <>
374
+ <HeaderUniversal
375
+ config={config}
376
+ context={context}
377
+ labels={labels}
378
+ className={parsed.className}
379
+ onAction={handleAction}
380
+ />
381
+ <StorefrontCartSheet emit={emit} />
382
+ </>
289
383
  )
290
384
  },
291
385
  Banner: ({ props, emit }: { props: Record<string, unknown>; emit: (event: string) => void }) => {
@@ -318,8 +412,8 @@ const baseComponents = {
318
412
  featured={parsed.featured}
319
413
  signIn={parsed.signIn}
320
414
  cta={parsed.cta}
321
- // Page-level navigation owns no commerce state: the cart affordance and
322
- // its `openCart` intent belong to the StorefrontNavbar shell (D5).
415
+ // Page-level navigation owns no commerce state: the shell header and
416
+ // its cart sheet own the cart affordance and `openCart` intent.
323
417
  />
324
418
  )
325
419
  },
@@ -7,7 +7,11 @@ import { storefrontInitialState } from '../state'
7
7
  import { views } from '../views'
8
8
  import { footerShellProps, navbarShellProps } from '../shell/props'
9
9
  import { bannerDismissLabel, mobileBottomNavItems } from '../shell/content'
10
- import { mountedFeatureConfigs, mountedFeatureNames } from '../composition'
10
+ import {
11
+ checkoutAvailable,
12
+ mountedFeatureConfigs,
13
+ mountedFeatureNames,
14
+ } from '../composition'
11
15
  import type { StorefrontElement } from './types'
12
16
 
13
17
  export type { StorefrontElement }
@@ -115,6 +119,11 @@ const shellElements: Record<string, StorefrontElement> = {
115
119
  // user-owned shell seam. Spread last so merchant edits win.
116
120
  ...navbarShellProps,
117
121
  },
122
+ on: {
123
+ openCart: { action: 'openCart' },
124
+ goToCart: { action: 'goToCart' },
125
+ ...(checkoutAvailable ? { goToCheckout: { action: 'goToCheckout' } } : {}),
126
+ },
118
127
  },
119
128
  footer: {
120
129
  type: 'Footer',
@@ -214,4 +214,5 @@ export const universalBannerDataSchema = z.object({
214
214
 
215
215
  export const universalBannerPropsSchema = z.object({
216
216
  data: universalBannerDataSchema,
217
+ headingLevel: z.union([z.literal(1), z.literal(2), z.literal(3)]).optional(),
217
218
  })
@@ -18,7 +18,10 @@ export const universalBannerRegistry: ViewRegistry = {
18
18
  setNow(new Date().toISOString())
19
19
  }, [])
20
20
  return (
21
- <UniversalBanner data={{ ...parsed.data, now }} />
21
+ <UniversalBanner
22
+ data={{ ...parsed.data, now }}
23
+ headingLevel={parsed.headingLevel}
24
+ />
22
25
  )
23
26
  },
24
27
  }
@@ -0,0 +1,7 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 300" role="img">
2
+ <rect width="400" height="300" fill="#F4F1EC"/>
3
+ <path d="M156 138 a44 44 0 0 1 88 0" fill="none" stroke="#C7BDA9" stroke-width="12"/>
4
+ <rect x="138" y="140" width="124" height="92" rx="18" fill="#E3DCCF"/>
5
+ <path d="M138 168 h124 l-18 42 h-88 z" fill="#C6774B"/>
6
+ <circle cx="200" cy="170" r="6" fill="#C7BDA9"/>
7
+ </svg>
@@ -0,0 +1,6 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 300" role="img">
2
+ <rect width="400" height="300" fill="#F4F1EC"/>
3
+ <path d="M176 96 h48 l-8 42 h-32 z" fill="#C7BDA9"/>
4
+ <path d="M168 138 h64 l48 92 a14 14 0 0 1 -14 14 h-132 a14 14 0 0 1 -14 -14 z" fill="#E3DCCF"/>
5
+ <rect x="168" y="134" width="64" height="10" fill="#C6774B"/>
6
+ </svg>
@@ -0,0 +1,9 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 300" role="img">
2
+ <rect width="400" height="300" fill="#F4F1EC"/>
3
+ <rect x="132" y="110" width="136" height="88" rx="20" fill="#E3DCCF"/>
4
+ <rect x="122" y="174" width="156" height="42" rx="16" fill="#C7BDA9"/>
5
+ <rect x="112" y="148" width="34" height="68" rx="16" fill="#C6774B"/>
6
+ <rect x="254" y="148" width="34" height="68" rx="16" fill="#C6774B"/>
7
+ <rect x="140" y="216" width="14" height="24" rx="4" fill="#C7BDA9"/>
8
+ <rect x="246" y="216" width="14" height="24" rx="4" fill="#C7BDA9"/>
9
+ </svg>
@@ -0,0 +1,8 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 300" role="img">
2
+ <rect width="400" height="300" fill="#F4F1EC"/>
3
+ <rect x="138" y="150" width="124" height="96" rx="4" fill="#E3DCCF"/>
4
+ <path d="M124 154 L200 96 L276 154 z" fill="#C7BDA9"/>
5
+ <rect x="186" y="196" width="28" height="50" rx="3" fill="#C6774B"/>
6
+ <rect x="154" y="166" width="26" height="22" rx="2" fill="#F4F1EC" stroke="#C7BDA9" stroke-width="3"/>
7
+ <rect x="220" y="166" width="26" height="22" rx="2" fill="#F4F1EC" stroke="#C7BDA9" stroke-width="3"/>
8
+ </svg>
@@ -0,0 +1,11 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 300" role="img">
2
+ <rect width="400" height="300" fill="#F4F1EC"/>
3
+ <rect x="118" y="120" width="56" height="118" rx="26" fill="#C7BDA9"/>
4
+ <rect x="226" y="120" width="56" height="118" rx="26" fill="#C7BDA9"/>
5
+ <path d="M162 102 h76 l12 14 v106 a16 16 0 0 1 -16 16 h-68 a16 16 0 0 1 -16 -16 V116 z" fill="#E3DCCF"/>
6
+ <path d="M162 102 l18 -26 h40 l18 26 z" fill="#C7BDA9"/>
7
+ <line x1="200" y1="116" x2="200" y2="232" stroke="#C7BDA9" stroke-width="3"/>
8
+ <circle cx="200" cy="148" r="4" fill="#C6774B"/>
9
+ <circle cx="200" cy="182" r="4" fill="#C6774B"/>
10
+ <circle cx="200" cy="216" r="4" fill="#C6774B"/>
11
+ </svg>
@@ -0,0 +1,8 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 300" role="img">
2
+ <rect width="400" height="300" fill="#F4F1EC"/>
3
+ <rect x="118" y="168" width="164" height="30" rx="9" fill="#C7BDA9"/>
4
+ <rect x="126" y="138" width="148" height="30" rx="9" fill="#E3DCCF"/>
5
+ <rect x="134" y="108" width="132" height="30" rx="9" fill="#C6774B"/>
6
+ <line x1="200" y1="108" x2="200" y2="138" stroke="#F4F1EC" stroke-width="2" opacity="0.6"/>
7
+ <line x1="200" y1="138" x2="200" y2="168" stroke="#C7BDA9" stroke-width="2" opacity="0.5"/>
8
+ </svg>
@@ -70,6 +70,7 @@ export interface CheckoutState {
70
70
  checkoutSelectedShippingOptionId: string | null
71
71
  checkoutFieldErrors: CheckoutFieldErrors
72
72
  checkoutContact: CheckoutContactValues
73
+ checkoutContactEdited: boolean
73
74
  checkoutShippingAddress: CheckoutAddressValues
74
75
  checkoutBillingAddress: CheckoutAddressValues
75
76
  checkoutSameAsShipping: boolean
@@ -106,6 +107,7 @@ export const checkoutState: CheckoutState = {
106
107
  checkoutSelectedShippingOptionId: null,
107
108
  checkoutFieldErrors: {},
108
109
  checkoutContact: emptyContact,
110
+ checkoutContactEdited: false,
109
111
  checkoutShippingAddress: emptyAddress,
110
112
  checkoutBillingAddress: emptyAddress,
111
113
  checkoutSameAsShipping: true,
@@ -9,6 +9,7 @@
9
9
  showFilters: hasFilters,
10
10
  showSort: true,
11
11
  showPrice: filtersConfig.showPrice === true,
12
+ categoryTitle: { $state: '/categoryEntity/name' },
12
13
  ...(hasSearch && searchConfig.placeholder
13
14
  ? { searchPlaceholder: searchConfig.placeholder }
14
15
  : {}),
@@ -26,6 +26,7 @@
26
26
  return (
27
27
  <CategoryListingBlock
28
28
  presentation={p.presentation}
29
+ categoryTitle={p.categoryTitle}
29
30
  products={p.products}
30
31
  categories={p.categories}
31
32
  collections={p.collections}
@@ -48,6 +49,7 @@
48
49
  viewOptions={p.viewOptions}
49
50
  status={p.status}
50
51
  activeFilters={p.activeFilters}
52
+ closeLabel={p.closeLabel}
51
53
  filtersTitle={p.filtersTitle}
52
54
  searchLabel={p.searchLabel}
53
55
  searchPlaceholder={p.searchPlaceholder}
@@ -12,6 +12,7 @@
12
12
  export const filterContent = {
13
13
  presentation: 'sidebar' as const,
14
14
  filtersTitle: 'Filtros',
15
+ closeLabel: 'Cerrar',
15
16
  searchLabel: 'Buscar',
16
17
  searchPlaceholder: 'Buscar productos',
17
18
  sortPlaceholder: 'Ordenar por',
@@ -76,6 +76,7 @@ const elements: Record<string, StorefrontElement> = {
76
76
  showFilters: hasFilters,
77
77
  showSort: true,
78
78
  showPrice: filtersConfig.showPrice === true,
79
+ categoryTitle: { $state: '/categoryEntity/name' },
79
80
  ...(hasSearch && searchConfig.placeholder
80
81
  ? { searchPlaceholder: searchConfig.placeholder }
81
82
  : {}),
@@ -76,6 +76,7 @@ export const registry: ViewRegistry = {
76
76
  return (
77
77
  <CategoryListingBlock
78
78
  presentation={p.presentation}
79
+ categoryTitle={p.categoryTitle}
79
80
  products={p.products}
80
81
  categories={p.categories}
81
82
  collections={p.collections}
@@ -98,6 +99,7 @@ export const registry: ViewRegistry = {
98
99
  viewOptions={p.viewOptions}
99
100
  status={p.status}
100
101
  activeFilters={p.activeFilters}
102
+ closeLabel={p.closeLabel}
101
103
  filtersTitle={p.filtersTitle}
102
104
  searchLabel={p.searchLabel}
103
105
  searchPlaceholder={p.searchPlaceholder}
@@ -94,7 +94,9 @@ export const categoryListingPropsSchema = z
94
94
  showFilters: z.boolean(),
95
95
  showSort: z.boolean(),
96
96
  showPrice: z.boolean().optional(),
97
+ categoryTitle: z.string().optional(),
97
98
  filtersTitle: z.string().optional(),
99
+ closeLabel: z.string().optional(),
98
100
  searchLabel: z.string().optional(),
99
101
  searchPlaceholder: z.string().optional(),
100
102
  sortPlaceholder: z.string().optional(),
@@ -3,6 +3,7 @@
3
3
  import { CheckoutCommerceV1Hosted } from '@thorprovider/blocks';
4
4
  import type {
5
5
  CheckoutAddressValues,
6
+ CheckoutContactValues,
6
7
  CheckoutLocationOptions,
7
8
  CheckoutReadState,
8
9
  CheckoutShippingGroup,
@@ -65,6 +66,20 @@ export type HostedCheckoutState = {
65
66
  type HostedSetter = (path: string, value: unknown) => void;
66
67
  type HostedEmit = (event: string) => void;
67
68
 
69
+ /** Apply both server contacts only while the shopper has not edited the form. */
70
+ export async function applyCheckoutContactHydration(
71
+ checkoutContact: Promise<CheckoutContactValues | undefined>,
72
+ prefillContact: Promise<CheckoutContactValues | undefined>,
73
+ hasShopperEdited: () => boolean,
74
+ set: HostedSetter,
75
+ ): Promise<void> {
76
+ const loadedContact = await checkoutContact;
77
+ if (loadedContact && !hasShopperEdited()) set('/checkoutContact', loadedContact);
78
+
79
+ const profileContact = await prefillContact;
80
+ if (profileContact && !hasShopperEdited()) set('/checkoutContact', profileContact);
81
+ }
82
+
68
83
  const EMPTY_LOCATIONS: CheckoutLocationOptions = { countries: [], provinces: [], cities: [] };
69
84
  const CURRENT_SHIPPING_ADDRESS_ID = 'checkout-current-shipping-address';
70
85
  const CURRENT_BILLING_ADDRESS_ID = 'checkout-current-billing-address';
@@ -836,6 +851,10 @@ export function createHostedCheckoutActions(
836
851
 
837
852
  return {
838
853
  onContactChange(patch: { name?: string; email?: string; phone?: string }) {
854
+ if (patch.name !== undefined || patch.email !== undefined || patch.phone !== undefined) {
855
+ // This callback is the shopper-edit boundary; hydration writes bypass it.
856
+ set('/checkoutContactEdited', true);
857
+ }
839
858
  if (patch.name !== undefined) {
840
859
  const name = splitName(patch.name);
841
860
  set('/checkoutContact/firstName', name.firstName);
@@ -11,7 +11,10 @@ import { Button } from '@thorprovider/blocks/ui/button'
11
11
  import CheckoutBlock from '@thorprovider/blocks/blocks/e-commerce/checkout-forms/checkout'
12
12
  import CheckoutConfirmationBlock from '@thorprovider/blocks/blocks/e-commerce/checkout-forms/checkout-confirmation'
13
13
  import { CheckoutConfirmationView } from '@thorprovider/blocks'
14
- import { CheckoutCommerceHostedAdapter } from './checkout-commerce-hosted'
14
+ import {
15
+ applyCheckoutContactHydration,
16
+ CheckoutCommerceHostedAdapter,
17
+ } from './checkout-commerce-hosted'
15
18
  import { useNextApp } from '@json-render/next'
16
19
  import { useStateStore } from '@json-render/react'
17
20
  import {
@@ -84,12 +87,14 @@ export const registry: ViewRegistry = {
84
87
  * reads a bare order/cart id.
85
88
  */
86
89
  CheckoutBoot: () => {
87
- const { state, set } = useStateStore()
90
+ const { state, set, getSnapshot } = useStateStore()
88
91
  const { navigate } = useNextApp()
89
92
  const booted = useRef(false)
90
93
  useEffect(() => {
91
94
  if (booted.current) return
92
95
  booted.current = true
96
+ // The edit signal belongs to this checkout boot, not to the prior route visit.
97
+ set('/checkoutContactEdited', false)
93
98
 
94
99
  const applyResult = (result: PlaceOrderResult) => {
95
100
  set('/checkoutPending', false)
@@ -192,7 +197,6 @@ export const registry: ViewRegistry = {
192
197
  const contact = flatToContact(flat)
193
198
  const shippingAddress = flatToAddress(flat)
194
199
  const countries = result.countries ?? []
195
- set('/checkoutContact', contact)
196
200
  set('/checkoutShippingAddress', shippingAddress)
197
201
  set('/checkoutBillingAddress', shippingAddress)
198
202
  set('/checkoutSameAsShipping', true)
@@ -202,19 +206,32 @@ export const registry: ViewRegistry = {
202
206
  set('/checkoutPaymentState', 'idle')
203
207
  set('/checkoutError', null)
204
208
 
205
- void loadCheckoutPrefillAction({
209
+ const prefillPromise = loadCheckoutPrefillAction({
206
210
  contact,
207
211
  shippingAddress,
208
212
  sameAsShipping: true,
209
213
  })
214
+ .catch((error) => {
215
+ bootError('loadCheckoutPrefill')(error)
216
+ return undefined
217
+ })
218
+ void applyCheckoutContactHydration(
219
+ Promise.resolve(contact),
220
+ prefillPromise.then((prefill) =>
221
+ prefill?.ok ? prefill.contact : undefined,
222
+ ),
223
+ () => Boolean(getSnapshot().checkoutContactEdited),
224
+ set,
225
+ ).catch(bootError('loadCheckoutPrefillContact'))
226
+ void prefillPromise
210
227
  .then((prefill) => {
228
+ if (!prefill) return
211
229
  if (!prefill.ok) {
212
230
  if (prefill.code === 'AUTH_REQUIRED') {
213
231
  navigate('/account')
214
232
  }
215
233
  return
216
234
  }
217
- set('/checkoutContact', prefill.contact)
218
235
  set('/checkoutShippingAddress', prefill.shippingAddress)
219
236
  if (prefill.billingAddress) set('/checkoutBillingAddress', prefill.billingAddress)
220
237
  set('/checkoutSameAsShipping', prefill.sameAsShipping)
@@ -6,5 +6,10 @@
6
6
  useEffect(() => {
7
7
  setNow(new Date().toISOString())
8
8
  }, [])
9
- return <UniversalBannerBlock data={{ ...parsed.data, now }} />
9
+ return (
10
+ <UniversalBannerBlock
11
+ data={{ ...parsed.data, now }}
12
+ headingLevel={parsed.headingLevel}
13
+ />
14
+ )
10
15
  },
@@ -75,6 +75,8 @@ export const benefitsContent = {
75
75
  * (−19%), Luna $82, Helios $96. A conformance test pins each claim to the
76
76
  * catalog fixtures, so editing a claim to an unsupported value fails CI.
77
77
  */
78
+ export const heroBannerHeadingLevel = 1 as const
79
+
78
80
  /**
79
81
  * Demo photography for the campaign banners: local static files under
80
82
  * `public/images/banners`, shipped by the starter and replaced in place (see the
@@ -4,7 +4,13 @@
4
4
  // and binds them into the element tree, so edits here survive `storefront sync`
5
5
  // and unit removal. Plain data only: no React and no server imports.
6
6
 
7
- import { benefitsContent, heroContent, heroBannerData, heroImage } from './content'
7
+ import {
8
+ benefitsContent,
9
+ heroContent,
10
+ heroBannerData,
11
+ heroBannerHeadingLevel,
12
+ heroImage,
13
+ } from './content'
8
14
 
9
15
  export const heroProps = {
10
16
  ...heroContent,
@@ -16,6 +22,7 @@ export const heroProps = {
16
22
  // shape mirrors `universalBannerPropsSchema` in ./schema.ts.
17
23
  export const heroBannerProps = {
18
24
  data: heroBannerData,
25
+ headingLevel: heroBannerHeadingLevel,
19
26
  }
20
27
 
21
28
  export const benefitsProps = {
@@ -31,7 +31,12 @@ export const registry: ViewRegistry = {
31
31
  useEffect(() => {
32
32
  setNow(new Date().toISOString())
33
33
  }, [])
34
- return <UniversalBannerBlock data={{ ...parsed.data, now }} />
34
+ return (
35
+ <UniversalBannerBlock
36
+ data={{ ...parsed.data, now }}
37
+ headingLevel={parsed.headingLevel}
38
+ />
39
+ )
35
40
  },
36
41
  Feature: ({ props }) => {
37
42
  const feature = featureSchemas.featureCardsSpecSchema.parse({
@@ -319,6 +319,7 @@ export const universalBannerDataSchema = z.object({
319
319
 
320
320
  export const universalBannerPropsSchema = z.object({
321
321
  data: universalBannerDataSchema,
322
+ headingLevel: z.union([z.literal(1), z.literal(2), z.literal(3)]).optional(),
322
323
  })
323
324
 
324
325
  export type FeaturedProduct = z.infer<typeof featuredProductSchema>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thorprovider/storefront",
3
- "version": "0.15.2",
3
+ "version": "0.15.3",
4
4
  "description": "Deterministic storefront scaffolder and installable OpenCode skill suite for Thor Commerce (Next.js, @thorprovider/blocks, @thorprovider/adapters, Medusa)",
5
5
  "type": "module",
6
6
  "bin": "bin/storefront.js",
@@ -47,9 +47,9 @@ export const CANDIDATE_TOOLSET = Object.freeze({
47
47
  '@json-render/next': '0.21.0',
48
48
  }),
49
49
  local: Object.freeze({
50
- '@thorprovider/blocks': '4.10.0',
50
+ '@thorprovider/blocks': '4.11.0',
51
51
  '@thorprovider/adapters': '5.8.1',
52
- '@thorprovider/runtime': '0.10.0',
52
+ '@thorprovider/runtime': '0.10.1',
53
53
  '@thorprovider/types': '7.8.0',
54
54
  }),
55
55
  })
@@ -34,6 +34,11 @@ export function envExample(name) {
34
34
  '# unset or blank falls back to es-UY, the scaffold default that matches',
35
35
  '# the mock Uruguay region (UYU).',
36
36
  'THOR_STORE_LOCALE=es-UY',
37
+ '# Canonical public origin for metadata, robots.txt, and sitemap.xml.',
38
+ '# Optional; without it, relative product Open Graph images are omitted.',
39
+ '# Set the store public origin to resolve relative images; absolute image URLs remain.',
40
+ '# Example: https://shop.example.com',
41
+ 'THOR_SITE_URL=',
37
42
  '# Demo imagery base (mock mode only). The starter ships local product,',
38
43
  '# category and banner shots under public/images; drop this to fall back to',
39
44
  '# the generated SVG placeholders.',
@@ -11,6 +11,7 @@ import {
11
11
  buildClientRegistryBarrel,
12
12
  writeClientRegistryBarrel,
13
13
  injectLayout,
14
+ injectStoreLayoutContract,
14
15
  migrateLayoutInjection,
15
16
  injectThemeMode,
16
17
  injectGlobals,
@@ -111,7 +112,9 @@ async function ensureLayoutAppend(targetDir, name, siteName, mode, dryRun) {
111
112
  // A custom injection is reported as a conflict and nothing is written.
112
113
  const migration = migrateLayoutInjection(existing)
113
114
  if (migration.conflict) return { changed: false, conflict: migration.conflict }
114
- const content = injectThemeMode(injectLayout(migration.content, name), mode)
115
+ const withProvider = injectLayout(migration.content, name)
116
+ const withStoreContract = injectStoreLayoutContract(withProvider, name, siteName)
117
+ const content = injectThemeMode(withStoreContract, mode)
115
118
  if (content === existing) return { changed: false, conflict: null }
116
119
  if (!dryRun) await writeFile(layoutPath, content)
117
120
  return { changed: true, conflict: null }
@@ -331,6 +331,109 @@ export function injectLayout(content, name) {
331
331
  return out
332
332
  }
333
333
 
334
+ /**
335
+ * Bring an existing create-next-app layout up to the storefront's root
336
+ * contract without replacing its user-owned fonts, body classes, or wrappers.
337
+ * The document locale and metadataBase are contract-managed; other custom
338
+ * metadata remains intact.
339
+ */
340
+ export function injectStoreLayoutContract(content, name, siteName) {
341
+ const storeContextPath = `@/lib/${name}/store-context`
342
+ const escapedPath = storeContextPath.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
343
+ const storeContextImport = new RegExp(
344
+ `import\\s*\\{([^}]*)\\}\\s*from\\s*(['"])${escapedPath}\\2`,
345
+ )
346
+ let out = content
347
+ const existingImport = out.match(storeContextImport)
348
+ if (existingImport) {
349
+ const names = existingImport[1].split(',').map((value) => value.trim()).filter(Boolean)
350
+ for (const required of ['getSiteUrl', 'getStoreLocale']) {
351
+ if (!names.includes(required)) names.push(required)
352
+ }
353
+ out = out.replace(existingImport[0], `import { ${names.join(', ')} } from '${storeContextPath}'`)
354
+ } else {
355
+ const lines = out.split('\n')
356
+ let lastImport = -1
357
+ for (let i = 0; i < lines.length; i++) {
358
+ if (lines[i].trimStart().startsWith('import ')) lastImport = i
359
+ }
360
+ lines.splice(
361
+ lastImport >= 0 ? lastImport + 1 : 0,
362
+ 0,
363
+ `import { getSiteUrl, getStoreLocale } from '${storeContextPath}'`,
364
+ )
365
+ out = lines.join('\n')
366
+ }
367
+
368
+ out = out.replace(/<html\b([^>]*)>/, (_tag, attributes) => {
369
+ const langAttribute = /\s+lang=(?:"[^"]*"|'[^']*'|\{[^}]*\})/
370
+ if (langAttribute.test(attributes)) {
371
+ return `<html${attributes.replace(langAttribute, ' lang={getStoreLocale()}')}>`
372
+ }
373
+ return `<html${attributes} lang={getStoreLocale()}>`
374
+ })
375
+
376
+ const metadataPattern = /export\s+const\s+metadata(?:\s*:\s*Metadata)?\s*=\s*\{/
377
+ const metadataMatch = out.match(metadataPattern)
378
+ const configuredSiteUrl = out.match(
379
+ /\b(?:const|let)\s+([A-Za-z_$][\w$]*)\s*=\s*getSiteUrl\(\)/,
380
+ )
381
+ let siteUrlName = configuredSiteUrl?.[1]
382
+ if (!siteUrlName) {
383
+ const declaredNames = new Set(
384
+ [...out.matchAll(/\b(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*=/g)].map((match) => match[1]),
385
+ )
386
+ siteUrlName = declaredNames.has('siteUrl') ? 'thorSiteUrl' : 'siteUrl'
387
+ while (declaredNames.has(siteUrlName)) siteUrlName = `_${siteUrlName}`
388
+ const metadataIndex = metadataMatch?.index ?? out.search(/export\s+default\s+function/)
389
+ const declaration = `\nconst ${siteUrlName} = getSiteUrl()\n`
390
+ out =
391
+ metadataIndex >= 0
392
+ ? `${out.slice(0, metadataIndex)}${declaration}\n${out.slice(metadataIndex)}`
393
+ : `${out.trimEnd()}${declaration}`
394
+ }
395
+
396
+ if (/\bmetadataBase\s*:/.test(out)) {
397
+ out = out.replace(
398
+ /(\bmetadataBase\s*:\s*)([^,\n}]+)/,
399
+ (_match, prefix) => `${prefix}${siteUrlName} ? new URL(${siteUrlName}) : undefined`,
400
+ )
401
+ } else {
402
+ const currentMetadataMatch = out.match(metadataPattern)
403
+ if (currentMetadataMatch?.index !== undefined) {
404
+ const insertionIndex = currentMetadataMatch.index + currentMetadataMatch[0].length
405
+ out = `${out.slice(0, insertionIndex)}\n metadataBase: ${siteUrlName} ? new URL(${siteUrlName}) : undefined,${out.slice(insertionIndex)}`
406
+ } else {
407
+ if (!/import\s+type\s+\{\s*Metadata\s*\}\s+from\s+['"]next['"]/.test(out)) {
408
+ const lines = out.split('\n')
409
+ let lastImport = -1
410
+ for (let i = 0; i < lines.length; i++) {
411
+ if (lines[i].trimStart().startsWith('import ')) lastImport = i
412
+ }
413
+ lines.splice(lastImport >= 0 ? lastImport + 1 : 0, 0, `import type { Metadata } from 'next'`)
414
+ out = lines.join('\n')
415
+ }
416
+ const metadata = `export const metadata: Metadata = {\n metadataBase: ${siteUrlName} ? new URL(${siteUrlName}) : undefined,\n title: ${JSON.stringify(siteName)},\n description: ${JSON.stringify(`Tienda online de ${siteName}.`)},\n}\n\n`
417
+ const rootLayoutIndex = out.search(/export\s+default\s+function/)
418
+ out =
419
+ rootLayoutIndex >= 0
420
+ ? `${out.slice(0, rootLayoutIndex)}${metadata}${out.slice(rootLayoutIndex)}`
421
+ : `${out.trimEnd()}\n\n${metadata}`
422
+ }
423
+ }
424
+
425
+ // Replace only the well-known create-next-app defaults. Any merchant-authored
426
+ // title or description remains their bounded metadata customization.
427
+ out = out.replace(/(\btitle\s*:\s*)['"]Create Next App['"]/, (_match, prefix) =>
428
+ `${prefix}${JSON.stringify(siteName)}`,
429
+ )
430
+ out = out.replace(
431
+ /(\bdescription\s*:\s*)['"]Generated by create next app['"]/i,
432
+ (_match, prefix) => `${prefix}${JSON.stringify(`Tienda online de ${siteName}.`)}`,
433
+ )
434
+ return out
435
+ }
436
+
334
437
  // The exact default theme expression the previous scaffold injected. Migration
335
438
  // removes it so the stylesheet becomes the single visual source.
336
439
  const LEGACY_THEME_EXPR = 'themeVarsToCss(themeTokensToVars(DEFAULT_THEME_TOKENS))'
@@ -574,7 +677,9 @@ async function ensureLayoutAppend(targetDir, name, siteName, mode = DEFAULT_THEM
574
677
  return
575
678
  }
576
679
  const existing = await readFile(layoutPath, 'utf8')
577
- const injected = injectThemeMode(injectLayout(existing, name), mode)
680
+ const withProvider = injectLayout(existing, name)
681
+ const withStoreContract = injectStoreLayoutContract(withProvider, name, siteName)
682
+ const injected = injectThemeMode(withStoreContract, mode)
578
683
  if (injected !== existing) await writeFile(layoutPath, injected)
579
684
  }
580
685