vue-i18n-routing
Advanced tools
Comparing version 0.0.0-6956b1d to 0.0.0-6abd48e
@@ -1,5 +0,5 @@ | ||
"use strict";var W=Object.defineProperty,k=Object.defineProperties;var H=Object.getOwnPropertyDescriptors;var A=Object.getOwnPropertySymbols;var y=Object.prototype.hasOwnProperty,D=Object.prototype.propertyIsEnumerable;var O=(e,t,a)=>t in e?W(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a,F=(e,t)=>{for(var a in t||(t={}))y.call(t,a)&&O(e,a,t[a]);if(A)for(var a of A(t))D.call(t,a)&&O(e,a,t[a]);return e},T=(e,t)=>k(e,H(t));var V=(e,t)=>{var a={};for(var n in e)y.call(e,n)&&t.indexOf(n)<0&&(a[n]=e[n]);if(e!=null&&A)for(var n of A(e))t.indexOf(n)<0&&D.call(e,n)&&(a[n]=e[n]);return a};Object.defineProperty(exports,"__esModule",{value:!0});exports[Symbol.toStringTag]="Module";var m=require("vue-demi"),N=require("@intlify/vue-router-bridge"),Y=require("@intlify/vue-i18n-bridge");function J(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var K=J(N);/*! | ||
* shared v9.2.0-beta.26 | ||
* (c) 2021 kazuya kawaguchi | ||
"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 U=Object.assign,b=e=>typeof e=="string",Q=e=>typeof e=="symbol";function Z(e){e=e||[];const t=[];for(const a of e)b(a)?t.push({code:a}):t.push(a);return t}function I(e,t){return m.isRef(e.locale)&&t==="composition"}function w(e){return"global"in e&&"mode"in e}function z(e){return w(e)?I(e.global,e.mode)?e.global.locale.value:e.global.locale:e.locale.value}function ee(e,t){w(e)?I(e.global,e.mode)?e.global.locale.value=t:e.global.locale=t:m.isRef(e.locale)&&(e.locale.value=t)}function te(e,t,a){return e.replace(/\/+$/,"")+(t?"/":"")||(a?"":"/")}function ae(e={}){const t=Y.useI18n(),a=N.useRouter(),n=N.useRoute(),R=e.defaultLocaleRouteNameSuffix||a.__defaultLocaleRouteNameSuffix,g=e.defaultLocale||a.__defaultLocale,h=e.routesNameSeparator||a.__routesNameSeparator,L=e.strategy||a.__strategy;function u(r){const c=r!=null?r:m.isRef(n)?n.value:n;return c.name?X(c.name).split(h)[0]:void 0}function _(r,c){let o=X(r)+(L==="no_prefix"?"":h+c);return c===g&&L==="prefix_and_default"&&(o+=h+R),o}function l(r,c){const o=c||z(t);let s=r;b(r)&&(r[0]==="/"?s={path:r}:s={name:r});let f=U({},s);if(f.path&&!f.name){const d=a.resolve(f),v=m.isVue2?d.route:d,E=u(v);b(E)&&(f={name:_(E,o),params:v.params,query:v.query,hash:v.hash})}else{f.name=_(f.name,o);const{params:d}=f;d&&d["0"]===void 0&&d.pathMatch&&(d["0"]=d.pathMatch)}const p=a.resolve(f);return(m.isVue2?p.route.name:p.name)?p:a.resolve(r)}function S(r,c){const o=l(r,c);return o==null?"":m.isVue2?o.route.redirectedFrom||o.route.fullPath:o.redirectedFrom||o.fullPath}function x(r,c){const o=l(r,c);return o==null?void 0:m.isVue2?o.route:o}function i(r,c){const o=l(r,c);return o==null?void 0:m.isVue2?o.location:o.href}function $(r){const c=u();if(!c)return"";const v=m.isVue2&&m.isRef(n)?n.value:n,{params:o}=v,s=V(v,["params"]),f={},p=U({},s,{name:c,params:T(F(F({},o),f),{0:o.pathMatch})}),d=S(p,r);return console.log("switchLocalePath",t.locale.value,r,d),d}return{getRouteBaseName:u,localePath:S,localeRoute:x,localeLocation:i,switchLocalePath:$}}function X(e){return b(e)?e:Q(e)?e.toString():"(null)"}const oe={PREFIX:"prefix",PREFIX_EXCEPT_DEFAULT:"prefix_except_default",PREFIX_AND_DEFAULT:"prefix_and_default",NO_PREFIX:"no_prefix"},M="",j=oe.PREFIX_EXCEPT_DEFAULT,C=!1,q="___",G="default";function B(e,{defaultLocale:t=M,strategy:a=j,trailingSlash:n=C,routesNameSeparator:R=q,defaultLocaleRouteNameSuffix:g=G,includeUprefixedFallback:h=!1,locales:L=[]}={}){if(a==="no_prefix")return e;const u=L.map(l=>b(l)?l:l.code);function _(l,S,x=!1,i=!1){return l.redirect&&(!l.component||!l.file)?[l]:S.reduce((r,c)=>{const{name:o}=l;let{path:s}=l;const f=F({},l);o&&(f.name=`${o}${R}${c}`),l.children&&(f.children=l.children.reduce((E,P)=>[...E,..._(P,[c],!0,i)],[]));const p=c===t;if(p&&a==="prefix_and_default")if(x)x&&i&&o&&(f.name+=`${R}${g}`);else{const E=T(F({},f),{path:s});if(o&&(E.name=`${f.name}${R}${g}`),l.children){E.children=[];for(const P of l.children)E.children=E.children.concat(_(P,[c],!0,!0))}r.push(E)}const d=x&&!s.startsWith("/"),v=!d&&!(p&&a==="prefix_except_default");return v&&(s=`/${c}${s}`),s&&(s=te(s,n,d)),v&&p&&a==="prefix"&&h&&r.push(F({},l)),f.path=s,r.push(f),r},[])}return e.reduce((l,S)=>[...l,..._(S,u||[])],[])}function le(e,{locales:t=[]}={}){if(!I(e.global,e.mode))throw new Error("");const a=m.ref(t);e.global.locales=m.computed(()=>a.value),console.log("... extends i18n done")}function ne(e){return new RegExp(`^/(${e.join("|")})(?:/|$)`,"i")}function re(e,t,a){const n=`(${e.join("|")})`,R=`(?:${t}${a})?`,g=new RegExp(`${t}${n}${R}$`,"i"),h=ne(e);return u=>{if(u.name){const l=(b(u.name)?u.name:u.name.toString()).match(g);if(l&&l.length>1)return l[1]}else if(u.path){const _=u.path.match(h);if(_&&_.length>1)return _[1]}return""}}function ce(e){var t,a,n,R,g,h,L,u;return e.version=(t=e.version)!=null?t:4,e.defaultLocale=(a=e.defaultLocale)!=null?a:M,e.strategy=(n=e.strategy)!=null?n:j,e.trailingSlash=(R=e.trailingSlash)!=null?R:C,e.routesNameSeparator=(g=e.routesNameSeparator)!=null?g:q,e.defaultLocaleRouteNameSuffix=(h=e.defaultLocaleRouteNameSuffix)!=null?h:G,e.locales=(L=e.locales)!=null?L:[],e.routes=(u=e.routes)!=null?u:[],e}function ue(e,t={}){const{version:a,defaultLocale:n,locales:R,strategy:g,trailingSlash:h,routesNameSeparator:L,defaultLocaleRouteNameSuffix:u,routes:_}=ce(t),l=Z(R),S=re(l.map($=>$.code),L,u);le(e,{locales:l});const x=B(_,{locales:R,defaultLocale:n,strategy:g,trailingSlash:h,routesNameSeparator:L,defaultLocaleRouteNameSuffix:u});t.routes=x;let i=null;if(m.isVue3&&a===4)i=N.createRouter(t);else if(m.isVue2&&a===3)i=new K.default(t);else throw new Error("TODO:");return i.__defaultLocale=n,i.__strategy=g,i.__trailingSlash=h,i.__routesNameSeparator=L,i.__defaultLocaleRouteNameSuffix=u,i.beforeEach(($,r,c)=>{console.log("beforeEach",$,r);const o=z(e),s=S($)||o||n||"";console.log("currentLocale",o,"finalLocale",s),o!==s&&ee(e,s),c()}),console.log("create router",i),i}const se="";exports.VERSION=se;exports.createRouter=ue;exports.localizeRoutes=B;exports.useI18nRouting=ae; | ||
*/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; |
@@ -0,15 +1,78 @@ | ||
import type { Composer } from '@intlify/vue-i18n-bridge'; | ||
import type { I18n } from '@intlify/vue-i18n-bridge'; | ||
import { Locale } from '@intlify/vue-i18n-bridge'; | ||
import type { Locale } from '@intlify/vue-i18n-bridge'; | ||
import type { RawLocation } from '@intlify/vue-router-bridge'; | ||
import type { Ref } from 'vue-demi'; | ||
import type { Route as Route_2 } from '@intlify/vue-router-bridge'; | ||
import type { RouteConfig } from '@intlify/vue-router-bridge'; | ||
import type { RouteLocation } from '@intlify/vue-router-bridge'; | ||
import type { RouteLocationNormalized } from '@intlify/vue-router-bridge'; | ||
import type { RouteLocationNormalizedLoaded } from '@intlify/vue-router-bridge'; | ||
import type { RouteLocationRaw } from '@intlify/vue-router-bridge'; | ||
import type { Router } from '@intlify/vue-router-bridge'; | ||
import type { RouterOptions } from '@intlify/vue-router-bridge'; | ||
import { useRoute } from '@intlify/vue-router-bridge'; | ||
import { useRouter } from '@intlify/vue-router-bridge'; | ||
import type { VueI18n } from '@intlify/vue-i18n-bridge'; | ||
import type { VueRouter } from '@intlify/vue-router-bridge'; | ||
export declare type BaseUrlResolveHandler<Context = unknown> = (context: Context) => string; | ||
/** | ||
* The browser locale info | ||
* | ||
* @remarks | ||
* This type is used by {@link FindBrowserLocaleOptions#sorter | sorter} in {@link findBrowserLocale} function | ||
*/ | ||
export declare type BrowserLocale = { | ||
/** | ||
* The locale code, such as BCP 47 (e.g `en-US`), or `ja` | ||
*/ | ||
code: string; | ||
/** | ||
* The score number | ||
* | ||
* @remarks | ||
* The score number that is used by `sorter` of {@link FindBrowserLocaleOptions} | ||
*/ | ||
score: number; | ||
}; | ||
/** | ||
* The browser locale matcher | ||
* | ||
* @remarks | ||
* This matcher is used by {@link findBrowserLocale} function | ||
* | ||
* @param locales - The target {@link LocaleObject | locale} list | ||
* @param browserLocales - The locale code list that is used in browser | ||
* | ||
* @returns The matched {@link BrowserLocale | locale info} | ||
*/ | ||
export declare type BrowserLocaleMatcher = (locales: TargetLocale[], browserLocales: string[]) => BrowserLocale[]; | ||
export declare type ComposableOptions = { | ||
route?: ReturnType<typeof useRoute>; | ||
router?: ReturnType<typeof useRouter>; | ||
i18n?: Composer; | ||
}; | ||
/** | ||
* Options to compute route localizing | ||
* | ||
* @remarks | ||
* The route options that is compute the route to be localized on {@link localizeRoutes} | ||
*/ | ||
export declare type ComputedRouteOptions = { | ||
locales: readonly string[]; | ||
paths: Record<string, string>; | ||
}; | ||
export declare function createLocaleFromRouteGetter(localeCodes: string[], routesNameSeparator: string, defaultLocaleRouteNameSuffix: string): (route: Route_2 | RouteLocationNormalizedLoaded | RouteLocationNormalized | string) => string; | ||
/** | ||
* Create a Vue Router instance | ||
* | ||
* @param i18n - A Vue I18n instance, see [Vue I18n API docs](https://vue-i18n.intlify.dev/api/general.html#i18n) | ||
* @param options - An options, see {@link VueI18nRoutingOptions} | ||
* @param options - An options, see {@link I18nRoutingOptions} | ||
* | ||
@@ -24,4 +87,6 @@ * @returns A Vue Router instance | ||
* At the Vue 2 will return a [Vue Router v3 instance](https://router.vuejs.org/api/#router-construction-options), and at the Vue 3 will return a [Vue Router v4 instance](https://next.router.vuejs.org/api/#createrouter). | ||
* | ||
* @public | ||
*/ | ||
export declare function createRouter<Options extends VueI18nRoutingOptions = VueI18nRoutingOptions>(i18n: I18n, options?: Options): Options['version'] extends 4 ? Router : VueRouter; | ||
export declare function createRouter<Options extends I18nRoutingOptions = I18nRoutingOptions>(i18n: I18n, options?: Options): Options['version'] extends 4 ? Router : VueRouter; | ||
@@ -33,76 +98,70 @@ /** | ||
export declare interface I18nRouting { | ||
getRouteBaseName(givenRoute?: Route_2 | RouteLocationNormalizedLoaded): string; | ||
localePath(route: any, locale?: Locale): string; | ||
localeRoute(route: any, locale?: Locale): any; | ||
localeLocation(route: any, locale?: Locale): any; | ||
switchLocalePath(locale: Locale): void; | ||
} | ||
/** | ||
* Find the browser locale | ||
* | ||
* @param locales - The target {@link LocaleObject | locale} list | ||
* @param browserLocales - The locale code list that is used in browser | ||
* @param options - The options for {@link findBrowserLocale} function | ||
* | ||
* @returns The matched the locale code | ||
*/ | ||
export declare function findBrowserLocale(locales: LocaleObject[], browserLocales: string[], { matcher, comparer }?: FindBrowserLocaleOptions): string | ''; | ||
export declare type I18nRoutingOptions = Pick<VueI18nRoutingOptions, 'defaultLocale' | 'strategy' | 'defaultLocaleRouteNameSuffix' | 'trailingSlash' | 'locales'> & { | ||
routesNameSeparator?: string; | ||
/** | ||
* The options for {@link findBrowserLocale} function | ||
*/ | ||
export declare type FindBrowserLocaleOptions = { | ||
matcher?: BrowserLocaleMatcher; | ||
comparer?: (a: BrowserLocale, b: BrowserLocale) => number; | ||
}; | ||
/** | ||
* Locale object | ||
* Get global i18n routing options | ||
* | ||
* @param router - A router instance | ||
* @returns A global options | ||
*/ | ||
export declare interface LocaleObject extends Record<string, any> { | ||
code: Locale; | ||
name?: string; | ||
dir?: Directions; | ||
domain?: string; | ||
file?: string; | ||
isCatchallLocale?: boolean; | ||
iso?: string; | ||
} | ||
export declare function getGlobalOptions(router: Router | VueRouter): I18nRoutingGlobalOptions; | ||
export declare function localizeRoutes(routes: VueI18nRoute[], { defaultLocale, strategy, trailingSlash, routesNameSeparator, defaultLocaleRouteNameSuffix, includeUprefixedFallback, locales }?: Pick<VueI18nRoutingOptions, 'defaultLocale' | 'strategy' | 'locales' | 'routesNameSeparator' | 'trailingSlash' | 'defaultLocaleRouteNameSuffix'> & { | ||
includeUprefixedFallback?: boolean; | ||
}): VueI18nRoute[]; | ||
/** | ||
* Route config for vue-router v4 | ||
* Get a locale | ||
* | ||
* @param i18n - An [I18n](https://vue-i18n.intlify.dev/api/general.html#i18n) instance or a [Composer](https://vue-i18n.intlify.dev/api/composition.html#composer) instance | ||
* | ||
* @returns A locale | ||
*/ | ||
export declare interface Route { | ||
name?: string; | ||
path: string; | ||
file?: string; | ||
children?: Route[]; | ||
} | ||
export declare function getLocale(i18n: I18n | Composer | VueI18n): Locale; | ||
declare type _Route = UnionToIntersection<RouteConfig>; | ||
export declare function getRouteBaseName(this: RoutingProxy, givenRoute?: Route_2 | RouteLocationNormalizedLoaded): string | undefined; | ||
/** | ||
* Route config for lagacy vue-router v3 | ||
*/ | ||
export declare interface RouteLegacy extends Pick<_Route, Exclude<keyof _Route, 'children' | 'component'>> { | ||
chunkName?: string; | ||
chunkNames?: Record<string, string>; | ||
component?: _Route['component'] | string; | ||
children?: RouteLegacy[]; | ||
} | ||
export declare type I18nCommonRoutingOptions = Pick<I18nRoutingOptions, 'defaultLocale' | 'strategy' | 'defaultLocaleRouteNameSuffix' | 'trailingSlash' | 'locales' | 'routesNameSeparator'>; | ||
declare const STRATEGIES: { | ||
readonly PREFIX: "prefix"; | ||
readonly PREFIX_EXCEPT_DEFAULT: "prefix_except_default"; | ||
readonly PREFIX_AND_DEFAULT: "prefix_and_default"; | ||
readonly NO_PREFIX: "no_prefix"; | ||
}; | ||
export declare type I18nCommonRoutingOptionsWithComposable = I18nCommonRoutingOptions & ComposableOptions; | ||
/** | ||
* Routing strategy | ||
* I18n header meta info | ||
*/ | ||
export declare type Strategies = typeof STRATEGIES[keyof typeof STRATEGIES]; | ||
export declare interface I18nHeadMetaInfo { | ||
htmlAttrs?: MetaAttrs; | ||
meta?: MetaAttrs[]; | ||
link?: MetaAttrs[]; | ||
} | ||
declare type UnionToIntersection<T> = (T extends any ? (k: T) => void : never) extends (k: infer U) => void ? U : never; | ||
export declare function useI18nRouting<Legacy extends boolean = false>(options?: I18nRoutingOptions): I18nRouting; | ||
/** | ||
* Vue I18n Routing Version | ||
* | ||
* @remarks | ||
* Semver format. Same format as the package.json `version` field. | ||
* Options for {@link localeHead} function | ||
*/ | ||
export declare const VERSION = ""; | ||
export declare interface I18nHeadOptions { | ||
/** | ||
* Adds a `dir` attribute to the HTML element. | ||
* | ||
* @defaultValue false | ||
*/ | ||
addDirAttribute?: boolean; | ||
/** | ||
* Adds various SEO attributes. | ||
* | ||
* @defaultValue false | ||
*/ | ||
addSeoAttributes?: boolean | SeoAttributesOptions; | ||
} | ||
@@ -112,3 +171,3 @@ /** | ||
*/ | ||
export declare type VueI18nRoute = Route & RouteLegacy & { | ||
export declare type I18nRoute = Route & RouteLegacy & { | ||
redirect?: string; | ||
@@ -118,2 +177,9 @@ }; | ||
/** | ||
* 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 | ||
@@ -124,3 +190,3 @@ * | ||
*/ | ||
export declare type VueI18nRoutingOptions = { | ||
export declare type I18nRoutingOptions<BaseUrl extends BaseUrlResolveHandler = BaseUrlResolveHandler> = { | ||
/** | ||
@@ -151,3 +217,4 @@ * Vue Router version | ||
* | ||
* @remarks TODO: | ||
* @remarks | ||
* Can either be an array of string codes (e.g. `['en', 'fr']`) or an array of {@link LocaleObject} for more complex configurations | ||
* | ||
@@ -192,15 +259,332 @@ * @defaultValue [] | ||
defaultLocaleRouteNameSuffix?: string; | ||
/** | ||
* Default direction direction | ||
* | ||
* @defaultValue 'ltr' | ||
*/ | ||
defaultDirection?: Directions; | ||
/** | ||
* The fallback base URL to use as a prefix for alternate URLs in hreflang tags. | ||
* | ||
* @remarks | ||
* By default VueRouter's base URL will be used and only if that is not available, fallback URL will be used. | ||
* | ||
* Can also be a function (will be passed a Nuxt Context as a parameter) that returns a string. | ||
* | ||
* Useful to make base URL dynamic based on request headers. | ||
* | ||
* @defaultValue '' | ||
*/ | ||
baseUrl?: string | BaseUrl; | ||
/** | ||
* Route options resolver | ||
* | ||
* @defaultValue undefined | ||
*/ | ||
routeOptionsResolver?: RouteOptionsResolver; | ||
} & RouterOptions; | ||
export declare function localeHead(this: RoutingProxy, { addDirAttribute, addSeoAttributes }?: I18nHeadOptions): I18nHeadMetaInfo; | ||
export declare function localeLocation(this: RoutingProxy, route: RawLocation | RouteLocationRaw, locale?: Locale): Location | RouteLocation | undefined; | ||
/** | ||
* Resolve locale location function | ||
* | ||
* @param route - A route location. The path or name of the route or an object for more complex routes | ||
* @param locale - A locale code, if not specified, uses the current locale | ||
* | ||
* @returns Returns the location object for a given route, the location object is resolved by vue-router rather than just a full route path. | ||
* | ||
* @see {@link useLocaleLocation} | ||
*/ | ||
export declare type LocaleLocationFunction = (route: RawLocation | RouteLocationRaw, locale?: Locale) => Location | RouteLocation | undefined; | ||
/** | ||
* Locale object | ||
*/ | ||
export declare interface LocaleObject extends Record<string, any> { | ||
code: Locale; | ||
name?: string; | ||
dir?: Directions; | ||
domain?: string; | ||
file?: string; | ||
isCatchallLocale?: boolean; | ||
iso?: string; | ||
} | ||
export declare function localePath(this: RoutingProxy, route: RawLocation | RouteLocationRaw, locale?: Locale): string; | ||
/** | ||
* Resolve locale path function | ||
* | ||
* @param route - A route location. The path or name of the route or an object for more complex routes | ||
* @param locale - A locale code, if not specified, uses the current locale | ||
* | ||
* @returns Returns the localized URL for a given route | ||
* | ||
* @see {@link useLocalePath} | ||
*/ | ||
export declare type LocalePathFunction = (route: RawLocation | RouteLocation, locale?: Locale) => string; | ||
export declare function localeRoute(this: RoutingProxy, route: RawLocation | RouteLocationRaw, locale?: Locale): Route_2 | ReturnType<Router['resolve']> | undefined; | ||
/** | ||
* Resolve route fucntion | ||
* | ||
* @param route - A route location. The path or name of the route or an object for more complex routes | ||
* @param locale - A locale code, if not specified, uses the current locale | ||
* | ||
* @returns Returns the route object for a given route, the route object is resolved by vue-router rather than just a full route path. | ||
* | ||
* @see {@link useLocaleRoute} | ||
*/ | ||
export declare type LocaleRouteFunction = (route: RawLocation | RouteLocationRaw, locale?: Locale) => Route_2 | ReturnType<Router['resolve']> | undefined; | ||
/** | ||
* Localize routes | ||
* | ||
* @param routes - Some routes | ||
* @param options - An options | ||
* | ||
* @returns Localized routes | ||
* | ||
* @public | ||
*/ | ||
export declare function localizeRoutes(routes: I18nRoute[], { defaultLocale, strategy, trailingSlash, routesNameSeparator, defaultLocaleRouteNameSuffix, includeUprefixedFallback, optionsResolver, locales }?: Pick<I18nRoutingOptions, 'defaultLocale' | 'strategy' | 'locales' | 'routesNameSeparator' | 'trailingSlash' | 'defaultLocaleRouteNameSuffix'> & { | ||
includeUprefixedFallback?: boolean; | ||
optionsResolver?: RouteOptionsResolver; | ||
}): I18nRoute[]; | ||
export declare type MetaAttrs = Record<string, any>; | ||
/** | ||
* 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 | ||
* | ||
* @param baseUrl - A base url to resolve on SEO and domain. if you want to resolve with dynamically, you can spacify {@link BaseUrlResolveHandler} | ||
* @param context - A context to resolve base url, if you want to resolve base url with {@link BaseUrlResolveHandler} | ||
* | ||
* @returns A resolved base url | ||
*/ | ||
export declare function resolveBaseUrl<Context = unknown>(baseUrl: string | BaseUrlResolveHandler<Context>, context: Context): string; | ||
export declare function resolveRoute(this: RoutingProxy, route: any, locale?: Locale): any; | ||
/** | ||
* Route config for vue-router v4 | ||
*/ | ||
export declare interface Route { | ||
name?: string; | ||
path: string; | ||
file?: string; | ||
children?: Route[]; | ||
} | ||
declare type _Route = UnionToIntersection<RouteConfig>; | ||
/** | ||
* Route config for lagacy vue-router v3 | ||
*/ | ||
export declare interface RouteLegacy extends Pick<_Route, Exclude<keyof _Route, 'children' | 'component'>> { | ||
chunkName?: string; | ||
chunkNames?: Record<string, string>; | ||
component?: _Route['component'] | string; | ||
children?: RouteLegacy[]; | ||
} | ||
/** | ||
* Resolver for route localizing options | ||
*/ | ||
export declare type RouteOptionsResolver = (route: I18nRoute, allowedLocaleCodes: string[]) => ComputedRouteOptions | null; | ||
/** | ||
* Routing Proxy | ||
*/ | ||
export declare type RoutingProxy = { | ||
i18n: any; | ||
getRouteBaseName: any; | ||
localePath: any; | ||
localeRoute: any; | ||
localeLocation: any; | ||
resolveRoute: any; | ||
switchLocalePath: any; | ||
localeHead: any; | ||
route: Route_2 | RouteLocationNormalizedLoaded; | ||
router: Router | VueRouter; | ||
defaultLocale?: string; | ||
localeCodes?: string[]; | ||
strategy?: Strategies; | ||
defaultDirection?: Directions; | ||
defaultLocaleRouteNameSuffix?: string; | ||
trailingSlash?: boolean; | ||
routesNameSeparator?: string; | ||
}; | ||
/** | ||
* SEO Attribute options | ||
*/ | ||
export declare interface SeoAttributesOptions { | ||
/** | ||
* An array of strings corresponding to query params you would like to include in your canonical URL. | ||
* | ||
* @defaultValue [] | ||
*/ | ||
canonicalQueries?: string[]; | ||
} | ||
/** | ||
* Set a locale | ||
* | ||
* @param i18n - An [I18n](https://vue-i18n.intlify.dev/api/general.html#i18n) instance or a [Composer](https://vue-i18n.intlify.dev/api/composition.html#composer) instance | ||
* @param locale - A target locale | ||
*/ | ||
export declare function setLocale(i18n: I18n | Composer, locale: Locale): void; | ||
declare const STRATEGIES: { | ||
readonly PREFIX: "prefix"; | ||
readonly PREFIX_EXCEPT_DEFAULT: "prefix_except_default"; | ||
readonly PREFIX_AND_DEFAULT: "prefix_and_default"; | ||
readonly NO_PREFIX: "no_prefix"; | ||
}; | ||
/** | ||
* Routing strategy | ||
*/ | ||
export declare type Strategies = typeof STRATEGIES[keyof typeof STRATEGIES]; | ||
export declare function switchLocalePath(this: RoutingProxy, locale: Locale): string; | ||
/** | ||
* Swtich locale path function | ||
* | ||
* @param locale - A locale code, if not specified, uses the current locale | ||
* | ||
* @returns Returns a link to the current route in another language | ||
* | ||
* @see {@link useSwitchLocalePath} | ||
*/ | ||
export declare type SwitchLocalePathFunction = (locale?: Locale) => string; | ||
/** | ||
* The target locale info | ||
* | ||
* @remarks | ||
* This type is used by {@link BrowserLocaleMatcher} first argument | ||
*/ | ||
export declare type TargetLocale = Required<Pick<LocaleObject, 'code' | 'iso'>>; | ||
declare type UnionToIntersection<T> = (T extends any ? (k: T) => void : never) extends (k: infer U) => void ? U : never; | ||
/** | ||
* Use localize head meta | ||
* | ||
* @param options - An options, see about details {@link I18nHeadOptions}, {@link ComposableOptions}, {@link I18nCommonRoutingOptions} | ||
* | ||
* @returns Genereated SEO head meta information | ||
*/ | ||
export declare function useLocaleHead({ addDirAttribute, addSeoAttributes, strategy, defaultLocale, route, router, i18n }?: Pick<I18nCommonRoutingOptionsWithComposable, 'strategy' | 'defaultLocale' | 'route' | 'router' | 'i18n'> & I18nHeadOptions): Ref<I18nHeadMetaInfo>; | ||
/** | ||
* Use resolve locale location | ||
* | ||
* @param options - An options, see about details {@link I18nRoutingOptions} | ||
* | ||
* @returns Returns a {@link LocaleLocationFunction} | ||
*/ | ||
export declare function useLocaleLocation({ router, route, i18n, defaultLocale, defaultLocaleRouteNameSuffix, routesNameSeparator, strategy, trailingSlash }?: I18nCommonRoutingOptionsWithComposable): LocaleLocationFunction; | ||
/** | ||
* Use resolve locale path | ||
* | ||
* @param options - An options, see about details {@link I18nRoutingOptions} | ||
* | ||
* @returns Returns a {@link LocalePathFunction} | ||
*/ | ||
export declare function useLocalePath({ router, route, i18n, defaultLocale, defaultLocaleRouteNameSuffix, routesNameSeparator, strategy, trailingSlash }?: I18nCommonRoutingOptionsWithComposable): LocalePathFunction; | ||
/** | ||
* Use resolve locale route | ||
* | ||
* @param options - An options, see about details {@link I18nRoutingOptions} | ||
* | ||
* @returns Returns a {@link LocaleRouteFunction} | ||
*/ | ||
export declare function useLocaleRoute({ router, route, i18n, defaultLocale, defaultLocaleRouteNameSuffix, routesNameSeparator, strategy, trailingSlash }?: I18nCommonRoutingOptionsWithComposable): LocaleRouteFunction; | ||
/** | ||
* Use route base name | ||
* | ||
* @param givenRoute - A route object, if not provided, the route is returned with `useRoute` will be used | ||
* @param options - An options, see about details {@link I18nRoutingOptions} | ||
* | ||
* @returns The route base name, if route name is not defined, return null | ||
*/ | ||
export declare function useRouteBaseName(givenRoute?: Route_2 | RouteLocationNormalizedLoaded, { router, routesNameSeparator }?: I18nCommonRoutingOptionsWithComposable): string | undefined; | ||
/** | ||
* Use swtich locale path | ||
* | ||
* @param options - An options, see about details {@link I18nRoutingOptions} | ||
* | ||
* @returns Returns a {@link SwitchLocalePathFunction} | ||
*/ | ||
export declare function useSwitchLocalePath({ router, route, i18n, defaultLocale, defaultLocaleRouteNameSuffix, routesNameSeparator, strategy, trailingSlash }?: I18nCommonRoutingOptionsWithComposable): SwitchLocalePathFunction; | ||
/** | ||
* Vue I18n Routing Version | ||
* | ||
* @remarks | ||
* Semver format. Same format as the package.json `version` field. | ||
*/ | ||
export declare const VERSION: string; | ||
/** | ||
* An options of Vue I18n Routing Plugin | ||
*/ | ||
export declare interface VueI18nRoutingPluginOptions { | ||
/** | ||
* Whether to inject some option APIs style methods into Vue instance | ||
* | ||
* @defaultValue `true` | ||
*/ | ||
inject?: boolean; | ||
} | ||
export { } | ||
import type { ComputedRef } from 'vue-demi' | ||
export interface ComposerCustomProperties { | ||
/** | ||
* List of locales | ||
* | ||
* @remarks | ||
* Can either be an array of string codes (e.g. `['en', 'fr']`) or an array of {@link LocaleObject} for more complex configurations | ||
*/ | ||
locales: ComputedRef<string[] | LocaleObject[]> | ||
/** | ||
* List of locale codes | ||
*/ | ||
localeCodes: ComputedRef<string[]> | ||
__baseUrl: string | ||
} | ||
declare module 'vue-i18n' { | ||
export interface ComposerCustom { | ||
locales: ComputedRef<string[] | LocaleObject[]> | ||
} | ||
// eslint-disable-next-line @typescript-eslint/no-empty-interface | ||
export interface ComposerCustom extends ComposerCustomProperties {} | ||
} | ||
declare module 'vue-i18n-bridge' { | ||
export interface ComposerCustom { | ||
locales: ComputedRef<string[] | LocaleObject[]> | ||
} | ||
// 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,13 +32,53 @@ var __defProp = Object.defineProperty; | ||
}; | ||
import { isRef, isVue2, ref, computed, isVue3 } from "vue-demi"; | ||
import VueRouter3, { useRouter, useRoute, 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"; | ||
/*! | ||
* shared v9.2.0-beta.26 | ||
* (c) 2021 kazuya kawaguchi | ||
* shared v9.2.0-beta.34 | ||
* (c) 2022 kazuya kawaguchi | ||
* Released under the MIT License. | ||
*/ | ||
const assign = Object.assign; | ||
const isArray = Array.isArray; | ||
const isFunction = (val) => typeof val === "function"; | ||
const isString = (val) => typeof val === "string"; | ||
const isBoolean = (val) => typeof val === "boolean"; | ||
const isSymbol = (val) => typeof val === "symbol"; | ||
const isObject = (val) => val !== null && typeof val === "object"; | ||
const TRAILING_SLASH_RE = /\/$|\/\?/; | ||
function hasTrailingSlash(input = "", queryParams = false) { | ||
if (!queryParams) { | ||
return input.endsWith("/"); | ||
} | ||
return TRAILING_SLASH_RE.test(input); | ||
} | ||
function withoutTrailingSlash(input = "", queryParams = false) { | ||
if (!queryParams) { | ||
return (hasTrailingSlash(input) ? input.slice(0, -1) : input) || "/"; | ||
} | ||
if (!hasTrailingSlash(input, true)) { | ||
return input || "/"; | ||
} | ||
const [s0, ...s] = input.split("?"); | ||
return (s0.slice(0, -1) || "/") + (s.length ? `?${s.join("?")}` : ""); | ||
} | ||
function withTrailingSlash(input = "", queryParams = false) { | ||
if (!queryParams) { | ||
return input.endsWith("/") ? input : input + "/"; | ||
} | ||
if (hasTrailingSlash(input, true)) { | ||
return input || "/"; | ||
} | ||
const [s0, ...s] = input.split("?"); | ||
return s0 + "/" + (s.length ? `?${s.join("?")}` : ""); | ||
} | ||
const inBrowser = typeof window !== "undefined"; | ||
function warn(msg, err) { | ||
if (typeof console !== "undefined") { | ||
console.warn(`[vue-i18n-routing] ` + msg); | ||
if (err) { | ||
console.warn(err.stack); | ||
} | ||
} | ||
} | ||
function getNormalizedLocales(locales) { | ||
@@ -56,20 +96,40 @@ locales = locales || []; | ||
} | ||
function isComposer(target, mode) { | ||
return isRef(target.locale) && mode === "composition"; | ||
} | ||
function isI18nInstance(i18n) { | ||
return "global" in i18n && "mode" in i18n; | ||
return i18n != null && "global" in i18n && "mode" in i18n; | ||
} | ||
function isComposer(target) { | ||
return target != null && !("__composer" in target) && isRef(target.locale); | ||
} | ||
function isVueI18n(target) { | ||
return target != null && "__composer" in target; | ||
} | ||
function isExportedGlobalComposer(target) { | ||
return target != null && !("__composer" in target) && !isRef(target.locale); | ||
} | ||
function isLegacyVueI18n(target) { | ||
return target != null && ("__VUE_I18N_BRIDGE__" in target || "_sync" in target); | ||
} | ||
function getComposer(i18n) { | ||
return isI18nInstance(i18n) ? isComposer(i18n.global) ? i18n.global : i18n.global.__composer : isVueI18n(i18n) ? i18n.__composer : i18n; | ||
} | ||
function getLocale(i18n) { | ||
return isI18nInstance(i18n) ? isComposer(i18n.global, i18n.mode) ? i18n.global.locale.value : i18n.global.locale : i18n.locale.value; | ||
const target = isI18nInstance(i18n) ? i18n.global : i18n; | ||
return isComposer(target) ? isVue2 && isLegacyVueI18n(i18n) ? i18n.locale : target.locale.value : isExportedGlobalComposer(target) || isVueI18n(target) || isLegacyVueI18n(target) ? target.locale : target.locale; | ||
} | ||
function getLocales(i18n) { | ||
const target = isI18nInstance(i18n) ? i18n.global : i18n; | ||
return isComposer(target) ? isVue2 && isLegacyVueI18n(i18n) ? i18n.locales : target.locales.value : isExportedGlobalComposer(target) || isVueI18n(target) || isLegacyVueI18n(target) ? target.locales : target.locales; | ||
} | ||
function setLocale(i18n, locale) { | ||
if (isI18nInstance(i18n)) { | ||
if (isComposer(i18n.global, i18n.mode)) { | ||
i18n.global.locale.value = locale; | ||
const target = isI18nInstance(i18n) ? i18n.global : i18n; | ||
if (isComposer(target)) { | ||
if (isVue2 && isLegacyVueI18n(i18n)) { | ||
i18n.locale = locale; | ||
} else { | ||
i18n.global.locale = locale; | ||
target.locale.value = locale; | ||
} | ||
} else if (isRef(i18n.locale)) { | ||
i18n.locale.value = locale; | ||
} else if (isExportedGlobalComposer(target) || isVueI18n(target) || isLegacyVueI18n(target)) { | ||
target.locale = locale; | ||
} else { | ||
throw new Error("TODO:"); | ||
} | ||
@@ -80,101 +140,66 @@ } | ||
} | ||
function useI18nRouting(options = {}) { | ||
const $i18n = useI18n(); | ||
const $router = useRouter(); | ||
const $route = useRoute(); | ||
const defaultLocaleRouteNameSuffix = options.defaultLocaleRouteNameSuffix || $router.__defaultLocaleRouteNameSuffix; | ||
const defaultLocale = options.defaultLocale || $router.__defaultLocale; | ||
const routesNameSeparator = options.routesNameSeparator || $router.__routesNameSeparator; | ||
const strategy = options.strategy || $router.__strategy; | ||
function getRouteBaseName(givenRoute) { | ||
const route = givenRoute != null ? givenRoute : isRef($route) ? $route.value : $route; | ||
if (!route.name) { | ||
return; | ||
} | ||
const name = getRouteName(route.name); | ||
return name.split(routesNameSeparator)[0]; | ||
function toRawRoute(maybeRoute) { | ||
return isVueRouter4 ? isRef(maybeRoute) ? maybeRoute.value : maybeRoute : isRef(maybeRoute) ? maybeRoute.value : maybeRoute; | ||
} | ||
function getRouteName(routeName) { | ||
return isString(routeName) ? routeName : isSymbol(routeName) ? routeName.toString() : "(null)"; | ||
} | ||
function getLocaleRouteName(routeName, locale, { | ||
defaultLocale, | ||
strategy, | ||
routesNameSeparator, | ||
defaultLocaleRouteNameSuffix | ||
}) { | ||
let name = getRouteName(routeName) + (strategy === "no_prefix" ? "" : routesNameSeparator + locale); | ||
if (locale === defaultLocale && strategy === "prefix_and_default") { | ||
name += routesNameSeparator + defaultLocaleRouteNameSuffix; | ||
} | ||
function getLocaleRouteName(routeName, locale) { | ||
let name = getRouteName(routeName) + (strategy === "no_prefix" ? "" : routesNameSeparator + locale); | ||
if (locale === defaultLocale && strategy === "prefix_and_default") { | ||
name += routesNameSeparator + defaultLocaleRouteNameSuffix; | ||
return name; | ||
} | ||
function resolveBaseUrl(baseUrl, context) { | ||
if (isFunction(baseUrl)) { | ||
return baseUrl(context); | ||
} | ||
return baseUrl; | ||
} | ||
function matchBrowserLocale(locales, browserLocales) { | ||
const matchedLocales = []; | ||
for (const [index, browserCode] of browserLocales.entries()) { | ||
const matchedLocale = locales.find((l) => l.iso.toLowerCase() === browserCode.toLowerCase()); | ||
if (matchedLocale) { | ||
matchedLocales.push({ code: matchedLocale.code, score: 1 - index / browserLocales.length }); | ||
break; | ||
} | ||
return name; | ||
} | ||
function resolveRoute(route, locale) { | ||
const _locale = locale || getLocale($i18n); | ||
let _route = route; | ||
if (isString(route)) { | ||
if (route[0] === "/") { | ||
_route = { path: route }; | ||
} else { | ||
_route = { name: route }; | ||
} | ||
for (const [index, browserCode] of browserLocales.entries()) { | ||
const languageCode = browserCode.split("-")[0].toLowerCase(); | ||
const matchedLocale = locales.find((l) => l.iso.split("-")[0].toLowerCase() === languageCode); | ||
if (matchedLocale) { | ||
matchedLocales.push({ code: matchedLocale.code, score: 0.999 - index / browserLocales.length }); | ||
break; | ||
} | ||
let localizedRoute = assign({}, _route); | ||
if (localizedRoute.path && !localizedRoute.name) { | ||
const _resolvedRoute = $router.resolve(localizedRoute); | ||
const resolvedRoute2 = !isVue2 ? _resolvedRoute : _resolvedRoute.route; | ||
const resolvedRouteName = getRouteBaseName(resolvedRoute2); | ||
if (isString(resolvedRouteName)) { | ||
localizedRoute = { | ||
name: getLocaleRouteName(resolvedRouteName, _locale), | ||
params: resolvedRoute2.params, | ||
query: resolvedRoute2.query, | ||
hash: resolvedRoute2.hash | ||
}; | ||
} | ||
} else { | ||
localizedRoute.name = getLocaleRouteName(localizedRoute.name, _locale); | ||
const { params } = localizedRoute; | ||
if (params && params["0"] === void 0 && params.pathMatch) { | ||
params["0"] = params.pathMatch; | ||
} | ||
} | ||
const resolvedRoute = $router.resolve(localizedRoute); | ||
if (isVue2 ? resolvedRoute.route.name : resolvedRoute.name) { | ||
return resolvedRoute; | ||
} | ||
return $router.resolve(route); | ||
} | ||
function localePath(route, locale) { | ||
const localizedRoute = resolveRoute(route, locale); | ||
return localizedRoute == null ? "" : isVue2 ? localizedRoute.route.redirectedFrom || localizedRoute.route.fullPath : localizedRoute.redirectedFrom || localizedRoute.fullPath; | ||
return matchedLocales; | ||
} | ||
const DefaultBrowserLocaleMatcher = matchBrowserLocale; | ||
function compareBrowserLocale(a, b) { | ||
if (a.score === b.score) { | ||
return b.code.length - a.code.length; | ||
} | ||
function localeRoute(route, locale) { | ||
const resolved = resolveRoute(route, locale); | ||
return resolved == null ? void 0 : isVue2 ? resolved.route : resolved; | ||
return b.score - a.score; | ||
} | ||
const DefaultBrowerLocaleComparer = compareBrowserLocale; | ||
function findBrowserLocale(locales, browserLocales, { matcher = DefaultBrowserLocaleMatcher, comparer = DefaultBrowerLocaleComparer } = {}) { | ||
const normalizedLocales = []; | ||
for (const l of locales) { | ||
const { code } = l; | ||
const iso = l.iso || code; | ||
normalizedLocales.push({ code, iso }); | ||
} | ||
function localeLocation(route, locale) { | ||
const resolved = resolveRoute(route, locale); | ||
return resolved == null ? void 0 : isVue2 ? resolved.location : resolved.href; | ||
const matchedLocales = matcher(normalizedLocales, browserLocales); | ||
if (matchedLocales.length > 1) { | ||
matchedLocales.sort(comparer); | ||
} | ||
function switchLocalePath(locale) { | ||
const name = getRouteBaseName(); | ||
if (!name) { | ||
return ""; | ||
} | ||
const _a = isVue2 && isRef($route) ? $route.value : $route, { params } = _a, routeCopy = __objRest(_a, ["params"]); | ||
const langSwitchParams = {}; | ||
const baseRoute = assign({}, routeCopy, { | ||
name, | ||
params: __spreadProps(__spreadValues(__spreadValues({}, params), langSwitchParams), { | ||
0: params.pathMatch | ||
}) | ||
}); | ||
const path = localePath(baseRoute, locale); | ||
console.log("switchLocalePath", $i18n.locale.value, locale, path); | ||
return path; | ||
} | ||
return { | ||
getRouteBaseName, | ||
localePath, | ||
localeRoute, | ||
localeLocation, | ||
switchLocalePath | ||
}; | ||
return matchedLocales.length ? matchedLocales[0].code : ""; | ||
} | ||
function getRouteName(routeName) { | ||
return isString(routeName) ? routeName : isSymbol(routeName) ? routeName.toString() : "(null)"; | ||
} | ||
const STRATEGIES = { | ||
@@ -191,2 +216,96 @@ PREFIX: "prefix", | ||
const DEFAULT_LOCALE_ROUTE_NAME_SUFFIX = "default"; | ||
const DEFAULT_DETECTION_DIRECTION = "ltr"; | ||
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, { | ||
@@ -199,2 +318,3 @@ defaultLocale = DEFAULT_LOCALE, | ||
includeUprefixedFallback = false, | ||
optionsResolver = void 0, | ||
locales = [] | ||
@@ -210,2 +330,9 @@ } = {}) { | ||
} | ||
let routeOptions = null; | ||
if (optionsResolver != null) { | ||
routeOptions = optionsResolver(route, allowedLocaleCodes); | ||
if (routeOptions == null) { | ||
return [route]; | ||
} | ||
} | ||
const targetLocales = allowedLocaleCodes; | ||
@@ -258,10 +385,69 @@ return targetLocales.reduce((_routes, locale) => { | ||
} | ||
function extendI18n(i18n, { locales = [] } = {}) { | ||
if (!isComposer(i18n.global, i18n.mode)) { | ||
throw new Error(""); | ||
const optionsMap = /* @__PURE__ */ new Map(); | ||
function registerGlobalOptions(router, options) { | ||
if (!optionsMap.has(router)) { | ||
optionsMap.set(router, options); | ||
} | ||
const _locales = ref(locales); | ||
i18n.global.locales = computed(() => _locales.value); | ||
console.log("... extends i18n done"); | ||
} | ||
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) { | ||
@@ -276,10 +462,17 @@ return new RegExp(`^/(${localeCodes.join("|")})(?:/|$)`, "i"); | ||
const getLocaleFromRoute = (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]; | ||
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 (route.path) { | ||
const matches = route.path.match(regexpPath); | ||
} else if (isString(route)) { | ||
const matches = route.match(regexpPath); | ||
if (matches && matches.length > 1) { | ||
@@ -294,3 +487,3 @@ return matches[1]; | ||
function asDefaultVueI18nRouterOptions(options) { | ||
var _a, _b, _c, _d, _e, _f, _g, _h; | ||
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j; | ||
options.version = (_a = options.version) != null ? _a : 4; | ||
@@ -303,55 +496,424 @@ options.defaultLocale = (_b = options.defaultLocale) != null ? _b : DEFAULT_LOCALE; | ||
options.locales = (_g = options.locales) != null ? _g : []; | ||
options.routes = (_h = options.routes) != null ? _h : []; | ||
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 createRouter(i18n, 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 } = getI18nRoutingOptions(router, this); | ||
const route = givenRoute != null ? isRef(givenRoute) ? unref(givenRoute) : givenRoute : this.route; | ||
if (!route.name) { | ||
return; | ||
} | ||
const name = getRouteName(route.name); | ||
return name.split(routesNameSeparator)[0]; | ||
} | ||
function localePath(route, locale) { | ||
const localizedRoute = resolveRoute.call(this, route, locale); | ||
return localizedRoute == null ? "" : isVue3 ? localizedRoute.redirectedFrom || localizedRoute.fullPath : localizedRoute.route.redirectedFrom || localizedRoute.route.fullPath; | ||
} | ||
function localeRoute(route, locale) { | ||
const resolved = resolveRoute.call(this, route, locale); | ||
return resolved == null ? void 0 : isVue3 ? resolved : resolved.route; | ||
} | ||
function localeLocation(route, locale) { | ||
const resolved = resolveRoute.call(this, route, locale); | ||
return resolved == null ? void 0 : isVue3 ? resolved : resolved.location; | ||
} | ||
function resolveRoute(route, locale) { | ||
const router = this.router; | ||
const i18n = this.i18n; | ||
const _locale = locale || getLocale(i18n); | ||
const { routesNameSeparator, defaultLocale, defaultLocaleRouteNameSuffix, strategy, trailingSlash } = getI18nRoutingOptions(router, this); | ||
let _route = route; | ||
if (isString(route)) { | ||
if (_route[0] === "/") { | ||
_route = { path: route }; | ||
} else { | ||
_route = { name: route }; | ||
} | ||
} | ||
let localizedRoute = assign({}, _route); | ||
if (localizedRoute.path && !localizedRoute.name) { | ||
const _resolvedRoute = router.resolve(localizedRoute); | ||
const resolvedRoute2 = isVue3 ? _resolvedRoute : _resolvedRoute.route; | ||
const resolvedRouteName = getRouteBaseName.call(this, resolvedRoute2); | ||
if (isString(resolvedRouteName)) { | ||
localizedRoute = { | ||
name: getLocaleRouteName(resolvedRouteName, _locale, { | ||
defaultLocale, | ||
strategy, | ||
routesNameSeparator, | ||
defaultLocaleRouteNameSuffix | ||
}), | ||
params: resolvedRoute2.params, | ||
query: resolvedRoute2.query, | ||
hash: resolvedRoute2.hash | ||
}; | ||
} else { | ||
const isDefaultLocale = _locale === defaultLocale; | ||
const isPrefixed = !(isDefaultLocale && RESOLVED_PREFIXED.has(strategy)) && !(strategy === STRATEGIES.NO_PREFIX); | ||
if (isPrefixed) { | ||
localizedRoute.path = `/${_locale}${localizedRoute.path}`; | ||
} | ||
localizedRoute.path = trailingSlash ? withTrailingSlash(localizedRoute.path, true) : withoutTrailingSlash(localizedRoute.path, true); | ||
} | ||
} else { | ||
localizedRoute.name = getLocaleRouteName(localizedRoute.name, _locale, { | ||
defaultLocale, | ||
strategy, | ||
routesNameSeparator, | ||
defaultLocaleRouteNameSuffix | ||
}); | ||
const { params } = localizedRoute; | ||
if (params && params["0"] === void 0 && params.pathMatch) { | ||
params["0"] = params.pathMatch; | ||
} | ||
} | ||
const resolvedRoute = router.resolve(localizedRoute); | ||
if (isVue3 ? resolvedRoute.name : resolvedRoute.route.name) { | ||
return resolvedRoute; | ||
} | ||
return router.resolve(route); | ||
} | ||
function switchLocalePath(locale) { | ||
const route = this.route; | ||
const name = getRouteBaseName.call(this, route); | ||
if (!name) { | ||
return ""; | ||
} | ||
const _a = !isVue3 && isRef(route) ? route.value : route, { params } = _a, routeCopy = __objRest(_a, ["params"]); | ||
const langSwitchParams = {}; | ||
const baseRoute = assign({}, routeCopy, { | ||
name, | ||
params: __spreadProps(__spreadValues(__spreadValues({}, params), langSwitchParams), { | ||
0: params.pathMatch | ||
}) | ||
}); | ||
const path = localePath.call(this, baseRoute, locale); | ||
return path; | ||
} | ||
function localeHead({ addDirAttribute = false, addSeoAttributes = false } = {}) { | ||
const router = this.router; | ||
const i18n = this.i18n; | ||
const { defaultDirection } = getI18nRoutingOptions(router, this); | ||
const metaObject = { | ||
htmlAttrs: {}, | ||
link: [], | ||
meta: [] | ||
}; | ||
if (i18n.locales == null || i18n.__baseUrl == null) { | ||
return metaObject; | ||
} | ||
const locale = getLocale(i18n); | ||
const locales = getLocales(i18n); | ||
const currentLocale = getNormalizedLocales(locales).find((l) => l.code === locale) || { | ||
code: locale | ||
}; | ||
const currentLocaleIso = currentLocale.iso; | ||
const currentLocaleDir = currentLocale.dir || defaultDirection; | ||
if (addDirAttribute) { | ||
metaObject.htmlAttrs.dir = currentLocaleDir; | ||
} | ||
if (addSeoAttributes && locale && i18n.locales) { | ||
if (currentLocaleIso) { | ||
metaObject.htmlAttrs.lang = currentLocaleIso; | ||
} | ||
addHreflangLinks.call(this, locales, i18n.__baseUrl, metaObject.link); | ||
addCanonicalLinks.call(this, i18n.__baseUrl, metaObject.link, addSeoAttributes); | ||
addCurrentOgLocale(currentLocale, currentLocaleIso, metaObject.meta); | ||
addAlternateOgLocales(locales, currentLocaleIso, metaObject.meta); | ||
} | ||
return metaObject; | ||
} | ||
function addHreflangLinks(locales, baseUrl, link) { | ||
const router = this.router; | ||
const { defaultLocale, strategy } = getI18nRoutingOptions(router, this); | ||
if (strategy === STRATEGIES.NO_PREFIX) { | ||
return; | ||
} | ||
const localeMap = /* @__PURE__ */ new Map(); | ||
for (const locale of locales) { | ||
const localeIso = locale.iso; | ||
if (!localeIso) { | ||
warn("Locale ISO code is required to generate alternate link"); | ||
continue; | ||
} | ||
const [language, region] = localeIso.split("-"); | ||
if (language && region && (locale.isCatchallLocale || !localeMap.has(language))) { | ||
localeMap.set(language, locale); | ||
} | ||
localeMap.set(localeIso, locale); | ||
} | ||
for (const [iso, mapLocale] of localeMap.entries()) { | ||
const localePath2 = switchLocalePath.call(this, mapLocale.code); | ||
if (localePath2) { | ||
link.push({ | ||
hid: `i18n-alt-${iso}`, | ||
rel: "alternate", | ||
href: toAbsoluteUrl(localePath2, baseUrl), | ||
hreflang: iso | ||
}); | ||
} | ||
} | ||
if (defaultLocale) { | ||
const localePath2 = switchLocalePath.call(this, defaultLocale); | ||
if (localePath2) { | ||
link.push({ | ||
hid: "i18n-xd", | ||
rel: "alternate", | ||
href: toAbsoluteUrl(localePath2, baseUrl), | ||
hreflang: "x-default" | ||
}); | ||
} | ||
} | ||
} | ||
function addCanonicalLinks(baseUrl, link, seoAttributesOptions) { | ||
const route = this.route; | ||
const currentRoute = localeRoute.call(this, __spreadProps(__spreadValues({}, route), { | ||
name: getRouteBaseName.call(this, route) | ||
})); | ||
if (currentRoute) { | ||
let href = toAbsoluteUrl(currentRoute.path, baseUrl); | ||
const canonicalQueries = isObject(seoAttributesOptions) && seoAttributesOptions.canonicalQueries || []; | ||
if (canonicalQueries.length) { | ||
const currentRouteQueryParams = currentRoute.query; | ||
const params = new URLSearchParams(); | ||
for (const queryParamName of canonicalQueries) { | ||
if (queryParamName in currentRouteQueryParams) { | ||
const queryParamValue = currentRouteQueryParams[queryParamName]; | ||
if (isArray(queryParamValue)) { | ||
queryParamValue.forEach((v) => params.append(queryParamName, v || "")); | ||
} else { | ||
params.append(queryParamName, queryParamValue || ""); | ||
} | ||
} | ||
} | ||
const queryString = params.toString(); | ||
if (queryString) { | ||
href = `${href}?${queryString}`; | ||
} | ||
} | ||
link.push({ | ||
hid: "i18n-can", | ||
rel: "canonical", | ||
href | ||
}); | ||
} | ||
} | ||
function addCurrentOgLocale(currentLocale, currentLocaleIso, meta) { | ||
const hasCurrentLocaleAndIso = currentLocale && currentLocaleIso; | ||
if (!hasCurrentLocaleAndIso) { | ||
return; | ||
} | ||
meta.push({ | ||
hid: "i18n-og", | ||
property: "og:locale", | ||
content: hypenToUnderscore(currentLocaleIso) | ||
}); | ||
} | ||
function addAlternateOgLocales(locales, currentLocaleIso, meta) { | ||
const localesWithoutCurrent = locales.filter((locale) => { | ||
const localeIso = locale.iso; | ||
return localeIso && localeIso !== currentLocaleIso; | ||
}); | ||
if (localesWithoutCurrent.length) { | ||
const alternateLocales = localesWithoutCurrent.map((locale) => ({ | ||
hid: `i18n-og-alt-${locale.iso}`, | ||
property: "og:locale:alternate", | ||
content: hypenToUnderscore(locale.iso) | ||
})); | ||
meta.push(...alternateLocales); | ||
} | ||
} | ||
function hypenToUnderscore(str) { | ||
return (str || "").replace(/-/g, "_"); | ||
} | ||
function toAbsoluteUrl(urlOrPath, baseUrl) { | ||
if (urlOrPath.match(/^https?:\/\//)) { | ||
return urlOrPath; | ||
} | ||
return baseUrl + urlOrPath; | ||
} | ||
function proxyForComposable(options, target) { | ||
const { | ||
version, | ||
router, | ||
route, | ||
i18n, | ||
defaultLocale, | ||
locales, | ||
strategy, | ||
defaultLocaleRouteNameSuffix, | ||
trailingSlash, | ||
routesNameSeparator | ||
} = options; | ||
return function(...args) { | ||
return Reflect.apply(target, { | ||
router, | ||
route, | ||
i18n, | ||
defaultLocale, | ||
strategy, | ||
defaultLocaleRouteNameSuffix, | ||
trailingSlash, | ||
routesNameSeparator | ||
}, args); | ||
}; | ||
} | ||
function useRouteBaseName(givenRoute = useRoute(), { router = useRouter(), routesNameSeparator = void 0 } = {}) { | ||
const proxy = { | ||
router, | ||
route: givenRoute, | ||
routesNameSeparator | ||
}; | ||
return getRouteBaseName.call(proxy, givenRoute); | ||
} | ||
function useLocalePath({ | ||
router = useRouter(), | ||
route = useRoute(), | ||
i18n = useI18n(), | ||
defaultLocale = void 0, | ||
defaultLocaleRouteNameSuffix = void 0, | ||
routesNameSeparator = void 0, | ||
strategy = void 0, | ||
trailingSlash = void 0 | ||
} = {}) { | ||
return proxyForComposable({ router, route, i18n, defaultLocale, defaultLocaleRouteNameSuffix, routesNameSeparator, strategy, trailingSlash }, localePath); | ||
} | ||
function useLocaleRoute({ | ||
router = useRouter(), | ||
route = useRoute(), | ||
i18n = useI18n(), | ||
defaultLocale = void 0, | ||
defaultLocaleRouteNameSuffix = void 0, | ||
routesNameSeparator = void 0, | ||
strategy = void 0, | ||
trailingSlash = void 0 | ||
} = {}) { | ||
return proxyForComposable({ | ||
router, | ||
route, | ||
i18n, | ||
defaultLocale, | ||
defaultLocaleRouteNameSuffix, | ||
routesNameSeparator, | ||
strategy, | ||
trailingSlash | ||
}, localeRoute); | ||
} | ||
function useLocaleLocation({ | ||
router = useRouter(), | ||
route = useRoute(), | ||
i18n = useI18n(), | ||
defaultLocale = void 0, | ||
defaultLocaleRouteNameSuffix = void 0, | ||
routesNameSeparator = void 0, | ||
strategy = void 0, | ||
trailingSlash = void 0 | ||
} = {}) { | ||
return proxyForComposable({ | ||
router, | ||
route, | ||
i18n, | ||
defaultLocale, | ||
defaultLocaleRouteNameSuffix, | ||
routes | ||
} = asDefaultVueI18nRouterOptions(options); | ||
const normalizedLocaleCodes = getNormalizedLocales(locales); | ||
const getLocaleFromRoute = createLocaleFromRouteGetter(normalizedLocaleCodes.map((l) => l.code), routesNameSeparator, defaultLocaleRouteNameSuffix); | ||
extendI18n(i18n, { locales: normalizedLocaleCodes }); | ||
const localizedRoutes = localizeRoutes(routes, { | ||
locales, | ||
routesNameSeparator, | ||
strategy, | ||
trailingSlash | ||
}, localeLocation); | ||
} | ||
function useSwitchLocalePath({ | ||
router = useRouter(), | ||
route = useRoute(), | ||
i18n = useI18n(), | ||
defaultLocale = void 0, | ||
defaultLocaleRouteNameSuffix = void 0, | ||
routesNameSeparator = void 0, | ||
strategy = void 0, | ||
trailingSlash = void 0 | ||
} = {}) { | ||
return proxyForComposable({ | ||
router, | ||
route, | ||
i18n, | ||
defaultLocale, | ||
defaultLocaleRouteNameSuffix, | ||
routesNameSeparator, | ||
strategy, | ||
trailingSlash, | ||
routesNameSeparator, | ||
defaultLocaleRouteNameSuffix | ||
trailingSlash | ||
}, switchLocalePath); | ||
} | ||
function useLocaleHead({ | ||
addDirAttribute = false, | ||
addSeoAttributes = false, | ||
strategy = void 0, | ||
defaultLocale = void 0, | ||
route = useRoute(), | ||
router = useRouter(), | ||
i18n = useI18n() | ||
} = {}) { | ||
const _router = router; | ||
const metaObject = ref({ | ||
htmlAttrs: {}, | ||
link: [], | ||
meta: [] | ||
}); | ||
options.routes = localizedRoutes; | ||
let router = null; | ||
if (isVue3 && version === 4) { | ||
router = createRouter$1(options); | ||
} else if (isVue2 && version === 3) { | ||
router = new VueRouter3(options); | ||
function cleanMeta() { | ||
metaObject.value = { | ||
htmlAttrs: {}, | ||
link: [], | ||
meta: [] | ||
}; | ||
} | ||
function updateMeta(_route) { | ||
metaObject.value = Reflect.apply(localeHead, { | ||
router, | ||
route: _route, | ||
i18n, | ||
defaultLocale, | ||
strategy | ||
}, [{ addDirAttribute, addSeoAttributes }]); | ||
} | ||
if (inBrowser) { | ||
if (isVue3) { | ||
const stop = watchEffect(() => { | ||
cleanMeta(); | ||
updateMeta(toRawRoute(_router.currentRoute)); | ||
}); | ||
onUnmounted(() => stop()); | ||
} else { | ||
const handler = _router.afterEach((to, from) => { | ||
cleanMeta(); | ||
updateMeta(to); | ||
}); | ||
onUnmounted(() => handler()); | ||
updateMeta(route); | ||
} | ||
} else { | ||
throw new Error("TODO:"); | ||
updateMeta(toRawRoute(_router.currentRoute)); | ||
} | ||
router.__defaultLocale = defaultLocale; | ||
router.__strategy = strategy; | ||
router.__trailingSlash = trailingSlash; | ||
router.__routesNameSeparator = routesNameSeparator; | ||
router.__defaultLocaleRouteNameSuffix = defaultLocaleRouteNameSuffix; | ||
router.beforeEach((to, from, next) => { | ||
console.log("beforeEach", to, from); | ||
const currentLocale = getLocale(i18n); | ||
const finalLocale = getLocaleFromRoute(to) || currentLocale || defaultLocale || ""; | ||
console.log("currentLocale", currentLocale, "finalLocale", finalLocale); | ||
if (currentLocale !== finalLocale) { | ||
setLocale(i18n, finalLocale); | ||
} | ||
next(); | ||
}); | ||
console.log("create router", router); | ||
return router; | ||
return metaObject; | ||
} | ||
const VERSION = ""; | ||
export { VERSION, createRouter, localizeRoutes, useI18nRouting }; | ||
const VERSION = "0.0.0"; | ||
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 ue=Object.defineProperty,se=Object.defineProperties;var fe=Object.getOwnPropertyDescriptors;var b=Object.getOwnPropertySymbols;var W=Object.prototype.hasOwnProperty,k=Object.prototype.propertyIsEnumerable;var B=(r,a,s)=>a in r?ue(r,a,{enumerable:!0,configurable:!0,writable:!0,value:s}):r[a]=s,T=(r,a)=>{for(var s in a||(a={}))W.call(a,s)&&B(r,s,a[s]);if(b)for(var s of b(a))k.call(a,s)&&B(r,s,a[s]);return r},O=(r,a)=>se(r,fe(a));var D=(r,a)=>{var s={};for(var p in r)W.call(r,p)&&a.indexOf(p)<0&&(s[p]=r[p]);if(r!=null&&b)for(var p of b(r))a.indexOf(p)<0&&k.call(r,p)&&(s[p]=r[p]);return s};var VueI18nRouting=function(r,a,s,p){"use strict";function H(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var Y=H(s);/*! | ||
* shared v9.2.0-beta.26 | ||
* (c) 2021 kazuya kawaguchi | ||
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 V=Object.assign,P=e=>typeof e=="string",J=e=>typeof e=="symbol";function K(e){e=e||[];const o=[];for(const l of e)P(l)?o.push({code:l}):o.push(l);return o}function y(e,o){return a.isRef(e.locale)&&o==="composition"}function U(e){return"global"in e&&"mode"in e}function w(e){return U(e)?y(e.global,e.mode)?e.global.locale.value:e.global.locale:e.locale.value}function Q(e,o){U(e)?y(e.global,e.mode)?e.global.locale.value=o:e.global.locale=o:a.isRef(e.locale)&&(e.locale.value=o)}function Z(e,o,l){return e.replace(/\/+$/,"")+(o?"/":"")||(l?"":"/")}function ee(e={}){const o=p.useI18n(),l=s.useRouter(),h=s.useRoute(),m=e.defaultLocaleRouteNameSuffix||l.__defaultLocaleRouteNameSuffix,E=e.defaultLocale||l.__defaultLocale,g=e.routesNameSeparator||l.__routesNameSeparator,S=e.strategy||l.__strategy;function f(c){const u=c!=null?c:a.isRef(h)?h.value:h;return u.name?z(u.name).split(g)[0]:void 0}function L(c,u){let t=z(c)+(S==="no_prefix"?"":g+u);return u===E&&S==="prefix_and_default"&&(t+=g+m),t}function n(c,u){const t=u||w(o);let i=c;P(c)&&(c[0]==="/"?i={path:c}:i={name:c});let d=V({},i);if(d.path&&!d.name){const _=l.resolve(d),$=a.isVue2?_.route:_,F=f($);P(F)&&(d={name:L(F,t),params:$.params,query:$.query,hash:$.hash})}else{d.name=L(d.name,t);const{params:_}=d;_&&_["0"]===void 0&&_.pathMatch&&(_["0"]=_.pathMatch)}const x=l.resolve(d);return(a.isVue2?x.route.name:x.name)?x:l.resolve(c)}function A(c,u){const t=n(c,u);return t==null?"":a.isVue2?t.route.redirectedFrom||t.route.fullPath:t.redirectedFrom||t.fullPath}function I(c,u){const t=n(c,u);return t==null?void 0:a.isVue2?t.route:t}function R(c,u){const t=n(c,u);return t==null?void 0:a.isVue2?t.location:t.href}function N(c){const u=f();if(!u)return"";const $=a.isVue2&&a.isRef(h)?h.value:h,{params:t}=$,i=D($,["params"]),d={},x=V({},i,{name:u,params:O(T(T({},t),d),{0:t.pathMatch})}),_=A(x,c);return console.log("switchLocalePath",o.locale.value,c,_),_}return{getRouteBaseName:f,localePath:A,localeRoute:I,localeLocation:R,switchLocalePath:N}}function z(e){return P(e)?e:J(e)?e.toString():"(null)"}const te={PREFIX:"prefix",PREFIX_EXCEPT_DEFAULT:"prefix_except_default",PREFIX_AND_DEFAULT:"prefix_and_default",NO_PREFIX:"no_prefix"},X="",M=te.PREFIX_EXCEPT_DEFAULT,j=!1,C="___",G="default";function q(e,{defaultLocale:o=X,strategy:l=M,trailingSlash:h=j,routesNameSeparator:m=C,defaultLocaleRouteNameSuffix:E=G,includeUprefixedFallback:g=!1,locales:S=[]}={}){if(l==="no_prefix")return e;const f=S.map(n=>P(n)?n:n.code);function L(n,A,I=!1,R=!1){return n.redirect&&(!n.component||!n.file)?[n]:A.reduce((c,u)=>{const{name:t}=n;let{path:i}=n;const d=T({},n);t&&(d.name=`${t}${m}${u}`),n.children&&(d.children=n.children.reduce((F,v)=>[...F,...L(v,[u],!0,R)],[]));const x=u===o;if(x&&l==="prefix_and_default")if(I)I&&R&&t&&(d.name+=`${m}${E}`);else{const F=O(T({},d),{path:i});if(t&&(F.name=`${d.name}${m}${E}`),n.children){F.children=[];for(const v of n.children)F.children=F.children.concat(L(v,[u],!0,!0))}c.push(F)}const _=I&&!i.startsWith("/"),$=!_&&!(x&&l==="prefix_except_default");return $&&(i=`/${u}${i}`),i&&(i=Z(i,h,_)),$&&x&&l==="prefix"&&g&&c.push(T({},n)),d.path=i,c.push(d),c},[])}return e.reduce((n,A)=>[...n,...L(A,f||[])],[])}function ae(e,{locales:o=[]}={}){if(!y(e.global,e.mode))throw new Error("");const l=a.ref(o);e.global.locales=a.computed(()=>l.value),console.log("... extends i18n done")}function oe(e){return new RegExp(`^/(${e.join("|")})(?:/|$)`,"i")}function ne(e,o,l){const h=`(${e.join("|")})`,m=`(?:${o}${l})?`,E=new RegExp(`${o}${h}${m}$`,"i"),g=oe(e);return f=>{if(f.name){const n=(P(f.name)?f.name:f.name.toString()).match(E);if(n&&n.length>1)return n[1]}else if(f.path){const L=f.path.match(g);if(L&&L.length>1)return L[1]}return""}}function le(e){var o,l,h,m,E,g,S,f;return e.version=(o=e.version)!=null?o:4,e.defaultLocale=(l=e.defaultLocale)!=null?l:X,e.strategy=(h=e.strategy)!=null?h:M,e.trailingSlash=(m=e.trailingSlash)!=null?m:j,e.routesNameSeparator=(E=e.routesNameSeparator)!=null?E:C,e.defaultLocaleRouteNameSuffix=(g=e.defaultLocaleRouteNameSuffix)!=null?g:G,e.locales=(S=e.locales)!=null?S:[],e.routes=(f=e.routes)!=null?f:[],e}function ce(e,o={}){const{version:l,defaultLocale:h,locales:m,strategy:E,trailingSlash:g,routesNameSeparator:S,defaultLocaleRouteNameSuffix:f,routes:L}=le(o),n=K(m),A=ne(n.map(N=>N.code),S,f);ae(e,{locales:n});const I=q(L,{locales:m,defaultLocale:h,strategy:E,trailingSlash:g,routesNameSeparator:S,defaultLocaleRouteNameSuffix:f});o.routes=I;let R=null;if(a.isVue3&&l===4)R=s.createRouter(o);else if(a.isVue2&&l===3)R=new Y.default(o);else throw new Error("TODO:");return R.__defaultLocale=h,R.__strategy=E,R.__trailingSlash=g,R.__routesNameSeparator=S,R.__defaultLocaleRouteNameSuffix=f,R.beforeEach((N,c,u)=>{console.log("beforeEach",N,c);const t=w(e),i=A(N)||t||h||"";console.log("currentLocale",t,"finalLocale",i),t!==i&&Q(e,i),u()}),console.log("create router",R),R}const re="";return r.VERSION=re,r.createRouter=ce,r.localizeRoutes=q,r.useI18nRouting=ee,Object.defineProperty(r,"__esModule",{value:!0}),r[Symbol.toStringTag]="Module",r}({},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-6956b1d", | ||
"version": "0.0.0-6abd48e", | ||
"dependencies": { | ||
"@intlify/shared": "beta", | ||
"@intlify/vue-i18n-bridge": "^0.3.4", | ||
"@intlify/vue-router-bridge": "^0.3.4", | ||
"@intlify/shared": "next", | ||
"@intlify/vue-i18n-bridge": "^0.3.5", | ||
"@intlify/vue-router-bridge": "^0.3.5", | ||
"ufo": "^0.7.9", | ||
"vue-demi": "^0.12.1" | ||
@@ -13,13 +14,16 @@ }, | ||
"@microsoft/api-extractor": "^7.18.20", | ||
"@vue/test-utils": "^1.3.0", | ||
"api-docs-gen": "^0.4.0", | ||
"rimraf": "^3.0.2", | ||
"typescript": "^4.5.4", | ||
"vite": "^2.7.4", | ||
"vite": "latest", | ||
"vite-plugin-dts": "^0.9.6", | ||
"vitest": "^0.2.8", | ||
"vue": "^3.2.23", | ||
"vue-i18n": "npm:vue-i18n@next", | ||
"vue-i18n-bridge": "beta", | ||
"vue-i18n-legacy": "npm:vue-i18n@latest", | ||
"vue-i18n-bridge": "next", | ||
"vue-i18n-legacy": "npm:vue-i18n@8", | ||
"vue-router": "^4.0.12", | ||
"vue-router3": "npm:vue-router@latest", | ||
"vue-router3": "npm:vue-router@3", | ||
"vue-template-compiler": "^2.6.14", | ||
"vue2": "npm:vue@2" | ||
@@ -30,4 +34,4 @@ }, | ||
"vue": "^2.6.14 || ^3.2.0", | ||
"vue-i18n": "^8.26.1 || ^9.2.0-beta.25", | ||
"vue-i18n-bridge": "^9.2.0-beta.25", | ||
"vue-i18n": "^8.26.1 || ^9.2.0-beta.34", | ||
"vue-i18n-bridge": "^9.2.0-beta.34", | ||
"vue-router": "^3.5.3 || ^4.0.0" | ||
@@ -49,2 +53,3 @@ }, | ||
"index.mjs", | ||
"types.d.ts", | ||
"LICENSE", | ||
@@ -64,4 +69,10 @@ "README.md" | ||
}, | ||
"require": "./dist/vue-i18n-routing.cjs.js" | ||
} | ||
"require": "./dist/vue-i18n-routing.cjs.js", | ||
"types": "./dist/vue-i18n-routing.d.ts" | ||
}, | ||
"./types": { | ||
"types": "./types.d.ts" | ||
}, | ||
"./package.json": "./package.json", | ||
"./dist/*": "./dist/*" | ||
}, | ||
@@ -93,4 +104,7 @@ "license": "MIT", | ||
"typecheck": "tsc -p . --noEmit", | ||
"test": "vitest run", | ||
"test:watch": "vitest", | ||
"test:cover": "vitest --coverage", | ||
"build:docs": "api-docs-gen ./temp/vue-i18n-routing.api.json -c ./docsgen.config.js -o ./ -g noprefix" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
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
91058
11
1667
10
16
1
+ Addedufo@^0.7.9
+ Added@intlify/shared@11.0.0-rc.1(transitive)
+ Addedufo@0.7.11(transitive)
- Removed@intlify/shared@9.3.0-beta.27(transitive)
Updated@intlify/shared@next