nuxt-typed-router 3.0.6 → 3.0.8
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.ts +5 -0
- package/dist/module.json +1 -1
- package/dist/module.mjs +53 -2
- package/package.json +20 -21
package/dist/module.d.ts
CHANGED
|
@@ -24,6 +24,11 @@ interface ModuleOptions {
|
|
|
24
24
|
* @default false
|
|
25
25
|
*/
|
|
26
26
|
strict?: boolean | StrictOptions;
|
|
27
|
+
/**
|
|
28
|
+
* Remove Nuxt definitions to avoid conflicts
|
|
29
|
+
* @default false
|
|
30
|
+
*/
|
|
31
|
+
experimentalRemoveNuxtDefs?: boolean;
|
|
27
32
|
}
|
|
28
33
|
interface StrictOptions {
|
|
29
34
|
NuxtLink?: StrictParamsOptions;
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { addPluginTemplate, extendPages,
|
|
1
|
+
import { addPluginTemplate, extendPages, createResolver, defineNuxtModule } from '@nuxt/kit';
|
|
2
2
|
import chalk from 'chalk';
|
|
3
3
|
import logSymbols from 'log-symbols';
|
|
4
4
|
import { defu } from 'defu';
|
|
@@ -10,6 +10,7 @@ import { fileURLToPath } from 'url';
|
|
|
10
10
|
import { dirname, resolve } from 'pathe';
|
|
11
11
|
import mkdirp from 'mkdirp';
|
|
12
12
|
import { camelCase } from 'lodash-es';
|
|
13
|
+
import { readFile } from 'fs/promises';
|
|
13
14
|
|
|
14
15
|
class ModuleOptionsStore {
|
|
15
16
|
constructor() {
|
|
@@ -18,6 +19,7 @@ class ModuleOptionsStore {
|
|
|
18
19
|
this.experimentalPathCheck = true;
|
|
19
20
|
this.autoImport = false;
|
|
20
21
|
this.rootDir = "";
|
|
22
|
+
this.buildDir = "";
|
|
21
23
|
this.i18n = false;
|
|
22
24
|
this.i18nOptions = null;
|
|
23
25
|
this.i18nLocales = [];
|
|
@@ -31,6 +33,8 @@ class ModuleOptionsStore {
|
|
|
31
33
|
this.autoImport = options.autoImport;
|
|
32
34
|
if (options.rootDir != null)
|
|
33
35
|
this.rootDir = options.rootDir;
|
|
36
|
+
if (options.buildDir != null)
|
|
37
|
+
this.buildDir = options.buildDir;
|
|
34
38
|
if (options.i18n != null)
|
|
35
39
|
this.i18n = options.i18n;
|
|
36
40
|
if (options.i18nOptions != null) {
|
|
@@ -1613,6 +1617,46 @@ async function createTypedRouter({
|
|
|
1613
1617
|
}
|
|
1614
1618
|
}
|
|
1615
1619
|
|
|
1620
|
+
async function removeNuxtDefinitions({
|
|
1621
|
+
buildDir,
|
|
1622
|
+
autoImport
|
|
1623
|
+
}) {
|
|
1624
|
+
const { resolve } = createResolver(import.meta.url);
|
|
1625
|
+
const componentDefinitions = await readFile(resolve(buildDir, "components.d.ts"), {
|
|
1626
|
+
encoding: "utf8"
|
|
1627
|
+
});
|
|
1628
|
+
const replacedNuxtLink = componentDefinitions.replace(
|
|
1629
|
+
/'NuxtLink': typeof import\(".*"\)\['default'\]/gm,
|
|
1630
|
+
""
|
|
1631
|
+
);
|
|
1632
|
+
processPathAndWriteFile({
|
|
1633
|
+
content: replacedNuxtLink,
|
|
1634
|
+
fileName: "components.d.ts",
|
|
1635
|
+
outDir: ".nuxt"
|
|
1636
|
+
});
|
|
1637
|
+
if (autoImport) {
|
|
1638
|
+
let globalDefinitions = await readFile(resolve(buildDir, "types/imports.d.ts"), {
|
|
1639
|
+
encoding: "utf8"
|
|
1640
|
+
});
|
|
1641
|
+
const importsToRemove = [
|
|
1642
|
+
"useRouter",
|
|
1643
|
+
"useRoute",
|
|
1644
|
+
"useLocalePath",
|
|
1645
|
+
"useLocaleRoute",
|
|
1646
|
+
"definePageMeta",
|
|
1647
|
+
"navigateTo"
|
|
1648
|
+
].map((m) => new RegExp(`const ${m}: typeof import\\('.*'\\)\\['${m}'\\]`, "gm"));
|
|
1649
|
+
importsToRemove.forEach((imp) => {
|
|
1650
|
+
globalDefinitions = globalDefinitions.replace(imp, "");
|
|
1651
|
+
});
|
|
1652
|
+
processPathAndWriteFile({
|
|
1653
|
+
content: globalDefinitions,
|
|
1654
|
+
fileName: "types/imports.d.ts",
|
|
1655
|
+
outDir: ".nuxt"
|
|
1656
|
+
});
|
|
1657
|
+
}
|
|
1658
|
+
}
|
|
1659
|
+
|
|
1616
1660
|
const module = defineNuxtModule({
|
|
1617
1661
|
meta: {
|
|
1618
1662
|
name: "nuxt-typed-router",
|
|
@@ -1622,7 +1666,8 @@ const module = defineNuxtModule({
|
|
|
1622
1666
|
defaults: {
|
|
1623
1667
|
plugin: false,
|
|
1624
1668
|
strict: false,
|
|
1625
|
-
experimentalPathCheck: true
|
|
1669
|
+
experimentalPathCheck: true,
|
|
1670
|
+
experimentalRemoveNuxtDefs: false
|
|
1626
1671
|
},
|
|
1627
1672
|
setup(moduleOptions, nuxt) {
|
|
1628
1673
|
const { resolve } = createResolver(import.meta.url);
|
|
@@ -1661,6 +1706,12 @@ const module = defineNuxtModule({
|
|
|
1661
1706
|
experimentalRfc436: true
|
|
1662
1707
|
};
|
|
1663
1708
|
}
|
|
1709
|
+
if (moduleOptions.experimentalRemoveNuxtDefs) {
|
|
1710
|
+
removeNuxtDefinitions({
|
|
1711
|
+
autoImport: nuxt.options.imports.autoImport ?? true,
|
|
1712
|
+
buildDir: nuxt.options.buildDir
|
|
1713
|
+
});
|
|
1714
|
+
}
|
|
1664
1715
|
});
|
|
1665
1716
|
if (nuxt.options.dev) {
|
|
1666
1717
|
nuxt.hook("devtools:customTabs", (tabs) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-typed-router",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.8",
|
|
4
4
|
"description": "Provide autocompletion for routes paths, names and params in Nuxt apps",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/module.cjs",
|
|
@@ -12,8 +12,7 @@
|
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
14
|
"files": [
|
|
15
|
-
"dist"
|
|
16
|
-
"main.d.ts"
|
|
15
|
+
"dist"
|
|
17
16
|
],
|
|
18
17
|
"scripts": {
|
|
19
18
|
"prepack": "nuxt-module-build",
|
|
@@ -60,7 +59,7 @@
|
|
|
60
59
|
"url": "https://github.com/victorgarciaesgi/nuxt-typed-router/issues"
|
|
61
60
|
},
|
|
62
61
|
"dependencies": {
|
|
63
|
-
"@nuxt/kit": "^3.
|
|
62
|
+
"@nuxt/kit": "^3.3.1",
|
|
64
63
|
"chalk": "^5.2.0",
|
|
65
64
|
"defu": "^6.1.2",
|
|
66
65
|
"lodash-es": "^4.17.21",
|
|
@@ -68,36 +67,36 @@
|
|
|
68
67
|
"mkdirp": "^2.1.5",
|
|
69
68
|
"nanoid": "^4.0.1",
|
|
70
69
|
"pathe": "1.1.0",
|
|
71
|
-
"prettier": "2.8.
|
|
70
|
+
"prettier": "2.8.6"
|
|
72
71
|
},
|
|
73
72
|
"devDependencies": {
|
|
74
73
|
"@nuxt/devtools": "^0.2.5",
|
|
75
74
|
"@nuxt/module-builder": "^0.2.1",
|
|
76
|
-
"@nuxt/test-utils": "^3.
|
|
77
|
-
"@nuxt/types": "^2.16.
|
|
75
|
+
"@nuxt/test-utils": "^3.3.1",
|
|
76
|
+
"@nuxt/types": "^2.16.3",
|
|
78
77
|
"@nuxtjs/eslint-config-typescript": "^12.0.0",
|
|
79
78
|
"@nuxtjs/i18n": "8.0.0-beta.9",
|
|
80
|
-
"@nuxtjs/web-vitals": "^0.2.
|
|
81
|
-
"@types/lodash-es": "^4.17.
|
|
82
|
-
"@types/node": "^18.
|
|
79
|
+
"@nuxtjs/web-vitals": "^0.2.4",
|
|
80
|
+
"@types/lodash-es": "^4.17.7",
|
|
81
|
+
"@types/node": "^18.15.5",
|
|
83
82
|
"@types/prettier": "^2.7.2",
|
|
84
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
85
|
-
"@typescript-eslint/parser": "^5.
|
|
86
|
-
"@vue/test-utils": "^2.3.
|
|
83
|
+
"@typescript-eslint/eslint-plugin": "^5.56.0",
|
|
84
|
+
"@typescript-eslint/parser": "^5.56.0",
|
|
85
|
+
"@vue/test-utils": "^2.3.2",
|
|
87
86
|
"bumpp": "9.0.0",
|
|
88
87
|
"changelogithub": "0.12.7",
|
|
89
88
|
"cross-env": "^7.0.3",
|
|
90
|
-
"eslint": "8.
|
|
91
|
-
"eslint-config-prettier": "^8.
|
|
89
|
+
"eslint": "8.36.0",
|
|
90
|
+
"eslint-config-prettier": "^8.8.0",
|
|
92
91
|
"eslint-plugin-vue": "^9.9.0",
|
|
93
|
-
"nuxt": "3.
|
|
92
|
+
"nuxt": "3.3.1",
|
|
93
|
+
"nuxt-seo-kit": "1.3.5",
|
|
94
94
|
"playwright": "1.31.2",
|
|
95
|
-
"tsd": "^0.
|
|
96
|
-
"typescript": "^
|
|
97
|
-
"vitest": "^0.29.
|
|
95
|
+
"tsd": "^0.28.0",
|
|
96
|
+
"typescript": "^5.0.2",
|
|
97
|
+
"vitest": "^0.29.7",
|
|
98
98
|
"vue-eslint-parser": "^9.1.0",
|
|
99
99
|
"vue-router": "^4.1.6",
|
|
100
|
-
"vue-tsc": "^1.1.7"
|
|
101
|
-
"nuxt-seo-kit": "1.3.4"
|
|
100
|
+
"vue-tsc": "^1.1.7"
|
|
102
101
|
}
|
|
103
102
|
}
|