reactive,
unref,
} from 'vue'
-import {
- RouteLocation,
- RouteLocationNormalized,
- Immutable,
- VueUseOptions,
-} from '../types'
+import { RouteLocation, RouteLocationNormalized, VueUseOptions } from '../types'
import { isSameLocationObject, isSameRouteRecord } from '../utils'
import { routerKey } from '../utils/injectionSymbols'
import { RouteRecordNormalized } from '../matcher/types'
}
function includesParams(
- outter: Immutable<RouteLocationNormalized['params']>,
- inner: Immutable<RouteLocationNormalized['params']>
+ outter: RouteLocationNormalized['params'],
+ inner: RouteLocationNormalized['params']
): boolean {
for (let key in inner) {
let innerValue = inner[key]
RouteLocationMatched,
VueUseOptions,
RouteLocationNormalizedResolved,
- Immutable,
} from '../types'
import {
matchedRouteKey,
} from '../utils/injectionSymbols'
interface ViewProps {
- route: Immutable<RouteLocationNormalizedResolved>
+ route: RouteLocationNormalizedResolved
name: string
}
name: Required<RouteRecord>['name']
) => RouteRecordMatcher | undefined
resolve: (
- location: Readonly<MatcherLocation>,
- currentLocation: Readonly<MatcherLocationNormalized>
+ location: MatcherLocation,
+ currentLocation: MatcherLocationNormalized
) => MatcherLocationNormalized
}
START_LOCATION_NORMALIZED,
Lazy,
TODO,
- Immutable,
MatcherLocationNormalized,
RouteLocationNormalizedResolved,
} from './types'
export interface Router {
history: RouterHistory
- currentRoute: Ref<Immutable<RouteLocationNormalizedResolved>>
+ currentRoute: Ref<RouteLocationNormalizedResolved>
addRoute(parentName: string, route: RouteRecord): () => void
addRoute(route: RouteRecord): () => void
getRoutes(): RouteRecordNormalized[]
resolve(to: RouteLocation): RouteLocationNormalized
- createHref(to: Immutable<RouteLocationNormalized>): string
+ createHref(to: RouteLocationNormalized): string
push(to: RouteLocation): Promise<RouteLocationNormalizedResolved>
replace(to: RouteLocation): Promise<RouteLocationNormalizedResolved>
const currentRoute = ref<RouteLocationNormalizedResolved>(
START_LOCATION_NORMALIZED
)
- let pendingLocation: Immutable<RouteLocationNormalized> = START_LOCATION_NORMALIZED
+ let pendingLocation: RouteLocationNormalized = START_LOCATION_NORMALIZED
if (isClient && 'scrollRestoration' in window.history) {
window.history.scrollRestoration = 'manual'
async function pushWithRedirect(
to: RouteLocation | RouteLocationNormalized,
redirectedFrom: RouteLocationNormalized | undefined
- ): Promise<RouteLocationNormalizedResolved> {
+ ): Promise<TODO> {
const toLocation: RouteLocationNormalized = (pendingLocation =
// Some functions will pass a normalized location and we don't need to resolve it again
typeof to === 'object' && 'matched' in to ? to : resolve(to))
- const from: RouteLocationNormalizedResolved = currentRoute.value
+ const from = currentRoute.value
const data: HistoryState | undefined = (to as any).state
// @ts-ignore: no need to check the string as force do not exist on a string
const force: boolean | undefined = to.force
return [leavingRecords, updatingRecords, enteringRecords]
}
-// function isSameLocation(
-// a: Immutable<RouteLocationNormalized>,
-// b: Immutable<RouteLocationNormalized>
-// ): boolean {
-// return (
-// a.name === b.name &&
-// a.path === b.path &&
-// a.hash === b.hash &&
-// isSameLocationObject(a.query, b.query) &&
-// a.matched.length === b.matched.length &&
-// a.matched.every((record, i) => isSameRouteRecord(record, b.matched[i]))
-// )
-// }
-
function isSameRouteLocation(
a: RouteLocationNormalized,
b: RouteLocationNormalized
export type Lazy<T> = () => Promise<T>
export type Override<T, U> = Pick<T, Exclude<keyof T, keyof U>> & U
+// TODO: find a better way to type readonly types. Readonly<T> is non recursive, maybe we should use it at multiple places. It would also allow preventing the problem Immutable create.
export type Immutable<T> = {
readonly [P in keyof T]: Immutable<T[P]>
}
props?:
| boolean
| Record<string, any>
- | ((to: Immutable<RouteLocationNormalized>) => Record<string, any>)
+ | ((to: RouteLocationNormalized) => Record<string, any>)
// TODO: beforeEnter has no effect with redirect, move and test
beforeEnter?: NavigationGuard<undefined> | NavigationGuard<undefined>[]
meta?: Record<string | number | symbol, any>
export type RouteRecordRedirectOption =
| RouteLocation
- | ((to: Immutable<RouteLocationNormalized>) => RouteLocation)
+ | ((to: RouteLocationNormalized) => RouteLocation)
export interface RouteRecordRedirect extends RouteRecordCommon {
redirect: RouteRecordRedirectOption
beforeEnter?: never
(
this: V,
// TODO: we could maybe add extra information like replace: true/false
- to: Immutable<RouteLocationNormalized>,
- from: Immutable<RouteLocationNormalized>,
+ to: RouteLocationNormalized,
+ from: RouteLocationNormalized,
next: NavigationGuardCallback
): any
}
export interface PostNavigationGuard {
- (
- to: Immutable<RouteLocationNormalized>,
- from: Immutable<RouteLocationNormalized>
- ): any
+ (to: RouteLocationNormalized, from: RouteLocationNormalized): any
}
export * from './type-guards'
import {
RouteLocationNormalized,
RouteParams,
- Immutable,
RouteComponent,
RouteLocationNormalizedResolved,
} from '../types'
}
export function isSameRouteRecord(
- a: Immutable<RouteRecordNormalized>,
- b: Immutable<RouteRecordNormalized>
+ a: RouteRecordNormalized,
+ b: RouteRecordNormalized
): boolean {
// since the original record has an undefined value for aliasOf
// but all aliases point to the original record, this will always compare
}
export function isSameLocationObject(
- a: Immutable<RouteLocationNormalized['query']>,
- b: Immutable<RouteLocationNormalized['query']>
+ a: RouteLocationNormalized['query'],
+ b: RouteLocationNormalized['query']
): boolean
export function isSameLocationObject(
- a: Immutable<RouteLocationNormalized['params']>,
- b: Immutable<RouteLocationNormalized['params']>
+ a: RouteLocationNormalized['params'],
+ b: RouteLocationNormalized['params']
): boolean
export function isSameLocationObject(
- a: Immutable<RouteLocationNormalized['query' | 'params']>,
- b: Immutable<RouteLocationNormalized['query' | 'params']>
+ a: RouteLocationNormalized['query' | 'params'],
+ b: RouteLocationNormalized['query' | 'params']
): boolean {
const aKeys = Object.keys(a)
const bKeys = Object.keys(b)
}
function isSameLocationObjectValue(
- a: Immutable<LocationQueryValue | LocationQueryValue[]>,
- b: Immutable<LocationQueryValue | LocationQueryValue[]>
+ a: LocationQueryValue | LocationQueryValue[],
+ b: LocationQueryValue | LocationQueryValue[]
): boolean
+function isSameLocationObjectValue(a: RouteParams, b: RouteParams): boolean
function isSameLocationObjectValue(
- a: Immutable<RouteParams | RouteParams[]>,
- b: Immutable<RouteParams | RouteParams[]>
-): boolean
-function isSameLocationObjectValue(
- a: Immutable<
- LocationQueryValue | LocationQueryValue[] | RouteParams | RouteParams[]
- >,
- b: Immutable<
- LocationQueryValue | LocationQueryValue[] | RouteParams | RouteParams[]
- >
+ a: LocationQueryValue | LocationQueryValue[] | RouteParams,
+ b: LocationQueryValue | LocationQueryValue[] | RouteParams
): boolean {
if (typeof a !== typeof b) return false
// both a and b are arrays
import { InjectionKey, ComputedRef } from 'vue'
-import {
- RouteLocationMatched,
- Immutable,
- RouteLocationNormalizedResolved,
-} from '../types'
+import { RouteLocationMatched, RouteLocationNormalizedResolved } from '../types'
import { Router } from '../router'
export const hasSymbol =
export const routerKey = PolySymbol('r') as InjectionKey<Router>
// rt = route location
export const routeLocationKey = PolySymbol('rl') as InjectionKey<
- Immutable<RouteLocationNormalizedResolved>
+ RouteLocationNormalizedResolved
>
dependencies:
"@types/yargs-parser" "*"
-"@vue/compiler-core@3.0.0-alpha.9":
- version "3.0.0-alpha.9"
- resolved "https://registry.yarnpkg.com/@vue/compiler-core/-/compiler-core-3.0.0-alpha.9.tgz#d54cee813bb444afbf347da7f49056e523197b70"
- integrity sha512-Hx4yr83DwIS4B6WfEXWJYcD5EjGoBLQKx7EfoKTvp7++ssO574J/BgasJSUbw/DOm3sHumXZtWRDTn/SKSTs7Q==
+"@vue/compiler-core@3.0.0-alpha.10":
+ version "3.0.0-alpha.10"
+ resolved "https://registry.yarnpkg.com/@vue/compiler-core/-/compiler-core-3.0.0-alpha.10.tgz#39e8de2d7fe8a932cd08958200f37086a9d6841a"
+ integrity sha512-YXJJyFfkgmX3Rnf+sEcL8RR9a9UiHqB6ng1pzN1Dy8STASqUBdwinvi/xBuuCS7mDls12xn562y5CEATAwZs/Q==
dependencies:
"@babel/parser" "^7.8.6"
"@babel/types" "^7.8.6"
- "@vue/shared" "3.0.0-alpha.9"
+ "@vue/shared" "3.0.0-alpha.10"
estree-walker "^0.8.1"
source-map "^0.6.1"
-"@vue/compiler-dom@3.0.0-alpha.9":
- version "3.0.0-alpha.9"
- resolved "https://registry.yarnpkg.com/@vue/compiler-dom/-/compiler-dom-3.0.0-alpha.9.tgz#cb93b9f25eaabaf084bcbae5518cd91565b09ba3"
- integrity sha512-LgYtgKTcjjRWX41EMpjAdcvNTM1mSvV6Z9iXcGQs348PzcbihboFvaVqOkK14f9R1d5WsnCaYvUNuIGSNV0Xig==
+"@vue/compiler-dom@3.0.0-alpha.10":
+ version "3.0.0-alpha.10"
+ resolved "https://registry.yarnpkg.com/@vue/compiler-dom/-/compiler-dom-3.0.0-alpha.10.tgz#be9ec1d24d0c4d96d164f8e00a479bd88a45e55d"
+ integrity sha512-hOasMBUsmqccY9Qyytqmrup4AnxQ6zBHT8tC9QpfdtygvxrFK2uNvNZlPoZay2hB13fJjZgRdCyxELM0zB4Hww==
dependencies:
- "@vue/compiler-core" "3.0.0-alpha.9"
- "@vue/shared" "3.0.0-alpha.9"
+ "@vue/compiler-core" "3.0.0-alpha.10"
+ "@vue/shared" "3.0.0-alpha.10"
-"@vue/compiler-sfc@latest":
- version "3.0.0-alpha.9"
- resolved "https://registry.yarnpkg.com/@vue/compiler-sfc/-/compiler-sfc-3.0.0-alpha.9.tgz#5d28d9d18fd0c4fb7fbe0e08f85f333fd7ecc8b1"
- integrity sha512-Wr4O0J/lO4Q5Li6RfhZFZNIuYlBkmhk6UxxgCWdW1iPko3/C/oI9/k2SBSiRQcGCE+J5N3l/x1elYlq77YHvHA==
+"@vue/compiler-sfc@^3.0.0-alpha.10":
+ version "3.0.0-alpha.10"
+ resolved "https://registry.yarnpkg.com/@vue/compiler-sfc/-/compiler-sfc-3.0.0-alpha.10.tgz#c2e148d224bdcf8b1a1be026e492c8a2e65401a1"
+ integrity sha512-JyZbNkAOTKcEk90/9eB+sqsBBCP5+exspDYLPmiL5HXak5G1+pQsVFB8sZAEqz35TMDoM2CxTLBuwKdhF6jEvQ==
dependencies:
- "@vue/compiler-core" "3.0.0-alpha.9"
- "@vue/compiler-dom" "3.0.0-alpha.9"
- "@vue/compiler-ssr" "3.0.0-alpha.9"
- "@vue/shared" "3.0.0-alpha.9"
+ "@vue/compiler-core" "3.0.0-alpha.10"
+ "@vue/compiler-dom" "3.0.0-alpha.10"
+ "@vue/compiler-ssr" "3.0.0-alpha.10"
+ "@vue/shared" "3.0.0-alpha.10"
consolidate "^0.15.1"
hash-sum "^2.0.0"
lru-cache "^5.1.1"
postcss-selector-parser "^6.0.2"
source-map "^0.6.1"
-"@vue/compiler-ssr@3.0.0-alpha.9":
- version "3.0.0-alpha.9"
- resolved "https://registry.yarnpkg.com/@vue/compiler-ssr/-/compiler-ssr-3.0.0-alpha.9.tgz#e5b64601dfa24437a0e7b5c56b98de4458fa5334"
- integrity sha512-BW3rpZyy6xxrvjGEM5vsadQrYH8kiG1MAO/8aKW4mgW+4Rj34MUATrWwYdmk+yVsgnaMirfUYuc4gRZbcTZCYw==
+"@vue/compiler-ssr@3.0.0-alpha.10":
+ version "3.0.0-alpha.10"
+ resolved "https://registry.yarnpkg.com/@vue/compiler-ssr/-/compiler-ssr-3.0.0-alpha.10.tgz#5f4cb1ddf748637087847401e0bd7f5bfa6bc166"
+ integrity sha512-9wwuz524VENQtIimzT70bG0Lqlk5L9l9+sah3Ghz8/kflOGOX2EyZKU3VhCOJ5cTt6CcFch63toKaVALCHzgtg==
dependencies:
- "@vue/compiler-dom" "3.0.0-alpha.9"
- "@vue/shared" "3.0.0-alpha.9"
+ "@vue/compiler-dom" "3.0.0-alpha.10"
+ "@vue/shared" "3.0.0-alpha.10"
-"@vue/reactivity@3.0.0-alpha.9":
- version "3.0.0-alpha.9"
- resolved "https://registry.yarnpkg.com/@vue/reactivity/-/reactivity-3.0.0-alpha.9.tgz#e8c8b5ecaad3a60978a503e4fdfd277644c49738"
- integrity sha512-Z9jlQ2yjNQIcVBg1SSViUQH8UgVhXHFblw4c6Xrf7vgejjxAqJwk6DKNbAJlneeA3Z84Ul+1Q8JY4zClLagW/A==
+"@vue/reactivity@3.0.0-alpha.10":
+ version "3.0.0-alpha.10"
+ resolved "https://registry.yarnpkg.com/@vue/reactivity/-/reactivity-3.0.0-alpha.10.tgz#d859acd384e42d42086cfefbefe478825aaa9b82"
+ integrity sha512-H4E0kbQQuc9W0eVKkPLK5g1CwUQkMh4pUWEE/Gl2pZsnDVNJlvbZIMwKu6P5cjd30Nnbv2sG3+wcUGS4TplDuA==
dependencies:
- "@vue/shared" "3.0.0-alpha.9"
+ "@vue/shared" "3.0.0-alpha.10"
-"@vue/runtime-core@3.0.0-alpha.9":
- version "3.0.0-alpha.9"
- resolved "https://registry.yarnpkg.com/@vue/runtime-core/-/runtime-core-3.0.0-alpha.9.tgz#295884f0cbec22be3fbcfce0ff1a2493e33abb67"
- integrity sha512-mqTQ2kpKtUKwvMT23VDm6HEIt+8SxvOaL47aLs5uROs7Jamgp0K2oNkGH/MltWpaDkXVSsbSBBgijgYDsKlbZw==
+"@vue/runtime-core@3.0.0-alpha.10":
+ version "3.0.0-alpha.10"
+ resolved "https://registry.yarnpkg.com/@vue/runtime-core/-/runtime-core-3.0.0-alpha.10.tgz#abba11b4c8ed4933632050c0319f63fffe66bb86"
+ integrity sha512-b4YPU+DnowcthtcZSPgAxEExAq/dz31aQasiY1lvSB54y4T2QNYOydVYnZsFUMOFhN0Fh3+k5s1dTolorem1cw==
dependencies:
- "@vue/reactivity" "3.0.0-alpha.9"
- "@vue/shared" "3.0.0-alpha.9"
+ "@vue/reactivity" "3.0.0-alpha.10"
+ "@vue/shared" "3.0.0-alpha.10"
-"@vue/runtime-dom@3.0.0-alpha.9":
- version "3.0.0-alpha.9"
- resolved "https://registry.yarnpkg.com/@vue/runtime-dom/-/runtime-dom-3.0.0-alpha.9.tgz#dfbfcbd4e3bf69a74736c1c3d79780a31434ad6f"
- integrity sha512-zWDW7Lg38PDoW+grQsSPzBauMMeY6A9yw/qaAzzgeN71EXJRInmv1fog/dVuWbD7/ZNc8E4jzDUJL16ryGbSmg==
+"@vue/runtime-dom@3.0.0-alpha.10":
+ version "3.0.0-alpha.10"
+ resolved "https://registry.yarnpkg.com/@vue/runtime-dom/-/runtime-dom-3.0.0-alpha.10.tgz#005880179a52001b4e4e76c816555cc0ce5d16a9"
+ integrity sha512-X0UcZlXBwZ0OW4yw3hA+8uE2CArPDf2LKk9aTIi3xrCeluQmJSEUsgDNxHBqvmNhVGqdi0kPB09NrOxfEtyPhw==
dependencies:
- "@vue/runtime-core" "3.0.0-alpha.9"
- "@vue/shared" "3.0.0-alpha.9"
+ "@vue/runtime-core" "3.0.0-alpha.10"
+ "@vue/shared" "3.0.0-alpha.10"
csstype "^2.6.8"
-"@vue/shared@3.0.0-alpha.9":
- version "3.0.0-alpha.9"
- resolved "https://registry.yarnpkg.com/@vue/shared/-/shared-3.0.0-alpha.9.tgz#681053df422dea1c8c2f54e860ef7c4b949b9852"
- integrity sha512-34jsIMNwXJ6V6qlGx5ATw4YHTRxoKCyKN8MulRrUxo4BDhzEl1T1nsh6A9dsmJ8MGki/4MtYyxStTnPBQCLNfA==
+"@vue/shared@3.0.0-alpha.10":
+ version "3.0.0-alpha.10"
+ resolved "https://registry.yarnpkg.com/@vue/shared/-/shared-3.0.0-alpha.10.tgz#7026d9a81fa5f03ea03e9434be6286ed167684b8"
+ integrity sha512-b6VYQrhsp/N0QpuXdxs1xIDrBiqVzFNyAvyQgPk2ssQgWD6H2StoySDj99DWrum2+pJUDO2/2dLfGH8l180R6g==
"@webassemblyjs/ast@1.9.0":
version "1.9.0"
merge-source-map "^1.1.0"
source-map "^0.6.1"
-vue@next:
- version "3.0.0-alpha.9"
- resolved "https://registry.yarnpkg.com/vue/-/vue-3.0.0-alpha.9.tgz#f84b6b52caf6753a8cefda370bd6bbd298b5b06a"
- integrity sha512-zZrfbchyCQXF/+9B5fD4djlqzZ2XB39MxDzTaJKfuMjs/CgD2CTDiEVrOcP9HwMjr48cpARiFH13vvl4/F73RA==
+vue@^3.0.0-alpha.10:
+ version "3.0.0-alpha.10"
+ resolved "https://registry.yarnpkg.com/vue/-/vue-3.0.0-alpha.10.tgz#0f1cb5471edc41e0b0153ff07f462e376e03b0ae"
+ integrity sha512-USdgVs1bQfuiM5ivt2S2XGKOmDC+gKhhc3RNKjASUnh9kWv/vhNJlQiqIaUFiPN9SE9833fWy3PKOJFj9yZjPQ==
dependencies:
- "@vue/compiler-dom" "3.0.0-alpha.9"
- "@vue/runtime-dom" "3.0.0-alpha.9"
- "@vue/shared" "3.0.0-alpha.9"
+ "@vue/compiler-dom" "3.0.0-alpha.10"
+ "@vue/runtime-dom" "3.0.0-alpha.10"
+ "@vue/shared" "3.0.0-alpha.10"
w3c-hr-time@^1.0.1:
version "1.0.2"