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)
|
|
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)
|
|
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)
|
|
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(
|
|
11
|
-
|
|
12
|
-
0===
|
|
13
|
-
!0}}if(b)return
|
|
14
|
-
!0;break a;default:
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
"$RefreshSig$"),
|
|
18
|
-
"("+
|
|
19
|
-
a;var
|
|
20
|
-
b.id;null!==
|
|
21
|
-
null!==
|
|
22
|
-
a.parent.type){var
|
|
23
|
-
|
|
24
|
-
|
|
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)
|
|
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 =
|
|
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)
|
|
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.
|