NAME
Chandra::DevTools - In-browser developer tools for Chandra applications
SYNOPSIS
use Chandra::App;
my $app = Chandra::App->new(title => 'My App', debug => 1);
# Enable DevTools (auto-enabled via $app->devtools)
$app->devtools->on_reload(sub {
$app->set_content(build_ui());
$app->refresh;
});
$app->set_content('<h1>Hello</h1>');
$app->run;
# Toggle DevTools with F12 or Ctrl+Shift+I in the browser
DESCRIPTION
Chandra::DevTools injects an in-browser developer panel into your Chandra application. The panel provides:
- Console - Perl error log with stack traces and JS errors
- Bindings - List of Perl functions bound to JavaScript
- Elements - Live DOM tree inspector
- Reload - Trigger a reload callback to refresh content
The panel is toggled with F12 or Ctrl+Shift+I.
Errors captured by Chandra::Error are automatically forwarded to the console panel when DevTools is enabled.
METHODS
new(%args)
Create a new DevTools instance. Usually accessed via $app->devtools.
enable($app)
Activate DevTools: register helper bindings and error forwarding.
disable()
Deactivate DevTools and hide the panel.
inject($app)
Inject the DevTools JavaScript into the webview.
is_enabled()
Return true if DevTools is currently enabled.
on_reload($coderef)
Register a callback invoked when the Reload button is clicked.
toggle() / show() / hide()
Control panel visibility from Perl.
log($message) / warn($message)
Send informational or warning messages to the DevTools console.
js_code()
Return the raw DevTools JavaScript for manual injection.