-
Notifications
You must be signed in to change notification settings - Fork 47k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Brian Vaughn
committed
Aug 2, 2021
1 parent
dc5304a
commit 680f27f
Showing
103 changed files
with
4,521 additions
and
1,796 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-3.03 KB
(40%)
packages/react-devtools-extensions/icons/128-development.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-300 Bytes
(53%)
packages/react-devtools-extensions/icons/16-development.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-274 Bytes
(50%)
packages/react-devtools-extensions/icons/16-production.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-206 Bytes
(58%)
packages/react-devtools-extensions/icons/16-restricted.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-300 Bytes
(53%)
packages/react-devtools-extensions/icons/16-unminified.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-757 Bytes
(43%)
packages/react-devtools-extensions/icons/32-development.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-594 Bytes
(44%)
packages/react-devtools-extensions/icons/32-production.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-602 Bytes
(45%)
packages/react-devtools-extensions/icons/32-restricted.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-757 Bytes
(43%)
packages/react-devtools-extensions/icons/32-unminified.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-960 Bytes
(43%)
packages/react-devtools-extensions/icons/48-production.png
Oops, something went wrong.
Binary file modified
BIN
-834 Bytes
(47%)
packages/react-devtools-extensions/icons/48-restricted.png
Oops, something went wrong.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import fs from 'fs' | ||
import find from 'find' | ||
import filesize from 'filesize' | ||
import imagemin from 'imagemin' | ||
import imageminGifsicle from 'imagemin-gifsicle' | ||
import imageminJpegtran from 'imagemin-jpegtran' | ||
import imageminOptipng from 'imagemin-optipng' | ||
import imageminSvgo from 'imagemin-svgo' | ||
import parseFilepath from 'parse-filepath' | ||
import chalk from 'chalk' | ||
|
||
const plugins = [ | ||
imageminGifsicle({}), | ||
imageminJpegtran({}), | ||
imageminOptipng({}), | ||
imageminSvgo({}) | ||
] | ||
|
||
let savedSize = 0 | ||
|
||
const run = async () => { | ||
const regex = new RegExp(/\.gif|\.jpeg|\.jpg|\.png$/) | ||
|
||
const files = find.fileSync(regex, 'icons/'); | ||
|
||
for (const file of files) { | ||
await optimized(file) | ||
} | ||
|
||
if (savedSize > 0) { | ||
console.info(`\n🎉 You saved ${readableSize(savedSize)}.`) | ||
} else { | ||
console.info(`\n🎉 Nothing to optimize.`) | ||
} | ||
} | ||
|
||
const size = (filename) => { | ||
return fs.statSync(filename).size | ||
} | ||
|
||
const readableSize = (size) => { | ||
return filesize(size, { round: 5 }) | ||
} | ||
|
||
const optimized = async (filename) => { | ||
let output = parseFilepath(filename).dir || './' | ||
|
||
const fileSizeBefore = size(filename) | ||
|
||
if (fileSizeBefore === 0){ | ||
console.info(chalk.blue(`Skipping ${filename}, it has ${readableSize(fileSizeBefore)}`)) | ||
return | ||
} | ||
|
||
const pluginsOptions = { | ||
destination: output, | ||
plugins | ||
} | ||
|
||
const filenameBackup = `${filename}.bak` | ||
fs.copyFileSync(filename, filenameBackup) | ||
|
||
try { | ||
await imagemin([filename], pluginsOptions) | ||
|
||
const fileSizeAfter = size(filename) | ||
const fileSizeDiff = fileSizeBefore - fileSizeAfter | ||
if (fileSizeDiff > 0){ | ||
savedSize += fileSizeDiff | ||
console.info(chalk.green(`Optimized ${filename}: ${chalk.yellow(readableSize(fileSizeAfter))}`)) | ||
} else { // file after same or bigger | ||
// restore previous file | ||
fs.renameSync(filenameBackup, filename) | ||
|
||
console.info(`${filename} ${chalk.red(`already optimized`)}`) | ||
} | ||
|
||
} catch (err) { | ||
console.info(chalk.red(`Skip ${filename} due to error when optimizing`)); | ||
} | ||
|
||
// delete backup file | ||
if (fs.existsSync(filenameBackup)) { | ||
fs.unlinkSync(filenameBackup) | ||
} | ||
} | ||
|
||
(async () => { | ||
await run(); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
packages/react-devtools-extensions/src/__tests__/__source__/ComponentUsingHooksIndirectly.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @flow | ||
*/ | ||
|
||
import React, {useEffect, useState} from 'react'; | ||
|
||
export function Component() { | ||
const countState = useState(0); | ||
const count = countState[0]; | ||
const setCount = countState[1]; | ||
|
||
const darkMode = useIsDarkMode(); | ||
const [isDarkMode] = darkMode; | ||
|
||
useEffect(() => { | ||
// ... | ||
}, []); | ||
|
||
const handleClick = () => setCount(count + 1); | ||
|
||
return ( | ||
<> | ||
<div>Dark mode? {isDarkMode}</div> | ||
<div>Count: {count}</div> | ||
<button onClick={handleClick}>Update count</button> | ||
</> | ||
); | ||
} | ||
|
||
function useIsDarkMode() { | ||
const darkModeState = useState(false); | ||
const [isDarkMode] = darkModeState; | ||
|
||
useEffect(function useEffectCreate() { | ||
// Here is where we may listen to a "theme" event... | ||
}, []); | ||
|
||
return [isDarkMode, () => {}]; | ||
} |
59 changes: 46 additions & 13 deletions
59
packages/react-devtools-extensions/src/__tests__/__source__/__compiled__/bundle/index.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.