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 2.0.0-alpha.8 to 2.0.0-alpha.10

dist/esm/useMouse/index.d.ts

3

dist/esm/index.d.ts

@@ -6,3 +6,6 @@ export { init } from './api';

export * from './useLocalStoragePlain';
export * from './useMouse';
export * from './useNetwork';
export * from './useNow';
export * from './useOnline';
export * from './useRaf';

@@ -9,0 +12,0 @@ export * from './useTimeout';

@@ -6,3 +6,6 @@ export { init } from './api';

export * from './useLocalStoragePlain';
export * from './useMouse';
export * from './useNetwork';
export * from './useNow';
export * from './useOnline';
export * from './useRaf';

@@ -9,0 +12,0 @@ export * from './useTimeout';

4

dist/esm/useIntervalFn/index.d.ts
export declare function useIntervalFn(cb: Function, interval?: number, startRightNow?: boolean): {
readonly start: () => void;
readonly stop: () => void;
start: () => void;
stop: () => void;
};
export declare function useTimeout(interval?: number, startRightNow?: boolean): {
readonly ready: import("@vue/composition-api/dist/reactivity/ref").Ref<boolean>;
readonly start: () => void;
readonly stop: () => void;
ready: import("@vue/composition-api/dist/reactivity/ref").Ref<boolean>;
start: () => void;
stop: () => void;
};

@@ -6,3 +6,6 @@ export { init } from './api';

export * from './useLocalStoragePlain';
export * from './useMouse';
export * from './useNetwork';
export * from './useNow';
export * from './useOnline';
export * from './useRaf';

@@ -9,0 +12,0 @@ export * from './useTimeout';

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

__export(require("./useLocalStoragePlain"));
__export(require("./useMouse"));
__export(require("./useNetwork"));
__export(require("./useNow"));
__export(require("./useOnline"));
__export(require("./useRaf"));

@@ -15,0 +18,0 @@ __export(require("./useTimeout"));

export declare function useIntervalFn(cb: Function, interval?: number, startRightNow?: boolean): {
readonly start: () => void;
readonly stop: () => void;
start: () => void;
stop: () => void;
};
export declare function useTimeout(interval?: number, startRightNow?: boolean): {
readonly ready: import("@vue/composition-api/dist/reactivity/ref").Ref<boolean>;
readonly start: () => void;
readonly stop: () => void;
ready: import("@vue/composition-api/dist/reactivity/ref").Ref<boolean>;
start: () => void;
stop: () => void;
};

@@ -103,2 +103,136 @@ (function (global, factory) {

function useMouse(refEl) {
if (refEl === void 0) { refEl = CompositionAPI.ref(null); }
var state = CompositionAPI.ref({
docX: 0,
docY: 0,
posX: 0,
posY: 0,
elX: 0,
elY: 0,
elH: 0,
elW: 0,
});
var stop = CompositionAPI.watch(refEl, function (el, prevEl, onCleanup) {
var moveHandler = function (event) {
var ele = el || document.body;
var _a = ele.getBoundingClientRect(), left = _a.left, top = _a.top, elW = _a.width, elH = _a.height;
var posX = left + window.pageXOffset;
var posY = top + window.pageYOffset;
var elX = event.pageX - posX;
var elY = event.pageY - posY;
Object.assign(state.value, {
docX: event.pageX,
docY: event.pageY,
posX: posX,
posY: posY,
elX: elX,
elY: elY,
elH: elH,
elW: elW,
});
};
document.addEventListener('mousemove', moveHandler);
onCleanup(function () {
document.removeEventListener('mousemove', moveHandler);
});
});
return { state: state, stop: stop };
}
var isClient = typeof window === 'object';
var on = function (obj) {
var args = [];
for (var _i = 1; _i < arguments.length; _i++) {
args[_i - 1] = arguments[_i];
}
return obj.addEventListener.apply(obj, args);
};
var off = function (obj) {
var args = [];
for (var _i = 1; _i < arguments.length; _i++) {
args[_i - 1] = arguments[_i];
}
return obj.removeEventListener.apply(obj, args);
};
var __assign = (undefined && undefined.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var getConnection = function () {
if (typeof navigator !== 'object')
return null;
var nav = navigator;
return nav.connection || nav.mozConnection || nav.webkitConnection;
};
var getConnectionState = function () {
var connection = getConnection();
if (!connection)
return {};
var downlink = connection.downlink, downlinkMax = connection.downlinkMax, effectiveType = connection.effectiveType, type = connection.type, rtt = connection.rtt;
return {
downlink: downlink,
downlinkMax: downlinkMax,
effectiveType: effectiveType,
type: type,
rtt: rtt,
};
};
var defaultState = {
online: null,
since: null,
downlink: null,
downlinkMax: null,
effectiveType: null,
rtt: null,
type: null,
};
function useNetwork(initialState) {
if (initialState === void 0) { initialState = {}; }
var state = CompositionAPI.reactive(Object.assign(initialState, defaultState));
var updateState = function (patch) {
for (var _i = 0, _a = Object.keys(patch); _i < _a.length; _i++) {
var key = _a[_i];
state[key] = patch[key];
}
};
var connection = getConnection();
var onOnline = function () {
updateState({
online: true,
since: new Date(),
});
};
var onOffline = function () {
updateState({
online: false,
since: new Date(),
});
};
var onConnectionChange = function () {
updateState(getConnectionState());
};
on(window, 'online', onOnline);
on(window, 'offline', onOffline);
if (connection) {
on(connection, 'change', onConnectionChange);
updateState(__assign({ online: navigator.onLine, since: undefined }, getConnectionState()));
}
CompositionAPI.onUnmounted(function () {
off(window, 'online', onOnline);
off(window, 'offline', onOffline);
if (connection)
off(connection, 'change', onConnectionChange);
});
return CompositionAPI.toRefs(state);
}
function getTimestamp() {

@@ -132,2 +266,7 @@ return +Date.now();

function useOnline() {
var online = useNetwork().online;
return online;
}
function useRaf() {

@@ -176,4 +315,2 @@ var now = useNow();

var isClient = typeof window === 'object';
function useWindowScroll() {

@@ -219,3 +356,6 @@ var x = CompositionAPI.ref(isClient ? window.pageXOffset : 0);

exports.useLocalStoragePlain = useLocalStoragePlain;
exports.useMouse = useMouse;
exports.useNetwork = useNetwork;
exports.useNow = useNow;
exports.useOnline = useOnline;
exports.useRaf = useRaf;

@@ -222,0 +362,0 @@ exports.useTimeout = useTimeout;

{
"name": "@vueuse/core",
"version": "2.0.0-alpha.8",
"version": "2.0.0-alpha.10",
"description": "Collection of essential Vue Composition API",

@@ -65,2 +65,3 @@ "main": "dist/main/index.js",

"@vue/test-utils": "1.0.0-beta.30",
"autoprefixer": "9.7.3",
"babel-loader": "8.0.6",

@@ -84,7 +85,11 @@ "babel-preset-vue": "2.0.2",

"markdown-it-prism": "2.0.3",
"postcss": "7.0.25",
"postcss-import": "12.0.1",
"postcss-loader": "3.0.0",
"prismjs": "1.17.1",
"rimraf": "3.0.0",
"rollup": "^1.27.14",
"rollup-plugin-local-resolve": "^1.0.7",
"rollup": "1.27.14",
"rollup-plugin-local-resolve": "1.0.7",
"semver": "7.1.1",
"tailwindcss": "1.1.4",
"ts-jest": "24.2.0",

@@ -91,0 +96,0 @@ "typescript": "3.7.4",

@@ -39,2 +39,14 @@ <p align="center">

### CDN
```html
<!-- For Vue 3.x -->
<script src="https://unpkg.com/@vueuse/core@next"></script>
<!-- For Vue 2.x -->
<script src="https://unpkg.com/@vueuse/core"></script>
```
It will be exposed to global variable `window.VueUse`
## ⚡ Functions

@@ -41,0 +53,0 @@

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