vue-i18n-routing
Advanced tools
Comparing version 1.1.3 to 1.1.4-4d221a4
@@ -7,2 +7,3 @@ import type { Composer } from '@intlify/vue-i18n-bridge'; | ||
import type { Locale } from '@intlify/vue-i18n-bridge'; | ||
import type { Locale as Locale_2 } from 'vue-i18n'; | ||
import { Location as Location_2 } from '@intlify/vue-router-bridge'; | ||
@@ -152,2 +153,4 @@ import { RawLocation } from '@intlify/vue-router-bridge'; | ||
declare type DynamicParamsInterceptor = () => Ref<Record<Locale_2, unknown>>; | ||
export declare type ExtendComposerHook = (compser: Composer) => void; | ||
@@ -292,2 +295,3 @@ | ||
localeCodes?: string[]; | ||
dynamicParamsInterceptor?: DynamicParamsInterceptor; | ||
}; | ||
@@ -616,2 +620,4 @@ | ||
export declare type MetaDynamicParamsInterceptor = (route: Route | RouteLocationNormalizedLoaded, key: Required<I18nRoutingOptions>['dynamicRouteParamsKey']) => Record<Locale, unknown>; | ||
/** | ||
@@ -618,0 +624,0 @@ * Route path prefix judgment logic in {@link resolveRoute} function |
@@ -657,3 +657,4 @@ var VueI18nRouting = function(exports, VueRouter3, vueDemi, vueI18nBridge) { | ||
switchLocalePathIntercepter: proxy.switchLocalePathIntercepter || options.switchLocalePathIntercepter || switchLocalePathIntercepter, | ||
dynamicRouteParamsKey: proxy.dynamicRouteParamsKey || options.dynamicRouteParamsKey || dynamicRouteParamsKey | ||
dynamicRouteParamsKey: proxy.dynamicRouteParamsKey || options.dynamicRouteParamsKey || dynamicRouteParamsKey, | ||
dynamicParamsInterceptor: options.dynamicParamsInterceptor || void 0 | ||
}; | ||
@@ -687,3 +688,3 @@ } | ||
var _a, _b; | ||
if (isV4Router()) { | ||
if (!isV4Router()) { | ||
return router.resolve(route); | ||
@@ -698,3 +699,3 @@ } | ||
if (_route == null) { | ||
return router.resolve(route); | ||
return route; | ||
} | ||
@@ -830,2 +831,3 @@ const _resolvableRoute = assign({}, route, _route); | ||
function switchLocalePath(locale) { | ||
var _a, _b; | ||
const route = this.route; | ||
@@ -836,6 +838,11 @@ const name = getRouteBaseName.call(this, route); | ||
} | ||
const { switchLocalePathIntercepter, dynamicRouteParamsKey } = getI18nRoutingOptions(this.router, this); | ||
const { switchLocalePathIntercepter, dynamicRouteParamsKey, dynamicParamsInterceptor } = getI18nRoutingOptions( | ||
this.router, | ||
this | ||
); | ||
const routeValue = vueDemi.isVue3 ? route : vueDemi.isRef(route) ? route.value : route; | ||
const routeCopy = routeToObject(routeValue); | ||
const langSwitchParamsIntercepted = (_b = (_a = dynamicParamsInterceptor == null ? void 0 : dynamicParamsInterceptor()) == null ? void 0 : _a.value) == null ? void 0 : _b[locale]; | ||
const langSwitchParams = getLocalizableMetaFromDynamicParams(route, dynamicRouteParamsKey)[locale] || {}; | ||
const resolvedParams = langSwitchParamsIntercepted ?? langSwitchParams ?? {}; | ||
const _baseRoute = { | ||
@@ -845,3 +852,3 @@ name, | ||
...routeCopy.params, | ||
...langSwitchParams | ||
...resolvedParams | ||
} | ||
@@ -1203,3 +1210,3 @@ }; | ||
} | ||
const VERSION = "1.1.3"; | ||
const VERSION = "1.1.4"; | ||
exports.DEFAULT_BASE_URL = DEFAULT_BASE_URL; | ||
@@ -1206,0 +1213,0 @@ exports.DEFAULT_DETECTION_DIRECTION = DEFAULT_DETECTION_DIRECTION; |
@@ -660,3 +660,4 @@ "use strict"; | ||
switchLocalePathIntercepter: proxy.switchLocalePathIntercepter || options.switchLocalePathIntercepter || switchLocalePathIntercepter, | ||
dynamicRouteParamsKey: proxy.dynamicRouteParamsKey || options.dynamicRouteParamsKey || dynamicRouteParamsKey | ||
dynamicRouteParamsKey: proxy.dynamicRouteParamsKey || options.dynamicRouteParamsKey || dynamicRouteParamsKey, | ||
dynamicParamsInterceptor: options.dynamicParamsInterceptor || void 0 | ||
}; | ||
@@ -690,3 +691,3 @@ } | ||
var _a, _b; | ||
if (isV4Router()) { | ||
if (!isV4Router()) { | ||
return router.resolve(route); | ||
@@ -701,3 +702,3 @@ } | ||
if (_route == null) { | ||
return router.resolve(route); | ||
return route; | ||
} | ||
@@ -833,2 +834,3 @@ const _resolvableRoute = assign({}, route, _route); | ||
function switchLocalePath(locale) { | ||
var _a, _b; | ||
const route = this.route; | ||
@@ -839,6 +841,11 @@ const name = getRouteBaseName.call(this, route); | ||
} | ||
const { switchLocalePathIntercepter, dynamicRouteParamsKey } = getI18nRoutingOptions(this.router, this); | ||
const { switchLocalePathIntercepter, dynamicRouteParamsKey, dynamicParamsInterceptor } = getI18nRoutingOptions( | ||
this.router, | ||
this | ||
); | ||
const routeValue = vueDemi.isVue3 ? route : vueDemi.isRef(route) ? route.value : route; | ||
const routeCopy = routeToObject(routeValue); | ||
const langSwitchParamsIntercepted = (_b = (_a = dynamicParamsInterceptor == null ? void 0 : dynamicParamsInterceptor()) == null ? void 0 : _a.value) == null ? void 0 : _b[locale]; | ||
const langSwitchParams = getLocalizableMetaFromDynamicParams(route, dynamicRouteParamsKey)[locale] || {}; | ||
const resolvedParams = langSwitchParamsIntercepted ?? langSwitchParams ?? {}; | ||
const _baseRoute = { | ||
@@ -848,3 +855,3 @@ name, | ||
...routeCopy.params, | ||
...langSwitchParams | ||
...resolvedParams | ||
} | ||
@@ -1206,3 +1213,3 @@ }; | ||
} | ||
const VERSION = "1.1.3"; | ||
const VERSION = "1.1.4"; | ||
exports.DEFAULT_BASE_URL = DEFAULT_BASE_URL; | ||
@@ -1209,0 +1216,0 @@ exports.DEFAULT_DETECTION_DIRECTION = DEFAULT_DETECTION_DIRECTION; |
{ | ||
"name": "vue-i18n-routing", | ||
"description": "The i18n routing with using vue-i18n", | ||
"version": "1.1.3", | ||
"scripts": { | ||
"dev": "vite", | ||
"build": "vite build", | ||
"typecheck": "tsc -p . --noEmit", | ||
"switch:2": "vue-demi-switch 2 vue2 && vue-router-switch 3 vue-router3 && vue-i18n-switch 8 vue-i18n-legacy", | ||
"switch:3": "vue-demi-switch 3 && vue-router-switch 4 && vue-i18n-switch 9", | ||
"test": "vitest run", | ||
"test:watch": "vitest", | ||
"test:cover": "vitest --coverage", | ||
"build:docs": "api-docs-gen ./temp/vue-i18n-routing.api.json -c ./docsgen.config.js -o ./ -g noprefix" | ||
}, | ||
"version": "1.1.4-4d221a4", | ||
"dependencies": { | ||
@@ -120,3 +109,14 @@ "@intlify/shared": "^9.4.1", | ||
}, | ||
"sideEffects": false | ||
} | ||
"sideEffects": false, | ||
"scripts": { | ||
"dev": "vite", | ||
"build": "vite build", | ||
"typecheck": "tsc -p . --noEmit", | ||
"switch:2": "vue-demi-switch 2 vue2 && vue-router-switch 3 vue-router3 && vue-i18n-switch 8 vue-i18n-legacy", | ||
"switch:3": "vue-demi-switch 3 && vue-router-switch 4 && vue-i18n-switch 9", | ||
"test": "vitest run", | ||
"test:watch": "vitest", | ||
"test:cover": "vitest --coverage", | ||
"build:docs": "api-docs-gen ./temp/vue-i18n-routing.api.json -c ./docsgen.config.js -o ./ -g noprefix" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
172387
12
4760
1