Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@atoms-studio/composables

Package Overview
Dependencies
Maintainers
7
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-0f07a89 to 0.0.0-10dc0a8

101

dist/composables.es.js

@@ -1,57 +0,7 @@

var __defProp = Object.defineProperty;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
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";
/*!
* vue-router v4.0.15
* vue-router v4.1.2
* (c) 2022 Eduardo San Martin Morote
* @license MIT
*/
const hasSymbol = typeof Symbol === "function" && typeof Symbol.toStringTag === "symbol";
const PolySymbol = (name) => hasSymbol ? Symbol(name) : "_vr_" + name;
const routerKey = /* @__PURE__ */ PolySymbol("r");
const routeLocationKey = /* @__PURE__ */ PolySymbol("rl");
var NavigationType;

@@ -74,2 +24,4 @@ (function(NavigationType2) {

})(NavigationFailureType || (NavigationFailureType = {}));
const routerKey = Symbol("");
const routeLocationKey = Symbol("");
function useRouter() {

@@ -107,3 +59,3 @@ return inject(routerKey);

const updateState = (partialState) => {
const newState = __spreadValues(__spreadValues({}, state.value), partialState);
const newState = { ...state.value, ...partialState };
const newQuery = {};

@@ -115,3 +67,3 @@ for (const stateKey of stateKeys) {

}
return router[method]({ query: __spreadValues(__spreadValues({}, route.query), newQuery) });
return router[method]({ query: { ...route.query, ...newQuery } });
};

@@ -123,2 +75,32 @@ return {

};
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) => {

@@ -157,3 +139,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(() => {

@@ -225,2 +208,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}`;

@@ -227,0 +218,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}};/*!
* vue-router v4.0.15
(function(p,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(p=typeof globalThis!="undefined"?globalThis:p||self,e(p.MyLib={},p.Vue))})(this,function(p,e){"use strict";/*!
* vue-router v4.1.2
* (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"}})});
*/var D;(function(t){t.pop="pop",t.push="push"})(D||(D={}));var I;(function(t){t.back="back",t.forward="forward",t.unknown=""})(I||(I={}));var U;(function(t){t[t.aborted=4]="aborted",t[t.cancelled=8]="cancelled",t[t.duplicated=16]="duplicated"})(U||(U={}));const A=Symbol(""),V=Symbol("");function _(){return e.inject(A)}function E(){return e.inject(V)}const K=(t,o="replace")=>{const n=E(),r=_();let c;Array.isArray(t)?c=t.reduce((h,a)=>(h[a]={get:f=>f,set:f=>f},h),{}):c=t;const d=Object.keys(c),m=e.computed(()=>{const h={};for(const a of d){const f=n.query[a],g=c[a].get(f);h[a]=g}return h});return{state:m,updateState:h=>{const a={...m.value,...h},f={};for(const g of d){const v=a[g],R=c[g].set(v);f[g]=R}return r[o]({query:{...n.query,...f}})}}},P=(t,o)=>{if(!o)throw new Error("Base is required");const n=e.computed(()=>t.value==="#"),r=e.computed(()=>typeof t.value=="string"?new URL(t.value,o):null),c=e.computed(()=>{var $;return(($=r.value)==null?void 0:$.origin)||""}),d=e.computed(()=>{var $;return n.value?"#":(($=r.value)==null?void 0:$.pathname)||""}),m=e.computed(()=>n.value||r.value!==null&&c.value!==o);return{url:r,origin:c,path:d,isExternal:m,isDummy:n}},C=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"},H=(t,o=0,n=0)=>{if(o>t||n>t){const r=o/n;Math.max(o,n)===o?(o=t,n=Math.round(o/r)):(n=t,o=Math.round(n*r))}return{width:o,height:n}},k=(t="")=>{if(typeof t=="number")return t;if(typeof t=="string"&&t.replace("px","").match(/^\d+$/g))return parseInt(t,10)},B=t=>t&&t.includes("ctfassets"),F=t=>t&&t.includes("datocms-assets"),O=(t,o,n,r,c,d,m,$,h)=>{const a=e.computed(()=>"url"in t?t.url:"file"in t?t.file.url:""),f=e.computed(()=>"width"in t?t.width:t&&"file"in t?t.file.details.image.width:0),g=e.computed(()=>t&&"height"in t?t.height:t&&"file"in t?t.file.details.image.height:0),v=e.computed(()=>C(a.value)),R=e.computed(()=>["png","webp","gif"].includes(v.value)),b=e.computed(()=>o||(v.value==="svg"?"svg":"webp")),W=e.computed(()=>n||{webp:R.value?"png":"jpeg",svg:"png"}[b.value]||v.value),z=e.computed(()=>H(4e3,f.value,g.value)),X=e.computed(()=>b.value==="svg"?[{srcset:a.value}]:(W.value!==b.value?[W.value,b.value]:[b.value]).map(i=>{const{srcset:y,sizes:s,src:x}=G(i);return{src:x,type:`image/${i}`,sizes:s,srcset:y}})),Y=(S,w,i="jpg",y)=>{let s="";return B(w)&&(s="?",s+=`w=${S}&`,s+=y?`h=${y}&`:"",s+=r?`fit=${r}&`:"",s+=`q=${c}&fm=${i&&i==="jpeg"?"jpg":i}`),F(w)&&(s="?",s+=`crop=focalpoint&fit=crop&fp-x=${$.x}&fp-y=${$.y}&`,s+=`w=${S}&`,s+=y?`h=${y}&`:"",s+=h?"auto=format&":"",s+=`q=${c}&fm=${i&&i==="jpeg"?"jpg":i}`),`${w}${s}`},G=S=>{const w=k(z.value.width),i=k(z.value.height),y=w&&i?i/w:0,s=[],x={};if(typeof d=="string")for(const u of d.split(/[\s,]+/).filter(l=>l)){const l=u.split(":");l.length===2&&(x[l[0].trim()]=l[1].trim())}else Object.assign(x,d);for(const u in x){const l=m&&m[u]||parseInt(u);let j=String(x[u]);const L=j.endsWith("vw");if(!L&&/^\d+$/.test(j)&&(j=j+"px"),!L&&!j.endsWith("px"))continue;let M=parseInt(j);if(!l||!M)continue;L&&(M=Math.round(M/100*l));const J=y?Math.round(M*y):i;s.push({width:M,size:j,screenMaxWidth:l,media:`(max-width: ${l}px)`,src:`${Y(M,a.value,S,J)}`})}s.sort((u,l)=>u.screenMaxWidth-l.screenMaxWidth);const q=s[s.length-1];return q&&(q.media=""),{sizes:s.map(u=>`${u.media?u.media+" ":""}${u.size}`).join(", "),srcset:s.map(u=>`${u.src} ${u.width}w`).join(", "),src:q==null?void 0:q.src}};return{imageUrl:a,imageWidth:f,imageHeight:g,originalFormat:v,isTransparent:R,nFormat:b,nLegacyFormat:W,safeDimensions:z,nSources:X}},Q=(t,o,n,r)=>({focalPoint:e.computed(()=>{const d=t*100/n,m=o*100/r;return{"object-position":`${d}% ${m}%`}})});p.useFocalPoint=Q,p.usePicture=O,p.useRouteState=K,p.useURL=P,Object.defineProperties(p,{__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-0f07a89",
"version": "0.0.0-10dc0a8",
"license": "MIT",

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

"dependencies": {
"@atoms-studio/nuxt-components": "0.0.0-0f07a89",
"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