@thorprovider/create-thor-app 4.0.0 → 4.0.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 +6 -55
- package/dist/index.js +154 -626
- package/package.json +1 -1
- package/templates/default/.agents/AGENTS.md +27 -0
- package/templates/default/.env.example +8 -30
- package/templates/default/.eslintrc.json +20 -27
- package/templates/default/README.md +52 -123
- package/templates/default/ai-validator.json +47 -29
- package/templates/default/app/api/revalidate/route.ts +27 -36
- package/templates/default/app/backend-unavailable/page.tsx +3 -7
- package/templates/default/app/error.tsx +1 -2
- package/templates/default/app/global-error.tsx +3 -3
- package/templates/default/app/globals.css +1 -71
- package/templates/default/app/layout.tsx +16 -38
- package/templates/default/app/not-found.tsx +1 -1
- package/templates/default/app/page.tsx +10 -119
- package/templates/default/components/providers/app-providers.tsx +19 -68
- package/templates/default/components/providers/cart-provider.tsx +143 -0
- package/templates/default/components/providers/commerce-provider.tsx +33 -0
- package/templates/default/components/providers/region-provider.tsx +105 -0
- package/templates/default/docs/README.md +46 -37
- package/templates/default/docs/commerce-api.md +58 -125
- package/templates/default/docs/patterns.md +128 -67
- package/templates/default/docs/project-structure.md +58 -50
- package/templates/default/docs/rules.md +43 -42
- package/templates/default/docs/types.md +105 -1024
- package/templates/default/lib/commerce.ts +33 -132
- package/templates/default/lib/env.ts +24 -94
- package/templates/default/lib/utils.ts +18 -0
- package/templates/default/next-env.d.ts +1 -1
- package/templates/default/next.config.ts +7 -0
- package/templates/default/package.json +2 -8
- package/templates/default/registry.json +6 -0
- package/templates/default/styles/tokens.css +81 -0
- package/templates/default/components/providers/navigation-provider.tsx +0 -37
- package/templates/default/config/site.config.ts +0 -156
- package/templates/default/docs/components.md +0 -282
- package/templates/default/docs/dependencies.md +0 -61
- package/templates/default/lib/auth-context.tsx +0 -213
- package/templates/default/lib/cart-provider.tsx +0 -53
- package/templates/default/lib/commerce-provider.tsx +0 -48
- package/templates/default/lib/region-detection.ts +0 -73
- package/templates/default/lib/region-provider.tsx +0 -53
- package/templates/default/lib/regions-config.ts +0 -48
- package/templates/default/lib/storefront-config.ts +0 -54
- package/templates/default/next.config.mjs +0 -51
- package/templates/default/proxy.ts +0 -155
- package/templates/default/scripts/generate-regions-config.ts +0 -498
|
@@ -1,165 +1,66 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Commerce Singleton
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* This is the ONLY place where createProvider()
|
|
6
|
-
* NEVER call createProvider() in app/layout.tsx or elsewhere.
|
|
7
|
-
* See: .v0/docs/v0_provider_chain.md
|
|
4
|
+
* FROZEN: V0 reads this file but NEVER modifies it.
|
|
5
|
+
* This is the ONLY place where createProvider() is called.
|
|
8
6
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
7
|
+
* Usage (server components):
|
|
8
|
+
* import { commerce } from '@/lib/commerce'
|
|
9
|
+
* const products = await commerce.getProducts({ first: 20 })
|
|
11
10
|
*/
|
|
12
11
|
|
|
13
|
-
import { createProvider } from '@thorprovider/adapters'
|
|
14
|
-
import type {
|
|
15
|
-
import { isSupportedProviderType } from '@thorprovider/types'
|
|
16
|
-
import {
|
|
12
|
+
import { createProvider } from '@thorprovider/adapters'
|
|
13
|
+
import type { ProviderTypeString } from '@thorprovider/types'
|
|
14
|
+
import { isSupportedProviderType } from '@thorprovider/types'
|
|
15
|
+
import { isEnvConfigured } from './env'
|
|
17
16
|
|
|
18
|
-
|
|
19
|
-
function normalizeBackendUrl(value?: string): string | undefined {
|
|
20
|
-
if (!value) return undefined;
|
|
21
|
-
const trimmed = value.trim();
|
|
22
|
-
if (!trimmed) return undefined;
|
|
23
|
-
return trimmed.replace(/\/+$/, '');
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// Lazy singleton — only initialized on first access at runtime, never during build.
|
|
27
|
-
// This allows @thorprovider/core to compile as a package template without env variables present.
|
|
28
|
-
let _commerce: ReturnType<typeof createProvider> | undefined;
|
|
17
|
+
let _commerce: ReturnType<typeof createProvider> | undefined
|
|
29
18
|
|
|
30
19
|
function createCommerceInstance(): ReturnType<typeof createProvider> {
|
|
31
|
-
if (_commerce) return _commerce
|
|
20
|
+
if (_commerce) return _commerce
|
|
32
21
|
|
|
33
|
-
|
|
34
|
-
// Runs only at runtime on first use, not during static build.
|
|
35
|
-
getEnv();
|
|
36
|
-
|
|
37
|
-
const rawProviderType = process.env.NEXT_PUBLIC_COMMERCE_PROVIDER || 'medusa';
|
|
22
|
+
const rawProviderType = process.env.NEXT_PUBLIC_COMMERCE_PROVIDER || 'medusa'
|
|
38
23
|
if (!isSupportedProviderType(rawProviderType)) {
|
|
39
24
|
throw new Error(
|
|
40
|
-
`[
|
|
41
|
-
|
|
42
|
-
`Please set NEXT_PUBLIC_COMMERCE_PROVIDER="medusa" in your environment variables.`
|
|
43
|
-
);
|
|
25
|
+
`[commerce] Unsupported provider: "${rawProviderType}". Set NEXT_PUBLIC_COMMERCE_PROVIDER to a supported value.`
|
|
26
|
+
)
|
|
44
27
|
}
|
|
45
28
|
|
|
46
|
-
const providerType: ProviderTypeString = rawProviderType
|
|
47
|
-
const baseUrl =
|
|
48
|
-
const apiKey = process.env.NEXT_PUBLIC_COMMERCE_API_KEY
|
|
29
|
+
const providerType: ProviderTypeString = rawProviderType
|
|
30
|
+
const baseUrl = (process.env.NEXT_PUBLIC_COMMERCE_API_URL ?? '').replace(/\/+$/, '')
|
|
31
|
+
const apiKey = process.env.NEXT_PUBLIC_COMMERCE_API_KEY ?? ''
|
|
49
32
|
|
|
50
33
|
_commerce = createProvider({
|
|
51
34
|
provider: providerType,
|
|
52
35
|
config: {
|
|
53
|
-
baseUrl
|
|
36
|
+
baseUrl,
|
|
54
37
|
publishableKey: apiKey,
|
|
55
38
|
currencyCode: process.env.NEXT_PUBLIC_DEFAULT_CURRENCY || 'USD',
|
|
56
39
|
debug: process.env.NODE_ENV === 'development',
|
|
57
|
-
|
|
58
|
-
// Retry configuration - prevents "fetch failed" errors from temporary network issues
|
|
59
40
|
retry: {
|
|
60
|
-
maxRetries: 3,
|
|
61
|
-
timeoutMs: 10000,
|
|
62
|
-
initialDelayMs: 300,
|
|
63
|
-
backoffMultiplier: 2,
|
|
64
|
-
maxDelayMs: 5000,
|
|
41
|
+
maxRetries: 3,
|
|
42
|
+
timeoutMs: 10000,
|
|
43
|
+
initialDelayMs: 300,
|
|
44
|
+
backoffMultiplier: 2,
|
|
45
|
+
maxDelayMs: 5000,
|
|
65
46
|
},
|
|
66
|
-
|
|
67
|
-
// Authentication configuration
|
|
68
47
|
auth: {
|
|
69
|
-
method: 'jwt',
|
|
70
|
-
storage: 'localStorage',
|
|
48
|
+
method: 'jwt',
|
|
49
|
+
storage: 'localStorage',
|
|
71
50
|
},
|
|
72
|
-
|
|
73
|
-
// Admin API configuration (passed to @thorprovider/adapters for inventory + admin dashboard operations)
|
|
74
|
-
// Only configured when API key is present in env
|
|
75
|
-
adminConfig: process.env.COMMERCE_ADMIN_API_KEY
|
|
76
|
-
? {
|
|
77
|
-
apiKey: process.env.COMMERCE_ADMIN_API_KEY,
|
|
78
|
-
}
|
|
79
|
-
: undefined,
|
|
80
51
|
},
|
|
81
|
-
})
|
|
52
|
+
})
|
|
82
53
|
|
|
83
|
-
return _commerce
|
|
54
|
+
return _commerce
|
|
84
55
|
}
|
|
85
56
|
|
|
86
57
|
/**
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
* Transparent Proxy — defers instantiation (and env validation) until first method call.
|
|
90
|
-
* This allows @thorprovider/core to compile as a package template without environment variables.
|
|
91
|
-
*
|
|
92
|
-
* @example
|
|
93
|
-
* ```typescript
|
|
94
|
-
* import { commerce } from '@/lib/commerce';
|
|
95
|
-
*
|
|
96
|
-
* // Fetch products
|
|
97
|
-
* const products = await commerce.getProducts();
|
|
98
|
-
*
|
|
99
|
-
* // Create cart
|
|
100
|
-
* const cart = await commerce.createCart();
|
|
101
|
-
* ```
|
|
58
|
+
* Lazy commerce proxy — defers instantiation until first method call.
|
|
59
|
+
* Allows the template to compile without env variables (build/CI).
|
|
102
60
|
*/
|
|
103
61
|
export const commerce = new Proxy({} as ReturnType<typeof createProvider>, {
|
|
104
62
|
get(_target, prop: string | symbol) {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
if (!isEnvConfigured()) {
|
|
108
|
-
return undefined;
|
|
109
|
-
}
|
|
110
|
-
return createCommerceInstance()[prop as keyof ReturnType<typeof createProvider>];
|
|
63
|
+
if (!isEnvConfigured()) return undefined
|
|
64
|
+
return createCommerceInstance()[prop as keyof ReturnType<typeof createProvider>]
|
|
111
65
|
},
|
|
112
|
-
})
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Initialize storefront context on app startup.
|
|
116
|
-
*
|
|
117
|
-
* Validates that the storefront/sales channel is configured and reachable.
|
|
118
|
-
* For providers where storefront is mandatory (e.g. Medusa), a missing or
|
|
119
|
-
* invalid configuration will throw a `StorefrontConfigError`.
|
|
120
|
-
*
|
|
121
|
-
* MUST be called once before any commerce operation that depends on
|
|
122
|
-
* storefront isolation (product listing, cart creation, etc.).
|
|
123
|
-
*
|
|
124
|
-
* @returns StorefrontContext for the current storefront
|
|
125
|
-
* @throws {StorefrontConfigError} if configuration is invalid and required
|
|
126
|
-
*/
|
|
127
|
-
export async function initializeStorefront(): Promise<StorefrontContext> {
|
|
128
|
-
try {
|
|
129
|
-
const context = await commerce.getStorefrontContext();
|
|
130
|
-
return context;
|
|
131
|
-
} catch (error) {
|
|
132
|
-
if (commerce.isStorefrontRequired()) {
|
|
133
|
-
throw error;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
// Provider allows optional storefront; use safe defaults
|
|
137
|
-
const rawProvider = (process.env.NEXT_PUBLIC_COMMERCE_PROVIDER || 'medusa') as ProviderTypeString;
|
|
138
|
-
return {
|
|
139
|
-
id: 'default',
|
|
140
|
-
name: 'Default Storefront',
|
|
141
|
-
platformType: rawProvider,
|
|
142
|
-
requiresProductScoping: false,
|
|
143
|
-
currencyCode: process.env.NEXT_PUBLIC_DEFAULT_CURRENCY || 'USD',
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* Re-export types from @thorprovider/adapters for convenience
|
|
150
|
-
*/
|
|
151
|
-
export type {
|
|
152
|
-
Product,
|
|
153
|
-
ProductVariant,
|
|
154
|
-
Cart,
|
|
155
|
-
CartItem,
|
|
156
|
-
Collection,
|
|
157
|
-
BackendCapabilities,
|
|
158
|
-
CommerceProvider,
|
|
159
|
-
StorefrontContext,
|
|
160
|
-
} from '@thorprovider/adapters';
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* Re-export React provider and hooks
|
|
164
|
-
*/
|
|
165
|
-
export { ClientCommerceProvider, useCommerce, useCapabilities } from './commerce-provider';
|
|
66
|
+
})
|
|
@@ -1,113 +1,57 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Environment Variable Validation (Zod
|
|
2
|
+
* Environment Variable Validation (Zod)
|
|
3
3
|
*
|
|
4
|
-
* FROZEN:
|
|
5
|
-
* Changes
|
|
6
|
-
*
|
|
7
|
-
* Usage in components/lib/commerce.ts:
|
|
8
|
-
* import { env } from './env';
|
|
9
|
-
* const { baseUrl, apiKey } = env;
|
|
10
|
-
*
|
|
11
|
-
* The validated env object is re-exported at module scope to catch errors during build.
|
|
4
|
+
* FROZEN: Validates required environment variables at runtime.
|
|
5
|
+
* Changes require architecture review.
|
|
12
6
|
*/
|
|
13
7
|
|
|
14
|
-
import { z } from 'zod'
|
|
8
|
+
import { z } from 'zod'
|
|
15
9
|
|
|
16
|
-
/**
|
|
17
|
-
* Schema for environment variables
|
|
18
|
-
* Required vars: throw error on startup
|
|
19
|
-
* Optional vars: only validated if provided
|
|
20
|
-
*/
|
|
21
10
|
export const EnvSchema = z.object({
|
|
22
|
-
// Commerce Provider Configuration (REQUIRED)
|
|
23
11
|
NEXT_PUBLIC_COMMERCE_PROVIDER: z
|
|
24
12
|
.enum(['medusa', 'shopify', 'bigcommerce', 'custom'])
|
|
25
|
-
.default('medusa')
|
|
26
|
-
|
|
27
|
-
|
|
13
|
+
.default('medusa'),
|
|
14
|
+
|
|
28
15
|
NEXT_PUBLIC_COMMERCE_API_URL: z
|
|
29
16
|
.string()
|
|
30
|
-
.url()
|
|
31
|
-
|
|
32
|
-
|
|
17
|
+
.url(),
|
|
18
|
+
|
|
33
19
|
NEXT_PUBLIC_COMMERCE_API_KEY: z
|
|
34
20
|
.string()
|
|
35
|
-
.min(1)
|
|
36
|
-
.describe('Public API key for commerce backend'),
|
|
21
|
+
.min(1),
|
|
37
22
|
|
|
38
|
-
// Currency (REQUIRED — defaults to USD)
|
|
39
23
|
NEXT_PUBLIC_DEFAULT_CURRENCY: z
|
|
40
24
|
.string()
|
|
41
|
-
.default('USD')
|
|
42
|
-
.describe('Default currency code (e.g., "USD", "EUR")'),
|
|
43
|
-
|
|
44
|
-
// Health Check (OPTIONAL — used by proxy.ts circuit breaker)
|
|
45
|
-
HEALTH_CHECK_PATH: z
|
|
46
|
-
.string()
|
|
47
|
-
.default('/store/regions')
|
|
48
|
-
.describe('Path used by proxy.ts to verify backend availability'),
|
|
25
|
+
.default('USD'),
|
|
49
26
|
|
|
50
|
-
// Sales Channel (OPTIONAL — multi-tenant stores)
|
|
51
27
|
NEXT_PUBLIC_SALES_CHANNEL_ID: z
|
|
52
28
|
.string()
|
|
53
|
-
.optional()
|
|
54
|
-
.describe('Sales channel ID for multi-tenant stores (required for Medusa)'),
|
|
55
|
-
|
|
56
|
-
// Admin API (OPTIONAL)
|
|
57
|
-
COMMERCE_ADMIN_EMAIL: z
|
|
58
|
-
.string()
|
|
59
|
-
.email()
|
|
60
|
-
.optional()
|
|
61
|
-
.describe('Admin email for backend admin API'),
|
|
62
|
-
|
|
63
|
-
COMMERCE_ADMIN_PASSWORD: z
|
|
64
|
-
.string()
|
|
65
|
-
.min(1)
|
|
66
|
-
.optional()
|
|
67
|
-
.describe('Admin password for backend admin API'),
|
|
68
|
-
|
|
69
|
-
COMMERCE_ADMIN_API_URL: z
|
|
70
|
-
.string()
|
|
71
|
-
.url()
|
|
72
|
-
.optional()
|
|
73
|
-
.describe('Commerce backend admin API URL (defaults to NEXT_PUBLIC_COMMERCE_API_URL)'),
|
|
29
|
+
.optional(),
|
|
74
30
|
|
|
75
|
-
COMMERCE_ADMIN_TOKEN_TTL_MS: z
|
|
76
|
-
.string()
|
|
77
|
-
.optional()
|
|
78
|
-
.transform(v => v ? Number.parseInt(v, 10) : undefined)
|
|
79
|
-
.describe('Admin token TTL in milliseconds'),
|
|
80
|
-
|
|
81
|
-
// Webhook Revalidation (OPTIONAL)
|
|
82
31
|
FRONTEND_WEBHOOK_SECRET: z
|
|
83
32
|
.string()
|
|
84
|
-
.optional()
|
|
85
|
-
|
|
86
|
-
});
|
|
33
|
+
.optional(),
|
|
34
|
+
})
|
|
87
35
|
|
|
88
|
-
export type Env = z.infer<typeof EnvSchema
|
|
36
|
+
export type Env = z.infer<typeof EnvSchema>
|
|
89
37
|
|
|
90
38
|
/**
|
|
91
39
|
* Check whether required commerce env vars are present.
|
|
92
|
-
* Used to bail out gracefully during build/SSG
|
|
40
|
+
* Used to bail out gracefully during build/SSG.
|
|
93
41
|
*/
|
|
94
42
|
export function isEnvConfigured(): boolean {
|
|
95
43
|
return Boolean(
|
|
96
44
|
process.env.NEXT_PUBLIC_COMMERCE_API_URL &&
|
|
97
45
|
process.env.NEXT_PUBLIC_COMMERCE_API_KEY
|
|
98
|
-
)
|
|
46
|
+
)
|
|
99
47
|
}
|
|
100
48
|
|
|
101
49
|
/**
|
|
102
50
|
* Validate and return environment variables.
|
|
103
|
-
* Throws detailed error if validation fails
|
|
51
|
+
* Throws detailed Zod error if validation fails.
|
|
104
52
|
*
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
* Passing the whole process.env object to Zod would break client-side validation
|
|
108
|
-
* because Next.js only inlines individual property accesses.
|
|
109
|
-
*
|
|
110
|
-
* @throws {Error} if required env vars are missing or invalid
|
|
53
|
+
* NOTE: Each var is referenced individually so Next.js can
|
|
54
|
+
* statically replace NEXT_PUBLIC_* in the client bundle.
|
|
111
55
|
*/
|
|
112
56
|
export function getEnv(): Env {
|
|
113
57
|
try {
|
|
@@ -116,32 +60,18 @@ export function getEnv(): Env {
|
|
|
116
60
|
NEXT_PUBLIC_COMMERCE_API_URL: process.env.NEXT_PUBLIC_COMMERCE_API_URL,
|
|
117
61
|
NEXT_PUBLIC_COMMERCE_API_KEY: process.env.NEXT_PUBLIC_COMMERCE_API_KEY,
|
|
118
62
|
NEXT_PUBLIC_DEFAULT_CURRENCY: process.env.NEXT_PUBLIC_DEFAULT_CURRENCY,
|
|
119
|
-
HEALTH_CHECK_PATH: process.env.HEALTH_CHECK_PATH,
|
|
120
63
|
NEXT_PUBLIC_SALES_CHANNEL_ID: process.env.NEXT_PUBLIC_SALES_CHANNEL_ID,
|
|
121
|
-
COMMERCE_ADMIN_EMAIL: process.env.COMMERCE_ADMIN_EMAIL,
|
|
122
|
-
COMMERCE_ADMIN_PASSWORD: process.env.COMMERCE_ADMIN_PASSWORD,
|
|
123
|
-
COMMERCE_ADMIN_API_URL: process.env.COMMERCE_ADMIN_API_URL,
|
|
124
|
-
COMMERCE_ADMIN_TOKEN_TTL_MS: process.env.COMMERCE_ADMIN_TOKEN_TTL_MS,
|
|
125
64
|
FRONTEND_WEBHOOK_SECRET: process.env.FRONTEND_WEBHOOK_SECRET,
|
|
126
|
-
})
|
|
65
|
+
})
|
|
127
66
|
} catch (error) {
|
|
128
67
|
if (error instanceof z.ZodError) {
|
|
129
68
|
const issues = error.issues
|
|
130
69
|
.map(issue => ` - ${issue.path.join('.')}: ${issue.message}`)
|
|
131
|
-
.join('\n')
|
|
70
|
+
.join('\n')
|
|
132
71
|
throw new Error(
|
|
133
|
-
`Invalid environment variables:\n${issues}\n\
|
|
134
|
-
|
|
135
|
-
);
|
|
72
|
+
`Invalid environment variables:\n${issues}\n\nSee .env.example for correct format.`
|
|
73
|
+
)
|
|
136
74
|
}
|
|
137
|
-
throw error
|
|
75
|
+
throw error
|
|
138
76
|
}
|
|
139
77
|
}
|
|
140
|
-
|
|
141
|
-
// Lazy getter — call getEnv() at runtime, not at module scope (avoids build-time failures
|
|
142
|
-
// when @thorprovider/core is compiled as a package template without environment variables).
|
|
143
|
-
export const env: Env = new Proxy({} as Env, {
|
|
144
|
-
get(_target, prop: string | symbol) {
|
|
145
|
-
return getEnv()[prop as keyof Env];
|
|
146
|
-
},
|
|
147
|
-
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { clsx, type ClassValue } from 'clsx'
|
|
2
2
|
import { twMerge } from 'tailwind-merge'
|
|
3
|
+
import type { Money } from '@thorprovider/types'
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Merge Tailwind CSS class names safely.
|
|
@@ -8,3 +9,20 @@ import { twMerge } from 'tailwind-merge'
|
|
|
8
9
|
export function cn(...inputs: ClassValue[]) {
|
|
9
10
|
return twMerge(clsx(inputs))
|
|
10
11
|
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Format a Money object for display.
|
|
15
|
+
*
|
|
16
|
+
* Money.amount is a DECIMAL STRING (e.g. "29.99", NOT cents).
|
|
17
|
+
* This function converts it to a locale-formatted currency string.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* formatPrice({ amount: "29.99", currencyCode: "USD" }) // "$29.99"
|
|
21
|
+
* formatPrice({ amount: "1499.00", currencyCode: "EUR" }) // "€1,499.00"
|
|
22
|
+
*/
|
|
23
|
+
export function formatPrice(money: Money, locale = 'en-US'): string {
|
|
24
|
+
return new Intl.NumberFormat(locale, {
|
|
25
|
+
style: 'currency',
|
|
26
|
+
currency: money.currencyCode,
|
|
27
|
+
}).format(parseFloat(money.amount))
|
|
28
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="next" />
|
|
2
2
|
/// <reference types="next/image-types/global" />
|
|
3
|
-
import "./.next/types/routes.d.ts";
|
|
3
|
+
import "./.next/dev/types/routes.d.ts";
|
|
4
4
|
|
|
5
5
|
// NOTE: This file should not be edited
|
|
6
6
|
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
|
|
@@ -1,21 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thorprovider/core",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "Thor Commerce
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "Thor Commerce V0-native template. Lean storefront scaffold for V0 AI code generation.",
|
|
5
5
|
"scripts": {
|
|
6
|
-
"prebuild": "PACKAGE_DIR=packages/core tsx ../../scripts/generate-regions-config.ts",
|
|
7
6
|
"build": "next build",
|
|
8
|
-
"predev": "PACKAGE_DIR=packages/core tsx ../../scripts/generate-regions-config.ts",
|
|
9
7
|
"dev": "next dev",
|
|
10
8
|
"start": "next start",
|
|
11
9
|
"type-check": "tsc --noEmit",
|
|
12
|
-
"generate:regions": "PACKAGE_DIR=packages/core tsx ../../scripts/generate-regions-config.ts",
|
|
13
10
|
"generate:agent-index": "node ../../scripts/generate-core-agents-index.cjs"
|
|
14
11
|
},
|
|
15
12
|
"dependencies": {
|
|
16
13
|
"@thorprovider/adapters": "^4.0.0",
|
|
17
|
-
"@thorprovider/components": "^2.0.0",
|
|
18
|
-
"@thorprovider/providers": "^2.0.0",
|
|
19
14
|
"@thorprovider/types": "^3.0.0",
|
|
20
15
|
"clsx": "^2.1.1",
|
|
21
16
|
"next": "16.0.10",
|
|
@@ -31,7 +26,6 @@
|
|
|
31
26
|
"@types/react-dom": "^19",
|
|
32
27
|
"postcss": "^8.5",
|
|
33
28
|
"tailwindcss": "^4.1.9",
|
|
34
|
-
"tsx": "^4.19.2",
|
|
35
29
|
"tw-animate-css": "1.3.3",
|
|
36
30
|
"typescript": "^5"
|
|
37
31
|
},
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Design Tokens — shadcn/ui CSS variable naming convention.
|
|
3
|
+
*
|
|
4
|
+
* SWAP THIS FILE to rebrand a client project.
|
|
5
|
+
* Components never reference colors directly — only these tokens.
|
|
6
|
+
*
|
|
7
|
+
* To customize for a client:
|
|
8
|
+
* 1. Replace oklch values below with the client's brand palette.
|
|
9
|
+
* 2. No component files need to change.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
:root {
|
|
13
|
+
--background: oklch(0.98 0.002 90);
|
|
14
|
+
--foreground: oklch(0.15 0 0);
|
|
15
|
+
--card: oklch(1 0 0);
|
|
16
|
+
--card-foreground: oklch(0.15 0 0);
|
|
17
|
+
--popover: oklch(1 0 0);
|
|
18
|
+
--popover-foreground: oklch(0.15 0 0);
|
|
19
|
+
--primary: oklch(0.15 0 0);
|
|
20
|
+
--primary-foreground: oklch(0.98 0.002 90);
|
|
21
|
+
--secondary: oklch(0.96 0.003 90);
|
|
22
|
+
--secondary-foreground: oklch(0.15 0 0);
|
|
23
|
+
--muted: oklch(0.94 0.003 90);
|
|
24
|
+
--muted-foreground: oklch(0.45 0 0);
|
|
25
|
+
--accent: oklch(0.65 0.15 25);
|
|
26
|
+
--accent-foreground: oklch(1 0 0);
|
|
27
|
+
--destructive: oklch(0.55 0.2 25);
|
|
28
|
+
--destructive-foreground: oklch(1 0 0);
|
|
29
|
+
--border: oklch(0.88 0.003 90);
|
|
30
|
+
--input: oklch(0.92 0.003 90);
|
|
31
|
+
--ring: oklch(0.15 0 0);
|
|
32
|
+
--chart-1: oklch(0.646 0.222 41.116);
|
|
33
|
+
--chart-2: oklch(0.6 0.118 184.704);
|
|
34
|
+
--chart-3: oklch(0.398 0.07 227.392);
|
|
35
|
+
--chart-4: oklch(0.828 0.189 84.429);
|
|
36
|
+
--chart-5: oklch(0.769 0.188 70.08);
|
|
37
|
+
--radius: 0.375rem;
|
|
38
|
+
--sidebar: oklch(0.985 0 0);
|
|
39
|
+
--sidebar-foreground: oklch(0.145 0 0);
|
|
40
|
+
--sidebar-primary: oklch(0.205 0 0);
|
|
41
|
+
--sidebar-primary-foreground: oklch(0.985 0 0);
|
|
42
|
+
--sidebar-accent: oklch(0.97 0 0);
|
|
43
|
+
--sidebar-accent-foreground: oklch(0.205 0 0);
|
|
44
|
+
--sidebar-border: oklch(0.922 0 0);
|
|
45
|
+
--sidebar-ring: oklch(0.708 0 0);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.dark {
|
|
49
|
+
--background: oklch(0.145 0 0);
|
|
50
|
+
--foreground: oklch(0.985 0 0);
|
|
51
|
+
--card: oklch(0.145 0 0);
|
|
52
|
+
--card-foreground: oklch(0.985 0 0);
|
|
53
|
+
--popover: oklch(0.145 0 0);
|
|
54
|
+
--popover-foreground: oklch(0.985 0 0);
|
|
55
|
+
--primary: oklch(0.985 0 0);
|
|
56
|
+
--primary-foreground: oklch(0.205 0 0);
|
|
57
|
+
--secondary: oklch(0.269 0 0);
|
|
58
|
+
--secondary-foreground: oklch(0.985 0 0);
|
|
59
|
+
--muted: oklch(0.269 0 0);
|
|
60
|
+
--muted-foreground: oklch(0.708 0 0);
|
|
61
|
+
--accent: oklch(0.269 0 0);
|
|
62
|
+
--accent-foreground: oklch(0.985 0 0);
|
|
63
|
+
--destructive: oklch(0.396 0.141 25.723);
|
|
64
|
+
--destructive-foreground: oklch(0.637 0.237 25.331);
|
|
65
|
+
--border: oklch(0.269 0 0);
|
|
66
|
+
--input: oklch(0.269 0 0);
|
|
67
|
+
--ring: oklch(0.439 0 0);
|
|
68
|
+
--chart-1: oklch(0.488 0.243 264.376);
|
|
69
|
+
--chart-2: oklch(0.696 0.17 162.48);
|
|
70
|
+
--chart-3: oklch(0.769 0.188 70.08);
|
|
71
|
+
--chart-4: oklch(0.627 0.265 303.9);
|
|
72
|
+
--chart-5: oklch(0.645 0.246 16.439);
|
|
73
|
+
--sidebar: oklch(0.205 0 0);
|
|
74
|
+
--sidebar-foreground: oklch(0.985 0 0);
|
|
75
|
+
--sidebar-primary: oklch(0.488 0.243 264.376);
|
|
76
|
+
--sidebar-primary-foreground: oklch(0.985 0 0);
|
|
77
|
+
--sidebar-accent: oklch(0.269 0 0);
|
|
78
|
+
--sidebar-accent-foreground: oklch(0.985 0 0);
|
|
79
|
+
--sidebar-border: oklch(0.269 0 0);
|
|
80
|
+
--sidebar-ring: oklch(0.439 0 0);
|
|
81
|
+
}
|
|
@@ -1,37 +0,0 @@
|
|
|
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
|
-
}
|