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

@docen/layout

v0.7.0

Published

Pure TypeScript layout engine for docen — text line breaking (UAX #14 + CJK kinsoku), OOXML paragraph/table block layout, and flow/fixed/grid strategies with zero DOM dependencies

Readme

@docen/layout

npm version npm downloads npm license

Pure TypeScript layout engine for docen — zero DOM, zero rendering libraries. The inner ring (text/, block/) measures and breaks text and lays out paragraphs/tables; the outer ring builds on it (flow/ — docx page boxing — is in; fixed/ for pptx shape text and grid/ for xlsx come with their editors).

Consumed by @docen/docx's projection (DocumentOptions → LayoutDoc) and painted by @docen/core's canvas stage.

Design

  • Input is a LayoutDoc projection, all-px, style-cascades already resolved. Adapters (docx from Tiptap/ProseMirror, pptx from its shape tree, xlsx from its grid) convert their document units and resolve their style chains exactly once; the engine never sees a styleId, a twip, or a Tiptap node. Only layout semantics keep their OOXML shape (line rules, grid pitch, snap flags) — those are the rules this engine exists to implement.
  • FontMetrics is the measuring seam. The engine works from per-code-unit advances supplied by a FontMetrics provider (browserFontMetrics measures through canvas 2d today; headless and server providers slot into the same interface). Misses fall back with a warning — Word's behavior.
  • One packer for text, hard breaks, and inline pictures — the unified breaker the DOM route never had. UAX #14 line breaking (linebreak.js) with CJK kinsoku, trailing-space hanging, first-line indent, float-zone width reduction, and per-line OOXML line-height semantics (exact / atLeast / multiple × docGrid pitch, CJK ceil snap).
  • Determinism is a contract. Same input → same output every pass — the property the paginator's convergence depends on.

Known boundaries: no GSUB shaping (ligature substitution — advances run slightly wide, conservative for breaking); rowspan cell content counts fully on its start row.

Usage

import { TextMeasurer, browserFontMetrics, layoutBlock } from "@docen/layout";

const measurer = new TextMeasurer(browserFontMetrics);
const laid = layoutBlock(paragraph, 612, { linePitchPx: 25 }, measurer);
// laid.lines — y, height, positioned items, split points

License