firefly-compiler 0.4.4 → 0.4.6

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 (98) hide show
  1. package/.hintrc +5 -0
  2. package/README.md +42 -61
  3. package/compiler/Compiler.ff +6 -2
  4. package/compiler/Deriver.ff +10 -0
  5. package/compiler/Environment.ff +2 -1
  6. package/compiler/JsEmitter.ff +29 -17
  7. package/compiler/Resolver.ff +1 -1
  8. package/core/.firefly/package.ff +1 -2
  9. package/core/Box.ff +7 -0
  10. package/core/BuildSystem.ff +5 -4
  11. package/core/Core.ff +4 -0
  12. package/core/HttpClient.ff +1 -1
  13. package/core/JsValue.ff +22 -1
  14. package/core/Lock.ff +4 -4
  15. package/core/NodeSystem.ff +12 -3
  16. package/core/Path.ff +1 -1
  17. package/core/SourceLocation.ff +41 -0
  18. package/core/Stack.ff +6 -6
  19. package/core/StringMap.ff +3 -3
  20. package/lsp/LanguageServer.ff +32 -7
  21. package/lsp/stderr.txt +1 -0
  22. package/lsp/stdin.txt +11 -0
  23. package/lsp/stdout.txt +41 -0
  24. package/lux/.firefly/package.ff +2 -0
  25. package/lux/Lux.ff +473 -0
  26. package/lux/LuxEvent.ff +116 -0
  27. package/lux/Main.ff +126 -0
  28. package/lux/Main2.ff +144 -0
  29. package/meetup/AutoCompletion.ff +6 -0
  30. package/output/js/ff/compiler/Builder.mjs +444 -440
  31. package/output/js/ff/compiler/Compiler.mjs +416 -410
  32. package/output/js/ff/compiler/Dependencies.mjs +389 -385
  33. package/output/js/ff/compiler/Deriver.mjs +1170 -1166
  34. package/output/js/ff/compiler/Dictionaries.mjs +1309 -1305
  35. package/output/js/ff/compiler/Environment.mjs +1015 -1005
  36. package/output/js/ff/compiler/Inference.mjs +4268 -4264
  37. package/output/js/ff/compiler/JsEmitter.mjs +5391 -5353
  38. package/output/js/ff/compiler/JsImporter.mjs +266 -262
  39. package/output/js/ff/compiler/LspHook.mjs +793 -789
  40. package/output/js/ff/compiler/Main.mjs +1699 -1695
  41. package/output/js/ff/compiler/Parser.mjs +4008 -4004
  42. package/output/js/ff/compiler/Patterns.mjs +927 -923
  43. package/output/js/ff/compiler/Resolver.mjs +2307 -2303
  44. package/output/js/ff/compiler/Substitution.mjs +1150 -1146
  45. package/output/js/ff/compiler/Syntax.mjs +12434 -12430
  46. package/output/js/ff/compiler/Token.mjs +3096 -3092
  47. package/output/js/ff/compiler/Tokenizer.mjs +593 -589
  48. package/output/js/ff/compiler/Unification.mjs +1752 -1748
  49. package/output/js/ff/compiler/Wildcards.mjs +608 -604
  50. package/output/js/ff/compiler/Workspace.mjs +687 -683
  51. package/output/js/ff/core/Any.mjs +143 -139
  52. package/output/js/ff/core/Array.mjs +547 -543
  53. package/output/js/ff/core/AssetSystem.mjs +274 -270
  54. package/output/js/ff/core/Atomic.mjs +154 -150
  55. package/output/js/ff/core/Bool.mjs +152 -141
  56. package/output/js/ff/core/Box.mjs +112 -0
  57. package/output/js/ff/core/BrowserSystem.mjs +126 -122
  58. package/output/js/ff/core/Buffer.mjs +395 -391
  59. package/output/js/ff/core/BuildSystem.mjs +296 -290
  60. package/output/js/ff/core/Channel.mjs +189 -185
  61. package/output/js/ff/core/Char.mjs +149 -145
  62. package/output/js/ff/core/Core.mjs +300 -288
  63. package/output/js/ff/core/Duration.mjs +116 -112
  64. package/output/js/ff/core/Equal.mjs +179 -175
  65. package/output/js/ff/core/Error.mjs +142 -138
  66. package/output/js/ff/core/FileHandle.mjs +150 -146
  67. package/output/js/ff/core/Float.mjs +225 -214
  68. package/output/js/ff/core/HttpClient.mjs +190 -186
  69. package/output/js/ff/core/Instant.mjs +109 -105
  70. package/output/js/ff/core/Int.mjs +265 -254
  71. package/output/js/ff/core/IntMap.mjs +280 -276
  72. package/output/js/ff/core/JsSystem.mjs +238 -234
  73. package/output/js/ff/core/JsValue.mjs +714 -664
  74. package/output/js/ff/core/List.mjs +2334 -2321
  75. package/output/js/ff/core/Lock.mjs +230 -226
  76. package/output/js/ff/core/Log.mjs +163 -159
  77. package/output/js/ff/core/Map.mjs +362 -358
  78. package/output/js/ff/core/NodeSystem.mjs +302 -283
  79. package/output/js/ff/core/Nothing.mjs +104 -100
  80. package/output/js/ff/core/Option.mjs +1015 -1002
  81. package/output/js/ff/core/Ordering.mjs +730 -726
  82. package/output/js/ff/core/Pair.mjs +331 -318
  83. package/output/js/ff/core/Path.mjs +546 -542
  84. package/output/js/ff/core/RbMap.mjs +1940 -1936
  85. package/output/js/ff/core/Serializable.mjs +428 -424
  86. package/output/js/ff/core/Set.mjs +254 -250
  87. package/output/js/ff/core/Show.mjs +205 -201
  88. package/output/js/ff/core/SourceLocation.mjs +229 -0
  89. package/output/js/ff/core/Stack.mjs +541 -537
  90. package/output/js/ff/core/Stream.mjs +1304 -1300
  91. package/output/js/ff/core/String.mjs +365 -354
  92. package/output/js/ff/core/StringMap.mjs +280 -276
  93. package/output/js/ff/core/Task.mjs +320 -316
  94. package/output/js/ff/core/Try.mjs +507 -503
  95. package/output/js/ff/core/Unit.mjs +151 -103
  96. package/package.json +29 -29
  97. package/vscode/package-lock.json +5 -5
  98. package/vscode/package.json +1 -1
@@ -1,388 +1,392 @@
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) {
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) {
182
186
 
183
187
  const tar = import$0
184
188
  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
-
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
+