Socket
Socket
Sign inDemoInstall

react-refresh

Package Overview
Dependencies
Maintainers
7
Versions
1787
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.4 to 0.0.5

12

cjs/react-refresh-babel.development.js

@@ -19,2 +19,10 @@ /** @license React vundefined

var ReactFreshBabelPlugin = function (babel) {
if (typeof babel.getEnv === 'function') {
// Only available in Babel 7.
var env = babel.getEnv();
if (env !== 'development') {
throw new Error('React Refresh Babel transform should only be enabled in development environment. ' + 'Instead, the environment is: "' + env + '".');
}
}
var t = babel.types;

@@ -220,3 +228,3 @@

// We let user do /* @hot reset */ to reset state in the whole file.
// We let user do /* @refresh reset */ to reset state in the whole file.
function hasForceResetComment(path) {

@@ -233,3 +241,3 @@ var file = path.hub.file;

var cmt = comments[i];
if (cmt.value.indexOf('@hot reset') !== -1) {
if (cmt.value.indexOf('@refresh reset') !== -1) {
hasForceReset = true;

@@ -236,0 +244,0 @@ break;

24

cjs/react-refresh-babel.production.min.js

@@ -10,13 +10,13 @@ /** @license React vundefined

'use strict';function u(A){function q(a,b){var d=a.scope.generateUidIdentifier("c");l.has(a)||l.set(a,[]);l.get(a).push({handle:d,persistentID:b});return d}function r(a){return"string"===typeof a&&"A"<=a[0]&&"Z">=a[0]}function m(a,b,d){var c=b.node;switch(c.type){case "Identifier":if(!r(c.name))break;d(a,c,null);return!0;case "FunctionDeclaration":return d(a,c.id,null),!0;case "ArrowFunctionExpression":if("ArrowFunctionExpression"===c.body.type)break;d(a,c,b);return!0;case "FunctionExpression":return d(a,
c,b),!0;case "CallExpression":var e=b.get("arguments");if(void 0===e||0===e.length)break;var g=b.get("callee");switch(g.node.type){case "MemberExpression":case "Identifier":g=g.getSource();if(!m(a+"$"+g,e[0],d))return!1;d(a,c,b);return!0;default:return!1}case "VariableDeclarator":if(e=c.init,null!==e&&(g=c.id.name,r(g)&&"Identifier"!==e.type&&"MemberExpression"!==e.type)){c=b.get("init");if(m(a,c,d))return!0;g=b.scope.getBinding(g);if(void 0===g)return;b=!1;g=g.referencePaths;for(var f=0;f<g.length;f++){var h=
g[f];if("JSXIdentifier"===h.node.type||"Identifier"===h.node.type){h=h.parent;if("JSXOpeningElement"===h.type)b=!0;else if("CallExpression"===h.type){h=h.callee;var k=void 0;switch(h.type){case "Identifier":k=h.name;break;case "MemberExpression":k=h.property.name}switch(k){case "createElement":case "jsx":case "jsxDEV":case "jsxs":b=!0}}if(b)return d(a,e,c),!0}}}}return!1}function v(a){a=n.get(a);return void 0===a?null:{key:a.map(function(a){return a.name+"{"+a.key+"}"}).join("\n"),customHooks:a.filter(function(a){a:switch(a.name){case "useState":case "React.useState":case "useReducer":case "React.useReducer":case "useEffect":case "React.useEffect":case "useLayoutEffect":case "React.useLayoutEffect":case "useMemo":case "React.useMemo":case "useCallback":case "React.useCallback":case "useRef":case "React.useRef":case "useContext":case "React.useContext":case "useImperativeMethods":case "React.useImperativeMethods":case "useDebugValue":case "React.useDebugValue":a=
!0;break a;default:a=!1}return!a}).map(function(a){return a.callee})}}function B(a){a=a.hub.file;var b=w.get(a);if(void 0!==b)return b;b=!1;for(var d=a.ast.comments,c=0;c<d.length;c++)if(-1!==d[c].value.indexOf("@hot reset")){b=!0;break}w.set(a,b);return b}function t(a,b,d){var c=b.key;b=b.customHooks;var e=B(d.path),g=[];b.forEach(function(a){var b=void 0;switch(a.type){case "MemberExpression":"Identifier"===a.object.type&&(b=a.object.name);break;case "Identifier":b=a.name}d.hasBinding(b)?g.push(a):
e=!0});a=[a,f.stringLiteral(c)];(e||0<g.length)&&a.push(f.booleanLiteral(e));0<g.length&&a.push(f.arrowFunctionExpression([],f.arrayExpression(g)));return a}var f=A.types,l=new Map,w=new WeakMap,k=new WeakSet,p=new WeakSet,x=new WeakSet,n=new WeakMap,C={CallExpression:function(a){var b=a.node.callee,d=null;switch(b.type){case "Identifier":d=b.name;break;case "MemberExpression":d=b.property.name}if(null!==d&&/^use[A-Z]/.test(d)&&(b=a.scope.getFunctionParent(),null!==b)){b=b.block;n.has(b)||n.set(b,
[]);b=n.get(b);var c="";"VariableDeclarator"===a.parent.type&&(c=a.parentPath.get("id").getSource());var e=a.get("arguments");"useState"===d&&0<e.length?c+="("+e[0].getSource()+")":"useReducer"===d&&1<e.length&&(c+="("+e[1].getSource()+")");b.push({callee:a.node.callee,name:d,key:c})}}};return{visitor:{ExportDefaultDeclaration:function(a){var b=a.node,d=b.declaration,c=a.get("declaration");if("CallExpression"===d.type&&!k.has(b)){k.add(b);var e=a.parentPath;m("%default%",c,function(a,b,c){null!==
c&&(a=q(e,a),c.replaceWith(f.assignmentExpression("=",a,b)))})}},FunctionDeclaration:{enter:function(a){var b=a.node,d=void 0,c=void 0;switch(a.parent.type){case "Program":c=a;d=a.parentPath;break;case "ExportNamedDeclaration":c=a.parentPath;d=c.parentPath;break;case "ExportDefaultDeclaration":c=a.parentPath;d=c.parentPath;break;default:return}var e=b.id;null!==e&&(e=e.name,r(e)&&!k.has(b)&&(k.add(b),m(e,a,function(a,b){a=q(d,a);c.insertAfter(f.expressionStatement(f.assignmentExpression("=",a,b)))})))},
exit:function(a){var b=a.node,d=b.id;if(null!==d){var c=v(b);if(null!==c&&!p.has(b)){p.add(b);b=a.scope.generateUidIdentifier("_s");a.scope.parent.push({id:b,init:f.callExpression(f.identifier("__signature__"),[])});a.get("body").unshiftContainer("body",f.expressionStatement(f.callExpression(b,[])));var e=null;a.find(function(a){if(a.parentPath.isBlock())return e=a,!0});null!==e&&e.insertAfter(f.expressionStatement(f.callExpression(b,t(d,c,e.scope))))}}}},"ArrowFunctionExpression|FunctionExpression":{exit:function(a){var b=
a.node,d=v(b);if(null!==d&&!p.has(b)){p.add(b);var c=a.scope.generateUidIdentifier("_s");a.scope.parent.push({id:c,init:f.callExpression(f.identifier("__signature__"),[])});a.get("body").unshiftContainer("body",f.expressionStatement(f.callExpression(c,[])));if("VariableDeclarator"===a.parent.type){var e=null;a.find(function(a){if(a.parentPath.isBlock())return e=a,!0});null!==e&&e.insertAfter(f.expressionStatement(f.callExpression(c,t(a.parent.id,d,e.scope))))}else a.replaceWith(f.callExpression(c,
t(b,d,a.scope)))}}},VariableDeclaration:function(a){var b=a.node,d=void 0,c=void 0;switch(a.parent.type){case "Program":c=a;d=a.parentPath;break;case "ExportNamedDeclaration":c=a.parentPath;d=c.parentPath;break;case "ExportDefaultDeclaration":c=a.parentPath;d=c.parentPath;break;default:return}if(!k.has(b)&&(k.add(b),a=a.get("declarations"),1===a.length)){var e=a[0];m(e.node.id.name,e,function(a,b,h){null!==h&&(a=q(d,a),"ArrowFunctionExpression"!==b.type&&"FunctionExpression"!==b.type||"VariableDeclarator"!==
h.parent.type?h.replaceWith(f.assignmentExpression("=",a,b)):c.insertAfter(f.expressionStatement(f.assignmentExpression("=",a,e.node.id))))})}},Program:{enter:function(a){a.traverse(C)},exit:function(a){var b=l.get(a);if(void 0!==b){var d=a.node;if(!x.has(d)){x.add(d);l.delete(a);var c=[];a.pushContainer("body",f.variableDeclaration("var",c));b.forEach(function(b){var d=b.handle;b=b.persistentID;a.pushContainer("body",f.expressionStatement(f.callExpression(f.identifier("__register__"),[d,f.stringLiteral(b)])));
c.push(f.variableDeclarator(d))})}}}}}}}var y={default:u},z=y&&u||y;module.exports=z.default||z;
'use strict';function v(q){function r(a,b){var d=a.scope.generateUidIdentifier("c");l.has(a)||l.set(a,[]);l.get(a).push({handle:d,persistentID:b});return d}function t(a){return"string"===typeof a&&"A"<=a[0]&&"Z">=a[0]}function m(a,b,d){var c=b.node;switch(c.type){case "Identifier":if(!t(c.name))break;d(a,c,null);return!0;case "FunctionDeclaration":return d(a,c.id,null),!0;case "ArrowFunctionExpression":if("ArrowFunctionExpression"===c.body.type)break;d(a,c,b);return!0;case "FunctionExpression":return d(a,
c,b),!0;case "CallExpression":var e=b.get("arguments");if(void 0===e||0===e.length)break;var g=b.get("callee");switch(g.node.type){case "MemberExpression":case "Identifier":g=g.getSource();if(!m(a+"$"+g,e[0],d))return!1;d(a,c,b);return!0;default:return!1}case "VariableDeclarator":if(e=c.init,null!==e&&(g=c.id.name,t(g)&&"Identifier"!==e.type&&"MemberExpression"!==e.type)){c=b.get("init");if(m(a,c,d))return!0;g=b.scope.getBinding(g);if(void 0===g)return;b=!1;g=g.referencePaths;for(var f=0;f<g.length;f++){var h=
g[f];if("JSXIdentifier"===h.node.type||"Identifier"===h.node.type){h=h.parent;if("JSXOpeningElement"===h.type)b=!0;else if("CallExpression"===h.type){h=h.callee;var k=void 0;switch(h.type){case "Identifier":k=h.name;break;case "MemberExpression":k=h.property.name}switch(k){case "createElement":case "jsx":case "jsxDEV":case "jsxs":b=!0}}if(b)return d(a,e,c),!0}}}}return!1}function w(a){a=n.get(a);return void 0===a?null:{key:a.map(function(a){return a.name+"{"+a.key+"}"}).join("\n"),customHooks:a.filter(function(a){a:switch(a.name){case "useState":case "React.useState":case "useReducer":case "React.useReducer":case "useEffect":case "React.useEffect":case "useLayoutEffect":case "React.useLayoutEffect":case "useMemo":case "React.useMemo":case "useCallback":case "React.useCallback":case "useRef":case "React.useRef":case "useContext":case "React.useContext":case "useImperativeMethods":case "React.useImperativeMethods":case "useDebugValue":case "React.useDebugValue":a=
!0;break a;default:a=!1}return!a}).map(function(a){return a.callee})}}function C(a){a=a.hub.file;var b=x.get(a);if(void 0!==b)return b;b=!1;for(var d=a.ast.comments,c=0;c<d.length;c++)if(-1!==d[c].value.indexOf("@refresh reset")){b=!0;break}x.set(a,b);return b}function u(a,b,d){var c=b.key;b=b.customHooks;var e=C(d.path),g=[];b.forEach(function(a){var b=void 0;switch(a.type){case "MemberExpression":"Identifier"===a.object.type&&(b=a.object.name);break;case "Identifier":b=a.name}d.hasBinding(b)?g.push(a):
e=!0});a=[a,f.stringLiteral(c)];(e||0<g.length)&&a.push(f.booleanLiteral(e));0<g.length&&a.push(f.arrowFunctionExpression([],f.arrayExpression(g)));return a}if("function"===typeof q.getEnv){var y=q.getEnv();if("development"!==y)throw Error('React Refresh Babel transform should only be enabled in development environment. Instead, the environment is: "'+y+'".');}var f=q.types,l=new Map,x=new WeakMap,k=new WeakSet,p=new WeakSet,z=new WeakSet,n=new WeakMap,D={CallExpression:function(a){var b=a.node.callee,
d=null;switch(b.type){case "Identifier":d=b.name;break;case "MemberExpression":d=b.property.name}if(null!==d&&/^use[A-Z]/.test(d)&&(b=a.scope.getFunctionParent(),null!==b)){b=b.block;n.has(b)||n.set(b,[]);b=n.get(b);var c="";"VariableDeclarator"===a.parent.type&&(c=a.parentPath.get("id").getSource());var e=a.get("arguments");"useState"===d&&0<e.length?c+="("+e[0].getSource()+")":"useReducer"===d&&1<e.length&&(c+="("+e[1].getSource()+")");b.push({callee:a.node.callee,name:d,key:c})}}};return{visitor:{ExportDefaultDeclaration:function(a){var b=
a.node,d=b.declaration,c=a.get("declaration");if("CallExpression"===d.type&&!k.has(b)){k.add(b);var e=a.parentPath;m("%default%",c,function(a,b,c){null!==c&&(a=r(e,a),c.replaceWith(f.assignmentExpression("=",a,b)))})}},FunctionDeclaration:{enter:function(a){var b=a.node,d=void 0,c=void 0;switch(a.parent.type){case "Program":c=a;d=a.parentPath;break;case "ExportNamedDeclaration":c=a.parentPath;d=c.parentPath;break;case "ExportDefaultDeclaration":c=a.parentPath;d=c.parentPath;break;default:return}var e=
b.id;null!==e&&(e=e.name,t(e)&&!k.has(b)&&(k.add(b),m(e,a,function(a,b){a=r(d,a);c.insertAfter(f.expressionStatement(f.assignmentExpression("=",a,b)))})))},exit:function(a){var b=a.node,d=b.id;if(null!==d){var c=w(b);if(null!==c&&!p.has(b)){p.add(b);b=a.scope.generateUidIdentifier("_s");a.scope.parent.push({id:b,init:f.callExpression(f.identifier("__signature__"),[])});a.get("body").unshiftContainer("body",f.expressionStatement(f.callExpression(b,[])));var e=null;a.find(function(a){if(a.parentPath.isBlock())return e=
a,!0});null!==e&&e.insertAfter(f.expressionStatement(f.callExpression(b,u(d,c,e.scope))))}}}},"ArrowFunctionExpression|FunctionExpression":{exit:function(a){var b=a.node,d=w(b);if(null!==d&&!p.has(b)){p.add(b);var c=a.scope.generateUidIdentifier("_s");a.scope.parent.push({id:c,init:f.callExpression(f.identifier("__signature__"),[])});a.get("body").unshiftContainer("body",f.expressionStatement(f.callExpression(c,[])));if("VariableDeclarator"===a.parent.type){var e=null;a.find(function(a){if(a.parentPath.isBlock())return e=
a,!0});null!==e&&e.insertAfter(f.expressionStatement(f.callExpression(c,u(a.parent.id,d,e.scope))))}else a.replaceWith(f.callExpression(c,u(b,d,a.scope)))}}},VariableDeclaration:function(a){var b=a.node,d=void 0,c=void 0;switch(a.parent.type){case "Program":c=a;d=a.parentPath;break;case "ExportNamedDeclaration":c=a.parentPath;d=c.parentPath;break;case "ExportDefaultDeclaration":c=a.parentPath;d=c.parentPath;break;default:return}if(!k.has(b)&&(k.add(b),a=a.get("declarations"),1===a.length)){var e=
a[0];m(e.node.id.name,e,function(a,b,h){null!==h&&(a=r(d,a),"ArrowFunctionExpression"!==b.type&&"FunctionExpression"!==b.type||"VariableDeclarator"!==h.parent.type?h.replaceWith(f.assignmentExpression("=",a,b)):c.insertAfter(f.expressionStatement(f.assignmentExpression("=",a,e.node.id))))})}},Program:{enter:function(a){a.traverse(D)},exit:function(a){var b=l.get(a);if(void 0!==b){var d=a.node;if(!z.has(d)){z.add(d);l.delete(a);var c=[];a.pushContainer("body",f.variableDeclaration("var",c));b.forEach(function(b){var d=
b.handle;b=b.persistentID;a.pushContainer("body",f.expressionStatement(f.callExpression(f.identifier("__register__"),[d,f.stringLiteral(b)])));c.push(f.variableDeclarator(d))})}}}}}}}var A={default:v},B=A&&v||A;module.exports=B.default||B;

@@ -35,2 +35,3 @@ /** @license React vundefined

var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;

@@ -201,105 +202,109 @@

function performReactRefresh() {
if (pendingUpdates.length === 0) {
return false;
}
{
if (pendingUpdates.length === 0) {
return false;
}
var staleFamilies = new Set();
var updatedFamilies = new Set();
var staleFamilies = new Set();
var updatedFamilies = new Set();
var updates = pendingUpdates;
pendingUpdates = [];
updates.forEach(function (_ref) {
var family = _ref[0],
nextType = _ref[1];
var updates = pendingUpdates;
pendingUpdates = [];
updates.forEach(function (_ref) {
var family = _ref[0],
nextType = _ref[1];
// Now that we got a real edit, we can create associations
// that will be read by the React reconciler.
var prevType = family.current;
familiesByType.set(prevType, family);
familiesByType.set(nextType, family);
family.current = nextType;
// Now that we got a real edit, we can create associations
// that will be read by the React reconciler.
var prevType = family.current;
familiesByType.set(prevType, family);
familiesByType.set(nextType, family);
family.current = nextType;
// Determine whether this should be a re-render or a re-mount.
if (canPreserveStateBetween(prevType, nextType)) {
updatedFamilies.add(family);
} else {
staleFamilies.add(family);
}
});
// Determine whether this should be a re-render or a re-mount.
if (canPreserveStateBetween(prevType, nextType)) {
updatedFamilies.add(family);
} else {
staleFamilies.add(family);
}
});
var update = {
updatedFamilies: updatedFamilies,
staleFamilies: staleFamilies
};
var update = {
updatedFamilies: updatedFamilies,
staleFamilies: staleFamilies
};
if (typeof setRefreshHandler !== 'function') {
warningWithoutStack$1(false, 'Could not find the setRefreshHandler() implementation. ' + 'This likely means that injectIntoGlobalHook() was either ' + 'called before the global DevTools hook was set up, or after the ' + 'renderer has already initialized. Please file an issue with a reproducing case.');
return false;
}
if (typeof setRefreshHandler !== 'function') {
warningWithoutStack$1(false, 'Could not find the setRefreshHandler() implementation. ' + 'This likely means that injectIntoGlobalHook() was either ' + 'called before the global DevTools hook was set up, or after the ' + 'renderer has already initialized. Please file an issue with a reproducing case.');
return false;
}
if (typeof scheduleRefresh !== 'function') {
warningWithoutStack$1(false, 'Could not find the scheduleRefresh() implementation. ' + 'This likely means that injectIntoGlobalHook() was either ' + 'called before the global DevTools hook was set up, or after the ' + 'renderer has already initialized. Please file an issue with a reproducing case.');
return false;
}
var scheduleRefreshForRoot = scheduleRefresh;
if (typeof scheduleRefresh !== 'function') {
warningWithoutStack$1(false, 'Could not find the scheduleRefresh() implementation. ' + 'This likely means that injectIntoGlobalHook() was either ' + 'called before the global DevTools hook was set up, or after the ' + 'renderer has already initialized. Please file an issue with a reproducing case.');
return false;
}
var scheduleRefreshForRoot = scheduleRefresh;
// Even if there are no roots, set the handler on first update.
// This ensures that if *new* roots are mounted, they'll use the resolve handler.
setRefreshHandler(resolveFamily);
// Even if there are no roots, set the handler on first update.
// This ensures that if *new* roots are mounted, they'll use the resolve handler.
setRefreshHandler(resolveFamily);
var didError = false;
var firstError = null;
mountedRoots.forEach(function (root) {
try {
scheduleRefreshForRoot(root, update);
} catch (err) {
if (!didError) {
didError = true;
firstError = err;
var didError = false;
var firstError = null;
mountedRoots.forEach(function (root) {
try {
scheduleRefreshForRoot(root, update);
} catch (err) {
if (!didError) {
didError = true;
firstError = err;
}
// Keep trying other roots.
}
// Keep trying other roots.
});
if (didError) {
throw firstError;
}
});
if (didError) {
throw firstError;
return true;
}
return true;
}
function register(type, id) {
if (type === null) {
return;
}
if (typeof type !== 'function' && typeof type !== 'object') {
return;
}
{
if (type === null) {
return;
}
if (typeof type !== 'function' && typeof type !== 'object') {
return;
}
// This can happen in an edge case, e.g. if we register
// return value of a HOC but it returns a cached component.
// Ignore anything but the first registration for each type.
if (allTypes.has(type)) {
return;
}
allTypes.add(type);
// This can happen in an edge case, e.g. if we register
// return value of a HOC but it returns a cached component.
// Ignore anything but the first registration for each type.
if (allTypes.has(type)) {
return;
}
allTypes.add(type);
// Create family or remember to update it.
// None of this bookkeeping affects reconciliation
// until the first prepareUpdate() call above.
var family = allFamiliesByID.get(id);
if (family === undefined) {
family = { current: type };
allFamiliesByID.set(id, family);
} else {
pendingUpdates.push([family, type]);
}
// Create family or remember to update it.
// None of this bookkeeping affects reconciliation
// until the first prepareUpdate() call above.
var family = allFamiliesByID.get(id);
if (family === undefined) {
family = { current: type };
allFamiliesByID.set(id, family);
} else {
pendingUpdates.push([family, type]);
}
// Visit inner types because we might not have registered them.
if (typeof type === 'object' && type !== null) {
switch (type.$$typeof) {
case REACT_FORWARD_REF_TYPE:
register(type.render, id + '$render');
break;
case REACT_MEMO_TYPE:
register(type.type, id + '$type');
break;
// Visit inner types because we might not have registered them.
if (typeof type === 'object' && type !== null) {
switch (type.$$typeof) {
case REACT_FORWARD_REF_TYPE:
register(type.render, id + '$render');
break;
case REACT_MEMO_TYPE:
register(type.type, id + '$type');
break;
}
}

@@ -313,10 +318,12 @@ }

allSignaturesByType.set(type, {
forceReset: forceReset,
ownKey: key,
fullKey: null,
getCustomHooks: getCustomHooks || function () {
return [];
}
});
{
allSignaturesByType.set(type, {
forceReset: forceReset,
ownKey: key,
fullKey: null,
getCustomHooks: getCustomHooks || function () {
return [];
}
});
}
}

@@ -327,5 +334,7 @@

function collectCustomHooksForSignature(type) {
var signature = allSignaturesByType.get(type);
if (signature !== undefined) {
computeFullKey(signature);
{
var signature = allSignaturesByType.get(type);
if (signature !== undefined) {
computeFullKey(signature);
}
}

@@ -335,80 +344,86 @@ }

function getFamilyByID(id) {
return allFamiliesByID.get(id);
{
return allFamiliesByID.get(id);
}
}
function findAffectedHostInstances(families) {
if (typeof findHostInstancesForRefresh !== 'function') {
warningWithoutStack$1(false, 'Could not find the findHostInstancesForRefresh() implementation. ' + 'This likely means that injectIntoGlobalHook() was either ' + 'called before the global DevTools hook was set up, or after the ' + 'renderer has already initialized. Please file an issue with a reproducing case.');
return new Set();
{
if (typeof findHostInstancesForRefresh !== 'function') {
warningWithoutStack$1(false, 'Could not find the findHostInstancesForRefresh() implementation. ' + 'This likely means that injectIntoGlobalHook() was either ' + 'called before the global DevTools hook was set up, or after the ' + 'renderer has already initialized. Please file an issue with a reproducing case.');
return new Set();
}
var findInstances = findHostInstancesForRefresh;
var affectedInstances = new Set();
mountedRoots.forEach(function (root) {
var instancesForRoot = findInstances(root, families);
instancesForRoot.forEach(function (inst) {
affectedInstances.add(inst);
});
});
return affectedInstances;
}
var findInstances = findHostInstancesForRefresh;
var affectedInstances = new Set();
mountedRoots.forEach(function (root) {
var instancesForRoot = findInstances(root, families);
instancesForRoot.forEach(function (inst) {
affectedInstances.add(inst);
});
});
return affectedInstances;
}
function injectIntoGlobalHook(globalObject) {
// For React Native, the global hook will be set up by require('react-devtools-core').
// That code will run before us. So we need to monkeypatch functions on existing hook.
{
// For React Native, the global hook will be set up by require('react-devtools-core').
// That code will run before us. So we need to monkeypatch functions on existing hook.
// For React Web, the global hook will be set up by the extension.
// This will also run before us.
var hook = globalObject.__REACT_DEVTOOLS_GLOBAL_HOOK__;
if (hook === undefined) {
// However, if there is no DevTools extension, we'll need to set up the global hook ourselves.
// Note that in this case it's important that renderer code runs *after* this method call.
// Otherwise, the renderer will think that there is no global hook, and won't do the injection.
globalObject.__REACT_DEVTOOLS_GLOBAL_HOOK__ = hook = {
supportsFiber: true,
inject: function () {},
onCommitFiberRoot: function (id, root) {},
onCommitFiberUnmount: function () {}
// For React Web, the global hook will be set up by the extension.
// This will also run before us.
var hook = globalObject.__REACT_DEVTOOLS_GLOBAL_HOOK__;
if (hook === undefined) {
// However, if there is no DevTools extension, we'll need to set up the global hook ourselves.
// Note that in this case it's important that renderer code runs *after* this method call.
// Otherwise, the renderer will think that there is no global hook, and won't do the injection.
globalObject.__REACT_DEVTOOLS_GLOBAL_HOOK__ = hook = {
supportsFiber: true,
inject: function () {},
onCommitFiberRoot: function (id, root) {},
onCommitFiberUnmount: function () {}
};
}
// Here, we just want to get a reference to scheduleRefresh.
var oldInject = hook.inject;
hook.inject = function (injected) {
findHostInstancesForRefresh = injected.findHostInstancesForRefresh;
scheduleRefresh = injected.scheduleRefresh;
setRefreshHandler = injected.setRefreshHandler;
return oldInject.apply(this, arguments);
};
}
// Here, we just want to get a reference to scheduleRefresh.
var oldInject = hook.inject;
hook.inject = function (injected) {
findHostInstancesForRefresh = injected.findHostInstancesForRefresh;
scheduleRefresh = injected.scheduleRefresh;
setRefreshHandler = injected.setRefreshHandler;
return oldInject.apply(this, arguments);
};
// We also want to track currently mounted roots.
var oldOnCommitFiberRoot = hook.onCommitFiberRoot;
hook.onCommitFiberRoot = function (id, root) {
var current = root.current;
var alternate = current.alternate;
// We also want to track currently mounted roots.
var oldOnCommitFiberRoot = hook.onCommitFiberRoot;
hook.onCommitFiberRoot = function (id, root) {
var current = root.current;
var alternate = current.alternate;
// We need to determine whether this root has just (un)mounted.
// This logic is copy-pasted from similar logic in the DevTools backend.
// If this breaks with some refactoring, you'll want to update DevTools too.
// We need to determine whether this root has just (un)mounted.
// This logic is copy-pasted from similar logic in the DevTools backend.
// If this breaks with some refactoring, you'll want to update DevTools too.
if (alternate !== null) {
var wasMounted = alternate.memoizedState != null && alternate.memoizedState.element != null;
var isMounted = current.memoizedState != null && current.memoizedState.element != null;
if (alternate !== null) {
var wasMounted = alternate.memoizedState != null && alternate.memoizedState.element != null;
var isMounted = current.memoizedState != null && current.memoizedState.element != null;
if (!wasMounted && isMounted) {
if (!wasMounted && isMounted) {
// Mount a new root.
mountedRoots.add(root);
} else if (wasMounted && isMounted) {
// Update an existing root.
// This doesn't affect our mounted root Set.
} else if (wasMounted && !isMounted) {
// Unmount an existing root.
mountedRoots.delete(root);
}
} else {
// Mount a new root.
mountedRoots.add(root);
} else if (wasMounted && isMounted) {
// Update an existing root.
// This doesn't affect our mounted root Set.
} else if (wasMounted && !isMounted) {
// Unmount an existing root.
mountedRoots.delete(root);
}
} else {
// Mount a new root.
mountedRoots.add(root);
}
return oldOnCommitFiberRoot.apply(this, arguments);
};
return oldOnCommitFiberRoot.apply(this, arguments);
};
}
}

@@ -418,3 +433,5 @@

function _getMountedRootCount() {
return mountedRoots.size;
{
return mountedRoots.size;
}
}

@@ -445,67 +462,71 @@

function createSignatureFunctionForTransform() {
var call = 0;
var savedType = void 0;
var hasCustomHooks = void 0;
return function (type, key, forceReset, getCustomHooks) {
switch (call++) {
case 0:
savedType = type;
hasCustomHooks = typeof getCustomHooks === 'function';
setSignature(type, key, forceReset, getCustomHooks);
break;
case 1:
if (hasCustomHooks) {
collectCustomHooksForSignature(savedType);
}
break;
}
return type;
};
{
var call = 0;
var savedType = void 0;
var hasCustomHooks = void 0;
return function (type, key, forceReset, getCustomHooks) {
switch (call++) {
case 0:
savedType = type;
hasCustomHooks = typeof getCustomHooks === 'function';
setSignature(type, key, forceReset, getCustomHooks);
break;
case 1:
if (hasCustomHooks) {
collectCustomHooksForSignature(savedType);
}
break;
}
return type;
};
}
}
function isLikelyComponentType(type) {
switch (typeof type) {
case 'function':
{
// First, deal with classes.
if (type.prototype != null) {
if (type.prototype.isReactComponent) {
// React class.
return true;
}
var ownNames = Object.getOwnPropertyNames(type.prototype);
if (ownNames.length > 1 || ownNames[0] !== 'constructor') {
// This looks like a class.
return false;
}
// eslint-disable-next-line no-proto
if (type.prototype.__proto__ !== Object.prototype) {
// It has a superclass.
return false;
}
// Pass through.
// This looks like a regular function with empty prototype.
}
// For plain functions and arrows, use name as a heuristic.
var name = type.name || type.displayName;
return typeof name === 'string' && /^[A-Z]/.test(name);
}
case 'object':
{
if (type != null) {
switch (type.$$typeof) {
case REACT_FORWARD_REF_TYPE:
case REACT_MEMO_TYPE:
// Definitely React components.
{
switch (typeof type) {
case 'function':
{
// First, deal with classes.
if (type.prototype != null) {
if (type.prototype.isReactComponent) {
// React class.
return true;
default:
}
var ownNames = Object.getOwnPropertyNames(type.prototype);
if (ownNames.length > 1 || ownNames[0] !== 'constructor') {
// This looks like a class.
return false;
}
// eslint-disable-next-line no-proto
if (type.prototype.__proto__ !== Object.prototype) {
// It has a superclass.
return false;
}
// Pass through.
// This looks like a regular function with empty prototype.
}
// For plain functions and arrows, use name as a heuristic.
var name = type.name || type.displayName;
return typeof name === 'string' && /^[A-Z]/.test(name);
}
return false;
}
default:
{
return false;
}
case 'object':
{
if (type != null) {
switch (type.$$typeof) {
case REACT_FORWARD_REF_TYPE:
case REACT_MEMO_TYPE:
// Definitely React components.
return true;
default:
return false;
}
}
return false;
}
default:
{
return false;
}
}
}

@@ -512,0 +533,0 @@ }

@@ -10,9 +10,2 @@ /** @license React vundefined

'use strict';var h="function"===typeof Symbol&&Symbol.for,l=h?Symbol.for("react.forward_ref"):60112,m=h?Symbol.for("react.memo"):60115,n="function"===typeof WeakMap?WeakMap:Map,p="function"===typeof WeakSet?WeakSet:Set,q=new Map,r=new p,t=new n,u=new n,v=[],w=null,x=null,y=null,z=new Set;
function A(a){if(null!==a.fullKey)return a.fullKey;var b=a.ownKey,c=void 0;try{c=a.getCustomHooks()}catch(k){return a.forceReset=!0,a.fullKey=b}for(var f=0;f<c.length;f++){var e=c[f];if("function"!==typeof e){a.forceReset=!0;break}e=t.get(e);if(void 0!==e){var g=A(e);e.forceReset&&(a.forceReset=!0);b+="\n---\n"+g}}return a.fullKey=b}function B(a){return u.get(a)}
function C(a,b){if(null!==a&&("function"===typeof a||"object"===typeof a)&&!r.has(a)){r.add(a);var c=q.get(b);void 0===c?(c={current:a},q.set(b,c)):v.push([c,a]);if("object"===typeof a&&null!==a)switch(a.$$typeof){case l:C(a.render,b+"$render");break;case m:C(a.type,b+"$type")}}}function D(a,b){t.set(a,{forceReset:2<arguments.length&&void 0!==arguments[2]?arguments[2]:!1,ownKey:b,fullKey:null,getCustomHooks:arguments[3]||function(){return[]}})}function E(a){a=t.get(a);void 0!==a&&A(a)}
var F={performReactRefresh:function(){if(0===v.length)return!1;var a=new Set,b=new Set,c=v;v=[];c.forEach(function(d){var c=d[0];d=d[1];var e=c.current;u.set(e,c);u.set(d,c);c.current=d;e.prototype&&e.prototype.isReactComponent||d.prototype&&d.prototype.isReactComponent?d=!1:(e=t.get(e),d=t.get(d),d=void 0===e&&void 0===d||void 0!==e&&void 0!==d&&A(e)===A(d)&&!d.forceReset?!0:!1);d?b.add(c):a.add(c)});var f={updatedFamilies:b,staleFamilies:a};if("function"!==typeof w||"function"!==typeof x)return!1;
var e=x;w(B);var g=!1,k=null;z.forEach(function(a){try{e(a,f)}catch(G){g||(g=!0,k=G)}});if(g)throw k;return!0},register:C,setSignature:D,collectCustomHooksForSignature:E,getFamilyByID:function(a){return q.get(a)},findAffectedHostInstances:function(a){if("function"!==typeof y)return new Set;var b=y,c=new Set;z.forEach(function(f){b(f,a).forEach(function(a){c.add(a)})});return c},injectIntoGlobalHook:function(a){var b=a.__REACT_DEVTOOLS_GLOBAL_HOOK__;void 0===b&&(a.__REACT_DEVTOOLS_GLOBAL_HOOK__=b=
{supportsFiber:!0,inject:function(){},onCommitFiberRoot:function(){},onCommitFiberUnmount:function(){}});var c=b.inject;b.inject=function(a){y=a.findHostInstancesForRefresh;x=a.scheduleRefresh;w=a.setRefreshHandler;return c.apply(this,arguments)};var f=b.onCommitFiberRoot;b.onCommitFiberRoot=function(a,b){var c=b.current,d=c.alternate;null!==d?(d=null!=d.memoizedState&&null!=d.memoizedState.element,c=null!=c.memoizedState&&null!=c.memoizedState.element,!d&&c?z.add(b):d&&c||d&&!c&&z.delete(b)):z.add(b);
return f.apply(this,arguments)}},_getMountedRootCount:function(){return z.size},createSignatureFunctionForTransform:function(){var a=0,b=void 0,c=void 0;return function(f,e,g,k){switch(a++){case 0:b=f;c="function"===typeof k;D(f,e,g,k);break;case 1:c&&E(b)}return f}},isLikelyComponentType:function(a){switch(typeof a){case "function":if(null!=a.prototype){if(a.prototype.isReactComponent)return!0;var b=Object.getOwnPropertyNames(a.prototype);if(1<b.length||"constructor"!==b[0]||a.prototype.__proto__!==
Object.prototype)return!1}a=a.name||a.displayName;return"string"===typeof a&&/^[A-Z]/.test(a);case "object":if(null!=a)switch(a.$$typeof){case l:case m:return!0}return!1;default:return!1}}};module.exports=F.default||F;
'use strict';throw Error("React Refresh runtime should not be included in the production bundle.");

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

],
"version": "0.0.4",
"version": "0.0.5",
"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