@thorprovider/storefront 0.14.0 → 0.15.1
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 +28 -12
- package/assets/templates/app/app/[[...slug]]/page.tsx +6 -0
- package/assets/templates/app/app/layout.tsx +2 -2
- package/assets/templates/app/lib/__STOREFRONT__/commerce.ts +11 -4
- package/assets/templates/app/lib/__STOREFRONT__/confirmation.core.ts +7 -4
- package/assets/templates/app/lib/__STOREFRONT__/mappers.ts +18 -3
- package/assets/templates/app/lib/__STOREFRONT__/registry.tsx +10 -0
- package/assets/templates/app/lib/__STOREFRONT__/state.core.ts +8 -0
- package/assets/templates/app/lib/__STOREFRONT__/store-context.ts +84 -18
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/schema.universal-main-menu.ts +3 -1
- package/assets/templates/app/public/images/README.md +43 -0
- package/assets/templates/app/public/images/banners/banner-aurora-deal.webp +0 -0
- package/assets/templates/app/public/images/banners/banner-guia-regalo.webp +0 -0
- package/assets/templates/app/public/images/banners/banner-mesa-decor.webp +0 -0
- package/assets/templates/app/public/images/banners/banner-nuevas-llegadas.webp +0 -0
- package/assets/templates/app/public/images/banners/banner-salon-oferta.webp +0 -0
- package/assets/templates/app/public/images/categories/accessories.webp +0 -0
- package/assets/templates/app/public/images/categories/dresses.webp +0 -0
- package/assets/templates/app/public/images/categories/furniture.webp +0 -0
- package/assets/templates/app/public/images/categories/home.webp +0 -0
- package/assets/templates/app/public/images/categories/jackets.webp +0 -0
- package/assets/templates/app/public/images/editorial/studio.webp +0 -0
- package/assets/templates/app/public/images/products/alpine-jacket.webp +0 -0
- package/assets/templates/app/public/images/products/amber-dress.webp +0 -0
- package/assets/templates/app/public/images/products/atlas-lamp.webp +0 -0
- package/assets/templates/app/public/images/products/atlas-sofa.webp +0 -0
- package/assets/templates/app/public/images/products/aurora-jacket.webp +0 -0
- package/assets/templates/app/public/images/products/boreal-jacket.webp +0 -0
- package/assets/templates/app/public/images/products/camille-dress.webp +0 -0
- package/assets/templates/app/public/images/products/ceramic-table-lamp.webp +0 -0
- package/assets/templates/app/public/images/products/cinder-jacket.webp +0 -0
- package/assets/templates/app/public/images/products/copper-lamp.webp +0 -0
- package/assets/templates/app/public/images/products/cove-bag.webp +0 -0
- package/assets/templates/app/public/images/products/dahlia-dress.webp +0 -0
- package/assets/templates/app/public/images/products/drift-jacket.webp +0 -0
- package/assets/templates/app/public/images/products/dune-lamp.webp +0 -0
- package/assets/templates/app/public/images/products/elara-dress.webp +0 -0
- package/assets/templates/app/public/images/products/ember-jacket.webp +0 -0
- package/assets/templates/app/public/images/products/fable-bag.webp +0 -0
- package/assets/templates/app/public/images/products/fjord-jacket.webp +0 -0
- package/assets/templates/app/public/images/products/floor-cushion.webp +0 -0
- package/assets/templates/app/public/images/products/harbor-jacket.webp +0 -0
- package/assets/templates/app/public/images/products/helios-lamp.webp +0 -0
- package/assets/templates/app/public/images/products/iris-dress.webp +0 -0
- package/assets/templates/app/public/images/products/juniper-bag.webp +0 -0
- package/assets/templates/app/public/images/products/kestrel-bag.webp +0 -0
- package/assets/templates/app/public/images/products/linen-armchair.webp +0 -0
- package/assets/templates/app/public/images/products/lumen-dress.webp +0 -0
- package/assets/templates/app/public/images/products/luna-bag.webp +0 -0
- package/assets/templates/app/public/images/products/marble-coffee-table.webp +0 -0
- package/assets/templates/app/public/images/products/marlowe-bag.webp +0 -0
- package/assets/templates/app/public/images/products/meridian-jacket.webp +0 -0
- package/assets/templates/app/public/images/products/nomad-jacket.webp +0 -0
- package/assets/templates/app/public/images/products/nova-dress.webp +0 -0
- package/assets/templates/app/public/images/products/oak-dining-table.webp +0 -0
- package/assets/templates/app/public/images/products/onyx-lamp.webp +0 -0
- package/assets/templates/app/public/images/products/piper-bag.webp +0 -0
- package/assets/templates/app/public/images/products/quill-lamp.webp +0 -0
- package/assets/templates/app/public/images/products/rosalind-dress.webp +0 -0
- package/assets/templates/app/public/images/products/rune-bag.webp +0 -0
- package/assets/templates/app/public/images/products/side-table.webp +0 -0
- package/assets/templates/app/public/images/products/slate-lamp.webp +0 -0
- package/assets/templates/app/public/images/products/solis-dress.webp +0 -0
- package/assets/templates/app/public/images/products/storage-shelf.webp +0 -0
- package/assets/templates/app/public/images/products/terra-lamp.webp +0 -0
- package/assets/templates/app/public/images/products/tundra-jacket.webp +0 -0
- package/assets/templates/app/public/images/products/vantage-jacket.webp +0 -0
- package/assets/templates/app/public/images/products/vera-dress.webp +0 -0
- package/assets/templates/app/public/images/products/verdant-lamp.webp +0 -0
- package/assets/templates/app/public/images/products/wall-mirror.webp +0 -0
- package/assets/templates/app/public/images/products/wool-rug.webp +0 -0
- package/assets/templates/views/account/address-book-advanced.defaults.ts +1 -1
- package/assets/templates/views/cart/registry.tsx +9 -0
- package/assets/templates/views/checkout/checkout-commerce-hosted.tsx +5 -1
- package/assets/templates/views/home/assembly/assembly.json +0 -1
- package/assets/templates/views/home/assembly/index.skeleton.tsx +3 -7
- package/assets/templates/views/home/assembly/registry.skeleton.tsx +0 -3
- package/assets/templates/views/home/content.ts +34 -80
- package/assets/templates/views/home/data.ts +12 -0
- package/assets/templates/views/home/index.tsx +4 -21
- package/assets/templates/views/home/props.ts +1 -7
- package/assets/templates/views/home/registry.tsx +0 -35
- package/assets/templates/views/home/schema.ts +0 -36
- package/bin/storefront.js +12 -27
- package/package.json +3 -2
- package/recipes/archetypes.json +0 -21
- package/recipes/catalog.json +0 -22
- package/recipes/features.json +0 -2
- package/recipes/recipe.schema.json +5 -0
- package/recipes/recipes.json +19 -16
- package/recipes/validate.mjs +7 -0
- package/scripts/candidate.mjs +3 -3
- package/scripts/default-sections.mjs +1 -0
- package/scripts/env-file.mjs +10 -0
- package/scripts/file-classes.mjs +3 -0
- package/scripts/generate-demo-images.mjs +507 -0
- package/scripts/reconcile.mjs +32 -1
- package/scripts/render-templates.mjs +13 -1
- package/scripts/section-compat.mjs +10 -1
- package/scripts/section-operations.mjs +3 -0
- package/scripts/starter.mjs +25 -1
- package/scripts/theme/starter-theme.mjs +118 -0
- package/skills/sf-view-gen/assets/recipes/archetypes.json +0 -21
- package/skills/sf-view-gen/assets/recipes/catalog.json +0 -22
- package/skills/sf-view-gen/assets/recipes/features.json +0 -2
- package/skills/sf-view-gen/assets/recipes/recipes.json +19 -16
- package/skills/sf-view-gen/assets/templates/views/sections/schema.universal-main-menu.ts +3 -1
- package/skills/sf-view-gen/scripts/validate.mjs +7 -0
- package/assets/templates/views/home/assembly/slots/categories/CategoryGrid/binding.json +0 -5
- package/assets/templates/views/home/assembly/slots/categories/CategoryGrid/catalog.part +0 -8
- package/assets/templates/views/home/assembly/slots/categories/CategoryGrid/element.part +0 -5
- package/assets/templates/views/home/assembly/slots/categories/CategoryGrid/registry.part +0 -31
|
@@ -0,0 +1,507 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Deterministic demo imagery for the scaffolded starter.
|
|
3
|
+
//
|
|
4
|
+
// The starter ships product, category and banner art as LOCAL static files so a
|
|
5
|
+
// freshly created store looks like a real shop instead of showing gradient
|
|
6
|
+
// placeholders. The bytes are rendered here from SVG, so they are reproducible,
|
|
7
|
+
// license-free, and reviewable in a diff-free way (re-run the script instead of
|
|
8
|
+
// editing a binary).
|
|
9
|
+
//
|
|
10
|
+
// node scripts/generate-demo-images.mjs [--out <dir>] [--force]
|
|
11
|
+
//
|
|
12
|
+
// Output (relative to assets/templates/app/public/images by default):
|
|
13
|
+
// products/<handle>.webp 1200x1200 — square, matches the product card
|
|
14
|
+
// categories/<handle>.webp 900x900 — square, matches the category tile
|
|
15
|
+
// banners/<banner-id>.webp 1800x1000 — landscape, banner `aspect: photo`
|
|
16
|
+
// editorial/studio.webp 1600x1200 — benefits section, rendered grayscale
|
|
17
|
+
//
|
|
18
|
+
// Replacing the art: drop your own file at the same path. Nothing in the code
|
|
19
|
+
// reads a manifest of these files, so a swap needs no code change.
|
|
20
|
+
|
|
21
|
+
import { mkdir, writeFile, access } from 'node:fs/promises'
|
|
22
|
+
import path from 'node:path'
|
|
23
|
+
import { fileURLToPath } from 'node:url'
|
|
24
|
+
import sharp from 'sharp'
|
|
25
|
+
|
|
26
|
+
const here = path.dirname(fileURLToPath(import.meta.url))
|
|
27
|
+
const pkgRoot = path.resolve(here, '..')
|
|
28
|
+
const DEFAULT_OUT = path.join(pkgRoot, 'assets', 'templates', 'app', 'public', 'images')
|
|
29
|
+
|
|
30
|
+
const args = process.argv.slice(2)
|
|
31
|
+
const outDir = args.includes('--out') ? args[args.indexOf('--out') + 1] : DEFAULT_OUT
|
|
32
|
+
const force = args.includes('--force')
|
|
33
|
+
|
|
34
|
+
// ---------------------------------------------------------------------------
|
|
35
|
+
// Shared studio furniture
|
|
36
|
+
// ---------------------------------------------------------------------------
|
|
37
|
+
|
|
38
|
+
// Warm, low-saturation ground so product colour stays the only strong signal.
|
|
39
|
+
const GROUND = `
|
|
40
|
+
<defs>
|
|
41
|
+
<radialGradient id="ground" cx="50%" cy="42%" r="72%">
|
|
42
|
+
<stop offset="0%" stop-color="#fbf9f5" />
|
|
43
|
+
<stop offset="62%" stop-color="#f1ede6" />
|
|
44
|
+
<stop offset="100%" stop-color="#e2ddd4" />
|
|
45
|
+
</radialGradient>
|
|
46
|
+
<radialGradient id="edge" cx="50%" cy="50%" r="62%">
|
|
47
|
+
<stop offset="70%" stop-color="rgba(60,50,40,0)" />
|
|
48
|
+
<stop offset="100%" stop-color="rgba(60,50,40,0.16)" />
|
|
49
|
+
</radialGradient>
|
|
50
|
+
<filter id="grain">
|
|
51
|
+
<feTurbulence type="fractalNoise" baseFrequency="0.9" numOctaves="3" stitchTiles="stitch" />
|
|
52
|
+
<feColorMatrix type="saturate" values="0" />
|
|
53
|
+
<feComponentTransfer><feFuncA type="linear" slope="0.055" /></feComponentTransfer>
|
|
54
|
+
</filter>
|
|
55
|
+
<filter id="soft" x="-30%" y="-30%" width="160%" height="160%">
|
|
56
|
+
<feGaussianBlur stdDeviation="22" />
|
|
57
|
+
</filter>
|
|
58
|
+
<filter id="blur8" x="-30%" y="-30%" width="160%" height="160%">
|
|
59
|
+
<feGaussianBlur stdDeviation="8" />
|
|
60
|
+
</filter>
|
|
61
|
+
</defs>
|
|
62
|
+
`
|
|
63
|
+
|
|
64
|
+
/** Floor shadow under a product, sized to its footprint. */
|
|
65
|
+
const shadow = (cx, cy, rx, ry = rx * 0.16, opacity = 0.22) =>
|
|
66
|
+
`<ellipse cx="${cx}" cy="${cy}" rx="${rx}" ry="${ry}" fill="rgba(70,58,46,${opacity})" filter="url(#soft)" />`
|
|
67
|
+
|
|
68
|
+
const svg = (w, h, body) => `<svg xmlns="http://www.w3.org/2000/svg" width="${w}" height="${h}" viewBox="0 0 ${w} ${h}">
|
|
69
|
+
${GROUND}
|
|
70
|
+
<rect width="${w}" height="${h}" fill="url(#ground)" />
|
|
71
|
+
${body}
|
|
72
|
+
<rect width="${w}" height="${h}" fill="url(#edge)" />
|
|
73
|
+
<rect width="${w}" height="${h}" filter="url(#grain)" opacity="0.5" />
|
|
74
|
+
</svg>`
|
|
75
|
+
|
|
76
|
+
// ---------------------------------------------------------------------------
|
|
77
|
+
// Product silhouettes — drawn in a 1200x1200 box, product fills ~y 260..950
|
|
78
|
+
// ---------------------------------------------------------------------------
|
|
79
|
+
|
|
80
|
+
const products = {
|
|
81
|
+
'aurora-jacket': () => `
|
|
82
|
+
${shadow(600, 908, 240, 24, 0.2)}
|
|
83
|
+
<g>
|
|
84
|
+
<path d='M600 244 q0 -28 19 -28 q17 0 17 17' stroke='#b9ab96' stroke-width='7' fill='none' stroke-linecap='round' />
|
|
85
|
+
<path d='M600 244 L466 336' stroke='#b9ab96' stroke-width='8' fill='none' stroke-linecap='round' />
|
|
86
|
+
<path d='M600 244 L734 336' stroke='#b9ab96' stroke-width='8' fill='none' stroke-linecap='round' />
|
|
87
|
+
<path d='M500 352 L452 368 Q430 528 424 706 L454 724 Q476 566 500 478 Z' fill='#243340' />
|
|
88
|
+
<path d='M700 352 L748 368 Q770 528 776 706 L746 724 Q724 566 700 478 Z' fill='#243340' />
|
|
89
|
+
<path d='M500 352 Q600 322 700 352 L718 478 L710 726 Q600 766 490 726 L482 478 Z' fill='#2e3d4b' />
|
|
90
|
+
<path d='M600 380 L600 766 L490 726 L482 478 L500 352 L556 336 Z' fill='#283544' />
|
|
91
|
+
<path d='M600 380 L522 346 L530 434 L600 476 Z' fill='#3d5062' />
|
|
92
|
+
<path d='M600 380 L678 346 L670 434 L600 476 Z' fill='#22303c' />
|
|
93
|
+
<rect x='592' y='476' width='16' height='252' fill='#1d2833' opacity='0.5' />
|
|
94
|
+
<rect x='512' y='608' width='72' height='14' rx='4' fill='#1d2833' opacity='0.45' />
|
|
95
|
+
<rect x='616' y='608' width='72' height='14' rx='4' fill='#1d2833' opacity='0.45' />
|
|
96
|
+
<circle cx='600' cy='566' r='7' fill='#c9b79a' />
|
|
97
|
+
<circle cx='600' cy='668' r='7' fill='#c9b79a' />
|
|
98
|
+
</g>`,
|
|
99
|
+
|
|
100
|
+
'solis-dress': () => `
|
|
101
|
+
${shadow(600, 950, 235, 24, 0.18)}
|
|
102
|
+
<g>
|
|
103
|
+
<path d="M540 290 L600 274 L660 290 L636 366 L664 520 L700 900 Q600 940 500 900 L536 520 L564 366 Z" fill="#b9583f" />
|
|
104
|
+
<path d="M600 274 L600 910" stroke="#a0462f" stroke-width="4" opacity="0.5" />
|
|
105
|
+
<path d="M540 290 L600 274 L600 300 L560 340 L548 366 Z" fill="#8f3a26" opacity="0.55" />
|
|
106
|
+
<path d="M660 290 L600 274 L600 300 L640 340 L652 366 Z" fill="#d1725a" opacity="0.5" />
|
|
107
|
+
<path d="M552 560 Q600 600 648 560" stroke="#f0d9cf" stroke-width="9" fill="none" opacity="0.55" />
|
|
108
|
+
<path d="M536 700 Q600 742 664 700" stroke="#f0d9cf" stroke-width="9" fill="none" opacity="0.4" />
|
|
109
|
+
</g>`,
|
|
110
|
+
|
|
111
|
+
'helios-lamp': () => `
|
|
112
|
+
${shadow(600, 946, 220, 22, 0.22)}
|
|
113
|
+
<g>
|
|
114
|
+
<path d="M470 380 Q600 300 730 380 L700 620 Q600 652 500 620 Z" fill="#e8c98f" />
|
|
115
|
+
<path d="M470 380 Q600 300 730 380 L700 620 Q600 652 500 620 Z" fill="url(#lampShade)" opacity="0.9" />
|
|
116
|
+
<defs>
|
|
117
|
+
<linearGradient id="lampShade" x1="0" x2="1">
|
|
118
|
+
<stop offset="0%" stop-color="#ffffff" stop-opacity="0.5" />
|
|
119
|
+
<stop offset="55%" stop-color="#ffffff" stop-opacity="0" />
|
|
120
|
+
<stop offset="100%" stop-color="#8a5f1f" stop-opacity="0.35" />
|
|
121
|
+
</linearGradient>
|
|
122
|
+
</defs>
|
|
123
|
+
<rect x="588" y="620" width="24" height="270" fill="#b98a3c" />
|
|
124
|
+
<path d="M520 930 Q520 890 600 890 Q680 890 680 930 Z" fill="#a87a30" />
|
|
125
|
+
<rect x="500" y="600" width="200" height="16" rx="8" fill="#c79b4a" />
|
|
126
|
+
<ellipse cx="600" cy="640" rx="60" ry="14" fill="#f6e3ba" opacity="0.55" filter="url(#blur8)" />
|
|
127
|
+
</g>`,
|
|
128
|
+
|
|
129
|
+
'luna-bag': () => `
|
|
130
|
+
${shadow(600, 900, 215, 24, 0.2)}
|
|
131
|
+
<g>
|
|
132
|
+
<path d="M420 560 Q420 500 480 500 L720 500 Q780 500 780 560 L768 840 Q764 884 720 884 L480 884 Q436 884 432 840 Z" fill="#a9703c" />
|
|
133
|
+
<path d="M492 500 Q492 360 600 360 Q708 360 708 500" stroke="#8d5a2c" stroke-width="26" fill="none" />
|
|
134
|
+
<path d="M420 560 Q420 500 480 500 L720 500 Q780 500 780 560 L772 620 Q600 660 428 620 Z" fill="#bd8148" opacity="0.85" />
|
|
135
|
+
<rect x="560" y="700" width="80" height="46" rx="10" fill="#d8a868" />
|
|
136
|
+
<rect x="590" y="718" width="20" height="14" rx="4" fill="#8d5a2c" />
|
|
137
|
+
<path d="M432 700 L768 700" stroke="#8d5a2c" stroke-width="5" opacity="0.35" />
|
|
138
|
+
</g>`,
|
|
139
|
+
|
|
140
|
+
'atlas-sofa': () => `
|
|
141
|
+
${shadow(600, 900, 330, 30, 0.24)}
|
|
142
|
+
<g>
|
|
143
|
+
<path d="M320 640 Q320 560 400 560 L800 560 Q880 560 880 640 L880 838 L320 838 Z" fill="#7d8b73" />
|
|
144
|
+
<path d="M320 640 Q320 560 400 560 L420 560 L420 838 L320 838 Z" fill="#6b7962" />
|
|
145
|
+
<path d="M780 560 L800 560 Q880 560 880 640 L880 838 L780 838 Z" fill="#6b7962" />
|
|
146
|
+
<path d="M440 570 L560 570 L560 700 L440 700 Z" fill="#8fa085" />
|
|
147
|
+
<path d="M640 570 L760 570 L760 700 L640 700 Z" fill="#8fa085" />
|
|
148
|
+
<path d="M520 600 L560 600 L560 700 L520 700 Z" fill="#a4b39a" />
|
|
149
|
+
<circle cx="676" cy="628" r="40" fill="#c8a883" opacity="0.9" />
|
|
150
|
+
<path d="M320 838 L320 884 M880 838 L880 884 M420 838 L420 884 M780 838 L780 884" stroke="#4b543f" stroke-width="14" />
|
|
151
|
+
</g>`,
|
|
152
|
+
|
|
153
|
+
'marble-coffee-table': () => `
|
|
154
|
+
${shadow(600, 880, 300, 28, 0.24)}
|
|
155
|
+
<g>
|
|
156
|
+
<ellipse cx="600" cy="640" rx="300" ry="72" fill="#e7e3dd" />
|
|
157
|
+
<path d="M300 640 Q600 712 900 640 L890 700 Q600 776 310 700 Z" fill="#cfc9c0" />
|
|
158
|
+
<ellipse cx="600" cy="640" rx="300" ry="72" fill="none" stroke="#b8b1a6" stroke-width="3" />
|
|
159
|
+
<path d="M420 652 Q520 610 620 664 Q700 700 790 660" stroke="#a49b8d" stroke-width="4" fill="none" opacity="0.8" />
|
|
160
|
+
<path d="M470 690 Q560 656 660 692" stroke="#a49b8d" stroke-width="3" fill="none" opacity="0.55" />
|
|
161
|
+
<path d="M420 712 L432 880 L468 880 L468 712" fill="#8d7f6b" />
|
|
162
|
+
<path d="M780 712 L768 880 L732 880 L732 712" fill="#8d7f6b" />
|
|
163
|
+
</g>`,
|
|
164
|
+
|
|
165
|
+
'oak-dining-table': () => `
|
|
166
|
+
${shadow(600, 910, 330, 30, 0.24)}
|
|
167
|
+
<g>
|
|
168
|
+
<path d="M240 560 L960 560 L960 620 L240 620 Z" fill="#bd8f57" />
|
|
169
|
+
<path d="M240 620 L960 620 L950 648 L250 648 Z" fill="#a37a45" />
|
|
170
|
+
<path d="M270 648 L330 648 L318 900 L258 900 Z" fill="#a37a45" />
|
|
171
|
+
<path d="M870 648 L930 648 L942 900 L882 900 Z" fill="#a37a45" />
|
|
172
|
+
<path d="M300 572 L900 572" stroke="#d7af7c" stroke-width="6" opacity="0.7" />
|
|
173
|
+
<path d="M420 572 L420 604 M600 572 L600 604 M780 572 L780 604" stroke="#8a6335" stroke-width="4" opacity="0.5" />
|
|
174
|
+
<rect x="560" y="470" width="90" height="90" rx="8" fill="#e8e2d6" />
|
|
175
|
+
<path d="M560 470 h90 v20 h-90 z" fill="#f4efe6" />
|
|
176
|
+
</g>`,
|
|
177
|
+
|
|
178
|
+
'linen-armchair': () => `
|
|
179
|
+
${shadow(600, 906, 250, 26, 0.22)}
|
|
180
|
+
<g>
|
|
181
|
+
<path d="M420 640 Q420 330 600 330 Q780 330 780 640 Z" fill="#cdbfa6" />
|
|
182
|
+
<path d="M420 640 Q420 330 600 330 L600 640 Z" fill="#dbcfb8" />
|
|
183
|
+
<path d="M400 640 L800 640 L800 760 Q800 800 760 800 L440 800 Q400 800 400 760 Z" fill="#c2b39a" />
|
|
184
|
+
<path d="M420 560 Q420 700 440 790" stroke="#b0a188" stroke-width="18" fill="none" />
|
|
185
|
+
<path d="M780 560 Q780 700 760 790" stroke="#b0a188" stroke-width="18" fill="none" />
|
|
186
|
+
<path d="M456 802 L456 880 M744 802 L744 880" stroke="#7b6b52" stroke-width="16" />
|
|
187
|
+
<path d="M500 700 L700 700" stroke="#b0a188" stroke-width="4" opacity="0.6" />
|
|
188
|
+
</g>`,
|
|
189
|
+
|
|
190
|
+
'ceramic-table-lamp': () => `
|
|
191
|
+
${shadow(600, 952, 200, 20, 0.2)}
|
|
192
|
+
<g>
|
|
193
|
+
<path d="M436 452 Q600 372 764 452 L736 620 Q600 660 464 620 Z" fill="#f4efe4" />
|
|
194
|
+
<path d="M436 452 Q600 372 764 452 L736 620 Q600 660 464 620 Z" fill="url(#cl)" opacity="0.9" />
|
|
195
|
+
<defs>
|
|
196
|
+
<linearGradient id="cl" x1="0" x2="1">
|
|
197
|
+
<stop offset="0%" stop-color="#ffffff" stop-opacity="0.65" />
|
|
198
|
+
<stop offset="100%" stop-color="#8d8471" stop-opacity="0.3" />
|
|
199
|
+
</linearGradient>
|
|
200
|
+
</defs>
|
|
201
|
+
<rect x="590" y="620" width="20" height="70" fill="#a89a80" />
|
|
202
|
+
<path d="M600 660 Q520 690 512 790 Q506 906 600 926 Q694 906 688 790 Q680 690 600 660 Z" fill="#cfc2a8" />
|
|
203
|
+
<path d="M600 660 Q556 690 552 790 Q548 880 600 920 Z" fill="#ddd2ba" opacity="0.7" />
|
|
204
|
+
<path d="M560 760 Q600 726 646 764" stroke="#e8ded0" stroke-width="9" fill="none" opacity="0.75" />
|
|
205
|
+
<ellipse cx="600" cy="668" rx="56" ry="12" fill="#fbf3df" opacity="0.55" filter="url(#blur8)" />
|
|
206
|
+
</g>`,
|
|
207
|
+
|
|
208
|
+
'wool-rug': () => `
|
|
209
|
+
${shadow(600, 900, 300, 26, 0.16)}
|
|
210
|
+
<g>
|
|
211
|
+
<rect x="300" y="330" width="600" height="560" rx="6" fill="#d9c9a8" />
|
|
212
|
+
<rect x="336" y="364" width="528" height="492" rx="4" fill="none" stroke="#b9a179" stroke-width="18" />
|
|
213
|
+
<rect x="378" y="404" width="444" height="412" rx="2" fill="none" stroke="#c8b592" stroke-width="6" />
|
|
214
|
+
<path d="M420 404 L420 816 M510 404 L510 816 M600 404 L600 816 M690 404 L690 816 M780 404 L780 816" stroke="#cbb894" stroke-width="10" opacity="0.6" />
|
|
215
|
+
<path d="M300 348 L300 872 M318 348 L318 872 M882 348 L882 872 M900 348 L900 872" stroke="#c2ad86" stroke-width="5" opacity="0.85" />
|
|
216
|
+
</g>`,
|
|
217
|
+
|
|
218
|
+
'wall-mirror': () => `
|
|
219
|
+
${shadow(600, 930, 210, 22, 0.2)}
|
|
220
|
+
<g>
|
|
221
|
+
<path d="M470 900 L470 470 Q470 250 600 250 Q730 250 730 470 L730 900 Z" fill="#b9955f" />
|
|
222
|
+
<path d="M498 884 L498 480 Q498 282 600 282 Q702 282 702 480 L702 884 Z" fill="#d9e2e0" />
|
|
223
|
+
<path d="M498 884 L498 480 Q498 282 600 282 L600 884 Z" fill="#cfd8d6" />
|
|
224
|
+
<path d="M520 830 L560 420 L596 300 L640 470" stroke="#ffffff" stroke-width="16" fill="none" opacity="0.45" />
|
|
225
|
+
<path d="M640 620 L680 840" stroke="#ffffff" stroke-width="10" fill="none" opacity="0.25" />
|
|
226
|
+
</g>`,
|
|
227
|
+
|
|
228
|
+
'storage-shelf': () => `
|
|
229
|
+
${shadow(600, 930, 290, 24, 0.2)}
|
|
230
|
+
<g>
|
|
231
|
+
<rect x="340" y="290" width="520" height="640" fill="#c8a977" />
|
|
232
|
+
<rect x="360" y="310" width="480" height="600" fill="#e9dfca" />
|
|
233
|
+
<rect x="360" y="460" width="480" height="18" fill="#b8945f" />
|
|
234
|
+
<rect x="360" y="640" width="480" height="18" fill="#b8945f" />
|
|
235
|
+
<rect x="390" y="360" width="34" height="100" fill="#8b5f4a" />
|
|
236
|
+
<rect x="430" y="380" width="34" height="80" fill="#5f6f7a" />
|
|
237
|
+
<rect x="470" y="352" width="34" height="108" fill="#a8863f" />
|
|
238
|
+
<rect x="620" y="500" width="180" height="120" rx="8" fill="#cfc2a4" />
|
|
239
|
+
<circle cx="800" cy="580" r="46" fill="#93a08c" />
|
|
240
|
+
<rect x="400" y="690" width="120" height="200" rx="6" fill="#d7cdb6" />
|
|
241
|
+
<rect x="560" y="720" width="150" height="170" rx="6" fill="#b9ac92" />
|
|
242
|
+
</g>`,
|
|
243
|
+
|
|
244
|
+
'side-table': () => `
|
|
245
|
+
${shadow(600, 880, 210, 22, 0.2)}
|
|
246
|
+
<g>
|
|
247
|
+
<ellipse cx="600" cy="560" rx="200" ry="52" fill="#caa06a" />
|
|
248
|
+
<path d="M400 560 Q600 612 800 560 L790 596 Q600 658 410 596 Z" fill="#ab8049" />
|
|
249
|
+
<rect x="588" y="600" width="24" height="270" fill="#ab8049" />
|
|
250
|
+
<path d="M470 890 Q470 850 600 850 Q730 850 730 890 Z" fill="#ab8049" />
|
|
251
|
+
<circle cx="600" cy="540" r="26" fill="#e8dfcd" />
|
|
252
|
+
</g>`,
|
|
253
|
+
|
|
254
|
+
'floor-cushion': () => `
|
|
255
|
+
${shadow(600, 928, 240, 22, 0.22)}
|
|
256
|
+
<g>
|
|
257
|
+
<path d="M330 360 Q330 300 390 300 L810 300 Q870 300 870 360 L870 830 Q870 890 810 890 L390 890 Q330 890 330 830 Z" fill="#c9a24a" />
|
|
258
|
+
<path d="M330 360 Q330 300 390 300 L810 300 Q870 300 870 360 L870 404 Q600 446 330 404 Z" fill="#dcb45e" />
|
|
259
|
+
<path d="M330 404 Q600 446 870 404 L870 830 Q870 890 810 890 L390 890 Q330 890 330 830 Z" fill="#bb9440" />
|
|
260
|
+
<path d="M330 404 Q600 446 870 404" stroke="#a8832f" stroke-width="8" fill="none" opacity="0.55" />
|
|
261
|
+
<path d="M344 818 Q600 858 856 818" stroke="#a8832f" stroke-width="8" fill="none" opacity="0.3" />
|
|
262
|
+
<circle cx="600" cy="594" r="16" fill="#8f6f26" />
|
|
263
|
+
<circle cx="376" cy="330" r="10" fill="#8f6f26" opacity="0.7" />
|
|
264
|
+
<circle cx="824" cy="330" r="10" fill="#8f6f26" opacity="0.7" />
|
|
265
|
+
<path d="M600 610 L600 856" stroke="#a8832f" stroke-width="4" opacity="0.3" />
|
|
266
|
+
</g>`,
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
// ---------------------------------------------------------------------------
|
|
270
|
+
// Category tiles — an abstract crop of the family's colour and shape
|
|
271
|
+
// ---------------------------------------------------------------------------
|
|
272
|
+
|
|
273
|
+
const categories = {
|
|
274
|
+
jackets: () =>
|
|
275
|
+
products['aurora-jacket']() + `<rect width="1200" height="1200" fill="rgba(255,255,255,0.02)" />`,
|
|
276
|
+
dresses: () => products['solis-dress'](),
|
|
277
|
+
home: () => products['atlas-sofa'](),
|
|
278
|
+
accessories: () => products['luna-bag'](),
|
|
279
|
+
furniture: () => products['oak-dining-table'](),
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
// ---------------------------------------------------------------------------
|
|
283
|
+
// Banner scenes — 1800x1000 interiors, kept soft so the banner copy stays legible
|
|
284
|
+
// ---------------------------------------------------------------------------
|
|
285
|
+
|
|
286
|
+
const scene = (w, h, body, tint) => `<svg xmlns="http://www.w3.org/2000/svg" width="${w}" height="${h}" viewBox="0 0 1800 1000">
|
|
287
|
+
<defs>
|
|
288
|
+
<linearGradient id="wall" x1="0" y1="0" x2="0" y2="1">
|
|
289
|
+
<stop offset="0%" stop-color="${tint[0]}" />
|
|
290
|
+
<stop offset="100%" stop-color="${tint[1]}" />
|
|
291
|
+
</linearGradient>
|
|
292
|
+
<linearGradient id="floor" x1="0" y1="0" x2="0" y2="1">
|
|
293
|
+
<stop offset="0%" stop-color="${tint[2]}" />
|
|
294
|
+
<stop offset="100%" stop-color="${tint[3]}" />
|
|
295
|
+
</linearGradient>
|
|
296
|
+
<filter id="sgrain">
|
|
297
|
+
<feTurbulence type="fractalNoise" baseFrequency="0.8" numOctaves="3" stitchTiles="stitch" />
|
|
298
|
+
<feColorMatrix type="saturate" values="0" />
|
|
299
|
+
<feComponentTransfer><feFuncA type="linear" slope="0.06" /></feComponentTransfer>
|
|
300
|
+
</filter>
|
|
301
|
+
<filter id="ssoft" x="-30%" y="-30%" width="160%" height="160%"><feGaussianBlur stdDeviation="26" /></filter>
|
|
302
|
+
</defs>
|
|
303
|
+
<rect width="${w}" height="${h}" fill="url(#wall)" />
|
|
304
|
+
<rect y="${Math.round(h * 0.72)}" width="${w}" height="${Math.round(h * 0.28)}" fill="url(#floor)" />
|
|
305
|
+
${body}
|
|
306
|
+
<rect width="${w}" height="${h}" filter="url(#sgrain)" opacity="0.55" />
|
|
307
|
+
</svg>`
|
|
308
|
+
|
|
309
|
+
const banners = {
|
|
310
|
+
'banner-salon-oferta': () =>
|
|
311
|
+
scene(1800, 1000, `
|
|
312
|
+
<ellipse cx="820" cy="880" rx="440" ry="46" fill="rgba(60,45,35,0.22)" filter="url(#ssoft)" />
|
|
313
|
+
<rect x="330" y="470" width="900" height="330" rx="26" fill="#7f8b74" />
|
|
314
|
+
<rect x="360" y="500" width="380" height="150" rx="16" fill="#8f9b84" />
|
|
315
|
+
<rect x="780" y="500" width="380" height="150" rx="16" fill="#8f9b84" />
|
|
316
|
+
<rect x="330" y="640" width="900" height="120" rx="18" fill="#6f7b66" />
|
|
317
|
+
<rect x="1240" y="430" width="26" height="380" fill="#b28a52" />
|
|
318
|
+
<path d="M1180 430 L1266 400 L1340 430 L1300 620 L1210 600 Z" fill="#efe2c6" />
|
|
319
|
+
<circle cx="1250" cy="760" r="60" fill="#a8452f" />
|
|
320
|
+
<rect x="1246" y="700" width="8" height="120" fill="#6b4b2c" />
|
|
321
|
+
<path d="M1440 880 Q1440 660 1500 600 L1560 620 Q1480 720 1480 880 Z" fill="#5e6f52" opacity="0.85" />
|
|
322
|
+
<ellipse cx="1500" cy="880" rx="120" ry="26" fill="rgba(60,45,35,0.18)" />
|
|
323
|
+
<rect x="470" y="250" width="300" height="200" rx="10" fill="#e6dccb" />
|
|
324
|
+
<rect x="500" y="280" width="240" height="140" rx="6" fill="#c3a98a" />`, ['#f3ece0', '#e6dbc9', '#cbb79c', '#b9a488']),
|
|
325
|
+
|
|
326
|
+
'banner-aurora-deal': () =>
|
|
327
|
+
scene(1800, 1000, `
|
|
328
|
+
<ellipse cx="900" cy="900" rx="520" ry="50" fill="rgba(50,40,45,0.2)" filter="url(#ssoft)" />
|
|
329
|
+
<rect x="360" y="520" width="1080" height="330" rx="24" fill="#e9dfe2" />
|
|
330
|
+
<rect x="360" y="520" width="1080" height="120" rx="24" fill="#f6eef0" />
|
|
331
|
+
<rect x="470" y="500" width="330" height="110" rx="24" fill="#ffffff" />
|
|
332
|
+
<rect x="830" y="500" width="330" height="110" rx="24" fill="#ffffff" />
|
|
333
|
+
<rect x="360" y="640" width="1080" height="120" rx="12" fill="#cdbfc4" />
|
|
334
|
+
<rect x="300" y="760" width="60" height="120" fill="#b99b8f" />
|
|
335
|
+
<rect x="1440" y="760" width="60" height="120" fill="#b99b8f" />
|
|
336
|
+
<rect x="1500" y="380" width="34" height="420" fill="#b28a52" />
|
|
337
|
+
<path d="M1430 380 L1516 350 L1590 380 L1550 520 L1466 500 Z" fill="#f2e4cf" />
|
|
338
|
+
<path d="M150 0 L150 1000 M320 0 L320 1000" stroke="rgba(255,255,255,0.35)" stroke-width="4" />
|
|
339
|
+
<rect x="100" y="0" width="300" height="1000" fill="rgba(255,255,255,0.16)" />`, ['#f0e4e6', '#ddcdd2', '#c3b0b5', '#ac979d']),
|
|
340
|
+
|
|
341
|
+
'banner-nuevas-llegadas': () =>
|
|
342
|
+
scene(1800, 1000, `
|
|
343
|
+
<ellipse cx="900" cy="920" rx="560" ry="44" fill="rgba(55,48,40,0.18)" filter="url(#ssoft)" />
|
|
344
|
+
<rect x="220" y="330" width="1360" height="26" rx="13" fill="#9a8b74" />
|
|
345
|
+
<rect x="240" y="356" width="20" height="560" fill="#9a8b74" />
|
|
346
|
+
<rect x="1540" y="356" width="20" height="560" fill="#9a8b74" />
|
|
347
|
+
${[
|
|
348
|
+
{ x: 330, c: '#3f5165', w: 190 },
|
|
349
|
+
{ x: 560, c: '#b4583f', w: 180 },
|
|
350
|
+
{ x: 780, c: '#77705f', w: 200 },
|
|
351
|
+
{ x: 1020, c: '#c9a24a', w: 170 },
|
|
352
|
+
{ x: 1230, c: '#5f7a6a', w: 200 },
|
|
353
|
+
]
|
|
354
|
+
.map(
|
|
355
|
+
(g) => `<path d="M${g.x} 356 h${g.w} l-10 420 q-${g.w / 2} 26 -${g.w - 20} 0 Z" fill="${g.c}" />
|
|
356
|
+
<path d="M${g.x + g.w / 2} 366 v400" stroke="rgba(0,0,0,0.12)" stroke-width="4" />`,
|
|
357
|
+
)
|
|
358
|
+
.join('\n')}
|
|
359
|
+
<rect x="1460" y="600" width="180" height="260" rx="10" fill="#e4d8c2" opacity="0.9" />`, ['#f2ece2', '#e4dbcd', '#cfc3ae', '#bdae96']),
|
|
360
|
+
|
|
361
|
+
'banner-guia-regalo': () =>
|
|
362
|
+
scene(1800, 1000, `
|
|
363
|
+
<ellipse cx="900" cy="900" rx="470" ry="48" fill="rgba(60,45,40,0.2)" filter="url(#ssoft)" />
|
|
364
|
+
<rect x="620" y="600" width="320" height="280" rx="10" fill="#f0e6d6" />
|
|
365
|
+
<path d="M620 690 h320 M780 600 v280" stroke="#b8452f" stroke-width="24" />
|
|
366
|
+
<path d="M700 600 q80 -90 80 0 q0 -90 80 0" stroke="#b8452f" stroke-width="20" fill="none" />
|
|
367
|
+
<rect x="980" y="700" width="240" height="180" rx="10" fill="#dcd0bb" />
|
|
368
|
+
<path d="M980 780 h240 M1100 700 v180" stroke="#7d8b74" stroke-width="18" />
|
|
369
|
+
<rect x="460" y="740" width="170" height="140" rx="8" fill="#cbb79c" />
|
|
370
|
+
<path d="M460 810 h170 M545 740 v140" stroke="#8a6a4a" stroke-width="14" />
|
|
371
|
+
<circle cx="1290" cy="640" r="52" fill="#a8452f" opacity="0.85" />
|
|
372
|
+
<rect x="1286" y="590" width="8" height="100" fill="#6b4b2c" />
|
|
373
|
+
<path d="M300 880 Q300 700 360 640" stroke="#5e6f52" stroke-width="14" fill="none" />
|
|
374
|
+
<ellipse cx="360" cy="636" rx="46" ry="26" fill="#6f8460" />`, ['#f7efe2', '#e9dcc6', '#d5c4a6', '#c2ae8c']),
|
|
375
|
+
|
|
376
|
+
'banner-mesa-decor': () =>
|
|
377
|
+
scene(1800, 1000, `
|
|
378
|
+
<rect x="0" y="240" width="1800" height="640" fill="#d8c6a8" />
|
|
379
|
+
<rect x="0" y="240" width="1800" height="24" fill="rgba(255,255,255,0.35)" />
|
|
380
|
+
<ellipse cx="540" cy="560" rx="200" ry="200" fill="#f4efe6" />
|
|
381
|
+
<ellipse cx="540" cy="560" rx="130" ry="130" fill="#e3dccd" />
|
|
382
|
+
<ellipse cx="540" cy="560" rx="70" ry="70" fill="#cbb79c" />
|
|
383
|
+
<ellipse cx="1240" cy="600" rx="170" ry="170" fill="#f4efe6" />
|
|
384
|
+
<ellipse cx="1240" cy="600" rx="100" ry="100" fill="#dcd0bb" />
|
|
385
|
+
<rect x="1206" y="470" width="26" height="150" fill="#a9b6a2" rx="10" />
|
|
386
|
+
<path d="M890 380 q60 90 0 190 q-60 -100 0 -190" fill="#7d8b74" />
|
|
387
|
+
<rect x="880" y="560" width="24" height="120" fill="#9aa694" />
|
|
388
|
+
<rect x="200" y="620" width="120" height="220" rx="8" fill="#e6dbc9" opacity="0.85" />
|
|
389
|
+
<path d="M760 300 l60 60 l-60 60 l-60 -60 z" fill="#cbb79c" opacity="0.8" />`, ['#efe6d6', '#e0d3bd', '#cbb79c', '#b3a084']),
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
// The editorial slot is a single quiet corner of the same studio. The benefits
|
|
393
|
+
// section renders editorial imagery in grayscale, so composition and light
|
|
394
|
+
// matter here, not hue.
|
|
395
|
+
const editorial = {
|
|
396
|
+
studio: () =>
|
|
397
|
+
scene(1600, 1200, `
|
|
398
|
+
<ellipse cx="800" cy="1010" rx="470" ry="50" fill="rgba(50,42,34,0.2)" filter="url(#ssoft)" />
|
|
399
|
+
<rect x="470" y="470" width="360" height="520" rx="30" fill="#cdbfa6" />
|
|
400
|
+
<rect x="500" y="640" width="300" height="90" rx="18" fill="#dccfb8" />
|
|
401
|
+
<rect x="500" y="760" width="300" height="210" rx="18" fill="#c3b49a" />
|
|
402
|
+
<rect x="820" y="600" width="120" height="380" rx="14" fill="#b09472" />
|
|
403
|
+
<ellipse cx="880" cy="600" rx="110" ry="34" fill="#c8b49a" />
|
|
404
|
+
<rect x="1060" y="330" width="300" height="380" rx="8" fill="#efe9df" />
|
|
405
|
+
<rect x="1084" y="354" width="252" height="332" rx="4" fill="#b9aa93" />
|
|
406
|
+
<rect x="120" y="520" width="180" height="440" rx="8" fill="#d9cdb8" />
|
|
407
|
+
<path d="M210 480 q-90 90 -40 200 q70 -30 80 -140 z" fill="#8b9a7d" opacity="0.9" />
|
|
408
|
+
<path d="M210 480 q90 80 50 190 q-80 -30 -80 -140 z" fill="#7b8a6d" opacity="0.9" />`, ['#f4efe6', '#e7ddcd', '#cfc2a8', '#b8a88e']),
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
// ---------------------------------------------------------------------------
|
|
412
|
+
// Render
|
|
413
|
+
// ---------------------------------------------------------------------------
|
|
414
|
+
|
|
415
|
+
const exists = async (p) => {
|
|
416
|
+
try {
|
|
417
|
+
await access(p)
|
|
418
|
+
return true
|
|
419
|
+
} catch {
|
|
420
|
+
return false
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
// The mock catalog is not only the fourteen fixture heroes: it also generates a
|
|
425
|
+
// per-category pool (eleven jackets, nine dresses, eight lamps, seven bags) from
|
|
426
|
+
// the adapter's blueprints, and every one of those handles resolves an image
|
|
427
|
+
// through the asset base. They are drawn from the category's hero silhouette,
|
|
428
|
+
// rotated by hue, so a generated product reads as a sibling of the hero instead
|
|
429
|
+
// of a broken tile.
|
|
430
|
+
const GENERATED_PRODUCTS = [
|
|
431
|
+
{
|
|
432
|
+
noun: 'jacket',
|
|
433
|
+
draw: products['aurora-jacket'],
|
|
434
|
+
names: ['Alpine', 'Boreal', 'Cinder', 'Drift', 'Ember', 'Fjord', 'Harbor', 'Meridian', 'Nomad', 'Tundra', 'Vantage'],
|
|
435
|
+
},
|
|
436
|
+
{
|
|
437
|
+
noun: 'dress',
|
|
438
|
+
draw: products['solis-dress'],
|
|
439
|
+
names: ['Amber', 'Camille', 'Dahlia', 'Elara', 'Iris', 'Lumen', 'Nova', 'Rosalind', 'Vera'],
|
|
440
|
+
},
|
|
441
|
+
{
|
|
442
|
+
noun: 'lamp',
|
|
443
|
+
draw: products['helios-lamp'],
|
|
444
|
+
names: ['Atlas', 'Copper', 'Dune', 'Onyx', 'Quill', 'Slate', 'Terra', 'Verdant'],
|
|
445
|
+
},
|
|
446
|
+
{
|
|
447
|
+
noun: 'bag',
|
|
448
|
+
draw: products['luna-bag'],
|
|
449
|
+
names: ['Cove', 'Fable', 'Juniper', 'Kestrel', 'Marlowe', 'Piper', 'Rune'],
|
|
450
|
+
},
|
|
451
|
+
]
|
|
452
|
+
|
|
453
|
+
/** Recolours a product drawing while leaving the studio ground untouched. */
|
|
454
|
+
const recolor = (body, degrees) =>
|
|
455
|
+
`<defs><filter id="hue"><feColorMatrix type="hueRotate" values="${degrees}"/></filter></defs>` +
|
|
456
|
+
`<g filter="url(#hue)">${body}</g>`
|
|
457
|
+
|
|
458
|
+
const generatedProductJobs = GENERATED_PRODUCTS.flatMap(({ noun, draw, names }) =>
|
|
459
|
+
names.map((name, index) => ({
|
|
460
|
+
rel: path.join('products', `${name.toLowerCase()}-${noun}.webp`),
|
|
461
|
+
svg: svg(1200, 1200, recolor(draw(), (index * 47 + noun.length * 23) % 360)),
|
|
462
|
+
width: 1200,
|
|
463
|
+
})),
|
|
464
|
+
)
|
|
465
|
+
|
|
466
|
+
const jobs = [
|
|
467
|
+
...generatedProductJobs,
|
|
468
|
+
...Object.entries(products).map(([name, draw]) => ({
|
|
469
|
+
rel: path.join('products', `${name}.webp`),
|
|
470
|
+
svg: svg(1200, 1200, draw()),
|
|
471
|
+
width: 1200,
|
|
472
|
+
})),
|
|
473
|
+
...Object.entries(categories).map(([name, draw]) => ({
|
|
474
|
+
rel: path.join('categories', `${name}.webp`),
|
|
475
|
+
svg: svg(900, 900, draw()),
|
|
476
|
+
width: 900,
|
|
477
|
+
})),
|
|
478
|
+
...Object.entries(banners).map(([name, draw]) => ({
|
|
479
|
+
rel: path.join('banners', `${name}.webp`),
|
|
480
|
+
svg: draw(),
|
|
481
|
+
width: 1800,
|
|
482
|
+
})),
|
|
483
|
+
...Object.entries(editorial).map(([name, draw]) => ({
|
|
484
|
+
rel: path.join('editorial', `${name}.webp`),
|
|
485
|
+
svg: draw(),
|
|
486
|
+
width: 1600,
|
|
487
|
+
})),
|
|
488
|
+
]
|
|
489
|
+
|
|
490
|
+
let written = 0
|
|
491
|
+
for (const job of jobs) {
|
|
492
|
+
const dest = path.join(outDir, job.rel)
|
|
493
|
+
if (!force && (await exists(dest))) continue
|
|
494
|
+
await mkdir(path.dirname(dest), { recursive: true })
|
|
495
|
+
const flat = sharp(Buffer.from(job.svg), { density: 96 }).resize({ width: job.width, withoutEnlargement: false })
|
|
496
|
+
// Banner scenes carry the page's headline under a neutral scrim, so they get
|
|
497
|
+
// a contrast and saturation lift: the flat studio palette read as grey once
|
|
498
|
+
// the overlay sat on top of it.
|
|
499
|
+
const toned = job.rel.startsWith('banners')
|
|
500
|
+
? flat.modulate({ saturation: 1.35, brightness: 1.03 }).linear(1.12, -12)
|
|
501
|
+
: flat
|
|
502
|
+
const buf = await toned.webp({ quality: 82, effort: 5 }).toBuffer()
|
|
503
|
+
await writeFile(dest, buf)
|
|
504
|
+
written += 1
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
process.stdout.write(`demo images: ${written} written, ${jobs.length - written} kept (${path.relative(pkgRoot, outDir)})\n`)
|
package/scripts/reconcile.mjs
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { mkdir, readdir, readFile, rm, writeFile } from 'node:fs/promises'
|
|
1
|
+
import { copyFile, mkdir, readdir, readFile, rm, writeFile } from 'node:fs/promises'
|
|
2
2
|
import { existsSync } from 'node:fs'
|
|
3
3
|
import path from 'node:path'
|
|
4
4
|
import { fileURLToPath } from 'node:url'
|
|
5
5
|
import {
|
|
6
6
|
templatesRoot,
|
|
7
7
|
replacePlaceholders,
|
|
8
|
+
BINARY_ASSET_RE,
|
|
8
9
|
buildBarrel,
|
|
9
10
|
writeBarrel,
|
|
10
11
|
buildClientRegistryBarrel,
|
|
@@ -53,6 +54,12 @@ async function walkFiles(dir, base = dir, out = []) {
|
|
|
53
54
|
return out
|
|
54
55
|
}
|
|
55
56
|
|
|
57
|
+
// Demo imagery and other binary template assets never pass through placeholder
|
|
58
|
+
// substitution: reading a `.webp` as UTF-8 corrupts it, and the drift compare
|
|
59
|
+
// would then keep rewriting a perfectly good file. Binaries are copied verbatim
|
|
60
|
+
// and only when missing, so a developer who swaps in real photography (or
|
|
61
|
+
// deletes a shot) keeps that decision across `storefront sync`.
|
|
62
|
+
|
|
56
63
|
// Render a template tree into the project, writing every derived file but only
|
|
57
64
|
// seeding user-owned files that do not exist yet, so reconcile never clobbers a
|
|
58
65
|
// hand edit. `derivedOnly` skips every non-derived class for scoped callers.
|
|
@@ -68,6 +75,15 @@ async function renderDerivedTree(fromDir, toDir, subs, classifyRel, changed, ski
|
|
|
68
75
|
const fileClass = classifyRel(rel)
|
|
69
76
|
if (derivedOnly && fileClass !== 'derived') continue
|
|
70
77
|
if (fileClass === 'user-owned' && existsSync(dest)) continue
|
|
78
|
+
if (BINARY_ASSET_RE.test(rel)) {
|
|
79
|
+
if (existsSync(dest)) continue
|
|
80
|
+
if (!dryRun) {
|
|
81
|
+
await mkdir(path.dirname(dest), { recursive: true })
|
|
82
|
+
await copyFile(path.join(fromDir, rel), dest)
|
|
83
|
+
}
|
|
84
|
+
changed.push(dest)
|
|
85
|
+
continue
|
|
86
|
+
}
|
|
71
87
|
const raw = await readFile(path.join(fromDir, rel), 'utf8')
|
|
72
88
|
const next = replacePlaceholders(raw, subs)
|
|
73
89
|
const prev = existsSync(dest) ? await readFile(dest, 'utf8') : null
|
|
@@ -352,6 +368,21 @@ export async function reconcile(projectDir, manifest, { dryRun = false, derivedO
|
|
|
352
368
|
derivedOnly,
|
|
353
369
|
)
|
|
354
370
|
|
|
371
|
+
// Demo imagery ships with the store as local static assets under
|
|
372
|
+
// `public/images`, so a fresh mock storefront reads as a real shop without a
|
|
373
|
+
// network call. User-owned by the default class rule: seeded once, never
|
|
374
|
+
// overwritten, so replacing a shot is permanent.
|
|
375
|
+
await renderDerivedTree(
|
|
376
|
+
path.join(templatesRoot, 'app', 'public'),
|
|
377
|
+
path.join(projectDir, 'public'),
|
|
378
|
+
subs,
|
|
379
|
+
(rel) => classifyFile(path.posix.join('app/public', rel)),
|
|
380
|
+
changed,
|
|
381
|
+
undefined,
|
|
382
|
+
dryRun,
|
|
383
|
+
derivedOnly,
|
|
384
|
+
)
|
|
385
|
+
|
|
355
386
|
const featuresDir = path.join(projectDir, 'lib', name, 'features')
|
|
356
387
|
const featureNames = manifest.features.map((feature) => feature.name).sort()
|
|
357
388
|
if (!dryRun && (!derivedOnly || featureNames.length > 0 || existsSync(featuresDir))) {
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
//
|
|
7
7
|
// node scripts/render-templates.mjs <target-dir> [name]
|
|
8
8
|
|
|
9
|
-
import { mkdir, readdir, readFile, writeFile, rm } from 'node:fs/promises'
|
|
9
|
+
import { copyFile, mkdir, readdir, readFile, writeFile, rm } from 'node:fs/promises'
|
|
10
10
|
import { existsSync } from 'node:fs'
|
|
11
11
|
import path from 'node:path'
|
|
12
12
|
import { fileURLToPath } from 'node:url'
|
|
@@ -75,11 +75,20 @@ async function walk(root, dir, out, skip) {
|
|
|
75
75
|
return out
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
+
// Template assets copied byte-for-byte instead of rendered: a binary (demo
|
|
79
|
+
// imagery, fonts, icons) carries no placeholders, and a UTF-8 round trip
|
|
80
|
+
// corrupts it.
|
|
81
|
+
export const BINARY_ASSET_RE = /\.(webp|avif|png|jpe?g|gif|ico|woff2?|mp4)$/i
|
|
82
|
+
|
|
78
83
|
export async function renderTree(fromDir, toDir, subs, { skip } = {}) {
|
|
79
84
|
await mkdir(toDir, { recursive: true })
|
|
80
85
|
for (const { abs, rel } of await walk(fromDir, fromDir, [], skip)) {
|
|
81
86
|
const dest = path.join(toDir, rel).replaceAll('__STOREFRONT__', subs.name)
|
|
82
87
|
await mkdir(path.dirname(dest), { recursive: true })
|
|
88
|
+
if (BINARY_ASSET_RE.test(rel)) {
|
|
89
|
+
await copyFile(abs, dest)
|
|
90
|
+
continue
|
|
91
|
+
}
|
|
83
92
|
const raw = await readFile(abs, 'utf8')
|
|
84
93
|
await writeFile(dest, replacePlaceholders(raw, subs))
|
|
85
94
|
}
|
|
@@ -502,6 +511,9 @@ export async function renderScaffold({
|
|
|
502
511
|
|
|
503
512
|
await renderTree(path.join(templatesRoot, 'app', 'app', '[[...slug]]'), path.join(targetDir, 'app', '[[...slug]]'), { name, siteName, mode })
|
|
504
513
|
await renderTree(path.join(templatesRoot, 'app', 'lib'), path.join(targetDir, 'lib'), { name, siteName, mode })
|
|
514
|
+
// Demo imagery: local static assets, so the store looks like a shop without a
|
|
515
|
+
// network call. A developer replaces the files in place (see the folder README).
|
|
516
|
+
await renderTree(path.join(templatesRoot, 'app', 'public'), path.join(targetDir, 'public'), { name, siteName, mode })
|
|
505
517
|
for (const entry of viewEntries) {
|
|
506
518
|
const viewSrc = path.join(templatesRoot, 'views', entry.name)
|
|
507
519
|
if (!existsSync(viewSrc)) continue
|