firefly-compiler 0.4.6 → 0.4.8

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.
Files changed (90) hide show
  1. package/compiler/Compiler.ff +2 -0
  2. package/compiler/Deriver.ff +7 -0
  3. package/core/Array.ff +17 -4
  4. package/core/AssetSystem.ff +1 -1
  5. package/core/BrowserSystem.ff +27 -0
  6. package/core/List.ff +4 -0
  7. package/core/Lock.ff +2 -2
  8. package/core/Random.ff +148 -0
  9. package/core/SourceLocation.ff +27 -0
  10. package/core/Task.ff +3 -0
  11. package/core/WebSocket.ff +127 -0
  12. package/httpserver/HttpServer.ff +1 -1
  13. package/lux/Css.ff +648 -0
  14. package/lux/CssTest.ff +48 -0
  15. package/lux/Lux.ff +33 -18
  16. package/lux/Main.ff +4 -1
  17. package/output/js/ff/compiler/Builder.mjs +448 -444
  18. package/output/js/ff/compiler/Compiler.mjs +420 -416
  19. package/output/js/ff/compiler/Dependencies.mjs +393 -389
  20. package/output/js/ff/compiler/Deriver.mjs +1178 -1170
  21. package/output/js/ff/compiler/Dictionaries.mjs +1315 -1309
  22. package/output/js/ff/compiler/Environment.mjs +1025 -1015
  23. package/output/js/ff/compiler/Inference.mjs +4272 -4268
  24. package/output/js/ff/compiler/JsEmitter.mjs +5405 -5391
  25. package/output/js/ff/compiler/JsImporter.mjs +270 -266
  26. package/output/js/ff/compiler/LspHook.mjs +799 -793
  27. package/output/js/ff/compiler/Main.mjs +1691 -1675
  28. package/output/js/ff/compiler/Parser.mjs +4016 -4008
  29. package/output/js/ff/compiler/Patterns.mjs +935 -927
  30. package/output/js/ff/compiler/Resolver.mjs +2311 -2307
  31. package/output/js/ff/compiler/Substitution.mjs +1154 -1150
  32. package/output/js/ff/compiler/Syntax.mjs +12566 -12434
  33. package/output/js/ff/compiler/Token.mjs +3152 -3096
  34. package/output/js/ff/compiler/Tokenizer.mjs +597 -593
  35. package/output/js/ff/compiler/Unification.mjs +1762 -1752
  36. package/output/js/ff/compiler/Wildcards.mjs +612 -608
  37. package/output/js/ff/compiler/Workspace.mjs +695 -687
  38. package/output/js/ff/core/Any.mjs +147 -143
  39. package/output/js/ff/core/Array.mjs +573 -547
  40. package/output/js/ff/core/AssetSystem.mjs +278 -274
  41. package/output/js/ff/core/Atomic.mjs +158 -154
  42. package/output/js/ff/core/Bool.mjs +156 -152
  43. package/output/js/ff/core/Box.mjs +116 -112
  44. package/output/js/ff/core/BrowserSystem.mjs +181 -126
  45. package/output/js/ff/core/Buffer.mjs +399 -395
  46. package/output/js/ff/core/BuildSystem.mjs +300 -296
  47. package/output/js/ff/core/Channel.mjs +193 -189
  48. package/output/js/ff/core/Char.mjs +153 -149
  49. package/output/js/ff/core/Core.mjs +304 -300
  50. package/output/js/ff/core/Duration.mjs +120 -116
  51. package/output/js/ff/core/Equal.mjs +183 -179
  52. package/output/js/ff/core/Error.mjs +146 -142
  53. package/output/js/ff/core/FileHandle.mjs +154 -150
  54. package/output/js/ff/core/Float.mjs +229 -225
  55. package/output/js/ff/core/HttpClient.mjs +195 -191
  56. package/output/js/ff/core/Instant.mjs +113 -109
  57. package/output/js/ff/core/Int.mjs +269 -265
  58. package/output/js/ff/core/IntMap.mjs +284 -280
  59. package/output/js/ff/core/JsSystem.mjs +242 -238
  60. package/output/js/ff/core/JsValue.mjs +712 -708
  61. package/output/js/ff/core/List.mjs +2346 -2334
  62. package/output/js/ff/core/Lock.mjs +235 -231
  63. package/output/js/ff/core/Log.mjs +167 -163
  64. package/output/js/ff/core/Map.mjs +366 -362
  65. package/output/js/ff/core/NodeSystem.mjs +298 -294
  66. package/output/js/ff/core/Nothing.mjs +108 -104
  67. package/output/js/ff/core/Option.mjs +1023 -1015
  68. package/output/js/ff/core/Ordering.mjs +734 -730
  69. package/output/js/ff/core/Pair.mjs +337 -331
  70. package/output/js/ff/core/Path.mjs +549 -545
  71. package/output/js/ff/core/Random.mjs +340 -0
  72. package/output/js/ff/core/RbMap.mjs +1944 -1940
  73. package/output/js/ff/core/Serializable.mjs +432 -428
  74. package/output/js/ff/core/Set.mjs +258 -254
  75. package/output/js/ff/core/Show.mjs +209 -205
  76. package/output/js/ff/core/SourceLocation.mjs +273 -229
  77. package/output/js/ff/core/Stack.mjs +533 -529
  78. package/output/js/ff/core/Stream.mjs +1308 -1304
  79. package/output/js/ff/core/String.mjs +369 -365
  80. package/output/js/ff/core/StringMap.mjs +284 -280
  81. package/output/js/ff/core/Task.mjs +325 -319
  82. package/output/js/ff/core/Try.mjs +511 -507
  83. package/output/js/ff/core/Unit.mjs +155 -151
  84. package/output/js/ff/core/WebSocket.mjs +198 -0
  85. package/package.json +1 -1
  86. package/vscode/package.json +1 -1
  87. package/webserver/.firefly/include/package-lock.json +16 -0
  88. package/webserver/.firefly/include/package.json +5 -0
  89. package/webserver/.firefly/package.ff +2 -0
  90. package/webserver/WebServer.ff +608 -0
@@ -1,271 +1,275 @@
1
- import * as import$0 from 'pkg';
2
-
3
- import * as ff_compiler_Builder from "../../ff/compiler/Builder.mjs"
4
-
5
- import * as ff_compiler_Compiler from "../../ff/compiler/Compiler.mjs"
6
-
7
- import * as ff_compiler_Dependencies from "../../ff/compiler/Dependencies.mjs"
8
-
9
- import * as ff_compiler_JsEmitter from "../../ff/compiler/JsEmitter.mjs"
10
-
11
- import * as ff_compiler_LspHook from "../../ff/compiler/LspHook.mjs"
12
-
13
- import * as ff_compiler_Parser from "../../ff/compiler/Parser.mjs"
14
-
15
- import * as ff_compiler_Resolver from "../../ff/compiler/Resolver.mjs"
16
-
17
- import * as ff_compiler_Syntax from "../../ff/compiler/Syntax.mjs"
18
-
19
- import * as ff_compiler_Tokenizer from "../../ff/compiler/Tokenizer.mjs"
20
-
21
- import * as ff_compiler_Unification from "../../ff/compiler/Unification.mjs"
22
-
23
- import * as ff_core_Any from "../../ff/core/Any.mjs"
24
-
25
- import * as ff_core_Array from "../../ff/core/Array.mjs"
26
-
27
- import * as ff_core_AssetSystem from "../../ff/core/AssetSystem.mjs"
28
-
29
- import * as ff_core_Atomic from "../../ff/core/Atomic.mjs"
30
-
31
- import * as ff_core_Bool from "../../ff/core/Bool.mjs"
32
-
33
- import * as ff_core_Box from "../../ff/core/Box.mjs"
34
-
35
- import * as ff_core_BrowserSystem from "../../ff/core/BrowserSystem.mjs"
36
-
37
- import * as ff_core_Buffer from "../../ff/core/Buffer.mjs"
38
-
39
- import * as ff_core_BuildSystem from "../../ff/core/BuildSystem.mjs"
40
-
41
- import * as ff_core_Channel from "../../ff/core/Channel.mjs"
42
-
43
- import * as ff_core_Char from "../../ff/core/Char.mjs"
44
-
45
- import * as ff_core_Core from "../../ff/core/Core.mjs"
46
-
47
- import * as ff_core_Duration from "../../ff/core/Duration.mjs"
48
-
49
- import * as ff_core_Equal from "../../ff/core/Equal.mjs"
50
-
51
- import * as ff_core_Error from "../../ff/core/Error.mjs"
52
-
53
- import * as ff_core_FileHandle from "../../ff/core/FileHandle.mjs"
54
-
55
- import * as ff_core_Float from "../../ff/core/Float.mjs"
56
-
57
- import * as ff_core_HttpClient from "../../ff/core/HttpClient.mjs"
58
-
59
- import * as ff_core_Instant from "../../ff/core/Instant.mjs"
60
-
61
- import * as ff_core_Int from "../../ff/core/Int.mjs"
62
-
63
- import * as ff_core_IntMap from "../../ff/core/IntMap.mjs"
64
-
65
- import * as ff_core_JsSystem from "../../ff/core/JsSystem.mjs"
66
-
67
- import * as ff_core_JsValue from "../../ff/core/JsValue.mjs"
68
-
69
- import * as ff_core_List from "../../ff/core/List.mjs"
70
-
71
- import * as ff_core_Lock from "../../ff/core/Lock.mjs"
72
-
73
- import * as ff_core_Log from "../../ff/core/Log.mjs"
74
-
75
- import * as ff_core_Map from "../../ff/core/Map.mjs"
76
-
77
- import * as ff_core_NodeSystem from "../../ff/core/NodeSystem.mjs"
78
-
79
- import * as ff_core_Nothing from "../../ff/core/Nothing.mjs"
80
-
81
- import * as ff_core_Option from "../../ff/core/Option.mjs"
82
-
83
- import * as ff_core_Ordering from "../../ff/core/Ordering.mjs"
84
-
85
- import * as ff_core_Pair from "../../ff/core/Pair.mjs"
86
-
87
- import * as ff_core_Path from "../../ff/core/Path.mjs"
88
-
89
- import * as ff_core_Serializable from "../../ff/core/Serializable.mjs"
90
-
91
- import * as ff_core_Set from "../../ff/core/Set.mjs"
92
-
93
- import * as ff_core_Show from "../../ff/core/Show.mjs"
94
-
95
- import * as ff_core_SourceLocation from "../../ff/core/SourceLocation.mjs"
96
-
97
- import * as ff_core_Stack from "../../ff/core/Stack.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 ff_core_Unit from "../../ff/core/Unit.mjs"
110
-
111
- // type PackageFiles
112
- export function PackageFiles(root_, packageFile_, files_) {
113
- return {root_, packageFile_, files_};
114
- }
115
-
116
-
117
-
118
- export function build_(system_, emitTarget_, mainPackage_, mainModule_, resolvedDependencies_, compilerModulePath_, tempPath_, jsOutputPath_, printMeasurements_) {
119
- if(ff_core_Path.Path_exists(tempPath_, false, false, false)) {
120
- ff_core_Path.Path_delete(tempPath_, 0, 100)
121
- };
122
- ff_core_Path.Path_createDirectory(tempPath_, false);
123
- const jsPathFile_ = ff_core_Path.Path_slash(tempPath_, "js");
124
- ff_core_Path.Path_createDirectory(jsPathFile_, true);
125
- const success_ = ff_core_Core.do_((() => {
126
- const compiler_ = ff_compiler_Compiler.make_(emitTarget_, ff_core_NodeSystem.NodeSystem_mainTask(system_), compilerModulePath_, jsPathFile_, resolvedDependencies_, ff_core_Map.empty_(), ff_compiler_LspHook.disabled_());
127
- ff_compiler_Compiler.Compiler_emit(compiler_, mainPackage_, mainModule_, true);
128
- if(printMeasurements_) {
129
- ff_compiler_Compiler.Compiler_printMeasurements(compiler_)
130
- };
131
- ff_core_Map.Map_each(resolvedDependencies_.packagePaths_, ((packagePair_, packagePath_) => {
132
- ff_core_Option.Option_each(ff_core_Map.Map_get(resolvedDependencies_.packages_, packagePair_, ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair), ((packageInfo_) => {
133
- ff_compiler_Builder.processIncludes_(jsPathFile_, packagePath_, packageInfo_)
134
- }))
135
- }), ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair);
136
- return true
137
- }));
138
- if(success_) {
139
- if(ff_core_Path.Path_exists(jsOutputPath_, false, false, false)) {
140
- ff_core_Path.Path_delete(jsOutputPath_, 0, 100)
141
- };
142
- ff_core_Path.Path_renameTo(jsPathFile_, jsOutputPath_)
143
- }
144
- }
145
-
146
- export function processIncludes_(jsPathFile_, packagePath_, info_) {
147
- ff_core_List.List_each(info_.includes_, ((include_) => {
148
- const fromPath_ = ff_core_Path.Path_slash(ff_core_Path.Path_slash(ff_core_Path.Path_slash(packagePath_, ".firefly"), "include"), include_.path_);
149
- const toPath_ = ff_core_Path.Path_slash(ff_core_Path.Path_slash(jsPathFile_, ff_compiler_Syntax.PackagePair_groupName(info_.package_.packagePair_, "/")), include_.path_);
150
- ff_core_Path.Path_copyTo(fromPath_, toPath_, 0, 100)
151
- }))
152
- }
153
-
154
- export function buildViaBuildSystem_(system_, fireflyPath_, mainFile_, target_) {
155
- const resolvedDependencies_ = ff_compiler_Dependencies.process_(ff_core_NodeSystem.NodeSystem_httpClient(system_), ff_core_NodeSystem.NodeSystem_path(system_, mainFile_));
156
- const fixedPackagePaths_ = (ff_core_Map.Map_contains(resolvedDependencies_.packagePaths_, ff_compiler_Syntax.PackagePair("ff", "core"), ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair)
157
- ? resolvedDependencies_.packagePaths_
158
- : ff_core_Map.Map_add(resolvedDependencies_.packagePaths_, ff_compiler_Syntax.PackagePair("ff", "core"), ff_core_Path.Path_slash(fireflyPath_, "core"), ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair));
159
- if((target_ !== "browser")) {
160
- ff_core_Core.panic_("buildViaBuildSystem is currently limited to browser target only - the restriction can be lifted")
161
- };
162
- ff_compiler_Builder.build_(system_, ff_compiler_JsEmitter.EmitBrowser(), resolvedDependencies_.mainPackagePair_, ff_core_String.String_dropLast(mainFile_, ff_core_String.String_size(".ff")), (((_c) => {
163
- return ff_compiler_Dependencies.ResolvedDependencies(_c.mainPackagePair_, _c.packages_, fixedPackagePaths_, _c.singleFilePackages_)
164
- }))(resolvedDependencies_), ff_core_Option.None(), ff_core_NodeSystem.NodeSystem_path(system_, ".firefly/temporary"), ff_core_Path.Path_slash(ff_core_NodeSystem.NodeSystem_path(system_, ".firefly/output"), target_), false)
165
- }
166
-
167
- export function check_(system_, fireflyPath_, path_, virtualFiles_, lspHook_, infer_) {
168
- const packages_ = (((_1) => {
169
- {
170
- if(_1) {
171
- return ff_compiler_Builder.findPackageFiles_(path_)
172
- return
173
- }
174
- }
175
- {
176
- if(!_1) {
177
- const _guard1 = ff_core_Path.Path_endsWith(path_, ff_core_List.Link(".firefly", ff_core_List.Link("package.ff", ff_core_List.Empty())));
178
- if(_guard1) {
179
- return ff_core_List.Link(ff_compiler_Builder.PackageFiles(ff_core_Option.Option_grab(ff_core_Path.Path_parent(path_)), ff_core_Option.Some(path_), ff_core_List.Empty()), ff_core_List.Empty())
180
- return
181
- }
182
- }
183
- }
184
- {
185
- if(!_1) {
186
- return ff_core_List.Link(ff_compiler_Builder.PackageFiles(ff_core_Option.Option_grab(ff_core_Path.Path_parent(path_)), ff_core_Option.None(), ff_core_List.Link(path_, ff_core_List.Empty())), ff_core_List.Empty())
187
- return
188
- }
189
- }
190
- }))(ff_core_Path.Path_isDirectory(path_));
191
- ff_core_List.List_each(ff_core_List.List_filter(packages_, ((_w1) => {
192
- return (!ff_core_List.List_isEmpty(_w1.files_))
193
- })), ((package_) => {
194
- const firstFile_ = ff_core_List.List_grabFirst(package_.files_);
195
- const resolvedDependencies_ = ff_compiler_Dependencies.process_(ff_core_NodeSystem.NodeSystem_httpClient(system_), firstFile_);
196
- const fixedPackagePaths_ = (ff_core_Map.Map_contains(resolvedDependencies_.packagePaths_, ff_compiler_Syntax.PackagePair("ff", "core"), ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair)
197
- ? resolvedDependencies_.packagePaths_
198
- : ff_core_Map.Map_add(resolvedDependencies_.packagePaths_, ff_compiler_Syntax.PackagePair("ff", "core"), ff_core_Path.Path_slash(fireflyPath_, "core"), ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair));
199
- const fixedResolvedDependencies_ = (((_c) => {
200
- return ff_compiler_Dependencies.ResolvedDependencies(_c.mainPackagePair_, _c.packages_, fixedPackagePaths_, _c.singleFilePackages_)
201
- }))(resolvedDependencies_);
202
- const compiler_ = ff_compiler_Compiler.make_(ff_compiler_JsEmitter.EmitBuild(), ff_core_NodeSystem.NodeSystem_mainTask(system_), ff_core_Option.None(), ff_core_Path.Path_slash(ff_core_Path.Path_slash(package_.root_, ".firefly"), "temporary"), fixedResolvedDependencies_, virtualFiles_, lspHook_);
203
- ff_core_List.List_each(package_.files_, ((file_) => {
204
- const localFile_ = ff_core_Path.Path_base(file_);
205
- if(infer_) {
206
- ff_compiler_Compiler.Compiler_infer(compiler_, resolvedDependencies_.mainPackagePair_, ff_core_String.String_dropLast(localFile_, ff_core_String.String_size(".ff")))
207
- } else {
208
- ff_compiler_Compiler.Compiler_resolve(compiler_, resolvedDependencies_.mainPackagePair_, ff_core_String.String_dropLast(localFile_, ff_core_String.String_size(".ff")))
209
- }
210
- }))
211
- }))
212
- }
213
-
214
- export function findPackageFiles_(path_) {
215
- const files_ = ff_compiler_Builder.findFireflyFiles_(path_);
216
- const split_ = ff_core_List.List_partition(files_, ((_w1) => {
217
- return ff_core_Path.Path_endsWith(_w1, ff_core_List.Link(".firefly", ff_core_List.Link("package.ff", ff_core_List.Empty())))
218
- }));
219
- const packageFiles_ = split_.first_;
220
- let singleFiles_ = split_.second_;
221
- const multiFileProjects_ = ff_core_List.List_map(packageFiles_, ((packageFile_) => {
222
- const projectRoot_ = ff_core_Option.Option_grab(ff_core_Path.Path_parent(ff_core_Option.Option_grab(ff_core_Path.Path_parent(packageFile_))));
223
- const files_ = ff_core_List.List_partition(singleFiles_, ((_w1) => {
224
- return ff_core_Path.Path_isInsideOf(_w1, projectRoot_)
225
- }));
226
- singleFiles_ = files_.second_;
227
- return ff_compiler_Builder.PackageFiles(projectRoot_, ff_core_Option.Some(packageFile_), files_.first_)
228
- }));
229
- const singleFileProjects_ = ff_core_List.List_map(singleFiles_, ((file_) => {
230
- const projectRoot_ = ff_core_Option.Option_grab(ff_core_Path.Path_parent(file_));
231
- return ff_compiler_Builder.PackageFiles(projectRoot_, ff_core_Option.None(), ff_core_List.Link(file_, ff_core_List.Empty()))
232
- }));
233
- return ff_core_List.List_addAll(multiFileProjects_, singleFileProjects_)
234
- }
235
-
236
- export function findFireflyFiles_(path_) {
237
- const split_ = ff_core_List.List_partition(ff_core_Stream.Stream_toList(ff_core_Path.Path_entries(path_)), ((_w1) => {
238
- return ff_core_Path.PathEntry_isDirectory(_w1)
239
- }));
240
- const directories_ = ff_core_List.List_filter(ff_core_List.List_map(split_.first_, ((_w1) => {
241
- return ff_core_Path.PathEntry_path(_w1)
242
- })), ((_w1) => {
243
- return ff_core_String.String_all(ff_core_Path.Path_base(_w1), ((c_) => {
244
- return (((c_ === 46) || ff_core_Char.Char_isAsciiLower(c_)) || ff_core_Char.Char_isAsciiDigit(c_))
245
- }))
246
- }));
247
- const fireflyFiles_ = ff_core_List.List_filter(ff_core_List.List_map(split_.second_, ((_w1) => {
248
- return ff_core_Path.PathEntry_path(_w1)
249
- })), ((_w1) => {
250
- return (ff_core_Path.Path_extension(_w1) === ".ff")
251
- }));
252
- return ff_core_List.List_addAll(fireflyFiles_, ff_core_List.List_flatMap(directories_, ((_w1) => {
253
- return ff_compiler_Builder.findFireflyFiles_(_w1)
254
- })))
255
- }
256
-
257
- export function internalCreateExecutable_(self_, mainJsFile_ = ".firefly/output/executable/Main.bundle.js", outputPath_ = ".firefly/output", targets_ = ff_core_List.Link("host", ff_core_List.Empty()), assets_ = ff_core_AssetSystem.create_()) {
258
- const assetOutputPath_ = ff_core_Path.Path_slash(outputPath_, "assets");
259
- ff_core_List.List_each(ff_core_Map.Map_pairs(assets_.files_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ((_1) => {
260
- {
261
- const path_ = _1.first_;
262
- const makeStream_ = _1.second_;
263
- const p_ = ff_core_Path.Path_slash(assetOutputPath_, path_);
264
- ff_core_Path.Path_createDirectory(ff_core_Option.Option_grab(ff_core_Path.Path_parent(p_)), true);
265
- ff_core_Path.Path_writeStream(p_, makeStream_(), false)
266
- return
267
- }
268
- }));
1
+ import * as import$0 from 'pkg';
2
+
3
+ import * as ff_compiler_Builder from "../../ff/compiler/Builder.mjs"
4
+
5
+ import * as ff_compiler_Compiler from "../../ff/compiler/Compiler.mjs"
6
+
7
+ import * as ff_compiler_Dependencies from "../../ff/compiler/Dependencies.mjs"
8
+
9
+ import * as ff_compiler_JsEmitter from "../../ff/compiler/JsEmitter.mjs"
10
+
11
+ import * as ff_compiler_LspHook from "../../ff/compiler/LspHook.mjs"
12
+
13
+ import * as ff_compiler_Parser from "../../ff/compiler/Parser.mjs"
14
+
15
+ import * as ff_compiler_Resolver from "../../ff/compiler/Resolver.mjs"
16
+
17
+ import * as ff_compiler_Syntax from "../../ff/compiler/Syntax.mjs"
18
+
19
+ import * as ff_compiler_Tokenizer from "../../ff/compiler/Tokenizer.mjs"
20
+
21
+ import * as ff_compiler_Unification from "../../ff/compiler/Unification.mjs"
22
+
23
+ import * as ff_core_Any from "../../ff/core/Any.mjs"
24
+
25
+ import * as ff_core_Array from "../../ff/core/Array.mjs"
26
+
27
+ import * as ff_core_AssetSystem from "../../ff/core/AssetSystem.mjs"
28
+
29
+ import * as ff_core_Atomic from "../../ff/core/Atomic.mjs"
30
+
31
+ import * as ff_core_Bool from "../../ff/core/Bool.mjs"
32
+
33
+ import * as ff_core_Box from "../../ff/core/Box.mjs"
34
+
35
+ import * as ff_core_BrowserSystem from "../../ff/core/BrowserSystem.mjs"
36
+
37
+ import * as ff_core_Buffer from "../../ff/core/Buffer.mjs"
38
+
39
+ import * as ff_core_BuildSystem from "../../ff/core/BuildSystem.mjs"
40
+
41
+ import * as ff_core_Channel from "../../ff/core/Channel.mjs"
42
+
43
+ import * as ff_core_Char from "../../ff/core/Char.mjs"
44
+
45
+ import * as ff_core_Core from "../../ff/core/Core.mjs"
46
+
47
+ import * as ff_core_Duration from "../../ff/core/Duration.mjs"
48
+
49
+ import * as ff_core_Equal from "../../ff/core/Equal.mjs"
50
+
51
+ import * as ff_core_Error from "../../ff/core/Error.mjs"
52
+
53
+ import * as ff_core_FileHandle from "../../ff/core/FileHandle.mjs"
54
+
55
+ import * as ff_core_Float from "../../ff/core/Float.mjs"
56
+
57
+ import * as ff_core_HttpClient from "../../ff/core/HttpClient.mjs"
58
+
59
+ import * as ff_core_Instant from "../../ff/core/Instant.mjs"
60
+
61
+ import * as ff_core_Int from "../../ff/core/Int.mjs"
62
+
63
+ import * as ff_core_IntMap from "../../ff/core/IntMap.mjs"
64
+
65
+ import * as ff_core_JsSystem from "../../ff/core/JsSystem.mjs"
66
+
67
+ import * as ff_core_JsValue from "../../ff/core/JsValue.mjs"
68
+
69
+ import * as ff_core_List from "../../ff/core/List.mjs"
70
+
71
+ import * as ff_core_Lock from "../../ff/core/Lock.mjs"
72
+
73
+ import * as ff_core_Log from "../../ff/core/Log.mjs"
74
+
75
+ import * as ff_core_Map from "../../ff/core/Map.mjs"
76
+
77
+ import * as ff_core_NodeSystem from "../../ff/core/NodeSystem.mjs"
78
+
79
+ import * as ff_core_Nothing from "../../ff/core/Nothing.mjs"
80
+
81
+ import * as ff_core_Option from "../../ff/core/Option.mjs"
82
+
83
+ import * as ff_core_Ordering from "../../ff/core/Ordering.mjs"
84
+
85
+ import * as ff_core_Pair from "../../ff/core/Pair.mjs"
86
+
87
+ import * as ff_core_Path from "../../ff/core/Path.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_Stack from "../../ff/core/Stack.mjs"
100
+
101
+ import * as ff_core_Stream from "../../ff/core/Stream.mjs"
102
+
103
+ import * as ff_core_String from "../../ff/core/String.mjs"
104
+
105
+ import * as ff_core_StringMap from "../../ff/core/StringMap.mjs"
106
+
107
+ import * as ff_core_Task from "../../ff/core/Task.mjs"
108
+
109
+ import * as ff_core_Try from "../../ff/core/Try.mjs"
110
+
111
+ import * as ff_core_Unit from "../../ff/core/Unit.mjs"
112
+
113
+ import * as ff_core_WebSocket from "../../ff/core/WebSocket.mjs"
114
+
115
+ // type PackageFiles
116
+ export function PackageFiles(root_, packageFile_, files_) {
117
+ return {root_, packageFile_, files_};
118
+ }
119
+
120
+
121
+
122
+ export function build_(system_, emitTarget_, mainPackage_, mainModule_, resolvedDependencies_, compilerModulePath_, tempPath_, jsOutputPath_, printMeasurements_) {
123
+ if(ff_core_Path.Path_exists(tempPath_, false, false, false)) {
124
+ ff_core_Path.Path_delete(tempPath_, 0, 100)
125
+ };
126
+ ff_core_Path.Path_createDirectory(tempPath_, false);
127
+ const jsPathFile_ = ff_core_Path.Path_slash(tempPath_, "js");
128
+ ff_core_Path.Path_createDirectory(jsPathFile_, true);
129
+ const success_ = ff_core_Core.do_((() => {
130
+ const compiler_ = ff_compiler_Compiler.make_(emitTarget_, ff_core_NodeSystem.NodeSystem_mainTask(system_), compilerModulePath_, jsPathFile_, resolvedDependencies_, ff_core_Map.empty_(), ff_compiler_LspHook.disabled_());
131
+ ff_compiler_Compiler.Compiler_emit(compiler_, mainPackage_, mainModule_, true);
132
+ if(printMeasurements_) {
133
+ ff_compiler_Compiler.Compiler_printMeasurements(compiler_)
134
+ };
135
+ ff_core_Map.Map_each(resolvedDependencies_.packagePaths_, ((packagePair_, packagePath_) => {
136
+ ff_core_Option.Option_each(ff_core_Map.Map_get(resolvedDependencies_.packages_, packagePair_, ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair), ((packageInfo_) => {
137
+ ff_compiler_Builder.processIncludes_(jsPathFile_, packagePath_, packageInfo_)
138
+ }))
139
+ }), ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair);
140
+ return true
141
+ }));
142
+ if(success_) {
143
+ if(ff_core_Path.Path_exists(jsOutputPath_, false, false, false)) {
144
+ ff_core_Path.Path_delete(jsOutputPath_, 0, 100)
145
+ };
146
+ ff_core_Path.Path_renameTo(jsPathFile_, jsOutputPath_)
147
+ }
148
+ }
149
+
150
+ export function processIncludes_(jsPathFile_, packagePath_, info_) {
151
+ ff_core_List.List_each(info_.includes_, ((include_) => {
152
+ const fromPath_ = ff_core_Path.Path_slash(ff_core_Path.Path_slash(ff_core_Path.Path_slash(packagePath_, ".firefly"), "include"), include_.path_);
153
+ const toPath_ = ff_core_Path.Path_slash(ff_core_Path.Path_slash(jsPathFile_, ff_compiler_Syntax.PackagePair_groupName(info_.package_.packagePair_, "/")), include_.path_);
154
+ ff_core_Path.Path_copyTo(fromPath_, toPath_, 0, 100)
155
+ }))
156
+ }
157
+
158
+ export function buildViaBuildSystem_(system_, fireflyPath_, mainFile_, target_) {
159
+ const resolvedDependencies_ = ff_compiler_Dependencies.process_(ff_core_NodeSystem.NodeSystem_httpClient(system_), ff_core_NodeSystem.NodeSystem_path(system_, mainFile_));
160
+ const fixedPackagePaths_ = (ff_core_Map.Map_contains(resolvedDependencies_.packagePaths_, ff_compiler_Syntax.PackagePair("ff", "core"), ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair)
161
+ ? resolvedDependencies_.packagePaths_
162
+ : ff_core_Map.Map_add(resolvedDependencies_.packagePaths_, ff_compiler_Syntax.PackagePair("ff", "core"), ff_core_Path.Path_slash(fireflyPath_, "core"), ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair));
163
+ if((target_ !== "browser")) {
164
+ ff_core_Core.panic_("buildViaBuildSystem is currently limited to browser target only - the restriction can be lifted")
165
+ };
166
+ ff_compiler_Builder.build_(system_, ff_compiler_JsEmitter.EmitBrowser(), resolvedDependencies_.mainPackagePair_, ff_core_String.String_dropLast(mainFile_, ff_core_String.String_size(".ff")), (((_c) => {
167
+ return ff_compiler_Dependencies.ResolvedDependencies(_c.mainPackagePair_, _c.packages_, fixedPackagePaths_, _c.singleFilePackages_)
168
+ }))(resolvedDependencies_), ff_core_Option.None(), ff_core_NodeSystem.NodeSystem_path(system_, ".firefly/temporary"), ff_core_Path.Path_slash(ff_core_NodeSystem.NodeSystem_path(system_, ".firefly/output"), target_), false)
169
+ }
170
+
171
+ export function check_(system_, fireflyPath_, path_, virtualFiles_, lspHook_, infer_) {
172
+ const packages_ = (((_1) => {
173
+ {
174
+ if(_1) {
175
+ return ff_compiler_Builder.findPackageFiles_(path_)
176
+ return
177
+ }
178
+ }
179
+ {
180
+ if(!_1) {
181
+ const _guard1 = ff_core_Path.Path_endsWith(path_, ff_core_List.Link(".firefly", ff_core_List.Link("package.ff", ff_core_List.Empty())));
182
+ if(_guard1) {
183
+ return ff_core_List.Link(ff_compiler_Builder.PackageFiles(ff_core_Option.Option_grab(ff_core_Path.Path_parent(path_)), ff_core_Option.Some(path_), ff_core_List.Empty()), ff_core_List.Empty())
184
+ return
185
+ }
186
+ }
187
+ }
188
+ {
189
+ if(!_1) {
190
+ return ff_core_List.Link(ff_compiler_Builder.PackageFiles(ff_core_Option.Option_grab(ff_core_Path.Path_parent(path_)), ff_core_Option.None(), ff_core_List.Link(path_, ff_core_List.Empty())), ff_core_List.Empty())
191
+ return
192
+ }
193
+ }
194
+ }))(ff_core_Path.Path_isDirectory(path_));
195
+ ff_core_List.List_each(ff_core_List.List_filter(packages_, ((_w1) => {
196
+ return (!ff_core_List.List_isEmpty(_w1.files_))
197
+ })), ((package_) => {
198
+ const firstFile_ = ff_core_List.List_grabFirst(package_.files_);
199
+ const resolvedDependencies_ = ff_compiler_Dependencies.process_(ff_core_NodeSystem.NodeSystem_httpClient(system_), firstFile_);
200
+ const fixedPackagePaths_ = (ff_core_Map.Map_contains(resolvedDependencies_.packagePaths_, ff_compiler_Syntax.PackagePair("ff", "core"), ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair)
201
+ ? resolvedDependencies_.packagePaths_
202
+ : ff_core_Map.Map_add(resolvedDependencies_.packagePaths_, ff_compiler_Syntax.PackagePair("ff", "core"), ff_core_Path.Path_slash(fireflyPath_, "core"), ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair));
203
+ const fixedResolvedDependencies_ = (((_c) => {
204
+ return ff_compiler_Dependencies.ResolvedDependencies(_c.mainPackagePair_, _c.packages_, fixedPackagePaths_, _c.singleFilePackages_)
205
+ }))(resolvedDependencies_);
206
+ const compiler_ = ff_compiler_Compiler.make_(ff_compiler_JsEmitter.EmitBuild(), ff_core_NodeSystem.NodeSystem_mainTask(system_), ff_core_Option.None(), ff_core_Path.Path_slash(ff_core_Path.Path_slash(package_.root_, ".firefly"), "temporary"), fixedResolvedDependencies_, virtualFiles_, lspHook_);
207
+ ff_core_List.List_each(package_.files_, ((file_) => {
208
+ const localFile_ = ff_core_Path.Path_base(file_);
209
+ if(infer_) {
210
+ ff_compiler_Compiler.Compiler_infer(compiler_, resolvedDependencies_.mainPackagePair_, ff_core_String.String_dropLast(localFile_, ff_core_String.String_size(".ff")))
211
+ } else {
212
+ ff_compiler_Compiler.Compiler_resolve(compiler_, resolvedDependencies_.mainPackagePair_, ff_core_String.String_dropLast(localFile_, ff_core_String.String_size(".ff")))
213
+ }
214
+ }))
215
+ }))
216
+ }
217
+
218
+ export function findPackageFiles_(path_) {
219
+ const files_ = ff_compiler_Builder.findFireflyFiles_(path_);
220
+ const split_ = ff_core_List.List_partition(files_, ((_w1) => {
221
+ return ff_core_Path.Path_endsWith(_w1, ff_core_List.Link(".firefly", ff_core_List.Link("package.ff", ff_core_List.Empty())))
222
+ }));
223
+ const packageFiles_ = split_.first_;
224
+ let singleFiles_ = split_.second_;
225
+ const multiFileProjects_ = ff_core_List.List_map(packageFiles_, ((packageFile_) => {
226
+ const projectRoot_ = ff_core_Option.Option_grab(ff_core_Path.Path_parent(ff_core_Option.Option_grab(ff_core_Path.Path_parent(packageFile_))));
227
+ const files_ = ff_core_List.List_partition(singleFiles_, ((_w1) => {
228
+ return ff_core_Path.Path_isInsideOf(_w1, projectRoot_)
229
+ }));
230
+ singleFiles_ = files_.second_;
231
+ return ff_compiler_Builder.PackageFiles(projectRoot_, ff_core_Option.Some(packageFile_), files_.first_)
232
+ }));
233
+ const singleFileProjects_ = ff_core_List.List_map(singleFiles_, ((file_) => {
234
+ const projectRoot_ = ff_core_Option.Option_grab(ff_core_Path.Path_parent(file_));
235
+ return ff_compiler_Builder.PackageFiles(projectRoot_, ff_core_Option.None(), ff_core_List.Link(file_, ff_core_List.Empty()))
236
+ }));
237
+ return ff_core_List.List_addAll(multiFileProjects_, singleFileProjects_)
238
+ }
239
+
240
+ export function findFireflyFiles_(path_) {
241
+ const split_ = ff_core_List.List_partition(ff_core_Stream.Stream_toList(ff_core_Path.Path_entries(path_)), ((_w1) => {
242
+ return ff_core_Path.PathEntry_isDirectory(_w1)
243
+ }));
244
+ const directories_ = ff_core_List.List_filter(ff_core_List.List_map(split_.first_, ((_w1) => {
245
+ return ff_core_Path.PathEntry_path(_w1)
246
+ })), ((_w1) => {
247
+ return ff_core_String.String_all(ff_core_Path.Path_base(_w1), ((c_) => {
248
+ return (((c_ === 46) || ff_core_Char.Char_isAsciiLower(c_)) || ff_core_Char.Char_isAsciiDigit(c_))
249
+ }))
250
+ }));
251
+ const fireflyFiles_ = ff_core_List.List_filter(ff_core_List.List_map(split_.second_, ((_w1) => {
252
+ return ff_core_Path.PathEntry_path(_w1)
253
+ })), ((_w1) => {
254
+ return (ff_core_Path.Path_extension(_w1) === ".ff")
255
+ }));
256
+ return ff_core_List.List_addAll(fireflyFiles_, ff_core_List.List_flatMap(directories_, ((_w1) => {
257
+ return ff_compiler_Builder.findFireflyFiles_(_w1)
258
+ })))
259
+ }
260
+
261
+ export function internalCreateExecutable_(self_, mainJsFile_ = ".firefly/output/executable/Main.bundle.js", outputPath_ = ".firefly/output", targets_ = ff_core_List.Link("host", ff_core_List.Empty()), assets_ = ff_core_AssetSystem.create_()) {
262
+ const assetOutputPath_ = ff_core_Path.Path_slash(outputPath_, "assets");
263
+ ff_core_List.List_each(ff_core_Map.Map_pairs(assets_.files_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ((_1) => {
264
+ {
265
+ const path_ = _1.first_;
266
+ const makeStream_ = _1.second_;
267
+ const p_ = ff_core_Path.Path_slash(assetOutputPath_, path_);
268
+ ff_core_Path.Path_createDirectory(ff_core_Option.Option_grab(ff_core_Path.Path_parent(p_)), true);
269
+ ff_core_Path.Path_writeStream(p_, makeStream_(), false)
270
+ return
271
+ }
272
+ }));
269
273
  const json_ = `{
270
274
  "name": "main",
271
275
  "bin": {
@@ -284,167 +288,167 @@ const json_ = `{
284
288
  "node18-win-x64"
285
289
  ]
286
290
  }
287
- }`;
288
- const packageFile_ = ff_core_Path.Path_slash(outputPath_, "executable/package.json");
289
- ff_core_Path.Path_writeText(packageFile_, json_);
290
- ff_compiler_Builder.internalCallPkg_(self_, packageFile_, outputPath_, targets_)
291
- }
292
-
293
- export function internalCallPkg_(self_, packageFile_, outputPath_, targets_) {
294
- throw new Error('Function internalCallPkg is missing on this target in sync context.');
295
- }
296
-
297
- export async function build_$(system_, emitTarget_, mainPackage_, mainModule_, resolvedDependencies_, compilerModulePath_, tempPath_, jsOutputPath_, printMeasurements_, $task) {
298
- if((await ff_core_Path.Path_exists$(tempPath_, false, false, false, $task))) {
299
- (await ff_core_Path.Path_delete$(tempPath_, 0, 100, $task))
300
- };
301
- (await ff_core_Path.Path_createDirectory$(tempPath_, false, $task));
302
- const jsPathFile_ = (await ff_core_Path.Path_slash$(tempPath_, "js", $task));
303
- (await ff_core_Path.Path_createDirectory$(jsPathFile_, true, $task));
304
- const success_ = (await ff_core_Core.do_$((async ($task) => {
305
- const compiler_ = (await ff_compiler_Compiler.make_$(emitTarget_, (await ff_core_NodeSystem.NodeSystem_mainTask$(system_, $task)), compilerModulePath_, jsPathFile_, resolvedDependencies_, ff_core_Map.empty_(), ff_compiler_LspHook.disabled_(), $task));
306
- (await ff_compiler_Compiler.Compiler_emit$(compiler_, mainPackage_, mainModule_, true, $task));
307
- if(printMeasurements_) {
308
- (await ff_compiler_Compiler.Compiler_printMeasurements$(compiler_, $task))
309
- };
310
- (await ff_core_Map.Map_each$(resolvedDependencies_.packagePaths_, (async (packagePair_, packagePath_, $task) => {
311
- (await ff_core_Option.Option_each$(ff_core_Map.Map_get(resolvedDependencies_.packages_, packagePair_, ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair), (async (packageInfo_, $task) => {
312
- (await ff_compiler_Builder.processIncludes_$(jsPathFile_, packagePath_, packageInfo_, $task))
313
- }), $task))
314
- }), ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair, $task));
315
- return true
316
- }), $task));
317
- if(success_) {
318
- if((await ff_core_Path.Path_exists$(jsOutputPath_, false, false, false, $task))) {
319
- (await ff_core_Path.Path_delete$(jsOutputPath_, 0, 100, $task))
320
- };
321
- (await ff_core_Path.Path_renameTo$(jsPathFile_, jsOutputPath_, $task))
322
- }
323
- }
324
-
325
- export async function processIncludes_$(jsPathFile_, packagePath_, info_, $task) {
326
- (await ff_core_List.List_each$(info_.includes_, (async (include_, $task) => {
327
- const fromPath_ = (await ff_core_Path.Path_slash$((await ff_core_Path.Path_slash$((await ff_core_Path.Path_slash$(packagePath_, ".firefly", $task)), "include", $task)), include_.path_, $task));
328
- const toPath_ = (await ff_core_Path.Path_slash$((await ff_core_Path.Path_slash$(jsPathFile_, ff_compiler_Syntax.PackagePair_groupName(info_.package_.packagePair_, "/"), $task)), include_.path_, $task));
329
- (await ff_core_Path.Path_copyTo$(fromPath_, toPath_, 0, 100, $task))
330
- }), $task))
331
- }
332
-
333
- export async function buildViaBuildSystem_$(system_, fireflyPath_, mainFile_, target_, $task) {
334
- const resolvedDependencies_ = (await ff_compiler_Dependencies.process_$((await ff_core_NodeSystem.NodeSystem_httpClient$(system_, $task)), (await ff_core_NodeSystem.NodeSystem_path$(system_, mainFile_, $task)), $task));
335
- const fixedPackagePaths_ = (ff_core_Map.Map_contains(resolvedDependencies_.packagePaths_, ff_compiler_Syntax.PackagePair("ff", "core"), ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair)
336
- ? resolvedDependencies_.packagePaths_
337
- : ff_core_Map.Map_add(resolvedDependencies_.packagePaths_, ff_compiler_Syntax.PackagePair("ff", "core"), (await ff_core_Path.Path_slash$(fireflyPath_, "core", $task)), ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair));
338
- if((target_ !== "browser")) {
339
- ff_core_Core.panic_("buildViaBuildSystem is currently limited to browser target only - the restriction can be lifted")
340
- };
341
- (await ff_compiler_Builder.build_$(system_, ff_compiler_JsEmitter.EmitBrowser(), resolvedDependencies_.mainPackagePair_, ff_core_String.String_dropLast(mainFile_, ff_core_String.String_size(".ff")), (((_c) => {
342
- return ff_compiler_Dependencies.ResolvedDependencies(_c.mainPackagePair_, _c.packages_, fixedPackagePaths_, _c.singleFilePackages_)
343
- }))(resolvedDependencies_), ff_core_Option.None(), (await ff_core_NodeSystem.NodeSystem_path$(system_, ".firefly/temporary", $task)), (await ff_core_Path.Path_slash$((await ff_core_NodeSystem.NodeSystem_path$(system_, ".firefly/output", $task)), target_, $task)), false, $task))
344
- }
345
-
346
- export async function check_$(system_, fireflyPath_, path_, virtualFiles_, lspHook_, infer_, $task) {
347
- const packages_ = (await ((async (_1, $task) => {
348
- {
349
- if(_1) {
350
- return (await ff_compiler_Builder.findPackageFiles_$(path_, $task))
351
- return
352
- }
353
- }
354
- {
355
- if(!_1) {
356
- const _guard1 = (await ff_core_Path.Path_endsWith$(path_, ff_core_List.Link(".firefly", ff_core_List.Link("package.ff", ff_core_List.Empty())), $task));
357
- if(_guard1) {
358
- return ff_core_List.Link(ff_compiler_Builder.PackageFiles(ff_core_Option.Option_grab((await ff_core_Path.Path_parent$(path_, $task))), ff_core_Option.Some(path_), ff_core_List.Empty()), ff_core_List.Empty())
359
- return
360
- }
361
- }
362
- }
363
- {
364
- if(!_1) {
365
- return ff_core_List.Link(ff_compiler_Builder.PackageFiles(ff_core_Option.Option_grab((await ff_core_Path.Path_parent$(path_, $task))), ff_core_Option.None(), ff_core_List.Link(path_, ff_core_List.Empty())), ff_core_List.Empty())
366
- return
367
- }
368
- }
369
- }))((await ff_core_Path.Path_isDirectory$(path_, $task)), $task));
370
- (await ff_core_List.List_each$(ff_core_List.List_filter(packages_, ((_w1) => {
371
- return (!ff_core_List.List_isEmpty(_w1.files_))
372
- })), (async (package_, $task) => {
373
- const firstFile_ = ff_core_List.List_grabFirst(package_.files_);
374
- const resolvedDependencies_ = (await ff_compiler_Dependencies.process_$((await ff_core_NodeSystem.NodeSystem_httpClient$(system_, $task)), firstFile_, $task));
375
- const fixedPackagePaths_ = (ff_core_Map.Map_contains(resolvedDependencies_.packagePaths_, ff_compiler_Syntax.PackagePair("ff", "core"), ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair)
376
- ? resolvedDependencies_.packagePaths_
377
- : ff_core_Map.Map_add(resolvedDependencies_.packagePaths_, ff_compiler_Syntax.PackagePair("ff", "core"), (await ff_core_Path.Path_slash$(fireflyPath_, "core", $task)), ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair));
378
- const fixedResolvedDependencies_ = (((_c) => {
379
- return ff_compiler_Dependencies.ResolvedDependencies(_c.mainPackagePair_, _c.packages_, fixedPackagePaths_, _c.singleFilePackages_)
380
- }))(resolvedDependencies_);
381
- const compiler_ = (await ff_compiler_Compiler.make_$(ff_compiler_JsEmitter.EmitBuild(), (await ff_core_NodeSystem.NodeSystem_mainTask$(system_, $task)), ff_core_Option.None(), (await ff_core_Path.Path_slash$((await ff_core_Path.Path_slash$(package_.root_, ".firefly", $task)), "temporary", $task)), fixedResolvedDependencies_, virtualFiles_, lspHook_, $task));
382
- (await ff_core_List.List_each$(package_.files_, (async (file_, $task) => {
383
- const localFile_ = (await ff_core_Path.Path_base$(file_, $task));
384
- if(infer_) {
385
- (await ff_compiler_Compiler.Compiler_infer$(compiler_, resolvedDependencies_.mainPackagePair_, ff_core_String.String_dropLast(localFile_, ff_core_String.String_size(".ff")), $task))
386
- } else {
387
- (await ff_compiler_Compiler.Compiler_resolve$(compiler_, resolvedDependencies_.mainPackagePair_, ff_core_String.String_dropLast(localFile_, ff_core_String.String_size(".ff")), $task))
388
- }
389
- }), $task))
390
- }), $task))
391
- }
392
-
393
- export async function findPackageFiles_$(path_, $task) {
394
- const files_ = (await ff_compiler_Builder.findFireflyFiles_$(path_, $task));
395
- const split_ = (await ff_core_List.List_partition$(files_, (async (_w1, $task) => {
396
- return (await ff_core_Path.Path_endsWith$(_w1, ff_core_List.Link(".firefly", ff_core_List.Link("package.ff", ff_core_List.Empty())), $task))
397
- }), $task));
398
- const packageFiles_ = split_.first_;
399
- let singleFiles_ = split_.second_;
400
- const multiFileProjects_ = (await ff_core_List.List_map$(packageFiles_, (async (packageFile_, $task) => {
401
- const projectRoot_ = ff_core_Option.Option_grab((await ff_core_Path.Path_parent$(ff_core_Option.Option_grab((await ff_core_Path.Path_parent$(packageFile_, $task))), $task)));
402
- const files_ = (await ff_core_List.List_partition$(singleFiles_, (async (_w1, $task) => {
403
- return (await ff_core_Path.Path_isInsideOf$(_w1, projectRoot_, $task))
404
- }), $task));
405
- singleFiles_ = files_.second_;
406
- return ff_compiler_Builder.PackageFiles(projectRoot_, ff_core_Option.Some(packageFile_), files_.first_)
407
- }), $task));
408
- const singleFileProjects_ = (await ff_core_List.List_map$(singleFiles_, (async (file_, $task) => {
409
- const projectRoot_ = ff_core_Option.Option_grab((await ff_core_Path.Path_parent$(file_, $task)));
410
- return ff_compiler_Builder.PackageFiles(projectRoot_, ff_core_Option.None(), ff_core_List.Link(file_, ff_core_List.Empty()))
411
- }), $task));
412
- return ff_core_List.List_addAll(multiFileProjects_, singleFileProjects_)
413
- }
414
-
415
- export async function findFireflyFiles_$(path_, $task) {
416
- const split_ = (await ff_core_List.List_partition$((await ff_core_Stream.Stream_toList$((await ff_core_Path.Path_entries$(path_, $task)), $task)), (async (_w1, $task) => {
417
- return (await ff_core_Path.PathEntry_isDirectory$(_w1, $task))
418
- }), $task));
419
- const directories_ = (await ff_core_List.List_filter$((await ff_core_List.List_map$(split_.first_, (async (_w1, $task) => {
420
- return (await ff_core_Path.PathEntry_path$(_w1, $task))
421
- }), $task)), (async (_w1, $task) => {
422
- return ff_core_String.String_all((await ff_core_Path.Path_base$(_w1, $task)), ((c_) => {
423
- return (((c_ === 46) || ff_core_Char.Char_isAsciiLower(c_)) || ff_core_Char.Char_isAsciiDigit(c_))
424
- }))
425
- }), $task));
426
- const fireflyFiles_ = (await ff_core_List.List_filter$((await ff_core_List.List_map$(split_.second_, (async (_w1, $task) => {
427
- return (await ff_core_Path.PathEntry_path$(_w1, $task))
428
- }), $task)), (async (_w1, $task) => {
429
- return ((await ff_core_Path.Path_extension$(_w1, $task)) === ".ff")
430
- }), $task));
431
- return ff_core_List.List_addAll(fireflyFiles_, (await ff_core_List.List_flatMap$(directories_, (async (_w1, $task) => {
432
- return (await ff_compiler_Builder.findFireflyFiles_$(_w1, $task))
433
- }), $task)))
434
- }
435
-
436
- export async function internalCreateExecutable_$(self_, mainJsFile_ = ".firefly/output/executable/Main.bundle.js", outputPath_ = ".firefly/output", targets_ = ff_core_List.Link("host", ff_core_List.Empty()), assets_ = ff_core_AssetSystem.create_(), $task) {
437
- const assetOutputPath_ = (await ff_core_Path.Path_slash$(outputPath_, "assets", $task));
438
- (await ff_core_List.List_each$(ff_core_Map.Map_pairs(assets_.files_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (async (_1, $task) => {
439
- {
440
- const path_ = _1.first_;
441
- const makeStream_ = _1.second_;
442
- const p_ = (await ff_core_Path.Path_slash$(assetOutputPath_, path_, $task));
443
- (await ff_core_Path.Path_createDirectory$(ff_core_Option.Option_grab((await ff_core_Path.Path_parent$(p_, $task))), true, $task));
444
- (await ff_core_Path.Path_writeStream$(p_, (await makeStream_($task)), false, $task))
445
- return
446
- }
447
- }), $task));
291
+ }`;
292
+ const packageFile_ = ff_core_Path.Path_slash(outputPath_, "executable/package.json");
293
+ ff_core_Path.Path_writeText(packageFile_, json_);
294
+ ff_compiler_Builder.internalCallPkg_(self_, packageFile_, outputPath_, targets_)
295
+ }
296
+
297
+ export function internalCallPkg_(self_, packageFile_, outputPath_, targets_) {
298
+ throw new Error('Function internalCallPkg is missing on this target in sync context.');
299
+ }
300
+
301
+ export async function build_$(system_, emitTarget_, mainPackage_, mainModule_, resolvedDependencies_, compilerModulePath_, tempPath_, jsOutputPath_, printMeasurements_, $task) {
302
+ if((await ff_core_Path.Path_exists$(tempPath_, false, false, false, $task))) {
303
+ (await ff_core_Path.Path_delete$(tempPath_, 0, 100, $task))
304
+ };
305
+ (await ff_core_Path.Path_createDirectory$(tempPath_, false, $task));
306
+ const jsPathFile_ = (await ff_core_Path.Path_slash$(tempPath_, "js", $task));
307
+ (await ff_core_Path.Path_createDirectory$(jsPathFile_, true, $task));
308
+ const success_ = (await ff_core_Core.do_$((async ($task) => {
309
+ const compiler_ = (await ff_compiler_Compiler.make_$(emitTarget_, (await ff_core_NodeSystem.NodeSystem_mainTask$(system_, $task)), compilerModulePath_, jsPathFile_, resolvedDependencies_, ff_core_Map.empty_(), ff_compiler_LspHook.disabled_(), $task));
310
+ (await ff_compiler_Compiler.Compiler_emit$(compiler_, mainPackage_, mainModule_, true, $task));
311
+ if(printMeasurements_) {
312
+ (await ff_compiler_Compiler.Compiler_printMeasurements$(compiler_, $task))
313
+ };
314
+ (await ff_core_Map.Map_each$(resolvedDependencies_.packagePaths_, (async (packagePair_, packagePath_, $task) => {
315
+ (await ff_core_Option.Option_each$(ff_core_Map.Map_get(resolvedDependencies_.packages_, packagePair_, ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair), (async (packageInfo_, $task) => {
316
+ (await ff_compiler_Builder.processIncludes_$(jsPathFile_, packagePath_, packageInfo_, $task))
317
+ }), $task))
318
+ }), ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair, $task));
319
+ return true
320
+ }), $task));
321
+ if(success_) {
322
+ if((await ff_core_Path.Path_exists$(jsOutputPath_, false, false, false, $task))) {
323
+ (await ff_core_Path.Path_delete$(jsOutputPath_, 0, 100, $task))
324
+ };
325
+ (await ff_core_Path.Path_renameTo$(jsPathFile_, jsOutputPath_, $task))
326
+ }
327
+ }
328
+
329
+ export async function processIncludes_$(jsPathFile_, packagePath_, info_, $task) {
330
+ (await ff_core_List.List_each$(info_.includes_, (async (include_, $task) => {
331
+ const fromPath_ = (await ff_core_Path.Path_slash$((await ff_core_Path.Path_slash$((await ff_core_Path.Path_slash$(packagePath_, ".firefly", $task)), "include", $task)), include_.path_, $task));
332
+ const toPath_ = (await ff_core_Path.Path_slash$((await ff_core_Path.Path_slash$(jsPathFile_, ff_compiler_Syntax.PackagePair_groupName(info_.package_.packagePair_, "/"), $task)), include_.path_, $task));
333
+ (await ff_core_Path.Path_copyTo$(fromPath_, toPath_, 0, 100, $task))
334
+ }), $task))
335
+ }
336
+
337
+ export async function buildViaBuildSystem_$(system_, fireflyPath_, mainFile_, target_, $task) {
338
+ const resolvedDependencies_ = (await ff_compiler_Dependencies.process_$((await ff_core_NodeSystem.NodeSystem_httpClient$(system_, $task)), (await ff_core_NodeSystem.NodeSystem_path$(system_, mainFile_, $task)), $task));
339
+ const fixedPackagePaths_ = (ff_core_Map.Map_contains(resolvedDependencies_.packagePaths_, ff_compiler_Syntax.PackagePair("ff", "core"), ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair)
340
+ ? resolvedDependencies_.packagePaths_
341
+ : ff_core_Map.Map_add(resolvedDependencies_.packagePaths_, ff_compiler_Syntax.PackagePair("ff", "core"), (await ff_core_Path.Path_slash$(fireflyPath_, "core", $task)), ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair));
342
+ if((target_ !== "browser")) {
343
+ ff_core_Core.panic_("buildViaBuildSystem is currently limited to browser target only - the restriction can be lifted")
344
+ };
345
+ (await ff_compiler_Builder.build_$(system_, ff_compiler_JsEmitter.EmitBrowser(), resolvedDependencies_.mainPackagePair_, ff_core_String.String_dropLast(mainFile_, ff_core_String.String_size(".ff")), (((_c) => {
346
+ return ff_compiler_Dependencies.ResolvedDependencies(_c.mainPackagePair_, _c.packages_, fixedPackagePaths_, _c.singleFilePackages_)
347
+ }))(resolvedDependencies_), ff_core_Option.None(), (await ff_core_NodeSystem.NodeSystem_path$(system_, ".firefly/temporary", $task)), (await ff_core_Path.Path_slash$((await ff_core_NodeSystem.NodeSystem_path$(system_, ".firefly/output", $task)), target_, $task)), false, $task))
348
+ }
349
+
350
+ export async function check_$(system_, fireflyPath_, path_, virtualFiles_, lspHook_, infer_, $task) {
351
+ const packages_ = (await ((async (_1, $task) => {
352
+ {
353
+ if(_1) {
354
+ return (await ff_compiler_Builder.findPackageFiles_$(path_, $task))
355
+ return
356
+ }
357
+ }
358
+ {
359
+ if(!_1) {
360
+ const _guard1 = (await ff_core_Path.Path_endsWith$(path_, ff_core_List.Link(".firefly", ff_core_List.Link("package.ff", ff_core_List.Empty())), $task));
361
+ if(_guard1) {
362
+ return ff_core_List.Link(ff_compiler_Builder.PackageFiles(ff_core_Option.Option_grab((await ff_core_Path.Path_parent$(path_, $task))), ff_core_Option.Some(path_), ff_core_List.Empty()), ff_core_List.Empty())
363
+ return
364
+ }
365
+ }
366
+ }
367
+ {
368
+ if(!_1) {
369
+ return ff_core_List.Link(ff_compiler_Builder.PackageFiles(ff_core_Option.Option_grab((await ff_core_Path.Path_parent$(path_, $task))), ff_core_Option.None(), ff_core_List.Link(path_, ff_core_List.Empty())), ff_core_List.Empty())
370
+ return
371
+ }
372
+ }
373
+ }))((await ff_core_Path.Path_isDirectory$(path_, $task)), $task));
374
+ (await ff_core_List.List_each$(ff_core_List.List_filter(packages_, ((_w1) => {
375
+ return (!ff_core_List.List_isEmpty(_w1.files_))
376
+ })), (async (package_, $task) => {
377
+ const firstFile_ = ff_core_List.List_grabFirst(package_.files_);
378
+ const resolvedDependencies_ = (await ff_compiler_Dependencies.process_$((await ff_core_NodeSystem.NodeSystem_httpClient$(system_, $task)), firstFile_, $task));
379
+ const fixedPackagePaths_ = (ff_core_Map.Map_contains(resolvedDependencies_.packagePaths_, ff_compiler_Syntax.PackagePair("ff", "core"), ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair)
380
+ ? resolvedDependencies_.packagePaths_
381
+ : ff_core_Map.Map_add(resolvedDependencies_.packagePaths_, ff_compiler_Syntax.PackagePair("ff", "core"), (await ff_core_Path.Path_slash$(fireflyPath_, "core", $task)), ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair));
382
+ const fixedResolvedDependencies_ = (((_c) => {
383
+ return ff_compiler_Dependencies.ResolvedDependencies(_c.mainPackagePair_, _c.packages_, fixedPackagePaths_, _c.singleFilePackages_)
384
+ }))(resolvedDependencies_);
385
+ const compiler_ = (await ff_compiler_Compiler.make_$(ff_compiler_JsEmitter.EmitBuild(), (await ff_core_NodeSystem.NodeSystem_mainTask$(system_, $task)), ff_core_Option.None(), (await ff_core_Path.Path_slash$((await ff_core_Path.Path_slash$(package_.root_, ".firefly", $task)), "temporary", $task)), fixedResolvedDependencies_, virtualFiles_, lspHook_, $task));
386
+ (await ff_core_List.List_each$(package_.files_, (async (file_, $task) => {
387
+ const localFile_ = (await ff_core_Path.Path_base$(file_, $task));
388
+ if(infer_) {
389
+ (await ff_compiler_Compiler.Compiler_infer$(compiler_, resolvedDependencies_.mainPackagePair_, ff_core_String.String_dropLast(localFile_, ff_core_String.String_size(".ff")), $task))
390
+ } else {
391
+ (await ff_compiler_Compiler.Compiler_resolve$(compiler_, resolvedDependencies_.mainPackagePair_, ff_core_String.String_dropLast(localFile_, ff_core_String.String_size(".ff")), $task))
392
+ }
393
+ }), $task))
394
+ }), $task))
395
+ }
396
+
397
+ export async function findPackageFiles_$(path_, $task) {
398
+ const files_ = (await ff_compiler_Builder.findFireflyFiles_$(path_, $task));
399
+ const split_ = (await ff_core_List.List_partition$(files_, (async (_w1, $task) => {
400
+ return (await ff_core_Path.Path_endsWith$(_w1, ff_core_List.Link(".firefly", ff_core_List.Link("package.ff", ff_core_List.Empty())), $task))
401
+ }), $task));
402
+ const packageFiles_ = split_.first_;
403
+ let singleFiles_ = split_.second_;
404
+ const multiFileProjects_ = (await ff_core_List.List_map$(packageFiles_, (async (packageFile_, $task) => {
405
+ const projectRoot_ = ff_core_Option.Option_grab((await ff_core_Path.Path_parent$(ff_core_Option.Option_grab((await ff_core_Path.Path_parent$(packageFile_, $task))), $task)));
406
+ const files_ = (await ff_core_List.List_partition$(singleFiles_, (async (_w1, $task) => {
407
+ return (await ff_core_Path.Path_isInsideOf$(_w1, projectRoot_, $task))
408
+ }), $task));
409
+ singleFiles_ = files_.second_;
410
+ return ff_compiler_Builder.PackageFiles(projectRoot_, ff_core_Option.Some(packageFile_), files_.first_)
411
+ }), $task));
412
+ const singleFileProjects_ = (await ff_core_List.List_map$(singleFiles_, (async (file_, $task) => {
413
+ const projectRoot_ = ff_core_Option.Option_grab((await ff_core_Path.Path_parent$(file_, $task)));
414
+ return ff_compiler_Builder.PackageFiles(projectRoot_, ff_core_Option.None(), ff_core_List.Link(file_, ff_core_List.Empty()))
415
+ }), $task));
416
+ return ff_core_List.List_addAll(multiFileProjects_, singleFileProjects_)
417
+ }
418
+
419
+ export async function findFireflyFiles_$(path_, $task) {
420
+ const split_ = (await ff_core_List.List_partition$((await ff_core_Stream.Stream_toList$((await ff_core_Path.Path_entries$(path_, $task)), $task)), (async (_w1, $task) => {
421
+ return (await ff_core_Path.PathEntry_isDirectory$(_w1, $task))
422
+ }), $task));
423
+ const directories_ = (await ff_core_List.List_filter$((await ff_core_List.List_map$(split_.first_, (async (_w1, $task) => {
424
+ return (await ff_core_Path.PathEntry_path$(_w1, $task))
425
+ }), $task)), (async (_w1, $task) => {
426
+ return ff_core_String.String_all((await ff_core_Path.Path_base$(_w1, $task)), ((c_) => {
427
+ return (((c_ === 46) || ff_core_Char.Char_isAsciiLower(c_)) || ff_core_Char.Char_isAsciiDigit(c_))
428
+ }))
429
+ }), $task));
430
+ const fireflyFiles_ = (await ff_core_List.List_filter$((await ff_core_List.List_map$(split_.second_, (async (_w1, $task) => {
431
+ return (await ff_core_Path.PathEntry_path$(_w1, $task))
432
+ }), $task)), (async (_w1, $task) => {
433
+ return ((await ff_core_Path.Path_extension$(_w1, $task)) === ".ff")
434
+ }), $task));
435
+ return ff_core_List.List_addAll(fireflyFiles_, (await ff_core_List.List_flatMap$(directories_, (async (_w1, $task) => {
436
+ return (await ff_compiler_Builder.findFireflyFiles_$(_w1, $task))
437
+ }), $task)))
438
+ }
439
+
440
+ export async function internalCreateExecutable_$(self_, mainJsFile_ = ".firefly/output/executable/Main.bundle.js", outputPath_ = ".firefly/output", targets_ = ff_core_List.Link("host", ff_core_List.Empty()), assets_ = ff_core_AssetSystem.create_(), $task) {
441
+ const assetOutputPath_ = (await ff_core_Path.Path_slash$(outputPath_, "assets", $task));
442
+ (await ff_core_List.List_each$(ff_core_Map.Map_pairs(assets_.files_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), (async (_1, $task) => {
443
+ {
444
+ const path_ = _1.first_;
445
+ const makeStream_ = _1.second_;
446
+ const p_ = (await ff_core_Path.Path_slash$(assetOutputPath_, path_, $task));
447
+ (await ff_core_Path.Path_createDirectory$(ff_core_Option.Option_grab((await ff_core_Path.Path_parent$(p_, $task))), true, $task));
448
+ (await ff_core_Path.Path_writeStream$(p_, (await makeStream_($task)), false, $task))
449
+ return
450
+ }
451
+ }), $task));
448
452
  const json_ = `{
449
453
  "name": "main",
450
454
  "bin": {
@@ -463,13 +467,13 @@ const json_ = `{
463
467
  "node18-win-x64"
464
468
  ]
465
469
  }
466
- }`;
467
- const packageFile_ = (await ff_core_Path.Path_slash$(outputPath_, "executable/package.json", $task));
468
- (await ff_core_Path.Path_writeText$(packageFile_, json_, $task));
469
- (await ff_compiler_Builder.internalCallPkg_$(self_, packageFile_, outputPath_, targets_, $task))
470
- }
471
-
472
- export async function internalCallPkg_$(self_, packageFile_, outputPath_, targets_, $task) {
470
+ }`;
471
+ const packageFile_ = (await ff_core_Path.Path_slash$(outputPath_, "executable/package.json", $task));
472
+ (await ff_core_Path.Path_writeText$(packageFile_, json_, $task));
473
+ (await ff_compiler_Builder.internalCallPkg_$(self_, packageFile_, outputPath_, targets_, $task))
474
+ }
475
+
476
+ export async function internalCallPkg_$(self_, packageFile_, outputPath_, targets_, $task) {
473
477
 
474
478
  const pkg = import$0
475
479
  return await pkg.exec([
@@ -477,11 +481,11 @@ export async function internalCallPkg_$(self_, packageFile_, outputPath_, target
477
481
  '--out-path', outputPath_,
478
482
  '--target', ff_core_List.List_toArray(targets_).join(',')
479
483
  ])
480
-
481
- }
482
-
483
-
484
-
485
-
486
-
487
-
484
+
485
+ }
486
+
487
+
488
+
489
+
490
+
491
+