@thorprovider/create-thor-app 2.1.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.
- package/README.md +470 -0
- package/dist/index.js +1054 -0
- package/package.json +46 -0
- package/templates/default/.env.example +56 -0
- package/templates/default/.eslintrc.json +43 -0
- package/templates/default/README.md +151 -0
- package/templates/default/app/api/revalidate/route.ts +64 -0
- package/templates/default/app/backend-unavailable/page.tsx +85 -0
- package/templates/default/app/error.tsx +58 -0
- package/templates/default/app/global-error.tsx +208 -0
- package/templates/default/app/globals.css +125 -0
- package/templates/default/app/layout.tsx +50 -0
- package/templates/default/app/not-found.tsx +31 -0
- package/templates/default/app/page.tsx +124 -0
- package/templates/default/components/providers/app-providers.tsx +77 -0
- package/templates/default/components/providers/navigation-provider.tsx +37 -0
- package/templates/default/config/site.config.ts +156 -0
- package/templates/default/docs/README.md +46 -0
- package/templates/default/docs/commerce-api.md +243 -0
- package/templates/default/docs/components.md +276 -0
- package/templates/default/docs/dependencies.md +53 -0
- package/templates/default/docs/patterns.md +100 -0
- package/templates/default/docs/project-structure.md +53 -0
- package/templates/default/docs/rules.md +51 -0
- package/templates/default/docs/types.md +329 -0
- package/templates/default/lib/auth-context.tsx +213 -0
- package/templates/default/lib/cart-provider.tsx +53 -0
- package/templates/default/lib/commerce-provider.tsx +48 -0
- package/templates/default/lib/commerce.ts +165 -0
- package/templates/default/lib/env.ts +147 -0
- package/templates/default/lib/region-detection.ts +80 -0
- package/templates/default/lib/region-provider.tsx +53 -0
- package/templates/default/lib/regions-config.ts +48 -0
- package/templates/default/lib/storefront-config.ts +54 -0
- package/templates/default/lib/utils.ts +10 -0
- package/templates/default/next-env.d.ts +6 -0
- package/templates/default/next.config.mjs +51 -0
- package/templates/default/package.json +42 -0
- package/templates/default/postcss.config.mjs +8 -0
- package/templates/default/proxy.ts +155 -0
- package/templates/default/scripts/generate-regions-config.ts +498 -0
- package/templates/default/tsconfig.json +43 -0
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Global Error Boundary
|
|
3
|
+
*
|
|
4
|
+
* Catches catastrophic errors in root layout (provider failures, StorefrontConfigError,
|
|
5
|
+
* missing environment variables).
|
|
6
|
+
* MUST include <html> and <body> tags — ThemeProvider may have crashed.
|
|
7
|
+
*
|
|
8
|
+
* Implements 3-step error pattern:
|
|
9
|
+
* 1. Categorize — SetupRequired | StorefrontConfig | generic
|
|
10
|
+
* 2. Log — structured logging, dev-only stack trace
|
|
11
|
+
* 3. Display — sanitized UI, no env var names exposed in production
|
|
12
|
+
*
|
|
13
|
+
* Inline styles are intentional: this boundary cannot depend on CSS custom properties
|
|
14
|
+
* defined by ThemeProvider (which may be the root cause of the crash).
|
|
15
|
+
* Colors are defined as RGB constants (not hex) to maintain consistency with design tokens.
|
|
16
|
+
*/
|
|
17
|
+
'use client'
|
|
18
|
+
|
|
19
|
+
import { useEffect } from 'react'
|
|
20
|
+
|
|
21
|
+
// FROZEN: Color tokens for error boundary (RGB format to match token system)
|
|
22
|
+
// These must remain inline since ThemeProvider may have crashed
|
|
23
|
+
const ERROR_COLORS = {
|
|
24
|
+
setupRequired: 'rgb(59, 130, 246)', // Blue-500 (Setup / config missing)
|
|
25
|
+
configError: 'rgb(249, 158, 11)', // Amber-500 (StorefrontConfigError)
|
|
26
|
+
appError: 'rgb(239, 68, 68)', // Red-500 (Generic errors)
|
|
27
|
+
background: 'rgb(250, 250, 250)', // Gray-50
|
|
28
|
+
border: 'rgb(229, 231, 235)', // Gray-200
|
|
29
|
+
textPrimary: 'rgb(17, 17, 17)', // Gray-900
|
|
30
|
+
textSecondary: 'rgb(107, 114, 128)', // Gray-500
|
|
31
|
+
textTertiary: 'rgb(156, 163, 175)', // Gray-400
|
|
32
|
+
buttonBg: 'rgb(37, 99, 235)', // Blue-600
|
|
33
|
+
boxBg: 'rgb(243, 244, 246)', // Gray-100
|
|
34
|
+
boxText: 'rgb(55, 65, 81)', // Gray-700
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
interface ErrorClassification {
|
|
38
|
+
title: string
|
|
39
|
+
message: string
|
|
40
|
+
suggestedActions: string[]
|
|
41
|
+
showRetry: boolean
|
|
42
|
+
color: string
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function classifyError(error: Error & { digest?: string }): ErrorClassification {
|
|
46
|
+
const msg = error.message || ''
|
|
47
|
+
const isDev = process.env.NODE_ENV === 'development'
|
|
48
|
+
|
|
49
|
+
// 1. Missing critical environment variables (lib/commerce.ts throws this)
|
|
50
|
+
const isSetupRequired =
|
|
51
|
+
msg.includes('Missing required environment variables') ||
|
|
52
|
+
msg.includes('Unsupported commerce provider')
|
|
53
|
+
|
|
54
|
+
if (isSetupRequired) {
|
|
55
|
+
return {
|
|
56
|
+
title: 'Setup Required',
|
|
57
|
+
message: isDev
|
|
58
|
+
? 'Critical environment variables are missing. Copy .env.example to .env.local and fill in the required values.'
|
|
59
|
+
: 'The application is not configured yet. Please contact the administrator.',
|
|
60
|
+
suggestedActions: isDev
|
|
61
|
+
? [
|
|
62
|
+
'Copy .env.example to .env.local',
|
|
63
|
+
'Set NEXT_PUBLIC_COMMERCE_API_URL to your backend URL',
|
|
64
|
+
'Set NEXT_PUBLIC_COMMERCE_API_KEY to your publishable key',
|
|
65
|
+
'Restart the dev server after updating .env.local',
|
|
66
|
+
]
|
|
67
|
+
: ['Contact the system administrator'],
|
|
68
|
+
showRetry: false,
|
|
69
|
+
color: ERROR_COLORS.setupRequired,
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// 2. Storefront / sales channel misconfiguration (valid env vars but wrong config)
|
|
74
|
+
const isStorefrontConfigError =
|
|
75
|
+
error.constructor.name === 'StorefrontConfigError' ||
|
|
76
|
+
msg.includes('Storefront') ||
|
|
77
|
+
msg.includes('sales channel')
|
|
78
|
+
|
|
79
|
+
if (isStorefrontConfigError) {
|
|
80
|
+
return {
|
|
81
|
+
title: 'Store Configuration Error',
|
|
82
|
+
message: isDev
|
|
83
|
+
? 'The storefront or sales channel configuration is invalid. Verify your backend settings.'
|
|
84
|
+
: 'The store configuration is incomplete. Please contact the administrator.',
|
|
85
|
+
suggestedActions: isDev
|
|
86
|
+
? [
|
|
87
|
+
'Check your sales channel / storefront configuration in the backend',
|
|
88
|
+
'Verify NEXT_PUBLIC_SALES_CHANNEL_ID if set',
|
|
89
|
+
'Review the .env.example file for required variables',
|
|
90
|
+
]
|
|
91
|
+
: ['Contact the system administrator'],
|
|
92
|
+
showRetry: false,
|
|
93
|
+
color: ERROR_COLORS.configError,
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// 3. Everything else — runtime crash, recoverable
|
|
98
|
+
return {
|
|
99
|
+
title: 'Application Error',
|
|
100
|
+
message: 'A critical error occurred while loading the application. Please try refreshing.',
|
|
101
|
+
suggestedActions: ['Refresh the page', 'Contact support if the problem persists'],
|
|
102
|
+
showRetry: true,
|
|
103
|
+
color: ERROR_COLORS.appError,
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export default function GlobalError({
|
|
108
|
+
error,
|
|
109
|
+
reset,
|
|
110
|
+
}: {
|
|
111
|
+
error: Error & { digest?: string }
|
|
112
|
+
reset: () => void
|
|
113
|
+
}) {
|
|
114
|
+
useEffect(() => {
|
|
115
|
+
const meta = {
|
|
116
|
+
name: error.constructor.name || 'UnknownError',
|
|
117
|
+
digest: error.digest,
|
|
118
|
+
context: 'global-error-boundary',
|
|
119
|
+
timestamp: new Date().toISOString(),
|
|
120
|
+
...(process.env.NODE_ENV === 'development' && { message: error.message }),
|
|
121
|
+
}
|
|
122
|
+
process.env.NODE_ENV === 'development'
|
|
123
|
+
? console.error('[GlobalError]', error)
|
|
124
|
+
: console.error('[GlobalError]', JSON.stringify(meta))
|
|
125
|
+
}, [error])
|
|
126
|
+
|
|
127
|
+
const { title, message, suggestedActions, showRetry, color } = classifyError(error)
|
|
128
|
+
|
|
129
|
+
return (
|
|
130
|
+
<html>
|
|
131
|
+
<body>
|
|
132
|
+
<div
|
|
133
|
+
style={{
|
|
134
|
+
display: 'flex',
|
|
135
|
+
flexDirection: 'column',
|
|
136
|
+
alignItems: 'center',
|
|
137
|
+
justifyContent: 'center',
|
|
138
|
+
minHeight: '100vh',
|
|
139
|
+
padding: '20px',
|
|
140
|
+
fontFamily: 'system-ui, -apple-system, sans-serif',
|
|
141
|
+
backgroundColor: ERROR_COLORS.background,
|
|
142
|
+
}}
|
|
143
|
+
>
|
|
144
|
+
<div style={{ width: 64, height: 64, borderRadius: '50%', backgroundColor: color, opacity: 0.15, marginBottom: 8 }} />
|
|
145
|
+
|
|
146
|
+
<h1 style={{ fontSize: 24, fontWeight: 700, color: ERROR_COLORS.textPrimary, margin: '16px 0 8px' }}>
|
|
147
|
+
{title}
|
|
148
|
+
</h1>
|
|
149
|
+
|
|
150
|
+
<p style={{ color: ERROR_COLORS.textSecondary, maxWidth: 500, textAlign: 'center', lineHeight: 1.5, margin: '0 0 16px' }}>
|
|
151
|
+
{message}
|
|
152
|
+
</p>
|
|
153
|
+
|
|
154
|
+
{error.digest && (
|
|
155
|
+
<p style={{ fontSize: 12, color: ERROR_COLORS.textTertiary, fontFamily: 'monospace', margin: '0 0 20px' }}>
|
|
156
|
+
Error ID: {error.digest}
|
|
157
|
+
</p>
|
|
158
|
+
)}
|
|
159
|
+
|
|
160
|
+
{suggestedActions.length > 0 && (
|
|
161
|
+
<div
|
|
162
|
+
style={{
|
|
163
|
+
backgroundColor: ERROR_COLORS.boxBg,
|
|
164
|
+
border: `1px solid ${ERROR_COLORS.border}`,
|
|
165
|
+
borderRadius: 6,
|
|
166
|
+
padding: 16,
|
|
167
|
+
marginBottom: 20,
|
|
168
|
+
maxWidth: 500,
|
|
169
|
+
}}
|
|
170
|
+
>
|
|
171
|
+
<p style={{ fontSize: 13, fontWeight: 600, color: ERROR_COLORS.boxText, margin: '0 0 10px' }}>
|
|
172
|
+
What you can try:
|
|
173
|
+
</p>
|
|
174
|
+
<ul style={{ listStyle: 'none', padding: 0, margin: 0 }}>
|
|
175
|
+
{suggestedActions.map((action, i) => (
|
|
176
|
+
<li
|
|
177
|
+
key={i}
|
|
178
|
+
style={{ fontSize: 13, color: ERROR_COLORS.textSecondary, marginBottom: i < suggestedActions.length - 1 ? 8 : 0, paddingLeft: 16 }}
|
|
179
|
+
>
|
|
180
|
+
• {action}
|
|
181
|
+
</li>
|
|
182
|
+
))}
|
|
183
|
+
</ul>
|
|
184
|
+
</div>
|
|
185
|
+
)}
|
|
186
|
+
|
|
187
|
+
{showRetry && (
|
|
188
|
+
<button
|
|
189
|
+
onClick={reset}
|
|
190
|
+
style={{
|
|
191
|
+
padding: '10px 22px',
|
|
192
|
+
backgroundColor: ERROR_COLORS.buttonBg,
|
|
193
|
+
color: 'rgb(255, 255, 255)',
|
|
194
|
+
border: 'none',
|
|
195
|
+
borderRadius: 6,
|
|
196
|
+
cursor: 'pointer',
|
|
197
|
+
fontSize: 15,
|
|
198
|
+
fontWeight: 500,
|
|
199
|
+
}}
|
|
200
|
+
>
|
|
201
|
+
Try Again
|
|
202
|
+
</button>
|
|
203
|
+
)}
|
|
204
|
+
</div>
|
|
205
|
+
</body>
|
|
206
|
+
</html>
|
|
207
|
+
)
|
|
208
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
@import 'tailwindcss';
|
|
2
|
+
@import 'tw-animate-css';
|
|
3
|
+
|
|
4
|
+
@custom-variant dark (&:is(.dark *));
|
|
5
|
+
|
|
6
|
+
:root {
|
|
7
|
+
--background: oklch(0.98 0.002 90);
|
|
8
|
+
--foreground: oklch(0.15 0 0);
|
|
9
|
+
--card: oklch(1 0 0);
|
|
10
|
+
--card-foreground: oklch(0.15 0 0);
|
|
11
|
+
--popover: oklch(1 0 0);
|
|
12
|
+
--popover-foreground: oklch(0.15 0 0);
|
|
13
|
+
--primary: oklch(0.15 0 0);
|
|
14
|
+
--primary-foreground: oklch(0.98 0.002 90);
|
|
15
|
+
--secondary: oklch(0.96 0.003 90);
|
|
16
|
+
--secondary-foreground: oklch(0.15 0 0);
|
|
17
|
+
--muted: oklch(0.94 0.003 90);
|
|
18
|
+
--muted-foreground: oklch(0.45 0 0);
|
|
19
|
+
--accent: oklch(0.65 0.15 25);
|
|
20
|
+
--accent-foreground: oklch(1 0 0);
|
|
21
|
+
--destructive: oklch(0.55 0.2 25);
|
|
22
|
+
--destructive-foreground: oklch(1 0 0);
|
|
23
|
+
--border: oklch(0.88 0.003 90);
|
|
24
|
+
--input: oklch(0.92 0.003 90);
|
|
25
|
+
--ring: oklch(0.15 0 0);
|
|
26
|
+
--chart-1: oklch(0.646 0.222 41.116);
|
|
27
|
+
--chart-2: oklch(0.6 0.118 184.704);
|
|
28
|
+
--chart-3: oklch(0.398 0.07 227.392);
|
|
29
|
+
--chart-4: oklch(0.828 0.189 84.429);
|
|
30
|
+
--chart-5: oklch(0.769 0.188 70.08);
|
|
31
|
+
--radius: 0.375rem;
|
|
32
|
+
--sidebar: oklch(0.985 0 0);
|
|
33
|
+
--sidebar-foreground: oklch(0.145 0 0);
|
|
34
|
+
--sidebar-primary: oklch(0.205 0 0);
|
|
35
|
+
--sidebar-primary-foreground: oklch(0.985 0 0);
|
|
36
|
+
--sidebar-accent: oklch(0.97 0 0);
|
|
37
|
+
--sidebar-accent-foreground: oklch(0.205 0 0);
|
|
38
|
+
--sidebar-border: oklch(0.922 0 0);
|
|
39
|
+
--sidebar-ring: oklch(0.708 0 0);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.dark {
|
|
43
|
+
--background: oklch(0.145 0 0);
|
|
44
|
+
--foreground: oklch(0.985 0 0);
|
|
45
|
+
--card: oklch(0.145 0 0);
|
|
46
|
+
--card-foreground: oklch(0.985 0 0);
|
|
47
|
+
--popover: oklch(0.145 0 0);
|
|
48
|
+
--popover-foreground: oklch(0.985 0 0);
|
|
49
|
+
--primary: oklch(0.985 0 0);
|
|
50
|
+
--primary-foreground: oklch(0.205 0 0);
|
|
51
|
+
--secondary: oklch(0.269 0 0);
|
|
52
|
+
--secondary-foreground: oklch(0.985 0 0);
|
|
53
|
+
--muted: oklch(0.269 0 0);
|
|
54
|
+
--muted-foreground: oklch(0.708 0 0);
|
|
55
|
+
--accent: oklch(0.269 0 0);
|
|
56
|
+
--accent-foreground: oklch(0.985 0 0);
|
|
57
|
+
--destructive: oklch(0.396 0.141 25.723);
|
|
58
|
+
--destructive-foreground: oklch(0.637 0.237 25.331);
|
|
59
|
+
--border: oklch(0.269 0 0);
|
|
60
|
+
--input: oklch(0.269 0 0);
|
|
61
|
+
--ring: oklch(0.439 0 0);
|
|
62
|
+
--chart-1: oklch(0.488 0.243 264.376);
|
|
63
|
+
--chart-2: oklch(0.696 0.17 162.48);
|
|
64
|
+
--chart-3: oklch(0.769 0.188 70.08);
|
|
65
|
+
--chart-4: oklch(0.627 0.265 303.9);
|
|
66
|
+
--chart-5: oklch(0.645 0.246 16.439);
|
|
67
|
+
--sidebar: oklch(0.205 0 0);
|
|
68
|
+
--sidebar-foreground: oklch(0.985 0 0);
|
|
69
|
+
--sidebar-primary: oklch(0.488 0.243 264.376);
|
|
70
|
+
--sidebar-primary-foreground: oklch(0.985 0 0);
|
|
71
|
+
--sidebar-accent: oklch(0.269 0 0);
|
|
72
|
+
--sidebar-accent-foreground: oklch(0.985 0 0);
|
|
73
|
+
--sidebar-border: oklch(0.269 0 0);
|
|
74
|
+
--sidebar-ring: oklch(0.439 0 0);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
@theme inline {
|
|
78
|
+
--font-sans: 'Inter', 'Inter Fallback', system-ui, sans-serif;
|
|
79
|
+
--font-mono: 'Geist Mono', 'Geist Mono Fallback';
|
|
80
|
+
--color-background: var(--background);
|
|
81
|
+
--color-foreground: var(--foreground);
|
|
82
|
+
--color-card: var(--card);
|
|
83
|
+
--color-card-foreground: var(--card-foreground);
|
|
84
|
+
--color-popover: var(--popover);
|
|
85
|
+
--color-popover-foreground: var(--popover-foreground);
|
|
86
|
+
--color-primary: var(--primary);
|
|
87
|
+
--color-primary-foreground: var(--primary-foreground);
|
|
88
|
+
--color-secondary: var(--secondary);
|
|
89
|
+
--color-secondary-foreground: var(--secondary-foreground);
|
|
90
|
+
--color-muted: var(--muted);
|
|
91
|
+
--color-muted-foreground: var(--muted-foreground);
|
|
92
|
+
--color-accent: var(--accent);
|
|
93
|
+
--color-accent-foreground: var(--accent-foreground);
|
|
94
|
+
--color-destructive: var(--destructive);
|
|
95
|
+
--color-destructive-foreground: var(--destructive-foreground);
|
|
96
|
+
--color-border: var(--border);
|
|
97
|
+
--color-input: var(--input);
|
|
98
|
+
--color-ring: var(--ring);
|
|
99
|
+
--color-chart-1: var(--chart-1);
|
|
100
|
+
--color-chart-2: var(--chart-2);
|
|
101
|
+
--color-chart-3: var(--chart-3);
|
|
102
|
+
--color-chart-4: var(--chart-4);
|
|
103
|
+
--color-chart-5: var(--chart-5);
|
|
104
|
+
--radius-sm: calc(var(--radius) - 4px);
|
|
105
|
+
--radius-md: calc(var(--radius) - 2px);
|
|
106
|
+
--radius-lg: var(--radius);
|
|
107
|
+
--radius-xl: calc(var(--radius) + 4px);
|
|
108
|
+
--color-sidebar: var(--sidebar);
|
|
109
|
+
--color-sidebar-foreground: var(--sidebar-foreground);
|
|
110
|
+
--color-sidebar-primary: var(--sidebar-primary);
|
|
111
|
+
--color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
|
|
112
|
+
--color-sidebar-accent: var(--sidebar-accent);
|
|
113
|
+
--color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
|
|
114
|
+
--color-sidebar-border: var(--sidebar-border);
|
|
115
|
+
--color-sidebar-ring: var(--sidebar-ring);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
@layer base {
|
|
119
|
+
* {
|
|
120
|
+
@apply border-border outline-ring/50;
|
|
121
|
+
}
|
|
122
|
+
body {
|
|
123
|
+
@apply bg-background text-foreground;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { Metadata } from 'next';
|
|
3
|
+
import { Inter } from 'next/font/google';
|
|
4
|
+
import { ThemeProvider } from '@thorprovider/providers';
|
|
5
|
+
import { AppProviders } from '@/components/providers/app-providers';
|
|
6
|
+
import { getRegionFromIpHeaders } from '@/lib/region-detection';
|
|
7
|
+
import { getStorefrontConfig, resolveAccentColor } from '@/lib/storefront-config';
|
|
8
|
+
import { siteConfig } from '@/config/site.config';
|
|
9
|
+
import '@thorprovider/components/styles.css';
|
|
10
|
+
import './globals.css';
|
|
11
|
+
|
|
12
|
+
const inter = Inter({ subsets: ['latin'], variable: '--font-inter' });
|
|
13
|
+
|
|
14
|
+
export const metadata: Metadata = {
|
|
15
|
+
title: siteConfig.title,
|
|
16
|
+
description: siteConfig.description,
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export default async function RootLayout({
|
|
20
|
+
children,
|
|
21
|
+
}: Readonly<{
|
|
22
|
+
children: React.ReactNode;
|
|
23
|
+
}>) {
|
|
24
|
+
const [initialRegionId, storefrontConfig] = await Promise.all([
|
|
25
|
+
getRegionFromIpHeaders(),
|
|
26
|
+
getStorefrontConfig(),
|
|
27
|
+
]);
|
|
28
|
+
|
|
29
|
+
const accentOverride = storefrontConfig?.themeAccentColor
|
|
30
|
+
? resolveAccentColor(storefrontConfig.themeAccentColor)
|
|
31
|
+
: undefined;
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<html>
|
|
35
|
+
<body className={`${inter.variable} font-sans antialiased`}>
|
|
36
|
+
<ThemeProvider {...({ preset: siteConfig.preset, children: (
|
|
37
|
+
<AppProviders initialRegionId={initialRegionId}>
|
|
38
|
+
{accentOverride ? (
|
|
39
|
+
<div style={{ '--accent': accentOverride } as React.CSSProperties}>
|
|
40
|
+
{children}
|
|
41
|
+
</div>
|
|
42
|
+
) : (
|
|
43
|
+
children
|
|
44
|
+
)}
|
|
45
|
+
</AppProviders>
|
|
46
|
+
)} as any)} />
|
|
47
|
+
</body>
|
|
48
|
+
</html>
|
|
49
|
+
);
|
|
50
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Locale-Level Not Found Page
|
|
3
|
+
*
|
|
4
|
+
* Displayed when a page inside app/[locale]/ does not exist.
|
|
5
|
+
* Self-contained — does not import @thorprovider/components components.
|
|
6
|
+
* Projects replace this with a branded 404 page.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import Link from 'next/link'
|
|
10
|
+
|
|
11
|
+
export default function NotFound() {
|
|
12
|
+
return (
|
|
13
|
+
<div className="flex flex-col items-center justify-center min-h-[60vh] px-8 py-16 text-center font-sans">
|
|
14
|
+
<p className="text-[64px] font-bold text-muted-foreground/30 leading-none mb-4">
|
|
15
|
+
404
|
|
16
|
+
</p>
|
|
17
|
+
<h2 className="text-xl font-semibold text-foreground mb-2">
|
|
18
|
+
Page Not Found
|
|
19
|
+
</h2>
|
|
20
|
+
<p className="text-muted-foreground max-w-[380px] leading-relaxed mb-7">
|
|
21
|
+
The page you're looking for doesn't exist or has been moved.
|
|
22
|
+
</p>
|
|
23
|
+
<Link
|
|
24
|
+
href="/"
|
|
25
|
+
className="px-5 py-2 bg-primary text-primary-foreground rounded-md no-underline text-sm font-medium hover:bg-primary/90 transition-colors"
|
|
26
|
+
>
|
|
27
|
+
Go to Home
|
|
28
|
+
</Link>
|
|
29
|
+
</div>
|
|
30
|
+
)
|
|
31
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { Metadata } from 'next';
|
|
2
|
+
import { Button, Heading, Text } from '@thorprovider/components';
|
|
3
|
+
|
|
4
|
+
export const metadata: Metadata = {
|
|
5
|
+
title: 'Thor Commerce | Initialized',
|
|
6
|
+
description: 'Your highly scalable, hexagonal e-commerce template is ready.',
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export default function HomePage() {
|
|
10
|
+
return (
|
|
11
|
+
<main className="flex min-h-screen flex-col items-center p-6 md:p-24 bg-background text-foreground relative overflow-hidden selection:bg-primary/30">
|
|
12
|
+
{/* Abstract Background Elements */}
|
|
13
|
+
<div className="absolute top-[-10%] left-[-10%] w-[40%] h-[40%] rounded-full bg-primary/10 blur-[120px] pointer-events-none" />
|
|
14
|
+
<div className="absolute bottom-[-10%] right-[-10%] w-[40%] h-[40%] rounded-full bg-accent/10 blur-[120px] pointer-events-none" />
|
|
15
|
+
|
|
16
|
+
{/* Top Status Bar */}
|
|
17
|
+
<div className="z-10 flex flex-col items-center max-w-5xl w-full gap-8">
|
|
18
|
+
<div className="flex items-center gap-3 px-5 py-2.5 rounded-full bg-muted/40 border border-border/50 text-sm backdrop-blur-md shadow-sm">
|
|
19
|
+
<span className="relative flex h-2.5 w-2.5">
|
|
20
|
+
<span className="animate-ping absolute inline-flex h-full w-full rounded-full bg-primary opacity-75"></span>
|
|
21
|
+
<span className="relative inline-flex rounded-full h-2.5 w-2.5 bg-primary"></span>
|
|
22
|
+
</span>
|
|
23
|
+
<span className="text-muted-foreground font-medium tracking-wide">
|
|
24
|
+
Template Initialized
|
|
25
|
+
</span>
|
|
26
|
+
<div className="hidden sm:block w-px h-4 bg-border" />
|
|
27
|
+
<span className="hidden sm:block text-muted-foreground">
|
|
28
|
+
Edit
|
|
29
|
+
</span>
|
|
30
|
+
<code className="font-mono text-xs font-semibold text-primary bg-muted px-2 py-0.5 rounded-sm border border-border/50">
|
|
31
|
+
app/page.tsx
|
|
32
|
+
</code>
|
|
33
|
+
</div>
|
|
34
|
+
|
|
35
|
+
{/* Hero Section */}
|
|
36
|
+
<div className="flex flex-col items-center text-center gap-6 mt-16 md:mt-24 z-10 w-full max-w-3xl">
|
|
37
|
+
<Heading
|
|
38
|
+
as="h1"
|
|
39
|
+
className="text-6xl md:text-8xl font-black tracking-tighter leading-none"
|
|
40
|
+
>
|
|
41
|
+
Thor<br className="md:hidden" />
|
|
42
|
+
<span className="text-transparent bg-clip-text bg-gradient-to-br from-primary to-accent">
|
|
43
|
+
Commerce
|
|
44
|
+
</span>
|
|
45
|
+
</Heading>
|
|
46
|
+
|
|
47
|
+
<Text className="text-xl md:text-2xl text-muted-foreground max-w-[600px] leading-relaxed font-light text-balance mt-4">
|
|
48
|
+
Your production-ready, hexagonal architecture storefront has been successfully deployed.
|
|
49
|
+
</Text>
|
|
50
|
+
|
|
51
|
+
<div className="flex flex-col sm:flex-row gap-4 mt-8 w-full sm:w-auto px-4">
|
|
52
|
+
<a
|
|
53
|
+
href="https://github.com/thorprovider/thor-commerce/blob/main/docs/architecture/overview.md"
|
|
54
|
+
target="_blank"
|
|
55
|
+
rel="noopener noreferrer"
|
|
56
|
+
className="w-full sm:w-auto"
|
|
57
|
+
>
|
|
58
|
+
<Button size="lg" className="w-full rounded-full px-8 h-12 text-base font-semibold shadow-lg shadow-primary/25 hover:shadow-primary/40 transition-all">
|
|
59
|
+
Read the Docs
|
|
60
|
+
</Button>
|
|
61
|
+
</a>
|
|
62
|
+
<a
|
|
63
|
+
href="https://github.com/thorprovider/thor-commerce"
|
|
64
|
+
target="_blank"
|
|
65
|
+
rel="noopener noreferrer"
|
|
66
|
+
className="w-full sm:w-auto"
|
|
67
|
+
>
|
|
68
|
+
<Button size="lg" variant="secondary" className="w-full rounded-full px-8 h-12 text-base font-semibold transition-all">
|
|
69
|
+
GitHub Repo
|
|
70
|
+
</Button>
|
|
71
|
+
</a>
|
|
72
|
+
</div>
|
|
73
|
+
</div>
|
|
74
|
+
</div>
|
|
75
|
+
|
|
76
|
+
{/* Grid Documentation Links */}
|
|
77
|
+
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6 max-w-6xl w-full mt-32 z-10">
|
|
78
|
+
{[
|
|
79
|
+
{
|
|
80
|
+
title: 'L1-L5 Architecture',
|
|
81
|
+
description: 'Learn the strict unidirectional data flow and layer separation.',
|
|
82
|
+
href: 'https://github.com/thorprovider/thor-commerce/blob/main/docs/architecture/layers-l1-to-l5.md',
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
title: 'Adapters & Providers',
|
|
86
|
+
description: 'Understand how to seamlessly switch between Medusa and Shopify.',
|
|
87
|
+
href: 'https://github.com/thorprovider/thor-commerce/blob/main/docs/guides/adapters.md',
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
title: 'UI Components',
|
|
91
|
+
description: 'Explore the 55+ accessible primitives powering this platform.',
|
|
92
|
+
href: 'https://github.com/thorprovider/thor-commerce/blob/main/packages/components/README.md',
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
title: 'Workflows & AI',
|
|
96
|
+
description: 'Supercharge development using automated V0 context generation.',
|
|
97
|
+
href: 'https://github.com/thorprovider/thor-commerce/blob/main/docs/architecture/ai-generation-workflow.md',
|
|
98
|
+
},
|
|
99
|
+
].map((feature, i) => (
|
|
100
|
+
<a
|
|
101
|
+
key={i}
|
|
102
|
+
href={feature.href}
|
|
103
|
+
target="_blank"
|
|
104
|
+
rel="noopener noreferrer"
|
|
105
|
+
className="group relative flex flex-col rounded-2xl border border-border/40 bg-card/10 p-6 backdrop-blur-sm transition-all hover:bg-card/40 hover:border-primary/30 overflow-hidden"
|
|
106
|
+
>
|
|
107
|
+
{/* Hover Gradient */}
|
|
108
|
+
<div className="absolute inset-0 bg-gradient-to-br from-primary/10 to-transparent opacity-0 transition-opacity duration-500 group-hover:opacity-100" />
|
|
109
|
+
|
|
110
|
+
<Heading as="h3" className="text-xl font-bold mb-3 flex items-center justify-between group-hover:text-primary transition-colors">
|
|
111
|
+
{feature.title}
|
|
112
|
+
<span className="inline-block transition-transform duration-300 group-hover:translate-x-1 group-hover:-translate-y-1 opacity-50 group-hover:opacity-100">
|
|
113
|
+
↗
|
|
114
|
+
</span>
|
|
115
|
+
</Heading>
|
|
116
|
+
<Text className="text-sm text-muted-foreground leading-relaxed m-0 text-balance flex-grow">
|
|
117
|
+
{feature.description}
|
|
118
|
+
</Text>
|
|
119
|
+
</a>
|
|
120
|
+
))}
|
|
121
|
+
</div>
|
|
122
|
+
</main>
|
|
123
|
+
);
|
|
124
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @thorprovider/core - Application Providers Composition
|
|
5
|
+
*
|
|
6
|
+
* V0: COPY THIS FILE VERBATIM when creating starters or apps.
|
|
7
|
+
* Only customize: add new providers as children of ClientNavigationProvider.
|
|
8
|
+
* NEVER remove, reorder, or replace providers with direct @thorprovider/providers imports.
|
|
9
|
+
* See: .v0/docs/v0_provider_chain.md
|
|
10
|
+
*
|
|
11
|
+
* Provider Hierarchy (ordered by dependencies — FROZEN, do not reorder):
|
|
12
|
+
* 1. ClientCommerceProvider - Commerce backend access (no dependencies)
|
|
13
|
+
* 2. ClientRegionProvider - Regional settings (depends on commerce)
|
|
14
|
+
* 3. AuthProvider - Authentication (no dependencies)
|
|
15
|
+
* 4. ClientCartProvider - Shopping cart (depends on commerce, region, auth)
|
|
16
|
+
* 5. ClientNavigationProvider - URL resolvers (no dependencies)
|
|
17
|
+
*
|
|
18
|
+
* Rule for V0: Add new providers as children of ClientNavigationProvider.
|
|
19
|
+
* Never reorder or remove from this chain.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
import React from 'react';
|
|
23
|
+
import { ClientCommerceProvider } from '@/lib/commerce-provider';
|
|
24
|
+
import { ClientRegionProvider } from '@/lib/region-provider';
|
|
25
|
+
import { AuthProvider } from '@/lib/auth-context';
|
|
26
|
+
import { ClientCartProvider } from '@/lib/cart-provider';
|
|
27
|
+
import { ClientNavigationProvider } from './navigation-provider';
|
|
28
|
+
import type { ReactNode } from 'react';
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* AppProviders Props
|
|
32
|
+
*/
|
|
33
|
+
export interface AppProvidersProps {
|
|
34
|
+
/**
|
|
35
|
+
* Child components to wrap with all providers
|
|
36
|
+
*/
|
|
37
|
+
children: ReactNode;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Region ID detected server-side from the client's IP geolocation headers.
|
|
41
|
+
* When provided, RegionProvider uses this as the initial region, bypassing
|
|
42
|
+
* the locale-based fallback. localStorage takes priority if the user
|
|
43
|
+
* has previously selected a region explicitly.
|
|
44
|
+
*/
|
|
45
|
+
initialRegionId?: string;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Application Providers Composition
|
|
50
|
+
*
|
|
51
|
+
* Wraps children with all required Context Providers in the correct order.
|
|
52
|
+
* This component is a Client Component because it contains provider functions
|
|
53
|
+
* that cannot be serialized for Server Components.
|
|
54
|
+
*/
|
|
55
|
+
export function AppProviders({ children, initialRegionId }: AppProvidersProps) {
|
|
56
|
+
return (
|
|
57
|
+
// FROZEN: Provider order is critical. Do NOT reorder or remove providers.
|
|
58
|
+
// Each provider depends on the previous ones in this exact sequence:
|
|
59
|
+
// 1. ClientCommerceProvider (no deps)
|
|
60
|
+
// 2. ClientRegionProvider (uses commerce context)
|
|
61
|
+
// 3. AuthProvider (no deps)
|
|
62
|
+
// 4. ClientCartProvider (uses commerce, region, auth contexts)
|
|
63
|
+
// 5. ClientNavigationProvider (no deps)
|
|
64
|
+
// Reordering will break context dependencies and cause runtime errors.
|
|
65
|
+
<ClientCommerceProvider>
|
|
66
|
+
<ClientRegionProvider initialRegionId={initialRegionId}>
|
|
67
|
+
<AuthProvider>
|
|
68
|
+
<ClientCartProvider>
|
|
69
|
+
<ClientNavigationProvider>
|
|
70
|
+
{children}
|
|
71
|
+
</ClientNavigationProvider>
|
|
72
|
+
</ClientCartProvider>
|
|
73
|
+
</AuthProvider>
|
|
74
|
+
</ClientRegionProvider>
|
|
75
|
+
</ClientCommerceProvider>
|
|
76
|
+
);
|
|
77
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Client-side Navigation Provider wrapper
|
|
5
|
+
*
|
|
6
|
+
* This component wraps the NavigationProvider from @thorprovider/providers
|
|
7
|
+
* with the appropriate configuration for Next.js App Router.
|
|
8
|
+
*
|
|
9
|
+
* IMPORTANT: Must be a Client Component because it contains functions
|
|
10
|
+
* (resolvers) that cannot be serialized for Server Components.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { NavigationProvider } from '@thorprovider/providers';
|
|
14
|
+
import NextLink from 'next/link';
|
|
15
|
+
import type { ReactNode } from 'react';
|
|
16
|
+
|
|
17
|
+
interface ClientNavigationProviderProps {
|
|
18
|
+
children: ReactNode;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function ClientNavigationProvider({ children }: ClientNavigationProviderProps) {
|
|
22
|
+
return (
|
|
23
|
+
<NavigationProvider
|
|
24
|
+
config={{
|
|
25
|
+
LinkComponent: NextLink,
|
|
26
|
+
resolvers: {
|
|
27
|
+
product: (product) => `/products/${product.handle}`,
|
|
28
|
+
category: (slug) => `/category/${slug}`,
|
|
29
|
+
search: (query) => `/search?q=${encodeURIComponent(query)}`,
|
|
30
|
+
},
|
|
31
|
+
debug: process.env.NODE_ENV === 'development',
|
|
32
|
+
}}
|
|
33
|
+
>
|
|
34
|
+
{children}
|
|
35
|
+
</NavigationProvider>
|
|
36
|
+
);
|
|
37
|
+
}
|