@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.
- package/README.md +72 -13
- package/android/src/main/jniLibs/arm64-v8a/libkbach_core_engine.so +0 -0
- package/android/src/main/jniLibs/x86_64/libkbach_core_engine.so +0 -0
- package/dist/chunk-AG7ZQ2K4.mjs +552 -0
- package/dist/{chunk-MJWWZJMH.mjs → chunk-OS7EPBH5.mjs} +1 -1
- package/dist/{chunk-45GOGUHJ.mjs → chunk-TS2EEVOE.mjs} +1 -1
- package/dist/dynamicTokens.d.ts +5 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.js +177 -9
- package/dist/index.web.d.ts +1 -1
- package/dist/index.web.js +28 -3
- package/dist/index.web.mjs +29 -4
- package/dist/jsx-dev-runtime.js +370 -156
- package/dist/jsx-dev-runtime.web.js +3 -4
- package/dist/jsx-dev-runtime.web.mjs +3 -3
- package/dist/jsx-runtime.js +360 -146
- package/dist/jsx-runtime.web.js +1 -1
- package/dist/jsx-runtime.web.mjs +2 -2
- package/dist/{useDynamicToken-Dr15c88t.d.ts → useDynamicToken-DAHQob1u.d.ts} +37 -6
- package/package.json +1 -1
- package/dist/chunk-OGFB3OXS.mjs +0 -552
package/dist/jsx-runtime.web.mjs
CHANGED
|
@@ -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.
|
|
90
|
-
*
|
|
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,
|
|
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.
|
|
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",
|