@kitbag/router 0.24.2 → 0.25.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/dist/{src/components → components}/routerLink.d.ts +4 -4
- package/dist/{src/components → components}/routerView.d.ts +3 -3
- package/dist/{src/compositions → compositions}/useComponentsStore.d.ts +2 -2
- package/dist/{src/compositions → compositions}/useLink.d.ts +6 -6
- package/dist/{src/compositions → compositions}/usePrefetching.d.ts +3 -3
- package/dist/{src/compositions → compositions}/useQueryValue.d.ts +3 -3
- package/dist/{src/compositions → compositions}/useRejection.d.ts +2 -2
- package/dist/{src/compositions → compositions}/useRoute.d.ts +2 -2
- package/dist/compositions/useRouteValueStore.d.ts +7 -0
- package/dist/{src/compositions → compositions}/useRouter.d.ts +1 -1
- package/dist/{src/compositions → compositions}/useRouterDepth.d.ts +1 -1
- package/dist/{src/compositions → compositions}/useRouterHooks.d.ts +2 -2
- package/dist/{src/compositions → compositions}/useVisibilityObserver.d.ts +1 -1
- package/dist/{src/devtools → devtools}/createRouterDevtools.d.ts +2 -2
- package/dist/{src/devtools → devtools}/filters.d.ts +1 -1
- package/dist/{src/errors → errors}/contextAbortError.d.ts +1 -1
- package/dist/{src/errors → errors}/contextPushError.d.ts +1 -1
- package/dist/{src/errors → errors}/contextRejectionError.d.ts +1 -1
- package/dist/{src/errors → errors}/invalidRouteParamValueError.d.ts +1 -1
- package/dist/errors/loaderDataAccessError.d.ts +8 -0
- package/dist/errors/loaderNameConflict.d.ts +9 -0
- package/dist/errors/navigationAbandonedError.d.ts +6 -0
- package/dist/{src/guards → guards}/routes.d.ts +2 -2
- package/dist/kitbag-router.d.ts +1 -0
- package/dist/kitbag-router.js +6452 -6172
- package/dist/kitbag-router.umd.cjs +5 -4
- package/dist/{src/main.d.ts → main.d.ts} +10 -2
- package/dist/{src/models → models}/hooks.d.ts +2 -2
- package/dist/services/addLoader.d.ts +40 -0
- package/dist/services/addView.d.ts +37 -0
- package/dist/{src/services → services}/arrayOf.d.ts +2 -2
- package/dist/{src/services → services}/combineHash.d.ts +2 -2
- package/dist/{src/services → services}/combinePath.d.ts +2 -2
- package/dist/{src/services → services}/combineQuery.d.ts +2 -2
- package/dist/{src/services → services}/combineState.d.ts +1 -1
- package/dist/{src/services → services}/combineUrl.d.ts +2 -2
- package/dist/{src/services → services}/component.d.ts +3 -4
- package/dist/{src/services → services}/createComponentHooks.d.ts +4 -4
- package/dist/{src/services → services}/createComponentsStore.d.ts +3 -3
- package/dist/{src/services → services}/createCurrentRejection.d.ts +2 -2
- package/dist/services/createCurrentRoute.d.ts +25 -0
- package/dist/services/createDataStore.d.ts +48 -0
- package/dist/{src/services → services}/createExternalRoute.d.ts +4 -4
- package/dist/services/createNavigationStores.d.ts +31 -0
- package/dist/{src/services → services}/createParam.d.ts +3 -3
- package/dist/{src/services → services}/createRejection.d.ts +3 -3
- package/dist/{src/services → services}/createRejectionHooks.d.ts +3 -3
- package/dist/services/createResolvedRoute.d.ts +4 -0
- package/dist/{src/services → services}/createResolvedRouteQuery.d.ts +1 -1
- package/dist/{src/services → services}/createRoute.d.ts +3 -6
- package/dist/{src/services → services}/createRouteHooks.d.ts +5 -5
- package/dist/{src/services → services}/createRouteRedirects.d.ts +2 -2
- package/dist/services/createRouteValueStore.d.ts +56 -0
- package/dist/services/createRouteViews.d.ts +16 -0
- package/dist/{src/services → services}/createRouter.d.ts +3 -3
- package/dist/{src/services → services}/createRouterAssets.d.ts +10 -10
- package/dist/{src/services → services}/createRouterCallbackContext.d.ts +7 -7
- package/dist/{src/services → services}/createRouterHistory.d.ts +1 -1
- package/dist/{src/services → services}/createRouterHooks.d.ts +2 -2
- package/dist/{src/services → services}/createRouterKeyStore.d.ts +1 -1
- package/dist/{src/services → services}/createRouterPlugin.d.ts +3 -3
- package/dist/services/createRouterRoute.d.ts +7 -0
- package/dist/{src/services → services}/createUrl.d.ts +1 -1
- package/dist/services/getGlobalHooksForRouter.d.ts +3 -0
- package/dist/{src/services → services}/getGlobalRouteHooks.d.ts +2 -2
- package/dist/{src/services → services}/getMatchesForUrl.d.ts +3 -3
- package/dist/{src/services → services}/getParamsForString.d.ts +2 -2
- package/dist/services/getRejectionHooks.d.ts +3 -0
- package/dist/{src/services → services}/getRouteHooks.d.ts +2 -2
- package/dist/{src/services → services}/getRoutesForRouter.d.ts +5 -6
- package/dist/{src/services → services}/hooks.d.ts +2 -2
- package/dist/{src/services → services}/insertBaseRoute.d.ts +1 -1
- package/dist/{src/services → services}/literal.d.ts +1 -1
- package/dist/{src/services → services}/params.d.ts +3 -3
- package/dist/{src/services → services}/queryParamFilter.d.ts +1 -1
- package/dist/{src/services → services}/routeRegex.d.ts +1 -1
- package/dist/{src/services → services}/state.d.ts +1 -1
- package/dist/{src/services → services}/tupleOf.d.ts +2 -2
- package/dist/services/unionOf.d.ts +3 -0
- package/dist/{src/services → services}/urlParser.d.ts +2 -2
- package/dist/{src/services → services}/valibot.d.ts +1 -1
- package/dist/{src/services → services}/withDefault.d.ts +2 -2
- package/dist/{src/services → services}/withParams.d.ts +4 -4
- package/dist/services/withRouteMethods.d.ts +7 -0
- package/dist/{src/services → services}/zod.d.ts +2 -2
- package/dist/types/addLoader.d.ts +69 -0
- package/dist/types/addView.d.ts +104 -0
- package/dist/{src/types → types}/createRouteOptions.d.ts +57 -36
- package/dist/{src/types → types}/hooks.d.ts +14 -14
- package/dist/{src/types → types}/paramTypes.d.ts +2 -2
- package/dist/{src/types → types}/params.d.ts +1 -1
- package/dist/{src/types → types}/prefetch.d.ts +1 -0
- package/dist/{src/types → types}/props.d.ts +13 -5
- package/dist/{src/types → types}/register.d.ts +1 -1
- package/dist/{src/types → types}/rejection.d.ts +4 -4
- package/dist/{src/types → types}/resolved.d.ts +24 -5
- package/dist/types/route.d.ts +121 -0
- package/dist/types/routeCallbackContext.d.ts +30 -0
- package/dist/types/routeLoaders.d.ts +30 -0
- package/dist/{src/types → types}/routeTitle.d.ts +1 -1
- package/dist/{src/types → types}/routeUpdate.d.ts +2 -2
- package/dist/types/routeViews.d.ts +44 -0
- package/dist/types/routeWithMethods.d.ts +16 -0
- package/dist/{src/types → types}/routeWithParams.d.ts +3 -3
- package/dist/{src/types → types}/router.d.ts +13 -13
- package/dist/{src/types → types}/routerLink.d.ts +5 -5
- package/dist/{src/types → types}/routerPlugin.d.ts +3 -3
- package/dist/{src/types → types}/routerPush.d.ts +8 -8
- package/dist/{src/types → types}/routerReject.d.ts +1 -1
- package/dist/{src/types → types}/routerReplace.d.ts +8 -8
- package/dist/{src/types → types}/routerResolve.d.ts +7 -7
- package/dist/{src/types → types}/routerRoute.d.ts +9 -3
- package/dist/{src/types → types}/routesMap.d.ts +2 -2
- package/dist/{src/types → types}/state.d.ts +6 -6
- package/dist/{src/types → types}/url.d.ts +6 -6
- package/dist/{src/types → types}/useLink.d.ts +5 -5
- package/dist/{src/types → types}/utilities.d.ts +1 -0
- package/dist/{src/utilities → utilities}/checkDuplicateNames.d.ts +1 -1
- package/dist/utilities/checkDuplicateNames.spec.d.ts +1 -0
- package/dist/utilities/checkDuplicateParams.spec.d.ts +1 -0
- package/dist/utilities/components.spec.d.ts +1 -0
- package/dist/utilities/guards.spec.d.ts +1 -0
- package/dist/utilities/isBrowser.browser.spec.d.ts +1 -0
- package/dist/utilities/isBrowser.spec.d.ts +1 -0
- package/dist/{src/utilities → utilities}/isNamedRoute.d.ts +1 -1
- package/dist/{src/utilities → utilities}/prefetch.d.ts +2 -2
- package/dist/utilities/prefetch.spec.d.ts +1 -0
- package/dist/utilities/props.d.ts +16 -0
- package/dist/{src/utilities → utilities}/setDocumentTitle.d.ts +1 -1
- package/dist/utilities/testHelpers.d.ts +242 -0
- package/dist/utilities/trailingSlashes.spec.d.ts +1 -0
- package/dist/{src/utilities → utilities}/urlSearchParams.d.ts +1 -1
- package/dist/utilities/urlSearchParams.spec.d.ts +1 -0
- package/package.json +18 -16
- package/dist/src/compositions/usePropStore.d.ts +0 -7
- package/dist/src/services/createCurrentRoute.d.ts +0 -13
- package/dist/src/services/createPropStore.d.ts +0 -13
- package/dist/src/services/createResolvedRoute.d.ts +0 -4
- package/dist/src/services/createRouterRoute.d.ts +0 -7
- package/dist/src/services/getGlobalHooksForRouter.d.ts +0 -3
- package/dist/src/services/getRejectionHooks.d.ts +0 -3
- package/dist/src/services/unionOf.d.ts +0 -3
- package/dist/src/types/route.d.ts +0 -80
- package/dist/src/utilities/props.d.ts +0 -6
- package/dist/src/utilities/testHelpers.d.ts +0 -3699
- /package/dist/{src/components → components}/echo.d.ts +0 -0
- /package/dist/{src/components → components}/helloWorld.d.ts +0 -0
- /package/dist/{src/components → components}/rejection.d.ts +0 -0
- /package/dist/{src/components → components}/routerLink.browser.spec.d.ts +0 -0
- /package/dist/{src/components → components}/routerView.browser.spec.d.ts +0 -0
- /package/dist/{src/components → components}/routerView.spec.d.ts +0 -0
- /package/dist/{src/compositions → compositions}/useEventListener.d.ts +0 -0
- /package/dist/{src/compositions → compositions}/useQueryValue.browser.spec.d.ts +0 -0
- /package/dist/{src/compositions → compositions}/useQueryValue.spec-d.d.ts +0 -0
- /package/dist/{src/compositions → compositions}/useRoute.browser.spec.d.ts +0 -0
- /package/dist/{src/compositions → compositions}/useRoute.spec-d.d.ts +0 -0
- /package/dist/{src/devtools → devtools}/getDevtoolsLabel.d.ts +0 -0
- /package/dist/{src/devtools → devtools}/types.d.ts +0 -0
- /package/dist/{src/errors → errors}/contextError.d.ts +0 -0
- /package/dist/{src/errors → errors}/duplicateNamesError.d.ts +0 -0
- /package/dist/{src/errors → errors}/duplicateParamsError.d.ts +0 -0
- /package/dist/{src/errors → errors}/initialRouteMissingError.d.ts +0 -0
- /package/dist/{src/errors → errors}/invalidRouteRedirectError.d.ts +0 -0
- /package/dist/{src/errors → errors}/metaPropertyConflict.d.ts +0 -0
- /package/dist/{src/errors → errors}/multipleRouteRedirectsError.d.ts +0 -0
- /package/dist/{src/errors → errors}/routeNotFoundError.d.ts +0 -0
- /package/dist/{src/errors → errors}/routerNotInstalledError.d.ts +0 -0
- /package/dist/{src/errors → errors}/useRouteInvalidError.d.ts +0 -0
- /package/dist/{src/guards → guards}/routes.spec-d.d.ts +0 -0
- /package/dist/{src/keys.d.ts → keys.d.ts} +0 -0
- /package/dist/{src/services/arrayOf.spec.d.ts → services/addLoader.spec-d.d.ts} +0 -0
- /package/dist/{src/services/combineHash.spec.d.ts → services/addLoader.spec.d.ts} +0 -0
- /package/dist/{src/services/combineMeta.spec.d.ts → services/addView.browser.spec.d.ts} +0 -0
- /package/dist/{src/services/combinePath.spec-d.d.ts → services/addView.spec-d.d.ts} +0 -0
- /package/dist/{src/services/combinePath.spec.d.ts → services/addView.spec.d.ts} +0 -0
- /package/dist/{src/services/combineQuery.spec.d.ts → services/arrayOf.spec.d.ts} +0 -0
- /package/dist/{src/services/combineState.spec.d.ts → services/combineHash.spec.d.ts} +0 -0
- /package/dist/{src/services → services}/combineMeta.d.ts +0 -0
- /package/dist/{src/services/combineUrl.spec.d.ts → services/combineMeta.spec.d.ts} +0 -0
- /package/dist/{src/services/component.browser.spec.d.ts → services/combinePath.spec-d.d.ts} +0 -0
- /package/dist/{src/services/createExternalRoute.spec.d.ts → services/combinePath.spec.d.ts} +0 -0
- /package/dist/{src/services/createIsExternal.spec.d.ts → services/combineQuery.spec.d.ts} +0 -0
- /package/dist/{src/services/createResolvedRoute.spec.d.ts → services/combineState.spec.d.ts} +0 -0
- /package/dist/{src/services/createRoute.spec-d.d.ts → services/combineUrl.spec.d.ts} +0 -0
- /package/dist/{src/services/createRoute.spec.d.ts → services/component.browser.spec.d.ts} +0 -0
- /package/dist/{src/services/createRouteRedirects.spec.d.ts → services/createDataStore.spec.d.ts} +0 -0
- /package/dist/{src/services/createRouter.browser.spec.d.ts → services/createExternalRoute.spec.d.ts} +0 -0
- /package/dist/{src/services → services}/createIsExternal.d.ts +0 -0
- /package/dist/{src/services/createRouter.spec-d.d.ts → services/createIsExternal.spec.d.ts} +0 -0
- /package/dist/{src/services/createRouter.spec.d.ts → services/createNavigationStores.spec.d.ts} +0 -0
- /package/dist/{src/services/createRouterHistory.browser.spec.d.ts → services/createResolvedRoute.spec.d.ts} +0 -0
- /package/dist/{src/services/createRouterPlugin.browser.spec.d.ts → services/createRoute.spec-d.d.ts} +0 -0
- /package/dist/{src/services/createRouterPlugin.spec-d.d.ts → services/createRoute.spec.d.ts} +0 -0
- /package/dist/{src/services → services}/createRouteId.d.ts +0 -0
- /package/dist/{src/services/createRouterRoute.spec.d.ts → services/createRouteRedirects.spec.d.ts} +0 -0
- /package/dist/{src/services/createUrl.spec.d.ts → services/createRouter.browser.spec.d.ts} +0 -0
- /package/dist/{src/services/getInitialUrl.browser.spec.d.ts → services/createRouter.spec-d.d.ts} +0 -0
- /package/dist/{src/services/getInitialUrl.spec.d.ts → services/createRouter.spec.d.ts} +0 -0
- /package/dist/{src/services/getMatchesForUrl.spec.d.ts → services/createRouterHistory.browser.spec.d.ts} +0 -0
- /package/dist/{src/services/getRouteHooks.spec.d.ts → services/createRouterPlugin.browser.spec.d.ts} +0 -0
- /package/dist/{src/services/getRoutesForRouter.spec.d.ts → services/createRouterPlugin.spec-d.d.ts} +0 -0
- /package/dist/{src/services/history.browser.spec.d.ts → services/createRouterRoute.spec.d.ts} +0 -0
- /package/dist/{src/services → services}/createUniqueIdSequence.d.ts +0 -0
- /package/dist/{src/services/hooks.browser.spec.d.ts → services/createUrl.spec.d.ts} +0 -0
- /package/dist/{src/services → services}/createVisibilityObserver.d.ts +0 -0
- /package/dist/{src/services → services}/createVueAppStore.d.ts +0 -0
- /package/dist/{src/services/hooks.spec.d.ts → services/getInitialUrl.browser.spec.d.ts} +0 -0
- /package/dist/{src/services → services}/getInitialUrl.d.ts +0 -0
- /package/dist/{src/services/insertBaseRoute.spec.d.ts → services/getInitialUrl.spec.d.ts} +0 -0
- /package/dist/{src/services/params.spec.d.ts → services/getMatchesForUrl.spec.d.ts} +0 -0
- /package/dist/{src/services/paramsFinder.spec.d.ts → services/getRouteHooks.spec.d.ts} +0 -0
- /package/dist/{src/services/queryParamFilter.spec.d.ts → services/getRoutesForRouter.spec.d.ts} +0 -0
- /package/dist/{src/services/routeRegex.spec.d.ts → services/history.browser.spec.d.ts} +0 -0
- /package/dist/{src/services → services}/history.d.ts +0 -0
- /package/dist/{src/services/state.spec.d.ts → services/hooks.browser.spec.d.ts} +0 -0
- /package/dist/{src/tests → services}/hooks.spec.d.ts +0 -0
- /package/dist/{src/services/tupleOf.spec.d.ts → services/insertBaseRoute.spec.d.ts} +0 -0
- /package/dist/{src/services/unionOf.spec.d.ts → services/params.spec.d.ts} +0 -0
- /package/dist/{src/services → services}/paramsFinder.d.ts +0 -0
- /package/dist/{src/services/urlParser.spec.d.ts → services/paramsFinder.spec.d.ts} +0 -0
- /package/dist/{src/services/valibot.spec-d.d.ts → services/queryParamFilter.spec.d.ts} +0 -0
- /package/dist/{src/services/valibot.spec.d.ts → services/routeRegex.spec.d.ts} +0 -0
- /package/dist/{src/services/withParams.spec-d.d.ts → services/state.spec.d.ts} +0 -0
- /package/dist/{src/services/withParams.spec.d.ts → services/tupleOf.spec.d.ts} +0 -0
- /package/dist/{src/services/zod.spec-d.d.ts → services/unionOf.spec.d.ts} +0 -0
- /package/dist/{src/services/zod.spec.d.ts → services/urlParser.spec.d.ts} +0 -0
- /package/dist/{src/tests/routeProps.browser.spec.d.ts → services/valibot.spec-d.d.ts} +0 -0
- /package/dist/{src/tests/routeProps.spec.d.ts → services/valibot.spec.d.ts} +0 -0
- /package/dist/{src/types/redirects.spec-d.d.ts → services/withParams.spec-d.d.ts} +0 -0
- /package/dist/{src/types/register.spec.d.ts → services/withParams.spec.d.ts} +0 -0
- /package/dist/{src/types/resolved.spec-d.d.ts → services/zod.spec-d.d.ts} +0 -0
- /package/dist/{src/types/route.spec-d.d.ts → services/zod.spec.d.ts} +0 -0
- /package/dist/{src/types/routeTitle.browser.spec.d.ts → tests/hooks.spec.d.ts} +0 -0
- /package/dist/{src/types/routeWithParams.spec-d.d.ts → tests/routeLoaders.browser.spec.d.ts} +0 -0
- /package/dist/{src/types/routesMap.spec-ts.d.ts → tests/routeLoaders.spec.d.ts} +0 -0
- /package/dist/{src/utilities/checkDuplicateNames.spec.d.ts → tests/routeProps.browser.spec.d.ts} +0 -0
- /package/dist/{src/utilities/checkDuplicateParams.spec.d.ts → tests/routeProps.spec.d.ts} +0 -0
- /package/dist/{src/types → types}/callbackContext.d.ts +0 -0
- /package/dist/{src/types → types}/meta.d.ts +0 -0
- /package/dist/{src/types → types}/name.d.ts +0 -0
- /package/dist/{src/types → types}/querySource.d.ts +0 -0
- /package/dist/{src/types → types}/redirects.d.ts +0 -0
- /package/dist/{src/utilities/components.spec.d.ts → types/redirects.spec-d.d.ts} +0 -0
- /package/dist/{src/utilities/guards.spec.d.ts → types/register.spec.d.ts} +0 -0
- /package/dist/{src/utilities/isBrowser.browser.spec.d.ts → types/resolved.spec-d.d.ts} +0 -0
- /package/dist/{src/utilities/isBrowser.spec.d.ts → types/route.spec-d.d.ts} +0 -0
- /package/dist/{src/types → types}/routeContext.d.ts +0 -0
- /package/dist/{src/utilities/prefetch.spec.d.ts → types/routeTitle.browser.spec.d.ts} +0 -0
- /package/dist/{src/utilities/trailingSlashes.spec.d.ts → types/routeWithParams.spec-d.d.ts} +0 -0
- /package/dist/{src/types → types}/routerAbort.d.ts +0 -0
- /package/dist/{src/utilities/urlSearchParams.spec.d.ts → types/routesMap.spec-ts.d.ts} +0 -0
- /package/dist/{src/types → types}/urlString.d.ts +0 -0
- /package/dist/{src/utilities → utilities}/array.d.ts +0 -0
- /package/dist/{src/utilities → utilities}/checkDuplicateParams.d.ts +0 -0
- /package/dist/{src/utilities → utilities}/components.d.ts +0 -0
- /package/dist/{src/utilities → utilities}/guards.d.ts +0 -0
- /package/dist/{src/utilities → utilities}/index.d.ts +0 -0
- /package/dist/{src/utilities → utilities}/isBrowser.d.ts +0 -0
- /package/dist/{src/utilities → utilities}/makeOptional.d.ts +0 -0
- /package/dist/{src/utilities → utilities}/promises.d.ts +0 -0
- /package/dist/{src/utilities → utilities}/trailingSlashes.d.ts +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ResolvedRoute } from '
|
|
2
|
-
import { Hooks } from '
|
|
1
|
+
import { ResolvedRoute } from '../types/resolved';
|
|
2
|
+
import { Hooks } from '../models/hooks';
|
|
3
3
|
export declare function getGlobalBeforeHooks(to: ResolvedRoute, from: ResolvedRoute | null, globalHooks: Hooks): Hooks;
|
|
4
4
|
export declare function getGlobalAfterHooks(to: ResolvedRoute, from: ResolvedRoute | null, globalHooks: Hooks): Hooks;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ResolvedRoute } from '
|
|
2
|
-
import { Routes } from '
|
|
3
|
-
import { ParseUrlOptions } from '
|
|
1
|
+
import { ResolvedRoute } from '../types/resolved';
|
|
2
|
+
import { Routes } from '../types/route';
|
|
3
|
+
import { ParseUrlOptions } from '../types/url';
|
|
4
4
|
type MatchOptions = {
|
|
5
5
|
state?: Partial<unknown>;
|
|
6
6
|
} & ParseUrlOptions;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { UrlParams } from '
|
|
2
|
-
import { Param } from '
|
|
1
|
+
import { UrlParams } from './withParams';
|
|
2
|
+
import { Param } from '../types/paramTypes';
|
|
3
3
|
export declare function getParamsForString(string?: string, params?: Record<string, Param | undefined>): UrlParams;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ResolvedRoute } from '
|
|
2
|
-
import { Hooks } from '
|
|
1
|
+
import { ResolvedRoute } from '../types/resolved';
|
|
2
|
+
import { Hooks } from '../models/hooks';
|
|
3
3
|
export declare function getBeforeHooksFromRoutes(to: ResolvedRoute, from: ResolvedRoute | null): Hooks;
|
|
4
4
|
export declare function getAfterHooksFromRoutes(to: ResolvedRoute, from: ResolvedRoute | null): Hooks;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Route, RouteInternal, Routes } from '
|
|
2
|
-
import { RouterPlugin } from '
|
|
3
|
-
import { BuiltInRejectionType, Rejection, RejectionInternal } from '
|
|
4
|
-
import { RouterOptions } from '
|
|
1
|
+
import { Route, RouteInternal, Routes } from '../types/route';
|
|
2
|
+
import { RouterPlugin } from '../types/routerPlugin';
|
|
3
|
+
import { BuiltInRejectionType, Rejection, RejectionInternal } from '../types/rejection';
|
|
4
|
+
import { RouterOptions } from '../types/router';
|
|
5
5
|
/**
|
|
6
6
|
* Takes in routes and plugins and returns a list of routes with the base route inserted if provided.
|
|
7
7
|
* Also checks for duplicate names in the routes.
|
|
@@ -11,8 +11,7 @@ import { RouterOptions } from '../../types/router';
|
|
|
11
11
|
export declare function getRoutesForRouter(routes: Routes | Routes[], plugins?: RouterPlugin[], options?: RouterOptions): {
|
|
12
12
|
routes: (import('../main').Url & {
|
|
13
13
|
id: string;
|
|
14
|
-
|
|
15
|
-
matches: import('../../types/route').CreatedRouteOptions[];
|
|
14
|
+
matches: import('../types/route').CreatedRouteOptions[];
|
|
16
15
|
name: string;
|
|
17
16
|
meta: Record<string, unknown>;
|
|
18
17
|
state: Record<string, import('../main').Param>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { HookLifecycle } from '
|
|
2
|
-
import { ResolvedRoute } from '
|
|
1
|
+
import { HookLifecycle } from '../types/hooks';
|
|
2
|
+
import { ResolvedRoute } from '../types/resolved';
|
|
3
3
|
type RouteHookCondition = (to: ResolvedRoute, from: ResolvedRoute | null, depth: number) => boolean;
|
|
4
4
|
export declare const isRouteEnter: RouteHookCondition;
|
|
5
5
|
export declare const isRouteLeave: RouteHookCondition;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Route } from '
|
|
1
|
+
import { Route } from '../types/route';
|
|
2
2
|
export declare function insertBaseRoute<T extends Route>(route: T, base?: string): T;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { LiteralParam, ParamGetSet } from '
|
|
1
|
+
import { LiteralParam, ParamGetSet } from '../types/paramTypes';
|
|
2
2
|
export declare function literal<T extends LiteralParam>(value: T): ParamGetSet<T>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { UrlParam } from '
|
|
2
|
-
import { ExtractParamType } from '
|
|
3
|
-
import { Param } from '
|
|
1
|
+
import { UrlParam } from './withParams';
|
|
2
|
+
import { ExtractParamType } from '../types/params';
|
|
3
|
+
import { Param } from '../types/paramTypes';
|
|
4
4
|
export declare function getParam(params: Record<string, Param | undefined>, paramName: string): Param;
|
|
5
5
|
export declare function getParamValue<T extends Param>(value: string | undefined, param: Partial<UrlParam<T>>): ExtractParamType<T>;
|
|
6
6
|
export declare function safeGetParamValue<T extends Param>(value: string | undefined, param: Partial<UrlParam<T>>): ExtractParamType<T> | undefined;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { QuerySource } from '
|
|
1
|
+
import { QuerySource } from '../types/querySource';
|
|
2
2
|
export declare function filterQueryParams(source: QuerySource, exclude: QuerySource): URLSearchParams;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { UrlPart } from '
|
|
1
|
+
import { UrlPart } from './withParams';
|
|
2
2
|
export declare const paramRegex = "\\[\\??([\\w-_]+)\\*?\\]";
|
|
3
3
|
export declare const optionalParamRegex = "\\[\\?([\\w-_]+)\\*?\\]";
|
|
4
4
|
export declare const requiredParamRegex = "\\[([\\w-_]+)\\*?\\]";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Param, ParamGetSet } from '
|
|
2
|
-
import { ExtractParamType } from '
|
|
1
|
+
import { Param, ParamGetSet } from '../types/paramTypes';
|
|
2
|
+
import { ExtractParamType } from '../types/params';
|
|
3
3
|
type TupleOfOptions = {
|
|
4
4
|
separator?: string;
|
|
5
5
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ExtractParamType } from '
|
|
2
|
-
import { Param, ParamGetSet } from '
|
|
1
|
+
import { ExtractParamType } from '../types/params';
|
|
2
|
+
import { Param, ParamGetSet } from '../types/paramTypes';
|
|
3
3
|
export type ParamWithDefault<TParam extends Param = Param> = Required<ParamGetSet<ExtractParamType<TParam>>>;
|
|
4
4
|
export declare function isParamWithDefault(param: Param): param is ParamWithDefault;
|
|
5
5
|
export declare function withDefault<TParam extends Param>(param: TParam, defaultValue: ExtractParamType<TParam>): ParamWithDefault<TParam>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ExtractParamName, ParamEnd, ParamIsGreedy, ParamIsOptionalOrHasDefault, ParamStart } from '
|
|
2
|
-
import { Param } from '
|
|
3
|
-
import { Identity } from '
|
|
4
|
-
import { MakeOptional } from '
|
|
1
|
+
import { ExtractParamName, ParamEnd, ParamIsGreedy, ParamIsOptionalOrHasDefault, ParamStart } from '../types/params';
|
|
2
|
+
import { Param } from '../types/paramTypes';
|
|
3
|
+
import { Identity } from '../types/utilities';
|
|
4
|
+
import { MakeOptional } from '../utilities/makeOptional';
|
|
5
5
|
type WithParamsParamsInput<TValue extends string> = TValue extends `${string}${ParamStart}${infer TParam}${ParamEnd}${infer Rest}` ? Record<ExtractParamName<TParam>, Param | undefined> & WithParamsParamsInput<Rest> : {};
|
|
6
6
|
type WithParamsParamsOutput<TValue extends string, TParams extends Record<string, Param | undefined> = Record<never, never>> = TValue extends `${string}${ParamStart}${infer TParam}${ParamEnd}${infer Rest}` ? ExtractParamName<TParam> extends keyof TParams ? TParams[ExtractParamName<TParam>] extends Param ? Record<ExtractParamName<TParam>, {
|
|
7
7
|
param: TParams[ExtractParamName<TParam>];
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Route } from '../types/route';
|
|
2
|
+
/**
|
|
3
|
+
* Attaches the chainable, immutable route methods — `addView` and `addLoader`. Each call rebuilds the
|
|
4
|
+
* route's own (last) match and returns a new route with the methods re-attached, so neither mutates the
|
|
5
|
+
* route it was called on, and chaining one never drops the other.
|
|
6
|
+
*/
|
|
7
|
+
export declare function withRouteMethods<TRoute extends Route>(route: TRoute): TRoute;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ParamGetSet } from '
|
|
2
|
-
import { Routes } from '
|
|
1
|
+
import { ParamGetSet } from '../types/paramTypes';
|
|
2
|
+
import { Routes } from '../types/route';
|
|
3
3
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
4
4
|
import { ZodType } from 'zod';
|
|
5
5
|
export interface ZodSchemaLike extends StandardSchemaV1<any> {
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { RouteWithMethods } from './routeWithMethods';
|
|
2
|
+
import { PrefetchConfig } from './prefetch';
|
|
3
|
+
import { ResolvedRoute } from './resolved';
|
|
4
|
+
import { CreatedRouteOptions, Route } from './route';
|
|
5
|
+
import { RouteCallbackContext } from './routeCallbackContext';
|
|
6
|
+
import { RouteLoader, RouteLoaders } from './routeLoaders';
|
|
7
|
+
import { Url } from './url';
|
|
8
|
+
import { Identity, LastInArray } from './utilities';
|
|
9
|
+
/**
|
|
10
|
+
* The getter for a loader added via `addLoader`. Receives the same two arguments as an `addView` props
|
|
11
|
+
* getter, except that its route carries no data: a route's data includes what the loader itself is
|
|
12
|
+
* computing, so reading it could only wait on itself. A parent's data is reached through the context.
|
|
13
|
+
*
|
|
14
|
+
* Unlike a props getter it can return anything, since nothing binds what it returns to a component.
|
|
15
|
+
*/
|
|
16
|
+
export type LoaderGetter<TRoute extends Route = Route> = (route: ResolvedRoute<TRoute>, context: RouteCallbackContext<TRoute>) => unknown;
|
|
17
|
+
/**
|
|
18
|
+
* The options for a loader added via `addLoader`.
|
|
19
|
+
*
|
|
20
|
+
* @template TName - The loader's name, inferred from the `name` option.
|
|
21
|
+
*/
|
|
22
|
+
export type AddLoaderOptions<TName extends string | undefined = string> = {
|
|
23
|
+
/**
|
|
24
|
+
* The name of the loader, which is the key its data is exposed under on the route. Defaults to the
|
|
25
|
+
* unnamed loader, whose data is exposed as the route's data directly.
|
|
26
|
+
*/
|
|
27
|
+
name?: TName;
|
|
28
|
+
/**
|
|
29
|
+
* Determines whether this loader is run when a router-link is rendered for this route. Overrides route
|
|
30
|
+
* level prefetch, and is itself overridden by link level prefetch.
|
|
31
|
+
*/
|
|
32
|
+
prefetch?: PrefetchConfig;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* The loaders of the route itself, from the last `matches` entry.
|
|
36
|
+
*/
|
|
37
|
+
type CurrentMatchLoaders<TMatches extends CreatedRouteOptions[]> = LastInArray<TMatches> extends {
|
|
38
|
+
loaders: infer TLoaders extends RouteLoaders;
|
|
39
|
+
} ? TLoaders : RouteLoaders;
|
|
40
|
+
/**
|
|
41
|
+
* Computes the new loaders after adding a loader, replacing any loader the route already stored under
|
|
42
|
+
* the same name.
|
|
43
|
+
*/
|
|
44
|
+
type AddLoaderLoaders<TCurrent extends RouteLoaders, TName extends string | undefined, TData> = Identity<Omit<TCurrent, LoaderName<TName>> & Record<LoaderName<TName>, RouteLoader<TData>>> extends infer TNext extends RouteLoaders ? TNext : TCurrent;
|
|
45
|
+
type LoaderName<TName extends string | undefined> = TName extends string ? TName : 'default';
|
|
46
|
+
/**
|
|
47
|
+
* Replaces the loaders on the last match, preserving all ancestors.
|
|
48
|
+
*/
|
|
49
|
+
type ReplaceLastMatchLoaders<TMatches extends CreatedRouteOptions[], TNewLoaders extends RouteLoaders> = TMatches extends [...infer THead extends CreatedRouteOptions[], infer TLast extends CreatedRouteOptions] ? Identity<Omit<TLast, 'loaders'> & {
|
|
50
|
+
loaders: TNewLoaders;
|
|
51
|
+
}> extends infer TNext extends CreatedRouteOptions ? [...THead, TNext] : TMatches : TMatches;
|
|
52
|
+
/**
|
|
53
|
+
* The full return type of an `addLoader` call: the same url with the last match's loaders replaced.
|
|
54
|
+
*/
|
|
55
|
+
type AddLoaderReturn<TUrl extends Url, TMatches extends CreatedRouteOptions[], TNewLoaders extends RouteLoaders> = ReplaceLastMatchLoaders<TMatches, TNewLoaders> extends infer TNext extends CreatedRouteOptions[] ? RouteWithMethods<TUrl, TNext> : never;
|
|
56
|
+
/**
|
|
57
|
+
* Adds a loader to a route. Chainable to register multiple loaders, each exposed under its own name on
|
|
58
|
+
* the resolved route's `data`.
|
|
59
|
+
*/
|
|
60
|
+
export type RouteAddLoader<TUrl extends Url = Url, TMatches extends CreatedRouteOptions[] = CreatedRouteOptions[]> = {
|
|
61
|
+
/**
|
|
62
|
+
* Adds a loader for this route. Loaders never block rendering, so their data is always a promise.
|
|
63
|
+
*
|
|
64
|
+
* @param load - The loader callback. Receives the resolved route and a context object.
|
|
65
|
+
* @param options - The loader's `name` and `prefetch` config.
|
|
66
|
+
*/
|
|
67
|
+
addLoader: <const TName extends string | undefined = undefined, const TGetter extends LoaderGetter<Route<TUrl, TMatches>> = LoaderGetter<Route<TUrl, TMatches>>>(load: TGetter, options?: AddLoaderOptions<TName>) => AddLoaderReturn<TUrl, TMatches, AddLoaderLoaders<CurrentMatchLoaders<TMatches>, TName, ReturnType<TGetter>>>;
|
|
68
|
+
};
|
|
69
|
+
export {};
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { Component } from 'vue';
|
|
2
|
+
import { ComponentProps } from '../services/component';
|
|
3
|
+
import { ComponentPropsAreOptional, PropsGetter } from './createRouteOptions';
|
|
4
|
+
import { ResolvedRoute, WithData } from './resolved';
|
|
5
|
+
import { CreatedRouteOptions, Route } from './route';
|
|
6
|
+
import { RouteCallbackContext } from './routeCallbackContext';
|
|
7
|
+
import { RouteWithMethods } from './routeWithMethods';
|
|
8
|
+
import { PrefetchConfig } from './prefetch';
|
|
9
|
+
import { RouteView, RouteViews } from './routeViews';
|
|
10
|
+
import { Url } from './url';
|
|
11
|
+
import { AnyFunction, Identity, LastInArray, MaybePromise } from './utilities';
|
|
12
|
+
/**
|
|
13
|
+
* The props getter for a view added via `addView`. Receives the same two arguments as the
|
|
14
|
+
* `createRoute` props callback: the resolved route and a context object.
|
|
15
|
+
*/
|
|
16
|
+
export type AddViewPropsGetter<TRoute extends Route, TComponent extends Component> = (route: ResolvedRoute<TRoute> & WithData<TRoute>, context: AddViewPropsCallbackContext<TRoute>) => MaybePromise<ComponentProps<TComponent>>;
|
|
17
|
+
/**
|
|
18
|
+
* Context provided to an `addView` props getter. The same context a loader is given, since both are
|
|
19
|
+
* callbacks attached to a route.
|
|
20
|
+
*/
|
|
21
|
+
export type AddViewPropsCallbackContext<TRoute extends Route> = RouteCallbackContext<TRoute>;
|
|
22
|
+
/**
|
|
23
|
+
* When the getter is omitted the default type param resolves to the wide getter type, which then
|
|
24
|
+
* "extends" itself and collapses to undefined. When a getter is provided its return type is kept — the
|
|
25
|
+
* view only needs what the props resolve to, not the signature it took to get there.
|
|
26
|
+
*/
|
|
27
|
+
type NewViewProps<TRoute extends Route, TComponent extends Component, TGetter extends AnyFunction> = AddViewPropsGetter<TRoute, TComponent> extends TGetter ? undefined : ReturnType<TGetter>;
|
|
28
|
+
/**
|
|
29
|
+
* The options for a view added via `addView`.
|
|
30
|
+
*
|
|
31
|
+
* @template TName - The view's name, inferred from the `name` option.
|
|
32
|
+
* @template TGetter - The view's props getter, inferred from the `props` option.
|
|
33
|
+
*/
|
|
34
|
+
export type AddViewOptions<TName extends string | undefined = string, TGetter = PropsGetter> = {
|
|
35
|
+
/**
|
|
36
|
+
* The name of the view, rendered by `<router-view name="..." />`. Defaults to the unnamed view.
|
|
37
|
+
*/
|
|
38
|
+
name?: TName;
|
|
39
|
+
/**
|
|
40
|
+
* A props getter for the view. Receives the resolved route and a context object.
|
|
41
|
+
*/
|
|
42
|
+
props?: TGetter;
|
|
43
|
+
/**
|
|
44
|
+
* Determines what assets are prefetched for this view when a router-link is rendered for this route.
|
|
45
|
+
* Overrides route level prefetch, and is itself overridden by link level prefetch.
|
|
46
|
+
*/
|
|
47
|
+
prefetch?: PrefetchConfig;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* {@link AddViewOptions} with `props` promoted to required. Only reached for components that have
|
|
51
|
+
* required props — everything else uses {@link AddViewOptions}, where `props` stays optional, so a view
|
|
52
|
+
* can always be given a name and a prefetch config without a getter.
|
|
53
|
+
*
|
|
54
|
+
* Spelled out rather than intersected with {@link AddViewOptions} so that the literal `name` still
|
|
55
|
+
* infers through the conditional args tuple.
|
|
56
|
+
*/
|
|
57
|
+
type AddViewOptionsWithRequiredProps<TName extends string | undefined, TGetter> = {
|
|
58
|
+
name?: TName;
|
|
59
|
+
props: TGetter;
|
|
60
|
+
prefetch?: PrefetchConfig;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* The options argument for `addView`, required only when the component has required props. `TName` and
|
|
64
|
+
* `TGetter` are inferred from the object's properties rather than from the object as a whole: inferring
|
|
65
|
+
* the whole object as a `const` type param through this conditional tuple widens the literal name.
|
|
66
|
+
*/
|
|
67
|
+
type AddViewArgs<TComponent extends Component, TName extends string | undefined, TGetter> = ComponentPropsAreOptional<TComponent> extends true ? [options?: AddViewOptions<TName, TGetter>] : [options: AddViewOptionsWithRequiredProps<TName, TGetter>];
|
|
68
|
+
/**
|
|
69
|
+
* The views of the route itself, from the last `matches` entry.
|
|
70
|
+
*/
|
|
71
|
+
type CurrentMatchViews<TMatches extends CreatedRouteOptions[]> = LastInArray<TMatches> extends {
|
|
72
|
+
views: infer TViews extends RouteViews;
|
|
73
|
+
} ? TViews : RouteViews;
|
|
74
|
+
/**
|
|
75
|
+
* Computes the new views after adding a view, replacing any view already stored under the same name.
|
|
76
|
+
*/
|
|
77
|
+
export type AddViewProps<TCurrent extends RouteViews, TName extends string | undefined, TNewProps> = Identity<Omit<TCurrent, ViewName<TName>> & Record<ViewName<TName>, [TNewProps] extends [undefined] ? RouteView : RouteView<TNewProps>>> extends infer TNext extends RouteViews ? TNext : TCurrent;
|
|
78
|
+
type ViewName<TName extends string | undefined> = TName extends string ? TName : 'default';
|
|
79
|
+
/**
|
|
80
|
+
* Replaces the views on the last match, preserving all ancestors.
|
|
81
|
+
*/
|
|
82
|
+
type ReplaceLastMatchViews<TMatches extends CreatedRouteOptions[], TNewViews extends RouteViews> = TMatches extends [...infer THead extends CreatedRouteOptions[], infer TLast extends CreatedRouteOptions] ? Identity<Omit<TLast, 'views'> & {
|
|
83
|
+
views: TNewViews;
|
|
84
|
+
}> extends infer TNext extends CreatedRouteOptions ? [...THead, TNext] : TMatches : TMatches;
|
|
85
|
+
/**
|
|
86
|
+
* The full return type of an `addView` call: the same url with the last match's views replaced.
|
|
87
|
+
*/
|
|
88
|
+
type AddViewReturn<TUrl extends Url, TMatches extends CreatedRouteOptions[], TNewProps extends RouteViews> = ReplaceLastMatchViews<TMatches, TNewProps> extends infer TNext extends CreatedRouteOptions[] ? RouteWithMethods<TUrl, TNext> : never;
|
|
89
|
+
/**
|
|
90
|
+
* Adds a view (component + optional props getter) to a route. Chainable to register multiple views,
|
|
91
|
+
* including named views for named `<router-view />`s.
|
|
92
|
+
*/
|
|
93
|
+
export type RouteAddView<TUrl extends Url = Url, TMatches extends CreatedRouteOptions[] = CreatedRouteOptions[]> = {
|
|
94
|
+
/**
|
|
95
|
+
* Adds a view for this route.
|
|
96
|
+
*
|
|
97
|
+
* @param component - The component to render. Rendered by `<router-view name="..." />` when the
|
|
98
|
+
* options carry a name, and by the default `<router-view />` otherwise.
|
|
99
|
+
* @param options - The view's `name`, `props` getter, and `prefetch` config. Required when the
|
|
100
|
+
* component has required props, optional otherwise.
|
|
101
|
+
*/
|
|
102
|
+
addView: <TComponent extends Component, const TName extends string | undefined = undefined, const TGetter extends AddViewPropsGetter<Route<TUrl, TMatches>, TComponent> = AddViewPropsGetter<Route<TUrl, TMatches>, TComponent>>(component: TComponent, ...options: AddViewArgs<TComponent, TName, TGetter>) => AddViewReturn<TUrl, TMatches, AddViewProps<CurrentMatchViews<TMatches>, TName, NewViewProps<Route<TUrl, TMatches>, TComponent, TGetter>>>;
|
|
103
|
+
};
|
|
104
|
+
export {};
|
|
@@ -1,22 +1,20 @@
|
|
|
1
1
|
import { Component } from 'vue';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import { ToUrl } from '../../types/url';
|
|
19
|
-
import { CombineUrl } from '../../services/combineUrl';
|
|
2
|
+
import { Param } from './paramTypes';
|
|
3
|
+
import { PrefetchConfig } from './prefetch';
|
|
4
|
+
import { RouteMeta } from './register';
|
|
5
|
+
import { Route } from './route';
|
|
6
|
+
import { ResolvedRoute, WithData } from './resolved';
|
|
7
|
+
import { ComponentProps } from '../services/component';
|
|
8
|
+
import { PropsCallbackContext } from './props';
|
|
9
|
+
import { AnyFunction, Identity, MaybePromise } from './utilities';
|
|
10
|
+
import { ToMeta } from './meta';
|
|
11
|
+
import { ToName } from './name';
|
|
12
|
+
import { UrlPart, UrlQueryPart } from '../services/withParams';
|
|
13
|
+
import { RouteContext } from './routeContext';
|
|
14
|
+
import { RouterViewProps } from '../components/routerView';
|
|
15
|
+
import { ToUrl } from './url';
|
|
16
|
+
import { CombineUrl } from '../services/combineUrl';
|
|
17
|
+
import { RouteView } from './routeViews';
|
|
20
18
|
export type WithHost<THost extends string | UrlPart = string | UrlPart> = {
|
|
21
19
|
/**
|
|
22
20
|
* Host part of URL.
|
|
@@ -44,15 +42,9 @@ type WithoutComponents = {
|
|
|
44
42
|
export declare function isWithComponent<T extends Record<string, unknown>>(options: T): options is T & {
|
|
45
43
|
component: Component;
|
|
46
44
|
};
|
|
47
|
-
export declare function isWithComponentProps<T extends Record<string, unknown>>(options: T): options is T & {
|
|
48
|
-
props: PropsGetter;
|
|
49
|
-
};
|
|
50
45
|
export declare function isWithComponents<T extends Record<string, unknown>>(options: T): options is T & {
|
|
51
46
|
components: Record<string, Component>;
|
|
52
47
|
};
|
|
53
|
-
export declare function isWithComponentPropsRecord<T extends Record<string, unknown>>(options: T): options is T & {
|
|
54
|
-
props: RoutePropsRecord;
|
|
55
|
-
};
|
|
56
48
|
export type CreateRouteOptions<TName extends string | undefined = string | undefined, TMeta extends RouteMeta = RouteMeta> = {
|
|
57
49
|
/**
|
|
58
50
|
* Name for route, used to create route keys and in navigation.
|
|
@@ -90,10 +82,13 @@ export type CreateRouteOptions<TName extends string | undefined = string | undef
|
|
|
90
82
|
* An optional component to render when this route is matched.
|
|
91
83
|
*
|
|
92
84
|
* @default RouterView
|
|
85
|
+
* @deprecated Use the chainable `addView` method on the route instead: `createRoute({ ... }).addView(component, { props })`.
|
|
93
86
|
*/
|
|
94
87
|
component?: Component;
|
|
95
88
|
/**
|
|
96
89
|
* An object of named components to render using named views
|
|
90
|
+
*
|
|
91
|
+
* @deprecated Use the chainable `addView` method on the route instead: `createRoute({ ... }).addView(component, { name, props })`.
|
|
97
92
|
*/
|
|
98
93
|
components?: Record<string, Component>;
|
|
99
94
|
/**
|
|
@@ -105,32 +100,58 @@ export type CreateRouteOptions<TName extends string | undefined = string | undef
|
|
|
105
100
|
*/
|
|
106
101
|
hoist?: boolean;
|
|
107
102
|
};
|
|
108
|
-
export type PropsGetter<TOptions extends CreateRouteOptions = CreateRouteOptions, TComponent extends Component = Component> = (route: ResolvedRoute<ToRoute<TOptions>>, context: PropsCallbackContext<ToRoute<TOptions>, TOptions>) => MaybePromise<ComponentProps<TComponent>>;
|
|
109
|
-
export type RouterViewPropsGetter<TOptions extends CreateRouteOptions = CreateRouteOptions> = (route: ResolvedRoute<ToRoute<TOptions>>, context: PropsCallbackContext<ToRoute<TOptions>, TOptions>) => MaybePromise<RouterViewProps & Record<string, unknown>>;
|
|
110
|
-
type ComponentPropsAreOptional<TComponent extends Component> = Partial<ComponentProps<TComponent>> extends ComponentProps<TComponent> ? true : false;
|
|
103
|
+
export type PropsGetter<TOptions extends CreateRouteOptions = CreateRouteOptions, TComponent extends Component = Component> = (route: ResolvedRoute<ToRoute<TOptions>> & WithData<ToRoute<TOptions>>, context: PropsCallbackContext<ToRoute<TOptions>, TOptions>) => MaybePromise<ComponentProps<TComponent>>;
|
|
104
|
+
export type RouterViewPropsGetter<TOptions extends CreateRouteOptions = CreateRouteOptions> = (route: ResolvedRoute<ToRoute<TOptions>> & WithData<ToRoute<TOptions>>, context: PropsCallbackContext<ToRoute<TOptions>, TOptions>) => MaybePromise<RouterViewProps & Record<string, unknown>>;
|
|
105
|
+
export type ComponentPropsAreOptional<TComponent extends Component> = Partial<ComponentProps<TComponent>> extends ComponentProps<TComponent> ? true : false;
|
|
111
106
|
type RoutePropsRecord<TOptions extends CreateRouteOptions = CreateRouteOptions, TComponents extends Record<string, Component> = Record<string, Component>> = {
|
|
112
107
|
[K in keyof TComponents as ComponentPropsAreOptional<TComponents[K]> extends true ? K : never]?: PropsGetter<TOptions, TComponents[K]>;
|
|
113
108
|
} & {
|
|
114
109
|
[K in keyof TComponents as ComponentPropsAreOptional<TComponents[K]> extends false ? K : never]: PropsGetter<TOptions, TComponents[K]>;
|
|
115
110
|
};
|
|
116
111
|
export type CreateRouteProps<TOptions extends CreateRouteOptions = CreateRouteOptions> = TOptions['component'] extends Component ? PropsGetter<TOptions, TOptions['component']> : TOptions['components'] extends Record<string, Component> ? RoutePropsRecord<TOptions, TOptions['components']> : RouterViewPropsGetter<TOptions>;
|
|
117
|
-
type ToMatch<TOptions extends CreateRouteOptions, TProps> = Omit<TOptions, '
|
|
112
|
+
type ToMatch<TOptions extends CreateRouteOptions, TProps = undefined> = Omit<TOptions, 'meta' | 'name' | 'component' | 'components' | 'parent'> & {
|
|
118
113
|
id: string;
|
|
119
114
|
name: ToName<TOptions['name']>;
|
|
120
|
-
props: TProps;
|
|
121
115
|
/**
|
|
122
116
|
* Represents additional metadata associated with a route. Always present, defaults to empty object.
|
|
123
117
|
*/
|
|
124
118
|
meta: ToMeta<TOptions['meta']>;
|
|
119
|
+
/**
|
|
120
|
+
* The views this route renders, keyed by view name.
|
|
121
|
+
*/
|
|
122
|
+
views: PropsToViews<TProps>;
|
|
123
|
+
/**
|
|
124
|
+
* The loaders this route runs, keyed by loader name. Always empty here — loaders are only added via
|
|
125
|
+
* the route's `addLoader`.
|
|
126
|
+
*/
|
|
127
|
+
loaders: {};
|
|
125
128
|
};
|
|
126
|
-
|
|
129
|
+
/**
|
|
130
|
+
* The matches for a route, from greatest ancestor to the route itself. Each carries its own views, so
|
|
131
|
+
* there is no second tuple to keep aligned with this one.
|
|
132
|
+
*/
|
|
133
|
+
type ToMatches<TOptions extends CreateRouteOptions, TProps = undefined> = TOptions extends {
|
|
127
134
|
parent: infer TParent extends Route;
|
|
128
|
-
} ? [...TParent['matches'], ToMatch<TOptions, TProps>] : [ToMatch<
|
|
129
|
-
|
|
135
|
+
} ? [...TParent['matches'], ToMatch<TOptions, TProps>] : [ToMatch<TOptions, TProps>];
|
|
136
|
+
/**
|
|
137
|
+
* Builds a views record from the props argument, which is either a single getter for the unnamed view or
|
|
138
|
+
* a record of getters keyed by view name.
|
|
139
|
+
*/
|
|
140
|
+
type PropsToViews<TProps> = [TProps] extends [AnyFunction] ? {
|
|
141
|
+
default: RouteView<ReturnType<TProps>>;
|
|
142
|
+
} : [TProps] extends [Record<string, AnyFunction>] ? {
|
|
143
|
+
[K in keyof TProps]: RouteView<ReturnType<TProps[K]>>;
|
|
144
|
+
} : {};
|
|
145
|
+
/**
|
|
146
|
+
* The url a route resolves to, combined with its parent's unless the route is hoisted.
|
|
147
|
+
*/
|
|
148
|
+
export type ToRouteUrl<TOptions extends CreateRouteOptions> = TOptions extends {
|
|
130
149
|
parent: infer TParent extends Route;
|
|
131
|
-
} ?
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
150
|
+
} ? TOptions['hoist'] extends true ? ToUrl<TOptions & WithoutComponents> : CombineUrl<TParent, ToUrl<TOptions & WithoutComponents>> : ToUrl<Identity<TOptions & WithoutComponents>>;
|
|
151
|
+
/**
|
|
152
|
+
* The matches for a route, with the props argument resolved to the views of its own match.
|
|
153
|
+
*/
|
|
154
|
+
export type ToRouteMatches<TOptions extends CreateRouteOptions, TProps> = ToMatches<TOptions, CreateRouteProps<TOptions> extends TProps ? undefined : TProps>;
|
|
155
|
+
export type ToRoute<TOptions extends CreateRouteOptions, TProps extends CreateRouteProps<TOptions> | undefined = undefined> = CreateRouteOptions extends TOptions ? Route : Route<ToRouteUrl<TOptions>, ToRouteMatches<TOptions, TProps>>;
|
|
135
156
|
export declare function combineRoutes(parent: Route, child: Route): Route;
|
|
136
157
|
export {};
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { Hooks } from '
|
|
2
|
-
import { ResolvedRoute, RouterResolvedRouteUnion, ResolvedRouteUnion } from '
|
|
3
|
-
import { MaybePromise } from '
|
|
4
|
-
import { Route, Routes } from '
|
|
5
|
-
import { RouterReject } from '
|
|
6
|
-
import { RouterPush } from '
|
|
7
|
-
import { RouterReplace } from '
|
|
8
|
-
import { Rejection, Rejections } from '
|
|
9
|
-
import { RouteContext, RouteContextToRejection, RouteContextToRoute } from '
|
|
10
|
-
import { RouterAbort } from '
|
|
11
|
-
import { CallbackContextAbort, CallbackContextPush, CallbackContextReject, CallbackContextSuccess } from '
|
|
12
|
-
import { RouteUpdate } from '
|
|
1
|
+
import { Hooks } from '../models/hooks';
|
|
2
|
+
import { ResolvedRoute, RouterResolvedRouteUnion, ResolvedRouteUnion } from './resolved';
|
|
3
|
+
import { MaybePromise } from './utilities';
|
|
4
|
+
import { Route, Routes } from './route';
|
|
5
|
+
import { RouterReject } from './routerReject';
|
|
6
|
+
import { RouterPush } from './routerPush';
|
|
7
|
+
import { RouterReplace } from './routerReplace';
|
|
8
|
+
import { Rejection, Rejections } from './rejection';
|
|
9
|
+
import { RouteContext, RouteContextToRejection, RouteContextToRoute } from './routeContext';
|
|
10
|
+
import { RouterAbort } from './routerAbort';
|
|
11
|
+
import { CallbackContextAbort, CallbackContextPush, CallbackContextReject, CallbackContextSuccess } from './callbackContext';
|
|
12
|
+
import { RouteUpdate } from './routeUpdate';
|
|
13
13
|
export declare function getHooks(value: Record<string, unknown> | undefined | null): Hooks[];
|
|
14
14
|
export declare function combineHooks(parent: Route, child: Route): Hooks[];
|
|
15
15
|
export type InternalRouteHooks<TRoute extends Route = Route, TContext extends RouteContext[] | undefined = undefined> = {
|
|
@@ -150,7 +150,7 @@ export type RejectionHookRunner<TRejection extends Rejection = Rejection, TRoute
|
|
|
150
150
|
export type ErrorHookContext<TRoute extends Route = Route, TRoutes extends Routes = Routes, TRejections extends Rejections = Rejections> = {
|
|
151
151
|
to: RouterResolvedRouteUnion<TRoutes>;
|
|
152
152
|
from: RouterResolvedRouteUnion<TRoutes> | null;
|
|
153
|
-
source: 'props' | 'hook' | 'component';
|
|
153
|
+
source: 'props' | 'loader' | 'hook' | 'component';
|
|
154
154
|
reject: RouterReject<TRejections>;
|
|
155
155
|
push: RouterPush<TRoutes>;
|
|
156
156
|
replace: RouterReplace<TRoutes>;
|
|
@@ -161,7 +161,7 @@ export type AddErrorHook<TRoute extends Route = Route, TRoutes extends Routes =
|
|
|
161
161
|
export type ErrorHookRunnerContext<TRoutes extends Routes = Routes> = {
|
|
162
162
|
to: RouterResolvedRouteUnion<TRoutes>;
|
|
163
163
|
from: RouterResolvedRouteUnion<TRoutes> | null;
|
|
164
|
-
source: 'props' | 'hook';
|
|
164
|
+
source: 'props' | 'loader' | 'hook';
|
|
165
165
|
};
|
|
166
166
|
export type ErrorHookRunner = (error: unknown, context: ErrorHookRunnerContext) => void;
|
|
167
167
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ValibotSchemaLike } from '
|
|
2
|
-
import { ZodSchemaLike } from '
|
|
1
|
+
import { ValibotSchemaLike } from '../services/valibot';
|
|
2
|
+
import { ZodSchemaLike } from '../services/zod';
|
|
3
3
|
export type ParamExtras = {
|
|
4
4
|
invalid: (message?: string) => never;
|
|
5
5
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LiteralParam, Param, ParamGetSet, ParamGetter } from '
|
|
1
|
+
import { LiteralParam, Param, ParamGetSet, ParamGetter } from './paramTypes';
|
|
2
2
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
3
3
|
export declare const paramStart = "[";
|
|
4
4
|
export type ParamStart = typeof paramStart;
|