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

react-refresh

Package Overview
Dependencies
Maintainers
7
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-375616788 to 0.0.0-3694a3b5e

8

build-info.json
{
"branch": "master",
"buildNumber": "32824",
"checksum": "5fa8efa",
"commit": "375616788",
"buildNumber": "48138",
"checksum": "d91410d",
"commit": "3694a3b5e",
"environment": "ci",
"reactVersion": "16.8.6-canary-375616788"
"reactVersion": "16.9.0-canary-3694a3b5e"
}

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

/** @license React v0.0.0-375616788
/** @license React v0.0.0-3694a3b5e
* react-refresh-babel.development.js

@@ -19,7 +19,10 @@ *

var ReactFreshBabelPlugin = function (babel) {
var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
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 + '".');
if (env !== 'development' && !opts.skipEnvCheck) {
throw new Error('React Refresh Babel transform should only be enabled in development environment. ' + 'Instead, the environment is: "' + env + '". If you want to override this check, pass {skipEnvCheck: true} as plugin options.');
}

@@ -29,10 +32,11 @@ }

var t = babel.types;
var registrationsByProgramPath = new Map();
var registrationsByProgramPath = new Map();
function createRegistration(programPath, persistentID) {
var handle = programPath.scope.generateUidIdentifier('c');
if (!registrationsByProgramPath.has(programPath)) {
registrationsByProgramPath.set(programPath, []);
}
var registrations = registrationsByProgramPath.get(programPath);

@@ -52,2 +56,3 @@ registrations.push({

var node = path.node;
switch (node.type) {

@@ -58,8 +63,10 @@ case 'Identifier':

return false;
}
// export default hoc(Foo)
} // export default hoc(Foo)
// const X = hoc(Foo)
callback(inferredName, node, null);
return true;
}
case 'FunctionDeclaration':

@@ -73,2 +80,3 @@ {

}
case 'ArrowFunctionExpression':

@@ -78,8 +86,10 @@ {

return false;
}
// let Foo = () => {}
} // let Foo = () => {}
// export default hoc1(hoc2(() => {}))
callback(inferredName, node, path);
return true;
}
case 'FunctionExpression':

@@ -93,9 +103,13 @@ {

}
case 'CallExpression':
{
var argsPath = path.get('arguments');
if (argsPath === undefined || argsPath.length === 0) {
return false;
}
var calleePath = path.get('callee');
switch (calleePath.node.type) {

@@ -109,10 +123,13 @@ case 'MemberExpression':

var foundInside = findInnerComponents(innerName, firstArgPath, callback);
if (!foundInside) {
return false;
}
// const Foo = hoc1(hoc2(() => {}))
} // const Foo = hoc1(hoc2(() => {}))
// export default memo(React.forwardRef(function() {}))
callback(inferredName, node, path);
return true;
}
default:

@@ -124,12 +141,17 @@ {

}
case 'VariableDeclarator':
{
var init = node.init;
if (init === null) {
return false;
}
var name = node.id.name;
if (!isComponentishName(name)) {
return false;
}
switch (init.type) {

@@ -140,2 +162,3 @@ case 'ArrowFunctionExpression':

break;
case 'CallExpression':

@@ -147,2 +170,3 @@ {

var calleeType = callee.type;
if (calleeType === 'Import') {

@@ -155,7 +179,6 @@ return false;

return false;
}
// Neither require nor import. Might be a HOC.
} // Neither require nor import. Might be a HOC.
// Pass through.
} else if (calleeType === 'MemberExpression') {
// Could be something like React.forwardRef(...)
} else if (calleeType === 'MemberExpression') {// Could be something like React.forwardRef(...)
// Pass through.

@@ -166,28 +189,41 @@ } else {

}
break;
}
case 'TaggedTemplateExpression':
// Maybe something like styled.div`...`
break;
default:
return false;
}
var initPath = path.get('init');
var _foundInside = findInnerComponents(inferredName, initPath, callback);
if (_foundInside) {
return true;
}
// See if this identifier is used in JSX. Then it's a component.
} // See if this identifier is used in JSX. Then it's a component.
var binding = path.scope.getBinding(name);
if (binding === undefined) {
return;
}
var isLikelyUsedAsType = false;
var referencePaths = binding.referencePaths;
for (var i = 0; i < referencePaths.length; i++) {
var ref = referencePaths[i];
if (ref.node.type !== 'JSXIdentifier' && ref.node.type !== 'Identifier') {
continue;
}
var refParent = ref.parent;
if (refParent.type === 'JSXOpeningElement') {

@@ -198,2 +234,3 @@ isLikelyUsedAsType = true;

var fnName = void 0;
switch (_callee.type) {

@@ -203,2 +240,3 @@ case 'Identifier':

break;
case 'MemberExpression':

@@ -208,2 +246,3 @@ fnName = _callee.property.name;

}
switch (fnName) {

@@ -218,2 +257,3 @@ case 'createElement':

}
if (isLikelyUsedAsType) {

@@ -227,2 +267,3 @@ // const X = ... + later <X />

}
return false;

@@ -254,2 +295,3 @@ }

return true;
default:

@@ -262,5 +304,7 @@ return false;

var fnHookCalls = hookCalls.get(functionNode);
if (fnHookCalls === undefined) {
return null;
}
return {

@@ -278,8 +322,8 @@ key: fnHookCalls.map(function (call) {

var hasForceResetCommentByFile = new WeakMap();
var hasForceResetCommentByFile = new WeakMap(); // We let user do /* @refresh reset */ to reset state in the whole file.
// We let user do /* @refresh reset */ to reset state in the whole file.
function hasForceResetComment(path) {
var file = path.hub.file;
var hasForceReset = hasForceResetCommentByFile.get(file);
if (hasForceReset !== undefined) {

@@ -291,4 +335,6 @@ return hasForceReset;

var comments = file.ast.comments;
for (var i = 0; i < comments.length; i++) {
var cmt = comments[i];
if (cmt.value.indexOf('@refresh reset') !== -1) {

@@ -307,4 +353,2 @@ hasForceReset = true;

customHooks = signature.customHooks;
var forceReset = hasForceResetComment(scope.path);

@@ -314,3 +358,4 @@ var customHooksInScope = [];

// Check if a corresponding binding exists where we emit the signature.
var bindingName = void 0;
var bindingName;
switch (callee.type) {

@@ -321,3 +366,5 @@ case 'MemberExpression':

}
break;
case 'Identifier':

@@ -327,2 +374,3 @@ bindingName = callee.name;

}
if (scope.hasBinding(bindingName)) {

@@ -336,13 +384,25 @@ customHooksInScope.push(callee);

});
var finalKey = key;
var args = [node, t.stringLiteral(key)];
if (typeof require === 'function' && !opts.emitFullSignatures) {
// Prefer to hash when we can (e.g. outside of ASTExplorer).
// This makes it deterministically compact, even if there's
// e.g. a useState ininitalizer with some code inside.
// We also need it for www that has transforms like cx()
// that don't understand if something is part of a string.
finalKey = require('crypto').createHash('sha1').update(key).digest('base64');
}
var args = [node, t.stringLiteral(finalKey)];
if (forceReset || customHooksInScope.length > 0) {
args.push(t.booleanLiteral(forceReset));
}
if (customHooksInScope.length > 0) {
args.push(
// TODO: We could use an arrow here to be more compact.
args.push( // TODO: We could use an arrow here to be more compact.
// However, don't do it until AMA can run them natively.
t.functionExpression(null, [], t.blockStatement([t.returnStatement(t.arrayExpression(customHooksInScope))])));
}
return args;

@@ -354,3 +414,2 @@ }

var seenForOutro = new WeakSet();
var hookCalls = new WeakMap();

@@ -360,8 +419,7 @@ var HookCallsVisitor = {

var node = path.node;
var callee = node.callee;
// Note: this visitor MUST NOT mutate the tree in any way.
var callee = node.callee; // Note: this visitor MUST NOT mutate the tree in any way.
// It runs early in a separate traversal and should be very fast.
var name = null;
switch (callee.type) {

@@ -371,2 +429,3 @@ case 'Identifier':

break;
case 'MemberExpression':

@@ -376,24 +435,31 @@ name = callee.property.name;

}
if (name === null || !/^use[A-Z]/.test(name)) {
return;
}
var fnScope = path.scope.getFunctionParent();
if (fnScope === null) {
return;
}
} // This is a Hook call. Record it.
// This is a Hook call. Record it.
var fnNode = fnScope.block;
if (!hookCalls.has(fnNode)) {
hookCalls.set(fnNode, []);
}
var hookCallsForFn = hookCalls.get(fnNode);
var key = '';
if (path.parent.type === 'VariableDeclarator') {
// TODO: if there is no LHS, consider some other heuristic.
key = path.parentPath.get('id').getSource();
}
} // Some built-in Hooks reset on edits to arguments.
// Some built-in Hooks reset on edits to arguments.
var args = path.get('arguments');
if (name === 'useState' && args.length > 0) {

@@ -414,3 +480,2 @@ // useState second argument is initial state.

};
return {

@@ -422,2 +487,3 @@ visitor: {

var declPath = path.get('declaration');
if (decl.type !== 'CallExpression') {

@@ -429,12 +495,11 @@ // For now, we only support possible HOC calls here.

return;
}
} // Make sure we're not mutating the same tree twice.
// This can happen if another Babel plugin replaces parents.
// Make sure we're not mutating the same tree twice.
// This can happen if another Babel plugin replaces parents.
if (seenForRegistration.has(node)) {
return;
}
seenForRegistration.add(node);
// Don't mutate the tree above this point.
seenForRegistration.add(node); // Don't mutate the tree above this point.
// This code path handles nested cases like:

@@ -446,2 +511,3 @@ // export default memo(() => {})

// export default memo(function Named() {})
var inferredName = '%default%';

@@ -457,2 +523,3 @@ var programPath = path.parentPath;

}
var handle = createRegistration(programPath, persistentID);

@@ -462,8 +529,8 @@ targetPath.replaceWith(t.assignmentExpression('=', handle, targetExpr));

},
FunctionDeclaration: {
enter: function (path) {
var node = path.node;
var programPath = void 0;
var insertAfterPath = void 0;
var programPath;
var insertAfterPath;
switch (path.parent.type) {

@@ -474,2 +541,3 @@ case 'Program':

break;
case 'ExportNamedDeclaration':

@@ -479,2 +547,3 @@ insertAfterPath = path.parentPath;

break;
case 'ExportDefaultDeclaration':

@@ -484,6 +553,9 @@ insertAfterPath = path.parentPath;

break;
default:
return;
}
var id = node.id;
if (id === null) {

@@ -493,17 +565,19 @@ // We don't currently handle anonymous default exports.

}
var inferredName = id.name;
if (!isComponentishName(inferredName)) {
return;
}
} // Make sure we're not mutating the same tree twice.
// This can happen if another Babel plugin replaces parents.
// Make sure we're not mutating the same tree twice.
// This can happen if another Babel plugin replaces parents.
if (seenForRegistration.has(node)) {
return;
}
seenForRegistration.add(node);
// Don't mutate the tree above this point.
seenForRegistration.add(node); // Don't mutate the tree above this point.
// export function Named() {}
// function Named() {}
findInnerComponents(inferredName, path, function (persistentID, targetExpr) {

@@ -517,18 +591,21 @@ var handle = createRegistration(programPath, persistentID);

var id = node.id;
if (id === null) {
return;
}
var signature = getHookCallsSignature(node);
if (signature === null) {
return;
}
} // Make sure we're not mutating the same tree twice.
// This can happen if another Babel plugin replaces parents.
// Make sure we're not mutating the same tree twice.
// This can happen if another Babel plugin replaces parents.
if (seenForSignature.has(node)) {
return;
}
seenForSignature.add(node);
// Don't mutate the tree above this point.
seenForSignature.add(node); // Don't mutate the tree above this point.
var sigCallID = path.scope.generateUidIdentifier('_s');

@@ -538,14 +615,11 @@ path.scope.parent.push({

init: t.callExpression(t.identifier('$RefreshSig$'), [])
});
// The signature call is split in two parts. One part is called inside the function.
}); // The signature call is split in two parts. One part is called inside the function.
// This is used to signal when first render happens.
path.get('body').unshiftContainer('body', t.expressionStatement(t.callExpression(sigCallID, [])));
// The second call is around the function itself.
path.get('body').unshiftContainer('body', t.expressionStatement(t.callExpression(sigCallID, []))); // The second call is around the function itself.
// This is used to associate a type with a signature.
// Unlike with $RefreshReg$, this needs to work for nested
// declarations too. So we need to search for a path where
// we can insert a statement rather than hardcoding it.
var insertAfterPath = null;

@@ -558,2 +632,3 @@ path.find(function (p) {

});
if (insertAfterPath === null) {

@@ -570,14 +645,15 @@ return;

var signature = getHookCallsSignature(node);
if (signature === null) {
return;
}
} // Make sure we're not mutating the same tree twice.
// This can happen if another Babel plugin replaces parents.
// Make sure we're not mutating the same tree twice.
// This can happen if another Babel plugin replaces parents.
if (seenForSignature.has(node)) {
return;
}
seenForSignature.add(node);
// Don't mutate the tree above this point.
seenForSignature.add(node); // Don't mutate the tree above this point.
var sigCallID = path.scope.generateUidIdentifier('_s');

@@ -587,9 +663,10 @@ path.scope.parent.push({

init: t.callExpression(t.identifier('$RefreshSig$'), [])
});
// The signature call is split in two parts. One part is called inside the function.
}); // The signature call is split in two parts. One part is called inside the function.
// This is used to signal when first render happens.
path.get('body').unshiftContainer('body', t.expressionStatement(t.callExpression(sigCallID, [])));
// The second call is around the function itself.
if (path.node.body.type !== 'BlockStatement') {
path.node.body = t.blockStatement([t.returnStatement(path.node.body)]);
}
path.get('body').unshiftContainer('body', t.expressionStatement(t.callExpression(sigCallID, []))); // The second call is around the function itself.
// This is used to associate a type with a signature.

@@ -605,6 +682,6 @@

});
if (insertAfterPath === null) {
return;
}
// Special case when a function would get an inferred name:
} // Special case when a function would get an inferred name:
// let Foo = () => {}

@@ -614,8 +691,8 @@ // let Foo = function() {}

// we don't mess up the inferred 'Foo' function name.
insertAfterPath.insertAfter(t.expressionStatement(t.callExpression(sigCallID, createArgumentsForSignature(path.parent.id, signature, insertAfterPath.scope))));
// Result: let Foo = () => {}; __signature(Foo, ...);
insertAfterPath.insertAfter(t.expressionStatement(t.callExpression(sigCallID, createArgumentsForSignature(path.parent.id, signature, insertAfterPath.scope)))); // Result: let Foo = () => {}; __signature(Foo, ...);
} else {
// let Foo = hoc(() => {})
path.replaceWith(t.callExpression(sigCallID, createArgumentsForSignature(node, signature, path.scope)));
// Result: let Foo = hoc(__signature(() => {}, ...))
path.replaceWith(t.callExpression(sigCallID, createArgumentsForSignature(node, signature, path.scope))); // Result: let Foo = hoc(__signature(() => {}, ...))
}

@@ -626,4 +703,5 @@ }

var node = path.node;
var programPath = void 0;
var insertAfterPath = void 0;
var programPath;
var insertAfterPath;
switch (path.parent.type) {

@@ -634,2 +712,3 @@ case 'Program':

break;
case 'ExportNamedDeclaration':

@@ -639,2 +718,3 @@ insertAfterPath = path.parentPath;

break;
case 'ExportDefaultDeclaration':

@@ -644,18 +724,21 @@ insertAfterPath = path.parentPath;

break;
default:
return;
}
} // Make sure we're not mutating the same tree twice.
// This can happen if another Babel plugin replaces parents.
// Make sure we're not mutating the same tree twice.
// This can happen if another Babel plugin replaces parents.
if (seenForRegistration.has(node)) {
return;
}
seenForRegistration.add(node);
// Don't mutate the tree above this point.
seenForRegistration.add(node); // Don't mutate the tree above this point.
var declPaths = path.get('declarations');
if (declPaths.length !== 1) {
return;
}
var declPath = declPaths[0];

@@ -671,3 +754,5 @@ var inferredName = declPath.node.id.name;

}
var handle = createRegistration(programPath, persistentID);
if ((targetExpr.type === 'ArrowFunctionExpression' || targetExpr.type === 'FunctionExpression') && targetPath.parent.type === 'VariableDeclarator') {

@@ -679,12 +764,9 @@ // Special case when a function would get an inferred name:

// we don't mess up the inferred 'Foo' function name.
insertAfterPath.insertAfter(t.expressionStatement(t.assignmentExpression('=', handle, declPath.node.id)));
// Result: let Foo = () => {}; _c1 = Foo;
insertAfterPath.insertAfter(t.expressionStatement(t.assignmentExpression('=', handle, declPath.node.id))); // Result: let Foo = () => {}; _c1 = Foo;
} else {
// let Foo = hoc(() => {})
targetPath.replaceWith(t.assignmentExpression('=', handle, targetExpr));
// Result: let Foo = _c1 = hoc(() => {})
targetPath.replaceWith(t.assignmentExpression('=', handle, targetExpr)); // Result: let Foo = _c1 = hoc(() => {})
}
});
},
Program: {

@@ -700,15 +782,17 @@ enter: function (path) {

var registrations = registrationsByProgramPath.get(path);
if (registrations === undefined) {
return;
}
} // Make sure we're not mutating the same tree twice.
// This can happen if another Babel plugin replaces parents.
// Make sure we're not mutating the same tree twice.
// This can happen if another Babel plugin replaces parents.
var node = path.node;
if (seenForOutro.has(node)) {
return;
}
seenForOutro.add(node);
// Don't mutate the tree above this point.
seenForOutro.add(node); // Don't mutate the tree above this point.
registrationsByProgramPath.delete(path);

@@ -720,3 +804,2 @@ var declarators = [];

persistentID = _ref.persistentID;
path.pushContainer('body', t.expressionStatement(t.callExpression(t.identifier('$RefreshReg$'), [handle, t.stringLiteral(persistentID)])));

@@ -738,2 +821,4 @@ declarators.push(t.variableDeclarator(handle));

// This is hacky but makes it work with both Rollup and Jest.
var babel = ReactFreshBabelPlugin$2.default || ReactFreshBabelPlugin$2;

@@ -740,0 +825,0 @@

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

/** @license React v0.0.0-375616788
/** @license React v0.0.0-3694a3b5e
* react-refresh-babel.production.min.js

@@ -14,10 +14,11 @@ *

h.property.name}switch(k){case "createElement":case "jsx":case "jsxDEV":case "jsxs":b=!0}}if(b)return d(a,f,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 e.cloneDeep(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 f=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):f=!0});a=[a,e.stringLiteral(c)];(f||0<g.length)&&a.push(e.booleanLiteral(f));0<g.length&&a.push(e.functionExpression(null,[],e.blockStatement([e.returnStatement(e.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 e=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 f=a.get("arguments");"useState"===d&&0<f.length?c+="("+f[0].getSource()+")":"useReducer"===d&&1<f.length&&(c+="("+f[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 f=a.parentPath;m("%default%",c,function(a,b,c){null!==c&&(a=r(f,a),c.replaceWith(e.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 f=b.id;null!==f&&(f=f.name,t(f)&&!k.has(b)&&(k.add(b),m(f,a,function(a,b){a=r(d,a);c.insertAfter(e.expressionStatement(e.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:e.callExpression(e.identifier("$RefreshSig$"),[])});a.get("body").unshiftContainer("body",e.expressionStatement(e.callExpression(b,
[])));var f=null;a.find(function(a){if(a.parentPath.isBlock())return f=a,!0});null!==f&&f.insertAfter(e.expressionStatement(e.callExpression(b,u(d,c,f.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:e.callExpression(e.identifier("$RefreshSig$"),[])});a.get("body").unshiftContainer("body",e.expressionStatement(e.callExpression(c,[])));if("VariableDeclarator"===
a.parent.type){var f=null;a.find(function(a){if(a.parentPath.isBlock())return f=a,!0});null!==f&&f.insertAfter(e.expressionStatement(e.callExpression(c,u(a.parent.id,d,f.scope))))}else a.replaceWith(e.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 f=a[0];m(f.node.id.name,f,function(a,b,h){null!==h&&(a=r(d,a),"ArrowFunctionExpression"!==b.type&&"FunctionExpression"!==b.type||"VariableDeclarator"!==h.parent.type?h.replaceWith(e.assignmentExpression("=",a,b)):c.insertAfter(e.expressionStatement(e.assignmentExpression("=",a,f.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",
e.variableDeclaration("var",c));b.forEach(function(b){var d=b.handle;b=b.persistentID;a.pushContainer("body",e.expressionStatement(e.callExpression(e.identifier("$RefreshReg$"),[d,e.stringLiteral(b)])));c.push(e.variableDeclarator(d))})}}}}}}}var A={default:v},B=A&&v||A;module.exports=B.default||B;
!0;break a;default:a=!1}return!a}).map(function(a){return e.cloneDeep(a.callee)})}}function D(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 f=D(d.path),g=[];b.forEach(function(a){switch(a.type){case "MemberExpression":if("Identifier"===a.object.type)var b=a.object.name;break;case "Identifier":b=a.name}d.hasBinding(b)?
g.push(a):f=!0});b=c;"function"!==typeof require||y.emitFullSignatures||(b=require("crypto").createHash("sha1").update(c).digest("base64"));a=[a,e.stringLiteral(b)];(f||0<g.length)&&a.push(e.booleanLiteral(f));0<g.length&&a.push(e.functionExpression(null,[],e.blockStatement([e.returnStatement(e.arrayExpression(g))])));return a}var y=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};if("function"===typeof q.getEnv){var z=q.getEnv();if("development"!==z&&!y.skipEnvCheck)throw Error('React Refresh Babel transform should only be enabled in development environment. Instead, the environment is: "'+
z+'". If you want to override this check, pass {skipEnvCheck: true} as plugin options.');}var e=q.types,l=new Map,x=new WeakMap,k=new WeakSet,p=new WeakSet,A=new WeakSet,n=new WeakMap,E={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 f=a.get("arguments");"useState"===d&&0<f.length?c+="("+f[0].getSource()+")":"useReducer"===d&&1<f.length&&(c+="("+f[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 f=a.parentPath;m("%default%",c,function(a,b,c){null!==c&&(a=r(f,a),c.replaceWith(e.assignmentExpression("=",a,b)))})}},FunctionDeclaration:{enter:function(a){var b=
a.node;switch(a.parent.type){case "Program":var d=a;var c=a.parentPath;break;case "ExportNamedDeclaration":d=a.parentPath;c=d.parentPath;break;case "ExportDefaultDeclaration":d=a.parentPath;c=d.parentPath;break;default:return}var f=b.id;null!==f&&(f=f.name,t(f)&&!k.has(b)&&(k.add(b),m(f,a,function(a,b){a=r(c,a);d.insertAfter(e.expressionStatement(e.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:e.callExpression(e.identifier("$RefreshSig$"),[])});a.get("body").unshiftContainer("body",e.expressionStatement(e.callExpression(b,[])));var f=null;a.find(function(a){if(a.parentPath.isBlock())return f=a,!0});null!==f&&f.insertAfter(e.expressionStatement(e.callExpression(b,u(d,c,f.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:e.callExpression(e.identifier("$RefreshSig$"),[])});"BlockStatement"!==a.node.body.type&&(a.node.body=e.blockStatement([e.returnStatement(a.node.body)]));a.get("body").unshiftContainer("body",e.expressionStatement(e.callExpression(c,[])));if("VariableDeclarator"===a.parent.type){var f=null;a.find(function(a){if(a.parentPath.isBlock())return f=a,!0});null!==f&&f.insertAfter(e.expressionStatement(e.callExpression(c,u(a.parent.id,d,f.scope))))}else a.replaceWith(e.callExpression(c,u(b,d,a.scope)))}}},
VariableDeclaration:function(a){var b=a.node;switch(a.parent.type){case "Program":var d=a;var c=a.parentPath;break;case "ExportNamedDeclaration":d=a.parentPath;c=d.parentPath;break;case "ExportDefaultDeclaration":d=a.parentPath;c=d.parentPath;break;default:return}if(!k.has(b)&&(k.add(b),a=a.get("declarations"),1===a.length)){var f=a[0];m(f.node.id.name,f,function(a,b,h){null!==h&&(a=r(c,a),"ArrowFunctionExpression"!==b.type&&"FunctionExpression"!==b.type||"VariableDeclarator"!==h.parent.type?h.replaceWith(e.assignmentExpression("=",
a,b)):d.insertAfter(e.expressionStatement(e.assignmentExpression("=",a,f.node.id))))})}},Program:{enter:function(a){a.traverse(E)},exit:function(a){var b=l.get(a);if(void 0!==b){var d=a.node;if(!A.has(d)){A.add(d);l.delete(a);var c=[];a.pushContainer("body",e.variableDeclaration("var",c));b.forEach(function(b){var d=b.handle;b=b.persistentID;a.pushContainer("body",e.expressionStatement(e.callExpression(e.identifier("$RefreshReg$"),[d,e.stringLiteral(b)])));c.push(e.variableDeclarator(d))})}}}}}}}
var B={default:v},C=B&&v||B;module.exports=C.default||C;

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

/** @license React v0.0.0-375616788
/** @license React v0.0.0-3694a3b5e
* react-refresh-runtime.development.js

@@ -27,8 +27,7 @@ *

// TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary
// (unstable) APIs that have been removed. Can we remove the symbols?
// TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary
// (unstable) APIs that have been removed. Can we remove the symbols?
var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;

@@ -39,78 +38,21 @@

/**
* Similar to invariant but only logs a warning if the condition is not met.
* This can be used to log issues in development environments in critical
* paths. Removing the logging code for production environments will keep the
* same logic and follow the same code paths.
*/
var PossiblyWeakMap = typeof WeakMap === 'function' ? WeakMap : Map; // We never remove these associations.
// It's OK to reference families, but use WeakMap/Set for types.
var warningWithoutStack = function () {};
{
warningWithoutStack = function (condition, format) {
for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
args[_key - 2] = arguments[_key];
}
if (format === undefined) {
throw new Error('`warningWithoutStack(condition, format, ...args)` requires a warning ' + 'message argument');
}
if (args.length > 8) {
// Check before the condition to catch violations early.
throw new Error('warningWithoutStack() currently supports at most 8 arguments.');
}
if (condition) {
return;
}
if (typeof console !== 'undefined') {
var argsWithFormat = args.map(function (item) {
return '' + item;
});
argsWithFormat.unshift('Warning: ' + format);
// We intentionally don't use spread (or .apply) directly because it
// breaks IE9: https://github.com/facebook/react/issues/13610
Function.prototype.apply.call(console.error, console, argsWithFormat);
}
try {
// --- Welcome to debugging React ---
// This error was thrown as a convenience so that you can use this stack
// to find the callsite that caused this warning to fire.
var argIndex = 0;
var message = 'Warning: ' + format.replace(/%s/g, function () {
return args[argIndex++];
});
throw new Error(message);
} catch (x) {}
};
}
var warningWithoutStack$1 = warningWithoutStack;
// In old environments, we'll leak previous types after every edit.
var PossiblyWeakMap = typeof WeakMap === 'function' ? WeakMap : Map;
// We never remove these associations.
// It's OK to reference families, but use WeakMap/Set for types.
var allFamiliesByID = new Map();
var allFamiliesByType = new PossiblyWeakMap();
var allSignaturesByType = new PossiblyWeakMap();
// This WeakMap is read by React, so we only put families
var allSignaturesByType = new PossiblyWeakMap(); // This WeakMap is read by React, so we only put families
// that have actually been edited here. This keeps checks fast.
// $FlowIssue
var updatedFamiliesByType = new PossiblyWeakMap();
// This is cleared on every performReactRefresh() call.
var updatedFamiliesByType = new PossiblyWeakMap(); // This is cleared on every performReactRefresh() call.
// It is an array of [Family, NextType] tuples.
var pendingUpdates = [];
// This is injected by the renderer via DevTools global hook.
var setRefreshHandler = null;
var scheduleRefresh = null;
var scheduleRoot = null;
var findHostInstancesForRefresh = null;
var pendingUpdates = []; // This is injected by the renderer via DevTools global hook.
// We keep track of mounted roots so we can schedule updates.
var mountedRoots = new Set();
// If a root captures an error, we add its element to this Map so we can retry on edit.
var helpersByRendererID = new Map();
var helpersByRoot = new Map(); // We keep track of mounted roots so we can schedule updates.
var mountedRoots = new Set(); // If a root captures an error, we add its element to this Map so we can retry on edit.
var failedRoots = new Map();

@@ -125,3 +67,4 @@ var didSomeRootFailOnMount = false;

var fullKey = signature.ownKey;
var hooks = void 0;
var hooks;
try {

@@ -140,2 +83,3 @@ hooks = signature.getCustomHooks();

var hook = hooks[i];
if (typeof hook !== 'function') {

@@ -147,3 +91,5 @@ // Something's wrong. Assume we need to remount.

}
var nestedHookSignature = allSignaturesByType.get(hook);
if (nestedHookSignature === undefined) {

@@ -154,6 +100,9 @@ // No signature means Hook wasn't in the source code, e.g. in a library.

}
var nestedHookKey = computeFullKey(nestedHookSignature);
if (nestedHookSignature.forceReset) {
signature.forceReset = true;
}
fullKey += '\n---\n' + nestedHookKey;

@@ -173,8 +122,11 @@ }

}
if (prevSignature === undefined || nextSignature === undefined) {
return false;
}
if (computeFullKey(prevSignature) !== computeFullKey(nextSignature)) {
return false;
}
if (nextSignature.forceReset) {

@@ -195,5 +147,7 @@ return false;

}
if (haveEqualSignatures(prevType, nextType)) {
return true;
}
return false;

@@ -215,3 +169,2 @@ }

var updatedFamilies = new Set();
var updates = pendingUpdates;

@@ -222,3 +175,2 @@ pendingUpdates = [];

nextType = _ref[1];
// Now that we got a real edit, we can create associations

@@ -229,5 +181,4 @@ // that will be read by the React reconciler.

updatedFamiliesByType.set(nextType, family);
family.current = nextType;
family.current = nextType; // Determine whether this should be a re-render or a re-mount.
// Determine whether this should be a re-render or a re-mount.
if (canPreserveStateBetween(prevType, nextType)) {

@@ -238,35 +189,26 @@ updatedFamilies.add(family);

}
});
}); // TODO: rename these fields to something more meaningful.
// TODO: rename these fields to something more meaningful.
var update = {
updatedFamilies: updatedFamilies, // Families that will re-render preserving state
updatedFamilies: updatedFamilies,
// Families that will re-render preserving state
staleFamilies: staleFamilies // Families that will be remounted
};
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 null;
}
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 null;
}
if (typeof scheduleRoot !== 'function') {
warningWithoutStack$1(false, 'Could not find the scheduleRoot() 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 null;
}
var scheduleRefreshForRoot = scheduleRefresh;
var scheduleRenderForRoot = scheduleRoot;
// 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);
helpersByRendererID.forEach(function (helpers) {
// 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.
helpers.setRefreshHandler(resolveFamily);
});
var didError = false;
var firstError = null;
failedRoots.forEach(function (element, root) {
var helpers = helpersByRoot.get(root);
if (helpers === undefined) {
throw new Error('Could not find helpers for a root. This is a bug in React Refresh.');
}
try {
scheduleRenderForRoot(root, element);
helpers.scheduleRoot(root, element);
} catch (err) {

@@ -276,9 +218,15 @@ if (!didError) {

firstError = err;
}
// Keep trying other roots.
} // Keep trying other roots.
}
});
mountedRoots.forEach(function (root) {
var helpers = helpersByRoot.get(root);
if (helpers === undefined) {
throw new Error('Could not find helpers for a root. This is a bug in React Refresh.');
}
try {
scheduleRefreshForRoot(root, update);
helpers.scheduleRefresh(root, update);
} catch (err) {

@@ -288,13 +236,14 @@ if (!didError) {

firstError = err;
}
// Keep trying other roots.
} // Keep trying other roots.
}
});
if (didError) {
throw firstError;
}
return update;
}
}
function register(type, id) {

@@ -305,18 +254,23 @@ {

}
if (typeof type !== 'function' && typeof type !== 'object') {
return;
}
// This can happen in an edge case, e.g. if we register
} // 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 (allFamiliesByType.has(type)) {
return;
}
// Create family or remember to update it.
} // Create family or remember to update it.
// None of this bookkeeping affects reconciliation
// until the first performReactRefresh() call above.
var family = allFamiliesByID.get(id);
if (family === undefined) {
family = { current: type };
family = {
current: type
};
allFamiliesByID.set(id, family);

@@ -326,5 +280,5 @@ } else {

}
allFamiliesByType.set(type, family);
// Visit inner types because we might not have registered them.
allFamiliesByType.set(type, family); // Visit inner types because we might not have registered them.
if (typeof type === 'object' && type !== null) {

@@ -335,2 +289,3 @@ switch (type.$$typeof) {

break;
case REACT_MEMO_TYPE:

@@ -343,6 +298,5 @@ register(type.type, id + '$type');

}
function setSignature(type, key) {
var forceReset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
var getCustomHooks = arguments[3];
var getCustomHooks = arguments.length > 3 ? arguments[3] : undefined;

@@ -359,9 +313,9 @@ {

}
}
} // This is lazily called during first render for a type.
// It captures Hook list at that time so inline requires don't break comparisons.
// This is lazily called during first render for a type.
// It captures Hook list at that time so inline requires don't break comparisons.
function collectCustomHooksForSignature(type) {
{
var signature = allSignaturesByType.get(type);
if (signature !== undefined) {

@@ -372,3 +326,2 @@ computeFullKey(signature);

}
function getFamilyByID(id) {

@@ -379,3 +332,2 @@ {

}
function getFamilyByType(type) {

@@ -386,13 +338,13 @@ {

}
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();
}
var findInstances = findHostInstancesForRefresh;
var affectedInstances = new Set();
mountedRoots.forEach(function (root) {
var instancesForRoot = findInstances(root, families);
var helpers = helpersByRoot.get(root);
if (helpers === undefined) {
throw new Error('Could not find helpers for a root. This is a bug in React Refresh.');
}
var instancesForRoot = helpers.findHostInstancesForRefresh(root, families);
instancesForRoot.forEach(function (inst) {

@@ -405,3 +357,2 @@ affectedInstances.add(inst);

}
function injectIntoGlobalHook(globalObject) {

@@ -411,6 +362,6 @@ {

// 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) {

@@ -420,27 +371,40 @@ // However, if there is no DevTools extension, we'll need to set up the global hook ourselves.

// Otherwise, the renderer will think that there is no global hook, and won't do the injection.
var nextID = 0;
globalObject.__REACT_DEVTOOLS_GLOBAL_HOOK__ = hook = {
supportsFiber: true,
inject: function () {},
inject: function (injected) {
return nextID++;
},
onCommitFiberRoot: function (id, root, maybePriorityLevel, didError) {},
onCommitFiberUnmount: function () {}
};
}
} // Here, we just want to get a reference to scheduleRefresh.
// Here, we just want to get a reference to scheduleRefresh.
var oldInject = hook.inject;
hook.inject = function (injected) {
findHostInstancesForRefresh = injected.findHostInstancesForRefresh;
scheduleRefresh = injected.scheduleRefresh;
scheduleRoot = injected.scheduleRoot;
setRefreshHandler = injected.setRefreshHandler;
return oldInject.apply(this, arguments);
};
var id = oldInject.apply(this, arguments);
// We also want to track currently mounted roots.
if (typeof injected.scheduleRefresh === 'function' && typeof injected.setRefreshHandler === 'function') {
// This version supports React Refresh.
helpersByRendererID.set(id, injected);
}
return id;
}; // We also want to track currently mounted roots.
var oldOnCommitFiberRoot = hook.onCommitFiberRoot;
hook.onCommitFiberRoot = function (id, root, maybePriorityLevel, didError) {
var helpers = helpersByRendererID.get(id);
if (helpers === undefined) {
return;
}
helpersByRoot.set(root, helpers);
var current = root.current;
var alternate = current.alternate;
// We need to determine whether this root has just (un)mounted.
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.

@@ -457,4 +421,3 @@ // If this breaks with some refactoring, you'll want to update DevTools too.

failedRoots.delete(root);
} else if (wasMounted && isMounted) {
// Update an existing root.
} else if (wasMounted && isMounted) {// Update an existing root.
// This doesn't affect our mounted root Set.

@@ -464,2 +427,3 @@ } else if (wasMounted && !isMounted) {

mountedRoots.delete(root);
if (didError) {

@@ -469,2 +433,4 @@ // We'll remount it on future edits.

failedRoots.set(root, alternate.memoizedState.element);
} else {
helpersByRoot.delete(root);
}

@@ -494,8 +460,6 @@ } else if (!wasMounted && !isMounted) {

}
function hasUnrecoverableErrors() {
return didSomeRootFailOnMount;
}
} // Exposed for testing.
// Exposed for testing.
function _getMountedRootCount() {

@@ -505,5 +469,3 @@ {

}
}
// This is a wrapper over more primitive functions for setting signature.
} // This is a wrapper over more primitive functions for setting signature.
// Signatures let us decide whether the Hook order has changed on refresh.

@@ -530,7 +492,8 @@ //

// );
function createSignatureFunctionForTransform() {
{
var call = 0;
var savedType = void 0;
var hasCustomHooks = void 0;
var savedType;
var hasCustomHooks;
return function (type, key, forceReset, getCustomHooks) {

@@ -543,2 +506,3 @@ switch (call++) {

break;
case 1:

@@ -548,4 +512,6 @@ if (hasCustomHooks) {

}
break;
}
return type;

@@ -555,3 +521,2 @@ };

}
function isLikelyComponentType(type) {

@@ -568,19 +533,24 @@ {

}
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
} // eslint-disable-next-line no-proto
if (type.prototype.__proto__ !== Object.prototype) {
// It has a superclass.
return false;
}
// Pass through.
} // Pass through.
// This looks like a regular function with empty prototype.
}
// For plain functions and arrows, use name as a heuristic.
} // 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':

@@ -594,2 +564,3 @@ {

return true;
default:

@@ -599,4 +570,6 @@ return false;

}
return false;
}
default:

@@ -626,2 +599,4 @@ {

// This is hacky but makes it work with both Rollup and Jest.
var runtime = ReactFreshRuntime.default || ReactFreshRuntime;

@@ -628,0 +603,0 @@

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

/** @license React v0.0.0-375616788
/** @license React v0.0.0-3694a3b5e
* react-refresh-runtime.production.min.js

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

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

],
"version": "0.0.0-375616788",
"version": "0.0.0-3694a3b5e",
"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