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.
Files changed (164) 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 +149 -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 +442 -411
  67. package/fireflysite/Main.ff +151 -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 +18 -0
  72. package/fireflysite/ReferenceIntroduction.ff +11 -0
  73. package/fireflysite/Styles.ff +567 -495
  74. package/fireflysite/Test.ff +46 -0
  75. package/fireflysite/assets/markdown/reference/BaseTypes.md +209 -0
  76. package/fireflysite/assets/markdown/reference/EmittedJavascript.md +66 -0
  77. package/fireflysite/assets/markdown/reference/Exceptions.md +101 -0
  78. package/fireflysite/assets/markdown/reference/FunctionsAndMethods.md +338 -0
  79. package/fireflysite/assets/markdown/reference/JavascriptInterop.md +134 -0
  80. package/fireflysite/assets/markdown/reference/ModulesAndPackages.md +162 -0
  81. package/fireflysite/assets/markdown/reference/OldStructuredConcurrency.md +48 -0
  82. package/fireflysite/assets/markdown/reference/PatternMatching.md +224 -0
  83. package/fireflysite/assets/markdown/reference/StatementsAndExpressions.md +86 -0
  84. package/fireflysite/assets/markdown/reference/StructuredConcurrency.md +99 -0
  85. package/fireflysite/assets/markdown/reference/TraitsAndInstances.md +100 -0
  86. package/fireflysite/assets/markdown/reference/UserDefinedTypes.md +184 -0
  87. package/fireflysite/assets/markdown/{ControlFlow.md → scratch/ControlFlow.md} +136 -136
  88. package/fireflysite/assets/markdown/scratch/Toc.md +41 -0
  89. package/lsp/.firefly/package.ff +1 -1
  90. package/lsp/CompletionHandler.ff +828 -828
  91. package/lsp/Handler.ff +714 -714
  92. package/lsp/HoverHandler.ff +79 -79
  93. package/lsp/LanguageServer.ff +272 -272
  94. package/lsp/SignatureHelpHandler.ff +55 -55
  95. package/lsp/SymbolHandler.ff +181 -181
  96. package/lsp/TestReferences.ff +17 -17
  97. package/lsp/TestReferencesCase.ff +7 -7
  98. package/lsp/stderr.txt +1 -1
  99. package/lsp/stdout.txt +34 -34
  100. package/lux/.firefly/package.ff +1 -1
  101. package/lux/Css.ff +648 -648
  102. package/lux/CssTest.ff +48 -48
  103. package/lux/Lux.ff +593 -487
  104. package/lux/LuxEvent.ff +116 -116
  105. package/lux/Main.ff +123 -123
  106. package/lux/Main2.ff +143 -143
  107. package/lux/TestDry.ff +27 -0
  108. package/output/js/ff/compiler/Builder.mjs +47 -47
  109. package/output/js/ff/compiler/Dependencies.mjs +3 -3
  110. package/output/js/ff/compiler/Inference.mjs +2 -2
  111. package/output/js/ff/compiler/JsEmitter.mjs +18 -72
  112. package/output/js/ff/compiler/Main.mjs +4 -4
  113. package/output/js/ff/compiler/ModuleCache.mjs +4 -4
  114. package/output/js/ff/core/Array.mjs +59 -59
  115. package/output/js/ff/core/Atomic.mjs +36 -36
  116. package/output/js/ff/core/BrowserSystem.mjs +11 -11
  117. package/output/js/ff/core/BuildSystem.mjs +30 -30
  118. package/output/js/ff/core/Crypto.mjs +40 -40
  119. package/output/js/ff/core/Float.mjs +50 -0
  120. package/output/js/ff/core/HttpClient.mjs +56 -56
  121. package/output/js/ff/core/Json.mjs +147 -147
  122. package/output/js/ff/core/List.mjs +50 -50
  123. package/output/js/ff/core/Lock.mjs +97 -97
  124. package/output/js/ff/core/NodeSystem.mjs +87 -87
  125. package/output/js/ff/core/Ordering.mjs +8 -8
  126. package/output/js/ff/core/Path.mjs +231 -231
  127. package/output/js/ff/core/Random.mjs +56 -56
  128. package/output/js/ff/core/Task.mjs +71 -39
  129. package/output/js/ff/core/Try.mjs +98 -4
  130. package/package.json +1 -1
  131. package/postgresql/Pg.ff +1 -1
  132. package/rpc/.firefly/package.ff +1 -1
  133. package/rpc/Rpc.ff +70 -70
  134. package/s3/.firefly/package.ff +1 -1
  135. package/s3/S3.ff +94 -94
  136. package/unsafejs/UnsafeJs.ff +19 -19
  137. package/vscode/LICENSE.txt +21 -21
  138. package/vscode/Prepublish.ff +15 -15
  139. package/vscode/README.md +16 -16
  140. package/vscode/client/package.json +22 -22
  141. package/vscode/client/src/extension.ts +104 -104
  142. package/vscode/icons/firefly-icon.svg +10 -10
  143. package/vscode/language-configuration.json +61 -61
  144. package/vscode/package-lock.json +3623 -3623
  145. package/vscode/package.json +1 -1
  146. package/vscode/snippets.json +241 -241
  147. package/vscode/syntaxes/firefly-markdown-injection.json +45 -45
  148. package/webserver/.firefly/include/package-lock.json +22 -22
  149. package/webserver/.firefly/include/package.json +5 -5
  150. package/webserver/.firefly/package.ff +2 -2
  151. package/webserver/WebServer.ff +685 -685
  152. package/websocket/.firefly/package.ff +1 -1
  153. package/websocket/WebSocket.ff +131 -131
  154. package/fireflysite/GuideAll.ff +0 -21
  155. package/fireflysite/GuideBaseTypes.ff +0 -168
  156. package/fireflysite/GuideControlFlow.ff +0 -212
  157. package/fireflysite/assets/markdown/Example.md +0 -78
  158. /package/fireflysite/assets/{NotoSansMono-Regular.ttf → font/NotoSansMono-Regular.ttf} +0 -0
  159. /package/fireflysite/assets/{NunitoSans-VariableFont_YTLC,opsz,wdth,wght.ttf → font/NunitoSans-VariableFont_YTLC,opsz,wdth,wght.ttf} +0 -0
  160. /package/fireflysite/assets/{autocomplete-small.png → image/autocomplete-small.png} +0 -0
  161. /package/fireflysite/assets/{autocomplete.png → image/autocomplete.png} +0 -0
  162. /package/fireflysite/assets/{edit-time-error.png → image/edit-time-error.png} +0 -0
  163. /package/fireflysite/assets/{firefly-logo-notext.png → image/firefly-logo-notext.png} +0 -0
  164. /package/fireflysite/assets/{firefly-logo-yellow.png → image/firefly-logo-yellow.png} +0 -0
@@ -1,137 +1,151 @@
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 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
+ }