@thorprovider/storefront 0.13.3 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. package/README.md +19 -8
  2. package/assets/templates/app/lib/__STOREFRONT__/mappers.ts +18 -3
  3. package/assets/templates/app/lib/__STOREFRONT__/views/sections/products.client.tsx +1 -0
  4. package/assets/templates/app/lib/__STOREFRONT__/views/sections/schema.products.ts +6 -0
  5. package/assets/templates/app/lib/__STOREFRONT__/views/sections/schema.universal-main-menu.ts +3 -1
  6. package/assets/templates/app/public/images/README.md +43 -0
  7. package/assets/templates/app/public/images/banners/banner-aurora-deal.webp +0 -0
  8. package/assets/templates/app/public/images/banners/banner-guia-regalo.webp +0 -0
  9. package/assets/templates/app/public/images/banners/banner-mesa-decor.webp +0 -0
  10. package/assets/templates/app/public/images/banners/banner-nuevas-llegadas.webp +0 -0
  11. package/assets/templates/app/public/images/banners/banner-salon-oferta.webp +0 -0
  12. package/assets/templates/app/public/images/categories/accessories.webp +0 -0
  13. package/assets/templates/app/public/images/categories/dresses.webp +0 -0
  14. package/assets/templates/app/public/images/categories/furniture.webp +0 -0
  15. package/assets/templates/app/public/images/categories/home.webp +0 -0
  16. package/assets/templates/app/public/images/categories/jackets.webp +0 -0
  17. package/assets/templates/app/public/images/editorial/studio.webp +0 -0
  18. package/assets/templates/app/public/images/products/alpine-jacket.webp +0 -0
  19. package/assets/templates/app/public/images/products/amber-dress.webp +0 -0
  20. package/assets/templates/app/public/images/products/atlas-lamp.webp +0 -0
  21. package/assets/templates/app/public/images/products/atlas-sofa.webp +0 -0
  22. package/assets/templates/app/public/images/products/aurora-jacket.webp +0 -0
  23. package/assets/templates/app/public/images/products/boreal-jacket.webp +0 -0
  24. package/assets/templates/app/public/images/products/camille-dress.webp +0 -0
  25. package/assets/templates/app/public/images/products/ceramic-table-lamp.webp +0 -0
  26. package/assets/templates/app/public/images/products/cinder-jacket.webp +0 -0
  27. package/assets/templates/app/public/images/products/copper-lamp.webp +0 -0
  28. package/assets/templates/app/public/images/products/cove-bag.webp +0 -0
  29. package/assets/templates/app/public/images/products/dahlia-dress.webp +0 -0
  30. package/assets/templates/app/public/images/products/drift-jacket.webp +0 -0
  31. package/assets/templates/app/public/images/products/dune-lamp.webp +0 -0
  32. package/assets/templates/app/public/images/products/elara-dress.webp +0 -0
  33. package/assets/templates/app/public/images/products/ember-jacket.webp +0 -0
  34. package/assets/templates/app/public/images/products/fable-bag.webp +0 -0
  35. package/assets/templates/app/public/images/products/fjord-jacket.webp +0 -0
  36. package/assets/templates/app/public/images/products/floor-cushion.webp +0 -0
  37. package/assets/templates/app/public/images/products/harbor-jacket.webp +0 -0
  38. package/assets/templates/app/public/images/products/helios-lamp.webp +0 -0
  39. package/assets/templates/app/public/images/products/iris-dress.webp +0 -0
  40. package/assets/templates/app/public/images/products/juniper-bag.webp +0 -0
  41. package/assets/templates/app/public/images/products/kestrel-bag.webp +0 -0
  42. package/assets/templates/app/public/images/products/linen-armchair.webp +0 -0
  43. package/assets/templates/app/public/images/products/lumen-dress.webp +0 -0
  44. package/assets/templates/app/public/images/products/luna-bag.webp +0 -0
  45. package/assets/templates/app/public/images/products/marble-coffee-table.webp +0 -0
  46. package/assets/templates/app/public/images/products/marlowe-bag.webp +0 -0
  47. package/assets/templates/app/public/images/products/meridian-jacket.webp +0 -0
  48. package/assets/templates/app/public/images/products/nomad-jacket.webp +0 -0
  49. package/assets/templates/app/public/images/products/nova-dress.webp +0 -0
  50. package/assets/templates/app/public/images/products/oak-dining-table.webp +0 -0
  51. package/assets/templates/app/public/images/products/onyx-lamp.webp +0 -0
  52. package/assets/templates/app/public/images/products/piper-bag.webp +0 -0
  53. package/assets/templates/app/public/images/products/quill-lamp.webp +0 -0
  54. package/assets/templates/app/public/images/products/rosalind-dress.webp +0 -0
  55. package/assets/templates/app/public/images/products/rune-bag.webp +0 -0
  56. package/assets/templates/app/public/images/products/side-table.webp +0 -0
  57. package/assets/templates/app/public/images/products/slate-lamp.webp +0 -0
  58. package/assets/templates/app/public/images/products/solis-dress.webp +0 -0
  59. package/assets/templates/app/public/images/products/storage-shelf.webp +0 -0
  60. package/assets/templates/app/public/images/products/terra-lamp.webp +0 -0
  61. package/assets/templates/app/public/images/products/tundra-jacket.webp +0 -0
  62. package/assets/templates/app/public/images/products/vantage-jacket.webp +0 -0
  63. package/assets/templates/app/public/images/products/vera-dress.webp +0 -0
  64. package/assets/templates/app/public/images/products/verdant-lamp.webp +0 -0
  65. package/assets/templates/app/public/images/products/wall-mirror.webp +0 -0
  66. package/assets/templates/app/public/images/products/wool-rug.webp +0 -0
  67. package/assets/templates/views/account/address-book-advanced.defaults.ts +1 -1
  68. package/assets/templates/views/home/assembly/assembly.json +1 -2
  69. package/assets/templates/views/home/assembly/index.skeleton.tsx +3 -7
  70. package/assets/templates/views/home/assembly/registry.skeleton.tsx +0 -3
  71. package/assets/templates/views/home/content.ts +80 -72
  72. package/assets/templates/views/home/data.ts +25 -3
  73. package/assets/templates/views/home/index.tsx +4 -21
  74. package/assets/templates/views/home/props.ts +1 -7
  75. package/assets/templates/views/home/registry.tsx +0 -35
  76. package/assets/templates/views/home/schema.ts +0 -36
  77. package/bin/storefront.js +12 -27
  78. package/package.json +3 -2
  79. package/recipes/archetypes.json +0 -21
  80. package/recipes/catalog.json +0 -22
  81. package/recipes/features.json +0 -2
  82. package/recipes/recipe.schema.json +5 -0
  83. package/recipes/recipes.json +32 -11
  84. package/recipes/validate.mjs +7 -0
  85. package/scripts/candidate.mjs +3 -3
  86. package/scripts/default-sections.mjs +1 -0
  87. package/scripts/env-file.mjs +5 -0
  88. package/scripts/file-classes.mjs +3 -0
  89. package/scripts/generate-demo-images.mjs +507 -0
  90. package/scripts/reconcile.mjs +32 -1
  91. package/scripts/render-templates.mjs +13 -1
  92. package/scripts/section-compat.mjs +10 -1
  93. package/scripts/section-operations.mjs +3 -0
  94. package/scripts/starter.mjs +25 -1
  95. package/scripts/theme/starter-theme.mjs +118 -0
  96. package/scripts/view-assembly.mjs +26 -5
  97. package/skills/sf-view-gen/assets/recipes/archetypes.json +0 -21
  98. package/skills/sf-view-gen/assets/recipes/catalog.json +0 -22
  99. package/skills/sf-view-gen/assets/recipes/features.json +0 -2
  100. package/skills/sf-view-gen/assets/recipes/recipes.json +32 -11
  101. package/skills/sf-view-gen/assets/templates/views/sections/products.client.tsx +53 -1
  102. package/skills/sf-view-gen/assets/templates/views/sections/schema.products.ts +6 -0
  103. package/skills/sf-view-gen/assets/templates/views/sections/schema.universal-main-menu.ts +3 -1
  104. package/skills/sf-view-gen/scripts/validate.mjs +7 -0
  105. package/assets/templates/views/home/assembly/slots/categories/CategoryGrid/binding.json +0 -5
  106. package/assets/templates/views/home/assembly/slots/categories/CategoryGrid/catalog.part +0 -8
  107. package/assets/templates/views/home/assembly/slots/categories/CategoryGrid/element.part +0 -5
  108. package/assets/templates/views/home/assembly/slots/categories/CategoryGrid/registry.part +0 -31
package/README.md CHANGED
@@ -110,9 +110,17 @@ storefront create my-shop \
110
110
  | `--site-name <name>` | human site name (`__SITE_NAME__`) | Title Case of `<name>` (`my-shop` → `My Shop`) |
111
111
  | `--preset <preset>` | visual preset: `maia`, `nova`, `vega`, `luma`, `lyra`, `mira` | prompted in the wizard (Maia preselected) |
112
112
  | `--starter` | seed the full curated composition — every curated view and feature — instead of the minimal `home`+`cart` baseline | off |
113
- | `--brand <color>` | named brand color (`orange`, `blue`, …) applied as a chromatic primary family (primary/foreground/ring/nav) over the preset tokens (never prompted) | none |
113
+ | `--brand <color>` | named brand color (`orange`, `blue`, …) applied as a chromatic primary family (primary/foreground/ring/nav) over the starter theme (never prompted) | none |
114
114
  | `--force`, `-f` | overwrite files that already exist | off |
115
115
 
116
+ Every scaffold ships a **marketplace starter theme** before any brand override:
117
+ an orange call-to-action with dark text on it, navy chrome, a grey page field with
118
+ white cards, and `0.25rem` corners — every color pair clears WCAG AA in both
119
+ modes. It is applied through the same theme plan as `storefront theme --set`
120
+ (`scripts/theme/starter-theme.mjs`), so a starter palette and a hand-applied one
121
+ cannot drift; `--brand` is applied last and still wins for the primary family. A
122
+ later `sync` never reverts a theme change.
123
+
116
124
  The pipeline runs: preconditions → Next.js base (files only) → `.yarnrc.yml`
117
125
  (`nodeLinker: node-modules`) → shadcn base with the preset → dependency install →
118
126
  template copy + placeholder substitution → mock `.env.local` + theme → suite install.
@@ -206,13 +214,16 @@ storefront feature add customer-addresses # refused when the backend lacks man
206
214
 
207
215
  A failed probe records no list (unknown), so capability-gated features stay
208
216
  uninstallable until `storefront setup` succeeds again. In **mock mode** there is no
209
- endpoint to probe, so `setup` records the mock provider's own flags: the modules the
210
- mock genuinely supports (profile updates, address book, order history) install, and the
211
- ones it refuses truthfully (email change, password change, saved payment methods) stay
212
- out. `storefront doctor` re-probes and reports an installed feature whose capability the
213
- backend no longer advertises. Features also declare `requires` (a module needs its host
214
- feature) and `adapter.needs` (callables checked against the adapter/commerce surface),
215
- and a held feature is inspectable with `storefront features --json` but never installable.
217
+ endpoint to probe, so both `create` and `setup` record the mock provider's own flags:
218
+ a freshly scaffolded store installs the modules the mock genuinely supports (profile
219
+ updates, address book, order history), and the ones it refuses truthfully (email
220
+ change, password change, saved payment methods) stay out. `create` writes that list
221
+ because it always leaves the store in mock mode; `setup` replaces it with the live
222
+ probe when a real backend is connected. `storefront doctor` re-probes and reports an
223
+ installed feature whose capability the backend no longer advertises. Features also
224
+ declare `requires` (a module needs its host feature) and `adapter.needs` (callables
225
+ checked against the adapter/commerce surface), and a held feature is inspectable with
226
+ `storefront features --json` but never installable.
216
227
 
217
228
  The guest flow is backend-authoritative end to end: the signed host cookie binds a
218
229
  persistent backend cart; the PDP adds the explicitly selected variant; the cart and
@@ -5,6 +5,21 @@
5
5
 
6
6
  import type { CardProduct, FeaturedProduct, ProductCategoryItem, StoreCategory } from '@thorprovider/blocks'
7
7
 
8
+ /** Base of the starter's local demo imagery (see `public/images/README.md`). */
9
+ const CATEGORY_IMAGE_BASE = '/images/categories'
10
+
11
+ /**
12
+ * Category shot for a `StoreCategory`. The category URL is `/categories/<handle>`
13
+ * and the starter ships one shot per handle, so the handle is the file name: a
14
+ * swapped photo needs no mapper change. The runtime projection carries no image,
15
+ * so the local asset is the source here; `CATEGORY_IMAGE_FALLBACK` covers a
16
+ * category without a shipped file (e.g. a real backend's own taxonomy).
17
+ */
18
+ export function categoryImage(href: string): string {
19
+ const handle = href.split('/').filter(Boolean).pop()
20
+ return handle ? `${CATEGORY_IMAGE_BASE}/${handle}.webp` : CATEGORY_IMAGE_FALLBACK
21
+ }
22
+
8
23
  export const CATEGORY_IMAGE_FALLBACK =
9
24
  "data:image/svg+xml;charset=utf-8," +
10
25
  encodeURIComponent(
@@ -38,15 +53,15 @@ export function toFeaturedProduct(card: CardProduct): FeaturedProduct {
38
53
  * carries no product count, so `itemCount` is unknown here: it is OMITTED (the
39
54
  * block then renders no count) rather than fabricated as `0`. A genuine `0`
40
55
  * supplied by a richer source is preserved because `itemCount` is optional.
41
- * `image` seeds the storefront's editorial category imagery — the brand overlay
42
- * rekeys it by backend handle; the block also supplies a neutral placeholder. */
56
+ * `image` is the shipped shot for the category's handle (see `categoryImage`),
57
+ * so a category tile never renders the neutral block placeholder by default. */
43
58
  export function toCategoryCard(category: StoreCategory): ProductCategoryItem {
44
59
  return {
45
60
  id: category.label,
46
61
  handle: category.href,
47
62
  name: category.label,
48
63
  description: '',
49
- image: CATEGORY_IMAGE_FALLBACK,
64
+ image: categoryImage(category.href),
50
65
  trending: false,
51
66
  }
52
67
  }
@@ -112,6 +112,7 @@ export const productsRegistry: ViewRegistry = {
112
112
  <div ref={containerRef}>
113
113
  {parsed.variant === 'ProductSlider' ? (
114
114
  <UniversalProductSlider
115
+ {...(parsed.sliderPreset ? { variant: parsed.sliderPreset } : {})}
115
116
  header={{
116
117
  title: parsed.heading ?? 'Productos',
117
118
  ...(parsed.description ? { description: parsed.description } : {}),
@@ -33,6 +33,12 @@ export const productsPropsSchema = z.object({
33
33
  objective: z.string().optional(),
34
34
  ctaLabel: z.string().optional(),
35
35
  ctaHref: z.string().optional(),
36
+ // Optional rail presentation, independent of the section variant: the same
37
+ // `ProductSlider` mount can read as a plain rail, a deals band, an editorial
38
+ // spread… Only the slider variant consumes it; the grid presentations ignore it.
39
+ sliderPreset: z
40
+ .enum(['classic', 'category', 'featured', 'deals', 'compact', 'editorial'])
41
+ .optional(),
36
42
  })
37
43
 
38
44
  export type ProductsProps = z.infer<typeof productsPropsSchema>
@@ -1,5 +1,5 @@
1
1
  // Optional section fragment: universal-main-menu (mirrors recipes/sections.json) — shared contract.
2
- // Zod mirror of the UniversalMainMenu block contract (delivery universal-main-menu, contract version 4.3.2),
2
+ // Zod mirror of the UniversalMainMenu block contract (delivery universal-main-menu, contract version 4.6.1),
3
3
  // shared by the server catalog (universal-main-menu.tsx) and the client registry (universal-main-menu.client.tsx).
4
4
  // The React-only callbacks (onNavigate, onOpenChange) are intentionally excluded.
5
5
 
@@ -79,6 +79,8 @@ export const universalMainMenuDataSchema = z.object({
79
79
  }),
80
80
  behavior: z.object({
81
81
  platform: z.string().optional(),
82
+ anchor: z.string().optional(),
83
+ trigger: z.string().optional(),
82
84
  mobilePattern: z.string().optional(),
83
85
  openOnHover: z.boolean().optional(),
84
86
  openDelayMs: z.number().optional(),
@@ -0,0 +1,43 @@
1
+ # Demo imagery
2
+
3
+ Local static images the starter ships so a generated store looks like a shop
4
+ without a network call. Everything here is served from `public/`, so these are
5
+ plain files, not a CDN and not remote URLs.
6
+
7
+ Replace any file with your own shot **at the same path** — no code change, no
8
+ manifest, no rebuild step. Delete a file and the block falls back to its own
9
+ placeholder.
10
+
11
+ | Path | Size | Used by |
12
+ | --- | --- | --- |
13
+ | `products/<handle>.webp` | 1200×1200 (square) | product cards in the grid and the sliders, product gallery |
14
+ | `categories/<handle>.webp` | 900×900 (square) | category tiles |
15
+ | `banners/<banner-id>.webp` | 1800×1000 (landscape) | campaign banners on the home view |
16
+ | `editorial/studio.webp` | 1600×1200 | the benefits section (rendered in grayscale) |
17
+
18
+ The file name is the contract: `<handle>` is the product or category handle in
19
+ your catalog, `<banner-id>` is the id of the banner in `views/home/content.ts`.
20
+ Serving a new banner is a new file plus its id in the content; serving a new
21
+ product is a new file named after the product.
22
+
23
+ ## How the mock catalog finds these
24
+
25
+ Mock mode resolves `<base>/products/<handle>.webp` and
26
+ `<base>/categories/<handle>.webp`, where `<base>` is `THOR_MOCK_ASSETS` from
27
+ `.env.local` (`/images` in a generated store). Unset the variable and the mock
28
+ provider draws its own SVG placeholders instead, so the store still renders
29
+ with no assets at all.
30
+
31
+ Real mode (Medusa) ignores this folder entirely — the backend serves its own
32
+ product images.
33
+
34
+ ## Regenerating the shipped art
35
+
36
+ ```bash
37
+ yarn workspace @thorprovider/storefront demo:images --force
38
+ ```
39
+
40
+ The script (`scripts/generate-demo-images.mjs`) renders deterministic SVG
41
+ through `sharp`. The shipped art is illustration, not photography: it exists to
42
+ show the composition a real shot belongs in. Swap in photography for a
43
+ production store.
@@ -53,7 +53,7 @@ export const addressBookAdvancedDefaults = {
53
53
  },
54
54
  "deleteDefaultPolicy": "clear",
55
55
  "deleteConfirmation": true,
56
- "searchThreshold": 3,
56
+ "searchThreshold": 0,
57
57
  "pageSize": 6,
58
58
  "validationProvider": false,
59
59
  "coverageProvider": false,
@@ -2,8 +2,7 @@
2
2
  "view": "home",
3
3
  "slots": [
4
4
  { "id": "home.hero", "slot": "hero", "default": "UniversalBanner" },
5
- { "id": "home.benefits", "slot": "benefits", "default": "cards" },
6
- { "id": "home.categories", "slot": "categories", "default": "CategoryGrid" }
5
+ { "id": "home.benefits", "slot": "benefits", "default": "cards" }
7
6
  ],
8
7
  "sections": {
9
8
  "faq": {
@@ -11,14 +11,12 @@ import type { StorefrontElement } from '../../spec/types'
11
11
  import type { ViewModule } from '../types'
12
12
  import { registry } from './registry'
13
13
  import { sectionData } from './sections-data'
14
- import { benefitsProps, categoriesProps, heroProps } from './props'
14
+ import { benefitsProps, heroProps } from './props'
15
15
  import * as homeProps from './props'
16
16
  import * as homeData from './data'
17
- import { toCategoryCard, toFeaturedProduct } from '../../mappers'
17
+ import { toFeaturedProduct } from '../../mappers'
18
18
  import { resolveSectionSources, resolveSectionViewStates } from '../../section-sources'
19
19
  import {
20
- categoryCardPropsSchema,
21
- categoryGridPropsSchema,
22
20
  featurePropsSchema,
23
21
  storefrontHeroPropsSchema,
24
22
  } from './schema'
@@ -67,10 +65,9 @@ export const home: ViewModule = {
67
65
  sections = {}
68
66
  }
69
67
  try {
70
- const { products, categories, source } = await getCatalog()
68
+ const { products, source } = await getCatalog()
71
69
  return {
72
70
  heroProducts: homeData.selectHeroProducts(products).map(toFeaturedProduct),
73
- categories: categories.map(toCategoryCard),
74
71
  dataSource: source,
75
72
  dataError: null,
76
73
  sections,
@@ -80,7 +77,6 @@ export const home: ViewModule = {
80
77
  // data. Mock mode is labelled by `dataSource`.
81
78
  return {
82
79
  heroProducts: [],
83
- categories: [],
84
80
  dataSource: getDataSource(),
85
81
  dataError:
86
82
  error instanceof Error ? error.message : 'No se pudo cargar el catálogo.',
@@ -10,7 +10,6 @@
10
10
  // schema (./schema.ts) before binding, so a contract mismatch fails loudly at
11
11
  // the boundary instead of rendering undefined fields or literal icon tags.
12
12
 
13
- import { CategoryCard as CategoryCardBlock } from '@thorprovider/blocks/blocks/e-commerce/product-categories/category-card'
14
13
  @@BLOCK_IMPORTS@@@@SECTION_REGISTRY_IMPORTS@@
15
14
  import { useEffect, useState } from 'react'
16
15
  import { useStateStore } from '@json-render/react'
@@ -18,8 +17,6 @@ import { resolveIcon } from '../../icon-map'
18
17
  import type { ViewRegistry } from '../types'
19
18
  import * as featureSchemas from './schema'
20
19
  import {
21
- categoryCardPropsSchema,
22
- categoryGridPropsSchema,
23
20
  featurePropsSchema,
24
21
  storefrontHeroPropsSchema,
25
22
  } from './schema'