vue-i18n-routing
Advanced tools
Comparing version 0.0.0-5735bda to 0.0.0-591e862
@@ -1,2 +0,4 @@ | ||
import { Composer } from '@intlify/vue-i18n-bridge'; | ||
import type { Composer } from '@intlify/vue-i18n-bridge'; | ||
import { EffectScope } from 'vue-demi'; | ||
import type { ExportedGlobalComposer } from '@intlify/vue-i18n-bridge'; | ||
import type { I18n } from '@intlify/vue-i18n-bridge'; | ||
@@ -6,7 +8,7 @@ import type { Locale } from '@intlify/vue-i18n-bridge'; | ||
import type { Ref } from 'vue-demi'; | ||
import type { Route as Route_2 } from '@intlify/vue-router-bridge'; | ||
import { Route } from '@intlify/vue-router-bridge'; | ||
import type { RouteConfig } from '@intlify/vue-router-bridge'; | ||
import type { RouteLocation } from '@intlify/vue-router-bridge'; | ||
import type { RouteLocationNormalized } from '@intlify/vue-router-bridge'; | ||
import type { RouteLocationNormalizedLoaded } from '@intlify/vue-router-bridge'; | ||
import { RouteLocationNormalized } from '@intlify/vue-router-bridge'; | ||
import { RouteLocationNormalizedLoaded } from '@intlify/vue-router-bridge'; | ||
import type { RouteLocationRaw } from '@intlify/vue-router-bridge'; | ||
@@ -17,6 +19,40 @@ import type { Router } from '@intlify/vue-router-bridge'; | ||
import { useRouter } from '@intlify/vue-router-bridge'; | ||
import type { VueI18n } from '@intlify/vue-i18n-bridge'; | ||
import type { VueRouter } from '@intlify/vue-router-bridge'; | ||
export declare type BaseUrlResolveHandler = (context: unknown) => string; | ||
export declare type BaseUrlResolveHandler<Context = unknown> = (context: Context) => string; | ||
/** | ||
* The browser locale info | ||
* | ||
* @remarks | ||
* This type is used by {@link FindBrowserLocaleOptions#sorter | sorter} in {@link findBrowserLocale} function | ||
*/ | ||
export declare type BrowserLocale = { | ||
/** | ||
* The locale code, such as BCP 47 (e.g `en-US`), or `ja` | ||
*/ | ||
code: string; | ||
/** | ||
* The score number | ||
* | ||
* @remarks | ||
* The score number that is used by `sorter` of {@link FindBrowserLocaleOptions} | ||
*/ | ||
score: number; | ||
}; | ||
/** | ||
* The browser locale matcher | ||
* | ||
* @remarks | ||
* This matcher is used by {@link findBrowserLocale} function | ||
* | ||
* @param locales - The target {@link LocaleObject | locale} list | ||
* @param browserLocales - The locale code list that is used in browser | ||
* | ||
* @returns The matched {@link BrowserLocale | locale info} | ||
*/ | ||
export declare type BrowserLocaleMatcher = (locales: TargetLocale[], browserLocales: string[]) => BrowserLocale[]; | ||
export declare type ComposableOptions = { | ||
@@ -39,3 +75,3 @@ route?: ReturnType<typeof useRoute>; | ||
export declare function createLocaleFromRouteGetter(localeCodes: string[], routesNameSeparator: string, defaultLocaleRouteNameSuffix: string): (route: Route_2 | RouteLocationNormalizedLoaded | RouteLocationNormalized | string) => string; | ||
export declare function createLocaleFromRouteGetter(localeCodes: string[], routesNameSeparator: string, defaultLocaleRouteNameSuffix: string): (route: Route | RouteLocationNormalizedLoaded | RouteLocationNormalized | string) => string; | ||
@@ -46,3 +82,3 @@ /** | ||
* @param i18n - A Vue I18n instance, see [Vue I18n API docs](https://vue-i18n.intlify.dev/api/general.html#i18n) | ||
* @param options - An options, see {@link VueI18nRoutingOptions} | ||
* @param options - An options, see {@link I18nRoutingOptions} | ||
* | ||
@@ -60,4 +96,18 @@ * @returns A Vue Router instance | ||
*/ | ||
export declare function createRouter<Options extends VueI18nRoutingOptions = VueI18nRoutingOptions>(i18n: I18n, options?: Options): Options['version'] extends 4 ? Router : VueRouter; | ||
export declare function createRouter<Options extends I18nRoutingOptions = I18nRoutingOptions>(i18n: I18n, options?: Options): Options['version'] extends 4 ? Router : VueRouter; | ||
export declare const DEFAULT_BASE_URL = ""; | ||
export declare const DEFAULT_DETECTION_DIRECTION = "ltr"; | ||
export declare const DEFAULT_LOCALE = ""; | ||
export declare const DEFAULT_LOCALE_ROUTE_NAME_SUFFIX = "default"; | ||
export declare const DEFAULT_ROUTES_NAME_SEPARATOR = "___"; | ||
export declare const DEFAULT_STRATEGY: "prefix_except_default"; | ||
export declare const DEFAULT_TRAILING_SLASH = false; | ||
/** | ||
@@ -68,22 +118,66 @@ * Direction | ||
export declare type ExtendComposerHook = (compser: Composer) => void; | ||
export declare type ExtendExportedGlobalHook = (global: Composer) => ExtendProperyDescripters; | ||
export declare interface ExtendHooks { | ||
onExtendComposer?: ExtendComposerHook; | ||
onExtendExportedGlobal?: ExtendExportedGlobalHook; | ||
onExtendVueI18n?: ExtendVueI18nHook; | ||
} | ||
export declare function extendI18n<TI18n extends I18n>(i18n: TI18n, { locales, localeCodes, baseUrl, hooks }?: VueI18nExtendOptions): EffectScope; | ||
export declare type ExtendProperyDescripters = { | ||
[key: string]: Pick<PropertyDescriptor, 'get'>; | ||
}; | ||
export declare type ExtendVueI18nHook = (composer: Composer) => ExtendProperyDescripters; | ||
/** | ||
* Get a locale | ||
* Find the browser locale | ||
* | ||
* @param i18n - An [I18n](https://vue-i18n.intlify.dev/api/general.html#i18n) instance or a [Composer](https://vue-i18n.intlify.dev/api/composition.html#composer) instance | ||
* @param locales - The target {@link LocaleObject | locale} list | ||
* @param browserLocales - The locale code list that is used in browser | ||
* @param options - The options for {@link findBrowserLocale} function | ||
* | ||
* @returns A locale | ||
* @returns The matched the locale code | ||
*/ | ||
export declare function getLocale(i18n: I18n | Composer): Locale; | ||
export declare function findBrowserLocale(locales: LocaleObject[], browserLocales: string[], { matcher, comparer }?: FindBrowserLocaleOptions): string | ''; | ||
/** | ||
* Get route base name | ||
* The options for {@link findBrowserLocale} function | ||
*/ | ||
export declare type FindBrowserLocaleOptions = { | ||
matcher?: BrowserLocaleMatcher; | ||
comparer?: (a: BrowserLocale, b: BrowserLocale) => number; | ||
}; | ||
/** | ||
* Get global i18n routing options | ||
* | ||
* @param givenRoute - A route object, if not provided, the route is returned with `useRoute` will be used | ||
* @param options - An options, see about details {@link I18nRoutingOptions} | ||
* @param router - A router instance, about router type | ||
* | ||
* @returns The route base name, if route name is not defined, return null | ||
* @returns - {@link I18nRoutingGlobalOptions | global options} from i18n routing options registory, if registered, return it, else empty object | ||
*/ | ||
export declare function getRouteBaseName(givenRoute?: Route_2 | RouteLocationNormalizedLoaded, { router, routesNameSeparator }?: I18nRoutingOptions): string | null; | ||
export declare function getGlobalOptions(router: Router | VueRouter): I18nRoutingGlobalOptions; | ||
/** | ||
* Get a locale | ||
* | ||
* @param i18n - An [I18n](https://vue-i18n.intlify.dev/api/general.html#i18n) instance or a [Composer](https://vue-i18n.intlify.dev/api/composition.html#composer) instance | ||
* | ||
* @returns A locale | ||
*/ | ||
export declare function getLocale(i18n: I18n | Composer | VueI18n): Locale; | ||
export declare function getLocalesRegex(localeCodes: string[]): RegExp; | ||
export declare function getRouteBaseName(this: RoutingProxy, givenRoute?: Route | RouteLocationNormalizedLoaded): string | undefined; | ||
export declare type I18nCommonRoutingOptions = Pick<I18nRoutingOptions, 'defaultLocale' | 'strategy' | 'defaultLocaleRouteNameSuffix' | 'trailingSlash' | 'locales' | 'routesNameSeparator'>; | ||
export declare type I18nCommonRoutingOptionsWithComposable = I18nCommonRoutingOptions & ComposableOptions; | ||
/** | ||
* I18n header meta info | ||
@@ -98,3 +192,3 @@ */ | ||
/** | ||
* Options for {@link useI18nHead} function | ||
* Options for {@link localeHead} function | ||
*/ | ||
@@ -117,17 +211,140 @@ export declare interface I18nHeadOptions { | ||
/** | ||
* Options for vue-i18n-routing common | ||
* Route config for vue-i18n-routing | ||
*/ | ||
export declare type I18nRoutingOptions = Pick<VueI18nRoutingOptions, 'defaultLocale' | 'strategy' | 'defaultLocaleRouteNameSuffix' | 'trailingSlash' | 'locales' | 'routesNameSeparator'> & ComposableOptions; | ||
export declare type I18nRoute = Route_2 & RouteLegacy & { | ||
redirect?: string; | ||
}; | ||
/** | ||
* Resolve locale location | ||
* Global options for i18n routing | ||
*/ | ||
export declare type I18nRoutingGlobalOptions<BaseUrl extends BaseUrlResolveHandler = BaseUrlResolveHandler> = Pick<I18nRoutingOptions<BaseUrl>, 'defaultLocale' | 'defaultDirection' | 'defaultLocaleRouteNameSuffix' | 'trailingSlash' | 'routesNameSeparator' | 'strategy'> & { | ||
localeCodes?: string[]; | ||
}; | ||
/** | ||
* Options to initialize a VueRouter instance | ||
* | ||
* @remarks | ||
* This options is extended from Vue Router `RouterOptioins`, so you can specify those options. | ||
*/ | ||
export declare type I18nRoutingOptions<BaseUrl extends BaseUrlResolveHandler = BaseUrlResolveHandler> = { | ||
/** | ||
* Vue Router version | ||
* | ||
* @remarks | ||
* You can choice between vue-router v3 and v4. | ||
* | ||
* If you specify `3`, this function return Vue Router v3 instance, else specify `4`, this function return Vue Router v4 instance. | ||
* | ||
* @defaultValue 4 | ||
*/ | ||
version?: 3 | 4; | ||
/** | ||
* The app's default locale | ||
* | ||
* @remarks | ||
* When using `prefix_except_default` strategy, URLs for locale specified here won't have a prefix. | ||
* | ||
* It's recommended to set this to some locale regardless of chosen strategy, as it will be used as a fallback locale when navigating to a non-existent route | ||
* | ||
* @defaultValue '' (emputy string) | ||
*/ | ||
defaultLocale?: string; | ||
/** | ||
* List of locales supported by your app | ||
* | ||
* @remarks | ||
* Can either be an array of string codes (e.g. `['en', 'fr']`) or an array of {@link LocaleObject} for more complex configurations | ||
* | ||
* @defaultValue [] | ||
*/ | ||
locales?: string[] | LocaleObject[]; | ||
/** | ||
* Routes strategy | ||
* | ||
* @remarks | ||
* Can be set to one of the following: | ||
* | ||
* - `no_prefix`: routes won't have a locale prefix | ||
* - `prefix_except_default`: locale prefix added for every locale except default | ||
* - `prefix`: locale prefix added for every locale | ||
* - `prefix_and_default`: locale prefix added for every locale and default | ||
* | ||
* @defaultValue 'prefix_except_default' | ||
*/ | ||
strategy?: Strategies; | ||
/** | ||
* Whether to use trailing slash | ||
* | ||
* @defaultValue false | ||
*/ | ||
trailingSlash?: boolean; | ||
/** | ||
* Internal separator used for generated route names for each locale. You shouldn't need to change this | ||
* | ||
* @defaultValue '___' | ||
*/ | ||
routesNameSeparator?: string; | ||
/** | ||
* Internal suffix added to generated route names for default locale | ||
* | ||
* @remarks | ||
* if strategy is prefix_and_default. You shouldn't need to change this. | ||
* | ||
* @defaultValue 'default' | ||
*/ | ||
defaultLocaleRouteNameSuffix?: string; | ||
/** | ||
* Default direction direction | ||
* | ||
* @defaultValue 'ltr' | ||
*/ | ||
defaultDirection?: Directions; | ||
/** | ||
* The fallback base URL to use as a prefix for alternate URLs in hreflang tags. | ||
* | ||
* @remarks | ||
* By default VueRouter's base URL will be used and only if that is not available, fallback URL will be used. | ||
* | ||
* Can also be a function (will be passed a Nuxt Context as a parameter) that returns a string. | ||
* | ||
* Useful to make base URL dynamic based on request headers. | ||
* | ||
* @defaultValue '' | ||
*/ | ||
baseUrl?: string | BaseUrl; | ||
/** | ||
* Route options resolver | ||
* | ||
* @defaultValue undefined | ||
*/ | ||
routeOptionsResolver?: RouteOptionsResolver; | ||
} & RouterOptions; | ||
export declare function isComposer(target: any): target is Composer; | ||
export declare function isExportedGlobalComposer(target: any): target is ExportedGlobalComposer; | ||
export declare function isI18nInstance(i18n: any): i18n is I18n; | ||
export declare function isLegacyVueI18n(target: any): target is Pick<VueI18n, 'locale'>; | ||
export declare function isVueI18n(target: any): target is VueI18n; | ||
export declare function localeHead(this: RoutingProxy, { addDirAttribute, addSeoAttributes }?: I18nHeadOptions): I18nHeadMetaInfo; | ||
export declare function localeLocation(this: RoutingProxy, route: RawLocation | RouteLocationRaw, locale?: Locale): Location | RouteLocation | undefined; | ||
/** | ||
* Resolve locale location function | ||
* | ||
* @param route - A route location. The path or name of the route or an object for more complex routes | ||
* @param locale - A locale code, if not specified, uses the current locale | ||
* @param options - An options, see about details {@link I18nRoutingOptions} | ||
* | ||
* @returns Returns the location object for a given route, the location object is resolved by vue-router rather than just a full route path. | ||
* | ||
* @see {@link useLocaleLocation} | ||
*/ | ||
export declare function localeLocation(route: RawLocation | RouteLocationRaw, locale?: Locale, // TODO: locale should be more type inference (completion) | ||
options?: I18nRoutingOptions): Location | RouteLocation | undefined; | ||
export declare type LocaleLocationFunction = (route: RawLocation | RouteLocationRaw, locale?: Locale) => Location | RouteLocation | undefined; | ||
@@ -147,25 +364,29 @@ /** | ||
export declare function localePath(this: RoutingProxy, route: RawLocation | RouteLocationRaw, locale?: Locale): string; | ||
/** | ||
* Resolve locale path | ||
* Resolve locale path function | ||
* | ||
* @param route - A route location. The path or name of the route or an object for more complex routes | ||
* @param locale - A locale code, if not specified, uses the current locale | ||
* @param options - An options, see about details {@link I18nRoutingOptions} | ||
* | ||
* @returns Returns the localized URL for a given route | ||
* | ||
* @see {@link useLocalePath} | ||
*/ | ||
export declare function localePath(route: RawLocation | RouteLocationRaw, locale?: Locale, // TODO: locale should be more type inference (completion) | ||
options?: I18nRoutingOptions): string; | ||
export declare type LocalePathFunction = (route: RawLocation | RouteLocation, locale?: Locale) => string; | ||
export declare function localeRoute(this: RoutingProxy, route: RawLocation | RouteLocationRaw, locale?: Locale): Route | ReturnType<Router['resolve']> | undefined; | ||
/** | ||
* Resolve locale route | ||
* Resolve route fucntion | ||
* | ||
* @param route - A route location. The path or name of the route or an object for more complex routes | ||
* @param locale - A locale code, if not specified, uses the current locale | ||
* @param options - An options, see about details {@link I18nRoutingOptions} | ||
* | ||
* @returns Returns the route object for a given route, the route object is resolved by vue-router rather than just a full route path. | ||
* | ||
* @see {@link useLocaleRoute} | ||
*/ | ||
export declare function localeRoute(route: RawLocation | RouteLocationRaw, locale?: Locale, // TODO: locale should be more type inference (completion) | ||
options?: I18nRoutingOptions): Route_2 | ReturnType<Router['resolve']> | undefined; | ||
export declare type LocaleRouteFunction = (route: RawLocation | RouteLocationRaw, locale?: Locale) => Route | ReturnType<Router['resolve']> | undefined; | ||
@@ -182,10 +403,20 @@ /** | ||
*/ | ||
export declare function localizeRoutes(routes: VueI18nRoute[], { defaultLocale, strategy, trailingSlash, routesNameSeparator, defaultLocaleRouteNameSuffix, includeUprefixedFallback, optionsResolver, locales }?: Pick<VueI18nRoutingOptions, 'defaultLocale' | 'strategy' | 'locales' | 'routesNameSeparator' | 'trailingSlash' | 'defaultLocaleRouteNameSuffix'> & { | ||
export declare function localizeRoutes(routes: I18nRoute[], { defaultLocale, strategy, trailingSlash, routesNameSeparator, defaultLocaleRouteNameSuffix, includeUprefixedFallback, optionsResolver, locales }?: Pick<I18nRoutingOptions, 'defaultLocale' | 'strategy' | 'locales' | 'routesNameSeparator' | 'trailingSlash' | 'defaultLocaleRouteNameSuffix'> & { | ||
includeUprefixedFallback?: boolean; | ||
optionsResolver?: RouteOptionsResolver; | ||
}): VueI18nRoute[]; | ||
}): I18nRoute[]; | ||
export declare type MetaAttrs = Record<string, any>; | ||
export declare function proxyVueInstance(target: Function): Function; | ||
/** | ||
* Register global i18n routing option registory | ||
* | ||
* @param router - A router instance, about router type | ||
* @param options - A global options, about options type, see {@link I18nRoutingGlobalOptions} | ||
*/ | ||
export declare function registerGlobalOptions<BaseUrl extends BaseUrlResolveHandler = BaseUrlResolveHandler>(router: Router | VueRouter, options: I18nRoutingGlobalOptions<BaseUrl>): void; | ||
/** | ||
* Resolve base url | ||
@@ -198,16 +429,20 @@ * | ||
*/ | ||
export declare function resolveBaseUrl(baseUrl: string | BaseUrlResolveHandler, context: unknown): string; | ||
export declare function resolveBaseUrl<Context = unknown>(baseUrl: string | BaseUrlResolveHandler<Context>, context: Context): string; | ||
export declare function resolveRoute(this: RoutingProxy, route: any, locale?: Locale): any; | ||
export { Route } | ||
declare type _Route = UnionToIntersection<RouteConfig>; | ||
/** | ||
* Route config for vue-router v4 | ||
*/ | ||
export declare interface Route { | ||
declare interface Route_2 { | ||
name?: string; | ||
path: string; | ||
file?: string; | ||
children?: Route[]; | ||
children?: Route_2[]; | ||
} | ||
declare type _Route = UnionToIntersection<RouteConfig>; | ||
/** | ||
@@ -223,8 +458,35 @@ * Route config for lagacy vue-router v3 | ||
export { RouteLocationNormalized } | ||
export { RouteLocationNormalizedLoaded } | ||
/** | ||
* Resolver for route localizing options | ||
*/ | ||
export declare type RouteOptionsResolver = (route: VueI18nRoute, allowedLocaleCodes: string[]) => ComputedRouteOptions | null; | ||
export declare type RouteOptionsResolver = (route: I18nRoute, localeCodes: string[]) => ComputedRouteOptions | null; | ||
/** | ||
* Routing Proxy | ||
*/ | ||
export declare type RoutingProxy = { | ||
i18n: any; | ||
getRouteBaseName: any; | ||
localePath: any; | ||
localeRoute: any; | ||
localeLocation: any; | ||
resolveRoute: any; | ||
switchLocalePath: any; | ||
localeHead: any; | ||
route: Route | RouteLocationNormalizedLoaded; | ||
router: Router | VueRouter; | ||
defaultLocale?: string; | ||
localeCodes?: string[]; | ||
strategy?: Strategies; | ||
defaultDirection?: Directions; | ||
defaultLocaleRouteNameSuffix?: string; | ||
trailingSlash?: boolean; | ||
routesNameSeparator?: string; | ||
}; | ||
/** | ||
* SEO Attribute options | ||
@@ -249,3 +511,3 @@ */ | ||
declare const STRATEGIES: { | ||
export declare const STRATEGIES: { | ||
readonly PREFIX: "prefix"; | ||
@@ -262,24 +524,81 @@ readonly PREFIX_EXCEPT_DEFAULT: "prefix_except_default"; | ||
export declare function switchLocalePath(this: RoutingProxy, locale: Locale): string; | ||
/** | ||
* Switch locale path | ||
* Swtich locale path function | ||
* | ||
* @param locale - A locale code, if not specified, uses the current locale | ||
* @param options - An options, see about details {@link I18nRoutingOptions} | ||
* | ||
* @returns Returns a link to the current route in another language | ||
* | ||
* @see {@link useSwitchLocalePath} | ||
*/ | ||
export declare function switchLocalePath(locale: Locale, options?: I18nRoutingOptions): string; | ||
export declare type SwitchLocalePathFunction = (locale?: Locale) => string; | ||
/** | ||
* The target locale info | ||
* | ||
* @remarks | ||
* This type is used by {@link BrowserLocaleMatcher} first argument | ||
*/ | ||
export declare type TargetLocale = Required<Pick<LocaleObject, 'code' | 'iso'>>; | ||
declare type UnionToIntersection<T> = (T extends any ? (k: T) => void : never) extends (k: infer U) => void ? U : never; | ||
/** | ||
* Generate SEO head meta information | ||
* Use localize head meta | ||
* | ||
* @param options - An options, see about details {@link I18nHeadOptions} | ||
* @param options - An options, see about details {@link I18nHeadOptions}, {@link ComposableOptions}, {@link I18nCommonRoutingOptions} | ||
* | ||
* @returns Genereated SEO head meta information | ||
*/ | ||
export declare function useI18nHead({ addDirAttribute, addSeoAttributes, strategy, defaultLocale, route, router, i18n }?: Pick<I18nRoutingOptions, 'strategy' | 'defaultLocale'> & ComposableOptions & I18nHeadOptions): Ref<I18nHeadMetaInfo>; | ||
export declare function useLocaleHead({ addDirAttribute, addSeoAttributes, strategy, defaultLocale, route, router, i18n }?: Pick<I18nCommonRoutingOptionsWithComposable, 'strategy' | 'defaultLocale' | 'route' | 'router' | 'i18n'> & I18nHeadOptions): Ref<I18nHeadMetaInfo>; | ||
/** | ||
* Use resolve locale location | ||
* | ||
* @param options - An options, see about details {@link I18nRoutingOptions} | ||
* | ||
* @returns Returns a {@link LocaleLocationFunction} | ||
*/ | ||
export declare function useLocaleLocation({ router, route, i18n, defaultLocale, defaultLocaleRouteNameSuffix, routesNameSeparator, strategy, trailingSlash }?: I18nCommonRoutingOptionsWithComposable): LocaleLocationFunction; | ||
/** | ||
* Use resolve locale path | ||
* | ||
* @param options - An options, see about details {@link I18nRoutingOptions} | ||
* | ||
* @returns Returns a {@link LocalePathFunction} | ||
*/ | ||
export declare function useLocalePath({ router, route, i18n, defaultLocale, defaultLocaleRouteNameSuffix, routesNameSeparator, strategy, trailingSlash }?: I18nCommonRoutingOptionsWithComposable): LocalePathFunction; | ||
/** | ||
* Use resolve locale route | ||
* | ||
* @param options - An options, see about details {@link I18nRoutingOptions} | ||
* | ||
* @returns Returns a {@link LocaleRouteFunction} | ||
*/ | ||
export declare function useLocaleRoute({ router, route, i18n, defaultLocale, defaultLocaleRouteNameSuffix, routesNameSeparator, strategy, trailingSlash }?: I18nCommonRoutingOptionsWithComposable): LocaleRouteFunction; | ||
/** | ||
* Use route base name | ||
* | ||
* @param givenRoute - A route object, if not provided, the route is returned with `useRoute` will be used | ||
* @param options - An options, see about details {@link I18nRoutingOptions} | ||
* | ||
* @returns The route base name, if route name is not defined, return null | ||
*/ | ||
export declare function useRouteBaseName(givenRoute?: Route | RouteLocationNormalizedLoaded, { router, routesNameSeparator }?: I18nCommonRoutingOptionsWithComposable): string | undefined; | ||
/** | ||
* Use swtich locale path | ||
* | ||
* @param options - An options, see about details {@link I18nRoutingOptions} | ||
* | ||
* @returns Returns a {@link SwitchLocalePathFunction} | ||
*/ | ||
export declare function useSwitchLocalePath({ router, route, i18n, defaultLocale, defaultLocaleRouteNameSuffix, routesNameSeparator, strategy, trailingSlash }?: I18nCommonRoutingOptionsWithComposable): SwitchLocalePathFunction; | ||
/** | ||
* Vue I18n Routing Version | ||
@@ -292,108 +611,19 @@ * | ||
/** | ||
* Route config for vue-i18n-routing | ||
*/ | ||
export declare type VueI18nRoute = Route & RouteLegacy & { | ||
redirect?: string; | ||
export declare type VueI18nExtendOptions = Pick<I18nRoutingOptions, 'baseUrl'> & { | ||
locales?: string[] | LocaleObject[]; | ||
localeCodes?: string[]; | ||
hooks?: ExtendHooks; | ||
}; | ||
/** | ||
* Options to initialize a VueRouter instance | ||
* | ||
* @remarks | ||
* This options is extended from Vue Router `RouterOptioins`, so you can specify those options. | ||
* An options of Vue I18n Routing Plugin | ||
*/ | ||
export declare type VueI18nRoutingOptions<BaseUrl extends BaseUrlResolveHandler = BaseUrlResolveHandler> = { | ||
export declare interface VueI18nRoutingPluginOptions { | ||
/** | ||
* Vue Router version | ||
* Whether to inject some option APIs style methods into Vue instance | ||
* | ||
* @remarks | ||
* You can choice between vue-router v3 and v4. | ||
* | ||
* If you specify `3`, this function return Vue Router v3 instance, else specify `4`, this function return Vue Router v4 instance. | ||
* | ||
* @defaultValue 4 | ||
* @defaultValue `true` | ||
*/ | ||
version?: 3 | 4; | ||
/** | ||
* The app's default locale | ||
* | ||
* @remarks | ||
* When using `prefix_except_default` strategy, URLs for locale specified here won't have a prefix. | ||
* | ||
* It's recommended to set this to some locale regardless of chosen strategy, as it will be used as a fallback locale when navigating to a non-existent route | ||
* | ||
* @defaultValue '' (emputy string) | ||
*/ | ||
defaultLocale?: string; | ||
/** | ||
* List of locales supported by your app | ||
* | ||
* @remarks | ||
* Can either be an array of string codes (e.g. `['en', 'fr']`) or an array of {@link LocaleObject} for more complex configurations | ||
* | ||
* @defaultValue [] | ||
*/ | ||
locales?: string[] | LocaleObject[]; | ||
/** | ||
* Routes strategy | ||
* | ||
* @remarks | ||
* Can be set to one of the following: | ||
* | ||
* - `no_prefix`: routes won't have a locale prefix | ||
* - `prefix_except_default`: locale prefix added for every locale except default | ||
* - `prefix`: locale prefix added for every locale | ||
* - `prefix_and_default`: locale prefix added for every locale and default | ||
* | ||
* @defaultValue 'prefix_except_default' | ||
*/ | ||
strategy?: Strategies; | ||
/** | ||
* Whether to use trailing slash | ||
* | ||
* @defaultValue false | ||
*/ | ||
trailingSlash?: boolean; | ||
/** | ||
* Internal separator used for generated route names for each locale. You shouldn't need to change this | ||
* | ||
* @defaultValue '___' | ||
*/ | ||
routesNameSeparator?: string; | ||
/** | ||
* Internal suffix added to generated route names for default locale | ||
* | ||
* @remarks | ||
* if strategy is prefix_and_default. You shouldn't need to change this. | ||
* | ||
* @defaultValue 'default' | ||
*/ | ||
defaultLocaleRouteNameSuffix?: string; | ||
/** | ||
* Default direction direction | ||
* | ||
* @defaultValue 'ltr' | ||
*/ | ||
defaultDirection?: Directions; | ||
/** | ||
* The fallback base URL to use as a prefix for alternate URLs in hreflang tags. | ||
* | ||
* @remarks | ||
* By default VueRouter's base URL will be used and only if that is not available, fallback URL will be used. | ||
* | ||
* Can also be a function (will be passed a Nuxt Context as a parameter) that returns a string. | ||
* | ||
* Useful to make base URL dynamic based on request headers. | ||
* | ||
* @defaultValue '' | ||
*/ | ||
baseUrl?: string | BaseUrl; | ||
/** | ||
* Route options resolver | ||
* | ||
* @defaultValue undefined | ||
*/ | ||
routeOptionsResolver?: RouteOptionsResolver; | ||
} & RouterOptions; | ||
inject?: boolean; | ||
} | ||
@@ -403,35 +633,28 @@ export { } | ||
export interface ComposerCustomProperties { | ||
/** | ||
* List of locales | ||
* | ||
* @remarks | ||
* Can either be an array of string codes (e.g. `['en', 'fr']`) or an array of {@link LocaleObject} for more complex configurations | ||
*/ | ||
locales: ComputedRef<string[] | LocaleObject[]> | ||
/** | ||
* List of locale codes | ||
*/ | ||
localeCodes: ComputedRef<string[]> | ||
__baseUrl: string | ||
} | ||
declare module 'vue-i18n' { | ||
export interface ComposerCustom { | ||
/** | ||
* List of locales | ||
* | ||
* @defaultValue `undefined` | ||
*/ | ||
locales?: ComputedRef<string[] | LocaleObject[]> | ||
/** | ||
* List of locale codes | ||
* | ||
* @defaultValue `undefined` | ||
*/ | ||
localeCodes?: ComputedRef<string[]> | ||
__baseUrl?: string | ||
} | ||
// eslint-disable-next-line @typescript-eslint/no-empty-interface | ||
export interface ComposerCustom extends ComposerCustomProperties {} | ||
} | ||
declare module 'vue-i18n-bridge' { | ||
export interface ComposerCustom { | ||
/** | ||
* List of locales | ||
* | ||
* @defaultValue `undefined` | ||
*/ | ||
locales?: ComputedRef<string[] | LocaleObject[]> | ||
/** | ||
* List of locale codes | ||
* | ||
* @defaultValue `undefined` | ||
*/ | ||
localeCodes?: ComputedRef<string[]> | ||
__baseUrl?: string | ||
} | ||
// eslint-disable-next-line @typescript-eslint/no-empty-interface | ||
export interface ComposerCustom extends ComposerCustomProperties {} | ||
} | ||
declare module '@intlify/vue-i18n-bridge' { | ||
// eslint-disable-next-line @typescript-eslint/no-empty-interface | ||
export interface ComposerCustom extends ComposerCustomProperties {} | ||
} |
@@ -1,5 +0,5 @@ | ||
var je=Object.defineProperty,Me=Object.defineProperties;var ze=Object.getOwnPropertyDescriptors;var x=Object.getOwnPropertySymbols;var ue=Object.prototype.hasOwnProperty,fe=Object.prototype.propertyIsEnumerable;var se=(s,c,g)=>c in s?je(s,c,{enumerable:!0,configurable:!0,writable:!0,value:g}):s[c]=g,y=(s,c)=>{for(var g in c||(c={}))ue.call(c,g)&&se(s,g,c[g]);if(x)for(var g of x(c))fe.call(c,g)&&se(s,g,c[g]);return s},X=(s,c)=>Me(s,ze(c));var ie=(s,c)=>{var g={};for(var p in s)ue.call(s,p)&&c.indexOf(p)<0&&(g[p]=s[p]);if(s!=null&&x)for(var p of x(s))c.indexOf(p)<0&&fe.call(s,p)&&(g[p]=s[p]);return g};var VueI18nRouting=function(s,c,g,p){"use strict";function de(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var he=de(g);/*! | ||
* shared v9.2.0-beta.30 | ||
const VueI18nRouting=function(f,h,g,N){"use strict";const Ae=(e=>e&&typeof e=="object"&&"default"in e?e:{default:e})(g),Q={PREFIX:"prefix",PREFIX_EXCEPT_DEFAULT:"prefix_except_default",PREFIX_AND_DEFAULT:"prefix_and_default",NO_PREFIX:"no_prefix"},j="",G=Q.PREFIX_EXCEPT_DEFAULT,B=!1,D="___",M="default",Y="ltr",J="";/*! | ||
* shared v9.2.0-beta.37 | ||
* (c) 2022 kazuya kawaguchi | ||
* Released under the MIT License. | ||
*/const B=Object.assign,_e=Array.isArray,ge=e=>typeof e=="function",P=e=>typeof e=="string",Le=e=>typeof e=="boolean",Re=e=>typeof e=="symbol",me=e=>e!==null&&typeof e=="object",Ee=/\/$|\/\?/;function V(e="",t=!1){return t?Ee.test(e):e.endsWith("/")}function Se(e="",t=!1){if(!t)return(V(e)?e.slice(0,-1):e)||"/";if(!V(e,!0))return e||"/";const[a,...n]=e.split("?");return(a.slice(0,-1)||"/")+(n.length?`?${n.join("?")}`:"")}function pe(e="",t=!1){if(!t)return e.endsWith("/")?e:e+"/";if(V(e,!0))return e||"/";const[a,...n]=e.split("?");return a+"/"+(n.length?`?${n.join("?")}`:"")}const Ae=typeof window!="undefined";function Ie(e,t){typeof console!="undefined"&&(console.warn("[vue-i18n-routing] "+e),t&&console.warn(t.stack))}function G(e){e=e||[];const t=[];for(const a of e)P(a)?t.push({code:a}):t.push(a);return t}function j(e,t){return c.isRef(e.locale)&&t==="composition"}function H(e){return"global"in e&&"mode"in e}function O(e){return H(e)?j(e.global,e.mode)?e.global.locale.value:e.global.locale:e.locale.value}function W(e,t){H(e)?j(e.global,e.mode)?e.global.locale.value=t:e.global.locale=t:c.isRef(e.locale)&&(e.locale.value=t)}function Te(e,t,a){return e.replace(/\/+$/,"")+(t?"/":"")||(a?"":"/")}function Q(e){return g.isVueRouter4,c.isRef(e)?e.value:e}function Y(e){return P(e)?e:Re(e)?e.toString():"(null)"}function J(e,t,{defaultLocale:a,strategy:n,routesNameSeparator:o,defaultLocaleRouteNameSuffix:l}){let r=Y(e)+(n==="no_prefix"?"":o+t);return t===a&&n==="prefix_and_default"&&(r+=o+l),r}function K(e,t){return ge(e)?e(t):e}const U={PREFIX:"prefix",PREFIX_EXCEPT_DEFAULT:"prefix_except_default",PREFIX_AND_DEFAULT:"prefix_and_default",NO_PREFIX:"no_prefix"},w="",b=U.PREFIX_EXCEPT_DEFAULT,Z=!1,v="___",M="default",Fe="ltr",ee="",Pe=new Set([U.PREFIX_AND_DEFAULT,U.PREFIX_EXCEPT_DEFAULT]);function C(e=g.useRoute(),{router:t=g.useRouter(),routesNameSeparator:a=v}={}){const n=a||t.__routesNameSeparator,o=c.unref(e);return o.name?Y(o.name).split(n)[0]:null}function te(e,t,a){const n=z(e,t,a);return n==null?"":c.isVue3?n.redirectedFrom||n.fullPath:n.route.redirectedFrom||n.route.fullPath}function ae(e,t,a){const n=z(e,t,a);return n==null?void 0:c.isVue3?n:n.route}function Ne(e,t,a){const n=z(e,t,a);return n==null?void 0:c.isVue3?n:n.location}function z(e,t,{router:a=g.useRouter(),i18n:n=p.useI18n(),defaultLocale:o=w,defaultLocaleRouteNameSuffix:l=M,routesNameSeparator:r=v,strategy:f=b,trailingSlash:i=!1}={}){const d=a.__defaultLocaleRouteNameSuffix||l,h=a.__defaultLocale||o,u=a.__routesNameSeparator||r,R=a.__strategy||f,m=t||O(n);let S=e;P(e)&&(S[0]==="/"?S={path:e}:S={name:e});let L=B({},S);if(L.path&&!L.name){const _=a.resolve(L),E=c.isVue3?_:_.route,F=C(E);P(F)?L={name:J(F,m,{defaultLocale:h,strategy:R,routesNameSeparator:u,defaultLocaleRouteNameSuffix:d}),params:E.params,query:E.query,hash:E.hash}:(!(m===o&&Pe.has(R))&&R!==U.NO_PREFIX&&(L.path=`/${m}${L.path}`),L.path=i?pe(L.path,!0):Se(L.path,!0))}else{L.name=J(L.name,m,{defaultLocale:h,strategy:R,routesNameSeparator:u,defaultLocaleRouteNameSuffix:d});const{params:_}=L;_&&_["0"]===void 0&&_.pathMatch&&(_["0"]=_.pathMatch)}const A=a.resolve(L);return(c.isVue3?A.name:A.route.name)?A:a.resolve(e)}function D(e,t){const a=t&&t.route||g.useRoute(),n=C(a,t);if(!n)return"";const d=!c.isVue3&&c.isRef(a)?a.value:a,{params:o}=d,l=ie(d,["params"]),r={},f=B({},l,{name:n,params:X(y(y({},o),r),{0:o.pathMatch})});return te(f,e,t)}function ye({addDirAttribute:e=!1,addSeoAttributes:t=!1,strategy:a=b,defaultLocale:n=w,route:o=g.useRoute(),router:l=g.useRouter(),i18n:r=p.useI18n()}={}){const f=l,i=n||f.__defaultLocale,d=a||f.__strategy,h=c.ref({htmlAttrs:{},link:[],meta:[]});function u(){h.value={htmlAttrs:{},link:[],meta:[]}}function R(m){if(r.locales==null||r.__baseUrl==null)return;const S=O(r),L=G(r.locales.value).find(E=>E.code===S)||{code:S},A=L.iso,_=L.dir||l.__defaultDirection;if(e&&(h.value.htmlAttrs.dir=_),t&&S&&r.locales){A&&(h.value.htmlAttrs.lang=A);const E=r.locales.value;$e(E,r.__baseUrl,h.value.link,{defaultLocale:i,strategy:d,route:o,router:l,i18n:r}),Ue(r.__baseUrl,h.value.link,t,{route:m,router:l,i18n:r}),Oe(L,A,h.value.meta),we(E,A,h.value.meta)}}if(Ae)if(c.isVue3){const m=c.watchEffect(()=>{u(),R(Q(f.currentRoute))});c.onUnmounted(()=>m())}else{const m=f.afterEach((S,L)=>{u(),R(S)});c.onUnmounted(()=>m()),R(o)}else R(Q(f.currentRoute));return h}function $e(e,t,a,n){if(n.strategy===U.NO_PREFIX)return;const o=new Map;for(const l of e){const r=l.iso;if(!r){Ie("Locale ISO code is required to generate alternate link");continue}const[f,i]=r.split("-");f&&i&&(l.isCatchallLocale||!o.has(f))&&o.set(f,l),o.set(r,l)}for(const[l,r]of o.entries()){const f=D(r.code,n);f&&a.push({hid:`i18n-alt-${l}`,rel:"alternate",href:k(f,t),hreflang:l})}if(n.defaultLocale){const l=D(n.defaultLocale,n);l&&a.push({hid:"i18n-xd",rel:"alternate",href:k(l,t),hreflang:"x-default"})}}function Ue(e,t,a,n){const{route:o}=n,l=ae(X(y({},o),{name:C(o,n)}),void 0,n);if(l){let r=k(l.path,e);const f=!Le(a)&&a.canonicalQueries||[];if(f.length){const i=l.query,d=new URLSearchParams;for(const u of f)if(u in i){const R=i[u];_e(R)?R.forEach(m=>d.append(u,m||"")):d.append(u,R||"")}const h=d.toString();h&&(r=`${r}?${h}`)}t.push({hid:"i18n-can",rel:"canonical",href:r})}}function Oe(e,t,a){!(e&&t)||a.push({hid:"i18n-og",property:"og:locale",content:ne(t)})}function we(e,t,a){const n=e.filter(o=>{const l=o.iso;return l&&l!==t});if(n.length){const o=n.map(l=>({hid:`i18n-og-alt-${l.iso}`,property:"og:locale:alternate",content:ne(l.iso)}));a.push(...o)}}function ne(e){return(e||"").replace(/-/g,"_")}function k(e,t){return e.match(/^https?:\/\//)?e:t+e}function le(e,{defaultLocale:t=w,strategy:a=b,trailingSlash:n=Z,routesNameSeparator:o=v,defaultLocaleRouteNameSuffix:l=M,includeUprefixedFallback:r=!1,optionsResolver:f=void 0,locales:i=[]}={}){if(a==="no_prefix")return e;const d=i.map(u=>P(u)?u:u.code);function h(u,R,m=!1,S=!1){if(u.redirect&&(!u.component||!u.file))return[u];let L=null;return f!=null&&(L=f(u,R),L==null)?[u]:R.reduce((_,E)=>{const{name:F}=u;let{path:I}=u;const T=y({},u);F&&(T.name=`${F}${o}${E}`),u.children&&(T.children=u.children.reduce((N,q)=>[...N,...h(q,[E],!0,S)],[]));const $=E===t;if($&&a==="prefix_and_default")if(m)m&&S&&F&&(T.name+=`${o}${l}`);else{const N=X(y({},T),{path:I});if(F&&(N.name=`${T.name}${o}${l}`),u.children){N.children=[];for(const q of u.children)N.children=N.children.concat(h(q,[E],!0,!0))}_.push(N)}const ce=m&&!I.startsWith("/"),re=!ce&&!($&&a==="prefix_except_default");return re&&(I=`/${E}${I}`),I&&(I=Te(I,n,ce)),re&&$&&a==="prefix"&&r&&_.push(y({},u)),T.path=I,_.push(T),_},[])}return e.reduce((u,R)=>[...u,...h(R,d||[])],[])}function be(e,{locales:t=[],localeCodes:a=[],baseUrl:n=ee}={}){if(!j(e.global,e.mode))throw new Error("TODO:");const o=c.ref(t),l=c.ref(a);e.global.locales=c.computed(()=>o.value),e.global.localeCodes=c.computed(()=>l.value),e.global.__baseUrl=K(n,{})}function ve(e,t={}){const{version:a,defaultLocale:n,locales:o,strategy:l,trailingSlash:r,routesNameSeparator:f,defaultLocaleRouteNameSuffix:i,defaultDirection:d,baseUrl:h,routes:u,routeOptionsResolver:R}=Xe(t),m=G(o),S=m.map(E=>E.code),L=oe(S,f,i);be(e,{locales:m,baseUrl:h,localeCodes:S});const A=le(u,{locales:o,defaultLocale:n,strategy:l,trailingSlash:r,routesNameSeparator:f,defaultLocaleRouteNameSuffix:i,optionsResolver:R});t.routes=A;const _=Ce(t,a);return _.__defaultLocale=n,_.__localeCodes=S,_.__strategy=l,_.__trailingSlash=r,_.__routesNameSeparator=f,_.__defaultLocaleRouteNameSuffix=i,_.__defaultDirection=d,_.beforeEach((E,F,I)=>{const T=O(e),$=L(E)||T||n||"";T!==$&&W(e,$),I()}),_}function Ce(e,t){if(c.isVue3&&t===4)return g.createRouter(e);if(c.isVue2&&t===3)return new he.default(e);throw new Error("TODO:")}function xe(e){return new RegExp(`^/(${e.join("|")})(?:/|$)`,"i")}function oe(e,t,a){const n=`(${e.join("|")})`,o=`(?:${t}${a})?`,l=new RegExp(`${t}${n}${o}$`,"i"),r=xe(e);return i=>{if(me(i)){if(i.name){const h=(P(i.name)?i.name:i.name.toString()).match(l);if(h&&h.length>1)return h[1]}else if(i.path){const d=i.path.match(r);if(d&&d.length>1)return d[1]}}else if(P(i)){const d=i.match(r);if(d&&d.length>1)return d[1]}return""}}function Xe(e){var t,a,n,o,l,r,f,i,d,h;return e.version=(t=e.version)!=null?t:4,e.defaultLocale=(a=e.defaultLocale)!=null?a:w,e.strategy=(n=e.strategy)!=null?n:b,e.trailingSlash=(o=e.trailingSlash)!=null?o:Z,e.routesNameSeparator=(l=e.routesNameSeparator)!=null?l:v,e.defaultLocaleRouteNameSuffix=(r=e.defaultLocaleRouteNameSuffix)!=null?r:M,e.locales=(f=e.locales)!=null?f:[],e.defaultDirection=(i=e.defaultDirection)!=null?i:Fe,e.baseUrl=(d=e.baseUrl)!=null?d:ee,e.routes=(h=e.routes)!=null?h:[],e}const Ve="0.0.0";return s.VERSION=Ve,s.createLocaleFromRouteGetter=oe,s.createRouter=ve,s.getLocale=O,s.getRouteBaseName=C,s.localeLocation=Ne,s.localePath=te,s.localeRoute=ae,s.localizeRoutes=le,s.resolveBaseUrl=K,s.setLocale=W,s.switchLocalePath=D,s.useI18nHead=ye,Object.defineProperty(s,"__esModule",{value:!0}),s[Symbol.toStringTag]="Module",s}({},VueDemi,VueRouter,VueI18n); | ||
*/process.env.NODE_ENV;const Ie=typeof Symbol=="function"&&typeof Symbol.toStringTag=="symbol",Te=e=>Ie?Symbol(e):e,k=Object.assign,ye=Array.isArray,Oe=e=>typeof e=="function",y=e=>typeof e=="string",Pe=e=>typeof e=="boolean",Ce=e=>typeof e=="symbol",K=e=>e!==null&&typeof e=="object",be=/\/$|\/\?/;function Z(e="",t=!1){return t?be.test(e):e.endsWith("/")}function Ue(e="",t=!1){if(!t)return(Z(e)?e.slice(0,-1):e)||"/";if(!Z(e,!0))return e||"/";const[o,...n]=e.split("?");return(o.slice(0,-1)||"/")+(n.length?`?${n.join("?")}`:"")}function Ne(e="",t=!1){if(!t)return e.endsWith("/")?e:e+"/";if(Z(e,!0))return e||"/";const[o,...n]=e.split("?");return o+"/"+(n.length?`?${n.join("?")}`:"")}const Fe=typeof window<"u";function ae(e,t){typeof console<"u"&&(console.warn("[vue-i18n-routing] "+e),t&&console.warn(t.stack))}function ce(e){e=e||[];const t=[];for(const o of e)y(o)?t.push({code:o}):t.push(o);return t}function F(e){return e!=null&&"global"in e&&"mode"in e}function w(e){return e!=null&&!("__composer"in e)&&h.isRef(e.locale)}function C(e){return e!=null&&"__composer"in e}function z(e){return e!=null&&!("__composer"in e)&&!h.isRef(e.locale)}function O(e){return e!=null&&("__VUE_I18N_BRIDGE__"in e||"_sync"in e)}function se(e){return F(e)?w(e.global)?e.global:e.global.__composer:C(e)?e.__composer:e}function H(e){const t=F(e)?e.global:e;return w(t)?h.isVue2&&O(e)?e.locale:t.locale.value:(z(t)||C(t)||O(t),t.locale)}function we(e){const t=F(e)?e.global:e;return w(t)?h.isVue2&&O(e)?e.locales:t.locales.value:(z(t)||C(t)||O(t),t.locales)}function re(e,t){const o=F(e)?e.global:e;if(w(o))h.isVue2&&O(e)?e.locale=t:o.locale.value=t;else if(z(o)||C(o)||O(o))o.locale=t;else throw new Error("TODO:")}function $e(e,t,o){return e.replace(/\/+$/,"")+(t?"/":"")||(o?"":"/")}function ie(e){return g.isVueRouter4,h.isRef(e)?e.value:e}function ue(e){return y(e)?e:Ce(e)?e.toString():"(null)"}function fe(e,t,{defaultLocale:o,strategy:n,routesNameSeparator:a,defaultLocaleRouteNameSuffix:l}){let c=ue(e)+(n==="no_prefix"?"":a+t);return t===o&&n==="prefix_and_default"&&(c+=a+l),c}function de(e,t){return Oe(e)?e(t):e}function ve(e,t){const o=[];for(const[n,a]of t.entries()){const l=e.find(c=>c.iso.toLowerCase()===a.toLowerCase());if(l){o.push({code:l.code,score:1-n/t.length});break}}for(const[n,a]of t.entries()){const l=a.split("-")[0].toLowerCase(),c=e.find(s=>s.iso.split("-")[0].toLowerCase()===l);if(c){o.push({code:c.code,score:.999-n/t.length});break}}return o}const Ve=ve;function je(e,t){return e.score===t.score?t.code.length-e.code.length:t.score-e.score}const Ge=je;function Be(e,t,{matcher:o=Ve,comparer:n=Ge}={}){const a=[];for(const c of e){const{code:s}=c,r=c.iso||s;a.push({code:s,iso:r})}const l=o(a,t);return l.length>1&&l.sort(n),l.length?l[0].code:""}function T(e){return function(){return Reflect.apply(e,{getRouteBaseName:this.getRouteBaseName,localePath:this.localePath,localeRoute:this.localeRoute,localeLocation:this.localeLocation,resolveRoute:this.resolveRoute,switchLocalePath:this.switchLocalePath,localeHead:this.localeHead,i18n:this.$i18n,route:this.$route,router:this.$router},arguments)}}function he(e,{locales:t=[],localeCodes:o=[],baseUrl:n=J,hooks:a={}}={}){const l=h.effectScope(),c=e.install;return e.install=(s,...r)=>{Reflect.apply(c,e,[s,...r]);const u=se(e);l.run(()=>De(u,{locales:t,localeCodes:o,baseUrl:n,hooks:a})),C(e.global)&&ke(e.global,a.onExtendVueI18n);const d=s,i=e.mode==="composition"?h.isVue3?d.config.globalProperties.$i18n:e:h.isVue2?e:null;if(i&&Me(i,u,a.onExtendExportedGlobal),(ze(r[0])?r[0]:{inject:!0}).inject&&s.mixin({methods:{resolveRoute:T($),localePath:T(x),localeRoute:T(q),localeLocation:T(te),switchLocalePath:T(v),getRouteBaseName:T(b),localeHead:T(oe)}}),d.unmount){const L=d.unmount;d.unmount=()=>{l.stop(),L()}}},l}function De(e,t){const{locales:o,localeCodes:n,baseUrl:a}=t,l=h.ref(o),c=h.ref(n);e.locales=h.computed(()=>l.value),e.localeCodes=h.computed(()=>c.value),e.__baseUrl=de(a,{}),t.hooks&&t.hooks.onExtendComposer&&t.hooks.onExtendComposer(e)}function Me(e,t,o){const n=[{locales:{get(){return t.locales.value}},localeCodes:{get(){return t.localeCodes.value}},__baseUrl:{get(){return t.__baseUrl}}}];o&&n.push(o(t));for(const a of n)for(const[l,c]of Object.entries(a))Object.defineProperty(e,l,c)}function ke(e,t){const o=se(e),n=[{locales:{get(){return o.locales.value}},localeCodes:{get(){return o.localeCodes.value}},__baseUrl:{get(){return o.__baseUrl}}}];t&&n.push(t(o));for(const a of n)for(const[l,c]of Object.entries(a))Object.defineProperty(e,l,c)}function ze(e){return K(e)&&"inject"in e&&Pe(e.inject)}function Le(e,{defaultLocale:t=j,strategy:o=G,trailingSlash:n=B,routesNameSeparator:a=D,defaultLocaleRouteNameSuffix:l=M,includeUprefixedFallback:c=!1,optionsResolver:s=void 0,locales:r=[]}={}){if(o==="no_prefix")return e;const u=r.map(i=>y(i)?i:i.code);function d(i,_,L=!1,S=!1){if(i.redirect&&(!i.component||!i.file))return[i];let R=null;if(s!=null&&(R=s(i,_),R==null))return[i];const p={locales:u,paths:{}};if(R!=null&&k(p,R),k(p,{locales:_}),p.locales.length>0&&R&&R.locales!=null&&R.locales.length>0){const E=[];for(const m of p.locales)R.locales.includes(m)&&E.push(m);p.locales=E}return p.locales.reduce((E,m)=>{const{name:V}=i;let{path:A}=i;const I={...i};V&&(I.name=`${V}${a}${m}`),i.children&&(I.children=i.children.reduce((P,le)=>[...P,...d(le,[m],!0,S)],[])),p.paths&&p.paths[m]&&(A=p.paths[m]);const U=m===t;if(U&&o==="prefix_and_default")if(L)L&&S&&V&&(I.name+=`${a}${l}`);else{const P={...I,path:A};if(V&&(P.name=`${I.name}${a}${l}`),i.children){P.children=[];for(const le of i.children)P.children=P.children.concat(d(le,[m],!0,!0))}E.push(P)}const Ee=L&&!A.startsWith("/"),Se=!Ee&&!(U&&o==="prefix_except_default");return Se&&(A=`/${m}${A}`),A&&(A=$e(A,n,Ee)),Se&&U&&o==="prefix"&&c&&E.push({...i}),I.path=A,E.push(I),E},[])}return e.reduce((i,_)=>[...i,...d(_,u||[])],[])}const ee=Te("vue-i18n-routing-gor");function ge(e,t){e[ee]?ae("already registered global options"):e[ee]=t}function _e(e){var t;return(t=e[ee])!=null?t:{}}function He(e,t={}){const{version:o,defaultLocale:n,locales:a,strategy:l,trailingSlash:c,routesNameSeparator:s,defaultLocaleRouteNameSuffix:r,defaultDirection:u,baseUrl:d,routes:i,routeOptionsResolver:_}=xe(t),L=ce(a),S=L.map(m=>m.code),R=Re(S,s,r);he(e,{locales:L,baseUrl:d,localeCodes:S});const p=Le(i,{locales:a,defaultLocale:n,strategy:l,trailingSlash:c,routesNameSeparator:s,defaultLocaleRouteNameSuffix:r,optionsResolver:_});t.routes=p;const E=Xe(t,o);return ge(E,{defaultLocale:n,localeCodes:S,strategy:l,trailingSlash:c,routesNameSeparator:s,defaultLocaleRouteNameSuffix:r,defaultDirection:u}),E.beforeEach((m,V,A)=>{const I=H(e),U=R(m)||I||n||"";I!==U&&re(e,U),A()}),E}function Xe(e,t){if(h.isVue3&&t===4)return g.createRouter(e);if(h.isVue2&&t===3)return new Ae.default(e);throw new Error("TODO:")}function me(e){return new RegExp(`^/(${e.join("|")})(?:/|$)`,"i")}function Re(e,t,o){const n=`(${e.join("|")})`,a=`(?:${t}${o})?`,l=new RegExp(`${t}${n}${a}$`,"i"),c=me(e);return r=>{if(K(r)){if(r.name){const d=(y(r.name)?r.name:r.name.toString()).match(l);if(d&&d.length>1)return d[1]}else if(r.path){const u=r.path.match(c);if(u&&u.length>1)return u[1]}}else if(y(r)){const u=r.match(c);if(u&&u.length>1)return u[1]}return""}}function xe(e){var t,o,n,a,l,c,s,r,u,d;return e.version=(t=e.version)!=null?t:4,e.defaultLocale=(o=e.defaultLocale)!=null?o:j,e.strategy=(n=e.strategy)!=null?n:G,e.trailingSlash=(a=e.trailingSlash)!=null?a:B,e.routesNameSeparator=(l=e.routesNameSeparator)!=null?l:D,e.defaultLocaleRouteNameSuffix=(c=e.defaultLocaleRouteNameSuffix)!=null?c:M,e.locales=(s=e.locales)!=null?s:[],e.defaultDirection=(r=e.defaultDirection)!=null?r:Y,e.baseUrl=(u=e.baseUrl)!=null?u:J,e.routes=(d=e.routes)!=null?d:[],e}function X(e,t,{defaultLocale:o=j,defaultDirection:n=Y,defaultLocaleRouteNameSuffix:a=M,routesNameSeparator:l=D,strategy:c=G,trailingSlash:s=B,localeCodes:r=[]}={}){const u=_e(e);return{defaultLocale:t.defaultLocale||u.defaultLocale||o,defaultDirection:t.defaultDirection||u.defaultDirection||n,defaultLocaleRouteNameSuffix:t.defaultLocaleRouteNameSuffix||u.defaultLocaleRouteNameSuffix||a,routesNameSeparator:t.routesNameSeparator||u.routesNameSeparator||l,strategy:t.strategy||u.strategy||c,trailingSlash:t.trailingSlash||u.trailingSlash||s,localeCodes:t.localeCodes||u.localeCodes||r}}const qe=new Set(["prefix_and_default","prefix_except_default"]);function b(e){const t=this.router,{routesNameSeparator:o}=X(t,this),n=e!=null?h.isRef(e)?h.unref(e):e:this.route;return n.name?ue(n.name).split(o)[0]:void 0}function x(e,t){const o=$.call(this,e,t);return o==null?"":h.isVue3?o.redirectedFrom||o.fullPath:o.route.redirectedFrom||o.route.fullPath}function q(e,t){const o=$.call(this,e,t);return o==null?void 0:h.isVue3?o:o.route}function te(e,t){const o=$.call(this,e,t);return o==null?void 0:h.isVue3?o:o.location}function $(e,t){const o=this.router,n=this.i18n,a=t||H(n),{routesNameSeparator:l,defaultLocale:c,defaultLocaleRouteNameSuffix:s,strategy:r,trailingSlash:u}=X(o,this);let d=e;y(e)&&(d[0]==="/"?d={path:e}:d={name:e});let i=k({},d);if(i.path&&!i.name){const L=o.resolve(i),S=h.isVue3?L:L.route,R=b.call(this,S);y(R)?i={name:fe(R,a,{defaultLocale:c,strategy:r,routesNameSeparator:l,defaultLocaleRouteNameSuffix:s}),params:S.params,query:S.query,hash:S.hash}:(!(a===c&&qe.has(r))&&r!=="no_prefix"&&(i.path=`/${a}${i.path}`),i.path=u?Ne(i.path,!0):Ue(i.path,!0))}else{i.name=fe(i.name,a,{defaultLocale:c,strategy:r,routesNameSeparator:l,defaultLocaleRouteNameSuffix:s});const{params:L}=i;L&&L[0]===void 0&&L.pathMatch&&(L[0]=L.pathMatch)}const _=o.resolve(i);return(h.isVue3?_.name:_.route.name)?_:o.resolve(e)}function v(e){const t=this.route,o=b.call(this,t);if(!o)return"";const{params:n,...a}=!h.isVue3&&h.isRef(t)?t.value:t,c=k({},a,{name:o,params:{...n,...{},0:n.pathMatch}});return x.call(this,c,e)}function oe({addDirAttribute:e=!1,addSeoAttributes:t=!1}={}){const o=this.router,n=this.i18n,{defaultDirection:a}=X(o,this),l={htmlAttrs:{},link:[],meta:[]};if(n.locales==null||n.__baseUrl==null)return l;const c=H(n),s=we(n),r=ce(s).find(i=>i.code===c)||{code:c},u=r.iso,d=r.dir||a;return e&&(l.htmlAttrs.dir=d),t&&c&&n.locales&&(u&&(l.htmlAttrs.lang=u),We.call(this,s,n.__baseUrl,l.link),Qe.call(this,n.__baseUrl,l.link,t),Ye(r,u,l.meta),Je(s,u,l.meta)),l}function We(e,t,o){const n=this.router,{defaultLocale:a,strategy:l}=X(n,this);if(l===Q.NO_PREFIX)return;const c=new Map;for(const s of e){const r=s.iso;if(!r){ae("Locale ISO code is required to generate alternate link");continue}const[u,d]=r.split("-");u&&d&&(s.isCatchallLocale||!c.has(u))&&c.set(u,s),c.set(r,s)}for(const[s,r]of c.entries()){const u=v.call(this,r.code);u&&o.push({hid:`i18n-alt-${s}`,rel:"alternate",href:ne(u,t),hreflang:s})}if(a){const s=v.call(this,a);s&&o.push({hid:"i18n-xd",rel:"alternate",href:ne(s,t),hreflang:"x-default"})}}function Qe(e,t,o){const n=this.route,a=q.call(this,{...n,name:b.call(this,n)});if(a){let l=ne(a.path,e);const c=K(o)&&o.canonicalQueries||[];if(c.length){const s=a.query,r=new URLSearchParams;for(const d of c)if(d in s){const i=s[d];ye(i)?i.forEach(_=>r.append(d,_||"")):r.append(d,i||"")}const u=r.toString();u&&(l=`${l}?${u}`)}t.push({hid:"i18n-can",rel:"canonical",href:l})}}function Ye(e,t,o){!(e&&t)||o.push({hid:"i18n-og",property:"og:locale",content:pe(t)})}function Je(e,t,o){const n=e.filter(a=>{const l=a.iso;return l&&l!==t});if(n.length){const a=n.map(l=>({hid:`i18n-og-alt-${l.iso}`,property:"og:locale:alternate",content:pe(l.iso)}));o.push(...a)}}function pe(e){return(e||"").replace(/-/g,"_")}function ne(e,t){return e.match(/^https?:\/\//)?e:t+e}function W(e,t){const{router:o,route:n,i18n:a,defaultLocale:l,strategy:c,defaultLocaleRouteNameSuffix:s,trailingSlash:r,routesNameSeparator:u}=e;return function(...d){return Reflect.apply(t,{router:o,route:n,i18n:a,defaultLocale:l,strategy:c,defaultLocaleRouteNameSuffix:s,trailingSlash:r,routesNameSeparator:u},d)}}function Ke(e=g.useRoute(),{router:t=g.useRouter(),routesNameSeparator:o=void 0}={}){const n={router:t,route:e,routesNameSeparator:o};return b.call(n,e)}function Ze({router:e=g.useRouter(),route:t=g.useRoute(),i18n:o=N.useI18n(),defaultLocale:n=void 0,defaultLocaleRouteNameSuffix:a=void 0,routesNameSeparator:l=void 0,strategy:c=void 0,trailingSlash:s=void 0}={}){return W({router:e,route:t,i18n:o,defaultLocale:n,defaultLocaleRouteNameSuffix:a,routesNameSeparator:l,strategy:c,trailingSlash:s},x)}function et({router:e=g.useRouter(),route:t=g.useRoute(),i18n:o=N.useI18n(),defaultLocale:n=void 0,defaultLocaleRouteNameSuffix:a=void 0,routesNameSeparator:l=void 0,strategy:c=void 0,trailingSlash:s=void 0}={}){return W({router:e,route:t,i18n:o,defaultLocale:n,defaultLocaleRouteNameSuffix:a,routesNameSeparator:l,strategy:c,trailingSlash:s},q)}function tt({router:e=g.useRouter(),route:t=g.useRoute(),i18n:o=N.useI18n(),defaultLocale:n=void 0,defaultLocaleRouteNameSuffix:a=void 0,routesNameSeparator:l=void 0,strategy:c=void 0,trailingSlash:s=void 0}={}){return W({router:e,route:t,i18n:o,defaultLocale:n,defaultLocaleRouteNameSuffix:a,routesNameSeparator:l,strategy:c,trailingSlash:s},te)}function ot({router:e=g.useRouter(),route:t=g.useRoute(),i18n:o=N.useI18n(),defaultLocale:n=void 0,defaultLocaleRouteNameSuffix:a=void 0,routesNameSeparator:l=void 0,strategy:c=void 0,trailingSlash:s=void 0}={}){return W({router:e,route:t,i18n:o,defaultLocale:n,defaultLocaleRouteNameSuffix:a,routesNameSeparator:l,strategy:c,trailingSlash:s},v)}function nt({addDirAttribute:e=!1,addSeoAttributes:t=!1,strategy:o=void 0,defaultLocale:n=void 0,route:a=g.useRoute(),router:l=g.useRouter(),i18n:c=N.useI18n()}={}){const s=l,r=h.ref({htmlAttrs:{},link:[],meta:[]});function u(){r.value={htmlAttrs:{},link:[],meta:[]}}function d(i){r.value=Reflect.apply(oe,{router:l,route:i,i18n:c,defaultLocale:n,strategy:o},[{addDirAttribute:e,addSeoAttributes:t}])}if(Fe)if(h.isVue3){const i=h.watchEffect(()=>{u(),d(ie(s.currentRoute))});h.onUnmounted(()=>i())}else{const i=s.afterEach((_,L)=>{u(),d(_)});h.onUnmounted(()=>i()),d(a)}else d(ie(s.currentRoute));return r}const lt="0.0.0";return f.DEFAULT_BASE_URL=J,f.DEFAULT_DETECTION_DIRECTION=Y,f.DEFAULT_LOCALE=j,f.DEFAULT_LOCALE_ROUTE_NAME_SUFFIX=M,f.DEFAULT_ROUTES_NAME_SEPARATOR=D,f.DEFAULT_STRATEGY=G,f.DEFAULT_TRAILING_SLASH=B,f.STRATEGIES=Q,f.VERSION=lt,f.createLocaleFromRouteGetter=Re,f.createRouter=He,f.extendI18n=he,f.findBrowserLocale=Be,f.getGlobalOptions=_e,f.getLocale=H,f.getLocalesRegex=me,f.getRouteBaseName=b,f.isComposer=w,f.isExportedGlobalComposer=z,f.isI18nInstance=F,f.isLegacyVueI18n=O,f.isVueI18n=C,f.localeHead=oe,f.localeLocation=te,f.localePath=x,f.localeRoute=q,f.localizeRoutes=Le,f.proxyVueInstance=T,f.registerGlobalOptions=ge,f.resolveBaseUrl=de,f.resolveRoute=$,f.setLocale=re,f.switchLocalePath=v,f.useLocaleHead=nt,f.useLocaleLocation=tt,f.useLocalePath=Ze,f.useLocaleRoute=et,f.useRouteBaseName=Ke,f.useSwitchLocalePath=ot,Object.defineProperties(f,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),f}({},VueDemi,VueRouter,VueI18n); |
{ | ||
"name": "vue-i18n-routing", | ||
"description": "The i18n routing with using vue-i18n", | ||
"version": "0.0.0-5735bda", | ||
"version": "0.0.0-591e862", | ||
"dependencies": { | ||
"@intlify/shared": "beta", | ||
"@intlify/shared": "next", | ||
"@intlify/vue-i18n-bridge": "^0.3.5", | ||
"@intlify/vue-router-bridge": "^0.3.5", | ||
"ufo": "^0.7.9", | ||
"vue-demi": "^0.12.1" | ||
"vue-demi": "^0.13.4" | ||
}, | ||
"devDependencies": { | ||
"@microsoft/api-extractor": "^7.18.20", | ||
"@vue/test-utils": "^1.3.0", | ||
"@microsoft/api-extractor": "^7.28.4", | ||
"api-docs-gen": "^0.4.0", | ||
"rimraf": "^3.0.2", | ||
"typescript": "^4.5.4", | ||
"vite": "latest", | ||
"typescript": "^4.7.4", | ||
"vite": "^3.0.0", | ||
"vite-plugin-dts": "^0.9.6", | ||
"vitest": "^0.2.8", | ||
"vue": "^3.2.23", | ||
"vitest": "^0.18.0", | ||
"vue": "^3.2.27", | ||
"vue-i18n": "npm:vue-i18n@next", | ||
"vue-i18n-bridge": "beta", | ||
"vue-i18n-bridge": "next", | ||
"vue-i18n-legacy": "npm:vue-i18n@8", | ||
"vue-router": "^4.0.12", | ||
"vue-router": "^4.0.15", | ||
"vue-router3": "npm:vue-router@3", | ||
@@ -33,4 +32,4 @@ "vue-template-compiler": "^2.6.14", | ||
"vue": "^2.6.14 || ^3.2.0", | ||
"vue-i18n": "^8.26.1 || ^9.2.0-beta.30", | ||
"vue-i18n-bridge": "^9.2.0-beta.30", | ||
"vue-i18n": "^8.26.1 || ^9.2.0-beta.37", | ||
"vue-i18n-bridge": "^9.2.0-beta.37", | ||
"vue-router": "^3.5.3 || ^4.0.0" | ||
@@ -41,2 +40,14 @@ }, | ||
"optional": true | ||
}, | ||
"vue": { | ||
"optional": true | ||
}, | ||
"vue-i18n": { | ||
"optional": true | ||
}, | ||
"vue-i18n-bridge": { | ||
"optional": true | ||
}, | ||
"vue-router": { | ||
"optional": true | ||
} | ||
@@ -53,7 +64,8 @@ }, | ||
"index.mjs", | ||
"types.d.ts", | ||
"LICENSE", | ||
"README.md" | ||
], | ||
"main": "./dist/vue-i18n-routing.cjs.js", | ||
"module": "./dist/vue-i18n-routing.es.js", | ||
"main": "./dist/vue-i18n-routing.js", | ||
"module": "./dist/vue-i18n-routing.mjs", | ||
"unpkg": "dist/vue-i18n-routing.iife.js", | ||
@@ -66,9 +78,12 @@ "jsdelivr": "dist/vue-i18n-routing.iife.js", | ||
"node": "./index.mjs", | ||
"default": "./dist/vue-i18n-routing.es.js" | ||
"default": "./dist/vue-i18n-routing.mjs" | ||
}, | ||
"require": "./dist/vue-i18n-routing.cjs.js", | ||
"require": "./dist/vue-i18n-routing.js", | ||
"types": "./dist/vue-i18n-routing.d.ts" | ||
}, | ||
"./dist/*": "./dist/*", | ||
"./package.json": "./package.json" | ||
"./types": { | ||
"types": "./types.d.ts" | ||
}, | ||
"./package.json": "./package.json", | ||
"./dist/*": "./dist/*" | ||
}, | ||
@@ -90,3 +105,3 @@ "license": "MIT", | ||
"engines": { | ||
"node": ">= 12" | ||
"node": ">= 14.6" | ||
}, | ||
@@ -93,0 +108,0 @@ "publishConfig": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
83127
15
11
1542
2
+ Added@intlify/shared@11.0.0-rc.1(transitive)
+ Addedvue-demi@0.13.11(transitive)
- Removed@intlify/shared@9.3.0-beta.27(transitive)
- Removedvue-demi@0.12.5(transitive)
Updated@intlify/shared@next
Updatedvue-demi@^0.13.4