uitheme-web 1.1.0 → 1.2.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/dist/cli/index.js CHANGED
@@ -1,311 +1,39 @@
1
1
  #!/usr/bin/env node
2
- import { parseArgs } from 'util';
3
- import { readFile, writeFile, readdir } from 'fs/promises';
4
- import path from 'path';
5
- import { createInterface } from 'readline/promises';
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}.
6
4
 
7
- // ../../node_modules/.pnpm/kleur@4.1.5/node_modules/kleur/colors.mjs
8
- var FORCE_COLOR;
9
- var NODE_DISABLE_COLORS;
10
- var NO_COLOR;
11
- var TERM;
12
- var isTTY = true;
13
- if (typeof process !== "undefined") {
14
- ({ FORCE_COLOR, NODE_DISABLE_COLORS, NO_COLOR, TERM } = process.env || {});
15
- isTTY = process.stdout && process.stdout.isTTY;
16
- }
17
- var $ = {
18
- enabled: !NODE_DISABLE_COLORS && NO_COLOR == null && TERM !== "dumb" && (FORCE_COLOR != null && FORCE_COLOR !== "0" || isTTY)
19
- };
20
- function init(x, y) {
21
- let rgx = new RegExp(`\\x1b\\[${y}m`, "g");
22
- let open = `\x1B[${x}m`, close = `\x1B[${y}m`;
23
- return function(txt) {
24
- if (!$.enabled || txt == null) return txt;
25
- return open + (!!~("" + txt).indexOf(close) ? txt.replace(rgx, close + open) : txt) + close;
26
- };
27
- }
28
- var bold = init(1, 22);
29
- var dim = init(2, 22);
30
- var red = init(31, 39);
31
- var green = init(32, 39);
32
- var yellow = init(33, 39);
33
- var blue = init(34, 39);
34
- var cyan = init(36, 39);
5
+ `);return}process.stdout.write(`The migration will rewrite ${a(String(t.length+(n?1:0)))} file(s):
35
6
 
36
- // src/cli/rewrite.ts
37
- var OLD_NAME = "@ui-theme/web";
38
- var NEW_NAME = "uitheme-web";
39
- var SPECIFIER = /(['"`])@ui-theme\/web(?![@\w-])(\/[^'"`\n]*)?\1/g;
40
- var NODE_MODULES_PATH = /node_modules\/@ui-theme\/web(?![\w-])/g;
41
- var PACKAGE_JSON_ENTRY = /"@ui-theme\/web"\s*:\s*"([^"]*)"/g;
42
- function rewriteModuleSpecifier(source) {
43
- return source.replace(
44
- SPECIFIER,
45
- (_match, quote, subpath) => `${quote}${NEW_NAME}${subpath ?? ""}${quote}`
46
- );
47
- }
48
- function rewriteNodeModulesPath(source) {
49
- return source.replace(NODE_MODULES_PATH, `node_modules/${NEW_NAME}`);
50
- }
51
- function rewriteSource(source) {
52
- return rewriteNodeModulesPath(rewriteModuleSpecifier(source));
53
- }
54
- function rewritePackageJson(source, version) {
55
- let keptRange = false;
56
- const text = source.replace(PACKAGE_JSON_ENTRY, (_match, range) => {
57
- if (version === null) {
58
- keptRange = true;
59
- return `"${NEW_NAME}": "${range}"`;
60
- }
61
- return `"${NEW_NAME}": "^${version}"`;
62
- });
63
- return { text, changed: text !== source, keptRange };
64
- }
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.")}
65
12
 
66
- // src/cli/migrate.ts
67
- var SOURCE_EXTENSIONS = /* @__PURE__ */ new Set([
68
- ".ts",
69
- ".tsx",
70
- ".js",
71
- ".jsx",
72
- ".mjs",
73
- ".cjs",
74
- ".mts",
75
- ".cts",
76
- ".css"
77
- ]);
78
- var IGNORED_DIRECTORIES = /* @__PURE__ */ new Set([
79
- "node_modules",
80
- ".git",
81
- ".next",
82
- ".output",
83
- ".svelte-kit",
84
- ".turbo",
85
- ".vercel",
86
- ".cache",
87
- "build",
88
- "coverage",
89
- "dist",
90
- "out"
91
- ]);
92
- var MAX_DEPTH = 12;
93
- async function readOwnVersion() {
94
- try {
95
- const manifestUrl = new URL("../../package.json", import.meta.url);
96
- const manifest = JSON.parse(await readFile(manifestUrl, "utf8"));
97
- return manifest.version ?? null;
98
- } catch {
99
- return null;
100
- }
101
- }
102
- async function collectSourceFiles(root, directory, depth) {
103
- if (depth > MAX_DEPTH) {
104
- return [];
105
- }
106
- const entries = await readdir(directory, { withFileTypes: true });
107
- const files = [];
108
- for (const entry of entries) {
109
- const full = path.join(directory, entry.name);
110
- if (entry.isDirectory()) {
111
- if (IGNORED_DIRECTORIES.has(entry.name)) {
112
- continue;
113
- }
114
- files.push(...await collectSourceFiles(root, full, depth + 1));
115
- continue;
116
- }
117
- if (!entry.isFile()) {
118
- continue;
119
- }
120
- if (SOURCE_EXTENSIONS.has(path.extname(entry.name))) {
121
- files.push(full);
122
- }
123
- }
124
- return files;
125
- }
126
- async function planSourceChanges(root) {
127
- const changes = [];
128
- for (const file of await collectSourceFiles(root, root, 0)) {
129
- const before = await readFile(file, "utf8");
130
- const after = rewriteSource(before);
131
- if (after !== before) {
132
- changes.push({ file, before, after });
133
- }
134
- }
135
- return changes;
136
- }
137
- async function planPackageJsonChange(root, version) {
138
- const file = path.join(root, "package.json");
139
- let before;
140
- try {
141
- before = await readFile(file, "utf8");
142
- } catch {
143
- return null;
144
- }
145
- const {
146
- text: after,
147
- changed,
148
- keptRange
149
- } = rewritePackageJson(before, version);
150
- if (!changed) {
151
- return null;
152
- }
153
- return { file, before, after, keptRange };
154
- }
155
- async function confirm(question) {
156
- const prompt = createInterface({
157
- input: process.stdin,
158
- output: process.stdout
159
- });
160
- try {
161
- const answer = await prompt.question(question);
162
- return /^y(es)?$/i.test(answer.trim());
163
- } finally {
164
- prompt.close();
165
- }
166
- }
167
- function reportPlan(root, source, manifest) {
168
- process.stdout.write("\n");
169
- if (source.length === 0 && manifest === null) {
170
- process.stdout.write(
171
- `${green("Nothing to do.")} No file mentions ${OLD_NAME}.
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.
172
18
 
173
- `
174
- );
175
- return;
176
- }
177
- process.stdout.write(
178
- `The migration will rewrite ${bold(String(source.length + (manifest ? 1 : 0)))} file(s):
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.
179
20
 
180
- `
181
- );
182
- for (const change of source) {
183
- process.stdout.write(` ${blue(path.relative(root, change.file))}
184
- `);
185
- }
186
- if (manifest) {
187
- process.stdout.write(` ${blue(path.relative(root, manifest.file))}
188
- `);
189
- }
190
- process.stdout.write(`
191
- ${OLD_NAME} becomes ${NEW_NAME}.
192
- `);
193
- process.stdout.write(
194
- `${dim("Entry points keep their names: /core, /react and /tanstack.")}
21
+ `),0}var v=`${a("uitheme-web")}
195
22
 
196
- `
197
- );
198
- }
199
- async function applyChange(change) {
200
- await writeFile(change.file, change.after, "utf8");
201
- }
202
- async function runMigrate(options) {
203
- const root = path.resolve(options.cwd);
204
- const version = await readOwnVersion();
205
- const source = await planSourceChanges(root);
206
- const manifest = await planPackageJsonChange(root, version);
207
- reportPlan(root, source, manifest);
208
- if (source.length === 0 && manifest === null) {
209
- return 0;
210
- }
211
- if (!options.yes) {
212
- const proceed = await confirm(`Rewrite these files? ${dim("[y/N]")} `);
213
- if (!proceed) {
214
- process.stdout.write(`
215
- ${yellow("Cancelled.")} No file was changed.
216
- `);
217
- return 0;
218
- }
219
- }
220
- for (const change of source) {
221
- await applyChange(change);
222
- }
223
- if (manifest) {
224
- await applyChange(manifest);
225
- }
226
- const total = source.length + (manifest ? 1 : 0);
227
- process.stdout.write(
228
- `
229
- ${green("Done.")} Rewrote ${bold(String(total))} file(s).
230
- `
231
- );
232
- process.stdout.write(
233
- `Install the new package with ${cyan(`${bold(NEW_NAME)}`)} and run your package manager.
234
-
235
- `
236
- );
237
- if (manifest?.keptRange) {
238
- process.stdout.write(
239
- `${yellow("Note.")} The command could not read its own version, so the dependency range in package.json was left as it was. Set it to ^${NEW_NAME}'s current version by hand.
240
-
241
- `
242
- );
243
- }
244
- return 0;
245
- }
246
-
247
- // src/cli/index.ts
248
- var USAGE = `${bold("uitheme-web")}
249
-
250
- ${bold("Usage")}
23
+ ${a("Usage")}
251
24
  uitheme-web <command> [options]
252
25
 
253
- ${bold("Commands")}
26
+ ${a("Commands")}
254
27
  migrate Move a project from @ui-theme/web to uitheme-web
255
28
 
256
- ${bold("Options")}
29
+ ${a("Options")}
257
30
  -c, --cwd <dir> Project directory. Defaults to the current directory
258
31
  -y, --yes Rewrite without asking for confirmation
259
32
  -h, --help Show this help
260
33
 
261
- ${dim("Example")}
34
+ ${p("Example")}
262
35
  npx uitheme-web migrate
263
- `;
264
- function fail(message) {
265
- process.stderr.write(`${red(message)}
36
+ `;function b(e){process.stderr.write(`${f(e)}
266
37
 
267
- ${USAGE}`);
268
- process.exit(1);
269
- }
270
- async function main(argv) {
271
- let values;
272
- let positionals;
273
- try {
274
- const parsed = parseArgs({
275
- args: argv,
276
- allowPositionals: true,
277
- options: {
278
- cwd: { type: "string", short: "c" },
279
- yes: { type: "boolean", short: "y", default: false },
280
- help: { type: "boolean", short: "h", default: false }
281
- }
282
- });
283
- values = parsed.values;
284
- positionals = parsed.positionals;
285
- } catch (error) {
286
- fail(error instanceof Error ? error.message : String(error));
287
- }
288
- const [command, ...rest] = positionals;
289
- if (values.help || command === void 0 || command === "help") {
290
- process.stdout.write(USAGE);
291
- return;
292
- }
293
- if (rest.length > 0) {
294
- fail(`Unexpected argument: ${rest.join(" ")}`);
295
- }
296
- if (command === "migrate") {
297
- await runMigrate({
298
- cwd: values.cwd ?? process.cwd(),
299
- yes: values.yes ?? false
300
- });
301
- return;
302
- }
303
- fail(`Unknown command: ${command}`);
304
- }
305
- main(process.argv.slice(2)).catch((error) => {
306
- process.stderr.write(
307
- `${red("The command failed.")} ${error instanceof Error ? error.message : String(error)}
308
- `
309
- );
310
- process.exitCode = 1;
311
- });
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;});
@@ -0,0 +1,145 @@
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
+ interface AnimationConfig extends ThemeAnimationSettings {
41
+ /** Asset already selected for the destination theme before capture. */
42
+ logo?: string;
43
+ a?: number;
44
+ b?: number;
45
+ x: number;
46
+ y: number;
47
+ duration: number;
48
+ easing: string;
49
+ animationType: ThemeAnimationType;
50
+ blurAmount: number;
51
+ styleId: string;
52
+ }
53
+ interface ThemeConfig {
54
+ themes?: Theme[];
55
+ colorThemes?: ColorTheme[];
56
+ defaultTheme?: Theme;
57
+ defaultColorTheme?: ColorTheme;
58
+ globalClassName?: string;
59
+ colorThemePrefix?: string;
60
+ storageKey?: string;
61
+ colorStorageKey?: string;
62
+ }
63
+ interface ThemeState {
64
+ theme: Theme;
65
+ colorTheme: ColorTheme;
66
+ resolvedTheme: 'light' | 'dark';
67
+ }
68
+
69
+ /** Injects styles scoped to transitions owned by this library. */
70
+ declare const injectBaseStyles: () => void;
71
+ /**
72
+ * Creates an SVG blur circle mask for animations
73
+ * @param blur - Blur amount for the gaussian filter
74
+ * @returns Data URI string for the SVG mask
75
+ */
76
+ declare const createBlurCircleMask: (blur: number) => string;
77
+ /**
78
+ * Gets the system theme preference
79
+ * @returns 'light' or 'dark' based on system preference
80
+ */
81
+ declare const getSystemTheme: () => "light" | "dark";
82
+ /**
83
+ * Resolves a theme value to its actual light/dark value
84
+ * @param theme - Theme to resolve ('light', 'dark', or 'system')
85
+ * @returns Resolved theme ('light' or 'dark')
86
+ */
87
+ declare const resolveTheme: (theme: string) => "light" | "dark";
88
+ /**
89
+ * Resolves a stored theme to the server-side class to apply on <html>.
90
+ * CSS mode uses the 'system' class so media queries can respond before hydration.
91
+ */
92
+ declare const resolveThemeForServer: (theme: string) => "light" | "dark" | "system";
93
+ /**
94
+ * Checks if the browser supports View Transitions API
95
+ * @returns true if view transitions are supported
96
+ */
97
+ declare const supportsViewTransitions: () => boolean;
98
+ /**
99
+ * Checks if user prefers reduced motion
100
+ * @returns true if user prefers reduced motion
101
+ */
102
+ declare const prefersReducedMotion: () => boolean;
103
+ /**
104
+ * Converts a slide direction to from coordinates
105
+ * @param direction - Slide direction
106
+ * @returns Object with a (x) and b (y) coordinates
107
+ */
108
+ declare const getSlideFromCoords: (direction: SlideDirection) => {
109
+ a: number;
110
+ b: number;
111
+ };
112
+ /** Viewport CSS coordinates for fixed origins; button origins stay in the hook. */
113
+ declare const getAnimationPosition: (position: Exclude<AnimationPosition, "trigger">) => {
114
+ x: number;
115
+ y: number;
116
+ };
117
+ /** A half-plane wipe, including diagonals, with compatible four-point polygons. */
118
+ declare const createClipPathAnimation: (config: AnimationConfig) => Animation;
119
+ /** Feathered polygon/edge mask, without Gaussian filtering or scaling content. */
120
+ declare const createPolygonGradientAnimation: (config: AnimationConfig) => Animation;
121
+ /** Upright triangle; its final incircle contains all four snapshot corners. */
122
+ declare const createTriangleAnimation: (config: AnimationConfig) => Animation;
123
+ /** The fixed logo has its own snapshot; only the page reveal grows beneath it. */
124
+ declare const createSvgLogoAnimation: (config: AnimationConfig) => Animation;
125
+ /** Native circular clip; browser compositor support varies by engine. */
126
+ declare const createCircleAnimation: (config: AnimationConfig) => Animation;
127
+ /** Predetermined translation uses WAAPI rather than a timer-owned stylesheet. */
128
+ declare const createSlideAnimation: (config: AnimationConfig) => Animation;
129
+ /**
130
+ * A bounded radial gradient feathers only the reveal edge. Unlike the old SVG
131
+ * Gaussian mask, it needs no huge filtered surface or animation on the old view.
132
+ * Mask animation can still paint; this is not a compositor-only guarantee.
133
+ */
134
+ declare const createBlurCircleAnimation: (config: AnimationConfig) => Animation;
135
+
136
+ declare const STORAGE_KEY = "theme";
137
+ declare const COLOR_STORAGE_KEY = "color-theme";
138
+ declare const GLOBAL_CLASS_NAME = "dark";
139
+ declare const COLOR_THEME_PREFIX = "theme-";
140
+ declare const DEFAULT_DURATION = 400;
141
+ declare const DEFAULT_EASING = "cubic-bezier(0.32, 0.72, 0, 1)";
142
+ declare const DEFAULT_BLUR_AMOUNT = 2;
143
+ declare const DEFAULT_STYLE_ID = "ui-theme-style";
144
+
145
+ export { type AnimationConfig as A, prefersReducedMotion as B, type ColorTheme as C, DEFAULT_BLUR_AMOUNT as D, resolveTheme as E, supportsViewTransitions as F, GLOBAL_CLASS_NAME as G, resolveThemeForServer as H, STORAGE_KEY as S, type Theme as T, type AnimationPosition as a, COLOR_STORAGE_KEY as b, COLOR_THEME_PREFIX as c, DEFAULT_DURATION as d, DEFAULT_EASING as e, DEFAULT_STYLE_ID as f, type SlideDirection as g, TRANSITION_DIRECTIONS as h, type ThemeAnimationOptions as i, ThemeAnimationType as j, type ThemeConfig as k, type ThemeLogoOptions as l, type ThemeState as m, type TransitionDirection as n, createBlurCircleAnimation as o, createBlurCircleMask as p, createCircleAnimation as q, createClipPathAnimation as r, createPolygonGradientAnimation as s, createSlideAnimation as t, createSvgLogoAnimation as u, createTriangleAnimation as v, getAnimationPosition as w, getSlideFromCoords as x, getSystemTheme as y, injectBaseStyles as z };
@@ -0,0 +1,145 @@
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
+ interface AnimationConfig extends ThemeAnimationSettings {
41
+ /** Asset already selected for the destination theme before capture. */
42
+ logo?: string;
43
+ a?: number;
44
+ b?: number;
45
+ x: number;
46
+ y: number;
47
+ duration: number;
48
+ easing: string;
49
+ animationType: ThemeAnimationType;
50
+ blurAmount: number;
51
+ styleId: string;
52
+ }
53
+ interface ThemeConfig {
54
+ themes?: Theme[];
55
+ colorThemes?: ColorTheme[];
56
+ defaultTheme?: Theme;
57
+ defaultColorTheme?: ColorTheme;
58
+ globalClassName?: string;
59
+ colorThemePrefix?: string;
60
+ storageKey?: string;
61
+ colorStorageKey?: string;
62
+ }
63
+ interface ThemeState {
64
+ theme: Theme;
65
+ colorTheme: ColorTheme;
66
+ resolvedTheme: 'light' | 'dark';
67
+ }
68
+
69
+ /** Injects styles scoped to transitions owned by this library. */
70
+ declare const injectBaseStyles: () => void;
71
+ /**
72
+ * Creates an SVG blur circle mask for animations
73
+ * @param blur - Blur amount for the gaussian filter
74
+ * @returns Data URI string for the SVG mask
75
+ */
76
+ declare const createBlurCircleMask: (blur: number) => string;
77
+ /**
78
+ * Gets the system theme preference
79
+ * @returns 'light' or 'dark' based on system preference
80
+ */
81
+ declare const getSystemTheme: () => "light" | "dark";
82
+ /**
83
+ * Resolves a theme value to its actual light/dark value
84
+ * @param theme - Theme to resolve ('light', 'dark', or 'system')
85
+ * @returns Resolved theme ('light' or 'dark')
86
+ */
87
+ declare const resolveTheme: (theme: string) => "light" | "dark";
88
+ /**
89
+ * Resolves a stored theme to the server-side class to apply on <html>.
90
+ * CSS mode uses the 'system' class so media queries can respond before hydration.
91
+ */
92
+ declare const resolveThemeForServer: (theme: string) => "light" | "dark" | "system";
93
+ /**
94
+ * Checks if the browser supports View Transitions API
95
+ * @returns true if view transitions are supported
96
+ */
97
+ declare const supportsViewTransitions: () => boolean;
98
+ /**
99
+ * Checks if user prefers reduced motion
100
+ * @returns true if user prefers reduced motion
101
+ */
102
+ declare const prefersReducedMotion: () => boolean;
103
+ /**
104
+ * Converts a slide direction to from coordinates
105
+ * @param direction - Slide direction
106
+ * @returns Object with a (x) and b (y) coordinates
107
+ */
108
+ declare const getSlideFromCoords: (direction: SlideDirection) => {
109
+ a: number;
110
+ b: number;
111
+ };
112
+ /** Viewport CSS coordinates for fixed origins; button origins stay in the hook. */
113
+ declare const getAnimationPosition: (position: Exclude<AnimationPosition, "trigger">) => {
114
+ x: number;
115
+ y: number;
116
+ };
117
+ /** A half-plane wipe, including diagonals, with compatible four-point polygons. */
118
+ declare const createClipPathAnimation: (config: AnimationConfig) => Animation;
119
+ /** Feathered polygon/edge mask, without Gaussian filtering or scaling content. */
120
+ declare const createPolygonGradientAnimation: (config: AnimationConfig) => Animation;
121
+ /** Upright triangle; its final incircle contains all four snapshot corners. */
122
+ declare const createTriangleAnimation: (config: AnimationConfig) => Animation;
123
+ /** The fixed logo has its own snapshot; only the page reveal grows beneath it. */
124
+ declare const createSvgLogoAnimation: (config: AnimationConfig) => Animation;
125
+ /** Native circular clip; browser compositor support varies by engine. */
126
+ declare const createCircleAnimation: (config: AnimationConfig) => Animation;
127
+ /** Predetermined translation uses WAAPI rather than a timer-owned stylesheet. */
128
+ declare const createSlideAnimation: (config: AnimationConfig) => Animation;
129
+ /**
130
+ * A bounded radial gradient feathers only the reveal edge. Unlike the old SVG
131
+ * Gaussian mask, it needs no huge filtered surface or animation on the old view.
132
+ * Mask animation can still paint; this is not a compositor-only guarantee.
133
+ */
134
+ declare const createBlurCircleAnimation: (config: AnimationConfig) => Animation;
135
+
136
+ declare const STORAGE_KEY = "theme";
137
+ declare const COLOR_STORAGE_KEY = "color-theme";
138
+ declare const GLOBAL_CLASS_NAME = "dark";
139
+ declare const COLOR_THEME_PREFIX = "theme-";
140
+ declare const DEFAULT_DURATION = 400;
141
+ declare const DEFAULT_EASING = "cubic-bezier(0.32, 0.72, 0, 1)";
142
+ declare const DEFAULT_BLUR_AMOUNT = 2;
143
+ declare const DEFAULT_STYLE_ID = "ui-theme-style";
144
+
145
+ export { type AnimationConfig as A, prefersReducedMotion as B, type ColorTheme as C, DEFAULT_BLUR_AMOUNT as D, resolveTheme as E, supportsViewTransitions as F, GLOBAL_CLASS_NAME as G, resolveThemeForServer as H, STORAGE_KEY as S, type Theme as T, type AnimationPosition as a, COLOR_STORAGE_KEY as b, COLOR_THEME_PREFIX as c, DEFAULT_DURATION as d, DEFAULT_EASING as e, DEFAULT_STYLE_ID as f, type SlideDirection as g, TRANSITION_DIRECTIONS as h, type ThemeAnimationOptions as i, ThemeAnimationType as j, type ThemeConfig as k, type ThemeLogoOptions as l, type ThemeState as m, type TransitionDirection as n, createBlurCircleAnimation as o, createBlurCircleMask as p, createCircleAnimation as q, createClipPathAnimation as r, createPolygonGradientAnimation as s, createSlideAnimation as t, createSvgLogoAnimation as u, createTriangleAnimation as v, getAnimationPosition as w, getSlideFromCoords as x, getSystemTheme as y, injectBaseStyles as z };