rari 0.2.6 → 0.2.8
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/dist/client.d.ts +1 -1
- package/dist/client.js +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/{runtime-client-P4vvSVPV.d.ts → runtime-client-BEWMJWMx.d.ts} +0 -1
- package/dist/{runtime-client-CcEhh-F7.js → runtime-client-CC4YQweh.js} +18 -48
- package/dist/{server-MkYb94pQ.js → server-DeSCwqZZ.js} +31 -255
- package/dist/{server-Ph4oyo0B.d.ts → server-MY0-nRif.d.ts} +2 -47
- package/dist/server.d.ts +3 -3
- package/dist/server.js +3 -3
- package/package.json +7 -8
- package/src/router/index.ts +6 -12
- package/src/router/router.tsx +45 -101
- package/src/router/types.ts +1 -2
- package/src/server.ts +1 -1
- package/src/vite/index.ts +25 -242
- package/dist/client-dev.d.ts +0 -2
- package/dist/client-dev.js +0 -3
package/dist/server.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { ErrorBoundaryProps, FileRouteInfo, HttpRuntimeClient, LayoutProps, Link, LinkProps, LoadingProps, Navigate, NavigationOptions, NavigationState, Outlet, PageComponent, PageProps, Route, RouteComponent, RouteGenerationOptions, RouteMatch, RouteMeta, RouteParams, RouterConfig, RouterContext, RouterProvider, RouterProviderProps, Routes, RuntimeClient, SearchParams, buildSearchString, buildUrl, createHttpRuntimeClient, extractParamNames, findMatchingRoute, getRoutePriority, isDynamicRoute, isPathActive, joinPaths, normalizePathname, parseSearchParams, parseUrl, useNavigation, useParams, usePathname, useRoute, useRouter, useSearchParams, withRouter } from "./runtime-client-
|
|
2
|
-
import { FileRouteGenerator, convertFilePatternToRoutePattern,
|
|
3
|
-
export { ErrorBoundaryProps, FileRouteGenerator, FileRouteInfo, HttpRuntimeClient, LayoutProps, Link, LinkProps, LoadingProps, Navigate, NavigationOptions, NavigationState, Outlet, PageComponent, PageProps, RouteComponent as Route, RouteGenerationOptions, RouteMatch, RouteMeta, RouteParams, Route as RouteType, RouterConfig, RouterContext, RouterProvider, RouterProviderProps, Routes, RuntimeClient, SearchParams, buildSearchString, buildUrl, convertFilePatternToRoutePattern, createHttpRuntimeClient,
|
|
1
|
+
import { ErrorBoundaryProps, FileRouteInfo, HttpRuntimeClient, LayoutProps, Link, LinkProps, LoadingProps, Navigate, NavigationOptions, NavigationState, Outlet, PageComponent, PageProps, Route, RouteComponent, RouteGenerationOptions, RouteMatch, RouteMeta, RouteParams, RouterConfig, RouterContext, RouterProvider, RouterProviderProps, Routes, RuntimeClient, SearchParams, buildSearchString, buildUrl, createHttpRuntimeClient, extractParamNames, findMatchingRoute, getRoutePriority, isDynamicRoute, isPathActive, joinPaths, normalizePathname, parseSearchParams, parseUrl, useNavigation, useParams, usePathname, useRoute, useRouter, useSearchParams, withRouter } from "./runtime-client-BEWMJWMx.js";
|
|
2
|
+
import { FileRouteGenerator, convertFilePatternToRoutePattern, createRouteManifest, defineRariConfig, generateFileRoutes, loadRouteManifest, rari, rariRouter, validateRoutes, watchFileRoutes } from "./server-MY0-nRif.js";
|
|
3
|
+
export { ErrorBoundaryProps, FileRouteGenerator, FileRouteInfo, HttpRuntimeClient, LayoutProps, Link, LinkProps, LoadingProps, Navigate, NavigationOptions, NavigationState, Outlet, PageComponent, PageProps, RouteComponent as Route, RouteGenerationOptions, RouteMatch, RouteMeta, RouteParams, Route as RouteType, RouterConfig, RouterContext, RouterProvider, RouterProviderProps, Routes, RuntimeClient, SearchParams, buildSearchString, buildUrl, convertFilePatternToRoutePattern, createHttpRuntimeClient, createRouteManifest, defineRariConfig, extractParamNames, findMatchingRoute, generateFileRoutes, getRoutePriority, isDynamicRoute, isPathActive, joinPaths, loadRouteManifest, normalizePathname, parseSearchParams, parseUrl, rari, rariRouter, useNavigation, useParams, usePathname, useRoute, useRouter, useSearchParams, validateRoutes, watchFileRoutes, withRouter };
|
package/dist/server.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { HttpRuntimeClient, Link, Navigate, Outlet, RouteComponent, Routes, buildSearchString, buildUrl, createHttpRuntimeClient, extractParamNames, findMatchingRoute, getRoutePriority, isDynamicRoute, isPathActive, joinPaths, normalizePathname, parseSearchParams, parseUrl, router_default, useNavigation, useParams, usePathname, useRoute, useRouter, useSearchParams, withRouter } from "./runtime-client-
|
|
2
|
-
import { FileRouteGenerator, convertFilePatternToRoutePattern,
|
|
1
|
+
import { HttpRuntimeClient, Link, Navigate, Outlet, RouteComponent, Routes, buildSearchString, buildUrl, createHttpRuntimeClient, extractParamNames, findMatchingRoute, getRoutePriority, isDynamicRoute, isPathActive, joinPaths, normalizePathname, parseSearchParams, parseUrl, router_default, useNavigation, useParams, usePathname, useRoute, useRouter, useSearchParams, withRouter } from "./runtime-client-CC4YQweh.js";
|
|
2
|
+
import { FileRouteGenerator, convertFilePatternToRoutePattern, createRouteManifest, defineRariConfig, generateFileRoutes, loadRouteManifest, rari, rariRouter, validateRoutes, watchFileRoutes } from "./server-DeSCwqZZ.js";
|
|
3
3
|
import "./server-build-DaBgiV55.js";
|
|
4
4
|
|
|
5
|
-
export { FileRouteGenerator, HttpRuntimeClient, Link, Navigate, Outlet, RouteComponent as Route, router_default as RouterProvider, Routes, buildSearchString, buildUrl, convertFilePatternToRoutePattern, createHttpRuntimeClient,
|
|
5
|
+
export { FileRouteGenerator, HttpRuntimeClient, Link, Navigate, Outlet, RouteComponent as Route, router_default as RouterProvider, Routes, buildSearchString, buildUrl, convertFilePatternToRoutePattern, createHttpRuntimeClient, createRouteManifest, defineRariConfig, extractParamNames, findMatchingRoute, generateFileRoutes, getRoutePriority, isDynamicRoute, isPathActive, joinPaths, loadRouteManifest, normalizePathname, parseSearchParams, parseUrl, rari, rariRouter, useNavigation, useParams, usePathname, useRoute, useRouter, useSearchParams, validateRoutes, watchFileRoutes, withRouter };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rari",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.8",
|
|
5
5
|
"description": "Runtime Accelerated Rendering Infrastructure (Rari)",
|
|
6
6
|
"author": "Ryan Skinner",
|
|
7
7
|
"license": "MIT",
|
|
@@ -78,15 +78,14 @@
|
|
|
78
78
|
"dependencies": {
|
|
79
79
|
"acorn": "^8.15.0",
|
|
80
80
|
"esbuild": "^0.25.9",
|
|
81
|
-
"picocolors": "^1.1.1"
|
|
82
|
-
"rollup-plugin-esbuild": "^6.2.1"
|
|
81
|
+
"picocolors": "^1.1.1"
|
|
83
82
|
},
|
|
84
83
|
"optionalDependencies": {
|
|
85
|
-
"rari-darwin-arm64": "0.2.
|
|
86
|
-
"rari-darwin-x64": "0.2.
|
|
87
|
-
"rari-linux-arm64": "0.2.
|
|
88
|
-
"rari-linux-x64": "0.2.
|
|
89
|
-
"rari-win32-x64": "0.2.
|
|
84
|
+
"rari-darwin-arm64": "0.2.7",
|
|
85
|
+
"rari-darwin-x64": "0.2.7",
|
|
86
|
+
"rari-linux-arm64": "0.2.7",
|
|
87
|
+
"rari-linux-x64": "0.2.7",
|
|
88
|
+
"rari-win32-x64": "0.2.7"
|
|
90
89
|
},
|
|
91
90
|
"devDependencies": {
|
|
92
91
|
"@types/node": "^24.2.1",
|
package/src/router/index.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
export {
|
|
2
|
+
Link,
|
|
3
|
+
Navigate,
|
|
2
4
|
Outlet,
|
|
3
5
|
RouteComponent,
|
|
4
6
|
RouterContext,
|
|
5
7
|
RouteRenderer,
|
|
6
8
|
default as RouterProvider,
|
|
7
9
|
Routes,
|
|
8
|
-
} from './router'
|
|
9
|
-
|
|
10
|
-
export {
|
|
11
10
|
useNavigation,
|
|
12
11
|
useParams,
|
|
13
12
|
usePathname,
|
|
@@ -17,29 +16,24 @@ export {
|
|
|
17
16
|
withRouter,
|
|
18
17
|
} from './router'
|
|
19
18
|
|
|
20
|
-
export { Link, Navigate } from './router'
|
|
21
|
-
|
|
22
19
|
export type * from './types'
|
|
23
20
|
|
|
24
|
-
export {
|
|
25
|
-
findMatchingRoute,
|
|
26
|
-
isDynamicRoute,
|
|
27
|
-
normalizePathname,
|
|
28
|
-
parseUrl,
|
|
29
|
-
} from './utils'
|
|
30
|
-
|
|
31
21
|
export {
|
|
32
22
|
analyzeFilePath,
|
|
33
23
|
buildSearchString,
|
|
34
24
|
buildUrl,
|
|
35
25
|
extractParamNames,
|
|
36
26
|
filePathToRoutePath,
|
|
27
|
+
findMatchingRoute,
|
|
37
28
|
getParentPath,
|
|
38
29
|
getParentPaths,
|
|
30
|
+
isDynamicRoute,
|
|
39
31
|
isPathActive,
|
|
40
32
|
joinPaths,
|
|
41
33
|
matchRoute,
|
|
34
|
+
normalizePathname,
|
|
42
35
|
parseSearchParams,
|
|
36
|
+
parseUrl,
|
|
43
37
|
routePathsEqual,
|
|
44
38
|
routePathToRegex,
|
|
45
39
|
sortRoutesBySpecificity,
|
package/src/router/router.tsx
CHANGED
|
@@ -47,9 +47,10 @@ export function RouterProvider({
|
|
|
47
47
|
}),
|
|
48
48
|
[config],
|
|
49
49
|
)
|
|
50
|
+
const [currentRoute, setCurrentRoute] = useState<RouteMatch | null>(null)
|
|
50
51
|
|
|
51
|
-
const
|
|
52
|
-
(url: string)
|
|
52
|
+
const updateCurrentRoute = useCallback(
|
|
53
|
+
(url: string) => {
|
|
53
54
|
const { pathname, search, hash, searchParams } = parseUrl(url)
|
|
54
55
|
const normalizedPathname = normalizePathname(pathname)
|
|
55
56
|
|
|
@@ -63,56 +64,17 @@ export function RouterProvider({
|
|
|
63
64
|
hash,
|
|
64
65
|
}
|
|
65
66
|
|
|
66
|
-
enhancedMatch.childMatch = findDeepestChildMatch(
|
|
67
|
-
enhancedMatch,
|
|
68
|
-
normalizedPathname,
|
|
69
|
-
)
|
|
70
|
-
return enhancedMatch
|
|
71
|
-
}
|
|
67
|
+
enhancedMatch.childMatch = findDeepestChildMatch(enhancedMatch, normalizedPathname)
|
|
72
68
|
|
|
73
|
-
|
|
69
|
+
setCurrentRoute(enhancedMatch)
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
setCurrentRoute(null)
|
|
73
|
+
}
|
|
74
74
|
},
|
|
75
75
|
[routes],
|
|
76
76
|
)
|
|
77
77
|
|
|
78
|
-
const [routerState, setRouterState] = useState<{
|
|
79
|
-
currentRoute: RouteMatch | null
|
|
80
|
-
isReady: boolean
|
|
81
|
-
}>(() => {
|
|
82
|
-
if (typeof window === 'undefined') {
|
|
83
|
-
return { currentRoute: null, isReady: false }
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
const url = mergedConfig.useHash
|
|
87
|
-
? window.location.hash.slice(1) || '/'
|
|
88
|
-
: window.location.pathname
|
|
89
|
-
+ window.location.search
|
|
90
|
-
+ window.location.hash
|
|
91
|
-
|
|
92
|
-
let initialRoute
|
|
93
|
-
try {
|
|
94
|
-
initialRoute = resolveRoute(url)
|
|
95
|
-
}
|
|
96
|
-
catch (error) {
|
|
97
|
-
console.error('Error resolving initial route:', error)
|
|
98
|
-
initialRoute = null
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
const isReady = true
|
|
102
|
-
return { currentRoute: initialRoute, isReady }
|
|
103
|
-
})
|
|
104
|
-
|
|
105
|
-
const currentRoute = routerState.currentRoute
|
|
106
|
-
const isReady = routerState.isReady
|
|
107
|
-
|
|
108
|
-
const updateCurrentRoute = useCallback(
|
|
109
|
-
(url: string) => {
|
|
110
|
-
const route = resolveRoute(url)
|
|
111
|
-
setRouterState({ currentRoute: route, isReady: true })
|
|
112
|
-
},
|
|
113
|
-
[resolveRoute],
|
|
114
|
-
)
|
|
115
|
-
|
|
116
78
|
useEffect(() => {
|
|
117
79
|
const handleLocationChange = () => {
|
|
118
80
|
const url = mergedConfig.useHash
|
|
@@ -124,6 +86,8 @@ export function RouterProvider({
|
|
|
124
86
|
updateCurrentRoute(url)
|
|
125
87
|
}
|
|
126
88
|
|
|
89
|
+
handleLocationChange()
|
|
90
|
+
|
|
127
91
|
const handlePopState = () => {
|
|
128
92
|
handleLocationChange()
|
|
129
93
|
}
|
|
@@ -211,8 +175,8 @@ export function RouterProvider({
|
|
|
211
175
|
[currentRoute],
|
|
212
176
|
)
|
|
213
177
|
|
|
214
|
-
const contextValue: IRouterContext = useMemo(
|
|
215
|
-
|
|
178
|
+
const contextValue: IRouterContext = useMemo(
|
|
179
|
+
() => ({
|
|
216
180
|
currentRoute,
|
|
217
181
|
routes,
|
|
218
182
|
navigate,
|
|
@@ -221,19 +185,18 @@ export function RouterProvider({
|
|
|
221
185
|
replace,
|
|
222
186
|
isActive,
|
|
223
187
|
config: mergedConfig,
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
])
|
|
188
|
+
}),
|
|
189
|
+
[
|
|
190
|
+
currentRoute,
|
|
191
|
+
routes,
|
|
192
|
+
navigate,
|
|
193
|
+
back,
|
|
194
|
+
forward,
|
|
195
|
+
replace,
|
|
196
|
+
isActive,
|
|
197
|
+
mergedConfig,
|
|
198
|
+
],
|
|
199
|
+
)
|
|
237
200
|
|
|
238
201
|
return <RouterContext value={contextValue}>{children}</RouterContext>
|
|
239
202
|
}
|
|
@@ -281,7 +244,8 @@ export function useParams() {
|
|
|
281
244
|
}
|
|
282
245
|
|
|
283
246
|
export function useSearchParams() {
|
|
284
|
-
const { currentRoute
|
|
247
|
+
const { currentRoute } = useRouter()
|
|
248
|
+
const { navigate } = useRouter()
|
|
285
249
|
|
|
286
250
|
const searchParams = currentRoute?.searchParams || {}
|
|
287
251
|
|
|
@@ -290,7 +254,7 @@ export function useSearchParams() {
|
|
|
290
254
|
params:
|
|
291
255
|
| Record<string, string | string[]>
|
|
292
256
|
| ((
|
|
293
|
-
prev: Record<string, string | string[]
|
|
257
|
+
prev: Record<string, string | string[]>
|
|
294
258
|
) => Record<string, string | string[]>),
|
|
295
259
|
options: NavigationOptions = DEFAULT_CONFIG,
|
|
296
260
|
) => {
|
|
@@ -393,25 +357,16 @@ export function Outlet() {
|
|
|
393
357
|
return null
|
|
394
358
|
}
|
|
395
359
|
|
|
396
|
-
return
|
|
397
|
-
<ChildComponent
|
|
398
|
-
{...childRoute.params}
|
|
399
|
-
searchParams={childRoute.searchParams}
|
|
400
|
-
/>
|
|
401
|
-
)
|
|
360
|
+
return <ChildComponent {...childRoute.params} searchParams={childRoute.searchParams} />
|
|
402
361
|
}
|
|
403
362
|
|
|
404
|
-
function findChildRouteForCurrentLevel(
|
|
405
|
-
currentRoute: RouteMatch,
|
|
406
|
-
): RouteMatch | null {
|
|
363
|
+
function findChildRouteForCurrentLevel(currentRoute: RouteMatch): RouteMatch | null {
|
|
407
364
|
if (currentRoute.childMatch) {
|
|
408
365
|
return currentRoute.childMatch
|
|
409
366
|
}
|
|
410
367
|
|
|
411
368
|
if (currentRoute.route.children) {
|
|
412
|
-
const indexRoute = currentRoute.route.children.find(
|
|
413
|
-
child => child.isIndex,
|
|
414
|
-
)
|
|
369
|
+
const indexRoute = currentRoute.route.children.find(child => child.isIndex)
|
|
415
370
|
if (indexRoute) {
|
|
416
371
|
return {
|
|
417
372
|
route: indexRoute,
|
|
@@ -430,26 +385,14 @@ function findChildRouteForCurrentLevel(
|
|
|
430
385
|
export function RouteRenderer({ routeMatch }: { routeMatch: RouteMatch }) {
|
|
431
386
|
if (!routeMatch.layouts || routeMatch.layouts.length === 0) {
|
|
432
387
|
const Component = routeMatch.route.component
|
|
433
|
-
return Component
|
|
434
|
-
? (
|
|
435
|
-
<Component
|
|
436
|
-
{...routeMatch.params}
|
|
437
|
-
searchParams={routeMatch.searchParams}
|
|
438
|
-
/>
|
|
439
|
-
)
|
|
440
|
-
: null
|
|
388
|
+
return Component ? <Component {...routeMatch.params} searchParams={routeMatch.searchParams} /> : null
|
|
441
389
|
}
|
|
442
390
|
|
|
443
391
|
let rendered: ReactNode = null
|
|
444
392
|
const Component = routeMatch.route.component
|
|
445
393
|
|
|
446
394
|
if (Component) {
|
|
447
|
-
rendered =
|
|
448
|
-
<Component
|
|
449
|
-
{...routeMatch.params}
|
|
450
|
-
searchParams={routeMatch.searchParams}
|
|
451
|
-
/>
|
|
452
|
-
)
|
|
395
|
+
rendered = <Component {...routeMatch.params} searchParams={routeMatch.searchParams} />
|
|
453
396
|
}
|
|
454
397
|
|
|
455
398
|
for (let i = routeMatch.layouts.length - 1; i >= 0; i--) {
|
|
@@ -457,9 +400,7 @@ export function RouteRenderer({ routeMatch }: { routeMatch: RouteMatch }) {
|
|
|
457
400
|
const LayoutComponent = layout.component
|
|
458
401
|
|
|
459
402
|
if (LayoutComponent) {
|
|
460
|
-
rendered =
|
|
461
|
-
<LayoutComponent route={routeMatch}>{rendered}</LayoutComponent>
|
|
462
|
-
)
|
|
403
|
+
rendered = <LayoutComponent route={routeMatch}>{rendered}</LayoutComponent>
|
|
463
404
|
}
|
|
464
405
|
}
|
|
465
406
|
|
|
@@ -487,10 +428,7 @@ export function Navigate({
|
|
|
487
428
|
export default RouterProvider
|
|
488
429
|
export { RouterContext }
|
|
489
430
|
|
|
490
|
-
function findDeepestChildMatch(
|
|
491
|
-
routeMatch: RouteMatch,
|
|
492
|
-
pathname: string,
|
|
493
|
-
): RouteMatch | null {
|
|
431
|
+
function findDeepestChildMatch(routeMatch: RouteMatch, pathname: string): RouteMatch | null {
|
|
494
432
|
if (!routeMatch.route.children || routeMatch.route.children.length === 0) {
|
|
495
433
|
return null
|
|
496
434
|
}
|
|
@@ -548,12 +486,18 @@ export function Link({
|
|
|
548
486
|
)
|
|
549
487
|
|
|
550
488
|
const isLinkActive = isActive(to, exact)
|
|
551
|
-
const finalClassName = [
|
|
552
|
-
|
|
553
|
-
|
|
489
|
+
const finalClassName = [
|
|
490
|
+
className,
|
|
491
|
+
isLinkActive && activeClassName,
|
|
492
|
+
].filter(Boolean).join(' ')
|
|
554
493
|
|
|
555
494
|
return (
|
|
556
|
-
<a
|
|
495
|
+
<a
|
|
496
|
+
href={to}
|
|
497
|
+
className={finalClassName}
|
|
498
|
+
onClick={handleClick}
|
|
499
|
+
{...props}
|
|
500
|
+
>
|
|
557
501
|
{children}
|
|
558
502
|
</a>
|
|
559
503
|
)
|
package/src/router/types.ts
CHANGED
|
@@ -75,7 +75,6 @@ export interface RouterContext {
|
|
|
75
75
|
replace: (path: string, options?: Omit<NavigationOptions, 'replace'>) => void
|
|
76
76
|
isActive: (path: string, exact?: boolean) => boolean
|
|
77
77
|
config: RouterConfig
|
|
78
|
-
isReady: boolean
|
|
79
78
|
}
|
|
80
79
|
|
|
81
80
|
export interface NavigationState {
|
|
@@ -123,7 +122,7 @@ export type RouteGenerator = (
|
|
|
123
122
|
options: RouteGenerationOptions,
|
|
124
123
|
) => Promise<Route[]>
|
|
125
124
|
|
|
126
|
-
export interface UseRouterReturn extends RouterContext {}
|
|
125
|
+
export interface UseRouterReturn extends RouterContext { }
|
|
127
126
|
|
|
128
127
|
export interface UseNavigationReturn extends NavigationState {
|
|
129
128
|
navigate: RouterContext['navigate']
|
package/src/server.ts
CHANGED
|
@@ -67,4 +67,4 @@ export { createHttpRuntimeClient, HttpRuntimeClient } from './runtime-client'
|
|
|
67
67
|
|
|
68
68
|
export type { RuntimeClient } from './runtime-client'
|
|
69
69
|
|
|
70
|
-
export {
|
|
70
|
+
export { defineRariConfig, rari } from './vite'
|