react-refresh 0.9.0-rc.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- /** @license React v0.9.0-rc.0
1
+ /** @license React vundefined
2
2
  * react-refresh-babel.development.js
3
3
  *
4
4
  * Copyright (c) Facebook, Inc. and its affiliates.
@@ -16,9 +16,9 @@ if (process.env.NODE_ENV !== "production") {
16
16
  function ReactFreshBabelPlugin (babel) {
17
17
  var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
18
18
 
19
- if (typeof babel.getEnv === 'function') {
19
+ if (typeof babel.env === 'function') {
20
20
  // Only available in Babel 7.
21
- var env = babel.getEnv();
21
+ var env = babel.env();
22
22
 
23
23
  if (env !== 'development' && !opts.skipEnvCheck) {
24
24
  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.');
@@ -264,8 +264,8 @@ function ReactFreshBabelPlugin (babel) {
264
264
  case 'React.useRef':
265
265
  case 'useContext':
266
266
  case 'React.useContext':
267
- case 'useImperativeMethods':
268
- case 'React.useImperativeMethods':
267
+ case 'useImperativeHandle':
268
+ case 'React.useImperativeHandle':
269
269
  case 'useDebugValue':
270
270
  case 'React.useDebugValue':
271
271
  return true;
@@ -376,6 +376,38 @@ function ReactFreshBabelPlugin (babel) {
376
376
  return args;
377
377
  }
378
378
 
379
+ function findHOCCallPathsAbove(path) {
380
+ var calls = [];
381
+
382
+ while (true) {
383
+ if (!path) {
384
+ return calls;
385
+ }
386
+
387
+ var parentPath = path.parentPath;
388
+
389
+ if (!parentPath) {
390
+ return calls;
391
+ }
392
+
393
+ if ( // hoc(_c = function() { })
394
+ parentPath.node.type === 'AssignmentExpression' && path.node === parentPath.node.right) {
395
+ // Ignore registrations.
396
+ path = parentPath;
397
+ continue;
398
+ }
399
+
400
+ if ( // hoc1(hoc2(...))
401
+ parentPath.node.type === 'CallExpression' && path.node !== parentPath.node.callee) {
402
+ calls.push(parentPath);
403
+ path = parentPath;
404
+ continue;
405
+ }
406
+
407
+ return calls; // Stop at other types.
408
+ }
409
+ }
410
+
379
411
  var seenForRegistration = new WeakSet();
380
412
  var seenForSignature = new WeakSet();
381
413
  var seenForOutro = new WeakSet();
@@ -641,7 +673,10 @@ function ReactFreshBabelPlugin (babel) {
641
673
  insertAfterPath.insertAfter(t.expressionStatement(t.callExpression(sigCallID, createArgumentsForSignature(path.parent.id, signature, insertAfterPath.scope)))); // Result: let Foo = () => {}; __signature(Foo, ...);
642
674
  } else {
643
675
  // let Foo = hoc(() => {})
644
- path.replaceWith(t.callExpression(sigCallID, createArgumentsForSignature(node, signature, path.scope))); // Result: let Foo = hoc(__signature(() => {}, ...))
676
+ var paths = [path].concat(findHOCCallPathsAbove(path));
677
+ paths.forEach(function (p) {
678
+ p.replaceWith(t.callExpression(sigCallID, createArgumentsForSignature(p.node, signature, p.scope)));
679
+ }); // Result: let Foo = __signature(hoc(__signature(() => {}, ...)), ...)
645
680
  }
646
681
  }
647
682
  },
@@ -1,4 +1,4 @@
1
- /** @license React v0.9.0-rc.0
1
+ /** @license React vundefined
2
2
  * react-refresh-babel.production.min.js
3
3
  *
4
4
  * Copyright (c) Facebook, Inc. and its affiliates.
@@ -6,16 +6,17 @@
6
6
  * This source code is licensed under the MIT license found in the
7
7
  * LICENSE file in the root directory of this source tree.
8
8
  */
9
- '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,
10
- 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")||
11
- 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=
12
- !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=
13
- !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)?
14
- 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.getEnv){var y=r.getEnv();if("development"!==y&&!p.skipEnvCheck)throw Error('React Refresh Babel transform should only be enabled in development environment. Instead, the environment is: "'+
15
- 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;
16
- 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,
17
- 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)))})))},
18
- 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=
19
- 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,
20
- 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"===
21
- 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))})}}}}}}};
9
+ '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,
10
+ 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")||
11
+ 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=
12
+ !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=
13
+ !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)?
14
+ 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"===
15
+ 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||
16
+ "$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+=
17
+ "("+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=
18
+ 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,
19
+ [])});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&&
20
+ (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;
21
+ 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("=",
22
+ 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,4 +1,4 @@
1
- /** @license React v0.9.0-rc.0
1
+ /** @license React vundefined
2
2
  * react-refresh-runtime.development.js
3
3
  *
4
4
  * Copyright (c) Facebook, Inc. and its affiliates.
@@ -30,14 +30,12 @@ var REACT_SUSPENSE_TYPE = 0xead1;
30
30
  var REACT_SUSPENSE_LIST_TYPE = 0xead8;
31
31
  var REACT_MEMO_TYPE = 0xead3;
32
32
  var REACT_LAZY_TYPE = 0xead4;
33
- var REACT_BLOCK_TYPE = 0xead9;
34
- var REACT_SERVER_BLOCK_TYPE = 0xeada;
35
- var REACT_FUNDAMENTAL_TYPE = 0xead5;
36
33
  var REACT_SCOPE_TYPE = 0xead7;
37
34
  var REACT_OPAQUE_ID_TYPE = 0xeae0;
38
35
  var REACT_DEBUG_TRACING_MODE_TYPE = 0xeae1;
39
36
  var REACT_OFFSCREEN_TYPE = 0xeae2;
40
37
  var REACT_LEGACY_HIDDEN_TYPE = 0xeae3;
38
+ var REACT_CACHE_TYPE = 0xeae4;
41
39
 
42
40
  if (typeof Symbol === 'function' && Symbol.for) {
43
41
  var symbolFor = Symbol.for;
@@ -53,14 +51,12 @@ if (typeof Symbol === 'function' && Symbol.for) {
53
51
  REACT_SUSPENSE_LIST_TYPE = symbolFor('react.suspense_list');
54
52
  REACT_MEMO_TYPE = symbolFor('react.memo');
55
53
  REACT_LAZY_TYPE = symbolFor('react.lazy');
56
- REACT_BLOCK_TYPE = symbolFor('react.block');
57
- REACT_SERVER_BLOCK_TYPE = symbolFor('react.server.block');
58
- REACT_FUNDAMENTAL_TYPE = symbolFor('react.fundamental');
59
54
  REACT_SCOPE_TYPE = symbolFor('react.scope');
60
55
  REACT_OPAQUE_ID_TYPE = symbolFor('react.opaque.id');
61
56
  REACT_DEBUG_TRACING_MODE_TYPE = symbolFor('react.debug_trace_mode');
62
57
  REACT_OFFSCREEN_TYPE = symbolFor('react.offscreen');
63
58
  REACT_LEGACY_HIDDEN_TYPE = symbolFor('react.legacy_hidden');
59
+ REACT_CACHE_TYPE = symbolFor('react.cache');
64
60
  }
65
61
 
66
62
  var PossiblyWeakMap = typeof WeakMap === 'function' ? WeakMap : Map; // We never remove these associations.
@@ -200,6 +196,16 @@ function cloneSet(set) {
200
196
  clone.add(value);
201
197
  });
202
198
  return clone;
199
+ } // This is a safety mechanism to protect against rogue getters and Proxies.
200
+
201
+
202
+ function getProperty(object, property) {
203
+ try {
204
+ return object[property];
205
+ } catch (err) {
206
+ // Intentionally ignore.
207
+ return undefined;
208
+ }
203
209
  }
204
210
 
205
211
  function performReactRefresh() {
@@ -350,7 +356,7 @@ function register(type, id) {
350
356
  allFamiliesByType.set(type, family); // Visit inner types because we might not have registered them.
351
357
 
352
358
  if (typeof type === 'object' && type !== null) {
353
- switch (type.$$typeof) {
359
+ switch (getProperty(type, '$$typeof')) {
354
360
  case REACT_FORWARD_REF_TYPE:
355
361
  register(type.render, id + '$render');
356
362
  break;
@@ -367,14 +373,29 @@ function setSignature(type, key) {
367
373
  var getCustomHooks = arguments.length > 3 ? arguments[3] : undefined;
368
374
 
369
375
  {
370
- allSignaturesByType.set(type, {
371
- forceReset: forceReset,
372
- ownKey: key,
373
- fullKey: null,
374
- getCustomHooks: getCustomHooks || function () {
375
- return [];
376
+ if (!allSignaturesByType.has(type)) {
377
+ allSignaturesByType.set(type, {
378
+ forceReset: forceReset,
379
+ ownKey: key,
380
+ fullKey: null,
381
+ getCustomHooks: getCustomHooks || function () {
382
+ return [];
383
+ }
384
+ });
385
+ } // Visit inner types because we might not have signed them.
386
+
387
+
388
+ if (typeof type === 'object' && type !== null) {
389
+ switch (getProperty(type, '$$typeof')) {
390
+ case REACT_FORWARD_REF_TYPE:
391
+ setSignature(type.render, key, forceReset, getCustomHooks);
392
+ break;
393
+
394
+ case REACT_MEMO_TYPE:
395
+ setSignature(type.type, key, forceReset, getCustomHooks);
396
+ break;
376
397
  }
377
- });
398
+ }
378
399
  }
379
400
  } // This is lazily called during first render for a type.
380
401
  // It captures Hook list at that time so inline requires don't break comparisons.
@@ -439,6 +460,14 @@ function injectIntoGlobalHook(globalObject) {
439
460
  onCommitFiberRoot: function (id, root, maybePriorityLevel, didError) {},
440
461
  onCommitFiberUnmount: function () {}
441
462
  };
463
+ }
464
+
465
+ if (hook.isDisabled) {
466
+ // This isn't a real property on the hook, but it can be set to opt out
467
+ // of DevTools integration and associated warnings and logs.
468
+ // Using console['warn'] to evade Babel and ESLint
469
+ 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.');
470
+ return;
442
471
  } // Here, we just want to get a reference to scheduleRefresh.
443
472
 
444
473
 
@@ -486,44 +515,43 @@ function injectIntoGlobalHook(globalObject) {
486
515
  hook.onCommitFiberRoot = function (id, root, maybePriorityLevel, didError) {
487
516
  var helpers = helpersByRendererID.get(id);
488
517
 
489
- if (helpers === undefined) {
490
- return;
491
- }
492
-
493
- helpersByRoot.set(root, helpers);
494
- var current = root.current;
495
- var alternate = current.alternate; // We need to determine whether this root has just (un)mounted.
496
- // This logic is copy-pasted from similar logic in the DevTools backend.
497
- // If this breaks with some refactoring, you'll want to update DevTools too.
498
-
499
- if (alternate !== null) {
500
- var wasMounted = alternate.memoizedState != null && alternate.memoizedState.element != null;
501
- var isMounted = current.memoizedState != null && current.memoizedState.element != null;
502
-
503
- if (!wasMounted && isMounted) {
518
+ if (helpers !== undefined) {
519
+ helpersByRoot.set(root, helpers);
520
+ var current = root.current;
521
+ var alternate = current.alternate; // We need to determine whether this root has just (un)mounted.
522
+ // This logic is copy-pasted from similar logic in the DevTools backend.
523
+ // If this breaks with some refactoring, you'll want to update DevTools too.
524
+
525
+ if (alternate !== null) {
526
+ var wasMounted = alternate.memoizedState != null && alternate.memoizedState.element != null;
527
+ var isMounted = current.memoizedState != null && current.memoizedState.element != null;
528
+
529
+ if (!wasMounted && isMounted) {
530
+ // Mount a new root.
531
+ mountedRoots.add(root);
532
+ failedRoots.delete(root);
533
+ } else if (wasMounted && isMounted) ; else if (wasMounted && !isMounted) {
534
+ // Unmount an existing root.
535
+ mountedRoots.delete(root);
536
+
537
+ if (didError) {
538
+ // We'll remount it on future edits.
539
+ failedRoots.add(root);
540
+ } else {
541
+ helpersByRoot.delete(root);
542
+ }
543
+ } else if (!wasMounted && !isMounted) {
544
+ if (didError) {
545
+ // We'll remount it on future edits.
546
+ failedRoots.add(root);
547
+ }
548
+ }
549
+ } else {
504
550
  // Mount a new root.
505
551
  mountedRoots.add(root);
506
- failedRoots.delete(root);
507
- } else if (wasMounted && isMounted) ; else if (wasMounted && !isMounted) {
508
- // Unmount an existing root.
509
- mountedRoots.delete(root);
510
-
511
- if (didError) {
512
- // We'll remount it on future edits.
513
- failedRoots.add(root);
514
- } else {
515
- helpersByRoot.delete(root);
516
- }
517
- } else if (!wasMounted && !isMounted) {
518
- if (didError) {
519
- // We'll remount it on future edits.
520
- failedRoots.add(root);
521
- }
522
552
  }
523
- } else {
524
- // Mount a new root.
525
- mountedRoots.add(root);
526
- }
553
+ } // Always call the decorated DevTools hook.
554
+
527
555
 
528
556
  return oldOnCommitFiberRoot.apply(this, arguments);
529
557
  };
@@ -547,14 +575,14 @@ function _getMountedRootCount() {
547
575
  // function Hello() {
548
576
  // const [foo, setFoo] = useState(0);
549
577
  // const value = useCustomHook();
550
- // _s(); /* Second call triggers collecting the custom Hook list.
578
+ // _s(); /* Call without arguments triggers collecting the custom Hook list.
551
579
  // * This doesn't happen during the module evaluation because we
552
580
  // * don't want to change the module order with inline requires.
553
581
  // * Next calls are noops. */
554
582
  // return <h1>Hi</h1>;
555
583
  // }
556
584
  //
557
- // /* First call specifies the signature: */
585
+ // /* Call with arguments attaches the signature to the type: */
558
586
  // _s(
559
587
  // Hello,
560
588
  // 'useState{[foo, setFoo]}(0)',
@@ -563,37 +591,37 @@ function _getMountedRootCount() {
563
591
 
564
592
  function createSignatureFunctionForTransform() {
565
593
  {
566
- // We'll fill in the signature in two steps.
567
- // First, we'll know the signature itself. This happens outside the component.
568
- // Then, we'll know the references to custom Hooks. This happens inside the component.
569
- // After that, the returned function will be a fast path no-op.
570
- var status = 'needsSignature';
571
594
  var savedType;
572
595
  var hasCustomHooks;
596
+ var didCollectHooks = false;
573
597
  return function (type, key, forceReset, getCustomHooks) {
574
- switch (status) {
575
- case 'needsSignature':
576
- if (type !== undefined) {
577
- // If we received an argument, this is the initial registration call.
578
- savedType = type;
579
- hasCustomHooks = typeof getCustomHooks === 'function';
580
- setSignature(type, key, forceReset, getCustomHooks); // The next call we expect is from inside a function, to fill in the custom Hooks.
581
-
582
- status = 'needsCustomHooks';
583
- }
584
-
585
- break;
586
-
587
- case 'needsCustomHooks':
588
- if (hasCustomHooks) {
589
- collectCustomHooksForSignature(savedType);
590
- }
598
+ if (typeof key === 'string') {
599
+ // We're in the initial phase that associates signatures
600
+ // with the functions. Note this may be called multiple times
601
+ // in HOC chains like _s(hoc1(_s(hoc2(_s(actualFunction))))).
602
+ if (!savedType) {
603
+ // We're in the innermost call, so this is the actual type.
604
+ savedType = type;
605
+ hasCustomHooks = typeof getCustomHooks === 'function';
606
+ } // Set the signature for all types (even wrappers!) in case
607
+ // they have no signatures of their own. This is to prevent
608
+ // problems like https://github.com/facebook/react/issues/20417.
609
+
610
+
611
+ if (type != null && (typeof type === 'function' || typeof type === 'object')) {
612
+ setSignature(type, key, forceReset, getCustomHooks);
613
+ }
591
614
 
592
- status = 'resolved';
593
- break;
615
+ return type;
616
+ } else {
617
+ // We're in the _s() call without arguments, which means
618
+ // this is the time to collect custom Hook signatures.
619
+ // Only do this once. This path is hot and runs *inside* every render!
620
+ if (!didCollectHooks && hasCustomHooks) {
621
+ didCollectHooks = true;
622
+ collectCustomHooksForSignature(savedType);
623
+ }
594
624
  }
595
-
596
- return type;
597
625
  };
598
626
  }
599
627
  }
@@ -633,7 +661,7 @@ function isLikelyComponentType(type) {
633
661
  case 'object':
634
662
  {
635
663
  if (type != null) {
636
- switch (type.$$typeof) {
664
+ switch (getProperty(type, '$$typeof')) {
637
665
  case REACT_FORWARD_REF_TYPE:
638
666
  case REACT_MEMO_TYPE:
639
667
  // Definitely React components.
@@ -1,4 +1,4 @@
1
- /** @license React v0.9.0-rc.0
1
+ /** @license React vundefined
2
2
  * react-refresh-runtime.production.min.js
3
3
  *
4
4
  * Copyright (c) Facebook, Inc. and its affiliates.
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "keywords": [
5
5
  "react"
6
6
  ],
7
- "version": "0.9.0-rc.0",
7
+ "version": "0.10.0",
8
8
  "homepage": "https://reactjs.org/",
9
9
  "bugs": "https://github.com/facebook/react/issues",
10
10
  "license": "MIT",
@@ -25,5 +25,9 @@
25
25
  },
26
26
  "engines": {
27
27
  "node": ">=0.10.0"
28
+ },
29
+ "devDependencies": {
30
+ "react-16-8": "npm:react@16.8.0",
31
+ "react-dom-16-8": "npm:react-dom@16.8.0"
28
32
  }
29
- }
33
+ }
package/build-info.json DELETED
@@ -1,8 +0,0 @@
1
- {
2
- "branch": "master",
3
- "buildNumber": "193044",
4
- "checksum": "38fb0e9",
5
- "commit": "94c0244ba",
6
- "environment": "ci",
7
- "reactVersion": "17.0.0-alpha.0-94c0244ba"
8
- }