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

@react-hookz/web

Package Overview
Dependencies
Maintainers
2
Versions
130
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@react-hookz/web - npm Package Compare versions

Comparing version 1.16.0 to 1.17.0

7

CHANGELOG.md

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

# [1.17.0](https://github.com/react-hookz/web/compare/v1.16.0...v1.17.0) (2021-05-06)
### Features
* use stricter TS config and fix issues caused by this ([6af7867](https://github.com/react-hookz/web/commit/6af786767f4d68c64b4116eb2e92f1343100aaf8))
# [1.16.0](https://github.com/react-hookz/web/compare/v1.15.0...v1.16.0) (2021-05-06)

@@ -2,0 +9,0 @@

6

cjs/useMediatedState.d.ts

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

export declare function useMediatedState<S>(initialState?: S | (() => S)): [S, (value: S | (() => S)) => void];
export declare function useMediatedState<S, R>(initialState?: S | (() => S), mediator?: (state: R) => S): [S, (value: R | ((prevState: S) => S)) => void];
import { Dispatch } from 'react';
import { IInitialState, INextState } from './util/resolveHookState';
export declare function useMediatedState<State>(initialState?: IInitialState<State>): [State, Dispatch<State>];
export declare function useMediatedState<State, RawState>(initialState: IInitialState<State>, mediator?: (state: RawState) => State): [State, Dispatch<INextState<RawState, State>>];

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

react_1.useCallback(function (value) {
if (mediator) {
setState(function (prevState) {
return mediatorRef.current(resolveHookState_1.resolveHookState(value, prevState));
});
var m = mediatorRef.current;
if (m) {
setState(function (prevState) { return m(resolveHookState_1.resolveHookState(value, prevState)); });
}

@@ -24,0 +23,0 @@ else {

@@ -63,7 +63,5 @@ import { IInitialState } from './util/resolveHookState';

}
declare const navigator: (Navigator & Partial<Record<'connection' | 'mozConnection' | 'webkitConnection', INetworkInformation>>) | undefined;
/**
* Tracks the state of browser's network connection.
*/
export declare const useNetworkState: typeof navigator.connection extends undefined ? undefined : (initialState?: IInitialState<IUseNetworkState>) => IUseNetworkState;
export {};
export declare function useNetworkState(initialState?: IInitialState<IUseNetworkState>): IUseNetworkState;

@@ -28,28 +28,27 @@ "use strict";

*/
exports.useNetworkState = const_1.isBrowser
? function useNetworkState(initialState) {
var _a = useSafeState_1.useSafeState(initialState !== null && initialState !== void 0 ? initialState : getConnectionState), state = _a[0], setState = _a[1];
react_1.useEffect(function () {
var handleStateChange = function () {
setState(getConnectionState);
};
misc_1.on(window, 'online', handleStateChange, { passive: true });
misc_1.on(window, 'offline', handleStateChange, { passive: true });
// it is quite hard to test it in jsdom environment maybe will be improved in future
function useNetworkState(initialState) {
var _a = useSafeState_1.useSafeState(initialState !== null && initialState !== void 0 ? initialState : getConnectionState), state = _a[0], setState = _a[1];
react_1.useEffect(function () {
var handleStateChange = function () {
setState(getConnectionState);
};
misc_1.on(window, 'online', handleStateChange, { passive: true });
misc_1.on(window, 'offline', handleStateChange, { passive: true });
// it is quite hard to test it in jsdom environment maybe will be improved in future
/* istanbul ignore next */
if (conn) {
misc_1.on(conn, 'change', handleStateChange, { passive: true });
}
return function () {
misc_1.off(window, 'online', handleStateChange);
misc_1.off(window, 'offline', handleStateChange);
/* istanbul ignore next */
if (conn) {
misc_1.on(conn, 'change', handleStateChange, { passive: true });
misc_1.off(conn, 'change', handleStateChange);
}
return function () {
misc_1.off(window, 'online', handleStateChange);
misc_1.off(window, 'offline', handleStateChange);
/* istanbul ignore next */
if (conn) {
misc_1.off(conn, 'change', handleStateChange);
}
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
return state;
}
: const_1.noop;
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
return state;
}
exports.useNetworkState = useNetworkState;

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

import { IInitialState, INewState } from './util/resolveHookState';
import { IInitialState, INextState } from './util/resolveHookState';
/**

@@ -9,2 +9,2 @@ * Like `useSafeState`, but can only become `true` or `false`.

*/
export declare function useToggle(initialState?: IInitialState<boolean>): [boolean, (nextState?: INewState<boolean>) => void];
export declare function useToggle(initialState?: IInitialState<boolean>): [boolean, (nextState?: INextState<boolean>) => void];
export declare const noop: () => void;
export declare const bypass: <T>(v: T) => T;
export declare const isBrowser: boolean;
export declare function truthyArrayItemsPredicate(conditions: ReadonlyArray<any>): boolean;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.truthyArrayItemsPredicate = exports.isBrowser = exports.noop = void 0;
exports.truthyArrayItemsPredicate = exports.isBrowser = exports.bypass = exports.noop = void 0;
var noop = function () { };
exports.noop = noop;
var bypass = function (v) { return v; };
exports.bypass = bypass;
exports.isBrowser = typeof window !== 'undefined' &&

@@ -7,0 +9,0 @@ typeof navigator !== 'undefined' &&

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

export declare type IInitialState<S> = S | (() => S);
export declare type INewState<S> = S | ((prevState: S) => S);
export declare function resolveHookState<S>(nextState: IInitialState<S>): S;
export declare function resolveHookState<S>(nextState: INewState<S>, prevState: S): S;
export declare type IInitialState<State> = State | (() => State);
export declare type INextState<State, PrevState = State> = State | ((prevState: PrevState) => State);
export declare function resolveHookState<State>(nextState: IInitialState<State>): State;
export declare function resolveHookState<State, PrevState = State>(nextState: INextState<State, PrevState>, prevState: PrevState): State;

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

export declare function useMediatedState<S>(initialState?: S | (() => S)): [S, (value: S | (() => S)) => void];
export declare function useMediatedState<S, R>(initialState?: S | (() => S), mediator?: (state: R) => S): [S, (value: R | ((prevState: S) => S)) => void];
import { Dispatch } from 'react';
import { IInitialState, INextState } from './util/resolveHookState';
export declare function useMediatedState<State>(initialState?: IInitialState<State>): [State, Dispatch<State>];
export declare function useMediatedState<State, RawState>(initialState: IInitialState<State>, mediator?: (state: RawState) => State): [State, Dispatch<INextState<RawState, State>>];

@@ -15,6 +15,5 @@ import { useCallback, useRef } from 'react';

useCallback(function (value) {
if (mediator) {
setState(function (prevState) {
return mediatorRef.current(resolveHookState(value, prevState));
});
var m = mediatorRef.current;
if (m) {
setState(function (prevState) { return m(resolveHookState(value, prevState)); });
}

@@ -21,0 +20,0 @@ else {

@@ -63,7 +63,5 @@ import { IInitialState } from './util/resolveHookState';

}
declare const navigator: (Navigator & Partial<Record<'connection' | 'mozConnection' | 'webkitConnection', INetworkInformation>>) | undefined;
/**
* Tracks the state of browser's network connection.
*/
export declare const useNetworkState: typeof navigator.connection extends undefined ? undefined : (initialState?: IInitialState<IUseNetworkState>) => IUseNetworkState;
export {};
export declare function useNetworkState(initialState?: IInitialState<IUseNetworkState>): IUseNetworkState;
import { useEffect } from 'react';
import { isBrowser, noop } from "./util/const.js";
import { isBrowser } from "./util/const.js";
import { useSafeState } from "./useSafeState.js";

@@ -25,28 +25,26 @@ import { off, on } from "./util/misc.js";

*/
export var useNetworkState = isBrowser
? function useNetworkState(initialState) {
var _a = useSafeState(initialState !== null && initialState !== void 0 ? initialState : getConnectionState), state = _a[0], setState = _a[1];
useEffect(function () {
var handleStateChange = function () {
setState(getConnectionState);
};
on(window, 'online', handleStateChange, { passive: true });
on(window, 'offline', handleStateChange, { passive: true });
// it is quite hard to test it in jsdom environment maybe will be improved in future
export function useNetworkState(initialState) {
var _a = useSafeState(initialState !== null && initialState !== void 0 ? initialState : getConnectionState), state = _a[0], setState = _a[1];
useEffect(function () {
var handleStateChange = function () {
setState(getConnectionState);
};
on(window, 'online', handleStateChange, { passive: true });
on(window, 'offline', handleStateChange, { passive: true });
// it is quite hard to test it in jsdom environment maybe will be improved in future
/* istanbul ignore next */
if (conn) {
on(conn, 'change', handleStateChange, { passive: true });
}
return function () {
off(window, 'online', handleStateChange);
off(window, 'offline', handleStateChange);
/* istanbul ignore next */
if (conn) {
on(conn, 'change', handleStateChange, { passive: true });
off(conn, 'change', handleStateChange);
}
return function () {
off(window, 'online', handleStateChange);
off(window, 'offline', handleStateChange);
/* istanbul ignore next */
if (conn) {
off(conn, 'change', handleStateChange);
}
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
return state;
}
: noop;
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
return state;
}

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

import { IInitialState, INewState } from './util/resolveHookState';
import { IInitialState, INextState } from './util/resolveHookState';
/**

@@ -9,2 +9,2 @@ * Like `useSafeState`, but can only become `true` or `false`.

*/
export declare function useToggle(initialState?: IInitialState<boolean>): [boolean, (nextState?: INewState<boolean>) => void];
export declare function useToggle(initialState?: IInitialState<boolean>): [boolean, (nextState?: INextState<boolean>) => void];
export declare const noop: () => void;
export declare const bypass: <T>(v: T) => T;
export declare const isBrowser: boolean;
export declare function truthyArrayItemsPredicate(conditions: ReadonlyArray<any>): boolean;
export var noop = function () { };
export var bypass = function (v) { return v; };
export var isBrowser = typeof window !== 'undefined' &&

@@ -3,0 +4,0 @@ typeof navigator !== 'undefined' &&

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

export declare type IInitialState<S> = S | (() => S);
export declare type INewState<S> = S | ((prevState: S) => S);
export declare function resolveHookState<S>(nextState: IInitialState<S>): S;
export declare function resolveHookState<S>(nextState: INewState<S>, prevState: S): S;
export declare type IInitialState<State> = State | (() => State);
export declare type INextState<State, PrevState = State> = State | ((prevState: PrevState) => State);
export declare function resolveHookState<State>(nextState: IInitialState<State>): State;
export declare function resolveHookState<State, PrevState = State>(nextState: INextState<State, PrevState>, prevState: PrevState): State;

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

export declare function useMediatedState<S>(initialState?: S | (() => S)): [S, (value: S | (() => S)) => void];
export declare function useMediatedState<S, R>(initialState?: S | (() => S), mediator?: (state: R) => S): [S, (value: R | ((prevState: S) => S)) => void];
import { Dispatch } from 'react';
import { IInitialState, INextState } from './util/resolveHookState';
export declare function useMediatedState<State>(initialState?: IInitialState<State>): [State, Dispatch<State>];
export declare function useMediatedState<State, RawState>(initialState: IInitialState<State>, mediator?: (state: RawState) => State): [State, Dispatch<INextState<RawState, State>>];

@@ -15,4 +15,5 @@ import { useCallback, useRef } from 'react';

useCallback((value) => {
if (mediator) {
setState((prevState) => mediatorRef.current(resolveHookState(value, prevState)));
const m = mediatorRef.current;
if (m) {
setState((prevState) => m(resolveHookState(value, prevState)));
}

@@ -19,0 +20,0 @@ else {

@@ -63,7 +63,5 @@ import { IInitialState } from './util/resolveHookState';

}
declare const navigator: (Navigator & Partial<Record<'connection' | 'mozConnection' | 'webkitConnection', INetworkInformation>>) | undefined;
/**
* Tracks the state of browser's network connection.
*/
export declare const useNetworkState: typeof navigator.connection extends undefined ? undefined : (initialState?: IInitialState<IUseNetworkState>) => IUseNetworkState;
export {};
export declare function useNetworkState(initialState?: IInitialState<IUseNetworkState>): IUseNetworkState;
import { useEffect } from 'react';
import { isBrowser, noop } from "./util/const.js";
import { isBrowser } from "./util/const.js";
import { useSafeState } from "./useSafeState.js";

@@ -25,28 +25,26 @@ import { off, on } from "./util/misc.js";

*/
export const useNetworkState = isBrowser
? function useNetworkState(initialState) {
const [state, setState] = useSafeState(initialState ?? getConnectionState);
useEffect(() => {
const handleStateChange = () => {
setState(getConnectionState);
};
on(window, 'online', handleStateChange, { passive: true });
on(window, 'offline', handleStateChange, { passive: true });
// it is quite hard to test it in jsdom environment maybe will be improved in future
export function useNetworkState(initialState) {
const [state, setState] = useSafeState(initialState ?? getConnectionState);
useEffect(() => {
const handleStateChange = () => {
setState(getConnectionState);
};
on(window, 'online', handleStateChange, { passive: true });
on(window, 'offline', handleStateChange, { passive: true });
// it is quite hard to test it in jsdom environment maybe will be improved in future
/* istanbul ignore next */
if (conn) {
on(conn, 'change', handleStateChange, { passive: true });
}
return () => {
off(window, 'online', handleStateChange);
off(window, 'offline', handleStateChange);
/* istanbul ignore next */
if (conn) {
on(conn, 'change', handleStateChange, { passive: true });
off(conn, 'change', handleStateChange);
}
return () => {
off(window, 'online', handleStateChange);
off(window, 'offline', handleStateChange);
/* istanbul ignore next */
if (conn) {
off(conn, 'change', handleStateChange);
}
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
return state;
}
: noop;
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
return state;
}

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

import { IInitialState, INewState } from './util/resolveHookState';
import { IInitialState, INextState } from './util/resolveHookState';
/**

@@ -9,2 +9,2 @@ * Like `useSafeState`, but can only become `true` or `false`.

*/
export declare function useToggle(initialState?: IInitialState<boolean>): [boolean, (nextState?: INewState<boolean>) => void];
export declare function useToggle(initialState?: IInitialState<boolean>): [boolean, (nextState?: INextState<boolean>) => void];
export declare const noop: () => void;
export declare const bypass: <T>(v: T) => T;
export declare const isBrowser: boolean;
export declare function truthyArrayItemsPredicate(conditions: ReadonlyArray<any>): boolean;
export const noop = () => { };
export const bypass = (v) => v;
export const isBrowser = typeof window !== 'undefined' &&

@@ -3,0 +4,0 @@ typeof navigator !== 'undefined' &&

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

export declare type IInitialState<S> = S | (() => S);
export declare type INewState<S> = S | ((prevState: S) => S);
export declare function resolveHookState<S>(nextState: IInitialState<S>): S;
export declare function resolveHookState<S>(nextState: INewState<S>, prevState: S): S;
export declare type IInitialState<State> = State | (() => State);
export declare type INextState<State, PrevState = State> = State | ((prevState: PrevState) => State);
export declare function resolveHookState<State>(nextState: IInitialState<State>): State;
export declare function resolveHookState<State, PrevState = State>(nextState: INextState<State, PrevState>, prevState: PrevState): State;
{
"name": "@react-hookz/web",
"version": "1.16.0",
"version": "1.17.0",
"description": "React hooks done right, for browser and SSR.",

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

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