vue-i18n-routing
Advanced tools
Comparing version 0.0.0-8fbb24d to 0.0.0-90c658c
@@ -1,5 +0,5 @@ | ||
"use strict";var ue=Object.defineProperty,ie=Object.defineProperties;var fe=Object.getOwnPropertyDescriptors;var D=Object.getOwnPropertySymbols;var G=Object.prototype.hasOwnProperty,H=Object.prototype.propertyIsEnumerable;var B=(e,t,a)=>t in e?ue(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a,I=(e,t)=>{for(var a in t||(t={}))G.call(t,a)&&B(e,a,t[a]);if(D)for(var a of D(t))H.call(t,a)&&B(e,a,t[a]);return e},N=(e,t)=>ie(e,fe(t));var W=(e,t)=>{var a={};for(var l in e)G.call(e,l)&&t.indexOf(l)<0&&(a[l]=e[l]);if(e!=null&&D)for(var l of D(e))t.indexOf(l)<0&&H.call(e,l)&&(a[l]=e[l]);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 de(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var he=de(A);/*! | ||
"use strict";var ie=Object.defineProperty,fe=Object.defineProperties;var de=Object.getOwnPropertyDescriptors;var D=Object.getOwnPropertySymbols;var G=Object.prototype.hasOwnProperty,H=Object.prototype.propertyIsEnumerable;var B=(e,t,a)=>t in e?ie(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a,T=(e,t)=>{for(var a in t||(t={}))G.call(t,a)&&B(e,a,t[a]);if(D)for(var a of D(t))H.call(t,a)&&B(e,a,t[a]);return e},N=(e,t)=>fe(e,de(t));var W=(e,t)=>{var a={};for(var l in e)G.call(e,l)&&t.indexOf(l)<0&&(a[l]=e[l]);if(e!=null&&D)for(var l of D(e))t.indexOf(l)<0&&H.call(e,l)&&(a[l]=e[l]);return a};Object.defineProperty(exports,"__esModule",{value:!0});exports[Symbol.toStringTag]="Module";var _=require("vue-demi"),v=require("@intlify/vue-router-bridge"),J=require("@intlify/vue-i18n-bridge");function he(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var _e=he(v);/*! | ||
* shared v9.2.0-beta.30 | ||
* (c) 2022 kazuya kawaguchi | ||
* Released under the MIT License. | ||
*/const J=Object.assign,_e=Array.isArray,me=e=>typeof e=="function",F=e=>typeof e=="string",Re=e=>typeof e=="boolean",ge=e=>typeof e=="symbol",Le=/\/$|\/\?/;function C(e="",t=!1){return t?Le.test(e):e.endsWith("/")}function Ee(e="",t=!1){if(!t)return(C(e)?e.slice(0,-1):e)||"/";if(!C(e,!0))return e||"/";const[a,...l]=e.split("?");return(a.slice(0,-1)||"/")+(l.length?`?${l.join("?")}`:"")}function pe(e="",t=!1){if(!t)return e.endsWith("/")?e:e+"/";if(C(e,!0))return e||"/";const[a,...l]=e.split("?");return a+"/"+(l.length?`?${l.join("?")}`:"")}function ve(e,t){typeof console!="undefined"&&(console.warn("[vue-i18n-routing] "+e),t&&console.warn(t.stack))}function K(e){e=e||[];const t=[];for(const a of e)F(a)?t.push({code:a}):t.push(a);return t}function M(e,t){return m.isRef(e.locale)&&t==="composition"}function Z(e){return"global"in e&&"mode"in e}function x(e){return Z(e)?M(e.global,e.mode)?e.global.locale.value:e.global.locale:e.locale.value}function ee(e,t){Z(e)?M(e.global,e.mode)?e.global.locale.value=t:e.global.locale=t:m.isRef(e.locale)&&(e.locale.value=t)}function Se(e,t,a){return e.replace(/\/+$/,"")+(t?"/":"")||(a?"":"/")}function te(e){return F(e)?e:ge(e)?e.toString():"(null)"}function Q(e,t,{defaultLocale:a,strategy:l,routesNameSeparator:n,defaultLocaleRouteNameSuffix:o}){let r=te(e)+(l==="no_prefix"?"":n+t);return t===a&&l==="prefix_and_default"&&(r+=n+o),r}function Ae(e,t){return me(e)?e(t):e}const P={PREFIX:"prefix",PREFIX_EXCEPT_DEFAULT:"prefix_except_default",PREFIX_AND_DEFAULT:"prefix_and_default",NO_PREFIX:"no_prefix"},$="",b=P.PREFIX_EXCEPT_DEFAULT,ae=!1,U="___",q="default",ye="ltr",le="",Ie=new Set([P.PREFIX_AND_DEFAULT,P.PREFIX_EXCEPT_DEFAULT]);function O(e=A.useRoute(),{router:t=A.useRouter(),routesNameSeparator:a=U}={}){const l=a||t.__routesNameSeparator,n=m.unref(e);return n.name?te(n.name).split(l)[0]:null}function oe(e,t,a){const l=z(e,t,a);return l==null?"":m.isVue3?l.redirectedFrom||l.fullPath:l.route.redirectedFrom||l.route.fullPath}function ne(e,t,a){const l=z(e,t,a);return l==null?void 0:m.isVue3?l:l.route}function Te(e,t,a){const l=z(e,t,a);return l==null?void 0:m.isVue3?l:l.location}function z(e,t,{router:a=A.useRouter(),i18n:l=Y.useI18n(),defaultLocale:n=$,defaultLocaleRouteNameSuffix:o=q,routesNameSeparator:r=U,strategy:i=b,trailingSlash:f=!1}={}){const s=a.__defaultLocaleRouteNameSuffix||o,h=a.__defaultLocale||n,c=a.__routesNameSeparator||r,_=a.__strategy||i,R=t||x(l);let g=e;F(e)&&(g[0]==="/"?g={path:e}:g={name:e});let d=J({},g);if(d.path&&!d.name){const u=a.resolve(d),L=m.isVue3?u:u.route,S=O(L);F(S)?d={name:Q(S,R,{defaultLocale:h,strategy:_,routesNameSeparator:c,defaultLocaleRouteNameSuffix:s}),params:L.params,query:L.query,hash:L.hash}:(!(R===n&&Ie.has(_))&&_!==P.NO_PREFIX&&(d.path=`/${R}${d.path}`),d.path=f?pe(d.path,!0):Ee(d.path,!0))}else{d.name=Q(d.name,R,{defaultLocale:h,strategy:_,routesNameSeparator:c,defaultLocaleRouteNameSuffix:s});const{params:u}=d;u&&u["0"]===void 0&&u.pathMatch&&(u["0"]=u.pathMatch)}const v=a.resolve(d);return(m.isVue3?v.name:v.route.name)?v:a.resolve(e)}function V(e,t){const a=t&&t.route||A.useRoute(),l=O(a,t);if(!l)return"";const s=!m.isVue3&&m.isRef(a)?a.value:a,{params:n}=s,o=W(s,["params"]),r={},i=J({},o,{name:l,params:N(I(I({},n),r),{0:n.pathMatch})});return oe(i,e,t)}function Fe({addDirAttribute:e=!1,addSeoAttributes:t=!1,strategy:a=b,defaultLocale:l=$,route:n=A.useRoute(),router:o=A.useRouter(),i18n:r=Y.useI18n()}={}){const i=l||o.__defaultLocale,f=a||o.__strategy,s=m.ref({htmlAttrs:{},link:[],meta:[]});function h(){s.value={htmlAttrs:{},link:[],meta:[]}}function c(_){if(r.locales==null||r.__baseUrl==null)return;const R=x(r),g=K(r.locales.value).find(u=>u.code===R)||{code:R},d=g.iso,v=g.dir||o.__defaultDirection;if(e&&(s.value.htmlAttrs.dir=v),t&&R&&r.locales){d&&(s.value.htmlAttrs.lang=d);const u=r.locales.value;Pe(u,r.__baseUrl,s.value.link,{defaultLocale:i,strategy:f,route:n,router:o,i18n:r}),De(r.__baseUrl,s.value.link,t,{route:_,router:o,i18n:r}),Ne(g,d,s.value.meta),xe(u,d,s.value.meta)}}return m.watch(o.currentRoute,_=>{h(),c(_)}),c(n),s}function Pe(e,t,a,l){if(l.strategy===P.NO_PREFIX)return;const n=new Map;for(const o of e){const r=o.iso;if(!r){ve("Locale ISO code is required to generate alternate link");continue}const[i,f]=r.split("-");i&&f&&(o.isCatchallLocale||!n.has(i))&&n.set(i,o),n.set(r,o)}for(const[o,r]of n.entries()){const i=V(r.code,l);i&&a.push({hid:`i18n-alt-${o}`,rel:"alternate",href:X(i,t),hreflang:o})}if(l.defaultLocale){const o=V(l.defaultLocale,l);o&&a.push({hid:"i18n-xd",rel:"alternate",href:X(o,t),hreflang:"x-default"})}}function De(e,t,a,l){const{route:n}=l,o=ne(N(I({},n),{name:O(n,l)}),void 0,l);if(o){let r=X(o.path,e);const i=!Re(a)&&a.canonicalQueries||[];if(i.length){const f=o.query,s=new URLSearchParams;for(const c of i)if(c in f){const _=f[c];_e(_)?_.forEach(R=>s.append(c,R||"")):s.append(c,_||"")}const h=s.toString();h&&(r=`${r}?${h}`)}t.push({hid:"i18n-can",rel:"canonical",href:r})}}function Ne(e,t,a){!(e&&t)||a.push({hid:"i18n-og",property:"og:locale",content:re(t)})}function xe(e,t,a){const l=e.filter(n=>{const o=n.iso;return o&&o!==t});if(l.length){const n=l.map(o=>({hid:`i18n-og-alt-${o.iso}`,property:"og:locale:alternate",content:re(o.iso)}));a.push(...n)}}function re(e){return(e||"").replace(/-/g,"_")}function X(e,t){return e.match(/^https?:\/\//)?e:t+e}function ce(e,{defaultLocale:t=$,strategy:a=b,trailingSlash:l=ae,routesNameSeparator:n=U,defaultLocaleRouteNameSuffix:o=q,includeUprefixedFallback:r=!1,optionsResolver:i=void 0,locales:f=[]}={}){if(a==="no_prefix")return e;const s=f.map(c=>F(c)?c:c.code);function h(c,_,R=!1,g=!1){if(c.redirect&&(!c.component||!c.file))return[c];let d=null;return i!=null&&(d=i(c,_),d==null)?[c]:_.reduce((u,L)=>{const{name:S}=c;let{path:E}=c;const p=I({},c);S&&(p.name=`${S}${n}${L}`),c.children&&(p.children=c.children.reduce((y,w)=>[...y,...h(w,[L],!0,g)],[]));const T=L===t;if(T&&a==="prefix_and_default")if(R)R&&g&&S&&(p.name+=`${n}${o}`);else{const y=N(I({},p),{path:E});if(S&&(y.name=`${p.name}${n}${o}`),c.children){y.children=[];for(const w of c.children)y.children=y.children.concat(h(w,[L],!0,!0))}u.push(y)}const j=R&&!E.startsWith("/"),k=!j&&!(T&&a==="prefix_except_default");return k&&(E=`/${L}${E}`),E&&(E=Se(E,l,j)),k&&T&&a==="prefix"&&r&&u.push(I({},c)),p.path=E,u.push(p),u},[])}return e.reduce((c,_)=>[...c,...h(_,s||[])],[])}function $e(e,{locales:t=[],localeCodes:a=[],baseUrl:l=le}={}){if(!M(e.global,e.mode))throw new Error("TODO:");const n=m.ref(t),o=m.ref(a);e.global.locales=m.computed(()=>n.value),e.global.localeCodes=m.computed(()=>o.value),e.global.__baseUrl=Ae(l,{})}function be(e){return new RegExp(`^/(${e.join("|")})(?:/|$)`,"i")}function se(e,t,a){const l=`(${e.join("|")})`,n=`(?:${t}${a})?`,o=new RegExp(`${t}${l}${n}$`,"i"),r=be(e);return f=>{if(f.name){const h=(F(f.name)?f.name:f.name.toString()).match(o);if(h&&h.length>1)return h[1]}else if(f.path){const s=f.path.match(r);if(s&&s.length>1)return s[1]}return""}}function Ue(e){var t,a,l,n,o,r,i,f,s,h;return e.version=(t=e.version)!=null?t:4,e.defaultLocale=(a=e.defaultLocale)!=null?a:$,e.strategy=(l=e.strategy)!=null?l:b,e.trailingSlash=(n=e.trailingSlash)!=null?n:ae,e.routesNameSeparator=(o=e.routesNameSeparator)!=null?o:U,e.defaultLocaleRouteNameSuffix=(r=e.defaultLocaleRouteNameSuffix)!=null?r:q,e.locales=(i=e.locales)!=null?i:[],e.defaultDirection=(f=e.defaultDirection)!=null?f:ye,e.baseUrl=(s=e.baseUrl)!=null?s:le,e.routes=(h=e.routes)!=null?h:[],e}function Oe(e,t={}){const{version:a,defaultLocale:l,locales:n,strategy:o,trailingSlash:r,routesNameSeparator:i,defaultLocaleRouteNameSuffix:f,defaultDirection:s,baseUrl:h,routes:c,routeOptionsResolver:_}=Ue(t),R=K(n),g=R.map(L=>L.code),d=se(g,i,f);$e(e,{locales:R,baseUrl:h,localeCodes:g});const v=ce(c,{locales:n,defaultLocale:l,strategy:o,trailingSlash:r,routesNameSeparator:i,defaultLocaleRouteNameSuffix:f,optionsResolver:_});t.routes=v;let u=null;if(m.isVue3&&a===4)u=A.createRouter(t);else if(m.isVue2&&a===3)u=new he.default(t);else throw new Error("TODO:");return u.__defaultLocale=l,u.__localeCodes=g,u.__strategy=o,u.__trailingSlash=r,u.__routesNameSeparator=i,u.__defaultLocaleRouteNameSuffix=f,u.__defaultDirection=s,u.beforeEach((L,S,E)=>{const p=x(e),T=d(L)||p||l||"";p!==T&&ee(e,T),E()}),u}const we="0.0.0";exports.VERSION=we;exports.createLocaleFromRouteGetter=se;exports.createRouter=Oe;exports.getLocale=x;exports.getRouteBaseName=O;exports.localeLocation=Te;exports.localePath=oe;exports.localeRoute=ne;exports.localizeRoutes=ce;exports.setLocale=ee;exports.switchLocalePath=V;exports.useI18nHead=Fe; | ||
*/const K=Object.assign,me=Array.isArray,Re=e=>typeof e=="function",F=e=>typeof e=="string",ge=e=>typeof e=="boolean",Le=e=>typeof e=="symbol",Ee=e=>e!==null&&typeof e=="object",pe=/\/$|\/\?/;function C(e="",t=!1){return t?pe.test(e):e.endsWith("/")}function ve(e="",t=!1){if(!t)return(C(e)?e.slice(0,-1):e)||"/";if(!C(e,!0))return e||"/";const[a,...l]=e.split("?");return(a.slice(0,-1)||"/")+(l.length?`?${l.join("?")}`:"")}function Se(e="",t=!1){if(!t)return e.endsWith("/")?e:e+"/";if(C(e,!0))return e||"/";const[a,...l]=e.split("?");return a+"/"+(l.length?`?${l.join("?")}`:"")}const Ae=typeof window!="undefined";function Ie(e,t){typeof console!="undefined"&&(console.warn("[vue-i18n-routing] "+e),t&&console.warn(t.stack))}function Z(e){e=e||[];const t=[];for(const a of e)F(a)?t.push({code:a}):t.push(a);return t}function j(e,t){return _.isRef(e.locale)&&t==="composition"}function ee(e){return"global"in e&&"mode"in e}function x(e){return ee(e)?j(e.global,e.mode)?e.global.locale.value:e.global.locale:e.locale.value}function te(e,t){ee(e)?j(e.global,e.mode)?e.global.locale.value=t:e.global.locale=t:_.isRef(e.locale)&&(e.locale.value=t)}function Te(e,t,a){return e.replace(/\/+$/,"")+(t?"/":"")||(a?"":"/")}function Q(e){return v.isVueRouter4,_.isRef(e)?e.value:e}function ae(e){return F(e)?e:Le(e)?e.toString():"(null)"}function Y(e,t,{defaultLocale:a,strategy:l,routesNameSeparator:o,defaultLocaleRouteNameSuffix:n}){let c=ae(e)+(l==="no_prefix"?"":o+t);return t===a&&l==="prefix_and_default"&&(c+=o+n),c}function Fe(e,t){return Re(e)?e(t):e}const y={PREFIX:"prefix",PREFIX_EXCEPT_DEFAULT:"prefix_except_default",PREFIX_AND_DEFAULT:"prefix_and_default",NO_PREFIX:"no_prefix"},$="",O=y.PREFIX_EXCEPT_DEFAULT,le=!1,U="___",M="default",Pe="ltr",ne="",ye=new Set([y.PREFIX_AND_DEFAULT,y.PREFIX_EXCEPT_DEFAULT]);function b(e=v.useRoute(),{router:t=v.useRouter(),routesNameSeparator:a=U}={}){const l=a||t.__routesNameSeparator,o=_.unref(e);return o.name?ae(o.name).split(l)[0]:null}function oe(e,t,a){const l=q(e,t,a);return l==null?"":_.isVue3?l.redirectedFrom||l.fullPath:l.route.redirectedFrom||l.route.fullPath}function ce(e,t,a){const l=q(e,t,a);return l==null?void 0:_.isVue3?l:l.route}function De(e,t,a){const l=q(e,t,a);return l==null?void 0:_.isVue3?l:l.location}function q(e,t,{router:a=v.useRouter(),i18n:l=J.useI18n(),defaultLocale:o=$,defaultLocaleRouteNameSuffix:n=M,routesNameSeparator:c=U,strategy:f=O,trailingSlash:i=!1}={}){const r=a.__defaultLocaleRouteNameSuffix||n,h=a.__defaultLocale||o,s=a.__routesNameSeparator||c,m=a.__strategy||f,R=t||x(l);let g=e;F(e)&&(g[0]==="/"?g={path:e}:g={name:e});let d=K({},g);if(d.path&&!d.name){const u=a.resolve(d),L=_.isVue3?u:u.route,A=b(L);F(A)?d={name:Y(A,R,{defaultLocale:h,strategy:m,routesNameSeparator:s,defaultLocaleRouteNameSuffix:r}),params:L.params,query:L.query,hash:L.hash}:(!(R===o&&ye.has(m))&&m!==y.NO_PREFIX&&(d.path=`/${R}${d.path}`),d.path=i?Se(d.path,!0):ve(d.path,!0))}else{d.name=Y(d.name,R,{defaultLocale:h,strategy:m,routesNameSeparator:s,defaultLocaleRouteNameSuffix:r});const{params:u}=d;u&&u["0"]===void 0&&u.pathMatch&&(u["0"]=u.pathMatch)}const S=a.resolve(d);return(_.isVue3?S.name:S.route.name)?S:a.resolve(e)}function V(e,t){const a=t&&t.route||v.useRoute(),l=b(a,t);if(!l)return"";const r=!_.isVue3&&_.isRef(a)?a.value:a,{params:o}=r,n=W(r,["params"]),c={},f=K({},n,{name:l,params:N(T(T({},o),c),{0:o.pathMatch})});return oe(f,e,t)}function Ne({addDirAttribute:e=!1,addSeoAttributes:t=!1,strategy:a=O,defaultLocale:l=$,route:o=v.useRoute(),router:n=v.useRouter(),i18n:c=J.useI18n()}={}){const f=l||n.__defaultLocale,i=a||n.__strategy,r=_.ref({htmlAttrs:{},link:[],meta:[]});function h(){r.value={htmlAttrs:{},link:[],meta:[]}}function s(m){if(c.locales==null||c.__baseUrl==null)return;const R=x(c),g=Z(c.locales.value).find(u=>u.code===R)||{code:R},d=g.iso,S=g.dir||n.__defaultDirection;if(e&&(r.value.htmlAttrs.dir=S),t&&R&&c.locales){d&&(r.value.htmlAttrs.lang=d);const u=c.locales.value;xe(u,c.__baseUrl,r.value.link,{defaultLocale:f,strategy:i,route:o,router:n,i18n:c}),$e(c.__baseUrl,r.value.link,t,{route:m,router:n,i18n:c}),Oe(g,d,r.value.meta),Ue(u,d,r.value.meta)}}return Ae?_.watchEffect(()=>{h(),s(Q(n.currentRoute))}):s(Q(n.currentRoute)),r}function xe(e,t,a,l){if(l.strategy===y.NO_PREFIX)return;const o=new Map;for(const n of e){const c=n.iso;if(!c){Ie("Locale ISO code is required to generate alternate link");continue}const[f,i]=c.split("-");f&&i&&(n.isCatchallLocale||!o.has(f))&&o.set(f,n),o.set(c,n)}for(const[n,c]of o.entries()){const f=V(c.code,l);f&&a.push({hid:`i18n-alt-${n}`,rel:"alternate",href:X(f,t),hreflang:n})}if(l.defaultLocale){const n=V(l.defaultLocale,l);n&&a.push({hid:"i18n-xd",rel:"alternate",href:X(n,t),hreflang:"x-default"})}}function $e(e,t,a,l){const{route:o}=l,n=ce(N(T({},o),{name:b(o,l)}),void 0,l);if(n){let c=X(n.path,e);const f=!ge(a)&&a.canonicalQueries||[];if(f.length){const i=n.query,r=new URLSearchParams;for(const s of f)if(s in i){const m=i[s];me(m)?m.forEach(R=>r.append(s,R||"")):r.append(s,m||"")}const h=r.toString();h&&(c=`${c}?${h}`)}t.push({hid:"i18n-can",rel:"canonical",href:c})}}function Oe(e,t,a){!(e&&t)||a.push({hid:"i18n-og",property:"og:locale",content:re(t)})}function Ue(e,t,a){const l=e.filter(o=>{const n=o.iso;return n&&n!==t});if(l.length){const o=l.map(n=>({hid:`i18n-og-alt-${n.iso}`,property:"og:locale:alternate",content:re(n.iso)}));a.push(...o)}}function re(e){return(e||"").replace(/-/g,"_")}function X(e,t){return e.match(/^https?:\/\//)?e:t+e}function se(e,{defaultLocale:t=$,strategy:a=O,trailingSlash:l=le,routesNameSeparator:o=U,defaultLocaleRouteNameSuffix:n=M,includeUprefixedFallback:c=!1,optionsResolver:f=void 0,locales:i=[]}={}){if(a==="no_prefix")return e;const r=i.map(s=>F(s)?s:s.code);function h(s,m,R=!1,g=!1){if(s.redirect&&(!s.component||!s.file))return[s];let d=null;return f!=null&&(d=f(s,m),d==null)?[s]:m.reduce((u,L)=>{const{name:A}=s;let{path:E}=s;const p=T({},s);A&&(p.name=`${A}${o}${L}`),s.children&&(p.children=s.children.reduce((I,w)=>[...I,...h(w,[L],!0,g)],[]));const P=L===t;if(P&&a==="prefix_and_default")if(R)R&&g&&A&&(p.name+=`${o}${n}`);else{const I=N(T({},p),{path:E});if(A&&(I.name=`${p.name}${o}${n}`),s.children){I.children=[];for(const w of s.children)I.children=I.children.concat(h(w,[L],!0,!0))}u.push(I)}const z=R&&!E.startsWith("/"),k=!z&&!(P&&a==="prefix_except_default");return k&&(E=`/${L}${E}`),E&&(E=Te(E,l,z)),k&&P&&a==="prefix"&&c&&u.push(T({},s)),p.path=E,u.push(p),u},[])}return e.reduce((s,m)=>[...s,...h(m,r||[])],[])}function be(e,{locales:t=[],localeCodes:a=[],baseUrl:l=ne}={}){if(!j(e.global,e.mode))throw new Error("TODO:");const o=_.ref(t),n=_.ref(a);e.global.locales=_.computed(()=>o.value),e.global.localeCodes=_.computed(()=>n.value),e.global.__baseUrl=Fe(l,{})}function we(e){return new RegExp(`^/(${e.join("|")})(?:/|$)`,"i")}function ue(e,t,a){const l=`(${e.join("|")})`,o=`(?:${t}${a})?`,n=new RegExp(`${t}${l}${o}$`,"i"),c=we(e);return i=>{if(Ee(i)){if(i.name){const h=(F(i.name)?i.name:i.name.toString()).match(n);if(h&&h.length>1)return h[1]}else if(i.path){const r=i.path.match(c);if(r&&r.length>1)return r[1]}}else if(F(i)){const r=i.match(c);if(r&&r.length>1)return r[1]}return""}}function Ce(e){var t,a,l,o,n,c,f,i,r,h;return e.version=(t=e.version)!=null?t:4,e.defaultLocale=(a=e.defaultLocale)!=null?a:$,e.strategy=(l=e.strategy)!=null?l:O,e.trailingSlash=(o=e.trailingSlash)!=null?o:le,e.routesNameSeparator=(n=e.routesNameSeparator)!=null?n:U,e.defaultLocaleRouteNameSuffix=(c=e.defaultLocaleRouteNameSuffix)!=null?c:M,e.locales=(f=e.locales)!=null?f:[],e.defaultDirection=(i=e.defaultDirection)!=null?i:Pe,e.baseUrl=(r=e.baseUrl)!=null?r:ne,e.routes=(h=e.routes)!=null?h:[],e}function Ve(e,t={}){const{version:a,defaultLocale:l,locales:o,strategy:n,trailingSlash:c,routesNameSeparator:f,defaultLocaleRouteNameSuffix:i,defaultDirection:r,baseUrl:h,routes:s,routeOptionsResolver:m}=Ce(t),R=Z(o),g=R.map(L=>L.code),d=ue(g,f,i);be(e,{locales:R,baseUrl:h,localeCodes:g});const S=se(s,{locales:o,defaultLocale:l,strategy:n,trailingSlash:c,routesNameSeparator:f,defaultLocaleRouteNameSuffix:i,optionsResolver:m});t.routes=S;let u=null;if(_.isVue3&&a===4)u=v.createRouter(t);else if(_.isVue2&&a===3)u=new _e.default(t);else throw new Error("TODO:");return u.__defaultLocale=l,u.__localeCodes=g,u.__strategy=n,u.__trailingSlash=c,u.__routesNameSeparator=f,u.__defaultLocaleRouteNameSuffix=i,u.__defaultDirection=r,u.beforeEach((L,A,E)=>{const p=x(e),P=d(L)||p||l||"";p!==P&&te(e,P),E()}),u}const Xe="0.0.0";exports.VERSION=Xe;exports.createLocaleFromRouteGetter=ue;exports.createRouter=Ve;exports.getLocale=x;exports.getRouteBaseName=b;exports.localeLocation=De;exports.localePath=oe;exports.localeRoute=ce;exports.localizeRoutes=se;exports.setLocale=te;exports.switchLocalePath=V;exports.useI18nHead=Ne; |
@@ -37,3 +37,3 @@ import { Composer } from '@intlify/vue-i18n-bridge'; | ||
export declare function createLocaleFromRouteGetter(localeCodes: string[], routesNameSeparator: string, defaultLocaleRouteNameSuffix: string): (route: Route_2 | RouteLocationNormalizedLoaded | RouteLocationNormalized) => string; | ||
export declare function createLocaleFromRouteGetter(localeCodes: string[], routesNameSeparator: string, defaultLocaleRouteNameSuffix: string): (route: Route_2 | RouteLocationNormalizedLoaded | RouteLocationNormalized | string) => string; | ||
@@ -40,0 +40,0 @@ /** |
@@ -32,4 +32,4 @@ var __defProp = Object.defineProperty; | ||
}; | ||
import { isRef, unref, isVue3, ref, watch, computed, isVue2 } from "vue-demi"; | ||
import VueRouter3, { useRoute, useRouter, createRouter as createRouter$1 } from "@intlify/vue-router-bridge"; | ||
import { isRef, unref, isVue3, ref, watchEffect, computed, isVue2 } from "vue-demi"; | ||
import VueRouter3, { isVueRouter4, useRoute, useRouter, createRouter as createRouter$1 } from "@intlify/vue-router-bridge"; | ||
import { useI18n } from "@intlify/vue-i18n-bridge"; | ||
@@ -47,2 +47,3 @@ /*! | ||
const isSymbol = (val) => typeof val === "symbol"; | ||
const isObject = (val) => val !== null && typeof val === "object"; | ||
const TRAILING_SLASH_RE = /\/$|\/\?/; | ||
@@ -75,2 +76,3 @@ function hasTrailingSlash(input = "", queryParams = false) { | ||
} | ||
const inBrowser = typeof window !== "undefined"; | ||
function warn(msg, err) { | ||
@@ -119,2 +121,5 @@ if (typeof console !== "undefined") { | ||
} | ||
function toRawRoute(maybeRoute) { | ||
return isVueRouter4 ? isRef(maybeRoute) ? maybeRoute.value : maybeRoute : isRef(maybeRoute) ? maybeRoute.value : maybeRoute; | ||
} | ||
function getRouteName(routeName) { | ||
@@ -311,7 +316,10 @@ return isString(routeName) ? routeName : isSymbol(routeName) ? routeName.toString() : "(null)"; | ||
} | ||
watch(router.currentRoute, (val) => { | ||
cleanMeta(); | ||
updateMeta(val); | ||
}); | ||
updateMeta(route); | ||
if (inBrowser) { | ||
watchEffect(() => { | ||
cleanMeta(); | ||
updateMeta(toRawRoute(router.currentRoute)); | ||
}); | ||
} else { | ||
updateMeta(toRawRoute(router.currentRoute)); | ||
} | ||
return metaObject; | ||
@@ -517,10 +525,17 @@ } | ||
const getLocaleFromRoute = (route) => { | ||
if (route.name) { | ||
const name = isString(route.name) ? route.name : route.name.toString(); | ||
const matches = name.match(regexpName); | ||
if (matches && matches.length > 1) { | ||
return matches[1]; | ||
if (isObject(route)) { | ||
if (route.name) { | ||
const name = isString(route.name) ? route.name : route.name.toString(); | ||
const matches = name.match(regexpName); | ||
if (matches && matches.length > 1) { | ||
return matches[1]; | ||
} | ||
} else if (route.path) { | ||
const matches = route.path.match(regexpPath); | ||
if (matches && matches.length > 1) { | ||
return matches[1]; | ||
} | ||
} | ||
} else if (route.path) { | ||
const matches = route.path.match(regexpPath); | ||
} else if (isString(route)) { | ||
const matches = route.match(regexpPath); | ||
if (matches && matches.length > 1) { | ||
@@ -527,0 +542,0 @@ return matches[1]; |
@@ -1,5 +0,5 @@ | ||
var Ce=Object.defineProperty,xe=Object.defineProperties;var De=Object.getOwnPropertyDescriptors;var x=Object.getOwnPropertySymbols;var re=Object.prototype.hasOwnProperty,se=Object.prototype.propertyIsEnumerable;var ce=(s,r,_)=>r in s?Ce(s,r,{enumerable:!0,configurable:!0,writable:!0,value:_}):s[r]=_,P=(s,r)=>{for(var _ in r||(r={}))re.call(r,_)&&ce(s,_,r[_]);if(x)for(var _ of x(r))se.call(r,_)&&ce(s,_,r[_]);return s},D=(s,r)=>xe(s,De(r));var ue=(s,r)=>{var _={};for(var p in s)re.call(s,p)&&r.indexOf(p)<0&&(_[p]=s[p]);if(s!=null&&x)for(var p of x(s))r.indexOf(p)<0&&se.call(s,p)&&(_[p]=s[p]);return _};var VueI18nRouting=function(s,r,_,p){"use strict";function fe(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var ie=fe(_);/*! | ||
var De=Object.defineProperty,je=Object.defineProperties;var Me=Object.getOwnPropertyDescriptors;var x=Object.getOwnPropertySymbols;var se=Object.prototype.hasOwnProperty,ue=Object.prototype.propertyIsEnumerable;var re=(u,r,_)=>r in u?De(u,r,{enumerable:!0,configurable:!0,writable:!0,value:_}):u[r]=_,y=(u,r)=>{for(var _ in r||(r={}))se.call(r,_)&&re(u,_,r[_]);if(x)for(var _ of x(r))ue.call(r,_)&&re(u,_,r[_]);return u},X=(u,r)=>je(u,Me(r));var fe=(u,r)=>{var _={};for(var p in u)se.call(u,p)&&r.indexOf(p)<0&&(_[p]=u[p]);if(u!=null&&x)for(var p of x(u))r.indexOf(p)<0&&ue.call(u,p)&&(_[p]=u[p]);return _};var VueI18nRouting=function(u,r,_,p){"use strict";function ie(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var de=ie(_);/*! | ||
* shared v9.2.0-beta.30 | ||
* (c) 2022 kazuya kawaguchi | ||
* Released under the MIT License. | ||
*/const G=Object.assign,de=Array.isArray,he=e=>typeof e=="function",N=e=>typeof e=="string",_e=e=>typeof e=="boolean",me=e=>typeof e=="symbol",Le=/\/$|\/\?/;function X(e="",t=!1){return t?Le.test(e):e.endsWith("/")}function ge(e="",t=!1){if(!t)return(X(e)?e.slice(0,-1):e)||"/";if(!X(e,!0))return e||"/";const[a,...l]=e.split("?");return(a.slice(0,-1)||"/")+(l.length?`?${l.join("?")}`:"")}function Re(e="",t=!1){if(!t)return e.endsWith("/")?e:e+"/";if(X(e,!0))return e||"/";const[a,...l]=e.split("?");return a+"/"+(l.length?`?${l.join("?")}`:"")}function Ee(e,t){typeof console!="undefined"&&(console.warn("[vue-i18n-routing] "+e),t&&console.warn(t.stack))}function H(e){e=e||[];const t=[];for(const a of e)N(a)?t.push({code:a}):t.push(a);return t}function M(e,t){return r.isRef(e.locale)&&t==="composition"}function W(e){return"global"in e&&"mode"in e}function U(e){return W(e)?M(e.global,e.mode)?e.global.locale.value:e.global.locale:e.locale.value}function B(e,t){W(e)?M(e.global,e.mode)?e.global.locale.value=t:e.global.locale=t:r.isRef(e.locale)&&(e.locale.value=t)}function Se(e,t,a){return e.replace(/\/+$/,"")+(t?"/":"")||(a?"":"/")}function Q(e){return N(e)?e:me(e)?e.toString():"(null)"}function Y(e,t,{defaultLocale:a,strategy:l,routesNameSeparator:o,defaultLocaleRouteNameSuffix:n}){let c=Q(e)+(l==="no_prefix"?"":o+t);return t===a&&l==="prefix_and_default"&&(c+=o+n),c}function pe(e,t){return he(e)?e(t):e}const b={PREFIX:"prefix",PREFIX_EXCEPT_DEFAULT:"prefix_except_default",PREFIX_AND_DEFAULT:"prefix_and_default",NO_PREFIX:"no_prefix"},v="",O=b.PREFIX_EXCEPT_DEFAULT,J=!1,w="___",V="default",Ae="ltr",K="",Ie=new Set([b.PREFIX_AND_DEFAULT,b.PREFIX_EXCEPT_DEFAULT]);function C(e=_.useRoute(),{router:t=_.useRouter(),routesNameSeparator:a=w}={}){const l=a||t.__routesNameSeparator,o=r.unref(e);return o.name?Q(o.name).split(l)[0]:null}function Z(e,t,a){const l=z(e,t,a);return l==null?"":r.isVue3?l.redirectedFrom||l.fullPath:l.route.redirectedFrom||l.route.fullPath}function ee(e,t,a){const l=z(e,t,a);return l==null?void 0:r.isVue3?l:l.route}function Te(e,t,a){const l=z(e,t,a);return l==null?void 0:r.isVue3?l:l.location}function z(e,t,{router:a=_.useRouter(),i18n:l=p.useI18n(),defaultLocale:o=v,defaultLocaleRouteNameSuffix:n=V,routesNameSeparator:c=w,strategy:d=O,trailingSlash:h=!1}={}){const f=a.__defaultLocaleRouteNameSuffix||n,L=a.__defaultLocale||o,u=a.__routesNameSeparator||c,g=a.__strategy||d,R=t||U(l);let E=e;N(e)&&(E[0]==="/"?E={path:e}:E={name:e});let m=G({},E);if(m.path&&!m.name){const i=a.resolve(m),S=r.isVue3?i:i.route,y=C(S);N(y)?m={name:Y(y,R,{defaultLocale:L,strategy:g,routesNameSeparator:u,defaultLocaleRouteNameSuffix:f}),params:S.params,query:S.query,hash:S.hash}:(!(R===o&&Ie.has(g))&&g!==b.NO_PREFIX&&(m.path=`/${R}${m.path}`),m.path=h?Re(m.path,!0):ge(m.path,!0))}else{m.name=Y(m.name,R,{defaultLocale:L,strategy:g,routesNameSeparator:u,defaultLocaleRouteNameSuffix:f});const{params:i}=m;i&&i["0"]===void 0&&i.pathMatch&&(i["0"]=i.pathMatch)}const T=a.resolve(m);return(r.isVue3?T.name:T.route.name)?T:a.resolve(e)}function j(e,t){const a=t&&t.route||_.useRoute(),l=C(a,t);if(!l)return"";const f=!r.isVue3&&r.isRef(a)?a.value:a,{params:o}=f,n=ue(f,["params"]),c={},d=G({},n,{name:l,params:D(P(P({},o),c),{0:o.pathMatch})});return Z(d,e,t)}function ye({addDirAttribute:e=!1,addSeoAttributes:t=!1,strategy:a=O,defaultLocale:l=v,route:o=_.useRoute(),router:n=_.useRouter(),i18n:c=p.useI18n()}={}){const d=l||n.__defaultLocale,h=a||n.__strategy,f=r.ref({htmlAttrs:{},link:[],meta:[]});function L(){f.value={htmlAttrs:{},link:[],meta:[]}}function u(g){if(c.locales==null||c.__baseUrl==null)return;const R=U(c),E=H(c.locales.value).find(i=>i.code===R)||{code:R},m=E.iso,T=E.dir||n.__defaultDirection;if(e&&(f.value.htmlAttrs.dir=T),t&&R&&c.locales){m&&(f.value.htmlAttrs.lang=m);const i=c.locales.value;Fe(i,c.__baseUrl,f.value.link,{defaultLocale:d,strategy:h,route:o,router:n,i18n:c}),Pe(c.__baseUrl,f.value.link,t,{route:g,router:n,i18n:c}),Ne(E,m,f.value.meta),$e(i,m,f.value.meta)}}return r.watch(n.currentRoute,g=>{L(),u(g)}),u(o),f}function Fe(e,t,a,l){if(l.strategy===b.NO_PREFIX)return;const o=new Map;for(const n of e){const c=n.iso;if(!c){Ee("Locale ISO code is required to generate alternate link");continue}const[d,h]=c.split("-");d&&h&&(n.isCatchallLocale||!o.has(d))&&o.set(d,n),o.set(c,n)}for(const[n,c]of o.entries()){const d=j(c.code,l);d&&a.push({hid:`i18n-alt-${n}`,rel:"alternate",href:k(d,t),hreflang:n})}if(l.defaultLocale){const n=j(l.defaultLocale,l);n&&a.push({hid:"i18n-xd",rel:"alternate",href:k(n,t),hreflang:"x-default"})}}function Pe(e,t,a,l){const{route:o}=l,n=ee(D(P({},o),{name:C(o,l)}),void 0,l);if(n){let c=k(n.path,e);const d=!_e(a)&&a.canonicalQueries||[];if(d.length){const h=n.query,f=new URLSearchParams;for(const u of d)if(u in h){const g=h[u];de(g)?g.forEach(R=>f.append(u,R||"")):f.append(u,g||"")}const L=f.toString();L&&(c=`${c}?${L}`)}t.push({hid:"i18n-can",rel:"canonical",href:c})}}function Ne(e,t,a){!(e&&t)||a.push({hid:"i18n-og",property:"og:locale",content:te(t)})}function $e(e,t,a){const l=e.filter(o=>{const n=o.iso;return n&&n!==t});if(l.length){const o=l.map(n=>({hid:`i18n-og-alt-${n.iso}`,property:"og:locale:alternate",content:te(n.iso)}));a.push(...o)}}function te(e){return(e||"").replace(/-/g,"_")}function k(e,t){return e.match(/^https?:\/\//)?e:t+e}function ae(e,{defaultLocale:t=v,strategy:a=O,trailingSlash:l=J,routesNameSeparator:o=w,defaultLocaleRouteNameSuffix:n=V,includeUprefixedFallback:c=!1,optionsResolver:d=void 0,locales:h=[]}={}){if(a==="no_prefix")return e;const f=h.map(u=>N(u)?u:u.code);function L(u,g,R=!1,E=!1){if(u.redirect&&(!u.component||!u.file))return[u];let m=null;return d!=null&&(m=d(u,g),m==null)?[u]:g.reduce((i,S)=>{const{name:y}=u;let{path:A}=u;const I=P({},u);y&&(I.name=`${y}${o}${S}`),u.children&&(I.children=u.children.reduce((F,q)=>[...F,...L(q,[S],!0,E)],[]));const $=S===t;if($&&a==="prefix_and_default")if(R)R&&E&&y&&(I.name+=`${o}${n}`);else{const F=D(P({},I),{path:A});if(y&&(F.name=`${I.name}${o}${n}`),u.children){F.children=[];for(const q of u.children)F.children=F.children.concat(L(q,[S],!0,!0))}i.push(F)}const ne=R&&!A.startsWith("/"),oe=!ne&&!($&&a==="prefix_except_default");return oe&&(A=`/${S}${A}`),A&&(A=Se(A,l,ne)),oe&&$&&a==="prefix"&&c&&i.push(P({},u)),I.path=A,i.push(I),i},[])}return e.reduce((u,g)=>[...u,...L(g,f||[])],[])}function be(e,{locales:t=[],localeCodes:a=[],baseUrl:l=K}={}){if(!M(e.global,e.mode))throw new Error("TODO:");const o=r.ref(t),n=r.ref(a);e.global.locales=r.computed(()=>o.value),e.global.localeCodes=r.computed(()=>n.value),e.global.__baseUrl=pe(l,{})}function Ue(e){return new RegExp(`^/(${e.join("|")})(?:/|$)`,"i")}function le(e,t,a){const l=`(${e.join("|")})`,o=`(?:${t}${a})?`,n=new RegExp(`${t}${l}${o}$`,"i"),c=Ue(e);return h=>{if(h.name){const L=(N(h.name)?h.name:h.name.toString()).match(n);if(L&&L.length>1)return L[1]}else if(h.path){const f=h.path.match(c);if(f&&f.length>1)return f[1]}return""}}function ve(e){var t,a,l,o,n,c,d,h,f,L;return e.version=(t=e.version)!=null?t:4,e.defaultLocale=(a=e.defaultLocale)!=null?a:v,e.strategy=(l=e.strategy)!=null?l:O,e.trailingSlash=(o=e.trailingSlash)!=null?o:J,e.routesNameSeparator=(n=e.routesNameSeparator)!=null?n:w,e.defaultLocaleRouteNameSuffix=(c=e.defaultLocaleRouteNameSuffix)!=null?c:V,e.locales=(d=e.locales)!=null?d:[],e.defaultDirection=(h=e.defaultDirection)!=null?h:Ae,e.baseUrl=(f=e.baseUrl)!=null?f:K,e.routes=(L=e.routes)!=null?L:[],e}function Oe(e,t={}){const{version:a,defaultLocale:l,locales:o,strategy:n,trailingSlash:c,routesNameSeparator:d,defaultLocaleRouteNameSuffix:h,defaultDirection:f,baseUrl:L,routes:u,routeOptionsResolver:g}=ve(t),R=H(o),E=R.map(S=>S.code),m=le(E,d,h);be(e,{locales:R,baseUrl:L,localeCodes:E});const T=ae(u,{locales:o,defaultLocale:l,strategy:n,trailingSlash:c,routesNameSeparator:d,defaultLocaleRouteNameSuffix:h,optionsResolver:g});t.routes=T;let i=null;if(r.isVue3&&a===4)i=_.createRouter(t);else if(r.isVue2&&a===3)i=new ie.default(t);else throw new Error("TODO:");return i.__defaultLocale=l,i.__localeCodes=E,i.__strategy=n,i.__trailingSlash=c,i.__routesNameSeparator=d,i.__defaultLocaleRouteNameSuffix=h,i.__defaultDirection=f,i.beforeEach((S,y,A)=>{const I=U(e),$=m(S)||I||l||"";I!==$&&B(e,$),A()}),i}const we="0.0.0";return s.VERSION=we,s.createLocaleFromRouteGetter=le,s.createRouter=Oe,s.getLocale=U,s.getRouteBaseName=C,s.localeLocation=Te,s.localePath=Z,s.localeRoute=ee,s.localizeRoutes=ae,s.setLocale=B,s.switchLocalePath=j,s.useI18nHead=ye,Object.defineProperty(s,"__esModule",{value:!0}),s[Symbol.toStringTag]="Module",s}({},VueDemi,VueRouter,VueI18n); | ||
*/const G=Object.assign,he=Array.isArray,_e=e=>typeof e=="function",P=e=>typeof e=="string",ge=e=>typeof e=="boolean",Le=e=>typeof e=="symbol",Re=e=>e!==null&&typeof e=="object",me=/\/$|\/\?/;function D(e="",t=!1){return t?me.test(e):e.endsWith("/")}function Ee(e="",t=!1){if(!t)return(D(e)?e.slice(0,-1):e)||"/";if(!D(e,!0))return e||"/";const[a,...l]=e.split("?");return(a.slice(0,-1)||"/")+(l.length?`?${l.join("?")}`:"")}function Se(e="",t=!1){if(!t)return e.endsWith("/")?e:e+"/";if(D(e,!0))return e||"/";const[a,...l]=e.split("?");return a+"/"+(l.length?`?${l.join("?")}`:"")}const pe=typeof window!="undefined";function Ae(e,t){typeof console!="undefined"&&(console.warn("[vue-i18n-routing] "+e),t&&console.warn(t.stack))}function B(e){e=e||[];const t=[];for(const a of e)P(a)?t.push({code:a}):t.push(a);return t}function j(e,t){return r.isRef(e.locale)&&t==="composition"}function H(e){return"global"in e&&"mode"in e}function U(e){return H(e)?j(e.global,e.mode)?e.global.locale.value:e.global.locale:e.locale.value}function W(e,t){H(e)?j(e.global,e.mode)?e.global.locale.value=t:e.global.locale=t:r.isRef(e.locale)&&(e.locale.value=t)}function Ie(e,t,a){return e.replace(/\/+$/,"")+(t?"/":"")||(a?"":"/")}function Q(e){return _.isVueRouter4,r.isRef(e)?e.value:e}function Y(e){return P(e)?e:Le(e)?e.toString():"(null)"}function J(e,t,{defaultLocale:a,strategy:l,routesNameSeparator:o,defaultLocaleRouteNameSuffix:n}){let c=Y(e)+(l==="no_prefix"?"":o+t);return t===a&&l==="prefix_and_default"&&(c+=o+n),c}function Te(e,t){return _e(e)?e(t):e}const O={PREFIX:"prefix",PREFIX_EXCEPT_DEFAULT:"prefix_except_default",PREFIX_AND_DEFAULT:"prefix_and_default",NO_PREFIX:"no_prefix"},v="",w=O.PREFIX_EXCEPT_DEFAULT,K=!1,b="___",M="default",Fe="ltr",Z="",Pe=new Set([O.PREFIX_AND_DEFAULT,O.PREFIX_EXCEPT_DEFAULT]);function C(e=_.useRoute(),{router:t=_.useRouter(),routesNameSeparator:a=b}={}){const l=a||t.__routesNameSeparator,o=r.unref(e);return o.name?Y(o.name).split(l)[0]:null}function ee(e,t,a){const l=V(e,t,a);return l==null?"":r.isVue3?l.redirectedFrom||l.fullPath:l.route.redirectedFrom||l.route.fullPath}function te(e,t,a){const l=V(e,t,a);return l==null?void 0:r.isVue3?l:l.route}function Ne(e,t,a){const l=V(e,t,a);return l==null?void 0:r.isVue3?l:l.location}function V(e,t,{router:a=_.useRouter(),i18n:l=p.useI18n(),defaultLocale:o=v,defaultLocaleRouteNameSuffix:n=M,routesNameSeparator:c=b,strategy:h=w,trailingSlash:d=!1}={}){const s=a.__defaultLocaleRouteNameSuffix||n,L=a.__defaultLocale||o,f=a.__routesNameSeparator||c,R=a.__strategy||h,m=t||U(l);let E=e;P(e)&&(E[0]==="/"?E={path:e}:E={name:e});let g=G({},E);if(g.path&&!g.name){const i=a.resolve(g),S=r.isVue3?i:i.route,F=C(S);P(F)?g={name:J(F,m,{defaultLocale:L,strategy:R,routesNameSeparator:f,defaultLocaleRouteNameSuffix:s}),params:S.params,query:S.query,hash:S.hash}:(!(m===o&&Pe.has(R))&&R!==O.NO_PREFIX&&(g.path=`/${m}${g.path}`),g.path=d?Se(g.path,!0):Ee(g.path,!0))}else{g.name=J(g.name,m,{defaultLocale:L,strategy:R,routesNameSeparator:f,defaultLocaleRouteNameSuffix:s});const{params:i}=g;i&&i["0"]===void 0&&i.pathMatch&&(i["0"]=i.pathMatch)}const T=a.resolve(g);return(r.isVue3?T.name:T.route.name)?T:a.resolve(e)}function z(e,t){const a=t&&t.route||_.useRoute(),l=C(a,t);if(!l)return"";const s=!r.isVue3&&r.isRef(a)?a.value:a,{params:o}=s,n=fe(s,["params"]),c={},h=G({},n,{name:l,params:X(y(y({},o),c),{0:o.pathMatch})});return ee(h,e,t)}function ye({addDirAttribute:e=!1,addSeoAttributes:t=!1,strategy:a=w,defaultLocale:l=v,route:o=_.useRoute(),router:n=_.useRouter(),i18n:c=p.useI18n()}={}){const h=l||n.__defaultLocale,d=a||n.__strategy,s=r.ref({htmlAttrs:{},link:[],meta:[]});function L(){s.value={htmlAttrs:{},link:[],meta:[]}}function f(R){if(c.locales==null||c.__baseUrl==null)return;const m=U(c),E=B(c.locales.value).find(i=>i.code===m)||{code:m},g=E.iso,T=E.dir||n.__defaultDirection;if(e&&(s.value.htmlAttrs.dir=T),t&&m&&c.locales){g&&(s.value.htmlAttrs.lang=g);const i=c.locales.value;$e(i,c.__baseUrl,s.value.link,{defaultLocale:h,strategy:d,route:o,router:n,i18n:c}),Oe(c.__baseUrl,s.value.link,t,{route:R,router:n,i18n:c}),Ue(E,g,s.value.meta),ve(i,g,s.value.meta)}}return pe?r.watchEffect(()=>{L(),f(Q(n.currentRoute))}):f(Q(n.currentRoute)),s}function $e(e,t,a,l){if(l.strategy===O.NO_PREFIX)return;const o=new Map;for(const n of e){const c=n.iso;if(!c){Ae("Locale ISO code is required to generate alternate link");continue}const[h,d]=c.split("-");h&&d&&(n.isCatchallLocale||!o.has(h))&&o.set(h,n),o.set(c,n)}for(const[n,c]of o.entries()){const h=z(c.code,l);h&&a.push({hid:`i18n-alt-${n}`,rel:"alternate",href:k(h,t),hreflang:n})}if(l.defaultLocale){const n=z(l.defaultLocale,l);n&&a.push({hid:"i18n-xd",rel:"alternate",href:k(n,t),hreflang:"x-default"})}}function Oe(e,t,a,l){const{route:o}=l,n=te(X(y({},o),{name:C(o,l)}),void 0,l);if(n){let c=k(n.path,e);const h=!ge(a)&&a.canonicalQueries||[];if(h.length){const d=n.query,s=new URLSearchParams;for(const f of h)if(f in d){const R=d[f];he(R)?R.forEach(m=>s.append(f,m||"")):s.append(f,R||"")}const L=s.toString();L&&(c=`${c}?${L}`)}t.push({hid:"i18n-can",rel:"canonical",href:c})}}function Ue(e,t,a){!(e&&t)||a.push({hid:"i18n-og",property:"og:locale",content:ae(t)})}function ve(e,t,a){const l=e.filter(o=>{const n=o.iso;return n&&n!==t});if(l.length){const o=l.map(n=>({hid:`i18n-og-alt-${n.iso}`,property:"og:locale:alternate",content:ae(n.iso)}));a.push(...o)}}function ae(e){return(e||"").replace(/-/g,"_")}function k(e,t){return e.match(/^https?:\/\//)?e:t+e}function le(e,{defaultLocale:t=v,strategy:a=w,trailingSlash:l=K,routesNameSeparator:o=b,defaultLocaleRouteNameSuffix:n=M,includeUprefixedFallback:c=!1,optionsResolver:h=void 0,locales:d=[]}={}){if(a==="no_prefix")return e;const s=d.map(f=>P(f)?f:f.code);function L(f,R,m=!1,E=!1){if(f.redirect&&(!f.component||!f.file))return[f];let g=null;return h!=null&&(g=h(f,R),g==null)?[f]:R.reduce((i,S)=>{const{name:F}=f;let{path:A}=f;const I=y({},f);F&&(I.name=`${F}${o}${S}`),f.children&&(I.children=f.children.reduce((N,q)=>[...N,...L(q,[S],!0,E)],[]));const $=S===t;if($&&a==="prefix_and_default")if(m)m&&E&&F&&(I.name+=`${o}${n}`);else{const N=X(y({},I),{path:A});if(F&&(N.name=`${I.name}${o}${n}`),f.children){N.children=[];for(const q of f.children)N.children=N.children.concat(L(q,[S],!0,!0))}i.push(N)}const oe=m&&!A.startsWith("/"),ce=!oe&&!($&&a==="prefix_except_default");return ce&&(A=`/${S}${A}`),A&&(A=Ie(A,l,oe)),ce&&$&&a==="prefix"&&c&&i.push(y({},f)),I.path=A,i.push(I),i},[])}return e.reduce((f,R)=>[...f,...L(R,s||[])],[])}function we(e,{locales:t=[],localeCodes:a=[],baseUrl:l=Z}={}){if(!j(e.global,e.mode))throw new Error("TODO:");const o=r.ref(t),n=r.ref(a);e.global.locales=r.computed(()=>o.value),e.global.localeCodes=r.computed(()=>n.value),e.global.__baseUrl=Te(l,{})}function be(e){return new RegExp(`^/(${e.join("|")})(?:/|$)`,"i")}function ne(e,t,a){const l=`(${e.join("|")})`,o=`(?:${t}${a})?`,n=new RegExp(`${t}${l}${o}$`,"i"),c=be(e);return d=>{if(Re(d)){if(d.name){const L=(P(d.name)?d.name:d.name.toString()).match(n);if(L&&L.length>1)return L[1]}else if(d.path){const s=d.path.match(c);if(s&&s.length>1)return s[1]}}else if(P(d)){const s=d.match(c);if(s&&s.length>1)return s[1]}return""}}function Ce(e){var t,a,l,o,n,c,h,d,s,L;return e.version=(t=e.version)!=null?t:4,e.defaultLocale=(a=e.defaultLocale)!=null?a:v,e.strategy=(l=e.strategy)!=null?l:w,e.trailingSlash=(o=e.trailingSlash)!=null?o:K,e.routesNameSeparator=(n=e.routesNameSeparator)!=null?n:b,e.defaultLocaleRouteNameSuffix=(c=e.defaultLocaleRouteNameSuffix)!=null?c:M,e.locales=(h=e.locales)!=null?h:[],e.defaultDirection=(d=e.defaultDirection)!=null?d:Fe,e.baseUrl=(s=e.baseUrl)!=null?s:Z,e.routes=(L=e.routes)!=null?L:[],e}function xe(e,t={}){const{version:a,defaultLocale:l,locales:o,strategy:n,trailingSlash:c,routesNameSeparator:h,defaultLocaleRouteNameSuffix:d,defaultDirection:s,baseUrl:L,routes:f,routeOptionsResolver:R}=Ce(t),m=B(o),E=m.map(S=>S.code),g=ne(E,h,d);we(e,{locales:m,baseUrl:L,localeCodes:E});const T=le(f,{locales:o,defaultLocale:l,strategy:n,trailingSlash:c,routesNameSeparator:h,defaultLocaleRouteNameSuffix:d,optionsResolver:R});t.routes=T;let i=null;if(r.isVue3&&a===4)i=_.createRouter(t);else if(r.isVue2&&a===3)i=new de.default(t);else throw new Error("TODO:");return i.__defaultLocale=l,i.__localeCodes=E,i.__strategy=n,i.__trailingSlash=c,i.__routesNameSeparator=h,i.__defaultLocaleRouteNameSuffix=d,i.__defaultDirection=s,i.beforeEach((S,F,A)=>{const I=U(e),$=g(S)||I||l||"";I!==$&&W(e,$),A()}),i}const Xe="0.0.0";return u.VERSION=Xe,u.createLocaleFromRouteGetter=ne,u.createRouter=xe,u.getLocale=U,u.getRouteBaseName=C,u.localeLocation=Ne,u.localePath=ee,u.localeRoute=te,u.localizeRoutes=le,u.setLocale=W,u.switchLocalePath=z,u.useI18nHead=ye,Object.defineProperty(u,"__esModule",{value:!0}),u[Symbol.toStringTag]="Module",u}({},VueDemi,VueRouter,VueI18n); |
{ | ||
"name": "vue-i18n-routing", | ||
"description": "The i18n routing with using vue-i18n", | ||
"version": "0.0.0-8fbb24d", | ||
"version": "0.0.0-90c658c", | ||
"dependencies": { | ||
@@ -6,0 +6,0 @@ "@intlify/shared": "beta", |
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
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
59921
1060