@flightdev/router 0.4.0 → 0.4.1
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 +7 -6
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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flightdev/router",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "Agnostic client-side routing primitives for Flight Framework",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -50,11 +50,6 @@
|
|
|
50
50
|
],
|
|
51
51
|
"author": "Flight Framework",
|
|
52
52
|
"license": "MIT",
|
|
53
|
-
"repository": {
|
|
54
|
-
"type": "git",
|
|
55
|
-
"url": "https://github.com/EliosLT/Flight-framework",
|
|
56
|
-
"directory": "packages/router"
|
|
57
|
-
},
|
|
58
53
|
"devDependencies": {
|
|
59
54
|
"@types/react": "^19.0.0",
|
|
60
55
|
"@types/react-dom": "^19.0.0",
|
|
@@ -88,6 +83,12 @@
|
|
|
88
83
|
"optional": true
|
|
89
84
|
}
|
|
90
85
|
},
|
|
86
|
+
"homepage": "https://github.com/EliosLT/FlightDev",
|
|
87
|
+
"repository": {
|
|
88
|
+
"url": "https://github.com/EliosLT/FlightDev.git",
|
|
89
|
+
"directory": "packages/router",
|
|
90
|
+
"type": "git"
|
|
91
|
+
},
|
|
91
92
|
"scripts": {
|
|
92
93
|
"build": "tsup",
|
|
93
94
|
"dev": "tsup --watch"
|