-module(spectator@internal@views@display). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]). -define(FILEPATH, "src/spectator/internal/views/display.gleam"). -export([pid/1, port/1, inspect/1, atom/1, pid_button/4, pid_link/4, port_link/3, reference/1, storage/1, storage_words/2, storage_detailed/1, bool/1, named_remote_process/2, system_primitive_interactive/3, system_primitive/2, function/1, number/1]). -if(?OTP_RELEASE >= 27). -define(MODULEDOC(Str), -moduledoc(Str)). -define(DOC(Str), -doc(Str)). -else. -define(MODULEDOC(Str), -compile([])). -define(DOC(Str), -compile([])). -endif. ?MODULEDOC(false). -file("src/spectator/internal/views/display.gleam", 16). ?DOC(false). -spec pid(gleam@erlang@process:pid_()) -> lustre@vdom@vnode:element(any()). pid(Pid) -> lustre@element@html:text(spectator_ffi:format_pid(Pid)). -file("src/spectator/internal/views/display.gleam", 146). ?DOC(false). -spec port(gleam@erlang@port:port_()) -> lustre@vdom@vnode:element(any()). port(Port) -> lustre@element@html:text(spectator_ffi:format_port(Port)). -file("src/spectator/internal/views/display.gleam", 172). ?DOC(false). -spec inspect(gleam@dynamic:dynamic_()) -> lustre@vdom@vnode:element(any()). inspect(D) -> lustre@element@html:text(gleam@string:inspect(D)). -file("src/spectator/internal/views/display.gleam", 176). ?DOC(false). -spec atom(gleam@erlang@atom:atom_()) -> lustre@vdom@vnode:element(any()). atom(A) -> lustre@element@html:text(erlang:atom_to_binary(A)). -file("src/spectator/internal/views/display.gleam", 20). ?DOC(false). -spec pid_button( gleam@erlang@process:pid_(), gleam@option:option(gleam@erlang@atom:atom_()), gleam@option:option(binary()), fun((gleam@erlang@process:pid_()) -> ACML) ) -> lustre@vdom@vnode:element(ACML). 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("src/spectator/internal/views/display.gleam", 73). ?DOC(false). -spec pid_link( gleam@erlang@process:pid_(), gleam@option:option(gleam@erlang@atom:atom_()), gleam@option:option(binary()), list({binary(), binary()}) ) -> lustre@vdom@vnode:element(any()). pid_link(Pid, Name, Tag, Params) -> case {Name, Tag} of {none, none} -> lustre@element@html:a( [lustre@attribute:href( <<"/processes"/utf8, (begin _pipe = spectator@internal@common:add_param( Params, <<"selected"/utf8>>, spectator@internal@api:serialize_pid(Pid) ), spectator@internal@common:encode_params(_pipe) end)/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"/utf8, (begin _pipe@1 = spectator@internal@common:add_param( Params, <<"selected"/utf8>>, spectator@internal@api:serialize_pid(Pid) ), spectator@internal@common:encode_params(_pipe@1) end)/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"/utf8, (begin _pipe@2 = spectator@internal@common:add_param( Params, <<"selected"/utf8>>, spectator@internal@api:serialize_pid(Pid) ), spectator@internal@common:encode_params(_pipe@2) end)/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"/utf8, (begin _pipe@3 = spectator@internal@common:add_param( Params, <<"selected"/utf8>>, spectator@internal@api:serialize_pid(Pid) ), spectator@internal@common:encode_params(_pipe@3) end)/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"/utf8, (begin _pipe@4 = spectator@internal@common:add_param( Params, <<"selected"/utf8>>, spectator@internal@api:serialize_pid(Pid) ), spectator@internal@common:encode_params(_pipe@4) end)/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("src/spectator/internal/views/display.gleam", 150). ?DOC(false). -spec port_link( gleam@erlang@port:port_(), gleam@option:option(gleam@erlang@atom:atom_()), list({binary(), binary()}) ) -> lustre@vdom@vnode:element(any()). port_link(Port, Name, Params) -> 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"/utf8, (begin _pipe = spectator@internal@common:add_param( Params, <<"selected"/utf8>>, spectator@internal@api:serialize_port(Port) ), spectator@internal@common:encode_params(_pipe) end)/binary>> )], [lustre@element@html:text(Label)] ). -file("src/spectator/internal/views/display.gleam", 180). ?DOC(false). -spec reference(gleam@erlang@reference:reference_()) -> lustre@vdom@vnode:element(any()). reference(Ref) -> lustre@element@html:text(gleam@string:inspect(Ref)). -file("src/spectator/internal/views/display.gleam", 188). ?DOC(false). -spec storage(integer()) -> lustre@vdom@vnode:element(any()). storage(Size) -> case Size of _ when Size < 1024 -> lustre@element@html:text( <<(erlang:integer_to_binary(Size))/binary, " B"/utf8>> ); _ when Size < 1048576 -> lustre@element@html:text( <<(erlang:integer_to_binary(Size div 1024))/binary, " KiB"/utf8>> ); _ -> lustre@element@html:text( <<(erlang:integer_to_binary((Size div 1024) div 1024))/binary, " MiB"/utf8>> ) end. -file("src/spectator/internal/views/display.gleam", 184). ?DOC(false). -spec storage_words(integer(), integer()) -> lustre@vdom@vnode:element(any()). storage_words(Words, Word_size) -> storage(Words * Word_size). -file("src/spectator/internal/views/display.gleam", 196). ?DOC(false). -spec storage_detailed(integer()) -> lustre@vdom@vnode:element(any()). storage_detailed(Size) -> Byte_size = <<(erlang:integer_to_binary(Size))/binary, " Bytes"/utf8>>, case Size of _ when Size < 1024 -> lustre@element@html:text(Byte_size); _ when Size < 1048576 -> lustre@element@html:text( <<<<<>/binary, (erlang:integer_to_binary(Size div 1024))/binary>>/binary, " KiB)"/utf8>> ); _ -> lustre@element@html:text( <<<<<>/binary, (erlang:integer_to_binary((Size div 1024) div 1024))/binary>>/binary, " MiB)"/utf8>> ) end. -file("src/spectator/internal/views/display.gleam", 209). ?DOC(false). -spec bool(boolean()) -> lustre@vdom@vnode:element(any()). bool(B) -> case B of true -> lustre@element@html:text(<<"true"/utf8>>); false -> lustre@element@html:text(<<"false"/utf8>>) end. -file("src/spectator/internal/views/display.gleam", 216). ?DOC(false). -spec named_remote_process(gleam@erlang@atom:atom_(), gleam@erlang@atom:atom_()) -> lustre@vdom@vnode: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("src/spectator/internal/views/display.gleam", 220). ?DOC(false). -spec system_primitive_interactive( spectator@internal@api:system_primitive(), fun((gleam@erlang@process:pid_()) -> ACNC), list({binary(), binary()}) ) -> lustre@vdom@vnode:element(ACNC). system_primitive_interactive(Primitive, On_process_click, Params) -> 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, Params); {nif_resource_primitive, _} -> lustre@element@html:text(<<"NIF Res."/utf8>>) end. -file("src/spectator/internal/views/display.gleam", 234). ?DOC(false). -spec system_primitive( spectator@internal@api:system_primitive(), list({binary(), binary()}) ) -> lustre@vdom@vnode:element(any()). system_primitive(Primitive, Params) -> case Primitive of {process_primitive, Pid, Name, Tag} -> pid_link(Pid, Name, Tag, Params); {remote_process_primitive, Name@1, Node} -> named_remote_process(Name@1, Node); {port_primitive, Port_id, Name@2} -> port_link(Port_id, Name@2, Params); {nif_resource_primitive, _} -> lustre@element@html:text(<<"NIF Res."/utf8>>) end. -file("src/spectator/internal/views/display.gleam", 243). ?DOC(false). -spec function( {gleam@erlang@atom:atom_(), gleam@erlang@atom:atom_(), integer()} ) -> lustre@vdom@vnode: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, (erlang:integer_to_binary(Arity))/binary>> ). -file("src/spectator/internal/views/display.gleam", 255). ?DOC(false). -spec number(integer()) -> lustre@vdom@vnode:element(any()). number(N) -> lustre@element@html:text(erlang:integer_to_binary(N)).