Skip to content

Commit da55d13

Browse files
authored
Merge pull request #30 from deeppatel234/auto-mode
Auto mode
2 parents b99cbce + c2ad9ef commit da55d13

33 files changed

Lines changed: 738 additions & 266 deletions

example/csr/src/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ import App from "./App";
44

55
ReactDOM.render(<App />, document.getElementById("root"));
66

7-
window.__REACT_CONTEXT_DEVTOOL_GLOBAL_HOOK.helpers.loadHookHelper().then(() => {
8-
window.__REACT_CONTEXT_DEVTOOL_GLOBAL_HOOK.debugFiber(document.getElementById('root'))
9-
});
7+
// window.__REACT_CONTEXT_DEVTOOL_GLOBAL_HOOK.helpers.loadHookHelper().then(() => {
8+
// window.__REACT_CONTEXT_DEVTOOL_GLOBAL_HOOK.debugFiber(document.getElementById('root'))
9+
// });

example/ssr/.gitignore

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# next.js
12+
/.next/
13+
/out/
14+
15+
# production
16+
/build
17+
18+
# misc
19+
.DS_Store
20+
*.pem
21+
22+
# debug
23+
npm-debug.log*
24+
yarn-debug.log*
25+
yarn-error.log*
26+
27+
# local env files
28+
.env.local
29+
.env.development.local
30+
.env.test.local
31+
.env.production.local
32+
33+
# vercel
34+
.vercel

example/ssr/package.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "ssr",
3+
"version": "0.1.0",
4+
"private": true,
5+
"scripts": {
6+
"dev": "next dev",
7+
"build": "next build",
8+
"start": "next start"
9+
},
10+
"dependencies": {
11+
"next": "10.1.3",
12+
"react": "17.0.2",
13+
"react-dom": "17.0.2"
14+
}
15+
}

example/ssr/pages/_app.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
function MyApp({ Component, pageProps }) {
2+
return <Component {...pageProps} />
3+
}
4+
5+
export default MyApp

example/ssr/pages/index.js

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
import React, { useReducer } from "react";
2+
3+
const MyContext1 = React.createContext({});
4+
const MyContext2 = React.createContext({});
5+
6+
MyContext1.displayName = "MyContext1";
7+
MyContext2.displayName = "MyContext2";
8+
9+
10+
const ws = new WeakSet();
11+
const foo = {};
12+
13+
ws.add(foo);
14+
15+
let myMap = new Map()
16+
myMap.set("s", 'not a number')
17+
18+
const valuesToTest = {
19+
f: new Set([1,2, 3,3]),
20+
g: ws,
21+
h: myMap,
22+
i: ws,
23+
}
24+
25+
class Test2 extends React.Component {
26+
constructor(props) {
27+
super(props);
28+
29+
this.state = {
30+
counter5: 0,
31+
};
32+
}
33+
34+
render() {
35+
const { counter5 } = this.state;
36+
const { id } = this.props;
37+
// const { id } = this.context;
38+
39+
return (
40+
<MyContext2.Provider value={{ id: counter5, b: "world", ...valuesToTest }}>
41+
<button onClick={() => this.setState({ counter5: counter5 + 1 })}>
42+
Click 5 Me {counter5} {id}
43+
</button>
44+
</MyContext2.Provider>
45+
);
46+
}
47+
}
48+
49+
Test2.contextType = MyContext1;
50+
51+
function myReducer(state, action) {
52+
// counter++;
53+
// console.log(counter);
54+
switch (action.type) {
55+
case 'increment':
56+
return {count: state.count + 1};
57+
case 'decrement':
58+
return {count: state.count - 1};
59+
default:
60+
// throw new Error();
61+
}
62+
63+
return state;
64+
}
65+
66+
const initialState = {count: 0};
67+
68+
function Counter() {
69+
const [state, dispatch] = useReducer(myReducer, initialState);
70+
// const dd = useContext(MyContext1);
71+
// const [state2, dispatch3] = useReducer(reducer, initialState);
72+
// const [abcd, setabcd] = useState(2);
73+
74+
75+
return (
76+
<>
77+
{/* Count: {dd.id} */}
78+
Count: {state.count}
79+
<button onClick={() => dispatch({type: 'decrement'})}>-</button>
80+
<button onClick={() => dispatch({type: 'increment'})}>+</button>
81+
</>
82+
);
83+
}
84+
85+
86+
export default function Home() {
87+
return (
88+
<div>
89+
<Test2 />
90+
<Counter />
91+
</div>
92+
)
93+
}

packages/devtool-extenstion/browser/chrome/manifest.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
"persistent": false
2424
},
2525
"devtools_page": "devtool/devtool.html",
26+
"options_ui": {
27+
"page": "options/options.html",
28+
"open_in_tab": false
29+
},
2630
"permissions": ["storage", "file:///*", "http://*/*", "https://*/*"],
2731
"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'; style-src * 'unsafe-inline'; img-src 'self' data:;",
2832
"content_scripts": [

packages/devtool-extenstion/browser/firefox/manifest.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222
"scripts": ["background.js"]
2323
},
2424
"devtools_page": "devtool/devtool.html",
25+
"options_ui": {
26+
"page": "options/options.html",
27+
"browser_style": true
28+
},
2529
"permissions": ["storage", "file:///*", "http://*/*", "https://*/*"],
2630
"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'; style-src * 'unsafe-inline'; img-src 'self' data:;",
2731
"content_scripts": [

packages/devtool-extenstion/build/build.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ const {
1515

1616
const webpackConfig = require('./webpack.config');
1717

18-
const EXTENSTION_FILES = ["assets", "devtool", "popup"];
18+
const EXTENSTION_FILES = ["assets", "devtool", "popup", "options"];
1919
const EXTENSION_CORE_FILES = ["background.js"];
20-
const BUILD_ID_REPLACE = ["popup/popup.html", "devtool/devpanel.html"];
20+
const BUILD_ID_REPLACE = ["popup/popup.html", "devtool/devpanel.html", "options/options.html"];
2121

2222
const env = process.env.NODE_ENV || 'development';
2323

packages/devtool-extenstion/build/webpack.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ module.exports = ({ mode, distPath } = {}) => {
2121
"react-context-devtool-helper": `${PATHS.EXTENSION_DIR}/core/helper.js`,
2222
"devtool/devpanel": `${PATHS.SRC_DIR}/devpanel.index.js`,
2323
"popup/popup": `${PATHS.SRC_DIR}/popup.index.js`,
24+
"options/options": `${PATHS.SRC_DIR}/options.index.js`,
2425
},
2526
output: {
2627
path: distPath,
2.94 KB
Loading

0 commit comments

Comments
 (0)