@flightdev/router 0.4.0 → 0.5.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 +15 -15
- package/package.json +95 -94
- package/LICENSE +0 -21
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# @
|
|
1
|
+
# @flightdev/router
|
|
2
2
|
|
|
3
3
|
Universal client-side routing primitives for Flight Framework. Zero external dependencies. Works with any UI framework.
|
|
4
4
|
|
|
@@ -40,7 +40,7 @@ Universal client-side routing primitives for Flight Framework. Zero external dep
|
|
|
40
40
|
## Installation
|
|
41
41
|
|
|
42
42
|
```bash
|
|
43
|
-
npm install @
|
|
43
|
+
npm install @flightdev/router
|
|
44
44
|
```
|
|
45
45
|
|
|
46
46
|
---
|
|
@@ -50,7 +50,7 @@ npm install @flight-framework/router
|
|
|
50
50
|
### With React
|
|
51
51
|
|
|
52
52
|
```tsx
|
|
53
|
-
import { RouterProvider, Link, useRouter } from '@
|
|
53
|
+
import { RouterProvider, Link, useRouter } from '@flightdev/router';
|
|
54
54
|
|
|
55
55
|
function App() {
|
|
56
56
|
return (
|
|
@@ -140,7 +140,7 @@ import {
|
|
|
140
140
|
smartPrefetch,
|
|
141
141
|
shouldSkipPrefetch,
|
|
142
142
|
canPrefetchOnNetwork,
|
|
143
|
-
} from '@
|
|
143
|
+
} from '@flightdev/router';
|
|
144
144
|
|
|
145
145
|
// Respects network conditions automatically
|
|
146
146
|
smartPrefetch('/dashboard');
|
|
@@ -181,7 +181,7 @@ Render routes in modals while preserving URL state. Perfect for photo galleries,
|
|
|
181
181
|
import {
|
|
182
182
|
InterceptedRouteProvider,
|
|
183
183
|
useInterceptedRoute,
|
|
184
|
-
} from '@
|
|
184
|
+
} from '@flightdev/router';
|
|
185
185
|
|
|
186
186
|
// Wrap your layout
|
|
187
187
|
function RootLayout({ children }) {
|
|
@@ -227,7 +227,7 @@ import {
|
|
|
227
227
|
useInterceptedRoute,
|
|
228
228
|
useSetInterceptedRoute,
|
|
229
229
|
useIsIntercepting,
|
|
230
|
-
} from '@
|
|
230
|
+
} from '@flightdev/router';
|
|
231
231
|
|
|
232
232
|
// Check if currently intercepting
|
|
233
233
|
const isIntercepting = useIsIntercepting();
|
|
@@ -247,7 +247,7 @@ import {
|
|
|
247
247
|
prefetchWhenIdle,
|
|
248
248
|
isPrefetched,
|
|
249
249
|
clearPrefetchCache,
|
|
250
|
-
} from '@
|
|
250
|
+
} from '@flightdev/router';
|
|
251
251
|
|
|
252
252
|
// Basic prefetch
|
|
253
253
|
prefetch('/docs');
|
|
@@ -280,7 +280,7 @@ clearPrefetchCache();
|
|
|
280
280
|
Control concurrent prefetch requests to avoid overwhelming the network:
|
|
281
281
|
|
|
282
282
|
```typescript
|
|
283
|
-
import { PrefetchQueue } from '@
|
|
283
|
+
import { PrefetchQueue } from '@flightdev/router';
|
|
284
284
|
|
|
285
285
|
// Create queue with max 3 concurrent prefetches
|
|
286
286
|
const queue = new PrefetchQueue(3);
|
|
@@ -310,7 +310,7 @@ import {
|
|
|
310
310
|
useParams,
|
|
311
311
|
useSearchParams,
|
|
312
312
|
usePathname,
|
|
313
|
-
} from '@
|
|
313
|
+
} from '@flightdev/router';
|
|
314
314
|
|
|
315
315
|
// Get current path and navigation functions
|
|
316
316
|
const { path, searchParams, navigate, back, forward } = useRouter();
|
|
@@ -330,7 +330,7 @@ const pathname = usePathname();
|
|
|
330
330
|
## Programmatic Navigation
|
|
331
331
|
|
|
332
332
|
```typescript
|
|
333
|
-
import { navigate, prefetch } from '@
|
|
333
|
+
import { navigate, prefetch } from '@flightdev/router';
|
|
334
334
|
|
|
335
335
|
// Navigate to a path
|
|
336
336
|
navigate('/docs');
|
|
@@ -350,7 +350,7 @@ navigate('/dashboard', { state: { from: '/login' } });
|
|
|
350
350
|
## Route Matching
|
|
351
351
|
|
|
352
352
|
```typescript
|
|
353
|
-
import { matchRoute, parseParams, generatePath } from '@
|
|
353
|
+
import { matchRoute, parseParams, generatePath } from '@flightdev/router';
|
|
354
354
|
|
|
355
355
|
// Check if a path matches a pattern
|
|
356
356
|
const { matched, params } = matchRoute('/docs/routing', '/docs/:slug');
|
|
@@ -386,7 +386,7 @@ const path = generatePath('/docs/:slug', { slug: 'api-routes' });
|
|
|
386
386
|
For proactive prefetching based on user behavior:
|
|
387
387
|
|
|
388
388
|
```tsx
|
|
389
|
-
import { PrefetchPageLinks } from '@
|
|
389
|
+
import { PrefetchPageLinks } from '@flightdev/router';
|
|
390
390
|
|
|
391
391
|
function SearchResults({ results }) {
|
|
392
392
|
return (
|
|
@@ -410,7 +410,7 @@ function SearchResults({ results }) {
|
|
|
410
410
|
|
|
411
411
|
```vue
|
|
412
412
|
<script setup>
|
|
413
|
-
import { useLinkProps } from '@
|
|
413
|
+
import { useLinkProps } from '@flightdev/router';
|
|
414
414
|
|
|
415
415
|
const docsLink = useLinkProps('/docs', { prefetch: 'intent' });
|
|
416
416
|
</script>
|
|
@@ -423,7 +423,7 @@ const docsLink = useLinkProps('/docs', { prefetch: 'intent' });
|
|
|
423
423
|
### Vanilla JavaScript
|
|
424
424
|
|
|
425
425
|
```typescript
|
|
426
|
-
import { createLink, prefetch } from '@
|
|
426
|
+
import { createLink, prefetch } from '@flightdev/router';
|
|
427
427
|
|
|
428
428
|
const link = createLink({
|
|
429
429
|
href: '/docs',
|
|
@@ -478,7 +478,7 @@ import type {
|
|
|
478
478
|
SmartPrefetchOptions,
|
|
479
479
|
InterceptedRouteState,
|
|
480
480
|
InterceptedRouteContextValue,
|
|
481
|
-
} from '@
|
|
481
|
+
} from '@flightdev/router';
|
|
482
482
|
```
|
|
483
483
|
|
|
484
484
|
---
|
package/package.json
CHANGED
|
@@ -1,95 +1,96 @@
|
|
|
1
|
-
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
"
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@flightdev/router",
|
|
3
|
+
"version": "0.5.0",
|
|
4
|
+
"description": "Agnostic client-side routing primitives for Flight Framework",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./react": {
|
|
15
|
+
"types": "./dist/react/index.d.ts",
|
|
16
|
+
"import": "./dist/react/index.js"
|
|
17
|
+
},
|
|
18
|
+
"./vue": {
|
|
19
|
+
"types": "./dist/vue/index.d.ts",
|
|
20
|
+
"import": "./dist/vue/index.js"
|
|
21
|
+
},
|
|
22
|
+
"./svelte": {
|
|
23
|
+
"types": "./dist/svelte/index.d.ts",
|
|
24
|
+
"import": "./dist/svelte/index.js"
|
|
25
|
+
},
|
|
26
|
+
"./solid": {
|
|
27
|
+
"types": "./dist/solid/index.d.ts",
|
|
28
|
+
"import": "./dist/solid/index.js"
|
|
29
|
+
},
|
|
30
|
+
"./preact": {
|
|
31
|
+
"types": "./dist/preact/index.d.ts",
|
|
32
|
+
"import": "./dist/preact/index.js"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"files": [
|
|
36
|
+
"dist",
|
|
37
|
+
"README.md"
|
|
38
|
+
],
|
|
39
|
+
"scripts": {
|
|
40
|
+
"build": "tsup",
|
|
41
|
+
"dev": "tsup --watch"
|
|
42
|
+
},
|
|
43
|
+
"keywords": [
|
|
44
|
+
"flight",
|
|
45
|
+
"router",
|
|
46
|
+
"spa",
|
|
47
|
+
"navigation",
|
|
48
|
+
"ssr",
|
|
49
|
+
"react",
|
|
50
|
+
"vue",
|
|
51
|
+
"svelte",
|
|
52
|
+
"solid",
|
|
53
|
+
"preact"
|
|
54
|
+
],
|
|
55
|
+
"author": "Flight Framework",
|
|
56
|
+
"license": "MIT",
|
|
57
|
+
"devDependencies": {
|
|
58
|
+
"@types/react": "^19.0.0",
|
|
59
|
+
"@types/react-dom": "^19.0.0",
|
|
60
|
+
"preact": "^10.19.0",
|
|
61
|
+
"solid-js": "^1.8.0",
|
|
62
|
+
"tsup": "^8.0.0",
|
|
63
|
+
"typescript": "^5.3.0",
|
|
64
|
+
"vue": "^3.4.0"
|
|
65
|
+
},
|
|
66
|
+
"peerDependencies": {
|
|
67
|
+
"preact": "\u003e=10.0.0",
|
|
68
|
+
"react": "\u003e=18.0.0",
|
|
69
|
+
"solid-js": "\u003e=1.0.0",
|
|
70
|
+
"svelte": "\u003e=4.0.0",
|
|
71
|
+
"vue": "\u003e=3.0.0"
|
|
72
|
+
},
|
|
73
|
+
"peerDependenciesMeta": {
|
|
74
|
+
"react": {
|
|
75
|
+
"optional": true
|
|
76
|
+
},
|
|
77
|
+
"vue": {
|
|
78
|
+
"optional": true
|
|
79
|
+
},
|
|
80
|
+
"svelte": {
|
|
81
|
+
"optional": true
|
|
82
|
+
},
|
|
83
|
+
"solid-js": {
|
|
84
|
+
"optional": true
|
|
85
|
+
},
|
|
86
|
+
"preact": {
|
|
87
|
+
"optional": true
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
"homepage": "https://github.com/EliosLT/FlightDev",
|
|
91
|
+
"repository": {
|
|
92
|
+
"url": "https://github.com/EliosLT/FlightDev.git",
|
|
93
|
+
"directory": "packages/router",
|
|
94
|
+
"type": "git"
|
|
95
|
+
}
|
|
95
96
|
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2024-2026 Flight Contributors
|
|
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
|
-
SOFTWARE.
|