Skip to content

Commit 8284dae

Browse files
feat(overmind-devtools): show webpack loader and automatic refresh in dev mode
1 parent 4ed9eec commit 8284dae

File tree

7 files changed

+67
-19
lines changed

7 files changed

+67
-19
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="UTF-8">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<meta http-equiv="X-UA-Compatible" content="ie=edge">
8+
<title>Document</title>
9+
<style>
10+
html,
11+
body {
12+
margin: 0;
13+
height: 100%;
14+
}
15+
16+
.loading {
17+
display: flex;
18+
align-items: center;
19+
justify-content: center;
20+
height: 100%;
21+
padding: 30px;
22+
text-align: center;
23+
}
24+
</style>
25+
</head>
26+
27+
<body>
28+
<div class="loading">
29+
<h1>Waiting for webpack to load up...</h1>
30+
</div>
31+
<script>
32+
async function checkDev() {
33+
try {
34+
const response = await fetch('http://localhost:3000')
35+
36+
if (response.status >= 200 && response.status < 300) {
37+
location.href = 'http://localhost:3000'
38+
} else {
39+
setTimeout(checkDev, 250)
40+
}
41+
} catch (_) {
42+
setTimeout(checkDev, 250)
43+
}
44+
}
45+
46+
setTimeout(checkDev, 1000)
47+
</script>
48+
</body>
49+
50+
</html>

packages/node_modules/overmind-devtools/backend/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ function createWindow() {
2222
if (process.env.NODE_ENV === 'production') {
2323
mainWindow.loadFile(path.join(__dirname, '..', 'dist', 'index.html'))
2424
} else {
25-
mainWindow.loadURL('http://localhost:3000')
2625
mainWindow.webContents.openDevTools()
26+
mainWindow.loadFile(path.join(__dirname, 'dev.html'))
2727
}
2828

2929
electron.Menu.setApplicationMenu(

packages/node_modules/overmind-devtools/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"color-hash": "^1.0.3",
2828
"electron": "^2.0.4",
2929
"electron-json-storage": "^4.1.0",
30-
"overmind": "next",
30+
"react-overmind": "next",
3131
"react": "^16.4.1",
3232
"react-dom": "^16.4.1",
3333
"styled-components": "^3.3.3",

packages/node_modules/overmind-devtools/src/app/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import App, { TConnect, TEffects, TAction } from 'overmind/react'
1+
import App, { TConnect, TEffects, TAction } from 'react-overmind'
22
import * as effects from './effects'
33
import actions from './actions'
44
import state from './state'

packages/node_modules/overmind-devtools/src/app/mutations.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ export function performMutationsByMessageType(state: State, message: Message) {
281281
isRunning: true,
282282
isCollapsed: true,
283283
mutations: [],
284-
providers: [],
284+
effects: [],
285285
}
286286
break
287287
}
@@ -312,13 +312,13 @@ export function performMutationsByMessageType(state: State, message: Message) {
312312
operator.mutations = mutations.mutations
313313
break
314314
}
315-
case 'provider': {
316-
const provider = clientMessage.data
317-
const id = getActionId(provider)
315+
case 'effect': {
316+
const effect = clientMessage.data
317+
const id = getActionId(effect)
318318
const operator =
319-
state.apps[message.port].actions[id].operators[provider.operatorId]
319+
state.apps[message.port].actions[id].operators[effect.operatorId]
320320

321-
operator.providers.push(provider)
321+
operator.effects.push(effect)
322322
break
323323
}
324324
}

packages/node_modules/overmind-devtools/src/app/state.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export type Mutation = {
77
path: string
88
}
99

10-
export type Provider = {
10+
export type Effect = {
1111
args: any[]
1212
method: string
1313
name: string
@@ -44,7 +44,7 @@ export type Operator = {
4444
isCollapsed: boolean
4545
operatorId: number
4646
mutations: Mutation[]
47-
providers: Provider[]
47+
effects: Effect[]
4848
path: string[]
4949
type: string
5050
result: any

packages/node_modules/overmind-devtools/src/components/ActionOperator/index.tsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const ActionOperator: React.SFC<Props> = ({ operator, value, app }) => (
3232
<Operator
3333
borderColor={operator.type === 'mutation' ? 'primary' : 'secondary'}
3434
onClick={
35-
operator.mutations.length || operator.providers.length
35+
operator.mutations.length || operator.effects.length
3636
? () => app.actions.toggleCollapsed(operator)
3737
: null
3838
}
@@ -48,7 +48,7 @@ const ActionOperator: React.SFC<Props> = ({ operator, value, app }) => (
4848
<Text variant="text" dense>
4949
{operator.name}
5050
</Text>
51-
{operator.mutations.length || operator.providers.length ? (
51+
{operator.mutations.length || operator.effects.length ? (
5252
<Text variant="hint">
5353
{operator.isCollapsed ? (
5454
<Icon>chevron-up</Icon>
@@ -60,21 +60,19 @@ const ActionOperator: React.SFC<Props> = ({ operator, value, app }) => (
6060
</OperatorHeader>
6161
{operator.isCollapsed ? null : (
6262
<div onClick={(event) => event.stopPropagation()}>
63-
{operator.providers.map((provider, index) => (
63+
{operator.effects.map((effect, index) => (
6464
<OperatorItem key={index}>
6565
<Text variant="description" color="secondary" mono>
66-
{provider.name + '.' + provider.method}
66+
{effect.name + '.' + effect.method}
6767
</Text>
6868
<ValueInspector
6969
small
70-
value={
71-
provider.args.length > 1 ? provider.args : provider.args[0]
72-
}
70+
value={effect.args.length > 1 ? effect.args : effect.args[0]}
7371
/>
7472
<Text variant="description" mono>
7573
=>
7674
</Text>
77-
<ValueInspector small value={provider.result} />
75+
<ValueInspector small value={effect.result} />
7876
</OperatorItem>
7977
))}
8078
{operator.mutations.map((mutation, index) => (

0 commit comments

Comments
 (0)