rari 0.2.6 → 0.2.7
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 +4 -4
- 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-Ph4oyo0B.d.ts → server-MY0-nRif.d.ts} +2 -47
- package/dist/{server-MkYb94pQ.js → server-_LR44Mbg.js} +34 -258
- package/dist/server-build-CLt2Us53.js +3 -0
- package/dist/{server-build-DaBgiV55.js → server-build-DyMLcQhk.js} +6 -3
- package/dist/server.d.ts +3 -3
- package/dist/server.js +4 -4
- package/package.json +7 -12
- package/src/client.ts +10 -3
- 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 +14 -5
- 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-build-Cp6_RdeA.js +0 -3
- package/src/client-dev.ts +0 -59
package/dist/client.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
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, isDynamicRoute, isPathActive, joinPaths, normalizePathname, parseSearchParams, parseUrl, useNavigation, useParams, usePathname, useRoute, useRouter, useSearchParams, withRouter } from "./runtime-client-
|
|
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, isDynamicRoute, isPathActive, joinPaths, normalizePathname, parseSearchParams, parseUrl, useNavigation, useParams, usePathname, useRoute, useRouter, useSearchParams, withRouter } from "./runtime-client-BEWMJWMx.js";
|
|
2
2
|
export { type ErrorBoundaryProps, type FileRouteInfo, HttpRuntimeClient, type LayoutProps, Link, type LinkProps, type LoadingProps, Navigate, type NavigationOptions, type NavigationState, Outlet, type PageComponent, type PageProps, RouteComponent as Route, type RouteGenerationOptions, type RouteMatch, type RouteMeta, type RouteParams, type Route as RouteType, type RouterConfig, type RouterContext, RouterProvider, type RouterProviderProps, Routes, type RuntimeClient, type SearchParams, buildSearchString, buildUrl, createHttpRuntimeClient, extractParamNames, findMatchingRoute, isDynamicRoute, isPathActive, joinPaths, normalizePathname, parseSearchParams, parseUrl, useNavigation, useParams, usePathname, useRoute, useRouter, useSearchParams, withRouter };
|
package/dist/client.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { HttpRuntimeClient, Link, Navigate, Outlet, RouteComponent, Routes, buildSearchString, buildUrl, createHttpRuntimeClient, extractParamNames, findMatchingRoute, isDynamicRoute, isPathActive, joinPaths, normalizePathname, parseSearchParams, parseUrl, router_default, useNavigation, useParams, usePathname, useRoute, useRouter, useSearchParams, withRouter } from "./runtime-client-
|
|
1
|
+
import { HttpRuntimeClient, Link, Navigate, Outlet, RouteComponent, Routes, buildSearchString, buildUrl, createHttpRuntimeClient, extractParamNames, findMatchingRoute, isDynamicRoute, isPathActive, joinPaths, normalizePathname, parseSearchParams, parseUrl, router_default, useNavigation, useParams, usePathname, useRoute, useRouter, useSearchParams, withRouter } from "./runtime-client-CC4YQweh.js";
|
|
2
2
|
|
|
3
3
|
export { HttpRuntimeClient, Link, Navigate, Outlet, RouteComponent as Route, router_default as RouterProvider, Routes, buildSearchString, buildUrl, createHttpRuntimeClient, extractParamNames, findMatchingRoute, isDynamicRoute, isPathActive, joinPaths, normalizePathname, parseSearchParams, parseUrl, useNavigation, useParams, usePathname, useRoute, useRouter, useSearchParams, withRouter };
|
package/dist/index.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/index.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,
|
|
3
|
-
import "./server-build-
|
|
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-_LR44Mbg.js";
|
|
3
|
+
import "./server-build-DyMLcQhk.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 };
|
|
@@ -72,7 +72,6 @@ interface RouterContext {
|
|
|
72
72
|
replace: (path: string, options?: Omit<NavigationOptions, 'replace'>) => void;
|
|
73
73
|
isActive: (path: string, exact?: boolean) => boolean;
|
|
74
74
|
config: RouterConfig;
|
|
75
|
-
isReady: boolean;
|
|
76
75
|
}
|
|
77
76
|
interface NavigationState {
|
|
78
77
|
isNavigating: boolean;
|
|
@@ -228,7 +228,8 @@ function RouterProvider({ config = DEFAULT_CONFIG, routes = DEFAULT_ROUTES, chil
|
|
|
228
228
|
caseSensitive: false,
|
|
229
229
|
...config
|
|
230
230
|
}), [config]);
|
|
231
|
-
const
|
|
231
|
+
const [currentRoute, setCurrentRoute] = useState(null);
|
|
232
|
+
const updateCurrentRoute = useCallback((url) => {
|
|
232
233
|
const { pathname, search, hash, searchParams } = parseUrl(url);
|
|
233
234
|
const normalizedPathname = normalizePathname(pathname);
|
|
234
235
|
const match = findMatchingRoute(normalizedPathname, routes);
|
|
@@ -240,43 +241,15 @@ function RouterProvider({ config = DEFAULT_CONFIG, routes = DEFAULT_ROUTES, chil
|
|
|
240
241
|
hash
|
|
241
242
|
};
|
|
242
243
|
enhancedMatch.childMatch = findDeepestChildMatch(enhancedMatch, normalizedPathname);
|
|
243
|
-
|
|
244
|
-
}
|
|
245
|
-
return null;
|
|
244
|
+
setCurrentRoute(enhancedMatch);
|
|
245
|
+
} else setCurrentRoute(null);
|
|
246
246
|
}, [routes]);
|
|
247
|
-
const [routerState, setRouterState] = useState(() => {
|
|
248
|
-
if (typeof window === "undefined") return {
|
|
249
|
-
currentRoute: null,
|
|
250
|
-
isReady: false
|
|
251
|
-
};
|
|
252
|
-
const url = mergedConfig.useHash ? window.location.hash.slice(1) || "/" : window.location.pathname + window.location.search + window.location.hash;
|
|
253
|
-
let initialRoute;
|
|
254
|
-
try {
|
|
255
|
-
initialRoute = resolveRoute(url);
|
|
256
|
-
} catch (error) {
|
|
257
|
-
console.error("Error resolving initial route:", error);
|
|
258
|
-
initialRoute = null;
|
|
259
|
-
}
|
|
260
|
-
const isReady$1 = true;
|
|
261
|
-
return {
|
|
262
|
-
currentRoute: initialRoute,
|
|
263
|
-
isReady: isReady$1
|
|
264
|
-
};
|
|
265
|
-
});
|
|
266
|
-
const currentRoute = routerState.currentRoute;
|
|
267
|
-
const isReady = routerState.isReady;
|
|
268
|
-
const updateCurrentRoute = useCallback((url) => {
|
|
269
|
-
const route = resolveRoute(url);
|
|
270
|
-
setRouterState({
|
|
271
|
-
currentRoute: route,
|
|
272
|
-
isReady: true
|
|
273
|
-
});
|
|
274
|
-
}, [resolveRoute]);
|
|
275
247
|
useEffect(() => {
|
|
276
248
|
const handleLocationChange = () => {
|
|
277
249
|
const url = mergedConfig.useHash ? window.location.hash.slice(1) || "/" : window.location.pathname + window.location.search + window.location.hash;
|
|
278
250
|
updateCurrentRoute(url);
|
|
279
251
|
};
|
|
252
|
+
handleLocationChange();
|
|
280
253
|
const handlePopState = () => {
|
|
281
254
|
handleLocationChange();
|
|
282
255
|
};
|
|
@@ -326,19 +299,16 @@ function RouterProvider({ config = DEFAULT_CONFIG, routes = DEFAULT_ROUTES, chil
|
|
|
326
299
|
if (!currentRoute) return false;
|
|
327
300
|
return isPathActive(currentRoute.pathname, path, exact);
|
|
328
301
|
}, [currentRoute]);
|
|
329
|
-
const contextValue = useMemo(() => {
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
isReady
|
|
340
|
-
};
|
|
341
|
-
}, [
|
|
302
|
+
const contextValue = useMemo(() => ({
|
|
303
|
+
currentRoute,
|
|
304
|
+
routes,
|
|
305
|
+
navigate,
|
|
306
|
+
back,
|
|
307
|
+
forward,
|
|
308
|
+
replace,
|
|
309
|
+
isActive,
|
|
310
|
+
config: mergedConfig
|
|
311
|
+
}), [
|
|
342
312
|
currentRoute,
|
|
343
313
|
routes,
|
|
344
314
|
navigate,
|
|
@@ -346,8 +316,7 @@ function RouterProvider({ config = DEFAULT_CONFIG, routes = DEFAULT_ROUTES, chil
|
|
|
346
316
|
forward,
|
|
347
317
|
replace,
|
|
348
318
|
isActive,
|
|
349
|
-
mergedConfig
|
|
350
|
-
isReady
|
|
319
|
+
mergedConfig
|
|
351
320
|
]);
|
|
352
321
|
return /* @__PURE__ */ jsx(RouterContext, {
|
|
353
322
|
value: contextValue,
|
|
@@ -387,7 +356,8 @@ function useParams() {
|
|
|
387
356
|
return currentRoute?.params || {};
|
|
388
357
|
}
|
|
389
358
|
function useSearchParams() {
|
|
390
|
-
const { currentRoute
|
|
359
|
+
const { currentRoute } = useRouter();
|
|
360
|
+
const { navigate } = useRouter();
|
|
391
361
|
const searchParams = currentRoute?.searchParams || {};
|
|
392
362
|
const setSearchParams = useCallback((params, options = DEFAULT_CONFIG) => {
|
|
393
363
|
const newParams = typeof params === "function" ? params(searchParams) : params;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Route, RouteGenerationOptions } from "./runtime-client-
|
|
1
|
+
import { Route, RouteGenerationOptions } from "./runtime-client-BEWMJWMx.js";
|
|
2
2
|
import { Plugin, UserConfig } from "rolldown-vite";
|
|
3
3
|
|
|
4
4
|
//#region src/router/file-routes.d.ts
|
|
@@ -62,53 +62,8 @@ interface RariOptions {
|
|
|
62
62
|
serverHandler?: boolean;
|
|
63
63
|
}
|
|
64
64
|
declare function rari(options?: RariOptions): Plugin[];
|
|
65
|
-
declare function createReactDOMOptimization(): {
|
|
66
|
-
build: {
|
|
67
|
-
rollupOptions: {
|
|
68
|
-
output: {
|
|
69
|
-
manualChunks: (id: string) => "react-dom" | "react" | "scheduler" | "vendor" | undefined;
|
|
70
|
-
};
|
|
71
|
-
treeshake: {
|
|
72
|
-
moduleSideEffects: (id: string) => boolean;
|
|
73
|
-
unknownGlobalSideEffects: boolean;
|
|
74
|
-
};
|
|
75
|
-
};
|
|
76
|
-
minify: string;
|
|
77
|
-
target: string[];
|
|
78
|
-
cssMinify: string;
|
|
79
|
-
sourcemap: boolean;
|
|
80
|
-
terserOptions: {
|
|
81
|
-
compress: {
|
|
82
|
-
drop_console: boolean;
|
|
83
|
-
drop_debugger: boolean;
|
|
84
|
-
pure_funcs: string[];
|
|
85
|
-
passes: number;
|
|
86
|
-
unsafe: boolean;
|
|
87
|
-
unsafe_comps: boolean;
|
|
88
|
-
unsafe_Function: boolean;
|
|
89
|
-
unsafe_math: boolean;
|
|
90
|
-
unsafe_symbols: boolean;
|
|
91
|
-
unsafe_methods: boolean;
|
|
92
|
-
unsafe_proto: boolean;
|
|
93
|
-
unsafe_regexp: boolean;
|
|
94
|
-
unsafe_undefined: boolean;
|
|
95
|
-
dead_code: boolean;
|
|
96
|
-
side_effects: boolean;
|
|
97
|
-
};
|
|
98
|
-
mangle: {
|
|
99
|
-
safari10: boolean;
|
|
100
|
-
properties: {
|
|
101
|
-
regex: RegExp;
|
|
102
|
-
};
|
|
103
|
-
};
|
|
104
|
-
format: {
|
|
105
|
-
comments: boolean;
|
|
106
|
-
};
|
|
107
|
-
};
|
|
108
|
-
};
|
|
109
|
-
};
|
|
110
65
|
declare function defineRariConfig(config: UserConfig & {
|
|
111
66
|
plugins?: Plugin[];
|
|
112
67
|
}): UserConfig;
|
|
113
68
|
//#endregion
|
|
114
|
-
export { FileRouteGenerator, convertFilePatternToRoutePattern,
|
|
69
|
+
export { FileRouteGenerator, convertFilePatternToRoutePattern, createRouteManifest, defineRariConfig, generateFileRoutes, loadRouteManifest, rari, rariRouter, validateRoutes, watchFileRoutes };
|