use-sync-external-store
Advanced tools
Comparing version 0.0.0-experimental-934177598-20221022 to 0.0.0-experimental-935180c7e0-20240524
@@ -15,6 +15,3 @@ /** | ||
(function() { | ||
'use strict'; | ||
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */ | ||
'use strict'; | ||
if ( | ||
@@ -27,5 +24,5 @@ typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' && | ||
} | ||
var React = require('react'); | ||
var React = require('react'); | ||
var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; | ||
var ReactSharedInternals = React.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE; | ||
@@ -48,20 +45,32 @@ function error(format) { | ||
{ | ||
var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; | ||
var stack = ReactDebugCurrentFrame.getStackAddendum(); | ||
var isErrorLogger = format === '%s\n\n%s\n' || format === '%o\n\n%s\n\n%s\n'; | ||
if (stack !== '') { | ||
format += '%s'; | ||
args = args.concat([stack]); | ||
} // eslint-disable-next-line react-internal/safe-string-coercion | ||
if (ReactSharedInternals.getCurrentStack) { | ||
var stack = ReactSharedInternals.getCurrentStack(); | ||
if (stack !== '') { | ||
format += '%s'; | ||
args = args.concat([stack]); | ||
} | ||
} | ||
var argsWithFormat = args.map(function (item) { | ||
return String(item); | ||
}); // Careful: RN currently depends on this prefix | ||
argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it | ||
if (isErrorLogger) { | ||
// Don't prefix our default logging formatting in ReactFiberErrorLoggger. | ||
// Don't toString the arguments. | ||
args.unshift(format); | ||
} else { | ||
// TODO: Remove this prefix and stop toStringing in the wrapper and | ||
// instead do it at each callsite as needed. | ||
// Careful: RN currently depends on this prefix | ||
// eslint-disable-next-line react-internal/safe-string-coercion | ||
args = args.map(function (item) { | ||
return String(item); | ||
}); | ||
args.unshift('Warning: ' + format); | ||
} // We intentionally don't use spread (or .apply) directly because it | ||
// breaks IE9: https://github.com/facebook/react/issues/13610 | ||
// eslint-disable-next-line react-internal/no-production-logging | ||
Function.prototype.apply.call(console[level], console, argsWithFormat); | ||
Function.prototype.apply.call(console[level], console, args); | ||
} | ||
@@ -100,3 +109,3 @@ } | ||
function useSyncExternalStore(subscribe, getSnapshot, // Note: The shim does not use getServerSnapshot, because pre-18 versions of | ||
function useSyncExternalStore$2(subscribe, getSnapshot, // Note: The shim does not use getServerSnapshot, because pre-18 versions of | ||
// React do not expose a way to check if we're hydrating. So users of the shim | ||
@@ -230,7 +239,6 @@ // will need to track that themselves and return the correct value | ||
var shim = isServerEnvironment ? useSyncExternalStore$1 : useSyncExternalStore; | ||
var useSyncExternalStore$2 = React.useSyncExternalStore !== undefined ? React.useSyncExternalStore : shim; | ||
var shim = isServerEnvironment ? useSyncExternalStore$1 : useSyncExternalStore$2; | ||
var useSyncExternalStore = React.useSyncExternalStore !== undefined ? React.useSyncExternalStore : shim; | ||
exports.useSyncExternalStore = useSyncExternalStore$2; | ||
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */ | ||
exports.useSyncExternalStore = useSyncExternalStore; | ||
if ( | ||
@@ -243,4 +251,4 @@ typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' && | ||
} | ||
})(); | ||
} |
@@ -15,6 +15,3 @@ /** | ||
(function() { | ||
'use strict'; | ||
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */ | ||
'use strict'; | ||
if ( | ||
@@ -27,5 +24,5 @@ typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' && | ||
} | ||
var React = require('react'); | ||
var React = require('react'); | ||
var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; | ||
var ReactSharedInternals = React.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE; | ||
@@ -48,20 +45,32 @@ function error(format) { | ||
{ | ||
var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; | ||
var stack = ReactDebugCurrentFrame.getStackAddendum(); | ||
var isErrorLogger = format === '%s\n\n%s\n' || format === '%o\n\n%s\n\n%s\n'; | ||
if (stack !== '') { | ||
format += '%s'; | ||
args = args.concat([stack]); | ||
} // eslint-disable-next-line react-internal/safe-string-coercion | ||
if (ReactSharedInternals.getCurrentStack) { | ||
var stack = ReactSharedInternals.getCurrentStack(); | ||
if (stack !== '') { | ||
format += '%s'; | ||
args = args.concat([stack]); | ||
} | ||
} | ||
var argsWithFormat = args.map(function (item) { | ||
return String(item); | ||
}); // Careful: RN currently depends on this prefix | ||
argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it | ||
if (isErrorLogger) { | ||
// Don't prefix our default logging formatting in ReactFiberErrorLoggger. | ||
// Don't toString the arguments. | ||
args.unshift(format); | ||
} else { | ||
// TODO: Remove this prefix and stop toStringing in the wrapper and | ||
// instead do it at each callsite as needed. | ||
// Careful: RN currently depends on this prefix | ||
// eslint-disable-next-line react-internal/safe-string-coercion | ||
args = args.map(function (item) { | ||
return String(item); | ||
}); | ||
args.unshift('Warning: ' + format); | ||
} // We intentionally don't use spread (or .apply) directly because it | ||
// breaks IE9: https://github.com/facebook/react/issues/13610 | ||
// eslint-disable-next-line react-internal/no-production-logging | ||
Function.prototype.apply.call(console[level], console, argsWithFormat); | ||
Function.prototype.apply.call(console[level], console, args); | ||
} | ||
@@ -100,3 +109,3 @@ } | ||
function useSyncExternalStore(subscribe, getSnapshot, // Note: The shim does not use getServerSnapshot, because pre-18 versions of | ||
function useSyncExternalStore$1(subscribe, getSnapshot, // Note: The shim does not use getServerSnapshot, because pre-18 versions of | ||
// React do not expose a way to check if we're hydrating. So users of the shim | ||
@@ -218,7 +227,6 @@ // will need to track that themselves and return the correct value | ||
var shim = useSyncExternalStore; | ||
var useSyncExternalStore$1 = React.useSyncExternalStore !== undefined ? React.useSyncExternalStore : shim; | ||
var shim = useSyncExternalStore$1; | ||
var useSyncExternalStore = React.useSyncExternalStore !== undefined ? React.useSyncExternalStore : shim; | ||
exports.useSyncExternalStore = useSyncExternalStore$1; | ||
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */ | ||
exports.useSyncExternalStore = useSyncExternalStore; | ||
if ( | ||
@@ -231,4 +239,4 @@ typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' && | ||
} | ||
})(); | ||
} |
@@ -15,6 +15,3 @@ /** | ||
(function() { | ||
'use strict'; | ||
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */ | ||
'use strict'; | ||
if ( | ||
@@ -27,3 +24,3 @@ typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' && | ||
} | ||
var React = require('react'); | ||
var React = require('react'); | ||
var shim = require('use-sync-external-store/shim'); | ||
@@ -150,3 +147,5 @@ | ||
useEffect(function () { | ||
inst.hasValue = true; | ||
// $FlowFixMe[incompatible-type] changing the variant using mutation isn't supported | ||
inst.hasValue = true; // $FlowFixMe[incompatible-type] | ||
inst.value = value; | ||
@@ -159,3 +158,2 @@ }, [value]); | ||
exports.useSyncExternalStoreWithSelector = useSyncExternalStoreWithSelector; | ||
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */ | ||
if ( | ||
@@ -168,4 +166,4 @@ typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' && | ||
} | ||
})(); | ||
} |
@@ -15,6 +15,3 @@ /** | ||
(function() { | ||
'use strict'; | ||
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */ | ||
'use strict'; | ||
if ( | ||
@@ -27,3 +24,3 @@ typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' && | ||
} | ||
var React = require('react'); | ||
var React = require('react'); | ||
@@ -149,3 +146,5 @@ /** | ||
useEffect(function () { | ||
inst.hasValue = true; | ||
// $FlowFixMe[incompatible-type] changing the variant using mutation isn't supported | ||
inst.hasValue = true; // $FlowFixMe[incompatible-type] | ||
inst.value = value; | ||
@@ -158,3 +157,2 @@ }, [value]); | ||
exports.useSyncExternalStoreWithSelector = useSyncExternalStoreWithSelector; | ||
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */ | ||
if ( | ||
@@ -167,4 +165,4 @@ typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' && | ||
} | ||
})(); | ||
} |
@@ -15,6 +15,3 @@ /** | ||
(function() { | ||
'use strict'; | ||
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */ | ||
'use strict'; | ||
if ( | ||
@@ -27,5 +24,5 @@ typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' && | ||
} | ||
var React = require('react'); | ||
var React = require('react'); | ||
var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; | ||
var ReactSharedInternals = React.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE; | ||
@@ -48,20 +45,32 @@ function error(format) { | ||
{ | ||
var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; | ||
var stack = ReactDebugCurrentFrame.getStackAddendum(); | ||
var isErrorLogger = format === '%s\n\n%s\n' || format === '%o\n\n%s\n\n%s\n'; | ||
if (stack !== '') { | ||
format += '%s'; | ||
args = args.concat([stack]); | ||
} // eslint-disable-next-line react-internal/safe-string-coercion | ||
if (ReactSharedInternals.getCurrentStack) { | ||
var stack = ReactSharedInternals.getCurrentStack(); | ||
if (stack !== '') { | ||
format += '%s'; | ||
args = args.concat([stack]); | ||
} | ||
} | ||
var argsWithFormat = args.map(function (item) { | ||
return String(item); | ||
}); // Careful: RN currently depends on this prefix | ||
argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it | ||
if (isErrorLogger) { | ||
// Don't prefix our default logging formatting in ReactFiberErrorLoggger. | ||
// Don't toString the arguments. | ||
args.unshift(format); | ||
} else { | ||
// TODO: Remove this prefix and stop toStringing in the wrapper and | ||
// instead do it at each callsite as needed. | ||
// Careful: RN currently depends on this prefix | ||
// eslint-disable-next-line react-internal/safe-string-coercion | ||
args = args.map(function (item) { | ||
return String(item); | ||
}); | ||
args.unshift('Warning: ' + format); | ||
} // We intentionally don't use spread (or .apply) directly because it | ||
// breaks IE9: https://github.com/facebook/react/issues/13610 | ||
// eslint-disable-next-line react-internal/no-production-logging | ||
Function.prototype.apply.call(console[level], console, argsWithFormat); | ||
Function.prototype.apply.call(console[level], console, args); | ||
} | ||
@@ -77,3 +86,2 @@ } | ||
exports.useSyncExternalStore = useSyncExternalStore; | ||
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */ | ||
if ( | ||
@@ -86,4 +94,4 @@ typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' && | ||
} | ||
})(); | ||
} |
'use strict'; | ||
if (process.env.NODE_ENV === 'production') { | ||
module.exports = require('./cjs/use-sync-external-store.production.min.js'); | ||
module.exports = require('./cjs/use-sync-external-store.production.js'); | ||
} else { | ||
module.exports = require('./cjs/use-sync-external-store.development.js'); | ||
} |
{ | ||
"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-934177598-20221022", | ||
"version": "0.0.0-experimental-935180c7e0-20240524", | ||
"repository": { | ||
@@ -22,4 +22,8 @@ "type": "git", | ||
"peerDependencies": { | ||
"react": "0.0.0-experimental-934177598-20221022" | ||
"react": "0.0.0-experimental-935180c7e0-20240524" | ||
}, | ||
"devDependencies": { | ||
"react-17": "npm:react@^17", | ||
"react-dom-17": "npm:react-dom@^17" | ||
} | ||
} |
'use strict'; | ||
if (process.env.NODE_ENV === 'production') { | ||
module.exports = require('../cjs/use-sync-external-store-shim.production.min.js'); | ||
module.exports = require('../cjs/use-sync-external-store-shim.production.js'); | ||
} else { | ||
module.exports = require('../cjs/use-sync-external-store-shim.development.js'); | ||
} |
'use strict'; | ||
if (process.env.NODE_ENV === 'production') { | ||
module.exports = require('../cjs/use-sync-external-store-shim.native.production.min.js'); | ||
module.exports = require('../cjs/use-sync-external-store-shim.native.production.js'); | ||
} else { | ||
module.exports = require('../cjs/use-sync-external-store-shim.native.development.js'); | ||
} |
'use strict'; | ||
if (process.env.NODE_ENV === 'production') { | ||
module.exports = require('../cjs/use-sync-external-store-shim/with-selector.production.min.js'); | ||
module.exports = require('../cjs/use-sync-external-store-shim/with-selector.production.js'); | ||
} else { | ||
module.exports = require('../cjs/use-sync-external-store-shim/with-selector.development.js'); | ||
} |
'use strict'; | ||
if (process.env.NODE_ENV === 'production') { | ||
module.exports = require('./cjs/use-sync-external-store-with-selector.production.min.js'); | ||
module.exports = require('./cjs/use-sync-external-store-with-selector.production.js'); | ||
} else { | ||
module.exports = require('./cjs/use-sync-external-store-with-selector.development.js'); | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 3 instances in 1 package
43913
1088
2
0
2