firefly-compiler 0.4.9 → 0.4.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/compiler/Compiler.ff +1 -0
- package/compiler/JsEmitter.ff +5 -3
- package/core/Array.ff +8 -0
- package/core/FileHandle.ff +6 -0
- package/core/Int.ff +4 -0
- package/core/JsSystem.ff +3 -0
- package/core/JsValue.ff +5 -0
- package/core/Json.ff +325 -0
- package/core/String.ff +22 -0
- package/lsp/Handler.ff +79 -88
- package/lsp/HoverHandler.ff +7 -10
- package/lsp/LanguageServer.ff +30 -33
- package/lsp/SignatureHelpHandler.ff +12 -13
- package/lsp/SymbolHandler.ff +17 -17
- package/output/js/ff/compiler/Builder.mjs +2 -0
- package/output/js/ff/compiler/Compiler.mjs +3 -1
- package/output/js/ff/compiler/Dependencies.mjs +2 -0
- package/output/js/ff/compiler/Deriver.mjs +2 -0
- package/output/js/ff/compiler/Dictionaries.mjs +2 -0
- package/output/js/ff/compiler/Environment.mjs +2 -0
- package/output/js/ff/compiler/Inference.mjs +2 -0
- package/output/js/ff/compiler/JsEmitter.mjs +12 -2
- package/output/js/ff/compiler/JsImporter.mjs +2 -0
- package/output/js/ff/compiler/LspHook.mjs +2 -0
- package/output/js/ff/compiler/Main.mjs +2 -0
- package/output/js/ff/compiler/Parser.mjs +2 -0
- package/output/js/ff/compiler/Patterns.mjs +2 -0
- package/output/js/ff/compiler/Resolver.mjs +2 -0
- package/output/js/ff/compiler/Substitution.mjs +2 -0
- package/output/js/ff/compiler/Syntax.mjs +2 -0
- package/output/js/ff/compiler/Token.mjs +2 -0
- package/output/js/ff/compiler/Tokenizer.mjs +2 -0
- package/output/js/ff/compiler/Unification.mjs +2 -0
- package/output/js/ff/compiler/Wildcards.mjs +2 -0
- package/output/js/ff/compiler/Workspace.mjs +2 -0
- package/output/js/ff/core/Any.mjs +2 -0
- package/output/js/ff/core/Array.mjs +18 -0
- package/output/js/ff/core/AssetSystem.mjs +2 -0
- package/output/js/ff/core/Atomic.mjs +2 -0
- package/output/js/ff/core/Bool.mjs +2 -0
- package/output/js/ff/core/Box.mjs +2 -0
- package/output/js/ff/core/BrowserSystem.mjs +2 -0
- package/output/js/ff/core/Buffer.mjs +2 -0
- package/output/js/ff/core/BuildSystem.mjs +2 -0
- package/output/js/ff/core/Channel.mjs +2 -0
- package/output/js/ff/core/Char.mjs +2 -0
- package/output/js/ff/core/Core.mjs +2 -0
- package/output/js/ff/core/Duration.mjs +2 -0
- package/output/js/ff/core/Equal.mjs +2 -0
- package/output/js/ff/core/Error.mjs +2 -0
- package/output/js/ff/core/FileHandle.mjs +14 -0
- package/output/js/ff/core/Float.mjs +2 -0
- package/output/js/ff/core/HttpClient.mjs +2 -0
- package/output/js/ff/core/Instant.mjs +2 -0
- package/output/js/ff/core/Int.mjs +10 -0
- package/output/js/ff/core/IntMap.mjs +2 -0
- package/output/js/ff/core/JsSystem.mjs +10 -0
- package/output/js/ff/core/JsValue.mjs +12 -0
- package/output/js/ff/core/Json.mjs +869 -0
- package/output/js/ff/core/List.mjs +2 -0
- package/output/js/ff/core/Lock.mjs +2 -0
- package/output/js/ff/core/Log.mjs +2 -0
- package/output/js/ff/core/Map.mjs +2 -0
- package/output/js/ff/core/NodeSystem.mjs +2 -0
- package/output/js/ff/core/Nothing.mjs +2 -0
- package/output/js/ff/core/Option.mjs +2 -0
- package/output/js/ff/core/Ordering.mjs +2 -0
- package/output/js/ff/core/Pair.mjs +2 -0
- package/output/js/ff/core/Path.mjs +2 -0
- package/output/js/ff/core/Random.mjs +2 -0
- package/output/js/ff/core/RbMap.mjs +2 -0
- package/output/js/ff/core/Serializable.mjs +2 -0
- package/output/js/ff/core/Set.mjs +2 -0
- package/output/js/ff/core/Show.mjs +2 -0
- package/output/js/ff/core/SourceLocation.mjs +2 -0
- package/output/js/ff/core/Stack.mjs +2 -0
- package/output/js/ff/core/Stream.mjs +2 -0
- package/output/js/ff/core/String.mjs +54 -0
- package/output/js/ff/core/StringMap.mjs +2 -0
- package/output/js/ff/core/Task.mjs +2 -0
- package/output/js/ff/core/Try.mjs +2 -0
- package/output/js/ff/core/Unit.mjs +2 -0
- package/output/js/ff/core/WebSocket.mjs +2 -0
- package/package.json +2 -2
- package/postgresql/Pg.ff +13 -13
- package/rpc/.firefly/package.ff +1 -0
- package/rpc/Rpc.ff +69 -0
- package/vscode/package.json +1 -1
- package/webserver/WebServer.ff +165 -88
- package/meetup/AutoCompletion.ff +0 -6
|
@@ -46,6 +46,8 @@ import * as ff_core_JsSystem from "../../ff/core/JsSystem.mjs"
|
|
|
46
46
|
|
|
47
47
|
import * as ff_core_JsValue from "../../ff/core/JsValue.mjs"
|
|
48
48
|
|
|
49
|
+
import * as ff_core_Json from "../../ff/core/Json.mjs"
|
|
50
|
+
|
|
49
51
|
import * as ff_core_List from "../../ff/core/List.mjs"
|
|
50
52
|
|
|
51
53
|
import * as ff_core_Lock from "../../ff/core/Lock.mjs"
|
|
@@ -46,6 +46,8 @@ import * as ff_core_JsSystem from "../../ff/core/JsSystem.mjs"
|
|
|
46
46
|
|
|
47
47
|
import * as ff_core_JsValue from "../../ff/core/JsValue.mjs"
|
|
48
48
|
|
|
49
|
+
import * as ff_core_Json from "../../ff/core/Json.mjs"
|
|
50
|
+
|
|
49
51
|
import * as ff_core_List from "../../ff/core/List.mjs"
|
|
50
52
|
|
|
51
53
|
import * as ff_core_Lock from "../../ff/core/Lock.mjs"
|
|
@@ -46,6 +46,8 @@ import * as ff_core_JsSystem from "../../ff/core/JsSystem.mjs"
|
|
|
46
46
|
|
|
47
47
|
import * as ff_core_JsValue from "../../ff/core/JsValue.mjs"
|
|
48
48
|
|
|
49
|
+
import * as ff_core_Json from "../../ff/core/Json.mjs"
|
|
50
|
+
|
|
49
51
|
import * as ff_core_List from "../../ff/core/List.mjs"
|
|
50
52
|
|
|
51
53
|
import * as ff_core_Lock from "../../ff/core/Lock.mjs"
|
|
@@ -46,6 +46,8 @@ import * as ff_core_JsSystem from "../../ff/core/JsSystem.mjs"
|
|
|
46
46
|
|
|
47
47
|
import * as ff_core_JsValue from "../../ff/core/JsValue.mjs"
|
|
48
48
|
|
|
49
|
+
import * as ff_core_Json from "../../ff/core/Json.mjs"
|
|
50
|
+
|
|
49
51
|
import * as ff_core_List from "../../ff/core/List.mjs"
|
|
50
52
|
|
|
51
53
|
import * as ff_core_Lock from "../../ff/core/Lock.mjs"
|
|
@@ -50,6 +50,8 @@ import * as ff_core_JsSystem from "../../ff/core/JsSystem.mjs"
|
|
|
50
50
|
|
|
51
51
|
import * as ff_core_JsValue from "../../ff/core/JsValue.mjs"
|
|
52
52
|
|
|
53
|
+
import * as ff_core_Json from "../../ff/core/Json.mjs"
|
|
54
|
+
|
|
53
55
|
import * as ff_core_List from "../../ff/core/List.mjs"
|
|
54
56
|
|
|
55
57
|
import * as ff_core_Lock from "../../ff/core/Lock.mjs"
|
|
@@ -46,6 +46,8 @@ import * as ff_core_JsSystem from "../../ff/core/JsSystem.mjs"
|
|
|
46
46
|
|
|
47
47
|
import * as ff_core_JsValue from "../../ff/core/JsValue.mjs"
|
|
48
48
|
|
|
49
|
+
import * as ff_core_Json from "../../ff/core/Json.mjs"
|
|
50
|
+
|
|
49
51
|
import * as ff_core_List from "../../ff/core/List.mjs"
|
|
50
52
|
|
|
51
53
|
import * as ff_core_Lock from "../../ff/core/Lock.mjs"
|
|
@@ -46,6 +46,8 @@ import * as ff_core_JsSystem from "../../ff/core/JsSystem.mjs"
|
|
|
46
46
|
|
|
47
47
|
import * as ff_core_JsValue from "../../ff/core/JsValue.mjs"
|
|
48
48
|
|
|
49
|
+
import * as ff_core_Json from "../../ff/core/Json.mjs"
|
|
50
|
+
|
|
49
51
|
import * as ff_core_List from "../../ff/core/List.mjs"
|
|
50
52
|
|
|
51
53
|
import * as ff_core_Lock from "../../ff/core/Lock.mjs"
|
|
@@ -46,6 +46,8 @@ import * as ff_core_JsSystem from "../../ff/core/JsSystem.mjs"
|
|
|
46
46
|
|
|
47
47
|
import * as ff_core_JsValue from "../../ff/core/JsValue.mjs"
|
|
48
48
|
|
|
49
|
+
import * as ff_core_Json from "../../ff/core/Json.mjs"
|
|
50
|
+
|
|
49
51
|
import * as ff_core_List from "../../ff/core/List.mjs"
|
|
50
52
|
|
|
51
53
|
import * as ff_core_Lock from "../../ff/core/Lock.mjs"
|
|
@@ -46,6 +46,8 @@ import * as ff_core_JsSystem from "../../ff/core/JsSystem.mjs"
|
|
|
46
46
|
|
|
47
47
|
import * as ff_core_JsValue from "../../ff/core/JsValue.mjs"
|
|
48
48
|
|
|
49
|
+
import * as ff_core_Json from "../../ff/core/Json.mjs"
|
|
50
|
+
|
|
49
51
|
import * as ff_core_List from "../../ff/core/List.mjs"
|
|
50
52
|
|
|
51
53
|
import * as ff_core_Lock from "../../ff/core/Lock.mjs"
|
|
@@ -52,6 +52,8 @@ import * as ff_core_JsSystem from "../../ff/core/JsSystem.mjs"
|
|
|
52
52
|
|
|
53
53
|
import * as ff_core_JsValue from "../../ff/core/JsValue.mjs"
|
|
54
54
|
|
|
55
|
+
import * as ff_core_Json from "../../ff/core/Json.mjs"
|
|
56
|
+
|
|
55
57
|
import * as ff_core_List from "../../ff/core/List.mjs"
|
|
56
58
|
|
|
57
59
|
import * as ff_core_Lock from "../../ff/core/Lock.mjs"
|
|
@@ -46,6 +46,8 @@ import * as ff_core_JsSystem from "../../ff/core/JsSystem.mjs"
|
|
|
46
46
|
|
|
47
47
|
import * as ff_core_JsValue from "../../ff/core/JsValue.mjs"
|
|
48
48
|
|
|
49
|
+
import * as ff_core_Json from "../../ff/core/Json.mjs"
|
|
50
|
+
|
|
49
51
|
import * as ff_core_List from "../../ff/core/List.mjs"
|
|
50
52
|
|
|
51
53
|
import * as ff_core_Lock from "../../ff/core/Lock.mjs"
|
|
@@ -48,6 +48,8 @@ import * as ff_core_JsSystem from "../../ff/core/JsSystem.mjs"
|
|
|
48
48
|
|
|
49
49
|
import * as ff_core_JsValue from "../../ff/core/JsValue.mjs"
|
|
50
50
|
|
|
51
|
+
import * as ff_core_Json from "../../ff/core/Json.mjs"
|
|
52
|
+
|
|
51
53
|
import * as ff_core_List from "../../ff/core/List.mjs"
|
|
52
54
|
|
|
53
55
|
import * as ff_core_Lock from "../../ff/core/Lock.mjs"
|
|
@@ -46,6 +46,8 @@ import * as ff_core_JsSystem from "../../ff/core/JsSystem.mjs"
|
|
|
46
46
|
|
|
47
47
|
import * as ff_core_JsValue from "../../ff/core/JsValue.mjs"
|
|
48
48
|
|
|
49
|
+
import * as ff_core_Json from "../../ff/core/Json.mjs"
|
|
50
|
+
|
|
49
51
|
import * as ff_core_List from "../../ff/core/List.mjs"
|
|
50
52
|
|
|
51
53
|
import * as ff_core_Lock from "../../ff/core/Lock.mjs"
|
|
@@ -46,6 +46,8 @@ import * as ff_core_JsSystem from "../../ff/core/JsSystem.mjs"
|
|
|
46
46
|
|
|
47
47
|
import * as ff_core_JsValue from "../../ff/core/JsValue.mjs"
|
|
48
48
|
|
|
49
|
+
import * as ff_core_Json from "../../ff/core/Json.mjs"
|
|
50
|
+
|
|
49
51
|
import * as ff_core_List from "../../ff/core/List.mjs"
|
|
50
52
|
|
|
51
53
|
import * as ff_core_Lock from "../../ff/core/Lock.mjs"
|
|
@@ -46,6 +46,8 @@ import * as ff_core_JsSystem from "../../ff/core/JsSystem.mjs"
|
|
|
46
46
|
|
|
47
47
|
import * as ff_core_JsValue from "../../ff/core/JsValue.mjs"
|
|
48
48
|
|
|
49
|
+
import * as ff_core_Json from "../../ff/core/Json.mjs"
|
|
50
|
+
|
|
49
51
|
import * as ff_core_List from "../../ff/core/List.mjs"
|
|
50
52
|
|
|
51
53
|
import * as ff_core_Lock from "../../ff/core/Lock.mjs"
|
|
@@ -46,6 +46,8 @@ import * as ff_core_JsSystem from "../../ff/core/JsSystem.mjs"
|
|
|
46
46
|
|
|
47
47
|
import * as ff_core_JsValue from "../../ff/core/JsValue.mjs"
|
|
48
48
|
|
|
49
|
+
import * as ff_core_Json from "../../ff/core/Json.mjs"
|
|
50
|
+
|
|
49
51
|
import * as ff_core_List from "../../ff/core/List.mjs"
|
|
50
52
|
|
|
51
53
|
import * as ff_core_Lock from "../../ff/core/Lock.mjs"
|
|
@@ -46,6 +46,8 @@ import * as ff_core_JsSystem from "../../ff/core/JsSystem.mjs"
|
|
|
46
46
|
|
|
47
47
|
import * as ff_core_JsValue from "../../ff/core/JsValue.mjs"
|
|
48
48
|
|
|
49
|
+
import * as ff_core_Json from "../../ff/core/Json.mjs"
|
|
50
|
+
|
|
49
51
|
import * as ff_core_List from "../../ff/core/List.mjs"
|
|
50
52
|
|
|
51
53
|
import * as ff_core_Lock from "../../ff/core/Lock.mjs"
|
|
@@ -46,6 +46,8 @@ import * as ff_core_JsSystem from "../../ff/core/JsSystem.mjs"
|
|
|
46
46
|
|
|
47
47
|
import * as ff_core_JsValue from "../../ff/core/JsValue.mjs"
|
|
48
48
|
|
|
49
|
+
import * as ff_core_Json from "../../ff/core/Json.mjs"
|
|
50
|
+
|
|
49
51
|
import * as ff_core_List from "../../ff/core/List.mjs"
|
|
50
52
|
|
|
51
53
|
import * as ff_core_Lock from "../../ff/core/Lock.mjs"
|
|
@@ -46,6 +46,8 @@ import * as ff_core_JsSystem from "../../ff/core/JsSystem.mjs"
|
|
|
46
46
|
|
|
47
47
|
import * as ff_core_JsValue from "../../ff/core/JsValue.mjs"
|
|
48
48
|
|
|
49
|
+
import * as ff_core_Json from "../../ff/core/Json.mjs"
|
|
50
|
+
|
|
49
51
|
import * as ff_core_List from "../../ff/core/List.mjs"
|
|
50
52
|
|
|
51
53
|
import * as ff_core_Lock from "../../ff/core/Lock.mjs"
|
|
@@ -126,6 +128,22 @@ export function String_reverse(self_) {
|
|
|
126
128
|
return [...self_].reverse().join('')
|
|
127
129
|
}
|
|
128
130
|
|
|
131
|
+
export function String_repeat(self_, count_) {
|
|
132
|
+
return self_.repeat(count_)
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export function String_trim(self_) {
|
|
136
|
+
return self_.trim()
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export function String_trimStart(self_) {
|
|
140
|
+
return self_.trimStart()
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export function String_trimEnd(self_) {
|
|
144
|
+
return self_.trimEnd()
|
|
145
|
+
}
|
|
146
|
+
|
|
129
147
|
export function String_lower(self_) {
|
|
130
148
|
return self_.toLowerCase()
|
|
131
149
|
}
|
|
@@ -265,6 +283,18 @@ return ff_core_Option.None()
|
|
|
265
283
|
}
|
|
266
284
|
}
|
|
267
285
|
|
|
286
|
+
export function String_padStart(self_, length_, padding_ = " ") {
|
|
287
|
+
|
|
288
|
+
return self_.padStart(length_, padding_);
|
|
289
|
+
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
export function String_padEnd(self_, length_, padding_ = " ") {
|
|
293
|
+
|
|
294
|
+
return self_.padEnd(length_, padding_);
|
|
295
|
+
|
|
296
|
+
}
|
|
297
|
+
|
|
268
298
|
export function String_any(self_, body_) {
|
|
269
299
|
|
|
270
300
|
for(let i = 0; i < self_.length; i++) {
|
|
@@ -310,6 +340,22 @@ export async function String_reverse$(self_, $task) {
|
|
|
310
340
|
throw new Error('Function String_reverse is missing on this target in async context.');
|
|
311
341
|
}
|
|
312
342
|
|
|
343
|
+
export async function String_repeat$(self_, count_, $task) {
|
|
344
|
+
throw new Error('Function String_repeat is missing on this target in async context.');
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
export async function String_trim$(self_, $task) {
|
|
348
|
+
throw new Error('Function String_trim is missing on this target in async context.');
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
export async function String_trimStart$(self_, $task) {
|
|
352
|
+
throw new Error('Function String_trimStart is missing on this target in async context.');
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
export async function String_trimEnd$(self_, $task) {
|
|
356
|
+
throw new Error('Function String_trimEnd is missing on this target in async context.');
|
|
357
|
+
}
|
|
358
|
+
|
|
313
359
|
export async function String_lower$(self_, $task) {
|
|
314
360
|
throw new Error('Function String_lower is missing on this target in async context.');
|
|
315
361
|
}
|
|
@@ -414,6 +460,14 @@ return ff_core_Option.None()
|
|
|
414
460
|
}
|
|
415
461
|
}
|
|
416
462
|
|
|
463
|
+
export async function String_padStart$(self_, length_, padding_ = " ", $task) {
|
|
464
|
+
throw new Error('Function String_padStart is missing on this target in async context.');
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
export async function String_padEnd$(self_, length_, padding_ = " ", $task) {
|
|
468
|
+
throw new Error('Function String_padEnd is missing on this target in async context.');
|
|
469
|
+
}
|
|
470
|
+
|
|
417
471
|
export async function String_any$(self_, body_, $task) {
|
|
418
472
|
|
|
419
473
|
for(let i = 0; i < self_.length; i++) {
|
|
@@ -46,6 +46,8 @@ import * as ff_core_JsSystem from "../../ff/core/JsSystem.mjs"
|
|
|
46
46
|
|
|
47
47
|
import * as ff_core_JsValue from "../../ff/core/JsValue.mjs"
|
|
48
48
|
|
|
49
|
+
import * as ff_core_Json from "../../ff/core/Json.mjs"
|
|
50
|
+
|
|
49
51
|
import * as ff_core_List from "../../ff/core/List.mjs"
|
|
50
52
|
|
|
51
53
|
import * as ff_core_Lock from "../../ff/core/Lock.mjs"
|
|
@@ -46,6 +46,8 @@ import * as ff_core_JsSystem from "../../ff/core/JsSystem.mjs"
|
|
|
46
46
|
|
|
47
47
|
import * as ff_core_JsValue from "../../ff/core/JsValue.mjs"
|
|
48
48
|
|
|
49
|
+
import * as ff_core_Json from "../../ff/core/Json.mjs"
|
|
50
|
+
|
|
49
51
|
import * as ff_core_List from "../../ff/core/List.mjs"
|
|
50
52
|
|
|
51
53
|
import * as ff_core_Lock from "../../ff/core/Lock.mjs"
|
|
@@ -46,6 +46,8 @@ import * as ff_core_JsSystem from "../../ff/core/JsSystem.mjs"
|
|
|
46
46
|
|
|
47
47
|
import * as ff_core_JsValue from "../../ff/core/JsValue.mjs"
|
|
48
48
|
|
|
49
|
+
import * as ff_core_Json from "../../ff/core/Json.mjs"
|
|
50
|
+
|
|
49
51
|
import * as ff_core_List from "../../ff/core/List.mjs"
|
|
50
52
|
|
|
51
53
|
import * as ff_core_Lock from "../../ff/core/Lock.mjs"
|
|
@@ -46,6 +46,8 @@ import * as ff_core_JsSystem from "../../ff/core/JsSystem.mjs"
|
|
|
46
46
|
|
|
47
47
|
import * as ff_core_JsValue from "../../ff/core/JsValue.mjs"
|
|
48
48
|
|
|
49
|
+
import * as ff_core_Json from "../../ff/core/Json.mjs"
|
|
50
|
+
|
|
49
51
|
import * as ff_core_List from "../../ff/core/List.mjs"
|
|
50
52
|
|
|
51
53
|
import * as ff_core_Lock from "../../ff/core/Lock.mjs"
|
|
@@ -46,6 +46,8 @@ import * as ff_core_JsSystem from "../../ff/core/JsSystem.mjs"
|
|
|
46
46
|
|
|
47
47
|
import * as ff_core_JsValue from "../../ff/core/JsValue.mjs"
|
|
48
48
|
|
|
49
|
+
import * as ff_core_Json from "../../ff/core/Json.mjs"
|
|
50
|
+
|
|
49
51
|
import * as ff_core_List from "../../ff/core/List.mjs"
|
|
50
52
|
|
|
51
53
|
import * as ff_core_Lock from "../../ff/core/Lock.mjs"
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"description": "Firefly compiler",
|
|
5
5
|
"author": "Firefly team",
|
|
6
6
|
"license": "MIT",
|
|
7
|
-
"version": "0.4.
|
|
7
|
+
"version": "0.4.11",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
10
10
|
"url": "https://github.com/Ahnfelt/firefly-boot"
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"Programming Languages"
|
|
15
15
|
],
|
|
16
16
|
"engines": {
|
|
17
|
-
"node": "
|
|
17
|
+
"node": ">=18.0.0"
|
|
18
18
|
},
|
|
19
19
|
"main": "./vscode/client/out/extension",
|
|
20
20
|
"icon": "./vscode/icons/firefly-logo.png",
|
package/postgresql/Pg.ff
CHANGED
|
@@ -62,11 +62,11 @@ extend self: PgPool {
|
|
|
62
62
|
|
|
63
63
|
connect(): PgConnection {
|
|
64
64
|
UnsafeJs.throwIfCancelled()
|
|
65
|
-
PgConnection(UnsafeJs.await {
|
|
65
|
+
PgConnection(UnsafeJs.await {self.jsValue.call0("connect")})
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
close(): Unit {
|
|
69
|
-
UnsafeJs.await {
|
|
69
|
+
UnsafeJs.await {self.jsValue.call0("end")}
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
connectionCount(): Int {
|
|
@@ -300,7 +300,7 @@ extend self: PgStatement {
|
|
|
300
300
|
}
|
|
301
301
|
|
|
302
302
|
each(body: PgRow => Unit): Unit {
|
|
303
|
-
self.all {
|
|
303
|
+
self.all {row =>
|
|
304
304
|
body(row)
|
|
305
305
|
True
|
|
306
306
|
}
|
|
@@ -308,7 +308,7 @@ extend self: PgStatement {
|
|
|
308
308
|
|
|
309
309
|
map[T](body: PgRow => T): List[T] {
|
|
310
310
|
mutable result = []
|
|
311
|
-
self.each {
|
|
311
|
+
self.each {row =>
|
|
312
312
|
result = [body(row), ...result]
|
|
313
313
|
}
|
|
314
314
|
result.reverse()
|
|
@@ -379,12 +379,12 @@ internalRunStatement(statement: PgStatement, body: Option[PgRow => Bool]): Int {
|
|
|
379
379
|
UnsafeJs.throwIfCancelled()
|
|
380
380
|
let pair = internalParseParameters(statement.sql)
|
|
381
381
|
let parameters = internalCheckParameters(pair.second, statement.parameters)
|
|
382
|
-
let result = UnsafeJs.await {
|
|
382
|
+
let result = UnsafeJs.await {statement.connection.grab().jsValue.call2("query", pair.first, parameters)}
|
|
383
383
|
body.{
|
|
384
384
|
| None =>
|
|
385
385
|
result.get("rowCount").grabInt()
|
|
386
386
|
| Some(f) =>
|
|
387
|
-
let all = result.get("rows").grabArray().toList().all {
|
|
387
|
+
let all = result.get("rows").grabArray().toList().all {row =>
|
|
388
388
|
f(PgRow(row))
|
|
389
389
|
}
|
|
390
390
|
if(all) {1} else {0}
|
|
@@ -392,9 +392,9 @@ internalRunStatement(statement: PgStatement, body: Option[PgRow => Bool]): Int {
|
|
|
392
392
|
}
|
|
393
393
|
|
|
394
394
|
internalBatchStatements(
|
|
395
|
-
connection: PgConnection
|
|
396
|
-
statements: List[PgStatement]
|
|
397
|
-
body: Option[PgRow => Bool]
|
|
395
|
+
connection: PgConnection
|
|
396
|
+
statements: List[PgStatement]
|
|
397
|
+
body: Option[PgRow => Bool]
|
|
398
398
|
endBody: Option[() => Unit]
|
|
399
399
|
): List[Int] {
|
|
400
400
|
let sqlCache = statements.map {s => Pair(s.sql, s.sql)}.group().map {sql, list =>
|
|
@@ -409,7 +409,7 @@ internalBatchStatements(
|
|
|
409
409
|
}
|
|
410
410
|
Pair(sql, (newSql = pair.first, parameterNames = pair.second, prepared = prepared))
|
|
411
411
|
}
|
|
412
|
-
let promises = statements.map {
|
|
412
|
+
let promises = statements.map {statement =>
|
|
413
413
|
UnsafeJs.throwIfCancelled()
|
|
414
414
|
let record = sqlCache.grab(statement.sql)
|
|
415
415
|
let parameters = internalCheckParameters(record.parameterNames, statement.parameters)
|
|
@@ -418,15 +418,15 @@ internalBatchStatements(
|
|
|
418
418
|
.with("values", parameters)
|
|
419
419
|
connection.jsValue.call1("query", record.prepared.map {query.with("name", _)}.else {query})
|
|
420
420
|
}
|
|
421
|
-
let results = promises.map {
|
|
421
|
+
let results = promises.map {promise =>
|
|
422
422
|
UnsafeJs.throwIfCancelled()
|
|
423
|
-
let result = UnsafeJs.await {
|
|
423
|
+
let result = UnsafeJs.await {promise }
|
|
424
424
|
UnsafeJs.throwIfCancelled()
|
|
425
425
|
body.{
|
|
426
426
|
| None =>
|
|
427
427
|
result.get("rowCount").grabInt()
|
|
428
428
|
| Some(f) =>
|
|
429
|
-
let all = result.get("rows").grabArray().toList().all {
|
|
429
|
+
let all = result.get("rows").grabArray().toList().all {row =>
|
|
430
430
|
f(PgRow(row))
|
|
431
431
|
}
|
|
432
432
|
endBody.each {_()}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
package ff:rpc:0.0.0
|
package/rpc/Rpc.ff
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
trait I: Rpc[O] {}
|
|
2
|
+
|
|
3
|
+
capability RpcServer[I, O, C](
|
|
4
|
+
handlers: StringMap[(C, I) => O]
|
|
5
|
+
)
|
|
6
|
+
|
|
7
|
+
makeServer[I, O, C](): RpcServer[I, O, C] {
|
|
8
|
+
RpcServer(StringMap.make())
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
extend self[I, O, C]: RpcServer[I, O, C] {
|
|
12
|
+
handle(name: String, context: C, input: I): Option[O] {
|
|
13
|
+
self.handlers.get(name).map {handler =>
|
|
14
|
+
handler(context, input)
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
addCustom(
|
|
19
|
+
handler: (C, I) => O
|
|
20
|
+
): Unit {
|
|
21
|
+
let name = "TODO"
|
|
22
|
+
self.handlers.set(name) {context, input =>
|
|
23
|
+
handler(context, input)
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
extend self[C]: RpcServer[Buffer, Buffer, C] {
|
|
29
|
+
add[I: Rpc[O]: HasAnyTag: Serializable, O: Serializable](
|
|
30
|
+
handler: (C, I) => O
|
|
31
|
+
): Unit {
|
|
32
|
+
let name = Any.anyTag[I]().show()
|
|
33
|
+
self.handlers.set(name) {context, message =>
|
|
34
|
+
let input = Serializable.deserialize(message)
|
|
35
|
+
let output = handler(context, input)
|
|
36
|
+
Serializable.serialize(output)
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
capability RpcClient(
|
|
42
|
+
binaryCall: (String, Buffer) => Buffer
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
extend self: RpcClient {
|
|
46
|
+
call[I: Rpc[O]: HasAnyTag: Serializable, O: Serializable](
|
|
47
|
+
message: I
|
|
48
|
+
): O {
|
|
49
|
+
let name = Any.anyTag[I]().show()
|
|
50
|
+
let input = Serializable.serialize(message)
|
|
51
|
+
let response = self.binaryCall(name, input)
|
|
52
|
+
Serializable.deserialize(response)
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
makeClient(
|
|
57
|
+
httpClient: HttpClient
|
|
58
|
+
prefix: String
|
|
59
|
+
method: String = "POST"
|
|
60
|
+
): RpcClient {
|
|
61
|
+
RpcClient {name, buffer =>
|
|
62
|
+
let response = httpClient.fetch(
|
|
63
|
+
url = prefix + name,
|
|
64
|
+
method = method,
|
|
65
|
+
body = Some(HttpClient.bodyBuffer(buffer))
|
|
66
|
+
)
|
|
67
|
+
response.readBuffer()
|
|
68
|
+
}
|
|
69
|
+
}
|