firefly-compiler 0.4.79 → 0.4.81
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/.hintrc +4 -4
- package/.vscode/settings.json +4 -4
- package/bin/Release.ff +153 -153
- package/bin/firefly.mjs +1 -1
- package/compiler/Builder.ff +257 -257
- package/compiler/Compiler.ff +227 -227
- package/compiler/Dependencies.ff +187 -187
- package/compiler/DependencyLock.ff +17 -17
- package/compiler/Inference.ff +2 -1
- package/compiler/JsEmitter.ff +940 -946
- package/compiler/LspHook.ff +202 -202
- package/compiler/Main.ff +3 -3
- package/compiler/ModuleCache.ff +178 -178
- package/compiler/Tokenizer.ff +1 -1
- package/compiler/Unification.ff +1 -1
- package/compiler/Workspace.ff +88 -88
- package/core/.firefly/include/package-lock.json +564 -564
- package/core/.firefly/include/package.json +5 -5
- package/core/.firefly/include/prepare.sh +1 -1
- package/core/.firefly/package.ff +2 -2
- package/core/Array.ff +265 -265
- package/core/Atomic.ff +64 -64
- package/core/Box.ff +7 -7
- package/core/BrowserSystem.ff +40 -40
- package/core/BuildSystem.ff +148 -148
- package/core/Crypto.ff +96 -96
- package/core/Equal.ff +36 -36
- package/core/Float.ff +25 -0
- package/core/HttpClient.ff +148 -148
- package/core/JsSystem.ff +69 -69
- package/core/Json.ff +434 -434
- package/core/List.ff +486 -486
- package/core/Lock.ff +144 -144
- package/core/NodeSystem.ff +216 -216
- package/core/Ordering.ff +161 -161
- package/core/Path.ff +401 -401
- package/core/Random.ff +134 -134
- package/core/RbMap.ff +216 -216
- package/core/Show.ff +43 -43
- package/core/SourceLocation.ff +68 -68
- package/core/Stream.ff +9 -9
- package/core/Task.ff +149 -141
- package/core/Try.ff +25 -4
- package/experimental/benchmarks/ListGrab.ff +23 -23
- package/experimental/benchmarks/ListGrab.java +55 -55
- package/experimental/benchmarks/Pyrotek45.ff +30 -30
- package/experimental/benchmarks/Pyrotek45.java +64 -64
- package/experimental/bidirectional/Bidi.ff +88 -88
- package/experimental/random/Index.ff +53 -53
- package/experimental/random/Process.ff +120 -120
- package/experimental/random/Scrape.ff +51 -51
- package/experimental/random/Symbols.ff +73 -73
- package/experimental/random/Tensor.ff +52 -52
- package/experimental/random/Units.ff +36 -36
- package/experimental/s3/S3TestAuthorizationHeader.ff +39 -39
- package/experimental/s3/S3TestPut.ff +16 -16
- package/experimental/tests/TestJson.ff +26 -26
- package/firefly.sh +0 -0
- package/fireflysite/.firefly/package.ff +4 -4
- package/fireflysite/CommunityOverview.ff +20 -20
- package/fireflysite/CountingButtonDemo.ff +58 -58
- package/fireflysite/DocumentParser.ff +331 -217
- package/fireflysite/ExamplesOverview.ff +40 -40
- package/fireflysite/FrontPage.ff +344 -360
- package/fireflysite/{GuideIntroduction.ff → GettingStarted.ff} +45 -52
- package/fireflysite/Guide.ff +442 -411
- package/fireflysite/Main.ff +151 -137
- package/fireflysite/MatchingPasswordsDemo.ff +82 -82
- package/fireflysite/PackagesOverview.ff +49 -49
- package/fireflysite/PostgresqlDemo.ff +34 -34
- package/fireflysite/ReferenceAll.ff +18 -0
- package/fireflysite/ReferenceIntroduction.ff +11 -0
- package/fireflysite/Styles.ff +567 -495
- package/fireflysite/Test.ff +46 -0
- package/fireflysite/assets/markdown/reference/BaseTypes.md +209 -0
- package/fireflysite/assets/markdown/reference/EmittedJavascript.md +66 -0
- package/fireflysite/assets/markdown/reference/Exceptions.md +101 -0
- package/fireflysite/assets/markdown/reference/FunctionsAndMethods.md +338 -0
- package/fireflysite/assets/markdown/reference/JavascriptInterop.md +134 -0
- package/fireflysite/assets/markdown/reference/ModulesAndPackages.md +162 -0
- package/fireflysite/assets/markdown/reference/OldStructuredConcurrency.md +48 -0
- package/fireflysite/assets/markdown/reference/PatternMatching.md +224 -0
- package/fireflysite/assets/markdown/reference/StatementsAndExpressions.md +86 -0
- package/fireflysite/assets/markdown/reference/StructuredConcurrency.md +99 -0
- package/fireflysite/assets/markdown/reference/TraitsAndInstances.md +100 -0
- package/fireflysite/assets/markdown/reference/UserDefinedTypes.md +184 -0
- package/fireflysite/assets/markdown/{ControlFlow.md → scratch/ControlFlow.md} +136 -136
- package/fireflysite/assets/markdown/scratch/Toc.md +41 -0
- package/lsp/.firefly/package.ff +1 -1
- package/lsp/CompletionHandler.ff +828 -828
- package/lsp/Handler.ff +714 -714
- package/lsp/HoverHandler.ff +79 -79
- package/lsp/LanguageServer.ff +272 -272
- package/lsp/SignatureHelpHandler.ff +55 -55
- package/lsp/SymbolHandler.ff +181 -181
- package/lsp/TestReferences.ff +17 -17
- package/lsp/TestReferencesCase.ff +7 -7
- package/lsp/stderr.txt +1 -1
- package/lsp/stdout.txt +34 -34
- package/lux/.firefly/package.ff +1 -1
- package/lux/Css.ff +648 -648
- package/lux/CssTest.ff +48 -48
- package/lux/Lux.ff +593 -487
- package/lux/LuxEvent.ff +116 -116
- package/lux/Main.ff +123 -123
- package/lux/Main2.ff +143 -143
- package/lux/TestDry.ff +27 -0
- package/output/js/ff/compiler/Builder.mjs +47 -47
- package/output/js/ff/compiler/Dependencies.mjs +3 -3
- package/output/js/ff/compiler/Inference.mjs +2 -2
- package/output/js/ff/compiler/JsEmitter.mjs +18 -72
- package/output/js/ff/compiler/Main.mjs +4 -4
- package/output/js/ff/compiler/ModuleCache.mjs +4 -4
- package/output/js/ff/core/Array.mjs +59 -59
- package/output/js/ff/core/Atomic.mjs +36 -36
- package/output/js/ff/core/BrowserSystem.mjs +11 -11
- package/output/js/ff/core/BuildSystem.mjs +30 -30
- package/output/js/ff/core/Crypto.mjs +40 -40
- package/output/js/ff/core/Float.mjs +50 -0
- package/output/js/ff/core/HttpClient.mjs +56 -56
- package/output/js/ff/core/Json.mjs +147 -147
- package/output/js/ff/core/List.mjs +50 -50
- package/output/js/ff/core/Lock.mjs +97 -97
- package/output/js/ff/core/NodeSystem.mjs +87 -87
- package/output/js/ff/core/Ordering.mjs +8 -8
- package/output/js/ff/core/Path.mjs +231 -231
- package/output/js/ff/core/Random.mjs +56 -56
- package/output/js/ff/core/Task.mjs +71 -39
- package/output/js/ff/core/Try.mjs +98 -4
- package/package.json +1 -1
- package/postgresql/Pg.ff +1 -1
- package/rpc/.firefly/package.ff +1 -1
- package/rpc/Rpc.ff +70 -70
- package/s3/.firefly/package.ff +1 -1
- package/s3/S3.ff +94 -94
- package/unsafejs/UnsafeJs.ff +19 -19
- package/vscode/LICENSE.txt +21 -21
- package/vscode/Prepublish.ff +15 -15
- package/vscode/README.md +16 -16
- package/vscode/client/package.json +22 -22
- package/vscode/client/src/extension.ts +104 -104
- package/vscode/icons/firefly-icon.svg +10 -10
- package/vscode/language-configuration.json +61 -61
- package/vscode/package-lock.json +3623 -3623
- package/vscode/package.json +1 -1
- package/vscode/snippets.json +241 -241
- package/vscode/syntaxes/firefly-markdown-injection.json +45 -45
- package/webserver/.firefly/include/package-lock.json +22 -22
- package/webserver/.firefly/include/package.json +5 -5
- package/webserver/.firefly/package.ff +2 -2
- package/webserver/WebServer.ff +685 -685
- package/websocket/.firefly/package.ff +1 -1
- package/websocket/WebSocket.ff +131 -131
- package/fireflysite/GuideAll.ff +0 -21
- package/fireflysite/GuideBaseTypes.ff +0 -168
- package/fireflysite/GuideControlFlow.ff +0 -212
- package/fireflysite/assets/markdown/Example.md +0 -78
- /package/fireflysite/assets/{NotoSansMono-Regular.ttf → font/NotoSansMono-Regular.ttf} +0 -0
- /package/fireflysite/assets/{NunitoSans-VariableFont_YTLC,opsz,wdth,wght.ttf → font/NunitoSans-VariableFont_YTLC,opsz,wdth,wght.ttf} +0 -0
- /package/fireflysite/assets/{autocomplete-small.png → image/autocomplete-small.png} +0 -0
- /package/fireflysite/assets/{autocomplete.png → image/autocomplete.png} +0 -0
- /package/fireflysite/assets/{edit-time-error.png → image/edit-time-error.png} +0 -0
- /package/fireflysite/assets/{firefly-logo-notext.png → image/firefly-logo-notext.png} +0 -0
- /package/fireflysite/assets/{firefly-logo-yellow.png → image/firefly-logo-yellow.png} +0 -0
package/fireflysite/Main.ff
CHANGED
|
@@ -1,137 +1,151 @@
|
|
|
1
|
-
import WebServer from ff:webserver
|
|
2
|
-
import Lux from ff:lux
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
let
|
|
15
|
-
system.
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
| ["
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
request.
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
request.
|
|
133
|
-
request.writeText("
|
|
134
|
-
request.writeText("<
|
|
135
|
-
request.writeText("
|
|
136
|
-
request.writeText("
|
|
137
|
-
|
|
1
|
+
import WebServer from ff:webserver
|
|
2
|
+
import Lux from ff:lux
|
|
3
|
+
import Css from ff:lux
|
|
4
|
+
import Guide
|
|
5
|
+
import GettingStarted
|
|
6
|
+
import ReferenceAll
|
|
7
|
+
import ExamplesOverview
|
|
8
|
+
import PackagesOverview
|
|
9
|
+
import CommunityOverview
|
|
10
|
+
import FrontPage
|
|
11
|
+
import Styles
|
|
12
|
+
|
|
13
|
+
nodeMain(system: NodeSystem): Unit {
|
|
14
|
+
let host = system.arguments().grab(0)
|
|
15
|
+
let port = system.arguments().grab(1).grabInt()
|
|
16
|
+
let cacheSalt = system.crypto().randomBuffer(16)
|
|
17
|
+
system.writeLine("Listening on " + host + ":" + port)
|
|
18
|
+
WebServer.new(system, host, port).listen {request =>
|
|
19
|
+
let path = request.readPath()
|
|
20
|
+
let segments = path.split('/').filter {s => s != "" && s != "." && s != ".."}
|
|
21
|
+
segments.{
|
|
22
|
+
| ["js", ...] =>
|
|
23
|
+
let asset = if(path == "/js/ff/fireflysite/Main.mjs" && system.assets().exists("/js/Main.bundle.js")) {
|
|
24
|
+
"/js/Main.bundle.js"
|
|
25
|
+
} else {
|
|
26
|
+
path
|
|
27
|
+
}
|
|
28
|
+
serveAsset(system, cacheSalt, request, "text/javascript; charset=UTF-8", asset)
|
|
29
|
+
| ["favicon.ico"] =>
|
|
30
|
+
serveAsset(system, cacheSalt, request, "image/png", "/assets/image/firefly-logo-notext.png")
|
|
31
|
+
| ["assets", "font", "FireflyMono.ttf"] =>
|
|
32
|
+
serveAsset(system, cacheSalt, request, "font/ttf", "/assets/font/NotoSansMono-Regular.ttf")
|
|
33
|
+
| ["assets", "font", "FireflySans.ttf"] =>
|
|
34
|
+
serveAsset(system, cacheSalt, request, "font/ttf", "/assets/font/NunitoSans-VariableFont_YTLC,opsz,wdth,wght.ttf")
|
|
35
|
+
| ["assets", ...rest] => serveAssets(system, cacheSalt, request, rest)
|
|
36
|
+
| _ {serveGuide(system, request)} =>
|
|
37
|
+
| _ =>
|
|
38
|
+
let parameters = if(request.readRawQueryString().size() == 0) {""} else {
|
|
39
|
+
"?" + request.readRawQueryString()
|
|
40
|
+
}
|
|
41
|
+
request.writeHeader("Location", "https://www.firefly-lang.org" + path + parameters)
|
|
42
|
+
request.writeStatus("302 Found")
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
guides = [
|
|
48
|
+
Guide("/front/", [FrontPage.new()])
|
|
49
|
+
Guide("/getting-started/", [GettingStarted.new()])
|
|
50
|
+
Guide("/examples/", ExamplesOverview.mock())
|
|
51
|
+
Guide("/reference/", ReferenceAll.mock())
|
|
52
|
+
Guide("/packages/", [PackagesOverview.new()])
|
|
53
|
+
Guide("/community/", [CommunityOverview.new()])
|
|
54
|
+
]
|
|
55
|
+
|
|
56
|
+
serveGuide(system: NodeSystem, request: WebRequest[WebResponse]): Bool {
|
|
57
|
+
let demos = ExamplesOverview.demos()
|
|
58
|
+
mutable served = False
|
|
59
|
+
guides.each {guide =>
|
|
60
|
+
if(request.readPath().startsWith(guide.prefix)):
|
|
61
|
+
let kebab = request.readPath().dropFirst(guide.prefix.size())
|
|
62
|
+
let htmlAndCss = Lux.renderToString(system) {lux =>
|
|
63
|
+
Guide.render(lux, system.httpClient(), guide.prefix, kebab, guides, demos)
|
|
64
|
+
}
|
|
65
|
+
let title = guide.documents.find {d =>
|
|
66
|
+
Guide.kebabCase(d.heading()) == kebab
|
|
67
|
+
}.map {_.title(guide)}.else {guide.title()}
|
|
68
|
+
serveGuideHtml(title, htmlAndCss.first, htmlAndCss.second, request)
|
|
69
|
+
served = True
|
|
70
|
+
}
|
|
71
|
+
served
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
browserMain(system: BrowserSystem): Unit {
|
|
75
|
+
let demos = ExamplesOverview.demos()
|
|
76
|
+
guides.collect {guide =>
|
|
77
|
+
if(system.urlPath().startsWith(guide.prefix)):
|
|
78
|
+
Lux.renderById(system, "main") {lux =>
|
|
79
|
+
let kebab = system.urlPath().dropFirst(guide.prefix.size())
|
|
80
|
+
Guide.render(lux, system.httpClient(), guide.prefix, kebab, guides, demos)
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
buildMain(system: BuildSystem) {
|
|
86
|
+
let browser = system.compileForBrowser("Main.ff")
|
|
87
|
+
let assets = AssetSystem.create()
|
|
88
|
+
.addAssets("/js/", browser.assets())
|
|
89
|
+
.addAssets("/assets/", system.packageAssets().assets("/assets/"))
|
|
90
|
+
system.setAssets(assets)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
serveAssets(system: NodeSystem, salt: Buffer, request: WebRequest[WebResponse], segments: List[String]): Unit {
|
|
94
|
+
let asset = "/assets/" + segments.join("/")
|
|
95
|
+
if(!system.assets().exists(asset)) {
|
|
96
|
+
request.writeStatus("404 Not Found")
|
|
97
|
+
} else:
|
|
98
|
+
|
|
99
|
+
guessContentType(asset).or {
|
|
100
|
+
request.writeStatus("404 Not Found")
|
|
101
|
+
}: contentType =>
|
|
102
|
+
|
|
103
|
+
serveAsset(system, salt, request, contentType, asset)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
guessContentType(path: String): Option[String] {
|
|
107
|
+
path.split('.').last().flatMap {
|
|
108
|
+
| "md" => Some("text/markdown")
|
|
109
|
+
| "png" => Some("image/png")
|
|
110
|
+
| "ttf" => Some("font/ttf")
|
|
111
|
+
| _ => None
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
serveAsset(system: NodeSystem, salt: Buffer, request: WebRequest[WebResponse], contentType: String, asset: String): Unit {
|
|
116
|
+
let etag = "\"" + system.crypto().hmacSha256(salt, asset.toBuffer()).toHex() + "\""
|
|
117
|
+
request.writeHeader("Content-Type", contentType)
|
|
118
|
+
if(request.readHeader("host") == Some("localhost:8080")) {
|
|
119
|
+
request.writeHeader("Cache-Control", "no-cache")
|
|
120
|
+
} else {
|
|
121
|
+
request.writeHeader("Cache-Control", "public, max-age=60, must-revalidate")
|
|
122
|
+
request.writeHeader("ETag", etag)
|
|
123
|
+
}
|
|
124
|
+
if(request.readHeader("if-none-match").any {_.trim() == etag}) {
|
|
125
|
+
request.writeStatus("304 Not Modified")
|
|
126
|
+
} else {
|
|
127
|
+
request.writeStream(system.assets().readStream(asset))
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
serveGuideHtml(title: String, contentHtml: String, styleTags: String, request: WebRequest[WebResponse]): Unit {
|
|
132
|
+
request.writeHeader("Content-Type", "text/html; charset=UTF-8")
|
|
133
|
+
request.writeText("<!doctype html>")
|
|
134
|
+
request.writeText("<html lang='en' style='background-color: #ffffff; color: #333333; width: 100%; height: 100%; color-scheme: light;'>")
|
|
135
|
+
request.writeText("<script type='module' src='/js/ff/fireflysite/Main.mjs'></script>")
|
|
136
|
+
request.writeText("<head>")
|
|
137
|
+
request.writeText("<title>" + title + "</title>")
|
|
138
|
+
request.writeText("<meta name='viewport' content='width=device-width, initial-scale=1.0'>")
|
|
139
|
+
request.writeText("<meta name='theme-color' content='#ecc45e'>")
|
|
140
|
+
request.writeText("<link rel='preload' href='/assets/font/FireflyMono.ttf' as='font' crossorigin='anonymous'>")
|
|
141
|
+
request.writeText("<link rel='preload' href='/assets/font/FireflySans.ttf' as='font' crossorigin='anonymous'>")
|
|
142
|
+
request.writeText("<link rel='preload' href='/assets/image/firefly-logo-yellow.png' as='image'>")
|
|
143
|
+
request.writeText("<style>@font-face { font-family: 'Firefly Mono'; font-display: fallback; src: url('/assets/font/FireflyMono.ttf'); unicode-range: U+000-5FF; }</style>")
|
|
144
|
+
request.writeText("<style>@font-face { font-family: 'Firefly Sans'; font-display: fallback; src: url('/assets/font/FireflySans.ttf'); unicode-range: U+000-5FF; }</style>")
|
|
145
|
+
request.writeText(styleTags)
|
|
146
|
+
request.writeText("</head>")
|
|
147
|
+
request.writeText("<body style='margin: 0; padding: 0; width: 100%; height: 100%; touch-action: manipulation;'>")
|
|
148
|
+
request.writeText("<div id='main'>" + contentHtml + "</div>")
|
|
149
|
+
request.writeText("</body>")
|
|
150
|
+
request.writeText("</html>")
|
|
151
|
+
}
|
|
@@ -1,82 +1,82 @@
|
|
|
1
|
-
import Guide
|
|
2
|
-
import Lux from ff:lux
|
|
3
|
-
import LuxEvent from ff:lux
|
|
4
|
-
|
|
5
|
-
name = "Matching passwords"
|
|
6
|
-
|
|
7
|
-
new(): Demo {
|
|
8
|
-
Demo(
|
|
9
|
-
name
|
|
10
|
-
{render(_)}
|
|
11
|
-
)
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
render(lux: Lux): Unit {
|
|
15
|
-
function passwordInput(password: String, setPassword: String => Unit) {
|
|
16
|
-
lux.div {
|
|
17
|
-
lux.input {
|
|
18
|
-
lux.set("type", "password")
|
|
19
|
-
lux.set("autocomplete", "new-password")
|
|
20
|
-
lux.setValue(password)
|
|
21
|
-
lux.onInput {event =>
|
|
22
|
-
setPassword(event.text())
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
lux.form {
|
|
28
|
-
lux.useState(""): password1, setPassword1 =>
|
|
29
|
-
lux.useState(""): password2, setPassword2 =>
|
|
30
|
-
passwordInput(password1, setPassword1)
|
|
31
|
-
passwordInput(password2, setPassword2)
|
|
32
|
-
lux.div {
|
|
33
|
-
if(password1 != password2) {
|
|
34
|
-
lux.text("Passwords don't match!")
|
|
35
|
-
} elseIf {password2.size() != 0} {
|
|
36
|
-
lux.text("Passwords match!")
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
newDocument(): Document {
|
|
43
|
-
ReadyDocument([
|
|
44
|
-
Section(name, [
|
|
45
|
-
Paragraph([Text("Two passwords fields and a check that they match.")])
|
|
46
|
-
])
|
|
47
|
-
Section("Demo", [
|
|
48
|
-
LuxDemo(name)
|
|
49
|
-
])
|
|
50
|
-
Section("Code", [
|
|
51
|
-
CodeBlock("""
|
|
52
|
-
render(lux: Lux): Unit {
|
|
53
|
-
function passwordInput(password: String, setPassword: String => Unit) {
|
|
54
|
-
lux.div {
|
|
55
|
-
lux.input {
|
|
56
|
-
lux.set("type", "password")
|
|
57
|
-
lux.set("autocomplete", "new-password")
|
|
58
|
-
lux.setValue(password)
|
|
59
|
-
lux.onInput {event =>
|
|
60
|
-
setPassword(event.text())
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
lux.form {
|
|
66
|
-
lux.useState(""): password1, setPassword1 =>
|
|
67
|
-
lux.useState(""): password2, setPassword2 =>
|
|
68
|
-
passwordInput(password1, setPassword1)
|
|
69
|
-
passwordInput(password2, setPassword2)
|
|
70
|
-
lux.div {
|
|
71
|
-
if(password1 != password2) {
|
|
72
|
-
lux.text("Passwords don't match!")
|
|
73
|
-
} elseIf {password2.size() != 0} {
|
|
74
|
-
lux.text("Passwords match!")
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
""", firefly = True)
|
|
80
|
-
])
|
|
81
|
-
])
|
|
82
|
-
}
|
|
1
|
+
import Guide
|
|
2
|
+
import Lux from ff:lux
|
|
3
|
+
import LuxEvent from ff:lux
|
|
4
|
+
|
|
5
|
+
name = "Matching passwords"
|
|
6
|
+
|
|
7
|
+
new(): Demo {
|
|
8
|
+
Demo(
|
|
9
|
+
name
|
|
10
|
+
{render(_)}
|
|
11
|
+
)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
render(lux: Lux): Unit {
|
|
15
|
+
function passwordInput(password: String, setPassword: String => Unit) {
|
|
16
|
+
lux.div {
|
|
17
|
+
lux.input {
|
|
18
|
+
lux.set("type", "password")
|
|
19
|
+
lux.set("autocomplete", "new-password")
|
|
20
|
+
lux.setValue(password)
|
|
21
|
+
lux.onInput {event =>
|
|
22
|
+
setPassword(event.text())
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
lux.form {
|
|
28
|
+
lux.useState(""): password1, setPassword1 =>
|
|
29
|
+
lux.useState(""): password2, setPassword2 =>
|
|
30
|
+
passwordInput(password1, setPassword1)
|
|
31
|
+
passwordInput(password2, setPassword2)
|
|
32
|
+
lux.div {
|
|
33
|
+
if(password1 != password2) {
|
|
34
|
+
lux.text("Passwords don't match!")
|
|
35
|
+
} elseIf {password2.size() != 0} {
|
|
36
|
+
lux.text("Passwords match!")
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
newDocument(): Document {
|
|
43
|
+
ReadyDocument([
|
|
44
|
+
Section(name, [
|
|
45
|
+
Paragraph([Text("Two passwords fields and a check that they match.")])
|
|
46
|
+
])
|
|
47
|
+
Section("Demo", [
|
|
48
|
+
LuxDemo(name)
|
|
49
|
+
])
|
|
50
|
+
Section("Code", [
|
|
51
|
+
CodeBlock("""
|
|
52
|
+
render(lux: Lux): Unit {
|
|
53
|
+
function passwordInput(password: String, setPassword: String => Unit) {
|
|
54
|
+
lux.div {
|
|
55
|
+
lux.input {
|
|
56
|
+
lux.set("type", "password")
|
|
57
|
+
lux.set("autocomplete", "new-password")
|
|
58
|
+
lux.setValue(password)
|
|
59
|
+
lux.onInput {event =>
|
|
60
|
+
setPassword(event.text())
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
lux.form {
|
|
66
|
+
lux.useState(""): password1, setPassword1 =>
|
|
67
|
+
lux.useState(""): password2, setPassword2 =>
|
|
68
|
+
passwordInput(password1, setPassword1)
|
|
69
|
+
passwordInput(password2, setPassword2)
|
|
70
|
+
lux.div {
|
|
71
|
+
if(password1 != password2) {
|
|
72
|
+
lux.text("Passwords don't match!")
|
|
73
|
+
} elseIf {password2.size() != 0} {
|
|
74
|
+
lux.text("Passwords match!")
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
""", firefly = True)
|
|
80
|
+
])
|
|
81
|
+
])
|
|
82
|
+
}
|
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
import Guide
|
|
2
|
-
import CountingButtonDemo
|
|
3
|
-
import MatchingPasswordsDemo
|
|
4
|
-
|
|
5
|
-
new(): Document {
|
|
6
|
-
ReadyDocument([
|
|
7
|
-
Section("Packages", [
|
|
8
|
-
Paragraph([
|
|
9
|
-
Text("Here you'll eventually find the package index.")
|
|
10
|
-
Text("For now, here's a short list of essential packages.")
|
|
11
|
-
])
|
|
12
|
-
])
|
|
13
|
-
Section("ff:core", [
|
|
14
|
-
Paragraph([
|
|
15
|
-
Text("The standard library of Firefly.")
|
|
16
|
-
])
|
|
17
|
-
])
|
|
18
|
-
Section("ff:webserver", [
|
|
19
|
-
Paragraph([
|
|
20
|
-
Text("A webserver package. Has HTTPS and WebSocket support.")
|
|
21
|
-
])
|
|
22
|
-
])
|
|
23
|
-
Section("ff:websocket", [
|
|
24
|
-
Paragraph([
|
|
25
|
-
Text("A package for making websocket connections.")
|
|
26
|
-
])
|
|
27
|
-
])
|
|
28
|
-
Section("ff:postgresql", [
|
|
29
|
-
Paragraph([
|
|
30
|
-
Text("A package for connecting to PostgreSQL. Has connection pool support.")
|
|
31
|
-
])
|
|
32
|
-
])
|
|
33
|
-
Section("ff:lux", [
|
|
34
|
-
Paragraph([
|
|
35
|
-
Text("A package for building interactive web interfaces.")
|
|
36
|
-
])
|
|
37
|
-
])
|
|
38
|
-
Section("ff:rpc", [
|
|
39
|
-
Paragraph([
|
|
40
|
-
Text("A package for type safe remote procedure calls.")
|
|
41
|
-
])
|
|
42
|
-
])
|
|
43
|
-
Section("ff:unsafejs", [
|
|
44
|
-
Paragraph([
|
|
45
|
-
Text("A FFI package for JavaScript.")
|
|
46
|
-
])
|
|
47
|
-
])
|
|
48
|
-
])
|
|
49
|
-
}
|
|
1
|
+
import Guide
|
|
2
|
+
import CountingButtonDemo
|
|
3
|
+
import MatchingPasswordsDemo
|
|
4
|
+
|
|
5
|
+
new(): Document {
|
|
6
|
+
ReadyDocument([
|
|
7
|
+
Section("Packages", [
|
|
8
|
+
Paragraph([
|
|
9
|
+
Text("Here you'll eventually find the package index.")
|
|
10
|
+
Text("For now, here's a short list of essential packages.")
|
|
11
|
+
])
|
|
12
|
+
])
|
|
13
|
+
Section("ff:core", [
|
|
14
|
+
Paragraph([
|
|
15
|
+
Text("The standard library of Firefly.")
|
|
16
|
+
])
|
|
17
|
+
])
|
|
18
|
+
Section("ff:webserver", [
|
|
19
|
+
Paragraph([
|
|
20
|
+
Text("A webserver package. Has HTTPS and WebSocket support.")
|
|
21
|
+
])
|
|
22
|
+
])
|
|
23
|
+
Section("ff:websocket", [
|
|
24
|
+
Paragraph([
|
|
25
|
+
Text("A package for making websocket connections.")
|
|
26
|
+
])
|
|
27
|
+
])
|
|
28
|
+
Section("ff:postgresql", [
|
|
29
|
+
Paragraph([
|
|
30
|
+
Text("A package for connecting to PostgreSQL. Has connection pool support.")
|
|
31
|
+
])
|
|
32
|
+
])
|
|
33
|
+
Section("ff:lux", [
|
|
34
|
+
Paragraph([
|
|
35
|
+
Text("A package for building interactive web interfaces.")
|
|
36
|
+
])
|
|
37
|
+
])
|
|
38
|
+
Section("ff:rpc", [
|
|
39
|
+
Paragraph([
|
|
40
|
+
Text("A package for type safe remote procedure calls.")
|
|
41
|
+
])
|
|
42
|
+
])
|
|
43
|
+
Section("ff:unsafejs", [
|
|
44
|
+
Paragraph([
|
|
45
|
+
Text("A FFI package for JavaScript.")
|
|
46
|
+
])
|
|
47
|
+
])
|
|
48
|
+
])
|
|
49
|
+
}
|
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
import Guide
|
|
2
|
-
import Lux from ff:lux
|
|
3
|
-
import LuxEvent from ff:lux
|
|
4
|
-
|
|
5
|
-
name = "Connecting to PostgreSQL"
|
|
6
|
-
|
|
7
|
-
newDocument(): Document {
|
|
8
|
-
ReadyDocument([
|
|
9
|
-
Section(name, [
|
|
10
|
-
Paragraph([Text("Connect to a PostgreSQL database and run a query.")])
|
|
11
|
-
Paragraph([Text("Add a dependency on "), Code("ff:postgresql"), Text(":")])
|
|
12
|
-
CodeBlock("""
|
|
13
|
-
dependency ff:postgresql:0.0.0
|
|
14
|
-
""", firefly = True)
|
|
15
|
-
Paragraph([Text("Import the"), Code("Pg"), Text("module from it:")])
|
|
16
|
-
CodeBlock("""
|
|
17
|
-
import Pg from ff:postgresql
|
|
18
|
-
""", firefly = True)
|
|
19
|
-
Paragraph([Text("Create a connection pool with the appropriate connection parameters:")])
|
|
20
|
-
CodeBlock("""
|
|
21
|
-
let pool = Pg.newPool(...)
|
|
22
|
-
""", firefly = True)
|
|
23
|
-
Paragraph([Text("And run your first transaction, e.g.:")])
|
|
24
|
-
CodeBlock("""
|
|
25
|
-
pool.transaction {connection =>
|
|
26
|
-
let emails = connection.statement("select email from users")
|
|
27
|
-
.map {row => row.getString("email").grab()}
|
|
28
|
-
Log.debug(emails)
|
|
29
|
-
}
|
|
30
|
-
""", firefly = True)
|
|
31
|
-
Paragraph([Text("Note that"), Code(".map", firefly = True), Text("here runs for each row of the result.")])
|
|
32
|
-
])
|
|
33
|
-
])
|
|
34
|
-
}
|
|
1
|
+
import Guide
|
|
2
|
+
import Lux from ff:lux
|
|
3
|
+
import LuxEvent from ff:lux
|
|
4
|
+
|
|
5
|
+
name = "Connecting to PostgreSQL"
|
|
6
|
+
|
|
7
|
+
newDocument(): Document {
|
|
8
|
+
ReadyDocument([
|
|
9
|
+
Section(name, [
|
|
10
|
+
Paragraph([Text("Connect to a PostgreSQL database and run a query.")])
|
|
11
|
+
Paragraph([Text("Add a dependency on "), Code("ff:postgresql"), Text(":")])
|
|
12
|
+
CodeBlock("""
|
|
13
|
+
dependency ff:postgresql:0.0.0
|
|
14
|
+
""", firefly = True)
|
|
15
|
+
Paragraph([Text("Import the"), Code("Pg"), Text("module from it:")])
|
|
16
|
+
CodeBlock("""
|
|
17
|
+
import Pg from ff:postgresql
|
|
18
|
+
""", firefly = True)
|
|
19
|
+
Paragraph([Text("Create a connection pool with the appropriate connection parameters:")])
|
|
20
|
+
CodeBlock("""
|
|
21
|
+
let pool = Pg.newPool(...)
|
|
22
|
+
""", firefly = True)
|
|
23
|
+
Paragraph([Text("And run your first transaction, e.g.:")])
|
|
24
|
+
CodeBlock("""
|
|
25
|
+
pool.transaction {connection =>
|
|
26
|
+
let emails = connection.statement("select email from users")
|
|
27
|
+
.map {row => row.getString("email").grab()}
|
|
28
|
+
Log.debug(emails)
|
|
29
|
+
}
|
|
30
|
+
""", firefly = True)
|
|
31
|
+
Paragraph([Text("Note that"), Code(".map", firefly = True), Text("here runs for each row of the result.")])
|
|
32
|
+
])
|
|
33
|
+
])
|
|
34
|
+
}
|