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

use-context-selector

Package Overview
Dependencies
Maintainers
1
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

use-context-selector - npm Package Compare versions

Comparing version 1.2.7 to 1.2.8

4

CHANGELOG.md

@@ -5,2 +5,6 @@ # Change Log

## [1.2.8] - 2020-10-08
### Changed
- Fix incomplete useBridgeValue implementation
## [1.2.7] - 2020-10-08

@@ -7,0 +11,0 @@ ### Changed

2

dist/index.modern.js

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

import e from"react";import{unstable_runWithPriority as r,unstable_NormalPriority as t}from"scheduler";let n;n=require("react-dom").unstable_batchedUpdates;const c="v",o="p",u="l",s="u",i=Symbol(),a=Symbol(),d="undefined"==typeof window||/ServerSideRendering/.test(window.navigator&&window.navigator.userAgent)?e.useEffect:e.useLayoutEffect,l=l=>{const f=e.createContext(l,()=>0);var v;return f[a]=f.Provider,f.Provider=(v=f.Provider,e.memo(({value:a,children:l})=>{const[f,p]=e.useState(0),E=e.useRef(0),w=e.useRef();w.current||(w.current=new Set);const h=e.useCallback(e=>{n(()=>{E.current+=1,p(E.current),w.current.forEach(e=>e(E.current)),e()})},[]);return d(()=>{E.current+=1,p(E.current),r(t,()=>{w.current.forEach(e=>{e(E.current,a)})})},[a]),e.createElement(v,{value:{[i]:{[c]:a,[o]:f,[u]:w.current,[s]:h}}},l)})),delete f.Consumer,f},f=(r,t)=>{const n=e.useContext(r)[i];if("production"!==process.env.NODE_ENV&&!n)throw new Error("useContextSelector requires special context");const{[c]:s,[o]:a,[u]:l}=n,f=t(s),v=e.useRef(null);d(()=>{v.current={f:t,v:s,s:f}});const[,p]=e.useReducer((e,r)=>{if(a<r)return e+1;try{if(v.current.v===s||Object.is(v.current.s,v.current.f(s)))return e}catch(e){}return e+1},0);return d(()=>{const e=(e,r)=>{try{if(r&&(v.current.v===r||Object.is(v.current.s,v.current.f(r))))return}catch(e){}p(e)};return l.add(e),()=>{l.delete(e)}},[l]),f},v=e=>e,p=e=>f(e,v),E=r=>{const t=e.useContext(r)[i];if("production"!==process.env.NODE_ENV&&!t)throw new Error("useContextUpdate requires special context");const{[s]:n}=t;return n},w=({context:r,value:t,children:n})=>{const{[a]:c}=r;if("production"!==process.env.NODE_ENV&&!c)throw new Error("BridgeProvider requires special context");return e.createElement(c,{value:t},n)},h=r=>{if("production"!==process.env.NODE_ENV){const{[a]:e}=r;if(!e)throw new Error("useBridgeValue requires special context")}return e.useContext(r)};export{w as BridgeProvider,l as createContext,h as useBridgeValue,p as useContext,f as useContextSelector,E as useContextUpdate};
import e from"react";import{unstable_runWithPriority as r,unstable_NormalPriority as t}from"scheduler";let n;n=require("react-dom").unstable_batchedUpdates;const c="v",o="p",u="l",s="u",i=Symbol(),a=Symbol(),d="undefined"==typeof window||/ServerSideRendering/.test(window.navigator&&window.navigator.userAgent)?e.useEffect:e.useLayoutEffect,l=l=>{const f=e.createContext(l,()=>0);var v;return f[a]=f.Provider,f.Provider=(v=f.Provider,e.memo(({value:a,children:l})=>{const[f,p]=e.useState(0),E=e.useRef(0),w=e.useRef();w.current||(w.current=new Set);const h=e.useCallback(e=>{n(()=>{E.current+=1,p(E.current),w.current.forEach(e=>e(E.current)),e()})},[]);return d(()=>{E.current+=1,p(E.current),r(t,()=>{w.current.forEach(e=>{e(E.current,a)})})},[a]),e.createElement(v,{value:{[i]:{[c]:a,[o]:f,[u]:w.current,[s]:h}}},l)})),delete f.Consumer,f},f=(r,t)=>{const n=e.useContext(r)[i];if("production"!==process.env.NODE_ENV&&!n)throw new Error("useContextSelector requires special context");const{[c]:s,[o]:a,[u]:l}=n,f=t(s),v=e.useRef(null);d(()=>{v.current={f:t,v:s,s:f}});const[,p]=e.useReducer((e,r)=>{if(a<r)return e+1;try{if(v.current.v===s||Object.is(v.current.s,v.current.f(s)))return e}catch(e){}return e+1},0);return d(()=>{const e=(e,r)=>{try{if(r&&(v.current.v===r||Object.is(v.current.s,v.current.f(r))))return}catch(e){}p(e)};return l.add(e),()=>{l.delete(e)}},[l]),f},v=e=>e,p=e=>f(e,v),E=r=>{const t=e.useContext(r)[i];if("production"!==process.env.NODE_ENV&&!t)throw new Error("useContextUpdate requires special context");const{[s]:n}=t;return n},w=({context:r,value:t,children:n})=>{const{[a]:c}=r;if("production"!==process.env.NODE_ENV&&!c)throw new Error("BridgeProvider requires special context");return e.createElement(c,{value:t},n)},h=r=>{const t=e.useContext(r),n=t[i];if("production"!==process.env.NODE_ENV&&!n)throw new Error("useBridgeValue requires special context");const{[u]:c}=n,[,o]=e.useReducer(e=>e+1,0);return d(()=>(c.add(o),()=>{c.delete(o)}),[c]),t};export{w as BridgeProvider,l as createContext,h as useBridgeValue,p as useContext,f as useContextSelector,E as useContextUpdate};
//# sourceMappingURL=index.modern.js.map

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

import e from"react";import{unstable_runWithPriority as r,unstable_NormalPriority as t}from"scheduler";let n;n=require("react-native").unstable_batchedUpdates;const c="v",o="p",u="l",s="u",i=Symbol(),a=Symbol(),d="undefined"==typeof window||/ServerSideRendering/.test(window.navigator&&window.navigator.userAgent)?e.useEffect:e.useLayoutEffect,l=l=>{const f=e.createContext(l,()=>0);var v;return f[a]=f.Provider,f.Provider=(v=f.Provider,e.memo(({value:a,children:l})=>{const[f,p]=e.useState(0),E=e.useRef(0),w=e.useRef();w.current||(w.current=new Set);const h=e.useCallback(e=>{n(()=>{E.current+=1,p(E.current),w.current.forEach(e=>e(E.current)),e()})},[]);return d(()=>{E.current+=1,p(E.current),r(t,()=>{w.current.forEach(e=>{e(E.current,a)})})},[a]),e.createElement(v,{value:{[i]:{[c]:a,[o]:f,[u]:w.current,[s]:h}}},l)})),delete f.Consumer,f},f=(r,t)=>{const n=e.useContext(r)[i];if("production"!==process.env.NODE_ENV&&!n)throw new Error("useContextSelector requires special context");const{[c]:s,[o]:a,[u]:l}=n,f=t(s),v=e.useRef(null);d(()=>{v.current={f:t,v:s,s:f}});const[,p]=e.useReducer((e,r)=>{if(a<r)return e+1;try{if(v.current.v===s||Object.is(v.current.s,v.current.f(s)))return e}catch(e){}return e+1},0);return d(()=>{const e=(e,r)=>{try{if(r&&(v.current.v===r||Object.is(v.current.s,v.current.f(r))))return}catch(e){}p(e)};return l.add(e),()=>{l.delete(e)}},[l]),f},v=e=>e,p=e=>f(e,v),E=r=>{const t=e.useContext(r)[i];if("production"!==process.env.NODE_ENV&&!t)throw new Error("useContextUpdate requires special context");const{[s]:n}=t;return n},w=({context:r,value:t,children:n})=>{const{[a]:c}=r;if("production"!==process.env.NODE_ENV&&!c)throw new Error("BridgeProvider requires special context");return e.createElement(c,{value:t},n)},h=r=>{if("production"!==process.env.NODE_ENV){const{[a]:e}=r;if(!e)throw new Error("useBridgeValue requires special context")}return e.useContext(r)};export{w as BridgeProvider,l as createContext,h as useBridgeValue,p as useContext,f as useContextSelector,E as useContextUpdate};
import e from"react";import{unstable_runWithPriority as r,unstable_NormalPriority as t}from"scheduler";let n;n=require("react-native").unstable_batchedUpdates;const c="v",u="p",o="l",s="u",i=Symbol(),a=Symbol(),d="undefined"==typeof window||/ServerSideRendering/.test(window.navigator&&window.navigator.userAgent)?e.useEffect:e.useLayoutEffect,l=l=>{const f=e.createContext(l,()=>0);var v;return f[a]=f.Provider,f.Provider=(v=f.Provider,e.memo(({value:a,children:l})=>{const[f,p]=e.useState(0),E=e.useRef(0),w=e.useRef();w.current||(w.current=new Set);const h=e.useCallback(e=>{n(()=>{E.current+=1,p(E.current),w.current.forEach(e=>e(E.current)),e()})},[]);return d(()=>{E.current+=1,p(E.current),r(t,()=>{w.current.forEach(e=>{e(E.current,a)})})},[a]),e.createElement(v,{value:{[i]:{[c]:a,[u]:f,[o]:w.current,[s]:h}}},l)})),delete f.Consumer,f},f=(r,t)=>{const n=e.useContext(r)[i];if("production"!==process.env.NODE_ENV&&!n)throw new Error("useContextSelector requires special context");const{[c]:s,[u]:a,[o]:l}=n,f=t(s),v=e.useRef(null);d(()=>{v.current={f:t,v:s,s:f}});const[,p]=e.useReducer((e,r)=>{if(a<r)return e+1;try{if(v.current.v===s||Object.is(v.current.s,v.current.f(s)))return e}catch(e){}return e+1},0);return d(()=>{const e=(e,r)=>{try{if(r&&(v.current.v===r||Object.is(v.current.s,v.current.f(r))))return}catch(e){}p(e)};return l.add(e),()=>{l.delete(e)}},[l]),f},v=e=>e,p=e=>f(e,v),E=r=>{const t=e.useContext(r)[i];if("production"!==process.env.NODE_ENV&&!t)throw new Error("useContextUpdate requires special context");const{[s]:n}=t;return n},w=({context:r,value:t,children:n})=>{const{[a]:c}=r;if("production"!==process.env.NODE_ENV&&!c)throw new Error("BridgeProvider requires special context");return e.createElement(c,{value:t},n)},h=r=>{const t=e.useContext(r),n=t[i];if("production"!==process.env.NODE_ENV&&!n)throw new Error("useBridgeValue requires special context");const{[o]:c}=n,[,u]=e.useReducer(e=>e+1,0);return d(()=>(c.add(u),()=>{c.delete(u)}),[c]),t};export{w as BridgeProvider,l as createContext,h as useBridgeValue,p as useContext,f as useContextSelector,E as useContextUpdate};
//# sourceMappingURL=index.native.modern.js.map

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

!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("react"),require("scheduler")):"function"==typeof define&&define.amd?define(["exports","react","scheduler"],r):r((e=e||self).useContextSelector={},e.react,e.scheduler)}(this,function(e,r,t){var n;r=r&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r,n=require("react-native").unstable_batchedUpdates;var u=Symbol(),o=Symbol(),c="undefined"==typeof window||/ServerSideRendering/.test(window.navigator&&window.navigator.userAgent)?r.useEffect:r.useLayoutEffect,i=function(e,t){var n=r.useContext(e)[u];if("production"!==process.env.NODE_ENV&&!n)throw new Error("useContextSelector requires special context");var o=n.v,i=n.p,a=n.l,s=t(o),f=r.useRef(null);c(function(){f.current={f:t,v:o,s:s}});var d=r.useReducer(function(e,r){if(i<r)return e+1;try{if(f.current.v===o||Object.is(f.current.s,f.current.f(o)))return e}catch(e){}return e+1},0)[1];return c(function(){var e=function(e,r){try{if(r&&(f.current.v===r||Object.is(f.current.s,f.current.f(r))))return}catch(e){}d(e)};return a.add(e),function(){a.delete(e)}},[a]),s},a=function(e){return e};e.BridgeProvider=function(e){var t=e.value,n=e.children,u=e.context[o];if("production"!==process.env.NODE_ENV&&!u)throw new Error("BridgeProvider requires special context");return r.createElement(u,{value:t},n)},e.createContext=function(e){var i,a=r.createContext(e,function(){return 0});return a[o]=a.Provider,a.Provider=(i=a.Provider,r.memo(function(e){var o,a,s=e.value,f=e.children,d=r.useState(0),l=d[0],v=d[1],p=r.useRef(0),x=r.useRef();x.current||(x.current=new Set);var E=r.useCallback(function(e){n(function(){p.current+=1,v(p.current),x.current.forEach(function(e){return e(p.current)}),e()})},[]);c(function(){p.current+=1,v(p.current),t.unstable_runWithPriority(t.unstable_NormalPriority,function(){x.current.forEach(function(e){e(p.current,s)})})},[s]);var h=((o={}).v=s,o.p=l,o.l=x.current,o.u=E,o);return r.createElement(i,{value:(a={},a[u]=h,a)},f)})),delete a.Consumer,a},e.useBridgeValue=function(e){if("production"!==process.env.NODE_ENV&&!e[o])throw new Error("useBridgeValue requires special context");return r.useContext(e)},e.useContext=function(e){return i(e,a)},e.useContextSelector=i,e.useContextUpdate=function(e){var t=r.useContext(e)[u];if("production"!==process.env.NODE_ENV&&!t)throw new Error("useContextUpdate requires special context");return t.u}});
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("react"),require("scheduler")):"function"==typeof define&&define.amd?define(["exports","react","scheduler"],r):r((e=e||self).useContextSelector={},e.react,e.scheduler)}(this,function(e,r,t){var n;r=r&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r,n=require("react-native").unstable_batchedUpdates;var u=Symbol(),o=Symbol(),c="undefined"==typeof window||/ServerSideRendering/.test(window.navigator&&window.navigator.userAgent)?r.useEffect:r.useLayoutEffect,i=function(e,t){var n=r.useContext(e)[u];if("production"!==process.env.NODE_ENV&&!n)throw new Error("useContextSelector requires special context");var o=n.v,i=n.p,a=n.l,f=t(o),s=r.useRef(null);c(function(){s.current={f:t,v:o,s:f}});var d=r.useReducer(function(e,r){if(i<r)return e+1;try{if(s.current.v===o||Object.is(s.current.s,s.current.f(o)))return e}catch(e){}return e+1},0)[1];return c(function(){var e=function(e,r){try{if(r&&(s.current.v===r||Object.is(s.current.s,s.current.f(r))))return}catch(e){}d(e)};return a.add(e),function(){a.delete(e)}},[a]),f},a=function(e){return e};e.BridgeProvider=function(e){var t=e.value,n=e.children,u=e.context[o];if("production"!==process.env.NODE_ENV&&!u)throw new Error("BridgeProvider requires special context");return r.createElement(u,{value:t},n)},e.createContext=function(e){var i,a=r.createContext(e,function(){return 0});return a[o]=a.Provider,a.Provider=(i=a.Provider,r.memo(function(e){var o,a,f=e.value,s=e.children,d=r.useState(0),l=d[0],v=d[1],p=r.useRef(0),x=r.useRef();x.current||(x.current=new Set);var E=r.useCallback(function(e){n(function(){p.current+=1,v(p.current),x.current.forEach(function(e){return e(p.current)}),e()})},[]);c(function(){p.current+=1,v(p.current),t.unstable_runWithPriority(t.unstable_NormalPriority,function(){x.current.forEach(function(e){e(p.current,f)})})},[f]);var h=((o={}).v=f,o.p=l,o.l=x.current,o.u=E,o);return r.createElement(i,{value:(a={},a[u]=h,a)},s)})),delete a.Consumer,a},e.useBridgeValue=function(e){var t=r.useContext(e),n=t[u];if("production"!==process.env.NODE_ENV&&!n)throw new Error("useBridgeValue requires special context");var o=n.l,i=r.useReducer(function(e){return e+1},0)[1];return c(function(){return o.add(i),function(){o.delete(i)}},[o]),t},e.useContext=function(e){return i(e,a)},e.useContextSelector=i,e.useContextUpdate=function(e){var t=r.useContext(e)[u];if("production"!==process.env.NODE_ENV&&!t)throw new Error("useContextUpdate requires special context");return t.u}});
//# sourceMappingURL=index.native.umd.js.map

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

!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("react"),require("scheduler")):"function"==typeof define&&define.amd?define(["exports","react","scheduler"],r):r((e=e||self).useContextSelector={},e.react,e.scheduler)}(this,function(e,r,t){var n;r=r&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r,n=require("react-dom").unstable_batchedUpdates;var u=Symbol(),o=Symbol(),c="undefined"==typeof window||/ServerSideRendering/.test(window.navigator&&window.navigator.userAgent)?r.useEffect:r.useLayoutEffect,i=function(e,t){var n=r.useContext(e)[u];if("production"!==process.env.NODE_ENV&&!n)throw new Error("useContextSelector requires special context");var o=n.v,i=n.p,a=n.l,s=t(o),f=r.useRef(null);c(function(){f.current={f:t,v:o,s:s}});var d=r.useReducer(function(e,r){if(i<r)return e+1;try{if(f.current.v===o||Object.is(f.current.s,f.current.f(o)))return e}catch(e){}return e+1},0)[1];return c(function(){var e=function(e,r){try{if(r&&(f.current.v===r||Object.is(f.current.s,f.current.f(r))))return}catch(e){}d(e)};return a.add(e),function(){a.delete(e)}},[a]),s},a=function(e){return e};e.BridgeProvider=function(e){var t=e.value,n=e.children,u=e.context[o];if("production"!==process.env.NODE_ENV&&!u)throw new Error("BridgeProvider requires special context");return r.createElement(u,{value:t},n)},e.createContext=function(e){var i,a=r.createContext(e,function(){return 0});return a[o]=a.Provider,a.Provider=(i=a.Provider,r.memo(function(e){var o,a,s=e.value,f=e.children,d=r.useState(0),l=d[0],v=d[1],p=r.useRef(0),x=r.useRef();x.current||(x.current=new Set);var E=r.useCallback(function(e){n(function(){p.current+=1,v(p.current),x.current.forEach(function(e){return e(p.current)}),e()})},[]);c(function(){p.current+=1,v(p.current),t.unstable_runWithPriority(t.unstable_NormalPriority,function(){x.current.forEach(function(e){e(p.current,s)})})},[s]);var h=((o={}).v=s,o.p=l,o.l=x.current,o.u=E,o);return r.createElement(i,{value:(a={},a[u]=h,a)},f)})),delete a.Consumer,a},e.useBridgeValue=function(e){if("production"!==process.env.NODE_ENV&&!e[o])throw new Error("useBridgeValue requires special context");return r.useContext(e)},e.useContext=function(e){return i(e,a)},e.useContextSelector=i,e.useContextUpdate=function(e){var t=r.useContext(e)[u];if("production"!==process.env.NODE_ENV&&!t)throw new Error("useContextUpdate requires special context");return t.u}});
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("react"),require("scheduler")):"function"==typeof define&&define.amd?define(["exports","react","scheduler"],r):r((e=e||self).useContextSelector={},e.react,e.scheduler)}(this,function(e,r,t){var n;r=r&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r,n=require("react-dom").unstable_batchedUpdates;var u=Symbol(),o=Symbol(),c="undefined"==typeof window||/ServerSideRendering/.test(window.navigator&&window.navigator.userAgent)?r.useEffect:r.useLayoutEffect,i=function(e,t){var n=r.useContext(e)[u];if("production"!==process.env.NODE_ENV&&!n)throw new Error("useContextSelector requires special context");var o=n.v,i=n.p,a=n.l,f=t(o),s=r.useRef(null);c(function(){s.current={f:t,v:o,s:f}});var d=r.useReducer(function(e,r){if(i<r)return e+1;try{if(s.current.v===o||Object.is(s.current.s,s.current.f(o)))return e}catch(e){}return e+1},0)[1];return c(function(){var e=function(e,r){try{if(r&&(s.current.v===r||Object.is(s.current.s,s.current.f(r))))return}catch(e){}d(e)};return a.add(e),function(){a.delete(e)}},[a]),f},a=function(e){return e};e.BridgeProvider=function(e){var t=e.value,n=e.children,u=e.context[o];if("production"!==process.env.NODE_ENV&&!u)throw new Error("BridgeProvider requires special context");return r.createElement(u,{value:t},n)},e.createContext=function(e){var i,a=r.createContext(e,function(){return 0});return a[o]=a.Provider,a.Provider=(i=a.Provider,r.memo(function(e){var o,a,f=e.value,s=e.children,d=r.useState(0),l=d[0],v=d[1],p=r.useRef(0),x=r.useRef();x.current||(x.current=new Set);var E=r.useCallback(function(e){n(function(){p.current+=1,v(p.current),x.current.forEach(function(e){return e(p.current)}),e()})},[]);c(function(){p.current+=1,v(p.current),t.unstable_runWithPriority(t.unstable_NormalPriority,function(){x.current.forEach(function(e){e(p.current,f)})})},[f]);var h=((o={}).v=f,o.p=l,o.l=x.current,o.u=E,o);return r.createElement(i,{value:(a={},a[u]=h,a)},s)})),delete a.Consumer,a},e.useBridgeValue=function(e){var t=r.useContext(e),n=t[u];if("production"!==process.env.NODE_ENV&&!n)throw new Error("useBridgeValue requires special context");var o=n.l,i=r.useReducer(function(e){return e+1},0)[1];return c(function(){return o.add(i),function(){o.delete(i)}},[o]),t},e.useContext=function(e){return i(e,a)},e.useContextSelector=i,e.useContextUpdate=function(e){var t=r.useContext(e)[u];if("production"!==process.env.NODE_ENV&&!t)throw new Error("useContextUpdate requires special context");return t.u}});
//# sourceMappingURL=index.umd.js.map
{
"name": "use-context-selector",
"description": "React useContextSelector hook in userland",
"version": "1.2.7",
"version": "1.2.8",
"author": "Daishi Kato",

@@ -6,0 +6,0 @@ "repository": {

@@ -214,9 +214,20 @@ import React from 'react';

export const useBridgeValue = (context) => {
const bridgeValue = React.useContext(context);
const contextValue = bridgeValue[CONTEXT_VALUE];
if (process.env.NODE_ENV !== 'production') {
const { [ORIGINAL_PROVIDER]: Provider } = context;
if (!Provider) {
if (!contextValue) {
throw new Error('useBridgeValue requires special context');
}
}
return React.useContext(context);
const {
[LISTENERS_PROP]: listeners,
} = contextValue;
const [, forceUpdate] = React.useReducer((c) => c + 1, 0);
useIsomorphicLayoutEffect(() => {
listeners.add(forceUpdate);
return () => {
listeners.delete(forceUpdate);
};
}, [listeners]);
return bridgeValue;
};

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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