uitheme-web 1.2.0 → 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.
Files changed (51) hide show
  1. package/README.md +56 -314
  2. package/dist/chunk-4UXANDJ5.cjs +26 -0
  3. package/dist/chunk-C4YNAGUP.js +26 -0
  4. package/dist/chunk-CTNYTI5Q.js +1 -0
  5. package/dist/{chunk-WFG34KG5.js → chunk-CY5E6WU4.js} +3 -3
  6. package/dist/chunk-CYGYUQUK.cjs +1 -0
  7. package/dist/chunk-EKVKQZNN.js +12 -0
  8. package/dist/chunk-EQPK72XK.js +14 -0
  9. package/dist/{chunk-W4YFUPGE.cjs → chunk-I5GA5T23.cjs} +3 -3
  10. package/dist/chunk-KQSBORXP.cjs +12 -0
  11. package/dist/chunk-NDNCNR4X.js +1 -0
  12. package/dist/chunk-SO3CO44A.js +1 -0
  13. package/dist/{constants-DmZ7yAIL.d.cts → constants-9M8X-rnX.d.cts} +2 -68
  14. package/dist/{constants-DmZ7yAIL.d.ts → constants-PAa1nGZ0.d.ts} +2 -68
  15. package/dist/controller-83zmHd-p.d.cts +76 -0
  16. package/dist/controller-DnMwV2nl.d.ts +76 -0
  17. package/dist/core/index.cjs +1 -1
  18. package/dist/core/index.d.cts +7 -5
  19. package/dist/core/index.d.ts +7 -5
  20. package/dist/core/index.js +1 -1
  21. package/dist/index-Dn3XRBX1.d.ts +106 -0
  22. package/dist/index-DqlTGyMr.d.cts +106 -0
  23. package/dist/next/index.cjs +2 -0
  24. package/dist/next/index.d.cts +4 -0
  25. package/dist/next/index.d.ts +4 -0
  26. package/dist/next/index.js +2 -0
  27. package/dist/nuxt.d.ts +10 -0
  28. package/dist/nuxt.js +34 -0
  29. package/dist/react/index.cjs +11 -89
  30. package/dist/react/index.d.cts +23 -279
  31. package/dist/react/index.d.ts +23 -279
  32. package/dist/react/index.js +11 -89
  33. package/dist/server/index.cjs +14 -0
  34. package/dist/server/index.d.cts +11 -0
  35. package/dist/server/index.d.ts +11 -0
  36. package/dist/server/index.js +14 -0
  37. package/dist/tanstack/index.cjs +1 -1
  38. package/dist/tanstack/index.d.cts +5 -3
  39. package/dist/tanstack/index.d.ts +5 -3
  40. package/dist/tanstack/index.js +1 -1
  41. package/dist/types-CrR56NLm.d.cts +79 -0
  42. package/dist/types-CrR56NLm.d.ts +79 -0
  43. package/dist/types-Dd4EU8V9.d.ts +96 -0
  44. package/dist/vue/bootstrap.d.ts +13 -0
  45. package/dist/vue/bootstrap.js +1 -0
  46. package/dist/vue/index.d.ts +39 -0
  47. package/dist/vue/index.js +1 -0
  48. package/package.json +68 -17
  49. package/dist/chunk-DFJEYTIW.js +0 -12
  50. package/dist/chunk-V3LMT5IJ.cjs +0 -12
  51. package/dist/cli/index.js +0 -39
@@ -0,0 +1,11 @@
1
+ import { ThemeConfig, Theme } from '../core/index.js';
2
+
3
+ type ThemeBootstrapOptions = Omit<ThemeConfig, 'themes' | 'colorThemes'> & {
4
+ themes?: readonly Theme[];
5
+ colorThemes?: readonly string[];
6
+ storage?: unknown;
7
+ };
8
+ declare function getThemeScript(options?: ThemeBootstrapOptions): string;
9
+
10
+ export { getThemeScript };
11
+ export type { ThemeBootstrapOptions };
@@ -0,0 +1,14 @@
1
+ import {c,d,b,a}from'../chunk-NDNCNR4X.js';function u(e={}){let t=e.themes??["light","dark","system"],r=e.colorThemes??["default"],a$1=e.defaultTheme??"system",l=e.defaultColorTheme??r[0],s=e.globalClassName??c,c$1=e.colorThemePrefix??d;if(!t.length||!t.every(o=>["light","dark","system"].includes(o))||!t.includes(a$1))throw new Error("themes must include defaultTheme and contain light, dark, or system.");if(!l||!r.includes(l)||![s,...r.map(o=>`${c$1}${o}`)].every(o=>o.length>0&&!/\s/.test(o)))throw new Error("Color themes and class names must be valid CSS class tokens.");return `(() => {
2
+ const config = ${JSON.stringify({themes:t,colorThemes:r,defaultTheme:a$1,defaultColorTheme:l,globalClassName:s,colorThemePrefix:c$1,storageKey:e.storageKey??a,colorStorageKey:e.colorStorageKey??b,browserStorage:e.storage===void 0}).replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")};
3
+ const root = document.documentElement;
4
+ let theme = config.defaultTheme;
5
+ let palette = config.defaultColorTheme;
6
+ if (config.browserStorage) {
7
+ try { const value = localStorage.getItem(config.storageKey); if (config.themes.includes(value)) theme = value; } catch {}
8
+ try { const value = localStorage.getItem(config.colorStorageKey); if (config.colorThemes.includes(value)) palette = value; } catch {}
9
+ }
10
+ const dark = theme === 'dark' || (theme === 'system' && matchMedia('(prefers-color-scheme: dark)').matches);
11
+ root.classList.toggle(config.globalClassName, dark);
12
+ root.style.colorScheme = dark ? 'dark' : 'light';
13
+ for (const value of config.colorThemes) root.classList.toggle(config.colorThemePrefix + value, value === palette);
14
+ })();`}export{u as getThemeScript};
@@ -1 +1 @@
1
- 'use strict';var chunkW4YFUPGE_cjs=require('../chunk-W4YFUPGE.cjs');function a(e,m,o={}){let{defaultTheme:h="system",defaultColorTheme:T="default"}=o,t=e==="light"||e==="dark"||e==="system"?e:h,s=m??T;return {theme:chunkW4YFUPGE_cjs.e(t),themePreference:t,colorTheme:s}}Object.defineProperty(exports,"COLOR_STORAGE_KEY",{enumerable:true,get:function(){return chunkW4YFUPGE_cjs.r}});Object.defineProperty(exports,"STORAGE_KEY",{enumerable:true,get:function(){return chunkW4YFUPGE_cjs.q}});Object.defineProperty(exports,"resolveThemeForServer",{enumerable:true,get:function(){return chunkW4YFUPGE_cjs.e}});exports.buildServerThemeData=a;
1
+ 'use strict';var chunkI5GA5T23_cjs=require('../chunk-I5GA5T23.cjs'),chunkCYGYUQUK_cjs=require('../chunk-CYGYUQUK.cjs');function a(e,m,o={}){let{defaultTheme:h="system",defaultColorTheme:T="default"}=o,t=e==="light"||e==="dark"||e==="system"?e:h,s=m??T;return {theme:chunkI5GA5T23_cjs.e(t),themePreference:t,colorTheme:s}}Object.defineProperty(exports,"resolveThemeForServer",{enumerable:true,get:function(){return chunkI5GA5T23_cjs.e}});Object.defineProperty(exports,"COLOR_STORAGE_KEY",{enumerable:true,get:function(){return chunkCYGYUQUK_cjs.b}});Object.defineProperty(exports,"STORAGE_KEY",{enumerable:true,get:function(){return chunkCYGYUQUK_cjs.a}});exports.buildServerThemeData=a;
@@ -1,5 +1,6 @@
1
- import { T as Theme } from '../constants-DmZ7yAIL.cjs';
2
- export { b as COLOR_STORAGE_KEY, C as ColorTheme, S as STORAGE_KEY, H as resolveThemeForServer } from '../constants-DmZ7yAIL.cjs';
1
+ import { c as Theme } from '../types-CrR56NLm.cjs';
2
+ export { C as ColorTheme } from '../types-CrR56NLm.cjs';
3
+ export { C as COLOR_STORAGE_KEY, S as STORAGE_KEY, r as resolveThemeForServer } from '../constants-9M8X-rnX.cjs';
3
4
 
4
5
  /** Resolved theme class to apply on <html> */
5
6
  type ServerResolvedTheme = 'light' | 'dark' | 'system';
@@ -33,4 +34,5 @@ declare function buildServerThemeData(themeCookie: string | undefined, colorThem
33
34
  defaultColorTheme?: string;
34
35
  }): ServerThemeData;
35
36
 
36
- export { type ServerResolvedTheme, type ServerThemeData, Theme, buildServerThemeData };
37
+ export { Theme, buildServerThemeData };
38
+ export type { ServerResolvedTheme, ServerThemeData };
@@ -1,5 +1,6 @@
1
- import { T as Theme } from '../constants-DmZ7yAIL.js';
2
- export { b as COLOR_STORAGE_KEY, C as ColorTheme, S as STORAGE_KEY, H as resolveThemeForServer } from '../constants-DmZ7yAIL.js';
1
+ import { c as Theme } from '../types-CrR56NLm.js';
2
+ export { C as ColorTheme } from '../types-CrR56NLm.js';
3
+ export { C as COLOR_STORAGE_KEY, S as STORAGE_KEY, r as resolveThemeForServer } from '../constants-PAa1nGZ0.js';
3
4
 
4
5
  /** Resolved theme class to apply on <html> */
5
6
  type ServerResolvedTheme = 'light' | 'dark' | 'system';
@@ -33,4 +34,5 @@ declare function buildServerThemeData(themeCookie: string | undefined, colorThem
33
34
  defaultColorTheme?: string;
34
35
  }): ServerThemeData;
35
36
 
36
- export { type ServerResolvedTheme, type ServerThemeData, Theme, buildServerThemeData };
37
+ export { Theme, buildServerThemeData };
38
+ export type { ServerResolvedTheme, ServerThemeData };
@@ -1 +1 @@
1
- import {e}from'../chunk-WFG34KG5.js';export{r as COLOR_STORAGE_KEY,q as STORAGE_KEY,e as resolveThemeForServer}from'../chunk-WFG34KG5.js';function a(e$1,m,o={}){let{defaultTheme:h="system",defaultColorTheme:T="default"}=o,t=e$1==="light"||e$1==="dark"||e$1==="system"?e$1:h,s=m??T;return {theme:e(t),themePreference:t,colorTheme:s}}export{a as buildServerThemeData};
1
+ import {e}from'../chunk-CY5E6WU4.js';export{e as resolveThemeForServer}from'../chunk-CY5E6WU4.js';export{b as COLOR_STORAGE_KEY,a as STORAGE_KEY}from'../chunk-NDNCNR4X.js';function a(e$1,m,o={}){let{defaultTheme:h="system",defaultColorTheme:T="default"}=o,t=e$1==="light"||e$1==="dark"||e$1==="system"?e$1:h,s=m??T;return {theme:e(t),themePreference:t,colorTheme:s}}export{a as buildServerThemeData};
@@ -0,0 +1,79 @@
1
+ declare enum ThemeAnimationType {
2
+ CIRCLE = "circle",
3
+ BLUR_CIRCLE = "blur-circle",
4
+ SLIDE = "slide",
5
+ CLIP_PATH = "clip-path",
6
+ POLYGON_GRADIENT = "polygon-gradient",
7
+ TRIANGLE = "triangle",
8
+ SVG_LOGO = "svg-logo"
9
+ }
10
+ /** Clockwise from the top-left corner. */
11
+ declare const TRANSITION_DIRECTIONS: readonly ["top-left", "top", "top-right", "right", "bottom-right", "bottom", "bottom-left", "left"];
12
+ type TransitionDirection = (typeof TRANSITION_DIRECTIONS)[number];
13
+ type AnimationPosition = TransitionDirection | 'center' | 'trigger';
14
+ interface ThemeAnimationSettings {
15
+ /** Starting edge/corner for polygon wipes. Defaults to top-left. */
16
+ clipPathDirection?: TransitionDirection;
17
+ /** Fixed circle/triangle origin; SVG_LOGO always uses the viewport center. */
18
+ animationPosition?: AnimationPosition;
19
+ /** Stationary logo width in CSS pixels or auto; default is 96 when both are omitted. */
20
+ logoWidth?: number | 'auto';
21
+ /** Logo height in CSS pixels or auto; omitted dimensions preserve the SVG aspect ratio. */
22
+ logoHeight?: number | 'auto';
23
+ /** Gradient wipe feather in CSS pixels; defaults to 80. */
24
+ gradientWidth?: number;
25
+ }
26
+ /** Choose one shared asset, or both destination-specific assets. */
27
+ type ThemeLogoOptions = {
28
+ logo?: string;
29
+ logoLight?: never;
30
+ logoDark?: never;
31
+ } | {
32
+ logo?: never;
33
+ logoLight: string;
34
+ logoDark: string;
35
+ };
36
+ type ThemeAnimationOptions = ThemeAnimationSettings & ThemeLogoOptions;
37
+ type Theme = 'light' | 'dark' | 'system';
38
+ type ColorTheme = string;
39
+ type SlideDirection = 'left' | 'right' | 'top' | 'bottom' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
40
+ type ThemeControlTransitionProps = {
41
+ duration?: number;
42
+ } & ({
43
+ animationType: 'slide';
44
+ slideDirection?: SlideDirection;
45
+ } | {
46
+ animationType?: 'circle' | 'blur-circle' | 'clip-path' | 'polygon-gradient' | 'triangle' | 'svg-logo';
47
+ slideDirection?: never;
48
+ });
49
+ interface AnimationConfig extends ThemeAnimationSettings {
50
+ /** Asset already selected for the destination theme before capture. */
51
+ logo?: string;
52
+ a?: number;
53
+ b?: number;
54
+ x: number;
55
+ y: number;
56
+ duration: number;
57
+ easing: string;
58
+ animationType: ThemeAnimationType;
59
+ blurAmount: number;
60
+ styleId: string;
61
+ }
62
+ interface ThemeConfig {
63
+ themes?: readonly Theme[];
64
+ colorThemes?: readonly ColorTheme[];
65
+ defaultTheme?: Theme;
66
+ defaultColorTheme?: ColorTheme;
67
+ globalClassName?: string;
68
+ colorThemePrefix?: string;
69
+ storageKey?: string;
70
+ colorStorageKey?: string;
71
+ }
72
+ interface ThemeState {
73
+ theme: Theme;
74
+ colorTheme: ColorTheme;
75
+ resolvedTheme: 'light' | 'dark';
76
+ }
77
+
78
+ export { ThemeAnimationType as a, TRANSITION_DIRECTIONS as f };
79
+ export type { AnimationConfig as A, ColorTheme as C, SlideDirection as S, ThemeAnimationOptions as T, ThemeState as b, Theme as c, ThemeConfig as d, AnimationPosition as e, ThemeControlTransitionProps as g, ThemeLogoOptions as h, TransitionDirection as i };
@@ -0,0 +1,79 @@
1
+ declare enum ThemeAnimationType {
2
+ CIRCLE = "circle",
3
+ BLUR_CIRCLE = "blur-circle",
4
+ SLIDE = "slide",
5
+ CLIP_PATH = "clip-path",
6
+ POLYGON_GRADIENT = "polygon-gradient",
7
+ TRIANGLE = "triangle",
8
+ SVG_LOGO = "svg-logo"
9
+ }
10
+ /** Clockwise from the top-left corner. */
11
+ declare const TRANSITION_DIRECTIONS: readonly ["top-left", "top", "top-right", "right", "bottom-right", "bottom", "bottom-left", "left"];
12
+ type TransitionDirection = (typeof TRANSITION_DIRECTIONS)[number];
13
+ type AnimationPosition = TransitionDirection | 'center' | 'trigger';
14
+ interface ThemeAnimationSettings {
15
+ /** Starting edge/corner for polygon wipes. Defaults to top-left. */
16
+ clipPathDirection?: TransitionDirection;
17
+ /** Fixed circle/triangle origin; SVG_LOGO always uses the viewport center. */
18
+ animationPosition?: AnimationPosition;
19
+ /** Stationary logo width in CSS pixels or auto; default is 96 when both are omitted. */
20
+ logoWidth?: number | 'auto';
21
+ /** Logo height in CSS pixels or auto; omitted dimensions preserve the SVG aspect ratio. */
22
+ logoHeight?: number | 'auto';
23
+ /** Gradient wipe feather in CSS pixels; defaults to 80. */
24
+ gradientWidth?: number;
25
+ }
26
+ /** Choose one shared asset, or both destination-specific assets. */
27
+ type ThemeLogoOptions = {
28
+ logo?: string;
29
+ logoLight?: never;
30
+ logoDark?: never;
31
+ } | {
32
+ logo?: never;
33
+ logoLight: string;
34
+ logoDark: string;
35
+ };
36
+ type ThemeAnimationOptions = ThemeAnimationSettings & ThemeLogoOptions;
37
+ type Theme = 'light' | 'dark' | 'system';
38
+ type ColorTheme = string;
39
+ type SlideDirection = 'left' | 'right' | 'top' | 'bottom' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
40
+ type ThemeControlTransitionProps = {
41
+ duration?: number;
42
+ } & ({
43
+ animationType: 'slide';
44
+ slideDirection?: SlideDirection;
45
+ } | {
46
+ animationType?: 'circle' | 'blur-circle' | 'clip-path' | 'polygon-gradient' | 'triangle' | 'svg-logo';
47
+ slideDirection?: never;
48
+ });
49
+ interface AnimationConfig extends ThemeAnimationSettings {
50
+ /** Asset already selected for the destination theme before capture. */
51
+ logo?: string;
52
+ a?: number;
53
+ b?: number;
54
+ x: number;
55
+ y: number;
56
+ duration: number;
57
+ easing: string;
58
+ animationType: ThemeAnimationType;
59
+ blurAmount: number;
60
+ styleId: string;
61
+ }
62
+ interface ThemeConfig {
63
+ themes?: readonly Theme[];
64
+ colorThemes?: readonly ColorTheme[];
65
+ defaultTheme?: Theme;
66
+ defaultColorTheme?: ColorTheme;
67
+ globalClassName?: string;
68
+ colorThemePrefix?: string;
69
+ storageKey?: string;
70
+ colorStorageKey?: string;
71
+ }
72
+ interface ThemeState {
73
+ theme: Theme;
74
+ colorTheme: ColorTheme;
75
+ resolvedTheme: 'light' | 'dark';
76
+ }
77
+
78
+ export { ThemeAnimationType as a, TRANSITION_DIRECTIONS as f };
79
+ export type { AnimationConfig as A, ColorTheme as C, SlideDirection as S, ThemeAnimationOptions as T, ThemeState as b, Theme as c, ThemeConfig as d, AnimationPosition as e, ThemeControlTransitionProps as g, ThemeLogoOptions as h, TransitionDirection as i };
@@ -0,0 +1,96 @@
1
+ import { MaybeRefOrGetter } from 'vue';
2
+
3
+ declare enum ThemeAnimationType {
4
+ CIRCLE = "circle",
5
+ BLUR_CIRCLE = "blur-circle",
6
+ SLIDE = "slide",
7
+ CLIP_PATH = "clip-path",
8
+ POLYGON_GRADIENT = "polygon-gradient",
9
+ TRIANGLE = "triangle",
10
+ SVG_LOGO = "svg-logo"
11
+ }
12
+ /** Clockwise from the top-left corner. */
13
+ declare const TRANSITION_DIRECTIONS: readonly ["top-left", "top", "top-right", "right", "bottom-right", "bottom", "bottom-left", "left"];
14
+ type TransitionDirection = (typeof TRANSITION_DIRECTIONS)[number];
15
+ type AnimationPosition = TransitionDirection | 'center' | 'trigger';
16
+ interface ThemeAnimationSettings {
17
+ /** Starting edge/corner for polygon wipes. Defaults to top-left. */
18
+ clipPathDirection?: TransitionDirection;
19
+ /** Fixed circle/triangle origin; SVG_LOGO always uses the viewport center. */
20
+ animationPosition?: AnimationPosition;
21
+ /** Stationary logo width in CSS pixels or auto; default is 96 when both are omitted. */
22
+ logoWidth?: number | 'auto';
23
+ /** Logo height in CSS pixels or auto; omitted dimensions preserve the SVG aspect ratio. */
24
+ logoHeight?: number | 'auto';
25
+ /** Gradient wipe feather in CSS pixels; defaults to 80. */
26
+ gradientWidth?: number;
27
+ }
28
+ /** Choose one shared asset, or both destination-specific assets. */
29
+ type ThemeLogoOptions = {
30
+ logo?: string;
31
+ logoLight?: never;
32
+ logoDark?: never;
33
+ } | {
34
+ logo?: never;
35
+ logoLight: string;
36
+ logoDark: string;
37
+ };
38
+ type ThemeAnimationOptions = ThemeAnimationSettings & ThemeLogoOptions;
39
+ type Theme = 'light' | 'dark' | 'system';
40
+ type ColorTheme = string;
41
+ type SlideDirection = 'left' | 'right' | 'top' | 'bottom' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
42
+ type ThemeControlTransitionProps = {
43
+ duration?: number;
44
+ } & ({
45
+ animationType: 'slide';
46
+ slideDirection?: SlideDirection;
47
+ } | {
48
+ animationType?: 'circle' | 'blur-circle' | 'clip-path' | 'polygon-gradient' | 'triangle' | 'svg-logo';
49
+ slideDirection?: never;
50
+ });
51
+ interface ThemeConfig {
52
+ themes?: readonly Theme[];
53
+ colorThemes?: readonly ColorTheme[];
54
+ defaultTheme?: Theme;
55
+ defaultColorTheme?: ColorTheme;
56
+ globalClassName?: string;
57
+ colorThemePrefix?: string;
58
+ storageKey?: string;
59
+ colorStorageKey?: string;
60
+ }
61
+
62
+ type ThemeTransitionInput = boolean | {
63
+ element?: Element | null;
64
+ origin?: {
65
+ x: number;
66
+ y: number;
67
+ };
68
+ animationOff?: boolean;
69
+ };
70
+ type ThemeTrigger = ThemeTransitionInput | MouseEvent;
71
+ type TransitionOptions = ThemeAnimationOptions & {
72
+ animationType?: ThemeAnimationType | `${ThemeAnimationType}`;
73
+ duration?: number;
74
+ easing?: string;
75
+ blurAmount?: number;
76
+ styleId?: string;
77
+ slideDirection?: SlideDirection;
78
+ slideFromX?: number;
79
+ slideFromY?: number;
80
+ slideToX?: number;
81
+ slideToY?: number;
82
+ };
83
+ interface ThemeStorage {
84
+ getItem(key: string): string | null;
85
+ setItem(key: string, value: string): void;
86
+ }
87
+ type UIThemeOptions = Omit<ThemeConfig, 'themes' | 'colorThemes'> & TransitionOptions & {
88
+ themes?: readonly Theme[];
89
+ colorThemes?: readonly string[];
90
+ storage?: ThemeStorage | false;
91
+ onThemeChange?: (theme: Theme) => void;
92
+ onColorThemeChange?: (theme: string) => void;
93
+ };
94
+ type ReactiveTransitionOptions = MaybeRefOrGetter<TransitionOptions>;
95
+
96
+ export type { AnimationPosition as A, ColorTheme as C, ReactiveTransitionOptions as R, SlideDirection as S, ThemeLogoOptions as T, UIThemeOptions as U, Theme as a, ThemeTrigger as b, ThemeAnimationOptions as c, ThemeConfig as d, ThemeControlTransitionProps as e, ThemeStorage as f, ThemeTransitionInput as g, TransitionDirection as h, TransitionOptions as i };
@@ -0,0 +1,13 @@
1
+ import { d as ThemeConfig } from '../types-Dd4EU8V9.js';
2
+ import { Theme } from './index.js';
3
+ export { U as UIThemeOptions } from '../types-Dd4EU8V9.js';
4
+ import 'vue';
5
+
6
+ type ThemeBootstrapOptions = Omit<ThemeConfig, 'themes' | 'colorThemes'> & {
7
+ themes?: readonly Theme[];
8
+ colorThemes?: readonly string[];
9
+ storage?: unknown;
10
+ };
11
+ declare function getThemeScript(options?: ThemeBootstrapOptions): string;
12
+
13
+ export { ThemeConfig, getThemeScript };
@@ -0,0 +1 @@
1
+ export{a as getThemeScript}from'../chunk-EQPK72XK.js';import'../chunk-CTNYTI5Q.js';
@@ -0,0 +1,39 @@
1
+ import * as uitheme_web_core from 'uitheme-web/core';
2
+ export { TRANSITION_DIRECTIONS, ThemeAnimationType, preloadThemeLogo } from 'uitheme-web/core';
3
+ import * as vue from 'vue';
4
+ import { App } from 'vue';
5
+ import { U as UIThemeOptions, R as ReactiveTransitionOptions, a as Theme, b as ThemeTrigger } from '../types-Dd4EU8V9.js';
6
+ export { A as AnimationPosition, C as ColorTheme, S as SlideDirection, c as ThemeAnimationOptions, d as ThemeConfig, e as ThemeControlTransitionProps, T as ThemeLogoOptions, f as ThemeStorage, g as ThemeTransitionInput, h as TransitionDirection, i as TransitionOptions } from '../types-Dd4EU8V9.js';
7
+ export { getThemeScript } from './bootstrap.js';
8
+
9
+ declare function createUITheme(options?: UIThemeOptions): {
10
+ install(app: App): void;
11
+ };
12
+ declare function useUITheme(settings?: ReactiveTransitionOptions): {
13
+ ref: vue.ShallowRef<HTMLElement | null, HTMLElement | null>;
14
+ theme: vue.ComputedRef<uitheme_web_core.Theme>;
15
+ resolvedTheme: vue.ComputedRef<"light" | "dark">;
16
+ colorTheme: vue.ComputedRef<string>;
17
+ mounted: vue.ComputedRef<boolean>;
18
+ readonly themes: readonly uitheme_web_core.Theme[];
19
+ readonly colorThemes: readonly string[];
20
+ setTheme: (theme: uitheme_web_core.Theme) => void;
21
+ setColorTheme: (theme: string) => void;
22
+ switchTheme: (theme: Theme, input?: ThemeTrigger) => Promise<void>;
23
+ switchColorTheme: (theme: string, input?: ThemeTrigger) => Promise<void>;
24
+ toggleTheme: (input?: ThemeTrigger) => Promise<void>;
25
+ toggleLightTheme: (input?: ThemeTrigger) => Promise<void>;
26
+ toggleDarkTheme: (input?: ThemeTrigger) => Promise<void>;
27
+ toggleColorTheme: (input?: ThemeTrigger) => Promise<void>;
28
+ createColorThemeToggle: (theme: string) => (input?: ThemeTrigger) => Promise<void>;
29
+ isColorThemeActive: (theme: string) => boolean;
30
+ };
31
+ declare const useTheme: typeof useUITheme;
32
+
33
+ declare const UIThemeProvider: vue.DefineSetupFnComponent<{
34
+ options?: UIThemeOptions;
35
+ }, {}, {}, {
36
+ options?: UIThemeOptions;
37
+ } & {}, vue.PublicProps>;
38
+
39
+ export { ReactiveTransitionOptions, Theme, ThemeTrigger, UIThemeOptions, UIThemeProvider, createUITheme, useTheme, useUITheme };
@@ -0,0 +1 @@
1
+ export{a as getThemeScript}from'../chunk-EQPK72XK.js';import {a as a$1}from'../chunk-SO3CO44A.js';import'../chunk-CTNYTI5Q.js';import {defineComponent,provide,watch,onMounted,onScopeDispose,nextTick,shallowRef,computed,inject,toValue}from'vue';import {createThemeController,preloadThemeLogo}from'uitheme-web/core';export{TRANSITION_DIRECTIONS,ThemeAnimationType,preloadThemeLogo}from'uitheme-web/core';function a(r){let t=a$1(r);return {...r,...t}}function l(r={}){let t={...r},o=createThemeController(a(r),{onBrowserStorageError:()=>{},commit:async s=>{s(),await nextTick();}}),n=shallowRef(o.getServerSnapshot()),i=o.subscribe(()=>{n.value=o.getSnapshot();});return {controller:o,theme:computed(()=>n.value.theme),colorTheme:computed(()=>n.value.colorTheme),resolvedTheme:computed(()=>n.value.resolvedTheme),mounted:computed(()=>n.value.mounted),get themes(){return n.value.themes},get colorThemes(){return n.value.colorThemes},mount:()=>{o.mount(),n.value=o.getSnapshot();},updateOptions:s=>{let T=Object.fromEntries(Object.keys(t).filter(e=>!(e in s)).map(e=>[e,void 0]));o.updateOptions({...T,...a(s)}),t={...s};},dispose:()=>{o.dispose(),i();}}}var p=Symbol("uitheme-web/vue");function w(r={}){return {install(t){let o=l(r);t.provide(p,o),t.onUnmount(o.dispose);}}}function g(r={}){let t=inject(p);if(!t)throw new Error("useUITheme requires app.use(createUITheme()) or UIThemeProvider.");let{controller:o}=t,n=shallowRef(null);onMounted(()=>{t.mount(),watch(()=>{let e=toValue(r);return [e.logo,e.logoLight,e.logoDark]},e=>{for(let m of e)m&&preloadThemeLogo(m);},{immediate:true});});let i=e=>{let m=e===true||e===false?{animationOff:e}:e&&"currentTarget"in e?{element:e.currentTarget instanceof Element?e.currentTarget:null,animationOff:e.detail===0}:e;return {...toValue(r),element:n.value,...m}},s=(e,m)=>o.switchTheme(e,i(m)),T=(e,m)=>o.switchColorTheme(e,i(m));return {ref:n,theme:t.theme,resolvedTheme:t.resolvedTheme,colorTheme:t.colorTheme,mounted:t.mounted,get themes(){return t.themes},get colorThemes(){return t.colorThemes},setTheme:o.setTheme,setColorTheme:o.setColorTheme,switchTheme:s,switchColorTheme:T,toggleTheme:e=>o.toggleTheme(i(e)),toggleLightTheme:e=>o.toggleLightTheme(i(e)),toggleDarkTheme:e=>o.toggleDarkTheme(i(e)),toggleColorTheme:e=>o.toggleColorTheme(i(e)),createColorThemeToggle:e=>m=>T(e,m),isColorThemeActive:e=>t.colorTheme.value===e}}var S=g;var L=defineComponent((r,{slots:t})=>{let o=l(r.options);return provide(p,o),watch(()=>r.options,n=>o.updateOptions(n??{}),{deep:true}),onMounted(o.mount),onScopeDispose(o.dispose),()=>t.default?.()},{name:"UIThemeProvider",props:{options:{type:Object,default:()=>({})}}});export{L as UIThemeProvider,w as createUITheme,S as useTheme,g as useUITheme};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "uitheme-web",
3
- "version": "1.2.0",
3
+ "version": "2.0.0",
4
4
  "description": "Cross-framework UI theme switching library",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -27,6 +27,16 @@
27
27
  },
28
28
  "sideEffects": false,
29
29
  "exports": {
30
+ ".": {
31
+ "import": {
32
+ "types": "./dist/core/index.d.ts",
33
+ "default": "./dist/core/index.js"
34
+ },
35
+ "require": {
36
+ "types": "./dist/core/index.d.cts",
37
+ "default": "./dist/core/index.cjs"
38
+ }
39
+ },
30
40
  "./core": {
31
41
  "import": {
32
42
  "types": "./dist/core/index.d.ts",
@@ -47,6 +57,26 @@
47
57
  "default": "./dist/react/index.cjs"
48
58
  }
49
59
  },
60
+ "./next": {
61
+ "import": {
62
+ "types": "./dist/next/index.d.ts",
63
+ "default": "./dist/next/index.js"
64
+ },
65
+ "require": {
66
+ "types": "./dist/next/index.d.cts",
67
+ "default": "./dist/next/index.cjs"
68
+ }
69
+ },
70
+ "./next/server": {
71
+ "import": {
72
+ "types": "./dist/server/index.d.ts",
73
+ "default": "./dist/server/index.js"
74
+ },
75
+ "require": {
76
+ "types": "./dist/server/index.d.cts",
77
+ "default": "./dist/server/index.cjs"
78
+ }
79
+ },
50
80
  "./tanstack": {
51
81
  "import": {
52
82
  "types": "./dist/tanstack/index.d.ts",
@@ -57,6 +87,18 @@
57
87
  "default": "./dist/tanstack/index.cjs"
58
88
  }
59
89
  },
90
+ "./vue": {
91
+ "types": "./dist/vue/index.d.ts",
92
+ "import": "./dist/vue/index.js"
93
+ },
94
+ "./vue/bootstrap": {
95
+ "types": "./dist/vue/bootstrap.d.ts",
96
+ "import": "./dist/vue/bootstrap.js"
97
+ },
98
+ "./nuxt": {
99
+ "types": "./dist/nuxt.d.ts",
100
+ "import": "./dist/nuxt.js"
101
+ },
60
102
  "./package.json": "./package.json"
61
103
  },
62
104
  "main": "./dist/core/index.cjs",
@@ -67,13 +109,11 @@
67
109
  "README.md",
68
110
  "LICENSE"
69
111
  ],
70
- "bin": {
71
- "uitheme-web": "./dist/cli/index.js"
72
- },
73
112
  "peerDependencies": {
74
- "@radix-ui/react-select": ">=2.0.0",
75
- "react": ">=18.0.0",
76
- "react-dom": ">=18.0.0"
113
+ "react": ">=18.0.0 <20",
114
+ "react-dom": ">=18.0.0 <20",
115
+ "vue": "^3.5.0",
116
+ "nuxt": "^4.0.0"
77
117
  },
78
118
  "peerDependenciesMeta": {
79
119
  "react": {
@@ -81,30 +121,41 @@
81
121
  },
82
122
  "react-dom": {
83
123
  "optional": true
124
+ },
125
+ "vue": {
126
+ "optional": true
127
+ },
128
+ "nuxt": {
129
+ "optional": true
84
130
  }
85
131
  },
86
132
  "devDependencies": {
87
- "@playwright/test": "1.62.1",
88
- "@radix-ui/react-select": "^2.3.7",
133
+ "@playwright/test": "1.64.1",
89
134
  "@types/react": "^19.3.0",
90
135
  "@types/react-dom": "^19.3.0",
91
- "kleur": "^4.1.5",
92
- "react": "^19.3.0",
93
- "react-dom": "^19.3.0",
94
- "vite": "^7.3.7"
136
+ "react": "^19.3.1",
137
+ "react-dom": "^19.3.1",
138
+ "vite": "^8.3.5",
139
+ "jsdom": "30.1.3",
140
+ "vue": "^3.5.44",
141
+ "@vue/compiler-sfc": "^3.5.44",
142
+ "@vitejs/plugin-vue": "^6.0.10",
143
+ "vue-tsc": "^3.3.13",
144
+ "nuxt": "4.6.2"
95
145
  },
96
146
  "scripts": {
97
- "build": "rm -rf dist && tsup && node scripts/mark-react-client.mjs",
147
+ "build": "rm -rf dist && tsup && tsup --config tsup.vue.config.ts && node scripts/mark-react-client.mjs",
98
148
  "dev": "tsup --watch",
99
149
  "typecheck": "tsc --noEmit",
100
- "test": "vitest run --passWithNoTests --exclude \"tests/browser/**\"",
101
- "test:watch": "vitest --exclude \"tests/browser/**\"",
150
+ "test": "vitest run --passWithNoTests --exclude \"tests/browser/**\" --exclude \"tests/vue-browser/**\"",
151
+ "test:watch": "vitest --exclude \"tests/browser/**\" --exclude \"tests/vue-browser/**\"",
102
152
  "clean": "rm -rf dist",
103
153
  "test:browser": "playwright test",
104
154
  "test:browser:serve": "vite tests/browser --host 127.0.0.1 --port 4179 --strictPort",
105
155
  "lint": "eslint .",
106
156
  "lint:fix": "eslint . --fix",
107
157
  "test:types": "tsc --noEmit -p tests/types/tsconfig.json",
108
- "test:package": "node scripts/smoke-package.mjs"
158
+ "test:package": "node scripts/smoke-v2-package.mjs",
159
+ "test:browser:vue": "playwright test --config playwright.vue.config.ts"
109
160
  }
110
161
  }
@@ -1,12 +0,0 @@
1
- import {q as q$1,r,f,g as g$1,a,o,p,j,k as k$1,l,m,n}from'./chunk-WFG34KG5.js';var A=(r=>(r.CIRCLE="circle",r.BLUR_CIRCLE="blur-circle",r.SLIDE="slide",r.CLIP_PATH="clip-path",r.POLYGON_GRADIENT="polygon-gradient",r.TRIANGLE="triangle",r.SVG_LOGO="svg-logo",r))(A||{}),D=["top-left","top","top-right","right","bottom-right","bottom","bottom-left","left"];var O=e=>{if(e.logoLight!==void 0||e.logoDark!==void 0){if(!e.logoLight||!e.logoDark)throw new Error("logoLight and logoDark must both be provided.");if(e.logo!==void 0)throw new Error("Use logo or the logoLight/logoDark pair, not both.");return {logoLight:e.logoLight,logoDark:e.logoDark}}return {logo:e.logo}},E=0,S=e=>{let t=I(e.logo);if(!t)return;let n=e.logoWidth!=="auto"&&e.logoWidth&&Number.isFinite(e.logoWidth)&&e.logoWidth>0?e.logoWidth:void 0,o=e.logoHeight!=="auto"&&e.logoHeight&&Number.isFinite(e.logoHeight)&&e.logoHeight>0?e.logoHeight:void 0,a=n??(o?o*t.aspectRatio:e.logoWidth==="auto"||e.logoHeight==="auto"?t.naturalWidth:96),i=o??a/t.aspectRatio,s=`ui-theme-logo-${++E}`,r=document.createElement("img");r.src=t.image,r.alt="",r.setAttribute("aria-hidden","true"),r.setAttribute("data-ui-theme-logo",""),r.style.cssText=`position:fixed;left:calc(50% - ${a/2}px);top:calc(50% - ${i/2}px);width:${a}px;height:${i}px;max-width:none;max-height:none;object-fit:contain;display:block;margin:0;padding:0;border:0;transform:none;pointer-events:none;z-index:2147483647;view-transition-name:${s};`;let m=document.createElement("style");return m.setAttribute("data-ui-theme-logo-style",""),m.textContent=`
2
- @keyframes ${s}-fade { 0%, 85% { opacity:1; } 100% { opacity:0; } }
3
- html[data-ui-theme-transition]::view-transition-group(${s}) {
4
- z-index:2;
5
- animation:${s}-fade ${e.duration}ms linear both;
6
- }
7
- html[data-ui-theme-transition]::view-transition-old(${s}) { display:none; }
8
- html[data-ui-theme-transition]::view-transition-new(${s}) {
9
- animation:none; mix-blend-mode:normal;
10
- }
11
- `,document.head.appendChild(m),document.documentElement.appendChild(r),{element:r,style:m}},u=new Map,k=e=>{if(typeof window>"u")return Promise.resolve();let t=u.get(e);if(t)return t.loading;let n={loading:Promise.resolve()};return u.set(e,n),n.loading=(async()=>{let o=new AbortController,a=setTimeout(()=>o.abort(),2e3);try{let i=await fetch(e,{signal:o.signal});if(!i.ok)return;let s=await i.text(),r=new DOMParser().parseFromString(s,"image/svg+xml");if(r.querySelector("parsererror")||r.documentElement.localName!=="svg"||r.documentElement.namespaceURI!=="http://www.w3.org/2000/svg")return;let m=`data:image/svg+xml,${encodeURIComponent(s)}`,l=new Image;l.src=m,await l.decode(),l.naturalWidth>0&&l.naturalHeight>0&&(n.ready={image:m,naturalWidth:l.naturalWidth,aspectRatio:l.naturalWidth/l.naturalHeight});}catch{}finally{clearTimeout(a);}})(),n.loading},I=e=>e?u.get(e)?.ready:void 0;var g=new WeakMap,G=async(e,t)=>{if(typeof document>"u"){e();return}let n$1=g.get(document);n$1?.transition?.skipTransition(),n$1?.animation?.cancel(),n$1?.logo?.element.remove(),n$1?.logo?.style.remove();let o$1={updateDone:Promise.resolve()};g.set(document,o$1);let a$1=()=>{o$1.animation?.cancel(),o$1.logo?.element.remove(),o$1.logo?.style.remove(),g.get(document)===o$1&&(g.delete(document),document.documentElement.removeAttribute("data-ui-theme-transition"));};o$1.updateDone=(async()=>{if(n$1&&await n$1.updateDone.catch(()=>{}),g.get(document)!==o$1||!t||!f()||g$1()||document.visibilityState==="hidden"){e();return}a(),document.documentElement.setAttribute("data-ui-theme-transition",""),t.animationType==="svg-logo"&&(o$1.logo=S(t));let i;try{i=document.startViewTransition(e);}catch{e();return}o$1.transition=i,i.ready.catch(()=>{}),i.finished.then(a$1,a$1),await i.updateCallbackDone;})();try{await o$1.updateDone;let i=o$1.transition;if(!i){a$1();return}try{await i.ready;}catch{a$1();return}if(g.get(document)!==o$1){i.skipTransition();return}if(!t)return;try{o$1.animation=t.animationType==="slide"?o(t):t.animationType==="blur-circle"?p(t):t.animationType==="clip-path"?j(t):t.animationType==="polygon-gradient"?k$1(t):t.animationType==="triangle"?l(t):t.animationType==="svg-logo"?m(t):n(t),o$1.animation.finished.catch(()=>{});let s=o$1.animation.effect;!(o$1.animation instanceof CSSAnimation)&&(!(s instanceof KeyframeEffect)||s.pseudoElement!=="::view-transition-new(root)")&&(i.skipTransition(),a$1());}catch{i.skipTransition(),a$1();}}catch(i){throw a$1(),i}};var d=typeof window<"u",$=(e=q$1,t=["light","dark","system"],n="system")=>{if(!d)return n;let o;try{o=localStorage.getItem(e);}catch{return n}return t.find(a=>a===o)??n},q=(e,t=q$1)=>{d&&localStorage.setItem(t,e);},V=(e=r,t=["default"],n="default")=>{if(!d)return n;let o;try{o=localStorage.getItem(e);}catch{return n}return o&&t.includes(o)?o:n},M=(e,t=r)=>{d&&localStorage.setItem(t,e);};
12
- export{A as a,D as b,O as c,k as d,G as e,$ as f,q as g,V as h,M as i};
@@ -1,12 +0,0 @@
1
- 'use strict';var chunkW4YFUPGE_cjs=require('./chunk-W4YFUPGE.cjs');var A=(r=>(r.CIRCLE="circle",r.BLUR_CIRCLE="blur-circle",r.SLIDE="slide",r.CLIP_PATH="clip-path",r.POLYGON_GRADIENT="polygon-gradient",r.TRIANGLE="triangle",r.SVG_LOGO="svg-logo",r))(A||{}),D=["top-left","top","top-right","right","bottom-right","bottom","bottom-left","left"];var O=e=>{if(e.logoLight!==void 0||e.logoDark!==void 0){if(!e.logoLight||!e.logoDark)throw new Error("logoLight and logoDark must both be provided.");if(e.logo!==void 0)throw new Error("Use logo or the logoLight/logoDark pair, not both.");return {logoLight:e.logoLight,logoDark:e.logoDark}}return {logo:e.logo}},E=0,S=e=>{let t=I(e.logo);if(!t)return;let n=e.logoWidth!=="auto"&&e.logoWidth&&Number.isFinite(e.logoWidth)&&e.logoWidth>0?e.logoWidth:void 0,o=e.logoHeight!=="auto"&&e.logoHeight&&Number.isFinite(e.logoHeight)&&e.logoHeight>0?e.logoHeight:void 0,a=n??(o?o*t.aspectRatio:e.logoWidth==="auto"||e.logoHeight==="auto"?t.naturalWidth:96),i=o??a/t.aspectRatio,s=`ui-theme-logo-${++E}`,r=document.createElement("img");r.src=t.image,r.alt="",r.setAttribute("aria-hidden","true"),r.setAttribute("data-ui-theme-logo",""),r.style.cssText=`position:fixed;left:calc(50% - ${a/2}px);top:calc(50% - ${i/2}px);width:${a}px;height:${i}px;max-width:none;max-height:none;object-fit:contain;display:block;margin:0;padding:0;border:0;transform:none;pointer-events:none;z-index:2147483647;view-transition-name:${s};`;let m=document.createElement("style");return m.setAttribute("data-ui-theme-logo-style",""),m.textContent=`
2
- @keyframes ${s}-fade { 0%, 85% { opacity:1; } 100% { opacity:0; } }
3
- html[data-ui-theme-transition]::view-transition-group(${s}) {
4
- z-index:2;
5
- animation:${s}-fade ${e.duration}ms linear both;
6
- }
7
- html[data-ui-theme-transition]::view-transition-old(${s}) { display:none; }
8
- html[data-ui-theme-transition]::view-transition-new(${s}) {
9
- animation:none; mix-blend-mode:normal;
10
- }
11
- `,document.head.appendChild(m),document.documentElement.appendChild(r),{element:r,style:m}},u=new Map,k=e=>{if(typeof window>"u")return Promise.resolve();let t=u.get(e);if(t)return t.loading;let n={loading:Promise.resolve()};return u.set(e,n),n.loading=(async()=>{let o=new AbortController,a=setTimeout(()=>o.abort(),2e3);try{let i=await fetch(e,{signal:o.signal});if(!i.ok)return;let s=await i.text(),r=new DOMParser().parseFromString(s,"image/svg+xml");if(r.querySelector("parsererror")||r.documentElement.localName!=="svg"||r.documentElement.namespaceURI!=="http://www.w3.org/2000/svg")return;let m=`data:image/svg+xml,${encodeURIComponent(s)}`,l=new Image;l.src=m,await l.decode(),l.naturalWidth>0&&l.naturalHeight>0&&(n.ready={image:m,naturalWidth:l.naturalWidth,aspectRatio:l.naturalWidth/l.naturalHeight});}catch{}finally{clearTimeout(a);}})(),n.loading},I=e=>e?u.get(e)?.ready:void 0;var g=new WeakMap,G=async(e,t)=>{if(typeof document>"u"){e();return}let n=g.get(document);n?.transition?.skipTransition(),n?.animation?.cancel(),n?.logo?.element.remove(),n?.logo?.style.remove();let o={updateDone:Promise.resolve()};g.set(document,o);let a=()=>{o.animation?.cancel(),o.logo?.element.remove(),o.logo?.style.remove(),g.get(document)===o&&(g.delete(document),document.documentElement.removeAttribute("data-ui-theme-transition"));};o.updateDone=(async()=>{if(n&&await n.updateDone.catch(()=>{}),g.get(document)!==o||!t||!chunkW4YFUPGE_cjs.f()||chunkW4YFUPGE_cjs.g()||document.visibilityState==="hidden"){e();return}chunkW4YFUPGE_cjs.a(),document.documentElement.setAttribute("data-ui-theme-transition",""),t.animationType==="svg-logo"&&(o.logo=S(t));let i;try{i=document.startViewTransition(e);}catch{e();return}o.transition=i,i.ready.catch(()=>{}),i.finished.then(a,a),await i.updateCallbackDone;})();try{await o.updateDone;let i=o.transition;if(!i){a();return}try{await i.ready;}catch{a();return}if(g.get(document)!==o){i.skipTransition();return}if(!t)return;try{o.animation=t.animationType==="slide"?chunkW4YFUPGE_cjs.o(t):t.animationType==="blur-circle"?chunkW4YFUPGE_cjs.p(t):t.animationType==="clip-path"?chunkW4YFUPGE_cjs.j(t):t.animationType==="polygon-gradient"?chunkW4YFUPGE_cjs.k(t):t.animationType==="triangle"?chunkW4YFUPGE_cjs.l(t):t.animationType==="svg-logo"?chunkW4YFUPGE_cjs.m(t):chunkW4YFUPGE_cjs.n(t),o.animation.finished.catch(()=>{});let s=o.animation.effect;!(o.animation instanceof CSSAnimation)&&(!(s instanceof KeyframeEffect)||s.pseudoElement!=="::view-transition-new(root)")&&(i.skipTransition(),a());}catch{i.skipTransition(),a();}}catch(i){throw a(),i}};var d=typeof window<"u",$=(e=chunkW4YFUPGE_cjs.q,t=["light","dark","system"],n="system")=>{if(!d)return n;let o;try{o=localStorage.getItem(e);}catch{return n}return t.find(a=>a===o)??n},q=(e,t=chunkW4YFUPGE_cjs.q)=>{d&&localStorage.setItem(t,e);},V=(e=chunkW4YFUPGE_cjs.r,t=["default"],n="default")=>{if(!d)return n;let o;try{o=localStorage.getItem(e);}catch{return n}return o&&t.includes(o)?o:n},M=(e,t=chunkW4YFUPGE_cjs.r)=>{d&&localStorage.setItem(t,e);};
12
- exports.a=A;exports.b=D;exports.c=O;exports.d=k;exports.e=G;exports.f=$;exports.g=q;exports.h=V;exports.i=M;
package/dist/cli/index.js DELETED
@@ -1,39 +0,0 @@
1
- #!/usr/bin/env node
2
- import {parseArgs}from'util';import {readFile,writeFile,readdir}from'fs/promises';import u from'path';import {createInterface}from'readline/promises';var g,y,$,E,S=true;typeof process<"u"&&({FORCE_COLOR:g,NODE_DISABLE_COLORS:y,NO_COLOR:$,TERM:E}=process.env||{},S=process.stdout&&process.stdout.isTTY);var _={enabled:!y&&$==null&&E!=="dumb"&&(g!=null&&g!=="0"||S)};function o(e,t){let n=new RegExp(`\\x1b\\[${t}m`,"g"),r=`\x1B[${e}m`,i=`\x1B[${t}m`;return function(s){return !_.enabled||s==null?s:r+(~(""+s).indexOf(i)?s.replace(n,i+r):s)+i}}var a=o(1,22),p=o(2,22),f=o(31,39),d=o(32,39),m=o(33,39),w=o(34,39),O=o(36,39);var h="@ui-theme/web",c="uitheme-web",M=/(['"`])@ui-theme\/web(?![@\w-])(\/[^'"`\n]*)?\1/g,T=/node_modules\/@ui-theme\/web(?![\w-])/g,j=/"@ui-theme\/web"\s*:\s*"([^"]*)"/g;function A(e){return e.replace(M,(t,n,r)=>`${n}${c}${r??""}${n}`)}function D(e){return e.replace(T,`node_modules/${c}`)}function k(e){return D(A(e))}function C(e,t){let n=false,r=e.replace(j,(i,s)=>t===null?(n=true,`"${c}": "${s}"`):`"${c}": "^${t}"`);return {text:r,changed:r!==e,keptRange:n}}var U=new Set([".ts",".tsx",".js",".jsx",".mjs",".cjs",".mts",".cts",".css"]),F=new Set(["node_modules",".git",".next",".output",".svelte-kit",".turbo",".vercel",".cache","build","coverage","dist","out"]),G=12;async function Y(){try{let e=new URL("../../package.json",import.meta.url),t=JSON.parse(await readFile(e,"utf8")),n=String(t.version??"");return /^\d+\.\d+\.\d+(?:[-+][a-zA-Z0-9.-]+)?$/.test(n)?n:null}catch{return null}}async function N(e,t,n){if(n>G)return [];let r=await readdir(t,{withFileTypes:true}),i=[];for(let s of r){let l=u.join(t,s.name);if(s.isDirectory()){if(F.has(s.name))continue;i.push(...await N(e,l,n+1));continue}s.isFile()&&U.has(u.extname(s.name))&&i.push(l);}return i}async function B(e){let t=[];for(let n of await N(e,e,0)){let r=await readFile(n,"utf8"),i=k(r);i!==r&&t.push({file:n,before:r,after:i});}return t}async function W(e,t){let n=u.join(e,"package.json"),r;try{r=await readFile(n,"utf8");}catch{return null}let{text:i,changed:s,keptRange:l}=C(r,t);return s?{file:n,before:r,after:i,keptRange:l}:null}async function H(e){let t=createInterface({input:process.stdin,output:process.stdout});try{let n=await t.question(e);return /^y(es)?$/i.test(n.trim())}finally{t.close();}}function X(e,t,n){if(process.stdout.write(`
3
- `),t.length===0&&n===null){process.stdout.write(`${d("Nothing to do.")} No file mentions ${h}.
4
-
5
- `);return}process.stdout.write(`The migration will rewrite ${a(String(t.length+(n?1:0)))} file(s):
6
-
7
- `);for(let r of t)process.stdout.write(` ${w(u.relative(e,r.file))}
8
- `);n&&process.stdout.write(` ${w(u.relative(e,n.file))}
9
- `),process.stdout.write(`
10
- ${h} becomes ${c}.
11
- `),process.stdout.write(`${p("Entry points keep their names: /core, /react and /tanstack.")}
12
-
13
- `);}async function P(e){await writeFile(e.file,e.after,"utf8");}async function R(e){let t=u.resolve(e.cwd),n=await Y(),r=await B(t),i=await W(t,n);if(X(t,r,i),r.length===0&&i===null)return 0;if(!e.yes&&!await H(`Rewrite these files? ${p("[y/N]")} `))return process.stdout.write(`
14
- ${m("Cancelled.")} No file was changed.
15
- `),0;for(let l of r)await P(l);i&&await P(i);let s=r.length+(i?1:0);return process.stdout.write(`
16
- ${d("Done.")} Rewrote ${a(String(s))} file(s).
17
- `),process.stdout.write(`Install the new package with ${O(`${a(c)}`)} and run your package manager.
18
-
19
- `),i?.keptRange&&process.stdout.write(`${m("Note.")} The command could not read its own version, so the dependency range in package.json was left as it was. Set it to ^${c}'s current version by hand.
20
-
21
- `),0}var v=`${a("uitheme-web")}
22
-
23
- ${a("Usage")}
24
- uitheme-web <command> [options]
25
-
26
- ${a("Commands")}
27
- migrate Move a project from @ui-theme/web to uitheme-web
28
-
29
- ${a("Options")}
30
- -c, --cwd <dir> Project directory. Defaults to the current directory
31
- -y, --yes Rewrite without asking for confirmation
32
- -h, --help Show this help
33
-
34
- ${p("Example")}
35
- npx uitheme-web migrate
36
- `;function b(e){process.stderr.write(`${f(e)}
37
-
38
- ${v}`),process.exit(1);}async function K(e){let t,n;try{let s=parseArgs({args:e,allowPositionals:!0,options:{cwd:{type:"string",short:"c"},yes:{type:"boolean",short:"y",default:!1},help:{type:"boolean",short:"h",default:!1}}});t=s.values,n=s.positionals;}catch(s){b(s instanceof Error?s.message:String(s));}let[r,...i]=n;if(t.help||r===void 0||r==="help"){process.stdout.write(v);return}if(i.length>0&&b(`Unexpected argument: ${i.join(" ")}`),r==="migrate"){await R({cwd:t.cwd??process.cwd(),yes:t.yes??false});return}b(`Unknown command: ${r}`);}K(process.argv.slice(2)).catch(e=>{process.stderr.write(`${f("The command failed.")} ${e instanceof Error?e.message:String(e)}
39
- `),process.exitCode=1;});