devtools

package
v0.0.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 3, 2026 License: MIT Imports: 19 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Kite Devtools

The devtools package provides essential debugging and inspection tools for Kite applications. It bridges the gap between terminal UI rendering and standard web-inspired development workflows.

Features

  • DOM Inspector: A web-based inspector that allows real-time visualization of the DOM tree, computed styles, and layout geometry.
  • X-Ray Mode: A visual debugging mode that highlights layout nodes directly in the terminal, useful for diagnosing padding, margins, and border issues.
  • Floating Inspector Window: Automatic launching of a Chromium-based browser in app mode to act as an external inspector dashboard.

Usage

To enable devtools in your Kite application, use the devtools.Install function during your application setup:

import (
    "github.com/masterkeysrd/kite/devtools"
    "github.com/masterkeysrd/kite/engine"
)

func main() {
    eng := engine.New(backend, opts)
    
    // Configure and install devtools
    _, err := devtools.Install(eng, devtools.Options{
        ServerAddr: "127.0.0.1:8080",
    })
    if err != nil {
        log.Fatalf("failed to install devtools: %v", err)
    }
    
    // ... run engine ...
}
Hotkeys
  • F12: Toggles the web inspector (opens browser).
  • Ctrl+D: Toggles X-Ray mode.

Use ToolsHotkey and XRayHotkey to change these shortcuts, or DisableXRay to leave Ctrl+D to the application. The server defaults to localhost:8080 and falls back to an ephemeral loopback port if occupied. Read insp.ServerAddr() on the returned inspector for the bound address. DisableServer: true skips the listener and F12 shortcut; the inspector remains usable and its address is empty.

Inspector Dashboard

When enabled, the inspector dashboard provides:

  1. DOM Tree: Select a logical node and read its identity, viewport origin and size in terminal cells when layout is available.
  2. Computed Styles: Inspect box models and resolved CSS-style properties.
  3. Fragments: Compare a fragment’s local offset with its viewport position.
  4. Layout Visualizer: Inspect the selected element’s box model.
  5. Profiler: Select a timeline span to inspect its phase and duration.

Documentation

Overview

Package devtools provides standard developer tools for Kite applications, including an X-Ray mode for visual debugging and a web-based DOM inspector.

To integrate these tools, call Install(eng, opts) after initializing the engine, before running the frame loop.

Index

Constants

View Source
const (
	DefaultXRayHotkey  = "ctrl+d"
	DefaultToolsHotkey = "f12"
	DefaultServerAddr  = "localhost:8080"
)

Variables

This section is empty.

Functions

func Install

func Install(eng *engine.Engine, opts Options) (*inspector.Inspector, error)

Install registers standard developer tools on the given engine.

func LocateBrowser

func LocateBrowser() string

LocateBrowser finds the path to the first available Chromium-based browser

func OpenFloatingInspector

func OpenFloatingInspector(ctx context.Context, url string) error

OpenFloatingInspector launches a Chromium-based browser in "app" mode if available.

Types

type DevToolsServer

type DevToolsServer struct {
	// contains filtered or unexported fields
}

func NewDevToolsServer

func NewDevToolsServer(eng *engine.Engine, insp *inspector.Inspector) *DevToolsServer

func (*DevToolsServer) Broadcast

func (s *DevToolsServer) Broadcast()

func (*DevToolsServer) HasClients

func (s *DevToolsServer) HasClients() bool

HasClients reports whether any SSE clients are currently connected.

func (*DevToolsServer) SetupRoutes

func (s *DevToolsServer) SetupRoutes(mux *http.ServeMux)

type Options

type Options struct {
	// XRayHotkey is the key combination used to toggle X-Ray mode.
	// Defaults to "ctrl+d" if empty.
	XRayHotkey  string
	DisableXRay bool

	// ServerAddr defaults to DefaultServerAddr unless DisableServer is true.
	// If the requested address is unavailable, a loopback port is chosen automatically.
	ServerAddr    string
	DisableServer bool

	// ToolsHotkey opens the tools dashboard. Defaults to "f12" if empty.
	ToolsHotkey string
}

Options configures the developer tools.

Directories

Path Synopsis
Package inspector captures snapshots of a running Kite application's DOM, layout fragments, and element styles for the DevTools inspector.
Package inspector captures snapshots of a running Kite application's DOM, layout fragments, and element styles for the DevTools inspector.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL