nuxt-typed-router 3.8.0 → 4.0.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/dist/module.d.mts CHANGED
@@ -40,6 +40,11 @@ interface ModuleOptions {
40
40
  * @default false
41
41
  */
42
42
  disablePrettier?: boolean;
43
+ /**
44
+ * Ignores i18n modifiers when generating typed routes
45
+ * @default false
46
+ */
47
+ ignoreI18nModifier?: boolean;
43
48
  }
44
49
  interface StrictOptions {
45
50
  NuxtLink?: StrictParamsOptions;
@@ -86,4 +91,5 @@ interface StrictParamsOptions {
86
91
 
87
92
  declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
88
93
 
89
- export { type ModuleOptions, _default as default };
94
+ export { _default as default };
95
+ export type { ModuleOptions };
package/dist/module.json CHANGED
@@ -5,9 +5,9 @@
5
5
  "nuxt": ">=3.0.0",
6
6
  "bridge": false
7
7
  },
8
- "version": "3.8.0",
8
+ "version": "4.0.2",
9
9
  "builder": {
10
- "@nuxt/module-builder": "0.8.4",
10
+ "@nuxt/module-builder": "1.0.1",
11
11
  "unbuild": "unknown"
12
12
  }
13
13
  }
package/dist/module.mjs CHANGED
@@ -26,22 +26,16 @@ class ModuleOptionsStore {
26
26
  i18nOptions = null;
27
27
  i18nLocales = [];
28
28
  ignoreRoutes = [];
29
+ ignoreI18nModifiers = false;
29
30
  updateOptions(options) {
30
- if (options.plugin != null)
31
- this.plugin = options.plugin;
32
- if (options.strict != null)
33
- this.strict = options.strict;
34
- if (options.autoImport != null)
35
- this.autoImport = options.autoImport;
36
- if (options.rootDir != null)
37
- this.rootDir = options.rootDir;
38
- if (options.srcDir != null)
39
- this.srcDir = options.srcDir;
40
- if (options.buildDir != null)
41
- this.buildDir = options.buildDir;
31
+ if (options.plugin != null) this.plugin = options.plugin;
32
+ if (options.strict != null) this.strict = options.strict;
33
+ if (options.autoImport != null) this.autoImport = options.autoImport;
34
+ if (options.rootDir != null) this.rootDir = options.rootDir;
35
+ if (options.srcDir != null) this.srcDir = options.srcDir;
36
+ if (options.buildDir != null) this.buildDir = options.buildDir;
42
37
  this.pagesDir = path.join(this.srcDir, "pages");
43
- if (options.i18n != null)
44
- this.i18n = options.i18n;
38
+ if (options.i18n != null) this.i18n = options.i18n;
45
39
  if (options.i18nOptions != null) {
46
40
  this.i18nOptions = defu(options.i18nOptions, {
47
41
  strategy: "prefix_except_default"
@@ -68,6 +62,9 @@ class ModuleOptionsStore {
68
62
  if (options.ignoreRoutes) {
69
63
  this.ignoreRoutes = options.ignoreRoutes;
70
64
  }
65
+ if (options.ignoreI18nModifier) {
66
+ this.ignoreI18nModifiers = options.ignoreI18nModifier;
67
+ }
71
68
  if (options.isDocumentDriven) {
72
69
  this.ignoreRoutes.push("[...slug].vue");
73
70
  }
@@ -256,13 +253,13 @@ function createValidatePathTypes(pathElements, routesList, withLocale = false) {
256
253
  )}Path<T extends string> = T extends string
257
254
  ? T extends '/'
258
255
  ? "index"
259
- ${pathConditions.length ? `: ${pathConditions.filter((f) => routesList.includes(f.routeName)).length ? pathConditions.filter((f) => routesList.includes(f.routeName)).map((t) => `${t.typeName}<T> extends true ? "${t.routeName}"`).join(": ") : "any"} : never` : ": never"}
256
+ ${pathConditions.length ? `: ${pathConditions.filter((f) => routesList.includes(f.routeName)).length ? pathConditions.filter((f) => routesList.includes(f.routeName)).map((t) => `${t.typeName}<T> extends true ? "${t.routeName}"`).join(": ") + ": never" : "any"}` : ": never"}
260
257
  : never;
261
258
 
262
259
  `;
263
260
  }
264
261
  function createTypeValidatePathCondition(elements, withLocale) {
265
- const seedName = pascalCase(elements[0][0].fullPath);
262
+ const seedName = pascalCase(elements?.[0]?.[0]?.fullPath);
266
263
  const typeName = `Validate${returnIfTrue(withLocale, "Locale")}${seedName}`;
267
264
  const params = /* @__PURE__ */ new Map();
268
265
  const routeName = elements.flat()[0]?.routeName ?? "index";
@@ -1015,7 +1012,7 @@ function extractParamsFromPathDecl(path) {
1015
1012
  matches = routeParamExtractRegxp.exec(path);
1016
1013
  if (matches) {
1017
1014
  const [_, mtch, key, catchAll, optional] = matches;
1018
- if (mtch) {
1015
+ if (mtch && key) {
1019
1016
  const _param = {
1020
1017
  name: key,
1021
1018
  optional: !!optional,
@@ -1123,10 +1120,10 @@ function createPathsFiles({ routesPaths, routesList }) {
1123
1120
  let hasParam;
1124
1121
  let indexOfParam;
1125
1122
  do {
1126
- alphabetOrder = pathCountA[index]?.localeCompare(pathCountB[index]);
1123
+ alphabetOrder = pathCountA[index]?.localeCompare(pathCountB[index] ?? "") ?? 0;
1127
1124
  hasElement = (pathCountA[index] != null ? 1 : 0) - (pathCountB[index] != null ? 1 : 0);
1128
1125
  hasParam = (pathCountA[index]?.includes(":") ? 1 : 0) - (pathCountB[index]?.includes(":") ? 1 : 0);
1129
- indexOfParam = pathCountB[index]?.indexOf(":") - pathCountA[index]?.indexOf(":");
1126
+ indexOfParam = (pathCountB[index]?.indexOf(":") ?? 0) - (pathCountA[index]?.indexOf(":") ?? 0);
1130
1127
  if (alphabetOrder !== 0 && index === 0) {
1131
1128
  order = alphabetOrder;
1132
1129
  break;
@@ -1555,8 +1552,8 @@ function is18Sibling(source, route) {
1555
1552
  return false;
1556
1553
  }
1557
1554
  function modifyRoutePrefixDefaultIfI18n(route) {
1558
- const { i18n, i18nOptions, i18nLocales } = moduleOptionStore;
1559
- if (i18n && i18nOptions && route.name) {
1555
+ const { i18n, i18nOptions, i18nLocales, ignoreI18nModifiers } = moduleOptionStore;
1556
+ if (i18n && i18nOptions && route.name && !ignoreI18nModifiers) {
1560
1557
  const separator = i18nOptions?.routesNameSeparator ?? "___";
1561
1558
  const i18LocalesRecognizer = i18nLocales?.map((m) => m.replace(specialCharacterRegxp, "\\$&")).join("|");
1562
1559
  if (i18nOptions?.strategy === "prefix_and_default") {
package/dist/types.d.mts CHANGED
@@ -1 +1,3 @@
1
- export { type ModuleOptions, default } from './module.js'
1
+ export { default } from './module.mjs'
2
+
3
+ export { type ModuleOptions } from './module.mjs'
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "nuxt-typed-router",
3
- "version": "3.8.0",
3
+ "version": "4.0.2",
4
4
  "description": "Provide autocompletion for routes paths, names and params in Nuxt apps",
5
5
  "type": "module",
6
- "main": "./dist/module.cjs",
7
- "types": "./dist/types.d.ts",
6
+ "main": "./dist/module.mjs",
7
+ "types": "./dist/types.d.mts",
8
8
  "exports": {
9
9
  ".": {
10
- "import": "./dist/module.mjs",
11
- "require": "./dist/module.cjs"
10
+ "types": "./dist/types.d.mts",
11
+ "import": "./dist/module.mjs"
12
12
  }
13
13
  },
14
14
  "files": [
@@ -63,53 +63,53 @@
63
63
  "prettier": "^2.5.x || 3.x"
64
64
  },
65
65
  "dependencies": {
66
- "@nuxt/kit": "^3.16.1",
66
+ "@nuxt/kit": "3.17.5",
67
67
  "chalk": "5.4.1",
68
68
  "defu": "6.1.4",
69
69
  "lodash-es": "4.17.21",
70
- "log-symbols": "7.0.0",
70
+ "log-symbols": "7.0.1",
71
71
  "mkdirp": "3.0.1",
72
72
  "nanoid": "5.1.5",
73
73
  "pathe": "2.0.3",
74
74
  "prettier": "3.5.3"
75
75
  },
76
76
  "devDependencies": {
77
- "@intlify/core-base": "~10.0.4",
78
- "@intlify/message-compiler": "~10.0.4",
79
- "@intlify/shared": "~10.0.4",
77
+ "@intlify/core-base": "11.1.5",
78
+ "@intlify/message-compiler": "11.1.5",
79
+ "@intlify/shared": "11.1.5",
80
80
  "@intlify/vue-i18n-bridge": "1.1.0",
81
81
  "@intlify/vue-router-bridge": "1.1.0",
82
82
  "@nuxt/content": "2.13.4",
83
- "@nuxt/devtools": "1.7.0",
84
- "@nuxt/module-builder": "0.8.4",
85
- "@nuxt/schema": "3.16.1",
86
- "@nuxt/test-utils": "3.17.2",
83
+ "@nuxt/devtools": "2.5.0",
84
+ "@nuxt/module-builder": "1.0.1",
85
+ "@nuxt/schema": "3.17.5",
86
+ "@nuxt/test-utils": "3.19.1",
87
87
  "@nuxt/types": "2.18.1",
88
88
  "@nuxtjs/eslint-config-typescript": "12.1.0",
89
- "@nuxtjs/i18n": "9.3.3",
89
+ "@nuxtjs/i18n": "9.5.5",
90
90
  "@nuxtjs/web-vitals": "0.2.7",
91
- "@playwright/test": "1.49.1",
91
+ "@playwright/test": "1.52.0",
92
92
  "@types/lodash-es": "4.17.12",
93
- "@types/node": "22.13.11",
94
- "@typescript-eslint/eslint-plugin": "8.27.0",
95
- "@typescript-eslint/parser": "8.27.0",
93
+ "@types/node": "22.15.29",
94
+ "@typescript-eslint/eslint-plugin": "8.33.1",
95
+ "@typescript-eslint/parser": "8.33.1",
96
96
  "@vue/test-utils": "2.4.6",
97
- "bumpp": "10.1.0",
98
- "changelogithub": "13.13.0",
97
+ "bumpp": "10.1.1",
98
+ "changelogithub": "13.15.0",
99
99
  "cross-env": "7.0.3",
100
- "eslint": "9.22.0",
101
- "eslint-config-prettier": "10.1.1",
102
- "eslint-plugin-vue": "10.0.0",
103
- "nuxt": "3.16.1",
100
+ "eslint": "9.28.0",
101
+ "eslint-config-prettier": "10.1.5",
102
+ "eslint-plugin-vue": "10.1.0",
103
+ "nuxt": "3.17.5",
104
104
  "nuxt-seo-kit": "1.3.13",
105
- "playwright": "1.49.1",
106
- "tsd": "0.31.2",
107
- "typescript": "5.8.2",
108
- "vitest": "2.1.8",
109
- "vue": "3.5.13",
110
- "vue-eslint-parser": "10.1.1",
111
- "vue-i18n": "~11.1.2",
112
- "vue-router": "4.5.0",
113
- "vue-tsc": "2.2.8"
105
+ "playwright": "1.52.0",
106
+ "tsd": "0.32.0",
107
+ "typescript": "5.8.3",
108
+ "vitest": "3.2.1",
109
+ "vue": "3.5.16",
110
+ "vue-eslint-parser": "10.1.3",
111
+ "vue-i18n": "11.1.5",
112
+ "vue-router": "4.5.1",
113
+ "vue-tsc": "2.2.10"
114
114
  }
115
115
  }
package/dist/module.cjs DELETED
@@ -1,5 +0,0 @@
1
- module.exports = function(...args) {
2
- return import('./module.mjs').then(m => m.default.call(this, ...args))
3
- }
4
- const _meta = module.exports.meta = require('./module.json')
5
- module.exports.getMeta = () => Promise.resolve(_meta)
package/dist/module.d.ts DELETED
@@ -1,89 +0,0 @@
1
- import * as _nuxt_schema from '@nuxt/schema';
2
-
3
- interface ModuleOptions {
4
- /**
5
- *
6
- * Enables path autocomplete and path validity for programmatic validation
7
- *
8
- * @default true
9
- */
10
- pathCheck?: boolean;
11
- /**
12
- * Set to false if you don't want a plugin generated
13
- * @default false
14
- */
15
- plugin?: boolean;
16
- /**
17
- * Customise Route location arguments strictness for `NuxtLink` or `router`
18
- * All strict options are disabled by default.
19
- * You can tweak options to add strict router navigation options.
20
- *
21
- * By passing `true` you can enable all of them
22
- *
23
- * @default false
24
- */
25
- strict?: boolean | StrictOptions;
26
- /**
27
- * Remove Nuxt definitions to avoid conflicts
28
- * @default true
29
- */
30
- removeNuxtDefs?: boolean;
31
- /**
32
- * ⚠️ Experimental
33
- *
34
- * Exclude certain routes from being included into the generated types
35
- * Ex: 404 routes or catchAll routes
36
- */
37
- ignoreRoutes?: string[];
38
- /**
39
- * Disable prettier formatter
40
- * @default false
41
- */
42
- disablePrettier?: boolean;
43
- }
44
- interface StrictOptions {
45
- NuxtLink?: StrictParamsOptions;
46
- router?: StrictParamsOptions;
47
- }
48
- interface StrictParamsOptions {
49
- /**
50
- * Prevent passing string path to the RouteLocation argument.
51
- *
52
- * Ex:
53
- * ```vue
54
- * <template>
55
- * <NuxtLink to='/login'/> // Error ❌
56
- * </template>
57
- * ```
58
- * Or
59
- * ```ts
60
- * router.push('/login'); // Error ❌
61
- * navigateTo('/login'); // Error ❌
62
- * ```
63
- *
64
- * @default false
65
- */
66
- strictToArgument?: boolean;
67
- /**
68
- * Prevent passing a `params` property in the RouteLocation argument.
69
- *
70
- * Ex:
71
- * ```vue
72
- * <template>
73
- * <NuxtLink :to='{path: "/login"}'/> // Error ❌
74
- * </template>
75
- * ```
76
- * Or
77
- * ```ts
78
- * router.push({path: "/login"}); // Error ❌
79
- * navigateTo({path: "/login"}); // Error ❌
80
- * ```
81
- *
82
- * @default false
83
- */
84
- strictRouteLocation?: boolean;
85
- }
86
-
87
- declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
88
-
89
- export { type ModuleOptions, _default as default };
package/dist/types.d.ts DELETED
@@ -1 +0,0 @@
1
- export { type ModuleOptions, default } from './module'