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

react-refresh

Package Overview
Dependencies
Maintainers
8
Versions
1925
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-refresh - npm Package Compare versions

Comparing version 0.0.0-experimental-3f3fe0874 to 0.0.0-experimental-57333ca33

10

build-info.json
{
"branch": "pull/17418",
"buildNumber": "61614",
"checksum": "4ae6549",
"commit": "3f3fe0874",
"branch": "master",
"buildNumber": "80519",
"checksum": "fcf66d8",
"commit": "57333ca33",
"environment": "ci",
"reactVersion": "16.12.0-experimental-3f3fe0874"
"reactVersion": "16.12.0-experimental-57333ca33"
}

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

/** @license React v0.0.0-experimental-3f3fe0874
/** @license React v0.0.0-experimental-57333ca33
* react-refresh-babel.development.js

@@ -3,0 +3,0 @@ *

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

/** @license React v0.0.0-experimental-3f3fe0874
/** @license React v0.0.0-experimental-57333ca33
* react-refresh-babel.production.min.js

@@ -3,0 +3,0 @@ *

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

/** @license React v0.0.0-experimental-3f3fe0874
/** @license React v0.0.0-experimental-57333ca33
* react-refresh-runtime.development.js

@@ -54,7 +54,13 @@ *

var mountedRoots = new Set(); // If a root captures an error, we add its element to this Map so we can retry on edit.
var mountedRoots = new Set(); // If a root captures an error, we remember it so we can retry on edit.
var failedRoots = new Map();
var didSomeRootFailOnMount = false;
var failedRoots = new Set(); // In environments that support WeakMap, we also remember the last element for every root.
// It needs to be weak because we do this even for roots that failed to mount.
// If there is no WeakMap, we won't attempt to do retrying.
// $FlowIssue
var rootElements = // $FlowIssue
typeof WeakMap === 'function' ? new WeakMap() : null;
var isPerformingRefresh = false;
function computeFullKey(signature) {

@@ -152,10 +158,33 @@ if (signature.fullKey !== null) {

return updatedFamiliesByType.get(type);
} // If we didn't care about IE11, we could use new Map/Set(iterable).
function cloneMap(map) {
var clone = new Map();
map.forEach(function (value, key) {
clone.set(key, value);
});
return clone;
}
function cloneSet(set) {
var clone = new Set();
set.forEach(function (value) {
clone.add(value);
});
return clone;
}
function performReactRefresh() {
{
if (pendingUpdates.length === 0) {
return null;
}
if (pendingUpdates.length === 0) {
return null;
}
if (isPerformingRefresh) {
return null;
}
isPerformingRefresh = true;
try {
var staleFamilies = new Set();

@@ -194,6 +223,13 @@ var updatedFamilies = new Set();

var didError = false;
var firstError = null;
failedRoots.forEach(function (element, root) {
var helpers = helpersByRoot.get(root);
var firstError = null; // We snapshot maps and sets that are mutated during commits.
// If we don't do this, there is a risk they will be mutated while
// we iterate over them. For example, trying to recover a failed root
// may cause another root to be added to the failed list -- an infinite loop.
var failedRootsSnapshot = cloneSet(failedRoots);
var mountedRootsSnapshot = cloneSet(mountedRoots);
var helpersByRootSnapshot = cloneMap(helpersByRoot);
failedRootsSnapshot.forEach(function (root) {
var helpers = helpersByRootSnapshot.get(root);
if (helpers === undefined) {

@@ -203,2 +239,15 @@ throw new Error('Could not find helpers for a root. This is a bug in React Refresh.');

if (!failedRoots.has(root)) {// No longer failed.
}
if (rootElements === null) {
return;
}
if (!rootElements.has(root)) {
return;
}
var element = rootElements.get(root);
try {

@@ -214,4 +263,4 @@ helpers.scheduleRoot(root, element);

});
mountedRoots.forEach(function (root) {
var helpers = helpersByRoot.get(root);
mountedRootsSnapshot.forEach(function (root) {
var helpers = helpersByRootSnapshot.get(root);

@@ -222,2 +271,5 @@ if (helpers === undefined) {

if (!mountedRoots.has(root)) {// No longer mounted.
}
try {

@@ -239,2 +291,4 @@ helpers.scheduleRefresh(root, update);

return update;
} finally {
isPerformingRefresh = false;
}

@@ -356,2 +410,3 @@ }

globalObject.__REACT_DEVTOOLS_GLOBAL_HOOK__ = hook = {
renderers: new Map(),
supportsFiber: true,

@@ -361,2 +416,3 @@ inject: function (injected) {

},
onScheduleFiberRoot: function (id, root, children) {},
onCommitFiberRoot: function (id, root, maybePriorityLevel, didError) {},

@@ -379,7 +435,32 @@ onCommitFiberUnmount: function () {}

return id;
}; // We also want to track currently mounted roots.
}; // Do the same for any already injected roots.
// This is useful if ReactDOM has already been initialized.
// https://github.com/facebook/react/issues/17626
hook.renderers.forEach(function (injected, id) {
if (typeof injected.scheduleRefresh === 'function' && typeof injected.setRefreshHandler === 'function') {
// This version supports React Refresh.
helpersByRendererID.set(id, injected);
}
}); // We also want to track currently mounted roots.
var oldOnCommitFiberRoot = hook.onCommitFiberRoot;
var oldOnScheduleFiberRoot = hook.onScheduleFiberRoot || function () {};
hook.onScheduleFiberRoot = function (id, root, children) {
if (!isPerformingRefresh) {
// If it was intentionally scheduled, don't attempt to restore.
// This includes intentionally scheduled unmounts.
failedRoots.delete(root);
if (rootElements !== null) {
rootElements.set(root, children);
}
}
return oldOnScheduleFiberRoot.apply(this, arguments);
};
hook.onCommitFiberRoot = function (id, root, maybePriorityLevel, didError) {

@@ -414,4 +495,3 @@ var helpers = helpersByRendererID.get(id);

// We'll remount it on future edits.
// Remember what was rendered so we can restore it.
failedRoots.set(root, alternate.memoizedState.element);
failedRoots.add(root);
} else {

@@ -421,17 +501,5 @@ helpersByRoot.delete(root);

} else if (!wasMounted && !isMounted) {
if (didError && !failedRoots.has(root)) {
// The root had an error during the initial mount.
// We can't read its last element from the memoized state
// because there was no previously committed alternate.
// Ideally, it would be nice if we had a way to extract
// the last attempted rendered element, but accessing the update queue
// would tie this package too closely to the reconciler version.
// So instead, we just set a flag.
// TODO: Maybe we could fix this as the same time as when we fix
// DevTools to not depend on `alternate.memoizedState.element`.
didSomeRootFailOnMount = true;
} else if (!didError && failedRoots.has(root)) {
// The error is fixed but the component is still unmounted.
// This means that the unmount was not caused by a failed refresh.
failedRoots.delete(root);
if (didError) {
// We'll remount it on future edits.
failedRoots.add(root);
}

@@ -449,3 +517,4 @@ }

function hasUnrecoverableErrors() {
return didSomeRootFailOnMount;
// TODO: delete this after removing dependency in RN.
return false;
} // Exposed for testing.

@@ -482,14 +551,24 @@

{
var call = 0;
// We'll fill in the signature in two steps.
// First, we'll know the signature itself. This happens outside the component.
// Then, we'll know the references to custom Hooks. This happens inside the component.
// After that, the returned function will be a fast path no-op.
var status = 'needsSignature';
var savedType;
var hasCustomHooks;
return function (type, key, forceReset, getCustomHooks) {
switch (call++) {
case 0:
savedType = type;
hasCustomHooks = typeof getCustomHooks === 'function';
setSignature(type, key, forceReset, getCustomHooks);
switch (status) {
case 'needsSignature':
if (type !== undefined) {
// If we received an argument, this is the initial registration call.
savedType = type;
hasCustomHooks = typeof getCustomHooks === 'function';
setSignature(type, key, forceReset, getCustomHooks); // The next call we expect is from inside a function, to fill in the custom Hooks.
status = 'needsCustomHooks';
}
break;
case 1:
case 'needsCustomHooks':
if (hasCustomHooks) {

@@ -499,3 +578,8 @@ collectCustomHooksForSignature(savedType);

status = 'resolved';
break;
case 'resolved':
// Do nothing. Fast path for all future renders.
break;
}

@@ -502,0 +586,0 @@

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

/** @license React v0.0.0-experimental-3f3fe0874
/** @license React v0.0.0-experimental-57333ca33
* react-refresh-runtime.production.min.js

@@ -3,0 +3,0 @@ *

@@ -7,3 +7,3 @@ {

],
"version": "0.0.0-experimental-3f3fe0874",
"version": "0.0.0-experimental-57333ca33",
"homepage": "https://reactjs.org/",

@@ -10,0 +10,0 @@ "bugs": "https://github.com/facebook/react/issues",

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