firefly-compiler 0.4.6 → 0.4.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/compiler/Compiler.ff +2 -0
  2. package/compiler/Deriver.ff +7 -0
  3. package/core/Array.ff +17 -4
  4. package/core/AssetSystem.ff +1 -1
  5. package/core/BrowserSystem.ff +27 -0
  6. package/core/List.ff +4 -0
  7. package/core/Lock.ff +2 -2
  8. package/core/Random.ff +148 -0
  9. package/core/SourceLocation.ff +27 -0
  10. package/core/Task.ff +3 -0
  11. package/core/WebSocket.ff +127 -0
  12. package/httpserver/HttpServer.ff +1 -1
  13. package/lux/Css.ff +648 -0
  14. package/lux/CssTest.ff +48 -0
  15. package/lux/Lux.ff +33 -18
  16. package/lux/Main.ff +4 -1
  17. package/output/js/ff/compiler/Builder.mjs +448 -444
  18. package/output/js/ff/compiler/Compiler.mjs +420 -416
  19. package/output/js/ff/compiler/Dependencies.mjs +393 -389
  20. package/output/js/ff/compiler/Deriver.mjs +1178 -1170
  21. package/output/js/ff/compiler/Dictionaries.mjs +1315 -1309
  22. package/output/js/ff/compiler/Environment.mjs +1025 -1015
  23. package/output/js/ff/compiler/Inference.mjs +4272 -4268
  24. package/output/js/ff/compiler/JsEmitter.mjs +5405 -5391
  25. package/output/js/ff/compiler/JsImporter.mjs +270 -266
  26. package/output/js/ff/compiler/LspHook.mjs +799 -793
  27. package/output/js/ff/compiler/Main.mjs +1691 -1675
  28. package/output/js/ff/compiler/Parser.mjs +4016 -4008
  29. package/output/js/ff/compiler/Patterns.mjs +935 -927
  30. package/output/js/ff/compiler/Resolver.mjs +2311 -2307
  31. package/output/js/ff/compiler/Substitution.mjs +1154 -1150
  32. package/output/js/ff/compiler/Syntax.mjs +12566 -12434
  33. package/output/js/ff/compiler/Token.mjs +3152 -3096
  34. package/output/js/ff/compiler/Tokenizer.mjs +597 -593
  35. package/output/js/ff/compiler/Unification.mjs +1762 -1752
  36. package/output/js/ff/compiler/Wildcards.mjs +612 -608
  37. package/output/js/ff/compiler/Workspace.mjs +695 -687
  38. package/output/js/ff/core/Any.mjs +147 -143
  39. package/output/js/ff/core/Array.mjs +573 -547
  40. package/output/js/ff/core/AssetSystem.mjs +278 -274
  41. package/output/js/ff/core/Atomic.mjs +158 -154
  42. package/output/js/ff/core/Bool.mjs +156 -152
  43. package/output/js/ff/core/Box.mjs +116 -112
  44. package/output/js/ff/core/BrowserSystem.mjs +181 -126
  45. package/output/js/ff/core/Buffer.mjs +399 -395
  46. package/output/js/ff/core/BuildSystem.mjs +300 -296
  47. package/output/js/ff/core/Channel.mjs +193 -189
  48. package/output/js/ff/core/Char.mjs +153 -149
  49. package/output/js/ff/core/Core.mjs +304 -300
  50. package/output/js/ff/core/Duration.mjs +120 -116
  51. package/output/js/ff/core/Equal.mjs +183 -179
  52. package/output/js/ff/core/Error.mjs +146 -142
  53. package/output/js/ff/core/FileHandle.mjs +154 -150
  54. package/output/js/ff/core/Float.mjs +229 -225
  55. package/output/js/ff/core/HttpClient.mjs +195 -191
  56. package/output/js/ff/core/Instant.mjs +113 -109
  57. package/output/js/ff/core/Int.mjs +269 -265
  58. package/output/js/ff/core/IntMap.mjs +284 -280
  59. package/output/js/ff/core/JsSystem.mjs +242 -238
  60. package/output/js/ff/core/JsValue.mjs +712 -708
  61. package/output/js/ff/core/List.mjs +2346 -2334
  62. package/output/js/ff/core/Lock.mjs +235 -231
  63. package/output/js/ff/core/Log.mjs +167 -163
  64. package/output/js/ff/core/Map.mjs +366 -362
  65. package/output/js/ff/core/NodeSystem.mjs +298 -294
  66. package/output/js/ff/core/Nothing.mjs +108 -104
  67. package/output/js/ff/core/Option.mjs +1023 -1015
  68. package/output/js/ff/core/Ordering.mjs +734 -730
  69. package/output/js/ff/core/Pair.mjs +337 -331
  70. package/output/js/ff/core/Path.mjs +549 -545
  71. package/output/js/ff/core/Random.mjs +340 -0
  72. package/output/js/ff/core/RbMap.mjs +1944 -1940
  73. package/output/js/ff/core/Serializable.mjs +432 -428
  74. package/output/js/ff/core/Set.mjs +258 -254
  75. package/output/js/ff/core/Show.mjs +209 -205
  76. package/output/js/ff/core/SourceLocation.mjs +273 -229
  77. package/output/js/ff/core/Stack.mjs +533 -529
  78. package/output/js/ff/core/Stream.mjs +1308 -1304
  79. package/output/js/ff/core/String.mjs +369 -365
  80. package/output/js/ff/core/StringMap.mjs +284 -280
  81. package/output/js/ff/core/Task.mjs +325 -319
  82. package/output/js/ff/core/Try.mjs +511 -507
  83. package/output/js/ff/core/Unit.mjs +155 -151
  84. package/output/js/ff/core/WebSocket.mjs +198 -0
  85. package/package.json +1 -1
  86. package/vscode/package.json +1 -1
  87. package/webserver/.firefly/include/package-lock.json +16 -0
  88. package/webserver/.firefly/include/package.json +5 -0
  89. package/webserver/.firefly/package.ff +2 -0
  90. package/webserver/WebServer.ff +608 -0
@@ -1,392 +1,396 @@
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_Box from "../../ff/core/Box.mjs"
26
-
27
- import * as ff_core_BrowserSystem from "../../ff/core/BrowserSystem.mjs"
28
-
29
- import * as ff_core_Buffer from "../../ff/core/Buffer.mjs"
30
-
31
- import * as ff_core_BuildSystem from "../../ff/core/BuildSystem.mjs"
32
-
33
- import * as ff_core_Channel from "../../ff/core/Channel.mjs"
34
-
35
- import * as ff_core_Char from "../../ff/core/Char.mjs"
36
-
37
- import * as ff_core_Core from "../../ff/core/Core.mjs"
38
-
39
- import * as ff_core_Duration from "../../ff/core/Duration.mjs"
40
-
41
- import * as ff_core_Equal from "../../ff/core/Equal.mjs"
42
-
43
- import * as ff_core_Error from "../../ff/core/Error.mjs"
44
-
45
- import * as ff_core_FileHandle from "../../ff/core/FileHandle.mjs"
46
-
47
- import * as ff_core_Float from "../../ff/core/Float.mjs"
48
-
49
- import * as ff_core_HttpClient from "../../ff/core/HttpClient.mjs"
50
-
51
- import * as ff_core_Instant from "../../ff/core/Instant.mjs"
52
-
53
- import * as ff_core_Int from "../../ff/core/Int.mjs"
54
-
55
- import * as ff_core_IntMap from "../../ff/core/IntMap.mjs"
56
-
57
- import * as ff_core_JsSystem from "../../ff/core/JsSystem.mjs"
58
-
59
- import * as ff_core_JsValue from "../../ff/core/JsValue.mjs"
60
-
61
- import * as ff_core_List from "../../ff/core/List.mjs"
62
-
63
- import * as ff_core_Lock from "../../ff/core/Lock.mjs"
64
-
65
- import * as ff_core_Log from "../../ff/core/Log.mjs"
66
-
67
- import * as ff_core_Map from "../../ff/core/Map.mjs"
68
-
69
- import * as ff_core_NodeSystem from "../../ff/core/NodeSystem.mjs"
70
-
71
- import * as ff_core_Nothing from "../../ff/core/Nothing.mjs"
72
-
73
- import * as ff_core_Option from "../../ff/core/Option.mjs"
74
-
75
- import * as ff_core_Ordering from "../../ff/core/Ordering.mjs"
76
-
77
- import * as ff_core_Pair from "../../ff/core/Pair.mjs"
78
-
79
- import * as ff_core_Path from "../../ff/core/Path.mjs"
80
-
81
- import * as ff_core_Serializable from "../../ff/core/Serializable.mjs"
82
-
83
- import * as ff_core_Set from "../../ff/core/Set.mjs"
84
-
85
- import * as ff_core_Show from "../../ff/core/Show.mjs"
86
-
87
- import * as ff_core_SourceLocation from "../../ff/core/SourceLocation.mjs"
88
-
89
- import * as ff_core_Stack from "../../ff/core/Stack.mjs"
90
-
91
- import * as ff_core_Stream from "../../ff/core/Stream.mjs"
92
-
93
- import * as ff_core_String from "../../ff/core/String.mjs"
94
-
95
- import * as ff_core_StringMap from "../../ff/core/StringMap.mjs"
96
-
97
- import * as ff_core_Task from "../../ff/core/Task.mjs"
98
-
99
- import * as ff_core_Try from "../../ff/core/Try.mjs"
100
-
101
- import * as ff_core_Unit from "../../ff/core/Unit.mjs"
102
-
103
- // type Dependencies
104
- export function Dependencies(workspace_, packages_, packagePaths_, singleFilePackages_) {
105
- return {workspace_, packages_, packagePaths_, singleFilePackages_};
106
- }
107
-
108
- // type ResolvedDependencies
109
- export function ResolvedDependencies(mainPackagePair_, packages_, packagePaths_, singleFilePackages_) {
110
- return {mainPackagePair_, packages_, packagePaths_, singleFilePackages_};
111
- }
112
-
113
-
114
-
115
- export function process_(fetch_, path_) {
116
- const workspace_ = ff_compiler_Workspace.loadWorkspace_(path_);
117
- 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));
118
- const packageInfo_ = ff_compiler_Dependencies.Dependencies_loadPackageInfo(self_, ff_compiler_Syntax.PackagePair("script", "script"), path_);
119
- const newDependencies_ = ff_compiler_Dependencies.Dependencies_processPackageInfo(self_, packageInfo_);
120
- ff_compiler_Dependencies.Dependencies_processDependencies(self_, path_, fetch_, newDependencies_);
121
- 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);
122
- return ff_compiler_Dependencies.ResolvedDependencies(packageInfo_.package_.packagePair_, self_.packages_, packagePaths_, self_.singleFilePackages_)
123
- }
124
-
125
- export function findScriptPackageLocation_(path_) {
126
- const packageDirectory_ = ((ff_core_Path.Path_extension(path_) === ".ff")
127
- ? ff_core_Option.Option_grab(ff_core_Path.Path_parent(path_))
128
- : path_);
129
- function go_(directory_) {
130
- const packageFile_ = ff_core_Path.Path_slash(ff_core_Path.Path_slash(directory_, ".firefly"), "package.ff");
131
- if(ff_core_Path.Path_exists(packageFile_, false, false, false)) {
132
- return directory_
133
- } else if((!ff_core_Option.Option_isEmpty(ff_core_Path.Path_parent(directory_)))) {
134
- return go_(ff_core_Option.Option_grab(ff_core_Path.Path_parent(directory_)))
135
- } else {
136
- return packageDirectory_
137
- }
138
- }
139
- return go_(packageDirectory_)
140
- }
141
-
142
- export function checkPackagePairs_(dependencyPair_, packagePair_) {
143
- if(((packagePair_.group_ !== dependencyPair_.group_) || (packagePair_.name_ !== dependencyPair_.name_))) {
144
- 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_, ":")))
145
- }
146
- }
147
-
148
- export function internalExtractTarGz_(tarGzPath_, path_) {
149
- throw new Error('Function internalExtractTarGz is missing on this target in sync context.');
150
- }
151
-
152
- export async function process_$(fetch_, path_, $task) {
153
- const workspace_ = (await ff_compiler_Workspace.loadWorkspace_$(path_, $task));
154
- 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));
155
- const packageInfo_ = (await ff_compiler_Dependencies.Dependencies_loadPackageInfo$(self_, ff_compiler_Syntax.PackagePair("script", "script"), path_, $task));
156
- const newDependencies_ = (await ff_compiler_Dependencies.Dependencies_processPackageInfo$(self_, packageInfo_, $task));
157
- (await ff_compiler_Dependencies.Dependencies_processDependencies$(self_, path_, fetch_, newDependencies_, $task));
158
- 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);
159
- return ff_compiler_Dependencies.ResolvedDependencies(packageInfo_.package_.packagePair_, self_.packages_, packagePaths_, self_.singleFilePackages_)
160
- }
161
-
162
- export async function findScriptPackageLocation_$(path_, $task) {
163
- const packageDirectory_ = (((await ff_core_Path.Path_extension$(path_, $task)) === ".ff")
164
- ? ff_core_Option.Option_grab((await ff_core_Path.Path_parent$(path_, $task)))
165
- : path_);
166
- async function go_$(directory_, $task) {
167
- const packageFile_ = (await ff_core_Path.Path_slash$((await ff_core_Path.Path_slash$(directory_, ".firefly", $task)), "package.ff", $task));
168
- if((await ff_core_Path.Path_exists$(packageFile_, false, false, false, $task))) {
169
- return directory_
170
- } else if((!ff_core_Option.Option_isEmpty((await ff_core_Path.Path_parent$(directory_, $task))))) {
171
- return (await go_$(ff_core_Option.Option_grab((await ff_core_Path.Path_parent$(directory_, $task))), $task))
172
- } else {
173
- return packageDirectory_
174
- }
175
- }
176
- return (await go_$(packageDirectory_, $task))
177
- }
178
-
179
- export async function checkPackagePairs_$(dependencyPair_, packagePair_, $task) {
180
- if(((packagePair_.group_ !== dependencyPair_.group_) || (packagePair_.name_ !== dependencyPair_.name_))) {
181
- 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_, ":")))
182
- }
183
- }
184
-
185
- export async function internalExtractTarGz_$(tarGzPath_, path_, $task) {
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_Box from "../../ff/core/Box.mjs"
26
+
27
+ import * as ff_core_BrowserSystem from "../../ff/core/BrowserSystem.mjs"
28
+
29
+ import * as ff_core_Buffer from "../../ff/core/Buffer.mjs"
30
+
31
+ import * as ff_core_BuildSystem from "../../ff/core/BuildSystem.mjs"
32
+
33
+ import * as ff_core_Channel from "../../ff/core/Channel.mjs"
34
+
35
+ import * as ff_core_Char from "../../ff/core/Char.mjs"
36
+
37
+ import * as ff_core_Core from "../../ff/core/Core.mjs"
38
+
39
+ import * as ff_core_Duration from "../../ff/core/Duration.mjs"
40
+
41
+ import * as ff_core_Equal from "../../ff/core/Equal.mjs"
42
+
43
+ import * as ff_core_Error from "../../ff/core/Error.mjs"
44
+
45
+ import * as ff_core_FileHandle from "../../ff/core/FileHandle.mjs"
46
+
47
+ import * as ff_core_Float from "../../ff/core/Float.mjs"
48
+
49
+ import * as ff_core_HttpClient from "../../ff/core/HttpClient.mjs"
50
+
51
+ import * as ff_core_Instant from "../../ff/core/Instant.mjs"
52
+
53
+ import * as ff_core_Int from "../../ff/core/Int.mjs"
54
+
55
+ import * as ff_core_IntMap from "../../ff/core/IntMap.mjs"
56
+
57
+ import * as ff_core_JsSystem from "../../ff/core/JsSystem.mjs"
58
+
59
+ import * as ff_core_JsValue from "../../ff/core/JsValue.mjs"
60
+
61
+ import * as ff_core_List from "../../ff/core/List.mjs"
62
+
63
+ import * as ff_core_Lock from "../../ff/core/Lock.mjs"
64
+
65
+ import * as ff_core_Log from "../../ff/core/Log.mjs"
66
+
67
+ import * as ff_core_Map from "../../ff/core/Map.mjs"
68
+
69
+ import * as ff_core_NodeSystem from "../../ff/core/NodeSystem.mjs"
70
+
71
+ import * as ff_core_Nothing from "../../ff/core/Nothing.mjs"
72
+
73
+ import * as ff_core_Option from "../../ff/core/Option.mjs"
74
+
75
+ import * as ff_core_Ordering from "../../ff/core/Ordering.mjs"
76
+
77
+ import * as ff_core_Pair from "../../ff/core/Pair.mjs"
78
+
79
+ import * as ff_core_Path from "../../ff/core/Path.mjs"
80
+
81
+ import * as ff_core_Random from "../../ff/core/Random.mjs"
82
+
83
+ import * as ff_core_Serializable from "../../ff/core/Serializable.mjs"
84
+
85
+ import * as ff_core_Set from "../../ff/core/Set.mjs"
86
+
87
+ import * as ff_core_Show from "../../ff/core/Show.mjs"
88
+
89
+ import * as ff_core_SourceLocation from "../../ff/core/SourceLocation.mjs"
90
+
91
+ import * as ff_core_Stack from "../../ff/core/Stack.mjs"
92
+
93
+ import * as ff_core_Stream from "../../ff/core/Stream.mjs"
94
+
95
+ import * as ff_core_String from "../../ff/core/String.mjs"
96
+
97
+ import * as ff_core_StringMap from "../../ff/core/StringMap.mjs"
98
+
99
+ import * as ff_core_Task from "../../ff/core/Task.mjs"
100
+
101
+ import * as ff_core_Try from "../../ff/core/Try.mjs"
102
+
103
+ import * as ff_core_Unit from "../../ff/core/Unit.mjs"
104
+
105
+ import * as ff_core_WebSocket from "../../ff/core/WebSocket.mjs"
106
+
107
+ // type Dependencies
108
+ export function Dependencies(workspace_, packages_, packagePaths_, singleFilePackages_) {
109
+ return {workspace_, packages_, packagePaths_, singleFilePackages_};
110
+ }
111
+
112
+ // type ResolvedDependencies
113
+ export function ResolvedDependencies(mainPackagePair_, packages_, packagePaths_, singleFilePackages_) {
114
+ return {mainPackagePair_, packages_, packagePaths_, singleFilePackages_};
115
+ }
116
+
117
+
118
+
119
+ export function process_(fetch_, path_) {
120
+ const workspace_ = ff_compiler_Workspace.loadWorkspace_(path_);
121
+ 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));
122
+ const packageInfo_ = ff_compiler_Dependencies.Dependencies_loadPackageInfo(self_, ff_compiler_Syntax.PackagePair("script", "script"), path_);
123
+ const newDependencies_ = ff_compiler_Dependencies.Dependencies_processPackageInfo(self_, packageInfo_);
124
+ ff_compiler_Dependencies.Dependencies_processDependencies(self_, path_, fetch_, newDependencies_);
125
+ 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);
126
+ return ff_compiler_Dependencies.ResolvedDependencies(packageInfo_.package_.packagePair_, self_.packages_, packagePaths_, self_.singleFilePackages_)
127
+ }
128
+
129
+ export function findScriptPackageLocation_(path_) {
130
+ const packageDirectory_ = ((ff_core_Path.Path_extension(path_) === ".ff")
131
+ ? ff_core_Option.Option_grab(ff_core_Path.Path_parent(path_))
132
+ : path_);
133
+ function go_(directory_) {
134
+ const packageFile_ = ff_core_Path.Path_slash(ff_core_Path.Path_slash(directory_, ".firefly"), "package.ff");
135
+ if(ff_core_Path.Path_exists(packageFile_, false, false, false)) {
136
+ return directory_
137
+ } else if((!ff_core_Option.Option_isEmpty(ff_core_Path.Path_parent(directory_)))) {
138
+ return go_(ff_core_Option.Option_grab(ff_core_Path.Path_parent(directory_)))
139
+ } else {
140
+ return packageDirectory_
141
+ }
142
+ }
143
+ return go_(packageDirectory_)
144
+ }
145
+
146
+ export function checkPackagePairs_(dependencyPair_, packagePair_) {
147
+ if(((packagePair_.group_ !== dependencyPair_.group_) || (packagePair_.name_ !== dependencyPair_.name_))) {
148
+ 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_, ":")))
149
+ }
150
+ }
151
+
152
+ export function internalExtractTarGz_(tarGzPath_, path_) {
153
+ throw new Error('Function internalExtractTarGz is missing on this target in sync context.');
154
+ }
155
+
156
+ export async function process_$(fetch_, path_, $task) {
157
+ const workspace_ = (await ff_compiler_Workspace.loadWorkspace_$(path_, $task));
158
+ 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));
159
+ const packageInfo_ = (await ff_compiler_Dependencies.Dependencies_loadPackageInfo$(self_, ff_compiler_Syntax.PackagePair("script", "script"), path_, $task));
160
+ const newDependencies_ = (await ff_compiler_Dependencies.Dependencies_processPackageInfo$(self_, packageInfo_, $task));
161
+ (await ff_compiler_Dependencies.Dependencies_processDependencies$(self_, path_, fetch_, newDependencies_, $task));
162
+ 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);
163
+ return ff_compiler_Dependencies.ResolvedDependencies(packageInfo_.package_.packagePair_, self_.packages_, packagePaths_, self_.singleFilePackages_)
164
+ }
165
+
166
+ export async function findScriptPackageLocation_$(path_, $task) {
167
+ const packageDirectory_ = (((await ff_core_Path.Path_extension$(path_, $task)) === ".ff")
168
+ ? ff_core_Option.Option_grab((await ff_core_Path.Path_parent$(path_, $task)))
169
+ : path_);
170
+ async function go_$(directory_, $task) {
171
+ const packageFile_ = (await ff_core_Path.Path_slash$((await ff_core_Path.Path_slash$(directory_, ".firefly", $task)), "package.ff", $task));
172
+ if((await ff_core_Path.Path_exists$(packageFile_, false, false, false, $task))) {
173
+ return directory_
174
+ } else if((!ff_core_Option.Option_isEmpty((await ff_core_Path.Path_parent$(directory_, $task))))) {
175
+ return (await go_$(ff_core_Option.Option_grab((await ff_core_Path.Path_parent$(directory_, $task))), $task))
176
+ } else {
177
+ return packageDirectory_
178
+ }
179
+ }
180
+ return (await go_$(packageDirectory_, $task))
181
+ }
182
+
183
+ export async function checkPackagePairs_$(dependencyPair_, packagePair_, $task) {
184
+ if(((packagePair_.group_ !== dependencyPair_.group_) || (packagePair_.name_ !== dependencyPair_.name_))) {
185
+ 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_, ":")))
186
+ }
187
+ }
188
+
189
+ export async function internalExtractTarGz_$(tarGzPath_, path_, $task) {
186
190
 
187
191
  const tar = import$0
188
192
  await tar.extract({file: tarGzPath_, cwd: path_, strict: true})
189
-
190
- }
191
-
192
- export function Dependencies_loadPackageInfo(self_, packagePair_, path_) {
193
- const packageDirectory_ = ((ff_core_Path.Path_extension(path_) === ".ff")
194
- ? ff_core_Option.Option_grab(ff_core_Path.Path_parent(path_))
195
- : path_);
196
- const sharedPackageFile_ = ff_core_Path.Path_slash(ff_core_Path.Path_slash(packageDirectory_, ".firefly"), "package.ff");
197
- const packageFile_ = (ff_core_Path.Path_exists(sharedPackageFile_, false, false, false)
198
- ? sharedPackageFile_
199
- : (function() {
200
- self_.singleFilePackages_ = ff_core_Set.Set_add(self_.singleFilePackages_, packagePair_, ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair);
201
- return path_
202
- })());
203
- const code_ = ff_core_Path.Path_readText(packageFile_);
204
- return ff_compiler_Dependencies.Dependencies_parsePackageFile(self_, packagePair_, ff_core_Path.Path_relativeTo(packageFile_, path_), code_)
205
- }
206
-
207
- export function Dependencies_parsePackageFile(self_, packagePair_, fileName_, code_) {
208
- const tokens_ = ff_compiler_Tokenizer.tokenize_(fileName_, code_, ff_core_Option.None(), true);
209
- const parser_ = ff_compiler_Parser.make_(packagePair_, fileName_, tokens_, false, ff_compiler_LspHook.disabled_());
210
- const info_ = ff_compiler_Parser.Parser_parsePackageInfo(parser_);
211
- return ff_compiler_Dependencies.Dependencies_addCoreDependencyIfMissing(self_, info_)
212
- }
213
-
214
- export function Dependencies_addCoreDependencyIfMissing(self_, info_) {
215
- if(ff_core_List.List_any(info_.dependencies_, ((d_) => {
216
- return ((d_.packagePair_.group_ === "ff") && (d_.packagePair_.name_ === "core"))
217
- }))) {
218
- return info_
219
- } else {
220
- 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_);
221
- {
222
- const _1 = info_;
223
- {
224
- const _c = _1;
225
- return ff_compiler_Syntax.PackageInfo(_c.package_, ff_core_List.Link(coreDependency_, info_.dependencies_), _c.includes_)
226
- return
227
- }
228
- }
229
- }
230
- }
231
-
232
- export function Dependencies_processPackageInfo(self_, packageInfo_) {
233
- self_.packages_ = ff_core_Map.Map_add(self_.packages_, packageInfo_.package_.packagePair_, packageInfo_, ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair);
234
- return ff_core_List.List_filter(packageInfo_.dependencies_, ((_w1) => {
235
- return (!ff_core_Map.Map_contains(self_.packages_, _w1.packagePair_, ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair))
236
- }))
237
- }
238
-
239
- export function Dependencies_fetchDependency(self_, path_, httpClient_, dependency_) {
240
- const location_ = ff_compiler_Workspace.Workspace_findPackageLocation(self_.workspace_, dependency_.packagePair_, dependency_.version_);
241
- if((ff_core_String.String_contains(location_, ":") && (!ff_core_String.String_startsWith(ff_core_String.String_dropFirst(location_, 1), ":", 0)))) {
242
- if((ff_core_String.String_startsWith(location_, "http://", 0) || ff_core_String.String_startsWith(location_, "https://", 0))) {
243
- const packagePair_ = dependency_.packagePair_;
244
- const directory_ = (ff_core_Path.Path_isDirectory(path_)
245
- ? path_
246
- : ff_core_Option.Option_grab(ff_core_Path.Path_parent(path_)));
247
- const dependenciesPath_ = ff_core_Path.Path_slash(ff_core_Path.Path_slash(directory_, ".firefly"), "dependencies");
248
- const dependencyPath_ = ff_core_Path.Path_slash(ff_core_Path.Path_slash(dependenciesPath_, packagePair_.group_), packagePair_.name_);
249
- const tarGzPath_ = ff_core_Path.Path_slash(dependenciesPath_, ff_compiler_Workspace.tarGzName_(packagePair_, dependency_.version_));
250
- const donePath_ = ff_core_Path.Path_slash(dependenciesPath_, (ff_compiler_Workspace.tarGzName_(packagePair_, dependency_.version_) + ".done"));
251
- if((!ff_core_Path.Path_exists(donePath_, false, false, false))) {
252
- ff_core_Log.trace_(("Fetching " + location_));
253
- 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);
254
- if((!ff_core_HttpClient.FetchResponse_ok(response_))) {
255
- ff_core_Core.panic_(("Could not download dependency: " + location_))
256
- };
257
- const buffer_ = ff_core_HttpClient.FetchResponse_readBuffer(response_);
258
- if(ff_core_Path.Path_exists(dependencyPath_, false, false, false)) {
259
- ff_core_Path.Path_delete(dependencyPath_, 0, 100)
260
- };
261
- ff_core_Path.Path_createDirectory(dependencyPath_, true);
262
- ff_core_Path.Path_writeStream(tarGzPath_, ff_core_List.List_toStream(ff_core_List.Link(buffer_, ff_core_List.Empty()), false), false);
263
- ff_compiler_Dependencies.internalExtractTarGz_(tarGzPath_, dependencyPath_);
264
- ff_core_Path.Path_renameTo(tarGzPath_, donePath_)
265
- };
266
- return dependencyPath_
267
- } else {
268
- return ff_core_Core.panic_(("Loading packages by this protocol is not supported: " + location_))
269
- }
270
- } else {
271
- return ff_core_Path.Path_path(path_, location_)
272
- }
273
- }
274
-
275
- export function Dependencies_processDependencies(self_, path_, httpClient_, dependencies_) {
276
- const packageInfos_ = ff_core_List.List_map(dependencies_, ((dependency_) => {
277
- const dependencyPath_ = ff_compiler_Dependencies.Dependencies_fetchDependency(self_, path_, httpClient_, dependency_);
278
- self_.packagePaths_ = ff_core_Map.Map_add(self_.packagePaths_, dependency_.packagePair_, dependencyPath_, ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair);
279
- const packageInfo_ = ff_compiler_Dependencies.Dependencies_loadPackageInfo(self_, dependency_.packagePair_, dependencyPath_);
280
- ff_compiler_Dependencies.checkPackagePairs_(dependency_.packagePair_, packageInfo_.package_.packagePair_);
281
- return packageInfo_
282
- }));
283
- const newDependencies_ = ff_core_List.List_flatMap(packageInfos_, ((_w1) => {
284
- return ff_compiler_Dependencies.Dependencies_processPackageInfo(self_, _w1)
285
- }));
286
- 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))) {
287
- ff_compiler_Dependencies.Dependencies_processDependencies(self_, path_, httpClient_, newDependencies_)
288
- }
289
- }
290
-
291
- export async function Dependencies_loadPackageInfo$(self_, packagePair_, path_, $task) {
292
- const packageDirectory_ = (((await ff_core_Path.Path_extension$(path_, $task)) === ".ff")
293
- ? ff_core_Option.Option_grab((await ff_core_Path.Path_parent$(path_, $task)))
294
- : path_);
295
- const sharedPackageFile_ = (await ff_core_Path.Path_slash$((await ff_core_Path.Path_slash$(packageDirectory_, ".firefly", $task)), "package.ff", $task));
296
- const packageFile_ = ((await ff_core_Path.Path_exists$(sharedPackageFile_, false, false, false, $task))
297
- ? sharedPackageFile_
298
- : (await (async function() {
299
- self_.singleFilePackages_ = ff_core_Set.Set_add(self_.singleFilePackages_, packagePair_, ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair);
300
- return path_
301
- })()));
302
- const code_ = (await ff_core_Path.Path_readText$(packageFile_, $task));
303
- return (await ff_compiler_Dependencies.Dependencies_parsePackageFile$(self_, packagePair_, (await ff_core_Path.Path_relativeTo$(packageFile_, path_, $task)), code_, $task))
304
- }
305
-
306
- export async function Dependencies_parsePackageFile$(self_, packagePair_, fileName_, code_, $task) {
307
- const tokens_ = ff_compiler_Tokenizer.tokenize_(fileName_, code_, ff_core_Option.None(), true);
308
- const parser_ = ff_compiler_Parser.make_(packagePair_, fileName_, tokens_, false, ff_compiler_LspHook.disabled_());
309
- const info_ = ff_compiler_Parser.Parser_parsePackageInfo(parser_);
310
- return (await ff_compiler_Dependencies.Dependencies_addCoreDependencyIfMissing$(self_, info_, $task))
311
- }
312
-
313
- export async function Dependencies_addCoreDependencyIfMissing$(self_, info_, $task) {
314
- if(ff_core_List.List_any(info_.dependencies_, ((d_) => {
315
- return ((d_.packagePair_.group_ === "ff") && (d_.packagePair_.name_ === "core"))
316
- }))) {
317
- return info_
318
- } else {
319
- 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_);
320
- {
321
- const _1 = info_;
322
- {
323
- const _c = _1;
324
- return ff_compiler_Syntax.PackageInfo(_c.package_, ff_core_List.Link(coreDependency_, info_.dependencies_), _c.includes_)
325
- return
326
- }
327
- }
328
- }
329
- }
330
-
331
- export async function Dependencies_processPackageInfo$(self_, packageInfo_, $task) {
332
- self_.packages_ = ff_core_Map.Map_add(self_.packages_, packageInfo_.package_.packagePair_, packageInfo_, ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair);
333
- return ff_core_List.List_filter(packageInfo_.dependencies_, ((_w1) => {
334
- return (!ff_core_Map.Map_contains(self_.packages_, _w1.packagePair_, ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair))
335
- }))
336
- }
337
-
338
- export async function Dependencies_fetchDependency$(self_, path_, httpClient_, dependency_, $task) {
339
- const location_ = ff_compiler_Workspace.Workspace_findPackageLocation(self_.workspace_, dependency_.packagePair_, dependency_.version_);
340
- if((ff_core_String.String_contains(location_, ":") && (!ff_core_String.String_startsWith(ff_core_String.String_dropFirst(location_, 1), ":", 0)))) {
341
- if((ff_core_String.String_startsWith(location_, "http://", 0) || ff_core_String.String_startsWith(location_, "https://", 0))) {
342
- const packagePair_ = dependency_.packagePair_;
343
- const directory_ = ((await ff_core_Path.Path_isDirectory$(path_, $task))
344
- ? path_
345
- : ff_core_Option.Option_grab((await ff_core_Path.Path_parent$(path_, $task))));
346
- const dependenciesPath_ = (await ff_core_Path.Path_slash$((await ff_core_Path.Path_slash$(directory_, ".firefly", $task)), "dependencies", $task));
347
- const dependencyPath_ = (await ff_core_Path.Path_slash$((await ff_core_Path.Path_slash$(dependenciesPath_, packagePair_.group_, $task)), packagePair_.name_, $task));
348
- const tarGzPath_ = (await ff_core_Path.Path_slash$(dependenciesPath_, ff_compiler_Workspace.tarGzName_(packagePair_, dependency_.version_), $task));
349
- const donePath_ = (await ff_core_Path.Path_slash$(dependenciesPath_, (ff_compiler_Workspace.tarGzName_(packagePair_, dependency_.version_) + ".done"), $task));
350
- if((!(await ff_core_Path.Path_exists$(donePath_, false, false, false, $task)))) {
351
- ff_core_Log.trace_(("Fetching " + location_));
352
- 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));
353
- if((!(await ff_core_HttpClient.FetchResponse_ok$(response_, $task)))) {
354
- ff_core_Core.panic_(("Could not download dependency: " + location_))
355
- };
356
- const buffer_ = (await ff_core_HttpClient.FetchResponse_readBuffer$(response_, $task));
357
- if((await ff_core_Path.Path_exists$(dependencyPath_, false, false, false, $task))) {
358
- (await ff_core_Path.Path_delete$(dependencyPath_, 0, 100, $task))
359
- };
360
- (await ff_core_Path.Path_createDirectory$(dependencyPath_, true, $task));
361
- (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));
362
- (await ff_compiler_Dependencies.internalExtractTarGz_$(tarGzPath_, dependencyPath_, $task));
363
- (await ff_core_Path.Path_renameTo$(tarGzPath_, donePath_, $task))
364
- };
365
- return dependencyPath_
366
- } else {
367
- return ff_core_Core.panic_(("Loading packages by this protocol is not supported: " + location_))
368
- }
369
- } else {
370
- return (await ff_core_Path.Path_path$(path_, location_, $task))
371
- }
372
- }
373
-
374
- export async function Dependencies_processDependencies$(self_, path_, httpClient_, dependencies_, $task) {
375
- const packageInfos_ = (await ff_core_List.List_map$(dependencies_, (async (dependency_, $task) => {
376
- const dependencyPath_ = (await ff_compiler_Dependencies.Dependencies_fetchDependency$(self_, path_, httpClient_, dependency_, $task));
377
- self_.packagePaths_ = ff_core_Map.Map_add(self_.packagePaths_, dependency_.packagePair_, dependencyPath_, ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair);
378
- const packageInfo_ = (await ff_compiler_Dependencies.Dependencies_loadPackageInfo$(self_, dependency_.packagePair_, dependencyPath_, $task));
379
- ff_compiler_Dependencies.checkPackagePairs_(dependency_.packagePair_, packageInfo_.package_.packagePair_);
380
- return packageInfo_
381
- }), $task));
382
- const newDependencies_ = (await ff_core_List.List_flatMap$(packageInfos_, (async (_w1, $task) => {
383
- return (await ff_compiler_Dependencies.Dependencies_processPackageInfo$(self_, _w1, $task))
384
- }), $task));
385
- 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))) {
386
- (await ff_compiler_Dependencies.Dependencies_processDependencies$(self_, path_, httpClient_, newDependencies_, $task))
387
- }
388
- }
389
-
390
-
391
-
392
-
193
+
194
+ }
195
+
196
+ export function Dependencies_loadPackageInfo(self_, packagePair_, path_) {
197
+ const packageDirectory_ = ((ff_core_Path.Path_extension(path_) === ".ff")
198
+ ? ff_core_Option.Option_grab(ff_core_Path.Path_parent(path_))
199
+ : path_);
200
+ const sharedPackageFile_ = ff_core_Path.Path_slash(ff_core_Path.Path_slash(packageDirectory_, ".firefly"), "package.ff");
201
+ const packageFile_ = (ff_core_Path.Path_exists(sharedPackageFile_, false, false, false)
202
+ ? sharedPackageFile_
203
+ : (function() {
204
+ self_.singleFilePackages_ = ff_core_Set.Set_add(self_.singleFilePackages_, packagePair_, ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair);
205
+ return path_
206
+ })());
207
+ const code_ = ff_core_Path.Path_readText(packageFile_);
208
+ return ff_compiler_Dependencies.Dependencies_parsePackageFile(self_, packagePair_, ff_core_Path.Path_relativeTo(packageFile_, path_), code_)
209
+ }
210
+
211
+ export function Dependencies_parsePackageFile(self_, packagePair_, fileName_, code_) {
212
+ const tokens_ = ff_compiler_Tokenizer.tokenize_(fileName_, code_, ff_core_Option.None(), true);
213
+ const parser_ = ff_compiler_Parser.make_(packagePair_, fileName_, tokens_, false, ff_compiler_LspHook.disabled_());
214
+ const info_ = ff_compiler_Parser.Parser_parsePackageInfo(parser_);
215
+ return ff_compiler_Dependencies.Dependencies_addCoreDependencyIfMissing(self_, info_)
216
+ }
217
+
218
+ export function Dependencies_addCoreDependencyIfMissing(self_, info_) {
219
+ if(ff_core_List.List_any(info_.dependencies_, ((d_) => {
220
+ return ((d_.packagePair_.group_ === "ff") && (d_.packagePair_.name_ === "core"))
221
+ }))) {
222
+ return info_
223
+ } else {
224
+ 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_);
225
+ {
226
+ const _1 = info_;
227
+ {
228
+ const _c = _1;
229
+ return ff_compiler_Syntax.PackageInfo(_c.package_, ff_core_List.Link(coreDependency_, info_.dependencies_), _c.includes_)
230
+ return
231
+ }
232
+ }
233
+ }
234
+ }
235
+
236
+ export function Dependencies_processPackageInfo(self_, packageInfo_) {
237
+ self_.packages_ = ff_core_Map.Map_add(self_.packages_, packageInfo_.package_.packagePair_, packageInfo_, ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair);
238
+ return ff_core_List.List_filter(packageInfo_.dependencies_, ((_w1) => {
239
+ return (!ff_core_Map.Map_contains(self_.packages_, _w1.packagePair_, ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair))
240
+ }))
241
+ }
242
+
243
+ export function Dependencies_fetchDependency(self_, path_, httpClient_, dependency_) {
244
+ const location_ = ff_compiler_Workspace.Workspace_findPackageLocation(self_.workspace_, dependency_.packagePair_, dependency_.version_);
245
+ if((ff_core_String.String_contains(location_, ":") && (!ff_core_String.String_startsWith(ff_core_String.String_dropFirst(location_, 1), ":", 0)))) {
246
+ if((ff_core_String.String_startsWith(location_, "http://", 0) || ff_core_String.String_startsWith(location_, "https://", 0))) {
247
+ const packagePair_ = dependency_.packagePair_;
248
+ const directory_ = (ff_core_Path.Path_isDirectory(path_)
249
+ ? path_
250
+ : ff_core_Option.Option_grab(ff_core_Path.Path_parent(path_)));
251
+ const dependenciesPath_ = ff_core_Path.Path_slash(ff_core_Path.Path_slash(directory_, ".firefly"), "dependencies");
252
+ const dependencyPath_ = ff_core_Path.Path_slash(ff_core_Path.Path_slash(dependenciesPath_, packagePair_.group_), packagePair_.name_);
253
+ const tarGzPath_ = ff_core_Path.Path_slash(dependenciesPath_, ff_compiler_Workspace.tarGzName_(packagePair_, dependency_.version_));
254
+ const donePath_ = ff_core_Path.Path_slash(dependenciesPath_, (ff_compiler_Workspace.tarGzName_(packagePair_, dependency_.version_) + ".done"));
255
+ if((!ff_core_Path.Path_exists(donePath_, false, false, false))) {
256
+ ff_core_Log.trace_(("Fetching " + location_));
257
+ 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);
258
+ if((!ff_core_HttpClient.FetchResponse_ok(response_))) {
259
+ ff_core_Core.panic_(("Could not download dependency: " + location_))
260
+ };
261
+ const buffer_ = ff_core_HttpClient.FetchResponse_readBuffer(response_);
262
+ if(ff_core_Path.Path_exists(dependencyPath_, false, false, false)) {
263
+ ff_core_Path.Path_delete(dependencyPath_, 0, 100)
264
+ };
265
+ ff_core_Path.Path_createDirectory(dependencyPath_, true);
266
+ ff_core_Path.Path_writeStream(tarGzPath_, ff_core_List.List_toStream(ff_core_List.Link(buffer_, ff_core_List.Empty()), false), false);
267
+ ff_compiler_Dependencies.internalExtractTarGz_(tarGzPath_, dependencyPath_);
268
+ ff_core_Path.Path_renameTo(tarGzPath_, donePath_)
269
+ };
270
+ return dependencyPath_
271
+ } else {
272
+ return ff_core_Core.panic_(("Loading packages by this protocol is not supported: " + location_))
273
+ }
274
+ } else {
275
+ return ff_core_Path.Path_path(path_, location_)
276
+ }
277
+ }
278
+
279
+ export function Dependencies_processDependencies(self_, path_, httpClient_, dependencies_) {
280
+ const packageInfos_ = ff_core_List.List_map(dependencies_, ((dependency_) => {
281
+ const dependencyPath_ = ff_compiler_Dependencies.Dependencies_fetchDependency(self_, path_, httpClient_, dependency_);
282
+ self_.packagePaths_ = ff_core_Map.Map_add(self_.packagePaths_, dependency_.packagePair_, dependencyPath_, ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair);
283
+ const packageInfo_ = ff_compiler_Dependencies.Dependencies_loadPackageInfo(self_, dependency_.packagePair_, dependencyPath_);
284
+ ff_compiler_Dependencies.checkPackagePairs_(dependency_.packagePair_, packageInfo_.package_.packagePair_);
285
+ return packageInfo_
286
+ }));
287
+ const newDependencies_ = ff_core_List.List_flatMap(packageInfos_, ((_w1) => {
288
+ return ff_compiler_Dependencies.Dependencies_processPackageInfo(self_, _w1)
289
+ }));
290
+ 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))) {
291
+ ff_compiler_Dependencies.Dependencies_processDependencies(self_, path_, httpClient_, newDependencies_)
292
+ }
293
+ }
294
+
295
+ export async function Dependencies_loadPackageInfo$(self_, packagePair_, path_, $task) {
296
+ const packageDirectory_ = (((await ff_core_Path.Path_extension$(path_, $task)) === ".ff")
297
+ ? ff_core_Option.Option_grab((await ff_core_Path.Path_parent$(path_, $task)))
298
+ : path_);
299
+ const sharedPackageFile_ = (await ff_core_Path.Path_slash$((await ff_core_Path.Path_slash$(packageDirectory_, ".firefly", $task)), "package.ff", $task));
300
+ const packageFile_ = ((await ff_core_Path.Path_exists$(sharedPackageFile_, false, false, false, $task))
301
+ ? sharedPackageFile_
302
+ : (await (async function() {
303
+ self_.singleFilePackages_ = ff_core_Set.Set_add(self_.singleFilePackages_, packagePair_, ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair);
304
+ return path_
305
+ })()));
306
+ const code_ = (await ff_core_Path.Path_readText$(packageFile_, $task));
307
+ return (await ff_compiler_Dependencies.Dependencies_parsePackageFile$(self_, packagePair_, (await ff_core_Path.Path_relativeTo$(packageFile_, path_, $task)), code_, $task))
308
+ }
309
+
310
+ export async function Dependencies_parsePackageFile$(self_, packagePair_, fileName_, code_, $task) {
311
+ const tokens_ = ff_compiler_Tokenizer.tokenize_(fileName_, code_, ff_core_Option.None(), true);
312
+ const parser_ = ff_compiler_Parser.make_(packagePair_, fileName_, tokens_, false, ff_compiler_LspHook.disabled_());
313
+ const info_ = ff_compiler_Parser.Parser_parsePackageInfo(parser_);
314
+ return (await ff_compiler_Dependencies.Dependencies_addCoreDependencyIfMissing$(self_, info_, $task))
315
+ }
316
+
317
+ export async function Dependencies_addCoreDependencyIfMissing$(self_, info_, $task) {
318
+ if(ff_core_List.List_any(info_.dependencies_, ((d_) => {
319
+ return ((d_.packagePair_.group_ === "ff") && (d_.packagePair_.name_ === "core"))
320
+ }))) {
321
+ return info_
322
+ } else {
323
+ 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_);
324
+ {
325
+ const _1 = info_;
326
+ {
327
+ const _c = _1;
328
+ return ff_compiler_Syntax.PackageInfo(_c.package_, ff_core_List.Link(coreDependency_, info_.dependencies_), _c.includes_)
329
+ return
330
+ }
331
+ }
332
+ }
333
+ }
334
+
335
+ export async function Dependencies_processPackageInfo$(self_, packageInfo_, $task) {
336
+ self_.packages_ = ff_core_Map.Map_add(self_.packages_, packageInfo_.package_.packagePair_, packageInfo_, ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair);
337
+ return ff_core_List.List_filter(packageInfo_.dependencies_, ((_w1) => {
338
+ return (!ff_core_Map.Map_contains(self_.packages_, _w1.packagePair_, ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair))
339
+ }))
340
+ }
341
+
342
+ export async function Dependencies_fetchDependency$(self_, path_, httpClient_, dependency_, $task) {
343
+ const location_ = ff_compiler_Workspace.Workspace_findPackageLocation(self_.workspace_, dependency_.packagePair_, dependency_.version_);
344
+ if((ff_core_String.String_contains(location_, ":") && (!ff_core_String.String_startsWith(ff_core_String.String_dropFirst(location_, 1), ":", 0)))) {
345
+ if((ff_core_String.String_startsWith(location_, "http://", 0) || ff_core_String.String_startsWith(location_, "https://", 0))) {
346
+ const packagePair_ = dependency_.packagePair_;
347
+ const directory_ = ((await ff_core_Path.Path_isDirectory$(path_, $task))
348
+ ? path_
349
+ : ff_core_Option.Option_grab((await ff_core_Path.Path_parent$(path_, $task))));
350
+ const dependenciesPath_ = (await ff_core_Path.Path_slash$((await ff_core_Path.Path_slash$(directory_, ".firefly", $task)), "dependencies", $task));
351
+ const dependencyPath_ = (await ff_core_Path.Path_slash$((await ff_core_Path.Path_slash$(dependenciesPath_, packagePair_.group_, $task)), packagePair_.name_, $task));
352
+ const tarGzPath_ = (await ff_core_Path.Path_slash$(dependenciesPath_, ff_compiler_Workspace.tarGzName_(packagePair_, dependency_.version_), $task));
353
+ const donePath_ = (await ff_core_Path.Path_slash$(dependenciesPath_, (ff_compiler_Workspace.tarGzName_(packagePair_, dependency_.version_) + ".done"), $task));
354
+ if((!(await ff_core_Path.Path_exists$(donePath_, false, false, false, $task)))) {
355
+ ff_core_Log.trace_(("Fetching " + location_));
356
+ 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));
357
+ if((!(await ff_core_HttpClient.FetchResponse_ok$(response_, $task)))) {
358
+ ff_core_Core.panic_(("Could not download dependency: " + location_))
359
+ };
360
+ const buffer_ = (await ff_core_HttpClient.FetchResponse_readBuffer$(response_, $task));
361
+ if((await ff_core_Path.Path_exists$(dependencyPath_, false, false, false, $task))) {
362
+ (await ff_core_Path.Path_delete$(dependencyPath_, 0, 100, $task))
363
+ };
364
+ (await ff_core_Path.Path_createDirectory$(dependencyPath_, true, $task));
365
+ (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));
366
+ (await ff_compiler_Dependencies.internalExtractTarGz_$(tarGzPath_, dependencyPath_, $task));
367
+ (await ff_core_Path.Path_renameTo$(tarGzPath_, donePath_, $task))
368
+ };
369
+ return dependencyPath_
370
+ } else {
371
+ return ff_core_Core.panic_(("Loading packages by this protocol is not supported: " + location_))
372
+ }
373
+ } else {
374
+ return (await ff_core_Path.Path_path$(path_, location_, $task))
375
+ }
376
+ }
377
+
378
+ export async function Dependencies_processDependencies$(self_, path_, httpClient_, dependencies_, $task) {
379
+ const packageInfos_ = (await ff_core_List.List_map$(dependencies_, (async (dependency_, $task) => {
380
+ const dependencyPath_ = (await ff_compiler_Dependencies.Dependencies_fetchDependency$(self_, path_, httpClient_, dependency_, $task));
381
+ self_.packagePaths_ = ff_core_Map.Map_add(self_.packagePaths_, dependency_.packagePair_, dependencyPath_, ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair);
382
+ const packageInfo_ = (await ff_compiler_Dependencies.Dependencies_loadPackageInfo$(self_, dependency_.packagePair_, dependencyPath_, $task));
383
+ ff_compiler_Dependencies.checkPackagePairs_(dependency_.packagePair_, packageInfo_.package_.packagePair_);
384
+ return packageInfo_
385
+ }), $task));
386
+ const newDependencies_ = (await ff_core_List.List_flatMap$(packageInfos_, (async (_w1, $task) => {
387
+ return (await ff_compiler_Dependencies.Dependencies_processPackageInfo$(self_, _w1, $task))
388
+ }), $task));
389
+ 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))) {
390
+ (await ff_compiler_Dependencies.Dependencies_processDependencies$(self_, path_, httpClient_, newDependencies_, $task))
391
+ }
392
+ }
393
+
394
+
395
+
396
+