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

ahooks

Package Overview
Dependencies
Maintainers
5
Versions
111
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ahooks - npm Package Compare versions

Comparing version 2.9.1 to 2.9.2

es/useDrag/index.d.ts

3

es/index.d.ts

@@ -37,3 +37,4 @@ import useRequest, { UseRequestProvider } from '@ahooksjs/use-request';

import useCreation from './useCreation';
import { useDrag, useDrop } from './useDrop';
import useDrop from './useDrop';
import useDrag from './useDrag';
import useMount from './useMount';

@@ -40,0 +41,0 @@ import useTextSelection from './useTextSelection';

@@ -72,3 +72,4 @@ var __read = this && this.__read || function (o, n) {

import useCreation from './useCreation';
import { useDrag, useDrop } from './useDrop';
import useDrop from './useDrop';
import useDrag from './useDrag';
import useMount from './useMount';

@@ -75,0 +76,0 @@ import useTextSelection from './useTextSelection';

@@ -6,2 +6,3 @@ /// <reference types="react" />

interval?: number;
onEnd?: () => void;
};

@@ -8,0 +9,0 @@ export interface FormattedRes {

@@ -30,2 +30,3 @@ var __read = this && this.__read || function (o, n) {

import dayjs from 'dayjs';
import usePersistFn from '../usePersistFn';

@@ -61,3 +62,4 @@ var calcLeft = function calcLeft(t) {

_b = _a.interval,
interval = _b === void 0 ? 1000 : _b;
interval = _b === void 0 ? 1000 : _b,
onEnd = _a.onEnd;

@@ -74,2 +76,7 @@ var _c = __read(useState(targetDate), 2),

var onEndPersistFn = usePersistFn(function () {
if (onEnd) {
onEnd();
}
});
useEffect(function () {

@@ -90,2 +97,3 @@ if (!target) {

clearInterval(timer);
onEndPersistFn();
}

@@ -92,0 +100,0 @@ }, interval);

@@ -1,3 +0,19 @@

import useDrag from './useDrag';
import useDrop from './useDrop';
export { useDrag, useDrop };
/// <reference types="react" />
export interface DropAreaState {
isHovering: boolean;
}
export interface DropProps {
onDragOver: React.DragEventHandler;
onDragEnter: React.DragEventHandler;
onDragLeave: React.DragEventHandler;
onDrop: React.DragEventHandler;
onPaste: React.ClipboardEventHandler;
}
export interface DropAreaOptions {
onFiles?: (files: File[], event?: React.DragEvent) => void;
onUri?: (url: string, event?: React.DragEvent) => void;
onDom?: (content: any, event?: React.DragEvent) => void;
onText?: (text: string, event?: React.ClipboardEvent) => void;
}
declare const useDrop: (options?: DropAreaOptions) => [DropProps, DropAreaState];
export default useDrop;

@@ -1,3 +0,108 @@

import useDrag from './useDrag';
import useDrop from './useDrop';
export { useDrag, useDrop };
var __read = this && this.__read || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o),
r,
ar = [],
e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
ar.push(r.value);
}
} catch (error) {
e = {
error: error
};
} finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
} finally {
if (e) throw e.error;
}
}
return ar;
};
import { useMemo, useState, useRef, useCallback } from 'react';
var getProps = function getProps(callback, setIsHovering) {
return {
onDragOver: function onDragOver(event) {
event.preventDefault();
},
onDragEnter: function onDragEnter(event) {
event.preventDefault();
setIsHovering(true);
},
onDragLeave: function onDragLeave() {
setIsHovering(false);
},
onDrop: function onDrop(event) {
event.preventDefault();
event.persist();
setIsHovering(false);
callback(event.dataTransfer, event);
},
onPaste: function onPaste(event) {
event.persist();
callback(event.clipboardData, event);
}
};
};
var useDrop = function useDrop(options) {
if (options === void 0) {
options = {};
}
var optionsRef = useRef(options);
optionsRef.current = options;
var _a = __read(useState(false), 2),
isHovering = _a[0],
setIsHovering = _a[1];
var callback = useCallback(function (dataTransfer, event) {
var uri = dataTransfer.getData('text/uri-list');
var dom = dataTransfer.getData('custom');
if (dom && optionsRef.current.onDom) {
var data = dom;
try {
data = JSON.parse(dom);
} catch (e) {
data = dom;
}
optionsRef.current.onDom(data, event);
return;
}
if (uri && optionsRef.current.onUri) {
optionsRef.current.onUri(uri, event);
return;
}
if (dataTransfer.files && dataTransfer.files.length && optionsRef.current.onFiles) {
optionsRef.current.onFiles(Array.from(dataTransfer.files), event);
return;
}
if (dataTransfer.items && dataTransfer.items.length && optionsRef.current.onText) {
dataTransfer.items[0].getAsString(function (text) {
optionsRef.current.onText(text, event);
});
}
}, []);
var props = useMemo(function () {
return getProps(callback, setIsHovering);
}, [callback, setIsHovering]);
return [props, {
isHovering: isHovering
}];
};
export default useDrop;

@@ -51,3 +51,3 @@ var __read = this && this.__read || function (o, n) {

if (!el) {
return false;
return undefined;
}

@@ -54,0 +54,0 @@

@@ -1,11 +0,8 @@

interface StableActions<U, V> {
set: (key: U, value: V) => void;
setAll: (newMap: Iterable<readonly [U, V]>) => void;
remove: (key: U) => void;
declare function useMap<K, T>(initialValue?: Iterable<readonly [K, T]>): readonly [Map<K, T>, {
set: (key: K, entry: T) => void;
setAll: (newMap: Iterable<readonly [K, T]>) => void;
remove: (key: K) => void;
reset: () => void;
}
interface Actions<U, V> extends StableActions<U, V> {
get: (key: U) => V;
}
declare function useMap<K, T>(initialValue?: Iterable<readonly [K, T]>): [Map<K, T>, Actions<K, T>];
get: (key: any) => T | undefined;
}];
export default useMap;

@@ -44,3 +44,3 @@ var __assign = this && this.__assign || function () {

import { useState, useMemo, useCallback } from 'react';
import { useMemo, useState, useCallback } from 'react';

@@ -50,7 +50,7 @@ function useMap(initialValue) {

return initialValue === undefined ? new Map() : new Map(initialValue);
}, [initialValue]);
}, []);
var _a = __read(useState(initialMap), 2),
map = _a[0],
_set = _a[1];
setMap = _a[1];

@@ -60,19 +60,23 @@ var stableActions = useMemo(function () {

set: function set(key, entry) {
map.set(key, entry);
_set(new Map(Array.from(map)));
setMap(function (prev) {
var temp = new Map(prev);
temp.set(key, entry);
return temp;
});
},
setAll: function setAll(newMap) {
_set(new Map(newMap));
setMap(new Map(newMap));
},
remove: function remove(key) {
map["delete"](key);
_set(new Map(Array.from(map)));
setMap(function (prev) {
var temp = new Map(prev);
temp["delete"](key);
return temp;
});
},
reset: function reset() {
return _set(initialMap);
return setMap(initialMap);
}
};
}, [map, _set]);
}, [setMap, initialMap]);

@@ -79,0 +83,0 @@ var utils = __assign({

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

declare const useMount: (fn: any) => void;
declare const useMount: (fn: () => void) => void;
export default useMount;
import { useEffect } from 'react';
import usePersistFn from '../usePersistFn';
var useMount = function useMount(fn) {
// 持久化函数
var fnPersist = usePersistFn(fn);
useEffect(function () {
if (fnPersist && typeof fnPersist === 'function') {
fnPersist();
}
fn();
}, []);

@@ -12,0 +7,0 @@ };

@@ -28,3 +28,4 @@ var __read = this && this.__read || function (o, n) {

import { useEffect, useState } from 'react';
import { useState } from 'react';
import useEventListener from '../useEventListener';
var initState = {

@@ -43,26 +44,21 @@ screenX: NaN,

useEffect(function () {
var moveHandler = function moveHandler(event) {
var screenX = event.screenX,
screenY = event.screenY,
clientX = event.clientX,
clientY = event.clientY,
pageX = event.pageX,
pageY = event.pageY;
setState({
screenX: screenX,
screenY: screenY,
clientX: clientX,
clientY: clientY,
pageX: pageX,
pageY: pageY
});
};
document.addEventListener('mousemove', moveHandler);
return function () {
document.removeEventListener('mousemove', moveHandler);
};
}, []);
useEventListener('mousemove', function (event) {
var screenX = event.screenX,
screenY = event.screenY,
clientX = event.clientX,
clientY = event.clientY,
pageX = event.pageX,
pageY = event.pageY;
setState({
screenX: screenX,
screenY: screenY,
clientX: clientX,
clientY: clientY,
pageX: pageX,
pageY: pageY
});
}, {
target: document
});
return state;
});

@@ -103,7 +103,7 @@ var __assign = this && this.__assign || function () {

var connection = getConnection();
connection && connection.addEventListener('change', onConnectionChange);
connection === null || connection === void 0 ? void 0 : connection.addEventListener('change', onConnectionChange);
return function () {
window.removeEventListener('online', onOnline);
window.removeEventListener('offline', onOffline);
connection && connection.removeEventListener('change', onConnectionChange);
connection === null || connection === void 0 ? void 0 : connection.removeEventListener('change', onConnectionChange);
};

@@ -110,0 +110,0 @@ }, []);

export declare type noop = (...args: any[]) => any;
declare function usePersistFn<T extends noop>(fn: T): T;
declare function usePersistFn<T extends noop>(fn: T): NonNullable<T>;
export default usePersistFn;

@@ -1,55 +0,25 @@

var __read = this && this.__read || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o),
r,
ar = [],
e;
import { useRef, useEffect } from 'react';
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
ar.push(r.value);
}
} catch (error) {
e = {
error: error
};
} finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
} finally {
if (e) throw e.error;
}
}
function usePersistFn(fn) {
var fnRef = useRef(fn);
useEffect(function () {
fnRef.current = fn;
}, [fn]);
var persistFn = useRef();
return ar;
};
if (!persistFn.current) {
persistFn.current = function () {
var args = [];
var __spread = this && this.__spread || function () {
for (var ar = [], i = 0; i < arguments.length; i++) {
ar = ar.concat(__read(arguments[i]));
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
return fnRef.current.apply(this, args);
};
}
return ar;
};
import { useCallback, useRef } from 'react';
function usePersistFn(fn) {
var ref = useRef(function () {
throw new Error('Cannot call function while rendering.');
});
ref.current = fn;
var persistFn = useCallback(function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
return ref.current.apply(ref, __spread(args));
}, [ref]);
return persistFn;
return persistFn.current;
}
export default usePersistFn;
export declare type compareFunction<T> = (prev: T | undefined, next: T) => boolean;
declare const _default: <T>(state: T, compare?: compareFunction<T> | undefined) => T | undefined;
export default _default;
declare function usePrevious<T>(state: T, compare?: compareFunction<T>): T | undefined;
export default usePrevious;
import { useRef } from 'react';
export default (function (state, compare) {
function usePrevious(state, compare) {
var prevRef = useRef();

@@ -13,2 +14,4 @@ var curRef = useRef();

return prevRef.current;
});
}
export default usePrevious;

@@ -56,32 +56,29 @@ var __values = this && this.__values || function (o) {

function init() {
if (info || typeof window === "undefined") return;
info = {};
function handleResize() {
var e_1, _a;
var oldInfo = info;
calculate();
window.addEventListener('resize', function () {
var e_1, _a;
if (oldInfo === info) return;
var oldInfo = info;
calculate();
if (oldInfo === info) return;
try {
for (var subscribers_1 = __values(subscribers), subscribers_1_1 = subscribers_1.next(); !subscribers_1_1.done; subscribers_1_1 = subscribers_1.next()) {
var subscriber = subscribers_1_1.value;
subscriber();
}
} catch (e_1_1) {
e_1 = {
error: e_1_1
};
} finally {
try {
for (var subscribers_1 = __values(subscribers), subscribers_1_1 = subscribers_1.next(); !subscribers_1_1.done; subscribers_1_1 = subscribers_1.next()) {
var subscriber = subscribers_1_1.value;
subscriber();
}
} catch (e_1_1) {
e_1 = {
error: e_1_1
};
if (subscribers_1_1 && !subscribers_1_1.done && (_a = subscribers_1["return"])) _a.call(subscribers_1);
} finally {
try {
if (subscribers_1_1 && !subscribers_1_1.done && (_a = subscribers_1["return"])) _a.call(subscribers_1);
} finally {
if (e_1) throw e_1.error;
}
if (e_1) throw e_1.error;
}
});
}
}
var listening = false;
function calculate() {

@@ -125,4 +122,11 @@ var e_2, _a;

export function useResponsive() {
init();
var windowExists = typeof window !== 'undefined';
if (windowExists && !listening) {
info = {};
calculate();
window.addEventListener('resize', handleResize);
listening = true;
}
var _a = __read(useState(info), 2),

@@ -132,3 +136,2 @@ state = _a[0],

var windowExists = typeof window !== "undefined";
useEffect(function () {

@@ -144,5 +147,10 @@ if (!windowExists) return;

subscribers["delete"](subscriber);
if (subscribers.size === 0) {
window.removeEventListener('resize', handleResize);
listening = false;
}
};
}, [windowExists]);
}, []);
return state;
}

@@ -29,2 +29,3 @@ var __read = this && this.__read || function (o, n) {

import { useEffect, useState } from 'react';
import usePersistFn from '../usePersistFn';
import { getTargetElement } from '../utils/dom';

@@ -34,3 +35,3 @@

if (shouldUpdate === void 0) {
shouldUpdate = function shouldUpdate(val) {
shouldUpdate = function shouldUpdate() {
return true;

@@ -47,2 +48,3 @@ };

var shouldUpdatePersist = usePersistFn(shouldUpdate);
useEffect(function () {

@@ -68,3 +70,3 @@ var el = getTargetElement(target, document);

if (shouldUpdate(newPosition)) setPosition(newPosition);
if (shouldUpdatePersist(newPosition)) setPosition(newPosition);
}

@@ -83,3 +85,3 @@

};
}, [target]);
}, [target, shouldUpdatePersist]);
return position;

@@ -86,0 +88,0 @@ }

/// <reference types="react" />
export default function useSelections<T>(items: T[], defaultSelected?: T[]): {
readonly selected: T[];
readonly selectAll: () => void;
readonly unSelectAll: () => void;
readonly noneSelected: boolean;
readonly allSelected: boolean;
readonly partiallySelected: boolean;
readonly toggleAll: () => void;
readonly isSelected: (item: T) => boolean;

@@ -8,9 +13,4 @@ readonly select: (item: T) => void;

readonly toggle: (item: T) => void;
readonly selectAll: () => void;
readonly unSelectAll: () => void;
readonly toggleAll: () => void;
readonly allSelected: boolean;
readonly noneSelected: boolean;
readonly partiallySelected: boolean;
readonly selected: T[];
readonly setSelected: import("react").Dispatch<import("react").SetStateAction<T[]>>;
};

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

var __assign = this && this.__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 __read = this && this.__read || function (o, n) {

@@ -40,5 +56,6 @@ var m = typeof Symbol === "function" && o[Symbol.iterator];

var _b = useMemo(function () {
var selectedSet = new Set(selected);
var selectedSet = useMemo(function () {
return new Set(selected);
}, [selected]);
var singleActions = useMemo(function () {
var isSelected = function isSelected(item) {

@@ -67,3 +84,2 @@ return selectedSet.has(item);

return {
selectedSet: selectedSet,
isSelected: isSelected,

@@ -74,10 +90,4 @@ select: select,

};
}, [selected]),
selectedSet = _b.selectedSet,
isSelected = _b.isSelected,
select = _b.select,
unSelect = _b.unSelect,
toggle = _b.toggle;
var _c = useMemo(function () {
}, [selectedSet]);
var allActions = useMemo(function () {
var selectAll = function selectAll() {

@@ -117,24 +127,7 @@ items.forEach(function (o) {

};
}, [selectedSet, items]),
selectAll = _c.selectAll,
unSelectAll = _c.unSelectAll,
noneSelected = _c.noneSelected,
allSelected = _c.allSelected,
partiallySelected = _c.partiallySelected,
toggleAll = _c.toggleAll;
return {
}, [selectedSet, items]);
return __assign(__assign({
selected: selected,
isSelected: isSelected,
select: select,
unSelect: unSelect,
toggle: toggle,
selectAll: selectAll,
unSelectAll: unSelectAll,
toggleAll: toggleAll,
allSelected: allSelected,
noneSelected: noneSelected,
partiallySelected: partiallySelected,
setSelected: setSelected
};
}, singleActions), allActions);
}

@@ -1,10 +0,7 @@

interface StableActions<K> {
declare function useSet<K>(initialValue?: Iterable<K>): readonly [Set<K>, {
add: (key: K) => void;
remove: (key: K) => void;
reset: () => void;
}
interface Actions<K> extends StableActions<K> {
has: (key: K) => boolean;
}
declare function useSet<K>(initialValue?: Iterable<K>): [Set<K>, Actions<K>];
}];
export default useSet;

@@ -43,11 +43,5 @@ var __assign = this && this.__assign || function () {

};
/* eslint-disable max-len */
var __spread = this && this.__spread || function () {
for (var ar = [], i = 0; i < arguments.length; i++) {
ar = ar.concat(__read(arguments[i]));
}
return ar;
};
import { useState, useMemo, useCallback } from 'react';

@@ -58,3 +52,3 @@

return initialValue === undefined ? new Set() : new Set(initialValue);
}, [initialValue]);
}, []);

@@ -68,11 +62,13 @@ var _a = __read(useState(initialSet), 2),

add: function add(key) {
return setSet(function (prevSet) {
return new Set(__spread(Array.from(prevSet), [key]));
setSet(function (prevSet) {
var temp = new Set(prevSet);
temp.add(key);
return temp;
});
},
remove: function remove(key) {
return setSet(function (prevSet) {
return new Set(Array.from(prevSet).filter(function (i) {
return i !== key;
}));
setSet(function (prevSet) {
var temp = new Set(prevSet);
temp["delete"](key);
return temp;
});

@@ -84,3 +80,3 @@ },

};
}, [setSet]);
}, [setSet, initialSet]);

@@ -87,0 +83,0 @@ var utils = __assign({

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

var __assign = this && this.__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 __read = this && this.__read || function (o, n) {

@@ -29,2 +45,3 @@ var m = typeof Symbol === "function" && o[Symbol.iterator];

import { useCallback, useState } from 'react';
import { isFunction } from '../utils';

@@ -42,5 +59,5 @@ var useSetState = function useSetState(initialState) {

setState(function (prevState) {
return Object.assign({}, prevState, patch instanceof Function ? patch(prevState) : patch);
return __assign(__assign({}, prevState), isFunction(patch) ? patch(prevState) : patch);
});
}, [setState]);
}, []);
return [state, setMergeState];

@@ -47,0 +64,0 @@ };

@@ -62,3 +62,3 @@ var __read = this && this.__read || function (o, n) {

};
}, [typeof target === 'function' ? undefined : target]);
}, [target]);
return state;

@@ -65,0 +65,0 @@ }

@@ -44,3 +44,3 @@ var __assign = this && this.__assign || function () {

import { useState, useEffect, useRef } from 'react';
import { useEffect, useRef, useState } from 'react';
import { getTargetElement } from '../utils/dom';

@@ -47,0 +47,0 @@ var initRect = {

@@ -1,12 +0,10 @@

import { useEffect, useRef } from 'react';
import { useEffect } from 'react';
import usePersistFn from '../usePersistFn';
function useTimeout(fn, delay) {
var timerRef = useRef();
timerRef.current = fn;
var timerFn = usePersistFn(fn);
useEffect(function () {
if (delay === undefined || delay === null) return;
var timer = setTimeout(function () {
var _a;
(_a = timerRef.current) === null || _a === void 0 ? void 0 : _a.call(timerRef);
timerFn();
}, delay);

@@ -16,5 +14,5 @@ return function () {

};
}, [delay]);
}, [delay, timerFn]);
}
export default useTimeout;
import { useEffect, useRef } from 'react';
import useUnmount from '../useUnmount';
var DEFAULT_OPTIONS = {

@@ -15,11 +16,9 @@ restoreOnUnmount: false

}, [title]);
useEffect(function () {
useUnmount(function () {
if (options && options.restoreOnUnmount) {
return function () {
document.title = titleRef.current;
};
document.title = titleRef.current;
}
}, []);
});
}
export default typeof document !== 'undefined' ? useTitle : function (_title) {};
export default typeof document !== 'undefined' ? useTitle : function () {};

@@ -1,15 +0,16 @@

import { useEffect, useRef } from 'react';
import { useEffect } from 'react';
import usePersistFn from '../usePersistFn';
import { isFunction } from '../utils';
var useUnmount = function useUnmount(fn) {
var fnRef = useRef(fn);
fnRef.current = fn;
var fnPersist = usePersistFn(fn);
useEffect(function () {
return function () {
if (fnRef.current && typeof fnRef.current === 'function') {
fnRef.current();
if (isFunction(fnPersist)) {
fnPersist();
}
};
}, []);
}, [fnPersist]);
};
export default useUnmount;

@@ -31,9 +31,7 @@ var __read = this && this.__read || function (o, n) {

var useUpdate = function useUpdate() {
var _a = __read(useState(0), 2),
var _a = __read(useState({}), 2),
setState = _a[1];
return useCallback(function () {
return setState(function (num) {
return num + 1;
});
return setState({});
}, []);

@@ -40,0 +38,0 @@ };

@@ -10,2 +10,3 @@ export declare enum ReadyState {

reconnectInterval?: number;
manual?: boolean;
onOpen?: (event: WebSocketEventMap['open']) => void;

@@ -12,0 +13,0 @@ onClose?: (event: WebSocketEventMap['close']) => void;

@@ -49,2 +49,4 @@ var __read = this && this.__read || function (o, n) {

reconnectInterval = _b === void 0 ? 3 * 1000 : _b,
_c = options.manual,
manual = _c === void 0 ? false : _c,
onOpen = options.onOpen,

@@ -58,9 +60,9 @@ onClose = options.onClose,

var _c = __read(useState(), 2),
latestMessage = _c[0],
setLatestMessage = _c[1];
var _d = __read(useState(), 2),
latestMessage = _d[0],
setLatestMessage = _d[1];
var _d = __read(useState(ReadyState.Closed), 2),
readyState = _d[0],
setReadyState = _d[1];
var _e = __read(useState(ReadyState.Closed), 2),
readyState = _e[0],
setReadyState = _e[1];
/**

@@ -159,4 +161,6 @@ * 重连

// 初始连接
connect();
}, [socketUrl]);
if (!manual) {
connect();
}
}, [socketUrl, manual]);
useUnmount(function () {

@@ -163,0 +167,0 @@ disconnect();

@@ -37,3 +37,4 @@ import useRequest, { UseRequestProvider } from '@ahooksjs/use-request';

import useCreation from './useCreation';
import { useDrag, useDrop } from './useDrop';
import useDrop from './useDrop';
import useDrag from './useDrag';
import useMount from './useMount';

@@ -40,0 +41,0 @@ import useTextSelection from './useTextSelection';

@@ -244,17 +244,10 @@ "use strict";

var useDrop_1 = require("./useDrop");
var useDrop_1 = __importDefault(require("./useDrop"));
Object.defineProperty(exports, "useDrag", {
enumerable: true,
get: function get() {
return useDrop_1.useDrag;
}
});
Object.defineProperty(exports, "useDrop", {
enumerable: true,
get: function get() {
return useDrop_1.useDrop;
}
});
exports.useDrop = useDrop_1["default"];
var useDrag_1 = __importDefault(require("./useDrag"));
exports.useDrag = useDrag_1["default"];
var useMount_1 = __importDefault(require("./useMount"));

@@ -261,0 +254,0 @@

@@ -6,2 +6,3 @@ /// <reference types="react" />

interval?: number;
onEnd?: () => void;
};

@@ -8,0 +9,0 @@ export interface FormattedRes {

@@ -44,2 +44,4 @@ "use strict";

var usePersistFn_1 = __importDefault(require("../usePersistFn"));
var calcLeft = function calcLeft(t) {

@@ -74,3 +76,4 @@ if (!t) {

_b = _a.interval,
interval = _b === void 0 ? 1000 : _b;
interval = _b === void 0 ? 1000 : _b,
onEnd = _a.onEnd;

@@ -87,2 +90,7 @@ var _c = __read(react_1.useState(targetDate), 2),

var onEndPersistFn = usePersistFn_1["default"](function () {
if (onEnd) {
onEnd();
}
});
react_1.useEffect(function () {

@@ -103,2 +111,3 @@ if (!target) {

clearInterval(timer);
onEndPersistFn();
}

@@ -105,0 +114,0 @@ }, interval);

@@ -1,3 +0,19 @@

import useDrag from './useDrag';
import useDrop from './useDrop';
export { useDrag, useDrop };
/// <reference types="react" />
export interface DropAreaState {
isHovering: boolean;
}
export interface DropProps {
onDragOver: React.DragEventHandler;
onDragEnter: React.DragEventHandler;
onDragLeave: React.DragEventHandler;
onDrop: React.DragEventHandler;
onPaste: React.ClipboardEventHandler;
}
export interface DropAreaOptions {
onFiles?: (files: File[], event?: React.DragEvent) => void;
onUri?: (url: string, event?: React.DragEvent) => void;
onDom?: (content: any, event?: React.DragEvent) => void;
onText?: (text: string, event?: React.ClipboardEvent) => void;
}
declare const useDrop: (options?: DropAreaOptions) => [DropProps, DropAreaState];
export default useDrop;
"use strict";
var __importDefault = this && this.__importDefault || function (mod) {
return mod && mod.__esModule ? mod : {
"default": mod
};
var __read = this && this.__read || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o),
r,
ar = [],
e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
ar.push(r.value);
}
} catch (error) {
e = {
error: error
};
} finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
} finally {
if (e) throw e.error;
}
}
return ar;
};

@@ -12,10 +33,83 @@

});
exports.useDrop = exports.useDrag = void 0;
var useDrag_1 = __importDefault(require("./useDrag"));
var react_1 = require("react");
exports.useDrag = useDrag_1["default"];
var getProps = function getProps(callback, setIsHovering) {
return {
onDragOver: function onDragOver(event) {
event.preventDefault();
},
onDragEnter: function onDragEnter(event) {
event.preventDefault();
setIsHovering(true);
},
onDragLeave: function onDragLeave() {
setIsHovering(false);
},
onDrop: function onDrop(event) {
event.preventDefault();
event.persist();
setIsHovering(false);
callback(event.dataTransfer, event);
},
onPaste: function onPaste(event) {
event.persist();
callback(event.clipboardData, event);
}
};
};
var useDrop_1 = __importDefault(require("./useDrop"));
var useDrop = function useDrop(options) {
if (options === void 0) {
options = {};
}
exports.useDrop = useDrop_1["default"];
var optionsRef = react_1.useRef(options);
optionsRef.current = options;
var _a = __read(react_1.useState(false), 2),
isHovering = _a[0],
setIsHovering = _a[1];
var callback = react_1.useCallback(function (dataTransfer, event) {
var uri = dataTransfer.getData('text/uri-list');
var dom = dataTransfer.getData('custom');
if (dom && optionsRef.current.onDom) {
var data = dom;
try {
data = JSON.parse(dom);
} catch (e) {
data = dom;
}
optionsRef.current.onDom(data, event);
return;
}
if (uri && optionsRef.current.onUri) {
optionsRef.current.onUri(uri, event);
return;
}
if (dataTransfer.files && dataTransfer.files.length && optionsRef.current.onFiles) {
optionsRef.current.onFiles(Array.from(dataTransfer.files), event);
return;
}
if (dataTransfer.items && dataTransfer.items.length && optionsRef.current.onText) {
dataTransfer.items[0].getAsString(function (text) {
optionsRef.current.onText(text, event);
});
}
}, []);
var props = react_1.useMemo(function () {
return getProps(callback, setIsHovering);
}, [callback, setIsHovering]);
return [props, {
isHovering: isHovering
}];
};
exports["default"] = useDrop;

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

if (!el) {
return false;
return undefined;
}

@@ -62,0 +62,0 @@

@@ -1,11 +0,8 @@

interface StableActions<U, V> {
set: (key: U, value: V) => void;
setAll: (newMap: Iterable<readonly [U, V]>) => void;
remove: (key: U) => void;
declare function useMap<K, T>(initialValue?: Iterable<readonly [K, T]>): readonly [Map<K, T>, {
set: (key: K, entry: T) => void;
setAll: (newMap: Iterable<readonly [K, T]>) => void;
remove: (key: K) => void;
reset: () => void;
}
interface Actions<U, V> extends StableActions<U, V> {
get: (key: U) => V;
}
declare function useMap<K, T>(initialValue?: Iterable<readonly [K, T]>): [Map<K, T>, Actions<K, T>];
get: (key: any) => T | undefined;
}];
export default useMap;

@@ -55,7 +55,7 @@ "use strict";

return initialValue === undefined ? new Map() : new Map(initialValue);
}, [initialValue]);
}, []);
var _a = __read(react_1.useState(initialMap), 2),
map = _a[0],
_set = _a[1];
setMap = _a[1];

@@ -65,19 +65,23 @@ var stableActions = react_1.useMemo(function () {

set: function set(key, entry) {
map.set(key, entry);
_set(new Map(Array.from(map)));
setMap(function (prev) {
var temp = new Map(prev);
temp.set(key, entry);
return temp;
});
},
setAll: function setAll(newMap) {
_set(new Map(newMap));
setMap(new Map(newMap));
},
remove: function remove(key) {
map["delete"](key);
_set(new Map(Array.from(map)));
setMap(function (prev) {
var temp = new Map(prev);
temp["delete"](key);
return temp;
});
},
reset: function reset() {
return _set(initialMap);
return setMap(initialMap);
}
};
}, [map, _set]);
}, [setMap, initialMap]);

@@ -84,0 +88,0 @@ var utils = __assign({

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

declare const useMount: (fn: any) => void;
declare const useMount: (fn: () => void) => void;
export default useMount;
"use strict";
var __importDefault = this && this.__importDefault || function (mod) {
return mod && mod.__esModule ? mod : {
"default": mod
};
};
Object.defineProperty(exports, "__esModule", {

@@ -15,11 +9,5 @@ value: true

var usePersistFn_1 = __importDefault(require("../usePersistFn"));
var useMount = function useMount(fn) {
// 持久化函数
var fnPersist = usePersistFn_1["default"](fn);
react_1.useEffect(function () {
if (fnPersist && typeof fnPersist === 'function') {
fnPersist();
}
fn();
}, []);

@@ -26,0 +14,0 @@ };

@@ -30,2 +30,8 @@ "use strict";

var __importDefault = this && this.__importDefault || function (mod) {
return mod && mod.__esModule ? mod : {
"default": mod
};
};
Object.defineProperty(exports, "__esModule", {

@@ -37,2 +43,4 @@ value: true

var useEventListener_1 = __importDefault(require("../useEventListener"));
var initState = {

@@ -52,26 +60,21 @@ screenX: NaN,

react_1.useEffect(function () {
var moveHandler = function moveHandler(event) {
var screenX = event.screenX,
screenY = event.screenY,
clientX = event.clientX,
clientY = event.clientY,
pageX = event.pageX,
pageY = event.pageY;
setState({
screenX: screenX,
screenY: screenY,
clientX: clientX,
clientY: clientY,
pageX: pageX,
pageY: pageY
});
};
document.addEventListener('mousemove', moveHandler);
return function () {
document.removeEventListener('mousemove', moveHandler);
};
}, []);
useEventListener_1["default"]('mousemove', function (event) {
var screenX = event.screenX,
screenY = event.screenY,
clientX = event.clientX,
clientY = event.clientY,
pageX = event.pageX,
pageY = event.pageY;
setState({
screenX: screenX,
screenY: screenY,
clientX: clientX,
clientY: clientY,
pageX: pageX,
pageY: pageY
});
}, {
target: document
});
return state;
};

@@ -109,7 +109,7 @@ "use strict";

var connection = getConnection();
connection && connection.addEventListener('change', onConnectionChange);
connection === null || connection === void 0 ? void 0 : connection.addEventListener('change', onConnectionChange);
return function () {
window.removeEventListener('online', onOnline);
window.removeEventListener('offline', onOffline);
connection && connection.removeEventListener('change', onConnectionChange);
connection === null || connection === void 0 ? void 0 : connection.removeEventListener('change', onConnectionChange);
};

@@ -116,0 +116,0 @@ }, []);

export declare type noop = (...args: any[]) => any;
declare function usePersistFn<T extends noop>(fn: T): T;
declare function usePersistFn<T extends noop>(fn: T): NonNullable<T>;
export default usePersistFn;
"use strict";
var __read = this && this.__read || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o),
r,
ar = [],
e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
ar.push(r.value);
}
} catch (error) {
e = {
error: error
};
} finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
} finally {
if (e) throw e.error;
}
}
return ar;
};
var __spread = this && this.__spread || function () {
for (var ar = [], i = 0; i < arguments.length; i++) {
ar = ar.concat(__read(arguments[i]));
}
return ar;
};
Object.defineProperty(exports, "__esModule", {

@@ -45,18 +10,23 @@ value: true

function usePersistFn(fn) {
var ref = react_1.useRef(function () {
throw new Error('Cannot call function while rendering.');
});
ref.current = fn;
var persistFn = react_1.useCallback(function () {
var args = [];
var fnRef = react_1.useRef(fn);
react_1.useEffect(function () {
fnRef.current = fn;
}, [fn]);
var persistFn = react_1.useRef();
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
if (!persistFn.current) {
persistFn.current = function () {
var args = [];
return ref.current.apply(ref, __spread(args));
}, [ref]);
return persistFn;
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
return fnRef.current.apply(this, args);
};
}
return persistFn.current;
}
exports["default"] = usePersistFn;
export declare type compareFunction<T> = (prev: T | undefined, next: T) => boolean;
declare const _default: <T>(state: T, compare?: compareFunction<T> | undefined) => T | undefined;
export default _default;
declare function usePrevious<T>(state: T, compare?: compareFunction<T>): T | undefined;
export default usePrevious;

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

exports["default"] = function (state, compare) {
function usePrevious(state, compare) {
var prevRef = react_1.useRef();

@@ -21,2 +21,4 @@ var curRef = react_1.useRef();

return prevRef.current;
};
}
exports["default"] = usePrevious;

@@ -64,32 +64,29 @@ "use strict";

function init() {
if (info || typeof window === "undefined") return;
info = {};
function handleResize() {
var e_1, _a;
var oldInfo = info;
calculate();
window.addEventListener('resize', function () {
var e_1, _a;
if (oldInfo === info) return;
var oldInfo = info;
calculate();
if (oldInfo === info) return;
try {
for (var subscribers_1 = __values(subscribers), subscribers_1_1 = subscribers_1.next(); !subscribers_1_1.done; subscribers_1_1 = subscribers_1.next()) {
var subscriber = subscribers_1_1.value;
subscriber();
}
} catch (e_1_1) {
e_1 = {
error: e_1_1
};
} finally {
try {
for (var subscribers_1 = __values(subscribers), subscribers_1_1 = subscribers_1.next(); !subscribers_1_1.done; subscribers_1_1 = subscribers_1.next()) {
var subscriber = subscribers_1_1.value;
subscriber();
}
} catch (e_1_1) {
e_1 = {
error: e_1_1
};
if (subscribers_1_1 && !subscribers_1_1.done && (_a = subscribers_1["return"])) _a.call(subscribers_1);
} finally {
try {
if (subscribers_1_1 && !subscribers_1_1.done && (_a = subscribers_1["return"])) _a.call(subscribers_1);
} finally {
if (e_1) throw e_1.error;
}
if (e_1) throw e_1.error;
}
});
}
}
var listening = false;
function calculate() {

@@ -136,4 +133,11 @@ var e_2, _a;

function useResponsive() {
init();
var windowExists = typeof window !== 'undefined';
if (windowExists && !listening) {
info = {};
calculate();
window.addEventListener('resize', handleResize);
listening = true;
}
var _a = __read(react_1.useState(info), 2),

@@ -143,3 +147,2 @@ state = _a[0],

var windowExists = typeof window !== "undefined";
react_1.useEffect(function () {

@@ -155,4 +158,9 @@ if (!windowExists) return;

subscribers["delete"](subscriber);
if (subscribers.size === 0) {
window.removeEventListener('resize', handleResize);
listening = false;
}
};
}, [windowExists]);
}, []);
return state;

@@ -159,0 +167,0 @@ }

@@ -30,2 +30,8 @@ "use strict";

var __importDefault = this && this.__importDefault || function (mod) {
return mod && mod.__esModule ? mod : {
"default": mod
};
};
Object.defineProperty(exports, "__esModule", {

@@ -37,2 +43,4 @@ value: true

var usePersistFn_1 = __importDefault(require("../usePersistFn"));
var dom_1 = require("../utils/dom");

@@ -42,3 +50,3 @@

if (shouldUpdate === void 0) {
shouldUpdate = function shouldUpdate(val) {
shouldUpdate = function shouldUpdate() {
return true;

@@ -55,2 +63,3 @@ };

var shouldUpdatePersist = usePersistFn_1["default"](shouldUpdate);
react_1.useEffect(function () {

@@ -76,3 +85,3 @@ var el = dom_1.getTargetElement(target, document);

if (shouldUpdate(newPosition)) setPosition(newPosition);
if (shouldUpdatePersist(newPosition)) setPosition(newPosition);
}

@@ -91,3 +100,3 @@

};
}, [target]);
}, [target, shouldUpdatePersist]);
return position;

@@ -94,0 +103,0 @@ }

/// <reference types="react" />
export default function useSelections<T>(items: T[], defaultSelected?: T[]): {
readonly selected: T[];
readonly selectAll: () => void;
readonly unSelectAll: () => void;
readonly noneSelected: boolean;
readonly allSelected: boolean;
readonly partiallySelected: boolean;
readonly toggleAll: () => void;
readonly isSelected: (item: T) => boolean;

@@ -8,9 +13,4 @@ readonly select: (item: T) => void;

readonly toggle: (item: T) => void;
readonly selectAll: () => void;
readonly unSelectAll: () => void;
readonly toggleAll: () => void;
readonly allSelected: boolean;
readonly noneSelected: boolean;
readonly partiallySelected: boolean;
readonly selected: T[];
readonly setSelected: import("react").Dispatch<import("react").SetStateAction<T[]>>;
};
"use strict";
var __assign = this && this.__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 __read = this && this.__read || function (o, n) {

@@ -46,5 +62,6 @@ var m = typeof Symbol === "function" && o[Symbol.iterator];

var _b = react_1.useMemo(function () {
var selectedSet = new Set(selected);
var selectedSet = react_1.useMemo(function () {
return new Set(selected);
}, [selected]);
var singleActions = react_1.useMemo(function () {
var isSelected = function isSelected(item) {

@@ -73,3 +90,2 @@ return selectedSet.has(item);

return {
selectedSet: selectedSet,
isSelected: isSelected,

@@ -80,10 +96,4 @@ select: select,

};
}, [selected]),
selectedSet = _b.selectedSet,
isSelected = _b.isSelected,
select = _b.select,
unSelect = _b.unSelect,
toggle = _b.toggle;
var _c = react_1.useMemo(function () {
}, [selectedSet]);
var allActions = react_1.useMemo(function () {
var selectAll = function selectAll() {

@@ -123,26 +133,9 @@ items.forEach(function (o) {

};
}, [selectedSet, items]),
selectAll = _c.selectAll,
unSelectAll = _c.unSelectAll,
noneSelected = _c.noneSelected,
allSelected = _c.allSelected,
partiallySelected = _c.partiallySelected,
toggleAll = _c.toggleAll;
return {
}, [selectedSet, items]);
return __assign(__assign({
selected: selected,
isSelected: isSelected,
select: select,
unSelect: unSelect,
toggle: toggle,
selectAll: selectAll,
unSelectAll: unSelectAll,
toggleAll: toggleAll,
allSelected: allSelected,
noneSelected: noneSelected,
partiallySelected: partiallySelected,
setSelected: setSelected
};
}, singleActions), allActions);
}
exports["default"] = useSelections;

@@ -1,10 +0,7 @@

interface StableActions<K> {
declare function useSet<K>(initialValue?: Iterable<K>): readonly [Set<K>, {
add: (key: K) => void;
remove: (key: K) => void;
reset: () => void;
}
interface Actions<K> extends StableActions<K> {
has: (key: K) => boolean;
}
declare function useSet<K>(initialValue?: Iterable<K>): [Set<K>, Actions<K>];
}];
export default useSet;

@@ -46,13 +46,6 @@ "use strict";

var __spread = this && this.__spread || function () {
for (var ar = [], i = 0; i < arguments.length; i++) {
ar = ar.concat(__read(arguments[i]));
}
return ar;
};
Object.defineProperty(exports, "__esModule", {
value: true
});
/* eslint-disable max-len */

@@ -64,3 +57,3 @@ var react_1 = require("react");

return initialValue === undefined ? new Set() : new Set(initialValue);
}, [initialValue]);
}, []);

@@ -74,11 +67,13 @@ var _a = __read(react_1.useState(initialSet), 2),

add: function add(key) {
return setSet(function (prevSet) {
return new Set(__spread(Array.from(prevSet), [key]));
setSet(function (prevSet) {
var temp = new Set(prevSet);
temp.add(key);
return temp;
});
},
remove: function remove(key) {
return setSet(function (prevSet) {
return new Set(Array.from(prevSet).filter(function (i) {
return i !== key;
}));
setSet(function (prevSet) {
var temp = new Set(prevSet);
temp["delete"](key);
return temp;
});

@@ -90,3 +85,3 @@ },

};
}, [setSet]);
}, [setSet, initialSet]);

@@ -93,0 +88,0 @@ var utils = __assign({

"use strict";
var __assign = this && this.__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 __read = this && this.__read || function (o, n) {

@@ -36,2 +52,4 @@ var m = typeof Symbol === "function" && o[Symbol.iterator];

var utils_1 = require("../utils");
var useSetState = function useSetState(initialState) {

@@ -48,5 +66,5 @@ if (initialState === void 0) {

setState(function (prevState) {
return Object.assign({}, prevState, patch instanceof Function ? patch(prevState) : patch);
return __assign(__assign({}, prevState), utils_1.isFunction(patch) ? patch(prevState) : patch);
});
}, [setState]);
}, []);
return [state, setMergeState];

@@ -53,0 +71,0 @@ };

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

};
}, [typeof target === 'function' ? undefined : target]);
}, [target]);
return state;

@@ -79,0 +79,0 @@ }

"use strict";
var __importDefault = this && this.__importDefault || function (mod) {
return mod && mod.__esModule ? mod : {
"default": mod
};
};
Object.defineProperty(exports, "__esModule", {

@@ -9,11 +15,10 @@ value: true

var usePersistFn_1 = __importDefault(require("../usePersistFn"));
function useTimeout(fn, delay) {
var timerRef = react_1.useRef();
timerRef.current = fn;
var timerFn = usePersistFn_1["default"](fn);
react_1.useEffect(function () {
if (delay === undefined || delay === null) return;
var timer = setTimeout(function () {
var _a;
(_a = timerRef.current) === null || _a === void 0 ? void 0 : _a.call(timerRef);
timerFn();
}, delay);

@@ -23,5 +28,5 @@ return function () {

};
}, [delay]);
}, [delay, timerFn]);
}
exports["default"] = useTimeout;
"use strict";
var __importDefault = this && this.__importDefault || function (mod) {
return mod && mod.__esModule ? mod : {
"default": mod
};
};
Object.defineProperty(exports, "__esModule", {

@@ -9,2 +15,4 @@ value: true

var useUnmount_1 = __importDefault(require("../useUnmount"));
var DEFAULT_OPTIONS = {

@@ -23,11 +31,9 @@ restoreOnUnmount: false

}, [title]);
react_1.useEffect(function () {
useUnmount_1["default"](function () {
if (options && options.restoreOnUnmount) {
return function () {
document.title = titleRef.current;
};
document.title = titleRef.current;
}
}, []);
});
}
exports["default"] = typeof document !== 'undefined' ? useTitle : function (_title) {};
exports["default"] = typeof document !== 'undefined' ? useTitle : function () {};
"use strict";
var __importDefault = this && this.__importDefault || function (mod) {
return mod && mod.__esModule ? mod : {
"default": mod
};
};
Object.defineProperty(exports, "__esModule", {

@@ -9,14 +15,17 @@ value: true

var usePersistFn_1 = __importDefault(require("../usePersistFn"));
var utils_1 = require("../utils");
var useUnmount = function useUnmount(fn) {
var fnRef = react_1.useRef(fn);
fnRef.current = fn;
var fnPersist = usePersistFn_1["default"](fn);
react_1.useEffect(function () {
return function () {
if (fnRef.current && typeof fnRef.current === 'function') {
fnRef.current();
if (utils_1.isFunction(fnPersist)) {
fnPersist();
}
};
}, []);
}, [fnPersist]);
};
exports["default"] = useUnmount;

@@ -37,9 +37,7 @@ "use strict";

var useUpdate = function useUpdate() {
var _a = __read(react_1.useState(0), 2),
var _a = __read(react_1.useState({}), 2),
setState = _a[1];
return react_1.useCallback(function () {
return setState(function (num) {
return num + 1;
});
return setState({});
}, []);

@@ -46,0 +44,0 @@ };

@@ -10,2 +10,3 @@ export declare enum ReadyState {

reconnectInterval?: number;
manual?: boolean;
onOpen?: (event: WebSocketEventMap['open']) => void;

@@ -12,0 +13,0 @@ onClose?: (event: WebSocketEventMap['close']) => void;

@@ -65,2 +65,4 @@ "use strict";

reconnectInterval = _b === void 0 ? 3 * 1000 : _b,
_c = options.manual,
manual = _c === void 0 ? false : _c,
onOpen = options.onOpen,

@@ -74,9 +76,9 @@ onClose = options.onClose,

var _c = __read(react_1.useState(), 2),
latestMessage = _c[0],
setLatestMessage = _c[1];
var _d = __read(react_1.useState(), 2),
latestMessage = _d[0],
setLatestMessage = _d[1];
var _d = __read(react_1.useState(ReadyState.Closed), 2),
readyState = _d[0],
setReadyState = _d[1];
var _e = __read(react_1.useState(ReadyState.Closed), 2),
readyState = _e[0],
setReadyState = _e[1];
/**

@@ -175,4 +177,6 @@ * 重连

// 初始连接
connect();
}, [socketUrl]);
if (!manual) {
connect();
}
}, [socketUrl, manual]);
useUnmount_1["default"](function () {

@@ -179,0 +183,0 @@ disconnect();

{
"name": "ahooks",
"version": "2.9.1",
"version": "2.9.2",
"description": "react hooks library",

@@ -5,0 +5,0 @@ "keywords": [

Sorry, the diff of this file is too big to display

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