@rootnative/core 0.0.0-alpha.20 → 0.0.0-alpha.21
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/dist/index.d.mts +4 -0
- package/dist/index.mjs +17 -12
- package/llms.txt +4 -2
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -175,6 +175,10 @@ interface ThemeProviderProps {
|
|
|
175
175
|
* `useThemeMode()`. Pass it to control the mode from your own state — the
|
|
176
176
|
* provider then never changes it on its own, so pair it with `onModeChange`.
|
|
177
177
|
*
|
|
178
|
+
* On a static web export, `'system'` renders light on the server and while
|
|
179
|
+
* the client hydrates, then switches to the OS scheme on the next render.
|
|
180
|
+
* The server cannot know the scheme, so the light theme is the first paint.
|
|
181
|
+
*
|
|
178
182
|
* @default 'system'
|
|
179
183
|
*/
|
|
180
184
|
mode?: ThemeMode;
|
package/dist/index.mjs
CHANGED
|
@@ -213,6 +213,20 @@ import { MotionConfig } from "@rootnative/inertia";
|
|
|
213
213
|
import * as React4 from "react";
|
|
214
214
|
import { useColorScheme } from "react-native";
|
|
215
215
|
|
|
216
|
+
// src/internal/useIsHydrating.ts
|
|
217
|
+
import { useSyncExternalStore } from "react";
|
|
218
|
+
var subscribeToNothing = () => () => {
|
|
219
|
+
};
|
|
220
|
+
var notHydrating = () => false;
|
|
221
|
+
var isHydratingOnServer = () => true;
|
|
222
|
+
function useIsHydrating() {
|
|
223
|
+
return useSyncExternalStore(
|
|
224
|
+
subscribeToNothing,
|
|
225
|
+
notHydrating,
|
|
226
|
+
isHydratingOnServer
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
|
|
216
230
|
// src/provider/IconResolverContext.ts
|
|
217
231
|
import * as React from "react";
|
|
218
232
|
var IconResolverContext = React.createContext(
|
|
@@ -246,7 +260,8 @@ function ThemeProvider({
|
|
|
246
260
|
children
|
|
247
261
|
}) {
|
|
248
262
|
const pair = theme && isThemePair(theme) ? theme : null;
|
|
249
|
-
const
|
|
263
|
+
const measuredScheme = useColorScheme();
|
|
264
|
+
const systemScheme = useIsHydrating() ? "light" : measuredScheme;
|
|
250
265
|
const [uncontrolledMode, setUncontrolledMode] = React4.useState(defaultMode);
|
|
251
266
|
const isControlled = controlledMode !== void 0;
|
|
252
267
|
const mode = isControlled ? controlledMode : uncontrolledMode;
|
|
@@ -342,12 +357,7 @@ function useIconResolver() {
|
|
|
342
357
|
}
|
|
343
358
|
|
|
344
359
|
// src/responsive/useWindowDimensions.ts
|
|
345
|
-
import { useSyncExternalStore } from "react";
|
|
346
360
|
import { useWindowDimensions as useMeasuredWindowDimensions } from "react-native";
|
|
347
|
-
var subscribeToNothing = () => () => {
|
|
348
|
-
};
|
|
349
|
-
var notHydrating = () => false;
|
|
350
|
-
var isHydratingOnServer = () => true;
|
|
351
361
|
var SERVER_WINDOW = Object.freeze({
|
|
352
362
|
width: 0,
|
|
353
363
|
height: 0,
|
|
@@ -356,12 +366,7 @@ var SERVER_WINDOW = Object.freeze({
|
|
|
356
366
|
});
|
|
357
367
|
function useWindowDimensions() {
|
|
358
368
|
const measured = useMeasuredWindowDimensions();
|
|
359
|
-
|
|
360
|
-
subscribeToNothing,
|
|
361
|
-
notHydrating,
|
|
362
|
-
isHydratingOnServer
|
|
363
|
-
);
|
|
364
|
-
return hydrating ? SERVER_WINDOW : measured;
|
|
369
|
+
return useIsHydrating() ? SERVER_WINDOW : measured;
|
|
365
370
|
}
|
|
366
371
|
|
|
367
372
|
// src/responsive/useBreakpoint.ts
|
package/llms.txt
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @rootnative/core — Theme System for React Native
|
|
2
2
|
|
|
3
|
-
> Version: 0.0.0-alpha.
|
|
3
|
+
> Version: 0.0.0-alpha.21
|
|
4
4
|
> Peer deps: react >=19.2.3 <20.0.0, react-native >=0.83.0 <0.87.0, @rootnative/inertia >=0.0.11 <0.1.0 (required — every animation runs on it)
|
|
5
5
|
> createMaterialTheme needs no extra install — its color engine (@material/material-color-utilities) is bundled behind the create-theme subpath
|
|
6
6
|
|
|
@@ -75,7 +75,7 @@ const custom: Theme = {
|
|
|
75
75
|
|
|
76
76
|
Props:
|
|
77
77
|
- `theme?: BaseTheme | { light: BaseTheme; dark: BaseTheme }` — A single theme, or a light/dark pair. A pair enables `useThemeMode()`. Default: `lightTheme` (MD3)
|
|
78
|
-
- `mode?: 'system' | 'light' | 'dark'` — Controlled mode. Leave unset and use `setMode()` instead. Pair with `onModeChange`
|
|
78
|
+
- `mode?: 'system' | 'light' | 'dark'` — Controlled mode. Leave unset and use `setMode()` instead. Pair with `onModeChange`. On a static web export, `'system'` renders light on the server and while the client hydrates, then follows the OS on the next render. No hydration gate is needed around it
|
|
79
79
|
- `defaultMode?: 'system' | 'light' | 'dark'` — Initial mode when uncontrolled. Default: `'system'`
|
|
80
80
|
- `onModeChange?: (mode: ThemeMode) => void`
|
|
81
81
|
- `storage?: { getItem, setItem }` — Persists the mode. Any AsyncStorage-shaped object; sync or async. Nothing is persisted unless you pass this
|
|
@@ -346,3 +346,5 @@ A static export (`web.output: 'static'`) renders on a server with no DOM, where
|
|
|
346
346
|
|
|
347
347
|
The practical consequence: a breakpoint-dependent layout **starts compact and widens a frame later** on a static export. That is unavoidable — the server cannot know the viewport — so design the compact variant to be the honest first paint. `Grid` inherits all of this, which matters because it resolves a `columns` map internally and leaves a consumer nowhere to put a gate of their own.
|
|
348
348
|
|
|
349
|
+
`ThemeProvider` reads the same hydration flag for `mode="system"`. The export server has no `matchMedia`, so react-native-web reports `'light'` there and the HTML ships the light theme. The provider keeps light while the client hydrates, then switches to the OS scheme on the same re-render as the window size. A reader with a dark system setting sees one light frame first. The `useColorScheme` hook from `react-native` is **not** hydration-safe: a theme chosen from it stays light in a dark browser.
|
|
350
|
+
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rootnative/core",
|
|
3
|
-
"version": "0.0.0-alpha.
|
|
3
|
+
"version": "0.0.0-alpha.21",
|
|
4
4
|
"description": "Design-system agnostic theme engine for RootNative UI — a React Native component library. Ships with Material Design 3 out of the box.",
|
|
5
5
|
"private": false,
|
|
6
6
|
"sideEffects": false,
|