diff --git a/src/Playground.res b/src/Playground.res index 7520827b3..8b8bd8197 100644 --- a/src/Playground.res +++ b/src/Playground.res @@ -896,7 +896,7 @@ module Settings = { let open_modules = switch readyState.selected.apiVersion { | V1 | V2 | V3 | UnknownVersion(_) => None - | V4 => + | V4 | V5 => readyState.selected.libraries->Array.some(el => el === "@rescript/core") ? Some(["RescriptCore"]) : None diff --git a/src/bindings/RescriptCompilerApi.res b/src/bindings/RescriptCompilerApi.res index fca8838ff..027da6a3e 100644 --- a/src/bindings/RescriptCompilerApi.res +++ b/src/bindings/RescriptCompilerApi.res @@ -37,6 +37,7 @@ module Version = { | V2 | V3 | V4 + | V5 | UnknownVersion(string) // Helps finding the right API version @@ -59,6 +60,7 @@ module Version = { | list{"2"} => V2 | list{"3"} => V3 | list{"4"} => V4 + | list{"5"} => V5 | _ => UnknownVersion(apiVersion) } @@ -68,6 +70,7 @@ module Version = { | V2 => "2.0" | V3 => "3.0" | V4 => "4.0" + | V5 => "5.0" | UnknownVersion(version) => version } @@ -76,7 +79,7 @@ module Version = { let availableLanguages = t => switch t { | V1 => [Lang.Reason, Res] - | V2 | V3 | V4 => [Lang.Res] + | V2 | V3 | V4 | V5 => [Lang.Res] | UnknownVersion(_) => [Res] } } @@ -405,7 +408,14 @@ module Compiler = { ConversionResult.decode(~fromLang=Reason, ~toLang=Reason, json) } - @get @scope("ocaml") external ocamlVersion: t => string = "version" + @get external ocaml: t => option> = "ocaml" + + let ocamlVersion = (t: t): option => { + switch ocaml(t) { + | Some(ocaml) => ocaml->Dict.get("version") + | None => None + } + } @send @scope("ocaml") external ocamlCompile: (t, string) => JSON.t = "compile" diff --git a/src/bindings/RescriptCompilerApi.resi b/src/bindings/RescriptCompilerApi.resi index b722d91c8..4852d197b 100644 --- a/src/bindings/RescriptCompilerApi.resi +++ b/src/bindings/RescriptCompilerApi.resi @@ -25,6 +25,7 @@ module Version: { | V2 | V3 | V4 + | V5 | UnknownVersion(string) // Helps finding the right API version @@ -188,7 +189,7 @@ module Compiler: { /* * OCaml compiler actions (Note: no pretty print available for OCaml) */ - let ocamlVersion: t => string + let ocamlVersion: t => option let ocamlCompile: (t, string) => CompilationResult.t /* diff --git a/src/common/CompilerManagerHook.res b/src/common/CompilerManagerHook.res index 2e0f7f488..595e8e099 100644 --- a/src/common/CompilerManagerHook.res +++ b/src/common/CompilerManagerHook.res @@ -147,7 +147,7 @@ let getLibrariesForVersion = (~version: Semver.t): array => { let getOpenModules = (~apiVersion: Version.t, ~libraries: array): option> => switch apiVersion { | V1 | V2 | V3 | UnknownVersion(_) => None - | V4 => libraries->Array.some(el => el === "@rescript/core") ? Some(["RescriptCore"]) : None + | V4 | V5 => libraries->Array.some(el => el === "@rescript/core") ? Some(["RescriptCore"]) : None } /* @@ -207,7 +207,7 @@ type selected = { id: Semver.t, // The id used for loading the compiler bundle (ideally should be the same as compilerVersion) apiVersion: Version.t, // The playground API version in use compilerVersion: string, - ocamlVersion: string, + ocamlVersion: option, libraries: array, config: Config.t, instance: Compiler.t, @@ -510,6 +510,11 @@ let useCompilerManager = ( ) | Lang.Res => instance->Compiler.resCompile(code) } + | V5 => + switch lang { + | Lang.Res => instance->Compiler.resCompile(code) + | _ => CompilationResult.UnexpectedError(`Can't handle with lang: ${lang->Lang.toString}`) + } | UnknownVersion(version) => CompilationResult.UnexpectedError( `Can't handle result of compiler API version "${version}"`, diff --git a/src/common/CompilerManagerHook.resi b/src/common/CompilerManagerHook.resi index 757032a8b..ac29d6e4d 100644 --- a/src/common/CompilerManagerHook.resi +++ b/src/common/CompilerManagerHook.resi @@ -28,7 +28,7 @@ type selected = { id: Semver.t, // The id used for loading the compiler bundle (ideally should be the same as compilerVersion) apiVersion: Version.t, // The playground API version in use compilerVersion: string, - ocamlVersion: string, + ocamlVersion: option, libraries: array, config: Config.t, instance: Compiler.t,