vue-i18n-routing
Advanced tools
Comparing version 0.0.0-6058846 to 0.0.0-0464d45
@@ -454,3 +454,3 @@ import type { Composer } from '@intlify/vue-i18n-bridge'; | ||
*/ | ||
export declare type RouteOptionsResolver = (route: I18nRoute, allowedLocaleCodes: string[]) => ComputedRouteOptions | null; | ||
export declare type RouteOptionsResolver = (route: I18nRoute, localeCodes: string[]) => ComputedRouteOptions | null; | ||
@@ -457,0 +457,0 @@ /** |
@@ -1,5 +0,5 @@ | ||
var VueI18nRouting=function(s,d,L,_){"use strict";var ht=Object.defineProperty,Lt=Object.defineProperties;var gt=Object.getOwnPropertyDescriptors;var Q=Object.getOwnPropertySymbols;var ye=Object.prototype.hasOwnProperty,Ce=Object.prototype.propertyIsEnumerable;var Pe=(s,d,L)=>d in s?ht(s,d,{enumerable:!0,configurable:!0,writable:!0,value:L}):s[d]=L,O=(s,d)=>{for(var L in d||(d={}))ye.call(d,L)&&Pe(s,L,d[L]);if(Q)for(var L of Q(d))Ce.call(d,L)&&Pe(s,L,d[L]);return s},Y=(s,d)=>Lt(s,gt(d));var Oe=(s,d)=>{var L={};for(var _ in s)ye.call(s,_)&&d.indexOf(_)<0&&(L[_]=s[_]);if(s!=null&&Q)for(var _ of Q(s))d.indexOf(_)<0&&Ce.call(s,_)&&(L[_]=s[_]);return L};function Ue(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var be=Ue(L);const U={PREFIX:"prefix",PREFIX_EXCEPT_DEFAULT:"prefix_except_default",PREFIX_AND_DEFAULT:"prefix_and_default",NO_PREFIX:"no_prefix"},G="",D=U.PREFIX_EXCEPT_DEFAULT,B=!1,X="___",M="default",J="ltr",K="";/*! | ||
* shared v9.2.0-beta.35 | ||
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 | ||
* (c) 2022 kazuya kawaguchi | ||
* Released under the MIT License. | ||
*/const Fe=typeof Symbol=="function"&&typeof Symbol.toStringTag=="symbol",Ne=e=>Fe?Symbol(e):e,se=Object.assign,we=Array.isArray,$e=e=>typeof e=="function",T=e=>typeof e=="string",ve=e=>typeof e=="boolean",Ve=e=>typeof e=="symbol",Z=e=>e!==null&&typeof e=="object",je=/\/$|\/\?/;function ee(e="",t=!1){return t?je.test(e):e.endsWith("/")}function Ge(e="",t=!1){if(!t)return(ee(e)?e.slice(0,-1):e)||"/";if(!ee(e,!0))return e||"/";const[o,...n]=e.split("?");return(o.slice(0,-1)||"/")+(n.length?`?${n.join("?")}`:"")}function De(e="",t=!1){if(!t)return e.endsWith("/")?e:e+"/";if(ee(e,!0))return e||"/";const[o,...n]=e.split("?");return o+"/"+(n.length?`?${n.join("?")}`:"")}const Be=typeof window!="undefined";function re(e,t){typeof console!="undefined"&&(console.warn("[vue-i18n-routing] "+e),t&&console.warn(t.stack))}function ie(e){e=e||[];const t=[];for(const o of e)T(o)?t.push({code:o}):t.push(o);return t}function w(e){return e!=null&&"global"in e&&"mode"in e}function $(e){return e!=null&&!("__composer"in e)&&d.isRef(e.locale)}function b(e){return e!=null&&"__composer"in e}function k(e){return e!=null&&!("__composer"in e)&&!d.isRef(e.locale)}function P(e){return e!=null&&("__VUE_I18N_BRIDGE__"in e||"_sync"in e)}function ue(e){return w(e)?$(e.global)?e.global:e.global.__composer:b(e)?e.__composer:e}function z(e){const t=w(e)?e.global:e;return $(t)?d.isVue2&&P(e)?e.locale:t.locale.value:(k(t)||b(t)||P(t),t.locale)}function Xe(e){const t=w(e)?e.global:e;return $(t)?d.isVue2&&P(e)?e.locales:t.locales.value:(k(t)||b(t)||P(t),t.locales)}function fe(e,t){const o=w(e)?e.global:e;if($(o))d.isVue2&&P(e)?e.locale=t:o.locale.value=t;else if(k(o)||b(o)||P(o))o.locale=t;else throw new Error("TODO:")}function Me(e,t,o){return e.replace(/\/+$/,"")+(t?"/":"")||(o?"":"/")}function de(e){return L.isVueRouter4,d.isRef(e)?e.value:e}function he(e){return T(e)?e:Ve(e)?e.toString():"(null)"}function Le(e,t,{defaultLocale:o,strategy:n,routesNameSeparator:l,defaultLocaleRouteNameSuffix:a}){let c=he(e)+(n==="no_prefix"?"":l+t);return t===o&&n==="prefix_and_default"&&(c+=l+a),c}function ge(e,t){return $e(e)?e(t):e}function ke(e,t){const o=[];for(const[n,l]of t.entries()){const a=e.find(c=>c.iso.toLowerCase()===l.toLowerCase());if(a){o.push({code:a.code,score:1-n/t.length});break}}for(const[n,l]of t.entries()){const a=l.split("-")[0].toLowerCase(),c=e.find(r=>r.iso.split("-")[0].toLowerCase()===a);if(c){o.push({code:c.code,score:.999-n/t.length});break}}return o}const ze=ke;function He(e,t){return e.score===t.score?t.code.length-e.code.length:t.score-e.score}const qe=He;function xe(e,t,{matcher:o=ze,comparer:n=qe}={}){const l=[];for(const c of e){const{code:r}=c,i=c.iso||r;l.push({code:r,iso:i})}const a=o(l,t);return a.length>1&&a.sort(n),a.length?a[0].code:""}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 _e(e,{locales:t=[],localeCodes:o=[],baseUrl:n=K,hooks:l={}}={}){const a=d.effectScope(),c=e.install;return e.install=(r,...i)=>{Reflect.apply(c,e,[r,...i]);const f=ue(e);a.run(()=>We(f,{locales:t,localeCodes:o,baseUrl:n,hooks:l})),b(e.global)&&Ye(e.global,l.onExtendVueI18n);const h=r,u=e.mode==="composition"?d.isVue3?h.config.globalProperties.$i18n:e:d.isVue2?e:null;if(u&&Qe(u,f,l.onExtendExportedGlobal),(Je(i[0])?i[0]:{inject:!0}).inject&&r.mixin({methods:{resolveRoute:I(v),localePath:I(q),localeRoute:I(x),localeLocation:I(oe),switchLocalePath:I(V),getRouteBaseName:I(F),localeHead:I(ne)}}),h.unmount){const g=h.unmount;h.unmount=()=>{a.stop(),g()}}},a}function We(e,t){const{locales:o,localeCodes:n,baseUrl:l}=t,a=d.ref(o),c=d.ref(n);e.locales=d.computed(()=>a.value),e.localeCodes=d.computed(()=>c.value),e.__baseUrl=ge(l,{}),t.hooks&&t.hooks.onExtendComposer&&t.hooks.onExtendComposer(e)}function Qe(e,t,o){const n=[{locales:{get(){return t.locales.value}},localeCodes:{get(){return t.localeCodes.value}},__baseUrl:{get(){return t.__baseUrl}}}];o&&n.push(o(t));for(const l of n)for(const[a,c]of Object.entries(l))Object.defineProperty(e,a,c)}function Ye(e,t){const o=ue(e),n=[{locales:{get(){return o.locales.value}},localeCodes:{get(){return o.localeCodes.value}},__baseUrl:{get(){return o.__baseUrl}}}];t&&n.push(t(o));for(const l of n)for(const[a,c]of Object.entries(l))Object.defineProperty(e,a,c)}function Je(e){return Z(e)&&"inject"in e&&ve(e.inject)}function me(e,{defaultLocale:t=G,strategy:o=D,trailingSlash:n=B,routesNameSeparator:l=X,defaultLocaleRouteNameSuffix:a=M,includeUprefixedFallback:c=!1,optionsResolver:r=void 0,locales:i=[]}={}){if(o==="no_prefix")return e;const f=i.map(u=>T(u)?u:u.code);function h(u,m,g=!1,R=!1){if(u.redirect&&(!u.component||!u.file))return[u];let y=null;return r!=null&&(y=r(u,m),y==null)?[u]:m.reduce((S,A)=>{const{name:j}=u;let{path:E}=u;const p=O({},u);j&&(p.name=`${j}${l}${A}`),u.children&&(p.children=u.children.reduce((C,ce)=>[...C,...h(ce,[A],!0,R)],[]));const N=A===t;if(N&&o==="prefix_and_default")if(g)g&&R&&j&&(p.name+=`${l}${a}`);else{const C=Y(O({},p),{path:E});if(j&&(C.name=`${p.name}${l}${a}`),u.children){C.children=[];for(const ce of u.children)C.children=C.children.concat(h(ce,[A],!0,!0))}S.push(C)}const Ie=g&&!E.startsWith("/"),Te=!Ie&&!(N&&o==="prefix_except_default");return Te&&(E=`/${A}${E}`),E&&(E=Me(E,n,Ie)),Te&&N&&o==="prefix"&&c&&S.push(O({},u)),p.path=E,S.push(p),S},[])}return e.reduce((u,m)=>[...u,...h(m,f||[])],[])}const te=Ne("vue-i18n-routing-gor");function Re(e,t){e[te]?re("already registered global options"):e[te]=t}function Ee(e){var t;return(t=e[te])!=null?t:{}}function Ke(e,t={}){const{version:o,defaultLocale:n,locales:l,strategy:a,trailingSlash:c,routesNameSeparator:r,defaultLocaleRouteNameSuffix:i,defaultDirection:f,baseUrl:h,routes:u,routeOptionsResolver:m}=et(t),g=ie(l),R=g.map(A=>A.code),y=Se(R,r,i);_e(e,{locales:g,baseUrl:h,localeCodes:R});const le=me(u,{locales:l,defaultLocale:n,strategy:a,trailingSlash:c,routesNameSeparator:r,defaultLocaleRouteNameSuffix:i,optionsResolver:m});t.routes=le;const S=Ze(t,o);return Re(S,{defaultLocale:n,localeCodes:R,strategy:a,trailingSlash:c,routesNameSeparator:r,defaultLocaleRouteNameSuffix:i,defaultDirection:f}),S.beforeEach((A,j,E)=>{const p=z(e),N=y(A)||p||n||"";p!==N&&fe(e,N),E()}),S}function Ze(e,t){if(d.isVue3&&t===4)return L.createRouter(e);if(d.isVue2&&t===3)return new be.default(e);throw new Error("TODO:")}function pe(e){return new RegExp(`^/(${e.join("|")})(?:/|$)`,"i")}function Se(e,t,o){const n=`(${e.join("|")})`,l=`(?:${t}${o})?`,a=new RegExp(`${t}${n}${l}$`,"i"),c=pe(e);return i=>{if(Z(i)){if(i.name){const h=(T(i.name)?i.name:i.name.toString()).match(a);if(h&&h.length>1)return h[1]}else if(i.path){const f=i.path.match(c);if(f&&f.length>1)return f[1]}}else if(T(i)){const f=i.match(c);if(f&&f.length>1)return f[1]}return""}}function et(e){var t,o,n,l,a,c,r,i,f,h;return e.version=(t=e.version)!=null?t:4,e.defaultLocale=(o=e.defaultLocale)!=null?o:G,e.strategy=(n=e.strategy)!=null?n:D,e.trailingSlash=(l=e.trailingSlash)!=null?l:B,e.routesNameSeparator=(a=e.routesNameSeparator)!=null?a:X,e.defaultLocaleRouteNameSuffix=(c=e.defaultLocaleRouteNameSuffix)!=null?c:M,e.locales=(r=e.locales)!=null?r:[],e.defaultDirection=(i=e.defaultDirection)!=null?i:J,e.baseUrl=(f=e.baseUrl)!=null?f:K,e.routes=(h=e.routes)!=null?h:[],e}function H(e,t,{defaultLocale:o=G,defaultDirection:n=J,defaultLocaleRouteNameSuffix:l=M,routesNameSeparator:a=X,strategy:c=D,trailingSlash:r=B,localeCodes:i=[]}={}){const f=Ee(e);return{defaultLocale:t.defaultLocale||f.defaultLocale||o,defaultDirection:t.defaultDirection||f.defaultDirection||n,defaultLocaleRouteNameSuffix:t.defaultLocaleRouteNameSuffix||f.defaultLocaleRouteNameSuffix||l,routesNameSeparator:t.routesNameSeparator||f.routesNameSeparator||a,strategy:t.strategy||f.strategy||c,trailingSlash:t.trailingSlash||f.trailingSlash||r,localeCodes:t.localeCodes||f.localeCodes||i}}const tt=new Set([U.PREFIX_AND_DEFAULT,U.PREFIX_EXCEPT_DEFAULT]);function F(e){const t=this.router,{routesNameSeparator:o}=H(t,this),n=e!=null?d.isRef(e)?d.unref(e):e:this.route;return n.name?he(n.name).split(o)[0]:void 0}function q(e,t){const o=v.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=v.call(this,e,t);return o==null?void 0:d.isVue3?o:o.route}function oe(e,t){const o=v.call(this,e,t);return o==null?void 0:d.isVue3?o:o.location}function v(e,t){const o=this.router,n=this.i18n,l=t||z(n),{routesNameSeparator:a,defaultLocale:c,defaultLocaleRouteNameSuffix:r,strategy:i,trailingSlash:f}=H(o,this);let h=e;T(e)&&(h[0]==="/"?h={path:e}:h={name:e});let u=se({},h);if(u.path&&!u.name){const g=o.resolve(u),R=d.isVue3?g:g.route,y=F.call(this,R);T(y)?u={name:Le(y,l,{defaultLocale:c,strategy:i,routesNameSeparator:a,defaultLocaleRouteNameSuffix:r}),params:R.params,query:R.query,hash:R.hash}:(!(l===c&&tt.has(i))&&i!==U.NO_PREFIX&&(u.path=`/${l}${u.path}`),u.path=f?De(u.path,!0):Ge(u.path,!0))}else{u.name=Le(u.name,l,{defaultLocale:c,strategy:i,routesNameSeparator:a,defaultLocaleRouteNameSuffix:r});const{params:g}=u;g&&g["0"]===void 0&&g.pathMatch&&(g["0"]=g.pathMatch)}const m=o.resolve(u);return(d.isVue3?m.name:m.route.name)?m:o.resolve(e)}function V(e){const t=this.route,o=F.call(this,t);if(!o)return"";const i=!d.isVue3&&d.isRef(t)?t.value:t,{params:n}=i,l=Oe(i,["params"]),a={},c=se({},l,{name:o,params:Y(O(O({},n),a),{0:n.pathMatch})});return q.call(this,c,e)}function ne({addDirAttribute:e=!1,addSeoAttributes:t=!1}={}){const o=this.router,n=this.i18n,{defaultDirection:l}=H(o,this),a={htmlAttrs:{},link:[],meta:[]};if(n.locales==null||n.__baseUrl==null)return a;const c=z(n),r=Xe(n),i=ie(r).find(u=>u.code===c)||{code:c},f=i.iso,h=i.dir||l;return e&&(a.htmlAttrs.dir=h),t&&c&&n.locales&&(f&&(a.htmlAttrs.lang=f),ot.call(this,r,n.__baseUrl,a.link),nt.call(this,n.__baseUrl,a.link,t),at(i,f,a.meta),lt(r,f,a.meta)),a}function ot(e,t,o){const n=this.router,{defaultLocale:l,strategy:a}=H(n,this);if(a===U.NO_PREFIX)return;const c=new Map;for(const r of e){const i=r.iso;if(!i){re("Locale ISO code is required to generate alternate link");continue}const[f,h]=i.split("-");f&&h&&(r.isCatchallLocale||!c.has(f))&&c.set(f,r),c.set(i,r)}for(const[r,i]of c.entries()){const f=V.call(this,i.code);f&&o.push({hid:`i18n-alt-${r}`,rel:"alternate",href:ae(f,t),hreflang:r})}if(l){const r=V.call(this,l);r&&o.push({hid:"i18n-xd",rel:"alternate",href:ae(r,t),hreflang:"x-default"})}}function nt(e,t,o){const n=this.route,l=x.call(this,Y(O({},n),{name:F.call(this,n)}));if(l){let a=ae(l.path,e);const c=Z(o)&&o.canonicalQueries||[];if(c.length){const r=l.query,i=new URLSearchParams;for(const h of c)if(h in r){const u=r[h];we(u)?u.forEach(m=>i.append(h,m||"")):i.append(h,u||"")}const f=i.toString();f&&(a=`${a}?${f}`)}t.push({hid:"i18n-can",rel:"canonical",href:a})}}function at(e,t,o){!(e&&t)||o.push({hid:"i18n-og",property:"og:locale",content:Ae(t)})}function lt(e,t,o){const n=e.filter(l=>{const a=l.iso;return a&&a!==t});if(n.length){const l=n.map(a=>({hid:`i18n-og-alt-${a.iso}`,property:"og:locale:alternate",content:Ae(a.iso)}));o.push(...l)}}function Ae(e){return(e||"").replace(/-/g,"_")}function ae(e,t){return e.match(/^https?:\/\//)?e:t+e}function W(e,t){const{router:o,route:n,i18n:l,defaultLocale:a,strategy:c,defaultLocaleRouteNameSuffix:r,trailingSlash:i,routesNameSeparator:f}=e;return function(...h){return Reflect.apply(t,{router:o,route:n,i18n:l,defaultLocale:a,strategy:c,defaultLocaleRouteNameSuffix:r,trailingSlash:i,routesNameSeparator:f},h)}}function ct(e=L.useRoute(),{router:t=L.useRouter(),routesNameSeparator:o=void 0}={}){const n={router:t,route:e,routesNameSeparator:o};return F.call(n,e)}function st({router:e=L.useRouter(),route:t=L.useRoute(),i18n:o=_.useI18n(),defaultLocale:n=void 0,defaultLocaleRouteNameSuffix:l=void 0,routesNameSeparator:a=void 0,strategy:c=void 0,trailingSlash:r=void 0}={}){return W({router:e,route:t,i18n:o,defaultLocale:n,defaultLocaleRouteNameSuffix:l,routesNameSeparator:a,strategy:c,trailingSlash:r},q)}function rt({router:e=L.useRouter(),route:t=L.useRoute(),i18n:o=_.useI18n(),defaultLocale:n=void 0,defaultLocaleRouteNameSuffix:l=void 0,routesNameSeparator:a=void 0,strategy:c=void 0,trailingSlash:r=void 0}={}){return W({router:e,route:t,i18n:o,defaultLocale:n,defaultLocaleRouteNameSuffix:l,routesNameSeparator:a,strategy:c,trailingSlash:r},x)}function it({router:e=L.useRouter(),route:t=L.useRoute(),i18n:o=_.useI18n(),defaultLocale:n=void 0,defaultLocaleRouteNameSuffix:l=void 0,routesNameSeparator:a=void 0,strategy:c=void 0,trailingSlash:r=void 0}={}){return W({router:e,route:t,i18n:o,defaultLocale:n,defaultLocaleRouteNameSuffix:l,routesNameSeparator:a,strategy:c,trailingSlash:r},oe)}function ut({router:e=L.useRouter(),route:t=L.useRoute(),i18n:o=_.useI18n(),defaultLocale:n=void 0,defaultLocaleRouteNameSuffix:l=void 0,routesNameSeparator:a=void 0,strategy:c=void 0,trailingSlash:r=void 0}={}){return W({router:e,route:t,i18n:o,defaultLocale:n,defaultLocaleRouteNameSuffix:l,routesNameSeparator:a,strategy:c,trailingSlash:r},V)}function ft({addDirAttribute:e=!1,addSeoAttributes:t=!1,strategy:o=void 0,defaultLocale:n=void 0,route:l=L.useRoute(),router:a=L.useRouter(),i18n:c=_.useI18n()}={}){const r=a,i=d.ref({htmlAttrs:{},link:[],meta:[]});function f(){i.value={htmlAttrs:{},link:[],meta:[]}}function h(u){i.value=Reflect.apply(ne,{router:a,route:u,i18n:c,defaultLocale:n,strategy:o},[{addDirAttribute:e,addSeoAttributes:t}])}if(Be)if(d.isVue3){const u=d.watchEffect(()=>{f(),h(de(r.currentRoute))});d.onUnmounted(()=>u())}else{const u=r.afterEach((m,g)=>{f(),h(m)});d.onUnmounted(()=>u()),h(l)}else h(de(r.currentRoute));return i}const dt="0.0.0";return s.DEFAULT_BASE_URL=K,s.DEFAULT_DETECTION_DIRECTION=J,s.DEFAULT_LOCALE=G,s.DEFAULT_LOCALE_ROUTE_NAME_SUFFIX=M,s.DEFAULT_ROUTES_NAME_SEPARATOR=X,s.DEFAULT_STRATEGY=D,s.DEFAULT_TRAILING_SLASH=B,s.STRATEGIES=U,s.VERSION=dt,s.createLocaleFromRouteGetter=Se,s.createRouter=Ke,s.extendI18n=_e,s.findBrowserLocale=xe,s.getGlobalOptions=Ee,s.getLocale=z,s.getLocalesRegex=pe,s.getRouteBaseName=F,s.isComposer=$,s.isExportedGlobalComposer=k,s.isI18nInstance=w,s.isLegacyVueI18n=P,s.isVueI18n=b,s.localeHead=ne,s.localeLocation=oe,s.localePath=q,s.localeRoute=x,s.localizeRoutes=me,s.proxyVueInstance=I,s.registerGlobalOptions=Re,s.resolveBaseUrl=ge,s.resolveRoute=v,s.setLocale=fe,s.switchLocalePath=V,s.useLocaleHead=ft,s.useLocaleLocation=it,s.useLocalePath=st,s.useLocaleRoute=rt,s.useRouteBaseName=ct,s.useSwitchLocalePath=ut,Object.defineProperties(s,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),s}({},VueDemi,VueRouter,VueI18n); | ||
*/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); |
{ | ||
"name": "vue-i18n-routing", | ||
"description": "The i18n routing with using vue-i18n", | ||
"version": "0.0.0-6058846", | ||
"version": "0.0.0-0464d45", | ||
"dependencies": { | ||
@@ -13,11 +13,10 @@ "@intlify/shared": "next", | ||
"devDependencies": { | ||
"@microsoft/api-extractor": "^7.18.20", | ||
"@vue/test-utils": "^1.3.0", | ||
"@microsoft/api-extractor": "^7.28.4", | ||
"api-docs-gen": "^0.4.0", | ||
"rimraf": "^3.0.2", | ||
"typescript": "^4.6.3", | ||
"vite": "^2.9.8", | ||
"typescript": "^4.7.4", | ||
"vite": "^3.0.0", | ||
"vite-plugin-dts": "^0.9.6", | ||
"vitest": "^0.2.8", | ||
"vue": "^3.2.23", | ||
"vitest": "^0.18.0", | ||
"vue": "^3.2.27", | ||
"vue-i18n": "npm:vue-i18n@next", | ||
@@ -34,4 +33,4 @@ "vue-i18n-bridge": "next", | ||
"vue": "^2.6.14 || ^3.2.0", | ||
"vue-i18n": "^8.26.1 || ^9.2.0-beta.35", | ||
"vue-i18n-bridge": "^9.2.0-beta.35", | ||
"vue-i18n": "^8.26.1 || ^9.2.0-beta.37", | ||
"vue-i18n-bridge": "^9.2.0-beta.37", | ||
"vue-router": "^3.5.3 || ^4.0.0" | ||
@@ -42,2 +41,14 @@ }, | ||
"optional": true | ||
}, | ||
"vue": { | ||
"optional": true | ||
}, | ||
"vue-i18n": { | ||
"optional": true | ||
}, | ||
"vue-i18n-bridge": { | ||
"optional": true | ||
}, | ||
"vue-router": { | ||
"optional": true | ||
} | ||
@@ -58,4 +69,4 @@ }, | ||
], | ||
"main": "./dist/vue-i18n-routing.cjs.js", | ||
"module": "./dist/vue-i18n-routing.es.js", | ||
"main": "./dist/vue-i18n-routing.js", | ||
"module": "./dist/vue-i18n-routing.mjs", | ||
"unpkg": "dist/vue-i18n-routing.iife.js", | ||
@@ -68,5 +79,5 @@ "jsdelivr": "dist/vue-i18n-routing.iife.js", | ||
"node": "./index.mjs", | ||
"default": "./dist/vue-i18n-routing.es.js" | ||
"default": "./dist/vue-i18n-routing.mjs" | ||
}, | ||
"require": "./dist/vue-i18n-routing.cjs.js", | ||
"require": "./dist/vue-i18n-routing.js", | ||
"types": "./dist/vue-i18n-routing.d.ts" | ||
@@ -73,0 +84,0 @@ }, |
export * from './dist/vue-i18n-routing' | ||
import './dist/vue-i18n-routing.vue' | ||
import './dist/vue-i18n-routing.vue-i18n' | ||
import './dist/vue' | ||
import './dist/vue-i18n' |
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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
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
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
15
83125
1542
2