firefly-compiler 0.4.6 → 0.4.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/output/js/ff/compiler/Builder.mjs +444 -444
- package/output/js/ff/compiler/Compiler.mjs +416 -416
- package/output/js/ff/compiler/Dependencies.mjs +389 -389
- package/output/js/ff/compiler/Deriver.mjs +1170 -1170
- package/output/js/ff/compiler/Dictionaries.mjs +1309 -1309
- package/output/js/ff/compiler/Environment.mjs +1015 -1015
- package/output/js/ff/compiler/Inference.mjs +4268 -4268
- package/output/js/ff/compiler/JsEmitter.mjs +5391 -5391
- package/output/js/ff/compiler/JsImporter.mjs +266 -266
- package/output/js/ff/compiler/LspHook.mjs +793 -793
- package/output/js/ff/compiler/Main.mjs +1675 -1675
- package/output/js/ff/compiler/Parser.mjs +4008 -4008
- package/output/js/ff/compiler/Patterns.mjs +927 -927
- package/output/js/ff/compiler/Resolver.mjs +2307 -2307
- package/output/js/ff/compiler/Substitution.mjs +1150 -1150
- package/output/js/ff/compiler/Syntax.mjs +12434 -12434
- package/output/js/ff/compiler/Token.mjs +3096 -3096
- package/output/js/ff/compiler/Tokenizer.mjs +593 -593
- package/output/js/ff/compiler/Unification.mjs +1752 -1752
- package/output/js/ff/compiler/Wildcards.mjs +608 -608
- package/output/js/ff/compiler/Workspace.mjs +687 -687
- package/output/js/ff/core/Any.mjs +143 -143
- package/output/js/ff/core/Array.mjs +547 -547
- package/output/js/ff/core/AssetSystem.mjs +274 -274
- package/output/js/ff/core/Atomic.mjs +154 -154
- package/output/js/ff/core/Bool.mjs +152 -152
- package/output/js/ff/core/Box.mjs +112 -112
- package/output/js/ff/core/BrowserSystem.mjs +126 -126
- package/output/js/ff/core/Buffer.mjs +395 -395
- package/output/js/ff/core/BuildSystem.mjs +296 -296
- package/output/js/ff/core/Channel.mjs +189 -189
- package/output/js/ff/core/Char.mjs +149 -149
- package/output/js/ff/core/Core.mjs +300 -300
- package/output/js/ff/core/Duration.mjs +116 -116
- package/output/js/ff/core/Equal.mjs +179 -179
- package/output/js/ff/core/Error.mjs +142 -142
- package/output/js/ff/core/FileHandle.mjs +150 -150
- package/output/js/ff/core/Float.mjs +225 -225
- package/output/js/ff/core/HttpClient.mjs +191 -191
- package/output/js/ff/core/Instant.mjs +109 -109
- package/output/js/ff/core/Int.mjs +265 -265
- package/output/js/ff/core/IntMap.mjs +280 -280
- package/output/js/ff/core/JsSystem.mjs +238 -238
- package/output/js/ff/core/JsValue.mjs +708 -708
- package/output/js/ff/core/List.mjs +2334 -2334
- package/output/js/ff/core/Lock.mjs +229 -229
- package/output/js/ff/core/Log.mjs +163 -163
- package/output/js/ff/core/Map.mjs +362 -362
- package/output/js/ff/core/NodeSystem.mjs +294 -294
- package/output/js/ff/core/Nothing.mjs +104 -104
- package/output/js/ff/core/Option.mjs +1015 -1015
- package/output/js/ff/core/Ordering.mjs +730 -730
- package/output/js/ff/core/Pair.mjs +331 -331
- package/output/js/ff/core/Path.mjs +545 -545
- package/output/js/ff/core/RbMap.mjs +1940 -1940
- package/output/js/ff/core/Serializable.mjs +428 -428
- package/output/js/ff/core/Set.mjs +254 -254
- package/output/js/ff/core/Show.mjs +205 -205
- package/output/js/ff/core/SourceLocation.mjs +229 -229
- package/output/js/ff/core/Stack.mjs +529 -529
- package/output/js/ff/core/Stream.mjs +1304 -1304
- package/output/js/ff/core/String.mjs +365 -365
- package/output/js/ff/core/StringMap.mjs +280 -280
- package/output/js/ff/core/Task.mjs +320 -320
- package/output/js/ff/core/Try.mjs +507 -507
- package/output/js/ff/core/Unit.mjs +151 -151
- package/package.json +1 -1
- package/vscode/package.json +1 -1
|
@@ -1,271 +1,271 @@
|
|
|
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_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
|
+
}));
|
|
269
269
|
const json_ = `{
|
|
270
270
|
"name": "main",
|
|
271
271
|
"bin": {
|
|
@@ -284,167 +284,167 @@ const json_ = `{
|
|
|
284
284
|
"node18-win-x64"
|
|
285
285
|
]
|
|
286
286
|
}
|
|
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));
|
|
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));
|
|
448
448
|
const json_ = `{
|
|
449
449
|
"name": "main",
|
|
450
450
|
"bin": {
|
|
@@ -463,13 +463,13 @@ const json_ = `{
|
|
|
463
463
|
"node18-win-x64"
|
|
464
464
|
]
|
|
465
465
|
}
|
|
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) {
|
|
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) {
|
|
473
473
|
|
|
474
474
|
const pkg = import$0
|
|
475
475
|
return await pkg.exec([
|
|
@@ -477,11 +477,11 @@ export async function internalCallPkg_$(self_, packageFile_, outputPath_, target
|
|
|
477
477
|
'--out-path', outputPath_,
|
|
478
478
|
'--target', ff_core_List.List_toArray(targets_).join(',')
|
|
479
479
|
])
|
|
480
|
-
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
480
|
+
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
|
|
484
|
+
|
|
485
|
+
|
|
486
|
+
|
|
487
|
+
|