@thorprovider/storefront 0.13.0 → 0.13.2

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.
@@ -1,4 +1,4 @@
1
- import type { OrderActionId, OrderDocument } from '@thorprovider/blocks/ports'
1
+ import type { OrderDetailActionId, OrderDocument } from '@thorprovider/blocks/ports'
2
2
 
3
3
  /**
4
4
  * Host capability gate for the order-detail route.
@@ -9,7 +9,7 @@ import type { OrderActionId, OrderDocument } from '@thorprovider/blocks/ports'
9
9
  * can really serve: project actions through it, and register exactly one handler
10
10
  * per entry in the route panel.
11
11
  */
12
- export const ORDER_DETAIL_HOST_ACTIONS: readonly OrderActionId[] = [
12
+ export const ORDER_DETAIL_HOST_ACTIONS: readonly OrderDetailActionId[] = [
13
13
  'reorder',
14
14
  'invoice',
15
15
  'track',
@@ -33,16 +33,16 @@ export const ORDER_DETAIL_SUPPORT_HREF = '/contact'
33
33
  */
34
34
  export function orderDetailHostActions(
35
35
  supportHref: string = ORDER_DETAIL_SUPPORT_HREF,
36
- ): readonly OrderActionId[] {
36
+ ): readonly OrderDetailActionId[] {
37
37
  if (supportHref !== '') return ORDER_DETAIL_HOST_ACTIONS
38
38
  return ORDER_DETAIL_HOST_ACTIONS.filter((action) => action !== 'support')
39
39
  }
40
40
 
41
41
  /** Project an authorised action set through the host's real capabilities. */
42
42
  export function projectHostActions(
43
- actions: readonly OrderActionId[],
43
+ actions: readonly OrderDetailActionId[],
44
44
  supportHref: string = ORDER_DETAIL_SUPPORT_HREF,
45
- ): OrderActionId[] {
45
+ ): OrderDetailActionId[] {
46
46
  const served = orderDetailHostActions(supportHref)
47
47
  return actions.filter((action) => served.includes(action))
48
48
  }
@@ -5,7 +5,7 @@ import { useRouter } from 'next/navigation'
5
5
  import { AfterSalesFlow } from '@thorprovider/blocks'
6
6
  import { OrderDetail as OrderDetailSurface } from '@thorprovider/blocks'
7
7
  import type { AfterSalesCaseType, AfterSalesRequest, OrderDetailProps } from '@thorprovider/blocks'
8
- import type { OrderActionId, OrderDetailSnapshot, OrderDocument } from '@thorprovider/blocks/ports'
8
+ import type { OrderDetailActionId, OrderDetailSnapshot, OrderDocument } from '@thorprovider/blocks/ports'
9
9
 
10
10
  import { ports } from '../../ports'
11
11
  import { reorderOrderAction } from '../../actions'
@@ -98,7 +98,7 @@ export function AccountOrderDetailPanel({ props }: PanelProps) {
98
98
  router.push('/account/orders')
99
99
  }, [router])
100
100
 
101
- const onAction = async (action: OrderActionId) => {
101
+ const onAction = async (action: OrderDetailActionId) => {
102
102
  switch (action) {
103
103
  case 'reorder': {
104
104
  if (busy) return
@@ -127,6 +127,14 @@ const giftsMobile = bannerScene(
127
127
  `<svg xmlns='http://www.w3.org/2000/svg' width='640' height='960' viewBox='0 0 640 960'><rect width='640' height='960' fill='#f3e7e2'/><rect x='0' y='780' width='640' height='180' fill='#e0cdc6'/><rect x='170' y='700' width='300' height='80' rx='12' fill='#d8c2ba'/><rect x='200' y='400' width='240' height='300' rx='26' fill='#a4465c'/><path d='M270 400 Q270 320 320 320 Q370 320 370 400' fill='none' stroke='#7d3346' stroke-width='20'/><rect x='200' y='510' width='240' height='22' fill='#7d3346' opacity='0.5'/><rect x='292' y='484' width='52' height='66' rx='9' fill='#e8c8a0'/></svg>`,
128
128
  )
129
129
 
130
+ // Dining-table scene for the decor tile: oak table, linen runner, plate stack.
131
+ const decorDesktop = bannerScene(
132
+ `<svg xmlns='http://www.w3.org/2000/svg' width='1600' height='900' viewBox='0 0 1600 900'><rect width='1600' height='900' fill='#eef1ec'/><rect x='0' y='640' width='1600' height='260' fill='#d5dccf'/><rect x='180' y='470' width='1240' height='190' rx='18' fill='#c9a879'/><rect x='120' y='660' width='60' height='150' rx='10' fill='#a98d63'/><rect x='1420' y='660' width='60' height='150' rx='10' fill='#a98d63'/><rect x='560' y='440' width='480' height='60' rx='8' fill='#f6f2ea'/><g fill='#ffffff' stroke='#cdd6c6' stroke-width='6'><circle cx='430' cy='440' r='110'/><circle cx='760' cy='430' r='86'/><circle cx='1050' cy='445' r='110'/></g><circle cx='430' cy='440' r='60' fill='#e8e3d6'/><circle cx='1050' cy='445' r='60' fill='#e8e3d6'/><g><rect x='1240' y='330' width='90' height='150' rx='16' fill='#b7a184'/><path d='M1265 330 q20 -70 40 0' fill='none' stroke='#8a9b6e' stroke-width='10'/><circle cx='1285' cy='248' r='34' fill='#9daf80'/></g><text x='90' y='140' font-family='system-ui, sans-serif' font-size='40' fill='#7c8778' opacity='0.6'>MESA</text></svg>`,
133
+ )
134
+ const decorMobile = bannerScene(
135
+ `<svg xmlns='http://www.w3.org/2000/svg' width='640' height='960' viewBox='0 0 640 960'><rect width='640' height='960' fill='#eef1ec'/><rect x='0' y='700' width='640' height='260' fill='#d5dccf'/><rect x='40' y='560' width='560' height='170' rx='16' fill='#c9a879'/><rect x='180' y='530' width='280' height='50' rx='8' fill='#f6f2ea'/><g fill='#ffffff' stroke='#cdd6c6' stroke-width='6'><circle cx='230' cy='520' r='80'/><circle cx='430' cy='525' r='80'/></g><g><rect x='470' y='380' width='70' height='120' rx='14' fill='#b7a184'/><path d='M490 380 q16 -54 32 0' fill='none' stroke='#8a9b6e' stroke-width='9'/><circle cx='506' cy='318' r='28' fill='#9daf80'/></g></svg>`,
136
+ )
137
+
130
138
  export const heroBannerData = {
131
139
  campaign: {
132
140
  schemaVersion: 1,
@@ -199,6 +207,9 @@ export const heroBannerData = {
199
207
  padding: 'md',
200
208
  textScale: 'sm',
201
209
  },
210
+ // Desktop: wide tiles with a 224px floor. Each tile owns one cell of the
211
+ // wall, so the floor sets the row height and copy can still grow it.
212
+ responsive: { '2xl': { aspect: 'wide', height: 'adaptive', heightToken: 'md' } },
202
213
  visible: true,
203
214
  },
204
215
  {
@@ -232,6 +243,9 @@ export const heroBannerData = {
232
243
  padding: 'md',
233
244
  textScale: 'sm',
234
245
  },
246
+ // Desktop: wide tiles with a 224px floor. Each tile owns one cell of the
247
+ // wall, so the floor sets the row height and copy can still grow it.
248
+ responsive: { '2xl': { aspect: 'wide', height: 'adaptive', heightToken: 'md' } },
235
249
  visible: true,
236
250
  },
237
251
  {
@@ -265,6 +279,45 @@ export const heroBannerData = {
265
279
  padding: 'md',
266
280
  textScale: 'sm',
267
281
  },
282
+ // Desktop: wide tiles with a 224px floor. Each tile owns one cell of the
283
+ // wall, so the floor sets the row height and copy can still grow it.
284
+ responsive: { '2xl': { aspect: 'wide', height: 'adaptive', heightToken: 'md' } },
285
+ visible: true,
286
+ },
287
+ {
288
+ id: 'banner-mesa-decor',
289
+ campaignId: 'campaign-thor-salon',
290
+ content: {
291
+ name: 'Mesa y textil',
292
+ alt: 'Mesa de roble con mantel de lino, vajilla clara y un jarrón de cerámica',
293
+ title: 'La mesa, a punto',
294
+ description: 'Mantelería de lino, vajilla y cerámica para completar el salón.',
295
+ badge: 'Decoración',
296
+ target: { kind: 'category', id: 'home' },
297
+ ctas: [
298
+ { id: 'cta-mesa', label: 'Ver decoración', target: { kind: 'category', id: 'home' }, tone: 'secondary' },
299
+ ],
300
+ },
301
+ media: { desktop: decorDesktop, mobile: decorMobile },
302
+ presentation: {
303
+ mode: 'overlay',
304
+ width: 'full',
305
+ height: 'auto',
306
+ heightToken: 'sm',
307
+ aspect: 'photo',
308
+ fit: 'cover',
309
+ focal: 'center',
310
+ align: 'start',
311
+ radius: '2xl',
312
+ surface: 'card',
313
+ overlay: 'scrim',
314
+ overlayOpacity: 'light',
315
+ padding: 'md',
316
+ textScale: 'sm',
317
+ },
318
+ // Desktop: wide tiles with a 224px floor. Each tile owns one cell of the
319
+ // wall, so the floor sets the row height and copy can still grow it.
320
+ responsive: { '2xl': { aspect: 'wide', height: 'adaptive', heightToken: 'md' } },
268
321
  visible: true,
269
322
  },
270
323
  ],
@@ -277,20 +330,25 @@ export const heroBannerData = {
277
330
  scheduleAware: true,
278
331
  responsiveEnabled: true,
279
332
  presentation: 'grid',
280
- preset: 'hero-three',
333
+ preset: 'custom',
281
334
  refs: [
282
335
  { bannerId: 'banner-salon-oferta' },
283
336
  { bannerId: 'banner-aurora-deal' },
284
337
  { bannerId: 'banner-nuevas-llegadas' },
285
338
  { bannerId: 'banner-guia-regalo' },
339
+ { bannerId: 'banner-mesa-decor' },
286
340
  ],
287
341
  layout: {
342
+ // Hero at two thirds with a tile beside it, then a row of three. Spans only
343
+ // apply at 2xl; narrower containers drop to one cell per column.
344
+ columns: { base: 1, md: 2, '2xl': 3 },
345
+ spans: [2, 1, 1, 1, 1],
288
346
  gapX: 'md',
289
347
  gapY: 'md',
290
348
  maxWidth: 'full',
291
- // No media cap: the tall hero spans three grid rows, and a capped media
292
- // leaves the rest of the card empty. Each cell sizes its own media.
293
- maxHeight: 'none',
349
+ // Caps every cell at 384px, which is the hero's height in its two-column
350
+ // cell. The tiles keep their 224px floor, so the wall stays near 630px.
351
+ maxHeight: 'xl',
294
352
  align: 'center',
295
353
  radius: '2xl',
296
354
  },
package/bin/storefront.js CHANGED
@@ -64,6 +64,7 @@ import {
64
64
  DEFAULT_REGISTRY,
65
65
  findPack,
66
66
  parseRuntimeCommerceImports,
67
+ REGISTRY_RETRY,
67
68
  verifyPackExports,
68
69
  verifyRegistryToolset,
69
70
  } from '../scripts/candidate.mjs'
@@ -1048,6 +1049,7 @@ async function create(args) {
1048
1049
  cliVersion,
1049
1050
  templatesDir: join(PKG_ROOT, 'assets', 'templates'),
1050
1051
  registry: process.env.STOREFRONT_REGISTRY_URL || DEFAULT_REGISTRY,
1052
+ retry: REGISTRY_RETRY,
1051
1053
  })
1052
1054
  if (!registry.ok) {
1053
1055
  console.error('Refusing to create: the pinned candidate is not installable from the registry.')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thorprovider/storefront",
3
- "version": "0.13.0",
3
+ "version": "0.13.2",
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",
@@ -48,9 +48,9 @@ export const CANDIDATE_TOOLSET = Object.freeze({
48
48
  }),
49
49
  local: Object.freeze({
50
50
  '@thorprovider/blocks': '4.5.0',
51
- '@thorprovider/adapters': '5.6.0',
52
- '@thorprovider/runtime': '0.8.0',
53
- '@thorprovider/types': '7.7.0',
51
+ '@thorprovider/adapters': '5.7.0',
52
+ '@thorprovider/runtime': '0.9.0',
53
+ '@thorprovider/types': '7.8.0',
54
54
  }),
55
55
  })
56
56
 
@@ -431,6 +431,40 @@ export function verifyRegistryArtifact({
431
431
  return { ok: true }
432
432
  }
433
433
 
434
+ /**
435
+ * `npm publish` returns before every registry edge serves the artifacts. A
436
+ * mirror that is still replicating answers 404 for a version that exists, so the
437
+ * acceptance gate polls instead of failing a release that published correctly.
438
+ * The linear backoff below waits ~3.5 minutes in total: acceptance starts ~30s
439
+ * after publishing, and a cold packument edge has been observed to take over a
440
+ * minute to serve a brand-new version.
441
+ */
442
+ export const REGISTRY_RETRY = Object.freeze({ attempts: 7, delayMs: 10_000 })
443
+
444
+ const defaultSleep = (ms) => new Promise((done) => setTimeout(done, ms))
445
+
446
+ /**
447
+ * Fetch once, then keep asking while the only answer is "not there yet" (404) or
448
+ * the network itself failed. Any other status is a real answer and ends the poll.
449
+ */
450
+ async function fetchUntilAvailable(fetchImpl, url, init, { attempts = 1, delayMs = 0, sleep = defaultSleep } = {}) {
451
+ let response
452
+ let error
453
+ for (let attempt = 1; attempt <= attempts; attempt += 1) {
454
+ error = undefined
455
+ try {
456
+ response = await fetchImpl(url, init)
457
+ } catch (cause) {
458
+ response = undefined
459
+ error = cause
460
+ }
461
+ const unavailable = error !== undefined || response.status === 404
462
+ if (!unavailable || attempt === attempts) break
463
+ await sleep(delayMs * attempt)
464
+ }
465
+ return { response, error }
466
+ }
467
+
434
468
  /**
435
469
  * Resolve one exact pin against the registry. Metadata is always checked; the
436
470
  * tarball is downloaded only when the caller needs to inspect its surface.
@@ -441,13 +475,21 @@ export async function resolveRegistryCandidate({
441
475
  registry = DEFAULT_REGISTRY,
442
476
  fetchImpl = globalThis.fetch,
443
477
  downloadTarball = false,
478
+ retry = { attempts: 1, delayMs: 0 },
479
+ sleep,
444
480
  }) {
445
481
  const url = registryMetadataUrl(name, version, registry)
446
- let response
447
- try {
448
- response = await fetchImpl(url, { headers: { accept: 'application/json' } })
449
- } catch (cause) {
450
- return registryFailure('E_REGISTRY_UNREACHABLE', `${name}@${version}: cannot reach ${url} (${cause.message})`)
482
+ const { response, error: metadataError } = await fetchUntilAvailable(
483
+ fetchImpl,
484
+ url,
485
+ { headers: { accept: 'application/json' } },
486
+ { ...retry, sleep },
487
+ )
488
+ if (!response) {
489
+ return registryFailure(
490
+ 'E_REGISTRY_UNREACHABLE',
491
+ `${name}@${version}: cannot reach ${url} (${metadataError?.message ?? 'no response'})`,
492
+ )
451
493
  }
452
494
  if (response.status === 404) {
453
495
  return registryFailure('E_PIN_UNPUBLISHED', `${name}@${version} is not published on ${registry}`)
@@ -487,13 +529,16 @@ export async function resolveRegistryCandidate({
487
529
  }
488
530
  if (!downloadTarball) return { ok: true, name, version, metadata, tarballUrl }
489
531
 
490
- let tarballResponse
491
- try {
492
- tarballResponse = await fetchImpl(tarballUrl)
493
- } catch (cause) {
532
+ const { response: tarballResponse, error: tarballError } = await fetchUntilAvailable(
533
+ fetchImpl,
534
+ tarballUrl,
535
+ undefined,
536
+ { ...retry, sleep },
537
+ )
538
+ if (!tarballResponse) {
494
539
  return registryFailure(
495
540
  'E_REGISTRY_UNREACHABLE',
496
- `${name}@${version}: cannot download ${tarballUrl} (${cause.message})`,
541
+ `${name}@${version}: cannot download ${tarballUrl} (${tarballError?.message ?? 'no response'})`,
497
542
  )
498
543
  }
499
544
  if (!tarballResponse.ok) {
@@ -532,6 +577,8 @@ export async function verifyRegistryToolset({
532
577
  templatesDir,
533
578
  registry = DEFAULT_REGISTRY,
534
579
  fetchImpl = globalThis.fetch,
580
+ retry = { attempts: 1, delayMs: 0 },
581
+ sleep,
535
582
  }) {
536
583
  const { blockImports, runtimeImports } = collectTemplateSurface(templatesDir)
537
584
  const pins = { ...toolset.local, ...(cliVersion ? { '@thorprovider/storefront': cliVersion } : {}) }
@@ -548,6 +595,8 @@ export async function verifyRegistryToolset({
548
595
  registry,
549
596
  fetchImpl,
550
597
  downloadTarball: inspect,
598
+ retry,
599
+ sleep,
551
600
  })
552
601
  if (!result.ok) {
553
602
  errors.push({ code: result.code, message: result.message })
@@ -6,34 +6,44 @@
6
6
  // hardlink, which turns a cheap scaffold into a burst of disk writes. Pointing
7
7
  // `TMPDIR` at a directory beside the target keeps staging and cache on one
8
8
  // device, so `hardlinks-global` holds for every install the scaffold runs.
9
+ //
10
+ // The generated project owns its lockfile: `create` declares the curated
11
+ // dependencies, lets `shadcn init` install, then tightens the CLI pin, so the
12
+ // reconcile pass must be allowed to rewrite the lockfile. Yarn treats `CI=true`
13
+ // as immutable, which turns that reconcile into YN0028 and fails the scaffold
14
+ // inside CI, so the child processes opt out of immutability explicitly.
9
15
 
10
16
  import { mkdtempSync, rmSync, statSync } from 'node:fs'
11
17
  import { tmpdir } from 'node:os'
12
18
  import { dirname, join } from 'node:path'
13
19
 
20
+ /** The scaffold writes the lockfile of the project it creates, never this repo's. */
21
+ const OWNED_LOCKFILE_ENV = { YARN_ENABLE_IMMUTABLE_INSTALLS: 'false' }
22
+
14
23
  /**
15
24
  * Env overrides that keep Yarn staging on the target's device.
16
- * Returns `{}` when the default temp directory already shares the device, or
17
- * when the target cannot be inspected.
25
+ * Always includes the owned-lockfile opt-out; `TMPDIR` is added only when the
26
+ * default temp directory lives on another device, or when the target cannot be
27
+ * inspected.
18
28
  */
19
29
  export function scaffoldTempEnv(target) {
20
- if (process.platform === 'win32') return {}
30
+ if (process.platform === 'win32') return { ...OWNED_LOCKFILE_ENV }
21
31
  let targetDevice
22
32
  try {
23
33
  targetDevice = statSync(target).dev
24
34
  } catch {
25
- return {}
35
+ return { ...OWNED_LOCKFILE_ENV }
26
36
  }
27
37
  try {
28
- if (statSync(tmpdir()).dev === targetDevice) return {}
38
+ if (statSync(tmpdir()).dev === targetDevice) return { ...OWNED_LOCKFILE_ENV }
29
39
  } catch {
30
- return {}
40
+ return { ...OWNED_LOCKFILE_ENV }
31
41
  }
32
42
  try {
33
- return { TMPDIR: mkdtempSync(join(dirname(target), '.storefront-tmp-')) }
43
+ return { ...OWNED_LOCKFILE_ENV, TMPDIR: mkdtempSync(join(dirname(target), '.storefront-tmp-')) }
34
44
  } catch {
35
45
  // A read-only parent is not a reason to fail the scaffold.
36
- return {}
46
+ return { ...OWNED_LOCKFILE_ENV }
37
47
  }
38
48
  }
39
49