nuxt-typed-router 2.3.0 → 2.3.2
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/README.md +1 -1
- package/dist/module.json +1 -1
- package/dist/module.mjs +26 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -94,7 +94,7 @@ export default defineNuxtConfig({
|
|
|
94
94
|
- [ ] Add `path` autocomplete with TS string templates
|
|
95
95
|
- [ ] Enforce strong params typing depending of origin route
|
|
96
96
|
- [ ] Add support for `validate` in `definePageMeta`
|
|
97
|
-
- [
|
|
97
|
+
- [x] Add `strict` option to prevent path navigation
|
|
98
98
|
|
|
99
99
|
|
|
100
100
|
## Development
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -238,7 +238,8 @@ function createTypedRouterFile() {
|
|
|
238
238
|
strictOptions.router.strictRouteLocation,
|
|
239
239
|
`| Omit<RouteLocationPathRaw, 'path'>`,
|
|
240
240
|
"| RouteLocationPathRaw"
|
|
241
|
-
)}
|
|
241
|
+
)}
|
|
242
|
+
;
|
|
242
243
|
|
|
243
244
|
|
|
244
245
|
/**
|
|
@@ -362,7 +363,7 @@ function createTypedRouterDefinitionFile() {
|
|
|
362
363
|
import type { NuxtLinkProps } from '#app';
|
|
363
364
|
import type { DefineComponent } from 'vue';
|
|
364
365
|
import type { RouteLocationRaw, RouteLocationPathRaw } from 'vue-router';
|
|
365
|
-
import type { RoutesNamedLocations, RoutesNamesListRecord } from './__routes';
|
|
366
|
+
import type { RoutesNamesList, RoutesNamedLocations, RoutesNamesListRecord } from './__routes';
|
|
366
367
|
import type {TypedRouter, TypedRoute} from './__router';
|
|
367
368
|
import { useRoute as _useRoute } from './__useTypedRoute';
|
|
368
369
|
import { useRouter as _useRouter } from './__useTypedRouter';
|
|
@@ -627,12 +628,15 @@ function createi18nRouterFile() {
|
|
|
627
628
|
`
|
|
628
629
|
|
|
629
630
|
import { useLocalePath as _useLocalePath, useLocaleRoute as _useLocaleRoute} from 'vue-i18n-routing';
|
|
630
|
-
import type {TypedRouteLocationRawFromName, TypedRouteFromName} from './__router';
|
|
631
|
+
import type {TypedRouteLocationRawFromName, TypedRouteFromName, TypedLocationAsRelativeRaw} from './__router';
|
|
631
632
|
import type {RoutesNamesList} from './__routes';
|
|
632
633
|
|
|
633
634
|
export type I18nLocales = ${i18nLocales.length ? i18nLocales.map((loc) => `"${loc}"`).join("|") : "string"};
|
|
634
635
|
|
|
635
|
-
export type TypedToLocalePath = <T extends RoutesNamesList>(
|
|
636
|
+
export type TypedToLocalePath = <T extends RoutesNamesList>(
|
|
637
|
+
to: TypedRouteLocationRawFromName<T>,
|
|
638
|
+
locale?: I18nLocales | undefined
|
|
639
|
+
) => Required<TypedLocationAsRelativeRaw<T>>;
|
|
636
640
|
|
|
637
641
|
export function useLocalePath(options?: Pick<NonNullable<Parameters<typeof _useLocalePath>[0]>, 'i18n'>): TypedToLocalePath {
|
|
638
642
|
return _useLocalePath(options) as any;
|
|
@@ -1035,11 +1039,27 @@ const module = defineNuxtModule({
|
|
|
1035
1039
|
setup(moduleOptions, nuxt) {
|
|
1036
1040
|
const { resolve } = createResolver(import.meta.url);
|
|
1037
1041
|
const rootDir = nuxt.options.rootDir;
|
|
1038
|
-
|
|
1042
|
+
let i18nLocales = [];
|
|
1043
|
+
const hasi18nModuleRegistered = nuxt.options.modules.some((mod) => {
|
|
1044
|
+
if (Array.isArray(mod)) {
|
|
1045
|
+
const [moduleName, options] = mod;
|
|
1046
|
+
const isRegistered = moduleName === "@nuxtjs/i18n";
|
|
1047
|
+
if (isRegistered) {
|
|
1048
|
+
i18nLocales = options?.locales ?? [];
|
|
1049
|
+
}
|
|
1050
|
+
return isRegistered;
|
|
1051
|
+
} else {
|
|
1052
|
+
const isRegistered = mod === "@nuxtjs/i18n";
|
|
1053
|
+
if (isRegistered) {
|
|
1054
|
+
i18nLocales = nuxt.options.i18n?.locales ?? [];
|
|
1055
|
+
}
|
|
1056
|
+
return isRegistered;
|
|
1057
|
+
}
|
|
1058
|
+
});
|
|
1039
1059
|
moduleOptionStore.updateOptions({
|
|
1040
1060
|
...moduleOptions,
|
|
1041
1061
|
i18n: hasi18nModuleRegistered,
|
|
1042
|
-
i18nLocales
|
|
1062
|
+
i18nLocales
|
|
1043
1063
|
});
|
|
1044
1064
|
nuxt.options.alias = {
|
|
1045
1065
|
...nuxt.options.alias,
|