react-native-theme-transition 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Mario Prieta
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,107 @@
1
+ <h1 align="center">react-native-theme-transition</h1>
2
+
3
+ <p align="center">
4
+ Smooth, animated theme transitions for React Native. Expo Go compatible, powered by Reanimated.
5
+ </p>
6
+
7
+ <p align="center">
8
+ <a href="https://www.npmjs.com/package/react-native-theme-transition"><img src="https://img.shields.io/npm/v/react-native-theme-transition.svg" alt="npm version" /></a>
9
+ <a href="https://bundlephobia.com/package/react-native-theme-transition"><img src="https://img.shields.io/bundlephobia/minzip/react-native-theme-transition" alt="bundle size" /></a>
10
+ <img src="https://img.shields.io/badge/Expo_Go-compatible-000.svg?logo=expo&logoColor=white" alt="expo compatible" />
11
+ <img src="https://img.shields.io/badge/React_Compiler-compatible-blue.svg" alt="react compiler" />
12
+ <a href="https://github.com/marioprieta/react-native-theme-transition/blob/main/LICENSE"><img src="https://img.shields.io/npm/l/react-native-theme-transition" alt="license" /></a>
13
+ </p>
14
+
15
+ <table align="center">
16
+ <tr>
17
+ <td align="center"><b>iOS</b></td>
18
+ <td align="center"><b>Android</b></td>
19
+ </tr>
20
+ <tr>
21
+ <td><video src="https://github.com/user-attachments/assets/449220b3-50b1-417e-b2c3-13d815d575d7" width="260" autoplay loop muted playsinline></video></td>
22
+ <td><video src="https://github.com/user-attachments/assets/9c55de09-41d2-4581-9463-eb315156dca3" width="260" autoplay loop muted playsinline></video></td>
23
+ </tr>
24
+ </table>
25
+
26
+ ## Features
27
+
28
+ - **Smooth cross-fade transitions** — powered by Reanimated on the native UI thread (60-120 FPS)
29
+ - **Expo Go compatible** — no native code, no prebuilds required
30
+ - **Multi-theme support** — define as many themes as you need with full TypeScript inference
31
+ - **System theme sync** — follows OS appearance automatically with zero-flash startup
32
+ - **Native UI sync** — alerts, keyboards, and date pickers automatically match your active theme
33
+ - **Transition safe** — blocks concurrent transitions and exposes `isTransitioning`
34
+ - **React Compiler ready** — all hooks follow the [Rules of React](https://react.dev/reference/rules)
35
+ - **Lightweight** — zero runtime dependencies
36
+
37
+ ## Documentation
38
+
39
+ For full docs, API reference, examples, and recipes, visit **[react-native-theme-transition.vercel.app](https://react-native-theme-transition.vercel.app)**.
40
+
41
+ ## Installation
42
+
43
+ ```bash
44
+ # Expo (SDK 54+ already has reanimated and view-shot)
45
+ npx expo install react-native-theme-transition react-native-worklets
46
+
47
+ # React Native CLI
48
+ npm install react-native-theme-transition react-native-reanimated react-native-view-shot react-native-worklets
49
+ ```
50
+
51
+ Add `react-native-worklets/plugin` as the **last plugin** in your `babel.config.js`.
52
+
53
+ ## Quick start
54
+
55
+ ```ts
56
+ // theme.ts
57
+ import { createThemeTransition } from 'react-native-theme-transition';
58
+
59
+ export const { ThemeTransitionProvider, useTheme } = createThemeTransition({
60
+ themes: {
61
+ light: { background: '#ffffff', text: '#000000', primary: '#007AFF' },
62
+ dark: { background: '#000000', text: '#ffffff', primary: '#0A84FF' },
63
+ },
64
+ });
65
+ ```
66
+
67
+ ```tsx
68
+ // App.tsx
69
+ import { ThemeTransitionProvider } from './theme';
70
+
71
+ export default function App() {
72
+ return (
73
+ <ThemeTransitionProvider initialTheme="system">
74
+ <MyApp />
75
+ </ThemeTransitionProvider>
76
+ );
77
+ }
78
+ ```
79
+
80
+ ```tsx
81
+ // MyScreen.tsx
82
+ import { useTheme } from './theme';
83
+
84
+ function MyScreen() {
85
+ const { colors, name, setTheme, isTransitioning } = useTheme();
86
+
87
+ return (
88
+ <View style={{ flex: 1, backgroundColor: colors.background }}>
89
+ <Text style={{ color: colors.text }}>Current: {name}</Text>
90
+ <Pressable
91
+ onPress={() => setTheme(name === 'light' ? 'dark' : 'light')}
92
+ disabled={isTransitioning}
93
+ >
94
+ <Text style={{ color: colors.primary }}>Toggle theme</Text>
95
+ </Pressable>
96
+ </View>
97
+ );
98
+ }
99
+ ```
100
+
101
+ ## Contributing
102
+
103
+ Contributions are welcome! Please read the [contributing guide](./CONTRIBUTING.md) and open an issue first to discuss what you'd like to change.
104
+
105
+ ## License
106
+
107
+ MIT
@@ -0,0 +1,3 @@
1
+ /** Log/error prefix shared across the package. @internal */
2
+ export declare const TAG = "[react-native-theme-transition]";
3
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,eAAO,MAAM,GAAG,oCAAoC,CAAC"}
@@ -0,0 +1,3 @@
1
+ /** Log/error prefix shared across the package. @internal */
2
+ export const TAG = '[react-native-theme-transition]';
3
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,MAAM,CAAC,MAAM,GAAG,GAAG,iCAAiC,CAAC"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Factory that wires the theme transition provider, context, and hooks.
3
+ *
4
+ * @remarks
5
+ * Validates theme configuration at initialization: ensures at least one theme
6
+ * exists and that all themes share identical token keys.
7
+ * Returns a self-contained API ({@link ThemeTransitionAPI}) with no singletons,
8
+ * so multiple theme scopes can coexist in the same app.
9
+ *
10
+ * @module
11
+ */
12
+ import type { ThemeTransitionAPI, ThemeTransitionConfig, ThemeDefinition } from './types';
13
+ /**
14
+ * Creates a fully typed theme transition system.
15
+ *
16
+ * @typeParam T - Your application's theme map, keyed by theme name.
17
+ * @param config - Theme configuration including available themes and defaults.
18
+ * @returns A provider component and hooks scoped to the supplied themes.
19
+ *
20
+ * @example
21
+ * ```tsx
22
+ * const { ThemeTransitionProvider, useTheme } = createThemeTransition({
23
+ * themes: { light: { bg: '#fff' }, dark: { bg: '#000' } },
24
+ * });
25
+ * ```
26
+ */
27
+ export declare function createThemeTransition<T extends Record<string, ThemeDefinition>>(config: ThemeTransitionConfig<T>): ThemeTransitionAPI<T>;
28
+ //# sourceMappingURL=createThemeTransition.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createThemeTransition.d.ts","sourceRoot":"","sources":["../src/createThemeTransition.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EACV,kBAAkB,EAClB,qBAAqB,EACrB,eAAe,EAEhB,MAAM,SAAS,CAAC;AAKjB;;;;;;;;;;;;;GAaG;AACH,wBAAgB,qBAAqB,CACnC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,EACzC,MAAM,EAAE,qBAAqB,CAAC,CAAC,CAAC,GAAG,kBAAkB,CAAC,CAAC,CAAC,CAqDzD"}
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Factory that wires the theme transition provider, context, and hooks.
3
+ *
4
+ * @remarks
5
+ * Validates theme configuration at initialization: ensures at least one theme
6
+ * exists and that all themes share identical token keys.
7
+ * Returns a self-contained API ({@link ThemeTransitionAPI}) with no singletons,
8
+ * so multiple theme scopes can coexist in the same app.
9
+ *
10
+ * @module
11
+ */
12
+ import { createProviderAndContext } from './transitionEngine';
13
+ import { createUseTheme } from './hooks/useTheme';
14
+ import { TAG } from './constants';
15
+ /**
16
+ * Creates a fully typed theme transition system.
17
+ *
18
+ * @typeParam T - Your application's theme map, keyed by theme name.
19
+ * @param config - Theme configuration including available themes and defaults.
20
+ * @returns A provider component and hooks scoped to the supplied themes.
21
+ *
22
+ * @example
23
+ * ```tsx
24
+ * const { ThemeTransitionProvider, useTheme } = createThemeTransition({
25
+ * themes: { light: { bg: '#fff' }, dark: { bg: '#000' } },
26
+ * });
27
+ * ```
28
+ */
29
+ export function createThemeTransition(config) {
30
+ const themeNames = Object.keys(config.themes);
31
+ if (themeNames.length === 0) {
32
+ throw new Error(`${TAG} \`themes\` must contain at least one theme.`);
33
+ }
34
+ if ('system' in config.themes) {
35
+ throw new Error(`${TAG} \`"system"\` is a reserved name and cannot be used as a theme key. Rename the theme and use \`systemThemeMap\` to map OS appearance to it.`);
36
+ }
37
+ const referenceTheme = themeNames[0];
38
+ const referenceKeys = Object.keys(config.themes[referenceTheme]).sort();
39
+ for (const name of themeNames) {
40
+ if (name === referenceTheme)
41
+ continue;
42
+ const keys = Object.keys(config.themes[name]).sort();
43
+ if (keys.length !== referenceKeys.length || keys.some((k, i) => k !== referenceKeys[i])) {
44
+ throw new Error(`${TAG} Theme "${name}" has different token keys than "${referenceTheme}". All themes must share identical keys.`);
45
+ }
46
+ }
47
+ if (config.duration != null && (typeof config.duration !== 'number' || !isFinite(config.duration) || config.duration < 0)) {
48
+ throw new Error(`${TAG} \`duration\` must be a finite non-negative number.`);
49
+ }
50
+ if (config.systemThemeMap) {
51
+ if (!('light' in config.systemThemeMap) || !('dark' in config.systemThemeMap)) {
52
+ throw new Error(`${TAG} \`systemThemeMap\` must provide both \`light\` and \`dark\` keys.`);
53
+ }
54
+ for (const [scheme, name] of Object.entries(config.systemThemeMap)) {
55
+ if (!(name in config.themes)) {
56
+ throw new Error(`${TAG} \`systemThemeMap.${scheme}\` maps to "${name}" which does not exist in themes.`);
57
+ }
58
+ }
59
+ }
60
+ const { Context, ThemeTransitionProvider } = createProviderAndContext(config);
61
+ return {
62
+ ThemeTransitionProvider,
63
+ useTheme: createUseTheme(Context),
64
+ };
65
+ }
66
+ //# sourceMappingURL=createThemeTransition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createThemeTransition.js","sourceRoot":"","sources":["../src/createThemeTransition.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAQH,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAElC;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,qBAAqB,CAEnC,MAAgC;IAChC,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAoB,CAAC;IAEjE,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC5B,MAAM,IAAI,KAAK,CAAC,GAAG,GAAG,8CAA8C,CAAC,CAAC;IACxE,CAAC;IAED,IAAI,QAAQ,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;QAC9B,MAAM,IAAI,KAAK,CACb,GAAG,GAAG,6IAA6I,CACpJ,CAAC;IACJ,CAAC;IAED,MAAM,cAAc,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;IACrC,MAAM,aAAa,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IACxE,KAAK,MAAM,IAAI,IAAI,UAAU,EAAE,CAAC;QAC9B,IAAI,IAAI,KAAK,cAAc;YAAE,SAAS;QACtC,MAAM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,EAAE,OAAO,EAAE,uBAAuB,EAAE,GAAG,wBAAwB,CAAC,MAAM,CAAC,CAAC;IAE9E,OAAO;QACL,uBAAuB;QACvB,QAAQ,EAAE,cAAc,CAAI,OAAO,CAAC;KACrC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type { Context } from 'react';
2
+ import type { UseThemeResult, ThemeSelectionResult, ThemeDefinition, ThemeNames, TokenNames } from '../types';
3
+ /**
4
+ * Factory that produces the `useTheme` hook bound to a specific context.
5
+ *
6
+ * @internal Used by {@link createThemeTransition}; not part of the public API.
7
+ */
8
+ export declare function createUseTheme<T extends Record<string, ThemeDefinition>>(Ctx: Context<UseThemeResult<TokenNames<T>, ThemeNames<T>> | null>): {
9
+ (): UseThemeResult<TokenNames<T>, ThemeNames<T>>;
10
+ (options: {
11
+ initialSelection?: ThemeNames<T> | "system";
12
+ }): UseThemeResult<TokenNames<T>, ThemeNames<T>> & ThemeSelectionResult<ThemeNames<T>>;
13
+ };
14
+ //# sourceMappingURL=useTheme.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useTheme.d.ts","sourceRoot":"","sources":["../../src/hooks/useTheme.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AACrC,OAAO,KAAK,EACV,cAAc,EACd,oBAAoB,EACpB,eAAe,EACf,UAAU,EACV,UAAU,EACX,MAAM,UAAU,CAAC;AAGlB;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,EACtE,GAAG,EAAE,OAAO,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;;cAQtC;QAAE,gBAAgB,CAAC,EAAE,gBAAQ,QAAQ,CAAA;KAAE;EA8DnE"}
@@ -0,0 +1,56 @@
1
+ import { useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';
2
+ import { TAG } from '../constants';
3
+ /**
4
+ * Factory that produces the `useTheme` hook bound to a specific context.
5
+ *
6
+ * @internal Used by {@link createThemeTransition}; not part of the public API.
7
+ */
8
+ export function createUseTheme(Ctx) {
9
+ function useTheme(options) {
10
+ const ctx = useContext(Ctx);
11
+ if (!ctx) {
12
+ throw new Error(`${TAG} \`useTheme\` must be used inside a \`ThemeTransitionProvider\`.`);
13
+ }
14
+ const { setTheme, isTransitioning } = ctx;
15
+ // Selection state — hooks are always called to satisfy React's rules of hooks.
16
+ // Only exposed in the return value when options are provided.
17
+ const [selected, setSelected] = useState(() => options?.initialSelection ?? ctx.name);
18
+ const pressLockRef = useRef(false);
19
+ // Ref tracks latest `selected` so the callback can read it without
20
+ // `selected` being a dependency — avoids recreating `select` on every change.
21
+ const selectedRef = useRef(selected);
22
+ selectedRef.current = selected;
23
+ useEffect(() => {
24
+ if (!isTransitioning)
25
+ pressLockRef.current = false;
26
+ }, [isTransitioning]);
27
+ const select = useCallback((option) => {
28
+ if (pressLockRef.current)
29
+ return;
30
+ pressLockRef.current = true;
31
+ const previousSelected = selectedRef.current;
32
+ // Paint the new highlight FIRST. Deferring setTheme to the next frame
33
+ // guarantees React commits + native paint before the library captures.
34
+ setSelected(option);
35
+ requestAnimationFrame(() => {
36
+ if (!setTheme(option)) {
37
+ // Rejected (same theme or already transitioning) — restore the prior selection.
38
+ setSelected(previousSelected);
39
+ }
40
+ // Always release: the blocker view (isBlocking) handles touch
41
+ // prevention during transitions at the native level.
42
+ pressLockRef.current = false;
43
+ });
44
+ }, [setTheme]);
45
+ // Memoize the extended result so consumers using selection tracking
46
+ // don't get a new object reference on every render (which would defeat
47
+ // the context-level useMemo in the provider).
48
+ const selectionResult = useMemo(() => ({ ...ctx, selected, select }), [ctx, selected, select]);
49
+ if (options != null) {
50
+ return selectionResult;
51
+ }
52
+ return ctx;
53
+ }
54
+ return useTheme;
55
+ }
56
+ //# sourceMappingURL=useTheme.js.map
@@ -0,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,CAAC,OAAO,CAAC;YAC7C,sEAAsE;YACtE,uEAAuE;YACvE,WAAW,CAAC,MAAM,CAAC,CAAC;YACpB,qBAAqB,CAAC,GAAG,EAAE;gBACzB,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;oBACtB,gFAAgF;oBAChF,WAAW,CAAC,gBAAgB,CAAC,CAAC;gBAChC,CAAC;gBACD,8DAA8D;gBAC9D,qDAAqD;gBACrD,YAAY,CAAC,OAAO,GAAG,KAAK,CAAC;YAC/B,CAAC,CAAC,CAAC;QACL,CAAC,EACD,CAAC,QAAQ,CAAC,CACX,CAAC;QAEF,oEAAoE;QACpE,uEAAuE;QACvE,8CAA8C;QAC9C,MAAM,eAAe,GAAG,OAAO,CAC7B,GAAG,EAAE,CAAC,CAAC,EAAE,GAAG,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,EACpC,CAAC,GAAG,EAAE,QAAQ,EAAE,MAAM,CAAC,CACxB,CAAC;QAEF,IAAI,OAAO,IAAI,IAAI,EAAE,CAAC;YACpB,OAAO,eAAe,CAAC;QACzB,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Public entry point for react-native-theme-transition.
3
+ *
4
+ * @remarks
5
+ * The transition mechanism works in five steps:
6
+ * 1. Blocks touch input via a Reanimated shared value (instant, no React re-render).
7
+ * 2. Captures the current native view via `react-native-view-shot`.
8
+ * 3. Overlays the snapshot as an absolute-positioned `Image` (`onLoad` confirms decode).
9
+ * 4. Mutates context to inject new theme colors underneath.
10
+ * 5. Fades the overlay to zero via `react-native-reanimated` — the native repaint
11
+ * completes during the first frames while the overlay is still near-opaque.
12
+ *
13
+ * @see {@link createThemeTransition} for the main API surface.
14
+ * @packageDocumentation
15
+ */
16
+ export { createThemeTransition } from './createThemeTransition';
17
+ export type { ThemeTransitionConfig, ThemeTransitionAPI, UseThemeResult, ThemeSelectionResult, SystemThemeMap, SetThemeOptions, ThemeDefinition, ThemeNames, TokenNames, } from './types';
18
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,YAAY,EACV,qBAAqB,EACrB,kBAAkB,EAClB,cAAc,EACd,oBAAoB,EACpB,cAAc,EACd,eAAe,EACf,eAAe,EACf,UAAU,EACV,UAAU,GACX,MAAM,SAAS,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Public entry point for react-native-theme-transition.
3
+ *
4
+ * @remarks
5
+ * The transition mechanism works in five steps:
6
+ * 1. Blocks touch input via a Reanimated shared value (instant, no React re-render).
7
+ * 2. Captures the current native view via `react-native-view-shot`.
8
+ * 3. Overlays the snapshot as an absolute-positioned `Image` (`onLoad` confirms decode).
9
+ * 4. Mutates context to inject new theme colors underneath.
10
+ * 5. Fades the overlay to zero via `react-native-reanimated` — the native repaint
11
+ * completes during the first frames while the overlay is still near-opaque.
12
+ *
13
+ * @see {@link createThemeTransition} for the main API surface.
14
+ * @packageDocumentation
15
+ */
16
+ export { createThemeTransition } from './createThemeTransition';
17
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Screenshot-overlay transition engine and provider.
3
+ *
4
+ * @module
5
+ */
6
+ import type { ThemeTransitionConfig, UseThemeResult, ThemeDefinition, ThemeNames, TokenNames } from './types';
7
+ /**
8
+ * Creates the React Context and provider component for a given theme configuration.
9
+ *
10
+ * @internal Used by {@link createThemeTransition}; not part of the public API.
11
+ */
12
+ export declare function createProviderAndContext<T extends Record<string, ThemeDefinition>>(config: ThemeTransitionConfig<T>): {
13
+ Context: import("react").Context<UseThemeResult<TokenNames<T>, ThemeNames<T>> | null>;
14
+ ThemeTransitionProvider: ({ children, initialTheme, }: {
15
+ children: React.ReactNode;
16
+ initialTheme: ThemeNames<T> | "system";
17
+ }) => import("react/jsx-runtime").JSX.Element;
18
+ };
19
+ //# sourceMappingURL=transitionEngine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transitionEngine.d.ts","sourceRoot":"","sources":["../src/transitionEngine.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAWH,OAAO,KAAK,EACV,qBAAqB,EACrB,cAAc,EAGd,eAAe,EACf,UAAU,EACV,UAAU,EACX,MAAM,SAAS,CAAC;AAqFjB;;;;GAIG;AACH,wBAAgB,wBAAwB,CACtC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,EACzC,MAAM,EAAE,qBAAqB,CAAC,CAAC,CAAC;;2DA0B7B;QACD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;QAC1B,YAAY,EAAE,gBAAQ,QAAQ,CAAC;KAChC;EA4SF"}