Developer-Dashboard
view release on metacpan or search on metacpan
Bookmark pages now also expose
`fetch_value(url, target, options, formatter)`,
`stream_value(url, target, options, formatter)`, and
`stream_data(url, target, options, formatter)` helpers so a bookmark can bind
saved Ajax endpoints into DOM targets without hand-writing the fetch and
render boilerplate. `stream_data()` and `stream_value()` now use
`XMLHttpRequest` progress events for browser-visible incremental updates, so
a saved `/ajax/...` endpoint that prints early output updates the DOM before
the request finishes. Those helpers support plain text, JSON, and HTML output
modes, and the saved Ajax endpoint bindings now run after the page declares
its endpoint root object, so `$(document).ready(...)` callbacks can call
helpers such as `fetch_value(endpoints.foo, '#foo')` on first render.
Saved browser workspaces that render response inspection panels should place
their Response Body and Response Headers tabs below the response `pre` box so
the main response payload stays visible while the tabbed details remain
reachable without jumping away from the current result.
## User CLI Extensions
Unknown top-level subcommands can be provided by executable files under
the current working directory's `./.developer-dashboard/cli` first, then the
lib/Developer/Dashboard.pm view on Meta::CPAN
Bookmark pages now also expose
C<fetch_value(url, target, options, formatter)>,
C<stream_value(url, target, options, formatter)>, and
C<stream_data(url, target, options, formatter)> helpers so a bookmark can bind
saved Ajax endpoints into DOM targets without hand-writing the fetch and
render boilerplate. C<stream_data()> and C<stream_value()> now use
C<XMLHttpRequest> progress events for browser-visible incremental updates, so
a saved C</ajax/...> endpoint that prints early output updates the DOM before
the request finishes. Those helpers support plain text, JSON, and HTML output
modes, and the saved Ajax endpoint bindings now run after the page declares
its endpoint root object, so C<$(document).ready(...)> callbacks can call
helpers such as C<fetch_value(endpoints.foo, '#foo')> on first render.
Saved browser workspaces that render response inspection panels should place
their Response Body and Response Headers tabs below the response C<pre> box so
the main response payload stays visible while the tabbed details remain
reachable without jumping away from the current result.
=head2 User CLI Extensions
Unknown top-level subcommands can be provided by executable files under
the current working directory's F<./.developer-dashboard/cli> first, then the
lib/Developer/Dashboard/PageRuntime.pm view on Meta::CPAN
return {
stdout => $stdout,
stderr => $stderr,
returns => \@returns,
merge => $state,
};
}
# stream_code_block(%args)
# Executes one CODE block and streams stdout/stderr chunks through callbacks.
# Input: Perl code string, mutable stash hash, runtime context hash, page/source metadata, and writer callbacks.
# Output: hash reference with streamed return values, merged stash, and trailing error text.
sub stream_code_block {
my ( $self, %args ) = @_;
my $code = $args{code} // '';
my $state = $args{state} || {};
my $runtime = $args{runtime_context} || {};
my $sandpit = $args{sandpit};
my $destroy_sandpit = !$sandpit ? 1 : 0;
my $stdout_writer = $args{stdout_writer} || \&_noop_writer;
my $stderr_writer = $args{stderr_writer} || \&_noop_writer;
lib/Developer/Dashboard/PageRuntime.pm view on Meta::CPAN
$self->_destroy_sandpit($sandpit) if $destroy_sandpit;
return {
returns => \@returns,
merge => $state,
error => $error,
};
}
# stream_saved_ajax_file(%args)
# Executes one saved Ajax file as a real process and streams stdout/stderr chunks through callbacks.
# Input: saved file path, request params hash, optional singleton name, page/source metadata, and writer callbacks.
# Output: hash reference with exit_code and process status word.
sub stream_saved_ajax_file {
my ( $self, %args ) = @_;
my $path = $args{path} || die 'Missing saved ajax file path';
my $params = $args{params} || {};
my $stdout_writer = $args{stdout_writer} || \&_noop_writer;
my $stderr_writer = $args{stderr_writer} || \&_noop_writer;
my $singleton = $self->_normalize_saved_ajax_singleton( $params->{singleton} );
$self->_kill_saved_ajax_singleton($singleton) if $singleton ne '';
my @command = $self->_saved_ajax_command( path => $path );
lib/Developer/Dashboard/PageRuntime.pm view on Meta::CPAN
disconnected => $disconnected ? 1 : 0,
exit_code => $status >> 8,
status => $status,
};
}
# _drain_saved_ajax_post_exit_handles(%args)
# Drains any remaining saved-Ajax stdout/stderr chunks after the child has
# already exited so Windows does not lose the final response body when
# IO::Select stops reporting the pipe handles as readable.
# Input: saved file path, select set, stdout fh, and writer callbacks.
# Output: true when all remaining handles were drained, otherwise false when a
# caller-visible writer disconnect stops the stream.
sub _drain_saved_ajax_post_exit_handles {
my ( $self, %args ) = @_;
my $select = $args{select} || die 'Missing select set';
my @handles = $select->can('handles') ? $select->handles : ();
for my $fh (@handles) {
while ( defined $fh && defined fileno($fh) ) {
my $continued = $self->_drain_saved_ajax_ready_handle(%args, fh => $fh);
return 0 if !$continued;
lib/Developer/Dashboard/PageRuntime.pm view on Meta::CPAN
}
# _noop_writer(@parts)
# Accepts streamed output chunks when the caller does not need them.
# Input: zero or more ignored chunk parts.
# Output: empty string.
sub _noop_writer { return '' }
# _drain_saved_ajax_ready_handle(%args)
# Reads one ready saved-Ajax process pipe handle and forwards the chunk or error to the right writer.
# Input: ready fh, active select set, stdout fh, saved file path, and writer callbacks.
# Output: true value when streaming should continue, otherwise false when the client disconnected.
sub _drain_saved_ajax_ready_handle {
my ( $self, %args ) = @_;
my $fh = $args{fh} || die 'Missing ready handle';
my $path = $args{path} || '';
my $select = $args{select} || die 'Missing select set';
my $stdout = $args{stdout} || die 'Missing stdout handle';
my $stdout_writer = $args{stdout_writer} || \&_noop_writer;
my $stderr_writer = $args{stderr_writer} || \&_noop_writer;
my $chunk = '';
lib/Developer/Dashboard/RuntimeManager.pm view on Meta::CPAN
use Developer::Dashboard::CollectorRunner ();
use Developer::Dashboard::InternalCLI ();
use Developer::Dashboard::JSON qw(json_encode json_decode);
use Developer::Dashboard::Platform qw(command_in_path is_windows);
our $SIGNAL_MANAGER;
our $COLLECTOR_SUPERVISOR_MANAGER;
# new(%args)
# Constructs the runtime lifecycle manager.
# Input: config, files, paths, runner, and app_builder objects/callbacks.
# Output: Developer::Dashboard::RuntimeManager object.
sub new {
my ( $class, %args ) = @_;
my $config = $args{config} || die 'Missing config';
my $files = $args{files} || die 'Missing file registry';
my $paths = $args{paths} || die 'Missing path registry';
my $runner = $args{runner} || die 'Missing collector runner';
my $app_builder = $args{app_builder} || die 'Missing app builder';
return bless {
( run in 1.036 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )