-module(spectator@internal@views@display). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]). -export([pid/1, port/1, inspect/1, atom/1, pid_button/4, pid_link/3, port_link/2, reference/1, storage/1, storage_words/1, storage_detailed/1, bool/1, named_remote_process/2, system_primitive_interactive/2, system_primitive/1, function/1, number/1]). -file("/Users/jonas/Projects/spectator/src/spectator/internal/views/display.gleam", 15). -spec pid(gleam@erlang@process:pid_()) -> lustre@internals@vdom:element(any()). pid(Pid) -> lustre@element@html:text(spectator_ffi:format_pid(Pid)). -file("/Users/jonas/Projects/spectator/src/spectator/internal/views/display.gleam", 120). -spec port(gleam@erlang@port:port_()) -> lustre@internals@vdom:element(any()). port(Port) -> lustre@element@html:text(spectator_ffi:format_port(Port)). -file("/Users/jonas/Projects/spectator/src/spectator/internal/views/display.gleam", 138). -spec inspect(gleam@dynamic:dynamic_()) -> lustre@internals@vdom:element(any()). inspect(D) -> lustre@element@html:text(gleam@string:inspect(D)). -file("/Users/jonas/Projects/spectator/src/spectator/internal/views/display.gleam", 142). -spec atom(gleam@erlang@atom:atom_()) -> lustre@internals@vdom:element(any()). atom(A) -> lustre@element@html:text(erlang:atom_to_binary(A)). -file("/Users/jonas/Projects/spectator/src/spectator/internal/views/display.gleam", 19). -spec pid_button( gleam@erlang@process:pid_(), gleam@option:option(gleam@erlang@atom:atom_()), gleam@option:option(binary()), fun((gleam@erlang@process:pid_()) -> APTU) ) -> lustre@internals@vdom:element(APTU). pid_button(Pid, Name, Tag, On_click) -> case {Name, Tag} of {none, none} -> lustre@element@html:button( [lustre@event:on_click(On_click(Pid)), lustre@attribute:class(<<"interactive-primitive"/utf8>>)], [lustre@element@html:text(spectator_ffi:format_pid(Pid))] ); {{some, Name@1}, none} -> lustre@element@html:button( [lustre@event:on_click(On_click(Pid)), lustre@attribute:class( <<"interactive-primitive named"/utf8>> ), lustre@attribute:title( <<"PID"/utf8, (spectator_ffi:format_pid(Pid))/binary>> )], [lustre@element@html:text(erlang:atom_to_binary(Name@1))] ); {none, {some, <<"__spectator_internal"/utf8, Internal_tag/binary>>}} -> lustre@element@html:button( [lustre@event:on_click(On_click(Pid)), lustre@attribute:class( <<"interactive-primitive muted"/utf8>> ), lustre@attribute:title( <<"This process is used for the Spectator application"/utf8>> )], [lustre@element@html:text( <<<<"🔍"/utf8, Internal_tag/binary>>/binary, (spectator_ffi:format_pid(Pid))/binary>> )] ); {none, {some, Tag@1}} -> lustre@element@html:button( [lustre@event:on_click(On_click(Pid)), lustre@attribute:class( <<"interactive-primitive tagged"/utf8>> )], [lustre@element@html:text( <<<<"🔖 "/utf8, Tag@1/binary>>/binary, (spectator_ffi:format_pid(Pid))/binary>> )] ); {{some, Name@2}, {some, Tag@2}} -> lustre@element@html:button( [lustre@event:on_click(On_click(Pid)), lustre@attribute:class( <<"interactive-primitive named tagged"/utf8>> ), lustre@attribute:title( <<"PID"/utf8, (spectator_ffi:format_pid(Pid))/binary>> )], [lustre@element@html:text( <<<<<<<<"🔖 "/utf8, Tag@2/binary>>/binary, "<"/utf8>>/binary, (erlang:atom_to_binary(Name@2))/binary>>/binary, ">"/utf8>> )] ) end. -file("/Users/jonas/Projects/spectator/src/spectator/internal/views/display.gleam", 72). -spec pid_link( gleam@erlang@process:pid_(), gleam@option:option(gleam@erlang@atom:atom_()), gleam@option:option(binary()) ) -> lustre@internals@vdom:element(any()). pid_link(Pid, Name, Tag) -> case {Name, Tag} of {none, none} -> lustre@element@html:a( [lustre@attribute:href( <<"/processes?selected="/utf8, (spectator@internal@api:serialize_pid(Pid))/binary>> ), lustre@attribute:class(<<"interactive-primitive"/utf8>>)], [lustre@element@html:text(spectator_ffi:format_pid(Pid))] ); {{some, Name@1}, none} -> lustre@element@html:a( [lustre@attribute:href( <<"/processes?selected="/utf8, (spectator@internal@api:serialize_pid(Pid))/binary>> ), lustre@attribute:class( <<"interactive-primitive named"/utf8>> ), lustre@attribute:title( <<"PID"/utf8, (spectator_ffi:format_pid(Pid))/binary>> )], [lustre@element@html:text(erlang:atom_to_binary(Name@1))] ); {none, {some, <<"__spectator_internal"/utf8, Internal_tag/binary>>}} -> lustre@element@html:a( [lustre@attribute:href( <<"/processes?selected="/utf8, (spectator@internal@api:serialize_pid(Pid))/binary>> ), lustre@attribute:class( <<"interactive-primitive muted"/utf8>> ), lustre@attribute:title( <<"This process is used for the Spectator application"/utf8>> )], [lustre@element@html:text( <<<<"🔍"/utf8, Internal_tag/binary>>/binary, (spectator_ffi:format_pid(Pid))/binary>> )] ); {none, {some, Tag@1}} -> lustre@element@html:a( [lustre@attribute:href( <<"/processes?selected="/utf8, (spectator@internal@api:serialize_pid(Pid))/binary>> ), lustre@attribute:class( <<"interactive-primitive tagged"/utf8>> )], [lustre@element@html:text( <<<<"🔖 "/utf8, Tag@1/binary>>/binary, (spectator_ffi:format_pid(Pid))/binary>> )] ); {{some, Name@2}, {some, Tag@2}} -> lustre@element@html:a( [lustre@attribute:href( <<"/processes?selected="/utf8, (spectator@internal@api:serialize_pid(Pid))/binary>> ), lustre@attribute:class( <<"interactive-primitive named tagged"/utf8>> ), lustre@attribute:title( <<"PID"/utf8, (spectator_ffi:format_pid(Pid))/binary>> )], [lustre@element@html:text( <<<<<<<<"🔖 "/utf8, Tag@2/binary>>/binary, "<"/utf8>>/binary, (erlang:atom_to_binary(Name@2))/binary>>/binary, ">"/utf8>> )] ) end. -file("/Users/jonas/Projects/spectator/src/spectator/internal/views/display.gleam", 124). -spec port_link( gleam@erlang@port:port_(), gleam@option:option(gleam@erlang@atom:atom_()) ) -> lustre@internals@vdom:element(any()). port_link(Port, Name) -> Label = case Name of none -> spectator_ffi:format_port(Port); {some, N} -> <<<<<<(spectator_ffi:format_port(Port))/binary, " ("/utf8>>/binary, (erlang:atom_to_binary(N))/binary>>/binary, ")"/utf8>> end, lustre@element@html:a( [lustre@attribute:class(<<"interactive-primitive"/utf8>>), lustre@attribute:href( <<"/ports?selected="/utf8, (spectator@internal@api:serialize_port(Port))/binary>> )], [lustre@element@html:text(Label)] ). -file("/Users/jonas/Projects/spectator/src/spectator/internal/views/display.gleam", 146). -spec reference(gleam@erlang:reference_()) -> lustre@internals@vdom:element(any()). reference(Ref) -> lustre@element@html:text(gleam@string:inspect(Ref)). -file("/Users/jonas/Projects/spectator/src/spectator/internal/views/display.gleam", 155). -spec storage(integer()) -> lustre@internals@vdom:element(any()). storage(Size) -> case Size of _ when Size < 1024 -> lustre@element@html:text( <<(gleam@int:to_string(Size))/binary, " B"/utf8>> ); _ when Size < 1048576 -> lustre@element@html:text( <<(gleam@int:to_string(Size div 1024))/binary, " KiB"/utf8>> ); _ -> lustre@element@html:text( <<(gleam@int:to_string((Size div 1024) div 1024))/binary, " MiB"/utf8>> ) end. -file("/Users/jonas/Projects/spectator/src/spectator/internal/views/display.gleam", 151). -spec storage_words(integer()) -> lustre@internals@vdom:element(any()). storage_words(Words) -> storage(Words * spectator_ffi:get_word_size()). -file("/Users/jonas/Projects/spectator/src/spectator/internal/views/display.gleam", 163). -spec storage_detailed(integer()) -> lustre@internals@vdom:element(any()). storage_detailed(Size) -> Byte_size = <<(gleam@int:to_string(Size))/binary, " Bytes"/utf8>>, case Size of _ when Size < 1024 -> lustre@element@html:text(Byte_size); _ when Size < 1048576 -> lustre@element@html:text( <<<<<>/binary, (gleam@int:to_string(Size div 1024))/binary>>/binary, " KiB)"/utf8>> ); _ -> lustre@element@html:text( <<<<<>/binary, (gleam@int:to_string((Size div 1024) div 1024))/binary>>/binary, " MiB)"/utf8>> ) end. -file("/Users/jonas/Projects/spectator/src/spectator/internal/views/display.gleam", 176). -spec bool(boolean()) -> lustre@internals@vdom:element(any()). bool(B) -> case B of true -> lustre@element@html:text(<<"true"/utf8>>); false -> lustre@element@html:text(<<"false"/utf8>>) end. -file("/Users/jonas/Projects/spectator/src/spectator/internal/views/display.gleam", 183). -spec named_remote_process(gleam@erlang@atom:atom_(), gleam@erlang@atom:atom_()) -> lustre@internals@vdom:element(any()). named_remote_process(Name, Node) -> lustre@element@html:text( <<<<(erlang:atom_to_binary(Name))/binary, " on "/utf8>>/binary, (erlang:atom_to_binary(Node))/binary>> ). -file("/Users/jonas/Projects/spectator/src/spectator/internal/views/display.gleam", 187). -spec system_primitive_interactive( spectator@internal@api:system_primitive(), fun((gleam@erlang@process:pid_()) -> APUL) ) -> lustre@internals@vdom:element(APUL). system_primitive_interactive(Primitive, On_process_click) -> case Primitive of {process_primitive, Pid, Name, Tag} -> pid_button(Pid, Name, Tag, On_process_click); {remote_process_primitive, Name@1, Node} -> named_remote_process(Name@1, Node); {port_primitive, Port_id, Name@2} -> port_link(Port_id, Name@2); {nif_resource_primitive, _} -> lustre@element@html:text(<<"NIF Res."/utf8>>) end. -file("/Users/jonas/Projects/spectator/src/spectator/internal/views/display.gleam", 200). -spec system_primitive(spectator@internal@api:system_primitive()) -> lustre@internals@vdom:element(any()). system_primitive(Primitive) -> case Primitive of {process_primitive, Pid, Name, Tag} -> pid_link(Pid, Name, Tag); {remote_process_primitive, Name@1, Node} -> named_remote_process(Name@1, Node); {port_primitive, Port_id, Name@2} -> port_link(Port_id, Name@2); {nif_resource_primitive, _} -> lustre@element@html:text(<<"NIF Res."/utf8>>) end. -file("/Users/jonas/Projects/spectator/src/spectator/internal/views/display.gleam", 209). -spec function( {gleam@erlang@atom:atom_(), gleam@erlang@atom:atom_(), integer()} ) -> lustre@internals@vdom:element(any()). function(Ref) -> {Module, Function, Arity} = Ref, lustre@element@html:text( <<<<<<<<(erlang:atom_to_binary(Module))/binary, ":"/utf8>>/binary, (erlang:atom_to_binary(Function))/binary>>/binary, "/"/utf8>>/binary, (gleam@int:to_string(Arity))/binary>> ). -file("/Users/jonas/Projects/spectator/src/spectator/internal/views/display.gleam", 221). -spec number(integer()) -> lustre@internals@vdom:element(any()). number(N) -> lustre@element@html:text(gleam@int:to_string(N)).