* selection stuff
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest)
* trigger CI
* fix bugs
* some edge cut stuff
* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest-8-cores)
* trigger CI
* A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-latest-8-cores)
* fix sketch mode issues
* fix more tests, selection in sketch related
* more test fixing
* A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-latest-8-cores)
* Trigger ci
* A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-latest-8-cores)
* Trigger ci
* more sketch mode selection fixes
* fix unit tests
* rename function
* remove .only
* migrate a more selections types
* migrate a more selections types
* migrate a more selections types
* lint
* migrate a more selections types
* migrate a more selections types
* migrate a more selections types
* migrate a more selections types
* migrate a more selections types
* migrate a more selections types
* migrate a more selections types
* migrate a more selections types
* migrate a more selections types
* migrate a more selections types
* fix bad pathToNode issue
* A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-latest-8-cores)
* fix sketch on face
* migrate a more selections types
* migrate a more selections types
* fix code selection of fillets
* migrate a more selections types
* migrate a more selections types
* migrate a more selections types
* migrate a more selections types
* migrate a more selections types
* fix bad path to node, looks like a race
* migrate a more selections types
* migrate a more selections types
* fix cmd bar selections
* fix cmd bar selections
* fix display issues
* migrate a more selections types
* Revert "migrate a more selections types"
This reverts commit 0d0e453bbb
.
* migrate a more selections types
* clean up1
* clean up 2
* fix types after main merge
* review tweaks
* fix wall selection bug
* Update src/lang/std/engineConnection.ts
Co-authored-by: Jonathan Tran <jonnytran@gmail.com>
* add franks TODO comment
* fix type after main merge, plus a touch of clean up
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Jonathan Tran <jonnytran@gmail.com>
95 lines
3.0 KiB
TypeScript
95 lines
3.0 KiB
TypeScript
import { CommandLog } from 'lang/std/engineConnection'
|
|
import { engineCommandManager } from 'lib/singletons'
|
|
import { reportRejection } from 'lib/trap'
|
|
import { useState, useEffect } from 'react'
|
|
|
|
export function useEngineCommands(): [CommandLog[], () => void] {
|
|
const [engineCommands, setEngineCommands] = useState<CommandLog[]>(
|
|
engineCommandManager.commandLogs
|
|
)
|
|
|
|
useEffect(() => {
|
|
engineCommandManager.registerCommandLogCallback((commands) =>
|
|
setEngineCommands(commands)
|
|
)
|
|
}, [])
|
|
|
|
return [engineCommands, () => engineCommandManager.clearCommandLogs()]
|
|
}
|
|
|
|
export const EngineCommands = () => {
|
|
const [engineCommands, clearEngineCommands] = useEngineCommands()
|
|
const [containsFilter, setContainsFilter] = useState('')
|
|
const [customCmd, setCustomCmd] = useState('')
|
|
return (
|
|
<div>
|
|
<input
|
|
className="text-gray-800 bg-slate-300 px-2"
|
|
data-testid="filter-input"
|
|
type="text"
|
|
value={containsFilter}
|
|
onChange={(e) => setContainsFilter(e.target.value)}
|
|
placeholder="Filter"
|
|
/>
|
|
<div className="max-w-xl max-h-36 overflow-auto">
|
|
{engineCommands.map((command, index) => {
|
|
const stringer = JSON.stringify(command)
|
|
if (containsFilter && !stringer.includes(containsFilter)) return null
|
|
return (
|
|
<pre className="text-xs" key={index}>
|
|
<code
|
|
key={index}
|
|
data-message-type={command.type}
|
|
data-command-type={
|
|
(command.type === 'send-modeling' ||
|
|
command.type === 'send-scene') &&
|
|
command.data.type === 'modeling_cmd_req'
|
|
? command?.data?.cmd?.type
|
|
: ''
|
|
}
|
|
data-command-id={
|
|
(command.type === 'send-modeling' ||
|
|
command.type === 'send-scene') &&
|
|
command.data.type === 'modeling_cmd_req'
|
|
? command.data.cmd_id
|
|
: ''
|
|
}
|
|
data-receive-command-type={
|
|
command.type === 'receive-reliable' ? command.cmd_type : ''
|
|
}
|
|
>
|
|
{JSON.stringify(command, null, 2)}
|
|
</code>
|
|
</pre>
|
|
)
|
|
})}
|
|
</div>
|
|
<button
|
|
data-testid="clear-commands"
|
|
onClick={() => clearEngineCommands()}
|
|
>
|
|
Clear
|
|
</button>
|
|
<br />
|
|
<input
|
|
className="text-gray-800 bg-slate-300 px-2"
|
|
type="text"
|
|
value={customCmd}
|
|
onChange={(e) => setCustomCmd(e.target.value)}
|
|
placeholder="JSON command"
|
|
data-testid="custom-cmd-input"
|
|
/>
|
|
<button
|
|
data-testid="custom-cmd-send-button"
|
|
onClick={() => {
|
|
engineCommandManager
|
|
.sendSceneCommand(JSON.parse(customCmd))
|
|
.catch(reportRejection)
|
|
}}
|
|
>
|
|
Send custom command
|
|
</button>
|
|
</div>
|
|
)
|
|
}
|