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.
- package/.firefly-workspace +1 -0
- package/.vscode/settings.json +5 -0
- package/LICENSE.txt +21 -0
- package/README.md +96 -0
- package/bin/firefly.mjs +2 -0
- package/compiler/.firefly/package.ff +1 -0
- package/compiler/Builder.ff +218 -0
- package/compiler/Compiler.ff +241 -0
- package/compiler/Dependencies.ff +179 -0
- package/compiler/Deriver.ff +647 -0
- package/compiler/Dictionaries.ff +205 -0
- package/compiler/Environment.ff +166 -0
- package/compiler/Inference.ff +1117 -0
- package/compiler/JsEmitter.ff +861 -0
- package/compiler/JsImporter.ff +56 -0
- package/compiler/LspHook.ff +188 -0
- package/compiler/Main.ff +237 -0
- package/compiler/Parser.ff +1383 -0
- package/compiler/Patterns.ff +111 -0
- package/compiler/Resolver.ff +620 -0
- package/compiler/Substitution.ff +178 -0
- package/compiler/Syntax.ff +299 -0
- package/compiler/Token.ff +180 -0
- package/compiler/Tokenizer.ff +278 -0
- package/compiler/Unification.ff +220 -0
- package/compiler/Wildcards.ff +50 -0
- package/compiler/Workspace.ff +88 -0
- package/core/.firefly/package.ff +2 -0
- package/core/Any.ff +30 -0
- package/core/Array.ff +249 -0
- package/core/AssetSystem.ff +61 -0
- package/core/Atomic.ff +64 -0
- package/core/Bool.ff +13 -0
- package/core/BrowserSystem.ff +14 -0
- package/core/Buffer.ff +211 -0
- package/core/BuildSystem.ff +144 -0
- package/core/Channel.ff +131 -0
- package/core/Char.ff +18 -0
- package/core/Core.ff +58 -0
- package/core/Duration.ff +15 -0
- package/core/Equal.ff +52 -0
- package/core/Error.ff +20 -0
- package/core/FileHandle.ff +41 -0
- package/core/Float.ff +41 -0
- package/core/HttpClient.ff +84 -0
- package/core/Instant.ff +9 -0
- package/core/Int.ff +61 -0
- package/core/IntMap.ff +85 -0
- package/core/JsSystem.ff +66 -0
- package/core/JsValue.ff +240 -0
- package/core/List.ff +440 -0
- package/core/Lock.ff +144 -0
- package/core/Log.ff +24 -0
- package/core/Map.ff +126 -0
- package/core/NodeSystem.ff +88 -0
- package/core/Nothing.ff +1 -0
- package/core/Option.ff +133 -0
- package/core/Ordering.ff +157 -0
- package/core/Pair.ff +55 -0
- package/core/Path.ff +393 -0
- package/core/RbMap.ff +216 -0
- package/core/Serializable.ff +173 -0
- package/core/Set.ff +38 -0
- package/core/Show.ff +43 -0
- package/core/Stack.ff +263 -0
- package/core/Stream.ff +406 -0
- package/core/String.ff +175 -0
- package/core/StringMap.ff +85 -0
- package/core/Task.ff +138 -0
- package/core/Try.ff +81 -0
- package/core/Unit.ff +3 -0
- package/experimental/random/AltGeneric.ff +44 -0
- package/experimental/random/Async.ff +68 -0
- package/experimental/random/Buffer2.ff +77 -0
- package/experimental/random/Cat.ff +12 -0
- package/experimental/random/Dictionary.ff +52 -0
- package/experimental/random/Example.ff +46 -0
- package/experimental/random/Generic.ff +102 -0
- package/experimental/random/HappyEyeballs.ff +40 -0
- package/experimental/random/HashMap.ff +72 -0
- package/experimental/random/IfElseUnit.ff +9 -0
- package/experimental/random/InputOutput.ff +23 -0
- package/experimental/random/ListVsArray.ff +45 -0
- package/experimental/random/Main.ff +44 -0
- package/experimental/random/MapTest.ff +67 -0
- package/experimental/random/OldTaskSystem.ff +210 -0
- package/experimental/random/PatternTest.ff +39 -0
- package/experimental/random/Patterns.ff +226 -0
- package/experimental/random/ReadBytesTest.ff +10 -0
- package/experimental/random/RunLength.ff +65 -0
- package/experimental/random/Scrape.ff +51 -0
- package/experimental/random/Serialization.ff +217 -0
- package/experimental/random/SerializationTest.ff +46 -0
- package/experimental/random/Serializer.ff +36 -0
- package/experimental/random/StdInOutErr.ff +4 -0
- package/experimental/random/Symbols.ff +74 -0
- package/experimental/random/Tag.ff +49 -0
- package/experimental/random/Tensor.ff +52 -0
- package/experimental/random/Try.ff +56 -0
- package/experimental/random/Tsv.ff +9 -0
- package/experimental/random/TypesAreModules.ff +87 -0
- package/experimental/random/blueprints/Blueprint.ff +52 -0
- package/experimental/random/blueprints/Main.ff +11 -0
- package/experimental/random/blueprints/Pretty.ff +58 -0
- package/experimental/random/blueprints/User.ff +64 -0
- package/experimental/random/blueprintsystem/BlueprintSystem.ff +48 -0
- package/experimental/random/blueprintsystem/Deserialize.ff +53 -0
- package/experimental/random/blueprintsystem/ReadJs.ff +13 -0
- package/experimental/random/blueprintsystem/User.ff +2 -0
- package/experimental/random/kahrs/Kahrs.ff +112 -0
- package/experimental/random/kahrs/TestKahrs.ff +22 -0
- package/experimental/random/kahrs/TestMap.ff +18 -0
- package/experimental/random/streaming/Gzip.ff +3 -0
- package/experimental/random/streaming/Main.ff +34 -0
- package/experimental/random/streaming/S3Bucket.ff +11 -0
- package/experimental/random/streaming/Tar.ff +5 -0
- package/experimental/rhymeapp/Main.ff +81 -0
- package/experimental/rhymeapp/index.html +14 -0
- package/firefly.sh +5 -0
- package/fireflysite/Main.ff +13 -0
- package/httpserver/.firefly/package.ff +1 -0
- package/httpserver/HttpServer.ff +184 -0
- package/lsp/.firefly/package.ff +1 -0
- package/lsp/CompletionHandler.ff +814 -0
- package/lsp/Handler.ff +551 -0
- package/lsp/HoverHandler.ff +82 -0
- package/lsp/LanguageServer.ff +229 -0
- package/lsp/SignatureHelpHandler.ff +55 -0
- package/lsp/SymbolHandler.ff +167 -0
- package/output/js/ff/compiler/Builder.mjs +483 -0
- package/output/js/ff/compiler/Compiler.mjs +410 -0
- package/output/js/ff/compiler/Dependencies.mjs +388 -0
- package/output/js/ff/compiler/Deriver.mjs +1166 -0
- package/output/js/ff/compiler/Dictionaries.mjs +1305 -0
- package/output/js/ff/compiler/Environment.mjs +1005 -0
- package/output/js/ff/compiler/Inference.mjs +4264 -0
- package/output/js/ff/compiler/JsEmitter.mjs +5353 -0
- package/output/js/ff/compiler/JsImporter.mjs +262 -0
- package/output/js/ff/compiler/LspHook.mjs +789 -0
- package/output/js/ff/compiler/Main.mjs +1695 -0
- package/output/js/ff/compiler/Parser.mjs +4004 -0
- package/output/js/ff/compiler/Patterns.mjs +923 -0
- package/output/js/ff/compiler/Resolver.mjs +2303 -0
- package/output/js/ff/compiler/Substitution.mjs +1146 -0
- package/output/js/ff/compiler/Syntax.mjs +12430 -0
- package/output/js/ff/compiler/Token.mjs +3092 -0
- package/output/js/ff/compiler/Tokenizer.mjs +589 -0
- package/output/js/ff/compiler/Unification.mjs +1748 -0
- package/output/js/ff/compiler/Wildcards.mjs +604 -0
- package/output/js/ff/compiler/Workspace.mjs +683 -0
- package/output/js/ff/core/Any.mjs +139 -0
- package/output/js/ff/core/Array.mjs +594 -0
- package/output/js/ff/core/AssetSystem.mjs +270 -0
- package/output/js/ff/core/Atomic.mjs +186 -0
- package/output/js/ff/core/Bool.mjs +141 -0
- package/output/js/ff/core/BrowserSystem.mjs +122 -0
- package/output/js/ff/core/Buffer.mjs +467 -0
- package/output/js/ff/core/BuildSystem.mjs +320 -0
- package/output/js/ff/core/Channel.mjs +268 -0
- package/output/js/ff/core/Char.mjs +145 -0
- package/output/js/ff/core/Core.mjs +300 -0
- package/output/js/ff/core/Duration.mjs +112 -0
- package/output/js/ff/core/Equal.mjs +175 -0
- package/output/js/ff/core/Error.mjs +138 -0
- package/output/js/ff/core/FileHandle.mjs +164 -0
- package/output/js/ff/core/Float.mjs +214 -0
- package/output/js/ff/core/HttpClient.mjs +210 -0
- package/output/js/ff/core/Instant.mjs +105 -0
- package/output/js/ff/core/Int.mjs +254 -0
- package/output/js/ff/core/IntMap.mjs +282 -0
- package/output/js/ff/core/JsSystem.mjs +234 -0
- package/output/js/ff/core/JsValue.mjs +678 -0
- package/output/js/ff/core/List.mjs +2335 -0
- package/output/js/ff/core/Lock.mjs +322 -0
- package/output/js/ff/core/Log.mjs +159 -0
- package/output/js/ff/core/Map.mjs +358 -0
- package/output/js/ff/core/NodeSystem.mjs +288 -0
- package/output/js/ff/core/Nothing.mjs +100 -0
- package/output/js/ff/core/Option.mjs +1002 -0
- package/output/js/ff/core/Ordering.mjs +734 -0
- package/output/js/ff/core/Pair.mjs +318 -0
- package/output/js/ff/core/Path.mjs +768 -0
- package/output/js/ff/core/RbMap.mjs +1936 -0
- package/output/js/ff/core/Serializable.mjs +434 -0
- package/output/js/ff/core/Set.mjs +250 -0
- package/output/js/ff/core/Show.mjs +201 -0
- package/output/js/ff/core/Stack.mjs +595 -0
- package/output/js/ff/core/Stream.mjs +1300 -0
- package/output/js/ff/core/String.mjs +433 -0
- package/output/js/ff/core/StringMap.mjs +282 -0
- package/output/js/ff/core/Task.mjs +345 -0
- package/output/js/ff/core/Try.mjs +503 -0
- package/output/js/ff/core/Unit.mjs +103 -0
- package/package.json +29 -0
- package/postgresql/.firefly/include/package-lock.json +250 -0
- package/postgresql/.firefly/include/package.json +5 -0
- package/postgresql/.firefly/include/prepare.sh +2 -0
- package/postgresql/.firefly/package.ff +3 -0
- package/postgresql/Pg.ff +530 -0
- package/unsafejs/.firefly/package.ff +1 -0
- package/unsafejs/UnsafeJs.ff +19 -0
- package/vscode/.vscode/launch.json +18 -0
- package/vscode/.vscode/tasks.json +33 -0
- package/vscode/LICENSE.txt +21 -0
- package/vscode/Prepublish.ff +15 -0
- package/vscode/README.md +17 -0
- package/vscode/client/package-lock.json +544 -0
- package/vscode/client/package.json +22 -0
- package/vscode/client/src/extension.ts +64 -0
- package/vscode/client/tsconfig.json +12 -0
- package/vscode/icons/firefly-icon.png +0 -0
- package/vscode/icons/firefly-icon.svg +10 -0
- package/vscode/icons/firefly-logo-notext.png +0 -0
- package/vscode/icons/firefly-logo.png +0 -0
- package/vscode/language-configuration.json +39 -0
- package/vscode/package-lock.json +3623 -0
- package/vscode/package.json +144 -0
- package/vscode/snippets-none.json +1 -0
- package/vscode/snippets.json +241 -0
- package/vscode/syntaxes/firefly.tmLanguage.json +294 -0
- package/vscode/tsconfig.json +20 -0
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
import * as import$0 from 'tar';
|
|
2
|
+
|
|
3
|
+
import * as ff_compiler_Dependencies from "../../ff/compiler/Dependencies.mjs"
|
|
4
|
+
|
|
5
|
+
import * as ff_compiler_LspHook from "../../ff/compiler/LspHook.mjs"
|
|
6
|
+
|
|
7
|
+
import * as ff_compiler_Parser from "../../ff/compiler/Parser.mjs"
|
|
8
|
+
|
|
9
|
+
import * as ff_compiler_Syntax from "../../ff/compiler/Syntax.mjs"
|
|
10
|
+
|
|
11
|
+
import * as ff_compiler_Tokenizer from "../../ff/compiler/Tokenizer.mjs"
|
|
12
|
+
|
|
13
|
+
import * as ff_compiler_Workspace from "../../ff/compiler/Workspace.mjs"
|
|
14
|
+
|
|
15
|
+
import * as ff_core_Any from "../../ff/core/Any.mjs"
|
|
16
|
+
|
|
17
|
+
import * as ff_core_Array from "../../ff/core/Array.mjs"
|
|
18
|
+
|
|
19
|
+
import * as ff_core_AssetSystem from "../../ff/core/AssetSystem.mjs"
|
|
20
|
+
|
|
21
|
+
import * as ff_core_Atomic from "../../ff/core/Atomic.mjs"
|
|
22
|
+
|
|
23
|
+
import * as ff_core_Bool from "../../ff/core/Bool.mjs"
|
|
24
|
+
|
|
25
|
+
import * as ff_core_BrowserSystem from "../../ff/core/BrowserSystem.mjs"
|
|
26
|
+
|
|
27
|
+
import * as ff_core_Buffer from "../../ff/core/Buffer.mjs"
|
|
28
|
+
|
|
29
|
+
import * as ff_core_BuildSystem from "../../ff/core/BuildSystem.mjs"
|
|
30
|
+
|
|
31
|
+
import * as ff_core_Channel from "../../ff/core/Channel.mjs"
|
|
32
|
+
|
|
33
|
+
import * as ff_core_Char from "../../ff/core/Char.mjs"
|
|
34
|
+
|
|
35
|
+
import * as ff_core_Core from "../../ff/core/Core.mjs"
|
|
36
|
+
|
|
37
|
+
import * as ff_core_Duration from "../../ff/core/Duration.mjs"
|
|
38
|
+
|
|
39
|
+
import * as ff_core_Equal from "../../ff/core/Equal.mjs"
|
|
40
|
+
|
|
41
|
+
import * as ff_core_Error from "../../ff/core/Error.mjs"
|
|
42
|
+
|
|
43
|
+
import * as ff_core_FileHandle from "../../ff/core/FileHandle.mjs"
|
|
44
|
+
|
|
45
|
+
import * as ff_core_Float from "../../ff/core/Float.mjs"
|
|
46
|
+
|
|
47
|
+
import * as ff_core_HttpClient from "../../ff/core/HttpClient.mjs"
|
|
48
|
+
|
|
49
|
+
import * as ff_core_Instant from "../../ff/core/Instant.mjs"
|
|
50
|
+
|
|
51
|
+
import * as ff_core_Int from "../../ff/core/Int.mjs"
|
|
52
|
+
|
|
53
|
+
import * as ff_core_IntMap from "../../ff/core/IntMap.mjs"
|
|
54
|
+
|
|
55
|
+
import * as ff_core_JsSystem from "../../ff/core/JsSystem.mjs"
|
|
56
|
+
|
|
57
|
+
import * as ff_core_JsValue from "../../ff/core/JsValue.mjs"
|
|
58
|
+
|
|
59
|
+
import * as ff_core_List from "../../ff/core/List.mjs"
|
|
60
|
+
|
|
61
|
+
import * as ff_core_Lock from "../../ff/core/Lock.mjs"
|
|
62
|
+
|
|
63
|
+
import * as ff_core_Log from "../../ff/core/Log.mjs"
|
|
64
|
+
|
|
65
|
+
import * as ff_core_Map from "../../ff/core/Map.mjs"
|
|
66
|
+
|
|
67
|
+
import * as ff_core_NodeSystem from "../../ff/core/NodeSystem.mjs"
|
|
68
|
+
|
|
69
|
+
import * as ff_core_Nothing from "../../ff/core/Nothing.mjs"
|
|
70
|
+
|
|
71
|
+
import * as ff_core_Option from "../../ff/core/Option.mjs"
|
|
72
|
+
|
|
73
|
+
import * as ff_core_Ordering from "../../ff/core/Ordering.mjs"
|
|
74
|
+
|
|
75
|
+
import * as ff_core_Pair from "../../ff/core/Pair.mjs"
|
|
76
|
+
|
|
77
|
+
import * as ff_core_Path from "../../ff/core/Path.mjs"
|
|
78
|
+
|
|
79
|
+
import * as ff_core_Serializable from "../../ff/core/Serializable.mjs"
|
|
80
|
+
|
|
81
|
+
import * as ff_core_Set from "../../ff/core/Set.mjs"
|
|
82
|
+
|
|
83
|
+
import * as ff_core_Show from "../../ff/core/Show.mjs"
|
|
84
|
+
|
|
85
|
+
import * as ff_core_Stack from "../../ff/core/Stack.mjs"
|
|
86
|
+
|
|
87
|
+
import * as ff_core_Stream from "../../ff/core/Stream.mjs"
|
|
88
|
+
|
|
89
|
+
import * as ff_core_String from "../../ff/core/String.mjs"
|
|
90
|
+
|
|
91
|
+
import * as ff_core_StringMap from "../../ff/core/StringMap.mjs"
|
|
92
|
+
|
|
93
|
+
import * as ff_core_Task from "../../ff/core/Task.mjs"
|
|
94
|
+
|
|
95
|
+
import * as ff_core_Try from "../../ff/core/Try.mjs"
|
|
96
|
+
|
|
97
|
+
import * as ff_core_Unit from "../../ff/core/Unit.mjs"
|
|
98
|
+
|
|
99
|
+
// type Dependencies
|
|
100
|
+
export function Dependencies(workspace_, packages_, packagePaths_, singleFilePackages_) {
|
|
101
|
+
return {workspace_, packages_, packagePaths_, singleFilePackages_};
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// type ResolvedDependencies
|
|
105
|
+
export function ResolvedDependencies(mainPackagePair_, packages_, packagePaths_, singleFilePackages_) {
|
|
106
|
+
return {mainPackagePair_, packages_, packagePaths_, singleFilePackages_};
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
export function process_(fetch_, path_) {
|
|
112
|
+
const workspace_ = ff_compiler_Workspace.loadWorkspace_(path_);
|
|
113
|
+
const self_ = ff_compiler_Dependencies.Dependencies(workspace_, ff_core_List.List_toMap(ff_core_List.Empty(), ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair), ff_core_List.List_toMap(ff_core_List.Empty(), ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair), ff_core_List.List_toSet(ff_core_List.Empty(), ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair));
|
|
114
|
+
const packageInfo_ = ff_compiler_Dependencies.Dependencies_loadPackageInfo(self_, ff_compiler_Syntax.PackagePair("script", "script"), path_);
|
|
115
|
+
const newDependencies_ = ff_compiler_Dependencies.Dependencies_processPackageInfo(self_, packageInfo_);
|
|
116
|
+
ff_compiler_Dependencies.Dependencies_processDependencies(self_, path_, fetch_, newDependencies_);
|
|
117
|
+
const packagePaths_ = ff_core_Map.Map_add(self_.packagePaths_, packageInfo_.package_.packagePair_, ff_compiler_Dependencies.findScriptPackageLocation_(path_), ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair);
|
|
118
|
+
return ff_compiler_Dependencies.ResolvedDependencies(packageInfo_.package_.packagePair_, self_.packages_, packagePaths_, self_.singleFilePackages_)
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export function findScriptPackageLocation_(path_) {
|
|
122
|
+
const packageDirectory_ = ((ff_core_Path.Path_extension(path_) === ".ff")
|
|
123
|
+
? ff_core_Option.Option_grab(ff_core_Path.Path_parent(path_))
|
|
124
|
+
: path_);
|
|
125
|
+
function go_(directory_) {
|
|
126
|
+
const packageFile_ = ff_core_Path.Path_slash(ff_core_Path.Path_slash(directory_, ".firefly"), "package.ff");
|
|
127
|
+
if(ff_core_Path.Path_exists(packageFile_, false, false, false)) {
|
|
128
|
+
return directory_
|
|
129
|
+
} else if((!ff_core_Option.Option_isEmpty(ff_core_Path.Path_parent(directory_)))) {
|
|
130
|
+
return go_(ff_core_Option.Option_grab(ff_core_Path.Path_parent(directory_)))
|
|
131
|
+
} else {
|
|
132
|
+
return packageDirectory_
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return go_(packageDirectory_)
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export function checkPackagePairs_(dependencyPair_, packagePair_) {
|
|
139
|
+
if(((packagePair_.group_ !== dependencyPair_.group_) || (packagePair_.name_ !== dependencyPair_.name_))) {
|
|
140
|
+
ff_core_Core.panic_(((("Dependency declaration and package declaration disagree on package name: " + ff_compiler_Syntax.PackagePair_groupName(dependencyPair_, ":")) + " vs. ") + ff_compiler_Syntax.PackagePair_groupName(packagePair_, ":")))
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export function internalExtractTarGz_(tarGzPath_, path_) {
|
|
145
|
+
throw new Error('Function internalExtractTarGz is missing on this target in sync context.');
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export async function process_$(fetch_, path_, $task) {
|
|
149
|
+
const workspace_ = (await ff_compiler_Workspace.loadWorkspace_$(path_, $task));
|
|
150
|
+
const self_ = ff_compiler_Dependencies.Dependencies(workspace_, ff_core_List.List_toMap(ff_core_List.Empty(), ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair), ff_core_List.List_toMap(ff_core_List.Empty(), ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair), ff_core_List.List_toSet(ff_core_List.Empty(), ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair));
|
|
151
|
+
const packageInfo_ = (await ff_compiler_Dependencies.Dependencies_loadPackageInfo$(self_, ff_compiler_Syntax.PackagePair("script", "script"), path_, $task));
|
|
152
|
+
const newDependencies_ = (await ff_compiler_Dependencies.Dependencies_processPackageInfo$(self_, packageInfo_, $task));
|
|
153
|
+
(await ff_compiler_Dependencies.Dependencies_processDependencies$(self_, path_, fetch_, newDependencies_, $task));
|
|
154
|
+
const packagePaths_ = ff_core_Map.Map_add(self_.packagePaths_, packageInfo_.package_.packagePair_, (await ff_compiler_Dependencies.findScriptPackageLocation_$(path_, $task)), ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair);
|
|
155
|
+
return ff_compiler_Dependencies.ResolvedDependencies(packageInfo_.package_.packagePair_, self_.packages_, packagePaths_, self_.singleFilePackages_)
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export async function findScriptPackageLocation_$(path_, $task) {
|
|
159
|
+
const packageDirectory_ = (((await ff_core_Path.Path_extension$(path_, $task)) === ".ff")
|
|
160
|
+
? ff_core_Option.Option_grab((await ff_core_Path.Path_parent$(path_, $task)))
|
|
161
|
+
: path_);
|
|
162
|
+
async function go_$(directory_, $task) {
|
|
163
|
+
const packageFile_ = (await ff_core_Path.Path_slash$((await ff_core_Path.Path_slash$(directory_, ".firefly", $task)), "package.ff", $task));
|
|
164
|
+
if((await ff_core_Path.Path_exists$(packageFile_, false, false, false, $task))) {
|
|
165
|
+
return directory_
|
|
166
|
+
} else if((!ff_core_Option.Option_isEmpty((await ff_core_Path.Path_parent$(directory_, $task))))) {
|
|
167
|
+
return (await go_$(ff_core_Option.Option_grab((await ff_core_Path.Path_parent$(directory_, $task))), $task))
|
|
168
|
+
} else {
|
|
169
|
+
return packageDirectory_
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
return (await go_$(packageDirectory_, $task))
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export async function checkPackagePairs_$(dependencyPair_, packagePair_, $task) {
|
|
176
|
+
if(((packagePair_.group_ !== dependencyPair_.group_) || (packagePair_.name_ !== dependencyPair_.name_))) {
|
|
177
|
+
ff_core_Core.panic_(((("Dependency declaration and package declaration disagree on package name: " + ff_compiler_Syntax.PackagePair_groupName(dependencyPair_, ":")) + " vs. ") + ff_compiler_Syntax.PackagePair_groupName(packagePair_, ":")))
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export async function internalExtractTarGz_$(tarGzPath_, path_, $task) {
|
|
182
|
+
|
|
183
|
+
const tar = import$0
|
|
184
|
+
await tar.extract({file: tarGzPath_, cwd: path_, strict: true})
|
|
185
|
+
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
export function Dependencies_loadPackageInfo(self_, packagePair_, path_) {
|
|
189
|
+
const packageDirectory_ = ((ff_core_Path.Path_extension(path_) === ".ff")
|
|
190
|
+
? ff_core_Option.Option_grab(ff_core_Path.Path_parent(path_))
|
|
191
|
+
: path_);
|
|
192
|
+
const sharedPackageFile_ = ff_core_Path.Path_slash(ff_core_Path.Path_slash(packageDirectory_, ".firefly"), "package.ff");
|
|
193
|
+
const packageFile_ = (ff_core_Path.Path_exists(sharedPackageFile_, false, false, false)
|
|
194
|
+
? sharedPackageFile_
|
|
195
|
+
: (function() {
|
|
196
|
+
self_.singleFilePackages_ = ff_core_Set.Set_add(self_.singleFilePackages_, packagePair_, ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair);
|
|
197
|
+
return path_
|
|
198
|
+
})());
|
|
199
|
+
const code_ = ff_core_Path.Path_readText(packageFile_);
|
|
200
|
+
return ff_compiler_Dependencies.Dependencies_parsePackageFile(self_, packagePair_, ff_core_Path.Path_relativeTo(packageFile_, path_), code_)
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
export function Dependencies_parsePackageFile(self_, packagePair_, fileName_, code_) {
|
|
204
|
+
const tokens_ = ff_compiler_Tokenizer.tokenize_(fileName_, code_, ff_core_Option.None(), true);
|
|
205
|
+
const parser_ = ff_compiler_Parser.make_(packagePair_, fileName_, tokens_, false, ff_compiler_LspHook.disabled_());
|
|
206
|
+
const info_ = ff_compiler_Parser.Parser_parsePackageInfo(parser_);
|
|
207
|
+
return ff_compiler_Dependencies.Dependencies_addCoreDependencyIfMissing(self_, info_)
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
export function Dependencies_addCoreDependencyIfMissing(self_, info_) {
|
|
211
|
+
if(ff_core_List.List_any(info_.dependencies_, ((d_) => {
|
|
212
|
+
return ((d_.packagePair_.group_ === "ff") && (d_.packagePair_.name_ === "core"))
|
|
213
|
+
}))) {
|
|
214
|
+
return info_
|
|
215
|
+
} else {
|
|
216
|
+
const coreDependency_ = ff_compiler_Syntax.DDependency(info_.package_.at_, ff_compiler_Syntax.PackagePair("ff", "core"), ff_compiler_Syntax.Version(info_.package_.at_, 0, 0, 0), ff_compiler_Syntax.Trusted(), info_.package_.targets_);
|
|
217
|
+
{
|
|
218
|
+
const _1 = info_;
|
|
219
|
+
{
|
|
220
|
+
const _c = _1;
|
|
221
|
+
return ff_compiler_Syntax.PackageInfo(_c.package_, ff_core_List.Link(coreDependency_, info_.dependencies_), _c.includes_)
|
|
222
|
+
return
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
export function Dependencies_processPackageInfo(self_, packageInfo_) {
|
|
229
|
+
self_.packages_ = ff_core_Map.Map_add(self_.packages_, packageInfo_.package_.packagePair_, packageInfo_, ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair);
|
|
230
|
+
return ff_core_List.List_filter(packageInfo_.dependencies_, ((_w1) => {
|
|
231
|
+
return (!ff_core_Map.Map_contains(self_.packages_, _w1.packagePair_, ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair))
|
|
232
|
+
}))
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
export function Dependencies_fetchDependency(self_, path_, httpClient_, dependency_) {
|
|
236
|
+
const location_ = ff_compiler_Workspace.Workspace_findPackageLocation(self_.workspace_, dependency_.packagePair_, dependency_.version_);
|
|
237
|
+
if((ff_core_String.String_contains(location_, ":") && (!ff_core_String.String_startsWith(ff_core_String.String_dropFirst(location_, 1), ":", 0)))) {
|
|
238
|
+
if((ff_core_String.String_startsWith(location_, "http://", 0) || ff_core_String.String_startsWith(location_, "https://", 0))) {
|
|
239
|
+
const packagePair_ = dependency_.packagePair_;
|
|
240
|
+
const directory_ = (ff_core_Path.Path_isDirectory(path_)
|
|
241
|
+
? path_
|
|
242
|
+
: ff_core_Option.Option_grab(ff_core_Path.Path_parent(path_)));
|
|
243
|
+
const dependenciesPath_ = ff_core_Path.Path_slash(ff_core_Path.Path_slash(directory_, ".firefly"), "dependencies");
|
|
244
|
+
const dependencyPath_ = ff_core_Path.Path_slash(ff_core_Path.Path_slash(dependenciesPath_, packagePair_.group_), packagePair_.name_);
|
|
245
|
+
const tarGzPath_ = ff_core_Path.Path_slash(dependenciesPath_, ff_compiler_Workspace.tarGzName_(packagePair_, dependency_.version_));
|
|
246
|
+
const donePath_ = ff_core_Path.Path_slash(dependenciesPath_, (ff_compiler_Workspace.tarGzName_(packagePair_, dependency_.version_) + ".done"));
|
|
247
|
+
if((!ff_core_Path.Path_exists(donePath_, false, false, false))) {
|
|
248
|
+
ff_core_Log.trace_(("Fetching " + location_));
|
|
249
|
+
const response_ = ff_core_HttpClient.HttpClient_fetch(httpClient_, location_, "GET", ff_core_HttpClient.emptyList_, ff_core_Option.None(), ff_core_HttpClient.RedirectFollow(), ff_core_Option.None(), ff_core_Option.None(), ff_core_Option.None(), ff_core_Option.None(), ff_core_Option.None(), false);
|
|
250
|
+
if((!ff_core_HttpClient.FetchResponse_ok(response_))) {
|
|
251
|
+
ff_core_Core.panic_(("Could not download dependency: " + location_))
|
|
252
|
+
};
|
|
253
|
+
const buffer_ = ff_core_HttpClient.FetchResponse_readBuffer(response_);
|
|
254
|
+
if(ff_core_Path.Path_exists(dependencyPath_, false, false, false)) {
|
|
255
|
+
ff_core_Path.Path_delete(dependencyPath_, 0, 100)
|
|
256
|
+
};
|
|
257
|
+
ff_core_Path.Path_createDirectory(dependencyPath_, true);
|
|
258
|
+
ff_core_Path.Path_writeStream(tarGzPath_, ff_core_List.List_toStream(ff_core_List.Link(buffer_, ff_core_List.Empty()), false), false);
|
|
259
|
+
ff_compiler_Dependencies.internalExtractTarGz_(tarGzPath_, dependencyPath_);
|
|
260
|
+
ff_core_Path.Path_renameTo(tarGzPath_, donePath_)
|
|
261
|
+
};
|
|
262
|
+
return dependencyPath_
|
|
263
|
+
} else {
|
|
264
|
+
return ff_core_Core.panic_(("Loading packages by this protocol is not supported: " + location_))
|
|
265
|
+
}
|
|
266
|
+
} else {
|
|
267
|
+
return ff_core_Path.Path_path(path_, location_)
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
export function Dependencies_processDependencies(self_, path_, httpClient_, dependencies_) {
|
|
272
|
+
const packageInfos_ = ff_core_List.List_map(dependencies_, ((dependency_) => {
|
|
273
|
+
const dependencyPath_ = ff_compiler_Dependencies.Dependencies_fetchDependency(self_, path_, httpClient_, dependency_);
|
|
274
|
+
self_.packagePaths_ = ff_core_Map.Map_add(self_.packagePaths_, dependency_.packagePair_, dependencyPath_, ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair);
|
|
275
|
+
const packageInfo_ = ff_compiler_Dependencies.Dependencies_loadPackageInfo(self_, dependency_.packagePair_, dependencyPath_);
|
|
276
|
+
ff_compiler_Dependencies.checkPackagePairs_(dependency_.packagePair_, packageInfo_.package_.packagePair_);
|
|
277
|
+
return packageInfo_
|
|
278
|
+
}));
|
|
279
|
+
const newDependencies_ = ff_core_List.List_flatMap(packageInfos_, ((_w1) => {
|
|
280
|
+
return ff_compiler_Dependencies.Dependencies_processPackageInfo(self_, _w1)
|
|
281
|
+
}));
|
|
282
|
+
if(ff_core_Equal.notEquals_(newDependencies_, ff_core_List.Empty(), ff_core_List.ff_core_Equal_Equal$ff_core_List_List(ff_compiler_Syntax.ff_core_Equal_Equal$ff_compiler_Syntax_DDependency))) {
|
|
283
|
+
ff_compiler_Dependencies.Dependencies_processDependencies(self_, path_, httpClient_, newDependencies_)
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
export async function Dependencies_loadPackageInfo$(self_, packagePair_, path_, $task) {
|
|
288
|
+
const packageDirectory_ = (((await ff_core_Path.Path_extension$(path_, $task)) === ".ff")
|
|
289
|
+
? ff_core_Option.Option_grab((await ff_core_Path.Path_parent$(path_, $task)))
|
|
290
|
+
: path_);
|
|
291
|
+
const sharedPackageFile_ = (await ff_core_Path.Path_slash$((await ff_core_Path.Path_slash$(packageDirectory_, ".firefly", $task)), "package.ff", $task));
|
|
292
|
+
const packageFile_ = ((await ff_core_Path.Path_exists$(sharedPackageFile_, false, false, false, $task))
|
|
293
|
+
? sharedPackageFile_
|
|
294
|
+
: (await (async function() {
|
|
295
|
+
self_.singleFilePackages_ = ff_core_Set.Set_add(self_.singleFilePackages_, packagePair_, ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair);
|
|
296
|
+
return path_
|
|
297
|
+
})()));
|
|
298
|
+
const code_ = (await ff_core_Path.Path_readText$(packageFile_, $task));
|
|
299
|
+
return (await ff_compiler_Dependencies.Dependencies_parsePackageFile$(self_, packagePair_, (await ff_core_Path.Path_relativeTo$(packageFile_, path_, $task)), code_, $task))
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
export async function Dependencies_parsePackageFile$(self_, packagePair_, fileName_, code_, $task) {
|
|
303
|
+
const tokens_ = ff_compiler_Tokenizer.tokenize_(fileName_, code_, ff_core_Option.None(), true);
|
|
304
|
+
const parser_ = ff_compiler_Parser.make_(packagePair_, fileName_, tokens_, false, ff_compiler_LspHook.disabled_());
|
|
305
|
+
const info_ = ff_compiler_Parser.Parser_parsePackageInfo(parser_);
|
|
306
|
+
return (await ff_compiler_Dependencies.Dependencies_addCoreDependencyIfMissing$(self_, info_, $task))
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
export async function Dependencies_addCoreDependencyIfMissing$(self_, info_, $task) {
|
|
310
|
+
if(ff_core_List.List_any(info_.dependencies_, ((d_) => {
|
|
311
|
+
return ((d_.packagePair_.group_ === "ff") && (d_.packagePair_.name_ === "core"))
|
|
312
|
+
}))) {
|
|
313
|
+
return info_
|
|
314
|
+
} else {
|
|
315
|
+
const coreDependency_ = ff_compiler_Syntax.DDependency(info_.package_.at_, ff_compiler_Syntax.PackagePair("ff", "core"), ff_compiler_Syntax.Version(info_.package_.at_, 0, 0, 0), ff_compiler_Syntax.Trusted(), info_.package_.targets_);
|
|
316
|
+
{
|
|
317
|
+
const _1 = info_;
|
|
318
|
+
{
|
|
319
|
+
const _c = _1;
|
|
320
|
+
return ff_compiler_Syntax.PackageInfo(_c.package_, ff_core_List.Link(coreDependency_, info_.dependencies_), _c.includes_)
|
|
321
|
+
return
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
export async function Dependencies_processPackageInfo$(self_, packageInfo_, $task) {
|
|
328
|
+
self_.packages_ = ff_core_Map.Map_add(self_.packages_, packageInfo_.package_.packagePair_, packageInfo_, ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair);
|
|
329
|
+
return ff_core_List.List_filter(packageInfo_.dependencies_, ((_w1) => {
|
|
330
|
+
return (!ff_core_Map.Map_contains(self_.packages_, _w1.packagePair_, ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair))
|
|
331
|
+
}))
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
export async function Dependencies_fetchDependency$(self_, path_, httpClient_, dependency_, $task) {
|
|
335
|
+
const location_ = ff_compiler_Workspace.Workspace_findPackageLocation(self_.workspace_, dependency_.packagePair_, dependency_.version_);
|
|
336
|
+
if((ff_core_String.String_contains(location_, ":") && (!ff_core_String.String_startsWith(ff_core_String.String_dropFirst(location_, 1), ":", 0)))) {
|
|
337
|
+
if((ff_core_String.String_startsWith(location_, "http://", 0) || ff_core_String.String_startsWith(location_, "https://", 0))) {
|
|
338
|
+
const packagePair_ = dependency_.packagePair_;
|
|
339
|
+
const directory_ = ((await ff_core_Path.Path_isDirectory$(path_, $task))
|
|
340
|
+
? path_
|
|
341
|
+
: ff_core_Option.Option_grab((await ff_core_Path.Path_parent$(path_, $task))));
|
|
342
|
+
const dependenciesPath_ = (await ff_core_Path.Path_slash$((await ff_core_Path.Path_slash$(directory_, ".firefly", $task)), "dependencies", $task));
|
|
343
|
+
const dependencyPath_ = (await ff_core_Path.Path_slash$((await ff_core_Path.Path_slash$(dependenciesPath_, packagePair_.group_, $task)), packagePair_.name_, $task));
|
|
344
|
+
const tarGzPath_ = (await ff_core_Path.Path_slash$(dependenciesPath_, ff_compiler_Workspace.tarGzName_(packagePair_, dependency_.version_), $task));
|
|
345
|
+
const donePath_ = (await ff_core_Path.Path_slash$(dependenciesPath_, (ff_compiler_Workspace.tarGzName_(packagePair_, dependency_.version_) + ".done"), $task));
|
|
346
|
+
if((!(await ff_core_Path.Path_exists$(donePath_, false, false, false, $task)))) {
|
|
347
|
+
ff_core_Log.trace_(("Fetching " + location_));
|
|
348
|
+
const response_ = (await ff_core_HttpClient.HttpClient_fetch$(httpClient_, location_, "GET", ff_core_HttpClient.emptyList_, ff_core_Option.None(), ff_core_HttpClient.RedirectFollow(), ff_core_Option.None(), ff_core_Option.None(), ff_core_Option.None(), ff_core_Option.None(), ff_core_Option.None(), false, $task));
|
|
349
|
+
if((!(await ff_core_HttpClient.FetchResponse_ok$(response_, $task)))) {
|
|
350
|
+
ff_core_Core.panic_(("Could not download dependency: " + location_))
|
|
351
|
+
};
|
|
352
|
+
const buffer_ = (await ff_core_HttpClient.FetchResponse_readBuffer$(response_, $task));
|
|
353
|
+
if((await ff_core_Path.Path_exists$(dependencyPath_, false, false, false, $task))) {
|
|
354
|
+
(await ff_core_Path.Path_delete$(dependencyPath_, 0, 100, $task))
|
|
355
|
+
};
|
|
356
|
+
(await ff_core_Path.Path_createDirectory$(dependencyPath_, true, $task));
|
|
357
|
+
(await ff_core_Path.Path_writeStream$(tarGzPath_, (await ff_core_List.List_toStream$(ff_core_List.Link(buffer_, ff_core_List.Empty()), false, $task)), false, $task));
|
|
358
|
+
(await ff_compiler_Dependencies.internalExtractTarGz_$(tarGzPath_, dependencyPath_, $task));
|
|
359
|
+
(await ff_core_Path.Path_renameTo$(tarGzPath_, donePath_, $task))
|
|
360
|
+
};
|
|
361
|
+
return dependencyPath_
|
|
362
|
+
} else {
|
|
363
|
+
return ff_core_Core.panic_(("Loading packages by this protocol is not supported: " + location_))
|
|
364
|
+
}
|
|
365
|
+
} else {
|
|
366
|
+
return (await ff_core_Path.Path_path$(path_, location_, $task))
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
export async function Dependencies_processDependencies$(self_, path_, httpClient_, dependencies_, $task) {
|
|
371
|
+
const packageInfos_ = (await ff_core_List.List_map$(dependencies_, (async (dependency_, $task) => {
|
|
372
|
+
const dependencyPath_ = (await ff_compiler_Dependencies.Dependencies_fetchDependency$(self_, path_, httpClient_, dependency_, $task));
|
|
373
|
+
self_.packagePaths_ = ff_core_Map.Map_add(self_.packagePaths_, dependency_.packagePair_, dependencyPath_, ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair);
|
|
374
|
+
const packageInfo_ = (await ff_compiler_Dependencies.Dependencies_loadPackageInfo$(self_, dependency_.packagePair_, dependencyPath_, $task));
|
|
375
|
+
ff_compiler_Dependencies.checkPackagePairs_(dependency_.packagePair_, packageInfo_.package_.packagePair_);
|
|
376
|
+
return packageInfo_
|
|
377
|
+
}), $task));
|
|
378
|
+
const newDependencies_ = (await ff_core_List.List_flatMap$(packageInfos_, (async (_w1, $task) => {
|
|
379
|
+
return (await ff_compiler_Dependencies.Dependencies_processPackageInfo$(self_, _w1, $task))
|
|
380
|
+
}), $task));
|
|
381
|
+
if(ff_core_Equal.notEquals_(newDependencies_, ff_core_List.Empty(), ff_core_List.ff_core_Equal_Equal$ff_core_List_List(ff_compiler_Syntax.ff_core_Equal_Equal$ff_compiler_Syntax_DDependency))) {
|
|
382
|
+
(await ff_compiler_Dependencies.Dependencies_processDependencies$(self_, path_, httpClient_, newDependencies_, $task))
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
|
|
387
|
+
|
|
388
|
+
|