@tanstack/router-core 0.0.1-beta.23 → 0.0.1-beta.25
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/build/cjs/packages/router-core/src/route.js +1 -0
- package/build/cjs/packages/router-core/src/route.js.map +1 -1
- package/build/cjs/packages/router-core/src/routeConfig.js.map +1 -1
- package/build/cjs/packages/router-core/src/routeMatch.js.map +1 -1
- package/build/cjs/packages/router-core/src/router.js.map +1 -1
- package/build/esm/index.js +1 -0
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +128 -128
- package/build/types/index.d.ts +5 -4
- package/build/umd/index.development.js +1 -0
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +1 -1
- package/build/umd/index.production.js.map +1 -1
- package/package.json +1 -1
- package/src/frameworks.ts +1 -0
- package/src/link.ts +3 -2
- package/src/route.ts +6 -1
- package/src/routeConfig.ts +1 -1
- package/src/routeMatch.ts +3 -3
- package/src/router.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route.js","sources":["../../../../../src/route.ts"],"sourcesContent":["import {\n CheckRelativePath,\n LinkInfo,\n LinkOptions,\n ResolveRelativePath,\n ToOptions,\n} from './link'\nimport { LoaderContext, RouteConfig, RouteOptions } from './routeConfig'\nimport {\n AnyAllRouteInfo,\n AnyRouteInfo,\n DefaultAllRouteInfo,\n RouteInfo,\n RouteInfoByPath,\n} from './routeInfo'\nimport {\n Action,\n ActionState,\n Loader,\n LoaderState,\n MatchRouteOptions,\n Router,\n} from './router'\nimport { NoInfer } from './utils'\n\nexport interface AnyRoute extends Route<any, any> {}\n\nexport interface Route<\n TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo,\n TRouteInfo extends AnyRouteInfo = RouteInfo,\n> {\n routeId: TRouteInfo['id']\n routeRouteId: TRouteInfo['routeId']\n routePath: TRouteInfo['path']\n fullPath: TRouteInfo['fullPath']\n parentRoute?: AnyRoute\n childRoutes?: AnyRoute[]\n options: RouteOptions\n router: Router<TAllRouteInfo['routeConfig'], TAllRouteInfo>\n buildLink: <TTo extends string = '.'>(\n options: Omit<\n LinkOptions<TAllRouteInfo, TRouteInfo['fullPath'], TTo>,\n 'from'\n >,\n ) => LinkInfo\n matchRoute: <\n TTo extends string = '.',\n TResolved extends string = ResolveRelativePath<TRouteInfo['id'], TTo>,\n >(\n matchLocation: CheckRelativePath<\n TAllRouteInfo,\n TRouteInfo['fullPath'],\n NoInfer<TTo>\n > &\n Omit<ToOptions<TAllRouteInfo, TRouteInfo['fullPath'], TTo>, 'from'>,\n opts?: MatchRouteOptions,\n ) => RouteInfoByPath<TAllRouteInfo, TResolved>['allParams']\n navigate: <TTo extends string = '.'>(\n options: Omit<LinkOptions<TAllRouteInfo, TRouteInfo['id'], TTo>, 'from'>,\n ) => Promise<void>\n action: unknown extends TRouteInfo['actionResponse']\n ?\n | Action<TRouteInfo['actionPayload'], TRouteInfo['actionResponse']>\n | undefined\n : Action<TRouteInfo['actionPayload'], TRouteInfo['actionResponse']>\n loader: unknown extends TRouteInfo['routeLoaderData']\n ?\n | Action<\n LoaderContext<\n TRouteInfo['fullSearchSchema'],\n TRouteInfo['allParams']\n >,\n TRouteInfo['routeLoaderData']\n >\n | undefined\n : Loader<\n TRouteInfo['fullSearchSchema'],\n TRouteInfo['allParams'],\n TRouteInfo['routeLoaderData']\n >\n}\n\nexport function createRoute<\n TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo,\n TRouteInfo extends AnyRouteInfo = RouteInfo,\n>(\n routeConfig: RouteConfig,\n options: TRouteInfo['options'],\n parent: undefined | Route<TAllRouteInfo, any>,\n router: Router<TAllRouteInfo['routeConfig'], TAllRouteInfo>,\n): Route<TAllRouteInfo, TRouteInfo> {\n const { id, routeId, path: routePath, fullPath } = routeConfig\n\n const action =\n router.state.actions[id] ||\n (() => {\n router.state.actions[id] = {\n submissions: [],\n submit: async <T, U>(\n submission: T,\n actionOpts?: { invalidate?: boolean; multi?: boolean },\n ) => {\n if (!route) {\n return\n }\n\n const invalidate = actionOpts?.invalidate ?? true\n\n if (!actionOpts?.multi) {\n action.submissions = action.submissions.filter((d) => d.isMulti)\n }\n\n const actionState: ActionState<T, U> = {\n submittedAt: Date.now(),\n status: 'pending',\n submission,\n isMulti: !!actionOpts?.multi,\n }\n\n action.current = actionState\n action.latest = actionState\n action.submissions.push(actionState)\n\n router.notify()\n\n try {\n const res = await route.options.action?.(submission)\n actionState.data = res as U\n\n if (invalidate) {\n router.invalidateRoute({ to: '.', fromCurrent: true })\n await router.reload()\n }\n actionState.status = 'success'\n return res\n } catch (err) {\n console.error(err)\n actionState.error = err\n actionState.status = 'error'\n } finally {\n router.notify()\n }\n },\n }\n return router.state.actions[id]!\n })()\n\n const loader =\n router.state.loaders[id] ||\n (() => {\n router.state.loaders[id] = {\n pending: [],\n fetch: (async (loaderContext: LoaderContext<any, any>) => {\n if (!route) {\n return\n }\n\n const loaderState: LoaderState<any, any> = {\n loadedAt: Date.now(),\n loaderContext,\n }\n\n loader.current = loaderState\n loader.latest = loaderState\n loader.pending.push(loaderState)\n\n // router.state = {\n // ...router.state,\n // currentAction: loaderState,\n // latestAction: loaderState,\n // }\n\n router.notify()\n\n try {\n return await route.options.loader?.(loaderContext)\n } finally {\n loader.pending = loader.pending.filter((d) => d !== loaderState)\n // router.removeActionQueue.push({ loader, loaderState })\n router.notify()\n }\n }) as any,\n }\n return router.state.loaders[id]!\n })()\n\n let route: Route<TAllRouteInfo, TRouteInfo> = {\n routeId: id,\n routeRouteId: routeId,\n routePath,\n fullPath,\n options,\n router,\n childRoutes: undefined!,\n parentRoute: parent,\n action,\n loader: loader as any,\n\n buildLink: (options) => {\n return router.buildLink({\n ...options,\n from: fullPath,\n } as any) as any\n },\n\n navigate: (options) => {\n return router.navigate({\n ...options,\n from: fullPath,\n } as any) as any\n },\n\n matchRoute: (matchLocation, opts) => {\n return router.matchRoute(\n {\n ...matchLocation,\n from: fullPath,\n } as any,\n opts,\n )\n },\n }\n\n router.options.createRoute?.({ router, route })\n\n return route\n}\n"],"names":["createRoute","routeConfig","options","parent","router","id","routeId","path","routePath","fullPath","action","state","actions","submissions","submit","submission","actionOpts","route","invalidate","multi","filter","d","isMulti","actionState","submittedAt","Date","now","status","current","latest","push","notify","res","data","invalidateRoute","to","fromCurrent","reload","err","console","error","loader","loaders","pending","fetch","loaderContext","loaderState","loadedAt","routeRouteId","childRoutes","undefined","parentRoute","buildLink","_extends","from","navigate","matchRoute","matchLocation","opts"],"mappings":";;;;;;;;;;;;;;;;AAkFO,SAASA,WAAT,CAILC,WAJK,EAKLC,OALK,EAMLC,MANK,EAOLC,MAPK,EAQ6B;EAClC,MAAM;IAAEC,EAAF;IAAMC,OAAN;AAAeC,IAAAA,IAAI,EAAEC,SAArB;AAAgCC,IAAAA,QAAAA;AAAhC,GAAA,GAA6CR,WAAnD,CAAA;;EAEA,MAAMS,MAAM,GACVN,MAAM,CAACO,KAAP,CAAaC,OAAb,CAAqBP,EAArB,CACA,IAAA,CAAC,MAAM;AACLD,IAAAA,MAAM,CAACO,KAAP,CAAaC,OAAb,CAAqBP,EAArB,CAA2B,GAAA;AACzBQ,MAAAA,WAAW,EAAE,EADY;AAEzBC,MAAAA,MAAM,EAAE,OACNC,UADM,EAENC,UAFM,KAGH;AAAA,QAAA,IAAA,qBAAA,CAAA;;QACH,IAAI,CAACC,KAAL,EAAY;AACV,UAAA,OAAA;AACD,SAAA;;QAED,MAAMC,UAAU,4BAAGF,UAAH,IAAA,IAAA,GAAA,KAAA,CAAA,GAAGA,UAAU,CAAEE,UAAf,oCAA6B,IAA7C,CAAA;;AAEA,QAAA,IAAI,EAACF,UAAD,IAAA,IAAA,IAACA,UAAU,CAAEG,KAAb,CAAJ,EAAwB;AACtBT,UAAAA,MAAM,CAACG,WAAP,GAAqBH,MAAM,CAACG,WAAP,CAAmBO,MAAnB,CAA2BC,CAAD,IAAOA,CAAC,CAACC,O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AACD;;;;"}
|
|
1
|
+
{"version":3,"file":"route.js","sources":["../../../../../src/route.ts"],"sourcesContent":["import {\n CheckRelativePath,\n LinkInfo,\n LinkOptions,\n ResolveRelativePath,\n ToOptions,\n} from './link'\nimport { LoaderContext, RouteConfig, RouteOptions } from './routeConfig'\nimport {\n AnyAllRouteInfo,\n AnyRouteInfo,\n DefaultAllRouteInfo,\n RouteInfo,\n RouteInfoByPath,\n} from './routeInfo'\nimport {\n Action,\n ActionState,\n Loader,\n LoaderState,\n MatchRouteOptions,\n Router,\n} from './router'\nimport { NoInfer } from './utils'\n\nexport interface AnyRoute extends Route<any, any> {}\n\nexport interface Route<\n TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo,\n TRouteInfo extends AnyRouteInfo = RouteInfo,\n> {\n routeInfo: TRouteInfo\n routeId: TRouteInfo['id']\n routeRouteId: TRouteInfo['routeId']\n routePath: TRouteInfo['path']\n fullPath: TRouteInfo['fullPath']\n parentRoute?: AnyRoute\n childRoutes?: AnyRoute[]\n options: RouteOptions\n router: Router<TAllRouteInfo['routeConfig'], TAllRouteInfo>\n buildLink: <TTo extends string = '.'>(\n options: Omit<\n LinkOptions<TAllRouteInfo, TRouteInfo['fullPath'], TTo>,\n 'from'\n >,\n ) => LinkInfo\n matchRoute: <\n TTo extends string = '.',\n TResolved extends string = ResolveRelativePath<TRouteInfo['id'], TTo>,\n >(\n matchLocation: CheckRelativePath<\n TAllRouteInfo,\n TRouteInfo['fullPath'],\n NoInfer<TTo>\n > &\n Omit<ToOptions<TAllRouteInfo, TRouteInfo['fullPath'], TTo>, 'from'>,\n opts?: MatchRouteOptions,\n ) => RouteInfoByPath<TAllRouteInfo, TResolved>['allParams']\n navigate: <TTo extends string = '.'>(\n options: Omit<\n LinkOptions<TAllRouteInfo, TRouteInfo['fullPath'], TTo>,\n 'from'\n >,\n ) => Promise<void>\n action: unknown extends TRouteInfo['actionResponse']\n ?\n | Action<TRouteInfo['actionPayload'], TRouteInfo['actionResponse']>\n | undefined\n : Action<TRouteInfo['actionPayload'], TRouteInfo['actionResponse']>\n loader: unknown extends TRouteInfo['routeLoaderData']\n ?\n | Action<\n LoaderContext<\n TRouteInfo['fullSearchSchema'],\n TRouteInfo['allParams']\n >,\n TRouteInfo['routeLoaderData']\n >\n | undefined\n : Loader<\n TRouteInfo['fullSearchSchema'],\n TRouteInfo['allParams'],\n TRouteInfo['routeLoaderData']\n >\n}\n\nexport function createRoute<\n TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo,\n TRouteInfo extends AnyRouteInfo = RouteInfo,\n>(\n routeConfig: RouteConfig,\n options: TRouteInfo['options'],\n parent: undefined | Route<TAllRouteInfo, any>,\n router: Router<TAllRouteInfo['routeConfig'], TAllRouteInfo>,\n): Route<TAllRouteInfo, TRouteInfo> {\n const { id, routeId, path: routePath, fullPath } = routeConfig\n\n const action =\n router.state.actions[id] ||\n (() => {\n router.state.actions[id] = {\n submissions: [],\n submit: async <T, U>(\n submission: T,\n actionOpts?: { invalidate?: boolean; multi?: boolean },\n ) => {\n if (!route) {\n return\n }\n\n const invalidate = actionOpts?.invalidate ?? true\n\n if (!actionOpts?.multi) {\n action.submissions = action.submissions.filter((d) => d.isMulti)\n }\n\n const actionState: ActionState<T, U> = {\n submittedAt: Date.now(),\n status: 'pending',\n submission,\n isMulti: !!actionOpts?.multi,\n }\n\n action.current = actionState\n action.latest = actionState\n action.submissions.push(actionState)\n\n router.notify()\n\n try {\n const res = await route.options.action?.(submission)\n actionState.data = res as U\n\n if (invalidate) {\n router.invalidateRoute({ to: '.', fromCurrent: true })\n await router.reload()\n }\n actionState.status = 'success'\n return res\n } catch (err) {\n console.error(err)\n actionState.error = err\n actionState.status = 'error'\n } finally {\n router.notify()\n }\n },\n }\n return router.state.actions[id]!\n })()\n\n const loader =\n router.state.loaders[id] ||\n (() => {\n router.state.loaders[id] = {\n pending: [],\n fetch: (async (loaderContext: LoaderContext<any, any>) => {\n if (!route) {\n return\n }\n\n const loaderState: LoaderState<any, any> = {\n loadedAt: Date.now(),\n loaderContext,\n }\n\n loader.current = loaderState\n loader.latest = loaderState\n loader.pending.push(loaderState)\n\n // router.state = {\n // ...router.state,\n // currentAction: loaderState,\n // latestAction: loaderState,\n // }\n\n router.notify()\n\n try {\n return await route.options.loader?.(loaderContext)\n } finally {\n loader.pending = loader.pending.filter((d) => d !== loaderState)\n // router.removeActionQueue.push({ loader, loaderState })\n router.notify()\n }\n }) as any,\n }\n return router.state.loaders[id]!\n })()\n\n let route: Route<TAllRouteInfo, TRouteInfo> = {\n routeInfo: undefined!,\n routeId: id,\n routeRouteId: routeId,\n routePath,\n fullPath,\n options,\n router,\n childRoutes: undefined!,\n parentRoute: parent,\n action,\n loader: loader as any,\n\n buildLink: (options) => {\n return router.buildLink({\n ...options,\n from: fullPath,\n } as any) as any\n },\n\n navigate: (options) => {\n return router.navigate({\n ...options,\n from: fullPath,\n } as any) as any\n },\n\n matchRoute: (matchLocation, opts) => {\n return router.matchRoute(\n {\n ...matchLocation,\n from: fullPath,\n } as any,\n opts,\n )\n },\n }\n\n router.options.createRoute?.({ router, route })\n\n return route\n}\n"],"names":["createRoute","routeConfig","options","parent","router","id","routeId","path","routePath","fullPath","action","state","actions","submissions","submit","submission","actionOpts","route","invalidate","multi","filter","d","isMulti","actionState","submittedAt","Date","now","status","current","latest","push","notify","res","data","invalidateRoute","to","fromCurrent","reload","err","console","error","loader","loaders","pending","fetch","loaderContext","loaderState","loadedAt","routeInfo","undefined","routeRouteId","childRoutes","parentRoute","buildLink","_extends","from","navigate","matchRoute","matchLocation","opts"],"mappings":";;;;;;;;;;;;;;;;AAsFO,SAASA,WAAT,CAILC,WAJK,EAKLC,OALK,EAMLC,MANK,EAOLC,MAPK,EAQ6B;EAClC,MAAM;IAAEC,EAAF;IAAMC,OAAN;AAAeC,IAAAA,IAAI,EAAEC,SAArB;AAAgCC,IAAAA,QAAAA;AAAhC,GAAA,GAA6CR,WAAnD,CAAA;;EAEA,MAAMS,MAA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AAA,CAAA,CAAA;KAd0C;IAoB5C+C,QAAQ,EAAGtD,OAAD,IAAa;AACrB,MAAA,OAAOE,MAAM,CAACoD,QAAP,CAAAF,oCAAA,CAAA,EAAA,EACFpD,OADE,EAAA;AAELqD,QAAAA,IAAI,EAAE9C,QAAAA;OAFR,CAAA,CAAA,CAAA;KArB0C;AA2B5CgD,IAAAA,UAAU,EAAE,CAACC,aAAD,EAAgBC,IAAhB,KAAyB;AACnC,MAAA,OAAOvD,MAAM,CAACqD,UAAP,CAAAH,oCAAA,CAAA,EAAA,EAEAI,aAFA,EAAA;AAGHH,QAAAA,IAAI,EAAE9C,QAAAA;AAHH,OAAA,CAAA,EAKLkD,IALK,CAAP,CAAA;AAOD,KAAA;GAnCH,CAAA;EAsCAvD,MAAM,CAACF,OAAP,CAAeF,WAAf,IAAA,IAAA,GAAA,KAAA,CAAA,GAAAI,MAAM,CAACF,OAAP,CAAeF,WAAf,CAA6B;IAAEI,MAAF;AAAUa,IAAAA,KAAAA;GAAvC,CAAA,CAAA;AAEA,EAAA,OAAOA,KAAP,CAAA;AACD;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routeConfig.js","sources":["../../../../../src/routeConfig.ts"],"sourcesContent":["import { GetFrameworkGeneric } from './frameworks'\nimport { ParsePathParams } from './link'\nimport { joinPaths, trimPath, trimPathRight } from './path'\nimport { RouteInfo } from './routeInfo'\nimport { RouteMatch } from './routeMatch'\nimport { RouterContext } from './router'\nimport {\n DeepAwaited,\n Expand,\n IsAny,\n NoInfer,\n PickUnsafe,\n Values,\n} from './utils'\n\nexport const rootRouteId = '__root__' as const\nexport type RootRouteId = typeof rootRouteId\n\nexport type AnyLoaderData = {}\nexport type AnyPathParams = {}\nexport type AnySearchSchema = {}\nexport interface RouteMeta {}\n\n// The parse type here allows a zod schema to be passed directly to the validator\nexport type SearchSchemaValidator<TReturn, TParentSchema> =\n | SearchSchemaValidatorObj<TReturn, TParentSchema>\n | SearchSchemaValidatorFn<TReturn, TParentSchema>\n\nexport type SearchSchemaValidatorObj<TReturn, TParentSchema> = {\n parse?: SearchSchemaValidatorFn<TReturn, TParentSchema>\n}\n\nexport type SearchSchemaValidatorFn<TReturn, TParentSchema> = (\n searchObj: Record<string, unknown>,\n) => {} extends TParentSchema\n ? TReturn\n : keyof TReturn extends keyof TParentSchema\n ? {\n error: 'Top level search params cannot be redefined by child routes!'\n keys: keyof TReturn & keyof TParentSchema\n }\n : TReturn\n\nexport type DefinedPathParamWarning =\n 'Path params cannot be redefined by child routes!'\n\nexport type ParentParams<TParentParams> = AnyPathParams extends TParentParams\n ? {}\n : {\n [Key in keyof TParentParams]?: DefinedPathParamWarning\n }\n\nexport type LoaderFn<\n TRouteLoaderData extends AnyLoaderData = {},\n TFullSearchSchema extends AnySearchSchema = {},\n TAllParams extends AnyPathParams = {},\n> = (\n loaderContext: LoaderContext<TFullSearchSchema, TAllParams>,\n) => Promise<TRouteLoaderData>\n\nexport interface LoaderContext<\n TFullSearchSchema extends AnySearchSchema = {},\n TAllParams extends AnyPathParams = {},\n> {\n params: TAllParams\n search: TFullSearchSchema\n signal?: AbortSignal\n // parentLoaderPromise?: Promise<TParentRouteLoaderData>\n}\n\nexport type ActionFn<TActionPayload = unknown, TActionResponse = unknown> = (\n submission: TActionPayload,\n) => TActionResponse | Promise<TActionResponse>\n\nexport type UnloaderFn<TPath extends string> = (\n routeMatch: RouteMatch<any, RouteInfo<string, TPath>>,\n) => void\n\nexport type RouteOptions<\n TRouteId extends string = string,\n TPath extends string = string,\n TParentRouteLoaderData extends AnyLoaderData = {},\n TRouteLoaderData extends AnyLoaderData = {},\n TLoaderData extends AnyLoaderData = {},\n TActionPayload = unknown,\n TActionResponse = unknown,\n TParentSearchSchema extends {} = {},\n TSearchSchema extends AnySearchSchema = {},\n TFullSearchSchema extends AnySearchSchema = TSearchSchema,\n TParentParams extends AnyPathParams = {},\n TParams extends Record<ParsePathParams<TPath>, unknown> = Record<\n ParsePathParams<TPath>,\n string\n >,\n TAllParams extends AnyPathParams = {},\n> = (\n | {\n // The path to match (relative to the nearest parent `Route` component or root basepath)\n path: TPath\n }\n | {\n id: TRouteId\n }\n) & {\n // If true, this route will be matched as case-sensitive\n caseSensitive?: boolean\n validateSearch?: SearchSchemaValidator<TSearchSchema, TParentSearchSchema>\n // Filter functions that can manipulate search params *before* they are passed to links and navigate\n // calls that match this route.\n preSearchFilters?: SearchFilter<TFullSearchSchema>[]\n // Filter functions that can manipulate search params *after* they are passed to links and navigate\n // calls that match this route.\n postSearchFilters?: SearchFilter<TFullSearchSchema>[]\n // The content to be rendered when the route is matched. If no component is provided, defaults to `<Outlet />`\n component?: GetFrameworkGeneric<'Component'> // , NoInfer<TParentLoaderData>>\n // The content to be rendered when the route encounters an error\n errorComponent?: GetFrameworkGeneric<'Component'> // , NoInfer<TParentLoaderData>>\n // If supported by your framework, the content to be rendered as the fallback content until the route is ready to render\n pendingComponent?: GetFrameworkGeneric<'Component'> //, NoInfer<TParentLoaderData>>\n // An asynchronous function responsible for preparing or fetching data for the route before it is rendered\n loader?: LoaderFn<TRouteLoaderData, TFullSearchSchema, TAllParams>\n // The max age to consider loader data fresh (not-stale) for this route in milliseconds from the time of fetch\n // Defaults to 0. Only stale loader data is refetched.\n loaderMaxAge?: number\n // The max age to cache the loader data for this route in milliseconds from the time of route inactivity\n // before it is garbage collected.\n loaderGcMaxAge?: number\n // An asynchronous function made available to the route for performing asynchronous or mutative actions that\n // might invalidate the route's data.\n action?: ActionFn<TActionPayload, TActionResponse>\n // This async function is called before a route is loaded. If an error is thrown, the navigation is cancelled.\n // If you want to redirect instead, throw a call to the `router.navigate()` function\n beforeLoad?: (opts: { context: RouterContext }) => Promise<void> | void\n // This function is called\n // when moving from an inactive state to an active one. Likewise, when moving from\n // an active to an inactive state, the return function (if provided) is called.\n onLoaded?: (matchContext: {\n params: TAllParams\n search: TFullSearchSchema\n }) =>\n | void\n | undefined\n | ((match: { params: TAllParams; search: TFullSearchSchema }) => void)\n // This function is called when the route remains active from one transition to the next.\n onTransition?: (match: {\n params: TAllParams\n search: TFullSearchSchema\n }) => void\n // An object of whatever you want! This object is accessible anywhere matches are.\n meta?: RouteMeta // TODO: Make this nested and mergeable\n} & (\n | {\n parseParams?: never\n stringifyParams?: never\n }\n | {\n // Parse params optionally receives path params as strings and returns them in a parsed format (like a number or boolean)\n parseParams: (\n rawParams: IsAny<TPath, any, Record<ParsePathParams<TPath>, string>>,\n ) => TParams\n stringifyParams: (\n params: TParams,\n ) => Record<ParsePathParams<TPath>, string>\n }\n ) &\n (PickUnsafe<TParentParams, ParsePathParams<TPath>> extends never // Detect if an existing path param is being redefined\n ? {}\n : 'Cannot redefined path params in child routes!')\n\nexport type SearchFilter<T, U = T> = (prev: T) => U\n\nexport interface RouteConfig<\n TId extends string = string,\n TRouteId extends string = string,\n TPath extends string = string,\n TFullPath extends string = string,\n TParentRouteLoaderData extends AnyLoaderData = AnyLoaderData,\n TRouteLoaderData extends AnyLoaderData = AnyLoaderData,\n TLoaderData extends AnyLoaderData = AnyLoaderData,\n TActionPayload = unknown,\n TActionResponse = unknown,\n TParentSearchSchema extends {} = {},\n TSearchSchema extends AnySearchSchema = {},\n TFullSearchSchema extends AnySearchSchema = {},\n TParentParams extends AnyPathParams = {},\n TParams extends Record<ParsePathParams<TPath>, unknown> = Record<\n ParsePathParams<TPath>,\n string\n >,\n TAllParams extends AnyPathParams = {},\n TKnownChildren = unknown,\n> {\n id: TId\n routeId: TRouteId\n path: NoInfer<TPath>\n fullPath: TFullPath\n options: RouteOptions<\n TRouteId,\n TPath,\n TParentRouteLoaderData,\n TRouteLoaderData,\n TLoaderData,\n TActionPayload,\n TActionResponse,\n TParentSearchSchema,\n TSearchSchema,\n TFullSearchSchema,\n TParentParams,\n TParams,\n TAllParams\n >\n children?: TKnownChildren\n addChildren: IsAny<\n TId,\n any,\n <TNewChildren extends any>(\n children: TNewChildren extends AnyRouteConfig[]\n ? TNewChildren\n : { error: 'Invalid route detected'; route: TNewChildren },\n ) => RouteConfig<\n TId,\n TRouteId,\n TPath,\n TFullPath,\n TParentRouteLoaderData,\n TRouteLoaderData,\n TLoaderData,\n TActionPayload,\n TActionResponse,\n TParentSearchSchema,\n TSearchSchema,\n TFullSearchSchema,\n TParentParams,\n TParams,\n TAllParams,\n TNewChildren\n >\n >\n createChildren: IsAny<\n TId,\n any,\n <TNewChildren extends any>(\n cb: (\n createChildRoute: CreateRouteConfigFn<\n false,\n TId,\n TFullPath,\n TRouteLoaderData,\n TLoaderData,\n TFullSearchSchema,\n TAllParams\n >,\n ) => TNewChildren extends AnyRouteConfig[]\n ? TNewChildren\n : { error: 'Invalid route detected'; route: TNewChildren },\n ) => RouteConfig<\n TId,\n TRouteId,\n TPath,\n TFullPath,\n TParentRouteLoaderData,\n TRouteLoaderData,\n TLoaderData,\n TActionPayload,\n TActionResponse,\n TParentSearchSchema,\n TSearchSchema,\n TFullSearchSchema,\n TParentParams,\n TParams,\n TAllParams,\n TNewChildren\n >\n >\n createRoute: CreateRouteConfigFn<\n false,\n TId,\n TFullPath,\n TRouteLoaderData,\n TLoaderData,\n TFullSearchSchema,\n TAllParams\n >\n}\n\ntype CreateRouteConfigFn<\n TIsRoot extends boolean = false,\n TParentId extends string = string,\n TParentPath extends string = string,\n TParentRouteLoaderData extends AnyLoaderData = {},\n TParentLoaderData extends AnyLoaderData = {},\n TParentSearchSchema extends AnySearchSchema = {},\n TParentParams extends AnyPathParams = {},\n> = <\n TRouteId extends string,\n TPath extends string,\n TRouteLoaderData extends AnyLoaderData,\n TActionPayload,\n TActionResponse,\n TSearchSchema extends AnySearchSchema = AnySearchSchema,\n TParams extends Record<ParsePathParams<TPath>, unknown> = Record<\n ParsePathParams<TPath>,\n string\n >,\n TAllParams extends AnyPathParams extends TParams\n ? Record<ParsePathParams<TPath>, string>\n : NoInfer<TParams> = AnyPathParams extends TParams\n ? Record<ParsePathParams<TPath>, string>\n : NoInfer<TParams>,\n TKnownChildren extends RouteConfig[] = RouteConfig[],\n TResolvedId extends string = string extends TRouteId\n ? string extends TPath\n ? string\n : TPath\n : TRouteId,\n>(\n options?: TIsRoot extends true\n ? Omit<\n RouteOptions<\n TRouteId,\n TPath,\n TParentRouteLoaderData,\n TRouteLoaderData,\n Expand<TParentLoaderData & DeepAwaited<NoInfer<TRouteLoaderData>>>,\n TActionPayload,\n TActionResponse,\n TParentSearchSchema,\n TSearchSchema,\n Expand<TParentSearchSchema & TSearchSchema>,\n TParentParams,\n TParams,\n Expand<TParentParams & TAllParams>\n >,\n 'path'\n > & { path?: never }\n : RouteOptions<\n TRouteId,\n TPath,\n TParentRouteLoaderData,\n TRouteLoaderData,\n Expand<TParentLoaderData & DeepAwaited<NoInfer<TRouteLoaderData>>>,\n TActionPayload,\n TActionResponse,\n TParentSearchSchema,\n TSearchSchema,\n Expand<TParentSearchSchema & TSearchSchema>,\n TParentParams,\n TParams,\n Expand<TParentParams & TAllParams>\n >,\n children?: TKnownChildren,\n isRoot?: boolean,\n parentId?: string,\n parentPath?: string,\n) => RouteConfig<\n RoutePrefix<TParentId, TResolvedId>,\n TResolvedId,\n TPath,\n string extends TPath ? '' : RoutePath<RoutePrefix<TParentPath, TPath>>,\n TParentRouteLoaderData,\n TRouteLoaderData,\n Expand<TParentLoaderData & DeepAwaited<NoInfer<TRouteLoaderData>>>,\n TActionPayload,\n TActionResponse,\n TParentSearchSchema,\n TSearchSchema,\n Expand<TParentSearchSchema & TSearchSchema>,\n TParentParams,\n TParams,\n Expand<TParentParams & TAllParams>,\n TKnownChildren\n>\n\ntype RoutePath<T extends string> = T extends RootRouteId\n ? '/'\n : TrimPathRight<`${T}`>\n\ntype RoutePrefix<\n TPrefix extends string,\n TId extends string,\n> = string extends TId\n ? RootRouteId\n : TId extends string\n ? `${TPrefix}/${TId}` extends '/'\n ? '/'\n : `/${TrimPathLeft<`${TrimPathRight<TPrefix>}/${TrimPath<TId>}`>}`\n : never\n\nexport interface AnyRouteConfig\n extends RouteConfig<\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any\n > {}\n\nexport interface AnyRouteConfigWithChildren<TChildren>\n extends RouteConfig<\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n TChildren\n > {}\n\ntype TrimPath<T extends string> = '' extends T\n ? ''\n : TrimPathRight<TrimPathLeft<T>>\n\ntype TrimPathLeft<T extends string> = T extends `${RootRouteId}/${infer U}`\n ? TrimPathLeft<U>\n : T extends `/${infer U}`\n ? TrimPathLeft<U>\n : T\ntype TrimPathRight<T extends string> = T extends '/'\n ? '/'\n : T extends `${infer U}/`\n ? TrimPathRight<U>\n : T\n\nexport const createRouteConfig: CreateRouteConfigFn<true> = (\n options = {} as any,\n children,\n isRoot = true,\n parentId,\n parentPath,\n) => {\n if (isRoot) {\n ;(options as any).path = rootRouteId\n }\n\n // Strip the root from parentIds\n if (parentId === rootRouteId) {\n parentId = ''\n }\n\n let path: undefined | string = isRoot ? rootRouteId : options.path\n\n // If the path is anything other than an index path, trim it up\n if (path && path !== '/') {\n path = trimPath(path)\n }\n\n const routeId = path || (options as { id?: string }).id\n\n let id = joinPaths([parentId, routeId])\n\n if (path === rootRouteId) {\n path = '/'\n }\n\n if (id !== rootRouteId) {\n id = joinPaths(['/', id])\n }\n\n const fullPath =\n id === rootRouteId ? '/' : trimPathRight(joinPaths([parentPath, path]))\n\n return {\n id: id as any,\n routeId: routeId as any,\n path: path as any,\n fullPath: fullPath as any,\n options: options as any,\n children,\n createChildren: (cb: any) =>\n createRouteConfig(\n options,\n cb((childOptions: any) =>\n createRouteConfig(childOptions, undefined, false, id, fullPath),\n ),\n false,\n parentId,\n parentPath,\n ),\n addChildren: (children: any) =>\n createRouteConfig(options, children, false, parentId, parentPath),\n createRoute: (childOptions: any) =>\n createRouteConfig(childOptions, undefined, false, id, fullPath) as any,\n }\n}\n"],"names":["rootRouteId","createRouteConfig","options","children","isRoot","parentId","parentPath","path","trimPath","routeId","id","joinPaths","fullPath","trimPathRight","createChildren","cb","childOptions","undefined","addChildren","createRoute"],"mappings":";;;;;;;;;;;;;;;;AAeO,MAAMA,WAAW,GAAG,WAApB;AA4aMC,MAAAA,iBAA4C,GAAG,SAA/CA,iBAA+C,CAC1DC,OAD0D,EAE1DC,QAF0D,EAG1DC,MAH0D,EAI1DC,QAJ0D,EAK1DC,UAL0D,EAMvD;AAAA,EAAA,IALHJ,OAKG,KAAA,KAAA,CAAA,EAAA;AALHA,IAAAA,OAKG,GALO,EAKP,CAAA;AAAA,GAAA;;AAAA,EAAA,IAHHE,MAGG,KAAA,KAAA,CAAA,EAAA;AAHHA,IAAAA,MAGG,GAHM,IAGN,CAAA;AAAA,GAAA;;AACH,EAAA,IAAIA,MAAJ,EAAY;IACRF,OAAD,CAAiBK,IAAjB,GAAwBP,WAAxB,CAAA;AACF,GAHE;;;EAMH,IAAIK,QAAQ,KAAKL,WAAjB,EAA8B;AAC5BK,IAAAA,QAAQ,GAAG,EAAX,CAAA;AACD,GAAA;;EAED,IAAIE,MAAwB,GAAGH,MAAM,GAAGJ,WAAH,GAAiBE,OAAO,CAACK,IAA9D,CAVG;;AAaH,EAAA,IAAIA,MAAI,IAAIA,MAAI,KAAK,GAArB,EAA0B;AACxBA,IAAAA,MAAI,GAAGC,aAAQ,CAACD,MAAD,CAAf,CAAA;AACD,GAAA;;AAED,EAAA,MAAME,OAAO,GAAGF,MAAI,IAAKL,OAAD,CAA6BQ,EAArD,CAAA;EAEA,IAAIA,EAAE,GAAGC,cAAS,CAAC,CAACN,QAAD,EAAWI,OAAX,CAAD,CAAlB,CAAA;;EAEA,IAAIF,MAAI,KAAKP,WAAb,EAA0B;AACxBO,IAAAA,MAAI,GAAG,GAAP,CAAA;AACD,GAAA;;EAED,IAAIG,EAAE,KAAKV,WAAX,EAAwB;IACtBU,EAAE,GAAGC,cAAS,CAAC,CAAC,GAAD,EAAMD,EAAN,CAAD,CAAd,CAAA;AACD,GAAA;;AAED,EAAA,MAAME,QAAQ,GACZF,EAAE,KAAKV,WAAP,GAAqB,GAArB,GAA2Ba,kBAAa,CAACF,cAAS,CAAC,CAACL,UAAD,EAAaC,MAAb,CAAD,CAAV,CAD1C,CAAA;EAGA,OAAO;AACLG,IAAAA,EAAE,EAAEA,EADC;AAELD,IAAAA,OAAO,EAAEA,OAFJ;AAGLF,IAAAA,IAAI,EAAEA,MAHD;AAILK,IAAAA,QAAQ,EAAEA,QAJL;AAKLV,IAAAA,OAAO,EAAEA,OALJ;IAMLC,QANK;AAOLW,IAAAA,cAAc,EAAGC,EAAD,IACdd,iBAAiB,CACfC,OADe,EAEfa,EAAE,CAAEC,YAAD,IACDf,iBAAiB,CAACe,YAAD,EAAeC,SAAf,EAA0B,KAA1B,EAAiCP,EAAjC,EAAqCE,QAArC,CADjB,CAFa,EAKf,KALe,EAMfP,QANe,EAOfC,UAPe,CARd;AAiBLY,IAAAA,WAAW,EAAGf,QAAD,IACXF,iBAAiB,CAACC,OAAD,EAAUC,QAAV,EAAoB,KAApB,EAA2BE,QAA3B,EAAqCC,UAArC,CAlBd;AAmBLa,IAAAA,WAAW,EAAGH,YAAD,IACXf,iBAAiB,CAACe,YAAD,EAAeC,SAAf,EAA0B,KAA1B,EAAiCP,EAAjC,EAAqCE,QAArC,CAAA;GApBrB,CAAA;AAsBD;;;;;"}
|
|
1
|
+
{"version":3,"file":"routeConfig.js","sources":["../../../../../src/routeConfig.ts"],"sourcesContent":["import { GetFrameworkGeneric } from './frameworks'\nimport { ParsePathParams } from './link'\nimport { joinPaths, trimPath, trimPathRight } from './path'\nimport { RouteInfo } from './routeInfo'\nimport { RouteMatch } from './routeMatch'\nimport { RouterContext } from './router'\nimport {\n DeepAwaited,\n Expand,\n IsAny,\n NoInfer,\n PickUnsafe,\n Values,\n} from './utils'\n\nexport const rootRouteId = '__root__' as const\nexport type RootRouteId = typeof rootRouteId\n\nexport type AnyLoaderData = {}\nexport type AnyPathParams = {}\nexport type AnySearchSchema = {}\nexport interface RouteMeta {}\n\n// The parse type here allows a zod schema to be passed directly to the validator\nexport type SearchSchemaValidator<TReturn, TParentSchema> =\n | SearchSchemaValidatorObj<TReturn, TParentSchema>\n | SearchSchemaValidatorFn<TReturn, TParentSchema>\n\nexport type SearchSchemaValidatorObj<TReturn, TParentSchema> = {\n parse?: SearchSchemaValidatorFn<TReturn, TParentSchema>\n}\n\nexport type SearchSchemaValidatorFn<TReturn, TParentSchema> = (\n searchObj: Record<string, unknown>,\n) => {} extends TParentSchema\n ? TReturn\n : keyof TReturn extends keyof TParentSchema\n ? {\n error: 'Top level search params cannot be redefined by child routes!'\n keys: keyof TReturn & keyof TParentSchema\n }\n : TReturn\n\nexport type DefinedPathParamWarning =\n 'Path params cannot be redefined by child routes!'\n\nexport type ParentParams<TParentParams> = AnyPathParams extends TParentParams\n ? {}\n : {\n [Key in keyof TParentParams]?: DefinedPathParamWarning\n }\n\nexport type LoaderFn<\n TRouteLoaderData extends AnyLoaderData = {},\n TFullSearchSchema extends AnySearchSchema = {},\n TAllParams extends AnyPathParams = {},\n> = (\n loaderContext: LoaderContext<TFullSearchSchema, TAllParams>,\n) => Promise<TRouteLoaderData>\n\nexport interface LoaderContext<\n TFullSearchSchema extends AnySearchSchema = {},\n TAllParams extends AnyPathParams = {},\n> {\n params: TAllParams\n search: TFullSearchSchema\n signal?: AbortSignal\n // parentLoaderPromise?: Promise<TParentRouteLoaderData>\n}\n\nexport type ActionFn<TActionPayload = unknown, TActionResponse = unknown> = (\n submission: TActionPayload,\n) => TActionResponse | Promise<TActionResponse>\n\nexport type UnloaderFn<TPath extends string> = (\n routeMatch: RouteMatch<any, RouteInfo<string, TPath>>,\n) => void\n\nexport type RouteOptions<\n TRouteId extends string = string,\n TPath extends string = string,\n TParentRouteLoaderData extends AnyLoaderData = {},\n TRouteLoaderData extends AnyLoaderData = {},\n TLoaderData extends AnyLoaderData = {},\n TActionPayload = unknown,\n TActionResponse = unknown,\n TParentSearchSchema extends {} = {},\n TSearchSchema extends AnySearchSchema = {},\n TFullSearchSchema extends AnySearchSchema = TSearchSchema,\n TParentParams extends AnyPathParams = {},\n TParams extends Record<ParsePathParams<TPath>, unknown> = Record<\n ParsePathParams<TPath>,\n string\n >,\n TAllParams extends AnyPathParams = {},\n> = (\n | {\n // The path to match (relative to the nearest parent `Route` component or root basepath)\n path: TPath\n }\n | {\n id: TRouteId\n }\n) & {\n // If true, this route will be matched as case-sensitive\n caseSensitive?: boolean\n validateSearch?: SearchSchemaValidator<TSearchSchema, TParentSearchSchema>\n // Filter functions that can manipulate search params *before* they are passed to links and navigate\n // calls that match this route.\n preSearchFilters?: SearchFilter<TFullSearchSchema>[]\n // Filter functions that can manipulate search params *after* they are passed to links and navigate\n // calls that match this route.\n postSearchFilters?: SearchFilter<TFullSearchSchema>[]\n // The content to be rendered when the route is matched. If no component is provided, defaults to `<Outlet />`\n component?: GetFrameworkGeneric<'Component'> // , NoInfer<TParentLoaderData>>\n // The content to be rendered when the route encounters an error\n errorComponent?: GetFrameworkGeneric<'ErrorComponent'> // , NoInfer<TParentLoaderData>>\n // If supported by your framework, the content to be rendered as the fallback content until the route is ready to render\n pendingComponent?: GetFrameworkGeneric<'Component'> //, NoInfer<TParentLoaderData>>\n // An asynchronous function responsible for preparing or fetching data for the route before it is rendered\n loader?: LoaderFn<TRouteLoaderData, TFullSearchSchema, TAllParams>\n // The max age to consider loader data fresh (not-stale) for this route in milliseconds from the time of fetch\n // Defaults to 0. Only stale loader data is refetched.\n loaderMaxAge?: number\n // The max age to cache the loader data for this route in milliseconds from the time of route inactivity\n // before it is garbage collected.\n loaderGcMaxAge?: number\n // An asynchronous function made available to the route for performing asynchronous or mutative actions that\n // might invalidate the route's data.\n action?: ActionFn<TActionPayload, TActionResponse>\n // This async function is called before a route is loaded. If an error is thrown, the navigation is cancelled.\n // If you want to redirect instead, throw a call to the `router.navigate()` function\n beforeLoad?: (opts: { context: RouterContext }) => Promise<void> | void\n // This function is called\n // when moving from an inactive state to an active one. Likewise, when moving from\n // an active to an inactive state, the return function (if provided) is called.\n onLoaded?: (matchContext: {\n params: TAllParams\n search: TFullSearchSchema\n }) =>\n | void\n | undefined\n | ((match: { params: TAllParams; search: TFullSearchSchema }) => void)\n // This function is called when the route remains active from one transition to the next.\n onTransition?: (match: {\n params: TAllParams\n search: TFullSearchSchema\n }) => void\n // An object of whatever you want! This object is accessible anywhere matches are.\n meta?: RouteMeta // TODO: Make this nested and mergeable\n} & (\n | {\n parseParams?: never\n stringifyParams?: never\n }\n | {\n // Parse params optionally receives path params as strings and returns them in a parsed format (like a number or boolean)\n parseParams: (\n rawParams: IsAny<TPath, any, Record<ParsePathParams<TPath>, string>>,\n ) => TParams\n stringifyParams: (\n params: TParams,\n ) => Record<ParsePathParams<TPath>, string>\n }\n ) &\n (PickUnsafe<TParentParams, ParsePathParams<TPath>> extends never // Detect if an existing path param is being redefined\n ? {}\n : 'Cannot redefined path params in child routes!')\n\nexport type SearchFilter<T, U = T> = (prev: T) => U\n\nexport interface RouteConfig<\n TId extends string = string,\n TRouteId extends string = string,\n TPath extends string = string,\n TFullPath extends string = string,\n TParentRouteLoaderData extends AnyLoaderData = AnyLoaderData,\n TRouteLoaderData extends AnyLoaderData = AnyLoaderData,\n TLoaderData extends AnyLoaderData = AnyLoaderData,\n TActionPayload = unknown,\n TActionResponse = unknown,\n TParentSearchSchema extends {} = {},\n TSearchSchema extends AnySearchSchema = {},\n TFullSearchSchema extends AnySearchSchema = {},\n TParentParams extends AnyPathParams = {},\n TParams extends Record<ParsePathParams<TPath>, unknown> = Record<\n ParsePathParams<TPath>,\n string\n >,\n TAllParams extends AnyPathParams = {},\n TKnownChildren = unknown,\n> {\n id: TId\n routeId: TRouteId\n path: NoInfer<TPath>\n fullPath: TFullPath\n options: RouteOptions<\n TRouteId,\n TPath,\n TParentRouteLoaderData,\n TRouteLoaderData,\n TLoaderData,\n TActionPayload,\n TActionResponse,\n TParentSearchSchema,\n TSearchSchema,\n TFullSearchSchema,\n TParentParams,\n TParams,\n TAllParams\n >\n children?: TKnownChildren\n addChildren: IsAny<\n TId,\n any,\n <TNewChildren extends any>(\n children: TNewChildren extends AnyRouteConfig[]\n ? TNewChildren\n : { error: 'Invalid route detected'; route: TNewChildren },\n ) => RouteConfig<\n TId,\n TRouteId,\n TPath,\n TFullPath,\n TParentRouteLoaderData,\n TRouteLoaderData,\n TLoaderData,\n TActionPayload,\n TActionResponse,\n TParentSearchSchema,\n TSearchSchema,\n TFullSearchSchema,\n TParentParams,\n TParams,\n TAllParams,\n TNewChildren\n >\n >\n createChildren: IsAny<\n TId,\n any,\n <TNewChildren extends any>(\n cb: (\n createChildRoute: CreateRouteConfigFn<\n false,\n TId,\n TFullPath,\n TRouteLoaderData,\n TLoaderData,\n TFullSearchSchema,\n TAllParams\n >,\n ) => TNewChildren extends AnyRouteConfig[]\n ? TNewChildren\n : { error: 'Invalid route detected'; route: TNewChildren },\n ) => RouteConfig<\n TId,\n TRouteId,\n TPath,\n TFullPath,\n TParentRouteLoaderData,\n TRouteLoaderData,\n TLoaderData,\n TActionPayload,\n TActionResponse,\n TParentSearchSchema,\n TSearchSchema,\n TFullSearchSchema,\n TParentParams,\n TParams,\n TAllParams,\n TNewChildren\n >\n >\n createRoute: CreateRouteConfigFn<\n false,\n TId,\n TFullPath,\n TRouteLoaderData,\n TLoaderData,\n TFullSearchSchema,\n TAllParams\n >\n}\n\ntype CreateRouteConfigFn<\n TIsRoot extends boolean = false,\n TParentId extends string = string,\n TParentPath extends string = string,\n TParentRouteLoaderData extends AnyLoaderData = {},\n TParentLoaderData extends AnyLoaderData = {},\n TParentSearchSchema extends AnySearchSchema = {},\n TParentParams extends AnyPathParams = {},\n> = <\n TRouteId extends string,\n TPath extends string,\n TRouteLoaderData extends AnyLoaderData,\n TActionPayload,\n TActionResponse,\n TSearchSchema extends AnySearchSchema = AnySearchSchema,\n TParams extends Record<ParsePathParams<TPath>, unknown> = Record<\n ParsePathParams<TPath>,\n string\n >,\n TAllParams extends AnyPathParams extends TParams\n ? Record<ParsePathParams<TPath>, string>\n : NoInfer<TParams> = AnyPathParams extends TParams\n ? Record<ParsePathParams<TPath>, string>\n : NoInfer<TParams>,\n TKnownChildren extends RouteConfig[] = RouteConfig[],\n TResolvedId extends string = string extends TRouteId\n ? string extends TPath\n ? string\n : TPath\n : TRouteId,\n>(\n options?: TIsRoot extends true\n ? Omit<\n RouteOptions<\n TRouteId,\n TPath,\n TParentRouteLoaderData,\n TRouteLoaderData,\n Expand<TParentLoaderData & DeepAwaited<NoInfer<TRouteLoaderData>>>,\n TActionPayload,\n TActionResponse,\n TParentSearchSchema,\n TSearchSchema,\n Expand<TParentSearchSchema & TSearchSchema>,\n TParentParams,\n TParams,\n Expand<TParentParams & TAllParams>\n >,\n 'path'\n > & { path?: never }\n : RouteOptions<\n TRouteId,\n TPath,\n TParentRouteLoaderData,\n TRouteLoaderData,\n Expand<TParentLoaderData & DeepAwaited<NoInfer<TRouteLoaderData>>>,\n TActionPayload,\n TActionResponse,\n TParentSearchSchema,\n TSearchSchema,\n Expand<TParentSearchSchema & TSearchSchema>,\n TParentParams,\n TParams,\n Expand<TParentParams & TAllParams>\n >,\n children?: TKnownChildren,\n isRoot?: boolean,\n parentId?: string,\n parentPath?: string,\n) => RouteConfig<\n RoutePrefix<TParentId, TResolvedId>,\n TResolvedId,\n TPath,\n string extends TPath ? '' : RoutePath<RoutePrefix<TParentPath, TPath>>,\n TParentRouteLoaderData,\n TRouteLoaderData,\n Expand<TParentLoaderData & DeepAwaited<NoInfer<TRouteLoaderData>>>,\n TActionPayload,\n TActionResponse,\n TParentSearchSchema,\n TSearchSchema,\n Expand<TParentSearchSchema & TSearchSchema>,\n TParentParams,\n TParams,\n Expand<TParentParams & TAllParams>,\n TKnownChildren\n>\n\ntype RoutePath<T extends string> = T extends RootRouteId\n ? '/'\n : TrimPathRight<`${T}`>\n\ntype RoutePrefix<\n TPrefix extends string,\n TId extends string,\n> = string extends TId\n ? RootRouteId\n : TId extends string\n ? `${TPrefix}/${TId}` extends '/'\n ? '/'\n : `/${TrimPathLeft<`${TrimPathRight<TPrefix>}/${TrimPath<TId>}`>}`\n : never\n\nexport interface AnyRouteConfig\n extends RouteConfig<\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any\n > {}\n\nexport interface AnyRouteConfigWithChildren<TChildren>\n extends RouteConfig<\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n TChildren\n > {}\n\ntype TrimPath<T extends string> = '' extends T\n ? ''\n : TrimPathRight<TrimPathLeft<T>>\n\ntype TrimPathLeft<T extends string> = T extends `${RootRouteId}/${infer U}`\n ? TrimPathLeft<U>\n : T extends `/${infer U}`\n ? TrimPathLeft<U>\n : T\ntype TrimPathRight<T extends string> = T extends '/'\n ? '/'\n : T extends `${infer U}/`\n ? TrimPathRight<U>\n : T\n\nexport const createRouteConfig: CreateRouteConfigFn<true> = (\n options = {} as any,\n children,\n isRoot = true,\n parentId,\n parentPath,\n) => {\n if (isRoot) {\n ;(options as any).path = rootRouteId\n }\n\n // Strip the root from parentIds\n if (parentId === rootRouteId) {\n parentId = ''\n }\n\n let path: undefined | string = isRoot ? rootRouteId : options.path\n\n // If the path is anything other than an index path, trim it up\n if (path && path !== '/') {\n path = trimPath(path)\n }\n\n const routeId = path || (options as { id?: string }).id\n\n let id = joinPaths([parentId, routeId])\n\n if (path === rootRouteId) {\n path = '/'\n }\n\n if (id !== rootRouteId) {\n id = joinPaths(['/', id])\n }\n\n const fullPath =\n id === rootRouteId ? '/' : trimPathRight(joinPaths([parentPath, path]))\n\n return {\n id: id as any,\n routeId: routeId as any,\n path: path as any,\n fullPath: fullPath as any,\n options: options as any,\n children,\n createChildren: (cb: any) =>\n createRouteConfig(\n options,\n cb((childOptions: any) =>\n createRouteConfig(childOptions, undefined, false, id, fullPath),\n ),\n false,\n parentId,\n parentPath,\n ),\n addChildren: (children: any) =>\n createRouteConfig(options, children, false, parentId, parentPath),\n createRoute: (childOptions: any) =>\n createRouteConfig(childOptions, undefined, false, id, fullPath) as any,\n }\n}\n"],"names":["rootRouteId","createRouteConfig","options","children","isRoot","parentId","parentPath","path","trimPath","routeId","id","joinPaths","fullPath","trimPathRight","createChildren","cb","childOptions","undefined","addChildren","createRoute"],"mappings":";;;;;;;;;;;;;;;;AAeO,MAAMA,WAAW,GAAG,WAApB;AA4aMC,MAAAA,iBAA4C,GAAG,SAA/CA,iBAA+C,CAC1DC,OAD0D,EAE1DC,QAF0D,EAG1DC,MAH0D,EAI1DC,QAJ0D,EAK1DC,UAL0D,EAMvD;AAAA,EAAA,IALHJ,OAKG,KAAA,KAAA,CAAA,EAAA;AALHA,IAAAA,OAKG,GALO,EAKP,CAAA;AAAA,GAAA;;AAAA,EAAA,IAHHE,MAGG,KAAA,KAAA,CAAA,EAAA;AAHHA,IAAAA,MAGG,GAHM,IAGN,CAAA;AAAA,GAAA;;AACH,EAAA,IAAIA,MAAJ,EAAY;IACRF,OAAD,CAAiBK,IAAjB,GAAwBP,WAAxB,CAAA;AACF,GAHE;;;EAMH,IAAIK,QAAQ,KAAKL,WAAjB,EAA8B;AAC5BK,IAAAA,QAAQ,GAAG,EAAX,CAAA;AACD,GAAA;;EAED,IAAIE,MAAwB,GAAGH,MAAM,GAAGJ,WAAH,GAAiBE,OAAO,CAACK,IAA9D,CAVG;;AAaH,EAAA,IAAIA,MAAI,IAAIA,MAAI,KAAK,GAArB,EAA0B;AACxBA,IAAAA,MAAI,GAAGC,aAAQ,CAACD,MAAD,CAAf,CAAA;AACD,GAAA;;AAED,EAAA,MAAME,OAAO,GAAGF,MAAI,IAAKL,OAAD,CAA6BQ,EAArD,CAAA;EAEA,IAAIA,EAAE,GAAGC,cAAS,CAAC,CAACN,QAAD,EAAWI,OAAX,CAAD,CAAlB,CAAA;;EAEA,IAAIF,MAAI,KAAKP,WAAb,EAA0B;AACxBO,IAAAA,MAAI,GAAG,GAAP,CAAA;AACD,GAAA;;EAED,IAAIG,EAAE,KAAKV,WAAX,EAAwB;IACtBU,EAAE,GAAGC,cAAS,CAAC,CAAC,GAAD,EAAMD,EAAN,CAAD,CAAd,CAAA;AACD,GAAA;;AAED,EAAA,MAAME,QAAQ,GACZF,EAAE,KAAKV,WAAP,GAAqB,GAArB,GAA2Ba,kBAAa,CAACF,cAAS,CAAC,CAACL,UAAD,EAAaC,MAAb,CAAD,CAAV,CAD1C,CAAA;EAGA,OAAO;AACLG,IAAAA,EAAE,EAAEA,EADC;AAELD,IAAAA,OAAO,EAAEA,OAFJ;AAGLF,IAAAA,IAAI,EAAEA,MAHD;AAILK,IAAAA,QAAQ,EAAEA,QAJL;AAKLV,IAAAA,OAAO,EAAEA,OALJ;IAMLC,QANK;AAOLW,IAAAA,cAAc,EAAGC,EAAD,IACdd,iBAAiB,CACfC,OADe,EAEfa,EAAE,CAAEC,YAAD,IACDf,iBAAiB,CAACe,YAAD,EAAeC,SAAf,EAA0B,KAA1B,EAAiCP,EAAjC,EAAqCE,QAArC,CADjB,CAFa,EAKf,KALe,EAMfP,QANe,EAOfC,UAPe,CARd;AAiBLY,IAAAA,WAAW,EAAGf,QAAD,IACXF,iBAAiB,CAACC,OAAD,EAAUC,QAAV,EAAoB,KAApB,EAA2BE,QAA3B,EAAqCC,UAArC,CAlBd;AAmBLa,IAAAA,WAAW,EAAGH,YAAD,IACXf,iBAAiB,CAACe,YAAD,EAAeC,SAAf,EAA0B,KAA1B,EAAiCP,EAAjC,EAAqCE,QAArC,CAAA;GApBrB,CAAA;AAsBD;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routeMatch.js","sources":["../../../../../src/routeMatch.ts"],"sourcesContent":["import { GetFrameworkGeneric } from './frameworks'\nimport { Route } from './route'\nimport {\n AnyAllRouteInfo,\n AnyRouteInfo,\n DefaultAllRouteInfo,\n RouteInfo,\n} from './routeInfo'\nimport { Router } from './router'\nimport { replaceEqualDeep } from './utils'\n\nexport interface RouteMatch<\n TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo,\n TRouteInfo extends AnyRouteInfo = RouteInfo,\n> extends Route<TAllRouteInfo, TRouteInfo> {\n matchId: string\n pathname: string\n params: TRouteInfo['allParams']\n parentMatch?: RouteMatch\n childMatches: RouteMatch[]\n routeSearch: TRouteInfo['searchSchema']\n search: TRouteInfo['fullSearchSchema']\n status: 'idle' | 'loading' | 'success' | 'error'\n updatedAt?: number\n error?: unknown\n isInvalid: boolean\n getIsInvalid: () => boolean\n loaderData: TRouteInfo['loaderData']\n routeLoaderData: TRouteInfo['routeLoaderData']\n isFetching: boolean\n invalidAt: number\n __: {\n component?: GetFrameworkGeneric<'Component'> // , TRouteInfo['loaderData']>\n errorComponent?: GetFrameworkGeneric<'Component'> // , TRouteInfo['loaderData']>\n pendingComponent?: GetFrameworkGeneric<'Component'> // , TRouteInfo['loaderData']>\n loadPromise?: Promise<void>\n componentsPromise?: Promise<void>\n dataPromise?: Promise<TRouteInfo['routeLoaderData']>\n onExit?:\n | void\n | ((matchContext: {\n params: TRouteInfo['allParams']\n search: TRouteInfo['fullSearchSchema']\n }) => void)\n abortController: AbortController\n latestId: string\n // setParentMatch: (parentMatch: RouteMatch) => void\n // addChildMatch: (childMatch: RouteMatch) => void\n validate: () => void\n notify: () => void\n resolve: () => void\n }\n cancel: () => void\n load: (\n loaderOpts?:\n | { preload: true; maxAge: number; gcMaxAge: number }\n | { preload?: false; maxAge?: never; gcMaxAge?: never },\n ) => Promise<TRouteInfo['routeLoaderData']>\n fetch: (opts?: { maxAge?: number }) => Promise<TRouteInfo['routeLoaderData']>\n invalidate: () => void\n hasLoaders: () => boolean\n}\n\nconst componentTypes = [\n 'component',\n 'errorComponent',\n 'pendingComponent',\n] as const\n\nexport function createRouteMatch<\n TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo,\n TRouteInfo extends AnyRouteInfo = RouteInfo,\n>(\n router: Router<any, any>,\n route: Route<TAllRouteInfo, TRouteInfo>,\n opts: {\n parentMatch?: RouteMatch<any, any>\n matchId: string\n params: TRouteInfo['allParams']\n pathname: string\n },\n): RouteMatch<TAllRouteInfo, TRouteInfo> {\n const routeMatch: RouteMatch<TAllRouteInfo, TRouteInfo> = {\n ...route,\n ...opts,\n router,\n routeSearch: {},\n search: {},\n childMatches: [],\n status: 'idle',\n routeLoaderData: {} as TRouteInfo['routeLoaderData'],\n loaderData: {} as TRouteInfo['loaderData'],\n isFetching: false,\n isInvalid: false,\n invalidAt: Infinity,\n // pendingActions: [],\n getIsInvalid: () => {\n const now = Date.now()\n return routeMatch.isInvalid || routeMatch.invalidAt < now\n },\n __: {\n abortController: new AbortController(),\n latestId: '',\n resolve: () => {},\n notify: () => {\n routeMatch.__.resolve()\n routeMatch.router.notify()\n },\n validate: () => {\n // Validate the search params and stabilize them\n const parentSearch =\n routeMatch.parentMatch?.search ?? router.location.search\n\n try {\n const prevSearch = routeMatch.routeSearch\n\n const validator =\n typeof routeMatch.options.validateSearch === 'object'\n ? routeMatch.options.validateSearch.parse\n : routeMatch.options.validateSearch\n\n let nextSearch = replaceEqualDeep(\n prevSearch,\n validator?.(parentSearch) ?? {},\n )\n\n // Invalidate route matches when search param stability changes\n if (prevSearch !== nextSearch) {\n routeMatch.isInvalid = true\n }\n\n routeMatch.routeSearch = nextSearch\n\n routeMatch.search = replaceEqualDeep(parentSearch, {\n ...parentSearch,\n ...nextSearch,\n })\n\n componentTypes.map(async (type) => {\n const component = routeMatch.options[type]\n\n if (typeof routeMatch.__[type] !== 'function') {\n routeMatch.__[type] = component\n }\n })\n } catch (err: any) {\n console.error(err)\n const error = new (Error as any)('Invalid search params found', {\n cause: err,\n })\n error.code = 'INVALID_SEARCH_PARAMS'\n routeMatch.status = 'error'\n routeMatch.error = error\n // Do not proceed with loading the route\n return\n }\n },\n },\n cancel: () => {\n routeMatch.__.abortController?.abort()\n },\n invalidate: () => {\n routeMatch.isInvalid = true\n },\n hasLoaders: () => {\n return !!(\n route.options.loader ||\n componentTypes.some((d) => route.options[d]?.preload)\n )\n },\n load: async (loaderOpts) => {\n const now = Date.now()\n const minMaxAge = loaderOpts?.preload\n ? Math.max(loaderOpts?.maxAge, loaderOpts?.gcMaxAge)\n : 0\n\n // If this is a preload, add it to the preload cache\n if (loaderOpts?.preload && minMaxAge > 0) {\n // If the match is currently active, don't preload it\n if (\n router.state.matches.find((d) => d.matchId === routeMatch.matchId)\n ) {\n return\n }\n\n router.matchCache[routeMatch.matchId] = {\n gc: now + loaderOpts.gcMaxAge,\n match: routeMatch as RouteMatch<any, any>,\n }\n }\n\n // If the match is invalid, errored or idle, trigger it to load\n if (\n (routeMatch.status === 'success' && routeMatch.getIsInvalid()) ||\n routeMatch.status === 'error' ||\n routeMatch.status === 'idle'\n ) {\n const maxAge = loaderOpts?.preload ? loaderOpts?.maxAge : undefined\n\n await routeMatch.fetch({ maxAge })\n }\n },\n fetch: async (opts) => {\n const loadId = '' + Date.now() + Math.random()\n routeMatch.__.latestId = loadId\n const checkLatest = async () => {\n if (loadId !== routeMatch.__.latestId) {\n // warning(true, 'Data loader is out of date!')\n return new Promise(() => {})\n }\n }\n\n // If the match was in an error state, set it\n // to a loading state again. Otherwise, keep it\n // as loading or resolved\n if (routeMatch.status === 'idle') {\n routeMatch.status = 'loading'\n }\n\n // We started loading the route, so it's no longer invalid\n routeMatch.isInvalid = false\n\n routeMatch.__.loadPromise = new Promise(async (resolve) => {\n // We are now fetching, even if it's in the background of a\n // resolved state\n routeMatch.isFetching = true\n routeMatch.__.resolve = resolve as () => void\n\n routeMatch.__.componentsPromise = (async () => {\n // then run all component and data loaders in parallel\n // For each component type, potentially load it asynchronously\n\n await Promise.all(\n componentTypes.map(async (type) => {\n const component = routeMatch.options[type]\n\n if (routeMatch.__[type]?.preload) {\n routeMatch.__[type] = await router.options.loadComponent!(\n component,\n )\n }\n }),\n )\n })()\n\n routeMatch.__.dataPromise = Promise.resolve().then(async () => {\n try {\n if (routeMatch.options.loader) {\n const data = await router.loadMatchData(routeMatch)\n await checkLatest()\n\n routeMatch.routeLoaderData = replaceEqualDeep(\n routeMatch.routeLoaderData,\n data,\n )\n }\n\n routeMatch.error = undefined\n routeMatch.status = 'success'\n routeMatch.updatedAt = Date.now()\n routeMatch.invalidAt =\n routeMatch.updatedAt +\n (opts?.maxAge ??\n routeMatch.options.loaderMaxAge ??\n router.options.defaultLoaderMaxAge ??\n 0)\n\n return routeMatch.routeLoaderData\n } catch (err) {\n await checkLatest()\n\n if (process.env.NODE_ENV !== 'production') {\n console.error(err)\n }\n\n routeMatch.error = err\n routeMatch.status = 'error'\n routeMatch.updatedAt = Date.now()\n\n throw err\n }\n })\n\n const after = async () => {\n await checkLatest()\n routeMatch.isFetching = false\n delete routeMatch.__.loadPromise\n routeMatch.__.notify()\n }\n\n try {\n await Promise.all([\n routeMatch.__.componentsPromise,\n routeMatch.__.dataPromise.catch(() => {}),\n ])\n after()\n } catch {\n after()\n }\n })\n\n await routeMatch.__.loadPromise\n await checkLatest()\n },\n }\n\n if (!routeMatch.hasLoaders()) {\n routeMatch.status = 'success'\n }\n\n return routeMatch\n}\n"],"names":["componentTypes","createRouteMatch","router","route","opts","routeMatch","_extends","routeSearch","search","childMatches","status","routeLoaderData","loaderData","isFetching","isInvalid","invalidAt","Infinity","getIsInvalid","now","Date","__","abortController","AbortController","latestId","resolve","notify","validate","parentSearch","parentMatch","location","prevSearch","validator","options","validateSearch","parse","nextSearch","replaceEqualDeep","map","type","component","err","console","error","Error","cause","code","cancel","abort","invalidate","hasLoaders","loader","some","d","preload","load","loaderOpts","minMaxAge","Math","max","maxAge","gcMaxAge","state","matches","find","matchId","matchCache","gc","match","undefined","fetch","loadId","random","checkLatest","Promise","loadPromise","componentsPromise","all","loadComponent","dataPromise","then","data","loadMatchData","updatedAt","loaderMaxAge","defaultLoaderMaxAge","process","env","NODE_ENV","after","catch"],"mappings":";;;;;;;;;;;;;;;;;AA+DA,MAAMA,cAAc,GAAG,CACrB,WAD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GAAd,CAAA,CAAA;AACD,aAAA;;YAEDnC,UAAU,CAACqC,KAAX,GAAmBF,GAAnB,CAAA;YACAnC,UAAU,CAACK,MAAX,GAAoB,OAApB,CAAA;AACAL,YAAAA,UAAU,CAAC6E,SAAX,GAAuB/D,IAAI,CAACD,GAAL,EAAvB,CAAA;AAEA,YAAA,MAAMsB,GAAN,CAAA;AACD,WAAA;AACF,SApC2B,CAA5B,CAAA;;QAsCA,MAAMgD,KAAK,GAAG,YAAY;AACxB,UAAA,MAAMhB,WAAW,EAAjB,CAAA;UACAnE,UAAU,CAACQ,UAAX,GAAwB,KAAxB,CAAA;AACA,UAAA,OAAOR,UAAU,CAACe,EAAX,CAAcsD,WAArB,CAAA;;UACArE,UAAU,CAACe,EAAX,CAAcK,MAAd,EAAA,CAAA;SAJF,CAAA;;QAOA,IAAI;UACF,MAAMgD,OAAO,CAACG,GAAR,CAAY,CAChBvE,UAAU,CAACe,EAAX,CAAcuD,iBADE,EAEhBtE,UAAU,CAACe,EAAX,CAAc0D,WAAd,CAA0BW,KAA1B,CAAgC,MAAM,EAAtC,CAFgB,CAAZ,CAAN,CAAA;UAIAD,KAAK,EAAA,CAAA;AACN,SAND,CAME,OAAM,OAAA,EAAA;UACNA,KAAK,EAAA,CAAA;AACN,SAAA;AACF,OA7E2B,CAA5B,CAAA;AA+EA,MAAA,MAAMnF,UAAU,CAACe,EAAX,CAAcsD,WAApB,CAAA;AACA,MAAA,MAAMF,WAAW,EAAjB,CAAA;AACD,KAAA;GA7NH,CAAA,CAAA;;AAgOA,EAAA,IAAI,CAACnE,UAAU,CAAC4C,UAAX,EAAL,EAA8B;IAC5B5C,UAAU,CAACK,MAAX,GAAoB,SAApB,CAAA;AACD,GAAA;;AAED,EAAA,OAAOL,UAAP,CAAA;AACD;;;;"}
|
|
1
|
+
{"version":3,"file":"routeMatch.js","sources":["../../../../../src/routeMatch.ts"],"sourcesContent":["import { GetFrameworkGeneric } from './frameworks'\nimport { Route } from './route'\nimport {\n AnyAllRouteInfo,\n AnyRouteInfo,\n DefaultAllRouteInfo,\n RouteInfo,\n} from './routeInfo'\nimport { Router } from './router'\nimport { replaceEqualDeep } from './utils'\n\nexport interface RouteMatch<\n TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo,\n TRouteInfo extends AnyRouteInfo = RouteInfo,\n> extends Route<TAllRouteInfo, TRouteInfo> {\n matchId: string\n pathname: string\n params: TRouteInfo['allParams']\n parentMatch?: RouteMatch\n childMatches: RouteMatch[]\n routeSearch: TRouteInfo['searchSchema']\n search: TRouteInfo['fullSearchSchema']\n status: 'idle' | 'loading' | 'success' | 'error'\n updatedAt?: number\n error?: unknown\n isInvalid: boolean\n getIsInvalid: () => boolean\n loaderData: TRouteInfo['loaderData']\n routeLoaderData: TRouteInfo['routeLoaderData']\n isFetching: boolean\n invalidAt: number\n __: {\n component?: GetFrameworkGeneric<'Component'>\n errorComponent?: GetFrameworkGeneric<'ErrorComponent'>\n pendingComponent?: GetFrameworkGeneric<'Component'>\n loadPromise?: Promise<void>\n componentsPromise?: Promise<void>\n dataPromise?: Promise<TRouteInfo['routeLoaderData']>\n onExit?:\n | void\n | ((matchContext: {\n params: TRouteInfo['allParams']\n search: TRouteInfo['fullSearchSchema']\n }) => void)\n abortController: AbortController\n latestId: string\n // setParentMatch: (parentMatch: RouteMatch) => void\n // addChildMatch: (childMatch: RouteMatch) => void\n validate: () => void\n notify: () => void\n resolve: () => void\n }\n cancel: () => void\n load: (\n loaderOpts?:\n | { preload: true; maxAge: number; gcMaxAge: number }\n | { preload?: false; maxAge?: never; gcMaxAge?: never },\n ) => Promise<TRouteInfo['routeLoaderData']>\n fetch: (opts?: { maxAge?: number }) => Promise<TRouteInfo['routeLoaderData']>\n invalidate: () => void\n hasLoaders: () => boolean\n}\n\nconst componentTypes = [\n 'component',\n 'errorComponent',\n 'pendingComponent',\n] as const\n\nexport function createRouteMatch<\n TAllRouteInfo extends AnyAllRouteInfo = DefaultAllRouteInfo,\n TRouteInfo extends AnyRouteInfo = RouteInfo,\n>(\n router: Router<any, any>,\n route: Route<TAllRouteInfo, TRouteInfo>,\n opts: {\n parentMatch?: RouteMatch<any, any>\n matchId: string\n params: TRouteInfo['allParams']\n pathname: string\n },\n): RouteMatch<TAllRouteInfo, TRouteInfo> {\n const routeMatch: RouteMatch<TAllRouteInfo, TRouteInfo> = {\n ...route,\n ...opts,\n router,\n routeSearch: {},\n search: {},\n childMatches: [],\n status: 'idle',\n routeLoaderData: {} as TRouteInfo['routeLoaderData'],\n loaderData: {} as TRouteInfo['loaderData'],\n isFetching: false,\n isInvalid: false,\n invalidAt: Infinity,\n // pendingActions: [],\n getIsInvalid: () => {\n const now = Date.now()\n return routeMatch.isInvalid || routeMatch.invalidAt < now\n },\n __: {\n abortController: new AbortController(),\n latestId: '',\n resolve: () => {},\n notify: () => {\n routeMatch.__.resolve()\n routeMatch.router.notify()\n },\n validate: () => {\n // Validate the search params and stabilize them\n const parentSearch =\n routeMatch.parentMatch?.search ?? router.location.search\n\n try {\n const prevSearch = routeMatch.routeSearch\n\n const validator =\n typeof routeMatch.options.validateSearch === 'object'\n ? routeMatch.options.validateSearch.parse\n : routeMatch.options.validateSearch\n\n let nextSearch = replaceEqualDeep(\n prevSearch,\n validator?.(parentSearch) ?? {},\n )\n\n // Invalidate route matches when search param stability changes\n if (prevSearch !== nextSearch) {\n routeMatch.isInvalid = true\n }\n\n routeMatch.routeSearch = nextSearch\n\n routeMatch.search = replaceEqualDeep(parentSearch, {\n ...parentSearch,\n ...nextSearch,\n })\n\n componentTypes.map(async (type) => {\n const component = routeMatch.options[type]\n\n if (typeof routeMatch.__[type] !== 'function') {\n routeMatch.__[type] = component\n }\n })\n } catch (err: any) {\n console.error(err)\n const error = new (Error as any)('Invalid search params found', {\n cause: err,\n })\n error.code = 'INVALID_SEARCH_PARAMS'\n routeMatch.status = 'error'\n routeMatch.error = error\n // Do not proceed with loading the route\n return\n }\n },\n },\n cancel: () => {\n routeMatch.__.abortController?.abort()\n },\n invalidate: () => {\n routeMatch.isInvalid = true\n },\n hasLoaders: () => {\n return !!(\n route.options.loader ||\n componentTypes.some((d) => route.options[d]?.preload)\n )\n },\n load: async (loaderOpts) => {\n const now = Date.now()\n const minMaxAge = loaderOpts?.preload\n ? Math.max(loaderOpts?.maxAge, loaderOpts?.gcMaxAge)\n : 0\n\n // If this is a preload, add it to the preload cache\n if (loaderOpts?.preload && minMaxAge > 0) {\n // If the match is currently active, don't preload it\n if (\n router.state.matches.find((d) => d.matchId === routeMatch.matchId)\n ) {\n return\n }\n\n router.matchCache[routeMatch.matchId] = {\n gc: now + loaderOpts.gcMaxAge,\n match: routeMatch as RouteMatch<any, any>,\n }\n }\n\n // If the match is invalid, errored or idle, trigger it to load\n if (\n (routeMatch.status === 'success' && routeMatch.getIsInvalid()) ||\n routeMatch.status === 'error' ||\n routeMatch.status === 'idle'\n ) {\n const maxAge = loaderOpts?.preload ? loaderOpts?.maxAge : undefined\n\n await routeMatch.fetch({ maxAge })\n }\n },\n fetch: async (opts) => {\n const loadId = '' + Date.now() + Math.random()\n routeMatch.__.latestId = loadId\n const checkLatest = async () => {\n if (loadId !== routeMatch.__.latestId) {\n // warning(true, 'Data loader is out of date!')\n return new Promise(() => {})\n }\n }\n\n // If the match was in an error state, set it\n // to a loading state again. Otherwise, keep it\n // as loading or resolved\n if (routeMatch.status === 'idle') {\n routeMatch.status = 'loading'\n }\n\n // We started loading the route, so it's no longer invalid\n routeMatch.isInvalid = false\n\n routeMatch.__.loadPromise = new Promise(async (resolve) => {\n // We are now fetching, even if it's in the background of a\n // resolved state\n routeMatch.isFetching = true\n routeMatch.__.resolve = resolve as () => void\n\n routeMatch.__.componentsPromise = (async () => {\n // then run all component and data loaders in parallel\n // For each component type, potentially load it asynchronously\n\n await Promise.all(\n componentTypes.map(async (type) => {\n const component = routeMatch.options[type]\n\n if (routeMatch.__[type]?.preload) {\n routeMatch.__[type] = await router.options.loadComponent!(\n component,\n )\n }\n }),\n )\n })()\n\n routeMatch.__.dataPromise = Promise.resolve().then(async () => {\n try {\n if (routeMatch.options.loader) {\n const data = await router.loadMatchData(routeMatch)\n await checkLatest()\n\n routeMatch.routeLoaderData = replaceEqualDeep(\n routeMatch.routeLoaderData,\n data,\n )\n }\n\n routeMatch.error = undefined\n routeMatch.status = 'success'\n routeMatch.updatedAt = Date.now()\n routeMatch.invalidAt =\n routeMatch.updatedAt +\n (opts?.maxAge ??\n routeMatch.options.loaderMaxAge ??\n router.options.defaultLoaderMaxAge ??\n 0)\n\n return routeMatch.routeLoaderData\n } catch (err) {\n await checkLatest()\n\n if (process.env.NODE_ENV !== 'production') {\n console.error(err)\n }\n\n routeMatch.error = err\n routeMatch.status = 'error'\n routeMatch.updatedAt = Date.now()\n\n throw err\n }\n })\n\n const after = async () => {\n await checkLatest()\n routeMatch.isFetching = false\n delete routeMatch.__.loadPromise\n routeMatch.__.notify()\n }\n\n try {\n await Promise.all([\n routeMatch.__.componentsPromise,\n routeMatch.__.dataPromise.catch(() => {}),\n ])\n after()\n } catch {\n after()\n }\n })\n\n await routeMatch.__.loadPromise\n await checkLatest()\n },\n }\n\n if (!routeMatch.hasLoaders()) {\n routeMatch.status = 'success'\n }\n\n return routeMatch\n}\n"],"names":["componentTypes","createRouteMatch","router","route","opts","routeMatch","_extends","routeSearch","search","childMatches","status","routeLoaderData","loaderData","isFetching","isInvalid","invalidAt","Infinity","getIsInvalid","now","Date","__","abortController","AbortController","latestId","resolve","notify","validate","parentSearch","parentMatch","location","prevSearch","validator","options","validateSearch","parse","nextSearch","replaceEqualDeep","map","type","component","err","console","error","Error","cause","code","cancel","abort","invalidate","hasLoaders","loader","some","d","preload","load","loaderOpts","minMaxAge","Math","max","maxAge","gcMaxAge","state","matches","find","matchId","matchCache","gc","match","undefined","fetch","loadId","random","checkLatest","Promise","loadPromise","componentsPromise","all","loadComponent","dataPromise","then","data","loadMatchData","updatedAt","loaderMaxAge","defaultLoaderMaxAge","process","env","NODE_ENV","after","catch"],"mappings":";;;;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