-
-
Notifications
You must be signed in to change notification settings - Fork 116
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
1 parent
916b44f
commit d93ce42
Showing
9 changed files
with
76 additions
and
55 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { devtools } from '@vue/devtools-kit' | ||
|
||
devtools.init() |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { isBrowser, target } from '@vue/devtools-shared' | ||
import { Bridge } from '../../core/src/bridge' | ||
import { prepareInjection } from '../../core/src/injection' | ||
import { devtools } from '../../devtools-kit/src/index' | ||
|
||
export function init(io) { | ||
const createSocket = io | ||
const host = target.__VUE_DEVTOOLS_HOST__ || 'http://localhost' | ||
const port = target.__VUE_DEVTOOLS_PORT__ !== undefined ? target.__VUE_DEVTOOLS_PORT__ : 8098 | ||
const fullHost = port ? `${host}:${port}` : host | ||
const socket = createSocket(fullHost) | ||
|
||
// @TODO: de-duplicate | ||
devtools.init() | ||
|
||
const bridge = new Bridge({ | ||
tracker(fn) { | ||
socket.on('vue-devtools:message', (data) => { | ||
fn(data) | ||
}) | ||
}, | ||
trigger(data) { | ||
socket.emit('vue-devtools:message', data) | ||
}, | ||
}) | ||
|
||
socket.on('connect', () => { | ||
prepareInjection(bridge) | ||
socket.emit('vue-devtools:init') | ||
}) | ||
|
||
// Global disconnect handler. Fires in two cases: | ||
// - after calling above socket.disconnect() | ||
// - once devtools is closed (that's why we need socket.disconnect() here too, to prevent further polling) | ||
socket.on('disconnect', () => { | ||
socket.disconnect() | ||
}) | ||
|
||
// Disconnect socket once other client is connected | ||
socket.on('vue-devtools:disconnect-user-app', () => { | ||
socket.disconnect() | ||
}) | ||
|
||
if (isBrowser) { | ||
window.addEventListener('beforeunload', () => { | ||
socket.emit('vue-devtools:disconnect') | ||
}) | ||
} | ||
} |
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,4 @@ | ||
import io from 'socket.io-client/dist/socket.io.js' | ||
import { init } from './user-app.core' | ||
|
||
init(io) |
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 |
---|---|---|
@@ -1,49 +1,4 @@ | ||
// import io from 'socket.io-client/dist/socket.io.js' | ||
import io from 'socket.io-client' | ||
import { isBrowser, target } from '@vue/devtools-shared' | ||
import { Bridge } from '../../core/src/bridge' | ||
import { prepareInjection } from '../../core/src/injection' | ||
import { devtools } from '../../devtools-kit/src/index' | ||
import { init } from './user-app.core' | ||
|
||
const createSocket = io | ||
const host = target.__VUE_DEVTOOLS_HOST__ || 'http://localhost' | ||
const port = target.__VUE_DEVTOOLS_PORT__ !== undefined ? target.__VUE_DEVTOOLS_PORT__ : 8098 | ||
const fullHost = port ? `${host}:${port}` : host | ||
const socket = createSocket(fullHost) | ||
|
||
// @TODO: de-duplicate | ||
devtools.init() | ||
|
||
const bridge = new Bridge({ | ||
tracker(fn) { | ||
socket.on('vue-devtools:message', (data) => { | ||
fn(data) | ||
}) | ||
}, | ||
trigger(data) { | ||
socket.emit('vue-devtools:message', data) | ||
}, | ||
}) | ||
|
||
socket.on('connect', () => { | ||
prepareInjection(bridge) | ||
socket.emit('vue-devtools:init') | ||
}) | ||
|
||
// Global disconnect handler. Fires in two cases: | ||
// - after calling above socket.disconnect() | ||
// - once devtools is closed (that's why we need socket.disconnect() here too, to prevent further polling) | ||
socket.on('disconnect', () => { | ||
socket.disconnect() | ||
}) | ||
|
||
// Disconnect socket once other client is connected | ||
socket.on('vue-devtools:disconnect-user-app', () => { | ||
socket.disconnect() | ||
}) | ||
|
||
if (isBrowser) { | ||
window.addEventListener('beforeunload', () => { | ||
socket.emit('vue-devtools:disconnect') | ||
}) | ||
} | ||
init(io) |
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