firefly-compiler 0.4.79 → 0.4.80

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 (158) hide show
  1. package/.hintrc +4 -4
  2. package/.vscode/settings.json +4 -4
  3. package/bin/Release.ff +153 -153
  4. package/bin/firefly.mjs +1 -1
  5. package/compiler/Builder.ff +257 -257
  6. package/compiler/Compiler.ff +227 -227
  7. package/compiler/Dependencies.ff +187 -187
  8. package/compiler/DependencyLock.ff +17 -17
  9. package/compiler/Inference.ff +2 -1
  10. package/compiler/JsEmitter.ff +940 -946
  11. package/compiler/LspHook.ff +202 -202
  12. package/compiler/Main.ff +3 -3
  13. package/compiler/ModuleCache.ff +178 -178
  14. package/compiler/Tokenizer.ff +1 -1
  15. package/compiler/Unification.ff +1 -1
  16. package/compiler/Workspace.ff +88 -88
  17. package/core/.firefly/include/package-lock.json +564 -564
  18. package/core/.firefly/include/package.json +5 -5
  19. package/core/.firefly/include/prepare.sh +1 -1
  20. package/core/.firefly/package.ff +2 -2
  21. package/core/Array.ff +265 -265
  22. package/core/Atomic.ff +64 -64
  23. package/core/Box.ff +7 -7
  24. package/core/BrowserSystem.ff +40 -40
  25. package/core/BuildSystem.ff +148 -148
  26. package/core/Crypto.ff +96 -96
  27. package/core/Equal.ff +36 -36
  28. package/core/Float.ff +25 -0
  29. package/core/HttpClient.ff +148 -148
  30. package/core/JsSystem.ff +69 -69
  31. package/core/Json.ff +434 -434
  32. package/core/List.ff +486 -486
  33. package/core/Lock.ff +144 -144
  34. package/core/NodeSystem.ff +216 -216
  35. package/core/Ordering.ff +161 -161
  36. package/core/Path.ff +401 -401
  37. package/core/Random.ff +134 -134
  38. package/core/RbMap.ff +216 -216
  39. package/core/Show.ff +43 -43
  40. package/core/SourceLocation.ff +68 -68
  41. package/core/Stream.ff +9 -9
  42. package/core/Task.ff +141 -141
  43. package/core/Try.ff +25 -4
  44. package/experimental/benchmarks/ListGrab.ff +23 -23
  45. package/experimental/benchmarks/ListGrab.java +55 -55
  46. package/experimental/benchmarks/Pyrotek45.ff +30 -30
  47. package/experimental/benchmarks/Pyrotek45.java +64 -64
  48. package/experimental/bidirectional/Bidi.ff +88 -88
  49. package/experimental/random/Index.ff +53 -53
  50. package/experimental/random/Process.ff +120 -120
  51. package/experimental/random/Scrape.ff +51 -51
  52. package/experimental/random/Symbols.ff +73 -73
  53. package/experimental/random/Tensor.ff +52 -52
  54. package/experimental/random/Units.ff +36 -36
  55. package/experimental/s3/S3TestAuthorizationHeader.ff +39 -39
  56. package/experimental/s3/S3TestPut.ff +16 -16
  57. package/experimental/tests/TestJson.ff +26 -26
  58. package/firefly.sh +0 -0
  59. package/fireflysite/.firefly/package.ff +4 -4
  60. package/fireflysite/CommunityOverview.ff +20 -20
  61. package/fireflysite/CountingButtonDemo.ff +58 -58
  62. package/fireflysite/DocumentParser.ff +331 -217
  63. package/fireflysite/ExamplesOverview.ff +40 -40
  64. package/fireflysite/FrontPage.ff +344 -360
  65. package/fireflysite/{GuideIntroduction.ff → GettingStarted.ff} +45 -52
  66. package/fireflysite/Guide.ff +443 -411
  67. package/fireflysite/Main.ff +141 -137
  68. package/fireflysite/MatchingPasswordsDemo.ff +82 -82
  69. package/fireflysite/PackagesOverview.ff +49 -49
  70. package/fireflysite/PostgresqlDemo.ff +34 -34
  71. package/fireflysite/ReferenceAll.ff +19 -0
  72. package/fireflysite/ReferenceIntroduction.ff +11 -0
  73. package/fireflysite/Styles.ff +567 -495
  74. package/fireflysite/Test.ff +38 -0
  75. package/fireflysite/assets/markdown/reference/BaseTypes.md +209 -0
  76. package/fireflysite/assets/markdown/reference/FunctionsAndMethods.md +208 -0
  77. package/fireflysite/assets/markdown/reference/ModulesAndPackages.md +168 -0
  78. package/fireflysite/assets/markdown/reference/PatternMatching.md +224 -0
  79. package/fireflysite/assets/markdown/reference/StatementsAndExpressions.md +86 -0
  80. package/fireflysite/assets/markdown/reference/TraitsAndInstances.md +100 -0
  81. package/fireflysite/assets/markdown/reference/UserDefinedTypes.md +184 -0
  82. package/fireflysite/assets/markdown/{ControlFlow.md → scratch/ControlFlow.md} +136 -136
  83. package/fireflysite/assets/markdown/scratch/Toc.md +41 -0
  84. package/lsp/.firefly/package.ff +1 -1
  85. package/lsp/CompletionHandler.ff +828 -828
  86. package/lsp/Handler.ff +714 -714
  87. package/lsp/HoverHandler.ff +79 -79
  88. package/lsp/LanguageServer.ff +272 -272
  89. package/lsp/SignatureHelpHandler.ff +55 -55
  90. package/lsp/SymbolHandler.ff +181 -181
  91. package/lsp/TestReferences.ff +17 -17
  92. package/lsp/TestReferencesCase.ff +7 -7
  93. package/lsp/stderr.txt +1 -1
  94. package/lsp/stdout.txt +34 -34
  95. package/lux/.firefly/package.ff +1 -1
  96. package/lux/Css.ff +648 -648
  97. package/lux/CssTest.ff +48 -48
  98. package/lux/Lux.ff +487 -487
  99. package/lux/LuxEvent.ff +116 -116
  100. package/lux/Main.ff +123 -123
  101. package/lux/Main2.ff +143 -143
  102. package/output/js/ff/compiler/Builder.mjs +47 -47
  103. package/output/js/ff/compiler/Dependencies.mjs +3 -3
  104. package/output/js/ff/compiler/Inference.mjs +2 -2
  105. package/output/js/ff/compiler/JsEmitter.mjs +18 -72
  106. package/output/js/ff/compiler/Main.mjs +4 -4
  107. package/output/js/ff/compiler/ModuleCache.mjs +4 -4
  108. package/output/js/ff/core/Array.mjs +59 -59
  109. package/output/js/ff/core/Atomic.mjs +36 -36
  110. package/output/js/ff/core/BrowserSystem.mjs +11 -11
  111. package/output/js/ff/core/BuildSystem.mjs +30 -30
  112. package/output/js/ff/core/Crypto.mjs +40 -40
  113. package/output/js/ff/core/Float.mjs +50 -0
  114. package/output/js/ff/core/HttpClient.mjs +56 -56
  115. package/output/js/ff/core/Json.mjs +147 -147
  116. package/output/js/ff/core/List.mjs +50 -50
  117. package/output/js/ff/core/Lock.mjs +97 -97
  118. package/output/js/ff/core/NodeSystem.mjs +87 -87
  119. package/output/js/ff/core/Ordering.mjs +8 -8
  120. package/output/js/ff/core/Path.mjs +231 -231
  121. package/output/js/ff/core/Random.mjs +56 -56
  122. package/output/js/ff/core/Task.mjs +39 -39
  123. package/output/js/ff/core/Try.mjs +98 -4
  124. package/package.json +1 -1
  125. package/postgresql/Pg.ff +1 -1
  126. package/rpc/.firefly/package.ff +1 -1
  127. package/rpc/Rpc.ff +70 -70
  128. package/s3/.firefly/package.ff +1 -1
  129. package/s3/S3.ff +94 -94
  130. package/unsafejs/UnsafeJs.ff +19 -19
  131. package/vscode/LICENSE.txt +21 -21
  132. package/vscode/Prepublish.ff +15 -15
  133. package/vscode/README.md +16 -16
  134. package/vscode/client/package.json +22 -22
  135. package/vscode/client/src/extension.ts +104 -104
  136. package/vscode/icons/firefly-icon.svg +10 -10
  137. package/vscode/language-configuration.json +61 -61
  138. package/vscode/package-lock.json +3623 -3623
  139. package/vscode/package.json +1 -1
  140. package/vscode/snippets.json +241 -241
  141. package/vscode/syntaxes/firefly-markdown-injection.json +45 -45
  142. package/webserver/.firefly/include/package-lock.json +22 -22
  143. package/webserver/.firefly/include/package.json +5 -5
  144. package/webserver/.firefly/package.ff +2 -2
  145. package/webserver/WebServer.ff +685 -685
  146. package/websocket/.firefly/package.ff +1 -1
  147. package/websocket/WebSocket.ff +131 -131
  148. package/fireflysite/GuideAll.ff +0 -21
  149. package/fireflysite/GuideBaseTypes.ff +0 -168
  150. package/fireflysite/GuideControlFlow.ff +0 -212
  151. package/fireflysite/assets/markdown/Example.md +0 -78
  152. /package/fireflysite/assets/{NotoSansMono-Regular.ttf → font/NotoSansMono-Regular.ttf} +0 -0
  153. /package/fireflysite/assets/{NunitoSans-VariableFont_YTLC,opsz,wdth,wght.ttf → font/NunitoSans-VariableFont_YTLC,opsz,wdth,wght.ttf} +0 -0
  154. /package/fireflysite/assets/{autocomplete-small.png → image/autocomplete-small.png} +0 -0
  155. /package/fireflysite/assets/{autocomplete.png → image/autocomplete.png} +0 -0
  156. /package/fireflysite/assets/{edit-time-error.png → image/edit-time-error.png} +0 -0
  157. /package/fireflysite/assets/{firefly-logo-notext.png → image/firefly-logo-notext.png} +0 -0
  158. /package/fireflysite/assets/{firefly-logo-yellow.png → image/firefly-logo-yellow.png} +0 -0
@@ -1,137 +1,141 @@
1
- import WebServer from ff:webserver
2
- import Lux from ff:lux
3
- import Guide
4
- import GuideAll
5
- import ExamplesOverview
6
- import PackagesOverview
7
- import CommunityOverview
8
- import FrontPage
9
- import Styles
10
-
11
- nodeMain(system: NodeSystem): Unit {
12
- let host = system.arguments().grab(0)
13
- let port = system.arguments().grab(1).grabInt()
14
- let cacheSalt = system.crypto().randomBuffer(16)
15
- system.writeLine("Listening on " + host + ":" + port)
16
- WebServer.new(system, host, port).listen {request =>
17
- let path = request.readPath()
18
- let segments = path.split('/').filter {s => s != "" && s != "." && s != ".."}
19
- segments.{
20
- | ["guide", ...] =>
21
- serveGuideHtml("Firefly Guide", request)
22
- | ["examples", ...] =>
23
- serveGuideHtml("Firefly Examples", request)
24
- | ["packages", ...] =>
25
- serveGuideHtml("Firefly Examples", request)
26
- | ["community", ...] =>
27
- serveGuideHtml("Firefly Examples", request)
28
- | ["front", ...] =>
29
- serveGuideHtml("Firefly Examples", request)
30
- | ["js", ...] =>
31
- let asset = if(path == "/js/ff/fireflysite/Main.mjs" && system.assets().exists("/js/Main.bundle.js")) {
32
- "/js/Main.bundle.js"
33
- } else {
34
- path
35
- }
36
- serveAsset(system, cacheSalt, request, "text/javascript; charset=UTF-8", asset)
37
- | ["favicon.ico"] =>
38
- serveAsset(system, cacheSalt, request, "image/png", "/assets/firefly-logo-notext.png")
39
- | ["assets", "FireflyMono.ttf"] =>
40
- serveAsset(system, cacheSalt, request, "image/png", "/assets/NotoSansMono-Regular.ttf")
41
- | ["assets", "FireflySans.ttf"] =>
42
- serveAsset(system, cacheSalt, request, "image/png", "/assets/NunitoSans-VariableFont_YTLC,opsz,wdth,wght.ttf")
43
- | ["assets", ...rest] => serveAssets(system, cacheSalt, request, rest)
44
- | _ =>
45
- let parameters = if(request.readRawQueryString().size() == 0) {""} else {
46
- "?" + request.readRawQueryString()
47
- }
48
- request.writeHeader("Location", "https://www.firefly-lang.org" + path + parameters)
49
- request.writeStatus("302 Found")
50
- }
51
- }
52
- }
53
-
54
- browserMain(system: BrowserSystem): Unit {
55
- let demos = ExamplesOverview.demos()
56
- let guides = [
57
- Guide("/front/", [FrontPage.new()])
58
- Guide("/guide/", GuideAll.mock())
59
- Guide("/examples/", ExamplesOverview.mock())
60
- Guide("/packages/", [PackagesOverview.new()])
61
- Guide("/community/", [CommunityOverview.new()])
62
- ]
63
- guides.collect {guide =>
64
- if(system.urlPath().startsWith(guide.prefix)):
65
- Lux.renderById(system, "main") {lux =>
66
- let kebab = system.urlPath().dropFirst(guide.prefix.size())
67
- Guide.render(lux, system, guide.prefix, kebab, guides, demos)
68
- }
69
- }
70
- }
71
-
72
- buildMain(system: BuildSystem) {
73
- let browser = system.compileForBrowser("Main.ff")
74
- let assets = AssetSystem.create()
75
- .addAssets("/js/", browser.assets())
76
- .addAssets("/assets/", system.packageAssets().assets("/assets/"))
77
- system.setAssets(assets)
78
- }
79
-
80
- serveAssets(system: NodeSystem, salt: Buffer, request: WebRequest[WebResponse], segments: List[String]): Unit {
81
- let asset = "/assets/" + segments.join("/")
82
- if(!system.assets().exists(asset)) {
83
- request.writeStatus("404 Not Found")
84
- } else:
85
-
86
- guessContentType(asset).or {
87
- request.writeStatus("404 Not Found")
88
- }: contentType =>
89
-
90
- serveAsset(system, salt, request, contentType, asset)
91
- }
92
-
93
- guessContentType(path: String): Option[String] {
94
- path.split('.').last().flatMap {
95
- | "md" => Some("text/markdown")
96
- | "png" => Some("image/png")
97
- | "ttf" => Some("font/ttf")
98
- | _ => None
99
- }
100
- }
101
-
102
- serveAsset(system: NodeSystem, salt: Buffer, request: WebRequest[WebResponse], contentType: String, asset: String): Unit {
103
- let etag = "\"" + system.crypto().hmacSha256(salt, asset.toBuffer()).toHex() + "\""
104
- request.writeHeader("Content-Type", contentType)
105
- if(request.readHeader("host") == Some("localhost:8080")) {
106
- request.writeHeader("Cache-Control", "public, max-age=0, must-revalidate")
107
- } else {
108
- request.writeHeader("Cache-Control", "public, max-age=60, must-revalidate")
109
- }
110
- request.writeHeader("ETag", etag)
111
- if(request.readHeader("if-none-match").any {_.trim() == etag}) {
112
- request.writeStatus("304 Not Modified")
113
- } else {
114
- request.writeStream(system.assets().readStream(asset))
115
- }
116
- }
117
-
118
- serveGuideHtml(title: String, request: WebRequest[WebResponse]): Unit {
119
- request.writeHeader("Content-Type", "text/html; charset=UTF-8")
120
- request.writeText("<!doctype html>")
121
- request.writeText("<html lang='en' style='background-color: #ffffff; color: #333333; width: 100%; height: 100%; color-scheme: light;'>")
122
- request.writeText("<head>")
123
- request.writeText("<title>" + title + "</title>")
124
- request.writeText("<meta name='viewport' content='width=device-width, initial-scale=1.0'>")
125
- request.writeText("<meta name='theme-color' content='#ecc45e'>")
126
- request.writeText("<link rel='preload' href='/assets/FireflyMono.ttf' as='font' crossorigin='anonymous'>")
127
- request.writeText("<link rel='preload' href='/assets/FireflySans.ttf' as='font' crossorigin='anonymous'>")
128
- request.writeText("<link rel='preload' href='/assets/firefly-logo-yellow.png' as='image'>")
129
- request.writeText("<style>@font-face { font-family: 'Firefly Mono'; font-display: fallback; src: url('/assets/FireflyMono.ttf'); unicode-range: U+000-5FF; }</style>")
130
- request.writeText("<style>@font-face { font-family: 'Firefly Sans'; font-display: fallback; src: url('/assets/FireflySans.ttf'); unicode-range: U+000-5FF; }</style>")
131
- request.writeText("</head>")
132
- request.writeText("<body style='margin: 0; padding: 0; width: 100%; height: 100%; touch-action: manipulation;'>")
133
- request.writeText("<div id='main'></div>")
134
- request.writeText("<script type='module' src='/js/ff/fireflysite/Main.mjs'></script>")
135
- request.writeText("</body>")
136
- request.writeText("</html>")
137
- }
1
+ import WebServer from ff:webserver
2
+ import Lux from ff:lux
3
+ import Guide
4
+ import GettingStarted
5
+ import ReferenceAll
6
+ import ExamplesOverview
7
+ import PackagesOverview
8
+ import CommunityOverview
9
+ import FrontPage
10
+ import Styles
11
+
12
+ nodeMain(system: NodeSystem): Unit {
13
+ let host = system.arguments().grab(0)
14
+ let port = system.arguments().grab(1).grabInt()
15
+ let cacheSalt = system.crypto().randomBuffer(16)
16
+ system.writeLine("Listening on " + host + ":" + port)
17
+ WebServer.new(system, host, port).listen {request =>
18
+ let path = request.readPath()
19
+ let segments = path.split('/').filter {s => s != "" && s != "." && s != ".."}
20
+ segments.{
21
+ | ["reference", ...] =>
22
+ serveGuideHtml("Firefly Reference", request)
23
+ | ["getting-started", ...] =>
24
+ serveGuideHtml("Firefly Getting Started", request)
25
+ | ["examples", ...] =>
26
+ serveGuideHtml("Firefly Examples", request)
27
+ | ["packages", ...] =>
28
+ serveGuideHtml("Firefly Packages", request)
29
+ | ["community", ...] =>
30
+ serveGuideHtml("Firefly Community", request)
31
+ | ["front", ...] =>
32
+ serveGuideHtml("Firefly", request)
33
+ | ["js", ...] =>
34
+ let asset = if(path == "/js/ff/fireflysite/Main.mjs" && system.assets().exists("/js/Main.bundle.js")) {
35
+ "/js/Main.bundle.js"
36
+ } else {
37
+ path
38
+ }
39
+ serveAsset(system, cacheSalt, request, "text/javascript; charset=UTF-8", asset)
40
+ | ["favicon.ico"] =>
41
+ serveAsset(system, cacheSalt, request, "image/png", "/assets/image/firefly-logo-notext.png")
42
+ | ["assets", "font", "FireflyMono.ttf"] =>
43
+ serveAsset(system, cacheSalt, request, "font/ttf", "/assets/font/NotoSansMono-Regular.ttf")
44
+ | ["assets", "font", "FireflySans.ttf"] =>
45
+ serveAsset(system, cacheSalt, request, "font/ttf", "/assets/font/NunitoSans-VariableFont_YTLC,opsz,wdth,wght.ttf")
46
+ | ["assets", ...rest] => serveAssets(system, cacheSalt, request, rest)
47
+ | _ =>
48
+ let parameters = if(request.readRawQueryString().size() == 0) {""} else {
49
+ "?" + request.readRawQueryString()
50
+ }
51
+ request.writeHeader("Location", "https://www.firefly-lang.org" + path + parameters)
52
+ request.writeStatus("302 Found")
53
+ }
54
+ }
55
+ }
56
+
57
+ browserMain(system: BrowserSystem): Unit {
58
+ let demos = ExamplesOverview.demos()
59
+ let guides = [
60
+ Guide("/front/", [FrontPage.new()])
61
+ Guide("/getting-started/", [GettingStarted.new()])
62
+ Guide("/examples/", ExamplesOverview.mock())
63
+ Guide("/reference/", ReferenceAll.mock())
64
+ Guide("/packages/", [PackagesOverview.new()])
65
+ Guide("/community/", [CommunityOverview.new()])
66
+ ]
67
+ guides.collect {guide =>
68
+ if(system.urlPath().startsWith(guide.prefix)):
69
+ Lux.renderById(system, "main") {lux =>
70
+ let kebab = system.urlPath().dropFirst(guide.prefix.size())
71
+ Guide.render(lux, system, guide.prefix, kebab, guides, demos)
72
+ }
73
+ }
74
+ }
75
+
76
+ buildMain(system: BuildSystem) {
77
+ let browser = system.compileForBrowser("Main.ff")
78
+ let assets = AssetSystem.create()
79
+ .addAssets("/js/", browser.assets())
80
+ .addAssets("/assets/", system.packageAssets().assets("/assets/"))
81
+ system.setAssets(assets)
82
+ }
83
+
84
+ serveAssets(system: NodeSystem, salt: Buffer, request: WebRequest[WebResponse], segments: List[String]): Unit {
85
+ let asset = "/assets/" + segments.join("/")
86
+ if(!system.assets().exists(asset)) {
87
+ request.writeStatus("404 Not Found")
88
+ } else:
89
+
90
+ guessContentType(asset).or {
91
+ request.writeStatus("404 Not Found")
92
+ }: contentType =>
93
+
94
+ serveAsset(system, salt, request, contentType, asset)
95
+ }
96
+
97
+ guessContentType(path: String): Option[String] {
98
+ path.split('.').last().flatMap {
99
+ | "md" => Some("text/markdown")
100
+ | "png" => Some("image/png")
101
+ | "ttf" => Some("font/ttf")
102
+ | _ => None
103
+ }
104
+ }
105
+
106
+ serveAsset(system: NodeSystem, salt: Buffer, request: WebRequest[WebResponse], contentType: String, asset: String): Unit {
107
+ let etag = "\"" + system.crypto().hmacSha256(salt, asset.toBuffer()).toHex() + "\""
108
+ request.writeHeader("Content-Type", contentType)
109
+ if(request.readHeader("host") == Some("localhost:8080")) {
110
+ request.writeHeader("Cache-Control", "no-cache")
111
+ } else {
112
+ request.writeHeader("Cache-Control", "public, max-age=60, must-revalidate")
113
+ request.writeHeader("ETag", etag)
114
+ }
115
+ if(request.readHeader("if-none-match").any {_.trim() == etag}) {
116
+ request.writeStatus("304 Not Modified")
117
+ } else {
118
+ request.writeStream(system.assets().readStream(asset))
119
+ }
120
+ }
121
+
122
+ serveGuideHtml(title: String, request: WebRequest[WebResponse]): Unit {
123
+ request.writeHeader("Content-Type", "text/html; charset=UTF-8")
124
+ request.writeText("<!doctype html>")
125
+ request.writeText("<html lang='en' style='background-color: #ffffff; color: #333333; width: 100%; height: 100%; color-scheme: light;'>")
126
+ request.writeText("<head>")
127
+ request.writeText("<title>" + title + "</title>")
128
+ request.writeText("<meta name='viewport' content='width=device-width, initial-scale=1.0'>")
129
+ request.writeText("<meta name='theme-color' content='#ecc45e'>")
130
+ request.writeText("<link rel='preload' href='/assets/font/FireflyMono.ttf' as='font' crossorigin='anonymous'>")
131
+ request.writeText("<link rel='preload' href='/assets/font/FireflySans.ttf' as='font' crossorigin='anonymous'>")
132
+ request.writeText("<link rel='preload' href='/assets/image/firefly-logo-yellow.png' as='image'>")
133
+ request.writeText("<style>@font-face { font-family: 'Firefly Mono'; font-display: fallback; src: url('/assets/font/FireflyMono.ttf'); unicode-range: U+000-5FF; }</style>")
134
+ request.writeText("<style>@font-face { font-family: 'Firefly Sans'; font-display: fallback; src: url('/assets/font/FireflySans.ttf'); unicode-range: U+000-5FF; }</style>")
135
+ request.writeText("</head>")
136
+ request.writeText("<body style='margin: 0; padding: 0; width: 100%; height: 100%; touch-action: manipulation;'>")
137
+ request.writeText("<div id='main'></div>")
138
+ request.writeText("<script type='module' src='/js/ff/fireflysite/Main.mjs'></script>")
139
+ request.writeText("</body>")
140
+ request.writeText("</html>")
141
+ }
@@ -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
+ }
@@ -0,0 +1,19 @@
1
+ import Guide
2
+ import ReferenceIntroduction
3
+
4
+ mock(): List[Document] {
5
+ [
6
+ ReferenceIntroduction.new()
7
+ UnfetchedDocument("Modules and packages")
8
+ UnfetchedDocument("Base types")
9
+ UnfetchedDocument("User defined types")
10
+ UnfetchedDocument("Statements and expressions")
11
+ UnfetchedDocument("Functions and methods")
12
+ UnfetchedDocument("Pattern matching")
13
+ UnfetchedDocument("Traits and instances")
14
+ UnfetchedDocument("Exceptions")
15
+ UnfetchedDocument("JavaScript interop")
16
+ UnfetchedDocument("Async I/O")
17
+ UnfetchedDocument("Structured concurrency")
18
+ ]
19
+ }