New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@atoms-studio/composables

Package Overview
Dependencies
Maintainers
6
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@atoms-studio/composables - npm Package Compare versions

Comparing version 0.0.0-2e73034 to 0.0.0-3cf276b

dist/useFocalPoint.d.ts

182

dist/composables.es.js

@@ -49,3 +49,3 @@ var __defProp = Object.defineProperty;

/*!
* vue-router v4.0.13
* vue-router v4.0.15
* (c) 2022 Eduardo San Martin Morote

@@ -121,2 +121,180 @@ * @license MIT

};
export { useRouteState, useURL };
const getFileExtension = (url) => {
var _a, _b, _c;
const extension = (_c = (_b = (_a = url.split(/[?#]/).shift()) == null ? void 0 : _a.split("/").pop()) == null ? void 0 : _b.split(".").pop()) != null ? _c : "jpg";
return extension;
};
const limitImageDimensions = (max, width = 0, height = 0) => {
if (width > max || height > max) {
const ratio = width / height;
const biggerDimension = Math.max(width, height);
if (biggerDimension === width) {
width = max;
height = Math.round(width / ratio);
} else {
height = max;
width = Math.round(height * ratio);
}
}
return {
width,
height
};
};
const parseSize = (input = "") => {
if (typeof input === "number") {
return input;
}
if (typeof input === "string") {
if (input.replace("px", "").match(/^\d+$/g)) {
return parseInt(input, 10);
}
}
};
const isCtfAsset = (url) => url && url.includes("ctfassets");
const usePicture = (image, format, legacyFormat, mode, quality, sizesProp, screensProp) => {
const imageUrl = computed(() => {
return "url" in image ? image.url : "file" in image ? image.file.url : "";
});
const imageWidth = computed(() => {
return "width" in image ? image.width : image && "file" in image ? image.file.details.image.width : 0;
});
const imageHeight = computed(() => {
return image && "height" in image ? image.height : image && "file" in image ? image.file.details.image.height : 0;
});
const originalFormat = computed(() => {
return getFileExtension(imageUrl.value);
});
const isTransparent = computed(() => {
return ["png", "webp", "gif"].includes(originalFormat.value);
});
const nFormat = computed(() => {
if (format) {
return format;
}
if (originalFormat.value === "svg") {
return "svg";
}
return "webp";
});
const nLegacyFormat = computed(() => {
if (legacyFormat) {
return legacyFormat;
}
const formats = {
webp: isTransparent.value ? "png" : "jpeg",
svg: "png"
};
return formats[nFormat.value] || originalFormat.value;
});
const safeDimensions = computed(() => {
return limitImageDimensions(4e3, imageWidth.value, imageHeight.value);
});
const nSources = computed(() => {
if (nFormat.value === "svg") {
return [
{
srcset: imageUrl.value
}
];
}
const formats = nLegacyFormat.value !== nFormat.value ? [nLegacyFormat.value, nFormat.value] : [nFormat.value];
const sources = formats.map((format2) => {
const { srcset, sizes, src } = getSizes(format2);
return {
src,
type: `image/${format2}`,
sizes,
srcset
};
});
return sources;
});
const createCfUrlImage = (breakPoint, url, format2 = "jpg", height) => {
let resizeParams = "";
if (isCtfAsset(url)) {
resizeParams = "?";
resizeParams += `w=${breakPoint}&`;
resizeParams += height ? `h=${height}&` : "";
resizeParams += mode ? `fit=${mode}&` : "";
resizeParams += `q=${quality}&fm=${format2 && format2 === "jpeg" ? "jpg" : format2}`;
}
return `${url}${resizeParams}`;
};
const getSizes = (format2) => {
const width = parseSize(safeDimensions.value.width);
const height = parseSize(safeDimensions.value.height);
const hwRatio = width && height ? height / width : 0;
const variants = [];
const sizes = {};
if (typeof sizesProp === "string") {
for (const entry of sizesProp.split(/[\s,]+/).filter((e) => e)) {
const s = entry.split(":");
if (s.length !== 2) {
continue;
}
sizes[s[0].trim()] = s[1].trim();
}
} else {
Object.assign(sizes, sizesProp);
}
for (const key in sizes) {
const screenMaxWidth = screensProp && screensProp[key] || parseInt(key);
let size = String(sizes[key]);
const isFluid = size.endsWith("vw");
if (!isFluid && /^\d+$/.test(size)) {
size = size + "px";
}
if (!isFluid && !size.endsWith("px")) {
continue;
}
let _cWidth = parseInt(size);
if (!screenMaxWidth || !_cWidth) {
continue;
}
if (isFluid) {
_cWidth = Math.round(_cWidth / 100 * screenMaxWidth);
}
const _cHeight = hwRatio ? Math.round(_cWidth * hwRatio) : height;
variants.push({
width: _cWidth,
size,
screenMaxWidth,
media: `(max-width: ${screenMaxWidth}px)`,
src: `${createCfUrlImage(_cWidth, imageUrl.value, format2, _cHeight)}`
});
}
variants.sort((v1, v2) => v1.screenMaxWidth - v2.screenMaxWidth);
const defaultVar = variants[variants.length - 1];
if (defaultVar) {
defaultVar.media = "";
}
return {
sizes: variants.map((v) => `${v.media ? v.media + " " : ""}${v.size}`).join(", "),
srcset: variants.map((v) => `${v.src} ${v.width}w`).join(", "),
src: defaultVar == null ? void 0 : defaultVar.src
};
};
return {
imageUrl,
imageWidth,
imageHeight,
originalFormat,
isTransparent,
nFormat,
nLegacyFormat,
safeDimensions,
nSources
};
};
const useFocalPoint = (x, y, width, height) => {
const focalPoint = computed(() => {
const focalX = x * 100 / width;
const focalY = y * 100 / height;
return { "object-position": `${focalX}% ${focalY}%` };
});
return {
focalPoint
};
};
export { useFocalPoint, usePicture, useRouteState, useURL };

6

dist/composables.umd.js

@@ -1,5 +0,5 @@

var U=Object.defineProperty;var q=Object.getOwnPropertySymbols;var g=Object.prototype.hasOwnProperty,A=Object.prototype.propertyIsEnumerable;var R=(o,t,n)=>t in o?U(o,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):o[t]=n,y=(o,t)=>{for(var n in t||(t={}))g.call(t,n)&&R(o,n,t[n]);if(q)for(var n of q(t))A.call(t,n)&&R(o,n,t[n]);return o};(function(o,t){typeof exports=="object"&&typeof module!="undefined"?t(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],t):(o=typeof globalThis!="undefined"?globalThis:o||self,t(o.MyLib={},o.Vue))})(this,function(o,t){"use strict";const n=(e,f)=>{if(!f)throw new Error("Base is required");const l=t.computed(()=>e.value==="#"),a=t.computed(()=>typeof e.value=="string"?new URL(e.value,f):null),u=t.computed(()=>{var d;return((d=a.value)==null?void 0:d.origin)||""}),p=t.computed(()=>{var d;return l.value?"#":((d=a.value)==null?void 0:d.pathname)||""}),m=t.computed(()=>l.value||a.value!==null&&u.value!==f);return{url:a,origin:u,path:p,isExternal:m,isDummy:l}};/*!
* vue-router v4.0.13
(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}};/*!
* vue-router v4.0.15
* (c) 2022 Eduardo San Martin Morote
* @license MIT
*/const j=typeof Symbol=="function"&&typeof Symbol.toStringTag=="symbol",S=e=>j?Symbol(e):"_vr_"+e,v=S("r"),L=S("rl");var b;(function(e){e.pop="pop",e.push="push"})(b||(b={}));var h;(function(e){e.back="back",e.forward="forward",e.unknown=""})(h||(h={}));var w;(function(e){e[e.aborted=4]="aborted",e[e.cancelled=8]="cancelled",e[e.duplicated=16]="duplicated"})(w||(w={}));function V(){return t.inject(v)}function k(){return t.inject(L)}const _=(e,f="replace")=>{const l=k(),a=V();let u;Array.isArray(e)?u=e.reduce((s,c)=>(s[c]={get:r=>r,set:r=>r},s),{}):u=e;const p=Object.keys(u),m=t.computed(()=>{const s={};for(const c of p){const r=l.query[c],i=u[c].get(r);s[c]=i}return s});return{state:m,updateState:s=>{const c=y(y({},m.value),s),r={};for(const i of p){const K=c[i],M=u[i].set(K);r[i]=M}return a[f]({query:y(y({},l.query),r)})}}};o.useRouteState=_,o.useURL=n,Object.defineProperty(o,"__esModule",{value:!0}),o[Symbol.toStringTag]="Module"});
*/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"}})});
export { useURL } from './useURL';
export { useRouteState } from './useRouteState';
export { usePicture } from './usePicture';
export { useFocalPoint } from './useFocalPoint';

@@ -7,3 +7,3 @@ {

},
"version": "0.0.0-2e73034",
"version": "0.0.0-3cf276b",
"license": "MIT",

@@ -42,5 +42,5 @@ "files": [

"dependencies": {
"@atoms-studio/nuxt-components": "0.0.0-2e73034",
"@atoms-studio/nuxt-components": "0.0.0-3cf276b",
"mkdirp": "^0.5.5"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc