Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vue-i18n-routing

Package Overview
Dependencies
Maintainers
1
Versions
239
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-i18n-routing - npm Package Compare versions

Comparing version 0.0.0-2087dad to 0.0.0-29e55b7

dist/vue-i18n-routing.vue-i18n.d.ts

4

dist/vue-i18n-routing.cjs.js

@@ -1,5 +0,5 @@

"use strict";var Se=Object.defineProperty,Ee=Object.defineProperties;var Pe=Object.getOwnPropertyDescriptors;var j=Object.getOwnPropertySymbols;var ae=Object.prototype.hasOwnProperty,le=Object.prototype.propertyIsEnumerable;var oe=(e,t,o)=>t in e?Se(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,v=(e,t)=>{for(var o in t||(t={}))ae.call(t,o)&&oe(e,o,t[o]);if(j)for(var o of j(t))le.call(t,o)&&oe(e,o,t[o]);return e},X=(e,t)=>Ee(e,Pe(t));var ne=(e,t)=>{var o={};for(var a in e)ae.call(e,a)&&t.indexOf(a)<0&&(o[a]=e[a]);if(e!=null&&j)for(var a of j(e))t.indexOf(a)<0&&le.call(e,a)&&(o[a]=e[a]);return o};Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var h=require("vue-demi"),L=require("@intlify/vue-router-bridge"),O=require("@intlify/vue-i18n-bridge");function ye(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var Ne=ye(L);/*!
"use strict";var Oe=Object.defineProperty,be=Object.defineProperties;var Ae=Object.getOwnPropertyDescriptors;var T=Object.getOwnPropertySymbols;var ce=Object.prototype.hasOwnProperty,se=Object.prototype.propertyIsEnumerable;var re=(e,t,o)=>t in e?Oe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,P=(e,t)=>{for(var o in t||(t={}))ce.call(t,o)&&re(e,o,t[o]);if(T)for(var o of T(t))se.call(t,o)&&re(e,o,t[o]);return e},U=(e,t)=>be(e,Ae(t));var ie=(e,t)=>{var o={};for(var n in e)ce.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&T)for(var n of T(e))t.indexOf(n)<0&&se.call(e,n)&&(o[n]=e[n]);return o};Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var d=require("vue-demi"),m=require("@intlify/vue-router-bridge"),N=require("@intlify/vue-i18n-bridge");function we(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var ye=we(m);/*!
* shared v9.2.0-beta.34
* (c) 2022 kazuya kawaguchi
* Released under the MIT License.
*/const se=Object.assign,xe=Array.isArray,ve=e=>typeof e=="function",A=e=>typeof e=="string",Ie=e=>typeof e=="symbol",ue=e=>e!==null&&typeof e=="object",Ae=/\/$|\/\?/;function Q(e="",t=!1){return t?Ae.test(e):e.endsWith("/")}function we(e="",t=!1){if(!t)return(Q(e)?e.slice(0,-1):e)||"/";if(!Q(e,!0))return e||"/";const[o,...a]=e.split("?");return(o.slice(0,-1)||"/")+(a.length?`?${a.join("?")}`:"")}function Ce(e="",t=!1){if(!t)return e.endsWith("/")?e:e+"/";if(Q(e,!0))return e||"/";const[o,...a]=e.split("?");return o+"/"+(a.length?`?${a.join("?")}`:"")}const De=typeof window!="undefined";function Fe(e,t){typeof console!="undefined"&&(console.warn("[vue-i18n-routing] "+e),t&&console.warn(t.stack))}function ie(e){e=e||[];const t=[];for(const o of e)A(o)?t.push({code:o}):t.push(o);return t}function M(e){return e!=null&&"global"in e&&"mode"in e}function k(e){return e!=null&&!("__composer"in e)&&h.isRef(e.locale)}function V(e){return e!=null&&"__composer"in e}function J(e){return e!=null&&!("__composer"in e)&&!h.isRef(e.locale)}function D(e){return e!=null&&("__VUE_I18N_BRIDGE__"in e||"_sync"in e)}function fe(e){return M(e)?k(e.global)?e.global:e.global.__composer:V(e)?e.__composer:e}function z(e){const t=M(e)?e.global:e;return k(t)?h.isVue2&&D(e)?e.locale:t.locale.value:(J(t)||V(t)||D(t),t.locale)}function Te(e){const t=M(e)?e.global:e;return k(t)?h.isVue2&&D(e)?e.locales:t.locales.value:(J(t)||V(t)||D(t),t.locales)}function he(e,t){const o=M(e)?e.global:e;if(k(o))h.isVue2&&D(e)?e.locale=t:o.locale.value=t;else if(J(o)||V(o)||D(o))o.locale=t;else throw new Error("TODO:")}function be(e,t,o){return e.replace(/\/+$/,"")+(t?"/":"")||(o?"":"/")}function re(e){return L.isVueRouter4,h.isRef(e)?e.value:e}function de(e){return A(e)?e:Ie(e)?e.toString():"(null)"}function ce(e,t,{defaultLocale:o,strategy:a,routesNameSeparator:l,defaultLocaleRouteNameSuffix:n}){let r=de(e)+(a==="no_prefix"?"":l+t);return t===o&&a==="prefix_and_default"&&(r+=l+n),r}function _e(e,t){return ve(e)?e(t):e}function Ue(e,t){const o=[];for(const[a,l]of t.entries()){const n=e.find(r=>r.iso.toLowerCase()===l.toLowerCase());if(n){o.push({code:n.code,score:1-a/t.length});break}}for(const[a,l]of t.entries()){const n=l.split("-")[0].toLowerCase(),r=e.find(c=>c.iso.split("-")[0].toLowerCase()===n);if(r){o.push({code:r.code,score:.999-a/t.length});break}}return o}const $e=Ue;function Oe(e,t){return e.score===t.score?t.code.length-e.code.length:t.score-e.score}const Ve=Oe;function Be(e,t,{matcher:o=$e,comparer:a=Ve}={}){const l=[];for(const r of e){const{code:c}=r,s=r.iso||c;l.push({code:c,iso:s})}const n=o(l,t);return n.length>1&&n.sort(a),n.length?n[0].code:""}const U={PREFIX:"prefix",PREFIX_EXCEPT_DEFAULT:"prefix_except_default",PREFIX_AND_DEFAULT:"prefix_and_default",NO_PREFIX:"no_prefix"},y="",N=U.PREFIX_EXCEPT_DEFAULT,me=!1,P="___",w="default",je="ltr",Le="",Xe=new Set([U.PREFIX_AND_DEFAULT,U.PREFIX_EXCEPT_DEFAULT]);function F(e){const o=this.router.__routesNameSeparator||this.__routesNameSeparator||P,a=e!=null?h.isRef(e)?h.unref(e):e:this.route;return a.name?de(a.name).split(o)[0]:void 0}function q(e,t){const o=B.call(this,e,t);return o==null?"":h.isVue3?o.redirectedFrom||o.fullPath:o.route.redirectedFrom||o.route.fullPath}function H(e,t){const o=B.call(this,e,t);return o==null?void 0:h.isVue3?o:o.route}function K(e,t){const o=B.call(this,e,t);return o==null?void 0:h.isVue3?o:o.location}function B(e,t){const o=this.router,a=this.i18n,l=t||z(a),n=this.__defaultLocale||y,r=o.__defaultLocale||n,c=o.__defaultLocaleRouteNameSuffix||this.__defaultLocaleRouteNameSuffix||w,s=o.__routesNameSeparator||this.__routesNameSeparator||P,u=o.__strategy||this.__strategy||N,f=o.__trailingSlash||this.__trailingSlash||!1;let i=e;A(e)&&(i[0]==="/"?i={path:e}:i={name:e});let d=se({},i);if(d.path&&!d.name){const _=o.resolve(d),E=h.isVue3?_:_.route,T=F.call(this,E);A(T)?d={name:ce(T,l,{defaultLocale:r,strategy:u,routesNameSeparator:s,defaultLocaleRouteNameSuffix:c}),params:E.params,query:E.query,hash:E.hash}:(!(l===n&&Xe.has(u))&&u!==U.NO_PREFIX&&(d.path=`/${l}${d.path}`),d.path=f?Ce(d.path,!0):we(d.path,!0))}else{d.name=ce(d.name,l,{defaultLocale:r,strategy:u,routesNameSeparator:s,defaultLocaleRouteNameSuffix:c});const{params:_}=d;_&&_["0"]===void 0&&_.pathMatch&&(_["0"]=_.pathMatch)}const R=o.resolve(d);return(h.isVue3?R.name:R.route.name)?R:o.resolve(e)}function $(e){const t=this.route,o=F.call(this,t);if(!o)return"";const s=!h.isVue3&&h.isRef(t)?t.value:t,{params:a}=s,l=ne(s,["params"]),n={},r=se({},l,{name:o,params:X(v(v({},a),n),{0:a.pathMatch})});return q.call(this,r,e)}function Z({addDirAttribute:e=!1,addSeoAttributes:t=!1}={}){const o=this.router,a=this.i18n,l={htmlAttrs:{},link:[],meta:[]};if(a.locales==null||a.__baseUrl==null)return l;const n=z(a),r=Te(a),c=ie(r).find(f=>f.code===n)||{code:n},s=c.iso,u=c.dir||o.__defaultDirection;return e&&(l.htmlAttrs.dir=u),t&&n&&a.locales&&(s&&(l.htmlAttrs.lang=s),Me.call(this,r,a.__baseUrl,l.link),ke.call(this,a.__baseUrl,l.link,t),ze(c,s,l.meta),qe(r,s,l.meta)),l}function Me(e,t,o){const a=this.router,l=a.__defaultLocale||this.__defaultLocale;if((a.__strategy||this.__strategy)===U.NO_PREFIX)return;const r=new Map;for(const c of e){const s=c.iso;if(!s){Fe("Locale ISO code is required to generate alternate link");continue}const[u,f]=s.split("-");u&&f&&(c.isCatchallLocale||!r.has(u))&&r.set(u,c),r.set(s,c)}for(const[c,s]of r.entries()){const u=$.call(this,s.code);u&&o.push({hid:`i18n-alt-${c}`,rel:"alternate",href:Y(u,t),hreflang:c})}if(l){const c=$.call(this,l);c&&o.push({hid:"i18n-xd",rel:"alternate",href:Y(c,t),hreflang:"x-default"})}}function ke(e,t,o){const a=this.route,l=H.call(this,X(v({},a),{name:F.call(this,a)}));if(l){let n=Y(l.path,e);const r=ue(o)&&o.canonicalQueries||[];if(r.length){const c=l.query,s=new URLSearchParams;for(const f of r)if(f in c){const i=c[f];xe(i)?i.forEach(d=>s.append(f,d||"")):s.append(f,i||"")}const u=s.toString();u&&(n=`${n}?${u}`)}t.push({hid:"i18n-can",rel:"canonical",href:n})}}function ze(e,t,o){!(e&&t)||o.push({hid:"i18n-og",property:"og:locale",content:Re(t)})}function qe(e,t,o){const a=e.filter(l=>{const n=l.iso;return n&&n!==t});if(a.length){const l=a.map(n=>({hid:`i18n-og-alt-${n.iso}`,property:"og:locale:alternate",content:Re(n.iso)}));o.push(...l)}}function Re(e){return(e||"").replace(/-/g,"_")}function Y(e,t){return e.match(/^https?:\/\//)?e:t+e}function G(e,t){const{router:o,route:a,i18n:l,defaultLocale:n,strategy:r,defaultLocaleRouteNameSuffix:c,trailingSlash:s,routesNameSeparator:u}=e;return function(...f){return Reflect.apply(t,{router:o,route:a,i18n:l,__defaultLocale:n,__strategy:r,__defaultLocaleRouteNameSuffix:c,__trailingSlash:s,__routesNameSeparator:u},f)}}function He(e=L.useRoute(),{router:t=L.useRouter(),routesNameSeparator:o=P}={}){const a={router:t,route:e,__routesNameSeparator:o};return F.call(a,e)}function Ge({router:e=L.useRouter(),route:t=L.useRoute(),i18n:o=O.useI18n(),defaultLocale:a=y,defaultLocaleRouteNameSuffix:l=w,routesNameSeparator:n=P,strategy:r=N,trailingSlash:c=!1}={}){return G({router:e,route:t,i18n:o,defaultLocale:a,defaultLocaleRouteNameSuffix:l,routesNameSeparator:n,strategy:r,trailingSlash:c},q)}function We({router:e=L.useRouter(),route:t=L.useRoute(),i18n:o=O.useI18n(),defaultLocale:a=y,defaultLocaleRouteNameSuffix:l=w,routesNameSeparator:n=P,strategy:r=N,trailingSlash:c=!1}={}){return G({router:e,route:t,i18n:o,defaultLocale:a,defaultLocaleRouteNameSuffix:l,routesNameSeparator:n,strategy:r,trailingSlash:c},H)}function Qe({router:e=L.useRouter(),route:t=L.useRoute(),i18n:o=O.useI18n(),defaultLocale:a=y,defaultLocaleRouteNameSuffix:l=w,routesNameSeparator:n=P,strategy:r=N,trailingSlash:c=!1}={}){return G({router:e,route:t,i18n:o,defaultLocale:a,defaultLocaleRouteNameSuffix:l,routesNameSeparator:n,strategy:r,trailingSlash:c},K)}function Ye({router:e=L.useRouter(),route:t=L.useRoute(),i18n:o=O.useI18n(),defaultLocale:a=y,defaultLocaleRouteNameSuffix:l=w,routesNameSeparator:n=P,strategy:r=N,trailingSlash:c=!1}={}){return G({router:e,route:t,i18n:o,defaultLocale:a,defaultLocaleRouteNameSuffix:l,routesNameSeparator:n,strategy:r,trailingSlash:c},$)}function Je({addDirAttribute:e=!1,addSeoAttributes:t=!1,strategy:o=N,defaultLocale:a=y,route:l=L.useRoute(),router:n=L.useRouter(),i18n:r=O.useI18n()}={}){const c=n,s=h.ref({htmlAttrs:{},link:[],meta:[]});function u(){s.value={htmlAttrs:{},link:[],meta:[]}}function f(i){s.value=Reflect.apply(Z,{router:n,route:i,i18n:r,__defaultLocale:a,__strategy:o},[{addDirAttribute:e,addSeoAttributes:t}])}if(De)if(h.isVue3){const i=h.watchEffect(()=>{u(),f(re(c.currentRoute))});h.onUnmounted(()=>i())}else{const i=c.afterEach((d,R)=>{u(),f(d)});h.onUnmounted(()=>i()),f(l)}else f(re(c.currentRoute));return s}function pe(e,{defaultLocale:t=y,strategy:o=N,trailingSlash:a=me,routesNameSeparator:l=P,defaultLocaleRouteNameSuffix:n=w,includeUprefixedFallback:r=!1,optionsResolver:c=void 0,locales:s=[]}={}){if(o==="no_prefix")return e;const u=s.map(i=>A(i)?i:i.code);function f(i,d,R=!1,_=!1){if(i.redirect&&(!i.component||!i.file))return[i];let E=null;return c!=null&&(E=c(i,d),E==null)?[i]:d.reduce((m,p)=>{const{name:b}=i;let{path:g}=i;const S=v({},i);b&&(S.name=`${b}${l}${p}`),i.children&&(S.children=i.children.reduce((x,W)=>[...x,...f(W,[p],!0,_)],[]));const C=p===t;if(C&&o==="prefix_and_default")if(R)R&&_&&b&&(S.name+=`${l}${n}`);else{const x=X(v({},S),{path:g});if(b&&(x.name=`${S.name}${l}${n}`),i.children){x.children=[];for(const W of i.children)x.children=x.children.concat(f(W,[p],!0,!0))}m.push(x)}const ee=R&&!g.startsWith("/"),te=!ee&&!(C&&o==="prefix_except_default");return te&&(g=`/${p}${g}`),g&&(g=be(g,a,ee)),te&&C&&o==="prefix"&&r&&m.push(v({},i)),S.path=g,m.push(S),m},[])}return e.reduce((i,d)=>[...i,...f(d,u||[])],[])}function I(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 Ke(e,{locales:t=[],localeCodes:o=[],baseUrl:a=Le}={}){const l=e.install;e.install=(n,...r)=>{Reflect.apply(l,e,[n,...r]);const c=fe(e);Ze(c,{locales:t,localeCodes:o,baseUrl:a}),V(e.global)&&tt(e.global);const s=n,u=e.mode==="composition"?h.isVue3?s.config.globalProperties.$i18n:e:h.isVue2?e:null;u&&et(u,c),n.mixin({methods:{resolveRoute:I(B),localePath:I(q),localeRoute:I(H),localeLocation:I(K),switchLocalePath:I($),getRouteBaseName:I(F),localeHead:I(Z)}})}}function Ze(e,t){const{locales:o,localeCodes:a,baseUrl:l}=t,n=h.ref(o),r=h.ref(a);e.locales=h.computed(()=>n.value),e.localeCodes=h.computed(()=>r.value),e.__baseUrl=_e(l,{})}function et(e,t){Object.defineProperty(e,"locales",{get(){return t.locales.value}}),Object.defineProperty(e,"localeCodes",{get(){return t.localeCodes.value}}),Object.defineProperty(e,"__baseUrl",{get(){return t.__baseUrl}})}function tt(e){const t=fe(e);Object.defineProperty(e,"locales",{get(){return t.locales.value}}),Object.defineProperty(e,"localeCodes",{get(){return t.localeCodes.value}}),Object.defineProperty(e,"__baseUrl",{get(){return t.__baseUrl}})}function ot(e,t={}){const{version:o,defaultLocale:a,locales:l,strategy:n,trailingSlash:r,routesNameSeparator:c,defaultLocaleRouteNameSuffix:s,defaultDirection:u,baseUrl:f,routes:i,routeOptionsResolver:d}=nt(t),R=ie(l),_=R.map(p=>p.code),E=ge(_,c,s);Ke(e,{locales:R,baseUrl:f,localeCodes:_});const T=pe(i,{locales:l,defaultLocale:a,strategy:n,trailingSlash:r,routesNameSeparator:c,defaultLocaleRouteNameSuffix:s,optionsResolver:d});t.routes=T;const m=at(t,o);return m.__defaultLocale=a,m.__localeCodes=_,m.__strategy=n,m.__trailingSlash=r,m.__routesNameSeparator=c,m.__defaultLocaleRouteNameSuffix=s,m.__defaultDirection=u,m.beforeEach((p,b,g)=>{const S=z(e),C=E(p)||S||a||"";S!==C&&he(e,C),g()}),m}function at(e,t){if(h.isVue3&&t===4)return L.createRouter(e);if(h.isVue2&&t===3)return new Ne.default(e);throw new Error("TODO:")}function lt(e){return new RegExp(`^/(${e.join("|")})(?:/|$)`,"i")}function ge(e,t,o){const a=`(${e.join("|")})`,l=`(?:${t}${o})?`,n=new RegExp(`${t}${a}${l}$`,"i"),r=lt(e);return s=>{if(ue(s)){if(s.name){const f=(A(s.name)?s.name:s.name.toString()).match(n);if(f&&f.length>1)return f[1]}else if(s.path){const u=s.path.match(r);if(u&&u.length>1)return u[1]}}else if(A(s)){const u=s.match(r);if(u&&u.length>1)return u[1]}return""}}function nt(e){var t,o,a,l,n,r,c,s,u,f;return e.version=(t=e.version)!=null?t:4,e.defaultLocale=(o=e.defaultLocale)!=null?o:y,e.strategy=(a=e.strategy)!=null?a:N,e.trailingSlash=(l=e.trailingSlash)!=null?l:me,e.routesNameSeparator=(n=e.routesNameSeparator)!=null?n:P,e.defaultLocaleRouteNameSuffix=(r=e.defaultLocaleRouteNameSuffix)!=null?r:w,e.locales=(c=e.locales)!=null?c:[],e.defaultDirection=(s=e.defaultDirection)!=null?s:je,e.baseUrl=(u=e.baseUrl)!=null?u:Le,e.routes=(f=e.routes)!=null?f:[],e}const rt="0.0.0";exports.VERSION=rt;exports.createLocaleFromRouteGetter=ge;exports.createRouter=ot;exports.findBrowserLocale=Be;exports.getLocale=z;exports.getRouteBaseName=F;exports.localeHead=Z;exports.localeLocation=K;exports.localePath=q;exports.localeRoute=H;exports.localizeRoutes=pe;exports.resolveBaseUrl=_e;exports.resolveRoute=B;exports.setLocale=he;exports.switchLocalePath=$;exports.useLocaleHead=Je;exports.useLocaleLocation=Qe;exports.useLocalePath=Ge;exports.useLocaleRoute=We;exports.useRouteBaseName=He;exports.useSwitchLocalePath=Ye;
*/const de=Object.assign,Ce=Array.isArray,De=e=>typeof e=="function",O=e=>typeof e=="string",Ne=e=>typeof e=="boolean",xe=e=>typeof e=="symbol",Q=e=>e!==null&&typeof e=="object",Fe=/\/$|\/\?/;function q(e="",t=!1){return t?Fe.test(e):e.endsWith("/")}function Te(e="",t=!1){if(!t)return(q(e)?e.slice(0,-1):e)||"/";if(!q(e,!0))return e||"/";const[o,...n]=e.split("?");return(o.slice(0,-1)||"/")+(n.length?`?${n.join("?")}`:"")}function Ue(e="",t=!1){if(!t)return e.endsWith("/")?e:e+"/";if(q(e,!0))return e||"/";const[o,...n]=e.split("?");return o+"/"+(n.length?`?${n.join("?")}`:"")}const $e=typeof window!="undefined";function Ve(e,t){typeof console!="undefined"&&(console.warn("[vue-i18n-routing] "+e),t&&console.warn(t.stack))}function he(e){e=e||[];const t=[];for(const o of e)O(o)?t.push({code:o}):t.push(o);return t}function $(e){return e!=null&&"global"in e&&"mode"in e}function V(e){return e!=null&&!("__composer"in e)&&d.isRef(e.locale)}function x(e){return e!=null&&"__composer"in e}function Y(e){return e!=null&&!("__composer"in e)&&!d.isRef(e.locale)}function A(e){return e!=null&&("__VUE_I18N_BRIDGE__"in e||"_sync"in e)}function me(e){return $(e)?V(e.global)?e.global:e.global.__composer:x(e)?e.__composer:e}function j(e){const t=$(e)?e.global:e;return V(t)?d.isVue2&&A(e)?e.locale:t.locale.value:(Y(t)||x(t)||A(t),t.locale)}function je(e){const t=$(e)?e.global:e;return V(t)?d.isVue2&&A(e)?e.locales:t.locales.value:(Y(t)||x(t)||A(t),t.locales)}function Le(e,t){const o=$(e)?e.global:e;if(V(o))d.isVue2&&A(e)?e.locale=t:o.locale.value=t;else if(Y(o)||x(o)||A(o))o.locale=t;else throw new Error("TODO:")}function Be(e,t,o){return e.replace(/\/+$/,"")+(t?"/":"")||(o?"":"/")}function ue(e){return m.isVueRouter4,d.isRef(e)?e.value:e}function Re(e){return O(e)?e:xe(e)?e.toString():"(null)"}function fe(e,t,{defaultLocale:o,strategy:n,routesNameSeparator:l,defaultLocaleRouteNameSuffix:a}){let r=Re(e)+(n==="no_prefix"?"":l+t);return t===o&&n==="prefix_and_default"&&(r+=l+a),r}function ge(e,t){return De(e)?e(t):e}function Me(e,t){const o=[];for(const[n,l]of t.entries()){const a=e.find(r=>r.iso.toLowerCase()===l.toLowerCase());if(a){o.push({code:a.code,score:1-n/t.length});break}}for(const[n,l]of t.entries()){const a=l.split("-")[0].toLowerCase(),r=e.find(c=>c.iso.split("-")[0].toLowerCase()===a);if(r){o.push({code:r.code,score:.999-n/t.length});break}}return o}const Xe=Me;function Ge(e,t){return e.score===t.score?t.code.length-e.code.length:t.score-e.score}const ke=Ge;function ze(e,t,{matcher:o=Xe,comparer:n=ke}={}){const l=[];for(const r of e){const{code:c}=r,s=r.iso||c;l.push({code:c,iso:s})}const a=o(l,t);return a.length>1&&a.sort(n),a.length?a[0].code:""}const C={PREFIX:"prefix",PREFIX_EXCEPT_DEFAULT:"prefix_except_default",PREFIX_AND_DEFAULT:"prefix_and_default",NO_PREFIX:"no_prefix"},J="",K=C.PREFIX_EXCEPT_DEFAULT,Z=!1,ee="___",te="default",pe="ltr",_e="";function I(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 qe(e,{locales:t=[],localeCodes:o=[],baseUrl:n=_e}={}){const l=e.install;e.install=(a,...r)=>{Reflect.apply(l,e,[a,...r]);const c=me(e);He(c,{locales:t,localeCodes:o,baseUrl:n}),x(e.global)&&Qe(e.global);const s=a,i=e.mode==="composition"?d.isVue3?s.config.globalProperties.$i18n:e:d.isVue2?e:null;i&&We(i,c),(Ye(r[0])?r[0]:{inject:!0}).inject&&a.mixin({methods:{resolveRoute:I(F),localePath:I(M),localeRoute:I(X),localeLocation:I(oe),switchLocalePath:I(D),getRouteBaseName:I(w),localeHead:I(ne)}})}}function He(e,t){const{locales:o,localeCodes:n,baseUrl:l}=t,a=d.ref(o),r=d.ref(n);e.locales=d.computed(()=>a.value),e.localeCodes=d.computed(()=>r.value),e.__baseUrl=ge(l,{})}function We(e,t){Object.defineProperty(e,"locales",{get(){return t.locales.value}}),Object.defineProperty(e,"localeCodes",{get(){return t.localeCodes.value}}),Object.defineProperty(e,"__baseUrl",{get(){return t.__baseUrl}})}function Qe(e){const t=me(e);Object.defineProperty(e,"locales",{get(){return t.locales.value}}),Object.defineProperty(e,"localeCodes",{get(){return t.localeCodes.value}}),Object.defineProperty(e,"__baseUrl",{get(){return t.__baseUrl}})}function Ye(e){return Q(e)&&"inject"in e&&Ne(e.inject)}function ve(e,{defaultLocale:t=J,strategy:o=K,trailingSlash:n=Z,routesNameSeparator:l=ee,defaultLocaleRouteNameSuffix:a=te,includeUprefixedFallback:r=!1,optionsResolver:c=void 0,locales:s=[]}={}){if(o==="no_prefix")return e;const i=s.map(u=>O(u)?u:u.code);function f(u,L,h=!1,R=!1){if(u.redirect&&(!u.component||!u.file))return[u];let E=null;return c!=null&&(E=c(u,L),E==null)?[u]:L.reduce((_,v)=>{const{name:y}=u;let{path:g}=u;const p=P({},u);y&&(p.name=`${y}${l}${v}`),u.children&&(p.children=u.children.reduce((S,z)=>[...S,...f(z,[v],!0,R)],[]));const b=v===t;if(b&&o==="prefix_and_default")if(h)h&&R&&y&&(p.name+=`${l}${a}`);else{const S=U(P({},p),{path:g});if(y&&(S.name=`${p.name}${l}${a}`),u.children){S.children=[];for(const z of u.children)S.children=S.children.concat(f(z,[v],!0,!0))}_.push(S)}const ae=h&&!g.startsWith("/"),le=!ae&&!(b&&o==="prefix_except_default");return le&&(g=`/${v}${g}`),g&&(g=Be(g,n,ae)),le&&b&&o==="prefix"&&r&&_.push(P({},u)),p.path=g,_.push(p),_},[])}return e.reduce((u,L)=>[...u,...f(L,i||[])],[])}const H=new Map;function Ee(e,t){H.has(e)||H.set(e,t)}function Se(e){var t;return(t=H.get(e))!=null?t:{}}function Je(e,t={}){const{version:o,defaultLocale:n,locales:l,strategy:a,trailingSlash:r,routesNameSeparator:c,defaultLocaleRouteNameSuffix:s,defaultDirection:i,baseUrl:f,routes:u,routeOptionsResolver:L}=et(t),h=he(l),R=h.map(v=>v.code),E=Pe(R,c,s);qe(e,{locales:h,baseUrl:f,localeCodes:R});const k=ve(u,{locales:l,defaultLocale:n,strategy:a,trailingSlash:r,routesNameSeparator:c,defaultLocaleRouteNameSuffix:s,optionsResolver:L});t.routes=k;const _=Ke(t,o);return Ee(_,{defaultLocale:n,localeCodes:R,strategy:a,trailingSlash:r,routesNameSeparator:c,defaultLocaleRouteNameSuffix:s,defaultDirection:i}),_.beforeEach((v,y,g)=>{const p=j(e),b=E(v)||p||n||"";p!==b&&Le(e,b),g()}),_}function Ke(e,t){if(d.isVue3&&t===4)return m.createRouter(e);if(d.isVue2&&t===3)return new ye.default(e);throw new Error("TODO:")}function Ze(e){return new RegExp(`^/(${e.join("|")})(?:/|$)`,"i")}function Pe(e,t,o){const n=`(${e.join("|")})`,l=`(?:${t}${o})?`,a=new RegExp(`${t}${n}${l}$`,"i"),r=Ze(e);return s=>{if(Q(s)){if(s.name){const f=(O(s.name)?s.name:s.name.toString()).match(a);if(f&&f.length>1)return f[1]}else if(s.path){const i=s.path.match(r);if(i&&i.length>1)return i[1]}}else if(O(s)){const i=s.match(r);if(i&&i.length>1)return i[1]}return""}}function et(e){var t,o,n,l,a,r,c,s,i,f;return e.version=(t=e.version)!=null?t:4,e.defaultLocale=(o=e.defaultLocale)!=null?o:J,e.strategy=(n=e.strategy)!=null?n:K,e.trailingSlash=(l=e.trailingSlash)!=null?l:Z,e.routesNameSeparator=(a=e.routesNameSeparator)!=null?a:ee,e.defaultLocaleRouteNameSuffix=(r=e.defaultLocaleRouteNameSuffix)!=null?r:te,e.locales=(c=e.locales)!=null?c:[],e.defaultDirection=(s=e.defaultDirection)!=null?s:pe,e.baseUrl=(i=e.baseUrl)!=null?i:_e,e.routes=(f=e.routes)!=null?f:[],e}function B(e,t,{defaultLocale:o=J,defaultDirection:n=pe,defaultLocaleRouteNameSuffix:l=te,routesNameSeparator:a=ee,strategy:r=K,trailingSlash:c=Z,localeCodes:s=[]}={}){const i=Se(e);return{defaultLocale:t.defaultLocale||i.defaultLocale||o,defaultDirection:t.defaultDirection||i.defaultDirection||n,defaultLocaleRouteNameSuffix:t.defaultLocaleRouteNameSuffix||i.defaultLocaleRouteNameSuffix||l,routesNameSeparator:t.routesNameSeparator||i.routesNameSeparator||a,strategy:t.strategy||i.strategy||r,trailingSlash:t.trailingSlash||i.trailingSlash||c,localeCodes:t.localeCodes||i.localeCodes||s}}const tt=new Set([C.PREFIX_AND_DEFAULT,C.PREFIX_EXCEPT_DEFAULT]);function w(e){const t=this.router,{routesNameSeparator:o}=B(t,this),n=e!=null?d.isRef(e)?d.unref(e):e:this.route;return n.name?Re(n.name).split(o)[0]:void 0}function M(e,t){const o=F.call(this,e,t);return o==null?"":d.isVue3?o.redirectedFrom||o.fullPath:o.route.redirectedFrom||o.route.fullPath}function X(e,t){const o=F.call(this,e,t);return o==null?void 0:d.isVue3?o:o.route}function oe(e,t){const o=F.call(this,e,t);return o==null?void 0:d.isVue3?o:o.location}function F(e,t){const o=this.router,n=this.i18n,l=t||j(n),{routesNameSeparator:a,defaultLocale:r,defaultLocaleRouteNameSuffix:c,strategy:s,trailingSlash:i}=B(o,this);let f=e;O(e)&&(f[0]==="/"?f={path:e}:f={name:e});let u=de({},f);if(u.path&&!u.name){const h=o.resolve(u),R=d.isVue3?h:h.route,E=w.call(this,R);O(E)?u={name:fe(E,l,{defaultLocale:r,strategy:s,routesNameSeparator:a,defaultLocaleRouteNameSuffix:c}),params:R.params,query:R.query,hash:R.hash}:(!(l===r&&tt.has(s))&&s!==C.NO_PREFIX&&(u.path=`/${l}${u.path}`),u.path=i?Ue(u.path,!0):Te(u.path,!0))}else{u.name=fe(u.name,l,{defaultLocale:r,strategy:s,routesNameSeparator:a,defaultLocaleRouteNameSuffix:c});const{params:h}=u;h&&h["0"]===void 0&&h.pathMatch&&(h["0"]=h.pathMatch)}const L=o.resolve(u);return(d.isVue3?L.name:L.route.name)?L:o.resolve(e)}function D(e){const t=this.route,o=w.call(this,t);if(!o)return"";const s=!d.isVue3&&d.isRef(t)?t.value:t,{params:n}=s,l=ie(s,["params"]),a={},r=de({},l,{name:o,params:U(P(P({},n),a),{0:n.pathMatch})});return M.call(this,r,e)}function ne({addDirAttribute:e=!1,addSeoAttributes:t=!1}={}){const o=this.router,n=this.i18n,{defaultDirection:l}=B(o,this),a={htmlAttrs:{},link:[],meta:[]};if(n.locales==null||n.__baseUrl==null)return a;const r=j(n),c=je(n),s=he(c).find(u=>u.code===r)||{code:r},i=s.iso,f=s.dir||l;return e&&(a.htmlAttrs.dir=f),t&&r&&n.locales&&(i&&(a.htmlAttrs.lang=i),ot.call(this,c,n.__baseUrl,a.link),nt.call(this,n.__baseUrl,a.link,t),at(s,i,a.meta),lt(c,i,a.meta)),a}function ot(e,t,o){const n=this.router,{defaultLocale:l,strategy:a}=B(n,this);if(a===C.NO_PREFIX)return;const r=new Map;for(const c of e){const s=c.iso;if(!s){Ve("Locale ISO code is required to generate alternate link");continue}const[i,f]=s.split("-");i&&f&&(c.isCatchallLocale||!r.has(i))&&r.set(i,c),r.set(s,c)}for(const[c,s]of r.entries()){const i=D.call(this,s.code);i&&o.push({hid:`i18n-alt-${c}`,rel:"alternate",href:W(i,t),hreflang:c})}if(l){const c=D.call(this,l);c&&o.push({hid:"i18n-xd",rel:"alternate",href:W(c,t),hreflang:"x-default"})}}function nt(e,t,o){const n=this.route,l=X.call(this,U(P({},n),{name:w.call(this,n)}));if(l){let a=W(l.path,e);const r=Q(o)&&o.canonicalQueries||[];if(r.length){const c=l.query,s=new URLSearchParams;for(const f of r)if(f in c){const u=c[f];Ce(u)?u.forEach(L=>s.append(f,L||"")):s.append(f,u||"")}const i=s.toString();i&&(a=`${a}?${i}`)}t.push({hid:"i18n-can",rel:"canonical",href:a})}}function at(e,t,o){!(e&&t)||o.push({hid:"i18n-og",property:"og:locale",content:Ie(t)})}function lt(e,t,o){const n=e.filter(l=>{const a=l.iso;return a&&a!==t});if(n.length){const l=n.map(a=>({hid:`i18n-og-alt-${a.iso}`,property:"og:locale:alternate",content:Ie(a.iso)}));o.push(...l)}}function Ie(e){return(e||"").replace(/-/g,"_")}function W(e,t){return e.match(/^https?:\/\//)?e:t+e}function G(e,t){const{router:o,route:n,i18n:l,defaultLocale:a,strategy:r,defaultLocaleRouteNameSuffix:c,trailingSlash:s,routesNameSeparator:i}=e;return function(...f){return Reflect.apply(t,{router:o,route:n,i18n:l,defaultLocale:a,strategy:r,defaultLocaleRouteNameSuffix:c,trailingSlash:s,routesNameSeparator:i},f)}}function rt(e=m.useRoute(),{router:t=m.useRouter(),routesNameSeparator:o=void 0}={}){const n={router:t,route:e,routesNameSeparator:o};return w.call(n,e)}function ct({router:e=m.useRouter(),route:t=m.useRoute(),i18n:o=N.useI18n(),defaultLocale:n=void 0,defaultLocaleRouteNameSuffix:l=void 0,routesNameSeparator:a=void 0,strategy:r=void 0,trailingSlash:c=void 0}={}){return G({router:e,route:t,i18n:o,defaultLocale:n,defaultLocaleRouteNameSuffix:l,routesNameSeparator:a,strategy:r,trailingSlash:c},M)}function st({router:e=m.useRouter(),route:t=m.useRoute(),i18n:o=N.useI18n(),defaultLocale:n=void 0,defaultLocaleRouteNameSuffix:l=void 0,routesNameSeparator:a=void 0,strategy:r=void 0,trailingSlash:c=void 0}={}){return G({router:e,route:t,i18n:o,defaultLocale:n,defaultLocaleRouteNameSuffix:l,routesNameSeparator:a,strategy:r,trailingSlash:c},X)}function it({router:e=m.useRouter(),route:t=m.useRoute(),i18n:o=N.useI18n(),defaultLocale:n=void 0,defaultLocaleRouteNameSuffix:l=void 0,routesNameSeparator:a=void 0,strategy:r=void 0,trailingSlash:c=void 0}={}){return G({router:e,route:t,i18n:o,defaultLocale:n,defaultLocaleRouteNameSuffix:l,routesNameSeparator:a,strategy:r,trailingSlash:c},oe)}function ut({router:e=m.useRouter(),route:t=m.useRoute(),i18n:o=N.useI18n(),defaultLocale:n=void 0,defaultLocaleRouteNameSuffix:l=void 0,routesNameSeparator:a=void 0,strategy:r=void 0,trailingSlash:c=void 0}={}){return G({router:e,route:t,i18n:o,defaultLocale:n,defaultLocaleRouteNameSuffix:l,routesNameSeparator:a,strategy:r,trailingSlash:c},D)}function ft({addDirAttribute:e=!1,addSeoAttributes:t=!1,strategy:o=void 0,defaultLocale:n=void 0,route:l=m.useRoute(),router:a=m.useRouter(),i18n:r=N.useI18n()}={}){const c=a,s=d.ref({htmlAttrs:{},link:[],meta:[]});function i(){s.value={htmlAttrs:{},link:[],meta:[]}}function f(u){s.value=Reflect.apply(ne,{router:a,route:u,i18n:r,defaultLocale:n,strategy:o},[{addDirAttribute:e,addSeoAttributes:t}])}if($e)if(d.isVue3){const u=d.watchEffect(()=>{i(),f(ue(c.currentRoute))});d.onUnmounted(()=>u())}else{const u=c.afterEach((L,h)=>{i(),f(L)});d.onUnmounted(()=>u()),f(l)}else f(ue(c.currentRoute));return s}const dt="0.0.0";exports.VERSION=dt;exports.createLocaleFromRouteGetter=Pe;exports.createRouter=Je;exports.findBrowserLocale=ze;exports.getGlobalOptions=Se;exports.getLocale=j;exports.getRouteBaseName=w;exports.localeHead=ne;exports.localeLocation=oe;exports.localePath=M;exports.localeRoute=X;exports.localizeRoutes=ve;exports.registerGlobalOptions=Ee;exports.resolveBaseUrl=ge;exports.resolveRoute=F;exports.setLocale=Le;exports.switchLocalePath=D;exports.useLocaleHead=ft;exports.useLocaleLocation=it;exports.useLocalePath=ct;exports.useLocaleRoute=st;exports.useRouteBaseName=rt;exports.useSwitchLocalePath=ut;

@@ -1,2 +0,2 @@

import { Composer } from '@intlify/vue-i18n-bridge';
import type { Composer } from '@intlify/vue-i18n-bridge';
import type { I18n } from '@intlify/vue-i18n-bridge';

@@ -117,2 +117,10 @@ import type { Locale } from '@intlify/vue-i18n-bridge';

/**
* Get global i18n routing options
*
* @param router - A router instance
* @returns A global options
*/
export declare function getGlobalOptions(router: Router | VueRouter): I18nRoutingGlobalOptions;
/**
* Get a locale

@@ -128,7 +136,6 @@ *

/**
* Options for vue-i18n-routing common
*/
export declare type I18nCommonRoutingOptions = Pick<I18nRoutingOptions, 'defaultLocale' | 'strategy' | 'defaultLocaleRouteNameSuffix' | 'trailingSlash' | 'locales' | 'routesNameSeparator'> & ComposableOptions;
export declare type I18nCommonRoutingOptions = Pick<I18nRoutingOptions, 'defaultLocale' | 'strategy' | 'defaultLocaleRouteNameSuffix' | 'trailingSlash' | 'locales' | 'routesNameSeparator'>;
export declare type I18nCommonRoutingOptionsWithComposable = I18nCommonRoutingOptions & ComposableOptions;
/**

@@ -169,2 +176,9 @@ * I18n header meta info

/**
* 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

@@ -344,2 +358,10 @@ *

/**
* Register global i18n routing options
*
* @param router - A router instance
* @param options - A global options
*/
export declare function registerGlobalOptions<BaseUrl extends BaseUrlResolveHandler = BaseUrlResolveHandler>(router: Router | VueRouter, options: I18nRoutingGlobalOptions<BaseUrl>): void;
/**
* Resolve base url

@@ -397,7 +419,9 @@ *

router: Router | VueRouter;
__defaultLocale: string;
__strategy: Strategies;
__defaultLocaleRouteNameSuffix: string;
__trailingSlash: boolean;
__routesNameSeparator: string;
defaultLocale?: string;
localeCodes?: string[];
strategy?: Strategies;
defaultDirection?: Directions;
defaultLocaleRouteNameSuffix?: string;
trailingSlash?: boolean;
routesNameSeparator?: string;
};

@@ -467,3 +491,3 @@

*/
export declare function useLocaleHead({ addDirAttribute, addSeoAttributes, strategy, defaultLocale, route, router, i18n }?: Pick<I18nCommonRoutingOptions, '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>;

@@ -477,3 +501,3 @@ /**

*/
export declare function useLocaleLocation({ router, route, i18n, defaultLocale, defaultLocaleRouteNameSuffix, routesNameSeparator, strategy, trailingSlash }?: I18nCommonRoutingOptions): LocaleLocationFunction;
export declare function useLocaleLocation({ router, route, i18n, defaultLocale, defaultLocaleRouteNameSuffix, routesNameSeparator, strategy, trailingSlash }?: I18nCommonRoutingOptionsWithComposable): LocaleLocationFunction;

@@ -487,3 +511,3 @@ /**

*/
export declare function useLocalePath({ router, route, i18n, defaultLocale, defaultLocaleRouteNameSuffix, routesNameSeparator, strategy, trailingSlash }?: I18nCommonRoutingOptions): LocalePathFunction;
export declare function useLocalePath({ router, route, i18n, defaultLocale, defaultLocaleRouteNameSuffix, routesNameSeparator, strategy, trailingSlash }?: I18nCommonRoutingOptionsWithComposable): LocalePathFunction;

@@ -497,3 +521,3 @@ /**

*/
export declare function useLocaleRoute({ router, route, i18n, defaultLocale, defaultLocaleRouteNameSuffix, routesNameSeparator, strategy, trailingSlash }?: I18nCommonRoutingOptions): LocaleRouteFunction;
export declare function useLocaleRoute({ router, route, i18n, defaultLocale, defaultLocaleRouteNameSuffix, routesNameSeparator, strategy, trailingSlash }?: I18nCommonRoutingOptionsWithComposable): LocaleRouteFunction;

@@ -508,3 +532,3 @@ /**

*/
export declare function useRouteBaseName(givenRoute?: Route_2 | RouteLocationNormalizedLoaded, { router, routesNameSeparator }?: I18nCommonRoutingOptions): string | undefined;
export declare function useRouteBaseName(givenRoute?: Route_2 | RouteLocationNormalizedLoaded, { router, routesNameSeparator }?: I18nCommonRoutingOptionsWithComposable): string | undefined;

@@ -518,3 +542,3 @@ /**

*/
export declare function useSwitchLocalePath({ router, route, i18n, defaultLocale, defaultLocaleRouteNameSuffix, routesNameSeparator, strategy, trailingSlash }?: I18nCommonRoutingOptions): SwitchLocalePathFunction;
export declare function useSwitchLocalePath({ router, route, i18n, defaultLocale, defaultLocaleRouteNameSuffix, routesNameSeparator, strategy, trailingSlash }?: I18nCommonRoutingOptionsWithComposable): SwitchLocalePathFunction;

@@ -529,67 +553,43 @@ /**

export { }
import type { ComputedRef } from 'vue-demi'
// 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
// }
// }
declare module 'vue-i18n-bridge' {
export interface VueI18n {
locales: string[] | LocaleObject[]
localeCodes: string[]
__baseUrl: string
}
export interface ComposerCustom {
/**
* An options of Vue I18n Routing Plugin
*/
export declare interface VueI18nRoutingPluginOptions {
/**
* List of locales
* Whether to inject some option APIs style methods into Vue instance
*
* @defaultValue `undefined`
* @defaultValue `true`
*/
locales?: ComputedRef<string[] | LocaleObject[]>
/**
* List of locale codes
*
* @defaultValue `undefined`
*/
localeCodes?: ComputedRef<string[]>
__baseUrl?: string
}
inject?: boolean;
}
declare module '@intlify/vue-i18n-bridge' {
export interface VueI18n {
locales: string[] | LocaleObject[]
localeCodes: string[]
__baseUrl: string
}
export { }
import type { ComputedRef } from 'vue-demi'
export interface ComposerCustom {
/**
* List of locales
*
* @defaultValue `[]`
*/
locales: ComputedRef<string[] | LocaleObject[]>
/**
* List of locale codes
*
* @defaultValue `[]`
*/
localeCodes: ComputedRef<string[]>
__baseUrl: string
}
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' {
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface ComposerCustom extends ComposerCustomProperties {}
}
declare module 'vue-i18n-bridge' {
// 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 {}
}

@@ -32,4 +32,4 @@ var __defProp = Object.defineProperty;

};
import { isRef, isVue2, unref, isVue3, ref, watchEffect, onUnmounted, computed } from "vue-demi";
import VueRouter3, { isVueRouter4, useRoute, useRouter, createRouter as createRouter$1 } from "@intlify/vue-router-bridge";
import { isRef, isVue2, isVue3, ref, computed, unref, watchEffect, onUnmounted } from "vue-demi";
import VueRouter3, { isVueRouter4, createRouter as createRouter$1, useRoute, useRouter } from "@intlify/vue-router-bridge";
import { useI18n } from "@intlify/vue-i18n-bridge";

@@ -45,2 +45,3 @@ /*!

const isString = (val) => typeof val === "string";
const isBoolean = (val) => typeof val === "boolean";
const isSymbol = (val) => typeof val === "symbol";

@@ -216,6 +217,303 @@ const isObject = (val) => val !== null && typeof val === "object";

const DEFAULT_BASE_URL = "";
function proxyVueInstance(target) {
return function() {
return Reflect.apply(target, {
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 extendI18n(i18n, { locales = [], localeCodes = [], baseUrl = DEFAULT_BASE_URL } = {}) {
const orgInstall = i18n.install;
i18n.install = (vue, ...options) => {
Reflect.apply(orgInstall, i18n, [vue, ...options]);
const composer = getComposer(i18n);
extendComposer(composer, { locales, localeCodes, baseUrl });
if (isVueI18n(i18n.global)) {
extendVueI18n(i18n.global);
}
const app = vue;
const exported = i18n.mode === "composition" ? isVue3 ? app.config.globalProperties.$i18n : i18n : isVue2 ? i18n : null;
if (exported) {
extendExportedGlobal(exported, composer);
}
const pluginOptions = isPluginOptions(options[0]) ? options[0] : { inject: true };
if (pluginOptions.inject) {
vue.mixin({
methods: {
resolveRoute: proxyVueInstance(resolveRoute),
localePath: proxyVueInstance(localePath),
localeRoute: proxyVueInstance(localeRoute),
localeLocation: proxyVueInstance(localeLocation),
switchLocalePath: proxyVueInstance(switchLocalePath),
getRouteBaseName: proxyVueInstance(getRouteBaseName),
localeHead: proxyVueInstance(localeHead)
}
});
}
};
}
function extendComposer(composer, options) {
const { locales, localeCodes, baseUrl } = options;
const _locales = ref(locales);
const _localeCodes = ref(localeCodes);
composer.locales = computed(() => _locales.value);
composer.localeCodes = computed(() => _localeCodes.value);
composer.__baseUrl = resolveBaseUrl(baseUrl, {});
}
function extendExportedGlobal(exported, global) {
Object.defineProperty(exported, "locales", {
get() {
return global.locales.value;
}
});
Object.defineProperty(exported, "localeCodes", {
get() {
return global.localeCodes.value;
}
});
Object.defineProperty(exported, "__baseUrl", {
get() {
return global.__baseUrl;
}
});
}
function extendVueI18n(vueI18n) {
const composer = getComposer(vueI18n);
Object.defineProperty(vueI18n, "locales", {
get() {
return composer.locales.value;
}
});
Object.defineProperty(vueI18n, "localeCodes", {
get() {
return composer.localeCodes.value;
}
});
Object.defineProperty(vueI18n, "__baseUrl", {
get() {
return composer.__baseUrl;
}
});
}
function isPluginOptions(options) {
return isObject(options) && "inject" in options && isBoolean(options.inject);
}
function localizeRoutes(routes, {
defaultLocale = DEFAULT_LOCALE,
strategy = DEFAULT_STRATEGY,
trailingSlash = DEFAULT_TRAILING_SLASH,
routesNameSeparator = DEFAULT_ROUTES_NAME_SEPARATOR,
defaultLocaleRouteNameSuffix = DEFAULT_LOCALE_ROUTE_NAME_SUFFIX,
includeUprefixedFallback = false,
optionsResolver = void 0,
locales = []
} = {}) {
if (strategy === "no_prefix") {
return routes;
}
const _localeCodes = locales.map((locale) => isString(locale) ? locale : locale.code);
function makeLocalizedRoutes(route, allowedLocaleCodes, isChild = false, isExtraPageTree = false) {
if (route.redirect && (!route.component || !route.file)) {
return [route];
}
let routeOptions = null;
if (optionsResolver != null) {
routeOptions = optionsResolver(route, allowedLocaleCodes);
if (routeOptions == null) {
return [route];
}
}
const targetLocales = allowedLocaleCodes;
return targetLocales.reduce((_routes, locale) => {
const { name } = route;
let { path } = route;
const localizedRoute = __spreadValues({}, route);
if (name) {
localizedRoute.name = `${name}${routesNameSeparator}${locale}`;
}
if (route.children) {
localizedRoute.children = route.children.reduce((children, child) => [...children, ...makeLocalizedRoutes(child, [locale], true, isExtraPageTree)], []);
}
const isDefaultLocale = locale === defaultLocale;
if (isDefaultLocale && strategy === "prefix_and_default") {
if (!isChild) {
const defaultRoute = __spreadProps(__spreadValues({}, localizedRoute), { path });
if (name) {
defaultRoute.name = `${localizedRoute.name}${routesNameSeparator}${defaultLocaleRouteNameSuffix}`;
}
if (route.children) {
defaultRoute.children = [];
for (const childRoute of route.children) {
defaultRoute.children = defaultRoute.children.concat(makeLocalizedRoutes(childRoute, [locale], true, true));
}
}
_routes.push(defaultRoute);
} else if (isChild && isExtraPageTree && name) {
localizedRoute.name += `${routesNameSeparator}${defaultLocaleRouteNameSuffix}`;
}
}
const isChildWithRelativePath = isChild && !path.startsWith("/");
const shouldAddPrefix = !isChildWithRelativePath && !(isDefaultLocale && strategy === "prefix_except_default");
if (shouldAddPrefix) {
path = `/${locale}${path}`;
}
if (path) {
path = adjustRoutePathForTrailingSlash(path, trailingSlash, isChildWithRelativePath);
}
if (shouldAddPrefix && isDefaultLocale && strategy === "prefix" && includeUprefixedFallback) {
_routes.push(__spreadValues({}, route));
}
localizedRoute.path = path;
_routes.push(localizedRoute);
return _routes;
}, []);
}
return routes.reduce((localized, route) => [...localized, ...makeLocalizedRoutes(route, _localeCodes || [])], []);
}
const optionsMap = /* @__PURE__ */ new Map();
function registerGlobalOptions(router, options) {
if (!optionsMap.has(router)) {
optionsMap.set(router, options);
}
}
function getGlobalOptions(router) {
var _a;
return (_a = optionsMap.get(router)) != null ? _a : {};
}
function createRouter(i18n, options = {}) {
const {
version,
defaultLocale,
locales,
strategy,
trailingSlash,
routesNameSeparator,
defaultLocaleRouteNameSuffix,
defaultDirection,
baseUrl,
routes,
routeOptionsResolver: optionsResolver
} = asDefaultVueI18nRouterOptions(options);
const normalizedLocaleCodes = getNormalizedLocales(locales);
const localeCodes = normalizedLocaleCodes.map((l) => l.code);
const getLocaleFromRoute = createLocaleFromRouteGetter(localeCodes, routesNameSeparator, defaultLocaleRouteNameSuffix);
extendI18n(i18n, { locales: normalizedLocaleCodes, baseUrl, localeCodes });
const localizedRoutes = localizeRoutes(routes, {
locales,
defaultLocale,
strategy,
trailingSlash,
routesNameSeparator,
defaultLocaleRouteNameSuffix,
optionsResolver
});
options.routes = localizedRoutes;
const router = createVueRouter(options, version);
registerGlobalOptions(router, {
defaultLocale,
localeCodes,
strategy,
trailingSlash,
routesNameSeparator,
defaultLocaleRouteNameSuffix,
defaultDirection
});
router.beforeEach((to, from, next) => {
const currentLocale = getLocale(i18n);
const finalLocale = getLocaleFromRoute(to) || currentLocale || defaultLocale || "";
if (currentLocale !== finalLocale) {
setLocale(i18n, finalLocale);
}
next();
});
return router;
}
function createVueRouter(options, version) {
if (isVue3 && version === 4) {
return createRouter$1(options);
} else if (isVue2 && version === 3) {
return new VueRouter3(options);
} else {
throw new Error("TODO:");
}
}
function getLocalesRegex(localeCodes) {
return new RegExp(`^/(${localeCodes.join("|")})(?:/|$)`, "i");
}
function createLocaleFromRouteGetter(localeCodes, routesNameSeparator, defaultLocaleRouteNameSuffix) {
const localesPattern = `(${localeCodes.join("|")})`;
const defaultSuffixPattern = `(?:${routesNameSeparator}${defaultLocaleRouteNameSuffix})?`;
const regexpName = new RegExp(`${routesNameSeparator}${localesPattern}${defaultSuffixPattern}$`, "i");
const regexpPath = getLocalesRegex(localeCodes);
const getLocaleFromRoute = (route) => {
if (isObject(route)) {
if (route.name) {
const name = isString(route.name) ? route.name : route.name.toString();
const matches = name.match(regexpName);
if (matches && matches.length > 1) {
return matches[1];
}
} else if (route.path) {
const matches = route.path.match(regexpPath);
if (matches && matches.length > 1) {
return matches[1];
}
}
} else if (isString(route)) {
const matches = route.match(regexpPath);
if (matches && matches.length > 1) {
return matches[1];
}
}
return "";
};
return getLocaleFromRoute;
}
function asDefaultVueI18nRouterOptions(options) {
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
options.version = (_a = options.version) != null ? _a : 4;
options.defaultLocale = (_b = options.defaultLocale) != null ? _b : DEFAULT_LOCALE;
options.strategy = (_c = options.strategy) != null ? _c : DEFAULT_STRATEGY;
options.trailingSlash = (_d = options.trailingSlash) != null ? _d : DEFAULT_TRAILING_SLASH;
options.routesNameSeparator = (_e = options.routesNameSeparator) != null ? _e : DEFAULT_ROUTES_NAME_SEPARATOR;
options.defaultLocaleRouteNameSuffix = (_f = options.defaultLocaleRouteNameSuffix) != null ? _f : DEFAULT_LOCALE_ROUTE_NAME_SUFFIX;
options.locales = (_g = options.locales) != null ? _g : [];
options.defaultDirection = (_h = options.defaultDirection) != null ? _h : DEFAULT_DETECTION_DIRECTION;
options.baseUrl = (_i = options.baseUrl) != null ? _i : DEFAULT_BASE_URL;
options.routes = (_j = options.routes) != null ? _j : [];
return options;
}
function getI18nRoutingOptions(router, proxy, {
defaultLocale = DEFAULT_LOCALE,
defaultDirection = DEFAULT_DETECTION_DIRECTION,
defaultLocaleRouteNameSuffix = DEFAULT_LOCALE_ROUTE_NAME_SUFFIX,
routesNameSeparator = DEFAULT_ROUTES_NAME_SEPARATOR,
strategy = DEFAULT_STRATEGY,
trailingSlash = DEFAULT_TRAILING_SLASH,
localeCodes = []
} = {}) {
const options = getGlobalOptions(router);
return {
defaultLocale: proxy.defaultLocale || options.defaultLocale || defaultLocale,
defaultDirection: proxy.defaultDirection || options.defaultDirection || defaultDirection,
defaultLocaleRouteNameSuffix: proxy.defaultLocaleRouteNameSuffix || options.defaultLocaleRouteNameSuffix || defaultLocaleRouteNameSuffix,
routesNameSeparator: proxy.routesNameSeparator || options.routesNameSeparator || routesNameSeparator,
strategy: proxy.strategy || options.strategy || strategy,
trailingSlash: proxy.trailingSlash || options.trailingSlash || trailingSlash,
localeCodes: proxy.localeCodes || options.localeCodes || localeCodes
};
}
const RESOLVED_PREFIXED = /* @__PURE__ */ new Set([STRATEGIES.PREFIX_AND_DEFAULT, STRATEGIES.PREFIX_EXCEPT_DEFAULT]);
function getRouteBaseName(givenRoute) {
const router = this.router;
const routesNameSeparator = router.__routesNameSeparator || this.__routesNameSeparator || DEFAULT_ROUTES_NAME_SEPARATOR;
const { routesNameSeparator } = getI18nRoutingOptions(router, this);
const route = givenRoute != null ? isRef(givenRoute) ? unref(givenRoute) : givenRoute : this.route;

@@ -244,8 +542,3 @@ if (!route.name) {

const _locale = locale || getLocale(i18n);
const defaultLocale = this.__defaultLocale || DEFAULT_LOCALE;
const _defaultLocale = router.__defaultLocale || defaultLocale;
const _defaultLocaleRouteNameSuffix = router.__defaultLocaleRouteNameSuffix || this.__defaultLocaleRouteNameSuffix || DEFAULT_LOCALE_ROUTE_NAME_SUFFIX;
const _routesNameSeparator = router.__routesNameSeparator || this.__routesNameSeparator || DEFAULT_ROUTES_NAME_SEPARATOR;
const _strategy = router.__strategy || this.__strategy || DEFAULT_STRATEGY;
const trailingSlash = router.__trailingSlash || this.__trailingSlash || false;
const { routesNameSeparator, defaultLocale, defaultLocaleRouteNameSuffix, strategy, trailingSlash } = getI18nRoutingOptions(router, this);
let _route = route;

@@ -267,6 +560,6 @@ if (isString(route)) {

name: getLocaleRouteName(resolvedRouteName, _locale, {
defaultLocale: _defaultLocale,
strategy: _strategy,
routesNameSeparator: _routesNameSeparator,
defaultLocaleRouteNameSuffix: _defaultLocaleRouteNameSuffix
defaultLocale,
strategy,
routesNameSeparator,
defaultLocaleRouteNameSuffix
}),

@@ -279,3 +572,3 @@ params: resolvedRoute2.params,

const isDefaultLocale = _locale === defaultLocale;
const isPrefixed = !(isDefaultLocale && RESOLVED_PREFIXED.has(_strategy)) && !(_strategy === STRATEGIES.NO_PREFIX);
const isPrefixed = !(isDefaultLocale && RESOLVED_PREFIXED.has(strategy)) && !(strategy === STRATEGIES.NO_PREFIX);
if (isPrefixed) {

@@ -288,6 +581,6 @@ localizedRoute.path = `/${_locale}${localizedRoute.path}`;

localizedRoute.name = getLocaleRouteName(localizedRoute.name, _locale, {
defaultLocale: _defaultLocale,
strategy: _strategy,
routesNameSeparator: _routesNameSeparator,
defaultLocaleRouteNameSuffix: _defaultLocaleRouteNameSuffix
defaultLocale,
strategy,
routesNameSeparator,
defaultLocaleRouteNameSuffix
});

@@ -325,2 +618,3 @@ const { params } = localizedRoute;

const i18n = this.i18n;
const { defaultDirection } = getI18nRoutingOptions(router, this);
const metaObject = {

@@ -340,3 +634,3 @@ htmlAttrs: {},

const currentLocaleIso = currentLocale.iso;
const currentLocaleDir = currentLocale.dir || router.__defaultDirection;
const currentLocaleDir = currentLocale.dir || defaultDirection;
if (addDirAttribute) {

@@ -358,4 +652,3 @@ metaObject.htmlAttrs.dir = currentLocaleDir;

const router = this.router;
const defaultLocale = router.__defaultLocale || this.__defaultLocale;
const strategy = router.__strategy || this.__strategy;
const { defaultLocale, strategy } = getI18nRoutingOptions(router, this);
if (strategy === STRATEGIES.NO_PREFIX) {

@@ -472,7 +765,7 @@ return;

i18n,
defaultLocale: __defaultLocale,
strategy: __strategy,
defaultLocaleRouteNameSuffix: __defaultLocaleRouteNameSuffix,
trailingSlash: __trailingSlash,
routesNameSeparator: __routesNameSeparator
defaultLocale,
strategy,
defaultLocaleRouteNameSuffix,
trailingSlash,
routesNameSeparator
} = options;

@@ -484,15 +777,15 @@ return function(...args) {

i18n,
__defaultLocale,
__strategy,
__defaultLocaleRouteNameSuffix,
__trailingSlash,
__routesNameSeparator
defaultLocale,
strategy,
defaultLocaleRouteNameSuffix,
trailingSlash,
routesNameSeparator
}, args);
};
}
function useRouteBaseName(givenRoute = useRoute(), { router = useRouter(), routesNameSeparator = DEFAULT_ROUTES_NAME_SEPARATOR } = {}) {
function useRouteBaseName(givenRoute = useRoute(), { router = useRouter(), routesNameSeparator = void 0 } = {}) {
const proxy = {
router,
route: givenRoute,
__routesNameSeparator: routesNameSeparator
routesNameSeparator
};

@@ -505,7 +798,7 @@ return getRouteBaseName.call(proxy, givenRoute);

i18n = useI18n(),
defaultLocale = DEFAULT_LOCALE,
defaultLocaleRouteNameSuffix = DEFAULT_LOCALE_ROUTE_NAME_SUFFIX,
routesNameSeparator = DEFAULT_ROUTES_NAME_SEPARATOR,
strategy = DEFAULT_STRATEGY,
trailingSlash = false
defaultLocale = void 0,
defaultLocaleRouteNameSuffix = void 0,
routesNameSeparator = void 0,
strategy = void 0,
trailingSlash = void 0
} = {}) {

@@ -518,7 +811,7 @@ return proxyForComposable({ router, route, i18n, defaultLocale, defaultLocaleRouteNameSuffix, routesNameSeparator, strategy, trailingSlash }, localePath);

i18n = useI18n(),
defaultLocale = DEFAULT_LOCALE,
defaultLocaleRouteNameSuffix = DEFAULT_LOCALE_ROUTE_NAME_SUFFIX,
routesNameSeparator = DEFAULT_ROUTES_NAME_SEPARATOR,
strategy = DEFAULT_STRATEGY,
trailingSlash = false
defaultLocale = void 0,
defaultLocaleRouteNameSuffix = void 0,
routesNameSeparator = void 0,
strategy = void 0,
trailingSlash = void 0
} = {}) {

@@ -540,7 +833,7 @@ return proxyForComposable({

i18n = useI18n(),
defaultLocale = DEFAULT_LOCALE,
defaultLocaleRouteNameSuffix = DEFAULT_LOCALE_ROUTE_NAME_SUFFIX,
routesNameSeparator = DEFAULT_ROUTES_NAME_SEPARATOR,
strategy = DEFAULT_STRATEGY,
trailingSlash = false
defaultLocale = void 0,
defaultLocaleRouteNameSuffix = void 0,
routesNameSeparator = void 0,
strategy = void 0,
trailingSlash = void 0
} = {}) {

@@ -562,7 +855,7 @@ return proxyForComposable({

i18n = useI18n(),
defaultLocale = DEFAULT_LOCALE,
defaultLocaleRouteNameSuffix = DEFAULT_LOCALE_ROUTE_NAME_SUFFIX,
routesNameSeparator = DEFAULT_ROUTES_NAME_SEPARATOR,
strategy = DEFAULT_STRATEGY,
trailingSlash = false
defaultLocale = void 0,
defaultLocaleRouteNameSuffix = void 0,
routesNameSeparator = void 0,
strategy = void 0,
trailingSlash = void 0
} = {}) {

@@ -583,4 +876,4 @@ return proxyForComposable({

addSeoAttributes = false,
strategy = DEFAULT_STRATEGY,
defaultLocale = DEFAULT_LOCALE,
strategy = void 0,
defaultLocale = void 0,
route = useRoute(),

@@ -608,4 +901,4 @@ router = useRouter(),

i18n,
__defaultLocale: defaultLocale,
__strategy: strategy
defaultLocale,
strategy
}, [{ addDirAttribute, addSeoAttributes }]);

@@ -633,262 +926,3 @@ }

}
function localizeRoutes(routes, {
defaultLocale = DEFAULT_LOCALE,
strategy = DEFAULT_STRATEGY,
trailingSlash = DEFAULT_TRAILING_SLASH,
routesNameSeparator = DEFAULT_ROUTES_NAME_SEPARATOR,
defaultLocaleRouteNameSuffix = DEFAULT_LOCALE_ROUTE_NAME_SUFFIX,
includeUprefixedFallback = false,
optionsResolver = void 0,
locales = []
} = {}) {
if (strategy === "no_prefix") {
return routes;
}
const _localeCodes = locales.map((locale) => isString(locale) ? locale : locale.code);
function makeLocalizedRoutes(route, allowedLocaleCodes, isChild = false, isExtraPageTree = false) {
if (route.redirect && (!route.component || !route.file)) {
return [route];
}
let routeOptions = null;
if (optionsResolver != null) {
routeOptions = optionsResolver(route, allowedLocaleCodes);
if (routeOptions == null) {
return [route];
}
}
const targetLocales = allowedLocaleCodes;
return targetLocales.reduce((_routes, locale) => {
const { name } = route;
let { path } = route;
const localizedRoute = __spreadValues({}, route);
if (name) {
localizedRoute.name = `${name}${routesNameSeparator}${locale}`;
}
if (route.children) {
localizedRoute.children = route.children.reduce((children, child) => [...children, ...makeLocalizedRoutes(child, [locale], true, isExtraPageTree)], []);
}
const isDefaultLocale = locale === defaultLocale;
if (isDefaultLocale && strategy === "prefix_and_default") {
if (!isChild) {
const defaultRoute = __spreadProps(__spreadValues({}, localizedRoute), { path });
if (name) {
defaultRoute.name = `${localizedRoute.name}${routesNameSeparator}${defaultLocaleRouteNameSuffix}`;
}
if (route.children) {
defaultRoute.children = [];
for (const childRoute of route.children) {
defaultRoute.children = defaultRoute.children.concat(makeLocalizedRoutes(childRoute, [locale], true, true));
}
}
_routes.push(defaultRoute);
} else if (isChild && isExtraPageTree && name) {
localizedRoute.name += `${routesNameSeparator}${defaultLocaleRouteNameSuffix}`;
}
}
const isChildWithRelativePath = isChild && !path.startsWith("/");
const shouldAddPrefix = !isChildWithRelativePath && !(isDefaultLocale && strategy === "prefix_except_default");
if (shouldAddPrefix) {
path = `/${locale}${path}`;
}
if (path) {
path = adjustRoutePathForTrailingSlash(path, trailingSlash, isChildWithRelativePath);
}
if (shouldAddPrefix && isDefaultLocale && strategy === "prefix" && includeUprefixedFallback) {
_routes.push(__spreadValues({}, route));
}
localizedRoute.path = path;
_routes.push(localizedRoute);
return _routes;
}, []);
}
return routes.reduce((localized, route) => [...localized, ...makeLocalizedRoutes(route, _localeCodes || [])], []);
}
function proxyVueInstance(target) {
return function() {
return Reflect.apply(target, {
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 extendI18n(i18n, { locales = [], localeCodes = [], baseUrl = DEFAULT_BASE_URL } = {}) {
const orgInstall = i18n.install;
i18n.install = (vue, ...options) => {
Reflect.apply(orgInstall, i18n, [vue, ...options]);
const composer = getComposer(i18n);
extendComposer(composer, { locales, localeCodes, baseUrl });
if (isVueI18n(i18n.global)) {
extendVueI18n(i18n.global);
}
const app = vue;
const exported = i18n.mode === "composition" ? isVue3 ? app.config.globalProperties.$i18n : i18n : isVue2 ? i18n : null;
if (exported) {
extendExportedGlobal(exported, composer);
}
vue.mixin({
methods: {
resolveRoute: proxyVueInstance(resolveRoute),
localePath: proxyVueInstance(localePath),
localeRoute: proxyVueInstance(localeRoute),
localeLocation: proxyVueInstance(localeLocation),
switchLocalePath: proxyVueInstance(switchLocalePath),
getRouteBaseName: proxyVueInstance(getRouteBaseName),
localeHead: proxyVueInstance(localeHead)
}
});
};
}
function extendComposer(composer, options) {
const { locales, localeCodes, baseUrl } = options;
const _locales = ref(locales);
const _localeCodes = ref(localeCodes);
composer.locales = computed(() => _locales.value);
composer.localeCodes = computed(() => _localeCodes.value);
composer.__baseUrl = resolveBaseUrl(baseUrl, {});
}
function extendExportedGlobal(exported, global) {
Object.defineProperty(exported, "locales", {
get() {
return global.locales.value;
}
});
Object.defineProperty(exported, "localeCodes", {
get() {
return global.localeCodes.value;
}
});
Object.defineProperty(exported, "__baseUrl", {
get() {
return global.__baseUrl;
}
});
}
function extendVueI18n(vueI18n) {
const composer = getComposer(vueI18n);
Object.defineProperty(vueI18n, "locales", {
get() {
return composer.locales.value;
}
});
Object.defineProperty(vueI18n, "localeCodes", {
get() {
return composer.localeCodes.value;
}
});
Object.defineProperty(vueI18n, "__baseUrl", {
get() {
return composer.__baseUrl;
}
});
}
function createRouter(i18n, options = {}) {
const {
version,
defaultLocale,
locales,
strategy,
trailingSlash,
routesNameSeparator,
defaultLocaleRouteNameSuffix,
defaultDirection,
baseUrl,
routes,
routeOptionsResolver: optionsResolver
} = asDefaultVueI18nRouterOptions(options);
const normalizedLocaleCodes = getNormalizedLocales(locales);
const localeCodes = normalizedLocaleCodes.map((l) => l.code);
const getLocaleFromRoute = createLocaleFromRouteGetter(localeCodes, routesNameSeparator, defaultLocaleRouteNameSuffix);
extendI18n(i18n, { locales: normalizedLocaleCodes, baseUrl, localeCodes });
const localizedRoutes = localizeRoutes(routes, {
locales,
defaultLocale,
strategy,
trailingSlash,
routesNameSeparator,
defaultLocaleRouteNameSuffix,
optionsResolver
});
options.routes = localizedRoutes;
const router = createVueRouter(options, version);
router.__defaultLocale = defaultLocale;
router.__localeCodes = localeCodes;
router.__strategy = strategy;
router.__trailingSlash = trailingSlash;
router.__routesNameSeparator = routesNameSeparator;
router.__defaultLocaleRouteNameSuffix = defaultLocaleRouteNameSuffix;
router.__defaultDirection = defaultDirection;
router.beforeEach((to, from, next) => {
const currentLocale = getLocale(i18n);
const finalLocale = getLocaleFromRoute(to) || currentLocale || defaultLocale || "";
if (currentLocale !== finalLocale) {
setLocale(i18n, finalLocale);
}
next();
});
return router;
}
function createVueRouter(options, version) {
if (isVue3 && version === 4) {
return createRouter$1(options);
} else if (isVue2 && version === 3) {
return new VueRouter3(options);
} else {
throw new Error("TODO:");
}
}
function getLocalesRegex(localeCodes) {
return new RegExp(`^/(${localeCodes.join("|")})(?:/|$)`, "i");
}
function createLocaleFromRouteGetter(localeCodes, routesNameSeparator, defaultLocaleRouteNameSuffix) {
const localesPattern = `(${localeCodes.join("|")})`;
const defaultSuffixPattern = `(?:${routesNameSeparator}${defaultLocaleRouteNameSuffix})?`;
const regexpName = new RegExp(`${routesNameSeparator}${localesPattern}${defaultSuffixPattern}$`, "i");
const regexpPath = getLocalesRegex(localeCodes);
const getLocaleFromRoute = (route) => {
if (isObject(route)) {
if (route.name) {
const name = isString(route.name) ? route.name : route.name.toString();
const matches = name.match(regexpName);
if (matches && matches.length > 1) {
return matches[1];
}
} else if (route.path) {
const matches = route.path.match(regexpPath);
if (matches && matches.length > 1) {
return matches[1];
}
}
} else if (isString(route)) {
const matches = route.match(regexpPath);
if (matches && matches.length > 1) {
return matches[1];
}
}
return "";
};
return getLocaleFromRoute;
}
function asDefaultVueI18nRouterOptions(options) {
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
options.version = (_a = options.version) != null ? _a : 4;
options.defaultLocale = (_b = options.defaultLocale) != null ? _b : DEFAULT_LOCALE;
options.strategy = (_c = options.strategy) != null ? _c : DEFAULT_STRATEGY;
options.trailingSlash = (_d = options.trailingSlash) != null ? _d : DEFAULT_TRAILING_SLASH;
options.routesNameSeparator = (_e = options.routesNameSeparator) != null ? _e : DEFAULT_ROUTES_NAME_SEPARATOR;
options.defaultLocaleRouteNameSuffix = (_f = options.defaultLocaleRouteNameSuffix) != null ? _f : DEFAULT_LOCALE_ROUTE_NAME_SUFFIX;
options.locales = (_g = options.locales) != null ? _g : [];
options.defaultDirection = (_h = options.defaultDirection) != null ? _h : DEFAULT_DETECTION_DIRECTION;
options.baseUrl = (_i = options.baseUrl) != null ? _i : DEFAULT_BASE_URL;
options.routes = (_j = options.routes) != null ? _j : [];
return options;
}
const VERSION = "0.0.0";
export { VERSION, createLocaleFromRouteGetter, createRouter, findBrowserLocale, getLocale, getRouteBaseName, localeHead, localeLocation, localePath, localeRoute, localizeRoutes, resolveBaseUrl, resolveRoute, setLocale, switchLocalePath, useLocaleHead, useLocaleLocation, useLocalePath, useLocaleRoute, useRouteBaseName, useSwitchLocalePath };
export { VERSION, createLocaleFromRouteGetter, createRouter, findBrowserLocale, getGlobalOptions, getLocale, getRouteBaseName, localeHead, localeLocation, localePath, localeRoute, localizeRoutes, registerGlobalOptions, resolveBaseUrl, resolveRoute, setLocale, switchLocalePath, useLocaleHead, useLocaleLocation, useLocalePath, useLocaleRoute, useRouteBaseName, useSwitchLocalePath };

@@ -1,5 +0,5 @@

var nt=Object.defineProperty,ct=Object.defineProperties;var rt=Object.getOwnPropertyDescriptors;var W=Object.getOwnPropertySymbols;var Re=Object.prototype.hasOwnProperty,pe=Object.prototype.propertyIsEnumerable;var ge=(i,u,d)=>u in i?nt(i,u,{enumerable:!0,configurable:!0,writable:!0,value:d}):i[u]=d,U=(i,u)=>{for(var d in u||(u={}))Re.call(u,d)&&ge(i,d,u[d]);if(W)for(var d of W(u))pe.call(u,d)&&ge(i,d,u[d]);return i},Q=(i,u)=>ct(i,rt(u));var Se=(i,u)=>{var d={};for(var m in i)Re.call(i,m)&&u.indexOf(m)<0&&(d[m]=i[m]);if(i!=null&&W)for(var m of W(i))u.indexOf(m)<0&&pe.call(i,m)&&(d[m]=i[m]);return d};var VueI18nRouting=function(i,u,d,m){"use strict";function Ee(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var Pe=Ee(d);/*!
var ft=Object.defineProperty,dt=Object.defineProperties;var ht=Object.getOwnPropertyDescriptors;var z=Object.getOwnPropertySymbols;var Oe=Object.prototype.hasOwnProperty,Ae=Object.prototype.propertyIsEnumerable;var Pe=(d,f,L)=>f in d?ft(d,f,{enumerable:!0,configurable:!0,writable:!0,value:L}):d[f]=L,C=(d,f)=>{for(var L in f||(f={}))Oe.call(f,L)&&Pe(d,L,f[L]);if(z)for(var L of z(f))Ae.call(f,L)&&Pe(d,L,f[L]);return d},x=(d,f)=>dt(d,ht(f));var Ie=(d,f)=>{var L={};for(var R in d)Oe.call(d,R)&&f.indexOf(R)<0&&(L[R]=d[R]);if(d!=null&&z)for(var R of z(d))f.indexOf(R)<0&&Ae.call(d,R)&&(L[R]=d[R]);return L};var VueI18nRouting=function(d,f,L,R){"use strict";function we(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var Ce=we(L);/*!
* shared v9.2.0-beta.34
* (c) 2022 kazuya kawaguchi
* Released under the MIT License.
*/const te=Object.assign,ye=Array.isArray,Ne=e=>typeof e=="function",w=e=>typeof e=="string",Ae=e=>typeof e=="symbol",oe=e=>e!==null&&typeof e=="object",Ie=/\/$|\/\?/;function v(e="",t=!1){return t?Ie.test(e):e.endsWith("/")}function we(e="",t=!1){if(!t)return(v(e)?e.slice(0,-1):e)||"/";if(!v(e,!0))return e||"/";const[o,...a]=e.split("?");return(o.slice(0,-1)||"/")+(a.length?`?${a.join("?")}`:"")}function Ce(e="",t=!1){if(!t)return e.endsWith("/")?e:e+"/";if(v(e,!0))return e||"/";const[o,...a]=e.split("?");return o+"/"+(a.length?`?${a.join("?")}`:"")}const Fe=typeof window!="undefined";function Te(e,t){typeof console!="undefined"&&(console.warn("[vue-i18n-routing] "+e),t&&console.warn(t.stack))}function ae(e){e=e||[];const t=[];for(const o of e)w(o)?t.push({code:o}):t.push(o);return t}function k(e){return e!=null&&"global"in e&&"mode"in e}function z(e){return e!=null&&!("__composer"in e)&&u.isRef(e.locale)}function x(e){return e!=null&&"__composer"in e}function Y(e){return e!=null&&!("__composer"in e)&&!u.isRef(e.locale)}function $(e){return e!=null&&("__VUE_I18N_BRIDGE__"in e||"_sync"in e)}function le(e){return k(e)?z(e.global)?e.global:e.global.__composer:x(e)?e.__composer:e}function H(e){const t=k(e)?e.global:e;return z(t)?u.isVue2&&$(e)?e.locale:t.locale.value:(Y(t)||x(t)||$(t),t.locale)}function Ue(e){const t=k(e)?e.global:e;return z(t)?u.isVue2&&$(e)?e.locales:t.locales.value:(Y(t)||x(t)||$(t),t.locales)}function ne(e,t){const o=k(e)?e.global:e;if(z(o))u.isVue2&&$(e)?e.locale=t:o.locale.value=t;else if(Y(o)||x(o)||$(o))o.locale=t;else throw new Error("TODO:")}function $e(e,t,o){return e.replace(/\/+$/,"")+(t?"/":"")||(o?"":"/")}function ce(e){return d.isVueRouter4,u.isRef(e)?e.value:e}function re(e){return w(e)?e:Ae(e)?e.toString():"(null)"}function se(e,t,{defaultLocale:o,strategy:a,routesNameSeparator:l,defaultLocaleRouteNameSuffix:n}){let c=re(e)+(a==="no_prefix"?"":l+t);return t===o&&a==="prefix_and_default"&&(c+=l+n),c}function ue(e,t){return Ne(e)?e(t):e}function be(e,t){const o=[];for(const[a,l]of t.entries()){const n=e.find(c=>c.iso.toLowerCase()===l.toLowerCase());if(n){o.push({code:n.code,score:1-a/t.length});break}}for(const[a,l]of t.entries()){const n=l.split("-")[0].toLowerCase(),c=e.find(r=>r.iso.split("-")[0].toLowerCase()===n);if(c){o.push({code:c.code,score:.999-a/t.length});break}}return o}const Oe=be;function xe(e,t){return e.score===t.score?t.code.length-e.code.length:t.score-e.score}const je=xe;function Ve(e,t,{matcher:o=Oe,comparer:a=je}={}){const l=[];for(const c of e){const{code:r}=c,s=c.iso||r;l.push({code:r,iso:s})}const n=o(l,t);return n.length>1&&n.sort(a),n.length?n[0].code:""}const j={PREFIX:"prefix",PREFIX_EXCEPT_DEFAULT:"prefix_except_default",PREFIX_AND_DEFAULT:"prefix_and_default",NO_PREFIX:"no_prefix"},A="",I=j.PREFIX_EXCEPT_DEFAULT,ie=!1,y="___",C="default",Be="ltr",fe="",Xe=new Set([j.PREFIX_AND_DEFAULT,j.PREFIX_EXCEPT_DEFAULT]);function b(e){const o=this.router.__routesNameSeparator||this.__routesNameSeparator||y,a=e!=null?u.isRef(e)?u.unref(e):e:this.route;return a.name?re(a.name).split(o)[0]:void 0}function G(e,t){const o=V.call(this,e,t);return o==null?"":u.isVue3?o.redirectedFrom||o.fullPath:o.route.redirectedFrom||o.route.fullPath}function q(e,t){const o=V.call(this,e,t);return o==null?void 0:u.isVue3?o:o.route}function J(e,t){const o=V.call(this,e,t);return o==null?void 0:u.isVue3?o:o.location}function V(e,t){const o=this.router,a=this.i18n,l=t||H(a),n=this.__defaultLocale||A,c=o.__defaultLocale||n,r=o.__defaultLocaleRouteNameSuffix||this.__defaultLocaleRouteNameSuffix||C,s=o.__routesNameSeparator||this.__routesNameSeparator||y,f=o.__strategy||this.__strategy||I,_=o.__trailingSlash||this.__trailingSlash||!1;let h=e;w(e)&&(h[0]==="/"?h={path:e}:h={name:e});let L=te({},h);if(L.path&&!L.name){const g=o.resolve(L),N=u.isVue3?g:g.route,X=b.call(this,N);w(X)?L={name:se(X,l,{defaultLocale:c,strategy:f,routesNameSeparator:s,defaultLocaleRouteNameSuffix:r}),params:N.params,query:N.query,hash:N.hash}:(!(l===n&&Xe.has(f))&&f!==j.NO_PREFIX&&(L.path=`/${l}${L.path}`),L.path=_?Ce(L.path,!0):we(L.path,!0))}else{L.name=se(L.name,l,{defaultLocale:c,strategy:f,routesNameSeparator:s,defaultLocaleRouteNameSuffix:r});const{params:g}=L;g&&g["0"]===void 0&&g.pathMatch&&(g["0"]=g.pathMatch)}const p=o.resolve(L);return(u.isVue3?p.name:p.route.name)?p:o.resolve(e)}function B(e){const t=this.route,o=b.call(this,t);if(!o)return"";const s=!u.isVue3&&u.isRef(t)?t.value:t,{params:a}=s,l=Se(s,["params"]),n={},c=te({},l,{name:o,params:Q(U(U({},a),n),{0:a.pathMatch})});return G.call(this,c,e)}function K({addDirAttribute:e=!1,addSeoAttributes:t=!1}={}){const o=this.router,a=this.i18n,l={htmlAttrs:{},link:[],meta:[]};if(a.locales==null||a.__baseUrl==null)return l;const n=H(a),c=Ue(a),r=ae(c).find(_=>_.code===n)||{code:n},s=r.iso,f=r.dir||o.__defaultDirection;return e&&(l.htmlAttrs.dir=f),t&&n&&a.locales&&(s&&(l.htmlAttrs.lang=s),Me.call(this,c,a.__baseUrl,l.link),ke.call(this,a.__baseUrl,l.link,t),ze(r,s,l.meta),He(c,s,l.meta)),l}function Me(e,t,o){const a=this.router,l=a.__defaultLocale||this.__defaultLocale;if((a.__strategy||this.__strategy)===j.NO_PREFIX)return;const c=new Map;for(const r of e){const s=r.iso;if(!s){Te("Locale ISO code is required to generate alternate link");continue}const[f,_]=s.split("-");f&&_&&(r.isCatchallLocale||!c.has(f))&&c.set(f,r),c.set(s,r)}for(const[r,s]of c.entries()){const f=B.call(this,s.code);f&&o.push({hid:`i18n-alt-${r}`,rel:"alternate",href:Z(f,t),hreflang:r})}if(l){const r=B.call(this,l);r&&o.push({hid:"i18n-xd",rel:"alternate",href:Z(r,t),hreflang:"x-default"})}}function ke(e,t,o){const a=this.route,l=q.call(this,Q(U({},a),{name:b.call(this,a)}));if(l){let n=Z(l.path,e);const c=oe(o)&&o.canonicalQueries||[];if(c.length){const r=l.query,s=new URLSearchParams;for(const _ of c)if(_ in r){const h=r[_];ye(h)?h.forEach(L=>s.append(_,L||"")):s.append(_,h||"")}const f=s.toString();f&&(n=`${n}?${f}`)}t.push({hid:"i18n-can",rel:"canonical",href:n})}}function ze(e,t,o){!(e&&t)||o.push({hid:"i18n-og",property:"og:locale",content:he(t)})}function He(e,t,o){const a=e.filter(l=>{const n=l.iso;return n&&n!==t});if(a.length){const l=a.map(n=>({hid:`i18n-og-alt-${n.iso}`,property:"og:locale:alternate",content:he(n.iso)}));o.push(...l)}}function he(e){return(e||"").replace(/-/g,"_")}function Z(e,t){return e.match(/^https?:\/\//)?e:t+e}function D(e,t){const{router:o,route:a,i18n:l,defaultLocale:n,strategy:c,defaultLocaleRouteNameSuffix:r,trailingSlash:s,routesNameSeparator:f}=e;return function(..._){return Reflect.apply(t,{router:o,route:a,i18n:l,__defaultLocale:n,__strategy:c,__defaultLocaleRouteNameSuffix:r,__trailingSlash:s,__routesNameSeparator:f},_)}}function Ge(e=d.useRoute(),{router:t=d.useRouter(),routesNameSeparator:o=y}={}){const a={router:t,route:e,__routesNameSeparator:o};return b.call(a,e)}function qe({router:e=d.useRouter(),route:t=d.useRoute(),i18n:o=m.useI18n(),defaultLocale:a=A,defaultLocaleRouteNameSuffix:l=C,routesNameSeparator:n=y,strategy:c=I,trailingSlash:r=!1}={}){return D({router:e,route:t,i18n:o,defaultLocale:a,defaultLocaleRouteNameSuffix:l,routesNameSeparator:n,strategy:c,trailingSlash:r},G)}function De({router:e=d.useRouter(),route:t=d.useRoute(),i18n:o=m.useI18n(),defaultLocale:a=A,defaultLocaleRouteNameSuffix:l=C,routesNameSeparator:n=y,strategy:c=I,trailingSlash:r=!1}={}){return D({router:e,route:t,i18n:o,defaultLocale:a,defaultLocaleRouteNameSuffix:l,routesNameSeparator:n,strategy:c,trailingSlash:r},q)}function We({router:e=d.useRouter(),route:t=d.useRoute(),i18n:o=m.useI18n(),defaultLocale:a=A,defaultLocaleRouteNameSuffix:l=C,routesNameSeparator:n=y,strategy:c=I,trailingSlash:r=!1}={}){return D({router:e,route:t,i18n:o,defaultLocale:a,defaultLocaleRouteNameSuffix:l,routesNameSeparator:n,strategy:c,trailingSlash:r},J)}function Qe({router:e=d.useRouter(),route:t=d.useRoute(),i18n:o=m.useI18n(),defaultLocale:a=A,defaultLocaleRouteNameSuffix:l=C,routesNameSeparator:n=y,strategy:c=I,trailingSlash:r=!1}={}){return D({router:e,route:t,i18n:o,defaultLocale:a,defaultLocaleRouteNameSuffix:l,routesNameSeparator:n,strategy:c,trailingSlash:r},B)}function ve({addDirAttribute:e=!1,addSeoAttributes:t=!1,strategy:o=I,defaultLocale:a=A,route:l=d.useRoute(),router:n=d.useRouter(),i18n:c=m.useI18n()}={}){const r=n,s=u.ref({htmlAttrs:{},link:[],meta:[]});function f(){s.value={htmlAttrs:{},link:[],meta:[]}}function _(h){s.value=Reflect.apply(K,{router:n,route:h,i18n:c,__defaultLocale:a,__strategy:o},[{addDirAttribute:e,addSeoAttributes:t}])}if(Fe)if(u.isVue3){const h=u.watchEffect(()=>{f(),_(ce(r.currentRoute))});u.onUnmounted(()=>h())}else{const h=r.afterEach((L,p)=>{f(),_(L)});u.onUnmounted(()=>h()),_(l)}else _(ce(r.currentRoute));return s}function de(e,{defaultLocale:t=A,strategy:o=I,trailingSlash:a=ie,routesNameSeparator:l=y,defaultLocaleRouteNameSuffix:n=C,includeUprefixedFallback:c=!1,optionsResolver:r=void 0,locales:s=[]}={}){if(o==="no_prefix")return e;const f=s.map(h=>w(h)?h:h.code);function _(h,L,p=!1,g=!1){if(h.redirect&&(!h.component||!h.file))return[h];let N=null;return r!=null&&(N=r(h,L),N==null)?[h]:L.reduce((R,S)=>{const{name:M}=h;let{path:E}=h;const P=U({},h);M&&(P.name=`${M}${l}${S}`),h.children&&(P.children=h.children.reduce((T,ee)=>[...T,..._(ee,[S],!0,g)],[]));const O=S===t;if(O&&o==="prefix_and_default")if(p)p&&g&&M&&(P.name+=`${l}${n}`);else{const T=Q(U({},P),{path:E});if(M&&(T.name=`${P.name}${l}${n}`),h.children){T.children=[];for(const ee of h.children)T.children=T.children.concat(_(ee,[S],!0,!0))}R.push(T)}const Le=p&&!E.startsWith("/"),me=!Le&&!(O&&o==="prefix_except_default");return me&&(E=`/${S}${E}`),E&&(E=$e(E,a,Le)),me&&O&&o==="prefix"&&c&&R.push(U({},h)),P.path=E,R.push(P),R},[])}return e.reduce((h,L)=>[...h,..._(L,f||[])],[])}function F(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 Ye(e,{locales:t=[],localeCodes:o=[],baseUrl:a=fe}={}){const l=e.install;e.install=(n,...c)=>{Reflect.apply(l,e,[n,...c]);const r=le(e);Je(r,{locales:t,localeCodes:o,baseUrl:a}),x(e.global)&&Ze(e.global);const s=n,f=e.mode==="composition"?u.isVue3?s.config.globalProperties.$i18n:e:u.isVue2?e:null;f&&Ke(f,r),n.mixin({methods:{resolveRoute:F(V),localePath:F(G),localeRoute:F(q),localeLocation:F(J),switchLocalePath:F(B),getRouteBaseName:F(b),localeHead:F(K)}})}}function Je(e,t){const{locales:o,localeCodes:a,baseUrl:l}=t,n=u.ref(o),c=u.ref(a);e.locales=u.computed(()=>n.value),e.localeCodes=u.computed(()=>c.value),e.__baseUrl=ue(l,{})}function Ke(e,t){Object.defineProperty(e,"locales",{get(){return t.locales.value}}),Object.defineProperty(e,"localeCodes",{get(){return t.localeCodes.value}}),Object.defineProperty(e,"__baseUrl",{get(){return t.__baseUrl}})}function Ze(e){const t=le(e);Object.defineProperty(e,"locales",{get(){return t.locales.value}}),Object.defineProperty(e,"localeCodes",{get(){return t.localeCodes.value}}),Object.defineProperty(e,"__baseUrl",{get(){return t.__baseUrl}})}function et(e,t={}){const{version:o,defaultLocale:a,locales:l,strategy:n,trailingSlash:c,routesNameSeparator:r,defaultLocaleRouteNameSuffix:s,defaultDirection:f,baseUrl:_,routes:h,routeOptionsResolver:L}=at(t),p=ae(l),g=p.map(S=>S.code),N=_e(g,r,s);Ye(e,{locales:p,baseUrl:_,localeCodes:g});const X=de(h,{locales:l,defaultLocale:a,strategy:n,trailingSlash:c,routesNameSeparator:r,defaultLocaleRouteNameSuffix:s,optionsResolver:L});t.routes=X;const R=tt(t,o);return R.__defaultLocale=a,R.__localeCodes=g,R.__strategy=n,R.__trailingSlash=c,R.__routesNameSeparator=r,R.__defaultLocaleRouteNameSuffix=s,R.__defaultDirection=f,R.beforeEach((S,M,E)=>{const P=H(e),O=N(S)||P||a||"";P!==O&&ne(e,O),E()}),R}function tt(e,t){if(u.isVue3&&t===4)return d.createRouter(e);if(u.isVue2&&t===3)return new Pe.default(e);throw new Error("TODO:")}function ot(e){return new RegExp(`^/(${e.join("|")})(?:/|$)`,"i")}function _e(e,t,o){const a=`(${e.join("|")})`,l=`(?:${t}${o})?`,n=new RegExp(`${t}${a}${l}$`,"i"),c=ot(e);return s=>{if(oe(s)){if(s.name){const _=(w(s.name)?s.name:s.name.toString()).match(n);if(_&&_.length>1)return _[1]}else if(s.path){const f=s.path.match(c);if(f&&f.length>1)return f[1]}}else if(w(s)){const f=s.match(c);if(f&&f.length>1)return f[1]}return""}}function at(e){var t,o,a,l,n,c,r,s,f,_;return e.version=(t=e.version)!=null?t:4,e.defaultLocale=(o=e.defaultLocale)!=null?o:A,e.strategy=(a=e.strategy)!=null?a:I,e.trailingSlash=(l=e.trailingSlash)!=null?l:ie,e.routesNameSeparator=(n=e.routesNameSeparator)!=null?n:y,e.defaultLocaleRouteNameSuffix=(c=e.defaultLocaleRouteNameSuffix)!=null?c:C,e.locales=(r=e.locales)!=null?r:[],e.defaultDirection=(s=e.defaultDirection)!=null?s:Be,e.baseUrl=(f=e.baseUrl)!=null?f:fe,e.routes=(_=e.routes)!=null?_:[],e}const lt="0.0.0";return i.VERSION=lt,i.createLocaleFromRouteGetter=_e,i.createRouter=et,i.findBrowserLocale=Ve,i.getLocale=H,i.getRouteBaseName=b,i.localeHead=K,i.localeLocation=J,i.localePath=G,i.localeRoute=q,i.localizeRoutes=de,i.resolveBaseUrl=ue,i.resolveRoute=V,i.setLocale=ne,i.switchLocalePath=B,i.useLocaleHead=ve,i.useLocaleLocation=We,i.useLocalePath=qe,i.useLocaleRoute=De,i.useRouteBaseName=Ge,i.useSwitchLocalePath=Qe,Object.defineProperties(i,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),i}({},VueDemi,VueRouter,VueI18n);
*/const le=Object.assign,be=Array.isArray,Ne=e=>typeof e=="function",O=e=>typeof e=="string",ye=e=>typeof e=="boolean",Fe=e=>typeof e=="symbol",H=e=>e!==null&&typeof e=="object",Te=/\/$|\/\?/;function D(e="",t=!1){return t?Te.test(e):e.endsWith("/")}function Ue(e="",t=!1){if(!t)return(D(e)?e.slice(0,-1):e)||"/";if(!D(e,!0))return e||"/";const[o,...n]=e.split("?");return(o.slice(0,-1)||"/")+(n.length?`?${n.join("?")}`:"")}function $e(e="",t=!1){if(!t)return e.endsWith("/")?e:e+"/";if(D(e,!0))return e||"/";const[o,...n]=e.split("?");return o+"/"+(n.length?`?${n.join("?")}`:"")}const ve=typeof window!="undefined";function je(e,t){typeof console!="undefined"&&(console.warn("[vue-i18n-routing] "+e),t&&console.warn(t.stack))}function ce(e){e=e||[];const t=[];for(const o of e)O(o)?t.push({code:o}):t.push(o);return t}function j(e){return e!=null&&"global"in e&&"mode"in e}function V(e){return e!=null&&!("__composer"in e)&&f.isRef(e.locale)}function F(e){return e!=null&&"__composer"in e}function q(e){return e!=null&&!("__composer"in e)&&!f.isRef(e.locale)}function b(e){return e!=null&&("__VUE_I18N_BRIDGE__"in e||"_sync"in e)}function se(e){return j(e)?V(e.global)?e.global:e.global.__composer:F(e)?e.__composer:e}function B(e){const t=j(e)?e.global:e;return V(t)?f.isVue2&&b(e)?e.locale:t.locale.value:(q(t)||F(t)||b(t),t.locale)}function Ve(e){const t=j(e)?e.global:e;return V(t)?f.isVue2&&b(e)?e.locales:t.locales.value:(q(t)||F(t)||b(t),t.locales)}function re(e,t){const o=j(e)?e.global:e;if(V(o))f.isVue2&&b(e)?e.locale=t:o.locale.value=t;else if(q(o)||F(o)||b(o))o.locale=t;else throw new Error("TODO:")}function Be(e,t,o){return e.replace(/\/+$/,"")+(t?"/":"")||(o?"":"/")}function ie(e){return L.isVueRouter4,f.isRef(e)?e.value:e}function ue(e){return O(e)?e:Fe(e)?e.toString():"(null)"}function fe(e,t,{defaultLocale:o,strategy:n,routesNameSeparator:l,defaultLocaleRouteNameSuffix:a}){let c=ue(e)+(n==="no_prefix"?"":l+t);return t===o&&n==="prefix_and_default"&&(c+=l+a),c}function de(e,t){return Ne(e)?e(t):e}function Me(e,t){const o=[];for(const[n,l]of t.entries()){const a=e.find(c=>c.iso.toLowerCase()===l.toLowerCase());if(a){o.push({code:a.code,score:1-n/t.length});break}}for(const[n,l]of t.entries()){const a=l.split("-")[0].toLowerCase(),c=e.find(s=>s.iso.split("-")[0].toLowerCase()===a);if(c){o.push({code:c.code,score:.999-n/t.length});break}}return o}const Xe=Me;function Ge(e,t){return e.score===t.score?t.code.length-e.code.length:t.score-e.score}const ke=Ge;function ze(e,t,{matcher:o=Xe,comparer:n=ke}={}){const l=[];for(const c of e){const{code:s}=c,r=c.iso||s;l.push({code:s,iso:r})}const a=o(l,t);return a.length>1&&a.sort(n),a.length?a[0].code:""}const T={PREFIX:"prefix",PREFIX_EXCEPT_DEFAULT:"prefix_except_default",PREFIX_AND_DEFAULT:"prefix_and_default",NO_PREFIX:"no_prefix"},W="",Q=T.PREFIX_EXCEPT_DEFAULT,Y=!1,J="___",K="default",he="ltr",Le="";function A(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 xe(e,{locales:t=[],localeCodes:o=[],baseUrl:n=Le}={}){const l=e.install;e.install=(a,...c)=>{Reflect.apply(l,e,[a,...c]);const s=se(e);He(s,{locales:t,localeCodes:o,baseUrl:n}),F(e.global)&&qe(e.global);const r=a,i=e.mode==="composition"?f.isVue3?r.config.globalProperties.$i18n:e:f.isVue2?e:null;i&&De(i,s),(We(c[0])?c[0]:{inject:!0}).inject&&a.mixin({methods:{resolveRoute:A(U),localePath:A(X),localeRoute:A(G),localeLocation:A(ee),switchLocalePath:A($),getRouteBaseName:A(N),localeHead:A(te)}})}}function He(e,t){const{locales:o,localeCodes:n,baseUrl:l}=t,a=f.ref(o),c=f.ref(n);e.locales=f.computed(()=>a.value),e.localeCodes=f.computed(()=>c.value),e.__baseUrl=de(l,{})}function De(e,t){Object.defineProperty(e,"locales",{get(){return t.locales.value}}),Object.defineProperty(e,"localeCodes",{get(){return t.localeCodes.value}}),Object.defineProperty(e,"__baseUrl",{get(){return t.__baseUrl}})}function qe(e){const t=se(e);Object.defineProperty(e,"locales",{get(){return t.locales.value}}),Object.defineProperty(e,"localeCodes",{get(){return t.localeCodes.value}}),Object.defineProperty(e,"__baseUrl",{get(){return t.__baseUrl}})}function We(e){return H(e)&&"inject"in e&&ye(e.inject)}function ge(e,{defaultLocale:t=W,strategy:o=Q,trailingSlash:n=Y,routesNameSeparator:l=J,defaultLocaleRouteNameSuffix:a=K,includeUprefixedFallback:c=!1,optionsResolver:s=void 0,locales:r=[]}={}){if(o==="no_prefix")return e;const i=r.map(u=>O(u)?u:u.code);function h(u,m,g=!1,_=!1){if(u.redirect&&(!u.component||!u.file))return[u];let I=null;return s!=null&&(I=s(u,m),I==null)?[u]:m.reduce((S,P)=>{const{name:v}=u;let{path:p}=u;const E=C({},u);v&&(E.name=`${v}${l}${P}`),u.children&&(E.children=u.children.reduce((w,ae)=>[...w,...h(ae,[P],!0,_)],[]));const y=P===t;if(y&&o==="prefix_and_default")if(g)g&&_&&v&&(E.name+=`${l}${a}`);else{const w=x(C({},E),{path:p});if(v&&(w.name=`${E.name}${l}${a}`),u.children){w.children=[];for(const ae of u.children)w.children=w.children.concat(h(ae,[P],!0,!0))}S.push(w)}const Ee=g&&!p.startsWith("/"),Se=!Ee&&!(y&&o==="prefix_except_default");return Se&&(p=`/${P}${p}`),p&&(p=Be(p,n,Ee)),Se&&y&&o==="prefix"&&c&&S.push(C({},u)),E.path=p,S.push(E),S},[])}return e.reduce((u,m)=>[...u,...h(m,i||[])],[])}const Z=new Map;function Re(e,t){Z.has(e)||Z.set(e,t)}function me(e){var t;return(t=Z.get(e))!=null?t:{}}function Qe(e,t={}){const{version:o,defaultLocale:n,locales:l,strategy:a,trailingSlash:c,routesNameSeparator:s,defaultLocaleRouteNameSuffix:r,defaultDirection:i,baseUrl:h,routes:u,routeOptionsResolver:m}=Ke(t),g=ce(l),_=g.map(P=>P.code),I=_e(_,s,r);xe(e,{locales:g,baseUrl:h,localeCodes:_});const ne=ge(u,{locales:l,defaultLocale:n,strategy:a,trailingSlash:c,routesNameSeparator:s,defaultLocaleRouteNameSuffix:r,optionsResolver:m});t.routes=ne;const S=Ye(t,o);return Re(S,{defaultLocale:n,localeCodes:_,strategy:a,trailingSlash:c,routesNameSeparator:s,defaultLocaleRouteNameSuffix:r,defaultDirection:i}),S.beforeEach((P,v,p)=>{const E=B(e),y=I(P)||E||n||"";E!==y&&re(e,y),p()}),S}function Ye(e,t){if(f.isVue3&&t===4)return L.createRouter(e);if(f.isVue2&&t===3)return new Ce.default(e);throw new Error("TODO:")}function Je(e){return new RegExp(`^/(${e.join("|")})(?:/|$)`,"i")}function _e(e,t,o){const n=`(${e.join("|")})`,l=`(?:${t}${o})?`,a=new RegExp(`${t}${n}${l}$`,"i"),c=Je(e);return r=>{if(H(r)){if(r.name){const h=(O(r.name)?r.name:r.name.toString()).match(a);if(h&&h.length>1)return h[1]}else if(r.path){const i=r.path.match(c);if(i&&i.length>1)return i[1]}}else if(O(r)){const i=r.match(c);if(i&&i.length>1)return i[1]}return""}}function Ke(e){var t,o,n,l,a,c,s,r,i,h;return e.version=(t=e.version)!=null?t:4,e.defaultLocale=(o=e.defaultLocale)!=null?o:W,e.strategy=(n=e.strategy)!=null?n:Q,e.trailingSlash=(l=e.trailingSlash)!=null?l:Y,e.routesNameSeparator=(a=e.routesNameSeparator)!=null?a:J,e.defaultLocaleRouteNameSuffix=(c=e.defaultLocaleRouteNameSuffix)!=null?c:K,e.locales=(s=e.locales)!=null?s:[],e.defaultDirection=(r=e.defaultDirection)!=null?r:he,e.baseUrl=(i=e.baseUrl)!=null?i:Le,e.routes=(h=e.routes)!=null?h:[],e}function M(e,t,{defaultLocale:o=W,defaultDirection:n=he,defaultLocaleRouteNameSuffix:l=K,routesNameSeparator:a=J,strategy:c=Q,trailingSlash:s=Y,localeCodes:r=[]}={}){const i=me(e);return{defaultLocale:t.defaultLocale||i.defaultLocale||o,defaultDirection:t.defaultDirection||i.defaultDirection||n,defaultLocaleRouteNameSuffix:t.defaultLocaleRouteNameSuffix||i.defaultLocaleRouteNameSuffix||l,routesNameSeparator:t.routesNameSeparator||i.routesNameSeparator||a,strategy:t.strategy||i.strategy||c,trailingSlash:t.trailingSlash||i.trailingSlash||s,localeCodes:t.localeCodes||i.localeCodes||r}}const Ze=new Set([T.PREFIX_AND_DEFAULT,T.PREFIX_EXCEPT_DEFAULT]);function N(e){const t=this.router,{routesNameSeparator:o}=M(t,this),n=e!=null?f.isRef(e)?f.unref(e):e:this.route;return n.name?ue(n.name).split(o)[0]:void 0}function X(e,t){const o=U.call(this,e,t);return o==null?"":f.isVue3?o.redirectedFrom||o.fullPath:o.route.redirectedFrom||o.route.fullPath}function G(e,t){const o=U.call(this,e,t);return o==null?void 0:f.isVue3?o:o.route}function ee(e,t){const o=U.call(this,e,t);return o==null?void 0:f.isVue3?o:o.location}function U(e,t){const o=this.router,n=this.i18n,l=t||B(n),{routesNameSeparator:a,defaultLocale:c,defaultLocaleRouteNameSuffix:s,strategy:r,trailingSlash:i}=M(o,this);let h=e;O(e)&&(h[0]==="/"?h={path:e}:h={name:e});let u=le({},h);if(u.path&&!u.name){const g=o.resolve(u),_=f.isVue3?g:g.route,I=N.call(this,_);O(I)?u={name:fe(I,l,{defaultLocale:c,strategy:r,routesNameSeparator:a,defaultLocaleRouteNameSuffix:s}),params:_.params,query:_.query,hash:_.hash}:(!(l===c&&Ze.has(r))&&r!==T.NO_PREFIX&&(u.path=`/${l}${u.path}`),u.path=i?$e(u.path,!0):Ue(u.path,!0))}else{u.name=fe(u.name,l,{defaultLocale:c,strategy:r,routesNameSeparator:a,defaultLocaleRouteNameSuffix:s});const{params:g}=u;g&&g["0"]===void 0&&g.pathMatch&&(g["0"]=g.pathMatch)}const m=o.resolve(u);return(f.isVue3?m.name:m.route.name)?m:o.resolve(e)}function $(e){const t=this.route,o=N.call(this,t);if(!o)return"";const r=!f.isVue3&&f.isRef(t)?t.value:t,{params:n}=r,l=Ie(r,["params"]),a={},c=le({},l,{name:o,params:x(C(C({},n),a),{0:n.pathMatch})});return X.call(this,c,e)}function te({addDirAttribute:e=!1,addSeoAttributes:t=!1}={}){const o=this.router,n=this.i18n,{defaultDirection:l}=M(o,this),a={htmlAttrs:{},link:[],meta:[]};if(n.locales==null||n.__baseUrl==null)return a;const c=B(n),s=Ve(n),r=ce(s).find(u=>u.code===c)||{code:c},i=r.iso,h=r.dir||l;return e&&(a.htmlAttrs.dir=h),t&&c&&n.locales&&(i&&(a.htmlAttrs.lang=i),et.call(this,s,n.__baseUrl,a.link),tt.call(this,n.__baseUrl,a.link,t),ot(r,i,a.meta),nt(s,i,a.meta)),a}function et(e,t,o){const n=this.router,{defaultLocale:l,strategy:a}=M(n,this);if(a===T.NO_PREFIX)return;const c=new Map;for(const s of e){const r=s.iso;if(!r){je("Locale ISO code is required to generate alternate link");continue}const[i,h]=r.split("-");i&&h&&(s.isCatchallLocale||!c.has(i))&&c.set(i,s),c.set(r,s)}for(const[s,r]of c.entries()){const i=$.call(this,r.code);i&&o.push({hid:`i18n-alt-${s}`,rel:"alternate",href:oe(i,t),hreflang:s})}if(l){const s=$.call(this,l);s&&o.push({hid:"i18n-xd",rel:"alternate",href:oe(s,t),hreflang:"x-default"})}}function tt(e,t,o){const n=this.route,l=G.call(this,x(C({},n),{name:N.call(this,n)}));if(l){let a=oe(l.path,e);const c=H(o)&&o.canonicalQueries||[];if(c.length){const s=l.query,r=new URLSearchParams;for(const h of c)if(h in s){const u=s[h];be(u)?u.forEach(m=>r.append(h,m||"")):r.append(h,u||"")}const i=r.toString();i&&(a=`${a}?${i}`)}t.push({hid:"i18n-can",rel:"canonical",href:a})}}function ot(e,t,o){!(e&&t)||o.push({hid:"i18n-og",property:"og:locale",content:pe(t)})}function nt(e,t,o){const n=e.filter(l=>{const a=l.iso;return a&&a!==t});if(n.length){const l=n.map(a=>({hid:`i18n-og-alt-${a.iso}`,property:"og:locale:alternate",content:pe(a.iso)}));o.push(...l)}}function pe(e){return(e||"").replace(/-/g,"_")}function oe(e,t){return e.match(/^https?:\/\//)?e:t+e}function k(e,t){const{router:o,route:n,i18n:l,defaultLocale:a,strategy:c,defaultLocaleRouteNameSuffix:s,trailingSlash:r,routesNameSeparator:i}=e;return function(...h){return Reflect.apply(t,{router:o,route:n,i18n:l,defaultLocale:a,strategy:c,defaultLocaleRouteNameSuffix:s,trailingSlash:r,routesNameSeparator:i},h)}}function at(e=L.useRoute(),{router:t=L.useRouter(),routesNameSeparator:o=void 0}={}){const n={router:t,route:e,routesNameSeparator:o};return N.call(n,e)}function lt({router:e=L.useRouter(),route:t=L.useRoute(),i18n:o=R.useI18n(),defaultLocale:n=void 0,defaultLocaleRouteNameSuffix:l=void 0,routesNameSeparator:a=void 0,strategy:c=void 0,trailingSlash:s=void 0}={}){return k({router:e,route:t,i18n:o,defaultLocale:n,defaultLocaleRouteNameSuffix:l,routesNameSeparator:a,strategy:c,trailingSlash:s},X)}function ct({router:e=L.useRouter(),route:t=L.useRoute(),i18n:o=R.useI18n(),defaultLocale:n=void 0,defaultLocaleRouteNameSuffix:l=void 0,routesNameSeparator:a=void 0,strategy:c=void 0,trailingSlash:s=void 0}={}){return k({router:e,route:t,i18n:o,defaultLocale:n,defaultLocaleRouteNameSuffix:l,routesNameSeparator:a,strategy:c,trailingSlash:s},G)}function st({router:e=L.useRouter(),route:t=L.useRoute(),i18n:o=R.useI18n(),defaultLocale:n=void 0,defaultLocaleRouteNameSuffix:l=void 0,routesNameSeparator:a=void 0,strategy:c=void 0,trailingSlash:s=void 0}={}){return k({router:e,route:t,i18n:o,defaultLocale:n,defaultLocaleRouteNameSuffix:l,routesNameSeparator:a,strategy:c,trailingSlash:s},ee)}function rt({router:e=L.useRouter(),route:t=L.useRoute(),i18n:o=R.useI18n(),defaultLocale:n=void 0,defaultLocaleRouteNameSuffix:l=void 0,routesNameSeparator:a=void 0,strategy:c=void 0,trailingSlash:s=void 0}={}){return k({router:e,route:t,i18n:o,defaultLocale:n,defaultLocaleRouteNameSuffix:l,routesNameSeparator:a,strategy:c,trailingSlash:s},$)}function it({addDirAttribute:e=!1,addSeoAttributes:t=!1,strategy:o=void 0,defaultLocale:n=void 0,route:l=L.useRoute(),router:a=L.useRouter(),i18n:c=R.useI18n()}={}){const s=a,r=f.ref({htmlAttrs:{},link:[],meta:[]});function i(){r.value={htmlAttrs:{},link:[],meta:[]}}function h(u){r.value=Reflect.apply(te,{router:a,route:u,i18n:c,defaultLocale:n,strategy:o},[{addDirAttribute:e,addSeoAttributes:t}])}if(ve)if(f.isVue3){const u=f.watchEffect(()=>{i(),h(ie(s.currentRoute))});f.onUnmounted(()=>u())}else{const u=s.afterEach((m,g)=>{i(),h(m)});f.onUnmounted(()=>u()),h(l)}else h(ie(s.currentRoute));return r}const ut="0.0.0";return d.VERSION=ut,d.createLocaleFromRouteGetter=_e,d.createRouter=Qe,d.findBrowserLocale=ze,d.getGlobalOptions=me,d.getLocale=B,d.getRouteBaseName=N,d.localeHead=te,d.localeLocation=ee,d.localePath=X,d.localeRoute=G,d.localizeRoutes=ge,d.registerGlobalOptions=Re,d.resolveBaseUrl=de,d.resolveRoute=U,d.setLocale=re,d.switchLocalePath=$,d.useLocaleHead=it,d.useLocaleLocation=st,d.useLocalePath=lt,d.useLocaleRoute=ct,d.useRouteBaseName=at,d.useSwitchLocalePath=rt,Object.defineProperties(d,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),d}({},VueDemi,VueRouter,VueI18n);
{
"name": "vue-i18n-routing",
"description": "The i18n routing with using vue-i18n",
"version": "0.0.0-2087dad",
"version": "0.0.0-29e55b7",
"dependencies": {

@@ -51,3 +51,3 @@ "@intlify/shared": "next",

"index.mjs",
"mixins.d.ts",
"types.d.ts",
"LICENSE",

@@ -70,4 +70,4 @@ "README.md"

},
"./mixins": {
"types": "./mixins.d.ts"
"./types": {
"types": "./types.d.ts"
},

@@ -74,0 +74,0 @@ "./package.json": "./package.json",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc