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