Socket
Socket
Sign inDemoInstall

use-sync-external-store

Package Overview
Dependencies
Maintainers
1
Versions
1365
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

use-sync-external-store - npm Package Compare versions

Comparing version 0.0.0-experimental-3ee7a004e-20210920 to 0.0.0-experimental-4298ddbc5-20211023

cjs/use-sync-external-store.native.development.js

46

cjs/use-sync-external-store-extra.development.js

@@ -14,4 +14,25 @@ /** @license React vundefined

(function() {
'use strict';
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
// Don't require this file directly; it's embedded by Rollup during build.
if (
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart ===
'function'
) {
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
}
'use strict';
var React = require('react');

@@ -100,3 +121,2 @@ var useSyncExternalStore = require('use-sync-external-store');

// The snapshot has changed, so we need to compute a new selection.
memoizedSnapshot = nextSnapshot;
var nextSelection = selector(nextSnapshot); // If a custom isEqual function is provided, use that to check if the data

@@ -115,2 +135,3 @@ // has changed. If it hasn't, return the previous selection. That signals

memoizedSnapshot = nextSnapshot;
memoizedSelection = nextSelection;

@@ -146,3 +167,24 @@ return nextSelection;

exports.useSyncExternalStoreExtra = useSyncExternalStoreExtra;
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
// Don't require this file directly; it's embedded by Rollup during build.
if (
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop ===
'function'
) {
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
}
})();
}

6

cjs/use-sync-external-store-extra.production.min.js

@@ -9,4 +9,4 @@ /** @license React vundefined

*/
'use strict';var h=require("react"),p=require("use-sync-external-store");function q(a,e){return a===e&&(0!==a||1/a===1/e)||a!==a&&e!==e}var r="function"===typeof Object.is?Object.is:q,t=h.useRef,u=h.useEffect,v=h.useMemo,w=h.useDebugValue;
exports.useSyncExternalStoreExtra=function(a,e,l,m,g){var c=t(null);if(null===c.current){var f={hasValue:!1,value:null};c.current=f}else f=c.current;c=v(function(){function a(b){if(!c){c=!0;d=b;var a=m(b);return void 0!==g&&f.hasValue&&(b=f.value,g(b,a))?k=b:k=a}a=k;if(r(d,b))return a;d=b;b=m(b);return void 0!==g&&g(a,b)?a:k=b}var c=!1,d,k,n=void 0===l?null:l;return[function(){return a(e())},null===n?void 0:function(){return a(n())}]},[e,l,m,g]);var d=p.useSyncExternalStore(a,c[0],c[1]);u(function(){f.hasValue=
!0;f.value=d},[d]);w(d);return d};
'use strict';var h=require("react"),n=require("use-sync-external-store");function p(a,b){return a===b&&(0!==a||1/a===1/b)||a!==a&&b!==b}var q="function"===typeof Object.is?Object.is:p,r=h.useRef,t=h.useEffect,u=h.useMemo,v=h.useDebugValue;
exports.useSyncExternalStoreExtra=function(a,b,e,l,g){var c=r(null);if(null===c.current){var f={hasValue:!1,value:null};c.current=f}else f=c.current;c=u(function(){function a(a){if(!c){c=!0;d=a;a=l(a);if(void 0!==g&&f.hasValue){var b=f.value;if(g(b,a))return k=b}return k=a}b=k;if(q(d,a))return b;var e=l(a);if(void 0!==g&&g(b,e))return b;d=a;return k=e}var c=!1,d,k,m=void 0===e?null:e;return[function(){return a(b())},null===m?void 0:function(){return a(m())}]},[b,e,l,g]);var d=n.useSyncExternalStore(a,
c[0],c[1]);t(function(){f.hasValue=!0;f.value=d},[d]);v(d);return d};

@@ -14,6 +14,29 @@ /** @license React vundefined

(function() {
'use strict';
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
// Don't require this file directly; it's embedded by Rollup during build.
if (
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart ===
'function'
) {
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
}
'use strict';
var React = require('react');
var canUseDOM = !!(typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined');
var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;

@@ -43,6 +66,7 @@

args = args.concat([stack]);
}
} // eslint-disable-next-line react-internal/safe-string-coercion
var argsWithFormat = args.map(function (item) {
return '' + item;
return String(item);
}); // Careful: RN currently depends on this prefix

@@ -69,4 +93,2 @@

var canUseDOM = !!(typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined');
// dispatch for CommonJS interop named imports.

@@ -77,25 +99,5 @@

useLayoutEffect = React.useLayoutEffect,
useDebugValue = React.useDebugValue,
builtInAPI = React.unstable_useSyncExternalStore; // TODO: This heuristic doesn't work in React Native. We'll need to provide a
// special build, using the `.native` extension.
var isServerEnvironment = !canUseDOM; // Prefer the built-in API, if it exists. If it doesn't exist, then we assume
// we're in version 16 or 17, so rendering is always synchronous. The shim
// does not support concurrent rendering, only the built-in API.
var useSyncExternalStore = builtInAPI !== undefined ? builtInAPI : isServerEnvironment ? useSyncExternalStore_server : useSyncExternalStore_client;
useDebugValue = React.useDebugValue;
var didWarnOld18Alpha = false;
var didWarnUncachedGetSnapshot = false;
function useSyncExternalStore_server(subscribe, getSnapshot, getServerSnapshot) {
if (getServerSnapshot === undefined) {
{
{
throw Error( "Missing getServerSnapshot, which is required for server-rendered content." );
}
}
}
return getServerSnapshot();
} // Disclaimer: This shim breaks many of the rules of React, and only works
var didWarnUncachedGetSnapshot = false; // Disclaimer: This shim breaks many of the rules of React, and only works
// because of a very particular set of implementation details and assumptions

@@ -111,4 +113,3 @@ // -- change any one of them and it will break. The most important assumption

function useSyncExternalStore_client(subscribe, getSnapshot, // Note: The client shim does not use getServerSnapshot, because pre-18
function useSyncExternalStore(subscribe, getSnapshot, // Note: The client shim does not use getServerSnapshot, because pre-18
// versions of React do not expose a way to check if we're hydrating. So

@@ -228,4 +229,32 @@ // users of the shim will need to track that themselves and return the

exports.useSyncExternalStore = useSyncExternalStore;
function useSyncExternalStore$1(subscribe, getSnapshot, getServerSnapshot) {
return getSnapshot();
}
var builtInAPI = React.unstable_useSyncExternalStore;
var useSyncExternalStore$2 = builtInAPI !== undefined ? builtInAPI : canUseDOM ? useSyncExternalStore : useSyncExternalStore$1;
exports.useSyncExternalStore = useSyncExternalStore$2;
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
// Don't require this file directly; it's embedded by Rollup during build.
if (
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop ===
'function'
) {
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
}
})();
}

@@ -9,4 +9,3 @@ /** @license React vundefined

*/
'use strict';var e=require("react");function h(a){for(var b="https://reactjs.org/docs/error-decoder.html?invariant="+a,c=1;c<arguments.length;c++)b+="&args[]="+encodeURIComponent(arguments[c]);return"Minified React error #"+a+"; visit "+b+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function k(a,b){return a===b&&(0!==a||1/a===1/b)||a!==a&&b!==b}
var l="function"===typeof Object.is?Object.is:k,m=e.useState,n=e.useEffect,p=e.useLayoutEffect,q=e.useDebugValue,r=e.unstable_useSyncExternalStore,t=!("undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement);function u(a,b,c){if(void 0===c)throw Error(h(408));return c()}
function v(a,b){var c=b(),f=m({inst:{value:c,getSnapshot:b}}),d=f[0].inst,g=f[1];p(function(){d.value=c;d.getSnapshot=b;w(d)&&g({inst:d})},[a,c,b]);n(function(){w(d)&&g({inst:d});return a(function(){w(d)&&g({inst:d})})},[a]);q(c);return c}function w(a){var b=a.getSnapshot;a=a.value;try{var c=b();return!l(a,c)}catch(f){return!0}}exports.useSyncExternalStore=void 0!==r?r:t?u:v;
'use strict';var e=require("react"),h=!("undefined"===typeof window||"undefined"===typeof window.document||"undefined"===typeof window.document.createElement);function k(a,b){return a===b&&(0!==a||1/a===1/b)||a!==a&&b!==b}var l="function"===typeof Object.is?Object.is:k,m=e.useState,n=e.useEffect,p=e.useLayoutEffect,q=e.useDebugValue;
function r(a,b){var d=b(),f=m({inst:{value:d,getSnapshot:b}}),c=f[0].inst,g=f[1];p(function(){c.value=d;c.getSnapshot=b;t(c)&&g({inst:c})},[a,d,b]);n(function(){t(c)&&g({inst:c});return a(function(){t(c)&&g({inst:c})})},[a]);q(d);return d}function t(a){var b=a.getSnapshot;a=a.value;try{var d=b();return!l(a,d)}catch(f){return!0}}function u(a,b){return b()}var v=e.unstable_useSyncExternalStore;exports.useSyncExternalStore=void 0!==v?v:h?r:u;
{
"name": "use-sync-external-store",
"description": "Backwards compatible shim for React's useSyncExternalStore. Works with any React that supports hooks.",
"version": "0.0.0-experimental-3ee7a004e-20210920",
"version": "0.0.0-experimental-4298ddbc5-20211023",
"repository": {

@@ -16,2 +16,3 @@ "type": "git",

"extra.js",
"index.native.js",
"cjs/"

@@ -21,4 +22,4 @@ ],

"peerDependencies": {
"react": "0.0.0-experimental-3ee7a004e-20210920"
"react": "0.0.0-experimental-4298ddbc5-20211023"
}
}
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