npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@printedjs/devtools

v0.2.3

Published

Diagnostic tracing and developer HUD overlay for Printedjs.

Readme

@printedjs/devtools

Diagnostic tracing and developer HUD overlay for Printedjs.

@printedjs/devtools provides lifecycle performance instrumentation, trace event collection, and an unobtrusive visual inspection overlay for document layout debugging.


Features

  • Lifecycle Phase Tracing (devtoolsPlugin) — Records high-resolution timestamps for style transformation, DOM parsing, layout steps, and plugin execution.
  • Trace Event Collector (TraceCollector) — Collects structured events and outputs a comprehensive TraceReport including phase durations and page counts.
  • Non-Print Visual Overlay (createDevtoolsOverlay) — Injects a lightweight fixed diagnostic HUD into the preview container displaying page count and total render time without interfering with print styles.

Installation

pnpm add -D @printedjs/devtools @printedjs/core

Usage

1. Tracing Lifecycle Performance

Attach devtoolsPlugin to monitor and benchmark document layout:

import { createRenderer } from "@printedjs/browser";
import { devtoolsPlugin, type TraceReport } from "@printedjs/devtools";
import { standardPreset } from "@printedjs/plugins";

const renderer = createRenderer({
	target: document.querySelector("#preview")!,
	plugins: [
		devtoolsPlugin({
			onReport: (report: TraceReport) => {
				console.log(
					`Rendered ${report.pageCount} pages in ${report.totalDurationMs.toFixed(1)}ms`,
				);
				console.table(report.events);
			},
		}),
		...standardPreset(),
	],
});

await renderer.render({
	content: { html: documentSource },
});

2. Diagnostic HUD Overlay & Hover Inspector

Display an on-screen diagnostic HUD with interactive element inspection and visual page guides:

import { createDevtoolsOverlay } from "@printedjs/devtools";

const container = document.querySelector("#preview") as HTMLElement;

// Create HUD overlay with hover inspection and page guides enabled
const overlay = createDevtoolsOverlay(container, {
	inspectEnabled: true,
	guidesEnabled: true,
	onInspect: (metrics) => {
		if (metrics) {
			console.log(`Inspecting ${metrics.selector} on Page ${metrics.pageNumber}`);
		}
	},
});

// Toggle features programmatically:
overlay.setInspectEnabled(false);
overlay.setGuidesEnabled(true);

// Clean up when destroying preview:
overlay.destroy();

API Reference

createDevtoolsOverlay(container: HTMLElement, options?: DevtoolsOverlayOptions | TraceReport): DevtoolsOverlay

Renders an on-screen HUD badge in the bottom-right corner of the container with interactive [Inspect] and [Guides] buttons.

  • Returns { element, hoverInspector, pageGuides, setInspectEnabled, setGuidesEnabled, updateReport, destroy }.

createHoverInspector(container: HTMLElement, options?: HoverInspectorOptions): HoverInspector

Creates an interactive pointer tracker that renders a multi-layer box model overlay (margin, border, padding, content) and a floating print diagnostics tooltip over hovered elements.

  • Returns { enable(), disable(), isEnabled(), destroy() }.

createPageGuides(container: HTMLElement, initialEnabled?: boolean): PageGuides

Injects and manages non-invasive CSS paged media guide styles:

  • Dashed outlines and labels for all 16 margin boxes (@top-left .. @bottom-right).
  • Outlines for sheet trim boundaries and bleed zones.
  • Split continuity markers for [data-split-to] and [data-split-from].

extractPrintMetrics(element: HTMLElement): ElementPrintMetrics | null

Extracts computed print metrics for any element inside a .printedjs_page:

  • Selector, tag name, ID, and classes.
  • Physical dimensions in px and mm.
  • Page number and total pages.
  • Four-layer box model (margin, border, padding, content).
  • Break constraints (break-inside, break-before, break-after, split flags).
  • Vertical clearance: Remaining space in px and mm before the page bottom margin.

devtoolsPlugin(options?: DevtoolsPluginOptions): PrintedjsPlugin

Creates a Printedjs plugin that records lifecycle trace events.

  • options.onReport?: (report: TraceReport) => void — Callback invoked with the final trace report after pagination completes.

TraceCollector

Standalone collector class:

  • start(): void — Resets collector and records start timestamp.
  • recordEvent(event: TraceEvent): void — Adds a phase or warning event.
  • generateReport(pageCount: number): TraceReport — Compiles and returns all recorded events with total duration.

License

MIT