@kitbag/router 0.24.3 → 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/compositions/useRouteValueStore.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 +6 -0
- package/dist/kitbag-router.d.ts +1 -1
- package/dist/kitbag-router.js +6452 -6172
- package/dist/kitbag-router.umd.cjs +5 -4
- package/dist/{src/main.d.ts → main.d.ts} +8 -0
- package/dist/services/addLoader.d.ts +40 -0
- package/dist/services/addView.d.ts +37 -0
- package/dist/{src/services → services}/component.d.ts +2 -3
- package/dist/{src/services → services}/createComponentsStore.d.ts +2 -2
- package/dist/services/createCurrentRoute.d.ts +25 -0
- package/dist/services/createDataStore.d.ts +48 -0
- package/dist/services/createNavigationStores.d.ts +31 -0
- package/dist/{src/services → services}/createRoute.d.ts +3 -6
- package/dist/services/createRouteValueStore.d.ts +56 -0
- package/dist/services/createRouteViews.d.ts +16 -0
- package/dist/{src/services → services}/createRouterRoute.d.ts +2 -2
- package/dist/{src/services → services}/getRoutesForRouter.d.ts +0 -1
- package/dist/services/withRouteMethods.d.ts +7 -0
- package/dist/types/addLoader.d.ts +69 -0
- package/dist/types/addView.d.ts +104 -0
- package/dist/{src/types → types}/createRouteOptions.d.ts +45 -24
- package/dist/{src/types → types}/hooks.d.ts +2 -2
- 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}/resolved.d.ts +21 -2
- 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/types/routeViews.d.ts +44 -0
- package/dist/types/routeWithMethods.d.ts +16 -0
- package/dist/{src/types → types}/routerPlugin.d.ts +1 -1
- package/dist/{src/types → types}/routerRoute.d.ts +6 -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.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/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 +15 -15
- 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/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}/routerLink.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 → compositions}/useLink.d.ts +0 -0
- /package/dist/{src/compositions → compositions}/usePrefetching.d.ts +0 -0
- /package/dist/{src/compositions → compositions}/useQueryValue.browser.spec.d.ts +0 -0
- /package/dist/{src/compositions → compositions}/useQueryValue.d.ts +0 -0
- /package/dist/{src/compositions → compositions}/useQueryValue.spec-d.d.ts +0 -0
- /package/dist/{src/compositions → compositions}/useRejection.d.ts +0 -0
- /package/dist/{src/compositions → compositions}/useRoute.browser.spec.d.ts +0 -0
- /package/dist/{src/compositions → compositions}/useRoute.d.ts +0 -0
- /package/dist/{src/compositions → 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/guards → 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/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 → services}/arrayOf.d.ts +0 -0
- /package/dist/{src/services/combineQuery.spec.d.ts → services/arrayOf.spec.d.ts} +0 -0
- /package/dist/{src/services → services}/combineHash.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 → services}/combinePath.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 → services}/combineQuery.d.ts +0 -0
- /package/dist/{src/services/createIsExternal.spec.d.ts → services/combineQuery.spec.d.ts} +0 -0
- /package/dist/{src/services → services}/combineState.d.ts +0 -0
- /package/dist/{src/services/createResolvedRoute.spec.d.ts → services/combineState.spec.d.ts} +0 -0
- /package/dist/{src/services → services}/combineUrl.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 → services}/createComponentHooks.d.ts +0 -0
- /package/dist/{src/services → services}/createCurrentRejection.d.ts +0 -0
- /package/dist/{src/services/createRouteRedirects.spec.d.ts → services/createDataStore.spec.d.ts} +0 -0
- /package/dist/{src/services → services}/createExternalRoute.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 → services}/createParam.d.ts +0 -0
- /package/dist/{src/services → services}/createRejection.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/createRouterHistory.browser.spec.d.ts → services/createResolvedRoute.spec.d.ts} +0 -0
- /package/dist/{src/services → services}/createResolvedRouteQuery.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}/createRouteHooks.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/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 → services}/createRouter.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 → services}/createRouterAssets.d.ts +0 -0
- /package/dist/{src/services → services}/createRouterCallbackContext.d.ts +0 -0
- /package/dist/{src/services/getMatchesForUrl.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 → services}/createRouterHooks.d.ts +0 -0
- /package/dist/{src/services → services}/createRouterKeyStore.d.ts +0 -0
- /package/dist/{src/services/getRouteHooks.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/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 → services}/createUrl.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 → services}/getGlobalHooksForRouter.d.ts +0 -0
- /package/dist/{src/services → services}/getGlobalRouteHooks.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 → services}/getMatchesForUrl.d.ts +0 -0
- /package/dist/{src/services/params.spec.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 → services}/getRouteHooks.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/services → services}/hooks.d.ts +0 -0
- /package/dist/{src/tests → services}/hooks.spec.d.ts +0 -0
- /package/dist/{src/services → services}/insertBaseRoute.d.ts +0 -0
- /package/dist/{src/services/tupleOf.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/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 → services}/queryParamFilter.d.ts +0 -0
- /package/dist/{src/services/valibot.spec-d.d.ts → services/queryParamFilter.spec.d.ts} +0 -0
- /package/dist/{src/services → services}/routeRegex.d.ts +0 -0
- /package/dist/{src/services/valibot.spec.d.ts → services/routeRegex.spec.d.ts} +0 -0
- /package/dist/{src/services → services}/state.d.ts +0 -0
- /package/dist/{src/services/withParams.spec-d.d.ts → services/state.spec.d.ts} +0 -0
- /package/dist/{src/services → services}/tupleOf.d.ts +0 -0
- /package/dist/{src/services/withParams.spec.d.ts → services/tupleOf.spec.d.ts} +0 -0
- /package/dist/{src/services → services}/unionOf.d.ts +0 -0
- /package/dist/{src/services/zod.spec-d.d.ts → services/unionOf.spec.d.ts} +0 -0
- /package/dist/{src/services → services}/urlParser.d.ts +0 -0
- /package/dist/{src/services/zod.spec.d.ts → services/urlParser.spec.d.ts} +0 -0
- /package/dist/{src/services → services}/valibot.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/services → services}/withDefault.d.ts +0 -0
- /package/dist/{src/services → services}/withParams.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/services → services}/zod.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}/paramTypes.d.ts +0 -0
- /package/dist/{src/types → types}/params.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/types → types}/register.d.ts +0 -0
- /package/dist/{src/utilities/guards.spec.d.ts → types/register.spec.d.ts} +0 -0
- /package/dist/{src/types → types}/rejection.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/types → types}/routeTitle.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/utilities/trailingSlashes.spec.d.ts → types/routeWithParams.spec-d.d.ts} +0 -0
- /package/dist/{src/types → types}/router.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}/routerReject.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/utilities/urlSearchParams.spec.d.ts → types/routesMap.spec-ts.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}/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}/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}/setDocumentTitle.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,6 +1,11 @@
|
|
|
1
1
|
import { RouterAssets } from './services/createRouterAssets';
|
|
2
2
|
import { RegisteredRouter } from './types/register';
|
|
3
3
|
export type { WithHost, WithoutHost, WithParent, WithoutParent, CreateRouteOptions, PropsGetter, RouterViewPropsGetter, CreateRouteProps, ToRoute } from './types/createRouteOptions';
|
|
4
|
+
export type { RouteAddView, AddViewOptions, AddViewPropsGetter, AddViewPropsCallbackContext } from './types/addView';
|
|
5
|
+
export type { RouteAddLoader, AddLoaderOptions, LoaderGetter } from './types/addLoader';
|
|
6
|
+
export type { RouteCallbackContext } from './types/routeCallbackContext';
|
|
7
|
+
export type { RouteViews } from './types/routeViews';
|
|
8
|
+
export type { RouteLoader, RouteLoaders } from './types/routeLoaders';
|
|
4
9
|
export type { RejectionHooks, HookRemove, BeforeHookLifecycle, AfterHookLifecycle, HookLifecycle, BeforeEnterHookContext, BeforeEnterHook, AddBeforeEnterHook, BeforeUpdateHookContext, BeforeUpdateHook, AddBeforeUpdateHook, BeforeLeaveHookContext, BeforeLeaveHook, AddBeforeLeaveHook, AfterEnterHookContext, AfterEnterHook, AddAfterEnterHook, AfterUpdateHookContext, AfterUpdateHook, AddAfterUpdateHook, AfterLeaveHookContext, AfterLeaveHook, AddAfterLeaveHook, RejectionHookContext, RejectionHook, AddRejectionHook, ErrorHookContext, ErrorHook, AddErrorHook } from './types/hooks';
|
|
5
10
|
export * from './types/paramTypes';
|
|
6
11
|
export * from './types/prefetch';
|
|
@@ -26,7 +31,10 @@ export * from './types/urlString';
|
|
|
26
31
|
export type { Url, CreateUrlOptions, ParseUrlOptions } from './types/url';
|
|
27
32
|
export * from './types/useLink';
|
|
28
33
|
export { DuplicateParamsError } from './errors/duplicateParamsError';
|
|
34
|
+
export { LoaderDataAccessError } from './errors/loaderDataAccessError';
|
|
35
|
+
export { LoaderNameConflict } from './errors/loaderNameConflict';
|
|
29
36
|
export { MetaPropertyConflict } from './errors/metaPropertyConflict';
|
|
37
|
+
export { NavigationAbandonedError } from './errors/navigationAbandonedError';
|
|
30
38
|
export { RouterNotInstalledError } from './errors/routerNotInstalledError';
|
|
31
39
|
export { UseRouteInvalidError } from './errors/useRouteInvalidError';
|
|
32
40
|
export { createRoute } from './services/createRoute';
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { PrefetchConfig } from '../types/prefetch';
|
|
2
|
+
import { CreatedRouteOptions, Route } from '../types/route';
|
|
3
|
+
import { AnyFunction } from '../types/utilities';
|
|
4
|
+
export declare const DEFAULT_LOADER_NAME = "default";
|
|
5
|
+
/**
|
|
6
|
+
* The loose runtime shape of the `addLoader` options. Purposely wide: the name type each
|
|
7
|
+
* `RouteAddLoader` describes is refined per route.
|
|
8
|
+
*/
|
|
9
|
+
type LoaderOptions = {
|
|
10
|
+
name?: string;
|
|
11
|
+
prefetch?: PrefetchConfig;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* The runtime arguments accepted by `addLoader`.
|
|
15
|
+
*/
|
|
16
|
+
type AddLoaderParameters = [load: AnyFunction, options?: LoaderOptions];
|
|
17
|
+
/**
|
|
18
|
+
* The loose runtime signature of the `addLoader` method. Purposely wide: it returns Route rather than the
|
|
19
|
+
* refined chainable route each `RouteAddLoader` overload describes.
|
|
20
|
+
*/
|
|
21
|
+
export type AddLoader = (...args: AddLoaderParameters) => Route;
|
|
22
|
+
type Loader = {
|
|
23
|
+
name: string;
|
|
24
|
+
load: AnyFunction;
|
|
25
|
+
prefetch: PrefetchConfig | undefined;
|
|
26
|
+
};
|
|
27
|
+
export declare function toLoader(load: AnyFunction, options: LoaderOptions | undefined): Loader;
|
|
28
|
+
/**
|
|
29
|
+
* Returns a new match with the loader merged into its loaders under the loader's name.
|
|
30
|
+
*
|
|
31
|
+
* Matches are `markRaw` so that making a route reactive does not turn its loaders into reactive proxies.
|
|
32
|
+
* Spreading a match drops that, so the rebuilt one is marked again.
|
|
33
|
+
*/
|
|
34
|
+
export declare function addLoaderToMatch(match: CreatedRouteOptions, { name, load, prefetch }: Loader): CreatedRouteOptions;
|
|
35
|
+
/**
|
|
36
|
+
* A route's data combines the loaders of every match, so a name an ancestor already uses would be
|
|
37
|
+
* ambiguous. Adding a loader the route itself already has is an override, and allowed.
|
|
38
|
+
*/
|
|
39
|
+
export declare function checkForLoaderConflict(ancestors: CreatedRouteOptions[], name: string): void;
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Component } from 'vue';
|
|
2
|
+
import { PropsGetter } from '../types/createRouteOptions';
|
|
3
|
+
import { PrefetchConfig } from '../types/prefetch';
|
|
4
|
+
import { CreatedRouteOptions, Route } from '../types/route';
|
|
5
|
+
/**
|
|
6
|
+
* The loose runtime shape of the `addView` options. Purposely wide: the getter and name types each
|
|
7
|
+
* `RouteAddView` describes are refined per route and component.
|
|
8
|
+
*/
|
|
9
|
+
type ViewOptions = {
|
|
10
|
+
name?: string;
|
|
11
|
+
props?: PropsGetter;
|
|
12
|
+
prefetch?: PrefetchConfig;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* The runtime arguments accepted by `addView`.
|
|
16
|
+
*/
|
|
17
|
+
type AddViewParameters = [component: Component, options?: ViewOptions];
|
|
18
|
+
/**
|
|
19
|
+
* The loose runtime signature of the `addView` method. Purposely wide: it returns Route rather than the
|
|
20
|
+
* refined chainable route each `RouteAddView` overload describes.
|
|
21
|
+
*/
|
|
22
|
+
export type AddView = (...args: AddViewParameters) => Route;
|
|
23
|
+
type View = {
|
|
24
|
+
name: string;
|
|
25
|
+
component: Component;
|
|
26
|
+
props: PropsGetter | undefined;
|
|
27
|
+
prefetch: PrefetchConfig | undefined;
|
|
28
|
+
};
|
|
29
|
+
export declare function toView(component: Component, options: ViewOptions | undefined): View;
|
|
30
|
+
/**
|
|
31
|
+
* Returns a new match with the view merged into its views under the view's name.
|
|
32
|
+
*
|
|
33
|
+
* Matches are `markRaw` so that making a route reactive does not turn its components into reactive
|
|
34
|
+
* proxies. Spreading a match drops that, so the rebuilt one is marked again.
|
|
35
|
+
*/
|
|
36
|
+
export declare function addViewToMatch(match: CreatedRouteOptions, { name, component, props, prefetch }: View): CreatedRouteOptions;
|
|
37
|
+
export {};
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { AsyncComponentLoader, Component, FunctionalComponent, InjectionKey } from 'vue';
|
|
2
|
-
import { CreatedRouteOptions } from '../types/route';
|
|
3
2
|
import { Router } from '../types/router';
|
|
4
3
|
type Constructor = new (...args: any) => any;
|
|
5
4
|
export type ComponentProps<TComponent extends Component> = TComponent extends Constructor ? InstanceType<TComponent>['$props'] : TComponent extends AsyncComponentLoader<infer T extends Component> ? ComponentProps<T> : TComponent extends FunctionalComponent<infer T> ? T : {};
|
|
6
5
|
type CreateComponentWrapperConfig = {
|
|
7
|
-
|
|
6
|
+
id: string;
|
|
8
7
|
name: string;
|
|
9
8
|
component: Component;
|
|
10
9
|
};
|
|
11
|
-
export declare function createComponentPropsWrapper(routerKey: InjectionKey<Router>, {
|
|
10
|
+
export declare function createComponentPropsWrapper(routerKey: InjectionKey<Router>, { id, name, component }: CreateComponentWrapperConfig): Component;
|
|
12
11
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Component, InjectionKey } from 'vue';
|
|
2
|
-
import {
|
|
2
|
+
import { RouteViews } from '../types/routeViews';
|
|
3
3
|
import { Router } from '../types/router';
|
|
4
4
|
export type ComponentsStore = {
|
|
5
|
-
getRouteComponents: (
|
|
5
|
+
getRouteComponents: (id: string, views: RouteViews) => Record<string, Component>;
|
|
6
6
|
};
|
|
7
7
|
export declare function createComponentsStore<TRouter extends Router>(routerKey: InjectionKey<TRouter>): ComponentsStore;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { InjectionKey } from 'vue';
|
|
2
|
+
import { RouteValueStore } from './createRouteValueStore';
|
|
3
|
+
import { Router, RouterRouteUnion } from '../types/router';
|
|
4
|
+
import { ResolvedRoute, WithData } from '../types/resolved';
|
|
5
|
+
import { Routes } from '../types/route';
|
|
6
|
+
import { RouterPush } from '../types/routerPush';
|
|
7
|
+
type ResolvedRouteUpdate = (route: ResolvedRoute) => void;
|
|
8
|
+
type CurrentRouteContext<TRoutes extends Routes = Routes> = {
|
|
9
|
+
currentRoute: ResolvedRoute & WithData;
|
|
10
|
+
routerRoute: RouterRouteUnion<TRoutes>;
|
|
11
|
+
updateRoute: ResolvedRouteUpdate;
|
|
12
|
+
};
|
|
13
|
+
type CurrentRouteOptions = {
|
|
14
|
+
routerKey: InjectionKey<Router>;
|
|
15
|
+
fallbackRoute: ResolvedRoute;
|
|
16
|
+
push: RouterPush;
|
|
17
|
+
getData: RouteValueStore['getData'];
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* The route the router is on. Data is read from the store as a route becomes current, which is the only
|
|
21
|
+
* route whose data anything computes — so a caller hands over whatever it resolved and does not have to
|
|
22
|
+
* know that data is attached at all.
|
|
23
|
+
*/
|
|
24
|
+
export declare function createCurrentRoute<TRoutes extends Routes>(options: CurrentRouteOptions): CurrentRouteContext<TRoutes>;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export type DataResultValue = {
|
|
2
|
+
kind: 'value';
|
|
3
|
+
value: unknown;
|
|
4
|
+
};
|
|
5
|
+
export type DataResultError = {
|
|
6
|
+
kind: 'error';
|
|
7
|
+
error: unknown;
|
|
8
|
+
};
|
|
9
|
+
export type DataResultPending = {
|
|
10
|
+
kind: 'pending';
|
|
11
|
+
};
|
|
12
|
+
export type DataResultRunning = {
|
|
13
|
+
kind: 'running';
|
|
14
|
+
};
|
|
15
|
+
export type DataResultMissing = {
|
|
16
|
+
kind: 'missing';
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Where a key has got to: nothing has asked for it, something is waiting on it, its getter is in flight,
|
|
20
|
+
* or how that getter settled. Tagged so that a getter returning `undefined` or an `Error` stays a value.
|
|
21
|
+
*/
|
|
22
|
+
export type DataResult = DataResultValue | DataResultError | DataResultPending | DataResultRunning | DataResultMissing;
|
|
23
|
+
/**
|
|
24
|
+
* A set of values that live and die together. A link owns one for whatever it points at, and the current
|
|
25
|
+
* navigation owns one.
|
|
26
|
+
*/
|
|
27
|
+
export type DataStore = {
|
|
28
|
+
/**
|
|
29
|
+
* The value for a key, whether or not anything has computed it yet. Subscribing to a key nobody has set
|
|
30
|
+
* leaves a promise waiting for whoever does.
|
|
31
|
+
*/
|
|
32
|
+
subscribe: (key: string) => Promise<unknown>;
|
|
33
|
+
/**
|
|
34
|
+
* Computes a key, unless something already has. A key promoted from another store while its getter is
|
|
35
|
+
* still running is left alone, so navigation adopts it rather than computing it a second time.
|
|
36
|
+
*/
|
|
37
|
+
set: (key: string, getter: () => unknown) => void;
|
|
38
|
+
/**
|
|
39
|
+
* What is known about a key, without waiting for it. Reactive, and readable during render.
|
|
40
|
+
*/
|
|
41
|
+
get: (key: string) => DataResult;
|
|
42
|
+
/**
|
|
43
|
+
* Ends the store. Every value is rejected so that anything waiting on one resumes rather than staying
|
|
44
|
+
* suspended, then discarded.
|
|
45
|
+
*/
|
|
46
|
+
dispose: (reason: Error) => void;
|
|
47
|
+
};
|
|
48
|
+
export declare function createDataStore(): DataStore;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { DataStore } from './createDataStore';
|
|
2
|
+
import { ResolvedRoute } from '../types/resolved';
|
|
3
|
+
/**
|
|
4
|
+
* Which store the rendered route reads from, and which one the next navigation will adopt.
|
|
5
|
+
*
|
|
6
|
+
* A navigation gets its own store so the one it replaces can be disposed outright. A followed link stages
|
|
7
|
+
* the store it prefetched into, which the navigation it triggers picks up — staged rather than handed over
|
|
8
|
+
* directly because a link is followed before that navigation starts.
|
|
9
|
+
*/
|
|
10
|
+
export type NavigationStores = {
|
|
11
|
+
/**
|
|
12
|
+
* The store the rendered route reads props from.
|
|
13
|
+
*/
|
|
14
|
+
current: () => DataStore;
|
|
15
|
+
/**
|
|
16
|
+
* Parks a followed link's store for the navigation it triggered. A store already parked is disposed,
|
|
17
|
+
* since following a second link before the first navigation arrives abandons the first.
|
|
18
|
+
*/
|
|
19
|
+
stage: (store: DataStore) => void;
|
|
20
|
+
/**
|
|
21
|
+
* Swaps in the staged store, or a fresh one, and hands back the store being replaced for disposal.
|
|
22
|
+
*/
|
|
23
|
+
promote: () => DataStore;
|
|
24
|
+
};
|
|
25
|
+
export declare function createNavigationStores(): NavigationStores;
|
|
26
|
+
/**
|
|
27
|
+
* What a stored value is: the props of a view, or the data of a loader. Part of the key so that a view
|
|
28
|
+
* and a loader sharing a name on the same route are still two values.
|
|
29
|
+
*/
|
|
30
|
+
export type DataKind = 'props' | 'loader';
|
|
31
|
+
export declare function getDataKey(kind: DataKind, id: string, name: string, route: ResolvedRoute): string;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import { CreateRouteOptions, PropsGetter, CreateRouteProps,
|
|
2
|
-
import {
|
|
3
|
-
import { ExtractRouteContext } from '../types/routeContext';
|
|
4
|
-
import { RouteRedirects } from '../types/redirects';
|
|
5
|
-
import { RouteSetTitle } from '../types/routeTitle';
|
|
1
|
+
import { CreateRouteOptions, PropsGetter, CreateRouteProps, ToRouteMatches, ToRouteUrl, RouterViewPropsGetter } from '../types/createRouteOptions';
|
|
2
|
+
import { RouteWithMethods } from '../types/routeWithMethods';
|
|
6
3
|
type CreateRouteWithProps<TOptions extends CreateRouteOptions, TProps extends CreateRouteProps<TOptions>> = CreateRouteProps<TOptions> extends RouterViewPropsGetter<TOptions> ? [props?: RouterViewPropsGetter<TOptions>] : CreateRouteProps<TOptions> extends PropsGetter<TOptions> ? Partial<ReturnType<CreateRouteProps<TOptions>>> extends ReturnType<CreateRouteProps<TOptions>> ? [props?: TProps] : [props: TProps] : Partial<CreateRouteProps<TOptions>> extends CreateRouteProps<TOptions> ? [props?: TProps] : [props: TProps];
|
|
7
|
-
export declare function createRoute<const TOptions extends CreateRouteOptions, const TProps extends CreateRouteProps<TOptions>>(options: TOptions, ...args: CreateRouteWithProps<TOptions, TProps>):
|
|
4
|
+
export declare function createRoute<const TOptions extends CreateRouteOptions, const TProps extends CreateRouteProps<TOptions>>(options: TOptions, ...args: CreateRouteWithProps<TOptions, TProps>): RouteWithMethods<ToRouteUrl<TOptions>, ToRouteMatches<TOptions, TProps>>;
|
|
8
5
|
export {};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { PrefetchConfigs, PrefetchStrategy } from '../types/prefetch';
|
|
2
|
+
import { ResolvedRoute, WithData } from '../types/resolved';
|
|
3
|
+
import { HasVueAppStore } from './createVueAppStore';
|
|
4
|
+
import { CallbackContextPush, CallbackContextReject, CallbackContextSuccess } from '../types/callbackContext';
|
|
5
|
+
import { PropsResult } from '../utilities/props';
|
|
6
|
+
import { MaybePromise } from '../types/utilities';
|
|
7
|
+
/**
|
|
8
|
+
* A navigation that was superseded before its values settled. The navigation that replaced it owns the
|
|
9
|
+
* outcome, so this one reports that it went nowhere rather than a success it never had.
|
|
10
|
+
*/
|
|
11
|
+
type RouteValueAbandoned = {
|
|
12
|
+
status: 'ABANDONED';
|
|
13
|
+
};
|
|
14
|
+
export type RouteValueResponse = CallbackContextSuccess | CallbackContextPush | CallbackContextReject | RouteValueAbandoned;
|
|
15
|
+
/**
|
|
16
|
+
* How a navigation's props and loaders settled. Reported separately because props are what a view renders
|
|
17
|
+
* with while loaders hold nothing up, so a slow loader must not be what decides when props are known.
|
|
18
|
+
*/
|
|
19
|
+
export type RouteValueResponses = {
|
|
20
|
+
props: Promise<RouteValueResponse>;
|
|
21
|
+
loaders: Promise<RouteValueResponse>;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* A link's own bucket of prefetched values, handed to the current navigation when the link is followed and
|
|
25
|
+
* discarded otherwise.
|
|
26
|
+
*/
|
|
27
|
+
export type PrefetchStore = {
|
|
28
|
+
/**
|
|
29
|
+
* Computes props for views whose prefetch option matches the given strategy.
|
|
30
|
+
*/
|
|
31
|
+
prefetch: (strategy: PrefetchStrategy, route: ResolvedRoute, configs: PrefetchConfigs) => void;
|
|
32
|
+
/**
|
|
33
|
+
* Stages the prefetched store for the next navigation to adopt.
|
|
34
|
+
*/
|
|
35
|
+
commit: () => void;
|
|
36
|
+
/**
|
|
37
|
+
* Abandons what was prefetched and starts over, for a link that now points somewhere else.
|
|
38
|
+
*/
|
|
39
|
+
reset: () => void;
|
|
40
|
+
/**
|
|
41
|
+
* Abandons what was prefetched, for a link that is gone.
|
|
42
|
+
*/
|
|
43
|
+
dispose: () => void;
|
|
44
|
+
};
|
|
45
|
+
export type RouteValueStore = HasVueAppStore & {
|
|
46
|
+
createPrefetchStore: () => PrefetchStore;
|
|
47
|
+
setRouteValues: (route: ResolvedRoute) => RouteValueResponses;
|
|
48
|
+
getProps: (id: string, name: string, route: ResolvedRoute) => MaybePromise<PropsResult>;
|
|
49
|
+
/**
|
|
50
|
+
* What a route exposes as `data`. Resolved per read rather than captured, so it stays correct as
|
|
51
|
+
* navigations replace the store its values live in.
|
|
52
|
+
*/
|
|
53
|
+
getData: (route: ResolvedRoute) => WithData['data'];
|
|
54
|
+
};
|
|
55
|
+
export declare function createRouteValueStore(): RouteValueStore;
|
|
56
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { CreateRouteOptions, CreateRouteProps } from '../types/createRouteOptions';
|
|
2
|
+
import { RouteViews } from '../types/routeViews';
|
|
3
|
+
export declare const DEFAULT_VIEW_NAME = "default";
|
|
4
|
+
/**
|
|
5
|
+
* Builds the initial views for a route, seeding components from the (deprecated) `component`/`components`
|
|
6
|
+
* options and prop getters from the props argument. Subsequent views are added via the route's `addView`.
|
|
7
|
+
*
|
|
8
|
+
* This is where the props argument's two shapes — a single getter for the unnamed view, or a record keyed
|
|
9
|
+
* by view name — are normalized, so the rest of the router only deals with views keyed by name.
|
|
10
|
+
*/
|
|
11
|
+
export declare function createRouteViews(options: CreateRouteOptions, props?: CreateRouteProps): RouteViews;
|
|
12
|
+
/**
|
|
13
|
+
* The names of the views that have a props getter. A view without one is never computed, so waiting on it
|
|
14
|
+
* would never settle.
|
|
15
|
+
*/
|
|
16
|
+
export declare function viewNamesWithProps(views: RouteViews): string[];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { InjectionKey } from 'vue';
|
|
2
|
-
import { ResolvedRoute } from '../types/resolved';
|
|
2
|
+
import { ResolvedRoute, WithData } from '../types/resolved';
|
|
3
3
|
import { RouterRoute } from '../types/routerRoute';
|
|
4
4
|
import { RouterPush } from '../types/routerPush';
|
|
5
5
|
import { Router } from '../types/router';
|
|
6
6
|
export declare function isRouterRoute(routerKey: InjectionKey<Router>, value: unknown): value is RouterRoute;
|
|
7
|
-
export declare function createRouterRoute<TRoute extends ResolvedRoute>(routerKey: InjectionKey<Router>, route: TRoute, push: RouterPush): RouterRoute<TRoute>;
|
|
7
|
+
export declare function createRouterRoute<TRoute extends ResolvedRoute & WithData>(routerKey: InjectionKey<Router>, route: TRoute, push: RouterPush): RouterRoute<TRoute>;
|
|
@@ -11,7 +11,6 @@ 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
|
-
matched: import('../types/route').CreatedRouteOptions;
|
|
15
14
|
matches: import('../types/route').CreatedRouteOptions[];
|
|
16
15
|
name: string;
|
|
17
16
|
meta: Record<string, unknown>;
|
|
@@ -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;
|
|
@@ -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 {};
|