@kbach/react-native 1.0.0-beta.7 → 1.0.0-beta.9
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 +70 -169
- 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-OJQAJLYT.mjs → chunk-DOWW44F7.mjs} +1 -1
- package/dist/chunk-H5Z24XX5.mjs +192 -0
- package/dist/{chunk-AEVOM2NB.mjs → chunk-HK6PDJJK.mjs} +54 -58
- package/dist/chunk-SY5OAY2C.mjs +1211 -0
- package/dist/chunk-X4UQCEOE.mjs +186 -0
- package/dist/chunk-YOC3SHF5.mjs +40 -0
- package/dist/chunk-Z664AKW7.mjs +54 -0
- package/dist/index.d.mts +24 -102
- package/dist/index.d.ts +24 -102
- package/dist/index.js +1387 -36
- package/dist/index.mjs +14 -8
- package/dist/index.web.d.mts +12 -4
- package/dist/index.web.d.ts +12 -4
- package/dist/index.web.js +266 -69
- package/dist/index.web.mjs +17 -11
- package/dist/jsx-dev-runtime.js +1246 -6
- package/dist/jsx-dev-runtime.mjs +4 -3
- package/dist/jsx-dev-runtime.web.js +124 -72
- package/dist/jsx-dev-runtime.web.mjs +4 -4
- package/dist/jsx-runtime.js +1246 -6
- package/dist/jsx-runtime.mjs +4 -3
- package/dist/jsx-runtime.web.js +109 -62
- package/dist/jsx-runtime.web.mjs +4 -6
- package/dist/useColors-CeP5_HvM.d.mts +230 -0
- package/dist/useColors-CeP5_HvM.d.ts +230 -0
- package/package.json +22 -4
- package/src/babel-plugin.js +74 -2
- package/dist/chunk-4KCCEMEN.mjs +0 -66
- package/dist/chunk-5WK55Z56.mjs +0 -14
- package/dist/chunk-FG5E4NLJ.mjs +0 -18
- package/dist/chunk-T3HPTH62.mjs +0 -161
package/dist/chunk-4KCCEMEN.mjs
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getGlobalDarkMode,
|
|
3
|
-
getGlobalThemeMode,
|
|
4
|
-
seedDefaultMode,
|
|
5
|
-
setGlobalThemeMode,
|
|
6
|
-
subscribeGlobalDarkMode,
|
|
7
|
-
toggleGlobalDarkMode
|
|
8
|
-
} from "./chunk-AEVOM2NB.mjs";
|
|
9
|
-
|
|
10
|
-
// src/useGlobalDarkMode.ts
|
|
11
|
-
import { useSyncExternalStore } from "react";
|
|
12
|
-
function useGlobalDarkMode() {
|
|
13
|
-
return useSyncExternalStore(subscribeGlobalDarkMode, getGlobalDarkMode);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
// src/ThemeContext.tsx
|
|
17
|
-
import { createContext, useContext } from "react";
|
|
18
|
-
var ThemeContext = createContext(null);
|
|
19
|
-
function useTheme() {
|
|
20
|
-
const ctx = useContext(ThemeContext);
|
|
21
|
-
if (!ctx) {
|
|
22
|
-
throw new Error(
|
|
23
|
-
'useTheme() must be called within a <ThemeProvider>. For dark-mode state without a provider, use useGlobalDarkMode() (read) or toggleGlobalDarkMode()/setGlobalThemeMode() (write) from "@kbach/react-native" instead.'
|
|
24
|
-
);
|
|
25
|
-
}
|
|
26
|
-
return ctx;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// src/ThemeProvider.tsx
|
|
30
|
-
import { useEffect, useMemo, useRef, useSyncExternalStore as useSyncExternalStore2 } from "react";
|
|
31
|
-
import { jsx } from "react/jsx-runtime";
|
|
32
|
-
var mountedProviderCount = 0;
|
|
33
|
-
var warnedMultipleProviders = false;
|
|
34
|
-
function ThemeProvider({ children, defaultMode = "system" }) {
|
|
35
|
-
useEffect(() => {
|
|
36
|
-
mountedProviderCount++;
|
|
37
|
-
if (mountedProviderCount > 1 && !warnedMultipleProviders) {
|
|
38
|
-
warnedMultipleProviders = true;
|
|
39
|
-
console.warn(
|
|
40
|
-
"[kbach] Multiple <ThemeProvider> instances are mounted at once. Dark-mode state is one global store (the same one useGlobalDarkMode()/toggleGlobalDarkMode() read and write), not scoped per-provider, so they will fight over the same state instead of each getting their own."
|
|
41
|
-
);
|
|
42
|
-
}
|
|
43
|
-
return () => {
|
|
44
|
-
mountedProviderCount--;
|
|
45
|
-
};
|
|
46
|
-
}, []);
|
|
47
|
-
const seeded = useRef(false);
|
|
48
|
-
useEffect(() => {
|
|
49
|
-
if (seeded.current) return;
|
|
50
|
-
seeded.current = true;
|
|
51
|
-
seedDefaultMode(defaultMode);
|
|
52
|
-
}, []);
|
|
53
|
-
const isDark = useSyncExternalStore2(subscribeGlobalDarkMode, getGlobalDarkMode);
|
|
54
|
-
const mode = useSyncExternalStore2(subscribeGlobalDarkMode, getGlobalThemeMode);
|
|
55
|
-
const value = useMemo(
|
|
56
|
-
() => ({ mode, isDark, setMode: setGlobalThemeMode, toggle: toggleGlobalDarkMode }),
|
|
57
|
-
[mode, isDark]
|
|
58
|
-
);
|
|
59
|
-
return /* @__PURE__ */ jsx(ThemeContext.Provider, { value, children });
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export {
|
|
63
|
-
useGlobalDarkMode,
|
|
64
|
-
useTheme,
|
|
65
|
-
ThemeProvider
|
|
66
|
-
};
|
package/dist/chunk-5WK55Z56.mjs
DELETED
package/dist/chunk-FG5E4NLJ.mjs
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getGlobalDarkMode,
|
|
3
|
-
getThemeJson
|
|
4
|
-
} from "./chunk-AEVOM2NB.mjs";
|
|
5
|
-
|
|
6
|
-
// src/nativeBridge.ts
|
|
7
|
-
import { Dimensions, TurboModuleRegistry } from "react-native";
|
|
8
|
-
function resolveStyle(classString, pressed = false) {
|
|
9
|
-
const KbachModule = TurboModuleRegistry.getEnforcing("KbachModule");
|
|
10
|
-
const colorScheme = getGlobalDarkMode() ? "dark" : "light";
|
|
11
|
-
const width = Dimensions.get("window").width;
|
|
12
|
-
const json = KbachModule.resolveStyle(classString, getThemeJson(), colorScheme, pressed, width);
|
|
13
|
-
return JSON.parse(json);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export {
|
|
17
|
-
resolveStyle
|
|
18
|
-
};
|