nuxt-typed-router 1.2.4 → 1.2.5
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 -2
- package/dist/module.json +1 -1
- package/dist/module.mjs +15 -14
- package/package.json +2 -2
package/dist/module.d.ts
CHANGED
|
@@ -9,8 +9,11 @@ interface ModuleOptions {
|
|
|
9
9
|
* @default "routerPagesNames"
|
|
10
10
|
* */
|
|
11
11
|
routesObjectName?: string;
|
|
12
|
-
/**
|
|
13
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Set to false if you don't want a plugin generated
|
|
14
|
+
* @default true
|
|
15
|
+
*/
|
|
16
|
+
plugin?: boolean;
|
|
14
17
|
}
|
|
15
18
|
|
|
16
19
|
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions>;
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -385,21 +385,23 @@ function createTypedRouteParamsExport(routesParams) {
|
|
|
385
385
|
}`;
|
|
386
386
|
}
|
|
387
387
|
|
|
388
|
-
function routeHook(outDir, routesObjectName, srcDir, nuxt) {
|
|
388
|
+
function routeHook({ outDir, plugin, routesObjectName }, srcDir, nuxt) {
|
|
389
389
|
try {
|
|
390
390
|
extendPages(async (routes) => {
|
|
391
391
|
if (routes.length) {
|
|
392
392
|
const { routesDeclTemplate, routesList, routesObjectTemplate, routesParams } = constructRouteMap(routes);
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
393
|
+
if (plugin) {
|
|
394
|
+
const pluginName = "__typed-router.ts";
|
|
395
|
+
nuxt.hook("build:done", async () => {
|
|
396
|
+
const pluginFolder = `${srcDir}/plugins`;
|
|
397
|
+
await saveRouteFiles(
|
|
398
|
+
pluginFolder,
|
|
399
|
+
srcDir,
|
|
400
|
+
pluginName,
|
|
401
|
+
createRuntimePluginFile(routesDeclTemplate)
|
|
402
|
+
);
|
|
403
|
+
});
|
|
404
|
+
}
|
|
403
405
|
await Promise.all([
|
|
404
406
|
saveRouteFiles(
|
|
405
407
|
outDir,
|
|
@@ -450,9 +452,8 @@ const module = defineNuxtModule({
|
|
|
450
452
|
},
|
|
451
453
|
setup(moduleOptions, nuxt) {
|
|
452
454
|
const srcDir = nuxt.options.srcDir;
|
|
453
|
-
const {
|
|
454
|
-
nuxt.hook("pages:extend", () => routeHook(
|
|
455
|
-
routeHook(outDir, routesObjectName, srcDir, nuxt);
|
|
455
|
+
const { plugin = true, ...otherOptions } = moduleOptions;
|
|
456
|
+
nuxt.hook("pages:extend", () => routeHook({ ...otherOptions, plugin }, srcDir, nuxt));
|
|
456
457
|
}
|
|
457
458
|
});
|
|
458
459
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-typed-router",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.5",
|
|
4
4
|
"description": "Provide autocompletion for pages route names generated by Nuxt router",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/module.cjs",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"dev:build": "nuxi build playground",
|
|
22
22
|
"dev:prepare": "nuxt-module-build --stub && nuxi prepare playground",
|
|
23
23
|
"build:test": "cross-env NUXT_BUILD_TYPE=stub yarn prepack && yarn dev:build",
|
|
24
|
-
"test": "yarn build:test && vitest run",
|
|
24
|
+
"test": "yarn dev:prepare && yarn build:test && vitest run",
|
|
25
25
|
"test:watch": "yarn build:test && vitest"
|
|
26
26
|
},
|
|
27
27
|
"publishConfig": {
|