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

@vmprint/engine

v1.4.0

Published

Deterministic typesetting engine core. Pure-JS, environment-agnostic document composition.

Downloads

1,119

Readme

@vmprint/engine

The deterministic layout engine at the center of VMPrint.

This package is for developers who already know why they want a layout engine: they want authored structure in, positioned boxes out, and no browser screenshot pipeline pretending to be typesetting.

Primary API

The main surface is VMPrintEngine.

import { VMPrintEngine, loadDocument } from '@vmprint/engine';
import { StandardFontManager } from '@vmprint/standard-fonts';
import { PdfLiteContext } from '@vmprint/context-pdf-lite';

const document = loadDocument(sourceTextOrObject, 'document.json');
const engine = new VMPrintEngine(document, new StandardFontManager());

const { width, height } = engine.info.pageSize;
const context = new PdfLiteContext({
  size: [width, height],
  margins: { top: 0, right: 0, bottom: 0, left: 0 },
  autoFirstPage: false,
  bufferPages: false
});

await engine.render(context);
const pdf: Uint8Array = context.getOutput();

If you want the positioned pages before rendering, call await engine.layout() first. The resulting Page[] is cached and reused by render(). Documents can use layout.pageTemplates to change page dimensions or margins per page; the returned Page[] carries those resolved sizes through to renderers that support per-page media boxes.

For previews and incremental layout tools, layout() also accepts a page limit:

const firstTwoPages = await engine.layout({ stopAtPage: 1 });

stopAtPage is zero-based and inclusive. A value of 1 returns the page prefix through the second physical page and records the run as a "page-limit" stop in the simulation report.

VMPrintEngine is the preferred API going forward, but it is not a hard break with the past. The older low-level bootstrap path built around LayoutEngine, Renderer, createPrintEngineRuntime, and toLayoutConfig is still supported for advanced integrations that want finer control over layout and rendering stages.

What the engine owns

  • Document validation and normalization via loadDocument
  • Font-aware layout through a FontManager
  • Pagination and box generation
  • Per-page geometry resolution from document-level page templates
  • Rendering orchestration into any Context

What stays outside

  • Font acquisition and embedding policy
  • Output transport and file I/O
  • Source-format conversion
  • Overlay logic and tooling concerns

Those seams are described by the engine's exported contract types.

Lower-level surface

The package still exports lower-level pieces such as LayoutEngine, Renderer, SimulationLoop, spatial helpers, and document serialization utilities. They remain supported for tooling, tests, and engine-adjacent integrations, but they are no longer the primary entry point.

Recommended stacks

  • Smallest Node bootstrap: @vmprint/local-fonts + @vmprint/context-pdf
  • Zero-embedded standard-font PDFs: @vmprint/standard-fonts + @vmprint/context-pdf-lite
  • Custom environments: bring your own FontManager and Context

Related material