nuxt-typed-router 3.2.2 → 3.2.4

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 CHANGED
@@ -50,6 +50,11 @@
50
50
 
51
51
  Demo repo 🧪 : [nuxt-typed-router-demo](https://github.com/victorgarciaesgi/nuxt-typed-router-demo)
52
52
 
53
+ ## Cool video about it from LearnVue!
54
+
55
+ [![Watch the video](https://img.youtube.com/vi/jiYoAiFb71Y/default.jpg)](https://www.youtube.com/watch?v=jiYoAiFb71Y&t)
56
+
57
+
53
58
  <br/>
54
59
 
55
60
  # Compatibility:
package/dist/module.json CHANGED
@@ -5,5 +5,5 @@
5
5
  "nuxt": "^3.0.0",
6
6
  "bridge": false
7
7
  },
8
- "version": "3.2.2"
8
+ "version": "3.2.4"
9
9
  }
package/dist/module.mjs CHANGED
@@ -240,9 +240,9 @@ function createValidatePathTypes(pathElements, withLocale = false) {
240
240
  function createTypeValidatePathCondition(elements) {
241
241
  const typeName = `Validate${nanoid(7)}`;
242
242
  const params = /* @__PURE__ */ new Map();
243
- const routeName = elements.flat()[0].routeName;
243
+ const routeName = elements.flat()[0]?.routeName ?? "index";
244
244
  elements.flat().every((elem) => elem.type === "name");
245
- const isLocale = elements.flat()[0].isLocale;
245
+ const isLocale = elements.flat()[0]?.isLocale ?? false;
246
246
  const condition = `type ${typeName}<T> = T extends \`/${elements.map((elementArray, index) => {
247
247
  return elementArray.map((elem) => {
248
248
  const isLast = index === elements.flat().length - 1;
@@ -300,7 +300,6 @@ function createRoutesTypesFile({
300
300
  /* typescript */
301
301
  `
302
302
  ${createRoutesNamesListExport(routesList)}
303
- export type WithoutBracket<T extends string> = T extends \`:\${string}\` ? never : T;
304
303
 
305
304
  ${createRoutesParamsRecordExport(routesParams)}
306
305
 
@@ -641,8 +640,6 @@ function createIndexFile() {
641
640
  RoutesNamesList,
642
641
  RoutesNamesListRecord,
643
642
  RoutesParamsRecord,
644
- RoutePath,
645
- RoutePathByName
646
643
  } from './__routes';
647
644
  export { useRoute } from './__useTypedRoute';
648
645
  export { useRouter } from './__useTypedRouter';
@@ -660,7 +657,7 @@ function createIndexFile() {
660
657
  ${returnIfTrue(
661
658
  i18n,
662
659
  `export {useLocalePath, useLocaleRoute} from './__i18n-router';
663
- export type {TypedToLocalePath, TypedLocaleRoute} from './__i18n-router';`
660
+ export type {TypedToLocalePath, TypedLocaleRoute, I18nLocales} from './__i18n-router';`
664
661
  )}
665
662
 
666
663
 
@@ -888,7 +885,7 @@ function createi18nRouterFile() {
888
885
  );
889
886
  }
890
887
 
891
- const routeParamExtractRegxp = /(:(\w+)(\(.*[^(]\)[*+]?)?(\?)?)+/g;
888
+ const routeParamExtractRegxp = /(:(\w+)(\(\.[^(]\)[*+]?)?(\?)?)+/g;
892
889
  function extractParamsFromPathDecl(path) {
893
890
  let params = [];
894
891
  let matches;
@@ -1032,7 +1029,7 @@ function createPathsFiles({ routesPaths }) {
1032
1029
  });
1033
1030
  const pathElements = filteredRoutesPaths.filter((f) => f.path && f.path !== "/").map((route) => {
1034
1031
  return route.path.split("/").filter((f) => f.length).map((m) => destructurePath(m, route));
1035
- });
1032
+ }).filter((f) => f.length);
1036
1033
  const validatePathTypes = createValidatePathTypes(pathElements);
1037
1034
  const validateLocalePathTypes = createValidatePathTypes(pathElements, true);
1038
1035
  return (
@@ -1309,7 +1306,6 @@ const watermarkTemplate = `
1309
1306
  `;
1310
1307
 
1311
1308
  let previousGeneratedRoutes = "";
1312
- let firstRun = false;
1313
1309
  async function saveGeneratedFiles({ outputData }) {
1314
1310
  const { i18n } = moduleOptionStore;
1315
1311
  const filesMap = [
@@ -1377,15 +1373,6 @@ async function saveGeneratedFiles({ outputData }) {
1377
1373
  if (previousGeneratedRoutes !== outputData.routesList.join(",")) {
1378
1374
  previousGeneratedRoutes = outputData.routesList.join(",");
1379
1375
  console.log(logSymbols.success, `Router autocompletions generated \u{1F6A6}`);
1380
- if (!firstRun) {
1381
- firstRun = true;
1382
- console.log(
1383
- logSymbols.warning,
1384
- chalk.yellow(
1385
- `Route path autocomplete is still experimental. You can disable it with the "nuxtTypedRouter.pathCheck: false" option`
1386
- )
1387
- );
1388
- }
1389
1376
  }
1390
1377
  }
1391
1378
 
@@ -1400,7 +1387,7 @@ function is18Sibling(source, route) {
1400
1387
  const { i18n, i18nOptions, i18nLocales } = moduleOptionStore;
1401
1388
  if (i18n && i18nOptions && i18nOptions?.strategy !== "no_prefix") {
1402
1389
  const i18LocalesRecognizer = i18nLocales?.map((m) => m.replace(specialCharacterRegxp, "\\$&")).join("|");
1403
- return !!route.path?.match(new RegExp(`/?(${i18LocalesRecognizer})(/.+)?`, "g"));
1390
+ return !!route.path?.match(new RegExp(`^/?(${i18LocalesRecognizer})(/.*)?$`, "g"));
1404
1391
  }
1405
1392
  return false;
1406
1393
  }
@@ -1445,7 +1432,7 @@ function createKeyedName(route, parent) {
1445
1432
  if (parent) {
1446
1433
  return camelCase(parentPath || "index");
1447
1434
  } else {
1448
- return camelCase(route.path.split("/").join("-") || "index");
1435
+ return camelCase(route.path.split("/").join("-")) || "index";
1449
1436
  }
1450
1437
  }
1451
1438
  function createNameKeyFromFullName(route, level, parentName) {
@@ -1470,12 +1457,14 @@ function walkThoughRoutes({
1470
1457
  }) {
1471
1458
  const route = modifyRoutePrefixDefaultIfI18n(_route);
1472
1459
  const isLocaleRoute = isLocale || is18Sibling(output.routesPaths, route);
1473
- const newPath = `${parent?.path ?? ""}${route.path.startsWith("/") ? route.path : `/${route.path}`}`;
1474
- output.routesPaths.push({
1475
- name: route.name,
1476
- path: newPath,
1477
- isLocale: isLocaleRoute
1478
- });
1460
+ const newPath = `${parent?.path ?? ""}${route.path.startsWith("/") || parent?.path === "/" ? route.path : `/${route.path}`}`;
1461
+ if (parent?.path !== "/") {
1462
+ output.routesPaths.push({
1463
+ name: route.name,
1464
+ path: newPath,
1465
+ isLocale: isLocaleRoute
1466
+ });
1467
+ }
1479
1468
  if (route.children?.length) {
1480
1469
  let childrenChunks = route.children;
1481
1470
  let nameKey = createKeyedName(route, parent);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-typed-router",
3
- "version": "3.2.2",
3
+ "version": "3.2.4",
4
4
  "description": "Provide autocompletion for routes paths, names and params in Nuxt apps",
5
5
  "type": "module",
6
6
  "main": "./dist/module.cjs",
@@ -28,7 +28,8 @@
28
28
  "test": "pnpm run dev:prepare && pnpm run test:types && pnpm run test:fixtures",
29
29
  "lint": "eslint --ext .ts --ext .vue .",
30
30
  "docs:dev": "cd docs && pnpm run dev",
31
- "docs:build": "npm run dev:prepare && cd docs && nuxi generate",
31
+ "docs:prepare": "nuxt-module-build --stub && nuxi prepare playground",
32
+ "docs:build": "npm run docs:prepare && cd docs && nuxi generate",
32
33
  "typecheck": "tsc --noEmit",
33
34
  "release": "bumpp && npm publish && git push --follow-tags"
34
35
  },
@@ -59,8 +60,8 @@
59
60
  "url": "https://github.com/victorgarciaesgi/nuxt-typed-router/issues"
60
61
  },
61
62
  "dependencies": {
62
- "@nuxt/kit": "^3.4.3",
63
- "chalk": "^5.2.0",
63
+ "@nuxt/kit": "^3.6.1",
64
+ "chalk": "^5.3.0",
64
65
  "defu": "^6.1.2",
65
66
  "lodash-es": "^4.17.21",
66
67
  "log-symbols": "^5.1.0",
@@ -70,33 +71,33 @@
70
71
  "prettier": "2.8.8"
71
72
  },
72
73
  "devDependencies": {
73
- "@nuxt/devtools": "^0.4.6",
74
+ "@nuxt/devtools": "^0.5.5",
74
75
  "@nuxt/module-builder": "^0.3.1",
75
- "@nuxt/test-utils": "^3.4.3",
76
- "@nuxt/types": "^2.16.3",
76
+ "@nuxt/test-utils": "^3.6.1",
77
+ "@nuxt/types": "^2.17.0",
77
78
  "@nuxtjs/eslint-config-typescript": "^12.0.0",
78
79
  "@nuxtjs/i18n": "8.0.0-beta.10",
79
- "@nuxtjs/web-vitals": "^0.2.5",
80
+ "@nuxtjs/web-vitals": "^0.2.6",
80
81
  "@types/lodash-es": "^4.17.7",
81
- "@types/node": "^20.1.2",
82
- "@types/prettier": "^2.7.2",
83
- "@typescript-eslint/eslint-plugin": "^5.59.5",
84
- "@typescript-eslint/parser": "^5.59.5",
85
- "@vue/test-utils": "^2.3.2",
82
+ "@types/node": "^20.3.3",
83
+ "@types/prettier": "^2.7.3",
84
+ "@typescript-eslint/eslint-plugin": "^5.61.0",
85
+ "@typescript-eslint/parser": "^5.61.0",
86
+ "@vue/test-utils": "^2.4.0",
86
87
  "bumpp": "9.1.0",
87
- "changelogithub": "0.12.9",
88
+ "changelogithub": "0.12.11",
88
89
  "cross-env": "^7.0.3",
89
- "eslint": "8.40.0",
90
+ "eslint": "8.41.0",
90
91
  "eslint-config-prettier": "^8.8.0",
91
- "eslint-plugin-vue": "^9.12.0",
92
- "nuxt": "3.4.3",
92
+ "eslint-plugin-vue": "^9.15.1",
93
+ "nuxt": "3.5.1",
93
94
  "nuxt-seo-kit": "1.3.8",
94
- "playwright": "1.33.0",
95
+ "playwright": "1.34.3",
95
96
  "tsd": "^0.28.1",
96
- "typescript": "^5.0.4",
97
- "vitest": "^0.31.0",
98
- "vue-eslint-parser": "^9.2.1",
99
- "vue-router": "^4.1.6",
100
- "vue-tsc": "^1.6.4"
97
+ "typescript": "^5.1.6",
98
+ "vitest": "^0.31.4",
99
+ "vue-eslint-parser": "^9.3.1",
100
+ "vue-router": "^4.2.2",
101
+ "vue-tsc": "^1.8.4"
101
102
  }
102
103
  }