New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More →

vue-i18n-routing

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-i18n-routing - npm Package Compare versions

Comparing version

to
0.3.0-822841b

@@ -108,2 +108,6 @@ import type { Composer } from '@intlify/vue-i18n-bridge';

export declare const DefaultPrefixable: typeof prefixable;
export declare const DefaultSwitchLocalePathIntercepter: SwitchLocalePathIntercepter;
/**

@@ -224,3 +228,3 @@ * Direction

*/
export declare type I18nRoutingGlobalOptions<BaseUrl extends BaseUrlResolveHandler = BaseUrlResolveHandler> = Pick<I18nRoutingOptions<BaseUrl>, 'defaultLocale' | 'defaultDirection' | 'defaultLocaleRouteNameSuffix' | 'trailingSlash' | 'routesNameSeparator' | 'strategy'> & {
export declare type I18nRoutingGlobalOptions<BaseUrl extends BaseUrlResolveHandler = BaseUrlResolveHandler> = Pick<I18nRoutingOptions<BaseUrl>, 'defaultLocale' | 'defaultDirection' | 'defaultLocaleRouteNameSuffix' | 'trailingSlash' | 'routesNameSeparator' | 'strategy' | 'prefixable' | 'switchLocalePathIntercepter'> & {
localeCodes?: string[];

@@ -327,2 +331,14 @@ };

routeOptionsResolver?: RouteOptionsResolver;
/**
* Whether to prefix the route path with the locale or not
*
* @defaultValue {@link DefaultPrefixable}
*/
prefixable?: Prefixable;
/**
* An option that Intercepter for custom processing for paths resolved with {@link switchLocalePath}
*
* @defaultValue {@link DefaultSwitchLocalePathIntercepter}
*/
switchLocalePathIntercepter?: SwitchLocalePathIntercepter;
} & RouterOptions;

@@ -414,2 +430,27 @@

/**
* Route path prefix judgment logic in {@link resolveRoute} function
*/
export declare type Prefixable = (optons: PrefixableOptions) => boolean;
declare function prefixable(optons: PrefixableOptions): boolean;
/**
* Route path prefix judgment options used in {@link Prefixable}
*/
export declare interface PrefixableOptions {
/**
* Current locale
*/
currentLocale: Locale;
/**
* Default locale
*/
defaultLocale: Locale;
/**
* Curernt strategy
*/
strategy: Strategies;
}
export declare function proxyVueInstance(target: Function): Function;

@@ -491,2 +532,4 @@

routesNameSeparator?: string;
prefixable?: Prefixable;
switchLocalePathIntercepter?: SwitchLocalePathIntercepter;
}

@@ -540,2 +583,7 @@

/**
* The intercept handler which is called in {@link switchLocalePath} function
*/
export declare type SwitchLocalePathIntercepter = (path: string, locale: Locale) => string;
/**
* The target locale info

@@ -542,0 +590,0 @@ *

@@ -443,2 +443,4 @@ var VueI18nRouting = function(exports, vueDemi, VueRouter3, vueI18nBridge) {

routes,
prefixable: prefixable2,
switchLocalePathIntercepter,
routeOptionsResolver: optionsResolver

@@ -468,3 +470,5 @@ } = asDefaultVueI18nRouterOptions(options);

defaultLocaleRouteNameSuffix,
defaultDirection
defaultDirection,
prefixable: prefixable2,
switchLocalePathIntercepter
});

@@ -523,3 +527,3 @@ router.beforeEach((to, from, next) => {

function asDefaultVueI18nRouterOptions(options) {
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
options.version = (_a = options.version) != null ? _a : 4;

@@ -535,2 +539,4 @@ options.defaultLocale = (_b = options.defaultLocale) != null ? _b : DEFAULT_LOCALE;

options.routes = (_j = options.routes) != null ? _j : [];
options.prefixable = (_k = options.prefixable) != null ? _k : DefaultPrefixable;
options.switchLocalePathIntercepter = (_l = options.switchLocalePathIntercepter) != null ? _l : DefaultSwitchLocalePathIntercepter;
return options;

@@ -545,3 +551,5 @@ }

trailingSlash = DEFAULT_TRAILING_SLASH,
localeCodes = []
localeCodes = [],
prefixable: prefixable2 = DefaultPrefixable,
switchLocalePathIntercepter = DefaultSwitchLocalePathIntercepter
} = {}) {

@@ -556,6 +564,14 @@ const options = getGlobalOptions(router);

trailingSlash: proxy.trailingSlash || options.trailingSlash || trailingSlash,
localeCodes: proxy.localeCodes || options.localeCodes || localeCodes
localeCodes: proxy.localeCodes || options.localeCodes || localeCodes,
prefixable: proxy.prefixable || options.prefixable || prefixable2,
switchLocalePathIntercepter: proxy.switchLocalePathIntercepter || options.switchLocalePathIntercepter || switchLocalePathIntercepter
};
}
const RESOLVED_PREFIXED = /* @__PURE__ */ new Set(["prefix_and_default", "prefix_except_default"]);
function prefixable(optons) {
const { currentLocale, defaultLocale, strategy } = optons;
const isDefaultLocale = currentLocale === defaultLocale;
return !(isDefaultLocale && RESOLVED_PREFIXED.has(strategy)) && !(strategy === "no_prefix");
}
const DefaultPrefixable = prefixable;
function getRouteBaseName(givenRoute) {

@@ -587,3 +603,3 @@ const router = this.router;

const _locale = locale || getLocale(i18n);
const { routesNameSeparator, defaultLocale, defaultLocaleRouteNameSuffix, strategy, trailingSlash } = getI18nRoutingOptions(router, this);
const { routesNameSeparator, defaultLocale, defaultLocaleRouteNameSuffix, strategy, trailingSlash, prefixable: prefixable2 } = getI18nRoutingOptions(router, this);
let _route = route;

@@ -622,5 +638,3 @@ if (isString(route)) {

} else {
const isDefaultLocale = _locale === defaultLocale;
const isPrefixed = !(isDefaultLocale && RESOLVED_PREFIXED.has(strategy)) && !(strategy === "no_prefix");
if (isPrefixed) {
if (prefixable2({ currentLocale: _locale, defaultLocale, strategy })) {
localizedRoute.path = `/${_locale}${localizedRoute.path}`;

@@ -661,2 +675,3 @@ }

}
const DefaultSwitchLocalePathIntercepter = (path) => path;
function switchLocalePath(locale) {

@@ -681,3 +696,5 @@ const route = this.route;

const baseRoute = assign({}, routeCopy, _baseRoute);
const path = localePath.call(this, baseRoute, locale);
let path = localePath.call(this, baseRoute, locale);
const { switchLocalePathIntercepter } = getI18nRoutingOptions(this.router, this);
path = switchLocalePathIntercepter(path, locale);
return path;

@@ -1017,2 +1034,4 @@ }

exports.DEFAULT_TRAILING_SLASH = DEFAULT_TRAILING_SLASH;
exports.DefaultPrefixable = DefaultPrefixable;
exports.DefaultSwitchLocalePathIntercepter = DefaultSwitchLocalePathIntercepter;
exports.STRATEGIES = STRATEGIES;

@@ -1019,0 +1038,0 @@ exports.VERSION = VERSION;

@@ -446,2 +446,4 @@ "use strict";

routes,
prefixable: prefixable2,
switchLocalePathIntercepter,
routeOptionsResolver: optionsResolver

@@ -471,3 +473,5 @@ } = asDefaultVueI18nRouterOptions(options);

defaultLocaleRouteNameSuffix,
defaultDirection
defaultDirection,
prefixable: prefixable2,
switchLocalePathIntercepter
});

@@ -526,3 +530,3 @@ router.beforeEach((to, from, next) => {

function asDefaultVueI18nRouterOptions(options) {
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
options.version = (_a = options.version) != null ? _a : 4;

@@ -538,2 +542,4 @@ options.defaultLocale = (_b = options.defaultLocale) != null ? _b : DEFAULT_LOCALE;

options.routes = (_j = options.routes) != null ? _j : [];
options.prefixable = (_k = options.prefixable) != null ? _k : DefaultPrefixable;
options.switchLocalePathIntercepter = (_l = options.switchLocalePathIntercepter) != null ? _l : DefaultSwitchLocalePathIntercepter;
return options;

@@ -548,3 +554,5 @@ }

trailingSlash = DEFAULT_TRAILING_SLASH,
localeCodes = []
localeCodes = [],
prefixable: prefixable2 = DefaultPrefixable,
switchLocalePathIntercepter = DefaultSwitchLocalePathIntercepter
} = {}) {

@@ -559,6 +567,14 @@ const options = getGlobalOptions(router);

trailingSlash: proxy.trailingSlash || options.trailingSlash || trailingSlash,
localeCodes: proxy.localeCodes || options.localeCodes || localeCodes
localeCodes: proxy.localeCodes || options.localeCodes || localeCodes,
prefixable: proxy.prefixable || options.prefixable || prefixable2,
switchLocalePathIntercepter: proxy.switchLocalePathIntercepter || options.switchLocalePathIntercepter || switchLocalePathIntercepter
};
}
const RESOLVED_PREFIXED = /* @__PURE__ */ new Set(["prefix_and_default", "prefix_except_default"]);
function prefixable(optons) {
const { currentLocale, defaultLocale, strategy } = optons;
const isDefaultLocale = currentLocale === defaultLocale;
return !(isDefaultLocale && RESOLVED_PREFIXED.has(strategy)) && !(strategy === "no_prefix");
}
const DefaultPrefixable = prefixable;
function getRouteBaseName(givenRoute) {

@@ -590,3 +606,3 @@ const router = this.router;

const _locale = locale || getLocale(i18n);
const { routesNameSeparator, defaultLocale, defaultLocaleRouteNameSuffix, strategy, trailingSlash } = getI18nRoutingOptions(router, this);
const { routesNameSeparator, defaultLocale, defaultLocaleRouteNameSuffix, strategy, trailingSlash, prefixable: prefixable2 } = getI18nRoutingOptions(router, this);
let _route = route;

@@ -625,5 +641,3 @@ if (isString(route)) {

} else {
const isDefaultLocale = _locale === defaultLocale;
const isPrefixed = !(isDefaultLocale && RESOLVED_PREFIXED.has(strategy)) && !(strategy === "no_prefix");
if (isPrefixed) {
if (prefixable2({ currentLocale: _locale, defaultLocale, strategy })) {
localizedRoute.path = `/${_locale}${localizedRoute.path}`;

@@ -664,2 +678,3 @@ }

}
const DefaultSwitchLocalePathIntercepter = (path) => path;
function switchLocalePath(locale) {

@@ -684,3 +699,5 @@ const route = this.route;

const baseRoute = assign({}, routeCopy, _baseRoute);
const path = localePath.call(this, baseRoute, locale);
let path = localePath.call(this, baseRoute, locale);
const { switchLocalePathIntercepter } = getI18nRoutingOptions(this.router, this);
path = switchLocalePathIntercepter(path, locale);
return path;

@@ -1020,2 +1037,4 @@ }

exports.DEFAULT_TRAILING_SLASH = DEFAULT_TRAILING_SLASH;
exports.DefaultPrefixable = DefaultPrefixable;
exports.DefaultSwitchLocalePathIntercepter = DefaultSwitchLocalePathIntercepter;
exports.STRATEGIES = STRATEGIES;

@@ -1022,0 +1041,0 @@ exports.VERSION = VERSION;

{
"name": "vue-i18n-routing",
"description": "The i18n routing with using vue-i18n",
"version": "0.3.0-3fd9ab5",
"version": "0.3.0-822841b",
"dependencies": {

@@ -6,0 +6,0 @@ "@intlify/shared": "next",

Sorry, the diff of this file is not supported yet