Skip to content

Commit 33b19e9

Browse files
Merge pull request cerebral#284 from eirikhm/next
WIP: VS Code extension
2 parents deb2e98 + c4efec9 commit 33b19e9

File tree

17 files changed

+42662
-30
lines changed

17 files changed

+42662
-30
lines changed

package-lock.json

Lines changed: 188 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
"@babel/plugin-transform-runtime": "^7.2.0",
2929
"@babel/preset-env": "^7.2.0",
3030
"@types/node": "10.5.1",
31+
"@types/vscode": "^1.35.0",
32+
"@types/ws": "6.0.1",
3133
"axios": "0.18.0",
3234
"color": "3.0.0",
3335
"color-hash": "1.0.3",
@@ -52,11 +54,11 @@
5254
"react-icons": "^3.5.0",
5355
"styled-components": "3.3.3",
5456
"tslib": "1.9.3",
57+
"vscode": "^1.1.34",
5558
"vue": "2.5.16",
5659
"vue-hot-reload-api": "2.3.0",
5760
"vue-styled-components": "1.3.0",
58-
"ws": "7.0.0",
59-
"@types/ws": "6.0.1"
61+
"ws": "7.0.0"
6062
},
6163
"devDependencies": {
6264
"@babel/core": "7.2.2",

packages/node_modules/overmind-devtools-client/DevtoolBackend.js

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,38 @@
11
const WebSocket = require('ws')
22

3+
4+
35
class DevtoolBackend {
46
constructor(options) {
57
this.options = options
6-
78
this.onError = this.onError.bind(this)
9+
810
this.onClientConnection = this.onClientConnection.bind(this)
911
this.onDevtoolConnection = this.onDevtoolConnection.bind(this)
12+
this.onConnection = this.onConnection.bind(this)
1013
this.onClientMessage = this.onClientMessage.bind(this)
1114
this.onDevtoolMessage = this.onDevtoolMessage.bind(this)
12-
15+
1316
this.devtoolServer = new WebSocket.Server(
1417
{
1518
port: options.port,
1619
},
1720
() => {}
1821
)
1922

20-
this.devtoolServer.on('connection', this.onDevtoolConnection)
23+
this.devtoolServer.on('connection', this.onConnection)
24+
this.devtoolServer.on('error', this.onError)
25+
}
26+
27+
onConnection(ws, req) {
28+
// devtools connects with ?devtools=1 in url
29+
if (req.url.indexOf("devtools") !== -1) {
30+
this.onDevtoolConnection(ws, req)
31+
} else {
32+
this.onClientConnection(ws, req)
33+
}
2134
}
35+
2236
onDevtoolConnection(ws) {
2337
this.devtoolSocket = ws
2438
this.devtoolSocket.on('message', this.onDevtoolMessage)
@@ -46,14 +60,16 @@ class DevtoolBackend {
4660
this.options.onRelaunch()
4761
break
4862
case 'connect':
49-
this.createClientServer(parsedMessage.data)
63+
console.log('TODO: connect'); // TODO: Let devtools know that they are connected to server?
64+
// this.createClientServer(parsedMessage.data)
5065
break
5166
default:
5267
this.clientSocket.send(JSON.stringify(parsedMessage.data))
5368
}
5469
}
5570
onError() {
56-
this.devtoolServer.emit('port:exists')
71+
console.log('TODO: onError');
72+
// this.devtoolServer.emit('port:exists')
5773
}
5874
onClientConnection(ws) {
5975
this.clientSocket = ws
@@ -82,23 +98,6 @@ class DevtoolBackend {
8298
)
8399
}
84100
}
85-
createClientServer(port) {
86-
if (this.clientPort === Number(port)) {
87-
return
88-
}
89-
90-
if (this.clientServer) {
91-
this.clientServer.close()
92-
}
93-
94-
this.clientPort = Number(port)
95-
this.clientServer = new WebSocket.Server(
96-
{ port: this.clientPort },
97-
() => {}
98-
)
99-
this.clientServer.on('connection', this.onClientConnection)
100-
this.clientServer.on('error', this.onError)
101-
}
102101
}
103102

104103
DevtoolBackend.create = (options) => new DevtoolBackend(options)

packages/node_modules/overmind-devtools-client/src/BackendConnector.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class WebsocketConnector {
1212
private callbacks: {
1313
[event: string]: Function[]
1414
} = {}
15-
private socket = new WebSocket('ws://localhost:1040')
15+
private socket = new WebSocket('ws://localhost:3031?devtools=1') // TODO should be able to configure
1616
private messagesBeforeConnected: Array<[string, any, any]> = []
1717
private isOpen = false
1818
constructor() {
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
out
2+
node_modules
3+
.vscode-test/
4+
*.vsix

0 commit comments

Comments
 (0)