@samitouri / QOS-React-2 / commits / 88d121899a

[DevTools] Support extended source maps with named hooks information (#22010)

## Summary Adds support for statically extracting names for hook calls from source code, and extending source maps with that information so that DevTools does not have to directly parse source code at runtime, which will speed up the Named Hooks feature and allow it to be enabled by default. Specifically, this PR includes the following parts: - [x] Adding logic to statically extract relevant hook names from the parsed source code (i.e. the babel ast). Note that this logic differs slightly from the existing logic in that the existing logic also uses runtime information from DevTools (such as whether given hooks are a custom hook) to extract names for hooks, whereas this code is meant to run entirely at build time, so it does not rely on that information. - [x] Generating an encoded "hook map", which encodes the information about a hooks *original* source location, and it's corresponding name. This "hook map" will be used to generate extended source maps, included tentatively under an extra `x_react_hook_map` field. The map itself is formatted and encoded in a very similar way as how the `names` and `mappings` fields of a standard source map are encoded ( = Base64 VLQ delta coding representing offsets into a string array), and how the "function map" in Metro is encoded, as suggested in #21782. Note that this initial version uses a very basic format, and we are not implementing our own custom encoding, but reusing the `encode` function from `sourcemap-codec`. - [x] Updating the logic in `parseHookNames` to check if the source maps have been extended with the hook map information, and if so use that information to extract the hook names without loading the original source code. In this PR we are manually generating extended source maps in our tests in order to test that this functionality works as expected, even though we are not actually generating the extended source maps in production. The second stage of this work, which will likely need to occur outside this repo, is to update bundlers such as Metro to use these new primitives to actually generate source maps that DevTools can use. ### Follow-ups - Enable named hooks by default when extended source maps are present - Support looking up hook names when column numbers are not present in source map. - Measure performance improvement of using extended source maps (manual testing suggests ~4 to 5x faster) - Update relevant bundlers to generate extended source maps. ## Test Plan - yarn flow - Tests still pass - yarn test - yarn test-build-devtools - Named hooks still work on manual test of browser extension on a few different apps (code sandbox, create-react-app, facebook). - For new functionality: - New tests for statically extracting hook names. - New tests for using extended source maps to look up hook names at runtime.

Juan committed Aug 11, 2021 at 10:46 UTC 88d121899aca8fec537003360010f077f0880541
77 files changed +3525 -33
packages/react-devtools-extensions/package.json
+3 -1
@@ -17,10 +17,12 @@
17 "test:firefox": "node ./firefox/test",
18 "test:edge": "node ./edge/test",
19 "improve-images": "node ./improveImages.mjs",
20 - "update-mock-source-maps": "node ./src/__tests__/updateMockSourceMaps.js"
20 + "update-mock-source-maps": "babel-node --presets=@babel/preset-env,@babel/preset-flow ./src/__tests__/updateMockSourceMaps.js"
21 },
22 "devDependencies": {
23 "@babel/core": "^7.11.1",
24 + "@babel/node": "^7.14.7",
25 + "@babel/parser": "^7.14.8",
26 "@babel/plugin-proposal-class-properties": "^7.10.4",
27 "@babel/plugin-transform-flow-strip-types": "^7.10.4",
28 "@babel/plugin-transform-modules-commonjs": "^7.10.4",
packages/react-devtools-extensions/src/__tests__/__source__/__compiled__/external/fb-sources-extended/ComponentUsingHooksIndirectly.js new
+45
@@ -0,0 +1,45 @@
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports.Component = Component;
7 +
8 +var _react = _interopRequireWildcard(require("react"));
9 +
10 +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
11 +
12 +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
13 +
14 +/**
15 + * Copyright (c) Facebook, Inc. and its affiliates.
16 + *
17 + * This source code is licensed under the MIT license found in the
18 + * LICENSE file in the root directory of this source tree.
19 + *
20 + * @flow
21 + */
22 +function Component() {
23 + const countState = (0, _react.useState)(0);
24 + const count = countState[0];
25 + const setCount = countState[1];
26 + const darkMode = useIsDarkMode();
27 + const [isDarkMode] = darkMode;
28 + (0, _react.useEffect)(() => {// ...
29 + }, []);
30 +
31 + const handleClick = () => setCount(count + 1);
32 +
33 + return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", null, "Dark mode? ", isDarkMode), /*#__PURE__*/_react.default.createElement("div", null, "Count: ", count), /*#__PURE__*/_react.default.createElement("button", {
34 + onClick: handleClick
35 + }, "Update count"));
36 +}
37 +
38 +function useIsDarkMode() {
39 + const darkModeState = (0, _react.useState)(false);
40 + const [isDarkMode] = darkModeState;
41 + (0, _react.useEffect)(function useEffectCreate() {// Here is where we may listen to a "theme" event...
42 + }, []);
43 + return [isDarkMode, () => {}];
44 +}
45 +//# sourceMappingURL=ComponentUsingHooksIndirectly.js.map
\ No newline at end of file
packages/react-devtools-extensions/src/__tests__/__source__/__compiled__/external/fb-sources-extended/ComponentUsingHooksIndirectly.js.map new
+1
@@ -0,0 +1 @@
1 +{"version":3,"sources":["ComponentUsingHooksIndirectly.js"],"names":["Component","countState","count","setCount","darkMode","useIsDarkMode","isDarkMode","handleClick","darkModeState","useEffectCreate"],"mappings":";;;;;;;AASA;;;;;;AATA;;;;;;;;AAWO,SAASA,SAAT,GAAqB;AAC1B,QAAMC,UAAU,GAAG,qBAAS,CAAT,CAAnB;AACA,QAAMC,KAAK,GAAGD,UAAU,CAAC,CAAD,CAAxB;AACA,QAAME,QAAQ,GAAGF,UAAU,CAAC,CAAD,CAA3B;AAEA,QAAMG,QAAQ,GAAGC,aAAa,EAA9B;AACA,QAAM,CAACC,UAAD,IAAeF,QAArB;AAEA,wBAAU,MAAM,CACd;AACD,GAFD,EAEG,EAFH;;AAIA,QAAMG,WAAW,GAAG,MAAMJ,QAAQ,CAACD,KAAK,GAAG,CAAT,CAAlC;;AAEA,sBACE,yEACE,yDAAiBI,UAAjB,CADF,eAEE,qDAAaJ,KAAb,CAFF,eAGE;AAAQ,IAAA,OAAO,EAAEK;AAAjB,oBAHF,CADF;AAOD;;AAED,SAASF,aAAT,GAAyB;AACvB,QAAMG,aAAa,GAAG,qBAAS,KAAT,CAAtB;AACA,QAAM,CAACF,UAAD,IAAeE,aAArB;AAEA,wBAAU,SAASC,eAAT,GAA2B,CACnC;AACD,GAFD,EAEG,EAFH;AAIA,SAAO,CAACH,UAAD,EAAa,MAAM,CAAE,CAArB,CAAP;AACD","sourcesContent":["/**\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * @flow\n */\n\nimport React, {useEffect, useState} from 'react';\n\nexport function Component() {\n const countState = useState(0);\n const count = countState[0];\n const setCount = countState[1];\n\n const darkMode = useIsDarkMode();\n const [isDarkMode] = darkMode;\n\n useEffect(() => {\n // ...\n }, []);\n\n const handleClick = () => setCount(count + 1);\n\n return (\n <>\n <div>Dark mode? {isDarkMode}</div>\n <div>Count: {count}</div>\n <button onClick={handleClick}>Update count</button>\n </>\n );\n}\n\nfunction useIsDarkMode() {\n const darkModeState = useState(false);\n const [isDarkMode] = darkModeState;\n\n useEffect(function useEffectCreate() {\n // Here is where we may listen to a \"theme\" event...\n }, []);\n\n return [isDarkMode, () => {}];\n}\n"],"x_fb_sources":[[null,{"names":["<no-hook>","count","darkMode","isDarkMode"],"mappings":"CAAD;aqBCA,AWDA;iBbEA,AeFA;oCVGA,AeHA"}]]}
\ No newline at end of file
packages/react-devtools-extensions/src/__tests__/__source__/__compiled__/external/fb-sources-extended/ComponentWithCustomHook.js new
+41
@@ -0,0 +1,41 @@
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports.Component = Component;
7 +
8 +var _react = _interopRequireWildcard(require("react"));
9 +
10 +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
11 +
12 +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
13 +
14 +/**
15 + * Copyright (c) Facebook, Inc. and its affiliates.
16 + *
17 + * This source code is licensed under the MIT license found in the
18 + * LICENSE file in the root directory of this source tree.
19 + *
20 + * @flow
21 + */
22 +function Component() {
23 + const [count, setCount] = (0, _react.useState)(0);
24 + const isDarkMode = useIsDarkMode();
25 + (0, _react.useEffect)(() => {// ...
26 + }, []);
27 +
28 + const handleClick = () => setCount(count + 1);
29 +
30 + return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", null, "Dark mode? ", isDarkMode), /*#__PURE__*/_react.default.createElement("div", null, "Count: ", count), /*#__PURE__*/_react.default.createElement("button", {
31 + onClick: handleClick
32 + }, "Update count"));
33 +}
34 +
35 +function useIsDarkMode() {
36 + const [isDarkMode] = (0, _react.useState)(false);
37 + (0, _react.useEffect)(function useEffectCreate() {// Here is where we may listen to a "theme" event...
38 + }, []);
39 + return isDarkMode;
40 +}
41 +//# sourceMappingURL=ComponentWithCustomHook.js.map
\ No newline at end of file
packages/react-devtools-extensions/src/__tests__/__source__/__compiled__/external/fb-sources-extended/ComponentWithCustomHook.js.map new
+1
@@ -0,0 +1 @@
1 +{"version":3,"sources":["ComponentWithCustomHook.js"],"names":["Component","count","setCount","isDarkMode","useIsDarkMode","handleClick","useEffectCreate"],"mappings":";;;;;;;AASA;;;;;;AATA;;;;;;;;AAWO,SAASA,SAAT,GAAqB;AAC1B,QAAM,CAACC,KAAD,EAAQC,QAAR,IAAoB,qBAAS,CAAT,CAA1B;AACA,QAAMC,UAAU,GAAGC,aAAa,EAAhC;AAEA,wBAAU,MAAM,CACd;AACD,GAFD,EAEG,EAFH;;AAIA,QAAMC,WAAW,GAAG,MAAMH,QAAQ,CAACD,KAAK,GAAG,CAAT,CAAlC;;AAEA,sBACE,yEACE,yDAAiBE,UAAjB,CADF,eAEE,qDAAaF,KAAb,CAFF,eAGE;AAAQ,IAAA,OAAO,EAAEI;AAAjB,oBAHF,CADF;AAOD;;AAED,SAASD,aAAT,GAAyB;AACvB,QAAM,CAACD,UAAD,IAAe,qBAAS,KAAT,CAArB;AAEA,wBAAU,SAASG,eAAT,GAA2B,CACnC;AACD,GAFD,EAEG,EAFH;AAIA,SAAOH,UAAP;AACD","sourcesContent":["/**\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * @flow\n */\n\nimport React, {useEffect, useState} from 'react';\n\nexport function Component() {\n const [count, setCount] = useState(0);\n const isDarkMode = useIsDarkMode();\n\n useEffect(() => {\n // ...\n }, []);\n\n const handleClick = () => setCount(count + 1);\n\n return (\n <>\n <div>Dark mode? {isDarkMode}</div>\n <div>Count: {count}</div>\n <button onClick={handleClick}>Update count</button>\n </>\n );\n}\n\nfunction useIsDarkMode() {\n const [isDarkMode] = useState(false);\n\n useEffect(function useEffectCreate() {\n // Here is where we may listen to a \"theme\" event...\n }, []);\n\n return isDarkMode;\n}\n"],"x_fb_sources":[[null,{"names":["<no-hook>","count","isDarkMode"],"mappings":"CAAD;a4BCA,AWDA;clBEA,AeFA;gCbEA,AeFA"}]]}
\ No newline at end of file
packages/react-devtools-extensions/src/__tests__/__source__/__compiled__/external/fb-sources-extended/ComponentWithExternalCustomHooks.js new
+26
@@ -0,0 +1,26 @@
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports.Component = Component;
7 +
8 +var _react = _interopRequireDefault(require("react"));
9 +
10 +var _useTheme = _interopRequireDefault(require("./useTheme"));
11 +
12 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13 +
14 +/**
15 + * Copyright (c) Facebook, Inc. and its affiliates.
16 + *
17 + * This source code is licensed under the MIT license found in the
18 + * LICENSE file in the root directory of this source tree.
19 + *
20 + * @flow
21 + */
22 +function Component() {
23 + const theme = (0, _useTheme.default)();
24 + return /*#__PURE__*/_react.default.createElement("div", null, "theme: ", theme);
25 +}
26 +//# sourceMappingURL=ComponentWithExternalCustomHooks.js.map
\ No newline at end of file
packages/react-devtools-extensions/src/__tests__/__source__/__compiled__/external/fb-sources-extended/ComponentWithExternalCustomHooks.js.map new
+1
@@ -0,0 +1 @@
1 +{"version":3,"sources":["ComponentWithExternalCustomHooks.js"],"names":["Component","theme"],"mappings":";;;;;;;AASA;;AACA;;;;AAVA;;;;;;;;AAYO,SAASA,SAAT,GAAqB;AAC1B,QAAMC,KAAK,GAAG,wBAAd;AAEA,sBAAO,qDAAaA,KAAb,CAAP;AACD","sourcesContent":["/**\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * @flow\n */\n\nimport React from 'react';\nimport useTheme from './useTheme';\n\nexport function Component() {\n const theme = useTheme();\n\n return <div>theme: {theme}</div>;\n}\n"],"x_fb_sources":[[null,{"names":["<no-hook>","theme"],"mappings":"CAAD;cgBCA,AUDA"}]]}
\ No newline at end of file
packages/react-devtools-extensions/src/__tests__/__source__/__compiled__/external/fb-sources-extended/ComponentWithMultipleHooksPerLine.js new
+30
@@ -0,0 +1,30 @@
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports.Component = Component;
7 +
8 +var _react = require("react");
9 +
10 +/**
11 + * Copyright (c) Facebook, Inc. and its affiliates.
12 + *
13 + * This source code is licensed under the MIT license found in the
14 + * LICENSE file in the root directory of this source tree.
15 + *
16 + * @flow
17 + */
18 +const A = /*#__PURE__*/(0, _react.createContext)(1);
19 +const B = /*#__PURE__*/(0, _react.createContext)(2);
20 +
21 +function Component() {
22 + const a = (0, _react.useContext)(A);
23 + const b = (0, _react.useContext)(B); // prettier-ignore
24 +
25 + const c = (0, _react.useContext)(A),
26 + d = (0, _react.useContext)(B); // eslint-disable-line one-var
27 +
28 + return a + b + c + d;
29 +}
30 +//# sourceMappingURL=ComponentWithMultipleHooksPerLine.js.map
\ No newline at end of file
packages/react-devtools-extensions/src/__tests__/__source__/__compiled__/external/fb-sources-extended/ComponentWithMultipleHooksPerLine.js.map new
+1
@@ -0,0 +1 @@
1 +{"version":3,"sources":["ComponentWithMultipleHooksPerLine.js"],"names":["A","B","Component","a","b","c","d"],"mappings":";;;;;;;AASA;;AATA;;;;;;;;AAWA,MAAMA,CAAC,gBAAG,0BAAc,CAAd,CAAV;AACA,MAAMC,CAAC,gBAAG,0BAAc,CAAd,CAAV;;AAEO,SAASC,SAAT,GAAqB;AAC1B,QAAMC,CAAC,GAAG,uBAAWH,CAAX,CAAV;AACA,QAAMI,CAAC,GAAG,uBAAWH,CAAX,CAAV,CAF0B,CAI1B;;AACA,QAAMI,CAAC,GAAG,uBAAWL,CAAX,CAAV;AAAA,QAAyBM,CAAC,GAAG,uBAAWL,CAAX,CAA7B,CAL0B,CAKkB;;AAE5C,SAAOE,CAAC,GAAGC,CAAJ,GAAQC,CAAR,GAAYC,CAAnB;AACD","sourcesContent":["/**\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * @flow\n */\n\nimport {createContext, useContext} from 'react';\n\nconst A = createContext(1);\nconst B = createContext(2);\n\nexport function Component() {\n const a = useContext(A);\n const b = useContext(B);\n\n // prettier-ignore\n const c = useContext(A), d = useContext(B); // eslint-disable-line one-var\n\n return a + b + c + d;\n}\n"],"x_fb_sources":[[null,{"names":["<no-hook>","a","b","c","d"],"mappings":"CAAD;gBYCA,AaDA;iBbEA,AaFA;oBbGA,AaHA,AMIA,AaJA"}]]}
\ No newline at end of file
packages/react-devtools-extensions/src/__tests__/__source__/__compiled__/external/fb-sources-extended/ComponentWithNestedHooks.js new
+28
@@ -0,0 +1,28 @@
1 +"use strict";
2 +
3 +/**
4 + * Copyright (c) Facebook, Inc. and its affiliates.
5 + *
6 + * This source code is licensed under the MIT license found in the
7 + * LICENSE file in the root directory of this source tree.
8 + *
9 + * @flow
10 + */
11 +const {
12 + useMemo,
13 + useState
14 +} = require('react');
15 +
16 +function Component(props) {
17 + const InnerComponent = useMemo(() => () => {
18 + const [state] = useState(0);
19 + return state;
20 + });
21 + props.callback(InnerComponent);
22 + return null;
23 +}
24 +
25 +module.exports = {
26 + Component
27 +};
28 +//# sourceMappingURL=ComponentWithNestedHooks.js.map
\ No newline at end of file
packages/react-devtools-extensions/src/__tests__/__source__/__compiled__/external/fb-sources-extended/ComponentWithNestedHooks.js.map new
+1
@@ -0,0 +1 @@
1 +{"version":3,"sources":["ComponentWithNestedHooks.js"],"names":["useMemo","useState","require","Component","props","InnerComponent","state","callback","module","exports"],"mappings":";;AAAA;;;;;;;;AAQA,MAAM;AAACA,EAAAA,OAAD;AAAUC,EAAAA;AAAV,IAAsBC,OAAO,CAAC,OAAD,CAAnC;;AAEA,SAASC,SAAT,CAAmBC,KAAnB,EAA0B;AACxB,QAAMC,cAAc,GAAGL,OAAO,CAAC,MAAM,MAAM;AACzC,UAAM,CAACM,KAAD,IAAUL,QAAQ,CAAC,CAAD,CAAxB;AAEA,WAAOK,KAAP;AACD,GAJ6B,CAA9B;AAKAF,EAAAA,KAAK,CAACG,QAAN,CAAeF,cAAf;AAEA,SAAO,IAAP;AACD;;AAEDG,MAAM,CAACC,OAAP,GAAiB;AAACN,EAAAA;AAAD,CAAjB","sourcesContent":["/**\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * @flow\n */\nconst {useMemo, useState} = require('react');\n\nfunction Component(props) {\n const InnerComponent = useMemo(() => () => {\n const [state] = useState(0);\n\n return state;\n });\n props.callback(InnerComponent);\n\n return null;\n}\n\nmodule.exports = {Component};\n"],"x_fb_sources":[[null,{"names":["<no-hook>","InnerComponent","state"],"mappings":"CAAD;YyBCA;aLCA,AWDA;gB3BDA"}]]}
\ No newline at end of file
packages/react-devtools-extensions/src/__tests__/__source__/__compiled__/external/fb-sources-extended/ContainingStringSourceMappingURL.js new
+29
@@ -0,0 +1,29 @@
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports.Component = Component;
7 +
8 +var _react = _interopRequireWildcard(require("react"));
9 +
10 +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
11 +
12 +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
13 +
14 +/**
15 + * Copyright (c) Facebook, Inc. and its affiliates.
16 + *
17 + * This source code is licensed under the MIT license found in the
18 + * LICENSE file in the root directory of this source tree.
19 + *
20 + * @flow
21 + */
22 +// ?sourceMappingURL=([^\s'"]+)/gm
23 +function Component() {
24 + const [count, setCount] = (0, _react.useState)(0);
25 + return /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("p", null, "You clicked ", count, " times"), /*#__PURE__*/_react.default.createElement("button", {
26 + onClick: () => setCount(count + 1)
27 + }, "Click me"));
28 +}
29 +//# sourceMappingURL=ContainingStringSourceMappingURL.js.map
\ No newline at end of file
packages/react-devtools-extensions/src/__tests__/__source__/__compiled__/external/fb-sources-extended/ContainingStringSourceMappingURL.js.map new
+1
@@ -0,0 +1 @@
1 +{"version":3,"sources":["ContainingStringSourceMappingURL.js"],"names":["Component","count","setCount"],"mappings":";;;;;;;AASA;;;;;;AATA;;;;;;;;AAWA;AAEO,SAASA,SAAT,GAAqB;AAC1B,QAAM,CAACC,KAAD,EAAQC,QAAR,IAAoB,qBAAS,CAAT,CAA1B;AAEA,sBACE,uDACE,wDAAgBD,KAAhB,WADF,eAEE;AAAQ,IAAA,OAAO,EAAE,MAAMC,QAAQ,CAACD,KAAK,GAAG,CAAT;AAA/B,gBAFF,CADF;AAMD","sourcesContent":["/**\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * @flow\n */\n\nimport React, {useState} from 'react';\n\n// ?sourceMappingURL=([^\\s'\"]+)/gm\n\nexport function Component() {\n const [count, setCount] = useState(0);\n\n return (\n <div>\n <p>You clicked {count} times</p>\n <button onClick={() => setCount(count + 1)}>Click me</button>\n </div>\n );\n}\n"],"x_fb_sources":[[null,{"names":["<no-hook>","count"],"mappings":"CAAD;e4BCA,AWDA"}]]}
\ No newline at end of file
packages/react-devtools-extensions/src/__tests__/__source__/__compiled__/external/fb-sources-extended/Example.js new
+28
@@ -0,0 +1,28 @@
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports.Component = Component;
7 +
8 +var _react = _interopRequireWildcard(require("react"));
9 +
10 +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
11 +
12 +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
13 +
14 +/**
15 + * Copyright (c) Facebook, Inc. and its affiliates.
16 + *
17 + * This source code is licensed under the MIT license found in the
18 + * LICENSE file in the root directory of this source tree.
19 + *
20 + * @flow
21 + */
22 +function Component() {
23 + const [count, setCount] = (0, _react.useState)(0);
24 + return /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("p", null, "You clicked ", count, " times"), /*#__PURE__*/_react.default.createElement("button", {
25 + onClick: () => setCount(count + 1)
26 + }, "Click me"));
27 +}
28 +//# sourceMappingURL=Example.js.map
\ No newline at end of file
packages/react-devtools-extensions/src/__tests__/__source__/__compiled__/external/fb-sources-extended/Example.js.map new
+1
@@ -0,0 +1 @@
1 +{"version":3,"sources":["Example.js"],"names":["Component","count","setCount"],"mappings":";;;;;;;AASA;;;;;;AATA;;;;;;;;AAWO,SAASA,SAAT,GAAqB;AAC1B,QAAM,CAACC,KAAD,EAAQC,QAAR,IAAoB,qBAAS,CAAT,CAA1B;AAEA,sBACE,uDACE,wDAAgBD,KAAhB,WADF,eAEE;AAAQ,IAAA,OAAO,EAAE,MAAMC,QAAQ,CAACD,KAAK,GAAG,CAAT;AAA/B,gBAFF,CADF;AAMD","sourcesContent":["/**\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * @flow\n */\n\nimport React, {useState} from 'react';\n\nexport function Component() {\n const [count, setCount] = useState(0);\n\n return (\n <div>\n <p>You clicked {count} times</p>\n <button onClick={() => setCount(count + 1)}>Click me</button>\n </div>\n );\n}\n"],"x_fb_sources":[[null,{"names":["<no-hook>","count"],"mappings":"CAAD;a4BCA,AWDA"}]]}
\ No newline at end of file
packages/react-devtools-extensions/src/__tests__/__source__/__compiled__/external/fb-sources-extended/InlineRequire.js new
+21
@@ -0,0 +1,21 @@
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports.Component = Component;
7 +
8 +/**
9 + * Copyright (c) Facebook, Inc. and its affiliates.
10 + *
11 + * This source code is licensed under the MIT license found in the
12 + * LICENSE file in the root directory of this source tree.
13 + *
14 + * @flow
15 + */
16 +function Component() {
17 + const [count] = require('react').useState(0);
18 +
19 + return count;
20 +}
21 +//# sourceMappingURL=InlineRequire.js.map
\ No newline at end of file
packages/react-devtools-extensions/src/__tests__/__source__/__compiled__/external/fb-sources-extended/InlineRequire.js.map new
+1
@@ -0,0 +1 @@
1 +{"version":3,"sources":["InlineRequire.js"],"names":["Component","count","require","useState"],"mappings":";;;;;;;AAAA;;;;;;;;AASO,SAASA,SAAT,GAAqB;AAC1B,QAAM,CAACC,KAAD,IAAUC,OAAO,CAAC,OAAD,CAAP,CAAiBC,QAAjB,CAA0B,CAA1B,CAAhB;;AAEA,SAAOF,KAAP;AACD","sourcesContent":["/**\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * @flow\n */\n\nexport function Component() {\n const [count] = require('react').useState(0);\n\n return count;\n}\n"],"x_fb_sources":[[null,{"names":["<no-hook>"],"mappings":"CAAD"}]]}
\ No newline at end of file
packages/react-devtools-extensions/src/__tests__/__source__/__compiled__/external/fb-sources-extended/ToDoList.js new
+106
@@ -0,0 +1,106 @@
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports.ListItem = ListItem;
7 +exports.List = List;
8 +
9 +var React = _interopRequireWildcard(require("react"));
10 +
11 +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
12 +
13 +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
14 +
15 +/**
16 + * Copyright (c) Facebook, Inc. and its affiliates.
17 + *
18 + * This source code is licensed under the MIT license found in the
19 + * LICENSE file in the root directory of this source tree.
20 + *
21 + * @flow
22 + */
23 +function ListItem({
24 + item,
25 + removeItem,
26 + toggleItem
27 +}) {
28 + const handleDelete = (0, React.useCallback)(() => {
29 + removeItem(item);
30 + }, [item, removeItem]);
31 + const handleToggle = (0, React.useCallback)(() => {
32 + toggleItem(item);
33 + }, [item, toggleItem]);
34 + return /*#__PURE__*/React.createElement("li", null, /*#__PURE__*/React.createElement("button", {
35 + onClick: handleDelete
36 + }, "Delete"), /*#__PURE__*/React.createElement("label", null, /*#__PURE__*/React.createElement("input", {
37 + checked: item.isComplete,
38 + onChange: handleToggle,
39 + type: "checkbox"
40 + }), ' ', item.text));
41 +}
42 +
43 +function List(props) {
44 + const [newItemText, setNewItemText] = (0, React.useState)('');
45 + const [items, setItems] = (0, React.useState)([{
46 + id: 1,
47 + isComplete: true,
48 + text: 'First'
49 + }, {
50 + id: 2,
51 + isComplete: true,
52 + text: 'Second'
53 + }, {
54 + id: 3,
55 + isComplete: false,
56 + text: 'Third'
57 + }]);
58 + const [uid, setUID] = (0, React.useState)(4);
59 + const handleClick = (0, React.useCallback)(() => {
60 + if (newItemText !== '') {
61 + setItems([...items, {
62 + id: uid,
63 + isComplete: false,
64 + text: newItemText
65 + }]);
66 + setUID(uid + 1);
67 + setNewItemText('');
68 + }
69 + }, [newItemText, items, uid]);
70 + const handleKeyPress = (0, React.useCallback)(event => {
71 + if (event.key === 'Enter') {
72 + handleClick();
73 + }
74 + }, [handleClick]);
75 + const handleChange = (0, React.useCallback)(event => {
76 + setNewItemText(event.currentTarget.value);
77 + }, [setNewItemText]);
78 + const removeItem = (0, React.useCallback)(itemToRemove => setItems(items.filter(item => item !== itemToRemove)), [items]);
79 + const toggleItem = (0, React.useCallback)(itemToToggle => {
80 + // Dont use indexOf()
81 + // because editing props in DevTools creates a new Object.
82 + const index = items.findIndex(item => item.id === itemToToggle.id);
83 + setItems(items.slice(0, index).concat({ ...itemToToggle,
84 + isComplete: !itemToToggle.isComplete
85 + }).concat(items.slice(index + 1)));
86 + }, [items]);
87 + return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("h1", null, "List"), /*#__PURE__*/React.createElement("input", {
88 + type: "text",
89 + placeholder: "New list item...",
90 + value: newItemText,
91 + onChange: handleChange,
92 + onKeyPress: handleKeyPress
93 + }), /*#__PURE__*/React.createElement("button", {
94 + disabled: newItemText === '',
95 + onClick: handleClick
96 + }, /*#__PURE__*/React.createElement("span", {
97 + role: "img",
98 + "aria-label": "Add item"
99 + }, "Add")), /*#__PURE__*/React.createElement("ul", null, items.map(item => /*#__PURE__*/React.createElement(ListItem, {
100 + key: item.id,
101 + item: item,
102 + removeItem: removeItem,
103 + toggleItem: toggleItem
104 + }))));
105 +}
106 +//# sourceMappingURL=ToDoList.js.map
\ No newline at end of file
packages/react-devtools-extensions/src/__tests__/__source__/__compiled__/external/fb-sources-extended/ToDoList.js.map new
+1
@@ -0,0 +1 @@
1 +{"version":3,"sources":["ToDoList.js"],"names":["ListItem","item","removeItem","toggleItem","handleDelete","handleToggle","isComplete","text","List","props","newItemText","setNewItemText","items","setItems","id","uid","setUID","handleClick","handleKeyPress","event","key","handleChange","currentTarget","value","itemToRemove","filter","itemToToggle","index","findIndex","slice","concat","map"],"mappings":";;;;;;;;AASA;;;;;;AATA;;;;;;;;AAYO,SAASA,QAAT,CAAkB;AAACC,EAAAA,IAAD;AAAOC,EAAAA,UAAP;AAAmBC,EAAAA;AAAnB,CAAlB,EAAkD;AACvD,QAAMC,YAAY,GAAG,uBAAY,MAAM;AACrCF,IAAAA,UAAU,CAACD,IAAD,CAAV;AACD,GAFoB,EAElB,CAACA,IAAD,EAAOC,UAAP,CAFkB,CAArB;AAIA,QAAMG,YAAY,GAAG,uBAAY,MAAM;AACrCF,IAAAA,UAAU,CAACF,IAAD,CAAV;AACD,GAFoB,EAElB,CAACA,IAAD,EAAOE,UAAP,CAFkB,CAArB;AAIA,sBACE,6CACE;AAAQ,IAAA,OAAO,EAAEC;AAAjB,cADF,eAEE,gDACE;AACE,IAAA,OAAO,EAAEH,IAAI,CAACK,UADhB;AAEE,IAAA,QAAQ,EAAED,YAFZ;AAGE,IAAA,IAAI,EAAC;AAHP,IADF,EAKK,GALL,EAMGJ,IAAI,CAACM,IANR,CAFF,CADF;AAaD;;AAEM,SAASC,IAAT,CAAcC,KAAd,EAAqB;AAC1B,QAAM,CAACC,WAAD,EAAcC,cAAd,IAAgC,oBAAS,EAAT,CAAtC;AACA,QAAM,CAACC,KAAD,EAAQC,QAAR,IAAoB,oBAAS,CACjC;AAACC,IAAAA,EAAE,EAAE,CAAL;AAAQR,IAAAA,UAAU,EAAE,IAApB;AAA0BC,IAAAA,IAAI,EAAE;AAAhC,GADiC,EAEjC;AAACO,IAAAA,EAAE,EAAE,CAAL;AAAQR,IAAAA,UAAU,EAAE,IAApB;AAA0BC,IAAAA,IAAI,EAAE;AAAhC,GAFiC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AAYY,YAAY,CAACZ,EAAjD,CAAd;AAEAD,IAAAA,QAAQ,CACND,KAAK,CACFiB,KADH,CACS,CADT,EACYF,KADZ,EAEGG,MAFH,CAEU,EACN,GAAGJ,YADG;AAENpB,MAAAA,UAAU,EAAE,CAACoB,YAAY,CAACpB;AAFpB,KAFV,EAMGwB,MANH,CAMUlB,KAAK,CAACiB,KAAN,CAAYF,KAAK,GAAG,CAApB,CANV,CADM,CAAR;AASD,GAfgB,EAgBjB,CAACf,KAAD,CAhBiB,CAAnB;AAmBA,sBACE,oBAAC,cAAD,qBACE,uCADF,eAEE;AACE,IAAA,IAAI,EAAC,MADP;AAEE,IAAA,WAAW,EAAC,kBAFd;AAGE,IAAA,KAAK,EAAEF,WAHT;AAIE,IAAA,QAAQ,EAAEW,YAJZ;AAKE,IAAA,UAAU,EAAEH;AALd,IAFF,eASE;AAAQ,IAAA,QAAQ,EAAER,WAAW,KAAK,EAAlC;AAAsC,IAAA,OAAO,EAAEO;AAA/C,kBACE;AAAM,IAAA,IAAI,EAAC,KAAX;AAAiB,kBAAW;AAA5B,WADF,CATF,eAcE,gCACGL,KAAK,CAACmB,GAAN,CAAU9B,IAAI,iBACb,oBAAC,QAAD;AACE,IAAA,GAAG,EAAEA,IAAI,CAACa,EADZ;AAEE,IAAA,IAAI,EAAEb,IAFR;AAGE,IAAA,UAAU,EAAEC,UAHd;AAIE,IAAA,UAAU,EAAEC;AAJd,IADD,CADH,CAdF,CADF;AA2BD","sourcesContent":["/**\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * @flow\n */\n\nimport * as React from 'react';\nimport {Fragment, useCallback, useState} from 'react';\n\nexport function ListItem({item, removeItem, toggleItem}) {\n const handleDelete = useCallback(() => {\n removeItem(item);\n }, [item, removeItem]);\n\n const handleToggle = useCallback(() => {\n toggleItem(item);\n }, [item, toggleItem]);\n\n return (\n <li>\n <button onClick={handleDelete}>Delete</button>\n <label>\n <input\n checked={item.isComplete}\n onChange={handleToggle}\n type=\"checkbox\"\n />{' '}\n {item.text}\n </label>\n </li>\n );\n}\n\nexport function List(props) {\n const [newItemText, setNewItemText] = useState('');\n const [items, setItems] = useState([\n {id: 1, isComplete: true, text: 'First'},\n {id: 2, isComplete: true, text: 'Second'},\n {id: 3, isComplete: false, text: 'Third'},\n ]);\n const [uid, setUID] = useState(4);\n\n const handleClick = useCallback(() => {\n if (newItemText !== '') {\n setItems([\n ...items,\n {\n id: uid,\n isComplete: false,\n text: newItemText,\n },\n ]);\n setUID(uid + 1);\n setNewItemText('');\n }\n }, [newItemText, items, uid]);\n\n const handleKeyPress = useCallback(\n event => {\n if (event.key === 'Enter') {\n handleClick();\n }\n },\n [handleClick],\n );\n\n const handleChange = useCallback(\n event => {\n setNewItemText(event.currentTarget.value);\n },\n [setNewItemText],\n );\n\n const removeItem = useCallback(\n itemToRemove => setItems(items.filter(item => item !== itemToRemove)),\n [items],\n );\n\n const toggleItem = useCallback(\n itemToToggle => {\n // Dont use indexOf()\n // because editing props in DevTools creates a new Object.\n const index = items.findIndex(item => item.id === itemToToggle.id);\n\n setItems(\n items\n .slice(0, index)\n .concat({\n ...itemToToggle,\n isComplete: !itemToToggle.isComplete,\n })\n .concat(items.slice(index + 1)),\n );\n },\n [items],\n );\n\n return (\n <Fragment>\n <h1>List</h1>\n <input\n type=\"text\"\n placeholder=\"New list item...\"\n value={newItemText}\n onChange={handleChange}\n onKeyPress={handleKeyPress}\n />\n <button disabled={newItemText === ''} onClick={handleClick}>\n <span role=\"img\" aria-label=\"Add item\">\n Add\n </span>\n </button>\n <ul>\n {items.map(item => (\n <ListItem\n key={item.id}\n item={item}\n removeItem={removeItem}\n toggleItem={toggleItem}\n />\n ))}\n </ul>\n </Fragment>\n );\n}\n"],"x_fb_sources":[[null,{"names":["<no-hook>","handleDelete","handleToggle","newItemText","items","uid","handleClick","handleKeyPress","handleChange","removeItem","toggleItem"],"mappings":"CAAD;cuBCA;gBCDA;kBDEA;oBCFA;sCgBGA,AYHA;uCxBIA;2CxBJA;4CoBKA,AWLA;8CbMA;2DSNA;6DNOA;oEtBPA;sEoBQA;2EpBRA;6EkBSA;gFlBTA;kFkBUA;mGlBVA"}]]}
\ No newline at end of file
packages/react-devtools-extensions/src/__tests__/__source__/__compiled__/external/fb-sources-extended/index.js new
+89
@@ -0,0 +1,89 @@
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +Object.defineProperty(exports, "ComponentUsingHooksIndirectly", {
7 + enumerable: true,
8 + get: function () {
9 + return _ComponentUsingHooksIndirectly.Component;
10 + }
11 +});
12 +Object.defineProperty(exports, "ComponentWithCustomHook", {
13 + enumerable: true,
14 + get: function () {
15 + return _ComponentWithCustomHook.Component;
16 + }
17 +});
18 +Object.defineProperty(exports, "ComponentWithExternalCustomHooks", {
19 + enumerable: true,
20 + get: function () {
21 + return _ComponentWithExternalCustomHooks.Component;
22 + }
23 +});
24 +Object.defineProperty(exports, "ComponentWithMultipleHooksPerLine", {
25 + enumerable: true,
26 + get: function () {
27 + return _ComponentWithMultipleHooksPerLine.Component;
28 + }
29 +});
30 +Object.defineProperty(exports, "ComponentWithNestedHooks", {
31 + enumerable: true,
32 + get: function () {
33 + return _ComponentWithNestedHooks.Component;
34 + }
35 +});
36 +Object.defineProperty(exports, "ContainingStringSourceMappingURL", {
37 + enumerable: true,
38 + get: function () {
39 + return _ContainingStringSourceMappingURL.Component;
40 + }
41 +});
42 +Object.defineProperty(exports, "Example", {
43 + enumerable: true,
44 + get: function () {
45 + return _Example.Component;
46 + }
47 +});
48 +Object.defineProperty(exports, "InlineRequire", {
49 + enumerable: true,
50 + get: function () {
51 + return _InlineRequire.Component;
52 + }
53 +});
54 +Object.defineProperty(exports, "useTheme", {
55 + enumerable: true,
56 + get: function () {
57 + return _useTheme.default;
58 + }
59 +});
60 +exports.ToDoList = void 0;
61 +
62 +var _ComponentUsingHooksIndirectly = require("./ComponentUsingHooksIndirectly");
63 +
64 +var _ComponentWithCustomHook = require("./ComponentWithCustomHook");
65 +
66 +var _ComponentWithExternalCustomHooks = require("./ComponentWithExternalCustomHooks");
67 +
68 +var _ComponentWithMultipleHooksPerLine = require("./ComponentWithMultipleHooksPerLine");
69 +
70 +var _ComponentWithNestedHooks = require("./ComponentWithNestedHooks");
71 +
72 +var _ContainingStringSourceMappingURL = require("./ContainingStringSourceMappingURL");
73 +
74 +var _Example = require("./Example");
75 +
76 +var _InlineRequire = require("./InlineRequire");
77 +
78 +var ToDoList = _interopRequireWildcard(require("./ToDoList"));
79 +
80 +exports.ToDoList = ToDoList;
81 +
82 +var _useTheme = _interopRequireDefault(require("./useTheme"));
83 +
84 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
85 +
86 +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
87 +
88 +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
89 +//# sourceMappingURL=index.js.map
\ No newline at end of file
packages/react-devtools-extensions/src/__tests__/__source__/__compiled__/external/fb-sources-extended/index.js.map new
+1
@@ -0,0 +1 @@
1 +{"version":3,"sources":["index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;AAEA","sourcesContent":["/**\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * @flow\n */\n\nexport {Component as ComponentUsingHooksIndirectly} from './ComponentUsingHooksIndirectly';\nexport {Component as ComponentWithCustomHook} from './ComponentWithCustomHook';\nexport {Component as ComponentWithExternalCustomHooks} from './ComponentWithExternalCustomHooks';\nexport {Component as ComponentWithMultipleHooksPerLine} from './ComponentWithMultipleHooksPerLine';\nexport {Component as ComponentWithNestedHooks} from './ComponentWithNestedHooks';\nexport {Component as ContainingStringSourceMappingURL} from './ContainingStringSourceMappingURL';\nexport {Component as Example} from './Example';\nexport {Component as InlineRequire} from './InlineRequire';\nimport * as ToDoList from './ToDoList';\nexport {ToDoList};\nexport {default as useTheme} from './useTheme';\n"],"x_fb_sources":[[null,{"names":["<no-hook>"],"mappings":"CAAD"}]]}
\ No newline at end of file
packages/react-devtools-extensions/src/__tests__/__source__/__compiled__/external/fb-sources-extended/useTheme.js new
+27
@@ -0,0 +1,27 @@
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports.default = useTheme;
7 +exports.ThemeContext = void 0;
8 +
9 +var _react = require("react");
10 +
11 +/**
12 + * Copyright (c) Facebook, Inc. and its affiliates.
13 + *
14 + * This source code is licensed under the MIT license found in the
15 + * LICENSE file in the root directory of this source tree.
16 + *
17 + * @flow
18 + */
19 +const ThemeContext = /*#__PURE__*/(0, _react.createContext)('bright');
20 +exports.ThemeContext = ThemeContext;
21 +
22 +function useTheme() {
23 + const theme = (0, _react.useContext)(ThemeContext);
24 + (0, _react.useDebugValue)(theme);
25 + return theme;
26 +}
27 +//# sourceMappingURL=useTheme.js.map
\ No newline at end of file
packages/react-devtools-extensions/src/__tests__/__source__/__compiled__/external/fb-sources-extended/useTheme.js.map new
+1
@@ -0,0 +1 @@
1 +{"version":3,"sources":["useTheme.js"],"names":["ThemeContext","useTheme","theme"],"mappings":";;;;;;;;AASA;;AATA;;;;;;;;AAWO,MAAMA,YAAY,gBAAG,0BAAc,QAAd,CAArB;;;AAEQ,SAASC,QAAT,GAAoB;AACjC,QAAMC,KAAK,GAAG,uBAAWF,YAAX,CAAd;AACA,4BAAcE,KAAd;AACA,SAAOA,KAAP;AACD","sourcesContent":["/**\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * @flow\n */\n\nimport {createContext, useContext, useDebugValue} from 'react';\n\nexport const ThemeContext = createContext('bright');\n\nexport default function useTheme() {\n const theme = useContext(ThemeContext);\n useDebugValue(theme);\n return theme;\n}\n"],"x_fb_sources":[[null,{"names":["<no-hook>","theme"],"mappings":"CAAD;egBCA,AwBDA"}]]}
\ No newline at end of file
packages/react-devtools-extensions/src/__tests__/__source__/__compiled__/external/react-sources-extended/ComponentUsingHooksIndirectly.js new
+45
@@ -0,0 +1,45 @@
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports.Component = Component;
7 +
8 +var _react = _interopRequireWildcard(require("react"));
9 +
10 +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
11 +
12 +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
13 +
14 +/**
15 + * Copyright (c) Facebook, Inc. and its affiliates.
16 + *
17 + * This source code is licensed under the MIT license found in the
18 + * LICENSE file in the root directory of this source tree.
19 + *
20 + * @flow
21 + */
22 +function Component() {
23 + const countState = (0, _react.useState)(0);
24 + const count = countState[0];
25 + const setCount = countState[1];
26 + const darkMode = useIsDarkMode();
27 + const [isDarkMode] = darkMode;
28 + (0, _react.useEffect)(() => {// ...
29 + }, []);
30 +
31 + const handleClick = () => setCount(count + 1);
32 +
33 + return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", null, "Dark mode? ", isDarkMode), /*#__PURE__*/_react.default.createElement("div", null, "Count: ", count), /*#__PURE__*/_react.default.createElement("button", {
34 + onClick: handleClick
35 + }, "Update count"));
36 +}
37 +
38 +function useIsDarkMode() {
39 + const darkModeState = (0, _react.useState)(false);
40 + const [isDarkMode] = darkModeState;
41 + (0, _react.useEffect)(function useEffectCreate() {// Here is where we may listen to a "theme" event...
42 + }, []);
43 + return [isDarkMode, () => {}];
44 +}
45 +//# sourceMappingURL=ComponentUsingHooksIndirectly.js.map
\ No newline at end of file
packages/react-devtools-extensions/src/__tests__/__source__/__compiled__/external/react-sources-extended/ComponentUsingHooksIndirectly.js.map new
+1
@@ -0,0 +1 @@
1 +{"version":3,"sources":["ComponentUsingHooksIndirectly.js"],"names":["Component","countState","count","setCount","darkMode","useIsDarkMode","isDarkMode","handleClick","darkModeState","useEffectCreate"],"mappings":";;;;;;;AASA;;;;;;AATA;;;;;;;;AAWO,SAASA,SAAT,GAAqB;AAC1B,QAAMC,UAAU,GAAG,qBAAS,CAAT,CAAnB;AACA,QAAMC,KAAK,GAAGD,UAAU,CAAC,CAAD,CAAxB;AACA,QAAME,QAAQ,GAAGF,UAAU,CAAC,CAAD,CAA3B;AAEA,QAAMG,QAAQ,GAAGC,aAAa,EAA9B;AACA,QAAM,CAACC,UAAD,IAAeF,QAArB;AAEA,wBAAU,MAAM,CACd;AACD,GAFD,EAEG,EAFH;;AAIA,QAAMG,WAAW,GAAG,MAAMJ,QAAQ,CAACD,KAAK,GAAG,CAAT,CAAlC;;AAEA,sBACE,yEACE,yDAAiBI,UAAjB,CADF,eAEE,qDAAaJ,KAAb,CAFF,eAGE;AAAQ,IAAA,OAAO,EAAEK;AAAjB,oBAHF,CADF;AAOD;;AAED,SAASF,aAAT,GAAyB;AACvB,QAAMG,aAAa,GAAG,qBAAS,KAAT,CAAtB;AACA,QAAM,CAACF,UAAD,IAAeE,aAArB;AAEA,wBAAU,SAASC,eAAT,GAA2B,CACnC;AACD,GAFD,EAEG,EAFH;AAIA,SAAO,CAACH,UAAD,EAAa,MAAM,CAAE,CAArB,CAAP;AACD","sourcesContent":["/**\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * @flow\n */\n\nimport React, {useEffect, useState} from 'react';\n\nexport function Component() {\n const countState = useState(0);\n const count = countState[0];\n const setCount = countState[1];\n\n const darkMode = useIsDarkMode();\n const [isDarkMode] = darkMode;\n\n useEffect(() => {\n // ...\n }, []);\n\n const handleClick = () => setCount(count + 1);\n\n return (\n <>\n <div>Dark mode? {isDarkMode}</div>\n <div>Count: {count}</div>\n <button onClick={handleClick}>Update count</button>\n </>\n );\n}\n\nfunction useIsDarkMode() {\n const darkModeState = useState(false);\n const [isDarkMode] = darkModeState;\n\n useEffect(function useEffectCreate() {\n // Here is where we may listen to a \"theme\" event...\n }, []);\n\n return [isDarkMode, () => {}];\n}\n"],"x_react_sources":[[{"names":["<no-hook>","count","darkMode","isDarkMode"],"mappings":"CAAD;aqBCA,AWDA;iBbEA,AeFA;oCVGA,AeHA"}]]}
\ No newline at end of file
packages/react-devtools-extensions/src/__tests__/__source__/__compiled__/external/react-sources-extended/ComponentWithCustomHook.js new
+41
@@ -0,0 +1,41 @@
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports.Component = Component;
7 +
8 +var _react = _interopRequireWildcard(require("react"));
9 +
10 +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
11 +
12 +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
13 +
14 +/**
15 + * Copyright (c) Facebook, Inc. and its affiliates.
16 + *
17 + * This source code is licensed under the MIT license found in the
18 + * LICENSE file in the root directory of this source tree.
19 + *
20 + * @flow
21 + */
22 +function Component() {
23 + const [count, setCount] = (0, _react.useState)(0);
24 + const isDarkMode = useIsDarkMode();
25 + (0, _react.useEffect)(() => {// ...
26 + }, []);
27 +
28 + const handleClick = () => setCount(count + 1);
29 +
30 + return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", null, "Dark mode? ", isDarkMode), /*#__PURE__*/_react.default.createElement("div", null, "Count: ", count), /*#__PURE__*/_react.default.createElement("button", {
31 + onClick: handleClick
32 + }, "Update count"));
33 +}
34 +
35 +function useIsDarkMode() {
36 + const [isDarkMode] = (0, _react.useState)(false);
37 + (0, _react.useEffect)(function useEffectCreate() {// Here is where we may listen to a "theme" event...
38 + }, []);
39 + return isDarkMode;
40 +}
41 +//# sourceMappingURL=ComponentWithCustomHook.js.map
\ No newline at end of file
packages/react-devtools-extensions/src/__tests__/__source__/__compiled__/external/react-sources-extended/ComponentWithCustomHook.js.map new
+1
@@ -0,0 +1 @@
1 +{"version":3,"sources":["ComponentWithCustomHook.js"],"names":["Component","count","setCount","isDarkMode","useIsDarkMode","handleClick","useEffectCreate"],"mappings":";;;;;;;AASA;;;;;;AATA;;;;;;;;AAWO,SAASA,SAAT,GAAqB;AAC1B,QAAM,CAACC,KAAD,EAAQC,QAAR,IAAoB,qBAAS,CAAT,CAA1B;AACA,QAAMC,UAAU,GAAGC,aAAa,EAAhC;AAEA,wBAAU,MAAM,CACd;AACD,GAFD,EAEG,EAFH;;AAIA,QAAMC,WAAW,GAAG,MAAMH,QAAQ,CAACD,KAAK,GAAG,CAAT,CAAlC;;AAEA,sBACE,yEACE,yDAAiBE,UAAjB,CADF,eAEE,qDAAaF,KAAb,CAFF,eAGE;AAAQ,IAAA,OAAO,EAAEI;AAAjB,oBAHF,CADF;AAOD;;AAED,SAASD,aAAT,GAAyB;AACvB,QAAM,CAACD,UAAD,IAAe,qBAAS,KAAT,CAArB;AAEA,wBAAU,SAASG,eAAT,GAA2B,CACnC;AACD,GAFD,EAEG,EAFH;AAIA,SAAOH,UAAP;AACD","sourcesContent":["/**\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * @flow\n */\n\nimport React, {useEffect, useState} from 'react';\n\nexport function Component() {\n const [count, setCount] = useState(0);\n const isDarkMode = useIsDarkMode();\n\n useEffect(() => {\n // ...\n }, []);\n\n const handleClick = () => setCount(count + 1);\n\n return (\n <>\n <div>Dark mode? {isDarkMode}</div>\n <div>Count: {count}</div>\n <button onClick={handleClick}>Update count</button>\n </>\n );\n}\n\nfunction useIsDarkMode() {\n const [isDarkMode] = useState(false);\n\n useEffect(function useEffectCreate() {\n // Here is where we may listen to a \"theme\" event...\n }, []);\n\n return isDarkMode;\n}\n"],"x_react_sources":[[{"names":["<no-hook>","count","isDarkMode"],"mappings":"CAAD;a4BCA,AWDA;clBEA,AeFA;gCbEA,AeFA"}]]}
\ No newline at end of file
packages/react-devtools-extensions/src/__tests__/__source__/__compiled__/external/react-sources-extended/ComponentWithExternalCustomHooks.js new
+26
@@ -0,0 +1,26 @@
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports.Component = Component;
7 +
8 +var _react = _interopRequireDefault(require("react"));
9 +
10 +var _useTheme = _interopRequireDefault(require("./useTheme"));
11 +
12 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13 +
14 +/**
15 + * Copyright (c) Facebook, Inc. and its affiliates.
16 + *
17 + * This source code is licensed under the MIT license found in the
18 + * LICENSE file in the root directory of this source tree.
19 + *
20 + * @flow
21 + */
22 +function Component() {
23 + const theme = (0, _useTheme.default)();
24 + return /*#__PURE__*/_react.default.createElement("div", null, "theme: ", theme);
25 +}
26 +//# sourceMappingURL=ComponentWithExternalCustomHooks.js.map
\ No newline at end of file
packages/react-devtools-extensions/src/__tests__/__source__/__compiled__/external/react-sources-extended/ComponentWithExternalCustomHooks.js.map new
+1
@@ -0,0 +1 @@
1 +{"version":3,"sources":["ComponentWithExternalCustomHooks.js"],"names":["Component","theme"],"mappings":";;;;;;;AASA;;AACA;;;;AAVA;;;;;;;;AAYO,SAASA,SAAT,GAAqB;AAC1B,QAAMC,KAAK,GAAG,wBAAd;AAEA,sBAAO,qDAAaA,KAAb,CAAP;AACD","sourcesContent":["/**\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * @flow\n */\n\nimport React from 'react';\nimport useTheme from './useTheme';\n\nexport function Component() {\n const theme = useTheme();\n\n return <div>theme: {theme}</div>;\n}\n"],"x_react_sources":[[{"names":["<no-hook>","theme"],"mappings":"CAAD;cgBCA,AUDA"}]]}
\ No newline at end of file
packages/react-devtools-extensions/src/__tests__/__source__/__compiled__/external/react-sources-extended/ComponentWithMultipleHooksPerLine.js new
+30
@@ -0,0 +1,30 @@
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports.Component = Component;
7 +
8 +var _react = require("react");
9 +
10 +/**
11 + * Copyright (c) Facebook, Inc. and its affiliates.
12 + *
13 + * This source code is licensed under the MIT license found in the
14 + * LICENSE file in the root directory of this source tree.
15 + *
16 + * @flow
17 + */
18 +const A = /*#__PURE__*/(0, _react.createContext)(1);
19 +const B = /*#__PURE__*/(0, _react.createContext)(2);
20 +
21 +function Component() {
22 + const a = (0, _react.useContext)(A);
23 + const b = (0, _react.useContext)(B); // prettier-ignore
24 +
25 + const c = (0, _react.useContext)(A),
26 + d = (0, _react.useContext)(B); // eslint-disable-line one-var
27 +
28 + return a + b + c + d;
29 +}
30 +//# sourceMappingURL=ComponentWithMultipleHooksPerLine.js.map
\ No newline at end of file
packages/react-devtools-extensions/src/__tests__/__source__/__compiled__/external/react-sources-extended/ComponentWithMultipleHooksPerLine.js.map new
+1
@@ -0,0 +1 @@
1 +{"version":3,"sources":["ComponentWithMultipleHooksPerLine.js"],"names":["A","B","Component","a","b","c","d"],"mappings":";;;;;;;AASA;;AATA;;;;;;;;AAWA,MAAMA,CAAC,gBAAG,0BAAc,CAAd,CAAV;AACA,MAAMC,CAAC,gBAAG,0BAAc,CAAd,CAAV;;AAEO,SAASC,SAAT,GAAqB;AAC1B,QAAMC,CAAC,GAAG,uBAAWH,CAAX,CAAV;AACA,QAAMI,CAAC,GAAG,uBAAWH,CAAX,CAAV,CAF0B,CAI1B;;AACA,QAAMI,CAAC,GAAG,uBAAWL,CAAX,CAAV;AAAA,QAAyBM,CAAC,GAAG,uBAAWL,CAAX,CAA7B,CAL0B,CAKkB;;AAE5C,SAAOE,CAAC,GAAGC,CAAJ,GAAQC,CAAR,GAAYC,CAAnB;AACD","sourcesContent":["/**\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * @flow\n */\n\nimport {createContext, useContext} from 'react';\n\nconst A = createContext(1);\nconst B = createContext(2);\n\nexport function Component() {\n const a = useContext(A);\n const b = useContext(B);\n\n // prettier-ignore\n const c = useContext(A), d = useContext(B); // eslint-disable-line one-var\n\n return a + b + c + d;\n}\n"],"x_react_sources":[[{"names":["<no-hook>","a","b","c","d"],"mappings":"CAAD;gBYCA,AaDA;iBbEA,AaFA;oBbGA,AaHA,AMIA,AaJA"}]]}
\ No newline at end of file
packages/react-devtools-extensions/src/__tests__/__source__/__compiled__/external/react-sources-extended/ComponentWithNestedHooks.js new
+28
@@ -0,0 +1,28 @@
1 +"use strict";
2 +
3 +/**
4 + * Copyright (c) Facebook, Inc. and its affiliates.
5 + *
6 + * This source code is licensed under the MIT license found in the
7 + * LICENSE file in the root directory of this source tree.
8 + *
9 + * @flow
10 + */
11 +const {
12 + useMemo,
13 + useState
14 +} = require('react');
15 +
16 +function Component(props) {
17 + const InnerComponent = useMemo(() => () => {
18 + const [state] = useState(0);
19 + return state;
20 + });
21 + props.callback(InnerComponent);
22 + return null;
23 +}
24 +
25 +module.exports = {
26 + Component
27 +};
28 +//# sourceMappingURL=ComponentWithNestedHooks.js.map
\ No newline at end of file
packages/react-devtools-extensions/src/__tests__/__source__/__compiled__/external/react-sources-extended/ComponentWithNestedHooks.js.map new
+1
@@ -0,0 +1 @@
1 +{"version":3,"sources":["ComponentWithNestedHooks.js"],"names":["useMemo","useState","require","Component","props","InnerComponent","state","callback","module","exports"],"mappings":";;AAAA;;;;;;;;AAQA,MAAM;AAACA,EAAAA,OAAD;AAAUC,EAAAA;AAAV,IAAsBC,OAAO,CAAC,OAAD,CAAnC;;AAEA,SAASC,SAAT,CAAmBC,KAAnB,EAA0B;AACxB,QAAMC,cAAc,GAAGL,OAAO,CAAC,MAAM,MAAM;AACzC,UAAM,CAACM,KAAD,IAAUL,QAAQ,CAAC,CAAD,CAAxB;AAEA,WAAOK,KAAP;AACD,GAJ6B,CAA9B;AAKAF,EAAAA,KAAK,CAACG,QAAN,CAAeF,cAAf;AAEA,SAAO,IAAP;AACD;;AAEDG,MAAM,CAACC,OAAP,GAAiB;AAACN,EAAAA;AAAD,CAAjB","sourcesContent":["/**\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * @flow\n */\nconst {useMemo, useState} = require('react');\n\nfunction Component(props) {\n const InnerComponent = useMemo(() => () => {\n const [state] = useState(0);\n\n return state;\n });\n props.callback(InnerComponent);\n\n return null;\n}\n\nmodule.exports = {Component};\n"],"x_react_sources":[[{"names":["<no-hook>","InnerComponent","state"],"mappings":"CAAD;YyBCA;aLCA,AWDA;gB3BDA"}]]}
\ No newline at end of file
packages/react-devtools-extensions/src/__tests__/__source__/__compiled__/external/react-sources-extended/ContainingStringSourceMappingURL.js new
+29
@@ -0,0 +1,29 @@
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports.Component = Component;
7 +
8 +var _react = _interopRequireWildcard(require("react"));
9 +
10 +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
11 +
12 +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
13 +
14 +/**
15 + * Copyright (c) Facebook, Inc. and its affiliates.
16 + *
17 + * This source code is licensed under the MIT license found in the
18 + * LICENSE file in the root directory of this source tree.
19 + *
20 + * @flow
21 + */
22 +// ?sourceMappingURL=([^\s'"]+)/gm
23 +function Component() {
24 + const [count, setCount] = (0, _react.useState)(0);
25 + return /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("p", null, "You clicked ", count, " times"), /*#__PURE__*/_react.default.createElement("button", {
26 + onClick: () => setCount(count + 1)
27 + }, "Click me"));
28 +}
29 +//# sourceMappingURL=ContainingStringSourceMappingURL.js.map
\ No newline at end of file
packages/react-devtools-extensions/src/__tests__/__source__/__compiled__/external/react-sources-extended/ContainingStringSourceMappingURL.js.map new
+1
@@ -0,0 +1 @@
1 +{"version":3,"sources":["ContainingStringSourceMappingURL.js"],"names":["Component","count","setCount"],"mappings":";;;;;;;AASA;;;;;;AATA;;;;;;;;AAWA;AAEO,SAASA,SAAT,GAAqB;AAC1B,QAAM,CAACC,KAAD,EAAQC,QAAR,IAAoB,qBAAS,CAAT,CAA1B;AAEA,sBACE,uDACE,wDAAgBD,KAAhB,WADF,eAEE;AAAQ,IAAA,OAAO,EAAE,MAAMC,QAAQ,CAACD,KAAK,GAAG,CAAT;AAA/B,gBAFF,CADF;AAMD","sourcesContent":["/**\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * @flow\n */\n\nimport React, {useState} from 'react';\n\n// ?sourceMappingURL=([^\\s'\"]+)/gm\n\nexport function Component() {\n const [count, setCount] = useState(0);\n\n return (\n <div>\n <p>You clicked {count} times</p>\n <button onClick={() => setCount(count + 1)}>Click me</button>\n </div>\n );\n}\n"],"x_react_sources":[[{"names":["<no-hook>","count"],"mappings":"CAAD;e4BCA,AWDA"}]]}
\ No newline at end of file
packages/react-devtools-extensions/src/__tests__/__source__/__compiled__/external/react-sources-extended/Example.js new
+28
@@ -0,0 +1,28 @@
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports.Component = Component;
7 +
8 +var _react = _interopRequireWildcard(require("react"));
9 +
10 +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
11 +
12 +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
13 +
14 +/**
15 + * Copyright (c) Facebook, Inc. and its affiliates.
16 + *
17 + * This source code is licensed under the MIT license found in the
18 + * LICENSE file in the root directory of this source tree.
19 + *
20 + * @flow
21 + */
22 +function Component() {
23 + const [count, setCount] = (0, _react.useState)(0);
24 + return /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("p", null, "You clicked ", count, " times"), /*#__PURE__*/_react.default.createElement("button", {
25 + onClick: () => setCount(count + 1)
26 + }, "Click me"));
27 +}
28 +//# sourceMappingURL=Example.js.map
\ No newline at end of file
packages/react-devtools-extensions/src/__tests__/__source__/__compiled__/external/react-sources-extended/Example.js.map new
+1
@@ -0,0 +1 @@
1 +{"version":3,"sources":["Example.js"],"names":["Component","count","setCount"],"mappings":";;;;;;;AASA;;;;;;AATA;;;;;;;;AAWO,SAASA,SAAT,GAAqB;AAC1B,QAAM,CAACC,KAAD,EAAQC,QAAR,IAAoB,qBAAS,CAAT,CAA1B;AAEA,sBACE,uDACE,wDAAgBD,KAAhB,WADF,eAEE;AAAQ,IAAA,OAAO,EAAE,MAAMC,QAAQ,CAACD,KAAK,GAAG,CAAT;AAA/B,gBAFF,CADF;AAMD","sourcesContent":["/**\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * @flow\n */\n\nimport React, {useState} from 'react';\n\nexport function Component() {\n const [count, setCount] = useState(0);\n\n return (\n <div>\n <p>You clicked {count} times</p>\n <button onClick={() => setCount(count + 1)}>Click me</button>\n </div>\n );\n}\n"],"x_react_sources":[[{"names":["<no-hook>","count"],"mappings":"CAAD;a4BCA,AWDA"}]]}
\ No newline at end of file
packages/react-devtools-extensions/src/__tests__/__source__/__compiled__/external/react-sources-extended/InlineRequire.js new
+21
@@ -0,0 +1,21 @@
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports.Component = Component;
7 +
8 +/**
9 + * Copyright (c) Facebook, Inc. and its affiliates.
10 + *
11 + * This source code is licensed under the MIT license found in the
12 + * LICENSE file in the root directory of this source tree.
13 + *
14 + * @flow
15 + */
16 +function Component() {
17 + const [count] = require('react').useState(0);
18 +
19 + return count;
20 +}
21 +//# sourceMappingURL=InlineRequire.js.map
\ No newline at end of file
packages/react-devtools-extensions/src/__tests__/__source__/__compiled__/external/react-sources-extended/InlineRequire.js.map new
+1
@@ -0,0 +1 @@
1 +{"version":3,"sources":["InlineRequire.js"],"names":["Component","count","require","useState"],"mappings":";;;;;;;AAAA;;;;;;;;AASO,SAASA,SAAT,GAAqB;AAC1B,QAAM,CAACC,KAAD,IAAUC,OAAO,CAAC,OAAD,CAAP,CAAiBC,QAAjB,CAA0B,CAA1B,CAAhB;;AAEA,SAAOF,KAAP;AACD","sourcesContent":["/**\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * @flow\n */\n\nexport function Component() {\n const [count] = require('react').useState(0);\n\n return count;\n}\n"],"x_react_sources":[[{"names":["<no-hook>"],"mappings":"CAAD"}]]}
\ No newline at end of file
packages/react-devtools-extensions/src/__tests__/__source__/__compiled__/external/react-sources-extended/ToDoList.js new
+106
@@ -0,0 +1,106 @@
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports.ListItem = ListItem;
7 +exports.List = List;
8 +
9 +var React = _interopRequireWildcard(require("react"));
10 +
11 +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
12 +
13 +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
14 +
15 +/**
16 + * Copyright (c) Facebook, Inc. and its affiliates.
17 + *
18 + * This source code is licensed under the MIT license found in the
19 + * LICENSE file in the root directory of this source tree.
20 + *
21 + * @flow
22 + */
23 +function ListItem({
24 + item,
25 + removeItem,
26 + toggleItem
27 +}) {
28 + const handleDelete = (0, React.useCallback)(() => {
29 + removeItem(item);
30 + }, [item, removeItem]);
31 + const handleToggle = (0, React.useCallback)(() => {
32 + toggleItem(item);
33 + }, [item, toggleItem]);
34 + return /*#__PURE__*/React.createElement("li", null, /*#__PURE__*/React.createElement("button", {
35 + onClick: handleDelete
36 + }, "Delete"), /*#__PURE__*/React.createElement("label", null, /*#__PURE__*/React.createElement("input", {
37 + checked: item.isComplete,
38 + onChange: handleToggle,
39 + type: "checkbox"
40 + }), ' ', item.text));
41 +}
42 +
43 +function List(props) {
44 + const [newItemText, setNewItemText] = (0, React.useState)('');
45 + const [items, setItems] = (0, React.useState)([{
46 + id: 1,
47 + isComplete: true,
48 + text: 'First'
49 + }, {
50 + id: 2,
51 + isComplete: true,
52 + text: 'Second'
53 + }, {
54 + id: 3,
55 + isComplete: false,
56 + text: 'Third'
57 + }]);
58 + const [uid, setUID] = (0, React.useState)(4);
59 + const handleClick = (0, React.useCallback)(() => {
60 + if (newItemText !== '') {
61 + setItems([...items, {
62 + id: uid,
63 + isComplete: false,
64 + text: newItemText
65 + }]);
66 + setUID(uid + 1);
67 + setNewItemText('');
68 + }
69 + }, [newItemText, items, uid]);
70 + const handleKeyPress = (0, React.useCallback)(event => {
71 + if (event.key === 'Enter') {
72 + handleClick();
73 + }
74 + }, [handleClick]);
75 + const handleChange = (0, React.useCallback)(event => {
76 + setNewItemText(event.currentTarget.value);
77 + }, [setNewItemText]);
78 + const removeItem = (0, React.useCallback)(itemToRemove => setItems(items.filter(item => item !== itemToRemove)), [items]);
79 + const toggleItem = (0, React.useCallback)(itemToToggle => {
80 + // Dont use indexOf()
81 + // because editing props in DevTools creates a new Object.
82 + const index = items.findIndex(item => item.id === itemToToggle.id);
83 + setItems(items.slice(0, index).concat({ ...itemToToggle,
84 + isComplete: !itemToToggle.isComplete
85 + }).concat(items.slice(index + 1)));
86 + }, [items]);
87 + return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("h1", null, "List"), /*#__PURE__*/React.createElement("input", {
88 + type: "text",
89 + placeholder: "New list item...",
90 + value: newItemText,
91 + onChange: handleChange,
92 + onKeyPress: handleKeyPress
93 + }), /*#__PURE__*/React.createElement("button", {
94 + disabled: newItemText === '',
95 + onClick: handleClick
96 + }, /*#__PURE__*/React.createElement("span", {
97 + role: "img",
98 + "aria-label": "Add item"
99 + }, "Add")), /*#__PURE__*/React.createElement("ul", null, items.map(item => /*#__PURE__*/React.createElement(ListItem, {
100 + key: item.id,
101 + item: item,
102 + removeItem: removeItem,
103 + toggleItem: toggleItem
104 + }))));
105 +}
106 +//# sourceMappingURL=ToDoList.js.map
\ No newline at end of file
packages/react-devtools-extensions/src/__tests__/__source__/__compiled__/external/react-sources-extended/ToDoList.js.map new
+1
@@ -0,0 +1 @@
1 +{"version":3,"sources":["ToDoList.js"],"names":["ListItem","item","removeItem","toggleItem","handleDelete","handleToggle","isComplete","text","List","props","newItemText","setNewItemText","items","setItems","id","uid","setUID","handleClick","handleKeyPress","event","key","handleChange","currentTarget","value","itemToRemove","filter","itemToToggle","index","findIndex","slice","concat","map"],"mappings":";;;;;;;;AASA;;;;;;AATA;;;;;;;;AAYO,SAASA,QAAT,CAAkB;AAACC,EAAAA,IAAD;AAAOC,EAAAA,UAAP;AAAmBC,EAAAA;AAAnB,CAAlB,EAAkD;AACvD,QAAMC,YAAY,GAAG,uBAAY,MAAM;AACrCF,IAAAA,UAAU,CAACD,IAAD,CAAV;AACD,GAFoB,EAElB,CAACA,IAAD,EAAOC,UAAP,CAFkB,CAArB;AAIA,QAAMG,YAAY,GAAG,uBAAY,MAAM;AACrCF,IAAAA,UAAU,CAACF,IAAD,CAAV;AACD,GAFoB,EAElB,CAACA,IAAD,EAAOE,UAAP,CAFkB,CAArB;AAIA,sBACE,6CACE;AAAQ,IAAA,OAAO,EAAEC;AAAjB,cADF,eAEE,gDACE;AACE,IAAA,OAAO,EAAEH,IAAI,CAACK,UADhB;AAEE,IAAA,QAAQ,EAAED,YAFZ;AAGE,IAAA,IAAI,EAAC;AAHP,IADF,EAKK,GALL,EAMGJ,IAAI,CAACM,IANR,CAFF,CADF;AAaD;;AAEM,SAASC,IAAT,CAAcC,KAAd,EAAqB;AAC1B,QAAM,CAACC,WAAD,EAAcC,cAAd,IAAgC,oBAAS,EAAT,CAAtC;AACA,QAAM,CAACC,KAAD,EAAQC,QAAR,IAAoB,oBAAS,CACjC;AAACC,IAAAA,EAAE,EAAE,CAAL;AAAQR,IAAAA,UAAU,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,KAAD,CAFiB,CAAnB;AAKA,QAAMT,UAAU,GAAG,uBACjBuB,YAAY,IAAI;AACd;AACA;AACA,UAAMC,KAAK,GAAGf,KAAK,CAACgB,SAAN,CAAgB3B,IAAI,IAAIA,IAAI,CAACa,EAAL,KAAYY,YAAY,CAACZ,EAAjD,CAAd;AAEAD,IAAAA,QAAQ,CACND,KAAK,CACFiB,KADH,CACS,CADT,EACYF,KADZ,EAEGG,MAFH,CAEU,EACN,GAAGJ,YADG;AAENpB,MAAAA,UAAU,EAAE,CAACoB,YAAY,CAACpB;AAFpB,KAFV,EAMGwB,MANH,CAMUlB,KAAK,CAACiB,KAAN,CAAYF,KAAK,GAAG,CAApB,CANV,CADM,CAAR;AASD,GAfgB,EAgBjB,CAACf,KAAD,CAhBiB,CAAnB;AAmBA,sBACE,oBAAC,cAAD,qBACE,uCADF,eAEE;AACE,IAAA,IAAI,EAAC,MADP;AAEE,IAAA,WAAW,EAAC,kBAFd;AAGE,IAAA,KAAK,EAAEF,WAHT;AAIE,IAAA,QAAQ,EAAEW,YAJZ;AAKE,IAAA,UAAU,EAAEH;AALd,IAFF,eASE;AAAQ,IAAA,QAAQ,EAAER,WAAW,KAAK,EAAlC;AAAsC,IAAA,OAAO,EAAEO;AAA/C,kBACE;AAAM,IAAA,IAAI,EAAC,KAAX;AAAiB,kBAAW;AAA5B,WADF,CATF,eAcE,gCACGL,KAAK,CAACmB,GAAN,CAAU9B,IAAI,iBACb,oBAAC,QAAD;AACE,IAAA,GAAG,EAAEA,IAAI,CAACa,EADZ;AAEE,IAAA,IAAI,EAAEb,IAFR;AAGE,IAAA,UAAU,EAAEC,UAHd;AAIE,IAAA,UAAU,EAAEC;AAJd,IADD,CADH,CAdF,CADF;AA2BD","sourcesContent":["/**\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * @flow\n */\n\nimport * as React from 'react';\nimport {Fragment, useCallback, useState} from 'react';\n\nexport function ListItem({item, removeItem, toggleItem}) {\n const handleDelete = useCallback(() => {\n removeItem(item);\n }, [item, removeItem]);\n\n const handleToggle = useCallback(() => {\n toggleItem(item);\n }, [item, toggleItem]);\n\n return (\n <li>\n <button onClick={handleDelete}>Delete</button>\n <label>\n <input\n checked={item.isComplete}\n onChange={handleToggle}\n type=\"checkbox\"\n />{' '}\n {item.text}\n </label>\n </li>\n );\n}\n\nexport function List(props) {\n const [newItemText, setNewItemText] = useState('');\n const [items, setItems] = useState([\n {id: 1, isComplete: true, text: 'First'},\n {id: 2, isComplete: true, text: 'Second'},\n {id: 3, isComplete: false, text: 'Third'},\n ]);\n const [uid, setUID] = useState(4);\n\n const handleClick = useCallback(() => {\n if (newItemText !== '') {\n setItems([\n ...items,\n {\n id: uid,\n isComplete: false,\n text: newItemText,\n },\n ]);\n setUID(uid + 1);\n setNewItemText('');\n }\n }, [newItemText, items, uid]);\n\n const handleKeyPress = useCallback(\n event => {\n if (event.key === 'Enter') {\n handleClick();\n }\n },\n [handleClick],\n );\n\n const handleChange = useCallback(\n event => {\n setNewItemText(event.currentTarget.value);\n },\n [setNewItemText],\n );\n\n const removeItem = useCallback(\n itemToRemove => setItems(items.filter(item => item !== itemToRemove)),\n [items],\n );\n\n const toggleItem = useCallback(\n itemToToggle => {\n // Dont use indexOf()\n // because editing props in DevTools creates a new Object.\n const index = items.findIndex(item => item.id === itemToToggle.id);\n\n setItems(\n items\n .slice(0, index)\n .concat({\n ...itemToToggle,\n isComplete: !itemToToggle.isComplete,\n })\n .concat(items.slice(index + 1)),\n );\n },\n [items],\n );\n\n return (\n <Fragment>\n <h1>List</h1>\n <input\n type=\"text\"\n placeholder=\"New list item...\"\n value={newItemText}\n onChange={handleChange}\n onKeyPress={handleKeyPress}\n />\n <button disabled={newItemText === ''} onClick={handleClick}>\n <span role=\"img\" aria-label=\"Add item\">\n Add\n </span>\n </button>\n <ul>\n {items.map(item => (\n <ListItem\n key={item.id}\n item={item}\n removeItem={removeItem}\n toggleItem={toggleItem}\n />\n ))}\n </ul>\n </Fragment>\n );\n}\n"],"x_react_sources":[[{"names":["<no-hook>","handleDelete","handleToggle","newItemText","items","uid","handleClick","handleKeyPress","handleChange","removeItem","toggleItem"],"mappings":"CAAD;cuBCA;gBCDA;kBDEA;oBCFA;sCgBGA,AYHA;uCxBIA;2CxBJA;4CoBKA,AWLA;8CbMA;2DSNA;6DNOA;oEtBPA;sEoBQA;2EpBRA;6EkBSA;gFlBTA;kFkBUA;mGlBVA"}]]}
\ No newline at end of file
packages/react-devtools-extensions/src/__tests__/__source__/__compiled__/external/react-sources-extended/index.js new
+89
@@ -0,0 +1,89 @@
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +Object.defineProperty(exports, "ComponentUsingHooksIndirectly", {
7 + enumerable: true,
8 + get: function () {
9 + return _ComponentUsingHooksIndirectly.Component;
10 + }
11 +});
12 +Object.defineProperty(exports, "ComponentWithCustomHook", {
13 + enumerable: true,
14 + get: function () {
15 + return _ComponentWithCustomHook.Component;
16 + }
17 +});
18 +Object.defineProperty(exports, "ComponentWithExternalCustomHooks", {
19 + enumerable: true,
20 + get: function () {
21 + return _ComponentWithExternalCustomHooks.Component;
22 + }
23 +});
24 +Object.defineProperty(exports, "ComponentWithMultipleHooksPerLine", {
25 + enumerable: true,
26 + get: function () {
27 + return _ComponentWithMultipleHooksPerLine.Component;
28 + }
29 +});
30 +Object.defineProperty(exports, "ComponentWithNestedHooks", {
31 + enumerable: true,
32 + get: function () {
33 + return _ComponentWithNestedHooks.Component;
34 + }
35 +});
36 +Object.defineProperty(exports, "ContainingStringSourceMappingURL", {
37 + enumerable: true,
38 + get: function () {
39 + return _ContainingStringSourceMappingURL.Component;
40 + }
41 +});
42 +Object.defineProperty(exports, "Example", {
43 + enumerable: true,
44 + get: function () {
45 + return _Example.Component;
46 + }
47 +});
48 +Object.defineProperty(exports, "InlineRequire", {
49 + enumerable: true,
50 + get: function () {
51 + return _InlineRequire.Component;
52 + }
53 +});
54 +Object.defineProperty(exports, "useTheme", {
55 + enumerable: true,
56 + get: function () {
57 + return _useTheme.default;
58 + }
59 +});
60 +exports.ToDoList = void 0;
61 +
62 +var _ComponentUsingHooksIndirectly = require("./ComponentUsingHooksIndirectly");
63 +
64 +var _ComponentWithCustomHook = require("./ComponentWithCustomHook");
65 +
66 +var _ComponentWithExternalCustomHooks = require("./ComponentWithExternalCustomHooks");
67 +
68 +var _ComponentWithMultipleHooksPerLine = require("./ComponentWithMultipleHooksPerLine");
69 +
70 +var _ComponentWithNestedHooks = require("./ComponentWithNestedHooks");
71 +
72 +var _ContainingStringSourceMappingURL = require("./ContainingStringSourceMappingURL");
73 +
74 +var _Example = require("./Example");
75 +
76 +var _InlineRequire = require("./InlineRequire");
77 +
78 +var ToDoList = _interopRequireWildcard(require("./ToDoList"));
79 +
80 +exports.ToDoList = ToDoList;
81 +
82 +var _useTheme = _interopRequireDefault(require("./useTheme"));
83 +
84 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
85 +
86 +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
87 +
88 +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
89 +//# sourceMappingURL=index.js.map
\ No newline at end of file
packages/react-devtools-extensions/src/__tests__/__source__/__compiled__/external/react-sources-extended/index.js.map new
+1
@@ -0,0 +1 @@
1 +{"version":3,"sources":["index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;AAEA","sourcesContent":["/**\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * @flow\n */\n\nexport {Component as ComponentUsingHooksIndirectly} from './ComponentUsingHooksIndirectly';\nexport {Component as ComponentWithCustomHook} from './ComponentWithCustomHook';\nexport {Component as ComponentWithExternalCustomHooks} from './ComponentWithExternalCustomHooks';\nexport {Component as ComponentWithMultipleHooksPerLine} from './ComponentWithMultipleHooksPerLine';\nexport {Component as ComponentWithNestedHooks} from './ComponentWithNestedHooks';\nexport {Component as ContainingStringSourceMappingURL} from './ContainingStringSourceMappingURL';\nexport {Component as Example} from './Example';\nexport {Component as InlineRequire} from './InlineRequire';\nimport * as ToDoList from './ToDoList';\nexport {ToDoList};\nexport {default as useTheme} from './useTheme';\n"],"x_react_sources":[[{"names":["<no-hook>"],"mappings":"CAAD"}]]}
\ No newline at end of file
packages/react-devtools-extensions/src/__tests__/__source__/__compiled__/external/react-sources-extended/useTheme.js new
+27
@@ -0,0 +1,27 @@
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports.default = useTheme;
7 +exports.ThemeContext = void 0;
8 +
9 +var _react = require("react");
10 +
11 +/**
12 + * Copyright (c) Facebook, Inc. and its affiliates.
13 + *
14 + * This source code is licensed under the MIT license found in the
15 + * LICENSE file in the root directory of this source tree.
16 + *
17 + * @flow
18 + */
19 +const ThemeContext = /*#__PURE__*/(0, _react.createContext)('bright');
20 +exports.ThemeContext = ThemeContext;
21 +
22 +function useTheme() {
23 + const theme = (0, _react.useContext)(ThemeContext);
24 + (0, _react.useDebugValue)(theme);
25 + return theme;
26 +}
27 +//# sourceMappingURL=useTheme.js.map
\ No newline at end of file
packages/react-devtools-extensions/src/__tests__/__source__/__compiled__/external/react-sources-extended/useTheme.js.map new
+1
@@ -0,0 +1 @@
1 +{"version":3,"sources":["useTheme.js"],"names":["ThemeContext","useTheme","theme"],"mappings":";;;;;;;;AASA;;AATA;;;;;;;;AAWO,MAAMA,YAAY,gBAAG,0BAAc,QAAd,CAArB;;;AAEQ,SAASC,QAAT,GAAoB;AACjC,QAAMC,KAAK,GAAG,uBAAWF,YAAX,CAAd;AACA,4BAAcE,KAAd;AACA,SAAOA,KAAP;AACD","sourcesContent":["/**\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * @flow\n */\n\nimport {createContext, useContext, useDebugValue} from 'react';\n\nexport const ThemeContext = createContext('bright');\n\nexport default function useTheme() {\n const theme = useContext(ThemeContext);\n useDebugValue(theme);\n return theme;\n}\n"],"x_react_sources":[[{"names":["<no-hook>","theme"],"mappings":"CAAD;egBCA,AwBDA"}]]}
\ No newline at end of file
packages/react-devtools-extensions/src/__tests__/__source__/__compiled__/inline/fb-sources-extended/ComponentUsingHooksIndirectly.js new
+45
@@ -0,0 +1,45 @@
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports.Component = Component;
7 +
8 +var _react = _interopRequireWildcard(require("react"));
9 +
10 +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
11 +
12 +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
13 +
14 +/**
15 + * Copyright (c) Facebook, Inc. and its affiliates.
16 + *
17 + * This source code is licensed under the MIT license found in the
18 + * LICENSE file in the root directory of this source tree.
19 + *
20 + * @flow
21 + */
22 +function Component() {
23 + const countState = (0, _react.useState)(0);
24 + const count = countState[0];
25 + const setCount = countState[1];
26 + const darkMode = useIsDarkMode();
27 + const [isDarkMode] = darkMode;
28 + (0, _react.useEffect)(() => {// ...
29 + }, []);
30 +
31 + const handleClick = () => setCount(count + 1);
32 +
33 + return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", null, "Dark mode? ", isDarkMode), /*#__PURE__*/_react.default.createElement("div", null, "Count: ", count), /*#__PURE__*/_react.default.createElement("button", {
34 + onClick: handleClick
35 + }, "Update count"));
36 +}
37 +
38 +function useIsDarkMode() {
39 + const darkModeState = (0, _react.useState)(false);
40 + const [isDarkMode] = darkModeState;
41 + (0, _react.useEffect)(function useEffectCreate() {// Here is where we may listen to a "theme" event...
42 + }, []);
43 + return [isDarkMode, () => {}];
44 +}
45 +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIkNvbXBvbmVudFVzaW5nSG9va3NJbmRpcmVjdGx5LmpzIl0sIm5hbWVzIjpbIkNvbXBvbmVudCIsImNvdW50U3RhdGUiLCJjb3VudCIsInNldENvdW50IiwiZGFya01vZGUiLCJ1c2VJc0RhcmtNb2RlIiwiaXNEYXJrTW9kZSIsImhhbmRsZUNsaWNrIiwiZGFya01vZGVTdGF0ZSIsInVzZUVmZmVjdENyZWF0ZSJdLCJtYXBwaW5ncyI6Ijs7Ozs7OztBQVNBOzs7Ozs7QUF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cIiBldmVudC4uLlxuICB9LCBbXSk7XG5cbiAgcmV0dXJuIFtpc0RhcmtNb2RlLCAoKSA9PiB7fV07XG59XG4iXSwieF9mYl9zb3VyY2VzIjpbW251bGwseyJuYW1lcyI6WyI8bm8taG9vaz4iLCJjb3VudCIsImRhcmtNb2RlIiwiaXNEYXJrTW9kZSJdLCJtYXBwaW5ncyI6IkNBQUQ7YXFCQ0EsQVdEQTtpQmJFQSxBZUZBO29DVkdBLEFlSEEifV1dfQ==
\ No newline at end of file
packages/react-devtools-extensions/src/__tests__/__source__/__compiled__/inline/fb-sources-extended/ComponentWithCustomHook.js new
+41
@@ -0,0 +1,41 @@
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports.Component = Component;
7 +
8 +var _react = _interopRequireWildcard(require("react"));
9 +
10 +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
11 +
12 +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
13 +
14 +/**
15 + * Copyright (c) Facebook, Inc. and its affiliates.
16 + *
17 + * This source code is licensed under the MIT license found in the
18 + * LICENSE file in the root directory of this source tree.
19 + *
20 + * @flow
21 + */
22 +function Component() {
23 + const [count, setCount] = (0, _react.useState)(0);
24 + const isDarkMode = useIsDarkMode();
25 + (0, _react.useEffect)(() => {// ...
26 + }, []);
27 +
28 + const handleClick = () => setCount(count + 1);
29 +
30 + return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", null, "Dark mode? ", isDarkMode), /*#__PURE__*/_react.default.createElement("div", null, "Count: ", count), /*#__PURE__*/_react.default.createElement("button", {
31 + onClick: handleClick
32 + }, "Update count"));
33 +}
34 +
35 +function useIsDarkMode() {
36 + const [isDarkMode] = (0, _react.useState)(false);
37 + (0, _react.useEffect)(function useEffectCreate() {// Here is where we may listen to a "theme" event...
38 + }, []);
39 + return isDarkMode;
40 +}
41 +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIkNvbXBvbmVudFdpdGhDdXN0b21Ib29rLmpzIl0sIm5hbWVzIjpbIkNvbXBvbmVudCIsImNvdW50Iiwic2V0Q291bnQiLCJpc0RhcmtNb2RlIiwidXNlSXNEYXJrTW9kZSIsImhhbmRsZUNsaWNrIiwidXNlRWZmZWN0Q3JlYXRlIl0sIm1hcHBpbmdzIjoiOzs7Ozs7O0FBU0E7Ozs7OztBQVRBOzs7Ozs7OztBQVdPLFNBQVNBLFNBQVQsR0FBcUI7QUFDMUIsUUFBTSxDQUFDQyxLQUFELEVBQVFDLFFBQVIsSUFBb0IscUJBQVMsQ0FBVCxDQUExQjtBQUNBLFFBQU1DLFVBQVUsR0FBR0MsYUFBYSxFQUFoQztBQUVBLHdCQUFVLE1BQU0sQ0FDZDtBQUNELEdBRkQsRUFFRyxFQUZIOztBQUlBLFFBQU1DLFdBQVcsR0FBRyxNQUFNSCxRQUFRLENBQUNELEtBQUssR0FBRyxDQUFULENBQWxDOztBQUVBLHNCQUNFLHlFQUNFLHlEQUFpQkUsVUFBakIsQ0FERixlQUVFLHFEQUFhRixLQUFiLENBRkYsZUFHRTtBQUFRLElBQUEsT0FBTyxFQUFFSTtBQUFqQixvQkFIRixDQURGO0FBT0Q7O0FBRUQsU0FBU0QsYUFB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biB1c2VJc0RhcmtNb2RlKCkge1xuICBjb25zdCBbaXNEYXJrTW9kZV0gPSB1c2VTdGF0ZShmYWxzZSk7XG5cbiAgdXNlRWZmZWN0KGZ1bmN0aW9uIHVzZUVmZmVjdENyZWF0ZSgpIHtcbiAgICAvLyBIZXJlIGlzIHdoZXJlIHdlIG1heSBsaXN0ZW4gdG8gYSBcInRoZW1lXCIgZXZlbnQuLi5cbiAgfSwgW10pO1xuXG4gIHJldHVybiBpc0RhcmtNb2RlO1xufVxuIl0sInhfZmJfc291cmNlcyI6W1tudWxsLHsibmFtZXMiOlsiPG5vLWhvb2s+IiwiY291bnQiLCJpc0RhcmtNb2RlIl0sIm1hcHBpbmdzIjoiQ0FBRDthNEJDQSxBV0RBO2NsQkVBLEFlRkE7Z0NiRUEsQWVGQSJ9XV19
\ No newline at end of file
packages/react-devtools-extensions/src/__tests__/__source__/__compiled__/inline/fb-sources-extended/ComponentWithExternalCustomHooks.js new
+26
@@ -0,0 +1,26 @@
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports.Component = Component;
7 +
8 +var _react = _interopRequireDefault(require("react"));
9 +
10 +var _useTheme = _interopRequireDefault(require("./useTheme"));
11 +
12 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13 +
14 +/**
15 + * Copyright (c) Facebook, Inc. and its affiliates.
16 + *
17 + * This source code is licensed under the MIT license found in the
18 + * LICENSE file in the root directory of this source tree.
19 + *
20 + * @flow
21 + */
22 +function Component() {
23 + const theme = (0, _useTheme.default)();
24 + return /*#__PURE__*/_react.default.createElement("div", null, "theme: ", theme);
25 +}
26 +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIkNvbXBvbmVudFdpdGhFeHRlcm5hbEN1c3RvbUhvb2tzLmpzIl0sIm5hbWVzIjpbIkNvbXBvbmVudCIsInRoZW1lIl0sIm1hcHBpbmdzIjoiOzs7Ozs7O0FBU0E7O0FBQ0E7Ozs7QUFWQTs7Ozs7Ozs7QUFZTyxTQUFTQSxTQUFULEdBQXFCO0FBQzFCLFFBQU1DLEtBQUssR0FBRyx3QkFBZDtBQUVBLHNCQUFPLHFEQUFhQSxLQUFiLENBQVA7QUFDRCIsInNvdXJjZXNDb250ZW50IjpbIi8qKlxuICogQ29weXJpZ2h0IChjKSBGYWNlYm9vaywgSW5jLiBhbmQgaXRzIGFmZmlsaWF0ZXMuXG4gKlxuICogVGhpcyBzb3VyY2UgY29kZSBpcyBsaWNlbnNlZCB1bmRlciB0aGUgTUlUIGxpY2Vuc2UgZm91bmQgaW4gdGhlXG4gKiBMSUNFTlNFIGZpbGUgaW4gdGhlIHJvb3QgZGlyZWN0b3J5IG9mIHRoaXMgc291cmNlIHRyZWUuXG4gKlxuICogQGZsb3dcbiAqL1xuXG5pbXBvcnQgUmVhY3QgZnJvbSAncmVhY3QnO1xuaW1wb3J0IHVzZVRoZW1lIGZyb20gJy4vdXNlVGhlbWUnO1xuXG5leHBvcnQgZnVuY3Rpb24gQ29tcG9uZW50KCkge1xuICBjb25zdCB0aGVtZSA9IHVzZVRoZW1lKCk7XG5cbiAgcmV0dXJuIDxkaXY+dGhlbWU6IHt0aGVtZX08L2Rpdj47XG59XG4iXSwieF9mYl9zb3VyY2VzIjpbW251bGwseyJuYW1lcyI6WyI8bm8taG9vaz4iLCJ0aGVtZSJdLCJtYXBwaW5ncyI6IkNBQUQ7Y2dCQ0EsQVVEQSJ9XV19
\ No newline at end of file
packages/react-devtools-extensions/src/__tests__/__source__/__compiled__/inline/fb-sources-extended/ComponentWithMultipleHooksPerLine.js new
+30
@@ -0,0 +1,30 @@
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports.Component = Component;
7 +
8 +var _react = require("react");
9 +
10 +/**
11 + * Copyright (c) Facebook, Inc. and its affiliates.
12 + *
13 + * This source code is licensed under the MIT license found in the
14 + * LICENSE file in the root directory of this source tree.
15 + *
16 + * @flow
17 + */
18 +const A = /*#__PURE__*/(0, _react.createContext)(1);
19 +const B = /*#__PURE__*/(0, _react.createContext)(2);
20 +
21 +function Component() {
22 + const a = (0, _react.useContext)(A);
23 + const b = (0, _react.useContext)(B); // prettier-ignore
24 +
25 + const c = (0, _react.useContext)(A),
26 + d = (0, _react.useContext)(B); // eslint-disable-line one-var
27 +
28 + return a + b + c + d;
29 +}
30 +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIkNvbXBvbmVudFdpdGhNdWx0aXBsZUhvb2tzUGVyTGluZS5qcyJdLCJuYW1lcyI6WyJBIiwiQiIsIkNvbXBvbmVudCIsImEiLCJiIiwiYyIsImQiXSwibWFwcGluZ3MiOiI7Ozs7Ozs7QUFTQTs7QUFUQTs7Ozs7Ozs7QUFXQSxNQUFNQSxDQUFDLGdCQUFHLDBCQUFjLENBQWQsQ0FBVjtBQUNBLE1BQU1DLENBQUMsZ0JBQUcsMEJBQWMsQ0FBZCxDQUFWOztBQUVPLFNBQVNDLFNBQVQsR0FBcUI7QUFDMUIsUUFBTUMsQ0FBQyxHQUFHLHVCQUFXSCxDQUFYLENBQVY7QUFDQSxRQUFNSSxDQUFDLEdBQUcsdUJBQVdILENBQVgsQ0FBVixDQUYwQixDQUkxQjs7QUFDQSxRQUFNSSxDQUFDLEdBQUcsdUJBQVdMLENBQVgsQ0FBVjtBQUFBLFFBQXlCTSxDQUFDLEdBQUcsdUJBQVdMLENBQVgsQ0FBN0IsQ0FMMEIsQ0FLa0I7O0FBRTVDLFNBQU9FLENBQUMsR0FBR0MsQ0FBSixHQUFRQyxDQUFSLEdBQVlDLENBQW5CO0FBQ0QiLCJzb3VyY2VzQ29udGVudCI6WyIvKipcbiAqIENvcHlyaWdodCAoYykgRmFjZWJvb2ssIEluYy4gYW5kIGl0cyBhZmZpbGlhdGVzLlxuICpcbiAqIFRoaXMgc291cmNlIGNvZGUgaXMgbGljZW5zZWQgdW5kZXIgdGhlIE1JVCBsaWNlbnNlIGZvdW5kIGluIHRoZVxuICogTElDRU5TRSBmaWxlIGluIHRoZSByb290IGRpcmVjdG9yeSBvZiB0aGlzIHNvdXJjZSB0cmVlLlxuICpcbiAqIEBmbG93XG4gKi9cblxuaW1wb3J0IHtjcmVhdGVDb250ZXh0LCB1c2VDb250ZXh0fSBmcm9tICdyZWFjdCc7XG5cbmNvbnN0IEEgPSBjcmVhdGVDb250ZXh0KDEpO1xuY29uc3QgQiA9IGNyZWF0ZUNvbnRleHQoMik7XG5cbmV4cG9ydCBmdW5jdGlvbiBDb21wb25lbnQoKSB7XG4gIGNvbnN0IGEgPSB1c2VDb250ZXh0KEEpO1xuICBjb25zdCBiID0gdXNlQ29udGV4dChCKTtcblxuICAvLyBwcmV0dGllci1pZ25vcmVcbiAgY29uc3QgYyA9IHVzZUNvbnRleHQoQSksIGQgPSB1c2VDb250ZXh0KEIpOyAvLyBlc2xpbnQtZGlzYWJsZS1saW5lIG9uZS12YXJcblxuICByZXR1cm4gYSArIGIgKyBjICsgZDtcbn1cbiJdLCJ4X2ZiX3NvdXJjZXMiOltbbnVsbCx7Im5hbWVzIjpbIjxuby1ob29rPiIsImEiLCJiIiwiYyIsImQiXSwibWFwcGluZ3MiOiJDQUFEO2dCWUNBLEFhREE7aUJiRUEsQWFGQTtvQmJHQSxBYUhBLEFNSUEsQWFKQSJ9XV19
\ No newline at end of file
packages/react-devtools-extensions/src/__tests__/__source__/__compiled__/inline/fb-sources-extended/ComponentWithNestedHooks.js new
+28
@@ -0,0 +1,28 @@
1 +"use strict";
2 +
3 +/**
4 + * Copyright (c) Facebook, Inc. and its affiliates.
5 + *
6 + * This source code is licensed under the MIT license found in the
7 + * LICENSE file in the root directory of this source tree.
8 + *
9 + * @flow
10 + */
11 +const {
12 + useMemo,
13 + useState
14 +} = require('react');
15 +
16 +function Component(props) {
17 + const InnerComponent = useMemo(() => () => {
18 + const [state] = useState(0);
19 + return state;
20 + });
21 + props.callback(InnerComponent);
22 + return null;
23 +}
24 +
25 +module.exports = {
26 + Component
27 +};
28 +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIkNvbXBvbmVudFdpdGhOZXN0ZWRIb29rcy5qcyJdLCJuYW1lcyI6WyJ1c2VNZW1vIiwidXNlU3RhdGUiLCJyZXF1aXJlIiwiQ29tcG9uZW50IiwicHJvcHMiLCJJbm5lckNvbXBvbmVudCIsInN0YXRlIiwiY2FsbGJhY2siLCJtb2R1bGUiLCJleHBvcnRzIl0sIm1hcHBpbmdzIjoiOztBQUFBOzs7Ozs7OztBQVFBLE1BQU07QUFBQ0EsRUFBQUEsT0FBRDtBQUFVQyxFQUFBQTtBQUFWLElBQXNCQyxPQUFPLENBQUMsT0FBRCxDQUFuQzs7QUFFQSxTQUFTQyxTQUFULENBQW1CQyxLQUFuQixFQUEwQjtBQUN4QixRQUFNQyxjQUFjLEdBQUdMLE9BQU8sQ0FBQyxNQUFNLE1BQU07QUFDekMsVUFBTSxDQUFDTSxLQUFELElBQVVMLFFBQVEsQ0FBQyxDQUFELENBQXhCO0FBRUEsV0FBT0ssS0FBUDtBQUNELEdBSjZCLENBQTlCO0FBS0FGLEVBQUFBLEtBQUssQ0FBQ0csUUFBTixDQUFlRixjQUFmO0FBRUEsU0FBTyxJQUFQO0FBQ0Q7O0FBRURHLE1BQU0sQ0FBQ0MsT0FBUCxHQUFpQjtBQUFDTixFQUFBQTtBQUFELENBQWpCIiwic291cmNlc0NvbnRlbnQiOlsiLyoqXG4gKiBDb3B5cmlnaHQgKGMpIEZhY2Vib29rLCBJbmMuIGFuZCBpdHMgYWZmaWxpYXRlcy5cbiAqXG4gKiBUaGlzIHNvdXJjZSBjb2RlIGlzIGxpY2Vuc2VkIHVuZGVyIHRoZSBNSVQgbGljZW5zZSBmb3VuZCBpbiB0aGVcbiAqIExJQ0VOU0UgZmlsZSBpbiB0aGUgcm9vdCBkaXJlY3Rvcnkgb2YgdGhpcyBzb3VyY2UgdHJlZS5cbiAqXG4gKiBAZmxvd1xuICovXG5jb25zdCB7dXNlTWVtbywgdXNlU3RhdGV9ID0gcmVxdWlyZSgncmVhY3QnKTtcblxuZnVuY3Rpb24gQ29tcG9uZW50KHByb3BzKSB7XG4gIGNvbnN0IElubmVyQ29tcG9uZW50ID0gdXNlTWVtbygoKSA9PiAoKSA9PiB7XG4gICAgY29uc3QgW3N0YXRlXSA9IHVzZVN0YXRlKDApO1xuXG4gICAgcmV0dXJuIHN0YXRlO1xuICB9KTtcbiAgcHJvcHMuY2FsbGJhY2soSW5uZXJDb21wb25lbnQpO1xuXG4gIHJldHVybiBudWxsO1xufVxuXG5tb2R1bGUuZXhwb3J0cyA9IHtDb21wb25lbnR9O1xuIl0sInhfZmJfc291cmNlcyI6W1tudWxsLHsibmFtZXMiOlsiPG5vLWhvb2s+IiwiSW5uZXJDb21wb25lbnQiLCJzdGF0ZSJdLCJtYXBwaW5ncyI6IkNBQUQ7WXlCQ0E7YUxDQSxBV0RBO2dCM0JEQSJ9XV19
\ No newline at end of file
packages/react-devtools-extensions/src/__tests__/__source__/__compiled__/inline/fb-sources-extended/ContainingStringSourceMappingURL.js new
+29
@@ -0,0 +1,29 @@
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports.Component = Component;
7 +
8 +var _react = _interopRequireWildcard(require("react"));
9 +
10 +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
11 +
12 +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
13 +
14 +/**
15 + * Copyright (c) Facebook, Inc. and its affiliates.
16 + *
17 + * This source code is licensed under the MIT license found in the
18 + * LICENSE file in the root directory of this source tree.
19 + *
20 + * @flow
21 + */
22 +// ?sourceMappingURL=([^\s'"]+)/gm
23 +function Component() {
24 + const [count, setCount] = (0, _react.useState)(0);
25 + return /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("p", null, "You clicked ", count, " times"), /*#__PURE__*/_react.default.createElement("button", {
26 + onClick: () => setCount(count + 1)
27 + }, "Click me"));
28 +}
29 +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIkNvbnRhaW5pbmdTdHJpbmdTb3VyY2VNYXBwaW5nVVJMLmpzIl0sIm5hbWVzIjpbIkNvbXBvbmVudCIsImNvdW50Iiwic2V0Q291bnQiXSwibWFwcGluZ3MiOiI7Ozs7Ozs7QUFTQTs7Ozs7O0FBVEE7Ozs7Ozs7O0FBV0E7QUFFTyxTQUFTQSxTQUFULEdBQXFCO0FBQzFCLFFBQU0sQ0FBQ0MsS0FBRCxFQUFRQyxRQUFSLElBQW9CLHFCQUFTLENBQVQsQ0FBMUI7QUFFQSxzQkFDRSx1REFDRSx3REFBZ0JELEtBQWhCLFdBREYsZUFFRTtBQUFRLElBQUEsT0FBTyxFQUFFLE1BQU1DLFFBQVEsQ0FBQ0QsS0FBSyxHQUFHLENBQVQ7QUFBL0IsZ0JBRkYsQ0FERjtBQU1EIiwic291cmNlc0NvbnRlbnQiOlsiLyoqXG4gKiBDb3B5cmlnaHQgKGMpIEZhY2Vib29rLCBJbmMuIGFuZCBpdHMgYWZmaWxpYXRlcy5cbiAqXG4gKiBUaGlzIHNvdXJjZSBjb2RlIGlzIGxpY2Vuc2VkIHVuZGVyIHRoZSBNSVQgbGljZW5zZSBmb3VuZCBpbiB0aGVcbiAqIExJQ0VOU0UgZmlsZSBpbiB0aGUgcm9vdCBkaXJlY3Rvcnkgb2YgdGhpcyBzb3VyY2UgdHJlZS5cbiAqXG4gKiBAZmxvd1xuICovXG5cbmltcG9ydCBSZWFjdCwge3VzZVN0YXRlfSBmcm9tICdyZWFjdCc7XG5cbi8vID9zb3VyY2VNYXBwaW5nVVJMPShbXlxccydcIl0rKS9nbVxuXG5leHBvcnQgZnVuY3Rpb24gQ29tcG9uZW50KCkge1xuICBjb25zdCBbY291bnQsIHNldENvdW50XSA9IHVzZVN0YXRlKDApO1xuXG4gIHJldHVybiAoXG4gICAgPGRpdj5cbiAgICAgIDxwPllvdSBjbGlja2VkIHtjb3VudH0gdGltZXM8L3A+XG4gICAgICA8YnV0dG9uIG9uQ2xpY2s9eygpID0+IHNldENvdW50KGNvdW50ICsgMSl9PkNsaWNrIG1lPC9idXR0b24+XG4gICAgPC9kaXY+XG4gICk7XG59XG4iXSwieF9mYl9zb3VyY2VzIjpbW251bGwseyJuYW1lcyI6WyI8bm8taG9vaz4iLCJjb3VudCJdLCJtYXBwaW5ncyI6IkNBQUQ7ZTRCQ0EsQVdEQSJ9XV19
\ No newline at end of file
packages/react-devtools-extensions/src/__tests__/__source__/__compiled__/inline/fb-sources-extended/Example.js new
+28
@@ -0,0 +1,28 @@
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports.Component = Component;
7 +
8 +var _react = _interopRequireWildcard(require("react"));
9 +
10 +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
11 +
12 +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
13 +
14 +/**
15 + * Copyright (c) Facebook, Inc. and its affiliates.
16 + *
17 + * This source code is licensed under the MIT license found in the
18 + * LICENSE file in the root directory of this source tree.
19 + *
20 + * @flow
21 + */
22 +function Component() {
23 + const [count, setCount] = (0, _react.useState)(0);
24 + return /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("p", null, "You clicked ", count, " times"), /*#__PURE__*/_react.default.createElement("button", {
25 + onClick: () => setCount(count + 1)
26 + }, "Click me"));
27 +}
28 +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIkV4YW1wbGUuanMiXSwibmFtZXMiOlsiQ29tcG9uZW50IiwiY291bnQiLCJzZXRDb3VudCJdLCJtYXBwaW5ncyI6Ijs7Ozs7OztBQVNBOzs7Ozs7QUFUQTs7Ozs7Ozs7QUFXTyxTQUFTQSxTQUFULEdBQXFCO0FBQzFCLFFBQU0sQ0FBQ0MsS0FBRCxFQUFRQyxRQUFSLElBQW9CLHFCQUFTLENBQVQsQ0FBMUI7QUFFQSxzQkFDRSx1REFDRSx3REFBZ0JELEtBQWhCLFdBREYsZUFFRTtBQUFRLElBQUEsT0FBTyxFQUFFLE1BQU1DLFFBQVEsQ0FBQ0QsS0FBSyxHQUFHLENBQVQ7QUFBL0IsZ0JBRkYsQ0FERjtBQU1EIiwic291cmNlc0NvbnRlbnQiOlsiLyoqXG4gKiBDb3B5cmlnaHQgKGMpIEZhY2Vib29rLCBJbmMuIGFuZCBpdHMgYWZmaWxpYXRlcy5cbiAqXG4gKiBUaGlzIHNvdXJjZSBjb2RlIGlzIGxpY2Vuc2VkIHVuZGVyIHRoZSBNSVQgbGljZW5zZSBmb3VuZCBpbiB0aGVcbiAqIExJQ0VOU0UgZmlsZSBpbiB0aGUgcm9vdCBkaXJlY3Rvcnkgb2YgdGhpcyBzb3VyY2UgdHJlZS5cbiAqXG4gKiBAZmxvd1xuICovXG5cbmltcG9ydCBSZWFjdCwge3VzZVN0YXRlfSBmcm9tICdyZWFjdCc7XG5cbmV4cG9ydCBmdW5jdGlvbiBDb21wb25lbnQoKSB7XG4gIGNvbnN0IFtjb3VudCwgc2V0Q291bnRdID0gdXNlU3RhdGUoMCk7XG5cbiAgcmV0dXJuIChcbiAgICA8ZGl2PlxuICAgICAgPHA+WW91IGNsaWNrZWQge2NvdW50fSB0aW1lczwvcD5cbiAgICAgIDxidXR0b24gb25DbGljaz17KCkgPT4gc2V0Q291bnQoY291bnQgKyAxKX0+Q2xpY2sgbWU8L2J1dHRvbj5cbiAgICA8L2Rpdj5cbiAgKTtcbn1cbiJdLCJ4X2ZiX3NvdXJjZXMiOltbbnVsbCx7Im5hbWVzIjpbIjxuby1ob29rPiIsImNvdW50Il0sIm1hcHBpbmdzIjoiQ0FBRDthNEJDQSxBV0RBIn1dXX0=
\ No newline at end of file
packages/react-devtools-extensions/src/__tests__/__source__/__compiled__/inline/fb-sources-extended/InlineRequire.js new
+21
@@ -0,0 +1,21 @@
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports.Component = Component;
7 +
8 +/**
9 + * Copyright (c) Facebook, Inc. and its affiliates.
10 + *
11 + * This source code is licensed under the MIT license found in the
12 + * LICENSE file in the root directory of this source tree.
13 + *
14 + * @flow
15 + */
16 +function Component() {
17 + const [count] = require('react').useState(0);
18 +
19 + return count;
20 +}
21 +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIklubGluZVJlcXVpcmUuanMiXSwibmFtZXMiOlsiQ29tcG9uZW50IiwiY291bnQiLCJyZXF1aXJlIiwidXNlU3RhdGUiXSwibWFwcGluZ3MiOiI7Ozs7Ozs7QUFBQTs7Ozs7Ozs7QUFTTyxTQUFTQSxTQUFULEdBQXFCO0FBQzFCLFFBQU0sQ0FBQ0MsS0FBRCxJQUFVQyxPQUFPLENBQUMsT0FBRCxDQUFQLENBQWlCQyxRQUFqQixDQUEwQixDQUExQixDQUFoQjs7QUFFQSxTQUFPRixLQUFQO0FBQ0QiLCJzb3VyY2VzQ29udGVudCI6WyIvKipcbiAqIENvcHlyaWdodCAoYykgRmFjZWJvb2ssIEluYy4gYW5kIGl0cyBhZmZpbGlhdGVzLlxuICpcbiAqIFRoaXMgc291cmNlIGNvZGUgaXMgbGljZW5zZWQgdW5kZXIgdGhlIE1JVCBsaWNlbnNlIGZvdW5kIGluIHRoZVxuICogTElDRU5TRSBmaWxlIGluIHRoZSByb290IGRpcmVjdG9yeSBvZiB0aGlzIHNvdXJjZSB0cmVlLlxuICpcbiAqIEBmbG93XG4gKi9cblxuZXhwb3J0IGZ1bmN0aW9uIENvbXBvbmVudCgpIHtcbiAgY29uc3QgW2NvdW50XSA9IHJlcXVpcmUoJ3JlYWN0JykudXNlU3RhdGUoMCk7XG5cbiAgcmV0dXJuIGNvdW50O1xufVxuIl0sInhfZmJfc291cmNlcyI6W1tudWxsLHsibmFtZXMiOlsiPG5vLWhvb2s+Il0sIm1hcHBpbmdzIjoiQ0FBRCJ9XV19
\ No newline at end of file
packages/react-devtools-extensions/src/__tests__/__source__/__compiled__/inline/fb-sources-extended/ToDoList.js new
+106
@@ -0,0 +1,106 @@
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports.ListItem = ListItem;
7 +exports.List = List;
8 +
9 +var React = _interopRequireWildcard(require("react"));
10 +
11 +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
12 +
13 +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
14 +
15 +/**
16 + * Copyright (c) Facebook, Inc. and its affiliates.
17 + *
18 + * This source code is licensed under the MIT license found in the
19 + * LICENSE file in the root directory of this source tree.
20 + *
21 + * @flow
22 + */
23 +function ListItem({
24 + item,
25 + removeItem,
26 + toggleItem
27 +}) {
28 + const handleDelete = (0, React.useCallback)(() => {
29 + removeItem(item);
30 + }, [item, removeItem]);
31 + const handleToggle = (0, React.useCallback)(() => {
32 + toggleItem(item);
33 + }, [item, toggleItem]);
34 + return /*#__PURE__*/React.createElement("li", null, /*#__PURE__*/React.createElement("button", {
35 + onClick: handleDelete
36 + }, "Delete"), /*#__PURE__*/React.createElement("label", null, /*#__PURE__*/React.createElement("input", {
37 + checked: item.isComplete,
38 + onChange: handleToggle,
39 + type: "checkbox"
40 + }), ' ', item.text));
41 +}
42 +
43 +function List(props) {
44 + const [newItemText, setNewItemText] = (0, React.useState)('');
45 + const [items, setItems] = (0, React.useState)([{
46 + id: 1,
47 + isComplete: true,
48 + text: 'First'
49 + }, {
50 + id: 2,
51 + isComplete: true,
52 + text: 'Second'
53 + }, {
54 + id: 3,
55 + isComplete: false,
56 + text: 'Third'
57 + }]);
58 + const [uid, setUID] = (0, React.useState)(4);
59 + const handleClick = (0, React.useCallback)(() => {
60 + if (newItemText !== '') {
61 + setItems([...items, {
62 + id: uid,
63 + isComplete: false,
64 + text: newItemText
65 + }]);
66 + setUID(uid + 1);
67 + setNewItemText('');
68 + }
69 + }, [newItemText, items, uid]);
70 + const handleKeyPress = (0, React.useCallback)(event => {
71 + if (event.key === 'Enter') {
72 + handleClick();
73 + }
74 + }, [handleClick]);
75 + const handleChange = (0, React.useCallback)(event => {
76 + setNewItemText(event.currentTarget.value);
77 + }, [setNewItemText]);
78 + const removeItem = (0, React.useCallback)(itemToRemove => setItems(items.filter(item => item !== itemToRemove)), [items]);
79 + const toggleItem = (0, React.useCallback)(itemToToggle => {
80 + // Dont use indexOf()
81 + // because editing props in DevTools creates a new Object.
82 + const index = items.findIndex(item => item.id === itemToToggle.id);
83 + setItems(items.slice(0, index).concat({ ...itemToToggle,
84 + isComplete: !itemToToggle.isComplete
85 + }).concat(items.slice(index + 1)));
86 + }, [items]);
87 + return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("h1", null, "List"), /*#__PURE__*/React.createElement("input", {
88 + type: "text",
89 + placeholder: "New list item...",
90 + value: newItemText,
91 + onChange: handleChange,
92 + onKeyPress: handleKeyPress
93 + }), /*#__PURE__*/React.createElement("button", {
94 + disabled: newItemText === '',
95 + onClick: handleClick
96 + }, /*#__PURE__*/React.createElement("span", {
97 + role: "img",
98 + "aria-label": "Add item"
99 + }, "Add")), /*#__PURE__*/React.createElement("ul", null, items.map(item => /*#__PURE__*/React.createElement(ListItem, {
100 + key: item.id,
101 + item: item,
102 + removeItem: removeItem,
103 + toggleItem: toggleItem
104 + }))));
105 +}
106 +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIlRvRG9MaXN0LmpzIl0sIm5hbWVzIjpbIkxpc3RJdGVtIiwiaXRlbSIsInJlbW92ZUl0ZW0iLCJ0b2dnbGVJdGVtIiwiaGFuZGxlRGVsZXRlIiwiaGFuZGxlVG9nZ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tCU0E7Z0ZsQlRBO2tGa0JVQTttR2xCVkEifV1dfQ==
\ No newline at end of file
packages/react-devtools-extensions/src/__tests__/__source__/__compiled__/inline/fb-sources-extended/index.js new
+89
@@ -0,0 +1,89 @@
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +Object.defineProperty(exports, "ComponentUsingHooksIndirectly", {
7 + enumerable: true,
8 + get: function () {
9 + return _ComponentUsingHooksIndirectly.Component;
10 + }
11 +});
12 +Object.defineProperty(exports, "ComponentWithCustomHook", {
13 + enumerable: true,
14 + get: function () {
15 + return _ComponentWithCustomHook.Component;
16 + }
17 +});
18 +Object.defineProperty(exports, "ComponentWithExternalCustomHooks", {
19 + enumerable: true,
20 + get: function () {
21 + return _ComponentWithExternalCustomHooks.Component;
22 + }
23 +});
24 +Object.defineProperty(exports, "ComponentWithMultipleHooksPerLine", {
25 + enumerable: true,
26 + get: function () {
27 + return _ComponentWithMultipleHooksPerLine.Component;
28 + }
29 +});
30 +Object.defineProperty(exports, "ComponentWithNestedHooks", {
31 + enumerable: true,
32 + get: function () {
33 + return _ComponentWithNestedHooks.Component;
34 + }
35 +});
36 +Object.defineProperty(exports, "ContainingStringSourceMappingURL", {
37 + enumerable: true,
38 + get: function () {
39 + return _ContainingStringSourceMappingURL.Component;
40 + }
41 +});
42 +Object.defineProperty(exports, "Example", {
43 + enumerable: true,
44 + get: function () {
45 + return _Example.Component;
46 + }
47 +});
48 +Object.defineProperty(exports, "InlineRequire", {
49 + enumerable: true,
50 + get: function () {
51 + return _InlineRequire.Component;
52 + }
53 +});
54 +Object.defineProperty(exports, "useTheme", {
55 + enumerable: true,
56 + get: function () {
57 + return _useTheme.default;
58 + }
59 +});
60 +exports.ToDoList = void 0;
61 +
62 +var _ComponentUsingHooksIndirectly = require("./ComponentUsingHooksIndirectly");
63 +
64 +var _ComponentWithCustomHook = require("./ComponentWithCustomHook");
65 +
66 +var _ComponentWithExternalCustomHooks = require("./ComponentWithExternalCustomHooks");
67 +
68 +var _ComponentWithMultipleHooksPerLine = require("./ComponentWithMultipleHooksPerLine");
69 +
70 +var _ComponentWithNestedHooks = require("./ComponentWithNestedHooks");
71 +
72 +var _ContainingStringSourceMappingURL = require("./ContainingStringSourceMappingURL");
73 +
74 +var _Example = require("./Example");
75 +
76 +var _InlineRequire = require("./InlineRequire");
77 +
78 +var ToDoList = _interopRequireWildcard(require("./ToDoList"));
79 +
80 +exports.ToDoList = ToDoList;
81 +
82 +var _useTheme = _interopRequireDefault(require("./useTheme"));
83 +
84 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
85 +
86 +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
87 +
88 +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
89 +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImluZGV4LmpzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7QUFTQTs7QUFDQTs7QUFDQTs7QUFDQTs7QUFDQTs7QUFDQTs7QUFDQTs7QUFDQTs7QUFDQTs7Ozt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hcyBFeGFtcGxlfSBmcm9tICcuL0V4YW1wbGUnO1xuZXhwb3J0IHtDb21wb25lbnQgYXMgSW5saW5lUmVxdWlyZX0gZnJvbSAnLi9JbmxpbmVSZXF1aXJlJztcbmltcG9ydCAqIGFzIFRvRG9MaXN0IGZyb20gJy4vVG9Eb0xpc3QnO1xuZXhwb3J0IHtUb0RvTGlzdH07XG5leHBvcnQge2RlZmF1bHQgYXMgdXNlVGhlbWV9IGZyb20gJy4vdXNlVGhlbWUnO1xuIl0sInhfZmJfc291cmNlcyI6W1tudWxsLHsibmFtZXMiOlsiPG5vLWhvb2s+Il0sIm1hcHBpbmdzIjoiQ0FBRCJ9XV19
\ No newline at end of file
packages/react-devtools-extensions/src/__tests__/__source__/__compiled__/inline/fb-sources-extended/useTheme.js new
+27
@@ -0,0 +1,27 @@
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports.default = useTheme;
7 +exports.ThemeContext = void 0;
8 +
9 +var _react = require("react");
10 +
11 +/**
12 + * Copyright (c) Facebook, Inc. and its affiliates.
13 + *
14 + * This source code is licensed under the MIT license found in the
15 + * LICENSE file in the root directory of this source tree.
16 + *
17 + * @flow
18 + */
19 +const ThemeContext = /*#__PURE__*/(0, _react.createContext)('bright');
20 +exports.ThemeContext = ThemeContext;
21 +
22 +function useTheme() {
23 + const theme = (0, _react.useContext)(ThemeContext);
24 + (0, _react.useDebugValue)(theme);
25 + return theme;
26 +}
27 +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInVzZVRoZW1lLmpzIl0sIm5hbWVzIjpbIlRoZW1lQ29udGV4dCIsInVzZVRoZW1lIiwidGhlbWUiXSwibWFwcGluZ3MiOiI7Ozs7Ozs7O0FBU0E7O0FBVEE7Ozs7Ozs7O0FBV08sTUFBTUEsWUFBWSxnQkFBRywwQkFBYyxRQUFkLENBQXJCOzs7QUFFUSxTQUFTQyxRQUFULEdBQW9CO0FBQ2pDLFFBQU1DLEtBQUssR0FBRyx1QkFBV0YsWUFBWCxDQUFkO0FBQ0EsNEJBQWNFLEtBQWQ7QUFDQSxTQUFPQSxLQUFQO0FBQ0QiLCJzb3VyY2VzQ29udGVudCI6WyIvKipcbiAqIENvcHlyaWdodCAoYykgRmFjZWJvb2ssIEluYy4gYW5kIGl0cyBhZmZpbGlhdGVzLlxuICpcbiAqIFRoaXMgc291cmNlIGNvZGUgaXMgbGljZW5zZWQgdW5kZXIgdGhlIE1JVCBsaWNlbnNlIGZvdW5kIGluIHRoZVxuICogTElDRU5TRSBmaWxlIGluIHRoZSByb290IGRpcmVjdG9yeSBvZiB0aGlzIHNvdXJjZSB0cmVlLlxuICpcbiAqIEBmbG93XG4gKi9cblxuaW1wb3J0IHtjcmVhdGVDb250ZXh0LCB1c2VDb250ZXh0LCB1c2VEZWJ1Z1ZhbHVlfSBmcm9tICdyZWFjdCc7XG5cbmV4cG9ydCBjb25zdCBUaGVtZUNvbnRleHQgPSBjcmVhdGVDb250ZXh0KCdicmlnaHQnKTtcblxuZXhwb3J0IGRlZmF1bHQgZnVuY3Rpb24gdXNlVGhlbWUoKSB7XG4gIGNvbnN0IHRoZW1lID0gdXNlQ29udGV4dChUaGVtZUNvbnRleHQpO1xuICB1c2VEZWJ1Z1ZhbHVlKHRoZW1lKTtcbiAgcmV0dXJuIHRoZW1lO1xufVxuIl0sInhfZmJfc291cmNlcyI6W1tudWxsLHsibmFtZXMiOlsiPG5vLWhvb2s+IiwidGhlbWUiXSwibWFwcGluZ3MiOiJDQUFEO2VnQkNBLEF3QkRBIn1dXX0=
\ No newline at end of file
packages/react-devtools-extensions/src/__tests__/__source__/__compiled__/inline/react-sources-extended/ComponentUsingHooksIndirectly.js new
+45
@@ -0,0 +1,45 @@
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports.Component = Component;
7 +
8 +var _react = _interopRequireWildcard(require("react"));
9 +
10 +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
11 +
12 +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
13 +
14 +/**
15 + * Copyright (c) Facebook, Inc. and its affiliates.
16 + *
17 + * This source code is licensed under the MIT license found in the
18 + * LICENSE file in the root directory of this source tree.
19 + *
20 + * @flow
21 + */
22 +function Component() {
23 + const countState = (0, _react.useState)(0);
24 + const count = countState[0];
25 + const setCount = countState[1];
26 + const darkMode = useIsDarkMode();
27 + const [isDarkMode] = darkMode;
28 + (0, _react.useEffect)(() => {// ...
29 + }, []);
30 +
31 + const handleClick = () => setCount(count + 1);
32 +
33 + return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", null, "Dark mode? ", isDarkMode), /*#__PURE__*/_react.default.createElement("div", null, "Count: ", count), /*#__PURE__*/_react.default.createElement("button", {
34 + onClick: handleClick
35 + }, "Update count"));
36 +}
37 +
38 +function useIsDarkMode() {
39 + const darkModeState = (0, _react.useState)(false);
40 + const [isDarkMode] = darkModeState;
41 + (0, _react.useEffect)(function useEffectCreate() {// Here is where we may listen to a "theme" event...
42 + }, []);
43 + return [isDarkMode, () => {}];
44 +}
45 +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIkNvb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bn1cblxuZnVuY3Rpb24gdXNlSXNEYXJrTW9kZSgpIHtcbiAgY29uc3QgZGFya01vZGVTdGF0ZSA9IHVzZVN0YXRlKGZhbHNlKTtcbiAgY29uc3QgW2lzRGFya01vZGVdID0gZGFya01vZGVTdGF0ZTtcblxuICB1c2VFZmZlY3QoZnVuY3Rpb24gdXNlRWZmZWN0Q3JlYXRlKCkge1xuICAgIC8vIEhlcmUgaXMgd2hlcmUgd2UgbWF5IGxpc3RlbiB0byBhIFwidGhlbWVcIiBldmVudC4uLlxuICB9LCBbXSk7XG5cbiAgcmV0dXJuIFtpc0RhcmtNb2RlLCAoKSA9PiB7fV07XG59XG4iXSwieF9yZWFjdF9zb3VyY2VzIjpbW3sibmFtZXMiOlsiPG5vLWhvb2s+IiwiY291bnQiLCJkYXJrTW9kZSIsImlzRGFya01vZGUiXSwibWFwcGluZ3MiOiJDQUFEO2FxQkNBLEFXREE7aUJiRUEsQWVGQTtvQ1ZHQSxBZUhBIn1dXX0=
\ No newline at end of file
packages/react-devtools-extensions/src/__tests__/__source__/__compiled__/inline/react-sources-extended/ComponentWithCustomHook.js new
+41
@@ -0,0 +1,41 @@
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports.Component = Component;
7 +
8 +var _react = _interopRequireWildcard(require("react"));
9 +
10 +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
11 +
12 +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
13 +
14 +/**
15 + * Copyright (c) Facebook, Inc. and its affiliates.
16 + *
17 + * This source code is licensed under the MIT license found in the
18 + * LICENSE file in the root directory of this source tree.
19 + *
20 + * @flow
21 + */
22 +function Component() {
23 + const [count, setCount] = (0, _react.useState)(0);
24 + const isDarkMode = useIsDarkMode();
25 + (0, _react.useEffect)(() => {// ...
26 + }, []);
27 +
28 + const handleClick = () => setCount(count + 1);
29 +
30 + return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", null, "Dark mode? ", isDarkMode), /*#__PURE__*/_react.default.createElement("div", null, "Count: ", count), /*#__PURE__*/_react.default.createElement("button", {
31 + onClick: handleClick
32 + }, "Update count"));
33 +}
34 +
35 +function useIsDarkMode() {
36 + const [isDarkMode] = (0, _react.useState)(false);
37 + (0, _react.useEffect)(function useEffectCreate() {// Here is where we may listen to a "theme" event...
38 + }, []);
39 + return isDarkMode;
40 +}
41 +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIkNvbXBvbmVudFdpdGhDdXN0b21Ib29rLmpzIl0sIm5hbWVzIjpbIkNvbXBvbmVudCIsImNvdW50Iiwic2V0Q291bnQiLCJpc0RhcmtNb2RlIiwidXNlSXNEYXJrTW9kZSIsImhhbmRsZUNsaWNrIiwidXNlRWZmZWN0Q3JlYXRlIl0sIm1hcHBpbmdzIjoiOzs7Ozs7O0FBU0E7Ozs7OztBQVRBOzs7Ozs7OztBQVdPLFNBQVNBLFNBQVQsR0FBcUI7QUFDMUIsUUFBTSxDQUFDQyxLQUFELEVBQVFDLFFBQVIsSUFBb0IscUJBQVMsQ0FBVCxDQUExQjtBQUNBLFFBQU1DLFVBQVUsR0FBR0MsYUFBYSxFQUFoQztBQUVBLHdCQUFVLE1BQU0sQ0FD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9PiBzZXRDb3VudChjb3VudCArIDEpO1xuXG4gIHJldHVybiAoXG4gICAgPD5cbiAgICAgIDxkaXY+RGFyayBtb2RlPyB7aXNEYXJrTW9kZX08L2Rpdj5cbiAgICAgIDxkaXY+Q291bnQ6IHtjb3VudH08L2Rpdj5cbiAgICAgIDxidXR0b24gb25DbGljaz17aGFuZGxlQ2xpY2t9PlVwZGF0ZSBjb3VudDwvYnV0dG9uPlxuICAgIDwvPlxuICApO1xufVxuXG5mdW5jdGlvbiB1c2VJc0RhcmtNb2RlKCkge1xuICBjb25zdCBbaXNEYXJrTW9kZV0gPSB1c2VTdGF0ZShmYWxzZSk7XG5cbiAgdXNlRWZmZWN0KGZ1bmN0aW9uIHVzZUVmZmVjdENyZWF0ZSgpIHtcbiAgICAvLyBIZXJlIGlzIHdoZXJlIHdlIG1heSBsaXN0ZW4gdG8gYSBcInRoZW1lXCIgZXZlbnQuLi5cbiAgfSwgW10pO1xuXG4gIHJldHVybiBpc0RhcmtNb2RlO1xufVxuIl0sInhfcmVhY3Rfc291cmNlcyI6W1t7Im5hbWVzIjpbIjxuby1ob29rPiIsImNvdW50IiwiaXNEYXJrTW9kZSJdLCJtYXBwaW5ncyI6IkNBQUQ7YTRCQ0EsQVdEQTtjbEJFQSxBZUZBO2dDYkVBLEFlRkEifV1dfQ==
\ No newline at end of file
packages/react-devtools-extensions/src/__tests__/__source__/__compiled__/inline/react-sources-extended/ComponentWithExternalCustomHooks.js new
+26
@@ -0,0 +1,26 @@
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports.Component = Component;
7 +
8 +var _react = _interopRequireDefault(require("react"));
9 +
10 +var _useTheme = _interopRequireDefault(require("./useTheme"));
11 +
12 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13 +
14 +/**
15 + * Copyright (c) Facebook, Inc. and its affiliates.
16 + *
17 + * This source code is licensed under the MIT license found in the
18 + * LICENSE file in the root directory of this source tree.
19 + *
20 + * @flow
21 + */
22 +function Component() {
23 + const theme = (0, _useTheme.default)();
24 + return /*#__PURE__*/_react.default.createElement("div", null, "theme: ", theme);
25 +}
26 +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIkNvbXBvbmVudFdpdGhFeHRlcm5hbEN1c3RvbUhvb2tzLmpzIl0sIm5hbWVzIjpbIkNvbXBvbmVudCIsInRoZW1lIl0sIm1hcHBpbmdzIjoiOzs7Ozs7O0FBU0E7O0FBQ0E7Ozs7QUFWQTs7Ozs7Ozs7QUFZTyxTQUFTQSxTQUFULEdBQXFCO0FBQzFCLFFBQU1DLEtBQUssR0FBRyx3QkFBZDtBQUVBLHNCQUFPLHFEQUFhQSxLQUFiLENBQVA7QUFDRCIsInNvdXJjZXNDb250ZW50IjpbIi8qKlxuICogQ29weXJpZ2h0IChjKSBGYWNlYm9vaywgSW5jLiBhbmQgaXRzIGFmZmlsaWF0ZXMuXG4gKlxuICogVGhpcyBzb3VyY2UgY29kZSBpcyBsaWNlbnNlZCB1bmRlciB0aGUgTUlUIGxpY2Vuc2UgZm91bmQgaW4gdGhlXG4gKiBMSUNFTlNFIGZpbGUgaW4gdGhlIHJvb3QgZGlyZWN0b3J5IG9mIHRoaXMgc291cmNlIHRyZWUuXG4gKlxuICogQGZsb3dcbiAqL1xuXG5pbXBvcnQgUmVhY3QgZnJvbSAncmVhY3QnO1xuaW1wb3J0IHVzZVRoZW1lIGZyb20gJy4vdXNlVGhlbWUnO1xuXG5leHBvcnQgZnVuY3Rpb24gQ29tcG9uZW50KCkge1xuICBjb25zdCB0aGVtZSA9IHVzZVRoZW1lKCk7XG5cbiAgcmV0dXJuIDxkaXY+dGhlbWU6IHt0aGVtZX08L2Rpdj47XG59XG4iXSwieF9yZWFjdF9zb3VyY2VzIjpbW3sibmFtZXMiOlsiPG5vLWhvb2s+IiwidGhlbWUiXSwibWFwcGluZ3MiOiJDQUFEO2NnQkNBLEFVREEifV1dfQ==
\ No newline at end of file
packages/react-devtools-extensions/src/__tests__/__source__/__compiled__/inline/react-sources-extended/ComponentWithMultipleHooksPerLine.js new
+30
@@ -0,0 +1,30 @@
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports.Component = Component;
7 +
8 +var _react = require("react");
9 +
10 +/**
11 + * Copyright (c) Facebook, Inc. and its affiliates.
12 + *
13 + * This source code is licensed under the MIT license found in the
14 + * LICENSE file in the root directory of this source tree.
15 + *
16 + * @flow
17 + */
18 +const A = /*#__PURE__*/(0, _react.createContext)(1);
19 +const B = /*#__PURE__*/(0, _react.createContext)(2);
20 +
21 +function Component() {
22 + const a = (0, _react.useContext)(A);
23 + const b = (0, _react.useContext)(B); // prettier-ignore
24 +
25 + const c = (0, _react.useContext)(A),
26 + d = (0, _react.useContext)(B); // eslint-disable-line one-var
27 +
28 + return a + b + c + d;
29 +}
30 +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIkNvbXBvbmVudFdpdGhNdWx0aXBsZUhvb2tzUGVyTGluZS5qcyJdLCJuYW1lcyI6WyJBIiwiQiIsIkNvbXBvbmVudCIsImEiLCJiIiwiYyIsImQiXSwibWFwcGluZ3MiOiI7Ozs7Ozs7QUFTQTs7QUFUQTs7Ozs7Ozs7QUFXQSxNQUFNQSxDQUFDLGdCQUFHLDBCQUFjLENBQWQsQ0FBVjtBQUNBLE1BQU1DLENBQUMsZ0JBQUcsMEJBQWMsQ0FBZCxDQUFWOztBQUVPLFNBQVNDLFNBQVQsR0FBcUI7QUFDMUIsUUFBTUMsQ0FBQyxHQUFHLHVCQUFXSCxDQUFYLENBQVY7QUFDQSxRQUFNSSxDQUFDLEdBQUcsdUJBQVdILENBQVgsQ0FBVixDQUYwQixDQUkxQjs7QUFDQSxRQUFNSSxDQUFDLEdBQUcsdUJBQVdMLENBQVgsQ0FBVjtBQUFBLFFBQXlCTS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ests__/__source__/__compiled__/inline/react-sources-extended/ComponentWithNestedHooks.js new
+28
@@ -0,0 +1,28 @@
1 +"use strict";
2 +
3 +/**
4 + * Copyright (c) Facebook, Inc. and its affiliates.
5 + *
6 + * This source code is licensed under the MIT license found in the
7 + * LICENSE file in the root directory of this source tree.
8 + *
9 + * @flow
10 + */
11 +const {
12 + useMemo,
13 + useState
14 +} = require('react');
15 +
16 +function Component(props) {
17 + const InnerComponent = useMemo(() => () => {
18 + const [state] = useState(0);
19 + return state;
20 + });
21 + props.callback(InnerComponent);
22 + return null;
23 +}
24 +
25 +module.exports = {
26 + Component
27 +};
28 +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIkNvbXBvbmVudFdpdGhOZXN0ZWRIb29rcy5qcyJdLCJuYW1lcyI6WyJ1c2VNZW1vIiwidXNlU3RhdGUiLCJyZXF1aXJlIiwiQ29tcG9uZW50IiwicHJvcHMiLCJJbm5lckNvbXBvbmVudCIsInN0YXRlIiwiY2FsbGJhY2siLCJtb2R1bGUiLCJleHBvcnRzIl0sIm1hcHBpbmdzIjoiOztBQUFBOzs7Ozs7OztBQVFBLE1BQU07QUFBQ0EsRUFBQUEsT0FBRDtBQUFVQyxFQUFBQTtBQUFWLElBQXNCQyxPQUFPLENBQUMsT0FBRCxDQUFuQzs7QUFFQSxTQUFTQyxTQUFULENBQW1CQyxLQUFuQixFQUEwQjtBQUN4QixRQUFNQyxjQUFjLEdBQUdMLE9BQU8sQ0FBQyxNQUFNLE1BQU07QUFDekMsVUFBTSxDQUFDTSxLQUFELElBQVVMLFFBQVEsQ0FBQyxDQUFELENBQXhCO0FBRUEsV0FBT0ssS0FBUDtBQUNELEdBSjZCLENBQTlCO0FBS0FGLEVBQUFBLEtBQUssQ0FBQ0csUUFBTixDQUFlRixjQUFmO0FBRUEsU0FBTyxJQUFQO0FBQ0Q7O0FBRURHLE1BQU0sQ0FBQ0MsT0FBUCxHQUFpQjtBQUFDTixFQUFBQTtBQUFELENBQWpCIiwic291cmNlc0NvbnRlbnQiOlsiLyoqXG4gKiBDb3B5cmlnaHQgKGMpIEZhY2Vib29rLCBJbmMuIGFuZCBpdHMgYWZmaWxpYXRlcy5cbiAqXG4gKiBUaGlzIHNvdXJjZSBjb2RlIGlzIGxpY2Vuc2VkIHVuZGVyIHRoZSBNSVQgbGljZW5zZSBmb3VuZCBpbiB0aGVcbiAqIExJQ0VOU0UgZmlsZSBpbiB0aGUgcm9vdCBkaXJlY3Rvcnkgb2YgdGhpcyBzb3VyY2UgdHJlZS5cbiAqXG4gKiBAZmxvd1xuICovXG5jb25zdCB7dXNlTWVtbywgdXNlU3RhdGV9ID0gcmVxdWlyZSgncmVhY3QnKTtcblxuZnVuY3Rpb24gQ29tcG9uZW50KHByb3BzKSB7XG4gIGNvbnN0IElubmVyQ29tcG9uZW50ID0gdXNlTWVtbygoKSA9PiAoKSA9PiB7XG4gICAgY29uc3QgW3N0YXRlXSA9IHVzZVN0YXRlKDApO1xuXG4gICAgcmV0dXJuIHN0YXRlO1xuICB9KTtcbiAgcHJvcHMuY2FsbGJhY2soSW5uZXJDb21wb25lbnQpO1xuXG4gIHJldHVybiBudWxsO1xufVxuXG5tb2R1bGUuZXhwb3J0cyA9IHtDb21wb25lbnR9O1xuIl0sInhfcmVhY3Rfc291cmNlcyI6W1t7Im5hbWVzIjpbIjxuby1ob29rPiIsIklubmVyQ29tcG9uZW50Iiwic3RhdGUiXSwibWFwcGluZ3MiOiJDQUFEO1l5QkNBO2FMQ0EsQVdEQTtnQjNCREEifV1dfQ==
\ No newline at end of file
packages/react-devtools-extensions/src/__tests__/__source__/__compiled__/inline/react-sources-extended/ContainingStringSourceMappingURL.js new
+29
@@ -0,0 +1,29 @@
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports.Component = Component;
7 +
8 +var _react = _interopRequireWildcard(require("react"));
9 +
10 +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
11 +
12 +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
13 +
14 +/**
15 + * Copyright (c) Facebook, Inc. and its affiliates.
16 + *
17 + * This source code is licensed under the MIT license found in the
18 + * LICENSE file in the root directory of this source tree.
19 + *
20 + * @flow
21 + */
22 +// ?sourceMappingURL=([^\s'"]+)/gm
23 +function Component() {
24 + const [count, setCount] = (0, _react.useState)(0);
25 + return /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("p", null, "You clicked ", count, " times"), /*#__PURE__*/_react.default.createElement("button", {
26 + onClick: () => setCount(count + 1)
27 + }, "Click me"));
28 +}
29 +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIkNvbnRhaW5pbmdTdHJpbmdTb3VyY2VNYXBwaW5nVVJMLmpzIl0sIm5hbWVzIjpbIkNvbXBvbmVudCIsImNvdW50Iiwic2V0Q291bnQiXSwibWFwcGluZ3MiOiI7Ozs7Ozs7QUFTQTs7Ozs7O0FBVEE7Ozs7Ozs7O0FBV0E7QUFFTyxTQUFTQSxTQUFULEdBQXFCO0FBQzFCLFFBQU0sQ0FBQ0MsS0FBRCxFQUFRQyxRQUFSLElBQW9CLHFCQUFTLENBQVQsQ0FBMUI7QUFFQSxzQkFDRSx1REFDRSx3REFBZ0JELEtBQWhCLFdBREYsZUFFRTtBQUFRLElBQUEsT0FBTyxFQUFFLE1BQU1DLFFBQVEsQ0FBQ0QsS0FBSyxHQUFHLENBQVQ7QUFBL0IsZ0JBRkYsQ0FERjtBQU1EIiwic291cmNlc0NvbnRlbnQiOlsiLyoqXG4gKiBDb3B5cmlnaHQgKGMpIEZhY2Vib29rLCBJbmMuIGFuZCBpdHMgYWZmaWxpYXRlcy5cbiAqXG4gKiBUaGlzIHNvdXJjZSBjb2RlIGlzIGxpY2Vuc2VkIHVuZGVyIHRoZSBNSVQgbGljZW5zZSBmb3VuZCBpbiB0aGVcbiAqIExJQ0VOU0UgZmlsZSBpbiB0aGUgcm9vdCBkaXJlY3Rvcnkgb2YgdGhpcyBzb3VyY2UgdHJlZS5cbiAqXG4gKiBAZmxvd1xuICovXG5cbmltcG9ydCBSZWFjdCwge3VzZVN0YXRlfSBmcm9tICdyZWFjdCc7XG5cbi8vID9zb3VyY2VNYXBwaW5nVVJMPShbXlxccydcIl0rKS9nbVxuXG5leHBvcnQgZnVuY3Rpb24gQ29tcG9uZW50KCkge1xuICBjb25zdCBbY291bnQsIHNldENvdW50XSA9IHVzZVN0YXRlKDApO1xuXG4gIHJldHVybiAoXG4gICAgPGRpdj5cbiAgICAgIDxwPllvdSBjbGlja2VkIHtjb3VudH0gdGltZXM8L3A+XG4gICAgICA8YnV0dG9uIG9uQ2xpY2s9eygpID0+IHNldENvdW50KGNvdW50ICsgMSl9PkNsaWNrIG1lPC9idXR0b24+XG4gICAgPC9kaXY+XG4gICk7XG59XG4iXSwieF9yZWFjdF9zb3VyY2VzIjpbW3sibmFtZXMiOlsiPG5vLWhvb2s+IiwiY291bnQiXSwibWFwcGluZ3MiOiJDQUFEO2U0QkNBLEFXREEifV1dfQ==
\ No newline at end of file
packages/react-devtools-extensions/src/__tests__/__source__/__compiled__/inline/react-sources-extended/Example.js new
+28
@@ -0,0 +1,28 @@
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports.Component = Component;
7 +
8 +var _react = _interopRequireWildcard(require("react"));
9 +
10 +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
11 +
12 +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
13 +
14 +/**
15 + * Copyright (c) Facebook, Inc. and its affiliates.
16 + *
17 + * This source code is licensed under the MIT license found in the
18 + * LICENSE file in the root directory of this source tree.
19 + *
20 + * @flow
21 + */
22 +function Component() {
23 + const [count, setCount] = (0, _react.useState)(0);
24 + return /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("p", null, "You clicked ", count, " times"), /*#__PURE__*/_react.default.createElement("button", {
25 + onClick: () => setCount(count + 1)
26 + }, "Click me"));
27 +}
28 +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIkV4YW1wbGUuanMiXSwibmFtZXMiOlsiQ29tcG9uZW50IiwiY291bnQiLCJzZXRDb3VudCJdLCJtYXBwaW5ncyI6Ijs7Ozs7OztBQVNBOzs7Ozs7QUFUQTs7Ozs7Ozs7QUFXTyxTQUFTQSxTQUFULEdBQXFCO0FBQzFCLFFBQU0sQ0FBQ0MsS0FBRCxFQUFRQyxRQUFSLElBQW9CLHFCQUFTLENBQVQsQ0FBMUI7QUFFQSxzQkFDRSx1REFDRSx3REFBZ0JELEtBQWhCLFdBREYsZUFFRTtBQUFRLElBQUEsT0FBTyxFQUFFLE1BQU1DLFFBQVEsQ0FBQ0QsS0FBSyxHQUFHLENBQVQ7QUFBL0IsZ0JBRkYsQ0FERjtBQU1EIiwic291cmNlc0NvbnRlbnQiOlsiLyoqXG4gKiBDb3B5cmlnaHQgKGMpIEZhY2Vib29rLCBJbmMuIGFuZCBpdHMgYWZmaWxpYXRlcy5cbiAqXG4gKiBUaGlzIHNvdXJjZSBjb2RlIGlzIGxpY2Vuc2VkIHVuZGVyIHRoZSBNSVQgbGljZW5zZSBmb3VuZCBpbiB0aGVcbiAqIExJQ0VOU0UgZmlsZSBpbiB0aGUgcm9vdCBkaXJlY3Rvcnkgb2YgdGhpcyBzb3VyY2UgdHJlZS5cbiAqXG4gKiBAZmxvd1xuICovXG5cbmltcG9ydCBSZWFjdCwge3VzZVN0YXRlfSBmcm9tICdyZWFjdCc7XG5cbmV4cG9ydCBmdW5jdGlvbiBDb21wb25lbnQoKSB7XG4gIGNvbnN0IFtjb3VudCwgc2V0Q291bnRdID0gdXNlU3RhdGUoMCk7XG5cbiAgcmV0dXJuIChcbiAgICA8ZGl2PlxuICAgICAgPHA+WW91IGNsaWNrZWQge2NvdW50fSB0aW1lczwvcD5cbiAgICAgIDxidXR0b24gb25DbGljaz17KCkgPT4gc2V0Q291bnQoY291bnQgKyAxKX0+Q2xpY2sgbWU8L2J1dHRvbj5cbiAgICA8L2Rpdj5cbiAgKTtcbn1cbiJdLCJ4X3JlYWN0X3NvdXJjZXMiOltbeyJuYW1lcyI6WyI8bm8taG9vaz4iLCJjb3VudCJdLCJtYXBwaW5ncyI6IkNBQUQ7YTRCQ0EsQVdEQSJ9XV19
\ No newline at end of file
packages/react-devtools-extensions/src/__tests__/__source__/__compiled__/inline/react-sources-extended/InlineRequire.js new
+21
@@ -0,0 +1,21 @@
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports.Component = Component;
7 +
8 +/**
9 + * Copyright (c) Facebook, Inc. and its affiliates.
10 + *
11 + * This source code is licensed under the MIT license found in the
12 + * LICENSE file in the root directory of this source tree.
13 + *
14 + * @flow
15 + */
16 +function Component() {
17 + const [count] = require('react').useState(0);
18 +
19 + return count;
20 +}
21 +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIklubGluZVJlcXVpcmUuanMiXSwibmFtZXMiOlsiQ29tcG9uZW50IiwiY291bnQiLCJyZXF1aXJlIiwidXNlU3RhdGUiXSwibWFwcGluZ3MiOiI7Ozs7Ozs7QUFBQTs7Ozs7Ozs7QUFTTyxTQUFTQSxTQUFULEdBQXFCO0FBQzFCLFFBQU0sQ0FBQ0MsS0FBRCxJQUFVQyxPQUFPLENBQUMsT0FBRCxDQUFQLENBQWlCQyxRQUFqQixDQUEwQixDQUExQixDQUFoQjs7QUFFQSxTQUFPRixLQUFQO0FBQ0QiLCJzb3VyY2VzQ29udGVudCI6WyIvKipcbiAqIENvcHlyaWdodCAoYykgRmFjZWJvb2ssIEluYy4gYW5kIGl0cyBhZmZpbGlhdGVzLlxuICpcbiAqIFRoaXMgc291cmNlIGNvZGUgaXMgbGljZW5zZWQgdW5kZXIgdGhlIE1JVCBsaWNlbnNlIGZvdW5kIGluIHRoZVxuICogTElDRU5TRSBmaWxlIGluIHRoZSByb290IGRpcmVjdG9yeSBvZiB0aGlzIHNvdXJjZSB0cmVlLlxuICpcbiAqIEBmbG93XG4gKi9cblxuZXhwb3J0IGZ1bmN0aW9uIENvbXBvbmVudCgpIHtcbiAgY29uc3QgW2NvdW50XSA9IHJlcXVpcmUoJ3JlYWN0JykudXNlU3RhdGUoMCk7XG5cbiAgcmV0dXJuIGNvdW50O1xufVxuIl0sInhfcmVhY3Rfc291cmNlcyI6W1t7Im5hbWVzIjpbIjxuby1ob29rPiJdLCJtYXBwaW5ncyI6IkNBQUQifV1dfQ==
\ No newline at end of file
packages/react-devtools-extensions/src/__tests__/__source__/__compiled__/inline/react-sources-extended/ToDoList.js new
+106
@@ -0,0 +1,106 @@
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports.ListItem = ListItem;
7 +exports.List = List;
8 +
9 +var React = _interopRequireWildcard(require("react"));
10 +
11 +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
12 +
13 +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
14 +
15 +/**
16 + * Copyright (c) Facebook, Inc. and its affiliates.
17 + *
18 + * This source code is licensed under the MIT license found in the
19 + * LICENSE file in the root directory of this source tree.
20 + *
21 + * @flow
22 + */
23 +function ListItem({
24 + item,
25 + removeItem,
26 + toggleItem
27 +}) {
28 + const handleDelete = (0, React.useCallback)(() => {
29 + removeItem(item);
30 + }, [item, removeItem]);
31 + const handleToggle = (0, React.useCallback)(() => {
32 + toggleItem(item);
33 + }, [item, toggleItem]);
34 + return /*#__PURE__*/React.createElement("li", null, /*#__PURE__*/React.createElement("button", {
35 + onClick: handleDelete
36 + }, "Delete"), /*#__PURE__*/React.createElement("label", null, /*#__PURE__*/React.createElement("input", {
37 + checked: item.isComplete,
38 + onChange: handleToggle,
39 + type: "checkbox"
40 + }), ' ', item.text));
41 +}
42 +
43 +function List(props) {
44 + const [newItemText, setNewItemText] = (0, React.useState)('');
45 + const [items, setItems] = (0, React.useState)([{
46 + id: 1,
47 + isComplete: true,
48 + text: 'First'
49 + }, {
50 + id: 2,
51 + isComplete: true,
52 + text: 'Second'
53 + }, {
54 + id: 3,
55 + isComplete: false,
56 + text: 'Third'
57 + }]);
58 + const [uid, setUID] = (0, React.useState)(4);
59 + const handleClick = (0, React.useCallback)(() => {
60 + if (newItemText !== '') {
61 + setItems([...items, {
62 + id: uid,
63 + isComplete: false,
64 + text: newItemText
65 + }]);
66 + setUID(uid + 1);
67 + setNewItemText('');
68 + }
69 + }, [newItemText, items, uid]);
70 + const handleKeyPress = (0, React.useCallback)(event => {
71 + if (event.key === 'Enter') {
72 + handleClick();
73 + }
74 + }, [handleClick]);
75 + const handleChange = (0, React.useCallback)(event => {
76 + setNewItemText(event.currentTarget.value);
77 + }, [setNewItemText]);
78 + const removeItem = (0, React.useCallback)(itemToRemove => setItems(items.filter(item => item !== itemToRemove)), [items]);
79 + const toggleItem = (0, React.useCallback)(itemToToggle => {
80 + // Dont use indexOf()
81 + // because editing props in DevTools creates a new Object.
82 + const index = items.findIndex(item => item.id === itemToToggle.id);
83 + setItems(items.slice(0, index).concat({ ...itemToToggle,
84 + isComplete: !itemToToggle.isComplete
85 + }).concat(items.slice(index + 1)));
86 + }, [items]);
87 + return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("h1", null, "List"), /*#__PURE__*/React.createElement("input", {
88 + type: "text",
89 + placeholder: "New list item...",
90 + value: newItemText,
91 + onChange: handleChange,
92 + onKeyPress: handleKeyPress
93 + }), /*#__PURE__*/React.createElement("button", {
94 + disabled: newItemText === '',
95 + onClick: handleClick
96 + }, /*#__PURE__*/React.createElement("span", {
97 + role: "img",
98 + "aria-label": "Add item"
99 + }, "Add")), /*#__PURE__*/React.createElement("ul", null, items.map(item => /*#__PURE__*/React.createElement(ListItem, {
100 + key: item.id,
101 +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sZUtleVByZXNzIiwiaGFuZGxlQ2hhbmdlIiwicmVtb3ZlSXRlbSIsInRvZ2dsZUl0ZW0iXSwibWFwcGluZ3MiOiJDQUFEO2N1QkNBO2dCQ0RBO2tCREVBO29CQ0ZBO3NDZ0JHQSxBWUhBO3VDeEJJQTsyQ3hCSkE7NENvQktBLEFXTEE7OENiTUE7MkRTTkE7NkROT0E7b0V0QlBBO3NFb0JRQTsyRXBCUkE7NkVrQlNBO2dGbEJUQTtrRmtCVUE7bUdsQlZBIn1dXX0=
\ No newline at end of file
packages/react-devtools-extensions/src/__tests__/__source__/__compiled__/inline/react-sources-extended/index.js new
+89
@@ -0,0 +1,89 @@
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +Object.defineProperty(exports, "ComponentUsingHooksIndirectly", {
7 + enumerable: true,
8 + get: function () {
9 + return _ComponentUsingHooksIndirectly.Component;
10 + }
11 +});
12 +Object.defineProperty(exports, "ComponentWithCustomHook", {
13 + enumerable: true,
14 + get: function () {
15 + return _ComponentWithCustomHook.Component;
16 + }
17 +});
18 +Object.defineProperty(exports, "ComponentWithExternalCustomHooks", {
19 + enumerable: true,
20 + get: function () {
21 + return _ComponentWithExternalCustomHooks.Component;
22 + }
23 +});
24 +Object.defineProperty(exports, "ComponentWithMultipleHooksPerLine", {
25 + enumerable: true,
26 + get: function () {
27 + return _ComponentWithMultipleHooksPerLine.Component;
28 + }
29 +});
30 +Object.defineProperty(exports, "ComponentWithNestedHooks", {
31 + enumerable: true,
32 + get: function () {
33 + return _ComponentWithNestedHooks.Component;
34 + }
35 +});
36 +Object.defineProperty(exports, "ContainingStringSourceMappingURL", {
37 + enumerable: true,
38 + get: function () {
39 + return _ContainingStringSourceMappingURL.Component;
40 + }
41 +});
42 +Object.defineProperty(exports, "Example", {
43 + enumerable: true,
44 + get: function () {
45 + return _Example.Component;
46 + }
47 +});
48 +Object.defineProperty(exports, "InlineRequire", {
49 + enumerable: true,
50 + get: function () {
51 + return _InlineRequire.Component;
52 + }
53 +});
54 +Object.defineProperty(exports, "useTheme", {
55 + enumerable: true,
56 + get: function () {
57 + return _useTheme.default;
58 + }
59 +});
60 +exports.ToDoList = void 0;
61 +
62 +var _ComponentUsingHooksIndirectly = require("./ComponentUsingHooksIndirectly");
63 +
64 +var _ComponentWithCustomHook = require("./ComponentWithCustomHook");
65 +
66 +var _ComponentWithExternalCustomHooks = require("./ComponentWithExternalCustomHooks");
67 +
68 +var _ComponentWithMultipleHooksPerLine = require("./ComponentWithMultipleHooksPerLine");
69 +
70 +var _ComponentWithNestedHooks = require("./ComponentWithNestedHooks");
71 +
72 +var _ContainingStringSourceMappingURL = require("./ContainingStringSourceMappingURL");
73 +
74 +var _Example = require("./Example");
75 +
76 +var _InlineRequire = require("./InlineRequire");
77 +
78 +var ToDoList = _interopRequireWildcard(require("./ToDoList"));
79 +
80 +exports.ToDoList = ToDoList;
81 +
82 +var _useTheme = _interopRequireDefault(require("./useTheme"));
83 +
84 +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
85 +
86 +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
87 +
88 +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
89 +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3V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bnQgYXMgQ29tcG9uZW50V2l0aE5lc3RlZEhvb2tzfSBmcm9tICcuL0NvbXBvbmVudFdpdGhOZXN0ZWRIb29rcyc7XG5leHBvcnQge0NvbXBvbmVudCBhcyBDb250YWluaW5nU3RyaW5nU291cmNlTWFwcGluZ1VSTH0gZnJvbSAnLi9Db250YWluaW5nU3RyaW5nU291cmNlTWFwcGluZ1VSTCc7XG5leHBvcnQge0NvbXBvbmVudCBhcyBFeGFtcGxlfSBmcm9tICcuL0V4YW1wbGUnO1xuZXhwb3J0IHtDb21wb25lbnQgYXMgSW5saW5lUmVxdWlyZX0gZnJvbSAnLi9JbmxpbmVSZXF1aXJlJztcbmltcG9ydCAqIGFzIFRvRG9MaXN0IGZyb20gJy4vVG9Eb0xpc3QnO1xuZXhwb3J0IHtUb0RvTGlzdH07XG5leHBvcnQge2RlZmF1bHQgYXMgdXNlVGhlbWV9IGZyb20gJy4vdXNlVGhlbWUnO1xuIl0sInhfcmVhY3Rfc291cmNlcyI6W1t7Im5hbWVzIjpbIjxuby1ob29rPiJdLCJtYXBwaW5ncyI6IkNBQUQifV1dfQ==
\ No newline at end of file
packages/react-devtools-extensions/src/__tests__/__source__/__compiled__/inline/react-sources-extended/useTheme.js new
+27
@@ -0,0 +1,27 @@
1 +"use strict";
2 +
3 +Object.defineProperty(exports, "__esModule", {
4 + value: true
5 +});
6 +exports.default = useTheme;
7 +exports.ThemeContext = void 0;
8 +
9 +var _react = require("react");
10 +
11 +/**
12 + * Copyright (c) Facebook, Inc. and its affiliates.
13 + *
14 + * This source code is licensed under the MIT license found in the
15 + * LICENSE file in the root directory of this source tree.
16 + *
17 + * @flow
18 + */
19 +const ThemeContext = /*#__PURE__*/(0, _react.createContext)('bright');
20 +exports.ThemeContext = ThemeContext;
21 +
22 +function useTheme() {
23 + const theme = (0, _react.useContext)(ThemeContext);
24 + (0, _react.useDebugValue)(theme);
25 + return theme;
26 +}
27 +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZX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bmdzIjoiQ0FBRDtlZ0JDQSxBd0JEQSJ9XV19
\ No newline at end of file
packages/react-devtools-extensions/src/__tests__/generateHookMap-test.js new
+212
@@ -0,0 +1,212 @@
1 +/**
2 + * Copyright (c) Facebook, Inc. and its affiliates.
3 + *
4 + * This source code is licensed under the MIT license found in the
5 + * LICENSE file in the root directory of this source tree.
6 + *
7 + * @flow
8 + */
9 +
10 +import {parse} from '@babel/parser';
11 +import {generateEncodedHookMap, generateHookMap} from '../generateHookMap';
12 +
13 +function expectHookMapToEqual(actual, expected) {
14 + expect(actual.names).toEqual(expected.names);
15 +
16 + const formattedMappings = [];
17 + actual.mappings.forEach(lines => {
18 + lines.forEach(segment => {
19 + const name = actual.names[segment[2]];
20 + if (name == null) {
21 + throw new Error(`Expected to find name at position ${segment[2]}`);
22 + }
23 + formattedMappings.push(`${name} from ${segment[0]}:${segment[1]}`);
24 + });
25 + });
26 + expect(formattedMappings).toEqual(expected.mappings);
27 +}
28 +
29 +describe('generateHookMap', () => {
30 + it('should parse names for built-in hooks', () => {
31 + const code = `
32 +import {useState, useContext, useMemo, useReducer} from 'react';
33 +
34 +export function Component() {
35 + const a = useMemo(() => A);
36 + const [b, setB] = useState(0);
37 +
38 + // prettier-ignore
39 + const c = useContext(A), d = useContext(B); // eslint-disable-line one-var
40 +
41 + const [e, dispatch] = useReducer(reducer, initialState);
42 + const f = useRef(null)
43 +
44 + return a + b + c + d + e + f.current;
45 +}`;
46 +
47 + const parsed = parse(code, {
48 + sourceType: 'module',
49 + plugins: ['jsx', 'flow'],
50 + });
51 + const hookMap = generateHookMap(parsed);
52 + expectHookMapToEqual(hookMap, {
53 + names: ['<no-hook>', 'a', 'b', 'c', 'd', 'e', 'f'],
54 + mappings: [
55 + '<no-hook> from 1:0',
56 + 'a from 5:12',
57 + '<no-hook> from 5:28',
58 + 'b from 6:20',
59 + '<no-hook> from 6:31',
60 + 'c from 9:12',
61 + '<no-hook> from 9:25',
62 + 'd from 9:31',
63 + '<no-hook> from 9:44',
64 + 'e from 11:24',
65 + '<no-hook> from 11:57',
66 + 'f from 12:12',
67 + '<no-hook> from 12:24',
68 + ],
69 + });
70 +
71 + const encodedHookMap = generateEncodedHookMap(parsed);
72 + expect(encodedHookMap).toMatchInlineSnapshot(`
73 + Object {
74 + "mappings": "CAAD;KYCA,AgBDA;MREA,AWFA;SnBGA,AaHA,AMIA,AaJA;WpBKA,AiCLA;Y7CMA,AYNA",
75 + "names": Array [
76 + "<no-hook>",
77 + "a",
78 + "b",
79 + "c",
80 + "d",
81 + "e",
82 + "f",
83 + ],
84 + }
85 + `);
86 + });
87 +
88 + it('should parse names for custom hooks', () => {
89 + const code = `
90 +import useTheme from 'useTheme';
91 +import useValue from 'useValue';
92 +
93 +export function Component() {
94 + const theme = useTheme();
95 + const [val, setVal] = useValue();
96 +
97 + return theme;
98 +}`;
99 +
100 + const parsed = parse(code, {
101 + sourceType: 'module',
102 + plugins: ['jsx', 'flow'],
103 + });
104 + const hookMap = generateHookMap(parsed);
105 + expectHookMapToEqual(hookMap, {
106 + names: ['<no-hook>', 'theme', 'val'],
107 + mappings: [
108 + '<no-hook> from 1:0',
109 + 'theme from 6:16',
110 + '<no-hook> from 6:26',
111 + 'val from 7:24',
112 + '<no-hook> from 7:34',
113 + ],
114 + });
115 +
116 + const encodedHookMap = generateEncodedHookMap(parsed);
117 + expect(encodedHookMap).toMatchInlineSnapshot(`
118 + Object {
119 + "mappings": "CAAD;MgBCA,AUDA;OFEA,AUFA",
120 + "names": Array [
121 + "<no-hook>",
122 + "theme",
123 + "val",
124 + ],
125 + }
126 + `);
127 + });
128 +
129 + it('should parse names for nested hook calls', () => {
130 + const code = `
131 +import {useMemo, useState} from 'react';
132 +
133 +export function Component() {
134 + const InnerComponent = useMemo(() => () => {
135 + const [state, setState] = useState(0);
136 +
137 + return state;
138 + });
139 +
140 + return null;
141 +}`;
142 +
143 + const parsed = parse(code, {
144 + sourceType: 'module',
145 + plugins: ['jsx', 'flow'],
146 + });
147 + const hookMap = generateHookMap(parsed);
148 + expectHookMapToEqual(hookMap, {
149 + names: ['<no-hook>', 'InnerComponent', 'state'],
150 + mappings: [
151 + '<no-hook> from 1:0',
152 + 'InnerComponent from 5:25',
153 + 'state from 6:30',
154 + 'InnerComponent from 6:41',
155 + '<no-hook> from 9:4',
156 + ],
157 + });
158 +
159 + const encodedHookMap = generateEncodedHookMap(parsed);
160 + expect(encodedHookMap).toMatchInlineSnapshot(`
161 + Object {
162 + "mappings": "CAAD;KyBCA;MKCA,AWDA;SrCDA",
163 + "names": Array [
164 + "<no-hook>",
165 + "InnerComponent",
166 + "state",
167 + ],
168 + }
169 + `);
170 + });
171 +
172 + it('should skip names for non-nameable hooks', () => {
173 + const code = `
174 +import useTheme from 'useTheme';
175 +import useValue from 'useValue';
176 +
177 +export function Component() {
178 + const [val, setVal] = useState(0);
179 +
180 + useEffect(() => {
181 + // ...
182 + });
183 +
184 + useLayoutEffect(() => {
185 + // ...
186 + });
187 +
188 + return val;
189 +}`;
190 +
191 + const parsed = parse(code, {
192 + sourceType: 'module',
193 + plugins: ['jsx', 'flow'],
194 + });
195 + const hookMap = generateHookMap(parsed);
196 + expectHookMapToEqual(hookMap, {
197 + names: ['<no-hook>', 'val'],
198 + mappings: ['<no-hook> from 1:0', 'val from 6:24', '<no-hook> from 6:35'],
199 + });
200 +
201 + const encodedHookMap = generateEncodedHookMap(parsed);
202 + expect(encodedHookMap).toMatchInlineSnapshot(`
203 + Object {
204 + "mappings": "CAAD;MwBCA,AWDA",
205 + "names": Array [
206 + "<no-hook>",
207 + "val",
208 + ],
209 + }
210 + `);
211 + });
212 +});
packages/react-devtools-extensions/src/__tests__/getHookNameForLocation-test.js new
+264
@@ -0,0 +1,264 @@
1 +/**
2 + * Copyright (c) Facebook, Inc. and its affiliates.
3 + *
4 + * This source code is licensed under the MIT license found in the
5 + * LICENSE file in the root directory of this source tree.
6 + *
7 + * @flow
8 + */
9 +
10 +import {parse} from '@babel/parser';
11 +import {generateHookMap} from '../generateHookMap';
12 +import {getHookNameForLocation} from '../getHookNameForLocation';
13 +
14 +function expectHookMapToEqual(actual, expected) {
15 + expect(actual.names).toEqual(expected.names);
16 +
17 + const formattedMappings = [];
18 + actual.mappings.forEach(lines => {
19 + lines.forEach(segment => {
20 + const name = actual.names[segment[2]];
21 + if (name == null) {
22 + throw new Error(`Expected to find name at position ${segment[2]}`);
23 + }
24 + formattedMappings.push(`${name} from ${segment[0]}:${segment[1]}`);
25 + });
26 + });
27 + expect(formattedMappings).toEqual(expected.mappings);
28 +}
29 +
30 +describe('generateHookMap', () => {
31 + it('should parse names for built-in hooks', () => {
32 + const code = `
33 +import {useState, useContext, useMemo, useReducer} from 'react';
34 +
35 +export function Component() {
36 + const a = useMemo(() => A);
37 + const [b, setB] = useState(0);
38 +
39 + // prettier-ignore
40 + const c = useContext(A), d = useContext(B); // eslint-disable-line one-var
41 +
42 + const [e, dispatch] = useReducer(reducer, initialState);
43 + const f = useRef(null)
44 +
45 + return a + b + c + d + e + f.current;
46 +}`;
47 +
48 + const parsed = parse(code, {
49 + sourceType: 'module',
50 + plugins: ['jsx', 'flow'],
51 + });
52 + const hookMap = generateHookMap(parsed);
53 + expectHookMapToEqual(hookMap, {
54 + names: ['<no-hook>', 'a', 'b', 'c', 'd', 'e', 'f'],
55 + mappings: [
56 + '<no-hook> from 1:0',
57 + 'a from 5:12',
58 + '<no-hook> from 5:28',
59 + 'b from 6:20',
60 + '<no-hook> from 6:31',
61 + 'c from 9:12',
62 + '<no-hook> from 9:25',
63 + 'd from 9:31',
64 + '<no-hook> from 9:44',
65 + 'e from 11:24',
66 + '<no-hook> from 11:57',
67 + 'f from 12:12',
68 + '<no-hook> from 12:24',
69 + ],
70 + });
71 +
72 + expect(getHookNameForLocation({line: 1, column: 0}, hookMap)).toEqual(null);
73 + expect(getHookNameForLocation({line: 2, column: 25}, hookMap)).toEqual(
74 + null,
75 + );
76 + expect(getHookNameForLocation({line: 5, column: 12}, hookMap)).toEqual('a');
77 + expect(getHookNameForLocation({line: 5, column: 13}, hookMap)).toEqual('a');
78 + expect(getHookNameForLocation({line: 5, column: 28}, hookMap)).toEqual(
79 + null,
80 + );
81 + expect(getHookNameForLocation({line: 5, column: 29}, hookMap)).toEqual(
82 + null,
83 + );
84 + expect(getHookNameForLocation({line: 6, column: 20}, hookMap)).toEqual('b');
85 + expect(getHookNameForLocation({line: 6, column: 30}, hookMap)).toEqual('b');
86 + expect(getHookNameForLocation({line: 6, column: 31}, hookMap)).toEqual(
87 + null,
88 + );
89 + expect(getHookNameForLocation({line: 7, column: 31}, hookMap)).toEqual(
90 + null,
91 + );
92 + expect(getHookNameForLocation({line: 8, column: 20}, hookMap)).toEqual(
93 + null,
94 + );
95 + expect(getHookNameForLocation({line: 9, column: 12}, hookMap)).toEqual('c');
96 + expect(getHookNameForLocation({line: 9, column: 13}, hookMap)).toEqual('c');
97 + expect(getHookNameForLocation({line: 9, column: 25}, hookMap)).toEqual(
98 + null,
99 + );
100 + expect(getHookNameForLocation({line: 9, column: 26}, hookMap)).toEqual(
101 + null,
102 + );
103 + expect(getHookNameForLocation({line: 9, column: 31}, hookMap)).toEqual('d');
104 + expect(getHookNameForLocation({line: 9, column: 32}, hookMap)).toEqual('d');
105 + expect(getHookNameForLocation({line: 9, column: 44}, hookMap)).toEqual(
106 + null,
107 + );
108 + expect(getHookNameForLocation({line: 9, column: 45}, hookMap)).toEqual(
109 + null,
110 + );
111 + expect(getHookNameForLocation({line: 11, column: 24}, hookMap)).toEqual(
112 + 'e',
113 + );
114 + expect(getHookNameForLocation({line: 11, column: 56}, hookMap)).toEqual(
115 + 'e',
116 + );
117 + expect(getHookNameForLocation({line: 11, column: 57}, hookMap)).toEqual(
118 + null,
119 + );
120 + expect(getHookNameForLocation({line: 11, column: 58}, hookMap)).toEqual(
121 + null,
122 + );
123 + expect(getHookNameForLocation({line: 12, column: 12}, hookMap)).toEqual(
124 + 'f',
125 + );
126 + expect(getHookNameForLocation({line: 12, column: 23}, hookMap)).toEqual(
127 + 'f',
128 + );
129 + expect(getHookNameForLocation({line: 12, column: 24}, hookMap)).toEqual(
130 + null,
131 + );
132 + expect(getHookNameForLocation({line: 100, column: 50}, hookMap)).toEqual(
133 + null,
134 + );
135 + });
136 +
137 + it('should parse names for custom hooks', () => {
138 + const code = `
139 +import useTheme from 'useTheme';
140 +import useValue from 'useValue';
141 +
142 +export function Component() {
143 + const theme = useTheme();
144 + const [val, setVal] = useValue();
145 +
146 + return theme;
147 +}`;
148 +
149 + const parsed = parse(code, {
150 + sourceType: 'module',
151 + plugins: ['jsx', 'flow'],
152 + });
153 + const hookMap = generateHookMap(parsed);
154 + expectHookMapToEqual(hookMap, {
155 + names: ['<no-hook>', 'theme', 'val'],
156 + mappings: [
157 + '<no-hook> from 1:0',
158 + 'theme from 6:16',
159 + '<no-hook> from 6:26',
160 + 'val from 7:24',
161 + '<no-hook> from 7:34',
162 + ],
163 + });
164 +
165 + expect(getHookNameForLocation({line: 1, column: 0}, hookMap)).toEqual(null);
166 + expect(getHookNameForLocation({line: 6, column: 16}, hookMap)).toEqual(
167 + 'theme',
168 + );
169 + expect(getHookNameForLocation({line: 6, column: 26}, hookMap)).toEqual(
170 + null,
171 + );
172 + expect(getHookNameForLocation({line: 7, column: 24}, hookMap)).toEqual(
173 + 'val',
174 + );
175 + expect(getHookNameForLocation({line: 7, column: 34}, hookMap)).toEqual(
176 + null,
177 + );
178 + });
179 +
180 + it('should parse names for nested hook calls', () => {
181 + const code = `
182 +import {useMemo, useState} from 'react';
183 +
184 +export function Component() {
185 + const InnerComponent = useMemo(() => () => {
186 + const [state, setState] = useState(0);
187 +
188 + return state;
189 + });
190 +
191 + return null;
192 +}`;
193 +
194 + const parsed = parse(code, {
195 + sourceType: 'module',
196 + plugins: ['jsx', 'flow'],
197 + });
198 + const hookMap = generateHookMap(parsed);
199 + expectHookMapToEqual(hookMap, {
200 + names: ['<no-hook>', 'InnerComponent', 'state'],
201 + mappings: [
202 + '<no-hook> from 1:0',
203 + 'InnerComponent from 5:25',
204 + 'state from 6:30',
205 + 'InnerComponent from 6:41',
206 + '<no-hook> from 9:4',
207 + ],
208 + });
209 +
210 + expect(getHookNameForLocation({line: 1, column: 0}, hookMap)).toEqual(null);
211 + expect(getHookNameForLocation({line: 5, column: 25}, hookMap)).toEqual(
212 + 'InnerComponent',
213 + );
214 + expect(getHookNameForLocation({line: 6, column: 30}, hookMap)).toEqual(
215 + 'state',
216 + );
217 + expect(getHookNameForLocation({line: 6, column: 40}, hookMap)).toEqual(
218 + 'state',
219 + );
220 + expect(getHookNameForLocation({line: 6, column: 41}, hookMap)).toEqual(
221 + 'InnerComponent',
222 + );
223 + expect(getHookNameForLocation({line: 9, column: 4}, hookMap)).toEqual(null);
224 + });
225 +
226 + it('should skip names for non-nameable hooks', () => {
227 + const code = `
228 +import useTheme from 'useTheme';
229 +import useValue from 'useValue';
230 +
231 +export function Component() {
232 + const [val, setVal] = useState(0);
233 +
234 + useEffect(() => {
235 + // ...
236 + });
237 +
238 + useLayoutEffect(() => {
239 + // ...
240 + });
241 +
242 + return val;
243 +}`;
244 +
245 + const parsed = parse(code, {
246 + sourceType: 'module',
247 + plugins: ['jsx', 'flow'],
248 + });
249 + const hookMap = generateHookMap(parsed);
250 + expectHookMapToEqual(hookMap, {
251 + names: ['<no-hook>', 'val'],
252 + mappings: ['<no-hook> from 1:0', 'val from 6:24', '<no-hook> from 6:35'],
253 + });
254 +
255 + expect(getHookNameForLocation({line: 1, column: 0}, hookMap)).toEqual(null);
256 + expect(getHookNameForLocation({line: 6, column: 24}, hookMap)).toEqual(
257 + 'val',
258 + );
259 + expect(getHookNameForLocation({line: 6, column: 35}, hookMap)).toEqual(
260 + null,
261 + );
262 + expect(getHookNameForLocation({line: 8, column: 2}, hookMap)).toEqual(null);
263 + });
264 +});
packages/react-devtools-extensions/src/__tests__/parseHookNames-test.js
+292
@@ -421,6 +421,298 @@ describe('parseHookNames', () => {
421 ); // simulated Webpack 'cheap-module-source-map'
422 });
423 });
424 +
425 + describe('extended source maps', () => {
426 + let parseMock;
427 +
428 + beforeEach(() => {
429 + parseMock = jest.fn();
430 + jest.mock('@babel/parser', () => {
431 + const actual = jest.requireActual('@babel/parser');
432 + const parse = (...args) => {
433 + parseMock();
434 + return actual.parse(...args);
435 + };
436 + return {
437 + parse,
438 + ...actual,
439 + };
440 + });
441 + });
442 +
443 + it('should work for simple components', async () => {
444 + async function test(path, name = 'Component') {
445 + const Component = require(path)[name];
446 + const hookNames = await getHookNamesForComponent(Component);
447 + expectHookNamesToEqual(hookNames, [
448 + 'count', // useState
449 + ]);
450 + expect(parseMock).toHaveBeenCalledTimes(0);
451 + }
452 +
453 + await test('./__source__/Example'); // original source (uncompiled)
454 + await test(
455 + './__source__/__compiled__/inline/fb-sources-extended/Example',
456 + ); // x_fb_sources extended inline source map
457 + await test(
458 + './__source__/__compiled__/external/fb-sources-extended/Example',
459 + ); // x_fb_sources extended external source map
460 + await test(
461 + './__source__/__compiled__/inline/react-sources-extended/Example',
462 + ); // x_react_sources extended inline source map
463 + await test(
464 + './__source__/__compiled__/external/react-sources-extended/Example',
465 + ); // x_react_sources extended external source map
466 + // TODO test no-columns and bundle cases with extended source maps
467 + });
468 +
469 + it('should work with more complex files and components', async () => {
470 + async function test(path, name = undefined) {
471 + const components = name != null ? require(path)[name] : require(path);
472 +
473 + let hookNames = await getHookNamesForComponent(components.List);
474 + expectHookNamesToEqual(hookNames, [
475 + 'newItemText', // useState
476 + 'items', // useState
477 + 'uid', // useState
478 + 'handleClick', // useCallback
479 + 'handleKeyPress', // useCallback
480 + 'handleChange', // useCallback
481 + 'removeItem', // useCallback
482 + 'toggleItem', // useCallback
483 + ]);
484 +
485 + hookNames = await getHookNamesForComponent(components.ListItem, {
486 + item: {},
487 + });
488 + expectHookNamesToEqual(hookNames, [
489 + 'handleDelete', // useCallback
490 + 'handleToggle', // useCallback
491 + ]);
492 +
493 + expect(parseMock).toHaveBeenCalledTimes(0);
494 + }
495 +
496 + await test('./__source__/ToDoList'); // original source (uncompiled)
497 + await test(
498 + './__source__/__compiled__/inline/fb-sources-extended/ToDoList',
499 + ); // x_fb_sources extended inline source map
500 + await test(
501 + './__source__/__compiled__/external/fb-sources-extended/ToDoList',
502 + ); // x_fb_sources extended external source map
503 + await test(
504 + './__source__/__compiled__/inline/react-sources-extended/ToDoList',
505 + ); // x_react_sources extended inline source map
506 + await test(
507 + './__source__/__compiled__/external/react-sources-extended/ToDoList',
508 + ); // x_react_sources extended external source map
509 + // TODO test no-columns and bundle cases with extended source maps
510 + });
511 +
512 + it('should work for custom hook', async () => {
513 + async function test(path, name = 'Component') {
514 + const Component = require(path)[name];
515 + const hookNames = await getHookNamesForComponent(Component);
516 + expectHookNamesToEqual(hookNames, [
517 + 'count', // useState()
518 + 'isDarkMode', // useIsDarkMode()
519 + 'isDarkMode', // useIsDarkMode -> useState()
520 + ]);
521 + expect(parseMock).toHaveBeenCalledTimes(0);
522 + }
523 +
524 + await test('./__source__/ComponentWithCustomHook'); // original source (uncompiled)
525 + await test(
526 + './__source__/__compiled__/inline/fb-sources-extended/ComponentWithCustomHook',
527 + ); // x_fb_sources extended inline source map
528 + await test(
529 + './__source__/__compiled__/external/fb-sources-extended/ComponentWithCustomHook',
530 + ); // x_fb_sources extended external source map
531 + await test(
532 + './__source__/__compiled__/inline/react-sources-extended/ComponentWithCustomHook',
533 + ); // x_react_sources extended inline source map
534 + await test(
535 + './__source__/__compiled__/external/react-sources-extended/ComponentWithCustomHook',
536 + ); // x_react_sources extended external source map
537 + // TODO test no-columns and bundle cases with extended source maps
538 + });
539 +
540 + it('should work when code is using hooks indirectly', async () => {
541 + async function test(path, name = 'Component') {
542 + const Component = require(path)[name];
543 + const hookNames = await getHookNamesForComponent(Component);
544 + expectHookNamesToEqual(hookNames, [
545 + 'count', // useState()
546 + 'darkMode', // useDarkMode()
547 + 'isDarkMode', // useState()
548 + ]);
549 + expect(parseMock).toHaveBeenCalledTimes(0);
550 + }
551 +
552 + await test(
553 + './__source__/__compiled__/inline/fb-sources-extended/ComponentUsingHooksIndirectly',
554 + ); // x_fb_sources extended inline source map
555 + await test(
556 + './__source__/__compiled__/external/fb-sources-extended/ComponentUsingHooksIndirectly',
557 + ); // x_fb_sources extended external source map
558 + await test(
559 + './__source__/__compiled__/inline/react-sources-extended/ComponentUsingHooksIndirectly',
560 + ); // x_react_sources extended inline source map
561 + await test(
562 + './__source__/__compiled__/external/react-sources-extended/ComponentUsingHooksIndirectly',
563 + ); // x_react_sources extended external source map
564 + // TODO test no-columns and bundle cases with extended source maps
565 + });
566 +
567 + it('should work when code is using nested hooks', async () => {
568 + async function test(path, name = 'Component') {
569 + const Component = require(path)[name];
570 + let InnerComponent;
571 + const hookNames = await getHookNamesForComponent(Component, {
572 + callback: innerComponent => {
573 + InnerComponent = innerComponent;
574 + },
575 + });
576 + const innerHookNames = await getHookNamesForComponent(InnerComponent);
577 + expectHookNamesToEqual(hookNames, [
578 + 'InnerComponent', // useMemo()
579 + ]);
580 + expectHookNamesToEqual(innerHookNames, [
581 + 'state', // useState()
582 + ]);
583 + expect(parseMock).toHaveBeenCalledTimes(0);
584 + }
585 +
586 + await test(
587 + './__source__/__compiled__/inline/fb-sources-extended/ComponentWithNestedHooks',
588 + ); // x_fb_sources extended inline source map
589 + await test(
590 + './__source__/__compiled__/external/fb-sources-extended/ComponentWithNestedHooks',
591 + ); // x_fb_sources extended external source map
592 + await test(
593 + './__source__/__compiled__/inline/react-sources-extended/ComponentWithNestedHooks',
594 + ); // x_react_sources extended inline source map
595 + await test(
596 + './__source__/__compiled__/external/react-sources-extended/ComponentWithNestedHooks',
597 + ); // x_react_sources extended external source map
598 + // TODO test no-columns and bundle cases with extended source maps
599 + });
600 +
601 + it('should work for external hooks', async () => {
602 + async function test(path, name = 'Component') {
603 + const Component = require(path)[name];
604 + const hookNames = await getHookNamesForComponent(Component);
605 + expectHookNamesToEqual(hookNames, [
606 + 'theme', // useTheme()
607 + 'theme', // useContext()
608 + ]);
609 + expect(parseMock).toHaveBeenCalledTimes(0);
610 + }
611 +
612 + // We can't test the uncompiled source here, because it either needs to get transformed,
613 + // which would break the source mapping, or the import statements will fail.
614 +
615 + await test(
616 + './__source__/__compiled__/inline/fb-sources-extended/ComponentWithExternalCustomHooks',
617 + ); // x_fb_sources extended inline source map
618 + await test(
619 + './__source__/__compiled__/external/fb-sources-extended/ComponentWithExternalCustomHooks',
620 + ); // x_fb_sources extended external source map
621 + await test(
622 + './__source__/__compiled__/inline/react-sources-extended/ComponentWithExternalCustomHooks',
623 + ); // x_react_sources extended inline source map
624 + await test(
625 + './__source__/__compiled__/external/react-sources-extended/ComponentWithExternalCustomHooks',
626 + ); // x_react_sources extended external source map
627 + // TODO test no-columns and bundle cases with extended source maps
628 + });
629 +
630 + it('should work when multiple hooks are on a line', async () => {
631 + async function test(path, name = 'Component') {
632 + const Component = require(path)[name];
633 + const hookNames = await getHookNamesForComponent(Component);
634 + expectHookNamesToEqual(hookNames, [
635 + 'a', // useContext()
636 + 'b', // useContext()
637 + 'c', // useContext()
638 + 'd', // useContext()
639 + ]);
640 + expect(parseMock).toHaveBeenCalledTimes(0);
641 + }
642 +
643 + await test(
644 + './__source__/__compiled__/inline/fb-sources-extended/ComponentWithMultipleHooksPerLine',
645 + ); // x_fb_sources extended inline source map
646 + await test(
647 + './__source__/__compiled__/external/fb-sources-extended/ComponentWithMultipleHooksPerLine',
648 + ); // x_fb_sources extended external source map
649 + await test(
650 + './__source__/__compiled__/inline/react-sources-extended/ComponentWithMultipleHooksPerLine',
651 + ); // x_react_sources extended inline source map
652 + await test(
653 + './__source__/__compiled__/external/react-sources-extended/ComponentWithMultipleHooksPerLine',
654 + ); // x_react_sources extended external source map
655 + // TODO test no-columns and bundle cases with extended source maps
656 + });
657 +
658 + // TODO Inline require (e.g. require("react").useState()) isn't supported yet.
659 + // Maybe this isn't an important use case to support,
660 + // since inline requires are most likely to exist in compiled source (if at all).
661 + xit('should work for inline requires', async () => {
662 + async function test(path, name = 'Component') {
663 + const Component = require(path)[name];
664 + const hookNames = await getHookNamesForComponent(Component);
665 + expectHookNamesToEqual(hookNames, [
666 + 'count', // useState()
667 + ]);
668 + expect(parseMock).toHaveBeenCalledTimes(0);
669 + }
670 +
671 + await test('./__source__/InlineRequire'); // original source (uncompiled)
672 + await test(
673 + './__source__/__compiled__/inline/fb-sources-extended/InlineRequire',
674 + ); // x_fb_sources extended inline source map
675 + await test(
676 + './__source__/__compiled__/external/fb-sources-extended/InlineRequire',
677 + ); // x_fb_sources extended external source map
678 + await test(
679 + './__source__/__compiled__/inline/react-sources-extended/InlineRequire',
680 + ); // x_react_sources extended inline source map
681 + await test(
682 + './__source__/__compiled__/external/react-sources-extended/InlineRequire',
683 + ); // x_react_sources extended external source map
684 + // TODO test no-columns and bundle cases with extended source maps
685 + });
686 +
687 + it('should support sources that contain the string "sourceMappingURL="', async () => {
688 + async function test(path, name = 'Component') {
689 + const Component = require(path)[name];
690 + const hookNames = await getHookNamesForComponent(Component);
691 + expectHookNamesToEqual(hookNames, [
692 + 'count', // useState()
693 + ]);
694 + expect(parseMock).toHaveBeenCalledTimes(0);
695 + }
696 +
697 + // We expect the inline sourceMappingURL to be invalid in this case; mute the warning.
698 + console.warn = () => {};
699 +
700 + await test('./__source__/ContainingStringSourceMappingURL'); // original source (uncompiled)
701 + await test(
702 + './__source__/__compiled__/inline/fb-sources-extended/ContainingStringSourceMappingURL',
703 + ); // x_fb_sources extended inline source map
704 + await test(
705 + './__source__/__compiled__/external/fb-sources-extended/ContainingStringSourceMappingURL',
706 + ); // x_fb_sources extended external source map
707 + await test(
708 + './__source__/__compiled__/inline/react-sources-extended/ContainingStringSourceMappingURL',
709 + ); // x_react_sources extended inline source map
710 + await test(
711 + './__source__/__compiled__/external/react-sources-extended/ContainingStringSourceMappingURL',
712 + ); // x_react_sources extended external source map
713 + // TODO test no-columns and bundle cases with extended source maps
714 + });
715 + });
716 });
717
718 describe('parseHookNames worker', () => {
packages/react-devtools-extensions/src/__tests__/updateMockSourceMaps.js
+88 -10
@@ -15,6 +15,8 @@ const commonjs = require('rollup-plugin-commonjs');
15 const jsx = require('acorn-jsx');
16 const rollupResolve = require('rollup-plugin-node-resolve');
17 const {encode, decode} = require('sourcemap-codec');
18 +const {generateEncodedHookMap} = require('../generateHookMap');
19 +const {parse} = require('@babel/parser');
20
21 const sourceDir = resolve(__dirname, '__source__');
22 const buildRoot = resolve(sourceDir, '__compiled__');
@@ -22,6 +24,19 @@ const externalDir = resolve(buildRoot, 'external');
24 const inlineDir = resolve(buildRoot, 'inline');
25 const bundleDir = resolve(buildRoot, 'bundle');
26 const noColumnsDir = resolve(buildRoot, 'no-columns');
27 +const inlineFbSourcesExtendedDir = resolve(inlineDir, 'fb-sources-extended');
28 +const externalFbSourcesExtendedDir = resolve(
29 + externalDir,
30 + 'fb-sources-extended',
31 +);
32 +const inlineReactSourcesExtendedDir = resolve(
33 + inlineDir,
34 + 'react-sources-extended',
35 +);
36 +const externalReactSourcesExtendedDir = resolve(
37 + externalDir,
38 + 'react-sources-extended',
39 +);
40
41 // Remove previous builds
42 emptyDirSync(buildRoot);
@@ -29,6 +44,10 @@ mkdirSync(externalDir);
44 mkdirSync(inlineDir);
45 mkdirSync(bundleDir);
46 mkdirSync(noColumnsDir);
47 +mkdirSync(inlineFbSourcesExtendedDir);
48 +mkdirSync(externalFbSourcesExtendedDir);
49 +mkdirSync(inlineReactSourcesExtendedDir);
50 +mkdirSync(externalReactSourcesExtendedDir);
51
52 function compile(fileName) {
53 const code = readFileSync(resolve(sourceDir, fileName), 'utf8');
@@ -63,6 +82,15 @@ function compile(fileName) {
82 'utf8',
83 );
84
85 + // Generate compiled output with inline base64 source maps
86 + writeFileSync(
87 + resolve(inlineDir, fileName),
88 + transformed.code +
89 + '\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,' +
90 + btoa(JSON.stringify(sourceMap)),
91 + 'utf8',
92 + );
93 +
94 // Strip column numbers from source map to mimic Webpack 'cheap-module-source-map'
95 // The mappings field represents a list of integer arrays.
96 // Each array defines a pair of corresponding file locations, one in the generated code and one in the original.
@@ -82,16 +110,7 @@ function compile(fileName) {
110 );
111 const encodedMappings = encode(decodedMappings);
112
85 - // Generate compiled output with external inline base64 source maps
86 - writeFileSync(
87 - resolve(inlineDir, fileName),
88 - transformed.code +
89 - '\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,' +
90 - btoa(JSON.stringify(sourceMap)),
91 - 'utf8',
92 - );
93 -
94 - // Generate compiled output with external inline base64 source maps without column numbers
113 + // Generate compiled output with inline base64 source maps without column numbers
114 writeFileSync(
115 resolve(noColumnsDir, fileName),
116 transformed.code +
@@ -104,6 +123,65 @@ function compile(fileName) {
123 ),
124 'utf8',
125 );
126 +
127 + // Generate compiled output with an extended sourcemap that
128 + // includes a map of hook names.
129 + const parsed = parse(code, {
130 + sourceType: 'module',
131 + plugins: ['jsx', 'flow'],
132 + });
133 + const encodedHookMap = generateEncodedHookMap(parsed);
134 + const fbSourcesExtendedSourceMap = {
135 + ...sourceMap,
136 + // When using the x_fb_sources extension field, the first item
137 + // for a given source is reserved for the Function Map, and the
138 + // Hook Map is added as the second item.
139 + x_fb_sources: [[null, encodedHookMap]],
140 + };
141 + const reactSourcesExtendedSourceMap = {
142 + ...sourceMap,
143 + // When using the x_react_sources extension field, the first item
144 + // for a given source is reserved for the Hook Map.
145 + x_react_sources: [[encodedHookMap]],
146 + };
147 +
148 + // Using the x_fb_sources field
149 + writeFileSync(
150 + resolve(inlineFbSourcesExtendedDir, fileName),
151 + transformed.code +
152 + '\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,' +
153 + btoa(JSON.stringify(fbSourcesExtendedSourceMap)),
154 + 'utf8',
155 + );
156 + writeFileSync(
157 + resolve(externalFbSourcesExtendedDir, fileName),
158 + transformed.code + `\n//# sourceMappingURL=${fileName}.map`,
159 + 'utf8',
160 + );
161 + writeFileSync(
162 + resolve(externalFbSourcesExtendedDir, `${fileName}.map`),
163 + JSON.stringify(fbSourcesExtendedSourceMap),
164 + 'utf8',
165 + );
166 +
167 + // Using the x_react_sources field
168 + writeFileSync(
169 + resolve(inlineReactSourcesExtendedDir, fileName),
170 + transformed.code +
171 + '\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,' +
172 + btoa(JSON.stringify(reactSourcesExtendedSourceMap)),
173 + 'utf8',
174 + );
175 + writeFileSync(
176 + resolve(externalReactSourcesExtendedDir, fileName),
177 + transformed.code + `\n//# sourceMappingURL=${fileName}.map`,
178 + 'utf8',
179 + );
180 + writeFileSync(
181 + resolve(externalReactSourcesExtendedDir, `${fileName}.map`),
182 + JSON.stringify(reactSourcesExtendedSourceMap),
183 + 'utf8',
184 + );
185 }
186
187 async function bundle() {
packages/react-devtools-extensions/src/astUtils.js
+221 -7
@@ -12,6 +12,11 @@ import {File} from '@babel/types';
12
13 import type {HooksNode} from 'react-debug-tools/src/ReactDebugHooks';
14
15 +export type Position = {|
16 + line: number,
17 + column: number,
18 +|};
19 +
20 export type SourceConsumer = any;
21
22 export type SourceFileASTWithHookDetails = {
@@ -20,12 +25,16 @@ export type SourceFileASTWithHookDetails = {
25 source: string,
26 };
27
28 +export const NO_HOOK_NAME = '<no-hook>';
29 +
30 const AST_NODE_TYPES = Object.freeze({
31 + PROGRAM: 'Program',
32 CALL_EXPRESSION: 'CallExpression',
33 MEMBER_EXPRESSION: 'MemberExpression',
34 ARRAY_PATTERN: 'ArrayPattern',
35 IDENTIFIER: 'Identifier',
36 NUMERIC_LITERAL: 'NumericLiteral',
37 + VARIABLE_DECLARATOR: 'VariableDeclarator',
38 });
39
40 // Check if line number obtained from source map and the line number in hook node match
@@ -51,7 +60,6 @@ function checkNodeLocation(
60 //
61 // For more info see https://github.com/facebook/react/pull/21833#discussion_r666831276
62 column -= 1;
54 -
63 if (
64 (line === start.line && column < start.column) ||
65 (line === end.line && column > end.column)
@@ -284,13 +292,209 @@ function getPotentialHookDeclarationsFromAST(sourceAST: File): NodePath[] {
292 return potentialHooksFound;
293 }
294
295 +/**
296 + * This function traverses the sourceAST and returns a mapping
297 + * that maps locations in the source code to their corresponding
298 + * Hook name, if there is a relevant Hook name for that location.
299 + *
300 + * A location in the source code is represented by line and column
301 + * numbers as a Position object: { line, column }.
302 + * - line is 1-indexed.
303 + * - column is 0-indexed.
304 + *
305 + * A Hook name will be assigned to a Hook CallExpression if the
306 + * CallExpression is for a variable declaration (i.e. it returns
307 + * a value that is assigned to a variable), and if we can reliably
308 + * infer the correct name to use (see comments in the function body
309 + * for more details).
310 + *
311 + * The returned mapping is an array of locations and their assigned
312 + * names, sorted by location. Specifically, each entry in the array
313 + * contains a `name` and a `start` Position. The `name` of a given
314 + * entry is the "assigned" name in the source code until the `start`
315 + * of the **next** entry. This means that given the mapping, in order
316 + * to determine the Hook name assigned for a given source location, we
317 + * need to find the adjacent entries that most closely contain the given
318 + * location.
319 + *
320 + * E.g. for the following code:
321 + *
322 + * 1| function Component() {
323 + * 2| const [state, setState] = useState(0);
324 + * 3| ^---------^ -> Cols 28 - 38: Hook CallExpression
325 + * 4|
326 + * 5| useEffect(() => {...}); -> call ignored since not declaring a variable
327 + * 6|
328 + * 7| return (...);
329 + * 8| }
330 + *
331 + * The returned "mapping" would be something like:
332 + * [
333 + * {name: '<no-hook>', start: {line: 1, column: 0}},
334 + * {name: 'state', start: {line: 2, column: 28}},
335 + * {name: '<no-hook>', start: {line: 2, column: 38}},
336 + * ]
337 + *
338 + * Where the Hook name `state` (corresponding to the `state` variable)
339 + * is assigned to the location in the code for the CallExpression
340 + * representing the call to `useState(0)` (line 2, col 28-38).
341 + */
342 +export function getHookNamesMappingFromAST(
343 + sourceAST: File,
344 +): $ReadOnlyArray<{|name: string, start: Position|}> {
345 + const hookStack = [];
346 + const hookNames = [];
347 + const pushFrame = (name: string, node: Node) => {
348 + const nameInfo = {name, start: {...node.loc.start}};
349 + hookStack.unshift(nameInfo);
350 + hookNames.push(nameInfo);
351 + };
352 + const popFrame = (node: Node) => {
353 + hookStack.shift();
354 + const top = hookStack[0];
355 + if (top != null) {
356 + hookNames.push({name: top.name, start: {...node.loc.end}});
357 + }
358 + };
359 +
360 + traverse(sourceAST, {
361 + [AST_NODE_TYPES.PROGRAM]: {
362 + enter(path) {
363 + pushFrame(NO_HOOK_NAME, path.node);
364 + },
365 + exit(path) {
366 + popFrame(path.node);
367 + },
368 + },
369 + [AST_NODE_TYPES.VARIABLE_DECLARATOR]: {
370 + enter(path) {
371 + // Check if this variable declaration corresponds to a variable
372 + // declared by calling a Hook.
373 + if (isConfirmedHookDeclaration(path)) {
374 + const hookDeclaredVariableName = getHookVariableName(path);
375 + if (!hookDeclaredVariableName) {
376 + return;
377 + }
378 + const callExpressionNode = assertCallExpression(path.node.init);
379 +
380 + // Check if this variable declaration corresponds to a call to a
381 + // built-in Hook that returns a tuple (useState, useReducer,
382 + // useTransition).
383 + // If it doesn't, we immediately use the declared variable name
384 + // as the Hook name. We do this because for any other Hooks that
385 + // aren't the built-in Hooks that return a tuple, we can't reliably
386 + // extract a Hook name from other variable declartions derived from
387 + // this one, since we don't know which of the declared variables
388 + // are the relevant ones to track and show in dev tools.
389 + if (!isBuiltInHookThatReturnsTuple(path)) {
390 + pushFrame(hookDeclaredVariableName, callExpressionNode);
391 + return;
392 + }
393 +
394 + // Check if the variable declared by the Hook call is referenced
395 + // anywhere else in the code. If not, we immediately use the
396 + // declared variable name as the Hook name.
397 + const referencePaths =
398 + hookDeclaredVariableName != null
399 + ? path.scope.bindings[hookDeclaredVariableName]?.referencePaths
400 + : null;
401 + if (referencePaths == null) {
402 + pushFrame(hookDeclaredVariableName, callExpressionNode);
403 + return;
404 + }
405 +
406 + // Check each reference to the variable declared by the Hook call,
407 + // and for each, we do the following:
408 + let declaredVariableName = null;
409 + for (let i = 0; i <= referencePaths.length; i++) {
410 + const referencePath = referencePaths[i];
411 + if (declaredVariableName != null) {
412 + break;
413 + }
414 +
415 + // 1. Check if the reference is contained within a VariableDeclarator
416 + // Node. This will allow us to determine if the variable declared by
417 + // the Hook call is being used to declare other variables.
418 + let variableDeclaratorPath = referencePath;
419 + while (
420 + variableDeclaratorPath != null &&
421 + variableDeclaratorPath.node.type !==
422 + AST_NODE_TYPES.VARIABLE_DECLARATOR
423 + ) {
424 + variableDeclaratorPath = variableDeclaratorPath.parentPath;
425 + }
426 +
427 + // 2. If we find a VariableDeclarator containing the
428 + // referenced variable, we extract the Hook name from the new
429 + // variable declaration.
430 + // E.g., a case like the following:
431 + // const countState = useState(0);
432 + // const count = countState[0];
433 + // const setCount = countState[1]
434 + // Where the reference to `countState` is later referenced
435 + // within a VariableDeclarator, so we can extract `count` as
436 + // the Hook name.
437 + const varDeclInit = variableDeclaratorPath?.node.init;
438 + if (varDeclInit != null) {
439 + switch (varDeclInit.type) {
440 + case AST_NODE_TYPES.MEMBER_EXPRESSION: {
441 + // When encountering a MemberExpression inside the new
442 + // variable declaration, we only want to extract the variable
443 + // name if we're assinging the value of the first member,
444 + // which is handled by `filterMemberWithHookVariableName`.
445 + // E.g.
446 + // const countState = useState(0);
447 + // const count = countState[0]; -> extract the name from this reference
448 + // const setCount = countState[1]; -> ignore this reference
449 + if (
450 + filterMemberWithHookVariableName(variableDeclaratorPath)
451 + ) {
452 + declaredVariableName = getHookVariableName(
453 + variableDeclaratorPath,
454 + );
455 + }
456 + break;
457 + }
458 + case AST_NODE_TYPES.IDENTIFIER: {
459 + declaredVariableName = getHookVariableName(
460 + variableDeclaratorPath,
461 + );
462 + break;
463 + }
464 + default:
465 + break;
466 + }
467 + }
468 + }
469 +
470 + // If we were able to extract a name from the new variable
471 + // declaration, use it as the Hook name. Otherwise, use the
472 + // original declared variable as the variable name.
473 + if (declaredVariableName != null) {
474 + pushFrame(declaredVariableName, callExpressionNode);
475 + } else {
476 + pushFrame(hookDeclaredVariableName, callExpressionNode);
477 + }
478 + }
479 + },
480 + exit(path) {
481 + if (isConfirmedHookDeclaration(path)) {
482 + const callExpressionNode = assertCallExpression(path.node.init);
483 + popFrame(callExpressionNode);
484 + }
485 + },
486 + },
487 + });
488 + return hookNames;
489 +}
490 +
491 // Check if 'path' contains declaration of the form const X = useState(0);
492 function isConfirmedHookDeclaration(path: NodePath): boolean {
289 - const node = path.node.init;
290 - if (node.type !== AST_NODE_TYPES.CALL_EXPRESSION) {
493 + const nodeInit = path.node.init;
494 + if (nodeInit == null || nodeInit.type !== AST_NODE_TYPES.CALL_EXPRESSION) {
495 return false;
496 }
293 - const callee = node.callee;
497 + const callee = nodeInit.callee;
498 return isHook(callee);
499 }
500
@@ -370,10 +574,12 @@ function isReactFunction(node: Node, functionName: string): boolean {
574 }
575
576 // Check if 'path' is either State or Reducer hook
373 -function isStateOrReducerHook(path: NodePath): boolean {
577 +function isBuiltInHookThatReturnsTuple(path: NodePath): boolean {
578 const callee = path.node.init.callee;
579 return (
376 - isReactFunction(callee, 'useState') || isReactFunction(callee, 'useReducer')
580 + isReactFunction(callee, 'useState') ||
581 + isReactFunction(callee, 'useReducer') ||
582 + isReactFunction(callee, 'useTransition')
583 );
584 }
585
@@ -394,9 +600,17 @@ function nodeContainsHookVariableName(hookNode: NodePath): boolean {
600 const node = hookNode.node.id;
601 if (
602 node.type === AST_NODE_TYPES.ARRAY_PATTERN ||
397 - (node.type === AST_NODE_TYPES.IDENTIFIER && !isStateOrReducerHook(hookNode))
603 + (node.type === AST_NODE_TYPES.IDENTIFIER &&
604 + !isBuiltInHookThatReturnsTuple(hookNode))
605 ) {
606 return true;
607 }
608 return false;
609 }
610 +
611 +function assertCallExpression(node: Node): Node {
612 + if (node.type !== AST_NODE_TYPES.CALL_EXPRESSION) {
613 + throw new Error('Expected a CallExpression node for a Hook declaration.');
614 + }
615 + return node;
616 +}
packages/react-devtools-extensions/src/generateHookMap.js new
+123
@@ -0,0 +1,123 @@
1 +/*
2 + * Copyright (c) Facebook, Inc. and its affiliates.
3 + *
4 + * This source code is licensed under the MIT license found in the
5 + * LICENSE file in the root directory of this source tree.
6 + *
7 + * @flow
8 + */
9 +
10 +import {getHookNamesMappingFromAST} from './astUtils';
11 +import {encode, decode} from 'sourcemap-codec';
12 +import {File} from '@babel/types';
13 +
14 +export type HookMap = {|
15 + names: $ReadOnlyArray<string>,
16 + mappings: HookMapMappings,
17 +|};
18 +
19 +export type EncodedHookMap = {|
20 + names: $ReadOnlyArray<string>,
21 + mappings: string,
22 +|};
23 +
24 +// See generateHookMap below for more details on formatting
25 +export type HookMapEntry = [
26 + number, // 1-indexed line number
27 + number, // 0-indexed column number
28 + number, // 0-indexed index into names array
29 + number, // TODO: filler number to support reusing encoding from `sourcemap-codec` (see TODO below)
30 +];
31 +export type HookMapLine = HookMapEntry[];
32 +export type HookMapMappings = HookMapLine[];
33 +
34 +/**
35 + * Given a parsed source code AST, returns a "Hook Map", which is a
36 + * mapping which maps locations in the source code to their to their
37 + * corresponding Hook name, if there is a relevant Hook name for that
38 + * location (see getHookNamesMappingFromAST for details on the
39 + * representation of the mapping).
40 + *
41 + * The format of the Hook Map follows a similar format as the `name`
42 + * and `mappings` fields in the Source Map spec, where `names` is an
43 + * array of strings, and `mappings` contains segments lines, columns,
44 + * and indices into the `names` array.
45 + *
46 + * E.g.:
47 + * {
48 + * names: ["<no-hook>", "state"],
49 + * mappings: [
50 + * [ -> line 1
51 + * [1, 0, 0], -> line, col, name index
52 + * ],
53 + * [ -> line 2
54 + * [2, 5, 1], -> line, col, name index
55 + * [2, 15, 0], -> line, col, name index
56 + * ],
57 + * ],
58 + * }
59 + */
60 +export function generateHookMap(sourceAST: File): HookMap {
61 + const hookNamesMapping = getHookNamesMappingFromAST(sourceAST);
62 + const namesMap: Map<string, number> = new Map();
63 + const names = [];
64 + const mappings = [];
65 +
66 + let currentLine = null;
67 + hookNamesMapping.forEach(({name, start}) => {
68 + let nameIndex = namesMap.get(name);
69 + if (nameIndex == null) {
70 + names.push(name);
71 + nameIndex = names.length - 1;
72 + namesMap.set(name, nameIndex);
73 + }
74 +
75 + // TODO: We add a -1 at the end of the entry so we can later
76 + // encode/decode the mappings by reusing the encode/decode functions
77 + // from the `sourcemap-codec` library. This library expects segments
78 + // of specific sizes (i.e. of size 4) in order to encode them correctly.
79 + // In the future, when we implement our own encoding, we will not
80 + // need this restriction and can remove the -1 at the end.
81 + const entry = [start.line, start.column, nameIndex, -1];
82 +
83 + if (currentLine !== start.line) {
84 + currentLine = start.line;
85 + mappings.push([entry]);
86 + } else {
87 + const current = mappings[mappings.length - 1];
88 + current.push(entry);
89 + }
90 + });
91 +
92 + return {names, mappings};
93 +}
94 +
95 +/**
96 + * Returns encoded version of a Hook Map that is returned
97 + * by generateHookMap.
98 + *
99 + * **NOTE:**
100 + * TODO: To encode the `mappings` in the Hook Map, we
101 + * reuse the encode function from the `sourcemap-codec`
102 + * library, which means that we are restricted to only
103 + * encoding segments of specific sizes.
104 + * Inside generateHookMap we make sure to build segments
105 + * of size 4.
106 + * In the future, when we implement our own encoding, we will not
107 + * need this restriction and can remove the -1 at the end.
108 + */
109 +export function generateEncodedHookMap(sourceAST: File): EncodedHookMap {
110 + const hookMap = generateHookMap(sourceAST);
111 + const encoded = encode(hookMap.mappings);
112 + return {
113 + names: hookMap.names,
114 + mappings: encoded,
115 + };
116 +}
117 +
118 +export function decodeHookMap(encodedHookMap: EncodedHookMap): HookMap {
119 + return {
120 + names: encodedHookMap.names,
121 + mappings: decode(encodedHookMap.mappings),
122 + };
123 +}
packages/react-devtools-extensions/src/getHookNameForLocation.js new
+274
@@ -0,0 +1,274 @@
1 +/*
2 + * Copyright (c) Facebook, Inc. and its affiliates.
3 + *
4 + * This source code is licensed under the MIT license found in the
5 + * LICENSE file in the root directory of this source tree.
6 + *
7 + * @flow strict-local
8 + */
9 +
10 +import type {
11 + HookMap,
12 + HookMapEntry,
13 + HookMapLine,
14 + HookMapMappings,
15 +} from './generateHookMap';
16 +import type {Position} from './astUtils';
17 +import {NO_HOOK_NAME} from './astUtils';
18 +
19 +/**
20 + * Finds the Hook name assigned to a given location in the source code,
21 + * and a HookMap extracted from an extended source map.
22 + * The given location must correspond to the location in the *original*
23 + * source code (i.e. *not* the generated one).
24 + *
25 + * Note that all locations in the source code are guaranteed to map
26 + * to a name, including a sentinel value that represents a missing
27 + * Hook name: '<no-hook>'.
28 + *
29 + * For more details on the format of the HookMap, see generateHookMap
30 + * and the tests for that function and this function.
31 + */
32 +export function getHookNameForLocation(
33 + location: Position,
34 + hookMap: HookMap,
35 +): string | null {
36 + const {names, mappings} = hookMap;
37 +
38 + // The HookMap mappings are grouped by lines, so first we look up
39 + // which line of mappings covers the target location.
40 + // Note that we expect to find a line since all the locations in the
41 + // source code are guaranteed to map to a name, including a '<no-hook>'
42 + // name.
43 + const foundLine = binSearch(location, mappings, compareLinePositions);
44 + if (foundLine == null) {
45 + throw new Error(
46 + `Expected to find a line in the HookMap that covers the target location at line: ${location.line}, column: ${location.column}`,
47 + );
48 + }
49 +
50 + let foundEntry;
51 + const foundLineNumber = getLineNumberFromLine(foundLine);
52 + // The line found in the mappings will never be larger than the target
53 + // line, and vice-versa, so if the target line doesn't match the found
54 + // line, we immediately know that it must correspond to the last mapping
55 + // entry for that line.
56 + if (foundLineNumber !== location.line) {
57 + foundEntry = foundLine[foundLine.length - 1];
58 + } else {
59 + foundEntry = binSearch(location, foundLine, compareColumnPositions);
60 + }
61 +
62 + if (foundEntry == null) {
63 + throw new Error(
64 + `Expected to find a mapping in the HookMap that covers the target location at line: ${location.line}, column: ${location.column}`,
65 + );
66 + }
67 +
68 + const foundNameIndex = getHookNameIndexFromEntry(foundEntry);
69 + if (foundNameIndex == null) {
70 + throw new Error(
71 + `Expected to find a name index in the HookMap that covers the target location at line: ${location.line}, column: ${location.column}`,
72 + );
73 + }
74 + const foundName = names[foundNameIndex];
75 + if (foundName == null) {
76 + throw new Error(
77 + `Expected to find a name in the HookMap that covers the target location at line: ${location.line}, column: ${location.column}`,
78 + );
79 + }
80 +
81 + if (foundName === NO_HOOK_NAME) {
82 + return null;
83 + }
84 + return foundName;
85 +}
86 +
87 +function binSearch<T>(
88 + location: Position,
89 + items: T[],
90 + compare: (
91 + location: Position,
92 + items: T[],
93 + index: number,
94 + ) => {|index: number | null, direction: number|},
95 +): T | null {
96 + let count = items.length;
97 + let index = 0;
98 + let firstElementIndex = 0;
99 + let step;
100 +
101 + while (count > 0) {
102 + index = firstElementIndex;
103 + step = Math.floor(count / 2);
104 + index += step;
105 +
106 + const comparison = compare(location, items, index);
107 + if (comparison.direction === 0) {
108 + if (comparison.index == null) {
109 + throw new Error('Expected an index when matching element is found.');
110 + }
111 + firstElementIndex = comparison.index;
112 + break;
113 + }
114 +
115 + if (comparison.direction > 0) {
116 + index++;
117 + firstElementIndex = index;
118 + count -= step + 1;
119 + } else {
120 + count = step;
121 + }
122 + }
123 +
124 + return firstElementIndex != null ? items[firstElementIndex] : null;
125 +}
126 +
127 +/**
128 + * Compares the target line location to the current location
129 + * given by the provided index.
130 + *
131 + * If the target line location matches the current location, returns
132 + * the index of the matching line in the mappings. In order for a line
133 + * to match, the target line must match the line exactly, or be within
134 + * the line range of the current line entries and the adjacent line
135 + * entries.
136 + *
137 + * If the line doesn't match, returns the search direction for the
138 + * next step in the binary search.
139 + */
140 +function compareLinePositions(
141 + location: Position,
142 + mappings: HookMapMappings,
143 + index: number,
144 +): {|index: number | null, direction: number|} {
145 + const startIndex = index;
146 + const start = mappings[startIndex];
147 + if (start == null) {
148 + throw new Error(`Unexpected line missing in HookMap at index ${index}.`);
149 + }
150 + const startLine = getLineNumberFromLine(start);
151 +
152 + let endLine;
153 + let endIndex = index + 1;
154 + const end = mappings[endIndex];
155 + if (end != null) {
156 + endLine = getLineNumberFromLine(end);
157 + } else {
158 + endIndex = startIndex;
159 + endLine = startLine;
160 + }
161 +
162 + // When the line matches exactly, return the matching index
163 + if (startLine === location.line) {
164 + return {index: startIndex, direction: 0};
165 + }
166 + if (endLine === location.line) {
167 + return {index: endIndex, direction: 0};
168 + }
169 +
170 + // If we're at the end of the mappings, and the target line is greater
171 + // than the current line, then this final line must cover the
172 + // target location, so we return it.
173 + if (location.line > endLine && end == null) {
174 + return {index: endIndex, direction: 0};
175 + }
176 +
177 + // If the location is within the current line and the adjacent one,
178 + // we know that the target location must be covered by the current line.
179 + if (startLine < location.line && location.line < endLine) {
180 + return {index: startIndex, direction: 0};
181 + }
182 +
183 + // Otherwise, return the next direction in the search.
184 + return {index: null, direction: location.line - startLine};
185 +}
186 +
187 +/**
188 + * Compares the target column location to the current location
189 + * given by the provided index.
190 + *
191 + * If the target column location matches the current location, returns
192 + * the index of the matching entry in the mappings. In order for a column
193 + * to match, the target column must match the column exactly, or be within
194 + * the column range of the current entry and the adjacent entry.
195 + *
196 + * If the column doesn't match, returns the search direction for the
197 + * next step in the binary search.
198 + */
199 +function compareColumnPositions(
200 + location: Position,
201 + line: HookMapLine,
202 + index: number,
203 +): {|index: number | null, direction: number|} {
204 + const startIndex = index;
205 + const start = line[index];
206 + if (start == null) {
207 + throw new Error(
208 + `Unexpected mapping missing in HookMap line at index ${index}.`,
209 + );
210 + }
211 + const startColumn = getColumnNumberFromEntry(start);
212 +
213 + let endColumn;
214 + let endIndex = index + 1;
215 + const end = line[endIndex];
216 + if (end != null) {
217 + endColumn = getColumnNumberFromEntry(end);
218 + } else {
219 + endIndex = startIndex;
220 + endColumn = startColumn;
221 + }
222 +
223 + // When the column matches exactly, return the matching index
224 + if (startColumn === location.column) {
225 + return {index: startIndex, direction: 0};
226 + }
227 + if (endColumn === location.column) {
228 + return {index: endIndex, direction: 0};
229 + }
230 +
231 + // If we're at the end of the entries for this line, and the target
232 + // column is greater than the current column, then this final entry
233 + // must cover the target location, so we return it.
234 + if (location.column > endColumn && end == null) {
235 + return {index: endIndex, direction: 0};
236 + }
237 +
238 + // If the location is within the current column and the adjacent one,
239 + // we know that the target location must be covered by the current entry.
240 + if (startColumn < location.column && location.column < endColumn) {
241 + return {index: startIndex, direction: 0};
242 + }
243 +
244 + // Otherwise, return the next direction in the search.
245 + return {index: null, direction: location.column - startColumn};
246 +}
247 +
248 +function getLineNumberFromLine(line: HookMapLine): number {
249 + return getLineNumberFromEntry(line[0]);
250 +}
251 +
252 +function getLineNumberFromEntry(entry: HookMapEntry): number {
253 + const lineNumber = entry[0];
254 + if (lineNumber == null) {
255 + throw new Error('Unexpected line number missing in entry in HookMap');
256 + }
257 + return lineNumber;
258 +}
259 +
260 +function getColumnNumberFromEntry(entry: HookMapEntry): number {
261 + const columnNumber = entry[1];
262 + if (columnNumber == null) {
263 + throw new Error('Unexpected column number missing in entry in HookMap');
264 + }
265 + return columnNumber;
266 +}
267 +
268 +function getHookNameIndexFromEntry(entry: HookMapEntry): number {
269 + const hookNameIndex = entry[2];
270 + if (hookNameIndex == null) {
271 + throw new Error('Unexpected hook name index missing in entry in HookMap');
272 + }
273 + return hookNameIndex;
274 +}
packages/react-devtools-extensions/src/parseHookNames/parseHookNames.js
+78 -12
@@ -14,7 +14,10 @@ import {getHookName} from '../astUtils';
14 import {areSourceMapsAppliedToErrors} from '../ErrorTester';
15 import {__DEBUG__} from 'react-devtools-shared/src/constants';
16 import {getHookSourceLocationKey} from 'react-devtools-shared/src/hookNamesCache';
17 +import {decodeHookMap} from '../generateHookMap';
18 +import {getHookNameForLocation} from '../getHookNameForLocation';
19
20 +import type {HookMap} from '../generateHookMap';
21 import type {
22 HooksNode,
23 HookSource,
@@ -26,10 +29,15 @@ import type {SourceConsumer} from '../astUtils';
29
30 const SOURCE_MAP_REGEX = / ?sourceMappingURL=([^\s'"]+)/gm;
31 const MAX_SOURCE_LENGTH = 100_000_000;
32 +const REACT_SOURCES_EXTENSION_KEY = 'x_react_sources';
33 +const FB_SOURCES_EXTENSION_KEY = 'x_fb_sources';
34
35 type AST = mixed;
36
37 type HookSourceData = {|
38 + // Hook map extracted from extended source map
39 + hookMap: HookMap | null,
40 +
41 // Generated by react-debug-tools.
42 hookSource: HookSource,
43
@@ -128,6 +136,7 @@ export async function parseHookNames(
136 const runtimeSourceURL = ((hookSource.fileName: any): string);
137
138 const hookSourceData: HookSourceData = {
139 + hookMap: null,
140 hookSource,
141 originalSourceAST: null,
142 originalSourceCode: null,
@@ -244,12 +253,16 @@ function extractAndLoadSourceMaps(
253
254 // Hook source might be a URL like "https://4syus.csb.app/src/App.js"
255 // Parsed source map might be a partial path like "src/App.js"
247 - const match = parsed.sources.find(
256 + const sourceIndex = parsed.sources.findIndex(
257 source =>
258 source === 'Inline Babel script' ||
259 runtimeSourceURL.endsWith(source),
260 );
252 - if (match) {
261 + if (sourceIndex !== -1) {
262 + const hookMap = extractHookMapFromSourceMap(parsed, sourceIndex);
263 + if (hookMap != null) {
264 + hookSourceData.hookMap = hookMap;
265 + }
266 setPromises.push(
267 new SourceMapConsumer(parsed).then(sourceConsumer => {
268 hookSourceData.sourceConsumer = sourceConsumer;
@@ -288,9 +301,22 @@ function extractAndLoadSourceMaps(
301 const fetchPromise =
302 fetchPromises.get(url) ||
303 fetchFile(url).then(
291 - sourceMapContents =>
292 - new SourceMapConsumer(JSON.parse(sourceMapContents)),
293 -
304 + sourceMapContents => {
305 + const parsed = JSON.parse(sourceMapContents);
306 + const sourceIndex = parsed.sources.findIndex(source =>
307 + runtimeSourceURL.endsWith(source),
308 + );
309 + if (sourceIndex !== -1) {
310 + const hookMap = extractHookMapFromSourceMap(
311 + parsed,
312 + sourceIndex,
313 + );
314 + if (hookMap != null) {
315 + hookSourceData.hookMap = hookMap;
316 + }
317 + }
318 + return new SourceMapConsumer(parsed);
319 + },
320 // In this case, we fall back to the assumption that the source has no source map.
321 // This might indicate an (unlikely) edge case that had no source map,
322 // but contained the string "sourceMappingURL".
@@ -414,13 +440,24 @@ function findHookNames(
440 return null;
441 }
442
417 - const name = getHookName(
418 - hook,
419 - hookSourceData.originalSourceAST,
420 - ((hookSourceData.originalSourceCode: any): string),
421 - ((originalSourceLineNumber: any): number),
422 - originalSourceColumnNumber,
423 - );
443 + let name;
444 + if (hookSourceData.hookMap != null) {
445 + name = getHookNameForLocation(
446 + {
447 + line: originalSourceLineNumber,
448 + column: originalSourceColumnNumber,
449 + },
450 + hookSourceData.hookMap,
451 + );
452 + } else {
453 + name = getHookName(
454 + hook,
455 + hookSourceData.originalSourceAST,
456 + ((hookSourceData.originalSourceCode: any): string),
457 + ((originalSourceLineNumber: any): number),
458 + originalSourceColumnNumber,
459 + );
460 + }
461
462 if (__DEBUG__) {
463 console.log(`findHookNames() Found name "${name || '-'}"`);
@@ -475,6 +512,12 @@ async function parseSourceAST(
512 // Use cached metadata.
513 return;
514 }
515 + if (hookSourceData.hookMap != null) {
516 + // If there's a hook map present from an extended sourcemap then
517 + // we don't need to parse the source files and instead can use the
518 + // hook map to extract hook names.
519 + return;
520 + }
521
522 const {sourceConsumer} = hookSourceData;
523 const runtimeSourceCode = ((hookSourceData.runtimeSourceCode: any): string);
@@ -618,6 +661,29 @@ function updateLruCache(
661 return Promise.resolve();
662 }
663
664 +function extractHookMapFromSourceMap(
665 + sourcemap,
666 + sourceIndex: number,
667 +): HookMap | null {
668 + let hookMap;
669 + if (sourcemap.hasOwnProperty(REACT_SOURCES_EXTENSION_KEY)) {
670 + // When using the x_react_sources extension field, the first item
671 + // for a given source is reserved for the Hook Map, which is why
672 + // we look up the index at position 0.
673 + hookMap = sourcemap[REACT_SOURCES_EXTENSION_KEY][sourceIndex][0];
674 + } else if (sourcemap.hasOwnProperty(FB_SOURCES_EXTENSION_KEY)) {
675 + // When using the x_fb_sources extension field, the first item
676 + // for a given source is reserved for the Function Map, and the
677 + // Hook Map is added as the second item, which is why we look up
678 + // the index at position 1.
679 + hookMap = sourcemap[FB_SOURCES_EXTENSION_KEY][sourceIndex][1];
680 + }
681 + if (hookMap != null) {
682 + return decodeHookMap(hookMap);
683 + }
684 + return null;
685 +}
686 +
687 export function purgeCachedMetadata(): void {
688 originalURLToMetadataCache.reset();
689 runtimeURLToMetadataCache.reset();
scripts/flow/config/flowconfig
+1
@@ -43,6 +43,7 @@ untyped-type-import=error
43 server.max_workers=4
44 esproposal.class_static_fields=enable
45 esproposal.class_instance_fields=enable
46 +esproposal.optional_chaining=enable
47
48 # Substituted by createFlowConfig.js:
49 %REACT_RENDERER_FLOW_OPTIONS%
yarn.lock
+67 -3
@@ -546,6 +546,18 @@
546 chalk "^2.0.0"
547 js-tokens "^4.0.0"
548
549 +"@babel/node@^7.14.7":
550 + version "7.14.7"
551 + resolved "https://registry.yarnpkg.com/@babel/node/-/node-7.14.7.tgz#0090e83e726027ea682240718ca39e4b625b15ad"
552 + integrity sha512-QghINtVgOUCrSpE7z4IXPTGJfRYyjoY7ny5Qz0cuUlsThQv6WSn1xJk217WlEDucPLP2o5HwGXPSkxD4LWOZxQ==
553 + dependencies:
554 + "@babel/register" "^7.14.5"
555 + commander "^4.0.1"
556 + core-js "^3.15.0"
557 + node-environment-flags "^1.0.5"
558 + regenerator-runtime "^0.13.4"
559 + v8flags "^3.1.1"
560 +
561 "@babel/parser@^7.0.0", "@babel/parser@^7.1.0", "@babel/parser@^7.8.3":
562 version "7.8.3"
563 resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.8.3.tgz#790874091d2001c9be6ec426c2eed47bc7679081"
@@ -561,6 +573,11 @@
573 resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.12.5.tgz#b4af32ddd473c0bfa643bd7ff0728b8e71b81ea0"
574 integrity sha512-FVM6RZQ0mn2KCf1VUED7KepYeUWoVShczewOCfm3nzoBybaih51h+sYVVGthW9M6lPByEPTQf+xm27PBdlpwmQ==
575
576 +"@babel/parser@^7.14.8":
577 + version "7.14.8"
578 + resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.14.8.tgz#66fd41666b2d7b840bd5ace7f7416d5ac60208d4"
579 + integrity sha512-syoCQFOoo/fzkWDeM0dLEZi5xqurb5vuyzwIMNZRNun+N/9A4cUZeQaE7dTrB8jGaKuJRBtEOajtnmw0I5hvvA==
580 +
581 "@babel/parser@^7.8.6", "@babel/parser@^7.9.0":
582 version "7.9.4"
583 resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.9.4.tgz#68a35e6b0319bbc014465be43828300113f2f2e8"
@@ -1420,6 +1437,17 @@
1437 "@babel/plugin-transform-react-jsx-source" "^7.10.4"
1438 "@babel/plugin-transform-react-pure-annotations" "^7.10.4"
1439
1440 +"@babel/register@^7.14.5":
1441 + version "7.14.5"
1442 + resolved "https://registry.yarnpkg.com/@babel/register/-/register-7.14.5.tgz#d0eac615065d9c2f1995842f85d6e56c345f3233"
1443 + integrity sha512-TjJpGz/aDjFGWsItRBQMOFTrmTI9tr79CHOK+KIvLeCkbxuOAk2M5QHjvruIMGoo9OuccMh5euplPzc5FjAKGg==
1444 + dependencies:
1445 + clone-deep "^4.0.1"
1446 + find-cache-dir "^2.0.0"
1447 + make-dir "^2.1.0"
1448 + pirates "^4.0.0"
1449 + source-map-support "^0.5.16"
1450 +
1451 "@babel/runtime-corejs2@^7.2.0":
1452 version "7.8.3"
1453 resolved "https://registry.yarnpkg.com/@babel/runtime-corejs2/-/runtime-corejs2-7.8.3.tgz#b62a61e0c41a90d2d91181fda6de21cecd3a9734"
@@ -4701,6 +4729,15 @@ clone-buffer@^1.0.0:
4729 resolved "https://registry.yarnpkg.com/clone-buffer/-/clone-buffer-1.0.0.tgz#e3e25b207ac4e701af721e2cb5a16792cac3dc58"
4730 integrity sha1-4+JbIHrE5wGvch4staFnksrD3Fg=
4731
4732 +clone-deep@^4.0.1:
4733 + version "4.0.1"
4734 + resolved "https://registry.yarnpkg.com/clone-deep/-/clone-deep-4.0.1.tgz#c19fd9bdbbf85942b4fd979c84dcf7d5f07c2387"
4735 + integrity sha512-neHB9xuzh/wk0dIHweyAXv2aPGZIVk3pLMe+/RNzINf17fe0OG96QroktYAUm7SM1PBnzTabaLboqqxDyMU+SQ==
4736 + dependencies:
4737 + is-plain-object "^2.0.4"
4738 + kind-of "^6.0.2"
4739 + shallow-clone "^3.0.0"
4740 +
4741 clone-response@1.0.2, clone-response@^1.0.2:
4742 version "1.0.2"
4743 resolved "https://registry.yarnpkg.com/clone-response/-/clone-response-1.0.2.tgz#d1dc973920314df67fbeb94223b4ee350239e96b"
@@ -5066,6 +5103,11 @@ core-js@^2.4.1, core-js@^2.6.5:
5103 resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.6.11.tgz#38831469f9922bded8ee21c9dc46985e0399308c"
5104 integrity sha512-5wjnpaT/3dV+XB4borEsnAYQchn00XSgTAWKDkEqv+K8KevjbzmofK6hfJ9TZIlpj2N0xQpazy7PiRQiWHqzWg==
5105
5106 +core-js@^3.15.0:
5107 + version "3.16.0"
5108 + resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.16.0.tgz#1d46fb33720bc1fa7f90d20431f36a5540858986"
5109 + integrity sha512-5+5VxRFmSf97nM8Jr2wzOwLqRo6zphH2aX+7KsAUONObyzakDNq2G/bgbhinxB4PoV9L3aXQYhiDKyIKWd2c8g==
5110 +
5111 core-js@^3.6.5:
5112 version "3.6.5"
5113 resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.6.5.tgz#7395dc273af37fb2e50e9bd3d9fe841285231d1a"
@@ -11210,6 +11252,14 @@ node-cleanup@^2.1.2:
11252 resolved "https://registry.yarnpkg.com/node-cleanup/-/node-cleanup-2.1.2.tgz#7ac19abd297e09a7f72a71545d951b517e4dde2c"
11253 integrity sha1-esGavSl+Caf3KnFUXZUbUX5N3iw=
11254
11255 +node-environment-flags@^1.0.5:
11256 + version "1.0.6"
11257 + resolved "https://registry.yarnpkg.com/node-environment-flags/-/node-environment-flags-1.0.6.tgz#a30ac13621f6f7d674260a54dede048c3982c088"
11258 + integrity sha512-5Evy2epuL+6TM0lCQGpFIj6KwiEsGh1SrHUhTbNX+sLbBtjidPZFAnVK9y5yU1+h//RitLbRHTIMyxQPtxMdHw==
11259 + dependencies:
11260 + object.getownpropertydescriptors "^2.0.3"
11261 + semver "^5.7.0"
11262 +
11263 node-fetch@2.6.1:
11264 version "2.6.1"
11265 resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.1.tgz#045bd323631f76ed2e2b55573394416b639a0052"
@@ -12353,7 +12403,7 @@ pinpoint@^1.1.0:
12403 resolved "https://registry.yarnpkg.com/pinpoint/-/pinpoint-1.1.0.tgz#0cf7757a6977f1bf7f6a32207b709e377388e874"
12404 integrity sha1-DPd1eml38b9/ajIge3CeN3OI6HQ=
12405
12356 -pirates@^4.0.1:
12406 +pirates@^4.0.0, pirates@^4.0.1:
12407 version "4.0.1"
12408 resolved "https://registry.yarnpkg.com/pirates/-/pirates-4.0.1.tgz#643a92caf894566f91b2b986d2c66950a8e2fb87"
12409 integrity sha512-WuNqLTbMI3tmfef2TKxlQmAiLHKtFhlsCZnPIpuv2Ow0RDVO8lfy1Opf4NUzlMXLjPl+Men7AuVdX6TA+s+uGA==
@@ -13830,7 +13880,7 @@ semver-truncate@^1.1.2:
13880 dependencies:
13881 semver "^5.3.0"
13882
13833 -"semver@2 || 3 || 4 || 5", semver@^5.0.3, semver@^5.1.0, semver@^5.3.0, semver@^5.4.1, semver@^5.5.0, semver@^5.5.1, semver@^5.6.0:
13883 +"semver@2 || 3 || 4 || 5", semver@^5.0.3, semver@^5.1.0, semver@^5.3.0, semver@^5.4.1, semver@^5.5.0, semver@^5.5.1, semver@^5.6.0, semver@^5.7.0:
13884 version "5.7.1"
13885 resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7"
13886 integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==
@@ -13957,6 +14007,13 @@ sha.js@^2.4.0, sha.js@^2.4.8, sha.js@~2.4.4:
14007 inherits "^2.0.1"
14008 safe-buffer "^5.0.1"
14009
14010 +shallow-clone@^3.0.0:
14011 + version "3.0.1"
14012 + resolved "https://registry.yarnpkg.com/shallow-clone/-/shallow-clone-3.0.1.tgz#8f2981ad92531f55035b01fb230769a40e02efa3"
14013 + integrity sha512-/6KqX+GVUdqPuPPd2LxDDxzX6CAbjJehAAOKlNpqqUpAqPM6HeL8f+o3a+JsyGjn2lv0WY8UsTgUJjU9Ok55NA==
14014 + dependencies:
14015 + kind-of "^6.0.2"
14016 +
14017 shallow-copy@0.0.1:
14018 version "0.0.1"
14019 resolved "https://registry.yarnpkg.com/shallow-copy/-/shallow-copy-0.0.1.tgz#415f42702d73d810330292cc5ee86eae1a11a170"
@@ -14193,7 +14250,7 @@ source-map-support@0.5.16:
14250 buffer-from "^1.0.0"
14251 source-map "^0.6.0"
14252
14196 -source-map-support@0.5.19, source-map-support@^0.5.17, source-map-support@~0.5.12:
14253 +source-map-support@0.5.19, source-map-support@^0.5.16, source-map-support@^0.5.17, source-map-support@~0.5.12:
14254 version "0.5.19"
14255 resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.19.tgz#a98b62f86dcaf4f67399648c085291ab9e8fed61"
14256 integrity sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw==
@@ -15690,6 +15747,13 @@ v8-to-istanbul@^7.0.0:
15747 convert-source-map "^1.6.0"
15748 source-map "^0.7.3"
15749
15750 +v8flags@^3.1.1:
15751 + version "3.2.0"
15752 + resolved "https://registry.yarnpkg.com/v8flags/-/v8flags-3.2.0.tgz#b243e3b4dfd731fa774e7492128109a0fe66d656"
15753 + integrity sha512-mH8etigqMfiGWdeXpaaqGfs6BndypxusHHcv2qSHyZkGEznCd/qAXCWWRzeowtL54147cktFOC4P5y+kl8d8Jg==
15754 + dependencies:
15755 + homedir-polyfill "^1.0.1"
15756 +
15757 validate-npm-package-license@^3.0.1:
15758 version "3.0.4"
15759 resolved "https://registry.yarnpkg.com/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz#fc91f6b9c7ba15c857f4cb2c5defeec39d4f410a"