@flemo/react 1.12.8 → 2.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/README.md +77 -9
- package/dist/Router.d.ts +3 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.mjs +586 -448
- package/dist/navigate/useNavigate.d.ts +0 -1
- package/dist/screen/Layer.d.ts +40 -0
- package/dist/screen/LayerContext.d.ts +77 -0
- package/dist/screen/Morph.d.ts +14 -0
- package/dist/screen/MorphLayer/MorphLayer.d.ts +6 -0
- package/dist/screen/MorphLayer/index.d.ts +1 -0
- package/dist/screen/Screen.d.ts +6 -0
- package/dist/screen/ScreenFreeze.d.ts +13 -1
- package/dist/screen/ScreenMotion.d.ts +1 -1
- package/dist/screen/__tests__/Layer.test.d.ts +1 -0
- package/dist/screen/__tests__/Morph.test.d.ts +1 -0
- package/dist/screen/__tests__/ScreenFreeze.portal.test.d.ts +1 -0
- package/dist/screen/__tests__/ScreenMotion.swipeBack.test.d.ts +1 -0
- package/dist/transition/styles.d.ts +2 -2
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -13,9 +13,12 @@
|
|
|
13
13
|
---
|
|
14
14
|
|
|
15
15
|
flemo is a router whose unit of routing is a **screen**, not a page. Push, pop, and the
|
|
16
|
-
animations and gestures between
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
animations and gestures between them belong to the router, so an app does not have to wire a
|
|
17
|
+
routing library and an animation library together and then keep their timing in agreement.
|
|
18
|
+
|
|
19
|
+
Transitions compile to CSS `@keyframes` and run on the compositor. Shared-element morphs,
|
|
20
|
+
swipe back, and the screen lifecycle are parts of that one engine rather than separate
|
|
21
|
+
integrations.
|
|
19
22
|
|
|
20
23
|
## Install
|
|
21
24
|
|
|
@@ -23,15 +26,80 @@ framework-agnostic core lives in `@flemo/core`).
|
|
|
23
26
|
pnpm add @flemo/react
|
|
24
27
|
```
|
|
25
28
|
|
|
26
|
-
`@flemo/react`
|
|
27
|
-
|
|
28
|
-
|
|
29
|
+
`@flemo/react` needs `react ^19` and `react-dom ^19`, and nothing else. Shared-element
|
|
30
|
+
morphs are included, so no animation library sits beside it. `@flemo/core` comes along as a
|
|
31
|
+
regular dependency.
|
|
32
|
+
|
|
33
|
+
## Example
|
|
34
|
+
|
|
35
|
+
```tsx
|
|
36
|
+
import { Route, Router, Screen, useNavigate } from "@flemo/react";
|
|
37
|
+
|
|
38
|
+
function Home() {
|
|
39
|
+
const navigate = useNavigate();
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<Screen>
|
|
43
|
+
<h1>Home</h1>
|
|
44
|
+
<button onClick={() => navigate.push("/posts/:slug", { slug: "hello" })}>Open hello</button>
|
|
45
|
+
</Screen>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export default function App() {
|
|
50
|
+
return (
|
|
51
|
+
<Router>
|
|
52
|
+
<Route path="/" element={<Home />} />
|
|
53
|
+
<Route path="/posts/:slug" element={<Post />} />
|
|
54
|
+
</Router>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Augment `RegisterRoute` once and TypeScript checks every path and params object:
|
|
60
|
+
|
|
61
|
+
```ts
|
|
62
|
+
declare module "@flemo/react" {
|
|
63
|
+
interface RegisterRoute {
|
|
64
|
+
"/": undefined;
|
|
65
|
+
"/posts/:slug": { slug: string };
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Browser Back, `navigate.pop()`, and a drag from the left edge each pop the pushed screen.
|
|
71
|
+
|
|
72
|
+
## What ships in this package
|
|
73
|
+
|
|
74
|
+
`Router` and `Route` own the stack. `Screen` is the unit that moves, and it takes the shared
|
|
75
|
+
top and bottom bars that hand over between screens. `Morph` pairs one element across two
|
|
76
|
+
screens by `layoutId` so it travels instead of appearing. `Part` runs a named transition on a
|
|
77
|
+
single element inside a screen. `Layer` renders an overlay beside the screen so a sheet can
|
|
78
|
+
cover the shared bars while the screen moves. The `useNavigate`, `useScreen`, `useParams`,
|
|
79
|
+
`usePathname`, and `useStep` hooks read and drive all of it.
|
|
80
|
+
|
|
81
|
+
## Packages
|
|
82
|
+
|
|
83
|
+
| Package | Published | What it is |
|
|
84
|
+
| ----------------- | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
85
|
+
| `@flemo/react` | yes | The React binding. Install this one. |
|
|
86
|
+
| `@flemo/core` | yes | Framework-agnostic primitives: the navigation task queue, the stores, transition factories and presets, the keyframes compiler, and the morph runtime. Install it directly only to use those without React. |
|
|
87
|
+
| `@flemo/devtools` | yes | Zero-dependency flight recorder and visual panel. It observes the `data-flemo-*` surfaces the engine already exposes and imports neither package above, so attaching it does not change measured motion. |
|
|
88
|
+
|
|
89
|
+
Svelte and SolidJS bindings are planned. There is no `flemo` meta package.
|
|
29
90
|
|
|
30
91
|
## Documentation
|
|
31
92
|
|
|
32
|
-
|
|
33
|
-
transitions, shared-element morphs, gestures, and the
|
|
34
|
-
|
|
93
|
+
[flemo.dev](https://flemo.dev) carries the full guide in English and Korean: getting started,
|
|
94
|
+
transitions, shared-element morphs, gestures, and the API reference. The live playground is at
|
|
95
|
+
[flemo.dev/playground](https://flemo.dev/playground).
|
|
96
|
+
|
|
97
|
+
## Contributing
|
|
98
|
+
|
|
99
|
+
The source lives at [github.com/kimjh96/flemo](https://github.com/kimjh96/flemo), a pnpm and
|
|
100
|
+
Turborepo monorepo. `pnpm turbo run typecheck lint test build` from the repository root is the
|
|
101
|
+
gate every change passes before it lands, and `AGENTS.md` holds the working rules: the layout,
|
|
102
|
+
where each kind of change belongs, and how releases are cut with Changesets.
|
|
35
103
|
|
|
36
104
|
## License
|
|
37
105
|
|
package/dist/Router.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CSSProperties, PropsWithChildren } from 'react';
|
|
2
|
-
import { HistoryDriver, PartTransition, Decorator, Transition, TransitionName } from '@flemo/core';
|
|
2
|
+
import { HistoryDriver, MorphTransition, PartTransition, Decorator, Transition, TransitionName } from '@flemo/core';
|
|
3
3
|
interface RouterProps {
|
|
4
4
|
name?: string;
|
|
5
5
|
strictRoutes?: boolean;
|
|
@@ -8,10 +8,11 @@ interface RouterProps {
|
|
|
8
8
|
transitions?: Transition[];
|
|
9
9
|
decorators?: Decorator[];
|
|
10
10
|
partTransitions?: PartTransition[];
|
|
11
|
+
morphTransitions?: MorphTransition[];
|
|
11
12
|
history?: "browser" | "memory";
|
|
12
13
|
createDriver?: (routerKey?: string) => HistoryDriver;
|
|
13
14
|
className?: string;
|
|
14
15
|
style?: CSSProperties;
|
|
15
16
|
}
|
|
16
|
-
declare function Router({ children, name, strictRoutes, initPath, defaultTransitionName, transitions, decorators, partTransitions, history, createDriver, className, style }: PropsWithChildren<RouterProps>): import("react").JSX.Element;
|
|
17
|
+
declare function Router({ children, name, strictRoutes, initPath, defaultTransitionName, transitions, decorators, partTransitions, morphTransitions, history, createDriver, className, style }: PropsWithChildren<RouterProps>): import("react").JSX.Element;
|
|
17
18
|
export default Router;
|
package/dist/index.d.ts
CHANGED
|
@@ -13,6 +13,8 @@ export { default as ScreenMotion } from './screen/ScreenMotion';
|
|
|
13
13
|
export { default as ScreenFreeze } from './screen/ScreenFreeze';
|
|
14
14
|
export { default as ScreenDecorator } from './screen/ScreenDecorator';
|
|
15
15
|
export { default as Part, type PartProps } from './screen/Part';
|
|
16
|
+
export { default as Layer, type LayerProps } from './screen/Layer';
|
|
17
|
+
export { default as Morph, type MorphProps } from './screen/Morph';
|
|
16
18
|
export { default as ScreenContext, type ScreenContextProps } from './screen/ScreenContext';
|
|
17
19
|
export { default as useHistoryStore } from './stores/useHistoryStore';
|
|
18
20
|
export { default as useNavigateStore } from './stores/useNavigateStore';
|
|
@@ -22,5 +24,5 @@ export { default as RouterScopeProvider } from './stores/RouterScopeProvider';
|
|
|
22
24
|
export { type FlemoStores } from './stores/StoreContext';
|
|
23
25
|
export { type SharedBarId, type SharedBarMetadata, type SharedBarPresence, type SharedBarsMetadata } from './screen/store';
|
|
24
26
|
export { default as useViewportScrollHeight } from './screen/useViewportScrollHeight';
|
|
25
|
-
export { createTransition, createRawTransition, createDecorator, createRawDecorator, createPartTransition, createRawPartTransition, partTransitionMap, createBrowserHistoryDriver } from '@flemo/core';
|
|
26
|
-
export type { TransitionName, RegisterTransition, DecoratorName, RegisterDecorator, PartTransitionName, RegisterPartTransition, PartTransitionOptions, HistoryDriver, HistoryNavEvent } from '@flemo/core';
|
|
27
|
+
export { createTransition, createRawTransition, createDecorator, createRawDecorator, createPartTransition, createRawPartTransition, partTransitionMap, createMorphTransition, createRawMorphTransition, morphTransitionMap, createBrowserHistoryDriver } from '@flemo/core';
|
|
28
|
+
export type { TransitionName, RegisterTransition, DecoratorName, RegisterDecorator, PartTransitionName, RegisterPartTransition, PartTransitionOptions, MorphTransitionName, RegisterMorphTransition, MorphTransitionOptions, HistoryDriver, HistoryNavEvent } from '@flemo/core';
|