@vlian/router 0.1.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 +1134 -0
- package/dist/adapters/create-app-router.cjs +1 -0
- package/dist/adapters/create-app-router.d.ts +4 -0
- package/dist/adapters/create-app-router.js +1 -0
- package/dist/adapters/index.cjs +1 -0
- package/dist/adapters/index.d.ts +1 -0
- package/dist/adapters/index.js +1 -0
- package/dist/core/guards/route-shell.cjs +1 -0
- package/dist/core/guards/route-shell.d.ts +13 -0
- package/dist/core/guards/route-shell.js +1 -0
- package/dist/core/index.cjs +1 -0
- package/dist/core/index.d.ts +3 -0
- package/dist/core/index.js +1 -0
- package/dist/core/normalize/normalize-routes.cjs +1 -0
- package/dist/core/normalize/normalize-routes.d.ts +8 -0
- package/dist/core/normalize/normalize-routes.js +1 -0
- package/dist/core/normalize/route-id.cjs +1 -0
- package/dist/core/normalize/route-id.d.ts +2 -0
- package/dist/core/normalize/route-id.js +1 -0
- package/dist/core/patcher/create-navigation-patcher.cjs +1 -0
- package/dist/core/patcher/create-navigation-patcher.d.ts +12 -0
- package/dist/core/patcher/create-navigation-patcher.js +1 -0
- package/dist/core/runtime/route-registry.cjs +1 -0
- package/dist/core/runtime/route-registry.d.ts +9 -0
- package/dist/core/runtime/route-registry.js +1 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +1 -0
- package/dist/runtime/AppRouterProvider.cjs +1 -0
- package/dist/runtime/AppRouterProvider.d.ts +6 -0
- package/dist/runtime/AppRouterProvider.js +1 -0
- package/dist/runtime/index.cjs +1 -0
- package/dist/runtime/index.d.ts +2 -0
- package/dist/runtime/index.js +1 -0
- package/dist/types/index.cjs +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +1 -0
- package/dist/types/route.cjs +1 -0
- package/dist/types/route.d.ts +116 -0
- package/dist/types/route.js +1 -0
- package/package.json +90 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});function _export(target,all){for(var name in all)Object.defineProperty(target,name,{enumerable:true,get:Object.getOwnPropertyDescriptor(all,name).get})}_export(exports,{get createAppRouter(){return createAppRouter},get defineRoutes(){return defineRoutes}});const _reactrouterdom=require("react-router-dom");const _normalizeroutes=require("../core/normalize/normalize-routes");const _createnavigationpatcher=require("../core/patcher/create-navigation-patcher");const _routeregistry=require("../core/runtime/route-registry");const defineRoutes=routes=>routes;const createAppRouter=options=>{const normalizedRoutes=(0,_normalizeroutes.normalizeRoutes)(options.routes,{authorization:options.authorization,source:"static"});const routeRegistry=new _routeregistry.RouteRegistry(normalizedRoutes);let router;const sharedRouterOptions={basename:options.basename,future:options.future,hydrationData:options.hydrationData,dataStrategy:options.dataStrategy,getContext:options.getContext,patchRoutesOnNavigation:options.dynamic?(0,_createnavigationpatcher.createNavigationPatcher)({dynamic:options.dynamic,authorization:options.authorization,registry:routeRegistry,getRouter:()=>router,onError:options.onError}):undefined};switch(options.mode){case"hash":router=(0,_reactrouterdom.createHashRouter)(normalizedRoutes,{...sharedRouterOptions,window:options.window});return router;case"memory":router=(0,_reactrouterdom.createMemoryRouter)(normalizedRoutes,{...sharedRouterOptions,initialEntries:options.initialEntries,initialIndex:options.initialIndex});return router;case"browser":default:router=(0,_reactrouterdom.createBrowserRouter)(normalizedRoutes,{...sharedRouterOptions,window:options.window});return router}};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type DataRouter } from "react-router-dom";
|
|
2
|
+
import type { DefaultRouteMeta, RouteExtraFields, RouterPluginOptions, StaticRouteConfig } from "../types";
|
|
3
|
+
export declare const defineRoutes: <Meta = DefaultRouteMeta, Extra extends RouteExtraFields = RouteExtraFields>(routes: StaticRouteConfig<Meta, Extra>[]) => StaticRouteConfig<Meta, Extra>[];
|
|
4
|
+
export declare const createAppRouter: <Meta = DefaultRouteMeta, Extra extends RouteExtraFields = RouteExtraFields>(options: RouterPluginOptions<Meta, Extra>) => DataRouter;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createBrowserRouter,createHashRouter,createMemoryRouter}from"react-router-dom";import{normalizeRoutes}from"../core/normalize/normalize-routes";import{createNavigationPatcher}from"../core/patcher/create-navigation-patcher";import{RouteRegistry}from"../core/runtime/route-registry";export const defineRoutes=routes=>routes;export const createAppRouter=options=>{const normalizedRoutes=normalizeRoutes(options.routes,{authorization:options.authorization,source:"static"});const routeRegistry=new RouteRegistry(normalizedRoutes);let router;const sharedRouterOptions={basename:options.basename,future:options.future,hydrationData:options.hydrationData,dataStrategy:options.dataStrategy,getContext:options.getContext,patchRoutesOnNavigation:options.dynamic?createNavigationPatcher({dynamic:options.dynamic,authorization:options.authorization,registry:routeRegistry,getRouter:()=>router,onError:options.onError}):undefined};switch(options.mode){case"hash":router=createHashRouter(normalizedRoutes,{...sharedRouterOptions,window:options.window});return router;case"memory":router=createMemoryRouter(normalizedRoutes,{...sharedRouterOptions,initialEntries:options.initialEntries,initialIndex:options.initialIndex});return router;case"browser":default:router=createBrowserRouter(normalizedRoutes,{...sharedRouterOptions,window:options.window});return router}};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});function _export(target,all){for(var name in all)Object.defineProperty(target,name,{enumerable:true,get:Object.getOwnPropertyDescriptor(all,name).get})}_export(exports,{get createAppRouter(){return _createapprouter.createAppRouter},get defineRoutes(){return _createapprouter.defineRoutes}});const _createapprouter=require("./create-app-router");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createAppRouter, defineRoutes } from "./create-app-router";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{createAppRouter,defineRoutes}from"./create-app-router";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});Object.defineProperty(exports,"createRouteShellComponent",{enumerable:true,get:function(){return createRouteShellComponent}});const _react=require("react");const _reactrouterdom=require("react-router-dom");const resolveLayoutDescriptor=layout=>typeof layout==="function"?{component:layout}:layout;const renderAuthorizationFallback=(route,auth,authorization)=>{const{renderDenied}=authorization;if(!renderDenied){return null}if(typeof renderDenied==="function"){return(0,_react.createElement)(renderDenied,{route,auth})}return renderDenied};const resolveUnauthorizedRedirect=(auth,authorization)=>{if(auth&&typeof auth==="object"&&typeof auth.redirectTo==="string"){return auth.redirectTo}if(typeof authorization?.redirectTo==="string"){return authorization.redirectTo}return null};const renderRouteContent=(route,config)=>{if(config.redirect){return React.createElement(_reactrouterdom.Navigate,{replace:config.redirect.replace??true,state:config.redirect.state,to:config.redirect.to})}if(config.component){return(0,_react.createElement)(config.component)}if(config.element!==undefined){return config.element}if(route.children?.length){return React.createElement(_reactrouterdom.Outlet,null)}return null};const createRouteShellComponent=config=>{const RouteShell=()=>{if(config.auth&&config.authorization){const isAllowed=config.authorization.resolve({route:config.route,auth:config.auth});if(!isAllowed){const redirectTo=resolveUnauthorizedRedirect(config.auth,config.authorization);if(redirectTo){return React.createElement(_reactrouterdom.Navigate,{replace:true,to:redirectTo})}return renderAuthorizationFallback(config.route,config.auth,config.authorization)}}const content=renderRouteContent(config.route,config);if(!config.layout){return content}const layoutDescriptor=resolveLayoutDescriptor(config.layout);return(0,_react.createElement)(layoutDescriptor.component,{...layoutDescriptor.props,route:config.route},content)};RouteShell.displayName=`RouteShell(${config.route.id})`;return RouteShell};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
import type { AppRouteObject, DefaultRouteMeta, RedirectRouteConfig, RouteAuthConfig, RouteAuthorizationOptions, RouteComponent, RouteExtraFields, RouteLayout } from "../../types";
|
|
3
|
+
type RouteShellConfig<Meta = DefaultRouteMeta, Extra extends RouteExtraFields = RouteExtraFields> = {
|
|
4
|
+
route: AppRouteObject<Meta, Extra>;
|
|
5
|
+
redirect?: RedirectRouteConfig;
|
|
6
|
+
auth?: RouteAuthConfig;
|
|
7
|
+
authorization?: RouteAuthorizationOptions<Meta, Extra>;
|
|
8
|
+
layout?: RouteLayout<Meta, Extra>;
|
|
9
|
+
component?: RouteComponent;
|
|
10
|
+
element?: ReactNode;
|
|
11
|
+
};
|
|
12
|
+
export declare const createRouteShellComponent: <Meta = DefaultRouteMeta, Extra extends RouteExtraFields = RouteExtraFields>(config: RouteShellConfig<Meta, Extra>) => RouteComponent;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createElement}from"react";import{Navigate,Outlet}from"react-router-dom";const resolveLayoutDescriptor=layout=>typeof layout==="function"?{component:layout}:layout;const renderAuthorizationFallback=(route,auth,authorization)=>{const{renderDenied}=authorization;if(!renderDenied){return null}if(typeof renderDenied==="function"){return createElement(renderDenied,{route,auth})}return renderDenied};const resolveUnauthorizedRedirect=(auth,authorization)=>{if(auth&&typeof auth==="object"&&typeof auth.redirectTo==="string"){return auth.redirectTo}if(typeof authorization?.redirectTo==="string"){return authorization.redirectTo}return null};const renderRouteContent=(route,config)=>{if(config.redirect){return React.createElement(Navigate,{replace:config.redirect.replace??true,state:config.redirect.state,to:config.redirect.to})}if(config.component){return createElement(config.component)}if(config.element!==undefined){return config.element}if(route.children?.length){return React.createElement(Outlet,null)}return null};export const createRouteShellComponent=config=>{const RouteShell=()=>{if(config.auth&&config.authorization){const isAllowed=config.authorization.resolve({route:config.route,auth:config.auth});if(!isAllowed){const redirectTo=resolveUnauthorizedRedirect(config.auth,config.authorization);if(redirectTo){return React.createElement(Navigate,{replace:true,to:redirectTo})}return renderAuthorizationFallback(config.route,config.auth,config.authorization)}}const content=renderRouteContent(config.route,config);if(!config.layout){return content}const layoutDescriptor=resolveLayoutDescriptor(config.layout);return createElement(layoutDescriptor.component,{...layoutDescriptor.props,route:config.route},content)};RouteShell.displayName=`RouteShell(${config.route.id})`;return RouteShell};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});function _export(target,all){for(var name in all)Object.defineProperty(target,name,{enumerable:true,get:Object.getOwnPropertyDescriptor(all,name).get})}_export(exports,{get RouteRegistry(){return _routeregistry.RouteRegistry},get createNavigationPatcher(){return _createnavigationpatcher.createNavigationPatcher},get normalizeRoutes(){return _normalizeroutes.normalizeRoutes}});const _normalizeroutes=require("./normalize/normalize-routes");const _createnavigationpatcher=require("./patcher/create-navigation-patcher");const _routeregistry=require("./runtime/route-registry");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{normalizeRoutes}from"./normalize/normalize-routes";export{createNavigationPatcher}from"./patcher/create-navigation-patcher";export{RouteRegistry}from"./runtime/route-registry";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});Object.defineProperty(exports,"normalizeRoutes",{enumerable:true,get:function(){return normalizeRoutes}});const _routeshell=require("../guards/route-shell");const _routeid=require("./route-id");const RESERVED_ROUTE_KEYS=new Set(["id","path","index","caseSensitive","component","Component","element","lazy","loader","action","shouldRevalidate","errorElement","ErrorBoundary","hydrateFallbackElement","HydrateFallback","handle","meta","layout","auth","redirect","children"]);const isRecord=value=>typeof value==="object"&&value!==null&&!Array.isArray(value);const mergeHandle=(handle,meta,auth,source)=>{const baseHandle=isRecord(handle)?handle:{};return{...baseHandle,meta,auth,source}};const pickExtraFields=route=>{const extraEntries=Object.entries(route).filter(([key])=>!RESERVED_ROUTE_KEYS.has(key));return Object.fromEntries(extraEntries)};const normalizeRedirect=redirect=>{if(!redirect){return undefined}if(typeof redirect==="string"){return{to:redirect,replace:true}}return{replace:true,...redirect}};const needsRouteShell=(route,normalizedRedirect,authorization)=>Boolean(normalizedRedirect||route.layout||route.auth&&authorization||route.component||route.Component&&(route.layout||route.auth)||route.element!==undefined&&(route.layout||route.auth));const wrapLazyRoute=(lazy,routeRef,route,normalizedRedirect,authorization)=>{return async()=>{const resolved=await lazy();const component=resolved.Component??route.Component??route.component;const element=resolved.element??route.element;if(!needsRouteShell({...route,Component:component,element},normalizedRedirect,authorization)){return resolved}return{...resolved,Component:(0,_routeshell.createRouteShellComponent)({route:routeRef,redirect:normalizedRedirect,auth:route.auth,authorization,layout:route.layout,component,element}),element:undefined}}};const normalizeRoute=(route,index,parentId,options)=>{const routeId=(0,_routeid.createRouteId)(route,parentId,index);const normalizedRedirect=normalizeRedirect(route.redirect);const handle=mergeHandle(route.handle,route.meta,route.auth,options.source);const normalizedRoute={id:routeId,path:route.path,index:route.index,caseSensitive:route.caseSensitive,loader:route.loader,action:route.action,shouldRevalidate:route.shouldRevalidate,errorElement:route.errorElement,ErrorBoundary:route.ErrorBoundary,hydrateFallbackElement:route.hydrateFallbackElement,HydrateFallback:route.HydrateFallback,handle,__extra:pickExtraFields(route)};if(route.children?.length){normalizedRoute.children=route.children.map((child,childIndex)=>normalizeRoute(child,childIndex,routeId,options))}if(route.lazy){normalizedRoute.lazy=wrapLazyRoute(route.lazy,normalizedRoute,route,normalizedRedirect,options.authorization);return normalizedRoute}const component=route.Component??route.component;const element=route.element;if(needsRouteShell(route,normalizedRedirect,options.authorization)){normalizedRoute.Component=(0,_routeshell.createRouteShellComponent)({route:normalizedRoute,redirect:normalizedRedirect,auth:route.auth,authorization:options.authorization,layout:route.layout,component,element});return normalizedRoute}if(component){normalizedRoute.Component=component}if(element!==undefined){normalizedRoute.element=element}return normalizedRoute};const normalizeRoutes=(routes,options)=>routes.map((route,index)=>normalizeRoute(route,index,options.parentId??null,options));
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { AppRouteObject, DefaultRouteMeta, RouteAuthorizationOptions, RouteExtraFields, StaticRouteConfig } from "../../types";
|
|
2
|
+
interface NormalizeRoutesOptions<Meta = DefaultRouteMeta, Extra extends RouteExtraFields = RouteExtraFields> {
|
|
3
|
+
authorization?: RouteAuthorizationOptions<Meta, Extra>;
|
|
4
|
+
parentId?: string | null;
|
|
5
|
+
source: "static" | "dynamic";
|
|
6
|
+
}
|
|
7
|
+
export declare const normalizeRoutes: <Meta = DefaultRouteMeta, Extra extends RouteExtraFields = RouteExtraFields>(routes: StaticRouteConfig<Meta, Extra>[], options: NormalizeRoutesOptions<Meta, Extra>) => AppRouteObject<Meta, Extra>[];
|
|
8
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createRouteShellComponent}from"../guards/route-shell";import{createRouteId}from"./route-id";const RESERVED_ROUTE_KEYS=new Set(["id","path","index","caseSensitive","component","Component","element","lazy","loader","action","shouldRevalidate","errorElement","ErrorBoundary","hydrateFallbackElement","HydrateFallback","handle","meta","layout","auth","redirect","children"]);const isRecord=value=>typeof value==="object"&&value!==null&&!Array.isArray(value);const mergeHandle=(handle,meta,auth,source)=>{const baseHandle=isRecord(handle)?handle:{};return{...baseHandle,meta,auth,source}};const pickExtraFields=route=>{const extraEntries=Object.entries(route).filter(([key])=>!RESERVED_ROUTE_KEYS.has(key));return Object.fromEntries(extraEntries)};const normalizeRedirect=redirect=>{if(!redirect){return undefined}if(typeof redirect==="string"){return{to:redirect,replace:true}}return{replace:true,...redirect}};const needsRouteShell=(route,normalizedRedirect,authorization)=>Boolean(normalizedRedirect||route.layout||route.auth&&authorization||route.component||route.Component&&(route.layout||route.auth)||route.element!==undefined&&(route.layout||route.auth));const wrapLazyRoute=(lazy,routeRef,route,normalizedRedirect,authorization)=>{return async()=>{const resolved=await lazy();const component=resolved.Component??route.Component??route.component;const element=resolved.element??route.element;if(!needsRouteShell({...route,Component:component,element},normalizedRedirect,authorization)){return resolved}return{...resolved,Component:createRouteShellComponent({route:routeRef,redirect:normalizedRedirect,auth:route.auth,authorization,layout:route.layout,component,element}),element:undefined}}};const normalizeRoute=(route,index,parentId,options)=>{const routeId=createRouteId(route,parentId,index);const normalizedRedirect=normalizeRedirect(route.redirect);const handle=mergeHandle(route.handle,route.meta,route.auth,options.source);const normalizedRoute={id:routeId,path:route.path,index:route.index,caseSensitive:route.caseSensitive,loader:route.loader,action:route.action,shouldRevalidate:route.shouldRevalidate,errorElement:route.errorElement,ErrorBoundary:route.ErrorBoundary,hydrateFallbackElement:route.hydrateFallbackElement,HydrateFallback:route.HydrateFallback,handle,__extra:pickExtraFields(route)};if(route.children?.length){normalizedRoute.children=route.children.map((child,childIndex)=>normalizeRoute(child,childIndex,routeId,options))}if(route.lazy){normalizedRoute.lazy=wrapLazyRoute(route.lazy,normalizedRoute,route,normalizedRedirect,options.authorization);return normalizedRoute}const component=route.Component??route.component;const element=route.element;if(needsRouteShell(route,normalizedRedirect,options.authorization)){normalizedRoute.Component=createRouteShellComponent({route:normalizedRoute,redirect:normalizedRedirect,auth:route.auth,authorization:options.authorization,layout:route.layout,component,element});return normalizedRoute}if(component){normalizedRoute.Component=component}if(element!==undefined){normalizedRoute.element=element}return normalizedRoute};export const normalizeRoutes=(routes,options)=>routes.map((route,index)=>normalizeRoute(route,index,options.parentId??null,options));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});Object.defineProperty(exports,"createRouteId",{enumerable:true,get:function(){return createRouteId}});const normalizeSegment=segment=>segment.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"route";const normalizePathToId=(path,index)=>{if(index){return"index"}if(!path||path==="/"){return"root"}return path.split("/").filter(Boolean).map(normalizeSegment).join(".")};const createRouteId=(route,parentId,position)=>{const explicitId=typeof route.id==="string"?route.id.trim():"";if(explicitId){return explicitId}const selfId=normalizePathToId(route.path,route.index);return parentId?`${parentId}.${selfId}.${position}`:`${selfId}.${position}`};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import type { DefaultRouteMeta, RouteExtraFields, StaticRouteConfig } from "../../types";
|
|
2
|
+
export declare const createRouteId: <Meta = DefaultRouteMeta, Extra extends RouteExtraFields = RouteExtraFields>(route: StaticRouteConfig<Meta, Extra>, parentId: string | null, position: number) => string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const normalizeSegment=segment=>segment.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"route";const normalizePathToId=(path,index)=>{if(index){return"index"}if(!path||path==="/"){return"root"}return path.split("/").filter(Boolean).map(normalizeSegment).join(".")};export const createRouteId=(route,parentId,position)=>{const explicitId=typeof route.id==="string"?route.id.trim():"";if(explicitId){return explicitId}const selfId=normalizePathToId(route.path,route.index);return parentId?`${parentId}.${selfId}.${position}`:`${selfId}.${position}`};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});Object.defineProperty(exports,"createNavigationPatcher",{enumerable:true,get:function(){return createNavigationPatcher}});const _normalizeroutes=require("../normalize/normalize-routes");const isDynamicPatch=value=>typeof value==="object"&&value!==null&&Array.isArray(value.routes);const toDynamicPatches=(result,defaultParentId)=>{if(!result){return[]}if(Array.isArray(result)){if(result.every(item=>isDynamicPatch(item))){return result}return[{parentId:defaultParentId,routes:result}]}if(isDynamicPatch(result)){return[result]}return[]};const createNavigationPatcher=options=>{const resolvedCacheKeys=new Set;const inFlightLoads=new Map;return async({matches,patch,path,signal})=>{const router=options.getRouter();const context={path,signal,matches:matches,router,knownRouteIds:options.registry.snapshot()};const navigationCacheKey=options.dynamic.getNavigationCacheKey?.(context)??path;if(navigationCacheKey&&resolvedCacheKeys.has(navigationCacheKey)){return}const inFlightKey=navigationCacheKey===false?`pending:${path}:${Date.now()}`:navigationCacheKey;const currentInFlight=inFlightLoads.get(inFlightKey);if(currentInFlight){await currentInFlight;return}const loadingTask=(async()=>{try{const loadResult=await options.dynamic.loader(context);const patches=toDynamicPatches(loadResult,options.dynamic.defaultParentId);for(const patchEntry of patches){const resolvedParentId=patchEntry.parentId??options.dynamic.defaultParentId??null;const normalizedRoutes=(0,_normalizeroutes.normalizeRoutes)(patchEntry.routes,{authorization:options.authorization,parentId:resolvedParentId,source:"dynamic"});const unregisteredRoutes=options.registry.filterUnregistered(normalizedRoutes);if(!unregisteredRoutes.length){continue}patch(resolvedParentId,unregisteredRoutes);options.registry.register(unregisteredRoutes);if(patchEntry.cacheKey){resolvedCacheKeys.add(patchEntry.cacheKey)}}if(navigationCacheKey){resolvedCacheKeys.add(navigationCacheKey)}}catch(error){const errorContext={...context,error,phase:"dynamic-route-loading"};await options.onError?.(errorContext);if(options.dynamic.errorMode==="throw"){throw error}}finally{inFlightLoads.delete(inFlightKey)}})();inFlightLoads.set(inFlightKey,loadingTask);await loadingTask}};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { DataRouter, PatchRoutesOnNavigationFunction } from "react-router-dom";
|
|
2
|
+
import { RouteRegistry } from "../runtime/route-registry";
|
|
3
|
+
import type { DefaultRouteMeta, DynamicRoutingOptions, RouteAuthorizationOptions, RouteExtraFields, RouterErrorHandler } from "../../types";
|
|
4
|
+
interface CreateNavigationPatcherOptions<Meta = DefaultRouteMeta, Extra extends RouteExtraFields = RouteExtraFields> {
|
|
5
|
+
dynamic: DynamicRoutingOptions<Meta, Extra>;
|
|
6
|
+
authorization?: RouteAuthorizationOptions<Meta, Extra>;
|
|
7
|
+
registry: RouteRegistry<Meta, Extra>;
|
|
8
|
+
getRouter: () => DataRouter;
|
|
9
|
+
onError?: RouterErrorHandler<Meta, Extra>;
|
|
10
|
+
}
|
|
11
|
+
export declare const createNavigationPatcher: <Meta = DefaultRouteMeta, Extra extends RouteExtraFields = RouteExtraFields>(options: CreateNavigationPatcherOptions<Meta, Extra>) => PatchRoutesOnNavigationFunction;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{normalizeRoutes}from"../normalize/normalize-routes";const isDynamicPatch=value=>typeof value==="object"&&value!==null&&Array.isArray(value.routes);const toDynamicPatches=(result,defaultParentId)=>{if(!result){return[]}if(Array.isArray(result)){if(result.every(item=>isDynamicPatch(item))){return result}return[{parentId:defaultParentId,routes:result}]}if(isDynamicPatch(result)){return[result]}return[]};export const createNavigationPatcher=options=>{const resolvedCacheKeys=new Set;const inFlightLoads=new Map;return async({matches,patch,path,signal})=>{const router=options.getRouter();const context={path,signal,matches:matches,router,knownRouteIds:options.registry.snapshot()};const navigationCacheKey=options.dynamic.getNavigationCacheKey?.(context)??path;if(navigationCacheKey&&resolvedCacheKeys.has(navigationCacheKey)){return}const inFlightKey=navigationCacheKey===false?`pending:${path}:${Date.now()}`:navigationCacheKey;const currentInFlight=inFlightLoads.get(inFlightKey);if(currentInFlight){await currentInFlight;return}const loadingTask=(async()=>{try{const loadResult=await options.dynamic.loader(context);const patches=toDynamicPatches(loadResult,options.dynamic.defaultParentId);for(const patchEntry of patches){const resolvedParentId=patchEntry.parentId??options.dynamic.defaultParentId??null;const normalizedRoutes=normalizeRoutes(patchEntry.routes,{authorization:options.authorization,parentId:resolvedParentId,source:"dynamic"});const unregisteredRoutes=options.registry.filterUnregistered(normalizedRoutes);if(!unregisteredRoutes.length){continue}patch(resolvedParentId,unregisteredRoutes);options.registry.register(unregisteredRoutes);if(patchEntry.cacheKey){resolvedCacheKeys.add(patchEntry.cacheKey)}}if(navigationCacheKey){resolvedCacheKeys.add(navigationCacheKey)}}catch(error){const errorContext={...context,error,phase:"dynamic-route-loading"};await options.onError?.(errorContext);if(options.dynamic.errorMode==="throw"){throw error}}finally{inFlightLoads.delete(inFlightKey)}})();inFlightLoads.set(inFlightKey,loadingTask);await loadingTask}};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});Object.defineProperty(exports,"RouteRegistry",{enumerable:true,get:function(){return RouteRegistry}});function _define_property(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true})}else{obj[key]=value}return obj}const collectRouteIds=(routes,collector)=>{for(const route of routes){collector.add(route.id);if(route.children?.length){collectRouteIds(route.children,collector)}}};let RouteRegistry=class RouteRegistry{isRegistered(routeId){return this.registeredIds.has(routeId)}register(routes){collectRouteIds(routes,this.registeredIds)}filterUnregistered(routes){return routes.filter(route=>!this.isRegistered(route.id))}snapshot(){return new Set(this.registeredIds)}constructor(routes=[]){_define_property(this,"registeredIds",new Set);this.register(routes)}};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { AppRouteObject, DefaultRouteMeta, RouteExtraFields } from "../../types";
|
|
2
|
+
export declare class RouteRegistry<Meta = DefaultRouteMeta, Extra extends RouteExtraFields = RouteExtraFields> {
|
|
3
|
+
private readonly registeredIds;
|
|
4
|
+
constructor(routes?: AppRouteObject<Meta, Extra>[]);
|
|
5
|
+
isRegistered(routeId: string): boolean;
|
|
6
|
+
register(routes: AppRouteObject<Meta, Extra>[]): void;
|
|
7
|
+
filterUnregistered(routes: AppRouteObject<Meta, Extra>[]): AppRouteObject<Meta, Extra>[];
|
|
8
|
+
snapshot(): Set<string>;
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function _define_property(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true})}else{obj[key]=value}return obj}const collectRouteIds=(routes,collector)=>{for(const route of routes){collector.add(route.id);if(route.children?.length){collectRouteIds(route.children,collector)}}};export class RouteRegistry{isRegistered(routeId){return this.registeredIds.has(routeId)}register(routes){collectRouteIds(routes,this.registeredIds)}filterUnregistered(routes){return routes.filter(route=>!this.isRegistered(route.id))}snapshot(){return new Set(this.registeredIds)}constructor(routes=[]){_define_property(this,"registeredIds",new Set);this.register(routes)}}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});function _export(target,all){for(var name in all)Object.defineProperty(target,name,{enumerable:true,get:Object.getOwnPropertyDescriptor(all,name).get})}_export(exports,{get createAppRouter(){return _adapters.createAppRouter},get defineRoutes(){return _adapters.defineRoutes}});const _adapters=require("./adapters");
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { createAppRouter, defineRoutes } from "./adapters";
|
|
2
|
+
export type { AppRouterProviderProps } from "./runtime";
|
|
3
|
+
export type { AppRouteHandle, AppRouteObject, AppRoutePatchFunction, AppRouterMode, DefaultRouteMeta, DynamicRouteLoader, DynamicRouteLoaderContext, DynamicRouteLoadResult, DynamicRoutePatch, DynamicRoutingOptions, RedirectRouteConfig, RouteAuthConfig, RouteAuthorizationContext, RouteAuthorizationFallbackProps, RouteAuthorizationOptions, RouteExtraFields, RouteLayout, RouteLayoutDescriptor, RouteLayoutProps, RouteLazyLoader, RouteRedirect, RouterErrorHandler, RouterErrorHandlerContext, RouterPluginOptions, StaticRouteConfig, } from "./types";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{createAppRouter,defineRoutes}from"./adapters";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});Object.defineProperty(exports,"AppRouterProvider",{enumerable:true,get:function(){return AppRouterProvider}});const _react=require("react");const _reactrouterdom=require("react-router-dom");const _createapprouter=require("../adapters/create-app-router");const AppRouterProvider=({options,...providerProps})=>{const router=(0,_react.useMemo)(()=>(0,_createapprouter.createAppRouter)(options),[options]);return React.createElement(_reactrouterdom.RouterProvider,{router:router,...providerProps})};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type RouterProviderProps } from "react-router-dom";
|
|
2
|
+
import type { DefaultRouteMeta, RouteExtraFields, RouterPluginOptions } from "../types";
|
|
3
|
+
export interface AppRouterProviderProps<Meta = DefaultRouteMeta, Extra extends RouteExtraFields = RouteExtraFields> extends Omit<RouterProviderProps, "router"> {
|
|
4
|
+
options: RouterPluginOptions<Meta, Extra>;
|
|
5
|
+
}
|
|
6
|
+
export declare const AppRouterProvider: <Meta = DefaultRouteMeta, Extra extends RouteExtraFields = RouteExtraFields>({ options, ...providerProps }: AppRouterProviderProps<Meta, Extra>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useMemo}from"react";import{RouterProvider}from"react-router-dom";import{createAppRouter}from"../adapters/create-app-router";export const AppRouterProvider=({options,...providerProps})=>{const router=useMemo(()=>createAppRouter(options),[options]);return React.createElement(RouterProvider,{router:router,...providerProps})};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});Object.defineProperty(exports,"AppRouterProvider",{enumerable:true,get:function(){return _AppRouterProvider.AppRouterProvider}});const _AppRouterProvider=require("./AppRouterProvider");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{AppRouterProvider}from"./AppRouterProvider";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { AppRouteHandle, AppRouteObject, AppRoutePatchFunction, AppRouterMode, DefaultRouteMeta, DynamicRouteLoader, DynamicRouteLoaderContext, DynamicRouteLoadResult, DynamicRoutePatch, DynamicRoutingOptions, MaybePromise, RedirectRouteConfig, RouteAuthConfig, RouteAuthorizationContext, RouteAuthorizationFallbackProps, RouteAuthorizationOptions, RouteComponent, RouteExtraFields, RouteLayout, RouteLayoutDescriptor, RouteLayoutProps, RouteLazyLoader, RouteRedirect, RouterErrorHandler, RouterErrorHandlerContext, RouterPluginOptions, StaticRouteConfig, } from "./route";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import type { ComponentType, ReactNode } from "react";
|
|
2
|
+
import type { DataRouter, LazyRouteFunction, MemoryRouterOpts, PatchRoutesOnNavigationFunction, RouteMatch, RouteObject } from "react-router-dom";
|
|
3
|
+
export type MaybePromise<T> = T | Promise<T>;
|
|
4
|
+
export type AppRouterMode = "browser" | "hash" | "memory";
|
|
5
|
+
export type DefaultRouteMeta = Record<string, unknown>;
|
|
6
|
+
export type RouteExtraFields = Record<string, unknown>;
|
|
7
|
+
export interface RedirectRouteConfig {
|
|
8
|
+
to: string;
|
|
9
|
+
replace?: boolean;
|
|
10
|
+
state?: unknown;
|
|
11
|
+
}
|
|
12
|
+
export type RouteRedirect = string | RedirectRouteConfig;
|
|
13
|
+
export type RouteAuthConfig = boolean | {
|
|
14
|
+
required?: boolean;
|
|
15
|
+
redirectTo?: string;
|
|
16
|
+
[key: string]: unknown;
|
|
17
|
+
};
|
|
18
|
+
export interface AppRouteHandle<Meta = DefaultRouteMeta> extends Record<string, unknown> {
|
|
19
|
+
meta?: Meta;
|
|
20
|
+
auth?: RouteAuthConfig;
|
|
21
|
+
source?: "static" | "dynamic";
|
|
22
|
+
}
|
|
23
|
+
export type AppRouteObject<Meta = DefaultRouteMeta, Extra extends RouteExtraFields = RouteExtraFields> = RouteObject & {
|
|
24
|
+
id: string;
|
|
25
|
+
children?: AppRouteObject<Meta, Extra>[];
|
|
26
|
+
handle?: AppRouteHandle<Meta>;
|
|
27
|
+
__extra?: Extra;
|
|
28
|
+
};
|
|
29
|
+
export interface RouteLayoutProps<Meta = DefaultRouteMeta, Extra extends RouteExtraFields = RouteExtraFields> {
|
|
30
|
+
children?: ReactNode;
|
|
31
|
+
route: AppRouteObject<Meta, Extra>;
|
|
32
|
+
}
|
|
33
|
+
export interface RouteLayoutDescriptor<Meta = DefaultRouteMeta, Extra extends RouteExtraFields = RouteExtraFields> {
|
|
34
|
+
component: ComponentType<RouteLayoutProps<Meta, Extra>>;
|
|
35
|
+
props?: Record<string, unknown>;
|
|
36
|
+
}
|
|
37
|
+
export type RouteLayout<Meta = DefaultRouteMeta, Extra extends RouteExtraFields = RouteExtraFields> = ComponentType<RouteLayoutProps<Meta, Extra>> | RouteLayoutDescriptor<Meta, Extra>;
|
|
38
|
+
export type RouteComponent = Exclude<RouteObject["Component"], undefined>;
|
|
39
|
+
export type RouteLazyLoader = LazyRouteFunction<RouteObject>;
|
|
40
|
+
interface StaticRouteConfigBase<Meta = DefaultRouteMeta, Extra extends RouteExtraFields = RouteExtraFields> {
|
|
41
|
+
id?: string;
|
|
42
|
+
path?: string;
|
|
43
|
+
index?: boolean;
|
|
44
|
+
caseSensitive?: boolean;
|
|
45
|
+
component?: RouteComponent;
|
|
46
|
+
Component?: RouteComponent;
|
|
47
|
+
element?: ReactNode;
|
|
48
|
+
lazy?: RouteLazyLoader;
|
|
49
|
+
loader?: RouteObject["loader"];
|
|
50
|
+
action?: RouteObject["action"];
|
|
51
|
+
shouldRevalidate?: RouteObject["shouldRevalidate"];
|
|
52
|
+
errorElement?: ReactNode;
|
|
53
|
+
ErrorBoundary?: RouteObject["ErrorBoundary"];
|
|
54
|
+
hydrateFallbackElement?: ReactNode;
|
|
55
|
+
HydrateFallback?: RouteObject["HydrateFallback"];
|
|
56
|
+
handle?: RouteObject["handle"];
|
|
57
|
+
meta?: Meta;
|
|
58
|
+
layout?: RouteLayout<Meta, Extra>;
|
|
59
|
+
auth?: RouteAuthConfig;
|
|
60
|
+
redirect?: RouteRedirect;
|
|
61
|
+
children?: StaticRouteConfig<Meta, Extra>[];
|
|
62
|
+
}
|
|
63
|
+
export type StaticRouteConfig<Meta = DefaultRouteMeta, Extra extends RouteExtraFields = RouteExtraFields> = StaticRouteConfigBase<Meta, Extra> & Extra;
|
|
64
|
+
export interface RouteAuthorizationContext<Meta = DefaultRouteMeta, Extra extends RouteExtraFields = RouteExtraFields> {
|
|
65
|
+
route: AppRouteObject<Meta, Extra>;
|
|
66
|
+
auth: RouteAuthConfig;
|
|
67
|
+
}
|
|
68
|
+
export interface RouteAuthorizationFallbackProps<Meta = DefaultRouteMeta, Extra extends RouteExtraFields = RouteExtraFields> extends RouteAuthorizationContext<Meta, Extra> {
|
|
69
|
+
}
|
|
70
|
+
export interface RouteAuthorizationOptions<Meta = DefaultRouteMeta, Extra extends RouteExtraFields = RouteExtraFields> {
|
|
71
|
+
resolve: (context: RouteAuthorizationContext<Meta, Extra>) => boolean;
|
|
72
|
+
redirectTo?: string;
|
|
73
|
+
renderDenied?: ReactNode | ComponentType<RouteAuthorizationFallbackProps<Meta, Extra>>;
|
|
74
|
+
}
|
|
75
|
+
export interface DynamicRouteLoaderContext<Meta = DefaultRouteMeta, Extra extends RouteExtraFields = RouteExtraFields> {
|
|
76
|
+
path: string;
|
|
77
|
+
signal: AbortSignal;
|
|
78
|
+
matches: RouteMatch<string, AppRouteObject<Meta, Extra>>[];
|
|
79
|
+
router: DataRouter;
|
|
80
|
+
knownRouteIds: Set<string>;
|
|
81
|
+
}
|
|
82
|
+
export interface DynamicRoutePatch<Meta = DefaultRouteMeta, Extra extends RouteExtraFields = RouteExtraFields> {
|
|
83
|
+
parentId?: string | null;
|
|
84
|
+
routes: StaticRouteConfig<Meta, Extra>[];
|
|
85
|
+
cacheKey?: string | false;
|
|
86
|
+
}
|
|
87
|
+
export type DynamicRouteLoadResult<Meta = DefaultRouteMeta, Extra extends RouteExtraFields = RouteExtraFields> = void | StaticRouteConfig<Meta, Extra>[] | DynamicRoutePatch<Meta, Extra> | DynamicRoutePatch<Meta, Extra>[];
|
|
88
|
+
export type DynamicRouteLoader<Meta = DefaultRouteMeta, Extra extends RouteExtraFields = RouteExtraFields> = (context: DynamicRouteLoaderContext<Meta, Extra>) => MaybePromise<DynamicRouteLoadResult<Meta, Extra>>;
|
|
89
|
+
export interface DynamicRoutingOptions<Meta = DefaultRouteMeta, Extra extends RouteExtraFields = RouteExtraFields> {
|
|
90
|
+
loader: DynamicRouteLoader<Meta, Extra>;
|
|
91
|
+
defaultParentId?: string | null;
|
|
92
|
+
getNavigationCacheKey?: (context: DynamicRouteLoaderContext<Meta, Extra>) => string | false;
|
|
93
|
+
errorMode?: "silent" | "throw";
|
|
94
|
+
}
|
|
95
|
+
export interface RouterErrorHandlerContext<Meta = DefaultRouteMeta, Extra extends RouteExtraFields = RouteExtraFields> extends DynamicRouteLoaderContext<Meta, Extra> {
|
|
96
|
+
error: unknown;
|
|
97
|
+
phase: "dynamic-route-loading";
|
|
98
|
+
}
|
|
99
|
+
export type RouterErrorHandler<Meta = DefaultRouteMeta, Extra extends RouteExtraFields = RouteExtraFields> = (context: RouterErrorHandlerContext<Meta, Extra>) => MaybePromise<void>;
|
|
100
|
+
export interface RouterPluginOptions<Meta = DefaultRouteMeta, Extra extends RouteExtraFields = RouteExtraFields> {
|
|
101
|
+
routes: StaticRouteConfig<Meta, Extra>[];
|
|
102
|
+
mode?: AppRouterMode;
|
|
103
|
+
basename?: string;
|
|
104
|
+
future?: MemoryRouterOpts["future"];
|
|
105
|
+
hydrationData?: MemoryRouterOpts["hydrationData"];
|
|
106
|
+
getContext?: MemoryRouterOpts["getContext"];
|
|
107
|
+
dataStrategy?: MemoryRouterOpts["dataStrategy"];
|
|
108
|
+
initialEntries?: MemoryRouterOpts["initialEntries"];
|
|
109
|
+
initialIndex?: MemoryRouterOpts["initialIndex"];
|
|
110
|
+
window?: Window;
|
|
111
|
+
dynamic?: DynamicRoutingOptions<Meta, Extra>;
|
|
112
|
+
authorization?: RouteAuthorizationOptions<Meta, Extra>;
|
|
113
|
+
onError?: RouterErrorHandler<Meta, Extra>;
|
|
114
|
+
}
|
|
115
|
+
export type AppRoutePatchFunction = PatchRoutesOnNavigationFunction;
|
|
116
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{};
|
package/package.json
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vlian/router",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Business-friendly router wrapper built on react-router-dom",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"author": "Secra Framework Contributors",
|
|
7
|
+
"packageManager": "pnpm@10.6.0",
|
|
8
|
+
"sideEffects": false,
|
|
9
|
+
"main": "./dist/index.cjs",
|
|
10
|
+
"module": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"import": "./dist/index.js",
|
|
16
|
+
"require": "./dist/index.cjs"
|
|
17
|
+
},
|
|
18
|
+
"./core": {
|
|
19
|
+
"types": "./dist/core/index.d.ts",
|
|
20
|
+
"import": "./dist/core/index.js",
|
|
21
|
+
"require": "./dist/core/index.cjs"
|
|
22
|
+
},
|
|
23
|
+
"./runtime": {
|
|
24
|
+
"types": "./dist/runtime/index.d.ts",
|
|
25
|
+
"import": "./dist/runtime/index.js",
|
|
26
|
+
"require": "./dist/runtime/index.cjs"
|
|
27
|
+
},
|
|
28
|
+
"./provider": {
|
|
29
|
+
"types": "./dist/runtime/index.d.ts",
|
|
30
|
+
"import": "./dist/runtime/index.js",
|
|
31
|
+
"require": "./dist/runtime/index.cjs"
|
|
32
|
+
},
|
|
33
|
+
"./types": {
|
|
34
|
+
"types": "./dist/types/index.d.ts",
|
|
35
|
+
"import": "./dist/types/index.js",
|
|
36
|
+
"require": "./dist/types/index.cjs"
|
|
37
|
+
},
|
|
38
|
+
"./package.json": "./package.json"
|
|
39
|
+
},
|
|
40
|
+
"typesVersions": {
|
|
41
|
+
"*": {
|
|
42
|
+
"core": [
|
|
43
|
+
"dist/core/index.d.ts"
|
|
44
|
+
],
|
|
45
|
+
"runtime": [
|
|
46
|
+
"dist/runtime/index.d.ts"
|
|
47
|
+
],
|
|
48
|
+
"provider": [
|
|
49
|
+
"dist/runtime/index.d.ts"
|
|
50
|
+
],
|
|
51
|
+
"types": [
|
|
52
|
+
"dist/types/index.d.ts"
|
|
53
|
+
],
|
|
54
|
+
"*": [
|
|
55
|
+
"dist/*.d.ts"
|
|
56
|
+
]
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
"files": [
|
|
60
|
+
"dist",
|
|
61
|
+
"README.md"
|
|
62
|
+
],
|
|
63
|
+
"scripts": {
|
|
64
|
+
"build": "npm run clean && npm run build:types && npm run build:esm && npm run build:cjs",
|
|
65
|
+
"build:types": "tsc --emitDeclarationOnly --declarationMap false --sourceMap false",
|
|
66
|
+
"build:esm": "swc src -d dist --strip-leading-paths --config-file .swcrc",
|
|
67
|
+
"build:cjs": "swc src -d dist-temp --strip-leading-paths --config-file .swcrc.cjs && node scripts/rename-cjs.js && rm -rf dist-temp",
|
|
68
|
+
"clean": "rm -rf dist dist-temp",
|
|
69
|
+
"typecheck": "tsc --noEmit",
|
|
70
|
+
"prepublishOnly": "npm run build"
|
|
71
|
+
},
|
|
72
|
+
"peerDependencies": {
|
|
73
|
+
"react": "^19.0.0",
|
|
74
|
+
"react-dom": "^19.0.0",
|
|
75
|
+
"react-router-dom": "^7.0.0"
|
|
76
|
+
},
|
|
77
|
+
"devDependencies": {
|
|
78
|
+
"@swc/cli": "^0.7.3",
|
|
79
|
+
"@swc/core": "^1.13.5",
|
|
80
|
+
"@types/react": "^19.2.5",
|
|
81
|
+
"@types/react-dom": "^19.2.3",
|
|
82
|
+
"react": "^19.2.0",
|
|
83
|
+
"react-dom": "^19.2.0",
|
|
84
|
+
"react-router-dom": "^7.13.1",
|
|
85
|
+
"typescript": "^5.9.3"
|
|
86
|
+
},
|
|
87
|
+
"publishConfig": {
|
|
88
|
+
"access": "public"
|
|
89
|
+
}
|
|
90
|
+
}
|