@bromscandium/router 1.0.0 → 1.0.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/LICENSE +20 -20
- package/README.md +91 -91
- package/package.json +42 -42
- package/src/components.tsx +411 -411
- package/src/hooks.ts +180 -180
- package/src/index.ts +31 -31
- package/src/router.ts +448 -448
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 bromscandium
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 bromscandium
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
21
|
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,91 +1,91 @@
|
|
|
1
|
-
# @bromscandium/router
|
|
2
|
-
|
|
3
|
-
Client-side router for BromiumJS with file-based routing support.
|
|
4
|
-
|
|
5
|
-
## Installation
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
npm install @bromscandium/router
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## Usage
|
|
12
|
-
|
|
13
|
-
```tsx
|
|
14
|
-
import { createRouter, Link, RouterView, useParams } from '@bromscandium/router';
|
|
15
|
-
|
|
16
|
-
const router = createRouter({
|
|
17
|
-
routes: [
|
|
18
|
-
{ path: '/', component: Home },
|
|
19
|
-
{ path: '/users/:id', component: UserProfile },
|
|
20
|
-
],
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
function App() {
|
|
24
|
-
return (
|
|
25
|
-
<div>
|
|
26
|
-
<nav>
|
|
27
|
-
<Link to="/">Home</Link>
|
|
28
|
-
<Link to="/users/123">User</Link>
|
|
29
|
-
</nav>
|
|
30
|
-
<RouterView />
|
|
31
|
-
</div>
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function UserProfile() {
|
|
36
|
-
const params = useParams();
|
|
37
|
-
return <div>User ID: {params.value.id}</div>;
|
|
38
|
-
}
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
### Router Hooks
|
|
42
|
-
|
|
43
|
-
```tsx
|
|
44
|
-
import { useRouter, useRoute, useParams, useQuery, useNavigate } from '@bromscandium/router';
|
|
45
|
-
|
|
46
|
-
function Component() {
|
|
47
|
-
const router = useRouter();
|
|
48
|
-
const route = useRoute();
|
|
49
|
-
const params = useParams();
|
|
50
|
-
const query = useQuery();
|
|
51
|
-
const nav = useNavigate();
|
|
52
|
-
|
|
53
|
-
const goHome = () => nav.push('/');
|
|
54
|
-
const goBack = () => nav.back();
|
|
55
|
-
|
|
56
|
-
return <button onClick={goHome}>Home</button>;
|
|
57
|
-
}
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
### Link Component
|
|
61
|
-
|
|
62
|
-
```tsx
|
|
63
|
-
<Link to="/about">About</Link>
|
|
64
|
-
|
|
65
|
-
<Link
|
|
66
|
-
to="/about"
|
|
67
|
-
activeClassName="active"
|
|
68
|
-
exactActiveClassName="exact-active"
|
|
69
|
-
>
|
|
70
|
-
About
|
|
71
|
-
</Link>
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
## API
|
|
75
|
-
|
|
76
|
-
| Export | Description |
|
|
77
|
-
|--------|-------------|
|
|
78
|
-
| `createRouter(options)` | Create router instance |
|
|
79
|
-
| `Link` | Navigation link component |
|
|
80
|
-
| `RouterView` | Route outlet component |
|
|
81
|
-
| `Navigate` | Programmatic navigation component |
|
|
82
|
-
| `Redirect` | Redirect component |
|
|
83
|
-
| `useRouter()` | Access router instance |
|
|
84
|
-
| `useRoute()` | Access current route (Ref) |
|
|
85
|
-
| `useParams()` | Access route parameters (ComputedRef) |
|
|
86
|
-
| `useQuery()` | Access query parameters (ComputedRef) |
|
|
87
|
-
| `useNavigate()` | Get navigation methods |
|
|
88
|
-
|
|
89
|
-
## License
|
|
90
|
-
|
|
91
|
-
MIT
|
|
1
|
+
# @bromscandium/router
|
|
2
|
+
|
|
3
|
+
Client-side router for BromiumJS with file-based routing support.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @bromscandium/router
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
import { createRouter, Link, RouterView, useParams } from '@bromscandium/router';
|
|
15
|
+
|
|
16
|
+
const router = createRouter({
|
|
17
|
+
routes: [
|
|
18
|
+
{ path: '/', component: Home },
|
|
19
|
+
{ path: '/users/:id', component: UserProfile },
|
|
20
|
+
],
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
function App() {
|
|
24
|
+
return (
|
|
25
|
+
<div>
|
|
26
|
+
<nav>
|
|
27
|
+
<Link to="/">Home</Link>
|
|
28
|
+
<Link to="/users/123">User</Link>
|
|
29
|
+
</nav>
|
|
30
|
+
<RouterView />
|
|
31
|
+
</div>
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function UserProfile() {
|
|
36
|
+
const params = useParams();
|
|
37
|
+
return <div>User ID: {params.value.id}</div>;
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Router Hooks
|
|
42
|
+
|
|
43
|
+
```tsx
|
|
44
|
+
import { useRouter, useRoute, useParams, useQuery, useNavigate } from '@bromscandium/router';
|
|
45
|
+
|
|
46
|
+
function Component() {
|
|
47
|
+
const router = useRouter();
|
|
48
|
+
const route = useRoute();
|
|
49
|
+
const params = useParams();
|
|
50
|
+
const query = useQuery();
|
|
51
|
+
const nav = useNavigate();
|
|
52
|
+
|
|
53
|
+
const goHome = () => nav.push('/');
|
|
54
|
+
const goBack = () => nav.back();
|
|
55
|
+
|
|
56
|
+
return <button onClick={goHome}>Home</button>;
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Link Component
|
|
61
|
+
|
|
62
|
+
```tsx
|
|
63
|
+
<Link to="/about">About</Link>
|
|
64
|
+
|
|
65
|
+
<Link
|
|
66
|
+
to="/about"
|
|
67
|
+
activeClassName="active"
|
|
68
|
+
exactActiveClassName="exact-active"
|
|
69
|
+
>
|
|
70
|
+
About
|
|
71
|
+
</Link>
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## API
|
|
75
|
+
|
|
76
|
+
| Export | Description |
|
|
77
|
+
|--------|-------------|
|
|
78
|
+
| `createRouter(options)` | Create router instance |
|
|
79
|
+
| `Link` | Navigation link component |
|
|
80
|
+
| `RouterView` | Route outlet component |
|
|
81
|
+
| `Navigate` | Programmatic navigation component |
|
|
82
|
+
| `Redirect` | Redirect component |
|
|
83
|
+
| `useRouter()` | Access router instance |
|
|
84
|
+
| `useRoute()` | Access current route (Ref) |
|
|
85
|
+
| `useParams()` | Access route parameters (ComputedRef) |
|
|
86
|
+
| `useQuery()` | Access query parameters (ComputedRef) |
|
|
87
|
+
| `useNavigate()` | Get navigation methods |
|
|
88
|
+
|
|
89
|
+
## License
|
|
90
|
+
|
|
91
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@bromscandium/router",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "BromiumJS router with file-based routing support",
|
|
5
|
-
"author": "bromscandium",
|
|
6
|
-
"license": "MIT",
|
|
7
|
-
"repository": {
|
|
8
|
-
"type": "git",
|
|
9
|
-
"url": "git+https://github.com/bromscandium/bromiumjs.git",
|
|
10
|
-
"directory": "packages/router"
|
|
11
|
-
},
|
|
12
|
-
"homepage": "https://github.com/bromscandium/bromiumjs#readme",
|
|
13
|
-
"bugs": {
|
|
14
|
-
"url": "https://github.com/bromscandium/bromiumjs/issues"
|
|
15
|
-
},
|
|
16
|
-
"keywords": ["bromium", "bromiumjs", "router", "file-based-routing", "spa"],
|
|
17
|
-
"type": "module",
|
|
18
|
-
"main": "./dist/index.js",
|
|
19
|
-
"module": "./dist/index.js",
|
|
20
|
-
"types": "./dist/index.d.ts",
|
|
21
|
-
"exports": {
|
|
22
|
-
".": {
|
|
23
|
-
"import": "./dist/index.js",
|
|
24
|
-
"types": "./dist/index.d.ts"
|
|
25
|
-
}
|
|
26
|
-
},
|
|
27
|
-
"files": [
|
|
28
|
-
"dist",
|
|
29
|
-
"src"
|
|
30
|
-
],
|
|
31
|
-
"scripts": {
|
|
32
|
-
"build": "tsc",
|
|
33
|
-
"dev": "tsc --watch"
|
|
34
|
-
},
|
|
35
|
-
"dependencies": {
|
|
36
|
-
"@bromscandium/core": "^1.0.0",
|
|
37
|
-
"@bromscandium/runtime": "^1.0.0"
|
|
38
|
-
},
|
|
39
|
-
"devDependencies": {
|
|
40
|
-
"typescript": "^5.9.3"
|
|
41
|
-
}
|
|
42
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@bromscandium/router",
|
|
3
|
+
"version": "1.0.2",
|
|
4
|
+
"description": "BromiumJS router with file-based routing support",
|
|
5
|
+
"author": "bromscandium",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/bromscandium/bromiumjs.git",
|
|
10
|
+
"directory": "packages/router"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://github.com/bromscandium/bromiumjs#readme",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/bromscandium/bromiumjs/issues"
|
|
15
|
+
},
|
|
16
|
+
"keywords": ["bromium", "bromiumjs", "router", "file-based-routing", "spa"],
|
|
17
|
+
"type": "module",
|
|
18
|
+
"main": "./dist/index.js",
|
|
19
|
+
"module": "./dist/index.js",
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"exports": {
|
|
22
|
+
".": {
|
|
23
|
+
"import": "./dist/index.js",
|
|
24
|
+
"types": "./dist/index.d.ts"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"dist",
|
|
29
|
+
"src"
|
|
30
|
+
],
|
|
31
|
+
"scripts": {
|
|
32
|
+
"build": "tsc",
|
|
33
|
+
"dev": "tsc --watch"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@bromscandium/core": "^1.0.0",
|
|
37
|
+
"@bromscandium/runtime": "^1.0.0"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"typescript": "^5.9.3"
|
|
41
|
+
}
|
|
42
|
+
}
|