vue-i18n-routing
Advanced tools
Comparing version 0.0.0-3801eb7 to 0.0.0-3e99379
@@ -1,5 +0,5 @@ | ||
"use strict";var W=Object.defineProperty,k=Object.defineProperties;var H=Object.getOwnPropertyDescriptors;var b=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(b)for(var a of b(t))D.call(t,a)&&O(e,a,t[a]);return e},P=(e,t)=>k(e,H(t));var V=(e,t)=>{var a={};for(var r in e)y.call(e,r)&&t.indexOf(r)<0&&(a[r]=e[r]);if(e!=null&&b)for(var r of b(e))t.indexOf(r)<0&&D.call(e,r)&&(a[r]=e[r]);return a};Object.defineProperty(exports,"__esModule",{value:!0});exports[Symbol.toStringTag]="Module";var m=require("vue-demi"),A=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(A);/*! | ||
* shared v9.2.0-beta.26 | ||
* (c) 2021 kazuya kawaguchi | ||
"use strict";var Se=Object.defineProperty,Ee=Object.defineProperties;var Pe=Object.getOwnPropertyDescriptors;var j=Object.getOwnPropertySymbols;var ae=Object.prototype.hasOwnProperty,le=Object.prototype.propertyIsEnumerable;var oe=(e,t,o)=>t in e?Se(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,v=(e,t)=>{for(var o in t||(t={}))ae.call(t,o)&&oe(e,o,t[o]);if(j)for(var o of j(t))le.call(t,o)&&oe(e,o,t[o]);return e},X=(e,t)=>Ee(e,Pe(t));var ne=(e,t)=>{var o={};for(var a in e)ae.call(e,a)&&t.indexOf(a)<0&&(o[a]=e[a]);if(e!=null&&j)for(var a of j(e))t.indexOf(a)<0&&le.call(e,a)&&(o[a]=e[a]);return o};Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var h=require("vue-demi"),L=require("@intlify/vue-router-bridge"),O=require("@intlify/vue-i18n-bridge");function ye(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var Ne=ye(L);/*! | ||
* shared v9.2.0-beta.34 | ||
* (c) 2022 kazuya kawaguchi | ||
* Released under the MIT License. | ||
*/const U=Object.assign,T=e=>typeof e=="string",Q=e=>typeof e=="symbol";function Z(e){e=e||[];const t=[];for(const a of e)T(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=A.useRouter(),r=A.useRoute(),R=e.defaultLocaleRouteNameSuffix||a.__defaultLocaleRouteNameSuffix,g=e.defaultLocale||a.__defaultLocale,_=e.routesNameSeparator||a.__routesNameSeparator,L=e.strategy||a.__strategy;function s(o){const c=o!=null?o:m.isRef(r)?r.value:r;return c.name?C(c.name).split(_)[0]:void 0}function h(o,c){let l=C(o)+(L==="no_prefix"?"":_+c);return c===g&&L==="prefix_and_default"&&(l+=_+R),l}function n(o,c){const l=c||z(t);let f=o;T(o)&&(o[0]==="/"?f={path:o}:f={name:o});let u=U({},f);if(u.path&&!u.name){const d=a.resolve(u),v=m.isVue2?d.route:d,E=s(v);T(E)&&(u={name:h(E,l),params:v.params,query:v.query,hash:v.hash})}else{u.name=h(u.name,l);const{params:d}=u;d&&d["0"]===void 0&&d.pathMatch&&(d["0"]=d.pathMatch)}const S=a.resolve(u);return(m.isVue2?S.route.name:S.name)?S:a.resolve(o)}function p(o,c){const l=n(o,c);return l==null?"":m.isVue2?l.route.redirectedFrom||l.route.fullPath:l.redirectedFrom||l.fullPath}function x(o,c){const l=n(o,c);return l==null?void 0:m.isVue2?l.route:l}function $(o,c){const l=n(o,c);return l==null?void 0:m.isVue2?l.location:l.href}function i(o){const c=s();if(!c)return"";const v=m.isVue2&&m.isRef(r)?r.value:r,{params:l}=v,f=V(v,["params"]),u={},S=U({},f,{name:c,params:P(F(F({},l),u),{0:l.pathMatch})}),d=p(S,o);return console.log("switchLocalePath",t.locale.value,o,d),d}return{getRouteBaseName:s,localePath:p,localeRoute:x,localeLocation:$,switchLocalePath:i}}function C(e){return T(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"},X="",M=oe.PREFIX_EXCEPT_DEFAULT,j=!1,q="___",G="default";function B(e,{defaultLocale:t=X,strategy:a=M,trailingSlash:r=j,routesNameSeparator:R=q,defaultLocaleRouteNameSuffix:g=G,includeUprefixedFallback:_=!1,locales:L=[]}={}){if(a==="no_prefix")return e;const s=L.map(n=>T(n)?n:n.code);function h(n,p,x=!1,$=!1){return n.redirect&&(!n.component||!n.file)?[n]:p.reduce((o,c)=>{const{name:l}=n;let{path:f}=n;const u=F({},n);l&&(u.name=`${l}${R}${c}`),n.children&&(u.children=n.children.reduce((E,N)=>[...E,...h(N,[c],!0,$)],[]));const S=c===t;if(S&&a==="prefix_and_default")if(x)x&&$&&l&&(u.name+=`${R}${g}`);else{const E=P(F({},u),{path:f});if(l&&(E.name=`${u.name}${R}${g}`),n.children){E.children=[];for(const N of n.children)E.children=E.children.concat(h(N,[c],!0,!0))}o.push(E)}const d=x&&!f.startsWith("/"),v=!d&&!(S&&a==="prefix_except_default");return v&&(f=`/${c}${f}`),f&&(f=te(f,r,d)),v&&S&&a==="prefix"&&_&&o.push(F({},n)),u.path=f,o.push(u),o},[])}return e.reduce((n,p)=>[...n,...h(p,s||[])],[])}function le(e,{locales:t=[]}={}){if(!I(e.global,e.mode))throw new Error("TODO:");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 r=`(${e.join("|")})`,R=`(?:${t}${a})?`,g=new RegExp(`${t}${r}${R}$`,"i"),_=ne(e);return s=>{if(s.name){const n=(T(s.name)?s.name:s.name.toString()).match(g);if(n&&n.length>1)return n[1]}else if(s.path){const h=s.path.match(_);if(h&&h.length>1)return h[1]}return""}}function ce(e){var t,a,r,R,g,_,L,s;return e.version=(t=e.version)!=null?t:4,e.defaultLocale=(a=e.defaultLocale)!=null?a:X,e.strategy=(r=e.strategy)!=null?r:M,e.trailingSlash=(R=e.trailingSlash)!=null?R:j,e.routesNameSeparator=(g=e.routesNameSeparator)!=null?g:q,e.defaultLocaleRouteNameSuffix=(_=e.defaultLocaleRouteNameSuffix)!=null?_:G,e.locales=(L=e.locales)!=null?L:[],e.routes=(s=e.routes)!=null?s:[],e}function ue(e,t={}){const{version:a,defaultLocale:r,locales:R,strategy:g,trailingSlash:_,routesNameSeparator:L,defaultLocaleRouteNameSuffix:s,routes:h}=ce(t),n=Z(R),p=n.map(o=>o.code),x=re(p,L,s);le(e,{locales:n});const $=B(h,{locales:R,defaultLocale:r,strategy:g,trailingSlash:_,routesNameSeparator:L,defaultLocaleRouteNameSuffix:s});t.routes=$;let i=null;if(m.isVue3&&a===4)i=A.createRouter(t);else if(m.isVue2&&a===3)i=new K.default(t);else throw new Error("TODO:");return i.__defaultLocale=r,i.__localeCodes=p,i.__strategy=g,i.__trailingSlash=_,i.__routesNameSeparator=L,i.__defaultLocaleRouteNameSuffix=s,i.beforeEach((o,c,l)=>{console.log("beforeEach",o,c);const f=z(e),u=x(o)||f||r||"";console.log("currentLocale",f,"finalLocale",u),f!==u&&ee(e,u),l()}),console.log("create router",i),i}const se="0.0.0";exports.VERSION=se;exports.createRouter=ue;exports.localizeRoutes=B;exports.useI18nRouting=ae; | ||
*/const se=Object.assign,xe=Array.isArray,ve=e=>typeof e=="function",A=e=>typeof e=="string",Ie=e=>typeof e=="symbol",ue=e=>e!==null&&typeof e=="object",Ae=/\/$|\/\?/;function Q(e="",t=!1){return t?Ae.test(e):e.endsWith("/")}function we(e="",t=!1){if(!t)return(Q(e)?e.slice(0,-1):e)||"/";if(!Q(e,!0))return e||"/";const[o,...a]=e.split("?");return(o.slice(0,-1)||"/")+(a.length?`?${a.join("?")}`:"")}function Ce(e="",t=!1){if(!t)return e.endsWith("/")?e:e+"/";if(Q(e,!0))return e||"/";const[o,...a]=e.split("?");return o+"/"+(a.length?`?${a.join("?")}`:"")}const De=typeof window!="undefined";function Fe(e,t){typeof console!="undefined"&&(console.warn("[vue-i18n-routing] "+e),t&&console.warn(t.stack))}function ie(e){e=e||[];const t=[];for(const o of e)A(o)?t.push({code:o}):t.push(o);return t}function M(e){return e!=null&&"global"in e&&"mode"in e}function k(e){return e!=null&&!("__composer"in e)&&h.isRef(e.locale)}function V(e){return e!=null&&"__composer"in e}function J(e){return e!=null&&!("__composer"in e)&&!h.isRef(e.locale)}function D(e){return e!=null&&("__VUE_I18N_BRIDGE__"in e||"_sync"in e)}function fe(e){return M(e)?k(e.global)?e.global:e.global.__composer:V(e)?e.__composer:e}function z(e){const t=M(e)?e.global:e;return k(t)?h.isVue2&&D(e)?e.locale:t.locale.value:(J(t)||V(t)||D(t),t.locale)}function Te(e){const t=M(e)?e.global:e;return k(t)?h.isVue2&&D(e)?e.locales:t.locales.value:(J(t)||V(t)||D(t),t.locales)}function he(e,t){const o=M(e)?e.global:e;if(k(o))h.isVue2&&D(e)?e.locale=t:o.locale.value=t;else if(J(o)||V(o)||D(o))o.locale=t;else throw new Error("TODO:")}function be(e,t,o){return e.replace(/\/+$/,"")+(t?"/":"")||(o?"":"/")}function re(e){return L.isVueRouter4,h.isRef(e)?e.value:e}function de(e){return A(e)?e:Ie(e)?e.toString():"(null)"}function ce(e,t,{defaultLocale:o,strategy:a,routesNameSeparator:l,defaultLocaleRouteNameSuffix:n}){let r=de(e)+(a==="no_prefix"?"":l+t);return t===o&&a==="prefix_and_default"&&(r+=l+n),r}function _e(e,t){return ve(e)?e(t):e}function Ue(e,t){const o=[];for(const[a,l]of t.entries()){const n=e.find(r=>r.iso.toLowerCase()===l.toLowerCase());if(n){o.push({code:n.code,score:1-a/t.length});break}}for(const[a,l]of t.entries()){const n=l.split("-")[0].toLowerCase(),r=e.find(c=>c.iso.split("-")[0].toLowerCase()===n);if(r){o.push({code:r.code,score:.999-a/t.length});break}}return o}const $e=Ue;function Oe(e,t){return e.score===t.score?t.code.length-e.code.length:t.score-e.score}const Ve=Oe;function Be(e,t,{matcher:o=$e,comparer:a=Ve}={}){const l=[];for(const r of e){const{code:c}=r,s=r.iso||c;l.push({code:c,iso:s})}const n=o(l,t);return n.length>1&&n.sort(a),n.length?n[0].code:""}const U={PREFIX:"prefix",PREFIX_EXCEPT_DEFAULT:"prefix_except_default",PREFIX_AND_DEFAULT:"prefix_and_default",NO_PREFIX:"no_prefix"},y="",N=U.PREFIX_EXCEPT_DEFAULT,me=!1,P="___",w="default",je="ltr",Le="",Xe=new Set([U.PREFIX_AND_DEFAULT,U.PREFIX_EXCEPT_DEFAULT]);function F(e){const o=this.router.__routesNameSeparator||this.__routesNameSeparator||P,a=e!=null?h.isRef(e)?h.unref(e):e:this.route;return a.name?de(a.name).split(o)[0]:void 0}function q(e,t){const o=B.call(this,e,t);return o==null?"":h.isVue3?o.redirectedFrom||o.fullPath:o.route.redirectedFrom||o.route.fullPath}function H(e,t){const o=B.call(this,e,t);return o==null?void 0:h.isVue3?o:o.route}function K(e,t){const o=B.call(this,e,t);return o==null?void 0:h.isVue3?o:o.location}function B(e,t){const o=this.router,a=this.i18n,l=t||z(a),n=this.__defaultLocale||y,r=o.__defaultLocale||n,c=o.__defaultLocaleRouteNameSuffix||this.__defaultLocaleRouteNameSuffix||w,s=o.__routesNameSeparator||this.__routesNameSeparator||P,u=o.__strategy||this.__strategy||N,f=o.__trailingSlash||this.__trailingSlash||!1;let i=e;A(e)&&(i[0]==="/"?i={path:e}:i={name:e});let d=se({},i);if(d.path&&!d.name){const _=o.resolve(d),E=h.isVue3?_:_.route,T=F.call(this,E);A(T)?d={name:ce(T,l,{defaultLocale:r,strategy:u,routesNameSeparator:s,defaultLocaleRouteNameSuffix:c}),params:E.params,query:E.query,hash:E.hash}:(!(l===n&&Xe.has(u))&&u!==U.NO_PREFIX&&(d.path=`/${l}${d.path}`),d.path=f?Ce(d.path,!0):we(d.path,!0))}else{d.name=ce(d.name,l,{defaultLocale:r,strategy:u,routesNameSeparator:s,defaultLocaleRouteNameSuffix:c});const{params:_}=d;_&&_["0"]===void 0&&_.pathMatch&&(_["0"]=_.pathMatch)}const R=o.resolve(d);return(h.isVue3?R.name:R.route.name)?R:o.resolve(e)}function $(e){const t=this.route,o=F.call(this,t);if(!o)return"";const s=!h.isVue3&&h.isRef(t)?t.value:t,{params:a}=s,l=ne(s,["params"]),n={},r=se({},l,{name:o,params:X(v(v({},a),n),{0:a.pathMatch})});return q.call(this,r,e)}function Z({addDirAttribute:e=!1,addSeoAttributes:t=!1}={}){const o=this.router,a=this.i18n,l={htmlAttrs:{},link:[],meta:[]};if(a.locales==null||a.__baseUrl==null)return l;const n=z(a),r=Te(a),c=ie(r).find(f=>f.code===n)||{code:n},s=c.iso,u=c.dir||o.__defaultDirection;return e&&(l.htmlAttrs.dir=u),t&&n&&a.locales&&(s&&(l.htmlAttrs.lang=s),Me.call(this,r,a.__baseUrl,l.link),ke.call(this,a.__baseUrl,l.link,t),ze(c,s,l.meta),qe(r,s,l.meta)),l}function Me(e,t,o){const a=this.router,l=a.__defaultLocale||this.__defaultLocale;if((a.__strategy||this.__strategy)===U.NO_PREFIX)return;const r=new Map;for(const c of e){const s=c.iso;if(!s){Fe("Locale ISO code is required to generate alternate link");continue}const[u,f]=s.split("-");u&&f&&(c.isCatchallLocale||!r.has(u))&&r.set(u,c),r.set(s,c)}for(const[c,s]of r.entries()){const u=$.call(this,s.code);u&&o.push({hid:`i18n-alt-${c}`,rel:"alternate",href:Y(u,t),hreflang:c})}if(l){const c=$.call(this,l);c&&o.push({hid:"i18n-xd",rel:"alternate",href:Y(c,t),hreflang:"x-default"})}}function ke(e,t,o){const a=this.route,l=H.call(this,X(v({},a),{name:F.call(this,a)}));if(l){let n=Y(l.path,e);const r=ue(o)&&o.canonicalQueries||[];if(r.length){const c=l.query,s=new URLSearchParams;for(const f of r)if(f in c){const i=c[f];xe(i)?i.forEach(d=>s.append(f,d||"")):s.append(f,i||"")}const u=s.toString();u&&(n=`${n}?${u}`)}t.push({hid:"i18n-can",rel:"canonical",href:n})}}function ze(e,t,o){!(e&&t)||o.push({hid:"i18n-og",property:"og:locale",content:Re(t)})}function qe(e,t,o){const a=e.filter(l=>{const n=l.iso;return n&&n!==t});if(a.length){const l=a.map(n=>({hid:`i18n-og-alt-${n.iso}`,property:"og:locale:alternate",content:Re(n.iso)}));o.push(...l)}}function Re(e){return(e||"").replace(/-/g,"_")}function Y(e,t){return e.match(/^https?:\/\//)?e:t+e}function G(e,t){const{router:o,route:a,i18n:l,defaultLocale:n,strategy:r,defaultLocaleRouteNameSuffix:c,trailingSlash:s,routesNameSeparator:u}=e;return function(...f){return Reflect.apply(t,{router:o,route:a,i18n:l,__defaultLocale:n,__strategy:r,__defaultLocaleRouteNameSuffix:c,__trailingSlash:s,__routesNameSeparator:u},f)}}function He(e=L.useRoute(),{router:t=L.useRouter(),routesNameSeparator:o=P}={}){const a={router:t,route:e,__routesNameSeparator:o};return F.call(a,e)}function Ge({router:e=L.useRouter(),route:t=L.useRoute(),i18n:o=O.useI18n(),defaultLocale:a=y,defaultLocaleRouteNameSuffix:l=w,routesNameSeparator:n=P,strategy:r=N,trailingSlash:c=!1}={}){return G({router:e,route:t,i18n:o,defaultLocale:a,defaultLocaleRouteNameSuffix:l,routesNameSeparator:n,strategy:r,trailingSlash:c},q)}function We({router:e=L.useRouter(),route:t=L.useRoute(),i18n:o=O.useI18n(),defaultLocale:a=y,defaultLocaleRouteNameSuffix:l=w,routesNameSeparator:n=P,strategy:r=N,trailingSlash:c=!1}={}){return G({router:e,route:t,i18n:o,defaultLocale:a,defaultLocaleRouteNameSuffix:l,routesNameSeparator:n,strategy:r,trailingSlash:c},H)}function Qe({router:e=L.useRouter(),route:t=L.useRoute(),i18n:o=O.useI18n(),defaultLocale:a=y,defaultLocaleRouteNameSuffix:l=w,routesNameSeparator:n=P,strategy:r=N,trailingSlash:c=!1}={}){return G({router:e,route:t,i18n:o,defaultLocale:a,defaultLocaleRouteNameSuffix:l,routesNameSeparator:n,strategy:r,trailingSlash:c},K)}function Ye({router:e=L.useRouter(),route:t=L.useRoute(),i18n:o=O.useI18n(),defaultLocale:a=y,defaultLocaleRouteNameSuffix:l=w,routesNameSeparator:n=P,strategy:r=N,trailingSlash:c=!1}={}){return G({router:e,route:t,i18n:o,defaultLocale:a,defaultLocaleRouteNameSuffix:l,routesNameSeparator:n,strategy:r,trailingSlash:c},$)}function Je({addDirAttribute:e=!1,addSeoAttributes:t=!1,strategy:o=N,defaultLocale:a=y,route:l=L.useRoute(),router:n=L.useRouter(),i18n:r=O.useI18n()}={}){const c=n,s=h.ref({htmlAttrs:{},link:[],meta:[]});function u(){s.value={htmlAttrs:{},link:[],meta:[]}}function f(i){s.value=Reflect.apply(Z,{router:n,route:i,i18n:r,__defaultLocale:a,__strategy:o},[{addDirAttribute:e,addSeoAttributes:t}])}if(De)if(h.isVue3){const i=h.watchEffect(()=>{u(),f(re(c.currentRoute))});h.onUnmounted(()=>i())}else{const i=c.afterEach((d,R)=>{u(),f(d)});h.onUnmounted(()=>i()),f(l)}else f(re(c.currentRoute));return s}function pe(e,{defaultLocale:t=y,strategy:o=N,trailingSlash:a=me,routesNameSeparator:l=P,defaultLocaleRouteNameSuffix:n=w,includeUprefixedFallback:r=!1,optionsResolver:c=void 0,locales:s=[]}={}){if(o==="no_prefix")return e;const u=s.map(i=>A(i)?i:i.code);function f(i,d,R=!1,_=!1){if(i.redirect&&(!i.component||!i.file))return[i];let E=null;return c!=null&&(E=c(i,d),E==null)?[i]:d.reduce((m,p)=>{const{name:b}=i;let{path:g}=i;const S=v({},i);b&&(S.name=`${b}${l}${p}`),i.children&&(S.children=i.children.reduce((x,W)=>[...x,...f(W,[p],!0,_)],[]));const C=p===t;if(C&&o==="prefix_and_default")if(R)R&&_&&b&&(S.name+=`${l}${n}`);else{const x=X(v({},S),{path:g});if(b&&(x.name=`${S.name}${l}${n}`),i.children){x.children=[];for(const W of i.children)x.children=x.children.concat(f(W,[p],!0,!0))}m.push(x)}const ee=R&&!g.startsWith("/"),te=!ee&&!(C&&o==="prefix_except_default");return te&&(g=`/${p}${g}`),g&&(g=be(g,a,ee)),te&&C&&o==="prefix"&&r&&m.push(v({},i)),S.path=g,m.push(S),m},[])}return e.reduce((i,d)=>[...i,...f(d,u||[])],[])}function I(e){return function(){return Reflect.apply(e,{getRouteBaseName:this.getRouteBaseName,localePath:this.localePath,localeRoute:this.localeRoute,localeLocation:this.localeLocation,resolveRoute:this.resolveRoute,switchLocalePath:this.switchLocalePath,localeHead:this.localeHead,i18n:this.$i18n,route:this.$route,router:this.$router},arguments)}}function Ke(e,{locales:t=[],localeCodes:o=[],baseUrl:a=Le}={}){const l=e.install;e.install=(n,...r)=>{Reflect.apply(l,e,[n,...r]);const c=fe(e);Ze(c,{locales:t,localeCodes:o,baseUrl:a}),V(e.global)&&tt(e.global);const s=n,u=e.mode==="composition"?h.isVue3?s.config.globalProperties.$i18n:e:h.isVue2?e:null;u&&et(u,c),n.mixin({methods:{resolveRoute:I(B),localePath:I(q),localeRoute:I(H),localeLocation:I(K),switchLocalePath:I($),getRouteBaseName:I(F),localeHead:I(Z)}})}}function Ze(e,t){const{locales:o,localeCodes:a,baseUrl:l}=t,n=h.ref(o),r=h.ref(a);e.locales=h.computed(()=>n.value),e.localeCodes=h.computed(()=>r.value),e.__baseUrl=_e(l,{})}function et(e,t){Object.defineProperty(e,"locales",{get(){return t.locales.value}}),Object.defineProperty(e,"localeCodes",{get(){return t.localeCodes.value}}),Object.defineProperty(e,"__baseUrl",{get(){return t.__baseUrl}})}function tt(e){const t=fe(e);Object.defineProperty(e,"locales",{get(){return t.locales.value}}),Object.defineProperty(e,"localeCodes",{get(){return t.localeCodes.value}}),Object.defineProperty(e,"__baseUrl",{get(){return t.__baseUrl}})}function ot(e,t={}){const{version:o,defaultLocale:a,locales:l,strategy:n,trailingSlash:r,routesNameSeparator:c,defaultLocaleRouteNameSuffix:s,defaultDirection:u,baseUrl:f,routes:i,routeOptionsResolver:d}=nt(t),R=ie(l),_=R.map(p=>p.code),E=ge(_,c,s);Ke(e,{locales:R,baseUrl:f,localeCodes:_});const T=pe(i,{locales:l,defaultLocale:a,strategy:n,trailingSlash:r,routesNameSeparator:c,defaultLocaleRouteNameSuffix:s,optionsResolver:d});t.routes=T;const m=at(t,o);return m.__defaultLocale=a,m.__localeCodes=_,m.__strategy=n,m.__trailingSlash=r,m.__routesNameSeparator=c,m.__defaultLocaleRouteNameSuffix=s,m.__defaultDirection=u,m.beforeEach((p,b,g)=>{const S=z(e),C=E(p)||S||a||"";S!==C&&he(e,C),g()}),m}function at(e,t){if(h.isVue3&&t===4)return L.createRouter(e);if(h.isVue2&&t===3)return new Ne.default(e);throw new Error("TODO:")}function lt(e){return new RegExp(`^/(${e.join("|")})(?:/|$)`,"i")}function ge(e,t,o){const a=`(${e.join("|")})`,l=`(?:${t}${o})?`,n=new RegExp(`${t}${a}${l}$`,"i"),r=lt(e);return s=>{if(ue(s)){if(s.name){const f=(A(s.name)?s.name:s.name.toString()).match(n);if(f&&f.length>1)return f[1]}else if(s.path){const u=s.path.match(r);if(u&&u.length>1)return u[1]}}else if(A(s)){const u=s.match(r);if(u&&u.length>1)return u[1]}return""}}function nt(e){var t,o,a,l,n,r,c,s,u,f;return e.version=(t=e.version)!=null?t:4,e.defaultLocale=(o=e.defaultLocale)!=null?o:y,e.strategy=(a=e.strategy)!=null?a:N,e.trailingSlash=(l=e.trailingSlash)!=null?l:me,e.routesNameSeparator=(n=e.routesNameSeparator)!=null?n:P,e.defaultLocaleRouteNameSuffix=(r=e.defaultLocaleRouteNameSuffix)!=null?r:w,e.locales=(c=e.locales)!=null?c:[],e.defaultDirection=(s=e.defaultDirection)!=null?s:je,e.baseUrl=(u=e.baseUrl)!=null?u:Le,e.routes=(f=e.routes)!=null?f:[],e}const rt="0.0.0";exports.VERSION=rt;exports.createLocaleFromRouteGetter=ge;exports.createRouter=ot;exports.findBrowserLocale=Be;exports.getLocale=z;exports.getRouteBaseName=F;exports.localeHead=Z;exports.localeLocation=K;exports.localePath=q;exports.localeRoute=H;exports.localizeRoutes=pe;exports.resolveBaseUrl=_e;exports.resolveRoute=B;exports.setLocale=he;exports.switchLocalePath=$;exports.useLocaleHead=Je;exports.useLocaleLocation=Qe;exports.useLocalePath=Ge;exports.useLocaleRoute=We;exports.useRouteBaseName=He;exports.useSwitchLocalePath=Ye; |
@@ -0,15 +1,78 @@ | ||
import { 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,74 +98,63 @@ /** | ||
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'>; | ||
/** | ||
* Locale object | ||
* The options for {@link findBrowserLocale} function | ||
*/ | ||
export declare interface LocaleObject extends Record<string, any> { | ||
code: Locale; | ||
name?: string; | ||
dir?: Directions; | ||
domain?: string; | ||
file?: string; | ||
isCatchallLocale?: boolean; | ||
iso?: string; | ||
} | ||
export declare type FindBrowserLocaleOptions = { | ||
matcher?: BrowserLocaleMatcher; | ||
comparer?: (a: BrowserLocale, b: BrowserLocale) => number; | ||
}; | ||
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 | ||
* Options for vue-i18n-routing common | ||
*/ | ||
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'> & ComposableOptions; | ||
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 | ||
* 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(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: string; | ||
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; | ||
} | ||
@@ -110,3 +164,3 @@ /** | ||
*/ | ||
export declare type VueI18nRoute = Route & RouteLegacy & { | ||
export declare type I18nRoute = Route & RouteLegacy & { | ||
redirect?: string; | ||
@@ -121,3 +175,3 @@ }; | ||
*/ | ||
export declare type VueI18nRoutingOptions = { | ||
export declare type I18nRoutingOptions<BaseUrl extends BaseUrlResolveHandler = BaseUrlResolveHandler> = { | ||
/** | ||
@@ -148,3 +202,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 | ||
* | ||
@@ -189,15 +244,281 @@ * @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 { } | ||
export declare function localeHead(this: RoutingProxy, { addDirAttribute, addSeoAttributes }?: I18nHeadOptions): I18nHeadMetaInfo; | ||
declare module 'vue-i18n' { | ||
export interface ComposerCustom { | ||
locales: ComputedRef<string[] | LocaleObject[]> | ||
} | ||
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; | ||
} | ||
declare module 'vue-i18n-bridge' { | ||
export interface ComposerCustom { | ||
locales: ComputedRef<string[] | LocaleObject[]> | ||
} | ||
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>; | ||
/** | ||
* 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; | ||
__strategy: Strategies; | ||
__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<I18nCommonRoutingOptions, 'strategy' | 'defaultLocale'> & ComposableOptions & 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 }?: I18nCommonRoutingOptions): 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 }?: I18nCommonRoutingOptions): 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 }?: I18nCommonRoutingOptions): 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 }?: I18nCommonRoutingOptions): 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 }?: I18nCommonRoutingOptions): SwitchLocalePathFunction; | ||
/** | ||
* Vue I18n Routing Version | ||
* | ||
* @remarks | ||
* Semver format. Same format as the package.json `version` field. | ||
*/ | ||
export declare const VERSION: string; | ||
export { } |
@@ -32,13 +32,52 @@ 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, unref, isVue3, ref, watchEffect, onUnmounted, computed } from "vue-demi"; | ||
import VueRouter3, { isVueRouter4, useRoute, useRouter, createRouter as createRouter$1 } 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 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 +95,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 +139,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 +215,405 @@ PREFIX: "prefix", | ||
const DEFAULT_LOCALE_ROUTE_NAME_SUFFIX = "default"; | ||
const DEFAULT_DETECTION_DIRECTION = "ltr"; | ||
const DEFAULT_BASE_URL = ""; | ||
const RESOLVED_PREFIXED = /* @__PURE__ */ new Set([STRATEGIES.PREFIX_AND_DEFAULT, STRATEGIES.PREFIX_EXCEPT_DEFAULT]); | ||
function getRouteBaseName(givenRoute) { | ||
const router = this.router; | ||
const routesNameSeparator = router.__routesNameSeparator || this.__routesNameSeparator || DEFAULT_ROUTES_NAME_SEPARATOR; | ||
const 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 defaultLocale = this.__defaultLocale || DEFAULT_LOCALE; | ||
const _defaultLocale = router.__defaultLocale || defaultLocale; | ||
const _defaultLocaleRouteNameSuffix = router.__defaultLocaleRouteNameSuffix || this.__defaultLocaleRouteNameSuffix || DEFAULT_LOCALE_ROUTE_NAME_SUFFIX; | ||
const _routesNameSeparator = router.__routesNameSeparator || this.__routesNameSeparator || DEFAULT_ROUTES_NAME_SEPARATOR; | ||
const _strategy = router.__strategy || this.__strategy || DEFAULT_STRATEGY; | ||
const trailingSlash = router.__trailingSlash || this.__trailingSlash || false; | ||
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: _defaultLocale, | ||
strategy: _strategy, | ||
routesNameSeparator: _routesNameSeparator, | ||
defaultLocaleRouteNameSuffix: _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: _defaultLocale, | ||
strategy: _strategy, | ||
routesNameSeparator: _routesNameSeparator, | ||
defaultLocaleRouteNameSuffix: _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 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 || router.__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 = router.__defaultLocale || this.__defaultLocale; | ||
const strategy = router.__strategy || this.__strategy; | ||
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 { | ||
router, | ||
route, | ||
i18n, | ||
defaultLocale: __defaultLocale, | ||
strategy: __strategy, | ||
defaultLocaleRouteNameSuffix: __defaultLocaleRouteNameSuffix, | ||
trailingSlash: __trailingSlash, | ||
routesNameSeparator: __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 = DEFAULT_ROUTES_NAME_SEPARATOR } = {}) { | ||
const proxy = { | ||
router, | ||
route: givenRoute, | ||
__routesNameSeparator: routesNameSeparator | ||
}; | ||
return getRouteBaseName.call(proxy, givenRoute); | ||
} | ||
function useLocalePath({ | ||
router = useRouter(), | ||
route = useRoute(), | ||
i18n = useI18n(), | ||
defaultLocale = DEFAULT_LOCALE, | ||
defaultLocaleRouteNameSuffix = DEFAULT_LOCALE_ROUTE_NAME_SUFFIX, | ||
routesNameSeparator = DEFAULT_ROUTES_NAME_SEPARATOR, | ||
strategy = DEFAULT_STRATEGY, | ||
trailingSlash = false | ||
} = {}) { | ||
return proxyForComposable({ router, route, i18n, defaultLocale, defaultLocaleRouteNameSuffix, routesNameSeparator, strategy, trailingSlash }, localePath); | ||
} | ||
function useLocaleRoute({ | ||
router = useRouter(), | ||
route = useRoute(), | ||
i18n = useI18n(), | ||
defaultLocale = DEFAULT_LOCALE, | ||
defaultLocaleRouteNameSuffix = DEFAULT_LOCALE_ROUTE_NAME_SUFFIX, | ||
routesNameSeparator = DEFAULT_ROUTES_NAME_SEPARATOR, | ||
strategy = DEFAULT_STRATEGY, | ||
trailingSlash = false | ||
} = {}) { | ||
return proxyForComposable({ | ||
router, | ||
route, | ||
i18n, | ||
defaultLocale, | ||
defaultLocaleRouteNameSuffix, | ||
routesNameSeparator, | ||
strategy, | ||
trailingSlash | ||
}, localeRoute); | ||
} | ||
function useLocaleLocation({ | ||
router = useRouter(), | ||
route = useRoute(), | ||
i18n = useI18n(), | ||
defaultLocale = DEFAULT_LOCALE, | ||
defaultLocaleRouteNameSuffix = DEFAULT_LOCALE_ROUTE_NAME_SUFFIX, | ||
routesNameSeparator = DEFAULT_ROUTES_NAME_SEPARATOR, | ||
strategy = DEFAULT_STRATEGY, | ||
trailingSlash = false | ||
} = {}) { | ||
return proxyForComposable({ | ||
router, | ||
route, | ||
i18n, | ||
defaultLocale, | ||
defaultLocaleRouteNameSuffix, | ||
routesNameSeparator, | ||
strategy, | ||
trailingSlash | ||
}, localeLocation); | ||
} | ||
function useSwitchLocalePath({ | ||
router = useRouter(), | ||
route = useRoute(), | ||
i18n = useI18n(), | ||
defaultLocale = DEFAULT_LOCALE, | ||
defaultLocaleRouteNameSuffix = DEFAULT_LOCALE_ROUTE_NAME_SUFFIX, | ||
routesNameSeparator = DEFAULT_ROUTES_NAME_SEPARATOR, | ||
strategy = DEFAULT_STRATEGY, | ||
trailingSlash = false | ||
} = {}) { | ||
return proxyForComposable({ | ||
router, | ||
route, | ||
i18n, | ||
defaultLocale, | ||
defaultLocaleRouteNameSuffix, | ||
routesNameSeparator, | ||
strategy, | ||
trailingSlash | ||
}, switchLocalePath); | ||
} | ||
function useLocaleHead({ | ||
addDirAttribute = false, | ||
addSeoAttributes = false, | ||
strategy = DEFAULT_STRATEGY, | ||
defaultLocale = DEFAULT_LOCALE, | ||
route = useRoute(), | ||
router = useRouter(), | ||
i18n = useI18n() | ||
} = {}) { | ||
const _router = router; | ||
const metaObject = ref({ | ||
htmlAttrs: {}, | ||
link: [], | ||
meta: [] | ||
}); | ||
function cleanMeta() { | ||
metaObject.value = { | ||
htmlAttrs: {}, | ||
link: [], | ||
meta: [] | ||
}; | ||
} | ||
function updateMeta(_route) { | ||
metaObject.value = Reflect.apply(localeHead, { | ||
router, | ||
route: _route, | ||
i18n, | ||
__defaultLocale: defaultLocale, | ||
__strategy: 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 { | ||
updateMeta(toRawRoute(_router.currentRoute)); | ||
} | ||
return metaObject; | ||
} | ||
function localizeRoutes(routes, { | ||
@@ -199,2 +626,3 @@ defaultLocale = DEFAULT_LOCALE, | ||
includeUprefixedFallback = false, | ||
optionsResolver = void 0, | ||
locales = [] | ||
@@ -210,2 +638,9 @@ } = {}) { | ||
} | ||
let routeOptions = null; | ||
if (optionsResolver != null) { | ||
routeOptions = optionsResolver(route, allowedLocaleCodes); | ||
if (routeOptions == null) { | ||
return [route]; | ||
} | ||
} | ||
const targetLocales = allowedLocaleCodes; | ||
@@ -258,47 +693,88 @@ return targetLocales.reduce((_routes, locale) => { | ||
} | ||
function extendI18n(i18n, { locales = [] } = {}) { | ||
if (!isComposer(i18n.global, i18n.mode)) { | ||
throw new Error("TODO:"); | ||
} | ||
function proxyVueInstance(target) { | ||
return function() { | ||
return Reflect.apply(target, { | ||
getRouteBaseName: this.getRouteBaseName, | ||
localePath: this.localePath, | ||
localeRoute: this.localeRoute, | ||
localeLocation: this.localeLocation, | ||
resolveRoute: this.resolveRoute, | ||
switchLocalePath: this.switchLocalePath, | ||
localeHead: this.localeHead, | ||
i18n: this.$i18n, | ||
route: this.$route, | ||
router: this.$router | ||
}, arguments); | ||
}; | ||
} | ||
function extendI18n(i18n, { locales = [], localeCodes = [], baseUrl = DEFAULT_BASE_URL } = {}) { | ||
const orgInstall = i18n.install; | ||
i18n.install = (vue, ...options) => { | ||
Reflect.apply(orgInstall, i18n, [vue, ...options]); | ||
const composer = getComposer(i18n); | ||
extendComposer(composer, { locales, localeCodes, baseUrl }); | ||
if (isVueI18n(i18n.global)) { | ||
extendVueI18n(i18n.global); | ||
} | ||
const app = vue; | ||
const exported = i18n.mode === "composition" ? isVue3 ? app.config.globalProperties.$i18n : i18n : isVue2 ? i18n : null; | ||
if (exported) { | ||
extendExportedGlobal(exported, composer); | ||
} | ||
vue.mixin({ | ||
methods: { | ||
resolveRoute: proxyVueInstance(resolveRoute), | ||
localePath: proxyVueInstance(localePath), | ||
localeRoute: proxyVueInstance(localeRoute), | ||
localeLocation: proxyVueInstance(localeLocation), | ||
switchLocalePath: proxyVueInstance(switchLocalePath), | ||
getRouteBaseName: proxyVueInstance(getRouteBaseName), | ||
localeHead: proxyVueInstance(localeHead) | ||
} | ||
}); | ||
}; | ||
} | ||
function extendComposer(composer, options) { | ||
const { locales, localeCodes, baseUrl } = options; | ||
const _locales = ref(locales); | ||
i18n.global.locales = computed(() => _locales.value); | ||
console.log("... extends i18n done"); | ||
const _localeCodes = ref(localeCodes); | ||
composer.locales = computed(() => _locales.value); | ||
composer.localeCodes = computed(() => _localeCodes.value); | ||
composer.__baseUrl = resolveBaseUrl(baseUrl, {}); | ||
} | ||
function getLocalesRegex(localeCodes) { | ||
return new RegExp(`^/(${localeCodes.join("|")})(?:/|$)`, "i"); | ||
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 createLocaleFromRouteGetter(localeCodes, routesNameSeparator, defaultLocaleRouteNameSuffix) { | ||
const localesPattern = `(${localeCodes.join("|")})`; | ||
const defaultSuffixPattern = `(?:${routesNameSeparator}${defaultLocaleRouteNameSuffix})?`; | ||
const regexpName = new RegExp(`${routesNameSeparator}${localesPattern}${defaultSuffixPattern}$`, "i"); | ||
const regexpPath = getLocalesRegex(localeCodes); | ||
const getLocaleFromRoute = (route) => { | ||
if (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]; | ||
} | ||
function extendVueI18n(vueI18n) { | ||
const composer = getComposer(vueI18n); | ||
Object.defineProperty(vueI18n, "locales", { | ||
get() { | ||
return composer.locales.value; | ||
} | ||
return ""; | ||
}; | ||
return getLocaleFromRoute; | ||
}); | ||
Object.defineProperty(vueI18n, "localeCodes", { | ||
get() { | ||
return composer.localeCodes.value; | ||
} | ||
}); | ||
Object.defineProperty(vueI18n, "__baseUrl", { | ||
get() { | ||
return composer.__baseUrl; | ||
} | ||
}); | ||
} | ||
function asDefaultVueI18nRouterOptions(options) { | ||
var _a, _b, _c, _d, _e, _f, _g, _h; | ||
options.version = (_a = options.version) != null ? _a : 4; | ||
options.defaultLocale = (_b = options.defaultLocale) != null ? _b : DEFAULT_LOCALE; | ||
options.strategy = (_c = options.strategy) != null ? _c : DEFAULT_STRATEGY; | ||
options.trailingSlash = (_d = options.trailingSlash) != null ? _d : DEFAULT_TRAILING_SLASH; | ||
options.routesNameSeparator = (_e = options.routesNameSeparator) != null ? _e : DEFAULT_ROUTES_NAME_SEPARATOR; | ||
options.defaultLocaleRouteNameSuffix = (_f = options.defaultLocaleRouteNameSuffix) != null ? _f : DEFAULT_LOCALE_ROUTE_NAME_SUFFIX; | ||
options.locales = (_g = options.locales) != null ? _g : []; | ||
options.routes = (_h = options.routes) != null ? _h : []; | ||
return options; | ||
} | ||
function createRouter(i18n, options = {}) { | ||
@@ -313,3 +789,6 @@ const { | ||
defaultLocaleRouteNameSuffix, | ||
routes | ||
defaultDirection, | ||
baseUrl, | ||
routes, | ||
routeOptionsResolver: optionsResolver | ||
} = asDefaultVueI18nRouterOptions(options); | ||
@@ -319,3 +798,3 @@ const normalizedLocaleCodes = getNormalizedLocales(locales); | ||
const getLocaleFromRoute = createLocaleFromRouteGetter(localeCodes, routesNameSeparator, defaultLocaleRouteNameSuffix); | ||
extendI18n(i18n, { locales: normalizedLocaleCodes }); | ||
extendI18n(i18n, { locales: normalizedLocaleCodes, baseUrl, localeCodes }); | ||
const localizedRoutes = localizeRoutes(routes, { | ||
@@ -327,13 +806,7 @@ locales, | ||
routesNameSeparator, | ||
defaultLocaleRouteNameSuffix | ||
defaultLocaleRouteNameSuffix, | ||
optionsResolver | ||
}); | ||
options.routes = localizedRoutes; | ||
let router = null; | ||
if (isVue3 && version === 4) { | ||
router = createRouter$1(options); | ||
} else if (isVue2 && version === 3) { | ||
router = new VueRouter3(options); | ||
} else { | ||
throw new Error("TODO:"); | ||
} | ||
const router = createVueRouter(options, version); | ||
router.__defaultLocale = defaultLocale; | ||
@@ -345,7 +818,6 @@ router.__localeCodes = localeCodes; | ||
router.__defaultLocaleRouteNameSuffix = defaultLocaleRouteNameSuffix; | ||
router.__defaultDirection = defaultDirection; | ||
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) { | ||
@@ -356,6 +828,60 @@ setLocale(i18n, finalLocale); | ||
}); | ||
console.log("create router", router); | ||
return router; | ||
} | ||
function createVueRouter(options, version) { | ||
if (isVue3 && version === 4) { | ||
return createRouter$1(options); | ||
} else if (isVue2 && version === 3) { | ||
return new VueRouter3(options); | ||
} else { | ||
throw new Error("TODO:"); | ||
} | ||
} | ||
function getLocalesRegex(localeCodes) { | ||
return new RegExp(`^/(${localeCodes.join("|")})(?:/|$)`, "i"); | ||
} | ||
function createLocaleFromRouteGetter(localeCodes, routesNameSeparator, defaultLocaleRouteNameSuffix) { | ||
const localesPattern = `(${localeCodes.join("|")})`; | ||
const defaultSuffixPattern = `(?:${routesNameSeparator}${defaultLocaleRouteNameSuffix})?`; | ||
const regexpName = new RegExp(`${routesNameSeparator}${localesPattern}${defaultSuffixPattern}$`, "i"); | ||
const regexpPath = getLocalesRegex(localeCodes); | ||
const getLocaleFromRoute = (route) => { | ||
if (isObject(route)) { | ||
if (route.name) { | ||
const name = isString(route.name) ? route.name : route.name.toString(); | ||
const matches = name.match(regexpName); | ||
if (matches && matches.length > 1) { | ||
return matches[1]; | ||
} | ||
} else if (route.path) { | ||
const matches = route.path.match(regexpPath); | ||
if (matches && matches.length > 1) { | ||
return matches[1]; | ||
} | ||
} | ||
} else if (isString(route)) { | ||
const matches = route.match(regexpPath); | ||
if (matches && matches.length > 1) { | ||
return matches[1]; | ||
} | ||
} | ||
return ""; | ||
}; | ||
return getLocaleFromRoute; | ||
} | ||
function asDefaultVueI18nRouterOptions(options) { | ||
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j; | ||
options.version = (_a = options.version) != null ? _a : 4; | ||
options.defaultLocale = (_b = options.defaultLocale) != null ? _b : DEFAULT_LOCALE; | ||
options.strategy = (_c = options.strategy) != null ? _c : DEFAULT_STRATEGY; | ||
options.trailingSlash = (_d = options.trailingSlash) != null ? _d : DEFAULT_TRAILING_SLASH; | ||
options.routesNameSeparator = (_e = options.routesNameSeparator) != null ? _e : DEFAULT_ROUTES_NAME_SEPARATOR; | ||
options.defaultLocaleRouteNameSuffix = (_f = options.defaultLocaleRouteNameSuffix) != null ? _f : DEFAULT_LOCALE_ROUTE_NAME_SUFFIX; | ||
options.locales = (_g = options.locales) != null ? _g : []; | ||
options.defaultDirection = (_h = options.defaultDirection) != null ? _h : DEFAULT_DETECTION_DIRECTION; | ||
options.baseUrl = (_i = options.baseUrl) != null ? _i : DEFAULT_BASE_URL; | ||
options.routes = (_j = options.routes) != null ? _j : []; | ||
return options; | ||
} | ||
const VERSION = "0.0.0"; | ||
export { VERSION, createRouter, localizeRoutes, useI18nRouting }; | ||
export { VERSION, createLocaleFromRouteGetter, createRouter, findBrowserLocale, getLocale, getRouteBaseName, localeHead, localeLocation, localePath, localeRoute, localizeRoutes, 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 D=Object.prototype.hasOwnProperty,W=Object.prototype.propertyIsEnumerable;var k=(r,t,f)=>t in r?ue(r,t,{enumerable:!0,configurable:!0,writable:!0,value:f}):r[t]=f,P=(r,t)=>{for(var f in t||(t={}))D.call(t,f)&&k(r,f,t[f]);if(b)for(var f of b(t))W.call(t,f)&&k(r,f,t[f]);return r},v=(r,t)=>se(r,fe(t));var B=(r,t)=>{var f={};for(var p in r)D.call(r,p)&&t.indexOf(p)<0&&(f[p]=r[p]);if(r!=null&&b)for(var p of b(r))t.indexOf(p)<0&&W.call(r,p)&&(f[p]=r[p]);return f};var VueI18nRouting=function(r,t,f,p){"use strict";function H(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var Y=H(f);/*! | ||
* shared v9.2.0-beta.26 | ||
* (c) 2021 kazuya kawaguchi | ||
var nt=Object.defineProperty,ct=Object.defineProperties;var rt=Object.getOwnPropertyDescriptors;var W=Object.getOwnPropertySymbols;var Re=Object.prototype.hasOwnProperty,pe=Object.prototype.propertyIsEnumerable;var ge=(i,u,d)=>u in i?nt(i,u,{enumerable:!0,configurable:!0,writable:!0,value:d}):i[u]=d,U=(i,u)=>{for(var d in u||(u={}))Re.call(u,d)&&ge(i,d,u[d]);if(W)for(var d of W(u))pe.call(u,d)&&ge(i,d,u[d]);return i},Q=(i,u)=>ct(i,rt(u));var Se=(i,u)=>{var d={};for(var m in i)Re.call(i,m)&&u.indexOf(m)<0&&(d[m]=i[m]);if(i!=null&&W)for(var m of W(i))u.indexOf(m)<0&&pe.call(i,m)&&(d[m]=i[m]);return d};var VueI18nRouting=function(i,u,d,m){"use strict";function Ee(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var Pe=Ee(d);/*! | ||
* shared v9.2.0-beta.34 | ||
* (c) 2022 kazuya kawaguchi | ||
* Released under the MIT License. | ||
*/const V=Object.assign,I=e=>typeof e=="string",J=e=>typeof e=="symbol";function K(e){e=e||[];const l=[];for(const c of e)I(c)?l.push({code:c}):l.push(c);return l}function y(e,l){return t.isRef(e.locale)&&l==="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,l){U(e)?y(e.global,e.mode)?e.global.locale.value=l:e.global.locale=l:t.isRef(e.locale)&&(e.locale.value=l)}function Z(e,l,c){return e.replace(/\/+$/,"")+(l?"/":"")||(c?"":"/")}function ee(e={}){const l=p.useI18n(),c=f.useRouter(),_=f.useRoute(),m=e.defaultLocaleRouteNameSuffix||c.__defaultLocaleRouteNameSuffix,E=e.defaultLocale||c.__defaultLocale,g=e.routesNameSeparator||c.__routesNameSeparator,S=e.strategy||c.__strategy;function i(a){const u=a!=null?a:t.isRef(_)?_.value:_;return u.name?z(u.name).split(g)[0]:void 0}function L(a,u){let o=z(a)+(S==="no_prefix"?"":g+u);return u===E&&S==="prefix_and_default"&&(o+=g+m),o}function n(a,u){const o=u||w(l);let d=a;I(a)&&(a[0]==="/"?d={path:a}:d={name:a});let s=V({},d);if(s.path&&!s.name){const R=c.resolve(s),$=t.isVue2?R.route:R,F=i($);I(F)&&(s={name:L(F,o),params:$.params,query:$.query,hash:$.hash})}else{s.name=L(s.name,o);const{params:R}=s;R&&R["0"]===void 0&&R.pathMatch&&(R["0"]=R.pathMatch)}const x=c.resolve(s);return(t.isVue2?x.route.name:x.name)?x:c.resolve(a)}function T(a,u){const o=n(a,u);return o==null?"":t.isVue2?o.route.redirectedFrom||o.route.fullPath:o.redirectedFrom||o.fullPath}function A(a,u){const o=n(a,u);return o==null?void 0:t.isVue2?o.route:o}function N(a,u){const o=n(a,u);return o==null?void 0:t.isVue2?o.location:o.href}function h(a){const u=i();if(!u)return"";const $=t.isVue2&&t.isRef(_)?_.value:_,{params:o}=$,d=B($,["params"]),s={},x=V({},d,{name:u,params:v(P(P({},o),s),{0:o.pathMatch})}),R=T(x,a);return console.log("switchLocalePath",l.locale.value,a,R),R}return{getRouteBaseName:i,localePath:T,localeRoute:A,localeLocation:N,switchLocalePath:h}}function z(e){return I(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"},C="",X=te.PREFIX_EXCEPT_DEFAULT,M=!1,j="___",G="default";function q(e,{defaultLocale:l=C,strategy:c=X,trailingSlash:_=M,routesNameSeparator:m=j,defaultLocaleRouteNameSuffix:E=G,includeUprefixedFallback:g=!1,locales:S=[]}={}){if(c==="no_prefix")return e;const i=S.map(n=>I(n)?n:n.code);function L(n,T,A=!1,N=!1){return n.redirect&&(!n.component||!n.file)?[n]:T.reduce((a,u)=>{const{name:o}=n;let{path:d}=n;const s=P({},n);o&&(s.name=`${o}${m}${u}`),n.children&&(s.children=n.children.reduce((F,O)=>[...F,...L(O,[u],!0,N)],[]));const x=u===l;if(x&&c==="prefix_and_default")if(A)A&&N&&o&&(s.name+=`${m}${E}`);else{const F=v(P({},s),{path:d});if(o&&(F.name=`${s.name}${m}${E}`),n.children){F.children=[];for(const O of n.children)F.children=F.children.concat(L(O,[u],!0,!0))}a.push(F)}const R=A&&!d.startsWith("/"),$=!R&&!(x&&c==="prefix_except_default");return $&&(d=`/${u}${d}`),d&&(d=Z(d,_,R)),$&&x&&c==="prefix"&&g&&a.push(P({},n)),s.path=d,a.push(s),a},[])}return e.reduce((n,T)=>[...n,...L(T,i||[])],[])}function ae(e,{locales:l=[]}={}){if(!y(e.global,e.mode))throw new Error("TODO:");const c=t.ref(l);e.global.locales=t.computed(()=>c.value),console.log("... extends i18n done")}function oe(e){return new RegExp(`^/(${e.join("|")})(?:/|$)`,"i")}function le(e,l,c){const _=`(${e.join("|")})`,m=`(?:${l}${c})?`,E=new RegExp(`${l}${_}${m}$`,"i"),g=oe(e);return i=>{if(i.name){const n=(I(i.name)?i.name:i.name.toString()).match(E);if(n&&n.length>1)return n[1]}else if(i.path){const L=i.path.match(g);if(L&&L.length>1)return L[1]}return""}}function ne(e){var l,c,_,m,E,g,S,i;return e.version=(l=e.version)!=null?l:4,e.defaultLocale=(c=e.defaultLocale)!=null?c:C,e.strategy=(_=e.strategy)!=null?_:X,e.trailingSlash=(m=e.trailingSlash)!=null?m:M,e.routesNameSeparator=(E=e.routesNameSeparator)!=null?E:j,e.defaultLocaleRouteNameSuffix=(g=e.defaultLocaleRouteNameSuffix)!=null?g:G,e.locales=(S=e.locales)!=null?S:[],e.routes=(i=e.routes)!=null?i:[],e}function ce(e,l={}){const{version:c,defaultLocale:_,locales:m,strategy:E,trailingSlash:g,routesNameSeparator:S,defaultLocaleRouteNameSuffix:i,routes:L}=ne(l),n=K(m),T=n.map(a=>a.code),A=le(T,S,i);ae(e,{locales:n});const N=q(L,{locales:m,defaultLocale:_,strategy:E,trailingSlash:g,routesNameSeparator:S,defaultLocaleRouteNameSuffix:i});l.routes=N;let h=null;if(t.isVue3&&c===4)h=f.createRouter(l);else if(t.isVue2&&c===3)h=new Y.default(l);else throw new Error("TODO:");return h.__defaultLocale=_,h.__localeCodes=T,h.__strategy=E,h.__trailingSlash=g,h.__routesNameSeparator=S,h.__defaultLocaleRouteNameSuffix=i,h.beforeEach((a,u,o)=>{console.log("beforeEach",a,u);const d=w(e),s=A(a)||d||_||"";console.log("currentLocale",d,"finalLocale",s),d!==s&&Q(e,s),o()}),console.log("create router",h),h}const re="0.0.0";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 te=Object.assign,ye=Array.isArray,Ne=e=>typeof e=="function",w=e=>typeof e=="string",Ae=e=>typeof e=="symbol",oe=e=>e!==null&&typeof e=="object",Ie=/\/$|\/\?/;function v(e="",t=!1){return t?Ie.test(e):e.endsWith("/")}function we(e="",t=!1){if(!t)return(v(e)?e.slice(0,-1):e)||"/";if(!v(e,!0))return e||"/";const[o,...a]=e.split("?");return(o.slice(0,-1)||"/")+(a.length?`?${a.join("?")}`:"")}function Ce(e="",t=!1){if(!t)return e.endsWith("/")?e:e+"/";if(v(e,!0))return e||"/";const[o,...a]=e.split("?");return o+"/"+(a.length?`?${a.join("?")}`:"")}const Fe=typeof window!="undefined";function Te(e,t){typeof console!="undefined"&&(console.warn("[vue-i18n-routing] "+e),t&&console.warn(t.stack))}function ae(e){e=e||[];const t=[];for(const o of e)w(o)?t.push({code:o}):t.push(o);return t}function k(e){return e!=null&&"global"in e&&"mode"in e}function z(e){return e!=null&&!("__composer"in e)&&u.isRef(e.locale)}function x(e){return e!=null&&"__composer"in e}function Y(e){return e!=null&&!("__composer"in e)&&!u.isRef(e.locale)}function $(e){return e!=null&&("__VUE_I18N_BRIDGE__"in e||"_sync"in e)}function le(e){return k(e)?z(e.global)?e.global:e.global.__composer:x(e)?e.__composer:e}function H(e){const t=k(e)?e.global:e;return z(t)?u.isVue2&&$(e)?e.locale:t.locale.value:(Y(t)||x(t)||$(t),t.locale)}function Ue(e){const t=k(e)?e.global:e;return z(t)?u.isVue2&&$(e)?e.locales:t.locales.value:(Y(t)||x(t)||$(t),t.locales)}function ne(e,t){const o=k(e)?e.global:e;if(z(o))u.isVue2&&$(e)?e.locale=t:o.locale.value=t;else if(Y(o)||x(o)||$(o))o.locale=t;else throw new Error("TODO:")}function $e(e,t,o){return e.replace(/\/+$/,"")+(t?"/":"")||(o?"":"/")}function ce(e){return d.isVueRouter4,u.isRef(e)?e.value:e}function re(e){return w(e)?e:Ae(e)?e.toString():"(null)"}function se(e,t,{defaultLocale:o,strategy:a,routesNameSeparator:l,defaultLocaleRouteNameSuffix:n}){let c=re(e)+(a==="no_prefix"?"":l+t);return t===o&&a==="prefix_and_default"&&(c+=l+n),c}function ue(e,t){return Ne(e)?e(t):e}function be(e,t){const o=[];for(const[a,l]of t.entries()){const n=e.find(c=>c.iso.toLowerCase()===l.toLowerCase());if(n){o.push({code:n.code,score:1-a/t.length});break}}for(const[a,l]of t.entries()){const n=l.split("-")[0].toLowerCase(),c=e.find(r=>r.iso.split("-")[0].toLowerCase()===n);if(c){o.push({code:c.code,score:.999-a/t.length});break}}return o}const Oe=be;function xe(e,t){return e.score===t.score?t.code.length-e.code.length:t.score-e.score}const je=xe;function Ve(e,t,{matcher:o=Oe,comparer:a=je}={}){const l=[];for(const c of e){const{code:r}=c,s=c.iso||r;l.push({code:r,iso:s})}const n=o(l,t);return n.length>1&&n.sort(a),n.length?n[0].code:""}const j={PREFIX:"prefix",PREFIX_EXCEPT_DEFAULT:"prefix_except_default",PREFIX_AND_DEFAULT:"prefix_and_default",NO_PREFIX:"no_prefix"},A="",I=j.PREFIX_EXCEPT_DEFAULT,ie=!1,y="___",C="default",Be="ltr",fe="",Xe=new Set([j.PREFIX_AND_DEFAULT,j.PREFIX_EXCEPT_DEFAULT]);function b(e){const o=this.router.__routesNameSeparator||this.__routesNameSeparator||y,a=e!=null?u.isRef(e)?u.unref(e):e:this.route;return a.name?re(a.name).split(o)[0]:void 0}function G(e,t){const o=V.call(this,e,t);return o==null?"":u.isVue3?o.redirectedFrom||o.fullPath:o.route.redirectedFrom||o.route.fullPath}function q(e,t){const o=V.call(this,e,t);return o==null?void 0:u.isVue3?o:o.route}function J(e,t){const o=V.call(this,e,t);return o==null?void 0:u.isVue3?o:o.location}function V(e,t){const o=this.router,a=this.i18n,l=t||H(a),n=this.__defaultLocale||A,c=o.__defaultLocale||n,r=o.__defaultLocaleRouteNameSuffix||this.__defaultLocaleRouteNameSuffix||C,s=o.__routesNameSeparator||this.__routesNameSeparator||y,f=o.__strategy||this.__strategy||I,_=o.__trailingSlash||this.__trailingSlash||!1;let h=e;w(e)&&(h[0]==="/"?h={path:e}:h={name:e});let L=te({},h);if(L.path&&!L.name){const g=o.resolve(L),N=u.isVue3?g:g.route,X=b.call(this,N);w(X)?L={name:se(X,l,{defaultLocale:c,strategy:f,routesNameSeparator:s,defaultLocaleRouteNameSuffix:r}),params:N.params,query:N.query,hash:N.hash}:(!(l===n&&Xe.has(f))&&f!==j.NO_PREFIX&&(L.path=`/${l}${L.path}`),L.path=_?Ce(L.path,!0):we(L.path,!0))}else{L.name=se(L.name,l,{defaultLocale:c,strategy:f,routesNameSeparator:s,defaultLocaleRouteNameSuffix:r});const{params:g}=L;g&&g["0"]===void 0&&g.pathMatch&&(g["0"]=g.pathMatch)}const p=o.resolve(L);return(u.isVue3?p.name:p.route.name)?p:o.resolve(e)}function B(e){const t=this.route,o=b.call(this,t);if(!o)return"";const s=!u.isVue3&&u.isRef(t)?t.value:t,{params:a}=s,l=Se(s,["params"]),n={},c=te({},l,{name:o,params:Q(U(U({},a),n),{0:a.pathMatch})});return G.call(this,c,e)}function K({addDirAttribute:e=!1,addSeoAttributes:t=!1}={}){const o=this.router,a=this.i18n,l={htmlAttrs:{},link:[],meta:[]};if(a.locales==null||a.__baseUrl==null)return l;const n=H(a),c=Ue(a),r=ae(c).find(_=>_.code===n)||{code:n},s=r.iso,f=r.dir||o.__defaultDirection;return e&&(l.htmlAttrs.dir=f),t&&n&&a.locales&&(s&&(l.htmlAttrs.lang=s),Me.call(this,c,a.__baseUrl,l.link),ke.call(this,a.__baseUrl,l.link,t),ze(r,s,l.meta),He(c,s,l.meta)),l}function Me(e,t,o){const a=this.router,l=a.__defaultLocale||this.__defaultLocale;if((a.__strategy||this.__strategy)===j.NO_PREFIX)return;const c=new Map;for(const r of e){const s=r.iso;if(!s){Te("Locale ISO code is required to generate alternate link");continue}const[f,_]=s.split("-");f&&_&&(r.isCatchallLocale||!c.has(f))&&c.set(f,r),c.set(s,r)}for(const[r,s]of c.entries()){const f=B.call(this,s.code);f&&o.push({hid:`i18n-alt-${r}`,rel:"alternate",href:Z(f,t),hreflang:r})}if(l){const r=B.call(this,l);r&&o.push({hid:"i18n-xd",rel:"alternate",href:Z(r,t),hreflang:"x-default"})}}function ke(e,t,o){const a=this.route,l=q.call(this,Q(U({},a),{name:b.call(this,a)}));if(l){let n=Z(l.path,e);const c=oe(o)&&o.canonicalQueries||[];if(c.length){const r=l.query,s=new URLSearchParams;for(const _ of c)if(_ in r){const h=r[_];ye(h)?h.forEach(L=>s.append(_,L||"")):s.append(_,h||"")}const f=s.toString();f&&(n=`${n}?${f}`)}t.push({hid:"i18n-can",rel:"canonical",href:n})}}function ze(e,t,o){!(e&&t)||o.push({hid:"i18n-og",property:"og:locale",content:he(t)})}function He(e,t,o){const a=e.filter(l=>{const n=l.iso;return n&&n!==t});if(a.length){const l=a.map(n=>({hid:`i18n-og-alt-${n.iso}`,property:"og:locale:alternate",content:he(n.iso)}));o.push(...l)}}function he(e){return(e||"").replace(/-/g,"_")}function Z(e,t){return e.match(/^https?:\/\//)?e:t+e}function D(e,t){const{router:o,route:a,i18n:l,defaultLocale:n,strategy:c,defaultLocaleRouteNameSuffix:r,trailingSlash:s,routesNameSeparator:f}=e;return function(..._){return Reflect.apply(t,{router:o,route:a,i18n:l,__defaultLocale:n,__strategy:c,__defaultLocaleRouteNameSuffix:r,__trailingSlash:s,__routesNameSeparator:f},_)}}function Ge(e=d.useRoute(),{router:t=d.useRouter(),routesNameSeparator:o=y}={}){const a={router:t,route:e,__routesNameSeparator:o};return b.call(a,e)}function qe({router:e=d.useRouter(),route:t=d.useRoute(),i18n:o=m.useI18n(),defaultLocale:a=A,defaultLocaleRouteNameSuffix:l=C,routesNameSeparator:n=y,strategy:c=I,trailingSlash:r=!1}={}){return D({router:e,route:t,i18n:o,defaultLocale:a,defaultLocaleRouteNameSuffix:l,routesNameSeparator:n,strategy:c,trailingSlash:r},G)}function De({router:e=d.useRouter(),route:t=d.useRoute(),i18n:o=m.useI18n(),defaultLocale:a=A,defaultLocaleRouteNameSuffix:l=C,routesNameSeparator:n=y,strategy:c=I,trailingSlash:r=!1}={}){return D({router:e,route:t,i18n:o,defaultLocale:a,defaultLocaleRouteNameSuffix:l,routesNameSeparator:n,strategy:c,trailingSlash:r},q)}function We({router:e=d.useRouter(),route:t=d.useRoute(),i18n:o=m.useI18n(),defaultLocale:a=A,defaultLocaleRouteNameSuffix:l=C,routesNameSeparator:n=y,strategy:c=I,trailingSlash:r=!1}={}){return D({router:e,route:t,i18n:o,defaultLocale:a,defaultLocaleRouteNameSuffix:l,routesNameSeparator:n,strategy:c,trailingSlash:r},J)}function Qe({router:e=d.useRouter(),route:t=d.useRoute(),i18n:o=m.useI18n(),defaultLocale:a=A,defaultLocaleRouteNameSuffix:l=C,routesNameSeparator:n=y,strategy:c=I,trailingSlash:r=!1}={}){return D({router:e,route:t,i18n:o,defaultLocale:a,defaultLocaleRouteNameSuffix:l,routesNameSeparator:n,strategy:c,trailingSlash:r},B)}function ve({addDirAttribute:e=!1,addSeoAttributes:t=!1,strategy:o=I,defaultLocale:a=A,route:l=d.useRoute(),router:n=d.useRouter(),i18n:c=m.useI18n()}={}){const r=n,s=u.ref({htmlAttrs:{},link:[],meta:[]});function f(){s.value={htmlAttrs:{},link:[],meta:[]}}function _(h){s.value=Reflect.apply(K,{router:n,route:h,i18n:c,__defaultLocale:a,__strategy:o},[{addDirAttribute:e,addSeoAttributes:t}])}if(Fe)if(u.isVue3){const h=u.watchEffect(()=>{f(),_(ce(r.currentRoute))});u.onUnmounted(()=>h())}else{const h=r.afterEach((L,p)=>{f(),_(L)});u.onUnmounted(()=>h()),_(l)}else _(ce(r.currentRoute));return s}function de(e,{defaultLocale:t=A,strategy:o=I,trailingSlash:a=ie,routesNameSeparator:l=y,defaultLocaleRouteNameSuffix:n=C,includeUprefixedFallback:c=!1,optionsResolver:r=void 0,locales:s=[]}={}){if(o==="no_prefix")return e;const f=s.map(h=>w(h)?h:h.code);function _(h,L,p=!1,g=!1){if(h.redirect&&(!h.component||!h.file))return[h];let N=null;return r!=null&&(N=r(h,L),N==null)?[h]:L.reduce((R,S)=>{const{name:M}=h;let{path:E}=h;const P=U({},h);M&&(P.name=`${M}${l}${S}`),h.children&&(P.children=h.children.reduce((T,ee)=>[...T,..._(ee,[S],!0,g)],[]));const O=S===t;if(O&&o==="prefix_and_default")if(p)p&&g&&M&&(P.name+=`${l}${n}`);else{const T=Q(U({},P),{path:E});if(M&&(T.name=`${P.name}${l}${n}`),h.children){T.children=[];for(const ee of h.children)T.children=T.children.concat(_(ee,[S],!0,!0))}R.push(T)}const Le=p&&!E.startsWith("/"),me=!Le&&!(O&&o==="prefix_except_default");return me&&(E=`/${S}${E}`),E&&(E=$e(E,a,Le)),me&&O&&o==="prefix"&&c&&R.push(U({},h)),P.path=E,R.push(P),R},[])}return e.reduce((h,L)=>[...h,..._(L,f||[])],[])}function F(e){return function(){return Reflect.apply(e,{getRouteBaseName:this.getRouteBaseName,localePath:this.localePath,localeRoute:this.localeRoute,localeLocation:this.localeLocation,resolveRoute:this.resolveRoute,switchLocalePath:this.switchLocalePath,localeHead:this.localeHead,i18n:this.$i18n,route:this.$route,router:this.$router},arguments)}}function Ye(e,{locales:t=[],localeCodes:o=[],baseUrl:a=fe}={}){const l=e.install;e.install=(n,...c)=>{Reflect.apply(l,e,[n,...c]);const r=le(e);Je(r,{locales:t,localeCodes:o,baseUrl:a}),x(e.global)&&Ze(e.global);const s=n,f=e.mode==="composition"?u.isVue3?s.config.globalProperties.$i18n:e:u.isVue2?e:null;f&&Ke(f,r),n.mixin({methods:{resolveRoute:F(V),localePath:F(G),localeRoute:F(q),localeLocation:F(J),switchLocalePath:F(B),getRouteBaseName:F(b),localeHead:F(K)}})}}function Je(e,t){const{locales:o,localeCodes:a,baseUrl:l}=t,n=u.ref(o),c=u.ref(a);e.locales=u.computed(()=>n.value),e.localeCodes=u.computed(()=>c.value),e.__baseUrl=ue(l,{})}function Ke(e,t){Object.defineProperty(e,"locales",{get(){return t.locales.value}}),Object.defineProperty(e,"localeCodes",{get(){return t.localeCodes.value}}),Object.defineProperty(e,"__baseUrl",{get(){return t.__baseUrl}})}function Ze(e){const t=le(e);Object.defineProperty(e,"locales",{get(){return t.locales.value}}),Object.defineProperty(e,"localeCodes",{get(){return t.localeCodes.value}}),Object.defineProperty(e,"__baseUrl",{get(){return t.__baseUrl}})}function et(e,t={}){const{version:o,defaultLocale:a,locales:l,strategy:n,trailingSlash:c,routesNameSeparator:r,defaultLocaleRouteNameSuffix:s,defaultDirection:f,baseUrl:_,routes:h,routeOptionsResolver:L}=at(t),p=ae(l),g=p.map(S=>S.code),N=_e(g,r,s);Ye(e,{locales:p,baseUrl:_,localeCodes:g});const X=de(h,{locales:l,defaultLocale:a,strategy:n,trailingSlash:c,routesNameSeparator:r,defaultLocaleRouteNameSuffix:s,optionsResolver:L});t.routes=X;const R=tt(t,o);return R.__defaultLocale=a,R.__localeCodes=g,R.__strategy=n,R.__trailingSlash=c,R.__routesNameSeparator=r,R.__defaultLocaleRouteNameSuffix=s,R.__defaultDirection=f,R.beforeEach((S,M,E)=>{const P=H(e),O=N(S)||P||a||"";P!==O&&ne(e,O),E()}),R}function tt(e,t){if(u.isVue3&&t===4)return d.createRouter(e);if(u.isVue2&&t===3)return new Pe.default(e);throw new Error("TODO:")}function ot(e){return new RegExp(`^/(${e.join("|")})(?:/|$)`,"i")}function _e(e,t,o){const a=`(${e.join("|")})`,l=`(?:${t}${o})?`,n=new RegExp(`${t}${a}${l}$`,"i"),c=ot(e);return s=>{if(oe(s)){if(s.name){const _=(w(s.name)?s.name:s.name.toString()).match(n);if(_&&_.length>1)return _[1]}else if(s.path){const f=s.path.match(c);if(f&&f.length>1)return f[1]}}else if(w(s)){const f=s.match(c);if(f&&f.length>1)return f[1]}return""}}function at(e){var t,o,a,l,n,c,r,s,f,_;return e.version=(t=e.version)!=null?t:4,e.defaultLocale=(o=e.defaultLocale)!=null?o:A,e.strategy=(a=e.strategy)!=null?a:I,e.trailingSlash=(l=e.trailingSlash)!=null?l:ie,e.routesNameSeparator=(n=e.routesNameSeparator)!=null?n:y,e.defaultLocaleRouteNameSuffix=(c=e.defaultLocaleRouteNameSuffix)!=null?c:C,e.locales=(r=e.locales)!=null?r:[],e.defaultDirection=(s=e.defaultDirection)!=null?s:Be,e.baseUrl=(f=e.baseUrl)!=null?f:fe,e.routes=(_=e.routes)!=null?_:[],e}const lt="0.0.0";return i.VERSION=lt,i.createLocaleFromRouteGetter=_e,i.createRouter=et,i.findBrowserLocale=Ve,i.getLocale=H,i.getRouteBaseName=b,i.localeHead=K,i.localeLocation=J,i.localePath=G,i.localeRoute=q,i.localizeRoutes=de,i.resolveBaseUrl=ue,i.resolveRoute=V,i.setLocale=ne,i.switchLocalePath=B,i.useLocaleHead=ve,i.useLocaleLocation=We,i.useLocalePath=qe,i.useLocaleRoute=De,i.useRouteBaseName=Ge,i.useSwitchLocalePath=Qe,Object.defineProperties(i,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),i}({},VueDemi,VueRouter,VueI18n); |
{ | ||
"name": "vue-i18n-routing", | ||
"description": "The i18n routing with using vue-i18n", | ||
"version": "0.0.0-3801eb7", | ||
"version": "0.0.0-3e99379", | ||
"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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
86770
11
1570
10
16
+ 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