Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fc1943s committed Nov 24, 2023
1 parent 1c0a07e commit 6bdcf6d
Show file tree
Hide file tree
Showing 37 changed files with 1,803 additions and 1,463 deletions.
1,387 changes: 713 additions & 674 deletions apps/dice/ui/dice_ui.fsx

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions apps/dice/ui/dice_ui.spi
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ inl main (args : array string) =

inl body : optionm'.option' rust.html_element = !\($'"leptos::document().body()"')
inl body = body |> optionm'.unbox
inl body_log = body |> format_debug
inl body_log = body |> sm'.format_debug

leptos.log $'"main / mount_to_body / body: " + string !body_log + ""'

Expand All @@ -33,8 +33,8 @@ inl main (args : array string) =
0i32

inl main () =
src.state.types ()
rust.types ()
leptos.types ()
src.model.near.backend.types ()
src.components.history.types ()

$"let main args = !main args" : ()
1,077 changes: 553 additions & 524 deletions apps/dice/ui/dice_ui_wasm.rs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/dice/ui/e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"outdated-pre": "npm-check-updates --target greatest"
},
"devDependencies": {
"@playwright/test": "1.38.0-beta-1691778350000",
"@playwright/test": "1.40.0",
"npm-check-updates": "~16.14"
}
}
31 changes: 17 additions & 14 deletions apps/dice/ui/e2e/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion apps/dice/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"build-css": "tailwindcss -i input.css -o target/tailwind.css"
},
"devDependencies": {
"@types/node": "~20.8",
"@types/node": "~20.9",
"npm-check-updates": "~16.14",
"tailwindcss": "~3.3",
"nightwind": "~1.1",
Expand Down
8 changes: 4 additions & 4 deletions apps/dice/ui/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion apps/dice/ui/src/components/app.spi
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ inl render () =
leptos.create_rw_signal <|
heap {
explorer_backend_host =
!\($'"include_str\!(\\\"explorer_backend_host.txt\\\")"')
"../../near/explorer_backend_host.txt"
|> sm'.include_str
|> sm'.ref_to_std_string
|> leptos.create_rw_signal
}
Expand Down
4 changes: 2 additions & 2 deletions apps/dice/ui/src/components/content.spi
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ inl render () : _ leptos.div =

inl hash_url = hash_url |> resultm.unbox |> resultm.get

inl hash_url_log = hash_url |> sm'.format_pretty
inl hash_url_log = hash_url |> sm'.format_pretty'
leptos.log $'"content.render () / effect 2 / hash_url: " + string !hash_url_log + ""'

inl tab =
if hash_url |> leptos.url_pathname |> sm'.starts_with ("/settings" |> sm'.to_std_string)
then menu_tabs.Settings
else menu_tabs.History

inl tab_log = tab |> sm'.format_pretty
inl tab_log = tab |> sm'.format_pretty'
leptos.log $'"content.render () / effect 2 / new_tab: " + string !tab_log + ""'

set_tab |> leptos.signal_update fun _ => tab
Expand Down
59 changes: 20 additions & 39 deletions apps/dice/ui/src/components/history.spi
Original file line number Diff line number Diff line change
@@ -1,40 +1,21 @@
open rust_operators
open model.near.backend

inl types () =
global "[<Fable.Core.Erase; Fable.Core.Emit(\"reqwest_wasm::Response\")>] type reqwest_Response = class end"
global "[<Fable.Core.Erase; Fable.Core.Emit(\"reqwest_wasm::Error\")>] type reqwest_Error = class end"

nominal reqwest_response = $"reqwest_Response"
nominal reqwest_error = $"reqwest_Error"

inl new_request_get (url : string) : rust.pin (rust.box (rust.dyn' (rust.future (resultm.result' reqwest_response reqwest_error)))) =
inl url = join url
inl url = url |> sm'.to_std_string
inl url = join url
!\($'"Box::pin(reqwest_wasm::Client::builder().build().map_err(|err| err.to_string())?.get(!url).send())"')

inl response_text (response : reqwest_response) : rust.pin (rust.box (rust.dyn' (rust.future (resultm.result' rust.std_string reqwest_error)))) =
!\($'"Box::pin(reqwest_wasm::Response::text(!response))"')

inl date_time_from_timestamp forall t {int}. (timestamp : t) : option rust.naive_date_time =
inl timestamp = join timestamp
inl result : optionm'.option' rust.naive_date_time =
!\($'"chrono::NaiveDateTime::from_timestamp_millis(!timestamp.try_into().unwrap())"')
result |> optionm'.unbox

inl transaction_render (transaction : transaction) : _ leptos.pre =
inl transaction_render (transaction : transaction) : _ leptos.div =
inl block_timestamp = transaction.block_timestamp

inl block_date =
inl block_date_time =
block_timestamp
|> date_time_from_timestamp
|> date_time.from_timestamp'
|> optionm.map (date_time.format' "%Y-%m-%d %H:%M:%S" >> sm'.from_std_string)

block_date
|> sm'.format_pretty
|> sm'.from_std_string
|> leptos.text_fragment
|> leptos.text_block_pre
leptos.grid_pair
{ class = "" }
("Block Timestamp" |> leptos.text_fragment)
(block_date_time
|> resultm.from_option
|> to_string
|> leptos.text_fragment)

inl render () =
leptos.log $'"history.render ()"'
Expand Down Expand Up @@ -68,7 +49,7 @@ inl render () =
inl input_json : resultm.result' rust.std_string rust.json_error = !\($'"serde_json::to_string(&!input_obj)"')
inl input_json = input_json |> resultm.unwrap'
inl input : rust.js_string = !\($'"js_sys::encode_uri_component(&!input_json)"')
input |> sm'.format
input |> sm'.format'

inl url = leptos.create_memo fun () =>
leptos.log $'"history.render () / url create_memo"'
Expand All @@ -90,13 +71,13 @@ inl render () =
fun () =>
leptos.log $'"history.render () / json create_local_resource"'
url
|> new_request_get
|> networking.new_request_get
|> async.await
|> resultm.map_error' sm'.format
|> resultm.map_error' sm'.format'
|> resultm.try'
|> response_text
|> networking.response_text
|> async.await
|> resultm.map_error' sm'.format
|> resultm.map_error' sm'.format'
|> resultm.try'
|> sm'.from_std_string
|> Ok
Expand All @@ -115,7 +96,7 @@ inl render () =
|> resultm.map fun json =>
json
|> sm'.deserialize
|> resultm.map_error' sm'.format
|> resultm.map_error' sm'.format'
|> resultm.try'
|> am'.from_vec
|> resultm.box
Expand Down Expand Up @@ -187,7 +168,7 @@ inl render () =
(transaction_list |> leptos.move_to_fragment fun transaction_list =>
transaction_list
|> rust.func0_get
|> sm'.format_pretty
|> sm'.format_pretty'
|> sm'.from_std_string
|> leptos.text_fragment
|> leptos.text_block_pre
Expand All @@ -200,7 +181,7 @@ inl render () =
(result_wrapper |> leptos.move_to_fragment fun result_wrapper =>
result_wrapper
|> rust.func0_get
|> sm'.format_pretty
|> sm'.format_pretty'
|> sm'.from_std_string
|> leptos.text_fragment
|> leptos.text_block_pre
Expand All @@ -213,7 +194,7 @@ inl render () =
(json |> leptos.move_to_fragment fun json =>
json
|> leptos.resource_get
|> sm'.format_pretty
|> sm'.format_pretty'
|> sm'.from_std_string
|> leptos.text_fragment
|> leptos.text_block_pre
Expand Down
Loading

0 comments on commit 6bdcf6d

Please sign in to comment.