vue-i18n-routing
Advanced tools
Comparing version 0.0.0-05f2feb to 0.0.0-089143c
@@ -1,5 +0,5 @@ | ||
"use strict";var Pe=Object.defineProperty,De=Object.defineProperties;var Oe=Object.getOwnPropertyDescriptors;var N=Object.getOwnPropertySymbols;var ue=Object.prototype.hasOwnProperty,ie=Object.prototype.propertyIsEnumerable;var se=(e,t,o)=>t in e?Pe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,I=(e,t)=>{for(var o in t||(t={}))ue.call(t,o)&&se(e,o,t[o]);if(N)for(var o of N(t))ie.call(t,o)&&se(e,o,t[o]);return e},w=(e,t)=>De(e,Oe(t));var fe=(e,t)=>{var o={};for(var n in e)ue.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&N)for(var n of N(e))t.indexOf(n)<0&&ie.call(e,n)&&(o[n]=e[n]);return o};Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var d=require("vue-demi"),L=require("@intlify/vue-router-bridge"),x=require("@intlify/vue-i18n-bridge");function be(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var Ue=be(L);const P={PREFIX:"prefix",PREFIX_EXCEPT_DEFAULT:"prefix_except_default",PREFIX_AND_DEFAULT:"prefix_and_default",NO_PREFIX:"no_prefix"},$="",V=P.PREFIX_EXCEPT_DEFAULT,B=!1,j="___",G="default",ee="ltr",te="";/*! | ||
"use strict";var De=Object.defineProperty,Oe=Object.defineProperties;var be=Object.getOwnPropertyDescriptors;var N=Object.getOwnPropertySymbols;var ue=Object.prototype.hasOwnProperty,ie=Object.prototype.propertyIsEnumerable;var se=(e,t,o)=>t in e?De(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,I=(e,t)=>{for(var o in t||(t={}))ue.call(t,o)&&se(e,o,t[o]);if(N)for(var o of N(t))ie.call(t,o)&&se(e,o,t[o]);return e},w=(e,t)=>Oe(e,be(t));var fe=(e,t)=>{var o={};for(var n in e)ue.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&N)for(var n of N(e))t.indexOf(n)<0&&ie.call(e,n)&&(o[n]=e[n]);return o};Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var d=require("vue-demi"),L=require("@intlify/vue-router-bridge"),U=require("@intlify/vue-i18n-bridge");function xe(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var Ue=xe(L);const P={PREFIX:"prefix",PREFIX_EXCEPT_DEFAULT:"prefix_except_default",PREFIX_AND_DEFAULT:"prefix_and_default",NO_PREFIX:"no_prefix"},$="",V=P.PREFIX_EXCEPT_DEFAULT,B=!1,j="___",G="default",ee="ltr",te="";/*! | ||
* shared v9.2.0-beta.35 | ||
* (c) 2022 kazuya kawaguchi | ||
* Released under the MIT License. | ||
*/const xe=typeof Symbol=="function"&&typeof Symbol.toStringTag=="symbol",Ce=e=>xe?Symbol(e):e,me=Object.assign,Fe=Array.isArray,Ne=e=>typeof e=="function",T=e=>typeof e=="string",we=e=>typeof e=="boolean",$e=e=>typeof e=="symbol",oe=e=>e!==null&&typeof e=="object",Ve=/\/$|\/\?/;function J(e="",t=!1){return t?Ve.test(e):e.endsWith("/")}function Be(e="",t=!1){if(!t)return(J(e)?e.slice(0,-1):e)||"/";if(!J(e,!0))return e||"/";const[o,...n]=e.split("?");return(o.slice(0,-1)||"/")+(n.length?`?${n.join("?")}`:"")}function je(e="",t=!1){if(!t)return e.endsWith("/")?e:e+"/";if(J(e,!0))return e||"/";const[o,...n]=e.split("?");return o+"/"+(n.length?`?${n.join("?")}`:"")}const Ge=typeof window!="undefined";function Le(e,t){typeof console!="undefined"&&(console.warn("[vue-i18n-routing] "+e),t&&console.warn(t.stack))}function pe(e){e=e||[];const t=[];for(const o of e)T(o)?t.push({code:o}):t.push(o);return t}function X(e){return e!=null&&"global"in e&&"mode"in e}function M(e){return e!=null&&!("__composer"in e)&&d.isRef(e.locale)}function C(e){return e!=null&&"__composer"in e}function ne(e){return e!=null&&!("__composer"in e)&&!d.isRef(e.locale)}function D(e){return e!=null&&("__VUE_I18N_BRIDGE__"in e||"_sync"in e)}function Re(e){return X(e)?M(e.global)?e.global:e.global.__composer:C(e)?e.__composer:e}function k(e){const t=X(e)?e.global:e;return M(t)?d.isVue2&&D(e)?e.locale:t.locale.value:(ne(t)||C(t)||D(t),t.locale)}function Xe(e){const t=X(e)?e.global:e;return M(t)?d.isVue2&&D(e)?e.locales:t.locales.value:(ne(t)||C(t)||D(t),t.locales)}function ge(e,t){const o=X(e)?e.global:e;if(M(o))d.isVue2&&D(e)?e.locale=t:o.locale.value=t;else if(ne(o)||C(o)||D(o))o.locale=t;else throw new Error("TODO:")}function Me(e,t,o){return e.replace(/\/+$/,"")+(t?"/":"")||(o?"":"/")}function de(e){return L.isVueRouter4,d.isRef(e)?e.value:e}function _e(e){return T(e)?e:$e(e)?e.toString():"(null)"}function he(e,t,{defaultLocale:o,strategy:n,routesNameSeparator:l,defaultLocaleRouteNameSuffix:a}){let r=_e(e)+(n==="no_prefix"?"":l+t);return t===o&&n==="prefix_and_default"&&(r+=l+a),r}function Ee(e,t){return Ne(e)?e(t):e}function ke(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 ze=ke;function He(e,t){return e.score===t.score?t.code.length-e.code.length:t.score-e.score}const qe=He;function We(e,t,{matcher:o=ze,comparer:n=qe}={}){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:""}function S(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 Se(e,{locales:t=[],localeCodes:o=[],baseUrl:n=te,hooks:l={}}={}){const a=d.effectScope(),r=e.install;return e.install=(c,...s)=>{Reflect.apply(r,e,[c,...s]);const i=Re(e);a.run(()=>Qe(i,{locales:t,localeCodes:o,baseUrl:n,hooks:l})),C(e.global)&&Je(e.global,l.onExtendVueI18n);const f=c,u=e.mode==="composition"?d.isVue3?f.config.globalProperties.$i18n:e:d.isVue2?e:null;if(u&&Ye(u,i,l.onExtendExportedGlobal),(Ke(s[0])?s[0]:{inject:!0}).inject&&c.mixin({methods:{resolveRoute:S(F),localePath:S(H),localeRoute:S(q),localeLocation:S(ae),switchLocalePath:S(U),getRouteBaseName:S(O),localeHead:S(le)}}),f.unmount){const h=f.unmount;f.unmount=()=>{a.stop(),h()}}},a}function Qe(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=Ee(l,{}),t.hooks&&t.hooks.onExtendComposer&&t.hooks.onExtendComposer(e)}function Ye(e,t,o){const n=[{locales:{get(){return t.locales.value}},localeCodes:{get(){return t.localeCodes.value}},__baseUrl:{get(){return t.__baseUrl}}}];o&&n.push(o(t));for(const l of n)for(const[a,r]of Object.entries(l))Object.defineProperty(e,a,r)}function Je(e,t){const o=Re(e),n=[{locales:{get(){return o.locales.value}},localeCodes:{get(){return o.localeCodes.value}},__baseUrl:{get(){return o.__baseUrl}}}];t&&n.push(t(o));for(const l of n)for(const[a,r]of Object.entries(l))Object.defineProperty(e,a,r)}function Ke(e){return oe(e)&&"inject"in e&&we(e.inject)}function ve(e,{defaultLocale:t=$,strategy:o=V,trailingSlash:n=B,routesNameSeparator:l=j,defaultLocaleRouteNameSuffix:a=G,includeUprefixedFallback:r=!1,optionsResolver:c=void 0,locales:s=[]}={}){if(o==="no_prefix")return e;const i=s.map(u=>T(u)?u:u.code);function f(u,m,h=!1,p=!1){if(u.redirect&&(!u.component||!u.file))return[u];let v=null;return c!=null&&(v=c(u,m),v==null)?[u]:m.reduce((_,E)=>{const{name:b}=u;let{path:R}=u;const g=I({},u);b&&(g.name=`${b}${l}${E}`),u.children&&(g.children=u.children.reduce((A,Y)=>[...A,...f(Y,[E],!0,p)],[]));const y=E===t;if(y&&o==="prefix_and_default")if(h)h&&p&&b&&(g.name+=`${l}${a}`);else{const A=w(I({},g),{path:R});if(b&&(A.name=`${g.name}${l}${a}`),u.children){A.children=[];for(const Y of u.children)A.children=A.children.concat(f(Y,[E],!0,!0))}_.push(A)}const re=h&&!R.startsWith("/"),ce=!re&&!(y&&o==="prefix_except_default");return ce&&(R=`/${E}${R}`),R&&(R=Me(R,n,re)),ce&&y&&o==="prefix"&&r&&_.push(I({},u)),g.path=R,_.push(g),_},[])}return e.reduce((u,m)=>[...u,...f(m,i||[])],[])}const K=Ce("vue-i18n-routing-gor");function Ae(e,t){e[K]?Le("already registered global options"):e[K]=t}function Ie(e){var t;return(t=e[K])!=null?t:{}}function Ze(e,t={}){const{version:o,defaultLocale:n,locales:l,strategy:a,trailingSlash:r,routesNameSeparator:c,defaultLocaleRouteNameSuffix:s,defaultDirection:i,baseUrl:f,routes:u,routeOptionsResolver:m}=ot(t),h=pe(l),p=h.map(E=>E.code),v=Te(p,c,s);Se(e,{locales:h,baseUrl:f,localeCodes:p});const Q=ve(u,{locales:l,defaultLocale:n,strategy:a,trailingSlash:r,routesNameSeparator:c,defaultLocaleRouteNameSuffix:s,optionsResolver:m});t.routes=Q;const _=et(t,o);return Ae(_,{defaultLocale:n,localeCodes:p,strategy:a,trailingSlash:r,routesNameSeparator:c,defaultLocaleRouteNameSuffix:s,defaultDirection:i}),_.beforeEach((E,b,R)=>{const g=k(e),y=v(E)||g||n||"";g!==y&&ge(e,y),R()}),_}function et(e,t){if(d.isVue3&&t===4)return L.createRouter(e);if(d.isVue2&&t===3)return new Ue.default(e);throw new Error("TODO:")}function tt(e){return new RegExp(`^/(${e.join("|")})(?:/|$)`,"i")}function Te(e,t,o){const n=`(${e.join("|")})`,l=`(?:${t}${o})?`,a=new RegExp(`${t}${n}${l}$`,"i"),r=tt(e);return s=>{if(oe(s)){if(s.name){const f=(T(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(T(s)){const i=s.match(r);if(i&&i.length>1)return i[1]}return""}}function ot(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:$,e.strategy=(n=e.strategy)!=null?n:V,e.trailingSlash=(l=e.trailingSlash)!=null?l:B,e.routesNameSeparator=(a=e.routesNameSeparator)!=null?a:j,e.defaultLocaleRouteNameSuffix=(r=e.defaultLocaleRouteNameSuffix)!=null?r:G,e.locales=(c=e.locales)!=null?c:[],e.defaultDirection=(s=e.defaultDirection)!=null?s:ee,e.baseUrl=(i=e.baseUrl)!=null?i:te,e.routes=(f=e.routes)!=null?f:[],e}function z(e,t,{defaultLocale:o=$,defaultDirection:n=ee,defaultLocaleRouteNameSuffix:l=G,routesNameSeparator:a=j,strategy:r=V,trailingSlash:c=B,localeCodes:s=[]}={}){const i=Ie(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 nt=new Set([P.PREFIX_AND_DEFAULT,P.PREFIX_EXCEPT_DEFAULT]);function O(e){const t=this.router,{routesNameSeparator:o}=z(t,this),n=e!=null?d.isRef(e)?d.unref(e):e:this.route;return n.name?_e(n.name).split(o)[0]:void 0}function H(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 q(e,t){const o=F.call(this,e,t);return o==null?void 0:d.isVue3?o:o.route}function ae(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||k(n),{routesNameSeparator:a,defaultLocale:r,defaultLocaleRouteNameSuffix:c,strategy:s,trailingSlash:i}=z(o,this);let f=e;T(e)&&(f[0]==="/"?f={path:e}:f={name:e});let u=me({},f);if(u.path&&!u.name){const h=o.resolve(u),p=d.isVue3?h:h.route,v=O.call(this,p);T(v)?u={name:he(v,l,{defaultLocale:r,strategy:s,routesNameSeparator:a,defaultLocaleRouteNameSuffix:c}),params:p.params,query:p.query,hash:p.hash}:(!(l===r&&nt.has(s))&&s!==P.NO_PREFIX&&(u.path=`/${l}${u.path}`),u.path=i?je(u.path,!0):Be(u.path,!0))}else{u.name=he(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 m=o.resolve(u);return(d.isVue3?m.name:m.route.name)?m:o.resolve(e)}function U(e){const t=this.route,o=O.call(this,t);if(!o)return"";const s=!d.isVue3&&d.isRef(t)?t.value:t,{params:n}=s,l=fe(s,["params"]),a={},r=me({},l,{name:o,params:w(I(I({},n),a),{0:n.pathMatch})});return H.call(this,r,e)}function le({addDirAttribute:e=!1,addSeoAttributes:t=!1}={}){const o=this.router,n=this.i18n,{defaultDirection:l}=z(o,this),a={htmlAttrs:{},link:[],meta:[]};if(n.locales==null||n.__baseUrl==null)return a;const r=k(n),c=Xe(n),s=pe(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),at.call(this,c,n.__baseUrl,a.link),lt.call(this,n.__baseUrl,a.link,t),rt(s,i,a.meta),ct(c,i,a.meta)),a}function at(e,t,o){const n=this.router,{defaultLocale:l,strategy:a}=z(n,this);if(a===P.NO_PREFIX)return;const r=new Map;for(const c of e){const s=c.iso;if(!s){Le("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=U.call(this,s.code);i&&o.push({hid:`i18n-alt-${c}`,rel:"alternate",href:Z(i,t),hreflang:c})}if(l){const c=U.call(this,l);c&&o.push({hid:"i18n-xd",rel:"alternate",href:Z(c,t),hreflang:"x-default"})}}function lt(e,t,o){const n=this.route,l=q.call(this,w(I({},n),{name:O.call(this,n)}));if(l){let a=Z(l.path,e);const r=oe(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];Fe(u)?u.forEach(m=>s.append(f,m||"")):s.append(f,u||"")}const i=s.toString();i&&(a=`${a}?${i}`)}t.push({hid:"i18n-can",rel:"canonical",href:a})}}function rt(e,t,o){!(e&&t)||o.push({hid:"i18n-og",property:"og:locale",content:ye(t)})}function ct(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:ye(a.iso)}));o.push(...l)}}function ye(e){return(e||"").replace(/-/g,"_")}function Z(e,t){return e.match(/^https?:\/\//)?e:t+e}function W(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 st(e=L.useRoute(),{router:t=L.useRouter(),routesNameSeparator:o=void 0}={}){const n={router:t,route:e,routesNameSeparator:o};return O.call(n,e)}function ut({router:e=L.useRouter(),route:t=L.useRoute(),i18n:o=x.useI18n(),defaultLocale:n=void 0,defaultLocaleRouteNameSuffix:l=void 0,routesNameSeparator:a=void 0,strategy:r=void 0,trailingSlash:c=void 0}={}){return W({router:e,route:t,i18n:o,defaultLocale:n,defaultLocaleRouteNameSuffix:l,routesNameSeparator:a,strategy:r,trailingSlash:c},H)}function it({router:e=L.useRouter(),route:t=L.useRoute(),i18n:o=x.useI18n(),defaultLocale:n=void 0,defaultLocaleRouteNameSuffix:l=void 0,routesNameSeparator:a=void 0,strategy:r=void 0,trailingSlash:c=void 0}={}){return W({router:e,route:t,i18n:o,defaultLocale:n,defaultLocaleRouteNameSuffix:l,routesNameSeparator:a,strategy:r,trailingSlash:c},q)}function ft({router:e=L.useRouter(),route:t=L.useRoute(),i18n:o=x.useI18n(),defaultLocale:n=void 0,defaultLocaleRouteNameSuffix:l=void 0,routesNameSeparator:a=void 0,strategy:r=void 0,trailingSlash:c=void 0}={}){return W({router:e,route:t,i18n:o,defaultLocale:n,defaultLocaleRouteNameSuffix:l,routesNameSeparator:a,strategy:r,trailingSlash:c},ae)}function dt({router:e=L.useRouter(),route:t=L.useRoute(),i18n:o=x.useI18n(),defaultLocale:n=void 0,defaultLocaleRouteNameSuffix:l=void 0,routesNameSeparator:a=void 0,strategy:r=void 0,trailingSlash:c=void 0}={}){return W({router:e,route:t,i18n:o,defaultLocale:n,defaultLocaleRouteNameSuffix:l,routesNameSeparator:a,strategy:r,trailingSlash:c},U)}function ht({addDirAttribute:e=!1,addSeoAttributes:t=!1,strategy:o=void 0,defaultLocale:n=void 0,route:l=L.useRoute(),router:a=L.useRouter(),i18n:r=x.useI18n()}={}){const c=a,s=d.ref({htmlAttrs:{},link:[],meta:[]});function i(){s.value={htmlAttrs:{},link:[],meta:[]}}function f(u){s.value=Reflect.apply(le,{router:a,route:u,i18n:r,defaultLocale:n,strategy:o},[{addDirAttribute:e,addSeoAttributes:t}])}if(Ge)if(d.isVue3){const u=d.watchEffect(()=>{i(),f(de(c.currentRoute))});d.onUnmounted(()=>u())}else{const u=c.afterEach((m,h)=>{i(),f(m)});d.onUnmounted(()=>u()),f(l)}else f(de(c.currentRoute));return s}const mt="0.0.0";exports.DEFAULT_BASE_URL=te;exports.DEFAULT_DETECTION_DIRECTION=ee;exports.DEFAULT_LOCALE=$;exports.DEFAULT_LOCALE_ROUTE_NAME_SUFFIX=G;exports.DEFAULT_ROUTES_NAME_SEPARATOR=j;exports.DEFAULT_STRATEGY=V;exports.DEFAULT_TRAILING_SLASH=B;exports.STRATEGIES=P;exports.VERSION=mt;exports.createLocaleFromRouteGetter=Te;exports.createRouter=Ze;exports.extendI18n=Se;exports.findBrowserLocale=We;exports.getGlobalOptions=Ie;exports.getLocale=k;exports.getRouteBaseName=O;exports.localeHead=le;exports.localeLocation=ae;exports.localePath=H;exports.localeRoute=q;exports.localizeRoutes=ve;exports.proxyVueInstance=S;exports.registerGlobalOptions=Ae;exports.resolveBaseUrl=Ee;exports.resolveRoute=F;exports.setLocale=ge;exports.switchLocalePath=U;exports.useLocaleHead=ht;exports.useLocaleLocation=ft;exports.useLocalePath=ut;exports.useLocaleRoute=it;exports.useRouteBaseName=st;exports.useSwitchLocalePath=dt; | ||
*/const Ce=typeof Symbol=="function"&&typeof Symbol.toStringTag=="symbol",Fe=e=>Ce?Symbol(e):e,me=Object.assign,Ne=Array.isArray,we=e=>typeof e=="function",T=e=>typeof e=="string",$e=e=>typeof e=="boolean",Ve=e=>typeof e=="symbol",oe=e=>e!==null&&typeof e=="object",Be=/\/$|\/\?/;function J(e="",t=!1){return t?Be.test(e):e.endsWith("/")}function je(e="",t=!1){if(!t)return(J(e)?e.slice(0,-1):e)||"/";if(!J(e,!0))return e||"/";const[o,...n]=e.split("?");return(o.slice(0,-1)||"/")+(n.length?`?${n.join("?")}`:"")}function Ge(e="",t=!1){if(!t)return e.endsWith("/")?e:e+"/";if(J(e,!0))return e||"/";const[o,...n]=e.split("?");return o+"/"+(n.length?`?${n.join("?")}`:"")}const Xe=typeof window!="undefined";function Le(e,t){typeof console!="undefined"&&(console.warn("[vue-i18n-routing] "+e),t&&console.warn(t.stack))}function pe(e){e=e||[];const t=[];for(const o of e)T(o)?t.push({code:o}):t.push(o);return t}function X(e){return e!=null&&"global"in e&&"mode"in e}function M(e){return e!=null&&!("__composer"in e)&&d.isRef(e.locale)}function C(e){return e!=null&&"__composer"in e}function ne(e){return e!=null&&!("__composer"in e)&&!d.isRef(e.locale)}function D(e){return e!=null&&("__VUE_I18N_BRIDGE__"in e||"_sync"in e)}function Re(e){return X(e)?M(e.global)?e.global:e.global.__composer:C(e)?e.__composer:e}function k(e){const t=X(e)?e.global:e;return M(t)?d.isVue2&&D(e)?e.locale:t.locale.value:(ne(t)||C(t)||D(t),t.locale)}function Me(e){const t=X(e)?e.global:e;return M(t)?d.isVue2&&D(e)?e.locales:t.locales.value:(ne(t)||C(t)||D(t),t.locales)}function ge(e,t){const o=X(e)?e.global:e;if(M(o))d.isVue2&&D(e)?e.locale=t:o.locale.value=t;else if(ne(o)||C(o)||D(o))o.locale=t;else throw new Error("TODO:")}function ke(e,t,o){return e.replace(/\/+$/,"")+(t?"/":"")||(o?"":"/")}function de(e){return L.isVueRouter4,d.isRef(e)?e.value:e}function _e(e){return T(e)?e:Ve(e)?e.toString():"(null)"}function he(e,t,{defaultLocale:o,strategy:n,routesNameSeparator:l,defaultLocaleRouteNameSuffix:a}){let r=_e(e)+(n==="no_prefix"?"":l+t);return t===o&&n==="prefix_and_default"&&(r+=l+a),r}function Ee(e,t){return we(e)?e(t):e}function ze(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 He=ze;function qe(e,t){return e.score===t.score?t.code.length-e.code.length:t.score-e.score}const We=qe;function Qe(e,t,{matcher:o=He,comparer:n=We}={}){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:""}function S(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 Se(e,{locales:t=[],localeCodes:o=[],baseUrl:n=te,hooks:l={}}={}){const a=d.effectScope(),r=e.install;return e.install=(c,...s)=>{Reflect.apply(r,e,[c,...s]);const i=Re(e);a.run(()=>Ye(i,{locales:t,localeCodes:o,baseUrl:n,hooks:l})),C(e.global)&&Ke(e.global,l.onExtendVueI18n);const f=c,u=e.mode==="composition"?d.isVue3?f.config.globalProperties.$i18n:e:d.isVue2?e:null;if(u&&Je(u,i,l.onExtendExportedGlobal),(Ze(s[0])?s[0]:{inject:!0}).inject&&c.mixin({methods:{resolveRoute:S(F),localePath:S(H),localeRoute:S(q),localeLocation:S(ae),switchLocalePath:S(x),getRouteBaseName:S(O),localeHead:S(le)}}),f.unmount){const h=f.unmount;f.unmount=()=>{a.stop(),h()}}},a}function Ye(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=Ee(l,{}),t.hooks&&t.hooks.onExtendComposer&&t.hooks.onExtendComposer(e)}function Je(e,t,o){const n=[{locales:{get(){return t.locales.value}},localeCodes:{get(){return t.localeCodes.value}},__baseUrl:{get(){return t.__baseUrl}}}];o&&n.push(o(t));for(const l of n)for(const[a,r]of Object.entries(l))Object.defineProperty(e,a,r)}function Ke(e,t){const o=Re(e),n=[{locales:{get(){return o.locales.value}},localeCodes:{get(){return o.localeCodes.value}},__baseUrl:{get(){return o.__baseUrl}}}];t&&n.push(t(o));for(const l of n)for(const[a,r]of Object.entries(l))Object.defineProperty(e,a,r)}function Ze(e){return oe(e)&&"inject"in e&&$e(e.inject)}function ve(e,{defaultLocale:t=$,strategy:o=V,trailingSlash:n=B,routesNameSeparator:l=j,defaultLocaleRouteNameSuffix:a=G,includeUprefixedFallback:r=!1,optionsResolver:c=void 0,locales:s=[]}={}){if(o==="no_prefix")return e;const i=s.map(u=>T(u)?u:u.code);function f(u,m,h=!1,p=!1){if(u.redirect&&(!u.component||!u.file))return[u];let v=null;return c!=null&&(v=c(u,m),v==null)?[u]:m.reduce((_,E)=>{const{name:b}=u;let{path:R}=u;const g=I({},u);b&&(g.name=`${b}${l}${E}`),u.children&&(g.children=u.children.reduce((A,Y)=>[...A,...f(Y,[E],!0,p)],[]));const y=E===t;if(y&&o==="prefix_and_default")if(h)h&&p&&b&&(g.name+=`${l}${a}`);else{const A=w(I({},g),{path:R});if(b&&(A.name=`${g.name}${l}${a}`),u.children){A.children=[];for(const Y of u.children)A.children=A.children.concat(f(Y,[E],!0,!0))}_.push(A)}const re=h&&!R.startsWith("/"),ce=!re&&!(y&&o==="prefix_except_default");return ce&&(R=`/${E}${R}`),R&&(R=ke(R,n,re)),ce&&y&&o==="prefix"&&r&&_.push(I({},u)),g.path=R,_.push(g),_},[])}return e.reduce((u,m)=>[...u,...f(m,i||[])],[])}const K=Fe("vue-i18n-routing-gor");function Ae(e,t){e[K]?Le("already registered global options"):e[K]=t}function Ie(e){var t;return(t=e[K])!=null?t:{}}function et(e,t={}){const{version:o,defaultLocale:n,locales:l,strategy:a,trailingSlash:r,routesNameSeparator:c,defaultLocaleRouteNameSuffix:s,defaultDirection:i,baseUrl:f,routes:u,routeOptionsResolver:m}=ot(t),h=pe(l),p=h.map(E=>E.code),v=ye(p,c,s);Se(e,{locales:h,baseUrl:f,localeCodes:p});const Q=ve(u,{locales:l,defaultLocale:n,strategy:a,trailingSlash:r,routesNameSeparator:c,defaultLocaleRouteNameSuffix:s,optionsResolver:m});t.routes=Q;const _=tt(t,o);return Ae(_,{defaultLocale:n,localeCodes:p,strategy:a,trailingSlash:r,routesNameSeparator:c,defaultLocaleRouteNameSuffix:s,defaultDirection:i}),_.beforeEach((E,b,R)=>{const g=k(e),y=v(E)||g||n||"";g!==y&&ge(e,y),R()}),_}function tt(e,t){if(d.isVue3&&t===4)return L.createRouter(e);if(d.isVue2&&t===3)return new Ue.default(e);throw new Error("TODO:")}function Te(e){return new RegExp(`^/(${e.join("|")})(?:/|$)`,"i")}function ye(e,t,o){const n=`(${e.join("|")})`,l=`(?:${t}${o})?`,a=new RegExp(`${t}${n}${l}$`,"i"),r=Te(e);return s=>{if(oe(s)){if(s.name){const f=(T(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(T(s)){const i=s.match(r);if(i&&i.length>1)return i[1]}return""}}function ot(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:$,e.strategy=(n=e.strategy)!=null?n:V,e.trailingSlash=(l=e.trailingSlash)!=null?l:B,e.routesNameSeparator=(a=e.routesNameSeparator)!=null?a:j,e.defaultLocaleRouteNameSuffix=(r=e.defaultLocaleRouteNameSuffix)!=null?r:G,e.locales=(c=e.locales)!=null?c:[],e.defaultDirection=(s=e.defaultDirection)!=null?s:ee,e.baseUrl=(i=e.baseUrl)!=null?i:te,e.routes=(f=e.routes)!=null?f:[],e}function z(e,t,{defaultLocale:o=$,defaultDirection:n=ee,defaultLocaleRouteNameSuffix:l=G,routesNameSeparator:a=j,strategy:r=V,trailingSlash:c=B,localeCodes:s=[]}={}){const i=Ie(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 nt=new Set([P.PREFIX_AND_DEFAULT,P.PREFIX_EXCEPT_DEFAULT]);function O(e){const t=this.router,{routesNameSeparator:o}=z(t,this),n=e!=null?d.isRef(e)?d.unref(e):e:this.route;return n.name?_e(n.name).split(o)[0]:void 0}function H(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 q(e,t){const o=F.call(this,e,t);return o==null?void 0:d.isVue3?o:o.route}function ae(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||k(n),{routesNameSeparator:a,defaultLocale:r,defaultLocaleRouteNameSuffix:c,strategy:s,trailingSlash:i}=z(o,this);let f=e;T(e)&&(f[0]==="/"?f={path:e}:f={name:e});let u=me({},f);if(u.path&&!u.name){const h=o.resolve(u),p=d.isVue3?h:h.route,v=O.call(this,p);T(v)?u={name:he(v,l,{defaultLocale:r,strategy:s,routesNameSeparator:a,defaultLocaleRouteNameSuffix:c}),params:p.params,query:p.query,hash:p.hash}:(!(l===r&&nt.has(s))&&s!==P.NO_PREFIX&&(u.path=`/${l}${u.path}`),u.path=i?Ge(u.path,!0):je(u.path,!0))}else{u.name=he(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 m=o.resolve(u);return(d.isVue3?m.name:m.route.name)?m:o.resolve(e)}function x(e){const t=this.route,o=O.call(this,t);if(!o)return"";const s=!d.isVue3&&d.isRef(t)?t.value:t,{params:n}=s,l=fe(s,["params"]),a={},r=me({},l,{name:o,params:w(I(I({},n),a),{0:n.pathMatch})});return H.call(this,r,e)}function le({addDirAttribute:e=!1,addSeoAttributes:t=!1}={}){const o=this.router,n=this.i18n,{defaultDirection:l}=z(o,this),a={htmlAttrs:{},link:[],meta:[]};if(n.locales==null||n.__baseUrl==null)return a;const r=k(n),c=Me(n),s=pe(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),at.call(this,c,n.__baseUrl,a.link),lt.call(this,n.__baseUrl,a.link,t),rt(s,i,a.meta),ct(c,i,a.meta)),a}function at(e,t,o){const n=this.router,{defaultLocale:l,strategy:a}=z(n,this);if(a===P.NO_PREFIX)return;const r=new Map;for(const c of e){const s=c.iso;if(!s){Le("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=x.call(this,s.code);i&&o.push({hid:`i18n-alt-${c}`,rel:"alternate",href:Z(i,t),hreflang:c})}if(l){const c=x.call(this,l);c&&o.push({hid:"i18n-xd",rel:"alternate",href:Z(c,t),hreflang:"x-default"})}}function lt(e,t,o){const n=this.route,l=q.call(this,w(I({},n),{name:O.call(this,n)}));if(l){let a=Z(l.path,e);const r=oe(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];Ne(u)?u.forEach(m=>s.append(f,m||"")):s.append(f,u||"")}const i=s.toString();i&&(a=`${a}?${i}`)}t.push({hid:"i18n-can",rel:"canonical",href:a})}}function rt(e,t,o){!(e&&t)||o.push({hid:"i18n-og",property:"og:locale",content:Pe(t)})}function ct(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 Z(e,t){return e.match(/^https?:\/\//)?e:t+e}function W(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 st(e=L.useRoute(),{router:t=L.useRouter(),routesNameSeparator:o=void 0}={}){const n={router:t,route:e,routesNameSeparator:o};return O.call(n,e)}function ut({router:e=L.useRouter(),route:t=L.useRoute(),i18n:o=U.useI18n(),defaultLocale:n=void 0,defaultLocaleRouteNameSuffix:l=void 0,routesNameSeparator:a=void 0,strategy:r=void 0,trailingSlash:c=void 0}={}){return W({router:e,route:t,i18n:o,defaultLocale:n,defaultLocaleRouteNameSuffix:l,routesNameSeparator:a,strategy:r,trailingSlash:c},H)}function it({router:e=L.useRouter(),route:t=L.useRoute(),i18n:o=U.useI18n(),defaultLocale:n=void 0,defaultLocaleRouteNameSuffix:l=void 0,routesNameSeparator:a=void 0,strategy:r=void 0,trailingSlash:c=void 0}={}){return W({router:e,route:t,i18n:o,defaultLocale:n,defaultLocaleRouteNameSuffix:l,routesNameSeparator:a,strategy:r,trailingSlash:c},q)}function ft({router:e=L.useRouter(),route:t=L.useRoute(),i18n:o=U.useI18n(),defaultLocale:n=void 0,defaultLocaleRouteNameSuffix:l=void 0,routesNameSeparator:a=void 0,strategy:r=void 0,trailingSlash:c=void 0}={}){return W({router:e,route:t,i18n:o,defaultLocale:n,defaultLocaleRouteNameSuffix:l,routesNameSeparator:a,strategy:r,trailingSlash:c},ae)}function dt({router:e=L.useRouter(),route:t=L.useRoute(),i18n:o=U.useI18n(),defaultLocale:n=void 0,defaultLocaleRouteNameSuffix:l=void 0,routesNameSeparator:a=void 0,strategy:r=void 0,trailingSlash:c=void 0}={}){return W({router:e,route:t,i18n:o,defaultLocale:n,defaultLocaleRouteNameSuffix:l,routesNameSeparator:a,strategy:r,trailingSlash:c},x)}function ht({addDirAttribute:e=!1,addSeoAttributes:t=!1,strategy:o=void 0,defaultLocale:n=void 0,route:l=L.useRoute(),router:a=L.useRouter(),i18n:r=U.useI18n()}={}){const c=a,s=d.ref({htmlAttrs:{},link:[],meta:[]});function i(){s.value={htmlAttrs:{},link:[],meta:[]}}function f(u){s.value=Reflect.apply(le,{router:a,route:u,i18n:r,defaultLocale:n,strategy:o},[{addDirAttribute:e,addSeoAttributes:t}])}if(Xe)if(d.isVue3){const u=d.watchEffect(()=>{i(),f(de(c.currentRoute))});d.onUnmounted(()=>u())}else{const u=c.afterEach((m,h)=>{i(),f(m)});d.onUnmounted(()=>u()),f(l)}else f(de(c.currentRoute));return s}const mt="0.0.0";exports.DEFAULT_BASE_URL=te;exports.DEFAULT_DETECTION_DIRECTION=ee;exports.DEFAULT_LOCALE=$;exports.DEFAULT_LOCALE_ROUTE_NAME_SUFFIX=G;exports.DEFAULT_ROUTES_NAME_SEPARATOR=j;exports.DEFAULT_STRATEGY=V;exports.DEFAULT_TRAILING_SLASH=B;exports.STRATEGIES=P;exports.VERSION=mt;exports.createLocaleFromRouteGetter=ye;exports.createRouter=et;exports.extendI18n=Se;exports.findBrowserLocale=Qe;exports.getGlobalOptions=Ie;exports.getLocale=k;exports.getLocalesRegex=Te;exports.getRouteBaseName=O;exports.localeHead=le;exports.localeLocation=ae;exports.localePath=H;exports.localeRoute=q;exports.localizeRoutes=ve;exports.proxyVueInstance=S;exports.registerGlobalOptions=Ae;exports.resolveBaseUrl=Ee;exports.resolveRoute=F;exports.setLocale=ge;exports.switchLocalePath=x;exports.useLocaleHead=ht;exports.useLocaleLocation=ft;exports.useLocalePath=ut;exports.useLocaleRoute=it;exports.useRouteBaseName=st;exports.useSwitchLocalePath=dt; |
@@ -167,2 +167,4 @@ import type { Composer } from '@intlify/vue-i18n-bridge'; | ||
export declare function getLocalesRegex(localeCodes: string[]): RegExp; | ||
export declare function getRouteBaseName(this: RoutingProxy, givenRoute?: Route | RouteLocationNormalizedLoaded): string | undefined; | ||
@@ -169,0 +171,0 @@ |
@@ -946,2 +946,2 @@ var __defProp = Object.defineProperty; | ||
const VERSION = "0.0.0"; | ||
export { DEFAULT_BASE_URL, DEFAULT_DETECTION_DIRECTION, DEFAULT_LOCALE, DEFAULT_LOCALE_ROUTE_NAME_SUFFIX, DEFAULT_ROUTES_NAME_SEPARATOR, DEFAULT_STRATEGY, DEFAULT_TRAILING_SLASH, STRATEGIES, VERSION, createLocaleFromRouteGetter, createRouter, extendI18n, findBrowserLocale, getGlobalOptions, getLocale, getRouteBaseName, localeHead, localeLocation, localePath, localeRoute, localizeRoutes, proxyVueInstance, registerGlobalOptions, resolveBaseUrl, resolveRoute, setLocale, switchLocalePath, useLocaleHead, useLocaleLocation, useLocalePath, useLocaleRoute, useRouteBaseName, useSwitchLocalePath }; | ||
export { DEFAULT_BASE_URL, DEFAULT_DETECTION_DIRECTION, DEFAULT_LOCALE, DEFAULT_LOCALE_ROUTE_NAME_SUFFIX, DEFAULT_ROUTES_NAME_SEPARATOR, DEFAULT_STRATEGY, DEFAULT_TRAILING_SLASH, STRATEGIES, VERSION, createLocaleFromRouteGetter, createRouter, extendI18n, findBrowserLocale, getGlobalOptions, getLocale, getLocalesRegex, getRouteBaseName, localeHead, localeLocation, localePath, localeRoute, localizeRoutes, proxyVueInstance, registerGlobalOptions, resolveBaseUrl, resolveRoute, setLocale, switchLocalePath, useLocaleHead, useLocaleLocation, useLocalePath, useLocaleRoute, useRouteBaseName, useSwitchLocalePath }; |
@@ -1,5 +0,5 @@ | ||
var VueI18nRouting=function(i,d,L,g){"use strict";var ht=Object.defineProperty,Lt=Object.defineProperties;var _t=Object.getOwnPropertyDescriptors;var W=Object.getOwnPropertySymbols;var Pe=Object.prototype.hasOwnProperty,ye=Object.prototype.propertyIsEnumerable;var Ie=(i,d,L)=>d in i?ht(i,d,{enumerable:!0,configurable:!0,writable:!0,value:L}):i[d]=L,O=(i,d)=>{for(var L in d||(d={}))Pe.call(d,L)&&Ie(i,L,d[L]);if(W)for(var L of W(d))ye.call(d,L)&&Ie(i,L,d[L]);return i},Q=(i,d)=>Lt(i,_t(d));var Oe=(i,d)=>{var L={};for(var g in i)Pe.call(i,g)&&d.indexOf(g)<0&&(L[g]=i[g]);if(i!=null&&W)for(var g of W(i))d.indexOf(g)<0&&ye.call(i,g)&&(L[g]=i[g]);return L};function Ue(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var Ce=Ue(L);const U={PREFIX:"prefix",PREFIX_EXCEPT_DEFAULT:"prefix_except_default",PREFIX_AND_DEFAULT:"prefix_and_default",NO_PREFIX:"no_prefix"},j="",V=U.PREFIX_EXCEPT_DEFAULT,G=!1,D="___",B="default",Y="ltr",J="";/*! | ||
var VueI18nRouting=function(r,d,L,g){"use strict";var ht=Object.defineProperty,Lt=Object.defineProperties;var _t=Object.getOwnPropertyDescriptors;var W=Object.getOwnPropertySymbols;var ye=Object.prototype.hasOwnProperty,Oe=Object.prototype.propertyIsEnumerable;var Pe=(r,d,L)=>d in r?ht(r,d,{enumerable:!0,configurable:!0,writable:!0,value:L}):r[d]=L,O=(r,d)=>{for(var L in d||(d={}))ye.call(d,L)&&Pe(r,L,d[L]);if(W)for(var L of W(d))Oe.call(d,L)&&Pe(r,L,d[L]);return r},Q=(r,d)=>Lt(r,_t(d));var Ue=(r,d)=>{var L={};for(var g in r)ye.call(r,g)&&d.indexOf(g)<0&&(L[g]=r[g]);if(r!=null&&W)for(var g of W(r))d.indexOf(g)<0&&Oe.call(r,g)&&(L[g]=r[g]);return L};function Ce(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var Fe=Ce(L);const U={PREFIX:"prefix",PREFIX_EXCEPT_DEFAULT:"prefix_except_default",PREFIX_AND_DEFAULT:"prefix_and_default",NO_PREFIX:"no_prefix"},j="",V=U.PREFIX_EXCEPT_DEFAULT,G=!1,D="___",B="default",Y="ltr",J="";/*! | ||
* shared v9.2.0-beta.35 | ||
* (c) 2022 kazuya kawaguchi | ||
* Released under the MIT License. | ||
*/const Fe=typeof Symbol=="function"&&typeof Symbol.toStringTag=="symbol",be=e=>Fe?Symbol(e):e,se=Object.assign,Ne=Array.isArray,we=e=>typeof e=="function",I=e=>typeof e=="string",$e=e=>typeof e=="boolean",ve=e=>typeof e=="symbol",K=e=>e!==null&&typeof e=="object",je=/\/$|\/\?/;function Z(e="",t=!1){return t?je.test(e):e.endsWith("/")}function Ve(e="",t=!1){if(!t)return(Z(e)?e.slice(0,-1):e)||"/";if(!Z(e,!0))return e||"/";const[o,...n]=e.split("?");return(o.slice(0,-1)||"/")+(n.length?`?${n.join("?")}`:"")}function Ge(e="",t=!1){if(!t)return e.endsWith("/")?e:e+"/";if(Z(e,!0))return e||"/";const[o,...n]=e.split("?");return o+"/"+(n.length?`?${n.join("?")}`:"")}const De=typeof window!="undefined";function re(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)I(o)?t.push({code:o}):t.push(o);return t}function X(e){return e!=null&&"global"in e&&"mode"in e}function M(e){return e!=null&&!("__composer"in e)&&d.isRef(e.locale)}function N(e){return e!=null&&"__composer"in e}function ee(e){return e!=null&&!("__composer"in e)&&!d.isRef(e.locale)}function C(e){return e!=null&&("__VUE_I18N_BRIDGE__"in e||"_sync"in e)}function ue(e){return X(e)?M(e.global)?e.global:e.global.__composer:N(e)?e.__composer:e}function k(e){const t=X(e)?e.global:e;return M(t)?d.isVue2&&C(e)?e.locale:t.locale.value:(ee(t)||N(t)||C(t),t.locale)}function Be(e){const t=X(e)?e.global:e;return M(t)?d.isVue2&&C(e)?e.locales:t.locales.value:(ee(t)||N(t)||C(t),t.locales)}function fe(e,t){const o=X(e)?e.global:e;if(M(o))d.isVue2&&C(e)?e.locale=t:o.locale.value=t;else if(ee(o)||N(o)||C(o))o.locale=t;else throw new Error("TODO:")}function Xe(e,t,o){return e.replace(/\/+$/,"")+(t?"/":"")||(o?"":"/")}function de(e){return L.isVueRouter4,d.isRef(e)?e.value:e}function he(e){return I(e)?e:ve(e)?e.toString():"(null)"}function Le(e,t,{defaultLocale:o,strategy:n,routesNameSeparator:l,defaultLocaleRouteNameSuffix:a}){let c=he(e)+(n==="no_prefix"?"":l+t);return t===o&&n==="prefix_and_default"&&(c+=l+a),c}function _e(e,t){return we(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 ke=Me;function ze(e,t){return e.score===t.score?t.code.length-e.code.length:t.score-e.score}const He=ze;function xe(e,t,{matcher:o=ke,comparer:n=He}={}){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:""}function T(e){return function(){return Reflect.apply(e,{getRouteBaseName:this.getRouteBaseName,localePath:this.localePath,localeRoute:this.localeRoute,localeLocation:this.localeLocation,resolveRoute:this.resolveRoute,switchLocalePath:this.switchLocalePath,localeHead:this.localeHead,i18n:this.$i18n,route:this.$route,router:this.$router},arguments)}}function ge(e,{locales:t=[],localeCodes:o=[],baseUrl:n=J,hooks:l={}}={}){const a=d.effectScope(),c=e.install;return e.install=(s,...r)=>{Reflect.apply(c,e,[s,...r]);const f=ue(e);a.run(()=>qe(f,{locales:t,localeCodes:o,baseUrl:n,hooks:l})),N(e.global)&&Qe(e.global,l.onExtendVueI18n);const h=s,u=e.mode==="composition"?d.isVue3?h.config.globalProperties.$i18n:e:d.isVue2?e:null;if(u&&We(u,f,l.onExtendExportedGlobal),(Ye(r[0])?r[0]:{inject:!0}).inject&&s.mixin({methods:{resolveRoute:T(w),localePath:T(H),localeRoute:T(x),localeLocation:T(oe),switchLocalePath:T($),getRouteBaseName:T(F),localeHead:T(ne)}}),h.unmount){const _=h.unmount;h.unmount=()=>{a.stop(),_()}}},a}function qe(e,t){const{locales:o,localeCodes:n,baseUrl:l}=t,a=d.ref(o),c=d.ref(n);e.locales=d.computed(()=>a.value),e.localeCodes=d.computed(()=>c.value),e.__baseUrl=_e(l,{}),t.hooks&&t.hooks.onExtendComposer&&t.hooks.onExtendComposer(e)}function We(e,t,o){const n=[{locales:{get(){return t.locales.value}},localeCodes:{get(){return t.localeCodes.value}},__baseUrl:{get(){return t.__baseUrl}}}];o&&n.push(o(t));for(const l of n)for(const[a,c]of Object.entries(l))Object.defineProperty(e,a,c)}function Qe(e,t){const o=ue(e),n=[{locales:{get(){return o.locales.value}},localeCodes:{get(){return o.localeCodes.value}},__baseUrl:{get(){return o.__baseUrl}}}];t&&n.push(t(o));for(const l of n)for(const[a,c]of Object.entries(l))Object.defineProperty(e,a,c)}function Ye(e){return K(e)&&"inject"in e&&$e(e.inject)}function Re(e,{defaultLocale:t=j,strategy:o=V,trailingSlash:n=G,routesNameSeparator:l=D,defaultLocaleRouteNameSuffix:a=B,includeUprefixedFallback:c=!1,optionsResolver:s=void 0,locales:r=[]}={}){if(o==="no_prefix")return e;const f=r.map(u=>I(u)?u:u.code);function h(u,R,_=!1,m=!1){if(u.redirect&&(!u.component||!u.file))return[u];let P=null;return s!=null&&(P=s(u,R),P==null)?[u]:R.reduce((S,A)=>{const{name:v}=u;let{path:p}=u;const E=O({},u);v&&(E.name=`${v}${l}${A}`),u.children&&(E.children=u.children.reduce((y,ce)=>[...y,...h(ce,[A],!0,m)],[]));const b=A===t;if(b&&o==="prefix_and_default")if(_)_&&m&&v&&(E.name+=`${l}${a}`);else{const y=Q(O({},E),{path:p});if(v&&(y.name=`${E.name}${l}${a}`),u.children){y.children=[];for(const ce of u.children)y.children=y.children.concat(h(ce,[A],!0,!0))}S.push(y)}const Ae=_&&!p.startsWith("/"),Te=!Ae&&!(b&&o==="prefix_except_default");return Te&&(p=`/${A}${p}`),p&&(p=Xe(p,n,Ae)),Te&&b&&o==="prefix"&&c&&S.push(O({},u)),E.path=p,S.push(E),S},[])}return e.reduce((u,R)=>[...u,...h(R,f||[])],[])}const te=be("vue-i18n-routing-gor");function me(e,t){e[te]?re("already registered global options"):e[te]=t}function pe(e){var t;return(t=e[te])!=null?t:{}}function Je(e,t={}){const{version:o,defaultLocale:n,locales:l,strategy:a,trailingSlash:c,routesNameSeparator:s,defaultLocaleRouteNameSuffix:r,defaultDirection:f,baseUrl:h,routes:u,routeOptionsResolver:R}=et(t),_=ie(l),m=_.map(A=>A.code),P=Ee(m,s,r);ge(e,{locales:_,baseUrl:h,localeCodes:m});const le=Re(u,{locales:l,defaultLocale:n,strategy:a,trailingSlash:c,routesNameSeparator:s,defaultLocaleRouteNameSuffix:r,optionsResolver:R});t.routes=le;const S=Ke(t,o);return me(S,{defaultLocale:n,localeCodes:m,strategy:a,trailingSlash:c,routesNameSeparator:s,defaultLocaleRouteNameSuffix:r,defaultDirection:f}),S.beforeEach((A,v,p)=>{const E=k(e),b=P(A)||E||n||"";E!==b&&fe(e,b),p()}),S}function Ke(e,t){if(d.isVue3&&t===4)return L.createRouter(e);if(d.isVue2&&t===3)return new Ce.default(e);throw new Error("TODO:")}function Ze(e){return new RegExp(`^/(${e.join("|")})(?:/|$)`,"i")}function Ee(e,t,o){const n=`(${e.join("|")})`,l=`(?:${t}${o})?`,a=new RegExp(`${t}${n}${l}$`,"i"),c=Ze(e);return r=>{if(K(r)){if(r.name){const h=(I(r.name)?r.name:r.name.toString()).match(a);if(h&&h.length>1)return h[1]}else if(r.path){const f=r.path.match(c);if(f&&f.length>1)return f[1]}}else if(I(r)){const f=r.match(c);if(f&&f.length>1)return f[1]}return""}}function et(e){var t,o,n,l,a,c,s,r,f,h;return e.version=(t=e.version)!=null?t:4,e.defaultLocale=(o=e.defaultLocale)!=null?o:j,e.strategy=(n=e.strategy)!=null?n:V,e.trailingSlash=(l=e.trailingSlash)!=null?l:G,e.routesNameSeparator=(a=e.routesNameSeparator)!=null?a:D,e.defaultLocaleRouteNameSuffix=(c=e.defaultLocaleRouteNameSuffix)!=null?c:B,e.locales=(s=e.locales)!=null?s:[],e.defaultDirection=(r=e.defaultDirection)!=null?r:Y,e.baseUrl=(f=e.baseUrl)!=null?f:J,e.routes=(h=e.routes)!=null?h:[],e}function z(e,t,{defaultLocale:o=j,defaultDirection:n=Y,defaultLocaleRouteNameSuffix:l=B,routesNameSeparator:a=D,strategy:c=V,trailingSlash:s=G,localeCodes:r=[]}={}){const f=pe(e);return{defaultLocale:t.defaultLocale||f.defaultLocale||o,defaultDirection:t.defaultDirection||f.defaultDirection||n,defaultLocaleRouteNameSuffix:t.defaultLocaleRouteNameSuffix||f.defaultLocaleRouteNameSuffix||l,routesNameSeparator:t.routesNameSeparator||f.routesNameSeparator||a,strategy:t.strategy||f.strategy||c,trailingSlash:t.trailingSlash||f.trailingSlash||s,localeCodes:t.localeCodes||f.localeCodes||r}}const tt=new Set([U.PREFIX_AND_DEFAULT,U.PREFIX_EXCEPT_DEFAULT]);function F(e){const t=this.router,{routesNameSeparator:o}=z(t,this),n=e!=null?d.isRef(e)?d.unref(e):e:this.route;return n.name?he(n.name).split(o)[0]:void 0}function H(e,t){const o=w.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=w.call(this,e,t);return o==null?void 0:d.isVue3?o:o.route}function oe(e,t){const o=w.call(this,e,t);return o==null?void 0:d.isVue3?o:o.location}function w(e,t){const o=this.router,n=this.i18n,l=t||k(n),{routesNameSeparator:a,defaultLocale:c,defaultLocaleRouteNameSuffix:s,strategy:r,trailingSlash:f}=z(o,this);let h=e;I(e)&&(h[0]==="/"?h={path:e}:h={name:e});let u=se({},h);if(u.path&&!u.name){const _=o.resolve(u),m=d.isVue3?_:_.route,P=F.call(this,m);I(P)?u={name:Le(P,l,{defaultLocale:c,strategy:r,routesNameSeparator:a,defaultLocaleRouteNameSuffix:s}),params:m.params,query:m.query,hash:m.hash}:(!(l===c&&tt.has(r))&&r!==U.NO_PREFIX&&(u.path=`/${l}${u.path}`),u.path=f?Ge(u.path,!0):Ve(u.path,!0))}else{u.name=Le(u.name,l,{defaultLocale:c,strategy:r,routesNameSeparator:a,defaultLocaleRouteNameSuffix:s});const{params:_}=u;_&&_["0"]===void 0&&_.pathMatch&&(_["0"]=_.pathMatch)}const R=o.resolve(u);return(d.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 r=!d.isVue3&&d.isRef(t)?t.value:t,{params:n}=r,l=Oe(r,["params"]),a={},c=se({},l,{name:o,params:Q(O(O({},n),a),{0:n.pathMatch})});return H.call(this,c,e)}function ne({addDirAttribute:e=!1,addSeoAttributes:t=!1}={}){const o=this.router,n=this.i18n,{defaultDirection:l}=z(o,this),a={htmlAttrs:{},link:[],meta:[]};if(n.locales==null||n.__baseUrl==null)return a;const c=k(n),s=Be(n),r=ie(s).find(u=>u.code===c)||{code:c},f=r.iso,h=r.dir||l;return e&&(a.htmlAttrs.dir=h),t&&c&&n.locales&&(f&&(a.htmlAttrs.lang=f),ot.call(this,s,n.__baseUrl,a.link),nt.call(this,n.__baseUrl,a.link,t),at(r,f,a.meta),lt(s,f,a.meta)),a}function ot(e,t,o){const n=this.router,{defaultLocale:l,strategy:a}=z(n,this);if(a===U.NO_PREFIX)return;const c=new Map;for(const s of e){const r=s.iso;if(!r){re("Locale ISO code is required to generate alternate link");continue}const[f,h]=r.split("-");f&&h&&(s.isCatchallLocale||!c.has(f))&&c.set(f,s),c.set(r,s)}for(const[s,r]of c.entries()){const f=$.call(this,r.code);f&&o.push({hid:`i18n-alt-${s}`,rel:"alternate",href:ae(f,t),hreflang:s})}if(l){const s=$.call(this,l);s&&o.push({hid:"i18n-xd",rel:"alternate",href:ae(s,t),hreflang:"x-default"})}}function nt(e,t,o){const n=this.route,l=x.call(this,Q(O({},n),{name:F.call(this,n)}));if(l){let a=ae(l.path,e);const c=K(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];Ne(u)?u.forEach(R=>r.append(h,R||"")):r.append(h,u||"")}const f=r.toString();f&&(a=`${a}?${f}`)}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:Se(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:Se(a.iso)}));o.push(...l)}}function Se(e){return(e||"").replace(/-/g,"_")}function ae(e,t){return e.match(/^https?:\/\//)?e:t+e}function q(e,t){const{router:o,route:n,i18n:l,defaultLocale:a,strategy:c,defaultLocaleRouteNameSuffix:s,trailingSlash:r,routesNameSeparator:f}=e;return function(...h){return Reflect.apply(t,{router:o,route:n,i18n:l,defaultLocale:a,strategy:c,defaultLocaleRouteNameSuffix:s,trailingSlash:r,routesNameSeparator:f},h)}}function ct(e=L.useRoute(),{router:t=L.useRouter(),routesNameSeparator:o=void 0}={}){const n={router:t,route:e,routesNameSeparator:o};return F.call(n,e)}function st({router:e=L.useRouter(),route:t=L.useRoute(),i18n:o=g.useI18n(),defaultLocale:n=void 0,defaultLocaleRouteNameSuffix:l=void 0,routesNameSeparator:a=void 0,strategy:c=void 0,trailingSlash:s=void 0}={}){return q({router:e,route:t,i18n:o,defaultLocale:n,defaultLocaleRouteNameSuffix:l,routesNameSeparator:a,strategy:c,trailingSlash:s},H)}function rt({router:e=L.useRouter(),route:t=L.useRoute(),i18n:o=g.useI18n(),defaultLocale:n=void 0,defaultLocaleRouteNameSuffix:l=void 0,routesNameSeparator:a=void 0,strategy:c=void 0,trailingSlash:s=void 0}={}){return q({router:e,route:t,i18n:o,defaultLocale:n,defaultLocaleRouteNameSuffix:l,routesNameSeparator:a,strategy:c,trailingSlash:s},x)}function it({router:e=L.useRouter(),route:t=L.useRoute(),i18n:o=g.useI18n(),defaultLocale:n=void 0,defaultLocaleRouteNameSuffix:l=void 0,routesNameSeparator:a=void 0,strategy:c=void 0,trailingSlash:s=void 0}={}){return q({router:e,route:t,i18n:o,defaultLocale:n,defaultLocaleRouteNameSuffix:l,routesNameSeparator:a,strategy:c,trailingSlash:s},oe)}function ut({router:e=L.useRouter(),route:t=L.useRoute(),i18n:o=g.useI18n(),defaultLocale:n=void 0,defaultLocaleRouteNameSuffix:l=void 0,routesNameSeparator:a=void 0,strategy:c=void 0,trailingSlash:s=void 0}={}){return q({router:e,route:t,i18n:o,defaultLocale:n,defaultLocaleRouteNameSuffix:l,routesNameSeparator:a,strategy:c,trailingSlash:s},$)}function ft({addDirAttribute:e=!1,addSeoAttributes:t=!1,strategy:o=void 0,defaultLocale:n=void 0,route:l=L.useRoute(),router:a=L.useRouter(),i18n:c=g.useI18n()}={}){const s=a,r=d.ref({htmlAttrs:{},link:[],meta:[]});function f(){r.value={htmlAttrs:{},link:[],meta:[]}}function h(u){r.value=Reflect.apply(ne,{router:a,route:u,i18n:c,defaultLocale:n,strategy:o},[{addDirAttribute:e,addSeoAttributes:t}])}if(De)if(d.isVue3){const u=d.watchEffect(()=>{f(),h(de(s.currentRoute))});d.onUnmounted(()=>u())}else{const u=s.afterEach((R,_)=>{f(),h(R)});d.onUnmounted(()=>u()),h(l)}else h(de(s.currentRoute));return r}const dt="0.0.0";return i.DEFAULT_BASE_URL=J,i.DEFAULT_DETECTION_DIRECTION=Y,i.DEFAULT_LOCALE=j,i.DEFAULT_LOCALE_ROUTE_NAME_SUFFIX=B,i.DEFAULT_ROUTES_NAME_SEPARATOR=D,i.DEFAULT_STRATEGY=V,i.DEFAULT_TRAILING_SLASH=G,i.STRATEGIES=U,i.VERSION=dt,i.createLocaleFromRouteGetter=Ee,i.createRouter=Je,i.extendI18n=ge,i.findBrowserLocale=xe,i.getGlobalOptions=pe,i.getLocale=k,i.getRouteBaseName=F,i.localeHead=ne,i.localeLocation=oe,i.localePath=H,i.localeRoute=x,i.localizeRoutes=Re,i.proxyVueInstance=T,i.registerGlobalOptions=me,i.resolveBaseUrl=_e,i.resolveRoute=w,i.setLocale=fe,i.switchLocalePath=$,i.useLocaleHead=ft,i.useLocaleLocation=it,i.useLocalePath=st,i.useLocaleRoute=rt,i.useRouteBaseName=ct,i.useSwitchLocalePath=ut,Object.defineProperties(i,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),i}({},VueDemi,VueRouter,VueI18n); | ||
*/const be=typeof Symbol=="function"&&typeof Symbol.toStringTag=="symbol",Ne=e=>be?Symbol(e):e,se=Object.assign,we=Array.isArray,$e=e=>typeof e=="function",I=e=>typeof e=="string",ve=e=>typeof e=="boolean",je=e=>typeof e=="symbol",K=e=>e!==null&&typeof e=="object",Ve=/\/$|\/\?/;function Z(e="",t=!1){return t?Ve.test(e):e.endsWith("/")}function Ge(e="",t=!1){if(!t)return(Z(e)?e.slice(0,-1):e)||"/";if(!Z(e,!0))return e||"/";const[o,...n]=e.split("?");return(o.slice(0,-1)||"/")+(n.length?`?${n.join("?")}`:"")}function De(e="",t=!1){if(!t)return e.endsWith("/")?e:e+"/";if(Z(e,!0))return e||"/";const[o,...n]=e.split("?");return o+"/"+(n.length?`?${n.join("?")}`:"")}const Be=typeof window!="undefined";function re(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)I(o)?t.push({code:o}):t.push(o);return t}function X(e){return e!=null&&"global"in e&&"mode"in e}function M(e){return e!=null&&!("__composer"in e)&&d.isRef(e.locale)}function N(e){return e!=null&&"__composer"in e}function ee(e){return e!=null&&!("__composer"in e)&&!d.isRef(e.locale)}function C(e){return e!=null&&("__VUE_I18N_BRIDGE__"in e||"_sync"in e)}function ue(e){return X(e)?M(e.global)?e.global:e.global.__composer:N(e)?e.__composer:e}function k(e){const t=X(e)?e.global:e;return M(t)?d.isVue2&&C(e)?e.locale:t.locale.value:(ee(t)||N(t)||C(t),t.locale)}function Xe(e){const t=X(e)?e.global:e;return M(t)?d.isVue2&&C(e)?e.locales:t.locales.value:(ee(t)||N(t)||C(t),t.locales)}function fe(e,t){const o=X(e)?e.global:e;if(M(o))d.isVue2&&C(e)?e.locale=t:o.locale.value=t;else if(ee(o)||N(o)||C(o))o.locale=t;else throw new Error("TODO:")}function Me(e,t,o){return e.replace(/\/+$/,"")+(t?"/":"")||(o?"":"/")}function de(e){return L.isVueRouter4,d.isRef(e)?e.value:e}function he(e){return I(e)?e:je(e)?e.toString():"(null)"}function Le(e,t,{defaultLocale:o,strategy:n,routesNameSeparator:l,defaultLocaleRouteNameSuffix:a}){let c=he(e)+(n==="no_prefix"?"":l+t);return t===o&&n==="prefix_and_default"&&(c+=l+a),c}function _e(e,t){return $e(e)?e(t):e}function ke(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 ze=ke;function He(e,t){return e.score===t.score?t.code.length-e.code.length:t.score-e.score}const xe=He;function qe(e,t,{matcher:o=ze,comparer:n=xe}={}){const l=[];for(const c of e){const{code:s}=c,i=c.iso||s;l.push({code:s,iso:i})}const a=o(l,t);return a.length>1&&a.sort(n),a.length?a[0].code:""}function T(e){return function(){return Reflect.apply(e,{getRouteBaseName:this.getRouteBaseName,localePath:this.localePath,localeRoute:this.localeRoute,localeLocation:this.localeLocation,resolveRoute:this.resolveRoute,switchLocalePath:this.switchLocalePath,localeHead:this.localeHead,i18n:this.$i18n,route:this.$route,router:this.$router},arguments)}}function ge(e,{locales:t=[],localeCodes:o=[],baseUrl:n=J,hooks:l={}}={}){const a=d.effectScope(),c=e.install;return e.install=(s,...i)=>{Reflect.apply(c,e,[s,...i]);const f=ue(e);a.run(()=>We(f,{locales:t,localeCodes:o,baseUrl:n,hooks:l})),N(e.global)&&Ye(e.global,l.onExtendVueI18n);const h=s,u=e.mode==="composition"?d.isVue3?h.config.globalProperties.$i18n:e:d.isVue2?e:null;if(u&&Qe(u,f,l.onExtendExportedGlobal),(Je(i[0])?i[0]:{inject:!0}).inject&&s.mixin({methods:{resolveRoute:T(w),localePath:T(H),localeRoute:T(x),localeLocation:T(oe),switchLocalePath:T($),getRouteBaseName:T(F),localeHead:T(ne)}}),h.unmount){const _=h.unmount;h.unmount=()=>{a.stop(),_()}}},a}function We(e,t){const{locales:o,localeCodes:n,baseUrl:l}=t,a=d.ref(o),c=d.ref(n);e.locales=d.computed(()=>a.value),e.localeCodes=d.computed(()=>c.value),e.__baseUrl=_e(l,{}),t.hooks&&t.hooks.onExtendComposer&&t.hooks.onExtendComposer(e)}function Qe(e,t,o){const n=[{locales:{get(){return t.locales.value}},localeCodes:{get(){return t.localeCodes.value}},__baseUrl:{get(){return t.__baseUrl}}}];o&&n.push(o(t));for(const l of n)for(const[a,c]of Object.entries(l))Object.defineProperty(e,a,c)}function Ye(e,t){const o=ue(e),n=[{locales:{get(){return o.locales.value}},localeCodes:{get(){return o.localeCodes.value}},__baseUrl:{get(){return o.__baseUrl}}}];t&&n.push(t(o));for(const l of n)for(const[a,c]of Object.entries(l))Object.defineProperty(e,a,c)}function Je(e){return K(e)&&"inject"in e&&ve(e.inject)}function Re(e,{defaultLocale:t=j,strategy:o=V,trailingSlash:n=G,routesNameSeparator:l=D,defaultLocaleRouteNameSuffix:a=B,includeUprefixedFallback:c=!1,optionsResolver:s=void 0,locales:i=[]}={}){if(o==="no_prefix")return e;const f=i.map(u=>I(u)?u:u.code);function h(u,R,_=!1,m=!1){if(u.redirect&&(!u.component||!u.file))return[u];let P=null;return s!=null&&(P=s(u,R),P==null)?[u]:R.reduce((S,A)=>{const{name:v}=u;let{path:p}=u;const E=O({},u);v&&(E.name=`${v}${l}${A}`),u.children&&(E.children=u.children.reduce((y,ce)=>[...y,...h(ce,[A],!0,m)],[]));const b=A===t;if(b&&o==="prefix_and_default")if(_)_&&m&&v&&(E.name+=`${l}${a}`);else{const y=Q(O({},E),{path:p});if(v&&(y.name=`${E.name}${l}${a}`),u.children){y.children=[];for(const ce of u.children)y.children=y.children.concat(h(ce,[A],!0,!0))}S.push(y)}const Te=_&&!p.startsWith("/"),Ie=!Te&&!(b&&o==="prefix_except_default");return Ie&&(p=`/${A}${p}`),p&&(p=Me(p,n,Te)),Ie&&b&&o==="prefix"&&c&&S.push(O({},u)),E.path=p,S.push(E),S},[])}return e.reduce((u,R)=>[...u,...h(R,f||[])],[])}const te=Ne("vue-i18n-routing-gor");function me(e,t){e[te]?re("already registered global options"):e[te]=t}function pe(e){var t;return(t=e[te])!=null?t:{}}function Ke(e,t={}){const{version:o,defaultLocale:n,locales:l,strategy:a,trailingSlash:c,routesNameSeparator:s,defaultLocaleRouteNameSuffix:i,defaultDirection:f,baseUrl:h,routes:u,routeOptionsResolver:R}=et(t),_=ie(l),m=_.map(A=>A.code),P=Se(m,s,i);ge(e,{locales:_,baseUrl:h,localeCodes:m});const le=Re(u,{locales:l,defaultLocale:n,strategy:a,trailingSlash:c,routesNameSeparator:s,defaultLocaleRouteNameSuffix:i,optionsResolver:R});t.routes=le;const S=Ze(t,o);return me(S,{defaultLocale:n,localeCodes:m,strategy:a,trailingSlash:c,routesNameSeparator:s,defaultLocaleRouteNameSuffix:i,defaultDirection:f}),S.beforeEach((A,v,p)=>{const E=k(e),b=P(A)||E||n||"";E!==b&&fe(e,b),p()}),S}function Ze(e,t){if(d.isVue3&&t===4)return L.createRouter(e);if(d.isVue2&&t===3)return new Fe.default(e);throw new Error("TODO:")}function Ee(e){return new RegExp(`^/(${e.join("|")})(?:/|$)`,"i")}function Se(e,t,o){const n=`(${e.join("|")})`,l=`(?:${t}${o})?`,a=new RegExp(`${t}${n}${l}$`,"i"),c=Ee(e);return i=>{if(K(i)){if(i.name){const h=(I(i.name)?i.name:i.name.toString()).match(a);if(h&&h.length>1)return h[1]}else if(i.path){const f=i.path.match(c);if(f&&f.length>1)return f[1]}}else if(I(i)){const f=i.match(c);if(f&&f.length>1)return f[1]}return""}}function et(e){var t,o,n,l,a,c,s,i,f,h;return e.version=(t=e.version)!=null?t:4,e.defaultLocale=(o=e.defaultLocale)!=null?o:j,e.strategy=(n=e.strategy)!=null?n:V,e.trailingSlash=(l=e.trailingSlash)!=null?l:G,e.routesNameSeparator=(a=e.routesNameSeparator)!=null?a:D,e.defaultLocaleRouteNameSuffix=(c=e.defaultLocaleRouteNameSuffix)!=null?c:B,e.locales=(s=e.locales)!=null?s:[],e.defaultDirection=(i=e.defaultDirection)!=null?i:Y,e.baseUrl=(f=e.baseUrl)!=null?f:J,e.routes=(h=e.routes)!=null?h:[],e}function z(e,t,{defaultLocale:o=j,defaultDirection:n=Y,defaultLocaleRouteNameSuffix:l=B,routesNameSeparator:a=D,strategy:c=V,trailingSlash:s=G,localeCodes:i=[]}={}){const f=pe(e);return{defaultLocale:t.defaultLocale||f.defaultLocale||o,defaultDirection:t.defaultDirection||f.defaultDirection||n,defaultLocaleRouteNameSuffix:t.defaultLocaleRouteNameSuffix||f.defaultLocaleRouteNameSuffix||l,routesNameSeparator:t.routesNameSeparator||f.routesNameSeparator||a,strategy:t.strategy||f.strategy||c,trailingSlash:t.trailingSlash||f.trailingSlash||s,localeCodes:t.localeCodes||f.localeCodes||i}}const tt=new Set([U.PREFIX_AND_DEFAULT,U.PREFIX_EXCEPT_DEFAULT]);function F(e){const t=this.router,{routesNameSeparator:o}=z(t,this),n=e!=null?d.isRef(e)?d.unref(e):e:this.route;return n.name?he(n.name).split(o)[0]:void 0}function H(e,t){const o=w.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=w.call(this,e,t);return o==null?void 0:d.isVue3?o:o.route}function oe(e,t){const o=w.call(this,e,t);return o==null?void 0:d.isVue3?o:o.location}function w(e,t){const o=this.router,n=this.i18n,l=t||k(n),{routesNameSeparator:a,defaultLocale:c,defaultLocaleRouteNameSuffix:s,strategy:i,trailingSlash:f}=z(o,this);let h=e;I(e)&&(h[0]==="/"?h={path:e}:h={name:e});let u=se({},h);if(u.path&&!u.name){const _=o.resolve(u),m=d.isVue3?_:_.route,P=F.call(this,m);I(P)?u={name:Le(P,l,{defaultLocale:c,strategy:i,routesNameSeparator:a,defaultLocaleRouteNameSuffix:s}),params:m.params,query:m.query,hash:m.hash}:(!(l===c&&tt.has(i))&&i!==U.NO_PREFIX&&(u.path=`/${l}${u.path}`),u.path=f?De(u.path,!0):Ge(u.path,!0))}else{u.name=Le(u.name,l,{defaultLocale:c,strategy:i,routesNameSeparator:a,defaultLocaleRouteNameSuffix:s});const{params:_}=u;_&&_["0"]===void 0&&_.pathMatch&&(_["0"]=_.pathMatch)}const R=o.resolve(u);return(d.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 i=!d.isVue3&&d.isRef(t)?t.value:t,{params:n}=i,l=Ue(i,["params"]),a={},c=se({},l,{name:o,params:Q(O(O({},n),a),{0:n.pathMatch})});return H.call(this,c,e)}function ne({addDirAttribute:e=!1,addSeoAttributes:t=!1}={}){const o=this.router,n=this.i18n,{defaultDirection:l}=z(o,this),a={htmlAttrs:{},link:[],meta:[]};if(n.locales==null||n.__baseUrl==null)return a;const c=k(n),s=Xe(n),i=ie(s).find(u=>u.code===c)||{code:c},f=i.iso,h=i.dir||l;return e&&(a.htmlAttrs.dir=h),t&&c&&n.locales&&(f&&(a.htmlAttrs.lang=f),ot.call(this,s,n.__baseUrl,a.link),nt.call(this,n.__baseUrl,a.link,t),at(i,f,a.meta),lt(s,f,a.meta)),a}function ot(e,t,o){const n=this.router,{defaultLocale:l,strategy:a}=z(n,this);if(a===U.NO_PREFIX)return;const c=new Map;for(const s of e){const i=s.iso;if(!i){re("Locale ISO code is required to generate alternate link");continue}const[f,h]=i.split("-");f&&h&&(s.isCatchallLocale||!c.has(f))&&c.set(f,s),c.set(i,s)}for(const[s,i]of c.entries()){const f=$.call(this,i.code);f&&o.push({hid:`i18n-alt-${s}`,rel:"alternate",href:ae(f,t),hreflang:s})}if(l){const s=$.call(this,l);s&&o.push({hid:"i18n-xd",rel:"alternate",href:ae(s,t),hreflang:"x-default"})}}function nt(e,t,o){const n=this.route,l=x.call(this,Q(O({},n),{name:F.call(this,n)}));if(l){let a=ae(l.path,e);const c=K(o)&&o.canonicalQueries||[];if(c.length){const s=l.query,i=new URLSearchParams;for(const h of c)if(h in s){const u=s[h];we(u)?u.forEach(R=>i.append(h,R||"")):i.append(h,u||"")}const f=i.toString();f&&(a=`${a}?${f}`)}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:Ae(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:Ae(a.iso)}));o.push(...l)}}function Ae(e){return(e||"").replace(/-/g,"_")}function ae(e,t){return e.match(/^https?:\/\//)?e:t+e}function q(e,t){const{router:o,route:n,i18n:l,defaultLocale:a,strategy:c,defaultLocaleRouteNameSuffix:s,trailingSlash:i,routesNameSeparator:f}=e;return function(...h){return Reflect.apply(t,{router:o,route:n,i18n:l,defaultLocale:a,strategy:c,defaultLocaleRouteNameSuffix:s,trailingSlash:i,routesNameSeparator:f},h)}}function ct(e=L.useRoute(),{router:t=L.useRouter(),routesNameSeparator:o=void 0}={}){const n={router:t,route:e,routesNameSeparator:o};return F.call(n,e)}function st({router:e=L.useRouter(),route:t=L.useRoute(),i18n:o=g.useI18n(),defaultLocale:n=void 0,defaultLocaleRouteNameSuffix:l=void 0,routesNameSeparator:a=void 0,strategy:c=void 0,trailingSlash:s=void 0}={}){return q({router:e,route:t,i18n:o,defaultLocale:n,defaultLocaleRouteNameSuffix:l,routesNameSeparator:a,strategy:c,trailingSlash:s},H)}function rt({router:e=L.useRouter(),route:t=L.useRoute(),i18n:o=g.useI18n(),defaultLocale:n=void 0,defaultLocaleRouteNameSuffix:l=void 0,routesNameSeparator:a=void 0,strategy:c=void 0,trailingSlash:s=void 0}={}){return q({router:e,route:t,i18n:o,defaultLocale:n,defaultLocaleRouteNameSuffix:l,routesNameSeparator:a,strategy:c,trailingSlash:s},x)}function it({router:e=L.useRouter(),route:t=L.useRoute(),i18n:o=g.useI18n(),defaultLocale:n=void 0,defaultLocaleRouteNameSuffix:l=void 0,routesNameSeparator:a=void 0,strategy:c=void 0,trailingSlash:s=void 0}={}){return q({router:e,route:t,i18n:o,defaultLocale:n,defaultLocaleRouteNameSuffix:l,routesNameSeparator:a,strategy:c,trailingSlash:s},oe)}function ut({router:e=L.useRouter(),route:t=L.useRoute(),i18n:o=g.useI18n(),defaultLocale:n=void 0,defaultLocaleRouteNameSuffix:l=void 0,routesNameSeparator:a=void 0,strategy:c=void 0,trailingSlash:s=void 0}={}){return q({router:e,route:t,i18n:o,defaultLocale:n,defaultLocaleRouteNameSuffix:l,routesNameSeparator:a,strategy:c,trailingSlash:s},$)}function ft({addDirAttribute:e=!1,addSeoAttributes:t=!1,strategy:o=void 0,defaultLocale:n=void 0,route:l=L.useRoute(),router:a=L.useRouter(),i18n:c=g.useI18n()}={}){const s=a,i=d.ref({htmlAttrs:{},link:[],meta:[]});function f(){i.value={htmlAttrs:{},link:[],meta:[]}}function h(u){i.value=Reflect.apply(ne,{router:a,route:u,i18n:c,defaultLocale:n,strategy:o},[{addDirAttribute:e,addSeoAttributes:t}])}if(Be)if(d.isVue3){const u=d.watchEffect(()=>{f(),h(de(s.currentRoute))});d.onUnmounted(()=>u())}else{const u=s.afterEach((R,_)=>{f(),h(R)});d.onUnmounted(()=>u()),h(l)}else h(de(s.currentRoute));return i}const dt="0.0.0";return r.DEFAULT_BASE_URL=J,r.DEFAULT_DETECTION_DIRECTION=Y,r.DEFAULT_LOCALE=j,r.DEFAULT_LOCALE_ROUTE_NAME_SUFFIX=B,r.DEFAULT_ROUTES_NAME_SEPARATOR=D,r.DEFAULT_STRATEGY=V,r.DEFAULT_TRAILING_SLASH=G,r.STRATEGIES=U,r.VERSION=dt,r.createLocaleFromRouteGetter=Se,r.createRouter=Ke,r.extendI18n=ge,r.findBrowserLocale=qe,r.getGlobalOptions=pe,r.getLocale=k,r.getLocalesRegex=Ee,r.getRouteBaseName=F,r.localeHead=ne,r.localeLocation=oe,r.localePath=H,r.localeRoute=x,r.localizeRoutes=Re,r.proxyVueInstance=T,r.registerGlobalOptions=me,r.resolveBaseUrl=_e,r.resolveRoute=w,r.setLocale=fe,r.switchLocalePath=$,r.useLocaleHead=ft,r.useLocaleLocation=it,r.useLocalePath=st,r.useLocaleRoute=rt,r.useRouteBaseName=ct,r.useSwitchLocalePath=ut,Object.defineProperties(r,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),r}({},VueDemi,VueRouter,VueI18n); |
{ | ||
"name": "vue-i18n-routing", | ||
"description": "The i18n routing with using vue-i18n", | ||
"version": "0.0.0-05f2feb", | ||
"version": "0.0.0-089143c", | ||
"dependencies": { | ||
@@ -6,0 +6,0 @@ "@intlify/shared": "next", |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
95578
1741
0