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

vue-composable

Package Overview
Dependencies
Maintainers
1
Versions
83
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-composable - npm Package Compare versions

Comparing version 1.0.0-dev.3 to 1.0.0-dev.4

50

dist/vue-composable.esm.js

@@ -13,3 +13,3 @@ import { isRef, ref, computed, watch, onMounted, onUnmounted } from '@vue/composition-api';

const isSymbol = (val) => typeof val === "symbol";
const isBoolean = (val) => typeof val === 'boolean';
const isBoolean = (val) => typeof val === "boolean";
const isDate = (val) => isObject(val) && isFunction(val.getTime);

@@ -22,2 +22,3 @@ const isNumber = (val) => typeof val === "number";

}
const NO_OP = () => { };
function promisedTimeout(timeout) {

@@ -672,2 +673,47 @@ return new Promise(res => {

function useNetworkInformation() {
const connection = navigator.connection ||
navigator.mozConnection ||
navigator.webkitConnection;
const supported = computed(() => !!connection);
const downlink = ref(0);
const downlinkMax = ref(0);
const effectiveType = ref("unknown");
const rtt = ref(0);
const saveData = ref(false);
const type = ref("none");
let handler = NO_OP;
let remove = NO_OP;
/* istanbul ignore else */
if (connection) {
handler = () => {
downlink.value = connection.downlink;
downlinkMax.value = connection.downlinkMax;
effectiveType.value = connection.effectiveType;
rtt.value = connection.rtt;
saveData.value = connection.saveData;
type.value = connection.type;
};
remove = () => {
connection.removeEventListener("change", handler);
};
connection.addEventListener("change", handler, { passive: true });
handler();
onUnmounted(remove);
}
else {
console.warn("[navigator.connection] not found, networkInformation not available.");
}
return {
supported,
downlink,
downlinkMax,
effectiveType,
rtt,
saveData,
type,
remove
};
}
// used to store all the instances of weakMap

@@ -733,2 +779,2 @@ const keyedMap = new Map();

export { debounce, exponentialDelay, isArray, isBoolean, isDate, isElement, isFunction, isNumber, isObject, isPromise, isString, isSymbol, minMax, noDelay, promisedTimeout, unwrap, useArrayPagination, useBreakpoint, useCancellablePromise, useDebounce, useEvent, useFetch, useIntersectionObserver, useLocalStorage, useMatchMedia, useOnMouseMove, useOnResize, useOnScroll, usePagination, usePromise, useRetry, useWebSocket, wrap };
export { NO_OP, debounce, exponentialDelay, isArray, isBoolean, isDate, isElement, isFunction, isNumber, isObject, isPromise, isString, isSymbol, minMax, noDelay, promisedTimeout, unwrap, useArrayPagination, useBreakpoint, useCancellablePromise, useDebounce, useEvent, useFetch, useIntersectionObserver, useLocalStorage, useMatchMedia, useNetworkInformation, useOnMouseMove, useOnResize, useOnScroll, usePagination, usePromise, useRetry, useWebSocket, wrap };

2

dist/vue-composable.esm.prod.js

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

import{isRef as e,ref as t,computed as n,watch as r,onMounted as l,onUnmounted as a}from"@vue/composition-api";function o(t){return e(t)?t.value:t}function u(n){return e(n)?n:t(n)}const s=Array.isArray,v=e=>"function"==typeof e,i=e=>"string"==typeof e,c=e=>"symbol"==typeof e,f=e=>"boolean"==typeof e,d=e=>y(e)&&v(e.getTime),m=e=>"number"==typeof e,y=e=>null!==e&&"object"==typeof e,g=e=>y(e)&&!!e.tagName;function h(e){return y(e)&&v(e.then)&&v(e.catch)}function p(e){return new Promise(t=>{setTimeout(t,e)})}function w(e,t,n){return e<t?t:e>n?n:e}function b(e){const l=u(e.currentPage),a=u(e.pageSize),o=t(0),s=u(e.total),v=n({get:()=>o.value,set(e){"number"==typeof e&&(o.value=Math.min(e,s.value))}}),i=n({get:()=>l.value,set(e){"number"==typeof e&&(l.value=w(e,1,f.value),v.value=(l.value-1)*c.value)}}),c=n({get:()=>a.value,set(e){"number"==typeof e&&(a.value=e)}}),f=n(()=>Math.ceil(s.value/c.value));i.value=l.value;return r([s,c],()=>{i.value>f.value&&(i.value=f.value)},{lazy:!0}),{pageSize:c,total:s,currentPage:i,offset:v,lastPage:f,next:()=>++i.value,prev:()=>--i.value,first:()=>i.value=1,last:()=>i.value=f.value}}function E(e,t){const r=u(e),l=b({currentPage:1,pageSize:10,...t,total:n(()=>r.value.length)}),a=n(()=>{const e=r.value;return Array.isArray(e)?e.slice(l.offset.value,l.offset.value+l.pageSize.value):[]});return{...l,result:a}}function R(e,n=!1){if(!e)throw new Error(`[usePromise] argument can't be '${e}'`);if("function"!=typeof e)throw new Error(`[usePromise] expects function, but received ${typeof e}`);const r=t(!1),l=t(null),a=t(null),o=t();return{exec:async(...t)=>{r.value=!0,l.value=null,a.value=null;let u=t&&e.length!==t.length&&t.length>0&&f(t[t.length-1])?t[t.length-1]:n;const s=o.value=e(...t);try{const e=await s;return o.value===s&&(a.value=e),e}catch(e){return o.value===s&&(l.value=e,a.value=null),u?s:void 0}finally{o.value===s&&(r.value=!1)}},result:a,promise:o,loading:r,error:l}}function x(e,n=!1){const r=t(!1);let l=void 0;return{...R((...t)=>(e=>new Promise((t,n)=>{l=e=>{r.value=!0,n(e)},e.then(t).catch(n)}))(e(...t)),n),cancel:e=>l(e),cancelled:r}}const L=Symbol(void 0),S=Symbol(void 0),I=async(e,t,n,r)=>{const l=t[L].value;let a=-1;const o=e.maxRetries||9001,u=e.retryDelay||z;t.retryErrors.value=[],t.isRetrying.value=!1,t.nextRetry.value=void 0;let s=void 0;do{let e=!1,v=null;try{if(++a,v=r?n(...r):n(),h(v)&&(v=await v),t[S].value)return null;e=!0}catch(e){v=null,t.retryErrors.value.push(e)}if(l!==t[L].value)return v;if(e)return t.isRetrying.value=!1,t.nextRetry.value=void 0,v;if(a>=o)return t.isRetrying.value=!1,t.nextRetry.value=void 0,Promise.reject(new Error(`[useRetry] max retries reached ${o}`));t.isRetrying.value=!0;const i=Date.now(),c=u(a),f=h(c)?await c:c;if(!h(c)||f){if(m(f))s=f;else{if(!d(f))throw new Error(`[useRetry] invalid value received from options.retryDelay '${typeof f}'`);s=f.getTime()}s<i?t.nextRetry.value=i+s:(t.nextRetry.value=s,s-=i),s>0&&await p(s)}if(t[S].value)return null;if(l!==t[L].value)return v}while(a<9e3);return null};function M(e,r){const l=!e||v(e)?{}:e,a=v(e)?e:r;if(!v(e)&&!y(e))throw new Error("[useRetry] options needs to be 'object'");if(a&&!v(a))throw new Error("[useRetry] factory needs to be 'function'");const o=t(!1),u=t(),s=t([]),i={value:!1},c={isRetrying:o,retryCount:n(()=>s.value.length),nextRetry:u,retryErrors:s,[L]:{value:0},[S]:i},f=a?(...e)=>(++c[L].value,I(l,c,a,e)):e=>(++c[L].value,I(l,c,e,void 0));return{...c,cancel:()=>{c.isRetrying.value=!1,c.retryErrors.value.push(new Error("[useRetry] cancelled")),c.nextRetry.value=void 0,i.value=!0},exec:f}}const T=e=>{const t=100*Math.pow(2,e);return t+.2*t*Math.random()},z=()=>0;function P(e,t,n){return j(e,t,n)}function j(e,t=50,n={isImmediate:!1}){let r;return function(...l){const a=this,o=n.isImmediate&&void 0===r;void 0!==r&&clearTimeout(r),r=setTimeout((function(){r=void 0,n.isImmediate||e.apply(a,l)}),t),o&&e.apply(a,l)}}function W(e,t,n,r){const o=u(e),s=()=>o.value.removeEventListener(t,n);return l(()=>o.value.addEventListener(t,n,r)),a(s),s}function A(e,n,r){const l=t(0),a=t(0);let o=e=>{l.value=e.x,a.value=e.y};const u="number"==typeof n?void 0:n;("number"==typeof n?n:r)&&(o=P(o,r));const s=W(e,"mousemove",o,u);return{mouseX:l,mouseY:a,remove:s}}function O(e,n,r){const l=u(e),a=t(l.value&&l.value.clientHeight),o=t(l.value&&l.value.clientWidth);let s=()=>{a.value=l.value.clientHeight,o.value=l.value.clientWidth};const v="number"==typeof n?void 0:n;("number"==typeof n?n:r)&&(s=P(s,r));const i=W(window,"resize",s,v||{passive:!0});return{height:a,width:o,remove:i}}function $(e,n,r){const l=u(e),a=t(l.value&&l.value.scrollTop),o=t(l.value&&l.value.scrollLeft);let s=e=>{a.value=l.value.scrollTop,o.value=l.value.scrollLeft};const v="number"==typeof n?void 0:n;("number"==typeof n?n:r)&&(s=P(s,r));const i=W(l,"scroll",s,v);return{scrollTop:a,scrollLeft:o,remove:i}}function D(e){const n=t(matchMedia(e)),r=t(n.value.matches),l=e=>{r.value=e.matches};n.value.addEventListener("change",l,{passive:!0});const o=()=>n.value.removeEventListener("change",l);return a(o),{mediaQueryList:n,remove:o,matches:r}}function J(e){const n={},r=new Map,o=t();let u=[];const s=[];for(const l in e){const a=e[l];if(m(a)){const e=t(!1);n[l]=e,r.set(a,{name:l,valid:e}),u.push(a)}else{const{matches:e,remove:t}=D(a);n[l]=e,s.push(t)}}u=u.sort((e,t)=>t-e);const v=()=>{const e=window.innerWidth;let t=void 0;for(let n=0;n<u.length;n++){const l=u[n],a=r.get(l);a.valid.value=e>=l,e>=l&&void 0===t&&(t=a.name)}o.value=t},i=P(v,10),c=()=>window.removeEventListener("resize",i);return l(()=>{v(),window.addEventListener("resize",i,{passive:!0})}),a(()=>{c(),s.forEach(e=>e())}),{...n,remove:c,current:o}}function N(e){const r=t(null),l=t(null),a=!e||!1!==e.isJson,o=!e||!1!==e.parseImmediate,u=R(async(e,t)=>{const n=await fetch(e,t);if(a){const e=n.json().then(e=>r.value=e).catch(e=>{r.value=null,l.value=e});o&&await e}return n}),s=n(()=>u.result.value&&u.result.value.status||null),v=n(()=>u.result.value&&u.result.value.statusText||null);return{...u,json:r,jsonError:l,status:s,statusText:v}}function k(e,n){const r=new WebSocket(e,n),l=t(null),a=t(),o=t(null),u=t(!1),s=t(!1),v=t(!1);r.addEventListener("message",e=>{l.value=e,o.value=e.data}),r.addEventListener("error",e=>{a.value=e,v.value=!0}),r.addEventListener("close",()=>{u.value=!1,s.value=!0}),r.addEventListener("open",()=>{u.value=!0,s.value=!1});return{ws:r,send:e=>r.send(e),close:(e,t)=>{r.close(e,t)},messageEvent:l,errorEvent:a,data:o,isOpen:u,isClosed:s,errored:v}}function C(e,s){const v=e?u(e):void 0,i=!v||!g(v.value)&&v.value?void 0:v,c=n(()=>s?o(s):i?void 0:o(e)),f=t(i&&i.value?[i.value]:[]),d=n(()=>f.value.length>0&&f.value.every(e=>e.isIntersecting)),m=e=>{f.value=e};let y=t();r(c,e=>{y.value&&y.value.disconnect();const t=e&&e&&{root:o(e.root),rootMargin:o(e.rootMargin),threshold:o(e.threshold)}||void 0;y.value=new IntersectionObserver(m,t),f.value.map(e=>e.target).forEach(y.value.observe)},{deep:!0});const h=e=>{const t=o(e);y.value.observe(t)},p=()=>y.value.disconnect();return i&&(i.value||l(()=>{i.value&&h(i)}),a(()=>{p()})),{elements:f,observe:h,unobserve:e=>{const t=o(e);y.value.unobserve(t)},disconnect:p,isIntersecting:d}}const H=new Map,Q=new WeakMap;function X(e,n){let l=!1,a=H.get(e);const o=localStorage.getItem(e),s=a&&Q.get(a)||!!n&&u(n)||t(null);if(o&&!a)try{s.value=JSON.parse(o),l=!1}catch(t){console.warn("[useLocalStorage] error parsing value from localStorage",e,t)}a||(a={},H.set(e,a),Q.set(a,s),r(s,t=>{void 0!==t?j(()=>localStorage.setItem(e,JSON.stringify(t)),100)():localStorage.removeItem(e)},{deep:!0,lazy:l}));return{storage:s,clear:()=>{H.forEach(e=>{const t=Q.get(e);t&&(t.value=void 0),Q.delete(e)}),H.clear()},remove:()=>{H.delete(e),Q.delete(a),s.value=void 0}}}export{j as debounce,T as exponentialDelay,s as isArray,f as isBoolean,d as isDate,g as isElement,v as isFunction,m as isNumber,y as isObject,h as isPromise,i as isString,c as isSymbol,w as minMax,z as noDelay,p as promisedTimeout,o as unwrap,E as useArrayPagination,J as useBreakpoint,x as useCancellablePromise,P as useDebounce,W as useEvent,N as useFetch,C as useIntersectionObserver,X as useLocalStorage,D as useMatchMedia,A as useOnMouseMove,O as useOnResize,$ as useOnScroll,b as usePagination,R as usePromise,M as useRetry,k as useWebSocket,u as wrap};
import{isRef as e,ref as t,computed as n,watch as r,onMounted as a,onUnmounted as o}from"@vue/composition-api";function l(t){return e(t)?t.value:t}function u(n){return e(n)?n:t(n)}const s=Array.isArray,v=e=>"function"==typeof e,i=e=>"string"==typeof e,c=e=>"symbol"==typeof e,d=e=>"boolean"==typeof e,f=e=>y(e)&&v(e.getTime),m=e=>"number"==typeof e,y=e=>null!==e&&"object"==typeof e,p=e=>y(e)&&!!e.tagName;function g(e){return y(e)&&v(e.then)&&v(e.catch)}const h=()=>{};function w(e){return new Promise(t=>{setTimeout(t,e)})}function E(e,t,n){return e<t?t:e>n?n:e}function b(e){const a=u(e.currentPage),o=u(e.pageSize),l=t(0),s=u(e.total),v=n({get:()=>l.value,set(e){"number"==typeof e&&(l.value=Math.min(e,s.value))}}),i=n({get:()=>a.value,set(e){"number"==typeof e&&(a.value=E(e,1,d.value),v.value=(a.value-1)*c.value)}}),c=n({get:()=>o.value,set(e){"number"==typeof e&&(o.value=e)}}),d=n(()=>Math.ceil(s.value/c.value));i.value=a.value;return r([s,c],()=>{i.value>d.value&&(i.value=d.value)},{lazy:!0}),{pageSize:c,total:s,currentPage:i,offset:v,lastPage:d,next:()=>++i.value,prev:()=>--i.value,first:()=>i.value=1,last:()=>i.value=d.value}}function x(e,t){const r=u(e),a=b({currentPage:1,pageSize:10,...t,total:n(()=>r.value.length)}),o=n(()=>{const e=r.value;return Array.isArray(e)?e.slice(a.offset.value,a.offset.value+a.pageSize.value):[]});return{...a,result:o}}function R(e,n=!1){if(!e)throw new Error(`[usePromise] argument can't be '${e}'`);if("function"!=typeof e)throw new Error(`[usePromise] expects function, but received ${typeof e}`);const r=t(!1),a=t(null),o=t(null),l=t();return{exec:async(...t)=>{r.value=!0,a.value=null,o.value=null;let u=t&&e.length!==t.length&&t.length>0&&d(t[t.length-1])?t[t.length-1]:n;const s=l.value=e(...t);try{const e=await s;return l.value===s&&(o.value=e),e}catch(e){return l.value===s&&(a.value=e,o.value=null),u?s:void 0}finally{l.value===s&&(r.value=!1)}},result:o,promise:l,loading:r,error:a}}function L(e,n=!1){const r=t(!1);let a=void 0;return{...R((...t)=>(e=>new Promise((t,n)=>{a=e=>{r.value=!0,n(e)},e.then(t).catch(n)}))(e(...t)),n),cancel:e=>a(e),cancelled:r}}const S=Symbol(void 0),M=Symbol(void 0),T=async(e,t,n,r)=>{const a=t[S].value;let o=-1;const l=e.maxRetries||9001,u=e.retryDelay||P;t.retryErrors.value=[],t.isRetrying.value=!1,t.nextRetry.value=void 0;let s=void 0;do{let e=!1,v=null;try{if(++o,v=r?n(...r):n(),g(v)&&(v=await v),t[M].value)return null;e=!0}catch(e){v=null,t.retryErrors.value.push(e)}if(a!==t[S].value)return v;if(e)return t.isRetrying.value=!1,t.nextRetry.value=void 0,v;if(o>=l)return t.isRetrying.value=!1,t.nextRetry.value=void 0,Promise.reject(new Error(`[useRetry] max retries reached ${l}`));t.isRetrying.value=!0;const i=Date.now(),c=u(o),d=g(c)?await c:c;if(!g(c)||d){if(m(d))s=d;else{if(!f(d))throw new Error(`[useRetry] invalid value received from options.retryDelay '${typeof d}'`);s=d.getTime()}s<i?t.nextRetry.value=i+s:(t.nextRetry.value=s,s-=i),s>0&&await w(s)}if(t[M].value)return null;if(a!==t[S].value)return v}while(o<9e3);return null};function z(e,r){const a=!e||v(e)?{}:e,o=v(e)?e:r;if(!v(e)&&!y(e))throw new Error("[useRetry] options needs to be 'object'");if(o&&!v(o))throw new Error("[useRetry] factory needs to be 'function'");const l=t(!1),u=t(),s=t([]),i={value:!1},c={isRetrying:l,retryCount:n(()=>s.value.length),nextRetry:u,retryErrors:s,[S]:{value:0},[M]:i},d=o?(...e)=>(++c[S].value,T(a,c,o,e)):e=>(++c[S].value,T(a,c,e,void 0));return{...c,cancel:()=>{c.isRetrying.value=!1,c.retryErrors.value.push(new Error("[useRetry] cancelled")),c.nextRetry.value=void 0,i.value=!0},exec:d}}const I=e=>{const t=100*Math.pow(2,e);return t+.2*t*Math.random()},P=()=>0;function k(e,t,n){return j(e,t,n)}function j(e,t=50,n={isImmediate:!1}){let r;return function(...a){const o=this,l=n.isImmediate&&void 0===r;void 0!==r&&clearTimeout(r),r=setTimeout((function(){r=void 0,n.isImmediate||e.apply(o,a)}),t),l&&e.apply(o,a)}}function D(e,t,n,r){const l=u(e),s=()=>l.value.removeEventListener(t,n);return a(()=>l.value.addEventListener(t,n,r)),o(s),s}function W(e,n,r){const a=t(0),o=t(0);let l=e=>{a.value=e.x,o.value=e.y};const u="number"==typeof n?void 0:n;("number"==typeof n?n:r)&&(l=k(l,r));const s=D(e,"mousemove",l,u);return{mouseX:a,mouseY:o,remove:s}}function A(e,n,r){const a=u(e),o=t(a.value&&a.value.clientHeight),l=t(a.value&&a.value.clientWidth);let s=()=>{o.value=a.value.clientHeight,l.value=a.value.clientWidth};const v="number"==typeof n?void 0:n;("number"==typeof n?n:r)&&(s=k(s,r));const i=D(window,"resize",s,v||{passive:!0});return{height:o,width:l,remove:i}}function C(e,n,r){const a=u(e),o=t(a.value&&a.value.scrollTop),l=t(a.value&&a.value.scrollLeft);let s=e=>{o.value=a.value.scrollTop,l.value=a.value.scrollLeft};const v="number"==typeof n?void 0:n;("number"==typeof n?n:r)&&(s=k(s,r));const i=D(a,"scroll",s,v);return{scrollTop:o,scrollLeft:l,remove:i}}function O(e){const n=t(matchMedia(e)),r=t(n.value.matches),a=e=>{r.value=e.matches};n.value.addEventListener("change",a,{passive:!0});const l=()=>n.value.removeEventListener("change",a);return o(l),{mediaQueryList:n,remove:l,matches:r}}function $(e){const n={},r=new Map,l=t();let u=[];const s=[];for(const a in e){const o=e[a];if(m(o)){const e=t(!1);n[a]=e,r.set(o,{name:a,valid:e}),u.push(o)}else{const{matches:e,remove:t}=O(o);n[a]=e,s.push(t)}}u=u.sort((e,t)=>t-e);const v=()=>{const e=window.innerWidth;let t=void 0;for(let n=0;n<u.length;n++){const a=u[n],o=r.get(a);o.valid.value=e>=a,e>=a&&void 0===t&&(t=o.name)}l.value=t},i=k(v,10),c=()=>window.removeEventListener("resize",i);return a(()=>{v(),window.addEventListener("resize",i,{passive:!0})}),o(()=>{c(),s.forEach(e=>e())}),{...n,remove:c,current:l}}function J(e){const r=t(null),a=t(null),o=!e||!1!==e.isJson,l=!e||!1!==e.parseImmediate,u=R(async(e,t)=>{const n=await fetch(e,t);if(o){const e=n.json().then(e=>r.value=e).catch(e=>{r.value=null,a.value=e});l&&await e}return n}),s=n(()=>u.result.value&&u.result.value.status||null),v=n(()=>u.result.value&&u.result.value.statusText||null);return{...u,json:r,jsonError:a,status:s,statusText:v}}function N(e,n){const r=new WebSocket(e,n),a=t(null),o=t(),l=t(null),u=t(!1),s=t(!1),v=t(!1);r.addEventListener("message",e=>{a.value=e,l.value=e.data}),r.addEventListener("error",e=>{o.value=e,v.value=!0}),r.addEventListener("close",()=>{u.value=!1,s.value=!0}),r.addEventListener("open",()=>{u.value=!0,s.value=!1});return{ws:r,send:e=>r.send(e),close:(e,t)=>{r.close(e,t)},messageEvent:a,errorEvent:o,data:l,isOpen:u,isClosed:s,errored:v}}function H(e,s){const v=e?u(e):void 0,i=!v||!p(v.value)&&v.value?void 0:v,c=n(()=>s?l(s):i?void 0:l(e)),d=t(i&&i.value?[i.value]:[]),f=n(()=>d.value.length>0&&d.value.every(e=>e.isIntersecting)),m=e=>{d.value=e};let y=t();r(c,e=>{y.value&&y.value.disconnect();const t=e&&e&&{root:l(e.root),rootMargin:l(e.rootMargin),threshold:l(e.threshold)}||void 0;y.value=new IntersectionObserver(m,t),d.value.map(e=>e.target).forEach(y.value.observe)},{deep:!0});const g=e=>{const t=l(e);y.value.observe(t)},h=()=>y.value.disconnect();return i&&(i.value||a(()=>{i.value&&g(i)}),o(()=>{h()})),{elements:d,observe:g,unobserve:e=>{const t=l(e);y.value.unobserve(t)},disconnect:h,isIntersecting:f}}function Q(){const e=navigator.connection||navigator.mozConnection||navigator.webkitConnection,r=n(()=>!!e),a=t(0),l=t(0),u=t("unknown"),s=t(0),v=t(!1),i=t("none");let c=h,d=h;return e&&(c=()=>{a.value=e.downlink,l.value=e.downlinkMax,u.value=e.effectiveType,s.value=e.rtt,v.value=e.saveData,i.value=e.type},d=()=>{e.removeEventListener("change",c)},e.addEventListener("change",c,{passive:!0}),c(),o(d)),{supported:r,downlink:a,downlinkMax:l,effectiveType:u,rtt:s,saveData:v,type:i,remove:d}}const X=new Map,Y=new WeakMap;function q(e,n){let a=!1,o=X.get(e);const l=localStorage.getItem(e),s=o&&Y.get(o)||!!n&&u(n)||t(null);if(l&&!o)try{s.value=JSON.parse(l),a=!1}catch(t){console.warn("[useLocalStorage] error parsing value from localStorage",e,t)}o||(o={},X.set(e,o),Y.set(o,s),r(s,t=>{void 0!==t?j(()=>localStorage.setItem(e,JSON.stringify(t)),100)():localStorage.removeItem(e)},{deep:!0,lazy:a}));return{storage:s,clear:()=>{X.forEach(e=>{const t=Y.get(e);t&&(t.value=void 0),Y.delete(e)}),X.clear()},remove:()=>{X.delete(e),Y.delete(o),s.value=void 0}}}export{h as NO_OP,j as debounce,I as exponentialDelay,s as isArray,d as isBoolean,f as isDate,p as isElement,v as isFunction,m as isNumber,y as isObject,g as isPromise,i as isString,c as isSymbol,E as minMax,P as noDelay,w as promisedTimeout,l as unwrap,x as useArrayPagination,$ as useBreakpoint,L as useCancellablePromise,k as useDebounce,D as useEvent,J as useFetch,H as useIntersectionObserver,q as useLocalStorage,O as useMatchMedia,Q as useNetworkInformation,W as useOnMouseMove,A as useOnResize,C as useOnScroll,b as usePagination,R as usePromise,z as useRetry,N as useWebSocket,u as wrap};

@@ -14,3 +14,3 @@ var vueComposable = (function (exports, compositionApi) {

const isSymbol = (val) => typeof val === "symbol";
const isBoolean = (val) => typeof val === 'boolean';
const isBoolean = (val) => typeof val === "boolean";
const isDate = (val) => isObject(val) && isFunction(val.getTime);

@@ -23,2 +23,3 @@ const isNumber = (val) => typeof val === "number";

}
const NO_OP = () => { };
function promisedTimeout(timeout) {

@@ -673,2 +674,47 @@ return new Promise(res => {

function useNetworkInformation() {
const connection = navigator.connection ||
navigator.mozConnection ||
navigator.webkitConnection;
const supported = compositionApi.computed(() => !!connection);
const downlink = compositionApi.ref(0);
const downlinkMax = compositionApi.ref(0);
const effectiveType = compositionApi.ref("unknown");
const rtt = compositionApi.ref(0);
const saveData = compositionApi.ref(false);
const type = compositionApi.ref("none");
let handler = NO_OP;
let remove = NO_OP;
/* istanbul ignore else */
if (connection) {
handler = () => {
downlink.value = connection.downlink;
downlinkMax.value = connection.downlinkMax;
effectiveType.value = connection.effectiveType;
rtt.value = connection.rtt;
saveData.value = connection.saveData;
type.value = connection.type;
};
remove = () => {
connection.removeEventListener("change", handler);
};
connection.addEventListener("change", handler, { passive: true });
handler();
compositionApi.onUnmounted(remove);
}
else {
console.warn("[navigator.connection] not found, networkInformation not available.");
}
return {
supported,
downlink,
downlinkMax,
effectiveType,
rtt,
saveData,
type,
remove
};
}
// used to store all the instances of weakMap

@@ -734,2 +780,3 @@ const keyedMap = new Map();

exports.NO_OP = NO_OP;
exports.debounce = debounce;

@@ -760,2 +807,3 @@ exports.exponentialDelay = exponentialDelay;

exports.useMatchMedia = useMatchMedia;
exports.useNetworkInformation = useNetworkInformation;
exports.useOnMouseMove = useOnMouseMove;

@@ -762,0 +810,0 @@ exports.useOnResize = useOnResize;

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

var vueComposable=function(e,t){"use strict";function n(e){return t.isRef(e)?e.value:e}function r(e){return t.isRef(e)?e:t.ref(e)}const o=Array.isArray,u=e=>"function"==typeof e,a=e=>"boolean"==typeof e,l=e=>i(e)&&u(e.getTime),s=e=>"number"==typeof e,i=e=>null!==e&&"object"==typeof e,v=e=>i(e)&&!!e.tagName;function c(e){return i(e)&&u(e.then)&&u(e.catch)}function f(e){return new Promise(t=>{setTimeout(t,e)})}function d(e,t,n){return e<t?t:e>n?n:e}function m(e,n=!1){if(!e)throw new Error(`[usePromise] argument can't be '${e}'`);if("function"!=typeof e)throw new Error(`[usePromise] expects function, but received ${typeof e}`);const r=t.ref(!1),o=t.ref(null),u=t.ref(null),l=t.ref();return{exec:async(...t)=>{r.value=!0,o.value=null,u.value=null;let s=t&&e.length!==t.length&&t.length>0&&a(t[t.length-1])?t[t.length-1]:n;const i=l.value=e(...t);try{const e=await i;return l.value===i&&(u.value=e),e}catch(e){return l.value===i&&(o.value=e,u.value=null),s?i:void 0}finally{l.value===i&&(r.value=!1)}},result:u,promise:l,loading:r,error:o}}const p=Symbol("RetryId"),y=Symbol("CancellationToken"),g=async(e,t,n,r)=>{const o=t[p].value;let u=-1;const a=e.maxRetries||9001,i=e.retryDelay||h;t.retryErrors.value=[],t.isRetrying.value=!1,t.nextRetry.value=void 0;let v=void 0;do{let e=!1,d=null;try{if(++u,d=r?n(...r):n(),c(d)&&(d=await d),t[y].value)return null;e=!0}catch(e){d=null,t.retryErrors.value.push(e)}if(o!==t[p].value)return d;if(e)return t.isRetrying.value=!1,t.nextRetry.value=void 0,d;if(u>=a)return t.isRetrying.value=!1,t.nextRetry.value=void 0,Promise.reject(new Error(`[useRetry] max retries reached ${a}`));t.isRetrying.value=!0;const m=Date.now(),g=i(u),h=c(g)?await g:g;if(!c(g)||h){if(s(h))v=h;else{if(!l(h))throw new Error(`[useRetry] invalid value received from options.retryDelay '${typeof h}'`);v=h.getTime()}v<m?t.nextRetry.value=m+v:(t.nextRetry.value=v,v-=m),v>0&&await f(v)}if(t[y].value)return null;if(o!==t[p].value)return d}while(u<9e3);return null};const h=()=>0;function w(e,t,n){return b(e,t,n)}function b(e,t=50,n={isImmediate:!1}){let r;return function(...o){const u=this,a=n.isImmediate&&void 0===r;void 0!==r&&clearTimeout(r),r=setTimeout((function(){r=void 0,n.isImmediate||e.apply(u,o)}),t),a&&e.apply(u,o)}}function E(e){const n=r(e.currentPage),o=r(e.pageSize),u=t.ref(0),a=r(e.total),l=t.computed({get:()=>u.value,set(e){"number"==typeof e?u.value=Math.min(e,a.value):console.warn(`[offset] expected number but got: '${typeof e}' value: '${e}'`)}}),s=t.computed({get:()=>n.value,set(e){"number"==typeof e?(n.value=d(e,1,v.value),l.value=(n.value-1)*i.value):console.warn(`[currentPage] expected number but got: '${typeof e}' value: '${e}'`)}}),i=t.computed({get:()=>o.value,set(e){"number"==typeof e?o.value=e:console.warn(`[pageSize] expected number but got: '${typeof e}' value: '${e}'`)}}),v=t.computed(()=>Math.ceil(a.value/i.value));s.value=n.value;return t.watch([a,i],()=>{s.value>v.value&&(s.value=v.value)},{lazy:!0}),{pageSize:i,total:a,currentPage:s,offset:l,lastPage:v,next:()=>++s.value,prev:()=>--s.value,first:()=>s.value=1,last:()=>s.value=v.value}}function R(e,n,o,u){const a=r(e),l=()=>a.value.removeEventListener(n,o);return t.onMounted(()=>a.value.addEventListener(n,o,u)),t.onUnmounted(l),l}function x(e){const n=t.ref(matchMedia(e)),r=t.ref(n.value.matches),o=e=>{r.value=e.matches};n.value.addEventListener("change",o,{passive:!0});const u=()=>n.value.removeEventListener("change",o);return t.onUnmounted(u),{mediaQueryList:n,remove:u,matches:r}}const S=new Map,M=new WeakMap;return e.debounce=b,e.exponentialDelay=e=>{const t=100*Math.pow(2,e);return t+.2*t*Math.random()},e.isArray=o,e.isBoolean=a,e.isDate=l,e.isElement=v,e.isFunction=u,e.isNumber=s,e.isObject=i,e.isPromise=c,e.isString=e=>"string"==typeof e,e.isSymbol=e=>"symbol"==typeof e,e.minMax=d,e.noDelay=h,e.promisedTimeout=f,e.unwrap=n,e.useArrayPagination=function(e,n){const o=r(e),u=E({currentPage:1,pageSize:10,...n,total:t.computed(()=>o.value.length)}),a=t.computed(()=>{const e=o.value;return Array.isArray(e)?e.slice(u.offset.value,u.offset.value+u.pageSize.value):[]});return{...u,result:a}},e.useBreakpoint=function(e){const n={},r=new Map,o=t.ref();let u=[];const a=[];for(const o in e){const l=e[o];if(s(l)){const e=t.ref(!1);n[o]=e,r.set(l,{name:o,valid:e}),u.push(l)}else{const{matches:e,remove:t}=x(l);n[o]=e,a.push(t)}}u=u.sort((e,t)=>t-e);const l=()=>{const e=window.innerWidth;let t=void 0;for(let n=0;n<u.length;n++){const o=u[n],a=r.get(o);a.valid.value=e>=o,e>=o&&void 0===t&&(t=a.name)}o.value=t},i=w(l,10),v=()=>window.removeEventListener("resize",i);return t.onMounted(()=>{l(),window.addEventListener("resize",i,{passive:!0})}),t.onUnmounted(()=>{v(),a.forEach(e=>e())}),{...n,remove:v,current:o}},e.useCancellablePromise=function(e,n=!1){const r=t.ref(!1);let o=void 0;return{...m((...t)=>(e=>new Promise((t,n)=>{o=e=>{r.value=!0,n(e)},e.then(t).catch(n)}))(e(...t)),n),cancel:e=>o(e),cancelled:r}},e.useDebounce=w,e.useEvent=R,e.useFetch=function(e){const n=t.ref(null),r=t.ref(null),o=!e||!1!==e.isJson,u=!e||!1!==e.parseImmediate,a=m(async(e,t)=>{const a=await fetch(e,t);if(o){const e=a.json().then(e=>n.value=e).catch(e=>{n.value=null,r.value=e});u&&await e}return a}),l=t.computed(()=>a.result.value&&a.result.value.status||null),s=t.computed(()=>a.result.value&&a.result.value.statusText||null);return{...a,json:n,jsonError:r,status:l,statusText:s}},e.useIntersectionObserver=function(e,o){const u=e?r(e):void 0,a=!u||!v(u.value)&&u.value?void 0:u,l=t.computed(()=>o?n(o):a?void 0:n(e)),s=t.ref(a&&a.value?[a.value]:[]),i=t.computed(()=>s.value.length>0&&s.value.every(e=>e.isIntersecting)),c=e=>{s.value=e};let f=t.ref();t.watch(l,e=>{f.value&&f.value.disconnect();const t=e&&e&&{root:n(e.root),rootMargin:n(e.rootMargin),threshold:n(e.threshold)}||void 0;f.value=new IntersectionObserver(c,t),s.value.map(e=>e.target).forEach(f.value.observe)},{deep:!0});const d=e=>{const t=n(e);f.value.observe(t)},m=()=>f.value.disconnect();return a&&(a.value||t.onMounted(()=>{a.value&&d(a)}),t.onUnmounted(()=>{m()})),{elements:s,observe:d,unobserve:e=>{const t=n(e);f.value.unobserve(t)},disconnect:m,isIntersecting:i}},e.useLocalStorage=function(e,n){let o=!1,u=S.get(e);const a=localStorage.getItem(e),l=u&&M.get(u)||!!n&&r(n)||t.ref(null);if(a&&!u)try{l.value=JSON.parse(a),o=!1}catch(t){console.warn("[useLocalStorage] error parsing value from localStorage",e,t)}return u||(u={},S.set(e,u),M.set(u,l),t.watch(l,t=>{void 0!==t?b(()=>localStorage.setItem(e,JSON.stringify(t)),100)():localStorage.removeItem(e)},{deep:!0,lazy:o})),{storage:l,clear:()=>{S.forEach(e=>{const t=M.get(e);t&&(t.value=void 0),M.delete(e)}),S.clear()},remove:()=>{S.delete(e),M.delete(u),l.value=void 0}}},e.useMatchMedia=x,e.useOnMouseMove=function(e,n,r){const o=t.ref(0),u=t.ref(0);let a=e=>{o.value=e.x,u.value=e.y};const l="number"==typeof n?void 0:n;("number"==typeof n?n:r)&&(a=w(a,r));const s=R(e,"mousemove",a,l);return{mouseX:o,mouseY:u,remove:s}},e.useOnResize=function(e,n,o){const u=r(e),a=t.ref(u.value&&u.value.clientHeight),l=t.ref(u.value&&u.value.clientWidth);let s=()=>{a.value=u.value.clientHeight,l.value=u.value.clientWidth};const i="number"==typeof n?void 0:n;("number"==typeof n?n:o)&&(s=w(s,o));const v=R(window,"resize",s,i||{passive:!0});return{height:a,width:l,remove:v}},e.useOnScroll=function(e,n,o){const u=r(e),a=t.ref(u.value&&u.value.scrollTop),l=t.ref(u.value&&u.value.scrollLeft);let s=e=>{a.value=u.value.scrollTop,l.value=u.value.scrollLeft};const i="number"==typeof n?void 0:n;("number"==typeof n?n:o)&&(s=w(s,o));const v=R(u,"scroll",s,i);return{scrollTop:a,scrollLeft:l,remove:v}},e.usePagination=E,e.usePromise=m,e.useRetry=function(e,n){const r=!e||u(e)?{}:e,o=u(e)?e:n;if(!u(e)&&!i(e))throw new Error("[useRetry] options needs to be 'object'");if(o&&!u(o))throw new Error("[useRetry] factory needs to be 'function'");const a=t.ref(!1),l=t.ref(),s=t.ref([]),v={value:!1},c={isRetrying:a,retryCount:t.computed(()=>s.value.length),nextRetry:l,retryErrors:s,[p]:{value:0},[y]:v},f=o?(...e)=>(++c[p].value,g(r,c,o,e)):e=>(++c[p].value,g(r,c,e,void 0));return{...c,cancel:()=>{c.isRetrying.value=!1,c.retryErrors.value.push(new Error("[useRetry] cancelled")),c.nextRetry.value=void 0,v.value=!0},exec:f}},e.useWebSocket=function(e,n){const r=new WebSocket(e,n),o=t.ref(null),u=t.ref(),a=t.ref(null),l=t.ref(!1),s=t.ref(!1),i=t.ref(!1);let v=Date.now()||void 0;return r.addEventListener("message",e=>{o.value=e,a.value=e.data,Date.now()-v<2&&console.warn('[useWebSocket] message rate is too high, if you are using "data" or "messageEvent" you might not get updated of all the messages. Use "ws..addEventListener("message", handler)" instead'),v=Date.now()}),r.addEventListener("error",e=>{u.value=e,i.value=!0}),r.addEventListener("close",()=>{l.value=!1,s.value=!0}),r.addEventListener("open",()=>{l.value=!0,s.value=!1}),{ws:r,send:e=>r.send(e),close:(e,t)=>{r.close(e,t)},messageEvent:o,errorEvent:u,data:a,isOpen:l,isClosed:s,errored:i}},e.wrap=r,e}({},vueCompositionApi);
var vueComposable=function(e,t){"use strict";function n(e){return t.isRef(e)?e.value:e}function r(e){return t.isRef(e)?e:t.ref(e)}const o=Array.isArray,a=e=>"function"==typeof e,u=e=>"boolean"==typeof e,l=e=>i(e)&&a(e.getTime),s=e=>"number"==typeof e,i=e=>null!==e&&"object"==typeof e,v=e=>i(e)&&!!e.tagName;function c(e){return i(e)&&a(e.then)&&a(e.catch)}const f=()=>{};function d(e){return new Promise(t=>{setTimeout(t,e)})}function m(e,t,n){return e<t?t:e>n?n:e}function p(e,n=!1){if(!e)throw new Error(`[usePromise] argument can't be '${e}'`);if("function"!=typeof e)throw new Error(`[usePromise] expects function, but received ${typeof e}`);const r=t.ref(!1),o=t.ref(null),a=t.ref(null),l=t.ref();return{exec:async(...t)=>{r.value=!0,o.value=null,a.value=null;let s=t&&e.length!==t.length&&t.length>0&&u(t[t.length-1])?t[t.length-1]:n;const i=l.value=e(...t);try{const e=await i;return l.value===i&&(a.value=e),e}catch(e){return l.value===i&&(o.value=e,a.value=null),s?i:void 0}finally{l.value===i&&(r.value=!1)}},result:a,promise:l,loading:r,error:o}}const y=Symbol("RetryId"),g=Symbol("CancellationToken"),h=async(e,t,n,r)=>{const o=t[y].value;let a=-1;const u=e.maxRetries||9001,i=e.retryDelay||w;t.retryErrors.value=[],t.isRetrying.value=!1,t.nextRetry.value=void 0;let v=void 0;do{let e=!1,f=null;try{if(++a,f=r?n(...r):n(),c(f)&&(f=await f),t[g].value)return null;e=!0}catch(e){f=null,t.retryErrors.value.push(e)}if(o!==t[y].value)return f;if(e)return t.isRetrying.value=!1,t.nextRetry.value=void 0,f;if(a>=u)return t.isRetrying.value=!1,t.nextRetry.value=void 0,Promise.reject(new Error(`[useRetry] max retries reached ${u}`));t.isRetrying.value=!0;const m=Date.now(),p=i(a),h=c(p)?await p:p;if(!c(p)||h){if(s(h))v=h;else{if(!l(h))throw new Error(`[useRetry] invalid value received from options.retryDelay '${typeof h}'`);v=h.getTime()}v<m?t.nextRetry.value=m+v:(t.nextRetry.value=v,v-=m),v>0&&await d(v)}if(t[g].value)return null;if(o!==t[y].value)return f}while(a<9e3);return null};const w=()=>0;function b(e,t,n){return E(e,t,n)}function E(e,t=50,n={isImmediate:!1}){let r;return function(...o){const a=this,u=n.isImmediate&&void 0===r;void 0!==r&&clearTimeout(r),r=setTimeout((function(){r=void 0,n.isImmediate||e.apply(a,o)}),t),u&&e.apply(a,o)}}function R(e){const n=r(e.currentPage),o=r(e.pageSize),a=t.ref(0),u=r(e.total),l=t.computed({get:()=>a.value,set(e){"number"==typeof e?a.value=Math.min(e,u.value):console.warn(`[offset] expected number but got: '${typeof e}' value: '${e}'`)}}),s=t.computed({get:()=>n.value,set(e){"number"==typeof e?(n.value=m(e,1,v.value),l.value=(n.value-1)*i.value):console.warn(`[currentPage] expected number but got: '${typeof e}' value: '${e}'`)}}),i=t.computed({get:()=>o.value,set(e){"number"==typeof e?o.value=e:console.warn(`[pageSize] expected number but got: '${typeof e}' value: '${e}'`)}}),v=t.computed(()=>Math.ceil(u.value/i.value));s.value=n.value;return t.watch([u,i],()=>{s.value>v.value&&(s.value=v.value)},{lazy:!0}),{pageSize:i,total:u,currentPage:s,offset:l,lastPage:v,next:()=>++s.value,prev:()=>--s.value,first:()=>s.value=1,last:()=>s.value=v.value}}function x(e,n,o,a){const u=r(e),l=()=>u.value.removeEventListener(n,o);return t.onMounted(()=>u.value.addEventListener(n,o,a)),t.onUnmounted(l),l}function S(e){const n=t.ref(matchMedia(e)),r=t.ref(n.value.matches),o=e=>{r.value=e.matches};n.value.addEventListener("change",o,{passive:!0});const a=()=>n.value.removeEventListener("change",o);return t.onUnmounted(a),{mediaQueryList:n,remove:a,matches:r}}const M=new Map,L=new WeakMap;return e.NO_OP=f,e.debounce=E,e.exponentialDelay=e=>{const t=100*Math.pow(2,e);return t+.2*t*Math.random()},e.isArray=o,e.isBoolean=u,e.isDate=l,e.isElement=v,e.isFunction=a,e.isNumber=s,e.isObject=i,e.isPromise=c,e.isString=e=>"string"==typeof e,e.isSymbol=e=>"symbol"==typeof e,e.minMax=m,e.noDelay=w,e.promisedTimeout=d,e.unwrap=n,e.useArrayPagination=function(e,n){const o=r(e),a=R({currentPage:1,pageSize:10,...n,total:t.computed(()=>o.value.length)}),u=t.computed(()=>{const e=o.value;return Array.isArray(e)?e.slice(a.offset.value,a.offset.value+a.pageSize.value):[]});return{...a,result:u}},e.useBreakpoint=function(e){const n={},r=new Map,o=t.ref();let a=[];const u=[];for(const o in e){const l=e[o];if(s(l)){const e=t.ref(!1);n[o]=e,r.set(l,{name:o,valid:e}),a.push(l)}else{const{matches:e,remove:t}=S(l);n[o]=e,u.push(t)}}a=a.sort((e,t)=>t-e);const l=()=>{const e=window.innerWidth;let t=void 0;for(let n=0;n<a.length;n++){const o=a[n],u=r.get(o);u.valid.value=e>=o,e>=o&&void 0===t&&(t=u.name)}o.value=t},i=b(l,10),v=()=>window.removeEventListener("resize",i);return t.onMounted(()=>{l(),window.addEventListener("resize",i,{passive:!0})}),t.onUnmounted(()=>{v(),u.forEach(e=>e())}),{...n,remove:v,current:o}},e.useCancellablePromise=function(e,n=!1){const r=t.ref(!1);let o=void 0;return{...p((...t)=>(e=>new Promise((t,n)=>{o=e=>{r.value=!0,n(e)},e.then(t).catch(n)}))(e(...t)),n),cancel:e=>o(e),cancelled:r}},e.useDebounce=b,e.useEvent=x,e.useFetch=function(e){const n=t.ref(null),r=t.ref(null),o=!e||!1!==e.isJson,a=!e||!1!==e.parseImmediate,u=p(async(e,t)=>{const u=await fetch(e,t);if(o){const e=u.json().then(e=>n.value=e).catch(e=>{n.value=null,r.value=e});a&&await e}return u}),l=t.computed(()=>u.result.value&&u.result.value.status||null),s=t.computed(()=>u.result.value&&u.result.value.statusText||null);return{...u,json:n,jsonError:r,status:l,statusText:s}},e.useIntersectionObserver=function(e,o){const a=e?r(e):void 0,u=!a||!v(a.value)&&a.value?void 0:a,l=t.computed(()=>o?n(o):u?void 0:n(e)),s=t.ref(u&&u.value?[u.value]:[]),i=t.computed(()=>s.value.length>0&&s.value.every(e=>e.isIntersecting)),c=e=>{s.value=e};let f=t.ref();t.watch(l,e=>{f.value&&f.value.disconnect();const t=e&&e&&{root:n(e.root),rootMargin:n(e.rootMargin),threshold:n(e.threshold)}||void 0;f.value=new IntersectionObserver(c,t),s.value.map(e=>e.target).forEach(f.value.observe)},{deep:!0});const d=e=>{const t=n(e);f.value.observe(t)},m=()=>f.value.disconnect();return u&&(u.value||t.onMounted(()=>{u.value&&d(u)}),t.onUnmounted(()=>{m()})),{elements:s,observe:d,unobserve:e=>{const t=n(e);f.value.unobserve(t)},disconnect:m,isIntersecting:i}},e.useLocalStorage=function(e,n){let o=!1,a=M.get(e);const u=localStorage.getItem(e),l=a&&L.get(a)||!!n&&r(n)||t.ref(null);if(u&&!a)try{l.value=JSON.parse(u),o=!1}catch(t){console.warn("[useLocalStorage] error parsing value from localStorage",e,t)}return a||(a={},M.set(e,a),L.set(a,l),t.watch(l,t=>{void 0!==t?E(()=>localStorage.setItem(e,JSON.stringify(t)),100)():localStorage.removeItem(e)},{deep:!0,lazy:o})),{storage:l,clear:()=>{M.forEach(e=>{const t=L.get(e);t&&(t.value=void 0),L.delete(e)}),M.clear()},remove:()=>{M.delete(e),L.delete(a),l.value=void 0}}},e.useMatchMedia=S,e.useNetworkInformation=function(){const e=navigator.connection||navigator.mozConnection||navigator.webkitConnection,n=t.computed(()=>!!e),r=t.ref(0),o=t.ref(0),a=t.ref("unknown"),u=t.ref(0),l=t.ref(!1),s=t.ref("none");let i=f,v=f;return e?(i=()=>{r.value=e.downlink,o.value=e.downlinkMax,a.value=e.effectiveType,u.value=e.rtt,l.value=e.saveData,s.value=e.type},v=()=>{e.removeEventListener("change",i)},e.addEventListener("change",i,{passive:!0}),i(),t.onUnmounted(v)):console.warn("[navigator.connection] not found, networkInformation not available."),{supported:n,downlink:r,downlinkMax:o,effectiveType:a,rtt:u,saveData:l,type:s,remove:v}},e.useOnMouseMove=function(e,n,r){const o=t.ref(0),a=t.ref(0);let u=e=>{o.value=e.x,a.value=e.y};const l="number"==typeof n?void 0:n;("number"==typeof n?n:r)&&(u=b(u,r));const s=x(e,"mousemove",u,l);return{mouseX:o,mouseY:a,remove:s}},e.useOnResize=function(e,n,o){const a=r(e),u=t.ref(a.value&&a.value.clientHeight),l=t.ref(a.value&&a.value.clientWidth);let s=()=>{u.value=a.value.clientHeight,l.value=a.value.clientWidth};const i="number"==typeof n?void 0:n;("number"==typeof n?n:o)&&(s=b(s,o));const v=x(window,"resize",s,i||{passive:!0});return{height:u,width:l,remove:v}},e.useOnScroll=function(e,n,o){const a=r(e),u=t.ref(a.value&&a.value.scrollTop),l=t.ref(a.value&&a.value.scrollLeft);let s=e=>{u.value=a.value.scrollTop,l.value=a.value.scrollLeft};const i="number"==typeof n?void 0:n;("number"==typeof n?n:o)&&(s=b(s,o));const v=x(a,"scroll",s,i);return{scrollTop:u,scrollLeft:l,remove:v}},e.usePagination=R,e.usePromise=p,e.useRetry=function(e,n){const r=!e||a(e)?{}:e,o=a(e)?e:n;if(!a(e)&&!i(e))throw new Error("[useRetry] options needs to be 'object'");if(o&&!a(o))throw new Error("[useRetry] factory needs to be 'function'");const u=t.ref(!1),l=t.ref(),s=t.ref([]),v={value:!1},c={isRetrying:u,retryCount:t.computed(()=>s.value.length),nextRetry:l,retryErrors:s,[y]:{value:0},[g]:v},f=o?(...e)=>(++c[y].value,h(r,c,o,e)):e=>(++c[y].value,h(r,c,e,void 0));return{...c,cancel:()=>{c.isRetrying.value=!1,c.retryErrors.value.push(new Error("[useRetry] cancelled")),c.nextRetry.value=void 0,v.value=!0},exec:f}},e.useWebSocket=function(e,n){const r=new WebSocket(e,n),o=t.ref(null),a=t.ref(),u=t.ref(null),l=t.ref(!1),s=t.ref(!1),i=t.ref(!1);let v=Date.now()||void 0;return r.addEventListener("message",e=>{o.value=e,u.value=e.data,Date.now()-v<2&&console.warn('[useWebSocket] message rate is too high, if you are using "data" or "messageEvent" you might not get updated of all the messages. Use "ws..addEventListener("message", handler)" instead'),v=Date.now()}),r.addEventListener("error",e=>{a.value=e,i.value=!0}),r.addEventListener("close",()=>{l.value=!1,s.value=!0}),r.addEventListener("open",()=>{l.value=!0,s.value=!1}),{ws:r,send:e=>r.send(e),close:(e,t)=>{r.close(e,t)},messageEvent:o,errorEvent:a,data:u,isOpen:l,isClosed:s,errored:i}},e.wrap=r,e}({},vueCompositionApi);

@@ -0,0 +0,0 @@ 'use strict'

{
"name": "vue-composable",
"version": "1.0.0-dev.3",
"version": "1.0.0-dev.4",
"description": "vue-composable",

@@ -40,4 +40,4 @@ "main": "index.js",

"dependencies": {
"@vue-composable/core": "1.0.0-dev.3",
"@vue-composable/web": "1.0.0-dev.3",
"@vue-composable/core": "1.0.0-dev.4",
"@vue-composable/web": "1.0.0-dev.4",
"@vue/composition-api": "^0.3.4",

@@ -44,0 +44,0 @@ "vue": "^2.6.10"

@@ -60,2 +60,3 @@ # vue-composable

- [IntersectionObserver](https://pikax.me/vue-composable/composable/web/intersectionObserver) - reactive `IntersectionObserver`
- [NetworkInformation](https://pikax.me/vue-composable/composable/web/networkInformation) - reactive `NetworkInformation` wrapper

@@ -62,0 +63,0 @@ ### External

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