@kitbag/router 0.24.3 → 0.26.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 +3 -3
- package/dist/compositions/useHasSuspenseBoundary.d.ts +4 -0
- package/dist/compositions/useIsServerRendering.d.ts +5 -0
- package/dist/compositions/useRouteValueStore.d.ts +7 -0
- package/dist/errors/contextRedirectError.d.ts +7 -0
- package/dist/errors/loaderDataAccessError.d.ts +8 -0
- package/dist/errors/loaderNameConflict.d.ts +9 -0
- package/dist/errors/navigationAbandonedError.d.ts +7 -0
- package/dist/errors/payloadValueError.d.ts +9 -0
- package/dist/errors/ssrOptionRequiredError.d.ts +7 -0
- package/dist/errors/unsupportedSchemaVendorError.d.ts +7 -0
- package/dist/errors/updateWithoutRouteError.d.ts +7 -0
- package/dist/kitbag-router.d.ts +1 -1
- package/dist/kitbag-router.js +2262 -1764
- package/dist/kitbag-router.umd.cjs +5 -4
- package/dist/{src/main.d.ts → main.d.ts} +10 -0
- package/dist/services/addLoader.d.ts +43 -0
- package/dist/services/addView.d.ts +40 -0
- package/dist/{src/services → services}/component.d.ts +2 -3
- package/dist/services/createActivityTracker.d.ts +6 -0
- package/dist/{src/services → services}/createComponentsStore.d.ts +2 -2
- package/dist/{src/services → services}/createCurrentRejection.d.ts +0 -3
- package/dist/services/createCurrentRoute.d.ts +25 -0
- package/dist/services/createDataStore.d.ts +48 -0
- package/dist/services/createNavigationIds.d.ts +6 -0
- package/dist/services/createNavigationStores.d.ts +36 -0
- package/dist/services/createRejection.d.ts +4 -0
- package/dist/{src/services → services}/createRoute.d.ts +3 -6
- package/dist/{src/services → services}/createRouteHooks.d.ts +1 -1
- package/dist/services/createRouteValueStore.d.ts +88 -0
- package/dist/services/createRouteViews.d.ts +16 -0
- package/dist/{src/services → services}/createRouterCallbackContext.d.ts +1 -1
- package/dist/{src/services → services}/createRouterRoute.d.ts +2 -2
- package/dist/services/createServerRedirect.d.ts +14 -0
- package/dist/services/getComputations.d.ts +40 -0
- package/dist/services/getGlobalRouteHooks.d.ts +4 -0
- package/dist/{src/services → services}/getRouteHooks.d.ts +2 -2
- package/dist/{src/services → services}/getRoutesForRouter.d.ts +3 -2
- package/dist/{src/services → services}/hooks.d.ts +1 -1
- package/dist/services/payload.d.ts +86 -0
- package/dist/services/standardSchema.d.ts +21 -0
- package/dist/{src/services → services}/urlParser.d.ts +5 -0
- package/dist/services/withRouteMethods.d.ts +7 -0
- package/dist/services/zod.spec.d.ts +1 -0
- package/dist/tests/hooks.spec.d.ts +1 -0
- package/dist/tests/hydration.browser.spec.d.ts +1 -0
- package/dist/tests/render.spec.d.ts +1 -0
- package/dist/tests/routeLoaders.browser.spec.d.ts +1 -0
- package/dist/tests/routeLoaders.spec.d.ts +1 -0
- package/dist/tests/routeProps.browser.spec.d.ts +1 -0
- package/dist/tests/routeProps.spec.d.ts +1 -0
- package/dist/types/addLoader.d.ts +70 -0
- package/dist/types/addView.d.ts +109 -0
- package/dist/{src/types → types}/callbackContext.d.ts +9 -0
- package/dist/{src/types → types}/createRouteOptions.d.ts +45 -24
- package/dist/{src/types → types}/hooks.d.ts +16 -17
- package/dist/{src/types → types}/paramTypes.d.ts +2 -3
- 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 +12 -4
- package/dist/{src/types → types}/redirects.d.ts +11 -3
- package/dist/types/redirects.spec-d.d.ts +1 -0
- package/dist/types/register.spec.d.ts +1 -0
- package/dist/{src/types → types}/rejection.d.ts +24 -4
- package/dist/{src/types → types}/resolved.d.ts +25 -4
- package/dist/types/resolved.spec-d.d.ts +1 -0
- package/dist/types/route.d.ts +121 -0
- package/dist/types/route.spec-d.d.ts +1 -0
- package/dist/types/routeCallbackContext.d.ts +30 -0
- package/dist/types/routeLoaders.d.ts +32 -0
- package/dist/types/routeTitle.browser.spec.d.ts +1 -0
- package/dist/{src/types → types}/routeTitle.d.ts +2 -1
- package/dist/types/routeViews.d.ts +46 -0
- package/dist/types/routeWithMethods.d.ts +16 -0
- package/dist/types/routeWithParams.spec-d.d.ts +1 -0
- package/dist/{src/types → types}/router.d.ts +95 -3
- package/dist/{src/types → types}/routerPlugin.d.ts +8 -4
- package/dist/types/routerReject.d.ts +15 -0
- package/dist/{src/types → types}/routerRoute.d.ts +7 -1
- package/dist/types/routesMap.spec-ts.d.ts +1 -0
- package/dist/types/serverRenderResponse.spec-d.d.ts +1 -0
- package/dist/{src/types → types}/utilities.d.ts +1 -0
- package/dist/utilities/checkDuplicateNames.spec.d.ts +1 -0
- package/dist/utilities/checkDuplicateParams.spec.d.ts +1 -0
- package/dist/utilities/components.d.ts +18 -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}/prefetch.d.ts +1 -1
- package/dist/utilities/prefetch.spec.d.ts +1 -0
- package/dist/utilities/props.d.ts +16 -0
- package/dist/utilities/setDocumentTitle.d.ts +1 -0
- package/dist/utilities/testHelpers.d.ts +242 -0
- package/dist/utilities/trailingSlashes.spec.d.ts +1 -0
- package/dist/utilities/urlSearchParams.spec.d.ts +1 -0
- package/package.json +17 -22
- 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/createRejection.d.ts +0 -8
- package/dist/src/services/getGlobalRouteHooks.d.ts +0 -4
- package/dist/src/services/valibot.d.ts +0 -7
- package/dist/src/services/zod.d.ts +0 -11
- package/dist/src/types/route.d.ts +0 -80
- package/dist/src/types/routerReject.d.ts +0 -2
- package/dist/src/utilities/components.d.ts +0 -6
- package/dist/src/utilities/props.d.ts +0 -6
- package/dist/src/utilities/setDocumentTitle.d.ts +0 -2
- 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.d.ts +0 -0
- /package/dist/{src/components → components}/routerView.spec.d.ts +0 -0
- /package/dist/{src/compositions → compositions}/useComponentsStore.d.ts +0 -0
- /package/dist/{src/compositions → compositions}/useEventListener.d.ts +0 -0
- /package/dist/{src/compositions/useQueryValue.browser.spec.d.ts → compositions/useHasSuspenseBoundary.browser.spec.d.ts} +0 -0
- /package/dist/{src/compositions/useQueryValue.spec-d.d.ts → compositions/useIsServerRendering.browser.spec.d.ts} +0 -0
- /package/dist/{src/compositions/useRoute.browser.spec.d.ts → compositions/useIsServerRendering.spec.d.ts} +0 -0
- /package/dist/{src/compositions → compositions}/useLink.d.ts +0 -0
- /package/dist/{src/compositions → compositions}/usePrefetching.d.ts +0 -0
- /package/dist/{src/compositions/useRoute.spec-d.d.ts → compositions/useQueryValue.browser.spec.d.ts} +0 -0
- /package/dist/{src/compositions → compositions}/useQueryValue.d.ts +0 -0
- /package/dist/{src/guards/routes.spec-d.d.ts → compositions/useQueryValue.spec-d.d.ts} +0 -0
- /package/dist/{src/compositions → compositions}/useRejection.d.ts +0 -0
- /package/dist/{src/services/arrayOf.spec.d.ts → compositions/useRoute.browser.spec.d.ts} +0 -0
- /package/dist/{src/compositions → compositions}/useRoute.d.ts +0 -0
- /package/dist/{src/services/combineHash.spec.d.ts → compositions/useRoute.spec-d.d.ts} +0 -0
- /package/dist/{src/compositions → compositions}/useRouter.d.ts +0 -0
- /package/dist/{src/compositions → compositions}/useRouterDepth.d.ts +0 -0
- /package/dist/{src/compositions → compositions}/useRouterHooks.d.ts +0 -0
- /package/dist/{src/compositions → compositions}/useVisibilityObserver.d.ts +0 -0
- /package/dist/{src/devtools → devtools}/createRouterDevtools.d.ts +0 -0
- /package/dist/{src/devtools → devtools}/filters.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}/contextAbortError.d.ts +0 -0
- /package/dist/{src/errors → errors}/contextError.d.ts +0 -0
- /package/dist/{src/errors → errors}/contextPushError.d.ts +0 -0
- /package/dist/{src/errors → errors}/contextRejectionError.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}/invalidRouteParamValueError.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.d.ts +0 -0
- /package/dist/{src/services/combineMeta.spec.d.ts → guards/routes.spec-d.d.ts} +0 -0
- /package/dist/{src/keys.d.ts → keys.d.ts} +0 -0
- /package/dist/{src/models → models}/hooks.d.ts +0 -0
- /package/dist/{src/services/combinePath.spec-d.d.ts → services/addLoader.spec-d.d.ts} +0 -0
- /package/dist/{src/services/combinePath.spec.d.ts → services/addLoader.spec.d.ts} +0 -0
- /package/dist/{src/services/combineQuery.spec.d.ts → services/addView.browser.spec.d.ts} +0 -0
- /package/dist/{src/services/combineState.spec.d.ts → services/addView.spec-d.d.ts} +0 -0
- /package/dist/{src/services/combineUrl.spec.d.ts → services/addView.spec.d.ts} +0 -0
- /package/dist/{src/services/component.browser.spec.d.ts → services/arktype.spec-d.d.ts} +0 -0
- /package/dist/{src/services/createExternalRoute.spec.d.ts → services/arktype.spec.d.ts} +0 -0
- /package/dist/{src/services → services}/arrayOf.d.ts +0 -0
- /package/dist/{src/services/createIsExternal.spec.d.ts → services/arrayOf.spec.d.ts} +0 -0
- /package/dist/{src/services → services}/combineHash.d.ts +0 -0
- /package/dist/{src/services/createResolvedRoute.spec.d.ts → services/combineHash.spec.d.ts} +0 -0
- /package/dist/{src/services → services}/combineMeta.d.ts +0 -0
- /package/dist/{src/services/createRoute.spec-d.d.ts → services/combineMeta.spec.d.ts} +0 -0
- /package/dist/{src/services → services}/combinePath.d.ts +0 -0
- /package/dist/{src/services/createRoute.spec.d.ts → services/combinePath.spec-d.d.ts} +0 -0
- /package/dist/{src/services/createRouteRedirects.spec.d.ts → services/combinePath.spec.d.ts} +0 -0
- /package/dist/{src/services → services}/combineQuery.d.ts +0 -0
- /package/dist/{src/services/createRouter.browser.spec.d.ts → services/combineQuery.spec.d.ts} +0 -0
- /package/dist/{src/services → services}/combineState.d.ts +0 -0
- /package/dist/{src/services/createRouter.spec-d.d.ts → services/combineState.spec.d.ts} +0 -0
- /package/dist/{src/services → services}/combineUrl.d.ts +0 -0
- /package/dist/{src/services/createRouter.spec.d.ts → services/combineUrl.spec.d.ts} +0 -0
- /package/dist/{src/services/createRouterHistory.browser.spec.d.ts → services/component.browser.spec.d.ts} +0 -0
- /package/dist/{src/services/createRouterPlugin.browser.spec.d.ts → services/createActivityTracker.spec.d.ts} +0 -0
- /package/dist/{src/services → services}/createComponentHooks.d.ts +0 -0
- /package/dist/{src/services/createRouterPlugin.spec-d.d.ts → services/createDataStore.spec.d.ts} +0 -0
- /package/dist/{src/services → services}/createExternalRoute.d.ts +0 -0
- /package/dist/{src/services/createRouterRoute.spec.d.ts → services/createExternalRoute.spec.d.ts} +0 -0
- /package/dist/{src/services → services}/createIsExternal.d.ts +0 -0
- /package/dist/{src/services/createUrl.spec.d.ts → services/createIsExternal.spec.d.ts} +0 -0
- /package/dist/{src/services/getInitialUrl.browser.spec.d.ts → services/createNavigationIds.spec.d.ts} +0 -0
- /package/dist/{src/services/getInitialUrl.spec.d.ts → services/createNavigationStores.spec.d.ts} +0 -0
- /package/dist/{src/services → services}/createParam.d.ts +0 -0
- /package/dist/{src/services/getMatchesForUrl.spec.d.ts → services/createRejection.spec-d.d.ts} +0 -0
- /package/dist/{src/services/getRouteHooks.spec.d.ts → services/createRejection.spec.d.ts} +0 -0
- /package/dist/{src/services → services}/createRejectionHooks.d.ts +0 -0
- /package/dist/{src/services → services}/createResolvedRoute.d.ts +0 -0
- /package/dist/{src/services/getRoutesForRouter.spec.d.ts → services/createResolvedRoute.spec.d.ts} +0 -0
- /package/dist/{src/services → services}/createResolvedRouteQuery.d.ts +0 -0
- /package/dist/{src/services/history.browser.spec.d.ts → services/createRoute.spec-d.d.ts} +0 -0
- /package/dist/{src/services/hooks.browser.spec.d.ts → services/createRoute.spec.d.ts} +0 -0
- /package/dist/{src/services → services}/createRouteId.d.ts +0 -0
- /package/dist/{src/services → services}/createRouteRedirects.d.ts +0 -0
- /package/dist/{src/services/hooks.spec.d.ts → services/createRouteRedirects.spec.d.ts} +0 -0
- /package/dist/{src/services/insertBaseRoute.spec.d.ts → services/createRouteValueStore.spec.d.ts} +0 -0
- /package/dist/{src/services/params.spec.d.ts → services/createRouter.browser.spec.d.ts} +0 -0
- /package/dist/{src/services → services}/createRouter.d.ts +0 -0
- /package/dist/{src/services/paramsFinder.spec.d.ts → services/createRouter.spec-d.d.ts} +0 -0
- /package/dist/{src/services/queryParamFilter.spec.d.ts → services/createRouter.spec.d.ts} +0 -0
- /package/dist/{src/services → services}/createRouterAssets.d.ts +0 -0
- /package/dist/{src/services/routeRegex.spec.d.ts → services/createRouterHistory.browser.spec.d.ts} +0 -0
- /package/dist/{src/services → services}/createRouterHistory.d.ts +0 -0
- /package/dist/{src/services/state.spec.d.ts → services/createRouterHistory.spec.d.ts} +0 -0
- /package/dist/{src/services → services}/createRouterHooks.d.ts +0 -0
- /package/dist/{src/services → services}/createRouterKeyStore.d.ts +0 -0
- /package/dist/{src/services/tupleOf.spec.d.ts → services/createRouterPlugin.browser.spec.d.ts} +0 -0
- /package/dist/{src/services → services}/createRouterPlugin.d.ts +0 -0
- /package/dist/{src/services/unionOf.spec.d.ts → services/createRouterPlugin.spec-d.d.ts} +0 -0
- /package/dist/{src/services/urlParser.spec.d.ts → services/createRouterRoute.spec.d.ts} +0 -0
- /package/dist/{src/services/valibot.spec-d.d.ts → services/createServerRedirect.spec.d.ts} +0 -0
- /package/dist/{src/services → services}/createUniqueIdSequence.d.ts +0 -0
- /package/dist/{src/services → services}/createUrl.d.ts +0 -0
- /package/dist/{src/services/valibot.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 → services}/getGlobalHooksForRouter.d.ts +0 -0
- /package/dist/{src/services/withParams.spec-d.d.ts → services/getInitialUrl.browser.spec.d.ts} +0 -0
- /package/dist/{src/services → services}/getInitialUrl.d.ts +0 -0
- /package/dist/{src/services/withParams.spec.d.ts → services/getInitialUrl.spec.d.ts} +0 -0
- /package/dist/{src/services → services}/getMatchesForUrl.d.ts +0 -0
- /package/dist/{src/services/zod.spec-d.d.ts → services/getMatchesForUrl.spec.d.ts} +0 -0
- /package/dist/{src/services → services}/getParamsForString.d.ts +0 -0
- /package/dist/{src/services → services}/getRejectionHooks.d.ts +0 -0
- /package/dist/{src/services/zod.spec.d.ts → services/getRouteHooks.spec.d.ts} +0 -0
- /package/dist/{src/tests/hooks.spec.d.ts → services/getRoutesForRouter.spec.d.ts} +0 -0
- /package/dist/{src/tests/routeProps.browser.spec.d.ts → services/history.browser.spec.d.ts} +0 -0
- /package/dist/{src/services → services}/history.d.ts +0 -0
- /package/dist/{src/tests/routeProps.spec.d.ts → services/hooks.browser.spec.d.ts} +0 -0
- /package/dist/{src/types/redirects.spec-d.d.ts → services/hooks.spec.d.ts} +0 -0
- /package/dist/{src/services → services}/insertBaseRoute.d.ts +0 -0
- /package/dist/{src/types/register.spec.d.ts → services/insertBaseRoute.spec.d.ts} +0 -0
- /package/dist/{src/services → services}/literal.d.ts +0 -0
- /package/dist/{src/services → services}/params.d.ts +0 -0
- /package/dist/{src/types/resolved.spec-d.d.ts → services/params.spec.d.ts} +0 -0
- /package/dist/{src/services → services}/paramsFinder.d.ts +0 -0
- /package/dist/{src/types/route.spec-d.d.ts → services/paramsFinder.spec.d.ts} +0 -0
- /package/dist/{src/types/routeTitle.browser.spec.d.ts → services/payload.spec.d.ts} +0 -0
- /package/dist/{src/services → services}/queryParamFilter.d.ts +0 -0
- /package/dist/{src/types/routeWithParams.spec-d.d.ts → services/queryParamFilter.spec.d.ts} +0 -0
- /package/dist/{src/services → services}/routeRegex.d.ts +0 -0
- /package/dist/{src/types/routesMap.spec-ts.d.ts → services/routeRegex.spec.d.ts} +0 -0
- /package/dist/{src/services → services}/state.d.ts +0 -0
- /package/dist/{src/utilities/checkDuplicateNames.spec.d.ts → services/state.spec.d.ts} +0 -0
- /package/dist/{src/services → services}/tupleOf.d.ts +0 -0
- /package/dist/{src/utilities/checkDuplicateParams.spec.d.ts → services/tupleOf.spec.d.ts} +0 -0
- /package/dist/{src/services → services}/unionOf.d.ts +0 -0
- /package/dist/{src/utilities/components.spec.d.ts → services/unionOf.spec.d.ts} +0 -0
- /package/dist/{src/utilities/guards.spec.d.ts → services/urlParser.spec.d.ts} +0 -0
- /package/dist/{src/utilities/isBrowser.browser.spec.d.ts → services/valibot.spec-d.d.ts} +0 -0
- /package/dist/{src/utilities/isBrowser.spec.d.ts → services/valibot.spec.d.ts} +0 -0
- /package/dist/{src/services → services}/withDefault.d.ts +0 -0
- /package/dist/{src/services → services}/withParams.d.ts +0 -0
- /package/dist/{src/utilities/prefetch.spec.d.ts → services/withParams.spec-d.d.ts} +0 -0
- /package/dist/{src/utilities/trailingSlashes.spec.d.ts → services/withParams.spec.d.ts} +0 -0
- /package/dist/{src/utilities/urlSearchParams.spec.d.ts → services/zod.spec-d.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}/register.d.ts +0 -0
- /package/dist/{src/types → types}/routeContext.d.ts +0 -0
- /package/dist/{src/types → types}/routeUpdate.d.ts +0 -0
- /package/dist/{src/types → types}/routeWithParams.d.ts +0 -0
- /package/dist/{src/types → types}/routerAbort.d.ts +0 -0
- /package/dist/{src/types → types}/routerLink.d.ts +0 -0
- /package/dist/{src/types → types}/routerPush.d.ts +0 -0
- /package/dist/{src/types → types}/routerReplace.d.ts +0 -0
- /package/dist/{src/types → types}/routerResolve.d.ts +0 -0
- /package/dist/{src/types → types}/routesMap.d.ts +0 -0
- /package/dist/{src/types → types}/state.d.ts +0 -0
- /package/dist/{src/types → types}/url.d.ts +0 -0
- /package/dist/{src/types → types}/urlString.d.ts +0 -0
- /package/dist/{src/types → types}/useLink.d.ts +0 -0
- /package/dist/{src/utilities → utilities}/array.d.ts +0 -0
- /package/dist/{src/utilities → utilities}/checkDuplicateNames.d.ts +0 -0
- /package/dist/{src/utilities → utilities}/checkDuplicateParams.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}/isNamedRoute.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
- /package/dist/{src/utilities → utilities}/urlSearchParams.d.ts +0 -0
|
@@ -1,7 +1,14 @@
|
|
|
1
|
-
import { Route, Routes } from './route';
|
|
1
|
+
import { CreatedRouteOptions, Route, RouteDataOf, Routes } from './route';
|
|
2
|
+
import { LastInArray } from './utilities';
|
|
2
3
|
import { ExtractRouteStateParamsAsOptional } from './state';
|
|
3
4
|
import { UrlString } from './urlString';
|
|
4
5
|
import { UrlParamsReading } from './url';
|
|
6
|
+
import { GetTitleCallback } from './routeTitle';
|
|
7
|
+
/**
|
|
8
|
+
* The match a route resolved to, which is the last of its matches. Falls back to the wide match type when
|
|
9
|
+
* the matches are not a concrete tuple, so an unregistered router stays assignable.
|
|
10
|
+
*/
|
|
11
|
+
type MatchedRoute<TMatches> = LastInArray<TMatches, CreatedRouteOptions> extends infer TMatched ? unknown extends TMatched ? CreatedRouteOptions : TMatched : never;
|
|
5
12
|
/**
|
|
6
13
|
* Represents a route that the router has matched to current browser location.
|
|
7
14
|
* @template TRoute - Underlying Route that has been resolved.
|
|
@@ -14,7 +21,7 @@ export type ResolvedRoute<TRoute extends Route = Route> = Readonly<{
|
|
|
14
21
|
/**
|
|
15
22
|
* The specific route properties that were matched in the current route.
|
|
16
23
|
*/
|
|
17
|
-
matched: TRoute['
|
|
24
|
+
matched: MatchedRoute<TRoute['matches']>;
|
|
18
25
|
/**
|
|
19
26
|
* The specific route properties that were matched in the current route, including any ancestors.
|
|
20
27
|
* Order of routes will be from greatest ancestor to narrowest matched.
|
|
@@ -45,10 +52,23 @@ export type ResolvedRoute<TRoute extends Route = Route> = Readonly<{
|
|
|
45
52
|
*/
|
|
46
53
|
hash: string;
|
|
47
54
|
/**
|
|
48
|
-
*
|
|
55
|
+
* Returns the title of the route from its `setTitle` callback, or from the closest parent route that
|
|
56
|
+
* defines one.
|
|
49
57
|
*/
|
|
50
|
-
|
|
58
|
+
getTitle: GetTitleCallback;
|
|
51
59
|
}>;
|
|
60
|
+
/**
|
|
61
|
+
* A resolved route whose loaders' data is available. Only the route being navigated to has data: a route
|
|
62
|
+
* the router merely resolved is not being loaded, so data on it could never settle. The current route and
|
|
63
|
+
* a props getter's route have it, `router.resolve` and hooks do not.
|
|
64
|
+
*/
|
|
65
|
+
export type WithData<TRoute extends Route = Route> = {
|
|
66
|
+
/**
|
|
67
|
+
* What the route's loaders resolve to, keyed by loader name. A route whose only loader is unnamed
|
|
68
|
+
* exposes that loader's data here directly. Always promises, since loaders never block rendering.
|
|
69
|
+
*/
|
|
70
|
+
data: RouteDataOf<TRoute['matches']>;
|
|
71
|
+
};
|
|
52
72
|
/**
|
|
53
73
|
* This type is the same as `ResolvedRoute<TRoutes[number]>` while remaining distributive
|
|
54
74
|
*/
|
|
@@ -65,3 +85,4 @@ export type RouterResolvedRouteUnion<TRoutes extends Routes> = {
|
|
|
65
85
|
* type ResolvedUnion = ResolvedRouteUnion<RouteUnion> // ResolvedRoute<RouteA> | ResolvedRoute<RouteB>
|
|
66
86
|
*/
|
|
67
87
|
export type ResolvedRouteUnion<TRoute extends Route> = TRoute extends Route ? ResolvedRoute<TRoute> : never;
|
|
88
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { Param } from './paramTypes';
|
|
2
|
+
import { PrefetchConfig } from './prefetch';
|
|
3
|
+
import { RouteMeta } from './register';
|
|
4
|
+
import { LastInArray } from './utilities';
|
|
5
|
+
import { CreateRouteOptions } from './createRouteOptions';
|
|
6
|
+
import { RouteContext, ToRouteContext } from './routeContext';
|
|
7
|
+
import { ToMeta } from './meta';
|
|
8
|
+
import { ToState } from './state';
|
|
9
|
+
import { Url } from './url';
|
|
10
|
+
import { GetRouteTitle } from './routeTitle';
|
|
11
|
+
import { Hooks } from '../models/hooks';
|
|
12
|
+
import { RouteRedirect } from './redirects';
|
|
13
|
+
import { RouteViews } from './routeViews';
|
|
14
|
+
import { LoadersDataReturnType, RouteLoaders } from './routeLoaders';
|
|
15
|
+
export declare const IS_ROUTE_SYMBOL: unique symbol;
|
|
16
|
+
export declare function isRoute(value: unknown): value is Route & RouteInternal;
|
|
17
|
+
export type RouteInternal = {
|
|
18
|
+
[IS_ROUTE_SYMBOL]: true;
|
|
19
|
+
depth: number;
|
|
20
|
+
hooks: Hooks[];
|
|
21
|
+
redirect: RouteRedirect;
|
|
22
|
+
getTitle: GetRouteTitle;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Represents an immutable array of Route instances. Return value of `createRoute`, expected param for `createRouter`.
|
|
26
|
+
*/
|
|
27
|
+
export type Routes = readonly Route[];
|
|
28
|
+
/**
|
|
29
|
+
* The Route properties originally provided to `createRoute`, plus the views that route renders and the
|
|
30
|
+
* loaders it runs. The deprecated `component`/`components` options are folded into `views` (see
|
|
31
|
+
* {@link RouteViews}).
|
|
32
|
+
*/
|
|
33
|
+
export type CreatedRouteOptions = Omit<CreateRouteOptions, 'component' | 'components'> & {
|
|
34
|
+
id: string;
|
|
35
|
+
views: RouteViews;
|
|
36
|
+
loaders: RouteLoaders;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* The name of the narrowest matched route.
|
|
40
|
+
*/
|
|
41
|
+
type RouteNameOf<TMatches extends CreatedRouteOptions[]> = LastInArray<TMatches> extends {
|
|
42
|
+
name: infer TName extends string;
|
|
43
|
+
} ? TName : string;
|
|
44
|
+
/**
|
|
45
|
+
* The meta of every matched route, combined. Mirrors `combineMeta`, which is an intersection.
|
|
46
|
+
*/
|
|
47
|
+
type RouteMetaOf<TMatches extends CreatedRouteOptions[]> = CreatedRouteOptions[] extends TMatches ? RouteMeta : TMatches extends [infer THead, ...infer TRest extends CreatedRouteOptions[]] ? ToMeta<THead extends {
|
|
48
|
+
meta: infer TMeta extends RouteMeta;
|
|
49
|
+
} ? TMeta : undefined> & RouteMetaOf<TRest> : {};
|
|
50
|
+
/**
|
|
51
|
+
* The state of every matched route, combined. Mirrors `combineState`, which is an intersection.
|
|
52
|
+
* A match without state contributes `{}` rather than `ToState<undefined>`, which widens to
|
|
53
|
+
* `Record<string, Param>` and would swallow the rest of the intersection.
|
|
54
|
+
*/
|
|
55
|
+
type RouteStateOf<TMatches extends CreatedRouteOptions[]> = CreatedRouteOptions[] extends TMatches ? Record<string, Param> : TMatches extends [infer THead, ...infer TRest extends CreatedRouteOptions[]] ? (THead extends {
|
|
56
|
+
state: infer TState extends Record<string, Param>;
|
|
57
|
+
} ? ToState<TState> : {}) & RouteStateOf<TRest> : {};
|
|
58
|
+
/**
|
|
59
|
+
* The loaders of every matched route, combined. A plain intersection: a loader name is unique across a
|
|
60
|
+
* route and its ancestors, which `addLoader` enforces.
|
|
61
|
+
*/
|
|
62
|
+
type RouteLoadersOf<TMatches extends CreatedRouteOptions[]> = CreatedRouteOptions[] extends TMatches ? RouteLoaders : TMatches extends [infer THead, ...infer TRest extends CreatedRouteOptions[]] ? (THead extends {
|
|
63
|
+
loaders: infer TLoaders extends RouteLoaders;
|
|
64
|
+
} ? TLoaders : {}) & RouteLoadersOf<TRest> : {};
|
|
65
|
+
/**
|
|
66
|
+
* The data every matched route's loaders resolve to, which is what a resolved route exposes as `data`.
|
|
67
|
+
* Undefined when nothing in the route tree declares a loader.
|
|
68
|
+
*/
|
|
69
|
+
export type RouteDataOf<TMatches extends CreatedRouteOptions[]> = CreatedRouteOptions[] extends TMatches ? Promise<unknown> | Record<string, Promise<unknown>> | undefined : LoadersDataReturnType<RouteLoadersOf<TMatches>>;
|
|
70
|
+
/**
|
|
71
|
+
* The context of every matched route, flattened from greatest ancestor to narrowest matched.
|
|
72
|
+
*/
|
|
73
|
+
type RouteContextOf<TMatches extends CreatedRouteOptions[]> = CreatedRouteOptions[] extends TMatches ? RouteContext[] : TMatches extends [infer THead, ...infer TRest extends CreatedRouteOptions[]] ? [...ToRouteContext<THead extends {
|
|
74
|
+
context: infer TContext extends RouteContext[];
|
|
75
|
+
} ? TContext : []>, ...RouteContextOf<TRest>] : [];
|
|
76
|
+
/**
|
|
77
|
+
* Represents the structure of a route within the application. Return value of `createRoute`
|
|
78
|
+
* @template TUrl - The url the route resolves to, combined with any parents. Intersected into the route.
|
|
79
|
+
* @template TMatches - The options of the route and its ancestors, indexed by depth. Name, meta, state,
|
|
80
|
+
* and context are all derived from this, including each route's views.
|
|
81
|
+
*/
|
|
82
|
+
export type Route<TUrl extends Url = Url, TMatches extends CreatedRouteOptions[] = CreatedRouteOptions[]> = TUrl & {
|
|
83
|
+
/**
|
|
84
|
+
* Unique identifier for the route, generated by router.
|
|
85
|
+
*/
|
|
86
|
+
id: string;
|
|
87
|
+
/**
|
|
88
|
+
* The specific route properties that were matched in the current route, including any ancestors.
|
|
89
|
+
* Order of routes will be from greatest ancestor to narrowest matched.
|
|
90
|
+
*/
|
|
91
|
+
matches: TMatches;
|
|
92
|
+
/**
|
|
93
|
+
* Identifier for the route as defined by user. Name must be unique among named routes. Name is used for routing and for matching.
|
|
94
|
+
*/
|
|
95
|
+
name: RouteNameOf<TMatches>;
|
|
96
|
+
/**
|
|
97
|
+
* Represents additional metadata associated with a route, combined with any parents.
|
|
98
|
+
*/
|
|
99
|
+
meta: RouteMetaOf<TMatches>;
|
|
100
|
+
/**
|
|
101
|
+
* Represents the schema of the route state, combined with any parents.
|
|
102
|
+
*/
|
|
103
|
+
state: RouteStateOf<TMatches>;
|
|
104
|
+
/**
|
|
105
|
+
* Determines what assets are prefetched when router-link is rendered for this route. Overrides router level prefetch.
|
|
106
|
+
*/
|
|
107
|
+
prefetch?: PrefetchConfig;
|
|
108
|
+
/**
|
|
109
|
+
* Related routes and rejections for the route. The context is exposed to the hooks and props callback functions for this route.
|
|
110
|
+
*/
|
|
111
|
+
context: RouteContextOf<TMatches>;
|
|
112
|
+
};
|
|
113
|
+
export type GenericRoute = Url & {
|
|
114
|
+
id: string;
|
|
115
|
+
name: string;
|
|
116
|
+
matches: CreatedRouteOptions[];
|
|
117
|
+
meta: RouteMeta;
|
|
118
|
+
state: Record<string, Param>;
|
|
119
|
+
prefetch?: PrefetchConfig;
|
|
120
|
+
};
|
|
121
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ResolvedRoute } from './resolved';
|
|
2
|
+
import { CreatedRouteOptions, Route } from './route';
|
|
3
|
+
import { RouteContextToRejection, RouteContextToRoute } from './routeContext';
|
|
4
|
+
import { RouterPush } from './routerPush';
|
|
5
|
+
import { RouterReject } from './routerReject';
|
|
6
|
+
import { RouterReplace } from './routerReplace';
|
|
7
|
+
import { RouteUpdate } from './routeUpdate';
|
|
8
|
+
import { LoadersDataReturnType } from './routeLoaders';
|
|
9
|
+
import { ViewsPropsReturnType } from './routeViews';
|
|
10
|
+
/**
|
|
11
|
+
* Context provided to a callback attached to a route — an `addView` props getter, or a loader. Sourced
|
|
12
|
+
* from the route: rejections/routes from the route's context, and the parent from the route's `matches`.
|
|
13
|
+
*/
|
|
14
|
+
export type RouteCallbackContext<TRoute extends Route> = {
|
|
15
|
+
reject: RouterReject<RouteContextToRejection<TRoute['context']>>;
|
|
16
|
+
push: RouterPush<[TRoute] | RouteContextToRoute<TRoute['context']>>;
|
|
17
|
+
replace: RouterReplace<[TRoute] | RouteContextToRoute<TRoute['context']>>;
|
|
18
|
+
update: RouteUpdate<ResolvedRoute<TRoute>>;
|
|
19
|
+
parent: RouteCallbackParent<TRoute>;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* The parent context ({ name, props, data }) reconstructed from the second-to-last `matches` entry, which
|
|
23
|
+
* carries the parent's name, its views and its loaders.
|
|
24
|
+
*/
|
|
25
|
+
type RouteCallbackParent<TRoute extends Route> = TRoute['matches'] extends [...CreatedRouteOptions[], infer TParent extends CreatedRouteOptions, CreatedRouteOptions] ? {
|
|
26
|
+
name: TParent['name'];
|
|
27
|
+
props: ViewsPropsReturnType<TParent['views']>;
|
|
28
|
+
data: LoadersDataReturnType<TParent['loaders']>;
|
|
29
|
+
} : undefined;
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { AnyPayloadTransformer } from '../services/payload';
|
|
2
|
+
import { PrefetchConfig } from './prefetch';
|
|
3
|
+
import { AnyFunction } from './utilities';
|
|
4
|
+
/**
|
|
5
|
+
* A single loader: how to load its data, and how to prefetch it. Unlike a view, a loader always has a
|
|
6
|
+
* getter — a loader without one would have nothing to contribute.
|
|
7
|
+
*
|
|
8
|
+
* @template TData - What this loader's getter returns, carried so a route's data can be typed from it.
|
|
9
|
+
*/
|
|
10
|
+
export type RouteLoader<TData = unknown> = {
|
|
11
|
+
load: AnyFunction<TData>;
|
|
12
|
+
prefetch?: PrefetchConfig;
|
|
13
|
+
transformer?: AnyPayloadTransformer;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* The loaders for a single route, keyed by loader name (the unnamed loader under 'default').
|
|
17
|
+
*/
|
|
18
|
+
export type RouteLoaders = Record<string, RouteLoader>;
|
|
19
|
+
/**
|
|
20
|
+
* The data a set of loaders resolves to. A lone unnamed loader is given directly rather than under a
|
|
21
|
+
* 'default' key, matching how the loader is written. Each loader's data is always a promise, since a
|
|
22
|
+
* loader never blocks rendering, even when the loader itself is synchronous.
|
|
23
|
+
*/
|
|
24
|
+
export type LoadersDataReturnType<TLoaders> = keyof TLoaders extends never ? undefined : keyof TLoaders extends 'default' ? LoaderData<Extract<TLoaders, {
|
|
25
|
+
default: unknown;
|
|
26
|
+
}>['default']> : {
|
|
27
|
+
[K in keyof TLoaders]: LoaderData<TLoaders[K]>;
|
|
28
|
+
};
|
|
29
|
+
type LoaderData<TLoader> = TLoader extends {
|
|
30
|
+
load: AnyFunction<infer TData>;
|
|
31
|
+
} ? Promise<Awaited<TData>> : never;
|
|
32
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { ResolvedRoute, ResolvedRouteUnion } from './resolved';
|
|
2
2
|
import { Route } from './route';
|
|
3
3
|
import { MaybePromise } from './utilities';
|
|
4
|
+
export type GetTitleCallback = () => Promise<string | undefined>;
|
|
4
5
|
export type SetRouteTitleContext = {
|
|
5
6
|
from: ResolvedRoute;
|
|
6
|
-
getParentTitle:
|
|
7
|
+
getParentTitle: GetTitleCallback;
|
|
7
8
|
};
|
|
8
9
|
export type SetRouteTitleCallback<TRoute extends Route = Route> = (to: ResolvedRouteUnion<TRoute>, context: SetRouteTitleContext) => MaybePromise<string>;
|
|
9
10
|
export type GetRouteTitle<TRoute extends Route = Route> = (to: ResolvedRouteUnion<TRoute>) => Promise<string | undefined>;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { AnyPayloadTransformer } from '../services/payload';
|
|
2
|
+
import { Component } from 'vue';
|
|
3
|
+
import { PrefetchConfig } from './prefetch';
|
|
4
|
+
import { AnyFunction } from './utilities';
|
|
5
|
+
/**
|
|
6
|
+
* A single view: what to render, how to get its props, and how to prefetch it. `component` is optional
|
|
7
|
+
* because a route can bind props to the nested RouterView it renders without declaring a component.
|
|
8
|
+
*
|
|
9
|
+
* @template TProps - What this view's props getter returns, carried so parent props can be typed from it.
|
|
10
|
+
*/
|
|
11
|
+
export type RouteView<TProps = undefined> = {
|
|
12
|
+
component?: Component;
|
|
13
|
+
props?: AnyFunction<TProps>;
|
|
14
|
+
prefetch?: PrefetchConfig;
|
|
15
|
+
transformer?: AnyPayloadTransformer;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* The views for a single route, keyed by view name (the unnamed view under 'default'). Indexed by depth in
|
|
19
|
+
* `route.views` — parallel to how `route.matches` indexes the matched options, which is where a route's id
|
|
20
|
+
* comes from at a given depth.
|
|
21
|
+
*/
|
|
22
|
+
export type RouteViews = Record<string, RouteView<unknown>>;
|
|
23
|
+
/**
|
|
24
|
+
* The props a child sees for a parent's views. A lone unnamed view is given directly rather than under a
|
|
25
|
+
* 'default' key, matching how the props argument is written. Each view's props are always a promise,
|
|
26
|
+
* since the parent's props may not have been computed when the child's getter runs.
|
|
27
|
+
*/
|
|
28
|
+
export type ViewsPropsReturnType<TViews> = keyof ViewsWithProps<TViews> extends never ? undefined : keyof ViewsWithProps<TViews> extends 'default' ? ParentViewProps<Extract<ViewsWithProps<TViews>, {
|
|
29
|
+
default: unknown;
|
|
30
|
+
}>['default']> : {
|
|
31
|
+
[K in keyof ViewsWithProps<TViews>]: ParentViewProps<ViewsWithProps<TViews>[K]>;
|
|
32
|
+
};
|
|
33
|
+
type ViewsWithProps<TViews> = {
|
|
34
|
+
[K in keyof TViews as HasViewProps<TViews[K]> extends true ? K : never]: TViews[K];
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* A view has props unless its getter is absent, which is carried as props resolving to undefined. Asked
|
|
38
|
+
* both ways because a getter that only ever throws resolves to never, which is assignable to undefined
|
|
39
|
+
* without being the absent case.
|
|
40
|
+
*/
|
|
41
|
+
type HasViewProps<TView> = [ViewProps<TView>] extends [undefined] ? [undefined] extends [ViewProps<TView>] ? false : true : true;
|
|
42
|
+
type ViewProps<TView> = TView extends {
|
|
43
|
+
props?: AnyFunction<infer TProps>;
|
|
44
|
+
} ? TProps : undefined;
|
|
45
|
+
type ParentViewProps<TView> = Promise<Awaited<ViewProps<TView>>>;
|
|
46
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { RouteAddLoader } from './addLoader';
|
|
2
|
+
import { RouteAddView } from './addView';
|
|
3
|
+
import { InternalRouteHooks } from './hooks';
|
|
4
|
+
import { RouteRedirects } from './redirects';
|
|
5
|
+
import { CreatedRouteOptions, Route } from './route';
|
|
6
|
+
import { RouteSetTitle } from './routeTitle';
|
|
7
|
+
import { Url } from './url';
|
|
8
|
+
/**
|
|
9
|
+
* A route plus every chainable/available method: addView, addLoader, hooks, redirects, and title. The type
|
|
10
|
+
* level counterpart to `withRouteMethods`.
|
|
11
|
+
*
|
|
12
|
+
* Takes the url and matches rather than an assembled route so that adding a view or a loader can rebuild
|
|
13
|
+
* from them directly. Taking the route would mean re-deriving the url from it on every call, and that
|
|
14
|
+
* reference is what made chained calls nest one inside the last.
|
|
15
|
+
*/
|
|
16
|
+
export type RouteWithMethods<TUrl extends Url = Url, TMatches extends CreatedRouteOptions[] = CreatedRouteOptions[]> = Route<TUrl, TMatches> & RouteAddView<TUrl, TMatches> & RouteAddLoader<TUrl, TMatches> & InternalRouteHooks<Route<TUrl, TMatches>, Route<TUrl, TMatches>['context']> & RouteRedirects<Route<TUrl, TMatches>> & RouteSetTitle<Route<TUrl, TMatches>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { App, InjectionKey, Ref } from 'vue';
|
|
2
2
|
import { RouterHistoryMode } from '../services/createRouterHistory';
|
|
3
|
+
import { TransformerOptions } from '../services/payload';
|
|
3
4
|
import { RouterRoute } from './routerRoute';
|
|
4
5
|
import { AddBeforeEnterHook, AddBeforeUpdateHook, AddBeforeLeaveHook, AddAfterEnterHook, AddAfterUpdateHook, AddAfterLeaveHook, AddErrorHook, AddRejectionHook } from './hooks';
|
|
5
6
|
import { PrefetchConfig } from './prefetch';
|
|
@@ -12,16 +13,22 @@ import { RouterReject } from './routerReject';
|
|
|
12
13
|
import { RouterPlugin } from './routerPlugin';
|
|
13
14
|
import { RoutesName } from './routesMap';
|
|
14
15
|
import { ExtractRejections, ExtractRejectionTypes, Rejections, BuiltInRejectionType } from './rejection';
|
|
16
|
+
import { PayloadValueError } from '../errors/payloadValueError';
|
|
15
17
|
/**
|
|
16
18
|
* Options to initialize a {@link Router} instance.
|
|
17
19
|
*/
|
|
18
|
-
export type RouterOptions = {
|
|
20
|
+
export type RouterOptions = TransformerOptions & {
|
|
19
21
|
/**
|
|
20
22
|
* Initial URL for the router to use. Required if using Node environment. Defaults to window.location when using browser.
|
|
21
23
|
*
|
|
22
24
|
* @default window.location.toString()
|
|
23
25
|
*/
|
|
24
26
|
initialUrl?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Marks the router as rendering on a server, so every navigation is part of the server render from
|
|
29
|
+
* the moment the router is created. Required to call `render`.
|
|
30
|
+
*/
|
|
31
|
+
ssr?: boolean;
|
|
25
32
|
/**
|
|
26
33
|
* Specifies the history mode for the router, such as "browser", "memory", or "hash".
|
|
27
34
|
*
|
|
@@ -47,6 +54,19 @@ export type RouterOptions = {
|
|
|
47
54
|
* @default true
|
|
48
55
|
*/
|
|
49
56
|
removeTrailingSlashes?: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* The status `render` responds with for a normalized url or a route redirect that does not declare
|
|
59
|
+
* its own.
|
|
60
|
+
*
|
|
61
|
+
* @default 302
|
|
62
|
+
*/
|
|
63
|
+
redirectStatus?: RedirectStatus;
|
|
64
|
+
/**
|
|
65
|
+
* The status `render` responds with for a rejection that does not declare its own.
|
|
66
|
+
*
|
|
67
|
+
* @default 200
|
|
68
|
+
*/
|
|
69
|
+
rejectStatus?: number;
|
|
50
70
|
/**
|
|
51
71
|
* When false, createRouterAssets must be used for component and hooks. Assets exported by the library
|
|
52
72
|
* will not work with the created router instance.
|
|
@@ -55,6 +75,67 @@ export type RouterOptions = {
|
|
|
55
75
|
*/
|
|
56
76
|
isGlobalRouter?: boolean;
|
|
57
77
|
};
|
|
78
|
+
/**
|
|
79
|
+
* What a server should respond with for what the router rendered. `location` exists only on a redirect,
|
|
80
|
+
* so narrowing on it is what proves a `Location` header is available.
|
|
81
|
+
*/
|
|
82
|
+
export type ServerRenderResponse = RenderSuccess | RenderReject | RenderRedirect;
|
|
83
|
+
export type RenderSuccess = {
|
|
84
|
+
kind: 'success';
|
|
85
|
+
/**
|
|
86
|
+
* Suggested http status.
|
|
87
|
+
*/
|
|
88
|
+
status: number;
|
|
89
|
+
/**
|
|
90
|
+
* A script tag to embed in the document sent to the client, so it adopts what this render settled on
|
|
91
|
+
* rather than working it out again.
|
|
92
|
+
*/
|
|
93
|
+
payload: string;
|
|
94
|
+
/**
|
|
95
|
+
* The title of the route that rendered, for the document sent to the client.
|
|
96
|
+
*/
|
|
97
|
+
title: string | undefined;
|
|
98
|
+
/**
|
|
99
|
+
* Values that could not be encoded into the payload. Each was left out, so the client computes it
|
|
100
|
+
* again, which can cause a hydration mismatch. Returned so a server can log or inspect them.
|
|
101
|
+
*/
|
|
102
|
+
failures: PayloadValueError[];
|
|
103
|
+
};
|
|
104
|
+
export type RenderReject = {
|
|
105
|
+
kind: 'reject';
|
|
106
|
+
/**
|
|
107
|
+
* Suggested http status.
|
|
108
|
+
*/
|
|
109
|
+
status: number;
|
|
110
|
+
/**
|
|
111
|
+
* The type of rejection in effect.
|
|
112
|
+
*/
|
|
113
|
+
rejection: string;
|
|
114
|
+
/**
|
|
115
|
+
* A script tag to embed in the document sent to the client, so it adopts this rejection rather than
|
|
116
|
+
* working it out again.
|
|
117
|
+
*/
|
|
118
|
+
payload: string;
|
|
119
|
+
/**
|
|
120
|
+
* The title of the rejection that rendered, for the document sent to the client.
|
|
121
|
+
*/
|
|
122
|
+
title: string | undefined;
|
|
123
|
+
};
|
|
124
|
+
export type RenderRedirect = {
|
|
125
|
+
kind: 'redirect';
|
|
126
|
+
/**
|
|
127
|
+
* Suggested http status.
|
|
128
|
+
*/
|
|
129
|
+
status: RedirectStatus;
|
|
130
|
+
/**
|
|
131
|
+
* Value for the `Location` header.
|
|
132
|
+
*/
|
|
133
|
+
location: string;
|
|
134
|
+
};
|
|
135
|
+
/**
|
|
136
|
+
* The statuses the router reports for a redirect.
|
|
137
|
+
*/
|
|
138
|
+
export type RedirectStatus = 301 | 302;
|
|
58
139
|
export type Router<TRoutes extends Routes = any, TOptions extends RouterOptions = any, TPlugin extends RouterPlugin = any> = {
|
|
59
140
|
/**
|
|
60
141
|
* Installs the router into a Vue application instance.
|
|
@@ -129,7 +210,7 @@ export type Router<TRoutes extends Routes = any, TOptions extends RouterOptions
|
|
|
129
210
|
* Registers a hook to be called when an error occurs.
|
|
130
211
|
* If the hook returns true, the error is considered handled and the other hooks are not run. If all hooks return false the error is rethrown
|
|
131
212
|
*/
|
|
132
|
-
onError: AddErrorHook<TRoutes
|
|
213
|
+
onError: AddErrorHook<TRoutes | TPlugin['routes'], ExtractRejections<TOptions> | ExtractRejections<TPlugin>>;
|
|
133
214
|
/**
|
|
134
215
|
* Registers a hook to be called when a rejection occurs.
|
|
135
216
|
*/
|
|
@@ -151,7 +232,18 @@ export type Router<TRoutes extends Routes = any, TOptions extends RouterOptions
|
|
|
151
232
|
*/
|
|
152
233
|
started: Ref<boolean>;
|
|
153
234
|
/**
|
|
154
|
-
*
|
|
235
|
+
* Resolves once the router has nothing left to render: every prop and loader has settled, following
|
|
236
|
+
* any navigation one of them caused, so this waits for the next *full* render rather than for one
|
|
237
|
+
* navigation. Resolves with what a server should respond with.
|
|
238
|
+
*
|
|
239
|
+
* Awaiting `push` only waits for the route to commit; this also waits for its data.
|
|
240
|
+
*
|
|
241
|
+
* Requires the router to be created with the `ssr` option, and throws `SsrOptionRequiredError`
|
|
242
|
+
* without it.
|
|
243
|
+
*/
|
|
244
|
+
render: () => Promise<ServerRenderResponse>;
|
|
245
|
+
/**
|
|
246
|
+
* Stops the router. Tears down the history listener and ignores any navigation still in flight or started afterwards.
|
|
155
247
|
*/
|
|
156
248
|
stop: () => void;
|
|
157
249
|
/**
|
|
@@ -43,13 +43,17 @@ type PluginAfterRouteHookContext<TRoutes extends Routes, TRejections extends Rej
|
|
|
43
43
|
replace: RouterReplace<TRoutes>;
|
|
44
44
|
};
|
|
45
45
|
export type PluginBeforeRouteHook<TRoutes extends Routes = Routes, TRejections extends Rejections = Rejections> = (to: ResolvedRoute, context: PluginBeforeRouteHookContext<TRoutes, TRejections>) => MaybePromise<void>;
|
|
46
|
+
export type PluginBeforeRouteLeaveHook<TRoutes extends Routes = Routes, TRejections extends Rejections = Rejections> = (to: ResolvedRoute | null, context: PluginBeforeRouteHookContext<TRoutes, TRejections>) => MaybePromise<void>;
|
|
47
|
+
type AddPluginBeforeRouteLeaveHook<TRoutes extends Routes = Routes, TRejections extends Rejections = Rejections> = (hook: PluginBeforeRouteLeaveHook<TRoutes, TRejections>) => HookRemove;
|
|
48
|
+
export type PluginAfterRouteLeaveHook<TRoutes extends Routes = Routes, TRejections extends Rejections = Rejections> = (to: ResolvedRoute | null, context: PluginAfterRouteHookContext<TRoutes, TRejections>) => MaybePromise<void>;
|
|
49
|
+
type AddPluginAfterRouteLeaveHook<TRoutes extends Routes = Routes, TRejections extends Rejections = Rejections> = (hook: PluginAfterRouteLeaveHook<TRoutes, TRejections>) => HookRemove;
|
|
46
50
|
export type PluginAfterRouteHook<TRoutes extends Routes = Routes, TRejections extends Rejections = Rejections> = (to: ResolvedRoute, context: PluginAfterRouteHookContext<TRoutes, TRejections>) => MaybePromise<void>;
|
|
47
51
|
type AddPluginBeforeRouteHook<TRoutes extends Routes, TRejections extends Rejections> = (hook: PluginBeforeRouteHook<TRoutes, TRejections>) => HookRemove;
|
|
48
52
|
type AddPluginAfterRouteHook<TRoutes extends Routes, TRejections extends Rejections> = (hook: PluginAfterRouteHook<TRoutes, TRejections>) => HookRemove;
|
|
49
53
|
export type PluginErrorHookContext<TRoutes extends Routes = Routes, TRejections extends Rejections = Rejections> = {
|
|
50
|
-
to: ResolvedRoute;
|
|
54
|
+
to: ResolvedRoute | null;
|
|
51
55
|
from: ResolvedRoute | null;
|
|
52
|
-
source: 'props' | 'hook' | 'component';
|
|
56
|
+
source: 'props' | 'loader' | 'hook' | 'component';
|
|
53
57
|
reject: RouterReject<TRejections>;
|
|
54
58
|
push: RouterPush<TRoutes>;
|
|
55
59
|
replace: RouterReplace<TRoutes>;
|
|
@@ -64,7 +68,7 @@ export type PluginRouteHooks<TRoutes extends Routes = Routes, TRejections extend
|
|
|
64
68
|
/**
|
|
65
69
|
* Registers a global hook to be called before a route is left.
|
|
66
70
|
*/
|
|
67
|
-
onBeforeRouteLeave:
|
|
71
|
+
onBeforeRouteLeave: AddPluginBeforeRouteLeaveHook<TRoutes, TRejections>;
|
|
68
72
|
/**
|
|
69
73
|
* Registers a global hook to be called before a route is updated.
|
|
70
74
|
*/
|
|
@@ -76,7 +80,7 @@ export type PluginRouteHooks<TRoutes extends Routes = Routes, TRejections extend
|
|
|
76
80
|
/**
|
|
77
81
|
* Registers a global hook to be called after a route is left.
|
|
78
82
|
*/
|
|
79
|
-
onAfterRouteLeave:
|
|
83
|
+
onAfterRouteLeave: AddPluginAfterRouteLeaveHook<TRoutes, TRejections>;
|
|
80
84
|
/**
|
|
81
85
|
* Registers a global hook to be called after a route is updated.
|
|
82
86
|
*/
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { BuiltInRejectionType, Rejections, RejectionType } from './rejection';
|
|
2
|
+
import { ResolvedRoute } from './resolved';
|
|
3
|
+
export type RouterReject<TRejections extends Rejections | undefined> = <TSource extends (RejectionType<TRejections> | BuiltInRejectionType)>(type: TSource) => void;
|
|
4
|
+
/**
|
|
5
|
+
* The routes a rejection happened between, which rejection hooks are given.
|
|
6
|
+
*/
|
|
7
|
+
export type RejectContext = {
|
|
8
|
+
to?: ResolvedRoute | null;
|
|
9
|
+
from?: ResolvedRoute | null;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Reject as the router itself calls it, which may name any rejection type and supply the routes the
|
|
13
|
+
* rejection happened between. The router exposes {@link RouterReject} instead.
|
|
14
|
+
*/
|
|
15
|
+
export type RouterRejectInternal<TRejections extends Rejections | undefined> = RouterReject<TRejections> & ((type: string, context?: RejectContext) => void);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { RouteUpdate } from './routeUpdate';
|
|
2
2
|
import { ResolvedRoute } from './resolved';
|
|
3
|
+
import { RouteDataOf } from './route';
|
|
3
4
|
import { QuerySource } from './querySource';
|
|
4
5
|
export type RouterRoute<TRoute extends ResolvedRoute = ResolvedRoute> = {
|
|
5
6
|
/**
|
|
@@ -34,7 +35,12 @@ export type RouterRoute<TRoute extends ResolvedRoute = ResolvedRoute> = {
|
|
|
34
35
|
/**
|
|
35
36
|
* Title of the route.
|
|
36
37
|
*/
|
|
37
|
-
readonly
|
|
38
|
+
readonly getTitle: TRoute['getTitle'];
|
|
39
|
+
/**
|
|
40
|
+
* What the route's loaders resolve to, keyed by loader name. A route whose only loader is unnamed
|
|
41
|
+
* exposes that loader's data here directly.
|
|
42
|
+
*/
|
|
43
|
+
readonly data: RouteDataOf<TRoute['matches']>;
|
|
38
44
|
params: TRoute['params'];
|
|
39
45
|
state: TRoute['state'];
|
|
40
46
|
get query(): URLSearchParams;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -4,6 +4,7 @@ export type Identity<T> = T extends object ? {} & {
|
|
|
4
4
|
type IsEmptyObject<T> = T extends Record<string, never> ? (keyof T extends never ? true : false) : false;
|
|
5
5
|
export type LastInArray<T, TFallback = never> = T extends [...any[], infer Last] ? Last : TFallback;
|
|
6
6
|
export type MaybePromise<T> = T | Promise<T>;
|
|
7
|
+
export type AnyFunction<TReturn = any> = (...args: any[]) => TReturn;
|
|
7
8
|
type OnlyRequiredProperties<T> = {
|
|
8
9
|
[K in keyof T as Extract<T[K], undefined> extends never ? K : never]: T[K];
|
|
9
10
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Component } from 'vue';
|
|
2
|
+
import { ResolvedRoute } from '../types/resolved';
|
|
3
|
+
import { CreatedRouteOptions } from '../types/route';
|
|
4
|
+
import { RouteView } from '../types/routeViews';
|
|
5
|
+
type ComponentWithAsyncLoader = Component & {
|
|
6
|
+
__asyncLoader: () => Promise<unknown>;
|
|
7
|
+
};
|
|
8
|
+
export declare function isAsyncComponent(component: Component): component is ComponentWithAsyncLoader;
|
|
9
|
+
/**
|
|
10
|
+
* Decides which of a route's views to load.
|
|
11
|
+
*/
|
|
12
|
+
export type AsyncComponentFilter = (match: CreatedRouteOptions, view: RouteView<unknown>) => boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Loads the async components a route renders, or only those the filter keeps, so they are ready to render
|
|
15
|
+
* synchronously.
|
|
16
|
+
*/
|
|
17
|
+
export declare function loadAsyncComponents(route: ResolvedRoute, filter?: AsyncComponentFilter): Promise<unknown>;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { PrefetchConfig, PrefetchConfigOptions, PrefetchConfigs, PrefetchStrategy } from '../types/prefetch';
|
|
2
2
|
export declare const DEFAULT_PREFETCH_STRATEGY: PrefetchStrategy;
|
|
3
|
-
export declare function getPrefetchOption({ routerPrefetch, routePrefetch, linkPrefetch }: PrefetchConfigs, setting: keyof PrefetchConfigOptions): false | PrefetchStrategy;
|
|
3
|
+
export declare function getPrefetchOption({ routerPrefetch, routePrefetch, viewPrefetch, linkPrefetch }: PrefetchConfigs, setting: keyof PrefetchConfigOptions): false | PrefetchStrategy;
|
|
4
4
|
export declare function getPrefetchConfigValue(prefetch: PrefetchConfig | undefined, setting: keyof PrefetchConfigOptions): boolean | PrefetchStrategy | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { MaybePromise } from '../types/utilities';
|
|
2
|
+
/**
|
|
3
|
+
* How a props getter settled. Tagged so that a getter returning `undefined` or an `Error` stays a value.
|
|
4
|
+
*/
|
|
5
|
+
export type PropsResult = {
|
|
6
|
+
kind: 'value';
|
|
7
|
+
value: unknown;
|
|
8
|
+
} | {
|
|
9
|
+
kind: 'error';
|
|
10
|
+
error: unknown;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Runs a props callback and captures how it settled rather than letting it throw, so that navigation can
|
|
14
|
+
* tell a push or rejection apart from a genuine failure. Sync getters settle synchronously.
|
|
15
|
+
*/
|
|
16
|
+
export declare function getPropsValue(callback: () => unknown): MaybePromise<PropsResult>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function setDocumentTitle(title: string | undefined): void;
|