firefly-compiler 0.5.79 → 0.5.80
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/compiler/Builder.ff +31 -39
- package/compiler/Compiler.ff +14 -4
- package/compiler/DevelopMode.ff +406 -0
- package/compiler/Main.ff +73 -53
- package/compiler/ModuleCache.ff +5 -5
- package/core/.firefly/include/package.json +1 -1
- package/core/BuildSystem.ff +82 -11
- package/core/NodeSystem.ff +47 -30
- package/core/Path.ff +7 -2
- package/experimental/proxy/Main.ff +60 -0
- package/experimental/proxy/Runner.ff +11 -0
- package/experimental/proxy/Tcp.ff +162 -0
- package/experimental/random/Superdigit.ff +18 -0
- package/experimental/terrain/Main.ff +40 -0
- package/experimental/terrain/Terrain.ff +97 -0
- package/experimental/terrain/Terrain2.ff +109 -0
- package/fireflysite/Main.ff +0 -1
- package/fireflysite/assets/markdown/reference/statements-and-expressions.md +1 -1
- package/lsp/CompletionHandler.ff +2 -2
- package/output/js/ff/compiler/Builder.mjs +24 -48
- package/output/js/ff/compiler/Builder.mjs.map +7 -11
- package/output/js/ff/compiler/Compiler.mjs +66 -12
- package/output/js/ff/compiler/Compiler.mjs.map +18 -14
- package/output/js/ff/compiler/Dependencies.mjs.map +2 -2
- package/output/js/ff/compiler/DependencyLock.mjs.map +1 -1
- package/output/js/ff/compiler/Deriver.mjs.map +1 -1
- package/output/js/ff/compiler/DevelopMode.mjs +1049 -0
- package/output/js/ff/compiler/DevelopMode.mjs.map +183 -0
- package/output/js/ff/compiler/Dictionaries.mjs.map +1 -1
- package/output/js/ff/compiler/Environment.mjs.map +1 -1
- package/output/js/ff/compiler/Inference.mjs.map +1 -1
- package/output/js/ff/compiler/JsEmitter.mjs.map +1 -1
- package/output/js/ff/compiler/JsImporter.mjs.map +1 -1
- package/output/js/ff/compiler/LspHook.mjs.map +1 -1
- package/output/js/ff/compiler/Main.mjs +256 -105
- package/output/js/ff/compiler/Main.mjs.map +43 -38
- package/output/js/ff/compiler/ModuleCache.mjs +12 -8
- package/output/js/ff/compiler/ModuleCache.mjs.map +4 -3
- package/output/js/ff/compiler/Parser.mjs.map +1 -1
- package/output/js/ff/compiler/Patterns.mjs.map +1 -1
- package/output/js/ff/compiler/Resolver.mjs.map +1 -1
- package/output/js/ff/compiler/SourceMap.mjs.map +1 -1
- package/output/js/ff/compiler/Substitution.mjs.map +1 -1
- package/output/js/ff/compiler/Syntax.mjs.map +1 -1
- package/output/js/ff/compiler/Token.mjs.map +1 -1
- package/output/js/ff/compiler/Tokenizer.mjs.map +1 -1
- package/output/js/ff/compiler/Unification.mjs.map +1 -1
- package/output/js/ff/compiler/Wildcards.mjs.map +1 -1
- package/output/js/ff/compiler/Workspace.mjs.map +1 -1
- package/output/js/ff/core/Any.mjs.map +1 -1
- package/output/js/ff/core/Array.mjs.map +1 -1
- package/output/js/ff/core/AssetSystem.mjs.map +1 -1
- package/output/js/ff/core/Atomic.mjs.map +1 -1
- package/output/js/ff/core/Bool.mjs.map +1 -1
- package/output/js/ff/core/BrowserSystem.mjs.map +1 -1
- package/output/js/ff/core/Buffer.mjs.map +1 -1
- package/output/js/ff/core/BuildSystem.mjs +116 -12
- package/output/js/ff/core/BuildSystem.mjs.map +35 -6
- package/output/js/ff/core/Channel.mjs.map +1 -1
- package/output/js/ff/core/Char.mjs.map +1 -1
- package/output/js/ff/core/Core.mjs.map +1 -1
- package/output/js/ff/core/Crypto.mjs.map +1 -1
- package/output/js/ff/core/Date.mjs.map +1 -1
- package/output/js/ff/core/Duration.mjs.map +1 -1
- package/output/js/ff/core/Equal.mjs.map +1 -1
- package/output/js/ff/core/Error.mjs.map +1 -1
- package/output/js/ff/core/FileHandle.mjs.map +1 -1
- package/output/js/ff/core/Float.mjs.map +1 -1
- package/output/js/ff/core/HttpClient.mjs.map +1 -1
- package/output/js/ff/core/Int.mjs.map +1 -1
- package/output/js/ff/core/IntMap.mjs.map +1 -1
- package/output/js/ff/core/Js.mjs.map +1 -1
- package/output/js/ff/core/JsSystem.mjs.map +1 -1
- package/output/js/ff/core/JsValue.mjs.map +1 -1
- package/output/js/ff/core/Json.mjs.map +1 -1
- package/output/js/ff/core/List.mjs.map +1 -1
- package/output/js/ff/core/Lock.mjs.map +1 -1
- package/output/js/ff/core/Log.mjs.map +1 -1
- package/output/js/ff/core/Map.mjs.map +1 -1
- package/output/js/ff/core/NodeSystem.mjs +54 -20
- package/output/js/ff/core/NodeSystem.mjs.map +14 -6
- package/output/js/ff/core/Nothing.mjs.map +1 -1
- package/output/js/ff/core/Option.mjs.map +1 -1
- package/output/js/ff/core/Ordering.mjs.map +1 -1
- package/output/js/ff/core/Pair.mjs.map +1 -1
- package/output/js/ff/core/Path.mjs +30 -4
- package/output/js/ff/core/Path.mjs.map +8 -6
- package/output/js/ff/core/Queue.mjs.map +1 -1
- package/output/js/ff/core/Random.mjs.map +1 -1
- package/output/js/ff/core/RbMap.mjs.map +1 -1
- package/output/js/ff/core/Serializable.mjs.map +1 -1
- package/output/js/ff/core/Set.mjs.map +1 -1
- package/output/js/ff/core/Show.mjs.map +1 -1
- package/output/js/ff/core/SourceLocation.mjs.map +1 -1
- package/output/js/ff/core/Stream.mjs.map +1 -1
- package/output/js/ff/core/String.mjs.map +1 -1
- package/output/js/ff/core/StringMap.mjs.map +1 -1
- package/output/js/ff/core/Task.mjs.map +1 -1
- package/output/js/ff/core/Try.mjs.map +1 -1
- package/output/js/ff/core/Unit.mjs.map +1 -1
- package/output/js/ff/core/node_modules +1 -0
- package/package.json +1 -1
- package/vscode/package.json +1 -1
- package/webserver/.firefly/include/package.json +1 -1
- package/webserver/WebServer.ff +6 -3
|
@@ -0,0 +1,1049 @@
|
|
|
1
|
+
import * as ff_compiler_DevelopMode from "../../ff/compiler/DevelopMode.mjs"
|
|
2
|
+
|
|
3
|
+
import * as ff_compiler_Builder from "../../ff/compiler/Builder.mjs"
|
|
4
|
+
|
|
5
|
+
import * as ff_compiler_Dependencies from "../../ff/compiler/Dependencies.mjs"
|
|
6
|
+
|
|
7
|
+
import * as ff_compiler_DependencyLock from "../../ff/compiler/DependencyLock.mjs"
|
|
8
|
+
|
|
9
|
+
import * as ff_compiler_JsEmitter from "../../ff/compiler/JsEmitter.mjs"
|
|
10
|
+
|
|
11
|
+
import * as ff_compiler_Main from "../../ff/compiler/Main.mjs"
|
|
12
|
+
|
|
13
|
+
import * as ff_compiler_ModuleCache from "../../ff/compiler/ModuleCache.mjs"
|
|
14
|
+
|
|
15
|
+
import * as ff_compiler_Syntax from "../../ff/compiler/Syntax.mjs"
|
|
16
|
+
|
|
17
|
+
import * as ff_core_Any from "../../ff/core/Any.mjs"
|
|
18
|
+
|
|
19
|
+
import * as ff_core_Array from "../../ff/core/Array.mjs"
|
|
20
|
+
|
|
21
|
+
import * as ff_core_AssetSystem from "../../ff/core/AssetSystem.mjs"
|
|
22
|
+
|
|
23
|
+
import * as ff_core_Atomic from "../../ff/core/Atomic.mjs"
|
|
24
|
+
|
|
25
|
+
import * as ff_core_Bool from "../../ff/core/Bool.mjs"
|
|
26
|
+
|
|
27
|
+
import * as ff_core_BrowserSystem from "../../ff/core/BrowserSystem.mjs"
|
|
28
|
+
|
|
29
|
+
import * as ff_core_Buffer from "../../ff/core/Buffer.mjs"
|
|
30
|
+
|
|
31
|
+
import * as ff_core_BuildSystem from "../../ff/core/BuildSystem.mjs"
|
|
32
|
+
|
|
33
|
+
import * as ff_core_Channel from "../../ff/core/Channel.mjs"
|
|
34
|
+
|
|
35
|
+
import * as ff_core_Char from "../../ff/core/Char.mjs"
|
|
36
|
+
|
|
37
|
+
import * as ff_core_Core from "../../ff/core/Core.mjs"
|
|
38
|
+
|
|
39
|
+
import * as ff_core_Crypto from "../../ff/core/Crypto.mjs"
|
|
40
|
+
|
|
41
|
+
import * as ff_core_Date from "../../ff/core/Date.mjs"
|
|
42
|
+
|
|
43
|
+
import * as ff_core_Duration from "../../ff/core/Duration.mjs"
|
|
44
|
+
|
|
45
|
+
import * as ff_core_Equal from "../../ff/core/Equal.mjs"
|
|
46
|
+
|
|
47
|
+
import * as ff_core_Error from "../../ff/core/Error.mjs"
|
|
48
|
+
|
|
49
|
+
import * as ff_core_FileHandle from "../../ff/core/FileHandle.mjs"
|
|
50
|
+
|
|
51
|
+
import * as ff_core_Float from "../../ff/core/Float.mjs"
|
|
52
|
+
|
|
53
|
+
import * as ff_core_HttpClient from "../../ff/core/HttpClient.mjs"
|
|
54
|
+
|
|
55
|
+
import * as ff_core_Int from "../../ff/core/Int.mjs"
|
|
56
|
+
|
|
57
|
+
import * as ff_core_IntMap from "../../ff/core/IntMap.mjs"
|
|
58
|
+
|
|
59
|
+
import * as ff_core_Js from "../../ff/core/Js.mjs"
|
|
60
|
+
|
|
61
|
+
import * as ff_core_JsSystem from "../../ff/core/JsSystem.mjs"
|
|
62
|
+
|
|
63
|
+
import * as ff_core_JsValue from "../../ff/core/JsValue.mjs"
|
|
64
|
+
|
|
65
|
+
import * as ff_core_Json from "../../ff/core/Json.mjs"
|
|
66
|
+
|
|
67
|
+
import * as ff_core_List from "../../ff/core/List.mjs"
|
|
68
|
+
|
|
69
|
+
import * as ff_core_Lock from "../../ff/core/Lock.mjs"
|
|
70
|
+
|
|
71
|
+
import * as ff_core_Log from "../../ff/core/Log.mjs"
|
|
72
|
+
|
|
73
|
+
import * as ff_core_Map from "../../ff/core/Map.mjs"
|
|
74
|
+
|
|
75
|
+
import * as ff_core_NodeSystem from "../../ff/core/NodeSystem.mjs"
|
|
76
|
+
|
|
77
|
+
import * as ff_core_Nothing from "../../ff/core/Nothing.mjs"
|
|
78
|
+
|
|
79
|
+
import * as ff_core_Option from "../../ff/core/Option.mjs"
|
|
80
|
+
|
|
81
|
+
import * as ff_core_Ordering from "../../ff/core/Ordering.mjs"
|
|
82
|
+
|
|
83
|
+
import * as ff_core_Pair from "../../ff/core/Pair.mjs"
|
|
84
|
+
|
|
85
|
+
import * as ff_core_Path from "../../ff/core/Path.mjs"
|
|
86
|
+
|
|
87
|
+
import * as ff_core_Queue from "../../ff/core/Queue.mjs"
|
|
88
|
+
|
|
89
|
+
import * as ff_core_Random from "../../ff/core/Random.mjs"
|
|
90
|
+
|
|
91
|
+
import * as ff_core_Serializable from "../../ff/core/Serializable.mjs"
|
|
92
|
+
|
|
93
|
+
import * as ff_core_Set from "../../ff/core/Set.mjs"
|
|
94
|
+
|
|
95
|
+
import * as ff_core_Show from "../../ff/core/Show.mjs"
|
|
96
|
+
|
|
97
|
+
import * as ff_core_SourceLocation from "../../ff/core/SourceLocation.mjs"
|
|
98
|
+
|
|
99
|
+
import * as ff_core_Stream from "../../ff/core/Stream.mjs"
|
|
100
|
+
|
|
101
|
+
import * as ff_core_String from "../../ff/core/String.mjs"
|
|
102
|
+
|
|
103
|
+
import * as ff_core_StringMap from "../../ff/core/StringMap.mjs"
|
|
104
|
+
|
|
105
|
+
import * as ff_core_Task from "../../ff/core/Task.mjs"
|
|
106
|
+
|
|
107
|
+
import * as ff_core_Try from "../../ff/core/Try.mjs"
|
|
108
|
+
|
|
109
|
+
import * as import$0 from 'node:fs';
|
|
110
|
+
import * as import$1 from 'node:net';
|
|
111
|
+
import * as ff_core_Unit from "../../ff/core/Unit.mjs"
|
|
112
|
+
|
|
113
|
+
// type Runner
|
|
114
|
+
export function Runner(lock_, lockCondition_, iteration_, state_, changedSinceCompilationStarted_, recompile_, appRunning_) {
|
|
115
|
+
return {lock_, lockCondition_, iteration_, state_, changedSinceCompilationStarted_, recompile_, appRunning_};
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// type RunnerState
|
|
119
|
+
const CompilingState$ = {CompilingState: true};
|
|
120
|
+
export function CompilingState() {
|
|
121
|
+
return CompilingState$;
|
|
122
|
+
}
|
|
123
|
+
export function CompileErrorState(at_, output_) {
|
|
124
|
+
return {CompileErrorState: true, at_, output_};
|
|
125
|
+
}
|
|
126
|
+
const ApplicationRunningState$ = {ApplicationRunningState: true};
|
|
127
|
+
export function ApplicationRunningState() {
|
|
128
|
+
return ApplicationRunningState$;
|
|
129
|
+
}
|
|
130
|
+
export function ApplicationCrashedState(output_) {
|
|
131
|
+
return {ApplicationCrashedState: true, output_};
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// type EsbuildContext
|
|
135
|
+
export function EsbuildContext(jsValue_) {
|
|
136
|
+
return {jsValue_};
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export const waiterHtml_ = "<!DOCTYPE html>\r\n<html lang=\"en\">\r\n<head>\r\n <meta charset=\"UTF-8\">\r\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\r\n <title>Firefly develop mode</title>\r\n <style>\r\n body {\r\n background-color: #121212;\r\n color: #e0e0e0;\r\n font-family: 'Courier New', monospace;\r\n display: flex;\r\n flex-direction: column;\r\n justify-content: center;\r\n align-items: center;\r\n height: 100vh;\r\n margin: 0;\r\n background-image: radial-gradient(circle at center, #1a1a2e, #121212);\r\n }\r\n\r\n h1 {\r\n color: #00f2ff;\r\n text-shadow: 0 0 10px #00f2ff;\r\n font-size: 3rem;\r\n margin-bottom: 20px;\r\n animation: glow 2s ease-in-out infinite alternate;\r\n }\r\n\r\n p {\r\n background-color: #1a1a2e;\r\n color: #00f2ff;\r\n padding: 15px 30px;\r\n border-radius: 25px;\r\n font-size: 1.2rem;\r\n border: 2px solid #00f2ff;\r\n box-shadow: 0 0 15px #00f2ff;\r\n animation: pulse 1.5s infinite;\r\n }\r\n \r\n a {\r\n color: #00f2ff;\r\n }\r\n\r\n @media only screen and (max-width: 600px) {\r\n h1 {\r\n font-size: 1.7rem;\r\n }\r\n p {\r\n padding: 10px 20px;\r\n border-radius: 50px;\r\n font-size: 1.1rem;\r\n max-width: 100%;\r\n box-sizing: border-box;\r\n }\r\n }\r\n \r\n @keyframes glow {\r\n from {\r\n text-shadow: 0 0 10px #00f2ff;\r\n }\r\n to {\r\n text-shadow: 0 0 20px #00f2ff, 0 0 30px #00f2ff;\r\n }\r\n }\r\n\r\n @keyframes pulse {\r\n 0% {\r\n box-shadow: 0 0 0 0 rgba(0, 242, 255, 0.7);\r\n }\r\n 70% {\r\n box-shadow: 0 0 0 10px rgba(0, 242, 255, 0);\r\n }\r\n 100% {\r\n box-shadow: 0 0 0 0 rgba(0, 242, 255, 0);\r\n }\r\n }\r\n </style>\r\n <script>\r\n let start = Date.now()\r\n let appStarted = null\r\n let delay = 10\r\n let poll = async () => {\r\n //delay *= 1.1\r\n try {\r\n let response = await fetch(\".\", {cache: 'no-store'})\r\n if(!response.headers.has('x-firefly-develop-mode')) {\r\n let now = Date.now()\r\n let compiling = appStarted - start\r\n let appStarting = now - appStarted\r\n //window.alert(\"Reloading after: \" + (now - start) + \" ms. Compiling: \" + compiling + \" ms. Starting application: \" + appStarting + \" ms.\")\r\n window.location.reload(true)\r\n return\r\n } else {\r\n let html = await response.text()\r\n if(appStarted == null && html.includes(\"Starting application...\")) appStarted = Date.now()\r\n let parser = new DOMParser()\r\n let d = parser.parseFromString(html, 'text/html')\r\n let bodyHtml = d.body.innerHTML\r\n if(document.body.innerHTML !== bodyHtml) {\r\n document.body.innerHTML = bodyHtml\r\n }\r\n setTimeout(poll, delay)\r\n }\r\n } catch (error) {\r\n console.error(\"Polling error:\", error)\r\n setTimeout(poll, delay)\r\n }\r\n }\r\n setTimeout(poll, delay)\r\n </script>\r\n</head>\r\n<body>\r\n <h1>Firefly develop mode</h1>\r\n <p>[STATUS]</p>\r\n</body>\r\n</html>\r\n";
|
|
140
|
+
|
|
141
|
+
export function run_(system_, fireflyPath_, mainFile_, arguments_) {
|
|
142
|
+
const esbuildContext_ = ff_compiler_DevelopMode.EsbuildContext(ff_core_Option.None());
|
|
143
|
+
const lock_ = ff_core_Task.Task_lock(ff_core_NodeSystem.NodeSystem_mainTask(system_));
|
|
144
|
+
const lockCondition_ = ff_core_Lock.Lock_condition(lock_);
|
|
145
|
+
const runner_ = ff_compiler_DevelopMode.Runner(lock_, lockCondition_, 1, ff_compiler_DevelopMode.CompilingState(), ff_core_Set.new_(), false, false);
|
|
146
|
+
ff_compiler_DevelopMode.startProxy_(system_, runner_, 8081, 8080);
|
|
147
|
+
ff_compiler_DevelopMode.startChangeListener_(system_, runner_, ff_core_NodeSystem.NodeSystem_path(system_, "."));
|
|
148
|
+
const moduleCache_ = ff_compiler_ModuleCache.new_(0);
|
|
149
|
+
while(true) {
|
|
150
|
+
const moduleKey_ = ff_compiler_DevelopMode.build_(system_, runner_, mainFile_, moduleCache_);
|
|
151
|
+
const task_ = (((_1) => {
|
|
152
|
+
if(_1.None) {
|
|
153
|
+
return ff_core_Task.Task_spawn(ff_core_NodeSystem.NodeSystem_mainTask(system_), ((_) => {
|
|
154
|
+
|
|
155
|
+
}))
|
|
156
|
+
return
|
|
157
|
+
}
|
|
158
|
+
{
|
|
159
|
+
const key_ = _1.value_;
|
|
160
|
+
ff_core_Lock.Lock_do(runner_.lock_, (() => {
|
|
161
|
+
runner_.state_ = ff_compiler_DevelopMode.ApplicationRunningState()
|
|
162
|
+
}));
|
|
163
|
+
return ff_compiler_DevelopMode.startApp_(system_, runner_, fireflyPath_, esbuildContext_, moduleCache_, key_, mainFile_, arguments_)
|
|
164
|
+
}
|
|
165
|
+
}))(moduleKey_);
|
|
166
|
+
ff_core_Lock.Lock_do(runner_.lock_, (() => {
|
|
167
|
+
if(runner_.appRunning_) {
|
|
168
|
+
while(runner_.appRunning_) {
|
|
169
|
+
ff_core_Lock.LockCondition_sleep(runner_.lockCondition_)
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
while((!runner_.recompile_)) {
|
|
173
|
+
ff_core_Lock.LockCondition_sleep(runner_.lockCondition_)
|
|
174
|
+
};
|
|
175
|
+
ff_core_Task.Task_abort(task_);
|
|
176
|
+
ff_core_Set.Set_each(runner_.changedSinceCompilationStarted_, ((key_) => {
|
|
177
|
+
ff_compiler_ModuleCache.ModuleCache_invalidate(moduleCache_, key_)
|
|
178
|
+
}), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
|
|
179
|
+
runner_.state_ = ff_compiler_DevelopMode.CompilingState();
|
|
180
|
+
runner_.recompile_ = false;
|
|
181
|
+
runner_.changedSinceCompilationStarted_ = ff_core_Set.new_();
|
|
182
|
+
runner_.iteration_ += 1
|
|
183
|
+
}))
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
export function build_(system_, runner_, mainFile_, moduleCache_) {
|
|
188
|
+
return ff_core_Try.Try_catchAny(ff_core_Try.Try_tryCatch(ff_core_Try.Try_tryCatch(ff_core_Core.try_((() => {
|
|
189
|
+
ff_compiler_Main.prepareFireflyDirectory_(ff_core_NodeSystem.NodeSystem_path(system_, "."));
|
|
190
|
+
const resolvedDependencies_ = ff_compiler_Dependencies.process_(ff_core_NodeSystem.NodeSystem_httpClient(system_), ff_compiler_DependencyLock.new_(ff_core_NodeSystem.NodeSystem_mainTask(system_)), ff_core_NodeSystem.NodeSystem_path(system_, mainFile_));
|
|
191
|
+
const mainPath_ = ff_core_NodeSystem.NodeSystem_path(system_, mainFile_);
|
|
192
|
+
return ff_core_Option.Some(ff_compiler_Main.buildScript_(system_, mainPath_, resolvedDependencies_.mainPackagePair_, ff_compiler_JsEmitter.EmitNode(), resolvedDependencies_, moduleCache_, false))
|
|
193
|
+
})), ((_1, _2) => {
|
|
194
|
+
{
|
|
195
|
+
const at_ = _1.at_;
|
|
196
|
+
const message_ = _1.message_;
|
|
197
|
+
const error_ = _2;
|
|
198
|
+
ff_core_Log.debug_(message_);
|
|
199
|
+
ff_core_Log.debug_((((((" at " + ff_core_String.String_replace(at_.file_, "./", "")) + ":") + at_.line_) + ":") + at_.column_));
|
|
200
|
+
ff_core_Lock.Lock_do(runner_.lock_, (() => {
|
|
201
|
+
runner_.state_ = ff_compiler_DevelopMode.CompileErrorState(ff_core_Option.Some(at_), message_)
|
|
202
|
+
}));
|
|
203
|
+
return ff_core_Option.None()
|
|
204
|
+
}
|
|
205
|
+
}), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError), ((_1, _2) => {
|
|
206
|
+
{
|
|
207
|
+
const compileErrors_ = _1.errors_;
|
|
208
|
+
const error_ = _2;
|
|
209
|
+
ff_core_List.List_each(compileErrors_, ((_1) => {
|
|
210
|
+
{
|
|
211
|
+
const at_ = _1.at_;
|
|
212
|
+
const message_ = _1.message_;
|
|
213
|
+
ff_core_Log.debug_(message_);
|
|
214
|
+
ff_core_Log.debug_((((((" at " + ff_core_String.String_replace(at_.file_, "./", "")) + ":") + at_.line_) + ":") + at_.column_));
|
|
215
|
+
ff_core_Lock.Lock_do(runner_.lock_, (() => {
|
|
216
|
+
runner_.state_ = ff_compiler_DevelopMode.CompileErrorState(ff_core_Option.Some(at_), message_)
|
|
217
|
+
}))
|
|
218
|
+
return
|
|
219
|
+
}
|
|
220
|
+
}));
|
|
221
|
+
return ff_core_Option.None()
|
|
222
|
+
}
|
|
223
|
+
}), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileErrors), ((error_) => {
|
|
224
|
+
ff_core_Log.debug_(ff_core_Error.Error_message(error_));
|
|
225
|
+
ff_core_Lock.Lock_do(runner_.lock_, (() => {
|
|
226
|
+
runner_.state_ = ff_compiler_DevelopMode.CompileErrorState(ff_core_Option.None(), ff_core_Error.Error_message(error_))
|
|
227
|
+
}));
|
|
228
|
+
return ff_core_Option.None()
|
|
229
|
+
}))
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
export function startApp_(system_, runner_, fireflyPath_, esbuildContext_, moduleCache_, moduleKey_, mainFile_, arguments_) {
|
|
233
|
+
const taskIteration_ = runner_.iteration_;
|
|
234
|
+
return ff_core_Task.Task_spawn(ff_core_NodeSystem.NodeSystem_mainTask(system_), ((task_) => {
|
|
235
|
+
try {
|
|
236
|
+
const runFile_ = ff_compiler_Main.locateRunFile_(system_, "node", moduleKey_);
|
|
237
|
+
const runFilePath_ = (ff_core_String.String_contains(runFile_, "://")
|
|
238
|
+
? ff_core_NodeSystem.NodeSystem_pathFromUrl(system_, runFile_)
|
|
239
|
+
: ff_core_NodeSystem.NodeSystem_path(system_, runFile_));
|
|
240
|
+
const startPath_ = ff_core_Path.Path_slash(ff_core_Option.Option_grab(ff_core_Path.Path_parent(runFilePath_)), (ff_core_Path.Path_base(runFilePath_) + ".start.mjs"));
|
|
241
|
+
ff_core_Path.Path_writeText(startPath_, (((((((("import * as run from " + ff_core_Json.Json_write(("./" + ff_core_Path.Path_base(runFilePath_)), ff_core_Option.None())) + "\n") + "globalThis.ffDevelopMode = true\n") + "run.$run$(") + ff_core_Json.Json_write(ff_core_Path.Path_absolute(fireflyPath_), ff_core_Option.None())) + ", ") + ff_core_Json.Json_write(ff_core_Json.ff_core_Json_JsonLike$ff_core_List_List(ff_core_Json.ff_core_Json_JsonLike$ff_core_String_String).toJson_(arguments_), ff_core_Option.None())) + ")"));
|
|
242
|
+
const esBuildPath_ = ff_core_Path.Path_slash(ff_core_Option.Option_grab(ff_core_Path.Path_parent(runFilePath_)), (ff_core_Path.Path_base(runFilePath_) + ".minified.js"));
|
|
243
|
+
const context_ = ff_core_Option.Option_else(esbuildContext_.jsValue_, (() => {
|
|
244
|
+
const jsValue_ = ff_core_BuildSystem.internalNodeCallEsBuildContext_(system_, ff_core_Path.Path_absolute(startPath_), ff_core_Path.Path_absolute(esBuildPath_), true);
|
|
245
|
+
esbuildContext_.jsValue_ = ff_core_Option.Some(jsValue_);
|
|
246
|
+
return jsValue_
|
|
247
|
+
}));
|
|
248
|
+
context_.rebuild();
|
|
249
|
+
const relativeStartFile_ = ff_core_Path.Path_relativeTo(esBuildPath_, ff_core_NodeSystem.NodeSystem_path(system_, "."));
|
|
250
|
+
const result_ = ff_core_NodeSystem.NodeSystem_execute(system_, relativeStartFile_, arguments_, ff_core_Buffer.new_(0, false), ff_core_Option.None(), ff_core_Option.None(), 16777216, 9, false, ff_core_Option.Some(((message_, forkedProcess_) => {
|
|
251
|
+
if((message_.ffDevelopMode === "internalCompile")) {
|
|
252
|
+
const mainFiles_ = message_.mainFiles;
|
|
253
|
+
const mainPaths_ = ff_core_List.List_map(mainFiles_, ((_w1) => {
|
|
254
|
+
return ff_core_NodeSystem.NodeSystem_path(system_, _w1)
|
|
255
|
+
}));
|
|
256
|
+
const target_ = message_.target;
|
|
257
|
+
ff_core_Lock.Lock_do(runner_.lock_, (() => {
|
|
258
|
+
if((taskIteration_ === runner_.iteration_)) {
|
|
259
|
+
return ff_core_Option.Some(ff_core_Try.Try_catchAny(ff_core_Try.Try_tryCatch(ff_core_Try.Try_tryCatch(ff_core_Core.try_((() => {
|
|
260
|
+
ff_compiler_Builder.buildViaBuildSystem_(system_, fireflyPath_, mainPaths_, target_, moduleCache_, false);
|
|
261
|
+
forkedProcess_.send({ffDevelopMode: "internalCompile"})
|
|
262
|
+
})), ((_1, _2) => {
|
|
263
|
+
{
|
|
264
|
+
const at_ = _1.at_;
|
|
265
|
+
const message_ = _1.message_;
|
|
266
|
+
const error_ = _2;
|
|
267
|
+
runner_.state_ = ff_compiler_DevelopMode.CompileErrorState(ff_core_Option.Some(at_), message_)
|
|
268
|
+
return
|
|
269
|
+
}
|
|
270
|
+
}), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError), ((_1, _2) => {
|
|
271
|
+
{
|
|
272
|
+
const compileErrors_ = _1.errors_;
|
|
273
|
+
const error_ = _2;
|
|
274
|
+
ff_core_List.List_each(compileErrors_, ((_1) => {
|
|
275
|
+
{
|
|
276
|
+
const at_ = _1.at_;
|
|
277
|
+
const message_ = _1.message_;
|
|
278
|
+
runner_.state_ = ff_compiler_DevelopMode.CompileErrorState(ff_core_Option.Some(at_), message_)
|
|
279
|
+
return
|
|
280
|
+
}
|
|
281
|
+
}))
|
|
282
|
+
return
|
|
283
|
+
}
|
|
284
|
+
}), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileErrors), ((error_) => {
|
|
285
|
+
runner_.state_ = ff_compiler_DevelopMode.CompileErrorState(ff_core_Option.None(), ff_core_Error.Error_message(error_))
|
|
286
|
+
})))
|
|
287
|
+
} else return ff_core_Option.None()
|
|
288
|
+
}))
|
|
289
|
+
}
|
|
290
|
+
})));
|
|
291
|
+
const standardOut_ = ff_core_Buffer.Buffer_toString(result_.standardOut_, "utf8");
|
|
292
|
+
const standardError_ = ff_core_Buffer.Buffer_toString(result_.standardError_, "utf8");
|
|
293
|
+
ff_core_Lock.Lock_do(runner_.lock_, (() => {
|
|
294
|
+
runner_.appRunning_ = false;
|
|
295
|
+
ff_core_Log.debug_(((((("Exited with code: " + result_.exitCode_) + "\n\n") + standardOut_) + "\n\n") + standardError_));
|
|
296
|
+
do {
|
|
297
|
+
const _1 = runner_.state_;
|
|
298
|
+
if(_1.ApplicationRunningState && (taskIteration_ === runner_.iteration_)) {
|
|
299
|
+
runner_.state_ = ff_compiler_DevelopMode.ApplicationCrashedState(((((("Exited with code: " + result_.exitCode_) + "\n\n") + standardOut_) + "\n\n") + standardError_))
|
|
300
|
+
break
|
|
301
|
+
}
|
|
302
|
+
{
|
|
303
|
+
|
|
304
|
+
}
|
|
305
|
+
} while(false);
|
|
306
|
+
return ff_core_Lock.LockCondition_wakeAll(runner_.lockCondition_)
|
|
307
|
+
}))
|
|
308
|
+
} catch(error_) {
|
|
309
|
+
ff_core_Lock.Lock_do(runner_.lock_, (() => {
|
|
310
|
+
runner_.appRunning_ = false;
|
|
311
|
+
return ff_core_Lock.LockCondition_wakeAll(runner_.lockCondition_)
|
|
312
|
+
}))
|
|
313
|
+
}
|
|
314
|
+
}))
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
export function startChangeListener_(system_, runner_, path_) {
|
|
318
|
+
const fs_ = import$0;
|
|
319
|
+
fs_.watch(ff_core_Path.Path_absolute(path_), {recursive: true}, ((eventType_, fileName_) => {
|
|
320
|
+
if((!ff_core_JsValue.JsValue_isNullOrUndefined(fileName_))) {
|
|
321
|
+
return ff_core_Option.Some((function() {
|
|
322
|
+
const file_ = fileName_;
|
|
323
|
+
if((ff_core_String.String_endsWith(file_, ".ff") || ff_core_String.String_endsWith(file_, ".firefly-workspace"))) {
|
|
324
|
+
return ff_core_Option.Some((function() {
|
|
325
|
+
const key_ = ff_core_Path.Path_absolute(ff_core_NodeSystem.NodeSystem_path(system_, file_));
|
|
326
|
+
return ff_core_Lock.Lock_do(runner_.lock_, (() => {
|
|
327
|
+
runner_.changedSinceCompilationStarted_ = ff_core_Set.Set_add(runner_.changedSinceCompilationStarted_, key_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)
|
|
328
|
+
}))
|
|
329
|
+
})())
|
|
330
|
+
} else return ff_core_Option.None()
|
|
331
|
+
})())
|
|
332
|
+
} else return ff_core_Option.None()
|
|
333
|
+
}))
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
export function startProxy_(system_, runner_, proxyPort_, targetPort_) {
|
|
337
|
+
const net_ = import$1;
|
|
338
|
+
const targetServer_ = "localhost";
|
|
339
|
+
const proxyServer_ = net_.createServer({pauseOnConnect: true}, ((clientSocket_) => {
|
|
340
|
+
let targetSocket_ = (void 0);
|
|
341
|
+
let connected_ = false;
|
|
342
|
+
clientSocket_.on("error", ((err_) => {
|
|
343
|
+
if((!ff_core_JsValue.JsValue_isUndefined(targetSocket_))) {
|
|
344
|
+
targetSocket_.end()
|
|
345
|
+
};
|
|
346
|
+
return ff_core_Log.debugDynamic_(err_)
|
|
347
|
+
}));
|
|
348
|
+
function serveWaiterHtml_() {
|
|
349
|
+
if((ff_core_Set.Set_size(runner_.changedSinceCompilationStarted_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String) !== 0)) {
|
|
350
|
+
runner_.recompile_ = true;
|
|
351
|
+
ff_core_Task.Task_spawn(ff_core_NodeSystem.NodeSystem_mainTask(system_), ((task_) => {
|
|
352
|
+
ff_core_Lock.Lock_do(runner_.lock_, (() => {
|
|
353
|
+
return ff_core_Lock.LockCondition_wakeAll(runner_.lockCondition_)
|
|
354
|
+
}))
|
|
355
|
+
}))
|
|
356
|
+
};
|
|
357
|
+
function escapeHtml_(html_) {
|
|
358
|
+
return ff_core_String.String_replace(ff_core_String.String_replace(ff_core_String.String_replace(ff_core_String.String_replace(ff_core_String.String_replace(html_, "&", "&"), "'", "'"), "\"", """), "<", "<"), ">", ">")
|
|
359
|
+
}
|
|
360
|
+
const status_ = (((_1) => {
|
|
361
|
+
if(runner_.recompile_) {
|
|
362
|
+
return "Restarting..."
|
|
363
|
+
}
|
|
364
|
+
if(_1.ApplicationCrashedState) {
|
|
365
|
+
const output_ = _1.output_;
|
|
366
|
+
return ("Application crashed!<br>" + escapeHtml_(output_))
|
|
367
|
+
}
|
|
368
|
+
if(_1.ApplicationRunningState) {
|
|
369
|
+
return "Starting application..."
|
|
370
|
+
}
|
|
371
|
+
if(_1.CompileErrorState && _1.at_.Some) {
|
|
372
|
+
const at_ = _1.at_.value_;
|
|
373
|
+
const output_ = _1.output_;
|
|
374
|
+
const location_ = escapeHtml_(((((at_.file_ + ":") + at_.line_) + ":") + at_.column_));
|
|
375
|
+
const relativeFile_ = ff_core_Path.Path_relativeTo(ff_core_NodeSystem.NodeSystem_path(system_, at_.file_), ff_core_NodeSystem.NodeSystem_path(system_, "."));
|
|
376
|
+
const relativeLocation_ = escapeHtml_(((((relativeFile_ + ":") + at_.line_) + ":") + at_.column_));
|
|
377
|
+
const link_ = (((("<a href='vscode://file/" + escapeHtml_(location_)) + "'>") + relativeLocation_) + "</a>");
|
|
378
|
+
return ((escapeHtml_(output_) + "<br><br>at ") + link_)
|
|
379
|
+
}
|
|
380
|
+
if(_1.CompileErrorState && _1.at_.None) {
|
|
381
|
+
const output_ = _1.output_;
|
|
382
|
+
return ("Compiler crashed!<br>" + escapeHtml_(output_))
|
|
383
|
+
}
|
|
384
|
+
{
|
|
385
|
+
return "Compiling..."
|
|
386
|
+
}
|
|
387
|
+
}))(runner_.state_);
|
|
388
|
+
const waiterBuffer_ = ff_core_String.String_toBuffer(ff_core_String.String_replace(ff_compiler_DevelopMode.waiterHtml_, "[STATUS]", status_));
|
|
389
|
+
clientSocket_.write("HTTP/1.1 200 OK\r\n");
|
|
390
|
+
clientSocket_.write("Content-Type: text/html\r\n");
|
|
391
|
+
clientSocket_.write((("Content-Length: " + ff_core_Buffer.Buffer_size(waiterBuffer_)) + "\r\n"));
|
|
392
|
+
clientSocket_.write("x-firefly-develop-mode: true\r\n");
|
|
393
|
+
clientSocket_.write("Connection: close\r\n");
|
|
394
|
+
clientSocket_.write("\r\n");
|
|
395
|
+
clientSocket_.write(Buffer.from(waiterBuffer_.buffer, waiterBuffer_.byteOffset, waiterBuffer_.byteLength));
|
|
396
|
+
clientSocket_.end()
|
|
397
|
+
}
|
|
398
|
+
targetSocket_ = net_.createConnection(targetPort_, targetServer_, (() => {
|
|
399
|
+
connected_ = true;
|
|
400
|
+
const direct_ = (((_1) => {
|
|
401
|
+
if(_1.ApplicationRunningState) {
|
|
402
|
+
return ((!runner_.recompile_) && (ff_core_Set.Set_size(runner_.changedSinceCompilationStarted_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String) === 0))
|
|
403
|
+
}
|
|
404
|
+
{
|
|
405
|
+
return false
|
|
406
|
+
}
|
|
407
|
+
}))(runner_.state_);
|
|
408
|
+
if(direct_) {
|
|
409
|
+
clientSocket_.pipe(targetSocket_).pipe(clientSocket_);
|
|
410
|
+
return clientSocket_.resume()
|
|
411
|
+
} else {
|
|
412
|
+
return serveWaiterHtml_()
|
|
413
|
+
}
|
|
414
|
+
}));
|
|
415
|
+
return targetSocket_.on("error", ((err_) => {
|
|
416
|
+
if(connected_) {
|
|
417
|
+
return clientSocket_.end()
|
|
418
|
+
} else {
|
|
419
|
+
return serveWaiterHtml_()
|
|
420
|
+
}
|
|
421
|
+
}))
|
|
422
|
+
}));
|
|
423
|
+
proxyServer_.listen(proxyPort_, (() => {
|
|
424
|
+
|
|
425
|
+
}))
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
export async function run_$(system_, fireflyPath_, mainFile_, arguments_, $task) {
|
|
429
|
+
const esbuildContext_ = ff_compiler_DevelopMode.EsbuildContext(ff_core_Option.None());
|
|
430
|
+
const lock_ = (await ff_core_Task.Task_lock$((await ff_core_NodeSystem.NodeSystem_mainTask$(system_, $task)), $task));
|
|
431
|
+
const lockCondition_ = (await ff_core_Lock.Lock_condition$(lock_, $task));
|
|
432
|
+
const runner_ = ff_compiler_DevelopMode.Runner(lock_, lockCondition_, 1, ff_compiler_DevelopMode.CompilingState(), ff_core_Set.new_(), false, false);
|
|
433
|
+
(await ff_compiler_DevelopMode.startProxy_$(system_, runner_, 8081, 8080, $task));
|
|
434
|
+
(await ff_compiler_DevelopMode.startChangeListener_$(system_, runner_, (await ff_core_NodeSystem.NodeSystem_path$(system_, ".", $task)), $task));
|
|
435
|
+
const moduleCache_ = ff_compiler_ModuleCache.new_(0);
|
|
436
|
+
while(true) {
|
|
437
|
+
const moduleKey_ = (await ff_compiler_DevelopMode.build_$(system_, runner_, mainFile_, moduleCache_, $task));
|
|
438
|
+
const task_ = (await ((async (_1, $task) => {
|
|
439
|
+
if(_1.None) {
|
|
440
|
+
return (await ff_core_Task.Task_spawn$((await ff_core_NodeSystem.NodeSystem_mainTask$(system_, $task)), (async (_, $task) => {
|
|
441
|
+
|
|
442
|
+
}), $task))
|
|
443
|
+
return
|
|
444
|
+
}
|
|
445
|
+
{
|
|
446
|
+
const key_ = _1.value_;
|
|
447
|
+
(await ff_core_Lock.Lock_do$(runner_.lock_, (async ($task) => {
|
|
448
|
+
runner_.state_ = ff_compiler_DevelopMode.ApplicationRunningState()
|
|
449
|
+
}), $task));
|
|
450
|
+
return (await ff_compiler_DevelopMode.startApp_$(system_, runner_, fireflyPath_, esbuildContext_, moduleCache_, key_, mainFile_, arguments_, $task))
|
|
451
|
+
}
|
|
452
|
+
}))(moduleKey_, $task));
|
|
453
|
+
(await ff_core_Lock.Lock_do$(runner_.lock_, (async ($task) => {
|
|
454
|
+
if(runner_.appRunning_) {
|
|
455
|
+
while(runner_.appRunning_) {
|
|
456
|
+
(await ff_core_Lock.LockCondition_sleep$(runner_.lockCondition_, $task))
|
|
457
|
+
}
|
|
458
|
+
};
|
|
459
|
+
while((!runner_.recompile_)) {
|
|
460
|
+
(await ff_core_Lock.LockCondition_sleep$(runner_.lockCondition_, $task))
|
|
461
|
+
};
|
|
462
|
+
(await ff_core_Task.Task_abort$(task_, $task));
|
|
463
|
+
ff_core_Set.Set_each(runner_.changedSinceCompilationStarted_, ((key_) => {
|
|
464
|
+
ff_compiler_ModuleCache.ModuleCache_invalidate(moduleCache_, key_)
|
|
465
|
+
}), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
|
|
466
|
+
runner_.state_ = ff_compiler_DevelopMode.CompilingState();
|
|
467
|
+
runner_.recompile_ = false;
|
|
468
|
+
runner_.changedSinceCompilationStarted_ = ff_core_Set.new_();
|
|
469
|
+
runner_.iteration_ += 1
|
|
470
|
+
}), $task))
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
export async function build_$(system_, runner_, mainFile_, moduleCache_, $task) {
|
|
475
|
+
return (await ff_core_Try.Try_catchAny$((await ff_core_Try.Try_tryCatch$((await ff_core_Try.Try_tryCatch$((await ff_core_Core.try_$((async ($task) => {
|
|
476
|
+
(await ff_compiler_Main.prepareFireflyDirectory_$((await ff_core_NodeSystem.NodeSystem_path$(system_, ".", $task)), $task));
|
|
477
|
+
const resolvedDependencies_ = (await ff_compiler_Dependencies.process_$((await ff_core_NodeSystem.NodeSystem_httpClient$(system_, $task)), (await ff_compiler_DependencyLock.new_$((await ff_core_NodeSystem.NodeSystem_mainTask$(system_, $task)), $task)), (await ff_core_NodeSystem.NodeSystem_path$(system_, mainFile_, $task)), $task));
|
|
478
|
+
const mainPath_ = (await ff_core_NodeSystem.NodeSystem_path$(system_, mainFile_, $task));
|
|
479
|
+
return ff_core_Option.Some((await ff_compiler_Main.buildScript_$(system_, mainPath_, resolvedDependencies_.mainPackagePair_, ff_compiler_JsEmitter.EmitNode(), resolvedDependencies_, moduleCache_, false, $task)))
|
|
480
|
+
}), $task)), (async (_1, _2, $task) => {
|
|
481
|
+
{
|
|
482
|
+
const at_ = _1.at_;
|
|
483
|
+
const message_ = _1.message_;
|
|
484
|
+
const error_ = _2;
|
|
485
|
+
ff_core_Log.debug_(message_);
|
|
486
|
+
ff_core_Log.debug_((((((" at " + ff_core_String.String_replace(at_.file_, "./", "")) + ":") + at_.line_) + ":") + at_.column_));
|
|
487
|
+
(await ff_core_Lock.Lock_do$(runner_.lock_, (async ($task) => {
|
|
488
|
+
runner_.state_ = ff_compiler_DevelopMode.CompileErrorState(ff_core_Option.Some(at_), message_)
|
|
489
|
+
}), $task));
|
|
490
|
+
return ff_core_Option.None()
|
|
491
|
+
}
|
|
492
|
+
}), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError, $task)), (async (_1, _2, $task) => {
|
|
493
|
+
{
|
|
494
|
+
const compileErrors_ = _1.errors_;
|
|
495
|
+
const error_ = _2;
|
|
496
|
+
(await ff_core_List.List_each$(compileErrors_, (async (_1, $task) => {
|
|
497
|
+
{
|
|
498
|
+
const at_ = _1.at_;
|
|
499
|
+
const message_ = _1.message_;
|
|
500
|
+
ff_core_Log.debug_(message_);
|
|
501
|
+
ff_core_Log.debug_((((((" at " + ff_core_String.String_replace(at_.file_, "./", "")) + ":") + at_.line_) + ":") + at_.column_));
|
|
502
|
+
(await ff_core_Lock.Lock_do$(runner_.lock_, (async ($task) => {
|
|
503
|
+
runner_.state_ = ff_compiler_DevelopMode.CompileErrorState(ff_core_Option.Some(at_), message_)
|
|
504
|
+
}), $task))
|
|
505
|
+
return
|
|
506
|
+
}
|
|
507
|
+
}), $task));
|
|
508
|
+
return ff_core_Option.None()
|
|
509
|
+
}
|
|
510
|
+
}), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileErrors, $task)), (async (error_, $task) => {
|
|
511
|
+
ff_core_Log.debug_(ff_core_Error.Error_message(error_));
|
|
512
|
+
(await ff_core_Lock.Lock_do$(runner_.lock_, (async ($task) => {
|
|
513
|
+
runner_.state_ = ff_compiler_DevelopMode.CompileErrorState(ff_core_Option.None(), ff_core_Error.Error_message(error_))
|
|
514
|
+
}), $task));
|
|
515
|
+
return ff_core_Option.None()
|
|
516
|
+
}), $task))
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
export async function startApp_$(system_, runner_, fireflyPath_, esbuildContext_, moduleCache_, moduleKey_, mainFile_, arguments_, $task) {
|
|
520
|
+
const taskIteration_ = runner_.iteration_;
|
|
521
|
+
return (await ff_core_Task.Task_spawn$((await ff_core_NodeSystem.NodeSystem_mainTask$(system_, $task)), (async (task_, $task) => {
|
|
522
|
+
try {
|
|
523
|
+
const runFile_ = (await ff_compiler_Main.locateRunFile_$(system_, "node", moduleKey_, $task));
|
|
524
|
+
const runFilePath_ = (ff_core_String.String_contains(runFile_, "://")
|
|
525
|
+
? (await ff_core_NodeSystem.NodeSystem_pathFromUrl$(system_, runFile_, $task))
|
|
526
|
+
: (await ff_core_NodeSystem.NodeSystem_path$(system_, runFile_, $task)));
|
|
527
|
+
const startPath_ = (await ff_core_Path.Path_slash$(ff_core_Option.Option_grab((await ff_core_Path.Path_parent$(runFilePath_, $task))), ((await ff_core_Path.Path_base$(runFilePath_, $task)) + ".start.mjs"), $task));
|
|
528
|
+
(await ff_core_Path.Path_writeText$(startPath_, (((((((("import * as run from " + ff_core_Json.Json_write(("./" + (await ff_core_Path.Path_base$(runFilePath_, $task))), ff_core_Option.None())) + "\n") + "globalThis.ffDevelopMode = true\n") + "run.$run$(") + ff_core_Json.Json_write((await ff_core_Path.Path_absolute$(fireflyPath_, $task)), ff_core_Option.None())) + ", ") + ff_core_Json.Json_write(ff_core_Json.ff_core_Json_JsonLike$ff_core_List_List(ff_core_Json.ff_core_Json_JsonLike$ff_core_String_String).toJson_(arguments_), ff_core_Option.None())) + ")"), $task));
|
|
529
|
+
const esBuildPath_ = (await ff_core_Path.Path_slash$(ff_core_Option.Option_grab((await ff_core_Path.Path_parent$(runFilePath_, $task))), ((await ff_core_Path.Path_base$(runFilePath_, $task)) + ".minified.js"), $task));
|
|
530
|
+
const context_ = (await ff_core_Option.Option_else$(esbuildContext_.jsValue_, (async ($task) => {
|
|
531
|
+
const jsValue_ = (await ff_core_BuildSystem.internalNodeCallEsBuildContext_$(system_, (await ff_core_Path.Path_absolute$(startPath_, $task)), (await ff_core_Path.Path_absolute$(esBuildPath_, $task)), true, $task));
|
|
532
|
+
esbuildContext_.jsValue_ = ff_core_Option.Some(jsValue_);
|
|
533
|
+
return jsValue_
|
|
534
|
+
}), $task));
|
|
535
|
+
(await context_.rebuild());
|
|
536
|
+
const relativeStartFile_ = (await ff_core_Path.Path_relativeTo$(esBuildPath_, (await ff_core_NodeSystem.NodeSystem_path$(system_, ".", $task)), $task));
|
|
537
|
+
const result_ = (await ff_core_NodeSystem.NodeSystem_execute$(system_, relativeStartFile_, arguments_, ff_core_Buffer.new_(0, false), ff_core_Option.None(), ff_core_Option.None(), 16777216, 9, false, ff_core_Option.Some((async (message_, forkedProcess_, $task) => {
|
|
538
|
+
if((message_.ffDevelopMode === "internalCompile")) {
|
|
539
|
+
const mainFiles_ = message_.mainFiles;
|
|
540
|
+
const mainPaths_ = (await ff_core_List.List_map$(mainFiles_, (async (_w1, $task) => {
|
|
541
|
+
return (await ff_core_NodeSystem.NodeSystem_path$(system_, _w1, $task))
|
|
542
|
+
}), $task));
|
|
543
|
+
const target_ = message_.target;
|
|
544
|
+
(await ff_core_Lock.Lock_do$(runner_.lock_, (async ($task) => {
|
|
545
|
+
if((taskIteration_ === runner_.iteration_)) {
|
|
546
|
+
return ff_core_Option.Some(ff_core_Try.Try_catchAny(ff_core_Try.Try_tryCatch(ff_core_Try.Try_tryCatch((await ff_core_Core.try_$((async ($task) => {
|
|
547
|
+
(await ff_compiler_Builder.buildViaBuildSystem_$(system_, fireflyPath_, mainPaths_, target_, moduleCache_, false, $task));
|
|
548
|
+
forkedProcess_.send({ffDevelopMode: "internalCompile"})
|
|
549
|
+
}), $task)), ((_1, _2) => {
|
|
550
|
+
{
|
|
551
|
+
const at_ = _1.at_;
|
|
552
|
+
const message_ = _1.message_;
|
|
553
|
+
const error_ = _2;
|
|
554
|
+
runner_.state_ = ff_compiler_DevelopMode.CompileErrorState(ff_core_Option.Some(at_), message_)
|
|
555
|
+
return
|
|
556
|
+
}
|
|
557
|
+
}), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError), ((_1, _2) => {
|
|
558
|
+
{
|
|
559
|
+
const compileErrors_ = _1.errors_;
|
|
560
|
+
const error_ = _2;
|
|
561
|
+
ff_core_List.List_each(compileErrors_, ((_1) => {
|
|
562
|
+
{
|
|
563
|
+
const at_ = _1.at_;
|
|
564
|
+
const message_ = _1.message_;
|
|
565
|
+
runner_.state_ = ff_compiler_DevelopMode.CompileErrorState(ff_core_Option.Some(at_), message_)
|
|
566
|
+
return
|
|
567
|
+
}
|
|
568
|
+
}))
|
|
569
|
+
return
|
|
570
|
+
}
|
|
571
|
+
}), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileErrors), ((error_) => {
|
|
572
|
+
runner_.state_ = ff_compiler_DevelopMode.CompileErrorState(ff_core_Option.None(), ff_core_Error.Error_message(error_))
|
|
573
|
+
})))
|
|
574
|
+
} else return ff_core_Option.None()
|
|
575
|
+
}), $task))
|
|
576
|
+
}
|
|
577
|
+
})), $task));
|
|
578
|
+
const standardOut_ = ff_core_Buffer.Buffer_toString(result_.standardOut_, "utf8");
|
|
579
|
+
const standardError_ = ff_core_Buffer.Buffer_toString(result_.standardError_, "utf8");
|
|
580
|
+
(await ff_core_Lock.Lock_do$(runner_.lock_, (async ($task) => {
|
|
581
|
+
runner_.appRunning_ = false;
|
|
582
|
+
ff_core_Log.debug_(((((("Exited with code: " + result_.exitCode_) + "\n\n") + standardOut_) + "\n\n") + standardError_));
|
|
583
|
+
do {
|
|
584
|
+
const _1 = runner_.state_;
|
|
585
|
+
if(_1.ApplicationRunningState && (taskIteration_ === runner_.iteration_)) {
|
|
586
|
+
runner_.state_ = ff_compiler_DevelopMode.ApplicationCrashedState(((((("Exited with code: " + result_.exitCode_) + "\n\n") + standardOut_) + "\n\n") + standardError_))
|
|
587
|
+
break
|
|
588
|
+
}
|
|
589
|
+
{
|
|
590
|
+
|
|
591
|
+
}
|
|
592
|
+
} while(false);
|
|
593
|
+
return (await ff_core_Lock.LockCondition_wakeAll$(runner_.lockCondition_, $task))
|
|
594
|
+
}), $task))
|
|
595
|
+
} catch(error_) {
|
|
596
|
+
(await ff_core_Lock.Lock_do$(runner_.lock_, (async ($task) => {
|
|
597
|
+
runner_.appRunning_ = false;
|
|
598
|
+
return (await ff_core_Lock.LockCondition_wakeAll$(runner_.lockCondition_, $task))
|
|
599
|
+
}), $task))
|
|
600
|
+
}
|
|
601
|
+
}), $task))
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
export async function startChangeListener_$(system_, runner_, path_, $task) {
|
|
605
|
+
const fs_ = import$0;
|
|
606
|
+
fs_.watch((await ff_core_Path.Path_absolute$(path_, $task)), {recursive: true}, (async (a_1, a_2) => await (async (eventType_, fileName_, $task) => {
|
|
607
|
+
if((!ff_core_JsValue.JsValue_isNullOrUndefined(fileName_))) {
|
|
608
|
+
return ff_core_Option.Some((await (async function() {
|
|
609
|
+
const file_ = fileName_;
|
|
610
|
+
if((ff_core_String.String_endsWith(file_, ".ff") || ff_core_String.String_endsWith(file_, ".firefly-workspace"))) {
|
|
611
|
+
return ff_core_Option.Some((await (async function() {
|
|
612
|
+
const key_ = (await ff_core_Path.Path_absolute$((await ff_core_NodeSystem.NodeSystem_path$(system_, file_, $task)), $task));
|
|
613
|
+
return (await ff_core_Lock.Lock_do$(runner_.lock_, (async ($task) => {
|
|
614
|
+
runner_.changedSinceCompilationStarted_ = ff_core_Set.Set_add(runner_.changedSinceCompilationStarted_, key_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)
|
|
615
|
+
}), $task))
|
|
616
|
+
})()))
|
|
617
|
+
} else return ff_core_Option.None()
|
|
618
|
+
})()))
|
|
619
|
+
} else return ff_core_Option.None()
|
|
620
|
+
})(a_1, a_2, $task)))
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
export async function startProxy_$(system_, runner_, proxyPort_, targetPort_, $task) {
|
|
624
|
+
const net_ = import$1;
|
|
625
|
+
const targetServer_ = "localhost";
|
|
626
|
+
const proxyServer_ = net_.createServer({pauseOnConnect: true}, (async (a_1) => await (async (clientSocket_, $task) => {
|
|
627
|
+
let targetSocket_ = (void 0);
|
|
628
|
+
let connected_ = false;
|
|
629
|
+
clientSocket_.on("error", ((err_) => {
|
|
630
|
+
if((!ff_core_JsValue.JsValue_isUndefined(targetSocket_))) {
|
|
631
|
+
targetSocket_.end()
|
|
632
|
+
};
|
|
633
|
+
return ff_core_Log.debugDynamic_(err_)
|
|
634
|
+
}));
|
|
635
|
+
async function serveWaiterHtml_$($task) {
|
|
636
|
+
if((ff_core_Set.Set_size(runner_.changedSinceCompilationStarted_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String) !== 0)) {
|
|
637
|
+
runner_.recompile_ = true;
|
|
638
|
+
(await ff_core_Task.Task_spawn$((await ff_core_NodeSystem.NodeSystem_mainTask$(system_, $task)), (async (task_, $task) => {
|
|
639
|
+
(await ff_core_Lock.Lock_do$(runner_.lock_, (async ($task) => {
|
|
640
|
+
return (await ff_core_Lock.LockCondition_wakeAll$(runner_.lockCondition_, $task))
|
|
641
|
+
}), $task))
|
|
642
|
+
}), $task))
|
|
643
|
+
};
|
|
644
|
+
function escapeHtml_(html_) {
|
|
645
|
+
return ff_core_String.String_replace(ff_core_String.String_replace(ff_core_String.String_replace(ff_core_String.String_replace(ff_core_String.String_replace(html_, "&", "&"), "'", "'"), "\"", """), "<", "<"), ">", ">")
|
|
646
|
+
}
|
|
647
|
+
const status_ = (await ((async (_1, $task) => {
|
|
648
|
+
if(runner_.recompile_) {
|
|
649
|
+
return "Restarting..."
|
|
650
|
+
}
|
|
651
|
+
if(_1.ApplicationCrashedState) {
|
|
652
|
+
const output_ = _1.output_;
|
|
653
|
+
return ("Application crashed!<br>" + escapeHtml_(output_))
|
|
654
|
+
}
|
|
655
|
+
if(_1.ApplicationRunningState) {
|
|
656
|
+
return "Starting application..."
|
|
657
|
+
}
|
|
658
|
+
if(_1.CompileErrorState && _1.at_.Some) {
|
|
659
|
+
const at_ = _1.at_.value_;
|
|
660
|
+
const output_ = _1.output_;
|
|
661
|
+
const location_ = escapeHtml_(((((at_.file_ + ":") + at_.line_) + ":") + at_.column_));
|
|
662
|
+
const relativeFile_ = (await ff_core_Path.Path_relativeTo$((await ff_core_NodeSystem.NodeSystem_path$(system_, at_.file_, $task)), (await ff_core_NodeSystem.NodeSystem_path$(system_, ".", $task)), $task));
|
|
663
|
+
const relativeLocation_ = escapeHtml_(((((relativeFile_ + ":") + at_.line_) + ":") + at_.column_));
|
|
664
|
+
const link_ = (((("<a href='vscode://file/" + escapeHtml_(location_)) + "'>") + relativeLocation_) + "</a>");
|
|
665
|
+
return ((escapeHtml_(output_) + "<br><br>at ") + link_)
|
|
666
|
+
}
|
|
667
|
+
if(_1.CompileErrorState && _1.at_.None) {
|
|
668
|
+
const output_ = _1.output_;
|
|
669
|
+
return ("Compiler crashed!<br>" + escapeHtml_(output_))
|
|
670
|
+
}
|
|
671
|
+
{
|
|
672
|
+
return "Compiling..."
|
|
673
|
+
}
|
|
674
|
+
}))(runner_.state_, $task));
|
|
675
|
+
const waiterBuffer_ = ff_core_String.String_toBuffer(ff_core_String.String_replace(ff_compiler_DevelopMode.waiterHtml_, "[STATUS]", status_));
|
|
676
|
+
clientSocket_.write("HTTP/1.1 200 OK\r\n");
|
|
677
|
+
clientSocket_.write("Content-Type: text/html\r\n");
|
|
678
|
+
clientSocket_.write((("Content-Length: " + ff_core_Buffer.Buffer_size(waiterBuffer_)) + "\r\n"));
|
|
679
|
+
clientSocket_.write("x-firefly-develop-mode: true\r\n");
|
|
680
|
+
clientSocket_.write("Connection: close\r\n");
|
|
681
|
+
clientSocket_.write("\r\n");
|
|
682
|
+
clientSocket_.write(Buffer.from(waiterBuffer_.buffer, waiterBuffer_.byteOffset, waiterBuffer_.byteLength));
|
|
683
|
+
clientSocket_.end()
|
|
684
|
+
}
|
|
685
|
+
targetSocket_ = net_.createConnection(targetPort_, targetServer_, (async () => await (async ($task) => {
|
|
686
|
+
connected_ = true;
|
|
687
|
+
const direct_ = (((_1) => {
|
|
688
|
+
if(_1.ApplicationRunningState) {
|
|
689
|
+
return ((!runner_.recompile_) && (ff_core_Set.Set_size(runner_.changedSinceCompilationStarted_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String) === 0))
|
|
690
|
+
}
|
|
691
|
+
{
|
|
692
|
+
return false
|
|
693
|
+
}
|
|
694
|
+
}))(runner_.state_);
|
|
695
|
+
if(direct_) {
|
|
696
|
+
clientSocket_.pipe(targetSocket_).pipe(clientSocket_);
|
|
697
|
+
return clientSocket_.resume()
|
|
698
|
+
} else {
|
|
699
|
+
return (await serveWaiterHtml_$($task))
|
|
700
|
+
}
|
|
701
|
+
})($task)));
|
|
702
|
+
return targetSocket_.on("error", (async (a_1) => await (async (err_, $task) => {
|
|
703
|
+
if(connected_) {
|
|
704
|
+
return clientSocket_.end()
|
|
705
|
+
} else {
|
|
706
|
+
return (await serveWaiterHtml_$($task))
|
|
707
|
+
}
|
|
708
|
+
})(a_1, $task)))
|
|
709
|
+
})(a_1, $task)));
|
|
710
|
+
proxyServer_.listen(proxyPort_, (() => {
|
|
711
|
+
|
|
712
|
+
}))
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
export const ff_core_Any_HasAnyTag$ff_compiler_DevelopMode_RunnerState = {
|
|
716
|
+
anyTag_() {
|
|
717
|
+
return ff_core_Any.internalAnyTag_((("ff:compiler/DevelopMode.RunnerState" + "[") + "]"))
|
|
718
|
+
},
|
|
719
|
+
async anyTag_$($task) {
|
|
720
|
+
return ff_core_Any.internalAnyTag_((("ff:compiler/DevelopMode.RunnerState" + "[") + "]"))
|
|
721
|
+
},
|
|
722
|
+
};
|
|
723
|
+
|
|
724
|
+
export const ff_core_Show_Show$ff_compiler_DevelopMode_RunnerState = {
|
|
725
|
+
show_(value_) {
|
|
726
|
+
const value_a = value_;
|
|
727
|
+
if(value_a.CompilingState) {
|
|
728
|
+
const z_ = value_a;
|
|
729
|
+
return "CompilingState"
|
|
730
|
+
}
|
|
731
|
+
if(value_a.CompileErrorState) {
|
|
732
|
+
const z_ = value_a;
|
|
733
|
+
return ((((("CompileErrorState" + "(") + ff_core_Option.ff_core_Show_Show$ff_core_Option_Option(ff_compiler_Syntax.ff_core_Show_Show$ff_compiler_Syntax_Location).show_(z_.at_)) + ", ") + ff_core_Show.ff_core_Show_Show$ff_core_String_String.show_(z_.output_)) + ")")
|
|
734
|
+
}
|
|
735
|
+
if(value_a.ApplicationRunningState) {
|
|
736
|
+
const z_ = value_a;
|
|
737
|
+
return "ApplicationRunningState"
|
|
738
|
+
}
|
|
739
|
+
{
|
|
740
|
+
const z_ = value_a;
|
|
741
|
+
return ((("ApplicationCrashedState" + "(") + ff_core_Show.ff_core_Show_Show$ff_core_String_String.show_(z_.output_)) + ")")
|
|
742
|
+
}
|
|
743
|
+
},
|
|
744
|
+
async show_$(value_, $task) {
|
|
745
|
+
const value_a = value_;
|
|
746
|
+
if(value_a.CompilingState) {
|
|
747
|
+
const z_ = value_a;
|
|
748
|
+
return "CompilingState"
|
|
749
|
+
}
|
|
750
|
+
if(value_a.CompileErrorState) {
|
|
751
|
+
const z_ = value_a;
|
|
752
|
+
return ((((("CompileErrorState" + "(") + ff_core_Option.ff_core_Show_Show$ff_core_Option_Option(ff_compiler_Syntax.ff_core_Show_Show$ff_compiler_Syntax_Location).show_(z_.at_)) + ", ") + ff_core_Show.ff_core_Show_Show$ff_core_String_String.show_(z_.output_)) + ")")
|
|
753
|
+
}
|
|
754
|
+
if(value_a.ApplicationRunningState) {
|
|
755
|
+
const z_ = value_a;
|
|
756
|
+
return "ApplicationRunningState"
|
|
757
|
+
}
|
|
758
|
+
{
|
|
759
|
+
const z_ = value_a;
|
|
760
|
+
return ((("ApplicationCrashedState" + "(") + ff_core_Show.ff_core_Show_Show$ff_core_String_String.show_(z_.output_)) + ")")
|
|
761
|
+
}
|
|
762
|
+
},
|
|
763
|
+
};
|
|
764
|
+
|
|
765
|
+
export const ff_core_Equal_Equal$ff_compiler_DevelopMode_RunnerState = {
|
|
766
|
+
equals_(x_, y_) {
|
|
767
|
+
const x_a = x_;
|
|
768
|
+
const y_a = y_;
|
|
769
|
+
if((x_ === y_)) {
|
|
770
|
+
return true
|
|
771
|
+
}
|
|
772
|
+
if(x_a.CompileErrorState && y_a.CompileErrorState) {
|
|
773
|
+
const x_ = x_a;
|
|
774
|
+
const y_ = y_a;
|
|
775
|
+
return (ff_core_Option.ff_core_Equal_Equal$ff_core_Option_Option(ff_compiler_Syntax.ff_core_Equal_Equal$ff_compiler_Syntax_Location).equals_(x_.at_, y_.at_) && (x_.output_ === y_.output_))
|
|
776
|
+
}
|
|
777
|
+
if(x_a.ApplicationCrashedState && y_a.ApplicationCrashedState) {
|
|
778
|
+
const x_ = x_a;
|
|
779
|
+
const y_ = y_a;
|
|
780
|
+
return (x_.output_ === y_.output_)
|
|
781
|
+
}
|
|
782
|
+
{
|
|
783
|
+
return false
|
|
784
|
+
}
|
|
785
|
+
},
|
|
786
|
+
async equals_$(x_, y_, $task) {
|
|
787
|
+
const x_a = x_;
|
|
788
|
+
const y_a = y_;
|
|
789
|
+
if((x_ === y_)) {
|
|
790
|
+
return true
|
|
791
|
+
}
|
|
792
|
+
if(x_a.CompileErrorState && y_a.CompileErrorState) {
|
|
793
|
+
const x_ = x_a;
|
|
794
|
+
const y_ = y_a;
|
|
795
|
+
return (ff_core_Option.ff_core_Equal_Equal$ff_core_Option_Option(ff_compiler_Syntax.ff_core_Equal_Equal$ff_compiler_Syntax_Location).equals_(x_.at_, y_.at_) && (x_.output_ === y_.output_))
|
|
796
|
+
}
|
|
797
|
+
if(x_a.ApplicationCrashedState && y_a.ApplicationCrashedState) {
|
|
798
|
+
const x_ = x_a;
|
|
799
|
+
const y_ = y_a;
|
|
800
|
+
return (x_.output_ === y_.output_)
|
|
801
|
+
}
|
|
802
|
+
{
|
|
803
|
+
return false
|
|
804
|
+
}
|
|
805
|
+
},
|
|
806
|
+
};
|
|
807
|
+
|
|
808
|
+
export const ff_core_Ordering_Order$ff_compiler_DevelopMode_RunnerState = {
|
|
809
|
+
compare_(x_, y_) {
|
|
810
|
+
const x_a = x_;
|
|
811
|
+
const y_a = y_;
|
|
812
|
+
if((x_ === y_)) {
|
|
813
|
+
return ff_core_Ordering.OrderingSame()
|
|
814
|
+
}
|
|
815
|
+
if(x_a.CompileErrorState && y_a.CompileErrorState) {
|
|
816
|
+
const x_ = x_a;
|
|
817
|
+
const y_ = y_a;
|
|
818
|
+
const atOrdering_ = ff_core_Option.ff_core_Ordering_Order$ff_core_Option_Option(ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_Location).compare_(x_.at_, y_.at_);
|
|
819
|
+
if((atOrdering_ !== ff_core_Ordering.OrderingSame())) {
|
|
820
|
+
return atOrdering_
|
|
821
|
+
} else {
|
|
822
|
+
const outputOrdering_ = ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String.compare_(x_.output_, y_.output_);
|
|
823
|
+
if((outputOrdering_ !== ff_core_Ordering.OrderingSame())) {
|
|
824
|
+
return outputOrdering_
|
|
825
|
+
} else {
|
|
826
|
+
return ff_core_Ordering.OrderingSame()
|
|
827
|
+
}
|
|
828
|
+
}
|
|
829
|
+
return
|
|
830
|
+
}
|
|
831
|
+
if(x_a.ApplicationCrashedState && y_a.ApplicationCrashedState) {
|
|
832
|
+
const x_ = x_a;
|
|
833
|
+
const y_ = y_a;
|
|
834
|
+
const outputOrdering_ = ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String.compare_(x_.output_, y_.output_);
|
|
835
|
+
if((outputOrdering_ !== ff_core_Ordering.OrderingSame())) {
|
|
836
|
+
return outputOrdering_
|
|
837
|
+
} else {
|
|
838
|
+
return ff_core_Ordering.OrderingSame()
|
|
839
|
+
}
|
|
840
|
+
return
|
|
841
|
+
}
|
|
842
|
+
{
|
|
843
|
+
function number_(z_) {
|
|
844
|
+
const z_a = z_;
|
|
845
|
+
if(z_a.CompilingState) {
|
|
846
|
+
return 0
|
|
847
|
+
}
|
|
848
|
+
if(z_a.CompileErrorState) {
|
|
849
|
+
return 1
|
|
850
|
+
}
|
|
851
|
+
if(z_a.ApplicationRunningState) {
|
|
852
|
+
return 2
|
|
853
|
+
}
|
|
854
|
+
{
|
|
855
|
+
return 3
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
return ff_core_Ordering.ff_core_Ordering_Order$ff_core_Int_Int.compare_(number_(x_), number_(y_))
|
|
859
|
+
}
|
|
860
|
+
},
|
|
861
|
+
async compare_$(x_, y_, $task) {
|
|
862
|
+
const x_a = x_;
|
|
863
|
+
const y_a = y_;
|
|
864
|
+
if((x_ === y_)) {
|
|
865
|
+
return ff_core_Ordering.OrderingSame()
|
|
866
|
+
}
|
|
867
|
+
if(x_a.CompileErrorState && y_a.CompileErrorState) {
|
|
868
|
+
const x_ = x_a;
|
|
869
|
+
const y_ = y_a;
|
|
870
|
+
const atOrdering_ = ff_core_Option.ff_core_Ordering_Order$ff_core_Option_Option(ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_Location).compare_(x_.at_, y_.at_);
|
|
871
|
+
if((atOrdering_ !== ff_core_Ordering.OrderingSame())) {
|
|
872
|
+
return atOrdering_
|
|
873
|
+
} else {
|
|
874
|
+
const outputOrdering_ = ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String.compare_(x_.output_, y_.output_);
|
|
875
|
+
if((outputOrdering_ !== ff_core_Ordering.OrderingSame())) {
|
|
876
|
+
return outputOrdering_
|
|
877
|
+
} else {
|
|
878
|
+
return ff_core_Ordering.OrderingSame()
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
return
|
|
882
|
+
}
|
|
883
|
+
if(x_a.ApplicationCrashedState && y_a.ApplicationCrashedState) {
|
|
884
|
+
const x_ = x_a;
|
|
885
|
+
const y_ = y_a;
|
|
886
|
+
const outputOrdering_ = ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String.compare_(x_.output_, y_.output_);
|
|
887
|
+
if((outputOrdering_ !== ff_core_Ordering.OrderingSame())) {
|
|
888
|
+
return outputOrdering_
|
|
889
|
+
} else {
|
|
890
|
+
return ff_core_Ordering.OrderingSame()
|
|
891
|
+
}
|
|
892
|
+
return
|
|
893
|
+
}
|
|
894
|
+
{
|
|
895
|
+
function number_(z_) {
|
|
896
|
+
const z_a = z_;
|
|
897
|
+
if(z_a.CompilingState) {
|
|
898
|
+
return 0
|
|
899
|
+
}
|
|
900
|
+
if(z_a.CompileErrorState) {
|
|
901
|
+
return 1
|
|
902
|
+
}
|
|
903
|
+
if(z_a.ApplicationRunningState) {
|
|
904
|
+
return 2
|
|
905
|
+
}
|
|
906
|
+
{
|
|
907
|
+
return 3
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
return ff_core_Ordering.ff_core_Ordering_Order$ff_core_Int_Int.compare_(number_(x_), number_(y_))
|
|
911
|
+
}
|
|
912
|
+
},
|
|
913
|
+
};
|
|
914
|
+
|
|
915
|
+
export const ff_core_Serializable_Serializable$ff_compiler_DevelopMode_RunnerState = {
|
|
916
|
+
serializeUsing_(serialization_, value_) {
|
|
917
|
+
const serialization_a = serialization_;
|
|
918
|
+
const value_a = value_;
|
|
919
|
+
if(value_a.CompilingState) {
|
|
920
|
+
const v_ = value_a;
|
|
921
|
+
serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 38), 0);
|
|
922
|
+
ff_core_Serializable.Serialization_autoResize(serialization_, 1);
|
|
923
|
+
ff_core_Buffer.Buffer_setUint8(serialization_.buffer_, serialization_.offset_, 0);
|
|
924
|
+
serialization_.offset_ += 1
|
|
925
|
+
return
|
|
926
|
+
}
|
|
927
|
+
if(value_a.CompileErrorState) {
|
|
928
|
+
const v_ = value_a;
|
|
929
|
+
serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 41), 0);
|
|
930
|
+
ff_core_Serializable.Serialization_autoResize(serialization_, 1);
|
|
931
|
+
ff_core_Buffer.Buffer_setUint8(serialization_.buffer_, serialization_.offset_, 1);
|
|
932
|
+
serialization_.offset_ += 1;
|
|
933
|
+
ff_core_Option.ff_core_Serializable_Serializable$ff_core_Option_Option(ff_compiler_Syntax.ff_core_Serializable_Serializable$ff_compiler_Syntax_Location).serializeUsing_(serialization_, v_.at_);
|
|
934
|
+
ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_String_String.serializeUsing_(serialization_, v_.output_)
|
|
935
|
+
return
|
|
936
|
+
}
|
|
937
|
+
if(value_a.ApplicationRunningState) {
|
|
938
|
+
const v_ = value_a;
|
|
939
|
+
serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 47), 0);
|
|
940
|
+
ff_core_Serializable.Serialization_autoResize(serialization_, 1);
|
|
941
|
+
ff_core_Buffer.Buffer_setUint8(serialization_.buffer_, serialization_.offset_, 2);
|
|
942
|
+
serialization_.offset_ += 1
|
|
943
|
+
return
|
|
944
|
+
}
|
|
945
|
+
{
|
|
946
|
+
const v_ = value_a;
|
|
947
|
+
serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 47), 0);
|
|
948
|
+
ff_core_Serializable.Serialization_autoResize(serialization_, 1);
|
|
949
|
+
ff_core_Buffer.Buffer_setUint8(serialization_.buffer_, serialization_.offset_, 3);
|
|
950
|
+
serialization_.offset_ += 1;
|
|
951
|
+
ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_String_String.serializeUsing_(serialization_, v_.output_)
|
|
952
|
+
return
|
|
953
|
+
}
|
|
954
|
+
},
|
|
955
|
+
deserializeUsing_(serialization_) {
|
|
956
|
+
const variantIndex_ = ff_core_Buffer.Buffer_grabUint8(serialization_.buffer_, serialization_.offset_);
|
|
957
|
+
serialization_.offset_ += 1;
|
|
958
|
+
{
|
|
959
|
+
const _1 = variantIndex_;
|
|
960
|
+
if(_1 === 0) {
|
|
961
|
+
serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 38), 0);
|
|
962
|
+
return ff_compiler_DevelopMode.CompilingState()
|
|
963
|
+
}
|
|
964
|
+
if(_1 === 1) {
|
|
965
|
+
serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 41), 0);
|
|
966
|
+
return ff_compiler_DevelopMode.CompileErrorState(ff_core_Option.ff_core_Serializable_Serializable$ff_core_Option_Option(ff_compiler_Syntax.ff_core_Serializable_Serializable$ff_compiler_Syntax_Location).deserializeUsing_(serialization_), ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_String_String.deserializeUsing_(serialization_))
|
|
967
|
+
}
|
|
968
|
+
if(_1 === 2) {
|
|
969
|
+
serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 47), 0);
|
|
970
|
+
return ff_compiler_DevelopMode.ApplicationRunningState()
|
|
971
|
+
}
|
|
972
|
+
if(_1 === 3) {
|
|
973
|
+
serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 47), 0);
|
|
974
|
+
return ff_compiler_DevelopMode.ApplicationCrashedState(ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_String_String.deserializeUsing_(serialization_))
|
|
975
|
+
}
|
|
976
|
+
{
|
|
977
|
+
throw ff_core_Js.initializeError_(ff_core_Serializable.DeserializationChecksumException(), new Error(), ff_core_Serializable.ff_core_Any_HasAnyTag$ff_core_Serializable_DeserializationChecksumException, ff_core_Serializable.ff_core_Show_Show$ff_core_Serializable_DeserializationChecksumException)
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
},
|
|
981
|
+
async serializeUsing_$(serialization_, value_, $task) {
|
|
982
|
+
const serialization_a = serialization_;
|
|
983
|
+
const value_a = value_;
|
|
984
|
+
if(value_a.CompilingState) {
|
|
985
|
+
const v_ = value_a;
|
|
986
|
+
serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 38), 0);
|
|
987
|
+
ff_core_Serializable.Serialization_autoResize(serialization_, 1);
|
|
988
|
+
ff_core_Buffer.Buffer_setUint8(serialization_.buffer_, serialization_.offset_, 0);
|
|
989
|
+
serialization_.offset_ += 1
|
|
990
|
+
return
|
|
991
|
+
}
|
|
992
|
+
if(value_a.CompileErrorState) {
|
|
993
|
+
const v_ = value_a;
|
|
994
|
+
serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 41), 0);
|
|
995
|
+
ff_core_Serializable.Serialization_autoResize(serialization_, 1);
|
|
996
|
+
ff_core_Buffer.Buffer_setUint8(serialization_.buffer_, serialization_.offset_, 1);
|
|
997
|
+
serialization_.offset_ += 1;
|
|
998
|
+
ff_core_Option.ff_core_Serializable_Serializable$ff_core_Option_Option(ff_compiler_Syntax.ff_core_Serializable_Serializable$ff_compiler_Syntax_Location).serializeUsing_(serialization_, v_.at_);
|
|
999
|
+
ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_String_String.serializeUsing_(serialization_, v_.output_)
|
|
1000
|
+
return
|
|
1001
|
+
}
|
|
1002
|
+
if(value_a.ApplicationRunningState) {
|
|
1003
|
+
const v_ = value_a;
|
|
1004
|
+
serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 47), 0);
|
|
1005
|
+
ff_core_Serializable.Serialization_autoResize(serialization_, 1);
|
|
1006
|
+
ff_core_Buffer.Buffer_setUint8(serialization_.buffer_, serialization_.offset_, 2);
|
|
1007
|
+
serialization_.offset_ += 1
|
|
1008
|
+
return
|
|
1009
|
+
}
|
|
1010
|
+
{
|
|
1011
|
+
const v_ = value_a;
|
|
1012
|
+
serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 47), 0);
|
|
1013
|
+
ff_core_Serializable.Serialization_autoResize(serialization_, 1);
|
|
1014
|
+
ff_core_Buffer.Buffer_setUint8(serialization_.buffer_, serialization_.offset_, 3);
|
|
1015
|
+
serialization_.offset_ += 1;
|
|
1016
|
+
ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_String_String.serializeUsing_(serialization_, v_.output_)
|
|
1017
|
+
return
|
|
1018
|
+
}
|
|
1019
|
+
},
|
|
1020
|
+
async deserializeUsing_$(serialization_, $task) {
|
|
1021
|
+
const variantIndex_ = ff_core_Buffer.Buffer_grabUint8(serialization_.buffer_, serialization_.offset_);
|
|
1022
|
+
serialization_.offset_ += 1;
|
|
1023
|
+
{
|
|
1024
|
+
const _1 = variantIndex_;
|
|
1025
|
+
if(_1 === 0) {
|
|
1026
|
+
serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 38), 0);
|
|
1027
|
+
return ff_compiler_DevelopMode.CompilingState()
|
|
1028
|
+
}
|
|
1029
|
+
if(_1 === 1) {
|
|
1030
|
+
serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 41), 0);
|
|
1031
|
+
return ff_compiler_DevelopMode.CompileErrorState(ff_core_Option.ff_core_Serializable_Serializable$ff_core_Option_Option(ff_compiler_Syntax.ff_core_Serializable_Serializable$ff_compiler_Syntax_Location).deserializeUsing_(serialization_), ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_String_String.deserializeUsing_(serialization_))
|
|
1032
|
+
}
|
|
1033
|
+
if(_1 === 2) {
|
|
1034
|
+
serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 47), 0);
|
|
1035
|
+
return ff_compiler_DevelopMode.ApplicationRunningState()
|
|
1036
|
+
}
|
|
1037
|
+
if(_1 === 3) {
|
|
1038
|
+
serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 47), 0);
|
|
1039
|
+
return ff_compiler_DevelopMode.ApplicationCrashedState(ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_String_String.deserializeUsing_(serialization_))
|
|
1040
|
+
}
|
|
1041
|
+
{
|
|
1042
|
+
throw ff_core_Js.initializeError_(ff_core_Serializable.DeserializationChecksumException(), new Error(), ff_core_Serializable.ff_core_Any_HasAnyTag$ff_core_Serializable_DeserializationChecksumException, ff_core_Serializable.ff_core_Show_Show$ff_core_Serializable_DeserializationChecksumException)
|
|
1043
|
+
}
|
|
1044
|
+
}
|
|
1045
|
+
},
|
|
1046
|
+
};
|
|
1047
|
+
|
|
1048
|
+
|
|
1049
|
+
//# sourceMappingURL=DevelopMode.mjs.map
|