@atoms-studio/composables
Advanced tools
Comparing version 0.0.0-bcf42fb to 0.0.0-f0a5e37
@@ -17,33 +17,3 @@ var __defProp = Object.defineProperty; | ||
}; | ||
import { computed, inject } from "vue"; | ||
const useURL = (to, base) => { | ||
if (!base) { | ||
throw new Error("Base is required"); | ||
} | ||
const isDummy = computed(() => to.value === "#"); | ||
const url = computed(() => { | ||
if (typeof to.value === "string") { | ||
return new URL(to.value, base); | ||
} | ||
return null; | ||
}); | ||
const origin = computed(() => { | ||
var _a; | ||
return ((_a = url.value) == null ? void 0 : _a.origin) || ""; | ||
}); | ||
const path = computed(() => { | ||
var _a; | ||
return isDummy.value ? "#" : ((_a = url.value) == null ? void 0 : _a.pathname) || ""; | ||
}); | ||
const isExternal = computed(() => { | ||
return isDummy.value || url.value !== null && origin.value !== base; | ||
}); | ||
return { | ||
url, | ||
origin, | ||
path, | ||
isExternal, | ||
isDummy | ||
}; | ||
}; | ||
import { inject, computed } from "vue"; | ||
/*! | ||
@@ -121,2 +91,32 @@ * vue-router v4.0.15 | ||
}; | ||
const useURL = (to, base) => { | ||
if (!base) { | ||
throw new Error("Base is required"); | ||
} | ||
const isDummy = computed(() => to.value === "#"); | ||
const url = computed(() => { | ||
if (typeof to.value === "string") { | ||
return new URL(to.value, base); | ||
} | ||
return null; | ||
}); | ||
const origin = computed(() => { | ||
var _a; | ||
return ((_a = url.value) == null ? void 0 : _a.origin) || ""; | ||
}); | ||
const path = computed(() => { | ||
var _a; | ||
return isDummy.value ? "#" : ((_a = url.value) == null ? void 0 : _a.pathname) || ""; | ||
}); | ||
const isExternal = computed(() => { | ||
return isDummy.value || url.value !== null && origin.value !== base; | ||
}); | ||
return { | ||
url, | ||
origin, | ||
path, | ||
isExternal, | ||
isDummy | ||
}; | ||
}; | ||
const getFileExtension = (url) => { | ||
@@ -155,3 +155,4 @@ var _a, _b, _c; | ||
const isCtfAsset = (url) => url && url.includes("ctfassets"); | ||
const usePicture = (image, format, legacyFormat, mode, quality, sizesProp, screensProp) => { | ||
const isDatoAsset = (url) => url && url.includes("datocms-assets"); | ||
const usePicture = (image, format, legacyFormat, mode, quality, sizesProp, screensProp, datoFocalPoint, datoAutoFormat) => { | ||
const imageUrl = computed(() => { | ||
@@ -223,2 +224,10 @@ return "url" in image ? image.url : "file" in image ? image.file.url : ""; | ||
} | ||
if (isDatoAsset(url)) { | ||
resizeParams = "?"; | ||
resizeParams += `crop=focalpoint&fit=crop&fp-x=${datoFocalPoint.x}&fp-y=${datoFocalPoint.y}&`; | ||
resizeParams += `w=${breakPoint}&`; | ||
resizeParams += height ? `h=${height}&` : ""; | ||
resizeParams += datoAutoFormat ? "auto=format&" : ""; | ||
resizeParams += `q=${quality}&fm=${format2 && format2 === "jpeg" ? "jpg" : format2}`; | ||
} | ||
return `${url}${resizeParams}`; | ||
@@ -225,0 +234,0 @@ }; |
@@ -1,5 +0,5 @@ | ||
(function(o,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(o=typeof globalThis!="undefined"?globalThis:o||self,e(o.MyLib={},o.Vue))})(this,function(o,e){"use strict";var N=Object.defineProperty;var D=Object.getOwnPropertySymbols;var tt=Object.prototype.hasOwnProperty,et=Object.prototype.propertyIsEnumerable;var V=(o,e,a)=>e in o?N(o,e,{enumerable:!0,configurable:!0,writable:!0,value:a}):o[e]=a,W=(o,e)=>{for(var a in e||(e={}))tt.call(e,a)&&V(o,a,e[a]);if(D)for(var a of D(e))et.call(e,a)&&V(o,a,e[a]);return o};const a=(t,s)=>{if(!s)throw new Error("Base is required");const n=e.computed(()=>t.value==="#"),r=e.computed(()=>typeof t.value=="string"?new URL(t.value,s):null),c=e.computed(()=>{var p;return((p=r.value)==null?void 0:p.origin)||""}),d=e.computed(()=>{var p;return n.value?"#":((p=r.value)==null?void 0:p.pathname)||""}),g=e.computed(()=>n.value||r.value!==null&&c.value!==s);return{url:r,origin:c,path:d,isExternal:g,isDummy:n}};/*! | ||
(function(r,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(r=typeof globalThis!="undefined"?globalThis:r||self,e(r.MyLib={},r.Vue))})(this,function(r,e){"use strict";var nt=Object.defineProperty;var V=Object.getOwnPropertySymbols;var st=Object.prototype.hasOwnProperty,ot=Object.prototype.propertyIsEnumerable;var E=(r,e,a)=>e in r?nt(r,e,{enumerable:!0,configurable:!0,writable:!0,value:a}):r[e]=a,W=(r,e)=>{for(var a in e||(e={}))st.call(e,a)&&E(r,a,e[a]);if(V)for(var a of V(e))ot.call(e,a)&&E(r,a,e[a]);return r};/*! | ||
* vue-router v4.0.15 | ||
* (c) 2022 Eduardo San Martin Morote | ||
* @license MIT | ||
*/const A=typeof Symbol=="function"&&typeof Symbol.toStringTag=="symbol",P=t=>A?Symbol(t):"_vr_"+t,E=P("r"),K=P("rl");var _;(function(t){t.pop="pop",t.push="push"})(_||(_={}));var k;(function(t){t.back="back",t.forward="forward",t.unknown=""})(k||(k={}));var I;(function(t){t[t.aborted=4]="aborted",t[t.cancelled=8]="cancelled",t[t.duplicated=16]="duplicated"})(I||(I={}));function C(){return e.inject(E)}function F(){return e.inject(K)}const H=(t,s="replace")=>{const n=F(),r=C();let c;Array.isArray(t)?c=t.reduce((m,y)=>(m[y]={get:l=>l,set:l=>l},m),{}):c=t;const d=Object.keys(c),g=e.computed(()=>{const m={};for(const y of d){const l=n.query[y],b=c[y].get(l);m[y]=b}return m});return{state:g,updateState:m=>{const y=W(W({},g.value),m),l={};for(const b of d){const $=y[b],x=c[b].set($);l[b]=x}return r[s]({query:W(W({},n.query),l)})}}},B=t=>{var n,r,c;return(c=(r=(n=t.split(/[?#]/).shift())==null?void 0:n.split("/").pop())==null?void 0:r.split(".").pop())!=null?c:"jpg"},O=(t,s=0,n=0)=>{if(s>t||n>t){const r=s/n;Math.max(s,n)===s?(s=t,n=Math.round(s/r)):(n=t,s=Math.round(n*r))}return{width:s,height:n}},U=(t="")=>{if(typeof t=="number")return t;if(typeof t=="string"&&t.replace("px","").match(/^\d+$/g))return parseInt(t,10)},Q=t=>t&&t.includes("ctfassets"),T=(t,s,n,r,c,d,g)=>{const p=e.computed(()=>"url"in t?t.url:"file"in t?t.file.url:""),m=e.computed(()=>"width"in t?t.width:t&&"file"in t?t.file.details.image.width:0),y=e.computed(()=>t&&"height"in t?t.height:t&&"file"in t?t.file.details.image.height:0),l=e.computed(()=>B(p.value)),b=e.computed(()=>["png","webp","gif"].includes(l.value)),$=e.computed(()=>s||(l.value==="svg"?"svg":"webp")),x=e.computed(()=>n||{webp:b.value?"png":"jpeg",svg:"png"}[$.value]||l.value),z=e.computed(()=>O(4e3,m.value,y.value)),Y=e.computed(()=>$.value==="svg"?[{srcset:p.value}]:(x.value!==$.value?[x.value,$.value]:[$.value]).map(h=>{const{srcset:v,sizes:u,src:j}=J(h);return{src:j,type:`image/${h}`,sizes:u,srcset:v}})),G=(q,w,h="jpg",v)=>{let u="";return Q(w)&&(u="?",u+=`w=${q}&`,u+=v?`h=${v}&`:"",u+=r?`fit=${r}&`:"",u+=`q=${c}&fm=${h&&h==="jpeg"?"jpg":h}`),`${w}${u}`},J=q=>{const w=U(z.value.width),h=U(z.value.height),v=w&&h?h/w:0,u=[],j={};if(typeof d=="string")for(const i of d.split(/[\s,]+/).filter(f=>f)){const f=i.split(":");f.length===2&&(j[f[0].trim()]=f[1].trim())}else Object.assign(j,d);for(const i in j){const f=g&&g[i]||parseInt(i);let S=String(j[i]);const L=S.endsWith("vw");if(!L&&/^\d+$/.test(S)&&(S=S+"px"),!L&&!S.endsWith("px"))continue;let M=parseInt(S);if(!f||!M)continue;L&&(M=Math.round(M/100*f));const Z=v?Math.round(M*v):h;u.push({width:M,size:S,screenMaxWidth:f,media:`(max-width: ${f}px)`,src:`${G(M,p.value,q,Z)}`})}u.sort((i,f)=>i.screenMaxWidth-f.screenMaxWidth);const R=u[u.length-1];return R&&(R.media=""),{sizes:u.map(i=>`${i.media?i.media+" ":""}${i.size}`).join(", "),srcset:u.map(i=>`${i.src} ${i.width}w`).join(", "),src:R==null?void 0:R.src}};return{imageUrl:p,imageWidth:m,imageHeight:y,originalFormat:l,isTransparent:b,nFormat:$,nLegacyFormat:x,safeDimensions:z,nSources:Y}},X=(t,s,n,r)=>({focalPoint:e.computed(()=>{const d=t*100/n,g=s*100/r;return{"object-position":`${d}% ${g}%`}})});o.useFocalPoint=X,o.usePicture=T,o.useRouteState=H,o.useURL=a,Object.defineProperties(o,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}); | ||
*/const a=typeof Symbol=="function"&&typeof Symbol.toStringTag=="symbol",I=t=>a?Symbol(t):"_vr_"+t,K=I("r"),C=I("rl");var U;(function(t){t.pop="pop",t.push="push"})(U||(U={}));var k;(function(t){t.back="back",t.forward="forward",t.unknown=""})(k||(k={}));var A;(function(t){t[t.aborted=4]="aborted",t[t.cancelled=8]="cancelled",t[t.duplicated=16]="duplicated"})(A||(A={}));function H(){return e.inject(K)}function B(){return e.inject(C)}const F=(t,o="replace")=>{const n=B(),c=H();let u;Array.isArray(t)?u=t.reduce(($,f)=>($[f]={get:d=>d,set:d=>d},$),{}):u=t;const m=Object.keys(u),y=e.computed(()=>{const $={};for(const f of m){const d=n.query[f],b=u[f].get(d);$[f]=b}return $});return{state:y,updateState:$=>{const f=W(W({},y.value),$),d={};for(const b of m){const S=f[b],z=u[b].set(S);d[b]=z}return c[o]({query:W(W({},n.query),d)})}}},O=(t,o)=>{if(!o)throw new Error("Base is required");const n=e.computed(()=>t.value==="#"),c=e.computed(()=>typeof t.value=="string"?new URL(t.value,o):null),u=e.computed(()=>{var h;return((h=c.value)==null?void 0:h.origin)||""}),m=e.computed(()=>{var h;return n.value?"#":((h=c.value)==null?void 0:h.pathname)||""}),y=e.computed(()=>n.value||c.value!==null&&u.value!==o);return{url:c,origin:u,path:m,isExternal:y,isDummy:n}},Q=t=>{var n,c,u;return(u=(c=(n=t.split(/[?#]/).shift())==null?void 0:n.split("/").pop())==null?void 0:c.split(".").pop())!=null?u:"jpg"},T=(t,o=0,n=0)=>{if(o>t||n>t){const c=o/n;Math.max(o,n)===o?(o=t,n=Math.round(o/c)):(n=t,o=Math.round(n*c))}return{width:o,height:n}},P=(t="")=>{if(typeof t=="number")return t;if(typeof t=="string"&&t.replace("px","").match(/^\d+$/g))return parseInt(t,10)},X=t=>t&&t.includes("ctfassets"),Y=t=>t&&t.includes("datocms-assets"),G=(t,o,n,c,u,m,y,h,$)=>{const f=e.computed(()=>"url"in t?t.url:"file"in t?t.file.url:""),d=e.computed(()=>"width"in t?t.width:t&&"file"in t?t.file.details.image.width:0),b=e.computed(()=>t&&"height"in t?t.height:t&&"file"in t?t.file.details.image.height:0),S=e.computed(()=>Q(f.value)),z=e.computed(()=>["png","webp","gif"].includes(S.value)),j=e.computed(()=>o||(S.value==="svg"?"svg":"webp")),L=e.computed(()=>n||{webp:z.value?"png":"jpeg",svg:"png"}[j.value]||S.value),_=e.computed(()=>T(4e3,d.value,b.value)),Z=e.computed(()=>j.value==="svg"?[{srcset:f.value}]:(L.value!==j.value?[L.value,j.value]:[j.value]).map(l=>{const{srcset:g,sizes:s,src:M}=tt(l);return{src:M,type:`image/${l}`,sizes:s,srcset:g}})),N=(x,v,l="jpg",g)=>{let s="";return X(v)&&(s="?",s+=`w=${x}&`,s+=g?`h=${g}&`:"",s+=c?`fit=${c}&`:"",s+=`q=${u}&fm=${l&&l==="jpeg"?"jpg":l}`),Y(v)&&(s="?",s+=`crop=focalpoint&fit=crop&fp-x=${h.x}&fp-y=${h.y}&`,s+=`w=${x}&`,s+=g?`h=${g}&`:"",s+=$?"auto=format&":"",s+=`q=${u}&fm=${l&&l==="jpeg"?"jpg":l}`),`${v}${s}`},tt=x=>{const v=P(_.value.width),l=P(_.value.height),g=v&&l?l/v:0,s=[],M={};if(typeof m=="string")for(const i of m.split(/[\s,]+/).filter(p=>p)){const p=i.split(":");p.length===2&&(M[p[0].trim()]=p[1].trim())}else Object.assign(M,m);for(const i in M){const p=y&&y[i]||parseInt(i);let w=String(M[i]);const D=w.endsWith("vw");if(!D&&/^\d+$/.test(w)&&(w=w+"px"),!D&&!w.endsWith("px"))continue;let q=parseInt(w);if(!p||!q)continue;D&&(q=Math.round(q/100*p));const et=g?Math.round(q*g):l;s.push({width:q,size:w,screenMaxWidth:p,media:`(max-width: ${p}px)`,src:`${N(q,f.value,x,et)}`})}s.sort((i,p)=>i.screenMaxWidth-p.screenMaxWidth);const R=s[s.length-1];return R&&(R.media=""),{sizes:s.map(i=>`${i.media?i.media+" ":""}${i.size}`).join(", "),srcset:s.map(i=>`${i.src} ${i.width}w`).join(", "),src:R==null?void 0:R.src}};return{imageUrl:f,imageWidth:d,imageHeight:b,originalFormat:S,isTransparent:z,nFormat:j,nLegacyFormat:L,safeDimensions:_,nSources:Z}},J=(t,o,n,c)=>({focalPoint:e.computed(()=>{const m=t*100/n,y=o*100/c;return{"object-position":`${m}% ${y}%`}})});r.useFocalPoint=J,r.usePicture=G,r.useRouteState=F,r.useURL=O,Object.defineProperties(r,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}); |
@@ -0,4 +1,4 @@ | ||
export { useRouteState } from './useRouteState'; | ||
export { useURL } from './useURL'; | ||
export { useRouteState } from './useRouteState'; | ||
export { usePicture } from './usePicture'; | ||
export { useFocalPoint } from './useFocalPoint'; |
@@ -33,3 +33,7 @@ import type { ComputedRef } from 'vue'; | ||
} | ||
export declare const usePicture: (image: ImageUrlObject | ImageFileObject, format: string, legacyFormat: string, mode: string, quality: number, sizesProp: string, screensProp: Record<string, number>) => { | ||
export interface FocalPointObject { | ||
x: number; | ||
y: number; | ||
} | ||
export declare const usePicture: (image: ImageUrlObject | ImageFileObject, format: string, legacyFormat: string, mode: string, quality: number, sizesProp: string, screensProp: Record<string, number>, datoFocalPoint: FocalPointObject, datoAutoFormat: boolean) => { | ||
imageUrl: ComputedRef<string>; | ||
@@ -36,0 +40,0 @@ imageWidth: ComputedRef<number>; |
@@ -7,3 +7,3 @@ { | ||
}, | ||
"version": "0.0.0-bcf42fb", | ||
"version": "0.0.0-f0a5e37", | ||
"license": "MIT", | ||
@@ -42,5 +42,4 @@ "files": [ | ||
"dependencies": { | ||
"@atoms-studio/nuxt-components": "0.0.0-bcf42fb", | ||
"mkdirp": "^0.5.5" | ||
} | ||
} |
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
19573
2
415
0
- Removed@ampproject/remapping@2.3.0(transitive)
- Removed@atoms-studio/nuxt-components@0.0.0-bcf42fb(transitive)
- Removed@babel/code-frame@7.26.2(transitive)
- Removed@babel/compat-data@7.26.8(transitive)
- Removed@babel/core@7.26.8(transitive)
- Removed@babel/generator@7.26.8(transitive)
- Removed@babel/helper-compilation-targets@7.26.5(transitive)
- Removed@babel/helper-module-imports@7.25.9(transitive)
- Removed@babel/helper-module-transforms@7.26.0(transitive)
- Removed@babel/helper-validator-option@7.25.9(transitive)
- Removed@babel/helpers@7.26.7(transitive)
- Removed@babel/standalone@7.26.8(transitive)
- Removed@babel/template@7.26.8(transitive)
- Removed@babel/traverse@7.26.8(transitive)
- Removed@jridgewell/gen-mapping@0.3.8(transitive)
- Removed@jridgewell/resolve-uri@3.1.2(transitive)
- Removed@jridgewell/set-array@1.2.1(transitive)
- Removed@jridgewell/trace-mapping@0.3.25(transitive)
- Removed@nodelib/fs.scandir@2.1.5(transitive)
- Removed@nodelib/fs.stat@2.0.5(transitive)
- Removed@nodelib/fs.walk@1.2.8(transitive)
- Removed@nuxt/kit@3.15.4(transitive)
- Removed@nuxt/schema@3.15.4(transitive)
- Removed@sindresorhus/merge-streams@2.3.0(transitive)
- Removed@types/estree@1.0.6(transitive)
- Removed@types/gensync@1.0.4(transitive)
- Removedacorn@8.14.0(transitive)
- Removedbraces@3.0.3(transitive)
- Removedbrowserslist@4.24.4(transitive)
- Removedc12@2.0.1(transitive)
- Removedcaniuse-lite@1.0.30001699(transitive)
- Removedchokidar@4.0.3(transitive)
- Removedchownr@2.0.0(transitive)
- Removedcitty@0.1.6(transitive)
- Removedconfbox@0.1.8(transitive)
- Removedconsola@3.4.0(transitive)
- Removedconvert-source-map@2.0.0(transitive)
- Removeddebug@4.4.0(transitive)
- Removeddefu@6.1.4(transitive)
- Removeddestr@2.0.3(transitive)
- Removeddotenv@16.4.7(transitive)
- Removedelectron-to-chromium@1.5.96(transitive)
- Removedescalade@3.2.0(transitive)
- Removedescape-string-regexp@5.0.0(transitive)
- Removedestree-walker@3.0.3(transitive)
- Removedfast-glob@3.3.3(transitive)
- Removedfastq@1.19.0(transitive)
- Removedfill-range@7.1.1(transitive)
- Removedfs-minipass@2.1.0(transitive)
- Removedgensync@1.0.0-beta.2(transitive)
- Removedgiget@1.2.4(transitive)
- Removedglob-parent@5.1.2(transitive)
- Removedglobals@11.12.0(transitive)
- Removedglobby@14.1.0(transitive)
- Removedignore@7.0.3(transitive)
- Removedis-extglob@2.1.1(transitive)
- Removedis-glob@4.0.3(transitive)
- Removedis-number@7.0.0(transitive)
- Removedjiti@2.4.2(transitive)
- Removedjs-tokens@4.0.09.0.1(transitive)
- Removedjsesc@3.1.0(transitive)
- Removedjson5@2.2.3(transitive)
- Removedklona@2.0.6(transitive)
- Removedknitwork@1.2.0(transitive)
- Removedlocal-pkg@1.0.0(transitive)
- Removedlru-cache@5.1.1(transitive)
- Removedmerge2@1.4.1(transitive)
- Removedmicromatch@4.0.8(transitive)
- Removedminipass@3.3.65.0.0(transitive)
- Removedminizlib@2.1.2(transitive)
- Removedmkdirp@1.0.4(transitive)
- Removedmlly@1.7.4(transitive)
- Removedms@2.1.3(transitive)
- Removednode-fetch-native@1.6.6(transitive)
- Removednode-releases@2.0.19(transitive)
- Removednypm@0.5.2(transitive)
- Removedohash@1.1.4(transitive)
- Removedpath-type@6.0.0(transitive)
- Removedpathe@1.1.22.0.2(transitive)
- Removedperfect-debounce@1.0.0(transitive)
- Removedpicomatch@2.3.14.0.2(transitive)
- Removedpkg-types@1.3.1(transitive)
- Removedqueue-microtask@1.2.3(transitive)
- Removedrc9@2.1.2(transitive)
- Removedreaddirp@4.1.1(transitive)
- Removedreusify@1.0.4(transitive)
- Removedrun-parallel@1.2.0(transitive)
- Removedscule@1.3.0(transitive)
- Removedsemver@6.3.17.7.1(transitive)
- Removedslash@5.1.0(transitive)
- Removedstd-env@3.8.0(transitive)
- Removedstrip-literal@3.0.0(transitive)
- Removedtar@6.2.1(transitive)
- Removedtinyexec@0.3.2(transitive)
- Removedto-regex-range@5.0.1(transitive)
- Removedufo@1.5.4(transitive)
- Removedunctx@2.4.1(transitive)
- Removedunicorn-magic@0.3.0(transitive)
- Removedunimport@4.1.0(transitive)
- Removedunplugin@2.1.2(transitive)
- Removedunplugin-utils@0.2.3(transitive)
- Removeduntyped@1.5.2(transitive)
- Removedupdate-browserslist-db@1.1.2(transitive)
- Removedwebpack-virtual-modules@0.6.2(transitive)
- Removedyallist@3.1.14.0.0(transitive)