@@ -1038,20 +1038,6 @@ module Settings = {
10381038}
10391039
10401040module ControlPanel = {
1041- let codeFromResult = (result : FinalResult .t ): string => {
1042- open Api
1043- switch result {
1044- | FinalResult .Comp (comp ) =>
1045- switch comp {
1046- | CompilationResult .Success ({js_code }) => js_code
1047- | UnexpectedError (_ )
1048- | Unknown (_ , _ )
1049- | Fail (_ ) => "/* No JS code generated */"
1050- }
1051- | Nothing
1052- | Conv (_ ) => "/* No JS code generated */"
1053- }
1054- }
10551041 module Button = {
10561042 @react.component
10571043 let make = (~children , ~onClick = ?) =>
@@ -1144,7 +1130,7 @@ module ControlPanel = {
11441130
11451131 let autoRun = switch state {
11461132 | CompilerManagerHook .Executing ({state : {autoRun : true }})
1147- | Compiling ({autoRun : true })
1133+ | Compiling ({state : { autoRun : true } })
11481134 | Ready ({autoRun : true }) => true
11491135 | _ => false
11501136 }
@@ -1211,77 +1197,24 @@ module OutputPanel = {
12111197 ~editorCode : React .ref <string >,
12121198 ~currentTab : tab ,
12131199 ) => {
1214- /*
1215- We need the prevState to understand different
1216- state transitions, and to be able to keep displaying
1217- old results until those transitions are done.
1218-
1219- Goal was to reduce the UI flickering during different
1220- state transitions
1221- */
1222- let prevState = React .useRef (None )
1223-
1224- let cmCode = switch prevState .current {
1225- | Some (prev ) =>
1226- switch (prev , compilerState ) {
1227- | (_ , Ready ({result : Nothing })) => None
1228- | (Ready (prevReady ), Ready (ready )) =>
1229- switch (prevReady .result , ready .result ) {
1230- | (_ , Comp (Success (_ ))) => ControlPanel .codeFromResult (ready .result )-> Some
1231- | _ => None
1232- }
1233- | (_ , Ready ({result : Comp (Success (_ )) as result })) =>
1234- ControlPanel .codeFromResult (result )-> Some
1235- | (Ready ({result : Comp (Success (_ )) as result }), Compiling (_ )) =>
1236- ControlPanel .codeFromResult (result )-> Some
1237- | (_ , Executing ({jsCode })) => Some (jsCode )
1238- | _ => None
1239- }
1240- | None =>
1241- switch compilerState {
1242- | Ready (ready ) => ControlPanel .codeFromResult (ready .result )-> Some
1243- | _ => None
1244- }
1245- }
1246-
1247- prevState .current = Some (compilerState )
1248-
1249- let resultPane = switch compilerState {
1250- | Compiling (ready )
1251- | Ready (ready )
1252- | Executing ({state : ready }) =>
1253- switch ready .result {
1254- | Comp (Success (_ ))
1255- | Conv (Success (_ )) => React .null
1256- | _ =>
1257- <ResultPane
1258- targetLang = ready .targetLang
1259- compilerVersion = ready .selected .compilerVersion
1260- result = ready .result
1261- />
1262- }
1263-
1264- | _ => React .null
1265- }
1266-
1267- let (code , showCm ) = switch cmCode {
1268- | None => ("" , false )
1269- | Some (code ) => (code , true )
1270- }
1271-
1272- let codeElement =
1273- <pre className = {"whitespace-pre-wrap p-4 " ++ (showCm ? "block" : "hidden" )}>
1274- {HighlightJs .renderHLJS (~code , ~darkmode = true , ~lang = "js" , ())}
1275- </pre >
1276-
12771200 let output =
12781201 <div className = "text-gray-20" >
1279- resultPane
1280- codeElement
1202+ {switch compilerState {
1203+ | Compiling ({previousJsCode : Some (jsCode )})
1204+ | Executing ({jsCode })
1205+ | Ready ({result : Comp (Success ({jsCode }))}) =>
1206+ <pre className = {"whitespace-pre-wrap p-4 " }>
1207+ {HighlightJs .renderHLJS (~code = jsCode , ~darkmode = true , ~lang = "js" , ())}
1208+ </pre >
1209+ | Ready ({result : Conv (Success (_ ))}) => React .null
1210+ | Ready ({result , targetLang , selected }) =>
1211+ <ResultPane targetLang compilerVersion = selected .compilerVersion result />
1212+ | _ => React .null
1213+ }}
12811214 </div >
12821215
12831216 let errorPane = switch compilerState {
1284- | Compiling (ready )
1217+ | Compiling ({ state : ready } )
12851218 | Ready (ready )
12861219 | Executing ({state : ready })
12871220 | SwitchingCompiler (ready , _ ) =>
@@ -1296,7 +1229,7 @@ module OutputPanel = {
12961229
12971230 let settingsPane = switch compilerState {
12981231 | Ready (ready )
1299- | Compiling (ready )
1232+ | Compiling ({ state : ready } )
13001233 | Executing ({state : ready })
13011234 | SwitchingCompiler (ready , _ ) =>
13021235 let config = ready .selected .config
@@ -1671,8 +1604,8 @@ let make = (~versions: array<string>) => {
16711604 }
16721605
16731606 let cmHoverHints = switch compilerState {
1674- | Ready ({result : FinalResult .Comp (Success ({type_hints }))}) =>
1675- Array .map (type_hints , hint => {
1607+ | Ready ({result : FinalResult .Comp (Success ({typeHints }))}) =>
1608+ Array .map (typeHints , hint => {
16761609 switch hint {
16771610 | TypeDeclaration ({start , end , hint })
16781611 | Binding ({start , end , hint })
0 commit comments