mirror of
https://github.com/streamwall/streamwall.git
synced 2026-01-24 22:22:50 -05:00
Add button to open devtools for stream views
This commit is contained in:
@@ -216,16 +216,25 @@ export default class StreamWindow extends EventEmitter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
reloadView(viewIdx) {
|
findViewByIdx(viewIdx, predicate) {
|
||||||
const view = this.views.find(
|
return this.views.find(
|
||||||
(v) =>
|
(v) =>
|
||||||
v.state.context.pos && v.state.context.pos.spaces.includes(viewIdx),
|
v.state.context.pos && v.state.context.pos.spaces.includes(viewIdx),
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
reloadView(viewIdx) {
|
||||||
|
const view = this.findViewByIdx(viewIdx)
|
||||||
if (view) {
|
if (view) {
|
||||||
view.send('RELOAD')
|
view.send('RELOAD')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
openDevTools(viewIdx, inWebContents) {
|
||||||
|
const view = this.findViewByIdx(viewIdx)
|
||||||
|
view.send({ type: 'DEVTOOLS', inWebContents })
|
||||||
|
}
|
||||||
|
|
||||||
send(...args) {
|
send(...args) {
|
||||||
this.overlayView.webContents.send(...args)
|
this.overlayView.webContents.send(...args)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -90,8 +90,16 @@ async function main() {
|
|||||||
broadcastState(clientState)
|
broadcastState(clientState)
|
||||||
} else if (msg.type === 'reload-view') {
|
} else if (msg.type === 'reload-view') {
|
||||||
streamWindow.reloadView(msg.viewIdx)
|
streamWindow.reloadView(msg.viewIdx)
|
||||||
} else if (msg.type === 'browse') {
|
} else if (msg.type === 'browse' || msg.type === 'dev-tools') {
|
||||||
ensureValidURL(msg.url)
|
if (
|
||||||
|
msg.type === 'dev-tools' &&
|
||||||
|
browseWindow &&
|
||||||
|
!browseWindow.isDestroyed()
|
||||||
|
) {
|
||||||
|
// DevTools needs a fresh webContents to work. Close any existing window.
|
||||||
|
browseWindow.destroy()
|
||||||
|
browseWindow = null
|
||||||
|
}
|
||||||
if (!browseWindow || browseWindow.isDestroyed()) {
|
if (!browseWindow || browseWindow.isDestroyed()) {
|
||||||
browseWindow = new BrowserWindow({
|
browseWindow = new BrowserWindow({
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
@@ -102,7 +110,12 @@ async function main() {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
if (msg.type === 'browse') {
|
||||||
|
ensureValidURL(msg.url)
|
||||||
browseWindow.loadURL(msg.url)
|
browseWindow.loadURL(msg.url)
|
||||||
|
} else if (msg.type === 'dev-tools') {
|
||||||
|
streamWindow.openDevTools(msg.viewIdx, browseWindow.webContents)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -81,6 +81,9 @@ const viewStateMachine = Machine(
|
|||||||
},
|
},
|
||||||
MUTE: '.muted',
|
MUTE: '.muted',
|
||||||
UNMUTE: '.listening',
|
UNMUTE: '.listening',
|
||||||
|
DEVTOOLS: {
|
||||||
|
actions: 'openDevTools',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
states: {
|
states: {
|
||||||
muted: {
|
muted: {
|
||||||
@@ -109,6 +112,12 @@ const viewStateMachine = Machine(
|
|||||||
unmuteAudio: (context, event) => {
|
unmuteAudio: (context, event) => {
|
||||||
context.view.webContents.audioMuted = false
|
context.view.webContents.audioMuted = false
|
||||||
},
|
},
|
||||||
|
openDevTools: (context, event) => {
|
||||||
|
const { view } = context
|
||||||
|
const { inWebContents } = event
|
||||||
|
view.webContents.setDevToolsWebContents(inWebContents)
|
||||||
|
view.webContents.openDevTools({ mode: 'detach' })
|
||||||
|
},
|
||||||
},
|
},
|
||||||
guards: {
|
guards: {
|
||||||
contentUnchanged: (context, event) => {
|
contentUnchanged: (context, event) => {
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import { GRID_COUNT } from '../constants'
|
|||||||
import SoundIcon from '../static/volume-up-solid.svg'
|
import SoundIcon from '../static/volume-up-solid.svg'
|
||||||
import ReloadIcon from '../static/redo-alt-solid.svg'
|
import ReloadIcon from '../static/redo-alt-solid.svg'
|
||||||
import LifeRingIcon from '../static/life-ring-regular.svg'
|
import LifeRingIcon from '../static/life-ring-regular.svg'
|
||||||
|
import WindowIcon from '../static/window-maximize-regular.svg'
|
||||||
|
|
||||||
function App({ wsEndpoint }) {
|
function App({ wsEndpoint }) {
|
||||||
const wsRef = useRef()
|
const wsRef = useRef()
|
||||||
@@ -119,6 +120,15 @@ function App({ wsEndpoint }) {
|
|||||||
)
|
)
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
|
const handleDevTools = useCallback((idx) => {
|
||||||
|
wsRef.current.send(
|
||||||
|
JSON.stringify({
|
||||||
|
type: 'dev-tools',
|
||||||
|
viewIdx: idx,
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
}, [])
|
||||||
|
|
||||||
const handleClickId = useCallback((streamId) => {
|
const handleClickId = useCallback((streamId) => {
|
||||||
const availableIdx = range(GRID_COUNT * GRID_COUNT).find(
|
const availableIdx = range(GRID_COUNT * GRID_COUNT).find(
|
||||||
(i) => !stateIdxMap.has(i),
|
(i) => !stateIdxMap.has(i),
|
||||||
@@ -171,6 +181,7 @@ function App({ wsEndpoint }) {
|
|||||||
onSetListening={handleSetListening}
|
onSetListening={handleSetListening}
|
||||||
onReloadView={handleReloadView}
|
onReloadView={handleReloadView}
|
||||||
onBrowse={handleBrowse}
|
onBrowse={handleBrowse}
|
||||||
|
onDevTools={handleDevTools}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
})}
|
})}
|
||||||
@@ -247,6 +258,7 @@ function GridInput({
|
|||||||
onSetListening,
|
onSetListening,
|
||||||
onReloadView,
|
onReloadView,
|
||||||
onBrowse,
|
onBrowse,
|
||||||
|
onDevTools,
|
||||||
}) {
|
}) {
|
||||||
const [editingValue, setEditingValue] = useState()
|
const [editingValue, setEditingValue] = useState()
|
||||||
const handleFocus = useCallback((ev) => {
|
const handleFocus = useCallback((ev) => {
|
||||||
@@ -272,6 +284,10 @@ function GridInput({
|
|||||||
onReloadView,
|
onReloadView,
|
||||||
])
|
])
|
||||||
const handleBrowseClick = useCallback(() => onBrowse(url), [url, onBrowse])
|
const handleBrowseClick = useCallback(() => onBrowse(url), [url, onBrowse])
|
||||||
|
const handleDevToolsClick = useCallback(() => onDevTools(idx), [
|
||||||
|
idx,
|
||||||
|
onDevTools,
|
||||||
|
])
|
||||||
const handleClick = useCallback((ev) => {
|
const handleClick = useCallback((ev) => {
|
||||||
ev.target.select()
|
ev.target.select()
|
||||||
})
|
})
|
||||||
@@ -283,6 +299,9 @@ function GridInput({
|
|||||||
<ReloadIcon />
|
<ReloadIcon />
|
||||||
</StyledButton>
|
</StyledButton>
|
||||||
<StyledButton onClick={handleBrowseClick}>
|
<StyledButton onClick={handleBrowseClick}>
|
||||||
|
<WindowIcon />
|
||||||
|
</StyledButton>
|
||||||
|
<StyledButton onClick={handleDevToolsClick}>
|
||||||
<LifeRingIcon />
|
<LifeRingIcon />
|
||||||
</StyledButton>
|
</StyledButton>
|
||||||
</StyledGridButtons>
|
</StyledGridButtons>
|
||||||
|
|||||||
Reference in New Issue
Block a user