* Add XState and naive ActionBar
* Add basic dialog and combobox
* Selectable commands in command bar
* Add a few (broken) file actions
* Home commands
* Add subcommand descriptions, cleanup on navigate
* Refactor: move command creation and types to lib
* Refactor to allow any machine to add commands
* Add auth to command bar, add ability to hide cmds
* Refactor: consolidate theme utilities
* Add settings as machine and command set
* Fix: type tweaks
* Fix: only allow auth to navigate from signin
* Remove zustand-powered settings
* Fix: remove zustand settings from App
* Fix: browser infinite redirect
* Feature: allow commands to be hidden per-platform
* Fix: tsc errors
* Fix: hide default project directory from cmd bar
* Polish: transitions, css tweaks
* Feature: label current value in options settings
* Fix broken debug panel UI
* Refactor: move settings toasts to actions
* Tweak: css rounding
* Fix: set default directory recursion and reload 🐞
* Refactor: move machines to their own directory
* Fix formatting
* @Irev-Dev clean-up catches, import cleanup
65 lines
1.9 KiB
TypeScript
65 lines
1.9 KiB
TypeScript
import ReactJson from 'react-json-view'
|
|
import { CollapsiblePanel, CollapsiblePanelProps } from './CollapsiblePanel'
|
|
import { useStore } from '../useStore'
|
|
import { useMemo } from 'react'
|
|
import { ProgramMemory } from '../lang/executor'
|
|
import { Themes } from '../lib/theme'
|
|
|
|
interface MemoryPanelProps extends CollapsiblePanelProps {
|
|
theme?: Exclude<Themes, Themes.System>
|
|
}
|
|
|
|
export const MemoryPanel = ({
|
|
theme = Themes.Light,
|
|
...props
|
|
}: MemoryPanelProps) => {
|
|
const { programMemory } = useStore((s) => ({
|
|
programMemory: s.programMemory,
|
|
}))
|
|
const ProcessedMemory = useMemo(
|
|
() => processMemory(programMemory),
|
|
[programMemory]
|
|
)
|
|
return (
|
|
<CollapsiblePanel {...props}>
|
|
<div className="h-full relative">
|
|
<div className="absolute inset-0 flex flex-col items-start">
|
|
<div className=" h-full console-tile w-full">
|
|
<ReactJson
|
|
src={ProcessedMemory}
|
|
collapsed={1}
|
|
collapseStringsAfterLength={60}
|
|
enableClipboard={false}
|
|
displayDataTypes={false}
|
|
displayObjectSize={true}
|
|
indentWidth={2}
|
|
quotesOnKeys={false}
|
|
name={false}
|
|
theme={theme === 'light' ? 'rjv-default' : 'monokai'}
|
|
/>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</CollapsiblePanel>
|
|
)
|
|
}
|
|
|
|
export const processMemory = (programMemory: ProgramMemory) => {
|
|
const processedMemory: any = {}
|
|
Object.keys(programMemory.root).forEach((key) => {
|
|
const val = programMemory.root[key]
|
|
if (typeof val.value !== 'function') {
|
|
if (val.type === 'sketchGroup' || val.type === 'extrudeGroup') {
|
|
processedMemory[key] = val.value.map(({ __geoMeta, ...rest }) => {
|
|
return rest
|
|
})
|
|
} else {
|
|
processedMemory[key] = val.value
|
|
}
|
|
} else if (key !== 'log') {
|
|
processedMemory[key] = '__function__'
|
|
}
|
|
})
|
|
return processedMemory
|
|
}
|