@vueuse/core
Advanced tools
Comparing version 2.0.0-alpha.19 to 2.0.0-alpha.20
@@ -1,2 +0,2 @@ | ||
export declare const version = "2.0.0-alpha.19"; | ||
export declare const version = "2.0.0-alpha.20"; | ||
export * from './useAsyncState'; | ||
@@ -3,0 +3,0 @@ export * from './useBattery'; |
@@ -1,2 +0,2 @@ | ||
export var version = '2.0.0-alpha.19'; | ||
export var version = '2.0.0-alpha.20'; | ||
export * from './useAsyncState'; | ||
@@ -3,0 +3,0 @@ export * from './useBattery'; |
@@ -1,2 +0,2 @@ | ||
import { Ref } from '@vue/composition-api'; | ||
import { Ref } from '../api'; | ||
export declare type NetworkType = 'bluetooth' | 'cellular' | 'ethernet' | 'none' | 'wifi' | 'wimax' | 'other' | 'unknown'; | ||
@@ -3,0 +3,0 @@ export declare type NetworkEffectiveType = 'slow-2g' | '2g' | '3g' | '4g' | undefined; |
@@ -1,2 +0,2 @@ | ||
import { onMounted, onUnmounted, ref } from '@vue/composition-api'; | ||
import { onMounted, onUnmounted, ref } from '../api'; | ||
export function useNetwork() { | ||
@@ -3,0 +3,0 @@ var isOnline = ref(true); |
export declare type GeneralPermissionDescriptor = PermissionDescriptor | DevicePermissionDescriptor | MidiPermissionDescriptor | PushPermissionDescriptor; | ||
declare type State = PermissionState | ''; | ||
export declare function usePermission(permissionDesc: GeneralPermissionDescriptor | PermissionDescriptor['name']): import("@vue/composition-api").Ref<State>; | ||
export declare function usePermission(permissionDesc: GeneralPermissionDescriptor | PermissionDescriptor['name']): import("@vue/composition-api/dist/reactivity/ref").Ref<State>; | ||
export {}; |
@@ -1,4 +0,3 @@ | ||
import { onUnmounted, onMounted } from '@vue/composition-api'; | ||
import { onUnmounted, onMounted, ref } from '../api'; | ||
import { off, on } from '../utils'; | ||
import { ref } from '../api'; | ||
var noop = function () { }; | ||
@@ -5,0 +4,0 @@ export function usePermission(permissionDesc) { |
@@ -1,2 +0,2 @@ | ||
export declare const version = "2.0.0-alpha.19"; | ||
export declare const version = "2.0.0-alpha.20"; | ||
export * from './useAsyncState'; | ||
@@ -3,0 +3,0 @@ export * from './useBattery'; |
@@ -6,3 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.version = '2.0.0-alpha.19'; | ||
exports.version = '2.0.0-alpha.20'; | ||
__export(require("./useAsyncState")); | ||
@@ -9,0 +9,0 @@ __export(require("./useBattery")); |
@@ -1,2 +0,2 @@ | ||
import { Ref } from '@vue/composition-api'; | ||
import { Ref } from '../api'; | ||
export declare type NetworkType = 'bluetooth' | 'cellular' | 'ethernet' | 'none' | 'wifi' | 'wimax' | 'other' | 'unknown'; | ||
@@ -3,0 +3,0 @@ export declare type NetworkEffectiveType = 'slow-2g' | '2g' | '3g' | '4g' | undefined; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var composition_api_1 = require("@vue/composition-api"); | ||
var api_1 = require("../api"); | ||
function useNetwork() { | ||
var isOnline = composition_api_1.ref(true); | ||
var saveData = composition_api_1.ref(false); | ||
var offlineAt = composition_api_1.ref(undefined); | ||
var downlink = composition_api_1.ref(undefined); | ||
var downlinkMax = composition_api_1.ref(undefined); | ||
var effectiveType = composition_api_1.ref(undefined); | ||
var type = composition_api_1.ref('unknown'); | ||
var isOnline = api_1.ref(true); | ||
var saveData = api_1.ref(false); | ||
var offlineAt = api_1.ref(undefined); | ||
var downlink = api_1.ref(undefined); | ||
var downlinkMax = api_1.ref(undefined); | ||
var effectiveType = api_1.ref(undefined); | ||
var type = api_1.ref('unknown'); | ||
function updateNetworkInformation() { | ||
@@ -31,3 +31,3 @@ isOnline.value = window.navigator.onLine; | ||
}; | ||
composition_api_1.onMounted(function () { | ||
api_1.onMounted(function () { | ||
updateNetworkInformation(); | ||
@@ -39,3 +39,3 @@ window.addEventListener('offline', onOffline); | ||
}); | ||
composition_api_1.onUnmounted(function () { | ||
api_1.onUnmounted(function () { | ||
window.removeEventListener('offline', onOffline); | ||
@@ -42,0 +42,0 @@ window.removeEventListener('online', onOnline); |
export declare type GeneralPermissionDescriptor = PermissionDescriptor | DevicePermissionDescriptor | MidiPermissionDescriptor | PushPermissionDescriptor; | ||
declare type State = PermissionState | ''; | ||
export declare function usePermission(permissionDesc: GeneralPermissionDescriptor | PermissionDescriptor['name']): import("@vue/composition-api").Ref<State>; | ||
export declare function usePermission(permissionDesc: GeneralPermissionDescriptor | PermissionDescriptor['name']): import("@vue/composition-api/dist/reactivity/ref").Ref<State>; | ||
export {}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var composition_api_1 = require("@vue/composition-api"); | ||
var api_1 = require("../api"); | ||
var utils_1 = require("../utils"); | ||
var api_1 = require("../api"); | ||
var noop = function () { }; | ||
@@ -22,3 +21,3 @@ function usePermission(permissionDesc) { | ||
}; | ||
composition_api_1.onMounted(function () { | ||
api_1.onMounted(function () { | ||
if ('permissions' in navigator) { | ||
@@ -34,3 +33,3 @@ navigator.permissions | ||
}); | ||
composition_api_1.onUnmounted(function () { | ||
api_1.onUnmounted(function () { | ||
mounted = false; | ||
@@ -37,0 +36,0 @@ permissionStatus && utils_1.off(permissionStatus, 'change', onChange); |
@@ -744,3 +744,3 @@ (function (global, factory) { | ||
var version = '2.0.0-alpha.19'; | ||
var version = '2.0.0-alpha.20'; | ||
@@ -747,0 +747,0 @@ exports.useAsyncState = useAsyncState; |
@@ -1,1 +0,1 @@ | ||
!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("vue"),require("@vue/composition-api")):"function"==typeof define&&define.amd?define(["exports","vue","@vue/composition-api"],e):e((n=n||self).VueUse={},n.Vue,n.vueCompositionApi)}(this,function(n,e,L){"use strict";e=e&&e.hasOwnProperty("default")?e.default:e;"default"in L&&L.default;function r(n,e){void 0===n&&(n=1e3),void 0===e&&(e=!0);var t=L.ref(!1),o=null;function i(){t.value=!1,o&&(clearTimeout(o),o=null)}function u(){i(),o=setTimeout(function(){t.value=!0,o=null},n)}return e&&u(),L.getCurrentInstance()&&L.onUnmounted(i),{ready:t,start:u,stop:i}}function a(e,n){var t=r(n),o=t.ready,i=t.start,u=t.stop;return L.watch(o,function(n){n&&e()},{lazy:!0}),{ready:o,start:i,stop:u}}var u=["chargingchange","chargingtimechange","dischargingtimechange","levelchange"];function E(){return+Date.now()}function M(n){for(var e=[],t=1;t<arguments.length;t++)e[t-1]=arguments[t];return n.addEventListener.apply(n,e)}function U(n){for(var e=[],t=1;t<arguments.length;t++)e[t-1]=arguments[t];return n.removeEventListener.apply(n,e)}var c="object"==typeof window,b=["mousemove","mousedown","resize","keydown","touchstart","wheel"];function l(n,e,t){void 0===t&&(t=localStorage);var o=L.ref(e);try{var i=t.getItem(n);i?o.value=i||void 0:e&&t.setItem(n,e)}catch(n){console.warn(n)}return L.watch(o,function(){try{null==o.value?t.removeItem(n):t.setItem(n,o.value)}catch(n){console.warn(n)}},{flush:"sync",lazy:!0}),o}function t(n,e,t){function o(n){return n?JSON.stringify(n):""}function i(n){return n?JSON.parse(n):e||{}}void 0===t&&(t=localStorage);var u=l(n,o(e),t),r=L.ref(i(u.value));function a(){u.value=o(r.value)}return L.watch(u,function(){return r.value=i(u.value)},{flush:"sync",lazy:!0}),L.watch(r,a,{flush:"sync",lazy:!0}),{state:r,update:a}}function o(n){var e;"undefined"!=typeof window&&(e=window.matchMedia(n));var t=L.ref(!!e&&e.matches);function o(n){t.value=n.matches}return L.onMounted(function(){e=e||window.matchMedia(n),t.value=e.matches,e.addListener(o)}),L.onUnmounted(function(){e.removeListener(o)}),t}function i(){var n=L.ref(!0),e=L.ref(!1),t=L.ref(void 0),o=L.ref(void 0),i=L.ref(void 0),u=L.ref(void 0),r=L.ref("unknown");function a(){n.value=window.navigator.onLine,t.value=n.value?void 0:Date.now(),"connection"in window.navigator&&(o.value=window.navigator.connection.downlink,i.value=window.navigator.connection.downlinkMax,u.value=window.navigator.connection.effectiveType,e.value=window.navigator.connection.saveData,r.value=window.navigator.connection.type)}function c(){n.value=!1,t.value=Date.now()}function l(){n.value=!0}return L.onMounted(function(){a(),window.addEventListener("offline",c),window.addEventListener("online",l),"connection"in window.navigator&&window.navigator.connection.addEventListener("change",a,!1)}),L.onUnmounted(function(){window.removeEventListener("offline",c),window.removeEventListener("online",l),"connection"in window.navigator&&window.navigator.connection.removeEventListener("change",a,!1)}),{isOnline:n,saveData:e,offlineAt:t,downlink:o,downlinkMax:i,effectiveType:u,type:r}}function f(){return+Date.now()}function v(){var n=L.ref(f()),e=!1,t=function(){requestAnimationFrame(function(){n.value=f(),e&&t()})};return e||(e=!0,t()),L.getCurrentInstance()&&L.onUnmounted(function(){e=!1}),n}function d(){}n.useAsyncState=function(n,e,t,o){void 0===t&&(t=0),void 0===o&&(o=function(n){});var i=L.ref(e),u=L.ref(!1);function r(){n.then(function(n){i.value=n,u.value=!0}).catch(o)}return t?a(r,t):r(),{state:i,ready:u}},n.useBattery=function(){var n=L.ref(!1),e=L.ref(0),t=L.ref(0),o=L.ref(1);function i(){n.value=this.charging,e.value=this.chargingTime||0,t.value=this.dischargingTime||0,o.value=this.level}return L.onMounted(function(){"getBattery"in navigator&&navigator.getBattery().then(function(e){i.call(e),u.forEach(function(n){e.addEventListener(n,i)})})}),L.onUnmounted(function(){"getBattery"in navigator&&navigator.getBattery().then(function(e){u.forEach(function(n){e.removeEventListener(n,i)})})}),{charging:n,chargingTime:e,dischargingTime:t,level:o}},n.useCounter=function(e){function t(n){return o.value=n}void 0===e&&(e=0);var o=L.ref(e);return{count:o,inc:function(n){return void 0===n&&(n=1),o.value+=n},dec:function(n){return void 0===n&&(n=1),o.value-=n},get:function(){return o.value},set:t,reset:function(n){return void 0===n&&(n=e),t(e=n)}}},n.useDeviceOrientation=function(){var e=L.ref(!1),t=L.ref(0),o=L.ref(0),i=L.ref(0);function n(n){e.value=n.absolute,t.value=n.alpha,o.value=n.beta,i.value=n.gamma}return L.onMounted(function(){window.addEventListener("deviceorientation",n)}),L.onUnmounted(function(){window.removeEventListener("deviceorientation",n)}),{isAbsolute:e,alpha:t,beta:o,gamma:i}},n.useFullscreen=function(n){void 0===n&&(n=L.ref(document.body));var e=L.ref(!1);function t(){document.fullscreenElement&&document.exitFullscreen(),e.value=!1}return{isFullscreen:e,enterFullscreen:function(){t(),n.value.requestFullscreen().then(function(){e.value=!0})},exitFullscreen:t}},n.useGeolocation=function(n){void 0===n&&(n={enableHighAccuracy:!0,maximumAge:3e4,timeout:27e3});var e,t=L.ref(null),o=L.ref(null),i=L.ref({accuracy:0,latitude:0,longitude:0,altitude:null,altitudeAccuracy:null,heading:null,speed:null});function u(n){t.value=n.timestamp,i.value=n.coords,o.value=null}return L.onMounted(function(){"geolocation"in navigator&&(e=window.navigator.geolocation.watchPosition(u,function(n){o.value=n},n))}),L.onUnmounted(function(){e&&window.navigator.geolocation.clearWatch(e)}),{coords:i,locatedAt:t,error:o}},n.useIdle=function(e,n,t,o){function i(n){w&&(s.value=n)}void 0===e&&(e=6e4),void 0===n&&(n=!1),void 0===t&&(t=b),void 0===o&&(o=50);var u,r,a,c,l,f,v,d,s=L.ref(n),g=L.ref(E()),w=!0,m=(r=o,v=!(a=function(){s.value=!1,clearTimeout(u),u=setTimeout(function(){return i(!0)},e),g.value=E()}),d=0,"boolean"!=typeof a&&(l=!!c,c=a,a=void 0),p.cancel=function(){h(),v=!0},p);function h(){f&&clearTimeout(f)}function p(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];var t=this,o=Date.now()-d;if(!v){var i=function(){d=Date.now(),c&&c.apply(t,n)};l&&!f&&i(),h(),void 0===l&&r<o?i():!0!==a&&(f=setTimeout(l?function(){f=void 0}:i,void 0===l?r-o:r))}}function y(){document.hidden||m()}return L.onMounted(function(){for(var n=0;n<t.length;n++)M(window,t[n],m);M(document,"visibilitychange",y),u=setTimeout(function(){return i(!0)},e)}),L.onUnmounted(function(){w=!1;for(var n=0;n<t.length;n++)U(window,t[n],m);U(document,"visibilitychange",y)}),{idle:s,lastActive:g}},n.useInterval=function(n,e){void 0===n&&(n=1e3),void 0===e&&(e=!0);var t=null,o=L.ref(0);function i(){t&&(clearInterval(t),t=null)}function u(){i(),t=setInterval(function(){o.value+=1},n)}return e&&L.onMounted(u),L.getCurrentInstance()&&L.onUnmounted(i),{counter:o,start:u,stop:i}},n.useIntervalFn=function(n,e,t){void 0===e&&(e=1e3),void 0===t&&(t=!0);var o=null;function i(){o&&(clearInterval(o),o=null)}function u(){i(),o=setInterval(n,e)}return t&&u(),L.getCurrentInstance()&&L.onUnmounted(i),{start:u,stop:i}},n.useLocalStorage=function(n,e){return t(n,e,localStorage)},n.useMediaQuery=o,n.useMouse=function(n){void 0===n&&(n=L.ref(null));var v=L.ref({docX:0,docY:0,posX:0,posY:0,elX:0,elY:0,elH:0,elW:0}),e=L.watch(n,function(f,n,e){function t(n){var e=(f||document.body).getBoundingClientRect(),t=e.left,o=e.top,i=e.width,u=e.height,r=t+window.pageXOffset,a=o+window.pageYOffset,c=n.pageX-r,l=n.pageY-a;Object.assign(v.value,{docX:n.pageX,docY:n.pageY,posX:r,posY:a,elX:c,elY:l,elH:u,elW:i})}document.addEventListener("mousemove",t),e(function(){document.removeEventListener("mousemove",t)})});return{state:v,stop:e}},n.useNetwork=i,n.useNow=v,n.useOnline=function(){return i().isOnline},n.usePermission=function(n){function e(){t&&o&&(u.value=o.state)}var t=!0,o=null,i="string"==typeof n?{name:n}:n,u=L.ref("");return L.onMounted(function(){"permissions"in navigator&&navigator.permissions.query(i).then(function(n){o=n,e(),M(o,"change",e)}).catch(d)}),L.onUnmounted(function(){t=!1,o&&U(o,"change",e)}),u},n.usePreferredDark=function(){return o("(prefers-color-scheme: dark)")},n.usePreferredLanguages=function(){var n=L.ref(navigator.languages);function e(){n.value=navigator.languages}return L.onMounted(function(){window.addEventListener("languagechange",e)}),L.onUnmounted(function(){window.removeEventListener("languagechange",e)}),n},n.useRaf=function(){var n=v(),e=L.ref(n.value);return L.computed(function(){return n.value-e.value})},n.useSessionStorage=function(n,e){return t(n,e,sessionStorage)},n.useStorage=t,n.useStoragePlain=l,n.useTimeout=r,n.useTimeoutFn=a,n.useWebWorker=function(n){var e,t=L.ref(null);return L.onMounted(function(){(e=new Worker(n)).onmessage=function(n){t.value=n.data}}),L.onUnmounted(function(){e.terminate()}),{data:t,post:function(n){e&&e.postMessage(n)},terminate:function(){e&&e.terminate()}}},n.useWindowScroll=function(){function n(){e.value=window.pageXOffset,t.value=window.pageYOffset}var e=L.ref(c?window.pageXOffset:0),t=L.ref(c?window.pageYOffset:0);return window.addEventListener("scroll",n,{capture:!1,passive:!0}),L.onUnmounted(function(){window.removeEventListener("scroll",n)}),{x:e,y:t}},n.useWindowSize=function(n,e){void 0===n&&(n=1/0),void 0===e&&(e=1/0);var t=L.ref(c?window.innerWidth:n),o=L.ref(c?window.innerWidth:e);if(c){var i=function(){t.value=window.innerWidth,o.value=window.innerHeight};window.addEventListener("resize",i),L.onUnmounted(function(){window.removeEventListener("resize",i)})}return{width:t,height:o}},n.version="2.0.0-alpha.19",Object.defineProperty(n,"__esModule",{value:!0})}); | ||
!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("vue"),require("@vue/composition-api")):"function"==typeof define&&define.amd?define(["exports","vue","@vue/composition-api"],e):e((n=n||self).VueUse={},n.Vue,n.vueCompositionApi)}(this,function(n,e,L){"use strict";e=e&&e.hasOwnProperty("default")?e.default:e;"default"in L&&L.default;function r(n,e){void 0===n&&(n=1e3),void 0===e&&(e=!0);var t=L.ref(!1),o=null;function i(){t.value=!1,o&&(clearTimeout(o),o=null)}function u(){i(),o=setTimeout(function(){t.value=!0,o=null},n)}return e&&u(),L.getCurrentInstance()&&L.onUnmounted(i),{ready:t,start:u,stop:i}}function a(e,n){var t=r(n),o=t.ready,i=t.start,u=t.stop;return L.watch(o,function(n){n&&e()},{lazy:!0}),{ready:o,start:i,stop:u}}var u=["chargingchange","chargingtimechange","dischargingtimechange","levelchange"];function E(){return+Date.now()}function M(n){for(var e=[],t=1;t<arguments.length;t++)e[t-1]=arguments[t];return n.addEventListener.apply(n,e)}function U(n){for(var e=[],t=1;t<arguments.length;t++)e[t-1]=arguments[t];return n.removeEventListener.apply(n,e)}var c="object"==typeof window,b=["mousemove","mousedown","resize","keydown","touchstart","wheel"];function l(n,e,t){void 0===t&&(t=localStorage);var o=L.ref(e);try{var i=t.getItem(n);i?o.value=i||void 0:e&&t.setItem(n,e)}catch(n){console.warn(n)}return L.watch(o,function(){try{null==o.value?t.removeItem(n):t.setItem(n,o.value)}catch(n){console.warn(n)}},{flush:"sync",lazy:!0}),o}function t(n,e,t){function o(n){return n?JSON.stringify(n):""}function i(n){return n?JSON.parse(n):e||{}}void 0===t&&(t=localStorage);var u=l(n,o(e),t),r=L.ref(i(u.value));function a(){u.value=o(r.value)}return L.watch(u,function(){return r.value=i(u.value)},{flush:"sync",lazy:!0}),L.watch(r,a,{flush:"sync",lazy:!0}),{state:r,update:a}}function o(n){var e;"undefined"!=typeof window&&(e=window.matchMedia(n));var t=L.ref(!!e&&e.matches);function o(n){t.value=n.matches}return L.onMounted(function(){e=e||window.matchMedia(n),t.value=e.matches,e.addListener(o)}),L.onUnmounted(function(){e.removeListener(o)}),t}function i(){var n=L.ref(!0),e=L.ref(!1),t=L.ref(void 0),o=L.ref(void 0),i=L.ref(void 0),u=L.ref(void 0),r=L.ref("unknown");function a(){n.value=window.navigator.onLine,t.value=n.value?void 0:Date.now(),"connection"in window.navigator&&(o.value=window.navigator.connection.downlink,i.value=window.navigator.connection.downlinkMax,u.value=window.navigator.connection.effectiveType,e.value=window.navigator.connection.saveData,r.value=window.navigator.connection.type)}function c(){n.value=!1,t.value=Date.now()}function l(){n.value=!0}return L.onMounted(function(){a(),window.addEventListener("offline",c),window.addEventListener("online",l),"connection"in window.navigator&&window.navigator.connection.addEventListener("change",a,!1)}),L.onUnmounted(function(){window.removeEventListener("offline",c),window.removeEventListener("online",l),"connection"in window.navigator&&window.navigator.connection.removeEventListener("change",a,!1)}),{isOnline:n,saveData:e,offlineAt:t,downlink:o,downlinkMax:i,effectiveType:u,type:r}}function f(){return+Date.now()}function v(){var n=L.ref(f()),e=!1,t=function(){requestAnimationFrame(function(){n.value=f(),e&&t()})};return e||(e=!0,t()),L.getCurrentInstance()&&L.onUnmounted(function(){e=!1}),n}function d(){}n.useAsyncState=function(n,e,t,o){void 0===t&&(t=0),void 0===o&&(o=function(n){});var i=L.ref(e),u=L.ref(!1);function r(){n.then(function(n){i.value=n,u.value=!0}).catch(o)}return t?a(r,t):r(),{state:i,ready:u}},n.useBattery=function(){var n=L.ref(!1),e=L.ref(0),t=L.ref(0),o=L.ref(1);function i(){n.value=this.charging,e.value=this.chargingTime||0,t.value=this.dischargingTime||0,o.value=this.level}return L.onMounted(function(){"getBattery"in navigator&&navigator.getBattery().then(function(e){i.call(e),u.forEach(function(n){e.addEventListener(n,i)})})}),L.onUnmounted(function(){"getBattery"in navigator&&navigator.getBattery().then(function(e){u.forEach(function(n){e.removeEventListener(n,i)})})}),{charging:n,chargingTime:e,dischargingTime:t,level:o}},n.useCounter=function(e){function t(n){return o.value=n}void 0===e&&(e=0);var o=L.ref(e);return{count:o,inc:function(n){return void 0===n&&(n=1),o.value+=n},dec:function(n){return void 0===n&&(n=1),o.value-=n},get:function(){return o.value},set:t,reset:function(n){return void 0===n&&(n=e),t(e=n)}}},n.useDeviceOrientation=function(){var e=L.ref(!1),t=L.ref(0),o=L.ref(0),i=L.ref(0);function n(n){e.value=n.absolute,t.value=n.alpha,o.value=n.beta,i.value=n.gamma}return L.onMounted(function(){window.addEventListener("deviceorientation",n)}),L.onUnmounted(function(){window.removeEventListener("deviceorientation",n)}),{isAbsolute:e,alpha:t,beta:o,gamma:i}},n.useFullscreen=function(n){void 0===n&&(n=L.ref(document.body));var e=L.ref(!1);function t(){document.fullscreenElement&&document.exitFullscreen(),e.value=!1}return{isFullscreen:e,enterFullscreen:function(){t(),n.value.requestFullscreen().then(function(){e.value=!0})},exitFullscreen:t}},n.useGeolocation=function(n){void 0===n&&(n={enableHighAccuracy:!0,maximumAge:3e4,timeout:27e3});var e,t=L.ref(null),o=L.ref(null),i=L.ref({accuracy:0,latitude:0,longitude:0,altitude:null,altitudeAccuracy:null,heading:null,speed:null});function u(n){t.value=n.timestamp,i.value=n.coords,o.value=null}return L.onMounted(function(){"geolocation"in navigator&&(e=window.navigator.geolocation.watchPosition(u,function(n){o.value=n},n))}),L.onUnmounted(function(){e&&window.navigator.geolocation.clearWatch(e)}),{coords:i,locatedAt:t,error:o}},n.useIdle=function(e,n,t,o){function i(n){w&&(s.value=n)}void 0===e&&(e=6e4),void 0===n&&(n=!1),void 0===t&&(t=b),void 0===o&&(o=50);var u,r,a,c,l,f,v,d,s=L.ref(n),g=L.ref(E()),w=!0,m=(r=o,v=!(a=function(){s.value=!1,clearTimeout(u),u=setTimeout(function(){return i(!0)},e),g.value=E()}),d=0,"boolean"!=typeof a&&(l=!!c,c=a,a=void 0),p.cancel=function(){h(),v=!0},p);function h(){f&&clearTimeout(f)}function p(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];var t=this,o=Date.now()-d;if(!v){var i=function(){d=Date.now(),c&&c.apply(t,n)};l&&!f&&i(),h(),void 0===l&&r<o?i():!0!==a&&(f=setTimeout(l?function(){f=void 0}:i,void 0===l?r-o:r))}}function y(){document.hidden||m()}return L.onMounted(function(){for(var n=0;n<t.length;n++)M(window,t[n],m);M(document,"visibilitychange",y),u=setTimeout(function(){return i(!0)},e)}),L.onUnmounted(function(){w=!1;for(var n=0;n<t.length;n++)U(window,t[n],m);U(document,"visibilitychange",y)}),{idle:s,lastActive:g}},n.useInterval=function(n,e){void 0===n&&(n=1e3),void 0===e&&(e=!0);var t=null,o=L.ref(0);function i(){t&&(clearInterval(t),t=null)}function u(){i(),t=setInterval(function(){o.value+=1},n)}return e&&L.onMounted(u),L.getCurrentInstance()&&L.onUnmounted(i),{counter:o,start:u,stop:i}},n.useIntervalFn=function(n,e,t){void 0===e&&(e=1e3),void 0===t&&(t=!0);var o=null;function i(){o&&(clearInterval(o),o=null)}function u(){i(),o=setInterval(n,e)}return t&&u(),L.getCurrentInstance()&&L.onUnmounted(i),{start:u,stop:i}},n.useLocalStorage=function(n,e){return t(n,e,localStorage)},n.useMediaQuery=o,n.useMouse=function(n){void 0===n&&(n=L.ref(null));var v=L.ref({docX:0,docY:0,posX:0,posY:0,elX:0,elY:0,elH:0,elW:0}),e=L.watch(n,function(f,n,e){function t(n){var e=(f||document.body).getBoundingClientRect(),t=e.left,o=e.top,i=e.width,u=e.height,r=t+window.pageXOffset,a=o+window.pageYOffset,c=n.pageX-r,l=n.pageY-a;Object.assign(v.value,{docX:n.pageX,docY:n.pageY,posX:r,posY:a,elX:c,elY:l,elH:u,elW:i})}document.addEventListener("mousemove",t),e(function(){document.removeEventListener("mousemove",t)})});return{state:v,stop:e}},n.useNetwork=i,n.useNow=v,n.useOnline=function(){return i().isOnline},n.usePermission=function(n){function e(){t&&o&&(u.value=o.state)}var t=!0,o=null,i="string"==typeof n?{name:n}:n,u=L.ref("");return L.onMounted(function(){"permissions"in navigator&&navigator.permissions.query(i).then(function(n){o=n,e(),M(o,"change",e)}).catch(d)}),L.onUnmounted(function(){t=!1,o&&U(o,"change",e)}),u},n.usePreferredDark=function(){return o("(prefers-color-scheme: dark)")},n.usePreferredLanguages=function(){var n=L.ref(navigator.languages);function e(){n.value=navigator.languages}return L.onMounted(function(){window.addEventListener("languagechange",e)}),L.onUnmounted(function(){window.removeEventListener("languagechange",e)}),n},n.useRaf=function(){var n=v(),e=L.ref(n.value);return L.computed(function(){return n.value-e.value})},n.useSessionStorage=function(n,e){return t(n,e,sessionStorage)},n.useStorage=t,n.useStoragePlain=l,n.useTimeout=r,n.useTimeoutFn=a,n.useWebWorker=function(n){var e,t=L.ref(null);return L.onMounted(function(){(e=new Worker(n)).onmessage=function(n){t.value=n.data}}),L.onUnmounted(function(){e.terminate()}),{data:t,post:function(n){e&&e.postMessage(n)},terminate:function(){e&&e.terminate()}}},n.useWindowScroll=function(){function n(){e.value=window.pageXOffset,t.value=window.pageYOffset}var e=L.ref(c?window.pageXOffset:0),t=L.ref(c?window.pageYOffset:0);return window.addEventListener("scroll",n,{capture:!1,passive:!0}),L.onUnmounted(function(){window.removeEventListener("scroll",n)}),{x:e,y:t}},n.useWindowSize=function(n,e){void 0===n&&(n=1/0),void 0===e&&(e=1/0);var t=L.ref(c?window.innerWidth:n),o=L.ref(c?window.innerWidth:e);if(c){var i=function(){t.value=window.innerWidth,o.value=window.innerHeight};window.addEventListener("resize",i),L.onUnmounted(function(){window.removeEventListener("resize",i)})}return{width:t,height:o}},n.version="2.0.0-alpha.20",Object.defineProperty(n,"__esModule",{value:!0})}); |
{ | ||
"name": "@vueuse/core", | ||
"version": "2.0.0-alpha.19", | ||
"version": "2.0.0-alpha.20", | ||
"description": "Collection of essential Vue Composition API", | ||
@@ -5,0 +5,0 @@ "main": "dist/main/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
129463
2898