@kbach/react-native 1.0.0-beta.8 → 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/AGENTS.md +495 -0
- package/LICENSE +21 -0
- package/README.md +209 -249
- package/THIRD_PARTY_NOTICES.md +41 -0
- 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-7CNURQSH.mjs +112 -0
- package/dist/{chunk-OIW7OQWO.mjs → chunk-HYQFT32E.mjs} +2 -2
- package/dist/chunk-MUPEQJRT.mjs +623 -0
- package/dist/darkModeStore.d.ts +73 -0
- package/dist/darkModeStore.js +118 -0
- package/dist/dynamicTokens.d.ts +53 -0
- package/dist/dynamicTokens.js +75 -0
- package/dist/index.d.ts +90 -71
- package/dist/index.js +1433 -606
- package/dist/index.web.d.ts +91 -1
- package/dist/index.web.js +323 -428
- package/dist/index.web.mjs +297 -11
- package/dist/jsx-dev-runtime.d.ts +2 -2
- package/dist/jsx-dev-runtime.js +1540 -589
- package/dist/jsx-dev-runtime.web.d.ts +2 -2
- package/dist/jsx-dev-runtime.web.js +20 -340
- package/dist/jsx-dev-runtime.web.mjs +18 -6
- package/dist/jsx-runtime.d.ts +3 -3
- package/dist/jsx-runtime.js +1530 -579
- package/dist/jsx-runtime.web.d.ts +3 -3
- package/dist/jsx-runtime.web.js +17 -340
- package/dist/jsx-runtime.web.mjs +2 -3
- package/dist/semanticElements-Bk3TB-vt.d.ts +334 -0
- package/dist/theme.d.ts +79 -0
- package/dist/{chunk-4BXM3QUV.mjs → theme.js} +120 -17
- package/llms.txt +38 -0
- package/package.json +15 -13
- package/src/babel-plugin.js +144 -2
- package/dist/ThemeContext-Dc5AC-m0.d.mts +0 -98
- package/dist/ThemeContext-Dc5AC-m0.d.ts +0 -98
- package/dist/chunk-CGU7UM2F.mjs +0 -66
- package/dist/chunk-DLIXI5OW.mjs +0 -53
- package/dist/chunk-JR3BLUAV.mjs +0 -1204
- package/dist/chunk-JS5KIGAB.mjs +0 -192
- package/dist/chunk-KV3ZIXSH.mjs +0 -14
- package/dist/chunk-Z664AKW7.mjs +0 -54
- package/dist/index.d.mts +0 -84
- package/dist/index.mjs +0 -34
- package/dist/index.web.d.mts +0 -15
- package/dist/jsx-dev-runtime.d.mts +0 -10
- package/dist/jsx-dev-runtime.mjs +0 -18
- package/dist/jsx-dev-runtime.web.d.mts +0 -10
- package/dist/jsx-runtime.d.mts +0 -7
- package/dist/jsx-runtime.mjs +0 -15
- package/dist/jsx-runtime.web.d.mts +0 -7
package/dist/chunk-KV3ZIXSH.mjs
DELETED
package/dist/chunk-Z664AKW7.mjs
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
// src/darkModeStore.ts
|
|
2
|
-
import { Appearance } from "react-native";
|
|
3
|
-
var listeners = /* @__PURE__ */ new Set();
|
|
4
|
-
function systemPrefersDark() {
|
|
5
|
-
return Appearance.getColorScheme() === "dark";
|
|
6
|
-
}
|
|
7
|
-
function resolveIsDark(m) {
|
|
8
|
-
return m === "system" ? systemPrefersDark() : m === "dark";
|
|
9
|
-
}
|
|
10
|
-
var mode = "system";
|
|
11
|
-
var isDark = resolveIsDark(mode);
|
|
12
|
-
var hasExplicitChoice = false;
|
|
13
|
-
var subscription = Appearance.addChangeListener(({ colorScheme }) => {
|
|
14
|
-
if (mode !== "system") return;
|
|
15
|
-
isDark = colorScheme === "dark";
|
|
16
|
-
notify();
|
|
17
|
-
});
|
|
18
|
-
function notify() {
|
|
19
|
-
for (const listener of listeners) listener();
|
|
20
|
-
}
|
|
21
|
-
function getGlobalDarkMode() {
|
|
22
|
-
return isDark;
|
|
23
|
-
}
|
|
24
|
-
function getGlobalThemeMode() {
|
|
25
|
-
return mode;
|
|
26
|
-
}
|
|
27
|
-
function setGlobalThemeMode(nextMode) {
|
|
28
|
-
mode = nextMode;
|
|
29
|
-
isDark = resolveIsDark(nextMode);
|
|
30
|
-
hasExplicitChoice = true;
|
|
31
|
-
notify();
|
|
32
|
-
}
|
|
33
|
-
function toggleGlobalDarkMode() {
|
|
34
|
-
setGlobalThemeMode(isDark ? "light" : "dark");
|
|
35
|
-
}
|
|
36
|
-
function subscribeGlobalDarkMode(listener) {
|
|
37
|
-
listeners.add(listener);
|
|
38
|
-
return () => listeners.delete(listener);
|
|
39
|
-
}
|
|
40
|
-
function seedDefaultMode(fallback) {
|
|
41
|
-
if (hasExplicitChoice || mode === fallback) return;
|
|
42
|
-
mode = fallback;
|
|
43
|
-
isDark = resolveIsDark(fallback);
|
|
44
|
-
notify();
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export {
|
|
48
|
-
getGlobalDarkMode,
|
|
49
|
-
getGlobalThemeMode,
|
|
50
|
-
setGlobalThemeMode,
|
|
51
|
-
toggleGlobalDarkMode,
|
|
52
|
-
subscribeGlobalDarkMode,
|
|
53
|
-
seedDefaultMode
|
|
54
|
-
};
|
package/dist/index.d.mts
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
export { T as ThemeConfig, a as ThemeContextValue, b as ThemeMode, c as ThemeProvider, d as ThemeProviderProps, e as defaultTheme, g as getGlobalDarkMode, f as getGlobalThemeMode, h as getTheme, s as setGlobalThemeMode, i as setTheme, j as subscribeGlobalDarkMode, t as toggleGlobalDarkMode, u as useGlobalDarkMode, k as useTheme } from './ThemeContext-Dc5AC-m0.mjs';
|
|
2
|
-
import 'react';
|
|
3
|
-
|
|
4
|
-
type StyleValue = string | number | {
|
|
5
|
-
width: number;
|
|
6
|
-
height: number;
|
|
7
|
-
};
|
|
8
|
-
interface StyleObject {
|
|
9
|
-
[key: string]: StyleValue;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Calls the Rust engine via the KbachModule TurboModule (see
|
|
13
|
-
* apps/native-sandbox/android/.../KbachModule.kt and
|
|
14
|
-
* packages/core-engine/src/resolve_style.rs) and returns a plain style
|
|
15
|
-
* object ready for RN's `style` prop. Synchronous — no async init step,
|
|
16
|
-
* unlike the web/WASM path, since JSI-backed TurboModule methods are
|
|
17
|
-
* available as soon as the module is loaded.
|
|
18
|
-
*
|
|
19
|
-
* Reads `getGlobalDarkMode()` (darkModeStore.ts) fresh on every call (no
|
|
20
|
-
* caching) so `dark:` resolves correctly whenever this runs. That store —
|
|
21
|
-
* not a direct `Appearance.getColorScheme()` read, which this function
|
|
22
|
-
* used prior to `<ThemeProvider>` support — is what makes an explicit
|
|
23
|
-
* `setGlobalThemeMode('dark')`/`toggle()` override actually affect
|
|
24
|
-
* rendering; the store itself falls back to tracking `Appearance` live
|
|
25
|
-
* whenever the mode is `'system'` (its own default), so nothing regresses
|
|
26
|
-
* for apps that never touch the override API at all. This function itself
|
|
27
|
-
* has no subscription of its own, so nothing re-renders just because the
|
|
28
|
-
* store's value changed — call `useGlobalDarkMode()` (or consume
|
|
29
|
-
* `useTheme()`'s `isDark`) somewhere in the tree for that, NOT React
|
|
30
|
-
* Native's own `useColorScheme()`, which only reflects the raw OS setting
|
|
31
|
-
* and would miss an explicit override entirely.
|
|
32
|
-
*
|
|
33
|
-
* Phase 11 originally shipped with live in-place theme switching unverified
|
|
34
|
-
* (a `uiMode` toggle triggered a re-render but `Appearance.getColorScheme()`
|
|
35
|
-
* kept returning a stale value). Root-caused in Phase 12 while debugging an
|
|
36
|
-
* unrelated `active:` failure: `apps/native-sandbox` has its own separate
|
|
37
|
-
* `node_modules/react-native` (excluded from the npm workspace since Phase
|
|
38
|
-
* 5), while `packages/react-native` resolved `react-native` hierarchically
|
|
39
|
-
* up to a *different* copy at the repo root — two physical module
|
|
40
|
-
* instances, so a `useColorScheme()` subscription and an
|
|
41
|
-
* `Appearance.getColorScheme()` read were silently talking to two separate
|
|
42
|
-
* copies of the Appearance module. Fixed by forcing a single instance via
|
|
43
|
-
* `resolver.resolveRequest` in apps/native-sandbox/metro.config.js; live
|
|
44
|
-
* theme switching (and `active:`, the bug that surfaced this) both verified
|
|
45
|
-
* working after the fix — see Phase 12. Still relevant here: darkModeStore.ts
|
|
46
|
-
* itself calls `Appearance.addChangeListener`, so the same dual-instance
|
|
47
|
-
* failure mode would silently break the 'system' fallback path too if that
|
|
48
|
-
* metro.config.js fix ever regressed.
|
|
49
|
-
*
|
|
50
|
-
* `pressed` gates the `active:` modifier — unlike `colorScheme`, there's no
|
|
51
|
-
* system-level getter for "is this element currently pressed"; only RN's
|
|
52
|
-
* `Pressable` ever knows this, so it's passed in directly by the caller
|
|
53
|
-
* (jsx-runtime, from Pressable's own style-function callback) rather than
|
|
54
|
-
* queried here. Defaults to `false` for every other element type.
|
|
55
|
-
*
|
|
56
|
-
* `width` gates `sm:`/`md:`/`lg:`/`xl:`/`2xl:` against the active theme's
|
|
57
|
-
* `screens` scale (resolve_style.rs's `native_modifier_state`) — read fresh
|
|
58
|
-
* from `Dimensions.get('window').width` on every call, the same "no
|
|
59
|
-
* caching, no store" choice `colorScheme`/`pressed` already make, and for
|
|
60
|
-
* the same reason: unlike dark mode there's no explicit-override concept to
|
|
61
|
-
* preserve here (nobody manually overrides their screen width), so a plain
|
|
62
|
-
* synchronous read is enough — no need for the subscribable store
|
|
63
|
-
* darkModeStore.ts is for. As with `colorScheme`, this function has no
|
|
64
|
-
* subscription of its own, so rotating/resizing the window doesn't
|
|
65
|
-
* re-render anything by itself — call RN's own `useWindowDimensions()`
|
|
66
|
-
* somewhere in the tree for that (same role `useColorScheme()` plays for
|
|
67
|
-
* `dark:` in apps/native-sandbox/App.tsx).
|
|
68
|
-
*
|
|
69
|
-
* Falls back to `./jsEngine` (a pure-JS, no-WASM/no-native reimplementation
|
|
70
|
-
* of this same resolution logic — see that directory's own doc comments)
|
|
71
|
-
* when `KbachModule` isn't registered at all — Expo Go, which can never
|
|
72
|
-
* load ANY custom native module (not even Expo's own Modules API), so the
|
|
73
|
-
* TurboModule this file otherwise depends on simply doesn't exist there.
|
|
74
|
-
* `TurboModuleRegistry.get` (not `.getEnforcing`, which throws) is what
|
|
75
|
-
* makes this detectable at all — `get` returns `null`/`undefined` instead.
|
|
76
|
-
* A real dev-client/CLI build always has the module registered, so this
|
|
77
|
-
* fallback only ever activates in Expo Go itself; everywhere else behaves
|
|
78
|
-
* exactly as before. The JS engine covers a strict subset of what the
|
|
79
|
-
* native/WASM engines resolve (see jsEngine/resolveUtilityNative.ts) — an
|
|
80
|
-
* intentional, documented parity gap, not a bug.
|
|
81
|
-
*/
|
|
82
|
-
declare function resolveStyle(classString: string, pressed?: boolean): StyleObject;
|
|
83
|
-
|
|
84
|
-
export { type StyleObject, resolveStyle };
|
package/dist/index.mjs
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ThemeProvider,
|
|
3
|
-
useGlobalDarkMode,
|
|
4
|
-
useTheme
|
|
5
|
-
} from "./chunk-CGU7UM2F.mjs";
|
|
6
|
-
import {
|
|
7
|
-
resolveStyle
|
|
8
|
-
} from "./chunk-JR3BLUAV.mjs";
|
|
9
|
-
import {
|
|
10
|
-
getGlobalDarkMode,
|
|
11
|
-
getGlobalThemeMode,
|
|
12
|
-
setGlobalThemeMode,
|
|
13
|
-
subscribeGlobalDarkMode,
|
|
14
|
-
toggleGlobalDarkMode
|
|
15
|
-
} from "./chunk-Z664AKW7.mjs";
|
|
16
|
-
import {
|
|
17
|
-
defaultTheme,
|
|
18
|
-
getTheme,
|
|
19
|
-
setTheme
|
|
20
|
-
} from "./chunk-4BXM3QUV.mjs";
|
|
21
|
-
export {
|
|
22
|
-
ThemeProvider,
|
|
23
|
-
defaultTheme,
|
|
24
|
-
getGlobalDarkMode,
|
|
25
|
-
getGlobalThemeMode,
|
|
26
|
-
getTheme,
|
|
27
|
-
resolveStyle,
|
|
28
|
-
setGlobalThemeMode,
|
|
29
|
-
setTheme,
|
|
30
|
-
subscribeGlobalDarkMode,
|
|
31
|
-
toggleGlobalDarkMode,
|
|
32
|
-
useGlobalDarkMode,
|
|
33
|
-
useTheme
|
|
34
|
-
};
|
package/dist/index.web.d.mts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export { T as ThemeConfig, a as ThemeContextValue, b as ThemeMode, c as ThemeProvider, d as ThemeProviderProps, e as defaultTheme, g as getGlobalDarkMode, f as getGlobalThemeMode, h as getTheme, s as setGlobalThemeMode, i as setTheme, j as subscribeGlobalDarkMode, t as toggleGlobalDarkMode, u as useGlobalDarkMode, k as useTheme } from './ThemeContext-Dc5AC-m0.mjs';
|
|
2
|
-
import 'react';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Resolves `classString` to CSS via the WASM engine, injects every returned
|
|
6
|
-
* rule into a shared `<style data-kbach-rn>` tag (cascade-order-safe — see
|
|
7
|
-
* cssInjector.web.ts), and returns the class string to use as
|
|
8
|
-
* `dataSet={{ kb: <returned value> }}`. MUST use the returned value, not the
|
|
9
|
-
* original input — mode-aware color names (e.g. `bg-surface`) expand into a
|
|
10
|
-
* literal light/dark pair, and the generated rules target that expanded
|
|
11
|
-
* text, not the original.
|
|
12
|
-
*/
|
|
13
|
-
declare function resolveClassName(classString: string): string;
|
|
14
|
-
|
|
15
|
-
export { resolveClassName };
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import * as react from 'react';
|
|
2
|
-
export { Fragment } from 'react';
|
|
3
|
-
|
|
4
|
-
declare const jsxDEV: (type: unknown, props: Record<string, unknown> | null, key?: string, isStaticChildren?: boolean, source?: {
|
|
5
|
-
fileName: string;
|
|
6
|
-
lineNumber: number;
|
|
7
|
-
columnNumber: number;
|
|
8
|
-
}, self?: unknown) => react.ReactElement;
|
|
9
|
-
|
|
10
|
-
export { jsxDEV };
|
package/dist/jsx-dev-runtime.mjs
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
jsx,
|
|
3
|
-
jsxs
|
|
4
|
-
} from "./chunk-KV3ZIXSH.mjs";
|
|
5
|
-
import "./chunk-JR3BLUAV.mjs";
|
|
6
|
-
import "./chunk-Z664AKW7.mjs";
|
|
7
|
-
import {
|
|
8
|
-
Fragment,
|
|
9
|
-
createJsxDEV
|
|
10
|
-
} from "./chunk-DLIXI5OW.mjs";
|
|
11
|
-
import "./chunk-4BXM3QUV.mjs";
|
|
12
|
-
|
|
13
|
-
// src/jsx-dev-runtime.tsx
|
|
14
|
-
var jsxDEV = createJsxDEV(jsx, jsxs);
|
|
15
|
-
export {
|
|
16
|
-
Fragment,
|
|
17
|
-
jsxDEV
|
|
18
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import * as react from 'react';
|
|
2
|
-
export { Fragment } from 'react';
|
|
3
|
-
|
|
4
|
-
declare const jsxDEV: (type: unknown, props: Record<string, unknown> | null, key?: string, isStaticChildren?: boolean, source?: {
|
|
5
|
-
fileName: string;
|
|
6
|
-
lineNumber: number;
|
|
7
|
-
columnNumber: number;
|
|
8
|
-
}, self?: unknown) => react.ReactElement;
|
|
9
|
-
|
|
10
|
-
export { jsxDEV };
|
package/dist/jsx-runtime.d.mts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import * as react from 'react';
|
|
2
|
-
export { Fragment, JSX } from 'react';
|
|
3
|
-
|
|
4
|
-
declare const jsx: (type: unknown, props: Record<string, unknown> | null, key?: string) => react.ReactElement;
|
|
5
|
-
declare const jsxs: (type: unknown, props: Record<string, unknown> | null, key?: string) => react.ReactElement;
|
|
6
|
-
|
|
7
|
-
export { jsx, jsxs };
|
package/dist/jsx-runtime.mjs
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
jsx,
|
|
3
|
-
jsxs
|
|
4
|
-
} from "./chunk-KV3ZIXSH.mjs";
|
|
5
|
-
import "./chunk-JR3BLUAV.mjs";
|
|
6
|
-
import "./chunk-Z664AKW7.mjs";
|
|
7
|
-
import {
|
|
8
|
-
Fragment
|
|
9
|
-
} from "./chunk-DLIXI5OW.mjs";
|
|
10
|
-
import "./chunk-4BXM3QUV.mjs";
|
|
11
|
-
export {
|
|
12
|
-
Fragment,
|
|
13
|
-
jsx,
|
|
14
|
-
jsxs
|
|
15
|
-
};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import * as react from 'react';
|
|
2
|
-
export { Fragment, JSX } from 'react';
|
|
3
|
-
|
|
4
|
-
declare const jsx: (type: unknown, props: Record<string, unknown> | null, key?: string) => react.ReactElement;
|
|
5
|
-
declare const jsxs: (type: unknown, props: Record<string, unknown> | null, key?: string) => react.ReactElement;
|
|
6
|
-
|
|
7
|
-
export { jsx, jsxs };
|