firefly-compiler 0.4.4

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 (221) hide show
  1. package/.firefly-workspace +1 -0
  2. package/.vscode/settings.json +5 -0
  3. package/LICENSE.txt +21 -0
  4. package/README.md +96 -0
  5. package/bin/firefly.mjs +2 -0
  6. package/compiler/.firefly/package.ff +1 -0
  7. package/compiler/Builder.ff +218 -0
  8. package/compiler/Compiler.ff +241 -0
  9. package/compiler/Dependencies.ff +179 -0
  10. package/compiler/Deriver.ff +647 -0
  11. package/compiler/Dictionaries.ff +205 -0
  12. package/compiler/Environment.ff +166 -0
  13. package/compiler/Inference.ff +1117 -0
  14. package/compiler/JsEmitter.ff +861 -0
  15. package/compiler/JsImporter.ff +56 -0
  16. package/compiler/LspHook.ff +188 -0
  17. package/compiler/Main.ff +237 -0
  18. package/compiler/Parser.ff +1383 -0
  19. package/compiler/Patterns.ff +111 -0
  20. package/compiler/Resolver.ff +620 -0
  21. package/compiler/Substitution.ff +178 -0
  22. package/compiler/Syntax.ff +299 -0
  23. package/compiler/Token.ff +180 -0
  24. package/compiler/Tokenizer.ff +278 -0
  25. package/compiler/Unification.ff +220 -0
  26. package/compiler/Wildcards.ff +50 -0
  27. package/compiler/Workspace.ff +88 -0
  28. package/core/.firefly/package.ff +2 -0
  29. package/core/Any.ff +30 -0
  30. package/core/Array.ff +249 -0
  31. package/core/AssetSystem.ff +61 -0
  32. package/core/Atomic.ff +64 -0
  33. package/core/Bool.ff +13 -0
  34. package/core/BrowserSystem.ff +14 -0
  35. package/core/Buffer.ff +211 -0
  36. package/core/BuildSystem.ff +144 -0
  37. package/core/Channel.ff +131 -0
  38. package/core/Char.ff +18 -0
  39. package/core/Core.ff +58 -0
  40. package/core/Duration.ff +15 -0
  41. package/core/Equal.ff +52 -0
  42. package/core/Error.ff +20 -0
  43. package/core/FileHandle.ff +41 -0
  44. package/core/Float.ff +41 -0
  45. package/core/HttpClient.ff +84 -0
  46. package/core/Instant.ff +9 -0
  47. package/core/Int.ff +61 -0
  48. package/core/IntMap.ff +85 -0
  49. package/core/JsSystem.ff +66 -0
  50. package/core/JsValue.ff +240 -0
  51. package/core/List.ff +440 -0
  52. package/core/Lock.ff +144 -0
  53. package/core/Log.ff +24 -0
  54. package/core/Map.ff +126 -0
  55. package/core/NodeSystem.ff +88 -0
  56. package/core/Nothing.ff +1 -0
  57. package/core/Option.ff +133 -0
  58. package/core/Ordering.ff +157 -0
  59. package/core/Pair.ff +55 -0
  60. package/core/Path.ff +393 -0
  61. package/core/RbMap.ff +216 -0
  62. package/core/Serializable.ff +173 -0
  63. package/core/Set.ff +38 -0
  64. package/core/Show.ff +43 -0
  65. package/core/Stack.ff +263 -0
  66. package/core/Stream.ff +406 -0
  67. package/core/String.ff +175 -0
  68. package/core/StringMap.ff +85 -0
  69. package/core/Task.ff +138 -0
  70. package/core/Try.ff +81 -0
  71. package/core/Unit.ff +3 -0
  72. package/experimental/random/AltGeneric.ff +44 -0
  73. package/experimental/random/Async.ff +68 -0
  74. package/experimental/random/Buffer2.ff +77 -0
  75. package/experimental/random/Cat.ff +12 -0
  76. package/experimental/random/Dictionary.ff +52 -0
  77. package/experimental/random/Example.ff +46 -0
  78. package/experimental/random/Generic.ff +102 -0
  79. package/experimental/random/HappyEyeballs.ff +40 -0
  80. package/experimental/random/HashMap.ff +72 -0
  81. package/experimental/random/IfElseUnit.ff +9 -0
  82. package/experimental/random/InputOutput.ff +23 -0
  83. package/experimental/random/ListVsArray.ff +45 -0
  84. package/experimental/random/Main.ff +44 -0
  85. package/experimental/random/MapTest.ff +67 -0
  86. package/experimental/random/OldTaskSystem.ff +210 -0
  87. package/experimental/random/PatternTest.ff +39 -0
  88. package/experimental/random/Patterns.ff +226 -0
  89. package/experimental/random/ReadBytesTest.ff +10 -0
  90. package/experimental/random/RunLength.ff +65 -0
  91. package/experimental/random/Scrape.ff +51 -0
  92. package/experimental/random/Serialization.ff +217 -0
  93. package/experimental/random/SerializationTest.ff +46 -0
  94. package/experimental/random/Serializer.ff +36 -0
  95. package/experimental/random/StdInOutErr.ff +4 -0
  96. package/experimental/random/Symbols.ff +74 -0
  97. package/experimental/random/Tag.ff +49 -0
  98. package/experimental/random/Tensor.ff +52 -0
  99. package/experimental/random/Try.ff +56 -0
  100. package/experimental/random/Tsv.ff +9 -0
  101. package/experimental/random/TypesAreModules.ff +87 -0
  102. package/experimental/random/blueprints/Blueprint.ff +52 -0
  103. package/experimental/random/blueprints/Main.ff +11 -0
  104. package/experimental/random/blueprints/Pretty.ff +58 -0
  105. package/experimental/random/blueprints/User.ff +64 -0
  106. package/experimental/random/blueprintsystem/BlueprintSystem.ff +48 -0
  107. package/experimental/random/blueprintsystem/Deserialize.ff +53 -0
  108. package/experimental/random/blueprintsystem/ReadJs.ff +13 -0
  109. package/experimental/random/blueprintsystem/User.ff +2 -0
  110. package/experimental/random/kahrs/Kahrs.ff +112 -0
  111. package/experimental/random/kahrs/TestKahrs.ff +22 -0
  112. package/experimental/random/kahrs/TestMap.ff +18 -0
  113. package/experimental/random/streaming/Gzip.ff +3 -0
  114. package/experimental/random/streaming/Main.ff +34 -0
  115. package/experimental/random/streaming/S3Bucket.ff +11 -0
  116. package/experimental/random/streaming/Tar.ff +5 -0
  117. package/experimental/rhymeapp/Main.ff +81 -0
  118. package/experimental/rhymeapp/index.html +14 -0
  119. package/firefly.sh +5 -0
  120. package/fireflysite/Main.ff +13 -0
  121. package/httpserver/.firefly/package.ff +1 -0
  122. package/httpserver/HttpServer.ff +184 -0
  123. package/lsp/.firefly/package.ff +1 -0
  124. package/lsp/CompletionHandler.ff +814 -0
  125. package/lsp/Handler.ff +551 -0
  126. package/lsp/HoverHandler.ff +82 -0
  127. package/lsp/LanguageServer.ff +229 -0
  128. package/lsp/SignatureHelpHandler.ff +55 -0
  129. package/lsp/SymbolHandler.ff +167 -0
  130. package/output/js/ff/compiler/Builder.mjs +483 -0
  131. package/output/js/ff/compiler/Compiler.mjs +410 -0
  132. package/output/js/ff/compiler/Dependencies.mjs +388 -0
  133. package/output/js/ff/compiler/Deriver.mjs +1166 -0
  134. package/output/js/ff/compiler/Dictionaries.mjs +1305 -0
  135. package/output/js/ff/compiler/Environment.mjs +1005 -0
  136. package/output/js/ff/compiler/Inference.mjs +4264 -0
  137. package/output/js/ff/compiler/JsEmitter.mjs +5353 -0
  138. package/output/js/ff/compiler/JsImporter.mjs +262 -0
  139. package/output/js/ff/compiler/LspHook.mjs +789 -0
  140. package/output/js/ff/compiler/Main.mjs +1695 -0
  141. package/output/js/ff/compiler/Parser.mjs +4004 -0
  142. package/output/js/ff/compiler/Patterns.mjs +923 -0
  143. package/output/js/ff/compiler/Resolver.mjs +2303 -0
  144. package/output/js/ff/compiler/Substitution.mjs +1146 -0
  145. package/output/js/ff/compiler/Syntax.mjs +12430 -0
  146. package/output/js/ff/compiler/Token.mjs +3092 -0
  147. package/output/js/ff/compiler/Tokenizer.mjs +589 -0
  148. package/output/js/ff/compiler/Unification.mjs +1748 -0
  149. package/output/js/ff/compiler/Wildcards.mjs +604 -0
  150. package/output/js/ff/compiler/Workspace.mjs +683 -0
  151. package/output/js/ff/core/Any.mjs +139 -0
  152. package/output/js/ff/core/Array.mjs +594 -0
  153. package/output/js/ff/core/AssetSystem.mjs +270 -0
  154. package/output/js/ff/core/Atomic.mjs +186 -0
  155. package/output/js/ff/core/Bool.mjs +141 -0
  156. package/output/js/ff/core/BrowserSystem.mjs +122 -0
  157. package/output/js/ff/core/Buffer.mjs +467 -0
  158. package/output/js/ff/core/BuildSystem.mjs +320 -0
  159. package/output/js/ff/core/Channel.mjs +268 -0
  160. package/output/js/ff/core/Char.mjs +145 -0
  161. package/output/js/ff/core/Core.mjs +300 -0
  162. package/output/js/ff/core/Duration.mjs +112 -0
  163. package/output/js/ff/core/Equal.mjs +175 -0
  164. package/output/js/ff/core/Error.mjs +138 -0
  165. package/output/js/ff/core/FileHandle.mjs +164 -0
  166. package/output/js/ff/core/Float.mjs +214 -0
  167. package/output/js/ff/core/HttpClient.mjs +210 -0
  168. package/output/js/ff/core/Instant.mjs +105 -0
  169. package/output/js/ff/core/Int.mjs +254 -0
  170. package/output/js/ff/core/IntMap.mjs +282 -0
  171. package/output/js/ff/core/JsSystem.mjs +234 -0
  172. package/output/js/ff/core/JsValue.mjs +678 -0
  173. package/output/js/ff/core/List.mjs +2335 -0
  174. package/output/js/ff/core/Lock.mjs +322 -0
  175. package/output/js/ff/core/Log.mjs +159 -0
  176. package/output/js/ff/core/Map.mjs +358 -0
  177. package/output/js/ff/core/NodeSystem.mjs +288 -0
  178. package/output/js/ff/core/Nothing.mjs +100 -0
  179. package/output/js/ff/core/Option.mjs +1002 -0
  180. package/output/js/ff/core/Ordering.mjs +734 -0
  181. package/output/js/ff/core/Pair.mjs +318 -0
  182. package/output/js/ff/core/Path.mjs +768 -0
  183. package/output/js/ff/core/RbMap.mjs +1936 -0
  184. package/output/js/ff/core/Serializable.mjs +434 -0
  185. package/output/js/ff/core/Set.mjs +250 -0
  186. package/output/js/ff/core/Show.mjs +201 -0
  187. package/output/js/ff/core/Stack.mjs +595 -0
  188. package/output/js/ff/core/Stream.mjs +1300 -0
  189. package/output/js/ff/core/String.mjs +433 -0
  190. package/output/js/ff/core/StringMap.mjs +282 -0
  191. package/output/js/ff/core/Task.mjs +345 -0
  192. package/output/js/ff/core/Try.mjs +503 -0
  193. package/output/js/ff/core/Unit.mjs +103 -0
  194. package/package.json +29 -0
  195. package/postgresql/.firefly/include/package-lock.json +250 -0
  196. package/postgresql/.firefly/include/package.json +5 -0
  197. package/postgresql/.firefly/include/prepare.sh +2 -0
  198. package/postgresql/.firefly/package.ff +3 -0
  199. package/postgresql/Pg.ff +530 -0
  200. package/unsafejs/.firefly/package.ff +1 -0
  201. package/unsafejs/UnsafeJs.ff +19 -0
  202. package/vscode/.vscode/launch.json +18 -0
  203. package/vscode/.vscode/tasks.json +33 -0
  204. package/vscode/LICENSE.txt +21 -0
  205. package/vscode/Prepublish.ff +15 -0
  206. package/vscode/README.md +17 -0
  207. package/vscode/client/package-lock.json +544 -0
  208. package/vscode/client/package.json +22 -0
  209. package/vscode/client/src/extension.ts +64 -0
  210. package/vscode/client/tsconfig.json +12 -0
  211. package/vscode/icons/firefly-icon.png +0 -0
  212. package/vscode/icons/firefly-icon.svg +10 -0
  213. package/vscode/icons/firefly-logo-notext.png +0 -0
  214. package/vscode/icons/firefly-logo.png +0 -0
  215. package/vscode/language-configuration.json +39 -0
  216. package/vscode/package-lock.json +3623 -0
  217. package/vscode/package.json +144 -0
  218. package/vscode/snippets-none.json +1 -0
  219. package/vscode/snippets.json +241 -0
  220. package/vscode/syntaxes/firefly.tmLanguage.json +294 -0
  221. package/vscode/tsconfig.json +20 -0
@@ -0,0 +1,483 @@
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_BrowserSystem from "../../ff/core/BrowserSystem.mjs"
34
+
35
+ import * as ff_core_Buffer from "../../ff/core/Buffer.mjs"
36
+
37
+ import * as ff_core_BuildSystem from "../../ff/core/BuildSystem.mjs"
38
+
39
+ import * as ff_core_Channel from "../../ff/core/Channel.mjs"
40
+
41
+ import * as ff_core_Char from "../../ff/core/Char.mjs"
42
+
43
+ import * as ff_core_Core from "../../ff/core/Core.mjs"
44
+
45
+ import * as ff_core_Duration from "../../ff/core/Duration.mjs"
46
+
47
+ import * as ff_core_Equal from "../../ff/core/Equal.mjs"
48
+
49
+ import * as ff_core_Error from "../../ff/core/Error.mjs"
50
+
51
+ import * as ff_core_FileHandle from "../../ff/core/FileHandle.mjs"
52
+
53
+ import * as ff_core_Float from "../../ff/core/Float.mjs"
54
+
55
+ import * as ff_core_HttpClient from "../../ff/core/HttpClient.mjs"
56
+
57
+ import * as ff_core_Instant from "../../ff/core/Instant.mjs"
58
+
59
+ import * as ff_core_Int from "../../ff/core/Int.mjs"
60
+
61
+ import * as ff_core_IntMap from "../../ff/core/IntMap.mjs"
62
+
63
+ import * as ff_core_JsSystem from "../../ff/core/JsSystem.mjs"
64
+
65
+ import * as ff_core_JsValue from "../../ff/core/JsValue.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_Serializable from "../../ff/core/Serializable.mjs"
88
+
89
+ import * as ff_core_Set from "../../ff/core/Set.mjs"
90
+
91
+ import * as ff_core_Show from "../../ff/core/Show.mjs"
92
+
93
+ import * as ff_core_Stack from "../../ff/core/Stack.mjs"
94
+
95
+ import * as ff_core_Stream from "../../ff/core/Stream.mjs"
96
+
97
+ import * as ff_core_String from "../../ff/core/String.mjs"
98
+
99
+ import * as ff_core_StringMap from "../../ff/core/StringMap.mjs"
100
+
101
+ import * as ff_core_Task from "../../ff/core/Task.mjs"
102
+
103
+ import * as ff_core_Try from "../../ff/core/Try.mjs"
104
+
105
+ import * as ff_core_Unit from "../../ff/core/Unit.mjs"
106
+
107
+ // type PackageFiles
108
+ export function PackageFiles(root_, packageFile_, files_) {
109
+ return {root_, packageFile_, files_};
110
+ }
111
+
112
+
113
+
114
+ export function build_(system_, emitTarget_, mainPackage_, mainModule_, resolvedDependencies_, compilerModulePath_, tempPath_, jsOutputPath_, printMeasurements_) {
115
+ if(ff_core_Path.Path_exists(tempPath_, false, false, false)) {
116
+ ff_core_Path.Path_delete(tempPath_, 0, 100)
117
+ };
118
+ ff_core_Path.Path_createDirectory(tempPath_, false);
119
+ const jsPathFile_ = ff_core_Path.Path_slash(tempPath_, "js");
120
+ ff_core_Path.Path_createDirectory(jsPathFile_, true);
121
+ const success_ = ff_core_Core.do_((() => {
122
+ const compiler_ = ff_compiler_Compiler.make_(emitTarget_, ff_core_NodeSystem.NodeSystem_mainTask(system_), compilerModulePath_, jsPathFile_, resolvedDependencies_, ff_core_Map.empty_(), ff_compiler_LspHook.disabled_());
123
+ ff_compiler_Compiler.Compiler_emit(compiler_, mainPackage_, mainModule_, true);
124
+ if(printMeasurements_) {
125
+ ff_compiler_Compiler.Compiler_printMeasurements(compiler_)
126
+ };
127
+ ff_core_Map.Map_each(resolvedDependencies_.packagePaths_, ((packagePair_, packagePath_) => {
128
+ 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_) => {
129
+ ff_compiler_Builder.processIncludes_(jsPathFile_, packagePath_, packageInfo_)
130
+ }))
131
+ }), ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair);
132
+ return true
133
+ }));
134
+ if(success_) {
135
+ if(ff_core_Path.Path_exists(jsOutputPath_, false, false, false)) {
136
+ ff_core_Path.Path_delete(jsOutputPath_, 0, 100)
137
+ };
138
+ ff_core_Path.Path_renameTo(jsPathFile_, jsOutputPath_)
139
+ }
140
+ }
141
+
142
+ export function processIncludes_(jsPathFile_, packagePath_, info_) {
143
+ ff_core_List.List_each(info_.includes_, ((include_) => {
144
+ const fromPath_ = ff_core_Path.Path_slash(ff_core_Path.Path_slash(ff_core_Path.Path_slash(packagePath_, ".firefly"), "include"), include_.path_);
145
+ const toPath_ = ff_core_Path.Path_slash(ff_core_Path.Path_slash(jsPathFile_, ff_compiler_Syntax.PackagePair_groupName(info_.package_.packagePair_, "/")), include_.path_);
146
+ ff_core_Path.Path_copyTo(fromPath_, toPath_, 0, 100)
147
+ }))
148
+ }
149
+
150
+ export function buildViaBuildSystem_(system_, fireflyPath_, mainFile_, target_) {
151
+ const resolvedDependencies_ = ff_compiler_Dependencies.process_(ff_core_NodeSystem.NodeSystem_httpClient(system_), ff_core_NodeSystem.NodeSystem_path(system_, mainFile_));
152
+ 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)
153
+ ? resolvedDependencies_.packagePaths_
154
+ : 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));
155
+ if((target_ !== "browser")) {
156
+ ff_core_Core.panic_("buildViaBuildSystem is currently limited to browser target only - the restriction can be lifted")
157
+ };
158
+ ff_compiler_Builder.build_(system_, ff_compiler_JsEmitter.EmitBrowser(), resolvedDependencies_.mainPackagePair_, ff_core_String.String_dropLast(mainFile_, ff_core_String.String_size(".ff")), (((_c) => {
159
+ return ff_compiler_Dependencies.ResolvedDependencies(_c.mainPackagePair_, _c.packages_, fixedPackagePaths_, _c.singleFilePackages_)
160
+ }))(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)
161
+ }
162
+
163
+ export function check_(system_, fireflyPath_, path_, virtualFiles_, lspHook_, infer_) {
164
+ const packages_ = (((_1) => {
165
+ {
166
+ if(_1) {
167
+ return ff_compiler_Builder.findPackageFiles_(path_)
168
+ return
169
+ }
170
+ }
171
+ {
172
+ if(!_1) {
173
+ const _guard1 = ff_core_Path.Path_endsWith(path_, ff_core_List.Link(".firefly", ff_core_List.Link("package.ff", ff_core_List.Empty())));
174
+ if(_guard1) {
175
+ 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())
176
+ return
177
+ }
178
+ }
179
+ }
180
+ {
181
+ if(!_1) {
182
+ 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())
183
+ return
184
+ }
185
+ }
186
+ }))(ff_core_Path.Path_isDirectory(path_));
187
+ ff_core_List.List_each(ff_core_List.List_filter(packages_, ((_w1) => {
188
+ return (!ff_core_List.List_isEmpty(_w1.files_))
189
+ })), ((package_) => {
190
+ const firstFile_ = ff_core_List.List_grabFirst(package_.files_);
191
+ const resolvedDependencies_ = ff_compiler_Dependencies.process_(ff_core_NodeSystem.NodeSystem_httpClient(system_), firstFile_);
192
+ 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)
193
+ ? resolvedDependencies_.packagePaths_
194
+ : 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));
195
+ const fixedResolvedDependencies_ = (((_c) => {
196
+ return ff_compiler_Dependencies.ResolvedDependencies(_c.mainPackagePair_, _c.packages_, fixedPackagePaths_, _c.singleFilePackages_)
197
+ }))(resolvedDependencies_);
198
+ 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_);
199
+ ff_core_List.List_each(package_.files_, ((file_) => {
200
+ const localFile_ = ff_core_Path.Path_base(file_);
201
+ if(infer_) {
202
+ ff_compiler_Compiler.Compiler_infer(compiler_, resolvedDependencies_.mainPackagePair_, ff_core_String.String_dropLast(localFile_, ff_core_String.String_size(".ff")))
203
+ } else {
204
+ ff_compiler_Compiler.Compiler_resolve(compiler_, resolvedDependencies_.mainPackagePair_, ff_core_String.String_dropLast(localFile_, ff_core_String.String_size(".ff")))
205
+ }
206
+ }))
207
+ }))
208
+ }
209
+
210
+ export function findPackageFiles_(path_) {
211
+ const files_ = ff_compiler_Builder.findFireflyFiles_(path_);
212
+ const split_ = ff_core_List.List_partition(files_, ((_w1) => {
213
+ return ff_core_Path.Path_endsWith(_w1, ff_core_List.Link(".firefly", ff_core_List.Link("package.ff", ff_core_List.Empty())))
214
+ }));
215
+ const packageFiles_ = split_.first_;
216
+ let singleFiles_ = split_.second_;
217
+ const multiFileProjects_ = ff_core_List.List_map(packageFiles_, ((packageFile_) => {
218
+ const projectRoot_ = ff_core_Option.Option_grab(ff_core_Path.Path_parent(ff_core_Option.Option_grab(ff_core_Path.Path_parent(packageFile_))));
219
+ const files_ = ff_core_List.List_partition(singleFiles_, ((_w1) => {
220
+ return ff_core_Path.Path_isInsideOf(_w1, projectRoot_)
221
+ }));
222
+ singleFiles_ = files_.second_;
223
+ return ff_compiler_Builder.PackageFiles(projectRoot_, ff_core_Option.Some(packageFile_), files_.first_)
224
+ }));
225
+ const singleFileProjects_ = ff_core_List.List_map(singleFiles_, ((file_) => {
226
+ const projectRoot_ = ff_core_Option.Option_grab(ff_core_Path.Path_parent(file_));
227
+ return ff_compiler_Builder.PackageFiles(projectRoot_, ff_core_Option.None(), ff_core_List.Link(file_, ff_core_List.Empty()))
228
+ }));
229
+ return ff_core_List.List_addAll(multiFileProjects_, singleFileProjects_)
230
+ }
231
+
232
+ export function findFireflyFiles_(path_) {
233
+ const split_ = ff_core_List.List_partition(ff_core_Stream.Stream_toList(ff_core_Path.Path_entries(path_)), ((_w1) => {
234
+ return ff_core_Path.PathEntry_isDirectory(_w1)
235
+ }));
236
+ const directories_ = ff_core_List.List_filter(ff_core_List.List_map(split_.first_, ((_w1) => {
237
+ return ff_core_Path.PathEntry_path(_w1)
238
+ })), ((_w1) => {
239
+ return ff_core_String.String_all(ff_core_Path.Path_base(_w1), ((c_) => {
240
+ return (((c_ === 46) || ff_core_Char.Char_isAsciiLower(c_)) || ff_core_Char.Char_isAsciiDigit(c_))
241
+ }))
242
+ }));
243
+ const fireflyFiles_ = ff_core_List.List_filter(ff_core_List.List_map(split_.second_, ((_w1) => {
244
+ return ff_core_Path.PathEntry_path(_w1)
245
+ })), ((_w1) => {
246
+ return (ff_core_Path.Path_extension(_w1) === ".ff")
247
+ }));
248
+ return ff_core_List.List_addAll(fireflyFiles_, ff_core_List.List_flatMap(directories_, ((_w1) => {
249
+ return ff_compiler_Builder.findFireflyFiles_(_w1)
250
+ })))
251
+ }
252
+
253
+ 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_()) {
254
+ const assetOutputPath_ = ff_core_Path.Path_slash(outputPath_, "assets");
255
+ ff_core_List.List_each(ff_core_Map.Map_pairs(assets_.files_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ((_1) => {
256
+ {
257
+ const path_ = _1.first_;
258
+ const makeStream_ = _1.second_;
259
+ const p_ = ff_core_Path.Path_slash(assetOutputPath_, path_);
260
+ ff_core_Path.Path_createDirectory(ff_core_Option.Option_grab(ff_core_Path.Path_parent(p_)), true);
261
+ ff_core_Path.Path_writeStream(p_, makeStream_(), false)
262
+ return
263
+ }
264
+ }));
265
+ const json_ = `{
266
+ "name": "main",
267
+ "bin": {
268
+ "firefly-main": "Main.bundle.js"
269
+ },
270
+ "devDependencies": {
271
+ "pkg": "^5.8.0"
272
+ },
273
+ "pkg": {
274
+ "scripts": "Main.bundle.js",
275
+ "outputPath": "bin",
276
+ "assets": ["../assets/**/*"],
277
+ "targets": [
278
+ "node18-linux-x64",
279
+ "node18-macos-x64",
280
+ "node18-win-x64"
281
+ ]
282
+ }
283
+ }`;
284
+ const packageFile_ = ff_core_Path.Path_slash(outputPath_, "executable/package.json");
285
+ ff_core_Path.Path_writeText(packageFile_, json_);
286
+ ff_compiler_Builder.internalCallPkg_(self_, packageFile_, outputPath_, targets_)
287
+ }
288
+
289
+ export function internalCallPkg_(self_, packageFile_, outputPath_, targets_) {
290
+ throw new Error('Function internalCallPkg is missing on this target in sync context.');
291
+ }
292
+
293
+ export async function build_$(system_, emitTarget_, mainPackage_, mainModule_, resolvedDependencies_, compilerModulePath_, tempPath_, jsOutputPath_, printMeasurements_, $task) {
294
+ if((await ff_core_Path.Path_exists$(tempPath_, false, false, false, $task))) {
295
+ (await ff_core_Path.Path_delete$(tempPath_, 0, 100, $task))
296
+ };
297
+ (await ff_core_Path.Path_createDirectory$(tempPath_, false, $task));
298
+ const jsPathFile_ = (await ff_core_Path.Path_slash$(tempPath_, "js", $task));
299
+ (await ff_core_Path.Path_createDirectory$(jsPathFile_, true, $task));
300
+ const success_ = (await ff_core_Core.do_$((async ($task) => {
301
+ 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));
302
+ (await ff_compiler_Compiler.Compiler_emit$(compiler_, mainPackage_, mainModule_, true, $task));
303
+ if(printMeasurements_) {
304
+ (await ff_compiler_Compiler.Compiler_printMeasurements$(compiler_, $task))
305
+ };
306
+ (await ff_core_Map.Map_each$(resolvedDependencies_.packagePaths_, (async (packagePair_, packagePath_, $task) => {
307
+ (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) => {
308
+ (await ff_compiler_Builder.processIncludes_$(jsPathFile_, packagePath_, packageInfo_, $task))
309
+ }), $task))
310
+ }), ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair, $task));
311
+ return true
312
+ }), $task));
313
+ if(success_) {
314
+ if((await ff_core_Path.Path_exists$(jsOutputPath_, false, false, false, $task))) {
315
+ (await ff_core_Path.Path_delete$(jsOutputPath_, 0, 100, $task))
316
+ };
317
+ (await ff_core_Path.Path_renameTo$(jsPathFile_, jsOutputPath_, $task))
318
+ }
319
+ }
320
+
321
+ export async function processIncludes_$(jsPathFile_, packagePath_, info_, $task) {
322
+ (await ff_core_List.List_each$(info_.includes_, (async (include_, $task) => {
323
+ 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));
324
+ 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));
325
+ (await ff_core_Path.Path_copyTo$(fromPath_, toPath_, 0, 100, $task))
326
+ }), $task))
327
+ }
328
+
329
+ export async function buildViaBuildSystem_$(system_, fireflyPath_, mainFile_, target_, $task) {
330
+ 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));
331
+ 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)
332
+ ? resolvedDependencies_.packagePaths_
333
+ : 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));
334
+ if((target_ !== "browser")) {
335
+ ff_core_Core.panic_("buildViaBuildSystem is currently limited to browser target only - the restriction can be lifted")
336
+ };
337
+ (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) => {
338
+ return ff_compiler_Dependencies.ResolvedDependencies(_c.mainPackagePair_, _c.packages_, fixedPackagePaths_, _c.singleFilePackages_)
339
+ }))(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))
340
+ }
341
+
342
+ export async function check_$(system_, fireflyPath_, path_, virtualFiles_, lspHook_, infer_, $task) {
343
+ const packages_ = (await ((async (_1, $task) => {
344
+ {
345
+ if(_1) {
346
+ return (await ff_compiler_Builder.findPackageFiles_$(path_, $task))
347
+ return
348
+ }
349
+ }
350
+ {
351
+ if(!_1) {
352
+ 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));
353
+ if(_guard1) {
354
+ 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())
355
+ return
356
+ }
357
+ }
358
+ }
359
+ {
360
+ if(!_1) {
361
+ 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())
362
+ return
363
+ }
364
+ }
365
+ }))((await ff_core_Path.Path_isDirectory$(path_, $task)), $task));
366
+ (await ff_core_List.List_each$(ff_core_List.List_filter(packages_, ((_w1) => {
367
+ return (!ff_core_List.List_isEmpty(_w1.files_))
368
+ })), (async (package_, $task) => {
369
+ const firstFile_ = ff_core_List.List_grabFirst(package_.files_);
370
+ const resolvedDependencies_ = (await ff_compiler_Dependencies.process_$((await ff_core_NodeSystem.NodeSystem_httpClient$(system_, $task)), firstFile_, $task));
371
+ 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)
372
+ ? resolvedDependencies_.packagePaths_
373
+ : 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));
374
+ const fixedResolvedDependencies_ = (((_c) => {
375
+ return ff_compiler_Dependencies.ResolvedDependencies(_c.mainPackagePair_, _c.packages_, fixedPackagePaths_, _c.singleFilePackages_)
376
+ }))(resolvedDependencies_);
377
+ 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));
378
+ (await ff_core_List.List_each$(package_.files_, (async (file_, $task) => {
379
+ const localFile_ = (await ff_core_Path.Path_base$(file_, $task));
380
+ if(infer_) {
381
+ (await ff_compiler_Compiler.Compiler_infer$(compiler_, resolvedDependencies_.mainPackagePair_, ff_core_String.String_dropLast(localFile_, ff_core_String.String_size(".ff")), $task))
382
+ } else {
383
+ (await ff_compiler_Compiler.Compiler_resolve$(compiler_, resolvedDependencies_.mainPackagePair_, ff_core_String.String_dropLast(localFile_, ff_core_String.String_size(".ff")), $task))
384
+ }
385
+ }), $task))
386
+ }), $task))
387
+ }
388
+
389
+ export async function findPackageFiles_$(path_, $task) {
390
+ const files_ = (await ff_compiler_Builder.findFireflyFiles_$(path_, $task));
391
+ const split_ = (await ff_core_List.List_partition$(files_, (async (_w1, $task) => {
392
+ return (await ff_core_Path.Path_endsWith$(_w1, ff_core_List.Link(".firefly", ff_core_List.Link("package.ff", ff_core_List.Empty())), $task))
393
+ }), $task));
394
+ const packageFiles_ = split_.first_;
395
+ let singleFiles_ = split_.second_;
396
+ const multiFileProjects_ = (await ff_core_List.List_map$(packageFiles_, (async (packageFile_, $task) => {
397
+ 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)));
398
+ const files_ = (await ff_core_List.List_partition$(singleFiles_, (async (_w1, $task) => {
399
+ return (await ff_core_Path.Path_isInsideOf$(_w1, projectRoot_, $task))
400
+ }), $task));
401
+ singleFiles_ = files_.second_;
402
+ return ff_compiler_Builder.PackageFiles(projectRoot_, ff_core_Option.Some(packageFile_), files_.first_)
403
+ }), $task));
404
+ const singleFileProjects_ = (await ff_core_List.List_map$(singleFiles_, (async (file_, $task) => {
405
+ const projectRoot_ = ff_core_Option.Option_grab((await ff_core_Path.Path_parent$(file_, $task)));
406
+ return ff_compiler_Builder.PackageFiles(projectRoot_, ff_core_Option.None(), ff_core_List.Link(file_, ff_core_List.Empty()))
407
+ }), $task));
408
+ return ff_core_List.List_addAll(multiFileProjects_, singleFileProjects_)
409
+ }
410
+
411
+ export async function findFireflyFiles_$(path_, $task) {
412
+ 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) => {
413
+ return (await ff_core_Path.PathEntry_isDirectory$(_w1, $task))
414
+ }), $task));
415
+ const directories_ = (await ff_core_List.List_filter$((await ff_core_List.List_map$(split_.first_, (async (_w1, $task) => {
416
+ return (await ff_core_Path.PathEntry_path$(_w1, $task))
417
+ }), $task)), (async (_w1, $task) => {
418
+ return ff_core_String.String_all((await ff_core_Path.Path_base$(_w1, $task)), ((c_) => {
419
+ return (((c_ === 46) || ff_core_Char.Char_isAsciiLower(c_)) || ff_core_Char.Char_isAsciiDigit(c_))
420
+ }))
421
+ }), $task));
422
+ const fireflyFiles_ = (await ff_core_List.List_filter$((await ff_core_List.List_map$(split_.second_, (async (_w1, $task) => {
423
+ return (await ff_core_Path.PathEntry_path$(_w1, $task))
424
+ }), $task)), (async (_w1, $task) => {
425
+ return ((await ff_core_Path.Path_extension$(_w1, $task)) === ".ff")
426
+ }), $task));
427
+ return ff_core_List.List_addAll(fireflyFiles_, (await ff_core_List.List_flatMap$(directories_, (async (_w1, $task) => {
428
+ return (await ff_compiler_Builder.findFireflyFiles_$(_w1, $task))
429
+ }), $task)))
430
+ }
431
+
432
+ 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) {
433
+ const assetOutputPath_ = (await ff_core_Path.Path_slash$(outputPath_, "assets", $task));
434
+ (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) => {
435
+ {
436
+ const path_ = _1.first_;
437
+ const makeStream_ = _1.second_;
438
+ const p_ = (await ff_core_Path.Path_slash$(assetOutputPath_, path_, $task));
439
+ (await ff_core_Path.Path_createDirectory$(ff_core_Option.Option_grab((await ff_core_Path.Path_parent$(p_, $task))), true, $task));
440
+ (await ff_core_Path.Path_writeStream$(p_, (await makeStream_($task)), false, $task))
441
+ return
442
+ }
443
+ }), $task));
444
+ const json_ = `{
445
+ "name": "main",
446
+ "bin": {
447
+ "firefly-main": "Main.bundle.js"
448
+ },
449
+ "devDependencies": {
450
+ "pkg": "^5.8.0"
451
+ },
452
+ "pkg": {
453
+ "scripts": "Main.bundle.js",
454
+ "outputPath": "bin",
455
+ "assets": ["../assets/**/*"],
456
+ "targets": [
457
+ "node18-linux-x64",
458
+ "node18-macos-x64",
459
+ "node18-win-x64"
460
+ ]
461
+ }
462
+ }`;
463
+ const packageFile_ = (await ff_core_Path.Path_slash$(outputPath_, "executable/package.json", $task));
464
+ (await ff_core_Path.Path_writeText$(packageFile_, json_, $task));
465
+ (await ff_compiler_Builder.internalCallPkg_$(self_, packageFile_, outputPath_, targets_, $task))
466
+ }
467
+
468
+ export async function internalCallPkg_$(self_, packageFile_, outputPath_, targets_, $task) {
469
+
470
+ const pkg = import$0
471
+ return await pkg.exec([
472
+ packageFile_,
473
+ '--out-path', outputPath_,
474
+ '--target', ff_core_List.List_toArray(targets_).join(',')
475
+ ])
476
+
477
+ }
478
+
479
+
480
+
481
+
482
+
483
+