Skip to content

Commit 273d45f

Browse files
tonyfromundefinedclaudeENvironmentSet
authored
[BREAKING CHANGE] future -> stable (#695)
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Co-authored-by: ENvironmentSet <sbshw1@gmail.com>
1 parent f74f4b1 commit 273d45f

208 files changed

Lines changed: 2412 additions & 3659 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@stackflow/compat-await-push": patch
3+
---
4+
5+
Remove unused peer dependencies (`@stackflow/core`, `@stackflow/react`, `react`, `@types/react`) — pure Promise-based utility with no React or Stackflow imports.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@stackflow/config": major
3+
"@stackflow/core": major
4+
---
5+
6+
Major version bump for ecosystem alignment. No API changes.

.changeset/link-v2-stable-api.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
"@stackflow/link": major
3+
---
4+
5+
Promote Future API to the default entry point and remove the legacy Stable API.
6+
7+
- `@stackflow/link/future` and `@stackflow/link/stable` sub-paths removed. Import from `@stackflow/link` directly.
8+
- `createLinkComponent()` removed. Use `import { Link } from "@stackflow/link"` directly.
9+
- `LinkProps.urlPatternOptions` removed. Link URL generation now uses `config.historySync.urlPatternOptions`.

.changeset/react-v2-stable-api.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
"@stackflow/react": major
3+
---
4+
5+
Promote Future API to the default entry point and remove the legacy Stable API.
6+
7+
- `@stackflow/react/future` and `@stackflow/react/stable` sub-paths removed. Import from `@stackflow/react` directly.
8+
- `stackflow()` signature changed from `{ activities, transitionDuration }` to `{ config, components }`. Use `defineConfig()` from `@stackflow/config` for activity and route definitions.
9+
- `useActions()` removed in favor of direct `useFlow()` imports, and `useStepActions()` removed in favor of direct `useStepFlow()` imports.
10+
- `useActiveEffect()`, `useEnterDoneEffect()`, and `useStep()` are no longer exported from the default API.
11+
- Step actions moved from `stackflow().actions` to the separate `stackflow().stepActions` object, with renamed methods: `stepPush` -> `pushStep`, `stepReplace` -> `replaceStep`, and `stepPop` -> `popStep`.
12+
- `stackflow()` no longer returns the `activities` field, `useFlow`, `useStepFlow`, `addActivity`, or `addPlugin`. Hooks are now direct imports and activities are defined in `@stackflow/config`.
13+
- `stackflow().actions` no longer exposes `getStack()` or `dispatchEvent()`; it now exposes only `push`, `replace`, and `pop`.
14+
- `__internal__` directory removed; shared utilities are inlined into the main source.
15+
- New default exports: `useLoaderData()`, `useConfig()`, `usePrepare()`, `lazy()`, and `structuredActivityComponent()`.
16+
- Activity params now use `declare module "@stackflow/config" { interface Register { ... } }` instead of component props inference.

.pnp.cjs

Lines changed: 1 addition & 131 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

AGENTS.md

Lines changed: 35 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -130,33 +130,51 @@ Plugins can hook into various lifecycle events:
130130

131131
## Common Tasks
132132

133-
### Adding a New Activity
133+
### Setting Up Navigation
134134
```typescript
135-
export const { Stack, useFlow } = stackflow({
136-
transitionDuration: 350,
135+
import { stackflow } from "@stackflow/react";
136+
137+
export const { Stack, actions } = stackflow({
138+
config,
139+
components: {
140+
Main,
141+
Article,
142+
},
137143
plugins: [
138144
basicRendererPlugin(),
139145
basicUIPlugin({
140146
theme: "cupertino",
141147
}),
148+
historySyncPlugin({
149+
config,
150+
fallbackActivity: () => "Main",
151+
}),
142152
],
143-
activities: {
144-
MyActivity,
145-
},
146153
});
147154
```
148155

149-
### Navigation
156+
### Defining an Activity
150157
```tsx
151-
const MyActivity: ActivityComponentType = () => {
158+
import type { ActivityComponentType } from "@stackflow/react";
159+
import { useFlow } from "@stackflow/react";
160+
161+
declare module "@stackflow/config" {
162+
interface Register {
163+
MyActivity: {
164+
title: string;
165+
};
166+
}
167+
}
168+
169+
const MyActivity: ActivityComponentType<"MyActivity"> = () => {
152170
const { push } = useFlow();
153-
171+
154172
const onClick = () => {
155173
push("Article", {
156174
title: "Hello",
157175
});
158176
};
159-
177+
160178
return (
161179
<AppScreen appBar={{ title: "My Activity" }}>
162180
<div>
@@ -188,17 +206,15 @@ stackflow({
188206
});
189207
```
190208

191-
## Future API (Stackflow 2.0 Preview)
192-
193-
The Future API (`@stackflow/react/future`) is a preview of Stackflow 2.0 that optimizes initial loading performance through better separation of concerns. Key improvements:
209+
## API Design
194210

195-
- **Config-first approach**: Activities and routes defined in `@stackflow/config` using `defineConfig()`, with React components injected separately
196-
- **Direct imports**: Hooks (`useFlow`, `useStepFlow`) and `<Link>` component imported directly without factory functions
197-
- **Loader API**: Built-in data loading without React dependencies for better performance
198-
- **API Pipelining**: Parallel loading of API data and React app initialization
199-
- **Enhanced type safety**: Types inferred from config rather than component props
211+
`@stackflow/react` uses a config-first approach for optimal loading performance:
200212

201-
The Future API maintains compatibility with existing code while preparing for Stackflow 2.0. Routes are now declared in the config file alongside activities, and the plugin system has been streamlined to work with the centralized configuration.
213+
- **Config-first approach**: Activities and routes defined in `@stackflow/config` using `defineConfig()`, with React components injected separately via `stackflow()`
214+
- **Direct imports**: Hooks (`useFlow`, `useStepFlow`) and `<Link>` component imported directly from `@stackflow/react`
215+
- **Loader API**: Built-in data loading via `useLoaderData` without React dependencies for better performance
216+
- **Lazy loading**: Code splitting via `lazy()` for activity components
217+
- **Enhanced type safety**: Types inferred from config via `declare module "@stackflow/config"` register pattern
202218

203219
## Build System
204220

README.md

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,34 @@ So, what advantages does **Stackflow** have compared to the existing navigation
3535
## Getting Started
3636

3737
```bash
38-
$ yarn add @stackflow/core @stackflow/react
38+
$ yarn add @stackflow/config @stackflow/core @stackflow/react
3939
```
4040

4141
```tsx
42-
import ReactDOM from 'react-dom'
43-
44-
import { stackflow } from '@stackflow/react';
42+
import ReactDOM from "react-dom";
43+
import { defineConfig } from "@stackflow/config";
44+
import { stackflow } from "@stackflow/react";
45+
import MyActivity from "./MyActivity";
46+
47+
const config = defineConfig({
48+
activities: [
49+
{
50+
name: "MyActivity",
51+
},
52+
],
53+
initialActivity: () => "MyActivity",
54+
transitionDuration: 350,
55+
});
4556

46-
const { Stack, useFlow } = stackflow({
47-
// ...
57+
const { Stack } = stackflow({
58+
config,
59+
components: {
60+
MyActivity,
61+
},
62+
plugins: [],
4863
});
4964

50-
const App: React.FC = () => {
65+
const App = () => {
5166
return (
5267
<Stack />
5368
);

demo/package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,12 @@
3232
"dependencies": {
3333
"@seed-design/design-token": "^1.0.3",
3434
"@seed-design/stylesheet": "^1.0.4",
35-
"@stackflow/compat-await-push": "^1.1.13",
3635
"@stackflow/config": "^1.2.0",
3736
"@stackflow/core": "^1.1.0",
3837
"@stackflow/link": "^1.5.0",
3938
"@stackflow/plugin-basic-ui": "^1.9.2",
4039
"@stackflow/plugin-devtools": "^0.1.11",
4140
"@stackflow/plugin-history-sync": "^1.7.0",
42-
"@stackflow/plugin-map-initial-activity": "^1.0.11",
43-
"@stackflow/plugin-preload": "^1.4.3",
4441
"@stackflow/plugin-renderer-basic": "^1.1.13",
4542
"@stackflow/plugin-stack-depth-change": "^1.1.5",
4643
"@stackflow/react": "^1.4.0",

demo/src/activities/Article/Article.content.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {
22
content,
33
useActivityParams,
44
useLoaderData,
5-
} from "@stackflow/react/future";
5+
} from "@stackflow/react";
66
import { LazyLoadImage } from "react-lazy-load-image-component";
77
import ArticleCard from "../../components/ArticleCard";
88
import ArticleProfile from "../../components/ArticleProfile";

demo/src/activities/Article/Article.layout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { layout } from "@stackflow/react/future";
1+
import { layout } from "@stackflow/react";
22
import Layout from "../../components/Layout";
33

44
const ArticleLayout = layout<"Article">(({ params: { title }, children }) => {

0 commit comments

Comments
 (0)