nuxt-typed-router 3.0.2 → 3.0.3
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.json +1 -1
- package/dist/module.mjs +18 -6
- package/package.json +1 -1
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -20,6 +20,7 @@ class ModuleOptionsStore {
|
|
|
20
20
|
this.rootDir = "";
|
|
21
21
|
this.i18n = false;
|
|
22
22
|
this.i18nOptions = null;
|
|
23
|
+
this.i18nLocales = [];
|
|
23
24
|
}
|
|
24
25
|
updateOptions(options) {
|
|
25
26
|
if (options.plugin != null)
|
|
@@ -32,10 +33,21 @@ class ModuleOptionsStore {
|
|
|
32
33
|
this.rootDir = options.rootDir;
|
|
33
34
|
if (options.i18n != null)
|
|
34
35
|
this.i18n = options.i18n;
|
|
35
|
-
if (options.i18nOptions != null)
|
|
36
|
+
if (options.i18nOptions != null) {
|
|
36
37
|
this.i18nOptions = options.i18nOptions;
|
|
37
|
-
|
|
38
|
+
if (options.i18nOptions.locales) {
|
|
39
|
+
this.i18nLocales = options.i18nOptions.locales.map((l) => {
|
|
40
|
+
if (typeof l === "string") {
|
|
41
|
+
return l;
|
|
42
|
+
} else {
|
|
43
|
+
return l.code;
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
if (options.experimentalPathCheck != null) {
|
|
38
49
|
this.experimentalPathCheck = options.experimentalPathCheck;
|
|
50
|
+
}
|
|
39
51
|
}
|
|
40
52
|
getResolvedStrictOptions() {
|
|
41
53
|
let resolved;
|
|
@@ -785,7 +797,7 @@ function createTypeUtilsRuntimeFile() {
|
|
|
785
797
|
|
|
786
798
|
function createi18nRouterFile() {
|
|
787
799
|
const { router } = moduleOptionStore.getResolvedStrictOptions();
|
|
788
|
-
const { i18nOptions, experimentalPathCheck } = moduleOptionStore;
|
|
800
|
+
const { i18nOptions, experimentalPathCheck, i18nLocales } = moduleOptionStore;
|
|
789
801
|
return (
|
|
790
802
|
/* typescript */
|
|
791
803
|
`
|
|
@@ -798,7 +810,7 @@ function createi18nRouterFile() {
|
|
|
798
810
|
`import type {TypedLocalePathParameter, RouteNameFromLocalePath} from './__paths';`
|
|
799
811
|
)}
|
|
800
812
|
|
|
801
|
-
export type I18nLocales = ${
|
|
813
|
+
export type I18nLocales = ${i18nLocales?.length ? i18nLocales.map((loc) => `"${loc}"`).join("|") : "string"};
|
|
802
814
|
|
|
803
815
|
export interface TypedToLocalePath {
|
|
804
816
|
<T extends RoutesNamesList, P extends string>(
|
|
@@ -1396,11 +1408,11 @@ function extractChunkMain(chunkName) {
|
|
|
1396
1408
|
}
|
|
1397
1409
|
|
|
1398
1410
|
function hasi18nSibling(source, route) {
|
|
1399
|
-
const { i18n, i18nOptions } = moduleOptionStore;
|
|
1411
|
+
const { i18n, i18nOptions, i18nLocales } = moduleOptionStore;
|
|
1400
1412
|
if (i18n && i18nOptions?.strategy !== "no_prefix") {
|
|
1401
1413
|
const separator = i18nOptions?.routesNameSeparator ?? "___";
|
|
1402
1414
|
return source.some((rt) => {
|
|
1403
|
-
return route.name?.match(new RegExp(`^(${rt.name})${separator}[a-zA-Z]+`, "g")) || rt.path !== "/" && route.path?.match(new RegExp(`/?[${
|
|
1415
|
+
return route.name?.match(new RegExp(`^(${rt.name})${separator}[a-zA-Z]+`, "g")) || rt.path !== "/" && route.path?.match(new RegExp(`/?[${i18nLocales?.join("|")}]${rt.path}`, "g"));
|
|
1404
1416
|
});
|
|
1405
1417
|
}
|
|
1406
1418
|
return false;
|