nuxt-typed-router 2.3.0-beta.0 → 2.3.1
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 +2 -1
- package/dist/module.json +1 -1
- package/dist/module.mjs +19 -3
- package/package.json +3 -1
package/README.md
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
- `NuxtLink` route autocomplete and params type-check
|
|
22
22
|
- `useRouter`, `useRoute` and `navigateTo` route autocomplete and params type-check
|
|
23
23
|
- Supports optional params and catchAll routes
|
|
24
|
-
-
|
|
24
|
+
- Out of the box `i18n` support
|
|
25
25
|
- Supports routes extended by config and modules
|
|
26
26
|
|
|
27
27
|
> ⚠️ Since `v2.1.x`, `useTypedRouter` and `useTypedRoute` are no longer exported.
|
|
@@ -94,6 +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
|
+
- [x] Add `strict` option to prevent path navigation
|
|
97
98
|
|
|
98
99
|
|
|
99
100
|
## Development
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -630,7 +630,7 @@ function createi18nRouterFile() {
|
|
|
630
630
|
import type {TypedRouteLocationRawFromName, TypedRouteFromName} from './__router';
|
|
631
631
|
import type {RoutesNamesList} from './__routes';
|
|
632
632
|
|
|
633
|
-
export type I18nLocales = ${i18nLocales.map((loc) => `"${loc}"`).join("|")};
|
|
633
|
+
export type I18nLocales = ${i18nLocales.length ? i18nLocales.map((loc) => `"${loc}"`).join("|") : "string"};
|
|
634
634
|
|
|
635
635
|
export type TypedToLocalePath = <T extends RoutesNamesList>(to: TypedRouteLocationRawFromName<T>, locale?: I18nLocales | undefined) => TypedRouteLocationRawFromName<T>;
|
|
636
636
|
|
|
@@ -1035,11 +1035,27 @@ const module = defineNuxtModule({
|
|
|
1035
1035
|
setup(moduleOptions, nuxt) {
|
|
1036
1036
|
const { resolve } = createResolver(import.meta.url);
|
|
1037
1037
|
const rootDir = nuxt.options.rootDir;
|
|
1038
|
-
|
|
1038
|
+
let i18nLocales = [];
|
|
1039
|
+
const hasi18nModuleRegistered = nuxt.options.modules.some((mod) => {
|
|
1040
|
+
if (Array.isArray(mod)) {
|
|
1041
|
+
const [moduleName, options] = mod;
|
|
1042
|
+
const isRegistered = moduleName === "@nuxtjs/i18n";
|
|
1043
|
+
if (isRegistered) {
|
|
1044
|
+
i18nLocales = options?.locales ?? [];
|
|
1045
|
+
}
|
|
1046
|
+
return isRegistered;
|
|
1047
|
+
} else {
|
|
1048
|
+
const isRegistered = mod === "@nuxtjs/i18n";
|
|
1049
|
+
if (isRegistered) {
|
|
1050
|
+
i18nLocales = nuxt.options.i18n?.locales ?? [];
|
|
1051
|
+
}
|
|
1052
|
+
return isRegistered;
|
|
1053
|
+
}
|
|
1054
|
+
});
|
|
1039
1055
|
moduleOptionStore.updateOptions({
|
|
1040
1056
|
...moduleOptions,
|
|
1041
1057
|
i18n: hasi18nModuleRegistered,
|
|
1042
|
-
i18nLocales
|
|
1058
|
+
i18nLocales
|
|
1043
1059
|
});
|
|
1044
1060
|
nuxt.options.alias = {
|
|
1045
1061
|
...nuxt.options.alias,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-typed-router",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.1",
|
|
4
4
|
"description": "Provide autocompletion for pages route names generated by Nuxt router",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/module.cjs",
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"scripts": {
|
|
19
19
|
"prepack": "nuxt-module-build",
|
|
20
20
|
"dev": "nuxi dev playground",
|
|
21
|
+
"prepare": "nuxi prepare playground",
|
|
21
22
|
"dev:build": "nuxi build playground",
|
|
22
23
|
"dev:prepare": "nuxt-module-build --stub && nuxi prepare playground && pnpm run test:prepare-fixtures",
|
|
23
24
|
"build:test": "cross-env NUXT_BUILD_TYPE=stub pnpm run prepack && pnpm run dev:build",
|
|
@@ -71,6 +72,7 @@
|
|
|
71
72
|
"@nuxt/test-utils": "^3.1.1",
|
|
72
73
|
"@nuxt/types": "^2.15.8",
|
|
73
74
|
"@nuxtjs/eslint-config-typescript": "^12.0.0",
|
|
75
|
+
"@nuxtjs/web-vitals": "^0.2.2",
|
|
74
76
|
"@nuxtjs/i18n": "8.0.0-beta.9",
|
|
75
77
|
"@types/lodash-es": "^4.17.6",
|
|
76
78
|
"@types/mkdirp": "^1.0.2",
|