@@ -47,6 +47,7 @@ import StyleFrame from './StyleFrame'
4747import SysInfoFrame from './SysInfoFrame/SysInfoFrame'
4848import { Connection } from 'shared/modules/connections/connectionsDuck'
4949import { FrameStack } from 'shared/modules/frames/framesDuck'
50+ import extras from './Extras/index'
5051
5152const nameToFrame : Record < string , React . ComponentType < any > > = {
5253 error : ErrorFrame ,
@@ -78,14 +79,19 @@ const nameToFrame: Record<string, React.ComponentType<any>> = {
7879
7980const getFrameComponent = ( frameData : FrameStack ) : React . ComponentType < any > => {
8081 const { cmd, type } = frameData . stack [ 0 ]
81- let MyFrame = nameToFrame [ type ]
82+ let MyFrame = nameToFrame [ type ] ?? ErrorFrame
8283
83- if ( ! MyFrame || type === 'error' ) {
84- try {
85- const command = cmd . replace ( / ^ : / , '' )
86- const Frame = command [ 0 ] . toUpperCase ( ) + command . slice ( 1 ) + 'Frame'
87- MyFrame = require ( './Extras/index' ) [ Frame ] || nameToFrame [ 'error' ]
88- } catch ( e ) { }
84+ if ( type === 'error' ) {
85+ const command = cmd . replace ( / ^ : / , '' )
86+ const frameName = command [ 0 ] . toUpperCase ( ) + command . slice ( 1 ) + 'Frame'
87+ const isExtraFrame = (
88+ frameName : string
89+ ) : frameName is keyof typeof extras =>
90+ Object . keys ( extras ) . includes ( frameName )
91+
92+ if ( isExtraFrame ( frameName ) ) {
93+ MyFrame = extras [ frameName ]
94+ }
8995 }
9096 return MyFrame
9197}
0 commit comments