@thorprovider/storefront 0.15.2 → 0.15.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/assets/templates/app/app/[[...slug]]/page.tsx +4 -0
- package/assets/templates/app/lib/__STOREFRONT__/header-universal.ts +112 -33
- package/assets/templates/app/lib/__STOREFRONT__/registry.tsx +236 -71
- package/assets/templates/app/lib/__STOREFRONT__/spec/index.ts +37 -1
- package/assets/templates/app/lib/__STOREFRONT__/state.core.ts +6 -0
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/schema.universal-banner.ts +2 -1
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/universal-banner.client.tsx +4 -1
- package/assets/templates/app/public/demo/accessories.svg +7 -0
- package/assets/templates/app/public/demo/dresses.svg +6 -0
- package/assets/templates/app/public/demo/furniture.svg +9 -0
- package/assets/templates/app/public/demo/home.svg +8 -0
- package/assets/templates/app/public/demo/jackets.svg +11 -0
- package/assets/templates/app/public/demo/promo-invierno.svg +8 -0
- package/assets/templates/features/checkout/state.ts +2 -0
- package/assets/templates/views/category/assembly/slots/filter/CategoryListing/element.part +1 -0
- package/assets/templates/views/category/assembly/slots/filter/CategoryListing/registry.part +2 -0
- package/assets/templates/views/category/content.ts +1 -0
- package/assets/templates/views/category/index.tsx +1 -0
- package/assets/templates/views/category/registry.tsx +2 -0
- package/assets/templates/views/category/schema.ts +2 -0
- package/assets/templates/views/checkout/checkout-commerce-hosted.tsx +19 -0
- package/assets/templates/views/checkout/registry.tsx +22 -5
- package/assets/templates/views/home/assembly/slots/hero/UniversalBanner/registry.part +6 -1
- package/assets/templates/views/home/content.ts +5 -1
- package/assets/templates/views/home/props.ts +8 -1
- package/assets/templates/views/home/registry.tsx +6 -1
- package/assets/templates/views/home/schema.ts +2 -1
- package/package.json +1 -1
- package/scripts/candidate.mjs +2 -2
- package/scripts/env-file.mjs +5 -0
- package/scripts/reconcile.mjs +4 -1
- package/scripts/render-templates.mjs +106 -1
- package/skills/sf-view-gen/assets/templates/views/sections/schema.universal-banner.ts +1 -1
|
@@ -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 {
|
|
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
|
-
|
|
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)
|
|
@@ -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
|
|
@@ -293,7 +295,9 @@ export const heroBannerData = {
|
|
|
293
295
|
spans: [2, 1, 1, 1, 1],
|
|
294
296
|
gapX: 'md',
|
|
295
297
|
gapY: 'md',
|
|
296
|
-
|
|
298
|
+
// The banner shares the page column with the product rail and the rest of
|
|
299
|
+
// the sections instead of running to the viewport edges.
|
|
300
|
+
maxWidth: 'page',
|
|
297
301
|
// Caps every cell at 384px, which is the hero's height in its two-column
|
|
298
302
|
// cell. The tiles keep their 224px floor, so the wall stays near 630px.
|
|
299
303
|
maxHeight: 'xl',
|
|
@@ -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 {
|
|
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
|
|
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({
|
|
@@ -282,7 +282,7 @@ export const universalBannerDataSchema = z.object({
|
|
|
282
282
|
layout: z.object({
|
|
283
283
|
gapX: z.enum(['sm', 'md', 'lg', 'xl', 'none']),
|
|
284
284
|
gapY: z.enum(['sm', 'md', 'lg', 'xl', 'none']),
|
|
285
|
-
maxWidth: z.enum(['full', 'sm', 'md', 'lg', 'xl']),
|
|
285
|
+
maxWidth: z.enum(['full', 'page', 'sm', 'md', 'lg', 'xl']),
|
|
286
286
|
maxHeight: z.enum(['sm', 'md', 'lg', 'xl', 'none']),
|
|
287
287
|
align: z.enum(['center', 'start', 'end']),
|
|
288
288
|
radius: z.enum(['md', 'lg', 'xl', 'none', '2xl']),
|
|
@@ -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.
|
|
3
|
+
"version": "0.15.4",
|
|
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",
|
package/scripts/candidate.mjs
CHANGED
|
@@ -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.
|
|
50
|
+
'@thorprovider/blocks': '4.11.0',
|
|
51
51
|
'@thorprovider/adapters': '5.8.1',
|
|
52
|
-
'@thorprovider/runtime': '0.10.
|
|
52
|
+
'@thorprovider/runtime': '0.10.1',
|
|
53
53
|
'@thorprovider/types': '7.8.0',
|
|
54
54
|
}),
|
|
55
55
|
})
|
package/scripts/env-file.mjs
CHANGED
|
@@ -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.',
|
package/scripts/reconcile.mjs
CHANGED
|
@@ -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
|
|
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
|
|
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
|
|
|
@@ -169,7 +169,7 @@ export const universalBannerDataSchema = z.object({
|
|
|
169
169
|
layout: z.object({
|
|
170
170
|
gapX: z.enum(["sm", "md", "lg", "xl", "none"]),
|
|
171
171
|
gapY: z.enum(["sm", "md", "lg", "xl", "none"]),
|
|
172
|
-
maxWidth: z.enum(["full", "sm", "md", "lg", "xl"]),
|
|
172
|
+
maxWidth: z.enum(["full", "page", "sm", "md", "lg", "xl"]),
|
|
173
173
|
maxHeight: z.enum(["sm", "md", "lg", "xl", "none"]),
|
|
174
174
|
align: z.enum(["center", "start", "end"]),
|
|
175
175
|
radius: z.enum(["md", "lg", "xl", "none", "2xl"]),
|