-
-
Notifications
You must be signed in to change notification settings - Fork 260
Expand file tree
/
Copy pathCompilerManagerHook.resi
More file actions
74 lines (65 loc) · 1.89 KB
/
CompilerManagerHook.resi
File metadata and controls
74 lines (65 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
open RescriptCompilerApi
module FinalResult: {
/* A final result is the last operation the compiler has done, right now this includes... */
type t =
| Conv(ConversionResult.t)
| Comp(CompilationResult.t)
| Nothing
}
type queryParams =
| @as("ext") Ext
| @as("version") Version
| @as("module") Module
| @as("jsxPreserve") JsxPreserve
| @as("experiments") Experiments
| @as("code") Code
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: option<string>,
libraries: array<string>,
config: Config.t,
instance: Compiler.t,
}
type ready = {
code: string,
versions: array<Semver.t>,
selected: selected,
targetLang: Lang.t,
errors: array<string>, // For major errors like bundle loading
result: FinalResult.t,
autoRun: bool,
validReactCode: bool,
logs: array<ConsolePanel.log>,
}
module CdnMeta: {
let getStdlibRuntimeUrl: (string, Semver.t, string) => string
}
type state =
| Init
| SetupFailed(string)
| SwitchingCompiler(ready, Semver.t) // (ready, targetId, libraries)
| Ready(ready)
| Compiling({state: ready, previousJsCode: option<string>})
| Executing({state: ready, jsCode: string})
type action =
| SwitchToCompiler(Semver.t) // id
| SwitchLanguage({lang: Lang.t, code: string})
| Format(string)
| CompileCode(Lang.t, string)
| UpdateConfig(Config.t)
| AppendLog(ConsolePanel.log)
| ToggleAutoRun
| RunCode
let useCompilerManager: (
~bundleBaseUrl: string,
~initialVersion: Semver.t=?,
~initialModuleSystem: string=?,
~initialJsxPreserveMode: bool=?,
~initialExperimentalFeatures: array<string>=?,
~initialLang: Lang.t=?,
~onAction: action => unit=?,
~versions: array<Semver.t>,
) => (state, action => unit)
let createUrl: (string, ready) => string