@dheme/react 2.0.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 +393 -0
- package/dist/index.d.mts +68 -0
- package/dist/index.d.ts +68 -0
- package/dist/index.js +476 -0
- package/dist/index.mjs +425 -0
- package/package.json +63 -0
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,425 @@
|
|
|
1
|
+
// src/components/DhemeProvider.tsx
|
|
2
|
+
import React, { useState, useEffect, useCallback, useMemo, useRef } from "react";
|
|
3
|
+
import { DhemeClient } from "@dheme/sdk";
|
|
4
|
+
|
|
5
|
+
// src/contexts/ThemeDataContext.ts
|
|
6
|
+
import { createContext } from "react";
|
|
7
|
+
var ThemeDataContext = createContext(null);
|
|
8
|
+
|
|
9
|
+
// src/contexts/ThemeActionsContext.ts
|
|
10
|
+
import { createContext as createContext2 } from "react";
|
|
11
|
+
var ThemeActionsContext = createContext2(null);
|
|
12
|
+
|
|
13
|
+
// src/constants.ts
|
|
14
|
+
var STORAGE_KEY_PREFIX = "dheme-cache";
|
|
15
|
+
var STORAGE_PARAMS_KEY = "dheme-params";
|
|
16
|
+
var STORAGE_MODE_KEY = "dheme-mode";
|
|
17
|
+
var CSS_TOKEN_KEYS = [
|
|
18
|
+
"background",
|
|
19
|
+
"foreground",
|
|
20
|
+
"card",
|
|
21
|
+
"cardForeground",
|
|
22
|
+
"popover",
|
|
23
|
+
"popoverForeground",
|
|
24
|
+
"primary",
|
|
25
|
+
"primaryForeground",
|
|
26
|
+
"secondary",
|
|
27
|
+
"secondaryForeground",
|
|
28
|
+
"muted",
|
|
29
|
+
"mutedForeground",
|
|
30
|
+
"accent",
|
|
31
|
+
"accentForeground",
|
|
32
|
+
"destructive",
|
|
33
|
+
"destructiveForeground",
|
|
34
|
+
"border",
|
|
35
|
+
"input",
|
|
36
|
+
"ring"
|
|
37
|
+
];
|
|
38
|
+
var TOKEN_TO_CSS_VAR = {
|
|
39
|
+
background: "--background",
|
|
40
|
+
foreground: "--foreground",
|
|
41
|
+
card: "--card",
|
|
42
|
+
cardForeground: "--card-foreground",
|
|
43
|
+
popover: "--popover",
|
|
44
|
+
popoverForeground: "--popover-foreground",
|
|
45
|
+
primary: "--primary",
|
|
46
|
+
primaryForeground: "--primary-foreground",
|
|
47
|
+
secondary: "--secondary",
|
|
48
|
+
secondaryForeground: "--secondary-foreground",
|
|
49
|
+
muted: "--muted",
|
|
50
|
+
mutedForeground: "--muted-foreground",
|
|
51
|
+
accent: "--accent",
|
|
52
|
+
accentForeground: "--accent-foreground",
|
|
53
|
+
destructive: "--destructive",
|
|
54
|
+
destructiveForeground: "--destructive-foreground",
|
|
55
|
+
border: "--border",
|
|
56
|
+
input: "--input",
|
|
57
|
+
ring: "--ring"
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
// src/utils/cssVariables.ts
|
|
61
|
+
function formatHSL(color) {
|
|
62
|
+
return `${color.h} ${color.s}% ${color.l}%`;
|
|
63
|
+
}
|
|
64
|
+
function themeToCSS(theme, mode) {
|
|
65
|
+
const colors = theme.colors[mode];
|
|
66
|
+
if (!colors) return "";
|
|
67
|
+
const parts = [];
|
|
68
|
+
for (const key of CSS_TOKEN_KEYS) {
|
|
69
|
+
const color = colors[key];
|
|
70
|
+
if (color) {
|
|
71
|
+
parts.push(`${TOKEN_TO_CSS_VAR[key]}:${formatHSL(color)}`);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
if (theme.radius != null) {
|
|
75
|
+
parts.push(`--radius:${theme.radius}rem`);
|
|
76
|
+
}
|
|
77
|
+
return parts.join(";");
|
|
78
|
+
}
|
|
79
|
+
function themeToCSSBothModes(theme) {
|
|
80
|
+
const lightCSS = themeToCSS(theme, "light");
|
|
81
|
+
const darkCSS = themeToCSS(theme, "dark");
|
|
82
|
+
return `:root{${lightCSS}}.dark{${darkCSS}}`;
|
|
83
|
+
}
|
|
84
|
+
function applyThemeCSSVariables(theme, mode) {
|
|
85
|
+
if (typeof document === "undefined") return;
|
|
86
|
+
const colors = theme.colors[mode];
|
|
87
|
+
if (!colors) return;
|
|
88
|
+
const style = document.documentElement.style;
|
|
89
|
+
for (const key of CSS_TOKEN_KEYS) {
|
|
90
|
+
const color = colors[key];
|
|
91
|
+
if (color) {
|
|
92
|
+
style.setProperty(TOKEN_TO_CSS_VAR[key], formatHSL(color));
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
if (theme.radius != null) {
|
|
96
|
+
style.setProperty("--radius", `${theme.radius}rem`);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
function removeThemeCSSVariables() {
|
|
100
|
+
if (typeof document === "undefined") return;
|
|
101
|
+
const style = document.documentElement.style;
|
|
102
|
+
for (const key of CSS_TOKEN_KEYS) {
|
|
103
|
+
style.removeProperty(TOKEN_TO_CSS_VAR[key]);
|
|
104
|
+
}
|
|
105
|
+
style.removeProperty("--radius");
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// src/utils/cacheKey.ts
|
|
109
|
+
function buildCacheKey(params) {
|
|
110
|
+
const normalized = {
|
|
111
|
+
t: params.theme.toLowerCase().replace("#", ""),
|
|
112
|
+
s: (params.secondaryColor || "").toLowerCase().replace("#", ""),
|
|
113
|
+
r: params.radius ?? 0.5,
|
|
114
|
+
sa: params.saturationAdjust ?? 0,
|
|
115
|
+
la: params.lightnessAdjust ?? 0,
|
|
116
|
+
ca: params.contrastAdjust ?? 0,
|
|
117
|
+
ci: params.cardIsColored ?? false,
|
|
118
|
+
bi: params.backgroundIsColored ?? true
|
|
119
|
+
};
|
|
120
|
+
return JSON.stringify(normalized);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// src/utils/storage.ts
|
|
124
|
+
var memoryCache = /* @__PURE__ */ new Map();
|
|
125
|
+
function getItem(key) {
|
|
126
|
+
if (memoryCache.has(key)) return memoryCache.get(key);
|
|
127
|
+
try {
|
|
128
|
+
if (typeof window === "undefined") return null;
|
|
129
|
+
const value = localStorage.getItem(key);
|
|
130
|
+
if (value !== null) memoryCache.set(key, value);
|
|
131
|
+
return value;
|
|
132
|
+
} catch {
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
function setItem(key, value) {
|
|
137
|
+
memoryCache.set(key, value);
|
|
138
|
+
try {
|
|
139
|
+
if (typeof window !== "undefined") {
|
|
140
|
+
localStorage.setItem(key, value);
|
|
141
|
+
}
|
|
142
|
+
} catch {
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
function removeItem(key) {
|
|
146
|
+
memoryCache.delete(key);
|
|
147
|
+
try {
|
|
148
|
+
if (typeof window !== "undefined") {
|
|
149
|
+
localStorage.removeItem(key);
|
|
150
|
+
}
|
|
151
|
+
} catch {
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
function saveThemeToCache(cacheKey, theme) {
|
|
155
|
+
setItem(`${STORAGE_KEY_PREFIX}:${cacheKey}`, JSON.stringify(theme));
|
|
156
|
+
}
|
|
157
|
+
function loadThemeFromCache(cacheKey) {
|
|
158
|
+
const raw = getItem(`${STORAGE_KEY_PREFIX}:${cacheKey}`);
|
|
159
|
+
if (!raw) return null;
|
|
160
|
+
try {
|
|
161
|
+
return JSON.parse(raw);
|
|
162
|
+
} catch {
|
|
163
|
+
return null;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
function saveCurrentParams(params) {
|
|
167
|
+
setItem(STORAGE_PARAMS_KEY, JSON.stringify(params));
|
|
168
|
+
}
|
|
169
|
+
function saveMode(mode) {
|
|
170
|
+
setItem(STORAGE_MODE_KEY, mode);
|
|
171
|
+
}
|
|
172
|
+
function loadMode() {
|
|
173
|
+
const raw = getItem(STORAGE_MODE_KEY);
|
|
174
|
+
if (raw === "light" || raw === "dark") return raw;
|
|
175
|
+
return null;
|
|
176
|
+
}
|
|
177
|
+
function clearAll() {
|
|
178
|
+
removeItem(STORAGE_PARAMS_KEY);
|
|
179
|
+
removeItem(STORAGE_MODE_KEY);
|
|
180
|
+
const keysToRemove = [];
|
|
181
|
+
memoryCache.forEach((_, key) => {
|
|
182
|
+
if (key.startsWith(STORAGE_KEY_PREFIX + ":")) {
|
|
183
|
+
keysToRemove.push(key);
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
keysToRemove.forEach(removeItem);
|
|
187
|
+
try {
|
|
188
|
+
if (typeof window !== "undefined") {
|
|
189
|
+
const len = localStorage.length;
|
|
190
|
+
for (let i = len - 1; i >= 0; i--) {
|
|
191
|
+
const key = localStorage.key(i);
|
|
192
|
+
if (key && key.startsWith(STORAGE_KEY_PREFIX + ":")) {
|
|
193
|
+
localStorage.removeItem(key);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
} catch {
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
// src/components/DhemeProvider.tsx
|
|
202
|
+
function DhemeProvider({
|
|
203
|
+
apiKey,
|
|
204
|
+
theme: primaryColor,
|
|
205
|
+
themeParams,
|
|
206
|
+
defaultMode = "light",
|
|
207
|
+
baseUrl,
|
|
208
|
+
persist = true,
|
|
209
|
+
autoApply = true,
|
|
210
|
+
onThemeChange,
|
|
211
|
+
onModeChange,
|
|
212
|
+
onError,
|
|
213
|
+
children
|
|
214
|
+
}) {
|
|
215
|
+
const client = useMemo(() => new DhemeClient({ apiKey, baseUrl }), [apiKey, baseUrl]);
|
|
216
|
+
const [theme, setTheme] = useState(null);
|
|
217
|
+
const [mode, setModeState] = useState(() => {
|
|
218
|
+
if (typeof window === "undefined") return defaultMode;
|
|
219
|
+
return loadMode() || defaultMode;
|
|
220
|
+
});
|
|
221
|
+
const [isReady, setIsReady] = useState(false);
|
|
222
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
223
|
+
const [error, setError] = useState(null);
|
|
224
|
+
const modeRef = useRef(mode);
|
|
225
|
+
modeRef.current = mode;
|
|
226
|
+
const autoApplyRef = useRef(autoApply);
|
|
227
|
+
autoApplyRef.current = autoApply;
|
|
228
|
+
const persistRef = useRef(persist);
|
|
229
|
+
persistRef.current = persist;
|
|
230
|
+
const onThemeChangeRef = useRef(onThemeChange);
|
|
231
|
+
onThemeChangeRef.current = onThemeChange;
|
|
232
|
+
const onModeChangeRef = useRef(onModeChange);
|
|
233
|
+
onModeChangeRef.current = onModeChange;
|
|
234
|
+
const onErrorRef = useRef(onError);
|
|
235
|
+
onErrorRef.current = onError;
|
|
236
|
+
const abortRef = useRef(null);
|
|
237
|
+
const setMode = useCallback((newMode) => {
|
|
238
|
+
setModeState(newMode);
|
|
239
|
+
if (persistRef.current) saveMode(newMode);
|
|
240
|
+
onModeChangeRef.current?.(newMode);
|
|
241
|
+
}, []);
|
|
242
|
+
useEffect(() => {
|
|
243
|
+
if (theme && autoApply) {
|
|
244
|
+
applyThemeCSSVariables(theme, mode);
|
|
245
|
+
}
|
|
246
|
+
if (typeof document !== "undefined") {
|
|
247
|
+
if (mode === "dark") {
|
|
248
|
+
document.documentElement.classList.add("dark");
|
|
249
|
+
} else {
|
|
250
|
+
document.documentElement.classList.remove("dark");
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}, [theme, mode, autoApply]);
|
|
254
|
+
const generateTheme = useCallback(
|
|
255
|
+
async (params) => {
|
|
256
|
+
abortRef.current?.abort();
|
|
257
|
+
setIsLoading(true);
|
|
258
|
+
setError(null);
|
|
259
|
+
try {
|
|
260
|
+
const response = await client.generateTheme(params);
|
|
261
|
+
const data = response.data;
|
|
262
|
+
setTheme(data);
|
|
263
|
+
setIsReady(true);
|
|
264
|
+
if (autoApplyRef.current) {
|
|
265
|
+
applyThemeCSSVariables(data, modeRef.current);
|
|
266
|
+
}
|
|
267
|
+
if (persistRef.current) {
|
|
268
|
+
const key = buildCacheKey(params);
|
|
269
|
+
saveThemeToCache(key, data);
|
|
270
|
+
saveCurrentParams(params);
|
|
271
|
+
}
|
|
272
|
+
onThemeChangeRef.current?.(data);
|
|
273
|
+
} catch (err) {
|
|
274
|
+
const error2 = err instanceof Error ? err : new Error(String(err));
|
|
275
|
+
setError(error2);
|
|
276
|
+
onErrorRef.current?.(error2);
|
|
277
|
+
} finally {
|
|
278
|
+
setIsLoading(false);
|
|
279
|
+
}
|
|
280
|
+
},
|
|
281
|
+
[client]
|
|
282
|
+
);
|
|
283
|
+
const clearTheme = useCallback(() => {
|
|
284
|
+
setTheme(null);
|
|
285
|
+
setIsReady(false);
|
|
286
|
+
setError(null);
|
|
287
|
+
if (autoApplyRef.current) removeThemeCSSVariables();
|
|
288
|
+
if (persistRef.current) clearAll();
|
|
289
|
+
}, []);
|
|
290
|
+
useEffect(() => {
|
|
291
|
+
if (!primaryColor) return;
|
|
292
|
+
const params = {
|
|
293
|
+
theme: primaryColor,
|
|
294
|
+
...themeParams
|
|
295
|
+
};
|
|
296
|
+
const cacheKey = buildCacheKey(params);
|
|
297
|
+
const cached = persist ? loadThemeFromCache(cacheKey) : null;
|
|
298
|
+
if (cached) {
|
|
299
|
+
setTheme(cached);
|
|
300
|
+
setIsReady(true);
|
|
301
|
+
if (autoApply) applyThemeCSSVariables(cached, mode);
|
|
302
|
+
const controller = new AbortController();
|
|
303
|
+
abortRef.current = controller;
|
|
304
|
+
client.generateTheme(params).then((response) => {
|
|
305
|
+
if (controller.signal.aborted) return;
|
|
306
|
+
const data = response.data;
|
|
307
|
+
const cachedLight = JSON.stringify(cached.colors.light);
|
|
308
|
+
const freshLight = JSON.stringify(data.colors.light);
|
|
309
|
+
if (cachedLight !== freshLight) {
|
|
310
|
+
setTheme(data);
|
|
311
|
+
if (autoApply) applyThemeCSSVariables(data, modeRef.current);
|
|
312
|
+
saveThemeToCache(cacheKey, data);
|
|
313
|
+
onThemeChangeRef.current?.(data);
|
|
314
|
+
}
|
|
315
|
+
}).catch(() => {
|
|
316
|
+
});
|
|
317
|
+
} else {
|
|
318
|
+
generateTheme(params);
|
|
319
|
+
}
|
|
320
|
+
return () => {
|
|
321
|
+
abortRef.current?.abort();
|
|
322
|
+
};
|
|
323
|
+
}, []);
|
|
324
|
+
const themeDataValue = useMemo(() => ({ theme, mode, isReady }), [theme, mode, isReady]);
|
|
325
|
+
const themeActionsValue = useMemo(
|
|
326
|
+
() => ({ generateTheme, setMode, clearTheme, isLoading, error, client }),
|
|
327
|
+
[generateTheme, setMode, clearTheme, isLoading, error, client]
|
|
328
|
+
);
|
|
329
|
+
return React.createElement(
|
|
330
|
+
ThemeDataContext.Provider,
|
|
331
|
+
{ value: themeDataValue },
|
|
332
|
+
React.createElement(ThemeActionsContext.Provider, { value: themeActionsValue }, children)
|
|
333
|
+
);
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
// src/components/DhemeScript.tsx
|
|
337
|
+
import React2 from "react";
|
|
338
|
+
|
|
339
|
+
// src/utils/scriptPayload.ts
|
|
340
|
+
function getBlockingScriptPayload(defaultMode) {
|
|
341
|
+
return `(function(){try{var p=localStorage.getItem('dheme-params');if(!p)return;var params=JSON.parse(p);var n={t:(params.theme||'').toLowerCase().replace('#',''),s:(params.secondaryColor||'').toLowerCase().replace('#',''),r:params.radius!=null?params.radius:0.5,sa:params.saturationAdjust||0,la:params.lightnessAdjust||0,ca:params.contrastAdjust||0,ci:!!params.cardIsColored,bi:params.backgroundIsColored!=null?params.backgroundIsColored:true};var key='dheme-cache:'+JSON.stringify(n);var c=localStorage.getItem(key);if(!c)return;var theme=JSON.parse(c);var mode=localStorage.getItem('dheme-mode')||'${defaultMode}';var colors=theme.colors[mode];if(!colors)return;var d=document.documentElement.style;var m={background:'--background',foreground:'--foreground',card:'--card',cardForeground:'--card-foreground',popover:'--popover',popoverForeground:'--popover-foreground',primary:'--primary',primaryForeground:'--primary-foreground',secondary:'--secondary',secondaryForeground:'--secondary-foreground',muted:'--muted',mutedForeground:'--muted-foreground',accent:'--accent',accentForeground:'--accent-foreground',destructive:'--destructive',destructiveForeground:'--destructive-foreground',border:'--border',input:'--input',ring:'--ring'};for(var k in m){if(colors[k]){var v=colors[k];d.setProperty(m[k],v.h+' '+v.s+'% '+v.l+'%')}}if(theme.radius!=null)d.setProperty('--radius',theme.radius+'rem');if(mode==='dark')document.documentElement.classList.add('dark');else document.documentElement.classList.remove('dark')}catch(e){}})()`;
|
|
342
|
+
}
|
|
343
|
+
function getNextBlockingScriptPayload(defaultMode) {
|
|
344
|
+
return `(function(){try{var m=document.cookie.match(/dheme-mode=(\\w+)/);var mode=m?m[1]:null;if(!mode){mode=window.matchMedia('(prefers-color-scheme: dark)').matches?'dark':'${defaultMode}'}if(mode==='dark'){document.documentElement.classList.add('dark')}else{document.documentElement.classList.remove('dark')}}catch(e){}})()`;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
// src/components/DhemeScript.tsx
|
|
348
|
+
function DhemeScript({
|
|
349
|
+
defaultMode = "light",
|
|
350
|
+
nonce
|
|
351
|
+
}) {
|
|
352
|
+
const scriptContent = getBlockingScriptPayload(defaultMode);
|
|
353
|
+
return React2.createElement("script", {
|
|
354
|
+
nonce,
|
|
355
|
+
dangerouslySetInnerHTML: { __html: scriptContent }
|
|
356
|
+
});
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
// src/hooks/useTheme.ts
|
|
360
|
+
import { useContext } from "react";
|
|
361
|
+
function useTheme() {
|
|
362
|
+
const context = useContext(ThemeDataContext);
|
|
363
|
+
if (!context) {
|
|
364
|
+
throw new Error("useTheme must be used within a <DhemeProvider>");
|
|
365
|
+
}
|
|
366
|
+
return context;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
// src/hooks/useThemeActions.ts
|
|
370
|
+
import { useContext as useContext2 } from "react";
|
|
371
|
+
function useThemeActions() {
|
|
372
|
+
const context = useContext2(ThemeActionsContext);
|
|
373
|
+
if (!context) {
|
|
374
|
+
throw new Error("useThemeActions must be used within a <DhemeProvider>");
|
|
375
|
+
}
|
|
376
|
+
return context;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
// src/hooks/useGenerateTheme.ts
|
|
380
|
+
import { useState as useState2, useCallback as useCallback2 } from "react";
|
|
381
|
+
function useGenerateTheme() {
|
|
382
|
+
const { generateTheme: generate } = useThemeActions();
|
|
383
|
+
const [isGenerating, setIsGenerating] = useState2(false);
|
|
384
|
+
const [error, setError] = useState2(null);
|
|
385
|
+
const generateTheme = useCallback2(
|
|
386
|
+
async (params) => {
|
|
387
|
+
setIsGenerating(true);
|
|
388
|
+
setError(null);
|
|
389
|
+
try {
|
|
390
|
+
await generate(params);
|
|
391
|
+
} catch (err) {
|
|
392
|
+
const error2 = err instanceof Error ? err : new Error(String(err));
|
|
393
|
+
setError(error2);
|
|
394
|
+
throw error2;
|
|
395
|
+
} finally {
|
|
396
|
+
setIsGenerating(false);
|
|
397
|
+
}
|
|
398
|
+
},
|
|
399
|
+
[generate]
|
|
400
|
+
);
|
|
401
|
+
return { generateTheme, isGenerating, error };
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
// src/hooks/useDhemeClient.ts
|
|
405
|
+
function useDhemeClient() {
|
|
406
|
+
const { client } = useThemeActions();
|
|
407
|
+
return client;
|
|
408
|
+
}
|
|
409
|
+
export {
|
|
410
|
+
DhemeProvider,
|
|
411
|
+
DhemeScript,
|
|
412
|
+
ThemeActionsContext,
|
|
413
|
+
ThemeDataContext,
|
|
414
|
+
applyThemeCSSVariables,
|
|
415
|
+
buildCacheKey,
|
|
416
|
+
getBlockingScriptPayload,
|
|
417
|
+
getNextBlockingScriptPayload,
|
|
418
|
+
removeThemeCSSVariables,
|
|
419
|
+
themeToCSS,
|
|
420
|
+
themeToCSSBothModes,
|
|
421
|
+
useDhemeClient,
|
|
422
|
+
useGenerateTheme,
|
|
423
|
+
useTheme,
|
|
424
|
+
useThemeActions
|
|
425
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dheme/react",
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "React bindings for Dheme SDK with zero-FOUC theme application",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"module": "./dist/index.mjs",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.mjs",
|
|
12
|
+
"require": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"README.md",
|
|
18
|
+
"LICENSE"
|
|
19
|
+
],
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "tsup src/index.ts --format cjs,esm --dts --clean --external react --external react-dom --external @dheme/sdk --tsconfig tsconfig.build.json",
|
|
22
|
+
"dev": "tsup src/index.ts --format cjs,esm --dts --watch --external react --external react-dom --external @dheme/sdk",
|
|
23
|
+
"test": "vitest run",
|
|
24
|
+
"test:watch": "vitest",
|
|
25
|
+
"lint": "eslint src --ext .ts,.tsx",
|
|
26
|
+
"typecheck": "tsc --noEmit",
|
|
27
|
+
"prepublishOnly": "npm run build"
|
|
28
|
+
},
|
|
29
|
+
"keywords": [
|
|
30
|
+
"dheme",
|
|
31
|
+
"theme",
|
|
32
|
+
"react",
|
|
33
|
+
"hooks",
|
|
34
|
+
"shadcn",
|
|
35
|
+
"tailwind",
|
|
36
|
+
"fouc",
|
|
37
|
+
"css-variables"
|
|
38
|
+
],
|
|
39
|
+
"author": "Dheme Team",
|
|
40
|
+
"license": "MIT",
|
|
41
|
+
"repository": {
|
|
42
|
+
"type": "git",
|
|
43
|
+
"url": "https://github.com/dheme/sdk"
|
|
44
|
+
},
|
|
45
|
+
"homepage": "https://dheme.com",
|
|
46
|
+
"peerDependencies": {
|
|
47
|
+
"react": ">=18.0.0",
|
|
48
|
+
"react-dom": ">=18.0.0"
|
|
49
|
+
},
|
|
50
|
+
"dependencies": {
|
|
51
|
+
"@dheme/sdk": "^1.1.0"
|
|
52
|
+
},
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"@types/react": "^18.2.0",
|
|
55
|
+
"@types/react-dom": "^18.2.0",
|
|
56
|
+
"@testing-library/react": "^14.1.0",
|
|
57
|
+
"tsup": "^8.0.1",
|
|
58
|
+
"typescript": "^5.3.0",
|
|
59
|
+
"vitest": "^1.2.0",
|
|
60
|
+
"react": "^18.2.0",
|
|
61
|
+
"react-dom": "^18.2.0"
|
|
62
|
+
}
|
|
63
|
+
}
|