firefly-compiler 0.4.31 → 0.4.33

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 (91) hide show
  1. package/bin/Release.ff +6 -0
  2. package/compiler/Builder.ff +15 -7
  3. package/compiler/Compiler.ff +13 -8
  4. package/compiler/Dependencies.ff +24 -17
  5. package/compiler/DependencyLock.ff +17 -0
  6. package/compiler/Deriver.ff +2 -1
  7. package/compiler/Dictionaries.ff +4 -4
  8. package/compiler/Environment.ff +3 -3
  9. package/compiler/Inference.ff +7 -7
  10. package/compiler/JsEmitter.ff +2 -2
  11. package/compiler/JsImporter.ff +2 -2
  12. package/compiler/LspHook.ff +2 -2
  13. package/compiler/Main.ff +22 -8
  14. package/compiler/ModuleCache.ff +6 -6
  15. package/compiler/Parser.ff +36 -36
  16. package/compiler/Resolver.ff +7 -7
  17. package/compiler/Syntax.ff +1 -1
  18. package/compiler/Tokenizer.ff +2 -2
  19. package/compiler/Unification.ff +3 -3
  20. package/compiler/Wildcards.ff +1 -1
  21. package/core/.firefly/include/package-lock.json +96 -96
  22. package/core/.firefly/include/package.json +1 -1
  23. package/core/Array.ff +2 -2
  24. package/core/Atomic.ff +1 -1
  25. package/core/Buffer.ff +1 -1
  26. package/core/Int.ff +2 -2
  27. package/core/IntMap.ff +4 -4
  28. package/core/Json.ff +5 -5
  29. package/core/List.ff +15 -15
  30. package/core/Map.ff +1 -1
  31. package/core/NodeSystem.ff +89 -0
  32. package/core/Option.ff +10 -3
  33. package/core/Random.ff +1 -1
  34. package/core/RbMap.ff +1 -1
  35. package/core/Serializable.ff +2 -2
  36. package/core/Set.ff +2 -2
  37. package/core/Stream.ff +4 -4
  38. package/core/StringMap.ff +4 -4
  39. package/experimental/random/Index.ff +53 -0
  40. package/experimental/random/MapTest.ff +2 -2
  41. package/experimental/random/Process.ff +120 -0
  42. package/experimental/random/RunLength.ff +2 -2
  43. package/experimental/random/Symbols.ff +2 -2
  44. package/lsp/CompletionHandler.ff +3 -6
  45. package/lsp/Handler.ff +45 -24
  46. package/lsp/LanguageServer.ff +13 -3
  47. package/lsp/SymbolHandler.ff +2 -2
  48. package/lsp/TestReferences.ff +2 -2
  49. package/lux/Lux.ff +6 -6
  50. package/output/js/ff/compiler/Builder.mjs +40 -28
  51. package/output/js/ff/compiler/Compiler.mjs +38 -14
  52. package/output/js/ff/compiler/Dependencies.mjs +30 -16
  53. package/output/js/ff/compiler/DependencyLock.mjs +128 -0
  54. package/output/js/ff/compiler/Deriver.mjs +4 -4
  55. package/output/js/ff/compiler/Dictionaries.mjs +8 -8
  56. package/output/js/ff/compiler/Environment.mjs +6 -6
  57. package/output/js/ff/compiler/Inference.mjs +12 -12
  58. package/output/js/ff/compiler/JsEmitter.mjs +4 -4
  59. package/output/js/ff/compiler/JsImporter.mjs +4 -4
  60. package/output/js/ff/compiler/LspHook.mjs +4 -4
  61. package/output/js/ff/compiler/Main.mjs +14 -12
  62. package/output/js/ff/compiler/ModuleCache.mjs +4 -4
  63. package/output/js/ff/compiler/Parser.mjs +72 -72
  64. package/output/js/ff/compiler/Resolver.mjs +14 -14
  65. package/output/js/ff/compiler/Syntax.mjs +2 -2
  66. package/output/js/ff/compiler/Tokenizer.mjs +4 -4
  67. package/output/js/ff/compiler/Unification.mjs +4 -4
  68. package/output/js/ff/compiler/Wildcards.mjs +2 -2
  69. package/output/js/ff/core/Array.mjs +5 -5
  70. package/output/js/ff/core/Atomic.mjs +3 -3
  71. package/output/js/ff/core/Buffer.mjs +3 -3
  72. package/output/js/ff/core/Int.mjs +4 -4
  73. package/output/js/ff/core/IntMap.mjs +9 -9
  74. package/output/js/ff/core/Json.mjs +10 -10
  75. package/output/js/ff/core/List.mjs +31 -31
  76. package/output/js/ff/core/Map.mjs +2 -2
  77. package/output/js/ff/core/NodeSystem.mjs +115 -0
  78. package/output/js/ff/core/Option.mjs +28 -2
  79. package/output/js/ff/core/Random.mjs +2 -2
  80. package/output/js/ff/core/RbMap.mjs +2 -2
  81. package/output/js/ff/core/Serializable.mjs +4 -4
  82. package/output/js/ff/core/Set.mjs +4 -4
  83. package/output/js/ff/core/Stream.mjs +8 -8
  84. package/output/js/ff/core/StringMap.mjs +9 -9
  85. package/package.json +1 -1
  86. package/postgresql/Pg.ff +2 -2
  87. package/rpc/Rpc.ff +3 -3
  88. package/vscode/package.json +1 -1
  89. package/webserver/WebServer.ff +2 -2
  90. package/httpserver/.firefly/package.ff +0 -1
  91. package/httpserver/HttpServer.ff +0 -184
package/lsp/Handler.ff CHANGED
@@ -8,6 +8,7 @@ import Environment from ff:compiler
8
8
  import Unification from ff:compiler
9
9
  import LspHook from ff:compiler
10
10
  import ModuleCache from ff:compiler
11
+ import DependencyLock from ff:compiler
11
12
  import HoverHandler
12
13
  import CompletionHandler
13
14
  import SignatureHelpHandler
@@ -21,6 +22,7 @@ capability Handler(
21
22
  mutable responseCache: Map[TokenRequestCacheKey, ResultOrError]
22
23
  mutable fileSymbolsCache: Map[String, List[DocumentSymbol]]
23
24
  moduleCache: ModuleCache
25
+ dependencyLock: DependencyLock
24
26
  )
25
27
 
26
28
  data TokenRequestCacheKey(
@@ -60,6 +62,9 @@ extend self: Handler {
60
62
  method.{
61
63
  | "initialized" =>
62
64
  []
65
+ | "textDocument/didOpen" =>
66
+ self.handleDidOpen(system, parameters)
67
+ []
63
68
  | "textDocument/didChange" =>
64
69
  self.handleDidChange(system, parameters)
65
70
  let diagnostics = self.handleFocusDiagnostic(system, parameters, version)
@@ -145,7 +150,7 @@ extend self: Handler {
145
150
  }
146
151
 
147
152
  handleInitialize(system: NodeSystem, parameters: Map[String, Json]): ResultOrError {
148
- self.rootPath = Some(system.pathFromUrl(parameters.grab("rootUri").grabString()))
153
+ self.rootPath = parameters.grab("rootUri").getString().map {system.pathFromUrl(_)}
149
154
 
150
155
  let anyFireflyFile = Json.object()
151
156
  .with("filters", [
@@ -206,12 +211,12 @@ extend self: Handler {
206
211
  Result(o.write())
207
212
  }
208
213
 
209
- handleDiagnostic(system: NodeSystem, parameters: Map[String, Json], version: Int): ResultOrError {
214
+ /*handleDiagnostic(system: NodeSystem, parameters: Map[String, Json], version: Int): ResultOrError {
210
215
  let js = system.js()
211
216
  let uri = parameters.grab("textDocument").field("uri").grabString()
212
217
  let path = system.pathFromUrl(uri)
213
218
  let fireflyPath = system.path(".")
214
- let errors = self.check(system, fireflyPath, path, None, Set.empty(), self.virtualFiles, version, LspHook.disabled(), True)
219
+ let errors = self.check(system, fireflyPath, path, None, Set.new(), self.virtualFiles, version, LspHook.disabled(), True)
215
220
  let diagnostics = errors.map {| CompileError(at, message) =>
216
221
  let tokenLocation = self.findToken(system, at)
217
222
  Json.object()
@@ -223,15 +228,15 @@ extend self: Handler {
223
228
  .with("kind", "full")
224
229
  .with("items", diagnostics)
225
230
  Result(o.write())
226
- }
231
+ }*/
227
232
 
228
233
  handleFocusDiagnostic(system: NodeSystem, parameters: Map[String, Json], version: Int): Json {
229
234
  let js = system.js()
230
235
  let uri = parameters.grab("textDocument").field("uri").grabString()
231
236
  let path = system.pathFromUrl(uri)
232
237
  let fireflyPath = system.path(".")
233
- let errors = self.check(system, fireflyPath, path, None, Set.empty(), self.virtualFiles, version, LspHook.disabled(), True)
234
- let diagnostics = errors.map {| CompileError(at, message) =>
238
+ let errors = self.check(system, fireflyPath, path, None, Set.new(), self.virtualFiles, version, LspHook.disabled(), True)
239
+ let diagnostics = errors.filter {_.at.file == path.absolute()}.map {| CompileError(at, message) =>
235
240
  let tokenLocation = self.findToken(system, at)
236
241
  Json.object()
237
242
  .with("range", self.tokenLocationToLspRange(tokenLocation))
@@ -265,10 +270,10 @@ extend self: Handler {
265
270
 
266
271
  getDocumentSymbols(system: NodeSystem, path: Path): List[DocumentSymbol] {
267
272
  try {
268
- let lspHook = LspHook.make(at = None, definedAt = None, insertIdentifier = False, trackSymbols = True)
273
+ let lspHook = LspHook.new(at = None, definedAt = None, insertIdentifier = False, trackSymbols = True)
269
274
  let code = self.virtualFiles.get(path.absolute()).else {path.readText()}
270
275
  let tokens = Tokenizer.tokenize(path.absolute(), code, None, True)
271
- let parser = Parser.make(PackagePair("script", "script"), path.absolute(), tokens, False, lspHook)
276
+ let parser = Parser.new(PackagePair("script", "script"), path.absolute(), tokens, False, lspHook)
272
277
  parser.parseModuleWithPackageInfo()
273
278
  SymbolHandler.readAllSymbols(lspHook.results())
274
279
  } catch {| CompileError(at, message), error =>
@@ -294,8 +299,14 @@ extend self: Handler {
294
299
  }
295
300
 
296
301
  handleWorkspaceSymbol(system: NodeSystem, parameters: Map[String, Json]): ResultOrError {
302
+ self.rootPath.or {Error(-32803 /*Request Failed*/, "Open a folder to enable workspace symbols")}: rootPath =>
303
+ let files = if(rootPath.isFile()) {
304
+ [rootPath]
305
+ } else {
306
+ self.printTime(system.mainTask(), "findFireflyFiles") {Builder.findFireflyFiles(rootPath, None, Set.new())}
307
+ }
308
+ let root = if(rootPath.isFile()) {rootPath.parent().grab()} else {rootPath}
297
309
  let query = parameters.grab("query").grabString()
298
- let files = self.printTime(system.mainTask(), "findFireflyFiles") {Builder.findFireflyFiles(self.rootPath.grab(), None, Set.empty())}
299
310
  let symbols = files.flatMap {file =>
300
311
  let documentSymbols = self.getDocumentSymbolsWithCache(system, file)
301
312
  let workspaceSymbols = documentSymbols.flatMap {SymbolHandler.documentToWorkspaceSymbols(_, None)}
@@ -306,7 +317,7 @@ extend self: Handler {
306
317
  }
307
318
  }
308
319
  let limitedSymbols = symbols.sortBy {_.name.size()}.takeFirst(100)
309
- let jsSymbols = limitedSymbols.map {SymbolHandler.workspaceSymbolToLsp(self.rootPath.grab(), _)}
320
+ let jsSymbols = limitedSymbols.map {SymbolHandler.workspaceSymbolToLsp(root, _)}
310
321
  Result(Json.array(jsSymbols).write())
311
322
  }
312
323
 
@@ -321,10 +332,19 @@ extend self: Handler {
321
332
  diagnostics.map {Pair("textDocument/publishDiagnostics", _)}
322
333
  }
323
334
 
335
+ handleDidOpen(system: NodeSystem, parameters: Map[String, Json]): Unit {
336
+ let uri = parameters.grab("textDocument").field("uri").grabString()
337
+ let path = system.pathFromUrl(uri)
338
+ if(self.rootPath.isEmpty()) {
339
+ Log.trace("Using file as rootPath: " + path.absolute())
340
+ self.rootPath = Some(path)
341
+ }
342
+ }
343
+
324
344
  handleDidChange(system: NodeSystem, parameters: Map[String, Json]): Unit {
325
345
  let uri = parameters.grab("textDocument").field("uri").grabString()
326
346
  let path = system.pathFromUrl(uri)
327
- self.responseCache = Map.empty()
347
+ self.responseCache = Map.new()
328
348
  self.fileSymbolsCache = self.fileSymbolsCache.remove(path.absolute())
329
349
  self.moduleCache.invalidate(path.absolute())
330
350
  let contentChanges = parameters.grab("contentChanges").grabArray()
@@ -342,9 +362,9 @@ extend self: Handler {
342
362
  }
343
363
 
344
364
  handleHover(system: NodeSystem, targetAt: Location, goToDefinition: Bool, version: Int): ResultOrError {
345
- let lspHook = LspHook.make(at = Some(targetAt), definedAt = None, insertIdentifier = False, trackSymbols = False)
365
+ let lspHook = LspHook.new(at = Some(targetAt), definedAt = None, insertIdentifier = False, trackSymbols = False)
346
366
  let path = system.path(targetAt.file)
347
- let errors = self.check(system, self.fireflyPath, path, None, Set.empty(), self.virtualFiles, version, lspHook, True)
367
+ let errors = self.check(system, self.fireflyPath, path, None, Set.new(), self.virtualFiles, version, lspHook, True)
348
368
  errors.each {| CompileError(at, message) =>
349
369
  Log.trace("handleHover check error: " + message)
350
370
  }
@@ -364,9 +384,9 @@ extend self: Handler {
364
384
  line = token.startLine
365
385
  column = token.startColumn
366
386
  )
367
- let lspHook = LspHook.make(at = Some(completionAt), definedAt = None, insertIdentifier = True, trackSymbols = False)
387
+ let lspHook = LspHook.new(at = Some(completionAt), definedAt = None, insertIdentifier = True, trackSymbols = False)
368
388
  let path = system.path(completionAt.file)
369
- let errors = self.check(system, self.fireflyPath, path, None, Set.empty(), self.virtualFiles, version, lspHook, True)
389
+ let errors = self.check(system, self.fireflyPath, path, None, Set.new(), self.virtualFiles, version, lspHook, True)
370
390
  errors.each {| CompileError(at, message) =>
371
391
  Log.trace("handleCompletion check error: " + message)
372
392
  }
@@ -376,11 +396,11 @@ extend self: Handler {
376
396
 
377
397
  handleSignatureHelp(system: NodeSystem, parameters: Map[String, Json], version: Int): ResultOrError {
378
398
  let cursorAt = self.findLocationFromParameters(system, parameters)
379
- let lspHook = LspHook.make(at = Some(cursorAt), definedAt = None, insertIdentifier = False, trackSymbols = False)
399
+ let lspHook = LspHook.new(at = Some(cursorAt), definedAt = None, insertIdentifier = False, trackSymbols = False)
380
400
  try {
381
401
  let code = self.virtualFiles.get(cursorAt.file).else {system.path(cursorAt.file).readText()}
382
402
  let tokens = Tokenizer.tokenize(cursorAt.file, code, None, True)
383
- let parser = Parser.make(PackagePair("script", "script"), cursorAt.file, tokens, False, lspHook)
403
+ let parser = Parser.new(PackagePair("script", "script"), cursorAt.file, tokens, False, lspHook)
384
404
  parser.parseModuleWithPackageInfo()
385
405
  } catch {| CompileError(at, message), error =>
386
406
  Log.trace("handleSignatureHelp check error: " + message)
@@ -397,9 +417,9 @@ extend self: Handler {
397
417
  } =>
398
418
  Some(SignatureHelpHandler.pickActiveParameter(help, h.argumentIndex, h.parameterName))
399
419
  | ParseArgumentHook h =>
400
- let callLspHook = LspHook.make(at = Some(h.callAt), definedAt = None, insertIdentifier = False, trackSymbols = False)
420
+ let callLspHook = LspHook.new(at = Some(h.callAt), definedAt = None, insertIdentifier = False, trackSymbols = False)
401
421
  let path = system.path(cursorAt.file)
402
- let errors = self.check(system, self.fireflyPath, path, None, Set.empty(), self.virtualFiles, version, callLspHook, True)
422
+ let errors = self.check(system, self.fireflyPath, path, None, Set.new(), self.virtualFiles, version, callLspHook, True)
403
423
  errors.each {| CompileError(at, message) =>
404
424
  Log.trace("handleSignatureHelp check 2 error: " + message)
405
425
  }
@@ -462,9 +482,9 @@ extend self: Handler {
462
482
  includeDeclaration: Bool
463
483
  version: Int
464
484
  ): Option[List[TokenLocation]] {
465
- let temporaryLspHook = LspHook.make(at = Some(targetAt), definedAt = None, insertIdentifier = False, trackSymbols = False)
485
+ let temporaryLspHook = LspHook.new(at = Some(targetAt), definedAt = None, insertIdentifier = False, trackSymbols = False)
466
486
  let path = system.path(targetAt.file)
467
- let errors = self.check(system, self.fireflyPath, path, None, Set.empty(), self.virtualFiles, version, temporaryLspHook, True)
487
+ let errors = self.check(system, self.fireflyPath, path, None, Set.new(), self.virtualFiles, version, temporaryLspHook, True)
468
488
  errors.each {| CompileError(at, message) =>
469
489
  Log.trace("findReferences first check error: " + message + " in " + at.file + ":" + at.line + ":" + at.column)
470
490
  }
@@ -508,9 +528,9 @@ extend self: Handler {
508
528
 
509
529
  definedAtList.first().{
510
530
  | Some(definition) =>
511
- let lspHook = LspHook.make(at = None, definedAt = Some(definition.at), insertIdentifier = False, trackSymbols = False)
531
+ let lspHook = LspHook.new(at = None, definedAt = Some(definition.at), insertIdentifier = False, trackSymbols = False)
512
532
  let localCheck = local || definition.local
513
- let path = if(localCheck) {system.path(targetAt.file)} else {self.rootPath.grab()}
533
+ let path = if(localCheck) {system.path(targetAt.file)} else {self.rootPath.else {system.path(targetAt.file)}}
514
534
  let mustContain = Some(definition.name).filter {_ => !localCheck}.map(unqualify)
515
535
  Log.trace("findReferences definition: " + Show.show(definition))
516
536
  mustContain.each {Log.trace("mustContain: " + _)}
@@ -524,7 +544,7 @@ extend self: Handler {
524
544
  list.toSet()
525
545
  }.else {
526
546
  Log.trace("No skip list due to unqualified definition.name: " + definition.name)
527
- Set.empty()
547
+ Set.new()
528
548
  }
529
549
  }
530
550
  let errors = self.check(system, self.fireflyPath, path, mustContain, skipFiles, self.virtualFiles, version, lspHook, True, False)
@@ -683,6 +703,7 @@ extend self: Handler {
683
703
  skipFiles
684
704
  virtualFiles
685
705
  self.moduleCache
706
+ self.dependencyLock
686
707
  newModuleCacheVersion
687
708
  lspHook
688
709
  infer
@@ -1,4 +1,5 @@
1
1
  import ModuleCache from ff:compiler
2
+ import DependencyLock from ff:compiler
2
3
  import Handler
3
4
 
4
5
  class LanguageServer(
@@ -29,8 +30,17 @@ main(system: NodeSystem) {
29
30
  }
30
31
 
31
32
  let fireflyPath = system.path(".")
32
- let cache = ModuleCache.empty(0)
33
- let handler = Handler(fireflyPath, None, Map.empty(), [].toSet(), Map.empty(), Map.empty(), cache)
33
+ let cache = ModuleCache.new(0)
34
+ let handler = Handler(
35
+ fireflyPath = fireflyPath
36
+ rootPath = None
37
+ virtualFiles = Map.new()
38
+ cancelledRequests = [].toSet()
39
+ responseCache = Map.new()
40
+ fileSymbolsCache = Map.new()
41
+ moduleCache = cache
42
+ dependencyLock = DependencyLock.new(system.mainTask())
43
+ )
34
44
  try {
35
45
  mutable input = system.readStream()
36
46
  let responseChannel: Channel[Pair[Json, String]] = system.mainTask().channel()
@@ -115,7 +125,7 @@ parseRequest(system: NodeSystem, input: Stream[Buffer]): Pair[Request, Stream[Bu
115
125
  }
116
126
 
117
127
  parseRequestHeaders(input: Stream[Buffer]): Pair[Map[String, String], Stream[Buffer]] {
118
- let buffers = Array.make()
128
+ let buffers = Array.new()
119
129
  mutable buffer = input.next().else {
120
130
  throw(BadRequestException("End of input while parsing request headers"))
121
131
  }
@@ -145,9 +145,9 @@ symbolFilter(symbol: WorkspaceSymbol, query: String): Bool {
145
145
  }
146
146
 
147
147
  matchSymbol(symbolWords: List[String], query: String): Bool {
148
- let memo = IntMap.make()
148
+ let memo = IntMap.new()
149
149
  function go(wordIndex: Int, queryOffset: Int): Bool {
150
- memo.getOrSet(wordIndex) {IntMap.make()}.getOrSet(queryOffset):
150
+ memo.getOrSet(wordIndex) {IntMap.new()}.getOrSet(queryOffset):
151
151
  if(queryOffset >= query.size()) {True} else:
152
152
  if(wordIndex >= symbolWords.size()) {False} else:
153
153
  prefixes(query.dropFirst(queryOffset)).any {prefix =>
@@ -6,8 +6,8 @@ nodeMain(system: NodeSystem) {
6
6
  Log.debug("Hello")
7
7
  let fireflyPath = system.path(".")
8
8
  Log.debug(fireflyPath.absolute())
9
- let cache = ModuleCache.empty(0)
10
- let handler = Handler(fireflyPath, None, Map.empty(), [].toSet(), Map.empty(), Map.empty(), cache)
9
+ let cache = ModuleCache.new(0)
10
+ let handler = Handler(fireflyPath, None, Map.new(), [].toSet(), Map.new(), Map.new(), cache)
11
11
  let targetAt = Location("/home/werk/projects/firefly-boot/lsp/TestReferencesCase.ff", 7, 5)
12
12
  let references = handler.findReferences(system, targetAt, local = False, includeDeclaration = True, version = 0)
13
13
  Log.show(references)
package/lux/Lux.ff CHANGED
@@ -138,7 +138,7 @@ extend self: Lux {
138
138
 
139
139
  set(attribute: String, value: String) {
140
140
  let attributes = self.attributes.else {
141
- let map = StringMap.make()
141
+ let map = StringMap.new()
142
142
  self.attributes = Some(map)
143
143
  map
144
144
  }
@@ -153,7 +153,7 @@ extend self: Lux {
153
153
 
154
154
  css(style: Css) {
155
155
  let attributes = self.attributes.else {
156
- let map = StringMap.make()
156
+ let map = StringMap.new()
157
157
  self.attributes = Some(map)
158
158
  map
159
159
  }
@@ -294,7 +294,7 @@ extend self: Lux {
294
294
  let lux = luxCopy.Lux(
295
295
  task = task
296
296
  renderLock = task.lock()
297
- renderQueue = Array.make()
297
+ renderQueue = Array.new()
298
298
  element = luxCopy.element.LuxElement(element = fragment)
299
299
  )
300
300
  try {
@@ -403,7 +403,7 @@ patchElement(self: Lux, tagName: String): JsValue {
403
403
  } else {
404
404
  let newNode = if(newKey == "") {self.document.createElement(tagName)} else {
405
405
  let keys = self.keys.else {
406
- let map = StringMap.make()
406
+ let map = StringMap.new()
407
407
  mutable i = self.element.child
408
408
  mutable c = self.element.childAt(i)
409
409
  while {!c.isNullOrUndefined()} {
@@ -466,7 +466,7 @@ render(browserSystem: BrowserSystem, element: JsValue, body: Lux => Unit) {
466
466
  let lux = Lux(
467
467
  jsSystem = browserSystem.js()
468
468
  renderLock = browserSystem.mainTask().lock()
469
- cssClasses = StringMap.make()
469
+ cssClasses = StringMap.new()
470
470
  task = browserSystem.mainTask()
471
471
  depth = 0
472
472
  document = LuxDocument(document)
@@ -474,7 +474,7 @@ render(browserSystem: BrowserSystem, element: JsValue, body: Lux => Unit) {
474
474
  keys = None
475
475
  key = ""
476
476
  attributes = None
477
- renderQueue = Array.make()
477
+ renderQueue = Array.new()
478
478
  )
479
479
  lux.renderLock.do(reentrant = False) {
480
480
  body(lux)
@@ -6,6 +6,8 @@ import * as ff_compiler_Compiler from "../../ff/compiler/Compiler.mjs"
6
6
 
7
7
  import * as ff_compiler_Dependencies from "../../ff/compiler/Dependencies.mjs"
8
8
 
9
+ import * as ff_compiler_DependencyLock from "../../ff/compiler/DependencyLock.mjs"
10
+
9
11
  import * as ff_compiler_JsEmitter from "../../ff/compiler/JsEmitter.mjs"
10
12
 
11
13
  import * as ff_compiler_LspHook from "../../ff/compiler/LspHook.mjs"
@@ -125,7 +127,7 @@ ff_core_Path.Path_createDirectory(tempPath_, false);
125
127
  const jsPathFile_ = ff_core_Path.Path_slash(tempPath_, "js");
126
128
  ff_core_Path.Path_createDirectory(jsPathFile_, true);
127
129
  const success_ = ff_core_Core.do_((() => {
128
- const compiler_ = ff_compiler_Compiler.make_(emitTarget_, ff_core_NodeSystem.NodeSystem_mainTask(system_), compilerModulePath_, jsPathFile_, resolvedDependencies_, ff_core_Map.empty_(), moduleCache_, ff_compiler_LspHook.disabled_());
130
+ const compiler_ = ff_compiler_Compiler.new_(emitTarget_, ff_core_NodeSystem.NodeSystem_mainTask(system_), compilerModulePath_, jsPathFile_, resolvedDependencies_, ff_core_Map.new_(), moduleCache_, ff_compiler_LspHook.disabled_());
129
131
  ff_compiler_Compiler.Compiler_emit(compiler_, mainPackage_, mainModule_, true);
130
132
  if(printMeasurements_) {
131
133
  ff_compiler_Compiler.Compiler_printMeasurements(compiler_)
@@ -154,7 +156,7 @@ ff_core_Path.Path_copyTo(fromPath_, toPath_, 0, 100)
154
156
  }
155
157
 
156
158
  export function buildViaBuildSystem_(system_, fireflyPath_, mainFile_, target_) {
157
- const resolvedDependencies_ = ff_compiler_Dependencies.process_(ff_core_NodeSystem.NodeSystem_httpClient(system_), ff_core_NodeSystem.NodeSystem_path(system_, mainFile_));
159
+ const resolvedDependencies_ = ff_compiler_Dependencies.process_(ff_core_NodeSystem.NodeSystem_httpClient(system_), ff_compiler_DependencyLock.new_(ff_core_NodeSystem.NodeSystem_mainTask(system_)), ff_core_NodeSystem.NodeSystem_path(system_, mainFile_));
158
160
  const fixedPackagePaths_ = (ff_core_Map.Map_contains(resolvedDependencies_.packagePaths_, ff_compiler_Syntax.PackagePair("ff", "core"), ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair)
159
161
  ? resolvedDependencies_.packagePaths_
160
162
  : ff_core_Map.Map_add(resolvedDependencies_.packagePaths_, ff_compiler_Syntax.PackagePair("ff", "core"), ff_core_Path.Path_slash(fireflyPath_, "core"), ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair));
@@ -163,10 +165,10 @@ ff_core_Core.panic_("buildViaBuildSystem is currently limited to browser target
163
165
  };
164
166
  ff_compiler_Builder.build_(system_, ff_compiler_JsEmitter.EmitBrowser(), resolvedDependencies_.mainPackagePair_, ff_core_String.String_dropLast(mainFile_, ff_core_String.String_size(".ff")), (((_c) => {
165
167
  return ff_compiler_Dependencies.ResolvedDependencies(_c.mainPackagePair_, _c.packages_, fixedPackagePaths_, _c.singleFilePackages_)
166
- }))(resolvedDependencies_), ff_core_Option.None(), ff_core_NodeSystem.NodeSystem_path(system_, ".firefly/temporary"), ff_core_Path.Path_slash(ff_core_NodeSystem.NodeSystem_path(system_, ".firefly/output"), target_), false, ff_compiler_ModuleCache.empty_(0))
168
+ }))(resolvedDependencies_), ff_core_Option.None(), ff_core_NodeSystem.NodeSystem_path(system_, ".firefly/temporary"), ff_core_Path.Path_slash(ff_core_NodeSystem.NodeSystem_path(system_, ".firefly/output"), target_), false, ff_compiler_ModuleCache.new_(0))
167
169
  }
168
170
 
169
- export function check_(system_, fireflyPath_, path_, mustContain_, skipFiles_, virtualFiles_, cache_, newVersion_, lspHook_, infer_, checkDependencies_) {
171
+ export function check_(system_, fireflyPath_, path_, mustContain_, skipFiles_, virtualFiles_, cache_, dependencyLock_, newVersion_, lspHook_, infer_, checkDependencies_) {
170
172
  const packages_ = (((_1) => {
171
173
  if(_1) {
172
174
  return ff_compiler_Builder.findPackageFiles_(path_, mustContain_, skipFiles_)
@@ -178,12 +180,12 @@ if(!_1) {
178
180
  return [ff_compiler_Builder.PackageFiles(ff_core_Option.Option_grab(ff_core_Path.Path_parent(path_)), ff_core_Option.None(), [path_])]
179
181
  }
180
182
  }))(ff_core_Path.Path_isDirectory(path_));
181
- const errors_ = ff_core_Array.make_();
183
+ const errors_ = ff_core_Array.new_();
182
184
  ff_core_List.List_each(ff_core_List.List_filter(packages_, ((_w1) => {
183
185
  return (!ff_core_List.List_isEmpty(_w1.files_))
184
186
  })), ((package_) => {
185
187
  const firstFile_ = ff_core_List.List_grabFirst(package_.files_);
186
- const resolvedDependencies_ = ff_compiler_Dependencies.process_(ff_core_NodeSystem.NodeSystem_httpClient(system_), firstFile_);
188
+ const resolvedDependencies_ = ff_compiler_Dependencies.process_(ff_core_NodeSystem.NodeSystem_httpClient(system_), dependencyLock_, firstFile_);
187
189
  const fixedPackagePaths_ = (ff_core_Map.Map_contains(resolvedDependencies_.packagePaths_, ff_compiler_Syntax.PackagePair("ff", "core"), ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair)
188
190
  ? resolvedDependencies_.packagePaths_
189
191
  : ff_core_Map.Map_add(resolvedDependencies_.packagePaths_, ff_compiler_Syntax.PackagePair("ff", "core"), ff_core_Path.Path_slash(fireflyPath_, "core"), ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair));
@@ -191,7 +193,7 @@ const fixedResolvedDependencies_ = (((_c) => {
191
193
  return ff_compiler_Dependencies.ResolvedDependencies(_c.mainPackagePair_, _c.packages_, fixedPackagePaths_, _c.singleFilePackages_)
192
194
  }))(resolvedDependencies_);
193
195
  const newCache_ = ff_compiler_ModuleCache.ModuleCache_without(cache_, newVersion_, path_);
194
- const compiler_ = ff_compiler_Compiler.make_(ff_compiler_JsEmitter.EmitBuild(), ff_core_NodeSystem.NodeSystem_mainTask(system_), ff_core_Option.None(), ff_core_Path.Path_slash(ff_core_Path.Path_slash(package_.root_, ".firefly"), "temporary"), fixedResolvedDependencies_, virtualFiles_, newCache_, lspHook_);
196
+ const compiler_ = ff_compiler_Compiler.new_(ff_compiler_JsEmitter.EmitBuild(), ff_core_NodeSystem.NodeSystem_mainTask(system_), ff_core_Option.None(), ff_core_Path.Path_slash(ff_core_Path.Path_slash(package_.root_, ".firefly"), "temporary"), fixedResolvedDependencies_, virtualFiles_, newCache_, lspHook_);
195
197
  const files_ = (checkDependencies_
196
198
  ? package_.files_
197
199
  : ff_core_List.List_filter(package_.files_, ((_w1) => {
@@ -199,22 +201,27 @@ return (!ff_core_Path.Path_contains(_w1, [".firefly", "dependencies"]))
199
201
  })));
200
202
  ff_core_List.List_each(files_, ((file_) => {
201
203
  const localFile_ = ff_core_Path.Path_base(file_);
202
- try {
204
+ ff_core_Try.Try_grab(ff_core_Try.Try_catch(ff_core_Try.Try_catch(ff_core_Core.try_((() => {
203
205
  if(infer_) {
204
206
  ff_compiler_Compiler.Compiler_infer(compiler_, resolvedDependencies_.mainPackagePair_, ff_core_String.String_dropLast(localFile_, ff_core_String.String_size(".ff")))
205
207
  } else {
206
208
  ff_compiler_Compiler.Compiler_resolve(compiler_, resolvedDependencies_.mainPackagePair_, ff_core_String.String_dropLast(localFile_, ff_core_String.String_size(".ff")))
207
209
  }
208
- } catch(_error) {
209
- if(!_error.ffException) throw _error
210
- const _exception = ff_core_Any.fromAny_(_error.ffException, ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)
211
- if(!_exception.Some) throw _error
210
+ })), ((_1, _2) => {
212
211
  {
213
- const c_ = _exception.value_;
214
- const error_ = _error;
212
+ const c_ = _1;
213
+ const error_ = _2;
215
214
  ff_core_Array.Array_push(errors_, c_)
215
+ return
216
216
  }
217
+ }), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError), ((_1, _2) => {
218
+ {
219
+ const compileErrors_ = _1.errors_;
220
+ const error_ = _2;
221
+ ff_core_Array.Array_pushList(errors_, compileErrors_)
222
+ return
217
223
  }
224
+ }), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileErrors))
218
225
  }));
219
226
  ff_compiler_ModuleCache.ModuleCache_mergeVersions(cache_, compiler_.cache_)
220
227
  }));
@@ -314,7 +321,7 @@ if((await ff_core_Path.Path_exists$(tempPath_, false, false, false, $task))) {
314
321
  const jsPathFile_ = (await ff_core_Path.Path_slash$(tempPath_, "js", $task));
315
322
  (await ff_core_Path.Path_createDirectory$(jsPathFile_, true, $task));
316
323
  const success_ = (await ff_core_Core.do_$((async ($task) => {
317
- const compiler_ = (await ff_compiler_Compiler.make_$(emitTarget_, (await ff_core_NodeSystem.NodeSystem_mainTask$(system_, $task)), compilerModulePath_, jsPathFile_, resolvedDependencies_, ff_core_Map.empty_(), moduleCache_, ff_compiler_LspHook.disabled_(), $task));
324
+ const compiler_ = (await ff_compiler_Compiler.new_$(emitTarget_, (await ff_core_NodeSystem.NodeSystem_mainTask$(system_, $task)), compilerModulePath_, jsPathFile_, resolvedDependencies_, ff_core_Map.new_(), moduleCache_, ff_compiler_LspHook.disabled_(), $task));
318
325
  (await ff_compiler_Compiler.Compiler_emit$(compiler_, mainPackage_, mainModule_, true, $task));
319
326
  if(printMeasurements_) {
320
327
  (await ff_compiler_Compiler.Compiler_printMeasurements$(compiler_, $task))
@@ -343,7 +350,7 @@ const toPath_ = (await ff_core_Path.Path_slash$((await ff_core_Path.Path_slash$(
343
350
  }
344
351
 
345
352
  export async function buildViaBuildSystem_$(system_, fireflyPath_, mainFile_, target_, $task) {
346
- const resolvedDependencies_ = (await ff_compiler_Dependencies.process_$((await ff_core_NodeSystem.NodeSystem_httpClient$(system_, $task)), (await ff_core_NodeSystem.NodeSystem_path$(system_, mainFile_, $task)), $task));
353
+ const resolvedDependencies_ = (await ff_compiler_Dependencies.process_$((await ff_core_NodeSystem.NodeSystem_httpClient$(system_, $task)), (await ff_compiler_DependencyLock.new_$((await ff_core_NodeSystem.NodeSystem_mainTask$(system_, $task)), $task)), (await ff_core_NodeSystem.NodeSystem_path$(system_, mainFile_, $task)), $task));
347
354
  const fixedPackagePaths_ = (ff_core_Map.Map_contains(resolvedDependencies_.packagePaths_, ff_compiler_Syntax.PackagePair("ff", "core"), ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair)
348
355
  ? resolvedDependencies_.packagePaths_
349
356
  : ff_core_Map.Map_add(resolvedDependencies_.packagePaths_, ff_compiler_Syntax.PackagePair("ff", "core"), (await ff_core_Path.Path_slash$(fireflyPath_, "core", $task)), ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair));
@@ -352,10 +359,10 @@ ff_core_Core.panic_("buildViaBuildSystem is currently limited to browser target
352
359
  };
353
360
  (await ff_compiler_Builder.build_$(system_, ff_compiler_JsEmitter.EmitBrowser(), resolvedDependencies_.mainPackagePair_, ff_core_String.String_dropLast(mainFile_, ff_core_String.String_size(".ff")), (((_c) => {
354
361
  return ff_compiler_Dependencies.ResolvedDependencies(_c.mainPackagePair_, _c.packages_, fixedPackagePaths_, _c.singleFilePackages_)
355
- }))(resolvedDependencies_), ff_core_Option.None(), (await ff_core_NodeSystem.NodeSystem_path$(system_, ".firefly/temporary", $task)), (await ff_core_Path.Path_slash$((await ff_core_NodeSystem.NodeSystem_path$(system_, ".firefly/output", $task)), target_, $task)), false, ff_compiler_ModuleCache.empty_(0), $task))
362
+ }))(resolvedDependencies_), ff_core_Option.None(), (await ff_core_NodeSystem.NodeSystem_path$(system_, ".firefly/temporary", $task)), (await ff_core_Path.Path_slash$((await ff_core_NodeSystem.NodeSystem_path$(system_, ".firefly/output", $task)), target_, $task)), false, ff_compiler_ModuleCache.new_(0), $task))
356
363
  }
357
364
 
358
- export async function check_$(system_, fireflyPath_, path_, mustContain_, skipFiles_, virtualFiles_, cache_, newVersion_, lspHook_, infer_, checkDependencies_, $task) {
365
+ export async function check_$(system_, fireflyPath_, path_, mustContain_, skipFiles_, virtualFiles_, cache_, dependencyLock_, newVersion_, lspHook_, infer_, checkDependencies_, $task) {
359
366
  const packages_ = (await ((async (_1, $task) => {
360
367
  if(_1) {
361
368
  return (await ff_compiler_Builder.findPackageFiles_$(path_, mustContain_, skipFiles_, $task))
@@ -367,12 +374,12 @@ if(!_1) {
367
374
  return [ff_compiler_Builder.PackageFiles(ff_core_Option.Option_grab((await ff_core_Path.Path_parent$(path_, $task))), ff_core_Option.None(), [path_])]
368
375
  }
369
376
  }))((await ff_core_Path.Path_isDirectory$(path_, $task)), $task));
370
- const errors_ = ff_core_Array.make_();
377
+ const errors_ = ff_core_Array.new_();
371
378
  (await ff_core_List.List_each$(ff_core_List.List_filter(packages_, ((_w1) => {
372
379
  return (!ff_core_List.List_isEmpty(_w1.files_))
373
380
  })), (async (package_, $task) => {
374
381
  const firstFile_ = ff_core_List.List_grabFirst(package_.files_);
375
- const resolvedDependencies_ = (await ff_compiler_Dependencies.process_$((await ff_core_NodeSystem.NodeSystem_httpClient$(system_, $task)), firstFile_, $task));
382
+ const resolvedDependencies_ = (await ff_compiler_Dependencies.process_$((await ff_core_NodeSystem.NodeSystem_httpClient$(system_, $task)), dependencyLock_, firstFile_, $task));
376
383
  const fixedPackagePaths_ = (ff_core_Map.Map_contains(resolvedDependencies_.packagePaths_, ff_compiler_Syntax.PackagePair("ff", "core"), ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair)
377
384
  ? resolvedDependencies_.packagePaths_
378
385
  : ff_core_Map.Map_add(resolvedDependencies_.packagePaths_, ff_compiler_Syntax.PackagePair("ff", "core"), (await ff_core_Path.Path_slash$(fireflyPath_, "core", $task)), ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair));
@@ -380,7 +387,7 @@ const fixedResolvedDependencies_ = (((_c) => {
380
387
  return ff_compiler_Dependencies.ResolvedDependencies(_c.mainPackagePair_, _c.packages_, fixedPackagePaths_, _c.singleFilePackages_)
381
388
  }))(resolvedDependencies_);
382
389
  const newCache_ = (await ff_compiler_ModuleCache.ModuleCache_without$(cache_, newVersion_, path_, $task));
383
- const compiler_ = (await ff_compiler_Compiler.make_$(ff_compiler_JsEmitter.EmitBuild(), (await ff_core_NodeSystem.NodeSystem_mainTask$(system_, $task)), ff_core_Option.None(), (await ff_core_Path.Path_slash$((await ff_core_Path.Path_slash$(package_.root_, ".firefly", $task)), "temporary", $task)), fixedResolvedDependencies_, virtualFiles_, newCache_, lspHook_, $task));
390
+ const compiler_ = (await ff_compiler_Compiler.new_$(ff_compiler_JsEmitter.EmitBuild(), (await ff_core_NodeSystem.NodeSystem_mainTask$(system_, $task)), ff_core_Option.None(), (await ff_core_Path.Path_slash$((await ff_core_Path.Path_slash$(package_.root_, ".firefly", $task)), "temporary", $task)), fixedResolvedDependencies_, virtualFiles_, newCache_, lspHook_, $task));
384
391
  const files_ = (checkDependencies_
385
392
  ? package_.files_
386
393
  : (await ff_core_List.List_filter$(package_.files_, (async (_w1, $task) => {
@@ -388,22 +395,27 @@ return (!(await ff_core_Path.Path_contains$(_w1, [".firefly", "dependencies"], $
388
395
  }), $task)));
389
396
  (await ff_core_List.List_each$(files_, (async (file_, $task) => {
390
397
  const localFile_ = (await ff_core_Path.Path_base$(file_, $task));
391
- try {
398
+ ff_core_Try.Try_grab(ff_core_Try.Try_catch(ff_core_Try.Try_catch((await ff_core_Core.try_$((async ($task) => {
392
399
  if(infer_) {
393
400
  (await ff_compiler_Compiler.Compiler_infer$(compiler_, resolvedDependencies_.mainPackagePair_, ff_core_String.String_dropLast(localFile_, ff_core_String.String_size(".ff")), $task))
394
401
  } else {
395
402
  (await ff_compiler_Compiler.Compiler_resolve$(compiler_, resolvedDependencies_.mainPackagePair_, ff_core_String.String_dropLast(localFile_, ff_core_String.String_size(".ff")), $task))
396
403
  }
397
- } catch(_error) {
398
- if(!_error.ffException) throw _error
399
- const _exception = ff_core_Any.fromAny_(_error.ffException, ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)
400
- if(!_exception.Some) throw _error
404
+ }), $task)), ((_1, _2) => {
401
405
  {
402
- const c_ = _exception.value_;
403
- const error_ = _error;
406
+ const c_ = _1;
407
+ const error_ = _2;
404
408
  ff_core_Array.Array_push(errors_, c_)
409
+ return
405
410
  }
411
+ }), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError), ((_1, _2) => {
412
+ {
413
+ const compileErrors_ = _1.errors_;
414
+ const error_ = _2;
415
+ ff_core_Array.Array_pushList(errors_, compileErrors_)
416
+ return
406
417
  }
418
+ }), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileErrors))
407
419
  }), $task));
408
420
  ff_compiler_ModuleCache.ModuleCache_mergeVersions(cache_, compiler_.cache_)
409
421
  }), $task));