-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch to structs, change icon signature (#2)
This pull request includes several changes to the codebase. The main changes are: Switching to using structs instead of classes for improved performance and memory efficiency. Updating the icon signature to match the new struct implementation. Switch to a valid protocol This pull request updates the protocol used in the codebase from "mandadin-web" to "web+mandadin". This change ensures that the protocol follows the correct format and is compatible with other systems. Add FsToolkit, add The Blunt Parser This pull request adds the FsToolkit.ErrorHandling and TheBlunt packages to the project. These packages provide additional functionality and error handling capabilities. Add Parser module for checkbox parsing This pull request introduces a new Parser module for parsing checkboxes in the codebase. This module allows for more efficient and accurate parsing of checkbox data. Add logging
- Loading branch information
1 parent
8d9bb22
commit feec017
Showing
11 changed files
with
221 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
namespace Mandadin.Client | ||
|
||
open TheBlunt | ||
open FsToolkit.ErrorHandling | ||
|
||
module Parse = | ||
let openCheckBox = | ||
pchar (fun c -> c = '[') (fun c -> | ||
$"'{c}' is not a valid character at this position") | ||
|
||
let closeCheckBox = | ||
pchar (fun c -> c = ']') (fun c -> | ||
$"'{c}' is not a valid character at this position") | ||
|
||
let completedCheckBox = | ||
pchar (fun c -> c = 'x') (fun c -> | ||
$"'{c}' is not a valid character at this position") | ||
|
||
let checkBox = | ||
parse { | ||
let! ``open`` = openCheckBox | ||
let! em1 = ptry blanks | ||
|
||
let! isChecked = | ||
ptry completedCheckBox | ||
|> map (fun check -> | ||
match check with | ||
| Some _ -> true | ||
| None -> false) | ||
|
||
let! em2 = ptry blanks | ||
let! ``close`` = closeCheckBox | ||
|
||
return | ||
{ range = | ||
Range.merge | ||
[ ``open``.range | ||
em1.range | ||
isChecked.range | ||
em2.range | ||
``close``.range ] | ||
result = isChecked.result } | ||
} | ||
|
||
let eol = | ||
pchoice [ pstr "\r\n"; pstr "\n"; pstr "\r" ] | ||
|
||
let content = | ||
parse { | ||
let! init = blanks | ||
let! content = many anyChar |> pconcat | ||
let! endl = eoi | ||
|
||
return | ||
{ range = | ||
Range.merge | ||
[ init.range | ||
content.range | ||
endl.range ] | ||
result = content.result } | ||
} | ||
|
||
let mandadinEntry = | ||
content |> andThen checkBox | ||
|
||
let inline parseLine line = | ||
match run line mandadinEntry with | ||
| POk { result = isChecked, content } -> | ||
Ok([| box isChecked; box content |]) | ||
| PError e -> Error(line, e) | ||
|
||
let entries lines = | ||
lines | ||
|> List.ofArray | ||
|> List.traverseResultA parseLine | ||
|> Result.map List.toArray |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace Mandadin.Client | ||
|
||
open TheBlunt | ||
|
||
[<RequireQualifiedAccess>] | ||
module Parse = | ||
val entries: lines: string array -> Result<obj array array, (string * ParseError) list> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,36 @@ | ||
namespace Mandadin.Client | ||
|
||
open Microsoft.Extensions.Logging | ||
open Microsoft.AspNetCore.Components.WebAssembly.Hosting | ||
|
||
module Program = | ||
|
||
[<EntryPoint>] | ||
let Main args = | ||
let builder = | ||
WebAssemblyHostBuilder.CreateDefault(args) | ||
task { | ||
let builder = | ||
WebAssemblyHostBuilder.CreateDefault(args) | ||
|
||
builder.RootComponents.Add<Main.Mandadin>("#main") | ||
builder.RootComponents.Add<Main.Mandadin>("#main") | ||
|
||
builder.Build().RunAsync() | ||
|> Async.AwaitTask | ||
|> Async.Start | ||
let level = | ||
if builder.HostEnvironment.Environment = "Production" then | ||
LogLevel.Information | ||
else | ||
LogLevel.Debug | ||
|
||
builder.Logging.AddFilter( | ||
"Microsoft.AspNetCore.Components.RenderTree.*", | ||
LogLevel.Warning | ||
) | ||
|> ignore | ||
|
||
builder.Logging.SetMinimumLevel(level) |> ignore | ||
|
||
let app = builder.Build() | ||
|
||
do! app.RunAsync() | ||
} | ||
|> ignore | ||
|
||
0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.