react-refresh 0.14.0 → 0.15.0-canary-b7972822b-20230503

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.
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) Facebook, Inc. and its affiliates.
3
+ Copyright (c) Meta Platforms, Inc. and affiliates.
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -2,7 +2,7 @@
2
2
  * @license React
3
3
  * react-refresh-babel.development.js
4
4
  *
5
- * Copyright (c) Facebook, Inc. and its affiliates.
5
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
@@ -169,7 +169,7 @@ function ReactFreshBabelPlugin (babel) {
169
169
  } // Neither require nor import. Might be a HOC.
170
170
  // Pass through.
171
171
 
172
- }
172
+ } else ;
173
173
 
174
174
  break;
175
175
  }
@@ -2,23 +2,23 @@
2
2
  * @license React
3
3
  * react-refresh-babel.production.min.js
4
4
  *
5
- * Copyright (c) Facebook, Inc. and its affiliates.
5
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
9
  */
10
- '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,
11
- d,b),!0;case "CallExpression":var e=b.get("arguments");if(void 0===e||0===e.length)break;var g=b.get("callee");switch(g.node.type){case "MemberExpression":case "Identifier":g=g.getSource();if(!m(a+"$"+g,e[0],c))return!1;c(a,d,b);return!0;default:return!1}case "VariableDeclarator":if(e=d.init,null!==e&&(g=d.id.name,u(g))){switch(e.type){case "ArrowFunctionExpression":case "FunctionExpression":break;case "CallExpression":d=e.callee;var f=d.type;if("Import"===f||"Identifier"===f&&(0===d.name.indexOf("require")||
12
- 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(f=0;f<g.length;f++){var h=g[f];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 v=void 0;switch(h.type){case "Identifier":v=h.name;break;case "MemberExpression":v=h.property.name}switch(v){case "createElement":case "jsx":case "jsxDEV":case "jsxs":b=
13
- !0}}if(b)return c(a,e,d),!0}}}}return!1}function x(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=
14
- !0;break a;default:a=!1}return!a}).map(function(a){return f.cloneDeep(a.callee)})}}function C(a){a=a.hub.file;var b=y.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}y.set(a,b);return b}function w(a,b,c){var d=b.key;b=b.customHooks;var e=C(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)?
15
- g.push(a):e=!0});b=d;"function"!==typeof require||p.emitFullSignatures||(b=require("crypto").createHash("sha1").update(d).digest("base64"));a=[a,f.stringLiteral(b)];(e||0<g.length)&&a.push(f.booleanLiteral(e));0<g.length&&a.push(f.functionExpression(null,[],f.blockStatement([f.returnStatement(f.arrayExpression(g))])));return a}function D(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"===
16
- 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 z=r.env();if("development"!==z&&!p.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 f=r.types,E=f.identifier(p.refreshReg||"$RefreshReg$"),A=f.identifier(p.refreshSig||
17
- "$RefreshSig$"),l=new Map,y=new WeakMap,k=new WeakSet,q=new WeakSet,B=new WeakSet,n=new WeakMap,F={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 e=a.get("arguments");"useState"===c&&0<e.length?d+=
18
- "("+e[0].getSource()+")":"useReducer"===c&&1<e.length&&(d+="("+e[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 e=a.parentPath;m("%default%",d,function(a,b,d){null!==d&&(a=t(e,a),d.replaceWith(f.assignmentExpression("=",a,b)))})}},FunctionDeclaration:{enter:function(a){var b=a.node,c="";switch(a.parent.type){case "Program":var d=
19
- a;var e=a.parentPath;break;case "TSModuleBlock":d=a;e=d.parentPath.parentPath;break;case "ExportNamedDeclaration":d=a.parentPath;e=d.parentPath;break;case "ExportDefaultDeclaration":d=a.parentPath;e=d.parentPath;break;default:return}if("TSModuleBlock"===a.parent.type||"ExportNamedDeclaration"===a.parent.type)for(;"Program"!==e.type;){if("TSModuleDeclaration"===e.type){if("Program"!==e.parentPath.type&&"ExportNamedDeclaration"!==e.parentPath.type)return;c=e.node.id.name+"$"+c}e=e.parentPath}var g=
20
- b.id;null!==g&&(g=g.name,u(g)&&!k.has(b)&&(k.add(b),m(c+g,a,function(a,b){a=t(e,a);d.insertAfter(f.expressionStatement(f.assignmentExpression("=",a,b)))})))},exit:function(a){var b=a.node,c=b.id;if(null!==c){var d=x(b);if(null!==d&&!q.has(b)){q.add(b);b=a.scope.generateUidIdentifier("_s");a.scope.parent.push({id:b,init:f.callExpression(A,[])});a.get("body").unshiftContainer("body",f.expressionStatement(f.callExpression(b,[])));var e=null;a.find(function(a){if(a.parentPath.isBlock())return e=a,!0});
21
- null!==e&&e.insertAfter(f.expressionStatement(f.callExpression(b,w(c,d,e.scope))))}}}},"ArrowFunctionExpression|FunctionExpression":{exit:function(a){var b=a.node,c=x(b);if(null!==c&&!q.has(b)){q.add(b);var d=a.scope.generateUidIdentifier("_s");a.scope.parent.push({id:d,init:f.callExpression(A,[])});"BlockStatement"!==a.node.body.type&&(a.node.body=f.blockStatement([f.returnStatement(a.node.body)]));a.get("body").unshiftContainer("body",f.expressionStatement(f.callExpression(d,[])));if("VariableDeclarator"===
22
- a.parent.type){var e=null;a.find(function(a){if(a.parentPath.isBlock())return e=a,!0});null!==e&&e.insertAfter(f.expressionStatement(f.callExpression(d,w(a.parent.id,c,e.scope))))}else[a].concat(D(a)).forEach(function(a){a.replaceWith(f.callExpression(d,w(a.node,c,a.scope)))})}}},VariableDeclaration:function(a){var b=a.node,c="";switch(a.parent.type){case "Program":var d=a;var e=a.parentPath;break;case "TSModuleBlock":d=a;e=d.parentPath.parentPath;break;case "ExportNamedDeclaration":d=a.parentPath;
23
- e=d.parentPath;break;case "ExportDefaultDeclaration":d=a.parentPath;e=d.parentPath;break;default:return}if("TSModuleBlock"===a.parent.type||"ExportNamedDeclaration"===a.parent.type)for(;"Program"!==e.type;){if("TSModuleDeclaration"===e.type){if("Program"!==e.parentPath.type&&"ExportNamedDeclaration"!==e.parentPath.type)return;c=e.node.id.name+"$"+c}e=e.parentPath}if(!k.has(b)&&(k.add(b),a=a.get("declarations"),1===a.length)){var g=a[0];m(c+g.node.id.name,g,function(a,b,c){null!==c&&(a=t(e,a),"VariableDeclarator"===
24
- c.parent.type?d.insertAfter(f.expressionStatement(f.assignmentExpression("=",a,g.node.id))):c.replaceWith(f.assignmentExpression("=",a,b)))})}},Program:{enter:function(a){a.traverse(F)},exit:function(a){var b=l.get(a);if(void 0!==b){var c=a.node;if(!B.has(c)){B.add(c);l.delete(a);var d=[];a.pushContainer("body",f.variableDeclaration("var",d));b.forEach(function(b){var c=b.handle;a.pushContainer("body",f.expressionStatement(f.callExpression(E,[c,f.stringLiteral(b.persistentID)])));d.push(f.variableDeclarator(c))})}}}}}}};
10
+ 'use strict';module.exports=function(u){function v(a,b){var e=a.scope.generateUidIdentifier("c");n.has(a)||n.set(a,[]);n.get(a).push({handle:e,persistentID:b});return e}function w(a){return"string"===typeof a&&"A"<=a[0]&&"Z">=a[0]}function p(a,b,e){var c=b.node;switch(c.type){case "Identifier":if(!w(c.name))break;e(a,c,null);return!0;case "FunctionDeclaration":return e(a,c.id,null),!0;case "ArrowFunctionExpression":if("ArrowFunctionExpression"===c.body.type)break;e(a,c,b);return!0;case "FunctionExpression":return e(a,
11
+ c,b),!0;case "CallExpression":var d=b.get("arguments");if(void 0===d||0===d.length)break;var f=b.get("callee");switch(f.node.type){case "MemberExpression":case "Identifier":f=f.getSource();if(!p(a+"$"+f,d[0],e))return!1;e(a,c,b);return!0;default:return!1}case "VariableDeclarator":if(d=c.init,null!==d&&(f=c.id.name,w(f))){switch(d.type){case "ArrowFunctionExpression":case "FunctionExpression":break;case "CallExpression":c=d.callee;var h=c.type;if("Import"===h||"Identifier"===h&&(0===c.name.indexOf("require")||
12
+ 0===c.name.indexOf("import")))return!1;break;case "TaggedTemplateExpression":break;default:return!1}c=b.get("init");if(p(a,c,e))return!0;f=b.scope.getBinding(f);if(void 0===f)return;b=!1;f=f.referencePaths;for(h=0;h<f.length;h++){var k=f[h];if(!k.node||"JSXIdentifier"===k.node.type||"Identifier"===k.node.type){k=k.parent;if("JSXOpeningElement"===k.type)b=!0;else if("CallExpression"===k.type){k=k.callee;var l=void 0;switch(k.type){case "Identifier":l=k.name;break;case "MemberExpression":l=k.property.name}switch(l){case "createElement":case "jsx":case "jsxDEV":case "jsxs":b=
13
+ !0}}if(b)return e(a,d,c),!0}}}}return!1}function y(a){a=q.get(a);return void 0===a?null:{key:a.map(function(b){return b.name+"{"+b.key+"}"}).join("\n"),customHooks:a.filter(function(b){a:switch(b.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":b=
14
+ !0;break a;default:b=!1}return!b}).map(function(b){return g.cloneDeep(b.callee)})}}function D(a){a=a.hub.file;var b=z.get(a);if(void 0!==b)return b;b=!1;for(var e=a.ast.comments,c=0;c<e.length;c++)if(-1!==e[c].value.indexOf("@refresh reset")){b=!0;break}z.set(a,b);return b}function x(a,b,e){var c=b.key;b=b.customHooks;var d=D(e.path),f=[];b.forEach(function(h){switch(h.type){case "MemberExpression":if("Identifier"===h.object.type)var k=h.object.name;break;case "Identifier":k=h.name}e.hasBinding(k)?
15
+ f.push(h):d=!0});b=c;"function"!==typeof require||r.emitFullSignatures||(b=require("crypto").createHash("sha1").update(c).digest("base64"));a=[a,g.stringLiteral(b)];(d||0<f.length)&&a.push(g.booleanLiteral(d));0<f.length&&a.push(g.functionExpression(null,[],g.blockStatement([g.returnStatement(g.arrayExpression(f))])));return a}function E(a){for(var b=[];;){if(!a)return b;var e=a.parentPath;if(!e)return b;if("AssignmentExpression"===e.node.type&&a.node===e.node.right)a=e;else if("CallExpression"===
16
+ e.node.type&&a.node!==e.node.callee)b.push(e),a=e;else return b}}var r=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};if("function"===typeof u.env){var A=u.env();if("development"!==A&&!r.skipEnvCheck)throw Error('React Refresh Babel transform should only be enabled in development environment. Instead, the environment is: "'+A+'". If you want to override this check, pass {skipEnvCheck: true} as plugin options.');}var g=u.types,F=g.identifier(r.refreshReg||"$RefreshReg$"),B=g.identifier(r.refreshSig||
17
+ "$RefreshSig$"),n=new Map,z=new WeakMap,m=new WeakSet,t=new WeakSet,C=new WeakSet,q=new WeakMap,G={CallExpression:function(a){var b=a.node.callee,e=null;switch(b.type){case "Identifier":e=b.name;break;case "MemberExpression":e=b.property.name}if(null!==e&&/^use[A-Z]/.test(e)&&(b=a.scope.getFunctionParent(),null!==b)){b=b.block;q.has(b)||q.set(b,[]);b=q.get(b);var c="";"VariableDeclarator"===a.parent.type&&(c=a.parentPath.get("id").getSource());var d=a.get("arguments");"useState"===e&&0<d.length?c+=
18
+ "("+d[0].getSource()+")":"useReducer"===e&&1<d.length&&(c+="("+d[1].getSource()+")");b.push({callee:a.node.callee,name:e,key:c})}}};return{visitor:{ExportDefaultDeclaration:function(a){var b=a.node,e=b.declaration,c=a.get("declaration");if("CallExpression"===e.type&&!m.has(b)){m.add(b);var d=a.parentPath;p("%default%",c,function(f,h,k){null!==k&&(f=v(d,f),k.replaceWith(g.assignmentExpression("=",f,h)))})}},FunctionDeclaration:{enter:function(a){var b=a.node,e="";switch(a.parent.type){case "Program":var c=
19
+ a;var d=a.parentPath;break;case "TSModuleBlock":c=a;d=c.parentPath.parentPath;break;case "ExportNamedDeclaration":c=a.parentPath;d=c.parentPath;break;case "ExportDefaultDeclaration":c=a.parentPath;d=c.parentPath;break;default:return}if("TSModuleBlock"===a.parent.type||"ExportNamedDeclaration"===a.parent.type)for(;"Program"!==d.type;){if("TSModuleDeclaration"===d.type){if("Program"!==d.parentPath.type&&"ExportNamedDeclaration"!==d.parentPath.type)return;e=d.node.id.name+"$"+e}d=d.parentPath}var f=
20
+ b.id;null!==f&&(f=f.name,w(f)&&!m.has(b)&&(m.add(b),p(e+f,a,function(h,k){h=v(d,h);c.insertAfter(g.expressionStatement(g.assignmentExpression("=",h,k)))})))},exit:function(a){var b=a.node,e=b.id;if(null!==e){var c=y(b);if(null!==c&&!t.has(b)){t.add(b);b=a.scope.generateUidIdentifier("_s");a.scope.parent.push({id:b,init:g.callExpression(B,[])});a.get("body").unshiftContainer("body",g.expressionStatement(g.callExpression(b,[])));var d=null;a.find(function(f){if(f.parentPath.isBlock())return d=f,!0});
21
+ null!==d&&d.insertAfter(g.expressionStatement(g.callExpression(b,x(e,c,d.scope))))}}}},"ArrowFunctionExpression|FunctionExpression":{exit:function(a){var b=a.node,e=y(b);if(null!==e&&!t.has(b)){t.add(b);var c=a.scope.generateUidIdentifier("_s");a.scope.parent.push({id:c,init:g.callExpression(B,[])});"BlockStatement"!==a.node.body.type&&(a.node.body=g.blockStatement([g.returnStatement(a.node.body)]));a.get("body").unshiftContainer("body",g.expressionStatement(g.callExpression(c,[])));if("VariableDeclarator"===
22
+ a.parent.type){var d=null;a.find(function(f){if(f.parentPath.isBlock())return d=f,!0});null!==d&&d.insertAfter(g.expressionStatement(g.callExpression(c,x(a.parent.id,e,d.scope))))}else[a].concat(E(a)).forEach(function(f){f.replaceWith(g.callExpression(c,x(f.node,e,f.scope)))})}}},VariableDeclaration:function(a){var b=a.node,e="";switch(a.parent.type){case "Program":var c=a;var d=a.parentPath;break;case "TSModuleBlock":c=a;d=c.parentPath.parentPath;break;case "ExportNamedDeclaration":c=a.parentPath;
23
+ d=c.parentPath;break;case "ExportDefaultDeclaration":c=a.parentPath;d=c.parentPath;break;default:return}if("TSModuleBlock"===a.parent.type||"ExportNamedDeclaration"===a.parent.type)for(;"Program"!==d.type;){if("TSModuleDeclaration"===d.type){if("Program"!==d.parentPath.type&&"ExportNamedDeclaration"!==d.parentPath.type)return;e=d.node.id.name+"$"+e}d=d.parentPath}if(!m.has(b)&&(m.add(b),a=a.get("declarations"),1===a.length)){var f=a[0];p(e+f.node.id.name,f,function(h,k,l){null!==l&&(h=v(d,h),"VariableDeclarator"===
24
+ l.parent.type?c.insertAfter(g.expressionStatement(g.assignmentExpression("=",h,f.node.id))):l.replaceWith(g.assignmentExpression("=",h,k)))})}},Program:{enter:function(a){a.traverse(G)},exit:function(a){var b=n.get(a);if(void 0!==b){var e=a.node;if(!C.has(e)){C.add(e);n.delete(a);var c=[];a.pushContainer("body",g.variableDeclaration("var",c));b.forEach(function(d){var f=d.handle;a.pushContainer("body",g.expressionStatement(g.callExpression(F,[f,g.stringLiteral(d.persistentID)])));c.push(g.variableDeclarator(f))})}}}}}}};
@@ -2,7 +2,7 @@
2
2
  * @license React
3
3
  * react-refresh-runtime.development.js
4
4
  *
5
- * Copyright (c) Facebook, Inc. and its affiliates.
5
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
@@ -25,7 +25,6 @@ var allFamiliesByID = new Map();
25
25
  var allFamiliesByType = new PossiblyWeakMap();
26
26
  var allSignaturesByType = new PossiblyWeakMap(); // This WeakMap is read by React, so we only put families
27
27
  // that have actually been edited here. This keeps checks fast.
28
- // $FlowIssue
29
28
 
30
29
  var updatedFamiliesByType = new PossiblyWeakMap(); // This is cleared on every performReactRefresh() call.
31
30
  // It is an array of [Family, NextType] tuples.
@@ -40,10 +39,8 @@ var mountedRoots = new Set(); // If a root captures an error, we remember it so
40
39
  var failedRoots = new Set(); // In environments that support WeakMap, we also remember the last element for every root.
41
40
  // It needs to be weak because we do this even for roots that failed to mount.
42
41
  // If there is no WeakMap, we won't attempt to do retrying.
43
- // $FlowIssue
44
42
 
45
- var rootElements = // $FlowIssue
46
- typeof WeakMap === 'function' ? new WeakMap() : null;
43
+ var rootElements = typeof WeakMap === 'function' ? new WeakMap() : null;
47
44
  var isPerformingRefresh = false;
48
45
 
49
46
  function computeFullKey(signature) {
@@ -560,6 +557,7 @@ function createSignatureFunctionForTransform() {
560
557
  // in HOC chains like _s(hoc1(_s(hoc2(_s(actualFunction))))).
561
558
  if (!savedType) {
562
559
  // We're in the innermost call, so this is the actual type.
560
+ // $FlowFixMe[escaped-generic] discovered when updating Flow
563
561
  savedType = type;
564
562
  hasCustomHooks = typeof getCustomHooks === 'function';
565
563
  } // Set the signature for all types (even wrappers!) in case
@@ -2,7 +2,7 @@
2
2
  * @license React
3
3
  * react-refresh-runtime.production.min.js
4
4
  *
5
- * Copyright (c) Facebook, Inc. and its affiliates.
5
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "keywords": [
5
5
  "react"
6
6
  ],
7
- "version": "0.14.0",
7
+ "version": "0.15.0-canary-b7972822b-20230503",
8
8
  "homepage": "https://reactjs.org/",
9
9
  "bugs": "https://github.com/facebook/react/issues",
10
10
  "license": "MIT",