@intent-framework/router 0.1.0-alpha.1 → 0.1.0-alpha.2
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 +59 -0
- package/package.json +2 -2
package/README.md
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# @intent-framework/router
|
|
2
|
+
|
|
3
|
+
Typed route definitions and navigation for Intent.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
pnpm add @intent-framework/core@0.1.0-alpha.1 @intent-framework/router@0.1.0-alpha.1
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
npm install @intent-framework/core@0.1.0-alpha.1 @intent-framework/router@0.1.0-alpha.1
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## What it provides
|
|
16
|
+
|
|
17
|
+
- `createRouter()` — typed, immutable route builder
|
|
18
|
+
- `.route(name, path, screen)` — register a route with typed params
|
|
19
|
+
- `.match(pathname)` — match a pathname to a route + screen
|
|
20
|
+
- `.path(name, params)` — generate a typed path string
|
|
21
|
+
- `RouterServices` — typed navigation service for screens and actions
|
|
22
|
+
- `renderRouter()` integration lives in `@intent-framework/dom`
|
|
23
|
+
|
|
24
|
+
## Minimal example
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
import { createRouter } from "@intent-framework/router"
|
|
28
|
+
|
|
29
|
+
type AppServices = {
|
|
30
|
+
navigate: (name: string) => void
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const router = createRouter<AppServices>()
|
|
34
|
+
.route("home", "/", HomeScreen)
|
|
35
|
+
.route("team", "/team/:teamId", TeamScreen)
|
|
36
|
+
.route("invite", "/team/:teamId/invite", InviteScreen)
|
|
37
|
+
|
|
38
|
+
const match = router.match("/team/abc123")
|
|
39
|
+
if (match.found) {
|
|
40
|
+
console.log(match.name, match.params) // "team", { teamId: "abc123" }
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const path = router.path("team", { teamId: "abc123" })
|
|
44
|
+
console.log(path) // "/team/abc123"
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Where this fits
|
|
48
|
+
|
|
49
|
+
Router provides typed route definitions and navigation for Intent screens. Use `@intent-framework/dom`'s `renderRouter()` to materialize navigation into the DOM. The router does not own the product model — it maps paths to screens.
|
|
50
|
+
|
|
51
|
+
## Learn more
|
|
52
|
+
|
|
53
|
+
- [Root README](../../README.md) — project overview and philosophy
|
|
54
|
+
- [MVP Checkpoint](../../docs/MVP-Checkpoint.md) — current implementation boundaries
|
|
55
|
+
- [Web basic example](../../examples/web-basic) — full demo with routing, resources, and diagnostics
|
|
56
|
+
|
|
57
|
+
## Status
|
|
58
|
+
|
|
59
|
+
Experimental alpha. Version `0.1.0-alpha.1`. APIs may change. Not recommended for production use.
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "0.1.0-alpha.
|
|
6
|
+
"version": "0.1.0-alpha.2",
|
|
7
7
|
"description": "Typed route definitions and navigation for Intent",
|
|
8
8
|
"license": "MIT",
|
|
9
9
|
"repository": {
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"dist"
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@intent-framework/core": "0.1.0-alpha.
|
|
29
|
+
"@intent-framework/core": "0.1.0-alpha.2"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"tsdown": "^0.3.0",
|