@thorprovider/storefront 0.15.1 → 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 (45) hide show
  1. package/README.md +1 -1
  2. package/assets/templates/app/app/[[...slug]]/page.tsx +16 -4
  3. package/assets/templates/app/lib/__STOREFRONT__/header-universal.ts +373 -0
  4. package/assets/templates/app/lib/__STOREFRONT__/registry.tsx +143 -11
  5. package/assets/templates/app/lib/__STOREFRONT__/schema.ts +52 -0
  6. package/assets/templates/app/lib/__STOREFRONT__/shell/content.ts +43 -0
  7. package/assets/templates/app/lib/__STOREFRONT__/shell/props.ts +4 -0
  8. package/assets/templates/app/lib/__STOREFRONT__/spec/index.ts +22 -40
  9. package/assets/templates/app/lib/__STOREFRONT__/views/sections/header-universal.client.tsx +33 -0
  10. package/assets/templates/app/lib/__STOREFRONT__/views/sections/header-universal.tsx +16 -0
  11. package/assets/templates/app/lib/__STOREFRONT__/views/sections/index.ts +2 -1
  12. package/assets/templates/app/lib/__STOREFRONT__/views/sections/schema.header-universal.ts +360 -0
  13. package/assets/templates/app/lib/__STOREFRONT__/views/sections/schema.universal-banner.ts +1 -0
  14. package/assets/templates/app/lib/__STOREFRONT__/views/sections/universal-banner.client.tsx +4 -1
  15. package/assets/templates/app/public/demo/accessories.svg +7 -0
  16. package/assets/templates/app/public/demo/dresses.svg +6 -0
  17. package/assets/templates/app/public/demo/furniture.svg +9 -0
  18. package/assets/templates/app/public/demo/home.svg +8 -0
  19. package/assets/templates/app/public/demo/jackets.svg +11 -0
  20. package/assets/templates/app/public/demo/promo-invierno.svg +8 -0
  21. package/assets/templates/features/checkout/state.ts +2 -0
  22. package/assets/templates/views/category/assembly/slots/filter/CategoryListing/element.part +1 -0
  23. package/assets/templates/views/category/assembly/slots/filter/CategoryListing/registry.part +2 -0
  24. package/assets/templates/views/category/content.ts +1 -0
  25. package/assets/templates/views/category/index.tsx +1 -0
  26. package/assets/templates/views/category/registry.tsx +2 -0
  27. package/assets/templates/views/category/schema.ts +2 -0
  28. package/assets/templates/views/checkout/checkout-commerce-hosted.tsx +19 -0
  29. package/assets/templates/views/checkout/registry.tsx +22 -5
  30. package/assets/templates/views/home/assembly/slots/hero/UniversalBanner/registry.part +6 -1
  31. package/assets/templates/views/home/content.ts +2 -0
  32. package/assets/templates/views/home/props.ts +8 -1
  33. package/assets/templates/views/home/registry.tsx +6 -1
  34. package/assets/templates/views/home/schema.ts +1 -0
  35. package/package.json +1 -1
  36. package/recipes/sections.json +18 -0
  37. package/scripts/candidate.mjs +2 -2
  38. package/scripts/env-file.mjs +5 -0
  39. package/scripts/file-classes.mjs +7 -2
  40. package/scripts/reconcile.mjs +4 -1
  41. package/scripts/render-templates.mjs +106 -1
  42. package/skills/sf-view-gen/assets/recipes/sections.json +18 -0
  43. package/skills/sf-view-gen/assets/templates/views/sections/header-universal.client.tsx +33 -0
  44. package/skills/sf-view-gen/assets/templates/views/sections/header-universal.tsx +16 -0
  45. package/skills/sf-view-gen/assets/templates/views/sections/schema.header-universal.ts +360 -0
@@ -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.1",
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",
@@ -366,6 +366,24 @@
366
366
  "propsHint": "data (categories[], config, labels, promotion, preview)",
367
367
  "status": "executable",
368
368
  "agent": {"status":"pending","section":"universal-main-menu","elementType":"UniversalMainMenu","variants":["UniversalMainMenu"],"kind":"pending-card","reason":"The menu's data is the shop's catalog taxonomy; an agent-editable card needs a reviewed authoring contract for recursive category trees before automatic configuration is enabled.","owner":"design intake — universal-main-menu"}
369
+ },
370
+ {
371
+ "name": "header-universal",
372
+ "description": "HeaderUniversal presentation section (delivery header-universal).",
373
+ "elementType": "HeaderUniversal",
374
+ "variants": ["HeaderUniversal"],
375
+ "defaultVariant": "HeaderUniversal",
376
+ "propsHint": "config (header configuration), context (brand, menu, capabilities)",
377
+ "status": "executable",
378
+ "agent": {
379
+ "status": "exempt",
380
+ "section": "header-universal",
381
+ "elementType": "HeaderUniversal",
382
+ "variants": ["HeaderUniversal"],
383
+ "kind": "host-only",
384
+ "reason": "The header and its menu are storefront-shell concerns: the header is the shop's navigation chrome and its menu data is the host's catalog taxonomy, so this section must be configured by the host rather than selected as page content.",
385
+ "owner": "Wave 1 — storefront shell"
386
+ }
369
387
  }
370
388
  ]
371
389
  }
@@ -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.8.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.',
@@ -64,6 +64,9 @@ const RULES = [
64
64
  // The footer content contract and its neutral defaults are package-owned;
65
65
  // a merchant overrides copy through the user-owned shell content seam.
66
66
  'app/lib/*/footer-content.ts',
67
+ // The universal header's authored config and menu builder are package-owned
68
+ // shell chrome, not merchant content.
69
+ 'app/lib/*/header-universal.ts',
67
70
  'app/lib/*/account-lifecycle.client.tsx',
68
71
  'app/lib/*/account-boundary.client.tsx',
69
72
  'app/lib/*/account-mutation.client.ts',
@@ -74,8 +77,7 @@ const RULES = [
74
77
  'app/lib/*/commerce.ts',
75
78
  'app/lib/*/ports.ts',
76
79
  'app/lib/*/orders-port.ts',
77
- 'app/lib/*/order-detail-port.ts',
78
- 'app/lib/*/order-detail-mapper.ts',
80
+ 'app/lib/*/order-detail-*.ts',
79
81
  'app/lib/*/fulfillment-evidence-port.ts',
80
82
  'app/lib/*/addresses-port.ts',
81
83
  'app/lib/*/customer-profile-port.ts',
@@ -98,6 +100,9 @@ const RULES = [
98
100
  'views/*/registry.tsx',
99
101
  'views/*/orders-advanced.client.tsx',
100
102
  'views/*/order-detail.client.tsx',
103
+ 'views/*/order-detail-invoice.ts',
104
+ 'views/*/order-detail-sheet.tsx',
105
+ 'views/*/order-detail-sheets.tsx',
101
106
  'views/*/fulfillment-evidence.client.tsx',
102
107
  'views/*/fulfillment-evidence.schema.ts',
103
108
  'views/*/*.defaults.ts',
@@ -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
 
@@ -366,6 +366,24 @@
366
366
  "propsHint": "data (categories[], config, labels, promotion, preview)",
367
367
  "status": "executable",
368
368
  "agent": {"status":"pending","section":"universal-main-menu","elementType":"UniversalMainMenu","variants":["UniversalMainMenu"],"kind":"pending-card","reason":"The menu's data is the shop's catalog taxonomy; an agent-editable card needs a reviewed authoring contract for recursive category trees before automatic configuration is enabled.","owner":"design intake — universal-main-menu"}
369
+ },
370
+ {
371
+ "name": "header-universal",
372
+ "description": "HeaderUniversal presentation section (delivery header-universal).",
373
+ "elementType": "HeaderUniversal",
374
+ "variants": ["HeaderUniversal"],
375
+ "defaultVariant": "HeaderUniversal",
376
+ "propsHint": "config (header configuration), context (brand, menu, capabilities)",
377
+ "status": "executable",
378
+ "agent": {
379
+ "status": "exempt",
380
+ "section": "header-universal",
381
+ "elementType": "HeaderUniversal",
382
+ "variants": ["HeaderUniversal"],
383
+ "kind": "host-only",
384
+ "reason": "The header and its menu are storefront-shell concerns: the header is the shop's navigation chrome and its menu data is the host's catalog taxonomy, so this section must be configured by the host rather than selected as page content.",
385
+ "owner": "Wave 1 — storefront shell"
386
+ }
369
387
  }
370
388
  ]
371
389
  }
@@ -0,0 +1,33 @@
1
+ 'use client'
2
+
3
+ // Optional section fragment: header-universal (mirrors recipes/sections.json) — client registry.
4
+ // The matching server-side catalog lives in header-universal.tsx. @thorprovider/blocks ships a
5
+ // 'use client' boundary, but this fragment keeps the explicit client boundary so
6
+ // the section composes identically in any consumer graph.
7
+
8
+ import { useRouter } from 'next/navigation'
9
+ import { HeaderUniversal } from '@thorprovider/blocks'
10
+ import { universalHeaderPropsSchema } from './schema.header-universal'
11
+ import type { ViewRegistry } from '../types'
12
+
13
+ export const headerUniversalRegistry: ViewRegistry = {
14
+ HeaderUniversal: ({ props }) => {
15
+ const router = useRouter()
16
+ const parsed = universalHeaderPropsSchema.parse(props)
17
+ return (
18
+ <HeaderUniversal
19
+ config={parsed.config}
20
+ context={parsed.context}
21
+ labels={parsed.labels}
22
+ breakpoint={parsed.breakpoint}
23
+ className={parsed.className}
24
+ onAction={(action) => {
25
+ if (action.name === 'navigate') {
26
+ const href = action.payload?.href
27
+ if (typeof href === 'string' && href.startsWith('/')) router.push(href)
28
+ }
29
+ }}
30
+ />
31
+ )
32
+ },
33
+ }