@@ -1038,20 +1038,6 @@ module Settings = {
1038
1038
}
1039
1039
1040
1040
module 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
- }
1055
1041
module Button = {
1056
1042
@react.component
1057
1043
let make = (~children , ~onClick = ?) =>
@@ -1144,7 +1130,7 @@ module ControlPanel = {
1144
1130
1145
1131
let autoRun = switch state {
1146
1132
| CompilerManagerHook .Executing ({state : {autoRun : true }})
1147
- | Compiling ({autoRun : true })
1133
+ | Compiling ({state : { autoRun : true } })
1148
1134
| Ready ({autoRun : true }) => true
1149
1135
| _ => false
1150
1136
}
@@ -1211,77 +1197,24 @@ module OutputPanel = {
1211
1197
~editorCode : React .ref <string >,
1212
1198
~currentTab : tab ,
1213
1199
) => {
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
-
1277
1200
let output =
1278
1201
<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
+ }}
1281
1214
</div >
1282
1215
1283
1216
let errorPane = switch compilerState {
1284
- | Compiling (ready )
1217
+ | Compiling ({ state : ready } )
1285
1218
| Ready (ready )
1286
1219
| Executing ({state : ready })
1287
1220
| SwitchingCompiler (ready , _ ) =>
@@ -1296,7 +1229,7 @@ module OutputPanel = {
1296
1229
1297
1230
let settingsPane = switch compilerState {
1298
1231
| Ready (ready )
1299
- | Compiling (ready )
1232
+ | Compiling ({ state : ready } )
1300
1233
| Executing ({state : ready })
1301
1234
| SwitchingCompiler (ready , _ ) =>
1302
1235
let config = ready .selected .config
@@ -1671,8 +1604,8 @@ let make = (~versions: array<string>) => {
1671
1604
}
1672
1605
1673
1606
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 => {
1676
1609
switch hint {
1677
1610
| TypeDeclaration ({start , end , hint })
1678
1611
| Binding ({start , end , hint })
0 commit comments