@kbach/react-native 1.0.0-beta.20 → 1.0.0-beta.22

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.
@@ -2,8 +2,8 @@ import {
2
2
  Fragment,
3
3
  jsx,
4
4
  jsxs
5
- } from "./chunk-MJWWZJMH.mjs";
6
- import "./chunk-OGFB3OXS.mjs";
5
+ } from "./chunk-OS7EPBH5.mjs";
6
+ import "./chunk-AG7ZQ2K4.mjs";
7
7
  export {
8
8
  Fragment,
9
9
  jsx,
@@ -80,18 +80,49 @@ interface ThemeState {
80
80
  */
81
81
  declare function useTheme(): ThemeState;
82
82
 
83
+ /**
84
+ * The exact shape `@react-native-async-storage/async-storage`'s default
85
+ * export already has — pass it directly as `persist`. Any other async
86
+ * key-value store (MMKV, SecureStore, a custom backend, ...) works too, as
87
+ * long as it exposes these two methods with this signature. Kept minimal
88
+ * on purpose: `ThemeProvider` never imports a storage library itself (see
89
+ * `darkModeStore.ts`'s own doc comment on why this package forces no real
90
+ * native dependency on consumers who don't want persistence) — deliberately
91
+ * NOT a `boolean`-only option that reaches for AsyncStorage internally,
92
+ * since Metro resolves every `require()`/`import` target at BUNDLE time
93
+ * regardless of try/catch, so a library-internal "if installed, use it"
94
+ * check can't actually degrade gracefully when the package is absent — an
95
+ * injected adapter sidesteps that entirely.
96
+ */
97
+ interface ThemeStorageAdapter {
98
+ getItem(key: string): Promise<string | null>;
99
+ setItem(key: string, value: string): Promise<void>;
100
+ }
83
101
  interface ThemeProviderProps {
84
102
  children: ReactNode;
85
103
  /**
86
104
  * Applied once, on this provider's first mount, but ONLY if nothing has
87
105
  * made an explicit mode choice yet (see
88
106
  * `darkModeStore.ts::seedDefaultMode`) — an explicit prior choice always
89
- * wins over a component's own default. Unlike @kbach/react's web
90
- * version, there's no persisted value to check here — see
91
- * darkModeStore.ts's own doc comment on why this package doesn't persist
92
- * the mode across app launches.
107
+ * wins over a component's own default. If `persist` is also set and a
108
+ * persisted mode is found, the persisted mode wins over this fallback.
93
109
  */
94
110
  defaultMode?: ThemeMode;
111
+ /**
112
+ * Opt-in persistence across app launches — `false` by default (this
113
+ * package never persists on its own; see `darkModeStore.ts`'s doc
114
+ * comment). Pass a storage adapter to enable it:
115
+ * ```tsx
116
+ * import AsyncStorage from '@react-native-async-storage/async-storage';
117
+ * <ThemeProvider persist={AsyncStorage}>...
118
+ * ```
119
+ * The persisted value (if any) is read once on mount and applied via the
120
+ * same "don't clobber a real choice already in flight" guard
121
+ * `seedDefaultMode`/`defaultMode` uses; every later explicit mode change
122
+ * is written back automatically for as long as this provider stays
123
+ * mounted.
124
+ */
125
+ persist?: ThemeStorageAdapter | false;
95
126
  }
96
127
  /**
97
128
  * Optional — `useTheme()` reads `darkModeStore.ts`'s global store directly
@@ -107,7 +138,7 @@ interface ThemeProviderProps {
107
138
  * state — mounting more than one is very likely a mistake, so this warns
108
139
  * once in dev.
109
140
  */
110
- declare function ThemeProvider({ children, defaultMode }: ThemeProviderProps): react.JSX.Element;
141
+ declare function ThemeProvider({ children, defaultMode, persist }: ThemeProviderProps): react.JSX.Element;
111
142
 
112
143
  interface ColorScale {
113
144
  /** `colors.blue[6]` -> raw value */
@@ -157,4 +188,4 @@ declare function useColors(): ColorsAPI;
157
188
  */
158
189
  declare function useDynamicToken(name: string): string | undefined;
159
190
 
160
- export { type ColorScale as C, type KbachConfig as K, ThemeProvider as T, type ColorsAPI as a, type ThemeProviderProps as b, type ThemeState as c, applyKbachConfig as d, useDynamicToken as e, useTheme as f, resolveKbachConfig as r, useColors as u };
191
+ export { type ColorScale as C, type KbachConfig as K, ThemeProvider as T, type ColorsAPI as a, type ThemeProviderProps as b, type ThemeState as c, type ThemeStorageAdapter as d, applyKbachConfig as e, useDynamicToken as f, useTheme as g, resolveKbachConfig as r, useColors as u };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kbach/react-native",
3
- "version": "1.0.0-beta.20",
3
+ "version": "1.0.0-beta.22",
4
4
  "description": "Kbach's utility-class styling engine for React Native — the same class names as @kbach/react, resolved to a StyleSheet-ready style object via a Kotlin/JNI TurboModule (native), the same WASM engine @kbach/react uses (Expo Web / react-native-web), or a pure-JS fallback engine (Expo Go). Ships its own native Android module — one npm install, no separate native package. Beta. Native is Android-only (no iOS bridge yet); works with the React Native CLI, an Expo dev client, AND Expo Go (a reduced-coverage pure-JS fallback, since Expo Go can't load any custom native module).",
5
5
  "keywords": [
6
6
  "css",