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,266 +1,270 @@
1
-
2
-
3
- import * as ff_compiler_JsImporter from "../../ff/compiler/JsImporter.mjs"
4
-
5
- import * as ff_compiler_Syntax from "../../ff/compiler/Syntax.mjs"
6
-
7
- import * as ff_core_Any from "../../ff/core/Any.mjs"
8
-
9
- import * as ff_core_Array from "../../ff/core/Array.mjs"
10
-
11
- import * as ff_core_AssetSystem from "../../ff/core/AssetSystem.mjs"
12
-
13
- import * as ff_core_Atomic from "../../ff/core/Atomic.mjs"
14
-
15
- import * as ff_core_Bool from "../../ff/core/Bool.mjs"
16
-
17
- import * as ff_core_Box from "../../ff/core/Box.mjs"
18
-
19
- import * as ff_core_BrowserSystem from "../../ff/core/BrowserSystem.mjs"
20
-
21
- import * as ff_core_Buffer from "../../ff/core/Buffer.mjs"
22
-
23
- import * as ff_core_BuildSystem from "../../ff/core/BuildSystem.mjs"
24
-
25
- import * as ff_core_Channel from "../../ff/core/Channel.mjs"
26
-
27
- import * as ff_core_Char from "../../ff/core/Char.mjs"
28
-
29
- import * as ff_core_Core from "../../ff/core/Core.mjs"
30
-
31
- import * as ff_core_Duration from "../../ff/core/Duration.mjs"
32
-
33
- import * as ff_core_Equal from "../../ff/core/Equal.mjs"
34
-
35
- import * as ff_core_Error from "../../ff/core/Error.mjs"
36
-
37
- import * as ff_core_FileHandle from "../../ff/core/FileHandle.mjs"
38
-
39
- import * as ff_core_Float from "../../ff/core/Float.mjs"
40
-
41
- import * as ff_core_HttpClient from "../../ff/core/HttpClient.mjs"
42
-
43
- import * as ff_core_Instant from "../../ff/core/Instant.mjs"
44
-
45
- import * as ff_core_Int from "../../ff/core/Int.mjs"
46
-
47
- import * as ff_core_IntMap from "../../ff/core/IntMap.mjs"
48
-
49
- import * as ff_core_JsSystem from "../../ff/core/JsSystem.mjs"
50
-
51
- import * as ff_core_JsValue from "../../ff/core/JsValue.mjs"
52
-
53
- import * as ff_core_List from "../../ff/core/List.mjs"
54
-
55
- import * as ff_core_Lock from "../../ff/core/Lock.mjs"
56
-
57
- import * as ff_core_Log from "../../ff/core/Log.mjs"
58
-
59
- import * as ff_core_Map from "../../ff/core/Map.mjs"
60
-
61
- import * as ff_core_NodeSystem from "../../ff/core/NodeSystem.mjs"
62
-
63
- import * as ff_core_Nothing from "../../ff/core/Nothing.mjs"
64
-
65
- import * as ff_core_Option from "../../ff/core/Option.mjs"
66
-
67
- import * as ff_core_Ordering from "../../ff/core/Ordering.mjs"
68
-
69
- import * as ff_core_Pair from "../../ff/core/Pair.mjs"
70
-
71
- import * as ff_core_Path from "../../ff/core/Path.mjs"
72
-
73
- import * as ff_core_Serializable from "../../ff/core/Serializable.mjs"
74
-
75
- import * as ff_core_Set from "../../ff/core/Set.mjs"
76
-
77
- import * as ff_core_Show from "../../ff/core/Show.mjs"
78
-
79
- import * as ff_core_SourceLocation from "../../ff/core/SourceLocation.mjs"
80
-
81
- import * as ff_core_Stack from "../../ff/core/Stack.mjs"
82
-
83
- import * as ff_core_Stream from "../../ff/core/Stream.mjs"
84
-
85
- import * as ff_core_String from "../../ff/core/String.mjs"
86
-
87
- import * as ff_core_StringMap from "../../ff/core/StringMap.mjs"
88
-
89
- import * as ff_core_Task from "../../ff/core/Task.mjs"
90
-
91
- import * as ff_core_Try from "../../ff/core/Try.mjs"
92
-
93
- import * as ff_core_Unit from "../../ff/core/Unit.mjs"
94
-
95
- // type JsImporter
96
- export function JsImporter(imports_) {
97
- return {imports_};
98
- }
99
-
100
-
101
-
102
- export function make_() {
103
- return ff_compiler_JsImporter.JsImporter(ff_core_Map.empty_())
104
- }
105
-
106
- export function fail_(at_, message_) {
107
- return ff_core_Core.panic_(((message_ + " ") + ff_compiler_Syntax.Location_show(at_)))
108
- }
109
-
110
- export async function make_$($task) {
111
- return ff_compiler_JsImporter.JsImporter(ff_core_Map.empty_())
112
- }
113
-
114
- export async function fail_$(at_, message_, $task) {
115
- return ff_core_Core.panic_(((message_ + " ") + ff_compiler_Syntax.Location_show(at_)))
116
- }
117
-
118
- export function JsImporter_add(self_, url_) {
119
- const importName_ = (((_1) => {
120
- {
121
- if(_1.None) {
122
- const n_ = ("import$" + ff_core_Map.Map_size(self_.imports_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String));
123
- self_.imports_ = ff_core_Map.Map_add(self_.imports_, url_, n_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
124
- return n_
125
- return
126
- }
127
- }
128
- {
129
- if(_1.Some) {
130
- const n_ = _1.value_;
131
- return n_
132
- return
133
- }
134
- }
135
- }))(ff_core_Map.Map_get(self_.imports_, url_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String));
136
- return importName_
137
- }
138
-
139
- export function JsImporter_process(self_, at_, code_) {
140
- const space_ = ff_core_String.String_takeWhile(code_, ((c_) => {
141
- return (((((c_ === 32) || (c_ === 9)) || (c_ === 13)) || (c_ === 10)) || (c_ === 59))
142
- }));
143
- const rest_ = ff_core_String.String_dropFirst(code_, ff_core_String.String_size(space_));
144
- if((!ff_core_String.String_startsWith(rest_, "import * as ", 0))) {
145
- return code_
146
- } else {
147
- const rest2_ = ff_core_String.String_dropFirst(rest_, ff_core_String.String_size("import * as "));
148
- const name_ = ff_core_String.String_takeWhile(rest2_, ((_w1) => {
149
- return ff_core_Char.Char_isAsciiLetterOrDigit(_w1)
150
- }));
151
- if((ff_core_String.String_size(name_) === 0)) {
152
- throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, "Expected alias after \"import * as \""), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
153
- };
154
- const rest3_ = ff_core_String.String_dropFirst(rest2_, ff_core_String.String_size(name_));
155
- if((!ff_core_String.String_startsWith(rest3_, " from '", 0))) {
156
- throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, "Expected \" from '\" after \"import * as ...\""), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
157
- };
158
- const rest4_ = ff_core_String.String_dropFirst(rest3_, ff_core_String.String_size(" from '"));
159
- const url_ = ff_core_String.String_takeWhile(rest4_, ((_w1) => {
160
- return (_w1 !== 39)
161
- }));
162
- if((ff_core_String.String_size(url_) === 0)) {
163
- throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, "Expected module name after \" from '\""), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
164
- };
165
- if(ff_core_String.String_any(url_, ((_w1) => {
166
- return (_w1 === 10)
167
- }))) {
168
- throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, "Unclosed module name string"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
169
- };
170
- const rest5_ = ff_core_String.String_dropFirst(rest4_, (ff_core_String.String_size(url_) + 1));
171
- const importName_ = ff_compiler_JsImporter.JsImporter_add(self_, url_);
172
- return (((((space_ + "const ") + name_) + " = ") + importName_) + ff_compiler_JsImporter.JsImporter_process(self_, at_, rest5_))
173
- }
174
- }
175
-
176
- export function JsImporter_generateImports(self_, ignoreModules_) {
177
- return ff_core_List.List_map(ff_core_Map.Map_pairs(self_.imports_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ((_1) => {
178
- {
179
- const moduleName_ = _1.first_;
180
- const mangledName_ = _1.second_;
181
- if(ff_core_Set.Set_contains(ignoreModules_, moduleName_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)) {
182
- return (("const " + mangledName_) + " = void 0; // Ignored import")
183
- } else {
184
- return (((("import * as " + mangledName_) + " from '") + moduleName_) + "';")
185
- }
186
- return
187
- }
188
- }))
189
- }
190
-
191
- export async function JsImporter_add$(self_, url_, $task) {
192
- const importName_ = (((_1) => {
193
- {
194
- if(_1.None) {
195
- const n_ = ("import$" + ff_core_Map.Map_size(self_.imports_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String));
196
- self_.imports_ = ff_core_Map.Map_add(self_.imports_, url_, n_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
197
- return n_
198
- return
199
- }
200
- }
201
- {
202
- if(_1.Some) {
203
- const n_ = _1.value_;
204
- return n_
205
- return
206
- }
207
- }
208
- }))(ff_core_Map.Map_get(self_.imports_, url_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String));
209
- return importName_
210
- }
211
-
212
- export async function JsImporter_process$(self_, at_, code_, $task) {
213
- const space_ = ff_core_String.String_takeWhile(code_, ((c_) => {
214
- return (((((c_ === 32) || (c_ === 9)) || (c_ === 13)) || (c_ === 10)) || (c_ === 59))
215
- }));
216
- const rest_ = ff_core_String.String_dropFirst(code_, ff_core_String.String_size(space_));
217
- if((!ff_core_String.String_startsWith(rest_, "import * as ", 0))) {
218
- return code_
219
- } else {
220
- const rest2_ = ff_core_String.String_dropFirst(rest_, ff_core_String.String_size("import * as "));
221
- const name_ = ff_core_String.String_takeWhile(rest2_, ((_w1) => {
222
- return ff_core_Char.Char_isAsciiLetterOrDigit(_w1)
223
- }));
224
- if((ff_core_String.String_size(name_) === 0)) {
225
- throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, "Expected alias after \"import * as \""), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
226
- };
227
- const rest3_ = ff_core_String.String_dropFirst(rest2_, ff_core_String.String_size(name_));
228
- if((!ff_core_String.String_startsWith(rest3_, " from '", 0))) {
229
- throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, "Expected \" from '\" after \"import * as ...\""), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
230
- };
231
- const rest4_ = ff_core_String.String_dropFirst(rest3_, ff_core_String.String_size(" from '"));
232
- const url_ = ff_core_String.String_takeWhile(rest4_, ((_w1) => {
233
- return (_w1 !== 39)
234
- }));
235
- if((ff_core_String.String_size(url_) === 0)) {
236
- throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, "Expected module name after \" from '\""), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
237
- };
238
- if(ff_core_String.String_any(url_, ((_w1) => {
239
- return (_w1 === 10)
240
- }))) {
241
- throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, "Unclosed module name string"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
242
- };
243
- const rest5_ = ff_core_String.String_dropFirst(rest4_, (ff_core_String.String_size(url_) + 1));
244
- const importName_ = ff_compiler_JsImporter.JsImporter_add(self_, url_);
245
- return (((((space_ + "const ") + name_) + " = ") + importName_) + ff_compiler_JsImporter.JsImporter_process(self_, at_, rest5_))
246
- }
247
- }
248
-
249
- export async function JsImporter_generateImports$(self_, ignoreModules_, $task) {
250
- return ff_core_List.List_map(ff_core_Map.Map_pairs(self_.imports_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ((_1) => {
251
- {
252
- const moduleName_ = _1.first_;
253
- const mangledName_ = _1.second_;
254
- if(ff_core_Set.Set_contains(ignoreModules_, moduleName_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)) {
255
- return (("const " + mangledName_) + " = void 0; // Ignored import")
256
- } else {
257
- return (((("import * as " + mangledName_) + " from '") + moduleName_) + "';")
258
- }
259
- return
260
- }
261
- }))
262
- }
263
-
264
-
265
-
266
-
1
+
2
+
3
+ import * as ff_compiler_JsImporter from "../../ff/compiler/JsImporter.mjs"
4
+
5
+ import * as ff_compiler_Syntax from "../../ff/compiler/Syntax.mjs"
6
+
7
+ import * as ff_core_Any from "../../ff/core/Any.mjs"
8
+
9
+ import * as ff_core_Array from "../../ff/core/Array.mjs"
10
+
11
+ import * as ff_core_AssetSystem from "../../ff/core/AssetSystem.mjs"
12
+
13
+ import * as ff_core_Atomic from "../../ff/core/Atomic.mjs"
14
+
15
+ import * as ff_core_Bool from "../../ff/core/Bool.mjs"
16
+
17
+ import * as ff_core_Box from "../../ff/core/Box.mjs"
18
+
19
+ import * as ff_core_BrowserSystem from "../../ff/core/BrowserSystem.mjs"
20
+
21
+ import * as ff_core_Buffer from "../../ff/core/Buffer.mjs"
22
+
23
+ import * as ff_core_BuildSystem from "../../ff/core/BuildSystem.mjs"
24
+
25
+ import * as ff_core_Channel from "../../ff/core/Channel.mjs"
26
+
27
+ import * as ff_core_Char from "../../ff/core/Char.mjs"
28
+
29
+ import * as ff_core_Core from "../../ff/core/Core.mjs"
30
+
31
+ import * as ff_core_Duration from "../../ff/core/Duration.mjs"
32
+
33
+ import * as ff_core_Equal from "../../ff/core/Equal.mjs"
34
+
35
+ import * as ff_core_Error from "../../ff/core/Error.mjs"
36
+
37
+ import * as ff_core_FileHandle from "../../ff/core/FileHandle.mjs"
38
+
39
+ import * as ff_core_Float from "../../ff/core/Float.mjs"
40
+
41
+ import * as ff_core_HttpClient from "../../ff/core/HttpClient.mjs"
42
+
43
+ import * as ff_core_Instant from "../../ff/core/Instant.mjs"
44
+
45
+ import * as ff_core_Int from "../../ff/core/Int.mjs"
46
+
47
+ import * as ff_core_IntMap from "../../ff/core/IntMap.mjs"
48
+
49
+ import * as ff_core_JsSystem from "../../ff/core/JsSystem.mjs"
50
+
51
+ import * as ff_core_JsValue from "../../ff/core/JsValue.mjs"
52
+
53
+ import * as ff_core_List from "../../ff/core/List.mjs"
54
+
55
+ import * as ff_core_Lock from "../../ff/core/Lock.mjs"
56
+
57
+ import * as ff_core_Log from "../../ff/core/Log.mjs"
58
+
59
+ import * as ff_core_Map from "../../ff/core/Map.mjs"
60
+
61
+ import * as ff_core_NodeSystem from "../../ff/core/NodeSystem.mjs"
62
+
63
+ import * as ff_core_Nothing from "../../ff/core/Nothing.mjs"
64
+
65
+ import * as ff_core_Option from "../../ff/core/Option.mjs"
66
+
67
+ import * as ff_core_Ordering from "../../ff/core/Ordering.mjs"
68
+
69
+ import * as ff_core_Pair from "../../ff/core/Pair.mjs"
70
+
71
+ import * as ff_core_Path from "../../ff/core/Path.mjs"
72
+
73
+ import * as ff_core_Random from "../../ff/core/Random.mjs"
74
+
75
+ import * as ff_core_Serializable from "../../ff/core/Serializable.mjs"
76
+
77
+ import * as ff_core_Set from "../../ff/core/Set.mjs"
78
+
79
+ import * as ff_core_Show from "../../ff/core/Show.mjs"
80
+
81
+ import * as ff_core_SourceLocation from "../../ff/core/SourceLocation.mjs"
82
+
83
+ import * as ff_core_Stack from "../../ff/core/Stack.mjs"
84
+
85
+ import * as ff_core_Stream from "../../ff/core/Stream.mjs"
86
+
87
+ import * as ff_core_String from "../../ff/core/String.mjs"
88
+
89
+ import * as ff_core_StringMap from "../../ff/core/StringMap.mjs"
90
+
91
+ import * as ff_core_Task from "../../ff/core/Task.mjs"
92
+
93
+ import * as ff_core_Try from "../../ff/core/Try.mjs"
94
+
95
+ import * as ff_core_Unit from "../../ff/core/Unit.mjs"
96
+
97
+ import * as ff_core_WebSocket from "../../ff/core/WebSocket.mjs"
98
+
99
+ // type JsImporter
100
+ export function JsImporter(imports_) {
101
+ return {imports_};
102
+ }
103
+
104
+
105
+
106
+ export function make_() {
107
+ return ff_compiler_JsImporter.JsImporter(ff_core_Map.empty_())
108
+ }
109
+
110
+ export function fail_(at_, message_) {
111
+ return ff_core_Core.panic_(((message_ + " ") + ff_compiler_Syntax.Location_show(at_)))
112
+ }
113
+
114
+ export async function make_$($task) {
115
+ return ff_compiler_JsImporter.JsImporter(ff_core_Map.empty_())
116
+ }
117
+
118
+ export async function fail_$(at_, message_, $task) {
119
+ return ff_core_Core.panic_(((message_ + " ") + ff_compiler_Syntax.Location_show(at_)))
120
+ }
121
+
122
+ export function JsImporter_add(self_, url_) {
123
+ const importName_ = (((_1) => {
124
+ {
125
+ if(_1.None) {
126
+ const n_ = ("import$" + ff_core_Map.Map_size(self_.imports_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String));
127
+ self_.imports_ = ff_core_Map.Map_add(self_.imports_, url_, n_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
128
+ return n_
129
+ return
130
+ }
131
+ }
132
+ {
133
+ if(_1.Some) {
134
+ const n_ = _1.value_;
135
+ return n_
136
+ return
137
+ }
138
+ }
139
+ }))(ff_core_Map.Map_get(self_.imports_, url_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String));
140
+ return importName_
141
+ }
142
+
143
+ export function JsImporter_process(self_, at_, code_) {
144
+ const space_ = ff_core_String.String_takeWhile(code_, ((c_) => {
145
+ return (((((c_ === 32) || (c_ === 9)) || (c_ === 13)) || (c_ === 10)) || (c_ === 59))
146
+ }));
147
+ const rest_ = ff_core_String.String_dropFirst(code_, ff_core_String.String_size(space_));
148
+ if((!ff_core_String.String_startsWith(rest_, "import * as ", 0))) {
149
+ return code_
150
+ } else {
151
+ const rest2_ = ff_core_String.String_dropFirst(rest_, ff_core_String.String_size("import * as "));
152
+ const name_ = ff_core_String.String_takeWhile(rest2_, ((_w1) => {
153
+ return ff_core_Char.Char_isAsciiLetterOrDigit(_w1)
154
+ }));
155
+ if((ff_core_String.String_size(name_) === 0)) {
156
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, "Expected alias after \"import * as \""), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
157
+ };
158
+ const rest3_ = ff_core_String.String_dropFirst(rest2_, ff_core_String.String_size(name_));
159
+ if((!ff_core_String.String_startsWith(rest3_, " from '", 0))) {
160
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, "Expected \" from '\" after \"import * as ...\""), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
161
+ };
162
+ const rest4_ = ff_core_String.String_dropFirst(rest3_, ff_core_String.String_size(" from '"));
163
+ const url_ = ff_core_String.String_takeWhile(rest4_, ((_w1) => {
164
+ return (_w1 !== 39)
165
+ }));
166
+ if((ff_core_String.String_size(url_) === 0)) {
167
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, "Expected module name after \" from '\""), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
168
+ };
169
+ if(ff_core_String.String_any(url_, ((_w1) => {
170
+ return (_w1 === 10)
171
+ }))) {
172
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, "Unclosed module name string"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
173
+ };
174
+ const rest5_ = ff_core_String.String_dropFirst(rest4_, (ff_core_String.String_size(url_) + 1));
175
+ const importName_ = ff_compiler_JsImporter.JsImporter_add(self_, url_);
176
+ return (((((space_ + "const ") + name_) + " = ") + importName_) + ff_compiler_JsImporter.JsImporter_process(self_, at_, rest5_))
177
+ }
178
+ }
179
+
180
+ export function JsImporter_generateImports(self_, ignoreModules_) {
181
+ return ff_core_List.List_map(ff_core_Map.Map_pairs(self_.imports_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ((_1) => {
182
+ {
183
+ const moduleName_ = _1.first_;
184
+ const mangledName_ = _1.second_;
185
+ if(ff_core_Set.Set_contains(ignoreModules_, moduleName_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)) {
186
+ return (("const " + mangledName_) + " = void 0; // Ignored import")
187
+ } else {
188
+ return (((("import * as " + mangledName_) + " from '") + moduleName_) + "';")
189
+ }
190
+ return
191
+ }
192
+ }))
193
+ }
194
+
195
+ export async function JsImporter_add$(self_, url_, $task) {
196
+ const importName_ = (((_1) => {
197
+ {
198
+ if(_1.None) {
199
+ const n_ = ("import$" + ff_core_Map.Map_size(self_.imports_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String));
200
+ self_.imports_ = ff_core_Map.Map_add(self_.imports_, url_, n_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
201
+ return n_
202
+ return
203
+ }
204
+ }
205
+ {
206
+ if(_1.Some) {
207
+ const n_ = _1.value_;
208
+ return n_
209
+ return
210
+ }
211
+ }
212
+ }))(ff_core_Map.Map_get(self_.imports_, url_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String));
213
+ return importName_
214
+ }
215
+
216
+ export async function JsImporter_process$(self_, at_, code_, $task) {
217
+ const space_ = ff_core_String.String_takeWhile(code_, ((c_) => {
218
+ return (((((c_ === 32) || (c_ === 9)) || (c_ === 13)) || (c_ === 10)) || (c_ === 59))
219
+ }));
220
+ const rest_ = ff_core_String.String_dropFirst(code_, ff_core_String.String_size(space_));
221
+ if((!ff_core_String.String_startsWith(rest_, "import * as ", 0))) {
222
+ return code_
223
+ } else {
224
+ const rest2_ = ff_core_String.String_dropFirst(rest_, ff_core_String.String_size("import * as "));
225
+ const name_ = ff_core_String.String_takeWhile(rest2_, ((_w1) => {
226
+ return ff_core_Char.Char_isAsciiLetterOrDigit(_w1)
227
+ }));
228
+ if((ff_core_String.String_size(name_) === 0)) {
229
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, "Expected alias after \"import * as \""), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
230
+ };
231
+ const rest3_ = ff_core_String.String_dropFirst(rest2_, ff_core_String.String_size(name_));
232
+ if((!ff_core_String.String_startsWith(rest3_, " from '", 0))) {
233
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, "Expected \" from '\" after \"import * as ...\""), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
234
+ };
235
+ const rest4_ = ff_core_String.String_dropFirst(rest3_, ff_core_String.String_size(" from '"));
236
+ const url_ = ff_core_String.String_takeWhile(rest4_, ((_w1) => {
237
+ return (_w1 !== 39)
238
+ }));
239
+ if((ff_core_String.String_size(url_) === 0)) {
240
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, "Expected module name after \" from '\""), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
241
+ };
242
+ if(ff_core_String.String_any(url_, ((_w1) => {
243
+ return (_w1 === 10)
244
+ }))) {
245
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, "Unclosed module name string"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
246
+ };
247
+ const rest5_ = ff_core_String.String_dropFirst(rest4_, (ff_core_String.String_size(url_) + 1));
248
+ const importName_ = ff_compiler_JsImporter.JsImporter_add(self_, url_);
249
+ return (((((space_ + "const ") + name_) + " = ") + importName_) + ff_compiler_JsImporter.JsImporter_process(self_, at_, rest5_))
250
+ }
251
+ }
252
+
253
+ export async function JsImporter_generateImports$(self_, ignoreModules_, $task) {
254
+ return ff_core_List.List_map(ff_core_Map.Map_pairs(self_.imports_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String), ((_1) => {
255
+ {
256
+ const moduleName_ = _1.first_;
257
+ const mangledName_ = _1.second_;
258
+ if(ff_core_Set.Set_contains(ignoreModules_, moduleName_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)) {
259
+ return (("const " + mangledName_) + " = void 0; // Ignored import")
260
+ } else {
261
+ return (((("import * as " + mangledName_) + " from '") + moduleName_) + "';")
262
+ }
263
+ return
264
+ }
265
+ }))
266
+ }
267
+
268
+
269
+
270
+