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

@vueuse/core

Package Overview
Dependencies
Maintainers
1
Versions
358
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vueuse/core - npm Package Compare versions

Comparing version 3.0.0-alpha.21 to 3.0.0-alpha.22

2

dist/esm/index.d.ts

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

export declare const version = "3.0.0-alpha.21";
export declare const version = "3.0.0-alpha.22";
export * from './useAsyncState';

@@ -3,0 +3,0 @@ export * from './useBattery';

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

export var version = '3.0.0-alpha.21';
export var version = '3.0.0-alpha.22';
export * from './useAsyncState';

@@ -3,0 +3,0 @@ export * from './useBattery';

import { Ref } from '../api';
interface ParallaxOptions {
mouseXMultiplier: number;
mouseYMultiplier: number;
deviceAlphaMultiplier: number;
deviceBetaMultiplier: number;
refEl?: Ref<Element>;
}
export declare function useParallax(options?: Partial<ParallaxOptions>): {
export declare function useParallax(targetElement?: Ref<Element>): {
roll: import("@vue/reactivity").ComputedRef<number>;

@@ -14,2 +7,1 @@ tilt: import("@vue/reactivity").ComputedRef<number>;

};
export {};
import { computed } from '../api';
import { useDeviceOrientation } from '../useDeviceOrientation';
import { useMouse } from '../useMouse';
var defaultParallaxOptions = {
mouseXMultiplier: 1,
mouseYMultiplier: 1,
deviceAlphaMultiplier: 0.5,
deviceBetaMultiplier: 0.5,
};
export function useParallax(options) {
var _options = Object.assign({}, defaultParallaxOptions, options);
export function useParallax(targetElement) {
var _a = useDeviceOrientation(), deviceBeta = _a.beta, deviceGamma = _a.gamma;
var _b = useMouse(_options.refEl, false), elementX = _b.elementX, elementY = _b.elementY, elementWidth = _b.elementWidth, elementHeight = _b.elementHeight;
var _b = useMouse(targetElement, false), elementX = _b.elementX, elementY = _b.elementY, elementWidth = _b.elementWidth, elementHeight = _b.elementHeight;
var source = computed(function () {

@@ -27,5 +20,5 @@ if (deviceBeta.value != null && deviceBeta.value != null)

return deviceGamma.value / 180;
return (elementY.value - elementHeight.value / 2) / elementHeight.value;
return -(elementY.value - elementHeight.value / 2) / elementHeight.value;
});
return { roll: roll, tilt: tilt, source: source };
}
import { ref, watch } from '../api';
import { useEventListener } from '../useEventListener';
export function useStoragePlain(key, defaultValue, storage) {
if (storage === void 0) { storage = localStorage; }
var data = ref(defaultValue);
try {
var rawValue = storage.getItem(key);
if (!rawValue) {
if (defaultValue)
function read() {
try {
var rawValue = storage.getItem(key);
if (!rawValue && defaultValue) {
storage.setItem(key, defaultValue);
rawValue = defaultValue;
}
else {
data.value = rawValue || undefined;
}
}
else {
data.value = rawValue || undefined;
catch (e) {
console.warn(e);
}
}
catch (e) {
console.warn(e);
}
read();
useEventListener('storage', read);
watch(data, function () {

@@ -19,0 +24,0 @@ try {

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

export declare const version = "3.0.0-alpha.21";
export declare const version = "3.0.0-alpha.22";
export * from './useAsyncState';

@@ -3,0 +3,0 @@ export * from './useBattery';

@@ -6,3 +6,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.version = '3.0.0-alpha.21';
exports.version = '3.0.0-alpha.22';
__export(require("./useAsyncState"));

@@ -9,0 +9,0 @@ __export(require("./useBattery"));

import { Ref } from '../api';
interface ParallaxOptions {
mouseXMultiplier: number;
mouseYMultiplier: number;
deviceAlphaMultiplier: number;
deviceBetaMultiplier: number;
refEl?: Ref<Element>;
}
export declare function useParallax(options?: Partial<ParallaxOptions>): {
export declare function useParallax(targetElement?: Ref<Element>): {
roll: import("@vue/reactivity").ComputedRef<number>;

@@ -14,2 +7,1 @@ tilt: import("@vue/reactivity").ComputedRef<number>;

};
export {};

@@ -6,12 +6,5 @@ "use strict";

var useMouse_1 = require("../useMouse");
var defaultParallaxOptions = {
mouseXMultiplier: 1,
mouseYMultiplier: 1,
deviceAlphaMultiplier: 0.5,
deviceBetaMultiplier: 0.5,
};
function useParallax(options) {
var _options = Object.assign({}, defaultParallaxOptions, options);
function useParallax(targetElement) {
var _a = useDeviceOrientation_1.useDeviceOrientation(), deviceBeta = _a.beta, deviceGamma = _a.gamma;
var _b = useMouse_1.useMouse(_options.refEl, false), elementX = _b.elementX, elementY = _b.elementY, elementWidth = _b.elementWidth, elementHeight = _b.elementHeight;
var _b = useMouse_1.useMouse(targetElement, false), elementX = _b.elementX, elementY = _b.elementY, elementWidth = _b.elementWidth, elementHeight = _b.elementHeight;
var source = api_1.computed(function () {

@@ -30,3 +23,3 @@ if (deviceBeta.value != null && deviceBeta.value != null)

return deviceGamma.value / 180;
return (elementY.value - elementHeight.value / 2) / elementHeight.value;
return -(elementY.value - elementHeight.value / 2) / elementHeight.value;
});

@@ -33,0 +26,0 @@ return { roll: roll, tilt: tilt, source: source };

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var api_1 = require("../api");
var useEventListener_1 = require("../useEventListener");
function useStoragePlain(key, defaultValue, storage) {
if (storage === void 0) { storage = localStorage; }
var data = api_1.ref(defaultValue);
try {
var rawValue = storage.getItem(key);
if (!rawValue) {
if (defaultValue)
function read() {
try {
var rawValue = storage.getItem(key);
if (!rawValue && defaultValue) {
storage.setItem(key, defaultValue);
rawValue = defaultValue;
}
else {
data.value = rawValue || undefined;
}
}
else {
data.value = rawValue || undefined;
catch (e) {
console.warn(e);
}
}
catch (e) {
console.warn(e);
}
read();
useEventListener_1.useEventListener('storage', read);
api_1.watch(data, function () {

@@ -21,0 +26,0 @@ try {

@@ -509,15 +509,19 @@ (function (global, factory) {

var data = runtimeDom.ref(defaultValue);
try {
var rawValue = storage.getItem(key);
if (!rawValue) {
if (defaultValue)
function read() {
try {
var rawValue = storage.getItem(key);
if (!rawValue && defaultValue) {
storage.setItem(key, defaultValue);
rawValue = defaultValue;
}
else {
data.value = rawValue || undefined;
}
}
else {
data.value = rawValue || undefined;
catch (e) {
console.warn(e);
}
}
catch (e) {
console.warn(e);
}
read();
useEventListener('storage', read);
runtimeDom.watch(data, function () {

@@ -708,12 +712,5 @@ try {

var defaultParallaxOptions = {
mouseXMultiplier: 1,
mouseYMultiplier: 1,
deviceAlphaMultiplier: 0.5,
deviceBetaMultiplier: 0.5,
};
function useParallax(options) {
var _options = Object.assign({}, defaultParallaxOptions, options);
function useParallax(targetElement) {
var _a = useDeviceOrientation(), deviceBeta = _a.beta, deviceGamma = _a.gamma;
var _b = useMouse(_options.refEl, false), elementX = _b.elementX, elementY = _b.elementY, elementWidth = _b.elementWidth, elementHeight = _b.elementHeight;
var _b = useMouse(targetElement, false), elementX = _b.elementX, elementY = _b.elementY, elementWidth = _b.elementWidth, elementHeight = _b.elementHeight;
var source = runtimeDom.computed(function () {

@@ -732,3 +729,3 @@ if (deviceBeta.value != null && deviceBeta.value != null)

return deviceGamma.value / 180;
return (elementY.value - elementHeight.value / 2) / elementHeight.value;
return -(elementY.value - elementHeight.value / 2) / elementHeight.value;
});

@@ -844,3 +841,3 @@ return { roll: roll, tilt: tilt, source: source };

var version = '3.0.0-alpha.21';
var version = '3.0.0-alpha.22';

@@ -847,0 +844,0 @@ exports.useAsyncState = useAsyncState;

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

!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("@vue/runtime-dom")):"function"==typeof define&&define.amd?define(["exports","@vue/runtime-dom"],n):n((e=e||self).VueUse={},e.Vue)}(this,function(e,y){"use strict";function i(e,n){void 0===e&&(e=1e3),void 0===n&&(n=!0);var t=y.ref(!1),u=null;function o(){t.value=!1,u&&(clearTimeout(u),u=null)}function r(){o(),u=setTimeout(function(){t.value=!0,u=null},e)}return n&&r(),y.getCurrentInstance()&&y.onUnmounted(o),{ready:t,start:r,stop:o}}function a(n,e){var t=i(e),u=t.ready,o=t.start,r=t.stop;return y.watch(u,function(e){e&&n()},{lazy:!0}),{ready:u,start:o,stop:r}}var l=["chargingchange","chargingtimechange","dischargingtimechange","levelchange"];function v(e,n,t,u){void 0===u&&(u=window),y.onMounted(function(){u.addEventListener(e,n,t)}),y.onUnmounted(function(){u.removeEventListener(e,n,t)})}var u=function(e,i,a,l){return new(a=a||Promise)(function(t,n){function u(e){try{r(l.next(e))}catch(e){n(e)}}function o(e){try{r(l.throw(e))}catch(e){n(e)}}function r(e){var n;e.done?t(e.value):((n=e.value)instanceof a?n:new a(function(e){e(n)})).then(u,o)}r((l=l.apply(e,i||[])).next())})},o=function(t,u){var o,r,i,e,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return e={next:n(0),throw:n(1),return:n(2)},"function"==typeof Symbol&&(e[Symbol.iterator]=function(){return this}),e;function n(n){return function(e){return function(n){if(o)throw new TypeError("Generator is already executing.");for(;a;)try{if(o=1,r&&(i=2&n[0]?r.return:n[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,n[1])).done)return i;switch(r=0,i&&(n=[2&n[0],i.value]),n[0]){case 0:case 1:i=n;break;case 4:return a.label++,{value:n[1],done:!1};case 5:a.label++,r=n[1],n=[0];continue;case 7:n=a.ops.pop(),a.trys.pop();continue;default:if(!(i=0<(i=a.trys).length&&i[i.length-1])&&(6===n[0]||2===n[0])){a=0;continue}if(3===n[0]&&(!i||n[1]>i[0]&&n[1]<i[3])){a.label=n[1];break}if(6===n[0]&&a.label<i[1]){a.label=i[1],i=n;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(n);break}i[2]&&a.ops.pop(),a.trys.pop();continue}n=u.call(t,a)}catch(e){n=[6,e],r=0}finally{o=i=0}if(5&n[0])throw n[1];return{value:n[0]?n[1]:void 0,done:!0}}([n,e])}}};function f(r,i,a,l){var c,v=!1,f=0;function s(){c&&clearTimeout(c)}function e(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var t=this,u=Date.now()-f;if(!v){var o=function(){f=Date.now(),a&&a.apply(t,e)};l&&!c&&o(),s(),void 0===l&&r<u?o():!0!==i&&(c=setTimeout(l?function(){c=void 0}:o,void 0===l?r-u:r))}}return"boolean"!=typeof i&&(l=!!a,a=i,i=void 0),e.cancel=function(){s(),v=!0},e}function s(){return+Date.now()}var r="object"==typeof window;function d(){var n=y.ref(!1),t=y.ref(0),u=y.ref(0),o=y.ref(0);return v("deviceorientation",function(e){n.value=e.absolute,t.value=e.alpha,u.value=e.beta,o.value=e.gamma}),{isAbsolute:n,alpha:t,beta:u,gamma:o}}var m=["mousemove","mousedown","resize","keydown","touchstart","wheel"];function c(e,n,t){void 0===t&&(t=localStorage);var u=y.ref(n);try{var o=t.getItem(e);o?u.value=o||void 0:n&&t.setItem(e,n)}catch(e){console.warn(e)}return y.watch(u,function(){try{null==u.value?t.removeItem(e):t.setItem(e,u.value)}catch(e){console.warn(e)}},{flush:"sync",lazy:!0}),u}function t(e,n,t){function u(e){return e?JSON.stringify(e):""}function o(e){return e?JSON.parse(e):n||{}}void 0===t&&(t=localStorage);var r=c(e,u(n),t),i=y.ref(o(r.value));function a(){r.value=u(i.value)}return y.watch(r,function(){return i.value=o(r.value)},{flush:"sync",lazy:!0}),y.watch(i,a,{flush:"sync",lazy:!0}),{state:i,update:a}}function n(e){var n;"undefined"!=typeof window&&(n=window.matchMedia(e));var t=y.ref(!!n&&n.matches);function u(e){t.value=e.matches}return y.onMounted(function(){n=n||window.matchMedia(e),t.value=n.matches,n.addListener(u)}),y.onUnmounted(function(){n.removeListener(u)}),t}function g(e,c){void 0===e&&(e=y.ref(document.body)),void 0===c&&(c=!1);var v=y.ref(0),f=y.ref(0),s=y.ref(0),d=y.ref(0),m=y.ref(0),g=y.ref(0),h=y.ref(0),p=y.ref(0),w=y.ref(!1),n=y.watch(e,function(l,e,n){function t(e){var n=(l||document.body).getBoundingClientRect(),t=n.left,u=n.top,o=n.width,r=n.height;v.value=e.pageX,f.value=e.pageY,m.value=t+window.pageXOffset,g.value=u+window.pageYOffset,h.value=r,p.value=o;var i=e.pageX-m.value,a=e.pageY-g.value;w.value=i<0||a<0||i>p.value||a>h.value,!c&&w.value||(s.value=i,d.value=a)}document.addEventListener("mousemove",t),n(function(){document.removeEventListener("mousemove",t)})});return{x:v,y:f,documentX:v,documentY:f,elementX:s,elementY:d,elementPositionX:m,elementPositionY:g,elementHeight:h,elementWidth:p,isOutside:w,stop:n}}function h(){var e=y.ref(!0),n=y.ref(!1),t=y.ref(void 0),u=y.ref(void 0),o=y.ref(void 0),r=y.ref(void 0),i=y.ref("unknown"),a=window.navigator,l="connection"in a?a.connection:void 0;function c(){e.value=a.onLine,t.value=e.value?void 0:Date.now(),l&&(u.value=l.downlink,o.value=l.downlinkMax,r.value=l.effectiveType,n.value=l.saveData,i.value=l.type)}return y.onMounted(c),v("offline",function(){e.value=!1,t.value=Date.now()}),v("online",function(){e.value=!0}),l&&v("change",c,!1,l),{isOnline:e,saveData:n,offlineAt:t,downlink:u,downlinkMax:o,effectiveType:r,type:i}}function p(){return+Date.now()}function w(){var e=y.ref(p()),n=!1,t=function(){requestAnimationFrame(function(){e.value=p(),n&&t()})};return n||(n=!0,t()),y.getCurrentInstance()&&y.onUnmounted(function(){n=!1}),e}var b={mouseXMultiplier:1,mouseYMultiplier:1,deviceAlphaMultiplier:.5,deviceBetaMultiplier:.5};function M(){}e.useAsyncState=function(e,n,t,u){void 0===t&&(t=0),void 0===u&&(u=function(e){});var o=y.ref(n),r=y.ref(!1);function i(){e.then(function(e){o.value=e,r.value=!0}).catch(u)}return t?a(i,t):i(),{state:o,ready:r}},e.useBattery=function(){var e=y.ref(!1),n=y.ref(0),t=y.ref(0),u=y.ref(1),o=y.ref("getBattery"in navigator);function r(){e.value=this.charging,n.value=this.chargingTime||0,t.value=this.dischargingTime||0,u.value=this.level}return y.onMounted(function(){o.value&&navigator.getBattery().then(function(n){r.call(n),l.forEach(function(e){n.addEventListener(e,r)})})}),y.onUnmounted(function(){o.value&&navigator.getBattery().then(function(n){l.forEach(function(e){n.removeEventListener(e,r)})})}),{charging:e,chargingTime:n,dischargingTime:t,level:u,supported:o}},e.useClipboard=function(){var e=this,t=y.ref(""),n=y.ref("clipboard"in navigator);return v("copy",function(){return u(e,void 0,void 0,function(){var n;return o(this,function(e){switch(e.label){case 0:return n=t,[4,navigator.clipboard.readText()];case 1:return n.value=e.sent(),[2]}})})}),{text:t,copy:function(e){return t.value=e,navigator.clipboard.writeText(e)},supported:n}},e.useCounter=function(n){function t(e){return u.value=e}void 0===n&&(n=0);var u=y.ref(n);return{count:u,inc:function(e){return void 0===e&&(e=1),u.value+=e},dec:function(e){return void 0===e&&(e=1),u.value-=e},get:function(){return u.value},set:t,reset:function(e){return void 0===e&&(e=n),t(n=e)}}},e.useDeviceLight=function(){var n=y.ref(null);return v("devicelight",function(e){n.value=e.value}),n},e.useDeviceMotion=function(e){void 0===e&&(e={throttleMs:10});var n=y.ref({x:null,y:null,z:null}),t=y.ref({alpha:null,beta:null,gamma:null}),u=y.ref(0),o=y.ref({x:null,y:null,z:null});function r(e){n.value=e.acceleration,o.value=e.accelerationIncludingGravity,t.value=e.rotationRate,u.value=e.interval}return v("devicemotion",e.throttleMs?f(e.throttleMs,r):r,!1),{acceleration:n,accelerationIncludingGravity:o,rotationRate:t,interval:u}},e.useDeviceOrientation=d,e.useEventListener=v,e.useFullscreen=function(e){void 0===e&&(e=y.ref(document.body));var n=y.ref(!1);function t(){document.fullscreenElement&&document.exitFullscreen(),n.value=!1}return{isFullscreen:n,enterFullscreen:function(){t(),e.value.requestFullscreen().then(function(){n.value=!0})},exitFullscreen:t}},e.useGeolocation=function(e){void 0===e&&(e={enableHighAccuracy:!0,maximumAge:3e4,timeout:27e3});var n,t=y.ref(null),u=y.ref(null),o=y.ref({accuracy:0,latitude:0,longitude:0,altitude:null,altitudeAccuracy:null,heading:null,speed:null});function r(e){t.value=e.timestamp,o.value=e.coords,u.value=null}return y.onMounted(function(){"geolocation"in navigator&&(n=window.navigator.geolocation.watchPosition(r,function(e){u.value=e},e))}),y.onUnmounted(function(){n&&window.navigator.geolocation.clearWatch(n)}),{coords:o,locatedAt:t,error:u}},e.useIdle=function(e,n,t,u){void 0===e&&(e=6e4),void 0===n&&(n=!1),void 0===t&&(t=m),void 0===u&&(u=50);for(var o,r=y.ref(n),i=y.ref(s()),a=f(u,function(){r.value=!1,clearTimeout(o),o=setTimeout(function(){return r.value=!0},e),i.value=s()}),l=0,c=t;l<c.length;l++){v(c[l],a)}return v("visibilitychange",function(){document.hidden||a()},void 0,document),y.onMounted(function(){o=setTimeout(function(){return e=!0,void(r.value=e);var e},e)}),{idle:r,lastActive:i}},e.useInterval=function(e,n){void 0===e&&(e=1e3),void 0===n&&(n=!0);var t=null,u=y.ref(0);function o(){t&&(clearInterval(t),t=null)}function r(){o(),t=setInterval(function(){u.value+=1},e)}return n&&y.onMounted(r),y.getCurrentInstance()&&y.onUnmounted(o),{counter:u,start:r,stop:o}},e.useIntervalFn=function(e,n,t){void 0===n&&(n=1e3),void 0===t&&(t=!0);var u=null;function o(){u&&(clearInterval(u),u=null)}function r(){o(),u=setInterval(e,n)}return t&&r(),y.getCurrentInstance()&&y.onUnmounted(o),{start:r,stop:o}},e.useLocalStorage=function(e,n){return t(e,n,localStorage)},e.useMediaQuery=n,e.useMouse=g,e.useNetwork=h,e.useNow=w,e.useOnline=function(){return h().isOnline},e.useParallax=function(e){var n=Object.assign({},b,e),t=d(),u=t.beta,o=t.gamma,r=g(n.refEl,!1),i=r.elementX,a=r.elementY,l=r.elementWidth,c=r.elementHeight,v=y.computed(function(){return null!=u.value&&null!=u.value?"deviceOrientation":"mouse"});return{roll:y.computed(function(){return"deviceOrientation"===v.value&&null!=u.value?u.value/180:(i.value-l.value/2)/l.value}),tilt:y.computed(function(){return"deviceOrientation"===v.value&&null!=o.value?o.value/180:(a.value-c.value/2)/c.value}),source:v}},e.usePermission=function(e){function n(){t&&(o.value=t.state)}var t=null,u="string"==typeof e?{name:e}:e,o=y.ref("");return"permissions"in navigator&&navigator.permissions.query(u).then(function(e){t=e,n(),v("change",n,void 0,t)}).catch(M),o},e.usePreferredDark=function(){return n("(prefers-color-scheme: dark)")},e.usePreferredLanguages=function(){var e=y.ref(navigator.languages);return v("languagechange",function(){e.value=navigator.languages}),e},e.useRaf=function(){var e=w(),n=y.ref(e.value);return y.computed(function(){return e.value-n.value})},e.useSessionStorage=function(e,n){return t(e,n,sessionStorage)},e.useStorage=t,e.useStoragePlain=c,e.useTimeout=i,e.useTimeoutFn=a,e.useWebWorker=function(e){var n,t=y.ref(null);return y.onMounted(function(){(n=new Worker(e)).onmessage=function(e){t.value=e.data}}),y.onUnmounted(function(){n.terminate()}),{data:t,post:function(e){n&&n.postMessage(e)},terminate:function(){n&&n.terminate()}}},e.useWindowScroll=function(){var e=y.ref(r?window.pageXOffset:0),n=y.ref(r?window.pageYOffset:0);return v("scroll",function(){e.value=window.pageXOffset,n.value=window.pageYOffset},{capture:!1,passive:!0}),{x:e,y:n}},e.useWindowSize=function(e,n){void 0===e&&(e=1/0),void 0===n&&(n=1/0);var t=y.ref(r?window.innerWidth:e),u=y.ref(r?window.innerWidth:n);return r||v("resize",function(){t.value=window.innerWidth,u.value=window.innerHeight}),{width:t,height:u}},e.version="3.0.0-alpha.21",Object.defineProperty(e,"__esModule",{value:!0})});
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("@vue/runtime-dom")):"function"==typeof define&&define.amd?define(["exports","@vue/runtime-dom"],n):n((e=e||self).VueUse={},e.Vue)}(this,function(e,y){"use strict";function a(e,n){void 0===e&&(e=1e3),void 0===n&&(n=!0);var t=y.ref(!1),u=null;function o(){t.value=!1,u&&(clearTimeout(u),u=null)}function r(){o(),u=setTimeout(function(){t.value=!0,u=null},e)}return n&&r(),y.getCurrentInstance()&&y.onUnmounted(o),{ready:t,start:r,stop:o}}function i(n,e){var t=a(e),u=t.ready,o=t.start,r=t.stop;return y.watch(u,function(e){e&&n()},{lazy:!0}),{ready:u,start:o,stop:r}}var l=["chargingchange","chargingtimechange","dischargingtimechange","levelchange"];function f(e,n,t,u){void 0===u&&(u=window),y.onMounted(function(){u.addEventListener(e,n,t)}),y.onUnmounted(function(){u.removeEventListener(e,n,t)})}var u=function(e,a,i,l){return new(i=i||Promise)(function(t,n){function u(e){try{r(l.next(e))}catch(e){n(e)}}function o(e){try{r(l.throw(e))}catch(e){n(e)}}function r(e){var n;e.done?t(e.value):((n=e.value)instanceof i?n:new i(function(e){e(n)})).then(u,o)}r((l=l.apply(e,a||[])).next())})},o=function(t,u){var o,r,a,e,i={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return e={next:n(0),throw:n(1),return:n(2)},"function"==typeof Symbol&&(e[Symbol.iterator]=function(){return this}),e;function n(n){return function(e){return function(n){if(o)throw new TypeError("Generator is already executing.");for(;i;)try{if(o=1,r&&(a=2&n[0]?r.return:n[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,n[1])).done)return a;switch(r=0,a&&(n=[2&n[0],a.value]),n[0]){case 0:case 1:a=n;break;case 4:return i.label++,{value:n[1],done:!1};case 5:i.label++,r=n[1],n=[0];continue;case 7:n=i.ops.pop(),i.trys.pop();continue;default:if(!(a=0<(a=i.trys).length&&a[a.length-1])&&(6===n[0]||2===n[0])){i=0;continue}if(3===n[0]&&(!a||n[1]>a[0]&&n[1]<a[3])){i.label=n[1];break}if(6===n[0]&&i.label<a[1]){i.label=a[1],a=n;break}if(a&&i.label<a[2]){i.label=a[2],i.ops.push(n);break}a[2]&&i.ops.pop(),i.trys.pop();continue}n=u.call(t,i)}catch(e){n=[6,e],r=0}finally{o=a=0}if(5&n[0])throw n[1];return{value:n[0]?n[1]:void 0,done:!0}}([n,e])}}};function v(r,a,i,l){var c,f=!1,v=0;function s(){c&&clearTimeout(c)}function e(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var t=this,u=Date.now()-v;if(!f){var o=function(){v=Date.now(),i&&i.apply(t,e)};l&&!c&&o(),s(),void 0===l&&r<u?o():!0!==a&&(c=setTimeout(l?function(){c=void 0}:o,void 0===l?r-u:r))}}return"boolean"!=typeof a&&(l=!!i,i=a,a=void 0),e.cancel=function(){s(),f=!0},e}function s(){return+Date.now()}var r="object"==typeof window;function d(){var n=y.ref(!1),t=y.ref(0),u=y.ref(0),o=y.ref(0);return f("deviceorientation",function(e){n.value=e.absolute,t.value=e.alpha,u.value=e.beta,o.value=e.gamma}),{isAbsolute:n,alpha:t,beta:u,gamma:o}}var g=["mousemove","mousedown","resize","keydown","touchstart","wheel"];function c(n,t,u){void 0===u&&(u=localStorage);var o=y.ref(t);function e(){try{var e=u.getItem(n);!e&&t?(u.setItem(n,t),e=t):o.value=e||void 0}catch(e){console.warn(e)}}return e(),f("storage",e),y.watch(o,function(){try{null==o.value?u.removeItem(n):u.setItem(n,o.value)}catch(e){console.warn(e)}},{flush:"sync",lazy:!0}),o}function t(e,n,t){function u(e){return e?JSON.stringify(e):""}function o(e){return e?JSON.parse(e):n||{}}void 0===t&&(t=localStorage);var r=c(e,u(n),t),a=y.ref(o(r.value));function i(){r.value=u(a.value)}return y.watch(r,function(){return a.value=o(r.value)},{flush:"sync",lazy:!0}),y.watch(a,i,{flush:"sync",lazy:!0}),{state:a,update:i}}function n(e){var n;"undefined"!=typeof window&&(n=window.matchMedia(e));var t=y.ref(!!n&&n.matches);function u(e){t.value=e.matches}return y.onMounted(function(){n=n||window.matchMedia(e),t.value=n.matches,n.addListener(u)}),y.onUnmounted(function(){n.removeListener(u)}),t}function m(e,c){void 0===e&&(e=y.ref(document.body)),void 0===c&&(c=!1);var f=y.ref(0),v=y.ref(0),s=y.ref(0),d=y.ref(0),g=y.ref(0),m=y.ref(0),h=y.ref(0),p=y.ref(0),w=y.ref(!1),n=y.watch(e,function(l,e,n){function t(e){var n=(l||document.body).getBoundingClientRect(),t=n.left,u=n.top,o=n.width,r=n.height;f.value=e.pageX,v.value=e.pageY,g.value=t+window.pageXOffset,m.value=u+window.pageYOffset,h.value=r,p.value=o;var a=e.pageX-g.value,i=e.pageY-m.value;w.value=a<0||i<0||a>p.value||i>h.value,!c&&w.value||(s.value=a,d.value=i)}document.addEventListener("mousemove",t),n(function(){document.removeEventListener("mousemove",t)})});return{x:f,y:v,documentX:f,documentY:v,elementX:s,elementY:d,elementPositionX:g,elementPositionY:m,elementHeight:h,elementWidth:p,isOutside:w,stop:n}}function h(){var e=y.ref(!0),n=y.ref(!1),t=y.ref(void 0),u=y.ref(void 0),o=y.ref(void 0),r=y.ref(void 0),a=y.ref("unknown"),i=window.navigator,l="connection"in i?i.connection:void 0;function c(){e.value=i.onLine,t.value=e.value?void 0:Date.now(),l&&(u.value=l.downlink,o.value=l.downlinkMax,r.value=l.effectiveType,n.value=l.saveData,a.value=l.type)}return y.onMounted(c),f("offline",function(){e.value=!1,t.value=Date.now()}),f("online",function(){e.value=!0}),l&&f("change",c,!1,l),{isOnline:e,saveData:n,offlineAt:t,downlink:u,downlinkMax:o,effectiveType:r,type:a}}function p(){return+Date.now()}function w(){var e=y.ref(p()),n=!1,t=function(){requestAnimationFrame(function(){e.value=p(),n&&t()})};return n||(n=!0,t()),y.getCurrentInstance()&&y.onUnmounted(function(){n=!1}),e}function b(){}e.useAsyncState=function(e,n,t,u){void 0===t&&(t=0),void 0===u&&(u=function(e){});var o=y.ref(n),r=y.ref(!1);function a(){e.then(function(e){o.value=e,r.value=!0}).catch(u)}return t?i(a,t):a(),{state:o,ready:r}},e.useBattery=function(){var e=y.ref(!1),n=y.ref(0),t=y.ref(0),u=y.ref(1),o=y.ref("getBattery"in navigator);function r(){e.value=this.charging,n.value=this.chargingTime||0,t.value=this.dischargingTime||0,u.value=this.level}return y.onMounted(function(){o.value&&navigator.getBattery().then(function(n){r.call(n),l.forEach(function(e){n.addEventListener(e,r)})})}),y.onUnmounted(function(){o.value&&navigator.getBattery().then(function(n){l.forEach(function(e){n.removeEventListener(e,r)})})}),{charging:e,chargingTime:n,dischargingTime:t,level:u,supported:o}},e.useClipboard=function(){var e=this,t=y.ref(""),n=y.ref("clipboard"in navigator);return f("copy",function(){return u(e,void 0,void 0,function(){var n;return o(this,function(e){switch(e.label){case 0:return n=t,[4,navigator.clipboard.readText()];case 1:return n.value=e.sent(),[2]}})})}),{text:t,copy:function(e){return t.value=e,navigator.clipboard.writeText(e)},supported:n}},e.useCounter=function(n){function t(e){return u.value=e}void 0===n&&(n=0);var u=y.ref(n);return{count:u,inc:function(e){return void 0===e&&(e=1),u.value+=e},dec:function(e){return void 0===e&&(e=1),u.value-=e},get:function(){return u.value},set:t,reset:function(e){return void 0===e&&(e=n),t(n=e)}}},e.useDeviceLight=function(){var n=y.ref(null);return f("devicelight",function(e){n.value=e.value}),n},e.useDeviceMotion=function(e){void 0===e&&(e={throttleMs:10});var n=y.ref({x:null,y:null,z:null}),t=y.ref({alpha:null,beta:null,gamma:null}),u=y.ref(0),o=y.ref({x:null,y:null,z:null});function r(e){n.value=e.acceleration,o.value=e.accelerationIncludingGravity,t.value=e.rotationRate,u.value=e.interval}return f("devicemotion",e.throttleMs?v(e.throttleMs,r):r,!1),{acceleration:n,accelerationIncludingGravity:o,rotationRate:t,interval:u}},e.useDeviceOrientation=d,e.useEventListener=f,e.useFullscreen=function(e){void 0===e&&(e=y.ref(document.body));var n=y.ref(!1);function t(){document.fullscreenElement&&document.exitFullscreen(),n.value=!1}return{isFullscreen:n,enterFullscreen:function(){t(),e.value.requestFullscreen().then(function(){n.value=!0})},exitFullscreen:t}},e.useGeolocation=function(e){void 0===e&&(e={enableHighAccuracy:!0,maximumAge:3e4,timeout:27e3});var n,t=y.ref(null),u=y.ref(null),o=y.ref({accuracy:0,latitude:0,longitude:0,altitude:null,altitudeAccuracy:null,heading:null,speed:null});function r(e){t.value=e.timestamp,o.value=e.coords,u.value=null}return y.onMounted(function(){"geolocation"in navigator&&(n=window.navigator.geolocation.watchPosition(r,function(e){u.value=e},e))}),y.onUnmounted(function(){n&&window.navigator.geolocation.clearWatch(n)}),{coords:o,locatedAt:t,error:u}},e.useIdle=function(e,n,t,u){void 0===e&&(e=6e4),void 0===n&&(n=!1),void 0===t&&(t=g),void 0===u&&(u=50);for(var o,r=y.ref(n),a=y.ref(s()),i=v(u,function(){r.value=!1,clearTimeout(o),o=setTimeout(function(){return r.value=!0},e),a.value=s()}),l=0,c=t;l<c.length;l++){f(c[l],i)}return f("visibilitychange",function(){document.hidden||i()},void 0,document),y.onMounted(function(){o=setTimeout(function(){return e=!0,void(r.value=e);var e},e)}),{idle:r,lastActive:a}},e.useInterval=function(e,n){void 0===e&&(e=1e3),void 0===n&&(n=!0);var t=null,u=y.ref(0);function o(){t&&(clearInterval(t),t=null)}function r(){o(),t=setInterval(function(){u.value+=1},e)}return n&&y.onMounted(r),y.getCurrentInstance()&&y.onUnmounted(o),{counter:u,start:r,stop:o}},e.useIntervalFn=function(e,n,t){void 0===n&&(n=1e3),void 0===t&&(t=!0);var u=null;function o(){u&&(clearInterval(u),u=null)}function r(){o(),u=setInterval(e,n)}return t&&r(),y.getCurrentInstance()&&y.onUnmounted(o),{start:r,stop:o}},e.useLocalStorage=function(e,n){return t(e,n,localStorage)},e.useMediaQuery=n,e.useMouse=m,e.useNetwork=h,e.useNow=w,e.useOnline=function(){return h().isOnline},e.useParallax=function(e){var n=d(),t=n.beta,u=n.gamma,o=m(e,!1),r=o.elementX,a=o.elementY,i=o.elementWidth,l=o.elementHeight,c=y.computed(function(){return null!=t.value&&null!=t.value?"deviceOrientation":"mouse"});return{roll:y.computed(function(){return"deviceOrientation"===c.value&&null!=t.value?t.value/180:(r.value-i.value/2)/i.value}),tilt:y.computed(function(){return"deviceOrientation"===c.value&&null!=u.value?u.value/180:-(a.value-l.value/2)/l.value}),source:c}},e.usePermission=function(e){function n(){t&&(o.value=t.state)}var t=null,u="string"==typeof e?{name:e}:e,o=y.ref("");return"permissions"in navigator&&navigator.permissions.query(u).then(function(e){t=e,n(),f("change",n,void 0,t)}).catch(b),o},e.usePreferredDark=function(){return n("(prefers-color-scheme: dark)")},e.usePreferredLanguages=function(){var e=y.ref(navigator.languages);return f("languagechange",function(){e.value=navigator.languages}),e},e.useRaf=function(){var e=w(),n=y.ref(e.value);return y.computed(function(){return e.value-n.value})},e.useSessionStorage=function(e,n){return t(e,n,sessionStorage)},e.useStorage=t,e.useStoragePlain=c,e.useTimeout=a,e.useTimeoutFn=i,e.useWebWorker=function(e){var n,t=y.ref(null);return y.onMounted(function(){(n=new Worker(e)).onmessage=function(e){t.value=e.data}}),y.onUnmounted(function(){n.terminate()}),{data:t,post:function(e){n&&n.postMessage(e)},terminate:function(){n&&n.terminate()}}},e.useWindowScroll=function(){var e=y.ref(r?window.pageXOffset:0),n=y.ref(r?window.pageYOffset:0);return f("scroll",function(){e.value=window.pageXOffset,n.value=window.pageYOffset},{capture:!1,passive:!0}),{x:e,y:n}},e.useWindowSize=function(e,n){void 0===e&&(e=1/0),void 0===n&&(n=1/0);var t=y.ref(r?window.innerWidth:e),u=y.ref(r?window.innerWidth:n);return r||f("resize",function(){t.value=window.innerWidth,u.value=window.innerHeight}),{width:t,height:u}},e.version="3.0.0-alpha.22",Object.defineProperty(e,"__esModule",{value:!0})});
{
"name": "@vueuse/core",
"version": "3.0.0-alpha.21",
"version": "3.0.0-alpha.22",
"description": "Collection of essential Vue Composition API",

@@ -53,3 +53,5 @@ "main": "dist/main/index.js",

"homepage": "https://github.com/antfu/vueuse#readme",
"dependencies": {},
"dependencies": {
"js-yaml": "^3.13.1"
},
"peerDependencies": {

@@ -72,4 +74,5 @@ "vue": "next"

"@types/inquirer": "6.5.0",
"@types/jest": "24.0.24",
"@types/node": "13.1.0",
"@types/jest": "24.0.25",
"@types/js-yaml": "^3.12.1",
"@types/node": "13.1.1",
"@types/semver": "6.2.0",

@@ -81,9 +84,9 @@ "@vue/babel-preset-jsx": "1.1.2",

"autoprefixer": "9.7.3",
"axios": "^0.19.0",
"axios": "0.19.0",
"babel-loader": "8.0.6",
"babel-preset-vue": "2.0.2",
"commander": "4.0.1",
"consola": "2.11.1",
"consola": "2.11.2",
"eslint": "6.8.0",
"eslint-plugin-jest": "23.1.1",
"eslint-plugin-jest": "23.2.0",
"eslint-plugin-markdown": "1.0.1",

@@ -96,3 +99,3 @@ "fs-extra": "8.1.0",

"lint-staged": "9.5.0",
"loader-utils": "^1.2.3",
"loader-utils": "1.2.3",
"markdown-it": "10.0.0",

@@ -106,15 +109,16 @@ "markdown-it-highlight-lines": "1.0.2",

"postcss-loader": "3.0.0",
"prettier": "^1.19.1",
"prettier": "1.19.1",
"prismjs": "1.17.1",
"raw-loader": "^4.0.0",
"raw-loader": "4.0.0",
"rimraf": "3.0.0",
"rollup": "1.27.14",
"rollup-plugin-gzip": "^2.2.0",
"rollup-plugin-gzip": "2.2.0",
"rollup-plugin-local-resolve": "1.0.7",
"rollup-plugin-uglify": "^6.0.4",
"rollup-plugin-uglify": "6.0.4",
"semver": "7.1.1",
"tailwindcss": "1.1.4",
"ts-jest": "24.2.0",
"typescript": "^3.7.4",
"version-bump-prompt": "5.0.6",
"typescript": "3.7.4",
"typestyle": "^2.0.4",
"version-bump-prompt": "5.0.7",
"vue": "2.6.11",

@@ -121,0 +125,0 @@ "vue-loader": "15.8.3",

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