@rootnative/core 0.0.0-alpha.14 → 0.0.0-alpha.16
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 +1 -1
- package/dist/index.d.mts +22 -0
- package/dist/index.mjs +11 -1
- package/llms.txt +12 -2
- package/package.json +10 -9
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ Design-system agnostic theme engine for [RootNative UI](https://github.com/rootn
|
|
|
14
14
|
pnpm add @rootnative/core @rootnative/inertia
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
-
Peer dependencies: `react >=
|
|
17
|
+
Peer dependencies: `react >=19.2.3`, `react-native >=0.83.0 <0.87.0`, `@rootnative/inertia >=0.0.10 <0.1.0`
|
|
18
18
|
|
|
19
19
|
`@rootnative/inertia` is required — every animation in the library runs on it.
|
|
20
20
|
npm and pnpm install required peers automatically; Yarn classic does not, so add
|
package/dist/index.d.mts
CHANGED
|
@@ -307,6 +307,28 @@ declare const breakpoints: {
|
|
|
307
307
|
* Returns the current Material Design 3 window size class based on viewport width.
|
|
308
308
|
* Reactively updates when the window is resized.
|
|
309
309
|
*
|
|
310
|
+
* **Hydration-safe by construction.** A static export renders on a server with
|
|
311
|
+
* no DOM, where react-native-web's `Dimensions` is hard-wired to `width: 0`,
|
|
312
|
+
* so every breakpoint resolves to `compact` and that is what ships in the
|
|
313
|
+
* HTML. On the client `Dimensions` reports the real width immediately, so
|
|
314
|
+
* without care the first client render disagrees with the markup it is
|
|
315
|
+
* hydrating — and **React does not repair that**. Measured against React
|
|
316
|
+
* 19.2.3: a `className` / `style` mismatch is adopted from the server DOM,
|
|
317
|
+
* left on screen, and reported through *zero* recoverable errors. A tablet
|
|
318
|
+
* gets the phone layout, permanently, with no console signal.
|
|
319
|
+
*
|
|
320
|
+
* So this hook reports `compact` for as long as the client is hydrating,
|
|
321
|
+
* matching the markup exactly, and switches to the measured breakpoint on the
|
|
322
|
+
* re-render React schedules once hydration finishes. The correction is an
|
|
323
|
+
* ordinary update, which *does* patch the DOM.
|
|
324
|
+
*
|
|
325
|
+
* **It costs nothing where there is no hydration.** On native, and on a
|
|
326
|
+
* single-page web build, `getServerSnapshot` is never called, so the measured
|
|
327
|
+
* breakpoint is returned from the first render with no extra pass. Consumers
|
|
328
|
+
* need no `useHydrated` gate of their own, and neither does `Grid`, which
|
|
329
|
+
* resolves a breakpoint map internally and gives a consumer nowhere to put
|
|
330
|
+
* one.
|
|
331
|
+
*
|
|
310
332
|
* @example
|
|
311
333
|
* const breakpoint = useBreakpoint()
|
|
312
334
|
* const columns = breakpoint === 'compact' ? 2 : 4
|
package/dist/index.mjs
CHANGED
|
@@ -340,6 +340,7 @@ function useIconResolver() {
|
|
|
340
340
|
}
|
|
341
341
|
|
|
342
342
|
// src/responsive/useBreakpoint.ts
|
|
343
|
+
import { useSyncExternalStore } from "react";
|
|
343
344
|
import { useWindowDimensions } from "react-native";
|
|
344
345
|
var breakpoints = {
|
|
345
346
|
compact: 0,
|
|
@@ -355,9 +356,18 @@ function getBreakpoint(width) {
|
|
|
355
356
|
if (width >= breakpoints.medium) return "medium";
|
|
356
357
|
return "compact";
|
|
357
358
|
}
|
|
359
|
+
var subscribeToNothing = () => () => {
|
|
360
|
+
};
|
|
361
|
+
var notHydrating = () => false;
|
|
362
|
+
var isHydratingOnServer = () => true;
|
|
358
363
|
function useBreakpoint() {
|
|
359
364
|
const { width } = useWindowDimensions();
|
|
360
|
-
|
|
365
|
+
const hydrating = useSyncExternalStore(
|
|
366
|
+
subscribeToNothing,
|
|
367
|
+
notHydrating,
|
|
368
|
+
isHydratingOnServer
|
|
369
|
+
);
|
|
370
|
+
return getBreakpoint(hydrating ? 0 : width);
|
|
361
371
|
}
|
|
362
372
|
|
|
363
373
|
// src/responsive/useBreakpointValue.ts
|
package/llms.txt
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# @rootnative/core — Theme System for React Native
|
|
2
2
|
|
|
3
|
-
> Version: 0.0.0-alpha.
|
|
4
|
-
> Peer deps: react >=
|
|
3
|
+
> Version: 0.0.0-alpha.16
|
|
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
|
|
|
7
7
|
## Quick Start
|
|
@@ -323,3 +323,13 @@ const columns = useBreakpointValue({ compact: 1, medium: 2, expanded: 4 })
|
|
|
323
323
|
|
|
324
324
|
Type: `useBreakpointValue<T>(values: Partial<Record<Breakpoint, T>> & Record<'compact', T>): T`
|
|
325
325
|
|
|
326
|
+
### Breakpoints and static export (web)
|
|
327
|
+
|
|
328
|
+
Both hooks are hydration-safe, so **no `useHydrated` gate is needed at the call site**.
|
|
329
|
+
|
|
330
|
+
A static export (`web.output: 'static'`) renders on a server with no DOM, where react-native-web's `Dimensions` is fixed at `width: 0` — so every breakpoint resolves to `compact` and that is what ships in the HTML. React 19 does **not** repair a `className`/`style` mismatch during hydration: it adopts the server DOM, keeps it, and fires no recoverable error, so a tablet would silently keep the phone layout.
|
|
331
|
+
|
|
332
|
+
`useBreakpoint` therefore reports `compact` for as long as the client is hydrating, matching that markup, and switches to the measured breakpoint on the re-render React schedules once hydration finishes. On native and on a single-page web build there is no hydration, so the measured value is returned from the first render at no cost.
|
|
333
|
+
|
|
334
|
+
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.
|
|
335
|
+
|
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.16",
|
|
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,
|
|
@@ -53,21 +53,22 @@
|
|
|
53
53
|
"md3"
|
|
54
54
|
],
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"@rootnative/inertia": ">=0.0.
|
|
57
|
-
"react": ">=
|
|
58
|
-
"react-native": ">=0.
|
|
56
|
+
"@rootnative/inertia": ">=0.0.11 <0.1.0",
|
|
57
|
+
"react": ">=19.2.3 <20.0.0",
|
|
58
|
+
"react-native": ">=0.83.0 <0.87.0"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"@material/material-color-utilities": "^0.4.0",
|
|
62
|
-
"@react-native/babel-preset": "^0.
|
|
63
|
-
"@
|
|
62
|
+
"@react-native/babel-preset": "^0.86.3",
|
|
63
|
+
"@react-native/jest-preset": "^0.86.3",
|
|
64
|
+
"@rootnative/inertia": "0.0.12",
|
|
64
65
|
"@testing-library/react-native": "^13.3.3",
|
|
65
66
|
"@types/jest": "^29.5.14",
|
|
66
67
|
"@types/react": "^19.0.0",
|
|
67
68
|
"jest": "^29.7.0",
|
|
68
|
-
"react": "19.
|
|
69
|
-
"react-native": "0.
|
|
70
|
-
"react-test-renderer": "19.
|
|
69
|
+
"react": "19.2.3",
|
|
70
|
+
"react-native": "0.86.3",
|
|
71
|
+
"react-test-renderer": "19.2.3",
|
|
71
72
|
"tsup": "^8.0.0",
|
|
72
73
|
"typescript": "^5.0.0"
|
|
73
74
|
},
|