firefly-compiler 0.5.49 → 0.5.51
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/bin/Release.ff +3 -3
- package/bin/firefly.mjs +1 -1
- package/compiler/Builder.ff +11 -5
- package/compiler/Compiler.ff +14 -3
- package/compiler/JsEmitter.ff +6 -11
- package/compiler/Main.ff +10 -15
- package/compiler/ModuleCache.ff +2 -1
- package/core/Buffer.ff +26 -4
- package/core/BuildSystem.ff +49 -46
- package/core/JsValue.ff +5 -0
- package/experimental/date/Date.ff +604 -0
- package/experimental/date/Main.ff +51 -0
- package/experimental/random/AsciiBuffer.ff +15 -0
- package/experimental/rhymeapp/Main.ff +2 -3
- package/experimental/site/Main.ff +2 -2
- package/experimental/site2/Main.ff +2 -2
- package/firefly.sh +1 -1
- package/fireflysite/CommunityOverview.ff +3 -3
- package/fireflysite/CountingButtonDemo.ff +3 -3
- package/fireflysite/ExamplesOverview.ff +3 -12
- package/fireflysite/FrontPage.ff +3 -3
- package/fireflysite/GettingStarted.ff +3 -3
- package/fireflysite/Guide.ff +7 -187
- package/fireflysite/Html.ff +66 -0
- package/fireflysite/Main.ff +13 -77
- package/fireflysite/MatchingPasswordsDemo.ff +3 -3
- package/fireflysite/Menu.ff +59 -0
- package/fireflysite/PackagesOverview.ff +3 -3
- package/fireflysite/PostgresqlDemo.ff +3 -3
- package/fireflysite/RouteFront.ff +30 -0
- package/fireflysite/RouteNonMarkdown.ff +48 -0
- package/fireflysite/RouteReference.ff +40 -0
- package/fireflysite/Router.ff +33 -0
- package/fireflysite/Website.ff +133 -0
- package/fireflysite/assets/markdown/reference/{FunctionsAndMethods.md → functions-and-methods.md} +1 -1
- package/fireflysite/assets/markdown/reference/{StatementsAndExpressions.md → statements-and-expressions.md} +0 -1
- package/fireflysite/assets/markdown/reference/{StructuredConcurrency.md → structured-concurrency.md} +0 -1
- package/fireflysite/assets/markdown/reference.md +3 -0
- package/graph/.firefly/package.ff +1 -0
- package/graph/Graph.ff +79 -0
- package/lsp/CompletionHandler.ff +2 -2
- package/lux/CssTest.ff +2 -2
- package/lux/Main.ff +2 -2
- package/lux/Main2.ff +2 -2
- package/output/js/ff/compiler/Builder.mjs +44 -12
- package/output/js/ff/compiler/Compiler.mjs +28 -10
- package/output/js/ff/compiler/Dependencies.mjs +0 -2
- package/output/js/ff/compiler/DependencyLock.mjs +0 -2
- package/output/js/ff/compiler/Deriver.mjs +0 -2
- package/output/js/ff/compiler/Dictionaries.mjs +0 -2
- package/output/js/ff/compiler/Environment.mjs +0 -2
- package/output/js/ff/compiler/Inference.mjs +0 -2
- package/output/js/ff/compiler/JsEmitter.mjs +12 -30
- package/output/js/ff/compiler/JsImporter.mjs +0 -2
- package/output/js/ff/compiler/LspHook.mjs +0 -2
- package/output/js/ff/compiler/Main.mjs +24 -47
- package/output/js/ff/compiler/Main.run.mjs +25 -0
- package/output/js/ff/compiler/ModuleCache.mjs +4 -6
- package/output/js/ff/compiler/Parser.mjs +0 -2
- package/output/js/ff/compiler/Patterns.mjs +0 -2
- package/output/js/ff/compiler/Resolver.mjs +0 -2
- package/output/js/ff/compiler/Substitution.mjs +0 -2
- package/output/js/ff/compiler/Syntax.mjs +0 -2
- package/output/js/ff/compiler/Token.mjs +0 -2
- package/output/js/ff/compiler/Tokenizer.mjs +0 -2
- package/output/js/ff/compiler/Unification.mjs +0 -2
- package/output/js/ff/compiler/Wildcards.mjs +0 -2
- package/output/js/ff/compiler/Workspace.mjs +0 -2
- package/output/js/ff/core/Any.mjs +0 -2
- package/output/js/ff/core/Array.mjs +0 -2
- package/output/js/ff/core/AssetSystem.mjs +0 -2
- package/output/js/ff/core/Atomic.mjs +0 -2
- package/output/js/ff/core/Bool.mjs +0 -2
- package/output/js/ff/core/BrowserSystem.mjs +0 -2
- package/output/js/ff/core/Buffer.mjs +50 -10
- package/output/js/ff/core/BuildSystem.mjs +92 -72
- package/output/js/ff/core/Channel.mjs +0 -2
- package/output/js/ff/core/Char.mjs +0 -2
- package/output/js/ff/core/Core.mjs +0 -2
- package/output/js/ff/core/Crypto.mjs +0 -2
- package/output/js/ff/core/Date.mjs +0 -2
- package/output/js/ff/core/Duration.mjs +0 -2
- package/output/js/ff/core/Equal.mjs +0 -2
- package/output/js/ff/core/Error.mjs +0 -2
- package/output/js/ff/core/FileHandle.mjs +0 -2
- package/output/js/ff/core/Float.mjs +0 -2
- package/output/js/ff/core/HttpClient.mjs +0 -2
- package/output/js/ff/core/Int.mjs +0 -2
- package/output/js/ff/core/IntMap.mjs +0 -2
- package/output/js/ff/core/Js.mjs +0 -2
- package/output/js/ff/core/JsSystem.mjs +0 -2
- package/output/js/ff/core/JsValue.mjs +8 -2
- package/output/js/ff/core/Json.mjs +0 -2
- package/output/js/ff/core/List.mjs +0 -2
- package/output/js/ff/core/Lock.mjs +0 -2
- package/output/js/ff/core/Log.mjs +0 -2
- package/output/js/ff/core/Map.mjs +0 -2
- package/output/js/ff/core/NodeSystem.mjs +0 -2
- package/output/js/ff/core/Nothing.mjs +0 -2
- package/output/js/ff/core/Option.mjs +0 -2
- package/output/js/ff/core/Ordering.mjs +0 -2
- package/output/js/ff/core/Pair.mjs +0 -2
- package/output/js/ff/core/Path.mjs +0 -2
- package/output/js/ff/core/Queue.mjs +0 -2
- package/output/js/ff/core/Random.mjs +0 -2
- package/output/js/ff/core/RbMap.mjs +0 -2
- package/output/js/ff/core/Serializable.mjs +0 -2
- package/output/js/ff/core/Set.mjs +0 -2
- package/output/js/ff/core/Show.mjs +0 -2
- package/output/js/ff/core/SourceLocation.mjs +0 -2
- package/output/js/ff/core/Stream.mjs +0 -2
- package/output/js/ff/core/String.mjs +0 -2
- package/output/js/ff/core/StringMap.mjs +0 -2
- package/output/js/ff/core/Task.mjs +0 -2
- package/output/js/ff/core/Try.mjs +0 -2
- package/output/js/ff/core/Unit.mjs +0 -2
- package/package.json +1 -1
- package/vscode/client/src/extension.ts +1 -1
- package/vscode/package.json +1 -1
- package/vscode/snippets.json +2 -2
- package/webserver/WebRoute.ff +51 -14
- package/fireflysite/ReferenceAll.ff +0 -18
- /package/fireflysite/assets/markdown/reference/{BaseTypes.md → base-types.md} +0 -0
- /package/fireflysite/assets/markdown/reference/{EmittedJavascript.md → emitted-javascript.md} +0 -0
- /package/fireflysite/assets/markdown/reference/{Exceptions.md → exceptions.md} +0 -0
- /package/fireflysite/assets/markdown/reference/{JavascriptInterop.md → javascript-interop.md} +0 -0
- /package/fireflysite/assets/markdown/reference/{ModulesAndPackages.md → modules-and-packages.md} +0 -0
- /package/fireflysite/assets/markdown/reference/{PatternMatching.md → pattern-matching.md} +0 -0
- /package/fireflysite/assets/markdown/reference/{TraitsAndInstances.md → traits-and-instances.md} +0 -0
- /package/fireflysite/assets/markdown/reference/{UserDefinedTypes.md → user-defined-types.md} +0 -0
- /package/fireflysite/assets/markdown/scratch/{ControlFlow.md → control-flow.md} +0 -0
- /package/fireflysite/assets/markdown/{reference/OldStructuredConcurrency.md → scratch/old-structured-concurrency.md} +0 -0
package/webserver/WebRoute.ff
CHANGED
|
@@ -15,6 +15,19 @@ instance Int: WebParameter {
|
|
|
15
15
|
fromRouteParameter(value: Int): String {"" + value}
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
+
instance Option[T: WebParameter]: WebParameter {
|
|
19
|
+
toRouteParameter(text: String): Option[Option[T]] {
|
|
20
|
+
if(text != "") {
|
|
21
|
+
toRouteParameter(text).map {Some(_)}
|
|
22
|
+
} else {
|
|
23
|
+
Some(None)
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
fromRouteParameter(value: Option[T]): String {
|
|
27
|
+
value.map {fromRouteParameter(_)}.else {""}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
18
31
|
data WebRoute0(urlPattern: String, segments: List[String])
|
|
19
32
|
data WebRoute1[P1](urlPattern: String, segments: List[String])
|
|
20
33
|
data WebRoute2[P1, P2](urlPattern: String, segments: List[String])
|
|
@@ -42,12 +55,16 @@ extend self[P1: WebParameter]: WebRoute1[P1] {
|
|
|
42
55
|
mutable result = ""
|
|
43
56
|
mutable parameter = 1
|
|
44
57
|
self.segments.each {r =>
|
|
45
|
-
result += "/"
|
|
46
58
|
if(r.startsWith("{")) {
|
|
47
|
-
if(parameter == 1) {
|
|
59
|
+
let p = if(parameter == 1) {
|
|
60
|
+
fromRouteParameter(p1)
|
|
61
|
+
} else {
|
|
62
|
+
""
|
|
63
|
+
}
|
|
64
|
+
if(p != "" || !r.endsWith("?}")) {result += "/" + p}
|
|
48
65
|
parameter += 1
|
|
49
66
|
} else {
|
|
50
|
-
result += r
|
|
67
|
+
result += "/" + r
|
|
51
68
|
}
|
|
52
69
|
}
|
|
53
70
|
if(self.urlPattern.endsWith("/")) {result += "/"}
|
|
@@ -60,13 +77,18 @@ extend self[P1: WebParameter, P2: WebParameter]: WebRoute2[P1, P2] {
|
|
|
60
77
|
mutable result = ""
|
|
61
78
|
mutable parameter = 0
|
|
62
79
|
self.segments.each {r =>
|
|
63
|
-
result += "/"
|
|
64
80
|
if(r.startsWith("{")) {
|
|
65
|
-
if(parameter == 1) {
|
|
66
|
-
|
|
81
|
+
let p = if(parameter == 1) {
|
|
82
|
+
fromRouteParameter(p1)
|
|
83
|
+
} elseIf {parameter == 2} {
|
|
84
|
+
fromRouteParameter(p2)
|
|
85
|
+
} else {
|
|
86
|
+
""
|
|
87
|
+
}
|
|
88
|
+
if(p != "" || !r.endsWith("?}")) {result += "/" + p}
|
|
67
89
|
parameter += 1
|
|
68
90
|
} else {
|
|
69
|
-
result += r
|
|
91
|
+
result += "/" + r
|
|
70
92
|
}
|
|
71
93
|
}
|
|
72
94
|
if(self.urlPattern.endsWith("/")) {result += "/"}
|
|
@@ -88,11 +110,12 @@ extend self[C]: WebRouteHandler[C] {
|
|
|
88
110
|
|
|
89
111
|
add1[P1: WebParameter](route: WebRoute1[P1], handle: (WebRequest[WebResponse], C, P1) => Unit) {
|
|
90
112
|
self.handlers.push {request, segments, context =>
|
|
91
|
-
|
|
92
|
-
|
|
113
|
+
let paddedSegments = internalCheckSegments(segments, route.segments)
|
|
114
|
+
if(paddedSegments.isEmpty()) {False} else:
|
|
115
|
+
mutable matching = True
|
|
93
116
|
mutable p1 = None
|
|
94
|
-
|
|
95
|
-
if(r.startsWith("{")) {
|
|
117
|
+
paddedSegments.zip(route.segments).eachWhile {| Pair(s, r) =>
|
|
118
|
+
matching = if(r.startsWith("{")) {
|
|
96
119
|
if(p1.isEmpty()) {
|
|
97
120
|
p1 = toRouteParameter(s)
|
|
98
121
|
!p1.isEmpty()
|
|
@@ -102,6 +125,7 @@ extend self[C]: WebRouteHandler[C] {
|
|
|
102
125
|
} else {
|
|
103
126
|
r == s
|
|
104
127
|
}
|
|
128
|
+
matching
|
|
105
129
|
}
|
|
106
130
|
if(!matching) {False} else:
|
|
107
131
|
handle(request, context, p1.grab())
|
|
@@ -111,11 +135,12 @@ extend self[C]: WebRouteHandler[C] {
|
|
|
111
135
|
|
|
112
136
|
add2[P1: WebParameter, P2: WebParameter](route: WebRoute2[P1, P2], handle: (WebRequest[WebResponse], C, P1, P2) => Unit) {
|
|
113
137
|
self.handlers.push {request, segments, context =>
|
|
114
|
-
|
|
138
|
+
let paddedSegments = internalCheckSegments(segments, route.segments)
|
|
139
|
+
if(paddedSegments.isEmpty()) {False} else:
|
|
115
140
|
mutable p1 = None
|
|
116
141
|
mutable p2 = None
|
|
117
142
|
mutable matching = True
|
|
118
|
-
|
|
143
|
+
paddedSegments.zip(route.segments).eachWhile {| Pair(s, r) =>
|
|
119
144
|
matching = if(r.startsWith("{")) {
|
|
120
145
|
if(p1.isEmpty()) {
|
|
121
146
|
p1 = toRouteParameter(s)
|
|
@@ -139,12 +164,24 @@ extend self[C]: WebRouteHandler[C] {
|
|
|
139
164
|
|
|
140
165
|
handle(request: WebRequest[WebResponse], context: C): Bool {
|
|
141
166
|
let segments = request.readPath().split('/').filter {s => s != ""}
|
|
167
|
+
let trimmedSegments = if(segments.last().contains("")) {segments.dropLast()} else {segments}
|
|
142
168
|
mutable handled = False
|
|
143
169
|
self.handlers.eachWhile {| handler =>
|
|
144
|
-
handled = handler(request,
|
|
170
|
+
handled = handler(request, trimmedSegments, context)
|
|
145
171
|
!handled
|
|
146
172
|
}
|
|
147
173
|
handled
|
|
148
174
|
}
|
|
149
175
|
|
|
150
176
|
}
|
|
177
|
+
|
|
178
|
+
internalCheckSegments(segments: List[String], patterns: List[String]): List[String] {
|
|
179
|
+
segments.{
|
|
180
|
+
| _ {segments.size() == patterns.size()} =>
|
|
181
|
+
segments
|
|
182
|
+
| _ {segments.size() == patterns.size() - 1} {patterns.indexWhere {_.endsWith("?}")} | Some(i)} =>
|
|
183
|
+
[...segments.takeFirst(i), "", ...segments.dropFirst(i)]
|
|
184
|
+
| _ =>
|
|
185
|
+
[]
|
|
186
|
+
}
|
|
187
|
+
}
|
|
@@ -1,18 +0,0 @@
|
|
|
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("Structured concurrency")
|
|
16
|
-
UnfetchedDocument("JavaScript interop")
|
|
17
|
-
]
|
|
18
|
-
}
|
|
File without changes
|
/package/fireflysite/assets/markdown/reference/{EmittedJavascript.md → emitted-javascript.md}
RENAMED
|
File without changes
|
|
File without changes
|
/package/fireflysite/assets/markdown/reference/{JavascriptInterop.md → javascript-interop.md}
RENAMED
|
File without changes
|
/package/fireflysite/assets/markdown/reference/{ModulesAndPackages.md → modules-and-packages.md}
RENAMED
|
File without changes
|
|
File without changes
|
/package/fireflysite/assets/markdown/reference/{TraitsAndInstances.md → traits-and-instances.md}
RENAMED
|
File without changes
|
/package/fireflysite/assets/markdown/reference/{UserDefinedTypes.md → user-defined-types.md}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|