@codefast/theme 0.3.11-canary.0 → 0.3.11-canary.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.
- package/CHANGELOG.md +16 -0
- package/dist/adapters/tanstack-start/index.d.ts +2 -39
- package/dist/adapters/tanstack-start/server.d.ts +13 -7
- package/dist/adapters/tanstack-start/server.js +62 -22
- package/dist/constants.d.ts +10 -6
- package/dist/constants.js +27 -0
- package/dist/core/context.d.ts +7 -3
- package/dist/core/context.js +12 -1
- package/dist/core/index.d.ts +4 -3
- package/dist/core/provider.d.ts +35 -26
- package/dist/core/provider.js +106 -78
- package/dist/core/use-theme.d.ts +6 -2
- package/dist/core/use-theme.js +32 -4
- package/dist/index.d.ts +9 -16
- package/dist/index.js +7 -4
- package/dist/script/index.d.ts +2 -1
- package/dist/script/theme-script.d.ts +13 -8
- package/dist/script/theme-script.js +25 -6
- package/dist/types.d.ts +16 -12
- package/dist/types.js +17 -4
- package/dist/utils/dom.d.ts +7 -3
- package/dist/utils/dom.js +45 -19
- package/dist/utils/index.d.ts +3 -2
- package/dist/utils/system.d.ts +7 -3
- package/dist/utils/system.js +24 -4
- package/package.json +22 -38
- package/dist/adapters/tanstack-start/index.cjs +0 -42
- package/dist/adapters/tanstack-start/server.cjs +0 -70
- package/dist/constants.cjs +0 -52
- package/dist/core/context.cjs +0 -37
- package/dist/core/index.cjs +0 -44
- package/dist/core/provider.cjs +0 -123
- package/dist/core/use-theme.cjs +0 -42
- package/dist/index.cjs +0 -76
- package/dist/script/index.cjs +0 -36
- package/dist/script/theme-script.cjs +0 -44
- package/dist/types.cjs +0 -45
- package/dist/utils/dom.cjs +0 -61
- package/dist/utils/index.cjs +0 -46
- package/dist/utils/system.cjs +0 -46
package/dist/index.d.ts
CHANGED
|
@@ -1,16 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
*/
|
|
11
|
-
export type { ResolvedTheme, Theme, ThemeContextType } from "./types";
|
|
12
|
-
export { themes, themeSchema } from "./types";
|
|
13
|
-
export { DEFAULT_RESOLVED_THEME, DEFAULT_THEME, THEME_STORAGE_KEY } from "./constants";
|
|
14
|
-
export { ThemeContext, ThemeProvider, useTheme } from "./core";
|
|
15
|
-
export { ThemeScript } from "./script";
|
|
16
|
-
export { applyTheme, disableAnimation, getSystemTheme, resolveTheme } from "./utils";
|
|
1
|
+
import { ResolvedTheme, Theme, ThemeContextType, themeSchema, themes } from "./types.js";
|
|
2
|
+
import { DEFAULT_RESOLVED_THEME, DEFAULT_THEME, THEME_STORAGE_KEY } from "./constants.js";
|
|
3
|
+
import { ThemeContext } from "./core/context.js";
|
|
4
|
+
import { ThemeProvider } from "./core/provider.js";
|
|
5
|
+
import { useTheme } from "./core/use-theme.js";
|
|
6
|
+
import { ThemeScript } from "./script/theme-script.js";
|
|
7
|
+
import { applyTheme, disableAnimation } from "./utils/dom.js";
|
|
8
|
+
import { getSystemTheme, resolveTheme } from "./utils/system.js";
|
|
9
|
+
export { DEFAULT_RESOLVED_THEME, DEFAULT_THEME, type ResolvedTheme, THEME_STORAGE_KEY, type Theme, ThemeContext, type ThemeContextType, ThemeProvider, ThemeScript, applyTheme, disableAnimation, getSystemTheme, resolveTheme, themeSchema, themes, useTheme };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import { themeSchema, themes } from "./types.js";
|
|
2
1
|
import { DEFAULT_RESOLVED_THEME, DEFAULT_THEME, THEME_STORAGE_KEY } from "./constants.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { applyTheme, disableAnimation
|
|
2
|
+
import { themeSchema, themes } from "./types.js";
|
|
3
|
+
import { ThemeContext } from "./core/context.js";
|
|
4
|
+
import { applyTheme, disableAnimation } from "./utils/dom.js";
|
|
5
|
+
import { getSystemTheme, resolveTheme } from "./utils/system.js";
|
|
6
|
+
import { ThemeProvider } from "./core/provider.js";
|
|
7
|
+
import { useTheme } from "./core/use-theme.js";
|
|
8
|
+
import { ThemeScript } from "./script/theme-script.js";
|
|
6
9
|
export { DEFAULT_RESOLVED_THEME, DEFAULT_THEME, THEME_STORAGE_KEY, ThemeContext, ThemeProvider, ThemeScript, applyTheme, disableAnimation, getSystemTheme, resolveTheme, themeSchema, themes, useTheme };
|
package/dist/script/index.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { ThemeScript } from "./theme-script.js";
|
|
2
|
+
export { ThemeScript };
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { Theme } from "../types.js";
|
|
2
|
+
import { JSX } from "react";
|
|
3
|
+
|
|
4
|
+
//#region src/script/theme-script.d.ts
|
|
3
5
|
interface ThemeScriptProps {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Initial theme from server (e.g., from cookie via loader).
|
|
8
|
+
*/
|
|
9
|
+
theme: Theme;
|
|
8
10
|
}
|
|
9
11
|
/**
|
|
10
12
|
* Inline script that prevents Flash of Unstyled Content (FOUC).
|
|
@@ -28,5 +30,8 @@ interface ThemeScriptProps {
|
|
|
28
30
|
* </head>
|
|
29
31
|
* ```
|
|
30
32
|
*/
|
|
31
|
-
|
|
32
|
-
|
|
33
|
+
declare function ThemeScript({
|
|
34
|
+
theme
|
|
35
|
+
}: ThemeScriptProps): JSX.Element;
|
|
36
|
+
//#endregion
|
|
37
|
+
export { ThemeScript };
|
|
@@ -1,10 +1,29 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
//#region src/script/theme-script.tsx
|
|
3
|
+
/**
|
|
4
|
+
* Inline script that prevents Flash of Unstyled Content (FOUC).
|
|
5
|
+
*
|
|
6
|
+
* **Why this is needed:**
|
|
7
|
+
* React hydration occurs after the browser has already painted the page.
|
|
8
|
+
* Without this script, users would briefly see the wrong theme before
|
|
9
|
+
* React takes over and applies the correct one.
|
|
10
|
+
*
|
|
11
|
+
* **How it works:**
|
|
12
|
+
* This script runs synchronously in the `<head>` before first paint:
|
|
13
|
+
* 1. Resolves 'system' to 'light' or 'dark' using `matchMedia()`
|
|
14
|
+
* 2. Adds the theme class to `<html>` immediately
|
|
15
|
+
* 3. Sets `color-scheme` for native form controls and scrollbars
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```tsx
|
|
19
|
+
* // In __root.tsx (TanStack Start)
|
|
20
|
+
* <head>
|
|
21
|
+
* <ThemeScript theme={theme} />
|
|
22
|
+
* </head>
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
2
25
|
function ThemeScript({ theme }) {
|
|
3
|
-
|
|
4
|
-
return /*#__PURE__*/ jsx("script", {
|
|
5
|
-
dangerouslySetInnerHTML: {
|
|
6
|
-
__html: themeScript
|
|
7
|
-
}
|
|
8
|
-
});
|
|
26
|
+
return /* @__PURE__ */ jsx("script", { dangerouslySetInnerHTML: { __html: `(function(){try{var theme="${theme}",resolvedTheme=theme;"system"===theme&&(resolvedTheme=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),document.documentElement.classList.add(resolvedTheme),document.documentElement.style.colorScheme=resolvedTheme}catch(error){}})()` } });
|
|
9
27
|
}
|
|
28
|
+
//#endregion
|
|
10
29
|
export { ThemeScript };
|
package/dist/types.d.ts
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
//#region src/types.d.ts
|
|
2
4
|
/**
|
|
3
5
|
* Zod schema for theme validation.
|
|
4
6
|
*
|
|
5
7
|
* Acts as the single source of truth for all theme-related types.
|
|
6
8
|
* Valid values: 'light', 'dark', 'system'.
|
|
7
9
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
declare const themeSchema: z.ZodEnum<{
|
|
11
|
+
light: "light";
|
|
12
|
+
dark: "dark";
|
|
13
|
+
system: "system";
|
|
12
14
|
}>;
|
|
13
15
|
/**
|
|
14
16
|
* User's theme preference.
|
|
@@ -17,19 +19,19 @@ export declare const themeSchema: z.ZodEnum<{
|
|
|
17
19
|
* - `'dark'` - Force dark mode
|
|
18
20
|
* - `'system'` - Follow OS preference
|
|
19
21
|
*/
|
|
20
|
-
|
|
22
|
+
type Theme = z.infer<typeof themeSchema>;
|
|
21
23
|
/**
|
|
22
24
|
* Actual theme applied to the UI after resolving 'system'.
|
|
23
25
|
*
|
|
24
26
|
* When theme is 'system', this reflects the OS preference (light/dark).
|
|
25
27
|
*/
|
|
26
|
-
|
|
28
|
+
type ResolvedTheme = Exclude<Theme, "system">;
|
|
27
29
|
/**
|
|
28
30
|
* Array of all available theme options: `['light', 'dark', 'system']`.
|
|
29
31
|
*
|
|
30
32
|
* Useful for rendering theme selectors in UI components.
|
|
31
33
|
*/
|
|
32
|
-
|
|
34
|
+
declare const themes: ("light" | "dark" | "system")[];
|
|
33
35
|
/**
|
|
34
36
|
* Shape of the theme context value provided by ThemeProvider.
|
|
35
37
|
*
|
|
@@ -38,9 +40,11 @@ export declare const themes: ("light" | "dark" | "system")[];
|
|
|
38
40
|
* - `setTheme` - Async function to update theme (triggers optimistic update)
|
|
39
41
|
* - `isPending` - True while theme change is being persisted
|
|
40
42
|
*/
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
interface ThemeContextType {
|
|
44
|
+
isPending: boolean;
|
|
45
|
+
resolvedTheme: ResolvedTheme;
|
|
46
|
+
setTheme: (value: Theme) => Promise<void>;
|
|
47
|
+
theme: Theme;
|
|
46
48
|
}
|
|
49
|
+
//#endregion
|
|
50
|
+
export { ResolvedTheme, Theme, ThemeContextType, themeSchema, themes };
|
package/dist/types.js
CHANGED
|
@@ -1,8 +1,21 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
//#region src/types.ts
|
|
3
|
+
/**
|
|
4
|
+
* Zod schema for theme validation.
|
|
5
|
+
*
|
|
6
|
+
* Acts as the single source of truth for all theme-related types.
|
|
7
|
+
* Valid values: 'light', 'dark', 'system'.
|
|
8
|
+
*/
|
|
9
|
+
const themeSchema = z.enum([
|
|
10
|
+
"light",
|
|
11
|
+
"dark",
|
|
12
|
+
"system"
|
|
6
13
|
]);
|
|
14
|
+
/**
|
|
15
|
+
* Array of all available theme options: `['light', 'dark', 'system']`.
|
|
16
|
+
*
|
|
17
|
+
* Useful for rendering theme selectors in UI components.
|
|
18
|
+
*/
|
|
7
19
|
const themes = themeSchema.options;
|
|
20
|
+
//#endregion
|
|
8
21
|
export { themeSchema, themes };
|
package/dist/utils/dom.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ResolvedTheme } from "../types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/utils/dom.d.ts
|
|
2
4
|
/**
|
|
3
5
|
* Apply theme to the DOM by updating `<html>` element.
|
|
4
6
|
*
|
|
@@ -8,7 +10,7 @@ import type { ResolvedTheme } from "../types";
|
|
|
8
10
|
*
|
|
9
11
|
* @param resolved - The resolved theme to apply ('light' or 'dark')
|
|
10
12
|
*/
|
|
11
|
-
|
|
13
|
+
declare function applyTheme(resolved: ResolvedTheme): void;
|
|
12
14
|
/**
|
|
13
15
|
* Temporarily disable all CSS transitions during theme changes.
|
|
14
16
|
*
|
|
@@ -25,4 +27,6 @@ export declare function applyTheme(resolved: ResolvedTheme): void;
|
|
|
25
27
|
* enableTransitions(); // Re-enables CSS transitions
|
|
26
28
|
* ```
|
|
27
29
|
*/
|
|
28
|
-
|
|
30
|
+
declare function disableAnimation(nonce?: string): () => void;
|
|
31
|
+
//#endregion
|
|
32
|
+
export { applyTheme, disableAnimation };
|
package/dist/utils/dom.js
CHANGED
|
@@ -1,24 +1,50 @@
|
|
|
1
|
+
//#region src/utils/dom.ts
|
|
2
|
+
/**
|
|
3
|
+
* Apply theme to the DOM by updating `<html>` element.
|
|
4
|
+
*
|
|
5
|
+
* Updates both:
|
|
6
|
+
* - CSS class (for Tailwind's `dark:` variants)
|
|
7
|
+
* - `color-scheme` style (for native form controls and scrollbars)
|
|
8
|
+
*
|
|
9
|
+
* @param resolved - The resolved theme to apply ('light' or 'dark')
|
|
10
|
+
*/
|
|
1
11
|
function applyTheme(resolved) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
12
|
+
const root = window.document.documentElement;
|
|
13
|
+
root.classList.remove("light", "dark", "system");
|
|
14
|
+
root.classList.add(resolved);
|
|
15
|
+
root.style.colorScheme = resolved;
|
|
6
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* Temporarily disable all CSS transitions during theme changes.
|
|
19
|
+
*
|
|
20
|
+
* Prevents jarring color animations when switching between light/dark themes.
|
|
21
|
+
* Respects user's `prefers-reduced-motion` preference (does nothing if enabled).
|
|
22
|
+
*
|
|
23
|
+
* @param nonce - Optional CSP nonce for the injected style element
|
|
24
|
+
* @returns Cleanup function to re-enable transitions. Call after theme is applied.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```tsx
|
|
28
|
+
* const enableTransitions = disableAnimation();
|
|
29
|
+
* applyTheme('dark');
|
|
30
|
+
* enableTransitions(); // Re-enables CSS transitions
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
7
33
|
function disableAnimation(nonce) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
};
|
|
34
|
+
if (typeof window === "undefined") return () => {};
|
|
35
|
+
if (window.matchMedia("(prefers-reduced-motion: reduce)").matches) return () => {};
|
|
36
|
+
const css = document.createElement("style");
|
|
37
|
+
if (nonce) css.setAttribute("nonce", nonce);
|
|
38
|
+
css.append(document.createTextNode(`*,*::before,*::after{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}`));
|
|
39
|
+
document.head.append(css);
|
|
40
|
+
return () => {
|
|
41
|
+
window.getComputedStyle(document.body);
|
|
42
|
+
requestAnimationFrame(() => {
|
|
43
|
+
requestAnimationFrame(() => {
|
|
44
|
+
if (css.parentNode) css.remove();
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
};
|
|
23
48
|
}
|
|
49
|
+
//#endregion
|
|
24
50
|
export { applyTheme, disableAnimation };
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { applyTheme, disableAnimation } from "./dom.js";
|
|
2
|
+
import { getSystemTheme, resolveTheme } from "./system.js";
|
|
3
|
+
export { applyTheme, disableAnimation, getSystemTheme, resolveTheme };
|
package/dist/utils/system.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ResolvedTheme, Theme } from "../types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/utils/system.d.ts
|
|
2
4
|
/**
|
|
3
5
|
* Detect the user's OS theme preference.
|
|
4
6
|
*
|
|
@@ -7,7 +9,7 @@ import type { ResolvedTheme, Theme } from "../types";
|
|
|
7
9
|
*
|
|
8
10
|
* @returns 'light' or 'dark' based on OS preference
|
|
9
11
|
*/
|
|
10
|
-
|
|
12
|
+
declare function getSystemTheme(): ResolvedTheme;
|
|
11
13
|
/**
|
|
12
14
|
* Resolve theme preference to actual light/dark value.
|
|
13
15
|
*
|
|
@@ -18,4 +20,6 @@ export declare function getSystemTheme(): ResolvedTheme;
|
|
|
18
20
|
* @param theme - User's theme preference
|
|
19
21
|
* @returns The resolved theme to apply
|
|
20
22
|
*/
|
|
21
|
-
|
|
23
|
+
declare function resolveTheme(theme: Theme): ResolvedTheme;
|
|
24
|
+
//#endregion
|
|
25
|
+
export { getSystemTheme, resolveTheme };
|
package/dist/utils/system.js
CHANGED
|
@@ -1,9 +1,29 @@
|
|
|
1
|
-
import { DEFAULT_RESOLVED_THEME
|
|
1
|
+
import { DEFAULT_RESOLVED_THEME } from "../constants.js";
|
|
2
|
+
//#region src/utils/system.ts
|
|
3
|
+
/**
|
|
4
|
+
* Detect the user's OS theme preference.
|
|
5
|
+
*
|
|
6
|
+
* Uses `matchMedia()` to query the `prefers-color-scheme` media feature.
|
|
7
|
+
* Returns {@link DEFAULT_RESOLVED_THEME} during SSR since `window` is unavailable.
|
|
8
|
+
*
|
|
9
|
+
* @returns 'light' or 'dark' based on OS preference
|
|
10
|
+
*/
|
|
2
11
|
function getSystemTheme() {
|
|
3
|
-
|
|
4
|
-
|
|
12
|
+
if (typeof window === "undefined") return DEFAULT_RESOLVED_THEME;
|
|
13
|
+
return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
5
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* Resolve theme preference to actual light/dark value.
|
|
17
|
+
*
|
|
18
|
+
* - 'light' → 'light'
|
|
19
|
+
* - 'dark' → 'dark'
|
|
20
|
+
* - 'system' → result of {@link getSystemTheme}
|
|
21
|
+
*
|
|
22
|
+
* @param theme - User's theme preference
|
|
23
|
+
* @returns The resolved theme to apply
|
|
24
|
+
*/
|
|
6
25
|
function resolveTheme(theme) {
|
|
7
|
-
|
|
26
|
+
return theme === "system" ? getSystemTheme() : theme;
|
|
8
27
|
}
|
|
28
|
+
//#endregion
|
|
9
29
|
export { getSystemTheme, resolveTheme };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codefast/theme",
|
|
3
|
-
"version": "0.3.11-canary.
|
|
3
|
+
"version": "0.3.11-canary.2",
|
|
4
4
|
"description": "Theme management with React 19 features - optimistic updates, cross-tab sync, and SSR support",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dark-mode",
|
|
@@ -30,79 +30,64 @@
|
|
|
30
30
|
],
|
|
31
31
|
"type": "module",
|
|
32
32
|
"sideEffects": false,
|
|
33
|
-
"main": "./dist/index.
|
|
34
|
-
"module": "./dist/index.js",
|
|
33
|
+
"main": "./dist/index.js",
|
|
35
34
|
"types": "./dist/index.d.ts",
|
|
36
35
|
"exports": {
|
|
37
36
|
".": {
|
|
38
37
|
"types": "./dist/index.d.ts",
|
|
39
|
-
"import": "./dist/index.js"
|
|
40
|
-
"require": "./dist/index.cjs"
|
|
38
|
+
"import": "./dist/index.js"
|
|
41
39
|
},
|
|
42
40
|
"./core": {
|
|
43
41
|
"types": "./dist/core/index.d.ts",
|
|
44
|
-
"import": "./dist/core/index.js"
|
|
45
|
-
"require": "./dist/core/index.cjs"
|
|
42
|
+
"import": "./dist/core/index.js"
|
|
46
43
|
},
|
|
47
44
|
"./core/context": {
|
|
48
45
|
"types": "./dist/core/context.d.ts",
|
|
49
|
-
"import": "./dist/core/context.js"
|
|
50
|
-
"require": "./dist/core/context.cjs"
|
|
46
|
+
"import": "./dist/core/context.js"
|
|
51
47
|
},
|
|
52
48
|
"./core/provider": {
|
|
53
49
|
"types": "./dist/core/provider.d.ts",
|
|
54
|
-
"import": "./dist/core/provider.js"
|
|
55
|
-
"require": "./dist/core/provider.cjs"
|
|
50
|
+
"import": "./dist/core/provider.js"
|
|
56
51
|
},
|
|
57
52
|
"./core/use-theme": {
|
|
58
53
|
"types": "./dist/core/use-theme.d.ts",
|
|
59
|
-
"import": "./dist/core/use-theme.js"
|
|
60
|
-
"require": "./dist/core/use-theme.cjs"
|
|
54
|
+
"import": "./dist/core/use-theme.js"
|
|
61
55
|
},
|
|
62
56
|
"./utils": {
|
|
63
57
|
"types": "./dist/utils/index.d.ts",
|
|
64
|
-
"import": "./dist/utils/index.js"
|
|
65
|
-
"require": "./dist/utils/index.cjs"
|
|
58
|
+
"import": "./dist/utils/index.js"
|
|
66
59
|
},
|
|
67
60
|
"./utils/dom": {
|
|
68
61
|
"types": "./dist/utils/dom.d.ts",
|
|
69
|
-
"import": "./dist/utils/dom.js"
|
|
70
|
-
"require": "./dist/utils/dom.cjs"
|
|
62
|
+
"import": "./dist/utils/dom.js"
|
|
71
63
|
},
|
|
72
64
|
"./utils/system": {
|
|
73
65
|
"types": "./dist/utils/system.d.ts",
|
|
74
|
-
"import": "./dist/utils/system.js"
|
|
75
|
-
"require": "./dist/utils/system.cjs"
|
|
66
|
+
"import": "./dist/utils/system.js"
|
|
76
67
|
},
|
|
77
68
|
"./adapters/tanstack-start": {
|
|
78
69
|
"types": "./dist/adapters/tanstack-start/index.d.ts",
|
|
79
|
-
"import": "./dist/adapters/tanstack-start/index.js"
|
|
80
|
-
"require": "./dist/adapters/tanstack-start/index.cjs"
|
|
70
|
+
"import": "./dist/adapters/tanstack-start/index.js"
|
|
81
71
|
},
|
|
82
72
|
"./adapters/tanstack-start/server": {
|
|
83
73
|
"types": "./dist/adapters/tanstack-start/server.d.ts",
|
|
84
|
-
"import": "./dist/adapters/tanstack-start/server.js"
|
|
85
|
-
"require": "./dist/adapters/tanstack-start/server.cjs"
|
|
74
|
+
"import": "./dist/adapters/tanstack-start/server.js"
|
|
86
75
|
},
|
|
87
76
|
"./script": {
|
|
88
77
|
"types": "./dist/script/index.d.ts",
|
|
89
|
-
"import": "./dist/script/index.js"
|
|
90
|
-
"require": "./dist/script/index.cjs"
|
|
78
|
+
"import": "./dist/script/index.js"
|
|
91
79
|
},
|
|
92
80
|
"./script/theme-script": {
|
|
93
81
|
"types": "./dist/script/theme-script.d.ts",
|
|
94
|
-
"import": "./dist/script/theme-script.js"
|
|
95
|
-
"require": "./dist/script/theme-script.cjs"
|
|
82
|
+
"import": "./dist/script/theme-script.js"
|
|
96
83
|
},
|
|
97
84
|
"./constants": {
|
|
98
85
|
"types": "./dist/constants.d.ts",
|
|
99
|
-
"import": "./dist/constants.js"
|
|
100
|
-
"require": "./dist/constants.cjs"
|
|
86
|
+
"import": "./dist/constants.js"
|
|
101
87
|
},
|
|
102
88
|
"./types": {
|
|
103
89
|
"types": "./dist/types.d.ts",
|
|
104
|
-
"import": "./dist/types.js"
|
|
105
|
-
"require": "./dist/types.cjs"
|
|
90
|
+
"import": "./dist/types.js"
|
|
106
91
|
},
|
|
107
92
|
"./package.json": "./package.json"
|
|
108
93
|
},
|
|
@@ -113,11 +98,9 @@
|
|
|
113
98
|
"zod": "^4.3.6"
|
|
114
99
|
},
|
|
115
100
|
"devDependencies": {
|
|
116
|
-
"@rsbuild/plugin-react": "^1.4.6",
|
|
117
|
-
"@rslib/core": "^0.19.1",
|
|
118
101
|
"@swc/core": "^1.15.21",
|
|
119
102
|
"@swc/jest": "^0.2.39",
|
|
120
|
-
"@tanstack/react-start": "^1.167.
|
|
103
|
+
"@tanstack/react-start": "^1.167.12",
|
|
121
104
|
"@testing-library/dom": "^10.4.1",
|
|
122
105
|
"@testing-library/jest-dom": "^6.9.1",
|
|
123
106
|
"@testing-library/react": "^16.3.2",
|
|
@@ -126,8 +109,9 @@
|
|
|
126
109
|
"@types/node": "^25.5.0",
|
|
127
110
|
"jest": "^30.3.0",
|
|
128
111
|
"jest-environment-jsdom": "^30.3.0",
|
|
129
|
-
"
|
|
130
|
-
"
|
|
112
|
+
"tsdown": "^0.21.6",
|
|
113
|
+
"typescript": "^6.0.2",
|
|
114
|
+
"@codefast/typescript-config": "0.3.11-canary.2"
|
|
131
115
|
},
|
|
132
116
|
"peerDependencies": {
|
|
133
117
|
"@tanstack/react-start": "^1.0",
|
|
@@ -148,9 +132,9 @@
|
|
|
148
132
|
}
|
|
149
133
|
},
|
|
150
134
|
"scripts": {
|
|
151
|
-
"build": "
|
|
135
|
+
"build": "tsdown",
|
|
152
136
|
"clean": "rm -rf dist",
|
|
153
|
-
"dev": "
|
|
137
|
+
"dev": "tsdown --watch --no-clean",
|
|
154
138
|
"test": "jest",
|
|
155
139
|
"test:coverage": "jest --coverage",
|
|
156
140
|
"test:coverage:ci": "jest --coverage --ci",
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __webpack_require__ = {};
|
|
3
|
-
(()=>{
|
|
4
|
-
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
-
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: definition[key]
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
})();
|
|
11
|
-
(()=>{
|
|
12
|
-
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
-
})();
|
|
14
|
-
(()=>{
|
|
15
|
-
__webpack_require__.r = (exports1)=>{
|
|
16
|
-
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
-
value: 'Module'
|
|
18
|
-
});
|
|
19
|
-
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
-
value: true
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
|
-
})();
|
|
24
|
-
var __webpack_exports__ = {};
|
|
25
|
-
__webpack_require__.r(__webpack_exports__);
|
|
26
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
-
createPersistTheme: ()=>external_server_cjs_namespaceObject.createPersistTheme,
|
|
28
|
-
getThemeServerFn: ()=>external_server_cjs_namespaceObject.getThemeServerFn,
|
|
29
|
-
setThemeServerFn: ()=>external_server_cjs_namespaceObject.setThemeServerFn
|
|
30
|
-
});
|
|
31
|
-
const external_server_cjs_namespaceObject = require("./server.cjs");
|
|
32
|
-
exports.createPersistTheme = __webpack_exports__.createPersistTheme;
|
|
33
|
-
exports.getThemeServerFn = __webpack_exports__.getThemeServerFn;
|
|
34
|
-
exports.setThemeServerFn = __webpack_exports__.setThemeServerFn;
|
|
35
|
-
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
36
|
-
"createPersistTheme",
|
|
37
|
-
"getThemeServerFn",
|
|
38
|
-
"setThemeServerFn"
|
|
39
|
-
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
40
|
-
Object.defineProperty(exports, '__esModule', {
|
|
41
|
-
value: true
|
|
42
|
-
});
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __webpack_require__ = {};
|
|
3
|
-
(()=>{
|
|
4
|
-
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
-
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: definition[key]
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
})();
|
|
11
|
-
(()=>{
|
|
12
|
-
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
-
})();
|
|
14
|
-
(()=>{
|
|
15
|
-
__webpack_require__.r = (exports1)=>{
|
|
16
|
-
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
-
value: 'Module'
|
|
18
|
-
});
|
|
19
|
-
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
-
value: true
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
|
-
})();
|
|
24
|
-
var __webpack_exports__ = {};
|
|
25
|
-
__webpack_require__.r(__webpack_exports__);
|
|
26
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
-
createPersistTheme: ()=>createPersistTheme,
|
|
28
|
-
getThemeServerFn: ()=>getThemeServerFn,
|
|
29
|
-
setThemeServerFn: ()=>setThemeServerFn
|
|
30
|
-
});
|
|
31
|
-
const react_start_namespaceObject = require("@tanstack/react-start");
|
|
32
|
-
const server_namespaceObject = require("@tanstack/react-start/server");
|
|
33
|
-
const external_constants_cjs_namespaceObject = require("../../constants.cjs");
|
|
34
|
-
const external_types_cjs_namespaceObject = require("../../types.cjs");
|
|
35
|
-
const getThemeServerFn = (0, react_start_namespaceObject.createServerFn)().handler(()=>{
|
|
36
|
-
const cookieTheme = (0, server_namespaceObject.getCookie)(external_constants_cjs_namespaceObject.THEME_STORAGE_KEY);
|
|
37
|
-
const validationResult = external_types_cjs_namespaceObject.themeSchema.safeParse(cookieTheme);
|
|
38
|
-
if (validationResult.success) return validationResult.data;
|
|
39
|
-
return external_constants_cjs_namespaceObject.DEFAULT_THEME;
|
|
40
|
-
});
|
|
41
|
-
const setThemeServerFn = (0, react_start_namespaceObject.createServerFn)({
|
|
42
|
-
method: "POST"
|
|
43
|
-
}).inputValidator(external_types_cjs_namespaceObject.themeSchema).handler(({ data })=>{
|
|
44
|
-
(0, server_namespaceObject.setCookie)(external_constants_cjs_namespaceObject.THEME_STORAGE_KEY, data, {
|
|
45
|
-
httpOnly: true,
|
|
46
|
-
maxAge: 31536000,
|
|
47
|
-
path: "/",
|
|
48
|
-
sameSite: "lax",
|
|
49
|
-
secure: "production" === process.env.NODE_ENV
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
const persistThemeHandler = async (value)=>{
|
|
53
|
-
await setThemeServerFn({
|
|
54
|
-
data: value
|
|
55
|
-
});
|
|
56
|
-
};
|
|
57
|
-
function createPersistTheme() {
|
|
58
|
-
return persistThemeHandler;
|
|
59
|
-
}
|
|
60
|
-
exports.createPersistTheme = __webpack_exports__.createPersistTheme;
|
|
61
|
-
exports.getThemeServerFn = __webpack_exports__.getThemeServerFn;
|
|
62
|
-
exports.setThemeServerFn = __webpack_exports__.setThemeServerFn;
|
|
63
|
-
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
64
|
-
"createPersistTheme",
|
|
65
|
-
"getThemeServerFn",
|
|
66
|
-
"setThemeServerFn"
|
|
67
|
-
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
68
|
-
Object.defineProperty(exports, '__esModule', {
|
|
69
|
-
value: true
|
|
70
|
-
});
|