react-refresh
Advanced tools
Comparing version 0.0.0-experimental-4ead6b530 to 0.0.0-experimental-5027eb465
@@ -1,2 +0,2 @@ | ||
/** @license React v0.0.0-experimental-4ead6b530 | ||
/** @license React vundefined | ||
* react-refresh-babel.development.js | ||
@@ -267,4 +267,4 @@ * | ||
case 'React.useContext': | ||
case 'useImperativeMethods': | ||
case 'React.useImperativeMethods': | ||
case 'useImperativeHandle': | ||
case 'React.useImperativeHandle': | ||
case 'useDebugValue': | ||
@@ -380,2 +380,34 @@ case 'React.useDebugValue': | ||
function findHOCCallPathsAbove(path) { | ||
var calls = []; | ||
while (true) { | ||
if (!path) { | ||
return calls; | ||
} | ||
var parentPath = path.parentPath; | ||
if (!parentPath) { | ||
return calls; | ||
} | ||
if ( // hoc(_c = function() { }) | ||
parentPath.node.type === 'AssignmentExpression' && path.node === parentPath.node.right) { | ||
// Ignore registrations. | ||
path = parentPath; | ||
continue; | ||
} | ||
if ( // hoc1(hoc2(...)) | ||
parentPath.node.type === 'CallExpression' && path.node !== parentPath.node.callee) { | ||
calls.push(parentPath); | ||
path = parentPath; | ||
continue; | ||
} | ||
return calls; // Stop at other types. | ||
} | ||
} | ||
var seenForRegistration = new WeakSet(); | ||
@@ -646,3 +678,6 @@ var seenForSignature = new WeakSet(); | ||
// let Foo = hoc(() => {}) | ||
path.replaceWith(t.callExpression(sigCallID, createArgumentsForSignature(node, signature, path.scope))); // Result: let Foo = hoc(__signature(() => {}, ...)) | ||
var paths = [path].concat(findHOCCallPathsAbove(path)); | ||
paths.forEach(function (p) { | ||
p.replaceWith(t.callExpression(sigCallID, createArgumentsForSignature(p.node, signature, p.scope))); | ||
}); // Result: let Foo = __signature(hoc(__signature(() => {}, ...)), ...) | ||
} | ||
@@ -649,0 +684,0 @@ } |
@@ -1,2 +0,2 @@ | ||
/** @license React v0.0.0-experimental-4ead6b530 | ||
/** @license React vundefined | ||
* react-refresh-babel.production.min.js | ||
@@ -9,14 +9,15 @@ * | ||
*/ | ||
'use strict';module.exports=function(r){function t(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 u(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(!u(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 f=b.get("arguments");if(void 0===f||0===f.length)break;var g=b.get("callee");switch(g.node.type){case "MemberExpression":case "Identifier":g=g.getSource();if(!m(a+"$"+g,f[0],d))return!1;d(a,c,b);return!0;default:return!1}case "VariableDeclarator":if(f=c.init,null!==f&&(g=c.id.name,u(g))){switch(f.type){case "ArrowFunctionExpression":case "FunctionExpression":break;case "CallExpression":c=f.callee;var e=c.type;if("Import"===e||"Identifier"===e&&(0===c.name.indexOf("require")|| | ||
0===c.name.indexOf("import")))return!1;break;case "TaggedTemplateExpression":break;default:return!1}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(e=0;e<g.length;e++){var h=g[e];if(!h.node||"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,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 B(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 v(a,b,d){var c=b.key;b=b.customHooks;var f=B(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||p.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 p=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};if("function"===typeof r.env){var y=r.env();if("development"!==y&&!p.skipEnvCheck)throw Error('React Refresh Babel transform should only be enabled in development environment. Instead, the environment is: "'+ | ||
y+'". If you want to override this check, pass {skipEnvCheck: true} as plugin options.');}var e=r.types,C=e.identifier(p.refreshReg||"$RefreshReg$"),z=e.identifier(p.refreshSig||"$RefreshSig$"),l=new Map,x=new WeakMap,k=new WeakSet,q=new WeakSet,A=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=t(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,u(f)&&!k.has(b)&&(k.add(b),m(f,a,function(a,b){a=t(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&&!q.has(b)){q.add(b);b=a.scope.generateUidIdentifier("_s");a.scope.parent.push({id:b,init:e.callExpression(z,[])});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,v(d,c,f.scope))))}}}},"ArrowFunctionExpression|FunctionExpression":{exit:function(a){var b= | ||
a.node,d=w(b);if(null!==d&&!q.has(b)){q.add(b);var c=a.scope.generateUidIdentifier("_s");a.scope.parent.push({id:c,init:e.callExpression(z,[])});"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, | ||
v(a.parent.id,d,f.scope))))}else a.replaceWith(e.callExpression(c,v(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=t(c,a),"VariableDeclarator"=== | ||
h.parent.type?d.insertAfter(e.expressionStatement(e.assignmentExpression("=",a,f.node.id))):h.replaceWith(e.assignmentExpression("=",a,b)))})}},Program:{enter:function(a){a.traverse(D)},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;a.pushContainer("body",e.expressionStatement(e.callExpression(C,[d,e.stringLiteral(b.persistentID)])));c.push(e.variableDeclarator(d))})}}}}}}}; | ||
'use strict';module.exports=function(r){function t(a,b){var c=a.scope.generateUidIdentifier("c");l.has(a)||l.set(a,[]);l.get(a).push({handle:c,persistentID:b});return c}function u(a){return"string"===typeof a&&"A"<=a[0]&&"Z">=a[0]}function m(a,b,c){var d=b.node;switch(d.type){case "Identifier":if(!u(d.name))break;c(a,d,null);return!0;case "FunctionDeclaration":return c(a,d.id,null),!0;case "ArrowFunctionExpression":if("ArrowFunctionExpression"===d.body.type)break;c(a,d,b);return!0;case "FunctionExpression":return c(a, | ||
d,b),!0;case "CallExpression":var f=b.get("arguments");if(void 0===f||0===f.length)break;var g=b.get("callee");switch(g.node.type){case "MemberExpression":case "Identifier":g=g.getSource();if(!m(a+"$"+g,f[0],c))return!1;c(a,d,b);return!0;default:return!1}case "VariableDeclarator":if(f=d.init,null!==f&&(g=d.id.name,u(g))){switch(f.type){case "ArrowFunctionExpression":case "FunctionExpression":break;case "CallExpression":d=f.callee;var e=d.type;if("Import"===e||"Identifier"===e&&(0===d.name.indexOf("require")|| | ||
0===d.name.indexOf("import")))return!1;break;case "TaggedTemplateExpression":break;default:return!1}d=b.get("init");if(m(a,d,c))return!0;g=b.scope.getBinding(g);if(void 0===g)return;b=!1;g=g.referencePaths;for(e=0;e<g.length;e++){var h=g[e];if(!h.node||"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 c(a,f,d),!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 "useImperativeHandle":case "React.useImperativeHandle":case "useDebugValue":case "React.useDebugValue":a= | ||
!0;break a;default:a=!1}return!a}).map(function(a){return e.cloneDeep(a.callee)})}}function B(a){a=a.hub.file;var b=x.get(a);if(void 0!==b)return b;b=!1;for(var c=a.ast.comments,d=0;d<c.length;d++)if(-1!==c[d].value.indexOf("@refresh reset")){b=!0;break}x.set(a,b);return b}function v(a,b,c){var d=b.key;b=b.customHooks;var f=B(c.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}c.hasBinding(b)? | ||
g.push(a):f=!0});b=d;"function"!==typeof require||p.emitFullSignatures||(b=require("crypto").createHash("sha1").update(d).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}function C(a){for(var b=[];;){if(!a)return b;var c=a.parentPath;if(!c)return b;if("AssignmentExpression"===c.node.type&&a.node===c.node.right)a=c;else if("CallExpression"=== | ||
c.node.type&&a.node!==c.node.callee)b.push(c),a=c;else return b}}var p=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};if("function"===typeof r.env){var y=r.env();if("development"!==y&&!p.skipEnvCheck)throw Error('React Refresh Babel transform should only be enabled in development environment. Instead, the environment is: "'+y+'". If you want to override this check, pass {skipEnvCheck: true} as plugin options.');}var e=r.types,D=e.identifier(p.refreshReg||"$RefreshReg$"),z=e.identifier(p.refreshSig|| | ||
"$RefreshSig$"),l=new Map,x=new WeakMap,k=new WeakSet,q=new WeakSet,A=new WeakSet,n=new WeakMap,E={CallExpression:function(a){var b=a.node.callee,c=null;switch(b.type){case "Identifier":c=b.name;break;case "MemberExpression":c=b.property.name}if(null!==c&&/^use[A-Z]/.test(c)&&(b=a.scope.getFunctionParent(),null!==b)){b=b.block;n.has(b)||n.set(b,[]);b=n.get(b);var d="";"VariableDeclarator"===a.parent.type&&(d=a.parentPath.get("id").getSource());var f=a.get("arguments");"useState"===c&&0<f.length?d+= | ||
"("+f[0].getSource()+")":"useReducer"===c&&1<f.length&&(d+="("+f[1].getSource()+")");b.push({callee:a.node.callee,name:c,key:d})}}};return{visitor:{ExportDefaultDeclaration:function(a){var b=a.node,c=b.declaration,d=a.get("declaration");if("CallExpression"===c.type&&!k.has(b)){k.add(b);var f=a.parentPath;m("%default%",d,function(a,b,c){null!==c&&(a=t(f,a),c.replaceWith(e.assignmentExpression("=",a,b)))})}},FunctionDeclaration:{enter:function(a){var b=a.node;switch(a.parent.type){case "Program":var c= | ||
a;var 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,u(f)&&!k.has(b)&&(k.add(b),m(f,a,function(a,b){a=t(d,a);c.insertAfter(e.expressionStatement(e.assignmentExpression("=",a,b)))})))},exit:function(a){var b=a.node,c=b.id;if(null!==c){var d=w(b);if(null!==d&&!q.has(b)){q.add(b);b=a.scope.generateUidIdentifier("_s");a.scope.parent.push({id:b,init:e.callExpression(z, | ||
[])});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,v(c,d,f.scope))))}}}},"ArrowFunctionExpression|FunctionExpression":{exit:function(a){var b=a.node,c=w(b);if(null!==c&&!q.has(b)){q.add(b);var d=a.scope.generateUidIdentifier("_s");a.scope.parent.push({id:d,init:e.callExpression(z,[])});"BlockStatement"!==a.node.body.type&& | ||
(a.node.body=e.blockStatement([e.returnStatement(a.node.body)]));a.get("body").unshiftContainer("body",e.expressionStatement(e.callExpression(d,[])));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(d,v(a.parent.id,c,f.scope))))}else[a].concat(C(a)).forEach(function(a){a.replaceWith(e.callExpression(d,v(a.node,c,a.scope)))})}}},VariableDeclaration:function(a){var b=a.node; | ||
switch(a.parent.type){case "Program":var c=a;var 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=t(d,a),"VariableDeclarator"===h.parent.type?c.insertAfter(e.expressionStatement(e.assignmentExpression("=",a,f.node.id))):h.replaceWith(e.assignmentExpression("=", | ||
a,b)))})}},Program:{enter:function(a){a.traverse(E)},exit:function(a){var b=l.get(a);if(void 0!==b){var c=a.node;if(!A.has(c)){A.add(c);l.delete(a);var d=[];a.pushContainer("body",e.variableDeclaration("var",d));b.forEach(function(b){var c=b.handle;a.pushContainer("body",e.expressionStatement(e.callExpression(D,[c,e.stringLiteral(b.persistentID)])));d.push(e.variableDeclarator(c))})}}}}}}}; |
@@ -1,2 +0,2 @@ | ||
/** @license React v0.0.0-experimental-4ead6b530 | ||
/** @license React vundefined | ||
* react-refresh-runtime.development.js | ||
@@ -33,5 +33,2 @@ * | ||
var REACT_LAZY_TYPE = 0xead4; | ||
var REACT_BLOCK_TYPE = 0xead9; | ||
var REACT_SERVER_BLOCK_TYPE = 0xeada; | ||
var REACT_FUNDAMENTAL_TYPE = 0xead5; | ||
var REACT_SCOPE_TYPE = 0xead7; | ||
@@ -42,2 +39,3 @@ var REACT_OPAQUE_ID_TYPE = 0xeae0; | ||
var REACT_LEGACY_HIDDEN_TYPE = 0xeae3; | ||
var REACT_CACHE_TYPE = 0xeae4; | ||
@@ -58,5 +56,2 @@ if (typeof Symbol === 'function' && Symbol.for) { | ||
REACT_LAZY_TYPE = symbolFor('react.lazy'); | ||
REACT_BLOCK_TYPE = symbolFor('react.block'); | ||
REACT_SERVER_BLOCK_TYPE = symbolFor('react.server.block'); | ||
REACT_FUNDAMENTAL_TYPE = symbolFor('react.fundamental'); | ||
REACT_SCOPE_TYPE = symbolFor('react.scope'); | ||
@@ -67,2 +62,3 @@ REACT_OPAQUE_ID_TYPE = symbolFor('react.opaque.id'); | ||
REACT_LEGACY_HIDDEN_TYPE = symbolFor('react.legacy_hidden'); | ||
REACT_CACHE_TYPE = symbolFor('react.cache'); | ||
} | ||
@@ -207,2 +203,12 @@ | ||
return clone; | ||
} // This is a safety mechanism to protect against rogue getters and Proxies. | ||
function getProperty(object, property) { | ||
try { | ||
return object[property]; | ||
} catch (err) { | ||
// Intentionally ignore. | ||
return undefined; | ||
} | ||
} | ||
@@ -358,3 +364,3 @@ | ||
if (typeof type === 'object' && type !== null) { | ||
switch (type.$$typeof) { | ||
switch (getProperty(type, '$$typeof')) { | ||
case REACT_FORWARD_REF_TYPE: | ||
@@ -376,10 +382,25 @@ register(type.render, id + '$render'); | ||
{ | ||
allSignaturesByType.set(type, { | ||
forceReset: forceReset, | ||
ownKey: key, | ||
fullKey: null, | ||
getCustomHooks: getCustomHooks || function () { | ||
return []; | ||
if (!allSignaturesByType.has(type)) { | ||
allSignaturesByType.set(type, { | ||
forceReset: forceReset, | ||
ownKey: key, | ||
fullKey: null, | ||
getCustomHooks: getCustomHooks || function () { | ||
return []; | ||
} | ||
}); | ||
} // Visit inner types because we might not have signed them. | ||
if (typeof type === 'object' && type !== null) { | ||
switch (getProperty(type, '$$typeof')) { | ||
case REACT_FORWARD_REF_TYPE: | ||
setSignature(type.render, key, forceReset, getCustomHooks); | ||
break; | ||
case REACT_MEMO_TYPE: | ||
setSignature(type.type, key, forceReset, getCustomHooks); | ||
break; | ||
} | ||
}); | ||
} | ||
} | ||
@@ -449,2 +470,10 @@ } // This is lazily called during first render for a type. | ||
}; | ||
} | ||
if (hook.isDisabled) { | ||
// This isn't a real property on the hook, but it can be set to opt out | ||
// of DevTools integration and associated warnings and logs. | ||
// Using console['warn'] to evade Babel and ESLint | ||
console['warn']('Something has shimmed the React DevTools global hook (__REACT_DEVTOOLS_GLOBAL_HOOK__). ' + 'Fast Refresh is not compatible with this shim and will be disabled.'); | ||
return; | ||
} // Here, we just want to get a reference to scheduleRefresh. | ||
@@ -497,41 +526,40 @@ | ||
if (helpers === undefined) { | ||
return; | ||
} | ||
if (helpers !== undefined) { | ||
helpersByRoot.set(root, helpers); | ||
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. | ||
helpersByRoot.set(root, helpers); | ||
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. | ||
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) { | ||
// Mount a new root. | ||
mountedRoots.add(root); | ||
failedRoots.delete(root); | ||
} else if (wasMounted && isMounted) ; else if (wasMounted && !isMounted) { | ||
// Unmount an existing root. | ||
mountedRoots.delete(root); | ||
if (!wasMounted && isMounted) { | ||
if (didError) { | ||
// We'll remount it on future edits. | ||
failedRoots.add(root); | ||
} else { | ||
helpersByRoot.delete(root); | ||
} | ||
} else if (!wasMounted && !isMounted) { | ||
if (didError) { | ||
// We'll remount it on future edits. | ||
failedRoots.add(root); | ||
} | ||
} | ||
} else { | ||
// Mount a new root. | ||
mountedRoots.add(root); | ||
failedRoots.delete(root); | ||
} else if (wasMounted && isMounted) ; else if (wasMounted && !isMounted) { | ||
// Unmount an existing root. | ||
mountedRoots.delete(root); | ||
if (didError) { | ||
// We'll remount it on future edits. | ||
failedRoots.add(root); | ||
} else { | ||
helpersByRoot.delete(root); | ||
} | ||
} else if (!wasMounted && !isMounted) { | ||
if (didError) { | ||
// We'll remount it on future edits. | ||
failedRoots.add(root); | ||
} | ||
} | ||
} else { | ||
// Mount a new root. | ||
mountedRoots.add(root); | ||
} | ||
} // Always call the decorated DevTools hook. | ||
return oldOnCommitFiberRoot.apply(this, arguments); | ||
@@ -559,3 +587,3 @@ }; | ||
// const value = useCustomHook(); | ||
// _s(); /* Second call triggers collecting the custom Hook list. | ||
// _s(); /* Call without arguments triggers collecting the custom Hook list. | ||
// * This doesn't happen during the module evaluation because we | ||
@@ -567,3 +595,3 @@ // * don't want to change the module order with inline requires. | ||
// | ||
// /* First call specifies the signature: */ | ||
// /* Call with arguments attaches the signature to the type: */ | ||
// _s( | ||
@@ -577,33 +605,33 @@ // Hello, | ||
{ | ||
// 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; | ||
var didCollectHooks = false; | ||
return function (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. | ||
if (typeof key === 'string') { | ||
// We're in the initial phase that associates signatures | ||
// with the functions. Note this may be called multiple times | ||
// in HOC chains like _s(hoc1(_s(hoc2(_s(actualFunction))))). | ||
if (!savedType) { | ||
// We're in the innermost call, so this is the actual type. | ||
savedType = type; | ||
hasCustomHooks = typeof getCustomHooks === 'function'; | ||
} // Set the signature for all types (even wrappers!) in case | ||
// they have no signatures of their own. This is to prevent | ||
// problems like https://github.com/facebook/react/issues/20417. | ||
status = 'needsCustomHooks'; | ||
} | ||
break; | ||
if (type != null && (typeof type === 'function' || typeof type === 'object')) { | ||
setSignature(type, key, forceReset, getCustomHooks); | ||
} | ||
case 'needsCustomHooks': | ||
if (hasCustomHooks) { | ||
collectCustomHooksForSignature(savedType); | ||
} | ||
status = 'resolved'; | ||
break; | ||
return type; | ||
} else { | ||
// We're in the _s() call without arguments, which means | ||
// this is the time to collect custom Hook signatures. | ||
// Only do this once. This path is hot and runs *inside* every render! | ||
if (!didCollectHooks && hasCustomHooks) { | ||
didCollectHooks = true; | ||
collectCustomHooksForSignature(savedType); | ||
} | ||
} | ||
return type; | ||
}; | ||
@@ -648,3 +676,3 @@ } | ||
if (type != null) { | ||
switch (type.$$typeof) { | ||
switch (getProperty(type, '$$typeof')) { | ||
case REACT_FORWARD_REF_TYPE: | ||
@@ -651,0 +679,0 @@ case REACT_MEMO_TYPE: |
@@ -1,2 +0,2 @@ | ||
/** @license React v0.0.0-experimental-4ead6b530 | ||
/** @license React vundefined | ||
* react-refresh-runtime.production.min.js | ||
@@ -3,0 +3,0 @@ * |
@@ -7,3 +7,3 @@ { | ||
], | ||
"version": "0.0.0-experimental-4ead6b530", | ||
"version": "0.0.0-experimental-5027eb465", | ||
"homepage": "https://reactjs.org/", | ||
@@ -29,3 +29,7 @@ "bugs": "https://github.com/facebook/react/issues", | ||
"node": ">=0.10.0" | ||
}, | ||
"devDependencies": { | ||
"react-16-8": "npm:react@16.8.0", | ||
"react-dom-16-8": "npm:react-dom@16.8.0" | ||
} | ||
} | ||
} |
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
57895
1278
2
9